GNU Mailutils |
|
General-Purpose Mail Package |
Official GNU Software |
This section describes the built-in tests supported by GNU libmu_sieve. In the discussion below the following macro-notations are used:
This tag specifies the matching type to be used with the test. It can be one of the following:
:is
The :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
The :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
The :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
The :regex
version specifies a match using POSIX Extended Regular
Expressions.
:value relation
The :value
match type does a relational comparison between
strings. Valid values for relation are:
Equal
Not Equal
Greater Than
Greater than or Equal
Less Than
Less than or Equal
:count relation
This match type first determines the number of the specified entities (headers, addresses, etc.) in the message and does a relational comparison of the number of entities to the values specified in the test expression. The test expression must be a list of one element.
A comparator syntax item is defined as follows:
: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" { ...
This syntax item is used when testing structured Internet addresses. It specifies which part of an address must be used in comparisons. Exactly one of the following tags may be used:
:all
Use the whole address. This is the default.
:localpart
Use local part of the address.
:domain
Use domain part of the address.
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'
GNU Sieve supports two kinds of tests. Built-in tests are
defined within the library and do not require any external files.
External tests are loadable modules that can be linked in at run
time using the require
statement (see Require Statement).
This document was generated on January 2, 2022 using makeinfo.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.