Difference between revisions of "Email sieve"

From Cncz
Jump to: navigation, search
(case)
([Voorbeelden van Sieve-scripts][Examples of Sieve-scripts])
Line 53: Line 53:
 
         fileinto "INBOX.Virus";
 
         fileinto "INBOX.Virus";
 
         stop;
 
         stop;
 +
}
 +
if address :is ["From", "To"] [
 +
              "Symposium2008@science.ru.nl",
 +
              "New-symposium2008@science.ru.nl"
 +
        ]
 +
{
 +
        fileinto "INBOX.Symposium2008";
 +
        stop;
 
  }
 
  }
 
  include "spam";
 
  include "spam";

Revision as of 14:55, 28 April 2008

Sieve

If one wants incoming mail to be sorted into folders automatically or to be filtered in some special way, one can use "Sieve" if one has the IMAP-server post.science.ru.nl as incoming mailserver. The Sieve language is described in RFC3028. Below are instructions to activate a Sieve-script:

  • Log in to "solo.science.ru.nl" (or "solost.science.ru.nl" for students)
  • Type:
        /usr/local/cyrus-imapd/bin/sieveshell post.science.ru.nl

and give your password.

  • If you type a '?', you see what to do:
        Usage:
          sieveshell [-u username] [-a authname] [-r realm] <server>
        help             - this screen
        list             - list scripts on server
        put <filename> [<target name>]
                         - upload script to server
        get <name> [<filename>]
                         - get script. if no filename display to stdout
        delete <name>    - delete script
        activate <name>  - set a script as the active script
        deactivate       - deactivate all scripts
        quit             - quit

This is an ftp-like interface to view (get) or upload (put) scripts. One has to be a bit careful changing such a script, because it is quite easy to lose new mail this way.

Examples of Sieve-scripts

  • If some mail should be sorted automatically into an existing folder, one can use a script like:

require [ "fileinto", "include" ];
#
# Messages into folders.
#
if header :contains "X-VirusscanResult" "infected" {
        fileinto "INBOX.Virus";
        stop;
}
if address :is ["From", "To"] [
              "",
              ""
        ]
{
        fileinto "INBOX.Symposium2008";
        stop; 
}
include "spam";
include "vacation";

If one wants to redirect all mail that remains after our spamfilter has done its job, one has to add after the include "spam"; line:

redirect "";