Sieve (mail filtering language)

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Template:Short description Script error: No such module "about". Script error: No such module "Unsubst". Script error: No such module "Infobox".Template:Template otherScript error: No such module "Check for unknown parameters".Template:Main other 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 generalizes to other systems that meet these criteria. The current version of Sieve's base specification is outlined in RFC 5228, published in January 2008.

Language

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.

While Sieve has many limitations – the base standard has no variables and no loops – it does allow conditional branching, preventing runaway programs. These limitations generally confine the language to simple filtering operations. Although extensions have been devised to extend the language to include variables and, limited 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.

While Sieve was originally conceived as tool external to SMTP,[1][2] Template:IETF RFC precognitively extends it in order to allow rejection at the SMTP protocol level.[3]

Use

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 Template:IETF RFC) 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 Template:Not a typo file in the users' home directories.

History

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

Extensions

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

  • Template:IETF RFC – Copying without side effects; allows a script to be copied across mailboxes without halting the script.
  • Template:IETF RFC – Body; allows a script to test the body of a message, not just its header.
  • Template:IETF RFC – Environment; provides access to information about the Sieve interpreter and its system environment.
  • Template:IETF RFC – Variables; allows the script to save and retrieve values in variables.
  • Template:IETF RFC – Vacation; specifies an action to send a response informing the sender that the recipient may be away.
  • Template:IETF RFC – Relational tests; defines numeric tests, so that a script may test a field for a numeric value, and may test against the number of occurrences of a field.
  • Template:IETF RFC – IMAP4flags; allows a script to test and set a message's IMAP flags.
  • Template:IETF RFC – Subaddress; allows a script to test subaddresses of the form "user+detail@domain.example".
  • Template:IETF RFC – Spamtest and Virustest; allows a script to interface with implementation
  • Template:IETF RFC – Date and Index Extensions.
  • Template:IETF RFC – Editheader; allows a script to add and delete message header fields.
  • Template:IETF RFC – Reject; allows messages to be rejected at either the LMTP/SMTP level or with an MDN or DSN.
  • Template:IETF RFC – Notifications; allows a script to trigger external notifications of email.
  • Template:IETF RFC – Notifications; allows notifications to be sent via the mailto protocol
  • Template:IETF RFC – XMPP notifications; specifies notifications via XMPP.
  • Template:IETF RFC – Checking; Mailbox status and accessing mailbox metadata.
  • Template:IETF RFC – MIME Part Tests, Iteration, Extraction, Replacement, and Enclosure
  • Template:IETF RFC – A Protocol for Remotely Managing Sieve Scripts
  • Template:IETF RFC – Vacation; adds the ability to specify seconds in a vacation time period.
  • Template:IETF RFC – MIME part conversion; allows a script to convert body parts between MIME types.
  • Template:IETF RFC – Script inclusion; allow a user to include one script inside another.
  • Template:IETF RFC - Detecting Duplicate Deliveries; allows a script to detect duplicate messages and define custom behavior in those cases.

A number of other extensions are still being developed by the Sieve working group.Script error: No such module "Unsubst".

Example

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.
Thanks.";
}

# 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 an "implicit keep" rule
#
else {
     keep;
}

See also

References

Template:Reflist

External links

  1. That Sieve operates after message acceptance is in its defining document: Template:Cite IETF
  2. That final delivery is outside SMTP is in its defining document: Template:Cite IETF
  3. Template:Cite IETF
  4. Sieve working group charter Template:Webarchive