Node:Tests, Next:Actions, Previous:Comparators, Up:Input Language
This section describes the built-in tests supported by GNU libsieve. In the discussion below the following macro-notations are used:
:is
:is
match type describes an absolute match; if the contents of
the first string are absolutely the same as the contents of the
second string, they match. Only the string "frobnitzm" is the string
"frobnitzm". The null key ":is" and only ":is" the null value.
This is the default match-type.
:contains
:contains
match type describes a substring match. If the value
argument contains the key argument as a substring, the match is true.
For instance, the string "frobnitzm" contains "frob" and "nit", but
not "fbm". The null key "" is contained in all values.
:matches
:matches
version specifies a wildcard match using the
characters *
and ?
. *
matches zero or more
characters, and ?
matches a single character. ?
and
*
may be escaped as \\?
and \\*
in strings to match
against themselves. The first backslash escapes the second backslash;
together, they escape the *
.
:regex
:regex
version specifies a match using POSIX Extended Regular
Expressions.
:comparator "comparator-name"
It instructs sieve to use the given comparator with the test.
If comparator-name is not one of i;octet
,
i;ascii-casemap
it must be required prior to using it.
For example:
require "comparator-i;ascii-numeric"; if header :comparator "i;ascii-numeric" :is "X-Num" "10" { ...
:all
:localpart
:domain
Notice, that match-type modifiers interact with
comparators. Some comparators are not suitable for matching with
:contains
or :matches
. If this occurs, sieve issues
an appropriate error message. For example, the statement:
if header :matches :comparator "i;ascii-numeric"
would result in the following error message:
comparator `i;ascii-numeric' is incompatible with match type `:matches' in call to `header'
false | Test |
This test always evaluates to "false". |
true | Test |
This test always evaluates to "true". |
address [address-part][comparator][match-type] header-names key-list | Test |
Tagged arguments:
Required arguments:
The This test returns The Example:
if address :is :all "from" "[email protected]" { discard; } |
size [:over|:under] number | Test |
The
If the tagged argument is If the argument is Otherwise, the test is true only if the size of the message equals exactly number. This is a GNU extension. The size of a message is defined to be the number of octets from the initial header until the last character in the message body. |
envelope [address-part][comparator][match-type] envelope-part key-list | Test |
Tagged arguments:
Required arguments:
The If the envelope-part strings is (case insensitive) Notice, that due to the limitations imposed by SMTP envelope structure the use of any other values in envelope-parts header is meaningless. |
exists header-names | Test |
Required arguments:
The The following example throws out mail that doesn't have a From header
and a Date header:
if not exists ["From","Date"] { discard; } |
header [comparator] [match-type] [:mime] header-names key-list | Test |
Tagged arguments:
Required arguments:
The The test returns If a header listed in header-names exists, it contains the null
key ( X-Caffeine: C8H10N4O2
these tests on that header evaluate as follows:
header :is ["X-Caffeine"] [""] => false header :contains ["X-Caffeine"] [""] => true |
numaddr [:over|:under] header-names number | Test |
This test is provided as an example of loadable extension tests. You
must use The If the tagged argument is If the tagged argument is If the tagged argument is not given, |