Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > a4080654d049ad31b216b761b9173c1f > files > 147

exim-doc-4.69-4mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on September, 10 2009 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>

-->
<head>
<title>Specification of the Exim Mail Transfer Agent: 43. System-wide message filtering</title>

<meta name="description" content="Specification of the Exim Mail Transfer Agent: 43. System-wide message filtering">
<meta name="keywords" content="Specification of the Exim Mail Transfer Agent: 43. System-wide message filtering">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="System_002dwide-message-filtering"></a>
<a name="SEC374"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="spec_42.html#SEC373" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC375" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="spec_42.html#SEC365" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="spec_44.html#SEC383" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[Contents]</td>
<td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 43. System-wide message filtering </h1>

<p>The previous chapters (on ACLs and the local scan function) describe checks
that can be applied to messages before they are accepted by a host. There is
also a mechanism for checking messages once they have been received, but before
they are delivered. This is called the <em>system filter</em>.
</p>
<p>The system filter operates in a similar manner to users' filter files, but it
is run just once per message (however many recipients the message has).
It should not normally be used as a substitute for routing, because <code>deliver</code>
commands in a system router provide new envelope recipient addresses.
The system filter must be an Exim filter. It cannot be a Sieve filter.
</p>
<p>The system filter is run at the start of a delivery attempt, before any routing
is done. If a message fails to be completely delivered at the first attempt,
the system filter is run again at the start of every retry.
If you want your filter to do something only once per message, you can make use
of the <code>first_delivery</code> condition in an <code>if</code> command in the filter to
prevent it happening on retries.
</p>
<a name="IDX2684"></a>
<a name="IDX2685"></a>
<p><strong>Warning</strong>: Because the system filter runs just once, variables that are
specific to individual recipient addresses, such as <code>$local_part</code> and
<code>$domain</code>, are not set, and the &quot;personal&quot; condition is not meaningful. If
you want to run a centrally-specified filter for each recipient address
independently, you can do so by setting up a suitable <code>redirect</code> router, as
described in section <a href="#SEC382">Per-address filtering</a> below.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC375">43.1 Specifying a system filter</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC376">43.2 Testing a system filter</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC377">43.3 Contents of a system filter</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC378">43.4 Additional variable for system filters</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC379">43.5 Defer, freeze, and fail commands for system filters</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC380">43.6 Adding and removing headers in a system filter</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC381">43.7 Setting an errors address in a system filter</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC382">43.8 Per-address filtering</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<hr size="6">
<a name="Specifying-a-system-filter"></a>
<a name="SEC375"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC374" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC376" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC374" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC374" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="spec_44.html#SEC383" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[Contents]</td>
<td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 43.1 Specifying a system filter </h2>

<p>The name of the file that contains the system filter must be specified by
setting <code>system_filter</code>. If you want the filter to run under a uid and gid
other than root, you must also set <code>system_filter_user</code> and
<code>system_filter_group</code> as appropriate. For example:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">system_filter = /etc/mail/exim.filter
system_filter_user = exim
</pre></td></tr></table>

<p>If a system filter generates any deliveries directly to files or pipes (via the
<code>save</code> or <code>pipe</code> commands), transports to handle these deliveries must be
specified by setting <code>system_filter_file_transport</code> and
<code>system_filter_pipe_transport</code>, respectively. Similarly,
<code>system_filter_reply_transport</code> must be set to handle any messages generated
by the <code>reply</code> command.
</p>
<hr size="6">
<a name="Testing-a-system-filter"></a>
<a name="SEC376"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC375" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC377" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC374" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC374" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="spec_44.html#SEC383" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[Contents]</td>
<td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 43.2 Testing a system filter </h2>

<p>You can run simple tests of a system filter in the same way as for a user
filter, but you should use <code>-bF</code> rather than <code>-bf</code>, so that features that
are permitted only in system filters are recognized.
</p>
<p>If you want to test the combined effect of a system filter and a user filter,
you can use both <code>-bF</code> and <code>-bf</code> on the same command line.
</p>
<hr size="6">
<a name="Contents-of-a-system-filter"></a>
<a name="SEC377"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC376" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC378" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC374" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC374" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="spec_44.html#SEC383" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[Contents]</td>
<td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 43.3 Contents of a system filter </h2>

<p>The language used to specify system filters is the same as for users' filter
files. It is described in the separate end-user document <em>Exim's interface to
mail filtering</em>. However, there are some additional features that are
available only in system filters; these are described in subsequent sections.
If they are encountered in a user's filter file or when testing with <code>-bf</code>,
they cause errors.
</p>
<a name="IDX2686"></a>
<p>There are two special conditions which, though available in users' filter
files, are designed for use in system filters. The condition <code>first_delivery</code>
is true only for the first attempt at delivering a message, and
<code>manually_thawed</code> is true only if the message has been frozen, and
subsequently thawed by an admin user. An explicit forced delivery counts as a
manual thaw, but thawing as a result of the <code>auto_thaw</code> setting does not.
</p>
<p><strong>Warning</strong>: If a system filter uses the <code>first_delivery</code> condition to
specify an &quot;unseen&quot; (non-significant) delivery, and that delivery does not
succeed, it will not be tried again.
If you want Exim to retry an unseen delivery until it succeeds, you should
arrange to set it up every time the filter runs.
</p>
<p>When a system filter finishes running, the values of the variables <code>$n0</code> -
<code>$n9</code> are copied into <code>$sn0</code> - <code>$sn9</code> and are thereby made available to
users' filter files. Thus a system filter can, for example, set up &quot;scores&quot;
to which users' filter files can refer.
</p>
<hr size="6">
<a name="Additional-variable-for-system-filters"></a>
<a name="SEC378"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC377" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC379" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC374" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC374" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="spec_44.html#SEC383" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[Contents]</td>
<td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 43.4 Additional variable for system filters </h2>

<p>The expansion variable <code>$recipients</code>, containing a list of all the recipients
of the message (separated by commas and white space), is available in system
filters. It is not available in users' filters for privacy reasons.
</p>
<hr size="6">
<a name="Defer_003b-freeze_003b-and-fail-commands-for-system-filters"></a>
<a name="SEC379"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC378" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC380" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC374" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC374" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="spec_44.html#SEC383" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[Contents]</td>
<td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 43.5 Defer, freeze, and fail commands for system filters </h2>

<p>There are three extra commands (<code>defer</code>, <code>freeze</code> and <code>fail</code>) which are
always available in system filters, but are not normally enabled in users'
filters. (See the <code>allow_defer</code>, <code>allow_freeze</code> and <code>allow_fail</code> options
for the <code>redirect</code> router.) These commands can optionally be followed by the
word <code>text</code> and a string containing an error message, for example:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">fail text &quot;this message looks like spam to me&quot;
</pre></td></tr></table>

<p>The keyword <code>text</code> is optional if the next character is a double quote.
</p>
<p>The <code>defer</code> command defers delivery of the original recipients of the
message. The <code>fail</code> command causes all the original recipients to be failed,
and a bounce message to be created. The <code>freeze</code> command suspends all
delivery attempts for the original recipients. In all cases, any new deliveries
that are specified by the filter are attempted as normal after the filter has
run.
</p>
<p>The <code>freeze</code> command is ignored if the message has been manually unfrozen and
not manually frozen since. This means that automatic freezing by a system
filter can be used as a way of checking out suspicious messages. If a message
is found to be all right, manually unfreezing it allows it to be delivered.
</p>
<a name="IDX2687"></a>
<a name="IDX2688"></a>
<p>The text given with a fail command is used as part of the bounce message as
well as being written to the log. If the message is quite long, this can fill
up a lot of log space when such failures are common. To reduce the size of the
log message, Exim interprets the text in a special way if it starts with the
two characters &lsquo;<samp>&lt;&lt;</samp>&rsquo; and contains &lsquo;<samp>&gt;&gt;</samp>&rsquo; later. The text between these two
strings is written to the log, and the rest of the text is used in the bounce
message. For example:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">fail &quot;&lt;&lt;filter test 1&gt;&gt;Your message is rejected \
     because it contains attachments that we are \
     not prepared to receive.&quot;
</pre></td></tr></table>

<a name="IDX2689"></a>
<p>Take great care with the <code>fail</code> command when basing the decision to fail on
the contents of the message, because the bounce message will of course include
the contents of the original message and will therefore trigger the <code>fail</code>
command again (causing a mail loop) unless steps are taken to prevent this.
Testing the <code>error_message</code> condition is one way to prevent this. You could
use, for example
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">if $message_body contains &quot;this is spam&quot; and not error_message
then fail text &quot;spam is not wanted here&quot; endif
</pre></td></tr></table>

<p>though of course that might let through unwanted bounce messages. The
alternative is clever checking of the body and/or headers to detect bounces
generated by the filter.
</p>
<p>The interpretation of a system filter file ceases after a
<code>defer</code>,
<code>freeze</code>, or <code>fail</code> command is obeyed. However, any deliveries that were
set up earlier in the filter file are honoured, so you can use a sequence such
as
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">mail ...
freeze
</pre></td></tr></table>

<p>to send a specified message when the system filter is freezing (or deferring or
failing) a message. The normal deliveries for the message do not, of course,
take place.
</p>
<hr size="6">
<a name="Adding-and-removing-headers-in-a-system-filter"></a>
<a name="SEC380"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC379" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC381" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC374" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC374" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="spec_44.html#SEC383" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[Contents]</td>
<td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 43.6 Adding and removing headers in a system filter </h2>

<p>Two filter commands that are available only in system filters are:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">headers add &lt;string&gt;
headers remove &lt;string&gt;
</pre></td></tr></table>

<p>The argument for the <code>headers add</code> is a string that is expanded and then
added to the end of the message's headers. It is the responsibility of the
filter maintainer to make sure it conforms to RFC 2822 syntax. Leading white
space is ignored, and if the string is otherwise empty, or if the expansion is
forced to fail, the command has no effect.
</p>
<p>You can use &quot;\n&quot; within the string, followed by white space, to specify
continued header lines. More than one header may be added in one command by
including &quot;\n&quot; within the string without any following white space. For
example:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">headers add &quot;X-header-1: ....\n  \
             continuation of X-header-1 ...\n\
             X-header-2: ....&quot;
</pre></td></tr></table>

<p>Note that the header line continuation white space after the first newline must
be placed before the backslash that continues the input string, because white
space after input continuations is ignored.
</p>
<p>The argument for <code>headers remove</code> is a colon-separated list of header names.
This command applies only to those headers that are stored with the message;
those that are added at delivery time (such as <em>Envelope-To:</em> and
<em>Return-Path:</em>) cannot be removed by this means. If there is more than one
header with the same name, they are all removed.
</p>
<p>The <code>headers</code> command in a system filter makes an immediate change to the set
of header lines that was received with the message (with possible additions
from ACL processing). Subsequent commands in the system filter operate on the
modified set, which also forms the basis for subsequent message delivery.
Unless further modified during routing or transporting, this set of headers is
used for all recipients of the message.
</p>
<p>During routing and transporting, the variables that refer to the contents of
header lines refer only to those lines that are in this set. Thus, header lines
that are added by a system filter are visible to users' filter files and to all
routers and transports. This contrasts with the manipulation of header lines by
routers and transports, which is not immediate, but which instead is saved up
until the message is actually being written (see section
<a href="spec_44.html#SEC400">Adding and removing header lines in routers and transports</a>).
</p>
<p>If the message is not delivered at the first attempt, header lines that were
added by the system filter are stored with the message, and so are still
present at the next delivery attempt. Header lines that were removed are still
present, but marked &quot;deleted&quot; so that they are not transported with the
message. For this reason, it is usual to make the <code>headers</code> command
conditional on <code>first_delivery</code> so that the set of header lines is not
modified more than once.
</p>
<p>Because header modification in a system filter acts immediately, you have to
use an indirect approach if you want to modify the contents of a header line.
For example:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">headers add &quot;Old-Subject: $h_subject:&quot;
headers remove &quot;Subject&quot;
headers add &quot;Subject: new subject (was: $h_old-subject:)&quot;
headers remove &quot;Old-Subject&quot;
</pre></td></tr></table>

<hr size="6">
<a name="Setting-an-errors-address-in-a-system-filter"></a>
<a name="SEC381"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC380" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC382" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC374" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC374" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="spec_44.html#SEC383" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[Contents]</td>
<td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 43.7 Setting an errors address in a system filter </h2>

<p>In a system filter, if a <code>deliver</code> command is followed by
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">errors_to &lt;some address&gt;
</pre></td></tr></table>

<p>in order to change the envelope sender (and hence the error reporting) for that
delivery, any address may be specified. (In a user filter, only the current
user's address can be set.) For example, if some mail is being monitored, you
might use
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">unseen deliver monitor@spying.example errors_to root@local.example
</pre></td></tr></table>

<p>to take a copy which would not be sent back to the normal error reporting
address if its delivery failed.
</p>
<hr size="6">
<a name="Per_002daddress-filtering"></a>
<a name="SEC382"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC381" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="spec_44.html#SEC383" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC374" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC374" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="spec_44.html#SEC383" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[Contents]</td>
<td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 43.8 Per-address filtering </h2>

<p>In contrast to the system filter, which is run just once per message for each
delivery attempt, it is also possible to set up a system-wide filtering
operation that runs once for each recipient address. In this case, variables
such as <code>$local_part</code> and <code>$domain</code> can be used, and indeed, the choice of
filter file could be made dependent on them. This is an example of a router
which implements such a filter:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">central_filter:
  check_local_user
  driver = redirect
  domains = +local_domains
  file = /central/filters/$local_part
  no_verify
  allow_filter
  allow_freeze
</pre></td></tr></table>

<p>The filter is run in a separate process under its own uid. Therefore, either
<code>check_local_user</code> must be set (as above), in which case the filter is run as
the local user, or the <code>user</code> option must be used to specify which user to
use. If both are set, <code>user</code> overrides.
</p>
<p>Care should be taken to ensure that none of the commands in the filter file
specify a significant delivery if the message is to go on to be delivered to
its intended recipient. The router will not then claim to have dealt with the
address, so it will be passed on to subsequent routers to be delivered in the
normal way.
<a name="IDX2690"></a>
<a name="IDX2691"></a>
<a name="IDX2692"></a>
</p>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC374" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="spec_44.html#SEC383" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="spec.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[Contents]</td>
<td valign="middle" align="left">[<a href="spec_55.html#SEC493" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="spec_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
 <font size="-1">
  This document was generated on <i>September, 10 2009</i> using <a href="http://www.nongnu.org/texi2html/"><i>texi2html 1.78</i></a>.
 </font>
 <br>

</p>
</body>
</html>