Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1493805
  • 博文数量: 408
  • 博客积分: 10036
  • 博客等级: 上将
  • 技术积分: 4440
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-06 13:57
文章分类

全部博文(408)

文章存档

2011年(1)

2010年(2)

2009年(1)

2008年(3)

2007年(7)

2006年(394)

我的朋友

分类: LINUX

2006-04-20 14:32:07

Check the

Filtering email with Sieve

Sieve allows you to filter your mail on the server. This means that your rules will be applied to your mail regardless of where you view it (e.g. if you use webmail at home, the filtering will still be applied to your account).

  • Developing Sieve scripts
    • - Deleting Spam
    • - Filtering Spam
    • - Vacation messages
    • - Locally scoped vacation messages
    • - General filtering example
  • - Brief technical overview

 

1. Introduction

Sieve is a proposed internet-standard language for filtering mail at the time of final delivery. It is a server-side filtering mechanism. It is officially documented at .

Sieve is a language that can be used to create filters for electronic mail. Based on a series of matching rules that work from the message headers, Sieve scripts can discard mail, redirect the message to another address or file mail into a specific folder. The Cyrus IMAP server used at the University of Bath enables server-side mail filtering.

To get an understanding of this it has to be contrasted with client-side filtering. Most modern email reading, or client, software facilitates the creation of filtering rules. These are triggered when the user launches the mail reading program and logs onto the email server. The client program has to be running and the user has to be logged into the server for the rules to be obeyed. Client-side filtering has its uses but is severely constrained. For example, the concept of vacation mail is infeasible with client-side filtering. With server-side filtering, vacation mail is possible and your filtering rules take effect regardless of which machine or mail reader you use or whether you are logged into the server.

Users can write one or more scripts and install them on the IMAP server using the command sieve which is available on The Mulberry email client can also be used to write and upload Sieve scripts. See for more information.

2. Installing a Sieve Script

Write your Sieve script, or scripts, using any tools you like. You can use the below or write from scratch using your favorite text editor. If using the Mulberry Graphical User Interface (GUI) to develop Sieve scripts please refer to for instructions.

If writing from scratch the working directory is the .sieve (dot sieve) directory directly off your home directory. Store your sieve scripts in this .sieve directory. Give them names like normal or vacation.

Log on to a . Change to your .sieve directory where your scripts are kept. If you don't already have a .sieve directory or folder create one. Upload your script to the IMAP server using the :

amos [~] $ sieve
connecting to imaphost.bath.ac.uk
help - this screen
list - list scripts on server
put  - upload script to server
get  [] - get script. If no filename display to screen
delete  - delete script.
activate  - set a script as the active script
deactivate - deactivate all scripts
quit - quit
>>>

From the prompt you can put your script onto the server, put xxx, activate your script, activate xxx, or list your scripts, list. xxx being the actual name of your script. Note that although you may have up to five scripts installed on the IMAP server only one may be active at any one time. Using the list command will display your uploaded scripts and their status - eg:

>>> list
forwardmail
newrbl <- active script
nospam
spam
vacation

In this case the script called 'newrbl' is the active script.

3. Developing Sieve scripts

Sieve scripts are just a series of instructions written in plain text which tell the Sieve engine what to do with your incoming email. Although designed to be simple to use Sieve scripting is a programming language so to gain effective use of it familiarity with basic programming code and concepts is required. Those who attempt to develop and use a Sieve script from scratch, should be familiar with basic scripting and with Sieve specifically. See for more information.

For those wishing to implement specific filters there are commands available for installing and .

4. Examples

Some examples will offer a brief overview of the Sieve scripting language:

Example 1: This sieve script will silently discard most spam. This is the script that is installed by running the command.

if exists "X-RBL-Warning" {
  discard;
  stop;
}
if exists "X-Spam-Flag" {
  discard;
  stop;
}

Example 2: This script will filter most spam to a mail folder called spam. This is the script that is installed by running the command. Note the mandatory declaration require "fileinto" required for all local mailbox filtering operations.

require "fileinto";
if exists "X-RBL-Warning" {
  fileinto "INBOX.spam";
  stop;
}
if exists "                                   
阅读(1244) | 评论(0) | 转发(0) |
0

上一篇:Filtering email with Sieve

下一篇:SieveExamples

给主人留下些什么吧!~~