1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.52
from filter on 25 November 2000 -->
<TITLE>Exim Filter Specification - Obeying commands conditionally</TITLE>
</HEAD>
<body bgcolor="#FFFFFF" text="#00005A" link="#FF6600" alink="#FF9933" vlink="#990000">
Go to the <A HREF="filter_1.html">first</A>, <A HREF="filter_18.html">previous</A>, <A HREF="filter_20.html">next</A>, <A HREF="filter_34.html">last</A> section, <A HREF="filter_toc.html">table of contents</A>.
<P><HR><P>
<H2><A NAME="SEC19" HREF="filter_toc.html#TOC19">Obeying commands conditionally</A></H2>
<P>
Most of the power of filtering comes from the ability to test conditions and
obey different commands depending on the outcome. The <TT>`if'</TT> command is used to
specify conditional execution, and its general form is
<PRE>
if <<EM>condition</EM>>
then <<EM>commands</EM>>
elif <<EM>condition</EM>>
then <<EM>commands</EM>>
else <<EM>commands</EM>>
endif
</PRE>
<P>
There may be any number of <TT>`elif'</TT> and <TT>`then'</TT> sections (including none) and
the <TT>`else'</TT> section is also optional. Any number of commands, including nested
<TT>`if'</TT> commands, may appear in any of the <<EM>commands</EM>> sections.
</P>
<P>
Conditions can be combined by using the words <TT>`and'</TT> and <TT>`or'</TT>, and round
brackets (parentheses) can be used to specify how several conditions are to
combine. Without brackets, <TT>`and'</TT> is more binding than <TT>`or'</TT>.
<font color=green>
For example,
<PRE>
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
</PRE>
<P>
</font>
A condition can be preceded by <TT>`not'</TT> to negate it, and there are also some
negative forms of condition that are more English-like.
</P>
<P><HR><P>
Go to the <A HREF="filter_1.html">first</A>, <A HREF="filter_18.html">previous</A>, <A HREF="filter_20.html">next</A>, <A HREF="filter_34.html">last</A> section, <A HREF="filter_toc.html">table of contents</A>.
</BODY>
</HTML>
|