Sieve language

The Sieve filter language was originally defined in RFC 3028 (Sieve: A Mail Filtering Language), since updated by RFC 5228 (Sieve: An Email Filtering Language). The Sieve language provides a way to analyze Internet format messages (RFC 822 messages), and perform processing appropriate for performing upon message delivery. Such processing might include: filing those messages meeting specified criteria into special folders rather than simply delivering into the INBOX, redirecting (so-called "forwarding") messages meeting specified criteria to additional recipients, setting IMAP flags for messages meeting specified criteria, generating new notification messages when certain sorts of messages are delivered, returning "vacation" messages, discarding messages matching specified criteria, etc. Additional RFCs, proposed extensions, and MTA-private extensions, have further extended and modified the Sieve language; see Sieve supported extensions for a list.

The RFCs defining standard Sieve features, and the Internet drafts for proposed Sieve extensions, are the most definitive resource for undering Sieve language syntax. For RFCs, see http://tools.ietf.org/rfc/ and for Internet drafts, search in the "Individual Submissions" area at http://tools.ietf.org/id/ Here follows a very brief overview of Sieve.

A Sieve script consists of a sequence of commands. Commands are tests,  actions, or  control structures. (There are some special cases in the MTA&#x27;s Sieve implementation, as for instance the MTA allows  " " to be used not only in its standard  capacity as a test, but also as a function call.  And new in  MS 8.0,  the MTA supports private operators  " "  and  " "  which have uses both as actions  and as tests.)  Many actions and tests may take arguments, both  positional and tagged, or have modifiers.

The values in Sieve scripts are generally strings or non-negative integers. However, values are also subject to a few alternate forms; see in particular the    and    extensions. And the MTA&#x27;s Sieve implementation supports use of signed integers (and in particular,  negative integers). Furthermore, the MTA&#x27;s Sieve implementation supports the use of expressions  in places where the base Sieve  specification expects values.

Many Sieve extensions, both standard and at proposal stage, plus additional extensions private-to-the-MTA, are supported by the MTA, adding  various additional actions, commands, and control structures to the  base Sieve language.  Extensions, especially standardized extensions, generally need to be enabled using a " "  control structure. An attempt to use an invalid action, test, or control structure will result in an " " error. As of MS 7.0, the MTA supports the Sieve " " extension, which allows Sieve scripts to test which extensions are available. An attempt to " " an unsupported or unenabled Sieve extension will result in an " " error.  (Such errors are reported in an email message to the Sieve "owner" -- the user to whom the Sieve belongs in the case of user-level Sieves, or the postmaster in the case of system-level Sieves.)

Note that in addition to supporting private extensions, more generally the MTA also supports an extended Sieve syntax, including allowing  expressions where Sieve expects arguments, and  allowing  assignment statements. The MTA also supports extending the Sieve language via custom tests defined via MTA mapping tables. And because the MTA&#x27;s Sieve implementation is built on top of the MTA&#x27;s implementation of string and mathematical operation processing, the MTA&#x27;s Sieve implementation supports some string functions and mathematical functions  (and supports additional numeric forms, such as negative integers) not part of the base Sieve specification.

Note that as the Sieve filter language has been undergoing rather rapid development, support for additional language elements will likely be added in future. See release notes for current versions of the MTA software for notices of additional language element support.

See also:
 * Sieve memcache extension
 * Sieve metermaid extension
 * Sieve expressions
 * Sieve custom tests via mappings
 * Sieve filters
 * Brief overview of Sieve language elements
 * Sieve supported extensions
 * Sieve environment extension