Brief overview of Sieve language elements

From Messaging Server Technical Reference Wiki
Jump to: navigation, search


For convenience, Sieve language elements provides a tabular overview of Sieve language elements, grouped into:

Sieve language elements summarizes the basic Sieve language elements (but not the subelements that are standard under an element), plus any supported extension elements and extension subelements. For full descriptions of Sieve language elements, see the referenced RFCs and drafts. In Table of Sieve language elements, arguments/values are shown in italics, optional elements are enclosed in square brackets ([]), choices are enclosed in angle brackets (<>) with the distinct choices separated by the forward slash character (/), default choices are shown in bold type, and optional repetition of an element is indicated with the asterisk character (*).

Sieve language elements
Element syntax
    Modifier Source Restrictions Main capability Description
        Modifier     Additional capability  
Control structures
{...} RFC 5228     Block of commands
error string RFC 5463   require "ihave"; Terminate Sieve script with runtime error
foreverypart [:name string] command-block
  RFC 5703   require "foreverypart"; (New in MS 8.0) Loop through the MIME parts of a message
    :name RFC 5703     Specify a name for this foreverypart loop for reference in enclosed break or continue statements
    break [:name string] RFC 5703     (New in MS 8.0) Break out of a foreverypart loop
        :name RFC 5703     Terminate closest enclosing loop having specified name
    continue [:name string] Private     (New in MS 8.0) Pass control to the bottom of the foreverypart loop
        :name RFC 5703     (New in MS 8.0) Pass control to the bottom of the closest enclosing foreverypart loop having specified name
loop [exitif expression]* [nextif expression]* command-block
  Private system-level   General loop
    exitif Private system-level   Exit a loop structure
    exitif Private system-level   (New in 8.0.1.3) Proceed to the next iteration of the loop structure
if  test  command-block [elsif  test  command-block]* [else  command-block]
  RFC 5228     Branch-on-condition control structure
    elsif  test  command-block RFC 5228     Next case of branch-on-condition structure
    else  test  command-⁠block RFC 5228     Final case of branch-on-condition structure
require  capability-list RFC 5228 strict_require MTA option   Declare that a Sieve script may use the named extension(s)
stop RFC 5228     End processing
sub  name[(variables-list)] {...}
  Private system-level   (New in MS 8.0) Define a subroutine
     my  var-name [:= value] Private     (New in MS 8.0) Declare a variable is local
     return  value Private     (New in MS 8.0) Exit subroutine, returning value
Actions
addconversiontag  string-or-list
  Private system-level   System-level Sieve action to add the specified conversion tag(s) to the message
addflag [variable-name] list-of-flags
  RFC 5232 (max_variables MTA option, if using optional variable argument) require "imap4flags"; (or require ["imap4flags", "variables"]; if using optional variable argument) Add the specified IMAP flag(s) to the message
addheader [:last] header-field-name value-string
  RFC 5293 max_addheaders MTA option   Add the specified header line (by default, at the beginning of the existing message header)
    :last RFC 5293     Add the specified header line at the end of the existing message header
    :replace Private     Add the specified header line, removing any previously present such header line(s)
addprefix  string
  Private     Add prefix text to the beginning of the first plain text part of the message
addsuffix  string
  Private     Add suffix text to the end of the first plain text part of the message
addtag  string
  Private     Add a tag (prefix text) to the Subject: header line
adjustcounter [:channel  channel-name] [:duplicate] counter-name [value]
  Private system-level   (New in MS 8.0) System-level Sieve action to adjust value of a system Sieve accessible MTA counter
    :channel Private system-level   Name of channel, one of whose counters is to be adjusted; the current source channel is assumed if no channel is explicitly specified
    :duplicate Private system-level   By default, "adjustcounter" is suppressed if the Sieve script is reevaluated (as when a Sieve script that uses an envelope "To" test applies to a message addressed to multiple recipients); specifying the " :duplicate" modifier means that the " adjustcounter" action will be performed even upon reevaluation
capture [:dsn / :message / :journal] [:header] repository-address
  Private system-level+   Capture a message copy for legal intercept, archival, message replay, or similar purposes
    :dsn Private system-level   Generate an encapsulated (DSN format) capture message; ":dsn" is the default
    :header Private system-level   Capture message contains only the header of the original message, not the body; cannot be combined with ":message"
    :journal Private system-level   Generate a MS Exchange "journal" format capture message
    :message Private system-level   Generate a capture message as a pure, unencapsulated message
debug  list-or-string
  Private mm_debug MTA option   Output the specified debug string; when mm_debug is 2 or more, the string is output to a debug log file, or with imsimta test -expression -mm -debug=2 the specified string is output to the terminal
deleteheader [:index  value [:last]] [MATCH-TYPE] [COMPARATOR] header-field-name-string [value-patterns-list]
  RFC 5293   require "editheader"; Delete the specified header line; (note that per RFC 5293, attempts to delete Received: or Auto-submitted: header lines will be ignored)
    :index RFC 5293     Separate though equivalent to the RFC 5260 ":index" MATCH-TYPE: attempt to match (and hence potentially delete) only exactly the specified occurrence of the specified header line, by default starting counting from the beginning of the message header
        :last RFC 5293     For the ":index" modifier, count backwards from the end of the message header
discard [log-string]
  RFC 5228, plus private logging argument filter_discard and log_filter MTA options, logging channel option   Discard message (do not deliver, just delete); a log-string may be specified to be included in the log_filter field in MTA message transaction log entries
ereject  reason-string
  RFC 5429 enable_sieve_ereject MTA option require "ereject"; Refuse message during SMTP transaction (or generate DSN if SMTP level rejection is not possible); note that use of non-US-ASCII characters in the reason-string prevents the SMTP level rejection
extracttext [MODIFIER] [:first  number] variable-name
  RFC 5703 max_variables MTA option require ["extracttext", "foreverypart", "variables"]; (New in MS 8.0) Store extracted message text into a variable
    :first RFC 5703     Extract only the first N characters of the current MIME body part into a variable
    :encodeurl RFC 5435     In a variablesset command or an extracttext command, perform percent-encoding (as per RFC 3986) of the string value
    :length RFC 5229     Decimal number of characters in the extracted string, converted to a string
    :lower RFC 5229     Convert upper case characters to lower case
    :lowerfirst RFC 5229     Convert first character to lower case if it is a letter and upper case; rest of extracted string left unchanged
    :quoteregex Private     In a variablesset command or extracttext command, backslash quote any characters requiring quoting for regex, namely asterisk, question mark, or backslash (*, ?, \)
    :quotewild Private     Prefix "*", "?", "\" characters with "\"
    :quotewildcard RFC 5229     Prefix "*", "?", "\" characters with "\"
    :upper RFC 5229     Convert lower case characters to upper case
    :upperfirst RFC 5229     Convert first character to upper case if it is a letter and lower case; rest of extracted string left unchanged
fileinto  folder-name
  RFC 5228 max_fileintos MTA option, fileinto and flagtransfer channel options require "fileinto"; Deliver into specified folder
    :copy RFC 3894   require "copy"; Modifies the fileinto and redirect actions so that the action is performed without affecting Sieve's "implicit keep"
    :flags RFC 5232   require "imap4flags"; Used with keep or fileinto to deliver the message with exactly the specified IMAP flag(s)
    :owner Private     Do the "fileinto" to the Sieve owner's address, rather than to the user's address; cases where the Sieve owner is different than the user on whose behalf the Sieve is being applied (hence cases where this argument would be relevant) might be "head of household" Sieves or system Sieves, when one might want to perform a "fileinto" to a folder belonging to the "head of household" or postmaster, respectively, rather than to a folder belonging to the original message recipient
hold Private system-level+   When specified in a system-level Sieve script, sideline a message as a .HELD file in the MTA queue area; ignored (no error) in user-level Sieve scripts
importanceadjust  value-string
  Private     Set or adjust a message's importance
jettison [log-string]
  Private filter_jettison and log_filter MTA options, logging channel option require "jettison"; Non-overridable discard; a log-string may be specified to be included in the log_filter field in MTA message transaction log entries
keep RFC 5228     Deliver message "normally"
    :flags RFC 5232   require "imap4flags"; Used with keep or fileinto to deliver the message with exactly the specified IMAP flag(s)
memcache Private memcache_host, enable_sieve_memcache MTA options   (New in MS 8.0) Used as an action to manipulate data via the memcache protocol; used as a test to access data via the memcache protocol
    :add [:host  host-string] [:tableprefix  prefix-string] [:duplicate] [:timeout  timeout-number] key-string value-string
  Private     Add a new entry with the specified key, value, and timeout. The operation only succeeds if the entry does not already exist. The operation returns TRUE if the entry is added successfully, FALSE if it is not.
    :adjustdown  value [:host  host-str] [:tableprefix  prefix-str] [:duplicate] [:quotatimeout  quotatimeout-num [:penalize]] [:timeout  timeout-num] key-str
  Private     Decrement the entry with the specified key by the specified adjustment value.
    :adjustup  value [:host  host-str] [:tableprefix  prefix-str] [:duplicate] [:quotatimeout  quotatimeout-num [:penalize]] [:timeout  timeout-num] key-str
  Private     Increment the entry with the specified key by the specified adjustment value.
    :append [:host  host-string] [:tableprefix  prefix-string] [:duplicate] key-string value
  Private     Append the specified value to the entry with the specified key. (Returns TRUE if the operation is successful, FALSE if it is not.)
    :fetch [:host  host-string] [:tableprefix  prefix-string] key-string
  Private     Fetches the value of the entry with the specified key, or return an empty string if the entry doesn't exist.
    :prepend [:host  host-string] [:tableprefix  prefix-string] [:duplicate] key-string value-string
  Private     Prepend the specified value to the entry with the specified key. (Returns TRUE if the operation is successful, FALSE if it is not.)
    :remove [:host  host-string] [:tableprefix  prefix-string] [:duplicate] [:lockout  lockout-numeric] key-string
  Private     Remove the entry with the specified key. (Returns TRUE if the operation is successful, FALSE if it is not.)
    :replace [:host  host-string] [:tableprefix  prefix-string] [:timeout  timeout-value] key-string value-string
  Private     Update the value and timeout of an (existing) entry. (Returns TRUE if the operation is successful, FALSE if it is not.)
    :store [:host  host-string] [:tableprefix  prefix-string] [:timeout  timeout-value] key-string value-string
  Private     Creates a new entry or updates an existing entry with the specified key, setting the entry to have the specified value and timeout. (Returns TRUE if the operation is successful, FALSE if it is not.)
metermaid Private enable_sieve_metermaid MTA option   (New in MS 8.0) Used as an action to manipulate data stored in MeterMaid; used as a test to access data stored in MeterMaid
nonotify Private system-level   System-level Sieve action to suppress all applications of either form of notify action
notify :method "email" [:id  string] :options  recipient-addr [subject-str] [< :days / :hours / :seconds > num] [:low / :normal / :high] [:mime] [:message  message-str]
  draft-martin-sieve-notify-01 max_notifys MTA option require "notify"; Generate a new message, typically some form of notification message
    :high draft-...-01     Urgent priority
    :id draft-...-01      
    :low draft-...-01     Non-urgent priority
    :method draft-...-01     The type of notification to generate: only "email" is supported
    :normal draft-...-01     Normal priority
    :options draft-...-01     :method-specific options; for the "email" method, the option value is the recipient email address to which to send the generated notification
    :echo Private      
    :mime Private     The specified message body is a MIME entity, including MIME headers as well as content
    :days Private notify_minimum_timeout, notify_maximum_timeout, and notify_timeout_default MTA options   Specify duplicate notification timeout in units of days
    :hours Private notify_minimum_timeout, notify_maximum_timeout, and notify_timeout_default MTA options   Specify duplicate notification timeout in units of hours
    :seconds Private notify_minimum_timeout, notify_maximum_timeout, and notify_timeout_default MTA options   Specify duplicate notification timeout in units of seconds
notify [:from  string] [:importance < "1" / "2" / "3" >] [:options  string-list] [:mime] [:message  string] method-string
  RFC 5435 max_notifys, notify_ignore_errors MTA options require "enotify"; Generate a new message, typically some form of notification message
    :fcc draft-ietf-extra-sieve-fcc-02.txt     Specify mailbox to receive copy of any generated notification
    :from RFC 5435     Specify author (From address) of notification
    :importance RFC 5435     Specify priority, where 1 corresponds to urgent priority, 2 corresponds to normal priority, and 3 corresponds to non-urgent priority; the default is 2 (normal)
    :options RFC 5435      
    :message RFC 5435      
    :echo Private      
    :mime Private     The specified message body is a MIME entity, including MIME headers as well as content
    :days Private notify_minimum_timeout, notify_maximum_timeout, and notify_timeout_default MTA options   Specify duplicate notification timeout in units of days
    :hours Private notify_minimum_timeout, notify_maximum_timeout, and notify_timeout_default MTA options   Specify duplicate notification timeout in units of hours
    :seconds Private notify_minimum_timeout, notify_maximum_timeout, and notify_timeout_default MTA options   Specify duplicate notification timeout in units of seconds
novacation Private system-level   System-level Sieve action to suppress all applications of the vacation action
override Private   require "override"; (New in MS 8.0) Mark this Sieve script as determining the disposition of a message
redirect [MODIFIERS] address
  RFC 5228 max_redirects, max_redirect_addresses MTA options   "Forward" message to specified recipient address(es)
    :copy RFC 3894   require "copy"; Modifies the fileinto and redirect actions so that the action is performed without affecting Sieve's "implicit keep"
    :keepmailfrom Private     Retain original envelope FROM address on redirect; :keepmailfrom is the default unless :notify is specified in which case the default switches to :resetmailfrom
    :list RFC 6134 SIEVE_EXTLISTS mapping table, max_redirect_addresses MTA option require "extlists"; Externally stored list of addresses to which to forward with redirect action
    :noresent Private sieve_redirect_add_resent MTA option   Do not add Resent-*: header lines upon redirect
    :notify RFC 6009   require "redirect-dsn"; Set message's NOTIFY parameter on redirect
    :resent Private sieve_redirect_add_resent MTA option   Add Resent-*: header lines upon redirect
    :resetmailfrom Private     Reset envelope FROM address to Sieve owner on redirect
    :ret RFC 6009   require "redirect-dsn"; Set message's NOTIFY RET (return-of-content) parameter on redirect
refuse  string
  Private ++ require "refuse"; Refuse message, at SMTP level if possible, falling back to generating MDN
reject  string
  RFC 5429   require "reject"; Refuse message
removeconversiontag  string-or-list
  Private system-level   System-level Sieve action to remove the specified conversion tag(s) from the message
removeflag  [variable-name] list-of-flags
  RFC 5232 (max_variables MTA option, if using optional variable argument) require "imap4flags"; (or require ["imap4flags", "variables"]; if using optional variable argument) Remove the specified IMAP flag(s) from the message
replaceheader [:index  value [:last]] [:newname  header-field-name-str] [:newvalue  string] [COMPARATOR] [MATCH-TYPE] header-field-name-str [value-patterns-list]
  draft-degener-sieve-editheader-00   require "editheader"; Replace a header line
    :index draft-...-00     Separate though equivalent to the RFC 5260 ":index" MATCH-TYPE: attempt to match (and hence potentially replace) only exactly the specified occurrence of the specified header line, by default starting counting from the beginning of the message header
        :last draft-...-00     For the ":index" modifier, count backwards from the end of the message header
    :newname draft-...-00     Change the name of all matching header fields to the specified new name
    :newvalue draft-...-00     Change the value of all matching header fields to the specified new value
set [MODIFIERS] variable-name string-value
  RFC 5229 max_variables MTA option require "variables"; Set a variable to a value
    :encodeurl RFC 5435     In a variables  set command, perform percent-encoding (as per RFC 3986) of the string value
    :length RFC 5229     Decimal number of characters in the value string, converted to a string
    :lower RFC 5229     Convert upper case characters to lower case
    :lowerfirst RFC 5229     Convert first character to lower case if it is a letter and upper case; rest of string left unchanged
    :quoteregex Private     In a variables  set command, backslash quote any characters requiring quoting for regex, namely asterisk, question mark, or backslash (*, ?, \)
    :quotewild Private     Prefix "*", "?", "\" characters with "\"
    :quotewildcard RFC 5229     Prefix "*", "?", "\" characters with "\"
    :upper RFC 5229     Convert lower case characters to upper case
    :upperfirst RFC 5229     Convert first character to upper case if it is a letter and lower case; rest of string left unchanged
setconversiontag  string-or-list
  Private system-level   System-level Sieve action to set the message to have exactly the specified conversion tag(s)
setenvelopefrom  address-string-or-list
  Private system-level   (New in MS 8.0) System-level Sieve action to override a message's original envelope From address
setflag [variable-name] list-of-flags
  RFC 5232 (max_variables MTA option if using variables; with LMTP delivery, see also the flagtransfer channel option) require "imap4flags"; (or require ["imap4flags", "variables"]; if using variables) Set the message to have exactly the specified IMAP flag(s)
setmtpriority  integer-or-string
  Private system-level   (New in MS 8.0) System-level Sieve action to set a message's MT-PRIORITY
setnotify  string-or-list
  Private system-level   System-level Sieve action to set the DSN NOTIFY parameter (defined in RFC 3461); the value may be the string "NEVER", or one (or a list) of the strings "FAILURE", "SUCCESS", "DELAY"
setoperation < "SUBMIT" / "PASSTHROUGH" / "RELAY" / "DEFAULT" >
  Private system-level   (New in MS 8.0) System-level Sieve per-recipient override of type of enqueue operation being performed
setpriority  string-or-numeric-priority-value
  Private system-level   System-level Sieve action to override message's effective processing priority
setreturn < "FULL" / "HDRS" / "HEADERS" >
  Private system-level   System-level Sieve action to set the DSN RET parameter (defined in RFC 3461)
spamadjust  numeric-value-string
  Private     Set a message's "spam level"
transactionlog  string-or-list
  Private system-level, log_transactionlog MTA option, logging channel option   (New in MS 8.0) System-level Sieve action specifying additional string to include in the MTA message transaction log file
vacation [:days  number] [:subject  string] [:from  address] [:addresses  string-list] [:mime] [:handle  string] reason-string
  RFC 5230 non-system-level, max_vacations and vacation_template MTA options require "vacation"; Generate a vacation auto-response (an "I'm on vacation" sort of message)
    :addresses RFC 5230     Additional addresses to consider as "belonging" to the user, and hence whose presence on a recipient header line of an original message satisfies one requirement for vacation message generation
    :days RFC 5230 autoreply_timeout_default, vacation_minimum_timeout, and vacation_maximum_timeout MTA options   Specify timeout in days
    :echo Private     Modifier on vacation to produce a "processed" MDN response
    :fcc draft-ietf-extra-sieve-fcc-02.txt     Specify mailbox to receive copy of any generated vacation notice
    :from RFC 5230     Address to use in the From: header line of the generated vacation message
    :handle RFC 5230     Explicit label for this vacation operation, to be used instead of the usual argument-based label, so that vacation actions with different arguments may have a coordinated label and thereby respect each other's prior execution (and not generate yet another vacation message)
    :headers Private     Modifier on vacation to produce a response containing header lines, rather than the default MDN called for by the standard
    :hours Private autoreply_timeout_default, vacation_minimum_timeout, and vacation_maximum_timeout MTA options   Specify the vacation action's autoresponse period in hours, rather than the normal days
    :mime RFC 5230     The reason-string is a MIME entity, including MIME headers as well as content
    :noaddresses Private     Modifier on vacation to suppress the MTA'S normal requirement (as per RFC 5230, Section 4.5) to only respond if the recipient address or one of its aliases appears explicitly on a recipient header line
    :noheadercheck Private     (MS 8.0.2.3) Modifier on vacation to suppress the MTA'S normal requirement (as per RFC 5230, Section 4.6) to only respond if various headers, e.g., List-ID:, are not present in the original message
    :reply Private     Modifier on vacation to produce a pure reply, containing only the reply text, rather than the default MDN called for by the standard
    :seconds RFC 6131 autoreply_timeout_default, vacation_minimum_timeout, and vacation_maximum_timeout MTA options require "vacation-seconds"; Specify vacation action's autoresponse period in seconds, rather than the normal days
    :subject RFC 5230     Text to use in Subject: header line of generated vacation message
virusset  numeric-value-string
  Private     Set a message's "virus level"
warn  string-or-list
  Private system-level, log_filter MTA option, logging channel option   (New in MS 8.0) System-level Sieve action specifying (an additional) string to appear in the " warn" clause in the log_filter field of MTA message transaction log entries
Tests
address [ADDRESS-PART] [COMPARATOR] [MATCH-TYPE] header-list value-list
  RFC 5228     Match Internet address in structured headers
    :aindex Private     Match against Nth address on header line
    :index RFC 5260   require "index"; Match against Nth named header line for address, header, or date tests
        :last RFC 5260   require "index"; Used with " :index to match against Nth named header line, counting backwards, for address, header, or date tests
    :mime [:anychild] [MIMEOPTS]
  RFC 5703   require "mime"; Alter address, exists, or header tests to check aspects of structured MIME header lines
        :anychild RFC 5703   require "mime"; Modify :mime to look inside any nested parts
    :raw Private analogue of RFC 5173     (New in MS 7.0.5) Do not MIME decode any RFC 2047 MIME encoded-words
    :text Private analogue of RFC 5173     (New in MS 7.0.5) Perform MIME decoding of any RFC 2047 MIME encoded-words
allof  test-list RFC 5228     Logical AND of tests; test-list has the form (test [,test]*)
anyof  test-list RFC 5228     Logical OR of tests
body [COMPARATOR] [MATCH-TYPE] [BODY-TRANSFORM] value-list
  RFC 5173 enable_sieve_body MTA option require "body"; Match content in the body of an email message; (only supports :contains and :isMATCH-TYPES, and a limited set of COMPARATORS)
currentdate [:zone  time-zone] [COMPARATOR] [MATCH-TYPE] date-part value-list
  RFC 5260   require "date"; Compare against current date-time
    :zone RFC 5260   require "date"; Specify a time zone offset to which to shift the current date-time prior to testing
date [:zone  time-zone / :originalzone] [COMPARATOR] [MATCH-TYPE] header-name date-part value-list
  RFC 5260   require "date"; Match against date from a header line
    :originalzone RFC 5260   require "date"; Test retaining the time zone offset of the original date time
    :zone RFC 5260   require "date"; Specify a time zone offset to which to shift the date-time prior to testing
duplicate [:handle  string] [:header  header-name / :uniqueid  value] [:seconds  timeout] [:last]
  draft-bosch-sieve-duplicate-09 max_duplicates, duplicate_tracking_url MTA options require "duplicate"; (New in MS 8.0) Test whether "the same" message was (recently) already received
    :handle draft-bosch-sieve-duplicate-09   require "duplicate"; Distinguish, via handle name, this duplicate test from other duplicate tests
    :header draft-bosch-sieve-duplicate-09   require "duplicate"; Use as unique ID (for duplicate detection) the content of the specified header field
    :last draft-bosch-sieve-duplicate-09 duplicate_timeout_default require "duplicate"; Modify :seconds interpretation (or if :seconds was not specified, use duplicate_timeout_default value) interpreting as seconds within which a "duplicate" message must have been received (counting from the most recent check of the same unique ID) to count as a duplicate
    :mime Private   require "mime";  
        :anychild Private   require "mime";  
    :seconds draft-bosch-sieve-duplicate-09 duplicate_timeout_default, duplicate_minimum_timeout, duplicate_maximum_timeout MTA options require "duplicate"; Seconds within which a "duplicate" message must have been received (counting time from the first message with the same unique ID) to count as duplicate
    :uniqueid draft-bosch-sieve-duplicate-09   require "duplicate"; Use the specified value as the unique ID (for duplicate detection)
envelope [COMPARATOR] [ADDRESS-PART] [MATCH-TYPE] envelope-part-list value-list
  RFC 5228   require "envelope"; Match SMTP envelope address
environment [COMPARATOR] [MATCH-TYPE] environment-item value-list
  RFC 5183   require "environment"; Match against operating environment information
exists  header-list value-list
  RFC 5228     Test whether specified header(s) are present in a message
    :list Private enhancement of RFC 6134 SIEVE_EXTLISTS mapping table require "extlists"; Match against externally stored data in address, envelope, and header tests; MTA private additional functionality is that ":list" is also supported on the standard exists test, as well as on extension tests currentdate, date, environment, hasflag, spamtest, string, and virustest, and on deleteheader and replaceheader actions
    :mime [ :anychild] [MIMEOPTS]
  RFC 5703   require "mime"; Alter address, exists, or header tests to check aspects of structured MIME header lines
        :anychild RFC 5703   require "mime"; Modify :mime to look inside any nested parts
    :regex Private enhancement of draft-murchison-sieve-regex-08 enable_sieve_regex MTA option require "regex"; Regex match type
false RFC 5228     Always evaluate to FALSE
hasflag [MATCH-TYPE] [COMPARATOR] [variable-list] list-of-flags
  RFC 5232 (max_variables MTA option if using optional variable argument) require "imap4flags"; (or require ["imap4flags", "variables"]; if using optional variable argument) Test whether the message has the specified IMAP flag(s)
    :list Private enhancement of RFC 6134 SIEVE_EXTLISTS mapping table require "extlists"; Match against externally stored data in address, envelope, and header tests; MTA private additional functionality is that ":list" is also supported on the standard exists test, as well as on extension tests currentdate, date, environment, hasflag, spamtest, string, and virustest, and on deleteheader and replaceheader actions
header [COMPARATOR] [MATCH-TYPE] header-list value-list
  RFC 5228 defer_header_addition and (new in MS 8.0) sieve_received MTA options   Match header
    :mime [:anychild] [MIMEOPTS]
  RFC 5703   require "mime"; Alter address, exists, or header tests to check aspects of structured MIME header lines
        :anychild RFC 5703   require "mime"; Modify :mime to look inside any nested parts
    :raw Private analogue of RFC 5173     (New in MS 7.0.5) Do not MIME decode any RFC 2047 MIME encoded-words
    :text Private analogue of RFC 5173     (New in MS 7.0.5) Perform MIME decoding of any RFC 2047 MIME encoded-words
ihave  capability-list
  RFC 5463   require "ihave"; Test which Sieve extensions are available
importancetest [COMPARATOR] [MATCH-TYPE] value
  Private     Test a message's importance
memcache Private memcache_host, enable_sieve_memcache MTA options   (New in MS 8.0) Used as an action to manipulate data via the memcache protocol; used as a test to access data via the memcache protocol
memcache :adjustdown  value [:host  host-string] [:tableprefix  prefix-string] [:duplicate] [MATCH-TYPE] [COMPARATOR] [:quotatimeout  quotatimeout-numeric [:penalize]] [:timeout  timeout-value] key-string [test-string]
  Private     For the entry with the specified key, adjust the value down as specified and compare that adjusted value against the specified test-string value, which same test-string then becomes the entry's new value. MATCH-TYPE and COMPARATOR default to ':value "lt"' and 'comparator "i;ascii-numeric"', respectively.
memcache :adjustup  value [:host  host-string] [:tableprefix  prefix-string] [:duplicate] [MATCH-TYPE] [COMPARATOR] [:quotatimeout  quotatimeout-numeric [:penalize]] [:timeout  timeout-value] key-string [test-string]
  Private     For the entry with the specified key, adjust the value up as specified and compare that adjusted value against the specified test-string value, which same test-string then becomes the entry's new value. MATCH-TYPE and COMPARATOR default to ':value "gt"' and 'comparator "i;ascii-numeric"', respectively.
memcache :fetch [:host  host-string] [:tableprefix  prefix-string] [MATCH-TYPE] [COMPARATOR] key-string [test-string]
  Private     For the entry with the specified key, compare its current value against the test-string, setting the value to test-string. The test always fails if the entry does not exist. MATCH-TYPE and COMPARATOR default to :is and "i;ascii-casemap", respectively.
memcache :release  [:duplicate] [:host  host-string] [:tableprefix  prefix-string] [:timeout  timeout-value] key-string
  Private     Implement a generic reservation capability. :release releases a previous reservation made with :reserve. The test returns TRUE if the reservation if a reservation is successfully released, FALSE otherwise.
memcache :reserve  :quota  quota-numeric [:duplicate] [:host  host-string] [:tableprefix  prefix-string] [:timeout  timeout-value] key-string
  Private     Implement a generic reservation capability. :reserve attempts to take out a reservation for the specified key-string. quota-numeric specifies the maximum number of reservations that are allowed. The test returns TRUE if the reservation if the reservation is taken out successfully, FALSE otherwise. Multiple reservations may be taken out by multiple  :reserve operations. Note that each :reserve should be matched by a subsequent  :release.
memcache :throttle  :quota  quota-numeric [:duplicate] :quotetimeout  quotatimeout-numeric [:penalize] [:host  host-string] [:tableprefix  prefix-string] [:timeout  timeout-value] [MATCH-TYPE] [COMPARATOR] [:adjustup  adjustment-value] [:adjustdown  adjustment-value] key-string [test-string]
  Private     Implement MeterMaid throttle capability. The throttle value is incremented by default, though ":adjustup" or ":adjustdown" may be used to specify a non-default adjustment of the value. Then if none of MATCH-TYPE, COMPARATOR, nor test-string are specified, the test returns TRUE if the throttle is engaged, or FALSE if it is not engaged (or an error occurs). If any of the MATCH-TYPE, COMPARATOR, or test-string parameters is specified, then the throttle entry's value is adjusted and then the specified Sieve test is applied to the value. The default MATCH-TYPE is :value "gt" and the default COMPARATOR is i;ascii-numeric.
metermaid Private enable_sieve_metermaid MTA option   (New in MS 8.0) Used as an action to manipulate data stored in MeterMaid; used as a test to access data stored in MeterMaid
    :adjustdown  adjustment-value [:host  host-string] [:duplicate] [MATCH-TYPE] [COMPARATOR] table-string key-string [test-string]
  Private     Decrement the entry with the specified key in the specified table by the specified adjustment value.
    :adjustup  adjustment-value [:host  host-string] [:duplicate] [MATCH-TYPE] [COMPARATOR] table-string key-string [test-string]
  Private     Increment the entry with the specified key in the specified table by the specified adjustment value.
    :fetch [:host  host-string] [MATCH-TYPE] [COMPARATOR] table-string key-string [test-string]
  Private     If none of MATCH-TYPE, COMPARATOR, nor test-string is specified, the specified entry's value is returned as a string, or an empty string is returned if the specified entry doesn't exist. If any of MATCH-TYPE, COMPARATOR, or test-string is specified, test against the current value of the specified entry (MATCH-TYPE and COMPARATOR default to ' :is' and ' :comparator "i;ascii-casemap"', respectively), returning FALSE if the specified entry does not exist.
    :greylisting [:host  host-string] [:duplicate] [MATCH-TYPE] [COMPARATOR] table-string key-string [test-string]
  Private     If none of MATCH-TYPE, COMPARATOR, nor test-string are specified, then return TRUE if greylisting is engaged, while FALSE is returned if greylisting is not engaged or an error occurs. If any of MATCH-TYPE, COMPARATOR, or test-string is specified (MATCH-TYPE and COMPARATOR default to ' :is' and ' :comparator "i;ascii-casemap"', respectively), then increment the throttle and then apply the Sieve test to the value.
    :remove [:host  host-string] [:duplicate] table-string key-string
  Private     Remove the entry with the specified key from the specified table. Returns TRUE if the operation is successful; FALSE if it is not.
    :store [:host  host-string] table-string key-string value-string
  Private     Creates a new entry or updates an existing entry with the specified key in the specified table. Returns TRUE if the operation is successful; FALSE if it is not.
    :throttle [:hosthost-string] [:duplicate] [MATCH-TYPE] [COMPARATOR] table-string key-string
  Private     MeterMaid throttle functionality. If none of MATCH-TYPE, COMPARATOR, nor test-string is specified, return TRUE if the throttle is engaged, or FALSE if the throttle is not engaged or an error occurs; if any of these three parameters is specified, then increment the throttle and then apply the Sieve test to the value. (MATCH-TYPE defaults to ':value "gt"' and COMPARATOR defaults to ':comparator "i;ascii-numeric"'.)
not  test RFC 5228     Reverse value of test argument
notify_method_capability [COMPARATOR] [MATCH-TYPE] notification-uri notification-capability value-list
  RFC 5435   require "enotify"; Test whether a capability of a method of notification is available to be performed as desired
    :list Private enhancement of RFC 6134 SIEVE_EXTLISTS mapping table require "extlists"; Match against externally stored data in address, envelope, and header tests; MTA private additional functionality is that ":list" is also supported on the standard exists test, as well as on extension tests currentdate, date, environment, hasflag, notify_method_capability, spamtest, string, and virustest, and on deleteheader and replaceheader actions
size < :over / :under > limit-value
  RFC 5228     Test size of message
    :over RFC 5228     Match if message size is over specified value
    :under RFC 5228     Match if message size is under specified value
spamtest [COMPARATOR] [MATCH-TYPE] value
  RFC 3685   require "spamtest"; or require "spamtestplus"; Test a message's "spam level"
    :list RFC 6134 SIEVE_EXTLISTS mapping table require "extlists"; Match against externally stored data in address, envelope, and header tests; MTA private additional functionality is that ":list" is also supported on the standard exists test, as well as on extension tests currentdate, date, environment, hasflag, notify_method_capability, spamtest, string, and virustest, and on deleteheader and replaceheader actions
    :percent RFC 5235   require "spamtestplus"; Test a message's "spam level" as a percentage value
string [MATCH-TYPE] [COMPARATOR] source-string-list value-list
  RFC 5229 max_sieve_string_size MTA option require "variables"; Test the (string) value of variable(s)
    :list Private enhancement of RFC 6134 SIEVE_EXTLISTS mapping table require "extlists"; Match against externally stored data in address, envelope, and header tests; MTA private additional functionality is that ":list" is also supported on the standard exists test, as well as on extension tests currentdate, date, environment, hasflag, spamtest, string, and virustest, and on deleteheader and replaceheader actions
true RFC 5228     Always evaluate to TRUE
valid_ext_list  extlist-names-list
  RFC 6134   require "extlists"; Test whether an external list specification is valid (both syntactically and semantically)
valid_notify_method  notification-uris-list
  RFC 5435   require "enotify"; Test whether notification methods are supported and syntactically valid
virustest [COMPARATOR] [MATCH-TYPE] value
  RFC 3685   require "virustest"; Test a message's "virus level"
    :count RFC 5231   require "relational"; Match type for numeric comparison on number of occurrences (as of MS 8.0.1.3, :count may also be used as a modifier to other match types in header and address tests to count and test the number of matches that occurred)
    :list RFC 6134 SIEVE_EXTLISTS mapping table require "extlists"; Match against externally stored data in address, currentdate, date, envelope, exists, and header tests, as well as in the string test when the variables extension is enabled, and in spamtest and virustest tests when those extensions are enabled
    :regex draft-murchison-sieve-regex-08 enable_sieve_regex MTA option require "regex"; Regex match type
    :value RFC 5231   require "relational"; Match type for comparison on string values
test-name string Private FILTER_test-name mapping table   Custom test test-name: probes mapping table FILTER_test-name with string, evaluating to TRUE if mapping table sets $Y flag, or FALSE otherwise
Functions
sub  name[(variables-list)] {...}
  Private system-level   (New in MS 8.0) Define a function/subroutine
     my  var-name [:= value] Private     (New in MS 8.0) Declare a variable is local
     return  value Private     (New in MS 8.0) Exit subroutine, returning value
translate  string-or-list source-charset dest-charset
  Private     (New in MS 8.0.1) Perform character set conversion, returning translated string or list
test-name string Private FILTER_test-name mapping table require "variables"; Custom test test-name used as a function: probes mapping table FILTER_test-name with string, returning mapping's string result in variable ${0} and mapping's flag result in variable ${1}
...many-other-functions... Private     See Symbol table functions
Values
non-negative-integer RFC 5228     Non-negative integer, range 0 to 2,147,483,647 (2^31 - 1); suffixes "K" (1024 or 2^10), "M" (2^20), or "G" (2^30) are permitted
negative-integer Private     Negative integers are also supported by the MTA
"utf-8-string" RFC 5228 max_sieve_string_size MTA option   String of characters represented in UTF-8; note that non-printing characters such as CR and LF are permitted, and so in particular strings can span multiple lines
"\character" RFC 5228     \\ represents the backslash character, \" represents the double quote character, and otherwise the backslash is ignored as if it were not present
text:multiline text ended by CRLF.CRLF RFC 5228     More convenient way to enter multiline text strings; note must dot-stuff (as with SMTP messages)
["s1", "s2", ..., "sN"] RFC 5228 max_sieve_list_size MTA option   List of strings
"${hex:hex-pair-sequence}" RFC 5228   require "encoded-character"; hex-pair-sequence is one or more hexadecimal-encoded characters, space separated; e.g., "{hex: 40 24}" represents "@$"
"${unicode: unicode-hex-sequence}" RFC 5228   require "encoded-character"; unicode-hex-sequence is one or more Unicode hex-encoded characters, space separated; e.g., "${unicode: 0000040}" represents "@"
${variable-name} RFC 5229 max_variables MTA option require "variables"; variable-name may be a variable identifier, or digit(s) identifying the variable, e.g., ${a} refers to the variable named "a", while ${0} refers to the 0th variable; variable namespaces are not currently supported (so in particular variable names may not include any periods); note that variable substitutions are not supported in "body" test arguments
expression Private     The MTA supports a variety of string and numeric operators and functions, and supports expressions to compute values; see Operators in Order of Precedence and Symbol table functions
ADDRESS-PARTS
    :all RFC 5228     Entire address
    :comment Private     Extract any parenthetical comment appearing after an address
    :detail RFC 3598   require "subaddress"; Extract subaddress (e.g., folder name) in address and envelope tests
    :display Private     Extract the display-name phrase (the optional text appearing outside of and specifically in front of the actual address, the actual address being the part enclosed in angles)
    :domain RFC 5228     Domain portion of address: the portion to the right of the @ character
    :localpart RFC 5228     RFC 822 "local-part" of address: the portion to the left of the @ character
    :user RFC 3598   require "subaddress"; Extract username (i.e., local-part minus subaddress) in address and envelope tests
BODY-TRANSFORMS
    :raw RFC 5173   require "body"; Interpret message body as an unprocessed "blob"; in particular, do not interpret MIME structure nor decode any content-transfer-encoding
    :text RFC 5173   require "body"; Decode MIME encoded text
COMPARATORS
    :comparator "i;ascii-casemap" RFC 5228, RFC 4790     Treat uppercase and lowercase characters in the ASCII subset of UTF8 the same
    :comparator "i;ascii-casemap-collapse" Private   require "comparator-i;ascii-casemap-collapse"; (New in MS 8.0) Similar to "i;ascii-casemap", except that all folding white space characters (space, tab, carriage return, line feed) are removed from both the target and pattern strings prior to comparison; this comparator is recommended for working around standards-incompliant client behavior regarding white space, folding white space, and MIME encoded-words
    :comparator "i;ascii-integer" Private   require "comparator-i;ascii-integer"; (New in MS 8.0) Test signed or unsigned integer values; (not supported on "body" tests)
    :comparator "i:ascii-numeric" RFC 4790   require "comparator-i;ascii-numeric"; Compare arbitrarily sized, unsigned integer numbers stored as octet strings, (in particular, disregard leading zeros, and truncate at the first non-digit character); see RFC 4790, Section 9.1.1 for further details; (not supported on "body" tests)
    :comparator "i;octet" RFC 5228, RFC 4790     Compare octets
    :comparator "i;octet-collapse" Private   require "comparator-i;octet-collapse"; (New in MS 8.0) Similar to "i;octet", except that all folding white space characters (space, tab, carriage return, line feed) are removed from both the target and pattern strings prior to comparison; this comparator is recommended for working around standards-incompliant client behavior regarding white space, folding white space, and MIME encoded-words
    :comparator "i;utf-8"  ?   require "comparator-i;utf8"; (New in MS 8.0) (not supported on "body" tests)
DATE-PARTS
    date RFC 5260   require "date"; Date in "yyyy-mm-dd" format
    day RFC 5260   require "date"; Two digit day, "01", ..., "31"
    hour RFC 5260   require "date"; Two digit hour, "00", ..., "23"
    iso8601 RFC 5260   require "date"; Date and time in restricted ISO 8601 format
    julian RFC 5260   require "date"; Modified Julian Day, that is, the date expressed as an integer number of days since 00:00 UTC on November 17, 1958 (using the Gregorian calendar); this corresponds to the Julian Day minus 2400000.5
    minute RFC 5260   require "date"; Two digit minute, "00", ..., "59"
    month RFC 5260   require "date"; Two digit month, "00", ..., "12"
    second RFC 5260   require "date"; Two digit second, "00", ..., "60"
    std11 RFC 5260   require "date"; Date and time in a format appropriate for use in a Date: header field (RFC 822 format)
    time RFC 5260   require "date"; Time in "hh:mm:ss" format
    weekday RFC 5260   require "date"; Day of the week expressed in range "0" (Sunday) to "6" (Saturday)
    year RFC 5260   require "date"; Four digit year, "0000", ..., "9999"
    zone RFC 5260   require "date"; Time zone in use, in +hh:mm or -hh:mm format
ENVELOPE-PARTS
    from RFC 5228   require "envelope"; Envelope From address
    to RFC 5228   require "envelope"; Envelope To address
    auth Private   require ["envelope", "envelope-auth"]; Access message's AUTH value
    conversiontag Private system-level require "envelope"; In system-level Sieve, access message's conversion tag(s)
    envid RFC 6009   require ["envelope", "envelope-dsn"]; Access message's envelope-id value
    orcpt RFC 6009   require ["envelope", "envelope-dsn"]; Access message's ORCPT value
    notify RFC 6009   require ["envelope", "envelope-dsn"]; Access message's DSN NOTIFY value
    ret RFC 6009   require ["envelope", "envelope-dsn"]; Access message's DSN RET value
ENVIRONMENT-ITEMS
domain RFC 5183   require "environment"; Preferably the value of ldap_default_domain MTA option, next the value of received_domain MTA option, or if neither are defined the value of the L channel official_host_name
host RFC 5183   require "environment"; L channel official-host-name
location RFC 5183   require "environment"; Type of service evaluating the Sieve; "MTA" for MTA evaluation
name RFC 5183   require "environment"; "IMTA" for MTA evaluation
phase RFC 5183   require "environment"; Phase of processing; possible values are "initialize", "connect", "mail" (reported at both HELO and MAIL FROM command stages), "rcptin", "rcptout", "datastart", "dataend", and "pre" (the default value)
remote-host RFC 5183   require "environment"; Current source system
remote-ip RFC 5183   require "environment"; Source IP
version RFC 5183   require "environment"; MTA version string (akin to version reported in Received: header line)
vnd.oracle.last-verdict Private   require "environment"; (New in MS 7.0.5) Prior Sieve's explicit handling action (see discussion of MTA's Sieve hierarchy)
vnd.oracle.max_mime_width Private   require "environment"; (New in MS 8.0.2.2) The maximum number of MIME parts found in any multipart in the message.
vnd.oracle.message-hash Private   require "environment"; (New in MS 8.0) Return any message hash calculated by the generatemessagehash channel option; the query will fail if no message hash was generated
vnd.oracle.mime_levels Private   require "environment"; (New in MS 8.0.2.2) The number of accessible MIME levels in the current message, i.e. the MIME "depth" of the message.
vnd.oracle.mt-priority Private   require "environment"; (New in MS 8.0) Match against message's current MT-PRIORITY value
vnd.oracle.notifycount Private   require "environment"; (New in MS 8.0.1.2) Return the count of the number of notification messages the current sieve has enqueued.
vnd.oracle.notifyquota Private   require "environment"; (New in MS 8.0.1.2) Return the number of additional notify actions the current sieve is able to perform.
vnd.oracle.operation-type Private   require "environment"; (New in MS 8.0) Match against message's current type of enqueue operation
vnd.oracle.reevaluate Private   require "environment"; (New in MS 8.0) TRUE or FALSE according to whether this Sieve script is being reevaluated
vnd.oracle.tracking-id Private   require "environment"; (New in MS 8.0) Return the tracking identifier for the current message; the query will fail if there's no tracking id
vnd.oracle.vacationcount Private   require "environment"; (New in MS 8.0.1.2) Return the count of the number of vacation messages enqueued by the current sieve. Note that this is not necessarily the same as number of vacation actions performed since any number of conditions can turn a vacation action into a no-op.
vnd.oracle.vacationquot Private   require "environment"; (New in MS 8.0.1.2) Return the number of additional vacation actions the current sieve is able to perform.
vnd.sun.authenticated-sender-address Private   require "environment"; Match against sender address associated with the authentication for the SMTP session
vnd.sun.authenticated-sender-id Private   require "environment"; Match against user identity associated with the authentication for the SMTP session
vnd.sun.autoreply-internal Private   require "environment"; TRUE or FALSE according to whether the autoreply criteria have been met for use of the "internal" autoreply response text stored in LDAP
vnd.sun.destination-channel Private   require "environment"; Match against message's destination channel
vnd.sun.source-channel Private   require "environment"; Match against message's source channel
custom-item-name Private $+Eitem-name|item-value in an *_ACCESS address mapping table require "environment"; Arbitrary, custom environment items for a message may be set from the FROM_ACCESS or *_ACCESS recipient accress mapping tables, for subsequent use in environment tests
MATCH-TYPES
    :aindex Private     Match against Nth address on header line
    :contains RFC 5228     Substring match
    :count RFC 5231   require "relational"; Match type for numeric comparison on number of occurrences; (not available for use with "body" test)
    :index RFC 5260   require "index"; Match against Nth named header line for address, header, or date tests
        :last RFC 5260   require "index"; For the :index modifier, count backwards from the end of the message header
    :is RFC 5228     Exact match
    :list RFC 6134 and private enhancements SIEVE_EXTLISTS mapping table require "extlists"; Match against externally stored data in address, envelope, and header tests; MTA private additional functionality is that ":list" is also supported on the standard exists test, as well as on extension tests currentdate, date, environment, hasflag, importancetest, memcache, metermaid, spamtest, string, and virustest, and on deleteheader and replaceheader actions
    :matches RFC 5228     Wildcard match; (not supported on "body" tests)
    :regex draft-murchison-sieve-regex-08 enable_sieve_regex MTA option require "regex"; Regex match type; (not supported on "hasflag" or "body" tests)
    :value RFC 5231   require "relational"; Match type for comparison on string values; (may not be specified on "body" tests)
MIMEOPTS
    :type RFC 5703   require "mime"; For Content-type: MIME header field, parse and test the value of the MIME type; for Content-disposition: MIME header field, parse and test the disposition value; for other MIME headers, use a blank string
    :subtype RFC 5703   require "mime"; For Content-type: MIME header field, parse and test the value of the MIME subtype; for other MIME headers, use a blank string
    :contenttype RFC 5703   require "mime"; For Content-type: MIME header field, parse and test the combined value of the MIME type and subtype; for Content-disposition: MIME header field, parse and test the disposition value; for other MIME headers, use a blank string
    :param RFC 5703   require "mime"; Parse the header for MIME parameters, returning true if any value found matches any of the test string values

+Only displayed in imsimta test -expression -mm if executing process has "world" privilege

++Prior to MS 6.2, only permitted in system-level Sieves; nowadays supported in arbitrary Sieves



See also: