The following conditions are available for testing while expanding strings:
!<condition>
This negates the result of the condition.
def:<variable>
This condition is true if the named expansion variable does not contain the empty string, for example
${if def:sender_ident {from $sender_ident}}
Note that the variable name is given without a leading `$' character. If the variable does not exist, the expansion fails.
def:header_<header name> or def:h_<header name>
This condition is true if a message is being processed and the named header exists in the message. For example,
${if def:header_reply-to:{$h_reply-to:}{$h_from:}}
Note that no `$' appears before `header_' or `h_' in the condition, and that header names must be terminated by colons if white space does not follow.
exists {<file name>}
The substring is first expanded and then interpreted as an absolute path. The condition is true if the named file (or directory) exists. The existence test is done by calling the `stat()' function.
eq {<string1>}{<string2>}
The two substrings are first expanded. The condition is true if the two resulting strings are identical, including the case of letters.
match {<string1>}{<string2>}
The two substrings are first expanded. The second is then treated as a regular expression and applied to the first. Because of the pre-expansion, if the regular expression contains dollar or backslash characters, they must be escaped with backslashes. If the whole expansion string is in double quotes, further escaping of backslashes is also required.
The condition is true if the regular expression match succeeds. At the start of an "if" expansion the values of the numeric variable substitutions `$1' etc. are remembered. Obeying a "match" condition that succeeds causes them to be reset to the substrings of that condition and they will have these values during the expansion of the success string. At the end of the "if" expansion, the previous values are restored. After testing a combination of conditions using "or", the subsequent values of the numeric variables are those of the condition that succeeded.
or {{<cond1>}{<cond2>}...}
The sub-conditions are evaluated from left to right. The condition is true if any one of the sub-conditions is true. When a true sub-condition is found, the following ones are parsed but not evaluated. Thus if there are several `match' sub-conditions the values of the numeric variables are taken from the first one that succeeds.
and {{<cond1>}{<cond2>}...}
The sub-conditions are evaluated from left to right. The condition is true if all of the sub-conditions are true. When a false sub-condition is found, the following ones are parsed but not evaluated.
Go to the first, previous, next, last section, table of contents.