Go to the first, previous, next, last section, table of contents.


Obeying commands conditionally

Most of the power of filtering comes from the ability to test conditions and obey different commands depending on the outcome. The `if' command is used to specify conditional execution, and its general form is

if    <condition>
then  <commands>
elif  <condition>
then  <commands>
else  <commands>
endif

There may be any number of `elif' and `then' sections (including none) and the `else' section is also optional. Any number of commands, including nested `if' commands, may appear in any of the <commands> sections.

Conditions can be combined by using the words `and' and `or', and round brackets (parentheses) can be used to specify how several conditions are to combine. Without brackets, `and' is more binding than `or'. For example,

if
  $h_subject: contains "Make money" or
  $h_precedence: is "junk" or
  ($h_sender: matches ^\\d{8}@ and not personal) or
  $message_body contains "this is spam"
then
  seen finish
endif

A condition can be preceded by `not' to negate it, and there are also some negative forms of condition that are more English-like.


Go to the first, previous, next, last section, table of contents.