Sieve is a mail filtering language for sorting e-mail. It is used by the Cyrus IMAP server for server-side mail sorting. Cyrus is the IMAP server at several Nada mail servers, most notably mail1.nada.kth.se. This document describes shortly how to use Sieve to sort your e-mail on delivery and provides pointers to more information.
Sieve is a language for e-mail filtering, originally designed by Tim Showalter. It is designed to be both useful and limited enough to avoid problems in server-side filtering systems. It is a proposed Internet Standard but not accepted as such up to this date. The drafts are the primary descriptions of the language and are available below.
Cyrus is the IMAP server we currently use at Nada on the server mail1.nada.kth.se. It it a "sealed" server in that the spool is only exported over the IMAP and POP3 protocols, and that e-mail accounts need not correspond to actual users on the machine. More information on the installation itself and administration of it is available in Swedish on the page Cyrus på Nada. The Cyrus server includes an implementation of the Sieve language and tools to transfer sieve-scripts to the server.
The tools for checking sieve-scripts and upload them to the server are located in the cyrus module. To get you environment set up type the command:
module add cyrus
The command for manipulating sieve scripts is installsieve. Currently you have to tell it explicitly to use kerberos authentication for it to work, so all use of the installsieve command will start with:
installsieve -m kerberos_v4
You can keep several scripts (currently five) on the server, however only one of them can be active at a time. You control which with installsieve. The actions you can do with installsieve include:
installsieve -m kerberos_v4 -i script mail1Listing installed scripts:
installsieve -m kerberos_v4 -l mail1Show the contents of the active script:
installsieve -m kerberos_v4 -v mail1Get the contents of a script:
installsieve -m kerberos_v4 -g <script name> mail1
Note that the script for some unknown reason will be saved with the extension .script. To install it on the server again you thus have to specify the file name <script name>.script. The .script extension will be stripped off and the name of the installed script be the same as before.
Set an installed script as active:installsieve -m kerberos_v4 -a script mail1Deleting an installed script:
installsieve -m kerberos_v4 -d script mail1
Read the man page for more information and options.
There is a small utility to test the syntax of sieve-scripts as well as check what actions a script causes given specific e-mail. There is no man-page available for sieve-test. It reads a script from STDIN and applies it to given e-mail. Checking on actions only applies to actions based on the contents of the e-mail, some actions are based on the so called envelope of the e-mail which is supplied to Cyrus by LMTP, and hence is hard to test for other than actually sending the script to the server. The syntax check still applies though. Syntax is also checked by the server when you try to submit your script.
To only check the syntax of a script use:
sieve-test < sieve-script
To check the syntax and actions use:
sieve-test mail-message < sieve-script
For details on sieve scripting, refer to the draft below. A general rule is that if no rule matches, the server will do an "implicit keep", which means that the mail will be delivered to your INBOX.
A simple example is provided here. It uses the "fileinto" extension to sort incoming e-mail from a couple of mail-lists into their respective folders upon delivery. All other mail will be delivered to the INBOX due to the implicit keep. Note that the Cyrus mail-server uses "." as hierarchy separator. More information about the syntax and the different actions is available in the draft.
require "fileinto";
if address :contains ["to","from","cc","bcc"] "ratatosk" {
fileinto "INBOX.mail-lists.tkrat";
}
elsif address :contains ["to","from","cc","bcc"] "info-cyrus" {
fileinto "INBOX.mail-lists.info-cyrus";
}
Sieve has a vacation functionality that is similar the "vacation" program on Unix. Below is an examle of a vacation script. It can be combined with other rules for more selective actions. More information on vacation is available in the draft.
Note that you currently have to supply your email address with the :addresses tag for vacation to work.
require "vacation";
vacation :days 7 :addresses "fjo@nada.kth.se"
"Jag är bortrest för tillfället, men läser ditt meddelande
så snart jag kan.";
To forward your mail to some other address, use the "redirect" action. It is part of the standard language so you don't need to "require" anything.
redirect "my-address@somewhere.else.com";