Sieve (mail filtering language)

Sieve is a programming language that can be used for email filtering. It owes its creation to the CMU Cyrus Project, creators of Cyrus IMAP server.

The language is not tied to any particular operating system or mail architecture. It requires the use of RFC 2822-compliant messages, but otherwise should generalize to other systems that meet these criteria. The current version of Sieve's base specification is outlined in RFC 5228, published in January 2008.


Sieve is a data-driven programming language, similar to earlier email filtering languages such as procmail and maildrop, and earlier line-oriented languages such as sed and AWK: it specifies conditions to match and actions to take on matching.

This differs from general-purpose programming languages in that it is highly limited – the base standard has no variables, and no loops (but does allow conditional branching), preventing runaway programs and limiting the language to simple filtering operations. Although extensions have been devised to extend the language to include variables and, to a limited degree, loops, the language is still highly restricted, and thus suitable for running user-devised programs as part of the mail system.

There are also a significant number of restrictions on the grammar of the language, in order to reduce the complexity of parsing the language, but the language also supports the use of multiple methods for comparing localized strings, and is fully Unicode-aware.


The Sieve scripts may be generated by a GUI-based rules editor or they may be entered directly using a text editor.

The scripts are transferred to the mail server in a server-dependent way. The ManageSieve protocol (defined in RFC 5804) allows users to manage their Sieve scripts on a remote server. Mail servers with local users may allow the scripts to be stored in e.g. a .sieve file in the users' home directories.


The language was standardized in the (now-obsolete) RFC 3028 of January 2001, by Tim Showalter.


The IETF Sieve working group[1] has updated the base specification in 2008 (RFC 5228), and has brought the following extensions to Proposed Standard status:

A number of other extensions are still being developed by the Sieve working group.


This is an example sieve script:

# Sieve filter

# Declare the extensions used by this script.
require ["fileinto", "reject"];

# Messages bigger than 100K will be rejected with an error message
if size :over 100K {
   reject "I'm sorry, I do not accept mail over 100kb in size. 
Please upload larger files to a server and send me a link.

# Mails from a mailing list will be put into the folder "mailinglist" 
elsif address :is ["From", "To"] "mailinglist@blafasel.invalid" {
   fileinto "INBOX.mailinglist";

# Spam Rule: Message does not contain my address in To, CC or Bcc
# header, or subject is something with "money" or "Viagra".
elsif anyof (not address :all :contains ["To", "Cc", "Bcc"] "me@blafasel.invalid", 
header :matches "Subject" ["*money*","*Viagra*"]) {
      fileinto "INBOX.spam";

# Keep the rest.
# This is not necessary because there is a "implicit keep" Rule
else {

See also


External links

This article is issued from Wikipedia - version of the 12/2/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.