Email - sieve


sieve is a programming language that is used to create mail filters. Our Local Delivery Agent (LDA) uses a sieve plugin to allow mail filtering. The sieve code goes in a file .dovecot.sieve which is located in your home directory on the login server,which is tau.phas.ubc.ca in 2016-03-01 (/mail/$HOME/). A user with username "fred" and login directory /home/fred would login to tau & $edit  /mail/home/fred/.dovecot.sieve

Incorrect sieve code can cause mail delivery to fail. Please ensure your sieve code works; use the sieve testers as explained below.

PHAS Default .dovecot.sieve File

All phas mail accounts will be get the following sieve file upon creation. You can open this file with any text editor. This filters all messages with a Header line of X-Spam-Level and with 3 or more X's. This line and others are added by the Sophos anti-spam software run on the UBC mail-relays. The message is filed in a mailbox called SPAM_PMX; it will not appear in your inbox. You can/should check this folder periodically for false positives. If the matching condition is NOT met the filter executes an implicit keep command & files the message into inbox.

PHAS Default .dovecot.sieve File

# Sieve Filter require["fileinto","regex","envelope","vacation"]; if anyof ( # puremsg scores (30% or higher) header :matches ["X-Spam-Level"] ["XXX*"] ) { fileinto "SPAM_PMX"; stop; }

Other sieve Examples

We present here some common examples of mail filtering with sieve. For further details and more examples sieve.info.
Header Line: most sieve filters will include a require line enumerating the optional commands the script may use.

# Sieve Filter require ["fileinto","regex","envelope","vacation"];

WhiteLists

If you find that messages from a correspondent are matching the Spam filtering & not being delivered to your inbox, you can white list that correspondent. This snippet should be placed above the Spam filter.

if header :contains "From" ["s.harper@somewhere.com"] { keep; stop; }

Whitelist an entire mail domain by matching the domain part of the From Address

if address :is :domain "from" "example.ca" { keep; stop; }

BlackLists

You continuely get messages that you do not want to read & they do not caught by the Spam filtering; you can Black list

if header :contains "From" ["abc@somewhere.com", "badguy@xyz.ubc.ca"] { discard; }

Vacation Message

You're on vacation ( at last !!) & you want your mail correspondents know that you may not being answering email.

# Sieve Filter require ["fileinto","regex","envelope","vacation"]; if not header :contains "Precedence" ["bulk","list"] { vacation # Reply at most once a day to a same sender :days 1 # List of recipient addresses which are included in the auto replying. # If a mail's recipient is not on the address list , # no vacation reply is sent :addresses ["jblow@phas.ubc.ca","Joe.Blow@ubc.ca"] :subject "Joe is away from his mail" # next is the message contents... "I will be away until sometime in the future. For immediate assistance, please call your friendly, local neighborhood spiderman. Joe Blow. "; } fileinto "INBOX";

Forwarding

To forward all unfiltered messages to another account add the following line at the end of your .dovecot.sieve file:

redirect "user@site.domain";

External Sieve Resources

Please consult the following references or contact one of the ITstaff for more information on using sieve.

Sieve Help

Website development by Checkmark Media. Designed by Armada.

a place of mind, The University of British Columbia

Faculty of Science
Department of Physics and Astronomy
6224 Agricultural Road
Vancouver, BC V6T 1Z1
Tel 604.822.3853
Fax 604.822.5324

Emergency Procedures | Accessibility | Contact UBC | © Copyright The University of British Columbia