Explain the current releases
[exim-website.git] / docbook / 4.61 / spec.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
3 <book>
4 <bookinfo>
5 <title>Specification of the Exim Mail Transfer Agent</title>
6 <titleabbrev>The Exim MTA</titleabbrev>
7 <date>22 March 2006</date>
8 <author><firstname>Philip</firstname><surname>Hazel</surname></author>
9 <authorinitials>PH</authorinitials>
10 <affiliation><orgname>University of Cambridge Computing Service</orgname></affiliation>
11 <address>New Museums Site, Pembroke Street, Cambridge CB2 3QH, England</address>
12 <revhistory><revision>
13   <revnumber>4.61</revnumber>
14   <date>22 March 2006</date>
15   <authorinitials>PH</authorinitials>
16 </revision></revhistory>
17 <copyright><year>2006</year><holder>University of Cambridge</holder></copyright>
18 </bookinfo>
19 <chapter>
20 <title>Introduction</title>
21
22 <indexterm role="concept">
23   <primary>$1, $2, etc.</primary>
24   <see><emphasis>numerical variables</emphasis></see>
25 </indexterm>
26 <indexterm role="concept">
27   <primary>address</primary>
28   <secondary>rewriting</secondary>
29   <see><emphasis>rewriting</emphasis></see>
30 </indexterm>
31 <indexterm role="concept">
32   <primary>Bounce Address Tag Validation</primary>
33   <see><emphasis>BATV</emphasis></see>
34 </indexterm>
35 <indexterm role="concept">
36   <primary>Client SMTP Authorization</primary>
37   <see><emphasis>CSA</emphasis></see>
38 </indexterm>
39 <indexterm role="concept">
40   <primary>CR character</primary>
41   <see><emphasis>carriage return</emphasis></see>
42 </indexterm>
43 <indexterm role="concept">
44   <primary>CRL</primary>
45   <see><emphasis>certificate revocation list</emphasis></see>
46 </indexterm>
47 <indexterm role="concept">
48   <primary>delivery</primary>
49   <secondary>failure report</secondary>
50   <see><emphasis>bounce message</emphasis></see>
51 </indexterm>
52 <indexterm role="concept">
53   <primary>dialup</primary>
54   <see><emphasis>intermittently connected hosts</emphasis></see>
55 </indexterm>
56 <indexterm role="concept">
57   <primary>exiscan</primary>
58   <see><emphasis>content scanning</emphasis></see>
59 </indexterm>
60 <indexterm role="concept">
61   <primary>failover</primary>
62   <see><emphasis>fallback</emphasis></see>
63 </indexterm>
64 <indexterm role="concept">
65   <primary>fallover</primary>
66   <see><emphasis>fallback</emphasis></see>
67 </indexterm>
68 <indexterm role="concept">
69   <primary>filter</primary>
70   <secondary>Sieve</secondary>
71   <see><emphasis>Sieve filter</emphasis></see>
72 </indexterm>
73 <indexterm role="concept">
74   <primary>ident</primary>
75   <see><emphasis>RFC 1413</emphasis></see>
76 </indexterm>
77 <indexterm role="concept">
78   <primary>LF character</primary>
79   <see><emphasis>linefeed</emphasis></see>
80 </indexterm>
81 <indexterm role="concept">
82   <primary>maximum</primary>
83   <see><emphasis>limit</emphasis></see>
84 </indexterm>
85 <indexterm role="concept">
86   <primary>monitor</primary>
87   <see><emphasis>Exim monitor</emphasis></see>
88 </indexterm>
89 <indexterm role="concept">
90   <primary>no_<emphasis>xxx</emphasis></primary>
91   <see>entry for xxx</see>
92 </indexterm>
93 <indexterm role="concept">
94   <primary>NUL</primary>
95   <see><emphasis>binary zero</emphasis></see>
96 </indexterm>
97 <indexterm role="concept">
98   <primary>passwd file</primary>
99   <see><emphasis>/etc/passwd</emphasis></see>
100 </indexterm>
101 <indexterm role="concept">
102   <primary>process id</primary>
103   <see><emphasis>pid</emphasis></see>
104 </indexterm>
105 <indexterm role="concept">
106   <primary>RBL</primary>
107   <see><emphasis>DNS list</emphasis></see>
108 </indexterm>
109 <indexterm role="concept">
110   <primary>redirection</primary>
111   <see><emphasis>address redirection</emphasis></see>
112 </indexterm>
113 <indexterm role="concept">
114   <primary>return path</primary>
115   <seealso><emphasis>envelope sender</emphasis></seealso>
116 </indexterm>
117 <indexterm role="concept">
118   <primary>scanning</primary>
119   <see><emphasis>content scanning</emphasis></see>
120 </indexterm>
121 <indexterm role="concept">
122   <primary>SSL</primary>
123   <see><emphasis>TLS</emphasis></see>
124 </indexterm>
125 <indexterm role="concept">
126   <primary>string</primary>
127   <secondary>expansion</secondary>
128   <see><emphasis>expansion</emphasis></see>
129 </indexterm>
130 <indexterm role="concept">
131   <primary>top bit</primary>
132   <see><emphasis>8-bit characters</emphasis></see>
133 </indexterm>
134 <indexterm role="concept">
135   <primary>variables</primary>
136   <see><emphasis>expansion, variables</emphasis></see>
137 </indexterm>
138 <indexterm role="concept">
139   <primary>zero, binary</primary>
140   <see><emphasis>binary zero</emphasis></see>
141 </indexterm>
142
143 <para>
144 Exim is a mail transfer agent (MTA) for hosts that are running Unix or
145 Unix-like operating systems. It was designed on the assumption that it would be
146 run on hosts that are permanently connected to the Internet. However, it can be
147 used on intermittently connected hosts with suitable configuration adjustments.
148 </para>
149 <para>
150 Configuration files currently exist for the following operating systems: AIX,
151 BSD/OS (aka BSDI), Darwin (Mac OS X), DGUX, Dragonfly, FreeBSD, GNU/Hurd,
152 GNU/Linux, HI-OSF (Hitachi), HI-UX, HP-UX, IRIX, MIPS RISCOS, NetBSD, OpenBSD,
153 OpenUNIX, QNX, SCO, SCO SVR4.2 (aka UNIX-SV), Solaris (aka SunOS5), SunOS4,
154 Tru64-Unix (formerly Digital UNIX, formerly DEC-OSF1), Ultrix, and Unixware.
155 Some of these operating systems are no longer current and cannot easily be
156 tested, so the configuration files may no longer work in practice.
157 </para>
158 <para>
159 There are also configuration files for compiling Exim in the Cygwin environment
160 that can be installed on systems running Windows. However, this document does
161 not contain any information about running Exim in the Cygwin environment.
162 </para>
163 <para>
164 The terms and conditions for the use and distribution of Exim are contained in
165 the file <filename>NOTICE</filename>. Exim is distributed under the terms of the GNU General
166 Public Licence, a copy of which may be found in the file <filename>LICENCE</filename>.
167 </para>
168 <para>
169 The use, supply or promotion of Exim for the purpose of sending bulk,
170 unsolicited electronic mail is incompatible with the basic aims of the program,
171 which revolve around the free provision of a service that enhances the quality
172 of personal communications. The author of Exim regards indiscriminate
173 mass-mailing as an antisocial, irresponsible abuse of the Internet.
174 </para>
175 <para>
176 Exim owes a great deal to Smail 3 and its author, Ron Karr. Without the
177 experience of running and working on the Smail 3 code, I could never have
178 contemplated starting to write a new MTA. Many of the ideas and user interfaces
179 were originally taken from Smail 3, though the actual code of Exim is entirely
180 new, and has developed far beyond the initial concept.
181 </para>
182 <para>
183 Many people, both in Cambridge and around the world, have contributed to the
184 development and the testing of Exim, and to porting it to various operating
185 systems. I am grateful to them all. The distribution now contains a file called
186 <filename>ACKNOWLEDGMENTS</filename>, in which I have started recording the names of
187 contributors.
188 </para>
189 <section>
190 <title>Exim documentation</title>
191 <para revisionflag="changed">
192 <indexterm role="concept">
193 <primary>documentation</primary>
194 </indexterm>
195 This edition of the Exim specification applies to version 4.61 of Exim.
196 Substantive changes from the 4.60 edition are marked in some
197 renditions of the document; this paragraph is so marked if the rendition is
198 capable of showing a change indicator.
199 </para>
200 <para>
201 This document is very much a reference manual; it is not a tutorial. The reader
202 is expected to have some familiarity with the SMTP mail transfer protocol and
203 with general Unix system administration. Although there are some discussions
204 and examples in places, the information is mostly organized in a way that makes
205 it easy to look up, rather than in a natural order for sequential reading.
206 Furthermore, the manual aims to cover every aspect of Exim in detail, including
207 a number of rarely-used, special-purpose features that are unlikely to be of
208 very wide interest.
209 </para>
210 <para>
211 <indexterm role="concept">
212 <primary>books about Exim</primary>
213 </indexterm>
214 An <quote>easier</quote> discussion of Exim which provides more in-depth explanatory,
215 introductory, and tutorial material can be found in a book entitled <emphasis>The Exim
216 SMTP Mail Server</emphasis>, published by UIT Cambridge
217 (<emphasis role="bold"><ulink url="http://www.uit.co.uk/exim-book/">http://www.uit.co.uk/exim-book/</ulink></emphasis>).
218 </para>
219 <para>
220 This book also contains a chapter that gives a general introduction to SMTP and
221 Internet mail. Inevitably, however, the book is unlikely to be fully up-to-date
222 with the latest release of Exim. (Note that the earlier book about Exim,
223 published by O&#x2019;Reilly, covers Exim 3, and many things have changed in Exim 4.)
224 </para>
225 <para>
226 <indexterm role="concept">
227 <primary>Debian</primary>
228 <secondary>information sources</secondary>
229 </indexterm>
230 If you are using a Debian distribution of Exim, you will find information about
231 Debian-specific features in the file
232 </para>
233 <literallayout>
234 <filename>/usr/share/doc/exim4-base/README.Debian</filename>
235 </literallayout>
236 <para>
237 The command <command>man update-exim.conf</command> is another source of Debian-specific
238 information.
239 </para>
240 <para>
241 <indexterm role="concept">
242 <primary><filename>doc/NewStuff</filename></primary>
243 </indexterm>
244 <indexterm role="concept">
245 <primary><filename>doc/ChangeLog</filename></primary>
246 </indexterm>
247 <indexterm role="concept">
248 <primary>change log</primary>
249 </indexterm>
250 As the program develops, there may be features in newer versions that have not
251 yet made it into this document, which is updated only when the most significant
252 digit of the fractional part of the version number changes. Specifications of
253 new features that are not yet in this manual are placed in the file
254 <filename>doc/NewStuff</filename> in the Exim distribution.
255 </para>
256 <para>
257 Some features may be classified as <quote>experimental</quote>. These may change
258 incompatibly while they are developing, or even be withdrawn. For this reason,
259 they are not documented in this manual. Information about experimental features
260 can be found in the file <filename>doc/experimental.txt</filename>.
261 </para>
262 <para>
263 All changes to the program (whether new features, bug fixes, or other kinds of
264 change) are noted briefly in the file called <filename>doc/ChangeLog</filename>.
265 </para>
266 <para>
267 <indexterm role="concept">
268 <primary><filename>doc/spec.txt</filename></primary>
269 </indexterm>
270 This specification itself is available as an ASCII file in <filename>doc/spec.txt</filename> so
271 that it can easily be searched with a text editor. Other files in the <filename>doc</filename>
272 directory are:
273 </para>
274 <informaltable frame="none">
275 <tgroup cols="2" colsep="0" rowsep="0">
276 <colspec colwidth="100pt" align="left"/>
277 <colspec colwidth="260pt" align="left"/>
278 <tbody>
279 <row>
280 <entry><filename>OptionLists.txt</filename></entry>
281 <entry>list of all options in alphabetical order</entry>
282 </row>
283 <row>
284 <entry><filename>dbm.discuss.txt</filename></entry>
285 <entry>discussion about DBM libraries</entry>
286 </row>
287 <row>
288 <entry><filename>exim.8</filename></entry>
289 <entry>a man page of Exim&#x2019;s command line options</entry>
290 </row>
291 <row>
292 <entry><filename>experimental.txt</filename></entry>
293 <entry>documentation of experimental features</entry>
294 </row>
295 <row>
296 <entry><filename>filter.txt</filename></entry>
297 <entry>specification of the filter language</entry>
298 </row>
299 <row>
300 <entry><filename>pcrepattern.txt</filename></entry>
301 <entry>specification of PCRE regular expressions</entry>
302 </row>
303 <row>
304 <entry><filename>pcretest.txt</filename></entry>
305 <entry>specification of the PCRE testing program</entry>
306 </row>
307 <row>
308 <entry><filename>Exim3.upgrade</filename></entry>
309 <entry>upgrade notes from release 2 to release 3</entry>
310 </row>
311 <row>
312 <entry><filename>Exim4.upgrade</filename></entry>
313 <entry>upgrade notes from release 3 to release 4</entry>
314 </row>
315 </tbody>
316 </tgroup>
317 </informaltable>
318 <para>
319 The main specification and the specification of the filtering language are also
320 available in other formats (HTML, PostScript, PDF, and Texinfo). Section
321 <xref linkend="SECTavail"/> below tells you how to get hold of these.
322 </para>
323 </section>
324 <section>
325 <title>FTP and web sites</title>
326 <para>
327 <indexterm role="concept">
328 <primary>web site</primary>
329 </indexterm>
330 <indexterm role="concept">
331 <primary>FTP site</primary>
332 </indexterm>
333 The primary site for Exim source distributions is currently the University of
334 Cambridge&#x2019;s FTP site, whose contents are described in <emphasis>Where to find the Exim
335 distribution</emphasis> below. In addition, there is a web site and an FTP site at
336 <option>exim.org</option>. These are now also hosted at the University of Cambridge. The
337 <option>exim.org</option> site was previously hosted for a number of years by Energis
338 Squared, formerly Planet Online Ltd, whose support I gratefully acknowledge.
339 </para>
340 <para>
341 <indexterm role="concept">
342 <primary>wiki</primary>
343 </indexterm>
344 <indexterm role="concept">
345 <primary>FAQ</primary>
346 </indexterm>
347 As well as Exim distribution tar files, the Exim web site contains a number of
348 differently formatted versions of the documentation, including the FAQ in both
349 text and HTML formats. The HTML version comes with a keyword-in-context index.
350 A recent addition to the online information is the Exim wiki
351 (<emphasis role="bold"><ulink url="http://www.exim.org/eximwiki/">http://www.exim.org/eximwiki/</ulink></emphasis>). We hope that this will make it easier
352 for Exim users to contribute examples, tips, and know-how for the benefit of
353 others.
354 </para>
355 </section>
356 <section>
357 <title>Mailing lists</title>
358 <para>
359 <indexterm role="concept">
360 <primary>mailing lists</primary>
361 <secondary>for Exim users</secondary>
362 </indexterm>
363 The following are the three main Exim mailing lists:
364 </para>
365 <informaltable frame="none">
366 <tgroup cols="2" colsep="0" rowsep="0">
367 <colspec colwidth="140pt" align="left"/>
368 <colspec colwidth="260pt" align="left"/>
369 <tbody>
370 <row>
371 <entry><emphasis>exim-users@exim.org</emphasis></entry>
372 <entry>general discussion list</entry>
373 </row>
374 <row>
375 <entry><emphasis>exim-dev@exim.org</emphasis></entry>
376 <entry>discussion of bugs, enhancements, etc.</entry>
377 </row>
378 <row>
379 <entry><emphasis>exim-announce@exim.org</emphasis></entry>
380 <entry>moderated, low volume announcements list</entry>
381 </row>
382 </tbody>
383 </tgroup>
384 </informaltable>
385 <para>
386 You can subscribe to these lists, change your existing subscriptions, and view
387 or search the archives via the mailing lists link on the Exim home page.
388 <indexterm role="concept">
389 <primary>Debian</primary>
390 <secondary>mailing list for</secondary>
391 </indexterm>
392 If you are using a Debian distribution of Exim, you may wish to subscribe to
393 the Debian-specific mailing list <emphasis>pkg-exim4-users@lists.alioth.debian.org</emphasis>.
394 </para>
395 </section>
396 <section>
397 <title>Exim training</title>
398 <para>
399 <indexterm role="concept">
400 <primary>training courses</primary>
401 </indexterm>
402 From time to time (approximately annually at the time of writing), training
403 courses are run by the author of Exim in Cambridge, UK. Details of any
404 forthcoming courses can be found on the web site
405 <emphasis role="bold"><ulink url="http://www-tus.csx.cam.ac.uk/courses/exim/">http://www-tus.csx.cam.ac.uk/courses/exim/</ulink></emphasis>.
406 </para>
407 </section>
408 <section>
409 <title>Bug reports</title>
410 <para>
411 <indexterm role="concept">
412 <primary>bug reports</primary>
413 </indexterm>
414 <indexterm role="concept">
415 <primary>reporting bugs</primary>
416 </indexterm>
417 Reports of obvious bugs should be emailed to <emphasis>bugs@exim.org</emphasis>. However, if you
418 are unsure whether some behaviour is a bug or not, the best thing to do is to
419 post a message to the <emphasis>exim-dev</emphasis> mailing list and have it discussed.
420 </para>
421 </section>
422 <section id="SECTavail">
423 <title>Where to find the Exim distribution</title>
424 <para>
425 <indexterm role="concept">
426 <primary>FTP site</primary>
427 </indexterm>
428 <indexterm role="concept">
429 <primary>distribution</primary>
430 <secondary>ftp site</secondary>
431 </indexterm>
432 The master ftp site for the Exim distribution is
433 </para>
434 <literallayout>
435 <emphasis role="bold">ftp://ftp.csx.cam.ac.uk/pub/software/email/exim</emphasis>
436 </literallayout>
437 <para>
438 This is mirrored by
439 </para>
440 <literallayout>
441 <emphasis role="bold">ftp://ftp.exim.org/pub/exim</emphasis>
442 </literallayout>
443 <para>
444 The file references that follow are relative to the <filename>exim</filename> directories at
445 these sites. There are now quite a number of independent mirror sites around
446 the world. Those that I know about are listed in the file called <filename>Mirrors</filename>.
447 </para>
448 <para>
449 Within the <filename>exim</filename> directory there are subdirectories called <filename>exim3</filename> (for
450 previous Exim 3 distributions), <filename>exim4</filename> (for the latest Exim 4
451 distributions), and <filename>Testing</filename> for testing versions. In the <filename>exim4</filename>
452 subdirectory, the current release can always be found in files called
453 </para>
454 <literallayout>
455 <filename>exim-n.nn.tar.gz</filename>
456 <filename>exim-n.nn.tar.bz2</filename>
457 </literallayout>
458 <para>
459 where <emphasis>n.nn</emphasis> is the highest such version number in the directory. The two
460 files contain identical data; the only difference is the type of compression.
461 The <filename>.bz2</filename> file is usually a lot smaller than the <filename>.gz</filename> file.
462 </para>
463 <para>
464 <indexterm role="concept">
465 <primary>distribution</primary>
466 <secondary>signing details</secondary>
467 </indexterm>
468 <indexterm role="concept">
469 <primary>distribution</primary>
470 <secondary>public key</secondary>
471 </indexterm>
472 <indexterm role="concept">
473 <primary>public key for signed distribution</primary>
474 </indexterm>
475 The distributions are currently signed with Philip Hazel&#x2019;s GPG key. The
476 corresponding public key is available from a number of keyservers, and there is
477 also a copy in the file <filename>Public-Key</filename>. The signatures for the tar bundles are
478 in:
479 </para>
480 <literallayout>
481 <filename>exim-n.nn.tar.gz.sig</filename>
482 <filename>exim-n.nn.tar.bz2.sig</filename>
483 </literallayout>
484 <para>
485 For each released version, the log of changes is made separately available in a
486 separate file in the directory <filename>ChangeLogs</filename> so that it is possible to
487 find out what has changed without having to download the entire distribution.
488 </para>
489 <para>
490 <indexterm role="concept">
491 <primary>documentation</primary>
492 <secondary>available formats</secondary>
493 </indexterm>
494 The main distribution contains ASCII versions of this specification and other
495 documentation; other formats of the documents are available in separate files
496 inside the <filename>exim4</filename> directory of the FTP site:
497 </para>
498 <literallayout>
499 <filename>exim-html-n.nn.tar.gz</filename>
500 <filename>exim-pdf-n.nn.tar.gz</filename>
501 <filename>exim-postscript-n.nn.tar.gz</filename>
502 <filename>exim-texinfo-n.nn.tar.gz</filename>
503 </literallayout>
504 <para>
505 These tar files contain only the <filename>doc</filename> directory, not the complete
506 distribution, and are also available in <filename>.bz2</filename> as well as <filename>.gz</filename> forms.
507 <indexterm role="concept">
508 <primary>FAQ</primary>
509 </indexterm>
510 The FAQ is available for downloading in two different formats in these files:
511 </para>
512 <literallayout>
513 <filename>exim4/FAQ.txt.gz</filename>
514 <filename>exim4/FAQ.html.tar.gz</filename>
515 </literallayout>
516 <para>
517 The first of these is a single ASCII file that can be searched with a text
518 editor. The second is a directory of HTML files, normally accessed by starting
519 at <filename>index.html</filename>. The HTML version of the FAQ (which is also included in the
520 HTML documentation tarbundle) includes a keyword-in-context index, which is
521 often the most convenient way of finding your way around.
522 </para>
523 </section>
524 <section>
525 <title>Wish list</title>
526 <para>
527 <indexterm role="concept">
528 <primary>wish list</primary>
529 </indexterm>
530 A wish list is maintained, containing ideas for new features that have been
531 submitted. From time to time the file is exported to the ftp site into the file
532 <filename>exim4/WishList</filename>. Items are removed from the list if they get implemented.
533 </para>
534 </section>
535 <section>
536 <title>Contributed material</title>
537 <para>
538 <indexterm role="concept">
539 <primary>contributed material</primary>
540 </indexterm>
541 At the ftp site, there is a directory called <filename>Contrib</filename> that contains
542 miscellaneous files contributed to the Exim community by Exim users. There is
543 also a collection of contributed configuration examples in
544 <filename>exim4/config.samples.tar.gz</filename>. These samples are referenced from the FAQ.
545 </para>
546 </section>
547 <section>
548 <title>Limitations</title>
549 <itemizedlist>
550 <listitem>
551 <para>
552 <indexterm role="concept">
553 <primary>limitations of Exim</primary>
554 </indexterm>
555 <indexterm role="concept">
556 <primary>bang paths</primary>
557 <secondary>not handled by Exim</secondary>
558 </indexterm>
559 Exim is designed for use as an Internet MTA, and therefore handles addresses in
560 RFC 2822 domain format only. It cannot handle UUCP <quote>bang paths</quote>, though
561 simple two-component bang paths can be converted by a straightforward rewriting
562 configuration. This restriction does not prevent Exim from being interfaced to
563 UUCP as a transport mechanism, provided that domain addresses are used.
564 </para>
565 </listitem>
566 <listitem>
567 <para>
568 <indexterm role="concept">
569 <primary>domainless addresses</primary>
570 </indexterm>
571 <indexterm role="concept">
572 <primary>address</primary>
573 <secondary>without domain</secondary>
574 </indexterm>
575 Exim insists that every address it handles has a domain attached. For incoming
576 local messages, domainless addresses are automatically qualified with a
577 configured domain value. Configuration options specify from which remote
578 systems unqualified addresses are acceptable. These are then qualified on
579 arrival.
580 </para>
581 </listitem>
582 <listitem>
583 <para>
584 <indexterm role="concept">
585 <primary>transport</primary>
586 <secondary>external</secondary>
587 </indexterm>
588 <indexterm role="concept">
589 <primary>external transports</primary>
590 </indexterm>
591 The only external transport mechanisms that are currently implemented are SMTP
592 and LMTP over a TCP/IP network (including support for IPv6). However, a pipe
593 transport is available, and there are facilities for writing messages to files
594 and pipes, optionally in <emphasis>batched SMTP</emphasis> format; these facilities can be used
595 to send messages to other transport mechanisms such as UUCP, provided they can
596 handle domain-style addresses. Batched SMTP input is also catered for.
597 </para>
598 </listitem>
599 <listitem>
600 <para>
601 Exim is not designed for storing mail for dial-in hosts. When the volumes of
602 such mail are large, it is better to get the messages <quote>delivered</quote> into files
603 (that is, off Exim&#x2019;s queue) and subsequently passed on to the dial-in hosts by
604 other means.
605 </para>
606 </listitem>
607 <listitem>
608 <para>
609 Although Exim does have basic facilities for scanning incoming messages, these
610 are not comprehensive enough to do full virus or spam scanning. Such operations
611 are best carried out using additional specialized software packages. If you
612 compile Exim with the content-scanning extension, straightforward interfaces to
613 a number of common scanners are provided.
614 </para>
615 </listitem>
616 </itemizedlist>
617 </section>
618 <section>
619 <title>Run time configuration</title>
620 <para>
621 Exim&#x2019;s run time configuration is held in a single text file that is divided
622 into a number of sections. The entries in this file consist of keywords and
623 values, in the style of Smail 3 configuration files. A default configuration
624 file which is suitable for simple online installations is provided in the
625 distribution, and is described in chapter <xref linkend="CHAPdefconfil"/> below.
626 </para>
627 </section>
628 <section>
629 <title>Calling interface</title>
630 <para>
631 <indexterm role="concept">
632 <primary>Sendmail compatibility</primary>
633 <secondary>command line interface</secondary>
634 </indexterm>
635 Like many MTAs, Exim has adopted the Sendmail command line interface so that it
636 can be a straight replacement for <filename>/usr/lib/sendmail</filename> or
637 <filename>/usr/sbin/sendmail</filename> when sending mail, but you do not need to know anything
638 about Sendmail in order to run Exim. For actions other than sending messages,
639 Sendmail-compatible options also exist, but those that produce output (for
640 example, <option>-bp</option>, which lists the messages on the queue) do so in Exim&#x2019;s own
641 format. There are also some additional options that are compatible with Smail
642 3, and some further options that are new to Exim. Chapter <xref linkend="CHAPcommandline"/>
643 documents all Exim&#x2019;s command line options. This information is automatically
644 made into the man page that forms part of the Exim distribution.
645 </para>
646 <para>
647 Control of messages on the queue can be done via certain privileged command
648 line options. There is also an optional monitor program called <emphasis>eximon</emphasis>,
649 which displays current information in an X window, and which contains a menu
650 interface to Exim&#x2019;s command line administration options.
651 </para>
652 </section>
653 <section>
654 <title>Terminology</title>
655 <para>
656 <indexterm role="concept">
657 <primary>terminology definitions</primary>
658 </indexterm>
659 <indexterm role="concept">
660 <primary>body of message</primary>
661 <secondary>definition of</secondary>
662 </indexterm>
663 The <emphasis>body</emphasis> of a message is the actual data that the sender wants to transmit.
664 It is the last part of a message, and is separated from the <emphasis>header</emphasis> (see
665 below) by a blank line.
666 </para>
667 <para>
668 <indexterm role="concept">
669 <primary>bounce message</primary>
670 <secondary>definition of</secondary>
671 </indexterm>
672 When a message cannot be delivered, it is normally returned to the sender in a
673 delivery failure message or a <quote>non-delivery report</quote> (NDR). The term
674 <emphasis>bounce</emphasis> is commonly used for this action, and the error reports are often
675 called <emphasis>bounce messages</emphasis>. This is a convenient shorthand for <quote>delivery
676 failure error report</quote>. Such messages have an empty sender address in the
677 message&#x2019;s <emphasis>envelope</emphasis> (see below) to ensure that they cannot themselves give
678 rise to further bounce messages.
679 </para>
680 <para>
681 The term <emphasis>default</emphasis> appears frequently in this manual. It is used to qualify a
682 value which is used in the absence of any setting in the configuration. It may
683 also qualify an action which is taken unless a configuration setting specifies
684 otherwise.
685 </para>
686 <para>
687 The term <emphasis>defer</emphasis> is used when the delivery of a message to a specific
688 destination cannot immediately take place for some reason (a remote host may be
689 down, or a user&#x2019;s local mailbox may be full). Such deliveries are <emphasis>deferred</emphasis>
690 until a later time.
691 </para>
692 <para>
693 The word <emphasis>domain</emphasis> is sometimes used to mean all but the first component of a
694 host&#x2019;s name. It is <emphasis>not</emphasis> used in that sense here, where it normally refers to
695 the part of an email address following the @ sign.
696 </para>
697 <para>
698 <indexterm role="concept">
699 <primary>envelope</primary>
700 <secondary>definition of</secondary>
701 </indexterm>
702 <indexterm role="concept">
703 <primary>sender</primary>
704 <secondary>definition of</secondary>
705 </indexterm>
706 A message in transit has an associated <emphasis>envelope</emphasis>, as well as a header and a
707 body. The envelope contains a sender address (to which bounce messages should
708 be delivered), and any number of recipient addresses. References to the
709 sender or the recipients of a message usually mean the addresses in the
710 envelope. An MTA uses these addresses for delivery, and for returning bounce
711 messages, not the addresses that appear in the header lines.
712 </para>
713 <para>
714 <indexterm role="concept">
715 <primary>message header</primary>
716 <secondary>definition of</secondary>
717 </indexterm>
718 <indexterm role="concept">
719 <primary>header section</primary>
720 <secondary>definition of</secondary>
721 </indexterm>
722 The <emphasis>header</emphasis> of a message is the first part of a message&#x2019;s text, consisting
723 of a number of lines, each of which has a name such as <emphasis>From:</emphasis>, <emphasis>To:</emphasis>,
724 <emphasis>Subject:</emphasis>, etc. Long header lines can be split over several text lines by
725 indenting the continuations. The header is separated from the body by a blank
726 line.
727 </para>
728 <para>
729 <indexterm role="concept">
730 <primary>local part</primary>
731 <secondary>definition of</secondary>
732 </indexterm>
733 <indexterm role="concept">
734 <primary>domain</primary>
735 <secondary>definition of</secondary>
736 </indexterm>
737 The term <emphasis>local part</emphasis>, which is taken from RFC 2822, is used to refer to that
738 part of an email address that precedes the @ sign. The part that follows the
739 @ sign is called the <emphasis>domain</emphasis> or <emphasis>mail domain</emphasis>.
740 </para>
741 <para>
742 <indexterm role="concept">
743 <primary>local delivery</primary>
744 <secondary>definition of</secondary>
745 </indexterm>
746 <indexterm role="concept">
747 <primary>remote delivery</primary>
748 <secondary>definition of</secondary>
749 </indexterm>
750 The terms <emphasis>local delivery</emphasis> and <emphasis>remote delivery</emphasis> are used to distinguish
751 delivery to a file or a pipe on the local host from delivery by SMTP over
752 TCP/IP to another host. As far as Exim is concerned, all hosts other than the
753 host it is running on are <emphasis>remote</emphasis>.
754 </para>
755 <para>
756 <indexterm role="concept">
757 <primary>return path</primary>
758 <secondary>definition of</secondary>
759 </indexterm>
760 <emphasis>Return path</emphasis> is another name that is used for the sender address in a
761 message&#x2019;s envelope.
762 </para>
763 <para>
764 <indexterm role="concept">
765 <primary>queue</primary>
766 <secondary>definition of</secondary>
767 </indexterm>
768 The term <emphasis>queue</emphasis> is used to refer to the set of messages awaiting delivery,
769 because this term is in widespread use in the context of MTAs. However, in
770 Exim&#x2019;s case the reality is more like a pool than a queue, because there is
771 normally no ordering of waiting messages.
772 </para>
773 <para>
774 <indexterm role="concept">
775 <primary>queue runner</primary>
776 <secondary>definition of</secondary>
777 </indexterm>
778 The term <emphasis>queue runner</emphasis> is used to describe a process that scans the queue
779 and attempts to deliver those messages whose retry times have come. This term
780 is used by other MTAs, and also relates to the command <option>runq</option>, but in Exim
781 the waiting messages are normally processed in an unpredictable order.
782 </para>
783 <para>
784 <indexterm role="concept">
785 <primary>spool directory</primary>
786 <secondary>definition of</secondary>
787 </indexterm>
788 The term <emphasis>spool directory</emphasis> is used for a directory in which Exim keeps the
789 messages on its queue &ndash; that is, those that it is in the process of
790 delivering. This should not be confused with the directory in which local
791 mailboxes are stored, which is called a <quote>spool directory</quote> by some people. In
792 the Exim documentation, <quote>spool</quote> is always used in the first sense.
793 </para>
794 </section>
795 </chapter>
796
797 <chapter>
798 <title>Incorporated code</title>
799 <para>
800 <indexterm role="concept">
801 <primary>incorporated code</primary>
802 </indexterm>
803 <indexterm role="concept">
804 <primary>regular expressions</primary>
805 <secondary>library</secondary>
806 </indexterm>
807 <indexterm role="concept">
808 <primary>PCRE</primary>
809 </indexterm>
810 A number of pieces of external code are included in the Exim distribution.
811 </para>
812 <itemizedlist>
813 <listitem>
814 <para>
815 Regular expressions are supported in the main Exim program and in the Exim
816 monitor using the freely-distributable PCRE library, copyright &copy;
817 University of Cambridge. The source is distributed in the directory
818 <filename>src/pcre</filename>. However, this is a cut-down version of PCRE. If you want to use
819 the PCRE library in other programs, you should obtain and install the full
820 version from <emphasis role="bold"><ulink url="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre">ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre</ulink></emphasis>.
821 </para>
822 </listitem>
823 <listitem>
824 <para>
825 <indexterm role="concept">
826 <primary>cdb</primary>
827 <secondary>acknowledgement</secondary>
828 </indexterm>
829 Support for the cdb (Constant DataBase) lookup method is provided by code
830 contributed by Nigel Metheringham of (at the time he contributed it) Planet
831 Online Ltd. The implementation is completely contained within the code of Exim.
832 It does not link against an external cdb library. The code contains the
833 following statements:
834 </para>
835 <blockquote>
836 <para>
837 Copyright &copy; 1998 Nigel Metheringham, Planet Online Ltd
838 </para>
839 <para>
840 This program is free software; you can redistribute it and/or modify it under
841 the terms of the GNU General Public License as published by the Free Software
842 Foundation; either version 2 of the License, or (at your option) any later
843 version.
844 </para>
845 <para>
846 This code implements Dan Bernstein&#x2019;s Constant DataBase (cdb) spec. Information,
847 the spec and sample code for cdb can be obtained from
848 <emphasis role="bold"><ulink url="http://www.pobox.com/~djb/cdb.html">http://www.pobox.com/~djb/cdb.html</ulink></emphasis>. This implementation borrows some
849 code from Dan Bernstein&#x2019;s implementation (which has no license restrictions
850 applied to it).
851 </para>
852 </blockquote>
853 </listitem>
854 <listitem>
855 <para>
856 <indexterm role="concept">
857 <primary>SPA authentication</primary>
858 </indexterm>
859 <indexterm role="concept">
860 <primary>Samba project</primary>
861 </indexterm>
862 <indexterm role="concept">
863 <primary>Microsoft Secure Password Authentication</primary>
864 </indexterm>
865 Client support for Microsoft&#x2019;s <emphasis>Secure Password Authentication</emphasis> is provided
866 by code contributed by Marc Prud&#x2019;hommeaux. Server support was contributed by
867 Tom Kistner. This includes code taken from the Samba project, which is released
868 under the Gnu GPL.
869 </para>
870 </listitem>
871 <listitem>
872 <para>
873 <indexterm role="concept">
874 <primary>Cyrus</primary>
875 </indexterm>
876 <indexterm role="concept">
877 <primary><emphasis>pwcheck</emphasis> daemon</primary>
878 </indexterm>
879 <indexterm role="concept">
880 <primary><emphasis>pwauthd</emphasis> daemon</primary>
881 </indexterm>
882 Support for calling the Cyrus <emphasis>pwcheck</emphasis> and <emphasis>saslauthd</emphasis> daemons is provided
883 by code taken from the Cyrus-SASL library and adapted by Alexander S.
884 Sabourenkov. The permission notice appears below, in accordance with the
885 conditions expressed therein.
886 </para>
887 <blockquote>
888 <para>
889 Copyright &copy; 2001 Carnegie Mellon University.  All rights reserved.
890 </para>
891 <para>
892 Redistribution and use in source and binary forms, with or without
893 modification, are permitted provided that the following conditions
894 are met:
895 </para>
896 <orderedlist numeration="arabic">
897 <listitem>
898 <para>
899 Redistributions of source code must retain the above copyright
900 notice, this list of conditions and the following disclaimer.
901 </para>
902 </listitem>
903 <listitem>
904 <para>
905 Redistributions in binary form must reproduce the above copyright
906 notice, this list of conditions and the following disclaimer in
907 the documentation and/or other materials provided with the
908 distribution.
909 </para>
910 </listitem>
911 <listitem>
912 <para>
913 The name <quote>Carnegie Mellon University</quote> must not be used to
914 endorse or promote products derived from this software without
915 prior written permission. For permission or any other legal
916 details, please contact
917 </para>
918 <literallayout>
919               Office of Technology Transfer
920               Carnegie Mellon University
921               5000 Forbes Avenue
922               Pittsburgh, PA  15213-3890
923               (412) 268-4387, fax: (412) 268-7395
924               tech-transfer@andrew.cmu.edu
925 </literallayout>
926 </listitem>
927 <listitem>
928 <para>
929 Redistributions of any form whatsoever must retain the following
930 acknowledgment:
931 </para>
932 <para>
933 <quote>This product includes software developed by Computing Services
934 at Carnegie Mellon University (<emphasis role="bold"><ulink url="http://www.cmu.edu/computing/">http://www.cmu.edu/computing/</ulink></emphasis>.</quote>
935 </para>
936 <para>
937 CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
938 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
939 AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
940 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
941 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
942 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
943 OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
944 </para>
945 </listitem>
946 </orderedlist>
947 </blockquote>
948 </listitem>
949 <listitem>
950 <para>
951 <indexterm role="concept">
952 <primary>Exim monitor</primary>
953 <secondary>acknowledgement</secondary>
954 </indexterm>
955 <indexterm role="concept">
956 <primary>X-windows</primary>
957 </indexterm>
958 <indexterm role="concept">
959 <primary>Athena</primary>
960 </indexterm>
961 The Exim Monitor program, which is an X-Window application, includes
962 modified versions of the Athena StripChart and TextPop widgets.
963 This code is copyright by DEC and MIT, and their permission notice appears
964 below, in accordance with the conditions expressed therein.
965 </para>
966 <blockquote>
967 <para>
968 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
969 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
970 </para>
971 <para>
972 All Rights Reserved
973 </para>
974 <para>
975 Permission to use, copy, modify, and distribute this software and its
976 documentation for any purpose and without fee is hereby granted,
977 provided that the above copyright notice appear in all copies and that
978 both that copyright notice and this permission notice appear in
979 supporting documentation, and that the names of Digital or MIT not be
980 used in advertising or publicity pertaining to distribution of the
981 software without specific, written prior permission.
982 </para>
983 <para>
984 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
985 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
986 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
987 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
988 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
989 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
990 SOFTWARE.
991 </para>
992 </blockquote>
993 </listitem>
994 <listitem>
995 <para>
996 Many people have contributed code fragments, some large, some small, that were
997 not covered by any specific licence requirements. It is assumed that the
998 contributors are happy to see their code incoporated into Exim under the GPL.
999 </para>
1000 </listitem>
1001 </itemizedlist>
1002 </chapter>
1003
1004 <chapter>
1005 <title>How Exim receives and delivers mail</title>
1006 <titleabbrev>Receiving and delivering mail</titleabbrev>
1007 <section>
1008 <title>Overall philosophy</title>
1009 <para>
1010 <indexterm role="concept">
1011 <primary>design philosophy</primary>
1012 </indexterm>
1013 Exim is designed to work efficiently on systems that are permanently connected
1014 to the Internet and are handling a general mix of mail. In such circumstances,
1015 most messages can be delivered immediately. Consequently, Exim does not
1016 maintain independent queues of messages for specific domains or hosts, though
1017 it does try to send several messages in a single SMTP connection after a host
1018 has been down, and it also maintains per-host retry information.
1019 </para>
1020 </section>
1021 <section>
1022 <title>Policy control</title>
1023 <para>
1024 <indexterm role="concept">
1025 <primary>policy control</primary>
1026 <secondary>overview</secondary>
1027 </indexterm>
1028 Policy controls are now an important feature of MTAs that are connected to the
1029 Internet. Perhaps their most important job is to stop MTAs being abused as
1030 <quote>open relays</quote> by misguided individuals who send out vast amounts of
1031 unsolicited junk, and want to disguise its source. Exim provides flexible
1032 facilities for specifying policy controls on incoming mail:
1033 </para>
1034 <itemizedlist>
1035 <listitem>
1036 <para>
1037 <indexterm role="concept">
1038 <primary>access control lists (ACLs)</primary>
1039 <secondary>introduction</secondary>
1040 </indexterm>
1041 Exim 4 (unlike previous versions of Exim) implements policy controls on
1042 incoming mail by means of <emphasis>Access Control Lists</emphasis> (ACLs). Each list is a
1043 series of statements that may either grant or deny access. ACLs can be used at
1044 several places in the SMTP dialogue while receiving a message from a remote
1045 host. However, the most common places are after each RCPT command, and at the
1046 very end of the message. The sysadmin can specify conditions for accepting or
1047 rejecting individual recipients or the entire message, respectively, at these
1048 two points (see chapter <xref linkend="CHAPACL"/>). Denial of access results in an SMTP
1049 error code.
1050 </para>
1051 </listitem>
1052 <listitem>
1053 <para>
1054 An ACL is also available for locally generated, non-SMTP messages. In this
1055 case, the only available actions are to accept or deny the entire message.
1056 </para>
1057 </listitem>
1058 <listitem>
1059 <para>
1060 When Exim is compiled with the content-scanning extension, facilities are
1061 provided in the ACL mechanism for passing the message to external virus and/or
1062 spam scanning software. The result of such a scan is passed back to the ACL,
1063 which can then use it to decide what to do with the message.
1064 </para>
1065 </listitem>
1066 <listitem>
1067 <para>
1068 When a message has been received, either from a remote host or from the local
1069 host, but before the final acknowledgement has been sent, a locally supplied C
1070 function called <function>local_scan()</function> can be run to inspect the message and decide
1071 whether to accept it or not (see chapter <xref linkend="CHAPlocalscan"/>). If the message
1072 is accepted, the list of recipients can be modified by the function.
1073 </para>
1074 </listitem>
1075 <listitem>
1076 <para>
1077 Using the <function>local_scan()</function> mechanism is another way of calling external scanner
1078 software. The <option>SA-Exim</option> add-on package works this way. It does not require
1079 Exim to be compiled with the content-scanning extension.
1080 </para>
1081 </listitem>
1082 <listitem>
1083 <para>
1084 After a message has been accepted, a further checking mechanism is available in
1085 the form of the <emphasis>system filter</emphasis> (see chapter <xref linkend="CHAPsystemfilter"/>). This
1086 runs at the start of every delivery process.
1087 </para>
1088 </listitem>
1089 </itemizedlist>
1090 </section>
1091 <section>
1092 <title>User filters</title>
1093 <para>
1094 <indexterm role="concept">
1095 <primary>filter</primary>
1096 <secondary>introduction</secondary>
1097 </indexterm>
1098 <indexterm role="concept">
1099 <primary>Sieve filter</primary>
1100 </indexterm>
1101 In a conventional Exim configuration, users are able to run private filters by
1102 setting up appropriate <filename>.forward</filename> files in their home directories. See
1103 chapter <xref linkend="CHAPredirect"/> (about the <command>redirect</command> router) for the
1104 configuration needed to support this, and the separate document entitled
1105 <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis> for user details. Two different kinds
1106 of filtering are available:
1107 </para>
1108 <itemizedlist>
1109 <listitem>
1110 <para>
1111 Sieve filters are written in the standard filtering language that is defined
1112 by RFC 3028.
1113 </para>
1114 </listitem>
1115 <listitem>
1116 <para>
1117 Exim filters are written in a syntax that is unique to Exim, but which is more
1118 powerful than Sieve, which it pre-dates.
1119 </para>
1120 </listitem>
1121 </itemizedlist>
1122 <para>
1123 User filters are run as part of the routing process, described below.
1124 </para>
1125 </section>
1126 <section id="SECTmessiden">
1127 <title>Message identification</title>
1128 <para>
1129 <indexterm role="concept">
1130 <primary>message ids</primary>
1131 <secondary>details of format</secondary>
1132 </indexterm>
1133 <indexterm role="concept">
1134 <primary>format</primary>
1135 <secondary>of message id</secondary>
1136 </indexterm>
1137 <indexterm role="concept">
1138 <primary>id of message</primary>
1139 </indexterm>
1140 <indexterm role="concept">
1141 <primary>base62</primary>
1142 </indexterm>
1143 <indexterm role="concept">
1144 <primary>base36</primary>
1145 </indexterm>
1146 <indexterm role="concept">
1147 <primary>Darwin</primary>
1148 </indexterm>
1149 <indexterm role="concept">
1150 <primary>Cygwin</primary>
1151 </indexterm>
1152 Every message handled by Exim is given a <emphasis>message id</emphasis> which is sixteen
1153 characters long. It is divided into three parts, separated by hyphens, for
1154 example <literal>16VDhn-0001bo-D3</literal>. Each part is a sequence of letters and digits,
1155 normally encoding numbers in base 62. However, in the Darwin operating
1156 system (Mac OS X) and when Exim is compiled to run under Cygwin, base 36
1157 (avoiding the use of lower case letters) is used instead, because the message
1158 id is used to construct file names, and the names of files in those systems are
1159 not always case-sensitive.
1160 </para>
1161 <para>
1162 <indexterm role="concept">
1163 <primary>pid (process id)</primary>
1164 <secondary>re-use of</secondary>
1165 </indexterm>
1166 The detail of the contents of the message id have changed as Exim has evolved.
1167 Earlier versions relied on the operating system not re-using a process id (pid)
1168 within one second. On modern operating systems, this assumption can no longer
1169 be made, so the algorithm had to be changed. To retain backward compatibility,
1170 the format of the message id was retained, which is why the following rules are
1171 somewhat eccentric:
1172 </para>
1173 <itemizedlist>
1174 <listitem>
1175 <para>
1176 The first six characters of the message id are the time at which the message
1177 started to be received, to a granularity of one second. That is, this field
1178 contains the number of seconds since the start of the epoch (the normal Unix
1179 way of representing the date and time of day).
1180 </para>
1181 </listitem>
1182 <listitem>
1183 <para>
1184 After the first hyphen, the next six characters are the id of the process that
1185 received the message.
1186 </para>
1187 </listitem>
1188 <listitem>
1189 <para>
1190 There are two different possibilities for the final two characters:
1191 </para>
1192 <orderedlist numeration="arabic">
1193 <listitem>
1194 <para>
1195 <indexterm role="concept">
1196 <primary><option>localhost_number</option></primary>
1197 </indexterm>
1198 If <option>localhost_number</option> is not set, this value is the fractional part of the
1199 time of reception, normally in units of 1/2000 of a second, but for systems
1200 that must use base 36 instead of base 62 (because of case-insensitive file
1201 systems), the units are 1/1000 of a second.
1202 </para>
1203 </listitem>
1204 <listitem>
1205 <para>
1206 If <option>localhost_number</option> is set, it is multiplied by 200 (100) and added to
1207 the fractional part of the time, which in this case is in units of 1/200
1208 (1/100) of a second.
1209 </para>
1210 </listitem>
1211 </orderedlist>
1212 </listitem>
1213 </itemizedlist>
1214 <para>
1215 After a message has been received, Exim waits for the clock to tick at the
1216 appropriate resolution before proceeding, so that if another message is
1217 received by the same process, or by another process with the same (re-used)
1218 pid, it is guaranteed that the time will be different. In most cases, the clock
1219 will already have ticked while the message was being received.
1220 </para>
1221 </section>
1222 <section>
1223 <title>Receiving mail</title>
1224 <para>
1225 <indexterm role="concept">
1226 <primary>receiving mail</primary>
1227 </indexterm>
1228 <indexterm role="concept">
1229 <primary>message</primary>
1230 <secondary>reception</secondary>
1231 </indexterm>
1232 The only way Exim can receive mail from another host is using SMTP over
1233 TCP/IP, in which case the sender and recipient addresses are transferred using
1234 SMTP commands. However, from a locally running process (such as a user&#x2019;s MUA),
1235 there are several possibilities:
1236 </para>
1237 <itemizedlist>
1238 <listitem>
1239 <para>
1240 If the process runs Exim with the <option>-bm</option> option, the message is read
1241 non-interactively (usually via a pipe), with the recipients taken from the
1242 command line, or from the body of the message if <option>-t</option> is also used.
1243 </para>
1244 </listitem>
1245 <listitem>
1246 <para>
1247 If the process runs Exim with the <option>-bS</option> option, the message is also read
1248 non-interactively, but in this case the recipients are listed at the start of
1249 the message in a series of SMTP RCPT commands, terminated by a DATA
1250 command. This is so-called <quote>batch SMTP</quote> format,
1251 but it isn&#x2019;t really SMTP. The SMTP commands are just another way of passing
1252 envelope addresses in a non-interactive submission.
1253 </para>
1254 </listitem>
1255 <listitem>
1256 <para>
1257 If the process runs Exim with the <option>-bs</option> option, the message is read
1258 interactively, using the SMTP protocol. A two-way pipe is normally used for
1259 passing data between the local process and the Exim process.
1260 This is <quote>real</quote> SMTP and is handled in the same way as SMTP over TCP/IP. For
1261 example, the ACLs for SMTP commands are used for this form of submission.
1262 </para>
1263 </listitem>
1264 <listitem>
1265 <para>
1266 A local process may also make a TCP/IP call to the host&#x2019;s loopback address
1267 (127.0.0.1) or any other of its IP addresses. When receiving messages, Exim
1268 does not treat the loopback address specially. It treats all such connections
1269 in the same way as connections from other hosts.
1270 </para>
1271 </listitem>
1272 </itemizedlist>
1273 <para>
1274 <indexterm role="concept">
1275 <primary>message sender</primary>
1276 <secondary>constructed by Exim</secondary>
1277 </indexterm>
1278 <indexterm role="concept">
1279 <primary>sender</primary>
1280 <secondary>constructed by Exim</secondary>
1281 </indexterm>
1282 In the three cases that do not involve TCP/IP, the sender address is
1283 constructed from the login name of the user that called Exim and a default
1284 qualification domain (which can be set by the <option>qualify_domain</option> configuration
1285 option). For local or batch SMTP, a sender address that is passed using the
1286 SMTP MAIL command is ignored. However, the system administrator may allow
1287 certain users (<quote>trusted users</quote>) to specify a different sender address
1288 unconditionally, or all users to specify certain forms of different sender
1289 address. The <option>-f</option> option or the SMTP MAIL command is used to specify these
1290 different addresses. See section <xref linkend="SECTtrustedadmin"/> for details of trusted
1291 users, and the <option>untrusted_set_sender</option> option for a way of allowing untrusted
1292 users to change sender addresses.
1293 </para>
1294 <para>
1295 Messages received by either of the non-interactive mechanisms are subject to
1296 checking by the non-SMTP ACL, if one is defined. Messages received using SMTP
1297 (either over TCP/IP, or interacting with a local process) can be checked by a
1298 number of ACLs that operate at different times during the SMTP session. Either
1299 individual recipients, or the entire message, can be rejected if local policy
1300 requirements are not met. The <function>local_scan()</function> function (see chapter
1301 <xref linkend="CHAPlocalscan"/>) is run for all incoming messages.
1302 </para>
1303 <para>
1304 Exim can be configured not to start a delivery process when a message is
1305 received; this can be unconditional, or depend on the number of incoming SMTP
1306 connections or the system load. In these situations, new messages wait on the
1307 queue until a queue runner process picks them up. However, in standard
1308 configurations under normal conditions, delivery is started as soon as a
1309 message is received.
1310 </para>
1311 </section>
1312 <section>
1313 <title>Handling an incoming message</title>
1314 <para>
1315 <indexterm role="concept">
1316 <primary>spool directory</primary>
1317 <secondary>files that hold a message</secondary>
1318 </indexterm>
1319 <indexterm role="concept">
1320 <primary>file</primary>
1321 <secondary>how a message is held</secondary>
1322 </indexterm>
1323 When Exim accepts a message, it writes two files in its spool directory. The
1324 first contains the envelope information, the current status of the message, and
1325 the header lines, and the second contains the body of the message. The names of
1326 the two spool files consist of the message id, followed by <literal>-H</literal> for the
1327 file containing the envelope and header, and <literal>-D</literal> for the data file.
1328 </para>
1329 <para>
1330 <indexterm role="concept">
1331 <primary>spool directory</primary>
1332 <secondary><filename>input</filename> sub-directory</secondary>
1333 </indexterm>
1334 By default all these message files are held in a single directory called
1335 <filename>input</filename> inside the general Exim spool directory. Some operating systems do
1336 not perform very well if the number of files in a directory gets very large; to
1337 improve performance in such cases, the <option>split_spool_directory</option> option can be
1338 used. This causes Exim to split up the input files into 62 sub-directories
1339 whose names are single letters or digits.
1340 </para>
1341 <para>
1342 The envelope information consists of the address of the message&#x2019;s sender and
1343 the addresses of the recipients. This information is entirely separate from
1344 any addresses contained in the header lines. The status of the message includes
1345 a list of recipients who have already received the message. The format of the
1346 first spool file is described in chapter <xref linkend="CHAPspool"/>.
1347 </para>
1348 <para>
1349 <indexterm role="concept">
1350 <primary>rewriting</primary>
1351 <secondary>addresses</secondary>
1352 </indexterm>
1353 Address rewriting that is specified in the rewrite section of the configuration
1354 (see chapter <xref linkend="CHAPrewrite"/>) is done once and for all on incoming addresses,
1355 both in the header lines and the envelope, at the time the message is accepted.
1356 If during the course of delivery additional addresses are generated (for
1357 example, via aliasing), these new addresses are rewritten as soon as they are
1358 generated. At the time a message is actually delivered (transported) further
1359 rewriting can take place; because this is a transport option, it can be
1360 different for different forms of delivery. It is also possible to specify the
1361 addition or removal of certain header lines at the time the message is
1362 delivered (see chapters <xref linkend="CHAProutergeneric"/> and
1363 <xref linkend="CHAPtransportgeneric"/>).
1364 </para>
1365 </section>
1366 <section>
1367 <title>Life of a message</title>
1368 <para>
1369 <indexterm role="concept">
1370 <primary>message</primary>
1371 <secondary>life of</secondary>
1372 </indexterm>
1373 <indexterm role="concept">
1374 <primary>message</primary>
1375 <secondary>frozen</secondary>
1376 </indexterm>
1377 A message remains in the spool directory until it is completely delivered to
1378 its recipients or to an error address, or until it is deleted by an
1379 administrator or by the user who originally created it. In cases when delivery
1380 cannot proceed &ndash; for example, when a message can neither be delivered to its
1381 recipients nor returned to its sender, the message is marked <quote>frozen</quote> on the
1382 spool, and no more deliveries are attempted.
1383 </para>
1384 <para>
1385 <indexterm role="concept">
1386 <primary>frozen messages</primary>
1387 <secondary>thawing</secondary>
1388 </indexterm>
1389 <indexterm role="concept">
1390 <primary>message</primary>
1391 <secondary>thawing frozen</secondary>
1392 </indexterm>
1393 An administrator can <quote>thaw</quote> such messages when the problem has been
1394 corrected, and can also freeze individual messages by hand if necessary. In
1395 addition, an administrator can force a delivery error, causing a bounce message
1396 to be sent.
1397 </para>
1398 <para>
1399 <indexterm role="concept">
1400 <primary><option>timeout_frozen_after</option></primary>
1401 </indexterm>
1402 <indexterm role="concept">
1403 <primary><option>ignore_bounce_errors_after</option></primary>
1404 </indexterm>
1405 There are options called <option>ignore_bounce_errors_after</option> and
1406 <option>timeout_frozen_after</option>, which discard frozen messages after a certain time.
1407 The first applies only to frozen bounces, the second to any frozen messages.
1408 </para>
1409 <para>
1410 <indexterm role="concept">
1411 <primary>message</primary>
1412 <secondary>log file for</secondary>
1413 </indexterm>
1414 <indexterm role="concept">
1415 <primary>log</primary>
1416 <secondary>file for each message</secondary>
1417 </indexterm>
1418 While Exim is working on a message, it writes information about each delivery
1419 attempt to its main log file. This includes successful, unsuccessful, and
1420 delayed deliveries for each recipient (see chapter <xref linkend="CHAPlog"/>). The log
1421 lines are also written to a separate <emphasis>message log</emphasis> file for each message.
1422 These logs are solely for the benefit of the administrator, and are normally
1423 deleted along with the spool files when processing of a message is complete.
1424 The use of individual message logs can be disabled by setting
1425 <option>no_message_logs</option>; this might give an improvement in performance on very busy
1426 systems.
1427 </para>
1428 <para>
1429 <indexterm role="concept">
1430 <primary>journal file</primary>
1431 </indexterm>
1432 <indexterm role="concept">
1433 <primary>file</primary>
1434 <secondary>journal</secondary>
1435 </indexterm>
1436 All the information Exim itself needs to set up a delivery is kept in the first
1437 spool file, along with the header lines. When a successful delivery occurs, the
1438 address is immediately written at the end of a journal file, whose name is the
1439 message id followed by <literal>-J</literal>. At the end of a delivery run, if there are some
1440 addresses left to be tried again later, the first spool file (the <literal>-H</literal> file)
1441 is updated to indicate which these are, and the journal file is then deleted.
1442 Updating the spool file is done by writing a new file and renaming it, to
1443 minimize the possibility of data loss.
1444 </para>
1445 <para>
1446 Should the system or the program crash after a successful delivery but before
1447 the spool file has been updated, the journal is left lying around. The next
1448 time Exim attempts to deliver the message, it reads the journal file and
1449 updates the spool file before proceeding. This minimizes the chances of double
1450 deliveries caused by crashes.
1451 </para>
1452 </section>
1453 <section id="SECTprocaddress">
1454 <title>Processing an address for delivery</title>
1455 <para>
1456 <indexterm role="concept">
1457 <primary>drivers</primary>
1458 <secondary>definition of</secondary>
1459 </indexterm>
1460 <indexterm role="concept">
1461 <primary>router</primary>
1462 <secondary>definition of</secondary>
1463 </indexterm>
1464 <indexterm role="concept">
1465 <primary>transport</primary>
1466 <secondary>definition of</secondary>
1467 </indexterm>
1468 The main delivery processing elements of Exim are called <emphasis>routers</emphasis> and
1469 <emphasis>transports</emphasis>, and collectively these are known as <emphasis>drivers</emphasis>. Code for a
1470 number of them is provided in the source distribution, and compile-time options
1471 specify which ones are included in the binary. Run time options specify which
1472 ones are actually used for delivering messages.
1473 </para>
1474 <para>
1475 <indexterm role="concept">
1476 <primary>drivers</primary>
1477 <secondary>instance definition</secondary>
1478 </indexterm>
1479 Each driver that is specified in the run time configuration is an <emphasis>instance</emphasis>
1480 of that particular driver type. Multiple instances are allowed; for example,
1481 you can set up several different <command>smtp</command> transports, each with different
1482 option values that might specify different ports or different timeouts. Each
1483 instance has its own identifying name. In what follows we will normally use the
1484 instance name when discussing one particular instance (that is, one specific
1485 configuration of the driver), and the generic driver name when discussing
1486 the driver&#x2019;s features in general.
1487 </para>
1488 <para>
1489 A <emphasis>router</emphasis> is a driver that operates on an address, either determining how
1490 its delivery should happen, by assigning it to a specific transport, or
1491 converting the address into one or more new addresses (for example, via an
1492 alias file). A router may also explicitly choose to fail an address, causing it
1493 to be bounced.
1494 </para>
1495 <para>
1496 A <emphasis>transport</emphasis> is a driver that transmits a copy of the message from Exim&#x2019;s
1497 spool to some destination. There are two kinds of transport: for a <emphasis>local</emphasis>
1498 transport, the destination is a file or a pipe on the local host, whereas for a
1499 <emphasis>remote</emphasis> transport the destination is some other host. A message is passed
1500 to a specific transport as a result of successful routing. If a message has
1501 several recipients, it may be passed to a number of different transports.
1502 </para>
1503 <para>
1504 <indexterm role="concept">
1505 <primary>preconditions</primary>
1506 <secondary>definition of</secondary>
1507 </indexterm>
1508 An address is processed by passing it to each configured router instance in
1509 turn, subject to certain preconditions, until a router accepts the address or
1510 specifies that it should be bounced. We will describe this process in more
1511 detail shortly. First, as a simple example, we consider how each recipient
1512 address in a message is processed in a small configuration of three routers.
1513 </para>
1514 <para>
1515 To make this a more concrete example, it is described in terms of some actual
1516 routers, but remember, this is only an example. You can configure Exim&#x2019;s
1517 routers in many different ways, and there may be any number of routers in a
1518 configuration.
1519 </para>
1520 <para>
1521 The first router that is specified in a configuration is often one that handles
1522 addresses in domains that are not recognized specially by the local host. These
1523 are typically addresses for arbitrary domains on the Internet. A precondition
1524 is set up which looks for the special domains known to the host (for example,
1525 its own domain name), and the router is run for addresses that do <emphasis>not</emphasis>
1526 match. Typically, this is a router that looks up domains in the DNS in order to
1527 find the hosts to which this address routes. If it succeeds, the address is
1528 assigned to a suitable SMTP transport; if it does not succeed, the router is
1529 configured to fail the address.
1530 </para>
1531 <para>
1532 The second router is reached only when the domain is recognized as one that
1533 <quote>belongs</quote> to the local host. This router does redirection &ndash; also known as
1534 aliasing and forwarding. When it generates one or more new addresses from the
1535 original, each of them is routed independently from the start. Otherwise, the
1536 router may cause an address to fail, or it may simply decline to handle the
1537 address, in which case the address is passed to the next router.
1538 </para>
1539 <para>
1540 The final router in many configurations is one that checks to see if the
1541 address belongs to a local mailbox. The precondition may involve a check to
1542 see if the local part is the name of a login account, or it may look up the
1543 local part in a file or a database. If its preconditions are not met, or if
1544 the router declines, we have reached the end of the routers. When this happens,
1545 the address is bounced.
1546 </para>
1547 </section>
1548 <section>
1549 <title>Processing an address for verification</title>
1550 <para>
1551 <indexterm role="concept">
1552 <primary>router</primary>
1553 <secondary>for verification</secondary>
1554 </indexterm>
1555 <indexterm role="concept">
1556 <primary>verifying address</primary>
1557 <secondary>overview</secondary>
1558 </indexterm>
1559 As well as being used to decide how to deliver to an address, Exim&#x2019;s routers
1560 are also used for <emphasis>address verification</emphasis>. Verification can be requested as
1561 one of the checks to be performed in an ACL for incoming messages, on both
1562 sender and recipient addresses, and it can be tested using the <option>-bv</option> and
1563 <option>-bvs</option> command line options.
1564 </para>
1565 <para>
1566 When an address is being verified, the routers are run in <quote>verify mode</quote>. This
1567 does not affect the way the routers work, but it is a state that can be
1568 detected. By this means, a router can be skipped or made to behave differently
1569 when verifying. A common example is a configuration in which the first router
1570 sends all messages to a message-scanning program, unless they have been
1571 previously scanned. Thus, the first router accepts all addresses without any
1572 checking, making it useless for verifying. Normally, the <option>no_verify</option> option
1573 would be set for such a router, causing it to be skipped in verify mode.
1574 </para>
1575 </section>
1576 <section id="SECTrunindrou">
1577 <title>Running an individual router</title>
1578 <para>
1579 <indexterm role="concept">
1580 <primary>router</primary>
1581 <secondary>running details</secondary>
1582 </indexterm>
1583 <indexterm role="concept">
1584 <primary>preconditions</primary>
1585 <secondary>checking</secondary>
1586 </indexterm>
1587 <indexterm role="concept">
1588 <primary>router</primary>
1589 <secondary>result of running</secondary>
1590 </indexterm>
1591 As explained in the example above, a number of preconditions are checked before
1592 running a router. If any are not met, the router is skipped, and the address is
1593 passed to the next router. When all the preconditions on a router <emphasis>are</emphasis> met,
1594 the router is run. What happens next depends on the outcome, which is one of
1595 the following:
1596 </para>
1597 <itemizedlist>
1598 <listitem>
1599 <para>
1600 <emphasis>accept</emphasis>: The router accepts the address, and either assigns it to a
1601 transport, or generates one or more <quote>child</quote> addresses. Processing the
1602 original address ceases,
1603 <indexterm role="concept">
1604 <primary><option>unseen</option> option</primary>
1605 </indexterm>
1606 unless the <option>unseen</option> option is set on the router. This option
1607 can be used to set up multiple deliveries with different routing (for example,
1608 for keeping archive copies of messages). When <option>unseen</option> is set, the address is
1609 passed to the next router. Normally, however, an <emphasis>accept</emphasis> return marks the
1610 end of routing.
1611 </para>
1612 <para>
1613 Any child addresses generated by the router are processed independently,
1614 starting with the first router by default. It is possible to change this by
1615 setting the <option>redirect_router</option> option to specify which router to start at for
1616 child addresses. Unlike <option>pass_router</option> (see below) the router specified by
1617 <option>redirect_router</option> may be anywhere in the router configuration.
1618 </para>
1619 </listitem>
1620 <listitem>
1621 <para>
1622 <emphasis>pass</emphasis>: The router recognizes the address, but cannot handle it itself. It
1623 requests that the address be passed to another router. By default the address
1624 is passed to the next router, but this can be changed by setting the
1625 <option>pass_router</option> option. However, (unlike <option>redirect_router</option>) the named router
1626 must be below the current router (to avoid loops).
1627 </para>
1628 </listitem>
1629 <listitem>
1630 <para>
1631 <emphasis>decline</emphasis>: The router declines to accept the address because it does not
1632 recognize it at all. By default, the address is passed to the next router, but
1633 this can be prevented by setting the <option>no_more</option> option. When <option>no_more</option> is
1634 set, all the remaining routers are skipped. In effect, <option>no_more</option> converts
1635 <emphasis>decline</emphasis> into <emphasis>fail</emphasis>.
1636 </para>
1637 </listitem>
1638 <listitem>
1639 <para>
1640 <emphasis>fail</emphasis>: The router determines that the address should fail, and queues it for
1641 the generation of a bounce message. There is no further processing of the
1642 original address unless <option>unseen</option> is set on the router.
1643 </para>
1644 </listitem>
1645 <listitem>
1646 <para>
1647 <emphasis>defer</emphasis>: The router cannot handle the address at the present time. (A
1648 database may be offline, or a DNS lookup may have timed out.) No further
1649 processing of the address happens in this delivery attempt. It is tried again
1650 next time the message is considered for delivery.
1651 </para>
1652 </listitem>
1653 <listitem>
1654 <para>
1655 <emphasis>error</emphasis>: There is some error in the router (for example, a syntax error in
1656 its configuration). The action is as for defer.
1657 </para>
1658 </listitem>
1659 </itemizedlist>
1660 <para>
1661 If an address reaches the end of the routers without having been accepted by
1662 any of them, it is bounced as unrouteable. The default error message in this
1663 situation is <quote>unrouteable address</quote>, but you can set your own message by
1664 making use of the <option>cannot_route_message</option> option. This can be set for any
1665 router; the value from the last router that <quote>saw</quote> the address is used.
1666 </para>
1667 <para>
1668 Sometimes while routing you want to fail a delivery when some conditions are
1669 met but others are not, instead of passing the address on for further routing.
1670 You can do this by having a second router that explicitly fails the delivery
1671 when the relevant conditions are met. The <command>redirect</command> router has a <quote>fail</quote>
1672 facility for this purpose.
1673 </para>
1674 </section>
1675 <section>
1676 <title>Duplicate addresses</title>
1677 <para>
1678 <indexterm role="concept">
1679 <primary>case of local parts</primary>
1680 </indexterm>
1681 <indexterm role="concept">
1682 <primary>address duplicate</primary>
1683 <secondary>discarding</secondary>
1684 </indexterm>
1685 Once routing is complete, Exim scans the addresses that are assigned to local
1686 and remote transports, and discards any duplicates that it finds. During this
1687 check, local parts are treated as case-sensitive.
1688 </para>
1689 </section>
1690 <section id="SECTrouprecon">
1691 <title>Router preconditions</title>
1692 <para>
1693 <indexterm role="concept">
1694 <primary>router preconditions</primary>
1695 <secondary>order of processing</secondary>
1696 </indexterm>
1697 <indexterm role="concept">
1698 <primary>preconditions</primary>
1699 <secondary>order of processing</secondary>
1700 </indexterm>
1701 The preconditions that are tested for each router are listed below, in the
1702 order in which they are tested. The individual configuration options are
1703 described in more detail in chapter <xref linkend="CHAProutergeneric"/>.
1704 </para>
1705 <itemizedlist>
1706 <listitem>
1707 <para>
1708 The <option>local_part_prefix</option> and <option>local_part_suffix</option> options can specify that
1709 the local parts handled by the router may or must have certain prefixes and/or
1710 suffixes. If a mandatory affix (prefix or suffix) is not present, the router is
1711 skipped. These conditions are tested first. When an affix is present, it is
1712 removed from the local part before further processing, including the evaluation
1713 of any other conditions.
1714 </para>
1715 </listitem>
1716 <listitem>
1717 <para>
1718 Routers can be designated for use only when not verifying an address, that is,
1719 only when routing it for delivery (or testing its delivery routing). If the
1720 <option>verify</option> option is set false, the router is skipped when Exim is verifying an
1721 address.
1722 Setting the <option>verify</option> option actually sets two options, <option>verify_sender</option> and
1723 <option>verify_recipient</option>, which independently control the use of the router for
1724 sender and recipient verification. You can set these options directly if
1725 you want a router to be used for only one type of verification.
1726 </para>
1727 </listitem>
1728 <listitem>
1729 <para>
1730 If the <option>address_test</option> option is set false, the router is skipped when Exim is
1731 run with the <option>-bt</option> option to test an address routing. This can be helpful
1732 when the first router sends all new messages to a scanner of some sort; it
1733 makes it possible to use <option>-bt</option> to test subsequent delivery routing without
1734 having to simulate the effect of the scanner.
1735 </para>
1736 </listitem>
1737 <listitem>
1738 <para>
1739 Routers can be designated for use only when verifying an address, as
1740 opposed to routing it for delivery. The <option>verify_only</option> option controls this.
1741 </para>
1742 </listitem>
1743 <listitem>
1744 <para>
1745 Individual routers can be explicitly skipped when running the routers to
1746 check an address given in the SMTP EXPN command (see the <option>expn</option> option).
1747 </para>
1748 </listitem>
1749 <listitem>
1750 <para>
1751 If the <option>domains</option> option is set, the domain of the address must be in the set
1752 of domains that it defines.
1753 </para>
1754 </listitem>
1755 <listitem>
1756 <para>
1757 <indexterm role="concept">
1758 <primary><varname>$local_part_prefix</varname></primary>
1759 </indexterm>
1760 <indexterm role="concept">
1761 <primary><varname>$local_part</varname></primary>
1762 </indexterm>
1763 <indexterm role="concept">
1764 <primary><varname>$local_part_suffix</varname></primary>
1765 </indexterm>
1766 If the <option>local_parts</option> option is set, the local part of the address must be in
1767 the set of local parts that it defines. If <option>local_part_prefix</option> or
1768 <option>local_part_suffix</option> is in use, the prefix or suffix is removed from the local
1769 part before this check. If you want to do precondition tests on local parts
1770 that include affixes, you can do so by using a <option>condition</option> option (see below)
1771 that uses the variables <varname>$local_part</varname>, <varname>$local_part_prefix</varname>, and
1772 <varname>$local_part_suffix</varname> as necessary.
1773 </para>
1774 </listitem>
1775 <listitem>
1776 <para>
1777 <indexterm role="concept">
1778 <primary><varname>$local_user_uid</varname></primary>
1779 </indexterm>
1780 <indexterm role="concept">
1781 <primary><varname>$local_user_gid</varname></primary>
1782 </indexterm>
1783 <indexterm role="concept">
1784 <primary><varname>$home</varname></primary>
1785 </indexterm>
1786 If the <option>check_local_user</option> option is set, the local part must be the name of
1787 an account on the local host. If this check succeeds, the uid and gid of the
1788 local user are placed in <varname>$local_user_uid</varname> and <varname>$local_user_gid</varname> and the
1789 user&#x2019;s home directory is placed in <varname>$home</varname>; these values can be used in the
1790 remaining preconditions.
1791 </para>
1792 </listitem>
1793 <listitem>
1794 <para>
1795 If the <option>router_home_directory</option> option is set, it is expanded at this point,
1796 because it overrides the value of <varname>$home</varname>. If this expansion were left till
1797 later, the value of <varname>$home</varname> as set by <option>check_local_user</option> would be used in
1798 subsequent tests. Having two different values of <varname>$home</varname> in the same router
1799 could lead to confusion.
1800 </para>
1801 </listitem>
1802 <listitem>
1803 <para>
1804 If the <option>senders</option> option is set, the envelope sender address must be in the
1805 set of addresses that it defines.
1806 </para>
1807 </listitem>
1808 <listitem>
1809 <para>
1810 If the <option>require_files</option> option is set, the existence or non-existence of
1811 specified files is tested.
1812 </para>
1813 </listitem>
1814 <listitem>
1815 <para>
1816 <indexterm role="concept">
1817 <primary>customizing</primary>
1818 <secondary>precondition</secondary>
1819 </indexterm>
1820 If the <option>condition</option> option is set, it is evaluated and tested. This option
1821 uses an expanded string to allow you to set up your own custom preconditions.
1822 Expanded strings are described in chapter <xref linkend="CHAPexpand"/>.
1823 </para>
1824 </listitem>
1825 </itemizedlist>
1826 <para>
1827 Note that <option>require_files</option> comes near the end of the list, so you cannot use
1828 it to check for the existence of a file in which to lookup up a domain, local
1829 part, or sender. However, as these options are all expanded, you can use the
1830 <option>exists</option> expansion condition to make such tests within each condition. The
1831 <option>require_files</option> option is intended for checking files that the router may be
1832 going to use internally, or which are needed by a specific transport (for
1833 example, <filename>.procmailrc</filename>).
1834 </para>
1835 </section>
1836 <section>
1837 <title>Delivery in detail</title>
1838 <para>
1839 <indexterm role="concept">
1840 <primary>delivery</primary>
1841 <secondary>in detail</secondary>
1842 </indexterm>
1843 When a message is to be delivered, the sequence of events is as follows:
1844 </para>
1845 <itemizedlist>
1846 <listitem>
1847 <para>
1848 If a system-wide filter file is specified, the message is passed to it. The
1849 filter may add recipients to the message, replace the recipients, discard the
1850 message, cause a new message to be generated, or cause the message delivery to
1851 fail. The format of the system filter file is the same as for Exim user filter
1852 files, described in the separate document entitled <emphasis>Exim&#x2019;s interfaces to mail
1853 filtering</emphasis>.
1854 <indexterm role="concept">
1855 <primary>Sieve filter</primary>
1856 <secondary>not available for system filter</secondary>
1857 </indexterm>
1858 (<emphasis role="bold">Note</emphasis>: Sieve cannot be used for system filter files.)
1859 </para>
1860 <para>
1861 Some additional features are available in system filters &ndash; see chapter
1862 <xref linkend="CHAPsystemfilter"/> for details. Note that a message is passed to the system
1863 filter only once per delivery attempt, however many recipients it has. However,
1864 if there are several delivery attempts because one or more addresses could not
1865 be immediately delivered, the system filter is run each time. The filter
1866 condition <option>first_delivery</option> can be used to detect the first run of the system
1867 filter.
1868 </para>
1869 </listitem>
1870 <listitem>
1871 <para>
1872 Each recipient address is offered to each configured router in turn, subject to
1873 its preconditions, until one is able to handle it. If no router can handle the
1874 address, that is, if they all decline, the address is failed. Because routers
1875 can be targeted at particular domains, several locally handled domains can be
1876 processed entirely independently of each other.
1877 </para>
1878 </listitem>
1879 <listitem>
1880 <para>
1881 <indexterm role="concept">
1882 <primary>routing</primary>
1883 <secondary>loops in</secondary>
1884 </indexterm>
1885 <indexterm role="concept">
1886 <primary>loop</primary>
1887 <secondary>while routing</secondary>
1888 </indexterm>
1889 A router that accepts an address may assign it to a local or a remote
1890 transport. However, the transport is not run at this time. Instead, the address
1891 is placed on a list for the particular transport, which will be run later.
1892 Alternatively, the router may generate one or more new addresses (typically
1893 from alias, forward, or filter files). New addresses are fed back into this
1894 process from the top, but in order to avoid loops, a router ignores any address
1895 which has an identically-named ancestor that was processed by itself.
1896 </para>
1897 </listitem>
1898 <listitem>
1899 <para>
1900 When all the routing has been done, addresses that have been successfully
1901 handled are passed to their assigned transports. When local transports are
1902 doing real local deliveries, they handle only one address at a time, but if a
1903 local transport is being used as a pseudo-remote transport (for example, to
1904 collect batched SMTP messages for transmission by some other means) multiple
1905 addresses can be handled. Remote transports can always handle more than one
1906 address at a time, but can be configured not to do so, or to restrict multiple
1907 addresses to the same domain.
1908 </para>
1909 </listitem>
1910 <listitem>
1911 <para>
1912 Each local delivery to a file or a pipe runs in a separate process under a
1913 non-privileged uid, and these deliveries are run one at a time. Remote
1914 deliveries also run in separate processes, normally under a uid that is private
1915 to Exim (<quote>the Exim user</quote>), but in this case, several remote deliveries can be
1916 run in parallel. The maximum number of simultaneous remote deliveries for any
1917 one message is set by the <option>remote_max_parallel</option> option.
1918 The order in which deliveries are done is not defined, except that all local
1919 deliveries happen before any remote deliveries.
1920 </para>
1921 </listitem>
1922 <listitem>
1923 <para>
1924 <indexterm role="concept">
1925 <primary>queue runner</primary>
1926 </indexterm>
1927 When it encounters a local delivery during a queue run, Exim checks its retry
1928 database to see if there has been a previous temporary delivery failure for the
1929 address before running the local transport. If there was a previous failure,
1930 Exim does not attempt a new delivery until the retry time for the address is
1931 reached. However, this happens only for delivery attempts that are part of a
1932 queue run. Local deliveries are always attempted when delivery immediately
1933 follows message reception, even if retry times are set for them. This makes for
1934 better behaviour if one particular message is causing problems (for example,
1935 causing quota overflow, or provoking an error in a filter file).
1936 </para>
1937 </listitem>
1938 <listitem>
1939 <para>
1940 <indexterm role="concept">
1941 <primary>delivery</primary>
1942 <secondary>retry in remote transports</secondary>
1943 </indexterm>
1944 Remote transports do their own retry handling, since an address may be
1945 deliverable to one of a number of hosts, each of which may have a different
1946 retry time. If there have been previous temporary failures and no host has
1947 reached its retry time, no delivery is attempted, whether in a queue run or
1948 not. See chapter <xref linkend="CHAPretry"/> for details of retry strategies.
1949 </para>
1950 </listitem>
1951 <listitem>
1952 <para>
1953 If there were any permanent errors, a bounce message is returned to an
1954 appropriate address (the sender in the common case), with details of the error
1955 for each failing address. Exim can be configured to send copies of bounce
1956 messages to other addresses.
1957 </para>
1958 </listitem>
1959 <listitem>
1960 <para>
1961 <indexterm role="concept">
1962 <primary>delivery</primary>
1963 <secondary>deferral</secondary>
1964 </indexterm>
1965 If one or more addresses suffered a temporary failure, the message is left on
1966 the queue, to be tried again later. Delivery of these addresses is said to be
1967 <emphasis>deferred</emphasis>.
1968 </para>
1969 </listitem>
1970 <listitem>
1971 <para>
1972 When all the recipient addresses have either been delivered or bounced,
1973 handling of the message is complete. The spool files and message log are
1974 deleted, though the message log can optionally be preserved if required.
1975 </para>
1976 </listitem>
1977 </itemizedlist>
1978 </section>
1979 <section>
1980 <title>Retry mechanism</title>
1981 <para>
1982 <indexterm role="concept">
1983 <primary>delivery</primary>
1984 <secondary>retry mechanism</secondary>
1985 </indexterm>
1986 <indexterm role="concept">
1987 <primary>retry</primary>
1988 <secondary>description of mechanism</secondary>
1989 </indexterm>
1990 <indexterm role="concept">
1991 <primary>queue runner</primary>
1992 </indexterm>
1993 Exim&#x2019;s mechanism for retrying messages that fail to get delivered at the first
1994 attempt is the queue runner process. You must either run an Exim daemon that
1995 uses the <option>-q</option> option with a time interval to start queue runners at regular
1996 intervals, or use some other means (such as <emphasis>cron</emphasis>) to start them. If you do
1997 not arrange for queue runners to be run, messages that fail temporarily at the
1998 first attempt will remain on your queue for ever. A queue runner process works
1999 its way through the queue, one message at a time, trying each delivery that has
2000 passed its retry time.
2001 You can run several queue runners at once.
2002 </para>
2003 <para>
2004 Exim uses a set of configured rules to determine when next to retry the failing
2005 address (see chapter <xref linkend="CHAPretry"/>). These rules also specify when Exim
2006 should give up trying to deliver to the address, at which point it generates a
2007 bounce message. If no retry rules are set for a particular host, address, and
2008 error combination, no retries are attempted, and temporary errors are treated
2009 as permanent.
2010 </para>
2011 </section>
2012 <section>
2013 <title>Temporary delivery failure</title>
2014 <para>
2015 <indexterm role="concept">
2016 <primary>delivery</primary>
2017 <secondary>temporary failure</secondary>
2018 </indexterm>
2019 There are many reasons why a message may not be immediately deliverable to a
2020 particular address. Failure to connect to a remote machine (because it, or the
2021 connection to it, is down) is one of the most common. Temporary failures may be
2022 detected during routing as well as during the transport stage of delivery.
2023 Local deliveries may be delayed if NFS files are unavailable, or if a mailbox
2024 is on a file system where the user is over quota. Exim can be configured to
2025 impose its own quotas on local mailboxes; where system quotas are set they will
2026 also apply.
2027 </para>
2028 <para>
2029 If a host is unreachable for a period of time, a number of messages may be
2030 waiting for it by the time it recovers, and sending them in a single SMTP
2031 connection is clearly beneficial. Whenever a delivery to a remote host is
2032 deferred,
2033 </para>
2034 <para>
2035 <indexterm role="concept">
2036 <primary>hints database</primary>
2037 </indexterm>
2038 Exim makes a note in its hints database, and whenever a successful
2039 SMTP delivery has happened, it looks to see if any other messages are waiting
2040 for the same host. If any are found, they are sent over the same SMTP
2041 connection, subject to a configuration limit as to the maximum number in any
2042 one connection.
2043 </para>
2044 </section>
2045 <section>
2046 <title>Permanent delivery failure</title>
2047 <para>
2048 <indexterm role="concept">
2049 <primary>delivery</primary>
2050 <secondary>permanent failure</secondary>
2051 </indexterm>
2052 <indexterm role="concept">
2053 <primary>bounce message</primary>
2054 <secondary>when generated</secondary>
2055 </indexterm>
2056 When a message cannot be delivered to some or all of its intended recipients, a
2057 bounce message is generated. Temporary delivery failures turn into permanent
2058 errors when their timeout expires. All the addresses that fail in a given
2059 delivery attempt are listed in a single message. If the original message has
2060 many recipients, it is possible for some addresses to fail in one delivery
2061 attempt and others to fail subsequently, giving rise to more than one bounce
2062 message. The wording of bounce messages can be customized by the administrator.
2063 See chapter <xref linkend="CHAPemsgcust"/> for details.
2064 </para>
2065 <para>
2066 <indexterm role="concept">
2067 <primary><emphasis>X-Failed-Recipients:</emphasis> header line</primary>
2068 </indexterm>
2069 Bounce messages contain an <emphasis>X-Failed-Recipients:</emphasis> header line that lists the
2070 failed addresses, for the benefit of programs that try to analyse such messages
2071 automatically.
2072 </para>
2073 <para>
2074 <indexterm role="concept">
2075 <primary>bounce message</primary>
2076 <secondary>recipient of</secondary>
2077 </indexterm>
2078 A bounce message is normally sent to the sender of the original message, as
2079 obtained from the message&#x2019;s envelope. For incoming SMTP messages, this is the
2080 address given in the MAIL command. However, when an address is expanded via a
2081 forward or alias file, an alternative address can be specified for delivery
2082 failures of the generated addresses. For a mailing list expansion (see section
2083 <xref linkend="SECTmailinglists"/>) it is common to direct bounce messages to the manager
2084 of the list.
2085 </para>
2086 </section>
2087 <section>
2088 <title>Failures to deliver bounce messages</title>
2089 <para>
2090 <indexterm role="concept">
2091 <primary>bounce message</primary>
2092 <secondary>failure to deliver</secondary>
2093 </indexterm>
2094 If a bounce message (either locally generated or received from a remote host)
2095 itself suffers a permanent delivery failure, the message is left on the queue,
2096 but it is frozen, awaiting the attention of an administrator. There are options
2097 that can be used to make Exim discard such failed messages, or to keep them
2098 for only a short time (see <option>timeout_frozen_after</option> and
2099 <option>ignore_bounce_errors_after</option>).
2100 </para>
2101 </section>
2102 </chapter>
2103
2104 <chapter>
2105 <title>Building and installing Exim</title>
2106 <para>
2107 <indexterm role="concept" id="IIDbuex" class="startofrange">
2108 <primary>building Exim</primary>
2109 </indexterm>
2110 </para>
2111 <section>
2112 <title>Unpacking</title>
2113 <para>
2114 Exim is distributed as a gzipped or bzipped tar file which, when upacked,
2115 creates a directory with the name of the current release (for example,
2116 <filename>exim-4.61</filename>) into which the following files are placed:
2117 </para>
2118 <informaltable frame="none">
2119 <tgroup cols="2" colsep="0" rowsep="0">
2120 <colspec colwidth="140pt" align="left"/>
2121 <colspec colwidth="260pt" align="left"/>
2122 <tbody>
2123 <row>
2124 <entry><filename>ACKNOWLEDGMENTS</filename></entry>
2125 <entry>contains some acknowledgments</entry>
2126 </row>
2127 <row>
2128 <entry><filename>CHANGES</filename></entry>
2129 <entry>contains a reference to where changes are documented</entry>
2130 </row>
2131 <row>
2132 <entry><filename>LICENCE</filename></entry>
2133 <entry>the GNU General Public Licence</entry>
2134 </row>
2135 <row>
2136 <entry><filename>Makefile</filename></entry>
2137 <entry>top-level make file</entry>
2138 </row>
2139 <row>
2140 <entry><filename>NOTICE</filename></entry>
2141 <entry>conditions for the use of Exim</entry>
2142 </row>
2143 <row>
2144 <entry><filename>README</filename></entry>
2145 <entry>list of files, directories and simple build instructions</entry>
2146 </row>
2147 </tbody>
2148 </tgroup>
2149 </informaltable>
2150 <para>
2151 Other files whose names begin with <filename>README</filename> may also be present. The
2152 following subdirectories are created:
2153 </para>
2154 <informaltable frame="none">
2155 <tgroup cols="2" colsep="0" rowsep="0">
2156 <colspec colwidth="140pt" align="left"/>
2157 <colspec colwidth="260pt" align="left"/>
2158 <tbody>
2159 <row>
2160 <entry><filename>Local</filename></entry>
2161 <entry>an empty directory for local configuration files</entry>
2162 </row>
2163 <row>
2164 <entry><filename>OS</filename></entry>
2165 <entry>OS-specific files</entry>
2166 </row>
2167 <row>
2168 <entry><filename>doc</filename></entry>
2169 <entry>documentation files</entry>
2170 </row>
2171 <row>
2172 <entry><filename>exim_monitor</filename></entry>
2173 <entry>source files for the Exim monitor</entry>
2174 </row>
2175 <row>
2176 <entry><filename>scripts</filename></entry>
2177 <entry>scripts used in the build process</entry>
2178 </row>
2179 <row>
2180 <entry><filename>src</filename></entry>
2181 <entry>remaining source files</entry>
2182 </row>
2183 <row>
2184 <entry><filename>util</filename></entry>
2185 <entry>independent utilities</entry>
2186 </row>
2187 </tbody>
2188 </tgroup>
2189 </informaltable>
2190 <para>
2191 The main utility programs are contained in the <filename>src</filename> directory, and are built
2192 with the Exim binary. The <filename>util</filename> directory contains a few optional scripts
2193 that may be useful to some sites.
2194 </para>
2195 </section>
2196 <section>
2197 <title>Multiple machine architectures and operating systems</title>
2198 <para>
2199 <indexterm role="concept">
2200 <primary>building Exim</primary>
2201 <secondary>multiple OS/architectures</secondary>
2202 </indexterm>
2203 The building process for Exim is arranged to make it easy to build binaries for
2204 a number of different architectures and operating systems from the same set of
2205 source files. Compilation does not take place in the <filename>src</filename> directory.
2206 Instead, a <emphasis>build directory</emphasis> is created for each architecture and operating
2207 system.
2208 <indexterm role="concept">
2209 <primary>symbolic link</primary>
2210 <secondary>to build directory</secondary>
2211 </indexterm>
2212 Symbolic links to the sources are installed in this directory, which is where
2213 the actual building takes place. In most cases, Exim can discover the machine
2214 architecture and operating system for itself, but the defaults can be
2215 overridden if necessary.
2216 </para>
2217 </section>
2218 <section id="SECTdb">
2219 <title>DBM libraries</title>
2220 <para>
2221 <indexterm role="concept">
2222 <primary>DBM libraries</primary>
2223 <secondary>discussion of</secondary>
2224 </indexterm>
2225 <indexterm role="concept">
2226 <primary>hints database</primary>
2227 <secondary>DBM files used for</secondary>
2228 </indexterm>
2229 Even if you do not use any DBM files in your configuration, Exim still needs a
2230 DBM library in order to operate, because it uses indexed files for its hints
2231 databases. Unfortunately, there are a number of DBM libraries in existence, and
2232 different operating systems often have different ones installed.
2233 </para>
2234 <para>
2235 <indexterm role="concept">
2236 <primary>Solaris</primary>
2237 <secondary>DBM library for</secondary>
2238 </indexterm>
2239 <indexterm role="concept">
2240 <primary>IRIX</primary>
2241 <secondary>DBM library for</secondary>
2242 </indexterm>
2243 <indexterm role="concept">
2244 <primary>BSD</primary>
2245 <secondary>DBM library for</secondary>
2246 </indexterm>
2247 <indexterm role="concept">
2248 <primary>Linux</primary>
2249 <secondary>DBM library for</secondary>
2250 </indexterm>
2251 If you are using Solaris, IRIX, one of the modern BSD systems, or a modern
2252 Linux distribution, the DBM configuration should happen automatically, and you
2253 may be able to ignore this section. Otherwise, you may have to learn more than
2254 you would like about DBM libraries from what follows.
2255 </para>
2256 <para>
2257 <indexterm role="concept">
2258 <primary><emphasis>ndbm</emphasis> DBM library</primary>
2259 </indexterm>
2260 Licensed versions of Unix normally contain a library of DBM functions operating
2261 via the <emphasis>ndbm</emphasis> interface, and this is what Exim expects by default. Free
2262 versions of Unix seem to vary in what they contain as standard. In particular,
2263 some early versions of Linux have no default DBM library, and different
2264 distributors have chosen to bundle different libraries with their packaged
2265 versions. However, the more recent releases seem to have standardised on the
2266 Berkeley DB library.
2267 </para>
2268 <para>
2269 Different DBM libraries have different conventions for naming the files they
2270 use. When a program opens a file called <filename>dbmfile</filename>, there are several
2271 possibilities:
2272 </para>
2273 <orderedlist numeration="arabic">
2274 <listitem>
2275 <para>
2276 A traditional <emphasis>ndbm</emphasis> implementation, such as that supplied as part of
2277 Solaris, operates on two files called <filename>dbmfile.dir</filename> and <filename>dbmfile.pag</filename>.
2278 </para>
2279 </listitem>
2280 <listitem>
2281 <para>
2282 <indexterm role="concept">
2283 <primary><emphasis>gdbm</emphasis> DBM library</primary>
2284 </indexterm>
2285 The GNU library, <emphasis>gdbm</emphasis>, operates on a single file. If used via its <emphasis>ndbm</emphasis>
2286 compatibility interface it makes two different hard links to it with names
2287 <filename>dbmfile.dir</filename> and <filename>dbmfile.pag</filename>, but if used via its native interface, the
2288 file name is used unmodified.
2289 </para>
2290 </listitem>
2291 <listitem>
2292 <para>
2293 <indexterm role="concept">
2294 <primary>Berkeley DB library</primary>
2295 </indexterm>
2296 The Berkeley DB package, if called via its <emphasis>ndbm</emphasis> compatibility interface,
2297 operates on a single file called <filename>dbmfile.db</filename>, but otherwise looks to the
2298 programmer exactly the same as the traditional <emphasis>ndbm</emphasis> implementation.
2299 </para>
2300 </listitem>
2301 <listitem>
2302 <para>
2303 If the Berkeley package is used in its native mode, it operates on a single
2304 file called <filename>dbmfile</filename>; the programmer&#x2019;s interface is somewhat different to
2305 the traditional <emphasis>ndbm</emphasis> interface.
2306 </para>
2307 </listitem>
2308 <listitem>
2309 <para>
2310 To complicate things further, there are several very different versions of the
2311 Berkeley DB package. Version 1.85 was stable for a very long time, releases
2312 2.<emphasis>x</emphasis> and 3.<emphasis>x</emphasis> were current for a while, but the latest versions are now
2313 numbered 4.<emphasis>x</emphasis>. Maintenance of some of the earlier releases has ceased. All
2314 versions of Berkeley DB can be obtained from
2315 <emphasis role="bold"><ulink url="http://www.sleepycat.com/">http://www.sleepycat.com/</ulink></emphasis>.
2316 </para>
2317 </listitem>
2318 <listitem>
2319 <para>
2320 <indexterm role="concept">
2321 <primary><emphasis>tdb</emphasis> DBM library</primary>
2322 </indexterm>
2323 Yet another DBM library, called <emphasis>tdb</emphasis>, is available from
2324 <emphasis role="bold"><ulink url="http://download.sourceforge.net/tdb">http://download.sourceforge.net/tdb</ulink></emphasis>. It has its own interface, and also
2325 operates on a single file.
2326 </para>
2327 </listitem>
2328 </orderedlist>
2329 <para>
2330 <indexterm role="concept">
2331 <primary>USE_DB</primary>
2332 </indexterm>
2333 <indexterm role="concept">
2334 <primary>DBM libraries</primary>
2335 <secondary>configuration for building</secondary>
2336 </indexterm>
2337 Exim and its utilities can be compiled to use any of these interfaces. In order
2338 to use any version of the Berkeley DB package in native mode, you must set
2339 USE_DB in an appropriate configuration file (typically
2340 <filename>Local/Makefile</filename>). For example:
2341 </para>
2342 <literallayout class="monospaced">
2343 USE_DB=yes
2344 </literallayout>
2345 <para>
2346 Similarly, for gdbm you set USE_GDBM, and for tdb you set USE_TDB. An
2347 error is diagnosed if you set more than one of these.
2348 </para>
2349 <para>
2350 At the lowest level, the build-time configuration sets none of these options,
2351 thereby assuming an interface of type (1). However, some operating system
2352 configuration files (for example, those for the BSD operating systems and
2353 Linux) assume type (4) by setting USE_DB as their default, and the
2354 configuration files for Cygwin set USE_GDBM. Anything you set in
2355 <filename>Local/Makefile</filename>, however, overrides these system defaults.
2356 </para>
2357 <para>
2358 As well as setting USE_DB, USE_GDBM, or USE_TDB, it may also be
2359 necessary to set DBMLIB, to cause inclusion of the appropriate library, as
2360 in one of these lines:
2361 </para>
2362 <literallayout class="monospaced">
2363 DBMLIB = -ldb
2364 DBMLIB = -ltdb
2365 </literallayout>
2366 <para>
2367 Settings like that will work if the DBM library is installed in the standard
2368 place. Sometimes it is not, and the library&#x2019;s header file may also not be in
2369 the default path. You may need to set INCLUDE to specify where the header
2370 file is, and to specify the path to the library more fully in DBMLIB, as in
2371 this example:
2372 </para>
2373 <literallayout class="monospaced">
2374 INCLUDE=-I/usr/local/include/db-4.1
2375 DBMLIB=/usr/local/lib/db-4.1/libdb.a
2376 </literallayout>
2377 <para>
2378 There is further detailed discussion about the various DBM libraries in the
2379 file <filename>doc/dbm.discuss.txt</filename> in the Exim distribution.
2380 </para>
2381 </section>
2382 <section>
2383 <title>Pre-building configuration</title>
2384 <para>
2385 <indexterm role="concept">
2386 <primary>building Exim</primary>
2387 <secondary>pre-building configuration</secondary>
2388 </indexterm>
2389 <indexterm role="concept">
2390 <primary>configuration for building Exim</primary>
2391 </indexterm>
2392 <indexterm role="concept">
2393 <primary><filename>Local/Makefile</filename></primary>
2394 </indexterm>
2395 <indexterm role="concept">
2396 <primary><filename>src/EDITME</filename></primary>
2397 </indexterm>
2398 Before building Exim, a local configuration file that specifies options
2399 independent of any operating system has to be created with the name
2400 <filename>Local/Makefile</filename>. A template for this file is supplied as the file
2401 <filename>src/EDITME</filename>, and it contains full descriptions of all the option settings
2402 therein. These descriptions are therefore not repeated here. If you are
2403 building Exim for the first time, the simplest thing to do is to copy
2404 <filename>src/EDITME</filename> to <filename>Local/Makefile</filename>, then read it and edit it appropriately.
2405 </para>
2406 <para>
2407 There are three settings that you must supply, because Exim will not build
2408 without them. They are the location of the run time configuration file
2409 (CONFIGURE_FILE), the directory in which Exim binaries will be installed
2410 (BIN_DIRECTORY), and the identity of the Exim user (EXIM_USER and
2411 maybe EXIM_GROUP as well). The value of CONFIGURE_FILE can in fact be
2412 a colon-separated list of file names; Exim uses the first of them that exists.
2413 </para>
2414 <para>
2415 There are a few other parameters that can be specified either at build time or
2416 at run time, to enable the same binary to be used on a number of different
2417 machines. However, if the locations of Exim&#x2019;s spool directory and log file
2418 directory (if not within the spool directory) are fixed, it is recommended that
2419 you specify them in <filename>Local/Makefile</filename> instead of at run time, so that errors
2420 detected early in Exim&#x2019;s execution (such as a malformed configuration file) can
2421 be logged.
2422 </para>
2423 <para>
2424 <indexterm role="concept">
2425 <primary>content scanning</primary>
2426 <secondary>specifying at build time</secondary>
2427 </indexterm>
2428 Exim&#x2019;s interfaces for calling virus and spam scanning software directly from
2429 access control lists are not compiled by default. If you want to include these
2430 facilities, you need to set
2431 </para>
2432 <literallayout class="monospaced">
2433 WITH_CONTENT_SCAN=yes
2434 </literallayout>
2435 <para>
2436 in your <filename>Local/Makefile</filename>. For details of the facilities themselves, see
2437 chapter <xref linkend="CHAPexiscan"/>.
2438 </para>
2439 <para>
2440 <indexterm role="concept">
2441 <primary><filename>Local/eximon.conf</filename></primary>
2442 </indexterm>
2443 <indexterm role="concept">
2444 <primary>_exim_monitor/EDITME_</primary>
2445 </indexterm>
2446 If you are going to build the Exim monitor, a similar configuration process is
2447 required. The file <filename>exim_monitor/EDITME</filename> must be edited appropriately for
2448 your installation and saved under the name <filename>Local/eximon.conf</filename>. If you are
2449 happy with the default settings described in <filename>exim_monitor/EDITME</filename>,
2450 <filename>Local/eximon.conf</filename> can be empty, but it must exist.
2451 </para>
2452 <para>
2453 This is all the configuration that is needed in straightforward cases for known
2454 operating systems. However, the building process is set up so that it is easy
2455 to override options that are set by default or by operating-system-specific
2456 configuration files, for example to change the name of the C compiler, which
2457 defaults to <option>gcc</option>. See section <xref linkend="SECToverride"/> below for details of how to
2458 do this.
2459 </para>
2460 </section>
2461 <section>
2462 <title>Support for iconv()</title>
2463 <para>
2464 <indexterm role="concept">
2465 <primary><function>iconv()</function> support</primary>
2466 </indexterm>
2467 <indexterm role="concept">
2468 <primary>RFC 2047</primary>
2469 </indexterm>
2470 The contents of header lines in messages may be encoded according to the rules
2471 described RFC 2047. This makes it possible to transmit characters that are not
2472 in the ASCII character set, and to label them as being in a particular
2473 character set. When Exim is inspecting header lines by means of the <option>$h_</option>
2474 mechanism, it decodes them, and translates them into a specified character set
2475 (default ISO-8859-1). The translation is possible only if the operating system
2476 supports the <function>iconv()</function> function.
2477 </para>
2478 <para>
2479 However, some of the operating systems that supply <function>iconv()</function> do not support
2480 very many conversions. The GNU <option>libiconv</option> library (available from
2481 <emphasis role="bold"><ulink url="http://www.gnu.org/software/libiconv/">http://www.gnu.org/software/libiconv/</ulink></emphasis>) can be installed on such
2482 systems to remedy this deficiency, as well as on systems that do not supply
2483 <function>iconv()</function> at all. After installing <option>libiconv</option>, you should add
2484 </para>
2485 <literallayout class="monospaced">
2486 HAVE_ICONV=yes
2487 </literallayout>
2488 <para>
2489 to your <filename>Local/Makefile</filename> and rebuild Exim.
2490 </para>
2491 </section>
2492 <section id="SECTinctlsssl">
2493 <title>Including TLS/SSL encryption support</title>
2494 <para>
2495 <indexterm role="concept">
2496 <primary>TLS</primary>
2497 <secondary>including support for TLS</secondary>
2498 </indexterm>
2499 <indexterm role="concept">
2500 <primary>encryption</primary>
2501 <secondary>including support for</secondary>
2502 </indexterm>
2503 <indexterm role="concept">
2504 <primary>SUPPORT_TLS</primary>
2505 </indexterm>
2506 <indexterm role="concept">
2507 <primary>OpenSSL</primary>
2508 <secondary>building Exim with</secondary>
2509 </indexterm>
2510 <indexterm role="concept">
2511 <primary>GnuTLS</primary>
2512 <secondary>building Exim with</secondary>
2513 </indexterm>
2514 Exim can be built to support encrypted SMTP connections, using the STARTTLS
2515 command as per RFC 2487. It can also support legacy clients that expect to
2516 start a TLS session immediately on connection to a non-standard port (see the
2517 <option>tls_on_connect_ports</option> runtime option and the <option>-tls-on-connect</option> command
2518 line option).
2519 </para>
2520 <para>
2521 If you want to build Exim with TLS support, you must first install either the
2522 OpenSSL or GnuTLS library. There is no cryptographic code in Exim itself for
2523 implementing SSL.
2524 </para>
2525 <para>
2526 If OpenSSL is installed, you should set
2527 </para>
2528 <literallayout class="monospaced">
2529 SUPPORT_TLS=yes
2530 TLS_LIBS=-lssl -lcrypto
2531 </literallayout>
2532 <para>
2533 in <filename>Local/Makefile</filename>. You may also need to specify the locations of the
2534 OpenSSL library and include files. For example:
2535 </para>
2536 <literallayout class="monospaced">
2537 SUPPORT_TLS=yes
2538 TLS_LIBS=-L/usr/local/openssl/lib -lssl -lcrypto
2539 TLS_INCLUDE=-I/usr/local/openssl/include/
2540 </literallayout>
2541 <para>
2542 <indexterm role="concept">
2543 <primary>USE_GNUTLS</primary>
2544 </indexterm>
2545 If GnuTLS is installed, you should set
2546 </para>
2547 <literallayout class="monospaced">
2548 SUPPORT_TLS=yes
2549 USE_GNUTLS=yes
2550 TLS_LIBS=-lgnutls -ltasn1 -lgcrypt
2551 </literallayout>
2552 <para>
2553 in <filename>Local/Makefile</filename>, and again you may need to specify the locations of the
2554 library and include files. For example:
2555 </para>
2556 <literallayout class="monospaced">
2557 SUPPORT_TLS=yes
2558 USE_GNUTLS=yes
2559 TLS_LIBS=-L/usr/gnu/lib -lgnutls -ltasn1 -lgcrypt
2560 TLS_INCLUDE=-I/usr/gnu/include
2561 </literallayout>
2562 <para>
2563 You do not need to set TLS_INCLUDE if the relevant directory is already
2564 specified in INCLUDE. Details of how to configure Exim to make use of TLS are
2565 given in chapter <xref linkend="CHAPTLS"/>.
2566 </para>
2567 </section>
2568 <section>
2569 <title>Use of tcpwrappers</title>
2570 <para>
2571 <indexterm role="concept">
2572 <primary>tcpwrappers</primary>
2573 <secondary>building Exim to support</secondary>
2574 </indexterm>
2575 <indexterm role="concept">
2576 <primary>USE_TCP_WRAPPERS</primary>
2577 </indexterm>
2578 Exim can be linked with the <emphasis>tcpwrappers</emphasis> library in order to check incoming
2579 SMTP calls using the <emphasis>tcpwrappers</emphasis> control files. This may be a convenient
2580 alternative to Exim&#x2019;s own checking facilities for installations that are
2581 already making use of <emphasis>tcpwrappers</emphasis> for other purposes. To do this, you
2582 should set USE_TCP_WRAPPERS in <filename>Local/Makefile</filename>, arrange for the file
2583 <filename>tcpd.h</filename> to be available at compile time, and also ensure that the library
2584 <filename>libwrap.a</filename> is available at link time, typically by including <option>-lwrap</option> in
2585 EXTRALIBS_EXIM. For example, if <emphasis>tcpwrappers</emphasis> is installed in <filename>/usr/local</filename>,
2586 you might have
2587 </para>
2588 <literallayout class="monospaced">
2589 USE_TCP_WRAPPERS=yes
2590 CFLAGS=-O -I/usr/local/include
2591 EXTRALIBS_EXIM=-L/usr/local/lib -lwrap
2592 </literallayout>
2593 <para>
2594 in <filename>Local/Makefile</filename>. The name to use in the <emphasis>tcpwrappers</emphasis> control files is
2595 <quote>exim</quote>. For example, the line
2596 </para>
2597 <literallayout class="monospaced">
2598 exim : LOCAL  192.168.1.  .friendly.domain.example
2599 </literallayout>
2600 <para>
2601 in your <filename>/etc/hosts.allow</filename> file allows connections from the local host, from
2602 the subnet 192.168.1.0/24, and from all hosts in <emphasis>friendly.domain.example</emphasis>.
2603 All other connections are denied. Consult the <emphasis>tcpwrappers</emphasis> documentation for
2604 further details.
2605 </para>
2606 </section>
2607 <section>
2608 <title>Including support for IPv6</title>
2609 <para>
2610 <indexterm role="concept">
2611 <primary>IPv6</primary>
2612 <secondary>including support for</secondary>
2613 </indexterm>
2614 Exim contains code for use on systems that have IPv6 support. Setting
2615 <literal>HAVE_IPV6=YES</literal> in <filename>Local/Makefile</filename> causes the IPv6 code to be included;
2616 it may also be necessary to set IPV6_INCLUDE and IPV6_LIBS on systems
2617 where the IPv6 support is not fully integrated into the normal include and
2618 library files.
2619 </para>
2620 <para>
2621 Two different types of DNS record for handling IPv6 addresses have been
2622 defined. AAAA records (analagous to A records for IPv4) are in use, and are
2623 currently seen as the mainstream. Another record type called A6 was proposed
2624 as better than AAAA because it had more flexibility. However, it was felt to be
2625 over-complex, and its status was reduced to <quote>experimental</quote>. It is not known
2626 if anyone is actually using A6 records. Exim has support for A6 records, but
2627 this is included only if you set <literal>SUPPORT_A6=YES</literal> in <filename>Local/Makefile</filename>. The
2628 support has not been tested for some time.
2629 </para>
2630 </section>
2631 <section>
2632 <title>The building process</title>
2633 <para>
2634 <indexterm role="concept">
2635 <primary>build directory</primary>
2636 </indexterm>
2637 Once <filename>Local/Makefile</filename> (and <filename>Local/eximon.conf</filename>, if required) have been
2638 created, run <emphasis>make</emphasis> at the top level. It determines the architecture and
2639 operating system types, and creates a build directory if one does not exist.
2640 For example, on a Sun system running Solaris 8, the directory
2641 <filename>build-SunOS5-5.8-sparc</filename> is created.
2642 <indexterm role="concept">
2643 <primary>symbolic link</primary>
2644 <secondary>to source files</secondary>
2645 </indexterm>
2646 Symbolic links to relevant source files are installed in the build directory.
2647 </para>
2648 <para>
2649 <emphasis role="bold">Warning</emphasis>: The <option>-j</option> (parallel) flag must not be used with <emphasis>make</emphasis>; the
2650 building process fails if it is set.
2651 </para>
2652 <para>
2653 If this is the first time <emphasis>make</emphasis> has been run, it calls a script that builds
2654 a make file inside the build directory, using the configuration files from the
2655 <filename>Local</filename> directory. The new make file is then passed to another instance of
2656 <emphasis>make</emphasis>. This does the real work, building a number of utility scripts, and
2657 then compiling and linking the binaries for the Exim monitor (if configured), a
2658 number of utility programs, and finally Exim itself. The command <literal>make
2659 makefile</literal> can be used to force a rebuild of the make file in the build
2660 directory, should this ever be necessary.
2661 </para>
2662 <para>
2663 If you have problems building Exim, check for any comments there may be in the
2664 <filename>README</filename> file concerning your operating system, and also take a look at the
2665 FAQ, where some common problems are covered.
2666 </para>
2667 </section>
2668 <section>
2669 <title>Output from <quote>make</quote></title>
2670 <para>
2671 The output produced by the <emphasis>make</emphasis> process for compile lines is often very
2672 unreadable, because these lines can be very long. For this reason, the normal
2673 output is suppressed by default, and instead output similar to that which
2674 appears when compiling the 2.6 Linux kernel is generated: just a short line for
2675 each module that is being compiled or linked. However, it is still possible to
2676 get the full output, by calling <emphasis>make</emphasis> like this:
2677 </para>
2678 <literallayout class="monospaced">
2679 FULLECHO='' make -e
2680 </literallayout>
2681 <para>
2682 The value of FULLECHO defaults to <quote>@</quote>, the flag character that suppresses
2683 command reflection in <emphasis>make</emphasis>. When you ask for the full output, it is
2684 given in addition to the the short output.
2685 </para>
2686 </section>
2687 <section id="SECToverride">
2688 <title>Overriding build-time options for Exim</title>
2689 <para>
2690 <indexterm role="concept">
2691 <primary>build-time options</primary>
2692 <secondary>overriding</secondary>
2693 </indexterm>
2694 The main make file that is created at the beginning of the building process
2695 consists of the concatenation of a number of files which set configuration
2696 values, followed by a fixed set of <emphasis>make</emphasis> instructions. If a value is set
2697 more than once, the last setting overrides any previous ones. This provides a
2698 convenient way of overriding defaults. The files that are concatenated are, in
2699 order:
2700 </para>
2701 <literallayout>
2702 <filename>OS/Makefile-Default</filename>
2703 <filename>OS/Makefile-</filename>&lt;<emphasis>ostype</emphasis>&gt;
2704 <filename>Local/Makefile</filename>
2705 <filename>Local/Makefile-</filename>&lt;<emphasis>ostype</emphasis>&gt;
2706 <filename>Local/Makefile-</filename>&lt;<emphasis>archtype</emphasis>&gt;
2707 <filename>Local/Makefile-</filename>&lt;<emphasis>ostype</emphasis>&gt;-&lt;<emphasis>archtype</emphasis>&gt;
2708 <filename>OS/Makefile-Base</filename>
2709 </literallayout>
2710 <para>
2711 <indexterm role="concept">
2712 <primary><filename>Local/Makefile</filename></primary>
2713 </indexterm>
2714 <indexterm role="concept">
2715 <primary>building Exim</primary>
2716 <secondary>operating system type</secondary>
2717 </indexterm>
2718 <indexterm role="concept">
2719 <primary>building Exim</primary>
2720 <secondary>architecture type</secondary>
2721 </indexterm>
2722 where &lt;<emphasis>ostype</emphasis>&gt; is the operating system type and &lt;<emphasis>archtype</emphasis>&gt; is the
2723 architecture type. <filename>Local/Makefile</filename> is required to exist, and the building
2724 process fails if it is absent. The other three <filename>Local</filename> files are optional,
2725 and are often not needed.
2726 </para>
2727 <para>
2728 The values used for &lt;<emphasis>ostype</emphasis>&gt; and &lt;<emphasis>archtype</emphasis>&gt; are obtained from scripts
2729 called <filename>scripts/os-type</filename> and <filename>scripts/arch-type</filename> respectively. If either of
2730 the environment variables EXIM_OSTYPE or EXIM_ARCHTYPE is set, their
2731 values are used, thereby providing a means of forcing particular settings.
2732 Otherwise, the scripts try to get values from the <option>uname</option> command. If this
2733 fails, the shell variables OSTYPE and ARCHTYPE are inspected. A number
2734 of <emphasis>ad hoc</emphasis> transformations are then applied, to produce the standard names
2735 that Exim expects. You can run these scripts directly from the shell in order
2736 to find out what values are being used on your system.
2737 </para>
2738 <para>
2739 <filename>OS/Makefile-Default</filename> contains comments about the variables that are set
2740 therein. Some (but not all) are mentioned below. If there is something that
2741 needs changing, review the contents of this file and the contents of the make
2742 file for your operating system (<filename>OS/Makefile-&lt;ostype&gt;</filename>) to see what the
2743 default values are.
2744 </para>
2745 <para>
2746 <indexterm role="concept">
2747 <primary>building Exim</primary>
2748 <secondary>overriding default settings</secondary>
2749 </indexterm>
2750 If you need to change any of the values that are set in <filename>OS/Makefile-Default</filename>
2751 or in <filename>OS/Makefile-&lt;ostype&gt;</filename>, or to add any new definitions, you do not
2752 need to change the original files. Instead, you should make the changes by
2753 putting the new values in an appropriate <filename>Local</filename> file. For example,
2754 <indexterm role="concept">
2755 <primary>Tru64-Unix build-time settings</primary>
2756 </indexterm>
2757 when building Exim in many releases of the Tru64-Unix (formerly Digital UNIX,
2758 formerly DEC-OSF1) operating system, it is necessary to specify that the C
2759 compiler is called <emphasis>cc</emphasis> rather than <emphasis>gcc</emphasis>. Also, the compiler must be
2760 called with the option <option>-std1</option>, to make it recognize some of the features of
2761 Standard C that Exim uses. (Most other compilers recognize Standard C by
2762 default.) To do this, you should create a file called <filename>Local/Makefile-OSF1</filename>
2763 containing the lines
2764 </para>
2765 <literallayout class="monospaced">
2766 CC=cc
2767 CFLAGS=-std1
2768 </literallayout>
2769 <para>
2770 If you are compiling for just one operating system, it may be easier to put
2771 these lines directly into <filename>Local/Makefile</filename>.
2772 </para>
2773 <para>
2774 Keeping all your local configuration settings separate from the distributed
2775 files makes it easy to transfer them to new versions of Exim simply by copying
2776 the contents of the <filename>Local</filename> directory.
2777 </para>
2778 <para>
2779 <indexterm role="concept">
2780 <primary>NIS lookup type</primary>
2781 <secondary>including support for</secondary>
2782 </indexterm>
2783 <indexterm role="concept">
2784 <primary>NIS+ lookup type</primary>
2785 <secondary>including support for</secondary>
2786 </indexterm>
2787 <indexterm role="concept">
2788 <primary>LDAP</primary>
2789 <secondary>including support for</secondary>
2790 </indexterm>
2791 <indexterm role="concept">
2792 <primary>lookup</primary>
2793 <secondary>inclusion in binary</secondary>
2794 </indexterm>
2795 Exim contains support for doing LDAP, NIS, NIS+, and other kinds of file
2796 lookup, but not all systems have these components installed, so the default is
2797 not to include the relevant code in the binary. All the different kinds of file
2798 and database lookup that Exim supports are implemented as separate code modules
2799 which are included only if the relevant compile-time options are set. In the
2800 case of LDAP, NIS, and NIS+, the settings for <filename>Local/Makefile</filename> are:
2801 </para>
2802 <literallayout class="monospaced">
2803 LOOKUP_LDAP=yes
2804 LOOKUP_NIS=yes
2805 LOOKUP_NISPLUS=yes
2806 </literallayout>
2807 <para>
2808 and similar settings apply to the other lookup types. They are all listed in
2809 <filename>src/EDITME</filename>. In many cases the relevant include files and interface
2810 libraries need to be installed before compiling Exim.
2811 <indexterm role="concept">
2812 <primary>cdb</primary>
2813 <secondary>including support for</secondary>
2814 </indexterm>
2815 However, there are some optional lookup types (such as cdb) for which
2816 the code is entirely contained within Exim, and no external include
2817 files or libraries are required. When a lookup type is not included in the
2818 binary, attempts to configure Exim to use it cause run time configuration
2819 errors.
2820 </para>
2821 <para>
2822 <indexterm role="concept">
2823 <primary>Perl</primary>
2824 <secondary>including support for</secondary>
2825 </indexterm>
2826 Exim can be linked with an embedded Perl interpreter, allowing Perl
2827 subroutines to be called during string expansion. To enable this facility,
2828 </para>
2829 <literallayout class="monospaced">
2830 EXIM_PERL=perl.o
2831 </literallayout>
2832 <para>
2833 must be defined in <filename>Local/Makefile</filename>. Details of this facility are given in
2834 chapter <xref linkend="CHAPperl"/>.
2835 </para>
2836 <para>
2837 <indexterm role="concept">
2838 <primary>X11 libraries</primary>
2839 <secondary>location of</secondary>
2840 </indexterm>
2841 The location of the X11 libraries is something that varies a lot between
2842 operating systems, and there may be different versions of X11 to cope
2843 with. Exim itself makes no use of X11, but if you are compiling the Exim
2844 monitor, the X11 libraries must be available.
2845 The following three variables are set in <filename>OS/Makefile-Default</filename>:
2846 </para>
2847 <literallayout class="monospaced">
2848 X11=/usr/X11R6
2849 XINCLUDE=-I$(X11)/include
2850 XLFLAGS=-L$(X11)/lib
2851 </literallayout>
2852 <para>
2853 These are overridden in some of the operating-system configuration files. For
2854 example, in <filename>OS/Makefile-SunOS5</filename> there is
2855 </para>
2856 <literallayout class="monospaced">
2857 X11=/usr/openwin
2858 XINCLUDE=-I$(X11)/include
2859 XLFLAGS=-L$(X11)/lib -R$(X11)/lib
2860 </literallayout>
2861 <para>
2862 If you need to override the default setting for your operating system, place a
2863 definition of all three of these variables into your
2864 <filename>Local/Makefile-&lt;ostype&gt;</filename> file.
2865 </para>
2866 <para>
2867 <indexterm role="concept">
2868 <primary>EXTRALIBS</primary>
2869 </indexterm>
2870 If you need to add any extra libraries to the link steps, these can be put in a
2871 variable called EXTRALIBS, which appears in all the link commands, but by
2872 default is not defined. In contrast, EXTRALIBS_EXIM is used only on the
2873 command for linking the main Exim binary, and not for any associated utilities.
2874 </para>
2875 <para>
2876 <indexterm role="concept">
2877 <primary>DBM libraries</primary>
2878 <secondary>configuration for building</secondary>
2879 </indexterm>
2880 There is also DBMLIB, which appears in the link commands for binaries that
2881 use DBM functions (see also section <xref linkend="SECTdb"/>). Finally, there is
2882 EXTRALIBS_EXIMON, which appears only in the link step for the Exim monitor
2883 binary, and which can be used, for example, to include additional X11
2884 libraries.
2885 </para>
2886 <para>
2887 <indexterm role="concept">
2888 <primary>configuration file</primary>
2889 <secondary>editing</secondary>
2890 </indexterm>
2891 The make file copes with rebuilding Exim correctly if any of the configuration
2892 files are edited. However, if an optional configuration file is deleted, it is
2893 necessary to touch the associated non-optional file (that is,
2894 <filename>Local/Makefile</filename> or <filename>Local/eximon.conf</filename>) before rebuilding.
2895 </para>
2896 </section>
2897 <section>
2898 <title>OS-specific header files</title>
2899 <para>
2900 <indexterm role="concept">
2901 <primary><filename>os.h</filename></primary>
2902 </indexterm>
2903 <indexterm role="concept">
2904 <primary>building Exim</primary>
2905 <secondary>OS-specific C header files</secondary>
2906 </indexterm>
2907 The <filename>OS</filename> directory contains a number of files with names of the form
2908 <filename>os.h-&lt;ostype&gt;</filename>. These are system-specific C header files that should not
2909 normally need to be changed. There is a list of macro settings that are
2910 recognized in the file <filename>OS/os.configuring</filename>, which should be consulted if you
2911 are porting Exim to a new operating system.
2912 </para>
2913 </section>
2914 <section>
2915 <title>Overriding build-time options for the monitor</title>
2916 <para>
2917 <indexterm role="concept">
2918 <primary>building Eximon</primary>
2919 <secondary>overriding default options</secondary>
2920 </indexterm>
2921 A similar process is used for overriding things when building the Exim monitor,
2922 where the files that are involved are
2923 </para>
2924 <literallayout>
2925 <filename>OS/eximon.conf-Default</filename>
2926 <filename>OS/eximon.conf-</filename>&lt;<emphasis>ostype</emphasis>&gt;
2927 <filename>Local/eximon.conf</filename>
2928 <filename>Local/eximon.conf-</filename>&lt;<emphasis>ostype</emphasis>&gt;
2929 <filename>Local/eximon.conf-</filename>&lt;<emphasis>archtype</emphasis>&gt;
2930 <filename>Local/eximon.conf-</filename>&lt;<emphasis>ostype</emphasis>&gt;-&lt;<emphasis>archtype</emphasis>&gt;
2931 </literallayout>
2932 <para>
2933 <indexterm role="concept">
2934 <primary><filename>Local/eximon.conf</filename></primary>
2935 </indexterm>
2936 As with Exim itself, the final three files need not exist, and in this case the
2937 <filename>OS/eximon.conf-&lt;ostype&gt;</filename> file is also optional. The default values in
2938 <filename>OS/eximon.conf-Default</filename> can be overridden dynamically by setting environment
2939 variables of the same name, preceded by EXIMON_. For example, setting
2940 EXIMON_LOG_DEPTH in the environment overrides the value of
2941 LOG_DEPTH at run time.
2942 <indexterm role="concept" startref="IIDbuex" class="endofrange"/>
2943 </para>
2944 </section>
2945 <section>
2946 <title>Installing Exim binaries and scripts</title>
2947 <para>
2948 <indexterm role="concept">
2949 <primary>installing Exim</primary>
2950 </indexterm>
2951 <indexterm role="concept">
2952 <primary>BIN_DIRECTORY</primary>
2953 </indexterm>
2954 The command <literal>make install</literal> runs the <command>exim_install</command> script with no
2955 arguments. The script copies binaries and utility scripts into the directory
2956 whose name is specified by the BIN_DIRECTORY setting in <filename>Local/Makefile</filename>.
2957 <indexterm role="concept">
2958 <primary>setuid</primary>
2959 <secondary>installing Exim with</secondary>
2960 </indexterm>
2961 The install script copies files only if they are newer than the files they are
2962 going to replace. The Exim binary is required to be owned by root and have the
2963 <emphasis>setuid</emphasis> bit set, for normal configurations. Therefore, you must run <literal>make
2964 install</literal> as root so that it can set up the Exim binary in this way. However, in
2965 some special situations (for example, if a host is doing no local deliveries)
2966 it may be possible to run Exim without making the binary setuid root (see
2967 chapter <xref linkend="CHAPsecurity"/> for details).
2968 </para>
2969 <para>
2970 <indexterm role="concept">
2971 <primary>CONFIGURE_FILE</primary>
2972 </indexterm>
2973 Exim&#x2019;s run time configuration file is named by the CONFIGURE_FILE setting
2974 in <filename>Local/Makefile</filename>. If this names a single file, and the file does not
2975 exist, the default configuration file <filename>src/configure.default</filename> is copied there
2976 by the installation script. If a run time configuration file already exists, it
2977 is left alone. If CONFIGURE_FILE is a colon-separated list, naming several
2978 alternative files, no default is installed.
2979 </para>
2980 <para>
2981 <indexterm role="concept">
2982 <primary>system aliases file</primary>
2983 </indexterm>
2984 <indexterm role="concept">
2985 <primary><filename>/etc/aliases</filename></primary>
2986 </indexterm>
2987 One change is made to the default configuration file when it is installed: the
2988 default configuration contains a router that references a system aliases file.
2989 The path to this file is set to the value specified by
2990 SYSTEM_ALIASES_FILE in <filename>Local/Makefile</filename> (<filename>/etc/aliases</filename> by default).
2991 If the system aliases file does not exist, the installation script creates it,
2992 and outputs a comment to the user.
2993 </para>
2994 <para>
2995 The created file contains no aliases, but it does contain comments about the
2996 aliases a site should normally have. Mail aliases have traditionally been
2997 kept in <filename>/etc/aliases</filename>. However, some operating systems are now using
2998 <filename>/etc/mail/aliases</filename>. You should check if yours is one of these, and change
2999 Exim&#x2019;s configuration if necessary.
3000 </para>
3001 <para>
3002 The default configuration uses the local host&#x2019;s name as the only local domain,
3003 and is set up to do local deliveries into the shared directory <filename>/var/mail</filename>,
3004 running as the local user. System aliases and <filename>.forward</filename> files in users&#x2019; home
3005 directories are supported, but no NIS or NIS+ support is configured. Domains
3006 other than the name of the local host are routed using the DNS, with delivery
3007 over SMTP.
3008 </para>
3009 <para>
3010 It is possible to install Exim for special purposes (such as building a binary
3011 distribution) in a private part of the file system. You can do this by a
3012 command such as
3013 </para>
3014 <literallayout class="monospaced">
3015 make DESTDIR=/some/directory/ install
3016 </literallayout>
3017 <para>
3018 This has the effect of pre-pending the specified directory to all the file
3019 paths, except the name of the system aliases file that appears in the default
3020 configuration. (If a default alias file is created, its name <emphasis>is</emphasis> modified.)
3021 For backwards compatibility, ROOT is used if DESTDIR is not set,
3022 but this usage is deprecated.
3023 </para>
3024 <para>
3025 <indexterm role="concept">
3026 <primary>installing Exim</primary>
3027 <secondary>what is not installed</secondary>
3028 </indexterm>
3029 Running <emphasis>make install</emphasis> does not copy the Exim 4 conversion script
3030 <emphasis>convert4r4</emphasis>, or the <emphasis>pcretest</emphasis> test program. You will probably run the
3031 first of these only once (if you are upgrading from Exim 3), and the second
3032 isn&#x2019;t really part of Exim. None of the documentation files in the <filename>doc</filename>
3033 directory are copied, except for the info files when you have set
3034 INFO_DIRECTORY, as described in section <xref linkend="SECTinsinfdoc"/> below.
3035 </para>
3036 <para>
3037 For the utility programs, old versions are renamed by adding the suffix <filename>.O</filename>
3038 to their names. The Exim binary itself, however, is handled differently. It is
3039 installed under a name that includes the version number and the compile number,
3040 for example <filename>exim-4.61-1</filename>. The script then arranges for a symbolic link
3041 called <filename>exim</filename> to point to the binary. If you are updating a previous version
3042 of Exim, the script takes care to ensure that the name <filename>exim</filename> is never absent
3043 from the directory (as seen by other processes).
3044 </para>
3045 <para>
3046 <indexterm role="concept">
3047 <primary>installing Exim</primary>
3048 <secondary>testing the script</secondary>
3049 </indexterm>
3050 If you want to see what the <emphasis>make install</emphasis> will do before running it for
3051 real, you can pass the <option>-n</option> option to the installation script by this
3052 command:
3053 </para>
3054 <literallayout class="monospaced">
3055 make INSTALL_ARG=-n install
3056 </literallayout>
3057 <para>
3058 The contents of the variable INSTALL_ARG are passed to the installation
3059 script. You do not need to be root to run this test. Alternatively, you can run
3060 the installation script directly, but this must be from within the build
3061 directory. For example, from the top-level Exim directory you could use this
3062 command:
3063 </para>
3064 <literallayout class="monospaced">
3065 (cd build-SunOS5-5.5.1-sparc; ../scripts/exim_install -n)
3066 </literallayout>
3067 <para>
3068 <indexterm role="concept">
3069 <primary>installing Exim</primary>
3070 <secondary>install script options</secondary>
3071 </indexterm>
3072 There are two other options that can be supplied to the installation script.
3073 </para>
3074 <itemizedlist>
3075 <listitem>
3076 <para>
3077 <option>-no_chown</option> bypasses the call to change the owner of the installed binary
3078 to root, and the call to make it a setuid binary.
3079 </para>
3080 </listitem>
3081 <listitem>
3082 <para>
3083 <option>-no_symlink</option> bypasses the setting up of the symbolic link <filename>exim</filename> to the
3084 installed binary.
3085 </para>
3086 </listitem>
3087 </itemizedlist>
3088 <para>
3089 INSTALL_ARG can be used to pass these options to the script. For example:
3090 </para>
3091 <literallayout class="monospaced">
3092 make INSTALL_ARG=-no_symlink install
3093 </literallayout>
3094 <para>
3095 The installation script can also be given arguments specifying which files are
3096 to be copied. For example, to install just the Exim binary, and nothing else,
3097 without creating the symbolic link, you could use:
3098 </para>
3099 <literallayout class="monospaced">
3100 make INSTALL_ARG='-no_symlink exim' install
3101 </literallayout>
3102 </section>
3103 <section id="SECTinsinfdoc">
3104 <title>Installing info documentation</title>
3105 <para>
3106 <indexterm role="concept">
3107 <primary>installing Exim</primary>
3108 <secondary><emphasis>info</emphasis> documentation</secondary>
3109 </indexterm>
3110 Not all systems use the GNU <emphasis>info</emphasis> system for documentation, and for this
3111 reason, the Texinfo source of Exim&#x2019;s documentation is not included in the main
3112 distribution. Instead it is available separately from the ftp site (see section
3113 <xref linkend="SECTavail"/>).
3114 </para>
3115 <para>
3116 If you have defined INFO_DIRECTORY in <filename>Local/Makefile</filename> and the Texinfo
3117 source of the documentation is found in the source tree, running <literal>make
3118 install</literal> automatically builds the info files and installs them.
3119 </para>
3120 </section>
3121 <section>
3122 <title>Setting up the spool directory</title>
3123 <para>
3124 <indexterm role="concept">
3125 <primary>spool directory</primary>
3126 <secondary>creating</secondary>
3127 </indexterm>
3128 When it starts up, Exim tries to create its spool directory if it does not
3129 exist. The Exim uid and gid are used for the owner and group of the spool
3130 directory. Sub-directories are automatically created in the spool directory as
3131 necessary.
3132 </para>
3133 </section>
3134 <section>
3135 <title>Testing</title>
3136 <para>
3137 <indexterm role="concept">
3138 <primary>testing</primary>
3139 <secondary>installation</secondary>
3140 </indexterm>
3141 Having installed Exim, you can check that the run time configuration file is
3142 syntactically valid by running the following command, which assumes that the
3143 Exim binary directory is within your PATH environment variable:
3144 </para>
3145 <literallayout class="monospaced">
3146 exim -bV
3147 </literallayout>
3148 <para>
3149 If there are any errors in the configuration file, Exim outputs error messages.
3150 Otherwise it outputs the version number and build date,
3151 the DBM library that is being used, and information about which drivers and
3152 other optional code modules are included in the binary.
3153 Some simple routing tests can be done by using the address testing option. For
3154 example,
3155 </para>
3156 <literallayout>
3157 <literal>exim -bt</literal> &lt;<emphasis>local username</emphasis>&gt;
3158 </literallayout>
3159 <para>
3160 should verify that it recognizes a local mailbox, and
3161 </para>
3162 <literallayout>
3163 <literal>exim -bt</literal> &lt;<emphasis>remote address</emphasis>&gt;
3164 </literallayout>
3165 <para>
3166 a remote one. Then try getting it to deliver mail, both locally and remotely.
3167 This can be done by passing messages directly to Exim, without going through a
3168 user agent. For example:
3169 </para>
3170 <literallayout class="monospaced">
3171 exim -v postmaster@your.domain.example
3172 From: user@your.domain.example
3173 To: postmaster@your.domain.example
3174 Subject: Testing Exim
3175
3176 This is a test message.
3177 ^D
3178 </literallayout>
3179 <para>
3180 The <option>-v</option> option causes Exim to output some verification of what it is doing.
3181 In this case you should see copies of three log lines, one for the message&#x2019;s
3182 arrival, one for its delivery, and one containing <quote>Completed</quote>.
3183 </para>
3184 <para>
3185 <indexterm role="concept">
3186 <primary>delivery</primary>
3187 <secondary>problems with</secondary>
3188 </indexterm>
3189 If you encounter problems, look at Exim&#x2019;s log files (<emphasis>mainlog</emphasis> and
3190 <emphasis>paniclog</emphasis>) to see if there is any relevant information there. Another source
3191 of information is running Exim with debugging turned on, by specifying the
3192 <option>-d</option> option. If a message is stuck on Exim&#x2019;s spool, you can force a delivery
3193 with debugging turned on by a command of the form
3194 </para>
3195 <literallayout>
3196 <literal>exim -d -M</literal> &lt;<emphasis>exim-message-id</emphasis>&gt;
3197 </literallayout>
3198 <para>
3199 You must be root or an <quote>admin user</quote> in order to do this. The <option>-d</option> option
3200 produces rather a lot of output, but you can cut this down to specific areas.
3201 For example, if you use <option>-d-all+route</option> only the debugging information
3202 relevant to routing is included. (See the <option>-d</option> option in chapter
3203 <xref linkend="CHAPcommandline"/> for more details.)
3204 </para>
3205 <para>
3206 <indexterm role="concept">
3207 <primary><quote>sticky</quote> bit</primary>
3208 </indexterm>
3209 <indexterm role="concept">
3210 <primary>lock files</primary>
3211 </indexterm>
3212 One specific problem that has shown up on some sites is the inability to do
3213 local deliveries into a shared mailbox directory, because it does not have the
3214 <quote>sticky bit</quote> set on it. By default, Exim tries to create a lock file before
3215 writing to a mailbox file, and if it cannot create the lock file, the delivery
3216 is deferred. You can get round this either by setting the <quote>sticky bit</quote> on the
3217 directory, or by setting a specific group for local deliveries and allowing
3218 that group to create files in the directory (see the comments above the
3219 <command>local_delivery</command> transport in the default configuration file). Another
3220 approach is to configure Exim not to use lock files, but just to rely on
3221 <function>fcntl()</function> locking instead. However, you should do this only if all user
3222 agents also use <function>fcntl()</function> locking. For further discussion of locking issues,
3223 see chapter <xref linkend="CHAPappendfile"/>.
3224 </para>
3225 <para>
3226 One thing that cannot be tested on a system that is already running an MTA is
3227 the receipt of incoming SMTP mail on the standard SMTP port. However, the
3228 <option>-oX</option> option can be used to run an Exim daemon that listens on some other
3229 port, or <emphasis>inetd</emphasis> can be used to do this. The <option>-bh</option> option and the
3230 <emphasis>exim_checkaccess</emphasis> utility can be used to check out policy controls on
3231 incoming SMTP mail.
3232 </para>
3233 <para>
3234 Testing a new version on a system that is already running Exim can most easily
3235 be done by building a binary with a different CONFIGURE_FILE setting. From
3236 within the run time configuration, all other file and directory names
3237 that Exim uses can be altered, in order to keep it entirely clear of the
3238 production version.
3239 </para>
3240 </section>
3241 <section>
3242 <title>Replacing another MTA with Exim</title>
3243 <para>
3244 <indexterm role="concept">
3245 <primary>replacing another MTA</primary>
3246 </indexterm>
3247 Building and installing Exim for the first time does not of itself put it in
3248 general use. The name by which the system&#x2019;s MTA is called by mail user agents
3249 is either <filename>/usr/sbin/sendmail</filename>, or <filename>/usr/lib/sendmail</filename> (depending on the
3250 operating system), and it is necessary to make this name point to the <emphasis>exim</emphasis>
3251 binary in order to get the user agents to pass messages to Exim. This is
3252 normally done by renaming any existing file and making <filename>/usr/sbin/sendmail</filename>
3253 or <filename>/usr/lib/sendmail</filename>
3254 <indexterm role="concept">
3255 <primary>symbolic link</primary>
3256 <secondary>to <emphasis>exim</emphasis> binary</secondary>
3257 </indexterm>
3258 a symbolic link to the <emphasis>exim</emphasis> binary. It is a good idea to remove any setuid
3259 privilege and executable status from the old MTA. It is then necessary to stop
3260 and restart the mailer daemon, if one is running.
3261 </para>
3262 <para>
3263 <indexterm role="concept">
3264 <primary>FreeBSD</primary>
3265 <secondary>MTA indirection</secondary>
3266 </indexterm>
3267 <indexterm role="concept">
3268 <primary><filename>/etc/mail/mailer.conf</filename></primary>
3269 </indexterm>
3270 Some operating systems have introduced alternative ways of switching MTAs. For
3271 example, if you are running FreeBSD, you need to edit the file
3272 <filename>/etc/mail/mailer.conf</filename> instead of setting up a symbolic link as just
3273 described. A typical example of the contents of this file for running Exim is
3274 as follows:
3275 </para>
3276 <literallayout class="monospaced">
3277 sendmail            /usr/exim/bin/exim
3278 send-mail           /usr/exim/bin/exim
3279 mailq               /usr/exim/bin/exim -bp
3280 newaliases          /usr/bin/true
3281 </literallayout>
3282 <para>
3283 Once you have set up the symbolic link, or edited <filename>/etc/mail/mailer.conf</filename>,
3284 your Exim installation is <quote>live</quote>. Check it by sending a message from your
3285 favourite user agent.
3286 </para>
3287 <para>
3288 You should consider what to tell your users about the change of MTA. Exim may
3289 have different capabilities to what was previously running, and there are
3290 various operational differences such as the text of messages produced by
3291 command line options and in bounce messages. If you allow your users to make
3292 use of Exim&#x2019;s filtering capabilities, you should make the document entitled
3293 <emphasis>Exim&#x2019;s interface to mail filtering</emphasis> available to them.
3294 </para>
3295 </section>
3296 <section>
3297 <title>Upgrading Exim</title>
3298 <para>
3299 <indexterm role="concept">
3300 <primary>upgrading Exim</primary>
3301 </indexterm>
3302 If you are already running Exim on your host, building and installing a new
3303 version automatically makes it available to MUAs, or any other programs that
3304 call the MTA directly. However, if you are running an Exim daemon, you do need
3305 to send it a HUP signal, to make it re-execute itself, and thereby pick up the
3306 new binary. You do not need to stop processing mail in order to install a new
3307 version of Exim. The install script does not modify an existing runtime
3308 configuration file.
3309 </para>
3310 </section>
3311 <section>
3312 <title>Stopping the Exim daemon on Solaris</title>
3313 <para>
3314 <indexterm role="concept">
3315 <primary>Solaris</primary>
3316 <secondary>stopping Exim on</secondary>
3317 </indexterm>
3318 The standard command for stopping the mailer daemon on Solaris is
3319 </para>
3320 <literallayout class="monospaced">
3321 /etc/init.d/sendmail stop
3322 </literallayout>
3323 <para>
3324 If <filename>/usr/lib/sendmail</filename> has been turned into a symbolic link, this script
3325 fails to stop Exim because it uses the command <emphasis>ps -e</emphasis> and greps the output
3326 for the text <quote>sendmail</quote>; this is not present because the actual program name
3327 (that is, <quote>exim</quote>) is given by the <emphasis>ps</emphasis> command with these options. A
3328 solution is to replace the line that finds the process id with something like
3329 </para>
3330 <literallayout class="monospaced">
3331 pid=`cat /var/spool/exim/exim-daemon.pid`
3332 </literallayout>
3333 <para>
3334 to obtain the daemon&#x2019;s pid directly from the file that Exim saves it in.
3335 </para>
3336 <para>
3337 Note, however, that stopping the daemon does not <quote>stop Exim</quote>. Messages can
3338 still be received from local processes, and if automatic delivery is configured
3339 (the normal case), deliveries will still occur.
3340 </para>
3341 </section>
3342 </chapter>
3343
3344 <chapter id="CHAPcommandline">
3345 <title>The Exim command line</title>
3346 <para>
3347 <indexterm role="concept" id="IIDclo1" class="startofrange">
3348 <primary>command line</primary>
3349 <secondary>options</secondary>
3350 </indexterm>
3351 <indexterm role="concept" id="IIDclo2" class="startofrange">
3352 <primary>options</primary>
3353 <secondary>command line</secondary>
3354 </indexterm>
3355 Exim&#x2019;s command line takes the standard Unix form of a sequence of options,
3356 each starting with a hyphen character, followed by a number of arguments. The
3357 options are compatible with the main options of Sendmail, and there are also
3358 some additional options, some of which are compatible with Smail 3. Certain
3359 combinations of options do not make sense, and provoke an error if used.
3360 The form of the arguments depends on which options are set.
3361 </para>
3362 <section>
3363 <title>Setting options by program name</title>
3364 <para>
3365 <indexterm role="concept">
3366 <primary><emphasis>mailq</emphasis></primary>
3367 </indexterm>
3368 If Exim is called under the name <emphasis>mailq</emphasis>, it behaves as if the option <option>-bp</option>
3369 were present before any other options.
3370 The <option>-bp</option> option requests a listing of the contents of the mail queue on the
3371 standard output.
3372 This feature is for compatibility with some systems that contain a command of
3373 that name in one of the standard libraries, symbolically linked to
3374 <filename>/usr/sbin/sendmail</filename> or <filename>/usr/lib/sendmail</filename>.
3375 </para>
3376 <para>
3377 <indexterm role="concept">
3378 <primary><emphasis>rsmtp</emphasis></primary>
3379 </indexterm>
3380 If Exim is called under the name <emphasis>rsmtp</emphasis> it behaves as if the option <option>-bS</option>
3381 were present before any other options, for compatibility with Smail. The
3382 <option>-bS</option> option is used for reading in a number of messages in batched SMTP
3383 format.
3384 </para>
3385 <para>
3386 <indexterm role="concept">
3387 <primary><emphasis>rmail</emphasis></primary>
3388 </indexterm>
3389 If Exim is called under the name <emphasis>rmail</emphasis> it behaves as if the <option>-i</option> and
3390 <option>-oee</option> options were present before any other options, for compatibility with
3391 Smail. The name <emphasis>rmail</emphasis> is used as an interface by some UUCP systems.
3392 </para>
3393 <para>
3394 <indexterm role="concept">
3395 <primary><emphasis>runq</emphasis></primary>
3396 </indexterm>
3397 <indexterm role="concept">
3398 <primary>queue runner</primary>
3399 </indexterm>
3400 If Exim is called under the name <emphasis>runq</emphasis> it behaves as if the option <option>-q</option>
3401 were present before any other options, for compatibility with Smail. The <option>-q</option>
3402 option causes a single queue runner process to be started.
3403 </para>
3404 <para>
3405 <indexterm role="concept">
3406 <primary><emphasis>newaliases</emphasis></primary>
3407 </indexterm>
3408 <indexterm role="concept">
3409 <primary>alias file</primary>
3410 <secondary>building</secondary>
3411 </indexterm>
3412 <indexterm role="concept">
3413 <primary>Sendmail compatibility</primary>
3414 <secondary>calling Exim as <emphasis>newaliases</emphasis></secondary>
3415 </indexterm>
3416 If Exim is called under the name <emphasis>newaliases</emphasis> it behaves as if the option
3417 <option>-bi</option> were present before any other options, for compatibility with Sendmail.
3418 This option is used for rebuilding Sendmail&#x2019;s alias file. Exim does not have
3419 the concept of a single alias file, but can be configured to run a given
3420 command if called with the <option>-bi</option> option.
3421 </para>
3422 </section>
3423 <section id="SECTtrustedadmin">
3424 <title>Trusted and admin users</title>
3425 <para>
3426 Some Exim options are available only to <emphasis>trusted users</emphasis> and others are
3427 available only to <emphasis>admin users</emphasis>. In the description below, the phrases <quote>Exim
3428 user</quote> and <quote>Exim group</quote> mean the user and group defined by EXIM_USER and
3429 EXIM_GROUP in <filename>Local/Makefile</filename> or set by the <option>exim_user</option> and
3430 <option>exim_group</option> options. These do not necessarily have to use the name <quote>exim</quote>.
3431 </para>
3432 <itemizedlist>
3433 <listitem>
3434 <para>
3435 <indexterm role="concept">
3436 <primary>trusted user</primary>
3437 <secondary>definition of</secondary>
3438 </indexterm>
3439 <indexterm role="concept">
3440 <primary>user</primary>
3441 <secondary>trusted definition of</secondary>
3442 </indexterm>
3443 The trusted users are root, the Exim user, any user listed in the
3444 <option>trusted_users</option> configuration option, and any user whose current group or any
3445 supplementary group is one of those listed in the <option>trusted_groups</option>
3446 configuration option. Note that the Exim group is not automatically trusted.
3447 </para>
3448 <para>
3449 <indexterm role="concept">
3450 <primary><quote>From</quote> line</primary>
3451 </indexterm>
3452 <indexterm role="concept">
3453 <primary>envelope sender</primary>
3454 </indexterm>
3455 Trusted users are always permitted to use the <option>-f</option> option or a leading
3456 <quote>From&nbsp;</quote> line to specify the envelope sender of a message that is passed to
3457 Exim through the local interface (see the <option>-bm</option> and <option>-f</option> options below).
3458 See the <option>untrusted_set_sender</option> option for a way of permitting non-trusted
3459 users to set envelope senders.
3460 </para>
3461 <para>
3462 <indexterm role="concept">
3463 <primary><emphasis>From:</emphasis> header line</primary>
3464 </indexterm>
3465 <indexterm role="concept">
3466 <primary><emphasis>Sender:</emphasis> header line</primary>
3467 </indexterm>
3468 For a trusted user, there is never any check on the contents of the <emphasis>From:</emphasis>
3469 header line, and a <emphasis>Sender:</emphasis> line is never added. Furthermore, any existing
3470 <emphasis>Sender:</emphasis> line in incoming local (non-TCP/IP) messages is not removed.
3471 </para>
3472 <para>
3473 Trusted users may also specify a host name, host address, interface address,
3474 protocol name, ident value, and authentication data when submitting a message
3475 locally. Thus, they are able to insert messages into Exim&#x2019;s queue locally that
3476 have the characteristics of messages received from a remote host. Untrusted
3477 users may in some circumstances use <option>-f</option>, but can never set the other values
3478 that are available to trusted users.
3479 </para>
3480 </listitem>
3481 <listitem>
3482 <para>
3483 <indexterm role="concept">
3484 <primary>user</primary>
3485 <secondary>admin definition of</secondary>
3486 </indexterm>
3487 <indexterm role="concept">
3488 <primary>admin user</primary>
3489 <secondary>definition of</secondary>
3490 </indexterm>
3491 The admin users are root, the Exim user, and any user that is a member of the
3492 Exim group or of any group listed in the <option>admin_groups</option> configuration option.
3493 The current group does not have to be one of these groups.
3494 </para>
3495 <para>
3496 Admin users are permitted to list the queue, and to carry out certain
3497 operations on messages, for example, to force delivery failures. It is also
3498 necessary to be an admin user in order to see the full information provided by
3499 the Exim monitor, and full debugging output.
3500 </para>
3501 <para>
3502 By default, the use of the <option>-M</option>, <option>-q</option>, <option>-R</option>, and <option>-S</option> options to cause
3503 Exim to attempt delivery of messages on its queue is restricted to admin users.
3504 However, this restriction can be relaxed by setting the <option>prod_requires_admin</option>
3505 option false (that is, specifying <option>no_prod_requires_admin</option>).
3506 </para>
3507 <para>
3508 Similarly, the use of the <option>-bp</option> option to list all the messages in the queue
3509 is restricted to admin users unless <option>queue_list_requires_admin</option> is set
3510 false.
3511 </para>
3512 </listitem>
3513 </itemizedlist>
3514 <para>
3515 <emphasis role="bold">Warning</emphasis>: If you configure your system so that admin users are able to
3516 edit Exim&#x2019;s configuration file, you are giving those users an easy way of
3517 getting root. There is further discussion of this issue at the start of chapter
3518 <xref linkend="CHAPconf"/>.
3519 </para>
3520 </section>
3521 <section>
3522 <title>Command line options</title>
3523 <para>
3524 The command options are described in alphabetical order below.
3525 </para>
3526 <!-- === Start of command line options === -->
3527 <variablelist>
3528 <varlistentry>
3529 <term><option>--</option></term>
3530 <listitem>
3531 <para>
3532 <indexterm role="option">
3533 <primary>--</primary>
3534 </indexterm>
3535 <indexterm role="concept">
3536 <primary>options</primary>
3537 <secondary>command line; terminating</secondary>
3538 </indexterm>
3539 This is a pseudo-option whose only purpose is to terminate the options and
3540 therefore to cause subsequent command line items to be treated as arguments
3541 rather than options, even if they begin with hyphens.
3542 </para>
3543 </listitem></varlistentry>
3544 <varlistentry>
3545 <term><option>--help</option></term>
3546 <listitem>
3547 <para>
3548 <indexterm role="option">
3549 <primary><option>--help</option></primary>
3550 </indexterm>
3551 This option causes Exim to output a few sentences stating what it is.
3552 The same output is generated if the Exim binary is called with no options and
3553 no arguments.
3554 </para>
3555 </listitem></varlistentry>
3556 <varlistentry>
3557 <term><option>-B</option>&lt;<emphasis>type</emphasis>&gt;</term>
3558 <listitem>
3559 <para>
3560 <indexterm role="option">
3561 <primary><option>-B</option></primary>
3562 </indexterm>
3563 <indexterm role="concept">
3564 <primary>8-bit characters</primary>
3565 </indexterm>
3566 <indexterm role="concept">
3567 <primary>Sendmail compatibility</primary>
3568 <secondary>8-bit characters</secondary>
3569 </indexterm>
3570 This is a Sendmail option for selecting 7 or 8 bit processing. Exim is 8-bit
3571 clean; it ignores this option.
3572 </para>
3573 </listitem></varlistentry>
3574 <varlistentry>
3575 <term><option>-bd</option></term>
3576 <listitem>
3577 <para>
3578 <indexterm role="option">
3579 <primary><option>-bd</option></primary>
3580 </indexterm>
3581 <indexterm role="concept">
3582 <primary>daemon</primary>
3583 </indexterm>
3584 <indexterm role="concept">
3585 <primary>SMTP listener</primary>
3586 </indexterm>
3587 <indexterm role="concept">
3588 <primary>queue runner</primary>
3589 </indexterm>
3590 This option runs Exim as a daemon, awaiting incoming SMTP connections. Usually
3591 the <option>-bd</option> option is combined with the <option>-q</option>&lt;<emphasis>time</emphasis>&gt; option, to specify
3592 that the daemon should also initiate periodic queue runs.
3593 </para>
3594 <para>
3595 The <option>-bd</option> option can be used only by an admin user. If either of the <option>-d</option>
3596 (debugging) or <option>-v</option> (verifying) options are set, the daemon does not
3597 disconnect from the controlling terminal. When running this way, it can be
3598 stopped by pressing ctrl-C.
3599 </para>
3600 <para>
3601 By default, Exim listens for incoming connections to the standard SMTP port on
3602 all the host&#x2019;s running interfaces. However, it is possible to listen on other
3603 ports, on multiple ports, and only on specific interfaces. Chapter
3604 <xref linkend="CHAPinterfaces"/> contains a description of the options that control this.
3605 </para>
3606 <para>
3607 When a listening daemon
3608 <indexterm role="concept">
3609 <primary>daemon</primary>
3610 <secondary>process id (pid)</secondary>
3611 </indexterm>
3612 <indexterm role="concept">
3613 <primary>pid (process id)</primary>
3614 <secondary>of daemon</secondary>
3615 </indexterm>
3616 is started without the use of <option>-oX</option> (that is, without overriding the normal
3617 configuration), it writes its process id to a file called <filename>exim-daemon.pid</filename>
3618 in Exim&#x2019;s spool directory. This location can be overridden by setting
3619 PID_FILE_PATH in <filename>Local/Makefile</filename>. The file is written while Exim is still
3620 running as root.
3621 </para>
3622 <para>
3623 When <option>-oX</option> is used on the command line to start a listening daemon, the
3624 process id is not written to the normal pid file path. However, <option>-oP</option> can be
3625 used to specify a path on the command line if a pid file is required.
3626 </para>
3627 <para>
3628 The SIGHUP signal
3629 <indexterm role="concept">
3630 <primary>SIGHUP</primary>
3631 </indexterm>
3632 can be used to cause the daemon to re-exec itself. This should be done whenever
3633 Exim&#x2019;s configuration file, or any file that is incorporated into it by means of
3634 the <option>.include</option> facility, is changed, and also whenever a new version of Exim
3635 is installed. It is not necessary to do this when other files that are
3636 referenced from the configuration (for example, alias files) are changed,
3637 because these are reread each time they are used.
3638 </para>
3639 </listitem></varlistentry>
3640 <varlistentry>
3641 <term><option>-bdf</option></term>
3642 <listitem>
3643 <para>
3644 <indexterm role="option">
3645 <primary><option>-bdf</option></primary>
3646 </indexterm>
3647 This option has the same effect as <option>-bd</option> except that it never disconnects
3648 from the controlling terminal, even when no debugging is specified.
3649 </para>
3650 </listitem></varlistentry>
3651 <varlistentry>
3652 <term><option>-be</option></term>
3653 <listitem>
3654 <para>
3655 <indexterm role="option">
3656 <primary><option>-be</option></primary>
3657 </indexterm>
3658 <indexterm role="concept">
3659 <primary>testing</primary>
3660 <secondary>string expansion</secondary>
3661 </indexterm>
3662 <indexterm role="concept">
3663 <primary>expansion</primary>
3664 <secondary>testing</secondary>
3665 </indexterm>
3666 Run Exim in expansion testing mode. Exim discards its root privilege, to
3667 prevent ordinary users from using this mode to read otherwise inaccessible
3668 files. If no arguments are given, Exim runs interactively, prompting for lines
3669 of data. Otherwise, it processes each argument in turn.
3670 </para>
3671 <para>
3672 If Exim was built with USE_READLINE=yes in <filename>Local/Makefile</filename>, it tries
3673 to load the <option>libreadline</option> library dynamically whenever the <option>-be</option> option is
3674 used without command line arguments. If successful, it uses the <function>readline()</function>
3675 function, which provides extensive line-editing facilities, for reading the
3676 test data. A line history is supported.
3677 </para>
3678 <para>
3679 Long expansion expressions can be split over several lines by using backslash
3680 continuations. As in Exim&#x2019;s run time configuration, white space at the start of
3681 continuation lines is ignored. Each argument or data line is passed through the
3682 string expansion mechanism, and the result is output. Variable values from the
3683 configuration file (for example, <varname>$qualify_domain</varname>) are available, but no
3684 message-specific values (such as <varname>$domain</varname>) are set, because no message is
3685 being processed.
3686 </para>
3687 <para>
3688 <emphasis role="bold">Note</emphasis>: If you use this mechanism to test lookups, and you change the data
3689 files or databases you are using, you must exit and restart Exim before trying
3690 the same lookup again. Otherwise, because each Exim process caches the results
3691 of lookups, you will just get the same result as before.
3692 </para>
3693 </listitem></varlistentry>
3694 <varlistentry>
3695 <term><option>-bF</option>&nbsp;&lt;<emphasis>filename</emphasis>&gt;</term>
3696 <listitem>
3697 <para>
3698 <indexterm role="option">
3699 <primary><option>-bF</option></primary>
3700 </indexterm>
3701 <indexterm role="concept">
3702 <primary>system filter</primary>
3703 <secondary>testing</secondary>
3704 </indexterm>
3705 <indexterm role="concept">
3706 <primary>testing</primary>
3707 <secondary>system filter</secondary>
3708 </indexterm>
3709 This option is the same as <option>-bf</option> except that it assumes that the filter being
3710 tested is a system filter. The additional commands that are available only in
3711 system filters are recognized.
3712 </para>
3713 </listitem></varlistentry>
3714 <varlistentry>
3715 <term><option>-bf</option>&nbsp;&lt;<emphasis>filename</emphasis>&gt;</term>
3716 <listitem>
3717 <para>
3718 <indexterm role="option">
3719 <primary><option>-bf</option></primary>
3720 </indexterm>
3721 <indexterm role="concept">
3722 <primary>filter</primary>
3723 <secondary>testing</secondary>
3724 </indexterm>
3725 <indexterm role="concept">
3726 <primary>testing</primary>
3727 <secondary>filter file</secondary>
3728 </indexterm>
3729 <indexterm role="concept">
3730 <primary>forward file</primary>
3731 <secondary>testing</secondary>
3732 </indexterm>
3733 <indexterm role="concept">
3734 <primary>testing</primary>
3735 <secondary>forward file</secondary>
3736 </indexterm>
3737 <indexterm role="concept">
3738 <primary>Sieve filter</primary>
3739 <secondary>testing</secondary>
3740 </indexterm>
3741 This option runs Exim in user filter testing mode; the file is the filter file
3742 to be tested, and a test message must be supplied on the standard input. If
3743 there are no message-dependent tests in the filter, an empty file can be
3744 supplied.
3745 </para>
3746 <para>
3747 If you want to test a system filter file, use <option>-bF</option> instead of <option>-bf</option>. You
3748 can use both <option>-bF</option> and <option>-bf</option> on the same command, in order to test a system
3749 filter and a user filter in the same run. For example:
3750 </para>
3751 <literallayout class="monospaced">
3752 exim -bF /system/filter -bf /user/filter &lt;/test/message
3753 </literallayout>
3754 <para>
3755 This is helpful when the system filter adds header lines or sets filter
3756 variables that are used by the user filter.
3757 </para>
3758 <para>
3759 If the test filter file does not begin with one of the special lines
3760 </para>
3761 <literallayout class="monospaced">
3762 # Exim filter
3763 # Sieve filter
3764 </literallayout>
3765 <para>
3766 it is taken to be a normal <filename>.forward</filename> file, and is tested for validity under
3767 that interpretation. See sections <xref linkend="SECTitenonfilred"/> to
3768 <xref linkend="SECTspecitredli"/> for a description of the possible contents of non-filter
3769 redirection lists.
3770 </para>
3771 <para>
3772 The result of an Exim command that uses <option>-bf</option>, provided no errors are
3773 detected, is a list of the actions that Exim would try to take if presented
3774 with the message for real. More details of filter testing are given in the
3775 separate document entitled <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis>.
3776 </para>
3777 <para>
3778 When testing a filter file,
3779 <indexterm role="concept">
3780 <primary><quote>From</quote> line</primary>
3781 </indexterm>
3782 <indexterm role="concept">
3783 <primary>envelope sender</primary>
3784 </indexterm>
3785 <indexterm role="concept">
3786 <primary><option>-f</option> option</primary>
3787 <secondary>for filter testing</secondary>
3788 </indexterm>
3789 the envelope sender can be set by the <option>-f</option> option,
3790 or by a <quote>From&nbsp;</quote> line at the start of the test message. Various parameters
3791 that would normally be taken from the envelope recipient address of the message
3792 can be set by means of additional command line options (see the next four
3793 options).
3794 </para>
3795 </listitem></varlistentry>
3796 <varlistentry>
3797 <term><option>-bfd</option>&nbsp;&lt;<emphasis>domain</emphasis>&gt;</term>
3798 <listitem>
3799 <para>
3800 <indexterm role="option">
3801 <primary><option>-bfd</option></primary>
3802 </indexterm>
3803 <indexterm role="concept">
3804 <primary><varname>$qualify_domain</varname></primary>
3805 </indexterm>
3806 This sets the domain of the recipient address when a filter file is being
3807 tested by means of the <option>-bf</option> option. The default is the value of
3808 <varname>$qualify_domain</varname>.
3809 </para>
3810 </listitem></varlistentry>
3811 <varlistentry>
3812 <term><option>-bfl</option>&nbsp;&lt;<emphasis>local&nbsp;part</emphasis>&gt;</term>
3813 <listitem>
3814 <para>
3815 <indexterm role="option">
3816 <primary><option>-bfl</option></primary>
3817 </indexterm>
3818 This sets the local part of the recipient address when a filter file is being
3819 tested by means of the <option>-bf</option> option. The default is the username of the
3820 process that calls Exim. A local part should be specified with any prefix or
3821 suffix stripped, because that is how it appears to the filter when a message is
3822 actually being delivered.
3823 </para>
3824 </listitem></varlistentry>
3825 <varlistentry>
3826 <term><option>-bfp</option>&nbsp;&lt;<emphasis>prefix</emphasis>&gt;</term>
3827 <listitem>
3828 <para>
3829 <indexterm role="option">
3830 <primary><option>-bfp</option></primary>
3831 </indexterm>
3832 This sets the prefix of the local part of the recipient address when a filter
3833 file is being tested by means of the <option>-bf</option> option. The default is an empty
3834 prefix.
3835 </para>
3836 </listitem></varlistentry>
3837 <varlistentry>
3838 <term><option>-bfs</option>&nbsp;&lt;<emphasis>suffix</emphasis>&gt;</term>
3839 <listitem>
3840 <para>
3841 <indexterm role="option">
3842 <primary><option>-bfs</option></primary>
3843 </indexterm>
3844 This sets the suffix of the local part of the recipient address when a filter
3845 file is being tested by means of the <option>-bf</option> option. The default is an empty
3846 suffix.
3847 </para>
3848 </listitem></varlistentry>
3849 <varlistentry>
3850 <term><option>-bh</option>&nbsp;&lt;<emphasis>IP&nbsp;address</emphasis>&gt;</term>
3851 <listitem>
3852 <para>
3853 <indexterm role="option">
3854 <primary><option>-bh</option></primary>
3855 </indexterm>
3856 <indexterm role="concept">
3857 <primary>testing</primary>
3858 <secondary>incoming SMTP</secondary>
3859 </indexterm>
3860 <indexterm role="concept">
3861 <primary>SMTP</primary>
3862 <secondary>testing incoming</secondary>
3863 </indexterm>
3864 <indexterm role="concept">
3865 <primary>testing</primary>
3866 <secondary>relay control</secondary>
3867 </indexterm>
3868 <indexterm role="concept">
3869 <primary>relaying</primary>
3870 <secondary>testing configuration</secondary>
3871 </indexterm>
3872 <indexterm role="concept">
3873 <primary>policy control</primary>
3874 <secondary>testing</secondary>
3875 </indexterm>
3876 <indexterm role="concept">
3877 <primary>debugging</primary>
3878 <secondary><option>-bh</option> option</secondary>
3879 </indexterm>
3880 This option runs a fake SMTP session as if from the given IP address, using the
3881 standard input and output. The IP address may include a port number at the end,
3882 after a full stop. For example:
3883 </para>
3884 <literallayout class="monospaced">
3885 exim -bh 10.9.8.7.1234
3886 exim -bh fe80::a00:20ff:fe86:a061.5678
3887 </literallayout>
3888 <para>
3889 When an IPv6 address is given, it is converted into canonical form. In the case
3890 of the second example above, the value of <varname>$sender_host_address</varname> after
3891 conversion to the canonical form is
3892 <literal>fe80:0000:0000:0a00:20ff:fe86:a061.5678</literal>.
3893 </para>
3894 <para>
3895 Comments as to what is going on are written to the standard error file. These
3896 include lines beginning with <quote>LOG</quote> for anything that would have been logged.
3897 This facility is provided for testing configuration options for incoming
3898 messages, to make sure they implement the required policy. For example, you can
3899 test your relay controls using <option>-bh</option>.
3900 </para>
3901 <para>
3902 <emphasis role="bold">Warning 1</emphasis>:
3903 <indexterm role="concept">
3904 <primary>RFC 1413</primary>
3905 </indexterm>
3906 You cannot test features of the configuration that rely on
3907 ident (RFC 1413) callouts. These cannot be done when testing using
3908 <option>-bh</option> because there is no incoming SMTP connection.
3909 </para>
3910 <para>
3911 <emphasis role="bold">Warning 2</emphasis>: Address verification callouts (see section <xref linkend="SECTcallver"/>)
3912 are also skipped when testing using <option>-bh</option>. If you want these callouts to
3913 occur, use <option>-bhc</option> instead.
3914 </para>
3915 <para>
3916 Messages supplied during the testing session are discarded, and nothing is
3917 written to any of the real log files. There may be pauses when DNS (and other)
3918 lookups are taking place, and of course these may time out. The <option>-oMi</option> option
3919 can be used to specify a specific IP interface and port if this is important.
3920 </para>
3921 <para>
3922 The <emphasis>exim_checkaccess</emphasis> utility is a <quote>packaged</quote> version of <option>-bh</option> whose
3923 output just states whether a given recipient address from a given host is
3924 acceptable or not. See section <xref linkend="SECTcheckaccess"/>.
3925 </para>
3926 </listitem></varlistentry>
3927 <varlistentry>
3928 <term><option>-bhc</option>&nbsp;&lt;<emphasis>IP&nbsp;address</emphasis>&gt;</term>
3929 <listitem>
3930 <para>
3931 <indexterm role="option">
3932 <primary><option>-bhc</option></primary>
3933 </indexterm>
3934 This option operates in the same way as <option>-bh</option>, except that address
3935 verification callouts are performed if required. This includes consulting and
3936 updating the callout cache database.
3937 </para>
3938 </listitem></varlistentry>
3939 <varlistentry>
3940 <term><option>-bi</option></term>
3941 <listitem>
3942 <para>
3943 <indexterm role="option">
3944 <primary><option>-bi</option></primary>
3945 </indexterm>
3946 <indexterm role="concept">
3947 <primary>alias file</primary>
3948 <secondary>building</secondary>
3949 </indexterm>
3950 <indexterm role="concept">
3951 <primary>building alias file</primary>
3952 </indexterm>
3953 <indexterm role="concept">
3954 <primary>Sendmail compatibility</primary>
3955 <secondary><option>-bi</option> option</secondary>
3956 </indexterm>
3957 Sendmail interprets the <option>-bi</option> option as a request to rebuild its alias file.
3958 Exim does not have the concept of a single alias file, and so it cannot mimic
3959 this behaviour. However, calls to <filename>/usr/lib/sendmail</filename> with the <option>-bi</option> option
3960 tend to appear in various scripts such as NIS make files, so the option must be
3961 recognized.
3962 </para>
3963 <para>
3964 If <option>-bi</option> is encountered, the command specified by the <option>bi_command</option>
3965 configuration option is run, under the uid and gid of the caller of Exim. If
3966 the <option>-oA</option> option is used, its value is passed to the command as an argument.
3967 The command set by <option>bi_command</option> may not contain arguments. The command can
3968 use the <emphasis>exim_dbmbuild</emphasis> utility, or some other means, to rebuild alias files
3969 if this is required. If the <option>bi_command</option> option is not set, calling Exim with
3970 <option>-bi</option> is a no-op.
3971 </para>
3972 </listitem></varlistentry>
3973 <varlistentry>
3974 <term><option>-bm</option></term>
3975 <listitem>
3976 <para>
3977 <indexterm role="option">
3978 <primary><option>-bm</option></primary>
3979 </indexterm>
3980 <indexterm role="concept">
3981 <primary>local message reception</primary>
3982 </indexterm>
3983 This option runs an Exim receiving process that accepts an incoming,
3984 locally-generated message on the current input. The recipients are given as the
3985 command arguments (except when <option>-t</option> is also present &ndash; see below). Each
3986 argument can be a comma-separated list of RFC 2822 addresses. This is the
3987 default option for selecting the overall action of an Exim call; it is assumed
3988 if no other conflicting option is present.
3989 </para>
3990 <para>
3991 If any addresses in the message are unqualified (have no domain), they are
3992 qualified by the values of the <option>qualify_domain</option> or <option>qualify_recipient</option>
3993 options, as appropriate. The <option>-bnq</option> option (see below) provides a way of
3994 suppressing this for special cases.
3995 </para>
3996 <para>
3997 Policy checks on the contents of local messages can be enforced by means of
3998 the non-SMTP ACL. See chapter <xref linkend="CHAPACL"/> for details.
3999 </para>
4000 <para>
4001 <indexterm role="concept">
4002 <primary>return code</primary>
4003 <secondary>for <option>-bm</option></secondary>
4004 </indexterm>
4005 The return code is zero if the message is successfully accepted. Otherwise, the
4006 action is controlled by the <option>-oe</option><emphasis>x</emphasis> option setting &ndash; see below.
4007 </para>
4008 <para>
4009 The format
4010 <indexterm role="concept">
4011 <primary>message</primary>
4012 <secondary>format</secondary>
4013 </indexterm>
4014 <indexterm role="concept">
4015 <primary>format</primary>
4016 <secondary>message</secondary>
4017 </indexterm>
4018 <indexterm role="concept">
4019 <primary><quote>From</quote> line</primary>
4020 </indexterm>
4021 <indexterm role="concept">
4022 <primary>UUCP</primary>
4023 <secondary><quote>From</quote> line</secondary>
4024 </indexterm>
4025 <indexterm role="concept">
4026 <primary>Sendmail compatibility</primary>
4027 <secondary><quote>From</quote> line</secondary>
4028 </indexterm>
4029 of the message must be as defined in RFC 2822, except that, for
4030 compatibility with Sendmail and Smail, a line in one of the forms
4031 </para>
4032 <literallayout class="monospaced">
4033 From sender Fri Jan  5 12:55 GMT 1997
4034 From sender Fri, 5 Jan 97 12:55:01
4035 </literallayout>
4036 <para>
4037 (with the weekday optional, and possibly with additional text after the date)
4038 is permitted to appear at the start of the message. There appears to be no
4039 authoritative specification of the format of this line. Exim recognizes it by
4040 matching against the regular expression defined by the <option>uucp_from_pattern</option>
4041 option, which can be changed if necessary.
4042 </para>
4043 <para>
4044 The
4045 <indexterm role="concept">
4046 <primary><option>-f</option> option</primary>
4047 <secondary>overriding <quote>From</quote> line</secondary>
4048 </indexterm>
4049 specified sender is treated as if it were given as the argument to the
4050 <option>-f</option> option, but if a <option>-f</option> option is also present, its argument is used in
4051 preference to the address taken from the message. The caller of Exim must be a
4052 trusted user for the sender of a message to be set in this way.
4053 </para>
4054 </listitem></varlistentry>
4055 <varlistentry>
4056 <term><option>-bnq</option></term>
4057 <listitem>
4058 <para>
4059 <indexterm role="option">
4060 <primary><option>-bnq</option></primary>
4061 </indexterm>
4062 <indexterm role="concept">
4063 <primary>address qualification</primary>
4064 <secondary>suppressing</secondary>
4065 </indexterm>
4066 By default, Exim automatically qualifies unqualified addresses (those
4067 without domains) that appear in messages that are submitted locally (that
4068 is, not over TCP/IP). This qualification applies both to addresses in
4069 envelopes, and addresses in header lines. Sender addresses are qualified using
4070 <option>qualify_domain</option>, and recipient addresses using <option>qualify_recipient</option> (which
4071 defaults to the value of <option>qualify_domain</option>).
4072 </para>
4073 <para>
4074 Sometimes, qualification is not wanted. For example, if <option>-bS</option> (batch SMTP) is
4075 being used to re-submit messages that originally came from remote hosts after
4076 content scanning, you probably do not want to qualify unqualified addresses in
4077 header lines. (Such lines will be present only if you have not enabled a header
4078 syntax check in the appropriate ACL.)
4079 </para>
4080 <para>
4081 The <option>-bnq</option> option suppresses all qualification of unqualified addresses in
4082 messages that originate on the local host. When this is used, unqualified
4083 addresses in the envelope provoke errors (causing message rejection) and
4084 unqualified addresses in header lines are left alone.
4085 </para>
4086 </listitem></varlistentry>
4087 <varlistentry>
4088 <term><option>-bP</option></term>
4089 <listitem>
4090 <para>
4091 <indexterm role="option">
4092 <primary><option>-bP</option></primary>
4093 </indexterm>
4094 <indexterm role="concept">
4095 <primary>configuration options</primary>
4096 <secondary>extracting</secondary>
4097 </indexterm>
4098 <indexterm role="concept">
4099 <primary>options</primary>
4100 <secondary>configuration &ndash; extracting</secondary>
4101 </indexterm>
4102 If this option is given with no arguments, it causes the values of all Exim&#x2019;s
4103 main configuration options to be written to the standard output. The values
4104 of one or more specific options can be requested by giving their names as
4105 arguments, for example:
4106 </para>
4107 <literallayout class="monospaced">
4108 exim -bP qualify_domain hold_domains
4109 </literallayout>
4110 <para>
4111 However, any option setting that is preceded by the word <quote>hide</quote> in the
4112 configuration file is not shown in full, except to an admin user. For other
4113 users, the output is as in this example:
4114 </para>
4115 <literallayout class="monospaced">
4116 mysql_servers = &lt;value not displayable&gt;
4117 </literallayout>
4118 <para>
4119 If <option>configure_file</option> is given as an argument, the name of the run time
4120 configuration file is output.
4121 If a list of configuration files was supplied, the value that is output here
4122 is the name of the file that was actually used.
4123 </para>
4124 <para>
4125 <indexterm role="concept">
4126 <primary>daemon</primary>
4127 <secondary>process id (pid)</secondary>
4128 </indexterm>
4129 <indexterm role="concept">
4130 <primary>pid (process id)</primary>
4131 <secondary>of daemon</secondary>
4132 </indexterm>
4133 If <option>log_file_path</option> or <option>pid_file_path</option> are given, the names of the
4134 directories where log files and daemon pid files are written are output,
4135 respectively. If these values are unset, log files are written in a
4136 sub-directory of the spool directory called <option>log</option>, and the pid file is
4137 written directly into the spool directory.
4138 </para>
4139 <para>
4140 If <option>-bP</option> is followed by a name preceded by <literal>+</literal>, for example,
4141 </para>
4142 <literallayout class="monospaced">
4143 exim -bP +local_domains
4144 </literallayout>
4145 <para>
4146 it searches for a matching named list of any type (domain, host, address, or
4147 local part) and outputs what it finds.
4148 </para>
4149 <para>
4150 <indexterm role="concept">
4151 <primary>options</primary>
4152 <secondary>router &ndash; extracting</secondary>
4153 </indexterm>
4154 <indexterm role="concept">
4155 <primary>options</primary>
4156 <secondary>transport &ndash; extracting</secondary>
4157 </indexterm>
4158 If one of the words <option>router</option>, <option>transport</option>, or <option>authenticator</option> is given,
4159 followed by the name of an appropriate driver instance, the option settings for
4160 that driver are output. For example:
4161 </para>
4162 <literallayout class="monospaced">
4163 exim -bP transport local_delivery
4164 </literallayout>
4165 <para>
4166 The generic driver options are output first, followed by the driver&#x2019;s private
4167 options. A list of the names of drivers of a particular type can be obtained by
4168 using one of the words <option>router_list</option>, <option>transport_list</option>, or
4169 <option>authenticator_list</option>, and a complete list of all drivers with their option
4170 settings can be obtained by using <option>routers</option>, <option>transports</option>, or
4171 <option>authenticators</option>.
4172 </para>
4173 </listitem></varlistentry>
4174 <varlistentry>
4175 <term><option>-bp</option></term>
4176 <listitem>
4177 <para>
4178 <indexterm role="option">
4179 <primary><option>-bp</option></primary>
4180 </indexterm>
4181 <indexterm role="concept">
4182 <primary>queue</primary>
4183 <secondary>listing messages on</secondary>
4184 </indexterm>
4185 <indexterm role="concept">
4186 <primary>listing</primary>
4187 <secondary>messages on the queue</secondary>
4188 </indexterm>
4189 This option requests a listing of the contents of the mail queue on the
4190 standard output. If the <option>-bp</option> option is followed by a list of message ids,
4191 just those messages are listed. By default, this option can be used only by an
4192 admin user. However, the <option>queue_list_requires_admin</option> option can be set false
4193 to allow any user to see the queue.
4194 </para>
4195 <para>
4196 Each message on the queue is displayed as in the following example:
4197 </para>
4198 <literallayout class="monospaced">
4199 25m  2.9K 0t5C6f-0000c8-00 &lt;alice@wonderland.fict.example&gt;
4200           red.king@looking-glass.fict.example
4201           &lt;other addresses&gt;
4202 </literallayout>
4203 <para>
4204 <indexterm role="concept">
4205 <primary>message</primary>
4206 <secondary>size in queue listing</secondary>
4207 </indexterm>
4208 <indexterm role="concept">
4209 <primary>size</primary>
4210 <secondary>of message</secondary>
4211 </indexterm>
4212 The first line contains the length of time the message has been on the queue
4213 (in this case 25 minutes), the size of the message (2.9K), the unique local
4214 identifier for the message, and the message sender, as contained in the
4215 envelope. For bounce messages, the sender address is empty, and appears as
4216 <quote>&lt;&gt;</quote>. If the message was submitted locally by an untrusted user who overrode
4217 the default sender address, the user&#x2019;s login name is shown in parentheses
4218 before the sender address.
4219 </para>
4220 <para>
4221 <indexterm role="concept">
4222 <primary>frozen messages</primary>
4223 <secondary>in queue listing</secondary>
4224 </indexterm>
4225 If the message is frozen (attempts to deliver it are suspended) then the text
4226 <quote>*** frozen ***</quote> is displayed at the end of this line.
4227 </para>
4228 <para>
4229 The recipients of the message (taken from the envelope, not the headers) are
4230 displayed on subsequent lines. Those addresses to which the message has already
4231 been delivered are marked with the letter D. If an original address gets
4232 expanded into several addresses via an alias or forward file, the original is
4233 displayed with a D only when deliveries for all of its child addresses are
4234 complete.
4235 </para>
4236 </listitem></varlistentry>
4237 <varlistentry>
4238 <term><option>-bpa</option></term>
4239 <listitem>
4240 <para>
4241 <indexterm role="option">
4242 <primary><option>-bpa</option></primary>
4243 </indexterm>
4244 This option operates like <option>-bp</option>, but in addition it shows delivered addresses
4245 that were generated from the original top level address(es) in each message by
4246 alias or forwarding operations. These addresses are flagged with <quote>+D</quote> instead
4247 of just <quote>D</quote>.
4248 </para>
4249 </listitem></varlistentry>
4250 <varlistentry>
4251 <term><option>-bpc</option></term>
4252 <listitem>
4253 <para>
4254 <indexterm role="option">
4255 <primary><option>-bpc</option></primary>
4256 </indexterm>
4257 <indexterm role="concept">
4258 <primary>queue</primary>
4259 <secondary>count of messages on</secondary>
4260 </indexterm>
4261 This option counts the number of messages on the queue, and writes the total
4262 to the standard output. It is restricted to admin users, unless
4263 <option>queue_list_requires_admin</option> is set false.
4264 </para>
4265 </listitem></varlistentry>
4266 <varlistentry>
4267 <term><option>-bpr</option></term>
4268 <listitem>
4269 <para>
4270 <indexterm role="option">
4271 <primary><option>-bpr</option></primary>
4272 </indexterm>
4273 This option operates like <option>-bp</option>, but the output is not sorted into
4274 chronological order of message arrival. This can speed it up when there are
4275 lots of messages on the queue, and is particularly useful if the output is
4276 going to be post-processed in a way that doesn&#x2019;t need the sorting.
4277 </para>
4278 </listitem></varlistentry>
4279 <varlistentry>
4280 <term><option>-bpra</option></term>
4281 <listitem>
4282 <para>
4283 <indexterm role="option">
4284 <primary><option>-bpra</option></primary>
4285 </indexterm>
4286 This option is a combination of <option>-bpr</option> and <option>-bpa</option>.
4287 </para>
4288 </listitem></varlistentry>
4289 <varlistentry>
4290 <term><option>-bpru</option></term>
4291 <listitem>
4292 <para>
4293 <indexterm role="option">
4294 <primary><option>-bpru</option></primary>
4295 </indexterm>
4296 This option is a combination of <option>-bpr</option> and <option>-bpu</option>.
4297 </para>
4298 </listitem></varlistentry>
4299 <varlistentry>
4300 <term><option>-bpu</option></term>
4301 <listitem>
4302 <para>
4303 <indexterm role="option">
4304 <primary><option>-bpu</option></primary>
4305 </indexterm>
4306 This option operates like <option>-bp</option> but shows only undelivered top-level
4307 addresses for each message displayed. Addresses generated by aliasing or
4308 forwarding are not shown, unless the message was deferred after processing by a
4309 router with the <option>one_time</option> option set.
4310 </para>
4311 </listitem></varlistentry>
4312 <varlistentry>
4313 <term><option>-brt</option></term>
4314 <listitem>
4315 <para>
4316 <indexterm role="option">
4317 <primary><option>-brt</option></primary>
4318 </indexterm>
4319 <indexterm role="concept">
4320 <primary>testing</primary>
4321 <secondary>retry configuration</secondary>
4322 </indexterm>
4323 <indexterm role="concept">
4324 <primary>retry</primary>
4325 <secondary>configuration testing</secondary>
4326 </indexterm>
4327 This option is for testing retry rules, and it must be followed by up to three
4328 arguments. It causes Exim to look for a retry rule that matches the values
4329 and to write it to the standard output. For example:
4330 </para>
4331 <literallayout class="monospaced">
4332 exim -brt bach.comp.mus.example
4333 Retry rule: *.comp.mus.example  F,2h,15m; F,4d,30m;
4334 </literallayout>
4335 <para revisionflag="changed">
4336 See chapter <xref linkend="CHAPretry"/> for a description of Exim&#x2019;s retry rules. The first
4337 argument, which is required, can be a complete address in the form
4338 <emphasis>local_part@domain</emphasis>, or it can be just a domain name. If the second argument
4339 contains a dot, it is interpreted as an optional second domain name; if no
4340 retry rule is found for the first argument, the second is tried. This ties in
4341 with Exim&#x2019;s behaviour when looking for retry rules for remote hosts &ndash; if no
4342 rule is found that matches the host, one that matches the mail domain is
4343 sought. Finally, an argument that is the name of a specific delivery error, as
4344 used in setting up retry rules, can be given. For example:
4345 </para>
4346 <literallayout class="monospaced" revisionflag="changed">
4347 exim -brt haydn.comp.mus.example quota_3d
4348 Retry rule: *@haydn.comp.mus.example quota_3d  F,1h,15m
4349 </literallayout>
4350 </listitem></varlistentry>
4351 <varlistentry>
4352 <term><option>-brw</option></term>
4353 <listitem>
4354 <para>
4355 <indexterm role="option">
4356 <primary><option>-brw</option></primary>
4357 </indexterm>
4358 <indexterm role="concept">
4359 <primary>testing</primary>
4360 <secondary>rewriting</secondary>
4361 </indexterm>
4362 <indexterm role="concept">
4363 <primary>rewriting</primary>
4364 <secondary>testing</secondary>
4365 </indexterm>
4366 This option is for testing address rewriting rules, and it must be followed by
4367 a single argument, consisting of either a local part without a domain, or a
4368 complete address with a fully qualified domain. Exim outputs how this address
4369 would be rewritten for each possible place it might appear. See chapter
4370 <xref linkend="CHAPrewrite"/> for further details.
4371 </para>
4372 </listitem></varlistentry>
4373 <varlistentry>
4374 <term><option>-bS</option></term>
4375 <listitem>
4376 <para>
4377 <indexterm role="option">
4378 <primary><option>-bS</option></primary>
4379 </indexterm>
4380 <indexterm role="concept">
4381 <primary>SMTP</primary>
4382 <secondary>batched incoming</secondary>
4383 </indexterm>
4384 <indexterm role="concept">
4385 <primary>batched SMTP input</primary>
4386 </indexterm>
4387 This option is used for batched SMTP input, which is an alternative interface
4388 for non-interactive local message submission. A number of messages can be
4389 submitted in a single run. However, despite its name, this is not really SMTP
4390 input. Exim reads each message&#x2019;s envelope from SMTP commands on the standard
4391 input, but generates no responses. If the caller is trusted, or
4392 <option>untrusted_set_sender</option> is set, the senders in the SMTP MAIL commands are
4393 believed; otherwise the sender is always the caller of Exim.
4394 </para>
4395 <para>
4396 The message itself is read from the standard input, in SMTP format (leading
4397 dots doubled), terminated by a line containing just a single dot. An error is
4398 provoked if the terminating dot is missing. A further message may then follow.
4399 </para>
4400 <para>
4401 As for other local message submissions, the contents of incoming batch SMTP
4402 messages can be checked using the non-SMTP ACL (see chapter <xref linkend="CHAPACL"/>).
4403 Unqualified addresses are automatically qualified using <option>qualify_domain</option> and
4404 <option>qualify_recipient</option>, as appropriate, unless the <option>-bnq</option> option is used.
4405 </para>
4406 <para>
4407 Some other SMTP commands are recognized in the input. HELO and EHLO act
4408 as RSET; VRFY, EXPN, ETRN, and HELP act as NOOP;
4409 QUIT quits, ignoring the rest of the standard input.
4410 </para>
4411 <para>
4412 <indexterm role="concept">
4413 <primary>return code</primary>
4414 <secondary>for <option>-bS</option></secondary>
4415 </indexterm>
4416 If any error is encountered, reports are written to the standard output and
4417 error streams, and Exim gives up immediately. The return code is 0 if no error
4418 was detected; it is 1 if one or more messages were accepted before the error
4419 was detected; otherwise it is 2.
4420 </para>
4421 <para>
4422 More details of input using batched SMTP are given in section
4423 <xref linkend="SECTincomingbatchedSMTP"/>.
4424 </para>
4425 </listitem></varlistentry>
4426 <varlistentry>
4427 <term><option>-bs</option></term>
4428 <listitem>
4429 <para>
4430 <indexterm role="option">
4431 <primary><option>-bs</option></primary>
4432 </indexterm>
4433 <indexterm role="concept">
4434 <primary>SMTP</primary>
4435 <secondary>local input</secondary>
4436 </indexterm>
4437 <indexterm role="concept">
4438 <primary>local SMTP input</primary>
4439 </indexterm>
4440 This option causes Exim to accept one or more messages by reading SMTP commands
4441 on the standard input, and producing SMTP replies on the standard output. SMTP
4442 policy controls, as defined in ACLs (see chapter <xref linkend="CHAPACL"/>) are applied.
4443 Some user agents use this interface as a way of passing locally-generated
4444 messages to the MTA.
4445 </para>
4446 <para>
4447 In
4448 <indexterm role="concept">
4449 <primary>sender</primary>
4450 <secondary>source of</secondary>
4451 </indexterm>
4452 this usage, if the caller of Exim is trusted, or <option>untrusted_set_sender</option> is
4453 set, the senders of messages are taken from the SMTP MAIL commands.
4454 Otherwise the content of these commands is ignored and the sender is set up as
4455 the calling user. Unqualified addresses are automatically qualified using
4456 <option>qualify_domain</option> and <option>qualify_recipient</option>, as appropriate, unless the
4457 <option>-bnq</option> option is used.
4458 </para>
4459 <para>
4460 <indexterm role="concept">
4461 <primary>inetd</primary>
4462 </indexterm>
4463 The
4464 <option>-bs</option> option is also used to run Exim from <emphasis>inetd</emphasis>, as an alternative to
4465 using a listening daemon. Exim can distinguish the two cases by checking
4466 whether the standard input is a TCP/IP socket. When Exim is called from
4467 <emphasis>inetd</emphasis>, the source of the mail is assumed to be remote, and the comments
4468 above concerning senders and qualification do not apply. In this situation,
4469 Exim behaves in exactly the same way as it does when receiving a message via
4470 the listening daemon.
4471 </para>
4472 </listitem></varlistentry>
4473 <varlistentry>
4474 <term><option>-bt</option></term>
4475 <listitem>
4476 <para>
4477 <indexterm role="option">
4478 <primary><option>-bt</option></primary>
4479 </indexterm>
4480 <indexterm role="concept">
4481 <primary>testing</primary>
4482 <secondary>addresses</secondary>
4483 </indexterm>
4484 <indexterm role="concept">
4485 <primary>address</primary>
4486 <secondary>testing</secondary>
4487 </indexterm>
4488 This option runs Exim in address testing mode, in which each argument is taken
4489 as an address to be tested for deliverability. The results are written to the
4490 standard output. If a test fails, and the caller is not an admin user, no
4491 details of the failure are output, because these might contain sensitive
4492 information such as usernames and passwords for database lookups.
4493 </para>
4494 <para>
4495 If no arguments are given, Exim runs in an interactive manner, prompting with a
4496 right angle bracket for addresses to be tested.
4497 </para>
4498 <para>
4499 Unlike the <option>-be</option> test option, you cannot arrange for Exim to use the
4500 <function>readline()</function> function, because it is running as <emphasis>root</emphasis> and there are
4501 security issues.
4502 </para>
4503 <para>
4504 Each address is handled as if it were the recipient address of a message
4505 (compare the <option>-bv</option> option). It is passed to the routers and the result is
4506 written to the standard output. However, any router that has
4507 <option>no_address_test</option> set is bypassed. This can make <option>-bt</option> easier to use for
4508 genuine routing tests if your first router passes everything to a scanner
4509 program.
4510 </para>
4511 <para>
4512 The
4513 <indexterm role="concept">
4514 <primary>return code</primary>
4515 <secondary>for <option>-bt</option></secondary>
4516 </indexterm>
4517 return code is 2 if any address failed outright; it is 1 if no address
4518 failed outright but at least one could not be resolved for some reason. Return
4519 code 0 is given only when all addresses succeed.
4520 </para>
4521 <para>
4522 <emphasis role="bold">Warning</emphasis>: <option>-bt</option> can only do relatively simple testing. If any of the
4523 routers in the configuration makes any tests on the sender address of a
4524 message,
4525 <indexterm role="concept">
4526 <primary><option>-f</option> option</primary>
4527 <secondary>for address testing</secondary>
4528 </indexterm>
4529 you can use the <option>-f</option> option to set an appropriate sender when running
4530 <option>-bt</option> tests. Without it, the sender is assumed to be the calling user at the
4531 default qualifying domain. However, if you have set up (for example) routers
4532 whose behaviour depends on the contents of an incoming message, you cannot test
4533 those conditions using <option>-bt</option>. The <option>-N</option> option provides a possible way of
4534 doing such tests.
4535 </para>
4536 </listitem></varlistentry>
4537 <varlistentry>
4538 <term><option>-bV</option></term>
4539 <listitem>
4540 <para>
4541 <indexterm role="option">
4542 <primary><option>-bV</option></primary>
4543 </indexterm>
4544 <indexterm role="concept">
4545 <primary>version number of Exim</primary>
4546 <secondary>verifying</secondary>
4547 </indexterm>
4548 This option causes Exim to write the current version number, compilation
4549 number, and compilation date of the <emphasis>exim</emphasis> binary to the standard output.
4550 It also lists the DBM library this is being used, the optional modules (such as
4551 specific lookup types), the drivers that are included in the binary, and the
4552 name of the run time configuration file that is in use.
4553 </para>
4554 <para>
4555 As part of its operation, <option>-bV</option> causes Exim to read and syntax check its
4556 configuration file. However, this is a static check only. It cannot check
4557 values that are to be expanded. For example, although a misspelt ACL verb is
4558 detected, an error in the verb&#x2019;s arguments is not. You cannot rely on <option>-bV</option>
4559 alone to discover (for example) all the typos in the configuration; some
4560 realistic testing is needed. The <option>-bh</option> and <option>-N</option> options provide more
4561 dynamic testing facilities.
4562 </para>
4563 </listitem></varlistentry>
4564 <varlistentry>
4565 <term><option>-bv</option></term>
4566 <listitem>
4567 <para>
4568 <indexterm role="option">
4569 <primary><option>-bv</option></primary>
4570 </indexterm>
4571 <indexterm role="concept">
4572 <primary>verifying address</primary>
4573 <secondary>using <option>-bv</option></secondary>
4574 </indexterm>
4575 <indexterm role="concept">
4576 <primary>address</primary>
4577 <secondary>verification</secondary>
4578 </indexterm>
4579 This option runs Exim in address verification mode, in which each argument is
4580 taken as an address to be verified. During normal operation, verification
4581 happens mostly as a consequence processing a <option>verify</option> condition in an ACL
4582 (see chapter <xref linkend="CHAPACL"/>). If you want to test an entire ACL, see the <option>-bh</option>
4583 option.
4584 </para>
4585 <para>
4586 If verification fails, and the caller is not an admin user, no details of the
4587 failure are output, because these might contain sensitive information such as
4588 usernames and passwords for database lookups.
4589 </para>
4590 <para>
4591 If no arguments are given, Exim runs in an interactive manner, prompting with a
4592 right angle bracket for addresses to be verified.
4593 </para>
4594 <para>
4595 Unlike the <option>-be</option> test option, you cannot arrange for Exim to use the
4596 <function>readline()</function> function, because it is running as <emphasis>exim</emphasis> and there are
4597 security issues.
4598 </para>
4599 <para>
4600 Verification differs from address testing (the <option>-bt</option> option) in that routers
4601 that have <option>no_verify</option> set are skipped, and if the address is accepted by a
4602 router that has <option>fail_verify</option> set, verification fails. The address is
4603 verified as a recipient if <option>-bv</option> is used; to test verification for a sender
4604 address, <option>-bvs</option> should be used.
4605 </para>
4606 <para>
4607 If the <option>-v</option> option is not set, the output consists of a single line for each
4608 address, stating whether it was verified or not, and giving a reason in the
4609 latter case. Otherwise, more details are given of how the address has been
4610 handled, and in the case of address redirection, all the generated addresses
4611 are also considered. Without <option>-v</option>, generating more than one address by
4612 redirection causes verification to end successfully.
4613 </para>
4614 <para>
4615 The
4616 <indexterm role="concept">
4617 <primary>return code</primary>
4618 <secondary>for <option>-bv</option></secondary>
4619 </indexterm>
4620 return code is 2 if any address failed outright; it is 1 if no address
4621 failed outright but at least one could not be resolved for some reason. Return
4622 code 0 is given only when all addresses succeed.
4623 </para>
4624 <para>
4625 If any of the routers in the configuration makes any tests on the sender
4626 address of a message, you should use the <option>-f</option> option to set an appropriate
4627 sender when running <option>-bv</option> tests. Without it, the sender is assumed to be the
4628 calling user at the default qualifying domain.
4629 </para>
4630 </listitem></varlistentry>
4631 <varlistentry>
4632 <term><option>-bvs</option></term>
4633 <listitem>
4634 <para>
4635 <indexterm role="option">
4636 <primary><option>-bvs</option></primary>
4637 </indexterm>
4638 This option acts like <option>-bv</option>, but verifies the address as a sender rather
4639 than a recipient address. This affects any rewriting and qualification that
4640 might happen.
4641 </para>
4642 </listitem></varlistentry>
4643 <varlistentry>
4644 <term><option>-C</option>&nbsp;&lt;<emphasis>filelist</emphasis>&gt;</term>
4645 <listitem>
4646 <para>
4647 <indexterm role="option">
4648 <primary><option>-C</option></primary>
4649 </indexterm>
4650 <indexterm role="concept">
4651 <primary>configuration file</primary>
4652 <secondary>alternate</secondary>
4653 </indexterm>
4654 <indexterm role="concept">
4655 <primary>CONFIGURE_FILE</primary>
4656 </indexterm>
4657 <indexterm role="concept">
4658 <primary>alternate configuration file</primary>
4659 </indexterm>
4660 This option causes Exim to find the run time configuration file from the given
4661 list instead of from the list specified by the CONFIGURE_FILE
4662 compile-time setting. Usually, the list will consist of just a single file
4663 name, but it can be a colon-separated list of names. In this case, the first
4664 file that exists is used. Failure to open an existing file stops Exim from
4665 proceeding any further along the list, and an error is generated.
4666 </para>
4667 <para>
4668 When this option is used by a caller other than root or the Exim user, and the
4669 list is different from the compiled-in list, Exim gives up its root privilege
4670 immediately, and runs with the real and effective uid and gid set to those of
4671 the caller. However, if ALT_CONFIG_ROOT_ONLY is defined in
4672 <filename>Local/Makefile</filename>, root privilege is retained for <option>-C</option> only if the caller of
4673 Exim is root.
4674 </para>
4675 <para>
4676 That is, the Exim user is no longer privileged in this regard. This build-time
4677 option is not set by default in the Exim source distribution tarbundle.
4678 However, if you are using a <quote>packaged</quote> version of Exim (source or binary),
4679 the packagers might have enabled it.
4680 </para>
4681 <para>
4682 Setting ALT_CONFIG_ROOT_ONLY locks out the possibility of testing a
4683 configuration using <option>-C</option> right through message reception and delivery, even
4684 if the caller is root. The reception works, but by that time, Exim is running
4685 as the Exim user, so when it re-executes to regain privilege for the delivery,
4686 the use of <option>-C</option> causes privilege to be lost. However, root can test reception
4687 and delivery using two separate commands (one to put a message on the queue,
4688 using <option>-odq</option>, and another to do the delivery, using <option>-M</option>).
4689 </para>
4690 <para>
4691 If ALT_CONFIG_PREFIX is defined <filename>in Local/Makefile</filename>, it specifies a
4692 prefix string with which any file named in a <option>-C</option> command line option
4693 must start. In addition, the file name must not contain the sequence <literal>/../</literal>.
4694 However, if the value of the <option>-C</option> option is identical to the value of
4695 CONFIGURE_FILE in <filename>Local/Makefile</filename>, Exim ignores <option>-C</option> and proceeds as
4696 usual. There is no default setting for ALT_CONFIG_PREFIX; when it is
4697 unset, any file name can be used with <option>-C</option>.
4698 </para>
4699 <para>
4700 ALT_CONFIG_PREFIX can be used to confine alternative configuration files
4701 to a directory to which only root has access. This prevents someone who has
4702 broken into the Exim account from running a privileged Exim with an arbitrary
4703 configuration file.
4704 </para>
4705 <para>
4706 The <option>-C</option> facility is useful for ensuring that configuration files are
4707 syntactically correct, but cannot be used for test deliveries, unless the
4708 caller is privileged, or unless it is an exotic configuration that does not
4709 require privilege. No check is made on the owner or group of the files
4710 specified by this option.
4711 </para>
4712 </listitem></varlistentry>
4713 <varlistentry>
4714 <term><option>-D</option>&lt;<emphasis>macro</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt;</term>
4715 <listitem>
4716 <para>
4717 <indexterm role="option">
4718 <primary><option>-D</option></primary>
4719 </indexterm>
4720 <indexterm role="concept">
4721 <primary>macro</primary>
4722 <secondary>setting on command line</secondary>
4723 </indexterm>
4724 This option can be used to override macro definitions in the configuration file
4725 (see section <xref linkend="SECTmacrodefs"/>). However, like <option>-C</option>, if it is used by an
4726 unprivileged caller, it causes Exim to give up its root privilege.
4727 If DISABLE_D_OPTION is defined in <filename>Local/Makefile</filename>, the use of <option>-D</option> is
4728 completely disabled, and its use causes an immediate error exit.
4729 </para>
4730 <para>
4731 The entire option (including equals sign if present) must all be within one
4732 command line item. <option>-D</option> can be used to set the value of a macro to the empty
4733 string, in which case the equals sign is optional. These two commands are
4734 synonymous:
4735 </para>
4736 <literallayout class="monospaced">
4737 exim -DABC  ...
4738 exim -DABC= ...
4739 </literallayout>
4740 <para>
4741 To include spaces in a macro definition item, quotes must be used. If you use
4742 quotes, spaces are permitted around the macro name and the equals sign. For
4743 example:
4744 </para>
4745 <literallayout class="monospaced">
4746 exim '-D ABC = something' ...
4747 </literallayout>
4748 <para>
4749 <option>-D</option> may be repeated up to 10 times on a command line.
4750 </para>
4751 </listitem></varlistentry>
4752 <varlistentry>
4753 <term><option>-d</option>&lt;<emphasis>debug&nbsp;options</emphasis>&gt;</term>
4754 <listitem>
4755 <para>
4756 <indexterm role="option">
4757 <primary><option>-d</option></primary>
4758 </indexterm>
4759 <indexterm role="concept">
4760 <primary>debugging</primary>
4761 <secondary>list of selectors</secondary>
4762 </indexterm>
4763 <indexterm role="concept">
4764 <primary>debugging</primary>
4765 <secondary><option>-d</option> option</secondary>
4766 </indexterm>
4767 This option causes debugging information to be written to the standard
4768 error stream. It is restricted to admin users because debugging output may show
4769 database queries that contain password information. Also, the details of users&#x2019;
4770 filter files should be protected. When <option>-d</option> is used, <option>-v</option> is assumed. If
4771 <option>-d</option> is given on its own, a lot of standard debugging data is output. This
4772 can be reduced, or increased to include some more rarely needed information, by
4773 directly following <option>-d</option> with a string made up of names preceded by plus or
4774 minus characters. These add or remove sets of debugging data, respectively. For
4775 example, <option>-d+filter</option> adds filter debugging, whereas <option>-d-all+filter</option> selects
4776 only filter debugging. Note that no spaces are allowed in the debug setting.
4777 The available debugging categories are:
4778 </para>
4779 <literallayout>
4780 <literal>acl            </literal> ACL interpretation
4781 <literal>auth           </literal> authenticators
4782 <literal>deliver        </literal> general delivery logic
4783 <literal>dns            </literal> DNS lookups (see also resolver)
4784 <literal>dnsbl          </literal> DNS black list (aka RBL) code
4785 <literal>exec           </literal> arguments for <function>execv()</function> calls
4786 <literal>expand         </literal> detailed debugging for string expansions
4787 <literal>filter         </literal> filter handling
4788 <literal>hints_lookup   </literal> hints data lookups
4789 <literal>host_lookup    </literal> all types of name-to-IP address handling
4790 <literal>ident          </literal> ident lookup
4791 <literal>interface      </literal> lists of local interfaces
4792 <literal>lists          </literal> matching things in lists
4793 <literal>load           </literal> system load checks
4794 <literal>local_scan     </literal> can be used by <function>local_scan()</function> (see chapter <xref linkend="CHAPlocalscan"/>)
4795 <literal>lookup         </literal> general lookup code and all lookups
4796 <literal>memory         </literal> memory handling
4797 <literal>pid            </literal> add pid to debug output lines
4798 <literal>process_info   </literal> setting info for the process log
4799 <literal>queue_run      </literal> queue runs
4800 <literal>receive        </literal> general message reception logic
4801 <literal>resolver       </literal> turn on the DNS resolver&#x2019;s debugging output
4802 <literal>retry          </literal> retry handling
4803 <literal>rewrite        </literal> address rewriting
4804 <literal>route          </literal> address routing
4805 <literal>timestamp      </literal> add timestamp to debug output lines
4806 <literal>tls            </literal> TLS logic
4807 <literal>transport      </literal> transports
4808 <literal>uid            </literal> changes of uid/gid and looking up uid/gid
4809 <literal>verify         </literal> address verification logic
4810 <literal>all            </literal> almost all of the above (see below), and also <option>-v</option>
4811 </literallayout>
4812 <para>
4813 The <literal>all</literal> option excludes <literal>memory</literal> when used as <literal>+all</literal>, but includes it
4814 for <literal>-all</literal>. The reason for this is that <literal>+all</literal> is something that people
4815 tend to use when generating debug output for Exim maintainers. If <literal>+memory</literal>
4816 is included, an awful lot of output that is very rarely of interest is
4817 generated, so it now has to be explicitly requested. However, <literal>-all</literal> does
4818 turn everything off.
4819 </para>
4820 <para>
4821 <indexterm role="concept">
4822 <primary>resolver</primary>
4823 <secondary>debugging output</secondary>
4824 </indexterm>
4825 <indexterm role="concept">
4826 <primary>DNS resolver</primary>
4827 <secondary>debugging output</secondary>
4828 </indexterm>
4829 The <literal>resolver</literal> option produces output only if the DNS resolver was compiled
4830 with DEBUG enabled. This is not the case in some operating systems. Also,
4831 unfortunately, debugging output from the DNS resolver is written to stdout
4832 rather than stderr.
4833 </para>
4834 <para>
4835 The default (<option>-d</option> with no argument) omits <literal>expand</literal>, <literal>filter</literal>,
4836 <literal>interface</literal>, <literal>load</literal>, <literal>memory</literal>, <literal>pid</literal>, <literal>resolver</literal>, and <literal>timestamp</literal>.
4837 However, the <literal>pid</literal> selector is forced when debugging is turned on for a
4838 daemon, which then passes it on to any re-executed Exims. Exim also
4839 automatically adds the pid to debug lines when several remote deliveries are
4840 run in parallel.
4841 </para>
4842 <para>
4843 The <literal>timestamp</literal> selector causes the current time to be inserted at the start
4844 of all debug output lines. This can be useful when trying to track down delays
4845 in processing.
4846 </para>
4847 <para>
4848 If the <option>debug_print</option> option is set in any driver, it produces output whenever
4849 any debugging is selected, or if <option>-v</option> is used.
4850 </para>
4851 </listitem></varlistentry>
4852 <varlistentry>
4853 <term><option>-dd</option>&lt;<emphasis>debug&nbsp;options</emphasis>&gt;</term>
4854 <listitem>
4855 <para>
4856 <indexterm role="option">
4857 <primary><option>-dd</option></primary>
4858 </indexterm>
4859 This option behaves exactly like <option>-d</option> except when used on a command that
4860 starts a daemon process. In that case, debugging is turned off for the
4861 subprocesses that the daemon creates. Thus, it is useful for monitoring the
4862 behaviour of the daemon without creating as much output as full debugging does.
4863 </para>
4864 </listitem></varlistentry>
4865 <varlistentry>
4866 <term><option>-dropcr</option></term>
4867 <listitem>
4868 <para>
4869 <indexterm role="option">
4870 <primary><option>-dropcr</option></primary>
4871 </indexterm>
4872 This is an obsolete option that is now a no-op. It used to affect the way Exim
4873 handled CR and LF characters in incoming messages. What happens now is
4874 described in section <xref linkend="SECTlineendings"/>.
4875 </para>
4876 </listitem></varlistentry>
4877 <varlistentry>
4878 <term><option>-E</option></term>
4879 <listitem>
4880 <para>
4881 <indexterm role="option">
4882 <primary><option>-E</option></primary>
4883 </indexterm>
4884 <indexterm role="concept">
4885 <primary>bounce message</primary>
4886 <secondary>generating</secondary>
4887 </indexterm>
4888 This option specifies that an incoming message is a locally-generated delivery
4889 failure report. It is used internally by Exim when handling delivery failures
4890 and is not intended for external use. Its only effect is to stop Exim
4891 generating certain messages to the postmaster, as otherwise message cascades
4892 could occur in some situations. As part of the same option, a message id may
4893 follow the characters <option>-E</option>. If it does, the log entry for the receipt of the
4894 new message contains the id, following <quote>R=</quote>, as a cross-reference.
4895 </para>
4896 </listitem></varlistentry>
4897 <varlistentry>
4898 <term><option>-e</option><emphasis>x</emphasis></term>
4899 <listitem>
4900 <para>
4901 <indexterm role="option">
4902 <primary><option>-e</option><emphasis>x</emphasis></primary>
4903 </indexterm>
4904 There are a number of Sendmail options starting with <option>-oe</option> which seem to be
4905 called by various programs without the leading <option>o</option> in the option. For
4906 example, the <option>vacation</option> program uses <option>-eq</option>. Exim treats all options of the
4907 form <option>-e</option><emphasis>x</emphasis> as synonymous with the corresponding <option>-oe</option><emphasis>x</emphasis> options.
4908 </para>
4909 </listitem></varlistentry>
4910 <varlistentry>
4911 <term><option>-F</option>&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
4912 <listitem>
4913 <para>
4914 <indexterm role="option">
4915 <primary><option>-F</option></primary>
4916 </indexterm>
4917 <indexterm role="concept">
4918 <primary>sender</primary>
4919 <secondary>name</secondary>
4920 </indexterm>
4921 <indexterm role="concept">
4922 <primary>name</primary>
4923 <secondary>of sender</secondary>
4924 </indexterm>
4925 This option sets the sender&#x2019;s full name for use when a locally-generated
4926 message is being accepted. In the absence of this option, the user&#x2019;s <emphasis>gecos</emphasis>
4927 entry from the password data is used. As users are generally permitted to alter
4928 their <emphasis>gecos</emphasis> entries, no security considerations are involved. White space
4929 between <option>-F</option> and the &lt;<emphasis>string</emphasis>&gt; is optional.
4930 </para>
4931 </listitem></varlistentry>
4932 <varlistentry>
4933 <term><option>-f</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;</term>
4934 <listitem>
4935 <para>
4936 <indexterm role="option">
4937 <primary><option>-f</option></primary>
4938 </indexterm>
4939 <indexterm role="concept">
4940 <primary>sender</primary>
4941 <secondary>address</secondary>
4942 </indexterm>
4943 <indexterm role="concept">
4944 <primary>address</primary>
4945 <secondary>sender</secondary>
4946 </indexterm>
4947 <indexterm role="concept">
4948 <primary>trusted user</primary>
4949 </indexterm>
4950 <indexterm role="concept">
4951 <primary>envelope sender</primary>
4952 </indexterm>
4953 <indexterm role="concept">
4954 <primary>user</primary>
4955 <secondary>trusted</secondary>
4956 </indexterm>
4957 This option sets the address of the envelope sender of a locally-generated
4958 message (also known as the return path). The option can normally be used only
4959 by a trusted user, but <option>untrusted_set_sender</option> can be set to allow untrusted
4960 users to use it.
4961 </para>
4962 <para>
4963 Processes running as root or the Exim user are always trusted. Other
4964 trusted users are defined by the <option>trusted_users</option> or <option>trusted_groups</option>
4965 options. In the absence of <option>-f</option>, or if the caller is not trusted, the sender
4966 of a local message is set to the caller&#x2019;s login name at the default qualify
4967 domain.
4968 </para>
4969 <para>
4970 There is one exception to the restriction on the use of <option>-f</option>: an empty sender
4971 can be specified by any user, trusted or not, to create a message that can
4972 never provoke a bounce. An empty sender can be specified either as an empty
4973 string, or as a pair of angle brackets with nothing between them, as in these
4974 examples of shell commands:
4975 </para>
4976 <literallayout class="monospaced">
4977 exim -f '&lt;&gt;' user@domain
4978 exim -f "" user@domain
4979 </literallayout>
4980 <para>
4981 In addition, the use of <option>-f</option> is not restricted when testing a filter file
4982 with <option>-bf</option> or when testing or verifying addresses using the <option>-bt</option> or
4983 <option>-bv</option> options.
4984 </para>
4985 <para>
4986 Allowing untrusted users to change the sender address does not of itself make
4987 it possible to send anonymous mail. Exim still checks that the <emphasis>From:</emphasis> header
4988 refers to the local user, and if it does not, it adds a <emphasis>Sender:</emphasis> header,
4989 though this can be overridden by setting <option>no_local_from_check</option>.
4990 </para>
4991 <para>
4992 White
4993 <indexterm role="concept">
4994 <primary><quote>From</quote> line</primary>
4995 </indexterm>
4996 space between <option>-f</option> and the &lt;<emphasis>address</emphasis>&gt; is optional (that is, they can be
4997 given as two arguments or one combined argument). The sender of a
4998 locally-generated message can also be set (when permitted) by an initial
4999 <quote>From&nbsp;</quote> line in the message &ndash; see the description of <option>-bm</option> above &ndash; but
5000 if <option>-f</option> is also present, it overrides <quote>From&nbsp;</quote>.
5001 </para>
5002 </listitem></varlistentry>
5003 <varlistentry>
5004 <term><option>-G</option></term>
5005 <listitem>
5006 <para>
5007 <indexterm role="option">
5008 <primary><option>-G</option></primary>
5009 </indexterm>
5010 <indexterm role="concept">
5011 <primary>Sendmail compatibility</primary>
5012 <secondary><option>-G</option> option ignored</secondary>
5013 </indexterm>
5014 This is a Sendmail option which is ignored by Exim.
5015 </para>
5016 </listitem></varlistentry>
5017 <varlistentry>
5018 <term><option>-h</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;</term>
5019 <listitem>
5020 <para>
5021 <indexterm role="option">
5022 <primary><option>-h</option></primary>
5023 </indexterm>
5024 <indexterm role="concept">
5025 <primary>Sendmail compatibility</primary>
5026 <secondary><option>-h</option> option ignored</secondary>
5027 </indexterm>
5028 This option is accepted for compatibility with Sendmail, but has no effect. (In
5029 Sendmail it overrides the <quote>hop count</quote> obtained by counting <emphasis>Received:</emphasis>
5030 headers.)
5031 </para>
5032 </listitem></varlistentry>
5033 <varlistentry>
5034 <term><option>-i</option></term>
5035 <listitem>
5036 <para>
5037 <indexterm role="option">
5038 <primary><option>-i</option></primary>
5039 </indexterm>
5040 <indexterm role="concept">
5041 <primary>Solaris</primary>
5042 <secondary><emphasis>mail</emphasis> command</secondary>
5043 </indexterm>
5044 <indexterm role="concept">
5045 <primary>dot in incoming</primary>
5046 <secondary>non-SMTP message</secondary>
5047 </indexterm>
5048 This option, which has the same effect as <option>-oi</option>, specifies that a dot on a
5049 line by itself should not terminate an incoming, non-SMTP message. I can find
5050 no documentation for this option in Solaris 2.4 Sendmail, but the <emphasis>mailx</emphasis>
5051 command in Solaris 2.4 uses it. See also <option>-ti</option>.
5052 </para>
5053 </listitem></varlistentry>
5054 <varlistentry>
5055 <term><option>-M</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5056 <listitem>
5057 <para>
5058 <indexterm role="option">
5059 <primary><option>-M</option></primary>
5060 </indexterm>
5061 <indexterm role="concept">
5062 <primary>forcing delivery</primary>
5063 </indexterm>
5064 <indexterm role="concept">
5065 <primary>delivery</primary>
5066 <secondary>forcing attempt</secondary>
5067 </indexterm>
5068 <indexterm role="concept">
5069 <primary>frozen messages</primary>
5070 <secondary>forcing delivery</secondary>
5071 </indexterm>
5072 This option requests Exim to run a delivery attempt on each message in turn. If
5073 any of the messages are frozen, they are automatically thawed before the
5074 delivery attempt. The settings of <option>queue_domains</option>, <option>queue_smtp_domains</option>,
5075 and <option>hold_domains</option> are ignored.
5076 </para>
5077 <para>
5078 Retry
5079 <indexterm role="concept">
5080 <primary>hints database</primary>
5081 <secondary>overriding retry hints</secondary>
5082 </indexterm>
5083 hints for any of the addresses are overridden &ndash; Exim tries to deliver even if
5084 the normal retry time has not yet been reached. This option requires the caller
5085 to be an admin user. However, there is an option called <option>prod_requires_admin</option>
5086 which can be set false to relax this restriction (and also the same requirement
5087 for the <option>-q</option>, <option>-R</option>, and <option>-S</option> options).
5088 </para>
5089 <para>
5090 The deliveries happen synchronously, that is, the original Exim process does
5091 not terminate until all the delivery attempts have finished. No output is
5092 produced unless there is a serious error. If you want to see what is happening,
5093 use the <option>-v</option> option as well, or inspect Exim&#x2019;s main log.
5094 </para>
5095 </listitem></varlistentry>
5096 <varlistentry>
5097 <term><option>-Mar</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>address</emphasis>&gt;&nbsp;&lt;<emphasis>address</emphasis>&gt;&nbsp;...</term>
5098 <listitem>
5099 <para>
5100 <indexterm role="option">
5101 <primary><option>-Mar</option></primary>
5102 </indexterm>
5103 <indexterm role="concept">
5104 <primary>message</primary>
5105 <secondary>adding recipients</secondary>
5106 </indexterm>
5107 <indexterm role="concept">
5108 <primary>recipient</primary>
5109 <secondary>adding</secondary>
5110 </indexterm>
5111 This option requests Exim to add the addresses to the list of recipients of the
5112 message (<quote>ar</quote> for <quote>add recipients</quote>). The first argument must be a message
5113 id, and the remaining ones must be email addresses. However, if the message is
5114 active (in the middle of a delivery attempt), it is not altered. This option
5115 can be used only by an admin user.
5116 </para>
5117 </listitem></varlistentry>
5118 <varlistentry>
5119 <term><option>-MC</option>&nbsp;&lt;<emphasis>transport</emphasis>&gt;&nbsp;&lt;<emphasis>hostname</emphasis>&gt;&nbsp;&lt;<emphasis>sequence&nbsp;number</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
5120 <listitem>
5121 <para>
5122 <indexterm role="option">
5123 <primary><option>-MC</option></primary>
5124 </indexterm>
5125 <indexterm role="concept">
5126 <primary>SMTP</primary>
5127 <secondary>passed connection</secondary>
5128 </indexterm>
5129 <indexterm role="concept">
5130 <primary>SMTP</primary>
5131 <secondary>multiple deliveries</secondary>
5132 </indexterm>
5133 <indexterm role="concept">
5134 <primary>multiple SMTP deliveries</primary>
5135 </indexterm>
5136 This option is not intended for use by external callers. It is used internally
5137 by Exim to invoke another instance of itself to deliver a waiting message using
5138 an existing SMTP connection, which is passed as the standard input. Details are
5139 given in chapter <xref linkend="CHAPSMTP"/>. This must be the final option, and the caller
5140 must be root or the Exim user in order to use it.
5141 </para>
5142 </listitem></varlistentry>
5143 <varlistentry>
5144 <term><option>-MCA</option></term>
5145 <listitem>
5146 <para>
5147 <indexterm role="option">
5148 <primary><option>-MCA</option></primary>
5149 </indexterm>
5150 This option is not intended for use by external callers. It is used internally
5151 by Exim in conjunction with the <option>-MC</option> option. It signifies that the
5152 connection to the remote host has been authenticated.
5153 </para>
5154 </listitem></varlistentry>
5155 <varlistentry>
5156 <term><option>-MCP</option></term>
5157 <listitem>
5158 <para>
5159 <indexterm role="option">
5160 <primary><option>-MCP</option></primary>
5161 </indexterm>
5162 This option is not intended for use by external callers. It is used internally
5163 by Exim in conjunction with the <option>-MC</option> option. It signifies that the server to
5164 which Exim is connected supports pipelining.
5165 </para>
5166 </listitem></varlistentry>
5167 <varlistentry>
5168 <term><option>-MCQ</option>&nbsp;&lt;<emphasis>process&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>pipe&nbsp;fd</emphasis>&gt;</term>
5169 <listitem>
5170 <para>
5171 <indexterm role="option">
5172 <primary><option>-MCQ</option></primary>
5173 </indexterm>
5174 This option is not intended for use by external callers. It is used internally
5175 by Exim in conjunction with the <option>-MC</option> option when the original delivery was
5176 started by a queue runner. It passes on the process id of the queue runner,
5177 together with the file descriptor number of an open pipe. Closure of the pipe
5178 signals the final completion of the sequence of processes that are passing
5179 messages through the same SMTP connection.
5180 </para>
5181 </listitem></varlistentry>
5182 <varlistentry>
5183 <term><option>-MCS</option></term>
5184 <listitem>
5185 <para>
5186 <indexterm role="option">
5187 <primary><option>-MCS</option></primary>
5188 </indexterm>
5189 This option is not intended for use by external callers. It is used internally
5190 by Exim in conjunction with the <option>-MC</option> option, and passes on the fact that the
5191 SMTP SIZE option should be used on messages delivered down the existing
5192 connection.
5193 </para>
5194 </listitem></varlistentry>
5195 <varlistentry>
5196 <term><option>-MCT</option></term>
5197 <listitem>
5198 <para>
5199 <indexterm role="option">
5200 <primary><option>-MCT</option></primary>
5201 </indexterm>
5202 This option is not intended for use by external callers. It is used internally
5203 by Exim in conjunction with the <option>-MC</option> option, and passes on the fact that the
5204 host to which Exim is connected supports TLS encryption.
5205 </para>
5206 </listitem></varlistentry>
5207 <varlistentry>
5208 <term><option>-Mc</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5209 <listitem>
5210 <para>
5211 <indexterm role="option">
5212 <primary><option>-Mc</option></primary>
5213 </indexterm>
5214 <indexterm role="concept">
5215 <primary>hints database</primary>
5216 <secondary>not overridden by <option>-Mc</option></secondary>
5217 </indexterm>
5218 <indexterm role="concept">
5219 <primary>delivery</primary>
5220 <secondary>manually started &ndash; not forced</secondary>
5221 </indexterm>
5222 This option requests Exim to run a delivery attempt on each message in turn,
5223 but unlike the <option>-M</option> option, it does check for retry hints, and respects any
5224 that are found. This option is not very useful to external callers. It is
5225 provided mainly for internal use by Exim when it needs to re-invoke itself in
5226 order to regain root privilege for a delivery (see chapter <xref linkend="CHAPsecurity"/>).
5227 However, <option>-Mc</option> can be useful when testing, in order to run a delivery that
5228 respects retry times and other options such as <option>hold_domains</option> that are
5229 overridden when <option>-M</option> is used. Such a delivery does not count as a queue run.
5230 If you want to run a specific delivery as if in a queue run, you should use
5231 <option>-q</option> with a message id argument. A distinction between queue run deliveries
5232 and other deliveries is made in one or two places.
5233 </para>
5234 </listitem></varlistentry>
5235 <varlistentry>
5236 <term><option>-Mes</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>address</emphasis>&gt;</term>
5237 <listitem>
5238 <para>
5239 <indexterm role="option">
5240 <primary><option>-Mes</option></primary>
5241 </indexterm>
5242 <indexterm role="concept">
5243 <primary>message</primary>
5244 <secondary>changing sender</secondary>
5245 </indexterm>
5246 <indexterm role="concept">
5247 <primary>sender</primary>
5248 <secondary>changing</secondary>
5249 </indexterm>
5250 This option requests Exim to change the sender address in the message to the
5251 given address, which must be a fully qualified address or <quote>&lt;&gt;</quote> (<quote>es</quote> for
5252 <quote>edit sender</quote>). There must be exactly two arguments. The first argument must
5253 be a message id, and the second one an email address. However, if the message
5254 is active (in the middle of a delivery attempt), its status is not altered.
5255 This option can be used only by an admin user.
5256 </para>
5257 </listitem></varlistentry>
5258 <varlistentry>
5259 <term><option>-Mf</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5260 <listitem>
5261 <para>
5262 <indexterm role="option">
5263 <primary><option>-Mf</option></primary>
5264 </indexterm>
5265 <indexterm role="concept">
5266 <primary>freezing messages</primary>
5267 </indexterm>
5268 <indexterm role="concept">
5269 <primary>message</primary>
5270 <secondary>manually freezing</secondary>
5271 </indexterm>
5272 This option requests Exim to mark each listed message as <quote>frozen</quote>. This
5273 prevents any delivery attempts taking place until the message is <quote>thawed</quote>,
5274 either manually or as a result of the <option>auto_thaw</option> configuration option.
5275 However, if any of the messages are active (in the middle of a delivery
5276 attempt), their status is not altered. This option can be used only by an admin
5277 user.
5278 </para>
5279 </listitem></varlistentry>
5280 <varlistentry>
5281 <term><option>-Mg</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5282 <listitem>
5283 <para>
5284 <indexterm role="option">
5285 <primary><option>-Mg</option></primary>
5286 </indexterm>
5287 <indexterm role="concept">
5288 <primary>giving up on messages</primary>
5289 </indexterm>
5290 <indexterm role="concept">
5291 <primary>message</primary>
5292 <secondary>abandoning delivery attempts</secondary>
5293 </indexterm>
5294 <indexterm role="concept">
5295 <primary>delivery</primary>
5296 <secondary>abandoning further attempts</secondary>
5297 </indexterm>
5298 This option requests Exim to give up trying to deliver the listed messages,
5299 including any that are frozen. However, if any of the messages are active,
5300 their status is not altered. For non-bounce messages, a delivery error message
5301 is sent to the sender, containing the text <quote>cancelled by administrator</quote>.
5302 Bounce messages are just discarded. This option can be used only by an admin
5303 user.
5304 </para>
5305 </listitem></varlistentry>
5306 <varlistentry>
5307 <term><option>-Mmad</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5308 <listitem>
5309 <para>
5310 <indexterm role="option">
5311 <primary><option>-Mmad</option></primary>
5312 </indexterm>
5313 <indexterm role="concept">
5314 <primary>delivery</primary>
5315 <secondary>cancelling all</secondary>
5316 </indexterm>
5317 This option requests Exim to mark all the recipient addresses in the messages
5318 as already delivered (<quote>mad</quote> for <quote>mark all delivered</quote>). However, if any
5319 message is active (in the middle of a delivery attempt), its status is not
5320 altered. This option can be used only by an admin user.
5321 </para>
5322 </listitem></varlistentry>
5323 <varlistentry>
5324 <term><option>-Mmd</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>address</emphasis>&gt;&nbsp;&lt;<emphasis>address</emphasis>&gt;&nbsp;...</term>
5325 <listitem>
5326 <para>
5327 <indexterm role="option">
5328 <primary><option>-Mmd</option></primary>
5329 </indexterm>
5330 <indexterm role="concept">
5331 <primary>delivery</primary>
5332 <secondary>cancelling by address</secondary>
5333 </indexterm>
5334 <indexterm role="concept">
5335 <primary>recipient</primary>
5336 <secondary>removing</secondary>
5337 </indexterm>
5338 <indexterm role="concept">
5339 <primary>removing recipients</primary>
5340 </indexterm>
5341 This option requests Exim to mark the given addresses as already delivered
5342 (<quote>md</quote> for <quote>mark delivered</quote>). The first argument must be a message id, and
5343 the remaining ones must be email addresses. These are matched to recipient
5344 addresses in the message in a case-sensitive manner. If the message is active
5345 (in the middle of a delivery attempt), its status is not altered. This option
5346 can be used only by an admin user.
5347 </para>
5348 </listitem></varlistentry>
5349 <varlistentry>
5350 <term><option>-Mrm</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5351 <listitem>
5352 <para>
5353 <indexterm role="option">
5354 <primary><option>-Mrm</option></primary>
5355 </indexterm>
5356 <indexterm role="concept">
5357 <primary>removing messages</primary>
5358 </indexterm>
5359 <indexterm role="concept">
5360 <primary>abandoning mail</primary>
5361 </indexterm>
5362 <indexterm role="concept">
5363 <primary>message</primary>
5364 <secondary>manually discarding</secondary>
5365 </indexterm>
5366 This option requests Exim to remove the given messages from the queue. No
5367 bounce messages are sent; each message is simply forgotten. However, if any of
5368 the messages are active, their status is not altered. This option can be used
5369 only by an admin user or by the user who originally caused the message to be
5370 placed on the queue.
5371 </para>
5372 </listitem></varlistentry>
5373 <varlistentry>
5374 <term><option>-Mt</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5375 <listitem>
5376 <para>
5377 <indexterm role="option">
5378 <primary><option>-Mt</option></primary>
5379 </indexterm>
5380 <indexterm role="concept">
5381 <primary>thawing messages</primary>
5382 </indexterm>
5383 <indexterm role="concept">
5384 <primary>unfreezing messages</primary>
5385 </indexterm>
5386 <indexterm role="concept">
5387 <primary>frozen messages</primary>
5388 <secondary>thawing</secondary>
5389 </indexterm>
5390 <indexterm role="concept">
5391 <primary>message</primary>
5392 <secondary>thawing frozen</secondary>
5393 </indexterm>
5394 This option requests Exim to <quote>thaw</quote> any of the listed messages that are
5395 <quote>frozen</quote>, so that delivery attempts can resume. However, if any of the
5396 messages are active, their status is not altered. This option can be used only
5397 by an admin user.
5398 </para>
5399 </listitem></varlistentry>
5400 <varlistentry>
5401 <term><option>-Mvb</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
5402 <listitem>
5403 <para>
5404 <indexterm role="option">
5405 <primary><option>-Mvb</option></primary>
5406 </indexterm>
5407 <indexterm role="concept">
5408 <primary>listing</primary>
5409 <secondary>message body</secondary>
5410 </indexterm>
5411 <indexterm role="concept">
5412 <primary>message</primary>
5413 <secondary>listing body of</secondary>
5414 </indexterm>
5415 This option causes the contents of the message body (-D) spool file to be
5416 written to the standard output. This option can be used only by an admin user.
5417 </para>
5418 </listitem></varlistentry>
5419 <varlistentry>
5420 <term><option>-Mvh</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
5421 <listitem>
5422 <para>
5423 <indexterm role="option">
5424 <primary><option>-Mvh</option></primary>
5425 </indexterm>
5426 <indexterm role="concept">
5427 <primary>listing</primary>
5428 <secondary>message headers</secondary>
5429 </indexterm>
5430 <indexterm role="concept">
5431 <primary>header lines</primary>
5432 <secondary>listing</secondary>
5433 </indexterm>
5434 <indexterm role="concept">
5435 <primary>message</primary>
5436 <secondary>listing header lines</secondary>
5437 </indexterm>
5438 This option causes the contents of the message headers (-H) spool file to be
5439 written to the standard output. This option can be used only by an admin user.
5440 </para>
5441 </listitem></varlistentry>
5442 <varlistentry>
5443 <term><option>-Mvl</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
5444 <listitem>
5445 <para>
5446 <indexterm role="option">
5447 <primary><option>-Mvl</option></primary>
5448 </indexterm>
5449 <indexterm role="concept">
5450 <primary>listing</primary>
5451 <secondary>message log</secondary>
5452 </indexterm>
5453 <indexterm role="concept">
5454 <primary>message</primary>
5455 <secondary>listing message log</secondary>
5456 </indexterm>
5457 This option causes the contents of the message log spool file to be written to
5458 the standard output. This option can be used only by an admin user.
5459 </para>
5460 </listitem></varlistentry>
5461 <varlistentry>
5462 <term><option>-m</option></term>
5463 <listitem>
5464 <para>
5465 <indexterm role="option">
5466 <primary><option>-m</option></primary>
5467 </indexterm>
5468 This is apparently a synonym for <option>-om</option> that is accepted by Sendmail, so Exim
5469 treats it that way too.
5470 </para>
5471 </listitem></varlistentry>
5472 <varlistentry>
5473 <term><option>-N</option></term>
5474 <listitem>
5475 <para>
5476 <indexterm role="option">
5477 <primary><option>-N</option></primary>
5478 </indexterm>
5479 <indexterm role="concept">
5480 <primary>debugging</primary>
5481 <secondary><option>-N</option> option</secondary>
5482 </indexterm>
5483 <indexterm role="concept">
5484 <primary>debugging</primary>
5485 <secondary>suppressing delivery</secondary>
5486 </indexterm>
5487 This is a debugging option that inhibits delivery of a message at the transport
5488 level. It implies <option>-v</option>. Exim goes through many of the motions of delivery &ndash;
5489 it just doesn&#x2019;t actually transport the message, but instead behaves as if it
5490 had successfully done so. However, it does not make any updates to the retry
5491 database, and the log entries for deliveries are flagged with <quote>*&gt;</quote> rather
5492 than <quote>=&gt;</quote>.
5493 </para>
5494 <para>
5495 Because <option>-N</option> discards any message to which it applies, only root or the Exim
5496 user are allowed to use it with <option>-bd</option>, <option>-q</option>, <option>-R</option> or <option>-M</option>. In other
5497 words, an ordinary user can use it only when supplying an incoming message to
5498 which it will apply. Although transportation never fails when <option>-N</option> is set, an
5499 address may be deferred because of a configuration problem on a transport, or a
5500 routing problem. Once <option>-N</option> has been used for a delivery attempt, it sticks to
5501 the message, and applies to any subsequent delivery attempts that may happen
5502 for that message.
5503 </para>
5504 </listitem></varlistentry>
5505 <varlistentry>
5506 <term><option>-n</option></term>
5507 <listitem>
5508 <para>
5509 <indexterm role="option">
5510 <primary><option>-n</option></primary>
5511 </indexterm>
5512 <indexterm role="concept">
5513 <primary>Sendmail compatibility</primary>
5514 <secondary><option>-n</option> option ignored</secondary>
5515 </indexterm>
5516 This option is interpreted by Sendmail to mean <quote>no aliasing</quote>. It is ignored
5517 by Exim.
5518 </para>
5519 </listitem></varlistentry>
5520 <varlistentry>
5521 <term><option>-O</option>&nbsp;&lt;<emphasis>data</emphasis>&gt;</term>
5522 <listitem>
5523 <para>
5524 <indexterm role="option">
5525 <primary><option>-O</option></primary>
5526 </indexterm>
5527 This option is interpreted by Sendmail to mean <literal>set option</literal>. It is ignored by
5528 Exim.
5529 </para>
5530 </listitem></varlistentry>
5531 <varlistentry>
5532 <term><option>-oA</option>&nbsp;&lt;<emphasis>file&nbsp;name</emphasis>&gt;</term>
5533 <listitem>
5534 <para>
5535 <indexterm role="option">
5536 <primary><option>-oA</option></primary>
5537 </indexterm>
5538 <indexterm role="concept">
5539 <primary>Sendmail compatibility</primary>
5540 <secondary><option>-oA</option> option</secondary>
5541 </indexterm>
5542 This option is used by Sendmail in conjunction with <option>-bi</option> to specify an
5543 alternative alias file name. Exim handles <option>-bi</option> differently; see the
5544 description above.
5545 </para>
5546 </listitem></varlistentry>
5547 <varlistentry>
5548 <term><option>-oB</option>&nbsp;&lt;<emphasis>n</emphasis>&gt;</term>
5549 <listitem>
5550 <para>
5551 <indexterm role="option">
5552 <primary><option>-oB</option></primary>
5553 </indexterm>
5554 <indexterm role="concept">
5555 <primary>SMTP</primary>
5556 <secondary>passed connection</secondary>
5557 </indexterm>
5558 <indexterm role="concept">
5559 <primary>SMTP</primary>
5560 <secondary>multiple deliveries</secondary>
5561 </indexterm>
5562 <indexterm role="concept">
5563 <primary>multiple SMTP deliveries</primary>
5564 </indexterm>
5565 This is a debugging option which limits the maximum number of messages that can
5566 be delivered down one SMTP connection, overriding the value set in any <command>smtp</command>
5567 transport. If &lt;<emphasis>n</emphasis>&gt; is omitted, the limit is set to 1.
5568 </para>
5569 </listitem></varlistentry>
5570 <varlistentry>
5571 <term><option>-odb</option></term>
5572 <listitem>
5573 <para>
5574 <indexterm role="option">
5575 <primary><option>-odb</option></primary>
5576 </indexterm>
5577 <indexterm role="concept">
5578 <primary>background delivery</primary>
5579 </indexterm>
5580 <indexterm role="concept">
5581 <primary>delivery</primary>
5582 <secondary>in the background</secondary>
5583 </indexterm>
5584 This option applies to all modes in which Exim accepts incoming messages,
5585 including the listening daemon. It requests <quote>background</quote> delivery of such
5586 messages, which means that the accepting process automatically starts a
5587 delivery process for each message received, but does not wait for the delivery
5588 processes to finish.
5589 </para>
5590 <para>
5591 When all the messages have been received, the reception process exits,
5592 leaving the delivery processes to finish in their own time. The standard output
5593 and error streams are closed at the start of each delivery process.
5594 This is the default action if none of the <option>-od</option> options are present.
5595 </para>
5596 <para>
5597 If one of the queueing options in the configuration file
5598 (<option>queue_only</option> or <option>queue_only_file</option>, for example) is in effect, <option>-odb</option>
5599 overrides it if <option>queue_only_override</option> is set true, which is the default
5600 setting. If <option>queue_only_override</option> is set false, <option>-odb</option> has no effect.
5601 </para>
5602 </listitem></varlistentry>
5603 <varlistentry>
5604 <term><option>-odf</option></term>
5605 <listitem>
5606 <para>
5607 <indexterm role="option">
5608 <primary><option>-odf</option></primary>
5609 </indexterm>
5610 <indexterm role="concept">
5611 <primary>foreground delivery</primary>
5612 </indexterm>
5613 <indexterm role="concept">
5614 <primary>delivery</primary>
5615 <secondary>in the foreground</secondary>
5616 </indexterm>
5617 This option requests <quote>foreground</quote> (synchronous) delivery when Exim has
5618 accepted a locally-generated message. (For the daemon it is exactly the same as
5619 <option>-odb</option>.) A delivery process is automatically started to deliver the message,
5620 and Exim waits for it to complete before proceeding.
5621 </para>
5622 <para>
5623 The original Exim reception process does not finish until the delivery
5624 process for the final message has ended. The standard error stream is left open
5625 during deliveries.
5626 </para>
5627 <para>
5628 However, like <option>-odb</option>, this option has no effect if <option>queue_only_override</option> is
5629 false and one of the queueing options in the configuration file is in effect.
5630 </para>
5631 <para>
5632 If there is a temporary delivery error during foreground delivery, the
5633 message is left on the queue for later delivery, and the original reception
5634 process exits. See chapter <xref linkend="CHAPnonqueueing"/> for a way of setting up a
5635 restricted configuration that never queues messages.
5636 </para>
5637 </listitem></varlistentry>
5638 <varlistentry>
5639 <term><option>-odi</option></term>
5640 <listitem>
5641 <para>
5642 <indexterm role="option">
5643 <primary><option>-odi</option></primary>
5644 </indexterm>
5645 This option is synonymous with <option>-odf</option>. It is provided for compatibility with
5646 Sendmail.
5647 </para>
5648 </listitem></varlistentry>
5649 <varlistentry>
5650 <term><option>-odq</option></term>
5651 <listitem>
5652 <para>
5653 <indexterm role="option">
5654 <primary><option>-odq</option></primary>
5655 </indexterm>
5656 <indexterm role="concept">
5657 <primary>non-immediate delivery</primary>
5658 </indexterm>
5659 <indexterm role="concept">
5660 <primary>delivery</primary>
5661 <secondary>suppressing immediate</secondary>
5662 </indexterm>
5663 <indexterm role="concept">
5664 <primary>queueing incoming messages</primary>
5665 </indexterm>
5666 This option applies to all modes in which Exim accepts incoming messages,
5667 including the listening daemon. It specifies that the accepting process should
5668 not automatically start a delivery process for each message received. Messages
5669 are placed on the queue, and remain there until a subsequent queue runner
5670 process encounters them. There are several configuration options (such as
5671 <option>queue_only</option>) that can be used to queue incoming messages under certain
5672 conditions. This option overrides all of them and also <option>-odqs</option>. It always
5673 forces queueing.
5674 </para>
5675 </listitem></varlistentry>
5676 <varlistentry>
5677 <term><option>-odqs</option></term>
5678 <listitem>
5679 <para>
5680 <indexterm role="option">
5681 <primary><option>-odqs</option></primary>
5682 </indexterm>
5683 <indexterm role="concept">
5684 <primary>SMTP</primary>
5685 <secondary>delaying delivery</secondary>
5686 </indexterm>
5687 This option is a hybrid between <option>-odb</option>/<option>-odi</option> and <option>-odq</option>.
5688 However, like <option>-odb</option> and <option>-odi</option>, this option has no effect if
5689 <option>queue_only_override</option> is false and one of the queueing options in the
5690 configuration file is in effect.
5691 </para>
5692 <para>
5693 When <option>-odqs</option> does operate, a delivery process is started for each incoming
5694 message, in the background by default, but in the foreground if <option>-odi</option> is
5695 also present. The recipient addresses are routed, and local deliveries are done
5696 in the normal way. However, if any SMTP deliveries are required, they are not
5697 done at this time, so the message remains on the queue until a subsequent queue
5698 runner process encounters it. Because routing was done, Exim knows which
5699 messages are waiting for which hosts, and so a number of messages for the same
5700 host can be sent in a single SMTP connection. The <option>queue_smtp_domains</option>
5701 configuration option has the same effect for specific domains. See also the
5702 <option>-qq</option> option.
5703 </para>
5704 </listitem></varlistentry>
5705 <varlistentry>
5706 <term><option>-oee</option></term>
5707 <listitem>
5708 <para>
5709 <indexterm role="option">
5710 <primary><option>-oee</option></primary>
5711 </indexterm>
5712 <indexterm role="concept">
5713 <primary>error</primary>
5714 <secondary>reporting</secondary>
5715 </indexterm>
5716 If an error is detected while a non-SMTP message is being received (for
5717 example, a malformed address), the error is reported to the sender in a mail
5718 message.
5719 </para>
5720 <para>
5721 <indexterm role="concept">
5722 <primary>return code</primary>
5723 <secondary>for <option>-oee</option></secondary>
5724 </indexterm>
5725 Provided
5726 this error message is successfully sent, the Exim receiving process
5727 exits with a return code of zero. If not, the return code is 2 if the problem
5728 is that the original message has no recipients, or 1 any other error. This is
5729 the default <option>-oe</option><emphasis>x</emphasis> option if Exim is called as <emphasis>rmail</emphasis>.
5730 </para>
5731 </listitem></varlistentry>
5732 <varlistentry>
5733 <term><option>-oem</option></term>
5734 <listitem>
5735 <para>
5736 <indexterm role="option">
5737 <primary><option>-oem</option></primary>
5738 </indexterm>
5739 <indexterm role="concept">
5740 <primary>error</primary>
5741 <secondary>reporting</secondary>
5742 </indexterm>
5743 <indexterm role="concept">
5744 <primary>return code</primary>
5745 <secondary>for <option>-oem</option></secondary>
5746 </indexterm>
5747 This is the same as <option>-oee</option>, except that Exim always exits with a non-zero
5748 return code, whether or not the error message was successfully sent.
5749 This is the default <option>-oe</option><emphasis>x</emphasis> option, unless Exim is called as <emphasis>rmail</emphasis>.
5750 </para>
5751 </listitem></varlistentry>
5752 <varlistentry>
5753 <term><option>-oep</option></term>
5754 <listitem>
5755 <para>
5756 <indexterm role="option">
5757 <primary><option>-oep</option></primary>
5758 </indexterm>
5759 <indexterm role="concept">
5760 <primary>error</primary>
5761 <secondary>reporting</secondary>
5762 </indexterm>
5763 If an error is detected while a non-SMTP message is being received, the
5764 error is reported by writing a message to the standard error file (stderr).
5765 <indexterm role="concept">
5766 <primary>return code</primary>
5767 <secondary>for <option>-oep</option></secondary>
5768 </indexterm>
5769 The return code is 1 for all errors.
5770 </para>
5771 </listitem></varlistentry>
5772 <varlistentry>
5773 <term><option>-oeq</option></term>
5774 <listitem>
5775 <para>
5776 <indexterm role="option">
5777 <primary><option>-oeq</option></primary>
5778 </indexterm>
5779 <indexterm role="concept">
5780 <primary>error</primary>
5781 <secondary>reporting</secondary>
5782 </indexterm>
5783 This option is supported for compatibility with Sendmail, but has the same
5784 effect as <option>-oep</option>.
5785 </para>
5786 </listitem></varlistentry>
5787 <varlistentry>
5788 <term><option>-oew</option></term>
5789 <listitem>
5790 <para>
5791 <indexterm role="option">
5792 <primary><option>-oew</option></primary>
5793 </indexterm>
5794 <indexterm role="concept">
5795 <primary>error</primary>
5796 <secondary>reporting</secondary>
5797 </indexterm>
5798 This option is supported for compatibility with Sendmail, but has the same
5799 effect as <option>-oem</option>.
5800 </para>
5801 </listitem></varlistentry>
5802 <varlistentry>
5803 <term><option>-oi</option></term>
5804 <listitem>
5805 <para>
5806 <indexterm role="option">
5807 <primary><option>-oi</option></primary>
5808 </indexterm>
5809 <indexterm role="concept">
5810 <primary>dot in incoming</primary>
5811 <secondary>non-SMTP message</secondary>
5812 </indexterm>
5813 This option, which has the same effect as <option>-i</option>, specifies that a dot on a
5814 line by itself should not terminate an incoming, non-SMTP message. Otherwise, a
5815 single dot does terminate, though Exim does no special processing for other
5816 lines that start with a dot. This option is set by default if Exim is called as
5817 <emphasis>rmail</emphasis>. See also <option>-ti</option>.
5818 </para>
5819 </listitem></varlistentry>
5820 <varlistentry>
5821 <term><option>-oitrue</option></term>
5822 <listitem>
5823 <para>
5824 <indexterm role="option">
5825 <primary><option>-oitrue</option></primary>
5826 </indexterm>
5827 This option is treated as synonymous with <option>-oi</option>.
5828 </para>
5829 </listitem></varlistentry>
5830 <varlistentry>
5831 <term><option>-oMa</option>&nbsp;&lt;<emphasis>host&nbsp;address</emphasis>&gt;</term>
5832 <listitem>
5833 <para>
5834 <indexterm role="option">
5835 <primary><option>-oMa</option></primary>
5836 </indexterm>
5837 <indexterm role="concept">
5838 <primary>sender host address</primary>
5839 <secondary>specifying for local message</secondary>
5840 </indexterm>
5841 A number of options starting with <option>-oM</option> can be used to set values associated
5842 with remote hosts on locally-submitted messages (that is, messages not received
5843 over TCP/IP). These options can be used by any caller in conjunction with the
5844 <option>-bh</option>, <option>-be</option>, <option>-bf</option>, <option>-bF</option>, <option>-bt</option>, or <option>-bv</option> testing options. In
5845 other circumstances, they are ignored unless the caller is trusted.
5846 </para>
5847 <para>
5848 The <option>-oMa</option> option sets the sender host address. This may include a port
5849 number at the end, after a full stop (period). For example:
5850 </para>
5851 <literallayout class="monospaced">
5852 exim -bs -oMa 10.9.8.7.1234
5853 </literallayout>
5854 <para>
5855 An alternative syntax is to enclose the IP address in square brackets,
5856 followed by a colon and the port number:
5857 </para>
5858 <literallayout class="monospaced">
5859 exim -bs -oMa [10.9.8.7]:1234
5860 </literallayout>
5861 <para>
5862 The IP address is placed in the <varname>$sender_host_address</varname> variable, and the
5863 port, if present, in <varname>$sender_host_port</varname>.
5864 </para>
5865 </listitem></varlistentry>
5866 <varlistentry>
5867 <term><option>-oMaa</option>&nbsp;&lt;<emphasis>name</emphasis>&gt;</term>
5868 <listitem>
5869 <para>
5870 <indexterm role="option">
5871 <primary><option>-oMaa</option></primary>
5872 </indexterm>
5873 <indexterm role="concept">
5874 <primary>authentication name</primary>
5875 <secondary>specifying for local message</secondary>
5876 </indexterm>
5877 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMaa</option>
5878 option sets the value of <varname>$sender_host_authenticated</varname> (the authenticator
5879 name). See chapter <xref linkend="CHAPSMTPAUTH"/> for a discussion of SMTP authentication.
5880 </para>
5881 </listitem></varlistentry>
5882 <varlistentry>
5883 <term><option>-oMai</option>&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
5884 <listitem>
5885 <para>
5886 <indexterm role="option">
5887 <primary><option>-oMai</option></primary>
5888 </indexterm>
5889 <indexterm role="concept">
5890 <primary>authentication id</primary>
5891 <secondary>specifying for local message</secondary>
5892 </indexterm>
5893 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMai</option>
5894 option sets the value of <varname>$authenticated_id</varname> (the id that was authenticated).
5895 This overrides the default value (the caller&#x2019;s login id) for messages from
5896 local sources. See chapter <xref linkend="CHAPSMTPAUTH"/> for a discussion of authenticated
5897 ids.
5898 </para>
5899 </listitem></varlistentry>
5900 <varlistentry>
5901 <term><option>-oMas</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;</term>
5902 <listitem>
5903 <para>
5904 <indexterm role="option">
5905 <primary><option>-oMas</option></primary>
5906 </indexterm>
5907 <indexterm role="concept">
5908 <primary>authentication sender</primary>
5909 <secondary>specifying for local message</secondary>
5910 </indexterm>
5911 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMas</option>
5912 option sets the authenticated sender value in <varname>$authenticated_sender</varname>. It
5913 overrides the sender address that is created from the caller&#x2019;s login id for
5914 messages from local sources. See chapter <xref linkend="CHAPSMTPAUTH"/> for a discussion of
5915 authenticated senders.
5916 </para>
5917 </listitem></varlistentry>
5918 <varlistentry>
5919 <term><option>-oMi</option>&nbsp;&lt;<emphasis>interface&nbsp;address</emphasis>&gt;</term>
5920 <listitem>
5921 <para>
5922 <indexterm role="option">
5923 <primary><option>-oMi</option></primary>
5924 </indexterm>
5925 <indexterm role="concept">
5926 <primary>interface address</primary>
5927 <secondary>specifying for local message</secondary>
5928 </indexterm>
5929 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMi</option>
5930 option sets the IP interface address value. A port number may be included,
5931 using the same syntax as for <option>-oMa</option>. The interface address is placed in
5932 <varname>$interface_address</varname> and the port number, if present, in <varname>$interface_port</varname>.
5933 </para>
5934 </listitem></varlistentry>
5935 <varlistentry>
5936 <term><option>-oMr</option>&nbsp;&lt;<emphasis>protocol&nbsp;name</emphasis>&gt;</term>
5937 <listitem>
5938 <para>
5939 <indexterm role="option">
5940 <primary><option>-oMr</option></primary>
5941 </indexterm>
5942 <indexterm role="concept">
5943 <primary>protocol</primary>
5944 <secondary>incoming &ndash; specifying for local message</secondary>
5945 </indexterm>
5946 <indexterm role="concept">
5947 <primary><varname>$received_protocol</varname></primary>
5948 </indexterm>
5949 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMr</option>
5950 option sets the received protocol value that is stored in
5951 <varname>$received_protocol</varname>. However, this applies only when <option>-bs</option> is not used. For
5952 interactive SMTP input (<option>-bs</option>), the protocol is always <quote>local-</quote> followed by
5953 one of the standard SMTP protocol names (see the description of
5954 <varname>$received_protocol</varname> in section <xref linkend="SECTexpvar"/>). For <option>-bS</option> (batch SMTP)
5955 however, the protocol can be set by <option>-oMr</option>.
5956 </para>
5957 </listitem></varlistentry>
5958 <varlistentry>
5959 <term><option>-oMs</option>&nbsp;&lt;<emphasis>host&nbsp;name</emphasis>&gt;</term>
5960 <listitem>
5961 <para>
5962 <indexterm role="option">
5963 <primary><option>-oMs</option></primary>
5964 </indexterm>
5965 <indexterm role="concept">
5966 <primary>sender host name</primary>
5967 <secondary>specifying for local message</secondary>
5968 </indexterm>
5969 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMs</option>
5970 option sets the sender host name in <varname>$sender_host_name</varname>. When this option is
5971 present, Exim does not attempt to look up a host name from an IP address; it
5972 uses the name it is given.
5973 </para>
5974 </listitem></varlistentry>
5975 <varlistentry>
5976 <term><option>-oMt</option>&nbsp;&lt;<emphasis>ident&nbsp;string</emphasis>&gt;</term>
5977 <listitem>
5978 <para>
5979 <indexterm role="option">
5980 <primary><option>-oMt</option></primary>
5981 </indexterm>
5982 <indexterm role="concept">
5983 <primary>sender ident string</primary>
5984 <secondary>specifying for local message</secondary>
5985 </indexterm>
5986 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMt</option>
5987 option sets the sender ident value in <varname>$sender_ident</varname>. The default setting for
5988 local callers is the login id of the calling process.
5989 </para>
5990 </listitem></varlistentry>
5991 <varlistentry>
5992 <term><option>-om</option></term>
5993 <listitem>
5994 <para>
5995 <indexterm role="option">
5996 <primary><option>-om</option></primary>
5997 </indexterm>
5998 <indexterm role="concept">
5999 <primary>Sendmail compatibility</primary>
6000 <secondary><option>-om</option> option ignored</secondary>
6001 </indexterm>
6002 In Sendmail, this option means <quote>me too</quote>, indicating that the sender of a
6003 message should receive a copy of the message if the sender appears in an alias
6004 expansion. Exim always does this, so the option does nothing.
6005 </para>
6006 </listitem></varlistentry>
6007 <varlistentry>
6008 <term><option>-oo</option></term>
6009 <listitem>
6010 <para>
6011 <indexterm role="option">
6012 <primary><option>-oo</option></primary>
6013 </indexterm>
6014 <indexterm role="concept">
6015 <primary>Sendmail compatibility</primary>
6016 <secondary><option>-oo</option> option ignored</secondary>
6017 </indexterm>
6018 This option is ignored. In Sendmail it specifies <quote>old style headers</quote>,
6019 whatever that means.
6020 </para>
6021 </listitem></varlistentry>
6022 <varlistentry>
6023 <term><option>-oP</option>&nbsp;&lt;<emphasis>path</emphasis>&gt;</term>
6024 <listitem>
6025 <para>
6026 <indexterm role="option">
6027 <primary><option>-oP</option></primary>
6028 </indexterm>
6029 <indexterm role="concept">
6030 <primary>pid (process id)</primary>
6031 <secondary>of daemon</secondary>
6032 </indexterm>
6033 <indexterm role="concept">
6034 <primary>daemon</primary>
6035 <secondary>process id (pid)</secondary>
6036 </indexterm>
6037 This option is useful only in conjunction with <option>-bd</option> or <option>-q</option> with a time
6038 value. The option specifies the file to which the process id of the daemon is
6039 written. When <option>-oX</option> is used with <option>-bd</option>, or when <option>-q</option> with a time is used
6040 without <option>-bd</option>, this is the only way of causing Exim to write a pid file,
6041 because in those cases, the normal pid file is not used.
6042 </para>
6043 </listitem></varlistentry>
6044 <varlistentry>
6045 <term><option>-or</option>&nbsp;&lt;<emphasis>time</emphasis>&gt;</term>
6046 <listitem>
6047 <para>
6048 <indexterm role="option">
6049 <primary><option>-or</option></primary>
6050 </indexterm>
6051 <indexterm role="concept">
6052 <primary>timeout</primary>
6053 <secondary>for non-SMTP input</secondary>
6054 </indexterm>
6055 This option sets a timeout value for incoming non-SMTP messages. If it is not
6056 set, Exim will wait forever for the standard input. The value can also be set
6057 by the <option>receive_timeout</option> option. The format used for specifying times is
6058 described in section <xref linkend="SECTtimeformat"/>.
6059 </para>
6060 </listitem></varlistentry>
6061 <varlistentry>
6062 <term><option>-os</option>&nbsp;&lt;<emphasis>time</emphasis>&gt;</term>
6063 <listitem>
6064 <para>
6065 <indexterm role="option">
6066 <primary><option>-os</option></primary>
6067 </indexterm>
6068 <indexterm role="concept">
6069 <primary>timeout</primary>
6070 <secondary>for SMTP input</secondary>
6071 </indexterm>
6072 <indexterm role="concept">
6073 <primary>SMTP timeout</primary>
6074 <secondary>input</secondary>
6075 </indexterm>
6076 This option sets a timeout value for incoming SMTP messages. The timeout
6077 applies to each SMTP command and block of data. The value can also be set by
6078 the <option>smtp_receive_timeout</option> option; it defaults to 5 minutes. The format used
6079 for specifying times is described in section <xref linkend="SECTtimeformat"/>.
6080 </para>
6081 </listitem></varlistentry>
6082 <varlistentry>
6083 <term><option>-ov</option></term>
6084 <listitem>
6085 <para>
6086 <indexterm role="option">
6087 <primary><option>-ov</option></primary>
6088 </indexterm>
6089 This option has exactly the same effect as <option>-v</option>.
6090 </para>
6091 </listitem></varlistentry>
6092 <varlistentry>
6093 <term><option>-oX</option>&nbsp;&lt;<emphasis>number&nbsp;or&nbsp;string</emphasis>&gt;</term>
6094 <listitem>
6095 <para>
6096 <indexterm role="option">
6097 <primary><option>-oX</option></primary>
6098 </indexterm>
6099 <indexterm role="concept">
6100 <primary>TCP/IP</primary>
6101 <secondary>setting listening ports</secondary>
6102 </indexterm>
6103 <indexterm role="concept">
6104 <primary>TCP/IP</primary>
6105 <secondary>setting listening interfaces</secondary>
6106 </indexterm>
6107 <indexterm role="concept">
6108 <primary>port</primary>
6109 <secondary>receiving TCP/IP</secondary>
6110 </indexterm>
6111 This option is relevant only when the <option>-bd</option> (start listening daemon) option
6112 is also given. It controls which ports and interfaces the daemon uses. Details
6113 of the syntax, and how it interacts with configuration file options, are given
6114 in chapter <xref linkend="CHAPinterfaces"/>. When <option>-oX</option> is used to start a daemon, no pid
6115 file is written unless <option>-oP</option> is also present to specify a pid file name.
6116 </para>
6117 </listitem></varlistentry>
6118 <varlistentry>
6119 <term><option>-pd</option></term>
6120 <listitem>
6121 <para>
6122 <indexterm role="option">
6123 <primary><option>-pd</option></primary>
6124 </indexterm>
6125 <indexterm role="concept">
6126 <primary>Perl</primary>
6127 <secondary>starting the interpreter</secondary>
6128 </indexterm>
6129 This option applies when an embedded Perl interpreter is linked with Exim (see
6130 chapter <xref linkend="CHAPperl"/>). It overrides the setting of the <option>perl_at_start</option>
6131 option, forcing the starting of the interpreter to be delayed until it is
6132 needed.
6133 </para>
6134 </listitem></varlistentry>
6135 <varlistentry>
6136 <term><option>-ps</option></term>
6137 <listitem>
6138 <para>
6139 <indexterm role="option">
6140 <primary><option>-ps</option></primary>
6141 </indexterm>
6142 <indexterm role="concept">
6143 <primary>Perl</primary>
6144 <secondary>starting the interpreter</secondary>
6145 </indexterm>
6146 This option applies when an embedded Perl interpreter is linked with Exim (see
6147 chapter <xref linkend="CHAPperl"/>). It overrides the setting of the <option>perl_at_start</option>
6148 option, forcing the starting of the interpreter to occur as soon as Exim is
6149 started.
6150 </para>
6151 </listitem></varlistentry>
6152 <varlistentry>
6153 <term><option>-p</option>&lt;<emphasis>rval</emphasis>&gt;:&lt;<emphasis>sval</emphasis>&gt;</term>
6154 <listitem>
6155 <para>
6156 <indexterm role="option">
6157 <primary><option>-p</option></primary>
6158 </indexterm>
6159 For compatibility with Sendmail, this option is equivalent to
6160 </para>
6161 <literallayout>
6162 <literal>-oMr</literal> &lt;<emphasis>rval</emphasis>&gt; <literal>-oMs</literal> &lt;<emphasis>sval</emphasis>&gt;
6163 </literallayout>
6164 <para>
6165 It sets the incoming protocol and host name (for trusted callers). The
6166 host name and its colon can be omitted when only the protocol is to be set.
6167 Note the Exim already has two private options, <option>-pd</option> and <option>-ps</option>, that refer
6168 to embedded Perl. It is therefore impossible to set a protocol value of <literal>p</literal>
6169 or <literal>s</literal> using this option (but that does not seem a real limitation).
6170 </para>
6171 </listitem></varlistentry>
6172 <varlistentry>
6173 <term><option>-q</option></term>
6174 <listitem>
6175 <para>
6176 <indexterm role="option">
6177 <primary><option>-q</option></primary>
6178 </indexterm>
6179 <indexterm role="concept">
6180 <primary>queue runner</primary>
6181 <secondary>starting manually</secondary>
6182 </indexterm>
6183 This option is normally restricted to admin users. However, there is a
6184 configuration option called <option>prod_requires_admin</option> which can be set false to
6185 relax this restriction (and also the same requirement for the <option>-M</option>, <option>-R</option>,
6186 and <option>-S</option> options).
6187 </para>
6188 <para>
6189 <indexterm role="concept">
6190 <primary>queue runner</primary>
6191 <secondary>description of operation</secondary>
6192 </indexterm>
6193 The <option>-q</option> option starts one queue runner process. This scans the queue of
6194 waiting messages, and runs a delivery process for each one in turn. It waits
6195 for each delivery process to finish before starting the next one. A delivery
6196 process may not actually do any deliveries if the retry times for the addresses
6197 have not been reached. Use <option>-qf</option> (see below) if you want to override this.
6198 </para>
6199 <para>
6200 If
6201 <indexterm role="concept">
6202 <primary>SMTP</primary>
6203 <secondary>passed connection</secondary>
6204 </indexterm>
6205 <indexterm role="concept">
6206 <primary>SMTP</primary>
6207 <secondary>multiple deliveries</secondary>
6208 </indexterm>
6209 <indexterm role="concept">
6210 <primary>multiple SMTP deliveries</primary>
6211 </indexterm>
6212 the delivery process spawns other processes to deliver other messages down
6213 passed SMTP connections, the queue runner waits for these to finish before
6214 proceeding.
6215 </para>
6216 <para>
6217 When all the queued messages have been considered, the original queue runner
6218 process terminates. In other words, a single pass is made over the waiting
6219 mail, one message at a time. Use <option>-q</option> with a time (see below) if you want
6220 this to be repeated periodically.
6221 </para>
6222 <para>
6223 Exim processes the waiting messages in an unpredictable order. It isn&#x2019;t very
6224 random, but it is likely to be different each time, which is all that matters.
6225 If one particular message screws up a remote MTA, other messages to the same
6226 MTA have a chance of getting through if they get tried first.
6227 </para>
6228 <para>
6229 It is possible to cause the messages to be processed in lexical message id
6230 order, which is essentially the order in which they arrived, by setting the
6231 <option>queue_run_in_order</option> option, but this is not recommended for normal use.
6232 </para>
6233 </listitem></varlistentry>
6234 <varlistentry>
6235 <term><option>-q</option>&lt;<emphasis>qflags</emphasis>&gt;</term>
6236 <listitem>
6237 <para>
6238 The <option>-q</option> option may be followed by one or more flag letters that change its
6239 behaviour. They are all optional, but if more than one is present, they must
6240 appear in the correct order. Each flag is described in a separate item below.
6241 </para>
6242 </listitem></varlistentry>
6243 <varlistentry>
6244 <term><option>-qq...</option></term>
6245 <listitem>
6246 <para>
6247 <indexterm role="option">
6248 <primary><option>-qq</option></primary>
6249 </indexterm>
6250 <indexterm role="concept">
6251 <primary>queue</primary>
6252 <secondary>double scanning</secondary>
6253 </indexterm>
6254 <indexterm role="concept">
6255 <primary>queue</primary>
6256 <secondary>routing</secondary>
6257 </indexterm>
6258 <indexterm role="concept">
6259 <primary>routing</primary>
6260 <secondary>whole queue before delivery</secondary>
6261 </indexterm>
6262 An option starting with <option>-qq</option> requests a two-stage queue run. In the first
6263 stage, the queue is scanned as if the <option>queue_smtp_domains</option> option matched
6264 every domain. Addresses are routed, local deliveries happen, but no remote
6265 transports are run.
6266 </para>
6267 <para>
6268 <indexterm role="concept">
6269 <primary>hints database</primary>
6270 <secondary>remembering routing</secondary>
6271 </indexterm>
6272 The hints database that remembers which messages are waiting for specific hosts
6273 is updated, as if delivery to those hosts had been deferred. After this is
6274 complete, a second, normal queue scan happens, with routing and delivery taking
6275 place as normal. Messages that are routed to the same host should mostly be
6276 delivered down a single SMTP
6277 <indexterm role="concept">
6278 <primary>SMTP</primary>
6279 <secondary>passed connection</secondary>
6280 </indexterm>
6281 <indexterm role="concept">
6282 <primary>SMTP</primary>
6283 <secondary>multiple deliveries</secondary>
6284 </indexterm>
6285 <indexterm role="concept">
6286 <primary>multiple SMTP deliveries</primary>
6287 </indexterm>
6288 connection because of the hints that were set up during the first queue scan.
6289 This option may be useful for hosts that are connected to the Internet
6290 intermittently.
6291 </para>
6292 </listitem></varlistentry>
6293 <varlistentry>
6294 <term><option>-q[q]i...</option></term>
6295 <listitem>
6296 <para>
6297 <indexterm role="option">
6298 <primary><option>-qi</option></primary>
6299 </indexterm>
6300 <indexterm role="concept">
6301 <primary>queue</primary>
6302 <secondary>initial delivery</secondary>
6303 </indexterm>
6304 If the <emphasis>i</emphasis> flag is present, the queue runner runs delivery processes only for
6305 those messages that haven&#x2019;t previously been tried. (<emphasis>i</emphasis> stands for <quote>initial
6306 delivery</quote>.) This can be helpful if you are putting messages on the queue using
6307 <option>-odq</option> and want a queue runner just to process the new messages.
6308 </para>
6309 </listitem></varlistentry>
6310 <varlistentry>
6311 <term><option>-q[q][i]f...</option></term>
6312 <listitem>
6313 <para>
6314 <indexterm role="option">
6315 <primary><option>-qf</option></primary>
6316 </indexterm>
6317 <indexterm role="concept">
6318 <primary>queue</primary>
6319 <secondary>forcing delivery</secondary>
6320 </indexterm>
6321 <indexterm role="concept">
6322 <primary>delivery</primary>
6323 <secondary>forcing in queue run</secondary>
6324 </indexterm>
6325 If one <emphasis>f</emphasis> flag is present, a delivery attempt is forced for each non-frozen
6326 message, whereas without <emphasis>f</emphasis> only those non-frozen addresses that have passed
6327 their retry times are tried.
6328 </para>
6329 </listitem></varlistentry>
6330 <varlistentry>
6331 <term><option>-q[q][i]ff...</option></term>
6332 <listitem>
6333 <para>
6334 <indexterm role="option">
6335 <primary><option>-qff</option></primary>
6336 </indexterm>
6337 <indexterm role="concept">
6338 <primary>frozen messages</primary>
6339 <secondary>forcing delivery</secondary>
6340 </indexterm>
6341 If <emphasis>ff</emphasis> is present, a delivery attempt is forced for every message, whether
6342 frozen or not.
6343 </para>
6344 </listitem></varlistentry>
6345 <varlistentry>
6346 <term><option>-q[q][i][f[f]]l</option></term>
6347 <listitem>
6348 <para>
6349 <indexterm role="option">
6350 <primary><option>-ql</option></primary>
6351 </indexterm>
6352 <indexterm role="concept">
6353 <primary>queue</primary>
6354 <secondary>local deliveries only</secondary>
6355 </indexterm>
6356 The <emphasis>l</emphasis> (the letter <quote>ell</quote>) flag specifies that only local deliveries are to
6357 be done. If a message requires any remote deliveries, it remains on the queue
6358 for later delivery.
6359 </para>
6360 </listitem></varlistentry>
6361 <varlistentry>
6362 <term><option>-q</option>&lt;<emphasis>qflags</emphasis>&gt;&nbsp;&lt;<emphasis>start&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>end&nbsp;id</emphasis>&gt;</term>
6363 <listitem>
6364 <para>
6365 <indexterm role="concept">
6366 <primary>queue</primary>
6367 <secondary>delivering specific messages</secondary>
6368 </indexterm>
6369 When scanning the queue, Exim can be made to skip over messages whose ids are
6370 lexically less than a given value by following the <option>-q</option> option with a
6371 starting message id. For example:
6372 </para>
6373 <literallayout class="monospaced">
6374 exim -q 0t5C6f-0000c8-00
6375 </literallayout>
6376 <para>
6377 Messages that arrived earlier than <literal>0t5C6f-0000c8-00</literal> are not inspected. If a
6378 second message id is given, messages whose ids are lexically greater than it
6379 are also skipped. If the same id is given twice, for example,
6380 </para>
6381 <literallayout class="monospaced">
6382 exim -q 0t5C6f-0000c8-00 0t5C6f-0000c8-00
6383 </literallayout>
6384 <para>
6385 just one delivery process is started, for that message. This differs from
6386 <option>-M</option> in that retry data is respected, and it also differs from <option>-Mc</option> in
6387 that it counts as a delivery from a queue run. Note that the selection
6388 mechanism does not affect the order in which the messages are scanned. There
6389 are also other ways of selecting specific sets of messages for delivery in a
6390 queue run &ndash; see <option>-R</option> and <option>-S</option>.
6391 </para>
6392 </listitem></varlistentry>
6393 <varlistentry>
6394 <term><option>-q</option>&lt;<emphasis>qflags</emphasis>&gt;&lt;<emphasis>time</emphasis>&gt;</term>
6395 <listitem>
6396 <para>
6397 <indexterm role="concept">
6398 <primary>queue runner</primary>
6399 <secondary>starting periodically</secondary>
6400 </indexterm>
6401 <indexterm role="concept">
6402 <primary>periodic queue running</primary>
6403 </indexterm>
6404 When a time value is present, the <option>-q</option> option causes Exim to run as a daemon,
6405 starting a queue runner process at intervals specified by the given time value
6406 (whose format is described in section <xref linkend="SECTtimeformat"/>). This form of the
6407 <option>-q</option> option is commonly combined with the <option>-bd</option> option, in which case a
6408 single daemon process handles both functions. A common way of starting up a
6409 combined daemon at system boot time is to use a command such as
6410 </para>
6411 <literallayout class="monospaced">
6412 /usr/exim/bin/exim -bd -q30m
6413 </literallayout>
6414 <para>
6415 Such a daemon listens for incoming SMTP calls, and also starts a queue runner
6416 process every 30 minutes.
6417 </para>
6418 <para>
6419 When a daemon is started by <option>-q</option> with a time value, but without <option>-bd</option>, no
6420 pid file is written unless one is explicitly requested by the <option>-oP</option> option.
6421 </para>
6422 </listitem></varlistentry>
6423 <varlistentry>
6424 <term><option>-qR</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
6425 <listitem>
6426 <para>
6427 <indexterm role="option">
6428 <primary><option>-qR</option></primary>
6429 </indexterm>
6430 This option is synonymous with <option>-R</option>. It is provided for Sendmail
6431 compatibility.
6432 </para>
6433 </listitem></varlistentry>
6434 <varlistentry>
6435 <term><option>-qS</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
6436 <listitem>
6437 <para>
6438 <indexterm role="option">
6439 <primary><option>-qS</option></primary>
6440 </indexterm>
6441 This option is synonymous with <option>-S</option>.
6442 </para>
6443 </listitem></varlistentry>
6444 <varlistentry>
6445 <term><option>-R</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
6446 <listitem>
6447 <para>
6448 <indexterm role="option">
6449 <primary><option>-R</option></primary>
6450 </indexterm>
6451 <indexterm role="concept">
6452 <primary>queue runner</primary>
6453 <secondary>for specific recipients</secondary>
6454 </indexterm>
6455 <indexterm role="concept">
6456 <primary>delivery</primary>
6457 <secondary>to given domain</secondary>
6458 </indexterm>
6459 <indexterm role="concept">
6460 <primary>domain</primary>
6461 <secondary>delivery to</secondary>
6462 </indexterm>
6463 The &lt;<emphasis>rsflags</emphasis>&gt; may be empty, in which case the white space before the string
6464 is optional, unless the string is <emphasis>f</emphasis>, <emphasis>ff</emphasis>, <emphasis>r</emphasis>, <emphasis>rf</emphasis>, or <emphasis>rff</emphasis>,
6465 which are the possible values for &lt;<emphasis>rsflags</emphasis>&gt;. White space is required if
6466 &lt;<emphasis>rsflags</emphasis>&gt; is not empty.
6467 </para>
6468 <para>
6469 This option is similar to <option>-q</option> with no time value, that is, it causes Exim to
6470 perform a single queue run, except that, when scanning the messages on the
6471 queue, Exim processes only those that have at least one undelivered recipient
6472 address containing the given string, which is checked in a case-independent
6473 way. If the &lt;<emphasis>rsflags</emphasis>&gt; start with <emphasis>r</emphasis>, &lt;<emphasis>string</emphasis>&gt; is interpreted as a
6474 regular expression; otherwise it is a literal string.
6475 </para>
6476 <para>
6477 Once a message is selected, all its addresses are processed. For the first
6478 selected message, Exim overrides any retry information and forces a delivery
6479 attempt for each undelivered address. This means that if delivery of any
6480 address in the first message is successful, any existing retry information is
6481 deleted, and so delivery attempts for that address in subsequently selected
6482 messages (which are processed without forcing) will run. However, if delivery
6483 of any address does not succeed, the retry information is updated, and in
6484 subsequently selected messages, the failing address will be skipped.
6485 </para>
6486 <para>
6487 <indexterm role="concept">
6488 <primary>frozen messages</primary>
6489 <secondary>forcing delivery</secondary>
6490 </indexterm>
6491 If the &lt;<emphasis>rsflags</emphasis>&gt; contain <emphasis>f</emphasis> or <emphasis>ff</emphasis>, the delivery forcing applies to
6492 all selected messages, not just the first; frozen messages are included when
6493 <emphasis>ff</emphasis> is present.
6494 </para>
6495 <para>
6496 The <option>-R</option> option makes it straightforward to initiate delivery of all messages
6497 to a given domain after a host has been down for some time. When the SMTP
6498 command ETRN is accepted by its ACL (see chapter <xref linkend="CHAPACL"/>), its default
6499 effect is to run Exim with the <option>-R</option> option, but it can be configured to run
6500 an arbitrary command instead.
6501 </para>
6502 </listitem></varlistentry>
6503 <varlistentry>
6504 <term><option>-r</option></term>
6505 <listitem>
6506 <para>
6507 <indexterm role="option">
6508 <primary><option>-r</option></primary>
6509 </indexterm>
6510 This is a documented (for Sendmail) obsolete alternative name for <option>-f</option>.
6511 </para>
6512 </listitem></varlistentry>
6513 <varlistentry>
6514 <term><option>-S</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
6515 <listitem>
6516 <para>
6517 <indexterm role="option">
6518 <primary><option>-S</option></primary>
6519 </indexterm>
6520 <indexterm role="concept">
6521 <primary>delivery</primary>
6522 <secondary>from given sender</secondary>
6523 </indexterm>
6524 <indexterm role="concept">
6525 <primary>queue runner</primary>
6526 <secondary>for specific senders</secondary>
6527 </indexterm>
6528 This option acts like <option>-R</option> except that it checks the string against each
6529 message&#x2019;s sender instead of against the recipients. If <option>-R</option> is also set, both
6530 conditions must be met for a message to be selected. If either of the options
6531 has <emphasis>f</emphasis> or <emphasis>ff</emphasis> in its flags, the associated action is taken.
6532 </para>
6533 </listitem></varlistentry>
6534 <varlistentry>
6535 <term><option>-Tqt</option>&nbsp;&lt;<emphasis>times</emphasis>&gt;</term>
6536 <listitem>
6537 <para>
6538 <indexterm role="option">
6539 <primary><option>-Tqt</option></primary>
6540 </indexterm>
6541 This an option that is exclusively for use by the Exim testing suite. It is not
6542 recognized when Exim is run normally. It allows for the setting up of explicit
6543 <quote>queue times</quote> so that various warning/retry features can be tested.
6544 </para>
6545 </listitem></varlistentry>
6546 <varlistentry>
6547 <term><option>-t</option></term>
6548 <listitem>
6549 <para>
6550 <indexterm role="option">
6551 <primary><option>-t</option></primary>
6552 </indexterm>
6553 <indexterm role="concept">
6554 <primary>recipient</primary>
6555 <secondary>extracting from header lines</secondary>
6556 </indexterm>
6557 <indexterm role="concept">
6558 <primary><emphasis>Bcc:</emphasis> header line</primary>
6559 </indexterm>
6560 <indexterm role="concept">
6561 <primary><emphasis>Cc:</emphasis> header line</primary>
6562 </indexterm>
6563 <indexterm role="concept">
6564 <primary><emphasis>To:</emphasis> header line</primary>
6565 </indexterm>
6566 When Exim is receiving a locally-generated, non-SMTP message on its standard
6567 input, the <option>-t</option> option causes the recipients of the message to be obtained
6568 from the <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>, and <emphasis>Bcc:</emphasis> header lines in the message instead of
6569 from the command arguments. The addresses are extracted before any rewriting
6570 takes place and the <emphasis>Bcc:</emphasis> header line, if present, is then removed.
6571 </para>
6572 <para>
6573 <indexterm role="concept">
6574 <primary>Sendmail compatibility</primary>
6575 <secondary><option>-t</option> option</secondary>
6576 </indexterm>
6577 If the command has any arguments, they specify addresses to which the message
6578 is <emphasis>not</emphasis> to be delivered. That is, the argument addresses are removed from
6579 the recipients list obtained from the headers. This is compatible with Smail 3
6580 and in accordance with the documented behaviour of several versions of
6581 Sendmail, as described in man pages on a number of operating systems (e.g.
6582 Solaris 8, IRIX 6.5, HP-UX 11). However, some versions of Sendmail <emphasis>add</emphasis>
6583 argument addresses to those obtained from the headers, and the O&#x2019;Reilly
6584 Sendmail book documents it that way. Exim can be made to add argument addresses
6585 instead of subtracting them by setting the option
6586 <option>extract_addresses_remove_arguments</option> false.
6587 </para>
6588 <para>
6589 <indexterm role="concept">
6590 <primary><option>Resent-</option> header lines</primary>
6591 <secondary>with <option>-t</option></secondary>
6592 </indexterm>
6593 If there are any <option>Resent-</option> header lines in the message, Exim extracts
6594 recipients from all <emphasis>Resent-To:</emphasis>, <emphasis>Resent-Cc:</emphasis>, and <emphasis>Resent-Bcc:</emphasis> header
6595 lines instead of from <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>, and <emphasis>Bcc:</emphasis>. This is for compatibility
6596 with Sendmail and other MTAs. (Prior to release 4.20, Exim gave an error if
6597 <option>-t</option> was used in conjunction with <option>Resent-</option> header lines.)
6598 </para>
6599 <para>
6600 RFC 2822 talks about different sets of <option>Resent-</option> header lines (for when a
6601 message is resent several times). The RFC also specifies that they should be
6602 added at the front of the message, and separated by <emphasis>Received:</emphasis> lines. It is
6603 not at all clear how <option>-t</option> should operate in the present of multiple sets,
6604 nor indeed exactly what constitutes a <quote>set</quote>.
6605 In practice, it seems that MUAs do not follow the RFC. The <option>Resent-</option> lines
6606 are often added at the end of the header, and if a message is resent more than
6607 once, it is common for the original set of <option>Resent-</option> headers to be renamed as
6608 <option>X-Resent-</option> when a new set is added. This removes any possible ambiguity.
6609 </para>
6610 </listitem></varlistentry>
6611 <varlistentry>
6612 <term><option>-ti</option></term>
6613 <listitem>
6614 <para>
6615 <indexterm role="option">
6616 <primary><option>-ti</option></primary>
6617 </indexterm>
6618 This option is exactly equivalent to <option>-t</option> <option>-i</option>. It is provided for
6619 compatibility with Sendmail.
6620 </para>
6621 </listitem></varlistentry>
6622 <varlistentry>
6623 <term><option>-tls-on-connect</option></term>
6624 <listitem>
6625 <para>
6626 <indexterm role="option">
6627 <primary><option>-tls-on-connect</option></primary>
6628 </indexterm>
6629 <indexterm role="concept">
6630 <primary>TLS</primary>
6631 <secondary>use without STARTTLS</secondary>
6632 </indexterm>
6633 <indexterm role="concept">
6634 <primary>TLS</primary>
6635 <secondary>automatic start</secondary>
6636 </indexterm>
6637 This option is available when Exim is compiled with TLS support. It forces all
6638 incoming SMTP connections to behave as if the incoming port is listed in the
6639 <option>tls_on_connect_ports</option> option. See section <xref linkend="SECTsupobssmt"/> and chapter
6640 <xref linkend="CHAPTLS"/> for further details.
6641 </para>
6642 </listitem></varlistentry>
6643 <varlistentry>
6644 <term><option>-U</option></term>
6645 <listitem>
6646 <para>
6647 <indexterm role="option">
6648 <primary><option>-U</option></primary>
6649 </indexterm>
6650 <indexterm role="concept">
6651 <primary>Sendmail compatibility</primary>
6652 <secondary><option>-U</option> option ignored</secondary>
6653 </indexterm>
6654 Sendmail uses this option for <quote>initial message submission</quote>, and its
6655 documentation states that in future releases, it may complain about
6656 syntactically invalid messages rather than fixing them when this flag is not
6657 set. Exim ignores this option.
6658 </para>
6659 </listitem></varlistentry>
6660 <varlistentry>
6661 <term><option>-v</option></term>
6662 <listitem>
6663 <para>
6664 <indexterm role="option">
6665 <primary><option>-v</option></primary>
6666 </indexterm>
6667 This option causes Exim to write information to the standard error stream,
6668 describing what it is doing. In particular, it shows the log lines for
6669 receiving and delivering a message, and if an SMTP connection is made, the SMTP
6670 dialogue is shown. Some of the log lines shown may not actually be written to
6671 the log if the setting of <option>log_selector</option> discards them. Any relevant
6672 selectors are shown with each log line. If none are shown, the logging is
6673 unconditional.
6674 </para>
6675 </listitem></varlistentry>
6676 <varlistentry>
6677 <term><option>-x</option></term>
6678 <listitem>
6679 <para>
6680 <indexterm role="option">
6681 <primary><option>-x</option></primary>
6682 </indexterm>
6683 AIX uses <option>-x</option> for a private purpose (<quote>mail from a local mail program has
6684 National Language Support extended characters in the body of the mail item</quote>).
6685 It sets <option>-x</option> when calling the MTA from its <option>mail</option> command. Exim ignores
6686 this option.
6687 </para>
6688 </listitem></varlistentry>
6689 </variablelist>
6690 <para>
6691 <indexterm role="concept" startref="IIDclo1" class="endofrange"/>
6692 <indexterm role="concept" startref="IIDclo2" class="endofrange"/>
6693 </para>
6694 <!-- === End of command line options === -->
6695 </section>
6696 </chapter>
6697
6698 <chapter id="CHAPconf">
6699 <title>The Exim run time configuration file</title>
6700 <titleabbrev>The runtime configuration file</titleabbrev>
6701 <para>
6702 <indexterm role="concept">
6703 <primary>run time configuration</primary>
6704 </indexterm>
6705 <indexterm role="concept">
6706 <primary>configuration file</primary>
6707 <secondary>general description</secondary>
6708 </indexterm>
6709 <indexterm role="concept">
6710 <primary>CONFIGURE_FILE</primary>
6711 </indexterm>
6712 <indexterm role="concept">
6713 <primary>configuration file</primary>
6714 <secondary>errors in</secondary>
6715 </indexterm>
6716 <indexterm role="concept">
6717 <primary>error</primary>
6718 <secondary>in configuration file</secondary>
6719 </indexterm>
6720 <indexterm role="concept">
6721 <primary>return code</primary>
6722 <secondary>for bad configuration</secondary>
6723 </indexterm>
6724 Exim uses a single run time configuration file that is read whenever an Exim
6725 binary is executed. Note that in normal operation, this happens frequently,
6726 because Exim is designed to operate in a distributed manner, without central
6727 control.
6728 </para>
6729 <para>
6730 If a syntax error is detected while reading the configuration file, Exim
6731 writes a message on the standard error, and exits with a non-zero return code.
6732 The message is also written to the panic log. <emphasis role="bold">Note</emphasis>: Only simple syntax
6733 errors can be detected at this time. The values of any expanded options are
6734 not checked until the expansion happens, even when the expansion does not
6735 actually alter the string.
6736 </para>
6737 <para>
6738 The name of the configuration file is compiled into the binary for security
6739 reasons, and is specified by the CONFIGURE_FILE compilation option. In
6740 most configurations, this specifies a single file. However, it is permitted to
6741 give a colon-separated list of file names, in which case Exim uses the first
6742 existing file in the list.
6743 </para>
6744 <para>
6745 <indexterm role="concept">
6746 <primary>EXIM_USER</primary>
6747 </indexterm>
6748 <indexterm role="concept">
6749 <primary>EXIM_GROUP</primary>
6750 </indexterm>
6751 <indexterm role="concept">
6752 <primary>CONFIGURE_OWNER</primary>
6753 </indexterm>
6754 <indexterm role="concept">
6755 <primary>CONFIGURE_GROUP</primary>
6756 </indexterm>
6757 <indexterm role="concept">
6758 <primary>configuration file</primary>
6759 <secondary>ownership</secondary>
6760 </indexterm>
6761 <indexterm role="concept">
6762 <primary>ownership</primary>
6763 <secondary>configuration file</secondary>
6764 </indexterm>
6765 The run time configuration file must be owned by root or by the user that is
6766 specified at compile time by the EXIM_USER option, or by the user that is
6767 specified at compile time by the CONFIGURE_OWNER option (if set). The
6768 configuration file must not be world-writeable or group-writeable, unless its
6769 group is the one specified at compile time by the EXIM_GROUP option or by the
6770 CONFIGURE_GROUP option.
6771 </para>
6772 <para>
6773 <emphasis role="bold">Warning</emphasis>: In a conventional configuration, where the Exim binary is setuid
6774 to root, anybody who is able to edit the run time configuration file has an
6775 easy way to run commands as root. If you make your mail administrators members
6776 of the Exim group, but do not trust them with root, make sure that the run time
6777 configuration is not group writeable.
6778 </para>
6779 <para>
6780 A default configuration file, which will work correctly in simple situations,
6781 is provided in the file <filename>src/configure.default</filename>. If CONFIGURE_FILE
6782 defines just one file name, the installation process copies the default
6783 configuration to a new file of that name if it did not previously exist. If
6784 CONFIGURE_FILE is a list, no default is automatically installed. Chapter
6785 <xref linkend="CHAPdefconfil"/> is a <quote>walk-through</quote> discussion of the default
6786 configuration.
6787 </para>
6788 <section>
6789 <title>Using a different configuration file</title>
6790 <para>
6791 <indexterm role="concept">
6792 <primary>configuration file</primary>
6793 <secondary>alternate</secondary>
6794 </indexterm>
6795 A one-off alternate configuration can be specified by the <option>-C</option> command line
6796 option, which may specify a single file or a list of files. However, when
6797 <option>-C</option> is used, Exim gives up its root privilege, unless called by root or the
6798 Exim user (or unless the argument for <option>-C</option> is identical to the built-in value
6799 from CONFIGURE_FILE). <option>-C</option> is useful mainly for checking the syntax of
6800 configuration files before installing them. No owner or group checks are done
6801 on a configuration file specified by <option>-C</option>.
6802 </para>
6803 <para>
6804 The privileged use of <option>-C</option> by the Exim user can be locked out by setting
6805 ALT_CONFIG_ROOT_ONLY in <filename>Local/Makefile</filename> when building Exim. However,
6806 if you do this, you also lock out the possibility of testing a
6807 configuration using <option>-C</option> right through message reception and delivery, even
6808 if the caller is root. The reception works, but by that time, Exim is running
6809 as the Exim user, so when it re-execs to regain privilege for the delivery, the
6810 use of <option>-C</option> causes privilege to be lost. However, root can test reception and
6811 delivery using two separate commands (one to put a message on the queue, using
6812 <option>-odq</option>, and another to do the delivery, using <option>-M</option>).
6813 </para>
6814 <para>
6815 If ALT_CONFIG_PREFIX is defined <filename>in Local/Makefile</filename>, it specifies a
6816 prefix string with which any file named in a <option>-C</option> command line option must
6817 start. In addition, the file name must not contain the sequence <quote><literal>/../</literal></quote>.
6818 There is no default setting for ALT_CONFIG_PREFIX; when it is unset, any file
6819 name can be used with <option>-C</option>.
6820 </para>
6821 <para>
6822 One-off changes to a configuration can be specified by the <option>-D</option> command line
6823 option, which defines and overrides values for macros used inside the
6824 configuration file. However, like <option>-C</option>, the use of this option by a
6825 non-privileged user causes Exim to discard its root privilege.
6826 If DISABLE_D_OPTION is defined in <filename>Local/Makefile</filename>, the use of <option>-D</option> is
6827 completely disabled, and its use causes an immediate error exit.
6828 </para>
6829 <para>
6830 Some sites may wish to use the same Exim binary on different machines that
6831 share a file system, but to use different configuration files on each machine.
6832 If CONFIGURE_FILE_USE_NODE is defined in <filename>Local/Makefile</filename>, Exim first
6833 looks for a file whose name is the configuration file name followed by a dot
6834 and the machine&#x2019;s node name, as obtained from the <function>uname()</function> function. If this
6835 file does not exist, the standard name is tried. This processing occurs for
6836 each file name in the list given by CONFIGURE_FILE or <option>-C</option>.
6837 </para>
6838 <para>
6839 In some esoteric situations different versions of Exim may be run under
6840 different effective uids and the CONFIGURE_FILE_USE_EUID is defined to
6841 help with this. See the comments in <filename>src/EDITME</filename> for details.
6842 </para>
6843 </section>
6844 <section id="SECTconffilfor">
6845 <title>Configuration file format</title>
6846 <para>
6847 <indexterm role="concept">
6848 <primary>configuration file</primary>
6849 <secondary>format of</secondary>
6850 </indexterm>
6851 <indexterm role="concept">
6852 <primary>format</primary>
6853 <secondary>configuration file</secondary>
6854 </indexterm>
6855 Exim&#x2019;s configuration file is divided into a number of different parts. General
6856 option settings must always appear at the start of the file. The other parts
6857 are all optional, and may appear in any order. Each part other than the first
6858 is introduced by the word <quote>begin</quote> followed by the name of the part. The
6859 optional parts are:
6860 </para>
6861 <itemizedlist>
6862 <listitem>
6863 <para>
6864 <emphasis>ACL</emphasis>: Access control lists for controlling incoming SMTP mail.
6865 </para>
6866 </listitem>
6867 <listitem>
6868 <para>
6869 <indexterm role="concept">
6870 <primary>AUTH</primary>
6871 <secondary>configuration</secondary>
6872 </indexterm>
6873 <emphasis>authenticators</emphasis>: Configuration settings for the authenticator drivers. These
6874 are concerned with the SMTP AUTH command (see chapter <xref linkend="CHAPSMTPAUTH"/>).
6875 </para>
6876 </listitem>
6877 <listitem>
6878 <para>
6879 <emphasis>routers</emphasis>: Configuration settings for the router drivers. Routers process
6880 addresses and determine how the message is to be delivered.
6881 </para>
6882 </listitem>
6883 <listitem>
6884 <para>
6885 <emphasis>transports</emphasis>: Configuration settings for the transport drivers. Transports
6886 define mechanisms for copying messages to destinations.
6887 </para>
6888 </listitem>
6889 <listitem>
6890 <para>
6891 <emphasis>retry</emphasis>: Retry rules, for use when a message cannot be immediately delivered.
6892 </para>
6893 </listitem>
6894 <listitem>
6895 <para>
6896 <emphasis>rewrite</emphasis>: Global address rewriting rules, for use when a message arrives and
6897 when new addresses are generated during delivery.
6898 </para>
6899 </listitem>
6900 <listitem>
6901 <para>
6902 <emphasis>local_scan</emphasis>: Private options for the <function>local_scan()</function> function. If you
6903 want to use this feature, you must set
6904 </para>
6905 <literallayout class="monospaced">
6906 LOCAL_SCAN_HAS_OPTIONS=yes
6907 </literallayout>
6908 <para>
6909 in <filename>Local/Makefile</filename> before building Exim. Full details of the
6910 <function>local_scan()</function> facility are given in chapter <xref linkend="CHAPlocalscan"/>.
6911 </para>
6912 </listitem>
6913 </itemizedlist>
6914 <para>
6915 <indexterm role="concept">
6916 <primary>configuration file</primary>
6917 <secondary>leading white space in</secondary>
6918 </indexterm>
6919 <indexterm role="concept">
6920 <primary>configuration file</primary>
6921 <secondary>trailing white space in</secondary>
6922 </indexterm>
6923 <indexterm role="concept">
6924 <primary>white space</primary>
6925 <secondary>in configuration file</secondary>
6926 </indexterm>
6927 Leading and trailing white space in configuration lines is always ignored.
6928 </para>
6929 <para>
6930 Blank lines in the file, and lines starting with a # character (ignoring
6931 leading white space) are treated as comments and are ignored. <emphasis role="bold">Note</emphasis>: A
6932 # character other than at the beginning of a line is not treated specially,
6933 and does not introduce a comment.
6934 </para>
6935 <para>
6936 Any non-comment line can be continued by ending it with a backslash. Note that
6937 the general rule for white space means that trailing white space after the
6938 backslash and leading white space at the start of continuation
6939 lines is ignored. Comment lines beginning with # (but not empty lines) may
6940 appear in the middle of a sequence of continuation lines.
6941 </para>
6942 <para>
6943 A convenient way to create a configuration file is to start from the
6944 default, which is supplied in <filename>src/configure.default</filename>, and add, delete, or
6945 change settings as required.
6946 </para>
6947 <para>
6948 The ACLs, retry rules, and rewriting rules have their own syntax which is
6949 described in chapters <xref linkend="CHAPACL"/>, <xref linkend="CHAPretry"/>, and <xref linkend="CHAPrewrite"/>,
6950 respectively. The other parts of the configuration file have some syntactic
6951 items in common, and these are described below, from section <xref linkend="SECTcos"/>
6952 onwards. Before that, the inclusion, macro, and conditional facilities are
6953 described.
6954 </para>
6955 </section>
6956 <section>
6957 <title>File inclusions in the configuration file</title>
6958 <para>
6959 <indexterm role="concept">
6960 <primary>inclusions in configuration file</primary>
6961 </indexterm>
6962 <indexterm role="concept">
6963 <primary>configuration file</primary>
6964 <secondary>including other files</secondary>
6965 </indexterm>
6966 <indexterm role="concept">
6967 <primary>.include in configuration file</primary>
6968 </indexterm>
6969 <indexterm role="concept">
6970 <primary>.include_if_exists in configuration file</primary>
6971 </indexterm>
6972 You can include other files inside Exim&#x2019;s run time configuration file by
6973 using this syntax:
6974 </para>
6975 <literallayout>
6976 <literal>.include</literal> &lt;<emphasis>file name</emphasis>&gt;
6977 <literal>.include_if_exists</literal> &lt;<emphasis>file name</emphasis>&gt;
6978 </literallayout>
6979 <para revisionflag="changed">
6980 on a line by itself. Double quotes round the file name are optional. If you use
6981 the first form, a configuration error occurs if the file does not exist; the
6982 second form does nothing for non-existent files. In all cases, an absolute file
6983 name is required.
6984 </para>
6985 <para>
6986 Includes may be nested to any depth, but remember that Exim reads its
6987 configuration file often, so it is a good idea to keep them to a minimum.
6988 If you change the contents of an included file, you must HUP the daemon,
6989 because an included file is read only when the configuration itself is read.
6990 </para>
6991 <para>
6992 The processing of inclusions happens early, at a physical line level, so, like
6993 comment lines, an inclusion can be used in the middle of an option setting,
6994 for example:
6995 </para>
6996 <literallayout class="monospaced">
6997 hosts_lookup = a.b.c \
6998                .include /some/file
6999 </literallayout>
7000 <para>
7001 Include processing happens after macro processing (see below). Its effect is to
7002 process the lines of the included file as if they occurred inline where the
7003 inclusion appears.
7004 </para>
7005 </section>
7006 <section id="SECTmacrodefs">
7007 <title>Macros in the configuration file</title>
7008 <para>
7009 <indexterm role="concept">
7010 <primary>macro</primary>
7011 <secondary>description of</secondary>
7012 </indexterm>
7013 <indexterm role="concept">
7014 <primary>configuration file</primary>
7015 <secondary>macros</secondary>
7016 </indexterm>
7017 If a line in the main part of the configuration (that is, before the first
7018 <quote>begin</quote> line) begins with an upper case letter, it is taken as a macro
7019 definition, and must be of the form
7020 </para>
7021 <literallayout>
7022 &lt;<emphasis>name</emphasis>&gt; = &lt;<emphasis>rest of line</emphasis>&gt;
7023 </literallayout>
7024 <para>
7025 The name must consist of letters, digits, and underscores, and need not all be
7026 in upper case, though that is recommended. The rest of the line, including any
7027 continuations, is the replacement text, and has leading and trailing white
7028 space removed. Quotes are not removed. The replacement text can never end with
7029 a backslash character, but this doesn&#x2019;t seem to be a serious limitation.
7030 </para>
7031 <para>
7032 Macros may also be defined between router, transport, authenticator, or ACL
7033 definitions. They may not, however, be defined within an individual driver or
7034 ACL, or in the <option>local_scan</option>, retry, or rewrite sections of the configuration.
7035 </para>
7036 </section>
7037 <section>
7038 <title>Macro substitution</title>
7039 <para>
7040 Once a macro is defined, all subsequent lines in the file (and any included
7041 files) are scanned for the macro name; if there are several macros, the line is
7042 scanned for each in turn, in the order in which the macros are defined. The
7043 replacement text is not re-scanned for the current macro, though it is scanned
7044 for subsequently defined macros. For this reason, a macro name may not contain
7045 the name of a previously defined macro as a substring. You could, for example,
7046 define
7047 </para>
7048 <literallayout>
7049 <literal>ABCD_XYZ = </literal>&lt;<emphasis>something</emphasis>&gt;
7050 <literal>ABCD = </literal>&lt;<emphasis>something else</emphasis>&gt;
7051 </literallayout>
7052 <para>
7053 but putting the definitions in the opposite order would provoke a configuration
7054 error. Macro expansion is applied to individual physical lines from the file,
7055 before checking for line continuation or file inclusion (see above). If a line
7056 consists solely of a macro name, and the expansion of the macro is empty, the
7057 line is ignored. A macro at the start of a line may turn the line into a
7058 comment line or a <literal>.include</literal> line.
7059 </para>
7060 </section>
7061 <section>
7062 <title>Redefining macros</title>
7063 <para>
7064 Once defined, the value of a macro can be redefined later in the configuration
7065 (or in an included file). Redefinition is specified by using <emphasis>==</emphasis> instead of
7066 <emphasis>=</emphasis>. For example:
7067 </para>
7068 <literallayout class="monospaced">
7069 MAC =  initial value
7070 ...
7071 MAC == updated value
7072 </literallayout>
7073 <para>
7074 Redefinition does not alter the order in which the macros are applied to the
7075 subsequent lines of the configuration file. It is still the same order in which
7076 the macros were originally defined. All that changes is the macro&#x2019;s value.
7077 Redefinition makes it possible to accumulate values. For example:
7078 </para>
7079 <literallayout class="monospaced">
7080 MAC =  initial value
7081 ...
7082 MAC == MAC and something added
7083 </literallayout>
7084 <para>
7085 This can be helpful in situations where the configuration file is built
7086 from a number of other files.
7087 </para>
7088 </section>
7089 <section>
7090 <title>Overriding macro values</title>
7091 <para>
7092 The values set for macros in the configuration file can be overridden by the
7093 <option>-D</option> command line option, but Exim gives up its root privilege when <option>-D</option> is
7094 used, unless called by root or the Exim user. A definition on the command line
7095 using the <option>-D</option> option causes all definitions and redefinitions within the
7096 file to be ignored.
7097 </para>
7098 </section>
7099 <section>
7100 <title>Example of macro usage</title>
7101 <para>
7102 As an example of macro usage, consider a configuration where aliases are looked
7103 up in a MySQL database. It helps to keep the file less cluttered if long
7104 strings such as SQL statements are defined separately as macros, for example:
7105 </para>
7106 <literallayout class="monospaced">
7107 ALIAS_QUERY = select mailbox from user where \
7108               login=${quote_mysql:$local_part};
7109 </literallayout>
7110 <para>
7111 This can then be used in a <command>redirect</command> router setting like this:
7112 </para>
7113 <literallayout class="monospaced">
7114 data = ${lookup mysql{ALIAS_QUERY}}
7115 </literallayout>
7116 <para>
7117 In earlier versions of Exim macros were sometimes used for domain, host, or
7118 address lists. In Exim 4 these are handled better by named lists &ndash; see
7119 section <xref linkend="SECTnamedlists"/>.
7120 </para>
7121 </section>
7122 <section>
7123 <title>Conditional skips in the configuration file</title>
7124 <para>
7125 <indexterm role="concept">
7126 <primary>configuration file</primary>
7127 <secondary>conditional skips</secondary>
7128 </indexterm>
7129 <indexterm role="concept">
7130 <primary>.ifdef</primary>
7131 </indexterm>
7132 You can use the directives <literal>.ifdef</literal>, <literal>.ifndef</literal>, <literal>.elifdef</literal>,
7133 <literal>.elifndef</literal>, <literal>.else</literal>, and <literal>.endif</literal> to dynamically include or exclude
7134 portions of the configuration file. The processing happens whenever the file is
7135 read (that is, when an Exim binary starts to run).
7136 </para>
7137 <para>
7138 The implementation is very simple. Instances of the first four directives must
7139 be followed by text that includes the names of one or macros. The condition
7140 that is tested is whether or not any macro substitution has taken place in the
7141 line. Thus:
7142 </para>
7143 <literallayout class="monospaced">
7144 .ifdef AAA
7145 message_size_limit = 50M
7146 .else
7147 message_size_limit = 100M
7148 .endif
7149 </literallayout>
7150 <para>
7151 sets a message size limit of 50M if the macro <literal>AAA</literal> is defined, and 100M
7152 otherwise. If there is more than one macro named on the line, the condition
7153 is true if any of them are defined. That is, it is an <quote>or</quote> condition. To
7154 obtain an <quote>and</quote> condition, you need to use nested <literal>.ifdef</literal>s.
7155 </para>
7156 <para>
7157 Although you can use a macro expansion to generate one of these directives,
7158 it is not very useful, because the condition <quote>there was a macro substitution
7159 in this line</quote> will always be true.
7160 </para>
7161 <para>
7162 Text following <literal>.else</literal> and <literal>.endif</literal> is ignored, and can be used as comment
7163 to clarify complicated nestings.
7164 </para>
7165 </section>
7166 <section id="SECTcos">
7167 <title>Common option syntax</title>
7168 <para>
7169 <indexterm role="concept">
7170 <primary>common option syntax</primary>
7171 </indexterm>
7172 <indexterm role="concept">
7173 <primary>syntax of common options</primary>
7174 </indexterm>
7175 <indexterm role="concept">
7176 <primary>configuration file</primary>
7177 <secondary>common option syntax</secondary>
7178 </indexterm>
7179 For the main set of options, driver options, and <function>local_scan()</function> options,
7180 each setting is on a line by itself, and starts with a name consisting of
7181 lower-case letters and underscores. Many options require a data value, and in
7182 these cases the name must be followed by an equals sign (with optional white
7183 space) and then the value. For example:
7184 </para>
7185 <literallayout class="monospaced">
7186 qualify_domain = mydomain.example.com
7187 </literallayout>
7188 <para>
7189 Some option settings may contain sensitive data, for example, passwords for
7190 accessing databases. To stop non-admin users from using the <option>-bP</option> command
7191 line option to read these values, you can precede the option settings with the
7192 word <quote>hide</quote>. For example:
7193 </para>
7194 <literallayout class="monospaced">
7195 hide mysql_servers = localhost/users/admin/secret-password
7196 </literallayout>
7197 <para>
7198 For non-admin users, such options are displayed like this:
7199 </para>
7200 <literallayout class="monospaced">
7201 mysql_servers = &lt;value not displayable&gt;
7202 </literallayout>
7203 <para>
7204 If <quote>hide</quote> is used on a driver option, it hides the value of that option on
7205 all instances of the same driver.
7206 </para>
7207 <para>
7208 The following sections describe the syntax used for the different data types
7209 that are found in option settings.
7210 </para>
7211 </section>
7212 <section>
7213 <title>Boolean options</title>
7214 <para>
7215 <indexterm role="concept">
7216 <primary>format</primary>
7217 <secondary>boolean</secondary>
7218 </indexterm>
7219 <indexterm role="concept">
7220 <primary>boolean configuration values</primary>
7221 </indexterm>
7222 <indexterm role="option">
7223 <primary><option>no_</option><emphasis>xxx</emphasis></primary>
7224 </indexterm>
7225 <indexterm role="option">
7226 <primary><option>not_</option><emphasis>xxx</emphasis></primary>
7227 </indexterm>
7228 Options whose type is given as boolean are on/off switches. There are two
7229 different ways of specifying such options: with and without a data value. If
7230 the option name is specified on its own without data, the switch is turned on;
7231 if it is preceded by <quote>no_</quote> or <quote>not_</quote> the switch is turned off. However,
7232 boolean options may be followed by an equals sign and one of the words
7233 <quote>true</quote>, <quote>false</quote>, <quote>yes</quote>, or <quote>no</quote>, as an alternative syntax. For example,
7234 the following two settings have exactly the same effect:
7235 </para>
7236 <literallayout class="monospaced">
7237 queue_only
7238 queue_only = true
7239 </literallayout>
7240 <para>
7241 The following two lines also have the same (opposite) effect:
7242 </para>
7243 <literallayout class="monospaced">
7244 no_queue_only
7245 queue_only = false
7246 </literallayout>
7247 <para>
7248 You can use whichever syntax you prefer.
7249 </para>
7250 </section>
7251 <section>
7252 <title>Integer values</title>
7253 <para>
7254 <indexterm role="concept">
7255 <primary>integer configuration values</primary>
7256 </indexterm>
7257 <indexterm role="concept">
7258 <primary>format</primary>
7259 <secondary>integer</secondary>
7260 </indexterm>
7261 If an integer data item starts with the characters <quote>0x</quote>, the remainder of it
7262 is interpreted as a hexadecimal number. Otherwise, it is treated as octal if it
7263 starts with the digit 0, and decimal if not. If an integer value is followed by
7264 the letter K, it is multiplied by 1024; if it is followed by the letter M, it
7265 is multiplied by 1024x1024.
7266 </para>
7267 <para>
7268 When the values of integer option settings are output, values which are an
7269 exact multiple of 1024 or 1024x1024 are
7270 sometimes, but not always,
7271 printed using the letters K and M. The printing style is independent of the
7272 actual input format that was used.
7273 </para>
7274 </section>
7275 <section>
7276 <title>Octal integer values</title>
7277 <para>
7278 <indexterm role="concept">
7279 <primary>integer format</primary>
7280 </indexterm>
7281 <indexterm role="concept">
7282 <primary>format</primary>
7283 <secondary>octal integer</secondary>
7284 </indexterm>
7285 The value of an option specified as an octal integer is always interpreted in
7286 octal, whether or not it starts with the digit zero. Such options are always
7287 output in octal.
7288 </para>
7289 </section>
7290 <section>
7291 <title>Fixed point number values</title>
7292 <para>
7293 <indexterm role="concept">
7294 <primary>fixed point configuration values</primary>
7295 </indexterm>
7296 <indexterm role="concept">
7297 <primary>format</primary>
7298 <secondary>fixed point</secondary>
7299 </indexterm>
7300 A fixed point number consists of a decimal integer, optionally followed by a
7301 decimal point and up to three further digits.
7302 </para>
7303 </section>
7304 <section id="SECTtimeformat">
7305 <title>Time interval values</title>
7306 <para>
7307 <indexterm role="concept">
7308 <primary>time interval</primary>
7309 <secondary>specifying in configuration</secondary>
7310 </indexterm>
7311 <indexterm role="concept">
7312 <primary>format</primary>
7313 <secondary>time interval</secondary>
7314 </indexterm>
7315 A time interval is specified as a sequence of numbers, each followed by one of
7316 the following letters, with no intervening white space:
7317 </para>
7318 <informaltable frame="none">
7319 <tgroup cols="2" colsep="0" rowsep="0">
7320 <colspec colwidth="50pt" align="left"/>
7321 <colspec colwidth="260pt" align="left"/>
7322 <tbody>
7323 <row>
7324 <entry>&nbsp;<option>s</option></entry>
7325 <entry>seconds</entry>
7326 </row>
7327 <row>
7328 <entry>&nbsp;<option>m</option></entry>
7329 <entry>minutes</entry>
7330 </row>
7331 <row>
7332 <entry>&nbsp;<option>h</option></entry>
7333 <entry>hours</entry>
7334 </row>
7335 <row>
7336 <entry>&nbsp;<option>d</option></entry>
7337 <entry>days</entry>
7338 </row>
7339 <row>
7340 <entry>&nbsp;<option>w</option></entry>
7341 <entry>weeks</entry>
7342 </row>
7343 </tbody>
7344 </tgroup>
7345 </informaltable>
7346 <para>
7347 For example, <quote>3h50m</quote> specifies 3 hours and 50 minutes. The values of time
7348 intervals are output in the same format. Exim does not restrict the values; it
7349 is perfectly acceptable, for example, to specify <quote>90m</quote> instead of <quote>1h30m</quote>.
7350 </para>
7351 </section>
7352 <section id="SECTstrings">
7353 <title>String values</title>
7354 <para>
7355 <indexterm role="concept">
7356 <primary>string</primary>
7357 <secondary>format of configuration values</secondary>
7358 </indexterm>
7359 <indexterm role="concept">
7360 <primary>format</primary>
7361 <secondary>string</secondary>
7362 </indexterm>
7363 If a string data item does not start with a double-quote character, it is taken
7364 as consisting of the remainder of the line plus any continuation lines,
7365 starting at the first character after any leading white space, with trailing
7366 white space removed, and with no interpretation of the characters in the
7367 string. Because Exim removes comment lines (those beginning with #) at an early
7368 stage, they can appear in the middle of a multi-line string. The following
7369 settings are therefore equivalent:
7370 </para>
7371 <literallayout class="monospaced">
7372 trusted_users = uucp:mail
7373
7374 trusted_users = uucp:\
7375                 # This comment line is ignored
7376                 mail
7377 </literallayout>
7378 <para>
7379 <indexterm role="concept">
7380 <primary>string</primary>
7381 <secondary>quoted</secondary>
7382 </indexterm>
7383 <indexterm role="concept">
7384 <primary>escape characters in quoted strings</primary>
7385 </indexterm>
7386 If a string does start with a double-quote, it must end with a closing
7387 double-quote, and any backslash characters other than those used for line
7388 continuation are interpreted as escape characters, as follows:
7389 </para>
7390 <informaltable frame="none">
7391 <tgroup cols="2" colsep="0" rowsep="0">
7392 <colspec colwidth="100pt" align="left"/>
7393 <colspec colwidth="260pt" align="left"/>
7394 <tbody>
7395 <row>
7396 <entry>&nbsp;<literal>\\</literal></entry>
7397 <entry>single backslash</entry>
7398 </row>
7399 <row>
7400 <entry>&nbsp;<literal>\n</literal></entry>
7401 <entry>newline</entry>
7402 </row>
7403 <row>
7404 <entry>&nbsp;<literal>\r</literal></entry>
7405 <entry>carriage return</entry>
7406 </row>
7407 <row>
7408 <entry>&nbsp;<literal>\t</literal></entry>
7409 <entry>tab</entry>
7410 </row>
7411 <row>
7412 <entry>&nbsp;<literal>\</literal>&lt;<emphasis>octal digits</emphasis>&gt;</entry>
7413 <entry>up to 3 octal digits specify one character</entry>
7414 </row>
7415 <row>
7416 <entry>&nbsp;<literal>\x</literal>&lt;<emphasis>hex digits</emphasis>&gt;</entry>
7417 <entry>up to 2 hexadecimal digits specify one character</entry>
7418 </row>
7419 </tbody>
7420 </tgroup>
7421 </informaltable>
7422 <para>
7423 If a backslash is followed by some other character, including a double-quote
7424 character, that character replaces the pair.
7425 </para>
7426 <para>
7427 Quoting is necessary only if you want to make use of the backslash escapes to
7428 insert special characters, or if you need to specify a value with leading or
7429 trailing spaces. These cases are rare, so quoting is almost never needed in
7430 current versions of Exim. In versions of Exim before 3.14, quoting was required
7431 in order to continue lines, so you may come across older configuration files
7432 and examples that apparently quote unnecessarily.
7433 </para>
7434 </section>
7435 <section>
7436 <title>Expanded strings</title>
7437 <para>
7438 <indexterm role="concept">
7439 <primary>string expansion</primary>
7440 <secondary>definition of</secondary>
7441 </indexterm>
7442 <indexterm role="concept">
7443 <primary>expansion</primary>
7444 <secondary>definition of</secondary>
7445 </indexterm>
7446 Some strings in the configuration file are subjected to <emphasis>string expansion</emphasis>,
7447 by which means various parts of the string may be changed according to the
7448 circumstances (see chapter <xref linkend="CHAPexpand"/>). The input syntax for such strings
7449 is as just described; in particular, the handling of backslashes in quoted
7450 strings is done as part of the input process, before expansion takes place.
7451 However, backslash is also an escape character for the expander, so any
7452 backslashes that are required for that reason must be doubled if they are
7453 within a quoted configuration string.
7454 </para>
7455 </section>
7456 <section>
7457 <title>User and group names</title>
7458 <para>
7459 <indexterm role="concept">
7460 <primary>user name</primary>
7461 <secondary>format of</secondary>
7462 </indexterm>
7463 <indexterm role="concept">
7464 <primary>format</primary>
7465 <secondary>user name</secondary>
7466 </indexterm>
7467 <indexterm role="concept">
7468 <primary>group</primary>
7469 <secondary>name format</secondary>
7470 </indexterm>
7471 <indexterm role="concept">
7472 <primary>format</primary>
7473 <secondary>group name</secondary>
7474 </indexterm>
7475 User and group names are specified as strings, using the syntax described
7476 above, but the strings are interpreted specially. A user or group name must
7477 either consist entirely of digits, or be a name that can be looked up using the
7478 <function>getpwnam()</function> or <function>getgrnam()</function> function, as appropriate.
7479 </para>
7480 </section>
7481 <section id="SECTlistconstruct">
7482 <title>List construction</title>
7483 <para>
7484 <indexterm role="concept">
7485 <primary>list</primary>
7486 <secondary>syntax of in configuration</secondary>
7487 </indexterm>
7488 <indexterm role="concept">
7489 <primary>format</primary>
7490 <secondary>list item in configuration</secondary>
7491 </indexterm>
7492 <indexterm role="concept">
7493 <primary>string list</primary>
7494 <secondary>definition</secondary>
7495 </indexterm>
7496 The data for some configuration options is a list of items, with colon as the
7497 default separator. Many of these options are shown with type <quote>string list</quote> in
7498 the descriptions later in this document. Others are listed as <quote>domain list</quote>,
7499 <quote>host list</quote>, <quote>address list</quote>, or <quote>local part list</quote>. Syntactically, they
7500 are all the same; however, those other than <quote>string list</quote> are subject to
7501 particular kinds of interpretation, as described in chapter
7502 <xref linkend="CHAPdomhosaddlists"/>.
7503 </para>
7504 <para>
7505 In all these cases, the entire list is treated as a single string as far as the
7506 input syntax is concerned. The <option>trusted_users</option> setting in section
7507 <xref linkend="SECTstrings"/> above is an example. If a colon is actually needed in an item
7508 in a list, it must be entered as two colons. Leading and trailing white space
7509 on each item in a list is ignored. This makes it possible to include items that
7510 start with a colon, and in particular, certain forms of IPv6 address. For
7511 example, the list
7512 </para>
7513 <literallayout class="monospaced">
7514 local_interfaces = 127.0.0.1 : ::::1
7515 </literallayout>
7516 <para>
7517 contains two IP addresses, the IPv4 address 127.0.0.1 and the IPv6 address ::1.
7518 </para>
7519 <para>
7520 <emphasis role="bold">Note</emphasis>: Although leading and trailing white space is ignored in individual
7521 list items, it is not ignored when parsing the list. The space after the first
7522 colon in the example above is necessary. If it were not there, the list would
7523 be interpreted as the two items 127.0.0.1:: and 1.
7524 </para>
7525 <para>
7526 <indexterm role="concept">
7527 <primary>list separator</primary>
7528 <secondary>changing</secondary>
7529 </indexterm>
7530 <indexterm role="concept">
7531 <primary>IPv6</primary>
7532 <secondary>addresses in lists</secondary>
7533 </indexterm>
7534 Doubling colons in IPv6 addresses is an unwelcome chore, so a mechanism was
7535 introduced to allow the separator character to be changed. If a list begins
7536 with a left angle bracket, followed by any punctuation character, that
7537 character is used instead of colon as the list separator. For example, the list
7538 above can be rewritten to use a semicolon separator like this:
7539 </para>
7540 <literallayout class="monospaced">
7541 local_interfaces = &lt;; 127.0.0.1 ; ::1
7542 </literallayout>
7543 <para>
7544 This facility applies to all lists, with the exception of the list in
7545 <option>log_file_path</option>. It is recommended that the use of non-colon separators be
7546 confined to circumstances where they really are needed.
7547 </para>
7548 </section>
7549 <section id="SECTempitelis">
7550 <title>Empty items in lists</title>
7551 <para>
7552 <indexterm role="concept">
7553 <primary>list</primary>
7554 <secondary>empty item in</secondary>
7555 </indexterm>
7556 An empty item at the end of a list is always ignored. In other words, trailing
7557 separator characters are ignored. Thus, the list in
7558 </para>
7559 <literallayout class="monospaced">
7560 senders = user@domain :
7561 </literallayout>
7562 <para>
7563 contains only a single item. If you want to include an empty string as one item
7564 in a list, it must not be the last item. For example, this list contains three
7565 items, the second of which is empty:
7566 </para>
7567 <literallayout class="monospaced">
7568 senders = user1@domain : : user2@domain
7569 </literallayout>
7570 <para>
7571 <emphasis role="bold">Note</emphasis>: There must be white space between the two colons, as otherwise they
7572 are interpreted as representing a single colon data character (and the list
7573 would then contain just one item). If you want to specify a list that contains
7574 just one, empty item, you can do it as in this example:
7575 </para>
7576 <literallayout class="monospaced">
7577 senders = :
7578 </literallayout>
7579 <para>
7580 In this case, the first item is empty, and the second is discarded because it
7581 is at the end of the list.
7582 </para>
7583 </section>
7584 <section id="SECTfordricon">
7585 <title>Format of driver configurations</title>
7586 <para>
7587 <indexterm role="concept">
7588 <primary>drivers</primary>
7589 <secondary>configuration format</secondary>
7590 </indexterm>
7591 There are separate parts in the configuration for defining routers, transports,
7592 and authenticators. In each part, you are defining a number of driver
7593 instances, each with its own set of options. Each driver instance is defined by
7594 a sequence of lines like this:
7595 </para>
7596 <literallayout>
7597 &lt;<emphasis>instance name</emphasis>&gt;:
7598   &lt;<emphasis>option</emphasis>&gt;
7599   ...
7600   &lt;<emphasis>option</emphasis>&gt;
7601 </literallayout>
7602 <para>
7603 In the following example, the instance name is <command>localuser</command>, and it is
7604 followed by three options settings:
7605 </para>
7606 <literallayout class="monospaced">
7607 localuser:
7608   driver = accept
7609   check_local_user
7610   transport = local_delivery
7611 </literallayout>
7612 <para>
7613 For each driver instance, you specify which Exim code module it uses &ndash; by the
7614 setting of the <option>driver</option> option &ndash; and (optionally) some configuration
7615 settings. For example, in the case of transports, if you want a transport to
7616 deliver with SMTP you would use the <command>smtp</command> driver; if you want to deliver to
7617 a local file you would use the <command>appendfile</command> driver. Each of the drivers is
7618 described in detail in its own separate chapter later in this manual.
7619 </para>
7620 <para>
7621 You can have several routers, transports, or authenticators that are based on
7622 the same underlying driver (each must have a different instance name).
7623 </para>
7624 <para>
7625 The order in which routers are defined is important, because addresses are
7626 passed to individual routers one by one, in order. The order in which
7627 transports are defined does not matter at all. The order in which
7628 authenticators are defined is used only when Exim, as a client, is searching
7629 them to find one that matches an authentication mechanism offered by the
7630 server.
7631 </para>
7632 <para>
7633 <indexterm role="concept">
7634 <primary>generic options</primary>
7635 </indexterm>
7636 <indexterm role="concept">
7637 <primary>options</primary>
7638 <secondary>generic &ndash; definition of</secondary>
7639 </indexterm>
7640 Within a driver instance definition, there are two kinds of option: <emphasis>generic</emphasis>
7641 and <emphasis>private</emphasis>. The generic options are those that apply to all drivers of the
7642 same type (that is, all routers, all transports or all authenticators). The
7643 <option>driver</option> option is a generic option that must appear in every definition.
7644 <indexterm role="concept">
7645 <primary>private options</primary>
7646 </indexterm>
7647 The private options are special for each driver, and none need appear, because
7648 they all have default values.
7649 </para>
7650 <para>
7651 The options may appear in any order, except that the <option>driver</option> option must
7652 precede any private options, since these depend on the particular driver. For
7653 this reason, it is recommended that <option>driver</option> always be the first option.
7654 </para>
7655 <para>
7656 Driver instance names, which are used for reference in log entries and
7657 elsewhere, can be any sequence of letters, digits, and underscores (starting
7658 with a letter) and must be unique among drivers of the same type. A router and
7659 a transport (for example) can each have the same name, but no two router
7660 instances can have the same name. The name of a driver instance should not be
7661 confused with the name of the underlying driver module. For example, the
7662 configuration lines:
7663 </para>
7664 <literallayout class="monospaced">
7665 remote_smtp:
7666   driver = smtp
7667 </literallayout>
7668 <para>
7669 create an instance of the <command>smtp</command> transport driver whose name is
7670 <command>remote_smtp</command>. The same driver code can be used more than once, with
7671 different instance names and different option settings each time. A second
7672 instance of the <command>smtp</command> transport, with different options, might be defined
7673 thus:
7674 </para>
7675 <literallayout class="monospaced">
7676 special_smtp:
7677   driver = smtp
7678   port = 1234
7679   command_timeout = 10s
7680 </literallayout>
7681 <para>
7682 The names <command>remote_smtp</command> and <command>special_smtp</command> would be used to reference
7683 these transport instances from routers, and these names would appear in log
7684 lines.
7685 </para>
7686 <para>
7687 Comment lines may be present in the middle of driver specifications. The full
7688 list of option settings for any particular driver instance, including all the
7689 defaulted values, can be extracted by making use of the <option>-bP</option> command line
7690 option.
7691 </para>
7692 </section>
7693 </chapter>
7694
7695 <chapter id="CHAPdefconfil">
7696 <title>The default configuration file</title>
7697 <para>
7698 <indexterm role="concept" id="IIDconfiwal" class="startofrange">
7699 <primary>configuration file</primary>
7700 <secondary>default <quote>walk through</quote></secondary>
7701 </indexterm>
7702 <indexterm role="concept">
7703 <primary>default</primary>
7704 <secondary>configuration file <quote>walk through</quote></secondary>
7705 </indexterm>
7706 The default configuration file supplied with Exim as <filename>src/configure.default</filename>
7707 is sufficient for a host with simple mail requirements. As an introduction to
7708 the way Exim is configured, this chapter <quote>walks through</quote> the default
7709 configuration, giving brief explanations of the settings. Detailed descriptions
7710 of the options are given in subsequent chapters. The default configuration file
7711 itself contains extensive comments about ways you might want to modify the
7712 initial settings. However, note that there are many options that are not
7713 mentioned at all in the default configuration.
7714 </para>
7715 <section>
7716 <title>Main configuration settings</title>
7717 <para>
7718 The main (global) configuration option settings must always come first in the
7719 file. The first thing you&#x2019;ll see in the file, after some initial comments, is
7720 the line
7721 </para>
7722 <literallayout class="monospaced">
7723 # primary_hostname =
7724 </literallayout>
7725 <para>
7726 This is a commented-out setting of the <option>primary_hostname</option> option. Exim needs
7727 to know the official, fully qualified name of your host, and this is where you
7728 can specify it. However, in most cases you do not need to set this option. When
7729 it is unset, Exim uses the <function>uname()</function> system function to obtain the host name.
7730 </para>
7731 <para>
7732 The first three non-comment configuration lines are as follows:
7733 </para>
7734 <literallayout class="monospaced">
7735 domainlist local_domains = @
7736 domainlist relay_to_domains =
7737 hostlist   relay_from_hosts = 127.0.0.1
7738 </literallayout>
7739 <para>
7740 These are not, in fact, option settings. They are definitions of two named
7741 domain lists and one named host list. Exim allows you to give names to lists of
7742 domains, hosts, and email addresses, in order to make it easier to manage the
7743 configuration file (see section <xref linkend="SECTnamedlists"/>).
7744 </para>
7745 <para>
7746 The first line defines a domain list called <emphasis>local_domains</emphasis>; this is used
7747 later in the configuration to identify domains that are to be delivered
7748 on the local host.
7749 </para>
7750 <para>
7751 <indexterm role="concept">
7752 <primary>@ in a domain list</primary>
7753 </indexterm>
7754 There is just one item in this list, the string <quote>@</quote>. This is a special form
7755 of entry which means <quote>the name of the local host</quote>. Thus, if the local host is
7756 called <emphasis>a.host.example</emphasis>, mail to <emphasis>any.user@a.host.example</emphasis> is expected to
7757 be delivered locally. Because the local host&#x2019;s name is referenced indirectly,
7758 the same configuration file can be used on different hosts.
7759 </para>
7760 <para>
7761 The second line defines a domain list called <emphasis>relay_to_domains</emphasis>, but the
7762 list itself is empty. Later in the configuration we will come to the part that
7763 controls mail relaying through the local host; it allows relaying to any
7764 domains in this list. By default, therefore, no relaying on the basis of a mail
7765 domain is permitted.
7766 </para>
7767 <para>
7768 The third line defines a host list called <emphasis>relay_from_hosts</emphasis>. This list is
7769 used later in the configuration to permit relaying from any host or IP address
7770 that matches the list. The default contains just the IP address of the IPv4
7771 loopback interface, which means that processes on the local host are able to
7772 submit mail for relaying by sending it over TCP/IP to that interface. No other
7773 hosts are permitted to submit messages for relaying.
7774 </para>
7775 <para>
7776 Just to be sure there&#x2019;s no misunderstanding: at this point in the configuration
7777 we aren&#x2019;t actually setting up any controls. We are just defining some domains
7778 and hosts that will be used in the controls that are specified later.
7779 </para>
7780 <para>
7781 The next two configuration lines are genuine option settings:
7782 </para>
7783 <literallayout class="monospaced">
7784 acl_smtp_rcpt = acl_check_rcpt
7785 acl_smtp_data = acl_check_data
7786 </literallayout>
7787 <para>
7788 These options specify <emphasis>Access Control Lists</emphasis> (ACLs) that are to be used
7789 during an incoming SMTP session for every recipient of a message (every RCPT
7790 command), and after the contents of the message have been received,
7791 respectively. The names of the lists are <emphasis>acl_check_rcpt</emphasis> and
7792 <emphasis>acl_check_data</emphasis>, and we will come to their definitions below, in the ACL
7793 section of the configuration. The RCPT ACL controls which recipients are
7794 accepted for an incoming message &ndash; if a configuration does not provide an ACL
7795 to check recipients, no SMTP mail can be accepted. The DATA ACL allows the
7796 contents of a message to be checked.
7797 </para>
7798 <para>
7799 Two commented-out option settings are next:
7800 </para>
7801 <literallayout class="monospaced">
7802 # av_scanner = clamd:/tmp/clamd
7803 # spamd_address = 127.0.0.1 783
7804 </literallayout>
7805 <para>
7806 These are example settings that can be used when Exim is compiled with the
7807 content-scanning extension. The first specifies the interface to the virus
7808 scanner, and the second specifies the interface to SpamAssassin. Further
7809 details are given in chapter <xref linkend="CHAPexiscan"/>.
7810 </para>
7811 <para>
7812 Two more commented-out options settings follow:
7813 </para>
7814 <literallayout class="monospaced">
7815 # qualify_domain =
7816 # qualify_recipient =
7817 </literallayout>
7818 <para>
7819 The first of these specifies a domain that Exim uses when it constructs a
7820 complete email address from a local login name. This is often needed when Exim
7821 receives a message from a local process. If you do not set <option>qualify_domain</option>,
7822 the value of <option>primary_hostname</option> is used. If you set both of these options,
7823 you can have different qualification domains for sender and recipient
7824 addresses. If you set only the first one, its value is used in both cases.
7825 </para>
7826 <para>
7827 <indexterm role="concept">
7828 <primary>domain literal</primary>
7829 <secondary>recognizing format</secondary>
7830 </indexterm>
7831 The following line must be uncommented if you want Exim to recognize
7832 addresses of the form <emphasis>user@[10.11.12.13]</emphasis> that is, with a <quote>domain literal</quote>
7833 (an IP address within square brackets) instead of a named domain.
7834 </para>
7835 <literallayout class="monospaced">
7836 # allow_domain_literals
7837 </literallayout>
7838 <para>
7839 The RFCs still require this form, but many people think that in the modern
7840 Internet it makes little sense to permit mail to be sent to specific hosts by
7841 quoting their IP addresses. This ancient format has been used by people who
7842 try to abuse hosts by using them for unwanted relaying. However, some
7843 people believe there are circumstances (for example, messages addressed to
7844 <emphasis>postmaster</emphasis>) where domain literals are still useful.
7845 </para>
7846 <para>
7847 The next configuration line is a kind of trigger guard:
7848 </para>
7849 <literallayout class="monospaced">
7850 never_users = root
7851 </literallayout>
7852 <para>
7853 It specifies that no delivery must ever be run as the root user. The normal
7854 convention is to set up <emphasis>root</emphasis> as an alias for the system administrator. This
7855 setting is a guard against slips in the configuration.
7856 The list of users specified by <option>never_users</option> is not, however, the complete
7857 list; the build-time configuration in <filename>Local/Makefile</filename> has an option called
7858 FIXED_NEVER_USERS specifying a list that cannot be overridden. The
7859 contents of <option>never_users</option> are added to this list. By default
7860 FIXED_NEVER_USERS also specifies root.
7861 </para>
7862 <para>
7863 When a remote host connects to Exim in order to send mail, the only information
7864 Exim has about the host&#x2019;s identity is its IP address. The next configuration
7865 line,
7866 </para>
7867 <literallayout class="monospaced">
7868 host_lookup = *
7869 </literallayout>
7870 <para>
7871 specifies that Exim should do a reverse DNS lookup on all incoming connections,
7872 in order to get a host name. This improves the quality of the logging
7873 information, but if you feel it is too expensive, you can remove it entirely,
7874 or restrict the lookup to hosts on <quote>nearby</quote> networks.
7875 Note that it is not always possible to find a host name from an IP address,
7876 because not all DNS reverse zones are maintained, and sometimes DNS servers are
7877 unreachable.
7878 </para>
7879 <para>
7880 The next two lines are concerned with <emphasis>ident</emphasis> callbacks, as defined by RFC
7881 1413 (hence their names):
7882 </para>
7883 <literallayout class="monospaced">
7884 rfc1413_hosts = *
7885 rfc1413_query_timeout = 30s
7886 </literallayout>
7887 <para>
7888 These settings cause Exim to make ident callbacks for all incoming SMTP calls.
7889 You can limit the hosts to which these calls are made, or change the timeout
7890 that is used. If you set the timeout to zero, all ident calls are disabled.
7891 Although they are cheap and can provide useful information for tracing problem
7892 messages, some hosts and firewalls have problems with ident calls. This can
7893 result in a timeout instead of an immediate refused connection, leading to
7894 delays on starting up an incoming SMTP session.
7895 </para>
7896 <para>
7897 When Exim receives messages over SMTP connections, it expects all addresses to
7898 be fully qualified with a domain, as required by the SMTP definition. However,
7899 if you are running a server to which simple clients submit messages, you may
7900 find that they send unqualified addresses. The two commented-out options:
7901 </para>
7902 <literallayout class="monospaced">
7903 # sender_unqualified_hosts =
7904 # recipient_unqualified_hosts =
7905 </literallayout>
7906 <para>
7907 show how you can specify hosts that are permitted to send unqualified sender
7908 and recipient addresses, respectively.
7909 </para>
7910 <para>
7911 The <option>percent_hack_domains</option> option is also commented out:
7912 </para>
7913 <literallayout class="monospaced">
7914 # percent_hack_domains =
7915 </literallayout>
7916 <para>
7917 It provides a list of domains for which the <quote>percent hack</quote> is to operate.
7918 This is an almost obsolete form of explicit email routing. If you do not know
7919 anything about it, you can safely ignore this topic.
7920 </para>
7921 <para>
7922 The last two settings in the main part of the default configuration are
7923 concerned with messages that have been <quote>frozen</quote> on Exim&#x2019;s queue. When a
7924 message is frozen, Exim no longer continues to try to deliver it. Freezing
7925 occurs when a bounce message encounters a permanent failure because the sender
7926 address of the original message that caused the bounce is invalid, so the
7927 bounce cannot be delivered. This is probably the most common case, but there
7928 are also other conditions that cause freezing, and frozen messages are not
7929 always bounce messages.
7930 </para>
7931 <literallayout class="monospaced">
7932 ignore_bounce_errors_after = 2d
7933 timeout_frozen_after = 7d
7934 </literallayout>
7935 <para>
7936 The first of these options specifies that failing bounce messages are to be
7937 discarded after 2 days on the queue. The second specifies that any frozen
7938 message (whether a bounce message or not) is to be timed out (and discarded)
7939 after a week. In this configuration, the first setting ensures that no failing
7940 bounce message ever lasts a week.
7941 </para>
7942 </section>
7943 <section>
7944 <title>ACL configuration</title>
7945 <para>
7946 <indexterm role="concept">
7947 <primary>default</primary>
7948 <secondary>ACLs</secondary>
7949 </indexterm>
7950 <indexterm role="concept">
7951 <primary>access control lists (ACLs)</primary>
7952 <secondary>default configuration</secondary>
7953 </indexterm>
7954 In the default configuration, the ACL section follows the main configuration.
7955 It starts with the line
7956 </para>
7957 <literallayout class="monospaced">
7958 begin acl
7959 </literallayout>
7960 <para>
7961 and it contains the definitions of two ACLs, called <emphasis>acl_check_rcpt</emphasis> and
7962 <emphasis>acl_check_data</emphasis>, that were referenced in the settings of <option>acl_smtp_rcpt</option>
7963 and <option>acl_smtp_data</option> above.
7964 </para>
7965 <para>
7966 <indexterm role="concept">
7967 <primary>RCPT</primary>
7968 <secondary>ACL for</secondary>
7969 </indexterm>
7970 The first ACL is used for every RCPT command in an incoming SMTP message. Each
7971 RCPT command specifies one of the message&#x2019;s recipients. The ACL statements
7972 are considered in order, until the recipient address is either accepted or
7973 rejected. The RCPT command is then accepted or rejected, according to the
7974 result of the ACL processing.
7975 </para>
7976 <literallayout class="monospaced">
7977 acl_check_rcpt:
7978 </literallayout>
7979 <para>
7980 This line, consisting of a name terminated by a colon, marks the start of the
7981 ACL, and names it.
7982 </para>
7983 <literallayout class="monospaced">
7984 accept  hosts = :
7985 </literallayout>
7986 <para>
7987 This ACL statement accepts the recipient if the sending host matches the list.
7988 But what does that strange list mean? It doesn&#x2019;t actually contain any host
7989 names or IP addresses. The presence of the colon puts an empty item in the
7990 list; Exim matches this only if the incoming message did not come from a remote
7991 host, because in that case, the remote hostname is empty. The colon is
7992 important. Without it, the list itself is empty, and can never match anything.
7993 </para>
7994 <para>
7995 What this statement is doing is to accept unconditionally all recipients in
7996 messages that are submitted by SMTP from local processes using the standard
7997 input and output (that is, not using TCP/IP). A number of MUAs operate in this
7998 manner.
7999 </para>
8000 <literallayout class="monospaced">
8001 deny    message       = Restricted characters in address
8002         domains       = +local_domains
8003         local_parts   = ^[.] : ^.*[@%!/|]
8004
8005 deny    message       = Restricted characters in address
8006         domains       = !+local_domains
8007         local_parts   = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
8008 </literallayout>
8009 <para>
8010 These statements are concerned with local parts that contain any of the
8011 characters <quote>@</quote>, <quote>%</quote>, <quote>!</quote>, <quote>/</quote>, <quote>|</quote>, or dots in unusual places.
8012 Although these characters are entirely legal in local parts (in the case of
8013 <quote>@</quote> and leading dots, only if correctly quoted), they do not commonly occur
8014 in Internet mail addresses.
8015 </para>
8016 <para>
8017 The first three have in the past been associated with explicitly routed
8018 addresses (percent is still sometimes used &ndash; see the <option>percent_hack_domains</option>
8019 option). Addresses containing these characters are regularly tried by spammers
8020 in an attempt to bypass relaying restrictions, and also by open relay testing
8021 programs. Unless you really need them it is safest to reject these characters
8022 at this early stage. This configuration is heavy-handed in rejecting these
8023 characters for all messages it accepts from remote hosts. This is a deliberate
8024 policy of being as safe as possible.
8025 </para>
8026 <para>
8027 The first rule above is stricter, and is applied to messages that are addressed
8028 to one of the local domains handled by this host. This is implemented by the
8029 first condition, which restricts it to domains that are listed in the
8030 <emphasis>local_domains</emphasis> domain list. The <quote>+</quote> character is used to indicate a
8031 reference to a named list. In this configuration, there is just one domain in
8032 <emphasis>local_domains</emphasis>, but in general there may be many.
8033 </para>
8034 <para>
8035 The second condition on the first statement uses two regular expressions to
8036 block local parts that begin with a dot or contain <quote>@</quote>, <quote>%</quote>, <quote>!</quote>, <quote>/</quote>,
8037 or <quote>|</quote>. If you have local accounts that include these characters, you will
8038 have to modify this rule.
8039 </para>
8040 <para>
8041 Empty components (two dots in a row) are not valid in RFC 2822, but Exim
8042 allows them because they have been encountered in practice. (Consider the
8043 common convention of local parts constructed as
8044 <quote><emphasis>first-initial.second-initial.family-name</emphasis></quote> when applied to someone like
8045 the author of Exim, who has no second initial.) However, a local part starting
8046 with a dot or containing <quote>/../</quote> can cause trouble if it is used as part of a
8047 file name (for example, for a mailing list). This is also true for local parts
8048 that contain slashes. A pipe symbol can also be troublesome if the local part
8049 is incorporated unthinkingly into a shell command line.
8050 </para>
8051 <para>
8052 The second rule above applies to all other domains, and is less strict. This
8053 allows your own users to send outgoing messages to sites that use slashes
8054 and vertical bars in their local parts. It blocks local parts that begin
8055 with a dot, slash, or vertical bar, but allows these characters within the
8056 local part. However, the sequence <quote>/../</quote> is barred. The use of <quote>@</quote>, <quote>%</quote>,
8057 and <quote>!</quote> is blocked, as before. The motivation here is to prevent your users
8058 (or your users&#x2019; viruses) from mounting certain kinds of attack on remote sites.
8059 </para>
8060 <literallayout class="monospaced">
8061 accept  local_parts   = postmaster
8062         domains       = +local_domains
8063 </literallayout>
8064 <para>
8065 This statement, which has two conditions, accepts an incoming address if the
8066 local part is <emphasis>postmaster</emphasis> and the domain is one of those listed in the
8067 <emphasis>local_domains</emphasis> domain list. The <quote>+</quote> character is used to indicate a
8068 reference to a named list. In this configuration, there is just one domain in
8069 <emphasis>local_domains</emphasis>, but in general there may be many.
8070 </para>
8071 <para>
8072 The presence of this statement means that mail to postmaster is never blocked
8073 by any of the subsequent tests. This can be helpful while sorting out problems
8074 in cases where the subsequent tests are incorrectly denying access.
8075 </para>
8076 <literallayout class="monospaced">
8077 require verify        = sender
8078 </literallayout>
8079 <para>
8080 This statement requires the sender address to be verified before any subsequent
8081 ACL statement can be used. If verification fails, the incoming recipient
8082 address is refused. Verification consists of trying to route the address, to
8083 see if a bounce message could be delivered to it. In the case of remote
8084 addresses, basic verification checks only the domain, but <emphasis>callouts</emphasis> can be
8085 used for more verification if required. Section <xref linkend="SECTaddressverification"/>
8086 discusses the details of address verification.
8087 </para>
8088 <literallayout class="monospaced">
8089 accept  hosts         = +relay_from_hosts
8090         control       = submission
8091 </literallayout>
8092 <para>
8093 This statement accepts the address if the message is coming from one of the
8094 hosts that are defined as being allowed to relay through this host. Recipient
8095 verification is omitted here, because in many cases the clients are dumb MUAs
8096 that do not cope well with SMTP error responses. For the same reason, the
8097 second line specifies <quote>submission mode</quote> for messages that are accepted. This
8098 is described in detail in section <xref linkend="SECTsubmodnon"/>; it causes Exim to fix
8099 messages that are deficient in some way, for example, because they lack a
8100 <emphasis>Date:</emphasis> header line. If you are actually relaying out from MTAs, you should
8101 probably add recipient verification here, and disable submission mode.
8102 </para>
8103 <literallayout class="monospaced">
8104 accept  authenticated = *
8105         control       = submission
8106 </literallayout>
8107 <para>
8108 This statement accepts the address if the client host has authenticated itself.
8109 Submission mode is again specified, on the grounds that such messages are most
8110 likely to come from MUAs. The default configuration does not define any
8111 authenticators, which means that no client can in fact authenticate. You will
8112 need to add authenticator definitions if you want to make use of this ACL
8113 statement.
8114 </para>
8115 <literallayout class="monospaced">
8116 # deny    message     = rejected because $sender_host_address \
8117 #                       is in a black list at $dnslist_domain\n\
8118 #                       $dnslist_text
8119 #         dnslists    = black.list.example
8120 #
8121 # warn    message     = X-Warning: $sender_host_address is \
8122 #                       in a black list at $dnslist_domain
8123 #         log_message = found in $dnslist_domain
8124 #         dnslists    = black.list.example
8125 </literallayout>
8126 <para>
8127 These commented-out lines are examples of how you could configure Exim to check
8128 sending hosts against a DNS black list. The first statement rejects messages
8129 from blacklisted hosts, whereas the second merely inserts a warning header
8130 line.
8131 </para>
8132 <literallayout class="monospaced">
8133 accept  domains       = +local_domains
8134         endpass
8135         verify        = recipient
8136 </literallayout>
8137 <para>
8138 This statement accepts the incoming recipient address if its domain is one of
8139 the local domains, but only if the address can be verified. Verification of
8140 local addresses normally checks both the local part and the domain. The
8141 <option>endpass</option> line needs some explanation: if the condition above <option>endpass</option>
8142 fails, that is, if the address is not in a local domain, control is passed to
8143 the next ACL statement. However, if the condition below <option>endpass</option> fails, that
8144 is, if a recipient in a local domain cannot be verified, access is denied and
8145 the recipient is rejected.
8146 </para>
8147 <literallayout class="monospaced">
8148 accept  domains       = +relay_to_domains
8149         endpass
8150         verify        = recipient
8151 </literallayout>
8152 <para>
8153 This statement accepts the incoming recipient address if its domain is one of
8154 the domains for which this host is a relay, but again, only if the address can
8155 be verified.
8156 </para>
8157 <literallayout class="monospaced">
8158 deny    message       = relay not permitted
8159 </literallayout>
8160 <para>
8161 The final statement denies access, giving a specific error message. Reaching
8162 the end of the ACL also causes access to be denied, but with the generic
8163 message <quote>administrative prohibition</quote>.
8164 </para>
8165 <literallayout class="monospaced">
8166 acl_check_data:
8167 </literallayout>
8168 <para>
8169 This line marks the start of the second ACL, and names it. Most of the contents
8170 of this ACL are commented out:
8171 </para>
8172 <literallayout class="monospaced">
8173 # deny    malware   = *
8174 #         message   = This message contains a virus \
8175 #                     ($malware_name).
8176 </literallayout>
8177 <para>
8178 These lines are examples of how to arrange for messages to be scanned for
8179 viruses when Exim has been compiled with the content-scanning extension, and a
8180 suitable virus scanner is installed. If the message is found to contain a
8181 virus, it is rejected with the given custom error message.
8182 </para>
8183 <literallayout class="monospaced">
8184 # warn    spam      = nobody
8185 #         message   = X-Spam_score: $spam_score\n\
8186 #                     X-Spam_score_int: $spam_score_int\n\
8187 #                     X-Spam_bar: $spam_bar\n\
8188 #                     X-Spam_report: $spam_report
8189 </literallayout>
8190 <para>
8191 These lines are an example of how to arrange for messages to be scanned by
8192 SpamAssassin when Exim has been compiled with the content-scanning extension,
8193 and SpamAssassin has been installed. The SpamAssassin check is run with
8194 <literal>nobody</literal> as its user parameter, and the results are added to the message as a
8195 series of extra header line. In this case, the message is not rejected,
8196 whatever the spam score.
8197 </para>
8198 <literallayout class="monospaced">
8199 accept
8200 </literallayout>
8201 <para>
8202 This final line in the DATA ACL accepts the message unconditionally.
8203 </para>
8204 </section>
8205 <section>
8206 <title>Router configuration</title>
8207 <para>
8208 <indexterm role="concept">
8209 <primary>default</primary>
8210 <secondary>routers</secondary>
8211 </indexterm>
8212 <indexterm role="concept">
8213 <primary>routers</primary>
8214 <secondary>default</secondary>
8215 </indexterm>
8216 The router configuration comes next in the default configuration, introduced
8217 by the line
8218 </para>
8219 <literallayout class="monospaced">
8220 begin routers
8221 </literallayout>
8222 <para>
8223 Routers are the modules in Exim that make decisions about where to send
8224 messages. An address is passed to each router in turn, until it is either
8225 accepted, or failed. This means that the order in which you define the routers
8226 matters. Each router is fully described in its own chapter later in this
8227 manual. Here we give only brief overviews.
8228 </para>
8229 <literallayout class="monospaced">
8230 # domain_literal:
8231 #   driver = ipliteral
8232 #   domains = !+local_domains
8233 #   transport = remote_smtp
8234 </literallayout>
8235 <para>
8236 <indexterm role="concept">
8237 <primary>domain literal</primary>
8238 <secondary>default router</secondary>
8239 </indexterm>
8240 This router is commented out because the majority of sites do not want to
8241 support domain literal addresses (those of the form <emphasis>user@[10.9.8.7]</emphasis>). If
8242 you uncomment this router, you also need to uncomment the setting of
8243 <option>allow_domain_literals</option> in the main part of the configuration.
8244 </para>
8245 <literallayout class="monospaced">
8246 dnslookup:
8247   driver = dnslookup
8248   domains = ! +local_domains
8249   transport = remote_smtp
8250   ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
8251   no_more
8252 </literallayout>
8253 <para>
8254 The first uncommented router handles addresses that do not involve any local
8255 domains. This is specified by the line
8256 </para>
8257 <literallayout class="monospaced">
8258 domains = ! +local_domains
8259 </literallayout>
8260 <para>
8261 The <option>domains</option> option lists the domains to which this router applies, but the
8262 exclamation mark is a negation sign, so the router is used only for domains
8263 that are not in the domain list called <emphasis>local_domains</emphasis> (which was defined at
8264 the start of the configuration). The plus sign before <emphasis>local_domains</emphasis>
8265 indicates that it is referring to a named list. Addresses in other domains are
8266 passed on to the following routers.
8267 </para>
8268 <para>
8269 The name of the router driver is <command>dnslookup</command>,
8270 and is specified by the <option>driver</option> option. Do not be confused by the fact that
8271 the name of this router instance is the same as the name of the driver. The
8272 instance name is arbitrary, but the name set in the <option>driver</option> option must be
8273 one of the driver modules that is in the Exim binary.
8274 </para>
8275 <para>
8276 The <command>dnslookup</command> router routes addresses by looking up their domains in the
8277 DNS in order to obtain a list of hosts to which the address is routed. If the
8278 router succeeds, the address is queued for the <command>remote_smtp</command> transport, as
8279 specified by the <option>transport</option> option. If the router does not find the domain
8280 in the DNS, no further routers are tried because of the <option>no_more</option> setting, so
8281 the address fails and is bounced.
8282 </para>
8283 <para>
8284 The <option>ignore_target_hosts</option> option specifies a list of IP addresses that are to
8285 be entirely ignored. This option is present because a number of cases have been
8286 encountered where MX records in the DNS point to host names
8287 whose IP addresses are 0.0.0.0 or are in the 127 subnet (typically 127.0.0.1).
8288 Completely ignoring these IP addresses causes Exim to fail to route the
8289 email address, so it bounces. Otherwise, Exim would log a routing problem, and
8290 continue to try to deliver the message periodically until the address timed
8291 out.
8292 </para>
8293 <literallayout class="monospaced">
8294 system_aliases:
8295   driver = redirect
8296   allow_fail
8297   allow_defer
8298   data = ${lookup{$local_part}lsearch{/etc/aliases}}
8299 # user = exim
8300   file_transport = address_file
8301   pipe_transport = address_pipe
8302 </literallayout>
8303 <para>
8304 Control reaches this and subsequent routers only for addresses in the local
8305 domains. This router checks to see whether the local part is defined as an
8306 alias in the <filename>/etc/aliases</filename> file, and if so, redirects it according to the
8307 data that it looks up from that file. If no data is found for the local part,
8308 the value of the <option>data</option> option is empty, causing the address to be passed to
8309 the next router.
8310 </para>
8311 <para>
8312 <filename>/etc/aliases</filename> is a conventional name for the system aliases file that is
8313 often used. That is why it is referenced by from the default configuration
8314 file. However, you can change this by setting SYSTEM_ALIASES_FILE in
8315 <filename>Local/Makefile</filename> before building Exim.
8316 </para>
8317 <literallayout class="monospaced">
8318 userforward:
8319   driver = redirect
8320   check_local_user
8321 # local_part_suffix = +* : -*
8322 # local_part_suffix_optional
8323   file = $home/.forward
8324 # allow_filter
8325   no_verify
8326   no_expn
8327   check_ancestor
8328   file_transport = address_file
8329   pipe_transport = address_pipe
8330   reply_transport = address_reply
8331 </literallayout>
8332 <para>
8333 This is the most complicated router in the default configuration. It is another
8334 redirection router, but this time it is looking for forwarding data set up by
8335 individual users. The <option>check_local_user</option> setting specifies a check that the
8336 local part of the address is the login name of a local user. If it is not, the
8337 router is skipped. The two commented options that follow <option>check_local_user</option>,
8338 namely:
8339 </para>
8340 <literallayout class="monospaced">
8341 # local_part_suffix = +* : -*
8342 # local_part_suffix_optional
8343 </literallayout>
8344 <para>
8345 <indexterm role="concept">
8346 <primary><varname>$local_part_suffix</varname></primary>
8347 </indexterm>
8348 show how you can specify the recognition of local part suffixes. If the first
8349 is uncommented, a suffix beginning with either a plus or a minus sign, followed
8350 by any sequence of characters, is removed from the local part and placed in the
8351 variable <varname>$local_part_suffix</varname>. The second suffix option specifies that the
8352 presence of a suffix in the local part is optional. When a suffix is present,
8353 the check for a local login uses the local part with the suffix removed.
8354 </para>
8355 <para>
8356 When a local user account is found, the file called <filename>.forward</filename> in the user&#x2019;s
8357 home directory is consulted. If it does not exist, or is empty, the router
8358 declines. Otherwise, the contents of <filename>.forward</filename> are interpreted as
8359 redirection data (see chapter <xref linkend="CHAPredirect"/> for more details).
8360 </para>
8361 <para>
8362 <indexterm role="concept">
8363 <primary>Sieve filter</primary>
8364 <secondary>enabling in default router</secondary>
8365 </indexterm>
8366 Traditional <filename>.forward</filename> files contain just a list of addresses, pipes, or
8367 files. Exim supports this by default. However, if <option>allow_filter</option> is set (it
8368 is commented out by default), the contents of the file are interpreted as a set
8369 of Exim or Sieve filtering instructions, provided the file begins with <quote>#Exim
8370 filter</quote> or <quote>#Sieve filter</quote>, respectively. User filtering is discussed in the
8371 separate document entitled <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis>.
8372 </para>
8373 <para>
8374 The <option>no_verify</option> and <option>no_expn</option> options mean that this router is skipped when
8375 verifying addresses, or when running as a consequence of an SMTP EXPN command.
8376 There are two reasons for doing this:
8377 </para>
8378 <orderedlist numeration="arabic">
8379 <listitem>
8380 <para>
8381 Whether or not a local user has a <filename>.forward</filename> file is not really relevant when
8382 checking an address for validity; it makes sense not to waste resources doing
8383 unnecessary work.
8384 </para>
8385 </listitem>
8386 <listitem>
8387 <para>
8388 More importantly, when Exim is verifying addresses or handling an EXPN
8389 command during an SMTP session, it is running as the Exim user, not as root.
8390 The group is the Exim group, and no additional groups are set up.
8391 It may therefore not be possible for Exim to read users&#x2019; <filename>.forward</filename> files at
8392 this time.
8393 </para>
8394 </listitem>
8395 </orderedlist>
8396 <para>
8397 The setting of <option>check_ancestor</option> prevents the router from generating a new
8398 address that is the same as any previous address that was redirected. (This
8399 works round a problem concerning a bad interaction between aliasing and
8400 forwarding &ndash; see section <xref linkend="SECTredlocmai"/>).
8401 </para>
8402 <para>
8403 The final three option settings specify the transports that are to be used when
8404 forwarding generates a direct delivery to a file, or to a pipe, or sets up an
8405 auto-reply, respectively. For example, if a <filename>.forward</filename> file contains
8406 </para>
8407 <literallayout class="monospaced">
8408 a.nother@elsewhere.example, /home/spqr/archive
8409 </literallayout>
8410 <para>
8411 the delivery to <filename>/home/spqr/archive</filename> is done by running the <option>address_file</option>
8412 transport.
8413 </para>
8414 <literallayout class="monospaced">
8415 localuser:
8416   driver = accept
8417   check_local_user
8418 # local_part_suffix = +* : -*
8419 # local_part_suffix_optional
8420   transport = local_delivery
8421 </literallayout>
8422 <para>
8423 The final router sets up delivery into local mailboxes, provided that the local
8424 part is the name of a local login, by accepting the address and assigning it to
8425 the <command>local_delivery</command> transport. Otherwise, we have reached the end of the
8426 routers, so the address is bounced. The commented suffix settings fulfil the
8427 same purpose as they do for the <command>userforward</command> router.
8428 </para>
8429 </section>
8430 <section>
8431 <title>Transport configuration</title>
8432 <para>
8433 <indexterm role="concept">
8434 <primary>default</primary>
8435 <secondary>transports</secondary>
8436 </indexterm>
8437 <indexterm role="concept">
8438 <primary>transports</primary>
8439 <secondary>default</secondary>
8440 </indexterm>
8441 Transports define mechanisms for actually delivering messages. They operate
8442 only when referenced from routers, so the order in which they are defined does
8443 not matter. The transports section of the configuration starts with
8444 </para>
8445 <literallayout class="monospaced">
8446 begin transports
8447 </literallayout>
8448 <para>
8449 One remote transport and four local transports are defined.
8450 </para>
8451 <literallayout class="monospaced">
8452 remote_smtp:
8453   driver = smtp
8454 </literallayout>
8455 <para>
8456 This transport is used for delivering messages over SMTP connections. All its
8457 options are defaulted. The list of remote hosts comes from the router.
8458 </para>
8459 <literallayout class="monospaced">
8460 local_delivery:
8461   driver = appendfile
8462   file = /var/mail/$local_part
8463   delivery_date_add
8464   envelope_to_add
8465   return_path_add
8466 # group = mail
8467 # mode = 0660
8468 </literallayout>
8469 <para>
8470 This <command>appendfile</command> transport is used for local delivery to user mailboxes in
8471 traditional BSD mailbox format. By default it runs under the uid and gid of the
8472 local user, which requires the sticky bit to be set on the <filename>/var/mail</filename>
8473 directory. Some systems use the alternative approach of running mail deliveries
8474 under a particular group instead of using the sticky bit. The commented options
8475 show how this can be done.
8476 </para>
8477 <para>
8478 Exim adds three headers to the message as it delivers it: <emphasis>Delivery-date:</emphasis>,
8479 <emphasis>Envelope-to:</emphasis> and <emphasis>Return-path:</emphasis>. This action is requested by the three
8480 similarly-named options above.
8481 </para>
8482 <literallayout class="monospaced">
8483 address_pipe:
8484   driver = pipe
8485   return_output
8486 </literallayout>
8487 <para>
8488 This transport is used for handling deliveries to pipes that are generated by
8489 redirection (aliasing or users&#x2019; <filename>.forward</filename> files). The <option>return_output</option>
8490 option specifies that any output generated by the pipe is to be returned to the
8491 sender.
8492 </para>
8493 <literallayout class="monospaced">
8494 address_file:
8495   driver = appendfile
8496   delivery_date_add
8497   envelope_to_add
8498   return_path_add
8499 </literallayout>
8500 <para>
8501 This transport is used for handling deliveries to files that are generated by
8502 redirection. The name of the file is not specified in this instance of
8503 <command>appendfile</command>, because it comes from the <command>redirect</command> router.
8504 </para>
8505 <literallayout class="monospaced">
8506 address_reply:
8507   driver = autoreply
8508 </literallayout>
8509 <para>
8510 This transport is used for handling automatic replies generated by users&#x2019;
8511 filter files.
8512 </para>
8513 </section>
8514 <section>
8515 <title>Default retry rule</title>
8516 <para>
8517 <indexterm role="concept">
8518 <primary>retry</primary>
8519 <secondary>default rule</secondary>
8520 </indexterm>
8521 <indexterm role="concept">
8522 <primary>default</primary>
8523 <secondary>retry rule</secondary>
8524 </indexterm>
8525 The retry section of the configuration file contains rules which affect the way
8526 Exim retries deliveries that cannot be completed at the first attempt. It is
8527 introduced by the line
8528 </para>
8529 <literallayout class="monospaced">
8530 begin retry
8531 </literallayout>
8532 <para>
8533 In the default configuration, there is just one rule, which applies to all
8534 errors:
8535 </para>
8536 <literallayout class="monospaced">
8537 *   *   F,2h,15m; G,16h,1h,1.5; F,4d,6h
8538 </literallayout>
8539 <para>
8540 This causes any temporarily failing address to be retried every 15 minutes for
8541 2 hours, then at intervals starting at one hour and increasing by a factor of
8542 1.5 until 16 hours have passed, then every 6 hours up to 4 days. If an address
8543 is not delivered after 4 days of temporary failure, it is bounced.
8544 </para>
8545 </section>
8546 <section>
8547 <title>Rewriting configuration</title>
8548 <para>
8549 The rewriting section of the configuration, introduced by
8550 </para>
8551 <literallayout class="monospaced">
8552 begin rewrite
8553 </literallayout>
8554 <para>
8555 contains rules for rewriting addresses in messages as they arrive. There are no
8556 rewriting rules in the default configuration file.
8557 </para>
8558 </section>
8559 <section>
8560 <title>Authenticators configuration</title>
8561 <para>
8562 <indexterm role="concept">
8563 <primary>AUTH</primary>
8564 <secondary>configuration</secondary>
8565 </indexterm>
8566 The authenticators section of the configuration, introduced by
8567 </para>
8568 <literallayout class="monospaced">
8569 begin authenticators
8570 </literallayout>
8571 <para>
8572 defines mechanisms for the use of the SMTP AUTH command. No authenticators
8573 are specified in the default configuration file.
8574 <indexterm role="concept" startref="IIDconfiwal" class="endofrange"/>
8575 </para>
8576 </section>
8577 </chapter>
8578
8579 <chapter id="CHAPregexp">
8580 <title>Regular expressions</title>
8581 <para>
8582 <indexterm role="concept">
8583 <primary>regular expressions</primary>
8584 <secondary>library</secondary>
8585 </indexterm>
8586 <indexterm role="concept">
8587 <primary>PCRE</primary>
8588 </indexterm>
8589 Exim supports the use of regular expressions in many of its options. It
8590 uses the PCRE regular expression library; this provides regular expression
8591 matching that is compatible with Perl 5. The syntax and semantics of
8592 regular expressions is discussed in many Perl reference books, and also in
8593 Jeffrey Friedl&#x2019;s <emphasis>Mastering Regular Expressions</emphasis>, which is published by
8594 O&#x2019;Reilly (see <emphasis role="bold"><ulink url="http://www.oreilly.com/catalog/regex2/">http://www.oreilly.com/catalog/regex2/</ulink></emphasis>).
8595 </para>
8596 <para>
8597 The documentation for the syntax and semantics of the regular expressions that
8598 are supported by PCRE is included in plain text in the file
8599 <filename>doc/pcrepattern.txt</filename> in the Exim distribution, and also in the HTML
8600 tarbundle of Exim documentation. It describes in detail the features of the
8601 regular expressions that PCRE supports, so no further description is included
8602 here. The PCRE functions are called from Exim using the default option settings
8603 (that is, with no PCRE options set), except that the PCRE_CASELESS option is
8604 set when the matching is required to be case-insensitive.
8605 </para>
8606 <para>
8607 In most cases, when a regular expression is required in an Exim configuration,
8608 it has to start with a circumflex, in order to distinguish it from plain text
8609 or an <quote>ends with</quote> wildcard. In this example of a configuration setting, the
8610 second item in the colon-separated list is a regular expression.
8611 </para>
8612 <literallayout class="monospaced">
8613 domains = a.b.c : ^\\d{3} : *.y.z : ...
8614 </literallayout>
8615 <para>
8616 The doubling of the backslash is required because of string expansion that
8617 precedes interpretation &ndash; see section <xref linkend="SECTlittext"/> for more discussion
8618 of this issue, and a way of avoiding the need for doubling backslashes. The
8619 regular expression that is eventually used in this example contains just one
8620 backslash. The circumflex is included in the regular expression, and has the
8621 normal effect of <quote>anchoring</quote> it to the start of the string that is being
8622 matched.
8623 </para>
8624 <para>
8625 There are, however, two cases where a circumflex is not required for the
8626 recognition of a regular expression: these are the <option>match</option> condition in a
8627 string expansion, and the <option>matches</option> condition in an Exim filter file. In
8628 these cases, the relevant string is always treated as a regular expression; if
8629 it does not start with a circumflex, the expression is not anchored, and can
8630 match anywhere in the subject string.
8631 </para>
8632 <para>
8633 In all cases, if you want a regular expression to match at the end of a string,
8634 you must code the $ metacharacter to indicate this. For example:
8635 </para>
8636 <literallayout class="monospaced">
8637 domains = ^\\d{3}\\.example
8638 </literallayout>
8639 <para>
8640 matches the domain <emphasis>123.example</emphasis>, but it also matches <emphasis>123.example.com</emphasis>.
8641 You need to use:
8642 </para>
8643 <literallayout class="monospaced">
8644 domains = ^\\d{3}\\.example\$
8645 </literallayout>
8646 <para>
8647 if you want <emphasis>example</emphasis> to be the top-level domain. The backslash before the
8648 $ is needed because string expansion also interprets dollar characters.
8649 </para>
8650 <section>
8651 <title>Testing regular expressions</title>
8652 <para>
8653 <indexterm role="concept">
8654 <primary>testing</primary>
8655 <secondary>regular expressions</secondary>
8656 </indexterm>
8657 <indexterm role="concept">
8658 <primary>regular expressions</primary>
8659 <secondary>testing</secondary>
8660 </indexterm>
8661 <indexterm role="concept">
8662 <primary><emphasis>pcretest</emphasis></primary>
8663 </indexterm>
8664 A program called <emphasis>pcretest</emphasis> forms part of the PCRE distribution and is built
8665 with PCRE during the process of building Exim. It is primarily intended for
8666 testing PCRE itself, but it can also be used for experimenting with regular
8667 expressions. After building Exim, the binary can be found in the build
8668 directory (it is not installed anywhere automatically). There is documentation
8669 of various options in <filename>doc/pcretest.txt</filename>, but for simple testing, none are
8670 needed. This is the output of a sample run of <emphasis>pcretest</emphasis>:
8671 </para>
8672 <literallayout>
8673 <literal>  re&gt; </literal><emphasis role="bold"><literal>/^([@]+)@.+\.(ac|edu)\.(?!kr)[a-z]{2}$/</literal></emphasis>
8674 <literal>data&gt; </literal><emphasis role="bold"><literal>x@y.ac.uk</literal></emphasis>
8675 <literal> 0: x@y.ac.uk</literal>
8676 <literal> 1: x</literal>
8677 <literal> 2: ac</literal>
8678 <literal>data&gt; </literal><emphasis role="bold"><literal>x@y.ac.kr</literal></emphasis>
8679 <literal>No match</literal>
8680 <literal>data&gt; </literal><emphasis role="bold"><literal>x@y.edu.com</literal></emphasis>
8681 <literal>No match</literal>
8682 <literal>data&gt; </literal><emphasis role="bold"><literal>x@y.edu.co</literal></emphasis>
8683 <literal> 0: x@y.edu.co</literal>
8684 <literal> 1: x</literal>
8685 <literal> 2: edu</literal>
8686 </literallayout>
8687 <para>
8688 Input typed by the user is shown in bold face. After the <quote>re&gt;</quote> prompt, a
8689 regular expression enclosed in delimiters is expected. If this compiles without
8690 error, <quote>data&gt;</quote> prompts are given for strings against which the expression is
8691 matched. An empty data line causes a new regular expression to be read. If the
8692 match is successful, the captured substring values (that is, what would be in
8693 the variables <varname>$0</varname>, <varname>$1</varname>, <varname>$2</varname>, etc.) are shown. The above example tests for
8694 an email address whose domain ends with either <quote>ac</quote> or <quote>edu</quote> followed by a
8695 two-character top-level domain that is not <quote>kr</quote>. The local part is captured
8696 in <varname>$1</varname> and the <quote>ac</quote> or <quote>edu</quote> in <varname>$2</varname>.
8697 </para>
8698 </section>
8699 </chapter>
8700
8701 <chapter id="CHAPfdlookup">
8702 <title>File and database lookups</title>
8703 <para>
8704 <indexterm role="concept" id="IIDfidalo1" class="startofrange">
8705 <primary>file</primary>
8706 <secondary>lookups</secondary>
8707 </indexterm>
8708 <indexterm role="concept" id="IIDfidalo2" class="startofrange">
8709 <primary>database lookups</primary>
8710 </indexterm>
8711 <indexterm role="concept">
8712 <primary>lookup</primary>
8713 <secondary>description of</secondary>
8714 </indexterm>
8715 Exim can be configured to look up data in files or databases as it processes
8716 messages. Two different kinds of syntax are used:
8717 </para>
8718 <orderedlist numeration="arabic">
8719 <listitem>
8720 <para>
8721 A string that is to be expanded may contain explicit lookup requests. These
8722 cause parts of the string to be replaced by data that is obtained from the
8723 lookup. Lookups of this type are conditional expansion items. Different results
8724 can be defined for the cases of lookup success and failure. See chapter
8725 <xref linkend="CHAPexpand"/>, where string expansions are described in detail.
8726 </para>
8727 </listitem>
8728 <listitem>
8729 <para>
8730 Lists of domains, hosts, and email addresses can contain lookup requests as a
8731 way of avoiding excessively long linear lists. In this case, the data that is
8732 returned by the lookup is often (but not always) discarded; whether the lookup
8733 succeeds or fails is what really counts. These kinds of list are described in
8734 chapter <xref linkend="CHAPdomhosaddlists"/>.
8735 </para>
8736 </listitem>
8737 </orderedlist>
8738 <para>
8739 String expansions, lists, and lookups interact with each other in such a way
8740 that there is no order in which to describe any one of them that does not
8741 involve references to the others. Each of these three chapters makes more sense
8742 if you have read the other two first. If you are reading this for the first
8743 time, be aware that some of it will make a lot more sense after you have read
8744 chapters <xref linkend="CHAPdomhosaddlists"/> and <xref linkend="CHAPexpand"/>.
8745 </para>
8746 <section>
8747 <title>Examples of different lookup syntax</title>
8748 <para>
8749 It is easy to confuse the two different kinds of lookup, especially as the
8750 lists that may contain the second kind are always expanded before being
8751 processed as lists. Therefore, they may also contain lookups of the first kind.
8752 Be careful to distinguish between the following two examples:
8753 </para>
8754 <literallayout class="monospaced">
8755 domains = ${lookup{$sender_host_address}lsearch{/some/file}}
8756 domains = lsearch;/some/file
8757 </literallayout>
8758 <para>
8759 The first uses a string expansion, the result of which must be a domain list.
8760 No strings have been specified for a successful or a failing lookup; the
8761 defaults in this case are the looked-up data and an empty string, respectively.
8762 The expansion takes place before the string is processed as a list, and the
8763 file that is searched could contain lines like this:
8764 </para>
8765 <literallayout class="monospaced">
8766 192.168.3.4: domain1:domain2:...
8767 192.168.1.9: domain3:domain4:...
8768 </literallayout>
8769 <para>
8770 When the lookup succeeds, the result of the expansion is a list of domains (and
8771 possibly other types of item that are allowed in domain lists).
8772 </para>
8773 <para>
8774 In the second example, the lookup is a single item in a domain list. It causes
8775 Exim to use a lookup to see if the domain that is being processed can be found
8776 in the file. The file could contains lines like this:
8777 </para>
8778 <literallayout class="monospaced">
8779 domain1:
8780 domain2:
8781 </literallayout>
8782 <para>
8783 Any data that follows the keys is not relevant when checking that the domain
8784 matches the list item.
8785 </para>
8786 <para>
8787 It is possible, though no doubt confusing, to use both kinds of lookup at once.
8788 Consider a file containing lines like this:
8789 </para>
8790 <literallayout class="monospaced">
8791 192.168.5.6: lsearch;/another/file
8792 </literallayout>
8793 <para>
8794 If the value of <varname>$sender_host_address</varname> is 192.168.5.6, expansion of the
8795 first <option>domains</option> setting above generates the second setting, which therefore
8796 causes a second lookup to occur.
8797 </para>
8798 <para>
8799 The rest of this chapter describes the different lookup types that are
8800 available. Any of them can be used in any part of the configuration where a
8801 lookup is permitted.
8802 </para>
8803 </section>
8804 <section>
8805 <title>Lookup types</title>
8806 <para>
8807 <indexterm role="concept">
8808 <primary>lookup</primary>
8809 <secondary>types of</secondary>
8810 </indexterm>
8811 <indexterm role="concept">
8812 <primary>single-key lookup</primary>
8813 <secondary>definition of</secondary>
8814 </indexterm>
8815 Two different types of data lookup are implemented:
8816 </para>
8817 <itemizedlist>
8818 <listitem>
8819 <para>
8820 The <emphasis>single-key</emphasis> type requires the specification of a file in which to look,
8821 and a single key to search for. The key must be a non-empty string for the
8822 lookup to succeed. The lookup type determines how the file is searched.
8823 </para>
8824 </listitem>
8825 <listitem>
8826 <para>
8827 <indexterm role="concept">
8828 <primary>query-style lookup</primary>
8829 <secondary>definition of</secondary>
8830 </indexterm>
8831 The <emphasis>query-style</emphasis> type accepts a generalized database query. No particular
8832 key value is assumed by Exim for query-style lookups. You can use whichever
8833 Exim variables you need to construct the database query.
8834 </para>
8835 </listitem>
8836 </itemizedlist>
8837 <para>
8838 The code for each lookup type is in a separate source file that is included in
8839 the binary of Exim only if the corresponding compile-time option is set. The
8840 default settings in <filename>src/EDITME</filename> are:
8841 </para>
8842 <literallayout class="monospaced">
8843 LOOKUP_DBM=yes
8844 LOOKUP_LSEARCH=yes
8845 </literallayout>
8846 <para>
8847 which means that only linear searching and DBM lookups are included by default.
8848 For some types of lookup (e.g. SQL databases), you need to install appropriate
8849 libraries and header files before building Exim.
8850 </para>
8851 </section>
8852 <section id="SECTsinglekeylookups">
8853 <title>Single-key lookup types</title>
8854 <para>
8855 <indexterm role="concept">
8856 <primary>lookup</primary>
8857 <secondary>single-key types</secondary>
8858 </indexterm>
8859 <indexterm role="concept">
8860 <primary>single-key lookup</primary>
8861 <secondary>list of types</secondary>
8862 </indexterm>
8863 The following single-key lookup types are implemented:
8864 </para>
8865 <itemizedlist>
8866 <listitem>
8867 <para>
8868 <indexterm role="concept">
8869 <primary>cdb</primary>
8870 <secondary>description of</secondary>
8871 </indexterm>
8872 <indexterm role="concept">
8873 <primary>lookup</primary>
8874 <secondary>cdb</secondary>
8875 </indexterm>
8876 <indexterm role="concept">
8877 <primary>binary zero</primary>
8878 <secondary>in lookup key</secondary>
8879 </indexterm>
8880 <command>cdb</command>: The given file is searched as a Constant DataBase file, using the key
8881 string without a terminating binary zero. The cdb format is designed for
8882 indexed files that are read frequently and never updated, except by total
8883 re-creation. As such, it is particulary suitable for large files containing
8884 aliases or other indexed data referenced by an MTA. Information about cdb can
8885 be found in several places:
8886 </para>
8887 <literallayout>
8888 <emphasis role="bold"><ulink url="http://www.pobox.com/~djb/cdb.html">http://www.pobox.com/~djb/cdb.html</ulink></emphasis>
8889 <emphasis role="bold"><ulink url="ftp://ftp.corpit.ru/pub/tinycdb/">ftp://ftp.corpit.ru/pub/tinycdb/</ulink></emphasis>
8890 <emphasis role="bold"><ulink url="http://packages.debian.org/stable/utils/freecdb.html">http://packages.debian.org/stable/utils/freecdb.html</ulink></emphasis>
8891 </literallayout>
8892 <para>
8893 A cdb distribution is not needed in order to build Exim with cdb support,
8894 because the code for reading cdb files is included directly in Exim itself.
8895 However, no means of building or testing cdb files is provided with Exim, so
8896 you need to obtain a cdb distribution in order to do this.
8897 </para>
8898 </listitem>
8899 <listitem>
8900 <para>
8901 <indexterm role="concept">
8902 <primary>DBM</primary>
8903 <secondary>lookup type</secondary>
8904 </indexterm>
8905 <indexterm role="concept">
8906 <primary>lookup</primary>
8907 <secondary>dbm</secondary>
8908 </indexterm>
8909 <indexterm role="concept">
8910 <primary>binary zero</primary>
8911 <secondary>in lookup key</secondary>
8912 </indexterm>
8913 <command>dbm</command>: Calls to DBM library functions are used to extract data from the given
8914 DBM file by looking up the record with the given key. A terminating binary
8915 zero is included in the key that is passed to the DBM library. See section
8916 <xref linkend="SECTdb"/> for a discussion of DBM libraries.
8917 </para>
8918 <para>
8919 <indexterm role="concept">
8920 <primary>Berkeley DB library</primary>
8921 <secondary>file format</secondary>
8922 </indexterm>
8923 For all versions of Berkeley DB, Exim uses the DB_HASH style of database
8924 when building DBM files using the <option>exim_dbmbuild</option> utility. However, when
8925 using Berkeley DB versions 3 or 4, it opens existing databases for reading with
8926 the DB_UNKNOWN option. This enables it to handle any of the types of database
8927 that the library supports, and can be useful for accessing DBM files created by
8928 other applications. (For earlier DB versions, DB_HASH is always used.)
8929 </para>
8930 </listitem>
8931 <listitem>
8932 <para>
8933 <indexterm role="concept">
8934 <primary>lookup</primary>
8935 <secondary>dbmnz</secondary>
8936 </indexterm>
8937 <indexterm role="concept">
8938 <primary>lookup</primary>
8939 <secondary>dbm &ndash; terminating zero</secondary>
8940 </indexterm>
8941 <indexterm role="concept">
8942 <primary>binary zero</primary>
8943 <secondary>in lookup key</secondary>
8944 </indexterm>
8945 <indexterm role="concept">
8946 <primary>Courier</primary>
8947 </indexterm>
8948 <indexterm role="concept">
8949 <primary><filename>/etc/userdbshadow.dat</filename></primary>
8950 </indexterm>
8951 <indexterm role="concept">
8952 <primary>dmbnz lookup type</primary>
8953 </indexterm>
8954 <command>dbmnz</command>: This is the same as <command>dbm</command>, except that a terminating binary zero
8955 is not included in the key that is passed to the DBM library. You may need this
8956 if you want to look up data in files that are created by or shared with some
8957 other application that does not use terminating zeros. For example, you need to
8958 use <command>dbmnz</command> rather than <command>dbm</command> if you want to authenticate incoming SMTP
8959 calls using the passwords from Courier&#x2019;s <filename>/etc/userdbshadow.dat</filename> file. Exim&#x2019;s
8960 utility program for creating DBM files (<emphasis>exim_dbmbuild</emphasis>) includes the zeros
8961 by default, but has an option to omit them (see section <xref linkend="SECTdbmbuild"/>).
8962 </para>
8963 </listitem>
8964 <listitem>
8965 <para>
8966 <indexterm role="concept">
8967 <primary>lookup</primary>
8968 <secondary>dsearch</secondary>
8969 </indexterm>
8970 <indexterm role="concept">
8971 <primary>dsearch lookup type</primary>
8972 </indexterm>
8973 <command>dsearch</command>: The given file must be a directory; this is searched for a file
8974 whose name is the key. The key may not contain any forward slash characters.
8975 The result of a successful lookup is the name of the file. An example of how
8976 this lookup can be used to support virtual domains is given in section
8977 <xref linkend="SECTvirtualdomains"/>.
8978 </para>
8979 </listitem>
8980 <listitem>
8981 <para>
8982 <indexterm role="concept">
8983 <primary>lookup</primary>
8984 <secondary>iplsearch</secondary>
8985 </indexterm>
8986 <indexterm role="concept">
8987 <primary>iplsearch lookup type</primary>
8988 </indexterm>
8989 <command>iplsearch</command>: The given file is a text file containing keys and data. A key is
8990 terminated by a colon or white space or the end of the line. The keys in the
8991 file must be IP addresses, or IP addresses with CIDR masks. Keys that involve
8992 IPv6 addresses must be enclosed in quotes to prevent the first internal colon
8993 being interpreted as a key terminator. For example:
8994 </para>
8995 <literallayout class="monospaced">
8996 1.2.3.4:           data for 1.2.3.4
8997 192.168.0.0/16     data for 192.168.0.0/16
8998 "abcd::cdab":      data for abcd::cdab
8999 "abcd:abcd::/32"   data for abcd:abcd::/32
9000 </literallayout>
9001 <para>
9002 The key for an <command>iplsearch</command> lookup must be an IP address (without a mask). The
9003 file is searched linearly, using the CIDR masks where present, until a matching
9004 key is found. The first key that matches is used; there is no attempt to find a
9005 <quote>best</quote> match. Apart from the way the keys are matched, the processing for
9006 <command>iplsearch</command> is the same as for <command>lsearch</command>.
9007 </para>
9008 <para>
9009 <emphasis role="bold">Warning 1</emphasis>: Unlike most other single-key lookup types, a file of data for
9010 <command>iplsearch</command> can <emphasis>not</emphasis> be turned into a DBM or cdb file, because those
9011 lookup types support only literal keys.
9012 </para>
9013 <para>
9014 <emphasis role="bold">Warning 2</emphasis>: In a host list, you must always use <command>net-iplsearch</command> so that
9015 the implicit key is the host&#x2019;s IP address rather than its name (see section
9016 <xref linkend="SECThoslispatsikey"/>).
9017 </para>
9018 </listitem>
9019 <listitem>
9020 <para>
9021 <indexterm role="concept">
9022 <primary>linear search</primary>
9023 </indexterm>
9024 <indexterm role="concept">
9025 <primary>lookup</primary>
9026 <secondary>lsearch</secondary>
9027 </indexterm>
9028 <indexterm role="concept">
9029 <primary>lsearch lookup type</primary>
9030 </indexterm>
9031 <command>lsearch</command>: The given file is a text file that is searched linearly for a
9032 line beginning with the search key, terminated by a colon or white space or the
9033 end of the line. The first occurrence that is found in the file is used. White
9034 space between the key and the colon is permitted. The remainder of the line,
9035 with leading and trailing white space removed, is the data. This can be
9036 continued onto subsequent lines by starting them with any amount of white
9037 space, but only a single space character is included in the data at such a
9038 junction. If the data begins with a colon, the key must be terminated by a
9039 colon, for example:
9040 </para>
9041 <literallayout class="monospaced">
9042 baduser:  :fail:
9043 </literallayout>
9044 <para>
9045 Empty lines and lines beginning with # are ignored, even if they occur in the
9046 middle of an item. This is the traditional textual format of alias files. Note
9047 that the keys in an <command>lsearch</command> file are literal strings. There is no
9048 wildcarding of any kind.
9049 </para>
9050 <para>
9051 <indexterm role="concept">
9052 <primary>lookup</primary>
9053 <secondary>lsearch &ndash; colons in keys</secondary>
9054 </indexterm>
9055 <indexterm role="concept">
9056 <primary>white space</primary>
9057 <secondary>in lsearch key</secondary>
9058 </indexterm>
9059 In most <command>lsearch</command> files, keys are not required to contain colons or #
9060 characters, or white space. However, if you need this feature, it is available.
9061 If a key begins with a doublequote character, it is terminated only by a
9062 matching quote (or end of line), and the normal escaping rules apply to its
9063 contents (see section <xref linkend="SECTstrings"/>). An optional colon is permitted after
9064 quoted keys (exactly as for unquoted keys). There is no special handling of
9065 quotes for the data part of an <command>lsearch</command> line.
9066 </para>
9067 </listitem>
9068 <listitem>
9069 <para>
9070 <indexterm role="concept">
9071 <primary>NIS lookup type</primary>
9072 </indexterm>
9073 <indexterm role="concept">
9074 <primary>lookup</primary>
9075 <secondary>NIS</secondary>
9076 </indexterm>
9077 <indexterm role="concept">
9078 <primary>binary zero</primary>
9079 <secondary>in lookup key</secondary>
9080 </indexterm>
9081 <command>nis</command>: The given file is the name of a NIS map, and a NIS lookup is done with
9082 the given key, without a terminating binary zero. There is a variant called
9083 <command>nis0</command> which does include the terminating binary zero in the key. This is
9084 reportedly needed for Sun-style alias files. Exim does not recognize NIS
9085 aliases; the full map names must be used.
9086 </para>
9087 </listitem>
9088 <listitem>
9089 <para>
9090 <indexterm role="concept">
9091 <primary>wildlsearch lookup type</primary>
9092 </indexterm>
9093 <indexterm role="concept">
9094 <primary>lookup</primary>
9095 <secondary>wildlsearch</secondary>
9096 </indexterm>
9097 <indexterm role="concept">
9098 <primary>nwildlsearch lookup type</primary>
9099 </indexterm>
9100 <indexterm role="concept">
9101 <primary>lookup</primary>
9102 <secondary>nwildlsearch</secondary>
9103 </indexterm>
9104 <command>wildlsearch</command> or <command>nwildlsearch</command>: These search a file linearly, like
9105 <command>lsearch</command>, but instead of being interpreted as a literal string, each key in
9106 the file may be wildcarded. The difference between these two lookup types is
9107 that for <command>wildlsearch</command>, each key in the file is string-expanded before being
9108 used, whereas for <command>nwildlsearch</command>, no expansion takes place.
9109 </para>
9110 <para>
9111 Like <command>lsearch</command>, the testing is done case-insensitively. The following forms
9112 of wildcard are recognized:
9113 </para>
9114 <orderedlist numeration="arabic">
9115 <listitem>
9116 <para>
9117 The string may begin with an asterisk to mean <quote>ends with</quote>. For example:
9118 </para>
9119 <literallayout class="monospaced">
9120     *.a.b.c       data for anything.a.b.c
9121     *fish         data for anythingfish
9122 </literallayout>
9123 </listitem>
9124 <listitem>
9125 <para>
9126 The string may begin with a circumflex to indicate a regular expression. For
9127 example, for <command>wildlsearch</command>:
9128 </para>
9129 <literallayout class="monospaced">
9130     ^\N\d+\.a\.b\N    data for &lt;digits&gt;.a.b
9131 </literallayout>
9132 <para>
9133 Note the use of <literal>\N</literal> to disable expansion of the contents of the regular
9134 expression. If you are using <command>nwildlsearch</command>, where the keys are not
9135 string-expanded, the equivalent entry is:
9136 </para>
9137 <literallayout class="monospaced">
9138     ^\d+\.a\.b        data for &lt;digits&gt;.a.b
9139 </literallayout>
9140 <para>
9141 If the regular expression contains white space or colon characters, you must
9142 either quote it (see <command>lsearch</command> above), or represent these characters in other
9143 ways. For example, <literal>\s</literal> can be used for white space and <literal>\x3A</literal> for a
9144 colon. This may be easier than quoting, because if you quote, you have to
9145 escape all the backslashes inside the quotes.
9146 </para>
9147 <para>
9148 <emphasis role="bold">Note</emphasis>: It is not possible to capture substrings in a regular expression
9149 match for later use, because the results of all lookups are cached. If a lookup
9150 is repeated, the result is taken from the cache, and no actual pattern matching
9151 takes place. The values of all the numeric variables are unset after a
9152 <command>(n)wildlsearch</command> match.
9153 </para>
9154 </listitem>
9155 <listitem>
9156 <para>
9157 Although I cannot see it being of much use, the general matching function that
9158 is used to implement <command>(n)wildlsearch</command> means that the string may begin with a
9159 lookup name terminated by a semicolon, and followed by lookup data. For
9160 example:
9161 </para>
9162 <literallayout class="monospaced">
9163     cdb;/some/file  data for keys that match the file
9164 </literallayout>
9165 <para>
9166 The data that is obtained from the nested lookup is discarded.
9167 </para>
9168 </listitem>
9169 </orderedlist>
9170 <para>
9171 Keys that do not match any of these patterns are interpreted literally. The
9172 continuation rules for the data are the same as for <command>lsearch</command>, and keys may
9173 be followed by optional colons.
9174 </para>
9175 <para>
9176 <emphasis role="bold">Warning</emphasis>: Unlike most other single-key lookup types, a file of data for
9177 <command>(n)wildlsearch</command> can <emphasis>not</emphasis> be turned into a DBM or cdb file, because those
9178 lookup types support only literal keys.
9179 </para>
9180 </listitem>
9181 </itemizedlist>
9182 </section>
9183 <section>
9184 <title>Query-style lookup types</title>
9185 <para>
9186 <indexterm role="concept">
9187 <primary>lookup</primary>
9188 <secondary>query-style types</secondary>
9189 </indexterm>
9190 <indexterm role="concept">
9191 <primary>query-style lookup</primary>
9192 <secondary>list of types</secondary>
9193 </indexterm>
9194 The supported query-style lookup types are listed below. Further details about
9195 many of them are given in later sections.
9196 </para>
9197 <itemizedlist>
9198 <listitem>
9199 <para>
9200 <indexterm role="concept">
9201 <primary>DNS</primary>
9202 <secondary>as a lookup type</secondary>
9203 </indexterm>
9204 <indexterm role="concept">
9205 <primary>lookup</primary>
9206 <secondary>DNS</secondary>
9207 </indexterm>
9208 <command>dnsdb</command>: This does a DNS search for one or more records whose domain names
9209 are given in the supplied query. The resulting data is the contents of the
9210 records. See section <xref linkend="SECTdnsdb"/>.
9211 </para>
9212 </listitem>
9213 <listitem>
9214 <para>
9215 <indexterm role="concept">
9216 <primary>Interbase lookup type</primary>
9217 </indexterm>
9218 <indexterm role="concept">
9219 <primary>lookup</primary>
9220 <secondary>Interbase</secondary>
9221 </indexterm>
9222 <command>ibase</command>: This does a lookup in an Interbase database.
9223 </para>
9224 </listitem>
9225 <listitem>
9226 <para>
9227 <indexterm role="concept">
9228 <primary>LDAP</primary>
9229 <secondary>lookup type</secondary>
9230 </indexterm>
9231 <indexterm role="concept">
9232 <primary>lookup</primary>
9233 <secondary>LDAP</secondary>
9234 </indexterm>
9235 <command>ldap</command>: This does an LDAP lookup using a query in the form of a URL, and
9236 returns attributes from a single entry. There is a variant called <command>ldapm</command>
9237 that permits values from multiple entries to be returned. A third variant
9238 called <command>ldapdn</command> returns the Distinguished Name of a single entry instead of
9239 any attribute values. See section <xref linkend="SECTldap"/>.
9240 </para>
9241 </listitem>
9242 <listitem>
9243 <para>
9244 <indexterm role="concept">
9245 <primary>MySQL</primary>
9246 <secondary>lookup type</secondary>
9247 </indexterm>
9248 <indexterm role="concept">
9249 <primary>lookup</primary>
9250 <secondary>MySQL</secondary>
9251 </indexterm>
9252 <command>mysql</command>: The format of the query is an SQL statement that is passed to a
9253 MySQL database. See section <xref linkend="SECTsql"/>.
9254 </para>
9255 </listitem>
9256 <listitem>
9257 <para>
9258 <indexterm role="concept">
9259 <primary>NIS+ lookup type</primary>
9260 </indexterm>
9261 <indexterm role="concept">
9262 <primary>lookup</primary>
9263 <secondary>NIS+</secondary>
9264 </indexterm>
9265 <command>nisplus</command>: This does a NIS+ lookup using a query that can specify the name of
9266 the field to be returned. See section <xref linkend="SECTnisplus"/>.
9267 </para>
9268 </listitem>
9269 <listitem>
9270 <para>
9271 <indexterm role="concept">
9272 <primary>Oracle</primary>
9273 <secondary>lookup type</secondary>
9274 </indexterm>
9275 <indexterm role="concept">
9276 <primary>lookup</primary>
9277 <secondary>Oracle</secondary>
9278 </indexterm>
9279 <command>oracle</command>: The format of the query is an SQL statement that is passed to an
9280 Oracle database. See section <xref linkend="SECTsql"/>.
9281 </para>
9282 </listitem>
9283 <listitem>
9284 <para>
9285 <indexterm role="concept">
9286 <primary>lookup</primary>
9287 <secondary>passwd</secondary>
9288 </indexterm>
9289 <indexterm role="concept">
9290 <primary>passwd lookup type</primary>
9291 </indexterm>
9292 <indexterm role="concept">
9293 <primary><filename>/etc/passwd</filename></primary>
9294 </indexterm>
9295 <command>passwd</command> is a query-style lookup with queries that are just user names. The
9296 lookup calls <function>getpwnam()</function> to interrogate the system password data, and on
9297 success, the result string is the same as you would get from an <command>lsearch</command>
9298 lookup on a traditional <filename>/etc/passwd file</filename>, though with <literal>*</literal> for the
9299 password value. For example:
9300 </para>
9301 <literallayout class="monospaced">
9302 *:42:42:King Rat:/home/kr:/bin/bash
9303 </literallayout>
9304 </listitem>
9305 <listitem>
9306 <para>
9307 <indexterm role="concept">
9308 <primary>PostgreSQL lookup type</primary>
9309 </indexterm>
9310 <indexterm role="concept">
9311 <primary>lookup</primary>
9312 <secondary>PostgreSQL</secondary>
9313 </indexterm>
9314 <command>pgsql</command>: The format of the query is an SQL statement that is passed to a
9315 PostgreSQL database. See section <xref linkend="SECTsql"/>.
9316 </para>
9317 </listitem>
9318 <listitem>
9319 <para>
9320 <indexterm role="concept">
9321 <primary>sqlite lookup type</primary>
9322 </indexterm>
9323 <indexterm role="concept">
9324 <primary>lookup</primary>
9325 <secondary>sqlite</secondary>
9326 </indexterm>
9327 <command>sqlite</command>: The format of the query is a file name followed by an SQL statement
9328 that is passed to an SQLite database. See section <xref linkend="SECTsqlite"/>.
9329 </para>
9330 </listitem>
9331 <listitem>
9332 <para>
9333 <command>testdb</command>: This is a lookup type that is used for testing Exim. It is
9334 not likely to be useful in normal operation.
9335 </para>
9336 </listitem>
9337 <listitem>
9338 <para>
9339 <indexterm role="concept">
9340 <primary>whoson lookup type</primary>
9341 </indexterm>
9342 <indexterm role="concept">
9343 <primary>lookup</primary>
9344 <secondary>whoson</secondary>
9345 </indexterm>
9346 <command>whoson</command>: <emphasis>Whoson</emphasis> (<emphasis role="bold"><ulink url="http://whoson.sourceforge.net">http://whoson.sourceforge.net</ulink></emphasis>) is a proposed
9347 Internet protocol that allows Internet server programs to check whether a
9348 particular (dynamically allocated) IP address is currently allocated to a known
9349 (trusted) user and, optionally, to obtain the identity of the said user. In
9350 Exim, this can be used to implement <quote>POP before SMTP</quote> checking using ACL
9351 statements such as
9352 </para>
9353 <literallayout class="monospaced">
9354 require condition = \
9355   ${lookup whoson {$sender_host_address}{yes}{no}}
9356 </literallayout>
9357 <para>
9358 The query consists of a single IP address. The value returned is the name of
9359 the authenticated user, which is stored in the variable <varname>$value</varname>. However, in
9360 this example, the data in <varname>$value</varname> is not used; the result of the lookup is
9361 one of the fixed strings <quote>yes</quote> or <quote>no</quote>.
9362 </para>
9363 </listitem>
9364 </itemizedlist>
9365 </section>
9366 <section>
9367 <title>Temporary errors in lookups</title>
9368 <para>
9369 <indexterm role="concept">
9370 <primary>lookup</primary>
9371 <secondary>temporary error in</secondary>
9372 </indexterm>
9373 Lookup functions can return temporary error codes if the lookup cannot be
9374 completed. For example, an SQL or LDAP database might be unavailable. For this
9375 reason, it is not advisable to use a lookup that might do this for critical
9376 options such as a list of local domains.
9377 </para>
9378 <para>
9379 When a lookup cannot be completed in a router or transport, delivery
9380 of the message (to the relevant address) is deferred, as for any other
9381 temporary error. In other circumstances Exim may assume the lookup has failed,
9382 or may give up altogether.
9383 </para>
9384 </section>
9385 <section id="SECTdefaultvaluelookups">
9386 <title>Default values in single-key lookups</title>
9387 <para>
9388 <indexterm role="concept">
9389 <primary>wildcard lookups</primary>
9390 </indexterm>
9391 <indexterm role="concept">
9392 <primary>lookup</primary>
9393 <secondary>default values</secondary>
9394 </indexterm>
9395 <indexterm role="concept">
9396 <primary>lookup</primary>
9397 <secondary>wildcard</secondary>
9398 </indexterm>
9399 <indexterm role="concept">
9400 <primary>lookup</primary>
9401 <secondary>* added to type</secondary>
9402 </indexterm>
9403 <indexterm role="concept">
9404 <primary>default</primary>
9405 <secondary>in single-key lookups</secondary>
9406 </indexterm>
9407 In this context, a <quote>default value</quote> is a value specified by the administrator
9408 that is to be used if a lookup fails.
9409 </para>
9410 <para>
9411 If <quote>*</quote> is added to a single-key lookup type (for example, <option>lsearch*</option>)
9412 and the initial lookup fails, the key <quote>*</quote> is looked up in the file to
9413 provide a default value. See also the section on partial matching below.
9414 </para>
9415 <para>
9416 <indexterm role="concept">
9417 <primary>*@ with single-key lookup</primary>
9418 </indexterm>
9419 <indexterm role="concept">
9420 <primary>lookup</primary>
9421 <secondary>*@ added to type</secondary>
9422 </indexterm>
9423 <indexterm role="concept">
9424 <primary>alias file</primary>
9425 <secondary>per-domain default</secondary>
9426 </indexterm>
9427 Alternatively, if <quote>*@</quote> is added to a single-key lookup type (for example
9428 <option>dbm*@</option>) then, if the initial lookup fails and the key contains an @
9429 character, a second lookup is done with everything before the last @ replaced
9430 by *. This makes it possible to provide per-domain defaults in alias files
9431 that include the domains in the keys. If the second lookup fails (or doesn&#x2019;t
9432 take place because there is no @ in the key), <quote>*</quote> is looked up.
9433 For example, a <command>redirect</command> router might contain:
9434 </para>
9435 <literallayout class="monospaced">
9436 data = ${lookup{$local_part@$domain}lsearch*@{/etc/mix-aliases}}
9437 </literallayout>
9438 <para>
9439 Suppose the address that is being processed is <emphasis>jane@eyre.example</emphasis>. Exim
9440 looks up these keys, in this order:
9441 </para>
9442 <literallayout class="monospaced">
9443 jane@eyre.example
9444 *@eyre.example
9445 *
9446 </literallayout>
9447 <para>
9448 The data is taken from whichever key it finds first. <emphasis role="bold">Note</emphasis>: In an
9449 <command>lsearch</command> file, this does not mean the first of these keys in the file. A
9450 complete scan is done for each key, and only if it is not found at all does
9451 Exim move on to try the next key.
9452 </para>
9453 </section>
9454 <section id="SECTpartiallookup">
9455 <title>Partial matching in single-key lookups</title>
9456 <para>
9457 <indexterm role="concept">
9458 <primary>partial matching</primary>
9459 </indexterm>
9460 <indexterm role="concept">
9461 <primary>wildcard lookups</primary>
9462 </indexterm>
9463 <indexterm role="concept">
9464 <primary>lookup</primary>
9465 <secondary>partial matching</secondary>
9466 </indexterm>
9467 <indexterm role="concept">
9468 <primary>lookup</primary>
9469 <secondary>wildcard</secondary>
9470 </indexterm>
9471 <indexterm role="concept">
9472 <primary>asterisk</primary>
9473 <secondary>in search type</secondary>
9474 </indexterm>
9475 The normal operation of a single-key lookup is to search the file for an exact
9476 match with the given key. However, in a number of situations where domains are
9477 being looked up, it is useful to be able to do partial matching. In this case,
9478 information in the file that has a key starting with <quote>*.</quote> is matched by any
9479 domain that ends with the components that follow the full stop. For example, if
9480 a key in a DBM file is
9481 </para>
9482 <literallayout class="monospaced">
9483 *.dates.fict.example
9484 </literallayout>
9485 <para>
9486 then when partial matching is enabled this is matched by (amongst others)
9487 <emphasis>2001.dates.fict.example</emphasis> and <emphasis>1984.dates.fict.example</emphasis>. It is also matched
9488 by <emphasis>dates.fict.example</emphasis>, if that does not appear as a separate key in the
9489 file.
9490 </para>
9491 <para>
9492 <emphasis role="bold">Note</emphasis>: Partial matching is not available for query-style lookups. It is
9493 also not available for any lookup items in address lists (see section
9494 <xref linkend="SECTaddresslist"/>).
9495 </para>
9496 <para>
9497 Partial matching is implemented by doing a series of separate lookups using
9498 keys constructed by modifying the original subject key. This means that it can
9499 be used with any of the single-key lookup types, provided that
9500 partial matching keys
9501 beginning with a special prefix (default <quote>*.</quote>) are included in the data file.
9502 Keys in the file that do not begin with the prefix are matched only by
9503 unmodified subject keys when partial matching is in use.
9504 </para>
9505 <para>
9506 Partial matching is requested by adding the string <quote>partial-</quote> to the front of
9507 the name of a single-key lookup type, for example, <option>partial-dbm</option>. When this
9508 is done, the subject key is first looked up unmodified; if that fails, <quote>*.</quote>
9509 is added at the start of the subject key, and it is looked up again. If that
9510 fails, further lookups are tried with dot-separated components removed from the
9511 start of the subject key, one-by-one, and <quote>*.</quote> added on the front of what
9512 remains.
9513 </para>
9514 <para>
9515 A minimum number of two non-* components are required. This can be adjusted
9516 by including a number before the hyphen in the search type. For example,
9517 <option>partial3-lsearch</option> specifies a minimum of three non-* components in the
9518 modified keys. Omitting the number is equivalent to <quote>partial2-</quote>. If the
9519 subject key is <emphasis>2250.dates.fict.example</emphasis> then the following keys are looked
9520 up when the minimum number of non-* components is two:
9521 </para>
9522 <literallayout class="monospaced">
9523 2250.dates.fict.example
9524 *.2250.dates.fict.example
9525 *.dates.fict.example
9526 *.fict.example
9527 </literallayout>
9528 <para>
9529 As soon as one key in the sequence is successfully looked up, the lookup
9530 finishes.
9531 </para>
9532 <para>
9533 <indexterm role="concept">
9534 <primary>lookup</primary>
9535 <secondary>partial matching &ndash; changing prefix</secondary>
9536 </indexterm>
9537 <indexterm role="concept">
9538 <primary>prefix</primary>
9539 <secondary>for partial matching</secondary>
9540 </indexterm>
9541 The use of <quote>*.</quote> as the partial matching prefix is a default that can be
9542 changed. The motivation for this feature is to allow Exim to operate with file
9543 formats that are used by other MTAs. A different prefix can be supplied in
9544 parentheses instead of the hyphen after <quote>partial</quote>. For example:
9545 </para>
9546 <literallayout class="monospaced">
9547 domains = partial(.)lsearch;/some/file
9548 </literallayout>
9549 <para>
9550 In this example, if the domain is <emphasis>a.b.c</emphasis>, the sequence of lookups is
9551 <literal>a.b.c</literal>, <literal>.a.b.c</literal>, and <literal>.b.c</literal> (the default minimum of 2 non-wild
9552 components is unchanged). The prefix may consist of any punctuation characters
9553 other than a closing parenthesis. It may be empty, for example:
9554 </para>
9555 <literallayout class="monospaced">
9556 domains = partial1()cdb;/some/file
9557 </literallayout>
9558 <para>
9559 For this example, if the domain is <emphasis>a.b.c</emphasis>, the sequence of lookups is
9560 <literal>a.b.c</literal>, <literal>b.c</literal>, and <literal>c</literal>.
9561 </para>
9562 <para>
9563 If <quote>partial0</quote> is specified, what happens at the end (when the lookup with
9564 just one non-wild component has failed, and the original key is shortened right
9565 down to the null string) depends on the prefix:
9566 </para>
9567 <itemizedlist>
9568 <listitem>
9569 <para>
9570 If the prefix has zero length, the whole lookup fails.
9571 </para>
9572 </listitem>
9573 <listitem>
9574 <para>
9575 If the prefix has length 1, a lookup for just the prefix is done. For
9576 example, the final lookup for <quote>partial0(.)</quote> is for <literal>.</literal> alone.
9577 </para>
9578 </listitem>
9579 <listitem>
9580 <para>
9581 Otherwise, if the prefix ends in a dot, the dot is removed, and the
9582 remainder is looked up. With the default prefix, therefore, the final lookup is
9583 for <quote>*</quote> on its own.
9584 </para>
9585 </listitem>
9586 <listitem>
9587 <para>
9588 Otherwise, the whole prefix is looked up.
9589 </para>
9590 </listitem>
9591 </itemizedlist>
9592 <para>
9593 If the search type ends in <quote>*</quote> or <quote>*@</quote> (see section
9594 <xref linkend="SECTdefaultvaluelookups"/> above), the search for an ultimate default that
9595 this implies happens after all partial lookups have failed. If <quote>partial0</quote> is
9596 specified, adding <quote>*</quote> to the search type has no effect with the default
9597 prefix, because the <quote>*</quote> key is already included in the sequence of partial
9598 lookups. However, there might be a use for lookup types such as
9599 <quote>partial0(.)lsearch*</quote>.
9600 </para>
9601 <para>
9602 The use of <quote>*</quote> in lookup partial matching differs from its use as a wildcard
9603 in domain lists and the like. Partial matching works only in terms of
9604 dot-separated components; a key such as <literal>*fict.example</literal>
9605 in a database file is useless, because the asterisk in a partial matching
9606 subject key is always followed by a dot.
9607 </para>
9608 </section>
9609 <section>
9610 <title>Lookup caching</title>
9611 <para>
9612 <indexterm role="concept">
9613 <primary>lookup</primary>
9614 <secondary>caching</secondary>
9615 </indexterm>
9616 <indexterm role="concept">
9617 <primary>caching</primary>
9618 <secondary>lookup data</secondary>
9619 </indexterm>
9620 Exim caches all lookup results in order to avoid needless repetition of
9621 lookups. However, because (apart from the daemon) Exim operates as a collection
9622 of independent, short-lived processes, this caching applies only within a
9623 single Exim process. There is no inter-process lookup caching facility.
9624 </para>
9625 <para>
9626 For single-key lookups, Exim keeps the relevant files open in case there is
9627 another lookup that needs them. In some types of configuration this can lead to
9628 many files being kept open for messages with many recipients. To avoid hitting
9629 the operating system limit on the number of simultaneously open files, Exim
9630 closes the least recently used file when it needs to open more files than its
9631 own internal limit, which can be changed via the <option>lookup_open_max</option> option.
9632 </para>
9633 <para>
9634 The single-key lookup files are closed and the lookup caches are flushed at
9635 strategic points during delivery &ndash; for example, after all routing is
9636 complete.
9637 </para>
9638 </section>
9639 <section>
9640 <title>Quoting lookup data</title>
9641 <para>
9642 <indexterm role="concept">
9643 <primary>lookup</primary>
9644 <secondary>quoting</secondary>
9645 </indexterm>
9646 <indexterm role="concept">
9647 <primary>quoting</primary>
9648 <secondary>in lookups</secondary>
9649 </indexterm>
9650 When data from an incoming message is included in a query-style lookup, there
9651 is the possibility of special characters in the data messing up the syntax of
9652 the query. For example, a NIS+ query that contains
9653 </para>
9654 <literallayout class="monospaced">
9655 [name=$local_part]
9656 </literallayout>
9657 <para>
9658 will be broken if the local part happens to contain a closing square bracket.
9659 For NIS+, data can be enclosed in double quotes like this:
9660 </para>
9661 <literallayout class="monospaced">
9662 [name="$local_part"]
9663 </literallayout>
9664 <para>
9665 but this still leaves the problem of a double quote in the data. The rule for
9666 NIS+ is that double quotes must be doubled. Other lookup types have different
9667 rules, and to cope with the differing requirements, an expansion operator
9668 of the following form is provided:
9669 </para>
9670 <literallayout class="monospaced">
9671 ${quote_&lt;lookup-type&gt;:&lt;string&gt;}
9672 </literallayout>
9673 <para>
9674 For example, the safest way to write the NIS+ query is
9675 </para>
9676 <literallayout class="monospaced">
9677 [name="${quote_nisplus:$local_part}"]
9678 </literallayout>
9679 <para>
9680 See chapter <xref linkend="CHAPexpand"/> for full coverage of string expansions. The quote
9681 operator can be used for all lookup types, but has no effect for single-key
9682 lookups, since no quoting is ever needed in their key strings.
9683 </para>
9684 </section>
9685 <section id="SECTdnsdb">
9686 <title>More about dnsdb</title>
9687 <para>
9688 <indexterm role="concept">
9689 <primary>dnsdb lookup</primary>
9690 </indexterm>
9691 <indexterm role="concept">
9692 <primary>lookup</primary>
9693 <secondary>dnsdb</secondary>
9694 </indexterm>
9695 <indexterm role="concept">
9696 <primary>DNS</primary>
9697 <secondary>as a lookup type</secondary>
9698 </indexterm>
9699 The <command>dnsdb</command> lookup type uses the DNS as its database. A simple query consists
9700 of a record type and a domain name, separated by an equals sign. For example,
9701 an expansion string could contain:
9702 </para>
9703 <literallayout class="monospaced">
9704 ${lookup dnsdb{mx=a.b.example}{$value}fail}
9705 </literallayout>
9706 <para>
9707 If the lookup succeeds, the result is placed in <varname>$value</varname>, which in this case
9708 is used on its own as the result. If the lookup succeeds, the <literal>fail</literal> keyword
9709 causes a <emphasis>forced expansion failure</emphasis> &ndash; see section <xref linkend="SECTforexpfai"/> for
9710 an explanation of what this means.
9711 </para>
9712 <para>
9713 The supported DNS record types are A, CNAME, MX, NS, PTR, SRV, and TXT, and,
9714 when Exim is compiled with IPv6 support, AAAA (and A6 if that is also
9715 configured). If no type is given, TXT is assumed. When the type is PTR,
9716 the data can be an IP address, written as normal; inversion and the addition of
9717 <option>in-addr.arpa</option> or <option>ip6.arpa</option> happens automatically. For example:
9718 </para>
9719 <literallayout class="monospaced">
9720 ${lookup dnsdb{ptr=192.168.4.5}{$value}fail}
9721 </literallayout>
9722 <para>
9723 If the data for a PTR record is not a syntactically valid IP address, it is not
9724 altered and nothing is added.
9725 </para>
9726 <para>
9727 <indexterm role="concept">
9728 <primary>MX record</primary>
9729 <secondary>in <command>dnsdb</command> lookup</secondary>
9730 </indexterm>
9731 <indexterm role="concept">
9732 <primary>SRV record</primary>
9733 <secondary>in <command>dnsdb</command> lookup</secondary>
9734 </indexterm>
9735 For an MX lookup, both the preference value and the host name are returned for
9736 each record, separated by a space. For an SRV lookup, the priority, weight,
9737 port, and host name are returned for each record, separated by spaces.
9738 </para>
9739 <para>
9740 For any record type, if multiple records are found (or, for A6 lookups, if a
9741 single record leads to multiple addresses), the data is returned as a
9742 concatenation, with newline as the default separator. The order, of course,
9743 depends on the DNS resolver. You can specify a different separator character
9744 between multiple records by putting a right angle-bracket followed immediately
9745 by the new separator at the start of the query. For example:
9746 </para>
9747 <literallayout class="monospaced">
9748 ${lookup dnsdb{&gt;: a=host1.example}}
9749 </literallayout>
9750 <para>
9751 It is permitted to specify a space as the separator character. Further
9752 white space is ignored.
9753 </para>
9754 </section>
9755 <section>
9756 <title>Pseudo dnsdb record types</title>
9757 <para>
9758 <indexterm role="concept">
9759 <primary>MX record</primary>
9760 <secondary>in <command>dnsdb</command> lookup</secondary>
9761 </indexterm>
9762 By default, both the preference value and the host name are returned for
9763 each MX record, separated by a space. If you want only host names, you can use
9764 the pseudo-type MXH:
9765 </para>
9766 <literallayout class="monospaced">
9767 ${lookup dnsdb{mxh=a.b.example}}
9768 </literallayout>
9769 <para>
9770 In this case, the preference values are omitted, and just the host names are
9771 returned.
9772 </para>
9773 <para>
9774 <indexterm role="concept">
9775 <primary>name server</primary>
9776 <secondary>for enclosing domain</secondary>
9777 </indexterm>
9778 Another pseudo-type is ZNS (for <quote>zone NS</quote>). It performs a lookup for NS
9779 records on the given domain, but if none are found, it removes the first
9780 component of the domain name, and tries again. This process continues until NS
9781 records are found or there are no more components left (or there is a DNS
9782 error). In other words, it may return the name servers for a top-level domain,
9783 but it never returns the root name servers. If there are no NS records for the
9784 top-level domain, the lookup fails. Consider these examples:
9785 </para>
9786 <literallayout class="monospaced">
9787 ${lookup dnsdb{zns=xxx.quercite.com}}
9788 ${lookup dnsdb{zns=xxx.edu}}
9789 </literallayout>
9790 <para>
9791 Assuming that in each case there are no NS records for the full domain name,
9792 the first returns the name servers for <option>quercite.com</option>, and the second returns
9793 the name servers for <option>edu</option>.
9794 </para>
9795 <para>
9796 You should be careful about how you use this lookup because, unless the
9797 top-level domain does not exist, the lookup always returns some host names. The
9798 sort of use to which this might be put is for seeing if the name servers for a
9799 given domain are on a blacklist. You can probably assume that the name servers
9800 for the high-level domains such as <option>com</option> or <option>co.uk</option> are not going to be on
9801 such a list.
9802 </para>
9803 <para>
9804 <indexterm role="concept">
9805 <primary>CSA</primary>
9806 <secondary>in <command>dnsdb</command> lookup</secondary>
9807 </indexterm>
9808 A third pseudo-type is CSA (Client SMTP Authorization). This looks up SRV
9809 records according to the CSA rules, which are described in section
9810 <xref linkend="SECTverifyCSA"/>. Although <command>dnsdb</command> supports SRV lookups directly, this is
9811 not sufficient because of the extra parent domain search behaviour of CSA. The
9812 result of a successful lookup such as:
9813 </para>
9814 <literallayout class="monospaced">
9815 ${lookup dnsdb {csa=$sender_helo_name}}
9816 </literallayout>
9817 <para>
9818 has two space-separated fields: an authorization code and a target host name.
9819 The authorization code can be <quote>Y</quote> for yes, <quote>N</quote> for no, <quote>X</quote> for explicit
9820 authorization required but absent, or <quote>?</quote> for unknown.
9821 </para>
9822 </section>
9823 <section>
9824 <title>Multiple dnsdb lookups</title>
9825 <para>
9826 In the previous sections, <command>dnsdb</command> lookups for a single domain are described.
9827 However, you can specify a list of domains or IP addresses in a single
9828 <command>dnsdb</command> lookup. The list is specified in the normal Exim way, with colon as
9829 the default separator, but with the ability to change this. For example:
9830 </para>
9831 <literallayout class="monospaced">
9832 ${lookup dnsdb{one.domain.com:two.domain.com}}
9833 ${lookup dnsdb{a=one.host.com:two.host.com}}
9834 ${lookup dnsdb{ptr = &lt;; 1.2.3.4 ; 4.5.6.8}}
9835 </literallayout>
9836 <para>
9837 In order to retain backwards compatibility, there is one special case: if
9838 the lookup type is PTR and no change of separator is specified, Exim looks
9839 to see if the rest of the string is precisely one IPv6 address. In this
9840 case, it does not treat it as a list.
9841 </para>
9842 <para>
9843 The data from each lookup is concatenated, with newline separators by default,
9844 in the same way that multiple DNS records for a single item are handled. A
9845 different separator can be specified, as described above.
9846 </para>
9847 <para>
9848 The <command>dnsdb</command> lookup fails only if all the DNS lookups fail. If there is a
9849 temporary DNS error for any of them, the behaviour is controlled by
9850 an optional keyword followed by a comma that may appear before the record
9851 type. The possible keywords are <quote>defer_strict</quote>, <quote>defer_never</quote>, and
9852 <quote>defer_lax</quote>. With <quote>strict</quote> behaviour, any temporary DNS error causes the
9853 whole lookup to defer. With <quote>never</quote> behaviour, a temporary DNS error is
9854 ignored, and the behaviour is as if the DNS lookup failed to find anything.
9855 With <quote>lax</quote> behaviour, all the queries are attempted, but a temporary DNS
9856 error causes the whole lookup to defer only if none of the other lookups
9857 succeed. The default is <quote>lax</quote>, so the following lookups are equivalent:
9858 </para>
9859 <literallayout class="monospaced">
9860 ${lookup dnsdb{defer_lax,a=one.host.com:two.host.com}}
9861 ${lookup dnsdb{a=one.host.com:two.host.com}}
9862 </literallayout>
9863 <para>
9864 Thus, in the default case, as long as at least one of the DNS lookups
9865 yields some data, the lookup succeeds.
9866 </para>
9867 </section>
9868 <section id="SECTldap">
9869 <title>More about LDAP</title>
9870 <para>
9871 <indexterm role="concept">
9872 <primary>LDAP lookup</primary>
9873 </indexterm>
9874 <indexterm role="concept">
9875 <primary>lookup</primary>
9876 <secondary>LDAP</secondary>
9877 </indexterm>
9878 <indexterm role="concept">
9879 <primary>Solaris</primary>
9880 <secondary>LDAP</secondary>
9881 </indexterm>
9882 The original LDAP implementation came from the University of Michigan; this has
9883 become <quote>Open LDAP</quote>, and there are now two different releases. Another
9884 implementation comes from Netscape, and Solaris 7 and subsequent releases
9885 contain inbuilt LDAP support. Unfortunately, though these are all compatible at
9886 the lookup function level, their error handling is different. For this reason
9887 it is necessary to set a compile-time variable when building Exim with LDAP, to
9888 indicate which LDAP library is in use. One of the following should appear in
9889 your <filename>Local/Makefile</filename>:
9890 </para>
9891 <literallayout class="monospaced">
9892 LDAP_LIB_TYPE=UMICHIGAN
9893 LDAP_LIB_TYPE=OPENLDAP1
9894 LDAP_LIB_TYPE=OPENLDAP2
9895 LDAP_LIB_TYPE=NETSCAPE
9896 LDAP_LIB_TYPE=SOLARIS
9897 </literallayout>
9898 <para>
9899 If LDAP_LIB_TYPE is not set, Exim assumes <literal>OPENLDAP1</literal>, which has the
9900 same interface as the University of Michigan version.
9901 </para>
9902 <para>
9903 There are three LDAP lookup types in Exim. These behave slightly differently in
9904 the way they handle the results of a query:
9905 </para>
9906 <itemizedlist>
9907 <listitem>
9908 <para>
9909 <command>ldap</command> requires the result to contain just one entry; if there are more, it
9910 gives an error.
9911 </para>
9912 </listitem>
9913 <listitem>
9914 <para>
9915 <command>ldapdn</command> also requires the result to contain just one entry, but it is the
9916 Distinguished Name that is returned rather than any attribute values.
9917 </para>
9918 </listitem>
9919 <listitem>
9920 <para>
9921 <command>ldapm</command> permits the result to contain more than one entry; the attributes
9922 from all of them are returned.
9923 </para>
9924 </listitem>
9925 </itemizedlist>
9926 <para>
9927 For <command>ldap</command> and <command>ldapm</command>, if a query finds only entries with no attributes,
9928 Exim behaves as if the entry did not exist, and the lookup fails. The format of
9929 the data returned by a successful lookup is described in the next section.
9930 First we explain how LDAP queries are coded.
9931 </para>
9932 </section>
9933 <section id="SECTforldaque">
9934 <title>Format of LDAP queries</title>
9935 <para>
9936 <indexterm role="concept">
9937 <primary>LDAP</primary>
9938 <secondary>query format</secondary>
9939 </indexterm>
9940 An LDAP query takes the form of a URL as defined in RFC 2255. For example, in
9941 the configuration of a <command>redirect</command> router one might have this setting:
9942 </para>
9943 <literallayout class="monospaced">
9944 data = ${lookup ldap \
9945   {ldap:///cn=$local_part,o=University%20of%20Cambridge,\
9946   c=UK?mailbox?base?}}
9947 </literallayout>
9948 <para>
9949 <indexterm role="concept">
9950 <primary>LDAP</primary>
9951 <secondary>with TLS</secondary>
9952 </indexterm>
9953 The URL may begin with <literal>ldap</literal> or <literal>ldaps</literal> if your LDAP library supports
9954 secure (encrypted) LDAP connections. The second of these ensures that an
9955 encrypted TLS connection is used.
9956 </para>
9957 </section>
9958 <section>
9959 <title>LDAP quoting</title>
9960 <para>
9961 <indexterm role="concept">
9962 <primary>LDAP</primary>
9963 <secondary>quoting</secondary>
9964 </indexterm>
9965 Two levels of quoting are required in LDAP queries, the first for LDAP itself
9966 and the second because the LDAP query is represented as a URL. Furthermore,
9967 within an LDAP query, two different kinds of quoting are required. For this
9968 reason, there are two different LDAP-specific quoting operators.
9969 </para>
9970 <para>
9971 The <option>quote_ldap</option> operator is designed for use on strings that are part of
9972 filter specifications. Conceptually, it first does the following conversions on
9973 the string:
9974 </para>
9975 <literallayout class="monospaced">
9976 *   =&gt;   \2A
9977 (   =&gt;   \28
9978 )   =&gt;   \29
9979 \   =&gt;   \5C
9980 </literallayout>
9981 <para>
9982 in accordance with RFC 2254. The resulting string is then quoted according
9983 to the rules for URLs, that is, all non-alphanumeric characters except
9984 </para>
9985 <literallayout class="monospaced">
9986 ! $ ' - . _ ( ) * +
9987 </literallayout>
9988 <para>
9989 are converted to their hex values, preceded by a percent sign. For example:
9990 </para>
9991 <literallayout class="monospaced">
9992 ${quote_ldap: a(bc)*, a&lt;yz&gt;; }
9993 </literallayout>
9994 <para>
9995 yields
9996 </para>
9997 <literallayout class="monospaced">
9998 %20a%5C28bc%5C29%5C2A%2C%20a%3Cyz%3E%3B%20
9999 </literallayout>
10000 <para>
10001 Removing the URL quoting, this is (with a leading and a trailing space):
10002 </para>
10003 <literallayout class="monospaced">
10004 a\28bc\29\2A, a&lt;yz&gt;;
10005 </literallayout>
10006 <para>
10007 The <option>quote_ldap_dn</option> operator is designed for use on strings that are part of
10008 base DN specifications in queries. Conceptually, it first converts the string
10009 by inserting a backslash in front of any of the following characters:
10010 </para>
10011 <literallayout class="monospaced">
10012 , + " \ &lt; &gt; ;
10013 </literallayout>
10014 <para>
10015 It also inserts a backslash before any leading spaces or # characters, and
10016 before any trailing spaces. (These rules are in RFC 2253.) The resulting string
10017 is then quoted according to the rules for URLs. For example:
10018 </para>
10019 <literallayout class="monospaced">
10020 ${quote_ldap_dn: a(bc)*, a&lt;yz&gt;; }
10021 </literallayout>
10022 <para>
10023 yields
10024 </para>
10025 <literallayout class="monospaced">
10026 %5C%20a(bc)*%5C%2C%20a%5C%3Cyz%5C%3E%5C%3B%5C%20
10027 </literallayout>
10028 <para>
10029 Removing the URL quoting, this is (with a trailing space):
10030 </para>
10031 <literallayout class="monospaced">
10032 \ a(bc)*\, a\&lt;yz\&gt;\;\
10033 </literallayout>
10034 <para>
10035 There are some further comments about quoting in the section on LDAP
10036 authentication below.
10037 </para>
10038 </section>
10039 <section>
10040 <title>LDAP connections</title>
10041 <para>
10042 <indexterm role="concept">
10043 <primary>LDAP</primary>
10044 <secondary>connections</secondary>
10045 </indexterm>
10046 The connection to an LDAP server may either be over TCP/IP, or, when OpenLDAP
10047 is in use, via a Unix domain socket. The example given above does not specify
10048 an LDAP server. A server that is reached by TCP/IP can be specified in a query
10049 by starting it with
10050 </para>
10051 <literallayout class="monospaced">
10052 ldap://&lt;hostname&gt;:&lt;port&gt;/...
10053 </literallayout>
10054 <para>
10055 If the port (and preceding colon) are omitted, the standard LDAP port (389) is
10056 used. When no server is specified in a query, a list of default servers is
10057 taken from the <option>ldap_default_servers</option> configuration option. This supplies a
10058 colon-separated list of servers which are tried in turn until one successfully
10059 handles a query, or there is a serious error. Successful handling either
10060 returns the requested data, or indicates that it does not exist. Serious errors
10061 are syntactical, or multiple values when only a single value is expected.
10062 Errors which cause the next server to be tried are connection failures, bind
10063 failures, and timeouts.
10064 </para>
10065 <para>
10066 For each server name in the list, a port number can be given. The standard way
10067 of specifing a host and port is to use a colon separator (RFC 1738). Because
10068 <option>ldap_default_servers</option> is a colon-separated list, such colons have to be
10069 doubled. For example
10070 </para>
10071 <literallayout class="monospaced">
10072 ldap_default_servers = ldap1.example.com::145:ldap2.example.com
10073 </literallayout>
10074 <para>
10075 If <option>ldap_default_servers</option> is unset, a URL with no server name is passed
10076 to the LDAP library with no server name, and the library&#x2019;s default (normally
10077 the local host) is used.
10078 </para>
10079 <para>
10080 If you are using the OpenLDAP library, you can connect to an LDAP server using
10081 a Unix domain socket instead of a TCP/IP connection. This is specified by using
10082 <literal>ldapi</literal> instead of <literal>ldap</literal> in LDAP queries. What follows here applies only
10083 to OpenLDAP. If Exim is compiled with a different LDAP library, this feature is
10084 not available.
10085 </para>
10086 <para>
10087 For this type of connection, instead of a host name for the server, a pathname
10088 for the socket is required, and the port number is not relevant. The pathname
10089 can be specified either as an item in <option>ldap_default_servers</option>, or inline in
10090 the query. In the former case, you can have settings such as
10091 </para>
10092 <literallayout class="monospaced">
10093 ldap_default_servers = /tmp/ldap.sock : backup.ldap.your.domain
10094 </literallayout>
10095 <para>
10096 When the pathname is given in the query, you have to escape the slashes as
10097 <literal>%2F</literal> to fit in with the LDAP URL syntax. For example:
10098 </para>
10099 <literallayout class="monospaced">
10100 ${lookup ldap {ldapi://%2Ftmp%2Fldap.sock/o=...
10101 </literallayout>
10102 <para>
10103 When Exim processes an LDAP lookup and finds that the <quote>hostname</quote> is really
10104 a pathname, it uses the Unix domain socket code, even if the query actually
10105 specifies <literal>ldap</literal> or <literal>ldaps</literal>. In particular, no encryption is used for a
10106 socket connection. This behaviour means that you can use a setting of
10107 <option>ldap_default_servers</option> such as in the example above with traditional <literal>ldap</literal>
10108 or <literal>ldaps</literal> queries, and it will work. First, Exim tries a connection via
10109 the Unix domain socket; if that fails, it tries a TCP/IP connection to the
10110 backup host.
10111 </para>
10112 <para>
10113 If an explicit <literal>ldapi</literal> type is given in a query when a host name is
10114 specified, an error is diagnosed. However, if there are more items in
10115 <option>ldap_default_servers</option>, they are tried. In other words:
10116 </para>
10117 <itemizedlist>
10118 <listitem>
10119 <para>
10120 Using a pathname with <literal>ldap</literal> or <literal>ldaps</literal> forces the use of the Unix domain
10121 interface.
10122 </para>
10123 </listitem>
10124 <listitem>
10125 <para>
10126 Using <literal>ldapi</literal> with a host name causes an error.
10127 </para>
10128 </listitem>
10129 </itemizedlist>
10130 <para>
10131 Using <literal>ldapi</literal> with no host or path in the query, and no setting of
10132 <option>ldap_default_servers</option>, does whatever the library does by default.
10133 </para>
10134 </section>
10135 <section>
10136 <title>LDAP authentication and control information</title>
10137 <para>
10138 <indexterm role="concept">
10139 <primary>LDAP</primary>
10140 <secondary>authentication</secondary>
10141 </indexterm>
10142 The LDAP URL syntax provides no way of passing authentication and other control
10143 information to the server. To make this possible, the URL in an LDAP query may
10144 be preceded by any number of &lt;<emphasis>name</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt; settings, separated by
10145 spaces. If a value contains spaces it must be enclosed in double quotes, and
10146 when double quotes are used, backslash is interpreted in the usual way inside
10147 them. The following names are recognized:
10148 </para>
10149 <literallayout>
10150 <literal>DEREFERENCE</literal>  set the dereferencing parameter
10151 <literal>NETTIME    </literal>  set a timeout for a network operation
10152 <literal>USER       </literal>  set the DN, for authenticating the LDAP bind
10153 <literal>PASS       </literal>  set the password, likewise
10154 <literal>SIZE       </literal>  set the limit for the number of entries returned
10155 <literal>TIME       </literal>  set the maximum waiting time for a query
10156 </literallayout>
10157 <para>
10158 The value of the DEREFERENCE parameter must be one of the words <quote>never</quote>,
10159 <quote>searching</quote>, <quote>finding</quote>, or <quote>always</quote>.
10160 </para>
10161 <para>
10162 The name CONNECT is an obsolete name for NETTIME, retained for
10163 backwards compatibility. This timeout (specified as a number of seconds) is
10164 enforced from the client end for operations that can be carried out over a
10165 network. Specifically, it applies to network connections and calls to the
10166 <emphasis>ldap_result()</emphasis> function. If the value is greater than zero, it is used if
10167 LDAP_OPT_NETWORK_TIMEOUT is defined in the LDAP headers (OpenLDAP), or
10168 if LDAP_X_OPT_CONNECT_TIMEOUT is defined in the LDAP headers (Netscape
10169 SDK 4.1). A value of zero forces an explicit setting of <quote>no timeout</quote> for
10170 Netscape SDK; for OpenLDAP no action is taken.
10171 </para>
10172 <para>
10173 The TIME parameter (also a number of seconds) is passed to the server to
10174 set a server-side limit on the time taken to complete a search.
10175 </para>
10176 <para>
10177 Here is an example of an LDAP query in an Exim lookup that uses some of these
10178 values. This is a single line, folded to fit on the page:
10179 </para>
10180 <literallayout class="monospaced">
10181 ${lookup ldap
10182   {user="cn=manager,o=University of Cambridge,c=UK" pass=secret
10183   ldap:///o=University%20of%20Cambridge,c=UK?sn?sub?(cn=foo)}
10184   {$value}fail}
10185 </literallayout>
10186 <para>
10187 The encoding of spaces as <literal>%20</literal> is a URL thing which should not be done for
10188 any of the auxiliary data. Exim configuration settings that include lookups
10189 which contain password information should be preceded by <quote>hide</quote> to prevent
10190 non-admin users from using the <option>-bP</option> option to see their values.
10191 </para>
10192 <para>
10193 The auxiliary data items may be given in any order. The default is no
10194 connection timeout (the system timeout is used), no user or password, no limit
10195 on the number of entries returned, and no time limit on queries.
10196 </para>
10197 <para>
10198 When a DN is quoted in the USER= setting for LDAP authentication, Exim
10199 removes any URL quoting that it may contain before passing it LDAP. Apparently
10200 some libraries do this for themselves, but some do not. Removing the URL
10201 quoting has two advantages:
10202 </para>
10203 <itemizedlist>
10204 <listitem>
10205 <para>
10206 It makes it possible to use the same <option>quote_ldap_dn</option> expansion for USER=
10207 DNs as with DNs inside actual queries.
10208 </para>
10209 </listitem>
10210 <listitem>
10211 <para>
10212 It permits spaces inside USER= DNs.
10213 </para>
10214 </listitem>
10215 </itemizedlist>
10216 <para>
10217 For example, a setting such as
10218 </para>
10219 <literallayout class="monospaced">
10220 USER=cn=${quote_ldap_dn:$1}
10221 </literallayout>
10222 <para>
10223 should work even if <varname>$1</varname> contains spaces.
10224 </para>
10225 <para>
10226 Expanded data for the PASS= value should be quoted using the <option>quote</option>
10227 expansion operator, rather than the LDAP quote operators. The only reason this
10228 field needs quoting is to ensure that it conforms to the Exim syntax, which
10229 does not allow unquoted spaces. For example:
10230 </para>
10231 <literallayout class="monospaced">
10232 PASS=${quote:$3}
10233 </literallayout>
10234 <para>
10235 The LDAP authentication mechanism can be used to check passwords as part of
10236 SMTP authentication. See the <option>ldapauth</option> expansion string condition in chapter
10237 <xref linkend="CHAPexpand"/>.
10238 </para>
10239 </section>
10240 <section>
10241 <title>Format of data returned by LDAP</title>
10242 <para>
10243 <indexterm role="concept">
10244 <primary>LDAP</primary>
10245 <secondary>returned data formats</secondary>
10246 </indexterm>
10247 The <command>ldapdn</command> lookup type returns the Distinguished Name from a single entry
10248 as a sequence of values, for example
10249 </para>
10250 <literallayout class="monospaced">
10251 cn=manager, o=University of Cambridge, c=UK
10252 </literallayout>
10253 <para>
10254 The <command>ldap</command> lookup type generates an error if more than one entry matches the
10255 search filter, whereas <command>ldapm</command> permits this case, and inserts a newline in
10256 the result between the data from different entries. It is possible for multiple
10257 values to be returned for both <command>ldap</command> and <command>ldapm</command>, but in the former case
10258 you know that whatever values are returned all came from a single entry in the
10259 directory.
10260 </para>
10261 <para>
10262 In the common case where you specify a single attribute in your LDAP query, the
10263 result is not quoted, and does not contain the attribute name. If the attribute
10264 has multiple values, they are separated by commas.
10265 </para>
10266 <para>
10267 If you specify multiple attributes, the result contains space-separated, quoted
10268 strings, each preceded by the attribute name and an equals sign. Within the
10269 quotes, the quote character, backslash, and newline are escaped with
10270 backslashes, and commas are used to separate multiple values for the attribute.
10271 Apart from the escaping, the string within quotes takes the same form as the
10272 output when a single attribute is requested. Specifying no attributes is the
10273 same as specifying all of an entry&#x2019;s attributes.
10274 </para>
10275 <para>
10276 Here are some examples of the output format. The first line of each pair is an
10277 LDAP query, and the second is the data that is returned. The attribute called
10278 <option>attr1</option> has two values, whereas <option>attr2</option> has only one value:
10279 </para>
10280 <literallayout class="monospaced">
10281 ldap:///o=base?attr1?sub?(uid=fred)
10282 value1.1, value1.2
10283
10284 ldap:///o=base?attr2?sub?(uid=fred)
10285 value two
10286
10287 ldap:///o=base?attr1,attr2?sub?(uid=fred)
10288 attr1="value1.1, value1.2" attr2="value two"
10289
10290 ldap:///o=base??sub?(uid=fred)
10291 objectClass="top" attr1="value1.1, value1.2" attr2="value two"
10292 </literallayout>
10293 <para>
10294 The <option>extract</option> operator in string expansions can be used to pick out
10295 individual fields from data that consists of <emphasis>key</emphasis>=<emphasis>value</emphasis> pairs. You can
10296 make use of Exim&#x2019;s <option>-be</option> option to run expansion tests and thereby check the
10297 results of LDAP lookups.
10298 </para>
10299 </section>
10300 <section id="SECTnisplus">
10301 <title>More about NIS+</title>
10302 <para>
10303 <indexterm role="concept">
10304 <primary>NIS+ lookup type</primary>
10305 </indexterm>
10306 <indexterm role="concept">
10307 <primary>lookup</primary>
10308 <secondary>NIS+</secondary>
10309 </indexterm>
10310 NIS+ queries consist of a NIS+ <emphasis>indexed name</emphasis> followed by an optional colon
10311 and field name. If this is given, the result of a successful query is the
10312 contents of the named field; otherwise the result consists of a concatenation
10313 of <emphasis>field-name=field-value</emphasis> pairs, separated by spaces. Empty values and
10314 values containing spaces are quoted. For example, the query
10315 </para>
10316 <literallayout class="monospaced">
10317 [name=mg1456],passwd.org_dir
10318 </literallayout>
10319 <para>
10320 might return the string
10321 </para>
10322 <literallayout class="monospaced">
10323 name=mg1456 passwd="" uid=999 gid=999 gcos="Martin Guerre"
10324 home=/home/mg1456 shell=/bin/bash shadow=""
10325 </literallayout>
10326 <para>
10327 (split over two lines here to fit on the page), whereas
10328 </para>
10329 <literallayout class="monospaced">
10330 [name=mg1456],passwd.org_dir:gcos
10331 </literallayout>
10332 <para>
10333 would just return
10334 </para>
10335 <literallayout class="monospaced">
10336 Martin Guerre
10337 </literallayout>
10338 <para>
10339 with no quotes. A NIS+ lookup fails if NIS+ returns more than one table entry
10340 for the given indexed key. The effect of the <option>quote_nisplus</option> expansion
10341 operator is to double any quote characters within the text.
10342 </para>
10343 </section>
10344 <section id="SECTsql">
10345 <title>SQL lookups</title>
10346 <para>
10347 <indexterm role="concept">
10348 <primary>SQL lookup types</primary>
10349 </indexterm>
10350 Exim can support lookups in Interbase, MySQL, Oracle, PostgreSQL, and SQLite
10351 databases. Queries for these databases contain SQL statements, so an example
10352 might be
10353 </para>
10354 <literallayout class="monospaced">
10355 ${lookup mysql{select mailbox from users where id='userx'}\
10356   {$value}fail}
10357 </literallayout>
10358 <para>
10359 If the result of the query contains more than one field, the data for each
10360 field in the row is returned, preceded by its name, so the result of
10361 </para>
10362 <literallayout class="monospaced">
10363 ${lookup pgsql{select home,name from users where id='userx'}\
10364   {$value}}
10365 </literallayout>
10366 <para>
10367 might be
10368 </para>
10369 <literallayout class="monospaced">
10370 home=/home/userx name="Mister X"
10371 </literallayout>
10372 <para>
10373 Empty values and values containing spaces are double quoted, with embedded
10374 quotes escaped by a backslash. If the result of the query contains just one
10375 field, the value is passed back verbatim, without a field name, for example:
10376 </para>
10377 <literallayout class="monospaced">
10378 Mister X
10379 </literallayout>
10380 <para>
10381 If the result of the query yields more than one row, it is all concatenated,
10382 with a newline between the data for each row.
10383 </para>
10384 </section>
10385 <section>
10386 <title>More about MySQL, PostgreSQL, Oracle, and Interbase</title>
10387 <para>
10388 <indexterm role="concept">
10389 <primary>MySQL</primary>
10390 <secondary>lookup type</secondary>
10391 </indexterm>
10392 <indexterm role="concept">
10393 <primary>PostgreSQL lookup type</primary>
10394 </indexterm>
10395 <indexterm role="concept">
10396 <primary>lookup</primary>
10397 <secondary>MySQL</secondary>
10398 </indexterm>
10399 <indexterm role="concept">
10400 <primary>lookup</primary>
10401 <secondary>PostgreSQL</secondary>
10402 </indexterm>
10403 <indexterm role="concept">
10404 <primary>Oracle</primary>
10405 <secondary>lookup type</secondary>
10406 </indexterm>
10407 <indexterm role="concept">
10408 <primary>lookup</primary>
10409 <secondary>Oracle</secondary>
10410 </indexterm>
10411 <indexterm role="concept">
10412 <primary>Interbase lookup type</primary>
10413 </indexterm>
10414 <indexterm role="concept">
10415 <primary>lookup</primary>
10416 <secondary>Interbase</secondary>
10417 </indexterm>
10418 If any MySQL, PostgreSQL, Oracle, or Interbase lookups are used, the
10419 <option>mysql_servers</option>, <option>pgsql_servers</option>, <option>oracle_servers</option>, or <option>ibase_servers</option>
10420 option (as appropriate) must be set to a colon-separated list of server
10421 information. Each item in the list is a slash-separated list of four items:
10422 host name, database name, user name, and password. In the case of Oracle, the
10423 host name field is used for the <quote>service name</quote>, and the database name field
10424 is not used and should be empty. For example:
10425 </para>
10426 <literallayout class="monospaced">
10427 hide oracle_servers = oracle.plc.example//userx/abcdwxyz
10428 </literallayout>
10429 <para>
10430 Because password data is sensitive, you should always precede the setting with
10431 <quote>hide</quote>, to prevent non-admin users from obtaining the setting via the <option>-bP</option>
10432 option. Here is an example where two MySQL servers are listed:
10433 </para>
10434 <literallayout class="monospaced">
10435 hide mysql_servers = localhost/users/root/secret:\
10436                      otherhost/users/root/othersecret
10437 </literallayout>
10438 <para>
10439 For MySQL and PostgreSQL, a host may be specified as &lt;<emphasis>name</emphasis>&gt;:&lt;<emphasis>port</emphasis>&gt; but
10440 because this is a colon-separated list, the colon has to be doubled. For each
10441 query, these parameter groups are tried in order until a connection and a query
10442 succeeds.
10443 </para>
10444 <para>
10445 The <option>quote_mysql</option>, <option>quote_pgsql</option>, and <option>quote_oracle</option> expansion operators
10446 convert newline, tab, carriage return, and backspace to \n, \t, \r, and \b
10447 respectively, and the characters single-quote, double-quote, and backslash
10448 itself are escaped with backslashes. The <option>quote_pgsql</option> expansion operator, in
10449 addition, escapes the percent and underscore characters. This cannot be done
10450 for MySQL because these escapes are not recognized in contexts where these
10451 characters are not special.
10452 </para>
10453 </section>
10454 <section>
10455 <title>Special MySQL features</title>
10456 <para>
10457 For MySQL, an empty host name or the use of <quote>localhost</quote> in <option>mysql_servers</option>
10458 causes a connection to the server on the local host by means of a Unix domain
10459 socket. An alternate socket can be specified in parentheses. The full syntax of
10460 each item in <option>mysql_servers</option> is:
10461 </para>
10462 <literallayout>
10463 &lt;<emphasis>hostname</emphasis>&gt;::&lt;<emphasis>port</emphasis>&gt;(&lt;<emphasis>socket name</emphasis>&gt;)/&lt;<emphasis>database</emphasis>&gt;/&lt;<emphasis>user</emphasis>&gt;/&lt;<emphasis>password</emphasis>&gt;
10464 </literallayout>
10465 <para>
10466 Any of the three sub-parts of the first field can be omitted. For normal use on
10467 the local host it can be left blank or set to just <quote>localhost</quote>.
10468 </para>
10469 <para>
10470 No database need be supplied &ndash; but if it is absent here, it must be given in
10471 the queries.
10472 </para>
10473 <para>
10474 If a MySQL query is issued that does not request any data (an insert, update,
10475 or delete command), the result of the lookup is the number of rows affected.
10476 </para>
10477 <para>
10478 <emphasis role="bold">Warning</emphasis>: This can be misleading. If an update does not actually change
10479 anything (for example, setting a field to the value it already has), the result
10480 is zero because no rows are affected.
10481 </para>
10482 </section>
10483 <section>
10484 <title>Special PostgreSQL features</title>
10485 <para>
10486 PostgreSQL lookups can also use Unix domain socket connections to the database.
10487 This is usually faster and costs less CPU time than a TCP/IP connection.
10488 However it can be used only if the mail server runs on the same machine as the
10489 database server. A configuration line for PostgreSQL via Unix domain sockets
10490 looks like this:
10491 </para>
10492 <literallayout class="monospaced">
10493 hide pgsql_servers = (/tmp/.s.PGSQL.5432)/db/user/password : ...
10494 </literallayout>
10495 <para>
10496 In other words, instead of supplying a host name, a path to the socket is
10497 given. The path name is enclosed in parentheses so that its slashes aren&#x2019;t
10498 visually confused with the delimiters for the other server parameters.
10499 </para>
10500 <para>
10501 If a PostgreSQL query is issued that does not request any data (an insert,
10502 update, or delete command), the result of the lookup is the number of rows
10503 affected.
10504 </para>
10505 </section>
10506 <section id="SECTsqlite">
10507 <title>More about SQLite</title>
10508 <para>
10509 <indexterm role="concept">
10510 <primary>lookup</primary>
10511 <secondary>SQLite</secondary>
10512 </indexterm>
10513 <indexterm role="concept">
10514 <primary>SQLite lookup type</primary>
10515 </indexterm>
10516 SQLite is different to the other SQL lookups because a file name is required in
10517 addition to the SQL query. An SQLite database is a single file, and there is no
10518 daemon as in the other SQL databases. The interface to Exim requires the name
10519 of the file, as an absolute path, to be given at the start of the query. It is
10520 separated from the query by white space. This means that the path name cannot
10521 contain white space. Here is a lookup expansion example:
10522 </para>
10523 <literallayout class="monospaced">
10524 ${lookup sqlite {/some/thing/sqlitedb \
10525   select name from aliases where id='userx';}}
10526 </literallayout>
10527 <para>
10528 In a list, the syntax is similar. For example:
10529 </para>
10530 <literallayout class="monospaced">
10531 domainlist relay_domains = sqlite;/some/thing/sqlitedb \
10532    select * from relays where ip='$sender_host_address';
10533 </literallayout>
10534 <para>
10535 The only character affected by the <option>quote_sqlite</option> operator is a single
10536 quote, which it doubles.
10537 </para>
10538 <para>
10539 The SQLite library handles multiple simultaneous accesses to the database
10540 internally. Multiple readers are permitted, but only one process can
10541 update at once. Attempts to access the database while it is being updated
10542 are rejected after a timeout period, during which the SQLite library
10543 waits for the lock to be released. In Exim, the default timeout is set
10544 to 5 seconds, but it can be changed by means of the <option>sqlite_lock_timeout</option>
10545 option.
10546 <indexterm role="concept" startref="IIDfidalo1" class="endofrange"/>
10547 <indexterm role="concept" startref="IIDfidalo2" class="endofrange"/>
10548 </para>
10549 </section>
10550 </chapter>
10551
10552 <chapter id="CHAPdomhosaddlists">
10553 <title>Domain, host, address, and local part lists</title>
10554 <titleabbrev>Domain, host, and address lists</titleabbrev>
10555 <para>
10556 <indexterm role="concept" id="IIDdohoadli" class="startofrange">
10557 <primary>lists of domains; hosts; etc.</primary>
10558 </indexterm>
10559 A number of Exim configuration options contain lists of domains, hosts,
10560 email addresses, or local parts. For example, the <option>hold_domains</option> option
10561 contains a list of domains whose delivery is currently suspended. These lists
10562 are also used as data in ACL statements (see chapter <xref linkend="CHAPACL"/>), and as
10563 arguments to expansion conditions such as <option>match_domain</option>.
10564 </para>
10565 <para>
10566 Each item in one of these lists is a pattern to be matched against a domain,
10567 host, email address, or local part, respectively. In the sections below, the
10568 different types of pattern for each case are described, but first we cover some
10569 general facilities that apply to all four kinds of list.
10570 </para>
10571 <section>
10572 <title>Expansion of lists</title>
10573 <para>
10574 <indexterm role="concept">
10575 <primary>expansion</primary>
10576 <secondary>of lists</secondary>
10577 </indexterm>
10578 Each list is expanded as a single string before it is used. The result of
10579 expansion must be a list, possibly containing empty items, which is split up
10580 into separate items for matching. By default, colon is the separator character,
10581 but this can be varied if necessary. See sections <xref linkend="SECTlistconstruct"/> and
10582 <xref linkend="SECTempitelis"/> for details of the list syntax; the second of these
10583 discusses the way to specify empty list items.
10584 </para>
10585 <para>
10586 If the string expansion is forced to fail, Exim behaves as if the item it is
10587 testing (domain, host, address, or local part) is not in the list. Other
10588 expansion failures cause temporary errors.
10589 </para>
10590 <para>
10591 If an item in a list is a regular expression, backslashes, dollars and possibly
10592 other special characters in the expression must be protected against
10593 misinterpretation by the string expander. The easiest way to do this is to use
10594 the <literal>\N</literal> expansion feature to indicate that the contents of the regular
10595 expression should not be expanded. For example, in an ACL you might have:
10596 </para>
10597 <literallayout class="monospaced">
10598 deny senders = \N^\d{8}\w@.*\.baddomain\.example$\N : \
10599                ${lookup{$domain}lsearch{/badsenders/bydomain}}
10600 </literallayout>
10601 <para>
10602 The first item is a regular expression that is protected from expansion by
10603 <literal>\N</literal>, whereas the second uses the expansion to obtain a list of unwanted
10604 senders based on the receiving domain.
10605 </para>
10606 </section>
10607 <section>
10608 <title>Negated items in lists</title>
10609 <para>
10610 <indexterm role="concept">
10611 <primary>list</primary>
10612 <secondary>negation</secondary>
10613 </indexterm>
10614 <indexterm role="concept">
10615 <primary>negation</primary>
10616 <secondary>in lists</secondary>
10617 </indexterm>
10618 Items in a list may be positive or negative. Negative items are indicated by a
10619 leading exclamation mark, which may be followed by optional white space. A list
10620 defines a set of items (domains, etc). When Exim processes one of these lists,
10621 it is trying to find out whether a domain, host, address, or local part
10622 (respectively) is in the set that is defined by the list. It works like this:
10623 </para>
10624 <para>
10625 The list is scanned from left to right. If a positive item is matched, the
10626 subject that is being checked is in the set; if a negative item is matched, the
10627 subject is not in the set. If the end of the list is reached without the
10628 subject having matched any of the patterns, it is in the set if the last item
10629 was a negative one, but not if it was a positive one. For example, the list in
10630 </para>
10631 <literallayout class="monospaced">
10632 domainlist relay_domains = !a.b.c : *.b.c
10633 </literallayout>
10634 <para>
10635 matches any domain ending in <emphasis>.b.c</emphasis> except for <emphasis>a.b.c</emphasis>. Domains that match
10636 neither <emphasis>a.b.c</emphasis> nor <emphasis>*.b.c</emphasis> do not match, because the last item in the
10637 list is positive. However, if the setting were
10638 </para>
10639 <literallayout class="monospaced">
10640 domainlist relay_domains = !a.b.c
10641 </literallayout>
10642 <para>
10643 then all domains other than <emphasis>a.b.c</emphasis> would match because the last item in the
10644 list is negative. In other words, a list that ends with a negative item behaves
10645 as if it had an extra item <literal>:*</literal> on the end.
10646 </para>
10647 <para>
10648 Another way of thinking about positive and negative items in lists is to read
10649 the connector as <quote>or</quote> after a positive item and as <quote>and</quote> after a negative
10650 item.
10651 </para>
10652 </section>
10653 <section id="SECTfilnamlis">
10654 <title>File names in lists</title>
10655 <para>
10656 <indexterm role="concept">
10657 <primary>list</primary>
10658 <secondary>file name in</secondary>
10659 </indexterm>
10660 If an item in a domain, host, address, or local part list is an absolute file
10661 name (beginning with a slash character), each line of the file is read and
10662 processed as if it were an independent item in the list, except that further
10663 file names are not allowed,
10664 and no expansion of the data from the file takes place.
10665 Empty lines in the file are ignored, and the file may also contain comment
10666 lines:
10667 </para>
10668 <itemizedlist>
10669 <listitem>
10670 <para>
10671 For domain and host lists, if a # character appears anywhere in a line of the
10672 file, it and all following characters are ignored.
10673 </para>
10674 </listitem>
10675 <listitem>
10676 <para>
10677 Because local parts may legitimately contain # characters, a comment in an
10678 address list or local part list file is recognized only if # is preceded by
10679 white space or the start of the line. For example:
10680 </para>
10681 <literallayout class="monospaced">
10682 not#comment@x.y.z   # but this is a comment
10683 </literallayout>
10684 </listitem>
10685 </itemizedlist>
10686 <para>
10687 Putting a file name in a list has the same effect as inserting each line of the
10688 file as an item in the list (blank lines and comments excepted). However, there
10689 is one important difference: the file is read each time the list is processed,
10690 so if its contents vary over time, Exim&#x2019;s behaviour changes.
10691 </para>
10692 <para>
10693 If a file name is preceded by an exclamation mark, the sense of any match
10694 within the file is inverted. For example, if
10695 </para>
10696 <literallayout class="monospaced">
10697 hold_domains = !/etc/nohold-domains
10698 </literallayout>
10699 <para>
10700 and the file contains the lines
10701 </para>
10702 <literallayout class="monospaced">
10703 !a.b.c
10704 *.b.c
10705 </literallayout>
10706 <para>
10707 then <emphasis>a.b.c</emphasis> is in the set of domains defined by <option>hold_domains</option>, whereas
10708 any domain matching <literal>*.b.c</literal> is not.
10709 </para>
10710 </section>
10711 <section>
10712 <title>An lsearch file is not an out-of-line list</title>
10713 <para>
10714 As will be described in the sections that follow, lookups can be used in lists
10715 to provide indexed methods of checking list membership. There has been some
10716 confusion about the way <command>lsearch</command> lookups work in lists. Because
10717 an <command>lsearch</command> file contains plain text and is scanned sequentially, it is
10718 sometimes thought that it is allowed to contain wild cards and other kinds of
10719 non-constant pattern. This is not the case. The keys in an <command>lsearch</command> file are
10720 always fixed strings, just as for any other single-key lookup type.
10721 </para>
10722 <para>
10723 If you want to use a file to contain wild-card patterns that form part of a
10724 list, just give the file name on its own, without a search type, as described
10725 in the previous section.
10726 </para>
10727 </section>
10728 <section id="SECTnamedlists">
10729 <title>Named lists</title>
10730 <para>
10731 <indexterm role="concept">
10732 <primary>named lists</primary>
10733 </indexterm>
10734 <indexterm role="concept">
10735 <primary>list</primary>
10736 <secondary>named</secondary>
10737 </indexterm>
10738 A list of domains, hosts, email addresses, or local parts can be given a name
10739 which is then used to refer to the list elsewhere in the configuration. This is
10740 particularly convenient if the same list is required in several different
10741 places. It also allows lists to be given meaningful names, which can improve
10742 the readability of the configuration. For example, it is conventional to define
10743 a domain list called <emphasis>local_domains</emphasis> for all the domains that are handled
10744 locally on a host, using a configuration line such as
10745 </para>
10746 <literallayout class="monospaced">
10747 domainlist local_domains = localhost:my.dom.example
10748 </literallayout>
10749 <para>
10750 Named lists are referenced by giving their name preceded by a plus sign, so,
10751 for example, a router that is intended to handle local domains would be
10752 configured with the line
10753 </para>
10754 <literallayout class="monospaced">
10755 domains = +local_domains
10756 </literallayout>
10757 <para>
10758 The first router in a configuration is often one that handles all domains
10759 except the local ones, using a configuration with a negated item like this:
10760 </para>
10761 <literallayout class="monospaced">
10762 dnslookup:
10763   driver = dnslookup
10764   domains = ! +local_domains
10765   transport = remote_smtp
10766   no_more
10767 </literallayout>
10768 <para>
10769 The four kinds of named list are created by configuration lines starting with
10770 the words <option>domainlist</option>, <option>hostlist</option>, <option>addresslist</option>, or <option>localpartlist</option>,
10771 respectively. Then there follows the name that you are defining, followed by an
10772 equals sign and the list itself. For example:
10773 </para>
10774 <literallayout class="monospaced">
10775 hostlist    relay_hosts = 192.168.23.0/24 : my.friend.example
10776 addresslist bad_senders = cdb;/etc/badsenders
10777 </literallayout>
10778 <para>
10779 A named list may refer to other named lists:
10780 </para>
10781 <literallayout class="monospaced">
10782 domainlist  dom1 = first.example : second.example
10783 domainlist  dom2 = +dom1 : third.example
10784 domainlist  dom3 = fourth.example : +dom2 : fifth.example
10785 </literallayout>
10786 <para>
10787 <emphasis role="bold">Warning</emphasis>: If the last item in a referenced list is a negative one, the
10788 effect may not be what you intended, because the negation does not propagate
10789 out to the higher level. For example, consider:
10790 </para>
10791 <literallayout class="monospaced">
10792 domainlist  dom1 = !a.b
10793 domainlist  dom2 = +dom1 : *.b
10794 </literallayout>
10795 <para>
10796 The second list specifies <quote>either in the <option>dom1</option> list or <emphasis>*.b</emphasis></quote>. The first
10797 list specifies just <quote>not <emphasis>a.b</emphasis></quote>, so the domain <emphasis>x.y</emphasis> matches it. That
10798 means it matches the second list as well. The effect is not the same as
10799 </para>
10800 <literallayout class="monospaced">
10801 domainlist  dom2 = !a.b : *.b
10802 </literallayout>
10803 <para>
10804 where <emphasis>x.y</emphasis> does not match. It&#x2019;s best to avoid negation altogether in
10805 referenced lists if you can.
10806 </para>
10807 <para>
10808 Named lists may have a performance advantage. When Exim is routing an
10809 address or checking an incoming message, it caches the result of tests on named
10810 lists. So, if you have a setting such as
10811 </para>
10812 <literallayout class="monospaced">
10813 domains = +local_domains
10814 </literallayout>
10815 <para>
10816 on several of your routers
10817 or in several ACL statements,
10818 the actual test is done only for the first one. However, the caching works only
10819 if there are no expansions within the list itself or any sublists that it
10820 references. In other words, caching happens only for lists that are known to be
10821 the same each time they are referenced.
10822 </para>
10823 <para>
10824 By default, there may be up to 16 named lists of each type. This limit can be
10825 extended by changing a compile-time variable. The use of domain and host lists
10826 is recommended for concepts such as local domains, relay domains, and relay
10827 hosts. The default configuration is set up like this.
10828 </para>
10829 </section>
10830 <section>
10831 <title>Named lists compared with macros</title>
10832 <para>
10833 <indexterm role="concept">
10834 <primary>list</primary>
10835 <secondary>named compared with macro</secondary>
10836 </indexterm>
10837 <indexterm role="concept">
10838 <primary>macro</primary>
10839 <secondary>compared with named list</secondary>
10840 </indexterm>
10841 At first sight, named lists might seem to be no different from macros in the
10842 configuration file. However, macros are just textual substitutions. If you
10843 write
10844 </para>
10845 <literallayout class="monospaced">
10846 ALIST = host1 : host2
10847 auth_advertise_hosts = !ALIST
10848 </literallayout>
10849 <para>
10850 it probably won&#x2019;t do what you want, because that is exactly the same as
10851 </para>
10852 <literallayout class="monospaced">
10853 auth_advertise_hosts = !host1 : host2
10854 </literallayout>
10855 <para>
10856 Notice that the second host name is not negated. However, if you use a host
10857 list, and write
10858 </para>
10859 <literallayout class="monospaced">
10860 hostlist alist = host1 : host2
10861 auth_advertise_hosts = ! +alist
10862 </literallayout>
10863 <para>
10864 the negation applies to the whole list, and so that is equivalent to
10865 </para>
10866 <literallayout class="monospaced">
10867 auth_advertise_hosts = !host1 : !host2
10868 </literallayout>
10869 </section>
10870 <section>
10871 <title>Named list caching</title>
10872 <para>
10873 <indexterm role="concept">
10874 <primary>list</primary>
10875 <secondary>caching of named</secondary>
10876 </indexterm>
10877 <indexterm role="concept">
10878 <primary>caching</primary>
10879 <secondary>named lists</secondary>
10880 </indexterm>
10881 While processing a message, Exim caches the result of checking a named list if
10882 it is sure that the list is the same each time. In practice, this means that
10883 the cache operates only if the list contains no $ characters, which guarantees
10884 that it will not change when it is expanded. Sometimes, however, you may have
10885 an expanded list that you know will be the same each time within a given
10886 message. For example:
10887 </para>
10888 <literallayout class="monospaced">
10889 domainlist special_domains = \
10890            ${lookup{$sender_host_address}cdb{/some/file}}
10891 </literallayout>
10892 <para>
10893 This provides a list of domains that depends only on the sending host&#x2019;s IP
10894 address. If this domain list is referenced a number of times (for example,
10895 in several ACL lines, or in several routers) the result of the check is not
10896 cached by default, because Exim does not know that it is going to be the
10897 same list each time.
10898 </para>
10899 <para>
10900 By appending <literal>_cache</literal> to <literal>domainlist</literal> you can tell Exim to go ahead and
10901 cache the result anyway. For example:
10902 </para>
10903 <literallayout class="monospaced">
10904 domainlist_cache special_domains = ${lookup{...
10905 </literallayout>
10906 <para>
10907 If you do this, you should be absolutely sure that caching is going to do
10908 the right thing in all cases. When in doubt, leave it out.
10909 </para>
10910 </section>
10911 <section id="SECTdomainlist">
10912 <title>Domain lists</title>
10913 <para>
10914 <indexterm role="concept">
10915 <primary>domain list</primary>
10916 <secondary>patterns for</secondary>
10917 </indexterm>
10918 <indexterm role="concept">
10919 <primary>list</primary>
10920 <secondary>domain list</secondary>
10921 </indexterm>
10922 Domain lists contain patterns that are to be matched against a mail domain.
10923 The following types of item may appear in domain lists:
10924 </para>
10925 <itemizedlist>
10926 <listitem>
10927 <para>
10928 <indexterm role="concept">
10929 <primary>primary host name</primary>
10930 </indexterm>
10931 <indexterm role="concept">
10932 <primary>host name</primary>
10933 <secondary>matched in domain list</secondary>
10934 </indexterm>
10935 <indexterm role="concept">
10936 <primary><option>primary_hostname</option></primary>
10937 </indexterm>
10938 <indexterm role="concept">
10939 <primary>domain list</primary>
10940 <secondary>matching primary host name</secondary>
10941 </indexterm>
10942 <indexterm role="concept">
10943 <primary>@ in a domain list</primary>
10944 </indexterm>
10945 If a pattern consists of a single @ character, it matches the local host name,
10946 as set by the <option>primary_hostname</option> option (or defaulted). This makes it
10947 possible to use the same configuration file on several different hosts that
10948 differ only in their names.
10949 </para>
10950 </listitem>
10951 <listitem>
10952 <para>
10953 <indexterm role="concept">
10954 <primary>@[] in a domain list</primary>
10955 </indexterm>
10956 <indexterm role="concept">
10957 <primary>domain list</primary>
10958 <secondary>matching local IP interfaces</secondary>
10959 </indexterm>
10960 <indexterm role="concept">
10961 <primary>domain literal</primary>
10962 </indexterm>
10963 If a pattern consists of the string <literal>@[]</literal> it matches any local IP interface
10964 address, enclosed in square brackets, as in an email address that contains a
10965 domain literal.
10966 In today&#x2019;s Internet, the use of domain literals is controversial.
10967 </para>
10968 </listitem>
10969 <listitem>
10970 <para>
10971 <indexterm role="concept">
10972 <primary>@mx_any</primary>
10973 </indexterm>
10974 <indexterm role="concept">
10975 <primary>@mx_primary</primary>
10976 </indexterm>
10977 <indexterm role="concept">
10978 <primary>@mx_secondary</primary>
10979 </indexterm>
10980 <indexterm role="concept">
10981 <primary>domain list</primary>
10982 <secondary>matching MX pointers to local host</secondary>
10983 </indexterm>
10984 If a pattern consists of the string <literal>@mx_any</literal> it matches any domain that
10985 has an MX record pointing to the local host or to any host that is listed in
10986 <indexterm role="concept">
10987 <primary><option>hosts_treat_as_local</option></primary>
10988 </indexterm>
10989 <option>hosts_treat_as_local</option>. The items <literal>@mx_primary</literal> and <literal>@mx_secondary</literal>
10990 are similar, except that the first matches only when a primary MX target is the
10991 local host, and the second only when no primary MX target is the local host,
10992 but a secondary MX target is. <quote>Primary</quote> means an MX record with the lowest
10993 preference value &ndash; there may of course be more than one of them.
10994 </para>
10995 <para>
10996 The MX lookup that takes place when matching a pattern of this type is
10997 performed with the resolver options for widening names turned off. Thus, for
10998 example, a single-component domain will <emphasis>not</emphasis> be expanded by adding the
10999 resolver&#x2019;s default domain. See the <option>qualify_single</option> and <option>search_parents</option>
11000 options of the <command>dnslookup</command> router for a discussion of domain widening.
11001 </para>
11002 <para>
11003 Sometimes you may want to ignore certain IP addresses when using one of these
11004 patterns. You can specify this by following the pattern with <literal>/ignore=</literal>&lt;<emphasis>ip
11005 list</emphasis>&gt;, where &lt;<emphasis>ip list</emphasis>&gt; is a list of IP addresses. These addresses are
11006 ignored when processing the pattern (compare the <option>ignore_target_hosts</option> option
11007 on a router). For example:
11008 </para>
11009 <literallayout class="monospaced">
11010 domains = @mx_any/ignore=127.0.0.1
11011 </literallayout>
11012 <para>
11013 This example matches any domain that has an MX record pointing to one of
11014 the local host&#x2019;s IP addresses other than 127.0.0.1.
11015 </para>
11016 <para>
11017 The list of IP addresses is in fact processed by the same code that processes
11018 host lists, so it may contain CIDR-coded network specifications and it may also
11019 contain negative items.
11020 </para>
11021 <para>
11022 Because the list of IP addresses is a sublist within a domain list, you have to
11023 be careful about delimiters if there is more than one address. Like any other
11024 list, the default delimiter can be changed. Thus, you might have:
11025 </para>
11026 <literallayout class="monospaced">
11027 domains = @mx_any/ignore=&lt;;127.0.0.1;0.0.0.0 : \
11028           an.other.domain : ...
11029 </literallayout>
11030 <para>
11031 so that the sublist uses semicolons for delimiters. When IPv6 addresses are
11032 involved, it is easiest to change the delimiter for the main list as well:
11033 </para>
11034 <literallayout class="monospaced">
11035 domains = &lt;? @mx_any/ignore=&lt;;127.0.0.1;::1 ? \
11036           an.other.domain ? ...
11037 </literallayout>
11038 </listitem>
11039 <listitem>
11040 <para>
11041 <indexterm role="concept">
11042 <primary>asterisk</primary>
11043 <secondary>in domain list</secondary>
11044 </indexterm>
11045 <indexterm role="concept">
11046 <primary>domain list</primary>
11047 <secondary>asterisk in</secondary>
11048 </indexterm>
11049 <indexterm role="concept">
11050 <primary>domain list</primary>
11051 <secondary>matching <quote>ends with</quote></secondary>
11052 </indexterm>
11053 If a pattern starts with an asterisk, the remaining characters of the pattern
11054 are compared with the terminating characters of the domain. The use of <quote>*</quote> in
11055 domain lists differs from its use in partial matching lookups. In a domain
11056 list, the character following the asterisk need not be a dot, whereas partial
11057 matching works only in terms of dot-separated components. For example, a domain
11058 list item such as <literal>*key.ex</literal> matches <emphasis>donkey.ex</emphasis> as well as
11059 <emphasis>cipher.key.ex</emphasis>.
11060 </para>
11061 </listitem>
11062 <listitem>
11063 <para>
11064 <indexterm role="concept">
11065 <primary>regular expressions</primary>
11066 <secondary>in domain list</secondary>
11067 </indexterm>
11068 <indexterm role="concept">
11069 <primary>domain list</primary>
11070 <secondary>matching regular expression</secondary>
11071 </indexterm>
11072 If a pattern starts with a circumflex character, it is treated as a regular
11073 expression, and matched against the domain using a regular expression matching
11074 function. The circumflex is treated as part of the regular expression.
11075 References to descriptions of the syntax of regular expressions are given in
11076 chapter <xref linkend="CHAPregexp"/>.
11077 </para>
11078 <para>
11079 <emphasis role="bold">Warning</emphasis>: Because domain lists are expanded before being processed, you
11080 must escape any backslash and dollar characters in the regular expression, or
11081 use the special <literal>\N</literal> sequence (see chapter <xref linkend="CHAPexpand"/>) to specify that
11082 it is not to be expanded (unless you really do want to build a regular
11083 expression by expansion, of course).
11084 </para>
11085 </listitem>
11086 <listitem>
11087 <para>
11088 <indexterm role="concept">
11089 <primary>lookup</primary>
11090 <secondary>in domain list</secondary>
11091 </indexterm>
11092 <indexterm role="concept">
11093 <primary>domain list</primary>
11094 <secondary>matching by lookup</secondary>
11095 </indexterm>
11096 If a pattern starts with the name of a single-key lookup type followed by a
11097 semicolon (for example, <quote>dbm;</quote> or <quote>lsearch;</quote>), the remainder of the pattern
11098 must be a file name in a suitable format for the lookup type. For example, for
11099 <quote>cdb;</quote> it must be an absolute path:
11100 </para>
11101 <literallayout class="monospaced">
11102 domains = cdb;/etc/mail/local_domains.cdb
11103 </literallayout>
11104 <para>
11105 The appropriate type of lookup is done on the file using the domain name as the
11106 key. In most cases, the data that is looked up is not used; Exim is interested
11107 only in whether or not the key is present in the file. However, when a lookup
11108 is used for the <option>domains</option> option on a router
11109 or a <option>domains</option> condition in an ACL statement, the data is preserved in the
11110 <varname>$domain_data</varname> variable and can be referred to in other router options or
11111 other statements in the same ACL.
11112 </para>
11113 </listitem>
11114 <listitem>
11115 <para>
11116 Any of the single-key lookup type names may be preceded by
11117 <literal>partial</literal>&lt;<emphasis>n</emphasis>&gt;<literal>-</literal>, where the &lt;<emphasis>n</emphasis>&gt; is optional, for example,
11118 </para>
11119 <literallayout class="monospaced">
11120 domains = partial-dbm;/partial/domains
11121 </literallayout>
11122 <para>
11123 This causes partial matching logic to be invoked; a description of how this
11124 works is given in section <xref linkend="SECTpartiallookup"/>.
11125 </para>
11126 </listitem>
11127 <listitem>
11128 <para>
11129 <indexterm role="concept">
11130 <primary>asterisk</primary>
11131 <secondary>in lookup type</secondary>
11132 </indexterm>
11133 Any of the single-key lookup types may be followed by an asterisk. This causes
11134 a default lookup for a key consisting of a single asterisk to be done if the
11135 original lookup fails. This is not a useful feature when using a domain list to
11136 select particular domains (because any domain would match), but it might have
11137 value if the result of the lookup is being used via the <varname>$domain_data</varname>
11138 expansion variable.
11139 </para>
11140 </listitem>
11141 <listitem>
11142 <para>
11143 If the pattern starts with the name of a query-style lookup type followed by a
11144 semicolon (for example, <quote>nisplus;</quote> or <quote>ldap;</quote>), the remainder of the
11145 pattern must be an appropriate query for the lookup type, as described in
11146 chapter <xref linkend="CHAPfdlookup"/>. For example:
11147 </para>
11148 <literallayout class="monospaced">
11149 hold_domains = mysql;select domain from holdlist \
11150   where domain = '$domain';
11151 </literallayout>
11152 <para>
11153 In most cases, the data that is looked up is not used (so for an SQL query, for
11154 example, it doesn&#x2019;t matter what field you select). Exim is interested only in
11155 whether or not the query succeeds. However, when a lookup is used for the
11156 <option>domains</option> option on a router, the data is preserved in the <varname>$domain_data</varname>
11157 variable and can be referred to in other options.
11158 </para>
11159 </listitem>
11160 <listitem>
11161 <para>
11162 <indexterm role="concept">
11163 <primary>domain list</primary>
11164 <secondary>matching literal domain name</secondary>
11165 </indexterm>
11166 If none of the above cases apply, a caseless textual comparison is made
11167 between the pattern and the domain.
11168 </para>
11169 </listitem>
11170 </itemizedlist>
11171 <para>
11172 Here is an example that uses several different kinds of pattern:
11173 </para>
11174 <literallayout class="monospaced">
11175 domainlist funny_domains = \
11176   @ : \
11177   lib.unseen.edu : \
11178   *.foundation.fict.example : \
11179   \N^[1-2]\d{3}\.fict\.example$\N : \
11180   partial-dbm;/opt/data/penguin/book : \
11181   nis;domains.byname : \
11182   nisplus;[name=$domain,status=local],domains.org_dir
11183 </literallayout>
11184 <para>
11185 There are obvious processing trade-offs among the various matching modes. Using
11186 an asterisk is faster than a regular expression, and listing a few names
11187 explicitly probably is too. The use of a file or database lookup is expensive,
11188 but may be the only option if hundreds of names are required. Because the
11189 patterns are tested in order, it makes sense to put the most commonly matched
11190 patterns earlier.
11191 </para>
11192 </section>
11193 <section id="SECThostlist">
11194 <title>Host lists</title>
11195 <para>
11196 <indexterm role="concept">
11197 <primary>host list</primary>
11198 <secondary>patterns in</secondary>
11199 </indexterm>
11200 <indexterm role="concept">
11201 <primary>list</primary>
11202 <secondary>host list</secondary>
11203 </indexterm>
11204 Host lists are used to control what remote hosts are allowed to do. For
11205 example, some hosts may be allowed to use the local host as a relay, and some
11206 may be permitted to use the SMTP ETRN command. Hosts can be identified in
11207 two different ways, by name or by IP address. In a host list, some types of
11208 pattern are matched to a host name, and some are matched to an IP address.
11209 You need to be particularly careful with this when single-key lookups are
11210 involved, to ensure that the right value is being used as the key.
11211 </para>
11212 </section>
11213 <section>
11214 <title>Special host list patterns</title>
11215 <para>
11216 <indexterm role="concept">
11217 <primary>empty item in hosts list</primary>
11218 </indexterm>
11219 <indexterm role="concept">
11220 <primary>host list</primary>
11221 <secondary>empty string in</secondary>
11222 </indexterm>
11223 If a host list item is the empty string, it matches only when no remote host is
11224 involved. This is the case when a message is being received from a local
11225 process using SMTP on the standard input, that is, when a TCP/IP connection is
11226 not used.
11227 </para>
11228 <para>
11229 <indexterm role="concept">
11230 <primary>asterisk</primary>
11231 <secondary>in host list</secondary>
11232 </indexterm>
11233 The special pattern <quote>*</quote> in a host list matches any host or no host. Neither
11234 the IP address nor the name is actually inspected.
11235 </para>
11236 </section>
11237 <section id="SECThoslispatip">
11238 <title>Host list patterns that match by IP address</title>
11239 <para>
11240 <indexterm role="concept">
11241 <primary>host list</primary>
11242 <secondary>matching IP addresses</secondary>
11243 </indexterm>
11244 If an IPv4 host calls an IPv6 host and the call is accepted on an IPv6 socket,
11245 the incoming address actually appears in the IPv6 host as
11246 <literal>::ffff:</literal>&lt;<emphasis>v4address</emphasis>&gt;. When such an address is tested against a host
11247 list, it is converted into a traditional IPv4 address first. (Not all operating
11248 systems accept IPv4 calls on IPv6 sockets, as there have been some security
11249 concerns.)
11250 </para>
11251 <para>
11252 The following types of pattern in a host list check the remote host by
11253 inspecting its IP address:
11254 </para>
11255 <itemizedlist>
11256 <listitem>
11257 <para>
11258 If the pattern is a plain domain name (not a regular expression, not starting
11259 with *, not a lookup of any kind), Exim calls the operating system function
11260 to find the associated IP address(es). Exim uses the newer
11261 <function>getipnodebyname()</function> function when available, otherwise <function>gethostbyname()</function>.
11262 This typically causes a forward DNS lookup of the name. The result is compared
11263 with the IP address of the subject host.
11264 </para>
11265 <para>
11266 If there is a temporary problem (such as a DNS timeout) with the host name
11267 lookup, a temporary error occurs. For example, if the list is being used in an
11268 ACL condition, the ACL gives a <quote>defer</quote> response, usually leading to a
11269 temporary SMTP error code. If no IP address can be found for the host name,
11270 what happens is described in section <xref linkend="SECTbehipnot"/> below.
11271 </para>
11272 </listitem>
11273 <listitem>
11274 <para>
11275 <indexterm role="concept">
11276 <primary>@ in a host list</primary>
11277 </indexterm>
11278 If the pattern is <quote>@</quote>, the primary host name is substituted and used as a
11279 domain name, as just described.
11280 </para>
11281 </listitem>
11282 <listitem>
11283 <para>
11284 If the pattern is an IP address, it is matched against the IP address of the
11285 subject host. IPv4 addresses are given in the normal <quote>dotted-quad</quote> notation.
11286 IPv6 addresses can be given in colon-separated format, but the colons have to
11287 be doubled so as not to be taken as item separators when the default list
11288 separator is used. IPv6 addresses are recognized even when Exim is compiled
11289 without IPv6 support. This means that if they appear in a host list on an
11290 IPv4-only host, Exim will not treat them as host names. They are just addresses
11291 that can never match a client host.
11292 </para>
11293 </listitem>
11294 <listitem>
11295 <para>
11296 <indexterm role="concept">
11297 <primary>@[] in a host list</primary>
11298 </indexterm>
11299 If the pattern is <quote>@[]</quote>, it matches the IP address of any IP interface on
11300 the local host. For example, if the local host is an IPv4 host with one
11301 interface address 10.45.23.56, these two ACL statements have the same effect:
11302 </para>
11303 <literallayout class="monospaced">
11304 accept hosts = 127.0.0.1 : 10.45.23.56
11305 accept hosts = @[]
11306 </literallayout>
11307 </listitem>
11308 <listitem>
11309 <para>
11310 <indexterm role="concept">
11311 <primary>CIDR notation</primary>
11312 </indexterm>
11313 If the pattern is an IP address followed by a slash and a mask length (for
11314 example 10.11.42.0/24), it is matched against the IP address of the subject
11315 host under the given mask. This allows, an entire network of hosts to be
11316 included (or excluded) by a single item. The mask uses CIDR notation; it
11317 specifies the number of address bits that must match, starting from the most
11318 significant end of the address.
11319 </para>
11320 <para>
11321 <emphasis role="bold">Note</emphasis>: The mask is <emphasis>not</emphasis> a count of addresses, nor is it the high number
11322 of a range of addresses. It is the number of bits in the network portion of the
11323 address. The above example specifies a 24-bit netmask, so it matches all 256
11324 addresses in the 10.11.42.0 network. An item such as
11325 </para>
11326 <literallayout class="monospaced">
11327 192.168.23.236/31
11328 </literallayout>
11329 <para>
11330 matches just two addresses, 192.168.23.236 and 192.168.23.237. A mask value of
11331 32 for an IPv4 address is the same as no mask at all; just a single address
11332 matches.
11333 </para>
11334 <para>
11335 Here is another example which shows an IPv4 and an IPv6 network:
11336 </para>
11337 <literallayout class="monospaced">
11338 recipient_unqualified_hosts = 192.168.0.0/16: \
11339                               3ffe::ffff::836f::::/48
11340 </literallayout>
11341 <para>
11342 The doubling of list separator characters applies only when these items
11343 appear inline in a host list. It is not required when indirecting via a file.
11344 For example:
11345 </para>
11346 <literallayout class="monospaced">
11347 recipient_unqualified_hosts = /opt/exim/unqualnets
11348 </literallayout>
11349 <para>
11350 could make use of a file containing
11351 </para>
11352 <literallayout class="monospaced">
11353 172.16.0.0/12
11354 3ffe:ffff:836f::/48
11355 </literallayout>
11356 <para>
11357 to have exactly the same effect as the previous example. When listing IPv6
11358 addresses inline, it is usually more convenient to use the facility for
11359 changing separator characters. This list contains the same two networks:
11360 </para>
11361 <literallayout class="monospaced">
11362 recipient_unqualified_hosts = &lt;; 172.16.0.0/12; \
11363                                  3ffe:ffff:836f::/48
11364 </literallayout>
11365 <para>
11366 The separator is changed to semicolon by the leading <quote>&lt;;</quote> at the start of the
11367 list.
11368 </para>
11369 </listitem>
11370 </itemizedlist>
11371 </section>
11372 <section id="SECThoslispatsikey">
11373 <title>Host list patterns for single-key lookups by host address</title>
11374 <para>
11375 <indexterm role="concept">
11376 <primary>host list</primary>
11377 <secondary>lookup of IP address</secondary>
11378 </indexterm>
11379 When a host is to be identified by a single-key lookup of its complete IP
11380 address, the pattern takes this form:
11381 </para>
11382 <literallayout>
11383 <literal>net-&lt;</literal><emphasis>single-key-search-type</emphasis><literal>&gt;;&lt;</literal><emphasis>search-data</emphasis><literal>&gt;</literal>
11384 </literallayout>
11385 <para>
11386 For example:
11387 </para>
11388 <literallayout class="monospaced">
11389 hosts_lookup = net-cdb;/hosts-by-ip.db
11390 </literallayout>
11391 <para>
11392 The text form of the IP address of the subject host is used as the lookup key.
11393 IPv6 addresses are converted to an unabbreviated form, using lower case
11394 letters, with dots as separators because colon is the key terminator in
11395 <command>lsearch</command> files. [Colons can in fact be used in keys in <command>lsearch</command> files by
11396 quoting the keys, but this is a facility that was added later.] The data
11397 returned by the lookup is not used.
11398 </para>
11399 <para>
11400 <indexterm role="concept">
11401 <primary>IP address</primary>
11402 <secondary>masking</secondary>
11403 </indexterm>
11404 <indexterm role="concept">
11405 <primary>host list</primary>
11406 <secondary>masked IP address</secondary>
11407 </indexterm>
11408 Single-key lookups can also be performed using masked IP addresses, using
11409 patterns of this form:
11410 </para>
11411 <literallayout>
11412 <literal>net&lt;</literal><emphasis>number</emphasis><literal>&gt;-&lt;</literal><emphasis>single-key-search-type</emphasis><literal>&gt;;&lt;</literal><emphasis>search-data</emphasis><literal>&gt;</literal>
11413 </literallayout>
11414 <para>
11415 For example:
11416 </para>
11417 <literallayout class="monospaced">
11418 net24-dbm;/networks.db
11419 </literallayout>
11420 <para>
11421 The IP address of the subject host is masked using &lt;<emphasis>number</emphasis>&gt; as the mask
11422 length. A textual string is constructed from the masked value, followed by the
11423 mask, and this is used as the lookup key. For example, if the host&#x2019;s IP address
11424 is 192.168.34.6, the key that is looked up for the above example is
11425 <quote>192.168.34.0/24</quote>. IPv6 addresses are converted to a text value using lower
11426 case letters and dots as separators instead of the more usual colon, because
11427 colon is the key terminator in <command>lsearch</command> files. Full, unabbreviated IPv6
11428 addresses are always used.
11429 </para>
11430 <para>
11431 <emphasis role="bold">Warning</emphasis>: Specifing <option>net32-</option> (for an IPv4 address) or <option>net128-</option> (for an
11432 IPv6 address) is not the same as specifing just <option>net-</option> without a number. In
11433 the former case the key strings include the mask value, whereas in the latter
11434 case the IP address is used on its own.
11435 </para>
11436 </section>
11437 <section id="SECThoslispatnam">
11438 <title>Host list patterns that match by host name</title>
11439 <para>
11440 <indexterm role="concept">
11441 <primary>host</primary>
11442 <secondary>lookup failures</secondary>
11443 </indexterm>
11444 <indexterm role="concept">
11445 <primary>unknown host name</primary>
11446 </indexterm>
11447 <indexterm role="concept">
11448 <primary>host list</primary>
11449 <secondary>matching host name</secondary>
11450 </indexterm>
11451 There are several types of pattern that require Exim to know the name of the
11452 remote host. These are either wildcard patterns or lookups by name. (If a
11453 complete hostname is given without any wildcarding, it is used to find an IP
11454 address to match against, as described in the section <xref linkend="SECThoslispatip"/>
11455 above.)
11456 </para>
11457 <para>
11458 If the remote host name is not already known when Exim encounters one of these
11459 patterns, it has to be found from the IP address.
11460 Although many sites on the Internet are conscientious about maintaining reverse
11461 DNS data for their hosts, there are also many that do not do this.
11462 Consequently, a name cannot always be found, and this may lead to unwanted
11463 effects. Take care when configuring host lists with wildcarded name patterns.
11464 Consider what will happen if a name cannot be found.
11465 </para>
11466 <para>
11467 Because of the problems of determining host names from IP addresses, matching
11468 against host names is not as common as matching against IP addresses.
11469 </para>
11470 <para>
11471 By default, in order to find a host name, Exim first does a reverse DNS lookup;
11472 if no name is found in the DNS, the system function (<function>gethostbyaddr()</function> or
11473 <function>getipnodebyaddr()</function> if available) is tried. The order in which these lookups
11474 are done can be changed by setting the <option>host_lookup_order</option> option.
11475 </para>
11476 <para>
11477 There are some options that control what happens if a host name cannot be
11478 found. These are described in section <xref linkend="SECTbehipnot"/> below.
11479 </para>
11480 <para>
11481 <indexterm role="concept">
11482 <primary>host</primary>
11483 <secondary>alias for</secondary>
11484 </indexterm>
11485 <indexterm role="concept">
11486 <primary>alias for host</primary>
11487 </indexterm>
11488 As a result of aliasing, hosts may have more than one name. When processing any
11489 of the following types of pattern, all the host&#x2019;s names are checked:
11490 </para>
11491 <itemizedlist>
11492 <listitem>
11493 <para>
11494 <indexterm role="concept">
11495 <primary>asterisk</primary>
11496 <secondary>in host list</secondary>
11497 </indexterm>
11498 If a pattern starts with <quote>*</quote> the remainder of the item must match the end of
11499 the host name. For example, <literal>*.b.c</literal> matches all hosts whose names end in
11500 <emphasis>.b.c</emphasis>. This special simple form is provided because this is a very common
11501 requirement. Other kinds of wildcarding require the use of a regular
11502 expression.
11503 </para>
11504 </listitem>
11505 <listitem>
11506 <para>
11507 <indexterm role="concept">
11508 <primary>regular expressions</primary>
11509 <secondary>in host list</secondary>
11510 </indexterm>
11511 <indexterm role="concept">
11512 <primary>host list</primary>
11513 <secondary>regular expression in</secondary>
11514 </indexterm>
11515 If the item starts with <quote>^</quote> it is taken to be a regular expression which is
11516 matched against the host name. For example,
11517 </para>
11518 <literallayout class="monospaced">
11519 ^(a|b)\.c\.d$
11520 </literallayout>
11521 <para>
11522 is a regular expression that matches either of the two hosts <emphasis>a.c.d</emphasis> or
11523 <emphasis>b.c.d</emphasis>. When a regular expression is used in a host list, you must take care
11524 that backslash and dollar characters are not misinterpreted as part of the
11525 string expansion. The simplest way to do this is to use <literal>\N</literal> to mark that
11526 part of the string as non-expandable. For example:
11527 </para>
11528 <literallayout class="monospaced">
11529 sender_unqualified_hosts = \N^(a|b)\.c\.d$\N : ....
11530 </literallayout>
11531 <para>
11532 <emphasis role="bold">Warning</emphasis>: If you want to match a complete host name, you must include the
11533 <literal>$</literal> terminating metacharacter in the regular expression, as in the above
11534 example. Without it, a match at the start of the host name is all that is
11535 required.
11536 </para>
11537 </listitem>
11538 </itemizedlist>
11539 </section>
11540 <section id="SECTbehipnot">
11541 <title>Behaviour when an IP address or name cannot be found</title>
11542 <para>
11543 <indexterm role="concept">
11544 <primary>host</primary>
11545 <secondary>lookup failures</secondary>
11546 </indexterm>
11547 While processing a host list, Exim may need to look up an IP address from a
11548 name (see section <xref linkend="SECThoslispatip"/>), or it may need to look up a host name
11549 from an IP address (see section <xref linkend="SECThoslispatnam"/>). In either case, the
11550 behaviour when it fails to find the information it is seeking is the same.
11551 </para>
11552 <para>
11553 <indexterm role="concept">
11554 <primary><literal>+include_unknown</literal></primary>
11555 </indexterm>
11556 <indexterm role="concept">
11557 <primary><literal>+ignore_unknown</literal></primary>
11558 </indexterm>
11559 By default, Exim behaves as if the host does not match the list. This may not
11560 always be what you want to happen. To change Exim&#x2019;s behaviour, the special
11561 items <literal>+include_unknown</literal> or <literal>+ignore_unknown</literal> may appear in the list (at
11562 top level &ndash; they are not recognized in an indirected file).
11563 </para>
11564 <itemizedlist>
11565 <listitem>
11566 <para>
11567 If any item that follows <literal>+include_unknown</literal> requires information that
11568 cannot found, Exim behaves as if the host does match the list. For example,
11569 </para>
11570 <literallayout class="monospaced">
11571 host_reject_connection = +include_unknown:*.enemy.ex
11572 </literallayout>
11573 <para>
11574 rejects connections from any host whose name matches <literal>*.enemy.ex</literal>, and also
11575 any hosts whose name it cannot find.
11576 </para>
11577 </listitem>
11578 <listitem>
11579 <para>
11580 If any item that follows <literal>+ignore_unknown</literal> requires information that cannot
11581 be found, Exim ignores that item and proceeds to the rest of the list. For
11582 example:
11583 </para>
11584 <literallayout class="monospaced">
11585 accept hosts = +ignore_unknown : friend.example : \
11586                192.168.4.5
11587 </literallayout>
11588 <para>
11589 accepts from any host whose name is <emphasis>friend.example</emphasis> and from 192.168.4.5,
11590 whether or not its host name can be found. Without <literal>+ignore_unknown</literal>, if no
11591 name can be found for 192.168.4.5, it is rejected.
11592 </para>
11593 </listitem>
11594 </itemizedlist>
11595 <para>
11596 Both <literal>+include_unknown</literal> and <literal>+ignore_unknown</literal> may appear in the same
11597 list. The effect of each one lasts until the next, or until the end of the
11598 list.
11599 </para>
11600 <para revisionflag="changed">
11601 <emphasis role="bold">Note</emphasis>: This section applies to permanent lookup failures. It does <emphasis>not</emphasis>
11602 apply to temporary DNS errors. They always cause a defer action (except when
11603 <option>dns_again_means_nonexist</option> converts them into permanent errors).
11604 </para>
11605 </section>
11606 <section id="SECThoslispatnamsk">
11607 <title>Host list patterns for single-key lookups by host name</title>
11608 <para>
11609 <indexterm role="concept">
11610 <primary>host</primary>
11611 <secondary>lookup failures</secondary>
11612 </indexterm>
11613 <indexterm role="concept">
11614 <primary>unknown host name</primary>
11615 </indexterm>
11616 <indexterm role="concept">
11617 <primary>host list</primary>
11618 <secondary>matching host name</secondary>
11619 </indexterm>
11620 If a pattern is of the form
11621 </para>
11622 <literallayout>
11623 &lt;<emphasis>single-key-search-type</emphasis>&gt;;&lt;<emphasis>search-data</emphasis>&gt;
11624 </literallayout>
11625 <para>
11626 for example
11627 </para>
11628 <literallayout class="monospaced">
11629 dbm;/host/accept/list
11630 </literallayout>
11631 <para>
11632 a single-key lookup is performend, using the host name as its key. If the
11633 lookup succeeds, the host matches the item. The actual data that is looked up
11634 is not used.
11635 </para>
11636 <para>
11637 <emphasis role="bold">Reminder</emphasis>: With this kind of pattern, you must have host <emphasis>names</emphasis> as
11638 keys in the file, not IP addresses. If you want to do lookups based on IP
11639 addresses, you must precede the search type with <quote>net-</quote> (see section
11640 <xref linkend="SECThoslispatsikey"/>). There is, however, no reason why you could not use
11641 two items in the same list, one doing an address lookup and one doing a name
11642 lookup, both using the same file.
11643 </para>
11644 </section>
11645 <section>
11646 <title>Host list patterns for query-style lookups</title>
11647 <para>
11648 If a pattern is of the form
11649 </para>
11650 <literallayout>
11651 &lt;<emphasis>query-style-search-type</emphasis>&gt;;&lt;<emphasis>query</emphasis>&gt;
11652 </literallayout>
11653 <para>
11654 the query is obeyed, and if it succeeds, the host matches the item. The actual
11655 data that is looked up is not used. The variables <varname>$sender_host_address</varname> and
11656 <varname>$sender_host_name</varname> can be used in the query. For example:
11657 </para>
11658 <literallayout class="monospaced">
11659 hosts_lookup = pgsql;\
11660   select ip from hostlist where ip='$sender_host_address'
11661 </literallayout>
11662 <para>
11663 The value of <varname>$sender_host_address</varname> for an IPv6 address contains colons. You
11664 can use the <option>sg</option> expansion item to change this if you need to. If you want to
11665 use masked IP addresses in database queries, you can use the <option>mask</option> expansion
11666 operator.
11667 </para>
11668 <para>
11669 If the query contains a reference to <varname>$sender_host_name</varname>, Exim automatically
11670 looks up the host name if has not already done so. (See section
11671 <xref linkend="SECThoslispatnam"/> for comments on finding host names.)
11672 </para>
11673 <para>
11674 Historical note: prior to release 4.30, Exim would always attempt to find a
11675 host name before running the query, unless the search type was preceded by
11676 <literal>net-</literal>. This is no longer the case. For backwards compatibility, <literal>net-</literal> is
11677 still recognized for query-style lookups, but its presence or absence has no
11678 effect. (Of course, for single-key lookups, <literal>net-</literal> <emphasis>is</emphasis> important.
11679 See section <xref linkend="SECThoslispatsikey"/>.)
11680 </para>
11681 </section>
11682 <section id="SECTmixwilhos">
11683 <title>Mixing wildcarded host names and addresses in host lists</title>
11684 <para>
11685 <indexterm role="concept">
11686 <primary>host list</primary>
11687 <secondary>mixing names and addresses in</secondary>
11688 </indexterm>
11689 If you have name lookups or wildcarded host names and IP addresses in the same
11690 host list, you should normally put the IP addresses first. For example, in an
11691 ACL you could have:
11692 </para>
11693 <literallayout class="monospaced">
11694 accept hosts = 10.9.8.7 : *.friend.example
11695 </literallayout>
11696 <para>
11697 The reason for this lies in the left-to-right way that Exim processes lists.
11698 It can test IP addresses without doing any DNS lookups, but when it reaches an
11699 item that requires a host name, it fails if it cannot find a host name to
11700 compare with the pattern. If the above list is given in the opposite order, the
11701 <option>accept</option> statement fails for a host whose name cannot be found, even if its
11702 IP address is 10.9.8.7.
11703 </para>
11704 <para>
11705 If you really do want to do the name check first, and still recognize the IP
11706 address, you can rewrite the ACL like this:
11707 </para>
11708 <literallayout class="monospaced">
11709 accept hosts = *.friend.example
11710 accept hosts = 10.9.8.7
11711 </literallayout>
11712 <para>
11713 If the first <option>accept</option> fails, Exim goes on to try the second one. See chapter
11714 <xref linkend="CHAPACL"/> for details of ACLs.
11715 </para>
11716 </section>
11717 <section id="SECTaddresslist">
11718 <title>Address lists</title>
11719 <para>
11720 <indexterm role="concept">
11721 <primary>list</primary>
11722 <secondary>address list</secondary>
11723 </indexterm>
11724 <indexterm role="concept">
11725 <primary>address list</primary>
11726 <secondary>empty item</secondary>
11727 </indexterm>
11728 <indexterm role="concept">
11729 <primary>address list</primary>
11730 <secondary>patterns</secondary>
11731 </indexterm>
11732 Address lists contain patterns that are matched against mail addresses. There
11733 is one special case to be considered: the sender address of a bounce message is
11734 always empty. You can test for this by providing an empty item in an address
11735 list. For example, you can set up a router to process bounce messages by
11736 using this option setting:
11737 </para>
11738 <literallayout class="monospaced">
11739 senders = :
11740 </literallayout>
11741 <para>
11742 The presence of the colon creates an empty item. If you do not provide any
11743 data, the list is empty and matches nothing. The empty sender can also be
11744 detected by a regular expression that matches an empty string,
11745 and by a query-style lookup that succeeds when <varname>$sender_address</varname> is empty.
11746 </para>
11747 <para revisionflag="changed">
11748 Non-empty items in an address list can be straightforward email addresses. For
11749 example:
11750 </para>
11751 <literallayout class="monospaced" revisionflag="changed">
11752 senders = jbc@askone.example : hs@anacreon.example
11753 </literallayout>
11754 <para revisionflag="changed">
11755 A certain amount of wildcarding is permitted. If a pattern contains an @
11756 character, but is not a regular expression and does not begin with a
11757 semicolon-terminated lookup type (described below), the local part of the
11758 subject address is compared with the local part of the pattern, which may start
11759 with an asterisk. If the local parts match, the domain is checked in exactly
11760 the same way as for a pattern in a domain list. For example, the domain can be
11761 wildcarded, refer to a named list, or be a lookup:
11762 </para>
11763 <literallayout class="monospaced" revisionflag="changed">
11764 deny senders = *@*.spamming.site:\
11765                *@+hostile_domains:\
11766                bozo@partial-lsearch;/list/of/dodgy/sites:\
11767                *@dbm;/bad/domains.db
11768 </literallayout>
11769 <para revisionflag="changed">
11770 <indexterm role="concept">
11771 <primary>local part</primary>
11772 <secondary>starting with !</secondary>
11773 </indexterm>
11774 <indexterm role="concept">
11775 <primary>address list</primary>
11776 <secondary>local part starting with !</secondary>
11777 </indexterm>
11778 If a local part that begins with an exclamation mark is required, it has to be
11779 specified using a regular expression, because otherwise the exclamation mark is
11780 treated as a sign of negation, as is standard in lists.
11781 </para>
11782 <para revisionflag="changed">
11783 If a non-empty pattern that is not a regular expression or a lookup does not
11784 contain an @ character, it is matched against the domain part of the subject
11785 address. The only two formats that are recognized this way are a literal
11786 domain, or a domain pattern that starts with *. In both these cases, the effect
11787 is the same as if <literal>*@</literal> preceded the pattern. For example:
11788 </para>
11789 <literallayout class="monospaced" revisionflag="changed">
11790 deny senders = enemy.domain : *.enemy.domain
11791 </literallayout>
11792 <para revisionflag="changed">
11793 The following kinds of more complicated address list pattern can match any
11794 address, including the empty address that is characteristic of bounce message
11795 senders:
11796 </para>
11797 <itemizedlist revisionflag="changed">
11798 <listitem>
11799 <para revisionflag="changed">
11800 <indexterm role="concept">
11801 <primary>regular expressions</primary>
11802 <secondary>in address list</secondary>
11803 </indexterm>
11804 <indexterm role="concept">
11805 <primary>address list</primary>
11806 <secondary>regular expression in</secondary>
11807 </indexterm>
11808 If (after expansion) a pattern starts with <quote>^</quote>, a regular expression match is
11809 done against the complete address, with the pattern as the regular expression.
11810 You must take care that backslash and dollar characters are not misinterpreted
11811 as part of the string expansion. The simplest way to do this is to use <literal>\N</literal>
11812 to mark that part of the string as non-expandable. For example:
11813 </para>
11814 <literallayout class="monospaced" revisionflag="changed">
11815 deny senders = \N^.*this.*@example\.com$\N : \
11816                \N^\d{8}.+@spamhaus.example$\N : ...
11817 </literallayout>
11818 <para revisionflag="changed">
11819 The <literal>\N</literal> sequences are removed by the expansion, so these items do indeed
11820 start with <quote>^</quote> by the time they are being interpreted as address patterns.
11821 </para>
11822 </listitem>
11823 <listitem>
11824 <para>
11825 <indexterm role="concept">
11826 <primary>address list</primary>
11827 <secondary>lookup for complete address</secondary>
11828 </indexterm>
11829 Complete addresses can be looked up by using a pattern that starts with a
11830 lookup type terminated by a semicolon, followed by the data for the lookup. For
11831 example:
11832 </para>
11833 <literallayout class="monospaced">
11834 deny senders = cdb;/etc/blocked.senders : \
11835   mysql;select address from blocked where \
11836   address='${quote_mysql:$sender_address}'
11837 </literallayout>
11838 <para>
11839 Both query-style and single-key lookup types can be used. For a single-key
11840 lookup type, Exim uses the complete address as the key. However, empty keys are
11841 not supported for single-key lookups, so a match against the empty address
11842 always fails. This restriction does not apply to query-style lookups.
11843 </para>
11844 <para>
11845 Partial matching for single-key lookups (section <xref linkend="SECTpartiallookup"/>)
11846 cannot be used, and is ignored if specified, with an entry being written to the
11847 panic log.
11848 <indexterm role="concept">
11849 <primary>*@ with single-key lookup</primary>
11850 </indexterm>
11851 However, you can configure lookup defaults, as described in section
11852 <xref linkend="SECTdefaultvaluelookups"/>, but this is useful only for the <quote>*@</quote> type of
11853 default. For example, with this lookup:
11854 </para>
11855 <literallayout class="monospaced">
11856 accept senders = lsearch*@;/some/file
11857 </literallayout>
11858 <para>
11859 the file could contains lines like this:
11860 </para>
11861 <literallayout class="monospaced">
11862 user1@domain1.example
11863 *@domain2.example
11864 </literallayout>
11865 <para>
11866 and for the sender address <emphasis>nimrod@jaeger.example</emphasis>, the sequence of keys
11867 that are tried is:
11868 </para>
11869 <literallayout class="monospaced">
11870 nimrod@jaeger.example
11871 *@jaeger.example
11872 *
11873 </literallayout>
11874 <para>
11875 <emphasis role="bold">Warning 1</emphasis>: Do not include a line keyed by <quote>*</quote> in the file, because that
11876 would mean that every address matches, thus rendering the test useless.
11877 </para>
11878 <para>
11879 <emphasis role="bold">Warning 2</emphasis>: Do not confuse these two kinds of item:
11880 </para>
11881 <literallayout class="monospaced">
11882 deny recipients = dbm*@;/some/file
11883 deny recipients = *@dbm;/some/file
11884 </literallayout>
11885 <para>
11886 The first does a whole address lookup, with defaulting, as just described,
11887 because it starts with a lookup type. The second matches the local part and
11888 domain independently, as described in a bullet point below.
11889 </para>
11890 </listitem>
11891 </itemizedlist>
11892 <para>
11893 The following kinds of address list pattern can match only non-empty addresses.
11894 If the subject address is empty, a match against any of these pattern types
11895 always fails.
11896 </para>
11897 <itemizedlist>
11898 <listitem>
11899 <para>
11900 <indexterm role="concept">
11901 <primary>@@ with single-key lookup</primary>
11902 </indexterm>
11903 <indexterm role="concept">
11904 <primary>address list</primary>
11905 <secondary>@@ lookup type</secondary>
11906 </indexterm>
11907 <indexterm role="concept">
11908 <primary>address list</primary>
11909 <secondary>split local part and domain</secondary>
11910 </indexterm>
11911 If a pattern starts with <quote>@@</quote> followed by a single-key lookup item
11912 (for example, <literal>@@lsearch;/some/file</literal>), the address that is being checked is
11913 split into a local part and a domain. The domain is looked up in the file. If
11914 it is not found, there is no match. If it is found, the data that is looked up
11915 from the file is treated as a colon-separated list of local part patterns, each
11916 of which is matched against the subject local part in turn.
11917 </para>
11918 <para>
11919 <indexterm role="concept">
11920 <primary>asterisk</primary>
11921 <secondary>in address list</secondary>
11922 </indexterm>
11923 The lookup may be a partial one, and/or one involving a search for a default
11924 keyed by <quote>*</quote> (see section <xref linkend="SECTdefaultvaluelookups"/>). The local part
11925 patterns that are looked up can be regular expressions or begin with <quote>*</quote>, or
11926 even be further lookups. They may also be independently negated. For example,
11927 with
11928 </para>
11929 <literallayout class="monospaced">
11930 deny senders = @@dbm;/etc/reject-by-domain
11931 </literallayout>
11932 <para>
11933 the data from which the DBM file is built could contain lines like
11934 </para>
11935 <literallayout class="monospaced">
11936 baddomain.com:  !postmaster : *
11937 </literallayout>
11938 <para>
11939 to reject all senders except <option>postmaster</option> from that domain.
11940 </para>
11941 <para>
11942 <indexterm role="concept">
11943 <primary>local part</primary>
11944 <secondary>starting with !</secondary>
11945 </indexterm>
11946 If a local part that actually begins with an exclamation mark is required, it
11947 has to be specified using a regular expression. In <command>lsearch</command> files, an entry
11948 may be split over several lines by indenting the second and subsequent lines,
11949 but the separating colon must still be included at line breaks. White space
11950 surrounding the colons is ignored. For example:
11951 </para>
11952 <literallayout class="monospaced">
11953 aol.com:  spammer1 : spammer2 : ^[0-9]+$ :
11954 spammer3 : spammer4
11955 </literallayout>
11956 <para>
11957 As in all colon-separated lists in Exim, a colon can be included in an item by
11958 doubling.
11959 </para>
11960 <para>
11961 If the last item in the list starts with a right angle-bracket, the remainder
11962 of the item is taken as a new key to look up in order to obtain a continuation
11963 list of local parts. The new key can be any sequence of characters. Thus one
11964 might have entries like
11965 </para>
11966 <literallayout class="monospaced">
11967 aol.com: spammer1 : spammer 2 : &gt;*
11968 xyz.com: spammer3 : &gt;*
11969 *:       ^\d{8}$
11970 </literallayout>
11971 <para>
11972 in a file that was searched with <option>@@dbm*</option>, to specify a match for 8-digit
11973 local parts for all domains, in addition to the specific local parts listed for
11974 each domain. Of course, using this feature costs another lookup each time a
11975 chain is followed, but the effort needed to maintain the data is reduced.
11976 </para>
11977 <para>
11978 <indexterm role="concept">
11979 <primary>loop</primary>
11980 <secondary>in lookups</secondary>
11981 </indexterm>
11982 It is possible to construct loops using this facility, and in order to catch
11983 them, the chains may be no more than fifty items long.
11984 </para>
11985 </listitem>
11986 <listitem>
11987 <para>
11988 The @@&lt;<emphasis>lookup</emphasis>&gt; style of item can also be used with a query-style
11989 lookup, but in this case, the chaining facility is not available. The lookup
11990 can only return a single list of local parts.
11991 </para>
11992 </listitem>
11993 </itemizedlist>
11994 <para>
11995 <emphasis role="bold">Warning</emphasis>: There is an important difference between the address list items
11996 in these two examples:
11997 </para>
11998 <literallayout class="monospaced">
11999 senders = +my_list
12000 senders = *@+my_list
12001 </literallayout>
12002 <para>
12003 In the first one, <literal>my_list</literal> is a named address list, whereas in the second
12004 example it is a named domain list.
12005 </para>
12006 </section>
12007 <section id="SECTcasletadd">
12008 <title>Case of letters in address lists</title>
12009 <para>
12010 <indexterm role="concept">
12011 <primary>case of local parts</primary>
12012 </indexterm>
12013 <indexterm role="concept">
12014 <primary>address list</primary>
12015 <secondary>case forcing</secondary>
12016 </indexterm>
12017 <indexterm role="concept">
12018 <primary>case forcing in address lists</primary>
12019 </indexterm>
12020 Domains in email addresses are always handled caselessly, but for local parts
12021 case may be significant on some systems (see <option>caseful_local_part</option> for how
12022 Exim deals with this when routing addresses). However, RFC 2505 (<emphasis>Anti-Spam
12023 Recommendations for SMTP MTAs</emphasis>) suggests that matching of addresses to
12024 blocking lists should be done in a case-independent manner. Since most address
12025 lists in Exim are used for this kind of control, Exim attempts to do this by
12026 default.
12027 </para>
12028 <para>
12029 The domain portion of an address is always lowercased before matching it to an
12030 address list. The local part is lowercased by default, and any string
12031 comparisons that take place are done caselessly. This means that the data in
12032 the address list itself, in files included as plain file names, and in any file
12033 that is looked up using the <quote>@@</quote> mechanism, can be in any case. However, the
12034 keys in files that are looked up by a search type other than <command>lsearch</command> (which
12035 works caselessly) must be in lower case, because these lookups are not
12036 case-independent.
12037 </para>
12038 <para>
12039 <indexterm role="concept">
12040 <primary><literal>+caseful</literal></primary>
12041 </indexterm>
12042 To allow for the possibility of caseful address list matching, if an item in
12043 an address list is the string <quote>+caseful</quote>, the original case of the local
12044 part is restored for any comparisons that follow, and string comparisons are no
12045 longer case-independent. This does not affect the domain, which remains in
12046 lower case. However, although independent matches on the domain alone are still
12047 performed caselessly, regular expressions that match against an entire address
12048 become case-sensitive after <quote>+caseful</quote> has been seen.
12049 </para>
12050 </section>
12051 <section id="SECTlocparlis">
12052 <title>Local part lists</title>
12053 <para>
12054 <indexterm role="concept">
12055 <primary>list</primary>
12056 <secondary>local part list</secondary>
12057 </indexterm>
12058 <indexterm role="concept">
12059 <primary>local part</primary>
12060 <secondary>list</secondary>
12061 </indexterm>
12062 Case-sensitivity in local part lists is handled in the same way as for address
12063 lists, as just described. The <quote>+caseful</quote> item can be used if required. In a
12064 setting of the <option>local_parts</option> option in a router with <option>caseful_local_part</option>
12065 set false, the subject is lowercased and the matching is initially
12066 case-insensitive. In this case, <quote>+caseful</quote> will restore case-sensitive
12067 matching in the local part list, but not elsewhere in the router. If
12068 <option>caseful_local_part</option> is set true in a router, matching in the <option>local_parts</option>
12069 option is case-sensitive from the start.
12070 </para>
12071 <para>
12072 If a local part list is indirected to a file (see section <xref linkend="SECTfilnamlis"/>),
12073 comments are handled in the same way as address lists &ndash; they are recognized
12074 only if the # is preceded by white space or the start of the line.
12075 Otherwise, local part lists are matched in the same way as domain lists, except
12076 that the special items that refer to the local host (<literal>@</literal>, <literal>@[]</literal>,
12077 <literal>@mx_any</literal>, <literal>@mx_primary</literal>, and <literal>@mx_secondary</literal>) are not recognized.
12078 Refer to section <xref linkend="SECTdomainlist"/> for details of the other available item
12079 types.
12080 <indexterm role="concept" startref="IIDdohoadli" class="endofrange"/>
12081 </para>
12082 </section>
12083 </chapter>
12084
12085 <chapter id="CHAPexpand">
12086 <title>String expansions</title>
12087 <para>
12088 <indexterm role="concept" id="IIDstrexp" class="startofrange">
12089 <primary>expansion</primary>
12090 <secondary>of strings</secondary>
12091 </indexterm>
12092 Many strings in Exim&#x2019;s run time configuration are expanded before use. Some of
12093 them are expanded every time they are used; others are expanded only once.
12094 </para>
12095 <para>
12096 When a string is being expanded it is copied verbatim from left to right except
12097 when a dollar or backslash character is encountered. A dollar specifies the
12098 start of a portion of the string that is interpreted and replaced as described
12099 below in section <xref linkend="SECTexpansionitems"/> onwards. Backslash is used as an
12100 escape character, as described in the following section.
12101 </para>
12102 <section id="SECTlittext">
12103 <title>Literal text in expanded strings</title>
12104 <para>
12105 <indexterm role="concept">
12106 <primary>expansion</primary>
12107 <secondary>including literal text</secondary>
12108 </indexterm>
12109 An uninterpreted dollar can be included in an expanded string by putting a
12110 backslash in front of it. A backslash can be used to prevent any special
12111 character being treated specially in an expansion, including backslash itself.
12112 If the string appears in quotes in the configuration file, two backslashes are
12113 required because the quotes themselves cause interpretation of backslashes when
12114 the string is read in (see section <xref linkend="SECTstrings"/>).
12115 </para>
12116 <para>
12117 <indexterm role="concept">
12118 <primary>expansion</primary>
12119 <secondary>non-expandable substrings</secondary>
12120 </indexterm>
12121 A portion of the string can specified as non-expandable by placing it between
12122 two occurrences of <literal>\N</literal>. This is particularly useful for protecting regular
12123 expressions, which often contain backslashes and dollar signs. For example:
12124 </para>
12125 <literallayout class="monospaced">
12126 deny senders = \N^\d{8}[a-z]@some\.site\.example$\N
12127 </literallayout>
12128 <para>
12129 On encountering the first <literal>\N</literal>, the expander copies subsequent characters
12130 without interpretation until it reaches the next <literal>\N</literal> or the end of the
12131 string.
12132 </para>
12133 </section>
12134 <section>
12135 <title>Character escape sequences in expanded strings</title>
12136 <para>
12137 <indexterm role="concept">
12138 <primary>expansion</primary>
12139 <secondary>escape sequences</secondary>
12140 </indexterm>
12141 A backslash followed by one of the letters <quote>n</quote>, <quote>r</quote>, or <quote>t</quote> in an
12142 expanded string is recognized as an escape sequence for the character newline,
12143 carriage return, or tab, respectively. A backslash followed by up to three
12144 octal digits is recognized as an octal encoding for a single character, and a
12145 backslash followed by <quote>x</quote> and up to two hexadecimal digits is a hexadecimal
12146 encoding.
12147 </para>
12148 <para>
12149 These escape sequences are also recognized in quoted strings when they are read
12150 in. Their interpretation in expansions as well is useful for unquoted strings,
12151 and for other cases such as looked-up strings that are then expanded.
12152 </para>
12153 </section>
12154 <section>
12155 <title>Testing string expansions</title>
12156 <para>
12157 <indexterm role="concept">
12158 <primary>expansion</primary>
12159 <secondary>testing</secondary>
12160 </indexterm>
12161 <indexterm role="concept">
12162 <primary>testing</primary>
12163 <secondary>string expansion</secondary>
12164 </indexterm>
12165 <indexterm role="concept">
12166 <primary><option>-be</option> option</primary>
12167 </indexterm>
12168 Many expansions can be tested by calling Exim with the <option>-be</option> option. This
12169 takes the command arguments, or lines from the standard input if there are no
12170 arguments, runs them through the string expansion code, and writes the results
12171 to the standard output. Variables based on configuration values are set up, but
12172 since no message is being processed, variables such as <varname>$local_part</varname> have no
12173 value. Nevertheless the <option>-be</option> option can be useful for checking out file and
12174 database lookups, and the use of expansion operators such as <option>sg</option>, <option>substr</option>
12175 and <option>nhash</option>.
12176 </para>
12177 <para>
12178 Exim gives up its root privilege when it is called with the <option>-be</option> option, and
12179 instead runs under the uid and gid it was called with, to prevent users from
12180 using <option>-be</option> for reading files to which they do not have access.
12181 </para>
12182 </section>
12183 <section id="SECTforexpfai">
12184 <title>Forced expansion failure</title>
12185 <para>
12186 <indexterm role="concept">
12187 <primary>expansion</primary>
12188 <secondary>forced failure</secondary>
12189 </indexterm>
12190 A number of expansions that are described in the following section have
12191 alternative <quote>true</quote> and <quote>false</quote> substrings, enclosed in brace characters
12192 (which are sometimes called <quote>curly brackets</quote>). Which of the two strings is
12193 used depends on some condition that is evaluated as part of the expansion. If,
12194 instead of a <quote>false</quote> substring, the word <quote>fail</quote> is used (not in braces),
12195 the entire string expansion fails in a way that can be detected by the code
12196 that requested the expansion. This is called <quote>forced expansion failure</quote>, and
12197 its consequences depend on the circumstances. In some cases it is no different
12198 from any other expansion failure, but in others a different action may be
12199 taken. Such variations are mentioned in the documentation of the option that is
12200 being expanded.
12201 </para>
12202 </section>
12203 <section id="SECTexpansionitems">
12204 <title>Expansion items</title>
12205 <para>
12206 The following items are recognized in expanded strings. White space may be used
12207 between sub-items that are keywords or substrings enclosed in braces inside an
12208 outer set of braces, to improve readability. <emphasis role="bold">Warning</emphasis>: Within braces,
12209 white space is significant.
12210 </para>
12211 <variablelist>
12212 <varlistentry>
12213 <term><emphasis role="bold">$</emphasis>&lt;<emphasis>variable&nbsp;name</emphasis>&gt;&nbsp;or&nbsp;<emphasis role="bold">${</emphasis>&lt;<emphasis>variable&nbsp;name</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
12214 <listitem>
12215 <para>
12216 <indexterm role="concept">
12217 <primary>expansion</primary>
12218 <secondary>variables</secondary>
12219 </indexterm>
12220 Substitute the contents of the named variable, for example:
12221 </para>
12222 <literallayout class="monospaced">
12223 $local_part
12224 ${domain}
12225 </literallayout>
12226 <para>
12227 The second form can be used to separate the name from subsequent alphanumeric
12228 characters. This form (using braces) is available only for variables; it does
12229 <emphasis>not</emphasis> apply to message headers. The names of the variables are given in
12230 section <xref linkend="SECTexpvar"/> below. If the name of a non-existent variable is
12231 given, the expansion fails.
12232 </para>
12233 </listitem></varlistentry>
12234 <varlistentry>
12235 <term><emphasis role="bold">${</emphasis>&lt;<emphasis>op</emphasis>&gt;<emphasis role="bold">:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
12236 <listitem>
12237 <para>
12238 <indexterm role="concept">
12239 <primary>expansion</primary>
12240 <secondary>operators</secondary>
12241 </indexterm>
12242 The string is first itself expanded, and then the operation specified by
12243 &lt;<emphasis>op</emphasis>&gt; is applied to it. For example:
12244 </para>
12245 <literallayout class="monospaced">
12246 ${lc:$local_part}
12247 </literallayout>
12248 <para>
12249 The string starts with the first character after the colon, which may be
12250 leading white space. A list of operators is given in section <xref linkend="SECTexpop"/>
12251 below. The operator notation is used for simple expansion items that have just
12252 one argument, because it reduces the number of braces and therefore makes the
12253 string easier to understand.
12254 </para>
12255 </listitem></varlistentry>
12256 <varlistentry>
12257 <term><emphasis role="bold">${dlfunc{</emphasis>&lt;<emphasis>file</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>function</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>arg</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>arg</emphasis>&gt;<emphasis role="bold">}...}</emphasis></term>
12258 <listitem>
12259 <para>
12260 <indexterm role="concept">
12261 <primary><option>dlfunc</option></primary>
12262 </indexterm>
12263 This expansion dynamically loads and then calls a locally-written C function.
12264 This functionality is available only if Exim is compiled with
12265 </para>
12266 <literallayout class="monospaced">
12267 EXPAND_DLFUNC=yes
12268 </literallayout>
12269 <para>
12270 set in <filename>Local/Makefile</filename>. Once loaded, Exim remembers the dynamically loaded
12271 object so that it doesn&#x2019;t reload the same object file in the same Exim process
12272 (but of course Exim does start new processes frequently).
12273 </para>
12274 <para>
12275 There may be from zero to eight arguments to the function. When compiling
12276 a local function that is to be called in this way, <filename>local_scan.h</filename> should be
12277 included. The Exim variables and functions that are defined by that API
12278 are also available for dynamically loaded functions. The function itself
12279 must have the following type:
12280 </para>
12281 <literallayout class="monospaced">
12282 int dlfunction(uschar **yield, int argc, uschar *argv[])
12283 </literallayout>
12284 <para>
12285 Where <literal>uschar</literal> is a typedef for <literal>unsigned char</literal> in <filename>local_scan.h</filename>. The
12286 function should return one of the following values:
12287 </para>
12288 <para>
12289 <literal>OK</literal>: Success. The string that is placed in the variable <emphasis>yield</emphasis> is put
12290 into the expanded string that is being built.
12291 </para>
12292 <para>
12293 <literal>FAIL</literal>: A non-forced expansion failure occurs, with the error message taken
12294 from <emphasis>yield</emphasis>, if it is set.
12295 </para>
12296 <para>
12297 <literal>FAIL_FORCED</literal>: A forced expansion failure occurs, with the error message
12298 taken from <emphasis>yield</emphasis> if it is set.
12299 </para>
12300 <para>
12301 <literal>ERROR</literal>: Same as <literal>FAIL</literal>, except that a panic log entry is written.
12302 </para>
12303 <para>
12304 When compiling a function that is to be used in this way with gcc,
12305 you need to add <option>-shared</option> to the gcc command. Also, in the Exim build-time
12306 configuration, you must add <option>-export-dynamic</option> to EXTRALIBS.
12307 </para>
12308 </listitem></varlistentry>
12309 <varlistentry>
12310 <term><emphasis role="bold">${extract{</emphasis>&lt;<emphasis>key</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string3</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
12311 <listitem>
12312 <para>
12313 <indexterm role="concept">
12314 <primary>expansion</primary>
12315 <secondary>extracting substrings by key</secondary>
12316 </indexterm>
12317 <indexterm role="concept">
12318 <primary><option>extract</option></primary>
12319 <secondary>substrings by key</secondary>
12320 </indexterm>
12321 The key and &lt;<emphasis>string1</emphasis>&gt; are first expanded separately. Leading and trailing
12322 white space is removed from the key (but not from any of the strings). The key
12323 must not consist entirely of digits. The expanded &lt;<emphasis>string1</emphasis>&gt; must be of the
12324 form:
12325 </para>
12326 <literallayout>
12327 &lt;<emphasis>key1</emphasis>&gt; = &lt;<emphasis>value1</emphasis>&gt;  &lt;<emphasis>key2</emphasis>&gt; = &lt;<emphasis>value2</emphasis>&gt; ...
12328 </literallayout>
12329 <para>
12330 <indexterm role="concept">
12331 <primary><varname>$value</varname></primary>
12332 </indexterm>
12333 where the equals signs and spaces (but not both) are optional. If any of the
12334 values contain white space, they must be enclosed in double quotes, and any
12335 values that are enclosed in double quotes are subject to escape processing as
12336 described in section <xref linkend="SECTstrings"/>. The expanded &lt;<emphasis>string1</emphasis>&gt; is searched
12337 for the value that corresponds to the key. The search is case-insensitive. If
12338 the key is found, &lt;<emphasis>string2</emphasis>&gt; is expanded, and replaces the whole item;
12339 otherwise &lt;<emphasis>string3</emphasis>&gt; is used. During the expansion of &lt;<emphasis>string2</emphasis>&gt; the
12340 variable <varname>$value</varname> contains the value that has been extracted. Afterwards, it
12341 is restored to any previous value it might have had.
12342 </para>
12343 <para>
12344 If {&lt;<emphasis>string3</emphasis>&gt;} is omitted, the item is replaced by an empty string if the
12345 key is not found. If {&lt;<emphasis>string2</emphasis>&gt;} is also omitted, the value that was
12346 extracted is used. Thus, for example, these two expansions are identical, and
12347 yield <quote>2001</quote>:
12348 </para>
12349 <literallayout class="monospaced">
12350 ${extract{gid}{uid=1984 gid=2001}}
12351 ${extract{gid}{uid=1984 gid=2001}{$value}}
12352 </literallayout>
12353 <para>
12354 Instead of {&lt;<emphasis>string3</emphasis>&gt;} the word <quote>fail</quote> (not in curly brackets) can
12355 appear, for example:
12356 </para>
12357 <literallayout class="monospaced">
12358 ${extract{Z}{A=... B=...}{$value} fail }
12359 </literallayout>
12360 <para>
12361 This forces an expansion failure (see section <xref linkend="SECTforexpfai"/>);
12362 {&lt;<emphasis>string2</emphasis>&gt;} must be present for <quote>fail</quote> to be recognized.
12363 </para>
12364 </listitem></varlistentry>
12365 <varlistentry>
12366 <term><emphasis role="bold">${extract{</emphasis>&lt;<emphasis>number</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>separators</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string3</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
12367 <listitem>
12368 <para>
12369 <indexterm role="concept">
12370 <primary>expansion</primary>
12371 <secondary>extracting substrings by number</secondary>
12372 </indexterm>
12373 <indexterm role="concept">
12374 <primary><option>extract</option></primary>
12375 <secondary>substrings by number</secondary>
12376 </indexterm>
12377 The &lt;<emphasis>number</emphasis>&gt; argument must consist entirely of decimal digits,
12378 apart from leading and trailing white space, which is ignored.
12379 This is what distinguishes this form of <option>extract</option> from the previous kind. It
12380 behaves in the same way, except that, instead of extracting a named field, it
12381 extracts from &lt;<emphasis>string1</emphasis>&gt; the field whose number is given as the first
12382 argument. You can use <varname>$value</varname> in &lt;<emphasis>string2</emphasis>&gt; or <literal>fail</literal> instead of
12383 &lt;<emphasis>string3</emphasis>&gt; as before.
12384 </para>
12385 <para>
12386 The fields in the string are separated by any one of the characters in the
12387 separator string. These may include space or tab characters.
12388 The first field is numbered one. If the number is negative, the fields are
12389 counted from the end of the string, with the rightmost one numbered -1. If the
12390 number given is zero, the entire string is returned. If the modulus of the
12391 number is greater than the number of fields in the string, the result is the
12392 expansion of &lt;<emphasis>string3</emphasis>&gt;, or the empty string if &lt;<emphasis>string3</emphasis>&gt; is not
12393 provided. For example:
12394 </para>
12395 <literallayout class="monospaced">
12396 ${extract{2}{:}{x:42:99:&amp; Mailer::/bin/bash}}
12397 </literallayout>
12398 <para>
12399 yields <quote>42</quote>, and
12400 </para>
12401 <literallayout class="monospaced">
12402 ${extract{-4}{:}{x:42:99:&amp; Mailer::/bin/bash}}
12403 </literallayout>
12404 <para>
12405 yields <quote>99</quote>. Two successive separators mean that the field between them is
12406 empty (for example, the fifth field above).
12407 </para>
12408 </listitem></varlistentry>
12409 <varlistentry>
12410 <term><emphasis role="bold">${hash{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string3</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
12411 <listitem>
12412 <para>
12413 <indexterm role="concept">
12414 <primary>hash function</primary>
12415 <secondary>textual</secondary>
12416 </indexterm>
12417 <indexterm role="concept">
12418 <primary>expansion</primary>
12419 <secondary>textual hash</secondary>
12420 </indexterm>
12421 This is a textual hashing function, and was the first to be implemented in
12422 early versions of Exim. In current releases, there are other hashing functions
12423 (numeric, MD5, and SHA-1), which are described below.
12424 </para>
12425 <para>
12426 The first two strings, after expansion, must be numbers. Call them &lt;<emphasis>m</emphasis>&gt; and
12427 &lt;<emphasis>n</emphasis>&gt;. If you are using fixed values for these numbers, that is, if
12428 &lt;<emphasis>string1</emphasis>&gt; and &lt;<emphasis>string2</emphasis>&gt; do not change when they are expanded, you can
12429 use the simpler operator notation that avoids some of the braces:
12430 </para>
12431 <literallayout class="monospaced">
12432 ${hash_&lt;n&gt;_&lt;m&gt;:&lt;string&gt;}
12433 </literallayout>
12434 <para>
12435 The second number is optional (in both notations). If &lt;<emphasis>n</emphasis>&gt; is greater than
12436 or equal to the length of the string, the expansion item returns the string.
12437 Otherwise it computes a new string of length &lt;<emphasis>n</emphasis>&gt; by applying a hashing
12438 function to the string. The new string consists of characters taken from the
12439 first &lt;<emphasis>m</emphasis>&gt; characters of the string
12440 </para>
12441 <literallayout class="monospaced">
12442 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQWRSTUVWXYZ0123456789
12443 </literallayout>
12444 <para>
12445 If &lt;<emphasis>m</emphasis>&gt; is not present the value 26 is used, so that only lower case
12446 letters appear. For example:
12447 </para>
12448 <literallayout>
12449 <literal>$hash{3}{monty}}           </literal>   yields  <literal>jmg</literal>
12450 <literal>$hash{5}{monty}}           </literal>   yields  <literal>monty</literal>
12451 <literal>$hash{4}{62}{monty python}}</literal>   yields  <literal>fbWx</literal>
12452 </literallayout>
12453 </listitem></varlistentry>
12454 <varlistentry>
12455 <term><emphasis role="bold">$header_</emphasis>&lt;<emphasis>header&nbsp;name</emphasis>&gt;<emphasis role="bold">:</emphasis>&nbsp;or&nbsp;<emphasis role="bold">$h_</emphasis>&lt;<emphasis>header&nbsp;name</emphasis>&gt;<emphasis role="bold">:</emphasis></term>
12456 <listitem>
12457 <para>
12458 See <emphasis role="bold">$rheader</emphasis> below.
12459 </para>
12460 </listitem></varlistentry>
12461 <varlistentry>
12462 <term><emphasis role="bold">$bheader_</emphasis>&lt;<emphasis>header&nbsp;name</emphasis>&gt;<emphasis role="bold">:</emphasis>&nbsp;or&nbsp;<emphasis role="bold">$bh_</emphasis>&lt;<emphasis>header&nbsp;name</emphasis>&gt;<emphasis role="bold">:</emphasis></term>
12463 <listitem>
12464 <para>
12465 See <emphasis role="bold">$rheader</emphasis> below.
12466 </para>
12467 </listitem></varlistentry>
12468 <varlistentry>
12469 <term><emphasis role="bold">$rheader_</emphasis>&lt;<emphasis>header&nbsp;name</emphasis>&gt;<emphasis role="bold">:</emphasis>&nbsp;or&nbsp;<emphasis role="bold">$rh_</emphasis>&lt;<emphasis>header&nbsp;name</emphasis>&gt;<emphasis role="bold">:</emphasis></term>
12470 <listitem>
12471 <para>
12472 <indexterm role="concept">
12473 <primary>expansion</primary>
12474 <secondary>header insertion</secondary>
12475 </indexterm>
12476 <indexterm role="concept">
12477 <primary><varname>$header_</varname></primary>
12478 </indexterm>
12479 <indexterm role="concept">
12480 <primary><varname>$bheader_</varname></primary>
12481 </indexterm>
12482 <indexterm role="concept">
12483 <primary><varname>$rheader_</varname></primary>
12484 </indexterm>
12485 <indexterm role="concept">
12486 <primary>header lines</primary>
12487 <secondary>in expansion strings</secondary>
12488 </indexterm>
12489 <indexterm role="concept">
12490 <primary>header lines</primary>
12491 <secondary>character sets</secondary>
12492 </indexterm>
12493 <indexterm role="concept">
12494 <primary>header lines</primary>
12495 <secondary>decoding</secondary>
12496 </indexterm>
12497 Substitute the contents of the named message header line, for example
12498 </para>
12499 <literallayout class="monospaced">
12500 $header_reply-to:
12501 </literallayout>
12502 <para>
12503 The newline that terminates a header line is not included in the expansion, but
12504 internal newlines (caused by splitting the header line over several physical
12505 lines) may be present.
12506 </para>
12507 <para>
12508 The difference between <option>rheader</option>, <option>bheader</option>, and <option>header</option> is in the way
12509 the data in the header line is interpreted.
12510 </para>
12511 <itemizedlist>
12512 <listitem>
12513 <para>
12514 <indexterm role="concept">
12515 <primary>white space</primary>
12516 <secondary>in header lines</secondary>
12517 </indexterm>
12518 <option>rheader</option> gives the original <quote>raw</quote> content of the header line, with no
12519 processing at all, and without the removal of leading and trailing white space.
12520 </para>
12521 </listitem>
12522 <listitem>
12523 <para>
12524 <indexterm role="concept">
12525 <primary>base64 encoding</primary>
12526 <secondary>in header lines</secondary>
12527 </indexterm>
12528 <option>bheader</option> removes leading and trailing white space, and then decodes base64
12529 or quoted-printable MIME <quote>words</quote> within the header text, but does no
12530 character set translation. If decoding of what looks superficially like a MIME
12531 <quote>word</quote> fails, the raw string is returned. If decoding
12532 <indexterm role="concept">
12533 <primary>binary zero</primary>
12534 <secondary>in header line</secondary>
12535 </indexterm>
12536 produces a binary zero character, it is replaced by a question mark &ndash; this is
12537 what Exim does for binary zeros that are actually received in header lines.
12538 </para>
12539 </listitem>
12540 <listitem>
12541 <para>
12542 <option>header</option> tries to translate the string as decoded by <option>bheader</option> to a
12543 standard character set. This is an attempt to produce the same string as would
12544 be displayed on a user&#x2019;s MUA. If translation fails, the <option>bheader</option> string is
12545 returned. Translation is attempted only on operating systems that support the
12546 <function>iconv()</function> function. This is indicated by the compile-time macro HAVE_ICONV in
12547 a system Makefile or in <filename>Local/Makefile</filename>.
12548 </para>
12549 </listitem>
12550 </itemizedlist>
12551 <para>
12552 In a filter file, the target character set for <option>header</option> can be specified by a
12553 command of the following form:
12554 </para>
12555 <literallayout class="monospaced">
12556 headers charset "UTF-8"
12557 </literallayout>
12558 <para>
12559 This command affects all references to <varname>$h_</varname> (or <varname>$header_</varname>) expansions in
12560 subsequently obeyed filter commands. In the absence of this command, the target
12561 character set in a filter is taken from the setting of the <option>headers_charset</option>
12562 option in the runtime configuration. The value of this option defaults to the
12563 value of HEADERS_CHARSET in <filename>Local/Makefile</filename>. The ultimate default is
12564 ISO-8859-1.
12565 </para>
12566 <para>
12567 Header names follow the syntax of RFC 2822, which states that they may contain
12568 any printing characters except space and colon. Consequently, curly brackets
12569 <emphasis>do not</emphasis> terminate header names, and should not be used to enclose them as
12570 if they were variables. Attempting to do so causes a syntax error.
12571 </para>
12572 <para>
12573 Only header lines that are common to all copies of a message are visible to
12574 this mechanism. These are the original header lines that are received with the
12575 message, and any that are added by an ACL <option>warn</option> statement or by a system
12576 filter. Header lines that are added to a particular copy of a message by a
12577 router or transport are not accessible.
12578 </para>
12579 <para>
12580 For incoming SMTP messages, no header lines are visible in ACLs that are obeyed
12581 before the DATA ACL, because the header structure is not set up until the
12582 message is received. Header lines that are added by <option>warn</option> statements in a
12583 RCPT ACL (for example) are saved until the message&#x2019;s incoming header lines
12584 are available, at which point they are added. When a DATA ACL is running,
12585 however, header lines added by earlier ACLs are visible.
12586 </para>
12587 <para>
12588 Upper case and lower case letters are synonymous in header names. If the
12589 following character is white space, the terminating colon may be omitted, but
12590 this is not recommended, because you may then forget it when it is needed. When
12591 white space terminates the header name, it is included in the expanded string.
12592 If the message does not contain the given header, the expansion item is
12593 replaced by an empty string. (See the <option>def</option> condition in section
12594 <xref linkend="SECTexpcond"/> for a means of testing for the existence of a header.)
12595 </para>
12596 <para>
12597 If there is more than one header with the same name, they are all
12598 concatenated to form the substitution string, up to a maximum length of 64K. A
12599 newline character is inserted between each line. For the <option>header</option> expansion,
12600 for those headers that contain lists of addresses, a comma is also inserted at
12601 the junctions between lines. This does not happen for the <option>rheader</option>
12602 expansion.
12603 </para>
12604 </listitem></varlistentry>
12605 <varlistentry>
12606 <term><emphasis role="bold">${hmac{</emphasis>&lt;<emphasis>hashname</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>secret</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
12607 <listitem>
12608 <para>
12609 <indexterm role="concept">
12610 <primary>expansion</primary>
12611 <secondary>hmac hashing</secondary>
12612 </indexterm>
12613 <indexterm role="concept">
12614 <primary><option>hmac</option></primary>
12615 </indexterm>
12616 This function uses cryptographic hashing (either MD5 or SHA-1) to convert a
12617 shared secret and some text into a message authentication code, as specified in
12618 RFC 2104. This differs from <literal>${md5:secret_text...}</literal> or
12619 <literal>${sha1:secret_text...}</literal> in that the hmac step adds a signature to the
12620 cryptographic hash, allowing for authentication that is not possible with MD5
12621 or SHA-1 alone. The hash name must expand to either <literal>md5</literal> or <literal>sha1</literal> at
12622 present. For example:
12623 </para>
12624 <literallayout class="monospaced">
12625 ${hmac{md5}{somesecret}{$primary_hostname $tod_log}}
12626 </literallayout>
12627 <para>
12628 For the hostname <emphasis>mail.example.com</emphasis> and time 2002-10-17 11:30:59, this
12629 produces:
12630 </para>
12631 <literallayout class="monospaced">
12632 dd97e3ba5d1a61b5006108f8c8252953
12633 </literallayout>
12634 <para>
12635 As an example of how this might be used, you might put in the main part of
12636 an Exim configuration:
12637 </para>
12638 <literallayout class="monospaced">
12639 SPAMSCAN_SECRET=cohgheeLei2thahw
12640 </literallayout>
12641 <para>
12642 In a router or a transport you could then have:
12643 </para>
12644 <literallayout class="monospaced">
12645 headers_add = \
12646   X-Spam-Scanned: ${primary_hostname} ${message_exim_id} \
12647   ${hmac{md5}{SPAMSCAN_SECRET}\
12648   {${primary_hostname},${message_exim_id},$h_message-id:}}
12649 </literallayout>
12650 <para>
12651 Then given a message, you can check where it was scanned by looking at the
12652 <emphasis>X-Spam-Scanned:</emphasis> header line. If you know the secret, you can check that
12653 this header line is authentic by recomputing the authentication code from the
12654 host name, message ID and the <emphasis>Message-id:</emphasis> header line. This can be done
12655 using Exim&#x2019;s <option>-be</option> option, or by other means, for example by using the
12656 <emphasis>hmac_md5_hex()</emphasis> function in Perl.
12657 </para>
12658 </listitem></varlistentry>
12659 <varlistentry>
12660 <term><emphasis role="bold">${if&nbsp;</emphasis>&lt;<emphasis>condition</emphasis>&gt;<emphasis role="bold">&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
12661 <listitem>
12662 <para>
12663 <indexterm role="concept">
12664 <primary>expansion</primary>
12665 <secondary>conditional</secondary>
12666 </indexterm>
12667 <indexterm role="concept">
12668 <primary><option>if</option>, expansion item</primary>
12669 </indexterm>
12670 If &lt;<emphasis>condition</emphasis>&gt; is true, &lt;<emphasis>string1</emphasis>&gt; is expanded and replaces the whole
12671 item; otherwise &lt;<emphasis>string2</emphasis>&gt; is used. The available conditions are described
12672 in section <xref linkend="SECTexpcond"/> below. For example:
12673 </para>
12674 <literallayout class="monospaced">
12675 ${if eq {$local_part}{postmaster} {yes}{no} }
12676 </literallayout>
12677 <para>
12678 The second string need not be present; if it is not and the condition is not
12679 true, the item is replaced with nothing. Alternatively, the word <quote>fail</quote> may
12680 be present instead of the second string (without any curly brackets). In this
12681 case, the expansion is forced to fail if the condition is not true (see section
12682 <xref linkend="SECTforexpfai"/>).
12683 </para>
12684 <para>
12685 If both strings are omitted, the result is the string <literal>true</literal> if the condition
12686 is true, and the empty string if the condition is false. This makes it less
12687 cumbersome to write custom ACL and router conditions. For example, instead of
12688 </para>
12689 <literallayout class="monospaced">
12690 condition = ${if &gt;{$acl_m4}{3}{true}{false}}
12691 </literallayout>
12692 <para>
12693 you can use
12694 </para>
12695 <literallayout class="monospaced">
12696 condition = ${if &gt;{$acl_m4}{3}}
12697 </literallayout>
12698 </listitem></varlistentry>
12699 <varlistentry>
12700 <term><emphasis role="bold">${length{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
12701 <listitem>
12702 <para>
12703 <indexterm role="concept">
12704 <primary>expansion</primary>
12705 <secondary>string truncation</secondary>
12706 </indexterm>
12707 <indexterm role="concept">
12708 <primary><option>length</option></primary>
12709 <secondary>expansion item</secondary>
12710 </indexterm>
12711 The <option>length</option> item is used to extract the initial portion of a string. Both
12712 strings are expanded, and the first one must yield a number, &lt;<emphasis>n</emphasis>&gt;, say. If
12713 you are using a fixed value for the number, that is, if &lt;<emphasis>string1</emphasis>&gt; does not
12714 change when expanded, you can use the simpler operator notation that avoids
12715 some of the braces:
12716 </para>
12717 <literallayout class="monospaced">
12718 ${length_&lt;n&gt;:&lt;string&gt;}
12719 </literallayout>
12720 <para>
12721 The result of this item is either the first &lt;<emphasis>n</emphasis>&gt; characters or the whole
12722 of &lt;<emphasis>string2</emphasis>&gt;, whichever is the shorter. Do not confuse <option>length</option> with
12723 <option>strlen</option>, which gives the length of a string.
12724 </para>
12725 </listitem></varlistentry>
12726 <varlistentry>
12727 <term><emphasis role="bold">${lookup{</emphasis>&lt;<emphasis>key</emphasis>&gt;<emphasis role="bold">}&nbsp;</emphasis>&lt;<emphasis>search&nbsp;type</emphasis>&gt;<emphasis role="bold">&nbsp;{</emphasis>&lt;<emphasis>file</emphasis>&gt;<emphasis role="bold">}&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}&nbsp;{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
12728 <listitem>
12729 <para>
12730 This is the first of one of two different types of lookup item, which are both
12731 described in the next item.
12732 </para>
12733 </listitem></varlistentry>
12734 <varlistentry>
12735 <term><emphasis role="bold">${lookup&nbsp;</emphasis>&lt;<emphasis>search&nbsp;type</emphasis>&gt;<emphasis role="bold">&nbsp;{</emphasis>&lt;<emphasis>query</emphasis>&gt;<emphasis role="bold">}&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}&nbsp;{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
12736 <listitem>
12737 <para>
12738 <indexterm role="concept">
12739 <primary>expansion</primary>
12740 <secondary>lookup in</secondary>
12741 </indexterm>
12742 <indexterm role="concept">
12743 <primary>file</primary>
12744 <secondary>lookups</secondary>
12745 </indexterm>
12746 <indexterm role="concept">
12747 <primary>lookup</primary>
12748 <secondary>in expanded string</secondary>
12749 </indexterm>
12750 The two forms of lookup item specify data lookups in files and databases, as
12751 discussed in chapter <xref linkend="CHAPfdlookup"/>. The first form is used for single-key
12752 lookups, and the second is used for query-style lookups. The &lt;<emphasis>key</emphasis>&gt;,
12753 &lt;<emphasis>file</emphasis>&gt;, and &lt;<emphasis>query</emphasis>&gt; strings are expanded before use.
12754 </para>
12755 <para>
12756 If there is any white space in a lookup item which is part of a filter command,
12757 a retry or rewrite rule, a routing rule for the <command>manualroute</command> router, or any
12758 other place where white space is significant, the lookup item must be enclosed
12759 in double quotes. The use of data lookups in users&#x2019; filter files may be locked
12760 out by the system administrator.
12761 </para>
12762 <para>
12763 <indexterm role="concept">
12764 <primary><varname>$value</varname></primary>
12765 </indexterm>
12766 If the lookup succeeds, &lt;<emphasis>string1</emphasis>&gt; is expanded and replaces the entire item.
12767 During its expansion, the variable <varname>$value</varname> contains the data returned by the
12768 lookup. Afterwards it reverts to the value it had previously (at the outer
12769 level it is empty). If the lookup fails, &lt;<emphasis>string2</emphasis>&gt; is expanded and replaces
12770 the entire item. If {&lt;<emphasis>string2</emphasis>&gt;} is omitted, the replacement is the empty
12771 string on failure. If &lt;<emphasis>string2</emphasis>&gt; is provided, it can itself be a nested
12772 lookup, thus providing a mechanism for looking up a default value when the
12773 original lookup fails.
12774 </para>
12775 <para>
12776 If a nested lookup is used as part of &lt;<emphasis>string1</emphasis>&gt;, <varname>$value</varname> contains the
12777 data for the outer lookup while the parameters of the second lookup are
12778 expanded, and also while &lt;<emphasis>string2</emphasis>&gt; of the second lookup is expanded, should
12779 the second lookup fail. Instead of {&lt;<emphasis>string2</emphasis>&gt;} the word <quote>fail</quote> can
12780 appear, and in this case, if the lookup fails, the entire expansion is forced
12781 to fail (see section <xref linkend="SECTforexpfai"/>). If both {&lt;<emphasis>string1</emphasis>&gt;} and
12782 {&lt;<emphasis>string2</emphasis>&gt;} are omitted, the result is the looked up value in the case of a
12783 successful lookup, and nothing in the case of failure.
12784 </para>
12785 <para>
12786 For single-key lookups, the string <quote>partial</quote> is permitted to precede the
12787 search type in order to do partial matching, and * or *@ may follow a search
12788 type to request default lookups if the key does not match (see sections
12789 <xref linkend="SECTdefaultvaluelookups"/> and <xref linkend="SECTpartiallookup"/> for details).
12790 </para>
12791 <para>
12792 <indexterm role="concept">
12793 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
12794 <secondary>in lookup expansion</secondary>
12795 </indexterm>
12796 If a partial search is used, the variables <varname>$1</varname> and <varname>$2</varname> contain the wild
12797 and non-wild parts of the key during the expansion of the replacement text.
12798 They return to their previous values at the end of the lookup item.
12799 </para>
12800 <para>
12801 This example looks up the postmaster alias in the conventional alias file:
12802 </para>
12803 <literallayout class="monospaced">
12804 ${lookup {postmaster} lsearch {/etc/aliases} {$value}}
12805 </literallayout>
12806 <para>
12807 This example uses NIS+ to look up the full name of the user corresponding to
12808 the local part of an address, forcing the expansion to fail if it is not found:
12809 </para>
12810 <literallayout class="monospaced">
12811 ${lookup nisplus {[name=$local_part],passwd.org_dir:gcos} \
12812   {$value}fail}
12813 </literallayout>
12814 </listitem></varlistentry>
12815 <varlistentry>
12816 <term><emphasis role="bold">${nhash{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string3</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
12817 <listitem>
12818 <para>
12819 <indexterm role="concept">
12820 <primary>expansion</primary>
12821 <secondary>numeric hash</secondary>
12822 </indexterm>
12823 <indexterm role="concept">
12824 <primary>hash function</primary>
12825 <secondary>numeric</secondary>
12826 </indexterm>
12827 The three strings are expanded; the first two must yield numbers. Call them
12828 &lt;<emphasis>n</emphasis>&gt; and &lt;<emphasis>m</emphasis>&gt;. If you are using fixed values for these numbers, that is,
12829 if &lt;<emphasis>string1</emphasis>&gt; and &lt;<emphasis>string2</emphasis>&gt; do not change when they are expanded, you
12830 can use the simpler operator notation that avoids some of the braces:
12831 </para>
12832 <literallayout class="monospaced">
12833 ${nhash_&lt;n&gt;_&lt;m&gt;:&lt;string&gt;}
12834 </literallayout>
12835 <para>
12836 The second number is optional (in both notations). If there is only one number,
12837 the result is a number in the range 0&ndash;&lt;<emphasis>n</emphasis>&gt;-1. Otherwise, the string is
12838 processed by a div/mod hash function that returns two numbers, separated by a
12839 slash, in the ranges 0 to &lt;<emphasis>n</emphasis>&gt;-1 and 0 to &lt;<emphasis>m</emphasis>&gt;-1, respectively. For
12840 example,
12841 </para>
12842 <literallayout class="monospaced">
12843 ${nhash{8}{64}{supercalifragilisticexpialidocious}}
12844 </literallayout>
12845 <para>
12846 returns the string <quote>6/33</quote>.
12847 </para>
12848 </listitem></varlistentry>
12849 <varlistentry>
12850 <term><emphasis role="bold">${perl{</emphasis>&lt;<emphasis>subroutine</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>arg</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>arg</emphasis>&gt;<emphasis role="bold">}...}</emphasis></term>
12851 <listitem>
12852 <para>
12853 <indexterm role="concept">
12854 <primary>Perl</primary>
12855 <secondary>use in expanded string</secondary>
12856 </indexterm>
12857 <indexterm role="concept">
12858 <primary>expansion</primary>
12859 <secondary>calling Perl from</secondary>
12860 </indexterm>
12861 This item is available only if Exim has been built to include an embedded Perl
12862 interpreter. The subroutine name and the arguments are first separately
12863 expanded, and then the Perl subroutine is called with those arguments. No
12864 additional arguments need be given; the maximum number permitted, including the
12865 name of the subroutine, is nine.
12866 </para>
12867 <para>
12868 The return value of the subroutine is inserted into the expanded string, unless
12869 the return value is <option>undef</option>. In that case, the expansion fails in the same
12870 way as an explicit <quote>fail</quote> on a lookup item. The return value is a scalar.
12871 Whatever you return is evaluated in a scalar context. For example, if you
12872 return the name of a Perl vector, the return value is the size of the vector,
12873 not its contents.
12874 </para>
12875 <para>
12876 If the subroutine exits by calling Perl&#x2019;s <option>die</option> function, the expansion fails
12877 with the error message that was passed to <option>die</option>. More details of the embedded
12878 Perl facility are given in chapter <xref linkend="CHAPperl"/>.
12879 </para>
12880 <para>
12881 The <command>redirect</command> router has an option called <option>forbid_filter_perl</option> which locks
12882 out the use of this expansion item in filter files.
12883 </para>
12884 </listitem></varlistentry>
12885 <varlistentry>
12886 <term><emphasis role="bold">${prvs{</emphasis>&lt;<emphasis>address</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>secret</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>keynumber</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
12887 <listitem>
12888 <para>
12889 <indexterm role="concept">
12890 <primary>prvs</primary>
12891 <secondary>expansion item</secondary>
12892 </indexterm>
12893 The first argument is a complete email address and the second is secret
12894 keystring. The third argument, specifying a key number, is optional. If absent,
12895 it defaults to 0. The result of the expansion is a prvs-signed email address,
12896 to be typically used with the <option>return_path</option> option on an <command>smtp</command> transport
12897 as part of a bounce address tag validation (BATV) scheme. For more discussion
12898 and an example, see section <xref linkend="SECTverifyPRVS"/>.
12899 </para>
12900 </listitem></varlistentry>
12901 <varlistentry>
12902 <term><emphasis role="bold">${prvscheck{</emphasis>&lt;<emphasis>address</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>secret</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
12903 <listitem>
12904 <para>
12905 <indexterm role="concept">
12906 <primary>prvscheck</primary>
12907 <secondary>expansion item</secondary>
12908 </indexterm>
12909 This expansion item is the complement of the <option>prvs</option> item. It is used for
12910 checking prvs-signed addresses. If the expansion of the first argument does not
12911 yield a syntactically valid prvs-signed address, the whole item expands to the
12912 empty string. When the first argument does expand to a syntactically valid
12913 prvs-signed address, the second argument is expanded, with the prvs-decoded
12914 version of the address and the key number extracted from the address in the
12915 variables <varname>$prvscheck_address</varname> and <varname>$prvscheck_keynum</varname>, respectively.
12916 </para>
12917 <para>
12918 These two variables can be used in the expansion of the second argument to
12919 retrieve the secret. The validity of the prvs-signed address is then checked
12920 against the secret. The result is stored in the variable <varname>$prvscheck_result</varname>,
12921 which is empty for failure or <quote>1</quote> for success.
12922 </para>
12923 <para>
12924 The third argument is optional; if it is missing, it defaults to an empty
12925 string. This argument is now expanded. If the result is an empty string, the
12926 result of the expansion is the decoded version of the address. This is the case
12927 whether or not the signature was valid. Otherwise, the result of the expansion
12928 is the expansion of the third argument.
12929 </para>
12930 <para>
12931 All three variables can be used in the expansion of the third argument.
12932 However, once the expansion is complete, only <varname>$prvscheck_result</varname> remains set.
12933 For more discussion and an example, see section <xref linkend="SECTverifyPRVS"/>.
12934 </para>
12935 </listitem></varlistentry>
12936 <varlistentry>
12937 <term><emphasis role="bold">${readfile{</emphasis>&lt;<emphasis>file&nbsp;name</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>eol&nbsp;string</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
12938 <listitem>
12939 <para>
12940 <indexterm role="concept">
12941 <primary>expansion</primary>
12942 <secondary>inserting an entire file</secondary>
12943 </indexterm>
12944 <indexterm role="concept">
12945 <primary>file</primary>
12946 <secondary>inserting into expansion</secondary>
12947 </indexterm>
12948 <indexterm role="concept">
12949 <primary><option>readfile</option> expansion item</primary>
12950 </indexterm>
12951 The file name and end-of-line string are first expanded separately. The file is
12952 then read, and its contents replace the entire item. All newline characters in
12953 the file are replaced by the end-of-line string if it is present. Otherwise,
12954 newlines are left in the string.
12955 String expansion is not applied to the contents of the file. If you want this,
12956 you must wrap the item in an <option>expand</option> operator. If the file cannot be read,
12957 the string expansion fails.
12958 </para>
12959 <para>
12960 The <command>redirect</command> router has an option called <option>forbid_filter_readfile</option> which
12961 locks out the use of this expansion item in filter files.
12962 </para>
12963 </listitem></varlistentry>
12964 <varlistentry>
12965 <term><emphasis role="bold">${readsocket{</emphasis>&lt;<emphasis>name</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>request</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>timeout</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>eol&nbsp;string</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>fail&nbsp;string</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
12966 <listitem>
12967 <para>
12968 <indexterm role="concept">
12969 <primary>expansion</primary>
12970 <secondary>inserting from a socket</secondary>
12971 </indexterm>
12972 <indexterm role="concept">
12973 <primary>socket</primary>
12974 <secondary>use of in expansion</secondary>
12975 </indexterm>
12976 <indexterm role="concept">
12977 <primary><option>readsocket</option> expansion item</primary>
12978 </indexterm>
12979 This item inserts data that is read from a Unix domain socket into the expanded
12980 string. The minimal way of using it uses just two arguments:
12981 </para>
12982 <literallayout class="monospaced">
12983 ${readsocket{/socket/name}{request string}}
12984 </literallayout>
12985 <para>
12986 Exim connects to the socket, writes the request string (unless it is an
12987 empty string) and reads from the socket until an end-of-file is read. A timeout
12988 of 5 seconds is applied. Additional, optional arguments extend what can be
12989 done. Firstly, you can vary the timeout. For example:
12990 </para>
12991 <literallayout class="monospaced">
12992 ${readsocket{/socket/name}{request-string}{3s}}
12993 </literallayout>
12994 <para>
12995 A fourth argument allows you to change any newlines that are in the data
12996 that is read, in the same way as for <option>readfile</option> (see above). This example
12997 turns them into spaces:
12998 </para>
12999 <literallayout class="monospaced">
13000 ${readsocket{/socket/name}{request-string}{3s}{ }}
13001 </literallayout>
13002 <para>
13003 As with all expansions, the substrings are expanded before the processing
13004 happens. Errors in these sub-expansions cause the expansion to fail. In
13005 addition, the following errors can occur:
13006 </para>
13007 <itemizedlist>
13008 <listitem>
13009 <para>
13010 Failure to create a socket file descriptor;
13011 </para>
13012 </listitem>
13013 <listitem>
13014 <para>
13015 Failure to connect the socket;
13016 </para>
13017 </listitem>
13018 <listitem>
13019 <para>
13020 Failure to write the request-string;
13021 </para>
13022 </listitem>
13023 <listitem>
13024 <para>
13025 Timeout on reading from the socket.
13026 </para>
13027 </listitem>
13028 </itemizedlist>
13029 <para>
13030 By default, any of these errors causes the expansion to fail. However, if
13031 you supply a fifth substring, it is expanded and used when any of the above
13032 errors occurs. For example:
13033 </para>
13034 <literallayout class="monospaced">
13035 ${readsocket{/socket/name}{request-string}{3s}{\n}\
13036   {socket failure}}
13037 </literallayout>
13038 <para>
13039 You can test for the existence of the socket by wrapping this expansion in
13040 <literal>${if exists</literal>, but there is a race condition between that test and the
13041 actual opening of the socket, so it is safer to use the fifth argument if you
13042 want to be absolutely sure of avoiding an expansion error for a non-existent
13043 socket.
13044 </para>
13045 <para>
13046 The <command>redirect</command> router has an option called <option>forbid_filter_readsocket</option> which
13047 locks out the use of this expansion item in filter files.
13048 </para>
13049 </listitem></varlistentry>
13050 <varlistentry>
13051 <term><emphasis role="bold">$rheader_</emphasis>&lt;<emphasis>header&nbsp;name</emphasis>&gt;<emphasis role="bold">:&nbsp;or&nbsp;$rh_</emphasis>&lt;<emphasis>header&nbsp;name</emphasis>&gt;<emphasis role="bold">:</emphasis></term>
13052 <listitem>
13053 <para>
13054 This item inserts <quote>raw</quote> header lines. It is described with the <option>header</option>
13055 expansion item above.
13056 </para>
13057 </listitem></varlistentry>
13058 <varlistentry>
13059 <term><emphasis role="bold">${run{</emphasis>&lt;<emphasis>command</emphasis>&gt;<emphasis role="bold">&nbsp;</emphasis>&lt;<emphasis>args</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
13060 <listitem>
13061 <para>
13062 <indexterm role="concept">
13063 <primary>expansion</primary>
13064 <secondary>running a command</secondary>
13065 </indexterm>
13066 <indexterm role="concept">
13067 <primary><option>run</option> expansion item</primary>
13068 </indexterm>
13069 The command and its arguments are first expanded separately, and then the
13070 command is run in a separate process, but under the same uid and gid. As in
13071 other command executions from Exim, a shell is not used by default. If you want
13072 a shell, you must explicitly code it.
13073 </para>
13074 <para>
13075 <indexterm role="concept">
13076 <primary>return code</primary>
13077 <secondary>from <option>run</option> expansion</secondary>
13078 </indexterm>
13079 <indexterm role="concept">
13080 <primary><varname>$value</varname></primary>
13081 </indexterm>
13082 If the command succeeds (gives a zero return code) &lt;<emphasis>string1</emphasis>&gt; is expanded
13083 and replaces the entire item; during this expansion, the standard output from
13084 the command is in the variable <varname>$value</varname>. If the command fails, &lt;<emphasis>string2</emphasis>&gt;,
13085 if present, is expanded and used. Once again, during the expansion, the
13086 standard output from the command is in the variable <varname>$value</varname>. If &lt;<emphasis>string2</emphasis>&gt;
13087 is absent, the result is empty. Alternatively, &lt;<emphasis>string2</emphasis>&gt; can be the word
13088 <quote>fail</quote> (not in braces) to force expansion failure if the command does not
13089 succeed. If both strings are omitted, the result is contents of the standard
13090 output on success, and nothing on failure.
13091 </para>
13092 <para>
13093 <indexterm role="concept">
13094 <primary><varname>$runrc</varname></primary>
13095 </indexterm>
13096 The return code from the command is put in the variable <varname>$runrc</varname>, and this
13097 remains set afterwards, so in a filter file you can do things like this:
13098 </para>
13099 <literallayout class="monospaced">
13100 if "${run{x y z}{}}$runrc" is 1 then ...
13101   elif $runrc is 2 then ...
13102   ...
13103 endif
13104 </literallayout>
13105 <para>
13106 If execution of the command fails (for example, the command does not exist),
13107 the return code is 127 &ndash; the same code that shells use for non-existent
13108 commands.
13109 </para>
13110 <para>
13111 <emphasis role="bold">Warning</emphasis>: In a router or transport, you cannot assume the order in which
13112 option values are expanded, except for those preconditions whose order of
13113 testing is documented. Therefore, you cannot reliably expect to set <varname>$runrc</varname>
13114 by the expansion of one option, and use it in another.
13115 </para>
13116 <para>
13117 The <command>redirect</command> router has an option called <option>forbid_filter_run</option> which locks
13118 out the use of this expansion item in filter files.
13119 </para>
13120 </listitem></varlistentry>
13121 <varlistentry>
13122 <term><emphasis role="bold">${sg{</emphasis>&lt;<emphasis>subject</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>regex</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>replacement</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
13123 <listitem>
13124 <para>
13125 <indexterm role="concept">
13126 <primary>expansion</primary>
13127 <secondary>string substitution</secondary>
13128 </indexterm>
13129 <indexterm role="concept">
13130 <primary><option>sg</option> expansion item</primary>
13131 </indexterm>
13132 This item works like Perl&#x2019;s substitution operator (s) with the global (/g)
13133 option; hence its name. However, unlike the Perl equivalent, Exim does not
13134 modify the subject string; instead it returns the modified string for insertion
13135 into the overall expansion. The item takes three arguments: the subject string,
13136 a regular expression, and a substitution string. For example:
13137 </para>
13138 <literallayout class="monospaced">
13139 ${sg{abcdefabcdef}{abc}{xyz}}
13140 </literallayout>
13141 <para>
13142 yields <quote>xyzdefxyzdef</quote>. Because all three arguments are expanded before use,
13143 if any $ or \ characters are required in the regular expression or in the
13144 substitution string, they have to be escaped. For example:
13145 </para>
13146 <literallayout class="monospaced">
13147 ${sg{abcdef}{^(...)(...)\$}{\$2\$1}}
13148 </literallayout>
13149 <para>
13150 yields <quote>defabc</quote>, and
13151 </para>
13152 <literallayout class="monospaced">
13153 ${sg{1=A 4=D 3=C}{\N(\d+)=\N}{K\$1=}}
13154 </literallayout>
13155 <para>
13156 yields <quote>K1=A K4=D K3=C</quote>. Note the use of <literal>\N</literal> to protect the contents of
13157 the regular expression from string expansion.
13158 </para>
13159 </listitem></varlistentry>
13160 <varlistentry>
13161 <term><emphasis role="bold">${substr{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string3</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
13162 <listitem>
13163 <para>
13164 <indexterm role="concept">
13165 <primary><option>substr</option></primary>
13166 </indexterm>
13167 <indexterm role="concept">
13168 <primary>substring extraction</primary>
13169 </indexterm>
13170 <indexterm role="concept">
13171 <primary>expansion</primary>
13172 <secondary>substring extraction</secondary>
13173 </indexterm>
13174 The three strings are expanded; the first two must yield numbers. Call them
13175 &lt;<emphasis>n</emphasis>&gt; and &lt;<emphasis>m</emphasis>&gt;. If you are using fixed values for these numbers, that is,
13176 if &lt;<emphasis>string1</emphasis>&gt; and &lt;<emphasis>string2</emphasis>&gt; do not change when they are expanded, you
13177 can use the simpler operator notation that avoids some of the braces:
13178 </para>
13179 <literallayout class="monospaced">
13180 ${substr_&lt;n&gt;_&lt;m&gt;:&lt;string&gt;}
13181 </literallayout>
13182 <para>
13183 The second number is optional (in both notations).
13184 If it is absent in the simpler format, the preceding underscore must also be
13185 omitted.
13186 </para>
13187 <para>
13188 The <option>substr</option> item can be used to extract more general substrings than
13189 <option>length</option>. The first number, &lt;<emphasis>n</emphasis>&gt;, is a starting offset, and &lt;<emphasis>m</emphasis>&gt; is the
13190 length required. For example
13191 </para>
13192 <literallayout class="monospaced">
13193 ${substr{3}{2}{$local_part}}
13194 </literallayout>
13195 <para>
13196 If the starting offset is greater than the string length the result is the
13197 null string; if the length plus starting offset is greater than the string
13198 length, the result is the right-hand part of the string, starting from the
13199 given offset. The first character in the string has offset zero.
13200 </para>
13201 <para>
13202 The <option>substr</option> expansion item can take negative offset values to count
13203 from the right-hand end of its operand. The last character is offset -1, the
13204 second-last is offset -2, and so on. Thus, for example,
13205 </para>
13206 <literallayout class="monospaced">
13207 ${substr{-5}{2}{1234567}}
13208 </literallayout>
13209 <para>
13210 yields <quote>34</quote>. If the absolute value of a negative offset is greater than the
13211 length of the string, the substring starts at the beginning of the string, and
13212 the length is reduced by the amount of overshoot. Thus, for example,
13213 </para>
13214 <literallayout class="monospaced">
13215 ${substr{-5}{2}{12}}
13216 </literallayout>
13217 <para>
13218 yields an empty string, but
13219 </para>
13220 <literallayout class="monospaced">
13221 ${substr{-3}{2}{12}}
13222 </literallayout>
13223 <para>
13224 yields <quote>1</quote>.
13225 </para>
13226 <para>
13227 When the second number is omitted from <option>substr</option>, the remainder of the string
13228 is taken if the offset is positive. If it is negative, all characters in the
13229 string preceding the offset point are taken. For example, an offset of -1 and
13230 no length, as in these semantically identical examples:
13231 </para>
13232 <literallayout class="monospaced">
13233 ${substr_-1:abcde}
13234 ${substr{-1}{abcde}}
13235 </literallayout>
13236 <para>
13237 yields all but the last character of the string, that is, <quote>abcd</quote>.
13238 </para>
13239 </listitem></varlistentry>
13240 <varlistentry>
13241 <term><emphasis role="bold">${tr{</emphasis>&lt;<emphasis>subject</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>characters</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>replacements</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
13242 <listitem>
13243 <para>
13244 <indexterm role="concept">
13245 <primary>expansion</primary>
13246 <secondary>character translation</secondary>
13247 </indexterm>
13248 <indexterm role="concept">
13249 <primary><option>tr</option> expansion item</primary>
13250 </indexterm>
13251 This item does single-character translation on its subject string. The second
13252 argument is a list of characters to be translated in the subject string. Each
13253 matching character is replaced by the corresponding character from the
13254 replacement list. For example
13255 </para>
13256 <literallayout class="monospaced">
13257 ${tr{abcdea}{ac}{13}}
13258 </literallayout>
13259 <para>
13260 yields <literal>1b3de1</literal>. If there are duplicates in the second character string, the
13261 last occurrence is used. If the third string is shorter than the second, its
13262 last character is replicated. However, if it is empty, no translation takes
13263 place.
13264 </para>
13265 </listitem></varlistentry>
13266 </variablelist>
13267 </section>
13268 <section id="SECTexpop">
13269 <title>Expansion operators</title>
13270 <para>
13271 <indexterm role="concept">
13272 <primary>expansion</primary>
13273 <secondary>operators</secondary>
13274 </indexterm>
13275 For expansion items that perform transformations on a single argument string,
13276 the <quote>operator</quote> notation is used because it is simpler and uses fewer braces.
13277 The substring is first expanded before the operation is applied to it. The
13278 following operations can be performed:
13279 </para>
13280 <variablelist>
13281 <varlistentry>
13282 <term><emphasis role="bold">${address:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13283 <listitem>
13284 <para>
13285 <indexterm role="concept">
13286 <primary>expansion</primary>
13287 <secondary>RFC 2822 address handling</secondary>
13288 </indexterm>
13289 <indexterm role="concept">
13290 <primary><option>address</option></primary>
13291 <secondary>expansion item</secondary>
13292 </indexterm>
13293 The string is interpreted as an RFC 2822 address, as it might appear in a
13294 header line, and the effective address is extracted from it. If the string does
13295 not parse successfully, the result is empty.
13296 </para>
13297 </listitem></varlistentry>
13298 <varlistentry>
13299 <term><emphasis role="bold">${base62:</emphasis>&lt;<emphasis>digits</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13300 <listitem>
13301 <para>
13302 <indexterm role="concept">
13303 <primary><option>base62</option></primary>
13304 </indexterm>
13305 <indexterm role="concept">
13306 <primary>expansion</primary>
13307 <secondary>conversion to base 62</secondary>
13308 </indexterm>
13309 The string must consist entirely of decimal digits. The number is converted to
13310 base 62 and output as a string of six characters, including leading zeros. In
13311 the few operating environments where Exim uses base 36 instead of base 62 for
13312 its message identifiers (because those systems do not have case-sensitive file
13313 names), base 36 is used by this operator, despite its name. <emphasis role="bold">Note</emphasis>: Just to
13314 be absolutely clear: this is <emphasis>not</emphasis> base64 encoding.
13315 </para>
13316 </listitem></varlistentry>
13317 <varlistentry>
13318 <term><emphasis role="bold">${base62d:</emphasis>&lt;<emphasis>base-62&nbsp;digits</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13319 <listitem>
13320 <para>
13321 <indexterm role="concept">
13322 <primary><option>base62d</option></primary>
13323 </indexterm>
13324 <indexterm role="concept">
13325 <primary>expansion</primary>
13326 <secondary>conversion to base 62</secondary>
13327 </indexterm>
13328 The string must consist entirely of base-62 digits, or, in operating
13329 environments where Exim uses base 36 instead of base 62 for its message
13330 identifiers, base-36 digits. The number is converted to decimal and output as a
13331 string.
13332 </para>
13333 </listitem></varlistentry>
13334 <varlistentry>
13335 <term><emphasis role="bold">${domain:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13336 <listitem>
13337 <para>
13338 <indexterm role="concept">
13339 <primary>domain</primary>
13340 <secondary>extraction</secondary>
13341 </indexterm>
13342 <indexterm role="concept">
13343 <primary>expansion</primary>
13344 <secondary>domain extraction</secondary>
13345 </indexterm>
13346 The string is interpreted as an RFC 2822 address and the domain is extracted
13347 from it. If the string does not parse successfully, the result is empty.
13348 </para>
13349 </listitem></varlistentry>
13350 <varlistentry>
13351 <term><emphasis role="bold">${escape:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13352 <listitem>
13353 <para>
13354 <indexterm role="concept">
13355 <primary>expansion</primary>
13356 <secondary>escaping non-printing characters</secondary>
13357 </indexterm>
13358 <indexterm role="concept">
13359 <primary><option>escape</option>, expansion item</primary>
13360 </indexterm>
13361 If the string contains any non-printing characters, they are converted to
13362 escape sequences starting with a backslash. Whether characters with the most
13363 significant bit set (so-called <quote>8-bit characters</quote>) count as printing or not
13364 is controlled by the <option>print_topbitchars</option> option.
13365 </para>
13366 </listitem></varlistentry>
13367 <varlistentry>
13368 <term><emphasis role="bold">${eval:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis>&nbsp;and&nbsp;<emphasis role="bold">${eval10:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13369 <listitem>
13370 <para>
13371 <indexterm role="concept">
13372 <primary>expansion</primary>
13373 <secondary>expression evaluation</secondary>
13374 </indexterm>
13375 <indexterm role="concept">
13376 <primary>expansion</primary>
13377 <secondary>arithmetic expression</secondary>
13378 </indexterm>
13379 <indexterm role="concept">
13380 <primary><option>eval</option> expansion item</primary>
13381 </indexterm>
13382 These items supports simple arithmetic in expansion strings. The string (after
13383 expansion) must be a conventional arithmetic expression, but it is limited to
13384 five basic operators (plus, minus, times, divide, remainder) and parentheses.
13385 All operations are carried out using integer arithmetic. Plus and minus have a
13386 lower priority than times, divide, and remainder; operators with the same
13387 priority are evaluated from left to right.
13388 </para>
13389 <para>
13390 For <option>eval</option>, numbers may be decimal, octal (starting with <quote>0</quote>) or
13391 hexadecimal (starting with <quote>0x</quote>). For <option>eval10</option>, all numbers are taken as
13392 decimal, even if they start with a leading zero. This can be useful when
13393 processing numbers extracted from dates or times, which often do have leading
13394 zeros.
13395 </para>
13396 <para>
13397 A number may be followed by <quote>K</quote> or <quote>M</quote> to multiply it by 1024 or 1024*1024,
13398 respectively. Negative numbers are supported. The result of the computation is
13399 a decimal representation of the answer (without <quote>K</quote> or <quote>M</quote>). For example:
13400 </para>
13401 <literallayout>
13402 <literal>${eval:1+1}     </literal>  yields 2
13403 <literal>${eval:1+2*3}   </literal>  yields 7
13404 <literal>${eval:(1+2)*3} </literal>  yields 9
13405 <literal>${eval:2+42%5}  </literal>  yields 4
13406 </literallayout>
13407 <para>
13408 As a more realistic example, in an ACL you might have
13409 </para>
13410 <literallayout class="monospaced">
13411 deny   message = Too many bad recipients
13412        condition =                    \
13413          ${if and {                   \
13414            {&gt;{$rcpt_count}{10}}       \
13415            {                          \
13416            &lt;                          \
13417              {$recipients_count}      \
13418              {${eval:$rcpt_count/2}}  \
13419            }                          \
13420          }{yes}{no}}
13421 </literallayout>
13422 <para>
13423 The condition is true if there have been more than 10 RCPT commands and
13424 fewer than half of them have resulted in a valid recipient.
13425 </para>
13426 </listitem></varlistentry>
13427 <varlistentry>
13428 <term><emphasis role="bold">${expand:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13429 <listitem>
13430 <para>
13431 <indexterm role="concept">
13432 <primary>expansion</primary>
13433 <secondary>re-expansion of substring</secondary>
13434 </indexterm>
13435 The <option>expand</option> operator causes a string to be expanded for a second time. For
13436 example,
13437 </para>
13438 <literallayout class="monospaced">
13439 ${expand:${lookup{$domain}dbm{/some/file}{$value}}}
13440 </literallayout>
13441 <para>
13442 first looks up a string in a file while expanding the operand for <option>expand</option>,
13443 and then re-expands what it has found.
13444 </para>
13445 </listitem></varlistentry>
13446 <varlistentry>
13447 <term><emphasis role="bold">${from_utf8:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13448 <listitem>
13449 <para>
13450 <indexterm role="concept">
13451 <primary>Unicode</primary>
13452 </indexterm>
13453 <indexterm role="concept">
13454 <primary>UTF-8</primary>
13455 <secondary>conversion from</secondary>
13456 </indexterm>
13457 <indexterm role="concept">
13458 <primary>expansion</primary>
13459 <secondary>UTF-8 conversion</secondary>
13460 </indexterm>
13461 <indexterm role="concept">
13462 <primary><option>from_utf8</option></primary>
13463 </indexterm>
13464 The world is slowly moving towards Unicode, although there are no standards for
13465 email yet. However, other applications (including some databases) are starting
13466 to store data in Unicode, using UTF-8 encoding. This operator converts from a
13467 UTF-8 string to an ISO-8859-1 string. UTF-8 code values greater than 255 are
13468 converted to underscores. The input must be a valid UTF-8 string. If it is not,
13469 the result is an undefined sequence of bytes.
13470 </para>
13471 <para>
13472 Unicode code points with values less than 256 are compatible with ASCII and
13473 ISO-8859-1 (also known as Latin-1).
13474 For example, character 169 is the copyright symbol in both cases, though the
13475 way it is encoded is different. In UTF-8, more than one byte is needed for
13476 characters with code values greater than 127, whereas ISO-8859-1 is a
13477 single-byte encoding (but thereby limited to 256 characters). This makes
13478 translation from UTF-8 to ISO-8859-1 straightforward.
13479 </para>
13480 </listitem></varlistentry>
13481 <varlistentry>
13482 <term><emphasis role="bold">${hash_</emphasis>&lt;<emphasis>n</emphasis>&gt;<emphasis role="bold">_</emphasis>&lt;<emphasis>m</emphasis>&gt;<emphasis role="bold">:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13483 <listitem>
13484 <para>
13485 <indexterm role="concept">
13486 <primary>hash function</primary>
13487 <secondary>textual</secondary>
13488 </indexterm>
13489 <indexterm role="concept">
13490 <primary>expansion</primary>
13491 <secondary>textual hash</secondary>
13492 </indexterm>
13493 The <option>hash</option> operator is a simpler interface to the hashing function that can
13494 be used when the two parameters are fixed numbers (as opposed to strings that
13495 change when expanded). The effect is the same as
13496 </para>
13497 <literallayout class="monospaced">
13498 ${hash{&lt;n&gt;}{&lt;m&gt;}{&lt;string&gt;}}
13499 </literallayout>
13500 <para>
13501 See the description of the general <option>hash</option> item above for details. The
13502 abbreviation <option>h</option> can be used when <option>hash</option> is used as an operator.
13503 </para>
13504 </listitem></varlistentry>
13505 <varlistentry>
13506 <term><emphasis role="bold">${hex2b64:</emphasis>&lt;<emphasis>hexstring</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13507 <listitem>
13508 <para>
13509 <indexterm role="concept">
13510 <primary>base64 encoding</primary>
13511 <secondary>conversion from hex</secondary>
13512 </indexterm>
13513 <indexterm role="concept">
13514 <primary>expansion</primary>
13515 <secondary>hex to base64</secondary>
13516 </indexterm>
13517 <indexterm role="concept">
13518 <primary><option>hex2b64</option></primary>
13519 </indexterm>
13520 This operator converts a hex string into one that is base64 encoded. This can
13521 be useful for processing the output of the MD5 and SHA-1 hashing functions.
13522 </para>
13523 </listitem></varlistentry>
13524 <varlistentry>
13525 <term><emphasis role="bold">${lc:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13526 <listitem>
13527 <para>
13528 <indexterm role="concept">
13529 <primary>case forcing in strings</primary>
13530 </indexterm>
13531 <indexterm role="concept">
13532 <primary>string</primary>
13533 <secondary>case forcing</secondary>
13534 </indexterm>
13535 <indexterm role="concept">
13536 <primary>lower casing</primary>
13537 </indexterm>
13538 <indexterm role="concept">
13539 <primary>expansion</primary>
13540 <secondary>case forcing</secondary>
13541 </indexterm>
13542 <indexterm role="concept">
13543 <primary><option>lc</option> expansion item</primary>
13544 </indexterm>
13545 This forces the letters in the string into lower-case, for example:
13546 </para>
13547 <literallayout class="monospaced">
13548 ${lc:$local_part}
13549 </literallayout>
13550 </listitem></varlistentry>
13551 <varlistentry>
13552 <term><emphasis role="bold">${length_</emphasis>&lt;<emphasis>number</emphasis>&gt;<emphasis role="bold">:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13553 <listitem>
13554 <para>
13555 <indexterm role="concept">
13556 <primary>expansion</primary>
13557 <secondary>string truncation</secondary>
13558 </indexterm>
13559 <indexterm role="concept">
13560 <primary><option>length</option></primary>
13561 <secondary>expansion item</secondary>
13562 </indexterm>
13563 The <option>length</option> operator is a simpler interface to the <option>length</option> function that
13564 can be used when the parameter is a fixed number (as opposed to a string that
13565 changes when expanded). The effect is the same as
13566 </para>
13567 <literallayout class="monospaced">
13568 ${length{&lt;number&gt;}{&lt;string&gt;}}
13569 </literallayout>
13570 <para>
13571 See the description of the general <option>length</option> item above for details. Note that
13572 <option>length</option> is not the same as <option>strlen</option>. The abbreviation <option>l</option> can be used
13573 when <option>length</option> is used as an operator.
13574 </para>
13575 </listitem></varlistentry>
13576 <varlistentry>
13577 <term><emphasis role="bold">${local_part:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13578 <listitem>
13579 <para>
13580 <indexterm role="concept">
13581 <primary>expansion</primary>
13582 <secondary>local part extraction</secondary>
13583 </indexterm>
13584 <indexterm role="concept">
13585 <primary><option>local_part</option> expansion item</primary>
13586 </indexterm>
13587 The string is interpreted as an RFC 2822 address and the local part is
13588 extracted from it. If the string does not parse successfully, the result is
13589 empty.
13590 </para>
13591 </listitem></varlistentry>
13592 <varlistentry>
13593 <term><emphasis role="bold">${mask:</emphasis>&lt;<emphasis>IP&nbsp;address</emphasis>&gt;<emphasis role="bold">/</emphasis>&lt;<emphasis>bit&nbsp;count</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13594 <listitem>
13595 <para>
13596 <indexterm role="concept">
13597 <primary>masked IP address</primary>
13598 </indexterm>
13599 <indexterm role="concept">
13600 <primary>IP address</primary>
13601 <secondary>masking</secondary>
13602 </indexterm>
13603 <indexterm role="concept">
13604 <primary>CIDR notation</primary>
13605 </indexterm>
13606 <indexterm role="concept">
13607 <primary>expansion</primary>
13608 <secondary>IP address masking</secondary>
13609 </indexterm>
13610 <indexterm role="concept">
13611 <primary><option>mask</option>, expansion item</primary>
13612 </indexterm>
13613 If the form of the string to be operated on is not an IP address followed by a
13614 slash and an integer (that is, a network address in CIDR notation), the
13615 expansion fails. Otherwise, this operator converts the IP address to binary,
13616 masks off the least significant bits according to the bit count, and converts
13617 the result back to text, with mask appended. For example,
13618 </para>
13619 <literallayout class="monospaced">
13620 ${mask:10.111.131.206/28}
13621 </literallayout>
13622 <para>
13623 returns the string <quote>10.111.131.192/28</quote>. Since this operation is expected to
13624 be mostly used for looking up masked addresses in files, the result for an IPv6
13625 address uses dots to separate components instead of colons, because colon
13626 terminates a key string in lsearch files. So, for example,
13627 </para>
13628 <literallayout class="monospaced">
13629 ${mask:3ffe:ffff:836f:0a00:000a:0800:200a:c031/99}
13630 </literallayout>
13631 <para>
13632 returns the string
13633 </para>
13634 <literallayout class="monospaced">
13635 3ffe.ffff.836f.0a00.000a.0800.2000.0000/99
13636 </literallayout>
13637 <para>
13638 Letters in IPv6 addresses are always output in lower case.
13639 </para>
13640 </listitem></varlistentry>
13641 <varlistentry>
13642 <term><emphasis role="bold">${md5:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13643 <listitem>
13644 <para>
13645 <indexterm role="concept">
13646 <primary>MD5 hash</primary>
13647 </indexterm>
13648 <indexterm role="concept">
13649 <primary>expansion</primary>
13650 <secondary>MD5 hash</secondary>
13651 </indexterm>
13652 <indexterm role="concept">
13653 <primary><option>md5</option> expansion item</primary>
13654 </indexterm>
13655 The <option>md5</option> operator computes the MD5 hash value of the string, and returns it
13656 as a 32-digit hexadecimal number, in which any letters are in lower case.
13657 </para>
13658 </listitem></varlistentry>
13659 <varlistentry>
13660 <term><emphasis role="bold">${nhash_</emphasis>&lt;<emphasis>n</emphasis>&gt;<emphasis role="bold">_</emphasis>&lt;<emphasis>m</emphasis>&gt;<emphasis role="bold">:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13661 <listitem>
13662 <para>
13663 <indexterm role="concept">
13664 <primary>expansion</primary>
13665 <secondary>numeric hash</secondary>
13666 </indexterm>
13667 <indexterm role="concept">
13668 <primary>hash function</primary>
13669 <secondary>numeric</secondary>
13670 </indexterm>
13671 The <option>nhash</option> operator is a simpler interface to the numeric hashing function
13672 that can be used when the two parameters are fixed numbers (as opposed to
13673 strings that change when expanded). The effect is the same as
13674 </para>
13675 <literallayout class="monospaced">
13676 ${nhash{&lt;n&gt;}{&lt;m&gt;}{&lt;string&gt;}}
13677 </literallayout>
13678 <para>
13679 See the description of the general <option>nhash</option> item above for details.
13680 </para>
13681 </listitem></varlistentry>
13682 <varlistentry>
13683 <term><emphasis role="bold">${quote:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13684 <listitem>
13685 <para>
13686 <indexterm role="concept">
13687 <primary>quoting</primary>
13688 <secondary>in string expansions</secondary>
13689 </indexterm>
13690 <indexterm role="concept">
13691 <primary>expansion</primary>
13692 <secondary>quoting</secondary>
13693 </indexterm>
13694 <indexterm role="concept">
13695 <primary><option>quote</option>, expansion item</primary>
13696 </indexterm>
13697 The <option>quote</option> operator puts its argument into double quotes if it
13698 is an empty string or
13699 contains anything other than letters, digits, underscores, dots, and hyphens.
13700 Any occurrences of double quotes and backslashes are escaped with a backslash.
13701 Newlines and carriage returns are converted to <literal>\n</literal> and <literal>\r</literal>,
13702 respectively For example,
13703 </para>
13704 <literallayout class="monospaced">
13705 ${quote:ab"*"cd}
13706 </literallayout>
13707 <para>
13708 becomes
13709 </para>
13710 <literallayout class="monospaced">
13711 "ab\"*\"cd"
13712 </literallayout>
13713 <para>
13714 The place where this is useful is when the argument is a substitution from a
13715 variable or a message header.
13716 </para>
13717 </listitem></varlistentry>
13718 <varlistentry>
13719 <term><emphasis role="bold">${quote_local_part:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13720 <listitem>
13721 <para>
13722 <indexterm role="concept">
13723 <primary><option>quote_local_part</option> expansion item</primary>
13724 </indexterm>
13725 This operator is like <option>quote</option>, except that it quotes the string only if
13726 required to do so by the rules of RFC 2822 for quoting local parts. For
13727 example, a plus sign would not cause quoting (but it would for <option>quote</option>).
13728 If you are creating a new email address from the contents of <varname>$local_part</varname>
13729 (or any other unknown data), you should always use this operator.
13730 </para>
13731 </listitem></varlistentry>
13732 <varlistentry>
13733 <term><emphasis role="bold">${quote_</emphasis>&lt;<emphasis>lookup-type</emphasis>&gt;<emphasis role="bold">:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13734 <listitem>
13735 <para>
13736 <indexterm role="concept">
13737 <primary>quoting</primary>
13738 <secondary>lookup-specific</secondary>
13739 </indexterm>
13740 This operator applies lookup-specific quoting rules to the string. Each
13741 query-style lookup type has its own quoting rules which are described with
13742 the lookups in chapter <xref linkend="CHAPfdlookup"/>. For example,
13743 </para>
13744 <literallayout class="monospaced">
13745 ${quote_ldap:two * two}
13746 </literallayout>
13747 <para>
13748 returns
13749 </para>
13750 <literallayout class="monospaced">
13751 two%20%5C2A%20two
13752 </literallayout>
13753 <para>
13754 For single-key lookup types, no quoting is ever necessary and this operator
13755 yields an unchanged string.
13756 </para>
13757 </listitem></varlistentry>
13758 <varlistentry>
13759 <term><emphasis role="bold">${rxquote:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13760 <listitem>
13761 <para>
13762 <indexterm role="concept">
13763 <primary>quoting</primary>
13764 <secondary>in regular expressions</secondary>
13765 </indexterm>
13766 <indexterm role="concept">
13767 <primary>regular expressions</primary>
13768 <secondary>quoting</secondary>
13769 </indexterm>
13770 <indexterm role="concept">
13771 <primary><option>rxquote</option> expansion item</primary>
13772 </indexterm>
13773 The <option>rxquote</option> operator inserts a backslash before any non-alphanumeric
13774 characters in its argument. This is useful when substituting the values of
13775 variables or headers inside regular expressions.
13776 </para>
13777 </listitem></varlistentry>
13778 <varlistentry>
13779 <term><emphasis role="bold">${rfc2047:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13780 <listitem>
13781 <para>
13782 <indexterm role="concept">
13783 <primary>expansion</primary>
13784 <secondary>RFC 2047</secondary>
13785 </indexterm>
13786 <indexterm role="concept">
13787 <primary>RFC 2047</primary>
13788 <secondary>expansion operator</secondary>
13789 </indexterm>
13790 <indexterm role="concept">
13791 <primary><option>rfc2047</option> expansion item</primary>
13792 </indexterm>
13793 This operator encodes text according to the rules of RFC 2047. This is an
13794 encoding that is used in header lines to encode non-ASCII characters. It is
13795 assumed that the input string is in the encoding specified by the
13796 <option>headers_charset</option> option, which defaults to ISO-8859-1. If the string
13797 contains only characters in the range 33&ndash;126, and no instances of the
13798 characters
13799 </para>
13800 <literallayout class="monospaced">
13801 ? = ( ) &lt; &gt; @ , ; : \ " . [ ] _
13802 </literallayout>
13803 <para>
13804 it is not modified. Otherwise, the result is the RFC 2047 encoding of the
13805 string, using as many <quote>encoded words</quote> as necessary to encode all the
13806 characters.
13807 </para>
13808 </listitem></varlistentry>
13809 <varlistentry>
13810 <term><emphasis role="bold">${sha1:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13811 <listitem>
13812 <para>
13813 <indexterm role="concept">
13814 <primary>SHA-1 hash</primary>
13815 </indexterm>
13816 <indexterm role="concept">
13817 <primary>expansion</primary>
13818 <secondary>SHA-1 hashing</secondary>
13819 </indexterm>
13820 <indexterm role="concept">
13821 <primary><option>sha2</option> expansion item</primary>
13822 </indexterm>
13823 The <option>sha1</option> operator computes the SHA-1 hash value of the string, and returns
13824 it as a 40-digit hexadecimal number, in which any letters are in upper case.
13825 </para>
13826 </listitem></varlistentry>
13827 <varlistentry>
13828 <term><emphasis role="bold">${stat:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13829 <listitem>
13830 <para>
13831 <indexterm role="concept">
13832 <primary>expansion</primary>
13833 <secondary>statting a file</secondary>
13834 </indexterm>
13835 <indexterm role="concept">
13836 <primary>file</primary>
13837 <secondary>extracting characteristics</secondary>
13838 </indexterm>
13839 <indexterm role="concept">
13840 <primary><option>stat</option> expansion item</primary>
13841 </indexterm>
13842 The string, after expansion, must be a file path. A call to the <function>stat()</function>
13843 function is made for this path. If <function>stat()</function> fails, an error occurs and the
13844 expansion fails. If it succeeds, the data from the stat replaces the item, as a
13845 series of &lt;<emphasis>name</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt; pairs, where the values are all numerical,
13846 except for the value of <quote>smode</quote>. The names are: <quote>mode</quote> (giving the mode as
13847 a 4-digit octal number), <quote>smode</quote> (giving the mode in symbolic format as a
13848 10-character string, as for the <emphasis>ls</emphasis> command), <quote>inode</quote>, <quote>device</quote>,
13849 <quote>links</quote>, <quote>uid</quote>, <quote>gid</quote>, <quote>size</quote>, <quote>atime</quote>, <quote>mtime</quote>, and <quote>ctime</quote>. You
13850 can extract individual fields using the <option>extract</option> expansion item.
13851 </para>
13852 <para>
13853 The use of the <option>stat</option> expansion in users&#x2019; filter files can be locked out by
13854 the system administrator. <emphasis role="bold">Warning</emphasis>: The file size may be incorrect on 32-bit
13855 systems for files larger than 2GB.
13856 </para>
13857 </listitem></varlistentry>
13858 <varlistentry>
13859 <term><emphasis role="bold">${str2b64:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13860 <listitem>
13861 <para>
13862 <indexterm role="concept">
13863 <primary>expansion</primary>
13864 <secondary>base64 encoding</secondary>
13865 </indexterm>
13866 <indexterm role="concept">
13867 <primary>base64 encoding</primary>
13868 <secondary>in string expansion</secondary>
13869 </indexterm>
13870 <indexterm role="concept">
13871 <primary><option>str2b64</option> expansion item</primary>
13872 </indexterm>
13873 This operator converts a string into one that is base64 encoded.
13874 </para>
13875 </listitem></varlistentry>
13876 <varlistentry>
13877 <term><emphasis role="bold">${strlen:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13878 <listitem>
13879 <para>
13880 <indexterm role="concept">
13881 <primary>expansion</primary>
13882 <secondary>string length</secondary>
13883 </indexterm>
13884 <indexterm role="concept">
13885 <primary>string</primary>
13886 <secondary>length in expansion</secondary>
13887 </indexterm>
13888 <indexterm role="concept">
13889 <primary><option>strlen</option> expansion item</primary>
13890 </indexterm>
13891 The item is replace by the length of the expanded string, expressed as a
13892 decimal number. <emphasis role="bold">Note</emphasis>: Do not confuse <option>strlen</option> with <option>length</option>.
13893 </para>
13894 </listitem></varlistentry>
13895 <varlistentry>
13896 <term><emphasis role="bold">${substr_</emphasis>&lt;<emphasis>start</emphasis>&gt;<emphasis role="bold">_</emphasis>&lt;<emphasis>length</emphasis>&gt;<emphasis role="bold">:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13897 <listitem>
13898 <para>
13899 <indexterm role="concept">
13900 <primary><option>substr</option> expansion item</primary>
13901 </indexterm>
13902 <indexterm role="concept">
13903 <primary>substring extraction</primary>
13904 </indexterm>
13905 <indexterm role="concept">
13906 <primary>expansion</primary>
13907 <secondary>substring expansion</secondary>
13908 </indexterm>
13909 The <option>substr</option> operator is a simpler interface to the <option>substr</option> function that
13910 can be used when the two parameters are fixed numbers (as opposed to strings
13911 that change when expanded). The effect is the same as
13912 </para>
13913 <literallayout class="monospaced">
13914 ${substr{&lt;start&gt;}{&lt;length&gt;}{&lt;string&gt;}}
13915 </literallayout>
13916 <para>
13917 See the description of the general <option>substr</option> item above for details. The
13918 abbreviation <option>s</option> can be used when <option>substr</option> is used as an operator.
13919 </para>
13920 </listitem></varlistentry>
13921 <varlistentry revisionflag="changed">
13922 <term><emphasis role="bold">${time_eval:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13923 <listitem>
13924 <para revisionflag="changed">
13925 <indexterm role="concept">
13926 <primary><option>time_eval</option> expansion item</primary>
13927 </indexterm>
13928 <indexterm role="concept">
13929 <primary>time interval</primary>
13930 <secondary>decoding</secondary>
13931 </indexterm>
13932 This item converts an Exim time interval such as <literal>2d4h5m</literal> into a number of
13933 seconds.
13934 </para>
13935 </listitem></varlistentry>
13936 <varlistentry>
13937 <term><emphasis role="bold">${time_interval:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13938 <listitem>
13939 <para>
13940 <indexterm role="concept">
13941 <primary><option>time_interval</option> expansion item</primary>
13942 </indexterm>
13943 <indexterm role="concept">
13944 <primary>time interval</primary>
13945 <secondary>formatting</secondary>
13946 </indexterm>
13947 The argument (after sub-expansion) must be a sequence of decimal digits that
13948 represents an interval of time as a number of seconds. It is converted into a
13949 number of larger units and output in Exim&#x2019;s normal time format, for example,
13950 <literal>1w3d4h2m6s</literal>.
13951 </para>
13952 </listitem></varlistentry>
13953 <varlistentry>
13954 <term><emphasis role="bold">${uc:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13955 <listitem>
13956 <para>
13957 <indexterm role="concept">
13958 <primary>case forcing in strings</primary>
13959 </indexterm>
13960 <indexterm role="concept">
13961 <primary>string</primary>
13962 <secondary>case forcing</secondary>
13963 </indexterm>
13964 <indexterm role="concept">
13965 <primary>upper casing</primary>
13966 </indexterm>
13967 <indexterm role="concept">
13968 <primary>expansion</primary>
13969 <secondary>case forcing</secondary>
13970 </indexterm>
13971 <indexterm role="concept">
13972 <primary><option>uc</option> expansion item</primary>
13973 </indexterm>
13974 This forces the letters in the string into upper-case.
13975 </para>
13976 </listitem></varlistentry>
13977 </variablelist>
13978 </section>
13979 <section id="SECTexpcond">
13980 <title>Expansion conditions</title>
13981 <para>
13982 <indexterm role="concept">
13983 <primary>expansion</primary>
13984 <secondary>conditions</secondary>
13985 </indexterm>
13986 The following conditions are available for testing by the <option>${if</option> construct
13987 while expanding strings:
13988 </para>
13989 <variablelist>
13990 <varlistentry>
13991 <term><emphasis role="bold">!</emphasis>&lt;<emphasis>condition</emphasis>&gt;</term>
13992 <listitem>
13993 <para>
13994 <indexterm role="concept">
13995 <primary>expansion</primary>
13996 <secondary>negating a condition</secondary>
13997 </indexterm>
13998 <indexterm role="concept">
13999 <primary>negation</primary>
14000 <secondary>in expansion condition</secondary>
14001 </indexterm>
14002 Preceding any condition with an exclamation mark negates the result of the
14003 condition.
14004 </para>
14005 </listitem></varlistentry>
14006 <varlistentry>
14007 <term>&lt;<emphasis>symbolic&nbsp;operator</emphasis>&gt;&nbsp;<emphasis role="bold">{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14008 <listitem>
14009 <para>
14010 <indexterm role="concept">
14011 <primary>numeric comparison</primary>
14012 </indexterm>
14013 <indexterm role="concept">
14014 <primary>expansion</primary>
14015 <secondary>numeric comparison</secondary>
14016 </indexterm>
14017 There are a number of symbolic operators for doing numeric comparisons. They
14018 are:
14019 </para>
14020 <literallayout>
14021 <literal>=   </literal>   equal
14022 <literal>==  </literal>   equal
14023 <literal>&gt;   </literal>   greater
14024 <literal>&gt;=  </literal>   greater or equal
14025 <literal>&lt;   </literal>   less
14026 <literal>&lt;=  </literal>   less or equal
14027 </literallayout>
14028 <para>
14029 For example:
14030 </para>
14031 <literallayout class="monospaced">
14032 ${if &gt;{$message_size}{10M} ...
14033 </literallayout>
14034 <para>
14035 Note that the general negation operator provides for inequality testing. The
14036 two strings must take the form of optionally signed decimal integers,
14037 optionally followed by one of the letters <quote>K</quote> or <quote>M</quote> (in either upper or
14038 lower case), signifying multiplication by 1024 or 1024*1024, respectively.
14039 </para>
14040 </listitem></varlistentry>
14041 <varlistentry>
14042 <term><emphasis role="bold">crypteq&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14043 <listitem>
14044 <para>
14045 <indexterm role="concept">
14046 <primary>expansion</primary>
14047 <secondary>encrypted comparison</secondary>
14048 </indexterm>
14049 <indexterm role="concept">
14050 <primary>encrypted strings</primary>
14051 <secondary>comparing</secondary>
14052 </indexterm>
14053 <indexterm role="concept">
14054 <primary><option>crypteq</option> expansion condition</primary>
14055 </indexterm>
14056 This condition is included in the Exim binary if it is built to support any
14057 authentication mechanisms (see chapter <xref linkend="CHAPSMTPAUTH"/>). Otherwise, it is
14058 necessary to define SUPPORT_CRYPTEQ in <filename>Local/Makefile</filename> to get <option>crypteq</option>
14059 included in the binary.
14060 </para>
14061 <para>
14062 The <option>crypteq</option> condition has two arguments. The first is encrypted and
14063 compared against the second, which is already encrypted. The second string may
14064 be in the LDAP form for storing encrypted strings, which starts with the
14065 encryption type in curly brackets, followed by the data. If the second string
14066 does not begin with <quote>{</quote> it is assumed to be encrypted with <function>crypt()</function> or
14067 <function>crypt16()</function> (see below), since such strings cannot begin with <quote>{</quote>.
14068 Typically this will be a field from a password file. An example of an encrypted
14069 string in LDAP form is:
14070 </para>
14071 <literallayout class="monospaced">
14072 {md5}CY9rzUYh03PK3k6DJie09g==
14073 </literallayout>
14074 <para>
14075 If such a string appears directly in an expansion, the curly brackets have to
14076 be quoted, because they are part of the expansion syntax. For example:
14077 </para>
14078 <literallayout class="monospaced">
14079 ${if crypteq {test}{\{md5\}CY9rzUYh03PK3k6DJie09g==}{yes}{no}}
14080 </literallayout>
14081 <para>
14082 The following encryption types (whose names are matched case-independently) are
14083 supported:
14084 </para>
14085 <itemizedlist>
14086 <listitem>
14087 <para>
14088 <indexterm role="concept">
14089 <primary>MD5 hash</primary>
14090 </indexterm>
14091 <indexterm role="concept">
14092 <primary>base64 encoding</primary>
14093 <secondary>in encrypted password</secondary>
14094 </indexterm>
14095 <option>{md5}</option> computes the MD5 digest of the first string, and expresses this as
14096 printable characters to compare with the remainder of the second string. If the
14097 length of the comparison string is 24, Exim assumes that it is base64 encoded
14098 (as in the above example). If the length is 32, Exim assumes that it is a
14099 hexadecimal encoding of the MD5 digest. If the length not 24 or 32, the
14100 comparison fails.
14101 </para>
14102 </listitem>
14103 <listitem>
14104 <para>
14105 <indexterm role="concept">
14106 <primary>SHA-1 hash</primary>
14107 </indexterm>
14108 <option>{sha1}</option> computes the SHA-1 digest of the first string, and expresses this as
14109 printable characters to compare with the remainder of the second string. If the
14110 length of the comparison string is 28, Exim assumes that it is base64 encoded.
14111 If the length is 40, Exim assumes that it is a hexadecimal encoding of the
14112 SHA-1 digest. If the length is not 28 or 40, the comparison fails.
14113 </para>
14114 </listitem>
14115 <listitem>
14116 <para>
14117 <indexterm role="concept">
14118 <primary><function>crypt()</function></primary>
14119 </indexterm>
14120 <option>{crypt}</option> calls the <function>crypt()</function> function, which traditionally used to use
14121 only the first eight characters of the password. However, in modern operating
14122 systems this is no longer true, and in many cases the entire password is used,
14123 whatever its length.
14124 </para>
14125 </listitem>
14126 <listitem>
14127 <para>
14128 <indexterm role="concept">
14129 <primary><function>crypt16()</function></primary>
14130 </indexterm>
14131 <option>{crypt16}</option> calls the <function>crypt16()</function> function (also known as <function>bigcrypt()</function>),
14132 which was orginally created to use up to 16 characters of the password. Again,
14133 in modern operating systems, more characters may be used.
14134 </para>
14135 </listitem>
14136 </itemizedlist>
14137 <para>
14138 Exim has its own version of <function>crypt16()</function> (which is just a double call to
14139 <function>crypt()</function>). For operating systems that have their own version, setting
14140 HAVE_CRYPT16 in <filename>Local/Makefile</filename> when building Exim causes it to use the
14141 operating system version instead of its own. This option is set by default in
14142 the OS-dependent <filename>Makefile</filename> for those operating systems that are known to
14143 support <function>crypt16()</function>.
14144 </para>
14145 <para>
14146 If you do not put any curly bracket encryption type in a <option>crypteq</option>
14147 comparison, the default is either <literal>{crypt}</literal> or <literal>{crypt16}</literal>, as determined
14148 by the setting of DEFAULT_CRYPT in <filename>Local/Makefile</filename>. The default default is
14149 <literal>{crypt}</literal>. Whatever the default, you can always use either function by
14150 specifying it explicitly in curly brackets.
14151 </para>
14152 <para>
14153 Note that if a password is no longer than 8 characters, the results of
14154 encrypting it with <function>crypt()</function> and <function>crypt16()</function> are identical. That means that
14155 <function>crypt16()</function> is backwards compatible, as long as nobody feeds it a password
14156 longer than 8 characters.
14157 </para>
14158 </listitem></varlistentry>
14159 <varlistentry>
14160 <term><emphasis role="bold">def:</emphasis>&lt;<emphasis>variable&nbsp;name</emphasis>&gt;</term>
14161 <listitem>
14162 <para>
14163 <indexterm role="concept">
14164 <primary>expansion</primary>
14165 <secondary>checking for empty variable</secondary>
14166 </indexterm>
14167 <indexterm role="concept">
14168 <primary><option>def</option> expansion condition</primary>
14169 </indexterm>
14170 The <option>def</option> condition must be followed by the name of one of the expansion
14171 variables defined in section <xref linkend="SECTexpvar"/>. The condition is true if the
14172 variable does not contain the empty string. For example:
14173 </para>
14174 <literallayout class="monospaced">
14175 ${if def:sender_ident {from $sender_ident}}
14176 </literallayout>
14177 <para>
14178 Note that the variable name is given without a leading <option>$</option> character. If the
14179 variable does not exist, the expansion fails.
14180 </para>
14181 </listitem></varlistentry>
14182 <varlistentry>
14183 <term><emphasis role="bold">def:header_</emphasis>&lt;<emphasis>header&nbsp;name</emphasis>&gt;<emphasis role="bold">:</emphasis>&nbsp;&nbsp;or&nbsp;&nbsp;<emphasis role="bold">def:h_</emphasis>&lt;<emphasis>header&nbsp;name</emphasis>&gt;<emphasis role="bold">:</emphasis></term>
14184 <listitem>
14185 <para>
14186 <indexterm role="concept">
14187 <primary>expansion</primary>
14188 <secondary>checking header line existence</secondary>
14189 </indexterm>
14190 This condition is true if a message is being processed and the named header
14191 exists in the message. For example,
14192 </para>
14193 <literallayout class="monospaced">
14194 ${if def:header_reply-to:{$h_reply-to:}{$h_from:}}
14195 </literallayout>
14196 <para>
14197 <emphasis role="bold">Note</emphasis>: No <option>$</option> appears before <option>header_</option> or <option>h_</option> in the condition, and
14198 the header name must be terminated by a colon if white space does not follow.
14199 </para>
14200 </listitem></varlistentry>
14201 <varlistentry>
14202 <term><emphasis role="bold">eq&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14203 <listitem>
14204 <para>
14205 <indexterm role="concept">
14206 <primary>string</primary>
14207 <secondary>comparison</secondary>
14208 </indexterm>
14209 <indexterm role="concept">
14210 <primary>expansion</primary>
14211 <secondary>string comparison</secondary>
14212 </indexterm>
14213 <indexterm role="concept">
14214 <primary><option>eq</option> expansion condition</primary>
14215 </indexterm>
14216 The two substrings are first expanded. The condition is true if the two
14217 resulting strings are identical, including the case of letters.
14218 </para>
14219 </listitem></varlistentry>
14220 <varlistentry>
14221 <term><emphasis role="bold">eqi&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14222 <listitem>
14223 <para>
14224 <indexterm role="concept">
14225 <primary>string</primary>
14226 <secondary>comparison</secondary>
14227 </indexterm>
14228 <indexterm role="concept">
14229 <primary>expansion</primary>
14230 <secondary>string comparison</secondary>
14231 </indexterm>
14232 <indexterm role="concept">
14233 <primary><option>eqi</option> expansion condition</primary>
14234 </indexterm>
14235 The two substrings are first expanded. The condition is true if the two
14236 resulting strings are identical when compared in a case-independent way.
14237 </para>
14238 </listitem></varlistentry>
14239 <varlistentry>
14240 <term><emphasis role="bold">exists&nbsp;{</emphasis>&lt;<emphasis>file&nbsp;name</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14241 <listitem>
14242 <para>
14243 <indexterm role="concept">
14244 <primary>expansion</primary>
14245 <secondary>file existence test</secondary>
14246 </indexterm>
14247 <indexterm role="concept">
14248 <primary>file</primary>
14249 <secondary>existence test</secondary>
14250 </indexterm>
14251 <indexterm role="concept">
14252 <primary><option>exists</option>, expansion condition</primary>
14253 </indexterm>
14254 The substring is first expanded and then interpreted as an absolute path. The
14255 condition is true if the named file (or directory) exists. The existence test
14256 is done by calling the <function>stat()</function> function. The use of the <option>exists</option> test in
14257 users&#x2019; filter files may be locked out by the system administrator.
14258 </para>
14259 </listitem></varlistentry>
14260 <varlistentry>
14261 <term><emphasis role="bold">first_delivery</emphasis></term>
14262 <listitem>
14263 <para>
14264 <indexterm role="concept">
14265 <primary>delivery</primary>
14266 <secondary>first</secondary>
14267 </indexterm>
14268 <indexterm role="concept">
14269 <primary>first delivery</primary>
14270 </indexterm>
14271 <indexterm role="concept">
14272 <primary>expansion</primary>
14273 <secondary>first delivery test</secondary>
14274 </indexterm>
14275 <indexterm role="concept">
14276 <primary><option>first_delivery</option> expansion condition</primary>
14277 </indexterm>
14278 This condition, which has no data, is true during a message&#x2019;s first delivery
14279 attempt. It is false during any subsequent delivery attempts.
14280 </para>
14281 </listitem></varlistentry>
14282 <varlistentry>
14283 <term><emphasis role="bold">ge&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14284 <listitem>
14285 <para>
14286 <indexterm role="concept">
14287 <primary><option>ge</option> expansion condition</primary>
14288 </indexterm>
14289 See <emphasis role="bold">gei</emphasis>.
14290 </para>
14291 </listitem></varlistentry>
14292 <varlistentry>
14293 <term><emphasis role="bold">gei&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14294 <listitem>
14295 <para>
14296 <indexterm role="concept">
14297 <primary>string</primary>
14298 <secondary>comparison</secondary>
14299 </indexterm>
14300 <indexterm role="concept">
14301 <primary>expansion</primary>
14302 <secondary>string comparison</secondary>
14303 </indexterm>
14304 <indexterm role="concept">
14305 <primary><option>gei</option> expansion condition</primary>
14306 </indexterm>
14307 The two substrings are first expanded. The condition is true if the first
14308 string is lexically greater than or equal to the second string: for <option>ge</option> the
14309 comparison includes the case of letters, whereas for <option>gei</option> the comparison is
14310 case-independent.
14311 </para>
14312 </listitem></varlistentry>
14313 <varlistentry>
14314 <term><emphasis role="bold">gt&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14315 <listitem>
14316 <para>
14317 <indexterm role="concept">
14318 <primary><option>gt</option> expansion condition</primary>
14319 </indexterm>
14320 See <emphasis role="bold">gti</emphasis>.
14321 </para>
14322 </listitem></varlistentry>
14323 <varlistentry>
14324 <term><emphasis role="bold">gti&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14325 <listitem>
14326 <para>
14327 <indexterm role="concept">
14328 <primary>string</primary>
14329 <secondary>comparison</secondary>
14330 </indexterm>
14331 <indexterm role="concept">
14332 <primary>expansion</primary>
14333 <secondary>string comparison</secondary>
14334 </indexterm>
14335 <indexterm role="concept">
14336 <primary><option>gti</option> expansion condition</primary>
14337 </indexterm>
14338 The two substrings are first expanded. The condition is true if the first
14339 string is lexically greater than the second string: for <option>gt</option> the comparison
14340 includes the case of letters, whereas for <option>gti</option> the comparison is
14341 case-independent.
14342 </para>
14343 </listitem></varlistentry>
14344 <varlistentry>
14345 <term><emphasis role="bold">isip&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14346 <listitem>
14347 <para>
14348 <indexterm role="concept">
14349 <primary><option>isip</option> expansion condition</primary>
14350 </indexterm>
14351 See <emphasis role="bold">isip6</emphasis>.
14352 </para>
14353 </listitem></varlistentry>
14354 <varlistentry>
14355 <term><emphasis role="bold">isip4&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14356 <listitem>
14357 <para>
14358 <indexterm role="concept">
14359 <primary><option>isip4</option> expansion condition</primary>
14360 </indexterm>
14361 See <emphasis role="bold">isip6</emphasis>.
14362 </para>
14363 </listitem></varlistentry>
14364 <varlistentry>
14365 <term><emphasis role="bold">isip6&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14366 <listitem>
14367 <para>
14368 <indexterm role="concept">
14369 <primary>IP address</primary>
14370 <secondary>testing string format</secondary>
14371 </indexterm>
14372 <indexterm role="concept">
14373 <primary>string</primary>
14374 <secondary>testing for IP address</secondary>
14375 </indexterm>
14376 <indexterm role="concept">
14377 <primary><option>isip6</option> expansion condition</primary>
14378 </indexterm>
14379 The substring is first expanded, and then tested to see if it has the form of
14380 an IP address. Both IPv4 and IPv6 addresses are valid for <option>isip</option>, whereas
14381 <option>isip4</option> and <option>isip6</option> test just for IPv4 or IPv6 addresses, respectively. For
14382 example, you could use
14383 </para>
14384 <literallayout class="monospaced">
14385 ${if isip4{$sender_host_address}...
14386 </literallayout>
14387 <para>
14388 to test which version of IP an incoming SMTP connection is using.
14389 </para>
14390 </listitem></varlistentry>
14391 <varlistentry>
14392 <term><emphasis role="bold">ldapauth&nbsp;{</emphasis>&lt;<emphasis>ldap&nbsp;query</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14393 <listitem>
14394 <para>
14395 <indexterm role="concept">
14396 <primary>LDAP</primary>
14397 <secondary>use for authentication</secondary>
14398 </indexterm>
14399 <indexterm role="concept">
14400 <primary>expansion</primary>
14401 <secondary>LDAP authentication test</secondary>
14402 </indexterm>
14403 <indexterm role="concept">
14404 <primary><option>ldapauth</option> expansion condition</primary>
14405 </indexterm>
14406 This condition supports user authentication using LDAP. See section
14407 <xref linkend="SECTldap"/> for details of how to use LDAP in lookups and the syntax of
14408 queries. For this use, the query must contain a user name and password. The
14409 query itself is not used, and can be empty. The condition is true if the
14410 password is not empty, and the user name and password are accepted by the LDAP
14411 server. An empty password is rejected without calling LDAP because LDAP binds
14412 with an empty password are considered anonymous regardless of the username, and
14413 will succeed in most configurations. See chapter <xref linkend="CHAPSMTPAUTH"/> for details
14414 of SMTP authentication, and chapter <xref linkend="CHAPplaintext"/> for an example of how
14415 this can be used.
14416 </para>
14417 </listitem></varlistentry>
14418 <varlistentry>
14419 <term><emphasis role="bold">le&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14420 <listitem>
14421 <para>
14422 <indexterm role="concept">
14423 <primary><option>le</option> expansion condition</primary>
14424 </indexterm>
14425 See <emphasis role="bold">lei</emphasis>.
14426 </para>
14427 </listitem></varlistentry>
14428 <varlistentry>
14429 <term><emphasis role="bold">lei&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14430 <listitem>
14431 <para>
14432 <indexterm role="concept">
14433 <primary>string</primary>
14434 <secondary>comparison</secondary>
14435 </indexterm>
14436 <indexterm role="concept">
14437 <primary>expansion</primary>
14438 <secondary>string comparison</secondary>
14439 </indexterm>
14440 <indexterm role="concept">
14441 <primary><option>lei</option> expansion condition</primary>
14442 </indexterm>
14443 The two substrings are first expanded. The condition is true if the first
14444 string is lexically less than or equal to the second string: for <option>le</option> the
14445 comparison includes the case of letters, whereas for <option>lei</option> the comparison is
14446 case-independent.
14447 </para>
14448 </listitem></varlistentry>
14449 <varlistentry>
14450 <term><emphasis role="bold">lt&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14451 <listitem>
14452 <para>
14453 <indexterm role="concept">
14454 <primary><option>lt</option> expansion condition</primary>
14455 </indexterm>
14456 See <emphasis role="bold">lti</emphasis>.
14457 </para>
14458 </listitem></varlistentry>
14459 <varlistentry>
14460 <term><emphasis role="bold">lti&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14461 <listitem>
14462 <para>
14463 <indexterm role="concept">
14464 <primary>string</primary>
14465 <secondary>comparison</secondary>
14466 </indexterm>
14467 <indexterm role="concept">
14468 <primary>expansion</primary>
14469 <secondary>string comparison</secondary>
14470 </indexterm>
14471 <indexterm role="concept">
14472 <primary><option>lti</option> expansion condition</primary>
14473 </indexterm>
14474 The two substrings are first expanded. The condition is true if the first
14475 string is lexically less than the second string: for <option>lt</option> the comparison
14476 includes the case of letters, whereas for <option>lti</option> the comparison is
14477 case-independent.
14478 </para>
14479 </listitem></varlistentry>
14480 <varlistentry>
14481 <term><emphasis role="bold">match&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14482 <listitem>
14483 <para>
14484 <indexterm role="concept">
14485 <primary>expansion</primary>
14486 <secondary>regular expression comparison</secondary>
14487 </indexterm>
14488 <indexterm role="concept">
14489 <primary>regular expressions</primary>
14490 <secondary>match in expanded string</secondary>
14491 </indexterm>
14492 <indexterm role="concept">
14493 <primary><option>match</option>, expansion condition</primary>
14494 </indexterm>
14495 The two substrings are first expanded. The second is then treated as a regular
14496 expression and applied to the first. Because of the pre-expansion, if the
14497 regular expression contains dollar, or backslash characters, they must be
14498 escaped. Care must also be taken if the regular expression contains braces
14499 (curly brackets). A closing brace must be escaped so that it is not taken as a
14500 premature termination of &lt;<emphasis>string2</emphasis>&gt;. The easiest approach is to use the
14501 <literal>\N</literal> feature to disable expansion of the regular expression.
14502 For example,
14503 </para>
14504 <literallayout class="monospaced">
14505 ${if match {$local_part}{\N^\d{3}\N} ...
14506 </literallayout>
14507 <para>
14508 If the whole expansion string is in double quotes, further escaping of
14509 backslashes is also required.
14510 </para>
14511 <para>
14512 The condition is true if the regular expression match succeeds.
14513 The regular expression is not required to begin with a circumflex
14514 metacharacter, but if there is no circumflex, the expression is not anchored,
14515 and it may match anywhere in the subject, not just at the start. If you want
14516 the pattern to match at the end of the subject, you must include the <literal>$</literal>
14517 metacharacter at an appropriate point.
14518 </para>
14519 <para>
14520 <indexterm role="concept">
14521 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
14522 <secondary>in <option>if</option> expansion</secondary>
14523 </indexterm>
14524 At the start of an <option>if</option> expansion the values of the numeric variable
14525 substitutions <varname>$1</varname> etc. are remembered. Obeying a <option>match</option> condition that
14526 succeeds causes them to be reset to the substrings of that condition and they
14527 will have these values during the expansion of the success string. At the end
14528 of the <option>if</option> expansion, the previous values are restored. After testing a
14529 combination of conditions using <option>or</option>, the subsequent values of the numeric
14530 variables are those of the condition that succeeded.
14531 </para>
14532 </listitem></varlistentry>
14533 <varlistentry>
14534 <term><emphasis role="bold">match_address&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14535 <listitem>
14536 <para>
14537 <indexterm role="concept">
14538 <primary><option>match_address</option> expansion condition</primary>
14539 </indexterm>
14540 See <emphasis role="bold">match_local_part</emphasis>.
14541 </para>
14542 </listitem></varlistentry>
14543 <varlistentry>
14544 <term><emphasis role="bold">match_domain&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14545 <listitem>
14546 <para>
14547 <indexterm role="concept">
14548 <primary><option>match_domain</option> expansion condition</primary>
14549 </indexterm>
14550 See <emphasis role="bold">match_local_part</emphasis>.
14551 </para>
14552 </listitem></varlistentry>
14553 <varlistentry>
14554 <term><emphasis role="bold">match_ip&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14555 <listitem>
14556 <para>
14557 <indexterm role="concept">
14558 <primary><option>match_ip</option> expansion condition</primary>
14559 </indexterm>
14560 This condition matches an IP address to a list of IP address patterns. It must
14561 be followed by two argument strings. The first (after expansion) must be an IP
14562 address or an empty string. The second (after expansion) is a restricted host
14563 list that can match only an IP address, not a host name. For example:
14564 </para>
14565 <literallayout class="monospaced">
14566 ${if match_ip{$sender_host_address}{1.2.3.4:5.6.7.8}{...}{...}}
14567 </literallayout>
14568 <para>
14569 The specific types of host list item that are permitted in the list are:
14570 </para>
14571 <itemizedlist>
14572 <listitem>
14573 <para>
14574 An IP address, optionally with a CIDR mask.
14575 </para>
14576 </listitem>
14577 <listitem>
14578 <para>
14579 A single asterisk, which matches any IP address.
14580 </para>
14581 </listitem>
14582 <listitem>
14583 <para>
14584 An empty item, which matches only if the IP address is empty. This could be
14585 useful for testing for a locally submitted message or one from specific hosts
14586 in a single test such as
14587 </para>
14588 <literallayout class="monospaced">
14589   ${if match_ip{$sender_host_address}{:4.3.2.1:...}{...}{...}}
14590 </literallayout>
14591 <para>
14592 where the first item in the list is the empty string.
14593 </para>
14594 </listitem>
14595 <listitem>
14596 <para>
14597 The item @[] matches any of the local host&#x2019;s interface addresses.
14598 </para>
14599 </listitem>
14600 <listitem>
14601 <para>
14602 Lookups are assumed to be <quote>net-</quote> style lookups, even if <literal>net-</literal> is not
14603 specified. Thus, the following are equivalent:
14604 </para>
14605 <literallayout class="monospaced">
14606   ${if match_ip{$sender_host_address}{lsearch;/some/file}...
14607   ${if match_ip{$sender_host_address}{net-lsearch;/some/file}...
14608 </literallayout>
14609 <para>
14610 You do need to specify the <literal>net-</literal> prefix if you want to specify a
14611 specific address mask, for example, by using <literal>net24-</literal>.
14612 </para>
14613 </listitem>
14614 </itemizedlist>
14615 <para>
14616 Consult section <xref linkend="SECThoslispatip"/> for further details of these patterns.
14617 </para>
14618 </listitem></varlistentry>
14619 <varlistentry>
14620 <term><emphasis role="bold">match_local_part&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14621 <listitem>
14622 <para>
14623 <indexterm role="concept">
14624 <primary>domain list</primary>
14625 <secondary>in expansion condition</secondary>
14626 </indexterm>
14627 <indexterm role="concept">
14628 <primary>address list</primary>
14629 <secondary>in expansion condition</secondary>
14630 </indexterm>
14631 <indexterm role="concept">
14632 <primary>local part list</primary>
14633 <secondary>in expansion condition</secondary>
14634 </indexterm>
14635 <indexterm role="concept">
14636 <primary><option>match_local_part</option> expansion condition</primary>
14637 </indexterm>
14638 This condition, together with <option>match_address</option> and <option>match_domain</option>, make it
14639 possible to test domain, address, and local part lists within expansions. Each
14640 condition requires two arguments: an item and a list to match. A trivial
14641 example is:
14642 </para>
14643 <literallayout class="monospaced">
14644 ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
14645 </literallayout>
14646 <para>
14647 In each case, the second argument may contain any of the allowable items for a
14648 list of the appropriate type. Also, because the second argument (after
14649 expansion) is a standard form of list, it is possible to refer to a named list.
14650 Thus, you can use conditions like this:
14651 </para>
14652 <literallayout class="monospaced">
14653 ${if match_domain{$domain}{+local_domains}{...
14654 </literallayout>
14655 <para>
14656 <indexterm role="concept">
14657 <primary><literal>+caseful</literal></primary>
14658 </indexterm>
14659 For address lists, the matching starts off caselessly, but the <literal>+caseful</literal>
14660 item can be used, as in all address lists, to cause subsequent items to
14661 have their local parts matched casefully. Domains are always matched
14662 caselessly.
14663 </para>
14664 <para>
14665 <emphasis role="bold">Note</emphasis>: Host lists are <emphasis>not</emphasis> supported in this way. This is because
14666 hosts have two identities: a name and an IP address, and it is not clear
14667 how to specify cleanly how such a test would work. However, IP addresses can be
14668 matched using <option>match_ip</option>.
14669 </para>
14670 </listitem></varlistentry>
14671 <varlistentry>
14672 <term><emphasis role="bold">pam&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">:</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">:...}</emphasis></term>
14673 <listitem>
14674 <para>
14675 <indexterm role="concept">
14676 <primary>PAM authentication</primary>
14677 </indexterm>
14678 <indexterm role="concept">
14679 <primary>AUTH</primary>
14680 <secondary>with PAM</secondary>
14681 </indexterm>
14682 <indexterm role="concept">
14683 <primary>Solaris</primary>
14684 <secondary>PAM support</secondary>
14685 </indexterm>
14686 <indexterm role="concept">
14687 <primary>expansion</primary>
14688 <secondary>PAM authentication test</secondary>
14689 </indexterm>
14690 <indexterm role="concept">
14691 <primary><option>pam</option> expansion condition</primary>
14692 </indexterm>
14693 <emphasis>Pluggable Authentication Modules</emphasis>
14694 (<emphasis role="bold"><ulink url="http://www.kernel.org/pub/linux/libs/pam/">http://www.kernel.org/pub/linux/libs/pam/</ulink></emphasis>) are a facility that is
14695 available in the latest releases of Solaris and in some GNU/Linux
14696 distributions. The Exim support, which is intended for use in conjunction with
14697 the SMTP AUTH command, is available only if Exim is compiled with
14698 </para>
14699 <literallayout class="monospaced">
14700 SUPPORT_PAM=yes
14701 </literallayout>
14702 <para>
14703 in <filename>Local/Makefile</filename>. You probably need to add <option>-lpam</option> to EXTRALIBS, and
14704 in some releases of GNU/Linux <option>-ldl</option> is also needed.
14705 </para>
14706 <para>
14707 The argument string is first expanded, and the result must be a
14708 colon-separated list of strings. Leading and trailing white space is ignored.
14709 The PAM module is initialized with the service name <quote>exim</quote> and the user name
14710 taken from the first item in the colon-separated data string (&lt;<emphasis>string1</emphasis>&gt;).
14711 The remaining items in the data string are passed over in response to requests
14712 from the authentication function. In the simple case there will only be one
14713 request, for a password, so the data consists of just two strings.
14714 </para>
14715 <para>
14716 There can be problems if any of the strings are permitted to contain colon
14717 characters. In the usual way, these have to be doubled to avoid being taken as
14718 separators. If the data is being inserted from a variable, the <option>sg</option> expansion
14719 item can be used to double any existing colons. For example, the configuration
14720 of a LOGIN authenticator might contain this setting:
14721 </para>
14722 <literallayout class="monospaced">
14723 server_condition = ${if pam{$1:${sg{$2}{:}{::}}}{yes}{no}}
14724 </literallayout>
14725 <para>
14726 For a PLAIN authenticator you could use:
14727 </para>
14728 <literallayout class="monospaced">
14729 server_condition = ${if pam{$2:${sg{$3}{:}{::}}}{yes}{no}}
14730 </literallayout>
14731 <para>
14732 In some operating systems, PAM authentication can be done only from a process
14733 running as root. Since Exim is running as the Exim user when receiving
14734 messages, this means that PAM cannot be used directly in those systems.
14735 A patched version of the <emphasis>pam_unix</emphasis> module that comes with the
14736 Linux PAM package is available from <emphasis role="bold"><ulink url="http://www.e-admin.de/pam_exim/">http://www.e-admin.de/pam_exim/</ulink></emphasis>.
14737 The patched module allows one special uid/gid combination, in addition to root,
14738 to authenticate. If you build the patched module to allow the Exim user and
14739 group, PAM can then be used from an Exim authenticator.
14740 </para>
14741 </listitem></varlistentry>
14742 <varlistentry>
14743 <term><emphasis role="bold">pwcheck&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">:</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14744 <listitem>
14745 <para>
14746 <indexterm role="concept">
14747 <primary><emphasis>pwcheck</emphasis> daemon</primary>
14748 </indexterm>
14749 <indexterm role="concept">
14750 <primary>Cyrus</primary>
14751 </indexterm>
14752 <indexterm role="concept">
14753 <primary>expansion</primary>
14754 <secondary><emphasis>pwcheck</emphasis> authentication test</secondary>
14755 </indexterm>
14756 <indexterm role="concept">
14757 <primary><option>pwcheck</option> expansion condition</primary>
14758 </indexterm>
14759 This condition supports user authentication using the Cyrus <emphasis>pwcheck</emphasis> daemon.
14760 This is one way of making it possible for passwords to be checked by a process
14761 that is not running as root. <emphasis role="bold">Note</emphasis>: The use of <emphasis>pwcheck</emphasis> is now
14762 deprecated. Its replacement is <emphasis>saslauthd</emphasis> (see below).
14763 </para>
14764 <para>
14765 The pwcheck support is not included in Exim by default. You need to specify
14766 the location of the pwcheck daemon&#x2019;s socket in <filename>Local/Makefile</filename> before
14767 building Exim. For example:
14768 </para>
14769 <literallayout class="monospaced">
14770 CYRUS_PWCHECK_SOCKET=/var/pwcheck/pwcheck
14771 </literallayout>
14772 <para>
14773 You do not need to install the full Cyrus software suite in order to use
14774 the pwcheck daemon. You can compile and install just the daemon alone
14775 from the Cyrus SASL library. Ensure that <emphasis>exim</emphasis> is the only user that has
14776 access to the <filename>/var/pwcheck</filename> directory.
14777 </para>
14778 <para>
14779 The <option>pwcheck</option> condition takes one argument, which must be the user name and
14780 password, separated by a colon. For example, in a LOGIN authenticator
14781 configuration, you might have this:
14782 </para>
14783 <literallayout class="monospaced">
14784 server_condition = ${if pwcheck{$1:$2}{1}{0}}
14785 </literallayout>
14786 </listitem></varlistentry>
14787 <varlistentry>
14788 <term><emphasis role="bold">queue_running</emphasis></term>
14789 <listitem>
14790 <para>
14791 <indexterm role="concept">
14792 <primary>queue runner</primary>
14793 <secondary>detecting when delivering from</secondary>
14794 </indexterm>
14795 <indexterm role="concept">
14796 <primary>expansion</primary>
14797 <secondary>queue runner test</secondary>
14798 </indexterm>
14799 <indexterm role="concept">
14800 <primary><option>queue_runnint</option> expansion condition</primary>
14801 </indexterm>
14802 This condition, which has no data, is true during delivery attempts that are
14803 initiated by queue runner processes, and false otherwise.
14804 </para>
14805 </listitem></varlistentry>
14806 <varlistentry>
14807 <term><emphasis role="bold">radius&nbsp;{</emphasis>&lt;<emphasis>authentication&nbsp;string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14808 <listitem>
14809 <para>
14810 <indexterm role="concept">
14811 <primary>Radius</primary>
14812 </indexterm>
14813 <indexterm role="concept">
14814 <primary>expansion</primary>
14815 <secondary>Radius authentication</secondary>
14816 </indexterm>
14817 <indexterm role="concept">
14818 <primary><option>radiu</option> expansion condition</primary>
14819 </indexterm>
14820 Radius authentication (RFC 2865) is supported in a similar way to PAM. You must
14821 set RADIUS_CONFIG_FILE in <filename>Local/Makefile</filename> to specify the location of
14822 the Radius client configuration file in order to build Exim with Radius
14823 support.
14824 </para>
14825 <para>
14826 With just that one setting, Exim expects to be linked with the <option>radiusclient</option>
14827 library, using the original API. If you are using release 0.4.0 or later of
14828 this library, you need to set
14829 </para>
14830 <literallayout class="monospaced">
14831 RADIUS_LIB_TYPE=RADIUSCLIENTNEW
14832 </literallayout>
14833 <para>
14834 in <filename>Local/Makefile</filename> when building Exim. You can also link Exim with the
14835 <option>libradius</option> library that comes with FreeBSD. To do this, set
14836 </para>
14837 <literallayout class="monospaced">
14838 RADIUS_LIB_TYPE=RADLIB
14839 </literallayout>
14840 <para>
14841 in <filename>Local/Makefile</filename>, in addition to setting RADIUS_CONFIGURE_FILE.
14842 You may also have to supply a suitable setting in EXTRALIBS so that the
14843 Radius library can be found when Exim is linked.
14844 </para>
14845 <para>
14846 The string specified by RADIUS_CONFIG_FILE is expanded and passed to the
14847 Radius client library, which calls the Radius server. The condition is true if
14848 the authentication is successful. For example:
14849 </para>
14850 <literallayout class="monospaced">
14851 server_condition = ${if radius{&lt;arguments&gt;}{yes}{no}}
14852 </literallayout>
14853 </listitem></varlistentry>
14854 <varlistentry>
14855 <term><emphasis role="bold">saslauthd&nbsp;{{</emphasis>&lt;<emphasis>user</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>password</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>service</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>realm</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
14856 <listitem>
14857 <para>
14858 <indexterm role="concept">
14859 <primary><emphasis>saslauthd</emphasis> daemon</primary>
14860 </indexterm>
14861 <indexterm role="concept">
14862 <primary>Cyrus</primary>
14863 </indexterm>
14864 <indexterm role="concept">
14865 <primary>expansion</primary>
14866 <secondary><emphasis>saslauthd</emphasis> authentication test</secondary>
14867 </indexterm>
14868 <indexterm role="concept">
14869 <primary><option>saslauthd</option> expansion condition</primary>
14870 </indexterm>
14871 This condition supports user authentication using the Cyrus <emphasis>saslauthd</emphasis>
14872 daemon. This replaces the older <emphasis>pwcheck</emphasis> daemon, which is now deprecated.
14873 Using this daemon is one way of making it possible for passwords to be checked
14874 by a process that is not running as root.
14875 </para>
14876 <para>
14877 The saslauthd support is not included in Exim by default. You need to specify
14878 the location of the saslauthd daemon&#x2019;s socket in <filename>Local/Makefile</filename> before
14879 building Exim. For example:
14880 </para>
14881 <literallayout class="monospaced">
14882 CYRUS_SASLAUTHD_SOCKET=/var/state/saslauthd/mux
14883 </literallayout>
14884 <para>
14885 You do not need to install the full Cyrus software suite in order to use
14886 the saslauthd daemon. You can compile and install just the daemon alone
14887 from the Cyrus SASL library.
14888 </para>
14889 <para>
14890 Up to four arguments can be supplied to the <option>saslauthd</option> condition, but only
14891 two are mandatory. For example:
14892 </para>
14893 <literallayout class="monospaced">
14894 server_condition = ${if saslauthd{{$1}{$2}}{1}{0}}
14895 </literallayout>
14896 <para>
14897 The service and the realm are optional (which is why the arguments are enclosed
14898 in their own set of braces). For details of the meaning of the service and
14899 realm, and how to run the daemon, consult the Cyrus documentation.
14900 </para>
14901 </listitem></varlistentry>
14902 </variablelist>
14903 </section>
14904 <section>
14905 <title>Combining expansion conditions</title>
14906 <para>
14907 <indexterm role="concept">
14908 <primary>expansion</primary>
14909 <secondary>combining conditions</secondary>
14910 </indexterm>
14911 Several conditions can be tested at once by combining them using the <option>and</option>
14912 and <option>or</option> combination conditions. Note that <option>and</option> and <option>or</option> are complete
14913 conditions on their own, and precede their lists of sub-conditions. Each
14914 sub-condition must be enclosed in braces within the overall braces that contain
14915 the list. No repetition of <option>if</option> is used.
14916 </para>
14917 <variablelist>
14918 <varlistentry>
14919 <term><emphasis role="bold">or&nbsp;{{</emphasis>&lt;<emphasis>cond1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>cond2</emphasis>&gt;<emphasis role="bold">}...}</emphasis></term>
14920 <listitem>
14921 <para>
14922 <indexterm role="concept">
14923 <primary><quote>or</quote> expansion condition</primary>
14924 </indexterm>
14925 <indexterm role="concept">
14926 <primary>expansion</primary>
14927 <secondary><quote>or</quote> of conditions</secondary>
14928 </indexterm>
14929 The sub-conditions are evaluated from left to right. The condition is true if
14930 any one of the sub-conditions is true.
14931 For example,
14932 </para>
14933 <literallayout class="monospaced">
14934 ${if or {{eq{$local_part}{spqr}}{eq{$domain}{testing.com}}}...
14935 </literallayout>
14936 <para>
14937 When a true sub-condition is found, the following ones are parsed but not
14938 evaluated. If there are several <quote>match</quote> sub-conditions the values of the
14939 numeric variables afterwards are taken from the first one that succeeds.
14940 </para>
14941 </listitem></varlistentry>
14942 <varlistentry>
14943 <term><emphasis role="bold">and&nbsp;{{</emphasis>&lt;<emphasis>cond1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>cond2</emphasis>&gt;<emphasis role="bold">}...}</emphasis></term>
14944 <listitem>
14945 <para>
14946 <indexterm role="concept">
14947 <primary><quote>and</quote> expansion condition</primary>
14948 </indexterm>
14949 <indexterm role="concept">
14950 <primary>expansion</primary>
14951 <secondary><quote>and</quote> of conditions</secondary>
14952 </indexterm>
14953 The sub-conditions are evaluated from left to right. The condition is true if
14954 all of the sub-conditions are true. If there are several <quote>match</quote>
14955 sub-conditions, the values of the numeric variables afterwards are taken from
14956 the last one. When a false sub-condition is found, the following ones are
14957 parsed but not evaluated.
14958 </para>
14959 </listitem></varlistentry>
14960 </variablelist>
14961 </section>
14962 <section id="SECTexpvar">
14963 <title>Expansion variables</title>
14964 <para>
14965 <indexterm role="concept">
14966 <primary>expansion variables</primary>
14967 <secondary>list of</secondary>
14968 </indexterm>
14969 This section contains an alphabetical list of all the expansion variables. Some
14970 of them are available only when Exim is compiled with specific options such as
14971 support for TLS or the content scanning extension.
14972 </para>
14973 <variablelist>
14974 <varlistentry>
14975 <term><varname>$0</varname>, <varname>$1</varname>, etc</term>
14976 <listitem>
14977 <para>
14978 <indexterm role="concept">
14979 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
14980 </indexterm>
14981 When a <option>match</option> expansion condition succeeds, these variables contain the
14982 captured substrings identified by the regular expression during subsequent
14983 processing of the success string of the containing <option>if</option> expansion item. They
14984 may also be set externally by some other matching process which precedes the
14985 expansion of the string. For example, the commands available in Exim filter
14986 files include an <option>if</option> command with its own regular expression matching
14987 condition.
14988 </para>
14989 </listitem></varlistentry>
14990 <varlistentry>
14991 <term><varname>$acl_c0</varname> &ndash; <varname>$acl_c19</varname></term>
14992 <listitem>
14993 <para>
14994 Values can be placed in these variables by the <option>set</option> modifier in an ACL. The
14995 values persist throughout the lifetime of an SMTP connection. They can be used
14996 to pass information between ACLs and different invocations of the same ACL.
14997 When a message is received, the values of these variables are saved with the
14998 message, and can be accessed by filters, routers, and transports during
14999 subsequent delivery.
15000 </para>
15001 </listitem></varlistentry>
15002 <varlistentry>
15003 <term><varname>$acl_m0</varname> &ndash; <varname>$acl_m19</varname></term>
15004 <listitem>
15005 <para>
15006 Values can be placed in these variables by the <option>set</option> modifier in an ACL. They
15007 retain their values while a message is being received, but are reset
15008 afterwards. They are also reset by MAIL, RSET, EHLO, HELO, and after starting a
15009 TLS session. When a message is received, the values of these variables are
15010 saved with the message, and can be accessed by filters, routers, and transports
15011 during subsequent delivery.
15012 </para>
15013 </listitem></varlistentry>
15014 <varlistentry>
15015 <term><varname>$acl_verify_message</varname></term>
15016 <listitem>
15017 <para>
15018 <indexterm role="concept">
15019 <primary><varname>$acl_verify_message</varname></primary>
15020 </indexterm>
15021 After an address verification has failed, this variable contains the failure
15022 message. It retains its value for use in subsequent modifiers. The message can
15023 be preserved by coding like this:
15024 </para>
15025 <literallayout class="monospaced">
15026 warn !verify = sender
15027      set acl_m0 = $acl_verify_message
15028 </literallayout>
15029 <para>
15030 You can use <varname>$acl_verify_message</varname> during the expansion of the <option>message</option> or
15031 <option>log_message</option> modifiers, to include information about the verification
15032 failure.
15033 </para>
15034 </listitem></varlistentry>
15035 <varlistentry>
15036 <term><varname>$address_data</varname></term>
15037 <listitem>
15038 <para>
15039 <indexterm role="concept">
15040 <primary><varname>$address_data</varname></primary>
15041 </indexterm>
15042 This variable is set by means of the <option>address_data</option> option in routers. The
15043 value then remains with the address while it is processed by subsequent routers
15044 and eventually a transport. If the transport is handling multiple addresses,
15045 the value from the first address is used. See chapter <xref linkend="CHAProutergeneric"/>
15046 for more details. <emphasis role="bold">Note</emphasis>: The contents of <varname>$address_data</varname> are visible in
15047 user filter files.
15048 </para>
15049 <para>
15050 If <varname>$address_data</varname> is set when the routers are called from an ACL to verify
15051 a recipient address, the final value is still in the variable for subsequent
15052 conditions and modifiers of the ACL statement. If routing the address caused it
15053 to be redirected to just one address, the child address is also routed as part
15054 of the verification, and in this case the final value of <varname>$address_data</varname> is
15055 from the child&#x2019;s routing.
15056 </para>
15057 <para>
15058 If <varname>$address_data</varname> is set when the routers are called from an ACL to verify a
15059 sender address, the final value is also preserved, but this time in
15060 <varname>$sender_address_data</varname>, to distinguish it from data from a recipient
15061 address.
15062 </para>
15063 <para>
15064 In both cases (recipient and sender verification), the value does not persist
15065 after the end of the current ACL statement. If you want to preserve
15066 these values for longer, you can save them in ACL variables.
15067 </para>
15068 </listitem></varlistentry>
15069 <varlistentry>
15070 <term><varname>$address_file</varname></term>
15071 <listitem>
15072 <para>
15073 <indexterm role="concept">
15074 <primary><varname>$address_file</varname></primary>
15075 </indexterm>
15076 When, as a result of aliasing, forwarding, or filtering, a message is directed
15077 to a specific file, this variable holds the name of the file when the transport
15078 is running. At other times, the variable is empty. For example, using the
15079 default configuration, if user <option>r2d2</option> has a <filename>.forward</filename> file containing
15080 </para>
15081 <literallayout class="monospaced">
15082 /home/r2d2/savemail
15083 </literallayout>
15084 <para>
15085 then when the <command>address_file</command> transport is running, <varname>$address_file</varname>
15086 contains <quote>/home/r2d2/savemail</quote>.
15087 </para>
15088 <para>
15089 <indexterm role="concept">
15090 <primary>Sieve filter</primary>
15091 <secondary>value of <varname>$address_file</varname></secondary>
15092 </indexterm>
15093 For Sieve filters, the value may be <quote>inbox</quote> or a relative folder name. It is
15094 then up to the transport configuration to generate an appropriate absolute path
15095 to the relevant file.
15096 </para>
15097 </listitem></varlistentry>
15098 <varlistentry>
15099 <term><varname>$address_pipe</varname></term>
15100 <listitem>
15101 <para>
15102 <indexterm role="concept">
15103 <primary><varname>$address_pipe</varname></primary>
15104 </indexterm>
15105 When, as a result of aliasing or forwarding, a message is directed to a pipe,
15106 this variable holds the pipe command when the transport is running.
15107 </para>
15108 </listitem></varlistentry>
15109 <varlistentry revisionflag="changed">
15110 <term><varname>$auth1</varname> &ndash; <varname>$auth3</varname></term>
15111 <listitem>
15112 <para revisionflag="changed">
15113 <indexterm role="concept">
15114 <primary><varname>$auth1</varname>, <varname>$auth2</varname>, etc</primary>
15115 </indexterm>
15116 These variables are used in SMTP authenticators (see chapters
15117 <xref linkend="CHAPplaintext"/>&ndash;<xref linkend="CHAPspa"/>). Elsewhere, they are empty.
15118 </para>
15119 </listitem></varlistentry>
15120 <varlistentry>
15121 <term><varname>$authenticated_id</varname></term>
15122 <listitem>
15123 <para>
15124 <indexterm role="concept">
15125 <primary>authentication</primary>
15126 <secondary>id</secondary>
15127 </indexterm>
15128 <indexterm role="concept">
15129 <primary><varname>$authenticated_id</varname></primary>
15130 </indexterm>
15131 When a server successfully authenticates a client it may be configured to
15132 preserve some of the authentication information in the variable
15133 <varname>$authenticated_id</varname> (see chapter <xref linkend="CHAPSMTPAUTH"/>). For example, a
15134 user/password authenticator configuration might preserve the user name for use
15135 in the routers. Note that this is not the same information that is saved in
15136 <varname>$sender_host_authenticated</varname>. When a message is submitted locally (that is,
15137 not over a TCP connection), the value of <varname>$authenticated_id</varname> is the login name
15138 of the calling process.
15139 </para>
15140 </listitem></varlistentry>
15141 <varlistentry>
15142 <term><varname>$authenticated_sender</varname></term>
15143 <listitem>
15144 <para>
15145 <indexterm role="concept">
15146 <primary>sender</primary>
15147 <secondary>authenticated</secondary>
15148 </indexterm>
15149 <indexterm role="concept">
15150 <primary>authentication</primary>
15151 <secondary>sender</secondary>
15152 </indexterm>
15153 <indexterm role="concept">
15154 <primary>AUTH</primary>
15155 <secondary>on MAIL command</secondary>
15156 </indexterm>
15157 <indexterm role="concept">
15158 <primary><varname>$authenticated_sender</varname></primary>
15159 </indexterm>
15160 When acting as a server, Exim takes note of the AUTH= parameter on an incoming
15161 SMTP MAIL command if it believes the sender is sufficiently trusted, as
15162 described in section <xref linkend="SECTauthparamail"/>. Unless the data is the string
15163 <quote>&lt;&gt;</quote>, it is set as the authenticated sender of the message, and the value is
15164 available during delivery in the <varname>$authenticated_sender</varname> variable. If the
15165 sender is not trusted, Exim accepts the syntax of AUTH=, but ignores the data.
15166 </para>
15167 <para>
15168 <indexterm role="concept">
15169 <primary><varname>$qualify_domain</varname></primary>
15170 </indexterm>
15171 When a message is submitted locally (that is, not over a TCP connection), the
15172 value of <varname>$authenticated_sender</varname> is an address constructed from the login
15173 name of the calling process and <varname>$qualify_domain</varname>.
15174 </para>
15175 </listitem></varlistentry>
15176 <varlistentry>
15177 <term><varname>$authentication_failed</varname></term>
15178 <listitem>
15179 <para>
15180 <indexterm role="concept">
15181 <primary>authentication</primary>
15182 <secondary>failure</secondary>
15183 </indexterm>
15184 <indexterm role="concept">
15185 <primary><varname>$authentication_failed</varname></primary>
15186 </indexterm>
15187 This variable is set to <quote>1</quote> in an Exim server if a client issues an AUTH
15188 command that does not succeed. Otherwise it is set to <quote>0</quote>. This makes it
15189 possible to distinguish between <quote>did not try to authenticate</quote>
15190 (<varname>$sender_host_authenticated</varname> is empty and <varname>$authentication_failed</varname> is set to
15191 <quote>0</quote>) and <quote>tried to authenticate but failed</quote> (<varname>$sender_host_authenticated</varname>
15192 is empty and <varname>$authentication_failed</varname> is set to <quote>1</quote>). Failure includes any
15193 negative response to an AUTH command, including (for example) an attempt to use
15194 an undefined mechanism.
15195 </para>
15196 </listitem></varlistentry>
15197 <varlistentry>
15198 <term><varname>$body_linecount</varname></term>
15199 <listitem>
15200 <para>
15201 <indexterm role="concept">
15202 <primary>message body</primary>
15203 <secondary>line count</secondary>
15204 </indexterm>
15205 <indexterm role="concept">
15206 <primary>body of message</primary>
15207 <secondary>line count</secondary>
15208 </indexterm>
15209 <indexterm role="concept">
15210 <primary><varname>$body_linecount</varname></primary>
15211 </indexterm>
15212 When a message is being received or delivered, this variable contains the
15213 number of lines in the message&#x2019;s body. See also <varname>$message_linecount</varname>.
15214 </para>
15215 </listitem></varlistentry>
15216 <varlistentry>
15217 <term><varname>$body_zerocount</varname></term>
15218 <listitem>
15219 <para>
15220 <indexterm role="concept">
15221 <primary>message body</primary>
15222 <secondary>binary zero count</secondary>
15223 </indexterm>
15224 <indexterm role="concept">
15225 <primary>body of message</primary>
15226 <secondary>binary zero count</secondary>
15227 </indexterm>
15228 <indexterm role="concept">
15229 <primary>binary zero</primary>
15230 <secondary>in message body</secondary>
15231 </indexterm>
15232 <indexterm role="concept">
15233 <primary><varname>$body_zerocount</varname></primary>
15234 </indexterm>
15235 When a message is being received or delivered, this variable contains the
15236 number of binary zero bytes in the message&#x2019;s body.
15237 </para>
15238 </listitem></varlistentry>
15239 <varlistentry>
15240 <term><varname>$bounce_recipient</varname></term>
15241 <listitem>
15242 <para>
15243 <indexterm role="concept">
15244 <primary><varname>$bounce_recipient</varname></primary>
15245 </indexterm>
15246 This is set to the recipient address of a bounce message while Exim is creating
15247 it. It is useful if a customized bounce message text file is in use (see
15248 chapter <xref linkend="CHAPemsgcust"/>).
15249 </para>
15250 </listitem></varlistentry>
15251 <varlistentry>
15252 <term><varname>$bounce_return_size_limit</varname></term>
15253 <listitem>
15254 <para>
15255 <indexterm role="concept">
15256 <primary><varname>$bounce_return_size_limit</varname></primary>
15257 </indexterm>
15258 This contains the value set in the <option>bounce_return_size_limit</option> option, rounded
15259 up to a multiple of 1000. It is useful when a customized error message text
15260 file is in use (see chapter <xref linkend="CHAPemsgcust"/>).
15261 </para>
15262 </listitem></varlistentry>
15263 <varlistentry>
15264 <term><varname>$caller_gid</varname></term>
15265 <listitem>
15266 <para>
15267 <indexterm role="concept">
15268 <primary>gid (group id)</primary>
15269 <secondary>caller</secondary>
15270 </indexterm>
15271 <indexterm role="concept">
15272 <primary><varname>$caller_gid</varname></primary>
15273 </indexterm>
15274 The real group id under which the process that called Exim was running. This is
15275 not the same as the group id of the originator of a message (see
15276 <varname>$originator_gid</varname>). If Exim re-execs itself, this variable in the new
15277 incarnation normally contains the Exim gid.
15278 </para>
15279 </listitem></varlistentry>
15280 <varlistentry>
15281 <term><varname>$caller_uid</varname></term>
15282 <listitem>
15283 <para>
15284 <indexterm role="concept">
15285 <primary>uid (user id)</primary>
15286 <secondary>caller</secondary>
15287 </indexterm>
15288 <indexterm role="concept">
15289 <primary><varname>$caller_uid</varname></primary>
15290 </indexterm>
15291 The real user id under which the process that called Exim was running. This is
15292 not the same as the user id of the originator of a message (see
15293 <varname>$originator_uid</varname>). If Exim re-execs itself, this variable in the new
15294 incarnation normally contains the Exim uid.
15295 </para>
15296 </listitem></varlistentry>
15297 <varlistentry>
15298 <term><varname>$compile_date</varname></term>
15299 <listitem>
15300 <para>
15301 <indexterm role="concept">
15302 <primary><varname>$compile_date</varname></primary>
15303 </indexterm>
15304 The date on which the Exim binary was compiled.
15305 </para>
15306 </listitem></varlistentry>
15307 <varlistentry>
15308 <term><varname>$compile_number</varname></term>
15309 <listitem>
15310 <para>
15311 <indexterm role="concept">
15312 <primary><varname>$compile_number</varname></primary>
15313 </indexterm>
15314 The building process for Exim keeps a count of the number
15315 of times it has been compiled. This serves to distinguish different
15316 compilations of the same version of the program.
15317 </para>
15318 </listitem></varlistentry>
15319 <varlistentry>
15320 <term><varname>$demime_errorlevel</varname></term>
15321 <listitem>
15322 <para>
15323 <indexterm role="concept">
15324 <primary><varname>$demime_errorlevel</varname></primary>
15325 </indexterm>
15326 This variable is available when Exim is compiled with
15327 the content-scanning extension and the obsolete <option>demime</option> condition. For
15328 details, see section <xref linkend="SECTdemimecond"/>.
15329 </para>
15330 </listitem></varlistentry>
15331 <varlistentry>
15332 <term><varname>$demime_reason</varname></term>
15333 <listitem>
15334 <para>
15335 <indexterm role="concept">
15336 <primary><varname>$demime_reason</varname></primary>
15337 </indexterm>
15338 This variable is available when Exim is compiled with the
15339 content-scanning extension and the obsolete <option>demime</option> condition. For details,
15340 see section <xref linkend="SECTdemimecond"/>.
15341 </para>
15342 </listitem></varlistentry>
15343 <varlistentry>
15344 <term><varname>$dnslist_domain</varname></term>
15345 <listitem>
15346 <para>
15347 <indexterm role="concept">
15348 <primary>black list (DNS)</primary>
15349 </indexterm>
15350 <indexterm role="concept">
15351 <primary><varname>$dnslist_domain</varname></primary>
15352 </indexterm>
15353 When a client host is found to be on a DNS (black) list,
15354 the list&#x2019;s domain name is put into this variable so that it can be included in
15355 the rejection message.
15356 </para>
15357 </listitem></varlistentry>
15358 <varlistentry>
15359 <term><varname>$dnslist_text</varname></term>
15360 <listitem>
15361 <para>
15362 <indexterm role="concept">
15363 <primary><varname>$dnslist_text</varname></primary>
15364 </indexterm>
15365 When a client host is found to be on a DNS (black) list, the
15366 contents of any associated TXT record are placed in this variable.
15367 </para>
15368 </listitem></varlistentry>
15369 <varlistentry>
15370 <term><varname>$dnslist_value</varname></term>
15371 <listitem>
15372 <para>
15373 <indexterm role="concept">
15374 <primary><varname>$dnslist_value</varname></primary>
15375 </indexterm>
15376 When a client host is found to be on a DNS (black) list,
15377 the IP address from the resource record is placed in this variable.
15378 If there are multiple records, all the addresses are included, comma-space
15379 separated.
15380 </para>
15381 </listitem></varlistentry>
15382 <varlistentry>
15383 <term><varname>$domain</varname></term>
15384 <listitem>
15385 <para>
15386 <indexterm role="concept">
15387 <primary><varname>$domain</varname></primary>
15388 </indexterm>
15389 When an address is being routed, or delivered on its own, this variable
15390 contains the domain. Global address rewriting happens when a message is
15391 received, so the value of <varname>$domain</varname> during routing and delivery is the value
15392 after rewriting. <varname>$domain</varname> is set during user filtering, but not during system
15393 filtering, because a message may have many recipients and the system filter is
15394 called just once.
15395 </para>
15396 <para>
15397 When more than one address is being delivered at once (for example, several
15398 RCPT commands in one SMTP delivery), <varname>$domain</varname> is set only if they all
15399 have the same domain. Transports can be restricted to handling only one domain
15400 at a time if the value of <varname>$domain</varname> is required at transport time &ndash; this is
15401 the default for local transports. For further details of the environment in
15402 which local transports are run, see chapter <xref linkend="CHAPenvironment"/>.
15403 </para>
15404 <para>
15405 <indexterm role="concept">
15406 <primary><option>delay_warning_condition</option></primary>
15407 </indexterm>
15408 At the end of a delivery, if all deferred addresses have the same domain, it is
15409 set in <varname>$domain</varname> during the expansion of <option>delay_warning_condition</option>.
15410 </para>
15411 <para>
15412 The <varname>$domain</varname> variable is also used in some other circumstances:
15413 </para>
15414 <itemizedlist>
15415 <listitem>
15416 <para>
15417 When an ACL is running for a RCPT command, <varname>$domain</varname> contains the domain of
15418 the recipient address. The domain of the <emphasis>sender</emphasis> address is in
15419 <varname>$sender_address_domain</varname> at both MAIL time and at RCPT time. <varname>$domain</varname> is not
15420 normally set during the running of the MAIL ACL. However, if the sender address
15421 is verified with a callout during the MAIL ACL, the sender domain is placed in
15422 <varname>$domain</varname> during the expansions of <option>hosts</option>, <option>interface</option>, and <option>port</option> in
15423 the <command>smtp</command> transport.
15424 </para>
15425 </listitem>
15426 <listitem>
15427 <para>
15428 When a rewrite item is being processed (see chapter <xref linkend="CHAPrewrite"/>),
15429 <varname>$domain</varname> contains the domain portion of the address that is being rewritten;
15430 it can be used in the expansion of the replacement address, for example, to
15431 rewrite domains by file lookup.
15432 </para>
15433 </listitem>
15434 <listitem>
15435 <para>
15436 With one important exception, whenever a domain list is being scanned,
15437 <varname>$domain</varname> contains the subject domain. <emphasis role="bold">Exception</emphasis>: When a domain list in
15438 a <option>sender_domains</option> condition in an ACL is being processed, the subject domain
15439 is in <varname>$sender_address_domain</varname> and not in <varname>$domain</varname>. It works this way so
15440 that, in a RCPT ACL, the sender domain list can be dependent on the
15441 recipient domain (which is what is in <varname>$domain</varname> at this time).
15442 </para>
15443 </listitem>
15444 <listitem>
15445 <para>
15446 <indexterm role="concept">
15447 <primary>ETRN</primary>
15448 <secondary>value of <varname>$domain</varname></secondary>
15449 </indexterm>
15450 <indexterm role="concept">
15451 <primary><option>smtp_etrn_command</option></primary>
15452 </indexterm>
15453 When the <option>smtp_etrn_command</option> option is being expanded, <varname>$domain</varname> contains
15454 the complete argument of the ETRN command (see section <xref linkend="SECTETRN"/>).
15455 </para>
15456 </listitem>
15457 </itemizedlist>
15458 </listitem></varlistentry>
15459 <varlistentry>
15460 <term><varname>$domain_data</varname></term>
15461 <listitem>
15462 <para>
15463 <indexterm role="concept">
15464 <primary><varname>$domain_data</varname></primary>
15465 </indexterm>
15466 When the <option>domains</option> option on a router matches a domain by
15467 means of a lookup, the data read by the lookup is available during the running
15468 of the router as <varname>$domain_data</varname>. In addition, if the driver routes the
15469 address to a transport, the value is available in that transport. If the
15470 transport is handling multiple addresses, the value from the first address is
15471 used.
15472 </para>
15473 <para>
15474 <varname>$domain_data</varname> is also set when the <option>domains</option> condition in an ACL matches a
15475 domain by means of a lookup. The data read by the lookup is available during
15476 the rest of the ACL statement. In all other situations, this variable expands
15477 to nothing.
15478 </para>
15479 </listitem></varlistentry>
15480 <varlistentry>
15481 <term><varname>$exim_gid</varname></term>
15482 <listitem>
15483 <para>
15484 <indexterm role="concept">
15485 <primary><varname>$exim_gid</varname></primary>
15486 </indexterm>
15487 This variable contains the numerical value of the Exim group id.
15488 </para>
15489 </listitem></varlistentry>
15490 <varlistentry>
15491 <term><varname>$exim_path</varname></term>
15492 <listitem>
15493 <para>
15494 <indexterm role="concept">
15495 <primary><varname>$exim_path</varname></primary>
15496 </indexterm>
15497 This variable contains the path to the Exim binary.
15498 </para>
15499 </listitem></varlistentry>
15500 <varlistentry>
15501 <term><varname>$exim_uid</varname></term>
15502 <listitem>
15503 <para>
15504 <indexterm role="concept">
15505 <primary><varname>$exim_uid</varname></primary>
15506 </indexterm>
15507 This variable contains the numerical value of the Exim user id.
15508 </para>
15509 </listitem></varlistentry>
15510 <varlistentry>
15511 <term><varname>$found_extension</varname></term>
15512 <listitem>
15513 <para>
15514 <indexterm role="concept">
15515 <primary><varname>$found_extension</varname></primary>
15516 </indexterm>
15517 This variable is available when Exim is compiled with the
15518 content-scanning extension and the obsolete <option>demime</option> condition. For details,
15519 see section <xref linkend="SECTdemimecond"/>.
15520 </para>
15521 </listitem></varlistentry>
15522 <varlistentry>
15523 <term><varname>$header_</varname>&lt;<emphasis>name</emphasis>&gt;</term>
15524 <listitem>
15525 <para>
15526 This is not strictly an expansion variable. It is expansion syntax for
15527 inserting the message header line with the given name. Note that the name must
15528 be terminated by colon or white space, because it may contain a wide variety of
15529 characters. Note also that braces must <emphasis>not</emphasis> be used.
15530 </para>
15531 </listitem></varlistentry>
15532 <varlistentry>
15533 <term><varname>$home</varname></term>
15534 <listitem>
15535 <para>
15536 <indexterm role="concept">
15537 <primary><varname>$home</varname></primary>
15538 </indexterm>
15539 When the <option>check_local_user</option> option is set for a router, the user&#x2019;s home
15540 directory is placed in <varname>$home</varname> when the check succeeds. In particular, this
15541 means it is set during the running of users&#x2019; filter files. A router may also
15542 explicitly set a home directory for use by a transport; this can be overridden
15543 by a setting on the transport itself.
15544 </para>
15545 <para>
15546 When running a filter test via the <option>-bf</option> option, <varname>$home</varname> is set to the value
15547 of the environment variable HOME.
15548 </para>
15549 </listitem></varlistentry>
15550 <varlistentry>
15551 <term><varname>$host</varname></term>
15552 <listitem>
15553 <para>
15554 <indexterm role="concept">
15555 <primary><varname>$host</varname></primary>
15556 </indexterm>
15557 When the <command>smtp</command> transport is expanding its options for encryption using TLS,
15558 <varname>$host</varname> contains the name of the host to which it is connected. Likewise, when
15559 used in the client part of an authenticator configuration (see chapter
15560 <xref linkend="CHAPSMTPAUTH"/>), <varname>$host</varname> contains the name of the server to which the
15561 client is connected.
15562 </para>
15563 <para>
15564 <indexterm role="concept">
15565 <primary>transport</primary>
15566 <secondary>filter</secondary>
15567 </indexterm>
15568 <indexterm role="concept">
15569 <primary>filter</primary>
15570 <secondary>transport filter</secondary>
15571 </indexterm>
15572 When used in a transport filter (see chapter <xref linkend="CHAPtransportgeneric"/>)
15573 <varname>$host</varname> refers to the host involved in the current connection. When a local
15574 transport is run as a result of a router that sets up a host list, <varname>$host</varname>
15575 contains the name of the first host.
15576 </para>
15577 </listitem></varlistentry>
15578 <varlistentry>
15579 <term><varname>$host_address</varname></term>
15580 <listitem>
15581 <para>
15582 <indexterm role="concept">
15583 <primary><varname>$host_address</varname></primary>
15584 </indexterm>
15585 This variable is set to the remote host&#x2019;s IP address whenever <varname>$host</varname> is set
15586 for a remote connection. It is also set to the IP address that is being checked
15587 when the <option>ignore_target_hosts</option> option is being processed.
15588 </para>
15589 </listitem></varlistentry>
15590 <varlistentry>
15591 <term><varname>$host_data</varname></term>
15592 <listitem>
15593 <para>
15594 <indexterm role="concept">
15595 <primary><varname>$host_data</varname></primary>
15596 </indexterm>
15597 If a <option>hosts</option> condition in an ACL is satisfied by means of a lookup, the
15598 result of the lookup is made available in the <varname>$host_data</varname> variable. This
15599 allows you, for example, to do things like this:
15600 </para>
15601 <literallayout class="monospaced">
15602 deny  hosts = net-lsearch;/some/file
15603 message = $host_data
15604 </literallayout>
15605 </listitem></varlistentry>
15606 <varlistentry>
15607 <term><varname>$host_lookup_deferred</varname></term>
15608 <listitem>
15609 <para>
15610 <indexterm role="concept">
15611 <primary>host name lookup</primary>
15612 <secondary>failure of</secondary>
15613 </indexterm>
15614 <indexterm role="concept">
15615 <primary><varname>$host_lookup_deferred</varname></primary>
15616 </indexterm>
15617 This variable normally contains <quote>0</quote>, as does <varname>$host_lookup_failed</varname>. When a
15618 message comes from a remote host and there is an attempt to look up the host&#x2019;s
15619 name from its IP address, and the attempt is not successful, one of these
15620 variables is set to <quote>1</quote>.
15621 </para>
15622 <itemizedlist>
15623 <listitem>
15624 <para>
15625 If the lookup receives a definite negative response (for example, a DNS lookup
15626 succeeded, but no records were found), <varname>$host_lookup_failed</varname> is set to <quote>1</quote>.
15627 </para>
15628 </listitem>
15629 <listitem>
15630 <para>
15631 If there is any kind of problem during the lookup, such that Exim cannot
15632 tell whether or not the host name is defined (for example, a timeout for a DNS
15633 lookup), <varname>$host_lookup_deferred</varname> is set to <quote>1</quote>.
15634 </para>
15635 </listitem>
15636 </itemizedlist>
15637 <para>
15638 Looking up a host&#x2019;s name from its IP address consists of more than just a
15639 single reverse lookup. Exim checks that a forward lookup of at least one of the
15640 names it receives from a reverse lookup yields the original IP address. If this
15641 is not the case, Exim does not accept the looked up name(s), and
15642 <varname>$host_lookup_failed</varname> is set to <quote>1</quote>. Thus, being able to find a name from an
15643 IP address (for example, the existence of a PTR record in the DNS) is not
15644 sufficient on its own for the success of a host name lookup. If the reverse
15645 lookup succeeds, but there is a lookup problem such as a timeout when checking
15646 the result, the name is not accepted, and <varname>$host_lookup_deferred</varname> is set to
15647 <quote>1</quote>. See also <varname>$sender_host_name</varname>.
15648 </para>
15649 </listitem></varlistentry>
15650 <varlistentry>
15651 <term><varname>$host_lookup_failed</varname></term>
15652 <listitem>
15653 <para>
15654 <indexterm role="concept">
15655 <primary><varname>$host_lookup_failed</varname></primary>
15656 </indexterm>
15657 See <varname>$host_lookup_deferred</varname>.
15658 </para>
15659 </listitem></varlistentry>
15660 <varlistentry>
15661 <term><varname>$inode</varname></term>
15662 <listitem>
15663 <para>
15664 <indexterm role="concept">
15665 <primary><varname>$inode</varname></primary>
15666 </indexterm>
15667 The only time this variable is set is while expanding the <option>directory_file</option>
15668 option in the <command>appendfile</command> transport. The variable contains the inode number
15669 of the temporary file which is about to be renamed. It can be used to construct
15670 a unique name for the file.
15671 </para>
15672 </listitem></varlistentry>
15673 <varlistentry>
15674 <term><varname>$interface_address</varname></term>
15675 <listitem>
15676 <para>
15677 <indexterm role="concept">
15678 <primary><varname>$interface_address</varname></primary>
15679 </indexterm>
15680 As soon as a server starts processing a TCP/IP connection, this variable is set
15681 to the address of the local IP interface, and <varname>$interface_port</varname> is set to the
15682 port number. These values are therefore available for use in the <quote>connect</quote>
15683 ACL. See also the <option>-oMi</option> command line option. As well as being used in ACLs,
15684 these variable could be used, for example, to make the file name for a TLS
15685 certificate depend on which interface and/or port is being used.
15686 </para>
15687 </listitem></varlistentry>
15688 <varlistentry>
15689 <term><varname>$interface_port</varname></term>
15690 <listitem>
15691 <para>
15692 <indexterm role="concept">
15693 <primary><varname>$interface_port</varname></primary>
15694 </indexterm>
15695 See <varname>$interface_address</varname>.
15696 </para>
15697 </listitem></varlistentry>
15698 <varlistentry>
15699 <term><varname>$ldap_dn</varname></term>
15700 <listitem>
15701 <para>
15702 <indexterm role="concept">
15703 <primary><varname>$ldap_dn</varname></primary>
15704 </indexterm>
15705 This variable, which is available only when Exim is compiled with LDAP support,
15706 contains the DN from the last entry in the most recently successful LDAP
15707 lookup.
15708 </para>
15709 </listitem></varlistentry>
15710 <varlistentry>
15711 <term><varname>$load_average</varname></term>
15712 <listitem>
15713 <para>
15714 <indexterm role="concept">
15715 <primary><varname>$load_average</varname></primary>
15716 </indexterm>
15717 This variable contains the system load average, multiplied by 1000 to that it
15718 is an integer. For example, if the load average is 0.21, the value of the
15719 variable is 210. The value is recomputed every time the variable is referenced.
15720 </para>
15721 </listitem></varlistentry>
15722 <varlistentry>
15723 <term><varname>$local_part</varname></term>
15724 <listitem>
15725 <para>
15726 <indexterm role="concept">
15727 <primary><varname>$local_part</varname></primary>
15728 </indexterm>
15729 When an address is being routed, or delivered on its own, this
15730 variable contains the local part. When a number of addresses are being
15731 delivered together (for example, multiple RCPT commands in an SMTP
15732 session), <varname>$local_part</varname> is not set.
15733 </para>
15734 <para>
15735 Global address rewriting happens when a message is received, so the value of
15736 <varname>$local_part</varname> during routing and delivery is the value after rewriting.
15737 <varname>$local_part</varname> is set during user filtering, but not during system filtering,
15738 because a message may have many recipients and the system filter is called just
15739 once.
15740 </para>
15741 <para>
15742 <indexterm role="concept">
15743 <primary><varname>$local_part_prefix</varname></primary>
15744 </indexterm>
15745 <indexterm role="concept">
15746 <primary><varname>$local_part_suffix</varname></primary>
15747 </indexterm>
15748 If a local part prefix or suffix has been recognized, it is not included in the
15749 value of <varname>$local_part</varname> during routing and subsequent delivery. The values of
15750 any prefix or suffix are in <varname>$local_part_prefix</varname> and
15751 <varname>$local_part_suffix</varname>, respectively.
15752 </para>
15753 <para>
15754 When a message is being delivered to a file, pipe, or autoreply transport as a
15755 result of aliasing or forwarding, <varname>$local_part</varname> is set to the local part of
15756 the parent address, not to the file name or command (see <varname>$address_file</varname> and
15757 <varname>$address_pipe</varname>).
15758 </para>
15759 <para>
15760 When an ACL is running for a RCPT command, <varname>$local_part</varname> contains the
15761 local part of the recipient address.
15762 </para>
15763 <para>
15764 When a rewrite item is being processed (see chapter <xref linkend="CHAPrewrite"/>),
15765 <varname>$local_part</varname> contains the local part of the address that is being rewritten;
15766 it can be used in the expansion of the replacement address, for example.
15767 </para>
15768 <para>
15769 In all cases, all quoting is removed from the local part. For example, for both
15770 the addresses
15771 </para>
15772 <literallayout class="monospaced">
15773 "abc:xyz"@test.example
15774 abc\:xyz@test.example
15775 </literallayout>
15776 <para>
15777 the value of <varname>$local_part</varname> is
15778 </para>
15779 <literallayout class="monospaced">
15780 abc:xyz
15781 </literallayout>
15782 <para>
15783 If you use <varname>$local_part</varname> to create another address, you should always wrap it
15784 inside a quoting operator. For example, in a <command>redirect</command> router you could
15785 have:
15786 </para>
15787 <literallayout class="monospaced">
15788 data = ${quote_local_part:$local_part}@new.domain.example
15789 </literallayout>
15790 <para>
15791 <emphasis role="bold">Note</emphasis>: The value of <varname>$local_part</varname> is normally lower cased. If you want
15792 to process local parts in a case-dependent manner in a router, you can set the
15793 <option>caseful_local_part</option> option (see chapter <xref linkend="CHAProutergeneric"/>).
15794 </para>
15795 </listitem></varlistentry>
15796 <varlistentry>
15797 <term><varname>$local_part_data</varname></term>
15798 <listitem>
15799 <para>
15800 <indexterm role="concept">
15801 <primary><varname>$local_part_data</varname></primary>
15802 </indexterm>
15803 When the <option>local_parts</option> option on a router matches a local part by means of a
15804 lookup, the data read by the lookup is available during the running of the
15805 router as <varname>$local_part_data</varname>. In addition, if the driver routes the address
15806 to a transport, the value is available in that transport. If the transport is
15807 handling multiple addresses, the value from the first address is used.
15808 </para>
15809 <para>
15810 <varname>$local_part_data</varname> is also set when the <option>local_parts</option> condition in an ACL
15811 matches a local part by means of a lookup. The data read by the lookup is
15812 available during the rest of the ACL statement. In all other situations, this
15813 variable expands to nothing.
15814 </para>
15815 </listitem></varlistentry>
15816 <varlistentry>
15817 <term><varname>$local_part_prefix</varname></term>
15818 <listitem>
15819 <para>
15820 <indexterm role="concept">
15821 <primary><varname>$local_part_prefix</varname></primary>
15822 </indexterm>
15823 When an address is being routed or delivered, and a
15824 specific prefix for the local part was recognized, it is available in this
15825 variable, having been removed from <varname>$local_part</varname>.
15826 </para>
15827 </listitem></varlistentry>
15828 <varlistentry>
15829 <term><varname>$local_part_suffix</varname></term>
15830 <listitem>
15831 <para>
15832 <indexterm role="concept">
15833 <primary><varname>$local_part_suffix</varname></primary>
15834 </indexterm>
15835 When an address is being routed or delivered, and a
15836 specific suffix for the local part was recognized, it is available in this
15837 variable, having been removed from <varname>$local_part</varname>.
15838 </para>
15839 </listitem></varlistentry>
15840 <varlistentry>
15841 <term><varname>$local_scan_data</varname></term>
15842 <listitem>
15843 <para>
15844 <indexterm role="concept">
15845 <primary><varname>$local_scan_data</varname></primary>
15846 </indexterm>
15847 This variable contains the text returned by the <function>local_scan()</function> function when
15848 a message is received. See chapter <xref linkend="CHAPlocalscan"/> for more details.
15849 </para>
15850 </listitem></varlistentry>
15851 <varlistentry>
15852 <term><varname>$local_user_gid</varname></term>
15853 <listitem>
15854 <para>
15855 <indexterm role="concept">
15856 <primary><varname>$local_user_gid</varname></primary>
15857 </indexterm>
15858 See <varname>$local_user_uid</varname>.
15859 </para>
15860 </listitem></varlistentry>
15861 <varlistentry>
15862 <term><varname>$local_user_uid</varname></term>
15863 <listitem>
15864 <para>
15865 <indexterm role="concept">
15866 <primary><varname>$local_user_uid</varname></primary>
15867 </indexterm>
15868 This variable and <varname>$local_user_gid</varname> are set to the uid and gid after the
15869 <option>check_local_user</option> router precondition succeeds. This means that their values
15870 are available for the remaining preconditions (<option>senders</option>, <option>require_files</option>,
15871 and <option>condition</option>), for the <option>address_data</option> expansion, and for any
15872 router-specific expansions. At all other times, the values in these variables
15873 are <literal>(uid_t)(-1)</literal> and <literal>(gid_t)(-1)</literal>, respectively.
15874 </para>
15875 </listitem></varlistentry>
15876 <varlistentry>
15877 <term><varname>$localhost_number</varname></term>
15878 <listitem>
15879 <para>
15880 <indexterm role="concept">
15881 <primary><varname>$localhost_number</varname></primary>
15882 </indexterm>
15883 This contains the expanded value of the
15884 <option>localhost_number</option> option. The expansion happens after the main options have
15885 been read.
15886 </para>
15887 </listitem></varlistentry>
15888 <varlistentry>
15889 <term><varname>$log_inodes</varname></term>
15890 <listitem>
15891 <para>
15892 <indexterm role="concept">
15893 <primary><varname>$log_inodes</varname></primary>
15894 </indexterm>
15895 The number of free inodes in the disk partition where Exim&#x2019;s
15896 log files are being written. The value is recalculated whenever the variable is
15897 referenced. If the relevant file system does not have the concept of inodes,
15898 the value of is -1. See also the <option>check_log_inodes</option> option.
15899 </para>
15900 </listitem></varlistentry>
15901 <varlistentry>
15902 <term><varname>$log_space</varname></term>
15903 <listitem>
15904 <para>
15905 <indexterm role="concept">
15906 <primary><varname>$log_space</varname></primary>
15907 </indexterm>
15908 The amount of free space (as a number of kilobytes) in the disk
15909 partition where Exim&#x2019;s log files are being written. The value is recalculated
15910 whenever the variable is referenced. If the operating system does not have the
15911 ability to find the amount of free space (only true for experimental systems),
15912 the space value is -1. See also the <option>check_log_space</option> option.
15913 </para>
15914 </listitem></varlistentry>
15915 <varlistentry>
15916 <term><varname>$mailstore_basename</varname></term>
15917 <listitem>
15918 <para>
15919 <indexterm role="concept">
15920 <primary><varname>$mailstore_basename</varname></primary>
15921 </indexterm>
15922 This variable is set only when doing deliveries in <quote>mailstore</quote> format in the
15923 <command>appendfile</command> transport. During the expansion of the <option>mailstore_prefix</option>,
15924 <option>mailstore_suffix</option>, <option>message_prefix</option>, and <option>message_suffix</option> options, it
15925 contains the basename of the files that are being written, that is, the name
15926 without the <quote>.tmp</quote>, <quote>.env</quote>, or <quote>.msg</quote> suffix. At all other times, this
15927 variable is empty.
15928 </para>
15929 </listitem></varlistentry>
15930 <varlistentry>
15931 <term><varname>$malware_name</varname></term>
15932 <listitem>
15933 <para>
15934 <indexterm role="concept">
15935 <primary><varname>$malware_name</varname></primary>
15936 </indexterm>
15937 This variable is available when Exim is compiled with the
15938 content-scanning extension. It is set to the name of the virus that was found
15939 when the ACL <option>malware</option> condition is true (see section <xref linkend="SECTscanvirus"/>).
15940 </para>
15941 </listitem></varlistentry>
15942 <varlistentry>
15943 <term><varname>$message_age</varname></term>
15944 <listitem>
15945 <para>
15946 <indexterm role="concept">
15947 <primary>message</primary>
15948 <secondary>age of</secondary>
15949 </indexterm>
15950 <indexterm role="concept">
15951 <primary><varname>$message_age</varname></primary>
15952 </indexterm>
15953 This variable is set at the start of a delivery attempt to contain the number
15954 of seconds since the message was received. It does not change during a single
15955 delivery attempt.
15956 </para>
15957 </listitem></varlistentry>
15958 <varlistentry>
15959 <term><varname>$message_body</varname></term>
15960 <listitem>
15961 <para>
15962 <indexterm role="concept">
15963 <primary>body of message</primary>
15964 <secondary>expansion variable</secondary>
15965 </indexterm>
15966 <indexterm role="concept">
15967 <primary>message body</primary>
15968 <secondary>in expansion</secondary>
15969 </indexterm>
15970 <indexterm role="concept">
15971 <primary>binary zero</primary>
15972 <secondary>in message body</secondary>
15973 </indexterm>
15974 <indexterm role="concept">
15975 <primary><varname>$message_body</varname></primary>
15976 </indexterm>
15977 This variable contains the initial portion of a message&#x2019;s
15978 body while it is being delivered, and is intended mainly for use in filter
15979 files. The maximum number of characters of the body that are put into the
15980 variable is set by the <option>message_body_visible</option> configuration option; the
15981 default is 500. Newlines are converted into spaces to make it easier to search
15982 for phrases that might be split over a line break.
15983 Binary zeros are also converted into spaces.
15984 </para>
15985 </listitem></varlistentry>
15986 <varlistentry>
15987 <term><varname>$message_body_end</varname></term>
15988 <listitem>
15989 <para>
15990 <indexterm role="concept">
15991 <primary>body of message</primary>
15992 <secondary>expansion variable</secondary>
15993 </indexterm>
15994 <indexterm role="concept">
15995 <primary>message body</primary>
15996 <secondary>in expansion</secondary>
15997 </indexterm>
15998 <indexterm role="concept">
15999 <primary><varname>$message_body_end</varname></primary>
16000 </indexterm>
16001 This variable contains the final portion of a message&#x2019;s
16002 body while it is being delivered. The format and maximum size are as for
16003 <varname>$message_body</varname>.
16004 </para>
16005 </listitem></varlistentry>
16006 <varlistentry>
16007 <term><varname>$message_body_size</varname></term>
16008 <listitem>
16009 <para>
16010 <indexterm role="concept">
16011 <primary>body of message</primary>
16012 <secondary>size</secondary>
16013 </indexterm>
16014 <indexterm role="concept">
16015 <primary>message body</primary>
16016 <secondary>size</secondary>
16017 </indexterm>
16018 <indexterm role="concept">
16019 <primary><varname>$message_body_size</varname></primary>
16020 </indexterm>
16021 When a message is being delivered, this variable contains the size of the body
16022 in bytes. The count starts from the character after the blank line that
16023 separates the body from the header. Newlines are included in the count. See
16024 also <varname>$message_size</varname>, <varname>$body_linecount</varname>, and <varname>$body_zerocount</varname>.
16025 </para>
16026 </listitem></varlistentry>
16027 <varlistentry>
16028 <term><varname>$message_exim_id</varname></term>
16029 <listitem>
16030 <para>
16031 <indexterm role="concept">
16032 <primary><varname>$message_exim_id</varname></primary>
16033 </indexterm>
16034 When a message is being received or delivered, this variable contains the
16035 unique message id that is generated and used by Exim to identify the message.
16036 An id is not created for a message until after its header has been successfully
16037 received. <emphasis role="bold">Note</emphasis>: This is <emphasis>not</emphasis> the contents of the <emphasis>Message-ID:</emphasis> header
16038 line; it is the local id that Exim assigns to the message, for example:
16039 <literal>1BXTIK-0001yO-VA</literal>.
16040 </para>
16041 </listitem></varlistentry>
16042 <varlistentry>
16043 <term><varname>$message_headers</varname></term>
16044 <listitem>
16045 <para>
16046 This variable contains a concatenation of all the header lines when a message
16047 is being processed, except for lines added by routers or transports. The header
16048 lines are separated by newline characters.
16049 </para>
16050 </listitem></varlistentry>
16051 <varlistentry>
16052 <term><varname>$message_id</varname></term>
16053 <listitem>
16054 <para>
16055 This is an old name for <varname>$message_exim_id</varname>, which is now deprecated.
16056 </para>
16057 </listitem></varlistentry>
16058 <varlistentry>
16059 <term><varname>$message_linecount</varname></term>
16060 <listitem>
16061 <para>
16062 <indexterm role="concept">
16063 <primary><varname>$message_linecount</varname></primary>
16064 </indexterm>
16065 This variable contains the total number of lines in the header and body of the
16066 message. Compare <varname>$body_linecount</varname>, which is the count for the body only.
16067 During the DATA and content-scanning ACLs, <varname>$message_linecount</varname> contains the
16068 number of lines received. Before delivery happens (that is, before filters,
16069 routers, and transports run) the count is increased to include the
16070 <emphasis>Received:</emphasis> header line that Exim standardly adds, and also any other header
16071 lines that are added by ACLs. The blank line that separates the message header
16072 from the body is not counted. Here is an example of the use of this variable in
16073 a DATA ACL:
16074 </para>
16075 <literallayout class="monospaced">
16076 deny message   = Too many lines in message header
16077      condition = \
16078        ${if &lt;{250}{${eval:$message_linecount - $body_linecount}}}
16079 </literallayout>
16080 <para>
16081 In the MAIL and RCPT ACLs, the value is zero because at that stage the
16082 message has not yet been received.
16083 </para>
16084 </listitem></varlistentry>
16085 <varlistentry>
16086 <term><varname>$message_size</varname></term>
16087 <listitem>
16088 <para>
16089 <indexterm role="concept">
16090 <primary>size</primary>
16091 <secondary>of message</secondary>
16092 </indexterm>
16093 <indexterm role="concept">
16094 <primary>message</primary>
16095 <secondary>size</secondary>
16096 </indexterm>
16097 <indexterm role="concept">
16098 <primary><varname>$message_size</varname></primary>
16099 </indexterm>
16100 When a message is being processed, this variable contains its size in bytes. In
16101 most cases, the size includes those headers that were received with the
16102 message, but not those (such as <emphasis>Envelope-to:</emphasis>) that are added to individual
16103 deliveries as they are written. However, there is one special case: during the
16104 expansion of the <option>maildir_tag</option> option in the <command>appendfile</command> transport while
16105 doing a delivery in maildir format, the value of <varname>$message_size</varname> is the
16106 precise size of the file that has been written. See also
16107 <varname>$message_body_size</varname>, <varname>$body_linecount</varname>, and <varname>$body_zerocount</varname>.
16108 </para>
16109 <para>
16110 <indexterm role="concept">
16111 <primary>RCPT</primary>
16112 <secondary>value of <varname>$message_size</varname></secondary>
16113 </indexterm>
16114 While running an ACL at the time of an SMTP RCPT command, <varname>$message_size</varname>
16115 contains the size supplied on the MAIL command, or -1 if no size was given. The
16116 value may not, of course, be truthful.
16117 </para>
16118 </listitem></varlistentry>
16119 <varlistentry>
16120 <term><varname>$mime_</varname><emphasis>xxx</emphasis></term>
16121 <listitem>
16122 <para>
16123 A number of variables whose names start with <varname>$mime</varname> are
16124 available when Exim is compiled with the content-scanning extension. For
16125 details, see section <xref linkend="SECTscanmimepart"/>.
16126 </para>
16127 </listitem></varlistentry>
16128 <varlistentry>
16129 <term><varname>$n0</varname> &ndash; <varname>$n9</varname></term>
16130 <listitem>
16131 <para>
16132 These variables are counters that can be incremented by means
16133 of the <option>add</option> command in filter files.
16134 </para>
16135 </listitem></varlistentry>
16136 <varlistentry>
16137 <term><varname>$original_domain</varname></term>
16138 <listitem>
16139 <para>
16140 <indexterm role="concept">
16141 <primary><varname>$domain</varname></primary>
16142 </indexterm>
16143 <indexterm role="concept">
16144 <primary><varname>$original_domain</varname></primary>
16145 </indexterm>
16146 When a top-level address is being processed for delivery, this contains the
16147 same value as <varname>$domain</varname>. However, if a <quote>child</quote> address (for example,
16148 generated by an alias, forward, or filter file) is being processed, this
16149 variable contains the domain of the original address. This differs from
16150 <varname>$parent_domain</varname> only when there is more than one level of aliasing or
16151 forwarding. When more than one address is being delivered in a single transport
16152 run, <varname>$original_domain</varname> is not set.
16153 </para>
16154 <para>
16155 If a new address is created by means of a <option>deliver</option> command in a system
16156 filter, it is set up with an artificial <quote>parent</quote> address. This has the local
16157 part <emphasis>system-filter</emphasis> and the default qualify domain.
16158 </para>
16159 </listitem></varlistentry>
16160 <varlistentry>
16161 <term><varname>$original_local_part</varname></term>
16162 <listitem>
16163 <para>
16164 <indexterm role="concept">
16165 <primary><varname>$local_part</varname></primary>
16166 </indexterm>
16167 <indexterm role="concept">
16168 <primary><varname>$original_local_part</varname></primary>
16169 </indexterm>
16170 When a top-level address is being processed for delivery, this contains the
16171 same value as <varname>$local_part</varname>, unless a prefix or suffix was removed from the
16172 local part, because <varname>$original_local_part</varname> always contains the full local
16173 part. When a <quote>child</quote> address (for example, generated by an alias, forward, or
16174 filter file) is being processed, this variable contains the full local part of
16175 the original address.
16176 </para>
16177 <para>
16178 If the router that did the redirection processed the local part
16179 case-insensitively, the value in <varname>$original_local_part</varname> is in lower case.
16180 This variable differs from <varname>$parent_local_part</varname> only when there is more than
16181 one level of aliasing or forwarding. When more than one address is being
16182 delivered in a single transport run, <varname>$original_local_part</varname> is not set.
16183 </para>
16184 <para>
16185 If a new address is created by means of a <option>deliver</option> command in a system
16186 filter, it is set up with an artificial <quote>parent</quote> address. This has the local
16187 part <emphasis>system-filter</emphasis> and the default qualify domain.
16188 </para>
16189 </listitem></varlistentry>
16190 <varlistentry>
16191 <term><varname>$originator_gid</varname></term>
16192 <listitem>
16193 <para>
16194 <indexterm role="concept">
16195 <primary>gid (group id)</primary>
16196 <secondary>of originating user</secondary>
16197 </indexterm>
16198 <indexterm role="concept">
16199 <primary>sender</primary>
16200 <secondary>gid</secondary>
16201 </indexterm>
16202 <indexterm role="concept">
16203 <primary><varname>$caller_gid</varname></primary>
16204 </indexterm>
16205 <indexterm role="concept">
16206 <primary><varname>$originator_gid</varname></primary>
16207 </indexterm>
16208 This variable contains the value of <varname>$caller_gid</varname> that was set when the
16209 message was received. For messages received via the command line, this is the
16210 gid of the sending user. For messages received by SMTP over TCP/IP, this is
16211 normally the gid of the Exim user.
16212 </para>
16213 </listitem></varlistentry>
16214 <varlistentry>
16215 <term><varname>$originator_uid</varname></term>
16216 <listitem>
16217 <para>
16218 <indexterm role="concept">
16219 <primary>uid (user id)</primary>
16220 <secondary>of originating user</secondary>
16221 </indexterm>
16222 <indexterm role="concept">
16223 <primary>sender</primary>
16224 <secondary>uid</secondary>
16225 </indexterm>
16226 <indexterm role="concept">
16227 <primary><varname>$caller_uid</varname></primary>
16228 </indexterm>
16229 <indexterm role="concept">
16230 <primary><varname>$originaltor_uid</varname></primary>
16231 </indexterm>
16232 The value of <varname>$caller_uid</varname> that was set when the message was received. For
16233 messages received via the command line, this is the uid of the sending user.
16234 For messages received by SMTP over TCP/IP, this is normally the uid of the Exim
16235 user.
16236 </para>
16237 </listitem></varlistentry>
16238 <varlistentry>
16239 <term><varname>$parent_domain</varname></term>
16240 <listitem>
16241 <para>
16242 <indexterm role="concept">
16243 <primary><varname>$parent_domain</varname></primary>
16244 </indexterm>
16245 This variable is similar to <varname>$original_domain</varname> (see
16246 above), except that it refers to the immediately preceding parent address.
16247 </para>
16248 </listitem></varlistentry>
16249 <varlistentry>
16250 <term><varname>$parent_local_part</varname></term>
16251 <listitem>
16252 <para>
16253 <indexterm role="concept">
16254 <primary><varname>$parent_local_part</varname></primary>
16255 </indexterm>
16256 This variable is similar to <varname>$original_local_part</varname>
16257 (see above), except that it refers to the immediately preceding parent address.
16258 </para>
16259 </listitem></varlistentry>
16260 <varlistentry>
16261 <term><varname>$pid</varname></term>
16262 <listitem>
16263 <para>
16264 <indexterm role="concept">
16265 <primary>pid (process id)</primary>
16266 <secondary>of current process</secondary>
16267 </indexterm>
16268 <indexterm role="concept">
16269 <primary><varname>$pid</varname></primary>
16270 </indexterm>
16271 This variable contains the current process id.
16272 </para>
16273 </listitem></varlistentry>
16274 <varlistentry>
16275 <term><varname>$pipe_addresses</varname></term>
16276 <listitem>
16277 <para>
16278 <indexterm role="concept">
16279 <primary>filter</primary>
16280 <secondary>transport filter</secondary>
16281 </indexterm>
16282 <indexterm role="concept">
16283 <primary>transport</primary>
16284 <secondary>filter</secondary>
16285 </indexterm>
16286 <indexterm role="concept">
16287 <primary><varname>$pipe_addresses</varname></primary>
16288 </indexterm>
16289 This is not an expansion variable, but is mentioned here because the string
16290 <quote>$pipe_addresses</quote> is handled specially in the command specification for the
16291 <command>pipe</command> transport (chapter <xref linkend="CHAPpipetransport"/>) and in transport filters
16292 (described under <option>transport_filter</option> in chapter <xref linkend="CHAPtransportgeneric"/>).
16293 It cannot be used in general expansion strings, and provokes an <quote>unknown
16294 variable</quote> error if encountered.
16295 </para>
16296 </listitem></varlistentry>
16297 <varlistentry>
16298 <term><varname>$primary_hostname</varname></term>
16299 <listitem>
16300 <para>
16301 <indexterm role="concept">
16302 <primary><varname>$primary_hostname</varname></primary>
16303 </indexterm>
16304 This variable contains the value set by <option>primary_hostname</option> in the
16305 configuration file, or read by the <function>uname()</function> function. If <function>uname()</function> returns
16306 a single-component name, Exim calls <function>gethostbyname()</function> (or
16307 <function>getipnodebyname()</function> where available) in an attempt to acquire a fully
16308 qualified host name. See also <varname>$smtp_active_hostname</varname>.
16309 </para>
16310 </listitem></varlistentry>
16311 <varlistentry>
16312 <term><varname>$prvscheck_address</varname></term>
16313 <listitem>
16314 <para>
16315 This variable is used in conjunction with the <option>prvscheck</option> expansion item,
16316 which is described in sections <xref linkend="SECTexpansionitems"/> and
16317 <xref linkend="SECTverifyPRVS"/>.
16318 </para>
16319 </listitem></varlistentry>
16320 <varlistentry>
16321 <term><varname>$prvscheck_keynum</varname></term>
16322 <listitem>
16323 <para>
16324 This variable is used in conjunction with the <option>prvscheck</option> expansion item,
16325 which is described in sections <xref linkend="SECTexpansionitems"/> and
16326 <xref linkend="SECTverifyPRVS"/>.
16327 </para>
16328 </listitem></varlistentry>
16329 <varlistentry>
16330 <term><varname>$prvscheck_result</varname></term>
16331 <listitem>
16332 <para>
16333 This variable is used in conjunction with the <option>prvscheck</option> expansion item,
16334 which is described in sections <xref linkend="SECTexpansionitems"/> and
16335 <xref linkend="SECTverifyPRVS"/>.
16336 </para>
16337 </listitem></varlistentry>
16338 <varlistentry>
16339 <term><varname>$qualify_domain</varname></term>
16340 <listitem>
16341 <para>
16342 <indexterm role="concept">
16343 <primary><varname>$qualify_domain</varname></primary>
16344 </indexterm>
16345 The value set for the <option>qualify_domain</option> option in the configuration file.
16346 </para>
16347 </listitem></varlistentry>
16348 <varlistentry>
16349 <term><varname>$qualify_recipient</varname></term>
16350 <listitem>
16351 <para>
16352 <indexterm role="concept">
16353 <primary><varname>$qualify_recipient</varname></primary>
16354 </indexterm>
16355 The value set for the <option>qualify_recipient</option> option in the configuration file,
16356 or if not set, the value of <varname>$qualify_domain</varname>.
16357 </para>
16358 </listitem></varlistentry>
16359 <varlistentry>
16360 <term><varname>$rcpt_count</varname></term>
16361 <listitem>
16362 <para>
16363 <indexterm role="concept">
16364 <primary><varname>$rcpt_count</varname></primary>
16365 </indexterm>
16366 When a message is being received by SMTP, this variable contains the number of
16367 RCPT commands received for the current message. If this variable is used in a
16368 RCPT ACL, its value includes the current command.
16369 </para>
16370 </listitem></varlistentry>
16371 <varlistentry>
16372 <term><varname>$rcpt_defer_count</varname></term>
16373 <listitem>
16374 <para>
16375 <indexterm role="concept">
16376 <primary><varname>$rcpt_defer_count</varname></primary>
16377 </indexterm>
16378 When a message is being received by SMTP, this variable contains the number of
16379 RCPT commands in the current message that have previously been rejected with a
16380 temporary (4<emphasis>xx</emphasis>) response.
16381 </para>
16382 </listitem></varlistentry>
16383 <varlistentry>
16384 <term><varname>$rcpt_fail_count</varname></term>
16385 <listitem>
16386 <para>
16387 <indexterm role="concept">
16388 <primary><varname>$rcpt_fail_count</varname></primary>
16389 </indexterm>
16390 When a message is being received by SMTP, this variable contains the number of
16391 RCPT commands in the current message that have previously been rejected with a
16392 permanent (5<emphasis>xx</emphasis>) response.
16393 </para>
16394 </listitem></varlistentry>
16395 <varlistentry>
16396 <term><varname>$received_count</varname></term>
16397 <listitem>
16398 <para>
16399 <indexterm role="concept">
16400 <primary><varname>$received_count</varname></primary>
16401 </indexterm>
16402 This variable contains the number of <emphasis>Received:</emphasis> header lines in the message,
16403 including the one added by Exim (so its value is always greater than zero). It
16404 is available in the DATA ACL, the non-SMTP ACL, and while routing and
16405 delivering.
16406 </para>
16407 </listitem></varlistentry>
16408 <varlistentry>
16409 <term><varname>$received_for</varname></term>
16410 <listitem>
16411 <para>
16412 <indexterm role="concept">
16413 <primary><varname>$received_for</varname></primary>
16414 </indexterm>
16415 If there is only a single recipient address in an incoming message, this
16416 variable contains that address when the <emphasis>Received:</emphasis> header line is being
16417 built. The value is copied after recipient rewriting has happened, but before
16418 the <function>local_scan()</function> function is run.
16419 </para>
16420 </listitem></varlistentry>
16421 <varlistentry>
16422 <term><varname>$received_protocol</varname></term>
16423 <listitem>
16424 <para>
16425 <indexterm role="concept">
16426 <primary><varname>$received_protocol</varname></primary>
16427 </indexterm>
16428 When a message is being processed, this variable contains the name of the
16429 protocol by which it was received. Most of the names used by Exim are defined
16430 by RFCs 821, 2821, and 3848. They start with <quote>smtp</quote> (the client used HELO) or
16431 <quote>esmtp</quote> (the client used EHLO). This can be followed by <quote>s</quote> for secure
16432 (encrypted) and/or <quote>a</quote> for authenticated. Thus, for example, if the protocol
16433 is set to <quote>esmtpsa</quote>, the message was received over an encrypted SMTP
16434 connection and the client was successfully authenticated.
16435 </para>
16436 <para>
16437 Exim uses the protocol name <quote>smtps</quote> for the case when encryption is
16438 automatically set up on connection without the use of STARTTLS (see
16439 <option>tls_on_connect_ports</option>), and the client uses HELO to initiate the
16440 encrypted SMTP session. The name <quote>smtps</quote> is also used for the rare situation
16441 where the client initially uses EHLO, sets up an encrypted connection using
16442 STARTTLS, and then uses HELO afterwards.
16443 </para>
16444 <para>
16445 The <option>-oMr</option> option provides a way of specifying a custom protocol name for
16446 messages that are injected locally by trusted callers. This is commonly used to
16447 identify messages that are being re-injected after some kind of scanning.
16448 </para>
16449 </listitem></varlistentry>
16450 <varlistentry>
16451 <term><varname>$received_time</varname></term>
16452 <listitem>
16453 <para>
16454 <indexterm role="concept">
16455 <primary><varname>$received_time</varname></primary>
16456 </indexterm>
16457 This variable contains the date and time when the current message was received,
16458 as a number of seconds since the start of the Unix epoch.
16459 </para>
16460 </listitem></varlistentry>
16461 <varlistentry>
16462 <term><varname>$recipient_data</varname></term>
16463 <listitem>
16464 <para>
16465 <indexterm role="concept">
16466 <primary><varname>$recipient_data</varname></primary>
16467 </indexterm>
16468 This variable is set after an indexing lookup success in an ACL <option>recipients</option>
16469 condition. It contains the data from the lookup, and the value remains set
16470 until the next <option>recipients</option> test. Thus, you can do things like this:
16471 </para>
16472 <literallayout>
16473 <literal>require recipients  = cdb*@;/some/file</literal>
16474 <literal>deny    </literal><emphasis>some further test involving</emphasis> <literal>$recipient_data</literal>
16475 </literallayout>
16476 <para>
16477 <emphasis role="bold">Warning</emphasis>: This variable is set only when a lookup is used as an indexing
16478 method in the address list, using the semicolon syntax as in the example above.
16479 The variable is not set for a lookup that is used as part of the string
16480 expansion that all such lists undergo before being interpreted.
16481 </para>
16482 </listitem></varlistentry>
16483 <varlistentry>
16484 <term><varname>$recipient_verify_failure</varname></term>
16485 <listitem>
16486 <para>
16487 <indexterm role="concept">
16488 <primary><varname>$recipient_verify_failure</varname></primary>
16489 </indexterm>
16490 In an ACL, when a recipient verification fails, this variable contains
16491 information about the failure. It is set to one of the following words:
16492 </para>
16493 <itemizedlist>
16494 <listitem>
16495 <para>
16496 <quote>qualify</quote>: The address was unqualified (no domain), and the message
16497 was neither local nor came from an exempted host.
16498 </para>
16499 </listitem>
16500 <listitem>
16501 <para>
16502 <quote>route</quote>: Routing failed.
16503 </para>
16504 </listitem>
16505 <listitem>
16506 <para>
16507 <quote>mail</quote>: Routing succeeded, and a callout was attempted; rejection occurred at
16508 or before the MAIL command (that is, on initial connection, HELO, or
16509 MAIL).
16510 </para>
16511 </listitem>
16512 <listitem>
16513 <para>
16514 <quote>recipient</quote>: The RCPT command in a callout was rejected.
16515 </para>
16516 </listitem>
16517 <listitem>
16518 <para>
16519 <quote>postmaster</quote>: The postmaster check in a callout was rejected.
16520 </para>
16521 </listitem>
16522 </itemizedlist>
16523 <para>
16524 The main use of this variable is expected to be to distinguish between
16525 rejections of MAIL and rejections of RCPT.
16526 </para>
16527 </listitem></varlistentry>
16528 <varlistentry>
16529 <term><varname>$recipients</varname></term>
16530 <listitem>
16531 <para>
16532 <indexterm role="concept">
16533 <primary><varname>$recipients</varname></primary>
16534 </indexterm>
16535 This variable contains a list of envelope recipients for a
16536 message. A comma and a space separate the addresses in the replacement text.
16537 However, the variable is not generally available, to prevent exposure of Bcc
16538 recipients in unprivileged users&#x2019; filter files. You can use <varname>$recipients</varname> only
16539 in these two cases:
16540 </para>
16541 <orderedlist numeration="arabic">
16542 <listitem>
16543 <para>
16544 In a system filter file.
16545 </para>
16546 </listitem>
16547 <listitem>
16548 <para>
16549 In the ACLs associated with the DATA command, that is, the ACLs defined by
16550 <option>acl_smtp_predata</option> and <option>acl_smtp_data</option>.
16551 </para>
16552 </listitem>
16553 </orderedlist>
16554 </listitem></varlistentry>
16555 <varlistentry>
16556 <term><varname>$recipients_count</varname></term>
16557 <listitem>
16558 <para>
16559 <indexterm role="concept">
16560 <primary><varname>$recipients_count</varname></primary>
16561 </indexterm>
16562 When a message is being processed, this variable contains the number of
16563 envelope recipients that came with the message. Duplicates are not excluded
16564 from the count. While a message is being received over SMTP, the number
16565 increases for each accepted recipient. It can be referenced in an ACL.
16566 </para>
16567 </listitem></varlistentry>
16568 <varlistentry>
16569 <term><varname>$reply_address</varname></term>
16570 <listitem>
16571 <para>
16572 <indexterm role="concept">
16573 <primary><varname>$reply_address</varname></primary>
16574 </indexterm>
16575 When a message is being processed, this variable contains the contents of the
16576 <emphasis>Reply-To:</emphasis> header line if one exists and it is not empty, or otherwise the
16577 contents of the <emphasis>From:</emphasis> header line. <phrase revisionflag="changed">Apart from the removal of leading
16578 white space, the value is not processed in any way. In particular, no RFC 2047
16579 decoding or character code translation takes place.</phrase>
16580 </para>
16581 </listitem></varlistentry>
16582 <varlistentry>
16583 <term><varname>$return_path</varname></term>
16584 <listitem>
16585 <para>
16586 <indexterm role="concept">
16587 <primary><varname>$return_path</varname></primary>
16588 </indexterm>
16589 When a message is being delivered, this variable contains the return path &ndash;
16590 the sender field that will be sent as part of the envelope. It is not enclosed
16591 in &lt;&gt; characters. At the start of routing an address, <varname>$return_path</varname> has the
16592 same value as <varname>$sender_address</varname>, but if, for example, an incoming message to a
16593 mailing list has been expanded by a router which specifies a different address
16594 for bounce messages, <varname>$return_path</varname> subsequently contains the new bounce
16595 address, whereas <varname>$sender_address</varname> always contains the original sender address
16596 that was received with the message. In other words, <varname>$sender_address</varname> contains
16597 the incoming envelope sender, and <varname>$return_path</varname> contains the outgoing
16598 envelope sender.
16599 </para>
16600 </listitem></varlistentry>
16601 <varlistentry>
16602 <term><varname>$return_size_limit</varname></term>
16603 <listitem>
16604 <para>
16605 <indexterm role="concept">
16606 <primary><varname>$return_size_limit</varname></primary>
16607 </indexterm>
16608 This is an obsolete name for <varname>$bounce_return_size_limit</varname>.
16609 </para>
16610 </listitem></varlistentry>
16611 <varlistentry>
16612 <term><varname>$runrc</varname></term>
16613 <listitem>
16614 <para>
16615 <indexterm role="concept">
16616 <primary>return code</primary>
16617 <secondary>from <option>run</option> expansion</secondary>
16618 </indexterm>
16619 <indexterm role="concept">
16620 <primary><varname>$runrc</varname></primary>
16621 </indexterm>
16622 This variable contains the return code from a command that is run by the
16623 <option>${run...}</option> expansion item. <emphasis role="bold">Warning</emphasis>: In a router or transport, you cannot
16624 assume the order in which option values are expanded, except for those
16625 preconditions whose order of testing is documented. Therefore, you cannot
16626 reliably expect to set <varname>$runrc</varname> by the expansion of one option, and use it in
16627 another.
16628 </para>
16629 </listitem></varlistentry>
16630 <varlistentry>
16631 <term><varname>$self_hostname</varname></term>
16632 <listitem>
16633 <para>
16634 <indexterm role="concept">
16635 <primary><option>self</option> option</primary>
16636 <secondary>value of host name</secondary>
16637 </indexterm>
16638 <indexterm role="concept">
16639 <primary><varname>$self_hostname</varname></primary>
16640 </indexterm>
16641 When an address is routed to a supposedly remote host that turns out to be the
16642 local host, what happens is controlled by the <option>self</option> generic router option.
16643 One of its values causes the address to be passed to another router. When this
16644 happens, <varname>$self_hostname</varname> is set to the name of the local host that the
16645 original router encountered. In other circumstances its contents are null.
16646 </para>
16647 </listitem></varlistentry>
16648 <varlistentry>
16649 <term><varname>$sender_address</varname></term>
16650 <listitem>
16651 <para>
16652 <indexterm role="concept">
16653 <primary><varname>$sender_address</varname></primary>
16654 </indexterm>
16655 When a message is being processed, this variable contains the sender&#x2019;s address
16656 that was received in the message&#x2019;s envelope. For bounce messages, the value of
16657 this variable is the empty string. See also <varname>$return_path</varname>.
16658 </para>
16659 </listitem></varlistentry>
16660 <varlistentry>
16661 <term><varname>$sender_address_data</varname></term>
16662 <listitem>
16663 <para>
16664 <indexterm role="concept">
16665 <primary><varname>$address_data</varname></primary>
16666 </indexterm>
16667 <indexterm role="concept">
16668 <primary><varname>$sender_address_data</varname></primary>
16669 </indexterm>
16670 If <varname>$address_data</varname> is set when the routers are called from an ACL to verify a
16671 sender address, the final value is preserved in <varname>$sender_address_data</varname>, to
16672 distinguish it from data from a recipient address. The value does not persist
16673 after the end of the current ACL statement. If you want to preserve it for
16674 longer, you can save it in an ACL variable.
16675 </para>
16676 </listitem></varlistentry>
16677 <varlistentry>
16678 <term><varname>$sender_address_domain</varname></term>
16679 <listitem>
16680 <para>
16681 <indexterm role="concept">
16682 <primary><varname>$sender_address_domain</varname></primary>
16683 </indexterm>
16684 The domain portion of <varname>$sender_address</varname>.
16685 </para>
16686 </listitem></varlistentry>
16687 <varlistentry>
16688 <term><varname>$sender_address_local_part</varname></term>
16689 <listitem>
16690 <para>
16691 <indexterm role="concept">
16692 <primary><varname>$sender_address_local_part</varname></primary>
16693 </indexterm>
16694 The local part portion of <varname>$sender_address</varname>.
16695 </para>
16696 </listitem></varlistentry>
16697 <varlistentry>
16698 <term><varname>$sender_data</varname></term>
16699 <listitem>
16700 <para>
16701 <indexterm role="concept">
16702 <primary><varname>$sender_data</varname></primary>
16703 </indexterm>
16704 This variable is set after a lookup success in an ACL <option>senders</option> condition or
16705 in a router <option>senders</option> option. It contains the data from the lookup, and the
16706 value remains set until the next <option>senders</option> test. Thus, you can do things like
16707 this:
16708 </para>
16709 <literallayout>
16710 <literal>require senders      = cdb*@;/some/file</literal>
16711 <literal>deny    </literal><emphasis>some further test involving</emphasis> <literal>$sender_data</literal>
16712 </literallayout>
16713 <para>
16714 <emphasis role="bold">Warning</emphasis>: This variable is set only when a lookup is used as an indexing
16715 method in the address list, using the semicolon syntax as in the example above.
16716 The variable is not set for a lookup that is used as part of the string
16717 expansion that all such lists undergo before being interpreted.
16718 </para>
16719 </listitem></varlistentry>
16720 <varlistentry>
16721 <term><varname>$sender_fullhost</varname></term>
16722 <listitem>
16723 <para>
16724 <indexterm role="concept">
16725 <primary><varname>$sender_fullhost</varname></primary>
16726 </indexterm>
16727 When a message is received from a remote host, this variable contains the host
16728 name and IP address in a single string. It ends with the IP address in square
16729 brackets, followed by a colon and a port number if the logging of ports is
16730 enabled. The format of the rest of the string depends on whether the host
16731 issued a HELO or EHLO SMTP command, and whether the host name was verified by
16732 looking up its IP address. (Looking up the IP address can be forced by the
16733 <option>host_lookup</option> option, independent of verification.) A plain host name at the
16734 start of the string is a verified host name; if this is not present,
16735 verification either failed or was not requested. A host name in parentheses is
16736 the argument of a HELO or EHLO command. This is omitted if it is identical to
16737 the verified host name or to the host&#x2019;s IP address in square brackets.
16738 </para>
16739 </listitem></varlistentry>
16740 <varlistentry>
16741 <term><varname>$sender_helo_name</varname></term>
16742 <listitem>
16743 <para>
16744 <indexterm role="concept">
16745 <primary><varname>$sender_hslo_name</varname></primary>
16746 </indexterm>
16747 When a message is received from a remote host that has issued a HELO or EHLO
16748 command, the argument of that command is placed in this variable. It is also
16749 set if HELO or EHLO is used when a message is received using SMTP locally via
16750 the <option>-bs</option> or <option>-bS</option> options.
16751 </para>
16752 </listitem></varlistentry>
16753 <varlistentry>
16754 <term><varname>$sender_host_address</varname></term>
16755 <listitem>
16756 <para>
16757 <indexterm role="concept">
16758 <primary><varname>$sender_host_address</varname></primary>
16759 </indexterm>
16760 When a message is received from a remote host, this variable contains that
16761 host&#x2019;s IP address. For locally submitted messages, it is empty.
16762 </para>
16763 </listitem></varlistentry>
16764 <varlistentry>
16765 <term><varname>$sender_host_authenticated</varname></term>
16766 <listitem>
16767 <para>
16768 <indexterm role="concept">
16769 <primary><varname>$sender_host_authenticated</varname></primary>
16770 </indexterm>
16771 This variable contains the name (not the public name) of the authenticator
16772 driver that successfully authenticated the client from which the message was
16773 received. It is empty if there was no successful authentication. See also
16774 <varname>$authenticated_id</varname>.
16775 </para>
16776 </listitem></varlistentry>
16777 <varlistentry>
16778 <term><varname>$sender_host_name</varname></term>
16779 <listitem>
16780 <para>
16781 <indexterm role="concept">
16782 <primary><varname>$sender_host_name</varname></primary>
16783 </indexterm>
16784 When a message is received from a remote host, this variable contains the
16785 host&#x2019;s name as obtained by looking up its IP address. For messages received by
16786 other means, this variable is empty.
16787 </para>
16788 <para>
16789 <indexterm role="concept">
16790 <primary><varname>$host_lookup_failed</varname></primary>
16791 </indexterm>
16792 If the host name has not previously been looked up, a reference to
16793 <varname>$sender_host_name</varname> triggers a lookup (for messages from remote hosts).
16794 A looked up name is accepted only if it leads back to the original IP address
16795 via a forward lookup. If either the reverse or the forward lookup fails to find
16796 any data, or if the forward lookup does not yield the original IP address,
16797 <varname>$sender_host_name</varname> remains empty, and <varname>$host_lookup_failed</varname> is set to <quote>1</quote>.
16798 </para>
16799 <para>
16800 <indexterm role="concept">
16801 <primary><varname>$host_lookup_deferred</varname></primary>
16802 </indexterm>
16803 However, if either of the lookups cannot be completed (for example, there is a
16804 DNS timeout), <varname>$host_lookup_deferred</varname> is set to <quote>1</quote>, and
16805 <varname>$host_lookup_failed</varname> remains set to <quote>0</quote>.
16806 </para>
16807 <para>
16808 Once <varname>$host_lookup_failed</varname> is set to <quote>1</quote>, Exim does not try to look up the
16809 host name again if there is a subsequent reference to <varname>$sender_host_name</varname>
16810 in the same Exim process, but it does try again if <varname>$sender_host_deferred</varname>
16811 is set to <quote>1</quote>.
16812 </para>
16813 <para>
16814 Exim does not automatically look up every calling host&#x2019;s name. If you want
16815 maximum efficiency, you should arrange your configuration so that it avoids
16816 these lookups altogether. The lookup happens only if one or more of the
16817 following are true:
16818 </para>
16819 <itemizedlist>
16820 <listitem>
16821 <para>
16822 A string containing <varname>$sender_host_name</varname> is expanded.
16823 </para>
16824 </listitem>
16825 <listitem>
16826 <para>
16827 The calling host matches the list in <option>host_lookup</option>. In the default
16828 configuration, this option is set to *, so it must be changed if lookups are
16829 to be avoided. (In the code, the default for <option>host_lookup</option> is unset.)
16830 </para>
16831 </listitem>
16832 <listitem>
16833 <para>
16834 Exim needs the host name in order to test an item in a host list. The items
16835 that require this are described in sections <xref linkend="SECThoslispatnam"/> and
16836 <xref linkend="SECThoslispatnamsk"/>.
16837 </para>
16838 </listitem>
16839 <listitem>
16840 <para>
16841 The calling host matches <option>helo_try_verify_hosts</option> or <option>helo_verify_hosts</option>.
16842 In this case, the host name is required to compare with the name quoted in any
16843 EHLO or HELO commands that the client issues.
16844 </para>
16845 </listitem>
16846 <listitem>
16847 <para>
16848 The remote host issues a EHLO or HELO command that quotes one of the
16849 domains in <option>helo_lookup_domains</option>. The default value of this option is
16850 </para>
16851 <literallayout class="monospaced">
16852   helo_lookup_domains = @ : @[]
16853 </literallayout>
16854 <para>
16855 which causes a lookup if a remote host (incorrectly) gives the server&#x2019;s name or
16856 IP address in an EHLO or HELO command.
16857 </para>
16858 </listitem>
16859 </itemizedlist>
16860 </listitem></varlistentry>
16861 <varlistentry>
16862 <term><varname>$sender_host_port</varname></term>
16863 <listitem>
16864 <para>
16865 <indexterm role="concept">
16866 <primary><varname>$sender_host_port</varname></primary>
16867 </indexterm>
16868 When a message is received from a remote host, this variable contains the port
16869 number that was used on the remote host.
16870 </para>
16871 </listitem></varlistentry>
16872 <varlistentry>
16873 <term><varname>$sender_ident</varname></term>
16874 <listitem>
16875 <para>
16876 <indexterm role="concept">
16877 <primary><varname>$sender_ident</varname></primary>
16878 </indexterm>
16879 When a message is received from a remote host, this variable contains the
16880 identification received in response to an RFC 1413 request. When a message has
16881 been received locally, this variable contains the login name of the user that
16882 called Exim.
16883 </para>
16884 </listitem></varlistentry>
16885 <varlistentry>
16886 <term><varname>$sender_rate_</varname><emphasis>xxx</emphasis></term>
16887 <listitem>
16888 <para>
16889 A number of variables whose names begin <varname>$sender_rate_</varname> are set as part of the
16890 <option>ratelimit</option> ACL condition. Details are given in section
16891 <xref linkend="SECTratelimiting"/>.
16892 </para>
16893 </listitem></varlistentry>
16894 <varlistentry>
16895 <term><varname>$sender_rcvhost</varname></term>
16896 <listitem>
16897 <para>
16898 <indexterm role="concept">
16899 <primary>DNS</primary>
16900 <secondary>reverse lookup</secondary>
16901 </indexterm>
16902 <indexterm role="concept">
16903 <primary>reverse DNS lookup</primary>
16904 </indexterm>
16905 <indexterm role="concept">
16906 <primary><varname>$sender_rcvhost</varname></primary>
16907 </indexterm>
16908 This is provided specifically for use in <emphasis>Received:</emphasis> headers. It starts with
16909 either the verified host name (as obtained from a reverse DNS lookup) or, if
16910 there is no verified host name, the IP address in square brackets. After that
16911 there may be text in parentheses. When the first item is a verified host name,
16912 the first thing in the parentheses is the IP address in square brackets,
16913 followed by a colon and a port number if port logging is enabled. When the
16914 first item is an IP address, the port is recorded as <quote>port=<emphasis>xxxx</emphasis></quote> inside
16915 the parentheses.
16916 </para>
16917 <para>
16918 There may also be items of the form <quote>helo=<emphasis>xxxx</emphasis></quote> if HELO or EHLO
16919 was used and its argument was not identical to the real host name or IP
16920 address, and <quote>ident=<emphasis>xxxx</emphasis></quote> if an RFC 1413 ident string is available. If
16921 all three items are present in the parentheses, a newline and tab are inserted
16922 into the string, to improve the formatting of the <emphasis>Received:</emphasis> header.
16923 </para>
16924 </listitem></varlistentry>
16925 <varlistentry>
16926 <term><varname>$sender_verify_failure</varname></term>
16927 <listitem>
16928 <para>
16929 <indexterm role="concept">
16930 <primary><varname>$sender_verify_failure</varname></primary>
16931 </indexterm>
16932 In an ACL, when a sender verification fails, this variable contains information
16933 about the failure. The details are the same as for
16934 <varname>$recipient_verify_failure</varname>.
16935 </para>
16936 </listitem></varlistentry>
16937 <varlistentry>
16938 <term><varname>$smtp_active_hostname</varname></term>
16939 <listitem>
16940 <para>
16941 <indexterm role="concept">
16942 <primary><varname>$smtp_active_hostname</varname></primary>
16943 </indexterm>
16944 During an SMTP session, this variable contains the value of the active host
16945 name, as specified by the <option>smtp_active_hostname</option> option. The value of
16946 <varname>$smtp_active_hostname</varname> is saved with any message that is received, so its
16947 value can be consulted during routing and delivery.
16948 </para>
16949 </listitem></varlistentry>
16950 <varlistentry>
16951 <term><varname>$smtp_command</varname></term>
16952 <listitem>
16953 <para>
16954 <indexterm role="concept">
16955 <primary><varname>$smtp_command</varname></primary>
16956 </indexterm>
16957 During the processing of an incoming SMTP command, this variable contains the
16958 entire command. This makes it possible to distinguish between HELO and EHLO in
16959 the HELO ACL, and also to distinguish between commands such as these:
16960 </para>
16961 <literallayout class="monospaced">
16962 MAIL FROM:&lt;&gt;
16963 MAIL FROM: &lt;&gt;
16964 </literallayout>
16965 <para>
16966 For a MAIL command, extra parameters such as SIZE can be inspected. For a RCPT
16967 command, the address in <varname>$smtp_command</varname> is the original address before any
16968 rewriting, whereas the values in <varname>$local_part</varname> and <varname>$domain</varname> are taken from
16969 the address after SMTP-time rewriting.
16970 </para>
16971 </listitem></varlistentry>
16972 <varlistentry>
16973 <term><varname>$smtp_command_argument</varname></term>
16974 <listitem>
16975 <para>
16976 <indexterm role="concept">
16977 <primary>SMTP command</primary>
16978 <secondary>argument for</secondary>
16979 </indexterm>
16980 <indexterm role="concept">
16981 <primary><varname>$smtp_command_argument</varname></primary>
16982 </indexterm>
16983 While an ACL is running to check an SMTP command, this variable contains the
16984 argument, that is, the text that follows the command name, with leading white
16985 space removed. Following the introduction of <varname>$smtp_command</varname>, this variable is
16986 somewhat redundant, but is retained for backwards compatibility.
16987 </para>
16988 </listitem></varlistentry>
16989 <varlistentry>
16990 <term><varname>$sn0</varname> &ndash; <varname>$sn9</varname></term>
16991 <listitem>
16992 <para>
16993 These variables are copies of the values of the <varname>$n0</varname> &ndash; <varname>$n9</varname> accumulators
16994 that were current at the end of the system filter file. This allows a system
16995 filter file to set values that can be tested in users&#x2019; filter files. For
16996 example, a system filter could set a value indicating how likely it is that a
16997 message is junk mail.
16998 </para>
16999 </listitem></varlistentry>
17000 <varlistentry>
17001 <term><varname>$spam_</varname><emphasis>xxx</emphasis></term>
17002 <listitem>
17003 <para>
17004 A number of variables whose names start with <varname>$spam</varname> are available when Exim
17005 is compiled with the content-scanning extension. For details, see section
17006 <xref linkend="SECTscanspamass"/>.
17007 </para>
17008 </listitem></varlistentry>
17009 <varlistentry>
17010 <term><varname>$spool_directory</varname></term>
17011 <listitem>
17012 <para>
17013 <indexterm role="concept">
17014 <primary><varname>$spool_directory</varname></primary>
17015 </indexterm>
17016 The name of Exim&#x2019;s spool directory.
17017 </para>
17018 </listitem></varlistentry>
17019 <varlistentry>
17020 <term><varname>$spool_inodes</varname></term>
17021 <listitem>
17022 <para>
17023 <indexterm role="concept">
17024 <primary><varname>$spool_inodes</varname></primary>
17025 </indexterm>
17026 The number of free inodes in the disk partition where Exim&#x2019;s spool files are
17027 being written. The value is recalculated whenever the variable is referenced.
17028 If the relevant file system does not have the concept of inodes, the value of
17029 is -1. See also the <option>check_spool_inodes</option> option.
17030 </para>
17031 </listitem></varlistentry>
17032 <varlistentry>
17033 <term><varname>$spool_space</varname></term>
17034 <listitem>
17035 <para>
17036 <indexterm role="concept">
17037 <primary><varname>$spool_space</varname></primary>
17038 </indexterm>
17039 The amount of free space (as a number of kilobytes) in the disk partition where
17040 Exim&#x2019;s spool files are being written. The value is recalculated whenever the
17041 variable is referenced. If the operating system does not have the ability to
17042 find the amount of free space (only true for experimental systems), the space
17043 value is -1. For example, to check in an ACL that there is at least 50
17044 megabytes free on the spool, you could write:
17045 </para>
17046 <literallayout class="monospaced">
17047 condition = ${if &gt; {$spool_space}{50000}}
17048 </literallayout>
17049 <para>
17050 See also the <option>check_spool_space</option> option.
17051 </para>
17052 </listitem></varlistentry>
17053 <varlistentry>
17054 <term><varname>$thisaddress</varname></term>
17055 <listitem>
17056 <para>
17057 <indexterm role="concept">
17058 <primary><varname>$thisaddress</varname></primary>
17059 </indexterm>
17060 This variable is set only during the processing of the <option>foranyaddress</option>
17061 command in a filter file. Its use is explained in the description of that
17062 command, which can be found in the separate document entitled <emphasis>Exim&#x2019;s
17063 interfaces to mail filtering</emphasis>.
17064 </para>
17065 </listitem></varlistentry>
17066 <varlistentry>
17067 <term><varname>$tls_certificate_verified</varname></term>
17068 <listitem>
17069 <para>
17070 <indexterm role="concept">
17071 <primary><varname>$tls_certificate_verified</varname></primary>
17072 </indexterm>
17073 This variable is set to <quote>1</quote> if a TLS certificate was verified when the
17074 message was received, and <quote>0</quote> otherwise.
17075 </para>
17076 </listitem></varlistentry>
17077 <varlistentry>
17078 <term><varname>$tls_cipher</varname></term>
17079 <listitem>
17080 <para>
17081 <indexterm role="concept">
17082 <primary><varname>$tls_cipher</varname></primary>
17083 </indexterm>
17084 When a message is received from a remote host over an encrypted SMTP
17085 connection, this variable is set to the cipher suite that was negotiated, for
17086 example DES-CBC3-SHA. In other circumstances, in particular, for message
17087 received over unencrypted connections, the variable is empty. See chapter
17088 <xref linkend="CHAPTLS"/> for details of TLS support.
17089 </para>
17090 </listitem></varlistentry>
17091 <varlistentry>
17092 <term><varname>$tls_peerdn</varname></term>
17093 <listitem>
17094 <para>
17095 <indexterm role="concept">
17096 <primary><varname>$tls_peerdn</varname></primary>
17097 </indexterm>
17098 When a message is received from a remote host over an encrypted SMTP
17099 connection, and Exim is configured to request a certificate from the client,
17100 the value of the Distinguished Name of the certificate is made available in the
17101 <varname>$tls_peerdn</varname> during subsequent processing.
17102 </para>
17103 </listitem></varlistentry>
17104 <varlistentry>
17105 <term><varname>$tod_bsdinbox</varname></term>
17106 <listitem>
17107 <para>
17108 <indexterm role="concept">
17109 <primary><varname>$tod_bsdinbox</varname></primary>
17110 </indexterm>
17111 The time of day and the date, in the format required for BSD-style mailbox
17112 files, for example: Thu Oct 17 17:14:09 1995.
17113 </para>
17114 </listitem></varlistentry>
17115 <varlistentry>
17116 <term><varname>$tod_epoch</varname></term>
17117 <listitem>
17118 <para>
17119 <indexterm role="concept">
17120 <primary><varname>$tod_epoch</varname></primary>
17121 </indexterm>
17122 The time and date as a number of seconds since the start of the Unix epoch.
17123 </para>
17124 </listitem></varlistentry>
17125 <varlistentry>
17126 <term><varname>$tod_full</varname></term>
17127 <listitem>
17128 <para>
17129 <indexterm role="concept">
17130 <primary><varname>$tod_full</varname></primary>
17131 </indexterm>
17132 A full version of the time and date, for example: Wed, 16 Oct 1995 09:51:40
17133 +0100. The timezone is always given as a numerical offset from UTC, with
17134 positive values used for timezones that are ahead (east) of UTC, and negative
17135 values for those that are behind (west).
17136 </para>
17137 </listitem></varlistentry>
17138 <varlistentry>
17139 <term><varname>$tod_log</varname></term>
17140 <listitem>
17141 <para>
17142 <indexterm role="concept">
17143 <primary><varname>$tod_log</varname></primary>
17144 </indexterm>
17145 The time and date in the format used for writing Exim&#x2019;s log files, for example:
17146 1995-10-12 15:32:29, but without a timezone.
17147 </para>
17148 </listitem></varlistentry>
17149 <varlistentry>
17150 <term><varname>$tod_logfile</varname></term>
17151 <listitem>
17152 <para>
17153 <indexterm role="concept">
17154 <primary><varname>$tod_logfile</varname></primary>
17155 </indexterm>
17156 This variable contains the date in the format yyyymmdd. This is the format that
17157 is used for datestamping log files when <option>log_file_path</option> contains the <literal>%D</literal>
17158 flag.
17159 </para>
17160 </listitem></varlistentry>
17161 <varlistentry>
17162 <term><varname>$tod_zone</varname></term>
17163 <listitem>
17164 <para>
17165 <indexterm role="concept">
17166 <primary><varname>$tod_zone</varname></primary>
17167 </indexterm>
17168 This variable contains the numerical value of the local timezone, for example:
17169 -0500.
17170 </para>
17171 </listitem></varlistentry>
17172 <varlistentry>
17173 <term><varname>$tod_zulu</varname></term>
17174 <listitem>
17175 <para>
17176 <indexterm role="concept">
17177 <primary><varname>$tod_zulu</varname></primary>
17178 </indexterm>
17179 This variable contains the UTC date and time in <quote>Zulu</quote> format, as specified
17180 by ISO 8601, for example: 20030221154023Z.
17181 </para>
17182 </listitem></varlistentry>
17183 <varlistentry>
17184 <term><varname>$value</varname></term>
17185 <listitem>
17186 <para>
17187 <indexterm role="concept">
17188 <primary><varname>$value</varname></primary>
17189 </indexterm>
17190 This variable contains the result of an expansion lookup, extraction operation,
17191 or external command, as described above.
17192 </para>
17193 </listitem></varlistentry>
17194 <varlistentry>
17195 <term><varname>$version_number</varname></term>
17196 <listitem>
17197 <para>
17198 <indexterm role="concept">
17199 <primary><varname>$version_number</varname></primary>
17200 </indexterm>
17201 The version number of Exim.
17202 </para>
17203 </listitem></varlistentry>
17204 <varlistentry>
17205 <term><varname>$warn_message_delay</varname></term>
17206 <listitem>
17207 <para>
17208 <indexterm role="concept">
17209 <primary><varname>$warn_message_delay</varname></primary>
17210 </indexterm>
17211 This variable is set only during the creation of a message warning about a
17212 delivery delay. Details of its use are explained in section <xref linkend="SECTcustwarn"/>.
17213 </para>
17214 </listitem></varlistentry>
17215 <varlistentry>
17216 <term><varname>$warn_message_recipients</varname></term>
17217 <listitem>
17218 <para>
17219 <indexterm role="concept">
17220 <primary><varname>$warn_message_recipients</varname></primary>
17221 </indexterm>
17222 This variable is set only during the creation of a message warning about a
17223 delivery delay. Details of its use are explained in section <xref linkend="SECTcustwarn"/>.
17224 </para>
17225 </listitem></varlistentry>
17226 </variablelist>
17227 <para>
17228 <indexterm role="concept" startref="IIDstrexp" class="endofrange"/>
17229 </para>
17230 </section>
17231 </chapter>
17232
17233 <chapter id="CHAPperl">
17234 <title>Embedded Perl</title>
17235 <para>
17236 <indexterm role="concept" id="IIDperl" class="startofrange">
17237 <primary>Perl</primary>
17238 <secondary>calling from Exim</secondary>
17239 </indexterm>
17240 Exim can be built to include an embedded Perl interpreter. When this is done,
17241 Perl subroutines can be called as part of the string expansion process. To make
17242 use of the Perl support, you need version 5.004 or later of Perl installed on
17243 your system. To include the embedded interpreter in the Exim binary, include
17244 the line
17245 </para>
17246 <literallayout class="monospaced">
17247 EXIM_PERL = perl.o
17248 </literallayout>
17249 <para>
17250 in your <filename>Local/Makefile</filename> and then build Exim in the normal way.
17251 </para>
17252 <section>
17253 <title>Setting up so Perl can be used</title>
17254 <para>
17255 <indexterm role="concept">
17256 <primary><option>perl_startup</option></primary>
17257 </indexterm>
17258 Access to Perl subroutines is via a global configuration option called
17259 <option>perl_startup</option> and an expansion string operator <option>${perl ...}</option>. If there is
17260 no <option>perl_startup</option> option in the Exim configuration file then no Perl
17261 interpreter is started and there is almost no overhead for Exim (since none of
17262 the Perl library will be paged in unless used). If there is a <option>perl_startup</option>
17263 option then the associated value is taken to be Perl code which is executed in
17264 a newly created Perl interpreter.
17265 </para>
17266 <para>
17267 The value of <option>perl_startup</option> is not expanded in the Exim sense, so you do not
17268 need backslashes before any characters to escape special meanings. The option
17269 should usually be something like
17270 </para>
17271 <literallayout class="monospaced">
17272 perl_startup = do '/etc/exim.pl'
17273 </literallayout>
17274 <para>
17275 where <filename>/etc/exim.pl</filename> is Perl code which defines any subroutines you want to
17276 use from Exim. Exim can be configured either to start up a Perl interpreter as
17277 soon as it is entered, or to wait until the first time it is needed. Starting
17278 the interpreter at the beginning ensures that it is done while Exim still has
17279 its setuid privilege, but can impose an unnecessary overhead if Perl is not in
17280 fact used in a particular run. Also, note that this does not mean that Exim is
17281 necessarily running as root when Perl is called at a later time. By default,
17282 the interpreter is started only when it is needed, but this can be changed in
17283 two ways:
17284 </para>
17285 <itemizedlist>
17286 <listitem>
17287 <para>
17288 <indexterm role="concept">
17289 <primary><option>perl_at_start</option></primary>
17290 </indexterm>
17291 Setting <option>perl_at_start</option> (a boolean option) in the configuration requests
17292 a startup when Exim is entered.
17293 </para>
17294 </listitem>
17295 <listitem>
17296 <para>
17297 The command line option <option>-ps</option> also requests a startup when Exim is entered,
17298 overriding the setting of <option>perl_at_start</option>.
17299 </para>
17300 </listitem>
17301 </itemizedlist>
17302 <para>
17303 There is also a command line option <option>-pd</option> (for delay) which suppresses the
17304 initial startup, even if <option>perl_at_start</option> is set.
17305 </para>
17306 </section>
17307 <section>
17308 <title>Calling Perl subroutines</title>
17309 <para>
17310 When the configuration file includes a <option>perl_startup</option> option you can make use
17311 of the string expansion item to call the Perl subroutines that are defined
17312 by the <option>perl_startup</option> code. The operator is used in any of the following
17313 forms:
17314 </para>
17315 <literallayout class="monospaced">
17316 ${perl{foo}}
17317 ${perl{foo}{argument}}
17318 ${perl{foo}{argument1}{argument2} ... }
17319 </literallayout>
17320 <para>
17321 which calls the subroutine <option>foo</option> with the given arguments. A maximum of eight
17322 arguments may be passed. Passing more than this results in an expansion failure
17323 with an error message of the form
17324 </para>
17325 <literallayout class="monospaced">
17326 Too many arguments passed to Perl subroutine "foo" (max is 8)
17327 </literallayout>
17328 <para>
17329 The return value of the Perl subroutine is evaluated in a scalar context before
17330 it is passed back to Exim to be inserted into the expanded string. If the
17331 return value is <emphasis>undef</emphasis>, the expansion is forced to fail in the same way as
17332 an explicit <quote>fail</quote> on an <option>if</option> or <option>lookup</option> item. If the subroutine aborts
17333 by obeying Perl&#x2019;s <option>die</option> function, the expansion fails with the error message
17334 that was passed to <option>die</option>.
17335 </para>
17336 </section>
17337 <section>
17338 <title>Calling Exim functions from Perl</title>
17339 <para>
17340 Within any Perl code called from Exim, the function <emphasis>Exim::expand_string()</emphasis>
17341 is available to call back into Exim&#x2019;s string expansion function. For example,
17342 the Perl code
17343 </para>
17344 <literallayout class="monospaced">
17345 my $lp = Exim::expand_string('$local_part');
17346 </literallayout>
17347 <para>
17348 makes the current Exim <varname>$local_part</varname> available in the Perl variable <varname>$lp</varname>.
17349 Note those are single quotes and not double quotes to protect against
17350 <varname>$local_part</varname> being interpolated as a Perl variable.
17351 </para>
17352 <para>
17353 If the string expansion is forced to fail by a <quote>fail</quote> item, the result of
17354 <emphasis>Exim::expand_string()</emphasis> is <option>undef</option>. If there is a syntax error in the
17355 expansion string, the Perl call from the original expansion string fails with
17356 an appropriate error message, in the same way as if <option>die</option> were used.
17357 </para>
17358 <para>
17359 <indexterm role="concept">
17360 <primary>debugging</primary>
17361 <secondary>from embedded Perl</secondary>
17362 </indexterm>
17363 <indexterm role="concept">
17364 <primary>log</primary>
17365 <secondary>writing from embedded Perl</secondary>
17366 </indexterm>
17367 Two other Exim functions are available for use from within Perl code.
17368 <emphasis>Exim::debug_write()</emphasis> writes a string to the standard error stream if Exim&#x2019;s
17369 debugging is enabled. If you want a newline at the end, you must supply it.
17370 <emphasis>Exim::log_write()</emphasis> writes a string to Exim&#x2019;s main log, adding a leading
17371 timestamp. In this case, you should not supply a terminating newline.
17372 </para>
17373 </section>
17374 <section>
17375 <title>Use of standard output and error by Perl</title>
17376 <para>
17377 <indexterm role="concept">
17378 <primary>Perl</primary>
17379 <secondary>standard output and error</secondary>
17380 </indexterm>
17381 You should not write to the standard error or output streams from within your
17382 Perl code, as it is not defined how these are set up. In versions of Exim
17383 before 4.50, it is possible for the standard output or error to refer to the
17384 SMTP connection during message reception via the daemon. Writing to this stream
17385 is certain to cause chaos. From Exim 4.50 onwards, the standard output and
17386 error streams are connected to <filename>/dev/null</filename> in the daemon. The chaos is
17387 avoided, but the output is lost.
17388 </para>
17389 <para>
17390 <indexterm role="concept">
17391 <primary>Perl</primary>
17392 <secondary>use of <option>warn</option></secondary>
17393 </indexterm>
17394 The Perl <option>warn</option> statement writes to the standard error stream by default.
17395 Calls to <option>warn</option> may be embedded in Perl modules that you use, but over which
17396 you have no control. When Exim starts up the Perl interpreter, it arranges for
17397 output from the <option>warn</option> statement to be written to the Exim main log. You can
17398 change this by including appropriate Perl magic somewhere in your Perl code.
17399 For example, to discard <option>warn</option> output completely, you need this:
17400 </para>
17401 <literallayout class="monospaced">
17402 $SIG{__WARN__} = sub { };
17403 </literallayout>
17404 <para>
17405 Whenever a <option>warn</option> is obeyed, the anonymous subroutine is called. In this
17406 example, the code for the subroutine is empty, so it does nothing, but you can
17407 include any Perl code that you like. The text of the <option>warn</option> message is passed
17408 as the first subroutine argument.
17409 <indexterm role="concept" startref="IIDperl" class="endofrange"/>
17410 </para>
17411 </section>
17412 </chapter>
17413
17414 <chapter id="CHAPinterfaces">
17415 <title>Starting the daemon and the use of network interfaces</title>
17416 <titleabbrev>Starting the daemon</titleabbrev>
17417 <para>
17418 <indexterm role="concept">
17419 <primary>daemon</primary>
17420 <secondary>starting</secondary>
17421 </indexterm>
17422 <indexterm role="concept">
17423 <primary>interface</primary>
17424 <secondary>listening</secondary>
17425 </indexterm>
17426 <indexterm role="concept">
17427 <primary>network interface</primary>
17428 </indexterm>
17429 <indexterm role="concept">
17430 <primary>interface</primary>
17431 <secondary>network</secondary>
17432 </indexterm>
17433 <indexterm role="concept">
17434 <primary>IP address</primary>
17435 <secondary>for listening</secondary>
17436 </indexterm>
17437 <indexterm role="concept">
17438 <primary>daemon</primary>
17439 <secondary>listening IP addresses</secondary>
17440 </indexterm>
17441 <indexterm role="concept">
17442 <primary>TCP/IP</primary>
17443 <secondary>setting listening interfaces</secondary>
17444 </indexterm>
17445 <indexterm role="concept">
17446 <primary>TCP/IP</primary>
17447 <secondary>setting listening ports</secondary>
17448 </indexterm>
17449 A host that is connected to a TCP/IP network may have one or more physical
17450 hardware network interfaces. Each of these interfaces may be configured as one
17451 or more <quote>logical</quote> interfaces, which are the entities that a program actually
17452 works with. Each of these logical interfaces is associated with an IP address.
17453 In addition, TCP/IP software supports <quote>loopback</quote> interfaces (127.0.0.1 in
17454 IPv4 and ::1 in IPv6), which do not use any physical hardware. Exim requires
17455 knowledge about the host&#x2019;s interfaces for use in three different circumstances:
17456 </para>
17457 <orderedlist numeration="arabic">
17458 <listitem>
17459 <para>
17460 When a listening daemon is started, Exim needs to know which interfaces
17461 and ports to listen on.
17462 </para>
17463 </listitem>
17464 <listitem>
17465 <para>
17466 When Exim is routing an address, it needs to know which IP addresses
17467 are associated with local interfaces. This is required for the correct
17468 processing of MX lists by removing the local host and others with the
17469 same or higher priority values. Also, Exim needs to detect cases
17470 when an address is routed to an IP address that in fact belongs to the
17471 local host. Unless the <option>self</option> router option or the <option>allow_localhost</option>
17472 option of the smtp transport is set (as appropriate), this is treated
17473 as an error situation.
17474 </para>
17475 </listitem>
17476 <listitem>
17477 <para>
17478 When Exim connects to a remote host, it may need to know which interface to use
17479 for the outgoing connection.
17480 </para>
17481 </listitem>
17482 </orderedlist>
17483 <para>
17484 Exim&#x2019;s default behaviour is likely to be appropriate in the vast majority
17485 of cases. If your host has only one interface, and you want all its IP
17486 addresses to be treated in the same way, and you are using only the
17487 standard SMTP port, you should not need to take any special action. The
17488 rest of this chapter does not apply to you.
17489 </para>
17490 <para>
17491 In a more complicated situation you may want to listen only on certain
17492 interfaces, or on different ports, and for this reason there are a number of
17493 options that can be used to influence Exim&#x2019;s behaviour. The rest of this
17494 chapter describes how they operate.
17495 </para>
17496 <para>
17497 When a message is received over TCP/IP, the interface and port that were
17498 actually used are set in <varname>$interface_address</varname> and <varname>$interface_port</varname>.
17499 </para>
17500 <section>
17501 <title>Starting a listening daemon</title>
17502 <para>
17503 When a listening daemon is started (by means of the <option>-bd</option> command line
17504 option), the interfaces and ports on which it listens are controlled by the
17505 following options:
17506 </para>
17507 <itemizedlist>
17508 <listitem>
17509 <para>
17510 <option>daemon_smtp_ports</option> contains a list of default ports. (For backward
17511 compatibility, this option can also be specified in the singular.)
17512 </para>
17513 </listitem>
17514 <listitem>
17515 <para>
17516 <option>local_interfaces</option> contains list of interface IP addresses on which to
17517 listen. Each item may optionally also specify a port.
17518 </para>
17519 </listitem>
17520 </itemizedlist>
17521 <para>
17522 The default list separator in both cases is a colon, but this can be changed as
17523 described in section <xref linkend="SECTlistconstruct"/>. When IPv6 addresses are involved,
17524 it is usually best to change the separator to avoid having to double all the
17525 colons. For example:
17526 </para>
17527 <literallayout class="monospaced">
17528 local_interfaces = &lt;; 127.0.0.1 ; \
17529                       192.168.23.65 ; \
17530                       ::1 ; \
17531                       3ffe:ffff:836f::fe86:a061
17532 </literallayout>
17533 <para>
17534 There are two different formats for specifying a port along with an IP address
17535 in <option>local_interfaces</option>:
17536 </para>
17537 <orderedlist numeration="arabic">
17538 <listitem>
17539 <para>
17540 The port is added onto the address with a dot separator. For example, to listen
17541 on port 1234 on two different IP addresses:
17542 </para>
17543 <literallayout class="monospaced">
17544 local_interfaces = &lt;; 192.168.23.65.1234 ; \
17545                       3ffe:ffff:836f::fe86:a061.1234
17546 </literallayout>
17547 </listitem>
17548 <listitem>
17549 <para>
17550 The IP address is enclosed in square brackets, and the port is added
17551 with a colon separator, for example:
17552 </para>
17553 <literallayout class="monospaced">
17554 local_interfaces = &lt;; [192.168.23.65]:1234 ; \
17555                       [3ffe:ffff:836f::fe86:a061]:1234
17556 </literallayout>
17557 </listitem>
17558 </orderedlist>
17559 <para>
17560 When a port is not specified, the value of <option>daemon_smtp_ports</option> is used. The
17561 default setting contains just one port:
17562 </para>
17563 <literallayout class="monospaced">
17564 daemon_smtp_ports = smtp
17565 </literallayout>
17566 <para>
17567 If more than one port is listed, each interface that does not have its own port
17568 specified listens on all of them. Ports that are listed in
17569 <option>daemon_smtp_ports</option> can be identified either by name (defined in
17570 <filename>/etc/services</filename>) or by number. However, when ports are given with individual
17571 IP addresses in <option>local_interfaces</option>, only numbers (not names) can be used.
17572 </para>
17573 </section>
17574 <section>
17575 <title>Special IP listening addresses</title>
17576 <para>
17577 The addresses 0.0.0.0 and ::0 are treated specially. They are interpreted
17578 as <quote>all IPv4 interfaces</quote> and <quote>all IPv6 interfaces</quote>, respectively. In each
17579 case, Exim tells the TCP/IP stack to <quote>listen on all IPv<emphasis>x</emphasis> interfaces</quote>
17580 instead of setting up separate listening sockets for each interface. The
17581 default value of <option>local_interfaces</option> is
17582 </para>
17583 <literallayout class="monospaced">
17584 local_interfaces = 0.0.0.0
17585 </literallayout>
17586 <para>
17587 when Exim is built without IPv6 support; otherwise it is:
17588 </para>
17589 <literallayout class="monospaced">
17590 local_interfaces = &lt;; ::0 ; 0.0.0.0
17591 </literallayout>
17592 <para>
17593 Thus, by default, Exim listens on all available interfaces, on the SMTP port.
17594 </para>
17595 </section>
17596 <section>
17597 <title>Overriding local_interfaces and daemon_smtp_ports</title>
17598 <para>
17599 The <option>-oX</option> command line option can be used to override the values of
17600 <option>daemon_smtp_ports</option> and/or <option>local_interfaces</option> for a particular daemon
17601 instance. Another way of doing this would be to use macros and the <option>-D</option>
17602 option. However, <option>-oX</option> can be used by any admin user, whereas modification of
17603 the runtime configuration by <option>-D</option> is allowed only when the caller is root or
17604 exim.
17605 </para>
17606 <para>
17607 The value of <option>-oX</option> is a list of items. The default colon separator can be
17608 changed in the usual way if required. If there are any items that do not
17609 contain dots or colons (that is, are not IP addresses), the value of
17610 <option>daemon_smtp_ports</option> is replaced by the list of those items. If there are any
17611 items that do contain dots or colons, the value of <option>local_interfaces</option> is
17612 replaced by those items. Thus, for example,
17613 </para>
17614 <literallayout class="monospaced">
17615 -oX 1225
17616 </literallayout>
17617 <para>
17618 overrides <option>daemon_smtp_ports</option>, but leaves <option>local_interfaces</option> unchanged,
17619 whereas
17620 </para>
17621 <literallayout class="monospaced">
17622 -oX 192.168.34.5.1125
17623 </literallayout>
17624 <para>
17625 overrides <option>local_interfaces</option>, leaving <option>daemon_smtp_ports</option> unchanged.
17626 (However, since <option>local_interfaces</option> now contains no items without ports, the
17627 value of <option>daemon_smtp_ports</option> is no longer relevant in this example.)
17628 </para>
17629 </section>
17630 <section id="SECTsupobssmt">
17631 <title>Support for the obsolete SSMTP (or SMTPS) protocol</title>
17632 <para>
17633 <indexterm role="concept">
17634 <primary>ssmtp protocol</primary>
17635 </indexterm>
17636 <indexterm role="concept">
17637 <primary>smtps protocol</primary>
17638 </indexterm>
17639 <indexterm role="concept">
17640 <primary>SMTP</primary>
17641 <secondary>ssmtp protocol</secondary>
17642 </indexterm>
17643 <indexterm role="concept">
17644 <primary>SMTP</primary>
17645 <secondary>smtps protocol</secondary>
17646 </indexterm>
17647 Exim supports the obsolete SSMTP protocol (also known as SMTPS) that was used
17648 before the STARTTLS command was standardized for SMTP. Some legacy clients
17649 still use this protocol. If the <option>tls_on_connect_ports</option> option is set to a
17650 list of port numbers, connections to those ports must use SSMTP. The most
17651 common use of this option is expected to be
17652 </para>
17653 <literallayout class="monospaced">
17654 tls_on_connect_ports = 465
17655 </literallayout>
17656 <para>
17657 because 465 is the usual port number used by the legacy clients. There is also
17658 a command line option <option>-tls-on-connect</option>, which forces all ports to behave in
17659 this way when a daemon is started.
17660 </para>
17661 <para>
17662 <emphasis role="bold">Warning</emphasis>: Setting <option>tls_on_connect_ports</option> does not of itself cause the
17663 daemon to listen on those ports. You must still specify them in
17664 <option>daemon_smtp_ports</option>, <option>local_interfaces</option>, or the <option>-oX</option> option. (This is
17665 because <option>tls_on_connect_ports</option> applies to <option>inetd</option> connections as well as to
17666 connections via the daemon.)
17667 </para>
17668 </section>
17669 <section>
17670 <title>IPv6 address scopes</title>
17671 <para>
17672 <indexterm role="concept">
17673 <primary>IPv6</primary>
17674 <secondary>address scopes</secondary>
17675 </indexterm>
17676 IPv6 addresses have <quote>scopes</quote>, and a host with multiple hardware interfaces
17677 can, in principle, have the same link-local IPv6 address on different
17678 interfaces. Thus, additional information is needed, over and above the IP
17679 address, to distinguish individual interfaces. A convention of using a
17680 percent sign followed by something (often the interface name) has been
17681 adopted in some cases, leading to addresses like this:
17682 </para>
17683 <literallayout class="monospaced">
17684 fe80::202:b3ff:fe03:45c1%eth0
17685 </literallayout>
17686 <para>
17687 To accommodate this usage, a percent sign followed by an arbitrary string is
17688 allowed at the end of an IPv6 address. By default, Exim calls <function>getaddrinfo()</function>
17689 to convert a textual IPv6 address for actual use. This function recognizes the
17690 percent convention in operating systems that support it, and it processes the
17691 address appropriately. Unfortunately, some older libraries have problems with
17692 <function>getaddrinfo()</function>. If
17693 </para>
17694 <literallayout class="monospaced">
17695 IPV6_USE_INET_PTON=yes
17696 </literallayout>
17697 <para>
17698 is set in <filename>Local/Makefile</filename> (or an OS-dependent Makefile) when Exim is built,
17699 Exim uses <emphasis>inet_pton()</emphasis> to convert a textual IPv6 address for actual use,
17700 instead of <function>getaddrinfo()</function>. (Before version 4.14, it always used this
17701 function.) Of course, this means that the additional functionality of
17702 <function>getaddrinfo()</function> &ndash; recognizing scoped addresses &ndash; is lost.
17703 </para>
17704 </section>
17705 <section revisionflag="changed">
17706 <title>Disabling IPv6</title>
17707 <para revisionflag="changed">
17708 <indexterm role="concept">
17709 <primary>IPv6</primary>
17710 <secondary>disabling</secondary>
17711 </indexterm>
17712 Sometimes it happens that an Exim binary that was compiled with IPv6 support is
17713 run on a host whose kernel does not support IPv6. The binary will fall back to
17714 using IPv4, but it may waste resources looking up AAAA records, and trying to
17715 connect to IPv6 addresses, causing delays to mail delivery. If you set the
17716 <indexterm role="option">
17717 <primary><option>disable_ipv6</option></primary>
17718 </indexterm>
17719 <option>disable_ipv6</option> option true, even if the Exim binary has IPv6 support, no IPv6
17720 activities take place. AAAA records are never looked up, and any IPv6 addresses
17721 that are listed in <option>local_interfaces</option>, data for the <command>manualroute</command> router,
17722 etc. are ignored. If IP literals are enabled, the <command>ipliteral</command> router declines
17723 to handle IPv6 literal addresses.
17724 </para>
17725 <para revisionflag="changed">
17726 On the other hand, when IPv6 is in use, there may be times when you want to
17727 disable it for certain hosts or domains. You can use the <option>dns_ipv4_lookup</option>
17728 option to globally suppress the lookup of AAAA records for specified domains,
17729 and you can use the <option>ignore_target_hosts</option> generic router option to ignore
17730 IPv6 addresses in an individual router.
17731 </para>
17732 </section>
17733 <section>
17734 <title>Examples of starting a listening daemon</title>
17735 <para>
17736 The default case in an IPv6 environment is
17737 </para>
17738 <literallayout class="monospaced">
17739 daemon_smtp_ports = smtp
17740 local_interfaces = &lt;; ::0 ; 0.0.0.0
17741 </literallayout>
17742 <para>
17743 This specifies listening on the smtp port on all IPv6 and IPv4 interfaces.
17744 Either one or two sockets may be used, depending on the characteristics of
17745 the TCP/IP stack. (This is complicated and messy; for more information,
17746 read the comments in the <filename>daemon.c</filename> source file.)
17747 </para>
17748 <para>
17749 To specify listening on ports 25 and 26 on all interfaces:
17750 </para>
17751 <literallayout class="monospaced">
17752 daemon_smtp_ports = 25 : 26
17753 </literallayout>
17754 <para>
17755 (leaving <option>local_interfaces</option> at the default setting) or, more explicitly:
17756 </para>
17757 <literallayout class="monospaced">
17758 local_interfaces = &lt;; ::0.25     ; ::0.26 \
17759                       0.0.0.0.25 ; 0.0.0.0.26
17760 </literallayout>
17761 <para>
17762 To listen on the default port on all IPv4 interfaces, and on port 26 on the
17763 IPv4 loopback address only:
17764 </para>
17765 <literallayout class="monospaced">
17766 local_interfaces = 0.0.0.0 : 127.0.0.1.26
17767 </literallayout>
17768 <para>
17769 To specify listening on the default port on specific interfaces only:
17770 </para>
17771 <literallayout class="monospaced">
17772 local_interfaces = 192.168.34.67 : 192.168.34.67
17773 </literallayout>
17774 <para>
17775 <emphasis role="bold">Warning</emphasis>: Such a setting excludes listening on the loopback interfaces.
17776 </para>
17777 </section>
17778 <section id="SECTreclocipadd">
17779 <title>Recognising the local host</title>
17780 <para>
17781 The <option>local_interfaces</option> option is also used when Exim needs to determine
17782 whether or not an IP address refers to the local host. That is, the IP
17783 addresses of all the interfaces on which a daemon is listening are always
17784 treated as local.
17785 </para>
17786 <para>
17787 For this usage, port numbers in <option>local_interfaces</option> are ignored. If either of
17788 the items 0.0.0.0 or ::0 are encountered, Exim gets a complete list of
17789 available interfaces from the operating system, and extracts the relevant
17790 (that is, IPv4 or IPv6) addresses to use for checking.
17791 </para>
17792 <para>
17793 Some systems set up large numbers of virtual interfaces in order to provide
17794 many virtual web servers. In this situation, you may want to listen for
17795 email on only a few of the available interfaces, but nevertheless treat all
17796 interfaces as local when routing. You can do this by setting
17797 <option>extra_local_interfaces</option> to a list of IP addresses, possibly including the
17798 <quote>all</quote> wildcard values. These addresses are recognized as local, but are not
17799 used for listening. Consider this example:
17800 </para>
17801 <literallayout class="monospaced">
17802 local_interfaces = &lt;; 127.0.0.1 ; ::1 ; \
17803                       192.168.53.235 ; \
17804                       3ffe:2101:12:1:a00:20ff:fe86:a061
17805
17806 extra_local_interfaces = &lt;; ::0 ; 0.0.0.0
17807 </literallayout>
17808 <para>
17809 The daemon listens on the loopback interfaces and just one IPv4 and one IPv6
17810 address, but all available interface addresses are treated as local when
17811 Exim is routing.
17812 </para>
17813 <para>
17814 In some environments the local host name may be in an MX list, but with an IP
17815 address that is not assigned to any local interface. In other cases it may be
17816 desirable to treat other host names as if they referred to the local host. Both
17817 these cases can be handled by setting the <option>hosts_treat_as_local</option> option.
17818 This contains host names rather than IP addresses. When a host is referenced
17819 during routing, either via an MX record or directly, it is treated as the local
17820 host if its name matches <option>hosts_treat_as_local</option>, or if any of its IP
17821 addresses match <option>local_interfaces</option> or <option>extra_local_interfaces</option>.
17822 </para>
17823 </section>
17824 <section>
17825 <title>Delivering to a remote host</title>
17826 <para>
17827 Delivery to a remote host is handled by the smtp transport. By default, it
17828 allows the system&#x2019;s TCP/IP functions to choose which interface to use (if
17829 there is more than one) when connecting to a remote host. However, the
17830 <option>interface</option> option can be set to specify which interface is used. See the
17831 description of the smtp transport in chapter <xref linkend="CHAPsmtptrans"/> for more
17832 details.
17833 </para>
17834 </section>
17835 </chapter>
17836
17837 <chapter id="CHAPmainconfig">
17838 <title>Main configuration</title>
17839 <para>
17840 <indexterm role="concept" id="IIDconfima" class="startofrange">
17841 <primary>configuration file</primary>
17842 <secondary>main section</secondary>
17843 </indexterm>
17844 <indexterm role="concept" id="IIDmaiconf" class="startofrange">
17845 <primary>main configuration</primary>
17846 </indexterm>
17847 The first part of the run time configuration file contains three types of item:
17848 </para>
17849 <itemizedlist>
17850 <listitem>
17851 <para>
17852 Macro definitions: These lines start with an upper case letter. See section
17853 <xref linkend="SECTmacrodefs"/> for details of macro processing.
17854 </para>
17855 </listitem>
17856 <listitem>
17857 <para>
17858 Named list definitions: These lines start with one of the words <quote>domainlist</quote>,
17859 <quote>hostlist</quote>, <quote>addresslist</quote>, or <quote>localpartlist</quote>. Their use is described in
17860 section <xref linkend="SECTnamedlists"/>.
17861 </para>
17862 </listitem>
17863 <listitem>
17864 <para>
17865 Main configuration settings: Each setting occupies one line of the file
17866 (with possible continuations). If any setting is preceded by the word
17867 <quote>hide</quote>, the <option>-bP</option> command line option displays its value to admin users
17868 only. See section <xref linkend="SECTcos"/> for a description of the syntax of these option
17869 settings.
17870 </para>
17871 </listitem>
17872 </itemizedlist>
17873 <para>
17874 This chapter specifies all the main configuration options, along with their
17875 types and default values. For ease of finding a particular option, they appear
17876 in alphabetical order in section <xref linkend="SECTalomo"/> below. However, because there
17877 are now so many options, they are first listed briefly in functional groups, as
17878 an aid to finding the name of the option you are looking for. Some options are
17879 listed in more than one group.
17880 </para>
17881 <section>
17882 <title>Miscellaneous</title>
17883 <informaltable frame="none">
17884 <tgroup cols="2" colsep="0" rowsep="0">
17885 <colspec colwidth="190pt" align="left"/>
17886 <colspec colwidth="260pt" align="left"/>
17887 <tbody>
17888 <row>
17889 <entry><option>bi_command</option></entry>
17890 <entry>to run for <option>-bi</option> command line option</entry>
17891 </row>
17892 <row>
17893 <entry><option>disable_ipv6</option></entry>
17894 <entry>do no IPv6 processing</entry>
17895 </row>
17896 <row>
17897 <entry><option>keep_malformed</option></entry>
17898 <entry>for broken files &ndash; should not happen</entry>
17899 </row>
17900 <row>
17901 <entry><option>localhost_number</option></entry>
17902 <entry>for unique message ids in clusters</entry>
17903 </row>
17904 <row>
17905 <entry><option>message_body_visible</option></entry>
17906 <entry>how much to show in <varname>$message_body</varname></entry>
17907 </row>
17908 <row>
17909 <entry><option>mua_wrapper</option></entry>
17910 <entry>run in <quote>MUA wrapper</quote> mode</entry>
17911 </row>
17912 <row>
17913 <entry><option>print_topbitchars</option></entry>
17914 <entry>top-bit characters are printing</entry>
17915 </row>
17916 <row>
17917 <entry><option>timezone</option></entry>
17918 <entry>force time zone</entry>
17919 </row>
17920 </tbody>
17921 </tgroup>
17922 </informaltable>
17923 </section>
17924 <section>
17925 <title>Exim parameters</title>
17926 <informaltable frame="none">
17927 <tgroup cols="2" colsep="0" rowsep="0">
17928 <colspec colwidth="190pt" align="left"/>
17929 <colspec colwidth="260pt" align="left"/>
17930 <tbody>
17931 <row>
17932 <entry><option>exim_group</option></entry>
17933 <entry>override compiled-in value</entry>
17934 </row>
17935 <row>
17936 <entry><option>exim_path</option></entry>
17937 <entry>override compiled-in value</entry>
17938 </row>
17939 <row>
17940 <entry><option>exim_user</option></entry>
17941 <entry>override compiled-in value</entry>
17942 </row>
17943 <row>
17944 <entry><option>primary_hostname</option></entry>
17945 <entry>default from <function>uname()</function></entry>
17946 </row>
17947 <row>
17948 <entry><option>split_spool_directory</option></entry>
17949 <entry>use multiple directories</entry>
17950 </row>
17951 <row>
17952 <entry><option>spool_directory</option></entry>
17953 <entry>override compiled-in value</entry>
17954 </row>
17955 </tbody>
17956 </tgroup>
17957 </informaltable>
17958 </section>
17959 <section>
17960 <title>Privilege controls</title>
17961 <informaltable frame="none">
17962 <tgroup cols="2" colsep="0" rowsep="0">
17963 <colspec colwidth="190pt" align="left"/>
17964 <colspec colwidth="260pt" align="left"/>
17965 <tbody>
17966 <row>
17967 <entry><option>admin_groups</option></entry>
17968 <entry>groups that are Exim admin users</entry>
17969 </row>
17970 <row>
17971 <entry><option>deliver_drop_privilege</option></entry>
17972 <entry>drop root for delivery processes</entry>
17973 </row>
17974 <row>
17975 <entry><option>local_from_check</option></entry>
17976 <entry>insert <emphasis>Sender:</emphasis> if necessary</entry>
17977 </row>
17978 <row>
17979 <entry><option>local_from_prefix</option></entry>
17980 <entry>for testing <emphasis>From:</emphasis> for local sender</entry>
17981 </row>
17982 <row>
17983 <entry><option>local_from_suffix</option></entry>
17984 <entry>for testing <emphasis>From:</emphasis> for local sender</entry>
17985 </row>
17986 <row>
17987 <entry><option>local_sender_retain</option></entry>
17988 <entry>keep <emphasis>Sender:</emphasis> from untrusted user</entry>
17989 </row>
17990 <row>
17991 <entry><option>never_users</option></entry>
17992 <entry>do not run deliveries as these</entry>
17993 </row>
17994 <row>
17995 <entry><option>prod_requires_admin</option></entry>
17996 <entry>forced delivery requires admin user</entry>
17997 </row>
17998 <row>
17999 <entry><option>queue_list_requires_admin</option></entry>
18000 <entry>queue listing requires admin user</entry>
18001 </row>
18002 <row>
18003 <entry><option>trusted_groups</option></entry>
18004 <entry>groups that are trusted</entry>
18005 </row>
18006 <row>
18007 <entry><option>trusted_users</option></entry>
18008 <entry>users that are trusted</entry>
18009 </row>
18010 </tbody>
18011 </tgroup>
18012 </informaltable>
18013 </section>
18014 <section>
18015 <title>Logging</title>
18016 <informaltable frame="none">
18017 <tgroup cols="2" colsep="0" rowsep="0">
18018 <colspec colwidth="190pt" align="left"/>
18019 <colspec colwidth="260pt" align="left"/>
18020 <tbody>
18021 <row>
18022 <entry><option>hosts_connection_nolog</option></entry>
18023 <entry>exemption from connect logging</entry>
18024 </row>
18025 <row>
18026 <entry><option>log_file_path</option></entry>
18027 <entry>override compiled-in value</entry>
18028 </row>
18029 <row>
18030 <entry><option>log_selector</option></entry>
18031 <entry>set/unset optional logging</entry>
18032 </row>
18033 <row>
18034 <entry><option>log_timezone</option></entry>
18035 <entry>add timezone to log lines</entry>
18036 </row>
18037 <row>
18038 <entry><option>message_logs</option></entry>
18039 <entry>create per-message logs</entry>
18040 </row>
18041 <row>
18042 <entry><option>preserve_message_logs</option></entry>
18043 <entry>after message completion</entry>
18044 </row>
18045 <row>
18046 <entry><option>process_log_path</option></entry>
18047 <entry>for SIGUSR1 and <emphasis>exiwhat</emphasis></entry>
18048 </row>
18049 <row>
18050 <entry><option>syslog_duplication</option></entry>
18051 <entry>controls duplicate log lines on syslog</entry>
18052 </row>
18053 <row>
18054 <entry><option>syslog_facility</option></entry>
18055 <entry>set syslog <quote>facility</quote> field</entry>
18056 </row>
18057 <row>
18058 <entry><option>syslog_processname</option></entry>
18059 <entry>set syslog <quote>ident</quote> field</entry>
18060 </row>
18061 <row>
18062 <entry><option>syslog_timestamp</option></entry>
18063 <entry>timestamp syslog lines</entry>
18064 </row>
18065 <row>
18066 <entry><option>write_rejectlog</option></entry>
18067 <entry>control use of message log</entry>
18068 </row>
18069 </tbody>
18070 </tgroup>
18071 </informaltable>
18072 </section>
18073 <section>
18074 <title>Frozen messages</title>
18075 <informaltable frame="none">
18076 <tgroup cols="2" colsep="0" rowsep="0">
18077 <colspec colwidth="190pt" align="left"/>
18078 <colspec colwidth="260pt" align="left"/>
18079 <tbody>
18080 <row>
18081 <entry><option>auto_thaw</option></entry>
18082 <entry>sets time for retrying frozen messages</entry>
18083 </row>
18084 <row>
18085 <entry><option>freeze_tell</option></entry>
18086 <entry>send message when freezing</entry>
18087 </row>
18088 <row>
18089 <entry><option>move_frozen_messages</option></entry>
18090 <entry>to another directory</entry>
18091 </row>
18092 <row>
18093 <entry><option>timeout_frozen_after</option></entry>
18094 <entry>keep frozen messages only so long</entry>
18095 </row>
18096 </tbody>
18097 </tgroup>
18098 </informaltable>
18099 </section>
18100 <section>
18101 <title>Data lookups</title>
18102 <informaltable frame="none">
18103 <tgroup cols="2" colsep="0" rowsep="0">
18104 <colspec colwidth="190pt" align="left"/>
18105 <colspec colwidth="260pt" align="left"/>
18106 <tbody>
18107 <row>
18108 <entry><option>ldap_default_servers</option></entry>
18109 <entry>used if no server in query</entry>
18110 </row>
18111 <row>
18112 <entry><option>ldap_version</option></entry>
18113 <entry>set protocol version</entry>
18114 </row>
18115 <row>
18116 <entry><option>lookup_open_max</option></entry>
18117 <entry>lookup files held open</entry>
18118 </row>
18119 <row>
18120 <entry><option>mysql_servers</option></entry>
18121 <entry>as it says</entry>
18122 </row>
18123 <row>
18124 <entry><option>oracle_servers</option></entry>
18125 <entry>as it says</entry>
18126 </row>
18127 <row>
18128 <entry><option>pgsql_servers</option></entry>
18129 <entry>as it says</entry>
18130 </row>
18131 <row>
18132 <entry><option>sqlite_lock_timeout</option></entry>
18133 <entry>as it says</entry>
18134 </row>
18135 </tbody>
18136 </tgroup>
18137 </informaltable>
18138 </section>
18139 <section>
18140 <title>Message ids</title>
18141 <informaltable frame="none">
18142 <tgroup cols="2" colsep="0" rowsep="0">
18143 <colspec colwidth="190pt" align="left"/>
18144 <colspec colwidth="260pt" align="left"/>
18145 <tbody>
18146 <row>
18147 <entry><option>message_id_header_domain</option></entry>
18148 <entry>used to build <emphasis>Message-ID:</emphasis> header</entry>
18149 </row>
18150 <row>
18151 <entry><option>message_id_header_text</option></entry>
18152 <entry>ditto</entry>
18153 </row>
18154 </tbody>
18155 </tgroup>
18156 </informaltable>
18157 </section>
18158 <section>
18159 <title>Embedded Perl Startup</title>
18160 <informaltable frame="none">
18161 <tgroup cols="2" colsep="0" rowsep="0">
18162 <colspec colwidth="190pt" align="left"/>
18163 <colspec colwidth="260pt" align="left"/>
18164 <tbody>
18165 <row>
18166 <entry><option>perl_at_start</option></entry>
18167 <entry>always start the interpreter</entry>
18168 </row>
18169 <row>
18170 <entry><option>perl_startup</option></entry>
18171 <entry>code to obey when starting Perl</entry>
18172 </row>
18173 </tbody>
18174 </tgroup>
18175 </informaltable>
18176 </section>
18177 <section>
18178 <title>Daemon</title>
18179 <informaltable frame="none">
18180 <tgroup cols="2" colsep="0" rowsep="0">
18181 <colspec colwidth="190pt" align="left"/>
18182 <colspec colwidth="260pt" align="left"/>
18183 <tbody>
18184 <row>
18185 <entry><option>daemon_smtp_ports</option></entry>
18186 <entry>default ports</entry>
18187 </row>
18188 <row>
18189 <entry><option>daemon_startup_retries</option></entry>
18190 <entry>number of times to retry</entry>
18191 </row>
18192 <row>
18193 <entry><option>daemon_startup_sleep</option></entry>
18194 <entry>time to sleep between tries</entry>
18195 </row>
18196 <row>
18197 <entry><option>extra_local_interfaces</option></entry>
18198 <entry>not necessarily listened on</entry>
18199 </row>
18200 <row>
18201 <entry><option>local_interfaces</option></entry>
18202 <entry>on which to listen, with optional ports</entry>
18203 </row>
18204 <row>
18205 <entry><option>pid_file_path</option></entry>
18206 <entry>override compiled-in value</entry>
18207 </row>
18208 <row>
18209 <entry><option>queue_run_max</option></entry>
18210 <entry>maximum simultaneous queue runners</entry>
18211 </row>
18212 </tbody>
18213 </tgroup>
18214 </informaltable>
18215 </section>
18216 <section>
18217 <title>Resource control</title>
18218 <informaltable frame="none">
18219 <tgroup cols="2" colsep="0" rowsep="0">
18220 <colspec colwidth="190pt" align="left"/>
18221 <colspec colwidth="260pt" align="left"/>
18222 <tbody>
18223 <row>
18224 <entry><option>check_log_inodes</option></entry>
18225 <entry>before accepting a message</entry>
18226 </row>
18227 <row>
18228 <entry><option>check_log_space</option></entry>
18229 <entry>before accepting a message</entry>
18230 </row>
18231 <row>
18232 <entry><option>check_spool_inodes</option></entry>
18233 <entry>before accepting a message</entry>
18234 </row>
18235 <row>
18236 <entry><option>check_spool_space</option></entry>
18237 <entry>before accepting a message</entry>
18238 </row>
18239 <row>
18240 <entry><option>deliver_queue_load_max</option></entry>
18241 <entry>no queue deliveries if load high</entry>
18242 </row>
18243 <row>
18244 <entry><option>queue_only_load</option></entry>
18245 <entry>queue incoming if load high</entry>
18246 </row>
18247 <row>
18248 <entry><option>queue_run_max</option></entry>
18249 <entry>maximum simultaneous queue runners</entry>
18250 </row>
18251 <row>
18252 <entry><option>remote_max_parallel</option></entry>
18253 <entry>parallel SMTP delivery per message</entry>
18254 </row>
18255 <row>
18256 <entry><option>smtp_accept_max</option></entry>
18257 <entry>simultaneous incoming connections</entry>
18258 </row>
18259 <row>
18260 <entry><option>smtp_accept_max_nommail</option></entry>
18261 <entry>non-mail commands</entry>
18262 </row>
18263 <row>
18264 <entry><option>smtp_accept_max_nonmail_hosts</option></entry>
18265 <entry>hosts to which the limit applies</entry>
18266 </row>
18267 <row>
18268 <entry><option>smtp_accept_max_per_connection</option></entry>
18269 <entry>messages per connection</entry>
18270 </row>
18271 <row>
18272 <entry><option>smtp_accept_max_per_host</option></entry>
18273 <entry>connections from one host</entry>
18274 </row>
18275 <row>
18276 <entry><option>smtp_accept_queue</option></entry>
18277 <entry>queue mail if more connections</entry>
18278 </row>
18279 <row>
18280 <entry><option>smtp_accept_queue_per_connection</option></entry>
18281 <entry>queue if more messages per connection</entry>
18282 </row>
18283 <row>
18284 <entry><option>smtp_accept_reserve</option></entry>
18285 <entry>only reserve hosts if more connections</entry>
18286 </row>
18287 <row>
18288 <entry><option>smtp_check_spool_space</option></entry>
18289 <entry>from SIZE on MAIL command</entry>
18290 </row>
18291 <row>
18292 <entry><option>smtp_connect_backlog</option></entry>
18293 <entry>passed to TCP/IP stack</entry>
18294 </row>
18295 <row>
18296 <entry><option>smtp_load_reserve</option></entry>
18297 <entry>SMTP from reserved hosts if load high</entry>
18298 </row>
18299 <row>
18300 <entry><option>smtp_reserve_hosts</option></entry>
18301 <entry>these are the reserve hosts</entry>
18302 </row>
18303 </tbody>
18304 </tgroup>
18305 </informaltable>
18306 </section>
18307 <section>
18308 <title>Policy controls</title>
18309 <informaltable frame="none">
18310 <tgroup cols="2" colsep="0" rowsep="0">
18311 <colspec colwidth="190pt" align="left"/>
18312 <colspec colwidth="260pt" align="left"/>
18313 <tbody>
18314 <row>
18315 <entry><option>acl_not_smtp</option></entry>
18316 <entry>ACL for non-SMTP messages</entry>
18317 </row>
18318 <row>
18319 <entry><option>acl_not_smtp_mime</option></entry>
18320 <entry>ACL for non-SMTP MIME parts</entry>
18321 </row>
18322 <row>
18323 <entry><option>acl_smtp_auth</option></entry>
18324 <entry>ACL for AUTH</entry>
18325 </row>
18326 <row>
18327 <entry><option>acl_smtp_connect</option></entry>
18328 <entry>ACL for connection</entry>
18329 </row>
18330 <row>
18331 <entry><option>acl_smtp_data</option></entry>
18332 <entry>ACL for DATA</entry>
18333 </row>
18334 <row>
18335 <entry><option>acl_smtp_etrn</option></entry>
18336 <entry>ACL for ETRN</entry>
18337 </row>
18338 <row>
18339 <entry><option>acl_smtp_expn</option></entry>
18340 <entry>ACL for EXPN</entry>
18341 </row>
18342 <row>
18343 <entry><option>acl_smtp_helo</option></entry>
18344 <entry>ACL for EHLO or HELO</entry>
18345 </row>
18346 <row>
18347 <entry><option>acl_smtp_mail</option></entry>
18348 <entry>ACL for MAIL</entry>
18349 </row>
18350 <row>
18351 <entry><option>acl_smtp_mailauth</option></entry>
18352 <entry>ACL for AUTH on MAIL command</entry>
18353 </row>
18354 <row>
18355 <entry><option>acl_smtp_mime</option></entry>
18356 <entry>ACL for MIME parts</entry>
18357 </row>
18358 <row>
18359 <entry><option>acl_smtp_predata</option></entry>
18360 <entry>ACL for start of data</entry>
18361 </row>
18362 <row>
18363 <entry><option>acl_smtp_quit</option></entry>
18364 <entry>ACL for QUIT</entry>
18365 </row>
18366 <row>
18367 <entry><option>acl_smtp_rcpt</option></entry>
18368 <entry>ACL for RCPT</entry>
18369 </row>
18370 <row>
18371 <entry><option>acl_smtp_starttls</option></entry>
18372 <entry>ACL for STARTTLS</entry>
18373 </row>
18374 <row>
18375 <entry><option>acl_smtp_vrfy</option></entry>
18376 <entry>ACL for VRFY</entry>
18377 </row>
18378 <row>
18379 <entry><option>av_scanner</option></entry>
18380 <entry>specify virus scanner</entry>
18381 </row>
18382 <row>
18383 <entry><option>check_rfc2047_length</option></entry>
18384 <entry>check length of RFC 2047 <quote>encoded words</quote></entry>
18385 </row>
18386 <row>
18387 <entry><option>dns_csa_search_limit</option></entry>
18388 <entry>control CSA parent search depth</entry>
18389 </row>
18390 <row>
18391 <entry><option>dns_csa_use_reverse</option></entry>
18392 <entry>en/disable CSA IP reverse search</entry>
18393 </row>
18394 <row>
18395 <entry><option>header_maxsize</option></entry>
18396 <entry>total size of message header</entry>
18397 </row>
18398 <row>
18399 <entry><option>header_line_maxsize</option></entry>
18400 <entry>individual header line limit</entry>
18401 </row>
18402 <row>
18403 <entry><option>helo_accept_junk_hosts</option></entry>
18404 <entry>allow syntactic junk from these hosts</entry>
18405 </row>
18406 <row>
18407 <entry><option>helo_allow_chars</option></entry>
18408 <entry>allow illegal chars in HELO names</entry>
18409 </row>
18410 <row>
18411 <entry><option>helo_lookup_domains</option></entry>
18412 <entry>lookup hostname for these HELO names</entry>
18413 </row>
18414 <row>
18415 <entry><option>helo_try_verify_hosts</option></entry>
18416 <entry>HELO soft-checked for these hosts</entry>
18417 </row>
18418 <row>
18419 <entry><option>helo_verify_hosts</option></entry>
18420 <entry>HELO hard-checked for these hosts</entry>
18421 </row>
18422 <row>
18423 <entry><option>host_lookup</option></entry>
18424 <entry>host name looked up for these hosts</entry>
18425 </row>
18426 <row>
18427 <entry><option>host_lookup_order</option></entry>
18428 <entry>order of DNS and local name lookups</entry>
18429 </row>
18430 <row>
18431 <entry><option>host_reject_connection</option></entry>
18432 <entry>reject connection from these hosts</entry>
18433 </row>
18434 <row>
18435 <entry><option>hosts_treat_as_local</option></entry>
18436 <entry>useful in some cluster configurations</entry>
18437 </row>
18438 <row>
18439 <entry><option>local_scan_timeout</option></entry>
18440 <entry>timeout for <function>local_scan()</function></entry>
18441 </row>
18442 <row>
18443 <entry><option>message_size_limit</option></entry>
18444 <entry>for all messages</entry>
18445 </row>
18446 <row>
18447 <entry><option>percent_hack_domains</option></entry>
18448 <entry>recognize %-hack for these domains</entry>
18449 </row>
18450 <row>
18451 <entry><option>spamd_address</option></entry>
18452 <entry>set interface to SpamAssassin</entry>
18453 </row>
18454 </tbody>
18455 </tgroup>
18456 </informaltable>
18457 </section>
18458 <section>
18459 <title>Callout cache</title>
18460 <informaltable frame="none">
18461 <tgroup cols="2" colsep="0" rowsep="0">
18462 <colspec colwidth="190pt" align="left"/>
18463 <colspec colwidth="260pt" align="left"/>
18464 <tbody>
18465 <row>
18466 <entry><option>callout_domain_negative_expire</option></entry>
18467 <entry>timeout for negative domain cache item</entry>
18468 </row>
18469 <row>
18470 <entry><option>callout_domain_positive_expire</option></entry>
18471 <entry>timeout for positive domain cache item</entry>
18472 </row>
18473 <row>
18474 <entry><option>callout_negative_expire</option></entry>
18475 <entry>timeout for negative address cache item</entry>
18476 </row>
18477 <row>
18478 <entry><option>callout_positive_expire</option></entry>
18479 <entry>timeout for positive address cache item</entry>
18480 </row>
18481 <row>
18482 <entry><option>callout_random_local_part</option></entry>
18483 <entry>string to use for <quote>random</quote> testing</entry>
18484 </row>
18485 </tbody>
18486 </tgroup>
18487 </informaltable>
18488 </section>
18489 <section>
18490 <title>TLS</title>
18491 <informaltable frame="none">
18492 <tgroup cols="2" colsep="0" rowsep="0">
18493 <colspec colwidth="190pt" align="left"/>
18494 <colspec colwidth="260pt" align="left"/>
18495 <tbody>
18496 <row>
18497 <entry><option>tls_advertise_hosts</option></entry>
18498 <entry>advertise TLS to these hosts</entry>
18499 </row>
18500 <row>
18501 <entry><option>tls_certificate</option></entry>
18502 <entry>location of server certificate</entry>
18503 </row>
18504 <row>
18505 <entry><option>tls_crl</option></entry>
18506 <entry>certificate revocation list</entry>
18507 </row>
18508 <row>
18509 <entry><option>tls_dhparam</option></entry>
18510 <entry>DH parameters for server</entry>
18511 </row>
18512 <row>
18513 <entry><option>tls_on_connect_ports</option></entry>
18514 <entry>specify SSMTP (SMTPS) ports</entry>
18515 </row>
18516 <row>
18517 <entry><option>tls_privatekey</option></entry>
18518 <entry>location of server private key</entry>
18519 </row>
18520 <row>
18521 <entry><option>tls_remember_esmtp</option></entry>
18522 <entry>don&#x2019;t reset after starting TLS</entry>
18523 </row>
18524 <row>
18525 <entry><option>tls_require_ciphers</option></entry>
18526 <entry>specify acceptable cipers</entry>
18527 </row>
18528 <row>
18529 <entry><option>tls_try_verify_hosts</option></entry>
18530 <entry>try to verify client certificate</entry>
18531 </row>
18532 <row>
18533 <entry><option>tls_verify_certificates</option></entry>
18534 <entry>expected client certificates</entry>
18535 </row>
18536 <row>
18537 <entry><option>tls_verify_hosts</option></entry>
18538 <entry>insist on client certificate verify</entry>
18539 </row>
18540 </tbody>
18541 </tgroup>
18542 </informaltable>
18543 </section>
18544 <section>
18545 <title>Local user handling</title>
18546 <informaltable frame="none">
18547 <tgroup cols="2" colsep="0" rowsep="0">
18548 <colspec colwidth="190pt" align="left"/>
18549 <colspec colwidth="260pt" align="left"/>
18550 <tbody>
18551 <row>
18552 <entry><option>finduser_retries</option></entry>
18553 <entry>useful in NIS environments</entry>
18554 </row>
18555 <row>
18556 <entry><option>gecos_name</option></entry>
18557 <entry>used when creating <emphasis>Sender:</emphasis></entry>
18558 </row>
18559 <row>
18560 <entry><option>gecos_pattern</option></entry>
18561 <entry>ditto</entry>
18562 </row>
18563 <row>
18564 <entry><option>max_username_length</option></entry>
18565 <entry>for systems that truncate</entry>
18566 </row>
18567 <row>
18568 <entry><option>unknown_login</option></entry>
18569 <entry>used when no login name found</entry>
18570 </row>
18571 <row>
18572 <entry><option>unknown_username</option></entry>
18573 <entry>ditto</entry>
18574 </row>
18575 <row>
18576 <entry><option>uucp_from_pattern</option></entry>
18577 <entry>for recognizing <quote>From </quote> lines</entry>
18578 </row>
18579 <row>
18580 <entry><option>uucp_from_sender</option></entry>
18581 <entry>ditto</entry>
18582 </row>
18583 </tbody>
18584 </tgroup>
18585 </informaltable>
18586 </section>
18587 <section>
18588 <title>All incoming messages (SMTP and non-SMTP)</title>
18589 <informaltable frame="none">
18590 <tgroup cols="2" colsep="0" rowsep="0">
18591 <colspec colwidth="190pt" align="left"/>
18592 <colspec colwidth="260pt" align="left"/>
18593 <tbody>
18594 <row>
18595 <entry><option>header_maxsize</option></entry>
18596 <entry>total size of message header</entry>
18597 </row>
18598 <row>
18599 <entry><option>header_line_maxsize</option></entry>
18600 <entry>individual header line limit</entry>
18601 </row>
18602 <row>
18603 <entry><option>message_size_limit</option></entry>
18604 <entry>applies to all messages</entry>
18605 </row>
18606 <row>
18607 <entry><option>percent_hack_domains</option></entry>
18608 <entry>recognize %-hack for these domains</entry>
18609 </row>
18610 <row>
18611 <entry><option>received_header_text</option></entry>
18612 <entry>expanded to make <emphasis>Received:</emphasis></entry>
18613 </row>
18614 <row>
18615 <entry><option>received_headers_max</option></entry>
18616 <entry>for mail loop detection</entry>
18617 </row>
18618 <row>
18619 <entry><option>recipients_max</option></entry>
18620 <entry>limit per message</entry>
18621 </row>
18622 <row>
18623 <entry><option>recipients_max_reject</option></entry>
18624 <entry>permanently reject excess</entry>
18625 </row>
18626 </tbody>
18627 </tgroup>
18628 </informaltable>
18629 </section>
18630 <section>
18631 <title>Non-SMTP incoming messages</title>
18632 <informaltable frame="none">
18633 <tgroup cols="2" colsep="0" rowsep="0">
18634 <colspec colwidth="190pt" align="left"/>
18635 <colspec colwidth="260pt" align="left"/>
18636 <tbody>
18637 <row>
18638 <entry><option>receive_timeout</option></entry>
18639 <entry>for non-SMTP messages</entry>
18640 </row>
18641 </tbody>
18642 </tgroup>
18643 </informaltable>
18644 </section>
18645 <section>
18646 <title>Incoming SMTP messages</title>
18647 <para>
18648 See also the <emphasis>Policy controls</emphasis> section above.
18649 </para>
18650 <informaltable frame="none">
18651 <tgroup cols="2" colsep="0" rowsep="0">
18652 <colspec colwidth="190pt" align="left"/>
18653 <colspec colwidth="260pt" align="left"/>
18654 <tbody>
18655 <row>
18656 <entry><option>host_lookup</option></entry>
18657 <entry>host name looked up for these hosts</entry>
18658 </row>
18659 <row>
18660 <entry><option>host_lookup_order</option></entry>
18661 <entry>order of DNS and local name lookups</entry>
18662 </row>
18663 <row>
18664 <entry><option>recipient_unqualified_hosts</option></entry>
18665 <entry>may send unqualified recipients</entry>
18666 </row>
18667 <row>
18668 <entry><option>rfc1413_hosts</option></entry>
18669 <entry>make ident calls to these hosts</entry>
18670 </row>
18671 <row>
18672 <entry><option>rfc1413_query_timeout</option></entry>
18673 <entry>zero disables ident calls</entry>
18674 </row>
18675 <row>
18676 <entry><option>sender_unqualified_hosts</option></entry>
18677 <entry>may send unqualified senders</entry>
18678 </row>
18679 <row>
18680 <entry><option>smtp_accept_keepalive</option></entry>
18681 <entry>some TCP/IP magic</entry>
18682 </row>
18683 <row>
18684 <entry><option>smtp_accept_max</option></entry>
18685 <entry>simultaneous incoming connections</entry>
18686 </row>
18687 <row>
18688 <entry><option>smtp_accept_max_nonmail</option></entry>
18689 <entry>non-mail commands</entry>
18690 </row>
18691 <row>
18692 <entry><option>smtp_accept_max_nonmail_hosts</option></entry>
18693 <entry>hosts to which the limit applies</entry>
18694 </row>
18695 <row>
18696 <entry><option>smtp_accept_max_per_connection</option></entry>
18697 <entry>messages per connection</entry>
18698 </row>
18699 <row>
18700 <entry><option>smtp_accept_max_per_host</option></entry>
18701 <entry>connections from one host</entry>
18702 </row>
18703 <row>
18704 <entry><option>smtp_accept_queue</option></entry>
18705 <entry>queue mail if more connections</entry>
18706 </row>
18707 <row>
18708 <entry><option>smtp_accept_queue_per_connection</option></entry>
18709 <entry>queue if more messages per connection</entry>
18710 </row>
18711 <row>
18712 <entry><option>smtp_accept_reserve</option></entry>
18713 <entry>only reserve hosts if more connections</entry>
18714 </row>
18715 <row>
18716 <entry><option>smtp_active_hostname</option></entry>
18717 <entry>host name to use in messages</entry>
18718 </row>
18719 <row>
18720 <entry><option>smtp_banner</option></entry>
18721 <entry>text for welcome banner</entry>
18722 </row>
18723 <row>
18724 <entry><option>smtp_check_spool_space</option></entry>
18725 <entry>from SIZE on MAIL command</entry>
18726 </row>
18727 <row>
18728 <entry><option>smtp_connect_backlog</option></entry>
18729 <entry>passed to TCP/IP stack</entry>
18730 </row>
18731 <row>
18732 <entry><option>smtp_enforce_sync</option></entry>
18733 <entry>of SMTP command/responses</entry>
18734 </row>
18735 <row>
18736 <entry><option>smtp_etrn_command</option></entry>
18737 <entry>what to run for ETRN</entry>
18738 </row>
18739 <row>
18740 <entry><option>smtp_etrn_serialize</option></entry>
18741 <entry>only one at once</entry>
18742 </row>
18743 <row>
18744 <entry><option>smtp_load_reserve</option></entry>
18745 <entry>only reserve hosts if this load</entry>
18746 </row>
18747 <row>
18748 <entry><option>smtp_max_unknown_commands</option></entry>
18749 <entry>before dropping connection</entry>
18750 </row>
18751 <row>
18752 <entry><option>smtp_ratelimit_hosts</option></entry>
18753 <entry>apply ratelimiting to these hosts</entry>
18754 </row>
18755 <row>
18756 <entry><option>smtp_ratelimit_mail</option></entry>
18757 <entry>ratelimit for MAIL commands</entry>
18758 </row>
18759 <row>
18760 <entry><option>smtp_ratelimit_rcpt</option></entry>
18761 <entry>ratelimit for RCPT commands</entry>
18762 </row>
18763 <row>
18764 <entry><option>smtp_receive_timeout</option></entry>
18765 <entry>per command or data line</entry>
18766 </row>
18767 <row>
18768 <entry><option>smtp_reserve_hosts</option></entry>
18769 <entry>these are the reserve hosts</entry>
18770 </row>
18771 <row>
18772 <entry><option>smtp_return_error_details</option></entry>
18773 <entry>give detail on rejections</entry>
18774 </row>
18775 </tbody>
18776 </tgroup>
18777 </informaltable>
18778 </section>
18779 <section>
18780 <title>SMTP extensions</title>
18781 <informaltable frame="none">
18782 <tgroup cols="2" colsep="0" rowsep="0">
18783 <colspec colwidth="190pt" align="left"/>
18784 <colspec colwidth="260pt" align="left"/>
18785 <tbody>
18786 <row>
18787 <entry><option>accept_8bitmime</option></entry>
18788 <entry>advertise 8BITMIME</entry>
18789 </row>
18790 <row>
18791 <entry><option>auth_advertise_hosts</option></entry>
18792 <entry>advertise AUTH to these hosts</entry>
18793 </row>
18794 <row>
18795 <entry><option>ignore_fromline_hosts</option></entry>
18796 <entry>allow <quote>From </quote> from these hosts</entry>
18797 </row>
18798 <row>
18799 <entry><option>ignore_fromline_local</option></entry>
18800 <entry>allow <quote>From </quote> from local SMTP</entry>
18801 </row>
18802 <row>
18803 <entry><option>pipelining_advertise_hosts</option></entry>
18804 <entry>advertise pipelining to these hosts</entry>
18805 </row>
18806 <row>
18807 <entry><option>tls_advertise_hosts</option></entry>
18808 <entry>advertise TLS to these hosts</entry>
18809 </row>
18810 </tbody>
18811 </tgroup>
18812 </informaltable>
18813 </section>
18814 <section>
18815 <title>Processing messages</title>
18816 <informaltable frame="none">
18817 <tgroup cols="2" colsep="0" rowsep="0">
18818 <colspec colwidth="190pt" align="left"/>
18819 <colspec colwidth="260pt" align="left"/>
18820 <tbody>
18821 <row>
18822 <entry><option>allow_domain_literals</option></entry>
18823 <entry>recognize domain literal syntax</entry>
18824 </row>
18825 <row>
18826 <entry><option>allow_mx_to_ip</option></entry>
18827 <entry>allow MX to point to IP address</entry>
18828 </row>
18829 <row>
18830 <entry><option>allow_utf8_domains</option></entry>
18831 <entry>in addresses</entry>
18832 </row>
18833 <row>
18834 <entry><option>check_rfc2047_length</option></entry>
18835 <entry>check length of RFC 2047 <quote>encoded words</quote></entry>
18836 </row>
18837 <row>
18838 <entry><option>delivery_date_remove</option></entry>
18839 <entry>from incoming messages</entry>
18840 </row>
18841 <row>
18842 <entry><option>envelope_to_remote</option></entry>
18843 <entry>from incoming messages</entry>
18844 </row>
18845 <row>
18846 <entry><option>extract_addresses_remove_arguments</option></entry>
18847 <entry>affects <option>-t</option> processing</entry>
18848 </row>
18849 <row>
18850 <entry><option>headers_charset</option></entry>
18851 <entry>default for translations</entry>
18852 </row>
18853 <row>
18854 <entry><option>qualify_domain</option></entry>
18855 <entry>default for senders</entry>
18856 </row>
18857 <row>
18858 <entry><option>qualify_recipient</option></entry>
18859 <entry>default for recipients</entry>
18860 </row>
18861 <row>
18862 <entry><option>return_path_remove</option></entry>
18863 <entry>from incoming messages</entry>
18864 </row>
18865 <row>
18866 <entry><option>strip_excess_angle_brackets</option></entry>
18867 <entry>in addresses</entry>
18868 </row>
18869 <row>
18870 <entry><option>strip_trailing_dot</option></entry>
18871 <entry>at end of addresses</entry>
18872 </row>
18873 <row>
18874 <entry><option>untrusted_set_sender</option></entry>
18875 <entry>untrusted can set envelope sender</entry>
18876 </row>
18877 </tbody>
18878 </tgroup>
18879 </informaltable>
18880 </section>
18881 <section>
18882 <title>System filter</title>
18883 <informaltable frame="none">
18884 <tgroup cols="2" colsep="0" rowsep="0">
18885 <colspec colwidth="190pt" align="left"/>
18886 <colspec colwidth="260pt" align="left"/>
18887 <tbody>
18888 <row>
18889 <entry><option>system_filter</option></entry>
18890 <entry>locate system filter</entry>
18891 </row>
18892 <row>
18893 <entry><option>system_filter_directory_transport</option></entry>
18894 <entry>transport for delivery to a directory</entry>
18895 </row>
18896 <row>
18897 <entry><option>system_filter_file_transport</option></entry>
18898 <entry>transport for delivery to a file</entry>
18899 </row>
18900 <row>
18901 <entry><option>system_filter_group</option></entry>
18902 <entry>group for filter running</entry>
18903 </row>
18904 <row>
18905 <entry><option>system_filter_pipe_transport</option></entry>
18906 <entry>transport for delivery to a pipe</entry>
18907 </row>
18908 <row>
18909 <entry><option>system_filter_reply_transport</option></entry>
18910 <entry>transport for autoreply delivery</entry>
18911 </row>
18912 <row>
18913 <entry><option>system_filter_user</option></entry>
18914 <entry>user for filter running</entry>
18915 </row>
18916 </tbody>
18917 </tgroup>
18918 </informaltable>
18919 </section>
18920 <section>
18921 <title>Routing and delivery</title>
18922 <informaltable frame="none">
18923 <tgroup cols="2" colsep="0" rowsep="0">
18924 <colspec colwidth="190pt" align="left"/>
18925 <colspec colwidth="260pt" align="left"/>
18926 <tbody>
18927 <row>
18928 <entry><option>disable_ipv6</option></entry>
18929 <entry>do no IPv6 processing</entry>
18930 </row>
18931 <row>
18932 <entry><option>dns_again_means_nonexist</option></entry>
18933 <entry>for broken domains</entry>
18934 </row>
18935 <row>
18936 <entry><option>dns_check_names_pattern</option></entry>
18937 <entry>pre-DNS syntax check</entry>
18938 </row>
18939 <row>
18940 <entry><option>dns_ipv4_lookup</option></entry>
18941 <entry>only v4 lookup for these domains</entry>
18942 </row>
18943 <row>
18944 <entry><option>dns_retrans</option></entry>
18945 <entry>parameter for resolver</entry>
18946 </row>
18947 <row>
18948 <entry><option>dns_retry</option></entry>
18949 <entry>parameter for resolver</entry>
18950 </row>
18951 <row>
18952 <entry><option>hold_domains</option></entry>
18953 <entry>hold delivery for these domains</entry>
18954 </row>
18955 <row>
18956 <entry><option>local_interfaces</option></entry>
18957 <entry>for routing checks</entry>
18958 </row>
18959 <row>
18960 <entry><option>queue_domains</option></entry>
18961 <entry>no immediate delivery for these</entry>
18962 </row>
18963 <row>
18964 <entry><option>queue_only</option></entry>
18965 <entry>no immediate delivery at all</entry>
18966 </row>
18967 <row>
18968 <entry><option>queue_only_file</option></entry>
18969 <entry>no immediate delivery if file exists</entry>
18970 </row>
18971 <row>
18972 <entry><option>queue_only_load</option></entry>
18973 <entry>no immediate delivery if load is high</entry>
18974 </row>
18975 <row>
18976 <entry><option>queue_only_override</option></entry>
18977 <entry>allow command line to override</entry>
18978 </row>
18979 <row>
18980 <entry><option>queue_run_in_order</option></entry>
18981 <entry>order of arrival</entry>
18982 </row>
18983 <row>
18984 <entry><option>queue_run_max</option></entry>
18985 <entry>of simultaneous queue runners</entry>
18986 </row>
18987 <row>
18988 <entry><option>queue_smtp_domains</option></entry>
18989 <entry>no immediate SMTP delivery for these</entry>
18990 </row>
18991 <row>
18992 <entry><option>remote_max_parallel</option></entry>
18993 <entry>parallel SMTP delivery per message</entry>
18994 </row>
18995 <row>
18996 <entry><option>remote_sort_domains</option></entry>
18997 <entry>order of remote deliveries</entry>
18998 </row>
18999 <row>
19000 <entry><option>retry_data_expire</option></entry>
19001 <entry>timeout for retry data</entry>
19002 </row>
19003 <row>
19004 <entry><option>retry_interval_max</option></entry>
19005 <entry>safety net for retry rules</entry>
19006 </row>
19007 </tbody>
19008 </tgroup>
19009 </informaltable>
19010 </section>
19011 <section>
19012 <title>Bounce and warning messages</title>
19013 <informaltable frame="none">
19014 <tgroup cols="2" colsep="0" rowsep="0">
19015 <colspec colwidth="190pt" align="left"/>
19016 <colspec colwidth="260pt" align="left"/>
19017 <tbody>
19018 <row>
19019 <entry><option>bounce_message_file</option></entry>
19020 <entry>content of bounce</entry>
19021 </row>
19022 <row>
19023 <entry><option>bounce_message_text</option></entry>
19024 <entry>content of bounce</entry>
19025 </row>
19026 <row>
19027 <entry><option>bounce_return_body</option></entry>
19028 <entry>include body if returning message</entry>
19029 </row>
19030 <row>
19031 <entry><option>bounce_return_message</option></entry>
19032 <entry>include original message in bounce</entry>
19033 </row>
19034 <row>
19035 <entry><option>bounce_return_size_limit</option></entry>
19036 <entry>limit on returned message</entry>
19037 </row>
19038 <row>
19039 <entry><option>bounce_sender_authentication</option></entry>
19040 <entry>send authenticated sender with bounce</entry>
19041 </row>
19042 <row>
19043 <entry><option>errors_copy</option></entry>
19044 <entry>copy bounce messages</entry>
19045 </row>
19046 <row>
19047 <entry><option>errors_reply_to</option></entry>
19048 <entry><emphasis>Reply-to:</emphasis> in bounces</entry>
19049 </row>
19050 <row>
19051 <entry><option>delay_warning</option></entry>
19052 <entry>time schedule</entry>
19053 </row>
19054 <row>
19055 <entry><option>delay_warning_condition</option></entry>
19056 <entry>condition for warning messages</entry>
19057 </row>
19058 <row>
19059 <entry><option>ignore_bounce_errors_after</option></entry>
19060 <entry>discard undeliverable bounces</entry>
19061 </row>
19062 <row>
19063 <entry><option>smtp_return_error_details</option></entry>
19064 <entry>give detail on rejections</entry>
19065 </row>
19066 <row>
19067 <entry><option>warn_message_file</option></entry>
19068 <entry>content of warning message</entry>
19069 </row>
19070 </tbody>
19071 </tgroup>
19072 </informaltable>
19073 </section>
19074 <section id="SECTalomo">
19075 <title>Alphabetical list of main options</title>
19076 <para>
19077 Those options that undergo string expansion before use are marked with
19078 &dagger;.
19079 </para>
19080 <para>
19081 <indexterm role="option">
19082 <primary>accept_8bitmime</primary>
19083 </indexterm>
19084 </para>
19085 <informaltable frame="all">
19086 <tgroup cols="4" colsep="0" rowsep="0">
19087 <colspec colwidth="8*" align="left"/>
19088 <colspec colwidth="5*" align="center"/>
19089 <colspec colwidth="5*" align="center"/>
19090 <colspec colwidth="6*" align="right"/>
19091 <tbody>
19092 <row>
19093 <entry><option>accept_8bitmime</option></entry>
19094 <entry>Use: <emphasis>main</emphasis></entry>
19095 <entry>Type: <emphasis>boolean</emphasis></entry>
19096 <entry>Default: <emphasis>false</emphasis></entry>
19097 </row>
19098 </tbody>
19099 </tgroup>
19100 </informaltable>
19101 <para>
19102 <indexterm role="concept">
19103 <primary>8BITMIME</primary>
19104 </indexterm>
19105 <indexterm role="concept">
19106 <primary>8-bit characters</primary>
19107 </indexterm>
19108 This option causes Exim to send 8BITMIME in its response to an SMTP
19109 EHLO command, and to accept the BODY= parameter on MAIL commands.
19110 However, though Exim is 8-bit clean, it is not a protocol converter, and it
19111 takes no steps to do anything special with messages received by this route.
19112 Consequently, this option is turned off by default.
19113 </para>
19114 <para>
19115 <indexterm role="option">
19116 <primary>acl_not_smtp</primary>
19117 </indexterm>
19118 </para>
19119 <informaltable frame="all">
19120 <tgroup cols="4" colsep="0" rowsep="0">
19121 <colspec colwidth="8*" align="left"/>
19122 <colspec colwidth="5*" align="center"/>
19123 <colspec colwidth="5*" align="center"/>
19124 <colspec colwidth="6*" align="right"/>
19125 <tbody>
19126 <row>
19127 <entry><option>acl_not_smtp</option></entry>
19128 <entry>Use: <emphasis>main</emphasis></entry>
19129 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19130 <entry>Default: <emphasis>unset</emphasis></entry>
19131 </row>
19132 </tbody>
19133 </tgroup>
19134 </informaltable>
19135 <para>
19136 <indexterm role="concept">
19137 <primary>access control lists (ACLs)</primary>
19138 <secondary>for non-SMTP messages</secondary>
19139 </indexterm>
19140 <indexterm role="concept">
19141 <primary>non-SMTP messages</primary>
19142 <secondary>ACLs for</secondary>
19143 </indexterm>
19144 This option defines the ACL that is run when a non-SMTP message is on the point
19145 of being accepted. See chapter <xref linkend="CHAPACL"/> for further details.
19146 </para>
19147 <para>
19148 <indexterm role="option">
19149 <primary>acl_not_smtp_mime</primary>
19150 </indexterm>
19151 </para>
19152 <informaltable frame="all">
19153 <tgroup cols="4" colsep="0" rowsep="0">
19154 <colspec colwidth="8*" align="left"/>
19155 <colspec colwidth="5*" align="center"/>
19156 <colspec colwidth="5*" align="center"/>
19157 <colspec colwidth="6*" align="right"/>
19158 <tbody>
19159 <row>
19160 <entry><option>acl_not_smtp_mime</option></entry>
19161 <entry>Use: <emphasis>main</emphasis></entry>
19162 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19163 <entry>Default: <emphasis>unset</emphasis></entry>
19164 </row>
19165 </tbody>
19166 </tgroup>
19167 </informaltable>
19168 <para>
19169 This option defines the ACL that is run for individual MIME parts of non-SMTP
19170 messages. It operates in exactly the same way as <option>acl_smtp_mime</option> operates for
19171 SMTP messages.
19172 </para>
19173 <para>
19174 <indexterm role="option">
19175 <primary>acl_smtp_auth</primary>
19176 </indexterm>
19177 </para>
19178 <informaltable frame="all">
19179 <tgroup cols="4" colsep="0" rowsep="0">
19180 <colspec colwidth="8*" align="left"/>
19181 <colspec colwidth="5*" align="center"/>
19182 <colspec colwidth="5*" align="center"/>
19183 <colspec colwidth="6*" align="right"/>
19184 <tbody>
19185 <row>
19186 <entry><option>acl_smtp_auth</option></entry>
19187 <entry>Use: <emphasis>main</emphasis></entry>
19188 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19189 <entry>Default: <emphasis>unset</emphasis></entry>
19190 </row>
19191 </tbody>
19192 </tgroup>
19193 </informaltable>
19194 <para>
19195 <indexterm role="concept">
19196 <primary>access control lists (ACLs)</primary>
19197 <secondary>setting up for SMTP commands</secondary>
19198 </indexterm>
19199 <indexterm role="concept">
19200 <primary>AUTH</primary>
19201 <secondary>ACL for</secondary>
19202 </indexterm>
19203 This option defines the ACL that is run when an SMTP AUTH command is
19204 received. See chapter <xref linkend="CHAPACL"/> for further details.
19205 </para>
19206 <para>
19207 <indexterm role="option">
19208 <primary>acl_smtp_connect</primary>
19209 </indexterm>
19210 </para>
19211 <informaltable frame="all">
19212 <tgroup cols="4" colsep="0" rowsep="0">
19213 <colspec colwidth="8*" align="left"/>
19214 <colspec colwidth="5*" align="center"/>
19215 <colspec colwidth="5*" align="center"/>
19216 <colspec colwidth="6*" align="right"/>
19217 <tbody>
19218 <row>
19219 <entry><option>acl_smtp_connect</option></entry>
19220 <entry>Use: <emphasis>main</emphasis></entry>
19221 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19222 <entry>Default: <emphasis>unset</emphasis></entry>
19223 </row>
19224 </tbody>
19225 </tgroup>
19226 </informaltable>
19227 <para>
19228 <indexterm role="concept">
19229 <primary>access control lists (ACLs)</primary>
19230 <secondary>on SMTP connection</secondary>
19231 </indexterm>
19232 This option defines the ACL that is run when an SMTP connection is received.
19233 See chapter <xref linkend="CHAPACL"/> for further details.
19234 </para>
19235 <para>
19236 <indexterm role="option">
19237 <primary>acl_smtp_data</primary>
19238 </indexterm>
19239 </para>
19240 <informaltable frame="all">
19241 <tgroup cols="4" colsep="0" rowsep="0">
19242 <colspec colwidth="8*" align="left"/>
19243 <colspec colwidth="5*" align="center"/>
19244 <colspec colwidth="5*" align="center"/>
19245 <colspec colwidth="6*" align="right"/>
19246 <tbody>
19247 <row>
19248 <entry><option>acl_smtp_data</option></entry>
19249 <entry>Use: <emphasis>main</emphasis></entry>
19250 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19251 <entry>Default: <emphasis>unset</emphasis></entry>
19252 </row>
19253 </tbody>
19254 </tgroup>
19255 </informaltable>
19256 <para>
19257 <indexterm role="concept">
19258 <primary>DATA</primary>
19259 <secondary>ACL for</secondary>
19260 </indexterm>
19261 This option defines the ACL that is run after an SMTP DATA command has been
19262 processed and the message itself has been received, but before the final
19263 acknowledgement is sent. See chapter <xref linkend="CHAPACL"/> for further details.
19264 </para>
19265 <para>
19266 <indexterm role="option">
19267 <primary>acl_smtp_etrn</primary>
19268 </indexterm>
19269 </para>
19270 <informaltable frame="all">
19271 <tgroup cols="4" colsep="0" rowsep="0">
19272 <colspec colwidth="8*" align="left"/>
19273 <colspec colwidth="5*" align="center"/>
19274 <colspec colwidth="5*" align="center"/>
19275 <colspec colwidth="6*" align="right"/>
19276 <tbody>
19277 <row>
19278 <entry><option>acl_smtp_etrn</option></entry>
19279 <entry>Use: <emphasis>main</emphasis></entry>
19280 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19281 <entry>Default: <emphasis>unset</emphasis></entry>
19282 </row>
19283 </tbody>
19284 </tgroup>
19285 </informaltable>
19286 <para>
19287 <indexterm role="concept">
19288 <primary>ETRN</primary>
19289 <secondary>ACL for</secondary>
19290 </indexterm>
19291 This option defines the ACL that is run when an SMTP ETRN command is
19292 received. See chapter <xref linkend="CHAPACL"/> for further details.
19293 </para>
19294 <para>
19295 <indexterm role="option">
19296 <primary>acl_smtp_expn</primary>
19297 </indexterm>
19298 </para>
19299 <informaltable frame="all">
19300 <tgroup cols="4" colsep="0" rowsep="0">
19301 <colspec colwidth="8*" align="left"/>
19302 <colspec colwidth="5*" align="center"/>
19303 <colspec colwidth="5*" align="center"/>
19304 <colspec colwidth="6*" align="right"/>
19305 <tbody>
19306 <row>
19307 <entry><option>acl_smtp_expn</option></entry>
19308 <entry>Use: <emphasis>main</emphasis></entry>
19309 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19310 <entry>Default: <emphasis>unset</emphasis></entry>
19311 </row>
19312 </tbody>
19313 </tgroup>
19314 </informaltable>
19315 <para>
19316 <indexterm role="concept">
19317 <primary>EXPN</primary>
19318 <secondary>ACL for</secondary>
19319 </indexterm>
19320 This option defines the ACL that is run when an SMTP EXPN command is
19321 received. See chapter <xref linkend="CHAPACL"/> for further details.
19322 </para>
19323 <para>
19324 <indexterm role="option">
19325 <primary>acl_smtp_helo</primary>
19326 </indexterm>
19327 </para>
19328 <informaltable frame="all">
19329 <tgroup cols="4" colsep="0" rowsep="0">
19330 <colspec colwidth="8*" align="left"/>
19331 <colspec colwidth="5*" align="center"/>
19332 <colspec colwidth="5*" align="center"/>
19333 <colspec colwidth="6*" align="right"/>
19334 <tbody>
19335 <row>
19336 <entry><option>acl_smtp_helo</option></entry>
19337 <entry>Use: <emphasis>main</emphasis></entry>
19338 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19339 <entry>Default: <emphasis>unset</emphasis></entry>
19340 </row>
19341 </tbody>
19342 </tgroup>
19343 </informaltable>
19344 <para>
19345 <indexterm role="concept">
19346 <primary>EHLO</primary>
19347 <secondary>ACL for</secondary>
19348 </indexterm>
19349 <indexterm role="concept">
19350 <primary>HELO</primary>
19351 <secondary>ACL for</secondary>
19352 </indexterm>
19353 This option defines the ACL that is run when an SMTP EHLO or HELO
19354 command is received. See chapter <xref linkend="CHAPACL"/> for further details.
19355 </para>
19356 <para>
19357 <indexterm role="option">
19358 <primary>acl_smtp_mail</primary>
19359 </indexterm>
19360 </para>
19361 <informaltable frame="all">
19362 <tgroup cols="4" colsep="0" rowsep="0">
19363 <colspec colwidth="8*" align="left"/>
19364 <colspec colwidth="5*" align="center"/>
19365 <colspec colwidth="5*" align="center"/>
19366 <colspec colwidth="6*" align="right"/>
19367 <tbody>
19368 <row>
19369 <entry><option>acl_smtp_mail</option></entry>
19370 <entry>Use: <emphasis>main</emphasis></entry>
19371 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19372 <entry>Default: <emphasis>unset</emphasis></entry>
19373 </row>
19374 </tbody>
19375 </tgroup>
19376 </informaltable>
19377 <para>
19378 <indexterm role="concept">
19379 <primary>MAIL</primary>
19380 <secondary>ACL for</secondary>
19381 </indexterm>
19382 This option defines the ACL that is run when an SMTP MAIL command is
19383 received. See chapter <xref linkend="CHAPACL"/> for further details.
19384 </para>
19385 <para>
19386 <indexterm role="option">
19387 <primary>acl_smtp_mailauth</primary>
19388 </indexterm>
19389 </para>
19390 <informaltable frame="all">
19391 <tgroup cols="4" colsep="0" rowsep="0">
19392 <colspec colwidth="8*" align="left"/>
19393 <colspec colwidth="5*" align="center"/>
19394 <colspec colwidth="5*" align="center"/>
19395 <colspec colwidth="6*" align="right"/>
19396 <tbody>
19397 <row>
19398 <entry><option>acl_smtp_mailauth</option></entry>
19399 <entry>Use: <emphasis>main</emphasis></entry>
19400 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19401 <entry>Default: <emphasis>unset</emphasis></entry>
19402 </row>
19403 </tbody>
19404 </tgroup>
19405 </informaltable>
19406 <para>
19407 <indexterm role="concept">
19408 <primary>AUTH</primary>
19409 <secondary>on MAIL command</secondary>
19410 </indexterm>
19411 This option defines the ACL that is run when there is an AUTH parameter on
19412 a MAIL command. See chapter <xref linkend="CHAPACL"/> for details of ACLs, and chapter
19413 <xref linkend="CHAPSMTPAUTH"/> for details of authentication.
19414 </para>
19415 <para>
19416 <indexterm role="option">
19417 <primary>acl_smtp_mime</primary>
19418 </indexterm>
19419 </para>
19420 <informaltable frame="all">
19421 <tgroup cols="4" colsep="0" rowsep="0">
19422 <colspec colwidth="8*" align="left"/>
19423 <colspec colwidth="5*" align="center"/>
19424 <colspec colwidth="5*" align="center"/>
19425 <colspec colwidth="6*" align="right"/>
19426 <tbody>
19427 <row>
19428 <entry><option>acl_smtp_mime</option></entry>
19429 <entry>Use: <emphasis>main</emphasis></entry>
19430 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19431 <entry>Default: <emphasis>unset</emphasis></entry>
19432 </row>
19433 </tbody>
19434 </tgroup>
19435 </informaltable>
19436 <para>
19437 <indexterm role="concept">
19438 <primary>MIME content scanning</primary>
19439 <secondary>ACL for</secondary>
19440 </indexterm>
19441 This option is available when Exim is built with the content-scanning
19442 extension. It defines the ACL that is run for each MIME part in a message. See
19443 section <xref linkend="SECTscanmimepart"/> for details.
19444 </para>
19445 <para>
19446 <indexterm role="option">
19447 <primary>acl_smtp_predata</primary>
19448 </indexterm>
19449 </para>
19450 <informaltable frame="all">
19451 <tgroup cols="4" colsep="0" rowsep="0">
19452 <colspec colwidth="8*" align="left"/>
19453 <colspec colwidth="5*" align="center"/>
19454 <colspec colwidth="5*" align="center"/>
19455 <colspec colwidth="6*" align="right"/>
19456 <tbody>
19457 <row>
19458 <entry><option>acl_smtp_predata</option></entry>
19459 <entry>Use: <emphasis>main</emphasis></entry>
19460 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19461 <entry>Default: <emphasis>unset</emphasis></entry>
19462 </row>
19463 </tbody>
19464 </tgroup>
19465 </informaltable>
19466 <para>
19467 This option defines the ACL that is run when an SMTP DATA command is
19468 received, before the message itself is received. See chapter <xref linkend="CHAPACL"/> for
19469 further details.
19470 </para>
19471 <para>
19472 <indexterm role="option">
19473 <primary>acl_smtp_quit</primary>
19474 </indexterm>
19475 </para>
19476 <informaltable frame="all">
19477 <tgroup cols="4" colsep="0" rowsep="0">
19478 <colspec colwidth="8*" align="left"/>
19479 <colspec colwidth="5*" align="center"/>
19480 <colspec colwidth="5*" align="center"/>
19481 <colspec colwidth="6*" align="right"/>
19482 <tbody>
19483 <row>
19484 <entry><option>acl_smtp_quit</option></entry>
19485 <entry>Use: <emphasis>main</emphasis></entry>
19486 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19487 <entry>Default: <emphasis>unset</emphasis></entry>
19488 </row>
19489 </tbody>
19490 </tgroup>
19491 </informaltable>
19492 <para>
19493 <indexterm role="concept">
19494 <primary>QUIT</primary>
19495 <secondary>ACL for</secondary>
19496 </indexterm>
19497 This option defines the ACL that is run when an SMTP QUIT command is
19498 received. See chapter <xref linkend="CHAPACL"/> for further details.
19499 </para>
19500 <para>
19501 <indexterm role="option">
19502 <primary>acl_smtp_rcpt</primary>
19503 </indexterm>
19504 </para>
19505 <informaltable frame="all">
19506 <tgroup cols="4" colsep="0" rowsep="0">
19507 <colspec colwidth="8*" align="left"/>
19508 <colspec colwidth="5*" align="center"/>
19509 <colspec colwidth="5*" align="center"/>
19510 <colspec colwidth="6*" align="right"/>
19511 <tbody>
19512 <row>
19513 <entry><option>acl_smtp_rcpt</option></entry>
19514 <entry>Use: <emphasis>main</emphasis></entry>
19515 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19516 <entry>Default: <emphasis>unset</emphasis></entry>
19517 </row>
19518 </tbody>
19519 </tgroup>
19520 </informaltable>
19521 <para>
19522 <indexterm role="concept">
19523 <primary>RCPT</primary>
19524 <secondary>ACL for</secondary>
19525 </indexterm>
19526 This option defines the ACL that is run when an SMTP RCPT command is
19527 received. See chapter <xref linkend="CHAPACL"/> for further details.
19528 </para>
19529 <para>
19530 <indexterm role="option">
19531 <primary>acl_smtp_starttls</primary>
19532 </indexterm>
19533 </para>
19534 <informaltable frame="all">
19535 <tgroup cols="4" colsep="0" rowsep="0">
19536 <colspec colwidth="8*" align="left"/>
19537 <colspec colwidth="5*" align="center"/>
19538 <colspec colwidth="5*" align="center"/>
19539 <colspec colwidth="6*" align="right"/>
19540 <tbody>
19541 <row>
19542 <entry><option>acl_smtp_starttls</option></entry>
19543 <entry>Use: <emphasis>main</emphasis></entry>
19544 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19545 <entry>Default: <emphasis>unset</emphasis></entry>
19546 </row>
19547 </tbody>
19548 </tgroup>
19549 </informaltable>
19550 <para>
19551 <indexterm role="concept">
19552 <primary>STARTTLS</primary>
19553 <secondary>ACL for</secondary>
19554 </indexterm>
19555 This option defines the ACL that is run when an SMTP STARTTLS command is
19556 received. See chapter <xref linkend="CHAPACL"/> for further details.
19557 </para>
19558 <para>
19559 <indexterm role="option">
19560 <primary>acl_smtp_vrfy</primary>
19561 </indexterm>
19562 </para>
19563 <informaltable frame="all">
19564 <tgroup cols="4" colsep="0" rowsep="0">
19565 <colspec colwidth="8*" align="left"/>
19566 <colspec colwidth="5*" align="center"/>
19567 <colspec colwidth="5*" align="center"/>
19568 <colspec colwidth="6*" align="right"/>
19569 <tbody>
19570 <row>
19571 <entry><option>acl_smtp_vrfy</option></entry>
19572 <entry>Use: <emphasis>main</emphasis></entry>
19573 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
19574 <entry>Default: <emphasis>unset</emphasis></entry>
19575 </row>
19576 </tbody>
19577 </tgroup>
19578 </informaltable>
19579 <para>
19580 <indexterm role="concept">
19581 <primary>VRFY</primary>
19582 <secondary>ACL for</secondary>
19583 </indexterm>
19584 This option defines the ACL that is run when an SMTP VRFY command is
19585 received. See chapter <xref linkend="CHAPACL"/> for further details.
19586 </para>
19587 <para>
19588 <indexterm role="option">
19589 <primary>admin_groups</primary>
19590 </indexterm>
19591 </para>
19592 <informaltable frame="all">
19593 <tgroup cols="4" colsep="0" rowsep="0">
19594 <colspec colwidth="8*" align="left"/>
19595 <colspec colwidth="5*" align="center"/>
19596 <colspec colwidth="5*" align="center"/>
19597 <colspec colwidth="6*" align="right"/>
19598 <tbody>
19599 <row>
19600 <entry><option>admin_groups</option></entry>
19601 <entry>Use: <emphasis>main</emphasis></entry>
19602 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
19603 <entry>Default: <emphasis>unset</emphasis></entry>
19604 </row>
19605 </tbody>
19606 </tgroup>
19607 </informaltable>
19608 <para>
19609 <indexterm role="concept">
19610 <primary>admin user</primary>
19611 </indexterm>
19612 This option is expanded just once, at the start of Exim&#x2019;s processing. If the
19613 current group or any of the supplementary groups of an Exim caller is in this
19614 colon-separated list, the caller has admin privileges. If all your system
19615 programmers are in a specific group, for example, you can give them all Exim
19616 admin privileges by putting that group in <option>admin_groups</option>. However, this does
19617 not permit them to read Exim&#x2019;s spool files (whose group owner is the Exim gid).
19618 To permit this, you have to add individuals to the Exim group.
19619 </para>
19620 <para>
19621 <indexterm role="option">
19622 <primary>allow_domain_literals</primary>
19623 </indexterm>
19624 </para>
19625 <informaltable frame="all">
19626 <tgroup cols="4" colsep="0" rowsep="0">
19627 <colspec colwidth="8*" align="left"/>
19628 <colspec colwidth="5*" align="center"/>
19629 <colspec colwidth="5*" align="center"/>
19630 <colspec colwidth="6*" align="right"/>
19631 <tbody>
19632 <row>
19633 <entry><option>allow_domain_literals</option></entry>
19634 <entry>Use: <emphasis>main</emphasis></entry>
19635 <entry>Type: <emphasis>boolean</emphasis></entry>
19636 <entry>Default: <emphasis>false</emphasis></entry>
19637 </row>
19638 </tbody>
19639 </tgroup>
19640 </informaltable>
19641 <para>
19642 <indexterm role="concept">
19643 <primary>domain literal</primary>
19644 </indexterm>
19645 If this option is set, the RFC 2822 domain literal format is permitted in
19646 email addresses. The option is not set by default, because the domain literal
19647 format is not normally required these days, and few people know about it. It
19648 has, however, been exploited by mail abusers.
19649 </para>
19650 <para>
19651 Unfortunately, it seems that some DNS black list maintainers are using this
19652 format to report black listing to postmasters. If you want to accept messages
19653 addressed to your hosts by IP address, you need to set
19654 <option>allow_domain_literals</option> true, and also to add <literal>@[]</literal> to the list of local
19655 domains (defined in the named domain list <option>local_domains</option> in the default
19656 configuration). This <quote>magic string</quote> matches the domain literal form of all
19657 the local host&#x2019;s IP addresses.
19658 </para>
19659 <para>
19660 <indexterm role="option">
19661 <primary>allow_mx_to_ip</primary>
19662 </indexterm>
19663 </para>
19664 <informaltable frame="all">
19665 <tgroup cols="4" colsep="0" rowsep="0">
19666 <colspec colwidth="8*" align="left"/>
19667 <colspec colwidth="5*" align="center"/>
19668 <colspec colwidth="5*" align="center"/>
19669 <colspec colwidth="6*" align="right"/>
19670 <tbody>
19671 <row>
19672 <entry><option>allow_mx_to_ip</option></entry>
19673 <entry>Use: <emphasis>main</emphasis></entry>
19674 <entry>Type: <emphasis>boolean</emphasis></entry>
19675 <entry>Default: <emphasis>false</emphasis></entry>
19676 </row>
19677 </tbody>
19678 </tgroup>
19679 </informaltable>
19680 <para>
19681 <indexterm role="concept">
19682 <primary>MX record</primary>
19683 <secondary>pointing to IP address</secondary>
19684 </indexterm>
19685 It appears that more and more DNS zone administrators are breaking the rules
19686 and putting domain names that look like IP addresses on the right hand side of
19687 MX records. Exim follows the rules and rejects this, giving an error message
19688 that explains the mis-configuration. However, some other MTAs support this
19689 practice, so to avoid <quote>Why can&#x2019;t Exim do this?</quote> complaints,
19690 <option>allow_mx_to_ip</option> exists, in order to enable this heinous activity. It is not
19691 recommended, except when you have no other choice.
19692 </para>
19693 <para>
19694 <indexterm role="option">
19695 <primary>allow_utf8_domains</primary>
19696 </indexterm>
19697 </para>
19698 <informaltable frame="all">
19699 <tgroup cols="4" colsep="0" rowsep="0">
19700 <colspec colwidth="8*" align="left"/>
19701 <colspec colwidth="5*" align="center"/>
19702 <colspec colwidth="5*" align="center"/>
19703 <colspec colwidth="6*" align="right"/>
19704 <tbody>
19705 <row>
19706 <entry><option>allow_utf8_domains</option></entry>
19707 <entry>Use: <emphasis>main</emphasis></entry>
19708 <entry>Type: <emphasis>boolean</emphasis></entry>
19709 <entry>Default: <emphasis>false</emphasis></entry>
19710 </row>
19711 </tbody>
19712 </tgroup>
19713 </informaltable>
19714 <para>
19715 <indexterm role="concept">
19716 <primary>domain</primary>
19717 <secondary>UTF-8 characters in</secondary>
19718 </indexterm>
19719 <indexterm role="concept">
19720 <primary>UTF-8</primary>
19721 <secondary>in domain name</secondary>
19722 </indexterm>
19723 Lots of discussion is going on about internationalized domain names. One
19724 camp is strongly in favour of just using UTF-8 characters, and it seems
19725 that at least two other MTAs permit this. This option allows Exim users to
19726 experiment if they wish.
19727 </para>
19728 <para>
19729 If it is set true, Exim&#x2019;s domain parsing function allows valid
19730 UTF-8 multicharacters to appear in domain name components, in addition to
19731 letters, digits, and hyphens. However, just setting this option is not
19732 enough; if you want to look up these domain names in the DNS, you must also
19733 adjust the value of <option>dns_check_names_pattern</option> to match the extended form. A
19734 suitable setting is:
19735 </para>
19736 <literallayout class="monospaced">
19737 dns_check_names_pattern = (?i)^(?&gt;(?(1)\.|())[a-z0-9\xc0-\xff]\
19738   (?&gt;[-a-z0-9\x80-\xff]*[a-z0-9\x80-\xbf])?)+$
19739 </literallayout>
19740 <para>
19741 Alternatively, you can just disable this feature by setting
19742 </para>
19743 <literallayout class="monospaced">
19744 dns_check_names_pattern =
19745 </literallayout>
19746 <para>
19747 That is, set the option to an empty string so that no check is done.
19748 </para>
19749 <para>
19750 <indexterm role="option">
19751 <primary>auth_advertise_hosts</primary>
19752 </indexterm>
19753 </para>
19754 <informaltable frame="all">
19755 <tgroup cols="4" colsep="0" rowsep="0">
19756 <colspec colwidth="8*" align="left"/>
19757 <colspec colwidth="5*" align="center"/>
19758 <colspec colwidth="5*" align="center"/>
19759 <colspec colwidth="6*" align="right"/>
19760 <tbody>
19761 <row>
19762 <entry><option>auth_advertise_hosts</option></entry>
19763 <entry>Use: <emphasis>main</emphasis></entry>
19764 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
19765 <entry>Default: <emphasis>*</emphasis></entry>
19766 </row>
19767 </tbody>
19768 </tgroup>
19769 </informaltable>
19770 <para>
19771 <indexterm role="concept">
19772 <primary>authentication</primary>
19773 <secondary>advertising</secondary>
19774 </indexterm>
19775 <indexterm role="concept">
19776 <primary>AUTH</primary>
19777 <secondary>advertising</secondary>
19778 </indexterm>
19779 If any server authentication mechanisms are configured, Exim advertises them in
19780 response to an EHLO command only if the calling host matches this list.
19781 Otherwise, Exim does not advertise AUTH.
19782 Exim does not accept AUTH commands from clients to which it has not
19783 advertised the availability of AUTH. The advertising of individual
19784 authentication mechanisms can be controlled by the use of the
19785 <option>server_advertise_condition</option> generic authenticator option on the individual
19786 authenticators. See chapter <xref linkend="CHAPSMTPAUTH"/> for further details.
19787 </para>
19788 <para>
19789 Certain mail clients (for example, Netscape) require the user to provide a name
19790 and password for authentication if AUTH is advertised, even though it may
19791 not be needed (the host may accept messages from hosts on its local LAN without
19792 authentication, for example). The <option>auth_advertise_hosts</option> option can be used
19793 to make these clients more friendly by excluding them from the set of hosts to
19794 which Exim advertises AUTH.
19795 </para>
19796 <para>
19797 <indexterm role="concept">
19798 <primary>AUTH</primary>
19799 <secondary>advertising when encrypted</secondary>
19800 </indexterm>
19801 If you want to advertise the availability of AUTH only when the connection
19802 is encrypted using TLS, you can make use of the fact that the value of this
19803 option is expanded, with a setting like this:
19804 </para>
19805 <literallayout class="monospaced">
19806 auth_advertise_hosts = ${if eq{$tls_cipher}{}{}{*}}
19807 </literallayout>
19808 <para>
19809 <indexterm role="concept">
19810 <primary><varname>$tls_cipher</varname></primary>
19811 </indexterm>
19812 If <varname>$tls_cipher</varname> is empty, the session is not encrypted, and the result of
19813 the expansion is empty, thus matching no hosts. Otherwise, the result of the
19814 expansion is *, which matches all hosts.
19815 </para>
19816 <para>
19817 <indexterm role="option">
19818 <primary>auto_thaw</primary>
19819 </indexterm>
19820 </para>
19821 <informaltable frame="all">
19822 <tgroup cols="4" colsep="0" rowsep="0">
19823 <colspec colwidth="8*" align="left"/>
19824 <colspec colwidth="5*" align="center"/>
19825 <colspec colwidth="5*" align="center"/>
19826 <colspec colwidth="6*" align="right"/>
19827 <tbody>
19828 <row>
19829 <entry><option>auto_thaw</option></entry>
19830 <entry>Use: <emphasis>main</emphasis></entry>
19831 <entry>Type: <emphasis>time</emphasis></entry>
19832 <entry>Default: <emphasis>0s</emphasis></entry>
19833 </row>
19834 </tbody>
19835 </tgroup>
19836 </informaltable>
19837 <para>
19838 <indexterm role="concept">
19839 <primary>thawing messages</primary>
19840 </indexterm>
19841 <indexterm role="concept">
19842 <primary>unfreezing messages</primary>
19843 </indexterm>
19844 If this option is set to a time greater than zero, a queue runner will try a
19845 new delivery attempt on any frozen message, other than a bounce message, if
19846 this much time has passed since it was frozen. This may result in the message
19847 being re-frozen if nothing has changed since the last attempt. It is a way of
19848 saying <quote>keep on trying, even though there are big problems</quote>.
19849 </para>
19850 <para>
19851 <emphasis role="bold">Note</emphasis>: This is an old option, which predates <option>timeout_frozen_after</option> and
19852 <option>ignore_bounce_errors_after</option>. It is retained for compatibility, but it is not
19853 thought to be very useful any more, and its use should probably be avoided.
19854 </para>
19855 <para>
19856 <indexterm role="option">
19857 <primary>av_scanner</primary>
19858 </indexterm>
19859 </para>
19860 <informaltable frame="all">
19861 <tgroup cols="4" colsep="0" rowsep="0">
19862 <colspec colwidth="8*" align="left"/>
19863 <colspec colwidth="5*" align="center"/>
19864 <colspec colwidth="5*" align="center"/>
19865 <colspec colwidth="6*" align="right"/>
19866 <tbody>
19867 <row>
19868 <entry><option>av_scanner</option></entry>
19869 <entry>Use: <emphasis>main</emphasis></entry>
19870 <entry>Type: <emphasis>string</emphasis></entry>
19871 <entry>Default: <emphasis>see below</emphasis></entry>
19872 </row>
19873 </tbody>
19874 </tgroup>
19875 </informaltable>
19876 <para>
19877 This option is available if Exim is built with the content-scanning extension.
19878 It specifies which anti-virus scanner to use. The default value is:
19879 </para>
19880 <literallayout class="monospaced">
19881 sophie:/var/run/sophie
19882 </literallayout>
19883 <para>
19884 If the value of <option>av_scanner</option> starts with dollar character, it is expanded
19885 before use. See section <xref linkend="SECTscanvirus"/> for further details.
19886 </para>
19887 <para>
19888 <indexterm role="option">
19889 <primary>bi_command</primary>
19890 </indexterm>
19891 </para>
19892 <informaltable frame="all">
19893 <tgroup cols="4" colsep="0" rowsep="0">
19894 <colspec colwidth="8*" align="left"/>
19895 <colspec colwidth="5*" align="center"/>
19896 <colspec colwidth="5*" align="center"/>
19897 <colspec colwidth="6*" align="right"/>
19898 <tbody>
19899 <row>
19900 <entry><option>bi_command</option></entry>
19901 <entry>Use: <emphasis>main</emphasis></entry>
19902 <entry>Type: <emphasis>string</emphasis></entry>
19903 <entry>Default: <emphasis>unset</emphasis></entry>
19904 </row>
19905 </tbody>
19906 </tgroup>
19907 </informaltable>
19908 <para>
19909 <indexterm role="concept">
19910 <primary><option>-bi</option> option</primary>
19911 </indexterm>
19912 This option supplies the name of a command that is run when Exim is called with
19913 the <option>-bi</option> option (see chapter <xref linkend="CHAPcommandline"/>). The string value is
19914 just the command name, it is not a complete command line. If an argument is
19915 required, it must come from the <option>-oA</option> command line option.
19916 </para>
19917 <para>
19918 <indexterm role="option">
19919 <primary>bounce_message_file</primary>
19920 </indexterm>
19921 </para>
19922 <informaltable frame="all">
19923 <tgroup cols="4" colsep="0" rowsep="0">
19924 <colspec colwidth="8*" align="left"/>
19925 <colspec colwidth="5*" align="center"/>
19926 <colspec colwidth="5*" align="center"/>
19927 <colspec colwidth="6*" align="right"/>
19928 <tbody>
19929 <row>
19930 <entry><option>bounce_message_file</option></entry>
19931 <entry>Use: <emphasis>main</emphasis></entry>
19932 <entry>Type: <emphasis>string</emphasis></entry>
19933 <entry>Default: <emphasis>unset</emphasis></entry>
19934 </row>
19935 </tbody>
19936 </tgroup>
19937 </informaltable>
19938 <para>
19939 <indexterm role="concept">
19940 <primary>bounce message</primary>
19941 <secondary>customizing</secondary>
19942 </indexterm>
19943 <indexterm role="concept">
19944 <primary>customizing</primary>
19945 <secondary>bounce message</secondary>
19946 </indexterm>
19947 This option defines a template file containing paragraphs of text to be used
19948 for constructing bounce messages.  Details of the file&#x2019;s contents are given in
19949 chapter <xref linkend="CHAPemsgcust"/>. See also <option>warn_message_file</option>.
19950 </para>
19951 <para>
19952 <indexterm role="option">
19953 <primary>bounce_message_text</primary>
19954 </indexterm>
19955 </para>
19956 <informaltable frame="all">
19957 <tgroup cols="4" colsep="0" rowsep="0">
19958 <colspec colwidth="8*" align="left"/>
19959 <colspec colwidth="5*" align="center"/>
19960 <colspec colwidth="5*" align="center"/>
19961 <colspec colwidth="6*" align="right"/>
19962 <tbody>
19963 <row>
19964 <entry><option>bounce_message_text</option></entry>
19965 <entry>Use: <emphasis>main</emphasis></entry>
19966 <entry>Type: <emphasis>string</emphasis></entry>
19967 <entry>Default: <emphasis>unset</emphasis></entry>
19968 </row>
19969 </tbody>
19970 </tgroup>
19971 </informaltable>
19972 <para>
19973 When this option is set, its contents are included in the default bounce
19974 message immediately after <quote>This message was created automatically by mail
19975 delivery software.</quote> It is not used if <option>bounce_message_file</option> is set.
19976 </para>
19977 <para>
19978 <indexterm role="option">
19979 <primary>bounce_return_body</primary>
19980 </indexterm>
19981 </para>
19982 <informaltable frame="all">
19983 <tgroup cols="4" colsep="0" rowsep="0">
19984 <colspec colwidth="8*" align="left"/>
19985 <colspec colwidth="5*" align="center"/>
19986 <colspec colwidth="5*" align="center"/>
19987 <colspec colwidth="6*" align="right"/>
19988 <tbody>
19989 <row>
19990 <entry><option>bounce_return_body</option></entry>
19991 <entry>Use: <emphasis>main</emphasis></entry>
19992 <entry>Type: <emphasis>boolean</emphasis></entry>
19993 <entry>Default: <emphasis>true</emphasis></entry>
19994 </row>
19995 </tbody>
19996 </tgroup>
19997 </informaltable>
19998 <para>
19999 <indexterm role="concept">
20000 <primary>bounce message</primary>
20001 <secondary>including body</secondary>
20002 </indexterm>
20003 </para>
20004 <para revisionflag="changed">
20005 This option controls whether the body of an incoming message is included in a
20006 bounce message when <option>bounce_return_message</option> is true. The default setting
20007 causes the entire message, both header and body, to be returned (subject to the
20008 value of <option>bounce_return_size_limit</option>). If this option is false, only the
20009 message header is included. In the case of a non-SMTP message containing an
20010 error that is detected during reception, only those header lines preceding the
20011 point at which the error was detected are returned.
20012 <indexterm role="concept">
20013 <primary>bounce message</primary>
20014 <secondary>including original</secondary>
20015 </indexterm>
20016 </para>
20017 <para>
20018 <indexterm role="option">
20019 <primary>bounce_return_message</primary>
20020 </indexterm>
20021 </para>
20022 <informaltable frame="all">
20023 <tgroup cols="4" colsep="0" rowsep="0">
20024 <colspec colwidth="8*" align="left"/>
20025 <colspec colwidth="5*" align="center"/>
20026 <colspec colwidth="5*" align="center"/>
20027 <colspec colwidth="6*" align="right"/>
20028 <tbody>
20029 <row>
20030 <entry><option>bounce_return_message</option></entry>
20031 <entry>Use: <emphasis>main</emphasis></entry>
20032 <entry>Type: <emphasis>boolean</emphasis></entry>
20033 <entry>Default: <emphasis>true</emphasis></entry>
20034 </row>
20035 </tbody>
20036 </tgroup>
20037 </informaltable>
20038 <para revisionflag="changed">
20039 If this option is set false, none of the original message is included in
20040 bounce messages generated by Exim. See also <option>bounce_return_size_limit</option> and
20041 <option>bounce_return_body</option>.
20042 </para>
20043 <para>
20044 <indexterm role="option">
20045 <primary>bounce_return_size_limit</primary>
20046 </indexterm>
20047 </para>
20048 <informaltable frame="all">
20049 <tgroup cols="4" colsep="0" rowsep="0">
20050 <colspec colwidth="8*" align="left"/>
20051 <colspec colwidth="5*" align="center"/>
20052 <colspec colwidth="5*" align="center"/>
20053 <colspec colwidth="6*" align="right"/>
20054 <tbody>
20055 <row>
20056 <entry><option>bounce_return_size_limit</option></entry>
20057 <entry>Use: <emphasis>main</emphasis></entry>
20058 <entry>Type: <emphasis>integer</emphasis></entry>
20059 <entry>Default: <emphasis>100K</emphasis></entry>
20060 </row>
20061 </tbody>
20062 </tgroup>
20063 </informaltable>
20064 <para>
20065 <indexterm role="concept">
20066 <primary>size limit</primary>
20067 <secondary>of bounce</secondary>
20068 </indexterm>
20069 <indexterm role="concept">
20070 <primary>bounce message</primary>
20071 <secondary>size limit</secondary>
20072 </indexterm>
20073 <indexterm role="concept">
20074 <primary>limit</primary>
20075 <secondary>bounce message size</secondary>
20076 </indexterm>
20077 This option sets a limit in bytes on the size of messages that are returned to
20078 senders as part of bounce messages when <option>bounce_return_message</option> is true. The
20079 limit should be less than the value of the global <option>message_size_limit</option> and of
20080 any <option>message_size_limit</option> settings on transports, to allow for the bounce text
20081 that Exim generates. If this option is set to zero there is no limit.
20082 </para>
20083 <para>
20084 When the body of any message that is to be included in a bounce message is
20085 greater than the limit, it is truncated, and a comment pointing this out is
20086 added at the top. The actual cutoff may be greater than the value given, owing
20087 to the use of buffering for transferring the message in chunks (typically 8K in
20088 size). The idea is to save bandwidth on those undeliverable 15-megabyte
20089 messages.
20090 </para>
20091 <para>
20092 <indexterm role="option">
20093 <primary>bounce_sender_authentication</primary>
20094 </indexterm>
20095 </para>
20096 <informaltable frame="all">
20097 <tgroup cols="4" colsep="0" rowsep="0">
20098 <colspec colwidth="8*" align="left"/>
20099 <colspec colwidth="5*" align="center"/>
20100 <colspec colwidth="5*" align="center"/>
20101 <colspec colwidth="6*" align="right"/>
20102 <tbody>
20103 <row>
20104 <entry><option>bounce_sender_authentication</option></entry>
20105 <entry>Use: <emphasis>main</emphasis></entry>
20106 <entry>Type: <emphasis>string</emphasis></entry>
20107 <entry>Default: <emphasis>unset</emphasis></entry>
20108 </row>
20109 </tbody>
20110 </tgroup>
20111 </informaltable>
20112 <para>
20113 <indexterm role="concept">
20114 <primary>bounce message</primary>
20115 <secondary>sender authentication</secondary>
20116 </indexterm>
20117 <indexterm role="concept">
20118 <primary>authentication</primary>
20119 <secondary>bounce message</secondary>
20120 </indexterm>
20121 <indexterm role="concept">
20122 <primary>AUTH</primary>
20123 <secondary>on bounce message</secondary>
20124 </indexterm>
20125 This option provides an authenticated sender address that is sent with any
20126 bounce messages generated by Exim that are sent over an authenticated SMTP
20127 connection. A typical setting might be:
20128 </para>
20129 <literallayout class="monospaced">
20130 bounce_sender_authentication = mailer-daemon@my.domain.example
20131 </literallayout>
20132 <para>
20133 which would cause bounce messages to be sent using the SMTP command:
20134 </para>
20135 <literallayout class="monospaced">
20136 MAIL FROM:&lt;&gt; AUTH=mailer-daemon@my.domain.example
20137 </literallayout>
20138 <para>
20139 The value of <option>bounce_sender_authentication</option> must always be a complete email
20140 address.
20141 </para>
20142 <para>
20143 <indexterm role="option">
20144 <primary>callout_domain_negative_expire</primary>
20145 </indexterm>
20146 </para>
20147 <informaltable frame="all">
20148 <tgroup cols="4" colsep="0" rowsep="0">
20149 <colspec colwidth="8*" align="left"/>
20150 <colspec colwidth="5*" align="center"/>
20151 <colspec colwidth="5*" align="center"/>
20152 <colspec colwidth="6*" align="right"/>
20153 <tbody>
20154 <row>
20155 <entry><option>callout_domain_negative_expire</option></entry>
20156 <entry>Use: <emphasis>main</emphasis></entry>
20157 <entry>Type: <emphasis>time</emphasis></entry>
20158 <entry>Default: <emphasis>3h</emphasis></entry>
20159 </row>
20160 </tbody>
20161 </tgroup>
20162 </informaltable>
20163 <para>
20164 <indexterm role="concept">
20165 <primary>caching</primary>
20166 <secondary>callout timeouts</secondary>
20167 </indexterm>
20168 <indexterm role="concept">
20169 <primary>callout</primary>
20170 <secondary>caching timeouts</secondary>
20171 </indexterm>
20172 This option specifies the expiry time for negative callout cache data for a
20173 domain. See section <xref linkend="SECTcallver"/> for details of callout verification, and
20174 section <xref linkend="SECTcallvercache"/> for details of the caching.
20175 </para>
20176 <para>
20177 <indexterm role="option">
20178 <primary>callout_domain_positive_expire</primary>
20179 </indexterm>
20180 </para>
20181 <informaltable frame="all">
20182 <tgroup cols="4" colsep="0" rowsep="0">
20183 <colspec colwidth="8*" align="left"/>
20184 <colspec colwidth="5*" align="center"/>
20185 <colspec colwidth="5*" align="center"/>
20186 <colspec colwidth="6*" align="right"/>
20187 <tbody>
20188 <row>
20189 <entry><option>callout_domain_positive_expire</option></entry>
20190 <entry>Use: <emphasis>main</emphasis></entry>
20191 <entry>Type: <emphasis>time</emphasis></entry>
20192 <entry>Default: <emphasis>7d</emphasis></entry>
20193 </row>
20194 </tbody>
20195 </tgroup>
20196 </informaltable>
20197 <para>
20198 This option specifies the expiry time for positive callout cache data for a
20199 domain. See section <xref linkend="SECTcallver"/> for details of callout verification, and
20200 section <xref linkend="SECTcallvercache"/> for details of the caching.
20201 </para>
20202 <para>
20203 <indexterm role="option">
20204 <primary>callout_negative_expire</primary>
20205 </indexterm>
20206 </para>
20207 <informaltable frame="all">
20208 <tgroup cols="4" colsep="0" rowsep="0">
20209 <colspec colwidth="8*" align="left"/>
20210 <colspec colwidth="5*" align="center"/>
20211 <colspec colwidth="5*" align="center"/>
20212 <colspec colwidth="6*" align="right"/>
20213 <tbody>
20214 <row>
20215 <entry><option>callout_negative_expire</option></entry>
20216 <entry>Use: <emphasis>main</emphasis></entry>
20217 <entry>Type: <emphasis>time</emphasis></entry>
20218 <entry>Default: <emphasis>2h</emphasis></entry>
20219 </row>
20220 </tbody>
20221 </tgroup>
20222 </informaltable>
20223 <para>
20224 This option specifies the expiry time for negative callout cache data for an
20225 address. See section <xref linkend="SECTcallver"/> for details of callout verification, and
20226 section <xref linkend="SECTcallvercache"/> for details of the caching.
20227 </para>
20228 <para>
20229 <indexterm role="option">
20230 <primary>callout_positive_expire</primary>
20231 </indexterm>
20232 </para>
20233 <informaltable frame="all">
20234 <tgroup cols="4" colsep="0" rowsep="0">
20235 <colspec colwidth="8*" align="left"/>
20236 <colspec colwidth="5*" align="center"/>
20237 <colspec colwidth="5*" align="center"/>
20238 <colspec colwidth="6*" align="right"/>
20239 <tbody>
20240 <row>
20241 <entry><option>callout_positive_expire</option></entry>
20242 <entry>Use: <emphasis>main</emphasis></entry>
20243 <entry>Type: <emphasis>time</emphasis></entry>
20244 <entry>Default: <emphasis>24h</emphasis></entry>
20245 </row>
20246 </tbody>
20247 </tgroup>
20248 </informaltable>
20249 <para>
20250 This option specifies the expiry time for positive callout cache data for an
20251 address. See section <xref linkend="SECTcallver"/> for details of callout verification, and
20252 section <xref linkend="SECTcallvercache"/> for details of the caching.
20253 </para>
20254 <para>
20255 <indexterm role="option">
20256 <primary>callout_random_local_part</primary>
20257 </indexterm>
20258 </para>
20259 <informaltable frame="all">
20260 <tgroup cols="4" colsep="0" rowsep="0">
20261 <colspec colwidth="8*" align="left"/>
20262 <colspec colwidth="5*" align="center"/>
20263 <colspec colwidth="5*" align="center"/>
20264 <colspec colwidth="6*" align="right"/>
20265 <tbody>
20266 <row>
20267 <entry><option>callout_random_local_part</option></entry>
20268 <entry>Use: <emphasis>main</emphasis></entry>
20269 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20270 <entry>Default: <emphasis>see below</emphasis></entry>
20271 </row>
20272 </tbody>
20273 </tgroup>
20274 </informaltable>
20275 <para>
20276 This option defines the <quote>random</quote> local part that can be used as part of
20277 callout verification. The default value is
20278 </para>
20279 <literallayout class="monospaced">
20280 $primary_host_name-$tod_epoch-testing
20281 </literallayout>
20282 <para>
20283 See section <xref linkend="CALLaddparcall"/> for details of how this value is used.
20284 </para>
20285 <para>
20286 <indexterm role="option">
20287 <primary>check_log_inodes</primary>
20288 </indexterm>
20289 </para>
20290 <informaltable frame="all">
20291 <tgroup cols="4" colsep="0" rowsep="0">
20292 <colspec colwidth="8*" align="left"/>
20293 <colspec colwidth="5*" align="center"/>
20294 <colspec colwidth="5*" align="center"/>
20295 <colspec colwidth="6*" align="right"/>
20296 <tbody>
20297 <row>
20298 <entry><option>check_log_inodes</option></entry>
20299 <entry>Use: <emphasis>main</emphasis></entry>
20300 <entry>Type: <emphasis>integer</emphasis></entry>
20301 <entry>Default: <emphasis>0</emphasis></entry>
20302 </row>
20303 </tbody>
20304 </tgroup>
20305 </informaltable>
20306 <para>
20307 See <option>check_spool_space</option> below.
20308 </para>
20309 <para>
20310 <indexterm role="option">
20311 <primary>check_log_space</primary>
20312 </indexterm>
20313 </para>
20314 <informaltable frame="all">
20315 <tgroup cols="4" colsep="0" rowsep="0">
20316 <colspec colwidth="8*" align="left"/>
20317 <colspec colwidth="5*" align="center"/>
20318 <colspec colwidth="5*" align="center"/>
20319 <colspec colwidth="6*" align="right"/>
20320 <tbody>
20321 <row>
20322 <entry><option>check_log_space</option></entry>
20323 <entry>Use: <emphasis>main</emphasis></entry>
20324 <entry>Type: <emphasis>integer</emphasis></entry>
20325 <entry>Default: <emphasis>0</emphasis></entry>
20326 </row>
20327 </tbody>
20328 </tgroup>
20329 </informaltable>
20330 <para>
20331 See <option>check_spool_space</option> below.
20332 </para>
20333 <para>
20334 <indexterm role="option">
20335 <primary><option>check_rfc2047_length</option></primary>
20336 </indexterm>
20337 <indexterm role="concept">
20338 <primary>RFC 2047</primary>
20339 <secondary>disabling length check</secondary>
20340 </indexterm>
20341 <indexterm role="option">
20342 <primary>check_rfc2047_length</primary>
20343 </indexterm>
20344 </para>
20345 <informaltable frame="all">
20346 <tgroup cols="4" colsep="0" rowsep="0">
20347 <colspec colwidth="8*" align="left"/>
20348 <colspec colwidth="5*" align="center"/>
20349 <colspec colwidth="5*" align="center"/>
20350 <colspec colwidth="6*" align="right"/>
20351 <tbody>
20352 <row>
20353 <entry><option>check_rfc2047_length</option></entry>
20354 <entry>Use: <emphasis> User: main</emphasis></entry>
20355 <entry>Type: <emphasis>boolean</emphasis></entry>
20356 <entry>Default: <emphasis>true</emphasis></entry>
20357 </row>
20358 </tbody>
20359 </tgroup>
20360 </informaltable>
20361 <para>
20362 RFC 2047 defines a way of encoding non-ASCII characters in headers using a
20363 system of <quote>encoded words</quote>. The RFC specifies a maximum length for an encoded
20364 word; strings to be encoded that exceed this length are supposed to use
20365 multiple encoded words. By default, Exim does not recognize encoded words that
20366 exceed the maximum length. However, it seems that some software, in violation
20367 of the RFC, generates overlong encoded words. If <option>check_rfc2047_length</option> is
20368 set false, Exim recognizes encoded words of any length.
20369 </para>
20370 <para>
20371 <indexterm role="option">
20372 <primary>check_spool_inodes</primary>
20373 </indexterm>
20374 </para>
20375 <informaltable frame="all">
20376 <tgroup cols="4" colsep="0" rowsep="0">
20377 <colspec colwidth="8*" align="left"/>
20378 <colspec colwidth="5*" align="center"/>
20379 <colspec colwidth="5*" align="center"/>
20380 <colspec colwidth="6*" align="right"/>
20381 <tbody>
20382 <row>
20383 <entry><option>check_spool_inodes</option></entry>
20384 <entry>Use: <emphasis>main</emphasis></entry>
20385 <entry>Type: <emphasis>integer</emphasis></entry>
20386 <entry>Default: <emphasis>0</emphasis></entry>
20387 </row>
20388 </tbody>
20389 </tgroup>
20390 </informaltable>
20391 <para>
20392 See <option>check_spool_space</option> below.
20393 </para>
20394 <para>
20395 <indexterm role="option">
20396 <primary>check_spool_space</primary>
20397 </indexterm>
20398 </para>
20399 <informaltable frame="all">
20400 <tgroup cols="4" colsep="0" rowsep="0">
20401 <colspec colwidth="8*" align="left"/>
20402 <colspec colwidth="5*" align="center"/>
20403 <colspec colwidth="5*" align="center"/>
20404 <colspec colwidth="6*" align="right"/>
20405 <tbody>
20406 <row>
20407 <entry><option>check_spool_space</option></entry>
20408 <entry>Use: <emphasis>main</emphasis></entry>
20409 <entry>Type: <emphasis>integer</emphasis></entry>
20410 <entry>Default: <emphasis>0</emphasis></entry>
20411 </row>
20412 </tbody>
20413 </tgroup>
20414 </informaltable>
20415 <para>
20416 <indexterm role="concept">
20417 <primary>checking disk space</primary>
20418 </indexterm>
20419 <indexterm role="concept">
20420 <primary>disk space</primary>
20421 <secondary>checking</secondary>
20422 </indexterm>
20423 <indexterm role="concept">
20424 <primary>spool directory</primary>
20425 <secondary>checking space</secondary>
20426 </indexterm>
20427 The four <option>check_...</option> options allow for checking of disk resources before a
20428 message is accepted.
20429 </para>
20430 <para>
20431 <indexterm role="concept">
20432 <primary><varname>$log_inodes</varname></primary>
20433 </indexterm>
20434 <indexterm role="concept">
20435 <primary><varname>$log_space</varname></primary>
20436 </indexterm>
20437 <indexterm role="concept">
20438 <primary><varname>$spool_inodes</varname></primary>
20439 </indexterm>
20440 <indexterm role="concept">
20441 <primary><varname>$spool_space</varname></primary>
20442 </indexterm>
20443 When any of these options are set, they apply to all incoming messages. If you
20444 want to apply different checks to different kinds of message, you can do so by
20445 testing the the variables <varname>$log_inodes</varname>, <varname>$log_space</varname>, <varname>$spool_inodes</varname>, and
20446 <varname>$spool_space</varname> in an ACL with appropriate additional conditions.
20447 </para>
20448 <para>
20449 <option>check_spool_space</option> and <option>check_spool_inodes</option> check the spool partition if
20450 either value is greater than zero, for example:
20451 </para>
20452 <literallayout class="monospaced">
20453 check_spool_space = 10M
20454 check_spool_inodes = 100
20455 </literallayout>
20456 <para>
20457 The spool partition is the one that contains the directory defined by
20458 SPOOL_DIRECTORY in <filename>Local/Makefile</filename>. It is used for holding messages in
20459 transit.
20460 </para>
20461 <para>
20462 <option>check_log_space</option> and <option>check_log_inodes</option>  check the partition in which log
20463 files are written if either is greater than zero. These should be set only if
20464 <option>log_file_path</option> and <option>spool_directory</option> refer to different partitions.
20465 </para>
20466 <para>
20467 If there is less space or fewer inodes than requested, Exim refuses to accept
20468 incoming mail. In the case of SMTP input this is done by giving a 452 temporary
20469 error response to the MAIL command. If ESMTP is in use and there was a
20470 SIZE parameter on the MAIL command, its value is added to the
20471 <option>check_spool_space</option> value, and the check is performed even if
20472 <option>check_spool_space</option> is zero, unless <option>no_smtp_check_spool_space</option> is set.
20473 </para>
20474 <para>
20475 The values for <option>check_spool_space</option> and <option>check_log_space</option> are held as a
20476 number of kilobytes. If a non-multiple of 1024 is specified, it is rounded up.
20477 </para>
20478 <para>
20479 For non-SMTP input and for batched SMTP input, the test is done at start-up; on
20480 failure a message is written to stderr and Exim exits with a non-zero code, as
20481 it obviously cannot send an error message of any kind.
20482 </para>
20483 <para>
20484 <indexterm role="option">
20485 <primary>daemon_smtp_ports</primary>
20486 </indexterm>
20487 </para>
20488 <informaltable frame="all">
20489 <tgroup cols="4" colsep="0" rowsep="0">
20490 <colspec colwidth="8*" align="left"/>
20491 <colspec colwidth="5*" align="center"/>
20492 <colspec colwidth="5*" align="center"/>
20493 <colspec colwidth="6*" align="right"/>
20494 <tbody>
20495 <row>
20496 <entry><option>daemon_smtp_ports</option></entry>
20497 <entry>Use: <emphasis>main</emphasis></entry>
20498 <entry>Type: <emphasis>string</emphasis></entry>
20499 <entry>Default: <emphasis><literal>smtp</literal></emphasis></entry>
20500 </row>
20501 </tbody>
20502 </tgroup>
20503 </informaltable>
20504 <para>
20505 <indexterm role="concept">
20506 <primary>port</primary>
20507 <secondary>for daemon</secondary>
20508 </indexterm>
20509 <indexterm role="concept">
20510 <primary>TCP/IP</primary>
20511 <secondary>setting listening ports</secondary>
20512 </indexterm>
20513 This option specifies one or more default SMTP ports on which the Exim daemon
20514 listens. See chapter <xref linkend="CHAPinterfaces"/> for details of how it is used. For
20515 backward compatibility, <option>daemon_smtp_port</option> (singular) is a synonym.
20516 </para>
20517 <para>
20518 <indexterm role="option">
20519 <primary>daemon_startup_retries</primary>
20520 </indexterm>
20521 </para>
20522 <informaltable frame="all">
20523 <tgroup cols="4" colsep="0" rowsep="0">
20524 <colspec colwidth="8*" align="left"/>
20525 <colspec colwidth="5*" align="center"/>
20526 <colspec colwidth="5*" align="center"/>
20527 <colspec colwidth="6*" align="right"/>
20528 <tbody>
20529 <row>
20530 <entry><option>daemon_startup_retries</option></entry>
20531 <entry>Use: <emphasis>main</emphasis></entry>
20532 <entry>Type: <emphasis>integer</emphasis></entry>
20533 <entry>Default: <emphasis>9</emphasis></entry>
20534 </row>
20535 </tbody>
20536 </tgroup>
20537 </informaltable>
20538 <para>
20539 <indexterm role="concept">
20540 <primary>daemon startup</primary>
20541 <secondary>retrying</secondary>
20542 </indexterm>
20543 This option, along with <option>daemon_startup_sleep</option>, controls the retrying done by
20544 the daemon at startup when it cannot immediately bind a listening socket
20545 (typically because the socket is already in use): <option>daemon_startup_retries</option>
20546 defines the number of retries after the first failure, and
20547 <option>daemon_startup_sleep</option> defines the length of time to wait between retries.
20548 </para>
20549 <para>
20550 <indexterm role="option">
20551 <primary>daemon_startup_sleep</primary>
20552 </indexterm>
20553 </para>
20554 <informaltable frame="all">
20555 <tgroup cols="4" colsep="0" rowsep="0">
20556 <colspec colwidth="8*" align="left"/>
20557 <colspec colwidth="5*" align="center"/>
20558 <colspec colwidth="5*" align="center"/>
20559 <colspec colwidth="6*" align="right"/>
20560 <tbody>
20561 <row>
20562 <entry><option>daemon_startup_sleep</option></entry>
20563 <entry>Use: <emphasis>main</emphasis></entry>
20564 <entry>Type: <emphasis>time</emphasis></entry>
20565 <entry>Default: <emphasis>30s</emphasis></entry>
20566 </row>
20567 </tbody>
20568 </tgroup>
20569 </informaltable>
20570 <para>
20571 See <option>daemon_startup_retries</option>.
20572 </para>
20573 <para>
20574 <indexterm role="option">
20575 <primary>delay_warning</primary>
20576 </indexterm>
20577 </para>
20578 <informaltable frame="all">
20579 <tgroup cols="4" colsep="0" rowsep="0">
20580 <colspec colwidth="8*" align="left"/>
20581 <colspec colwidth="5*" align="center"/>
20582 <colspec colwidth="5*" align="center"/>
20583 <colspec colwidth="6*" align="right"/>
20584 <tbody>
20585 <row>
20586 <entry><option>delay_warning</option></entry>
20587 <entry>Use: <emphasis>main</emphasis></entry>
20588 <entry>Type: <emphasis>time list</emphasis></entry>
20589 <entry>Default: <emphasis>24h</emphasis></entry>
20590 </row>
20591 </tbody>
20592 </tgroup>
20593 </informaltable>
20594 <para>
20595 <indexterm role="concept">
20596 <primary>warning of delay</primary>
20597 </indexterm>
20598 <indexterm role="concept">
20599 <primary>delay warning</primary>
20600 <secondary>specifying</secondary>
20601 </indexterm>
20602 When a message is delayed, Exim sends a warning message to the sender at
20603 intervals specified by this option. The data is a colon-separated list of times
20604 after which to send warning messages. If the value of the option is an empty
20605 string or a zero time, no warnings are sent. Up to 10 times may be given. If a
20606 message has been on the queue for longer than the last time, the last interval
20607 between the times is used to compute subsequent warning times. For example,
20608 with
20609 </para>
20610 <literallayout class="monospaced">
20611 delay_warning = 4h:8h:24h
20612 </literallayout>
20613 <para>
20614 the first message is sent after 4 hours, the second after 8 hours, and
20615 the third one after 24 hours. After that, messages are sent every 16 hours,
20616 because that is the interval between the last two times on the list. If you set
20617 just one time, it specifies the repeat interval. For example, with:
20618 </para>
20619 <literallayout class="monospaced">
20620 delay_warning = 6h
20621 </literallayout>
20622 <para>
20623 messages are repeated every six hours. To stop warnings after a given time, set
20624 a very large time at the end of the list. For example:
20625 </para>
20626 <literallayout class="monospaced">
20627 delay_warning = 2h:12h:99d
20628 </literallayout>
20629 <para>
20630 <indexterm role="option">
20631 <primary>delay_warning_condition</primary>
20632 </indexterm>
20633 </para>
20634 <informaltable frame="all">
20635 <tgroup cols="4" colsep="0" rowsep="0">
20636 <colspec colwidth="8*" align="left"/>
20637 <colspec colwidth="5*" align="center"/>
20638 <colspec colwidth="5*" align="center"/>
20639 <colspec colwidth="6*" align="right"/>
20640 <tbody>
20641 <row>
20642 <entry><option>delay_warning_condition</option></entry>
20643 <entry>Use: <emphasis>main</emphasis></entry>
20644 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20645 <entry>Default: <emphasis>see below</emphasis></entry>
20646 </row>
20647 </tbody>
20648 </tgroup>
20649 </informaltable>
20650 <para>
20651 <indexterm role="concept">
20652 <primary><varname>$domain</varname></primary>
20653 </indexterm>
20654 The string is expanded at the time a warning message might be sent. If all the
20655 deferred addresses have the same domain, it is set in <varname>$domain</varname> during the
20656 expansion. Otherwise <varname>$domain</varname> is empty. If the result of the expansion is a
20657 forced failure, an empty string, or a string matching any of <quote>0</quote>, <quote>no</quote> or
20658 <quote>false</quote> (the comparison being done caselessly) then the warning message is
20659 not sent. The default is
20660 </para>
20661 <literallayout class="monospaced">
20662 delay_warning_condition = \
20663   ${if match{$h_precedence:}{(?i)bulk|list|junk}{no}{yes}}
20664 </literallayout>
20665 <para>
20666 which suppresses the sending of warnings about messages that have <quote>bulk</quote>,
20667 <quote>list</quote> or <quote>junk</quote> in a <emphasis>Precedence:</emphasis> header.
20668 </para>
20669 <para>
20670 <indexterm role="option">
20671 <primary>deliver_drop_privilege</primary>
20672 </indexterm>
20673 </para>
20674 <informaltable frame="all">
20675 <tgroup cols="4" colsep="0" rowsep="0">
20676 <colspec colwidth="8*" align="left"/>
20677 <colspec colwidth="5*" align="center"/>
20678 <colspec colwidth="5*" align="center"/>
20679 <colspec colwidth="6*" align="right"/>
20680 <tbody>
20681 <row>
20682 <entry><option>deliver_drop_privilege</option></entry>
20683 <entry>Use: <emphasis>main</emphasis></entry>
20684 <entry>Type: <emphasis>boolean</emphasis></entry>
20685 <entry>Default: <emphasis>false</emphasis></entry>
20686 </row>
20687 </tbody>
20688 </tgroup>
20689 </informaltable>
20690 <para>
20691 <indexterm role="concept">
20692 <primary>unprivileged delivery</primary>
20693 </indexterm>
20694 <indexterm role="concept">
20695 <primary>delivery</primary>
20696 <secondary>unprivileged</secondary>
20697 </indexterm>
20698 If this option is set true, Exim drops its root privilege at the start of a
20699 delivery process, and runs as the Exim user throughout. This severely restricts
20700 the kinds of local delivery that are possible, but is viable in certain types
20701 of configuration. There is a discussion about the use of root privilege in
20702 chapter <xref linkend="CHAPsecurity"/>.
20703 </para>
20704 <para>
20705 <indexterm role="option">
20706 <primary>deliver_queue_load_max</primary>
20707 </indexterm>
20708 </para>
20709 <informaltable frame="all">
20710 <tgroup cols="4" colsep="0" rowsep="0">
20711 <colspec colwidth="8*" align="left"/>
20712 <colspec colwidth="5*" align="center"/>
20713 <colspec colwidth="5*" align="center"/>
20714 <colspec colwidth="6*" align="right"/>
20715 <tbody>
20716 <row>
20717 <entry><option>deliver_queue_load_max</option></entry>
20718 <entry>Use: <emphasis>main</emphasis></entry>
20719 <entry>Type: <emphasis>fixed-point</emphasis></entry>
20720 <entry>Default: <emphasis>unset</emphasis></entry>
20721 </row>
20722 </tbody>
20723 </tgroup>
20724 </informaltable>
20725 <para>
20726 <indexterm role="concept">
20727 <primary>load average</primary>
20728 </indexterm>
20729 <indexterm role="concept">
20730 <primary>queue runner</primary>
20731 <secondary>abandoning</secondary>
20732 </indexterm>
20733 When this option is set, a queue run is abandoned if the system load average
20734 becomes greater than the value of the option. The option has no effect on
20735 ancient operating systems on which Exim cannot determine the load average.
20736 See also <option>queue_only_load</option> and <option>smtp_load_reserve</option>.
20737 </para>
20738 <para>
20739 <indexterm role="option">
20740 <primary>delivery_date_remove</primary>
20741 </indexterm>
20742 </para>
20743 <informaltable frame="all">
20744 <tgroup cols="4" colsep="0" rowsep="0">
20745 <colspec colwidth="8*" align="left"/>
20746 <colspec colwidth="5*" align="center"/>
20747 <colspec colwidth="5*" align="center"/>
20748 <colspec colwidth="6*" align="right"/>
20749 <tbody>
20750 <row>
20751 <entry><option>delivery_date_remove</option></entry>
20752 <entry>Use: <emphasis>main</emphasis></entry>
20753 <entry>Type: <emphasis>boolean</emphasis></entry>
20754 <entry>Default: <emphasis>true</emphasis></entry>
20755 </row>
20756 </tbody>
20757 </tgroup>
20758 </informaltable>
20759 <para>
20760 <indexterm role="concept">
20761 <primary><emphasis>Delivery-date:</emphasis> header line</primary>
20762 </indexterm>
20763 Exim&#x2019;s transports have an option for adding a <emphasis>Delivery-date:</emphasis> header to a
20764 message when it is delivered, in exactly the same way as <emphasis>Return-path:</emphasis> is
20765 handled. <emphasis>Delivery-date:</emphasis> records the actual time of delivery. Such headers
20766 should not be present in incoming messages, and this option causes them to be
20767 removed at the time the message is received, to avoid any problems that might
20768 occur when a delivered message is subsequently sent on to some other recipient.
20769 </para>
20770 <para revisionflag="changed">
20771 <indexterm role="option">
20772 <primary>disable_ipv6</primary>
20773 </indexterm>
20774 </para>
20775 <informaltable frame="all" revisionflag="changed">
20776 <tgroup cols="4" colsep="0" rowsep="0">
20777 <colspec colwidth="8*" align="left"/>
20778 <colspec colwidth="5*" align="center"/>
20779 <colspec colwidth="5*" align="center"/>
20780 <colspec colwidth="6*" align="right"/>
20781 <tbody>
20782 <row>
20783 <entry><option>disable_ipv6</option></entry>
20784 <entry>Use: <emphasis>main</emphasis></entry>
20785 <entry>Type: <emphasis>boolean</emphasis></entry>
20786 <entry>Default: <emphasis>false</emphasis></entry>
20787 </row>
20788 </tbody>
20789 </tgroup>
20790 </informaltable>
20791 <para revisionflag="changed">
20792 <indexterm role="concept">
20793 <primary>IPv6</primary>
20794 <secondary>disabling</secondary>
20795 </indexterm>
20796 If this option is set true, even if the Exim binary has IPv6 support, no IPv6
20797 activities take place. AAAA records are never looked up, and any IPv6 addresses
20798 that are listed in <option>local_interfaces</option>, data for the <option>manualroute</option> router,
20799 etc. are ignored. If IP literals are enabled, the <command>ipliteral</command> router declines
20800 to handle IPv6 literal addresses.
20801 </para>
20802 <para>
20803 <indexterm role="option">
20804 <primary>dns_again_means_nonexist</primary>
20805 </indexterm>
20806 </para>
20807 <informaltable frame="all">
20808 <tgroup cols="4" colsep="0" rowsep="0">
20809 <colspec colwidth="8*" align="left"/>
20810 <colspec colwidth="5*" align="center"/>
20811 <colspec colwidth="5*" align="center"/>
20812 <colspec colwidth="6*" align="right"/>
20813 <tbody>
20814 <row>
20815 <entry><option>dns_again_means_nonexist</option></entry>
20816 <entry>Use: <emphasis>main</emphasis></entry>
20817 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
20818 <entry>Default: <emphasis>unset</emphasis></entry>
20819 </row>
20820 </tbody>
20821 </tgroup>
20822 </informaltable>
20823 <para>
20824 <indexterm role="concept">
20825 <primary>DNS</primary>
20826 <secondary><quote>try again</quote> response; overriding</secondary>
20827 </indexterm>
20828 DNS lookups give a <quote>try again</quote> response for the DNS errors
20829 <quote>non-authoritative host not found</quote> and <quote>SERVERFAIL</quote>. This can cause Exim to
20830 keep trying to deliver a message, or to give repeated temporary errors to
20831 incoming mail. Sometimes the effect is caused by a badly set up name server and
20832 may persist for a long time. If a domain which exhibits this problem matches
20833 anything in <option>dns_again_means_nonexist</option>, it is treated as if it did not exist.
20834 This option should be used with care. You can make it apply to reverse lookups
20835 by a setting such as this:
20836 </para>
20837 <literallayout class="monospaced">
20838 dns_again_means_nonexist = *.in-addr.arpa
20839 </literallayout>
20840 <para revisionflag="changed">
20841 This option applies to all DNS lookups that Exim does. It also applies when the
20842 <function>gethostbyname()</function> or <function>getipnodebyname()</function> functions give temporary errors,
20843 since these are most likely to be caused by DNS lookup problems. The
20844 <command>dnslookup</command> router has some options of its own for controlling what happens
20845 when lookups for MX or SRV records give temporary errors. These more specific
20846 options are applied after this global option.
20847 </para>
20848 <para>
20849 <indexterm role="option">
20850 <primary>dns_check_names_pattern</primary>
20851 </indexterm>
20852 </para>
20853 <informaltable frame="all">
20854 <tgroup cols="4" colsep="0" rowsep="0">
20855 <colspec colwidth="8*" align="left"/>
20856 <colspec colwidth="5*" align="center"/>
20857 <colspec colwidth="5*" align="center"/>
20858 <colspec colwidth="6*" align="right"/>
20859 <tbody>
20860 <row>
20861 <entry><option>dns_check_names_pattern</option></entry>
20862 <entry>Use: <emphasis>main</emphasis></entry>
20863 <entry>Type: <emphasis>string</emphasis></entry>
20864 <entry>Default: <emphasis>see below</emphasis></entry>
20865 </row>
20866 </tbody>
20867 </tgroup>
20868 </informaltable>
20869 <para>
20870 <indexterm role="concept">
20871 <primary>DNS</primary>
20872 <secondary>pre-check of name syntax</secondary>
20873 </indexterm>
20874 </para>
20875 <para revisionflag="changed">
20876 When this option is set to a non-empty string, it causes Exim to check domain
20877 names for characters that are not allowed in host names before handing them to
20878 the DNS resolver, because some resolvers give temporary errors for names that
20879 contain unusual characters. If a domain name contains any unwanted characters,
20880 a <quote>not found</quote> result is forced, and the resolver is not called. The check is
20881 done by matching the domain name against a regular expression, which is the
20882 value of this option. The default pattern is
20883 </para>
20884 <literallayout class="monospaced" revisionflag="changed">
20885 dns_check_names_pattern = \
20886   (?i)^(?&gt;(?(1)\.|())[^\W_](?&gt;[a-z0-9/-]*[^\W_])?)+$
20887 </literallayout>
20888 <para revisionflag="changed">
20889 which permits only letters, digits, slashes, and hyphens in components, but
20890 they must start and end with a letter or digit. Hyphens are not, in fact,
20891 permitted in host names, but they are found in certain NS records (which can be
20892 accessed in Exim by using a <option>dnsdb</option> lookup). If you set
20893 <option>allow_utf8_domains</option>, you must modify this pattern, or set the option to an
20894 empty string.
20895 </para>
20896 <para>
20897 <indexterm role="option">
20898 <primary>dns_csa_search_limit</primary>
20899 </indexterm>
20900 </para>
20901 <informaltable frame="all">
20902 <tgroup cols="4" colsep="0" rowsep="0">
20903 <colspec colwidth="8*" align="left"/>
20904 <colspec colwidth="5*" align="center"/>
20905 <colspec colwidth="5*" align="center"/>
20906 <colspec colwidth="6*" align="right"/>
20907 <tbody>
20908 <row>
20909 <entry><option>dns_csa_search_limit</option></entry>
20910 <entry>Use: <emphasis>main</emphasis></entry>
20911 <entry>Type: <emphasis>integer</emphasis></entry>
20912 <entry>Default: <emphasis>5</emphasis></entry>
20913 </row>
20914 </tbody>
20915 </tgroup>
20916 </informaltable>
20917 <para>
20918 This option controls the depth of parental searching for CSA SRV records in the
20919 DNS, as described in more detail in section <xref linkend="SECTverifyCSA"/>.
20920 </para>
20921 <para>
20922 <indexterm role="option">
20923 <primary>dns_csa_use_reverse</primary>
20924 </indexterm>
20925 </para>
20926 <informaltable frame="all">
20927 <tgroup cols="4" colsep="0" rowsep="0">
20928 <colspec colwidth="8*" align="left"/>
20929 <colspec colwidth="5*" align="center"/>
20930 <colspec colwidth="5*" align="center"/>
20931 <colspec colwidth="6*" align="right"/>
20932 <tbody>
20933 <row>
20934 <entry><option>dns_csa_use_reverse</option></entry>
20935 <entry>Use: <emphasis>main</emphasis></entry>
20936 <entry>Type: <emphasis>boolean</emphasis></entry>
20937 <entry>Default: <emphasis>true</emphasis></entry>
20938 </row>
20939 </tbody>
20940 </tgroup>
20941 </informaltable>
20942 <para>
20943 This option controls whether or not an IP address, given as a CSA domain, is
20944 reversed and looked up in the reverse DNS, as described in more detail in
20945 section <xref linkend="SECTverifyCSA"/>.
20946 </para>
20947 <para>
20948 <indexterm role="option">
20949 <primary>dns_ipv4_lookup</primary>
20950 </indexterm>
20951 </para>
20952 <informaltable frame="all">
20953 <tgroup cols="4" colsep="0" rowsep="0">
20954 <colspec colwidth="8*" align="left"/>
20955 <colspec colwidth="5*" align="center"/>
20956 <colspec colwidth="5*" align="center"/>
20957 <colspec colwidth="6*" align="right"/>
20958 <tbody>
20959 <row>
20960 <entry><option>dns_ipv4_lookup</option></entry>
20961 <entry>Use: <emphasis>main</emphasis></entry>
20962 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
20963 <entry>Default: <emphasis>unset</emphasis></entry>
20964 </row>
20965 </tbody>
20966 </tgroup>
20967 </informaltable>
20968 <para>
20969 <indexterm role="concept">
20970 <primary>IPv6</primary>
20971 <secondary>DNS lookup for AAAA records</secondary>
20972 </indexterm>
20973 <indexterm role="concept">
20974 <primary>DNS</primary>
20975 <secondary>IPv6 lookup for AAAA records</secondary>
20976 </indexterm>
20977 </para>
20978 <para revisionflag="changed">
20979 When Exim is compiled with IPv6 support and <option>disable_ipv6</option> is not set, it
20980 looks for IPv6 address records (AAAA records) as well as IPv4 address records
20981 (A records) when trying to find IP addresses for hosts, unless the host&#x2019;s
20982 domain matches this list.
20983 </para>
20984 <para revisionflag="changed">
20985 This is a fudge to help with name servers that give big delays or otherwise do
20986 not work for the AAAA record type. In due course, when the world&#x2019;s name
20987 servers have all been upgraded, there should be no need for this option.
20988 </para>
20989 <para>
20990 <indexterm role="option">
20991 <primary>dns_retrans</primary>
20992 </indexterm>
20993 </para>
20994 <informaltable frame="all">
20995 <tgroup cols="4" colsep="0" rowsep="0">
20996 <colspec colwidth="8*" align="left"/>
20997 <colspec colwidth="5*" align="center"/>
20998 <colspec colwidth="5*" align="center"/>
20999 <colspec colwidth="6*" align="right"/>
21000 <tbody>
21001 <row>
21002 <entry><option>dns_retrans</option></entry>
21003 <entry>Use: <emphasis>main</emphasis></entry>
21004 <entry>Type: <emphasis>time</emphasis></entry>
21005 <entry>Default: <emphasis>0s</emphasis></entry>
21006 </row>
21007 </tbody>
21008 </tgroup>
21009 </informaltable>
21010 <para>
21011 <indexterm role="concept">
21012 <primary>DNS</primary>
21013 <secondary>resolver options</secondary>
21014 </indexterm>
21015 The options <option>dns_retrans</option> and <option>dns_retry</option> can be used to set the
21016 retransmission and retry parameters for DNS lookups. Values of zero (the
21017 defaults) leave the system default settings unchanged. The first value is the
21018 time between retries, and the second is the number of retries. It isn&#x2019;t
21019 totally clear exactly how these settings affect the total time a DNS lookup may
21020 take. I haven&#x2019;t found any documentation about timeouts on DNS lookups; these
21021 parameter values are available in the external resolver interface structure,
21022 but nowhere does it seem to describe how they are used or what you might want
21023 to set in them.
21024 </para>
21025 <para>
21026 <indexterm role="option">
21027 <primary>dns_retry</primary>
21028 </indexterm>
21029 </para>
21030 <informaltable frame="all">
21031 <tgroup cols="4" colsep="0" rowsep="0">
21032 <colspec colwidth="8*" align="left"/>
21033 <colspec colwidth="5*" align="center"/>
21034 <colspec colwidth="5*" align="center"/>
21035 <colspec colwidth="6*" align="right"/>
21036 <tbody>
21037 <row>
21038 <entry><option>dns_retry</option></entry>
21039 <entry>Use: <emphasis>main</emphasis></entry>
21040 <entry>Type: <emphasis>integer</emphasis></entry>
21041 <entry>Default: <emphasis>0</emphasis></entry>
21042 </row>
21043 </tbody>
21044 </tgroup>
21045 </informaltable>
21046 <para>
21047 See <option>dns_retrans</option> above.
21048 </para>
21049 <para>
21050 <indexterm role="option">
21051 <primary>drop_cr</primary>
21052 </indexterm>
21053 </para>
21054 <informaltable frame="all">
21055 <tgroup cols="4" colsep="0" rowsep="0">
21056 <colspec colwidth="8*" align="left"/>
21057 <colspec colwidth="5*" align="center"/>
21058 <colspec colwidth="5*" align="center"/>
21059 <colspec colwidth="6*" align="right"/>
21060 <tbody>
21061 <row>
21062 <entry><option>drop_cr</option></entry>
21063 <entry>Use: <emphasis>main</emphasis></entry>
21064 <entry>Type: <emphasis>boolean</emphasis></entry>
21065 <entry>Default: <emphasis>false</emphasis></entry>
21066 </row>
21067 </tbody>
21068 </tgroup>
21069 </informaltable>
21070 <para>
21071 This is an obsolete option that is now a no-op. It used to affect the way Exim
21072 handled CR and LF characters in incoming messages. What happens now is
21073 described in section <xref linkend="SECTlineendings"/>.
21074 </para>
21075 <para>
21076 <indexterm role="option">
21077 <primary>envelope_to_remove</primary>
21078 </indexterm>
21079 </para>
21080 <informaltable frame="all">
21081 <tgroup cols="4" colsep="0" rowsep="0">
21082 <colspec colwidth="8*" align="left"/>
21083 <colspec colwidth="5*" align="center"/>
21084 <colspec colwidth="5*" align="center"/>
21085 <colspec colwidth="6*" align="right"/>
21086 <tbody>
21087 <row>
21088 <entry><option>envelope_to_remove</option></entry>
21089 <entry>Use: <emphasis>main</emphasis></entry>
21090 <entry>Type: <emphasis>boolean</emphasis></entry>
21091 <entry>Default: <emphasis>true</emphasis></entry>
21092 </row>
21093 </tbody>
21094 </tgroup>
21095 </informaltable>
21096 <para>
21097 <indexterm role="concept">
21098 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
21099 </indexterm>
21100 Exim&#x2019;s transports have an option for adding an <emphasis>Envelope-to:</emphasis> header to a
21101 message when it is delivered, in exactly the same way as <emphasis>Return-path:</emphasis> is
21102 handled. <emphasis>Envelope-to:</emphasis> records the original recipient address from the
21103 messages&#x2019;s envelope that caused the delivery to happen. Such headers should not
21104 be present in incoming messages, and this option causes them to be removed at
21105 the time the message is received, to avoid any problems that might occur when a
21106 delivered message is subsequently sent on to some other recipient.
21107 </para>
21108 <para>
21109 <indexterm role="option">
21110 <primary>errors_copy</primary>
21111 </indexterm>
21112 </para>
21113 <informaltable frame="all">
21114 <tgroup cols="4" colsep="0" rowsep="0">
21115 <colspec colwidth="8*" align="left"/>
21116 <colspec colwidth="5*" align="center"/>
21117 <colspec colwidth="5*" align="center"/>
21118 <colspec colwidth="6*" align="right"/>
21119 <tbody>
21120 <row>
21121 <entry><option>errors_copy</option></entry>
21122 <entry>Use: <emphasis>main</emphasis></entry>
21123 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
21124 <entry>Default: <emphasis>unset</emphasis></entry>
21125 </row>
21126 </tbody>
21127 </tgroup>
21128 </informaltable>
21129 <para>
21130 <indexterm role="concept">
21131 <primary>bounce message</primary>
21132 <secondary>copy to other address</secondary>
21133 </indexterm>
21134 <indexterm role="concept">
21135 <primary>copy of bounce message</primary>
21136 </indexterm>
21137 Setting this option causes Exim to send bcc copies of bounce messages that it
21138 generates to other addresses. <emphasis role="bold">Note</emphasis>: This does not apply to bounce messages
21139 coming from elsewhere. The value of the option is a colon-separated list of
21140 items. Each item consists of a pattern, terminated by white space, followed by
21141 a comma-separated list of email addresses. If a pattern contains spaces, it
21142 must be enclosed in double quotes.
21143 </para>
21144 <para>
21145 Each pattern is processed in the same way as a single item in an address list
21146 (see section <xref linkend="SECTaddresslist"/>). When a pattern matches the recipient of
21147 the bounce message, the message is copied to the addresses on the list. The
21148 items are scanned in order, and once a matching one is found, no further items
21149 are examined. For example:
21150 </para>
21151 <literallayout class="monospaced">
21152 errors_copy = spqr@mydomain   postmaster@mydomain.example :\
21153               rqps@mydomain   hostmaster@mydomain.example,\
21154                               postmaster@mydomain.example
21155 </literallayout>
21156 <para>
21157 <indexterm role="concept">
21158 <primary><varname>$domain</varname></primary>
21159 </indexterm>
21160 <indexterm role="concept">
21161 <primary><varname>$local_part</varname></primary>
21162 </indexterm>
21163 The address list is expanded before use. The expansion variables <varname>$local_part</varname>
21164 and <varname>$domain</varname> are set from the original recipient of the error message, and if
21165 there was any wildcard matching in the pattern, the expansion
21166 <indexterm role="concept">
21167 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
21168 <secondary>in <option>errors_copy</option></secondary>
21169 </indexterm>
21170 variables <varname>$0</varname>, <varname>$1</varname>, etc. are set in the normal way.
21171 </para>
21172 <para>
21173 <indexterm role="option">
21174 <primary>errors_reply_to</primary>
21175 </indexterm>
21176 </para>
21177 <informaltable frame="all">
21178 <tgroup cols="4" colsep="0" rowsep="0">
21179 <colspec colwidth="8*" align="left"/>
21180 <colspec colwidth="5*" align="center"/>
21181 <colspec colwidth="5*" align="center"/>
21182 <colspec colwidth="6*" align="right"/>
21183 <tbody>
21184 <row>
21185 <entry><option>errors_reply_to</option></entry>
21186 <entry>Use: <emphasis>main</emphasis></entry>
21187 <entry>Type: <emphasis>string</emphasis></entry>
21188 <entry>Default: <emphasis>unset</emphasis></entry>
21189 </row>
21190 </tbody>
21191 </tgroup>
21192 </informaltable>
21193 <para>
21194 <indexterm role="concept">
21195 <primary>bounce message</primary>
21196 <secondary><emphasis>Reply-to:</emphasis> in</secondary>
21197 </indexterm>
21198 </para>
21199 <para revisionflag="changed">
21200 By default, Exim&#x2019;s bounce and delivery warning messages contain the header line
21201 </para>
21202 <literallayout revisionflag="changed">
21203 <literal>From: Mail Delivery System &lt;Mailer-Daemon@</literal><emphasis>qualify-domain</emphasis><literal>&gt;</literal>
21204 </literallayout>
21205 <para revisionflag="changed">
21206 <indexterm role="option">
21207 <primary><option>quota_warn_message</option></primary>
21208 </indexterm>
21209 where <emphasis>qualify-domain</emphasis> is the value of the <option>qualify_domain</option> option.
21210 A warning message that is generated by the <option>quota_warn_message</option> option in an
21211 <command>appendfile</command> transport may contain its own <emphasis>From:</emphasis> header line that
21212 overrides the default.
21213 </para>
21214 <para revisionflag="changed">
21215 Experience shows that people reply to bounce messages. If the
21216 <option>errors_reply_to</option> option is set, a <emphasis>Reply-To:</emphasis> header is added to bounce
21217 and warning messages. For example:
21218 </para>
21219 <literallayout class="monospaced" revisionflag="changed">
21220 errors_reply_to = postmaster@my.domain.example
21221 </literallayout>
21222 <para revisionflag="changed">
21223 The value of the option is not expanded. It must specify a valid RFC 2822
21224 address. However, if a warning message that is generated by the
21225 <option>quota_warn_message</option> option in an <command>appendfile</command> transport contain its
21226 own <emphasis>Reply-To:</emphasis> header line, the value of the <option>errors_reply_to</option> option is
21227 not used.
21228 </para>
21229 <para>
21230 <indexterm role="option">
21231 <primary>exim_group</primary>
21232 </indexterm>
21233 </para>
21234 <informaltable frame="all">
21235 <tgroup cols="4" colsep="0" rowsep="0">
21236 <colspec colwidth="8*" align="left"/>
21237 <colspec colwidth="5*" align="center"/>
21238 <colspec colwidth="5*" align="center"/>
21239 <colspec colwidth="6*" align="right"/>
21240 <tbody>
21241 <row>
21242 <entry><option>exim_group</option></entry>
21243 <entry>Use: <emphasis>main</emphasis></entry>
21244 <entry>Type: <emphasis>string</emphasis></entry>
21245 <entry>Default: <emphasis>compile-time configured</emphasis></entry>
21246 </row>
21247 </tbody>
21248 </tgroup>
21249 </informaltable>
21250 <para>
21251 <indexterm role="concept">
21252 <primary>gid (group id)</primary>
21253 <secondary>Exim&#x2019;s own</secondary>
21254 </indexterm>
21255 <indexterm role="concept">
21256 <primary>Exim group</primary>
21257 </indexterm>
21258 This option changes the gid under which Exim runs when it gives up root
21259 privilege. The default value is compiled into the binary. The value of this
21260 option is used only when <option>exim_user</option> is also set. Unless it consists entirely
21261 of digits, the string is looked up using <function>getgrnam()</function>, and failure causes a
21262 configuration error. See chapter <xref linkend="CHAPsecurity"/> for a discussion of
21263 security issues.
21264 </para>
21265 <para>
21266 <indexterm role="option">
21267 <primary>exim_path</primary>
21268 </indexterm>
21269 </para>
21270 <informaltable frame="all">
21271 <tgroup cols="4" colsep="0" rowsep="0">
21272 <colspec colwidth="8*" align="left"/>
21273 <colspec colwidth="5*" align="center"/>
21274 <colspec colwidth="5*" align="center"/>
21275 <colspec colwidth="6*" align="right"/>
21276 <tbody>
21277 <row>
21278 <entry><option>exim_path</option></entry>
21279 <entry>Use: <emphasis>main</emphasis></entry>
21280 <entry>Type: <emphasis>string</emphasis></entry>
21281 <entry>Default: <emphasis>see below</emphasis></entry>
21282 </row>
21283 </tbody>
21284 </tgroup>
21285 </informaltable>
21286 <para>
21287 <indexterm role="concept">
21288 <primary>Exim binary</primary>
21289 <secondary>path name</secondary>
21290 </indexterm>
21291 This option specifies the path name of the Exim binary, which is used when Exim
21292 needs to re-exec itself. The default is set up to point to the file <emphasis>exim</emphasis> in
21293 the directory configured at compile time by the BIN_DIRECTORY setting. It
21294 is necessary to change <option>exim_path</option> if, exceptionally, Exim is run from some
21295 other place.
21296 <emphasis role="bold">Warning</emphasis>: Do not use a macro to define the value of this option, because
21297 you will break those Exim utilities that scan the configuration file to find
21298 where the binary is. (They then use the <option>-bP</option> option to extract option
21299 settings such as the value of <option>spool_directory</option>.)
21300 </para>
21301 <para>
21302 <indexterm role="option">
21303 <primary>exim_user</primary>
21304 </indexterm>
21305 </para>
21306 <informaltable frame="all">
21307 <tgroup cols="4" colsep="0" rowsep="0">
21308 <colspec colwidth="8*" align="left"/>
21309 <colspec colwidth="5*" align="center"/>
21310 <colspec colwidth="5*" align="center"/>
21311 <colspec colwidth="6*" align="right"/>
21312 <tbody>
21313 <row>
21314 <entry><option>exim_user</option></entry>
21315 <entry>Use: <emphasis>main</emphasis></entry>
21316 <entry>Type: <emphasis>string</emphasis></entry>
21317 <entry>Default: <emphasis>compile-time configured</emphasis></entry>
21318 </row>
21319 </tbody>
21320 </tgroup>
21321 </informaltable>
21322 <para>
21323 <indexterm role="concept">
21324 <primary>uid (user id)</primary>
21325 <secondary>Exim&#x2019;s own</secondary>
21326 </indexterm>
21327 <indexterm role="concept">
21328 <primary>Exim user</primary>
21329 </indexterm>
21330 This option changes the uid under which Exim runs when it gives up root
21331 privilege. The default value is compiled into the binary. Ownership of the run
21332 time configuration file and the use of the <option>-C</option> and <option>-D</option> command line
21333 options is checked against the values in the binary, not what is set here.
21334 </para>
21335 <para>
21336 Unless it consists entirely of digits, the string is looked up using
21337 <function>getpwnam()</function>, and failure causes a configuration error. If <option>exim_group</option> is
21338 not also supplied, the gid is taken from the result of <function>getpwnam()</function> if it is
21339 used. See chapter <xref linkend="CHAPsecurity"/> for a discussion of security issues.
21340 </para>
21341 <para>
21342 <indexterm role="option">
21343 <primary>extra_local_interfaces</primary>
21344 </indexterm>
21345 </para>
21346 <informaltable frame="all">
21347 <tgroup cols="4" colsep="0" rowsep="0">
21348 <colspec colwidth="8*" align="left"/>
21349 <colspec colwidth="5*" align="center"/>
21350 <colspec colwidth="5*" align="center"/>
21351 <colspec colwidth="6*" align="right"/>
21352 <tbody>
21353 <row>
21354 <entry><option>extra_local_interfaces</option></entry>
21355 <entry>Use: <emphasis>main</emphasis></entry>
21356 <entry>Type: <emphasis>string list</emphasis></entry>
21357 <entry>Default: <emphasis>unset</emphasis></entry>
21358 </row>
21359 </tbody>
21360 </tgroup>
21361 </informaltable>
21362 <para>
21363 This option defines network interfaces that are to be considered local when
21364 routing, but which are not used for listening by the daemon. See section
21365 <xref linkend="SECTreclocipadd"/> for details.
21366 </para>
21367 <para>
21368 <indexterm role="option">
21369 <primary>extract_addresses_remove_ &nbsp;arguments</primary>
21370 </indexterm>
21371 </para>
21372 <informaltable frame="all">
21373 <tgroup cols="4" colsep="0" rowsep="0">
21374 <colspec colwidth="8*" align="left"/>
21375 <colspec colwidth="5*" align="center"/>
21376 <colspec colwidth="5*" align="center"/>
21377 <colspec colwidth="6*" align="right"/>
21378 <tbody>
21379 <row>
21380 <entry><option>extract_addresses_remove_ &nbsp;arguments</option></entry>
21381 <entry>Use: <emphasis>main</emphasis></entry>
21382 <entry>Type: <emphasis>boolean</emphasis></entry>
21383 <entry>Default: <emphasis>true</emphasis></entry>
21384 </row>
21385 </tbody>
21386 </tgroup>
21387 </informaltable>
21388 <para>
21389 <indexterm role="concept">
21390 <primary><option>-t</option> option</primary>
21391 </indexterm>
21392 <indexterm role="concept">
21393 <primary>command line</primary>
21394 <secondary>addresses with <option>-t</option></secondary>
21395 </indexterm>
21396 <indexterm role="concept">
21397 <primary>Sendmail compatibility</primary>
21398 <secondary><option>-t</option> option</secondary>
21399 </indexterm>
21400 According to some Sendmail documentation (Sun, IRIX, HP-UX), if any addresses
21401 are present on the command line when the <option>-t</option> option is used to build an
21402 envelope from a message&#x2019;s <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis> and <emphasis>Bcc:</emphasis> headers, the command
21403 line addresses are removed from the recipients list. This is also how Smail
21404 behaves. However, other Sendmail documentation (the O&#x2019;Reilly book) states that
21405 command line addresses are added to those obtained from the header lines. When
21406 <option>extract_addresses_remove_arguments</option> is true (the default), Exim subtracts
21407 argument headers. If it is set false, Exim adds rather than removes argument
21408 addresses.
21409 </para>
21410 <para>
21411 <indexterm role="option">
21412 <primary>finduser_retries</primary>
21413 </indexterm>
21414 </para>
21415 <informaltable frame="all">
21416 <tgroup cols="4" colsep="0" rowsep="0">
21417 <colspec colwidth="8*" align="left"/>
21418 <colspec colwidth="5*" align="center"/>
21419 <colspec colwidth="5*" align="center"/>
21420 <colspec colwidth="6*" align="right"/>
21421 <tbody>
21422 <row>
21423 <entry><option>finduser_retries</option></entry>
21424 <entry>Use: <emphasis>main</emphasis></entry>
21425 <entry>Type: <emphasis>integer</emphasis></entry>
21426 <entry>Default: <emphasis>0</emphasis></entry>
21427 </row>
21428 </tbody>
21429 </tgroup>
21430 </informaltable>
21431 <para>
21432 <indexterm role="concept">
21433 <primary>NIS</primary>
21434 <secondary>looking up users; retrying</secondary>
21435 </indexterm>
21436 On systems running NIS or other schemes in which user and group information is
21437 distributed from a remote system, there can be times when <function>getpwnam()</function> and
21438 related functions fail, even when given valid data, because things time out.
21439 Unfortunately these failures cannot be distinguished from genuine <quote>not found</quote>
21440 errors. If <option>finduser_retries</option> is set greater than zero, Exim will try that
21441 many extra times to find a user or a group, waiting for one second between
21442 retries.
21443 </para>
21444 <para>
21445 <indexterm role="concept">
21446 <primary><filename>/etc/passwd</filename></primary>
21447 <secondary>multiple reading of</secondary>
21448 </indexterm>
21449 You should not set this option greater than zero if your user information is in
21450 a traditional <filename>/etc/passwd</filename> file, because it will cause Exim needlessly to
21451 search the file multiple times for non-existent users, and also cause delay.
21452 </para>
21453 <para>
21454 <indexterm role="option">
21455 <primary>freeze_tell</primary>
21456 </indexterm>
21457 </para>
21458 <informaltable frame="all">
21459 <tgroup cols="4" colsep="0" rowsep="0">
21460 <colspec colwidth="8*" align="left"/>
21461 <colspec colwidth="5*" align="center"/>
21462 <colspec colwidth="5*" align="center"/>
21463 <colspec colwidth="6*" align="right"/>
21464 <tbody>
21465 <row>
21466 <entry><option>freeze_tell</option></entry>
21467 <entry>Use: <emphasis>main</emphasis></entry>
21468 <entry>Type: <emphasis>string list, comma separated</emphasis></entry>
21469 <entry>Default: <emphasis>unset</emphasis></entry>
21470 </row>
21471 </tbody>
21472 </tgroup>
21473 </informaltable>
21474 <para>
21475 <indexterm role="concept">
21476 <primary>freezing messages</primary>
21477 <secondary>sending a message when freezing</secondary>
21478 </indexterm>
21479 On encountering certain errors, or when configured to do so in a system filter,
21480 ACL, or special router, Exim freezes a message. This means that no further
21481 delivery attempts take place until an administrator thaws the message, or the
21482 <option>auto_thaw</option>, <option>ignore_bounce_errors_after</option>, or <option>timeout_frozen_after</option>
21483 feature cause it to be processed. If <option>freeze_tell</option> is set, Exim generates a
21484 warning message whenever it freezes something, unless the message it is
21485 freezing is a locally-generated bounce message. (Without this exception there
21486 is the possibility of looping.) The warning message is sent to the addresses
21487 supplied as the comma-separated value of this option. If several of the
21488 message&#x2019;s addresses cause freezing, only a single message is sent. If the
21489 freezing was automatic, the reason(s) for freezing can be found in the message
21490 log. If you configure freezing in a filter or ACL, you must arrange for any
21491 logging that you require.
21492 </para>
21493 <para>
21494 <indexterm role="option">
21495 <primary>gecos_name</primary>
21496 </indexterm>
21497 </para>
21498 <informaltable frame="all">
21499 <tgroup cols="4" colsep="0" rowsep="0">
21500 <colspec colwidth="8*" align="left"/>
21501 <colspec colwidth="5*" align="center"/>
21502 <colspec colwidth="5*" align="center"/>
21503 <colspec colwidth="6*" align="right"/>
21504 <tbody>
21505 <row>
21506 <entry><option>gecos_name</option></entry>
21507 <entry>Use: <emphasis>main</emphasis></entry>
21508 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
21509 <entry>Default: <emphasis>unset</emphasis></entry>
21510 </row>
21511 </tbody>
21512 </tgroup>
21513 </informaltable>
21514 <para>
21515 <indexterm role="concept">
21516 <primary>HP-UX</primary>
21517 </indexterm>
21518 <indexterm role="concept">
21519 <primary><quote>gecos</quote> field</primary>
21520 <secondary>parsing</secondary>
21521 </indexterm>
21522 Some operating systems, notably HP-UX, use the <quote>gecos</quote> field in the system
21523 password file to hold other information in addition to users&#x2019; real names. Exim
21524 looks up this field for use when it is creating <emphasis>Sender:</emphasis> or <emphasis>From:</emphasis>
21525 headers. If either <option>gecos_pattern</option> or <option>gecos_name</option> are unset, the contents
21526 of the field are used unchanged, except that, if an ampersand is encountered,
21527 it is replaced by the user&#x2019;s login name with the first character forced to
21528 upper case, since this is a convention that is observed on many systems.
21529 </para>
21530 <para>
21531 When these options are set, <option>gecos_pattern</option> is treated as a regular
21532 expression that is to be applied to the field (again with &amp; replaced by the
21533 login name), and if it matches, <option>gecos_name</option> is expanded and used as the
21534 user&#x2019;s name.
21535 </para>
21536 <para>
21537 <indexterm role="concept">
21538 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
21539 <secondary>in <option>gecos_name</option></secondary>
21540 </indexterm>
21541 Numeric variables such as <varname>$1</varname>, <varname>$2</varname>, etc. can be used in the expansion to
21542 pick up sub-fields that were matched by the pattern. In HP-UX, where the user&#x2019;s
21543 name terminates at the first comma, the following can be used:
21544 </para>
21545 <literallayout class="monospaced">
21546 gecos_pattern = ([^,]*)
21547 gecos_name = $1
21548 </literallayout>
21549 <para>
21550 <indexterm role="option">
21551 <primary>gecos_pattern</primary>
21552 </indexterm>
21553 </para>
21554 <informaltable frame="all">
21555 <tgroup cols="4" colsep="0" rowsep="0">
21556 <colspec colwidth="8*" align="left"/>
21557 <colspec colwidth="5*" align="center"/>
21558 <colspec colwidth="5*" align="center"/>
21559 <colspec colwidth="6*" align="right"/>
21560 <tbody>
21561 <row>
21562 <entry><option>gecos_pattern</option></entry>
21563 <entry>Use: <emphasis>main</emphasis></entry>
21564 <entry>Type: <emphasis>string</emphasis></entry>
21565 <entry>Default: <emphasis>unset</emphasis></entry>
21566 </row>
21567 </tbody>
21568 </tgroup>
21569 </informaltable>
21570 <para>
21571 See <option>gecos_name</option> above.
21572 </para>
21573 <para>
21574 <indexterm role="option">
21575 <primary>headers_charset</primary>
21576 </indexterm>
21577 </para>
21578 <informaltable frame="all">
21579 <tgroup cols="4" colsep="0" rowsep="0">
21580 <colspec colwidth="8*" align="left"/>
21581 <colspec colwidth="5*" align="center"/>
21582 <colspec colwidth="5*" align="center"/>
21583 <colspec colwidth="6*" align="right"/>
21584 <tbody>
21585 <row>
21586 <entry><option>headers_charset</option></entry>
21587 <entry>Use: <emphasis>main</emphasis></entry>
21588 <entry>Type: <emphasis>string</emphasis></entry>
21589 <entry>Default: <emphasis>see below</emphasis></entry>
21590 </row>
21591 </tbody>
21592 </tgroup>
21593 </informaltable>
21594 <para>
21595 This option sets a default character set for translating from encoded MIME
21596 <quote>words</quote> in header lines, when referenced by an <varname>$h_xxx</varname> expansion item. The
21597 default is the value of HEADERS_CHARSET in <filename>Local/Makefile</filename>. The
21598 ultimate default is ISO-8859-1. For more details see the description of header
21599 insertions in section <xref linkend="SECTexpansionitems"/>.
21600 </para>
21601 <para>
21602 <indexterm role="option">
21603 <primary>header_maxsize</primary>
21604 </indexterm>
21605 </para>
21606 <informaltable frame="all">
21607 <tgroup cols="4" colsep="0" rowsep="0">
21608 <colspec colwidth="8*" align="left"/>
21609 <colspec colwidth="5*" align="center"/>
21610 <colspec colwidth="5*" align="center"/>
21611 <colspec colwidth="6*" align="right"/>
21612 <tbody>
21613 <row>
21614 <entry><option>header_maxsize</option></entry>
21615 <entry>Use: <emphasis>main</emphasis></entry>
21616 <entry>Type: <emphasis>integer</emphasis></entry>
21617 <entry>Default: <emphasis>see below</emphasis></entry>
21618 </row>
21619 </tbody>
21620 </tgroup>
21621 </informaltable>
21622 <para>
21623 <indexterm role="concept">
21624 <primary>header section</primary>
21625 <secondary>maximum size of</secondary>
21626 </indexterm>
21627 <indexterm role="concept">
21628 <primary>limit</primary>
21629 <secondary>size of message header section</secondary>
21630 </indexterm>
21631 This option controls the overall maximum size of a message&#x2019;s header
21632 section. The default is the value of HEADER_MAXSIZE in
21633 <filename>Local/Makefile</filename>; the default for that is 1M. Messages with larger header
21634 sections are rejected.
21635 </para>
21636 <para>
21637 <indexterm role="option">
21638 <primary>header_line_maxsize</primary>
21639 </indexterm>
21640 </para>
21641 <informaltable frame="all">
21642 <tgroup cols="4" colsep="0" rowsep="0">
21643 <colspec colwidth="8*" align="left"/>
21644 <colspec colwidth="5*" align="center"/>
21645 <colspec colwidth="5*" align="center"/>
21646 <colspec colwidth="6*" align="right"/>
21647 <tbody>
21648 <row>
21649 <entry><option>header_line_maxsize</option></entry>
21650 <entry>Use: <emphasis>main</emphasis></entry>
21651 <entry>Type: <emphasis>integer</emphasis></entry>
21652 <entry>Default: <emphasis>0</emphasis></entry>
21653 </row>
21654 </tbody>
21655 </tgroup>
21656 </informaltable>
21657 <para>
21658 <indexterm role="concept">
21659 <primary>header lines</primary>
21660 <secondary>maximum size of</secondary>
21661 </indexterm>
21662 <indexterm role="concept">
21663 <primary>limit</primary>
21664 <secondary>size of one header line</secondary>
21665 </indexterm>
21666 This option limits the length of any individual header line in a message, after
21667 all the continuations have been joined together. Messages with individual
21668 header lines that are longer than the limit are rejected. The default value of
21669 zero means <quote>no limit</quote>.
21670 </para>
21671 <para>
21672 <indexterm role="option">
21673 <primary>helo_accept_junk_hosts</primary>
21674 </indexterm>
21675 </para>
21676 <informaltable frame="all">
21677 <tgroup cols="4" colsep="0" rowsep="0">
21678 <colspec colwidth="8*" align="left"/>
21679 <colspec colwidth="5*" align="center"/>
21680 <colspec colwidth="5*" align="center"/>
21681 <colspec colwidth="6*" align="right"/>
21682 <tbody>
21683 <row>
21684 <entry><option>helo_accept_junk_hosts</option></entry>
21685 <entry>Use: <emphasis>main</emphasis></entry>
21686 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
21687 <entry>Default: <emphasis>unset</emphasis></entry>
21688 </row>
21689 </tbody>
21690 </tgroup>
21691 </informaltable>
21692 <para>
21693 <indexterm role="concept">
21694 <primary>HELO</primary>
21695 <secondary>accepting junk data</secondary>
21696 </indexterm>
21697 <indexterm role="concept">
21698 <primary>EHLO</primary>
21699 <secondary>accepting junk data</secondary>
21700 </indexterm>
21701 Exim checks the syntax of HELO and EHLO commands for incoming SMTP
21702 mail, and gives an error response for invalid data. Unfortunately, there are
21703 some SMTP clients that send syntactic junk. They can be accommodated by setting
21704 this option. Note that this is a syntax check only. See <option>helo_verify_hosts</option>
21705 if you want to do semantic checking.
21706 See also <option>helo_allow_chars</option> for a way of extending the permitted character
21707 set.
21708 </para>
21709 <para>
21710 <indexterm role="option">
21711 <primary>helo_allow_chars</primary>
21712 </indexterm>
21713 </para>
21714 <informaltable frame="all">
21715 <tgroup cols="4" colsep="0" rowsep="0">
21716 <colspec colwidth="8*" align="left"/>
21717 <colspec colwidth="5*" align="center"/>
21718 <colspec colwidth="5*" align="center"/>
21719 <colspec colwidth="6*" align="right"/>
21720 <tbody>
21721 <row>
21722 <entry><option>helo_allow_chars</option></entry>
21723 <entry>Use: <emphasis>main</emphasis></entry>
21724 <entry>Type: <emphasis>string</emphasis></entry>
21725 <entry>Default: <emphasis>unset</emphasis></entry>
21726 </row>
21727 </tbody>
21728 </tgroup>
21729 </informaltable>
21730 <para>
21731 <indexterm role="concept">
21732 <primary>HELO</primary>
21733 <secondary>underscores in</secondary>
21734 </indexterm>
21735 <indexterm role="concept">
21736 <primary>EHLO</primary>
21737 <secondary>underscores in</secondary>
21738 </indexterm>
21739 <indexterm role="concept">
21740 <primary>underscore in EHLO/HELO</primary>
21741 </indexterm>
21742 This option can be set to a string of rogue characters that are permitted in
21743 all EHLO and HELO names in addition to the standard letters, digits,
21744 hyphens, and dots. If you really must allow underscores, you can set
21745 </para>
21746 <literallayout class="monospaced">
21747 helo_allow_chars = _
21748 </literallayout>
21749 <para>
21750 Note that the value is one string, not a list.
21751 </para>
21752 <para>
21753 <indexterm role="option">
21754 <primary>helo_lookup_domains</primary>
21755 </indexterm>
21756 </para>
21757 <informaltable frame="all">
21758 <tgroup cols="4" colsep="0" rowsep="0">
21759 <colspec colwidth="8*" align="left"/>
21760 <colspec colwidth="5*" align="center"/>
21761 <colspec colwidth="5*" align="center"/>
21762 <colspec colwidth="6*" align="right"/>
21763 <tbody>
21764 <row>
21765 <entry><option>helo_lookup_domains</option></entry>
21766 <entry>Use: <emphasis>main</emphasis></entry>
21767 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
21768 <entry>Default: <emphasis><literal>@:@[]</literal></emphasis></entry>
21769 </row>
21770 </tbody>
21771 </tgroup>
21772 </informaltable>
21773 <para>
21774 <indexterm role="concept">
21775 <primary>HELO</primary>
21776 <secondary>forcing reverse lookup</secondary>
21777 </indexterm>
21778 <indexterm role="concept">
21779 <primary>EHLO</primary>
21780 <secondary>forcing reverse lookup</secondary>
21781 </indexterm>
21782 If the domain given by a client in a HELO or EHLO command matches this
21783 list, a reverse lookup is done in order to establish the host&#x2019;s true name. The
21784 default forces a lookup if the client host gives the server&#x2019;s name or any of
21785 its IP addresses (in brackets), something that broken clients have been seen to
21786 do.
21787 </para>
21788 <para>
21789 <indexterm role="option">
21790 <primary>helo_try_verify_hosts</primary>
21791 </indexterm>
21792 </para>
21793 <informaltable frame="all">
21794 <tgroup cols="4" colsep="0" rowsep="0">
21795 <colspec colwidth="8*" align="left"/>
21796 <colspec colwidth="5*" align="center"/>
21797 <colspec colwidth="5*" align="center"/>
21798 <colspec colwidth="6*" align="right"/>
21799 <tbody>
21800 <row>
21801 <entry><option>helo_try_verify_hosts</option></entry>
21802 <entry>Use: <emphasis>main</emphasis></entry>
21803 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
21804 <entry>Default: <emphasis>unset</emphasis></entry>
21805 </row>
21806 </tbody>
21807 </tgroup>
21808 </informaltable>
21809 <para>
21810 <indexterm role="concept">
21811 <primary>HELO verifying</primary>
21812 <secondary>optional</secondary>
21813 </indexterm>
21814 <indexterm role="concept">
21815 <primary>EHLO verifying</primary>
21816 <secondary>optional</secondary>
21817 </indexterm>
21818 By default, Exim just checks the syntax of HELO and EHLO commands (see
21819 <option>helo_accept_junk_hosts</option> and <option>helo_allow_chars</option>). However, some sites like
21820 to do more extensive checking of the data supplied by these commands. The ACL
21821 condition <literal>verify</literal> <literal>=</literal> <literal>helo</literal> is provided to make this possible.
21822 Formerly, it was necessary also to set this option (<option>helo_try_verify_hosts</option>)
21823 to force the check to occur. From release 4.53 onwards, this is no longer
21824 necessary. If the check has not been done before <literal>verify</literal> <literal>=</literal> <literal>helo</literal> is
21825 encountered, it is done at that time. Consequently, this option is obsolete.
21826 Its specification is retained here for backwards compatibility.
21827 </para>
21828 <para>
21829 When an EHLO or HELO command is received, if the calling host matches
21830 <option>helo_try_verify_hosts</option>, Exim checks that the host name given in the HELO or
21831 EHLO command either:
21832 </para>
21833 <itemizedlist>
21834 <listitem>
21835 <para>
21836 is an IP literal matching the calling address of the host, or
21837 </para>
21838 </listitem>
21839 <listitem>
21840 <para>
21841 <indexterm role="concept">
21842 <primary>DNS</primary>
21843 <secondary>reverse lookup</secondary>
21844 </indexterm>
21845 <indexterm role="concept">
21846 <primary>reverse DNS lookup</primary>
21847 </indexterm>
21848 matches the host name that Exim obtains by doing a reverse lookup of the
21849 calling host address, or
21850 </para>
21851 </listitem>
21852 <listitem>
21853 <para>
21854 when looked up using <function>gethostbyname()</function> (or <function>getipnodebyname()</function> when
21855 available) yields the calling host address.
21856 </para>
21857 </listitem>
21858 </itemizedlist>
21859 <para>
21860 However, the EHLO or HELO command is not rejected if any of the checks
21861 fail. Processing continues, but the result of the check is remembered, and can
21862 be detected later in an ACL by the <literal>verify</literal> <literal>=</literal> <literal>helo</literal> condition.
21863 </para>
21864 <para>
21865 <indexterm role="option">
21866 <primary>helo_verify_hosts</primary>
21867 </indexterm>
21868 </para>
21869 <informaltable frame="all">
21870 <tgroup cols="4" colsep="0" rowsep="0">
21871 <colspec colwidth="8*" align="left"/>
21872 <colspec colwidth="5*" align="center"/>
21873 <colspec colwidth="5*" align="center"/>
21874 <colspec colwidth="6*" align="right"/>
21875 <tbody>
21876 <row>
21877 <entry><option>helo_verify_hosts</option></entry>
21878 <entry>Use: <emphasis>main</emphasis></entry>
21879 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
21880 <entry>Default: <emphasis>unset</emphasis></entry>
21881 </row>
21882 </tbody>
21883 </tgroup>
21884 </informaltable>
21885 <para>
21886 <indexterm role="concept">
21887 <primary>HELO verifying</primary>
21888 <secondary>mandatory</secondary>
21889 </indexterm>
21890 <indexterm role="concept">
21891 <primary>EHLO verifying</primary>
21892 <secondary>mandatory</secondary>
21893 </indexterm>
21894 Like <option>helo_try_verify_hosts</option>, this option is obsolete, and retained only for
21895 backwards compatibility. For hosts that match this option, Exim checks the host
21896 name given in the HELO or EHLO in the same way as for
21897 <option>helo_try_verify_hosts</option>. If the check fails, the HELO or EHLO command is
21898 rejected with a 550 error, and entries are written to the main and reject logs.
21899 If a MAIL command is received before EHLO or HELO, it is rejected with a 503
21900 error.
21901 </para>
21902 <para>
21903 <indexterm role="option">
21904 <primary>hold_domains</primary>
21905 </indexterm>
21906 </para>
21907 <informaltable frame="all">
21908 <tgroup cols="4" colsep="0" rowsep="0">
21909 <colspec colwidth="8*" align="left"/>
21910 <colspec colwidth="5*" align="center"/>
21911 <colspec colwidth="5*" align="center"/>
21912 <colspec colwidth="6*" align="right"/>
21913 <tbody>
21914 <row>
21915 <entry><option>hold_domains</option></entry>
21916 <entry>Use: <emphasis>main</emphasis></entry>
21917 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
21918 <entry>Default: <emphasis>unset</emphasis></entry>
21919 </row>
21920 </tbody>
21921 </tgroup>
21922 </informaltable>
21923 <para>
21924 <indexterm role="concept">
21925 <primary>domain</primary>
21926 <secondary>delaying delivery</secondary>
21927 </indexterm>
21928 <indexterm role="concept">
21929 <primary>delivery</primary>
21930 <secondary>delaying certain domains</secondary>
21931 </indexterm>
21932 This option allows mail for particular domains to be held on the queue
21933 manually. The option is overridden if a message delivery is forced with the
21934 <option>-M</option>, <option>-qf</option>, <option>-Rf</option> or <option>-Sf</option> options, and also while testing or
21935 verifying addresses using <option>-bt</option> or <option>-bv</option>. Otherwise, if a domain matches an
21936 item in <option>hold_domains</option>, no routing or delivery for that address is done, and
21937 it is deferred every time the message is looked at.
21938 </para>
21939 <para>
21940 This option is intended as a temporary operational measure for delaying the
21941 delivery of mail while some problem is being sorted out, or some new
21942 configuration tested. If you just want to delay the processing of some
21943 domains until a queue run occurs, you should use <option>queue_domains</option> or
21944 <option>queue_smtp_domains</option>, not <option>hold_domains</option>.
21945 </para>
21946 <para>
21947 A setting of <option>hold_domains</option> does not override Exim&#x2019;s code for removing
21948 messages from the queue if they have been there longer than the longest retry
21949 time in any retry rule. If you want to hold messages for longer than the normal
21950 retry times, insert a dummy retry rule with a long retry time.
21951 </para>
21952 <para>
21953 <indexterm role="option">
21954 <primary>host_lookup</primary>
21955 </indexterm>
21956 </para>
21957 <informaltable frame="all">
21958 <tgroup cols="4" colsep="0" rowsep="0">
21959 <colspec colwidth="8*" align="left"/>
21960 <colspec colwidth="5*" align="center"/>
21961 <colspec colwidth="5*" align="center"/>
21962 <colspec colwidth="6*" align="right"/>
21963 <tbody>
21964 <row>
21965 <entry><option>host_lookup</option></entry>
21966 <entry>Use: <emphasis>main</emphasis></entry>
21967 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
21968 <entry>Default: <emphasis>unset</emphasis></entry>
21969 </row>
21970 </tbody>
21971 </tgroup>
21972 </informaltable>
21973 <para>
21974 <indexterm role="concept">
21975 <primary>host name lookup</primary>
21976 <secondary>forcing</secondary>
21977 </indexterm>
21978 Exim does not look up the name of a calling host from its IP address unless it
21979 is required to compare against some host list, or the host matches
21980 <option>helo_try_verify_hosts</option> or <option>helo_verify_hosts</option>, or the host matches this
21981 option (which normally contains IP addresses rather than host names). The
21982 default configuration file contains
21983 </para>
21984 <literallayout class="monospaced">
21985 host_lookup = *
21986 </literallayout>
21987 <para>
21988 which causes a lookup to happen for all hosts. If the expense of these lookups
21989 is felt to be too great, the setting can be changed or removed.
21990 </para>
21991 <para>
21992 After a successful reverse lookup, Exim does a forward lookup on the name it
21993 has obtained, to verify that it yields the IP address that it started with. If
21994 this check fails, Exim behaves as if the name lookup failed.
21995 </para>
21996 <para>
21997 <indexterm role="concept">
21998 <primary><varname>$host_lookup_failed</varname></primary>
21999 </indexterm>
22000 <indexterm role="concept">
22001 <primary><varname>$sender_host_name</varname></primary>
22002 </indexterm>
22003 After any kind of failure, the host name (in <varname>$sender_host_name</varname>) remains
22004 unset, and <varname>$host_lookup_failed</varname> is set to the string <quote>1</quote>. See also
22005 <option>dns_again_means_nonexist</option>, <option>helo_lookup_domains</option>, and <literal>verify</literal> <literal>=</literal>
22006 <literal>reverse_host_lookup</literal> in ACLs.
22007 </para>
22008 <para>
22009 <indexterm role="option">
22010 <primary>host_lookup_order</primary>
22011 </indexterm>
22012 </para>
22013 <informaltable frame="all">
22014 <tgroup cols="4" colsep="0" rowsep="0">
22015 <colspec colwidth="8*" align="left"/>
22016 <colspec colwidth="5*" align="center"/>
22017 <colspec colwidth="5*" align="center"/>
22018 <colspec colwidth="6*" align="right"/>
22019 <tbody>
22020 <row>
22021 <entry><option>host_lookup_order</option></entry>
22022 <entry>Use: <emphasis>main</emphasis></entry>
22023 <entry>Type: <emphasis>string list</emphasis></entry>
22024 <entry>Default: <emphasis><literal>bydns:byaddr</literal></emphasis></entry>
22025 </row>
22026 </tbody>
22027 </tgroup>
22028 </informaltable>
22029 <para>
22030 This option specifies the order of different lookup methods when Exim is trying
22031 to find a host name from an IP address. The default is to do a DNS lookup
22032 first, and then to try a local lookup (using <function>gethostbyaddr()</function> or equivalent)
22033 if that fails. You can change the order of these lookups, or omit one entirely,
22034 if you want.
22035 </para>
22036 <para>
22037 <emphasis role="bold">Warning</emphasis>: The <quote>byaddr</quote> method does not always yield aliases when there are
22038 multiple PTR records in the DNS and the IP address is not listed in
22039 <filename>/etc/hosts</filename>. Different operating systems give different results in this
22040 case. That is why the default tries a DNS lookup first.
22041 </para>
22042 <para>
22043 <indexterm role="option">
22044 <primary>host_reject_connection</primary>
22045 </indexterm>
22046 </para>
22047 <informaltable frame="all">
22048 <tgroup cols="4" colsep="0" rowsep="0">
22049 <colspec colwidth="8*" align="left"/>
22050 <colspec colwidth="5*" align="center"/>
22051 <colspec colwidth="5*" align="center"/>
22052 <colspec colwidth="6*" align="right"/>
22053 <tbody>
22054 <row>
22055 <entry><option>host_reject_connection</option></entry>
22056 <entry>Use: <emphasis>main</emphasis></entry>
22057 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
22058 <entry>Default: <emphasis>unset</emphasis></entry>
22059 </row>
22060 </tbody>
22061 </tgroup>
22062 </informaltable>
22063 <para>
22064 <indexterm role="concept">
22065 <primary>host</primary>
22066 <secondary>rejecting connections from</secondary>
22067 </indexterm>
22068 If this option is set, incoming SMTP calls from the hosts listed are rejected
22069 as soon as the connection is made.
22070 This option is obsolete, and retained only for backward compatibility, because
22071 nowadays the ACL specified by <option>acl_smtp_connect</option> can also reject incoming
22072 connections immediately.
22073 </para>
22074 <para>
22075 The ability to give an immediate rejection (either by this option or using an
22076 ACL) is provided for use in unusual cases. Many hosts will just try again,
22077 sometimes without much delay. Normally, it is better to use an ACL to reject
22078 incoming messages at a later stage, such as after RCPT commands. See
22079 chapter <xref linkend="CHAPACL"/>.
22080 </para>
22081 <para>
22082 <indexterm role="option">
22083 <primary>hosts_connection_nolog</primary>
22084 </indexterm>
22085 </para>
22086 <informaltable frame="all">
22087 <tgroup cols="4" colsep="0" rowsep="0">
22088 <colspec colwidth="8*" align="left"/>
22089 <colspec colwidth="5*" align="center"/>
22090 <colspec colwidth="5*" align="center"/>
22091 <colspec colwidth="6*" align="right"/>
22092 <tbody>
22093 <row>
22094 <entry><option>hosts_connection_nolog</option></entry>
22095 <entry>Use: <emphasis>main</emphasis></entry>
22096 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
22097 <entry>Default: <emphasis>unset</emphasis></entry>
22098 </row>
22099 </tbody>
22100 </tgroup>
22101 </informaltable>
22102 <para>
22103 <indexterm role="concept">
22104 <primary>host</primary>
22105 <secondary>not logging connections from</secondary>
22106 </indexterm>
22107 This option defines a list of hosts for which connection logging does not
22108 happen, even though the <option>smtp_connection</option> log selector is set. For example,
22109 you might want not to log SMTP connections from local processes, or from
22110 127.0.0.1, or from your local LAN. This option is consulted in the main loop of
22111 the daemon; you should therefore strive to restrict its value to a short inline
22112 list of IP addresses and networks. To disable logging SMTP connections from
22113 local processes, you must create a host list with an empty item. For example:
22114 </para>
22115 <literallayout class="monospaced">
22116 hosts_connection_nolog = :
22117 </literallayout>
22118 <para>
22119 If the <option>smtp_connection</option> log selector is not set, this option has no effect.
22120 </para>
22121 <para>
22122 <indexterm role="option">
22123 <primary>hosts_treat_as_local</primary>
22124 </indexterm>
22125 </para>
22126 <informaltable frame="all">
22127 <tgroup cols="4" colsep="0" rowsep="0">
22128 <colspec colwidth="8*" align="left"/>
22129 <colspec colwidth="5*" align="center"/>
22130 <colspec colwidth="5*" align="center"/>
22131 <colspec colwidth="6*" align="right"/>
22132 <tbody>
22133 <row>
22134 <entry><option>hosts_treat_as_local</option></entry>
22135 <entry>Use: <emphasis>main</emphasis></entry>
22136 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
22137 <entry>Default: <emphasis>unset</emphasis></entry>
22138 </row>
22139 </tbody>
22140 </tgroup>
22141 </informaltable>
22142 <para>
22143 <indexterm role="concept">
22144 <primary>local host</primary>
22145 <secondary>domains treated as</secondary>
22146 </indexterm>
22147 <indexterm role="concept">
22148 <primary>host</primary>
22149 <secondary>treated as local</secondary>
22150 </indexterm>
22151 If this option is set, any host names that match the domain list are treated as
22152 if they were the local host when Exim is scanning host lists obtained from MX
22153 records
22154 or other sources. Note that the value of this option is a domain list, not a
22155 host list, because it is always used to check host names, not IP addresses.
22156 </para>
22157 <para>
22158 This option also applies when Exim is matching the special items
22159 <literal>@mx_any</literal>, <literal>@mx_primary</literal>, and <literal>@mx_secondary</literal> in a domain list (see
22160 section <xref linkend="SECTdomainlist"/>), and when checking the <option>hosts</option> option in the
22161 <command>smtp</command> transport for the local host (see the <option>allow_localhost</option> option in
22162 that transport). See also <option>local_interfaces</option>, <option>extra_local_interfaces</option>, and
22163 chapter <xref linkend="CHAPinterfaces"/>, which contains a discussion about local network
22164 interfaces and recognising the local host.
22165 </para>
22166 <para>
22167 <indexterm role="option">
22168 <primary>ignore_bounce_errors_after</primary>
22169 </indexterm>
22170 </para>
22171 <informaltable frame="all">
22172 <tgroup cols="4" colsep="0" rowsep="0">
22173 <colspec colwidth="8*" align="left"/>
22174 <colspec colwidth="5*" align="center"/>
22175 <colspec colwidth="5*" align="center"/>
22176 <colspec colwidth="6*" align="right"/>
22177 <tbody>
22178 <row>
22179 <entry><option>ignore_bounce_errors_after</option></entry>
22180 <entry>Use: <emphasis>main</emphasis></entry>
22181 <entry>Type: <emphasis>time</emphasis></entry>
22182 <entry>Default: <emphasis>10w</emphasis></entry>
22183 </row>
22184 </tbody>
22185 </tgroup>
22186 </informaltable>
22187 <para>
22188 <indexterm role="concept">
22189 <primary>bounce message</primary>
22190 <secondary>discarding</secondary>
22191 </indexterm>
22192 <indexterm role="concept">
22193 <primary>discarding bounce message</primary>
22194 </indexterm>
22195 This option affects the processing of bounce messages that cannot be delivered,
22196 that is, those that suffer a permanent delivery failure. (Bounce messages that
22197 suffer temporary delivery failures are of course retried in the usual way.)
22198 </para>
22199 <para>
22200 After a permanent delivery failure, bounce messages are frozen,
22201 because there is no sender to whom they can be returned. When a frozen bounce
22202 message has been on the queue for more than the given time, it is unfrozen at
22203 the next queue run, and a further delivery is attempted. If delivery fails
22204 again, the bounce message is discarded. This makes it possible to keep failed
22205 bounce messages around for a shorter time than the normal maximum retry time
22206 for frozen messages. For example,
22207 </para>
22208 <literallayout class="monospaced">
22209 ignore_bounce_errors_after = 12h
22210 </literallayout>
22211 <para>
22212 retries failed bounce message deliveries after 12 hours, discarding any further
22213 failures. If the value of this option is set to a zero time period, bounce
22214 failures are discarded immediately. Setting a very long time (as in the default
22215 value) has the effect of disabling this option. For ways of automatically
22216 dealing with other kinds of frozen message, see <option>auto_thaw</option> and
22217 <option>timeout_frozen_after</option>.
22218 </para>
22219 <para>
22220 <indexterm role="option">
22221 <primary>ignore_fromline_hosts</primary>
22222 </indexterm>
22223 </para>
22224 <informaltable frame="all">
22225 <tgroup cols="4" colsep="0" rowsep="0">
22226 <colspec colwidth="8*" align="left"/>
22227 <colspec colwidth="5*" align="center"/>
22228 <colspec colwidth="5*" align="center"/>
22229 <colspec colwidth="6*" align="right"/>
22230 <tbody>
22231 <row>
22232 <entry><option>ignore_fromline_hosts</option></entry>
22233 <entry>Use: <emphasis>main</emphasis></entry>
22234 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
22235 <entry>Default: <emphasis>unset</emphasis></entry>
22236 </row>
22237 </tbody>
22238 </tgroup>
22239 </informaltable>
22240 <para>
22241 <indexterm role="concept">
22242 <primary><quote>From</quote> line</primary>
22243 </indexterm>
22244 <indexterm role="concept">
22245 <primary>UUCP</primary>
22246 <secondary><quote>From</quote> line</secondary>
22247 </indexterm>
22248 Some broken SMTP clients insist on sending a UUCP-like <quote>From&nbsp;</quote> line before
22249 the headers of a message. By default this is treated as the start of the
22250 message&#x2019;s body, which means that any following headers are not recognized as
22251 such. Exim can be made to ignore it by setting <option>ignore_fromline_hosts</option> to
22252 match those hosts that insist on sending it. If the sender is actually a local
22253 process rather than a remote host, and is using <option>-bs</option> to inject the messages,
22254 <option>ignore_fromline_local</option> must be set to achieve this effect.
22255 </para>
22256 <para>
22257 <indexterm role="option">
22258 <primary>ignore_fromline_local</primary>
22259 </indexterm>
22260 </para>
22261 <informaltable frame="all">
22262 <tgroup cols="4" colsep="0" rowsep="0">
22263 <colspec colwidth="8*" align="left"/>
22264 <colspec colwidth="5*" align="center"/>
22265 <colspec colwidth="5*" align="center"/>
22266 <colspec colwidth="6*" align="right"/>
22267 <tbody>
22268 <row>
22269 <entry><option>ignore_fromline_local</option></entry>
22270 <entry>Use: <emphasis>main</emphasis></entry>
22271 <entry>Type: <emphasis>boolean</emphasis></entry>
22272 <entry>Default: <emphasis>false</emphasis></entry>
22273 </row>
22274 </tbody>
22275 </tgroup>
22276 </informaltable>
22277 <para>
22278 See <option>ignore_fromline_hosts</option> above.
22279 </para>
22280 <para>
22281 <indexterm role="option">
22282 <primary>keep_malformed</primary>
22283 </indexterm>
22284 </para>
22285 <informaltable frame="all">
22286 <tgroup cols="4" colsep="0" rowsep="0">
22287 <colspec colwidth="8*" align="left"/>
22288 <colspec colwidth="5*" align="center"/>
22289 <colspec colwidth="5*" align="center"/>
22290 <colspec colwidth="6*" align="right"/>
22291 <tbody>
22292 <row>
22293 <entry><option>keep_malformed</option></entry>
22294 <entry>Use: <emphasis>main</emphasis></entry>
22295 <entry>Type: <emphasis>time</emphasis></entry>
22296 <entry>Default: <emphasis>4d</emphasis></entry>
22297 </row>
22298 </tbody>
22299 </tgroup>
22300 </informaltable>
22301 <para>
22302 This option specifies the length of time to keep messages whose spool files
22303 have been corrupted in some way. This should, of course, never happen. At the
22304 next attempt to deliver such a message, it gets removed. The incident is
22305 logged.
22306 </para>
22307 <para>
22308 <indexterm role="option">
22309 <primary>ldap_default_servers</primary>
22310 </indexterm>
22311 </para>
22312 <informaltable frame="all">
22313 <tgroup cols="4" colsep="0" rowsep="0">
22314 <colspec colwidth="8*" align="left"/>
22315 <colspec colwidth="5*" align="center"/>
22316 <colspec colwidth="5*" align="center"/>
22317 <colspec colwidth="6*" align="right"/>
22318 <tbody>
22319 <row>
22320 <entry><option>ldap_default_servers</option></entry>
22321 <entry>Use: <emphasis>main</emphasis></entry>
22322 <entry>Type: <emphasis>string list</emphasis></entry>
22323 <entry>Default: <emphasis>unset</emphasis></entry>
22324 </row>
22325 </tbody>
22326 </tgroup>
22327 </informaltable>
22328 <para>
22329 <indexterm role="concept">
22330 <primary>LDAP</primary>
22331 <secondary>default servers</secondary>
22332 </indexterm>
22333 This option provides a list of LDAP servers which are tried in turn when an
22334 LDAP query does not contain a server. See section <xref linkend="SECTforldaque"/> for
22335 details of LDAP queries. This option is available only when Exim has been built
22336 with LDAP support.
22337 </para>
22338 <para>
22339 <indexterm role="option">
22340 <primary>ldap_version</primary>
22341 </indexterm>
22342 </para>
22343 <informaltable frame="all">
22344 <tgroup cols="4" colsep="0" rowsep="0">
22345 <colspec colwidth="8*" align="left"/>
22346 <colspec colwidth="5*" align="center"/>
22347 <colspec colwidth="5*" align="center"/>
22348 <colspec colwidth="6*" align="right"/>
22349 <tbody>
22350 <row>
22351 <entry><option>ldap_version</option></entry>
22352 <entry>Use: <emphasis>main</emphasis></entry>
22353 <entry>Type: <emphasis>integer</emphasis></entry>
22354 <entry>Default: <emphasis>unset</emphasis></entry>
22355 </row>
22356 </tbody>
22357 </tgroup>
22358 </informaltable>
22359 <para>
22360 <indexterm role="concept">
22361 <primary>LDAP protocol version</primary>
22362 <secondary>forcing</secondary>
22363 </indexterm>
22364 This option can be used to force Exim to set a specific protocol version for
22365 LDAP. If it option is unset, it is shown by the <option>-bP</option> command line option as
22366 -1. When this is the case, the default is 3 if LDAP_VERSION3 is defined in
22367 the LDAP headers; otherwise it is 2. This option is available only when Exim
22368 has been built with LDAP support.
22369 </para>
22370 <para>
22371 <indexterm role="option">
22372 <primary>local_from_check</primary>
22373 </indexterm>
22374 </para>
22375 <informaltable frame="all">
22376 <tgroup cols="4" colsep="0" rowsep="0">
22377 <colspec colwidth="8*" align="left"/>
22378 <colspec colwidth="5*" align="center"/>
22379 <colspec colwidth="5*" align="center"/>
22380 <colspec colwidth="6*" align="right"/>
22381 <tbody>
22382 <row>
22383 <entry><option>local_from_check</option></entry>
22384 <entry>Use: <emphasis>main</emphasis></entry>
22385 <entry>Type: <emphasis>boolean</emphasis></entry>
22386 <entry>Default: <emphasis>true</emphasis></entry>
22387 </row>
22388 </tbody>
22389 </tgroup>
22390 </informaltable>
22391 <para>
22392 <indexterm role="concept">
22393 <primary><emphasis>Sender:</emphasis> header line</primary>
22394 <secondary>disabling addition of</secondary>
22395 </indexterm>
22396 <indexterm role="concept">
22397 <primary><emphasis>From:</emphasis> header line</primary>
22398 <secondary>disabling checking of</secondary>
22399 </indexterm>
22400 When a message is submitted locally (that is, not over a TCP/IP connection) by
22401 an untrusted user, Exim removes any existing <emphasis>Sender:</emphasis> header line, and
22402 checks that the <emphasis>From:</emphasis> header line matches the login of the calling user and
22403 the domain specified by <option>qualify_domain</option>.
22404 </para>
22405 <para>
22406 <emphasis role="bold">Note</emphasis>: An unqualified address (no domain) in the <emphasis>From:</emphasis> header in a
22407 locally submitted message is automatically qualified by Exim, unless the
22408 <option>-bnq</option> command line option is used.
22409 </para>
22410 <para>
22411 You can use <option>local_from_prefix</option> and <option>local_from_suffix</option> to permit affixes
22412 on the local part. If the <emphasis>From:</emphasis> header line does not match, Exim adds a
22413 <emphasis>Sender:</emphasis> header with an address constructed from the calling user&#x2019;s login
22414 and the default qualify domain.
22415 </para>
22416 <para>
22417 If <option>local_from_check</option> is set false, the <emphasis>From:</emphasis> header check is disabled,
22418 and no <emphasis>Sender:</emphasis> header is ever added. If, in addition, you want to retain
22419 <emphasis>Sender:</emphasis> header lines supplied by untrusted users, you must also set
22420 <option>local_sender_retain</option> to be true.
22421 </para>
22422 <para>
22423 <indexterm role="concept">
22424 <primary>envelope sender</primary>
22425 </indexterm>
22426 These options affect only the header lines in the message. The envelope sender
22427 is still forced to be the login id at the qualify domain unless
22428 <option>untrusted_set_sender</option> permits the user to supply an envelope sender.
22429 </para>
22430 <para>
22431 For messages received over TCP/IP, an ACL can specify <quote>submission mode</quote> to
22432 request similar header line checking. See section <xref linkend="SECTthesenhea"/>, which
22433 has more details about <emphasis>Sender:</emphasis> processing.
22434 </para>
22435 <para>
22436 <indexterm role="option">
22437 <primary>local_from_prefix</primary>
22438 </indexterm>
22439 </para>
22440 <informaltable frame="all">
22441 <tgroup cols="4" colsep="0" rowsep="0">
22442 <colspec colwidth="8*" align="left"/>
22443 <colspec colwidth="5*" align="center"/>
22444 <colspec colwidth="5*" align="center"/>
22445 <colspec colwidth="6*" align="right"/>
22446 <tbody>
22447 <row>
22448 <entry><option>local_from_prefix</option></entry>
22449 <entry>Use: <emphasis>main</emphasis></entry>
22450 <entry>Type: <emphasis>string</emphasis></entry>
22451 <entry>Default: <emphasis>unset</emphasis></entry>
22452 </row>
22453 </tbody>
22454 </tgroup>
22455 </informaltable>
22456 <para>
22457 When Exim checks the <emphasis>From:</emphasis> header line of locally submitted messages for
22458 matching the login id (see <option>local_from_check</option> above), it can be configured to
22459 ignore certain prefixes and suffixes in the local part of the address. This is
22460 done by setting <option>local_from_prefix</option> and/or <option>local_from_suffix</option> to
22461 appropriate lists, in the same form as the <option>local_part_prefix</option> and
22462 <option>local_part_suffix</option> router options (see chapter <xref linkend="CHAProutergeneric"/>). For
22463 example, if
22464 </para>
22465 <literallayout class="monospaced">
22466 local_from_prefix = *-
22467 </literallayout>
22468 <para>
22469 is set, a <emphasis>From:</emphasis> line containing
22470 </para>
22471 <literallayout class="monospaced">
22472 From: anything-user@your.domain.example
22473 </literallayout>
22474 <para>
22475 will not cause a <emphasis>Sender:</emphasis> header to be added if <emphasis>user@your.domain.example</emphasis>
22476 matches the actual sender address that is constructed from the login name and
22477 qualify domain.
22478 </para>
22479 <para>
22480 <indexterm role="option">
22481 <primary>local_from_suffix</primary>
22482 </indexterm>
22483 </para>
22484 <informaltable frame="all">
22485 <tgroup cols="4" colsep="0" rowsep="0">
22486 <colspec colwidth="8*" align="left"/>
22487 <colspec colwidth="5*" align="center"/>
22488 <colspec colwidth="5*" align="center"/>
22489 <colspec colwidth="6*" align="right"/>
22490 <tbody>
22491 <row>
22492 <entry><option>local_from_suffix</option></entry>
22493 <entry>Use: <emphasis>main</emphasis></entry>
22494 <entry>Type: <emphasis>string</emphasis></entry>
22495 <entry>Default: <emphasis>unset</emphasis></entry>
22496 </row>
22497 </tbody>
22498 </tgroup>
22499 </informaltable>
22500 <para>
22501 See <option>local_from_prefix</option> above.
22502 </para>
22503 <para>
22504 <indexterm role="option">
22505 <primary>local_interfaces</primary>
22506 </indexterm>
22507 </para>
22508 <informaltable frame="all">
22509 <tgroup cols="4" colsep="0" rowsep="0">
22510 <colspec colwidth="8*" align="left"/>
22511 <colspec colwidth="5*" align="center"/>
22512 <colspec colwidth="5*" align="center"/>
22513 <colspec colwidth="6*" align="right"/>
22514 <tbody>
22515 <row>
22516 <entry><option>local_interfaces</option></entry>
22517 <entry>Use: <emphasis>main</emphasis></entry>
22518 <entry>Type: <emphasis>string list</emphasis></entry>
22519 <entry>Default: <emphasis>see below</emphasis></entry>
22520 </row>
22521 </tbody>
22522 </tgroup>
22523 </informaltable>
22524 <para>
22525 This option controls which network interfaces are used by the daemon for
22526 listening; they are also used to identify the local host when routing. Chapter
22527 <xref linkend="CHAPinterfaces"/> contains a full description of this option and the related
22528 options <option>daemon_smtp_ports</option>, <option>extra_local_interfaces</option>,
22529 <option>hosts_treat_as_local</option>, and <option>tls_on_connect_ports</option>. The default value for
22530 <option>local_interfaces</option> is
22531 </para>
22532 <literallayout class="monospaced">
22533 local_interfaces = 0.0.0.0
22534 </literallayout>
22535 <para>
22536 when Exim is built without IPv6 support; otherwise it is
22537 </para>
22538 <literallayout class="monospaced">
22539 local_interfaces = &lt;; ::0 ; 0.0.0.0
22540 </literallayout>
22541 <para>
22542 <indexterm role="option">
22543 <primary>local_scan_timeout</primary>
22544 </indexterm>
22545 </para>
22546 <informaltable frame="all">
22547 <tgroup cols="4" colsep="0" rowsep="0">
22548 <colspec colwidth="8*" align="left"/>
22549 <colspec colwidth="5*" align="center"/>
22550 <colspec colwidth="5*" align="center"/>
22551 <colspec colwidth="6*" align="right"/>
22552 <tbody>
22553 <row>
22554 <entry><option>local_scan_timeout</option></entry>
22555 <entry>Use: <emphasis>main</emphasis></entry>
22556 <entry>Type: <emphasis>time</emphasis></entry>
22557 <entry>Default: <emphasis>5m</emphasis></entry>
22558 </row>
22559 </tbody>
22560 </tgroup>
22561 </informaltable>
22562 <para>
22563 <indexterm role="concept">
22564 <primary>timeout</primary>
22565 <secondary>for <function>local_scan()</function> function</secondary>
22566 </indexterm>
22567 <indexterm role="concept">
22568 <primary><function>local_scan()</function> function</primary>
22569 <secondary>timeout</secondary>
22570 </indexterm>
22571 This timeout applies to the <function>local_scan()</function> function (see chapter
22572 <xref linkend="CHAPlocalscan"/>). Zero means <quote>no timeout</quote>. If the timeout is exceeded,
22573 the incoming message is rejected with a temporary error if it is an SMTP
22574 message. For a non-SMTP message, the message is dropped and Exim ends with a
22575 non-zero code. The incident is logged on the main and reject logs.
22576 </para>
22577 <para>
22578 <indexterm role="option">
22579 <primary>local_sender_retain</primary>
22580 </indexterm>
22581 </para>
22582 <informaltable frame="all">
22583 <tgroup cols="4" colsep="0" rowsep="0">
22584 <colspec colwidth="8*" align="left"/>
22585 <colspec colwidth="5*" align="center"/>
22586 <colspec colwidth="5*" align="center"/>
22587 <colspec colwidth="6*" align="right"/>
22588 <tbody>
22589 <row>
22590 <entry><option>local_sender_retain</option></entry>
22591 <entry>Use: <emphasis>main</emphasis></entry>
22592 <entry>Type: <emphasis>boolean</emphasis></entry>
22593 <entry>Default: <emphasis>false</emphasis></entry>
22594 </row>
22595 </tbody>
22596 </tgroup>
22597 </informaltable>
22598 <para>
22599 <indexterm role="concept">
22600 <primary><emphasis>Sender:</emphasis> header line</primary>
22601 <secondary>retaining from local submission</secondary>
22602 </indexterm>
22603 When a message is submitted locally (that is, not over a TCP/IP connection) by
22604 an untrusted user, Exim removes any existing <emphasis>Sender:</emphasis> header line. If you
22605 do not want this to happen, you must set <option>local_sender_retain</option>, and you must
22606 also set <option>local_from_check</option> to be false (Exim will complain if you do not).
22607 See also the ACL modifier <literal>control = suppress_local_fixups</literal>. Section
22608 <xref linkend="SECTthesenhea"/> has more details about <emphasis>Sender:</emphasis> processing.
22609 </para>
22610 <para>
22611 <indexterm role="option">
22612 <primary>localhost_number</primary>
22613 </indexterm>
22614 </para>
22615 <informaltable frame="all">
22616 <tgroup cols="4" colsep="0" rowsep="0">
22617 <colspec colwidth="8*" align="left"/>
22618 <colspec colwidth="5*" align="center"/>
22619 <colspec colwidth="5*" align="center"/>
22620 <colspec colwidth="6*" align="right"/>
22621 <tbody>
22622 <row>
22623 <entry><option>localhost_number</option></entry>
22624 <entry>Use: <emphasis>main</emphasis></entry>
22625 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
22626 <entry>Default: <emphasis>unset</emphasis></entry>
22627 </row>
22628 </tbody>
22629 </tgroup>
22630 </informaltable>
22631 <para>
22632 <indexterm role="concept">
22633 <primary>host</primary>
22634 <secondary>locally unique number for</secondary>
22635 </indexterm>
22636 <indexterm role="concept">
22637 <primary>message ids</primary>
22638 <secondary>with multiple hosts</secondary>
22639 </indexterm>
22640 <indexterm role="concept">
22641 <primary><varname>$localhost_number</varname></primary>
22642 </indexterm>
22643 Exim&#x2019;s message ids are normally unique only within the local host. If
22644 uniqueness among a set of hosts is required, each host must set a different
22645 value for the <option>localhost_number</option> option. The string is expanded immediately
22646 after reading the configuration file (so that a number can be computed from the
22647 host name, for example) and the result of the expansion must be a number in the
22648 range 0&ndash;16 (or 0&ndash;10 on operating systems with case-insensitive file
22649 systems). This is available in subsequent string expansions via the variable
22650 <varname>$localhost_number</varname>. When <option>localhost_number is set</option>, the final two
22651 characters of the message id, instead of just being a fractional part of the
22652 time, are computed from the time and the local host number as described in
22653 section <xref linkend="SECTmessiden"/>.
22654 </para>
22655 <para>
22656 <indexterm role="option">
22657 <primary>log_file_path</primary>
22658 </indexterm>
22659 </para>
22660 <informaltable frame="all">
22661 <tgroup cols="4" colsep="0" rowsep="0">
22662 <colspec colwidth="8*" align="left"/>
22663 <colspec colwidth="5*" align="center"/>
22664 <colspec colwidth="5*" align="center"/>
22665 <colspec colwidth="6*" align="right"/>
22666 <tbody>
22667 <row>
22668 <entry><option>log_file_path</option></entry>
22669 <entry>Use: <emphasis>main</emphasis></entry>
22670 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
22671 <entry>Default: <emphasis>set at compile time</emphasis></entry>
22672 </row>
22673 </tbody>
22674 </tgroup>
22675 </informaltable>
22676 <para>
22677 <indexterm role="concept">
22678 <primary>log</primary>
22679 <secondary>file path for</secondary>
22680 </indexterm>
22681 This option sets the path which is used to determine the names of Exim&#x2019;s log
22682 files, or indicates that logging is to be to syslog, or both. It is expanded
22683 when Exim is entered, so it can, for example, contain a reference to the host
22684 name. If no specific path is set for the log files at compile or run time, they
22685 are written in a sub-directory called <filename>log</filename> in Exim&#x2019;s spool directory.
22686 Chapter <xref linkend="CHAPlog"/> contains further details about Exim&#x2019;s logging, and
22687 section <xref linkend="SECTwhelogwri"/> describes how the contents of <option>log_file_path</option> are
22688 used. If this string is fixed at your installation (contains no expansion
22689 variables) it is recommended that you do not set this option in the
22690 configuration file, but instead supply the path using LOG_FILE_PATH in
22691 <filename>Local/Makefile</filename> so that it is available to Exim for logging errors detected
22692 early on &ndash; in particular, failure to read the configuration file.
22693 </para>
22694 <para>
22695 <indexterm role="option">
22696 <primary>log_selector</primary>
22697 </indexterm>
22698 </para>
22699 <informaltable frame="all">
22700 <tgroup cols="4" colsep="0" rowsep="0">
22701 <colspec colwidth="8*" align="left"/>
22702 <colspec colwidth="5*" align="center"/>
22703 <colspec colwidth="5*" align="center"/>
22704 <colspec colwidth="6*" align="right"/>
22705 <tbody>
22706 <row>
22707 <entry><option>log_selector</option></entry>
22708 <entry>Use: <emphasis>main</emphasis></entry>
22709 <entry>Type: <emphasis>string</emphasis></entry>
22710 <entry>Default: <emphasis>unset</emphasis></entry>
22711 </row>
22712 </tbody>
22713 </tgroup>
22714 </informaltable>
22715 <para>
22716 <indexterm role="concept">
22717 <primary>log</primary>
22718 <secondary>selectors</secondary>
22719 </indexterm>
22720 This option can be used to reduce or increase the number of things that Exim
22721 writes to its log files. Its argument is made up of names preceded by plus or
22722 minus characters. For example:
22723 </para>
22724 <literallayout class="monospaced">
22725 log_selector = +arguments -retry_defer
22726 </literallayout>
22727 <para>
22728 A list of possible names and what they control is given in the chapter on
22729 logging, in section <xref linkend="SECTlogselector"/>.
22730 </para>
22731 <para>
22732 <indexterm role="option">
22733 <primary>log_timezone</primary>
22734 </indexterm>
22735 </para>
22736 <informaltable frame="all">
22737 <tgroup cols="4" colsep="0" rowsep="0">
22738 <colspec colwidth="8*" align="left"/>
22739 <colspec colwidth="5*" align="center"/>
22740 <colspec colwidth="5*" align="center"/>
22741 <colspec colwidth="6*" align="right"/>
22742 <tbody>
22743 <row>
22744 <entry><option>log_timezone</option></entry>
22745 <entry>Use: <emphasis>main</emphasis></entry>
22746 <entry>Type: <emphasis>boolean</emphasis></entry>
22747 <entry>Default: <emphasis>false</emphasis></entry>
22748 </row>
22749 </tbody>
22750 </tgroup>
22751 </informaltable>
22752 <para>
22753 <indexterm role="concept">
22754 <primary>log</primary>
22755 <secondary>timezone for entries</secondary>
22756 </indexterm>
22757 <indexterm role="concept">
22758 <primary><varname>$tod_log</varname></primary>
22759 </indexterm>
22760 <indexterm role="concept">
22761 <primary><varname>$tod_zone</varname></primary>
22762 </indexterm>
22763 By default, the timestamps on log lines are in local time without the
22764 timezone. This means that if your timezone changes twice a year, the timestamps
22765 in log lines are ambiguous for an hour when the clocks go back. One way of
22766 avoiding this problem is to set the timezone to UTC. An alternative is to set
22767 <option>log_timezone</option> true. This turns on the addition of the timezone offset to
22768 timestamps in log lines. Turning on this option can add quite a lot to the size
22769 of log files because each line is extended by 6 characters. Note that the
22770 <varname>$tod_log</varname> variable contains the log timestamp without the zone, but there is
22771 another variable called <varname>$tod_zone</varname> that contains just the timezone offset.
22772 </para>
22773 <para>
22774 <indexterm role="option">
22775 <primary>lookup_open_max</primary>
22776 </indexterm>
22777 </para>
22778 <informaltable frame="all">
22779 <tgroup cols="4" colsep="0" rowsep="0">
22780 <colspec colwidth="8*" align="left"/>
22781 <colspec colwidth="5*" align="center"/>
22782 <colspec colwidth="5*" align="center"/>
22783 <colspec colwidth="6*" align="right"/>
22784 <tbody>
22785 <row>
22786 <entry><option>lookup_open_max</option></entry>
22787 <entry>Use: <emphasis>main</emphasis></entry>
22788 <entry>Type: <emphasis>integer</emphasis></entry>
22789 <entry>Default: <emphasis>25</emphasis></entry>
22790 </row>
22791 </tbody>
22792 </tgroup>
22793 </informaltable>
22794 <para>
22795 <indexterm role="concept">
22796 <primary>too many open files</primary>
22797 </indexterm>
22798 <indexterm role="concept">
22799 <primary>open files</primary>
22800 <secondary>too many</secondary>
22801 </indexterm>
22802 <indexterm role="concept">
22803 <primary>file</primary>
22804 <secondary>too many open</secondary>
22805 </indexterm>
22806 <indexterm role="concept">
22807 <primary>lookup</primary>
22808 <secondary>maximum open files</secondary>
22809 </indexterm>
22810 <indexterm role="concept">
22811 <primary>limit</primary>
22812 <secondary>open files for lookups</secondary>
22813 </indexterm>
22814 This option limits the number of simultaneously open files for single-key
22815 lookups that use regular files (that is, <command>lsearch</command>, <command>dbm</command>, and <command>cdb</command>).
22816 Exim normally keeps these files open during routing, because often the same
22817 file is required several times. If the limit is reached, Exim closes the least
22818 recently used file. Note that if you are using the <emphasis>ndbm</emphasis> library, it
22819 actually opens two files for each logical DBM database, though it still counts
22820 as one for the purposes of <option>lookup_open_max</option>. If you are getting <quote>too many
22821 open files</quote> errors with NDBM, you need to reduce the value of
22822 <option>lookup_open_max</option>.
22823 </para>
22824 <para>
22825 <indexterm role="option">
22826 <primary>max_username_length</primary>
22827 </indexterm>
22828 </para>
22829 <informaltable frame="all">
22830 <tgroup cols="4" colsep="0" rowsep="0">
22831 <colspec colwidth="8*" align="left"/>
22832 <colspec colwidth="5*" align="center"/>
22833 <colspec colwidth="5*" align="center"/>
22834 <colspec colwidth="6*" align="right"/>
22835 <tbody>
22836 <row>
22837 <entry><option>max_username_length</option></entry>
22838 <entry>Use: <emphasis>main</emphasis></entry>
22839 <entry>Type: <emphasis>integer</emphasis></entry>
22840 <entry>Default: <emphasis>0</emphasis></entry>
22841 </row>
22842 </tbody>
22843 </tgroup>
22844 </informaltable>
22845 <para>
22846 <indexterm role="concept">
22847 <primary>length</primary>
22848 <secondary>of login name</secondary>
22849 </indexterm>
22850 <indexterm role="concept">
22851 <primary>user name</primary>
22852 <secondary>maximum length</secondary>
22853 </indexterm>
22854 <indexterm role="concept">
22855 <primary>limit</primary>
22856 <secondary>user name length</secondary>
22857 </indexterm>
22858 Some operating systems are broken in that they truncate long arguments to
22859 <function>getpwnam()</function> to eight characters, instead of returning <quote>no such user</quote>. If
22860 this option is set greater than zero, any attempt to call <function>getpwnam()</function> with
22861 an argument that is longer behaves as if <function>getpwnam()</function> failed.
22862 </para>
22863 <para>
22864 <indexterm role="option">
22865 <primary>message_body_visible</primary>
22866 </indexterm>
22867 </para>
22868 <informaltable frame="all">
22869 <tgroup cols="4" colsep="0" rowsep="0">
22870 <colspec colwidth="8*" align="left"/>
22871 <colspec colwidth="5*" align="center"/>
22872 <colspec colwidth="5*" align="center"/>
22873 <colspec colwidth="6*" align="right"/>
22874 <tbody>
22875 <row>
22876 <entry><option>message_body_visible</option></entry>
22877 <entry>Use: <emphasis>main</emphasis></entry>
22878 <entry>Type: <emphasis>integer</emphasis></entry>
22879 <entry>Default: <emphasis>500</emphasis></entry>
22880 </row>
22881 </tbody>
22882 </tgroup>
22883 </informaltable>
22884 <para>
22885 <indexterm role="concept">
22886 <primary>body of message</primary>
22887 <secondary>visible size</secondary>
22888 </indexterm>
22889 <indexterm role="concept">
22890 <primary>message body</primary>
22891 <secondary>visible size</secondary>
22892 </indexterm>
22893 <indexterm role="concept">
22894 <primary><varname>$message_body</varname></primary>
22895 </indexterm>
22896 <indexterm role="concept">
22897 <primary><varname>$message_body_end</varname></primary>
22898 </indexterm>
22899 This option specifies how much of a message&#x2019;s body is to be included in the
22900 <varname>$message_body</varname> and <varname>$message_body_end</varname> expansion variables.
22901 </para>
22902 <para>
22903 <indexterm role="option">
22904 <primary>message_id_header_domain</primary>
22905 </indexterm>
22906 </para>
22907 <informaltable frame="all">
22908 <tgroup cols="4" colsep="0" rowsep="0">
22909 <colspec colwidth="8*" align="left"/>
22910 <colspec colwidth="5*" align="center"/>
22911 <colspec colwidth="5*" align="center"/>
22912 <colspec colwidth="6*" align="right"/>
22913 <tbody>
22914 <row>
22915 <entry><option>message_id_header_domain</option></entry>
22916 <entry>Use: <emphasis>main</emphasis></entry>
22917 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
22918 <entry>Default: <emphasis>unset</emphasis></entry>
22919 </row>
22920 </tbody>
22921 </tgroup>
22922 </informaltable>
22923 <para>
22924 <indexterm role="concept">
22925 <primary><emphasis>Message-ID:</emphasis> header line</primary>
22926 </indexterm>
22927 If this option is set, the string is expanded and used as the right hand side
22928 (domain) of the <emphasis>Message-ID:</emphasis> header that Exim creates if a
22929 locally-originated incoming message does not have one. <quote>Locally-originated</quote>
22930 means <quote>not received over TCP/IP.</quote>
22931 Otherwise, the primary host name is used.
22932 Only letters, digits, dot and hyphen are accepted; any other characters are
22933 replaced by hyphens. If the expansion is forced to fail, or if the result is an
22934 empty string, the option is ignored.
22935 </para>
22936 <para>
22937 <indexterm role="option">
22938 <primary>message_id_header_text</primary>
22939 </indexterm>
22940 </para>
22941 <informaltable frame="all">
22942 <tgroup cols="4" colsep="0" rowsep="0">
22943 <colspec colwidth="8*" align="left"/>
22944 <colspec colwidth="5*" align="center"/>
22945 <colspec colwidth="5*" align="center"/>
22946 <colspec colwidth="6*" align="right"/>
22947 <tbody>
22948 <row>
22949 <entry><option>message_id_header_text</option></entry>
22950 <entry>Use: <emphasis>main</emphasis></entry>
22951 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
22952 <entry>Default: <emphasis>unset</emphasis></entry>
22953 </row>
22954 </tbody>
22955 </tgroup>
22956 </informaltable>
22957 <para>
22958 If this variable is set, the string is expanded and used to augment the text of
22959 the <emphasis>Message-id:</emphasis> header that Exim creates if a locally-originated incoming
22960 message does not have one. The text of this header is required by RFC 2822 to
22961 take the form of an address. By default, Exim uses its internal message id as
22962 the local part, and the primary host name as the domain. If this option is set,
22963 it is expanded, and provided the expansion is not forced to fail, and does not
22964 yield an empty string, the result is inserted into the header immediately
22965 before the @, separated from the internal message id by a dot. Any characters
22966 that are illegal in an address are automatically converted into hyphens. This
22967 means that variables such as <varname>$tod_log</varname> can be used, because the spaces and
22968 colons will become hyphens.
22969 </para>
22970 <para>
22971 <indexterm role="option">
22972 <primary>message_logs</primary>
22973 </indexterm>
22974 </para>
22975 <informaltable frame="all">
22976 <tgroup cols="4" colsep="0" rowsep="0">
22977 <colspec colwidth="8*" align="left"/>
22978 <colspec colwidth="5*" align="center"/>
22979 <colspec colwidth="5*" align="center"/>
22980 <colspec colwidth="6*" align="right"/>
22981 <tbody>
22982 <row>
22983 <entry><option>message_logs</option></entry>
22984 <entry>Use: <emphasis>main</emphasis></entry>
22985 <entry>Type: <emphasis>boolean</emphasis></entry>
22986 <entry>Default: <emphasis>true</emphasis></entry>
22987 </row>
22988 </tbody>
22989 </tgroup>
22990 </informaltable>
22991 <para>
22992 <indexterm role="concept">
22993 <primary>message log</primary>
22994 <secondary>disabling</secondary>
22995 </indexterm>
22996 <indexterm role="concept">
22997 <primary>log</primary>
22998 <secondary>message log; disabling</secondary>
22999 </indexterm>
23000 If this option is turned off, per-message log files are not created in the
23001 <filename>msglog</filename> spool sub-directory. This reduces the amount of disk I/O required by
23002 Exim, by reducing the number of files involved in handling a message from a
23003 minimum of four (header spool file, body spool file, delivery journal, and
23004 per-message log) to three. The other major I/O activity is Exim&#x2019;s main log,
23005 which is not affected by this option.
23006 </para>
23007 <para>
23008 <indexterm role="option">
23009 <primary>message_size_limit</primary>
23010 </indexterm>
23011 </para>
23012 <informaltable frame="all">
23013 <tgroup cols="4" colsep="0" rowsep="0">
23014 <colspec colwidth="8*" align="left"/>
23015 <colspec colwidth="5*" align="center"/>
23016 <colspec colwidth="5*" align="center"/>
23017 <colspec colwidth="6*" align="right"/>
23018 <tbody>
23019 <row>
23020 <entry><option>message_size_limit</option></entry>
23021 <entry>Use: <emphasis>main</emphasis></entry>
23022 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23023 <entry>Default: <emphasis>50M</emphasis></entry>
23024 </row>
23025 </tbody>
23026 </tgroup>
23027 </informaltable>
23028 <para>
23029 <indexterm role="concept">
23030 <primary>message</primary>
23031 <secondary>size limit</secondary>
23032 </indexterm>
23033 <indexterm role="concept">
23034 <primary>limit</primary>
23035 <secondary>message size</secondary>
23036 </indexterm>
23037 <indexterm role="concept">
23038 <primary>size of message</primary>
23039 <secondary>limit</secondary>
23040 </indexterm>
23041 This option limits the maximum size of message that Exim will process. The
23042 value is expanded for each incoming
23043 connection so, for example, it can be made to depend on the IP address of the
23044 remote host for messages arriving via TCP/IP. <emphasis role="bold">Note</emphasis>: This limit cannot be
23045 made to depend on a message&#x2019;s sender or any other properties of an individual
23046 message, because it has to be advertised in the server&#x2019;s response to EHLO.
23047 String expansion failure causes a temporary error. A value of zero means no
23048 limit, but its use is not recommended. See also <option>bounce_return_size_limit</option>.
23049 </para>
23050 <para>
23051 Incoming SMTP messages are failed with a 552 error if the limit is
23052 exceeded; locally-generated messages either get a stderr message or a delivery
23053 failure message to the sender, depending on the <option>-oe</option> setting. Rejection of
23054 an oversized message is logged in both the main and the reject logs. See also
23055 the generic transport option <option>message_size_limit</option>, which limits the size of
23056 message that an individual transport can process.
23057 </para>
23058 <para>
23059 <indexterm role="option">
23060 <primary>move_frozen_messages</primary>
23061 </indexterm>
23062 </para>
23063 <informaltable frame="all">
23064 <tgroup cols="4" colsep="0" rowsep="0">
23065 <colspec colwidth="8*" align="left"/>
23066 <colspec colwidth="5*" align="center"/>
23067 <colspec colwidth="5*" align="center"/>
23068 <colspec colwidth="6*" align="right"/>
23069 <tbody>
23070 <row>
23071 <entry><option>move_frozen_messages</option></entry>
23072 <entry>Use: <emphasis>main</emphasis></entry>
23073 <entry>Type: <emphasis>boolean</emphasis></entry>
23074 <entry>Default: <emphasis>false</emphasis></entry>
23075 </row>
23076 </tbody>
23077 </tgroup>
23078 </informaltable>
23079 <para>
23080 <indexterm role="concept">
23081 <primary>frozen messages</primary>
23082 <secondary>moving</secondary>
23083 </indexterm>
23084 This option, which is available only if Exim has been built with the setting
23085 </para>
23086 <literallayout class="monospaced">
23087 SUPPORT_MOVE_FROZEN_MESSAGES=yes
23088 </literallayout>
23089 <para>
23090 in <filename>Local/Makefile</filename>, causes frozen messages and their message logs to be
23091 moved from the <filename>input</filename> and <filename>msglog</filename> directories on the spool to <filename>Finput</filename>
23092 and <filename>Fmsglog</filename>, respectively. There is currently no support in Exim or the
23093 standard utilities for handling such moved messages, and they do not show up in
23094 lists generated by <option>-bp</option> or by the Exim monitor.
23095 </para>
23096 <para>
23097 <indexterm role="option">
23098 <primary>mua_wrapper</primary>
23099 </indexterm>
23100 </para>
23101 <informaltable frame="all">
23102 <tgroup cols="4" colsep="0" rowsep="0">
23103 <colspec colwidth="8*" align="left"/>
23104 <colspec colwidth="5*" align="center"/>
23105 <colspec colwidth="5*" align="center"/>
23106 <colspec colwidth="6*" align="right"/>
23107 <tbody>
23108 <row>
23109 <entry><option>mua_wrapper</option></entry>
23110 <entry>Use: <emphasis>main</emphasis></entry>
23111 <entry>Type: <emphasis>boolean</emphasis></entry>
23112 <entry>Default: <emphasis>false</emphasis></entry>
23113 </row>
23114 </tbody>
23115 </tgroup>
23116 </informaltable>
23117 <para>
23118 Setting this option true causes Exim to run in a very restrictive mode in which
23119 it passes messages synchronously to a smart host. Chapter <xref linkend="CHAPnonqueueing"/>
23120 contains a full description of this facility.
23121 </para>
23122 <para>
23123 <indexterm role="option">
23124 <primary>mysql_servers</primary>
23125 </indexterm>
23126 </para>
23127 <informaltable frame="all">
23128 <tgroup cols="4" colsep="0" rowsep="0">
23129 <colspec colwidth="8*" align="left"/>
23130 <colspec colwidth="5*" align="center"/>
23131 <colspec colwidth="5*" align="center"/>
23132 <colspec colwidth="6*" align="right"/>
23133 <tbody>
23134 <row>
23135 <entry><option>mysql_servers</option></entry>
23136 <entry>Use: <emphasis>main</emphasis></entry>
23137 <entry>Type: <emphasis>string list</emphasis></entry>
23138 <entry>Default: <emphasis>unset</emphasis></entry>
23139 </row>
23140 </tbody>
23141 </tgroup>
23142 </informaltable>
23143 <para>
23144 <indexterm role="concept">
23145 <primary>MySQL</primary>
23146 <secondary>server list</secondary>
23147 </indexterm>
23148 This option provides a list of MySQL servers and associated connection data, to
23149 be used in conjunction with <command>mysql</command> lookups (see section <xref linkend="SECTsql"/>). The
23150 option is available only if Exim has been built with MySQL support.
23151 </para>
23152 <para>
23153 <indexterm role="option">
23154 <primary>never_users</primary>
23155 </indexterm>
23156 </para>
23157 <informaltable frame="all">
23158 <tgroup cols="4" colsep="0" rowsep="0">
23159 <colspec colwidth="8*" align="left"/>
23160 <colspec colwidth="5*" align="center"/>
23161 <colspec colwidth="5*" align="center"/>
23162 <colspec colwidth="6*" align="right"/>
23163 <tbody>
23164 <row>
23165 <entry><option>never_users</option></entry>
23166 <entry>Use: <emphasis>main</emphasis></entry>
23167 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
23168 <entry>Default: <emphasis>unset</emphasis></entry>
23169 </row>
23170 </tbody>
23171 </tgroup>
23172 </informaltable>
23173 <para>
23174 This option is expanded just once, at the start of Exim&#x2019;s processing. Local
23175 message deliveries are normally run in processes that are setuid to the
23176 recipient, and remote deliveries are normally run under Exim&#x2019;s own uid and gid.
23177 It is usually desirable to prevent any deliveries from running as root, as a
23178 safety precaution.
23179 </para>
23180 <para>
23181 When Exim is built, an option called FIXED_NEVER_USERS can be set to a
23182 list of users that must not be used for local deliveries. This list is fixed in
23183 the binary and cannot be overridden by the configuration file. By default, it
23184 contains just the single user name <quote>root</quote>. The <option>never_users</option> runtime option
23185 can be used to add more users to the fixed list.
23186 </para>
23187 <para>
23188 If a message is to be delivered as one of the users on the fixed list or the
23189 <option>never_users</option> list, an error occurs, and delivery is deferred. A common
23190 example is
23191 </para>
23192 <literallayout class="monospaced">
23193 never_users = root:daemon:bin
23194 </literallayout>
23195 <para>
23196 Including root is redundant if it is also on the fixed list, but it does no
23197 harm. This option overrides the <option>pipe_as_creator</option> option of the <command>pipe</command>
23198 transport driver.
23199 </para>
23200 <para>
23201 <indexterm role="option">
23202 <primary>oracle_servers</primary>
23203 </indexterm>
23204 </para>
23205 <informaltable frame="all">
23206 <tgroup cols="4" colsep="0" rowsep="0">
23207 <colspec colwidth="8*" align="left"/>
23208 <colspec colwidth="5*" align="center"/>
23209 <colspec colwidth="5*" align="center"/>
23210 <colspec colwidth="6*" align="right"/>
23211 <tbody>
23212 <row>
23213 <entry><option>oracle_servers</option></entry>
23214 <entry>Use: <emphasis>main</emphasis></entry>
23215 <entry>Type: <emphasis>string list</emphasis></entry>
23216 <entry>Default: <emphasis>unset</emphasis></entry>
23217 </row>
23218 </tbody>
23219 </tgroup>
23220 </informaltable>
23221 <para>
23222 <indexterm role="concept">
23223 <primary>Oracle</primary>
23224 <secondary>server list</secondary>
23225 </indexterm>
23226 This option provides a list of Oracle servers and associated connection data,
23227 to be used in conjunction with <command>oracle</command> lookups (see section <xref linkend="SECTsql"/>).
23228 The option is available only if Exim has been built with Oracle support.
23229 </para>
23230 <para>
23231 <indexterm role="option">
23232 <primary>percent_hack_domains</primary>
23233 </indexterm>
23234 </para>
23235 <informaltable frame="all">
23236 <tgroup cols="4" colsep="0" rowsep="0">
23237 <colspec colwidth="8*" align="left"/>
23238 <colspec colwidth="5*" align="center"/>
23239 <colspec colwidth="5*" align="center"/>
23240 <colspec colwidth="6*" align="right"/>
23241 <tbody>
23242 <row>
23243 <entry><option>percent_hack_domains</option></entry>
23244 <entry>Use: <emphasis>main</emphasis></entry>
23245 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
23246 <entry>Default: <emphasis>unset</emphasis></entry>
23247 </row>
23248 </tbody>
23249 </tgroup>
23250 </informaltable>
23251 <para>
23252 <indexterm role="concept">
23253 <primary><quote>percent hack</quote></primary>
23254 </indexterm>
23255 <indexterm role="concept">
23256 <primary>source routing</primary>
23257 <secondary>in email address</secondary>
23258 </indexterm>
23259 <indexterm role="concept">
23260 <primary>address</primary>
23261 <secondary>source-routed</secondary>
23262 </indexterm>
23263 The <quote>percent hack</quote> is the convention whereby a local part containing a
23264 percent sign is re-interpreted as a new email address, with the percent
23265 replaced by @. This is sometimes called <quote>source routing</quote>, though that term is
23266 also applied to RFC 2822 addresses that begin with an @ character. If this
23267 option is set, Exim implements the percent facility for those domains listed,
23268 but no others. This happens before an incoming SMTP address is tested against
23269 an ACL.
23270 </para>
23271 <para>
23272 <emphasis role="bold">Warning</emphasis>: The <quote>percent hack</quote> has often been abused by people who are
23273 trying to get round relaying restrictions. For this reason, it is best avoided
23274 if at all possible. Unfortunately, a number of less security-conscious MTAs
23275 implement it unconditionally. If you are running Exim on a gateway host, and
23276 routing mail through to internal MTAs without processing the local parts, it is
23277 a good idea to reject recipient addresses with percent characters in their
23278 local parts. Exim&#x2019;s default configuration does this.
23279 </para>
23280 <para>
23281 <indexterm role="option">
23282 <primary>perl_at_start</primary>
23283 </indexterm>
23284 </para>
23285 <informaltable frame="all">
23286 <tgroup cols="4" colsep="0" rowsep="0">
23287 <colspec colwidth="8*" align="left"/>
23288 <colspec colwidth="5*" align="center"/>
23289 <colspec colwidth="5*" align="center"/>
23290 <colspec colwidth="6*" align="right"/>
23291 <tbody>
23292 <row>
23293 <entry><option>perl_at_start</option></entry>
23294 <entry>Use: <emphasis>main</emphasis></entry>
23295 <entry>Type: <emphasis>boolean</emphasis></entry>
23296 <entry>Default: <emphasis>false</emphasis></entry>
23297 </row>
23298 </tbody>
23299 </tgroup>
23300 </informaltable>
23301 <para>
23302 This option is available only when Exim is built with an embedded Perl
23303 interpreter. See chapter <xref linkend="CHAPperl"/> for details of its use.
23304 </para>
23305 <para>
23306 <indexterm role="option">
23307 <primary>perl_startup</primary>
23308 </indexterm>
23309 </para>
23310 <informaltable frame="all">
23311 <tgroup cols="4" colsep="0" rowsep="0">
23312 <colspec colwidth="8*" align="left"/>
23313 <colspec colwidth="5*" align="center"/>
23314 <colspec colwidth="5*" align="center"/>
23315 <colspec colwidth="6*" align="right"/>
23316 <tbody>
23317 <row>
23318 <entry><option>perl_startup</option></entry>
23319 <entry>Use: <emphasis>main</emphasis></entry>
23320 <entry>Type: <emphasis>string</emphasis></entry>
23321 <entry>Default: <emphasis>unset</emphasis></entry>
23322 </row>
23323 </tbody>
23324 </tgroup>
23325 </informaltable>
23326 <para>
23327 This option is available only when Exim is built with an embedded Perl
23328 interpreter. See chapter <xref linkend="CHAPperl"/> for details of its use.
23329 </para>
23330 <para>
23331 <indexterm role="option">
23332 <primary>pgsql_servers</primary>
23333 </indexterm>
23334 </para>
23335 <informaltable frame="all">
23336 <tgroup cols="4" colsep="0" rowsep="0">
23337 <colspec colwidth="8*" align="left"/>
23338 <colspec colwidth="5*" align="center"/>
23339 <colspec colwidth="5*" align="center"/>
23340 <colspec colwidth="6*" align="right"/>
23341 <tbody>
23342 <row>
23343 <entry><option>pgsql_servers</option></entry>
23344 <entry>Use: <emphasis>main</emphasis></entry>
23345 <entry>Type: <emphasis>string list</emphasis></entry>
23346 <entry>Default: <emphasis>unset</emphasis></entry>
23347 </row>
23348 </tbody>
23349 </tgroup>
23350 </informaltable>
23351 <para>
23352 <indexterm role="concept">
23353 <primary>PostgreSQL lookup type</primary>
23354 <secondary>server list</secondary>
23355 </indexterm>
23356 This option provides a list of PostgreSQL servers and associated connection
23357 data, to be used in conjunction with <command>pgsql</command> lookups (see section
23358 <xref linkend="SECTsql"/>). The option is available only if Exim has been built with
23359 PostgreSQL support.
23360 </para>
23361 <para>
23362 <indexterm role="option">
23363 <primary>pid_file_path</primary>
23364 </indexterm>
23365 </para>
23366 <informaltable frame="all">
23367 <tgroup cols="4" colsep="0" rowsep="0">
23368 <colspec colwidth="8*" align="left"/>
23369 <colspec colwidth="5*" align="center"/>
23370 <colspec colwidth="5*" align="center"/>
23371 <colspec colwidth="6*" align="right"/>
23372 <tbody>
23373 <row>
23374 <entry><option>pid_file_path</option></entry>
23375 <entry>Use: <emphasis>main</emphasis></entry>
23376 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23377 <entry>Default: <emphasis>set at compile time</emphasis></entry>
23378 </row>
23379 </tbody>
23380 </tgroup>
23381 </informaltable>
23382 <para>
23383 <indexterm role="concept">
23384 <primary>daemon</primary>
23385 <secondary>pid file path</secondary>
23386 </indexterm>
23387 <indexterm role="concept">
23388 <primary>pid file</primary>
23389 <secondary>path for</secondary>
23390 </indexterm>
23391 This option sets the name of the file to which the Exim daemon writes its
23392 process id. The string is expanded, so it can contain, for example, references
23393 to the host name:
23394 </para>
23395 <literallayout class="monospaced">
23396 pid_file_path = /var/log/$primary_hostname/exim.pid
23397 </literallayout>
23398 <para>
23399 If no path is set, the pid is written to the file <filename>exim-daemon.pid</filename> in Exim&#x2019;s
23400 spool directory.
23401 The value set by the option can be overridden by the <option>-oP</option> command line
23402 option. A pid file is not written if a <quote>non-standard</quote> daemon is run by means
23403 of the <option>-oX</option> option, unless a path is explicitly supplied by <option>-oP</option>.
23404 </para>
23405 <para>
23406 <indexterm role="option">
23407 <primary>pipelining_advertise_hosts</primary>
23408 </indexterm>
23409 </para>
23410 <informaltable frame="all">
23411 <tgroup cols="4" colsep="0" rowsep="0">
23412 <colspec colwidth="8*" align="left"/>
23413 <colspec colwidth="5*" align="center"/>
23414 <colspec colwidth="5*" align="center"/>
23415 <colspec colwidth="6*" align="right"/>
23416 <tbody>
23417 <row>
23418 <entry><option>pipelining_advertise_hosts</option></entry>
23419 <entry>Use: <emphasis>main</emphasis></entry>
23420 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
23421 <entry>Default: <emphasis>*</emphasis></entry>
23422 </row>
23423 </tbody>
23424 </tgroup>
23425 </informaltable>
23426 <para>
23427 <indexterm role="concept">
23428 <primary>PIPELINING advertising</primary>
23429 <secondary>suppressing</secondary>
23430 </indexterm>
23431 This option can be used to suppress the advertisement of the SMTP
23432 PIPELINING extension to specific hosts. When PIPELINING is not
23433 advertised and <option>smtp_enforce_sync</option> is true, an Exim server enforces strict
23434 synchronization for each SMTP command and response.
23435 When PIPELINING is advertised, Exim assumes that clients will use it; <quote>out
23436 of order</quote> commands that are <quote>expected</quote> do not count as protocol errors (see
23437 <option>smtp_max_synprot_errors</option>).
23438 </para>
23439 <para>
23440 <indexterm role="option">
23441 <primary>preserve_message_logs</primary>
23442 </indexterm>
23443 </para>
23444 <informaltable frame="all">
23445 <tgroup cols="4" colsep="0" rowsep="0">
23446 <colspec colwidth="8*" align="left"/>
23447 <colspec colwidth="5*" align="center"/>
23448 <colspec colwidth="5*" align="center"/>
23449 <colspec colwidth="6*" align="right"/>
23450 <tbody>
23451 <row>
23452 <entry><option>preserve_message_logs</option></entry>
23453 <entry>Use: <emphasis>main</emphasis></entry>
23454 <entry>Type: <emphasis>boolean</emphasis></entry>
23455 <entry>Default: <emphasis>false</emphasis></entry>
23456 </row>
23457 </tbody>
23458 </tgroup>
23459 </informaltable>
23460 <para>
23461 <indexterm role="concept">
23462 <primary>message logs</primary>
23463 <secondary>preserving</secondary>
23464 </indexterm>
23465 If this option is set, message log files are not deleted when messages are
23466 completed. Instead, they are moved to a sub-directory of the spool directory
23467 called <filename>msglog.OLD</filename>, where they remain available for statistical or debugging
23468 purposes. This is a dangerous option to set on systems with any appreciable
23469 volume of mail. Use with care!
23470 </para>
23471 <para>
23472 <indexterm role="option">
23473 <primary>primary_hostname</primary>
23474 </indexterm>
23475 </para>
23476 <informaltable frame="all">
23477 <tgroup cols="4" colsep="0" rowsep="0">
23478 <colspec colwidth="8*" align="left"/>
23479 <colspec colwidth="5*" align="center"/>
23480 <colspec colwidth="5*" align="center"/>
23481 <colspec colwidth="6*" align="right"/>
23482 <tbody>
23483 <row>
23484 <entry><option>primary_hostname</option></entry>
23485 <entry>Use: <emphasis>main</emphasis></entry>
23486 <entry>Type: <emphasis>string</emphasis></entry>
23487 <entry>Default: <emphasis>see below</emphasis></entry>
23488 </row>
23489 </tbody>
23490 </tgroup>
23491 </informaltable>
23492 <para>
23493 <indexterm role="concept">
23494 <primary>name</primary>
23495 <secondary>of local host</secondary>
23496 </indexterm>
23497 <indexterm role="concept">
23498 <primary>host</primary>
23499 <secondary>name of local</secondary>
23500 </indexterm>
23501 <indexterm role="concept">
23502 <primary>local host</primary>
23503 <secondary>name of</secondary>
23504 </indexterm>
23505 <indexterm role="concept">
23506 <primary><varname>$primary_hostname</varname></primary>
23507 </indexterm>
23508 This specifies the name of the current host. It is used in the default EHLO or
23509 HELO command for outgoing SMTP messages (changeable via the <option>helo_data</option>
23510 option in the <command>smtp</command> transport), and as the default for <option>qualify_domain</option>.
23511 The value is also used by default in some SMTP response messages from an Exim
23512 server. This can be changed dynamically by setting <option>smtp_active_hostname</option>.
23513 </para>
23514 <para>
23515 If <option>primary_hostname</option> is not set, Exim calls <function>uname()</function> to find the host
23516 name. If this fails, Exim panics and dies. If the name returned by <function>uname()</function>
23517 contains only one component, Exim passes it to <function>gethostbyname()</function> (or
23518 <function>getipnodebyname()</function> when available) in order to obtain the fully qualified
23519 version. The variable <varname>$primary_hostname</varname> contains the host name, whether set
23520 explicitly by this option, or defaulted.
23521 </para>
23522 <para>
23523 <indexterm role="option">
23524 <primary>print_topbitchars</primary>
23525 </indexterm>
23526 </para>
23527 <informaltable frame="all">
23528 <tgroup cols="4" colsep="0" rowsep="0">
23529 <colspec colwidth="8*" align="left"/>
23530 <colspec colwidth="5*" align="center"/>
23531 <colspec colwidth="5*" align="center"/>
23532 <colspec colwidth="6*" align="right"/>
23533 <tbody>
23534 <row>
23535 <entry><option>print_topbitchars</option></entry>
23536 <entry>Use: <emphasis>main</emphasis></entry>
23537 <entry>Type: <emphasis>boolean</emphasis></entry>
23538 <entry>Default: <emphasis>false</emphasis></entry>
23539 </row>
23540 </tbody>
23541 </tgroup>
23542 </informaltable>
23543 <para>
23544 <indexterm role="concept">
23545 <primary>printing characters</primary>
23546 </indexterm>
23547 <indexterm role="concept">
23548 <primary>8-bit characters</primary>
23549 </indexterm>
23550 By default, Exim considers only those characters whose codes lie in the range
23551 32&ndash;126 to be printing characters. In a number of circumstances (for example,
23552 when writing log entries) non-printing characters are converted into escape
23553 sequences, primarily to avoid messing up the layout. If <option>print_topbitchars</option>
23554 is set, code values of 128 and above are also considered to be printing
23555 characters.
23556 </para>
23557 <para>
23558 <indexterm role="option">
23559 <primary>process_log_path</primary>
23560 </indexterm>
23561 </para>
23562 <informaltable frame="all">
23563 <tgroup cols="4" colsep="0" rowsep="0">
23564 <colspec colwidth="8*" align="left"/>
23565 <colspec colwidth="5*" align="center"/>
23566 <colspec colwidth="5*" align="center"/>
23567 <colspec colwidth="6*" align="right"/>
23568 <tbody>
23569 <row>
23570 <entry><option>process_log_path</option></entry>
23571 <entry>Use: <emphasis>main</emphasis></entry>
23572 <entry>Type: <emphasis>string</emphasis></entry>
23573 <entry>Default: <emphasis>unset</emphasis></entry>
23574 </row>
23575 </tbody>
23576 </tgroup>
23577 </informaltable>
23578 <para>
23579 <indexterm role="concept">
23580 <primary>process log path</primary>
23581 </indexterm>
23582 <indexterm role="concept">
23583 <primary>log</primary>
23584 <secondary>process log</secondary>
23585 </indexterm>
23586 <indexterm role="concept">
23587 <primary><emphasis>exiwhat</emphasis></primary>
23588 </indexterm>
23589 This option sets the name of the file to which an Exim process writes its
23590 <quote>process log</quote> when sent a USR1 signal. This is used by the <emphasis>exiwhat</emphasis>
23591 utility script. If this option is unset, the file called <filename>exim-process.info</filename>
23592 in Exim&#x2019;s spool directory is used. The ability to specify the name explicitly
23593 can be useful in environments where two different Exims are running, using
23594 different spool directories.
23595 </para>
23596 <para>
23597 <indexterm role="option">
23598 <primary>prod_requires_admin</primary>
23599 </indexterm>
23600 </para>
23601 <informaltable frame="all">
23602 <tgroup cols="4" colsep="0" rowsep="0">
23603 <colspec colwidth="8*" align="left"/>
23604 <colspec colwidth="5*" align="center"/>
23605 <colspec colwidth="5*" align="center"/>
23606 <colspec colwidth="6*" align="right"/>
23607 <tbody>
23608 <row>
23609 <entry><option>prod_requires_admin</option></entry>
23610 <entry>Use: <emphasis>main</emphasis></entry>
23611 <entry>Type: <emphasis>boolean</emphasis></entry>
23612 <entry>Default: <emphasis>true</emphasis></entry>
23613 </row>
23614 </tbody>
23615 </tgroup>
23616 </informaltable>
23617 <para>
23618 <indexterm role="concept">
23619 <primary><option>-M</option> option</primary>
23620 </indexterm>
23621 <indexterm role="concept">
23622 <primary><option>-R</option> option</primary>
23623 </indexterm>
23624 <indexterm role="concept">
23625 <primary><option>-q</option> option</primary>
23626 </indexterm>
23627 The <option>-M</option>, <option>-R</option>, and <option>-q</option> command-line options require the caller to be an
23628 admin user unless <option>prod_requires_admin</option> is set false. See also
23629 <option>queue_list_requires_admin</option>.
23630 </para>
23631 <para>
23632 <indexterm role="option">
23633 <primary>qualify_domain</primary>
23634 </indexterm>
23635 </para>
23636 <informaltable frame="all">
23637 <tgroup cols="4" colsep="0" rowsep="0">
23638 <colspec colwidth="8*" align="left"/>
23639 <colspec colwidth="5*" align="center"/>
23640 <colspec colwidth="5*" align="center"/>
23641 <colspec colwidth="6*" align="right"/>
23642 <tbody>
23643 <row>
23644 <entry><option>qualify_domain</option></entry>
23645 <entry>Use: <emphasis>main</emphasis></entry>
23646 <entry>Type: <emphasis>string</emphasis></entry>
23647 <entry>Default: <emphasis>see below</emphasis></entry>
23648 </row>
23649 </tbody>
23650 </tgroup>
23651 </informaltable>
23652 <para>
23653 <indexterm role="concept">
23654 <primary>domain</primary>
23655 <secondary>for qualifying addresses</secondary>
23656 </indexterm>
23657 <indexterm role="concept">
23658 <primary>address</primary>
23659 <secondary>qualification</secondary>
23660 </indexterm>
23661 This option specifies the domain name that is added to any envelope sender
23662 addresses that do not have a domain qualification. It also applies to
23663 recipient addresses if <option>qualify_recipient</option> is not set. Unqualified addresses
23664 are accepted by default only for locally-generated messages. Qualification is
23665 also applied to addresses in header lines such as <emphasis>From:</emphasis> and <emphasis>To:</emphasis> for
23666 locally-generated messages, unless the <option>-bnq</option> command line option is used.
23667 </para>
23668 <para>
23669 Messages from external sources must always contain fully qualified addresses,
23670 unless the sending host matches <option>sender_unqualified_hosts</option> or
23671 <option>recipient_unqualified_hosts</option> (as appropriate), in which case incoming
23672 addresses are qualified with <option>qualify_domain</option> or <option>qualify_recipient</option> as
23673 necessary. Internally, Exim always works with fully qualified envelope
23674 addresses. If <option>qualify_domain</option> is not set, it defaults to the
23675 <option>primary_hostname</option> value.
23676 </para>
23677 <para>
23678 <indexterm role="option">
23679 <primary>qualify_recipient</primary>
23680 </indexterm>
23681 </para>
23682 <informaltable frame="all">
23683 <tgroup cols="4" colsep="0" rowsep="0">
23684 <colspec colwidth="8*" align="left"/>
23685 <colspec colwidth="5*" align="center"/>
23686 <colspec colwidth="5*" align="center"/>
23687 <colspec colwidth="6*" align="right"/>
23688 <tbody>
23689 <row>
23690 <entry><option>qualify_recipient</option></entry>
23691 <entry>Use: <emphasis>main</emphasis></entry>
23692 <entry>Type: <emphasis>string</emphasis></entry>
23693 <entry>Default: <emphasis>see below</emphasis></entry>
23694 </row>
23695 </tbody>
23696 </tgroup>
23697 </informaltable>
23698 <para>
23699 This option allows you to specify a different domain for qualifying recipient
23700 addresses to the one that is used for senders. See <option>qualify_domain</option> above.
23701 </para>
23702 <para>
23703 <indexterm role="option">
23704 <primary>queue_domains</primary>
23705 </indexterm>
23706 </para>
23707 <informaltable frame="all">
23708 <tgroup cols="4" colsep="0" rowsep="0">
23709 <colspec colwidth="8*" align="left"/>
23710 <colspec colwidth="5*" align="center"/>
23711 <colspec colwidth="5*" align="center"/>
23712 <colspec colwidth="6*" align="right"/>
23713 <tbody>
23714 <row>
23715 <entry><option>queue_domains</option></entry>
23716 <entry>Use: <emphasis>main</emphasis></entry>
23717 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
23718 <entry>Default: <emphasis>unset</emphasis></entry>
23719 </row>
23720 </tbody>
23721 </tgroup>
23722 </informaltable>
23723 <para>
23724 <indexterm role="concept">
23725 <primary>domain</primary>
23726 <secondary>specifying non-immediate delivery</secondary>
23727 </indexterm>
23728 <indexterm role="concept">
23729 <primary>queueing incoming messages</primary>
23730 </indexterm>
23731 <indexterm role="concept">
23732 <primary>message</primary>
23733 <secondary>queueing certain domains</secondary>
23734 </indexterm>
23735 This option lists domains for which immediate delivery is not required.
23736 A delivery process is started whenever a message is received, but only those
23737 domains that do not match are processed. All other deliveries wait until the
23738 next queue run. See also <option>hold_domains</option> and <option>queue_smtp_domains</option>.
23739 </para>
23740 <para>
23741 <indexterm role="option">
23742 <primary>queue_list_requires_admin</primary>
23743 </indexterm>
23744 </para>
23745 <informaltable frame="all">
23746 <tgroup cols="4" colsep="0" rowsep="0">
23747 <colspec colwidth="8*" align="left"/>
23748 <colspec colwidth="5*" align="center"/>
23749 <colspec colwidth="5*" align="center"/>
23750 <colspec colwidth="6*" align="right"/>
23751 <tbody>
23752 <row>
23753 <entry><option>queue_list_requires_admin</option></entry>
23754 <entry>Use: <emphasis>main</emphasis></entry>
23755 <entry>Type: <emphasis>boolean</emphasis></entry>
23756 <entry>Default: <emphasis>true</emphasis></entry>
23757 </row>
23758 </tbody>
23759 </tgroup>
23760 </informaltable>
23761 <para>
23762 <indexterm role="concept">
23763 <primary><option>-bp</option> option</primary>
23764 </indexterm>
23765 The <option>-bp</option> command-line option, which lists the messages that are on the
23766 queue, requires the caller to be an admin user unless
23767 <option>queue_list_requires_admin</option> is set false. See also <option>prod_requires_admin</option>.
23768 </para>
23769 <para>
23770 <indexterm role="option">
23771 <primary>queue_only</primary>
23772 </indexterm>
23773 </para>
23774 <informaltable frame="all">
23775 <tgroup cols="4" colsep="0" rowsep="0">
23776 <colspec colwidth="8*" align="left"/>
23777 <colspec colwidth="5*" align="center"/>
23778 <colspec colwidth="5*" align="center"/>
23779 <colspec colwidth="6*" align="right"/>
23780 <tbody>
23781 <row>
23782 <entry><option>queue_only</option></entry>
23783 <entry>Use: <emphasis>main</emphasis></entry>
23784 <entry>Type: <emphasis>boolean</emphasis></entry>
23785 <entry>Default: <emphasis>false</emphasis></entry>
23786 </row>
23787 </tbody>
23788 </tgroup>
23789 </informaltable>
23790 <para>
23791 <indexterm role="concept">
23792 <primary>queueing incoming messages</primary>
23793 </indexterm>
23794 <indexterm role="concept">
23795 <primary>message</primary>
23796 <secondary>queueing unconditionally</secondary>
23797 </indexterm>
23798 If <option>queue_only</option> is set, a delivery process is not automatically started
23799 whenever a message is received. Instead, the message waits on the queue for the
23800 next queue run. Even if <option>queue_only</option> is false, incoming messages may not get
23801 delivered immediately when certain conditions (such as heavy load) occur.
23802 </para>
23803 <para>
23804 The <option>-odq</option> command line has the same effect as <option>queue_only</option>. The <option>-odb</option>
23805 and <option>-odi</option> command line options override <option>queue_only</option> unless
23806 <option>queue_only_override</option> is set false. See also <option>queue_only_file</option>,
23807 <option>queue_only_load</option>, and <option>smtp_accept_queue</option>.
23808 </para>
23809 <para>
23810 <indexterm role="option">
23811 <primary>queue_only_file</primary>
23812 </indexterm>
23813 </para>
23814 <informaltable frame="all">
23815 <tgroup cols="4" colsep="0" rowsep="0">
23816 <colspec colwidth="8*" align="left"/>
23817 <colspec colwidth="5*" align="center"/>
23818 <colspec colwidth="5*" align="center"/>
23819 <colspec colwidth="6*" align="right"/>
23820 <tbody>
23821 <row>
23822 <entry><option>queue_only_file</option></entry>
23823 <entry>Use: <emphasis>main</emphasis></entry>
23824 <entry>Type: <emphasis>string</emphasis></entry>
23825 <entry>Default: <emphasis>unset</emphasis></entry>
23826 </row>
23827 </tbody>
23828 </tgroup>
23829 </informaltable>
23830 <para>
23831 <indexterm role="concept">
23832 <primary>queueing incoming messages</primary>
23833 </indexterm>
23834 <indexterm role="concept">
23835 <primary>message</primary>
23836 <secondary>queueing by file existence</secondary>
23837 </indexterm>
23838 This option can be set to a colon-separated list of absolute path names, each
23839 one optionally preceded by <quote>smtp</quote>. When Exim is receiving a message,
23840 it tests for the existence of each listed path using a call to <function>stat()</function>. For
23841 each path that exists, the corresponding queuing option is set.
23842 For paths with no prefix, <option>queue_only</option> is set; for paths prefixed by
23843 <quote>smtp</quote>, <option>queue_smtp_domains</option> is set to match all domains. So, for example,
23844 </para>
23845 <literallayout class="monospaced">
23846 queue_only_file = smtp/some/file
23847 </literallayout>
23848 <para>
23849 causes Exim to behave as if <option>queue_smtp_domains</option> were set to <quote>*</quote> whenever
23850 <filename>/some/file</filename> exists.
23851 </para>
23852 <para>
23853 <indexterm role="option">
23854 <primary>queue_only_load</primary>
23855 </indexterm>
23856 </para>
23857 <informaltable frame="all">
23858 <tgroup cols="4" colsep="0" rowsep="0">
23859 <colspec colwidth="8*" align="left"/>
23860 <colspec colwidth="5*" align="center"/>
23861 <colspec colwidth="5*" align="center"/>
23862 <colspec colwidth="6*" align="right"/>
23863 <tbody>
23864 <row>
23865 <entry><option>queue_only_load</option></entry>
23866 <entry>Use: <emphasis>main</emphasis></entry>
23867 <entry>Type: <emphasis>fixed-point</emphasis></entry>
23868 <entry>Default: <emphasis>unset</emphasis></entry>
23869 </row>
23870 </tbody>
23871 </tgroup>
23872 </informaltable>
23873 <para>
23874 <indexterm role="concept">
23875 <primary>load average</primary>
23876 </indexterm>
23877 <indexterm role="concept">
23878 <primary>queueing incoming messages</primary>
23879 </indexterm>
23880 <indexterm role="concept">
23881 <primary>message</primary>
23882 <secondary>queueing by load</secondary>
23883 </indexterm>
23884 If the system load average is higher than this value, incoming messages from
23885 all sources are queued, and no automatic deliveries are started. If this
23886 happens during local or remote SMTP input, all subsequent messages on the same
23887 connection are queued. Deliveries will subsequently be performed by queue
23888 runner processes. This option has no effect on ancient operating systems on
23889 which Exim cannot determine the load average. See also
23890 <option>deliver_queue_load_max</option> and <option>smtp_load_reserve</option>.
23891 </para>
23892 <para>
23893 <indexterm role="option">
23894 <primary>queue_only_override</primary>
23895 </indexterm>
23896 </para>
23897 <informaltable frame="all">
23898 <tgroup cols="4" colsep="0" rowsep="0">
23899 <colspec colwidth="8*" align="left"/>
23900 <colspec colwidth="5*" align="center"/>
23901 <colspec colwidth="5*" align="center"/>
23902 <colspec colwidth="6*" align="right"/>
23903 <tbody>
23904 <row>
23905 <entry><option>queue_only_override</option></entry>
23906 <entry>Use: <emphasis>main</emphasis></entry>
23907 <entry>Type: <emphasis>boolean</emphasis></entry>
23908 <entry>Default: <emphasis>true</emphasis></entry>
23909 </row>
23910 </tbody>
23911 </tgroup>
23912 </informaltable>
23913 <para>
23914 <indexterm role="concept">
23915 <primary>queueing incoming messages</primary>
23916 </indexterm>
23917 When this option is true, the <option>-od</option><emphasis>x</emphasis> command line options override the
23918 setting of <option>queue_only</option> or <option>queue_only_file</option> in the configuration file. If
23919 <option>queue_only_override</option> is set false, the <option>-od</option><emphasis>x</emphasis> options cannot be used
23920 to override; they are accepted, but ignored.
23921 </para>
23922 <para>
23923 <indexterm role="option">
23924 <primary>queue_run_in_order</primary>
23925 </indexterm>
23926 </para>
23927 <informaltable frame="all">
23928 <tgroup cols="4" colsep="0" rowsep="0">
23929 <colspec colwidth="8*" align="left"/>
23930 <colspec colwidth="5*" align="center"/>
23931 <colspec colwidth="5*" align="center"/>
23932 <colspec colwidth="6*" align="right"/>
23933 <tbody>
23934 <row>
23935 <entry><option>queue_run_in_order</option></entry>
23936 <entry>Use: <emphasis>main</emphasis></entry>
23937 <entry>Type: <emphasis>boolean</emphasis></entry>
23938 <entry>Default: <emphasis>false</emphasis></entry>
23939 </row>
23940 </tbody>
23941 </tgroup>
23942 </informaltable>
23943 <para>
23944 <indexterm role="concept">
23945 <primary>queue runner</primary>
23946 <secondary>processing messages in order</secondary>
23947 </indexterm>
23948 If this option is set, queue runs happen in order of message arrival instead of
23949 in an arbitrary order. For this to happen, a complete list of the entire queue
23950 must be set up before the deliveries start. When the queue is all held in a
23951 single directory (the default),
23952 </para>
23953 <para>
23954 a single list is created for both the ordered and the non-ordered cases.
23955 However, if <option>split_spool_directory</option> is set, a single list is not created when
23956 <option>queue_run_in_order</option> is false. In this case, the sub-directories are
23957 processed one at a time (in a random order), and this avoids setting up one
23958 huge list for the whole queue. Thus, setting <option>queue_run_in_order</option> with
23959 <option>split_spool_directory</option> may degrade performance when the queue is large,
23960 because of the extra work in setting up the single, large list. In most
23961 situations, <option>queue_run_in_order</option> should not be set.
23962 </para>
23963 <para>
23964 <indexterm role="option">
23965 <primary>queue_run_max</primary>
23966 </indexterm>
23967 </para>
23968 <informaltable frame="all">
23969 <tgroup cols="4" colsep="0" rowsep="0">
23970 <colspec colwidth="8*" align="left"/>
23971 <colspec colwidth="5*" align="center"/>
23972 <colspec colwidth="5*" align="center"/>
23973 <colspec colwidth="6*" align="right"/>
23974 <tbody>
23975 <row>
23976 <entry><option>queue_run_max</option></entry>
23977 <entry>Use: <emphasis>main</emphasis></entry>
23978 <entry>Type: <emphasis>integer</emphasis></entry>
23979 <entry>Default: <emphasis>5</emphasis></entry>
23980 </row>
23981 </tbody>
23982 </tgroup>
23983 </informaltable>
23984 <para>
23985 <indexterm role="concept">
23986 <primary>queue runner</primary>
23987 <secondary>maximum number of</secondary>
23988 </indexterm>
23989 This controls the maximum number of queue runner processes that an Exim daemon
23990 can run simultaneously. This does not mean that it starts them all at once,
23991 but rather that if the maximum number are still running when the time comes to
23992 start another one, it refrains from starting another one. This can happen with
23993 very large queues and/or very sluggish deliveries. This option does not,
23994 however, interlock with other processes, so additional queue runners can be
23995 started by other means, or by killing and restarting the daemon.
23996 </para>
23997 <para>
23998 Setting this option to zero does not suppress queue runs; rather, it disables
23999 the limit, allowing any number of simultaneous queue runner processes to be
24000 run. If you do not want queue runs to occur, omit the <option>-q</option><emphasis>xx</emphasis> setting on
24001 the daemon&#x2019;s command line.
24002 </para>
24003 <para>
24004 <indexterm role="option">
24005 <primary>queue_smtp_domains</primary>
24006 </indexterm>
24007 </para>
24008 <informaltable frame="all">
24009 <tgroup cols="4" colsep="0" rowsep="0">
24010 <colspec colwidth="8*" align="left"/>
24011 <colspec colwidth="5*" align="center"/>
24012 <colspec colwidth="5*" align="center"/>
24013 <colspec colwidth="6*" align="right"/>
24014 <tbody>
24015 <row>
24016 <entry><option>queue_smtp_domains</option></entry>
24017 <entry>Use: <emphasis>main</emphasis></entry>
24018 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
24019 <entry>Default: <emphasis>unset</emphasis></entry>
24020 </row>
24021 </tbody>
24022 </tgroup>
24023 </informaltable>
24024 <para>
24025 <indexterm role="concept">
24026 <primary>queueing incoming messages</primary>
24027 </indexterm>
24028 <indexterm role="concept">
24029 <primary>message</primary>
24030 <secondary>queueing remote deliveries</secondary>
24031 </indexterm>
24032 When this option is set, a delivery process is started whenever a message is
24033 received, routing is performed, and local deliveries take place.
24034 However, if any SMTP deliveries are required for domains that match
24035 <option>queue_smtp_domains</option>, they are not immediately delivered, but instead the
24036 message waits on the queue for the next queue run. Since routing of the message
24037 has taken place, Exim knows to which remote hosts it must be delivered, and so
24038 when the queue run happens, multiple messages for the same host are delivered
24039 over a single SMTP connection. The <option>-odqs</option> command line option causes all
24040 SMTP deliveries to be queued in this way, and is equivalent to setting
24041 <option>queue_smtp_domains</option> to <quote>*</quote>. See also <option>hold_domains</option> and
24042 <option>queue_domains</option>.
24043 </para>
24044 <para>
24045 <indexterm role="option">
24046 <primary>receive_timeout</primary>
24047 </indexterm>
24048 </para>
24049 <informaltable frame="all">
24050 <tgroup cols="4" colsep="0" rowsep="0">
24051 <colspec colwidth="8*" align="left"/>
24052 <colspec colwidth="5*" align="center"/>
24053 <colspec colwidth="5*" align="center"/>
24054 <colspec colwidth="6*" align="right"/>
24055 <tbody>
24056 <row>
24057 <entry><option>receive_timeout</option></entry>
24058 <entry>Use: <emphasis>main</emphasis></entry>
24059 <entry>Type: <emphasis>time</emphasis></entry>
24060 <entry>Default: <emphasis>0s</emphasis></entry>
24061 </row>
24062 </tbody>
24063 </tgroup>
24064 </informaltable>
24065 <para>
24066 <indexterm role="concept">
24067 <primary>timeout</primary>
24068 <secondary>for non-SMTP input</secondary>
24069 </indexterm>
24070 This option sets the timeout for accepting a non-SMTP message, that is, the
24071 maximum time that Exim waits when reading a message on the standard input. If
24072 the value is zero, it will wait for ever. This setting is overridden by the
24073 <option>-or</option> command line option. The timeout for incoming SMTP messages is
24074 controlled by <option>smtp_receive_timeout</option>.
24075 </para>
24076 <para>
24077 <indexterm role="option">
24078 <primary>received_header_text</primary>
24079 </indexterm>
24080 </para>
24081 <informaltable frame="all">
24082 <tgroup cols="4" colsep="0" rowsep="0">
24083 <colspec colwidth="8*" align="left"/>
24084 <colspec colwidth="5*" align="center"/>
24085 <colspec colwidth="5*" align="center"/>
24086 <colspec colwidth="6*" align="right"/>
24087 <tbody>
24088 <row>
24089 <entry><option>received_header_text</option></entry>
24090 <entry>Use: <emphasis>main</emphasis></entry>
24091 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
24092 <entry>Default: <emphasis>see below</emphasis></entry>
24093 </row>
24094 </tbody>
24095 </tgroup>
24096 </informaltable>
24097 <para>
24098 <indexterm role="concept">
24099 <primary>customizing</primary>
24100 <secondary><emphasis>Received:</emphasis> header</secondary>
24101 </indexterm>
24102 <indexterm role="concept">
24103 <primary><emphasis>Received:</emphasis> header line</primary>
24104 <secondary>customizing</secondary>
24105 </indexterm>
24106 This string defines the contents of the <emphasis>Received:</emphasis> message header that is
24107 added to each message, except for the timestamp, which is automatically added
24108 on at the end (preceded by a semicolon). The string is expanded each time it is
24109 used. If the expansion yields an empty string, no <emphasis>Received:</emphasis> header line is
24110 added to the message. Otherwise, the string should start with the text
24111 <quote>Received:</quote> and conform to the RFC 2822 specification for <emphasis>Received:</emphasis>
24112 header lines. The default setting is:
24113 </para>
24114 <literallayout class="monospaced">
24115 received_header_text = Received: \
24116   ${if def:sender_rcvhost {from $sender_rcvhost\n\t}\
24117   {${if def:sender_ident \
24118   {from ${quote_local_part:$sender_ident} }}\
24119   ${if def:sender_helo_name {(helo=$sender_helo_name)\n\t}}}}\
24120   by $primary_hostname \
24121   ${if def:received_protocol {with $received_protocol}} \
24122   ${if def:tls_cipher {($tls_cipher)\n\t}}\
24123   (Exim $version_number)\n\t\
24124   ${if def:sender_address \
24125   {(envelope-from &lt;$sender_address&gt;)\n\t}}\
24126   id $message_exim_id\
24127   ${if def:received_for {\n\tfor $received_for}}
24128 </literallayout>
24129 <para>
24130 The reference to the TLS cipher is omitted when Exim is built without TLS
24131 support. The use of conditional expansions ensures that this works for both
24132 locally generated messages and messages received from remote hosts, giving
24133 header lines such as the following:
24134 </para>
24135 <literallayout class="monospaced">
24136 Received: from scrooge.carol.example ([192.168.12.25] ident=root)
24137 by marley.carol.example with esmtp (Exim 4.00)
24138 (envelope-from &lt;bob@carol.example&gt;)
24139 id 16IOWa-00019l-00
24140 for chas@dickens.example; Tue, 25 Dec 2001 14:43:44 +0000
24141 Received: by scrooge.carol.example with local (Exim 4.00)
24142 id 16IOWW-000083-00; Tue, 25 Dec 2001 14:43:41 +0000
24143 </literallayout>
24144 <para>
24145 Until the body of the message has been received, the timestamp is the time when
24146 the message started to be received. Once the body has arrived, and all policy
24147 checks have taken place, the timestamp is updated to the time at which the
24148 message was accepted.
24149 </para>
24150 <para>
24151 <indexterm role="option">
24152 <primary>received_headers_max</primary>
24153 </indexterm>
24154 </para>
24155 <informaltable frame="all">
24156 <tgroup cols="4" colsep="0" rowsep="0">
24157 <colspec colwidth="8*" align="left"/>
24158 <colspec colwidth="5*" align="center"/>
24159 <colspec colwidth="5*" align="center"/>
24160 <colspec colwidth="6*" align="right"/>
24161 <tbody>
24162 <row>
24163 <entry><option>received_headers_max</option></entry>
24164 <entry>Use: <emphasis>main</emphasis></entry>
24165 <entry>Type: <emphasis>integer</emphasis></entry>
24166 <entry>Default: <emphasis>30</emphasis></entry>
24167 </row>
24168 </tbody>
24169 </tgroup>
24170 </informaltable>
24171 <para>
24172 <indexterm role="concept">
24173 <primary>loop</primary>
24174 <secondary>prevention</secondary>
24175 </indexterm>
24176 <indexterm role="concept">
24177 <primary>mail loop prevention</primary>
24178 </indexterm>
24179 <indexterm role="concept">
24180 <primary><emphasis>Received:</emphasis> header line</primary>
24181 <secondary>counting</secondary>
24182 </indexterm>
24183 When a message is to be delivered, the number of <emphasis>Received:</emphasis> headers is
24184 counted, and if it is greater than this parameter, a mail loop is assumed to
24185 have occurred, the delivery is abandoned, and an error message is generated.
24186 This applies to both local and remote deliveries.
24187 </para>
24188 <para>
24189 <indexterm role="option">
24190 <primary>recipient_unqualified_hosts</primary>
24191 </indexterm>
24192 </para>
24193 <informaltable frame="all">
24194 <tgroup cols="4" colsep="0" rowsep="0">
24195 <colspec colwidth="8*" align="left"/>
24196 <colspec colwidth="5*" align="center"/>
24197 <colspec colwidth="5*" align="center"/>
24198 <colspec colwidth="6*" align="right"/>
24199 <tbody>
24200 <row>
24201 <entry><option>recipient_unqualified_hosts</option></entry>
24202 <entry>Use: <emphasis>main</emphasis></entry>
24203 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
24204 <entry>Default: <emphasis>unset</emphasis></entry>
24205 </row>
24206 </tbody>
24207 </tgroup>
24208 </informaltable>
24209 <para>
24210 <indexterm role="concept">
24211 <primary>unqualified addresses</primary>
24212 </indexterm>
24213 <indexterm role="concept">
24214 <primary>host</primary>
24215 <secondary>unqualified addresses from</secondary>
24216 </indexterm>
24217 This option lists those hosts from which Exim is prepared to accept unqualified
24218 recipient addresses in message envelopes. The addresses are made fully
24219 qualified by the addition of the <option>qualify_recipient</option> value. This option also
24220 affects message header lines. Exim does not reject unqualified recipient
24221 addresses in headers, but it qualifies them only if the message came from a
24222 host that matches <option>recipient_unqualified_hosts</option>,
24223 or if the message was submitted locally (not using TCP/IP), and the <option>-bnq</option>
24224 option was not set.
24225 </para>
24226 <para>
24227 <indexterm role="option">
24228 <primary>recipients_max</primary>
24229 </indexterm>
24230 </para>
24231 <informaltable frame="all">
24232 <tgroup cols="4" colsep="0" rowsep="0">
24233 <colspec colwidth="8*" align="left"/>
24234 <colspec colwidth="5*" align="center"/>
24235 <colspec colwidth="5*" align="center"/>
24236 <colspec colwidth="6*" align="right"/>
24237 <tbody>
24238 <row>
24239 <entry><option>recipients_max</option></entry>
24240 <entry>Use: <emphasis>main</emphasis></entry>
24241 <entry>Type: <emphasis>integer</emphasis></entry>
24242 <entry>Default: <emphasis>0</emphasis></entry>
24243 </row>
24244 </tbody>
24245 </tgroup>
24246 </informaltable>
24247 <para>
24248 <indexterm role="concept">
24249 <primary>limit</primary>
24250 <secondary>number of recipients</secondary>
24251 </indexterm>
24252 <indexterm role="concept">
24253 <primary>recipient</primary>
24254 <secondary>maximum number</secondary>
24255 </indexterm>
24256 If this option is set greater than zero, it specifies the maximum number of
24257 original recipients for any message. Additional recipients that are generated
24258 by aliasing or forwarding do not count. SMTP messages get a 452 response for
24259 all recipients over the limit; earlier recipients are delivered as normal.
24260 Non-SMTP messages with too many recipients are failed, and no deliveries are
24261 done.
24262 </para>
24263 <para>
24264 <indexterm role="concept">
24265 <primary>RCPT</primary>
24266 <secondary>maximum number of incoming</secondary>
24267 </indexterm>
24268 <emphasis role="bold">Note</emphasis>: The RFCs specify that an SMTP server should accept at least 100
24269 RCPT commands in a single message.
24270 </para>
24271 <para>
24272 <indexterm role="option">
24273 <primary>recipients_max_reject</primary>
24274 </indexterm>
24275 </para>
24276 <informaltable frame="all">
24277 <tgroup cols="4" colsep="0" rowsep="0">
24278 <colspec colwidth="8*" align="left"/>
24279 <colspec colwidth="5*" align="center"/>
24280 <colspec colwidth="5*" align="center"/>
24281 <colspec colwidth="6*" align="right"/>
24282 <tbody>
24283 <row>
24284 <entry><option>recipients_max_reject</option></entry>
24285 <entry>Use: <emphasis>main</emphasis></entry>
24286 <entry>Type: <emphasis>boolean</emphasis></entry>
24287 <entry>Default: <emphasis>false</emphasis></entry>
24288 </row>
24289 </tbody>
24290 </tgroup>
24291 </informaltable>
24292 <para>
24293 If this option is set true, Exim rejects SMTP messages containing too many
24294 recipients by giving 552 errors to the surplus RCPT commands, and a 554
24295 error to the eventual DATA command. Otherwise (the default) it gives a 452
24296 error to the surplus RCPT commands and accepts the message on behalf of the
24297 initial set of recipients. The remote server should then re-send the message
24298 for the remaining recipients at a later time.
24299 </para>
24300 <para>
24301 <indexterm role="option">
24302 <primary>remote_max_parallel</primary>
24303 </indexterm>
24304 </para>
24305 <informaltable frame="all">
24306 <tgroup cols="4" colsep="0" rowsep="0">
24307 <colspec colwidth="8*" align="left"/>
24308 <colspec colwidth="5*" align="center"/>
24309 <colspec colwidth="5*" align="center"/>
24310 <colspec colwidth="6*" align="right"/>
24311 <tbody>
24312 <row>
24313 <entry><option>remote_max_parallel</option></entry>
24314 <entry>Use: <emphasis>main</emphasis></entry>
24315 <entry>Type: <emphasis>integer</emphasis></entry>
24316 <entry>Default: <emphasis>2</emphasis></entry>
24317 </row>
24318 </tbody>
24319 </tgroup>
24320 </informaltable>
24321 <para>
24322 <indexterm role="concept">
24323 <primary>delivery</primary>
24324 <secondary>parallelism for remote</secondary>
24325 </indexterm>
24326 This option controls parallel delivery of one message to a number of remote
24327 hosts. If the value is less than 2, parallel delivery is disabled, and Exim
24328 does all the remote deliveries for a message one by one. Otherwise, if a single
24329 message has to be delivered to more than one remote host, or if several copies
24330 have to be sent to the same remote host, up to <option>remote_max_parallel</option>
24331 deliveries are done simultaneously. If more than <option>remote_max_parallel</option>
24332 deliveries are required, the maximum number of processes are started, and as
24333 each one finishes, another is begun. The order of starting processes is the
24334 same as if sequential delivery were being done, and can be controlled by the
24335 <option>remote_sort_domains</option> option. If parallel delivery takes place while running
24336 with debugging turned on, the debugging output from each delivery process is
24337 tagged with its process id.
24338 </para>
24339 <para>
24340 This option controls only the maximum number of parallel deliveries for one
24341 message in one Exim delivery process. Because Exim has no central queue
24342 manager, there is no way of controlling the total number of simultaneous
24343 deliveries if the configuration allows a delivery attempt as soon as a message
24344 is received.
24345 </para>
24346 <para>
24347 <indexterm role="concept">
24348 <primary>number of deliveries</primary>
24349 </indexterm>
24350 <indexterm role="concept">
24351 <primary>delivery</primary>
24352 <secondary>maximum number of</secondary>
24353 </indexterm>
24354 If you want to control the total number of deliveries on the system, you
24355 need to set the <option>queue_only</option> option. This ensures that all incoming messages
24356 are added to the queue without starting a delivery process. Then set up an Exim
24357 daemon to start queue runner processes at appropriate intervals (probably
24358 fairly often, for example, every minute), and limit the total number of queue
24359 runners by setting the <option>queue_run_max</option> parameter. Because each queue runner
24360 delivers only one message at a time, the maximum number of deliveries that can
24361 then take place at once is <option>queue_run_max</option> multiplied by
24362 <option>remote_max_parallel</option>.
24363 </para>
24364 <para>
24365 If it is purely remote deliveries you want to control, use
24366 <option>queue_smtp_domains</option> instead of <option>queue_only</option>. This has the added benefit of
24367 doing the SMTP routing before queuing, so that several messages for the same
24368 host will eventually get delivered down the same connection.
24369 </para>
24370 <para>
24371 <indexterm role="option">
24372 <primary>remote_sort_domains</primary>
24373 </indexterm>
24374 </para>
24375 <informaltable frame="all">
24376 <tgroup cols="4" colsep="0" rowsep="0">
24377 <colspec colwidth="8*" align="left"/>
24378 <colspec colwidth="5*" align="center"/>
24379 <colspec colwidth="5*" align="center"/>
24380 <colspec colwidth="6*" align="right"/>
24381 <tbody>
24382 <row>
24383 <entry><option>remote_sort_domains</option></entry>
24384 <entry>Use: <emphasis>main</emphasis></entry>
24385 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
24386 <entry>Default: <emphasis>unset</emphasis></entry>
24387 </row>
24388 </tbody>
24389 </tgroup>
24390 </informaltable>
24391 <para>
24392 <indexterm role="concept">
24393 <primary>sorting remote deliveries</primary>
24394 </indexterm>
24395 <indexterm role="concept">
24396 <primary>delivery</primary>
24397 <secondary>sorting remote</secondary>
24398 </indexterm>
24399 When there are a number of remote deliveries for a message, they are sorted by
24400 domain into the order given by this list. For example,
24401 </para>
24402 <literallayout class="monospaced">
24403 remote_sort_domains = *.cam.ac.uk:*.uk
24404 </literallayout>
24405 <para>
24406 would attempt to deliver to all addresses in the <emphasis>cam.ac.uk</emphasis> domain first,
24407 then to those in the <option>uk</option> domain, then to any others.
24408 </para>
24409 <para>
24410 <indexterm role="option">
24411 <primary>retry_data_expire</primary>
24412 </indexterm>
24413 </para>
24414 <informaltable frame="all">
24415 <tgroup cols="4" colsep="0" rowsep="0">
24416 <colspec colwidth="8*" align="left"/>
24417 <colspec colwidth="5*" align="center"/>
24418 <colspec colwidth="5*" align="center"/>
24419 <colspec colwidth="6*" align="right"/>
24420 <tbody>
24421 <row>
24422 <entry><option>retry_data_expire</option></entry>
24423 <entry>Use: <emphasis>main</emphasis></entry>
24424 <entry>Type: <emphasis>time</emphasis></entry>
24425 <entry>Default: <emphasis>7d</emphasis></entry>
24426 </row>
24427 </tbody>
24428 </tgroup>
24429 </informaltable>
24430 <para>
24431 <indexterm role="concept">
24432 <primary>hints database</primary>
24433 <secondary>data expiry</secondary>
24434 </indexterm>
24435 This option sets a <quote>use before</quote> time on retry information in Exim&#x2019;s hints
24436 database. Any older retry data is ignored. This means that, for example, once a
24437 host has not been tried for 7 days, Exim behaves as if it has no knowledge of
24438 past failures.
24439 </para>
24440 <para>
24441 <indexterm role="option">
24442 <primary>retry_interval_max</primary>
24443 </indexterm>
24444 </para>
24445 <informaltable frame="all">
24446 <tgroup cols="4" colsep="0" rowsep="0">
24447 <colspec colwidth="8*" align="left"/>
24448 <colspec colwidth="5*" align="center"/>
24449 <colspec colwidth="5*" align="center"/>
24450 <colspec colwidth="6*" align="right"/>
24451 <tbody>
24452 <row>
24453 <entry><option>retry_interval_max</option></entry>
24454 <entry>Use: <emphasis>main</emphasis></entry>
24455 <entry>Type: <emphasis>time</emphasis></entry>
24456 <entry>Default: <emphasis>24h</emphasis></entry>
24457 </row>
24458 </tbody>
24459 </tgroup>
24460 </informaltable>
24461 <para>
24462 <indexterm role="concept">
24463 <primary>retry</primary>
24464 <secondary>limit on interval</secondary>
24465 </indexterm>
24466 <indexterm role="concept">
24467 <primary>limit</primary>
24468 <secondary>on retry interval</secondary>
24469 </indexterm>
24470 </para>
24471 <para revisionflag="changed">
24472 Chapter <xref linkend="CHAPretry"/> describes Exim&#x2019;s mechanisms for controlling the
24473 intervals between delivery attempts for messages that cannot be delivered
24474 straight away. This option sets an overall limit to the length of time between
24475 retries. It cannot be set greater than 24 hours; any attempt to do so forces
24476 the default value.
24477 </para>
24478 <para>
24479 <indexterm role="option">
24480 <primary>return_path_remove</primary>
24481 </indexterm>
24482 </para>
24483 <informaltable frame="all">
24484 <tgroup cols="4" colsep="0" rowsep="0">
24485 <colspec colwidth="8*" align="left"/>
24486 <colspec colwidth="5*" align="center"/>
24487 <colspec colwidth="5*" align="center"/>
24488 <colspec colwidth="6*" align="right"/>
24489 <tbody>
24490 <row>
24491 <entry><option>return_path_remove</option></entry>
24492 <entry>Use: <emphasis>main</emphasis></entry>
24493 <entry>Type: <emphasis>boolean</emphasis></entry>
24494 <entry>Default: <emphasis>true</emphasis></entry>
24495 </row>
24496 </tbody>
24497 </tgroup>
24498 </informaltable>
24499 <para>
24500 <indexterm role="concept">
24501 <primary><emphasis>Return-path:</emphasis> header line</primary>
24502 <secondary>removing</secondary>
24503 </indexterm>
24504 RFC 2821, section 4.4, states that an SMTP server must insert a
24505 <emphasis>Return-path:</emphasis> header line into a message when it makes a <quote>final delivery</quote>.
24506 The <emphasis>Return-path:</emphasis> header preserves the sender address as received in the
24507 MAIL command. This description implies that this header should not be present
24508 in an incoming message. If <option>return_path_remove</option> is true, any existing
24509 <emphasis>Return-path:</emphasis> headers are removed from messages at the time they are
24510 received. Exim&#x2019;s transports have options for adding <emphasis>Return-path:</emphasis> headers at
24511 the time of delivery. They are normally used only for final local deliveries.
24512 </para>
24513 <para>
24514 <indexterm role="option">
24515 <primary>return_size_limit</primary>
24516 </indexterm>
24517 </para>
24518 <informaltable frame="all">
24519 <tgroup cols="4" colsep="0" rowsep="0">
24520 <colspec colwidth="8*" align="left"/>
24521 <colspec colwidth="5*" align="center"/>
24522 <colspec colwidth="5*" align="center"/>
24523 <colspec colwidth="6*" align="right"/>
24524 <tbody>
24525 <row>
24526 <entry><option>return_size_limit</option></entry>
24527 <entry>Use: <emphasis>main</emphasis></entry>
24528 <entry>Type: <emphasis>integer</emphasis></entry>
24529 <entry>Default: <emphasis>100K</emphasis></entry>
24530 </row>
24531 </tbody>
24532 </tgroup>
24533 </informaltable>
24534 <para>
24535 This option is an obsolete synonym for <option>bounce_return_size_limit</option>.
24536 </para>
24537 <para>
24538 <indexterm role="option">
24539 <primary>rfc1413_hosts</primary>
24540 </indexterm>
24541 </para>
24542 <informaltable frame="all">
24543 <tgroup cols="4" colsep="0" rowsep="0">
24544 <colspec colwidth="8*" align="left"/>
24545 <colspec colwidth="5*" align="center"/>
24546 <colspec colwidth="5*" align="center"/>
24547 <colspec colwidth="6*" align="right"/>
24548 <tbody>
24549 <row>
24550 <entry><option>rfc1413_hosts</option></entry>
24551 <entry>Use: <emphasis>main</emphasis></entry>
24552 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
24553 <entry>Default: <emphasis>*</emphasis></entry>
24554 </row>
24555 </tbody>
24556 </tgroup>
24557 </informaltable>
24558 <para>
24559 <indexterm role="concept">
24560 <primary>RFC 1413</primary>
24561 </indexterm>
24562 <indexterm role="concept">
24563 <primary>host</primary>
24564 <secondary>for RFC 1413 calls</secondary>
24565 </indexterm>
24566 RFC 1413 identification calls are made to any client host which matches an item
24567 in the list.
24568 </para>
24569 <para revisionflag="changed">
24570 <indexterm role="option">
24571 <primary>rfc1413_query_timeout</primary>
24572 </indexterm>
24573 </para>
24574 <informaltable frame="all" revisionflag="changed">
24575 <tgroup cols="4" colsep="0" rowsep="0">
24576 <colspec colwidth="8*" align="left"/>
24577 <colspec colwidth="5*" align="center"/>
24578 <colspec colwidth="5*" align="center"/>
24579 <colspec colwidth="6*" align="right"/>
24580 <tbody>
24581 <row>
24582 <entry><option>rfc1413_query_timeout</option></entry>
24583 <entry>Use: <emphasis>main</emphasis></entry>
24584 <entry>Type: <emphasis>time</emphasis></entry>
24585 <entry>Default: <emphasis>5s</emphasis></entry>
24586 </row>
24587 </tbody>
24588 </tgroup>
24589 </informaltable>
24590 <para>
24591 <indexterm role="concept">
24592 <primary>RFC 1413</primary>
24593 <secondary>query timeout</secondary>
24594 </indexterm>
24595 <indexterm role="concept">
24596 <primary>timeout</primary>
24597 <secondary>for RFC 1413 call</secondary>
24598 </indexterm>
24599 This sets the timeout on RFC 1413 identification calls. If it is set to zero,
24600 no RFC 1413 calls are ever made.
24601 </para>
24602 <para>
24603 <indexterm role="option">
24604 <primary>sender_unqualified_hosts</primary>
24605 </indexterm>
24606 </para>
24607 <informaltable frame="all">
24608 <tgroup cols="4" colsep="0" rowsep="0">
24609 <colspec colwidth="8*" align="left"/>
24610 <colspec colwidth="5*" align="center"/>
24611 <colspec colwidth="5*" align="center"/>
24612 <colspec colwidth="6*" align="right"/>
24613 <tbody>
24614 <row>
24615 <entry><option>sender_unqualified_hosts</option></entry>
24616 <entry>Use: <emphasis>main</emphasis></entry>
24617 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
24618 <entry>Default: <emphasis>unset</emphasis></entry>
24619 </row>
24620 </tbody>
24621 </tgroup>
24622 </informaltable>
24623 <para>
24624 <indexterm role="concept">
24625 <primary>unqualified addresses</primary>
24626 </indexterm>
24627 <indexterm role="concept">
24628 <primary>host</primary>
24629 <secondary>unqualified addresses from</secondary>
24630 </indexterm>
24631 This option lists those hosts from which Exim is prepared to accept unqualified
24632 sender addresses. The addresses are made fully qualified by the addition of
24633 <option>qualify_domain</option>. This option also affects message header lines. Exim does
24634 not reject unqualified addresses in headers that contain sender addresses, but
24635 it qualifies them only if the message came from a host that matches
24636 <option>sender_unqualified_hosts</option>, or if the message was submitted locally (not
24637 using TCP/IP), and the <option>-bnq</option> option was not set.
24638 </para>
24639 <para>
24640 <indexterm role="option">
24641 <primary>smtp_accept_keepalive</primary>
24642 </indexterm>
24643 </para>
24644 <informaltable frame="all">
24645 <tgroup cols="4" colsep="0" rowsep="0">
24646 <colspec colwidth="8*" align="left"/>
24647 <colspec colwidth="5*" align="center"/>
24648 <colspec colwidth="5*" align="center"/>
24649 <colspec colwidth="6*" align="right"/>
24650 <tbody>
24651 <row>
24652 <entry><option>smtp_accept_keepalive</option></entry>
24653 <entry>Use: <emphasis>main</emphasis></entry>
24654 <entry>Type: <emphasis>boolean</emphasis></entry>
24655 <entry>Default: <emphasis>true</emphasis></entry>
24656 </row>
24657 </tbody>
24658 </tgroup>
24659 </informaltable>
24660 <para>
24661 <indexterm role="concept">
24662 <primary>keepalive</primary>
24663 <secondary>on incoming connection</secondary>
24664 </indexterm>
24665 This option controls the setting of the SO_KEEPALIVE option on incoming
24666 TCP/IP socket connections. When set, it causes the kernel to probe idle
24667 connections periodically, by sending packets with <quote>old</quote> sequence numbers. The
24668 other end of the connection should send an acknowledgement if the connection is
24669 still okay or a reset if the connection has been aborted. The reason for doing
24670 this is that it has the beneficial effect of freeing up certain types of
24671 connection that can get stuck when the remote host is disconnected without
24672 tidying up the TCP/IP call properly. The keepalive mechanism takes several
24673 hours to detect unreachable hosts.
24674 </para>
24675 <para>
24676 <indexterm role="option">
24677 <primary>smtp_accept_max</primary>
24678 </indexterm>
24679 </para>
24680 <informaltable frame="all">
24681 <tgroup cols="4" colsep="0" rowsep="0">
24682 <colspec colwidth="8*" align="left"/>
24683 <colspec colwidth="5*" align="center"/>
24684 <colspec colwidth="5*" align="center"/>
24685 <colspec colwidth="6*" align="right"/>
24686 <tbody>
24687 <row>
24688 <entry><option>smtp_accept_max</option></entry>
24689 <entry>Use: <emphasis>main</emphasis></entry>
24690 <entry>Type: <emphasis>integer</emphasis></entry>
24691 <entry>Default: <emphasis>20</emphasis></entry>
24692 </row>
24693 </tbody>
24694 </tgroup>
24695 </informaltable>
24696 <para>
24697 <indexterm role="concept">
24698 <primary>limit</primary>
24699 <secondary>incoming SMTP connections</secondary>
24700 </indexterm>
24701 <indexterm role="concept">
24702 <primary>SMTP</primary>
24703 <secondary>incoming connection count</secondary>
24704 </indexterm>
24705 <indexterm role="concept">
24706 <primary>inetd</primary>
24707 </indexterm>
24708 This option specifies the maximum number of simultaneous incoming SMTP calls
24709 that Exim will accept. It applies only to the listening daemon; there is no
24710 control (in Exim) when incoming SMTP is being handled by <emphasis>inetd</emphasis>. If the
24711 value is set to zero, no limit is applied. However, it is required to be
24712 non-zero if either <option>smtp_accept_max_per_host</option> or <option>smtp_accept_queue</option> is
24713 set. See also <option>smtp_accept_reserve</option>.
24714 </para>
24715 <para>
24716 <indexterm role="option">
24717 <primary>smtp_accept_max_nonmail</primary>
24718 </indexterm>
24719 </para>
24720 <informaltable frame="all">
24721 <tgroup cols="4" colsep="0" rowsep="0">
24722 <colspec colwidth="8*" align="left"/>
24723 <colspec colwidth="5*" align="center"/>
24724 <colspec colwidth="5*" align="center"/>
24725 <colspec colwidth="6*" align="right"/>
24726 <tbody>
24727 <row>
24728 <entry><option>smtp_accept_max_nonmail</option></entry>
24729 <entry>Use: <emphasis>main</emphasis></entry>
24730 <entry>Type: <emphasis>integer</emphasis></entry>
24731 <entry>Default: <emphasis>10</emphasis></entry>
24732 </row>
24733 </tbody>
24734 </tgroup>
24735 </informaltable>
24736 <para>
24737 <indexterm role="concept">
24738 <primary>limit</primary>
24739 <secondary>non-mail SMTP commands</secondary>
24740 </indexterm>
24741 <indexterm role="concept">
24742 <primary>SMTP</primary>
24743 <secondary>limiting non-mail commands</secondary>
24744 </indexterm>
24745 Exim counts the number of <quote>non-mail</quote> commands in an SMTP session, and drops
24746 the connection if there are too many. This option defines <quote>too many</quote>. The
24747 check catches some denial-of-service attacks, repeated failing AUTHs, or a mad
24748 client looping sending EHLO, for example. The check is applied only if the
24749 client host matches <option>smtp_accept_max_nonmail_hosts</option>.
24750 </para>
24751 <para>
24752 When a new message is expected, one occurrence of RSET is not counted. This
24753 allows a client to send one RSET between messages (this is not necessary,
24754 but some clients do it). Exim also allows one uncounted occurence of HELO
24755 or EHLO, and one occurrence of STARTTLS between messages. After
24756 starting up a TLS session, another EHLO is expected, and so it too is not
24757 counted. The first occurrence of AUTH in a connection, or immediately
24758 following STARTTLS is not counted. Otherwise, all commands other than
24759 MAIL, RCPT, DATA, and QUIT are counted.
24760 </para>
24761 <para>
24762 <indexterm role="option">
24763 <primary>smtp_accept_max_nonmail_hosts</primary>
24764 </indexterm>
24765 </para>
24766 <informaltable frame="all">
24767 <tgroup cols="4" colsep="0" rowsep="0">
24768 <colspec colwidth="8*" align="left"/>
24769 <colspec colwidth="5*" align="center"/>
24770 <colspec colwidth="5*" align="center"/>
24771 <colspec colwidth="6*" align="right"/>
24772 <tbody>
24773 <row>
24774 <entry><option>smtp_accept_max_nonmail_hosts</option></entry>
24775 <entry>Use: <emphasis>main</emphasis></entry>
24776 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
24777 <entry>Default: <emphasis>*</emphasis></entry>
24778 </row>
24779 </tbody>
24780 </tgroup>
24781 </informaltable>
24782 <para>
24783 You can control which hosts are subject to the <option>smtp_accept_max_nonmail</option>
24784 check by setting this option. The default value makes it apply to all hosts. By
24785 changing the value, you can exclude any badly-behaved hosts that you have to
24786 live with.
24787 </para>
24788 <para>
24789 <indexterm role="option">
24790 <primary>smtp_accept_max_per_connection</primary>
24791 </indexterm>
24792 </para>
24793 <informaltable frame="all">
24794 <tgroup cols="4" colsep="0" rowsep="0">
24795 <colspec colwidth="8*" align="left"/>
24796 <colspec colwidth="5*" align="center"/>
24797 <colspec colwidth="5*" align="center"/>
24798 <colspec colwidth="6*" align="right"/>
24799 <tbody>
24800 <row>
24801 <entry><option>smtp_accept_max_per_connection</option></entry>
24802 <entry>Use: <emphasis>main</emphasis></entry>
24803 <entry>Type: <emphasis>integer</emphasis></entry>
24804 <entry>Default: <emphasis>1000</emphasis></entry>
24805 </row>
24806 </tbody>
24807 </tgroup>
24808 </informaltable>
24809 <para>
24810 <indexterm role="concept">
24811 <primary>SMTP incoming message count</primary>
24812 <secondary>limiting</secondary>
24813 </indexterm>
24814 <indexterm role="concept">
24815 <primary>limit</primary>
24816 <secondary>messages per SMTP connection</secondary>
24817 </indexterm>
24818 The value of this option limits the number of MAIL commands that Exim is
24819 prepared to accept over a single SMTP connection, whether or not each command
24820 results in the transfer of a message. After the limit is reached, a 421
24821 response is given to subsequent MAIL commands. This limit is a safety
24822 precaution against a client that goes mad (incidents of this type have been
24823 seen).
24824 </para>
24825 <para>
24826 <indexterm role="option">
24827 <primary>smtp_accept_max_per_host</primary>
24828 </indexterm>
24829 </para>
24830 <informaltable frame="all">
24831 <tgroup cols="4" colsep="0" rowsep="0">
24832 <colspec colwidth="8*" align="left"/>
24833 <colspec colwidth="5*" align="center"/>
24834 <colspec colwidth="5*" align="center"/>
24835 <colspec colwidth="6*" align="right"/>
24836 <tbody>
24837 <row>
24838 <entry><option>smtp_accept_max_per_host</option></entry>
24839 <entry>Use: <emphasis>main</emphasis></entry>
24840 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
24841 <entry>Default: <emphasis>unset</emphasis></entry>
24842 </row>
24843 </tbody>
24844 </tgroup>
24845 </informaltable>
24846 <para>
24847 <indexterm role="concept">
24848 <primary>limit</primary>
24849 <secondary>SMTP connections from one host</secondary>
24850 </indexterm>
24851 <indexterm role="concept">
24852 <primary>host</primary>
24853 <secondary>limiting SMTP connections from</secondary>
24854 </indexterm>
24855 This option restricts the number of simultaneous IP connections from a single
24856 host (strictly, from a single IP address) to the Exim daemon. The option is
24857 expanded, to enable different limits to be applied to different hosts by
24858 reference to <varname>$sender_host_address</varname>. Once the limit is reached, additional
24859 connection attempts from the same host are rejected with error code 421. The
24860 default value of zero imposes no limit. If this option is set, it is required
24861 that <option>smtp_accept_max</option> be non-zero.
24862 </para>
24863 <para>
24864 <emphasis role="bold">Warning</emphasis>: When setting this option you should not use any expansion
24865 constructions that take an appreciable amount of time. The expansion and test
24866 happen in the main daemon loop, in order to reject additional connections
24867 without forking additional processes (otherwise a denial-of-service attack
24868 could cause a vast number or processes to be created). While the daemon is
24869 doing this processing, it cannot accept any other incoming connections.
24870 </para>
24871 <para>
24872 <indexterm role="option">
24873 <primary>smtp_accept_queue</primary>
24874 </indexterm>
24875 </para>
24876 <informaltable frame="all">
24877 <tgroup cols="4" colsep="0" rowsep="0">
24878 <colspec colwidth="8*" align="left"/>
24879 <colspec colwidth="5*" align="center"/>
24880 <colspec colwidth="5*" align="center"/>
24881 <colspec colwidth="6*" align="right"/>
24882 <tbody>
24883 <row>
24884 <entry><option>smtp_accept_queue</option></entry>
24885 <entry>Use: <emphasis>main</emphasis></entry>
24886 <entry>Type: <emphasis>integer</emphasis></entry>
24887 <entry>Default: <emphasis>0</emphasis></entry>
24888 </row>
24889 </tbody>
24890 </tgroup>
24891 </informaltable>
24892 <para>
24893 <indexterm role="concept">
24894 <primary>SMTP</primary>
24895 <secondary>incoming connection count</secondary>
24896 </indexterm>
24897 <indexterm role="concept">
24898 <primary>queueing incoming messages</primary>
24899 </indexterm>
24900 <indexterm role="concept">
24901 <primary>message</primary>
24902 <secondary>queueing by SMTP connection count</secondary>
24903 </indexterm>
24904 If the number of simultaneous incoming SMTP calls handled via the listening
24905 daemon exceeds this value, messages received by SMTP are just placed on the
24906 queue; no delivery processes are started automatically. A value of zero implies
24907 no limit, and clearly any non-zero value is useful only if it is less than the
24908 <option>smtp_accept_max</option> value (unless that is zero). See also <option>queue_only</option>,
24909 <option>queue_only_load</option>, <option>queue_smtp_domains</option>, and the various <option>-od</option><emphasis>x</emphasis>
24910 command line options.
24911 </para>
24912 <para>
24913 <indexterm role="option">
24914 <primary>smtp_accept_queue_per_connection</primary>
24915 </indexterm>
24916 </para>
24917 <informaltable frame="all">
24918 <tgroup cols="4" colsep="0" rowsep="0">
24919 <colspec colwidth="8*" align="left"/>
24920 <colspec colwidth="5*" align="center"/>
24921 <colspec colwidth="5*" align="center"/>
24922 <colspec colwidth="6*" align="right"/>
24923 <tbody>
24924 <row>
24925 <entry><option>smtp_accept_queue_per_connection</option></entry>
24926 <entry>Use: <emphasis>main</emphasis></entry>
24927 <entry>Type: <emphasis>integer</emphasis></entry>
24928 <entry>Default: <emphasis>10</emphasis></entry>
24929 </row>
24930 </tbody>
24931 </tgroup>
24932 </informaltable>
24933 <para>
24934 <indexterm role="concept">
24935 <primary>queueing incoming messages</primary>
24936 </indexterm>
24937 <indexterm role="concept">
24938 <primary>message</primary>
24939 <secondary>queueing by message count</secondary>
24940 </indexterm>
24941 This option limits the number of delivery processes that Exim starts
24942 automatically when receiving messages via SMTP, whether via the daemon or by
24943 the use of <option>-bs</option> or <option>-bS</option>. If the value of the option is greater than zero,
24944 and the number of messages received in a single SMTP session exceeds this
24945 number, subsequent messages are placed on the queue, but no delivery processes
24946 are started. This helps to limit the number of Exim processes when a server
24947 restarts after downtime and there is a lot of mail waiting for it on other
24948 systems. On large systems, the default should probably be increased, and on
24949 dial-in client systems it should probably be set to zero (that is, disabled).
24950 </para>
24951 <para>
24952 <indexterm role="option">
24953 <primary>smtp_accept_reserve</primary>
24954 </indexterm>
24955 </para>
24956 <informaltable frame="all">
24957 <tgroup cols="4" colsep="0" rowsep="0">
24958 <colspec colwidth="8*" align="left"/>
24959 <colspec colwidth="5*" align="center"/>
24960 <colspec colwidth="5*" align="center"/>
24961 <colspec colwidth="6*" align="right"/>
24962 <tbody>
24963 <row>
24964 <entry><option>smtp_accept_reserve</option></entry>
24965 <entry>Use: <emphasis>main</emphasis></entry>
24966 <entry>Type: <emphasis>integer</emphasis></entry>
24967 <entry>Default: <emphasis>0</emphasis></entry>
24968 </row>
24969 </tbody>
24970 </tgroup>
24971 </informaltable>
24972 <para>
24973 <indexterm role="concept">
24974 <primary>SMTP</primary>
24975 <secondary>incoming call count</secondary>
24976 </indexterm>
24977 <indexterm role="concept">
24978 <primary>host</primary>
24979 <secondary>reserved</secondary>
24980 </indexterm>
24981 When <option>smtp_accept_max</option> is set greater than zero, this option specifies a
24982 number of SMTP connections that are reserved for connections from the hosts
24983 that are specified in <option>smtp_reserve_hosts</option>. The value set in
24984 <option>smtp_accept_max</option> includes this reserve pool. The specified hosts are not
24985 restricted to this number of connections; the option specifies a minimum number
24986 of connection slots for them, not a maximum. It is a guarantee that that group
24987 of hosts can always get at least <option>smtp_accept_reserve</option> connections.
24988 </para>
24989 <para>
24990 For example, if <option>smtp_accept_max</option> is set to 50 and <option>smtp_accept_reserve</option> is
24991 set to 5, once there are 45 active connections (from any hosts), new
24992 connections are accepted only from hosts listed in <option>smtp_reserve_hosts</option>.
24993 See also <option>smtp_accept_max_per_host</option>.
24994 </para>
24995 <para>
24996 <indexterm role="option">
24997 <primary>smtp_active_hostname</primary>
24998 </indexterm>
24999 </para>
25000 <informaltable frame="all">
25001 <tgroup cols="4" colsep="0" rowsep="0">
25002 <colspec colwidth="8*" align="left"/>
25003 <colspec colwidth="5*" align="center"/>
25004 <colspec colwidth="5*" align="center"/>
25005 <colspec colwidth="6*" align="right"/>
25006 <tbody>
25007 <row>
25008 <entry><option>smtp_active_hostname</option></entry>
25009 <entry>Use: <emphasis>main</emphasis></entry>
25010 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
25011 <entry>Default: <emphasis>unset</emphasis></entry>
25012 </row>
25013 </tbody>
25014 </tgroup>
25015 </informaltable>
25016 <para>
25017 <indexterm role="concept">
25018 <primary>host</primary>
25019 <secondary>name in SMTP responses</secondary>
25020 </indexterm>
25021 <indexterm role="concept">
25022 <primary>SMTP</primary>
25023 <secondary>host name in responses</secondary>
25024 </indexterm>
25025 <indexterm role="concept">
25026 <primary><varname>$primary_hostname</varname></primary>
25027 </indexterm>
25028 This option is provided for multi-homed servers that want to masquerade as
25029 several different hosts. At the start of an SMTP connection, its value is
25030 expanded and used instead of the value of <varname>$primary_hostname</varname> in SMTP
25031 responses. For example, it is used as domain name in the response to an
25032 incoming HELO or EHLO command.
25033 </para>
25034 <para>
25035 <indexterm role="concept">
25036 <primary><varname>$smtp_active_hostname</varname></primary>
25037 </indexterm>
25038 It is also used in HELO commands for callout verification. The active hostname
25039 is placed in the <varname>$smtp_active_hostname</varname> variable, which is saved with any
25040 messages that are received. It is therefore available for use in routers and
25041 transports when the message is later delivered.
25042 </para>
25043 <para>
25044 If this option is unset, or if its expansion is forced to fail, or if the
25045 expansion results in an empty string, the value of <varname>$primary_hostname</varname> is
25046 used. Other expansion failures cause a message to be written to the main and
25047 panic logs, and the SMTP command receives a temporary error. Typically, the
25048 value of <option>smtp_active_hostname</option> depends on the incoming interface address.
25049 For example:
25050 </para>
25051 <literallayout class="monospaced">
25052 smtp_active_hostname = ${if eq{$interface_address}{10.0.0.1}\
25053   {cox.mydomain}{box.mydomain}}
25054 </literallayout>
25055 <para>
25056 <indexterm role="option">
25057 <primary>smtp_banner</primary>
25058 </indexterm>
25059 </para>
25060 <informaltable frame="all">
25061 <tgroup cols="4" colsep="0" rowsep="0">
25062 <colspec colwidth="8*" align="left"/>
25063 <colspec colwidth="5*" align="center"/>
25064 <colspec colwidth="5*" align="center"/>
25065 <colspec colwidth="6*" align="right"/>
25066 <tbody>
25067 <row>
25068 <entry><option>smtp_banner</option></entry>
25069 <entry>Use: <emphasis>main</emphasis></entry>
25070 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
25071 <entry>Default: <emphasis>see below</emphasis></entry>
25072 </row>
25073 </tbody>
25074 </tgroup>
25075 </informaltable>
25076 <para>
25077 <indexterm role="concept">
25078 <primary>SMTP</primary>
25079 <secondary>welcome banner</secondary>
25080 </indexterm>
25081 <indexterm role="concept">
25082 <primary>banner for SMTP</primary>
25083 </indexterm>
25084 <indexterm role="concept">
25085 <primary>welcome banner for SMTP</primary>
25086 </indexterm>
25087 <indexterm role="concept">
25088 <primary>customizing</primary>
25089 <secondary>SMTP banner</secondary>
25090 </indexterm>
25091 This string, which is expanded every time it is used, is output as the initial
25092 positive response to an SMTP connection. The default setting is:
25093 </para>
25094 <literallayout class="monospaced">
25095 smtp_banner = $smtp_active_hostname ESMTP Exim \
25096   $version_number $tod_full
25097 </literallayout>
25098 <para>
25099 Failure to expand the string causes a panic error. If you want to create a
25100 multiline response to the initial SMTP connection, use <quote>\n</quote> in the string at
25101 appropriate points, but not at the end. Note that the 220 code is not included
25102 in this string. Exim adds it automatically (several times in the case of a
25103 multiline response).
25104 </para>
25105 <para>
25106 <indexterm role="option">
25107 <primary>smtp_check_spool_space</primary>
25108 </indexterm>
25109 </para>
25110 <informaltable frame="all">
25111 <tgroup cols="4" colsep="0" rowsep="0">
25112 <colspec colwidth="8*" align="left"/>
25113 <colspec colwidth="5*" align="center"/>
25114 <colspec colwidth="5*" align="center"/>
25115 <colspec colwidth="6*" align="right"/>
25116 <tbody>
25117 <row>
25118 <entry><option>smtp_check_spool_space</option></entry>
25119 <entry>Use: <emphasis>main</emphasis></entry>
25120 <entry>Type: <emphasis>boolean</emphasis></entry>
25121 <entry>Default: <emphasis>true</emphasis></entry>
25122 </row>
25123 </tbody>
25124 </tgroup>
25125 </informaltable>
25126 <para>
25127 <indexterm role="concept">
25128 <primary>checking disk space</primary>
25129 </indexterm>
25130 <indexterm role="concept">
25131 <primary>disk space</primary>
25132 <secondary>checking</secondary>
25133 </indexterm>
25134 <indexterm role="concept">
25135 <primary>spool directory</primary>
25136 <secondary>checking space</secondary>
25137 </indexterm>
25138 When this option is set, if an incoming SMTP session encounters the SIZE
25139 option on a MAIL command, it checks that there is enough space in the
25140 spool directory&#x2019;s partition to accept a message of that size, while still
25141 leaving free the amount specified by <option>check_spool_space</option> (even if that value
25142 is zero). If there isn&#x2019;t enough space, a temporary error code is returned.
25143 </para>
25144 <para>
25145 <indexterm role="option">
25146 <primary>smtp_connect_backlog</primary>
25147 </indexterm>
25148 </para>
25149 <informaltable frame="all">
25150 <tgroup cols="4" colsep="0" rowsep="0">
25151 <colspec colwidth="8*" align="left"/>
25152 <colspec colwidth="5*" align="center"/>
25153 <colspec colwidth="5*" align="center"/>
25154 <colspec colwidth="6*" align="right"/>
25155 <tbody>
25156 <row>
25157 <entry><option>smtp_connect_backlog</option></entry>
25158 <entry>Use: <emphasis>main</emphasis></entry>
25159 <entry>Type: <emphasis>integer</emphasis></entry>
25160 <entry>Default: <emphasis>20</emphasis></entry>
25161 </row>
25162 </tbody>
25163 </tgroup>
25164 </informaltable>
25165 <para>
25166 <indexterm role="concept">
25167 <primary>connection backlog</primary>
25168 </indexterm>
25169 <indexterm role="concept">
25170 <primary>SMTP</primary>
25171 <secondary>connection backlog</secondary>
25172 </indexterm>
25173 <indexterm role="concept">
25174 <primary>backlog of connections</primary>
25175 </indexterm>
25176 This option specifies a maximum number of waiting SMTP connections. Exim passes
25177 this value to the TCP/IP system when it sets up its listener. Once this number
25178 of connections are waiting for the daemon&#x2019;s attention, subsequent connection
25179 attempts are refused at the TCP/IP level. At least, that is what the manuals
25180 say; in some circumstances such connection attempts have been observed to time
25181 out instead. For large systems it is probably a good idea to increase the
25182 value (to 50, say). It also gives some protection against denial-of-service
25183 attacks by SYN flooding.
25184 </para>
25185 <para>
25186 <indexterm role="option">
25187 <primary>smtp_enforce_sync</primary>
25188 </indexterm>
25189 </para>
25190 <informaltable frame="all">
25191 <tgroup cols="4" colsep="0" rowsep="0">
25192 <colspec colwidth="8*" align="left"/>
25193 <colspec colwidth="5*" align="center"/>
25194 <colspec colwidth="5*" align="center"/>
25195 <colspec colwidth="6*" align="right"/>
25196 <tbody>
25197 <row>
25198 <entry><option>smtp_enforce_sync</option></entry>
25199 <entry>Use: <emphasis>main</emphasis></entry>
25200 <entry>Type: <emphasis>boolean</emphasis></entry>
25201 <entry>Default: <emphasis>true</emphasis></entry>
25202 </row>
25203 </tbody>
25204 </tgroup>
25205 </informaltable>
25206 <para>
25207 <indexterm role="concept">
25208 <primary>SMTP</primary>
25209 <secondary>synchronization checking</secondary>
25210 </indexterm>
25211 <indexterm role="concept">
25212 <primary>synchronization checking in SMTP</primary>
25213 </indexterm>
25214 The SMTP protocol specification requires the client to wait for a response from
25215 the server at certain points in the dialogue. Without PIPELINING these
25216 synchronization points are after every command; with PIPELINING they are
25217 fewer, but they still exist.
25218 </para>
25219 <para>
25220 Some spamming sites send out a complete set of SMTP commands without waiting
25221 for any response. Exim protects against this by rejecting a message if the
25222 client has sent further input when it should not have. The error response <quote>554
25223 SMTP synchronization error</quote> is sent, and the connection is dropped. Testing
25224 for this error cannot be perfect because of transmission delays (unexpected
25225 input may be on its way but not yet received when Exim checks). However, it
25226 does detect many instances.
25227 </para>
25228 <para>
25229 The check can be globally disabled by setting <option>smtp_enforce_sync</option> false.
25230 If you want to disable the check selectively (for example, only for certain
25231 hosts), you can do so by an appropriate use of a <option>control</option> modifier in an ACL
25232 (see section <xref linkend="SECTcontrols"/>). See also <option>pipelining_advertise_hosts</option>.
25233 </para>
25234 <para>
25235 <indexterm role="option">
25236 <primary>smtp_etrn_command</primary>
25237 </indexterm>
25238 </para>
25239 <informaltable frame="all">
25240 <tgroup cols="4" colsep="0" rowsep="0">
25241 <colspec colwidth="8*" align="left"/>
25242 <colspec colwidth="5*" align="center"/>
25243 <colspec colwidth="5*" align="center"/>
25244 <colspec colwidth="6*" align="right"/>
25245 <tbody>
25246 <row>
25247 <entry><option>smtp_etrn_command</option></entry>
25248 <entry>Use: <emphasis>main</emphasis></entry>
25249 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
25250 <entry>Default: <emphasis>unset</emphasis></entry>
25251 </row>
25252 </tbody>
25253 </tgroup>
25254 </informaltable>
25255 <para>
25256 <indexterm role="concept">
25257 <primary>ETRN</primary>
25258 <secondary>command to be run</secondary>
25259 </indexterm>
25260 <indexterm role="concept">
25261 <primary><varname>$domain</varname></primary>
25262 </indexterm>
25263 If this option is set, the given command is run whenever an SMTP ETRN
25264 command is received from a host that is permitted to issue such commands (see
25265 chapter <xref linkend="CHAPACL"/>). The string is split up into separate arguments which
25266 are independently expanded. The expansion variable <varname>$domain</varname> is set to the
25267 argument of the ETRN command, and no syntax checking is done on it. For
25268 example:
25269 </para>
25270 <literallayout class="monospaced">
25271 smtp_etrn_command = /etc/etrn_command $domain \
25272                     $sender_host_address
25273 </literallayout>
25274 <para>
25275 A new process is created to run the command, but Exim does not wait for it to
25276 complete. Consequently, its status cannot be checked. If the command cannot be
25277 run, a line is written to the panic log, but the ETRN caller still receives
25278 a 250 success response. Exim is normally running under its own uid when
25279 receiving SMTP, so it is not possible for it to change the uid before running
25280 the command.
25281 </para>
25282 <para>
25283 <indexterm role="option">
25284 <primary>smtp_etrn_serialize</primary>
25285 </indexterm>
25286 </para>
25287 <informaltable frame="all">
25288 <tgroup cols="4" colsep="0" rowsep="0">
25289 <colspec colwidth="8*" align="left"/>
25290 <colspec colwidth="5*" align="center"/>
25291 <colspec colwidth="5*" align="center"/>
25292 <colspec colwidth="6*" align="right"/>
25293 <tbody>
25294 <row>
25295 <entry><option>smtp_etrn_serialize</option></entry>
25296 <entry>Use: <emphasis>main</emphasis></entry>
25297 <entry>Type: <emphasis>boolean</emphasis></entry>
25298 <entry>Default: <emphasis>true</emphasis></entry>
25299 </row>
25300 </tbody>
25301 </tgroup>
25302 </informaltable>
25303 <para>
25304 <indexterm role="concept">
25305 <primary>ETRN</primary>
25306 <secondary>serializing</secondary>
25307 </indexterm>
25308 When this option is set, it prevents the simultaneous execution of more than
25309 one identical command as a result of ETRN in an SMTP connection. See
25310 section <xref linkend="SECTETRN"/> for details.
25311 </para>
25312 <para>
25313 <indexterm role="option">
25314 <primary>smtp_load_reserve</primary>
25315 </indexterm>
25316 </para>
25317 <informaltable frame="all">
25318 <tgroup cols="4" colsep="0" rowsep="0">
25319 <colspec colwidth="8*" align="left"/>
25320 <colspec colwidth="5*" align="center"/>
25321 <colspec colwidth="5*" align="center"/>
25322 <colspec colwidth="6*" align="right"/>
25323 <tbody>
25324 <row>
25325 <entry><option>smtp_load_reserve</option></entry>
25326 <entry>Use: <emphasis>main</emphasis></entry>
25327 <entry>Type: <emphasis>fixed-point</emphasis></entry>
25328 <entry>Default: <emphasis>unset</emphasis></entry>
25329 </row>
25330 </tbody>
25331 </tgroup>
25332 </informaltable>
25333 <para>
25334 <indexterm role="concept">
25335 <primary>load average</primary>
25336 </indexterm>
25337 If the system load average ever gets higher than this, incoming SMTP calls are
25338 accepted only from those hosts that match an entry in <option>smtp_reserve_hosts</option>.
25339 If <option>smtp_reserve_hosts</option> is not set, no incoming SMTP calls are accepted when
25340 the load is over the limit. The option has no effect on ancient operating
25341 systems on which Exim cannot determine the load average. See also
25342 <option>deliver_queue_load_max</option> and <option>queue_only_load</option>.
25343 </para>
25344 <para>
25345 <indexterm role="option">
25346 <primary>smtp_max_synprot_errors</primary>
25347 </indexterm>
25348 </para>
25349 <informaltable frame="all">
25350 <tgroup cols="4" colsep="0" rowsep="0">
25351 <colspec colwidth="8*" align="left"/>
25352 <colspec colwidth="5*" align="center"/>
25353 <colspec colwidth="5*" align="center"/>
25354 <colspec colwidth="6*" align="right"/>
25355 <tbody>
25356 <row>
25357 <entry><option>smtp_max_synprot_errors</option></entry>
25358 <entry>Use: <emphasis>main</emphasis></entry>
25359 <entry>Type: <emphasis>integer</emphasis></entry>
25360 <entry>Default: <emphasis>3</emphasis></entry>
25361 </row>
25362 </tbody>
25363 </tgroup>
25364 </informaltable>
25365 <para>
25366 <indexterm role="concept">
25367 <primary>SMTP</primary>
25368 <secondary>limiting syntax and protocol errors</secondary>
25369 </indexterm>
25370 <indexterm role="concept">
25371 <primary>limit</primary>
25372 <secondary>SMTP syntax and protocol errors</secondary>
25373 </indexterm>
25374 Exim rejects SMTP commands that contain syntax or protocol errors. In
25375 particular, a syntactically invalid email address, as in this command:
25376 </para>
25377 <literallayout class="monospaced">
25378 RCPT TO:&lt;abc xyz@a.b.c&gt;
25379 </literallayout>
25380 <para>
25381 causes immediate rejection of the command, before any other tests are done.
25382 (The ACL cannot be run if there is no valid address to set up for it.) An
25383 example of a protocol error is receiving RCPT before MAIL. If there are
25384 too many syntax or protocol errors in one SMTP session, the connection is
25385 dropped. The limit is set by this option.
25386 </para>
25387 <para>
25388 <indexterm role="concept">
25389 <primary>PIPELINING</primary>
25390 <secondary>expected errors</secondary>
25391 </indexterm>
25392 When the PIPELINING extension to SMTP is in use, some protocol errors are
25393 <quote>expected</quote>, for instance, a RCPT command after a rejected MAIL command.
25394 Exim assumes that PIPELINING will be used if it advertises it (see
25395 <option>pipelining_advertise_hosts</option>), and in this situation, <quote>expected</quote> errors do
25396 not count towards the limit.
25397 </para>
25398 <para>
25399 <indexterm role="option">
25400 <primary>smtp_max_unknown_commands</primary>
25401 </indexterm>
25402 </para>
25403 <informaltable frame="all">
25404 <tgroup cols="4" colsep="0" rowsep="0">
25405 <colspec colwidth="8*" align="left"/>
25406 <colspec colwidth="5*" align="center"/>
25407 <colspec colwidth="5*" align="center"/>
25408 <colspec colwidth="6*" align="right"/>
25409 <tbody>
25410 <row>
25411 <entry><option>smtp_max_unknown_commands</option></entry>
25412 <entry>Use: <emphasis>main</emphasis></entry>
25413 <entry>Type: <emphasis>integer</emphasis></entry>
25414 <entry>Default: <emphasis>3</emphasis></entry>
25415 </row>
25416 </tbody>
25417 </tgroup>
25418 </informaltable>
25419 <para>
25420 <indexterm role="concept">
25421 <primary>SMTP</primary>
25422 <secondary>limiting unknown commands</secondary>
25423 </indexterm>
25424 <indexterm role="concept">
25425 <primary>limit</primary>
25426 <secondary>unknown SMTP commands</secondary>
25427 </indexterm>
25428 If there are too many unrecognized commands in an incoming SMTP session, an
25429 Exim server drops the connection. This is a defence against some kinds of abuse
25430 that subvert web
25431 clients
25432 into making connections to SMTP ports; in these circumstances, a number of
25433 non-SMTP command lines are sent first.
25434 </para>
25435 <para>
25436 <indexterm role="option">
25437 <primary>smtp_ratelimit_hosts</primary>
25438 </indexterm>
25439 </para>
25440 <informaltable frame="all">
25441 <tgroup cols="4" colsep="0" rowsep="0">
25442 <colspec colwidth="8*" align="left"/>
25443 <colspec colwidth="5*" align="center"/>
25444 <colspec colwidth="5*" align="center"/>
25445 <colspec colwidth="6*" align="right"/>
25446 <tbody>
25447 <row>
25448 <entry><option>smtp_ratelimit_hosts</option></entry>
25449 <entry>Use: <emphasis>main</emphasis></entry>
25450 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
25451 <entry>Default: <emphasis>unset</emphasis></entry>
25452 </row>
25453 </tbody>
25454 </tgroup>
25455 </informaltable>
25456 <para>
25457 <indexterm role="concept">
25458 <primary>SMTP</primary>
25459 <secondary>rate limiting</secondary>
25460 </indexterm>
25461 <indexterm role="concept">
25462 <primary>limit</primary>
25463 <secondary>rate of message arrival</secondary>
25464 </indexterm>
25465 <indexterm role="concept">
25466 <primary>RCPT</primary>
25467 <secondary>rate limiting</secondary>
25468 </indexterm>
25469 Some sites find it helpful to be able to limit the rate at which certain hosts
25470 can send them messages, and the rate at which an individual message can specify
25471 recipients.
25472 </para>
25473 <para>
25474 Exim has two rate-limiting facilities. This section describes the older
25475 facility, which can limit rates within a single connection. The newer
25476 <option>ratelimit</option> ACL condition can limit rates across all connections. See section
25477 <xref linkend="SECTratelimiting"/> for details of the newer facility.
25478 </para>
25479 <para>
25480 When a host matches <option>smtp_ratelimit_hosts</option>, the values of
25481 <option>smtp_ratelimit_mail</option> and <option>smtp_ratelimit_rcpt</option> are used to control the
25482 rate of acceptance of MAIL and RCPT commands in a single SMTP session,
25483 respectively. Each option, if set, must contain a set of four comma-separated
25484 values:
25485 </para>
25486 <itemizedlist>
25487 <listitem>
25488 <para>
25489 A threshold, before which there is no rate limiting.
25490 </para>
25491 </listitem>
25492 <listitem>
25493 <para>
25494 An initial time delay. Unlike other times in Exim, numbers with decimal
25495 fractional parts are allowed here.
25496 </para>
25497 </listitem>
25498 <listitem>
25499 <para>
25500 A factor by which to increase the delay each time.
25501 </para>
25502 </listitem>
25503 <listitem>
25504 <para>
25505 A maximum value for the delay. This should normally be less than 5 minutes,
25506 because after that time, the client is liable to timeout the SMTP command.
25507 </para>
25508 </listitem>
25509 </itemizedlist>
25510 <para>
25511 For example, these settings have been used successfully at the site which
25512 first suggested this feature, for controlling mail from their customers:
25513 </para>
25514 <literallayout class="monospaced">
25515 smtp_ratelimit_mail = 2,0.5s,1.05,4m
25516 smtp_ratelimit_rcpt = 4,0.25s,1.015,4m
25517 </literallayout>
25518 <para>
25519 The first setting specifies delays that are applied to MAIL commands after
25520 two have been received over a single connection. The initial delay is 0.5
25521 seconds, increasing by a factor of 1.05 each time. The second setting applies
25522 delays to RCPT commands when more than four occur in a single message.
25523 </para>
25524 <para>
25525 <indexterm role="option">
25526 <primary>smtp_ratelimit_mail</primary>
25527 </indexterm>
25528 </para>
25529 <informaltable frame="all">
25530 <tgroup cols="4" colsep="0" rowsep="0">
25531 <colspec colwidth="8*" align="left"/>
25532 <colspec colwidth="5*" align="center"/>
25533 <colspec colwidth="5*" align="center"/>
25534 <colspec colwidth="6*" align="right"/>
25535 <tbody>
25536 <row>
25537 <entry><option>smtp_ratelimit_mail</option></entry>
25538 <entry>Use: <emphasis>main</emphasis></entry>
25539 <entry>Type: <emphasis>string</emphasis></entry>
25540 <entry>Default: <emphasis>unset</emphasis></entry>
25541 </row>
25542 </tbody>
25543 </tgroup>
25544 </informaltable>
25545 <para>
25546 See <option>smtp_ratelimit_hosts</option> above.
25547 </para>
25548 <para>
25549 <indexterm role="option">
25550 <primary>smtp_ratelimit_rcpt</primary>
25551 </indexterm>
25552 </para>
25553 <informaltable frame="all">
25554 <tgroup cols="4" colsep="0" rowsep="0">
25555 <colspec colwidth="8*" align="left"/>
25556 <colspec colwidth="5*" align="center"/>
25557 <colspec colwidth="5*" align="center"/>
25558 <colspec colwidth="6*" align="right"/>
25559 <tbody>
25560 <row>
25561 <entry><option>smtp_ratelimit_rcpt</option></entry>
25562 <entry>Use: <emphasis>main</emphasis></entry>
25563 <entry>Type: <emphasis>string</emphasis></entry>
25564 <entry>Default: <emphasis>unset</emphasis></entry>
25565 </row>
25566 </tbody>
25567 </tgroup>
25568 </informaltable>
25569 <para>
25570 See <option>smtp_ratelimit_hosts</option> above.
25571 </para>
25572 <para>
25573 <indexterm role="option">
25574 <primary>smtp_receive_timeout</primary>
25575 </indexterm>
25576 </para>
25577 <informaltable frame="all">
25578 <tgroup cols="4" colsep="0" rowsep="0">
25579 <colspec colwidth="8*" align="left"/>
25580 <colspec colwidth="5*" align="center"/>
25581 <colspec colwidth="5*" align="center"/>
25582 <colspec colwidth="6*" align="right"/>
25583 <tbody>
25584 <row>
25585 <entry><option>smtp_receive_timeout</option></entry>
25586 <entry>Use: <emphasis>main</emphasis></entry>
25587 <entry>Type: <emphasis>time</emphasis></entry>
25588 <entry>Default: <emphasis>5m</emphasis></entry>
25589 </row>
25590 </tbody>
25591 </tgroup>
25592 </informaltable>
25593 <para>
25594 <indexterm role="concept">
25595 <primary>timeout</primary>
25596 <secondary>for SMTP input</secondary>
25597 </indexterm>
25598 <indexterm role="concept">
25599 <primary>SMTP timeout</primary>
25600 <secondary>input</secondary>
25601 </indexterm>
25602 This sets a timeout value for SMTP reception. It applies to all forms of SMTP
25603 input, including batch SMTP. If a line of input (either an SMTP command or a
25604 data line) is not received within this time, the SMTP connection is dropped and
25605 the message is abandoned.
25606 A line is written to the log containing one of the following messages:
25607 </para>
25608 <literallayout class="monospaced">
25609 SMTP command timeout on connection from...
25610 SMTP data timeout on connection from...
25611 </literallayout>
25612 <para>
25613 The former means that Exim was expecting to read an SMTP command; the latter
25614 means that it was in the DATA phase, reading the contents of a message.
25615 </para>
25616 <para>
25617 <indexterm role="concept">
25618 <primary><option>-os</option> option</primary>
25619 </indexterm>
25620 The value set by this option can be overridden by the
25621 <option>-os</option> command-line option. A setting of zero time disables the timeout, but
25622 this should never be used for SMTP over TCP/IP. (It can be useful in some cases
25623 of local input using <option>-bs</option> or <option>-bS</option>.) For non-SMTP input, the reception
25624 timeout is controlled by <option>receive_timeout</option> and <option>-or</option>.
25625 </para>
25626 <para>
25627 <indexterm role="option">
25628 <primary>smtp_reserve_hosts</primary>
25629 </indexterm>
25630 </para>
25631 <informaltable frame="all">
25632 <tgroup cols="4" colsep="0" rowsep="0">
25633 <colspec colwidth="8*" align="left"/>
25634 <colspec colwidth="5*" align="center"/>
25635 <colspec colwidth="5*" align="center"/>
25636 <colspec colwidth="6*" align="right"/>
25637 <tbody>
25638 <row>
25639 <entry><option>smtp_reserve_hosts</option></entry>
25640 <entry>Use: <emphasis>main</emphasis></entry>
25641 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
25642 <entry>Default: <emphasis>unset</emphasis></entry>
25643 </row>
25644 </tbody>
25645 </tgroup>
25646 </informaltable>
25647 <para>
25648 This option defines hosts for which SMTP connections are reserved; see
25649 <option>smtp_accept_reserve</option> and <option>smtp_load_reserve</option> above.
25650 </para>
25651 <para>
25652 <indexterm role="option">
25653 <primary>smtp_return_error_details</primary>
25654 </indexterm>
25655 </para>
25656 <informaltable frame="all">
25657 <tgroup cols="4" colsep="0" rowsep="0">
25658 <colspec colwidth="8*" align="left"/>
25659 <colspec colwidth="5*" align="center"/>
25660 <colspec colwidth="5*" align="center"/>
25661 <colspec colwidth="6*" align="right"/>
25662 <tbody>
25663 <row>
25664 <entry><option>smtp_return_error_details</option></entry>
25665 <entry>Use: <emphasis>main</emphasis></entry>
25666 <entry>Type: <emphasis>boolean</emphasis></entry>
25667 <entry>Default: <emphasis>false</emphasis></entry>
25668 </row>
25669 </tbody>
25670 </tgroup>
25671 </informaltable>
25672 <para>
25673 <indexterm role="concept">
25674 <primary>SMTP</primary>
25675 <secondary>details policy failures</secondary>
25676 </indexterm>
25677 <indexterm role="concept">
25678 <primary>policy control rejection</primary>
25679 <secondary>returning details</secondary>
25680 </indexterm>
25681 In the default state, Exim uses bland messages such as
25682 <quote>Administrative prohibition</quote> when it rejects SMTP commands for policy
25683 reasons. Many sysadmins like this because it gives away little information
25684 to spammers. However, some other syadmins who are applying strict checking
25685 policies want to give out much fuller information about failures. Setting
25686 <option>smtp_return_error_details</option> true causes Exim to be more forthcoming. For
25687 example, instead of <quote>Administrative prohibition</quote>, it might give:
25688 </para>
25689 <literallayout class="monospaced">
25690 550-Rejected after DATA: '&gt;' missing at end of address:
25691 550 failing address in "From" header is: &lt;user@dom.ain
25692 </literallayout>
25693 <para>
25694 <indexterm role="option">
25695 <primary>spamd_address</primary>
25696 </indexterm>
25697 </para>
25698 <informaltable frame="all">
25699 <tgroup cols="4" colsep="0" rowsep="0">
25700 <colspec colwidth="8*" align="left"/>
25701 <colspec colwidth="5*" align="center"/>
25702 <colspec colwidth="5*" align="center"/>
25703 <colspec colwidth="6*" align="right"/>
25704 <tbody>
25705 <row>
25706 <entry><option>spamd_address</option></entry>
25707 <entry>Use: <emphasis>main</emphasis></entry>
25708 <entry>Type: <emphasis>string</emphasis></entry>
25709 <entry>Default: <emphasis>see below</emphasis></entry>
25710 </row>
25711 </tbody>
25712 </tgroup>
25713 </informaltable>
25714 <para>
25715 This option is available when Exim is compiled with the content-scanning
25716 extension. It specifies how Exim connects to SpamAssassin&#x2019;s <option>spamd</option> daemon.
25717 The default value is
25718 </para>
25719 <literallayout class="monospaced">
25720 127.0.0.1 783
25721 </literallayout>
25722 <para>
25723 See section <xref linkend="SECTscanspamass"/> for more details.
25724 </para>
25725 <para>
25726 <indexterm role="option">
25727 <primary>split_spool_directory</primary>
25728 </indexterm>
25729 </para>
25730 <informaltable frame="all">
25731 <tgroup cols="4" colsep="0" rowsep="0">
25732 <colspec colwidth="8*" align="left"/>
25733 <colspec colwidth="5*" align="center"/>
25734 <colspec colwidth="5*" align="center"/>
25735 <colspec colwidth="6*" align="right"/>
25736 <tbody>
25737 <row>
25738 <entry><option>split_spool_directory</option></entry>
25739 <entry>Use: <emphasis>main</emphasis></entry>
25740 <entry>Type: <emphasis>boolean</emphasis></entry>
25741 <entry>Default: <emphasis>false</emphasis></entry>
25742 </row>
25743 </tbody>
25744 </tgroup>
25745 </informaltable>
25746 <para>
25747 <indexterm role="concept">
25748 <primary>multiple spool directories</primary>
25749 </indexterm>
25750 <indexterm role="concept">
25751 <primary>spool directory</primary>
25752 <secondary>split</secondary>
25753 </indexterm>
25754 <indexterm role="concept">
25755 <primary>directories</primary>
25756 <secondary>multiple</secondary>
25757 </indexterm>
25758 If this option is set, it causes Exim to split its input directory into 62
25759 subdirectories, each with a single alphanumeric character as its name. The
25760 sixth character of the message id is used to allocate messages to
25761 subdirectories; this is the least significant base-62 digit of the time of
25762 arrival of the message.
25763 </para>
25764 <para>
25765 Splitting up the spool in this way may provide better performance on systems
25766 where there are long mail queues, by reducing the number of files in any one
25767 directory. The msglog directory is also split up in a similar way to the input
25768 directory; however, if <option>preserve_message_logs</option> is set, all old msglog files
25769 are still placed in the single directory <filename>msglog.OLD</filename>.
25770 </para>
25771 <para>
25772 It is not necessary to take any special action for existing messages when
25773 changing <option>split_spool_directory</option>. Exim notices messages that are in the
25774 <quote>wrong</quote> place, and continues to process them. If the option is turned off
25775 after a period of being on, the subdirectories will eventually empty and be
25776 automatically deleted.
25777 </para>
25778 <para>
25779 When <option>split_spool_directory</option> is set, the behaviour of queue runner processes
25780 changes. Instead of creating a list of all messages in the queue, and then
25781 trying to deliver each one in turn, it constructs a list of those in one
25782 sub-directory and tries to deliver them, before moving on to the next
25783 sub-directory. The sub-directories are processed in a random order. This
25784 spreads out the scanning of the input directories, and uses less memory. It is
25785 particularly beneficial when there are lots of messages on the queue. However,
25786 if <option>queue_run_in_order</option> is set, none of this new processing happens. The
25787 entire queue has to be scanned and sorted before any deliveries can start.
25788 </para>
25789 <para>
25790 <indexterm role="option">
25791 <primary>spool_directory</primary>
25792 </indexterm>
25793 </para>
25794 <informaltable frame="all">
25795 <tgroup cols="4" colsep="0" rowsep="0">
25796 <colspec colwidth="8*" align="left"/>
25797 <colspec colwidth="5*" align="center"/>
25798 <colspec colwidth="5*" align="center"/>
25799 <colspec colwidth="6*" align="right"/>
25800 <tbody>
25801 <row>
25802 <entry><option>spool_directory</option></entry>
25803 <entry>Use: <emphasis>main</emphasis></entry>
25804 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
25805 <entry>Default: <emphasis>set at compile time</emphasis></entry>
25806 </row>
25807 </tbody>
25808 </tgroup>
25809 </informaltable>
25810 <para>
25811 <indexterm role="concept">
25812 <primary>spool directory</primary>
25813 <secondary>path to</secondary>
25814 </indexterm>
25815 This defines the directory in which Exim keeps its spool, that is, the messages
25816 it is waiting to deliver. The default value is taken from the compile-time
25817 configuration setting, if there is one. If not, this option must be set. The
25818 string is expanded, so it can contain, for example, a reference to
25819 <varname>$primary_hostname</varname>.
25820 </para>
25821 <para>
25822 If the spool directory name is fixed on your installation, it is recommended
25823 that you set it at build time rather than from this option, particularly if the
25824 log files are being written to the spool directory (see <option>log_file_path</option>).
25825 Otherwise log files cannot be used for errors that are detected early on, such
25826 as failures in the configuration file.
25827 </para>
25828 <para>
25829 By using this option to override the compiled-in path, it is possible to run
25830 tests of Exim without using the standard spool.
25831 </para>
25832 <para>
25833 <indexterm role="option">
25834 <primary>sqlite_lock_timeout</primary>
25835 </indexterm>
25836 </para>
25837 <informaltable frame="all">
25838 <tgroup cols="4" colsep="0" rowsep="0">
25839 <colspec colwidth="8*" align="left"/>
25840 <colspec colwidth="5*" align="center"/>
25841 <colspec colwidth="5*" align="center"/>
25842 <colspec colwidth="6*" align="right"/>
25843 <tbody>
25844 <row>
25845 <entry><option>sqlite_lock_timeout</option></entry>
25846 <entry>Use: <emphasis>main</emphasis></entry>
25847 <entry>Type: <emphasis>time</emphasis></entry>
25848 <entry>Default: <emphasis>5s</emphasis></entry>
25849 </row>
25850 </tbody>
25851 </tgroup>
25852 </informaltable>
25853 <para>
25854 <indexterm role="concept">
25855 <primary>sqlite</primary>
25856 <secondary>lock timeout</secondary>
25857 </indexterm>
25858 This option controls the timeout that the <command>sqlite</command> lookup uses when trying to
25859 access an SQLite database. See section <xref linkend="SECTsqlite"/> for more details.
25860 </para>
25861 <para>
25862 <indexterm role="option">
25863 <primary>strip_excess_angle_brackets</primary>
25864 </indexterm>
25865 </para>
25866 <informaltable frame="all">
25867 <tgroup cols="4" colsep="0" rowsep="0">
25868 <colspec colwidth="8*" align="left"/>
25869 <colspec colwidth="5*" align="center"/>
25870 <colspec colwidth="5*" align="center"/>
25871 <colspec colwidth="6*" align="right"/>
25872 <tbody>
25873 <row>
25874 <entry><option>strip_excess_angle_brackets</option></entry>
25875 <entry>Use: <emphasis>main</emphasis></entry>
25876 <entry>Type: <emphasis>boolean</emphasis></entry>
25877 <entry>Default: <emphasis>false</emphasis></entry>
25878 </row>
25879 </tbody>
25880 </tgroup>
25881 </informaltable>
25882 <para>
25883 <indexterm role="concept">
25884 <primary>angle brackets</primary>
25885 <secondary>excess</secondary>
25886 </indexterm>
25887 If this option is set, redundant pairs of angle brackets round <quote>route-addr</quote>
25888 items in addresses are stripped. For example, <emphasis>&lt;&lt;xxx@a.b.c.d&gt;&gt;</emphasis> is
25889 treated as <emphasis>&lt;xxx@a.b.c.d&gt;</emphasis>. If this is in the envelope and the message is
25890 passed on to another MTA, the excess angle brackets are not passed on. If this
25891 option is not set, multiple pairs of angle brackets cause a syntax error.
25892 </para>
25893 <para>
25894 <indexterm role="option">
25895 <primary>strip_trailing_dot</primary>
25896 </indexterm>
25897 </para>
25898 <informaltable frame="all">
25899 <tgroup cols="4" colsep="0" rowsep="0">
25900 <colspec colwidth="8*" align="left"/>
25901 <colspec colwidth="5*" align="center"/>
25902 <colspec colwidth="5*" align="center"/>
25903 <colspec colwidth="6*" align="right"/>
25904 <tbody>
25905 <row>
25906 <entry><option>strip_trailing_dot</option></entry>
25907 <entry>Use: <emphasis>main</emphasis></entry>
25908 <entry>Type: <emphasis>boolean</emphasis></entry>
25909 <entry>Default: <emphasis>false</emphasis></entry>
25910 </row>
25911 </tbody>
25912 </tgroup>
25913 </informaltable>
25914 <para>
25915 <indexterm role="concept">
25916 <primary>trailing dot on domain</primary>
25917 </indexterm>
25918 <indexterm role="concept">
25919 <primary>dot</primary>
25920 <secondary>trailing on domain</secondary>
25921 </indexterm>
25922 If this option is set, a trailing dot at the end of a domain in an address is
25923 ignored. If this is in the envelope and the message is passed on to another
25924 MTA, the dot is not passed on. If this option is not set, a dot at the end of a
25925 domain causes a syntax error.
25926 However, addresses in header lines are checked only when an ACL requests header
25927 syntax checking.
25928 </para>
25929 <para>
25930 <indexterm role="option">
25931 <primary>syslog_duplication</primary>
25932 </indexterm>
25933 </para>
25934 <informaltable frame="all">
25935 <tgroup cols="4" colsep="0" rowsep="0">
25936 <colspec colwidth="8*" align="left"/>
25937 <colspec colwidth="5*" align="center"/>
25938 <colspec colwidth="5*" align="center"/>
25939 <colspec colwidth="6*" align="right"/>
25940 <tbody>
25941 <row>
25942 <entry><option>syslog_duplication</option></entry>
25943 <entry>Use: <emphasis>main</emphasis></entry>
25944 <entry>Type: <emphasis>boolean</emphasis></entry>
25945 <entry>Default: <emphasis>true</emphasis></entry>
25946 </row>
25947 </tbody>
25948 </tgroup>
25949 </informaltable>
25950 <para>
25951 <indexterm role="concept">
25952 <primary>syslog</primary>
25953 <secondary>duplicate log lines; suppressing</secondary>
25954 </indexterm>
25955 When Exim is logging to syslog, it writes the log lines for its three
25956 separate logs at different syslog priorities so that they can in principle
25957 be separated on the logging hosts. Some installations do not require this
25958 separation, and in those cases, the duplication of certain log lines is a
25959 nuisance. If <option>syslog_duplication</option> is set false, only one copy of any
25960 particular log line is written to syslog. For lines that normally go to
25961 both the main log and the reject log, the reject log version (possibly
25962 containing message header lines) is written, at LOG_NOTICE priority.
25963 Lines that normally go to both the main and the panic log are written at
25964 the LOG_ALERT priority.
25965 </para>
25966 <para>
25967 <indexterm role="option">
25968 <primary>syslog_facility</primary>
25969 </indexterm>
25970 </para>
25971 <informaltable frame="all">
25972 <tgroup cols="4" colsep="0" rowsep="0">
25973 <colspec colwidth="8*" align="left"/>
25974 <colspec colwidth="5*" align="center"/>
25975 <colspec colwidth="5*" align="center"/>
25976 <colspec colwidth="6*" align="right"/>
25977 <tbody>
25978 <row>
25979 <entry><option>syslog_facility</option></entry>
25980 <entry>Use: <emphasis>main</emphasis></entry>
25981 <entry>Type: <emphasis>string</emphasis></entry>
25982 <entry>Default: <emphasis>unset</emphasis></entry>
25983 </row>
25984 </tbody>
25985 </tgroup>
25986 </informaltable>
25987 <para>
25988 <indexterm role="concept">
25989 <primary>syslog</primary>
25990 <secondary>facility; setting</secondary>
25991 </indexterm>
25992 This option sets the syslog <quote>facility</quote> name, used when Exim is logging to
25993 syslog. The value must be one of the strings <quote>mail</quote>, <quote>user</quote>, <quote>news</quote>,
25994 <quote>uucp</quote>, <quote>daemon</quote>, or <quote>local<emphasis>x</emphasis></quote> where <emphasis>x</emphasis> is a digit between 0 and 7.
25995 If this option is unset, <quote>mail</quote> is used. See chapter <xref linkend="CHAPlog"/> for
25996 details of Exim&#x2019;s logging.
25997 </para>
25998 <para>
25999 <indexterm role="option">
26000 <primary>syslog_processname</primary>
26001 </indexterm>
26002 </para>
26003 <informaltable frame="all">
26004 <tgroup cols="4" colsep="0" rowsep="0">
26005 <colspec colwidth="8*" align="left"/>
26006 <colspec colwidth="5*" align="center"/>
26007 <colspec colwidth="5*" align="center"/>
26008 <colspec colwidth="6*" align="right"/>
26009 <tbody>
26010 <row>
26011 <entry><option>syslog_processname</option></entry>
26012 <entry>Use: <emphasis>main</emphasis></entry>
26013 <entry>Type: <emphasis>string</emphasis></entry>
26014 <entry>Default: <emphasis><literal>exim</literal></emphasis></entry>
26015 </row>
26016 </tbody>
26017 </tgroup>
26018 </informaltable>
26019 <para>
26020 <indexterm role="concept">
26021 <primary>syslog</primary>
26022 <secondary>process name; setting</secondary>
26023 </indexterm>
26024 This option sets the syslog <quote>ident</quote> name, used when Exim is logging to
26025 syslog. The value must be no longer than 32 characters. See chapter
26026 <xref linkend="CHAPlog"/> for details of Exim&#x2019;s logging.
26027 </para>
26028 <para>
26029 <indexterm role="option">
26030 <primary>syslog_timestamp</primary>
26031 </indexterm>
26032 </para>
26033 <informaltable frame="all">
26034 <tgroup cols="4" colsep="0" rowsep="0">
26035 <colspec colwidth="8*" align="left"/>
26036 <colspec colwidth="5*" align="center"/>
26037 <colspec colwidth="5*" align="center"/>
26038 <colspec colwidth="6*" align="right"/>
26039 <tbody>
26040 <row>
26041 <entry><option>syslog_timestamp</option></entry>
26042 <entry>Use: <emphasis>main</emphasis></entry>
26043 <entry>Type: <emphasis>boolean</emphasis></entry>
26044 <entry>Default: <emphasis>true</emphasis></entry>
26045 </row>
26046 </tbody>
26047 </tgroup>
26048 </informaltable>
26049 <para>
26050 <indexterm role="concept">
26051 <primary>syslog</primary>
26052 <secondary>timestamps</secondary>
26053 </indexterm>
26054 If <option>syslog_timestamp</option> is set false, the timestamps on Exim&#x2019;s log lines are
26055 omitted when these lines are sent to syslog. See chapter <xref linkend="CHAPlog"/> for
26056 details of Exim&#x2019;s logging.
26057 </para>
26058 <para>
26059 <indexterm role="option">
26060 <primary>system_filter</primary>
26061 </indexterm>
26062 </para>
26063 <informaltable frame="all">
26064 <tgroup cols="4" colsep="0" rowsep="0">
26065 <colspec colwidth="8*" align="left"/>
26066 <colspec colwidth="5*" align="center"/>
26067 <colspec colwidth="5*" align="center"/>
26068 <colspec colwidth="6*" align="right"/>
26069 <tbody>
26070 <row>
26071 <entry><option>system_filter</option></entry>
26072 <entry>Use: <emphasis>main</emphasis></entry>
26073 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26074 <entry>Default: <emphasis>unset</emphasis></entry>
26075 </row>
26076 </tbody>
26077 </tgroup>
26078 </informaltable>
26079 <para>
26080 <indexterm role="concept">
26081 <primary>filter</primary>
26082 <secondary>system filter</secondary>
26083 </indexterm>
26084 <indexterm role="concept">
26085 <primary>system filter</primary>
26086 <secondary>specifying</secondary>
26087 </indexterm>
26088 <indexterm role="concept">
26089 <primary>Sieve filter</primary>
26090 <secondary>not available for system filter</secondary>
26091 </indexterm>
26092 This option specifies an Exim filter file that is applied to all messages at
26093 the start of each delivery attempt, before any routing is done. System filters
26094 must be Exim filters; they cannot be Sieve filters. If the system filter
26095 generates any deliveries to files or pipes, or any new mail messages, the
26096 appropriate <option>system_filter_..._transport</option> option(s) must be set, to define
26097 which transports are to be used. Details of this facility are given in chapter
26098 <xref linkend="CHAPsystemfilter"/>.
26099 </para>
26100 <para>
26101 <indexterm role="option">
26102 <primary>system_filter_directory_transport</primary>
26103 </indexterm>
26104 </para>
26105 <informaltable frame="all">
26106 <tgroup cols="4" colsep="0" rowsep="0">
26107 <colspec colwidth="8*" align="left"/>
26108 <colspec colwidth="5*" align="center"/>
26109 <colspec colwidth="5*" align="center"/>
26110 <colspec colwidth="6*" align="right"/>
26111 <tbody>
26112 <row>
26113 <entry><option>system_filter_directory_transport</option></entry>
26114 <entry>Use: <emphasis>main</emphasis></entry>
26115 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26116 <entry>Default: <emphasis>unset</emphasis></entry>
26117 </row>
26118 </tbody>
26119 </tgroup>
26120 </informaltable>
26121 <para>
26122 <indexterm role="concept">
26123 <primary><varname>$address_file</varname></primary>
26124 </indexterm>
26125 This sets the name of the transport driver that is to be used when the
26126 <option>save</option> command in a system message filter specifies a path ending in <quote>/</quote>,
26127 implying delivery of each message into a separate file in some directory.
26128 During the delivery, the variable <varname>$address_file</varname> contains the path name.
26129 </para>
26130 <para>
26131 <indexterm role="option">
26132 <primary>system_filter_file_transport</primary>
26133 </indexterm>
26134 </para>
26135 <informaltable frame="all">
26136 <tgroup cols="4" colsep="0" rowsep="0">
26137 <colspec colwidth="8*" align="left"/>
26138 <colspec colwidth="5*" align="center"/>
26139 <colspec colwidth="5*" align="center"/>
26140 <colspec colwidth="6*" align="right"/>
26141 <tbody>
26142 <row>
26143 <entry><option>system_filter_file_transport</option></entry>
26144 <entry>Use: <emphasis>main</emphasis></entry>
26145 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26146 <entry>Default: <emphasis>unset</emphasis></entry>
26147 </row>
26148 </tbody>
26149 </tgroup>
26150 </informaltable>
26151 <para>
26152 <indexterm role="concept">
26153 <primary>file</primary>
26154 <secondary>transport for system filter</secondary>
26155 </indexterm>
26156 This sets the name of the transport driver that is to be used when the <option>save</option>
26157 command in a system message filter specifies a path not ending in <quote>/</quote>. During
26158 the delivery, the variable <varname>$address_file</varname> contains the path name.
26159 </para>
26160 <para>
26161 <indexterm role="option">
26162 <primary>system_filter_group</primary>
26163 </indexterm>
26164 </para>
26165 <informaltable frame="all">
26166 <tgroup cols="4" colsep="0" rowsep="0">
26167 <colspec colwidth="8*" align="left"/>
26168 <colspec colwidth="5*" align="center"/>
26169 <colspec colwidth="5*" align="center"/>
26170 <colspec colwidth="6*" align="right"/>
26171 <tbody>
26172 <row>
26173 <entry><option>system_filter_group</option></entry>
26174 <entry>Use: <emphasis>main</emphasis></entry>
26175 <entry>Type: <emphasis>string</emphasis></entry>
26176 <entry>Default: <emphasis>unset</emphasis></entry>
26177 </row>
26178 </tbody>
26179 </tgroup>
26180 </informaltable>
26181 <para>
26182 <indexterm role="concept">
26183 <primary>gid (group id)</primary>
26184 <secondary>system filter</secondary>
26185 </indexterm>
26186 This option is used only when <option>system_filter_user</option> is also set. It sets the
26187 gid under which the system filter is run, overriding any gid that is associated
26188 with the user. The value may be numerical or symbolic.
26189 </para>
26190 <para>
26191 <indexterm role="option">
26192 <primary>system_filter_pipe_transport</primary>
26193 </indexterm>
26194 </para>
26195 <informaltable frame="all">
26196 <tgroup cols="4" colsep="0" rowsep="0">
26197 <colspec colwidth="8*" align="left"/>
26198 <colspec colwidth="5*" align="center"/>
26199 <colspec colwidth="5*" align="center"/>
26200 <colspec colwidth="6*" align="right"/>
26201 <tbody>
26202 <row>
26203 <entry><option>system_filter_pipe_transport</option></entry>
26204 <entry>Use: <emphasis>main</emphasis></entry>
26205 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26206 <entry>Default: <emphasis>unset</emphasis></entry>
26207 </row>
26208 </tbody>
26209 </tgroup>
26210 </informaltable>
26211 <para>
26212 <indexterm role="concept">
26213 <primary><command>pipe</command> transport</primary>
26214 <secondary>for system filter</secondary>
26215 </indexterm>
26216 <indexterm role="concept">
26217 <primary><varname>$address_pipe</varname></primary>
26218 </indexterm>
26219 This specifies the transport driver that is to be used when a <option>pipe</option> command
26220 is used in a system filter. During the delivery, the variable <varname>$address_pipe</varname>
26221 contains the pipe command.
26222 </para>
26223 <para>
26224 <indexterm role="option">
26225 <primary>system_filter_reply_transport</primary>
26226 </indexterm>
26227 </para>
26228 <informaltable frame="all">
26229 <tgroup cols="4" colsep="0" rowsep="0">
26230 <colspec colwidth="8*" align="left"/>
26231 <colspec colwidth="5*" align="center"/>
26232 <colspec colwidth="5*" align="center"/>
26233 <colspec colwidth="6*" align="right"/>
26234 <tbody>
26235 <row>
26236 <entry><option>system_filter_reply_transport</option></entry>
26237 <entry>Use: <emphasis>main</emphasis></entry>
26238 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26239 <entry>Default: <emphasis>unset</emphasis></entry>
26240 </row>
26241 </tbody>
26242 </tgroup>
26243 </informaltable>
26244 <para>
26245 <indexterm role="concept">
26246 <primary><command>autoreply</command> transport</primary>
26247 <secondary>for system filter</secondary>
26248 </indexterm>
26249 This specifies the transport driver that is to be used when a <option>mail</option> command
26250 is used in a system filter.
26251 </para>
26252 <para>
26253 <indexterm role="option">
26254 <primary>system_filter_user</primary>
26255 </indexterm>
26256 </para>
26257 <informaltable frame="all">
26258 <tgroup cols="4" colsep="0" rowsep="0">
26259 <colspec colwidth="8*" align="left"/>
26260 <colspec colwidth="5*" align="center"/>
26261 <colspec colwidth="5*" align="center"/>
26262 <colspec colwidth="6*" align="right"/>
26263 <tbody>
26264 <row>
26265 <entry><option>system_filter_user</option></entry>
26266 <entry>Use: <emphasis>main</emphasis></entry>
26267 <entry>Type: <emphasis>string</emphasis></entry>
26268 <entry>Default: <emphasis>unset</emphasis></entry>
26269 </row>
26270 </tbody>
26271 </tgroup>
26272 </informaltable>
26273 <para>
26274 <indexterm role="concept">
26275 <primary>uid (user id)</primary>
26276 <secondary>system filter</secondary>
26277 </indexterm>
26278 If this option is not set, the system filter is run in the main Exim delivery
26279 process, as root. When the option is set, the system filter runs in a separate
26280 process, as the given user. Unless the string consists entirely of digits, it
26281 is looked up in the password data. Failure to find the named user causes a
26282 configuration error. The gid is either taken from the password data, or
26283 specified by <option>system_filter_group</option>. When the uid is specified numerically,
26284 <option>system_filter_group</option> is required to be set.
26285 </para>
26286 <para>
26287 If the system filter generates any pipe, file, or reply deliveries, the uid
26288 under which the filter is run is used when transporting them, unless a
26289 transport option overrides. Normally you should set <option>system_filter_user</option> if
26290 your system filter generates these kinds of delivery.
26291 </para>
26292 <para>
26293 <indexterm role="option">
26294 <primary>tcp_nodelay</primary>
26295 </indexterm>
26296 </para>
26297 <informaltable frame="all">
26298 <tgroup cols="4" colsep="0" rowsep="0">
26299 <colspec colwidth="8*" align="left"/>
26300 <colspec colwidth="5*" align="center"/>
26301 <colspec colwidth="5*" align="center"/>
26302 <colspec colwidth="6*" align="right"/>
26303 <tbody>
26304 <row>
26305 <entry><option>tcp_nodelay</option></entry>
26306 <entry>Use: <emphasis>main</emphasis></entry>
26307 <entry>Type: <emphasis>boolean</emphasis></entry>
26308 <entry>Default: <emphasis>true</emphasis></entry>
26309 </row>
26310 </tbody>
26311 </tgroup>
26312 </informaltable>
26313 <para>
26314 <indexterm role="concept">
26315 <primary>daemon</primary>
26316 <secondary>TCP_NODELAY on sockets</secondary>
26317 </indexterm>
26318 <indexterm role="concept">
26319 <primary>Nagle algorithm</primary>
26320 </indexterm>
26321 <indexterm role="concept">
26322 <primary>TCP_NODELAY on listening sockets</primary>
26323 </indexterm>
26324 If this option is set false, it stops the Exim daemon setting the
26325 TCP_NODELAY option on its listening sockets. Setting TCP_NODELAY
26326 turns off the <quote>Nagle algorithm</quote>, which is a way of improving network
26327 performance in interactive (character-by-character) situations. Turning it off
26328 should improve Exim&#x2019;s performance a bit, so that is what happens by default.
26329 However, it appears that some broken clients cannot cope, and time out. Hence
26330 this option. It affects only those sockets that are set up for listening by the
26331 daemon. Sockets created by the smtp transport for delivering mail always set
26332 TCP_NODELAY.
26333 </para>
26334 <para>
26335 <indexterm role="option">
26336 <primary>timeout_frozen_after</primary>
26337 </indexterm>
26338 </para>
26339 <informaltable frame="all">
26340 <tgroup cols="4" colsep="0" rowsep="0">
26341 <colspec colwidth="8*" align="left"/>
26342 <colspec colwidth="5*" align="center"/>
26343 <colspec colwidth="5*" align="center"/>
26344 <colspec colwidth="6*" align="right"/>
26345 <tbody>
26346 <row>
26347 <entry><option>timeout_frozen_after</option></entry>
26348 <entry>Use: <emphasis>main</emphasis></entry>
26349 <entry>Type: <emphasis>time</emphasis></entry>
26350 <entry>Default: <emphasis>0s</emphasis></entry>
26351 </row>
26352 </tbody>
26353 </tgroup>
26354 </informaltable>
26355 <para>
26356 <indexterm role="concept">
26357 <primary>frozen messages</primary>
26358 <secondary>timing out</secondary>
26359 </indexterm>
26360 <indexterm role="concept">
26361 <primary>timeout</primary>
26362 <secondary>frozen messages</secondary>
26363 </indexterm>
26364 If <option>timeout_frozen_after</option> is set to a time greater than zero, a frozen
26365 message of any kind that has been on the queue for longer than the given
26366 time is automatically cancelled at the next queue run. If it is a bounce
26367 message, it is just discarded; otherwise, a bounce is sent to the sender, in a
26368 similar manner to cancellation by the <option>-Mg</option> command line option. If you want
26369 to timeout frozen bounce messages earlier than other kinds of frozen message,
26370 see <option>ignore_bounce_errors_after</option>.
26371 </para>
26372 <para>
26373 <indexterm role="option">
26374 <primary>timezone</primary>
26375 </indexterm>
26376 </para>
26377 <informaltable frame="all">
26378 <tgroup cols="4" colsep="0" rowsep="0">
26379 <colspec colwidth="8*" align="left"/>
26380 <colspec colwidth="5*" align="center"/>
26381 <colspec colwidth="5*" align="center"/>
26382 <colspec colwidth="6*" align="right"/>
26383 <tbody>
26384 <row>
26385 <entry><option>timezone</option></entry>
26386 <entry>Use: <emphasis>main</emphasis></entry>
26387 <entry>Type: <emphasis>string</emphasis></entry>
26388 <entry>Default: <emphasis>unset</emphasis></entry>
26389 </row>
26390 </tbody>
26391 </tgroup>
26392 </informaltable>
26393 <para>
26394 <indexterm role="concept">
26395 <primary>timezone</primary>
26396 <secondary>setting</secondary>
26397 </indexterm>
26398 The value of <option>timezone</option> is used to set the environment variable TZ while
26399 running Exim (if it is different on entry). This ensures that all timestamps
26400 created by Exim are in the required timezone. If you want all your timestamps
26401 to be in UTC (aka GMT) you should set
26402 </para>
26403 <literallayout class="monospaced">
26404 timezone = UTC
26405 </literallayout>
26406 <para>
26407 The default value is taken from TIMEZONE_DEFAULT in <filename>Local/Makefile</filename>,
26408 or, if that is not set, from the value of the TZ environment variable when Exim
26409 is built. If <option>timezone</option> is set to the empty string, either at build or run
26410 time, any existing TZ variable is removed from the environment when Exim
26411 runs. This is appropriate behaviour for obtaining wall-clock time on some, but
26412 unfortunately not all, operating systems.
26413 </para>
26414 <para>
26415 <indexterm role="option">
26416 <primary>tls_advertise_hosts</primary>
26417 </indexterm>
26418 </para>
26419 <informaltable frame="all">
26420 <tgroup cols="4" colsep="0" rowsep="0">
26421 <colspec colwidth="8*" align="left"/>
26422 <colspec colwidth="5*" align="center"/>
26423 <colspec colwidth="5*" align="center"/>
26424 <colspec colwidth="6*" align="right"/>
26425 <tbody>
26426 <row>
26427 <entry><option>tls_advertise_hosts</option></entry>
26428 <entry>Use: <emphasis>main</emphasis></entry>
26429 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
26430 <entry>Default: <emphasis>unset</emphasis></entry>
26431 </row>
26432 </tbody>
26433 </tgroup>
26434 </informaltable>
26435 <para>
26436 <indexterm role="concept">
26437 <primary>TLS</primary>
26438 <secondary>advertising</secondary>
26439 </indexterm>
26440 <indexterm role="concept">
26441 <primary>encryption</primary>
26442 <secondary>on SMTP connection</secondary>
26443 </indexterm>
26444 <indexterm role="concept">
26445 <primary>SMTP</primary>
26446 <secondary>encrypted connection</secondary>
26447 </indexterm>
26448 When Exim is built with support for TLS encrypted connections, the availability
26449 of the STARTTLS command to set up an encrypted session is advertised in
26450 response to EHLO only to those client hosts that match this option. See
26451 chapter <xref linkend="CHAPTLS"/> for details of Exim&#x2019;s support for TLS.
26452 </para>
26453 <para>
26454 <indexterm role="option">
26455 <primary>tls_certificate</primary>
26456 </indexterm>
26457 </para>
26458 <informaltable frame="all">
26459 <tgroup cols="4" colsep="0" rowsep="0">
26460 <colspec colwidth="8*" align="left"/>
26461 <colspec colwidth="5*" align="center"/>
26462 <colspec colwidth="5*" align="center"/>
26463 <colspec colwidth="6*" align="right"/>
26464 <tbody>
26465 <row>
26466 <entry><option>tls_certificate</option></entry>
26467 <entry>Use: <emphasis>main</emphasis></entry>
26468 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26469 <entry>Default: <emphasis>unset</emphasis></entry>
26470 </row>
26471 </tbody>
26472 </tgroup>
26473 </informaltable>
26474 <para>
26475 <indexterm role="concept">
26476 <primary>TLS</primary>
26477 <secondary>server certificate; location of</secondary>
26478 </indexterm>
26479 <indexterm role="concept">
26480 <primary>certificate for server</primary>
26481 <secondary>location of</secondary>
26482 </indexterm>
26483 The value of this option is expanded, and must then be the absolute path to a
26484 file which contains the server&#x2019;s certificates. The server&#x2019;s private key is also
26485 assumed to be in this file if <option>tls_privatekey</option> is unset. See chapter
26486 <xref linkend="CHAPTLS"/> for further details.
26487 </para>
26488 <para>
26489 <emphasis role="bold">Note</emphasis>: The certificates defined by this option are used only when Exim is
26490 receiving incoming messages as a server. If you want to supply certificates for
26491 use when sending messages as a client, you must set the <option>tls_certificate</option>
26492 option in the relevant <command>smtp</command> transport.
26493 </para>
26494 <para>
26495 <indexterm role="option">
26496 <primary>tls_crl</primary>
26497 </indexterm>
26498 </para>
26499 <informaltable frame="all">
26500 <tgroup cols="4" colsep="0" rowsep="0">
26501 <colspec colwidth="8*" align="left"/>
26502 <colspec colwidth="5*" align="center"/>
26503 <colspec colwidth="5*" align="center"/>
26504 <colspec colwidth="6*" align="right"/>
26505 <tbody>
26506 <row>
26507 <entry><option>tls_crl</option></entry>
26508 <entry>Use: <emphasis>main</emphasis></entry>
26509 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26510 <entry>Default: <emphasis>unset</emphasis></entry>
26511 </row>
26512 </tbody>
26513 </tgroup>
26514 </informaltable>
26515 <para>
26516 <indexterm role="concept">
26517 <primary>TLS</primary>
26518 <secondary>server certificate revocation list</secondary>
26519 </indexterm>
26520 <indexterm role="concept">
26521 <primary>certificate</primary>
26522 <secondary>revocation list for server</secondary>
26523 </indexterm>
26524 This option specifies a certificate revocation list. The expanded value must
26525 be the name of a file that contains a CRL in PEM format.
26526 </para>
26527 <para>
26528 <indexterm role="option">
26529 <primary>tls_dhparam</primary>
26530 </indexterm>
26531 </para>
26532 <informaltable frame="all">
26533 <tgroup cols="4" colsep="0" rowsep="0">
26534 <colspec colwidth="8*" align="left"/>
26535 <colspec colwidth="5*" align="center"/>
26536 <colspec colwidth="5*" align="center"/>
26537 <colspec colwidth="6*" align="right"/>
26538 <tbody>
26539 <row>
26540 <entry><option>tls_dhparam</option></entry>
26541 <entry>Use: <emphasis>main</emphasis></entry>
26542 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26543 <entry>Default: <emphasis>unset</emphasis></entry>
26544 </row>
26545 </tbody>
26546 </tgroup>
26547 </informaltable>
26548 <para>
26549 <indexterm role="concept">
26550 <primary>TLS</primary>
26551 <secondary>D-H parameters for server</secondary>
26552 </indexterm>
26553 The value of this option is expanded, and must then be the absolute path to
26554 a file which contains the server&#x2019;s DH parameter values.
26555 This is used only for OpenSSL. When Exim is linked with GnuTLS, this option is
26556 ignored. See section <xref linkend="SECTopenvsgnu"/> for further details.
26557 </para>
26558 <para>
26559 <indexterm role="option">
26560 <primary>tls_on_connect_ports</primary>
26561 </indexterm>
26562 </para>
26563 <informaltable frame="all">
26564 <tgroup cols="4" colsep="0" rowsep="0">
26565 <colspec colwidth="8*" align="left"/>
26566 <colspec colwidth="5*" align="center"/>
26567 <colspec colwidth="5*" align="center"/>
26568 <colspec colwidth="6*" align="right"/>
26569 <tbody>
26570 <row>
26571 <entry><option>tls_on_connect_ports</option></entry>
26572 <entry>Use: <emphasis>main</emphasis></entry>
26573 <entry>Type: <emphasis>string list</emphasis></entry>
26574 <entry>Default: <emphasis>unset</emphasis></entry>
26575 </row>
26576 </tbody>
26577 </tgroup>
26578 </informaltable>
26579 <para>
26580 This option specifies a list of incoming SSMTP (aka SMTPS) ports that should
26581 operate the obsolete SSMTP (SMTPS) protocol, where a TLS session is immediately
26582 set up without waiting for the client to issue a STARTTLS command. For
26583 further details, see section <xref linkend="SECTsupobssmt"/>.
26584 </para>
26585 <para>
26586 <indexterm role="option">
26587 <primary>tls_privatekey</primary>
26588 </indexterm>
26589 </para>
26590 <informaltable frame="all">
26591 <tgroup cols="4" colsep="0" rowsep="0">
26592 <colspec colwidth="8*" align="left"/>
26593 <colspec colwidth="5*" align="center"/>
26594 <colspec colwidth="5*" align="center"/>
26595 <colspec colwidth="6*" align="right"/>
26596 <tbody>
26597 <row>
26598 <entry><option>tls_privatekey</option></entry>
26599 <entry>Use: <emphasis>main</emphasis></entry>
26600 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26601 <entry>Default: <emphasis>unset</emphasis></entry>
26602 </row>
26603 </tbody>
26604 </tgroup>
26605 </informaltable>
26606 <para>
26607 <indexterm role="concept">
26608 <primary>TLS</primary>
26609 <secondary>server private key; location of</secondary>
26610 </indexterm>
26611 </para>
26612 <para revisionflag="changed">
26613 The value of this option is expanded, and must then be the absolute path to a
26614 file which contains the server&#x2019;s private key. If this option is unset, or if
26615 the expansion is forced to fail, or the result is an empty string, the private
26616 key is assumed to be in the same file as the server&#x2019;s certificates. See chapter
26617 <xref linkend="CHAPTLS"/> for further details.
26618 </para>
26619 <para>
26620 <indexterm role="option">
26621 <primary>tls_remember_esmtp</primary>
26622 </indexterm>
26623 </para>
26624 <informaltable frame="all">
26625 <tgroup cols="4" colsep="0" rowsep="0">
26626 <colspec colwidth="8*" align="left"/>
26627 <colspec colwidth="5*" align="center"/>
26628 <colspec colwidth="5*" align="center"/>
26629 <colspec colwidth="6*" align="right"/>
26630 <tbody>
26631 <row>
26632 <entry><option>tls_remember_esmtp</option></entry>
26633 <entry>Use: <emphasis>main</emphasis></entry>
26634 <entry>Type: <emphasis>boolean</emphasis></entry>
26635 <entry>Default: <emphasis>false</emphasis></entry>
26636 </row>
26637 </tbody>
26638 </tgroup>
26639 </informaltable>
26640 <para>
26641 <indexterm role="concept">
26642 <primary>TLS</primary>
26643 <secondary>esmtp state; remembering</secondary>
26644 </indexterm>
26645 <indexterm role="concept">
26646 <primary>TLS</primary>
26647 <secondary>broken clients</secondary>
26648 </indexterm>
26649 If this option is set true, Exim violates the RFCs by remembering that it is in
26650 <quote>esmtp</quote> state after successfully negotiating a TLS session. This provides
26651 support for broken clients that fail to send a new EHLO after starting a
26652 TLS session.
26653 </para>
26654 <para>
26655 <indexterm role="option">
26656 <primary>tls_require_ciphers</primary>
26657 </indexterm>
26658 </para>
26659 <informaltable frame="all">
26660 <tgroup cols="4" colsep="0" rowsep="0">
26661 <colspec colwidth="8*" align="left"/>
26662 <colspec colwidth="5*" align="center"/>
26663 <colspec colwidth="5*" align="center"/>
26664 <colspec colwidth="6*" align="right"/>
26665 <tbody>
26666 <row>
26667 <entry><option>tls_require_ciphers</option></entry>
26668 <entry>Use: <emphasis>main</emphasis></entry>
26669 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26670 <entry>Default: <emphasis>unset</emphasis></entry>
26671 </row>
26672 </tbody>
26673 </tgroup>
26674 </informaltable>
26675 <para>
26676 <indexterm role="concept">
26677 <primary>TLS</primary>
26678 <secondary>requiring specific ciphers</secondary>
26679 </indexterm>
26680 <indexterm role="concept">
26681 <primary>cipher</primary>
26682 <secondary>requiring specific</secondary>
26683 </indexterm>
26684 This option controls which ciphers can be used for incoming TLS connections.
26685 The <command>smtp</command> transport has an option of the same name for controlling outgoing
26686 connections. This option is expanded for each connection, so can be varied for
26687 different clients if required. The value of this option must be a list of
26688 permitted cipher suites. The OpenSSL and GnuTLS libraries handle cipher control
26689 in somewhat different ways. If GnuTLS is being used, the client controls the
26690 preference order of the available ciphers. Details are given in sections
26691 <xref linkend="SECTreqciphssl"/> and <xref linkend="SECTreqciphgnu"/>.
26692 </para>
26693 <para>
26694 <indexterm role="option">
26695 <primary>tls_try_verify_hosts</primary>
26696 </indexterm>
26697 </para>
26698 <informaltable frame="all">
26699 <tgroup cols="4" colsep="0" rowsep="0">
26700 <colspec colwidth="8*" align="left"/>
26701 <colspec colwidth="5*" align="center"/>
26702 <colspec colwidth="5*" align="center"/>
26703 <colspec colwidth="6*" align="right"/>
26704 <tbody>
26705 <row>
26706 <entry><option>tls_try_verify_hosts</option></entry>
26707 <entry>Use: <emphasis>main</emphasis></entry>
26708 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
26709 <entry>Default: <emphasis>unset</emphasis></entry>
26710 </row>
26711 </tbody>
26712 </tgroup>
26713 </informaltable>
26714 <para>
26715 <indexterm role="concept">
26716 <primary>TLS</primary>
26717 <secondary>client certificate verification</secondary>
26718 </indexterm>
26719 <indexterm role="concept">
26720 <primary>certificate</primary>
26721 <secondary>verification of client</secondary>
26722 </indexterm>
26723 See <option>tls_verify_hosts</option> below.
26724 </para>
26725 <para>
26726 <indexterm role="option">
26727 <primary>tls_verify_certificates</primary>
26728 </indexterm>
26729 </para>
26730 <informaltable frame="all">
26731 <tgroup cols="4" colsep="0" rowsep="0">
26732 <colspec colwidth="8*" align="left"/>
26733 <colspec colwidth="5*" align="center"/>
26734 <colspec colwidth="5*" align="center"/>
26735 <colspec colwidth="6*" align="right"/>
26736 <tbody>
26737 <row>
26738 <entry><option>tls_verify_certificates</option></entry>
26739 <entry>Use: <emphasis>main</emphasis></entry>
26740 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26741 <entry>Default: <emphasis>unset</emphasis></entry>
26742 </row>
26743 </tbody>
26744 </tgroup>
26745 </informaltable>
26746 <para>
26747 <indexterm role="concept">
26748 <primary>TLS</primary>
26749 <secondary>client certificate verification</secondary>
26750 </indexterm>
26751 <indexterm role="concept">
26752 <primary>certificate</primary>
26753 <secondary>verification of client</secondary>
26754 </indexterm>
26755 The value of this option is expanded, and must then be the absolute path to
26756 a file containing permitted certificates for clients that
26757 match <option>tls_verify_hosts</option> or <option>tls_try_verify_hosts</option>. Alternatively, if you
26758 are using OpenSSL, you can set <option>tls_verify_certificates</option> to the name of a
26759 directory containing certificate files. This does not work with GnuTLS; the
26760 option must be set to the name of a single file if you are using GnuTLS.
26761 </para>
26762 <para>
26763 <indexterm role="option">
26764 <primary>tls_verify_hosts</primary>
26765 </indexterm>
26766 </para>
26767 <informaltable frame="all">
26768 <tgroup cols="4" colsep="0" rowsep="0">
26769 <colspec colwidth="8*" align="left"/>
26770 <colspec colwidth="5*" align="center"/>
26771 <colspec colwidth="5*" align="center"/>
26772 <colspec colwidth="6*" align="right"/>
26773 <tbody>
26774 <row>
26775 <entry><option>tls_verify_hosts</option></entry>
26776 <entry>Use: <emphasis>main</emphasis></entry>
26777 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
26778 <entry>Default: <emphasis>unset</emphasis></entry>
26779 </row>
26780 </tbody>
26781 </tgroup>
26782 </informaltable>
26783 <para>
26784 <indexterm role="concept">
26785 <primary>TLS</primary>
26786 <secondary>client certificate verification</secondary>
26787 </indexterm>
26788 <indexterm role="concept">
26789 <primary>certificate</primary>
26790 <secondary>verification of client</secondary>
26791 </indexterm>
26792 This option, along with <option>tls_try_verify_hosts</option>, controls the checking of
26793 certificates from clients.
26794 The expected certificates are defined by <option>tls_verify_certificates</option>, which
26795 must be set. A configuration error occurs if either <option>tls_verify_hosts</option> or
26796 <option>tls_try_verify_hosts</option> is set and <option>tls_verify_certificates</option> is not set.
26797 </para>
26798 <para>
26799 Any client that matches <option>tls_verify_hosts</option> is constrained by
26800 <option>tls_verify_certificates</option>. The client must present one of the listed
26801 certificates. If it does not, the connection is aborted.
26802 </para>
26803 <para>
26804 A weaker form of checking is provided by <option>tls_try_verify_hosts</option>. If a client
26805 matches this option (but not <option>tls_verify_hosts</option>), Exim requests a
26806 certificate and checks it against <option>tls_verify_certificates</option>, but does not
26807 abort the connection if there is no certificate or if it does not match. This
26808 state can be detected in an ACL, which makes it possible to implement policies
26809 such as <quote>accept for relay only if a verified certificate has been received,
26810 but accept for local delivery if encrypted, even without a verified
26811 certificate</quote>.
26812 </para>
26813 <para>
26814 Client hosts that match neither of these lists are not asked to present
26815 certificates.
26816 </para>
26817 <para>
26818 <indexterm role="option">
26819 <primary>trusted_groups</primary>
26820 </indexterm>
26821 </para>
26822 <informaltable frame="all">
26823 <tgroup cols="4" colsep="0" rowsep="0">
26824 <colspec colwidth="8*" align="left"/>
26825 <colspec colwidth="5*" align="center"/>
26826 <colspec colwidth="5*" align="center"/>
26827 <colspec colwidth="6*" align="right"/>
26828 <tbody>
26829 <row>
26830 <entry><option>trusted_groups</option></entry>
26831 <entry>Use: <emphasis>main</emphasis></entry>
26832 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
26833 <entry>Default: <emphasis>unset</emphasis></entry>
26834 </row>
26835 </tbody>
26836 </tgroup>
26837 </informaltable>
26838 <para>
26839 <indexterm role="concept">
26840 <primary>trusted group</primary>
26841 </indexterm>
26842 <indexterm role="concept">
26843 <primary>group</primary>
26844 <secondary>trusted</secondary>
26845 </indexterm>
26846 This option is expanded just once, at the start of Exim&#x2019;s processing. If this
26847 option is set, any process that is running in one of the listed groups, or
26848 which has one of them as a supplementary group, is trusted. The groups can be
26849 specified numerically or by name. See section <xref linkend="SECTtrustedadmin"/> for
26850 details of what trusted callers are permitted to do. If neither
26851 <option>trusted_groups</option> nor <option>trusted_users</option> is set, only root and the Exim user
26852 are trusted.
26853 </para>
26854 <para>
26855 <indexterm role="option">
26856 <primary>trusted_users</primary>
26857 </indexterm>
26858 </para>
26859 <informaltable frame="all">
26860 <tgroup cols="4" colsep="0" rowsep="0">
26861 <colspec colwidth="8*" align="left"/>
26862 <colspec colwidth="5*" align="center"/>
26863 <colspec colwidth="5*" align="center"/>
26864 <colspec colwidth="6*" align="right"/>
26865 <tbody>
26866 <row>
26867 <entry><option>trusted_users</option></entry>
26868 <entry>Use: <emphasis>main</emphasis></entry>
26869 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
26870 <entry>Default: <emphasis>unset</emphasis></entry>
26871 </row>
26872 </tbody>
26873 </tgroup>
26874 </informaltable>
26875 <para>
26876 <indexterm role="concept">
26877 <primary>trusted user</primary>
26878 </indexterm>
26879 <indexterm role="concept">
26880 <primary>user</primary>
26881 <secondary>trusted</secondary>
26882 </indexterm>
26883 This option is expanded just once, at the start of Exim&#x2019;s processing. If this
26884 option is set, any process that is running as one of the listed users is
26885 trusted. The users can be specified numerically or by name. See section
26886 <xref linkend="SECTtrustedadmin"/> for details of what trusted callers are permitted to do.
26887 If neither <option>trusted_groups</option> nor <option>trusted_users</option> is set, only root and the
26888 Exim user are trusted.
26889 </para>
26890 <para>
26891 <indexterm role="option">
26892 <primary>unknown_login</primary>
26893 </indexterm>
26894 </para>
26895 <informaltable frame="all">
26896 <tgroup cols="4" colsep="0" rowsep="0">
26897 <colspec colwidth="8*" align="left"/>
26898 <colspec colwidth="5*" align="center"/>
26899 <colspec colwidth="5*" align="center"/>
26900 <colspec colwidth="6*" align="right"/>
26901 <tbody>
26902 <row>
26903 <entry><option>unknown_login</option></entry>
26904 <entry>Use: <emphasis>main</emphasis></entry>
26905 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26906 <entry>Default: <emphasis>unset</emphasis></entry>
26907 </row>
26908 </tbody>
26909 </tgroup>
26910 </informaltable>
26911 <para>
26912 <indexterm role="concept">
26913 <primary>uid (user id)</primary>
26914 <secondary>unknown caller</secondary>
26915 </indexterm>
26916 <indexterm role="concept">
26917 <primary><varname>$caller_uid</varname></primary>
26918 </indexterm>
26919 This is a specialized feature for use in unusual configurations. By default, if
26920 the uid of the caller of Exim cannot be looked up using <function>getpwuid()</function>, Exim
26921 gives up. The <option>unknown_login</option> option can be used to set a login name to be
26922 used in this circumstance. It is expanded, so values like <option>user$caller_uid</option>
26923 can be set. When <option>unknown_login</option> is used, the value of <option>unknown_username</option>
26924 is used for the user&#x2019;s real name (gecos field), unless this has been set by the
26925 <option>-F</option> option.
26926 </para>
26927 <para>
26928 <indexterm role="option">
26929 <primary>unknown_username</primary>
26930 </indexterm>
26931 </para>
26932 <informaltable frame="all">
26933 <tgroup cols="4" colsep="0" rowsep="0">
26934 <colspec colwidth="8*" align="left"/>
26935 <colspec colwidth="5*" align="center"/>
26936 <colspec colwidth="5*" align="center"/>
26937 <colspec colwidth="6*" align="right"/>
26938 <tbody>
26939 <row>
26940 <entry><option>unknown_username</option></entry>
26941 <entry>Use: <emphasis>main</emphasis></entry>
26942 <entry>Type: <emphasis>string</emphasis></entry>
26943 <entry>Default: <emphasis>unset</emphasis></entry>
26944 </row>
26945 </tbody>
26946 </tgroup>
26947 </informaltable>
26948 <para>
26949 See <option>unknown_login</option>.
26950 </para>
26951 <para>
26952 <indexterm role="option">
26953 <primary>untrusted_set_sender</primary>
26954 </indexterm>
26955 </para>
26956 <informaltable frame="all">
26957 <tgroup cols="4" colsep="0" rowsep="0">
26958 <colspec colwidth="8*" align="left"/>
26959 <colspec colwidth="5*" align="center"/>
26960 <colspec colwidth="5*" align="center"/>
26961 <colspec colwidth="6*" align="right"/>
26962 <tbody>
26963 <row>
26964 <entry><option>untrusted_set_sender</option></entry>
26965 <entry>Use: <emphasis>main</emphasis></entry>
26966 <entry>Type: <emphasis>address list</emphasis>&dagger;<emphasis></emphasis></entry>
26967 <entry>Default: <emphasis>unset</emphasis></entry>
26968 </row>
26969 </tbody>
26970 </tgroup>
26971 </informaltable>
26972 <para>
26973 <indexterm role="concept">
26974 <primary>trusted user</primary>
26975 </indexterm>
26976 <indexterm role="concept">
26977 <primary>sender</primary>
26978 <secondary>setting by untrusted user</secondary>
26979 </indexterm>
26980 <indexterm role="concept">
26981 <primary>untrusted user</primary>
26982 <secondary>setting sender</secondary>
26983 </indexterm>
26984 <indexterm role="concept">
26985 <primary>user</primary>
26986 <secondary>untrusted setting sender</secondary>
26987 </indexterm>
26988 <indexterm role="concept">
26989 <primary>envelope sender</primary>
26990 </indexterm>
26991 When an untrusted user submits a message to Exim using the standard input, Exim
26992 normally creates an envelope sender address from the user&#x2019;s login and the
26993 default qualification domain. Data from the <option>-f</option> option (for setting envelope
26994 senders on non-SMTP messages) or the SMTP MAIL command (if <option>-bs</option> or <option>-bS</option>
26995 is used) is ignored.
26996 </para>
26997 <para>
26998 However, untrusted users are permitted to set an empty envelope sender address,
26999 to declare that a message should never generate any bounces. For example:
27000 </para>
27001 <literallayout class="monospaced">
27002 exim -f '&lt;&gt;' user@domain.example
27003 </literallayout>
27004 <para>
27005 <indexterm role="concept">
27006 <primary><varname>$sender_ident</varname></primary>
27007 </indexterm>
27008 The <option>untrusted_set_sender</option> option allows you to permit untrusted users to set
27009 other envelope sender addresses in a controlled way. When it is set, untrusted
27010 users are allowed to set envelope sender addresses that match any of the
27011 patterns in the list. Like all address lists, the string is expanded. The
27012 identity of the user is in <varname>$sender_ident</varname>, so you can, for example, restrict
27013 users to setting senders that start with their login ids
27014 followed by a hyphen
27015 by a setting like this:
27016 </para>
27017 <literallayout class="monospaced">
27018 untrusted_set_sender = ^$sender_ident-
27019 </literallayout>
27020 <para>
27021 If you want to allow untrusted users to set envelope sender addresses without
27022 restriction, you can use
27023 </para>
27024 <literallayout class="monospaced">
27025 untrusted_set_sender = *
27026 </literallayout>
27027 <para>
27028 The <option>untrusted_set_sender</option> option applies to all forms of local input, but
27029 only to the setting of the envelope sender. It does not permit untrusted users
27030 to use the other options which trusted user can use to override message
27031 parameters. Furthermore, it does not stop Exim from removing an existing
27032 <emphasis>Sender:</emphasis> header in the message, or from adding a <emphasis>Sender:</emphasis> header if
27033 necessary. See <option>local_sender_retain</option> and <option>local_from_check</option> for ways of
27034 overriding these actions. The handling of the <emphasis>Sender:</emphasis> header is also
27035 described in section <xref linkend="SECTthesenhea"/>.
27036 </para>
27037 <para>
27038 The log line for a message&#x2019;s arrival shows the envelope sender following
27039 <quote>&lt;=</quote>. For local messages, the user&#x2019;s login always follows, after <quote>U=</quote>. In
27040 <option>-bp</option> displays, and in the Exim monitor, if an untrusted user sets an
27041 envelope sender address, the user&#x2019;s login is shown in parentheses after the
27042 sender address.
27043 </para>
27044 <para>
27045 <indexterm role="option">
27046 <primary>uucp_from_pattern</primary>
27047 </indexterm>
27048 </para>
27049 <informaltable frame="all">
27050 <tgroup cols="4" colsep="0" rowsep="0">
27051 <colspec colwidth="8*" align="left"/>
27052 <colspec colwidth="5*" align="center"/>
27053 <colspec colwidth="5*" align="center"/>
27054 <colspec colwidth="6*" align="right"/>
27055 <tbody>
27056 <row>
27057 <entry><option>uucp_from_pattern</option></entry>
27058 <entry>Use: <emphasis>main</emphasis></entry>
27059 <entry>Type: <emphasis>string</emphasis></entry>
27060 <entry>Default: <emphasis>see below</emphasis></entry>
27061 </row>
27062 </tbody>
27063 </tgroup>
27064 </informaltable>
27065 <para>
27066 <indexterm role="concept">
27067 <primary><quote>From</quote> line</primary>
27068 </indexterm>
27069 <indexterm role="concept">
27070 <primary>UUCP</primary>
27071 <secondary><quote>From</quote> line</secondary>
27072 </indexterm>
27073 Some applications that pass messages to an MTA via a command line interface use
27074 an initial line starting with <quote>From&nbsp;</quote> to pass the envelope sender. In
27075 particular, this is used by UUCP software. Exim recognizes such a line by means
27076 of a regular expression that is set in <option>uucp_from_pattern</option>. When the pattern
27077 matches, the sender address is constructed by expanding the contents of
27078 <option>uucp_from_sender</option>, provided that the caller of Exim is a trusted user. The
27079 default pattern recognizes lines in the following two forms:
27080 </para>
27081 <literallayout class="monospaced">
27082 From ph10 Fri Jan  5 12:35 GMT 1996
27083 From ph10 Fri, 7 Jan 97 14:00:00 GMT
27084 </literallayout>
27085 <para>
27086 The pattern can be seen by running
27087 </para>
27088 <literallayout class="monospaced">
27089 exim -bP uucp_from_pattern
27090 </literallayout>
27091 <para>
27092 It checks only up to the hours and minutes, and allows for a 2-digit or 4-digit
27093 year in the second case. The first word after <quote>From&nbsp;</quote> is matched in the
27094 regular expression by a parenthesized subpattern. The default value for
27095 <option>uucp_from_sender</option> is <quote>$1</quote>, which therefore just uses this first word
27096 (<quote>ph10</quote> in the example above) as the message&#x2019;s sender. See also
27097 <option>ignore_fromline_hosts</option>.
27098 </para>
27099 <para>
27100 <indexterm role="option">
27101 <primary>uucp_from_sender</primary>
27102 </indexterm>
27103 </para>
27104 <informaltable frame="all">
27105 <tgroup cols="4" colsep="0" rowsep="0">
27106 <colspec colwidth="8*" align="left"/>
27107 <colspec colwidth="5*" align="center"/>
27108 <colspec colwidth="5*" align="center"/>
27109 <colspec colwidth="6*" align="right"/>
27110 <tbody>
27111 <row>
27112 <entry><option>uucp_from_sender</option></entry>
27113 <entry>Use: <emphasis>main</emphasis></entry>
27114 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27115 <entry>Default: <emphasis><literal>$1</literal></emphasis></entry>
27116 </row>
27117 </tbody>
27118 </tgroup>
27119 </informaltable>
27120 <para>
27121 See <option>uucp_from_pattern</option> above.
27122 </para>
27123 <para>
27124 <indexterm role="option">
27125 <primary>warn_message_file</primary>
27126 </indexterm>
27127 </para>
27128 <informaltable frame="all">
27129 <tgroup cols="4" colsep="0" rowsep="0">
27130 <colspec colwidth="8*" align="left"/>
27131 <colspec colwidth="5*" align="center"/>
27132 <colspec colwidth="5*" align="center"/>
27133 <colspec colwidth="6*" align="right"/>
27134 <tbody>
27135 <row>
27136 <entry><option>warn_message_file</option></entry>
27137 <entry>Use: <emphasis>main</emphasis></entry>
27138 <entry>Type: <emphasis>string</emphasis></entry>
27139 <entry>Default: <emphasis>unset</emphasis></entry>
27140 </row>
27141 </tbody>
27142 </tgroup>
27143 </informaltable>
27144 <para>
27145 <indexterm role="concept">
27146 <primary>warning of delay</primary>
27147 <secondary>customizing the message</secondary>
27148 </indexterm>
27149 <indexterm role="concept">
27150 <primary>customizing</primary>
27151 <secondary>warning message</secondary>
27152 </indexterm>
27153 This option defines a template file containing paragraphs of text to be used
27154 for constructing the warning message which is sent by Exim when a message has
27155 been on the queue for a specified amount of time, as specified by
27156 <option>delay_warning</option>. Details of the file&#x2019;s contents are given in chapter
27157 <xref linkend="CHAPemsgcust"/>. See also <option>bounce_message_file</option>.
27158 </para>
27159 <para>
27160 <indexterm role="option">
27161 <primary>write_rejectlog</primary>
27162 </indexterm>
27163 </para>
27164 <informaltable frame="all">
27165 <tgroup cols="4" colsep="0" rowsep="0">
27166 <colspec colwidth="8*" align="left"/>
27167 <colspec colwidth="5*" align="center"/>
27168 <colspec colwidth="5*" align="center"/>
27169 <colspec colwidth="6*" align="right"/>
27170 <tbody>
27171 <row>
27172 <entry><option>write_rejectlog</option></entry>
27173 <entry>Use: <emphasis>main</emphasis></entry>
27174 <entry>Type: <emphasis>boolean</emphasis></entry>
27175 <entry>Default: <emphasis>true</emphasis></entry>
27176 </row>
27177 </tbody>
27178 </tgroup>
27179 </informaltable>
27180 <para>
27181 <indexterm role="concept">
27182 <primary>reject log</primary>
27183 <secondary>disabling</secondary>
27184 </indexterm>
27185 If this option is set false, Exim no longer writes anything to the reject log.
27186 See chapter <xref linkend="CHAPlog"/> for details of what Exim writes to its logs.
27187 <indexterm role="concept" startref="IIDconfima" class="endofrange"/>
27188 <indexterm role="concept" startref="IIDmaiconf" class="endofrange"/>
27189 </para>
27190 </section>
27191 </chapter>
27192
27193 <chapter id="CHAProutergeneric">
27194 <title>Generic options for routers</title>
27195 <para>
27196 <indexterm role="concept" id="IIDgenoprou1" class="startofrange">
27197 <primary>options</primary>
27198 <secondary>generic; for routers</secondary>
27199 </indexterm>
27200 <indexterm role="concept" id="IIDgenoprou2" class="startofrange">
27201 <primary>generic options</primary>
27202 <secondary>router</secondary>
27203 </indexterm>
27204 This chapter describes the generic options that apply to all routers.
27205 Those that are preconditions are marked with &Dagger; in the <quote>use</quote> field.
27206 </para>
27207 <para>
27208 For a general description of how a router operates, see sections
27209 <xref linkend="SECTrunindrou"/> and <xref linkend="SECTrouprecon"/>. The latter specifies the order in
27210 which the preconditions are tested. The order of expansion of the options that
27211 provide data for a transport is: <option>errors_to</option>, <option>headers_add</option>,
27212 <option>headers_remove</option>, <option>transport</option>.
27213 </para>
27214 <para>
27215 <indexterm role="option">
27216 <primary>address_data</primary>
27217 </indexterm>
27218 </para>
27219 <informaltable frame="all">
27220 <tgroup cols="4" colsep="0" rowsep="0">
27221 <colspec colwidth="8*" align="left"/>
27222 <colspec colwidth="5*" align="center"/>
27223 <colspec colwidth="5*" align="center"/>
27224 <colspec colwidth="6*" align="right"/>
27225 <tbody>
27226 <row>
27227 <entry><option>address_data</option></entry>
27228 <entry>Use: <emphasis>routers</emphasis></entry>
27229 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27230 <entry>Default: <emphasis>unset</emphasis></entry>
27231 </row>
27232 </tbody>
27233 </tgroup>
27234 </informaltable>
27235 <para>
27236 <indexterm role="concept">
27237 <primary>router</primary>
27238 <secondary>data attached to address</secondary>
27239 </indexterm>
27240 The string is expanded just before the router is run, that is, after all the
27241 precondition tests have succeeded. If the expansion is forced to fail, the
27242 router declines, the value of <option>address_data</option> remains unchanged, and the
27243 <option>more</option> option controls what happens next. Other expansion failures cause
27244 delivery of the address to be deferred.
27245 </para>
27246 <para>
27247 <indexterm role="concept">
27248 <primary><varname>$address_data</varname></primary>
27249 </indexterm>
27250 When the expansion succeeds, the value is retained with the address, and can be
27251 accessed using the variable <varname>$address_data</varname> in the current router, subsequent
27252 routers, and the eventual transport.
27253 </para>
27254 <para>
27255 <emphasis role="bold">Warning</emphasis>: If the current or any subsequent router is a <command>redirect</command> router
27256 that runs a user&#x2019;s filter file, the contents of <varname>$address_data</varname> are accessible
27257 in the filter. This is not normally a problem, because such data is usually
27258 either not confidential or it <quote>belongs</quote> to the current user, but if you do
27259 put confidential data into <varname>$address_data</varname> you need to remember this point.
27260 </para>
27261 <para>
27262 Even if the router declines or passes, the value of <varname>$address_data</varname> remains
27263 with the address, though it can be changed by another <option>address_data</option> setting
27264 on a subsequent router. If a router generates child addresses, the value of
27265 <varname>$address_data</varname> propagates to them. This also applies to the special kind of
27266 <quote>child</quote> that is generated by a router with the <option>unseen</option> option.
27267 </para>
27268 <para>
27269 The idea of <option>address_data</option> is that you can use it to look up a lot of data
27270 for the address once, and then pick out parts of the data later. For example,
27271 you could use a single LDAP lookup to return a string of the form
27272 </para>
27273 <literallayout class="monospaced">
27274 uid=1234 gid=5678 mailbox=/mail/xyz forward=/home/xyz/.forward
27275 </literallayout>
27276 <para>
27277 In the transport you could pick out the mailbox by a setting such as
27278 </para>
27279 <literallayout class="monospaced">
27280 file = ${extract{mailbox}{$address_data}}
27281 </literallayout>
27282 <para>
27283 This makes the configuration file less messy, and also reduces the number of
27284 lookups (though Exim does cache lookups).
27285 </para>
27286 <para>
27287 The <option>address_data</option> facility is also useful as a means of passing information
27288 from one router to another, and from a router to a transport. In addition, if
27289 </para>
27290 <para>
27291 <indexterm role="concept">
27292 <primary><varname>$sender_address_data</varname></primary>
27293 </indexterm>
27294 <indexterm role="concept">
27295 <primary><varname>$address_data</varname></primary>
27296 </indexterm>
27297 When <varname>$address_data</varname> is set by a router when verifying a recipient address
27298 from an ACL, it remains available for use in the rest of the ACL statement.
27299 After verifying a sender, the value is transferred to <varname>$sender_address_data</varname>.
27300 </para>
27301 <para>
27302 <indexterm role="option">
27303 <primary>address_test</primary>
27304 </indexterm>
27305 </para>
27306 <informaltable frame="all">
27307 <tgroup cols="4" colsep="0" rowsep="0">
27308 <colspec colwidth="8*" align="left"/>
27309 <colspec colwidth="5*" align="center"/>
27310 <colspec colwidth="5*" align="center"/>
27311 <colspec colwidth="6*" align="right"/>
27312 <tbody>
27313 <row>
27314 <entry><option>address_test</option></entry>
27315 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
27316 <entry>Type: <emphasis>boolean</emphasis></entry>
27317 <entry>Default: <emphasis>true</emphasis></entry>
27318 </row>
27319 </tbody>
27320 </tgroup>
27321 </informaltable>
27322 <para>
27323 <indexterm role="concept">
27324 <primary><option>-bt</option> option</primary>
27325 </indexterm>
27326 <indexterm role="concept">
27327 <primary>router</primary>
27328 <secondary>skipping when address testing</secondary>
27329 </indexterm>
27330 If this option is set false, the router is skipped when routing is being tested
27331 by means of the <option>-bt</option> command line option. This can be a convenience when
27332 your first router sends messages to an external scanner, because it saves you
27333 having to set the <quote>already scanned</quote> indicator when testing real address
27334 routing.
27335 </para>
27336 <para>
27337 <indexterm role="option">
27338 <primary>cannot_route_message</primary>
27339 </indexterm>
27340 </para>
27341 <informaltable frame="all">
27342 <tgroup cols="4" colsep="0" rowsep="0">
27343 <colspec colwidth="8*" align="left"/>
27344 <colspec colwidth="5*" align="center"/>
27345 <colspec colwidth="5*" align="center"/>
27346 <colspec colwidth="6*" align="right"/>
27347 <tbody>
27348 <row>
27349 <entry><option>cannot_route_message</option></entry>
27350 <entry>Use: <emphasis>routers</emphasis></entry>
27351 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27352 <entry>Default: <emphasis>unset</emphasis></entry>
27353 </row>
27354 </tbody>
27355 </tgroup>
27356 </informaltable>
27357 <para>
27358 <indexterm role="concept">
27359 <primary>router</primary>
27360 <secondary>customizing <quote>cannot route</quote> message</secondary>
27361 </indexterm>
27362 <indexterm role="concept">
27363 <primary>customizing</primary>
27364 <secondary><quote>cannot route</quote> message</secondary>
27365 </indexterm>
27366 This option specifies a text message that is used when an address cannot be
27367 routed because Exim has run out of routers. The default message is
27368 <quote>Unrouteable address</quote>. This option is useful only on routers that have
27369 <option>more</option> set false, or on the very last router in a configuration, because the
27370 value that is used is taken from the last router that is considered. This
27371 includes a router that is skipped because its preconditions are not met, as
27372 well as a router that declines. For example, using the default configuration,
27373 you could put:
27374 </para>
27375 <literallayout class="monospaced">
27376 cannot_route_message = Remote domain not found in DNS
27377 </literallayout>
27378 <para>
27379 on the first router, which is a <command>dnslookup</command> router with <option>more</option> set false,
27380 and
27381 </para>
27382 <literallayout class="monospaced">
27383 cannot_route_message = Unknown local user
27384 </literallayout>
27385 <para>
27386 on the final router that checks for local users. If string expansion fails for
27387 this option, the default message is used. Unless the expansion failure was
27388 explicitly forced, a message about the failure is written to the main and panic
27389 logs, in addition to the normal message about the routing failure.
27390 </para>
27391 <para>
27392 <indexterm role="option">
27393 <primary>caseful_local_part</primary>
27394 </indexterm>
27395 </para>
27396 <informaltable frame="all">
27397 <tgroup cols="4" colsep="0" rowsep="0">
27398 <colspec colwidth="8*" align="left"/>
27399 <colspec colwidth="5*" align="center"/>
27400 <colspec colwidth="5*" align="center"/>
27401 <colspec colwidth="6*" align="right"/>
27402 <tbody>
27403 <row>
27404 <entry><option>caseful_local_part</option></entry>
27405 <entry>Use: <emphasis>routers</emphasis></entry>
27406 <entry>Type: <emphasis>boolean</emphasis></entry>
27407 <entry>Default: <emphasis>false</emphasis></entry>
27408 </row>
27409 </tbody>
27410 </tgroup>
27411 </informaltable>
27412 <para>
27413 <indexterm role="concept">
27414 <primary>case of local parts</primary>
27415 </indexterm>
27416 <indexterm role="concept">
27417 <primary>router</primary>
27418 <secondary>case of local parts</secondary>
27419 </indexterm>
27420 By default, routers handle the local parts of addresses in a case-insensitive
27421 manner, though the actual case is preserved for transmission with the message.
27422 If you want the case of letters to be significant in a router, you must set
27423 this option true. For individual router options that contain address or local
27424 part lists (for example, <option>local_parts</option>), case-sensitive matching can be
27425 turned on by <quote>+caseful</quote> as a list item. See section <xref linkend="SECTcasletadd"/> for
27426 more details.
27427 </para>
27428 <para>
27429 <indexterm role="concept">
27430 <primary><varname>$local_part</varname></primary>
27431 </indexterm>
27432 <indexterm role="concept">
27433 <primary><varname>$original_local_part</varname></primary>
27434 </indexterm>
27435 <indexterm role="concept">
27436 <primary><varname>$parent_local_part</varname></primary>
27437 </indexterm>
27438 The value of the <varname>$local_part</varname> variable is forced to lower case while a
27439 router is running unless <option>caseful_local_part</option> is set. When a router assigns
27440 an address to a transport, the value of <varname>$local_part</varname> when the transport runs
27441 is the same as it was in the router. Similarly, when a router generates child
27442 addresses by aliasing or forwarding, the values of <varname>$original_local_part</varname>
27443 and <varname>$parent_local_part</varname> are those that were used by the redirecting router.
27444 </para>
27445 <para>
27446 This option applies to the processing of an address by a router. When a
27447 recipient address is being processed in an ACL, there is a separate <option>control</option>
27448 modifier that can be used to specify case-sensitive processing within the ACL
27449 (see section <xref linkend="SECTcontrols"/>).
27450 </para>
27451 <para>
27452 <indexterm role="option">
27453 <primary>check_local_user</primary>
27454 </indexterm>
27455 </para>
27456 <informaltable frame="all">
27457 <tgroup cols="4" colsep="0" rowsep="0">
27458 <colspec colwidth="8*" align="left"/>
27459 <colspec colwidth="5*" align="center"/>
27460 <colspec colwidth="5*" align="center"/>
27461 <colspec colwidth="6*" align="right"/>
27462 <tbody>
27463 <row>
27464 <entry><option>check_local_user</option></entry>
27465 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
27466 <entry>Type: <emphasis>boolean</emphasis></entry>
27467 <entry>Default: <emphasis>false</emphasis></entry>
27468 </row>
27469 </tbody>
27470 </tgroup>
27471 </informaltable>
27472 <para>
27473 <indexterm role="concept">
27474 <primary>local user</primary>
27475 <secondary>checking in router</secondary>
27476 </indexterm>
27477 <indexterm role="concept">
27478 <primary>router</primary>
27479 <secondary>checking for local user</secondary>
27480 </indexterm>
27481 <indexterm role="concept">
27482 <primary><filename>/etc/passwd</filename></primary>
27483 </indexterm>
27484 <indexterm role="concept">
27485 <primary><varname>$home</varname></primary>
27486 </indexterm>
27487 When this option is true, Exim checks that the local part of the recipient
27488 address (with affixes removed if relevant) is the name of an account on the
27489 local system. The check is done by calling the <function>getpwnam()</function> function rather
27490 than trying to read <filename>/etc/passwd</filename> directly. This means that other methods of
27491 holding password data (such as NIS) are supported. If the local part is a local
27492 user, <varname>$home</varname> is set from the password data, and can be tested in other
27493 preconditions that are evaluated after this one (the order of evaluation is
27494 given in section <xref linkend="SECTrouprecon"/>). However, the value of <varname>$home</varname> can be
27495 overridden by <option>router_home_directory</option>. If the local part is not a local user,
27496 the router is skipped.
27497 </para>
27498 <para>
27499 If you want to check that the local part is either the name of a local user
27500 or matches something else, you cannot combine <option>check_local_user</option> with a
27501 setting of <option>local_parts</option>, because that specifies the logical <emphasis>and</emphasis> of the
27502 two conditions. However, you can use a <command>passwd</command> lookup in a <option>local_parts</option>
27503 setting to achieve this. For example:
27504 </para>
27505 <literallayout class="monospaced">
27506 local_parts = passwd;$local_part : lsearch;/etc/other/users
27507 </literallayout>
27508 <para>
27509 Note, however, that the side effects of <option>check_local_user</option> (such as setting
27510 up a home directory) do not occur when a <command>passwd</command> lookup is used in a
27511 <option>local_parts</option> (or any other) precondition.
27512 </para>
27513 <para>
27514 <indexterm role="option">
27515 <primary>condition</primary>
27516 </indexterm>
27517 </para>
27518 <informaltable frame="all">
27519 <tgroup cols="4" colsep="0" rowsep="0">
27520 <colspec colwidth="8*" align="left"/>
27521 <colspec colwidth="5*" align="center"/>
27522 <colspec colwidth="5*" align="center"/>
27523 <colspec colwidth="6*" align="right"/>
27524 <tbody>
27525 <row>
27526 <entry><option>condition</option></entry>
27527 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
27528 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27529 <entry>Default: <emphasis>unset</emphasis></entry>
27530 </row>
27531 </tbody>
27532 </tgroup>
27533 </informaltable>
27534 <para>
27535 <indexterm role="concept">
27536 <primary>router</primary>
27537 <secondary>customized precondition</secondary>
27538 </indexterm>
27539 This option specifies a general precondition test that has to succeed for the
27540 router to be called. The <option>condition</option> option is the last precondition to be
27541 evaluated (see section <xref linkend="SECTrouprecon"/>). The string is expanded, and if the
27542 result is a forced failure, or an empty string, or one of the strings <quote>0</quote> or
27543 <quote>no</quote> or <quote>false</quote> (checked without regard to the case of the letters), the
27544 router is skipped, and the address is offered to the next one.
27545 </para>
27546 <para>
27547 If the result is any other value, the router is run (as this is the last
27548 precondition to be evaluated, all the other preconditions must be true).
27549 </para>
27550 <para>
27551 The <option>condition</option> option provides a means of applying custom conditions to the
27552 running of routers. Note that in the case of a simple conditional expansion,
27553 the default expansion values are exactly what is wanted. For example:
27554 </para>
27555 <literallayout class="monospaced">
27556 condition = ${if &gt;{$message_age}{600}}
27557 </literallayout>
27558 <para>
27559 Because of the default behaviour of the string expansion, this is equivalent to
27560 </para>
27561 <literallayout class="monospaced">
27562 condition = ${if &gt;{$message_age}{600}{true}{}}
27563 </literallayout>
27564 <para>
27565 If the expansion fails (other than forced failure) delivery is deferred. Some
27566 of the other precondition options are common special cases that could in fact
27567 be specified using <option>condition</option>.
27568 </para>
27569 <para>
27570 <indexterm role="option">
27571 <primary>debug_print</primary>
27572 </indexterm>
27573 </para>
27574 <informaltable frame="all">
27575 <tgroup cols="4" colsep="0" rowsep="0">
27576 <colspec colwidth="8*" align="left"/>
27577 <colspec colwidth="5*" align="center"/>
27578 <colspec colwidth="5*" align="center"/>
27579 <colspec colwidth="6*" align="right"/>
27580 <tbody>
27581 <row>
27582 <entry><option>debug_print</option></entry>
27583 <entry>Use: <emphasis>routers</emphasis></entry>
27584 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27585 <entry>Default: <emphasis>unset</emphasis></entry>
27586 </row>
27587 </tbody>
27588 </tgroup>
27589 </informaltable>
27590 <para>
27591 <indexterm role="concept">
27592 <primary>testing</primary>
27593 <secondary>variables in drivers</secondary>
27594 </indexterm>
27595 If this option is set and debugging is enabled (see the <option>-d</option> command line
27596 option), the string is expanded and included in the debugging output.
27597 If expansion of the string fails, the error message is written to the debugging
27598 output, and Exim carries on processing.
27599 This option is provided to help with checking out the values of variables and
27600 so on when debugging router configurations. For example, if a <option>condition</option>
27601 option appears not to be working, <option>debug_print</option> can be used to output the
27602 variables it references. The output happens after checks for <option>domains</option>,
27603 <option>local_parts</option>, and <option>check_local_user</option> but before any other preconditions
27604 are tested. A newline is added to the text if it does not end with one.
27605 </para>
27606 <para>
27607 <indexterm role="option">
27608 <primary>disable_logging</primary>
27609 </indexterm>
27610 </para>
27611 <informaltable frame="all">
27612 <tgroup cols="4" colsep="0" rowsep="0">
27613 <colspec colwidth="8*" align="left"/>
27614 <colspec colwidth="5*" align="center"/>
27615 <colspec colwidth="5*" align="center"/>
27616 <colspec colwidth="6*" align="right"/>
27617 <tbody>
27618 <row>
27619 <entry><option>disable_logging</option></entry>
27620 <entry>Use: <emphasis>routers</emphasis></entry>
27621 <entry>Type: <emphasis>boolean</emphasis></entry>
27622 <entry>Default: <emphasis>false</emphasis></entry>
27623 </row>
27624 </tbody>
27625 </tgroup>
27626 </informaltable>
27627 <para>
27628 If this option is set true, nothing is logged for any routing errors
27629 or for any deliveries caused by this router. You should not set this option
27630 unless you really, really know what you are doing. See also the generic
27631 transport option of the same name.
27632 </para>
27633 <para>
27634 <indexterm role="option">
27635 <primary>domains</primary>
27636 </indexterm>
27637 </para>
27638 <informaltable frame="all">
27639 <tgroup cols="4" colsep="0" rowsep="0">
27640 <colspec colwidth="8*" align="left"/>
27641 <colspec colwidth="5*" align="center"/>
27642 <colspec colwidth="5*" align="center"/>
27643 <colspec colwidth="6*" align="right"/>
27644 <tbody>
27645 <row>
27646 <entry><option>domains</option></entry>
27647 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
27648 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
27649 <entry>Default: <emphasis>unset</emphasis></entry>
27650 </row>
27651 </tbody>
27652 </tgroup>
27653 </informaltable>
27654 <para>
27655 <indexterm role="concept">
27656 <primary>router</primary>
27657 <secondary>restricting to specific domains</secondary>
27658 </indexterm>
27659 <indexterm role="concept">
27660 <primary><varname>$domain_data</varname></primary>
27661 </indexterm>
27662 If this option is set, the router is skipped unless the current domain matches
27663 the list. If the match is achieved by means of a file lookup, the data that the
27664 lookup returned for the domain is placed in <varname>$domain_data</varname> for use in string
27665 expansions of the driver&#x2019;s private options. See section <xref linkend="SECTrouprecon"/> for
27666 a list of the order in which preconditions are evaluated.
27667 </para>
27668 <para>
27669 <indexterm role="option">
27670 <primary>driver</primary>
27671 </indexterm>
27672 </para>
27673 <informaltable frame="all">
27674 <tgroup cols="4" colsep="0" rowsep="0">
27675 <colspec colwidth="8*" align="left"/>
27676 <colspec colwidth="5*" align="center"/>
27677 <colspec colwidth="5*" align="center"/>
27678 <colspec colwidth="6*" align="right"/>
27679 <tbody>
27680 <row>
27681 <entry><option>driver</option></entry>
27682 <entry>Use: <emphasis>routers</emphasis></entry>
27683 <entry>Type: <emphasis>string</emphasis></entry>
27684 <entry>Default: <emphasis>unset</emphasis></entry>
27685 </row>
27686 </tbody>
27687 </tgroup>
27688 </informaltable>
27689 <para>
27690 This option must always be set. It specifies which of the available routers is
27691 to be used.
27692 </para>
27693 <para>
27694 <indexterm role="option">
27695 <primary>errors_to</primary>
27696 </indexterm>
27697 </para>
27698 <informaltable frame="all">
27699 <tgroup cols="4" colsep="0" rowsep="0">
27700 <colspec colwidth="8*" align="left"/>
27701 <colspec colwidth="5*" align="center"/>
27702 <colspec colwidth="5*" align="center"/>
27703 <colspec colwidth="6*" align="right"/>
27704 <tbody>
27705 <row>
27706 <entry><option>errors_to</option></entry>
27707 <entry>Use: <emphasis>routers</emphasis></entry>
27708 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27709 <entry>Default: <emphasis>unset</emphasis></entry>
27710 </row>
27711 </tbody>
27712 </tgroup>
27713 </informaltable>
27714 <para>
27715 <indexterm role="concept">
27716 <primary>envelope sender</primary>
27717 </indexterm>
27718 <indexterm role="concept">
27719 <primary>router</primary>
27720 <secondary>changing address for errors</secondary>
27721 </indexterm>
27722 If a router successfully handles an address, it may assign the address to a
27723 transport for delivery or it may generate child addresses. In both cases, if
27724 there is a delivery problem during later processing, the resulting bounce
27725 message is sent to the address that results from expanding this string,
27726 provided that the address verifies successfully. The <option>errors_to</option> option is
27727 expanded before <option>headers_add</option>, <option>headers_remove</option>, and <option>transport</option>.
27728 </para>
27729 <para>
27730 The <option>errors_to</option> setting associated with an address can be overridden if it
27731 subsequently passes through other routers that have their own <option>errors_to</option>
27732 settings, or if the message is delivered by a transport with a <option>return_path</option>
27733 setting.
27734 </para>
27735 <para>
27736 If <option>errors_to</option> is unset, or the expansion is forced to fail, or the result of
27737 the expansion fails to verify, the errors address associated with the incoming
27738 address is used. At top level, this is the envelope sender. A non-forced
27739 expansion failure causes delivery to be deferred.
27740 </para>
27741 <para>
27742 If an address for which <option>errors_to</option> has been set ends up being delivered over
27743 SMTP, the envelope sender for that delivery is the <option>errors_to</option> value, so that
27744 any bounces that are generated by other MTAs on the delivery route are also
27745 sent there. You can set <option>errors_to</option> to the empty string by either of these
27746 settings:
27747 </para>
27748 <literallayout class="monospaced">
27749 errors_to =
27750 errors_to = ""
27751 </literallayout>
27752 <para>
27753 An expansion item that yields an empty string has the same effect. If you do
27754 this, a locally detected delivery error for addresses processed by this router
27755 no longer gives rise to a bounce message; the error is discarded. If the
27756 address is delivered to a remote host, the return path is set to <literal>&lt;&gt;</literal>, unless
27757 overridden by the <option>return_path</option> option on the transport.
27758 </para>
27759 <para>
27760 <indexterm role="concept">
27761 <primary><varname>$address_data</varname></primary>
27762 </indexterm>
27763 If for some reason you want to discard local errors, but use a non-empty
27764 MAIL command for remote delivery, you can preserve the original return
27765 path in <varname>$address_data</varname> in the router, and reinstate it in the transport by
27766 setting <option>return_path</option>.
27767 </para>
27768 <para>
27769 The most common use of <option>errors_to</option> is to direct mailing list bounces to the
27770 manager of the list, as described in section <xref linkend="SECTmailinglists"/>, or to
27771 implement VERP (Variable Envelope Return Paths) (see section <xref linkend="SECTverp"/>).
27772 </para>
27773 <para>
27774 <indexterm role="option">
27775 <primary>expn</primary>
27776 </indexterm>
27777 </para>
27778 <informaltable frame="all">
27779 <tgroup cols="4" colsep="0" rowsep="0">
27780 <colspec colwidth="8*" align="left"/>
27781 <colspec colwidth="5*" align="center"/>
27782 <colspec colwidth="5*" align="center"/>
27783 <colspec colwidth="6*" align="right"/>
27784 <tbody>
27785 <row>
27786 <entry><option>expn</option></entry>
27787 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
27788 <entry>Type: <emphasis>boolean</emphasis></entry>
27789 <entry>Default: <emphasis>true</emphasis></entry>
27790 </row>
27791 </tbody>
27792 </tgroup>
27793 </informaltable>
27794 <para>
27795 <indexterm role="concept">
27796 <primary>address</primary>
27797 <secondary>testing</secondary>
27798 </indexterm>
27799 <indexterm role="concept">
27800 <primary>testing</primary>
27801 <secondary>addresses</secondary>
27802 </indexterm>
27803 <indexterm role="concept">
27804 <primary>EXPN</primary>
27805 <secondary>router skipping</secondary>
27806 </indexterm>
27807 <indexterm role="concept">
27808 <primary>router</primary>
27809 <secondary>skipping for EXPN</secondary>
27810 </indexterm>
27811 If this option is turned off, the router is skipped when testing an address
27812 as a result of processing an SMTP EXPN command. You might, for example,
27813 want to turn it off on a router for users&#x2019; <filename>.forward</filename> files, while leaving it
27814 on for the system alias file.
27815 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
27816 are evaluated.
27817 </para>
27818 <para>
27819 The use of the SMTP EXPN command is controlled by an ACL (see chapter
27820 <xref linkend="CHAPACL"/>). When Exim is running an EXPN command, it is similar to testing
27821 an address with <option>-bt</option>. Compare VRFY, whose counterpart is <option>-bv</option>.
27822 </para>
27823 <para>
27824 <indexterm role="option">
27825 <primary>fail_verify</primary>
27826 </indexterm>
27827 </para>
27828 <informaltable frame="all">
27829 <tgroup cols="4" colsep="0" rowsep="0">
27830 <colspec colwidth="8*" align="left"/>
27831 <colspec colwidth="5*" align="center"/>
27832 <colspec colwidth="5*" align="center"/>
27833 <colspec colwidth="6*" align="right"/>
27834 <tbody>
27835 <row>
27836 <entry><option>fail_verify</option></entry>
27837 <entry>Use: <emphasis>routers</emphasis></entry>
27838 <entry>Type: <emphasis>boolean</emphasis></entry>
27839 <entry>Default: <emphasis>false</emphasis></entry>
27840 </row>
27841 </tbody>
27842 </tgroup>
27843 </informaltable>
27844 <para>
27845 <indexterm role="concept">
27846 <primary>router</primary>
27847 <secondary>forcing verification failure</secondary>
27848 </indexterm>
27849 Setting this option has the effect of setting both <option>fail_verify_sender</option> and
27850 <option>fail_verify_recipient</option> to the same value.
27851 </para>
27852 <para>
27853 <indexterm role="option">
27854 <primary>fail_verify_recipient</primary>
27855 </indexterm>
27856 </para>
27857 <informaltable frame="all">
27858 <tgroup cols="4" colsep="0" rowsep="0">
27859 <colspec colwidth="8*" align="left"/>
27860 <colspec colwidth="5*" align="center"/>
27861 <colspec colwidth="5*" align="center"/>
27862 <colspec colwidth="6*" align="right"/>
27863 <tbody>
27864 <row>
27865 <entry><option>fail_verify_recipient</option></entry>
27866 <entry>Use: <emphasis>routers</emphasis></entry>
27867 <entry>Type: <emphasis>boolean</emphasis></entry>
27868 <entry>Default: <emphasis>false</emphasis></entry>
27869 </row>
27870 </tbody>
27871 </tgroup>
27872 </informaltable>
27873 <para>
27874 If this option is true and an address is accepted by this router when
27875 verifying a recipient, verification fails.
27876 </para>
27877 <para>
27878 <indexterm role="option">
27879 <primary>fail_verify_sender</primary>
27880 </indexterm>
27881 </para>
27882 <informaltable frame="all">
27883 <tgroup cols="4" colsep="0" rowsep="0">
27884 <colspec colwidth="8*" align="left"/>
27885 <colspec colwidth="5*" align="center"/>
27886 <colspec colwidth="5*" align="center"/>
27887 <colspec colwidth="6*" align="right"/>
27888 <tbody>
27889 <row>
27890 <entry><option>fail_verify_sender</option></entry>
27891 <entry>Use: <emphasis>routers</emphasis></entry>
27892 <entry>Type: <emphasis>boolean</emphasis></entry>
27893 <entry>Default: <emphasis>false</emphasis></entry>
27894 </row>
27895 </tbody>
27896 </tgroup>
27897 </informaltable>
27898 <para>
27899 If this option is true and an address is accepted by this router when
27900 verifying a sender, verification fails.
27901 </para>
27902 <para>
27903 <indexterm role="option">
27904 <primary>fallback_hosts</primary>
27905 </indexterm>
27906 </para>
27907 <informaltable frame="all">
27908 <tgroup cols="4" colsep="0" rowsep="0">
27909 <colspec colwidth="8*" align="left"/>
27910 <colspec colwidth="5*" align="center"/>
27911 <colspec colwidth="5*" align="center"/>
27912 <colspec colwidth="6*" align="right"/>
27913 <tbody>
27914 <row>
27915 <entry><option>fallback_hosts</option></entry>
27916 <entry>Use: <emphasis>routers</emphasis></entry>
27917 <entry>Type: <emphasis>string list</emphasis></entry>
27918 <entry>Default: <emphasis>unset</emphasis></entry>
27919 </row>
27920 </tbody>
27921 </tgroup>
27922 </informaltable>
27923 <para>
27924 <indexterm role="concept">
27925 <primary>router</primary>
27926 <secondary>fallback hosts</secondary>
27927 </indexterm>
27928 <indexterm role="concept">
27929 <primary>fallback</primary>
27930 <secondary>hosts specified on router</secondary>
27931 </indexterm>
27932 String expansion is not applied to this option. The argument must be a
27933 colon-separated list of host names or IP addresses. The list separator can be
27934 changed (see section <xref linkend="SECTlistconstruct"/>), and a port can be specified with
27935 each name or address. In fact, the format of each item is exactly the same as
27936 defined for the list of hosts in a <command>manualroute</command> router (see section
27937 <xref linkend="SECTformatonehostitem"/>).
27938 </para>
27939 <para>
27940 If a router queues an address for a remote transport, this host list is
27941 associated with the address, and used instead of the transport&#x2019;s fallback host
27942 list. If <option>hosts_randomize</option> is set on the transport, the order of the list is
27943 randomized for each use. See the <option>fallback_hosts</option> option of the <command>smtp</command>
27944 transport for further details.
27945 </para>
27946 <para>
27947 <indexterm role="option">
27948 <primary>group</primary>
27949 </indexterm>
27950 </para>
27951 <informaltable frame="all">
27952 <tgroup cols="4" colsep="0" rowsep="0">
27953 <colspec colwidth="8*" align="left"/>
27954 <colspec colwidth="5*" align="center"/>
27955 <colspec colwidth="5*" align="center"/>
27956 <colspec colwidth="6*" align="right"/>
27957 <tbody>
27958 <row>
27959 <entry><option>group</option></entry>
27960 <entry>Use: <emphasis>routers</emphasis></entry>
27961 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27962 <entry>Default: <emphasis>see below</emphasis></entry>
27963 </row>
27964 </tbody>
27965 </tgroup>
27966 </informaltable>
27967 <para>
27968 <indexterm role="concept">
27969 <primary>gid (group id)</primary>
27970 <secondary>local delivery</secondary>
27971 </indexterm>
27972 <indexterm role="concept">
27973 <primary>local transports</primary>
27974 <secondary>uid and gid</secondary>
27975 </indexterm>
27976 <indexterm role="concept">
27977 <primary>transport</primary>
27978 <secondary>local</secondary>
27979 </indexterm>
27980 <indexterm role="concept">
27981 <primary>router</primary>
27982 <secondary>setting group</secondary>
27983 </indexterm>
27984 When a router queues an address for a transport, and the transport does not
27985 specify a group, the group given here is used when running the delivery
27986 process.
27987 The group may be specified numerically or by name. If expansion fails, the
27988 error is logged and delivery is deferred.
27989 The default is unset, unless <option>check_local_user</option> is set, when the default
27990 is taken from the password information. See also <option>initgroups</option> and <option>user</option>
27991 and the discussion in chapter <xref linkend="CHAPenvironment"/>.
27992 </para>
27993 <para>
27994 <indexterm role="option">
27995 <primary>headers_add</primary>
27996 </indexterm>
27997 </para>
27998 <informaltable frame="all">
27999 <tgroup cols="4" colsep="0" rowsep="0">
28000 <colspec colwidth="8*" align="left"/>
28001 <colspec colwidth="5*" align="center"/>
28002 <colspec colwidth="5*" align="center"/>
28003 <colspec colwidth="6*" align="right"/>
28004 <tbody>
28005 <row>
28006 <entry><option>headers_add</option></entry>
28007 <entry>Use: <emphasis>routers</emphasis></entry>
28008 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28009 <entry>Default: <emphasis>unset</emphasis></entry>
28010 </row>
28011 </tbody>
28012 </tgroup>
28013 </informaltable>
28014 <para>
28015 <indexterm role="concept">
28016 <primary>header lines</primary>
28017 <secondary>adding</secondary>
28018 </indexterm>
28019 <indexterm role="concept">
28020 <primary>router</primary>
28021 <secondary>adding header lines</secondary>
28022 </indexterm>
28023 This option specifies a string of text that is expanded at routing time, and
28024 associated with any addresses that are accepted by the router. However, this
28025 option has no effect when an address is just being verified. The way in which
28026 the text is used to add header lines at transport time is described in section
28027 <xref linkend="SECTheadersaddrem"/>. New header lines are not actually added until the
28028 message is in the process of being transported. This means that references to
28029 header lines in string expansions in the transport&#x2019;s configuration do not
28030 <quote>see</quote> the added header lines.
28031 </para>
28032 <para>
28033 The <option>headers_add</option> option is expanded after <option>errors_to</option>, but before
28034 <option>headers_remove</option> and <option>transport</option>. If the expanded string is empty, or if
28035 the expansion is forced to fail, the option has no effect. Other expansion
28036 failures are treated as configuration errors.
28037 </para>
28038 <para>
28039 <emphasis role="bold">Warning 1</emphasis>: The <option>headers_add</option> option cannot be used for a <command>redirect</command>
28040 router that has the <option>one_time</option> option set.
28041 </para>
28042 <para>
28043 <emphasis role="bold">Warning 2</emphasis>: If the <option>unseen</option> option is set on the router, all header
28044 additions are deleted when the address is passed on to subsequent routers.
28045 </para>
28046 <para>
28047 <indexterm role="option">
28048 <primary>headers_remove</primary>
28049 </indexterm>
28050 </para>
28051 <informaltable frame="all">
28052 <tgroup cols="4" colsep="0" rowsep="0">
28053 <colspec colwidth="8*" align="left"/>
28054 <colspec colwidth="5*" align="center"/>
28055 <colspec colwidth="5*" align="center"/>
28056 <colspec colwidth="6*" align="right"/>
28057 <tbody>
28058 <row>
28059 <entry><option>headers_remove</option></entry>
28060 <entry>Use: <emphasis>routers</emphasis></entry>
28061 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28062 <entry>Default: <emphasis>unset</emphasis></entry>
28063 </row>
28064 </tbody>
28065 </tgroup>
28066 </informaltable>
28067 <para>
28068 <indexterm role="concept">
28069 <primary>header lines</primary>
28070 <secondary>removing</secondary>
28071 </indexterm>
28072 <indexterm role="concept">
28073 <primary>router</primary>
28074 <secondary>removing header lines</secondary>
28075 </indexterm>
28076 This option specifies a string of text that is expanded at routing time, and
28077 associated with any addresses that are accepted by the router. However, this
28078 option has no effect when an address is just being verified. The way in which
28079 the text is used to remove header lines at transport time is described in
28080 section <xref linkend="SECTheadersaddrem"/>. Header lines are not actually removed until
28081 the message is in the process of being transported. This means that references
28082 to header lines in string expansions in the transport&#x2019;s configuration still
28083 <quote>see</quote> the original header lines.
28084 </para>
28085 <para>
28086 The <option>headers_remove</option> option is expanded after <option>errors_to</option> and
28087 <option>headers_add</option>, but before <option>transport</option>. If the expansion is forced to fail,
28088 the option has no effect. Other expansion failures are treated as configuration
28089 errors.
28090 </para>
28091 <para>
28092 <emphasis role="bold">Warning 1</emphasis>: The <option>headers_remove</option> option cannot be used for a <command>redirect</command>
28093 router that has the <option>one_time</option> option set.
28094 </para>
28095 <para>
28096 <emphasis role="bold">Warning 2</emphasis>: If the <option>unseen</option> option is set on the router, all header
28097 removal requests are deleted when the address is passed on to subsequent
28098 routers.
28099 </para>
28100 <para>
28101 <indexterm role="option">
28102 <primary>ignore_target_hosts</primary>
28103 </indexterm>
28104 </para>
28105 <informaltable frame="all">
28106 <tgroup cols="4" colsep="0" rowsep="0">
28107 <colspec colwidth="8*" align="left"/>
28108 <colspec colwidth="5*" align="center"/>
28109 <colspec colwidth="5*" align="center"/>
28110 <colspec colwidth="6*" align="right"/>
28111 <tbody>
28112 <row>
28113 <entry><option>ignore_target_hosts</option></entry>
28114 <entry>Use: <emphasis>routers</emphasis></entry>
28115 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
28116 <entry>Default: <emphasis>unset</emphasis></entry>
28117 </row>
28118 </tbody>
28119 </tgroup>
28120 </informaltable>
28121 <para>
28122 <indexterm role="concept">
28123 <primary>IP address</primary>
28124 <secondary>discarding</secondary>
28125 </indexterm>
28126 <indexterm role="concept">
28127 <primary>router</primary>
28128 <secondary>discarding IP addresses</secondary>
28129 </indexterm>
28130 Although this option is a host list, it should normally contain IP address
28131 entries rather than names. If any host that is looked up by the router has an
28132 IP address that matches an item in this list, Exim behaves as if that IP
28133 address did not exist. This option allows you to cope with rogue DNS entries
28134 like
28135 </para>
28136 <literallayout class="monospaced">
28137 remote.domain.example.  A  127.0.0.1
28138 </literallayout>
28139 <para>
28140 by setting
28141 </para>
28142 <literallayout class="monospaced">
28143 ignore_target_hosts = 127.0.0.1
28144 </literallayout>
28145 <para>
28146 on the relevant router. If all the hosts found by a <command>dnslookup</command> router are
28147 discarded in this way, the router declines. In a conventional configuration, an
28148 attempt to mail to such a domain would normally provoke the <quote>unrouteable
28149 domain</quote> error, and an attempt to verify an address in the domain would fail.
28150 Similarly, if <option>ignore_target_hosts</option> is set on an <command>ipliteral</command> router, the
28151 router declines if presented with one of the listed addresses.
28152 </para>
28153 <para>
28154 You can use this option to disable the use of IPv4 or IPv6 for mail delivery by
28155 means of the first or the second of the following settings, respectively:
28156 </para>
28157 <literallayout class="monospaced">
28158 ignore_target_hosts = 0.0.0.0/0
28159 ignore_target_hosts = &lt;; 0::0/0
28160 </literallayout>
28161 <para>
28162 The pattern in the first line matches all IPv4 addresses, whereas the pattern
28163 in the second line matches all IPv6 addresses.
28164 </para>
28165 <para>
28166 This option may also be useful for ignoring link-local and site-local IPv6
28167 addresses. Because, like all host lists, the value of <option>ignore_target_hosts</option>
28168 is expanded before use as a list, it is possible to make it dependent on the
28169 domain that is being routed.
28170 </para>
28171 <para>
28172 <indexterm role="concept">
28173 <primary><varname>$host_address</varname></primary>
28174 </indexterm>
28175 During its expansion, <varname>$host_address</varname> is set to the IP address that is being
28176 checked.
28177 </para>
28178 <para>
28179 <indexterm role="option">
28180 <primary>initgroups</primary>
28181 </indexterm>
28182 </para>
28183 <informaltable frame="all">
28184 <tgroup cols="4" colsep="0" rowsep="0">
28185 <colspec colwidth="8*" align="left"/>
28186 <colspec colwidth="5*" align="center"/>
28187 <colspec colwidth="5*" align="center"/>
28188 <colspec colwidth="6*" align="right"/>
28189 <tbody>
28190 <row>
28191 <entry><option>initgroups</option></entry>
28192 <entry>Use: <emphasis>routers</emphasis></entry>
28193 <entry>Type: <emphasis>boolean</emphasis></entry>
28194 <entry>Default: <emphasis>false</emphasis></entry>
28195 </row>
28196 </tbody>
28197 </tgroup>
28198 </informaltable>
28199 <para>
28200 <indexterm role="concept">
28201 <primary>additional groups</primary>
28202 </indexterm>
28203 <indexterm role="concept">
28204 <primary>groups</primary>
28205 <secondary>additional</secondary>
28206 </indexterm>
28207 <indexterm role="concept">
28208 <primary>local transports</primary>
28209 <secondary>uid and gid</secondary>
28210 </indexterm>
28211 <indexterm role="concept">
28212 <primary>transport</primary>
28213 <secondary>local</secondary>
28214 </indexterm>
28215 If the router queues an address for a transport, and this option is true, and
28216 the uid supplied by the router is not overridden by the transport, the
28217 <function>initgroups()</function> function is called when running the transport to ensure that
28218 any additional groups associated with the uid are set up. See also <option>group</option>
28219 and <option>user</option> and the discussion in chapter <xref linkend="CHAPenvironment"/>.
28220 </para>
28221 <para>
28222 <indexterm role="option">
28223 <primary>local_part_prefix</primary>
28224 </indexterm>
28225 </para>
28226 <informaltable frame="all">
28227 <tgroup cols="4" colsep="0" rowsep="0">
28228 <colspec colwidth="8*" align="left"/>
28229 <colspec colwidth="5*" align="center"/>
28230 <colspec colwidth="5*" align="center"/>
28231 <colspec colwidth="6*" align="right"/>
28232 <tbody>
28233 <row>
28234 <entry><option>local_part_prefix</option></entry>
28235 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
28236 <entry>Type: <emphasis>string list</emphasis></entry>
28237 <entry>Default: <emphasis>unset</emphasis></entry>
28238 </row>
28239 </tbody>
28240 </tgroup>
28241 </informaltable>
28242 <para>
28243 <indexterm role="concept">
28244 <primary>router</primary>
28245 <secondary>prefix for local part</secondary>
28246 </indexterm>
28247 <indexterm role="concept">
28248 <primary>prefix</primary>
28249 <secondary>for local part; used in router</secondary>
28250 </indexterm>
28251 If this option is set, the router is skipped unless the local part starts with
28252 one of the given strings, or <option>local_part_prefix_optional</option> is true. See
28253 section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions are
28254 evaluated.
28255 </para>
28256 <para>
28257 The list is scanned from left to right, and the first prefix that matches is
28258 used. A limited form of wildcard is available; if the prefix begins with an
28259 asterisk, it matches the longest possible sequence of arbitrary characters at
28260 the start of the local part. An asterisk should therefore always be followed by
28261 some character that does not occur in normal local parts.
28262 <indexterm role="concept">
28263 <primary>multiple mailboxes</primary>
28264 </indexterm>
28265 <indexterm role="concept">
28266 <primary>mailbox</primary>
28267 <secondary>multiple</secondary>
28268 </indexterm>
28269 Wildcarding can be used to set up multiple user mailboxes, as described in
28270 section <xref linkend="SECTmulbox"/>.
28271 </para>
28272 <para>
28273 <indexterm role="concept">
28274 <primary><varname>$local_part</varname></primary>
28275 </indexterm>
28276 <indexterm role="concept">
28277 <primary><varname>$local_part_prefix</varname></primary>
28278 </indexterm>
28279 During the testing of the <option>local_parts</option> option, and while the router is
28280 running, the prefix is removed from the local part, and is available in the
28281 expansion variable <varname>$local_part_prefix</varname>. When a message is being delivered, if
28282 the router accepts the address, this remains true during subsequent delivery by
28283 a transport. In particular, the local part that is transmitted in the RCPT
28284 command for LMTP, SMTP, and BSMTP deliveries has the prefix removed by default.
28285 This behaviour can be overridden by setting <option>rcpt_include_affixes</option> true on
28286 the relevant transport.
28287 </para>
28288 <para>
28289 When an address is being verified, <option>local_part_prefix</option> affects only the
28290 behaviour of the router. If the callout feature of verification is in use, this
28291 means that the full address, including the prefix, will be used during the
28292 callout.
28293 </para>
28294 <para>
28295 The prefix facility is commonly used to handle local parts of the form
28296 <option>owner-something</option>. Another common use is to support local parts of the form
28297 <option>real-username</option> to bypass a user&#x2019;s <filename>.forward</filename> file &ndash; helpful when trying
28298 to tell a user their forwarding is broken &ndash; by placing a router like this one
28299 immediately before the router that handles <filename>.forward</filename> files:
28300 </para>
28301 <literallayout class="monospaced">
28302 real_localuser:
28303   driver = accept
28304   local_part_prefix = real-
28305   check_local_user
28306   transport = local_delivery
28307 </literallayout>
28308 <para>
28309 If both <option>local_part_prefix</option> and <option>local_part_suffix</option> are set for a router,
28310 both conditions must be met if not optional. Care must be taken if wildcards
28311 are used in both a prefix and a suffix on the same router. Different
28312 separator characters must be used to avoid ambiguity.
28313 </para>
28314 <para>
28315 <indexterm role="option">
28316 <primary>local_part_prefix_optional</primary>
28317 </indexterm>
28318 </para>
28319 <informaltable frame="all">
28320 <tgroup cols="4" colsep="0" rowsep="0">
28321 <colspec colwidth="8*" align="left"/>
28322 <colspec colwidth="5*" align="center"/>
28323 <colspec colwidth="5*" align="center"/>
28324 <colspec colwidth="6*" align="right"/>
28325 <tbody>
28326 <row>
28327 <entry><option>local_part_prefix_optional</option></entry>
28328 <entry>Use: <emphasis>routers</emphasis></entry>
28329 <entry>Type: <emphasis>boolean</emphasis></entry>
28330 <entry>Default: <emphasis>false</emphasis></entry>
28331 </row>
28332 </tbody>
28333 </tgroup>
28334 </informaltable>
28335 <para>
28336 See <option>local_part_prefix</option> above.
28337 </para>
28338 <para>
28339 <indexterm role="option">
28340 <primary>local_part_suffix</primary>
28341 </indexterm>
28342 </para>
28343 <informaltable frame="all">
28344 <tgroup cols="4" colsep="0" rowsep="0">
28345 <colspec colwidth="8*" align="left"/>
28346 <colspec colwidth="5*" align="center"/>
28347 <colspec colwidth="5*" align="center"/>
28348 <colspec colwidth="6*" align="right"/>
28349 <tbody>
28350 <row>
28351 <entry><option>local_part_suffix</option></entry>
28352 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
28353 <entry>Type: <emphasis>string list</emphasis></entry>
28354 <entry>Default: <emphasis>unset</emphasis></entry>
28355 </row>
28356 </tbody>
28357 </tgroup>
28358 </informaltable>
28359 <para>
28360 <indexterm role="concept">
28361 <primary>router</primary>
28362 <secondary>suffix for local part</secondary>
28363 </indexterm>
28364 <indexterm role="concept">
28365 <primary>suffix for local part</primary>
28366 <secondary>used in router</secondary>
28367 </indexterm>
28368 This option operates in the same way as <option>local_part_prefix</option>, except that the
28369 local part must end (rather than start) with the given string, the
28370 <option>local_part_suffix_optional</option> option determines whether the suffix is
28371 mandatory, and the wildcard * character, if present, must be the last
28372 character of the suffix. This option facility is commonly used to handle local
28373 parts of the form <option>something-request</option> and multiple user mailboxes of the form
28374 <option>username-foo</option>.
28375 </para>
28376 <para>
28377 <indexterm role="option">
28378 <primary>local_part_suffix_optional</primary>
28379 </indexterm>
28380 </para>
28381 <informaltable frame="all">
28382 <tgroup cols="4" colsep="0" rowsep="0">
28383 <colspec colwidth="8*" align="left"/>
28384 <colspec colwidth="5*" align="center"/>
28385 <colspec colwidth="5*" align="center"/>
28386 <colspec colwidth="6*" align="right"/>
28387 <tbody>
28388 <row>
28389 <entry><option>local_part_suffix_optional</option></entry>
28390 <entry>Use: <emphasis>routers</emphasis></entry>
28391 <entry>Type: <emphasis>boolean</emphasis></entry>
28392 <entry>Default: <emphasis>false</emphasis></entry>
28393 </row>
28394 </tbody>
28395 </tgroup>
28396 </informaltable>
28397 <para>
28398 See <option>local_part_suffix</option> above.
28399 </para>
28400 <para>
28401 <indexterm role="option">
28402 <primary>local_parts</primary>
28403 </indexterm>
28404 </para>
28405 <informaltable frame="all">
28406 <tgroup cols="4" colsep="0" rowsep="0">
28407 <colspec colwidth="8*" align="left"/>
28408 <colspec colwidth="5*" align="center"/>
28409 <colspec colwidth="5*" align="center"/>
28410 <colspec colwidth="6*" align="right"/>
28411 <tbody>
28412 <row>
28413 <entry><option>local_parts</option></entry>
28414 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
28415 <entry>Type: <emphasis>local part list</emphasis>&dagger;<emphasis></emphasis></entry>
28416 <entry>Default: <emphasis>unset</emphasis></entry>
28417 </row>
28418 </tbody>
28419 </tgroup>
28420 </informaltable>
28421 <para>
28422 <indexterm role="concept">
28423 <primary>router</primary>
28424 <secondary>restricting to specific local parts</secondary>
28425 </indexterm>
28426 <indexterm role="concept">
28427 <primary>local part</primary>
28428 <secondary>checking in router</secondary>
28429 </indexterm>
28430 The router is run only if the local part of the address matches the list.
28431 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
28432 are evaluated, and
28433 section <xref linkend="SECTlocparlis"/> for a discussion of local part lists. Because the
28434 string is expanded, it is possible to make it depend on the domain, for
28435 example:
28436 </para>
28437 <literallayout class="monospaced">
28438 local_parts = dbm;/usr/local/specials/$domain
28439 </literallayout>
28440 <para>
28441 <indexterm role="concept">
28442 <primary><varname>$local_part_data</varname></primary>
28443 </indexterm>
28444 If the match is achieved by a lookup, the data that the lookup returned
28445 for the local part is placed in the variable <varname>$local_part_data</varname> for use in
28446 expansions of the router&#x2019;s private options. You might use this option, for
28447 example, if you have a large number of local virtual domains, and you want to
28448 send all postmaster mail to the same place without having to set up an alias in
28449 each virtual domain:
28450 </para>
28451 <literallayout class="monospaced">
28452 postmaster:
28453   driver = redirect
28454   local_parts = postmaster
28455   data = postmaster@real.domain.example
28456 </literallayout>
28457 <para>
28458 <indexterm role="option">
28459 <primary>log_as_local</primary>
28460 </indexterm>
28461 </para>
28462 <informaltable frame="all">
28463 <tgroup cols="4" colsep="0" rowsep="0">
28464 <colspec colwidth="8*" align="left"/>
28465 <colspec colwidth="5*" align="center"/>
28466 <colspec colwidth="5*" align="center"/>
28467 <colspec colwidth="6*" align="right"/>
28468 <tbody>
28469 <row>
28470 <entry><option>log_as_local</option></entry>
28471 <entry>Use: <emphasis>routers</emphasis></entry>
28472 <entry>Type: <emphasis>boolean</emphasis></entry>
28473 <entry>Default: <emphasis>see below</emphasis></entry>
28474 </row>
28475 </tbody>
28476 </tgroup>
28477 </informaltable>
28478 <para>
28479 <indexterm role="concept">
28480 <primary>log</primary>
28481 <secondary>delivery line</secondary>
28482 </indexterm>
28483 <indexterm role="concept">
28484 <primary>delivery</primary>
28485 <secondary>log line format</secondary>
28486 </indexterm>
28487 Exim has two logging styles for delivery, the idea being to make local
28488 deliveries stand out more visibly from remote ones. In the <quote>local</quote> style, the
28489 recipient address is given just as the local part, without a domain. The use of
28490 this style is controlled by this option. It defaults to true for the <command>accept</command>
28491 router, and false for all the others. This option applies only when a
28492 router assigns an address to a transport. It has no effect on routers that
28493 redirect addresses.
28494 </para>
28495 <para>
28496 <indexterm role="option">
28497 <primary>more</primary>
28498 </indexterm>
28499 </para>
28500 <informaltable frame="all">
28501 <tgroup cols="4" colsep="0" rowsep="0">
28502 <colspec colwidth="8*" align="left"/>
28503 <colspec colwidth="5*" align="center"/>
28504 <colspec colwidth="5*" align="center"/>
28505 <colspec colwidth="6*" align="right"/>
28506 <tbody>
28507 <row>
28508 <entry><option>more</option></entry>
28509 <entry>Use: <emphasis>routers</emphasis></entry>
28510 <entry>Type: <emphasis>boolean</emphasis>&dagger;<emphasis></emphasis></entry>
28511 <entry>Default: <emphasis>true</emphasis></entry>
28512 </row>
28513 </tbody>
28514 </tgroup>
28515 </informaltable>
28516 <para>
28517 The result of string expansion for this option must be a valid boolean value,
28518 that is, one of the strings <quote>yes</quote>, <quote>no</quote>, <quote>true</quote>, or <quote>false</quote>. Any other
28519 result causes an error, and delivery is deferred. If the expansion is forced to
28520 fail, the default value for the option (true) is used. Other failures cause
28521 delivery to be deferred.
28522 </para>
28523 <para>
28524 If this option is set false, and the router declines to handle the address, no
28525 further routers are tried, routing fails, and the address is bounced.
28526 <indexterm role="concept">
28527 <primary><option>self</option> option</primary>
28528 </indexterm>
28529 However, if the router explicitly passes an address to the following router by
28530 means of the setting
28531 </para>
28532 <literallayout class="monospaced">
28533 self = pass
28534 </literallayout>
28535 <para>
28536 or otherwise, the setting of <option>more</option> is ignored. Also, the setting of <option>more</option>
28537 does not affect the behaviour if one of the precondition tests fails. In that
28538 case, the address is always passed to the next router.
28539 </para>
28540 <para>
28541 Note that <option>address_data</option> is not considered to be a precondition. If its
28542 expansion is forced to fail, the router declines, and the value of <option>more</option>
28543 controls what happens next.
28544 </para>
28545 <para>
28546 <indexterm role="option">
28547 <primary>pass_on_timeout</primary>
28548 </indexterm>
28549 </para>
28550 <informaltable frame="all">
28551 <tgroup cols="4" colsep="0" rowsep="0">
28552 <colspec colwidth="8*" align="left"/>
28553 <colspec colwidth="5*" align="center"/>
28554 <colspec colwidth="5*" align="center"/>
28555 <colspec colwidth="6*" align="right"/>
28556 <tbody>
28557 <row>
28558 <entry><option>pass_on_timeout</option></entry>
28559 <entry>Use: <emphasis>routers</emphasis></entry>
28560 <entry>Type: <emphasis>boolean</emphasis></entry>
28561 <entry>Default: <emphasis>false</emphasis></entry>
28562 </row>
28563 </tbody>
28564 </tgroup>
28565 </informaltable>
28566 <para>
28567 <indexterm role="concept">
28568 <primary>timeout</primary>
28569 <secondary>of router</secondary>
28570 </indexterm>
28571 <indexterm role="concept">
28572 <primary>router</primary>
28573 <secondary>timeout</secondary>
28574 </indexterm>
28575 If a router times out during a host lookup, it normally causes deferral of the
28576 address. If <option>pass_on_timeout</option> is set, the address is passed on to the next
28577 router, overriding <option>no_more</option>. This may be helpful for systems that are
28578 intermittently connected to the Internet, or those that want to pass to a smart
28579 host any messages that cannot immediately be delivered.
28580 </para>
28581 <para>
28582 There are occasional other temporary errors that can occur while doing DNS
28583 lookups. They are treated in the same way as a timeout, and this option
28584 applies to all of them.
28585 </para>
28586 <para>
28587 <indexterm role="option">
28588 <primary>pass_router</primary>
28589 </indexterm>
28590 </para>
28591 <informaltable frame="all">
28592 <tgroup cols="4" colsep="0" rowsep="0">
28593 <colspec colwidth="8*" align="left"/>
28594 <colspec colwidth="5*" align="center"/>
28595 <colspec colwidth="5*" align="center"/>
28596 <colspec colwidth="6*" align="right"/>
28597 <tbody>
28598 <row>
28599 <entry><option>pass_router</option></entry>
28600 <entry>Use: <emphasis>routers</emphasis></entry>
28601 <entry>Type: <emphasis>string</emphasis></entry>
28602 <entry>Default: <emphasis>unset</emphasis></entry>
28603 </row>
28604 </tbody>
28605 </tgroup>
28606 </informaltable>
28607 <para>
28608 <indexterm role="concept">
28609 <primary>router</primary>
28610 <secondary>go to after <quote>pass</quote></secondary>
28611 </indexterm>
28612 When a router returns <quote>pass</quote>, the address is normally handed on to the next
28613 router in sequence. This can be changed by setting <option>pass_router</option> to the name
28614 of another router. However (unlike <option>redirect_router</option>) the named router must
28615 be below the current router, to avoid loops. Note that this option applies only
28616 to the special case of <quote>pass</quote>. It does not apply when a router returns
28617 <quote>decline</quote>.
28618 </para>
28619 <para>
28620 <indexterm role="option">
28621 <primary>redirect_router</primary>
28622 </indexterm>
28623 </para>
28624 <informaltable frame="all">
28625 <tgroup cols="4" colsep="0" rowsep="0">
28626 <colspec colwidth="8*" align="left"/>
28627 <colspec colwidth="5*" align="center"/>
28628 <colspec colwidth="5*" align="center"/>
28629 <colspec colwidth="6*" align="right"/>
28630 <tbody>
28631 <row>
28632 <entry><option>redirect_router</option></entry>
28633 <entry>Use: <emphasis>routers</emphasis></entry>
28634 <entry>Type: <emphasis>string</emphasis></entry>
28635 <entry>Default: <emphasis>unset</emphasis></entry>
28636 </row>
28637 </tbody>
28638 </tgroup>
28639 </informaltable>
28640 <para>
28641 <indexterm role="concept">
28642 <primary>router</primary>
28643 <secondary>start at after redirection</secondary>
28644 </indexterm>
28645 Sometimes an administrator knows that it is pointless to reprocess addresses
28646 generated from alias or forward files with the same router again. For
28647 example, if an alias file translates real names into login ids there is no
28648 point searching the alias file a second time, especially if it is a large file.
28649 </para>
28650 <para>
28651 The <option>redirect_router</option> option can be set to the name of any router instance.
28652 It causes the routing of any generated addresses to start at the named router
28653 instead of at the first router. This option has no effect if the router in
28654 which it is set does not generate new addresses.
28655 </para>
28656 <para>
28657 <indexterm role="option">
28658 <primary>require_files</primary>
28659 </indexterm>
28660 </para>
28661 <informaltable frame="all">
28662 <tgroup cols="4" colsep="0" rowsep="0">
28663 <colspec colwidth="8*" align="left"/>
28664 <colspec colwidth="5*" align="center"/>
28665 <colspec colwidth="5*" align="center"/>
28666 <colspec colwidth="6*" align="right"/>
28667 <tbody>
28668 <row>
28669 <entry><option>require_files</option></entry>
28670 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
28671 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
28672 <entry>Default: <emphasis>unset</emphasis></entry>
28673 </row>
28674 </tbody>
28675 </tgroup>
28676 </informaltable>
28677 <para>
28678 <indexterm role="concept">
28679 <primary>file</primary>
28680 <secondary>requiring for router</secondary>
28681 </indexterm>
28682 <indexterm role="concept">
28683 <primary>router</primary>
28684 <secondary>requiring file existence</secondary>
28685 </indexterm>
28686 This option provides a general mechanism for predicating the running of a
28687 router on the existence or non-existence of certain files or directories.
28688 Before running a router, as one of its precondition tests, Exim works its way
28689 through the <option>require_files</option> list, expanding each item separately.
28690 </para>
28691 <para>
28692 Because the list is split before expansion, any colons in expansion items must
28693 be doubled, or the facility for using a different list separator must be used.
28694 If any expansion is forced to fail, the item is ignored. Other expansion
28695 failures cause routing of the address to be deferred.
28696 </para>
28697 <para>
28698 If any expanded string is empty, it is ignored. Otherwise, except as described
28699 below, each string must be a fully qualified file path, optionally preceded by
28700 <quote>!</quote>. The paths are passed to the <function>stat()</function> function to test for the
28701 existence of the files or directories. The router is skipped if any paths not
28702 preceded by <quote>!</quote> do not exist, or if any paths preceded by <quote>!</quote> do exist.
28703 </para>
28704 <para>
28705 <indexterm role="concept">
28706 <primary>NFS</primary>
28707 </indexterm>
28708 If <function>stat()</function> cannot determine whether a file exists or not, delivery of
28709 the message is deferred. This can happen when NFS-mounted filesystems are
28710 unavailable.
28711 </para>
28712 <para>
28713 This option is checked after the <option>domains</option>, <option>local_parts</option>, and <option>senders</option>
28714 options, so you cannot use it to check for the existence of a file in which to
28715 look up a domain, local part, or sender. (See section <xref linkend="SECTrouprecon"/> for a
28716 full list of the order in which preconditions are evaluated.) However, as
28717 these options are all expanded, you can use the <option>exists</option> expansion condition
28718 to make such tests. The <option>require_files</option> option is intended for checking files
28719 that the router may be going to use internally, or which are needed by a
28720 transport (for example <filename>.procmailrc</filename>).
28721 </para>
28722 <para>
28723 During delivery, the <function>stat()</function> function is run as root, but there is a
28724 facility for some checking of the accessibility of a file by another user.
28725 This is not a proper permissions check, but just a <quote>rough</quote> check that
28726 operates as follows:
28727 </para>
28728 <para>
28729 If an item in a <option>require_files</option> list does not contain any forward slash
28730 characters, it is taken to be the user (and optional group, separated by a
28731 comma) to be checked for subsequent files in the list. If no group is specified
28732 but the user is specified symbolically, the gid associated with the uid is
28733 used. For example:
28734 </para>
28735 <literallayout class="monospaced">
28736 require_files = mail:/some/file
28737 require_files = $local_part:$home/.procmailrc
28738 </literallayout>
28739 <para>
28740 If a user or group name in a <option>require_files</option> list does not exist, the
28741 <option>require_files</option> condition fails.
28742 </para>
28743 <para>
28744 Exim performs the check by scanning along the components of the file path, and
28745 checking the access for the given uid and gid. It checks for <quote>x</quote> access on
28746 directories, and <quote>r</quote> access on the final file. Note that this means that file
28747 access control lists, if the operating system has them, are ignored.
28748 </para>
28749 <para>
28750 <emphasis role="bold">Warning 1</emphasis>: When the router is being run to verify addresses for an
28751 incoming SMTP message, Exim is not running as root, but under its own uid. This
28752 may affect the result of a <option>require_files</option> check. In particular, <function>stat()</function>
28753 may yield the error EACCES (<quote>Permission denied</quote>). This means that the Exim
28754 user is not permitted to read one of the directories on the file&#x2019;s path.
28755 </para>
28756 <para>
28757 <emphasis role="bold">Warning 2</emphasis>: Even when Exim is running as root while delivering a message,
28758 <function>stat()</function> can yield EACCES for a file in an NFS directory that is mounted
28759 without root access. In this case, if a check for access by a particular user
28760 is requested, Exim creates a subprocess that runs as that user, and tries the
28761 check again in that process.
28762 </para>
28763 <para>
28764 The default action for handling an unresolved EACCES is to consider it to
28765 be caused by a configuration error, and routing is deferred because the
28766 existence or non-existence of the file cannot be determined. However, in some
28767 circumstances it may be desirable to treat this condition as if the file did
28768 not exist. If the file name (or the exclamation mark that precedes the file
28769 name for non-existence) is preceded by a plus sign, the EACCES error is treated
28770 as if the file did not exist. For example:
28771 </para>
28772 <literallayout class="monospaced">
28773 require_files = +/some/file
28774 </literallayout>
28775 <para>
28776 If the router is not an essential part of verification (for example, it
28777 handles users&#x2019; <filename>.forward</filename> files), another solution is to set the <option>verify</option>
28778 option false so that the router is skipped when verifying.
28779 </para>
28780 <para>
28781 <indexterm role="option">
28782 <primary>retry_use_local_part</primary>
28783 </indexterm>
28784 </para>
28785 <informaltable frame="all">
28786 <tgroup cols="4" colsep="0" rowsep="0">
28787 <colspec colwidth="8*" align="left"/>
28788 <colspec colwidth="5*" align="center"/>
28789 <colspec colwidth="5*" align="center"/>
28790 <colspec colwidth="6*" align="right"/>
28791 <tbody>
28792 <row>
28793 <entry><option>retry_use_local_part</option></entry>
28794 <entry>Use: <emphasis>routers</emphasis></entry>
28795 <entry>Type: <emphasis>boolean</emphasis></entry>
28796 <entry>Default: <emphasis>see below</emphasis></entry>
28797 </row>
28798 </tbody>
28799 </tgroup>
28800 </informaltable>
28801 <para>
28802 <indexterm role="concept">
28803 <primary>hints database</primary>
28804 <secondary>retry keys</secondary>
28805 </indexterm>
28806 <indexterm role="concept">
28807 <primary>local part</primary>
28808 <secondary>in retry keys</secondary>
28809 </indexterm>
28810 When a delivery suffers a temporary routing failure, a retry record is created
28811 in Exim&#x2019;s hints database. For addresses whose routing depends only on the
28812 domain, the key for the retry record should not involve the local part, but for
28813 other addresses, both the domain and the local part should be included.
28814 Usually, remote routing is of the former kind, and local routing is of the
28815 latter kind.
28816 </para>
28817 <para>
28818 This option controls whether the local part is used to form the key for retry
28819 hints for addresses that suffer temporary errors while being handled by this
28820 router. The default value is true for any router that has <option>check_local_user</option>
28821 set, and false otherwise. Note that this option does not apply to hints keys
28822 for transport delays; they are controlled by a generic transport option of the
28823 same name.
28824 </para>
28825 <para>
28826 The setting of <option>retry_use_local_part</option> applies only to the router on which it
28827 appears. If the router generates child addresses, they are routed
28828 independently; this setting does not become attached to them.
28829 </para>
28830 <para>
28831 <indexterm role="option">
28832 <primary>router_home_directory</primary>
28833 </indexterm>
28834 </para>
28835 <informaltable frame="all">
28836 <tgroup cols="4" colsep="0" rowsep="0">
28837 <colspec colwidth="8*" align="left"/>
28838 <colspec colwidth="5*" align="center"/>
28839 <colspec colwidth="5*" align="center"/>
28840 <colspec colwidth="6*" align="right"/>
28841 <tbody>
28842 <row>
28843 <entry><option>router_home_directory</option></entry>
28844 <entry>Use: <emphasis>routers</emphasis></entry>
28845 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28846 <entry>Default: <emphasis>unset</emphasis></entry>
28847 </row>
28848 </tbody>
28849 </tgroup>
28850 </informaltable>
28851 <para>
28852 <indexterm role="concept">
28853 <primary>router</primary>
28854 <secondary>home directory for</secondary>
28855 </indexterm>
28856 <indexterm role="concept">
28857 <primary>home directory</primary>
28858 <secondary>for router</secondary>
28859 </indexterm>
28860 <indexterm role="concept">
28861 <primary><varname>$home</varname></primary>
28862 </indexterm>
28863 This option sets a home directory for use while the router is running. (Compare
28864 <option>transport_home_directory</option>, which sets a home directory for later
28865 transporting.) In particular, if used on a <command>redirect</command> router, this option
28866 sets a value for <varname>$home</varname> while a filter is running. The value is expanded;
28867 forced expansion failure causes the option to be ignored &ndash; other failures
28868 cause the router to defer.
28869 </para>
28870 <para>
28871 Expansion of <option>router_home_directory</option> happens immediately after the
28872 <option>check_local_user</option> test (if configured), before any further expansions take
28873 place.
28874 (See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
28875 are evaluated.)
28876 While the router is running, <option>router_home_directory</option> overrides the value of
28877 <varname>$home</varname> that came from <option>check_local_user</option>.
28878 </para>
28879 <para revisionflag="changed">
28880 When a router accepts an address and assigns it to a local transport (including
28881 the cases when a <command>redirect</command> router generates a pipe, file, or autoreply
28882 delivery), the home directory setting for the transport is taken from the first
28883 of these values that is set:
28884 </para>
28885 <itemizedlist>
28886 <listitem>
28887 <para>
28888 The <option>home_directory</option> option on the transport;
28889 </para>
28890 </listitem>
28891 <listitem>
28892 <para>
28893 The <option>transport_home_directory</option> option on the router;
28894 </para>
28895 </listitem>
28896 <listitem>
28897 <para>
28898 The password data if <option>check_local_user</option> is set on the router;
28899 </para>
28900 </listitem>
28901 <listitem>
28902 <para>
28903 The <option>router_home_directory</option> option on the router.
28904 </para>
28905 </listitem>
28906 </itemizedlist>
28907 <para>
28908 In other words, <option>router_home_directory</option> overrides the password data for the
28909 router, but not for the transport.
28910 </para>
28911 <para>
28912 <indexterm role="option">
28913 <primary>self</primary>
28914 </indexterm>
28915 </para>
28916 <informaltable frame="all">
28917 <tgroup cols="4" colsep="0" rowsep="0">
28918 <colspec colwidth="8*" align="left"/>
28919 <colspec colwidth="5*" align="center"/>
28920 <colspec colwidth="5*" align="center"/>
28921 <colspec colwidth="6*" align="right"/>
28922 <tbody>
28923 <row>
28924 <entry><option>self</option></entry>
28925 <entry>Use: <emphasis>routers</emphasis></entry>
28926 <entry>Type: <emphasis>string</emphasis></entry>
28927 <entry>Default: <emphasis>freeze</emphasis></entry>
28928 </row>
28929 </tbody>
28930 </tgroup>
28931 </informaltable>
28932 <para>
28933 <indexterm role="concept">
28934 <primary>MX record</primary>
28935 <secondary>pointing to local host</secondary>
28936 </indexterm>
28937 <indexterm role="concept">
28938 <primary>local host</primary>
28939 <secondary>MX pointing to</secondary>
28940 </indexterm>
28941 This option applies to those routers that use a recipient address to find a
28942 list of remote hosts. Currently, these are the <command>dnslookup</command>, <command>ipliteral</command>,
28943 and <command>manualroute</command> routers.
28944 Certain configurations of the <command>queryprogram</command> router can also specify a list
28945 of remote hosts.
28946 Usually such routers are configured to send the message to a remote host via an
28947 <command>smtp</command> transport. The <option>self</option> option specifies what happens when the first
28948 host on the list turns out to be the local host.
28949 The way in which Exim checks for the local host is described in section
28950 <xref linkend="SECTreclocipadd"/>.
28951 </para>
28952 <para>
28953 Normally this situation indicates either an error in Exim&#x2019;s configuration (for
28954 example, the router should be configured not to process this domain), or an
28955 error in the DNS (for example, the MX should not point to this host). For this
28956 reason, the default action is to log the incident, defer the address, and
28957 freeze the message. The following alternatives are provided for use in special
28958 cases:
28959 </para>
28960 <variablelist>
28961 <varlistentry>
28962 <term><option>defer</option></term>
28963 <listitem>
28964 <para>
28965 Delivery of the message is tried again later, but the message is not frozen.
28966 </para>
28967 </listitem></varlistentry>
28968 <varlistentry>
28969 <term><option>reroute</option>: &lt;<emphasis>domain</emphasis>&gt;</term>
28970 <listitem>
28971 <para>
28972 The domain is changed to the given domain, and the address is passed back to
28973 be reprocessed by the routers. No rewriting of headers takes place. This
28974 behaviour is essentially a redirection.
28975 </para>
28976 </listitem></varlistentry>
28977 <varlistentry>
28978 <term><option>reroute: rewrite:</option> &lt;<emphasis>domain</emphasis>&gt;</term>
28979 <listitem>
28980 <para>
28981 The domain is changed to the given domain, and the address is passed back to be
28982 reprocessed by the routers. Any headers that contain the original domain are
28983 rewritten.
28984 </para>
28985 </listitem></varlistentry>
28986 <varlistentry>
28987 <term><option>pass</option></term>
28988 <listitem>
28989 <para>
28990 <indexterm role="concept">
28991 <primary><option>more</option> option</primary>
28992 </indexterm>
28993 <indexterm role="concept">
28994 <primary><varname>$self_hostname</varname></primary>
28995 </indexterm>
28996 The router passes the address to the next router, or to the router named in the
28997 <option>pass_router</option> option if it is set. This overrides <option>no_more</option>. During
28998 subsequent routing and delivery, the variable <varname>$self_hostname</varname> contains the
28999 name of the local host that the router encountered. This can be used to
29000 distinguish between different cases for hosts with multiple names. The
29001 combination
29002 </para>
29003 <literallayout class="monospaced">
29004 self = pass
29005 no_more
29006 </literallayout>
29007 <para>
29008 ensures that only those addresses that routed to the local host are passed on.
29009 Without <option>no_more</option>, addresses that were declined for other reasons would also
29010 be passed to the next router.
29011 </para>
29012 </listitem></varlistentry>
29013 <varlistentry>
29014 <term><option>fail</option></term>
29015 <listitem>
29016 <para>
29017 Delivery fails and an error report is generated.
29018 </para>
29019 </listitem></varlistentry>
29020 <varlistentry>
29021 <term><option>send</option></term>
29022 <listitem>
29023 <para>
29024 <indexterm role="concept">
29025 <primary>local host</primary>
29026 <secondary>sending to</secondary>
29027 </indexterm>
29028 The anomaly is ignored and the address is queued for the transport. This
29029 setting should be used with extreme caution. For an <command>smtp</command> transport, it
29030 makes sense only in cases where the program that is listening on the SMTP port
29031 is not this version of Exim. That is, it must be some other MTA, or Exim with a
29032 different configuration file that handles the domain in another way.
29033 </para>
29034 </listitem></varlistentry>
29035 </variablelist>
29036 <para>
29037 <indexterm role="option">
29038 <primary>senders</primary>
29039 </indexterm>
29040 </para>
29041 <informaltable frame="all">
29042 <tgroup cols="4" colsep="0" rowsep="0">
29043 <colspec colwidth="8*" align="left"/>
29044 <colspec colwidth="5*" align="center"/>
29045 <colspec colwidth="5*" align="center"/>
29046 <colspec colwidth="6*" align="right"/>
29047 <tbody>
29048 <row>
29049 <entry><option>senders</option></entry>
29050 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29051 <entry>Type: <emphasis>address list</emphasis>&dagger;<emphasis></emphasis></entry>
29052 <entry>Default: <emphasis>unset</emphasis></entry>
29053 </row>
29054 </tbody>
29055 </tgroup>
29056 </informaltable>
29057 <para>
29058 <indexterm role="concept">
29059 <primary>router</primary>
29060 <secondary>checking senders</secondary>
29061 </indexterm>
29062 If this option is set, the router is skipped unless the message&#x2019;s sender
29063 address matches something on the list.
29064 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
29065 are evaluated.
29066 </para>
29067 <para>
29068 There are issues concerning verification when the running of routers is
29069 dependent on the sender. When Exim is verifying the address in an <option>errors_to</option>
29070 setting, it sets the sender to the null string. When using the <option>-bt</option> option
29071 to check a configuration file, it is necessary also to use the <option>-f</option> option to
29072 set an appropriate sender. For incoming mail, the sender is unset when
29073 verifying the sender, but is available when verifying any recipients. If the
29074 SMTP VRFY command is enabled, it must be used after MAIL if the sender address
29075 matters.
29076 </para>
29077 <para>
29078 <indexterm role="option">
29079 <primary>translate_ip_address</primary>
29080 </indexterm>
29081 </para>
29082 <informaltable frame="all">
29083 <tgroup cols="4" colsep="0" rowsep="0">
29084 <colspec colwidth="8*" align="left"/>
29085 <colspec colwidth="5*" align="center"/>
29086 <colspec colwidth="5*" align="center"/>
29087 <colspec colwidth="6*" align="right"/>
29088 <tbody>
29089 <row>
29090 <entry><option>translate_ip_address</option></entry>
29091 <entry>Use: <emphasis>routers</emphasis></entry>
29092 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29093 <entry>Default: <emphasis>unset</emphasis></entry>
29094 </row>
29095 </tbody>
29096 </tgroup>
29097 </informaltable>
29098 <para>
29099 <indexterm role="concept">
29100 <primary>IP address</primary>
29101 <secondary>translating</secondary>
29102 </indexterm>
29103 <indexterm role="concept">
29104 <primary>packet radio</primary>
29105 </indexterm>
29106 <indexterm role="concept">
29107 <primary>router</primary>
29108 <secondary>IP address translation</secondary>
29109 </indexterm>
29110 There exist some rare networking situations (for example, packet radio) where
29111 it is helpful to be able to translate IP addresses generated by normal routing
29112 mechanisms into other IP addresses, thus performing a kind of manual IP
29113 routing. This should be done only if the normal IP routing of the TCP/IP stack
29114 is inadequate or broken. Because this is an extremely uncommon requirement, the
29115 code to support this option is not included in the Exim binary unless
29116 SUPPORT_TRANSLATE_IP_ADDRESS=yes is set in <filename>Local/Makefile</filename>.
29117 </para>
29118 <para>
29119 <indexterm role="concept">
29120 <primary><varname>$host_address</varname></primary>
29121 </indexterm>
29122 The <option>translate_ip_address</option> string is expanded for every IP address generated
29123 by the router, with the generated address set in <varname>$host_address</varname>. If the
29124 expansion is forced to fail, no action is taken.
29125 For any other expansion error, delivery of the message is deferred.
29126 If the result of the expansion is an IP address, that replaces the original
29127 address; otherwise the result is assumed to be a host name &ndash; this is looked
29128 up using <function>gethostbyname()</function> (or <function>getipnodebyname()</function> when available) to
29129 produce one or more replacement IP addresses. For example, to subvert all IP
29130 addresses in some specific networks, this could be added to a router:
29131 </para>
29132 <literallayout class="monospaced">
29133 translate_ip_address = \
29134   ${lookup{${mask:$host_address/26}}lsearch{/some/file}\
29135     {$value}fail}}
29136 </literallayout>
29137 <para>
29138 The file would contain lines like
29139 </para>
29140 <literallayout class="monospaced">
29141 10.2.3.128/26    some.host
29142 10.8.4.34/26     10.44.8.15
29143 </literallayout>
29144 <para>
29145 You should not make use of this facility unless you really understand what you
29146 are doing.
29147 </para>
29148 <para>
29149 <indexterm role="option">
29150 <primary>transport</primary>
29151 </indexterm>
29152 </para>
29153 <informaltable frame="all">
29154 <tgroup cols="4" colsep="0" rowsep="0">
29155 <colspec colwidth="8*" align="left"/>
29156 <colspec colwidth="5*" align="center"/>
29157 <colspec colwidth="5*" align="center"/>
29158 <colspec colwidth="6*" align="right"/>
29159 <tbody>
29160 <row>
29161 <entry><option>transport</option></entry>
29162 <entry>Use: <emphasis>routers</emphasis></entry>
29163 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29164 <entry>Default: <emphasis>unset</emphasis></entry>
29165 </row>
29166 </tbody>
29167 </tgroup>
29168 </informaltable>
29169 <para>
29170 This option specifies the transport to be used when a router accepts an address
29171 and sets it up for delivery. A transport is never needed if a router is used
29172 only for verification. The value of the option is expanded at routing time,
29173 after the expansion of <option>errors_to</option>, <option>headers_add</option>, and <option>headers_remove</option>,
29174 and result must be the name of one of the configured transports. If it is not,
29175 delivery is deferred.
29176 </para>
29177 <para>
29178 The <option>transport</option> option is not used by the <command>redirect</command> router, but it does
29179 have some private options that set up transports for pipe and file deliveries
29180 (see chapter <xref linkend="CHAPredirect"/>).
29181 </para>
29182 <para>
29183 <indexterm role="option">
29184 <primary>transport_current_directory</primary>
29185 </indexterm>
29186 </para>
29187 <informaltable frame="all">
29188 <tgroup cols="4" colsep="0" rowsep="0">
29189 <colspec colwidth="8*" align="left"/>
29190 <colspec colwidth="5*" align="center"/>
29191 <colspec colwidth="5*" align="center"/>
29192 <colspec colwidth="6*" align="right"/>
29193 <tbody>
29194 <row>
29195 <entry><option>transport_current_directory</option></entry>
29196 <entry>Use: <emphasis>routers</emphasis></entry>
29197 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29198 <entry>Default: <emphasis>unset</emphasis></entry>
29199 </row>
29200 </tbody>
29201 </tgroup>
29202 </informaltable>
29203 <para>
29204 <indexterm role="concept">
29205 <primary>current directory for local transport</primary>
29206 </indexterm>
29207 This option associates a current directory with any address that is routed
29208 to a local transport. This can happen either because a transport is
29209 explicitly configured for the router, or because it generates a delivery to a
29210 file or a pipe. During the delivery process (that is, at transport time), this
29211 option string is expanded and is set as the current directory, unless
29212 overridden by a setting on the transport.
29213 If the expansion fails for any reason, including forced failure, an error is
29214 logged, and delivery is deferred.
29215 See chapter <xref linkend="CHAPenvironment"/> for details of the local delivery
29216 environment.
29217 </para>
29218 <para>
29219 <indexterm role="option">
29220 <primary>transport_home_directory</primary>
29221 </indexterm>
29222 </para>
29223 <informaltable frame="all">
29224 <tgroup cols="4" colsep="0" rowsep="0">
29225 <colspec colwidth="8*" align="left"/>
29226 <colspec colwidth="5*" align="center"/>
29227 <colspec colwidth="5*" align="center"/>
29228 <colspec colwidth="6*" align="right"/>
29229 <tbody>
29230 <row>
29231 <entry><option>transport_home_directory</option></entry>
29232 <entry>Use: <emphasis>routers</emphasis></entry>
29233 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29234 <entry>Default: <emphasis>see below</emphasis></entry>
29235 </row>
29236 </tbody>
29237 </tgroup>
29238 </informaltable>
29239 <para>
29240 <indexterm role="concept">
29241 <primary>home directory</primary>
29242 <secondary>for local transport</secondary>
29243 </indexterm>
29244 This option associates a home directory with any address that is routed to a
29245 local transport. This can happen either because a transport is explicitly
29246 configured for the router, or because it generates a delivery to a file or a
29247 pipe. During the delivery process (that is, at transport time), the option
29248 string is expanded and is set as the home directory, unless overridden by a
29249 setting of <option>home_directory</option> on the transport.
29250 If the expansion fails for any reason, including forced failure, an error is
29251 logged, and delivery is deferred.
29252 </para>
29253 <para>
29254 If the transport does not specify a home directory, and
29255 <option>transport_home_directory</option> is not set for the router, the home directory for
29256 the tranport is taken from the password data if <option>check_local_user</option> is set for
29257 the router. Otherwise it is taken from <option>router_home_directory</option> if that option
29258 is set; if not, no home directory is set for the transport.
29259 </para>
29260 <para>
29261 See chapter <xref linkend="CHAPenvironment"/> for further details of the local delivery
29262 environment.
29263 </para>
29264 <para>
29265 <indexterm role="option">
29266 <primary>unseen</primary>
29267 </indexterm>
29268 </para>
29269 <informaltable frame="all">
29270 <tgroup cols="4" colsep="0" rowsep="0">
29271 <colspec colwidth="8*" align="left"/>
29272 <colspec colwidth="5*" align="center"/>
29273 <colspec colwidth="5*" align="center"/>
29274 <colspec colwidth="6*" align="right"/>
29275 <tbody>
29276 <row>
29277 <entry><option>unseen</option></entry>
29278 <entry>Use: <emphasis>routers</emphasis></entry>
29279 <entry>Type: <emphasis>boolean</emphasis>&dagger;<emphasis></emphasis></entry>
29280 <entry>Default: <emphasis>false</emphasis></entry>
29281 </row>
29282 </tbody>
29283 </tgroup>
29284 </informaltable>
29285 <para>
29286 <indexterm role="concept">
29287 <primary>router</primary>
29288 <secondary>carrying on after success</secondary>
29289 </indexterm>
29290 The result of string expansion for this option must be a valid boolean value,
29291 that is, one of the strings <quote>yes</quote>, <quote>no</quote>, <quote>true</quote>, or <quote>false</quote>. Any other
29292 result causes an error, and delivery is deferred. If the expansion is forced to
29293 fail, the default value for the option (false) is used. Other failures cause
29294 delivery to be deferred.
29295 </para>
29296 <para>
29297 When this option is set true, routing does not cease if the router accepts the
29298 address. Instead, a copy of the incoming address is passed to the next router,
29299 overriding a false setting of <option>more</option>. There is little point in setting
29300 <option>more</option> false if <option>unseen</option> is always true, but it may be useful in cases when
29301 the value of <option>unseen</option> contains expansion items (and therefore, presumably, is
29302 sometimes true and sometimes false).
29303 </para>
29304 <para>
29305 <indexterm role="concept">
29306 <primary>copy of message (<option>unseen</option> option)</primary>
29307 </indexterm>
29308 The <option>unseen</option> option can be used to cause copies of messages to be delivered
29309 to some other destination, while also carrying out a normal delivery. In
29310 effect, the current address is made into a <quote>parent</quote> that has two children &ndash;
29311 one that is delivered as specified by this router, and a clone that goes on to
29312 be routed further. For this reason, <option>unseen</option> may not be combined with the
29313 <option>one_time</option> option in a <command>redirect</command> router.
29314 </para>
29315 <para>
29316 <emphasis role="bold">Warning</emphasis>: Header lines added to the address (or specified for removal) by
29317 this router or by previous routers affect the <quote>unseen</quote> copy of the message
29318 only. The clone that continues to be processed by further routers starts with
29319 no added headers and none specified for removal. However, any data that was set
29320 by the <option>address_data</option> option in the current or previous routers is passed on.
29321 Setting the <option>unseen</option> option has a similar effect to the <option>unseen</option> command
29322 qualifier in filter files.
29323 </para>
29324 <para>
29325 <indexterm role="option">
29326 <primary>user</primary>
29327 </indexterm>
29328 </para>
29329 <informaltable frame="all">
29330 <tgroup cols="4" colsep="0" rowsep="0">
29331 <colspec colwidth="8*" align="left"/>
29332 <colspec colwidth="5*" align="center"/>
29333 <colspec colwidth="5*" align="center"/>
29334 <colspec colwidth="6*" align="right"/>
29335 <tbody>
29336 <row>
29337 <entry><option>user</option></entry>
29338 <entry>Use: <emphasis>routers</emphasis></entry>
29339 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29340 <entry>Default: <emphasis>see below</emphasis></entry>
29341 </row>
29342 </tbody>
29343 </tgroup>
29344 </informaltable>
29345 <para>
29346 <indexterm role="concept">
29347 <primary>uid (user id)</primary>
29348 <secondary>local delivery</secondary>
29349 </indexterm>
29350 <indexterm role="concept">
29351 <primary>local transports</primary>
29352 <secondary>uid and gid</secondary>
29353 </indexterm>
29354 <indexterm role="concept">
29355 <primary>transport</primary>
29356 <secondary>local</secondary>
29357 </indexterm>
29358 <indexterm role="concept">
29359 <primary>router</primary>
29360 <secondary>user for filter processing</secondary>
29361 </indexterm>
29362 <indexterm role="concept">
29363 <primary>filter</primary>
29364 <secondary>user for processing</secondary>
29365 </indexterm>
29366 When a router queues an address for a transport, and the transport does not
29367 specify a user, the user given here is used when running the delivery process.
29368 The user may be specified numerically or by name. If expansion fails, the
29369 error is logged and delivery is deferred.
29370 This user is also used by the <command>redirect</command> router when running a filter file.
29371 The default is unset, except when <option>check_local_user</option> is set. In this case,
29372 the default is taken from the password information. If the user is specified as
29373 a name, and <option>group</option> is not set, the group associated with the user is used.
29374 See also <option>initgroups</option> and <option>group</option> and the discussion in chapter
29375 <xref linkend="CHAPenvironment"/>.
29376 </para>
29377 <para>
29378 <indexterm role="option">
29379 <primary>verify</primary>
29380 </indexterm>
29381 </para>
29382 <informaltable frame="all">
29383 <tgroup cols="4" colsep="0" rowsep="0">
29384 <colspec colwidth="8*" align="left"/>
29385 <colspec colwidth="5*" align="center"/>
29386 <colspec colwidth="5*" align="center"/>
29387 <colspec colwidth="6*" align="right"/>
29388 <tbody>
29389 <row>
29390 <entry><option>verify</option></entry>
29391 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29392 <entry>Type: <emphasis>boolean</emphasis></entry>
29393 <entry>Default: <emphasis>true</emphasis></entry>
29394 </row>
29395 </tbody>
29396 </tgroup>
29397 </informaltable>
29398 <para>
29399 Setting this option has the effect of setting <option>verify_sender</option> and
29400 <option>verify_recipient</option> to the same value.
29401 </para>
29402 <para>
29403 <indexterm role="option">
29404 <primary>verify_only</primary>
29405 </indexterm>
29406 </para>
29407 <informaltable frame="all">
29408 <tgroup cols="4" colsep="0" rowsep="0">
29409 <colspec colwidth="8*" align="left"/>
29410 <colspec colwidth="5*" align="center"/>
29411 <colspec colwidth="5*" align="center"/>
29412 <colspec colwidth="6*" align="right"/>
29413 <tbody>
29414 <row>
29415 <entry><option>verify_only</option></entry>
29416 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29417 <entry>Type: <emphasis>boolean</emphasis></entry>
29418 <entry>Default: <emphasis>false</emphasis></entry>
29419 </row>
29420 </tbody>
29421 </tgroup>
29422 </informaltable>
29423 <para>
29424 <indexterm role="concept">
29425 <primary>EXPN</primary>
29426 <secondary>with <option>verify_only</option></secondary>
29427 </indexterm>
29428 <indexterm role="concept">
29429 <primary><option>-bv</option> option</primary>
29430 </indexterm>
29431 <indexterm role="concept">
29432 <primary>router</primary>
29433 <secondary>used only when verifying</secondary>
29434 </indexterm>
29435 If this option is set, the router is used only when verifying an address or
29436 testing with the <option>-bv</option> option, not when actually doing a delivery, testing
29437 with the <option>-bt</option> option, or running the SMTP EXPN command. It can be further
29438 restricted to verifying only senders or recipients by means of
29439 <option>verify_sender</option> and <option>verify_recipient</option>.
29440 </para>
29441 <para>
29442 <emphasis role="bold">Warning</emphasis>: When the router is being run to verify addresses for an incoming
29443 SMTP message, Exim is not running as root, but under its own uid. If the router
29444 accesses any files, you need to make sure that they are accessible to the Exim
29445 user or group.
29446 </para>
29447 <para>
29448 <indexterm role="option">
29449 <primary>verify_recipient</primary>
29450 </indexterm>
29451 </para>
29452 <informaltable frame="all">
29453 <tgroup cols="4" colsep="0" rowsep="0">
29454 <colspec colwidth="8*" align="left"/>
29455 <colspec colwidth="5*" align="center"/>
29456 <colspec colwidth="5*" align="center"/>
29457 <colspec colwidth="6*" align="right"/>
29458 <tbody>
29459 <row>
29460 <entry><option>verify_recipient</option></entry>
29461 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29462 <entry>Type: <emphasis>boolean</emphasis></entry>
29463 <entry>Default: <emphasis>true</emphasis></entry>
29464 </row>
29465 </tbody>
29466 </tgroup>
29467 </informaltable>
29468 <para>
29469 If this option is false, the router is skipped when verifying recipient
29470 addresses
29471 or testing recipient verification using <option>-bv</option>.
29472 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
29473 are evaluated.
29474 </para>
29475 <para>
29476 <indexterm role="option">
29477 <primary>verify_sender</primary>
29478 </indexterm>
29479 </para>
29480 <informaltable frame="all">
29481 <tgroup cols="4" colsep="0" rowsep="0">
29482 <colspec colwidth="8*" align="left"/>
29483 <colspec colwidth="5*" align="center"/>
29484 <colspec colwidth="5*" align="center"/>
29485 <colspec colwidth="6*" align="right"/>
29486 <tbody>
29487 <row>
29488 <entry><option>verify_sender</option></entry>
29489 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29490 <entry>Type: <emphasis>boolean</emphasis></entry>
29491 <entry>Default: <emphasis>true</emphasis></entry>
29492 </row>
29493 </tbody>
29494 </tgroup>
29495 </informaltable>
29496 <para>
29497 If this option is false, the router is skipped when verifying sender addresses
29498 or testing sender verification using <option>-bvs</option>.
29499 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
29500 are evaluated.
29501 <indexterm role="concept" startref="IIDgenoprou1" class="endofrange"/>
29502 <indexterm role="concept" startref="IIDgenoprou2" class="endofrange"/>
29503 </para>
29504 </chapter>
29505
29506 <chapter>
29507 <title>The accept router</title>
29508 <para>
29509 <indexterm role="concept">
29510 <primary><command>accept</command> router</primary>
29511 </indexterm>
29512 <indexterm role="concept">
29513 <primary>routers</primary>
29514 <secondary><command>accept</command></secondary>
29515 </indexterm>
29516 The <command>accept</command> router has no private options of its own. Unless it is being
29517 used purely for verification (see <option>verify_only</option>) a transport is required to
29518 be defined by the generic <option>transport</option> option. If the preconditions that are
29519 specified by generic options are met, the router accepts the address and queues
29520 it for the given transport. The most common use of this router is for setting
29521 up deliveries to local mailboxes. For example:
29522 </para>
29523 <literallayout class="monospaced">
29524 localusers:
29525   driver = accept
29526   domains = mydomain.example
29527   check_local_user
29528   transport = local_delivery
29529 </literallayout>
29530 <para>
29531 The <option>domains</option> condition in this example checks the domain of the address, and
29532 <option>check_local_user</option> checks that the local part is the login of a local user.
29533 When both preconditions are met, the <command>accept</command> router runs, and queues the
29534 address for the <command>local_delivery</command> transport.
29535 </para>
29536 </chapter>
29537
29538 <chapter id="CHAPdnslookup">
29539 <title>The dnslookup router</title>
29540 <para>
29541 <indexterm role="concept" id="IIDdnsrou1" class="startofrange">
29542 <primary><command>dnslookup</command> router</primary>
29543 </indexterm>
29544 <indexterm role="concept" id="IIDdnsrou2" class="startofrange">
29545 <primary>routers</primary>
29546 <secondary><command>dnslookup</command></secondary>
29547 </indexterm>
29548 The <command>dnslookup</command> router looks up the hosts that handle mail for the
29549 recipient&#x2019;s domain in the DNS. A transport must always be set for this router,
29550 unless <option>verify_only</option> is set.
29551 </para>
29552 <para>
29553 If SRV support is configured (see <option>check_srv</option> below), Exim first searches for
29554 SRV records. If none are found, or if SRV support is not configured,
29555 MX records are looked up. If no MX records exist, address records are sought.
29556 However, <option>mx_domains</option> can be set to disable the direct use of address
29557 records.
29558 </para>
29559 <para>
29560 MX records of equal priority are sorted by Exim into a random order. Exim then
29561 looks for address records for the host names obtained from MX or SRV records.
29562 When a host has more than one IP address, they are sorted into a random order,
29563 except that IPv6 addresses are always sorted before IPv4 addresses. If all the
29564 IP addresses found are discarded by a setting of the <option>ignore_target_hosts</option>
29565 generic option, the router declines.
29566 </para>
29567 <para>
29568 Unless they have the highest priority (lowest MX value), MX records that point
29569 to the local host, or to any host name that matches <option>hosts_treat_as_local</option>,
29570 are discarded, together with any other MX records of equal or lower priority.
29571 </para>
29572 <para>
29573 <indexterm role="concept">
29574 <primary>MX record</primary>
29575 <secondary>pointing to local host</secondary>
29576 </indexterm>
29577 <indexterm role="concept">
29578 <primary>local host</primary>
29579 <secondary>MX pointing to</secondary>
29580 </indexterm>
29581 <indexterm role="concept">
29582 <primary><option>self</option> option</primary>
29583 <secondary>in <command>dnslookup</command> router</secondary>
29584 </indexterm>
29585 If the host pointed to by the highest priority MX record, or looked up as an
29586 address record, is the local host, or matches <option>hosts_treat_as_local</option>, what
29587 happens is controlled by the generic <option>self</option> option.
29588 </para>
29589 <section id="SECTprowitdnsloo">
29590 <title>Problems with DNS lookups</title>
29591 <para>
29592 There have been problems with DNS servers when SRV records are looked up.
29593 Some mis-behaving servers return a DNS error or timeout when a non-existent
29594 SRV record is sought. Similar problems have in the past been reported for
29595 MX records. The global <option>dns_again_means_nonexist</option> option can help with this
29596 problem, but it is heavy-handed because it is a global option.
29597 </para>
29598 <para>
29599 For this reason, there are two options, <option>srv_fail_domains</option> and
29600 <option>mx_fail_domains</option>, that control what happens when a DNS lookup in a
29601 <command>dnslookup</command> router results in a DNS failure or a <quote>try again</quote> response. If
29602 an attempt to look up an SRV or MX record causes one of these results, and the
29603 domain matches the relevant list, Exim behaves as if the DNS had responded <quote>no
29604 such record</quote>. In the case of an SRV lookup, this means that the router
29605 proceeds to look for MX records; in the case of an MX lookup, it proceeds to
29606 look for A or AAAA records, unless the domain matches <option>mx_domains</option>, in which
29607 case routing fails.
29608 </para>
29609 </section>
29610 <section>
29611 <title>Private options for dnslookup</title>
29612 <para>
29613 <indexterm role="concept">
29614 <primary>options</primary>
29615 <secondary><command>dnslookup</command> router</secondary>
29616 </indexterm>
29617 The private options for the <command>dnslookup</command> router are as follows:
29618 </para>
29619 <para>
29620 <indexterm role="option">
29621 <primary>check_secondary_mx</primary>
29622 </indexterm>
29623 </para>
29624 <informaltable frame="all">
29625 <tgroup cols="4" colsep="0" rowsep="0">
29626 <colspec colwidth="8*" align="left"/>
29627 <colspec colwidth="5*" align="center"/>
29628 <colspec colwidth="5*" align="center"/>
29629 <colspec colwidth="6*" align="right"/>
29630 <tbody>
29631 <row>
29632 <entry><option>check_secondary_mx</option></entry>
29633 <entry>Use: <emphasis>dnslookup</emphasis></entry>
29634 <entry>Type: <emphasis>boolean</emphasis></entry>
29635 <entry>Default: <emphasis>false</emphasis></entry>
29636 </row>
29637 </tbody>
29638 </tgroup>
29639 </informaltable>
29640 <para>
29641 <indexterm role="concept">
29642 <primary>MX record</primary>
29643 <secondary>checking for secondary</secondary>
29644 </indexterm>
29645 If this option is set, the router declines unless the local host is found in
29646 (and removed from) the list of hosts obtained by MX lookup. This can be used to
29647 process domains for which the local host is a secondary mail exchanger
29648 differently to other domains. The way in which Exim decides whether a host is
29649 the local host is described in section <xref linkend="SECTreclocipadd"/>.
29650 </para>
29651 <para>
29652 <indexterm role="option">
29653 <primary>check_srv</primary>
29654 </indexterm>
29655 </para>
29656 <informaltable frame="all">
29657 <tgroup cols="4" colsep="0" rowsep="0">
29658 <colspec colwidth="8*" align="left"/>
29659 <colspec colwidth="5*" align="center"/>
29660 <colspec colwidth="5*" align="center"/>
29661 <colspec colwidth="6*" align="right"/>
29662 <tbody>
29663 <row>
29664 <entry><option>check_srv</option></entry>
29665 <entry>Use: <emphasis>dnslookup</emphasis></entry>
29666 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29667 <entry>Default: <emphasis>unset</emphasis></entry>
29668 </row>
29669 </tbody>
29670 </tgroup>
29671 </informaltable>
29672 <para>
29673 <indexterm role="concept">
29674 <primary>SRV record</primary>
29675 <secondary>enabling use of</secondary>
29676 </indexterm>
29677 The <command>dnslookup</command> router supports the use of SRV records (see RFC 2782) in
29678 addition to MX and address records. The support is disabled by default. To
29679 enable SRV support, set the <option>check_srv</option> option to the name of the service
29680 required. For example,
29681 </para>
29682 <literallayout class="monospaced">
29683 check_srv = smtp
29684 </literallayout>
29685 <para>
29686 looks for SRV records that refer to the normal smtp service. The option is
29687 expanded, so the service name can vary from message to message or address
29688 to address. This might be helpful if SRV records are being used for a
29689 submission service. If the expansion is forced to fail, the <option>check_srv</option>
29690 option is ignored, and the router proceeds to look for MX records in the
29691 normal way.
29692 </para>
29693 <para>
29694 When the expansion succeeds, the router searches first for SRV records for
29695 the given service (it assumes TCP protocol). A single SRV record with a
29696 host name that consists of just a single dot indicates <quote>no such service for
29697 this domain</quote>; if this is encountered, the router declines. If other kinds of
29698 SRV record are found, they are used to construct a host list for delivery
29699 according to the rules of RFC 2782. MX records are not sought in this case.
29700 </para>
29701 <para>
29702 When no SRV records are found, MX records (and address records) are sought in
29703 the traditional way. In other words, SRV records take precedence over MX
29704 records, just as MX records take precedence over address records. Note that
29705 this behaviour is not sanctioned by RFC 2782, though a previous draft RFC
29706 defined it. It is apparently believed that MX records are sufficient for email
29707 and that SRV records should not be used for this purpose. However, SRV records
29708 have an additional <quote>weight</quote> feature which some people might find useful when
29709 trying to split an SMTP load between hosts of different power.
29710 </para>
29711 <para>
29712 See section <xref linkend="SECTprowitdnsloo"/> above for a discussion of Exim&#x2019;s behaviour
29713 when there is a DNS lookup error.
29714 </para>
29715 <para>
29716 <indexterm role="option">
29717 <primary>mx_domains</primary>
29718 </indexterm>
29719 </para>
29720 <informaltable frame="all">
29721 <tgroup cols="4" colsep="0" rowsep="0">
29722 <colspec colwidth="8*" align="left"/>
29723 <colspec colwidth="5*" align="center"/>
29724 <colspec colwidth="5*" align="center"/>
29725 <colspec colwidth="6*" align="right"/>
29726 <tbody>
29727 <row>
29728 <entry><option>mx_domains</option></entry>
29729 <entry>Use: <emphasis>dnslookup</emphasis></entry>
29730 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
29731 <entry>Default: <emphasis>unset</emphasis></entry>
29732 </row>
29733 </tbody>
29734 </tgroup>
29735 </informaltable>
29736 <para>
29737 <indexterm role="concept">
29738 <primary>MX record</primary>
29739 <secondary>required to exist</secondary>
29740 </indexterm>
29741 <indexterm role="concept">
29742 <primary>SRV record</primary>
29743 <secondary>required to exist</secondary>
29744 </indexterm>
29745 A domain that matches <option>mx_domains</option> is required to have either an MX or an SRV
29746 record in order to be recognised. (The name of this option could be improved.)
29747 For example, if all the mail hosts in <emphasis>fict.example</emphasis> are known to have MX
29748 records, except for those in <emphasis>discworld.fict.example</emphasis>, you could use this
29749 setting:
29750 </para>
29751 <literallayout class="monospaced">
29752 mx_domains = ! *.discworld.fict.example : *.fict.example
29753 </literallayout>
29754 <para>
29755 This specifies that messages addressed to a domain that matches the list but
29756 has no MX record should be bounced immediately instead of being routed using
29757 the address record.
29758 </para>
29759 <para>
29760 <indexterm role="option">
29761 <primary>mx_fail_domains</primary>
29762 </indexterm>
29763 </para>
29764 <informaltable frame="all">
29765 <tgroup cols="4" colsep="0" rowsep="0">
29766 <colspec colwidth="8*" align="left"/>
29767 <colspec colwidth="5*" align="center"/>
29768 <colspec colwidth="5*" align="center"/>
29769 <colspec colwidth="6*" align="right"/>
29770 <tbody>
29771 <row>
29772 <entry><option>mx_fail_domains</option></entry>
29773 <entry>Use: <emphasis>dnslookup</emphasis></entry>
29774 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
29775 <entry>Default: <emphasis>unset</emphasis></entry>
29776 </row>
29777 </tbody>
29778 </tgroup>
29779 </informaltable>
29780 <para>
29781 If the DNS lookup for MX records for one of the domains in this list causes a
29782 DNS lookup error, Exim behaves as if no MX records were found. See section
29783 <xref linkend="SECTprowitdnsloo"/> for more discussion.
29784 </para>
29785 <para>
29786 <indexterm role="option">
29787 <primary>qualify_single</primary>
29788 </indexterm>
29789 </para>
29790 <informaltable frame="all">
29791 <tgroup cols="4" colsep="0" rowsep="0">
29792 <colspec colwidth="8*" align="left"/>
29793 <colspec colwidth="5*" align="center"/>
29794 <colspec colwidth="5*" align="center"/>
29795 <colspec colwidth="6*" align="right"/>
29796 <tbody>
29797 <row>
29798 <entry><option>qualify_single</option></entry>
29799 <entry>Use: <emphasis>dnslookup</emphasis></entry>
29800 <entry>Type: <emphasis>boolean</emphasis></entry>
29801 <entry>Default: <emphasis>true</emphasis></entry>
29802 </row>
29803 </tbody>
29804 </tgroup>
29805 </informaltable>
29806 <para>
29807 <indexterm role="concept">
29808 <primary>DNS</primary>
29809 <secondary>resolver options</secondary>
29810 </indexterm>
29811 <indexterm role="concept">
29812 <primary>DNS</primary>
29813 <secondary>qualifying single-component names</secondary>
29814 </indexterm>
29815 When this option is true, the resolver option RES_DEFNAMES is set for DNS
29816 lookups. Typically, but not standardly, this causes the resolver to qualify
29817 single-component names with the default domain. For example, on a machine
29818 called <emphasis>dictionary.ref.example</emphasis>, the domain <emphasis>thesaurus</emphasis> would be changed to
29819 <emphasis>thesaurus.ref.example</emphasis> inside the resolver. For details of what your
29820 resolver actually does, consult your man pages for <emphasis>resolver</emphasis> and
29821 <emphasis>resolv.conf</emphasis>.
29822 </para>
29823 <para>
29824 <indexterm role="option">
29825 <primary>rewrite_headers</primary>
29826 </indexterm>
29827 </para>
29828 <informaltable frame="all">
29829 <tgroup cols="4" colsep="0" rowsep="0">
29830 <colspec colwidth="8*" align="left"/>
29831 <colspec colwidth="5*" align="center"/>
29832 <colspec colwidth="5*" align="center"/>
29833 <colspec colwidth="6*" align="right"/>
29834 <tbody>
29835 <row>
29836 <entry><option>rewrite_headers</option></entry>
29837 <entry>Use: <emphasis>dnslookup</emphasis></entry>
29838 <entry>Type: <emphasis>boolean</emphasis></entry>
29839 <entry>Default: <emphasis>true</emphasis></entry>
29840 </row>
29841 </tbody>
29842 </tgroup>
29843 </informaltable>
29844 <para>
29845 <indexterm role="concept">
29846 <primary>rewriting</primary>
29847 <secondary>header lines</secondary>
29848 </indexterm>
29849 <indexterm role="concept">
29850 <primary>header lines</primary>
29851 <secondary>rewriting</secondary>
29852 </indexterm>
29853 If the domain name in the address that is being processed is not fully
29854 qualified, it may be expanded to its full form by a DNS lookup. For example, if
29855 an address is specified as <emphasis>dormouse@teaparty</emphasis>, the domain might be
29856 expanded to <emphasis>teaparty.wonderland.fict.example</emphasis>. Domain expansion can also
29857 occur as a result of setting the <option>widen_domains</option> option. If
29858 <option>rewrite_headers</option> is true, all occurrences of the abbreviated domain name in
29859 any <emphasis>Bcc:</emphasis>, <emphasis>Cc:</emphasis>, <emphasis>From:</emphasis>, <emphasis>Reply-to:</emphasis>, <emphasis>Sender:</emphasis>, and <emphasis>To:</emphasis>
29860 header lines of the message are rewritten with the full domain name.
29861 </para>
29862 <para>
29863 This option should be turned off only when it is known that no message is
29864 ever going to be sent outside an environment where the abbreviation makes
29865 sense.
29866 </para>
29867 <para>
29868 When an MX record is looked up in the DNS and matches a wildcard record, name
29869 servers normally return a record containing the name that has been looked up,
29870 making it impossible to detect whether a wildcard was present or not. However,
29871 some name servers have recently been seen to return the wildcard entry. If the
29872 name returned by a DNS lookup begins with an asterisk, it is not used for
29873 header rewriting.
29874 </para>
29875 <para>
29876 <indexterm role="option">
29877 <primary>same_domain_copy_routing</primary>
29878 </indexterm>
29879 </para>
29880 <informaltable frame="all">
29881 <tgroup cols="4" colsep="0" rowsep="0">
29882 <colspec colwidth="8*" align="left"/>
29883 <colspec colwidth="5*" align="center"/>
29884 <colspec colwidth="5*" align="center"/>
29885 <colspec colwidth="6*" align="right"/>
29886 <tbody>
29887 <row>
29888 <entry><option>same_domain_copy_routing</option></entry>
29889 <entry>Use: <emphasis>dnslookup</emphasis></entry>
29890 <entry>Type: <emphasis>boolean</emphasis></entry>
29891 <entry>Default: <emphasis>false</emphasis></entry>
29892 </row>
29893 </tbody>
29894 </tgroup>
29895 </informaltable>
29896 <para>
29897 <indexterm role="concept">
29898 <primary>address</primary>
29899 <secondary>copying routing</secondary>
29900 </indexterm>
29901 Addresses with the same domain are normally routed by the <command>dnslookup</command> router
29902 to the same list of hosts. However, this cannot be presumed, because the router
29903 options and preconditions may refer to the local part of the address. By
29904 default, therefore, Exim routes each address in a message independently. DNS
29905 servers run caches, so repeated DNS lookups are not normally expensive, and in
29906 any case, personal messages rarely have more than a few recipients.
29907 </para>
29908 <para>
29909 If you are running mailing lists with large numbers of subscribers at the same
29910 domain, and you are using a <command>dnslookup</command> router which is independent of the
29911 local part, you can set <option>same_domain_copy_routing</option> to bypass repeated DNS
29912 lookups for identical domains in one message. In this case, when <command>dnslookup</command>
29913 routes an address to a remote transport, any other unrouted addresses in the
29914 message that have the same domain are automatically given the same routing
29915 without processing them independently,
29916 provided the following conditions are met:
29917 </para>
29918 <itemizedlist>
29919 <listitem>
29920 <para>
29921 No router that processed the address specified <option>headers_add</option> or
29922 <option>headers_remove</option>.
29923 </para>
29924 </listitem>
29925 <listitem>
29926 <para>
29927 The router did not change the address in any way, for example, by <quote>widening</quote>
29928 the domain.
29929 </para>
29930 </listitem>
29931 </itemizedlist>
29932 <para>
29933 <indexterm role="option">
29934 <primary>search_parents</primary>
29935 </indexterm>
29936 </para>
29937 <informaltable frame="all">
29938 <tgroup cols="4" colsep="0" rowsep="0">
29939 <colspec colwidth="8*" align="left"/>
29940 <colspec colwidth="5*" align="center"/>
29941 <colspec colwidth="5*" align="center"/>
29942 <colspec colwidth="6*" align="right"/>
29943 <tbody>
29944 <row>
29945 <entry><option>search_parents</option></entry>
29946 <entry>Use: <emphasis>dnslookup</emphasis></entry>
29947 <entry>Type: <emphasis>boolean</emphasis></entry>
29948 <entry>Default: <emphasis>false</emphasis></entry>
29949 </row>
29950 </tbody>
29951 </tgroup>
29952 </informaltable>
29953 <para>
29954 <indexterm role="concept">
29955 <primary>DNS</primary>
29956 <secondary>resolver options</secondary>
29957 </indexterm>
29958 When this option is true, the resolver option RES_DNSRCH is set for DNS
29959 lookups. This is different from the <option>qualify_single</option> option in that it
29960 applies to domains containing dots. Typically, but not standardly, it causes
29961 the resolver to search for the name in the current domain and in parent
29962 domains. For example, on a machine in the <emphasis>fict.example</emphasis> domain, if looking
29963 up <emphasis>teaparty.wonderland</emphasis> failed, the resolver would try
29964 <emphasis>teaparty.wonderland.fict.example</emphasis>. For details of what your resolver
29965 actually does, consult your man pages for <emphasis>resolver</emphasis> and <emphasis>resolv.conf</emphasis>.
29966 </para>
29967 <para>
29968 Setting this option true can cause problems in domains that have a wildcard MX
29969 record, because any domain that does not have its own MX record matches the
29970 local wildcard.
29971 </para>
29972 <para>
29973 <indexterm role="option">
29974 <primary>srv_fail_domains</primary>
29975 </indexterm>
29976 </para>
29977 <informaltable frame="all">
29978 <tgroup cols="4" colsep="0" rowsep="0">
29979 <colspec colwidth="8*" align="left"/>
29980 <colspec colwidth="5*" align="center"/>
29981 <colspec colwidth="5*" align="center"/>
29982 <colspec colwidth="6*" align="right"/>
29983 <tbody>
29984 <row>
29985 <entry><option>srv_fail_domains</option></entry>
29986 <entry>Use: <emphasis>dnslookup</emphasis></entry>
29987 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
29988 <entry>Default: <emphasis>unset</emphasis></entry>
29989 </row>
29990 </tbody>
29991 </tgroup>
29992 </informaltable>
29993 <para>
29994 If the DNS lookup for SRV records for one of the domains in this list causes a
29995 DNS lookup error, Exim behaves as if no SRV records were found. See section
29996 <xref linkend="SECTprowitdnsloo"/> for more discussion.
29997 </para>
29998 <para>
29999 <indexterm role="option">
30000 <primary>widen_domains</primary>
30001 </indexterm>
30002 </para>
30003 <informaltable frame="all">
30004 <tgroup cols="4" colsep="0" rowsep="0">
30005 <colspec colwidth="8*" align="left"/>
30006 <colspec colwidth="5*" align="center"/>
30007 <colspec colwidth="5*" align="center"/>
30008 <colspec colwidth="6*" align="right"/>
30009 <tbody>
30010 <row>
30011 <entry><option>widen_domains</option></entry>
30012 <entry>Use: <emphasis>dnslookup</emphasis></entry>
30013 <entry>Type: <emphasis>string list</emphasis></entry>
30014 <entry>Default: <emphasis>unset</emphasis></entry>
30015 </row>
30016 </tbody>
30017 </tgroup>
30018 </informaltable>
30019 <para>
30020 <indexterm role="concept">
30021 <primary>domain</primary>
30022 <secondary>partial; widening</secondary>
30023 </indexterm>
30024 If a DNS lookup fails and this option is set, each of its strings in turn is
30025 added onto the end of the domain, and the lookup is tried again. For example,
30026 if
30027 </para>
30028 <literallayout class="monospaced">
30029 widen_domains = fict.example:ref.example
30030 </literallayout>
30031 <para>
30032 is set and a lookup of <emphasis>klingon.dictionary</emphasis> fails,
30033 <emphasis>klingon.dictionary.fict.example</emphasis> is looked up, and if this fails,
30034 <emphasis>klingon.dictionary.ref.example</emphasis> is tried. Note that the <option>qualify_single</option>
30035 and <option>search_parents</option> options can cause some widening to be undertaken inside
30036 the DNS resolver. <option>widen_domains</option> is not applied to sender addresses
30037 when verifying, unless <option>rewrite_headers</option> is false (not the default).
30038 </para>
30039 </section>
30040 <section>
30041 <title>Effect of qualify_single and search_parents</title>
30042 <para>
30043 When a domain from an envelope recipient is changed by the resolver as a result
30044 of the <option>qualify_single</option> or <option>search_parents</option> options, Exim rewrites the
30045 corresponding address in the message&#x2019;s header lines unless <option>rewrite_headers</option>
30046 is set false. Exim then re-routes the address, using the full domain.
30047 </para>
30048 <para>
30049 These two options affect only the DNS lookup that takes place inside the router
30050 for the domain of the address that is being routed. They do not affect lookups
30051 such as that implied by
30052 </para>
30053 <literallayout class="monospaced">
30054 domains = @mx_any
30055 </literallayout>
30056 <para>
30057 that may happen while processing a router precondition before the router is
30058 entered. No widening ever takes place for these lookups.
30059 <indexterm role="concept" startref="IIDdnsrou1" class="endofrange"/>
30060 <indexterm role="concept" startref="IIDdnsrou2" class="endofrange"/>
30061 </para>
30062 </section>
30063 </chapter>
30064
30065 <chapter>
30066 <title>The ipliteral router</title>
30067 <para>
30068 <indexterm role="concept">
30069 <primary><command>ipliteral</command> router</primary>
30070 </indexterm>
30071 <indexterm role="concept">
30072 <primary>domain literal</primary>
30073 <secondary>routing</secondary>
30074 </indexterm>
30075 <indexterm role="concept">
30076 <primary>routers</primary>
30077 <secondary><command>ipliteral</command></secondary>
30078 </indexterm>
30079 This router has no private options. Unless it is being used purely for
30080 verification (see <option>verify_only</option>) a transport is required to be defined by the
30081 generic <option>transport</option> option. The router accepts the address if its domain part
30082 takes the form of an RFC 2822 domain literal. For example, the <command>ipliteral</command>
30083 router handles the address
30084 </para>
30085 <literallayout class="monospaced">
30086 root@[192.168.1.1]
30087 </literallayout>
30088 <para revisionflag="changed">
30089 by setting up delivery to the host with that IP address. IPv4 domain literals
30090 consist of an IPv4 address enclosed in square brackets. IPv6 domain literals
30091 are similar, but the address is preceded by <literal>ipv6:</literal>. For example:
30092 </para>
30093 <literallayout class="monospaced" revisionflag="changed">
30094 postmaster@[ipv6:fe80::a00:20ff:fe86:a061.5678]
30095 </literallayout>
30096 <para revisionflag="changed">
30097 Exim allows <literal>ipv4:</literal> before IPv4 addresses, for consistency, and on the
30098 grounds that sooner or later somebody will try it.
30099 </para>
30100 <para>
30101 <indexterm role="concept">
30102 <primary><option>self</option> option</primary>
30103 <secondary>in <command>ipliteral</command> router</secondary>
30104 </indexterm>
30105 If the IP address matches something in <option>ignore_target_hosts</option>, the router
30106 declines. If an IP literal turns out to refer to the local host, the generic
30107 <option>self</option> option determines what happens.
30108 </para>
30109 <para>
30110 The RFCs require support for domain literals; however, their use is
30111 controversial in today&#x2019;s Internet. If you want to use this router, you must
30112 also set the main configuration option <option>allow_domain_literals</option>. Otherwise,
30113 Exim will not recognize the domain literal syntax in addresses.
30114 </para>
30115 </chapter>
30116
30117 <chapter>
30118 <title>The iplookup router</title>
30119 <para>
30120 <indexterm role="concept">
30121 <primary><command>iplookup</command> router</primary>
30122 </indexterm>
30123 <indexterm role="concept">
30124 <primary>routers</primary>
30125 <secondary><command>iplookup</command></secondary>
30126 </indexterm>
30127 The <command>iplookup</command> router was written to fulfil a specific requirement in
30128 Cambridge University (which in fact no longer exists). For this reason, it is
30129 not included in the binary of Exim by default. If you want to include it, you
30130 must set
30131 </para>
30132 <literallayout class="monospaced">
30133 ROUTER_IPLOOKUP=yes
30134 </literallayout>
30135 <para>
30136 in your <filename>Local/Makefile</filename> configuration file.
30137 </para>
30138 <para>
30139 The <command>iplookup</command> router routes an address by sending it over a TCP or UDP
30140 connection to one or more specific hosts. The host can then return the same or
30141 a different address &ndash; in effect rewriting the recipient address in the
30142 message&#x2019;s envelope. The new address is then passed on to subsequent routers. If
30143 this process fails, the address can be passed on to other routers, or delivery
30144 can be deferred. Since <command>iplookup</command> is just a rewriting router, a transport
30145 must not be specified for it.
30146 </para>
30147 <para>
30148 <indexterm role="concept">
30149 <primary>options</primary>
30150 <secondary><command>iplookup</command> router</secondary>
30151 </indexterm>
30152 <indexterm role="option">
30153 <primary>hosts</primary>
30154 </indexterm>
30155 </para>
30156 <informaltable frame="all">
30157 <tgroup cols="4" colsep="0" rowsep="0">
30158 <colspec colwidth="8*" align="left"/>
30159 <colspec colwidth="5*" align="center"/>
30160 <colspec colwidth="5*" align="center"/>
30161 <colspec colwidth="6*" align="right"/>
30162 <tbody>
30163 <row>
30164 <entry><option>hosts</option></entry>
30165 <entry>Use: <emphasis>iplookup</emphasis></entry>
30166 <entry>Type: <emphasis>string</emphasis></entry>
30167 <entry>Default: <emphasis>unset</emphasis></entry>
30168 </row>
30169 </tbody>
30170 </tgroup>
30171 </informaltable>
30172 <para>
30173 This option must be supplied. Its value is a colon-separated list of host
30174 names. The hosts are looked up using <function>gethostbyname()</function>
30175 (or <function>getipnodebyname()</function> when available)
30176 and are tried in order until one responds to the query. If none respond, what
30177 happens is controlled by <option>optional</option>.
30178 </para>
30179 <para>
30180 <indexterm role="option">
30181 <primary>optional</primary>
30182 </indexterm>
30183 </para>
30184 <informaltable frame="all">
30185 <tgroup cols="4" colsep="0" rowsep="0">
30186 <colspec colwidth="8*" align="left"/>
30187 <colspec colwidth="5*" align="center"/>
30188 <colspec colwidth="5*" align="center"/>
30189 <colspec colwidth="6*" align="right"/>
30190 <tbody>
30191 <row>
30192 <entry><option>optional</option></entry>
30193 <entry>Use: <emphasis>iplookup</emphasis></entry>
30194 <entry>Type: <emphasis>boolean</emphasis></entry>
30195 <entry>Default: <emphasis>false</emphasis></entry>
30196 </row>
30197 </tbody>
30198 </tgroup>
30199 </informaltable>
30200 <para>
30201 If <option>optional</option> is true, if no response is obtained from any host, the address
30202 is passed to the next router, overriding <option>no_more</option>. If <option>optional</option> is false,
30203 delivery to the address is deferred.
30204 </para>
30205 <para>
30206 <indexterm role="option">
30207 <primary>port</primary>
30208 </indexterm>
30209 </para>
30210 <informaltable frame="all">
30211 <tgroup cols="4" colsep="0" rowsep="0">
30212 <colspec colwidth="8*" align="left"/>
30213 <colspec colwidth="5*" align="center"/>
30214 <colspec colwidth="5*" align="center"/>
30215 <colspec colwidth="6*" align="right"/>
30216 <tbody>
30217 <row>
30218 <entry><option>port</option></entry>
30219 <entry>Use: <emphasis>iplookup</emphasis></entry>
30220 <entry>Type: <emphasis>integer</emphasis></entry>
30221 <entry>Default: <emphasis>0</emphasis></entry>
30222 </row>
30223 </tbody>
30224 </tgroup>
30225 </informaltable>
30226 <para>
30227 <indexterm role="concept">
30228 <primary>port</primary>
30229 <secondary><command>iplookup</command> router</secondary>
30230 </indexterm>
30231 This option must be supplied. It specifies the port number for the TCP or UDP
30232 call.
30233 </para>
30234 <para>
30235 <indexterm role="option">
30236 <primary>protocol</primary>
30237 </indexterm>
30238 </para>
30239 <informaltable frame="all">
30240 <tgroup cols="4" colsep="0" rowsep="0">
30241 <colspec colwidth="8*" align="left"/>
30242 <colspec colwidth="5*" align="center"/>
30243 <colspec colwidth="5*" align="center"/>
30244 <colspec colwidth="6*" align="right"/>
30245 <tbody>
30246 <row>
30247 <entry><option>protocol</option></entry>
30248 <entry>Use: <emphasis>iplookup</emphasis></entry>
30249 <entry>Type: <emphasis>string</emphasis></entry>
30250 <entry>Default: <emphasis>udp</emphasis></entry>
30251 </row>
30252 </tbody>
30253 </tgroup>
30254 </informaltable>
30255 <para>
30256 This option can be set to <quote>udp</quote> or <quote>tcp</quote> to specify which of the two
30257 protocols is to be used.
30258 </para>
30259 <para>
30260 <indexterm role="option">
30261 <primary>query</primary>
30262 </indexterm>
30263 </para>
30264 <informaltable frame="all">
30265 <tgroup cols="4" colsep="0" rowsep="0">
30266 <colspec colwidth="8*" align="left"/>
30267 <colspec colwidth="5*" align="center"/>
30268 <colspec colwidth="5*" align="center"/>
30269 <colspec colwidth="6*" align="right"/>
30270 <tbody>
30271 <row>
30272 <entry><option>query</option></entry>
30273 <entry>Use: <emphasis>iplookup</emphasis></entry>
30274 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30275 <entry>Default: <emphasis><literal>$local_part@$domain $local_part@$domain</literal></emphasis></entry>
30276 </row>
30277 </tbody>
30278 </tgroup>
30279 </informaltable>
30280 <para>
30281 This defines the content of the query that is sent to the remote hosts. The
30282 repetition serves as a way of checking that a response is to the correct query
30283 in the default case (see <option>response_pattern</option> below).
30284 </para>
30285 <para>
30286 <indexterm role="option">
30287 <primary>reroute</primary>
30288 </indexterm>
30289 </para>
30290 <informaltable frame="all">
30291 <tgroup cols="4" colsep="0" rowsep="0">
30292 <colspec colwidth="8*" align="left"/>
30293 <colspec colwidth="5*" align="center"/>
30294 <colspec colwidth="5*" align="center"/>
30295 <colspec colwidth="6*" align="right"/>
30296 <tbody>
30297 <row>
30298 <entry><option>reroute</option></entry>
30299 <entry>Use: <emphasis>iplookup</emphasis></entry>
30300 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30301 <entry>Default: <emphasis>unset</emphasis></entry>
30302 </row>
30303 </tbody>
30304 </tgroup>
30305 </informaltable>
30306 <para>
30307 If this option is not set, the rerouted address is precisely the byte string
30308 returned by the remote host, up to the first white space, if any. If set, the
30309 string is expanded to form the rerouted address. It can include parts matched
30310 in the response by <option>response_pattern</option> by means of numeric variables such as
30311 <varname>$1</varname>, <varname>$2</varname>, etc. The variable <varname>$0</varname> refers to the entire input string,
30312 whether or not a pattern is in use. In all cases, the rerouted address must end
30313 up in the form <emphasis>local_part@domain</emphasis>.
30314 </para>
30315 <para>
30316 <indexterm role="option">
30317 <primary>response_pattern</primary>
30318 </indexterm>
30319 </para>
30320 <informaltable frame="all">
30321 <tgroup cols="4" colsep="0" rowsep="0">
30322 <colspec colwidth="8*" align="left"/>
30323 <colspec colwidth="5*" align="center"/>
30324 <colspec colwidth="5*" align="center"/>
30325 <colspec colwidth="6*" align="right"/>
30326 <tbody>
30327 <row>
30328 <entry><option>response_pattern</option></entry>
30329 <entry>Use: <emphasis>iplookup</emphasis></entry>
30330 <entry>Type: <emphasis>string</emphasis></entry>
30331 <entry>Default: <emphasis>unset</emphasis></entry>
30332 </row>
30333 </tbody>
30334 </tgroup>
30335 </informaltable>
30336 <para>
30337 This option can be set to a regular expression that is applied to the string
30338 returned from the remote host. If the pattern does not match the response, the
30339 router declines. If <option>response_pattern</option> is not set, no checking of the
30340 response is done, unless the query was defaulted, in which case there is a
30341 check that the text returned after the first white space is the original
30342 address. This checks that the answer that has been received is in response to
30343 the correct question. For example, if the response is just a new domain, the
30344 following could be used:
30345 </para>
30346 <literallayout class="monospaced">
30347 response_pattern = ^([^@]+)$
30348 reroute = $local_part@$1
30349 </literallayout>
30350 <para>
30351 <indexterm role="option">
30352 <primary>timeout</primary>
30353 </indexterm>
30354 </para>
30355 <informaltable frame="all">
30356 <tgroup cols="4" colsep="0" rowsep="0">
30357 <colspec colwidth="8*" align="left"/>
30358 <colspec colwidth="5*" align="center"/>
30359 <colspec colwidth="5*" align="center"/>
30360 <colspec colwidth="6*" align="right"/>
30361 <tbody>
30362 <row>
30363 <entry><option>timeout</option></entry>
30364 <entry>Use: <emphasis>iplookup</emphasis></entry>
30365 <entry>Type: <emphasis>time</emphasis></entry>
30366 <entry>Default: <emphasis>5s</emphasis></entry>
30367 </row>
30368 </tbody>
30369 </tgroup>
30370 </informaltable>
30371 <para>
30372 This specifies the amount of time to wait for a response from the remote
30373 machine. The same timeout is used for the <function>connect()</function> function for a TCP
30374 call. It does not apply to UDP.
30375 </para>
30376 </chapter>
30377
30378 <chapter>
30379 <title>The manualroute router</title>
30380 <para>
30381 <indexterm role="concept" id="IIDmanrou1" class="startofrange">
30382 <primary><command>manualroute</command> router</primary>
30383 </indexterm>
30384 <indexterm role="concept" id="IIDmanrou2" class="startofrange">
30385 <primary>routers</primary>
30386 <secondary><command>manualroute</command></secondary>
30387 </indexterm>
30388 <indexterm role="concept">
30389 <primary>domain</primary>
30390 <secondary>manually routing</secondary>
30391 </indexterm>
30392 The <command>manualroute</command> router is so-called because it provides a way of manually
30393 routing an address according to its domain. It is mainly used when you want to
30394 route addresses to remote hosts according to your own rules, bypassing the
30395 normal DNS routing that looks up MX records. However, <command>manualroute</command> can also
30396 route to local transports, a facility that may be useful if you want to save
30397 messages for dial-in hosts in local files.
30398 </para>
30399 <para>
30400 The <command>manualroute</command> router compares a list of domain patterns with the domain
30401 it is trying to route. If there is no match, the router declines. Each pattern
30402 has associated with it a list of hosts and some other optional data, which may
30403 include a transport. The combination of a pattern and its data is called a
30404 <quote>routing rule</quote>. For patterns that do not have an associated transport, the
30405 generic <option>transport</option> option must specify a transport, unless the router is
30406 being used purely for verification (see <option>verify_only</option>).
30407 </para>
30408 <para>
30409 <indexterm role="concept">
30410 <primary><varname>$host</varname></primary>
30411 </indexterm>
30412 In the case of verification, matching the domain pattern is sufficient for the
30413 router to accept the address. When actually routing an address for delivery,
30414 an address that matches a domain pattern is queued for the associated
30415 transport. If the transport is not a local one, a host list must be associated
30416 with the pattern; IP addresses are looked up for the hosts, and these are
30417 passed to the transport along with the mail address. For local transports, a
30418 host list is optional. If it is present, it is passed in <varname>$host</varname> as a single
30419 text string.
30420 </para>
30421 <para>
30422 The list of routing rules can be provided as an inline string in
30423 <option>route_list</option>, or the data can be obtained by looking up the domain in a file
30424 or database by setting <option>route_data</option>. Only one of these settings may appear in
30425 any one instance of <command>manualroute</command>. The format of routing rules is described
30426 below, following the list of private options.
30427 </para>
30428 <section id="SECTprioptman">
30429 <title>Private options for manualroute</title>
30430 <para>
30431 <indexterm role="concept">
30432 <primary>options</primary>
30433 <secondary><command>manualroute</command> router</secondary>
30434 </indexterm>
30435 The private options for the <command>manualroute</command> router are as follows:
30436 </para>
30437 <para>
30438 <indexterm role="option">
30439 <primary>host_find_failed</primary>
30440 </indexterm>
30441 </para>
30442 <informaltable frame="all">
30443 <tgroup cols="4" colsep="0" rowsep="0">
30444 <colspec colwidth="8*" align="left"/>
30445 <colspec colwidth="5*" align="center"/>
30446 <colspec colwidth="5*" align="center"/>
30447 <colspec colwidth="6*" align="right"/>
30448 <tbody>
30449 <row>
30450 <entry><option>host_find_failed</option></entry>
30451 <entry>Use: <emphasis>manualroute</emphasis></entry>
30452 <entry>Type: <emphasis>string</emphasis></entry>
30453 <entry>Default: <emphasis>freeze</emphasis></entry>
30454 </row>
30455 </tbody>
30456 </tgroup>
30457 </informaltable>
30458 <para>
30459 This option controls what happens when <command>manualroute</command> tries to find an IP
30460 address for a host, and the host does not exist. The option can be set to one
30461 of
30462 </para>
30463 <literallayout class="monospaced">
30464 decline
30465 defer
30466 fail
30467 freeze
30468 pass
30469 </literallayout>
30470 <para>
30471 The default assumes that this state is a serious configuration error. The
30472 difference between <quote>pass</quote> and <quote>decline</quote> is that the former forces the
30473 address to be passed to the next router (or the router defined by
30474 <option>pass_router</option>),
30475 <indexterm role="concept">
30476 <primary><option>more</option> option</primary>
30477 </indexterm>
30478 overriding <option>no_more</option>, whereas the latter passes the address to the next
30479 router only if <option>more</option> is true.
30480 </para>
30481 <para>
30482 This option applies only to a definite <quote>does not exist</quote> state; if a host
30483 lookup gets a temporary error, delivery is deferred unless the generic
30484 <option>pass_on_timeout</option> option is set.
30485 </para>
30486 <para>
30487 <indexterm role="option">
30488 <primary>hosts_randomize</primary>
30489 </indexterm>
30490 </para>
30491 <informaltable frame="all">
30492 <tgroup cols="4" colsep="0" rowsep="0">
30493 <colspec colwidth="8*" align="left"/>
30494 <colspec colwidth="5*" align="center"/>
30495 <colspec colwidth="5*" align="center"/>
30496 <colspec colwidth="6*" align="right"/>
30497 <tbody>
30498 <row>
30499 <entry><option>hosts_randomize</option></entry>
30500 <entry>Use: <emphasis>manualroute</emphasis></entry>
30501 <entry>Type: <emphasis>boolean</emphasis></entry>
30502 <entry>Default: <emphasis>false</emphasis></entry>
30503 </row>
30504 </tbody>
30505 </tgroup>
30506 </informaltable>
30507 <para>
30508 <indexterm role="concept">
30509 <primary>randomized host list</primary>
30510 </indexterm>
30511 <indexterm role="concept">
30512 <primary>host</primary>
30513 <secondary>list of; randomized</secondary>
30514 </indexterm>
30515 If this option is set, the order of the items in a host list in a routing rule
30516 is randomized each time the list is used, unless an option in the routing rule
30517 overrides (see below). Randomizing the order of a host list can be used to do
30518 crude load sharing. However, if more than one mail address is routed by the
30519 same router to the same host list, the host lists are considered to be the same
30520 (even though they may be randomized into different orders) for the purpose of
30521 deciding whether to batch the deliveries into a single SMTP transaction.
30522 </para>
30523 <para>
30524 When <option>hosts_randomize</option> is true, a host list may be split
30525 into groups whose order is separately randomized. This makes it possible to
30526 set up MX-like behaviour. The boundaries between groups are indicated by an
30527 item that is just <literal>+</literal> in the host list. For example:
30528 </para>
30529 <literallayout class="monospaced">
30530 route_list = * host1:host2:host3:+:host4:host5
30531 </literallayout>
30532 <para>
30533 The order of the first three hosts and the order of the last two hosts is
30534 randomized for each use, but the first three always end up before the last two.
30535 If <option>hosts_randomize</option> is not set, a <literal>+</literal> item in the list is ignored. If a
30536 randomized host list is passed to an <command>smtp</command> transport that also has
30537 <option>hosts_randomize set</option>, the list is not re-randomized.
30538 </para>
30539 <para>
30540 <indexterm role="option">
30541 <primary>route_data</primary>
30542 </indexterm>
30543 </para>
30544 <informaltable frame="all">
30545 <tgroup cols="4" colsep="0" rowsep="0">
30546 <colspec colwidth="8*" align="left"/>
30547 <colspec colwidth="5*" align="center"/>
30548 <colspec colwidth="5*" align="center"/>
30549 <colspec colwidth="6*" align="right"/>
30550 <tbody>
30551 <row>
30552 <entry><option>route_data</option></entry>
30553 <entry>Use: <emphasis>manualroute</emphasis></entry>
30554 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30555 <entry>Default: <emphasis>unset</emphasis></entry>
30556 </row>
30557 </tbody>
30558 </tgroup>
30559 </informaltable>
30560 <para>
30561 If this option is set, it must expand to yield the data part of a routing rule.
30562 Typically, the expansion string includes a lookup based on the domain. For
30563 example:
30564 </para>
30565 <literallayout class="monospaced">
30566 route_data = ${lookup{$domain}dbm{/etc/routes}}
30567 </literallayout>
30568 <para>
30569 If the expansion is forced to fail, or the result is an empty string, the
30570 router declines. Other kinds of expansion failure cause delivery to be
30571 deferred.
30572 </para>
30573 <para>
30574 <indexterm role="option">
30575 <primary>route_list</primary>
30576 </indexterm>
30577 </para>
30578 <informaltable frame="all">
30579 <tgroup cols="4" colsep="0" rowsep="0">
30580 <colspec colwidth="8*" align="left"/>
30581 <colspec colwidth="5*" align="center"/>
30582 <colspec colwidth="5*" align="center"/>
30583 <colspec colwidth="6*" align="right"/>
30584 <tbody>
30585 <row>
30586 <entry><option>route_list</option></entry>
30587 <entry>Use: <emphasis>manualroute</emphasis></entry>
30588 <entry>Type: <emphasis> </emphasis></entry>
30589 <entry>Default: <emphasis>string</emphasis></entry>
30590 </row>
30591 </tbody>
30592 </tgroup>
30593 </informaltable>
30594 <para>
30595 This string is a list of routing rules, in the form defined below. Note that,
30596 unlike most string lists, the items are separated by semicolons. This is so
30597 that they may contain colon-separated host lists.
30598 </para>
30599 <para>
30600 <indexterm role="option">
30601 <primary>same_domain_copy_routing</primary>
30602 </indexterm>
30603 </para>
30604 <informaltable frame="all">
30605 <tgroup cols="4" colsep="0" rowsep="0">
30606 <colspec colwidth="8*" align="left"/>
30607 <colspec colwidth="5*" align="center"/>
30608 <colspec colwidth="5*" align="center"/>
30609 <colspec colwidth="6*" align="right"/>
30610 <tbody>
30611 <row>
30612 <entry><option>same_domain_copy_routing</option></entry>
30613 <entry>Use: <emphasis>manualroute</emphasis></entry>
30614 <entry>Type: <emphasis>boolean</emphasis></entry>
30615 <entry>Default: <emphasis>false</emphasis></entry>
30616 </row>
30617 </tbody>
30618 </tgroup>
30619 </informaltable>
30620 <para>
30621 <indexterm role="concept">
30622 <primary>address</primary>
30623 <secondary>copying routing</secondary>
30624 </indexterm>
30625 Addresses with the same domain are normally routed by the <command>manualroute</command>
30626 router to the same list of hosts. However, this cannot be presumed, because the
30627 router options and preconditions may refer to the local part of the address. By
30628 default, therefore, Exim routes each address in a message independently. DNS
30629 servers run caches, so repeated DNS lookups are not normally expensive, and in
30630 any case, personal messages rarely have more than a few recipients.
30631 </para>
30632 <para>
30633 If you are running mailing lists with large numbers of subscribers at the same
30634 domain, and you are using a <command>manualroute</command> router which is independent of the
30635 local part, you can set <option>same_domain_copy_routing</option> to bypass repeated DNS
30636 lookups for identical domains in one message. In this case, when
30637 <command>manualroute</command> routes an address to a remote transport, any other unrouted
30638 addresses in the message that have the same domain are automatically given the
30639 same routing without processing them independently. However, this is only done
30640 if <option>headers_add</option> and <option>headers_remove</option> are unset.
30641 </para>
30642 </section>
30643 <section>
30644 <title>Routing rules in route_list</title>
30645 <para>
30646 The value of <option>route_list</option> is a string consisting of a sequence of routing
30647 rules, separated by semicolons. If a semicolon is needed in a rule, it can be
30648 entered as two semicolons. Alternatively, the list separator can be changed as
30649 described (for colon-separated lists) in section <xref linkend="SECTlistconstruct"/>.
30650 Empty rules are ignored. The format of each rule is
30651 </para>
30652 <literallayout>
30653 &lt;<emphasis>domain pattern</emphasis>&gt;  &lt;<emphasis>list of hosts</emphasis>&gt;  &lt;<emphasis>options</emphasis>&gt;
30654 </literallayout>
30655 <para>
30656 The following example contains two rules, each with a simple domain pattern and
30657 no options:
30658 </para>
30659 <literallayout class="monospaced">
30660 route_list = \
30661   dict.ref.example  mail-1.ref.example:mail-2.ref.example ; \
30662   thes.ref.example  mail-3.ref.example:mail-4.ref.example
30663 </literallayout>
30664 <para>
30665 The three parts of a rule are separated by white space. The pattern and the
30666 list of hosts can be enclosed in quotes if necessary, and if they are, the
30667 usual quoting rules apply. Each rule in a <option>route_list</option> must start with a
30668 single domain pattern, which is the only mandatory item in the rule. The
30669 pattern is in the same format as one item in a domain list (see section
30670 <xref linkend="SECTdomainlist"/>),
30671 except that it may not be the name of an interpolated file.
30672 That is, it may be wildcarded, or a regular expression, or a file or database
30673 lookup (with semicolons doubled, because of the use of semicolon as a separator
30674 in a <option>route_list</option>).
30675 </para>
30676 <para>
30677 The rules in <option>route_list</option> are searched in order until one of the patterns
30678 matches the domain that is being routed. The list of hosts and then options are
30679 then used as described below. If there is no match, the router declines. When
30680 <option>route_list</option> is set, <option>route_data</option> must not be set.
30681 </para>
30682 </section>
30683 <section>
30684 <title>Routing rules in route_data</title>
30685 <para>
30686 The use of <option>route_list</option> is convenient when there are only a small number of
30687 routing rules. For larger numbers, it is easier to use a file or database to
30688 hold the routing information, and use the <option>route_data</option> option instead.
30689 The value of <option>route_data</option> is a list of hosts, followed by (optional) options.
30690 Most commonly, <option>route_data</option> is set as a string that contains an
30691 expansion lookup. For example, suppose we place two routing rules in a file
30692 like this:
30693 </para>
30694 <literallayout class="monospaced">
30695 dict.ref.example:  mail-1.ref.example:mail-2.ref.example
30696 thes.ref.example:  mail-3.ref.example:mail-4.ref.example
30697 </literallayout>
30698 <para>
30699 This data can be accessed by setting
30700 </para>
30701 <literallayout class="monospaced">
30702 route_data = ${lookup{$domain}lsearch{/the/file/name}}
30703 </literallayout>
30704 <para>
30705 Failure of the lookup results in an empty string, causing the router to
30706 decline. However, you do not have to use a lookup in <option>route_data</option>. The only
30707 requirement is that the result of expanding the string is a list of hosts,
30708 possibly followed by options, separated by white space. The list of hosts must
30709 be enclosed in quotes if it contains white space.
30710 </para>
30711 </section>
30712 <section>
30713 <title>Format of the list of hosts</title>
30714 <para>
30715 A list of hosts, whether obtained via <option>route_data</option> or <option>route_list</option>, is
30716 always separately expanded before use. If the expansion fails, the router
30717 declines. The result of the expansion must be a colon-separated list of names
30718 and/or IP addresses, optionally also including ports. The format of each item
30719 in the list is described in the next section. The list separator can be changed
30720 as described in section <xref linkend="SECTlistconstruct"/>.
30721 </para>
30722 <para>
30723 If the list of hosts was obtained from a <option>route_list</option> item, the following
30724 variables are set during its expansion:
30725 </para>
30726 <itemizedlist>
30727 <listitem>
30728 <para>
30729 <indexterm role="concept">
30730 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname>  etc)</primary>
30731 <secondary>in <command>manualroute</command> router</secondary>
30732 </indexterm>
30733 If the domain was matched against a regular expression, the numeric variables
30734 <varname>$1</varname>, <varname>$2</varname>, etc. may be set. For example:
30735 </para>
30736 <literallayout class="monospaced">
30737 route_list = ^domain(\d+)   host-$1.text.example
30738 </literallayout>
30739 </listitem>
30740 <listitem>
30741 <para>
30742 <varname>$0</varname> is always set to the entire domain.
30743 </para>
30744 </listitem>
30745 <listitem>
30746 <para>
30747 <varname>$1</varname> is also set when partial matching is done in a file lookup.
30748 </para>
30749 </listitem>
30750 <listitem>
30751 <para>
30752 <indexterm role="concept">
30753 <primary><varname>$value</varname></primary>
30754 </indexterm>
30755 If the pattern that matched the domain was a lookup item, the data that was
30756 looked up is available in the expansion variable <varname>$value</varname>. For example:
30757 </para>
30758 <literallayout class="monospaced">
30759 route_list = lsearch;;/some/file.routes  $value
30760 </literallayout>
30761 </listitem>
30762 </itemizedlist>
30763 <para>
30764 Note the doubling of the semicolon in the pattern that is necessary because
30765 semicolon is the default route list separator.
30766 </para>
30767 </section>
30768 <section id="SECTformatonehostitem">
30769 <title>Format of one host item</title>
30770 <para>
30771 Each item in the list of hosts is either a host name or an IP address,
30772 optionally with an attached port number. When no port is given, an IP address
30773 is not enclosed in brackets. When a port is specified, it overrides the port
30774 specification on the transport. The port is separated from the name or address
30775 by a colon. This leads to some complications:
30776 </para>
30777 <itemizedlist>
30778 <listitem>
30779 <para>
30780 Because colon is the default separator for the list of hosts, either
30781 the colon that specifies a port must be doubled, or the list separator must
30782 be changed. The following two examples have the same effect:
30783 </para>
30784 <literallayout class="monospaced">
30785 route_list = * "host1.tld::1225 : host2.tld::1226"
30786 route_list = * "&lt;+ host1.tld:1225 + host2.tld:1226"
30787 </literallayout>
30788 </listitem>
30789 <listitem>
30790 <para>
30791 When IPv6 addresses are involved, it gets worse, because they contain
30792 colons of their own. To make this case easier, it is permitted to
30793 enclose an IP address (either v4 or v6) in square brackets if a port
30794 number follows. For example:
30795 </para>
30796 <literallayout class="monospaced">
30797 route_list = * "&lt;/ [10.1.1.1]:1225 / [::1]:1226"
30798 </literallayout>
30799 </listitem>
30800 </itemizedlist>
30801 </section>
30802 <section id="SECThostshowused">
30803 <title>How the list of hosts is used</title>
30804 <para>
30805 When an address is routed to an <command>smtp</command> transport by <command>manualroute</command>, each of
30806 the hosts is tried, in the order specified, when carrying out the SMTP
30807 delivery. However, the order can be changed by setting the <option>hosts_randomize</option>
30808 option, either on the router (see section <xref linkend="SECTprioptman"/> above), or on the
30809 transport.
30810 </para>
30811 <para>
30812 Hosts may be listed by name or by IP address. An unadorned name in the list of
30813 hosts is interpreted as a host name. A name that is followed by <literal>/MX</literal> is
30814 interpreted as an indirection to a sublist of hosts obtained by looking up MX
30815 records in the DNS. For example:
30816 </para>
30817 <literallayout class="monospaced">
30818 route_list = *  x.y.z:p.q.r/MX:e.f.g
30819 </literallayout>
30820 <para>
30821 If this feature is used with a port specifier, the port must come last. For
30822 example:
30823 </para>
30824 <literallayout class="monospaced">
30825 route_list = *  dom1.tld/mx::1225
30826 </literallayout>
30827 <para>
30828 If the <option>hosts_randomize</option> option is set, the order of the items in the list is
30829 randomized before any lookups are done. Exim then scans the list; for any name
30830 that is not followed by <literal>/MX</literal> it looks up an IP address. If this turns out to
30831 be an interface on the local host and the item is not the first in the list,
30832 Exim discards it and any subsequent items. If it is the first item, what
30833 happens is controlled by the
30834 <indexterm role="concept">
30835 <primary><option>self</option> option</primary>
30836 <secondary>in <command>manualroute</command> router</secondary>
30837 </indexterm>
30838 <option>self</option> option of the router.
30839 </para>
30840 <para>
30841 A name on the list that is followed by <literal>/MX</literal> is replaced with the list of
30842 hosts obtained by looking up MX records for the name. This is always a DNS
30843 lookup; the <option>bydns</option> and <option>byname</option> options (see section <xref linkend="SECThowoptused"/>
30844 below) are not relevant here. The order of these hosts is determined by the
30845 preference values in the MX records, according to the usual rules. Because
30846 randomizing happens before the MX lookup, it does not affect the order that is
30847 defined by MX preferences.
30848 </para>
30849 <para>
30850 If the local host is present in the sublist obtained from MX records, but is
30851 not the most preferred host in that list, it and any equally or less
30852 preferred hosts are removed before the sublist is inserted into the main list.
30853 </para>
30854 <para>
30855 If the local host is the most preferred host in the MX list, what happens
30856 depends on where in the original list of hosts the <literal>/MX</literal> item appears. If it
30857 is not the first item (that is, there are previous hosts in the main list),
30858 Exim discards this name and any subsequent items in the main list.
30859 </para>
30860 <para>
30861 If the MX item is first in the list of hosts, and the local host is the
30862 most preferred host, what happens is controlled by the <option>self</option> option of the
30863 router.
30864 </para>
30865 <para>
30866 DNS failures when lookup up the MX records are treated in the same way as DNS
30867 failures when looking up IP addresses: <option>pass_on_timeout</option> and
30868 <option>host_find_failed</option> are used when relevant.
30869 </para>
30870 <para>
30871 The generic <option>ignore_target_hosts</option> option applies to all hosts in the list,
30872 whether obtained from an MX lookup or not.
30873 </para>
30874 </section>
30875 <section id="SECThowoptused">
30876 <title>How the options are used</title>
30877 <para>
30878 The options are a sequence of words; in practice no more than three are ever
30879 present. One of the words can be the name of a transport; this overrides the
30880 <option>transport</option> option on the router for this particular routing rule only. The
30881 other words (if present) control randomization of the list of hosts on a
30882 per-rule basis, and how the IP addresses of the hosts are to be found when
30883 routing to a remote transport. These options are as follows:
30884 </para>
30885 <itemizedlist>
30886 <listitem>
30887 <para>
30888 <option>randomize</option>: randomize the order of the hosts in this list, overriding the
30889 setting of <option>hosts_randomize</option> for this routing rule only.
30890 </para>
30891 </listitem>
30892 <listitem>
30893 <para>
30894 <option>no_randomize</option>: do not randomize the order of the hosts in this list,
30895 overriding the setting of <option>hosts_randomize</option> for this routing rule only.
30896 </para>
30897 </listitem>
30898 <listitem>
30899 <para>
30900 <option>byname</option>: use <function>getipnodebyname()</function> (<function>gethostbyname()</function> on older systems) to
30901 find IP addresses. This function may ultimately cause a DNS lookup, but it may
30902 also look in <filename>/etc/hosts</filename> or other sources of information.
30903 </para>
30904 </listitem>
30905 <listitem>
30906 <para>
30907 <option>bydns</option>: look up address records for the hosts directly in the DNS; fail if
30908 no address records are found. If there is a temporary DNS error (such as a
30909 timeout), delivery is deferred.
30910 </para>
30911 </listitem>
30912 </itemizedlist>
30913 <para>
30914 For example:
30915 </para>
30916 <literallayout class="monospaced">
30917 route_list = domain1  host1:host2:host3  randomize bydns;\
30918              domain2  host4:host5
30919 </literallayout>
30920 <para>
30921 If neither <option>byname</option> nor <option>bydns</option> is given, Exim behaves as follows: First, a
30922 DNS lookup is done. If this yields anything other than HOST_NOT_FOUND, that
30923 result is used. Otherwise, Exim goes on to try a call to <function>getipnodebyname()</function>
30924 or <function>gethostbyname()</function>, and the result of the lookup is the result of that
30925 call.
30926 </para>
30927 <para>
30928 <emphasis role="bold">Warning</emphasis>: It has been discovered that on some systems, if a DNS lookup
30929 called via <function>getipnodebyname()</function> times out, HOST_NOT_FOUND is returned
30930 instead of TRY_AGAIN. That is why the default action is to try a DNS
30931 lookup first. Only if that gives a definite <quote>no such host</quote> is the local
30932 function called.
30933 </para>
30934 <para>
30935 If no IP address for a host can be found, what happens is controlled by the
30936 <option>host_find_failed</option> option.
30937 </para>
30938 <para>
30939 <indexterm role="concept">
30940 <primary><varname>$host</varname></primary>
30941 </indexterm>
30942 When an address is routed to a local transport, IP addresses are not looked up.
30943 The host list is passed to the transport in the <varname>$host</varname> variable.
30944 </para>
30945 </section>
30946 <section>
30947 <title>Manualroute examples</title>
30948 <para>
30949 In some of the examples that follow, the presence of the <option>remote_smtp</option>
30950 transport, as defined in the default configuration file, is assumed:
30951 </para>
30952 <itemizedlist>
30953 <listitem>
30954 <para>
30955 <indexterm role="concept">
30956 <primary>smart host</primary>
30957 <secondary>example router</secondary>
30958 </indexterm>
30959 The <command>manualroute</command> router can be used to forward all external mail to a
30960 <emphasis>smart host</emphasis>. If you have set up, in the main part of the configuration, a
30961 named domain list that contains your local domains, for example:
30962 </para>
30963 <literallayout class="monospaced">
30964 domainlist local_domains = my.domain.example
30965 </literallayout>
30966 <para>
30967 You can arrange for all other domains to be routed to a smart host by making
30968 your first router something like this:
30969 </para>
30970 <literallayout class="monospaced">
30971 smart_route:
30972   driver = manualroute
30973   domains = !+local_domains
30974   transport = remote_smtp
30975   route_list = * smarthost.ref.example
30976 </literallayout>
30977 <para>
30978 This causes all non-local addresses to be sent to the single host
30979 <emphasis>smarthost.ref.example</emphasis>. If a colon-separated list of smart hosts is given,
30980 they are tried in order
30981 (but you can use <option>hosts_randomize</option> to vary the order each time).
30982 Another way of configuring the same thing is this:
30983 </para>
30984 <literallayout class="monospaced">
30985 smart_route:
30986   driver = manualroute
30987   transport = remote_smtp
30988   route_list = !+local_domains  smarthost.ref.example
30989 </literallayout>
30990 <para>
30991 There is no difference in behaviour between these two routers as they stand.
30992 However, they behave differently if <option>no_more</option> is added to them. In the first
30993 example, the router is skipped if the domain does not match the <option>domains</option>
30994 precondition; the following router is always tried. If the router runs, it
30995 always matches the domain and so can never decline. Therefore, <option>no_more</option>
30996 would have no effect. In the second case, the router is never skipped; it
30997 always runs. However, if it doesn&#x2019;t match the domain, it declines. In this case
30998 <option>no_more</option> would prevent subsequent routers from running.
30999 </para>
31000 </listitem>
31001 <listitem>
31002 <para>
31003 <indexterm role="concept">
31004 <primary>mail hub example</primary>
31005 </indexterm>
31006 A <emphasis>mail hub</emphasis> is a host which receives mail for a number of domains via MX
31007 records in the DNS and delivers it via its own private routing mechanism. Often
31008 the final destinations are behind a firewall, with the mail hub being the one
31009 machine that can connect to machines both inside and outside the firewall. The
31010 <command>manualroute</command> router is usually used on a mail hub to route incoming messages
31011 to the correct hosts. For a small number of domains, the routing can be inline,
31012 using the <option>route_list</option> option, but for a larger number a file or database
31013 lookup is easier to manage.
31014 </para>
31015 <para>
31016 If the domain names are in fact the names of the machines to which the mail is
31017 to be sent by the mail hub, the configuration can be quite simple. For
31018 example:
31019 </para>
31020 <literallayout class="monospaced">
31021 hub_route:
31022   driver = manualroute
31023   transport = remote_smtp
31024   route_list = *.rhodes.tvs.example  $domain
31025 </literallayout>
31026 <para>
31027 This configuration routes domains that match <literal>*.rhodes.tvs.example</literal> to hosts
31028 whose names are the same as the mail domains. A similar approach can be taken
31029 if the host name can be obtained from the domain name by a string manipulation
31030 that the expansion facilities can handle. Otherwise, a lookup based on the
31031 domain can be used to find the host:
31032 </para>
31033 <literallayout class="monospaced">
31034 through_firewall:
31035   driver = manualroute
31036   transport = remote_smtp
31037   route_data = ${lookup {$domain} cdb {/internal/host/routes}}
31038 </literallayout>
31039 <para>
31040 The result of the lookup must be the name or IP address of the host (or
31041 hosts) to which the address is to be routed. If the lookup fails, the route
31042 data is empty, causing the router to decline. The address then passes to the
31043 next router.
31044 </para>
31045 </listitem>
31046 <listitem>
31047 <para>
31048 <indexterm role="concept">
31049 <primary>batched SMTP output example</primary>
31050 </indexterm>
31051 <indexterm role="concept">
31052 <primary>SMTP</primary>
31053 <secondary>batched outgoing; example</secondary>
31054 </indexterm>
31055 You can use <command>manualroute</command> to deliver messages to pipes or files in batched
31056 SMTP format for onward transportation by some other means. This is one way of
31057 storing mail for a dial-up host when it is not connected. The route list entry
31058 can be as simple as a single domain name in a configuration like this:
31059 </para>
31060 <literallayout class="monospaced">
31061 save_in_file:
31062   driver = manualroute
31063   transport = batchsmtp_appendfile
31064   route_list = saved.domain.example
31065 </literallayout>
31066 <para>
31067 though often a pattern is used to pick up more than one domain. If there are
31068 several domains or groups of domains with different transport requirements,
31069 different transports can be listed in the routing information:
31070 </para>
31071 <literallayout class="monospaced">
31072 save_in_file:
31073   driver = manualroute
31074   route_list = \
31075     *.saved.domain1.example  $domain  batch_appendfile; \
31076     *.saved.domain2.example  \
31077       ${lookup{$domain}dbm{/domain2/hosts}{$value}fail} \
31078       batch_pipe
31079 </literallayout>
31080 <para>
31081 <indexterm role="concept">
31082 <primary><varname>$domain</varname></primary>
31083 </indexterm>
31084 <indexterm role="concept">
31085 <primary><varname>$host</varname></primary>
31086 </indexterm>
31087 The first of these just passes the domain in the <varname>$host</varname> variable, which
31088 doesn&#x2019;t achieve much (since it is also in <varname>$domain</varname>), but the second does a
31089 file lookup to find a value to pass, causing the router to decline to handle
31090 the address if the lookup fails.
31091 </para>
31092 </listitem>
31093 <listitem>
31094 <para>
31095 <indexterm role="concept">
31096 <primary>UUCP</primary>
31097 <secondary>example of router for</secondary>
31098 </indexterm>
31099 Routing mail directly to UUCP software is a specific case of the use of
31100 <command>manualroute</command> in a gateway to another mail environment. This is an example of
31101 one way it can be done:
31102 </para>
31103 <literallayout class="monospaced">
31104 # Transport
31105 uucp:
31106   driver = pipe
31107   user = nobody
31108   command = /usr/local/bin/uux -r - \
31109     ${substr_-5:$host}!rmail ${local_part}
31110   return_fail_output = true
31111
31112 # Router
31113 uucphost:
31114   transport = uucp
31115   driver = manualroute
31116   route_data = \
31117     ${lookup{$domain}lsearch{/usr/local/exim/uucphosts}}
31118 </literallayout>
31119 <para>
31120 The file <filename>/usr/local/exim/uucphosts</filename> contains entries like
31121 </para>
31122 <literallayout class="monospaced">
31123 darksite.ethereal.example:           darksite.UUCP
31124 </literallayout>
31125 <para>
31126 It can be set up more simply without adding and removing <quote>.UUCP</quote> but this way
31127 makes clear the distinction between the domain name
31128 <emphasis>darksite.ethereal.example</emphasis> and the UUCP host name <emphasis>darksite</emphasis>.
31129 </para>
31130 </listitem>
31131 </itemizedlist>
31132 <para>
31133 <indexterm role="concept" startref="IIDmanrou1" class="endofrange"/>
31134 <indexterm role="concept" startref="IIDmanrou2" class="endofrange"/>
31135 </para>
31136 </section>
31137 </chapter>
31138
31139 <chapter id="CHAPdriverlast">
31140 <title>The queryprogram router</title>
31141 <para>
31142 <indexterm role="concept" id="IIDquerou1" class="startofrange">
31143 <primary><command>queryprogram</command> router</primary>
31144 </indexterm>
31145 <indexterm role="concept" id="IIDquerou2" class="startofrange">
31146 <primary>routers</primary>
31147 <secondary><command>queryprogram</command></secondary>
31148 </indexterm>
31149 <indexterm role="concept">
31150 <primary>routing</primary>
31151 <secondary>by external program</secondary>
31152 </indexterm>
31153 The <command>queryprogram</command> router routes an address by running an external command
31154 and acting on its output. This is an expensive way to route, and is intended
31155 mainly for use in lightly-loaded systems, or for performing experiments.
31156 However, if it is possible to use the precondition options (<option>domains</option>,
31157 <option>local_parts</option>, etc) to skip this router for most addresses, it could sensibly
31158 be used in special cases, even on a busy host. There are the following private
31159 options:
31160 <indexterm role="concept">
31161 <primary>options</primary>
31162 <secondary><command>queryprogram</command> router</secondary>
31163 </indexterm>
31164 </para>
31165 <para>
31166 <indexterm role="option">
31167 <primary>command</primary>
31168 </indexterm>
31169 </para>
31170 <informaltable frame="all">
31171 <tgroup cols="4" colsep="0" rowsep="0">
31172 <colspec colwidth="8*" align="left"/>
31173 <colspec colwidth="5*" align="center"/>
31174 <colspec colwidth="5*" align="center"/>
31175 <colspec colwidth="6*" align="right"/>
31176 <tbody>
31177 <row>
31178 <entry><option>command</option></entry>
31179 <entry>Use: <emphasis>queryprogram</emphasis></entry>
31180 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
31181 <entry>Default: <emphasis>unset</emphasis></entry>
31182 </row>
31183 </tbody>
31184 </tgroup>
31185 </informaltable>
31186 <para>
31187 This option must be set. It specifies the command that is to be run. The
31188 command is split up into a command name and arguments, and then each is
31189 expanded separately (exactly as for a <command>pipe</command> transport, described in chapter
31190 <xref linkend="CHAPpipetransport"/>).
31191 </para>
31192 <para>
31193 <indexterm role="option">
31194 <primary>command_group</primary>
31195 </indexterm>
31196 </para>
31197 <informaltable frame="all">
31198 <tgroup cols="4" colsep="0" rowsep="0">
31199 <colspec colwidth="8*" align="left"/>
31200 <colspec colwidth="5*" align="center"/>
31201 <colspec colwidth="5*" align="center"/>
31202 <colspec colwidth="6*" align="right"/>
31203 <tbody>
31204 <row>
31205 <entry><option>command_group</option></entry>
31206 <entry>Use: <emphasis>queryprogram</emphasis></entry>
31207 <entry>Type: <emphasis>string</emphasis></entry>
31208 <entry>Default: <emphasis>unset</emphasis></entry>
31209 </row>
31210 </tbody>
31211 </tgroup>
31212 </informaltable>
31213 <para>
31214 <indexterm role="concept">
31215 <primary>gid (group id)</primary>
31216 <secondary>in <command>queryprogram</command> router</secondary>
31217 </indexterm>
31218 </para>
31219 <para revisionflag="changed">
31220 This option specifies a gid to be set when running the command while routing an
31221 address for deliver. It must be set if <option>command_user</option> specifies a numerical
31222 uid. If it begins with a digit, it is interpreted as the numerical value of the
31223 gid. Otherwise it is looked up using <function>getgrnam()</function>.
31224 </para>
31225 <para>
31226 <indexterm role="option">
31227 <primary>command_user</primary>
31228 </indexterm>
31229 </para>
31230 <informaltable frame="all">
31231 <tgroup cols="4" colsep="0" rowsep="0">
31232 <colspec colwidth="8*" align="left"/>
31233 <colspec colwidth="5*" align="center"/>
31234 <colspec colwidth="5*" align="center"/>
31235 <colspec colwidth="6*" align="right"/>
31236 <tbody>
31237 <row>
31238 <entry><option>command_user</option></entry>
31239 <entry>Use: <emphasis>queryprogram</emphasis></entry>
31240 <entry>Type: <emphasis>string</emphasis></entry>
31241 <entry>Default: <emphasis>unset</emphasis></entry>
31242 </row>
31243 </tbody>
31244 </tgroup>
31245 </informaltable>
31246 <para>
31247 <indexterm role="concept">
31248 <primary>uid (user id)</primary>
31249 <secondary>for <command>queryprogram</command></secondary>
31250 </indexterm>
31251 </para>
31252 <para revisionflag="changed">
31253 This option must be set. It specifies the uid which is set when running the
31254 command while routing an address for delivery. If the value begins with a digit,
31255 it is interpreted as the numerical value of the uid. Otherwise, it is looked up
31256 using <function>getpwnam()</function> to obtain a value for the uid and, if <option>command_group</option> is
31257 not set, a value for the gid also.
31258 </para>
31259 <para revisionflag="changed">
31260 <emphasis role="bold">Warning:</emphasis> Changing uid and gid is possible only when Exim is running as
31261 root, which it does during a normal delivery in a conventional configuration.
31262 However, when an address is being verified during message reception, Exim is
31263 usually running as the Exim user, not as root. If the <command>queryprogram</command> router
31264 is called from a non-root process, Exim cannot change uid or gid before running
31265 the command. In this circumstance the command runs under the current uid and
31266 gid.
31267 </para>
31268 <para>
31269 <indexterm role="option">
31270 <primary>current_directory</primary>
31271 </indexterm>
31272 </para>
31273 <informaltable frame="all">
31274 <tgroup cols="4" colsep="0" rowsep="0">
31275 <colspec colwidth="8*" align="left"/>
31276 <colspec colwidth="5*" align="center"/>
31277 <colspec colwidth="5*" align="center"/>
31278 <colspec colwidth="6*" align="right"/>
31279 <tbody>
31280 <row>
31281 <entry><option>current_directory</option></entry>
31282 <entry>Use: <emphasis>queryprogram</emphasis></entry>
31283 <entry>Type: <emphasis>string</emphasis></entry>
31284 <entry>Default: <emphasis>/</emphasis></entry>
31285 </row>
31286 </tbody>
31287 </tgroup>
31288 </informaltable>
31289 <para>
31290 This option specifies an absolute path which is made the current directory
31291 before running the command.
31292 </para>
31293 <para>
31294 <indexterm role="option">
31295 <primary>timeout</primary>
31296 </indexterm>
31297 </para>
31298 <informaltable frame="all">
31299 <tgroup cols="4" colsep="0" rowsep="0">
31300 <colspec colwidth="8*" align="left"/>
31301 <colspec colwidth="5*" align="center"/>
31302 <colspec colwidth="5*" align="center"/>
31303 <colspec colwidth="6*" align="right"/>
31304 <tbody>
31305 <row>
31306 <entry><option>timeout</option></entry>
31307 <entry>Use: <emphasis>queryprogram</emphasis></entry>
31308 <entry>Type: <emphasis>time</emphasis></entry>
31309 <entry>Default: <emphasis>1h</emphasis></entry>
31310 </row>
31311 </tbody>
31312 </tgroup>
31313 </informaltable>
31314 <para>
31315 If the command does not complete within the timeout period, its process group
31316 is killed and the message is frozen. A value of zero time specifies no
31317 timeout.
31318 </para>
31319 <para>
31320 The standard output of the command is connected to a pipe, which is read when
31321 the command terminates. It should consist of a single line of output,
31322 containing up to five fields, separated by white space. The maximum length of
31323 the line is 1023 characters. Longer lines are silently truncated. The first
31324 field is one of the following words (case-insensitive):
31325 </para>
31326 <itemizedlist>
31327 <listitem>
31328 <para>
31329 <emphasis>Accept</emphasis>: routing succeeded; the remaining fields specify what to do (see
31330 below).
31331 </para>
31332 </listitem>
31333 <listitem>
31334 <para>
31335 <emphasis>Decline</emphasis>: the router declines; pass the address to the next router, unless
31336 <option>no_more</option> is set.
31337 </para>
31338 </listitem>
31339 <listitem>
31340 <para>
31341 <emphasis>Fail</emphasis>: routing failed; do not pass the address to any more routers. Any
31342 subsequent text on the line is an error message. If the router is run as part
31343 of address verification during an incoming SMTP message, the message is
31344 included in the SMTP response.
31345 </para>
31346 </listitem>
31347 <listitem>
31348 <para>
31349 <emphasis>Defer</emphasis>: routing could not be completed at this time; try again later. Any
31350 subsequent text on the line is an error message which is logged. It is not
31351 included in any SMTP response.
31352 </para>
31353 </listitem>
31354 <listitem>
31355 <para>
31356 <emphasis>Freeze</emphasis>: the same as <emphasis>defer</emphasis>, except that the message is frozen.
31357 </para>
31358 </listitem>
31359 <listitem>
31360 <para>
31361 <emphasis>Pass</emphasis>: pass the address to the next router (or the router specified by
31362 <option>pass_router</option>), overriding <option>no_more</option>.
31363 </para>
31364 </listitem>
31365 <listitem>
31366 <para>
31367 <emphasis>Redirect</emphasis>: the message is redirected. The remainder of the line is a list of
31368 new addresses, which are routed independently, starting with the first router,
31369 or the router specified by <option>redirect_router</option>, if set.
31370 </para>
31371 </listitem>
31372 </itemizedlist>
31373 <para>
31374 When the first word is <emphasis>accept</emphasis>, the remainder of the line consists of a
31375 number of keyed data values, as follows (split into two lines here, to fit on
31376 the page):
31377 </para>
31378 <literallayout class="monospaced">
31379 ACCEPT TRANSPORT=&lt;transport&gt; HOSTS=&lt;list of hosts&gt;
31380 LOOKUP=byname|bydns DATA=&lt;text&gt;
31381 </literallayout>
31382 <para>
31383 The data items can be given in any order, and all are optional. If no transport
31384 is included, the transport specified by the generic <option>transport</option> option is
31385 used. The list of hosts and the lookup type are needed only if the transport is
31386 an <command>smtp</command> transport that does not itself supply a list of hosts.
31387 </para>
31388 <para>
31389 The format of the list of hosts is the same as for the <command>manualroute</command> router.
31390 As well as host names and IP addresses with optional port numbers, as described
31391 in section <xref linkend="SECTformatonehostitem"/>, it may contain names followed by
31392 <literal>/MX</literal> to specify sublists of hosts that are obtained by looking up MX records
31393 (see section <xref linkend="SECThostshowused"/>).
31394 </para>
31395 <para>
31396 If the lookup type is not specified, Exim behaves as follows when trying to
31397 find an IP address for each host: First, a DNS lookup is done. If this yields
31398 anything other than HOST_NOT_FOUND, that result is used. Otherwise, Exim
31399 goes on to try a call to <function>getipnodebyname()</function> or <function>gethostbyname()</function>, and the
31400 result of the lookup is the result of that call.
31401 </para>
31402 <para>
31403 <indexterm role="concept">
31404 <primary><varname>$address_data</varname></primary>
31405 </indexterm>
31406 If the DATA field is set, its value is placed in the <varname>$address_data</varname>
31407 variable. For example, this return line
31408 </para>
31409 <literallayout class="monospaced">
31410 accept hosts=x1.y.example:x2.y.example data="rule1"
31411 </literallayout>
31412 <para>
31413 routes the address to the default transport, passing a list of two hosts. When
31414 the transport runs, the string <quote>rule1</quote> is in <varname>$address_data</varname>.
31415 <indexterm role="concept" startref="IIDquerou1" class="endofrange"/>
31416 <indexterm role="concept" startref="IIDquerou2" class="endofrange"/>
31417 </para>
31418 </chapter>
31419
31420 <chapter id="CHAPredirect">
31421 <title>The redirect router</title>
31422 <para>
31423 <indexterm role="concept" id="IIDredrou1" class="startofrange">
31424 <primary><command>redirect</command> router</primary>
31425 </indexterm>
31426 <indexterm role="concept" id="IIDredrou2" class="startofrange">
31427 <primary>routers</primary>
31428 <secondary><command>redirect</command></secondary>
31429 </indexterm>
31430 <indexterm role="concept">
31431 <primary>alias file</primary>
31432 <secondary>in a <command>redirect</command> router</secondary>
31433 </indexterm>
31434 <indexterm role="concept">
31435 <primary>address redirection</primary>
31436 <secondary><command>redirect</command> router</secondary>
31437 </indexterm>
31438 The <command>redirect</command> router handles several kinds of address redirection. Its most
31439 common uses are for resolving local part aliases from a central alias file
31440 (usually called <filename>/etc/aliases</filename>) and for handling users&#x2019; personal <filename>.forward</filename>
31441 files, but it has many other potential uses. The incoming address can be
31442 redirected in several different ways:
31443 </para>
31444 <itemizedlist>
31445 <listitem>
31446 <para>
31447 It can be replaced by one or more new addresses which are themselves routed
31448 independently.
31449 </para>
31450 </listitem>
31451 <listitem>
31452 <para>
31453 It can be routed to be delivered to a given file or directory.
31454 </para>
31455 </listitem>
31456 <listitem>
31457 <para>
31458 It can be routed to be delivered to a specified pipe command.
31459 </para>
31460 </listitem>
31461 <listitem>
31462 <para>
31463 It can cause an automatic reply to be generated.
31464 </para>
31465 </listitem>
31466 <listitem>
31467 <para>
31468 It can be forced to fail, with a custom error message.
31469 </para>
31470 </listitem>
31471 <listitem>
31472 <para>
31473 It can be temporarily deferred.
31474 </para>
31475 </listitem>
31476 <listitem>
31477 <para>
31478 It can be discarded.
31479 </para>
31480 </listitem>
31481 </itemizedlist>
31482 <para>
31483 The generic <option>transport</option> option must not be set for <command>redirect</command> routers.
31484 However, there are some private options which define transports for delivery to
31485 files and pipes, and for generating autoreplies. See the <option>file_transport</option>,
31486 <option>pipe_transport</option> and <option>reply_transport</option> descriptions below.
31487 </para>
31488 <section>
31489 <title>Redirection data</title>
31490 <para>
31491 The router operates by interpreting a text string which it obtains either by
31492 expanding the contents of the <option>data</option> option, or by reading the entire
31493 contents of a file whose name is given in the <option>file</option> option. These two
31494 options are mutually exclusive. The first is commonly used for handling system
31495 aliases, in a configuration like this:
31496 </para>
31497 <literallayout class="monospaced">
31498 system_aliases:
31499   driver = redirect
31500   data = ${lookup{$local_part}lsearch{/etc/aliases}}
31501 </literallayout>
31502 <para>
31503 If the lookup fails, the expanded string in this example is empty. When the
31504 expansion of <option>data</option> results in an empty string, the router declines. A forced
31505 expansion failure also causes the router to decline; other expansion failures
31506 cause delivery to be deferred.
31507 </para>
31508 <para>
31509 A configuration using <option>file</option> is commonly used for handling users&#x2019;
31510 <filename>.forward</filename> files, like this:
31511 </para>
31512 <literallayout class="monospaced">
31513 userforward:
31514   driver = redirect
31515   check_local_user
31516   file = $home/.forward
31517   no_verify
31518 </literallayout>
31519 <para>
31520 If the file does not exist, or causes no action to be taken (for example, it is
31521 empty or consists only of comments), the router declines. <emphasis role="bold">Warning</emphasis>: This
31522 is not the case when the file contains syntactically valid items that happen to
31523 yield empty addresses, for example, items containing only RFC 2822 address
31524 comments.
31525 </para>
31526 </section>
31527 <section>
31528 <title>Forward files and address verification</title>
31529 <para>
31530 <indexterm role="concept">
31531 <primary>address redirection</primary>
31532 <secondary>while verifying</secondary>
31533 </indexterm>
31534 It is usual to set <option>no_verify</option> on <command>redirect</command> routers which handle users&#x2019;
31535 <filename>.forward</filename> files, as in the example above. There are two reasons for this:
31536 </para>
31537 <itemizedlist>
31538 <listitem>
31539 <para>
31540 When Exim is receiving an incoming SMTP message from a remote host, it is
31541 running under the Exim uid, not as root.
31542 No additional groups are set up, even if the Exim uid is a member of other
31543 groups (that is, the <function>initgroups()</function> function is not run).
31544 Exim is unable to change uid to read the file as the user, and it may not be
31545 able to read it as the Exim user. So in practice the router may not be able to
31546 operate.
31547 </para>
31548 </listitem>
31549 <listitem>
31550 <para>
31551 However, even when the router can operate, the existence of a <filename>.forward</filename> file
31552 is unimportant when verifying an address. What should be checked is whether the
31553 local part is a valid user name or not. Cutting out the redirection processing
31554 saves some resources.
31555 </para>
31556 </listitem>
31557 </itemizedlist>
31558 </section>
31559 <section>
31560 <title>Interpreting redirection data</title>
31561 <para>
31562 <indexterm role="concept">
31563 <primary>Sieve filter</primary>
31564 <secondary>specifying in redirection data</secondary>
31565 </indexterm>
31566 <indexterm role="concept">
31567 <primary>filter</primary>
31568 <secondary>specifying in redirection data</secondary>
31569 </indexterm>
31570 The contents of the data string, whether obtained from <option>data</option> or <option>file</option>,
31571 can be interpreted in two different ways:
31572 </para>
31573 <itemizedlist>
31574 <listitem>
31575 <para>
31576 If the <option>allow_filter</option> option is set true, and the data begins with the text
31577 <quote>#Exim filter</quote> or <quote>#Sieve filter</quote>, it is interpreted as a list of
31578 <emphasis>filtering</emphasis> instructions in the form of an Exim or Sieve filter file,
31579 respectively. Details of the syntax and semantics of filter files are described
31580 in a separate document entitled <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis>; this
31581 document is intended for use by end users.
31582 </para>
31583 </listitem>
31584 <listitem>
31585 <para>
31586 Otherwise, the data must be a comma-separated list of redirection items, as
31587 described in the next section.
31588 </para>
31589 </listitem>
31590 </itemizedlist>
31591 <para>
31592 When a message is redirected to a file (a <quote>mail folder</quote>), the file name given
31593 in a non-filter redirection list must always be an absolute path. A filter may
31594 generate a relative path &ndash; how this is handled depends on the transport&#x2019;s
31595 configuration. See section <xref linkend="SECTfildiropt"/> for a discussion of this issue
31596 for the <command>appendfile</command> transport.
31597 </para>
31598 </section>
31599 <section id="SECTitenonfilred">
31600 <title>Items in a non-filter redirection list</title>
31601 <para>
31602 <indexterm role="concept">
31603 <primary>address redirection</primary>
31604 <secondary>non-filter list items</secondary>
31605 </indexterm>
31606 When the redirection data is not an Exim or Sieve filter, for example, if it
31607 comes from a conventional alias or forward file, it consists of a list of
31608 addresses, file names, pipe commands, or certain special items (see section
31609 <xref linkend="SECTspecitredli"/> below). The special items can be individually enabled or
31610 disabled by means of options whose names begin with <option>allow_</option> or <option>forbid_</option>,
31611 depending on their default values. The items in the list are separated by
31612 commas or newlines.
31613 If a comma is required in an item, the entire item must be enclosed in double
31614 quotes.
31615 </para>
31616 <para>
31617 Lines starting with a # character are comments, and are ignored, and # may
31618 also appear following a comma, in which case everything between the # and the
31619 next newline character is ignored.
31620 </para>
31621 <para>
31622 If an item is entirely enclosed in double quotes, these are removed. Otherwise
31623 double quotes are retained because some forms of mail address require their use
31624 (but never to enclose the entire address). In the following description,
31625 <quote>item</quote> refers to what remains after any surrounding double quotes have been
31626 removed.
31627 </para>
31628 <para>
31629 <indexterm role="concept">
31630 <primary><varname>$local_part</varname></primary>
31631 </indexterm>
31632 <emphasis role="bold">Warning</emphasis>: If you use an Exim expansion to construct a redirection address,
31633 and the expansion contains a reference to <varname>$local_part</varname>, you should make use
31634 of the <option>quote_local_part</option> expansion operator, in case the local part contains
31635 special characters. For example, to redirect all mail for the domain
31636 <emphasis>obsolete.example</emphasis>, retaining the existing local part, you could use this
31637 setting:
31638 </para>
31639 <literallayout class="monospaced">
31640 data = ${quote_local_part:$local_part}@newdomain.example
31641 </literallayout>
31642 </section>
31643 <section id="SECTredlocmai">
31644 <title>Redirecting to a local mailbox</title>
31645 <para>
31646 <indexterm role="concept">
31647 <primary>routing</primary>
31648 <secondary>loops in</secondary>
31649 </indexterm>
31650 <indexterm role="concept">
31651 <primary>loop while routing</primary>
31652 <secondary>avoidance of</secondary>
31653 </indexterm>
31654 <indexterm role="concept">
31655 <primary>address redirection</primary>
31656 <secondary>to local mailbox</secondary>
31657 </indexterm>
31658 A redirection item may safely be the same as the address currently under
31659 consideration. This does not cause a routing loop, because a router is
31660 automatically skipped if any ancestor of the address that is being processed
31661 is the same as the current address and was processed by the current router.
31662 Such an address is therefore passed to the following routers, so it is handled
31663 as if there were no redirection. When making this loop-avoidance test, the
31664 complete local part, including any prefix or suffix, is used.
31665 </para>
31666 <para>
31667 <indexterm role="concept">
31668 <primary>address redirection</primary>
31669 <secondary>local part without domain</secondary>
31670 </indexterm>
31671 Specifying the same local part without a domain is a common usage in personal
31672 filter files when the user wants to have messages delivered to the local
31673 mailbox and also forwarded elsewhere. For example, the user whose login is
31674 <emphasis>cleo</emphasis> might have a <filename>.forward</filename> file containing this:
31675 </para>
31676 <literallayout class="monospaced">
31677 cleo, cleopatra@egypt.example
31678 </literallayout>
31679 <para>
31680 <indexterm role="concept">
31681 <primary>backslash in alias file</primary>
31682 </indexterm>
31683 <indexterm role="concept">
31684 <primary>alias file</primary>
31685 <secondary>backslash in</secondary>
31686 </indexterm>
31687 For compatibility with other MTAs, such unqualified local parts may be
31688 preceeded by <quote>\</quote>, but this is not a requirement for loop prevention. However,
31689 it does make a difference if more than one domain is being handled
31690 synonymously.
31691 </para>
31692 <para>
31693 If an item begins with <quote>\</quote> and the rest of the item parses as a valid RFC
31694 2822 address that does not include a domain, the item is qualified using the
31695 domain of the incoming address. In the absence of a leading <quote>\</quote>, unqualified
31696 addresses are qualified using the value in <option>qualify_recipient</option>, but you can
31697 force the incoming domain to be used by setting <option>qualify_preserve_domain</option>.
31698 </para>
31699 <para>
31700 Care must be taken if there are alias names for local users.
31701 Consider an MTA handling a single local domain where the system alias file
31702 contains:
31703 </para>
31704 <literallayout class="monospaced">
31705 Sam.Reman: spqr
31706 </literallayout>
31707 <para>
31708 Now suppose that Sam (whose login id is <emphasis>spqr</emphasis>) wants to save copies of
31709 messages in the local mailbox, and also forward copies elsewhere. He creates
31710 this forward file:
31711 </para>
31712 <literallayout class="monospaced">
31713 Sam.Reman, spqr@reme.elsewhere.example
31714 </literallayout>
31715 <para>
31716 With these settings, an incoming message addressed to <emphasis>Sam.Reman</emphasis> fails. The
31717 <command>redirect</command> router for system aliases does not process <emphasis>Sam.Reman</emphasis> the
31718 second time round, because it has previously routed it,
31719 and the following routers presumably cannot handle the alias. The forward file
31720 should really contain
31721 </para>
31722 <literallayout class="monospaced">
31723 spqr, spqr@reme.elsewhere.example
31724 </literallayout>
31725 <para>
31726 but because this is such a common error, the <option>check_ancestor</option> option (see
31727 below) exists to provide a way to get round it. This is normally set on a
31728 <command>redirect</command> router that is handling users&#x2019; <filename>.forward</filename> files.
31729 </para>
31730 </section>
31731 <section id="SECTspecitredli">
31732 <title>Special items in redirection lists</title>
31733 <para>
31734 In addition to addresses, the following types of item may appear in redirection
31735 lists (that is, in non-filter redirection data):
31736 </para>
31737 <itemizedlist>
31738 <listitem>
31739 <para>
31740 <indexterm role="concept">
31741 <primary>pipe</primary>
31742 <secondary>in redirection list</secondary>
31743 </indexterm>
31744 <indexterm role="concept">
31745 <primary>address redirection</primary>
31746 <secondary>to pipe</secondary>
31747 </indexterm>
31748 An item is treated as a pipe command if it begins with <quote>|</quote> and does not parse
31749 as a valid RFC 2822 address that includes a domain. A transport for running the
31750 command must be specified by the <option>pipe_transport</option> option.
31751 Normally, either the router or the transport specifies a user and a group under
31752 which to run the delivery. The default is to use the Exim user and group.
31753 </para>
31754 <para>
31755 Single or double quotes can be used for enclosing the individual arguments of
31756 the pipe command; no interpretation of escapes is done for single quotes. If
31757 the command contains a comma character, it is necessary to put the whole item
31758 in double quotes, for example:
31759 </para>
31760 <literallayout class="monospaced">
31761 "|/some/command ready,steady,go"
31762 </literallayout>
31763 <para>
31764 since items in redirection lists are terminated by commas. Do not, however,
31765 quote just the command. An item such as
31766 </para>
31767 <literallayout class="monospaced">
31768 |"/some/command ready,steady,go"
31769 </literallayout>
31770 <para>
31771 is interpreted as a pipe with a rather strange command name, and no arguments.
31772 </para>
31773 </listitem>
31774 <listitem>
31775 <para>
31776 <indexterm role="concept">
31777 <primary>file</primary>
31778 <secondary>in redirection list</secondary>
31779 </indexterm>
31780 <indexterm role="concept">
31781 <primary>address redirection</primary>
31782 <secondary>to file</secondary>
31783 </indexterm>
31784 An item is interpreted as a path name if it begins with <quote>/</quote> and does not
31785 parse as a valid RFC 2822 address that includes a domain. For example,
31786 </para>
31787 <literallayout class="monospaced">
31788 /home/world/minbari
31789 </literallayout>
31790 <para>
31791 is treated as a file name, but
31792 </para>
31793 <literallayout class="monospaced">
31794 /s=molari/o=babylon/@x400gate.way
31795 </literallayout>
31796 <para>
31797 is treated as an address. For a file name, a transport must be specified using
31798 the <option>file_transport</option> option. However, if the generated path name ends with a
31799 forward slash character, it is interpreted as a directory name rather than a
31800 file name, and <option>directory_transport</option> is used instead.
31801 </para>
31802 <para>
31803 Normally, either the router or the transport specifies a user and a group under
31804 which to run the delivery. The default is to use the Exim user and group.
31805 </para>
31806 <para>
31807 <indexterm role="concept">
31808 <primary><filename>/dev/null</filename></primary>
31809 </indexterm>
31810 However, if a redirection item is the path <filename>/dev/null</filename>, delivery to it is
31811 bypassed at a high level, and the log entry shows <quote>**bypassed**</quote>
31812 instead of a transport name. In this case the user and group are not used.
31813 </para>
31814 </listitem>
31815 <listitem>
31816 <para>
31817 <indexterm role="concept">
31818 <primary>included address list</primary>
31819 </indexterm>
31820 <indexterm role="concept">
31821 <primary>address redirection</primary>
31822 <secondary>included external list</secondary>
31823 </indexterm>
31824 If an item is of the form
31825 </para>
31826 <literallayout class="monospaced">
31827 :include:&lt;path name&gt;
31828 </literallayout>
31829 <para>
31830 a list of further items is taken from the given file and included at that
31831 point. <emphasis role="bold">Note</emphasis>: Such a file can not be a filter file; it is just an
31832 out-of-line addition to the list. The items in the included list are separated
31833 by commas or newlines and are not subject to expansion. If this is the first
31834 item in an alias list in an <command>lsearch</command> file, a colon must be used to terminate
31835 the alias name. This example is incorrect:
31836 </para>
31837 <literallayout class="monospaced">
31838 list1    :include:/opt/lists/list1
31839 </literallayout>
31840 <para>
31841 It must be given as
31842 </para>
31843 <literallayout class="monospaced">
31844 list1:   :include:/opt/lists/list1
31845 </literallayout>
31846 </listitem>
31847 <listitem>
31848 <para>
31849 <indexterm role="concept">
31850 <primary>address redirection</primary>
31851 <secondary>to black hole</secondary>
31852 </indexterm>
31853 Sometimes you want to throw away mail to a particular local part. Making the
31854 <option>data</option> option expand to an empty string does not work, because that causes
31855 the router to decline. Instead, the alias item
31856 <indexterm role="concept">
31857 <primary>black hole</primary>
31858 </indexterm>
31859 <indexterm role="concept">
31860 <primary>abandoning mail</primary>
31861 </indexterm>
31862 </para>
31863 <literallayout class="monospaced">
31864 :blackhole:
31865 </literallayout>
31866 <para>
31867 can be used. It does what its name implies. No delivery is done, and no error
31868 message is generated. This has the same effect as specifing <filename>/dev/null</filename>, but
31869 can be independently disabled.
31870 </para>
31871 <para>
31872 <emphasis role="bold">Warning</emphasis>: If <literal>:blackhole:</literal> appears anywhere in a redirection list, no
31873 delivery is done for the original local part, even if other redirection items
31874 are present. If you are generating a multi-item list (for example, by reading a
31875 database) and need the ability to provide a no-op item, you must use
31876 <filename>/dev/null</filename>.
31877 </para>
31878 </listitem>
31879 <listitem>
31880 <para>
31881 <indexterm role="concept">
31882 <primary>delivery</primary>
31883 <secondary>forcing failure</secondary>
31884 </indexterm>
31885 <indexterm role="concept">
31886 <primary>delivery</primary>
31887 <secondary>forcing deferral</secondary>
31888 </indexterm>
31889 <indexterm role="concept">
31890 <primary>failing delivery</primary>
31891 <secondary>forcing</secondary>
31892 </indexterm>
31893 <indexterm role="concept">
31894 <primary>deferred delivery</primary>
31895 <secondary>forcing</secondary>
31896 </indexterm>
31897 <indexterm role="concept">
31898 <primary>customizing</primary>
31899 <secondary>failure message</secondary>
31900 </indexterm>
31901 An attempt to deliver a particular address can be deferred or forced to fail by
31902 redirection items of the form
31903 </para>
31904 <literallayout class="monospaced">
31905 :defer:
31906 :fail:
31907 </literallayout>
31908 <para>
31909 respectively. When a redirection list contains such an item, it applies to the
31910 entire redirection; any other items in the list are ignored (<emphasis>:blackhole:</emphasis> is
31911 different). Any text following <emphasis>:fail:</emphasis> or <emphasis>:defer:</emphasis> is placed in the error
31912 text associated with the failure. For example, an alias file might contain:
31913 </para>
31914 <literallayout class="monospaced">
31915 X.Employee:  :fail: Gone away, no forwarding address
31916 </literallayout>
31917 <para>
31918 In the case of an address that is being verified from an ACL or as the subject
31919 of a
31920 <indexterm role="concept">
31921 <primary>VRFY error text</primary>
31922 <secondary>display of</secondary>
31923 </indexterm>
31924 VRFY command, the text is included in the SMTP error response by
31925 default.
31926 <indexterm role="concept">
31927 <primary>EXPN error text</primary>
31928 <secondary>display of</secondary>
31929 </indexterm>
31930 The text is not included in the response to an EXPN command.
31931 </para>
31932 <para>
31933 <indexterm role="concept">
31934 <primary><varname>$acl_verify_message</varname></primary>
31935 </indexterm>
31936 In an ACL, an explicitly provided message overrides the default, but the
31937 default message is available in the variable <varname>$acl_verify_message</varname> and can
31938 therefore be included in a custom message if this is desired. Exim sends a 451
31939 SMTP code for a <emphasis>:defer:</emphasis>, and 550 for <emphasis>:fail:</emphasis>. In non-SMTP cases the text
31940 is included in the error message that Exim generates.
31941 </para>
31942 <para>
31943 Normally the error text is the rest of the redirection list &ndash; a comma does
31944 not terminate it &ndash; but a newline does act as a terminator. Newlines are not
31945 normally present in alias expansions. In <command>lsearch</command> lookups they are removed
31946 as part of the continuation process, but they may exist in other kinds of
31947 lookup and in <emphasis>:include:</emphasis> files.
31948 </para>
31949 <para>
31950 During routing for message delivery (as opposed to verification), a redirection
31951 containing <emphasis>:fail:</emphasis> causes an immediate failure of the incoming address,
31952 whereas <emphasis>:defer:</emphasis> causes the message to remain on the queue so that a
31953 subsequent delivery attempt can happen at a later time. If an address is
31954 deferred for too long, it will ultimately fail, because the normal retry
31955 rules still apply.
31956 </para>
31957 </listitem>
31958 <listitem>
31959 <para>
31960 <indexterm role="concept">
31961 <primary>alias file</primary>
31962 <secondary>exception to default</secondary>
31963 </indexterm>
31964 Sometimes it is useful to use a single-key search type with a default (see
31965 chapter <xref linkend="CHAPfdlookup"/>) to look up aliases. However, there may be a need
31966 for exceptions to the default. These can be handled by aliasing them to
31967 </para>
31968 <literallayout class="monospaced">
31969 :unknown:
31970 </literallayout>
31971 <para>
31972 This differs from <emphasis>:fail:</emphasis> in that it causes the <command>redirect</command> router to
31973 decline, whereas <emphasis>:fail:</emphasis> forces routing to fail. A lookup which results in
31974 an empty redirection list has the same effect.
31975 </para>
31976 </listitem>
31977 </itemizedlist>
31978 </section>
31979 <section>
31980 <title>Duplicate addresses</title>
31981 <para>
31982 <indexterm role="concept">
31983 <primary>duplicate addresses</primary>
31984 </indexterm>
31985 <indexterm role="concept">
31986 <primary>address duplicate</primary>
31987 <secondary>discarding</secondary>
31988 </indexterm>
31989 <indexterm role="concept">
31990 <primary>pipe</primary>
31991 <secondary>duplicated</secondary>
31992 </indexterm>
31993 Exim removes duplicate addresses from the list to which it is delivering, so as
31994 to deliver just one copy to each address. This does not apply to deliveries
31995 routed to pipes by different immediate parent addresses, but an indirect
31996 aliasing scheme of the type
31997 </para>
31998 <literallayout class="monospaced">
31999 pipe:       |/some/command $local_part
32000 localpart1: pipe
32001 localpart2: pipe
32002 </literallayout>
32003 <para>
32004 does not work with a message that is addressed to both local parts, because
32005 when the second is aliased to the intermediate local part <quote>pipe</quote> it gets
32006 discarded as being the same as a previously handled address. However, a scheme
32007 such as
32008 </para>
32009 <literallayout class="monospaced">
32010 localpart1: |/some/command $local_part
32011 localpart2: |/some/command $local_part
32012 </literallayout>
32013 <para>
32014 does result in two different pipe deliveries, because the immediate parents of
32015 the pipes are distinct.
32016 </para>
32017 </section>
32018 <section>
32019 <title>Repeated redirection expansion</title>
32020 <para>
32021 <indexterm role="concept">
32022 <primary>repeated redirection expansion</primary>
32023 </indexterm>
32024 <indexterm role="concept">
32025 <primary>address redirection</primary>
32026 <secondary>repeated for each delivery attempt</secondary>
32027 </indexterm>
32028 When a message cannot be delivered to all of its recipients immediately,
32029 leading to two or more delivery attempts, redirection expansion is carried out
32030 afresh each time for those addresses whose children were not all previously
32031 delivered. If redirection is being used as a mailing list, this can lead to new
32032 members of the list receiving copies of old messages. The <option>one_time</option> option
32033 can be used to avoid this.
32034 </para>
32035 </section>
32036 <section>
32037 <title>Errors in redirection lists</title>
32038 <para>
32039 <indexterm role="concept">
32040 <primary>address redirection</primary>
32041 <secondary>errors</secondary>
32042 </indexterm>
32043 If <option>skip_syntax_errors</option> is set, a malformed address that causes a parsing
32044 error is skipped, and an entry is written to the main log. This may be useful
32045 for mailing lists that are automatically managed. Otherwise, if an error is
32046 detected while generating the list of new addresses, the original address is
32047 deferred. See also <option>syntax_errors_to</option>.
32048 </para>
32049 </section>
32050 <section>
32051 <title>Private options for the redirect router</title>
32052 <para>
32053 <indexterm role="concept">
32054 <primary>options</primary>
32055 <secondary><command>redirect</command> router</secondary>
32056 </indexterm>
32057 The private options for the <command>redirect</command> router are as follows:
32058 </para>
32059 <para>
32060 <indexterm role="option">
32061 <primary>allow_defer</primary>
32062 </indexterm>
32063 </para>
32064 <informaltable frame="all">
32065 <tgroup cols="4" colsep="0" rowsep="0">
32066 <colspec colwidth="8*" align="left"/>
32067 <colspec colwidth="5*" align="center"/>
32068 <colspec colwidth="5*" align="center"/>
32069 <colspec colwidth="6*" align="right"/>
32070 <tbody>
32071 <row>
32072 <entry><option>allow_defer</option></entry>
32073 <entry>Use: <emphasis>redirect</emphasis></entry>
32074 <entry>Type: <emphasis>boolean</emphasis></entry>
32075 <entry>Default: <emphasis>false</emphasis></entry>
32076 </row>
32077 </tbody>
32078 </tgroup>
32079 </informaltable>
32080 <para>
32081 Setting this option allows the use of <emphasis>:defer:</emphasis> in non-filter redirection
32082 data, or the <option>defer</option> command in an Exim filter file.
32083 </para>
32084 <para>
32085 <indexterm role="option">
32086 <primary>allow_fail</primary>
32087 </indexterm>
32088 </para>
32089 <informaltable frame="all">
32090 <tgroup cols="4" colsep="0" rowsep="0">
32091 <colspec colwidth="8*" align="left"/>
32092 <colspec colwidth="5*" align="center"/>
32093 <colspec colwidth="5*" align="center"/>
32094 <colspec colwidth="6*" align="right"/>
32095 <tbody>
32096 <row>
32097 <entry><option>allow_fail</option></entry>
32098 <entry>Use: <emphasis>redirect</emphasis></entry>
32099 <entry>Type: <emphasis>boolean</emphasis></entry>
32100 <entry>Default: <emphasis>false</emphasis></entry>
32101 </row>
32102 </tbody>
32103 </tgroup>
32104 </informaltable>
32105 <para>
32106 <indexterm role="concept">
32107 <primary>failing delivery</primary>
32108 <secondary>from filter</secondary>
32109 </indexterm>
32110 If this option is true, the <emphasis>:fail:</emphasis> item can be used in a redirection list,
32111 and the <option>fail</option> command may be used in an Exim filter file.
32112 </para>
32113 <para>
32114 <indexterm role="option">
32115 <primary>allow_filter</primary>
32116 </indexterm>
32117 </para>
32118 <informaltable frame="all">
32119 <tgroup cols="4" colsep="0" rowsep="0">
32120 <colspec colwidth="8*" align="left"/>
32121 <colspec colwidth="5*" align="center"/>
32122 <colspec colwidth="5*" align="center"/>
32123 <colspec colwidth="6*" align="right"/>
32124 <tbody>
32125 <row>
32126 <entry><option>allow_filter</option></entry>
32127 <entry>Use: <emphasis>redirect</emphasis></entry>
32128 <entry>Type: <emphasis>boolean</emphasis></entry>
32129 <entry>Default: <emphasis>false</emphasis></entry>
32130 </row>
32131 </tbody>
32132 </tgroup>
32133 </informaltable>
32134 <para>
32135 <indexterm role="concept">
32136 <primary>filter</primary>
32137 <secondary>enabling use of</secondary>
32138 </indexterm>
32139 <indexterm role="concept">
32140 <primary>Sieve filter</primary>
32141 <secondary>enabling use of</secondary>
32142 </indexterm>
32143 Setting this option allows Exim to interpret redirection data that starts with
32144 <quote>#Exim filter</quote> or <quote>#Sieve filter</quote> as a set of filtering instructions. There
32145 are some features of Exim filter files that some administrators may wish to
32146 lock out; see the <option>forbid_filter_</option><emphasis>xxx</emphasis> options below.
32147 </para>
32148 <para>
32149 It is also possible to lock out Exim filters or Sieve filters while allowing
32150 the other type; see <option>forbid_exim_filter</option> and <option>forbid_sieve_filter</option>.
32151 </para>
32152 <para>
32153 The filter is run using the uid and gid set by the generic <option>user</option> and
32154 <option>group</option> options. These take their defaults from the password data if
32155 <option>check_local_user</option> is set, so in the normal case of users&#x2019; personal filter
32156 files, the filter is run as the relevant user. When <option>allow_filter</option> is set
32157 true, Exim insists that either <option>check_local_user</option> or <option>user</option> is set.
32158 </para>
32159 <para>
32160 <indexterm role="option">
32161 <primary>allow_freeze</primary>
32162 </indexterm>
32163 </para>
32164 <informaltable frame="all">
32165 <tgroup cols="4" colsep="0" rowsep="0">
32166 <colspec colwidth="8*" align="left"/>
32167 <colspec colwidth="5*" align="center"/>
32168 <colspec colwidth="5*" align="center"/>
32169 <colspec colwidth="6*" align="right"/>
32170 <tbody>
32171 <row>
32172 <entry><option>allow_freeze</option></entry>
32173 <entry>Use: <emphasis>redirect</emphasis></entry>
32174 <entry>Type: <emphasis>boolean</emphasis></entry>
32175 <entry>Default: <emphasis>false</emphasis></entry>
32176 </row>
32177 </tbody>
32178 </tgroup>
32179 </informaltable>
32180 <para>
32181 <indexterm role="concept">
32182 <primary>freezing messages</primary>
32183 <secondary>allowing in filter</secondary>
32184 </indexterm>
32185 Setting this option allows the use of the <option>freeze</option> command in an Exim filter.
32186 This command is more normally encountered in system filters, and is disabled by
32187 default for redirection filters because it isn&#x2019;t something you usually want to
32188 let ordinary users do.
32189 </para>
32190 <para>
32191 <indexterm role="option">
32192 <primary>check_ancestor</primary>
32193 </indexterm>
32194 </para>
32195 <informaltable frame="all">
32196 <tgroup cols="4" colsep="0" rowsep="0">
32197 <colspec colwidth="8*" align="left"/>
32198 <colspec colwidth="5*" align="center"/>
32199 <colspec colwidth="5*" align="center"/>
32200 <colspec colwidth="6*" align="right"/>
32201 <tbody>
32202 <row>
32203 <entry><option>check_ancestor</option></entry>
32204 <entry>Use: <emphasis>redirect</emphasis></entry>
32205 <entry>Type: <emphasis>boolean</emphasis></entry>
32206 <entry>Default: <emphasis>false</emphasis></entry>
32207 </row>
32208 </tbody>
32209 </tgroup>
32210 </informaltable>
32211 <para>
32212 This option is concerned with handling generated addresses that are the same
32213 as some address in the list of redirection ancestors of the current address.
32214 Although it is turned off by default in the code, it is set in the default
32215 configuration file for handling users&#x2019; <filename>.forward</filename> files. It is recommended
32216 for this use of the <command>redirect</command> router.
32217 </para>
32218 <para>
32219 When <option>check_ancestor</option> is set, if a generated address (including the domain)
32220 is the same as any ancestor of the current address, it is replaced by a copy of
32221 the current address. This helps in the case where local part A is aliased to B,
32222 and B has a <filename>.forward</filename> file pointing back to A. For example, within a single
32223 domain, the local part <quote>Joe.Bloggs</quote> is aliased to <quote>jb</quote> and
32224 <filename>&nbsp;jb/.forward</filename> contains:
32225 </para>
32226 <literallayout class="monospaced">
32227 \Joe.Bloggs, &lt;other item(s)&gt;
32228 </literallayout>
32229 <para>
32230 Without the <option>check_ancestor</option> setting, either local part (<quote>jb</quote> or
32231 <quote>joe.bloggs</quote>) gets processed once by each router and so ends up as it was
32232 originally. If <quote>jb</quote> is the real mailbox name, mail to <quote>jb</quote> gets delivered
32233 (having been turned into <quote>joe.bloggs</quote> by the <filename>.forward</filename> file and back to
32234 <quote>jb</quote> by the alias), but mail to <quote>joe.bloggs</quote> fails. Setting
32235 <option>check_ancestor</option> on the <command>redirect</command> router that handles the <filename>.forward</filename>
32236 file prevents it from turning <quote>jb</quote> back into <quote>joe.bloggs</quote> when that was the
32237 original address. See also the <option>repeat_use</option> option below.
32238 </para>
32239 <para>
32240 <indexterm role="option">
32241 <primary>check_group</primary>
32242 </indexterm>
32243 </para>
32244 <informaltable frame="all">
32245 <tgroup cols="4" colsep="0" rowsep="0">
32246 <colspec colwidth="8*" align="left"/>
32247 <colspec colwidth="5*" align="center"/>
32248 <colspec colwidth="5*" align="center"/>
32249 <colspec colwidth="6*" align="right"/>
32250 <tbody>
32251 <row>
32252 <entry><option>check_group</option></entry>
32253 <entry>Use: <emphasis>redirect</emphasis></entry>
32254 <entry>Type: <emphasis>boolean</emphasis></entry>
32255 <entry>Default: <emphasis>see below</emphasis></entry>
32256 </row>
32257 </tbody>
32258 </tgroup>
32259 </informaltable>
32260 <para>
32261 When the <option>file</option> option is used, the group owner of the file is checked only
32262 when this option is set. The permitted groups are those listed in the
32263 <option>owngroups</option> option, together with the user&#x2019;s default group if
32264 <option>check_local_user</option> is set. If the file has the wrong group, routing is
32265 deferred. The default setting for this option is true if <option>check_local_user</option>
32266 is set and the <option>modemask</option> option permits the group write bit, or if the
32267 <option>owngroups</option> option is set. Otherwise it is false, and no group check occurs.
32268 </para>
32269 <para>
32270 <indexterm role="option">
32271 <primary>check_owner</primary>
32272 </indexterm>
32273 </para>
32274 <informaltable frame="all">
32275 <tgroup cols="4" colsep="0" rowsep="0">
32276 <colspec colwidth="8*" align="left"/>
32277 <colspec colwidth="5*" align="center"/>
32278 <colspec colwidth="5*" align="center"/>
32279 <colspec colwidth="6*" align="right"/>
32280 <tbody>
32281 <row>
32282 <entry><option>check_owner</option></entry>
32283 <entry>Use: <emphasis>redirect</emphasis></entry>
32284 <entry>Type: <emphasis>boolean</emphasis></entry>
32285 <entry>Default: <emphasis>see below</emphasis></entry>
32286 </row>
32287 </tbody>
32288 </tgroup>
32289 </informaltable>
32290 <para>
32291 When the <option>file</option> option is used, the owner of the file is checked only when
32292 this option is set. If <option>check_local_user</option> is set, the local user is
32293 permitted; otherwise the owner must be one of those listed in the <option>owners</option>
32294 option. The default value for this option is true if <option>check_local_user</option> or
32295 <option>owners</option> is set. Otherwise the default is false, and no owner check occurs.
32296 </para>
32297 <para>
32298 <indexterm role="option">
32299 <primary>data</primary>
32300 </indexterm>
32301 </para>
32302 <informaltable frame="all">
32303 <tgroup cols="4" colsep="0" rowsep="0">
32304 <colspec colwidth="8*" align="left"/>
32305 <colspec colwidth="5*" align="center"/>
32306 <colspec colwidth="5*" align="center"/>
32307 <colspec colwidth="6*" align="right"/>
32308 <tbody>
32309 <row>
32310 <entry><option>data</option></entry>
32311 <entry>Use: <emphasis>redirect</emphasis></entry>
32312 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32313 <entry>Default: <emphasis>unset</emphasis></entry>
32314 </row>
32315 </tbody>
32316 </tgroup>
32317 </informaltable>
32318 <para>
32319 This option is mutually exclusive with <option>file</option>. One or other of them must be
32320 set, but not both. The contents of <option>data</option> are expanded, and then used as the
32321 list of forwarding items, or as a set of filtering instructions. If the
32322 expansion is forced to fail, or the result is an empty string or a string that
32323 has no effect (consists entirely of comments), the router declines.
32324 </para>
32325 <para>
32326 When filtering instructions are used, the string must begin with <quote>#Exim
32327 filter</quote>, and all comments in the string, including this initial one, must be
32328 terminated with newline characters. For example:
32329 </para>
32330 <literallayout class="monospaced">
32331 data = #Exim filter\n\
32332        if $h_to: contains Exim then save $home/mail/exim endif
32333 </literallayout>
32334 <para>
32335 If you are reading the data from a database where newlines cannot be included,
32336 you can use the <varname>${sg}</varname> expansion item to turn the escape string of your
32337 choice into a newline.
32338 </para>
32339 <para>
32340 <indexterm role="option">
32341 <primary>directory_transport</primary>
32342 </indexterm>
32343 </para>
32344 <informaltable frame="all">
32345 <tgroup cols="4" colsep="0" rowsep="0">
32346 <colspec colwidth="8*" align="left"/>
32347 <colspec colwidth="5*" align="center"/>
32348 <colspec colwidth="5*" align="center"/>
32349 <colspec colwidth="6*" align="right"/>
32350 <tbody>
32351 <row>
32352 <entry><option>directory_transport</option></entry>
32353 <entry>Use: <emphasis>redirect</emphasis></entry>
32354 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32355 <entry>Default: <emphasis>unset</emphasis></entry>
32356 </row>
32357 </tbody>
32358 </tgroup>
32359 </informaltable>
32360 <para>
32361 A <command>redirect</command> router sets up a direct delivery to a directory when a path name
32362 ending with a slash is specified as a new <quote>address</quote>. The transport used is
32363 specified by this option, which, after expansion, must be the name of a
32364 configured transport. This should normally be an <command>appendfile</command> transport.
32365 </para>
32366 <para>
32367 <indexterm role="option">
32368 <primary>file</primary>
32369 </indexterm>
32370 </para>
32371 <informaltable frame="all">
32372 <tgroup cols="4" colsep="0" rowsep="0">
32373 <colspec colwidth="8*" align="left"/>
32374 <colspec colwidth="5*" align="center"/>
32375 <colspec colwidth="5*" align="center"/>
32376 <colspec colwidth="6*" align="right"/>
32377 <tbody>
32378 <row>
32379 <entry><option>file</option></entry>
32380 <entry>Use: <emphasis>redirect</emphasis></entry>
32381 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32382 <entry>Default: <emphasis>unset</emphasis></entry>
32383 </row>
32384 </tbody>
32385 </tgroup>
32386 </informaltable>
32387 <para>
32388 This option specifies the name of a file that contains the redirection data. It
32389 is mutually exclusive with the <option>data</option> option. The string is expanded before
32390 use; if the expansion is forced to fail, the router declines. Other expansion
32391 failures cause delivery to be deferred. The result of a successful expansion
32392 must be an absolute path. The entire file is read and used as the redirection
32393 data. If the data is an empty string or a string that has no effect (consists
32394 entirely of comments), the router declines.
32395 </para>
32396 <para>
32397 <indexterm role="concept">
32398 <primary>NFS</primary>
32399 <secondary>checking for file existence</secondary>
32400 </indexterm>
32401 If the attempt to open the file fails with a <quote>does not exist</quote> error, Exim
32402 runs a check on the containing directory,
32403 unless <option>ignore_enotdir</option> is true (see below).
32404 If the directory does not appear to exist, delivery is deferred. This can
32405 happen when users&#x2019; <filename>.forward</filename> files are in NFS-mounted directories, and there
32406 is a mount problem. If the containing directory does exist, but the file does
32407 not, the router declines.
32408 </para>
32409 <para>
32410 <indexterm role="option">
32411 <primary>file_transport</primary>
32412 </indexterm>
32413 </para>
32414 <informaltable frame="all">
32415 <tgroup cols="4" colsep="0" rowsep="0">
32416 <colspec colwidth="8*" align="left"/>
32417 <colspec colwidth="5*" align="center"/>
32418 <colspec colwidth="5*" align="center"/>
32419 <colspec colwidth="6*" align="right"/>
32420 <tbody>
32421 <row>
32422 <entry><option>file_transport</option></entry>
32423 <entry>Use: <emphasis>redirect</emphasis></entry>
32424 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32425 <entry>Default: <emphasis>unset</emphasis></entry>
32426 </row>
32427 </tbody>
32428 </tgroup>
32429 </informaltable>
32430 <para>
32431 <indexterm role="concept">
32432 <primary><varname>$address_file</varname></primary>
32433 </indexterm>
32434 A <command>redirect</command> router sets up a direct delivery to a file when a path name not
32435 ending in a slash is specified as a new <quote>address</quote>. The transport used is
32436 specified by this option, which, after expansion, must be the name of a
32437 configured transport. This should normally be an <command>appendfile</command> transport. When
32438 it is running, the file name is in <varname>$address_file</varname>.
32439 </para>
32440 <para>
32441 <indexterm role="option">
32442 <primary>forbid_blackhole</primary>
32443 </indexterm>
32444 </para>
32445 <informaltable frame="all">
32446 <tgroup cols="4" colsep="0" rowsep="0">
32447 <colspec colwidth="8*" align="left"/>
32448 <colspec colwidth="5*" align="center"/>
32449 <colspec colwidth="5*" align="center"/>
32450 <colspec colwidth="6*" align="right"/>
32451 <tbody>
32452 <row>
32453 <entry><option>forbid_blackhole</option></entry>
32454 <entry>Use: <emphasis>redirect</emphasis></entry>
32455 <entry>Type: <emphasis>boolean</emphasis></entry>
32456 <entry>Default: <emphasis>false</emphasis></entry>
32457 </row>
32458 </tbody>
32459 </tgroup>
32460 </informaltable>
32461 <para>
32462 If this option is true, the <emphasis>:blackhole:</emphasis> item may not appear in a
32463 redirection list.
32464 </para>
32465 <para>
32466 <indexterm role="option">
32467 <primary>forbid_exim_filter</primary>
32468 </indexterm>
32469 </para>
32470 <informaltable frame="all">
32471 <tgroup cols="4" colsep="0" rowsep="0">
32472 <colspec colwidth="8*" align="left"/>
32473 <colspec colwidth="5*" align="center"/>
32474 <colspec colwidth="5*" align="center"/>
32475 <colspec colwidth="6*" align="right"/>
32476 <tbody>
32477 <row>
32478 <entry><option>forbid_exim_filter</option></entry>
32479 <entry>Use: <emphasis>redirect</emphasis></entry>
32480 <entry>Type: <emphasis>boolean</emphasis></entry>
32481 <entry>Default: <emphasis>false</emphasis></entry>
32482 </row>
32483 </tbody>
32484 </tgroup>
32485 </informaltable>
32486 <para>
32487 If this option is set true, only Sieve filters are permitted when
32488 <option>allow_filter</option> is true.
32489 </para>
32490 <para>
32491 <indexterm role="option">
32492 <primary>forbid_file</primary>
32493 </indexterm>
32494 </para>
32495 <informaltable frame="all">
32496 <tgroup cols="4" colsep="0" rowsep="0">
32497 <colspec colwidth="8*" align="left"/>
32498 <colspec colwidth="5*" align="center"/>
32499 <colspec colwidth="5*" align="center"/>
32500 <colspec colwidth="6*" align="right"/>
32501 <tbody>
32502 <row>
32503 <entry><option>forbid_file</option></entry>
32504 <entry>Use: <emphasis>redirect</emphasis></entry>
32505 <entry>Type: <emphasis>boolean</emphasis></entry>
32506 <entry>Default: <emphasis>false</emphasis></entry>
32507 </row>
32508 </tbody>
32509 </tgroup>
32510 </informaltable>
32511 <para>
32512 <indexterm role="concept">
32513 <primary>delivery</primary>
32514 <secondary>to file; forbidding</secondary>
32515 </indexterm>
32516 <indexterm role="concept">
32517 <primary>Sieve filter</primary>
32518 <secondary>forbidding delivery to a file</secondary>
32519 </indexterm>
32520 <indexterm role="concept">
32521 <primary>Sieve filter</primary>
32522 <secondary><quote>keep</quote> facility; disabling</secondary>
32523 </indexterm>
32524 If this option is true, this router may not generate a new address that
32525 specifies delivery to a local file or directory, either from a filter or from a
32526 conventional forward file. This option is forced to be true if <option>one_time</option> is
32527 set. It applies to Sieve filters as well as to Exim filters, but if true, it
32528 locks out the Sieve&#x2019;s <quote>keep</quote> facility.
32529 </para>
32530 <para>
32531 <indexterm role="option">
32532 <primary>forbid_filter_dlfunc</primary>
32533 </indexterm>
32534 </para>
32535 <informaltable frame="all">
32536 <tgroup cols="4" colsep="0" rowsep="0">
32537 <colspec colwidth="8*" align="left"/>
32538 <colspec colwidth="5*" align="center"/>
32539 <colspec colwidth="5*" align="center"/>
32540 <colspec colwidth="6*" align="right"/>
32541 <tbody>
32542 <row>
32543 <entry><option>forbid_filter_dlfunc</option></entry>
32544 <entry>Use: <emphasis>redirect</emphasis></entry>
32545 <entry>Type: <emphasis>boolean</emphasis></entry>
32546 <entry>Default: <emphasis>false</emphasis></entry>
32547 </row>
32548 </tbody>
32549 </tgroup>
32550 </informaltable>
32551 <para>
32552 <indexterm role="concept">
32553 <primary>filter</primary>
32554 <secondary>locking out certain features</secondary>
32555 </indexterm>
32556 If this option is true, string expansions in Exim filters are not allowed to
32557 make use of the <option>dlfunc</option> expansion facility to run dynamically loaded
32558 functions.
32559 </para>
32560 <para>
32561 <indexterm role="option">
32562 <primary>forbid_filter_existstest</primary>
32563 </indexterm>
32564 </para>
32565 <informaltable frame="all">
32566 <tgroup cols="4" colsep="0" rowsep="0">
32567 <colspec colwidth="8*" align="left"/>
32568 <colspec colwidth="5*" align="center"/>
32569 <colspec colwidth="5*" align="center"/>
32570 <colspec colwidth="6*" align="right"/>
32571 <tbody>
32572 <row>
32573 <entry><option>forbid_filter_existstest</option></entry>
32574 <entry>Use: <emphasis>redirect</emphasis></entry>
32575 <entry>Type: <emphasis>boolean</emphasis></entry>
32576 <entry>Default: <emphasis>false</emphasis></entry>
32577 </row>
32578 </tbody>
32579 </tgroup>
32580 </informaltable>
32581 <para>
32582 <indexterm role="concept">
32583 <primary>expansion</primary>
32584 <secondary>statting a file</secondary>
32585 </indexterm>
32586 If this option is true, string expansions in Exim filters are not allowed to
32587 make use of the <option>exists</option> condition or the <option>stat</option> expansion item.
32588 </para>
32589 <para>
32590 <indexterm role="option">
32591 <primary>forbid_filter_logwrite</primary>
32592 </indexterm>
32593 </para>
32594 <informaltable frame="all">
32595 <tgroup cols="4" colsep="0" rowsep="0">
32596 <colspec colwidth="8*" align="left"/>
32597 <colspec colwidth="5*" align="center"/>
32598 <colspec colwidth="5*" align="center"/>
32599 <colspec colwidth="6*" align="right"/>
32600 <tbody>
32601 <row>
32602 <entry><option>forbid_filter_logwrite</option></entry>
32603 <entry>Use: <emphasis>redirect</emphasis></entry>
32604 <entry>Type: <emphasis>boolean</emphasis></entry>
32605 <entry>Default: <emphasis>false</emphasis></entry>
32606 </row>
32607 </tbody>
32608 </tgroup>
32609 </informaltable>
32610 <para>
32611 If this option is true, use of the logging facility in Exim filters is not
32612 permitted. Logging is in any case available only if the filter is being run
32613 under some unprivileged uid (which is normally the case for ordinary users&#x2019;
32614 <filename>.forward</filename> files).
32615 </para>
32616 <para>
32617 <indexterm role="option">
32618 <primary>forbid_filter_lookup</primary>
32619 </indexterm>
32620 </para>
32621 <informaltable frame="all">
32622 <tgroup cols="4" colsep="0" rowsep="0">
32623 <colspec colwidth="8*" align="left"/>
32624 <colspec colwidth="5*" align="center"/>
32625 <colspec colwidth="5*" align="center"/>
32626 <colspec colwidth="6*" align="right"/>
32627 <tbody>
32628 <row>
32629 <entry><option>forbid_filter_lookup</option></entry>
32630 <entry>Use: <emphasis>redirect</emphasis></entry>
32631 <entry>Type: <emphasis>boolean</emphasis></entry>
32632 <entry>Default: <emphasis>false</emphasis></entry>
32633 </row>
32634 </tbody>
32635 </tgroup>
32636 </informaltable>
32637 <para>
32638 If this option is true, string expansions in Exim filter files are not allowed
32639 to make use of <option>lookup</option> items.
32640 </para>
32641 <para>
32642 <indexterm role="option">
32643 <primary>forbid_filter_perl</primary>
32644 </indexterm>
32645 </para>
32646 <informaltable frame="all">
32647 <tgroup cols="4" colsep="0" rowsep="0">
32648 <colspec colwidth="8*" align="left"/>
32649 <colspec colwidth="5*" align="center"/>
32650 <colspec colwidth="5*" align="center"/>
32651 <colspec colwidth="6*" align="right"/>
32652 <tbody>
32653 <row>
32654 <entry><option>forbid_filter_perl</option></entry>
32655 <entry>Use: <emphasis>redirect</emphasis></entry>
32656 <entry>Type: <emphasis>boolean</emphasis></entry>
32657 <entry>Default: <emphasis>false</emphasis></entry>
32658 </row>
32659 </tbody>
32660 </tgroup>
32661 </informaltable>
32662 <para>
32663 This option has an effect only if Exim is built with embedded Perl support. If
32664 it is true, string expansions in Exim filter files are not allowed to make use
32665 of the embedded Perl support.
32666 </para>
32667 <para>
32668 <indexterm role="option">
32669 <primary>forbid_filter_readfile</primary>
32670 </indexterm>
32671 </para>
32672 <informaltable frame="all">
32673 <tgroup cols="4" colsep="0" rowsep="0">
32674 <colspec colwidth="8*" align="left"/>
32675 <colspec colwidth="5*" align="center"/>
32676 <colspec colwidth="5*" align="center"/>
32677 <colspec colwidth="6*" align="right"/>
32678 <tbody>
32679 <row>
32680 <entry><option>forbid_filter_readfile</option></entry>
32681 <entry>Use: <emphasis>redirect</emphasis></entry>
32682 <entry>Type: <emphasis>boolean</emphasis></entry>
32683 <entry>Default: <emphasis>false</emphasis></entry>
32684 </row>
32685 </tbody>
32686 </tgroup>
32687 </informaltable>
32688 <para>
32689 If this option is true, string expansions in Exim filter files are not allowed
32690 to make use of <option>readfile</option> items.
32691 </para>
32692 <para>
32693 <indexterm role="option">
32694 <primary>forbid_filter_readsocket</primary>
32695 </indexterm>
32696 </para>
32697 <informaltable frame="all">
32698 <tgroup cols="4" colsep="0" rowsep="0">
32699 <colspec colwidth="8*" align="left"/>
32700 <colspec colwidth="5*" align="center"/>
32701 <colspec colwidth="5*" align="center"/>
32702 <colspec colwidth="6*" align="right"/>
32703 <tbody>
32704 <row>
32705 <entry><option>forbid_filter_readsocket</option></entry>
32706 <entry>Use: <emphasis>redirect</emphasis></entry>
32707 <entry>Type: <emphasis>boolean</emphasis></entry>
32708 <entry>Default: <emphasis>false</emphasis></entry>
32709 </row>
32710 </tbody>
32711 </tgroup>
32712 </informaltable>
32713 <para>
32714 If this option is true, string expansions in Exim filter files are not allowed
32715 to make use of <option>readsocket</option> items.
32716 </para>
32717 <para>
32718 <indexterm role="option">
32719 <primary>forbid_filter_reply</primary>
32720 </indexterm>
32721 </para>
32722 <informaltable frame="all">
32723 <tgroup cols="4" colsep="0" rowsep="0">
32724 <colspec colwidth="8*" align="left"/>
32725 <colspec colwidth="5*" align="center"/>
32726 <colspec colwidth="5*" align="center"/>
32727 <colspec colwidth="6*" align="right"/>
32728 <tbody>
32729 <row>
32730 <entry><option>forbid_filter_reply</option></entry>
32731 <entry>Use: <emphasis>redirect</emphasis></entry>
32732 <entry>Type: <emphasis>boolean</emphasis></entry>
32733 <entry>Default: <emphasis>false</emphasis></entry>
32734 </row>
32735 </tbody>
32736 </tgroup>
32737 </informaltable>
32738 <para>
32739 If this option is true, this router may not generate an automatic reply
32740 message. Automatic replies can be generated only from Exim or Sieve filter
32741 files, not from traditional forward files. This option is forced to be true if
32742 <option>one_time</option> is set.
32743 </para>
32744 <para>
32745 <indexterm role="option">
32746 <primary>forbid_filter_run</primary>
32747 </indexterm>
32748 </para>
32749 <informaltable frame="all">
32750 <tgroup cols="4" colsep="0" rowsep="0">
32751 <colspec colwidth="8*" align="left"/>
32752 <colspec colwidth="5*" align="center"/>
32753 <colspec colwidth="5*" align="center"/>
32754 <colspec colwidth="6*" align="right"/>
32755 <tbody>
32756 <row>
32757 <entry><option>forbid_filter_run</option></entry>
32758 <entry>Use: <emphasis>redirect</emphasis></entry>
32759 <entry>Type: <emphasis>boolean</emphasis></entry>
32760 <entry>Default: <emphasis>false</emphasis></entry>
32761 </row>
32762 </tbody>
32763 </tgroup>
32764 </informaltable>
32765 <para>
32766 If this option is true, string expansions in Exim filter files are not allowed
32767 to make use of <option>run</option> items.
32768 </para>
32769 <para>
32770 <indexterm role="option">
32771 <primary>forbid_include</primary>
32772 </indexterm>
32773 </para>
32774 <informaltable frame="all">
32775 <tgroup cols="4" colsep="0" rowsep="0">
32776 <colspec colwidth="8*" align="left"/>
32777 <colspec colwidth="5*" align="center"/>
32778 <colspec colwidth="5*" align="center"/>
32779 <colspec colwidth="6*" align="right"/>
32780 <tbody>
32781 <row>
32782 <entry><option>forbid_include</option></entry>
32783 <entry>Use: <emphasis>redirect</emphasis></entry>
32784 <entry>Type: <emphasis>boolean</emphasis></entry>
32785 <entry>Default: <emphasis>false</emphasis></entry>
32786 </row>
32787 </tbody>
32788 </tgroup>
32789 </informaltable>
32790 <para>
32791 If this option is true, items of the form
32792 </para>
32793 <literallayout class="monospaced">
32794 :include:&lt;path name&gt;
32795 </literallayout>
32796 <para>
32797 are not permitted in non-filter redirection lists.
32798 </para>
32799 <para>
32800 <indexterm role="option">
32801 <primary>forbid_pipe</primary>
32802 </indexterm>
32803 </para>
32804 <informaltable frame="all">
32805 <tgroup cols="4" colsep="0" rowsep="0">
32806 <colspec colwidth="8*" align="left"/>
32807 <colspec colwidth="5*" align="center"/>
32808 <colspec colwidth="5*" align="center"/>
32809 <colspec colwidth="6*" align="right"/>
32810 <tbody>
32811 <row>
32812 <entry><option>forbid_pipe</option></entry>
32813 <entry>Use: <emphasis>redirect</emphasis></entry>
32814 <entry>Type: <emphasis>boolean</emphasis></entry>
32815 <entry>Default: <emphasis>false</emphasis></entry>
32816 </row>
32817 </tbody>
32818 </tgroup>
32819 </informaltable>
32820 <para>
32821 <indexterm role="concept">
32822 <primary>delivery</primary>
32823 <secondary>to pipe; forbidding</secondary>
32824 </indexterm>
32825 If this option is true, this router may not generate a new address which
32826 specifies delivery to a pipe, either from an Exim filter or from a conventional
32827 forward file. This option is forced to be true if <option>one_time</option> is set.
32828 </para>
32829 <para>
32830 <indexterm role="option">
32831 <primary>forbid_sieve_filter</primary>
32832 </indexterm>
32833 </para>
32834 <informaltable frame="all">
32835 <tgroup cols="4" colsep="0" rowsep="0">
32836 <colspec colwidth="8*" align="left"/>
32837 <colspec colwidth="5*" align="center"/>
32838 <colspec colwidth="5*" align="center"/>
32839 <colspec colwidth="6*" align="right"/>
32840 <tbody>
32841 <row>
32842 <entry><option>forbid_sieve_filter</option></entry>
32843 <entry>Use: <emphasis>redirect</emphasis></entry>
32844 <entry>Type: <emphasis>boolean</emphasis></entry>
32845 <entry>Default: <emphasis>false</emphasis></entry>
32846 </row>
32847 </tbody>
32848 </tgroup>
32849 </informaltable>
32850 <para>
32851 If this option is set true, only Exim filters are permitted when
32852 <option>allow_filter</option> is true.
32853 </para>
32854 <para>
32855 <indexterm role="option">
32856 <primary>hide_child_in_errmsg</primary>
32857 </indexterm>
32858 </para>
32859 <informaltable frame="all">
32860 <tgroup cols="4" colsep="0" rowsep="0">
32861 <colspec colwidth="8*" align="left"/>
32862 <colspec colwidth="5*" align="center"/>
32863 <colspec colwidth="5*" align="center"/>
32864 <colspec colwidth="6*" align="right"/>
32865 <tbody>
32866 <row>
32867 <entry><option>hide_child_in_errmsg</option></entry>
32868 <entry>Use: <emphasis>redirect</emphasis></entry>
32869 <entry>Type: <emphasis>boolean</emphasis></entry>
32870 <entry>Default: <emphasis>false</emphasis></entry>
32871 </row>
32872 </tbody>
32873 </tgroup>
32874 </informaltable>
32875 <para>
32876 <indexterm role="concept">
32877 <primary>bounce message</primary>
32878 <secondary>redirection details; suppressing</secondary>
32879 </indexterm>
32880 If this option is true, it prevents Exim from quoting a child address if it
32881 generates a bounce or delay message for it. Instead it says <quote>an address
32882 generated from &lt;<emphasis>the top level address</emphasis>&gt;</quote>. Of course, this applies only to
32883 bounces generated locally. If a message is forwarded to another host, <emphasis>its</emphasis>
32884 bounce may well quote the generated address.
32885 </para>
32886 <para>
32887 <indexterm role="option">
32888 <primary>ignore_eacces</primary>
32889 </indexterm>
32890 </para>
32891 <informaltable frame="all">
32892 <tgroup cols="4" colsep="0" rowsep="0">
32893 <colspec colwidth="8*" align="left"/>
32894 <colspec colwidth="5*" align="center"/>
32895 <colspec colwidth="5*" align="center"/>
32896 <colspec colwidth="6*" align="right"/>
32897 <tbody>
32898 <row>
32899 <entry><option>ignore_eacces</option></entry>
32900 <entry>Use: <emphasis>redirect</emphasis></entry>
32901 <entry>Type: <emphasis>boolean</emphasis></entry>
32902 <entry>Default: <emphasis>false</emphasis></entry>
32903 </row>
32904 </tbody>
32905 </tgroup>
32906 </informaltable>
32907 <para>
32908 <indexterm role="concept">
32909 <primary>EACCES</primary>
32910 </indexterm>
32911 If this option is set and an attempt to open a redirection file yields the
32912 EACCES error (permission denied), the <command>redirect</command> router behaves as if the
32913 file did not exist.
32914 </para>
32915 <para>
32916 <indexterm role="option">
32917 <primary>ignore_enotdir</primary>
32918 </indexterm>
32919 </para>
32920 <informaltable frame="all">
32921 <tgroup cols="4" colsep="0" rowsep="0">
32922 <colspec colwidth="8*" align="left"/>
32923 <colspec colwidth="5*" align="center"/>
32924 <colspec colwidth="5*" align="center"/>
32925 <colspec colwidth="6*" align="right"/>
32926 <tbody>
32927 <row>
32928 <entry><option>ignore_enotdir</option></entry>
32929 <entry>Use: <emphasis>redirect</emphasis></entry>
32930 <entry>Type: <emphasis>boolean</emphasis></entry>
32931 <entry>Default: <emphasis>false</emphasis></entry>
32932 </row>
32933 </tbody>
32934 </tgroup>
32935 </informaltable>
32936 <para>
32937 <indexterm role="concept">
32938 <primary>ENOTDIR</primary>
32939 </indexterm>
32940 If this option is set and an attempt to open a redirection file yields the
32941 ENOTDIR error (something on the path is not a directory), the <command>redirect</command>
32942 router behaves as if the file did not exist.
32943 </para>
32944 <para>
32945 Setting <option>ignore_enotdir</option> has another effect as well: When a <command>redirect</command>
32946 router that has the <option>file</option> option set discovers that the file does not exist
32947 (the ENOENT error), it tries to <function>stat()</function> the parent directory, as a check
32948 against unmounted NFS directories. If the parent can not be statted, delivery
32949 is deferred. However, it seems wrong to do this check when <option>ignore_enotdir</option>
32950 is set, because that option tells Exim to ignore <quote>something on the path is not
32951 a directory</quote> (the ENOTDIR error). This is a confusing area, because it seems
32952 that some operating systems give ENOENT where others give ENOTDIR.
32953 </para>
32954 <para>
32955 <indexterm role="option">
32956 <primary>include_directory</primary>
32957 </indexterm>
32958 </para>
32959 <informaltable frame="all">
32960 <tgroup cols="4" colsep="0" rowsep="0">
32961 <colspec colwidth="8*" align="left"/>
32962 <colspec colwidth="5*" align="center"/>
32963 <colspec colwidth="5*" align="center"/>
32964 <colspec colwidth="6*" align="right"/>
32965 <tbody>
32966 <row>
32967 <entry><option>include_directory</option></entry>
32968 <entry>Use: <emphasis>redirect</emphasis></entry>
32969 <entry>Type: <emphasis>string</emphasis></entry>
32970 <entry>Default: <emphasis>unset</emphasis></entry>
32971 </row>
32972 </tbody>
32973 </tgroup>
32974 </informaltable>
32975 <para>
32976 If this option is set, the path names of any <emphasis>:include:</emphasis> items in a
32977 redirection list must start with this directory.
32978 </para>
32979 <para>
32980 <indexterm role="option">
32981 <primary>modemask</primary>
32982 </indexterm>
32983 </para>
32984 <informaltable frame="all">
32985 <tgroup cols="4" colsep="0" rowsep="0">
32986 <colspec colwidth="8*" align="left"/>
32987 <colspec colwidth="5*" align="center"/>
32988 <colspec colwidth="5*" align="center"/>
32989 <colspec colwidth="6*" align="right"/>
32990 <tbody>
32991 <row>
32992 <entry><option>modemask</option></entry>
32993 <entry>Use: <emphasis>redirect</emphasis></entry>
32994 <entry>Type: <emphasis>octal integer</emphasis></entry>
32995 <entry>Default: <emphasis>022</emphasis></entry>
32996 </row>
32997 </tbody>
32998 </tgroup>
32999 </informaltable>
33000 <para>
33001 This specifies mode bits which must not be set for a file specified by the
33002 <option>file</option> option. If any of the forbidden bits are set, delivery is deferred.
33003 </para>
33004 <para>
33005 <indexterm role="option">
33006 <primary>one_time</primary>
33007 </indexterm>
33008 </para>
33009 <informaltable frame="all">
33010 <tgroup cols="4" colsep="0" rowsep="0">
33011 <colspec colwidth="8*" align="left"/>
33012 <colspec colwidth="5*" align="center"/>
33013 <colspec colwidth="5*" align="center"/>
33014 <colspec colwidth="6*" align="right"/>
33015 <tbody>
33016 <row>
33017 <entry><option>one_time</option></entry>
33018 <entry>Use: <emphasis>redirect</emphasis></entry>
33019 <entry>Type: <emphasis>boolean</emphasis></entry>
33020 <entry>Default: <emphasis>false</emphasis></entry>
33021 </row>
33022 </tbody>
33023 </tgroup>
33024 </informaltable>
33025 <para>
33026 <indexterm role="concept">
33027 <primary>one-time aliasing/forwarding expansion</primary>
33028 </indexterm>
33029 <indexterm role="concept">
33030 <primary>alias file</primary>
33031 <secondary>one-time expansion</secondary>
33032 </indexterm>
33033 <indexterm role="concept">
33034 <primary>forward file</primary>
33035 <secondary>one-time expansion</secondary>
33036 </indexterm>
33037 <indexterm role="concept">
33038 <primary>mailing lists</primary>
33039 <secondary>one-time expansion</secondary>
33040 </indexterm>
33041 <indexterm role="concept">
33042 <primary>address redirection</primary>
33043 <secondary>one-time expansion</secondary>
33044 </indexterm>
33045 Sometimes the fact that Exim re-evaluates aliases and reprocesses redirection
33046 files each time it tries to deliver a message causes a problem when one or more
33047 of the generated addresses fails be delivered at the first attempt. The problem
33048 is not one of duplicate delivery &ndash; Exim is clever enough to handle that &ndash;
33049 but of what happens when the redirection list changes during the time that the
33050 message is on Exim&#x2019;s queue. This is particularly true in the case of mailing
33051 lists, where new subscribers might receive copies of messages that were posted
33052 before they subscribed.
33053 </para>
33054 <para>
33055 If <option>one_time</option> is set and any addresses generated by the router fail to
33056 deliver at the first attempt, the failing addresses are added to the message as
33057 <quote>top level</quote> addresses, and the parent address that generated them is marked
33058 <quote>delivered</quote>. Thus, redirection does not happen again at the next delivery
33059 attempt.
33060 </para>
33061 <para>
33062 <emphasis role="bold">Warning 1</emphasis>: Any header line addition or removal that is specified by this
33063 router would be lost if delivery did not succeed at the first attempt. For this
33064 reason, the <option>headers_add</option> and <option>headers_remove</option> generic options are not
33065 permitted when <option>one_time</option> is set.
33066 </para>
33067 <para>
33068 <emphasis role="bold">Warning 2</emphasis>: To ensure that the router generates only addresses (as opposed
33069 to pipe or file deliveries or auto-replies) <option>forbid_file</option>, <option>forbid_pipe</option>,
33070 and <option>forbid_filter_reply</option> are forced to be true when <option>one_time</option> is set.
33071 </para>
33072 <para>
33073 <emphasis role="bold">Warning 3</emphasis>: The <option>unseen</option> generic router option may not be set with
33074 <option>one_time</option>.
33075 </para>
33076 <para>
33077 The original top-level address is remembered with each of the generated
33078 addresses, and is output in any log messages. However, any intermediate parent
33079 addresses are not recorded. This makes a difference to the log only if
33080 <option>all_parents</option> log selector is set. It is expected that <option>one_time</option> will
33081 typically be used for mailing lists, where there is normally just one level of
33082 expansion.
33083 </para>
33084 <para>
33085 <indexterm role="option">
33086 <primary>owners</primary>
33087 </indexterm>
33088 </para>
33089 <informaltable frame="all">
33090 <tgroup cols="4" colsep="0" rowsep="0">
33091 <colspec colwidth="8*" align="left"/>
33092 <colspec colwidth="5*" align="center"/>
33093 <colspec colwidth="5*" align="center"/>
33094 <colspec colwidth="6*" align="right"/>
33095 <tbody>
33096 <row>
33097 <entry><option>owners</option></entry>
33098 <entry>Use: <emphasis>redirect</emphasis></entry>
33099 <entry>Type: <emphasis>string list</emphasis></entry>
33100 <entry>Default: <emphasis>unset</emphasis></entry>
33101 </row>
33102 </tbody>
33103 </tgroup>
33104 </informaltable>
33105 <para>
33106 <indexterm role="concept">
33107 <primary>ownership</primary>
33108 <secondary>alias file</secondary>
33109 </indexterm>
33110 <indexterm role="concept">
33111 <primary>ownership</primary>
33112 <secondary>forward file</secondary>
33113 </indexterm>
33114 <indexterm role="concept">
33115 <primary>alias file</primary>
33116 <secondary>ownership</secondary>
33117 </indexterm>
33118 <indexterm role="concept">
33119 <primary>forward file</primary>
33120 <secondary>ownership</secondary>
33121 </indexterm>
33122 This specifies a list of permitted owners for the file specified by <option>file</option>.
33123 This list is in addition to the local user when <option>check_local_user</option> is set.
33124 See <option>check_owner</option> above.
33125 </para>
33126 <para>
33127 <indexterm role="option">
33128 <primary>owngroups</primary>
33129 </indexterm>
33130 </para>
33131 <informaltable frame="all">
33132 <tgroup cols="4" colsep="0" rowsep="0">
33133 <colspec colwidth="8*" align="left"/>
33134 <colspec colwidth="5*" align="center"/>
33135 <colspec colwidth="5*" align="center"/>
33136 <colspec colwidth="6*" align="right"/>
33137 <tbody>
33138 <row>
33139 <entry><option>owngroups</option></entry>
33140 <entry>Use: <emphasis>redirect</emphasis></entry>
33141 <entry>Type: <emphasis>string list</emphasis></entry>
33142 <entry>Default: <emphasis>unset</emphasis></entry>
33143 </row>
33144 </tbody>
33145 </tgroup>
33146 </informaltable>
33147 <para>
33148 This specifies a list of permitted groups for the file specified by <option>file</option>.
33149 The list is in addition to the local user&#x2019;s primary group when
33150 <option>check_local_user</option> is set. See <option>check_group</option> above.
33151 </para>
33152 <para>
33153 <indexterm role="option">
33154 <primary>pipe_transport</primary>
33155 </indexterm>
33156 </para>
33157 <informaltable frame="all">
33158 <tgroup cols="4" colsep="0" rowsep="0">
33159 <colspec colwidth="8*" align="left"/>
33160 <colspec colwidth="5*" align="center"/>
33161 <colspec colwidth="5*" align="center"/>
33162 <colspec colwidth="6*" align="right"/>
33163 <tbody>
33164 <row>
33165 <entry><option>pipe_transport</option></entry>
33166 <entry>Use: <emphasis>redirect</emphasis></entry>
33167 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33168 <entry>Default: <emphasis>unset</emphasis></entry>
33169 </row>
33170 </tbody>
33171 </tgroup>
33172 </informaltable>
33173 <para>
33174 <indexterm role="concept">
33175 <primary><varname>$address_pipe</varname></primary>
33176 </indexterm>
33177 A <command>redirect</command> router sets up a direct delivery to a pipe when a string
33178 starting with a vertical bar character is specified as a new <quote>address</quote>. The
33179 transport used is specified by this option, which, after expansion, must be the
33180 name of a configured transport. This should normally be a <command>pipe</command> transport.
33181 When the transport is run, the pipe command is in <varname>$address_pipe</varname>.
33182 </para>
33183 <para>
33184 <indexterm role="option">
33185 <primary>qualify_domain</primary>
33186 </indexterm>
33187 </para>
33188 <informaltable frame="all">
33189 <tgroup cols="4" colsep="0" rowsep="0">
33190 <colspec colwidth="8*" align="left"/>
33191 <colspec colwidth="5*" align="center"/>
33192 <colspec colwidth="5*" align="center"/>
33193 <colspec colwidth="6*" align="right"/>
33194 <tbody>
33195 <row>
33196 <entry><option>qualify_domain</option></entry>
33197 <entry>Use: <emphasis>redirect</emphasis></entry>
33198 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33199 <entry>Default: <emphasis>unset</emphasis></entry>
33200 </row>
33201 </tbody>
33202 </tgroup>
33203 </informaltable>
33204 <para>
33205 <indexterm role="concept">
33206 <primary><varname>$qualify_recipient</varname></primary>
33207 </indexterm>
33208 </para>
33209 <para revisionflag="changed">
33210 If this option is set, and an unqualified address (one without a domain) is
33211 generated, and that address would normally be qualified by the global setting
33212 in <option>qualify_recipient</option>, it is instead qualified with the domain specified by
33213 expanding this string. If the expansion fails, the router declines. If you want
33214 to revert to the default, you can have the expansion generate
33215 <varname>$qualify_recipient</varname>.
33216 </para>
33217 <para revisionflag="changed">
33218 This option applies to all unqualified addresses generated by Exim filters,
33219 but for traditional <filename>.forward</filename> files, it applies only to addresses that are
33220 not preceded by a backslash. Sieve filters cannot generate unqualified
33221 addresses.
33222 </para>
33223 <para>
33224 <indexterm role="option">
33225 <primary>qualify_preserve_domain</primary>
33226 </indexterm>
33227 </para>
33228 <informaltable frame="all">
33229 <tgroup cols="4" colsep="0" rowsep="0">
33230 <colspec colwidth="8*" align="left"/>
33231 <colspec colwidth="5*" align="center"/>
33232 <colspec colwidth="5*" align="center"/>
33233 <colspec colwidth="6*" align="right"/>
33234 <tbody>
33235 <row>
33236 <entry><option>qualify_preserve_domain</option></entry>
33237 <entry>Use: <emphasis>redirect</emphasis></entry>
33238 <entry>Type: <emphasis>boolean</emphasis></entry>
33239 <entry>Default: <emphasis>false</emphasis></entry>
33240 </row>
33241 </tbody>
33242 </tgroup>
33243 </informaltable>
33244 <para>
33245 <indexterm role="concept">
33246 <primary>domain</primary>
33247 <secondary>in redirection; preserving</secondary>
33248 </indexterm>
33249 <indexterm role="concept">
33250 <primary>preserving domain in redirection</primary>
33251 </indexterm>
33252 <indexterm role="concept">
33253 <primary>address redirection</primary>
33254 <secondary>domain; preserving</secondary>
33255 </indexterm>
33256 </para>
33257 <para revisionflag="changed">
33258 If this option is set, the router&#x2019;s local <option>qualify_domain</option> option must not be
33259 set (a configuration error occurs if it is). If an unqualified address (one
33260 without a domain) is generated, it is qualified with the domain of the parent
33261 address (the immediately preceding ancestor) instead of the global
33262 <option>qualify_recipient</option> value. In the case of a traditional <filename>.forward</filename> file,
33263 this applies whether or not the address is preceded by a backslash.
33264 </para>
33265 <para>
33266 <indexterm role="option">
33267 <primary>repeat_use</primary>
33268 </indexterm>
33269 </para>
33270 <informaltable frame="all">
33271 <tgroup cols="4" colsep="0" rowsep="0">
33272 <colspec colwidth="8*" align="left"/>
33273 <colspec colwidth="5*" align="center"/>
33274 <colspec colwidth="5*" align="center"/>
33275 <colspec colwidth="6*" align="right"/>
33276 <tbody>
33277 <row>
33278 <entry><option>repeat_use</option></entry>
33279 <entry>Use: <emphasis>redirect</emphasis></entry>
33280 <entry>Type: <emphasis>boolean</emphasis></entry>
33281 <entry>Default: <emphasis>true</emphasis></entry>
33282 </row>
33283 </tbody>
33284 </tgroup>
33285 </informaltable>
33286 <para>
33287 If this option is set false, the router is skipped for a child address that has
33288 any ancestor that was routed by this router. This test happens before any of
33289 the other preconditions are tested. Exim&#x2019;s default anti-looping rules skip
33290 only when the ancestor is the same as the current address. See also
33291 <option>check_ancestor</option> above and the generic <option>redirect_router</option> option.
33292 </para>
33293 <para>
33294 <indexterm role="option">
33295 <primary>reply_transport</primary>
33296 </indexterm>
33297 </para>
33298 <informaltable frame="all">
33299 <tgroup cols="4" colsep="0" rowsep="0">
33300 <colspec colwidth="8*" align="left"/>
33301 <colspec colwidth="5*" align="center"/>
33302 <colspec colwidth="5*" align="center"/>
33303 <colspec colwidth="6*" align="right"/>
33304 <tbody>
33305 <row>
33306 <entry><option>reply_transport</option></entry>
33307 <entry>Use: <emphasis>redirect</emphasis></entry>
33308 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33309 <entry>Default: <emphasis>unset</emphasis></entry>
33310 </row>
33311 </tbody>
33312 </tgroup>
33313 </informaltable>
33314 <para>
33315 A <command>redirect</command> router sets up an automatic reply when a <option>mail</option> or
33316 <option>vacation</option> command is used in a filter file. The transport used is specified
33317 by this option, which, after expansion, must be the name of a configured
33318 transport. This should normally be an <command>autoreply</command> transport. Other transports
33319 are unlikely to do anything sensible or useful.
33320 </para>
33321 <para>
33322 <indexterm role="option">
33323 <primary>rewrite</primary>
33324 </indexterm>
33325 </para>
33326 <informaltable frame="all">
33327 <tgroup cols="4" colsep="0" rowsep="0">
33328 <colspec colwidth="8*" align="left"/>
33329 <colspec colwidth="5*" align="center"/>
33330 <colspec colwidth="5*" align="center"/>
33331 <colspec colwidth="6*" align="right"/>
33332 <tbody>
33333 <row>
33334 <entry><option>rewrite</option></entry>
33335 <entry>Use: <emphasis>redirect</emphasis></entry>
33336 <entry>Type: <emphasis>boolean</emphasis></entry>
33337 <entry>Default: <emphasis>true</emphasis></entry>
33338 </row>
33339 </tbody>
33340 </tgroup>
33341 </informaltable>
33342 <para>
33343 <indexterm role="concept">
33344 <primary>address redirection</primary>
33345 <secondary>disabling rewriting</secondary>
33346 </indexterm>
33347 If this option is set false, addresses generated by the router are not
33348 subject to address rewriting. Otherwise, they are treated like new addresses
33349 and are rewritten according to the global rewriting rules.
33350 </para>
33351 <para>
33352 <indexterm role="option">
33353 <primary>sieve_subaddress</primary>
33354 </indexterm>
33355 </para>
33356 <informaltable frame="all">
33357 <tgroup cols="4" colsep="0" rowsep="0">
33358 <colspec colwidth="8*" align="left"/>
33359 <colspec colwidth="5*" align="center"/>
33360 <colspec colwidth="5*" align="center"/>
33361 <colspec colwidth="6*" align="right"/>
33362 <tbody>
33363 <row>
33364 <entry><option>sieve_subaddress</option></entry>
33365 <entry>Use: <emphasis>redirect</emphasis></entry>
33366 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33367 <entry>Default: <emphasis>unset</emphasis></entry>
33368 </row>
33369 </tbody>
33370 </tgroup>
33371 </informaltable>
33372 <para>
33373 The value of this option is passed to a Sieve filter to specify the
33374 :subaddress part of an address.
33375 </para>
33376 <para>
33377 <indexterm role="option">
33378 <primary>sieve_useraddress</primary>
33379 </indexterm>
33380 </para>
33381 <informaltable frame="all">
33382 <tgroup cols="4" colsep="0" rowsep="0">
33383 <colspec colwidth="8*" align="left"/>
33384 <colspec colwidth="5*" align="center"/>
33385 <colspec colwidth="5*" align="center"/>
33386 <colspec colwidth="6*" align="right"/>
33387 <tbody>
33388 <row>
33389 <entry><option>sieve_useraddress</option></entry>
33390 <entry>Use: <emphasis>redirect</emphasis></entry>
33391 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33392 <entry>Default: <emphasis>unset</emphasis></entry>
33393 </row>
33394 </tbody>
33395 </tgroup>
33396 </informaltable>
33397 <para>
33398 The value of this option is passed to a Sieve filter to specify the :user part
33399 of an address. However, if it is unset, the entire original local part
33400 (including any prefix or suffix) is used for :user.
33401 </para>
33402 <para>
33403 <indexterm role="option">
33404 <primary>sieve_vacation_directory</primary>
33405 </indexterm>
33406 </para>
33407 <informaltable frame="all">
33408 <tgroup cols="4" colsep="0" rowsep="0">
33409 <colspec colwidth="8*" align="left"/>
33410 <colspec colwidth="5*" align="center"/>
33411 <colspec colwidth="5*" align="center"/>
33412 <colspec colwidth="6*" align="right"/>
33413 <tbody>
33414 <row>
33415 <entry><option>sieve_vacation_directory</option></entry>
33416 <entry>Use: <emphasis>redirect</emphasis></entry>
33417 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33418 <entry>Default: <emphasis>unset</emphasis></entry>
33419 </row>
33420 </tbody>
33421 </tgroup>
33422 </informaltable>
33423 <para>
33424 <indexterm role="concept">
33425 <primary>Sieve filter</primary>
33426 <secondary>vacation directory</secondary>
33427 </indexterm>
33428 To enable the <quote>vacation</quote> extension for Sieve filters, you must set
33429 <option>sieve_vacation_directory</option> to the directory where vacation databases are held
33430 (do not put anything else in that directory), and ensure that the
33431 <option>reply_transport</option> option refers to an <command>autoreply</command> transport. Each user
33432 needs their own directory; Exim will create it if necessary.
33433 </para>
33434 <para>
33435 <indexterm role="option">
33436 <primary>skip_syntax_errors</primary>
33437 </indexterm>
33438 </para>
33439 <informaltable frame="all">
33440 <tgroup cols="4" colsep="0" rowsep="0">
33441 <colspec colwidth="8*" align="left"/>
33442 <colspec colwidth="5*" align="center"/>
33443 <colspec colwidth="5*" align="center"/>
33444 <colspec colwidth="6*" align="right"/>
33445 <tbody>
33446 <row>
33447 <entry><option>skip_syntax_errors</option></entry>
33448 <entry>Use: <emphasis>redirect</emphasis></entry>
33449 <entry>Type: <emphasis>boolean</emphasis></entry>
33450 <entry>Default: <emphasis>false</emphasis></entry>
33451 </row>
33452 </tbody>
33453 </tgroup>
33454 </informaltable>
33455 <para>
33456 <indexterm role="concept">
33457 <primary>forward file</primary>
33458 <secondary>broken</secondary>
33459 </indexterm>
33460 <indexterm role="concept">
33461 <primary>address redirection</primary>
33462 <secondary>broken files</secondary>
33463 </indexterm>
33464 <indexterm role="concept">
33465 <primary>alias file</primary>
33466 <secondary>broken</secondary>
33467 </indexterm>
33468 <indexterm role="concept">
33469 <primary>broken alias or forward files</primary>
33470 </indexterm>
33471 <indexterm role="concept">
33472 <primary>ignoring faulty addresses</primary>
33473 </indexterm>
33474 <indexterm role="concept">
33475 <primary>skipping faulty addresses</primary>
33476 </indexterm>
33477 <indexterm role="concept">
33478 <primary>error</primary>
33479 <secondary>skipping bad syntax</secondary>
33480 </indexterm>
33481 If <option>skip_syntax_errors</option> is set, syntactically malformed addresses in
33482 non-filter redirection data are skipped, and each failing address is logged. If
33483 <option>syntax_errors_to</option> is set, a message is sent to the address it defines,
33484 giving details of the failures. If <option>syntax_errors_text</option> is set, its contents
33485 are expanded and placed at the head of the error message generated by
33486 <option>syntax_errors_to</option>. Usually it is appropriate to set <option>syntax_errors_to</option> to
33487 be the same address as the generic <option>errors_to</option> option. The
33488 <option>skip_syntax_errors</option> option is often used when handling mailing lists.
33489 </para>
33490 <para>
33491 If all the addresses in a redirection list are skipped because of syntax
33492 errors, the router declines to handle the original address, and it is passed to
33493 the following routers.
33494 </para>
33495 <para>
33496 If <option>skip_syntax_errors</option> is set when an Exim filter is interpreted, any syntax
33497 error in the filter causes filtering to be abandoned without any action being
33498 taken. The incident is logged, and the router declines to handle the address,
33499 so it is passed to the following routers.
33500 </para>
33501 <para>
33502 <indexterm role="concept">
33503 <primary>Sieve filter</primary>
33504 <secondary>syntax errors in</secondary>
33505 </indexterm>
33506 Syntax errors in a Sieve filter file cause the <quote>keep</quote> action to occur. This
33507 action is specified by RFC 3028. The values of <option>skip_syntax_errors</option>,
33508 <option>syntax_errors_to</option>, and <option>syntax_errors_text</option> are not used.
33509 </para>
33510 <para>
33511 <option>skip_syntax_errors</option> can be used to specify that errors in users&#x2019; forward
33512 lists or filter files should not prevent delivery. The <option>syntax_errors_to</option>
33513 option, used with an address that does not get redirected, can be used to
33514 notify users of these errors, by means of a router like this:
33515 </para>
33516 <literallayout class="monospaced">
33517 userforward:
33518   driver = redirect
33519   allow_filter
33520   check_local_user
33521   file = $home/.forward
33522   file_transport = address_file
33523   pipe_transport = address_pipe
33524   reply_transport = address_reply
33525   no_verify
33526   skip_syntax_errors
33527   syntax_errors_to = real-$local_part@$domain
33528   syntax_errors_text = \
33529    This is an automatically generated message. An error has\n\
33530    been found in your .forward file. Details of the error are\n\
33531    reported below. While this error persists, you will receive\n\
33532    a copy of this message for every message that is addressed\n\
33533    to you. If your .forward file is a filter file, or if it is\n\
33534    a non-filter file containing no valid forwarding addresses,\n\
33535    a copy of each incoming message will be put in your normal\n\
33536    mailbox. If a non-filter file contains at least one valid\n\
33537    forwarding address, forwarding to the valid addresses will\n\
33538    happen, and those will be the only deliveries that occur.
33539 </literallayout>
33540 <para>
33541 You also need a router to ensure that local addresses that are prefixed by
33542 <literal>real-</literal> are recognized, but not forwarded or filtered. For example, you could
33543 put this immediately before the <command>userforward</command> router:
33544 </para>
33545 <literallayout class="monospaced">
33546 real_localuser:
33547   driver = accept
33548   check_local_user
33549   local_part_prefix = real-
33550   transport = local_delivery
33551 </literallayout>
33552 <para>
33553 <indexterm role="option">
33554 <primary>syntax_errors_text</primary>
33555 </indexterm>
33556 </para>
33557 <informaltable frame="all">
33558 <tgroup cols="4" colsep="0" rowsep="0">
33559 <colspec colwidth="8*" align="left"/>
33560 <colspec colwidth="5*" align="center"/>
33561 <colspec colwidth="5*" align="center"/>
33562 <colspec colwidth="6*" align="right"/>
33563 <tbody>
33564 <row>
33565 <entry><option>syntax_errors_text</option></entry>
33566 <entry>Use: <emphasis>redirect</emphasis></entry>
33567 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33568 <entry>Default: <emphasis>unset</emphasis></entry>
33569 </row>
33570 </tbody>
33571 </tgroup>
33572 </informaltable>
33573 <para>
33574 See <option>skip_syntax_errors</option> above.
33575 </para>
33576 <para>
33577 <indexterm role="option">
33578 <primary>syntax_errors_to</primary>
33579 </indexterm>
33580 </para>
33581 <informaltable frame="all">
33582 <tgroup cols="4" colsep="0" rowsep="0">
33583 <colspec colwidth="8*" align="left"/>
33584 <colspec colwidth="5*" align="center"/>
33585 <colspec colwidth="5*" align="center"/>
33586 <colspec colwidth="6*" align="right"/>
33587 <tbody>
33588 <row>
33589 <entry><option>syntax_errors_to</option></entry>
33590 <entry>Use: <emphasis>redirect</emphasis></entry>
33591 <entry>Type: <emphasis>string</emphasis></entry>
33592 <entry>Default: <emphasis>unset</emphasis></entry>
33593 </row>
33594 </tbody>
33595 </tgroup>
33596 </informaltable>
33597 <para>
33598 See <option>skip_syntax_errors</option> above.
33599 <indexterm role="concept" startref="IIDredrou1" class="endofrange"/>
33600 <indexterm role="concept" startref="IIDredrou2" class="endofrange"/>
33601 </para>
33602 </section>
33603 </chapter>
33604
33605 <chapter id="CHAPenvironment">
33606 <title>Environment for running local transports</title>
33607 <titleabbrev>Environment for local transports</titleabbrev>
33608 <para>
33609 <indexterm role="concept" id="IIDenvlotra1" class="startofrange">
33610 <primary>local transports</primary>
33611 <secondary>environment for</secondary>
33612 </indexterm>
33613 <indexterm role="concept" id="IIDenvlotra2" class="startofrange">
33614 <primary>environment for local transports</primary>
33615 </indexterm>
33616 <indexterm role="concept" id="IIDenvlotra3" class="startofrange">
33617 <primary>transport</primary>
33618 <secondary>local; environment for</secondary>
33619 </indexterm>
33620 Local transports handle deliveries to files and pipes. (The <command>autoreply</command>
33621 transport can be thought of as similar to a pipe.) Exim always runs transports
33622 in subprocesses, under specified uids and gids. Typical deliveries to local
33623 mailboxes run under the uid and gid of the local user.
33624 </para>
33625 <para>
33626 Exim also sets a specific current directory while running the transport; for
33627 some transports a home directory setting is also relevant. The <command>pipe</command>
33628 transport is the only one that sets up environment variables; see section
33629 <xref linkend="SECTpipeenv"/> for details.
33630 </para>
33631 <para>
33632 The values used for the uid, gid, and the directories may come from several
33633 different places. In many cases, the router that handles the address associates
33634 settings with that address as a result of its <option>check_local_user</option>, <option>group</option>,
33635 or <option>user</option> options. However, values may also be given in the transport&#x2019;s own
33636 configuration, and these override anything that comes from the router.
33637 </para>
33638 <section>
33639 <title>Concurrent deliveries</title>
33640 <para>
33641 <indexterm role="concept">
33642 <primary>concurrent deliveries</primary>
33643 </indexterm>
33644 <indexterm role="concept">
33645 <primary>simultaneous deliveries</primary>
33646 </indexterm>
33647 If two different messages for the same local recpient arrive more or less
33648 simultaneously, the two delivery processes are likely to run concurrently. When
33649 the <command>appendfile</command> transport is used to write to a file, Exim applies locking
33650 rules to stop concurrent processes from writing to the same file at the same
33651 time.
33652 </para>
33653 <para>
33654 However, when you use a <command>pipe</command> transport, it is up to you to arrange any
33655 locking that is needed. Here is a silly example:
33656 </para>
33657 <literallayout class="monospaced">
33658 my_transport:
33659   driver = pipe
33660   command = /bin/sh -c 'cat &gt;&gt;/some/file'
33661 </literallayout>
33662 <para>
33663 This is supposed to write the message at the end of the file. However, if two
33664 messages arrive at the same time, the file will be scrambled. You can use the
33665 <option>exim_lock</option> utility program (see section <xref linkend="SECTmailboxmaint"/>) to lock a
33666 file using the same algorithm that Exim itself uses.
33667 </para>
33668 </section>
33669 <section id="SECTenvuidgid">
33670 <title>Uids and gids</title>
33671 <para>
33672 <indexterm role="concept">
33673 <primary>local transports</primary>
33674 <secondary>uid and gid</secondary>
33675 </indexterm>
33676 <indexterm role="concept">
33677 <primary>transport</primary>
33678 <secondary>local; uid and gid</secondary>
33679 </indexterm>
33680 All transports have the options <option>group</option> and <option>user</option>. If <option>group</option> is set, it
33681 overrides any group that the router set in the address, even if <option>user</option> is not
33682 set for the transport. This makes it possible, for example, to run local mail
33683 delivery under the uid of the recipient (set by the router), but in a special
33684 group (set by the transport). For example:
33685 </para>
33686 <literallayout class="monospaced">
33687 # Routers ...
33688 # User/group are set by check_local_user in this router
33689 local_users:
33690   driver = accept
33691   check_local_user
33692   transport = group_delivery
33693
33694 # Transports ...
33695 # This transport overrides the group
33696 group_delivery:
33697   driver = appendfile
33698   file = /var/spool/mail/$local_part
33699   group = mail
33700 </literallayout>
33701 <para>
33702 If <option>user</option> is set for a transport, its value overrides what is set in the
33703 address by the router. If <option>user</option> is non-numeric and <option>group</option> is not set, the
33704 gid associated with the user is used. If <option>user</option> is numeric, <option>group</option> must be
33705 set.
33706 </para>
33707 <para>
33708 <indexterm role="concept">
33709 <primary><option>initgroups</option> option</primary>
33710 </indexterm>
33711 When the uid is taken from the transport&#x2019;s configuration, the <function>initgroups()</function>
33712 function is called for the groups associated with that uid if the
33713 <option>initgroups</option> option is set for the transport. When the uid is not specified
33714 by the transport, but is associated with the address by a router, the option
33715 for calling <function>initgroups()</function> is taken from the router configuration.
33716 </para>
33717 <para>
33718 <indexterm role="concept">
33719 <primary><command>pipe</command> transport</primary>
33720 <secondary>uid for</secondary>
33721 </indexterm>
33722 The <command>pipe</command> transport contains the special option <option>pipe_as_creator</option>. If this
33723 is set and <option>user</option> is not set, the uid of the process that called Exim to
33724 receive the message is used, and if <option>group</option> is not set, the corresponding
33725 original gid is also used.
33726 </para>
33727 <para>
33728 This is the detailed preference order for obtaining a gid; the first of the
33729 following that is set is used:
33730 </para>
33731 <itemizedlist>
33732 <listitem>
33733 <para>
33734 A <option>group</option> setting of the transport;
33735 </para>
33736 </listitem>
33737 <listitem>
33738 <para>
33739 A <option>group</option> setting of the router;
33740 </para>
33741 </listitem>
33742 <listitem>
33743 <para>
33744 A gid associated with a user setting of the router, either as a result of
33745 <option>check_local_user</option> or an explicit non-numeric <option>user</option> setting;
33746 </para>
33747 </listitem>
33748 <listitem>
33749 <para>
33750 The group associated with a non-numeric <option>user</option> setting of the transport;
33751 </para>
33752 </listitem>
33753 <listitem>
33754 <para>
33755 In a <command>pipe</command> transport, the creator&#x2019;s gid if <option>deliver_as_creator</option> is set and
33756 the uid is the creator&#x2019;s uid;
33757 </para>
33758 </listitem>
33759 <listitem>
33760 <para>
33761 The Exim gid if the Exim uid is being used as a default.
33762 </para>
33763 </listitem>
33764 </itemizedlist>
33765 <para>
33766 If, for example, the user is specified numerically on the router and there are
33767 no group settings, no gid is available. In this situation, an error occurs.
33768 This is different for the uid, for which there always is an ultimate default.
33769 The first of the following that is set is used:
33770 </para>
33771 <itemizedlist>
33772 <listitem>
33773 <para>
33774 A <option>user</option> setting of the transport;
33775 </para>
33776 </listitem>
33777 <listitem>
33778 <para>
33779 In a <command>pipe</command> transport, the creator&#x2019;s uid if <option>deliver_as_creator</option> is set;
33780 </para>
33781 </listitem>
33782 <listitem>
33783 <para>
33784 A <option>user</option> setting of the router;
33785 </para>
33786 </listitem>
33787 <listitem>
33788 <para>
33789 A <option>check_local_user</option> setting of the router;
33790 </para>
33791 </listitem>
33792 <listitem>
33793 <para>
33794 The Exim uid.
33795 </para>
33796 </listitem>
33797 </itemizedlist>
33798 <para>
33799 Of course, an error will still occur if the uid that is chosen is on the
33800 <option>never_users</option> list.
33801 </para>
33802 </section>
33803 <section>
33804 <title>Current and home directories</title>
33805 <para>
33806 <indexterm role="concept">
33807 <primary>current directory for local transport</primary>
33808 </indexterm>
33809 <indexterm role="concept">
33810 <primary>home directory</primary>
33811 <secondary>for local transport</secondary>
33812 </indexterm>
33813 <indexterm role="concept">
33814 <primary>transport</primary>
33815 <secondary>local; home directory for</secondary>
33816 </indexterm>
33817 <indexterm role="concept">
33818 <primary>transport</primary>
33819 <secondary>local; current directory for</secondary>
33820 </indexterm>
33821 Routers may set current and home directories for local transports by means of
33822 the <option>transport_current_directory</option> and <option>transport_home_directory</option> options.
33823 However, if the transport&#x2019;s <option>current_directory</option> or <option>home_directory</option> options
33824 are set, they override the router&#x2019;s values. In detail, the home directory
33825 for a local transport is taken from the first of these values that is set:
33826 </para>
33827 <itemizedlist>
33828 <listitem>
33829 <para>
33830 The <option>home_directory</option> option on the transport;
33831 </para>
33832 </listitem>
33833 <listitem>
33834 <para>
33835 The <option>transport_home_directory</option> option on the router;
33836 </para>
33837 </listitem>
33838 <listitem>
33839 <para>
33840 The password data if <option>check_local_user</option> is set on the router;
33841 </para>
33842 </listitem>
33843 <listitem>
33844 <para>
33845 The <option>router_home_directory</option> option on the router.
33846 </para>
33847 </listitem>
33848 </itemizedlist>
33849 <para>
33850 The current directory is taken from the first of these values that is set:
33851 </para>
33852 <itemizedlist>
33853 <listitem>
33854 <para>
33855 The <option>current_directory</option> option on the transport;
33856 </para>
33857 </listitem>
33858 <listitem>
33859 <para>
33860 The <option>transport_current_directory</option> option on the router.
33861 </para>
33862 </listitem>
33863 </itemizedlist>
33864 <para>
33865 If neither the router nor the transport sets a current directory, Exim uses the
33866 value of the home directory, if it is set. Otherwise it sets the current
33867 directory to <filename>/</filename> before running a local transport.
33868 </para>
33869 </section>
33870 <section>
33871 <title>Expansion variables derived from the address</title>
33872 <para>
33873 <indexterm role="concept">
33874 <primary><varname>$domain</varname></primary>
33875 </indexterm>
33876 <indexterm role="concept">
33877 <primary><varname>$local_part</varname></primary>
33878 </indexterm>
33879 <indexterm role="concept">
33880 <primary><varname>$original_domain</varname></primary>
33881 </indexterm>
33882 Normally a local delivery is handling a single address, and in that case the
33883 variables such as <varname>$domain</varname> and <varname>$local_part</varname> are set during local
33884 deliveries. However, in some circumstances more than one address may be handled
33885 at once (for example, while writing batch SMTP for onward transmission by some
33886 other means). In this case, the variables associated with the local part are
33887 never set, <varname>$domain</varname> is set only if all the addresses have the same domain,
33888 and <varname>$original_domain</varname> is never set.
33889 <indexterm role="concept" startref="IIDenvlotra1" class="endofrange"/>
33890 <indexterm role="concept" startref="IIDenvlotra2" class="endofrange"/>
33891 <indexterm role="concept" startref="IIDenvlotra3" class="endofrange"/>
33892 </para>
33893 </section>
33894 </chapter>
33895
33896 <chapter id="CHAPtransportgeneric">
33897 <title>Generic options for transports</title>
33898 <para>
33899 <indexterm role="concept" id="IIDgenoptra1" class="startofrange">
33900 <primary>generic options</primary>
33901 <secondary>transport</secondary>
33902 </indexterm>
33903 <indexterm role="concept" id="IIDgenoptra2" class="startofrange">
33904 <primary>options</primary>
33905 <secondary>generic; for transports</secondary>
33906 </indexterm>
33907 <indexterm role="concept" id="IIDgenoptra3" class="startofrange">
33908 <primary>transport</primary>
33909 <secondary>generic options for</secondary>
33910 </indexterm>
33911 The following generic options apply to all transports:
33912 </para>
33913 <para>
33914 <indexterm role="option">
33915 <primary>body_only</primary>
33916 </indexterm>
33917 </para>
33918 <informaltable frame="all">
33919 <tgroup cols="4" colsep="0" rowsep="0">
33920 <colspec colwidth="8*" align="left"/>
33921 <colspec colwidth="5*" align="center"/>
33922 <colspec colwidth="5*" align="center"/>
33923 <colspec colwidth="6*" align="right"/>
33924 <tbody>
33925 <row>
33926 <entry><option>body_only</option></entry>
33927 <entry>Use: <emphasis>transports</emphasis></entry>
33928 <entry>Type: <emphasis>boolean</emphasis></entry>
33929 <entry>Default: <emphasis>false</emphasis></entry>
33930 </row>
33931 </tbody>
33932 </tgroup>
33933 </informaltable>
33934 <para>
33935 <indexterm role="concept">
33936 <primary>transport</primary>
33937 <secondary>body only</secondary>
33938 </indexterm>
33939 <indexterm role="concept">
33940 <primary>message</primary>
33941 <secondary>transporting body only</secondary>
33942 </indexterm>
33943 <indexterm role="concept">
33944 <primary>body of message</primary>
33945 <secondary>transporting</secondary>
33946 </indexterm>
33947 If this option is set, the message&#x2019;s headers are not transported. It is
33948 mutually exclusive with <option>headers_only</option>. If it is used with the <command>appendfile</command>
33949 or <command>pipe</command> transports, the settings of <option>message_prefix</option> and
33950 <option>message_suffix</option> should be checked, because this option does not
33951 automatically suppress them.
33952 </para>
33953 <para>
33954 <indexterm role="option">
33955 <primary>current_directory</primary>
33956 </indexterm>
33957 </para>
33958 <informaltable frame="all">
33959 <tgroup cols="4" colsep="0" rowsep="0">
33960 <colspec colwidth="8*" align="left"/>
33961 <colspec colwidth="5*" align="center"/>
33962 <colspec colwidth="5*" align="center"/>
33963 <colspec colwidth="6*" align="right"/>
33964 <tbody>
33965 <row>
33966 <entry><option>current_directory</option></entry>
33967 <entry>Use: <emphasis>transports</emphasis></entry>
33968 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33969 <entry>Default: <emphasis>unset</emphasis></entry>
33970 </row>
33971 </tbody>
33972 </tgroup>
33973 </informaltable>
33974 <para>
33975 <indexterm role="concept">
33976 <primary>transport</primary>
33977 <secondary>current directory for</secondary>
33978 </indexterm>
33979 This specifies the current directory that is to be set while running the
33980 transport, overriding any value that may have been set by the router.
33981 If the expansion fails for any reason, including forced failure, an error is
33982 logged, and delivery is deferred.
33983 </para>
33984 <para>
33985 <indexterm role="option">
33986 <primary>disable_logging</primary>
33987 </indexterm>
33988 </para>
33989 <informaltable frame="all">
33990 <tgroup cols="4" colsep="0" rowsep="0">
33991 <colspec colwidth="8*" align="left"/>
33992 <colspec colwidth="5*" align="center"/>
33993 <colspec colwidth="5*" align="center"/>
33994 <colspec colwidth="6*" align="right"/>
33995 <tbody>
33996 <row>
33997 <entry><option>disable_logging</option></entry>
33998 <entry>Use: <emphasis>transports</emphasis></entry>
33999 <entry>Type: <emphasis>boolean</emphasis></entry>
34000 <entry>Default: <emphasis>false</emphasis></entry>
34001 </row>
34002 </tbody>
34003 </tgroup>
34004 </informaltable>
34005 <para>
34006 If this option is set true, nothing is logged for any
34007 deliveries by the transport or for any
34008 transport errors. You should not set this option unless you really, really know
34009 what you are doing.
34010 </para>
34011 <para>
34012 <indexterm role="option">
34013 <primary>debug_print</primary>
34014 </indexterm>
34015 </para>
34016 <informaltable frame="all">
34017 <tgroup cols="4" colsep="0" rowsep="0">
34018 <colspec colwidth="8*" align="left"/>
34019 <colspec colwidth="5*" align="center"/>
34020 <colspec colwidth="5*" align="center"/>
34021 <colspec colwidth="6*" align="right"/>
34022 <tbody>
34023 <row>
34024 <entry><option>debug_print</option></entry>
34025 <entry>Use: <emphasis>transports</emphasis></entry>
34026 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34027 <entry>Default: <emphasis>unset</emphasis></entry>
34028 </row>
34029 </tbody>
34030 </tgroup>
34031 </informaltable>
34032 <para>
34033 <indexterm role="concept">
34034 <primary>testing</primary>
34035 <secondary>variables in drivers</secondary>
34036 </indexterm>
34037 If this option is set and debugging is enabled (see the <option>-d</option> command line
34038 option), the string is expanded and included in the debugging output when the
34039 transport is run.
34040 If expansion of the string fails, the error message is written to the debugging
34041 output, and Exim carries on processing.
34042 This facility is provided to help with checking out the values of variables and
34043 so on when debugging driver configurations. For example, if a <option>headers_add</option>
34044 option is not working properly, <option>debug_print</option> could be used to output the
34045 variables it references. A newline is added to the text if it does not end with
34046 one.
34047 </para>
34048 <para>
34049 <indexterm role="option">
34050 <primary>delivery_date_add</primary>
34051 </indexterm>
34052 </para>
34053 <informaltable frame="all">
34054 <tgroup cols="4" colsep="0" rowsep="0">
34055 <colspec colwidth="8*" align="left"/>
34056 <colspec colwidth="5*" align="center"/>
34057 <colspec colwidth="5*" align="center"/>
34058 <colspec colwidth="6*" align="right"/>
34059 <tbody>
34060 <row>
34061 <entry><option>delivery_date_add</option></entry>
34062 <entry>Use: <emphasis>transports</emphasis></entry>
34063 <entry>Type: <emphasis>boolean</emphasis></entry>
34064 <entry>Default: <emphasis>false</emphasis></entry>
34065 </row>
34066 </tbody>
34067 </tgroup>
34068 </informaltable>
34069 <para>
34070 <indexterm role="concept">
34071 <primary><emphasis>Delivery-date:</emphasis> header line</primary>
34072 </indexterm>
34073 If this option is true, a <emphasis>Delivery-date:</emphasis> header is added to the message.
34074 This gives the actual time the delivery was made. As this is not a standard
34075 header, Exim has a configuration option (<option>delivery_date_remove</option>) which
34076 requests its removal from incoming messages, so that delivered messages can
34077 safely be resent to other recipients.
34078 </para>
34079 <para>
34080 <indexterm role="option">
34081 <primary>driver</primary>
34082 </indexterm>
34083 </para>
34084 <informaltable frame="all">
34085 <tgroup cols="4" colsep="0" rowsep="0">
34086 <colspec colwidth="8*" align="left"/>
34087 <colspec colwidth="5*" align="center"/>
34088 <colspec colwidth="5*" align="center"/>
34089 <colspec colwidth="6*" align="right"/>
34090 <tbody>
34091 <row>
34092 <entry><option>driver</option></entry>
34093 <entry>Use: <emphasis>transports</emphasis></entry>
34094 <entry>Type: <emphasis>string</emphasis></entry>
34095 <entry>Default: <emphasis>unset</emphasis></entry>
34096 </row>
34097 </tbody>
34098 </tgroup>
34099 </informaltable>
34100 <para>
34101 This specifies which of the available transport drivers is to be used.
34102 There is no default, and this option must be set for every transport.
34103 </para>
34104 <para>
34105 <indexterm role="option">
34106 <primary>envelope_to_add</primary>
34107 </indexterm>
34108 </para>
34109 <informaltable frame="all">
34110 <tgroup cols="4" colsep="0" rowsep="0">
34111 <colspec colwidth="8*" align="left"/>
34112 <colspec colwidth="5*" align="center"/>
34113 <colspec colwidth="5*" align="center"/>
34114 <colspec colwidth="6*" align="right"/>
34115 <tbody>
34116 <row>
34117 <entry><option>envelope_to_add</option></entry>
34118 <entry>Use: <emphasis>transports</emphasis></entry>
34119 <entry>Type: <emphasis>boolean</emphasis></entry>
34120 <entry>Default: <emphasis>false</emphasis></entry>
34121 </row>
34122 </tbody>
34123 </tgroup>
34124 </informaltable>
34125 <para>
34126 <indexterm role="concept">
34127 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
34128 </indexterm>
34129 If this option is true, an <emphasis>Envelope-to:</emphasis> header is added to the message.
34130 This gives the original address(es) in the incoming envelope that caused this
34131 delivery to happen. More than one address may be present if the transport is
34132 configured to handle several addresses at once, or if more than one original
34133 address was redirected to the same final address. As this is not a standard
34134 header, Exim has a configuration option (<option>envelope_to_remove</option>) which requests
34135 its removal from incoming messages, so that delivered messages can safely be
34136 resent to other recipients.
34137 </para>
34138 <para>
34139 <indexterm role="option">
34140 <primary>group</primary>
34141 </indexterm>
34142 </para>
34143 <informaltable frame="all">
34144 <tgroup cols="4" colsep="0" rowsep="0">
34145 <colspec colwidth="8*" align="left"/>
34146 <colspec colwidth="5*" align="center"/>
34147 <colspec colwidth="5*" align="center"/>
34148 <colspec colwidth="6*" align="right"/>
34149 <tbody>
34150 <row>
34151 <entry><option>group</option></entry>
34152 <entry>Use: <emphasis>transports</emphasis></entry>
34153 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34154 <entry>Default: <emphasis>Exim group</emphasis></entry>
34155 </row>
34156 </tbody>
34157 </tgroup>
34158 </informaltable>
34159 <para>
34160 <indexterm role="concept">
34161 <primary>transport</primary>
34162 <secondary>group; specifying</secondary>
34163 </indexterm>
34164 This option specifies a gid for running the transport process, overriding any
34165 value that the router supplies, and also overriding any value associated with
34166 <option>user</option> (see below).
34167 </para>
34168 <para>
34169 <indexterm role="option">
34170 <primary>headers_add</primary>
34171 </indexterm>
34172 </para>
34173 <informaltable frame="all">
34174 <tgroup cols="4" colsep="0" rowsep="0">
34175 <colspec colwidth="8*" align="left"/>
34176 <colspec colwidth="5*" align="center"/>
34177 <colspec colwidth="5*" align="center"/>
34178 <colspec colwidth="6*" align="right"/>
34179 <tbody>
34180 <row>
34181 <entry><option>headers_add</option></entry>
34182 <entry>Use: <emphasis>transports</emphasis></entry>
34183 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34184 <entry>Default: <emphasis>unset</emphasis></entry>
34185 </row>
34186 </tbody>
34187 </tgroup>
34188 </informaltable>
34189 <para>
34190 <indexterm role="concept">
34191 <primary>header lines</primary>
34192 <secondary>adding in transport</secondary>
34193 </indexterm>
34194 <indexterm role="concept">
34195 <primary>transport</primary>
34196 <secondary>header lines; adding</secondary>
34197 </indexterm>
34198 This option specifies a string of text that is expanded and added to the header
34199 portion of a message as it is transported, as described in section
34200 <xref linkend="SECTheadersaddrem"/>. Additional header lines can also be specified by
34201 routers. If the result of the expansion is an empty string, or if the expansion
34202 is forced to fail, no action is taken. Other expansion failures are treated as
34203 errors and cause the delivery to be deferred.
34204 </para>
34205 <para>
34206 <indexterm role="option">
34207 <primary>headers_only</primary>
34208 </indexterm>
34209 </para>
34210 <informaltable frame="all">
34211 <tgroup cols="4" colsep="0" rowsep="0">
34212 <colspec colwidth="8*" align="left"/>
34213 <colspec colwidth="5*" align="center"/>
34214 <colspec colwidth="5*" align="center"/>
34215 <colspec colwidth="6*" align="right"/>
34216 <tbody>
34217 <row>
34218 <entry><option>headers_only</option></entry>
34219 <entry>Use: <emphasis>transports</emphasis></entry>
34220 <entry>Type: <emphasis>boolean</emphasis></entry>
34221 <entry>Default: <emphasis>false</emphasis></entry>
34222 </row>
34223 </tbody>
34224 </tgroup>
34225 </informaltable>
34226 <para>
34227 <indexterm role="concept">
34228 <primary>transport</primary>
34229 <secondary>header lines only</secondary>
34230 </indexterm>
34231 <indexterm role="concept">
34232 <primary>message</primary>
34233 <secondary>transporting headers only</secondary>
34234 </indexterm>
34235 <indexterm role="concept">
34236 <primary>header lines</primary>
34237 <secondary>transporting</secondary>
34238 </indexterm>
34239 If this option is set, the message&#x2019;s body is not transported. It is mutually
34240 exclusive with <option>body_only</option>. If it is used with the <command>appendfile</command> or <command>pipe</command>
34241 transports, the settings of <option>message_prefix</option> and <option>message_suffix</option> should be
34242 checked, since this option does not automatically suppress them.
34243 </para>
34244 <para>
34245 <indexterm role="option">
34246 <primary>headers_remove</primary>
34247 </indexterm>
34248 </para>
34249 <informaltable frame="all">
34250 <tgroup cols="4" colsep="0" rowsep="0">
34251 <colspec colwidth="8*" align="left"/>
34252 <colspec colwidth="5*" align="center"/>
34253 <colspec colwidth="5*" align="center"/>
34254 <colspec colwidth="6*" align="right"/>
34255 <tbody>
34256 <row>
34257 <entry><option>headers_remove</option></entry>
34258 <entry>Use: <emphasis>transports</emphasis></entry>
34259 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34260 <entry>Default: <emphasis>unset</emphasis></entry>
34261 </row>
34262 </tbody>
34263 </tgroup>
34264 </informaltable>
34265 <para>
34266 <indexterm role="concept">
34267 <primary>header lines</primary>
34268 <secondary>removing</secondary>
34269 </indexterm>
34270 <indexterm role="concept">
34271 <primary>transport</primary>
34272 <secondary>header lines; removing</secondary>
34273 </indexterm>
34274 This option specifies a string that is expanded into a list of header names;
34275 these headers are omitted from the message as it is transported, as described
34276 in section <xref linkend="SECTheadersaddrem"/>. Header removal can also be specified by
34277 routers. If the result of the expansion is an empty string, or if the expansion
34278 is forced to fail, no action is taken. Other expansion failures are treated as
34279 errors and cause the delivery to be deferred.
34280 </para>
34281 <para>
34282 <indexterm role="option">
34283 <primary>headers_rewrite</primary>
34284 </indexterm>
34285 </para>
34286 <informaltable frame="all">
34287 <tgroup cols="4" colsep="0" rowsep="0">
34288 <colspec colwidth="8*" align="left"/>
34289 <colspec colwidth="5*" align="center"/>
34290 <colspec colwidth="5*" align="center"/>
34291 <colspec colwidth="6*" align="right"/>
34292 <tbody>
34293 <row>
34294 <entry><option>headers_rewrite</option></entry>
34295 <entry>Use: <emphasis>transports</emphasis></entry>
34296 <entry>Type: <emphasis>string</emphasis></entry>
34297 <entry>Default: <emphasis>unset</emphasis></entry>
34298 </row>
34299 </tbody>
34300 </tgroup>
34301 </informaltable>
34302 <para>
34303 <indexterm role="concept">
34304 <primary>transport</primary>
34305 <secondary>header lines; rewriting</secondary>
34306 </indexterm>
34307 <indexterm role="concept">
34308 <primary>rewriting</primary>
34309 <secondary>at transport time</secondary>
34310 </indexterm>
34311 This option allows addresses in header lines to be rewritten at transport time,
34312 that is, as the message is being copied to its destination. The contents of the
34313 option are a colon-separated list of rewriting rules. Each rule is in exactly
34314 the same form as one of the general rewriting rules that are applied when a
34315 message is received. These are described in chapter <xref linkend="CHAPrewrite"/>. For
34316 example,
34317 </para>
34318 <literallayout class="monospaced">
34319 headers_rewrite = a@b c@d f : \
34320                   x@y w@z
34321 </literallayout>
34322 <para>
34323 changes <emphasis>a@b</emphasis> into <emphasis>c@d</emphasis> in <emphasis>From:</emphasis> header lines, and <emphasis>x@y</emphasis> into
34324 <emphasis>w@z</emphasis> in all address-bearing header lines. The rules are applied to the
34325 header lines just before they are written out at transport time, so they affect
34326 only those copies of the message that pass through the transport. However, only
34327 the message&#x2019;s original header lines, and any that were added by a system
34328 filter, are rewritten. If a router or transport adds header lines, they are not
34329 affected by this option. These rewriting rules are <emphasis>not</emphasis> applied to the
34330 envelope. You can change the return path using <option>return_path</option>, but you cannot
34331 change envelope recipients at this time.
34332 </para>
34333 <para>
34334 <indexterm role="option">
34335 <primary>home_directory</primary>
34336 </indexterm>
34337 </para>
34338 <informaltable frame="all">
34339 <tgroup cols="4" colsep="0" rowsep="0">
34340 <colspec colwidth="8*" align="left"/>
34341 <colspec colwidth="5*" align="center"/>
34342 <colspec colwidth="5*" align="center"/>
34343 <colspec colwidth="6*" align="right"/>
34344 <tbody>
34345 <row>
34346 <entry><option>home_directory</option></entry>
34347 <entry>Use: <emphasis>transports</emphasis></entry>
34348 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34349 <entry>Default: <emphasis>unset</emphasis></entry>
34350 </row>
34351 </tbody>
34352 </tgroup>
34353 </informaltable>
34354 <para>
34355 <indexterm role="concept">
34356 <primary>transport</primary>
34357 <secondary>home directory for</secondary>
34358 </indexterm>
34359 <indexterm role="concept">
34360 <primary><varname>$home</varname></primary>
34361 </indexterm>
34362 This option specifies a home directory setting for <phrase revisionflag="changed">a local</phrase> transport,
34363 overriding any value that may be set by the router. The home directory is
34364 placed in <varname>$home</varname> while expanding the transport&#x2019;s private options. It is also
34365 used as the current directory if no current directory is set by the
34366 <option>current_directory</option> option on the transport or the
34367 <option>transport_current_directory</option> option on the router. If the expansion fails
34368 for any reason, including forced failure, an error is logged, and delivery is
34369 deferred.
34370 </para>
34371 <para>
34372 <indexterm role="option">
34373 <primary>initgroups</primary>
34374 </indexterm>
34375 </para>
34376 <informaltable frame="all">
34377 <tgroup cols="4" colsep="0" rowsep="0">
34378 <colspec colwidth="8*" align="left"/>
34379 <colspec colwidth="5*" align="center"/>
34380 <colspec colwidth="5*" align="center"/>
34381 <colspec colwidth="6*" align="right"/>
34382 <tbody>
34383 <row>
34384 <entry><option>initgroups</option></entry>
34385 <entry>Use: <emphasis>transports</emphasis></entry>
34386 <entry>Type: <emphasis>boolean</emphasis></entry>
34387 <entry>Default: <emphasis>false</emphasis></entry>
34388 </row>
34389 </tbody>
34390 </tgroup>
34391 </informaltable>
34392 <para>
34393 <indexterm role="concept">
34394 <primary>additional groups</primary>
34395 </indexterm>
34396 <indexterm role="concept">
34397 <primary>groups</primary>
34398 <secondary>additional</secondary>
34399 </indexterm>
34400 <indexterm role="concept">
34401 <primary>transport</primary>
34402 <secondary>group; additional</secondary>
34403 </indexterm>
34404 If this option is true and the uid for the delivery process is provided by the
34405 transport, the <function>initgroups()</function> function is called when running the transport
34406 to ensure that any additional groups associated with the uid are set up.
34407 </para>
34408 <para>
34409 <indexterm role="option">
34410 <primary>message_size_limit</primary>
34411 </indexterm>
34412 </para>
34413 <informaltable frame="all">
34414 <tgroup cols="4" colsep="0" rowsep="0">
34415 <colspec colwidth="8*" align="left"/>
34416 <colspec colwidth="5*" align="center"/>
34417 <colspec colwidth="5*" align="center"/>
34418 <colspec colwidth="6*" align="right"/>
34419 <tbody>
34420 <row>
34421 <entry><option>message_size_limit</option></entry>
34422 <entry>Use: <emphasis>transports</emphasis></entry>
34423 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34424 <entry>Default: <emphasis>0</emphasis></entry>
34425 </row>
34426 </tbody>
34427 </tgroup>
34428 </informaltable>
34429 <para>
34430 <indexterm role="concept">
34431 <primary>limit</primary>
34432 <secondary>message size per transport</secondary>
34433 </indexterm>
34434 <indexterm role="concept">
34435 <primary>size of message</primary>
34436 <secondary>limit</secondary>
34437 </indexterm>
34438 <indexterm role="concept">
34439 <primary>transport</primary>
34440 <secondary>message size; limiting</secondary>
34441 </indexterm>
34442 This option controls the size of messages passed through the transport. It is
34443 expanded before use; the result of the expansion must be a sequence of digits,
34444 optionally followed by K or M.
34445 If the expansion fails for any reason, including forced failure, or if the
34446 result is not of the required form, delivery is deferred.
34447 If the value is greater than zero and the size of a message exceeds this
34448 limit, the address is failed. If there is any chance that the resulting bounce
34449 message could be routed to the same transport, you should ensure that
34450 <option>return_size_limit</option> is less than the transport&#x2019;s <option>message_size_limit</option>, as
34451 otherwise the bounce message will fail to get delivered.
34452 </para>
34453 <para>
34454 <indexterm role="option">
34455 <primary>rcpt_include_affixes</primary>
34456 </indexterm>
34457 </para>
34458 <informaltable frame="all">
34459 <tgroup cols="4" colsep="0" rowsep="0">
34460 <colspec colwidth="8*" align="left"/>
34461 <colspec colwidth="5*" align="center"/>
34462 <colspec colwidth="5*" align="center"/>
34463 <colspec colwidth="6*" align="right"/>
34464 <tbody>
34465 <row>
34466 <entry><option>rcpt_include_affixes</option></entry>
34467 <entry>Use: <emphasis>transports</emphasis></entry>
34468 <entry>Type: <emphasis>boolean</emphasis></entry>
34469 <entry>Default: <emphasis>false</emphasis></entry>
34470 </row>
34471 </tbody>
34472 </tgroup>
34473 </informaltable>
34474 <para>
34475 <indexterm role="concept">
34476 <primary>prefix</primary>
34477 <secondary>for local part; including in envelope</secondary>
34478 </indexterm>
34479 <indexterm role="concept">
34480 <primary>suffix</primary>
34481 <secondary>for local part; including in envelope</secondary>
34482 </indexterm>
34483 <indexterm role="concept">
34484 <primary>local part</primary>
34485 <secondary>prefix</secondary>
34486 </indexterm>
34487 <indexterm role="concept">
34488 <primary>local part</primary>
34489 <secondary>suffix</secondary>
34490 </indexterm>
34491 When this option is false (the default), and an address that has had any
34492 affixes (prefixes or suffixes) removed from the local part is delivered by any
34493 form of SMTP or LMTP, the affixes are not included. For example, if a router
34494 that contains
34495 </para>
34496 <literallayout class="monospaced">
34497 local_part_prefix = *-
34498 </literallayout>
34499 <para>
34500 routes the address <emphasis>abc-xyz@some.domain</emphasis> to an SMTP transport, the envelope
34501 is delivered with
34502 </para>
34503 <literallayout class="monospaced">
34504 RCPT TO:&lt;xyz@some.domain&gt;
34505 </literallayout>
34506 <para>
34507 This is also the case when an ACL-time callout is being used to verify a
34508 recipient address. However, if <option>rcpt_include_affixes</option> is set true, the
34509 whole local part is included in the RCPT command. This option applies to BSMTP
34510 deliveries by the <command>appendfile</command> and <command>pipe</command> transports as well as to the
34511 <command>lmtp</command> and <command>smtp</command> transports.
34512 </para>
34513 <para>
34514 <indexterm role="option">
34515 <primary>retry_use_local_part</primary>
34516 </indexterm>
34517 </para>
34518 <informaltable frame="all">
34519 <tgroup cols="4" colsep="0" rowsep="0">
34520 <colspec colwidth="8*" align="left"/>
34521 <colspec colwidth="5*" align="center"/>
34522 <colspec colwidth="5*" align="center"/>
34523 <colspec colwidth="6*" align="right"/>
34524 <tbody>
34525 <row>
34526 <entry><option>retry_use_local_part</option></entry>
34527 <entry>Use: <emphasis>transports</emphasis></entry>
34528 <entry>Type: <emphasis>boolean</emphasis></entry>
34529 <entry>Default: <emphasis>see below</emphasis></entry>
34530 </row>
34531 </tbody>
34532 </tgroup>
34533 </informaltable>
34534 <para>
34535 <indexterm role="concept">
34536 <primary>hints database</primary>
34537 <secondary>retry keys</secondary>
34538 </indexterm>
34539 When a delivery suffers a temporary failure, a retry record is created
34540 in Exim&#x2019;s hints database. For remote deliveries, the key for the retry record
34541 is based on the name and/or IP address of the failing remote host. For local
34542 deliveries, the key is normally the entire address, including both the local
34543 part and the domain. This is suitable for most common cases of local delivery
34544 temporary failure &ndash; for example, exceeding a mailbox quota should delay only
34545 deliveries to that mailbox, not to the whole domain.
34546 </para>
34547 <para>
34548 However, in some special cases you may want to treat a temporary local delivery
34549 as a failure associated with the domain, and not with a particular local part.
34550 (For example, if you are storing all mail for some domain in files.) You can do
34551 this by setting <option>retry_use_local_part</option> false.
34552 </para>
34553 <para>
34554 For all the local transports, its default value is true. For remote transports,
34555 the default value is false for tidiness, but changing the value has no effect
34556 on a remote transport in the current implementation.
34557 </para>
34558 <para>
34559 <indexterm role="option">
34560 <primary>return_path</primary>
34561 </indexterm>
34562 </para>
34563 <informaltable frame="all">
34564 <tgroup cols="4" colsep="0" rowsep="0">
34565 <colspec colwidth="8*" align="left"/>
34566 <colspec colwidth="5*" align="center"/>
34567 <colspec colwidth="5*" align="center"/>
34568 <colspec colwidth="6*" align="right"/>
34569 <tbody>
34570 <row>
34571 <entry><option>return_path</option></entry>
34572 <entry>Use: <emphasis>transports</emphasis></entry>
34573 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34574 <entry>Default: <emphasis>unset</emphasis></entry>
34575 </row>
34576 </tbody>
34577 </tgroup>
34578 </informaltable>
34579 <para>
34580 <indexterm role="concept">
34581 <primary>envelope sender</primary>
34582 </indexterm>
34583 <indexterm role="concept">
34584 <primary>transport</primary>
34585 <secondary>return path; changing</secondary>
34586 </indexterm>
34587 <indexterm role="concept">
34588 <primary>return path</primary>
34589 <secondary>changing in transport</secondary>
34590 </indexterm>
34591 If this option is set, the string is expanded at transport time and replaces
34592 the existing return path (envelope sender) value in the copy of the message
34593 that is being delivered. An empty return path is permitted. This feature is
34594 designed for remote deliveries, where the value of this option is used in the
34595 SMTP MAIL command. If you set <option>return_path</option> for a local transport, the
34596 only effect is to change the address that is placed in the <emphasis>Return-path:</emphasis>
34597 header line, if one is added to the message (see the next option).
34598 </para>
34599 <para>
34600 <indexterm role="concept">
34601 <primary><varname>$return_path</varname></primary>
34602 </indexterm>
34603 The expansion can refer to the existing value via <varname>$return_path</varname>. This is
34604 either the message&#x2019;s envelope sender, or an address set by the
34605 <option>errors_to</option> option on a router. If the expansion is forced to fail, no
34606 replacement occurs; if it fails for another reason, delivery is deferred. This
34607 option can be used to support VERP (Variable Envelope Return Paths) &ndash; see
34608 section <xref linkend="SECTverp"/>.
34609 </para>
34610 <para revisionflag="changed">
34611 <emphasis role="bold">Note</emphasis>: If a delivery error is detected locally, including the case when a
34612 remote server rejects a message at SMTP time, the bounce message is not sent to
34613 the value of this option. It is sent to the previously set errors address.
34614 This defaults to the incoming sender address, but can be changed by setting
34615 <option>errors_to</option> in a router.
34616 </para>
34617 <para>
34618 <indexterm role="option">
34619 <primary>return_path_add</primary>
34620 </indexterm>
34621 </para>
34622 <informaltable frame="all">
34623 <tgroup cols="4" colsep="0" rowsep="0">
34624 <colspec colwidth="8*" align="left"/>
34625 <colspec colwidth="5*" align="center"/>
34626 <colspec colwidth="5*" align="center"/>
34627 <colspec colwidth="6*" align="right"/>
34628 <tbody>
34629 <row>
34630 <entry><option>return_path_add</option></entry>
34631 <entry>Use: <emphasis>transports</emphasis></entry>
34632 <entry>Type: <emphasis>boolean</emphasis></entry>
34633 <entry>Default: <emphasis>false</emphasis></entry>
34634 </row>
34635 </tbody>
34636 </tgroup>
34637 </informaltable>
34638 <para>
34639 <indexterm role="concept">
34640 <primary><emphasis>Return-path:</emphasis> header line</primary>
34641 </indexterm>
34642 If this option is true, a <emphasis>Return-path:</emphasis> header is added to the message.
34643 Although the return path is normally available in the prefix line of BSD
34644 mailboxes, this is commonly not displayed by MUAs, and so the user does not
34645 have easy access to it.
34646 </para>
34647 <para>
34648 RFC 2821 states that the <emphasis>Return-path:</emphasis> header is added to a message <quote>when
34649 the delivery SMTP server makes the final delivery</quote>. This implies that this
34650 header should not be present in incoming messages. Exim has a configuration
34651 option, <option>return_path_remove</option>, which requests removal of this header from
34652 incoming messages, so that delivered messages can safely be resent to other
34653 recipients.
34654 </para>
34655 <para>
34656 <indexterm role="option">
34657 <primary>shadow_condition</primary>
34658 </indexterm>
34659 </para>
34660 <informaltable frame="all">
34661 <tgroup cols="4" colsep="0" rowsep="0">
34662 <colspec colwidth="8*" align="left"/>
34663 <colspec colwidth="5*" align="center"/>
34664 <colspec colwidth="5*" align="center"/>
34665 <colspec colwidth="6*" align="right"/>
34666 <tbody>
34667 <row>
34668 <entry><option>shadow_condition</option></entry>
34669 <entry>Use: <emphasis>transports</emphasis></entry>
34670 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34671 <entry>Default: <emphasis>unset</emphasis></entry>
34672 </row>
34673 </tbody>
34674 </tgroup>
34675 </informaltable>
34676 <para>
34677 See <option>shadow_transport</option> below.
34678 </para>
34679 <para>
34680 <indexterm role="option">
34681 <primary>shadow_transport</primary>
34682 </indexterm>
34683 </para>
34684 <informaltable frame="all">
34685 <tgroup cols="4" colsep="0" rowsep="0">
34686 <colspec colwidth="8*" align="left"/>
34687 <colspec colwidth="5*" align="center"/>
34688 <colspec colwidth="5*" align="center"/>
34689 <colspec colwidth="6*" align="right"/>
34690 <tbody>
34691 <row>
34692 <entry><option>shadow_transport</option></entry>
34693 <entry>Use: <emphasis>transports</emphasis></entry>
34694 <entry>Type: <emphasis>string</emphasis></entry>
34695 <entry>Default: <emphasis>unset</emphasis></entry>
34696 </row>
34697 </tbody>
34698 </tgroup>
34699 </informaltable>
34700 <para>
34701 <indexterm role="concept">
34702 <primary>shadow transport</primary>
34703 </indexterm>
34704 <indexterm role="concept">
34705 <primary>transport</primary>
34706 <secondary>shadow</secondary>
34707 </indexterm>
34708 A local transport may set the <option>shadow_transport</option> option to the name of
34709 another local transport. Shadow remote transports are not supported.
34710 </para>
34711 <para>
34712 Whenever a delivery to the main transport succeeds, and either
34713 <option>shadow_condition</option> is unset, or its expansion does not result in the empty
34714 string or one of the strings <quote>0</quote> or <quote>no</quote> or <quote>false</quote>, the message is also
34715 passed to the shadow transport, with the same delivery address or addresses. If
34716 expansion fails, no action is taken except that non-forced expansion failures
34717 cause a log line to be written.
34718 </para>
34719 <para>
34720 The result of the shadow transport is discarded and does not affect the
34721 subsequent processing of the message. Only a single level of shadowing is
34722 provided; the <option>shadow_transport</option> option is ignored on any transport when it
34723 is running as a shadow. Options concerned with output from pipes are also
34724 ignored. The log line for the successful delivery has an item added on the end,
34725 of the form
34726 </para>
34727 <literallayout class="monospaced">
34728 ST=&lt;shadow transport name&gt;
34729 </literallayout>
34730 <para>
34731 If the shadow transport did not succeed, the error message is put in
34732 parentheses afterwards. Shadow transports can be used for a number of different
34733 purposes, including keeping more detailed log information than Exim normally
34734 provides, and implementing automatic acknowledgement policies based on message
34735 headers that some sites insist on.
34736 </para>
34737 <para>
34738 <indexterm role="option">
34739 <primary>transport_filter</primary>
34740 </indexterm>
34741 </para>
34742 <informaltable frame="all">
34743 <tgroup cols="4" colsep="0" rowsep="0">
34744 <colspec colwidth="8*" align="left"/>
34745 <colspec colwidth="5*" align="center"/>
34746 <colspec colwidth="5*" align="center"/>
34747 <colspec colwidth="6*" align="right"/>
34748 <tbody>
34749 <row>
34750 <entry><option>transport_filter</option></entry>
34751 <entry>Use: <emphasis>transports</emphasis></entry>
34752 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34753 <entry>Default: <emphasis>unset</emphasis></entry>
34754 </row>
34755 </tbody>
34756 </tgroup>
34757 </informaltable>
34758 <para>
34759 <indexterm role="concept">
34760 <primary>transport</primary>
34761 <secondary>filter</secondary>
34762 </indexterm>
34763 <indexterm role="concept">
34764 <primary>filter</primary>
34765 <secondary>transport filter</secondary>
34766 </indexterm>
34767 This option sets up a filtering (in the Unix shell sense) process for messages
34768 at transport time. It should not be confused with mail filtering as set up by
34769 individual users or via a system filter.
34770 </para>
34771 <para>
34772 When the message is about to be written out, the command specified by
34773 <option>transport_filter</option> is started up in a separate, parallel process, and
34774 the entire message, including the header lines, is passed to it on its standard
34775 input (this in fact is done from a third process, to avoid deadlock). The
34776 command must be specified as an absolute path.
34777 </para>
34778 <para>
34779 The lines of the message that are written to the transport filter are
34780 terminated by newline (<quote>\n</quote>). The message is passed to the filter before any
34781 SMTP-specific processing, such as turning <quote>\n</quote> into <quote>\r\n</quote> and escaping
34782 lines beginning with a dot, and also before any processing implied by the
34783 settings of <option>check_string</option> and <option>escape_string</option> in the <command>appendfile</command> or
34784 <command>pipe</command> transports.
34785 </para>
34786 <para>
34787 The standard error for the filter process is set to the same destination as its
34788 standard output; this is read and written to the message&#x2019;s ultimate
34789 destination. The process that writes the message to the filter, the
34790 filter itself, and the original process that reads the result and delivers it
34791 are all run in parallel, like a shell pipeline.
34792 </para>
34793 <para>
34794 The filter can perform any transformations it likes, but of course should take
34795 care not to break RFC 2822 syntax. A demonstration Perl script is provided in
34796 <filename>util/transport-filter.pl</filename>; this makes a few arbitrary modifications just to
34797 show the possibilities. Exim does not check the result, except to test for a
34798 final newline when SMTP is in use. All messages transmitted over SMTP must end
34799 with a newline, so Exim supplies one if it is missing.
34800 </para>
34801 <para>
34802 <indexterm role="concept">
34803 <primary>content scanning</primary>
34804 <secondary>per user</secondary>
34805 </indexterm>
34806 A transport filter can be used to provide content-scanning on a per-user basis
34807 at delivery time if the only required effect of the scan is to modify the
34808 message. For example, a content scan could insert a new header line containing
34809 a spam score. This could be interpreted by a filter in the user&#x2019;s MUA. It is
34810 not possible to discard a message at this stage.
34811 </para>
34812 <para>
34813 <indexterm role="concept">
34814 <primary>SMTP</primary>
34815 <secondary>SIZE</secondary>
34816 </indexterm>
34817 A problem might arise if the filter increases the size of a message that is
34818 being sent down an SMTP connection. If the receiving SMTP server has indicated
34819 support for the SIZE parameter, Exim will have sent the size of the message
34820 at the start of the SMTP session. If what is actually sent is substantially
34821 more, the server might reject the message. This can be worked round by setting
34822 the <option>size_addition</option> option on the <command>smtp</command> transport, either to allow for
34823 additions to the message, or to disable the use of SIZE altogether.
34824 </para>
34825 <para>
34826 <indexterm role="concept">
34827 <primary><varname>$pipe_addresses</varname></primary>
34828 </indexterm>
34829 The value of the <option>transport_filter</option> option is the command string for starting
34830 the filter, which is run directly from Exim, not under a shell. The string is
34831 parsed by Exim in the same way as a command string for the <command>pipe</command> transport:
34832 Exim breaks it up into arguments and then expands each argument separately (see
34833 section <xref linkend="SECThowcommandrun"/>). Any kind of expansion failure causes delivery
34834 to be deferred. The special argument <varname>$pipe_addresses</varname> is replaced by a number
34835 of arguments, one for each address that applies to this delivery. (This isn&#x2019;t
34836 an ideal name for this feature here, but as it was already implemented for the
34837 <command>pipe</command> transport, it seemed sensible not to change it.)
34838 </para>
34839 <para>
34840 <indexterm role="concept">
34841 <primary><varname>$host</varname></primary>
34842 </indexterm>
34843 <indexterm role="concept">
34844 <primary><varname>$host_address</varname></primary>
34845 </indexterm>
34846 The expansion variables <varname>$host</varname> and <varname>$host_address</varname> are available when the
34847 transport is a remote one. They contain the name and IP address of the host to
34848 which the message is being sent. For example:
34849 </para>
34850 <literallayout class="monospaced">
34851 transport_filter = /some/directory/transport-filter.pl \
34852   $host $host_address $sender_address $pipe_addresses
34853 </literallayout>
34854 <para revisionflag="changed">
34855 Two problems arise if you want to use more complicated expansion items to
34856 generate transport filter commands, both of which due to the fact that the
34857 command is split up <emphasis>before</emphasis> expansion.
34858 </para>
34859 <itemizedlist revisionflag="changed">
34860 <listitem>
34861 <para revisionflag="changed">
34862 If an expansion item contains white space, you must quote it, so that it is all
34863 part of the same command item. If the entire option setting is one such
34864 expansion item, you have to take care what kind of quoting you use. For
34865 example:
34866 </para>
34867 <literallayout class="monospaced" revisionflag="changed">
34868 transport_filter = '/bin/cmd${if eq{$host}{a.b.c}{1}{2}}'
34869 </literallayout>
34870 <para revisionflag="changed">
34871 This runs the command <command>/bin/cmd1</command> if the host name is <emphasis>a.b.c</emphasis>, and
34872 <command>/bin/cmd2</command> otherwise. If double quotes had been used, they would have been
34873 stripped by Exim when it read the option&#x2019;s value. When the value is used, if
34874 the single quotes were missing, the line would be split into two items,
34875 <literal>/bin/cmd${if</literal> and <literal>eq{$host}{a.b.c}{1}{2}</literal>, and an error would occur when
34876 Exim tried to expand the first one.
34877 </para>
34878 </listitem>
34879 <listitem>
34880 <para revisionflag="changed">
34881 Except for the special case of <varname>$pipe_addresses</varname> that is mentioned above, an
34882 expansion cannot generate multiple arguments, or a command name followed by
34883 arguments. Consider this example:
34884 </para>
34885 <literallayout class="monospaced" revisionflag="changed">
34886 transport_filter = ${lookup{$host}lsearch{/some/file}\
34887                     {$value}{/bin/cat}}
34888 </literallayout>
34889 <para revisionflag="changed">
34890 The result of the lookup is interpreted as the name of the command, even
34891 if it contains white space. The simplest way round this is to use a shell:
34892 </para>
34893 <literallayout class="monospaced" revisionflag="changed">
34894 transport_filter = /bin/sh -c ${lookup{$host}lsearch{/some/file}\
34895                                {$value}{/bin/cat}}
34896 </literallayout>
34897 </listitem>
34898 </itemizedlist>
34899 <para>
34900 The filter process is run under the same uid and gid as the normal delivery.
34901 For remote deliveries this is the Exim uid/gid by default. The command should
34902 normally yield a zero return code. Transport filters are not supposed to fail.
34903 A non-zero code is taken to mean that the transport filter encountered some
34904 serious problem. Delivery of the message is deferred; the message remains on
34905 the queue and is tried again later. It is not possible to cause a message to be
34906 bounced from a transport filter.
34907 </para>
34908 <para>
34909 If a transport filter is set on an autoreply transport, the original message is
34910 passed through the filter as it is being copied into the newly generated
34911 message, which happens if the <option>return_message</option> option is set.
34912 </para>
34913 <para>
34914 <indexterm role="option">
34915 <primary>transport_filter_timeout</primary>
34916 </indexterm>
34917 </para>
34918 <informaltable frame="all">
34919 <tgroup cols="4" colsep="0" rowsep="0">
34920 <colspec colwidth="8*" align="left"/>
34921 <colspec colwidth="5*" align="center"/>
34922 <colspec colwidth="5*" align="center"/>
34923 <colspec colwidth="6*" align="right"/>
34924 <tbody>
34925 <row>
34926 <entry><option>transport_filter_timeout</option></entry>
34927 <entry>Use: <emphasis>transports</emphasis></entry>
34928 <entry>Type: <emphasis>time</emphasis></entry>
34929 <entry>Default: <emphasis>5m</emphasis></entry>
34930 </row>
34931 </tbody>
34932 </tgroup>
34933 </informaltable>
34934 <para>
34935 <indexterm role="concept">
34936 <primary>transport filter</primary>
34937 <secondary>timeout</secondary>
34938 </indexterm>
34939 When Exim is reading the output of a transport filter, it a applies a timeout
34940 that can be set by this option. Exceeding the timeout is normally treated as a
34941 temporary delivery failure. However, if a transport filter is used with a
34942 <command>pipe</command> transport, a timeout in the transport filter is treated in the same
34943 way as a timeout in the pipe command itself. By default, a timeout is a hard
34944 error, but if the <command>pipe</command> transport&#x2019;s <option>timeout_defer</option> option is set true, it
34945 becomes a temporary error.
34946 </para>
34947 <para>
34948 <indexterm role="option">
34949 <primary>user</primary>
34950 </indexterm>
34951 </para>
34952 <informaltable frame="all">
34953 <tgroup cols="4" colsep="0" rowsep="0">
34954 <colspec colwidth="8*" align="left"/>
34955 <colspec colwidth="5*" align="center"/>
34956 <colspec colwidth="5*" align="center"/>
34957 <colspec colwidth="6*" align="right"/>
34958 <tbody>
34959 <row>
34960 <entry><option>user</option></entry>
34961 <entry>Use: <emphasis>transports</emphasis></entry>
34962 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34963 <entry>Default: <emphasis>Exim user</emphasis></entry>
34964 </row>
34965 </tbody>
34966 </tgroup>
34967 </informaltable>
34968 <para>
34969 <indexterm role="concept">
34970 <primary>uid (user id)</primary>
34971 <secondary>local delivery</secondary>
34972 </indexterm>
34973 <indexterm role="concept">
34974 <primary>transport user</primary>
34975 <secondary>specifying</secondary>
34976 </indexterm>
34977 This option specifies the user under whose uid the delivery process is to be
34978 run, overriding any uid that may have been set by the router. If the user is
34979 given as a name, the uid is looked up from the password data, and the
34980 associated group is taken as the value of the gid to be used if the <option>group</option>
34981 option is not set.
34982 </para>
34983 <para>
34984 For deliveries that use local transports, a user and group are normally
34985 specified explicitly or implicitly (for example, as a result of
34986 <option>check_local_user</option>) by the router or transport.
34987 </para>
34988 <para>
34989 <indexterm role="concept">
34990 <primary>hints database</primary>
34991 <secondary>access by remote transport</secondary>
34992 </indexterm>
34993 For remote transports, you should leave this option unset unless you really are
34994 sure you know what you are doing. When a remote transport is running, it needs
34995 to be able to access Exim&#x2019;s hints databases, because each host may have its own
34996 retry data.
34997 <indexterm role="concept" startref="IIDgenoptra1" class="endofrange"/>
34998 <indexterm role="concept" startref="IIDgenoptra2" class="endofrange"/>
34999 <indexterm role="concept" startref="IIDgenoptra3" class="endofrange"/>
35000 </para>
35001 </chapter>
35002
35003 <chapter id="CHAPbatching">
35004 <title>Address batching in local transports</title>
35005 <titleabbrev>Address batching</titleabbrev>
35006 <para>
35007 <indexterm role="concept">
35008 <primary>transport</primary>
35009 <secondary>local; address batching in</secondary>
35010 </indexterm>
35011 The only remote transport (<command>smtp</command>) is normally configured to handle more than
35012 one address at a time, so that when several addresses are routed to the same
35013 remote host, just one copy of the message is sent. Local transports, however,
35014 normally handle one address at a time. That is, a separate instance of the
35015 transport is run for each address that is routed to the transport. A separate
35016 copy of the message is delivered each time.
35017 </para>
35018 <para>
35019 <indexterm role="concept">
35020 <primary>batched local delivery</primary>
35021 </indexterm>
35022 <indexterm role="concept">
35023 <primary><option>batch_max</option></primary>
35024 </indexterm>
35025 <indexterm role="concept">
35026 <primary><option>batch_id</option></primary>
35027 </indexterm>
35028 In special cases, it may be desirable to handle several addresses at once in a
35029 local transport, for example:
35030 </para>
35031 <itemizedlist>
35032 <listitem>
35033 <para>
35034 In an <command>appendfile</command> transport, when storing messages in files for later
35035 delivery by some other means, a single copy of the message with multiple
35036 recipients saves space.
35037 </para>
35038 </listitem>
35039 <listitem>
35040 <para>
35041 In an <command>lmtp</command> transport, when delivering over <quote>local SMTP</quote> to some process,
35042 a single copy saves time, and is the normal way LMTP is expected to work.
35043 </para>
35044 </listitem>
35045 <listitem>
35046 <para>
35047 In a <command>pipe</command> transport, when passing the message
35048 to a scanner program or
35049 to some other delivery mechanism such as UUCP, multiple recipients may be
35050 acceptable.
35051 </para>
35052 </listitem>
35053 </itemizedlist>
35054 <para>
35055 The three local transports (<command>appendfile</command>, <command>lmtp</command>, and <command>pipe</command>) all have
35056 the same options for controlling multiple (<quote>batched</quote>) deliveries, namely
35057 <option>batch_max</option> and <option>batch_id</option>. To save repeating the information for each
35058 transport, these options are described here.
35059 </para>
35060 <para>
35061 The <option>batch_max</option> option specifies the maximum number of addresses that can be
35062 delivered together in a single run of the transport. Its default value is one.
35063 When more than one address is routed to a transport that has a <option>batch_max</option>
35064 value greater than one, the addresses are delivered in a batch (that is, in a
35065 single run of the transport), subject to certain conditions:
35066 </para>
35067 <itemizedlist>
35068 <listitem>
35069 <para>
35070 <indexterm role="concept">
35071 <primary><varname>$local_part</varname></primary>
35072 </indexterm>
35073 If any of the transport&#x2019;s options contain a reference to <varname>$local_part</varname>, no
35074 batching is possible.
35075 </para>
35076 </listitem>
35077 <listitem>
35078 <para>
35079 <indexterm role="concept">
35080 <primary><varname>$domain</varname></primary>
35081 </indexterm>
35082 If any of the transport&#x2019;s options contain a reference to <varname>$domain</varname>, only
35083 addresses with the same domain are batched.
35084 </para>
35085 </listitem>
35086 <listitem>
35087 <para>
35088 <indexterm role="concept">
35089 <primary>customizing</primary>
35090 <secondary>batching condition</secondary>
35091 </indexterm>
35092 If <option>batch_id</option> is set, it is expanded for each address, and only those
35093 addresses with the same expanded value are batched. This allows you to specify
35094 customized batching conditions.
35095 Failure of the expansion for any reason, including forced failure, disables
35096 batching, but it does not stop the delivery from taking place.
35097 </para>
35098 </listitem>
35099 <listitem>
35100 <para>
35101 Batched addresses must also have the same errors address (where to send
35102 delivery errors), the same header additions and removals, the same user and
35103 group for the transport, and if a host list is present, the first host must
35104 be the same.
35105 </para>
35106 </listitem>
35107 </itemizedlist>
35108 <para>
35109 <indexterm role="concept">
35110 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
35111 </indexterm>
35112 If the generic <option>envelope_to_add</option> option is set for the transport, the
35113 <emphasis>Envelope-to:</emphasis> header that is added to the message contains all the addresses
35114 that are batched together.
35115 </para>
35116 <para>
35117 The <command>appendfile</command> and <command>pipe</command> transports have an option called <option>use_bsmtp</option>,
35118 which causes them to deliver the message in <quote>batched SMTP</quote> format, with the
35119 envelope represented as SMTP commands. The <option>check_string</option> and
35120 <option>escape_string</option> options are forced to the values
35121 </para>
35122 <literallayout class="monospaced">
35123 check_string = "."
35124 escape_string = ".."
35125 </literallayout>
35126 <para>
35127 when batched SMTP is in use. A full description of the batch SMTP mechanism is
35128 given in section <xref linkend="SECTbatchSMTP"/>. The <command>lmtp</command> transport does not have a
35129 <option>use_bsmtp</option> option, because it always delivers using the SMTP protocol.
35130 </para>
35131 <para>
35132 <indexterm role="concept">
35133 <primary><command>pipe</command> transport</primary>
35134 <secondary>with multiple addresses</secondary>
35135 </indexterm>
35136 <indexterm role="concept">
35137 <primary><varname>$pipe_addresses</varname></primary>
35138 </indexterm>
35139 If you are not using BSMTP, but are using a <command>pipe</command> transport, you can include
35140 <varname>$pipe_addresses</varname> as part of the command. This is not a true variable; it is
35141 a bit of magic that causes each of the recipient addresses to be inserted into
35142 the command as a separate argument. This provides a way of accessing all the
35143 addresses that are being delivered in the batch.
35144 </para>
35145 <para>
35146 If you are using a batching <command>appendfile</command> transport without <option>use_bsmtp</option>, the
35147 only way to preserve the recipient addresses is to set the <option>envelope_to_add</option>
35148 option. This causes an <emphasis>Envelope-to:</emphasis> header line to be added to the message,
35149 containing all the recipients.
35150 </para>
35151 </chapter>
35152
35153 <chapter id="CHAPappendfile">
35154 <title>The appendfile transport</title>
35155 <para>
35156 <indexterm role="concept" id="IIDapptra1" class="startofrange">
35157 <primary><command>appendfile</command> transport</primary>
35158 </indexterm>
35159 <indexterm role="concept" id="IIDapptra2" class="startofrange">
35160 <primary>transports</primary>
35161 <secondary><command>appendfile</command></secondary>
35162 </indexterm>
35163 <indexterm role="concept">
35164 <primary>directory creation</primary>
35165 </indexterm>
35166 <indexterm role="concept">
35167 <primary>creating directories</primary>
35168 </indexterm>
35169 The <command>appendfile</command> transport delivers a message by appending it to an existing
35170 file, or by creating an entirely new file in a specified directory. Single
35171 files to which messages are appended can be in the traditional Unix mailbox
35172 format, or optionally in the MBX format supported by the Pine MUA and
35173 University of Washington IMAP daemon, <emphasis>inter alia</emphasis>. When each message is
35174 being delivered as a separate file, <quote>maildir</quote> format can optionally be used
35175 to give added protection against failures that happen part-way through the
35176 delivery. A third form of separate-file delivery known as <quote>mailstore</quote> is also
35177 supported. For all file formats, Exim attempts to create as many levels of
35178 directory as necessary, provided that <option>create_directory</option> is set.
35179 </para>
35180 <para>
35181 The code for the optional formats is not included in the Exim binary by
35182 default. It is necessary to set SUPPORT_MBX, SUPPORT_MAILDIR and/or
35183 SUPPORT_MAILSTORE in <filename>Local/Makefile</filename> to have the appropriate code
35184 included.
35185 </para>
35186 <para>
35187 <indexterm role="concept">
35188 <primary>quota</primary>
35189 <secondary>system</secondary>
35190 </indexterm>
35191 Exim recognises system quota errors, and generates an appropriate message. Exim
35192 also supports its own quota control within the transport, for use when the
35193 system facility is unavailable or cannot be used for some reason.
35194 </para>
35195 <para>
35196 If there is an error while appending to a file (for example, quota exceeded or
35197 partition filled), Exim attempts to reset the file&#x2019;s length and last
35198 modification time back to what they were before. If there is an error while
35199 creating an entirely new file, the new file is removed.
35200 </para>
35201 <para>
35202 Before appending to a file, a number of security checks are made, and the
35203 file is locked. A detailed description is given below, after the list of
35204 private options.
35205 </para>
35206 <para>
35207 The <command>appendfile</command> transport is most commonly used for local deliveries to
35208 users&#x2019; mailboxes. However, it can also be used as a pseudo-remote transport for
35209 putting messages into files for remote delivery by some means other than Exim.
35210 <quote>Batch SMTP</quote> format is often used in this case (see the <option>use_bsmtp</option>
35211 option).
35212 </para>
35213 <section id="SECTfildiropt">
35214 <title>The file and directory options</title>
35215 <para>
35216 The <option>file</option> option specifies a single file, to which the message is appended;
35217 the <option>directory</option> option specifies a directory, in which a new file containing
35218 the message is created. Only one of these two options can be set, and for
35219 normal deliveries to mailboxes, one of them <emphasis>must</emphasis> be set.
35220 </para>
35221 <para>
35222 <indexterm role="concept">
35223 <primary><varname>$address_file</varname></primary>
35224 </indexterm>
35225 <indexterm role="concept">
35226 <primary><varname>$local_part</varname></primary>
35227 </indexterm>
35228 However, <command>appendfile</command> is also used for delivering messages to files or
35229 directories whose names (or parts of names) are obtained from alias,
35230 forwarding, or filtering operations (for example, a <option>save</option> command in a
35231 user&#x2019;s Exim filter). When such a transport is running, <varname>$local_part</varname> contains
35232 the local part that was aliased or forwarded, and <varname>$address_file</varname> contains the
35233 name (or partial name) of the file or directory generated by the redirection
35234 operation. There are two cases:
35235 </para>
35236 <itemizedlist>
35237 <listitem>
35238 <para>
35239 If neither <option>file</option> nor <option>directory</option> is set, the redirection operation
35240 must specify an absolute path (one that begins with <literal>/</literal>). This is the most
35241 common case when users with local accounts use filtering to sort mail into
35242 different folders. See for example, the <command>address_file</command> transport in the
35243 default configuration. If the path ends with a slash, it is assumed to be the
35244 name of a directory. A delivery to a directory can also be forced by setting
35245 <option>maildir_format</option> or <option>mailstore_format</option>.
35246 </para>
35247 </listitem>
35248 <listitem>
35249 <para>
35250 If <option>file</option> or <option>directory</option> is set for a delivery from a redirection, it is
35251 used to determine the file or directory name for the delivery. Normally, the
35252 contents of <varname>$address_file</varname> are used in some way in the string expansion.
35253 </para>
35254 </listitem>
35255 </itemizedlist>
35256 <para>
35257 <indexterm role="concept">
35258 <primary>Sieve filter</primary>
35259 <secondary>configuring <command>appendfile</command></secondary>
35260 </indexterm>
35261 <indexterm role="concept">
35262 <primary>Sieve filter</primary>
35263 <secondary>relative mailbox path handling</secondary>
35264 </indexterm>
35265 As an example of the second case, consider an environment where users do not
35266 have home directories. They may be permitted to use Exim filter commands of the
35267 form:
35268 </para>
35269 <literallayout class="monospaced">
35270 save folder23
35271 </literallayout>
35272 <para>
35273 or Sieve filter commands of the form:
35274 </para>
35275 <literallayout class="monospaced">
35276 require "fileinto";
35277 fileinto "folder23";
35278 </literallayout>
35279 <para>
35280 In this situation, the expansion of <option>file</option> or <option>directory</option> in the transport
35281 must transform the relative path into an appropriate absolute file name. In the
35282 case of Sieve filters, the name <emphasis>inbox</emphasis> must be handled. It is the name that
35283 is used as a result of a <quote>keep</quote> action in the filter. This example shows one
35284 way of handling this requirement:
35285 </para>
35286 <literallayout class="monospaced">
35287 file = ${if eq{$address_file}{inbox} \
35288             {/var/mail/$local_part} \
35289             {${if eq{${substr_0_1:$address_file}}{/} \
35290                   {$address_file} \
35291                   {$home/mail/$address_file} \
35292             }} \
35293        }
35294 </literallayout>
35295 <para>
35296 With this setting of <option>file</option>, <emphasis>inbox</emphasis> refers to the standard mailbox
35297 location, absolute paths are used without change, and other folders are in the
35298 <filename>mail</filename> directory within the home directory.
35299 </para>
35300 <para>
35301 <emphasis role="bold">Note 1</emphasis>: While processing an Exim filter, a relative path such as
35302 <filename>folder23</filename> is turned into an absolute path if a home directory is known to
35303 the router. In particular, this is the case if <option>check_local_user</option> is set. If
35304 you want to prevent this happening at routing time, you can set
35305 <option>router_home_directory</option> empty. This forces the router to pass the relative
35306 path to the transport.
35307 </para>
35308 <para>
35309 <emphasis role="bold">Note 2</emphasis>: An absolute path in <varname>$address_file</varname> is not treated specially;
35310 the <option>file</option> or <option>directory</option> option is still used if it is set.
35311 </para>
35312 </section>
35313 <section>
35314 <title>Private options for appendfile</title>
35315 <para>
35316 <indexterm role="concept">
35317 <primary>options</primary>
35318 <secondary><command>appendfile</command> transport</secondary>
35319 </indexterm>
35320 </para>
35321 <para>
35322 <indexterm role="option">
35323 <primary>allow_fifo</primary>
35324 </indexterm>
35325 </para>
35326 <informaltable frame="all">
35327 <tgroup cols="4" colsep="0" rowsep="0">
35328 <colspec colwidth="8*" align="left"/>
35329 <colspec colwidth="5*" align="center"/>
35330 <colspec colwidth="5*" align="center"/>
35331 <colspec colwidth="6*" align="right"/>
35332 <tbody>
35333 <row>
35334 <entry><option>allow_fifo</option></entry>
35335 <entry>Use: <emphasis>appendfile</emphasis></entry>
35336 <entry>Type: <emphasis>boolean</emphasis></entry>
35337 <entry>Default: <emphasis>false</emphasis></entry>
35338 </row>
35339 </tbody>
35340 </tgroup>
35341 </informaltable>
35342 <para>
35343 <indexterm role="concept">
35344 <primary>fifo (named pipe)</primary>
35345 </indexterm>
35346 <indexterm role="concept">
35347 <primary>named pipe (fifo)</primary>
35348 </indexterm>
35349 <indexterm role="concept">
35350 <primary>pipe</primary>
35351 <secondary>named (fifo)</secondary>
35352 </indexterm>
35353 Setting this option permits delivery to named pipes (FIFOs) as well as to
35354 regular files. If no process is reading the named pipe at delivery time, the
35355 delivery is deferred.
35356 </para>
35357 <para>
35358 <indexterm role="option">
35359 <primary>allow_symlink</primary>
35360 </indexterm>
35361 </para>
35362 <informaltable frame="all">
35363 <tgroup cols="4" colsep="0" rowsep="0">
35364 <colspec colwidth="8*" align="left"/>
35365 <colspec colwidth="5*" align="center"/>
35366 <colspec colwidth="5*" align="center"/>
35367 <colspec colwidth="6*" align="right"/>
35368 <tbody>
35369 <row>
35370 <entry><option>allow_symlink</option></entry>
35371 <entry>Use: <emphasis>appendfile</emphasis></entry>
35372 <entry>Type: <emphasis>boolean</emphasis></entry>
35373 <entry>Default: <emphasis>false</emphasis></entry>
35374 </row>
35375 </tbody>
35376 </tgroup>
35377 </informaltable>
35378 <para>
35379 <indexterm role="concept">
35380 <primary>symbolic link</primary>
35381 <secondary>to mailbox</secondary>
35382 </indexterm>
35383 <indexterm role="concept">
35384 <primary>mailbox</primary>
35385 <secondary>symbolic link</secondary>
35386 </indexterm>
35387 By default, <command>appendfile</command> will not deliver if the path name for the file is
35388 that of a symbolic link. Setting this option relaxes that constraint, but there
35389 are security issues involved in the use of symbolic links. Be sure you know
35390 what you are doing if you set this. Details of exactly what this option affects
35391 are included in the discussion which follows this list of options.
35392 </para>
35393 <para>
35394 <indexterm role="option">
35395 <primary>batch_id</primary>
35396 </indexterm>
35397 </para>
35398 <informaltable frame="all">
35399 <tgroup cols="4" colsep="0" rowsep="0">
35400 <colspec colwidth="8*" align="left"/>
35401 <colspec colwidth="5*" align="center"/>
35402 <colspec colwidth="5*" align="center"/>
35403 <colspec colwidth="6*" align="right"/>
35404 <tbody>
35405 <row>
35406 <entry><option>batch_id</option></entry>
35407 <entry>Use: <emphasis>appendfile</emphasis></entry>
35408 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35409 <entry>Default: <emphasis>unset</emphasis></entry>
35410 </row>
35411 </tbody>
35412 </tgroup>
35413 </informaltable>
35414 <para>
35415 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
35416 However, batching is automatically disabled for <command>appendfile</command> deliveries that
35417 happen as a result of forwarding or aliasing or other redirection directly to a
35418 file.
35419 </para>
35420 <para>
35421 <indexterm role="option">
35422 <primary>batch_max</primary>
35423 </indexterm>
35424 </para>
35425 <informaltable frame="all">
35426 <tgroup cols="4" colsep="0" rowsep="0">
35427 <colspec colwidth="8*" align="left"/>
35428 <colspec colwidth="5*" align="center"/>
35429 <colspec colwidth="5*" align="center"/>
35430 <colspec colwidth="6*" align="right"/>
35431 <tbody>
35432 <row>
35433 <entry><option>batch_max</option></entry>
35434 <entry>Use: <emphasis>appendfile</emphasis></entry>
35435 <entry>Type: <emphasis>integer</emphasis></entry>
35436 <entry>Default: <emphasis>1</emphasis></entry>
35437 </row>
35438 </tbody>
35439 </tgroup>
35440 </informaltable>
35441 <para>
35442 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
35443 </para>
35444 <para>
35445 <indexterm role="option">
35446 <primary>check_group</primary>
35447 </indexterm>
35448 </para>
35449 <informaltable frame="all">
35450 <tgroup cols="4" colsep="0" rowsep="0">
35451 <colspec colwidth="8*" align="left"/>
35452 <colspec colwidth="5*" align="center"/>
35453 <colspec colwidth="5*" align="center"/>
35454 <colspec colwidth="6*" align="right"/>
35455 <tbody>
35456 <row>
35457 <entry><option>check_group</option></entry>
35458 <entry>Use: <emphasis>appendfile</emphasis></entry>
35459 <entry>Type: <emphasis>boolean</emphasis></entry>
35460 <entry>Default: <emphasis>false</emphasis></entry>
35461 </row>
35462 </tbody>
35463 </tgroup>
35464 </informaltable>
35465 <para>
35466 When this option is set, the group owner of the file defined by the <option>file</option>
35467 option is checked to see that it is the same as the group under which the
35468 delivery process is running. The default setting is false because the default
35469 file mode is 0600, which means that the group is irrelevant.
35470 </para>
35471 <para>
35472 <indexterm role="option">
35473 <primary>check_owner</primary>
35474 </indexterm>
35475 </para>
35476 <informaltable frame="all">
35477 <tgroup cols="4" colsep="0" rowsep="0">
35478 <colspec colwidth="8*" align="left"/>
35479 <colspec colwidth="5*" align="center"/>
35480 <colspec colwidth="5*" align="center"/>
35481 <colspec colwidth="6*" align="right"/>
35482 <tbody>
35483 <row>
35484 <entry><option>check_owner</option></entry>
35485 <entry>Use: <emphasis>appendfile</emphasis></entry>
35486 <entry>Type: <emphasis>boolean</emphasis></entry>
35487 <entry>Default: <emphasis>true</emphasis></entry>
35488 </row>
35489 </tbody>
35490 </tgroup>
35491 </informaltable>
35492 <para>
35493 When this option is set, the owner of the file defined by the <option>file</option> option
35494 is checked to ensure that it is the same as the user under which the delivery
35495 process is running.
35496 </para>
35497 <para>
35498 <indexterm role="option">
35499 <primary>check_string</primary>
35500 </indexterm>
35501 </para>
35502 <informaltable frame="all">
35503 <tgroup cols="4" colsep="0" rowsep="0">
35504 <colspec colwidth="8*" align="left"/>
35505 <colspec colwidth="5*" align="center"/>
35506 <colspec colwidth="5*" align="center"/>
35507 <colspec colwidth="6*" align="right"/>
35508 <tbody>
35509 <row>
35510 <entry><option>check_string</option></entry>
35511 <entry>Use: <emphasis>appendfile</emphasis></entry>
35512 <entry>Type: <emphasis>string</emphasis></entry>
35513 <entry>Default: <emphasis>see below</emphasis></entry>
35514 </row>
35515 </tbody>
35516 </tgroup>
35517 </informaltable>
35518 <para>
35519 <indexterm role="concept">
35520 <primary><quote>From</quote> line</primary>
35521 </indexterm>
35522 As <command>appendfile</command> writes the message, the start of each line is tested for
35523 matching <option>check_string</option>, and if it does, the initial matching characters are
35524 replaced by the contents of <option>escape_string</option>. The value of <option>check_string</option> is
35525 a literal string, not a regular expression, and the case of any letters it
35526 contains is significant.
35527 </para>
35528 <para>
35529 If <option>use_bsmtp</option> is set the values of <option>check_string</option> and <option>escape_string</option>
35530 are forced to <quote>.</quote> and <quote>..</quote> respectively, and any settings in the
35531 configuration are ignored. Otherwise, they default to <quote>From&nbsp;</quote> and
35532 <quote>&gt;From&nbsp;</quote> when the <option>file</option> option is set, and unset when any of the
35533 <option>directory</option>, <option>maildir</option>, or <option>mailstore</option> options are set.
35534 </para>
35535 <para>
35536 The default settings, along with <option>message_prefix</option> and <option>message_suffix</option>, are
35537 suitable for traditional <quote>BSD</quote> mailboxes, where a line beginning with
35538 <quote>From&nbsp;</quote> indicates the start of a new message. All four options need changing
35539 if another format is used. For example, to deliver to mailboxes in MMDF format:
35540 <indexterm role="concept">
35541 <primary>MMDF format mailbox</primary>
35542 </indexterm>
35543 <indexterm role="concept">
35544 <primary>mailbox</primary>
35545 <secondary>MMDF format</secondary>
35546 </indexterm>
35547 </para>
35548 <literallayout class="monospaced">
35549 check_string = "\1\1\1\1\n"
35550 escape_string = "\1\1\1\1 \n"
35551 message_prefix = "\1\1\1\1\n"
35552 message_suffix = "\1\1\1\1\n"
35553 </literallayout>
35554 <para>
35555 <indexterm role="option">
35556 <primary>create_directory</primary>
35557 </indexterm>
35558 </para>
35559 <informaltable frame="all">
35560 <tgroup cols="4" colsep="0" rowsep="0">
35561 <colspec colwidth="8*" align="left"/>
35562 <colspec colwidth="5*" align="center"/>
35563 <colspec colwidth="5*" align="center"/>
35564 <colspec colwidth="6*" align="right"/>
35565 <tbody>
35566 <row>
35567 <entry><option>create_directory</option></entry>
35568 <entry>Use: <emphasis>appendfile</emphasis></entry>
35569 <entry>Type: <emphasis>boolean</emphasis></entry>
35570 <entry>Default: <emphasis>true</emphasis></entry>
35571 </row>
35572 </tbody>
35573 </tgroup>
35574 </informaltable>
35575 <para>
35576 <indexterm role="concept">
35577 <primary>directory creation</primary>
35578 </indexterm>
35579 When this option is true, Exim attempts to create any missing superior
35580 directories for the file that it is about to write. A created directory&#x2019;s mode
35581 is given by the <option>directory_mode</option> option.
35582 </para>
35583 <para>
35584 The group ownership of a newly created directory is highly dependent on the
35585 operating system (and possibly the file system) that is being used. For
35586 example, in Solaris, if the parent directory has the setgid bit set, its group
35587 is propagated to the child; if not, the currently set group is used. However,
35588 in FreeBSD, the parent&#x2019;s group is always used.
35589 </para>
35590 <para>
35591 <indexterm role="option">
35592 <primary>create_file</primary>
35593 </indexterm>
35594 </para>
35595 <informaltable frame="all">
35596 <tgroup cols="4" colsep="0" rowsep="0">
35597 <colspec colwidth="8*" align="left"/>
35598 <colspec colwidth="5*" align="center"/>
35599 <colspec colwidth="5*" align="center"/>
35600 <colspec colwidth="6*" align="right"/>
35601 <tbody>
35602 <row>
35603 <entry><option>create_file</option></entry>
35604 <entry>Use: <emphasis>appendfile</emphasis></entry>
35605 <entry>Type: <emphasis>string</emphasis></entry>
35606 <entry>Default: <emphasis>anywhere</emphasis></entry>
35607 </row>
35608 </tbody>
35609 </tgroup>
35610 </informaltable>
35611 <para>
35612 This option constrains the location of files and directories that are created
35613 by this transport. It applies to files defined by the <option>file</option> option and
35614 directories defined by the <option>directory</option> option. In the case of maildir
35615 delivery, it applies to the top level directory, not the maildir directories
35616 beneath.
35617 </para>
35618 <para>
35619 The option must be set to one of the words <quote>anywhere</quote>, <quote>inhome</quote>, or
35620 <quote>belowhome</quote>. In the second and third cases, a home directory must have been
35621 set for the transport. This option is not useful when an explicit file name is
35622 given for normal mailbox deliveries. It is intended for the case when file
35623 names are generated from users&#x2019; <filename>.forward</filename> files. These are usually handled
35624 by an <command>appendfile</command> transport called <option>address_file</option>. See also
35625 <option>file_must_exist</option>.
35626 </para>
35627 <para>
35628 <indexterm role="option">
35629 <primary>directory</primary>
35630 </indexterm>
35631 </para>
35632 <informaltable frame="all">
35633 <tgroup cols="4" colsep="0" rowsep="0">
35634 <colspec colwidth="8*" align="left"/>
35635 <colspec colwidth="5*" align="center"/>
35636 <colspec colwidth="5*" align="center"/>
35637 <colspec colwidth="6*" align="right"/>
35638 <tbody>
35639 <row>
35640 <entry><option>directory</option></entry>
35641 <entry>Use: <emphasis>appendfile</emphasis></entry>
35642 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35643 <entry>Default: <emphasis>unset</emphasis></entry>
35644 </row>
35645 </tbody>
35646 </tgroup>
35647 </informaltable>
35648 <para>
35649 This option is mutually exclusive with the <option>file</option> option, but one of <option>file</option>
35650 or <option>directory</option> must be set, unless the delivery is the direct result of a
35651 redirection (see section <xref linkend="SECTfildiropt"/>).
35652 </para>
35653 <para>
35654 When <option>directory</option> is set, the string is expanded, and the message is delivered
35655 into a new file or files in or below the given directory, instead of being
35656 appended to a single mailbox file. A number of different formats are provided
35657 (see <option>maildir_format</option> and <option>mailstore_format</option>), and see section
35658 <xref linkend="SECTopdir"/> for further details of this form of delivery.
35659 </para>
35660 <para>
35661 <indexterm role="option">
35662 <primary>directory_file</primary>
35663 </indexterm>
35664 </para>
35665 <informaltable frame="all">
35666 <tgroup cols="4" colsep="0" rowsep="0">
35667 <colspec colwidth="8*" align="left"/>
35668 <colspec colwidth="5*" align="center"/>
35669 <colspec colwidth="5*" align="center"/>
35670 <colspec colwidth="6*" align="right"/>
35671 <tbody>
35672 <row>
35673 <entry><option>directory_file</option></entry>
35674 <entry>Use: <emphasis>appendfile</emphasis></entry>
35675 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35676 <entry>Default: <emphasis><literal>q${base62:$tod_epoch}-$inode</literal></emphasis></entry>
35677 </row>
35678 </tbody>
35679 </tgroup>
35680 </informaltable>
35681 <para>
35682 <indexterm role="concept">
35683 <primary>base62</primary>
35684 </indexterm>
35685 <indexterm role="concept">
35686 <primary><varname>$inode</varname></primary>
35687 </indexterm>
35688 When <option>directory</option> is set, but neither <option>maildir_format</option> nor
35689 <option>mailstore_format</option> is set, <command>appendfile</command> delivers each message into a file
35690 whose name is obtained by expanding this string. The default value generates a
35691 unique name from the current time, in base 62 form, and the inode of the file.
35692 The variable <varname>$inode</varname> is available only when expanding this option.
35693 </para>
35694 <para>
35695 <indexterm role="option">
35696 <primary>directory_mode</primary>
35697 </indexterm>
35698 </para>
35699 <informaltable frame="all">
35700 <tgroup cols="4" colsep="0" rowsep="0">
35701 <colspec colwidth="8*" align="left"/>
35702 <colspec colwidth="5*" align="center"/>
35703 <colspec colwidth="5*" align="center"/>
35704 <colspec colwidth="6*" align="right"/>
35705 <tbody>
35706 <row>
35707 <entry><option>directory_mode</option></entry>
35708 <entry>Use: <emphasis>appendfile</emphasis></entry>
35709 <entry>Type: <emphasis>octal integer</emphasis></entry>
35710 <entry>Default: <emphasis>0700</emphasis></entry>
35711 </row>
35712 </tbody>
35713 </tgroup>
35714 </informaltable>
35715 <para>
35716 If <command>appendfile</command> creates any directories as a result of the
35717 <option>create_directory</option> option, their mode is specified by this option.
35718 </para>
35719 <para>
35720 <indexterm role="option">
35721 <primary>escape_string</primary>
35722 </indexterm>
35723 </para>
35724 <informaltable frame="all">
35725 <tgroup cols="4" colsep="0" rowsep="0">
35726 <colspec colwidth="8*" align="left"/>
35727 <colspec colwidth="5*" align="center"/>
35728 <colspec colwidth="5*" align="center"/>
35729 <colspec colwidth="6*" align="right"/>
35730 <tbody>
35731 <row>
35732 <entry><option>escape_string</option></entry>
35733 <entry>Use: <emphasis>appendfile</emphasis></entry>
35734 <entry>Type: <emphasis>string</emphasis></entry>
35735 <entry>Default: <emphasis>see description</emphasis></entry>
35736 </row>
35737 </tbody>
35738 </tgroup>
35739 </informaltable>
35740 <para>
35741 See <option>check_string</option> above.
35742 </para>
35743 <para>
35744 <indexterm role="option">
35745 <primary>file</primary>
35746 </indexterm>
35747 </para>
35748 <informaltable frame="all">
35749 <tgroup cols="4" colsep="0" rowsep="0">
35750 <colspec colwidth="8*" align="left"/>
35751 <colspec colwidth="5*" align="center"/>
35752 <colspec colwidth="5*" align="center"/>
35753 <colspec colwidth="6*" align="right"/>
35754 <tbody>
35755 <row>
35756 <entry><option>file</option></entry>
35757 <entry>Use: <emphasis>appendfile</emphasis></entry>
35758 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35759 <entry>Default: <emphasis>unset</emphasis></entry>
35760 </row>
35761 </tbody>
35762 </tgroup>
35763 </informaltable>
35764 <para>
35765 This option is mutually exclusive with the <option>directory</option> option, but one of
35766 <option>file</option> or <option>directory</option> must be set, unless the delivery is the direct result
35767 of a redirection (see section <xref linkend="SECTfildiropt"/>). The <option>file</option> option
35768 specifies a single file, to which the message is appended. One or more of
35769 <option>use_fcntl_lock</option>, <option>use_flock_lock</option>, or <option>use_lockfile</option> must be set with
35770 <option>file</option>.
35771 </para>
35772 <para>
35773 <indexterm role="concept">
35774 <primary>NFS</primary>
35775 <secondary>lock file</secondary>
35776 </indexterm>
35777 <indexterm role="concept">
35778 <primary>locking files</primary>
35779 </indexterm>
35780 <indexterm role="concept">
35781 <primary>lock files</primary>
35782 </indexterm>
35783 If you are using more than one host to deliver over NFS into the same
35784 mailboxes, you should always use lock files.
35785 </para>
35786 <para>
35787 The string value is expanded for each delivery, and must yield an absolute
35788 path. The most common settings of this option are variations on one of these
35789 examples:
35790 </para>
35791 <literallayout class="monospaced">
35792 file = /var/spool/mail/$local_part
35793 file = /home/$local_part/inbox
35794 file = $home/inbox
35795 </literallayout>
35796 <para>
35797 <indexterm role="concept">
35798 <primary><quote>sticky</quote> bit</primary>
35799 </indexterm>
35800 In the first example, all deliveries are done into the same directory. If Exim
35801 is configured to use lock files (see <option>use_lockfile</option> below) it must be able to
35802 create a file in the directory, so the <quote>sticky</quote> bit must be turned on for
35803 deliveries to be possible, or alternatively the <option>group</option> option can be used to
35804 run the delivery under a group id which has write access to the directory.
35805 </para>
35806 <para>
35807 <indexterm role="option">
35808 <primary>file_format</primary>
35809 </indexterm>
35810 </para>
35811 <informaltable frame="all">
35812 <tgroup cols="4" colsep="0" rowsep="0">
35813 <colspec colwidth="8*" align="left"/>
35814 <colspec colwidth="5*" align="center"/>
35815 <colspec colwidth="5*" align="center"/>
35816 <colspec colwidth="6*" align="right"/>
35817 <tbody>
35818 <row>
35819 <entry><option>file_format</option></entry>
35820 <entry>Use: <emphasis>appendfile</emphasis></entry>
35821 <entry>Type: <emphasis>string</emphasis></entry>
35822 <entry>Default: <emphasis>unset</emphasis></entry>
35823 </row>
35824 </tbody>
35825 </tgroup>
35826 </informaltable>
35827 <para>
35828 <indexterm role="concept">
35829 <primary>file</primary>
35830 <secondary>mailbox; checking existing format</secondary>
35831 </indexterm>
35832 This option requests the transport to check the format of an existing file
35833 before adding to it. The check consists of matching a specific string at the
35834 start of the file. The value of the option consists of an even number of
35835 colon-separated strings. The first of each pair is the test string, and the
35836 second is the name of a transport. If the transport associated with a matched
35837 string is not the current transport, control is passed over to the other
35838 transport. For example, suppose the standard <command>local_delivery</command> transport has
35839 this added to it:
35840 </para>
35841 <literallayout class="monospaced">
35842 file_format = "From       : local_delivery :\
35843                \1\1\1\1\n : local_mmdf_delivery"
35844 </literallayout>
35845 <para>
35846 Mailboxes that begin with <quote>From</quote> are still handled by this transport, but if
35847 a mailbox begins with four binary ones followed by a newline, control is passed
35848 to a transport called <option>local_mmdf_delivery</option>, which presumably is configured
35849 to do the delivery in MMDF format. If a mailbox does not exist or is empty, it
35850 is assumed to match the current transport. If the start of a mailbox doesn&#x2019;t
35851 match any string, or if the transport named for a given string is not defined,
35852 delivery is deferred.
35853 </para>
35854 <para>
35855 <indexterm role="option">
35856 <primary>file_must_exist</primary>
35857 </indexterm>
35858 </para>
35859 <informaltable frame="all">
35860 <tgroup cols="4" colsep="0" rowsep="0">
35861 <colspec colwidth="8*" align="left"/>
35862 <colspec colwidth="5*" align="center"/>
35863 <colspec colwidth="5*" align="center"/>
35864 <colspec colwidth="6*" align="right"/>
35865 <tbody>
35866 <row>
35867 <entry><option>file_must_exist</option></entry>
35868 <entry>Use: <emphasis>appendfile</emphasis></entry>
35869 <entry>Type: <emphasis>boolean</emphasis></entry>
35870 <entry>Default: <emphasis>false</emphasis></entry>
35871 </row>
35872 </tbody>
35873 </tgroup>
35874 </informaltable>
35875 <para>
35876 If this option is true, the file specified by the <option>file</option> option must exist,
35877 and an error occurs if it does not. Otherwise, it is created if it does not
35878 exist.
35879 </para>
35880 <para>
35881 <indexterm role="option">
35882 <primary>lock_fcntl_timeout</primary>
35883 </indexterm>
35884 </para>
35885 <informaltable frame="all">
35886 <tgroup cols="4" colsep="0" rowsep="0">
35887 <colspec colwidth="8*" align="left"/>
35888 <colspec colwidth="5*" align="center"/>
35889 <colspec colwidth="5*" align="center"/>
35890 <colspec colwidth="6*" align="right"/>
35891 <tbody>
35892 <row>
35893 <entry><option>lock_fcntl_timeout</option></entry>
35894 <entry>Use: <emphasis>appendfile</emphasis></entry>
35895 <entry>Type: <emphasis>time</emphasis></entry>
35896 <entry>Default: <emphasis>0s</emphasis></entry>
35897 </row>
35898 </tbody>
35899 </tgroup>
35900 </informaltable>
35901 <para>
35902 <indexterm role="concept">
35903 <primary>timeout</primary>
35904 <secondary>mailbox locking</secondary>
35905 </indexterm>
35906 <indexterm role="concept">
35907 <primary>mailbox locking</primary>
35908 <secondary>blocking and non-blocking</secondary>
35909 </indexterm>
35910 <indexterm role="concept">
35911 <primary>locking files</primary>
35912 </indexterm>
35913 By default, the <command>appendfile</command> transport uses non-blocking calls to <function>fcntl()</function>
35914 when locking an open mailbox file. If the call fails, the delivery process
35915 sleeps for <option>lock_interval</option> and tries again, up to <option>lock_retries</option> times.
35916 Non-blocking calls are used so that the file is not kept open during the wait
35917 for the lock; the reason for this is to make it as safe as possible for
35918 deliveries over NFS in the case when processes might be accessing an NFS
35919 mailbox without using a lock file. This should not be done, but
35920 misunderstandings and hence misconfigurations are not unknown.
35921 </para>
35922 <para>
35923 On a busy system, however, the performance of a non-blocking lock approach is
35924 not as good as using a blocking lock with a timeout. In this case, the waiting
35925 is done inside the system call, and Exim&#x2019;s delivery process acquires the lock
35926 and can proceed as soon as the previous lock holder releases it.
35927 </para>
35928 <para>
35929 If <option>lock_fcntl_timeout</option> is set to a non-zero time, blocking locks, with that
35930 timeout, are used. There may still be some retrying: the maximum number of
35931 retries is
35932 </para>
35933 <literallayout class="monospaced">
35934 (lock_retries * lock_interval) / lock_fcntl_timeout
35935 </literallayout>
35936 <para>
35937 rounded up to the next whole number. In other words, the total time during
35938 which <command>appendfile</command> is trying to get a lock is roughly the same, unless
35939 <option>lock_fcntl_timeout</option> is set very large.
35940 </para>
35941 <para>
35942 You should consider setting this option if you are getting a lot of delayed
35943 local deliveries because of errors of the form
35944 </para>
35945 <literallayout class="monospaced">
35946 failed to lock mailbox /some/file (fcntl)
35947 </literallayout>
35948 <para>
35949 <indexterm role="option">
35950 <primary>lock_flock_timeout</primary>
35951 </indexterm>
35952 </para>
35953 <informaltable frame="all">
35954 <tgroup cols="4" colsep="0" rowsep="0">
35955 <colspec colwidth="8*" align="left"/>
35956 <colspec colwidth="5*" align="center"/>
35957 <colspec colwidth="5*" align="center"/>
35958 <colspec colwidth="6*" align="right"/>
35959 <tbody>
35960 <row>
35961 <entry><option>lock_flock_timeout</option></entry>
35962 <entry>Use: <emphasis>appendfile</emphasis></entry>
35963 <entry>Type: <emphasis>time</emphasis></entry>
35964 <entry>Default: <emphasis>0s</emphasis></entry>
35965 </row>
35966 </tbody>
35967 </tgroup>
35968 </informaltable>
35969 <para>
35970 This timeout applies to file locking when using <function>flock()</function> (see
35971 <option>use_flock</option>); the timeout operates in a similar manner to
35972 <option>lock_fcntl_timeout</option>.
35973 </para>
35974 <para>
35975 <indexterm role="option">
35976 <primary>lock_interval</primary>
35977 </indexterm>
35978 </para>
35979 <informaltable frame="all">
35980 <tgroup cols="4" colsep="0" rowsep="0">
35981 <colspec colwidth="8*" align="left"/>
35982 <colspec colwidth="5*" align="center"/>
35983 <colspec colwidth="5*" align="center"/>
35984 <colspec colwidth="6*" align="right"/>
35985 <tbody>
35986 <row>
35987 <entry><option>lock_interval</option></entry>
35988 <entry>Use: <emphasis>appendfile</emphasis></entry>
35989 <entry>Type: <emphasis>time</emphasis></entry>
35990 <entry>Default: <emphasis>3s</emphasis></entry>
35991 </row>
35992 </tbody>
35993 </tgroup>
35994 </informaltable>
35995 <para>
35996 This specifies the time to wait between attempts to lock the file. See below
35997 for details of locking.
35998 </para>
35999 <para>
36000 <indexterm role="option">
36001 <primary>lock_retries</primary>
36002 </indexterm>
36003 </para>
36004 <informaltable frame="all">
36005 <tgroup cols="4" colsep="0" rowsep="0">
36006 <colspec colwidth="8*" align="left"/>
36007 <colspec colwidth="5*" align="center"/>
36008 <colspec colwidth="5*" align="center"/>
36009 <colspec colwidth="6*" align="right"/>
36010 <tbody>
36011 <row>
36012 <entry><option>lock_retries</option></entry>
36013 <entry>Use: <emphasis>appendfile</emphasis></entry>
36014 <entry>Type: <emphasis>integer</emphasis></entry>
36015 <entry>Default: <emphasis>10</emphasis></entry>
36016 </row>
36017 </tbody>
36018 </tgroup>
36019 </informaltable>
36020 <para>
36021 This specifies the maximum number of attempts to lock the file. A value of zero
36022 is treated as 1. See below for details of locking.
36023 </para>
36024 <para>
36025 <indexterm role="option">
36026 <primary>lockfile_mode</primary>
36027 </indexterm>
36028 </para>
36029 <informaltable frame="all">
36030 <tgroup cols="4" colsep="0" rowsep="0">
36031 <colspec colwidth="8*" align="left"/>
36032 <colspec colwidth="5*" align="center"/>
36033 <colspec colwidth="5*" align="center"/>
36034 <colspec colwidth="6*" align="right"/>
36035 <tbody>
36036 <row>
36037 <entry><option>lockfile_mode</option></entry>
36038 <entry>Use: <emphasis>appendfile</emphasis></entry>
36039 <entry>Type: <emphasis>octal integer</emphasis></entry>
36040 <entry>Default: <emphasis>0600</emphasis></entry>
36041 </row>
36042 </tbody>
36043 </tgroup>
36044 </informaltable>
36045 <para>
36046 This specifies the mode of the created lock file, when a lock file is being
36047 used (see <option>use_lockfile</option>).
36048 </para>
36049 <para>
36050 <indexterm role="option">
36051 <primary>lockfile_timeout</primary>
36052 </indexterm>
36053 </para>
36054 <informaltable frame="all">
36055 <tgroup cols="4" colsep="0" rowsep="0">
36056 <colspec colwidth="8*" align="left"/>
36057 <colspec colwidth="5*" align="center"/>
36058 <colspec colwidth="5*" align="center"/>
36059 <colspec colwidth="6*" align="right"/>
36060 <tbody>
36061 <row>
36062 <entry><option>lockfile_timeout</option></entry>
36063 <entry>Use: <emphasis>appendfile</emphasis></entry>
36064 <entry>Type: <emphasis>time</emphasis></entry>
36065 <entry>Default: <emphasis>30m</emphasis></entry>
36066 </row>
36067 </tbody>
36068 </tgroup>
36069 </informaltable>
36070 <para>
36071 <indexterm role="concept">
36072 <primary>timeout</primary>
36073 <secondary>mailbox locking</secondary>
36074 </indexterm>
36075 When a lock file is being used (see <option>use_lockfile</option>), if a lock file already
36076 exists and is older than this value, it is assumed to have been left behind by
36077 accident, and Exim attempts to remove it.
36078 </para>
36079 <para>
36080 <indexterm role="option">
36081 <primary>mailbox_filecount</primary>
36082 </indexterm>
36083 </para>
36084 <informaltable frame="all">
36085 <tgroup cols="4" colsep="0" rowsep="0">
36086 <colspec colwidth="8*" align="left"/>
36087 <colspec colwidth="5*" align="center"/>
36088 <colspec colwidth="5*" align="center"/>
36089 <colspec colwidth="6*" align="right"/>
36090 <tbody>
36091 <row>
36092 <entry><option>mailbox_filecount</option></entry>
36093 <entry>Use: <emphasis>appendfile</emphasis></entry>
36094 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36095 <entry>Default: <emphasis>unset</emphasis></entry>
36096 </row>
36097 </tbody>
36098 </tgroup>
36099 </informaltable>
36100 <para>
36101 <indexterm role="concept">
36102 <primary>mailbox</primary>
36103 <secondary>specifying size of</secondary>
36104 </indexterm>
36105 <indexterm role="concept">
36106 <primary>size</primary>
36107 <secondary>of mailbox</secondary>
36108 </indexterm>
36109 If this option is set, it is expanded, and the result is taken as the current
36110 number of files in the mailbox. It must be a decimal number, optionally
36111 followed by K or M. This provides a way of obtaining this information from an
36112 external source that maintains the data.
36113 </para>
36114 <para>
36115 <indexterm role="option">
36116 <primary>mailbox_size</primary>
36117 </indexterm>
36118 </para>
36119 <informaltable frame="all">
36120 <tgroup cols="4" colsep="0" rowsep="0">
36121 <colspec colwidth="8*" align="left"/>
36122 <colspec colwidth="5*" align="center"/>
36123 <colspec colwidth="5*" align="center"/>
36124 <colspec colwidth="6*" align="right"/>
36125 <tbody>
36126 <row>
36127 <entry><option>mailbox_size</option></entry>
36128 <entry>Use: <emphasis>appendfile</emphasis></entry>
36129 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36130 <entry>Default: <emphasis>unset</emphasis></entry>
36131 </row>
36132 </tbody>
36133 </tgroup>
36134 </informaltable>
36135 <para>
36136 <indexterm role="concept">
36137 <primary>mailbox</primary>
36138 <secondary>specifying size of</secondary>
36139 </indexterm>
36140 <indexterm role="concept">
36141 <primary>size</primary>
36142 <secondary>of mailbox</secondary>
36143 </indexterm>
36144 If this option is set, it is expanded, and the result is taken as the current
36145 size the mailbox. It must be a decimal number, optionally followed by K or M.
36146 This provides a way of obtaining this information from an external source that
36147 maintains the data. This is likely to be helpful for maildir deliveries where
36148 it is computationally expensive to compute the size of a mailbox.
36149 </para>
36150 <para>
36151 <indexterm role="option">
36152 <primary>maildir_format</primary>
36153 </indexterm>
36154 </para>
36155 <informaltable frame="all">
36156 <tgroup cols="4" colsep="0" rowsep="0">
36157 <colspec colwidth="8*" align="left"/>
36158 <colspec colwidth="5*" align="center"/>
36159 <colspec colwidth="5*" align="center"/>
36160 <colspec colwidth="6*" align="right"/>
36161 <tbody>
36162 <row>
36163 <entry><option>maildir_format</option></entry>
36164 <entry>Use: <emphasis>appendfile</emphasis></entry>
36165 <entry>Type: <emphasis>boolean</emphasis></entry>
36166 <entry>Default: <emphasis>false</emphasis></entry>
36167 </row>
36168 </tbody>
36169 </tgroup>
36170 </informaltable>
36171 <para>
36172 <indexterm role="concept">
36173 <primary>maildir format</primary>
36174 <secondary>specifying</secondary>
36175 </indexterm>
36176 If this option is set with the <option>directory</option> option, the delivery is into a new
36177 file, in the <quote>maildir</quote> format that is used by other mail software. When the
36178 transport is activated directly from a <command>redirect</command> router (for example, the
36179 <command>address_file</command> transport in the default configuration), setting
36180 <option>maildir_format</option> causes the path received from the router to be treated as a
36181 directory, whether or not it ends with <literal>/</literal>. This option is available only if
36182 SUPPORT_MAILDIR is present in <filename>Local/Makefile</filename>. See section
36183 <xref linkend="SECTmaildirdelivery"/> below for further details.
36184 </para>
36185 <para>
36186 <indexterm role="option">
36187 <primary>maildir_quota_directory_regex</primary>
36188 </indexterm>
36189 </para>
36190 <informaltable frame="all">
36191 <tgroup cols="4" colsep="0" rowsep="0">
36192 <colspec colwidth="8*" align="left"/>
36193 <colspec colwidth="5*" align="center"/>
36194 <colspec colwidth="5*" align="center"/>
36195 <colspec colwidth="6*" align="right"/>
36196 <tbody>
36197 <row>
36198 <entry><option>maildir_quota_directory_regex</option></entry>
36199 <entry>Use: <emphasis>appendfile</emphasis></entry>
36200 <entry>Type: <emphasis>string</emphasis></entry>
36201 <entry>Default: <emphasis>See below</emphasis></entry>
36202 </row>
36203 </tbody>
36204 </tgroup>
36205 </informaltable>
36206 <para>
36207 <indexterm role="concept">
36208 <primary>maildir format</primary>
36209 <secondary>quota; directories included in</secondary>
36210 </indexterm>
36211 <indexterm role="concept">
36212 <primary>quota</primary>
36213 <secondary>maildir; directories included in</secondary>
36214 </indexterm>
36215 This option is relevant only when <option>maildir_use_size_file</option> is set. It defines
36216 a regular expression for specifying directories that should be included in the
36217 quota calculation. The default value is
36218 </para>
36219 <literallayout class="monospaced">
36220 maildir_quota_directory_regex = ^(?:cur|new|\..*)$
36221 </literallayout>
36222 <para>
36223 which includes the <filename>cur</filename> and <filename>new</filename> directories, and any maildir++ folders
36224 (directories whose names begin with a dot). If you want to exclude the
36225 <filename>Trash</filename>
36226 folder from the count (as some sites do), you need to change this setting to
36227 </para>
36228 <literallayout class="monospaced">
36229 maildir_quota_directory_regex = ^(?:cur|new|\.(?!Trash).*)$
36230 </literallayout>
36231 <para>
36232 This uses a negative lookahead in the regular expression to exclude the
36233 directory whose name is <filename>.Trash</filename>.
36234 </para>
36235 <para>
36236 <indexterm role="option">
36237 <primary>maildir_retries</primary>
36238 </indexterm>
36239 </para>
36240 <informaltable frame="all">
36241 <tgroup cols="4" colsep="0" rowsep="0">
36242 <colspec colwidth="8*" align="left"/>
36243 <colspec colwidth="5*" align="center"/>
36244 <colspec colwidth="5*" align="center"/>
36245 <colspec colwidth="6*" align="right"/>
36246 <tbody>
36247 <row>
36248 <entry><option>maildir_retries</option></entry>
36249 <entry>Use: <emphasis>appendfile</emphasis></entry>
36250 <entry>Type: <emphasis>integer</emphasis></entry>
36251 <entry>Default: <emphasis>10</emphasis></entry>
36252 </row>
36253 </tbody>
36254 </tgroup>
36255 </informaltable>
36256 <para>
36257 This option specifies the number of times to retry when writing a file in
36258 <quote>maildir</quote> format. See section <xref linkend="SECTmaildirdelivery"/> below.
36259 </para>
36260 <para>
36261 <indexterm role="option">
36262 <primary>maildir_tag</primary>
36263 </indexterm>
36264 </para>
36265 <informaltable frame="all">
36266 <tgroup cols="4" colsep="0" rowsep="0">
36267 <colspec colwidth="8*" align="left"/>
36268 <colspec colwidth="5*" align="center"/>
36269 <colspec colwidth="5*" align="center"/>
36270 <colspec colwidth="6*" align="right"/>
36271 <tbody>
36272 <row>
36273 <entry><option>maildir_tag</option></entry>
36274 <entry>Use: <emphasis>appendfile</emphasis></entry>
36275 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36276 <entry>Default: <emphasis>unset</emphasis></entry>
36277 </row>
36278 </tbody>
36279 </tgroup>
36280 </informaltable>
36281 <para>
36282 This option applies only to deliveries in maildir format, and is described in
36283 section <xref linkend="SECTmaildirdelivery"/> below.
36284 </para>
36285 <para>
36286 <indexterm role="option">
36287 <primary>maildir_use_size_file</primary>
36288 </indexterm>
36289 </para>
36290 <informaltable frame="all">
36291 <tgroup cols="4" colsep="0" rowsep="0">
36292 <colspec colwidth="8*" align="left"/>
36293 <colspec colwidth="5*" align="center"/>
36294 <colspec colwidth="5*" align="center"/>
36295 <colspec colwidth="6*" align="right"/>
36296 <tbody>
36297 <row>
36298 <entry><option>maildir_use_size_file</option></entry>
36299 <entry>Use: <emphasis>appendfile</emphasis></entry>
36300 <entry>Type: <emphasis>boolean</emphasis></entry>
36301 <entry>Default: <emphasis>false</emphasis></entry>
36302 </row>
36303 </tbody>
36304 </tgroup>
36305 </informaltable>
36306 <para>
36307 <indexterm role="concept">
36308 <primary>maildir format</primary>
36309 <secondary><filename>maildirsize</filename> file</secondary>
36310 </indexterm>
36311 Setting this option true enables support for <filename>maildirsize</filename> files. Exim
36312 creates a <filename>maildirsize</filename> file in a maildir if one does not exist, taking the
36313 quota from the <option>quota</option> option of the transport. If <option>quota</option> is unset, the
36314 value is zero. See section <xref linkend="SECTmaildirdelivery"/> below for further details.
36315 </para>
36316 <para>
36317 <indexterm role="option">
36318 <primary>mailstore_format</primary>
36319 </indexterm>
36320 </para>
36321 <informaltable frame="all">
36322 <tgroup cols="4" colsep="0" rowsep="0">
36323 <colspec colwidth="8*" align="left"/>
36324 <colspec colwidth="5*" align="center"/>
36325 <colspec colwidth="5*" align="center"/>
36326 <colspec colwidth="6*" align="right"/>
36327 <tbody>
36328 <row>
36329 <entry><option>mailstore_format</option></entry>
36330 <entry>Use: <emphasis>appendfile</emphasis></entry>
36331 <entry>Type: <emphasis>boolean</emphasis></entry>
36332 <entry>Default: <emphasis>false</emphasis></entry>
36333 </row>
36334 </tbody>
36335 </tgroup>
36336 </informaltable>
36337 <para>
36338 <indexterm role="concept">
36339 <primary>mailstore format</primary>
36340 <secondary>specifying</secondary>
36341 </indexterm>
36342 If this option is set with the <option>directory</option> option, the delivery is into two
36343 new files in  <quote>mailstore</quote> format. The option is available only if
36344 SUPPORT_MAILSTORE is present in <filename>Local/Makefile</filename>. See section <xref linkend="SECTopdir"/>
36345 below for further details.
36346 </para>
36347 <para>
36348 <indexterm role="option">
36349 <primary>mailstore_prefix</primary>
36350 </indexterm>
36351 </para>
36352 <informaltable frame="all">
36353 <tgroup cols="4" colsep="0" rowsep="0">
36354 <colspec colwidth="8*" align="left"/>
36355 <colspec colwidth="5*" align="center"/>
36356 <colspec colwidth="5*" align="center"/>
36357 <colspec colwidth="6*" align="right"/>
36358 <tbody>
36359 <row>
36360 <entry><option>mailstore_prefix</option></entry>
36361 <entry>Use: <emphasis>appendfile</emphasis></entry>
36362 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36363 <entry>Default: <emphasis>unset</emphasis></entry>
36364 </row>
36365 </tbody>
36366 </tgroup>
36367 </informaltable>
36368 <para>
36369 This option applies only to deliveries in mailstore format, and is described in
36370 section <xref linkend="SECTopdir"/> below.
36371 </para>
36372 <para>
36373 <indexterm role="option">
36374 <primary>mailstore_suffix</primary>
36375 </indexterm>
36376 </para>
36377 <informaltable frame="all">
36378 <tgroup cols="4" colsep="0" rowsep="0">
36379 <colspec colwidth="8*" align="left"/>
36380 <colspec colwidth="5*" align="center"/>
36381 <colspec colwidth="5*" align="center"/>
36382 <colspec colwidth="6*" align="right"/>
36383 <tbody>
36384 <row>
36385 <entry><option>mailstore_suffix</option></entry>
36386 <entry>Use: <emphasis>appendfile</emphasis></entry>
36387 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36388 <entry>Default: <emphasis>unset</emphasis></entry>
36389 </row>
36390 </tbody>
36391 </tgroup>
36392 </informaltable>
36393 <para>
36394 This option applies only to deliveries in mailstore format, and is described in
36395 section <xref linkend="SECTopdir"/> below.
36396 </para>
36397 <para>
36398 <indexterm role="option">
36399 <primary>mbx_format</primary>
36400 </indexterm>
36401 </para>
36402 <informaltable frame="all">
36403 <tgroup cols="4" colsep="0" rowsep="0">
36404 <colspec colwidth="8*" align="left"/>
36405 <colspec colwidth="5*" align="center"/>
36406 <colspec colwidth="5*" align="center"/>
36407 <colspec colwidth="6*" align="right"/>
36408 <tbody>
36409 <row>
36410 <entry><option>mbx_format</option></entry>
36411 <entry>Use: <emphasis>appendfile</emphasis></entry>
36412 <entry>Type: <emphasis>boolean</emphasis></entry>
36413 <entry>Default: <emphasis>false</emphasis></entry>
36414 </row>
36415 </tbody>
36416 </tgroup>
36417 </informaltable>
36418 <para>
36419 <indexterm role="concept">
36420 <primary>locking files</primary>
36421 </indexterm>
36422 <indexterm role="concept">
36423 <primary>file</primary>
36424 <secondary>locking</secondary>
36425 </indexterm>
36426 <indexterm role="concept">
36427 <primary>file</primary>
36428 <secondary>MBX format</secondary>
36429 </indexterm>
36430 <indexterm role="concept">
36431 <primary>MBX format</primary>
36432 <secondary>specifying</secondary>
36433 </indexterm>
36434 This option is available only if Exim has been compiled with SUPPORT_MBX
36435 set in <filename>Local/Makefile</filename>. If <option>mbx_format</option> is set with the <option>file</option> option,
36436 the message is appended to the mailbox file in MBX format instead of
36437 traditional Unix format. This format is supported by Pine4 and its associated
36438 IMAP and POP daemons, by means of the <emphasis>c-client</emphasis> library that they all use.
36439 </para>
36440 <para>
36441 <emphasis role="bold">Note</emphasis>: The <option>message_prefix</option> and <option>message_suffix</option> options are not
36442 automatically changed by the use of <option>mbx_format</option>. They should normally be set
36443 empty when using MBX format, so this option almost always appears in this
36444 combination:
36445 </para>
36446 <literallayout class="monospaced">
36447 mbx_format = true
36448 message_prefix =
36449 message_suffix =
36450 </literallayout>
36451 <para>
36452 If none of the locking options are mentioned in the configuration,
36453 <option>use_mbx_lock</option> is assumed and the other locking options default to false. It
36454 is possible to specify the other kinds of locking with <option>mbx_format</option>, but
36455 <option>use_fcntl_lock</option> and <option>use_mbx_lock</option> are mutually exclusive. MBX locking
36456 interworks with <emphasis>c-client</emphasis>, providing for shared access to the mailbox. It
36457 should not be used if any program that does not use this form of locking is
36458 going to access the mailbox, nor should it be used if the mailbox file is NFS
36459 mounted, because it works only when the mailbox is accessed from a single host.
36460 </para>
36461 <para>
36462 If you set <option>use_fcntl_lock</option> with an MBX-format mailbox, you cannot use
36463 the standard version of <emphasis>c-client</emphasis>, because as long as it has a mailbox open
36464 (this means for the whole of a Pine or IMAP session), Exim will not be able to
36465 append messages to it.
36466 </para>
36467 <para>
36468 <indexterm role="option">
36469 <primary>message_prefix</primary>
36470 </indexterm>
36471 </para>
36472 <informaltable frame="all">
36473 <tgroup cols="4" colsep="0" rowsep="0">
36474 <colspec colwidth="8*" align="left"/>
36475 <colspec colwidth="5*" align="center"/>
36476 <colspec colwidth="5*" align="center"/>
36477 <colspec colwidth="6*" align="right"/>
36478 <tbody>
36479 <row>
36480 <entry><option>message_prefix</option></entry>
36481 <entry>Use: <emphasis>appendfile</emphasis></entry>
36482 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36483 <entry>Default: <emphasis>see below</emphasis></entry>
36484 </row>
36485 </tbody>
36486 </tgroup>
36487 </informaltable>
36488 <para>
36489 <indexterm role="concept">
36490 <primary><quote>From</quote> line</primary>
36491 </indexterm>
36492 The string specified here is expanded and output at the start of every message.
36493 The default is unset unless <option>file</option> is specified and <option>use_bsmtp</option> is not set,
36494 in which case it is:
36495 </para>
36496 <literallayout class="monospaced">
36497 message_prefix = "From ${if def:return_path{$return_path}\
36498   {MAILER-DAEMON}} $tod_bsdinbox\n"
36499 </literallayout>
36500 <para>
36501 <indexterm role="option">
36502 <primary>message_suffix</primary>
36503 </indexterm>
36504 </para>
36505 <informaltable frame="all">
36506 <tgroup cols="4" colsep="0" rowsep="0">
36507 <colspec colwidth="8*" align="left"/>
36508 <colspec colwidth="5*" align="center"/>
36509 <colspec colwidth="5*" align="center"/>
36510 <colspec colwidth="6*" align="right"/>
36511 <tbody>
36512 <row>
36513 <entry><option>message_suffix</option></entry>
36514 <entry>Use: <emphasis>appendfile</emphasis></entry>
36515 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36516 <entry>Default: <emphasis>see below</emphasis></entry>
36517 </row>
36518 </tbody>
36519 </tgroup>
36520 </informaltable>
36521 <para>
36522 The string specified here is expanded and output at the end of every message.
36523 The default is unset unless <option>file</option> is specified and <option>use_bsmtp</option> is not set,
36524 in which case it is a single newline character. The suffix can be suppressed by
36525 setting
36526 </para>
36527 <literallayout class="monospaced">
36528 message_suffix =
36529 </literallayout>
36530 <para>
36531 <indexterm role="option">
36532 <primary>mode</primary>
36533 </indexterm>
36534 </para>
36535 <informaltable frame="all">
36536 <tgroup cols="4" colsep="0" rowsep="0">
36537 <colspec colwidth="8*" align="left"/>
36538 <colspec colwidth="5*" align="center"/>
36539 <colspec colwidth="5*" align="center"/>
36540 <colspec colwidth="6*" align="right"/>
36541 <tbody>
36542 <row>
36543 <entry><option>mode</option></entry>
36544 <entry>Use: <emphasis>appendfile</emphasis></entry>
36545 <entry>Type: <emphasis>octal integer</emphasis></entry>
36546 <entry>Default: <emphasis>0600</emphasis></entry>
36547 </row>
36548 </tbody>
36549 </tgroup>
36550 </informaltable>
36551 <para>
36552 If the output file is created, it is given this mode. If it already exists and
36553 has wider permissions, they are reduced to this mode. If it has narrower
36554 permissions, an error occurs unless <option>mode_fail_narrower</option> is false. However,
36555 if the delivery is the result of a <option>save</option> command in a filter file specifing
36556 a particular mode, the mode of the output file is always forced to take that
36557 value, and this option is ignored.
36558 </para>
36559 <para>
36560 <indexterm role="option">
36561 <primary>mode_fail_narrower</primary>
36562 </indexterm>
36563 </para>
36564 <informaltable frame="all">
36565 <tgroup cols="4" colsep="0" rowsep="0">
36566 <colspec colwidth="8*" align="left"/>
36567 <colspec colwidth="5*" align="center"/>
36568 <colspec colwidth="5*" align="center"/>
36569 <colspec colwidth="6*" align="right"/>
36570 <tbody>
36571 <row>
36572 <entry><option>mode_fail_narrower</option></entry>
36573 <entry>Use: <emphasis>appendfile</emphasis></entry>
36574 <entry>Type: <emphasis>boolean</emphasis></entry>
36575 <entry>Default: <emphasis>true</emphasis></entry>
36576 </row>
36577 </tbody>
36578 </tgroup>
36579 </informaltable>
36580 <para>
36581 This option applies in the case when an existing mailbox file has a narrower
36582 mode than that specified by the <option>mode</option> option. If <option>mode_fail_narrower</option> is
36583 true, the delivery is deferred (<quote>mailbox has the wrong mode</quote>); otherwise Exim
36584 continues with the delivery attempt, using the existing mode of the file.
36585 </para>
36586 <para>
36587 <indexterm role="option">
36588 <primary>notify_comsat</primary>
36589 </indexterm>
36590 </para>
36591 <informaltable frame="all">
36592 <tgroup cols="4" colsep="0" rowsep="0">
36593 <colspec colwidth="8*" align="left"/>
36594 <colspec colwidth="5*" align="center"/>
36595 <colspec colwidth="5*" align="center"/>
36596 <colspec colwidth="6*" align="right"/>
36597 <tbody>
36598 <row>
36599 <entry><option>notify_comsat</option></entry>
36600 <entry>Use: <emphasis>appendfile</emphasis></entry>
36601 <entry>Type: <emphasis>boolean</emphasis></entry>
36602 <entry>Default: <emphasis>false</emphasis></entry>
36603 </row>
36604 </tbody>
36605 </tgroup>
36606 </informaltable>
36607 <para>
36608 If this option is true, the <emphasis>comsat</emphasis> daemon is notified after every
36609 successful delivery to a user mailbox. This is the daemon that notifies logged
36610 on users about incoming mail.
36611 </para>
36612 <para>
36613 <indexterm role="option">
36614 <primary>quota</primary>
36615 </indexterm>
36616 </para>
36617 <informaltable frame="all">
36618 <tgroup cols="4" colsep="0" rowsep="0">
36619 <colspec colwidth="8*" align="left"/>
36620 <colspec colwidth="5*" align="center"/>
36621 <colspec colwidth="5*" align="center"/>
36622 <colspec colwidth="6*" align="right"/>
36623 <tbody>
36624 <row>
36625 <entry><option>quota</option></entry>
36626 <entry>Use: <emphasis>appendfile</emphasis></entry>
36627 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36628 <entry>Default: <emphasis>unset</emphasis></entry>
36629 </row>
36630 </tbody>
36631 </tgroup>
36632 </informaltable>
36633 <para>
36634 <indexterm role="concept">
36635 <primary>quota</primary>
36636 <secondary>imposed by Exim</secondary>
36637 </indexterm>
36638 This option imposes a limit on the size of the file to which Exim is appending,
36639 or to the total space used in the directory tree when the <option>directory</option> option
36640 is set. In the latter case, computation of the space used is expensive, because
36641 all the files in the directory (and any sub-directories) have to be
36642 individually inspected and their sizes summed. (See <option>quota_size_regex</option> and
36643 <option>maildir_use_size_file</option> for ways to avoid this in environments where users
36644 have no shell access to their mailboxes).
36645 </para>
36646 <para>
36647 As there is no interlock against two simultaneous deliveries into a
36648 multi-file mailbox, it is possible for the quota to be overrun in this case.
36649 For single-file mailboxes, of course, an interlock is a necessity.
36650 </para>
36651 <para>
36652 A file&#x2019;s size is taken as its <emphasis>used</emphasis> value. Because of blocking effects, this
36653 may be a lot less than the actual amount of disk space allocated to the file.
36654 If the sizes of a number of files are being added up, the rounding effect can
36655 become quite noticeable, especially on systems that have large block sizes.
36656 Nevertheless, it seems best to stick to the <emphasis>used</emphasis> figure, because this is
36657 the obvious value which users understand most easily.
36658 </para>
36659 <para>
36660 The value of the option is expanded, and must then be a numerical value
36661 (decimal point allowed), optionally followed by one of the letters K, M, or G,
36662 for kilobytes, megabytes, or gigabytes. If Exim is running on a system with
36663 large file support (Linux and FreeBSD have this), mailboxes larger than 2G can
36664 be handled.
36665 </para>
36666 <para>
36667 <emphasis role="bold">Note</emphasis>: A value of zero is interpreted as <quote>no quota</quote>.
36668 </para>
36669 <para>
36670 The expansion happens while Exim is running as root, before it changes uid for
36671 the delivery. This means that files that are inaccessible to the end user can
36672 be used to hold quota values that are looked up in the expansion. When delivery
36673 fails because this quota is exceeded, the handling of the error is as for
36674 system quota failures.
36675 </para>
36676 <para>
36677 By default, Exim&#x2019;s quota checking mimics system quotas, and restricts the
36678 mailbox to the specified maximum size, though the value is not accurate to the
36679 last byte, owing to separator lines and additional headers that may get added
36680 during message delivery. When a mailbox is nearly full, large messages may get
36681 refused even though small ones are accepted, because the size of the current
36682 message is added to the quota when the check is made. This behaviour can be
36683 changed by setting <option>quota_is_inclusive</option> false. When this is done, the check
36684 for exceeding the quota does not include the current message. Thus, deliveries
36685 continue until the quota has been exceeded; thereafter, no further messages are
36686 delivered. See also <option>quota_warn_threshold</option>.
36687 </para>
36688 <para>
36689 <indexterm role="option">
36690 <primary>quota_directory</primary>
36691 </indexterm>
36692 </para>
36693 <informaltable frame="all">
36694 <tgroup cols="4" colsep="0" rowsep="0">
36695 <colspec colwidth="8*" align="left"/>
36696 <colspec colwidth="5*" align="center"/>
36697 <colspec colwidth="5*" align="center"/>
36698 <colspec colwidth="6*" align="right"/>
36699 <tbody>
36700 <row>
36701 <entry><option>quota_directory</option></entry>
36702 <entry>Use: <emphasis>appendfile</emphasis></entry>
36703 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36704 <entry>Default: <emphasis>unset</emphasis></entry>
36705 </row>
36706 </tbody>
36707 </tgroup>
36708 </informaltable>
36709 <para>
36710 This option defines the directory to check for quota purposes when delivering
36711 into individual files. The default is the delivery directory, or, if a file
36712 called <filename>maildirfolder</filename> exists in a maildir directory, the parent of the
36713 delivery directory.
36714 </para>
36715 <para>
36716 <indexterm role="option">
36717 <primary>quota_filecount</primary>
36718 </indexterm>
36719 </para>
36720 <informaltable frame="all">
36721 <tgroup cols="4" colsep="0" rowsep="0">
36722 <colspec colwidth="8*" align="left"/>
36723 <colspec colwidth="5*" align="center"/>
36724 <colspec colwidth="5*" align="center"/>
36725 <colspec colwidth="6*" align="right"/>
36726 <tbody>
36727 <row>
36728 <entry><option>quota_filecount</option></entry>
36729 <entry>Use: <emphasis>appendfile</emphasis></entry>
36730 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36731 <entry>Default: <emphasis>0</emphasis></entry>
36732 </row>
36733 </tbody>
36734 </tgroup>
36735 </informaltable>
36736 <para revisionflag="changed">
36737 This option applies when the <option>directory</option> option is set. It limits the total
36738 number of files in the directory (compare the inode limit in system quotas). It
36739 can only be used if <option>quota</option> is also set. The value is expanded; an expansion
36740 failure causes delivery to be deferred. A value of zero is interpreted as
36741 <quote>no quota</quote>.
36742 </para>
36743 <para>
36744 <indexterm role="option">
36745 <primary>quota_is_inclusive</primary>
36746 </indexterm>
36747 </para>
36748 <informaltable frame="all">
36749 <tgroup cols="4" colsep="0" rowsep="0">
36750 <colspec colwidth="8*" align="left"/>
36751 <colspec colwidth="5*" align="center"/>
36752 <colspec colwidth="5*" align="center"/>
36753 <colspec colwidth="6*" align="right"/>
36754 <tbody>
36755 <row>
36756 <entry><option>quota_is_inclusive</option></entry>
36757 <entry>Use: <emphasis>appendfile</emphasis></entry>
36758 <entry>Type: <emphasis>boolean</emphasis></entry>
36759 <entry>Default: <emphasis>true</emphasis></entry>
36760 </row>
36761 </tbody>
36762 </tgroup>
36763 </informaltable>
36764 <para>
36765 See <option>quota</option> above.
36766 </para>
36767 <para>
36768 <indexterm role="option">
36769 <primary>quota_size_regex</primary>
36770 </indexterm>
36771 </para>
36772 <informaltable frame="all">
36773 <tgroup cols="4" colsep="0" rowsep="0">
36774 <colspec colwidth="8*" align="left"/>
36775 <colspec colwidth="5*" align="center"/>
36776 <colspec colwidth="5*" align="center"/>
36777 <colspec colwidth="6*" align="right"/>
36778 <tbody>
36779 <row>
36780 <entry><option>quota_size_regex</option></entry>
36781 <entry>Use: <emphasis>appendfile</emphasis></entry>
36782 <entry>Type: <emphasis>string</emphasis></entry>
36783 <entry>Default: <emphasis>unset</emphasis></entry>
36784 </row>
36785 </tbody>
36786 </tgroup>
36787 </informaltable>
36788 <para>
36789 This option applies when one of the delivery modes that writes a separate file
36790 for each message is being used. When Exim wants to find the size of one of
36791 these files in order to test the quota, it first checks <option>quota_size_regex</option>.
36792 If this is set to a regular expression that matches the file name, and it
36793 captures one string, that string is interpreted as a representation of the
36794 file&#x2019;s size. The value of <option>quota_size_regex</option> is not expanded.
36795 </para>
36796 <para>
36797 This feature is useful only when users have no shell access to their mailboxes
36798 &ndash; otherwise they could defeat the quota simply by renaming the files. This
36799 facility can be used with maildir deliveries, by setting <option>maildir_tag</option> to add
36800 the file length to the file name. For example:
36801 </para>
36802 <literallayout class="monospaced">
36803 maildir_tag = ,S=$message_size
36804 quota_size_regex = ,S=(\d+)
36805 </literallayout>
36806 <para>
36807 An alternative to <varname>$message_size</varname> is <varname>$message_linecount</varname>, which contains the
36808 number of lines in the message.
36809 </para>
36810 <para>
36811 The regular expression should not assume that the length is at the end of the
36812 file name (even though <option>maildir_tag</option> puts it there) because maildir MUAs
36813 sometimes add other information onto the ends of message file names.
36814 </para>
36815 <para>
36816 <indexterm role="option">
36817 <primary>quota_warn_message</primary>
36818 </indexterm>
36819 </para>
36820 <informaltable frame="all">
36821 <tgroup cols="4" colsep="0" rowsep="0">
36822 <colspec colwidth="8*" align="left"/>
36823 <colspec colwidth="5*" align="center"/>
36824 <colspec colwidth="5*" align="center"/>
36825 <colspec colwidth="6*" align="right"/>
36826 <tbody>
36827 <row>
36828 <entry><option>quota_warn_message</option></entry>
36829 <entry>Use: <emphasis>appendfile</emphasis></entry>
36830 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36831 <entry>Default: <emphasis>see below</emphasis></entry>
36832 </row>
36833 </tbody>
36834 </tgroup>
36835 </informaltable>
36836 <para>
36837 See below for the use of this option. If it is not set when
36838 <option>quota_warn_threshold</option> is set, it defaults to
36839 </para>
36840 <literallayout class="monospaced">
36841 quota_warn_message = "\
36842   To: $local_part@$domain\n\
36843   Subject: Your mailbox\n\n\
36844   This message is automatically created \
36845   by mail delivery software.\n\n\
36846   The size of your mailbox has exceeded \
36847   a warning threshold that is\n\
36848   set by the system administrator.\n"
36849 </literallayout>
36850 <para>
36851 <indexterm role="option">
36852 <primary>quota_warn_threshold</primary>
36853 </indexterm>
36854 </para>
36855 <informaltable frame="all">
36856 <tgroup cols="4" colsep="0" rowsep="0">
36857 <colspec colwidth="8*" align="left"/>
36858 <colspec colwidth="5*" align="center"/>
36859 <colspec colwidth="5*" align="center"/>
36860 <colspec colwidth="6*" align="right"/>
36861 <tbody>
36862 <row>
36863 <entry><option>quota_warn_threshold</option></entry>
36864 <entry>Use: <emphasis>appendfile</emphasis></entry>
36865 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36866 <entry>Default: <emphasis>0</emphasis></entry>
36867 </row>
36868 </tbody>
36869 </tgroup>
36870 </informaltable>
36871 <para>
36872 <indexterm role="concept">
36873 <primary>quota</primary>
36874 <secondary>warning threshold</secondary>
36875 </indexterm>
36876 <indexterm role="concept">
36877 <primary>mailbox</primary>
36878 <secondary>size warning</secondary>
36879 </indexterm>
36880 <indexterm role="concept">
36881 <primary>size</primary>
36882 <secondary>of mailbox</secondary>
36883 </indexterm>
36884 This option is expanded in the same way as <option>quota</option> (see above). If the
36885 resulting value is greater than zero, and delivery of the message causes the
36886 size of the file or total space in the directory tree to cross the given
36887 threshold, a warning message is sent. If <option>quota</option> is also set, the threshold
36888 may be specified as a percentage of it by following the value with a percent
36889 sign. For example:
36890 </para>
36891 <literallayout class="monospaced">
36892 quota = 10M
36893 quota_warn_threshold = 75%
36894 </literallayout>
36895 <para>
36896 If <option>quota</option> is not set, a setting of <option>quota_warn_threshold</option> that ends with a
36897 percent sign is ignored.
36898 </para>
36899 <para revisionflag="changed">
36900 The warning message itself is specified by the <option>quota_warn_message</option> option,
36901 and it must start with a <emphasis>To:</emphasis> header line containing the recipient(s) of the
36902 warning message. These do not necessarily have to include the recipient(s) of
36903 the original message. A <emphasis>Subject:</emphasis> line should also normally be supplied. You
36904 can include any other header lines that you want. If you do not include a
36905 <emphasis>From:</emphasis> line, the default is:
36906 </para>
36907 <literallayout class="monospaced" revisionflag="changed">
36908 From: Mail Delivery System &lt;mailer-daemon@$qualify_domain_sender&gt;
36909 </literallayout>
36910 <para revisionflag="changed">
36911 <indexterm role="option">
36912 <primary><option>errors_reply_to</option></primary>
36913 </indexterm>
36914 If you supply a <emphasis>Reply-To:</emphasis> line, it overrides the global <option>errors_reply_to</option>
36915 option.
36916 </para>
36917 <para>
36918 The <option>quota</option> option does not have to be set in order to use this option; they
36919 are independent of one another except when the threshold is specified as a
36920 percentage.
36921 </para>
36922 <para>
36923 <indexterm role="option">
36924 <primary>use_bsmtp</primary>
36925 </indexterm>
36926 </para>
36927 <informaltable frame="all">
36928 <tgroup cols="4" colsep="0" rowsep="0">
36929 <colspec colwidth="8*" align="left"/>
36930 <colspec colwidth="5*" align="center"/>
36931 <colspec colwidth="5*" align="center"/>
36932 <colspec colwidth="6*" align="right"/>
36933 <tbody>
36934 <row>
36935 <entry><option>use_bsmtp</option></entry>
36936 <entry>Use: <emphasis>appendfile</emphasis></entry>
36937 <entry>Type: <emphasis>boolean</emphasis></entry>
36938 <entry>Default: <emphasis>false</emphasis></entry>
36939 </row>
36940 </tbody>
36941 </tgroup>
36942 </informaltable>
36943 <para>
36944 <indexterm role="concept">
36945 <primary>envelope sender</primary>
36946 </indexterm>
36947 If this option is set true, <command>appendfile</command> writes messages in <quote>batch SMTP</quote>
36948 format, with the envelope sender and recipient(s) included as SMTP commands. If
36949 you want to include a leading HELO command with such messages, you can do
36950 so by setting the <option>message_prefix</option> option. See section <xref linkend="SECTbatchSMTP"/>
36951 for details of batch SMTP.
36952 </para>
36953 <para>
36954 <indexterm role="option">
36955 <primary>use_crlf</primary>
36956 </indexterm>
36957 </para>
36958 <informaltable frame="all">
36959 <tgroup cols="4" colsep="0" rowsep="0">
36960 <colspec colwidth="8*" align="left"/>
36961 <colspec colwidth="5*" align="center"/>
36962 <colspec colwidth="5*" align="center"/>
36963 <colspec colwidth="6*" align="right"/>
36964 <tbody>
36965 <row>
36966 <entry><option>use_crlf</option></entry>
36967 <entry>Use: <emphasis>appendfile</emphasis></entry>
36968 <entry>Type: <emphasis>boolean</emphasis></entry>
36969 <entry>Default: <emphasis>false</emphasis></entry>
36970 </row>
36971 </tbody>
36972 </tgroup>
36973 </informaltable>
36974 <para>
36975 <indexterm role="concept">
36976 <primary>carriage return</primary>
36977 </indexterm>
36978 <indexterm role="concept">
36979 <primary>linefeed</primary>
36980 </indexterm>
36981 This option causes lines to be terminated with the two-character CRLF sequence
36982 (carriage return, linefeed) instead of just a linefeed character. In the case
36983 of batched SMTP, the byte sequence written to the file is then an exact image
36984 of what would be sent down a real SMTP connection.
36985 </para>
36986 <para>
36987 The contents of the <option>message_prefix</option> and <option>message_suffix</option> options are
36988 written verbatim, so must contain their own carriage return characters if these
36989 are needed. In cases where these options have non-empty defaults, the values
36990 end with a single linefeed, so they must be changed to end with <literal>\r\n</literal> if
36991 <option>use_crlf</option> is set.
36992 </para>
36993 <para>
36994 <indexterm role="option">
36995 <primary>use_fcntl_lock</primary>
36996 </indexterm>
36997 </para>
36998 <informaltable frame="all">
36999 <tgroup cols="4" colsep="0" rowsep="0">
37000 <colspec colwidth="8*" align="left"/>
37001 <colspec colwidth="5*" align="center"/>
37002 <colspec colwidth="5*" align="center"/>
37003 <colspec colwidth="6*" align="right"/>
37004 <tbody>
37005 <row>
37006 <entry><option>use_fcntl_lock</option></entry>
37007 <entry>Use: <emphasis>appendfile</emphasis></entry>
37008 <entry>Type: <emphasis>boolean</emphasis></entry>
37009 <entry>Default: <emphasis>see below</emphasis></entry>
37010 </row>
37011 </tbody>
37012 </tgroup>
37013 </informaltable>
37014 <para>
37015 This option controls the use of the <function>fcntl()</function> function to lock a file for
37016 exclusive use when a message is being appended. It is set by default unless
37017 <option>use_flock_lock</option> is set. Otherwise, it should be turned off only if you know
37018 that all your MUAs use lock file locking. When both <option>use_fcntl_lock</option> and
37019 <option>use_flock_lock</option> are unset, <option>use_lockfile</option> must be set.
37020 </para>
37021 <para>
37022 <indexterm role="option">
37023 <primary>use_flock_lock</primary>
37024 </indexterm>
37025 </para>
37026 <informaltable frame="all">
37027 <tgroup cols="4" colsep="0" rowsep="0">
37028 <colspec colwidth="8*" align="left"/>
37029 <colspec colwidth="5*" align="center"/>
37030 <colspec colwidth="5*" align="center"/>
37031 <colspec colwidth="6*" align="right"/>
37032 <tbody>
37033 <row>
37034 <entry><option>use_flock_lock</option></entry>
37035 <entry>Use: <emphasis>appendfile</emphasis></entry>
37036 <entry>Type: <emphasis>boolean</emphasis></entry>
37037 <entry>Default: <emphasis>false</emphasis></entry>
37038 </row>
37039 </tbody>
37040 </tgroup>
37041 </informaltable>
37042 <para>
37043 This option is provided to support the use of <function>flock()</function> for file locking, for
37044 the few situations where it is needed. Most modern operating systems support
37045 <function>fcntl()</function> and <function>lockf()</function> locking, and these two functions interwork with
37046 each other. Exim uses <function>fcntl()</function> locking by default.
37047 </para>
37048 <para>
37049 This option is required only if you are using an operating system where
37050 <function>flock()</function> is used by programs that access mailboxes (typically MUAs), and
37051 where <function>flock()</function> does not correctly interwork with <function>fcntl()</function>. You can use
37052 both <function>fcntl()</function> and <function>flock()</function> locking simultaneously if you want.
37053 </para>
37054 <para>
37055 <indexterm role="concept">
37056 <primary>Solaris</primary>
37057 <secondary><function>flock()</function> support</secondary>
37058 </indexterm>
37059 Not all operating systems provide <function>flock()</function>. Some versions of Solaris do not
37060 have it (and some, I think, provide a not quite right version built on top of
37061 <function>lockf()</function>). If the OS does not have <function>flock()</function>, Exim will be built without
37062 the ability to use it, and any attempt to do so will cause a configuration
37063 error.
37064 </para>
37065 <para>
37066 <emphasis role="bold">Warning</emphasis>: <function>flock()</function> locks do not work on NFS files (unless <function>flock()</function>
37067 is just being mapped onto <function>fcntl()</function> by the OS).
37068 </para>
37069 <para>
37070 <indexterm role="option">
37071 <primary>use_lockfile</primary>
37072 </indexterm>
37073 </para>
37074 <informaltable frame="all">
37075 <tgroup cols="4" colsep="0" rowsep="0">
37076 <colspec colwidth="8*" align="left"/>
37077 <colspec colwidth="5*" align="center"/>
37078 <colspec colwidth="5*" align="center"/>
37079 <colspec colwidth="6*" align="right"/>
37080 <tbody>
37081 <row>
37082 <entry><option>use_lockfile</option></entry>
37083 <entry>Use: <emphasis>appendfile</emphasis></entry>
37084 <entry>Type: <emphasis>boolean</emphasis></entry>
37085 <entry>Default: <emphasis>see below</emphasis></entry>
37086 </row>
37087 </tbody>
37088 </tgroup>
37089 </informaltable>
37090 <para>
37091 If this option is turned off, Exim does not attempt to create a lock file when
37092 appending to a mailbox file. In this situation, the only locking is by
37093 <function>fcntl()</function>. You should only turn <option>use_lockfile</option> off if you are absolutely
37094 sure that every MUA that is ever going to look at your users&#x2019; mailboxes uses
37095 <function>fcntl()</function> rather than a lock file, and even then only when you are not
37096 delivering over NFS from more than one host.
37097 </para>
37098 <para>
37099 <indexterm role="concept">
37100 <primary>NFS</primary>
37101 <secondary>lock file</secondary>
37102 </indexterm>
37103 In order to append to an NFS file safely from more than one host, it is
37104 necessary to take out a lock <emphasis>before</emphasis> opening the file, and the lock file
37105 achieves this. Otherwise, even with <function>fcntl()</function> locking, there is a risk of
37106 file corruption.
37107 </para>
37108 <para>
37109 The <option>use_lockfile</option> option is set by default unless <option>use_mbx_lock</option> is set.
37110 It is not possible to turn both <option>use_lockfile</option> and <option>use_fcntl_lock</option> off,
37111 except when <option>mbx_format</option> is set.
37112 </para>
37113 <para>
37114 <indexterm role="option">
37115 <primary>use_mbx_lock</primary>
37116 </indexterm>
37117 </para>
37118 <informaltable frame="all">
37119 <tgroup cols="4" colsep="0" rowsep="0">
37120 <colspec colwidth="8*" align="left"/>
37121 <colspec colwidth="5*" align="center"/>
37122 <colspec colwidth="5*" align="center"/>
37123 <colspec colwidth="6*" align="right"/>
37124 <tbody>
37125 <row>
37126 <entry><option>use_mbx_lock</option></entry>
37127 <entry>Use: <emphasis>appendfile</emphasis></entry>
37128 <entry>Type: <emphasis>boolean</emphasis></entry>
37129 <entry>Default: <emphasis>see below</emphasis></entry>
37130 </row>
37131 </tbody>
37132 </tgroup>
37133 </informaltable>
37134 <para>
37135 This option is available only if Exim has been compiled with SUPPORT_MBX
37136 set in <filename>Local/Makefile</filename>. Setting the option specifies that special MBX
37137 locking rules be used. It is set by default if <option>mbx_format</option> is set and none
37138 of the locking options are mentioned in the configuration. The locking rules
37139 are the same as are used by the <emphasis>c-client</emphasis> library that underlies Pine and
37140 the IMAP4 and POP daemons that come with it (see the discussion below). The
37141 rules allow for shared access to the mailbox. However, this kind of locking
37142 does not work when the mailbox is NFS mounted.
37143 </para>
37144 <para>
37145 You can set <option>use_mbx_lock</option> with either (or both) of <option>use_fcntl_lock</option> and
37146 <option>use_flock_lock</option> to control what kind of locking is used in implementing the
37147 MBX locking rules. The default is to use <function>fcntl()</function> if <option>use_mbx_lock</option> is set
37148 without <option>use_fcntl_lock</option> or <option>use_flock_lock</option>.
37149 </para>
37150 </section>
37151 <section id="SECTopappend">
37152 <title>Operational details for appending</title>
37153 <para>
37154 <indexterm role="concept">
37155 <primary>appending to a file</primary>
37156 </indexterm>
37157 <indexterm role="concept">
37158 <primary>file</primary>
37159 <secondary>appending</secondary>
37160 </indexterm>
37161 Before appending to a file, the following preparations are made:
37162 </para>
37163 <itemizedlist>
37164 <listitem>
37165 <para>
37166 If the name of the file is <filename>/dev/null</filename>, no action is taken, and a success
37167 return is given.
37168 </para>
37169 </listitem>
37170 <listitem>
37171 <para>
37172 <indexterm role="concept">
37173 <primary>directory creation</primary>
37174 </indexterm>
37175 If any directories on the file&#x2019;s path are missing, Exim creates them if the
37176 <option>create_directory</option> option is set. A created directory&#x2019;s mode is given by the
37177 <option>directory_mode</option> option.
37178 </para>
37179 </listitem>
37180 <listitem>
37181 <para>
37182 If <option>file_format</option> is set, the format of an existing file is checked. If this
37183 indicates that a different transport should be used, control is passed to that
37184 transport.
37185 </para>
37186 </listitem>
37187 <listitem>
37188 <para>
37189 <indexterm role="concept">
37190 <primary>file</primary>
37191 <secondary>locking</secondary>
37192 </indexterm>
37193 <indexterm role="concept">
37194 <primary>locking files</primary>
37195 </indexterm>
37196 <indexterm role="concept">
37197 <primary>NFS</primary>
37198 <secondary>lock file</secondary>
37199 </indexterm>
37200 If <option>use_lockfile</option> is set, a lock file is built in a way that will work
37201 reliably over NFS, as follows:
37202 </para>
37203 <orderedlist numeration="arabic">
37204 <listitem>
37205 <para>
37206 Create a <quote>hitching post</quote> file whose name is that of the lock file with the
37207 current time, primary host name, and process id added, by opening for writing
37208 as a new file. If this fails with an access error, delivery is deferred.
37209 </para>
37210 </listitem>
37211 <listitem>
37212 <para>
37213 Close the hitching post file, and hard link it to the lock file name.
37214 </para>
37215 </listitem>
37216 <listitem>
37217 <para>
37218 If the call to <function>link()</function> succeeds, creation of the lock file has succeeded.
37219 Unlink the hitching post name.
37220 </para>
37221 </listitem>
37222 <listitem>
37223 <para>
37224 Otherwise, use <function>stat()</function> to get information about the hitching post file, and
37225 then unlink hitching post name. If the number of links is exactly two, creation
37226 of the lock file succeeded but something (for example, an NFS server crash and
37227 restart) caused this fact not to be communicated to the <function>link()</function> call.
37228 </para>
37229 </listitem>
37230 <listitem>
37231 <para>
37232 If creation of the lock file failed, wait for <option>lock_interval</option> and try again,
37233 up to <option>lock_retries</option> times. However, since any program that writes to a
37234 mailbox should complete its task very quickly, it is reasonable to time out old
37235 lock files that are normally the result of user agent and system crashes. If an
37236 existing lock file is older than <option>lockfile_timeout</option> Exim attempts to unlink
37237 it before trying again.
37238 </para>
37239 </listitem>
37240 </orderedlist>
37241 </listitem>
37242 <listitem>
37243 <para>
37244 A call is made to <function>lstat()</function> to discover whether the main file exists, and if
37245 so, what its characteristics are. If <function>lstat()</function> fails for any reason other
37246 than non-existence, delivery is deferred.
37247 </para>
37248 </listitem>
37249 <listitem>
37250 <para>
37251 <indexterm role="concept">
37252 <primary>symbolic link</primary>
37253 <secondary>to mailbox</secondary>
37254 </indexterm>
37255 <indexterm role="concept">
37256 <primary>mailbox</primary>
37257 <secondary>symbolic link</secondary>
37258 </indexterm>
37259 If the file does exist and is a symbolic link, delivery is deferred, unless the
37260 <option>allow_symlink</option> option is set, in which case the ownership of the link is
37261 checked, and then <function>stat()</function> is called to find out about the real file, which
37262 is then subjected to the checks below. The check on the top-level link
37263 ownership prevents one user creating a link for another&#x2019;s mailbox in a sticky
37264 directory, though allowing symbolic links in this case is definitely not a good
37265 idea. If there is a chain of symbolic links, the intermediate ones are not
37266 checked.
37267 </para>
37268 </listitem>
37269 <listitem>
37270 <para>
37271 If the file already exists but is not a regular file, or if the file&#x2019;s owner
37272 and group (if the group is being checked &ndash; see <option>check_group</option> above) are
37273 different from the user and group under which the delivery is running,
37274 delivery is deferred.
37275 </para>
37276 </listitem>
37277 <listitem>
37278 <para>
37279 If the file&#x2019;s permissions are more generous than specified, they are reduced.
37280 If they are insufficient, delivery is deferred, unless <option>mode_fail_narrower</option>
37281 is set false, in which case the delivery is tried using the existing
37282 permissions.
37283 </para>
37284 </listitem>
37285 <listitem>
37286 <para>
37287 The file&#x2019;s inode number is saved, and the file is then opened for appending.
37288 If this fails because the file has vanished, <command>appendfile</command> behaves as if it
37289 hadn&#x2019;t existed (see below). For any other failures, delivery is deferred.
37290 </para>
37291 </listitem>
37292 <listitem>
37293 <para>
37294 If the file is opened successfully, check that the inode number hasn&#x2019;t
37295 changed, that it is still a regular file, and that the owner and permissions
37296 have not changed. If anything is wrong, defer delivery and freeze the message.
37297 </para>
37298 </listitem>
37299 <listitem>
37300 <para>
37301 If the file did not exist originally, defer delivery if the <option>file_must_exist</option>
37302 option is set. Otherwise, check that the file is being created in a permitted
37303 directory if the <option>create_file</option> option is set (deferring on failure), and then
37304 open for writing as a new file, with the O_EXCL and O_CREAT options,
37305 except when dealing with a symbolic link (the <option>allow_symlink</option> option must be
37306 set). In this case, which can happen if the link points to a non-existent file,
37307 the file is opened for writing using O_CREAT but not O_EXCL, because
37308 that prevents link following.
37309 </para>
37310 </listitem>
37311 <listitem>
37312 <para>
37313 <indexterm role="concept">
37314 <primary>loop</primary>
37315 <secondary>while file testing</secondary>
37316 </indexterm>
37317 If opening fails because the file exists, obey the tests given above for
37318 existing files. However, to avoid looping in a situation where the file is
37319 being continuously created and destroyed, the exists/not-exists loop is broken
37320 after 10 repetitions, and the message is then frozen.
37321 </para>
37322 </listitem>
37323 <listitem>
37324 <para>
37325 If opening fails with any other error, defer delivery.
37326 </para>
37327 </listitem>
37328 <listitem>
37329 <para>
37330 <indexterm role="concept">
37331 <primary>file</primary>
37332 <secondary>locking</secondary>
37333 </indexterm>
37334 <indexterm role="concept">
37335 <primary>locking files</primary>
37336 </indexterm>
37337 Once the file is open, unless both <option>use_fcntl_lock</option> and <option>use_flock_lock</option>
37338 are false, it is locked using <function>fcntl()</function> or <function>flock()</function> or both. If
37339 <option>use_mbx_lock</option> is false, an exclusive lock is requested in each case.
37340 However, if <option>use_mbx_lock</option> is true, Exim takes out a shared lock on the open
37341 file, and an exclusive lock on the file whose name is
37342 </para>
37343 <literallayout class="monospaced">
37344 /tmp/.&lt;device-number&gt;.&lt;inode-number&gt;
37345 </literallayout>
37346 <para>
37347 using the device and inode numbers of the open mailbox file, in accordance with
37348 the MBX locking rules.
37349 </para>
37350 <para>
37351 If Exim fails to lock the file, there are two possible courses of action,
37352 depending on the value of the locking timeout. This is obtained from
37353 <option>lock_fcntl_timeout</option> or <option>lock_flock_timeout</option>, as appropriate.
37354 </para>
37355 <para>
37356 If the timeout value is zero, the file is closed, Exim waits for
37357 <option>lock_interval</option>, and then goes back and re-opens the file as above and tries
37358 to lock it again. This happens up to <option>lock_retries</option> times, after which the
37359 delivery is deferred.
37360 </para>
37361 <para>
37362 If the timeout has a value greater than zero, blocking calls to <function>fcntl()</function> or
37363 <function>flock()</function> are used (with the given timeout), so there has already been some
37364 waiting involved by the time locking fails. Nevertheless, Exim does not give up
37365 immediately. It retries up to
37366 </para>
37367 <literallayout class="monospaced">
37368 (lock_retries * lock_interval) / &lt;timeout&gt;
37369 </literallayout>
37370 <para>
37371 times (rounded up).
37372 </para>
37373 </listitem>
37374 </itemizedlist>
37375 <para>
37376 At the end of delivery, Exim closes the file (which releases the <function>fcntl()</function>
37377 and/or <function>flock()</function> locks) and then deletes the lock file if one was created.
37378 </para>
37379 </section>
37380 <section id="SECTopdir">
37381 <title>Operational details for delivery to a new file</title>
37382 <para>
37383 <indexterm role="concept">
37384 <primary>delivery</primary>
37385 <secondary>to single file</secondary>
37386 </indexterm>
37387 <indexterm role="concept">
37388 <primary><quote>From</quote> line</primary>
37389 </indexterm>
37390 When the <option>directory</option> option is set instead of <option>file</option>, each message is
37391 delivered into a newly-created file or set of files. When <command>appendfile</command> is
37392 activated directly from a <command>redirect</command> router, neither <option>file</option> nor
37393 <option>directory</option> is normally set, because the path for delivery is supplied by the
37394 router. (See for example, the <command>address_file</command> transport in the default
37395 configuration.) In this case, delivery is to a new file if either the path name
37396 ends in <literal>/</literal>, or the <option>maildir_format</option> or <option>mailstore_format</option> option is set.
37397 </para>
37398 <para>
37399 No locking is required while writing the message to a new file, so the various
37400 locking options of the transport are ignored. The <quote>From</quote> line that by default
37401 separates messages in a single file is not normally needed, nor is the escaping
37402 of message lines that start with <quote>From</quote>, and there is no need to ensure a
37403 newline at the end of each message. Consequently, the default values for
37404 <option>check_string</option>, <option>message_prefix</option>, and <option>message_suffix</option> are all unset when
37405 any of <option>directory</option>, <option>maildir_format</option>, or <option>mailstore_format</option> is set.
37406 </para>
37407 <para>
37408 If Exim is required to check a <option>quota</option> setting, it adds up the sizes of all
37409 the files in the delivery directory by default. However, you can specify a
37410 different directory by setting <option>quota_directory</option>. Also, for maildir
37411 deliveries (see below) the <filename>maildirfolder</filename> convention is honoured.
37412 </para>
37413 <para>
37414 <indexterm role="concept">
37415 <primary>maildir format</primary>
37416 </indexterm>
37417 <indexterm role="concept">
37418 <primary>mailstore format</primary>
37419 </indexterm>
37420 There are three different ways in which delivery to individual files can be
37421 done, controlled by the settings of the <option>maildir_format</option> and
37422 <option>mailstore_format</option> options. Note that code to support maildir or mailstore
37423 formats is not included in the binary unless SUPPORT_MAILDIR or
37424 SUPPORT_MAILSTORE, respectively, is set in <filename>Local/Makefile</filename>.
37425 </para>
37426 <para>
37427 <indexterm role="concept">
37428 <primary>directory creation</primary>
37429 </indexterm>
37430 In all three cases an attempt is made to create the directory and any necessary
37431 sub-directories if they do not exist, provided that the <option>create_directory</option>
37432 option is set (the default). The location of a created directory can be
37433 constrained by setting <option>create_file</option>. A created directory&#x2019;s mode is given by
37434 the <option>directory_mode</option> option. If creation fails, or if the
37435 <option>create_directory</option> option is not set when creation is required, delivery is
37436 deferred.
37437 </para>
37438 </section>
37439 <section id="SECTmaildirdelivery">
37440 <title>Maildir delivery</title>
37441 <para>
37442 <indexterm role="concept">
37443 <primary>maildir format</primary>
37444 <secondary>description of</secondary>
37445 </indexterm>
37446 If the <option>maildir_format</option> option is true, Exim delivers each message by writing
37447 it to a file whose name is <filename>tmp/&lt;stime&gt;.H&lt;mtime&gt;P&lt;pid&gt;.&lt;host&gt;</filename> in the
37448 given directory. If the delivery is successful, the file is renamed into the
37449 <filename>new</filename> subdirectory.
37450 </para>
37451 <para>
37452 In the file name, &lt;<emphasis>stime</emphasis>&gt; is the current time of day in seconds, and
37453 &lt;<emphasis>mtime</emphasis>&gt; is the microsecond fraction of the time. After a maildir delivery,
37454 Exim checks that the time-of-day clock has moved on by at least one microsecond
37455 before terminating the delivery process. This guarantees uniqueness for the
37456 file name. However, as a precaution, Exim calls <function>stat()</function> for the file before
37457 opening it. If any response other than ENOENT (does not exist) is given,
37458 Exim waits 2 seconds and tries again, up to <option>maildir_retries</option> times.
37459 </para>
37460 <para>
37461 <indexterm role="concept">
37462 <primary>quota</primary>
37463 <secondary>in maildir delivery</secondary>
37464 </indexterm>
37465 <indexterm role="concept">
37466 <primary>maildir++</primary>
37467 </indexterm>
37468 If Exim is required to check a <option>quota</option> setting before a maildir delivery, and
37469 <option>quota_directory</option> is not set, it looks for a file called <filename>maildirfolder</filename> in
37470 the maildir directory (alongside <filename>new</filename>, <filename>cur</filename>, <filename>tmp</filename>). If this exists,
37471 Exim assumes the directory is a maildir++ folder directory, which is one level
37472 down from the user&#x2019;s top level mailbox directory. This causes it to start at
37473 the parent directory instead of the current directory when calculating the
37474 amount of space used.
37475 </para>
37476 <para>
37477 One problem with delivering into a multi-file mailbox is that it is
37478 computationally expensive to compute the size of the mailbox for quota
37479 checking. Various approaches have been taken to reduce the amount of work
37480 needed. The next two sections describe two of them. A third alternative is to
37481 use some external process for maintaining the size data, and use the expansion
37482 of the <option>mailbox_size</option> option as a way of importing it into Exim.
37483 </para>
37484 </section>
37485 <section>
37486 <title>Using tags to record message sizes</title>
37487 <para>
37488 If <option>maildir_tag</option> is set, the string is expanded for each delivery.
37489 When the maildir file is renamed into the <filename>new</filename> sub-directory, the
37490 tag is added to its name. However, if adding the tag takes the length of the
37491 name to the point where the test <function>stat()</function> call fails with ENAMETOOLONG,
37492 the tag is dropped and the maildir file is created with no tag.
37493 </para>
37494 <para>
37495 <indexterm role="concept">
37496 <primary><varname>$message_size</varname></primary>
37497 </indexterm>
37498 Tags can be used to encode the size of files in their names; see
37499 <option>quota_size_regex</option> above for an example. The expansion of <option>maildir_tag</option>
37500 happens after the message has been written. The value of the <varname>$message_size</varname>
37501 variable is set to the number of bytes actually written. If the expansion is
37502 forced to fail, the tag is ignored, but a non-forced failure causes delivery to
37503 be deferred. The expanded tag may contain any printing characters except <quote>/</quote>.
37504 Non-printing characters in the string are ignored; if the resulting string is
37505 empty, it is ignored. If it starts with an alphanumeric character, a leading
37506 colon is inserted.
37507 </para>
37508 </section>
37509 <section>
37510 <title>Using a maildirsize file</title>
37511 <para>
37512 <indexterm role="concept">
37513 <primary>quota</primary>
37514 <secondary>in maildir delivery</secondary>
37515 </indexterm>
37516 <indexterm role="concept">
37517 <primary>maildir format</primary>
37518 <secondary><filename>maildirsize</filename> file</secondary>
37519 </indexterm>
37520 If <option>maildir_use_size_file</option> is true, Exim implements the maildir++ rules for
37521 storing quota and message size information in a file called <filename>maildirsize</filename>
37522 within the maildir directory. If this file does not exist, Exim creates it,
37523 setting the quota from the <option>quota</option> option of the transport. If the maildir
37524 directory itself does not exist, it is created before any attempt to write a
37525 <filename>maildirsize</filename> file.
37526 </para>
37527 <para>
37528 The <filename>maildirsize</filename> file is used to hold information about the sizes of
37529 messages in the maildir, thus speeding up quota calculations. The quota value
37530 in the file is just a cache; if the quota is changed in the transport, the new
37531 value overrides the cached value when the next message is delivered. The cache
37532 is maintained for the benefit of other programs that access the maildir and
37533 need to know the quota.
37534 </para>
37535 <para>
37536 If the <option>quota</option> option in the transport is unset or zero, the <filename>maildirsize</filename>
37537 file is maintained (with a zero quota setting), but no quota is imposed.
37538 </para>
37539 <para>
37540 A regular expression is available for controlling which directories in the
37541 maildir participate in quota calculations. See the description of the
37542 <option>maildir_quota_directory_regex</option> option above for details.
37543 </para>
37544 </section>
37545 <section>
37546 <title>Mailstore delivery</title>
37547 <para>
37548 <indexterm role="concept">
37549 <primary>mailstore format</primary>
37550 <secondary>description of</secondary>
37551 </indexterm>
37552 If the <option>mailstore_format</option> option is true, each message is written as two
37553 files in the given directory. A unique base name is constructed from the
37554 message id and the current delivery process, and the files that are written use
37555 this base name plus the suffixes <filename>.env</filename> and <filename>.msg</filename>. The <filename>.env</filename> file
37556 contains the message&#x2019;s envelope, and the <filename>.msg</filename> file contains the message
37557 itself. The base name is placed in the variable <varname>$mailstore_basename</varname>.
37558 </para>
37559 <para>
37560 During delivery, the envelope is first written to a file with the suffix
37561 <filename>.tmp</filename>. The <filename>.msg</filename> file is then written, and when it is complete, the
37562 <filename>.tmp</filename> file is renamed as the <filename>.env</filename> file. Programs that access messages in
37563 mailstore format should wait for the presence of both a <filename>.msg</filename> and a <filename>.env</filename>
37564 file before accessing either of them. An alternative approach is to wait for
37565 the absence of a <filename>.tmp</filename> file.
37566 </para>
37567 <para>
37568 The envelope file starts with any text defined by the <option>mailstore_prefix</option>
37569 option, expanded and terminated by a newline if there isn&#x2019;t one. Then follows
37570 the sender address on one line, then all the recipient addresses, one per line.
37571 There can be more than one recipient only if the <option>batch_max</option> option is set
37572 greater than one. Finally, <option>mailstore_suffix</option> is expanded and the result
37573 appended to the file, followed by a newline if it does not end with one.
37574 </para>
37575 <para>
37576 If expansion of <option>mailstore_prefix</option> or <option>mailstore_suffix</option> ends with a forced
37577 failure, it is ignored. Other expansion errors are treated as serious
37578 configuration errors, and delivery is deferred. The variable
37579 <varname>$mailstore_basename</varname> is available for use during these expansions.
37580 </para>
37581 </section>
37582 <section>
37583 <title>Non-special new file delivery</title>
37584 <para>
37585 If neither <option>maildir_format</option> nor <option>mailstore_format</option> is set, a single new
37586 file is created directly in the named directory. For example, when delivering
37587 messages into files in batched SMTP format for later delivery to some host (see
37588 section <xref linkend="SECTbatchSMTP"/>), a setting such as
37589 </para>
37590 <literallayout class="monospaced">
37591 directory = /var/bsmtp/$host
37592 </literallayout>
37593 <para>
37594 might be used. A message is written to a file with a temporary name, which is
37595 then renamed when the delivery is complete. The final name is obtained by
37596 expanding the contents of the <option>directory_file</option> option.
37597 <indexterm role="concept" startref="IIDapptra1" class="endofrange"/>
37598 <indexterm role="concept" startref="IIDapptra2" class="endofrange"/>
37599 </para>
37600 </section>
37601 </chapter>
37602
37603 <chapter>
37604 <title>The autoreply transport</title>
37605 <para>
37606 <indexterm role="concept" id="IIDauttra1" class="startofrange">
37607 <primary>transports</primary>
37608 <secondary><command>autoreply</command></secondary>
37609 </indexterm>
37610 <indexterm role="concept" id="IIDauttra2" class="startofrange">
37611 <primary><command>autoreply</command> transport</primary>
37612 </indexterm>
37613 </para>
37614 <para revisionflag="changed">
37615 The <command>autoreply</command> transport is not a true transport in that it does not cause
37616 the message to be transmitted. Instead, it generates a new mail message as an
37617 automatic reply to the incoming message. <emphasis>References:</emphasis> and
37618 <emphasis>Auto-Submitted:</emphasis> header lines are included. These are constructed according
37619 to the rules in RFCs 2822 and 3834, respectively.
37620 </para>
37621 <para>
37622 If the router that passes the message to this transport does not have the
37623 <option>unseen</option> option set, the original message (for the current recipient) is not
37624 delivered anywhere. However, when the <option>unseen</option> option is set on the router
37625 that passes the message to this transport, routing of the address continues, so
37626 another router can set up a normal message delivery.
37627 </para>
37628 <para>
37629 The <command>autoreply</command> transport is usually run as the result of mail filtering, a
37630 <quote>vacation</quote> message being the standard example. However, it can also be run
37631 directly from a router like any other transport. To reduce the possibility of
37632 message cascades, messages created by the <command>autoreply</command> transport always have
37633 empty envelope sender addresses, like bounce messages.
37634 </para>
37635 <para>
37636 The parameters of the message to be sent can be specified in the configuration
37637 by options described below. However, these are used only when the address
37638 passed to the transport does not contain its own reply information. When the
37639 transport is run as a consequence of a
37640 <option>mail</option>
37641 or <option>vacation</option> command in a filter file, the parameters of the message are
37642 supplied by the filter, and passed with the address. The transport&#x2019;s options
37643 that define the message are then ignored (so they are not usually set in this
37644 case). The message is specified entirely by the filter or by the transport; it
37645 is never built from a mixture of options. However, the <option>file_optional</option>,
37646 <option>mode</option>, and <option>return_message</option> options apply in all cases.
37647 </para>
37648 <para>
37649 <command>Autoreply</command> is implemented as a local transport. When used as a result of a
37650 command in a user&#x2019;s filter file, <command>autoreply</command> normally runs under the uid and
37651 gid of the user, and with appropriate current and home directories (see chapter
37652 <xref linkend="CHAPenvironment"/>).
37653 </para>
37654 <para>
37655 There is a subtle difference between routing a message to a <command>pipe</command> transport
37656 that generates some text to be returned to the sender, and routing it to an
37657 <command>autoreply</command> transport. This difference is noticeable only if more than one
37658 address from the same message is so handled. In the case of a pipe, the
37659 separate outputs from the different addresses are gathered up and returned to
37660 the sender in a single message, whereas if <command>autoreply</command> is used, a separate
37661 message is generated for each address that is passed to it.
37662 </para>
37663 <para>
37664 Non-printing characters are not permitted in the header lines generated for the
37665 message that <command>autoreply</command> creates, with the exception of newlines that are
37666 immediately followed by white space. If any non-printing characters are found,
37667 the transport defers.
37668 Whether characters with the top bit set count as printing characters or not is
37669 controlled by the <option>print_topbitchars</option> global option.
37670 </para>
37671 <para>
37672 If any of the generic options for manipulating headers (for example,
37673 <option>headers_add</option>) are set on an <command>autoreply</command> transport, they apply to the copy
37674 of the original message that is included in the generated message when
37675 <option>return_message</option> is set. They do not apply to the generated message itself.
37676 </para>
37677 <para>
37678 <indexterm role="concept">
37679 <primary><varname>$sender_address</varname></primary>
37680 </indexterm>
37681 If the <command>autoreply</command> transport receives return code 2 from Exim when it submits
37682 the message, indicating that there were no recipients, it does not treat this
37683 as an error. This means that autoreplies sent to <varname>$sender_address</varname> when this
37684 is empty (because the incoming message is a bounce message) do not cause
37685 problems. They are just discarded.
37686 </para>
37687 <section>
37688 <title>Private options for autoreply</title>
37689 <para>
37690 <indexterm role="concept">
37691 <primary>options</primary>
37692 <secondary><command>autoreply</command> transport</secondary>
37693 </indexterm>
37694 </para>
37695 <para>
37696 <indexterm role="option">
37697 <primary>bcc</primary>
37698 </indexterm>
37699 </para>
37700 <informaltable frame="all">
37701 <tgroup cols="4" colsep="0" rowsep="0">
37702 <colspec colwidth="8*" align="left"/>
37703 <colspec colwidth="5*" align="center"/>
37704 <colspec colwidth="5*" align="center"/>
37705 <colspec colwidth="6*" align="right"/>
37706 <tbody>
37707 <row>
37708 <entry><option>bcc</option></entry>
37709 <entry>Use: <emphasis>autoreply</emphasis></entry>
37710 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37711 <entry>Default: <emphasis>unset</emphasis></entry>
37712 </row>
37713 </tbody>
37714 </tgroup>
37715 </informaltable>
37716 <para>
37717 This specifies the addresses that are to receive <quote>blind carbon copies</quote> of the
37718 message when the message is specified by the transport.
37719 </para>
37720 <para>
37721 <indexterm role="option">
37722 <primary>cc</primary>
37723 </indexterm>
37724 </para>
37725 <informaltable frame="all">
37726 <tgroup cols="4" colsep="0" rowsep="0">
37727 <colspec colwidth="8*" align="left"/>
37728 <colspec colwidth="5*" align="center"/>
37729 <colspec colwidth="5*" align="center"/>
37730 <colspec colwidth="6*" align="right"/>
37731 <tbody>
37732 <row>
37733 <entry><option>cc</option></entry>
37734 <entry>Use: <emphasis>autoreply</emphasis></entry>
37735 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37736 <entry>Default: <emphasis>unset</emphasis></entry>
37737 </row>
37738 </tbody>
37739 </tgroup>
37740 </informaltable>
37741 <para>
37742 This specifies recipients of the message and the contents of the <emphasis>Cc:</emphasis> header
37743 when the message is specified by the transport.
37744 </para>
37745 <para>
37746 <indexterm role="option">
37747 <primary>file</primary>
37748 </indexterm>
37749 </para>
37750 <informaltable frame="all">
37751 <tgroup cols="4" colsep="0" rowsep="0">
37752 <colspec colwidth="8*" align="left"/>
37753 <colspec colwidth="5*" align="center"/>
37754 <colspec colwidth="5*" align="center"/>
37755 <colspec colwidth="6*" align="right"/>
37756 <tbody>
37757 <row>
37758 <entry><option>file</option></entry>
37759 <entry>Use: <emphasis>autoreply</emphasis></entry>
37760 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37761 <entry>Default: <emphasis>unset</emphasis></entry>
37762 </row>
37763 </tbody>
37764 </tgroup>
37765 </informaltable>
37766 <para>
37767 The contents of the file are sent as the body of the message when the message
37768 is specified by the transport. If both <option>file</option> and <option>text</option> are set, the text
37769 string comes first.
37770 </para>
37771 <para>
37772 <indexterm role="option">
37773 <primary>file_expand</primary>
37774 </indexterm>
37775 </para>
37776 <informaltable frame="all">
37777 <tgroup cols="4" colsep="0" rowsep="0">
37778 <colspec colwidth="8*" align="left"/>
37779 <colspec colwidth="5*" align="center"/>
37780 <colspec colwidth="5*" align="center"/>
37781 <colspec colwidth="6*" align="right"/>
37782 <tbody>
37783 <row>
37784 <entry><option>file_expand</option></entry>
37785 <entry>Use: <emphasis>autoreply</emphasis></entry>
37786 <entry>Type: <emphasis>boolean</emphasis></entry>
37787 <entry>Default: <emphasis>false</emphasis></entry>
37788 </row>
37789 </tbody>
37790 </tgroup>
37791 </informaltable>
37792 <para>
37793 If this is set, the contents of the file named by the <option>file</option> option are
37794 subjected to string expansion as they are added to the message.
37795 </para>
37796 <para>
37797 <indexterm role="option">
37798 <primary>file_optional</primary>
37799 </indexterm>
37800 </para>
37801 <informaltable frame="all">
37802 <tgroup cols="4" colsep="0" rowsep="0">
37803 <colspec colwidth="8*" align="left"/>
37804 <colspec colwidth="5*" align="center"/>
37805 <colspec colwidth="5*" align="center"/>
37806 <colspec colwidth="6*" align="right"/>
37807 <tbody>
37808 <row>
37809 <entry><option>file_optional</option></entry>
37810 <entry>Use: <emphasis>autoreply</emphasis></entry>
37811 <entry>Type: <emphasis>boolean</emphasis></entry>
37812 <entry>Default: <emphasis>false</emphasis></entry>
37813 </row>
37814 </tbody>
37815 </tgroup>
37816 </informaltable>
37817 <para>
37818 If this option is true, no error is generated if the file named by the <option>file</option>
37819 option or passed with the address does not exist or cannot be read.
37820 </para>
37821 <para>
37822 <indexterm role="option">
37823 <primary>from</primary>
37824 </indexterm>
37825 </para>
37826 <informaltable frame="all">
37827 <tgroup cols="4" colsep="0" rowsep="0">
37828 <colspec colwidth="8*" align="left"/>
37829 <colspec colwidth="5*" align="center"/>
37830 <colspec colwidth="5*" align="center"/>
37831 <colspec colwidth="6*" align="right"/>
37832 <tbody>
37833 <row>
37834 <entry><option>from</option></entry>
37835 <entry>Use: <emphasis>autoreply</emphasis></entry>
37836 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37837 <entry>Default: <emphasis>unset</emphasis></entry>
37838 </row>
37839 </tbody>
37840 </tgroup>
37841 </informaltable>
37842 <para>
37843 This specifies the contents of the <emphasis>From:</emphasis> header when the message is
37844 specified by the transport.
37845 </para>
37846 <para>
37847 <indexterm role="option">
37848 <primary>headers</primary>
37849 </indexterm>
37850 </para>
37851 <informaltable frame="all">
37852 <tgroup cols="4" colsep="0" rowsep="0">
37853 <colspec colwidth="8*" align="left"/>
37854 <colspec colwidth="5*" align="center"/>
37855 <colspec colwidth="5*" align="center"/>
37856 <colspec colwidth="6*" align="right"/>
37857 <tbody>
37858 <row>
37859 <entry><option>headers</option></entry>
37860 <entry>Use: <emphasis>autoreply</emphasis></entry>
37861 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37862 <entry>Default: <emphasis>unset</emphasis></entry>
37863 </row>
37864 </tbody>
37865 </tgroup>
37866 </informaltable>
37867 <para>
37868 This specifies additional RFC 2822 headers that are to be added to the message
37869 when the message is specified by the transport. Several can be given by using
37870 <quote>\n</quote> to separate them. There is no check on the format.
37871 </para>
37872 <para>
37873 <indexterm role="option">
37874 <primary>log</primary>
37875 </indexterm>
37876 </para>
37877 <informaltable frame="all">
37878 <tgroup cols="4" colsep="0" rowsep="0">
37879 <colspec colwidth="8*" align="left"/>
37880 <colspec colwidth="5*" align="center"/>
37881 <colspec colwidth="5*" align="center"/>
37882 <colspec colwidth="6*" align="right"/>
37883 <tbody>
37884 <row>
37885 <entry><option>log</option></entry>
37886 <entry>Use: <emphasis>autoreply</emphasis></entry>
37887 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37888 <entry>Default: <emphasis>unset</emphasis></entry>
37889 </row>
37890 </tbody>
37891 </tgroup>
37892 </informaltable>
37893 <para>
37894 This option names a file in which a record of every message sent is logged when
37895 the message is specified by the transport.
37896 </para>
37897 <para>
37898 <indexterm role="option">
37899 <primary>mode</primary>
37900 </indexterm>
37901 </para>
37902 <informaltable frame="all">
37903 <tgroup cols="4" colsep="0" rowsep="0">
37904 <colspec colwidth="8*" align="left"/>
37905 <colspec colwidth="5*" align="center"/>
37906 <colspec colwidth="5*" align="center"/>
37907 <colspec colwidth="6*" align="right"/>
37908 <tbody>
37909 <row>
37910 <entry><option>mode</option></entry>
37911 <entry>Use: <emphasis>autoreply</emphasis></entry>
37912 <entry>Type: <emphasis>octal integer</emphasis></entry>
37913 <entry>Default: <emphasis>0600</emphasis></entry>
37914 </row>
37915 </tbody>
37916 </tgroup>
37917 </informaltable>
37918 <para>
37919 If either the log file or the <quote>once</quote> file has to be created, this mode is
37920 used.
37921 </para>
37922 <para>
37923 <indexterm role="option">
37924 <primary>never_mail</primary>
37925 </indexterm>
37926 </para>
37927 <informaltable frame="all">
37928 <tgroup cols="4" colsep="0" rowsep="0">
37929 <colspec colwidth="8*" align="left"/>
37930 <colspec colwidth="5*" align="center"/>
37931 <colspec colwidth="5*" align="center"/>
37932 <colspec colwidth="6*" align="right"/>
37933 <tbody>
37934 <row>
37935 <entry><option>never_mail</option></entry>
37936 <entry>Use: <emphasis>autoreply</emphasis></entry>
37937 <entry>Type: <emphasis>address list</emphasis>&dagger;<emphasis></emphasis></entry>
37938 <entry>Default: <emphasis>unset</emphasis></entry>
37939 </row>
37940 </tbody>
37941 </tgroup>
37942 </informaltable>
37943 <para>
37944 If any run of the transport creates a message with a recipient that matches any
37945 item in the list, that recipient is quietly discarded. If all recipients are
37946 discarded, no message is created.
37947 </para>
37948 <para>
37949 <indexterm role="option">
37950 <primary>once</primary>
37951 </indexterm>
37952 </para>
37953 <informaltable frame="all">
37954 <tgroup cols="4" colsep="0" rowsep="0">
37955 <colspec colwidth="8*" align="left"/>
37956 <colspec colwidth="5*" align="center"/>
37957 <colspec colwidth="5*" align="center"/>
37958 <colspec colwidth="6*" align="right"/>
37959 <tbody>
37960 <row>
37961 <entry><option>once</option></entry>
37962 <entry>Use: <emphasis>autoreply</emphasis></entry>
37963 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37964 <entry>Default: <emphasis>unset</emphasis></entry>
37965 </row>
37966 </tbody>
37967 </tgroup>
37968 </informaltable>
37969 <para>
37970 This option names a file or DBM database in which a record of each <emphasis>To:</emphasis>
37971 recipient is kept when the message is specified by the transport. <emphasis role="bold">Note</emphasis>:
37972 This does not apply to <emphasis>Cc:</emphasis> or <emphasis>Bcc:</emphasis> recipients.
37973 </para>
37974 <para>
37975 If <option>once</option> is unset, or is set to an empty string, the message is always sent.
37976 By default, if <option>once</option> is set to a non-empty file name, the message
37977 is not sent if a potential recipient is already listed in the database.
37978 However, if the <option>once_repeat</option> option specifies a time greater than zero, the
37979 message is sent if that much time has elapsed since a message was last sent to
37980 this recipient. A setting of zero time for <option>once_repeat</option> (the default)
37981 prevents a message from being sent a second time &ndash; in this case, zero means
37982 infinity.
37983 </para>
37984 <para>
37985 If <option>once_file_size</option> is zero, a DBM database is used to remember recipients,
37986 and it is allowed to grow as large as necessary. If <option>once_file_size</option> is set
37987 greater than zero, it changes the way Exim implements the <option>once</option> option.
37988 Instead of using a DBM file to record every recipient it sends to, it uses a
37989 regular file, whose size will never get larger than the given value.
37990 </para>
37991 <para>
37992 In the file, Exim keeps a linear list of recipient addresses and the times at
37993 which they were sent messages. If the file is full when a new address needs to
37994 be added, the oldest address is dropped. If <option>once_repeat</option> is not set, this
37995 means that a given recipient may receive multiple messages, but at
37996 unpredictable intervals that depend on the rate of turnover of addresses in the
37997 file. If <option>once_repeat</option> is set, it specifies a maximum time between repeats.
37998 </para>
37999 <para>
38000 <indexterm role="option">
38001 <primary>once_file_size</primary>
38002 </indexterm>
38003 </para>
38004 <informaltable frame="all">
38005 <tgroup cols="4" colsep="0" rowsep="0">
38006 <colspec colwidth="8*" align="left"/>
38007 <colspec colwidth="5*" align="center"/>
38008 <colspec colwidth="5*" align="center"/>
38009 <colspec colwidth="6*" align="right"/>
38010 <tbody>
38011 <row>
38012 <entry><option>once_file_size</option></entry>
38013 <entry>Use: <emphasis>autoreply</emphasis></entry>
38014 <entry>Type: <emphasis>integer</emphasis></entry>
38015 <entry>Default: <emphasis>0</emphasis></entry>
38016 </row>
38017 </tbody>
38018 </tgroup>
38019 </informaltable>
38020 <para>
38021 See <option>once</option> above.
38022 </para>
38023 <para>
38024 <indexterm role="option">
38025 <primary>once_repeat</primary>
38026 </indexterm>
38027 </para>
38028 <informaltable frame="all">
38029 <tgroup cols="4" colsep="0" rowsep="0">
38030 <colspec colwidth="8*" align="left"/>
38031 <colspec colwidth="5*" align="center"/>
38032 <colspec colwidth="5*" align="center"/>
38033 <colspec colwidth="6*" align="right"/>
38034 <tbody>
38035 <row>
38036 <entry><option>once_repeat</option></entry>
38037 <entry>Use: <emphasis>autoreply</emphasis></entry>
38038 <entry>Type: <emphasis>time</emphasis>&dagger;<emphasis></emphasis></entry>
38039 <entry>Default: <emphasis>0s</emphasis></entry>
38040 </row>
38041 </tbody>
38042 </tgroup>
38043 </informaltable>
38044 <para>
38045 See <option>once</option> above.
38046 After expansion, the value of this option must be a valid time value.
38047 </para>
38048 <para>
38049 <indexterm role="option">
38050 <primary>reply_to</primary>
38051 </indexterm>
38052 </para>
38053 <informaltable frame="all">
38054 <tgroup cols="4" colsep="0" rowsep="0">
38055 <colspec colwidth="8*" align="left"/>
38056 <colspec colwidth="5*" align="center"/>
38057 <colspec colwidth="5*" align="center"/>
38058 <colspec colwidth="6*" align="right"/>
38059 <tbody>
38060 <row>
38061 <entry><option>reply_to</option></entry>
38062 <entry>Use: <emphasis>autoreply</emphasis></entry>
38063 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38064 <entry>Default: <emphasis>unset</emphasis></entry>
38065 </row>
38066 </tbody>
38067 </tgroup>
38068 </informaltable>
38069 <para>
38070 This specifies the contents of the <emphasis>Reply-To:</emphasis> header when the message is
38071 specified by the transport.
38072 </para>
38073 <para>
38074 <indexterm role="option">
38075 <primary>return_message</primary>
38076 </indexterm>
38077 </para>
38078 <informaltable frame="all">
38079 <tgroup cols="4" colsep="0" rowsep="0">
38080 <colspec colwidth="8*" align="left"/>
38081 <colspec colwidth="5*" align="center"/>
38082 <colspec colwidth="5*" align="center"/>
38083 <colspec colwidth="6*" align="right"/>
38084 <tbody>
38085 <row>
38086 <entry><option>return_message</option></entry>
38087 <entry>Use: <emphasis>autoreply</emphasis></entry>
38088 <entry>Type: <emphasis>boolean</emphasis></entry>
38089 <entry>Default: <emphasis>false</emphasis></entry>
38090 </row>
38091 </tbody>
38092 </tgroup>
38093 </informaltable>
38094 <para>
38095 If this is set, a copy of the original message is returned with the new
38096 message, subject to the maximum size set in the <option>return_size_limit</option> global
38097 configuration option.
38098 </para>
38099 <para>
38100 <indexterm role="option">
38101 <primary>subject</primary>
38102 </indexterm>
38103 </para>
38104 <informaltable frame="all">
38105 <tgroup cols="4" colsep="0" rowsep="0">
38106 <colspec colwidth="8*" align="left"/>
38107 <colspec colwidth="5*" align="center"/>
38108 <colspec colwidth="5*" align="center"/>
38109 <colspec colwidth="6*" align="right"/>
38110 <tbody>
38111 <row>
38112 <entry><option>subject</option></entry>
38113 <entry>Use: <emphasis>autoreply</emphasis></entry>
38114 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38115 <entry>Default: <emphasis>unset</emphasis></entry>
38116 </row>
38117 </tbody>
38118 </tgroup>
38119 </informaltable>
38120 <para>
38121 This specifies the contents of the <emphasis>Subject:</emphasis> header when the message is
38122 specified by the transport. It is tempting to quote the original subject in
38123 automatic responses. For example:
38124 </para>
38125 <literallayout class="monospaced">
38126 subject = Re: $h_subject:
38127 </literallayout>
38128 <para>
38129 There is a danger in doing this, however. It may allow a third party to
38130 subscribe your users to an opt-in mailing list, provided that the list accepts
38131 bounce messages as subscription confirmations. Well-managed lists require a
38132 non-bounce message to confirm a subscription, so the danger is relatively
38133 small.
38134 </para>
38135 <para>
38136 <indexterm role="option">
38137 <primary>text</primary>
38138 </indexterm>
38139 </para>
38140 <informaltable frame="all">
38141 <tgroup cols="4" colsep="0" rowsep="0">
38142 <colspec colwidth="8*" align="left"/>
38143 <colspec colwidth="5*" align="center"/>
38144 <colspec colwidth="5*" align="center"/>
38145 <colspec colwidth="6*" align="right"/>
38146 <tbody>
38147 <row>
38148 <entry><option>text</option></entry>
38149 <entry>Use: <emphasis>autoreply</emphasis></entry>
38150 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38151 <entry>Default: <emphasis>unset</emphasis></entry>
38152 </row>
38153 </tbody>
38154 </tgroup>
38155 </informaltable>
38156 <para>
38157 This specifies a single string to be used as the body of the message when the
38158 message is specified by the transport. If both <option>text</option> and <option>file</option> are set,
38159 the text comes first.
38160 </para>
38161 <para>
38162 <indexterm role="option">
38163 <primary>to</primary>
38164 </indexterm>
38165 </para>
38166 <informaltable frame="all">
38167 <tgroup cols="4" colsep="0" rowsep="0">
38168 <colspec colwidth="8*" align="left"/>
38169 <colspec colwidth="5*" align="center"/>
38170 <colspec colwidth="5*" align="center"/>
38171 <colspec colwidth="6*" align="right"/>
38172 <tbody>
38173 <row>
38174 <entry><option>to</option></entry>
38175 <entry>Use: <emphasis>autoreply</emphasis></entry>
38176 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38177 <entry>Default: <emphasis>unset</emphasis></entry>
38178 </row>
38179 </tbody>
38180 </tgroup>
38181 </informaltable>
38182 <para>
38183 This specifies recipients of the message and the contents of the <emphasis>To:</emphasis> header
38184 when the message is specified by the transport.
38185 <indexterm role="concept" startref="IIDauttra1" class="endofrange"/>
38186 <indexterm role="concept" startref="IIDauttra2" class="endofrange"/>
38187 </para>
38188 </section>
38189 </chapter>
38190
38191 <chapter id="CHAPLMTP">
38192 <title>The lmtp transport</title>
38193 <para>
38194 <indexterm role="concept">
38195 <primary>transports</primary>
38196 <secondary><command>lmtp</command></secondary>
38197 </indexterm>
38198 <indexterm role="concept">
38199 <primary><command>lmtp</command> transport</primary>
38200 </indexterm>
38201 <indexterm role="concept">
38202 <primary>LMTP</primary>
38203 <secondary>over a pipe</secondary>
38204 </indexterm>
38205 <indexterm role="concept">
38206 <primary>LMTP</primary>
38207 <secondary>over a socket</secondary>
38208 </indexterm>
38209 The <command>lmtp</command> transport runs the LMTP protocol (RFC 2033) over a pipe to a
38210 specified command
38211 or by interacting with a Unix domain socket.
38212 This transport is something of a cross between the <command>pipe</command> and <command>smtp</command>
38213 transports. Exim also has support for using LMTP over TCP/IP; this is
38214 implemented as an option for the <command>smtp</command> transport. Because LMTP is expected
38215 to be of minority interest, the default build-time configure in <filename>src/EDITME</filename>
38216 has it commented out. You need to ensure that
38217 </para>
38218 <literallayout class="monospaced">
38219 TRANSPORT_LMTP=yes
38220 </literallayout>
38221 <para>
38222 <indexterm role="concept">
38223 <primary>options</primary>
38224 <secondary><command>lmtp</command> transport</secondary>
38225 </indexterm>
38226 is present in your <filename>Local/Makefile</filename> in order to have the <command>lmtp</command> transport
38227 included in the Exim binary. The private options of the <command>lmtp</command> transport are
38228 as follows:
38229 </para>
38230 <para>
38231 <indexterm role="option">
38232 <primary>batch_id</primary>
38233 </indexterm>
38234 </para>
38235 <informaltable frame="all">
38236 <tgroup cols="4" colsep="0" rowsep="0">
38237 <colspec colwidth="8*" align="left"/>
38238 <colspec colwidth="5*" align="center"/>
38239 <colspec colwidth="5*" align="center"/>
38240 <colspec colwidth="6*" align="right"/>
38241 <tbody>
38242 <row>
38243 <entry><option>batch_id</option></entry>
38244 <entry>Use: <emphasis>lmtp</emphasis></entry>
38245 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38246 <entry>Default: <emphasis>unset</emphasis></entry>
38247 </row>
38248 </tbody>
38249 </tgroup>
38250 </informaltable>
38251 <para>
38252 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
38253 </para>
38254 <para>
38255 <indexterm role="option">
38256 <primary>batch_max</primary>
38257 </indexterm>
38258 </para>
38259 <informaltable frame="all">
38260 <tgroup cols="4" colsep="0" rowsep="0">
38261 <colspec colwidth="8*" align="left"/>
38262 <colspec colwidth="5*" align="center"/>
38263 <colspec colwidth="5*" align="center"/>
38264 <colspec colwidth="6*" align="right"/>
38265 <tbody>
38266 <row>
38267 <entry><option>batch_max</option></entry>
38268 <entry>Use: <emphasis>lmtp</emphasis></entry>
38269 <entry>Type: <emphasis>integer</emphasis></entry>
38270 <entry>Default: <emphasis>1</emphasis></entry>
38271 </row>
38272 </tbody>
38273 </tgroup>
38274 </informaltable>
38275 <para>
38276 This limits the number of addresses that can be handled in a single delivery.
38277 Most LMTP servers can handle several addresses at once, so it is normally a
38278 good idea to increase this value. See the description of local delivery
38279 batching in chapter <xref linkend="CHAPbatching"/>.
38280 </para>
38281 <para>
38282 <indexterm role="option">
38283 <primary>command</primary>
38284 </indexterm>
38285 </para>
38286 <informaltable frame="all">
38287 <tgroup cols="4" colsep="0" rowsep="0">
38288 <colspec colwidth="8*" align="left"/>
38289 <colspec colwidth="5*" align="center"/>
38290 <colspec colwidth="5*" align="center"/>
38291 <colspec colwidth="6*" align="right"/>
38292 <tbody>
38293 <row>
38294 <entry><option>command</option></entry>
38295 <entry>Use: <emphasis>lmtp</emphasis></entry>
38296 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38297 <entry>Default: <emphasis>unset</emphasis></entry>
38298 </row>
38299 </tbody>
38300 </tgroup>
38301 </informaltable>
38302 <para>
38303 This option must be set if <option>socket</option> is not set. The string is a command which
38304 is run in a separate process. It is split up into a command name and list of
38305 arguments, each of which is separately expanded (so expansion cannot change the
38306 number of arguments). The command is run directly, not via a shell. The message
38307 is passed to the new process using the standard input and output to operate the
38308 LMTP protocol.
38309 </para>
38310 <para>
38311 <indexterm role="option">
38312 <primary>ignore_quota</primary>
38313 </indexterm>
38314 </para>
38315 <informaltable frame="all">
38316 <tgroup cols="4" colsep="0" rowsep="0">
38317 <colspec colwidth="8*" align="left"/>
38318 <colspec colwidth="5*" align="center"/>
38319 <colspec colwidth="5*" align="center"/>
38320 <colspec colwidth="6*" align="right"/>
38321 <tbody>
38322 <row>
38323 <entry><option>ignore_quota</option></entry>
38324 <entry>Use: <emphasis>lmtp</emphasis></entry>
38325 <entry>Type: <emphasis>boolean</emphasis></entry>
38326 <entry>Default: <emphasis>false</emphasis></entry>
38327 </row>
38328 </tbody>
38329 </tgroup>
38330 </informaltable>
38331 <para>
38332 <indexterm role="concept">
38333 <primary>LMTP</primary>
38334 <secondary>ignoring quota errors</secondary>
38335 </indexterm>
38336 If this option is set true, the string <literal>IGNOREQUOTA</literal> is added to RCPT
38337 commands, provided that the LMTP server has advertised support for IGNOREQUOTA
38338 in its response to the LHLO command.
38339 </para>
38340 <para>
38341 <indexterm role="option">
38342 <primary>socket</primary>
38343 </indexterm>
38344 </para>
38345 <informaltable frame="all">
38346 <tgroup cols="4" colsep="0" rowsep="0">
38347 <colspec colwidth="8*" align="left"/>
38348 <colspec colwidth="5*" align="center"/>
38349 <colspec colwidth="5*" align="center"/>
38350 <colspec colwidth="6*" align="right"/>
38351 <tbody>
38352 <row>
38353 <entry><option>socket</option></entry>
38354 <entry>Use: <emphasis>lmtp</emphasis></entry>
38355 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38356 <entry>Default: <emphasis>unset</emphasis></entry>
38357 </row>
38358 </tbody>
38359 </tgroup>
38360 </informaltable>
38361 <para>
38362 This option must be set if <option>command</option> is not set. The result of expansion must
38363 be the name of a Unix domain socket. The transport connects to the socket and
38364 delivers the message to it using the LMTP protocol.
38365 </para>
38366 <para>
38367 <indexterm role="option">
38368 <primary>timeout</primary>
38369 </indexterm>
38370 </para>
38371 <informaltable frame="all">
38372 <tgroup cols="4" colsep="0" rowsep="0">
38373 <colspec colwidth="8*" align="left"/>
38374 <colspec colwidth="5*" align="center"/>
38375 <colspec colwidth="5*" align="center"/>
38376 <colspec colwidth="6*" align="right"/>
38377 <tbody>
38378 <row>
38379 <entry><option>timeout</option></entry>
38380 <entry>Use: <emphasis>lmtp</emphasis></entry>
38381 <entry>Type: <emphasis>time</emphasis></entry>
38382 <entry>Default: <emphasis>5m</emphasis></entry>
38383 </row>
38384 </tbody>
38385 </tgroup>
38386 </informaltable>
38387 <para>
38388 The transport is aborted if the created process
38389 or Unix domain socket
38390 does not respond to LMTP commands or message input within this timeout.
38391 </para>
38392 <para>
38393 Here is an example of a typical LMTP transport:
38394 </para>
38395 <literallayout class="monospaced">
38396 lmtp:
38397   driver = lmtp
38398   command = /some/local/lmtp/delivery/program
38399   batch_max = 20
38400   user = exim
38401 </literallayout>
38402 <para>
38403 This delivers up to 20 addresses at a time, in a mixture of domains if
38404 necessary, running as the user <emphasis>exim</emphasis>.
38405 </para>
38406 </chapter>
38407
38408 <chapter id="CHAPpipetransport">
38409 <title>The pipe transport</title>
38410 <para>
38411 <indexterm role="concept" id="IIDpiptra1" class="startofrange">
38412 <primary>transports</primary>
38413 <secondary><command>pipe</command></secondary>
38414 </indexterm>
38415 <indexterm role="concept" id="IIDpiptra2" class="startofrange">
38416 <primary><command>pipe</command> transport</primary>
38417 </indexterm>
38418 The <command>pipe</command> transport is used to deliver messages via a pipe to a command
38419 running in another process. One example is the use of <command>pipe</command> as a
38420 pseudo-remote transport for passing messages to some other delivery mechanism
38421 (such as UUCP). Another is the use by individual users to automatically process
38422 their incoming messages. The <command>pipe</command> transport can be used in one of the
38423 following ways:
38424 </para>
38425 <itemizedlist>
38426 <listitem>
38427 <para>
38428 <indexterm role="concept">
38429 <primary><varname>$local_part</varname></primary>
38430 </indexterm>
38431 A router routes one address to a transport in the normal way, and the
38432 transport is configured as a <command>pipe</command> transport. In this case, <varname>$local_part</varname>
38433 contains the local part of the address (as usual), and the command that is run
38434 is specified by the <option>command</option> option on the transport.
38435 </para>
38436 </listitem>
38437 <listitem>
38438 <para>
38439 <indexterm role="concept">
38440 <primary><varname>$pipe_addresses</varname></primary>
38441 </indexterm>
38442 If the <option>batch_max</option> option is set greater than 1 (the default), the transport
38443 can be called upon to handle more than one address in a single run. In this
38444 case, <varname>$local_part</varname> is not set (because it is not unique). However, the
38445 pseudo-variable <varname>$pipe_addresses</varname> (described in section
38446 <xref linkend="SECThowcommandrun"/> below) contains all the addresses that are being
38447 handled.
38448 </para>
38449 </listitem>
38450 <listitem>
38451 <para>
38452 <indexterm role="concept">
38453 <primary><varname>$address_pipe</varname></primary>
38454 </indexterm>
38455 A router redirects an address directly to a pipe command (for example, from an
38456 alias or forward file). In this case, <varname>$local_part</varname> contains the local part
38457 that was redirected, and <varname>$address_pipe</varname> contains the text of the pipe
38458 command itself. The <option>command</option> option on the transport is ignored.
38459 </para>
38460 </listitem>
38461 </itemizedlist>
38462 <para>
38463 The <command>pipe</command> transport is a non-interactive delivery method. Exim can also
38464 deliver messages over pipes using the LMTP interactive protocol. This is
38465 implemented by the <command>lmtp</command> transport.
38466 </para>
38467 <para>
38468 In the case when <command>pipe</command> is run as a consequence of an entry in a local user&#x2019;s
38469 <filename>.forward</filename> file, the command runs under the uid and gid of that user. In
38470 other cases, the uid and gid have to be specified explicitly, either on the
38471 transport or on the router that handles the address. Current and <quote>home</quote>
38472 directories are also controllable. See chapter <xref linkend="CHAPenvironment"/> for
38473 details of the local delivery environment.
38474 </para>
38475 <section>
38476 <title>Concurrent delivery</title>
38477 <para>
38478 If two messages arrive at almost the same time, and both are routed to a pipe
38479 delivery, the two pipe transports may be run concurrently. You must ensure that
38480 any pipe commands you set up are robust against this happening. If the commands
38481 write to a file, the <option>exim_lock</option> utility might be of use.
38482 </para>
38483 </section>
38484 <section>
38485 <title>Returned status and data</title>
38486 <para>
38487 <indexterm role="concept">
38488 <primary><command>pipe</command> transport</primary>
38489 <secondary>returned data</secondary>
38490 </indexterm>
38491 If the command exits with a non-zero return code, the delivery is deemed to
38492 have failed, unless either the <option>ignore_status</option> option is set (in which case
38493 the return code is treated as zero), or the return code is one of those listed
38494 in the <option>temp_errors</option> option, which are interpreted as meaning <quote>try again
38495 later</quote>. In this case, delivery is deferred. Details of a permanent failure are
38496 logged, but are not included in the bounce message, which merely contains
38497 <quote>local delivery failed</quote>.
38498 </para>
38499 <para>
38500 If the return code is greater than 128 and the command being run is a shell
38501 script, it normally means that the script was terminated by a signal whose
38502 value is the return code minus 128.
38503 </para>
38504 <para>
38505 If Exim is unable to run the command (that is, if <function>execve()</function> fails), the
38506 return code is set to 127. This is the value that a shell returns if it is
38507 asked to run a non-existent command. The wording for the log line suggests that
38508 a non-existent command may be the problem.
38509 </para>
38510 <para>
38511 The <option>return_output</option> option can affect the result of a pipe delivery. If it is
38512 set and the command produces any output on its standard output or standard
38513 error streams, the command is considered to have failed, even if it gave a zero
38514 return code or if <option>ignore_status</option> is set. The output from the command is
38515 included as part of the bounce message. The <option>return_fail_output</option> option is
38516 similar, except that output is returned only when the command exits with a
38517 failure return code, that is, a value other than zero or a code that matches
38518 <option>temp_errors</option>.
38519 </para>
38520 </section>
38521 <section id="SECThowcommandrun">
38522 <title>How the command is run</title>
38523 <para>
38524 <indexterm role="concept">
38525 <primary><command>pipe</command> transport</primary>
38526 <secondary>path for command</secondary>
38527 </indexterm>
38528 The command line is (by default) broken down into a command name and arguments
38529 by the <command>pipe</command> transport itself. The <option>allow_commands</option> and
38530 <option>restrict_to_path</option> options can be used to restrict the commands that may be
38531 run.
38532 </para>
38533 <para>
38534 <indexterm role="concept">
38535 <primary>quoting</primary>
38536 <secondary>in pipe command</secondary>
38537 </indexterm>
38538 Unquoted arguments are delimited by white space. If an argument appears in
38539 double quotes, backslash is interpreted as an escape character in the usual
38540 way. If an argument appears in single quotes, no escaping is done.
38541 </para>
38542 <para>
38543 String expansion is applied to the command line except when it comes from a
38544 traditional <filename>.forward</filename> file (commands from a filter file are expanded). The
38545 expansion is applied to each argument in turn rather than to the whole line.
38546 For this reason, any string expansion item that contains white space must be
38547 quoted so as to be contained within a single argument. A setting such as
38548 </para>
38549 <literallayout class="monospaced">
38550 command = /some/path ${if eq{$local_part}{postmaster}{xx}{yy}}
38551 </literallayout>
38552 <para>
38553 will not work, because the expansion item gets split between several
38554 arguments. You have to write
38555 </para>
38556 <literallayout class="monospaced">
38557 command = /some/path "${if eq{$local_part}{postmaster}{xx}{yy}}"
38558 </literallayout>
38559 <para revisionflag="changed">
38560 to ensure that it is all in one argument. The expansion is done in this way,
38561 argument by argument, so that the number of arguments cannot be changed as a
38562 result of expansion, and quotes or backslashes in inserted variables do not
38563 interact with external quoting. However, this leads to problems if you want to
38564 generate multiple arguments (or the command name plus arguments) from a single
38565 expansion. In this situation, the simplest solution is to use a shell. For
38566 example:
38567 </para>
38568 <literallayout class="monospaced" revisionflag="changed">
38569 command = /bin/sh -c ${lookup{$local_part}lsearch{/some/file}}
38570 </literallayout>
38571 <para>
38572 <indexterm role="concept">
38573 <primary>transport</primary>
38574 <secondary>filter</secondary>
38575 </indexterm>
38576 <indexterm role="concept">
38577 <primary>filter</primary>
38578 <secondary>transport filter</secondary>
38579 </indexterm>
38580 <indexterm role="concept">
38581 <primary><varname>$pipe_addresses</varname></primary>
38582 </indexterm>
38583 Special handling takes place when an argument consists of precisely the text
38584 <literal>$pipe_addresses</literal>. This is not a general expansion variable; the only
38585 place this string is recognized is when it appears as an argument for a pipe or
38586 transport filter command. It causes each address that is being handled to be
38587 inserted in the argument list at that point <emphasis>as a separate argument</emphasis>. This
38588 avoids any problems with spaces or shell metacharacters, and is of use when a
38589 <command>pipe</command> transport is handling groups of addresses in a batch.
38590 </para>
38591 <para>
38592 After splitting up into arguments and expansion, the resulting command is run
38593 in a subprocess directly from the transport, <emphasis>not</emphasis> under a shell. The
38594 message that is being delivered is supplied on the standard input, and the
38595 standard output and standard error are both connected to a single pipe that is
38596 read by Exim. The <option>max_output</option> option controls how much output the command
38597 may produce, and the <option>return_output</option> and <option>return_fail_output</option> options
38598 control what is done with it.
38599 </para>
38600 <para>
38601 Not running the command under a shell (by default) lessens the security risks
38602 in cases when a command from a user&#x2019;s filter file is built out of data that was
38603 taken from an incoming message. If a shell is required, it can of course be
38604 explicitly specified as the command to be run. However, there are circumstances
38605 where existing commands (for example, in <filename>.forward</filename> files) expect to be run
38606 under a shell and cannot easily be modified. To allow for these cases, there is
38607 an option called <option>use_shell</option>, which changes the way the <command>pipe</command> transport
38608 works. Instead of breaking up the command line as just described, it expands it
38609 as a single string and passes the result to <filename>/bin/sh</filename>. The
38610 <option>restrict_to_path</option> option and the <varname>$pipe_addresses</varname> facility cannot be used
38611 with <option>use_shell</option>, and the whole mechanism is inherently less secure.
38612 </para>
38613 </section>
38614 <section id="SECTpipeenv">
38615 <title>Environment variables</title>
38616 <para>
38617 <indexterm role="concept">
38618 <primary><command>pipe</command> transport</primary>
38619 <secondary>environment for command</secondary>
38620 </indexterm>
38621 <indexterm role="concept">
38622 <primary>environment for pipe transport</primary>
38623 </indexterm>
38624 The environment variables listed below are set up when the command is invoked.
38625 This list is a compromise for maximum compatibility with other MTAs. Note that
38626 the <option>environment</option> option can be used to add additional variables to this
38627 environment.
38628 </para>
38629 <literallayout>
38630 <literal>DOMAIN            </literal>   the domain of the address
38631 <literal>HOME              </literal>   the home directory, if set
38632 <literal>HOST              </literal>   the host name when called from a router (see below)
38633 <literal>LOCAL_PART        </literal>   see below
38634 <literal>LOCAL_PART_PREFIX </literal>   see below
38635 <literal>LOCAL_PART_SUFFIX </literal>   see below
38636 <literal>LOGNAME           </literal>   see below
38637 <literal>MESSAGE_ID        </literal>   Exim&#x2019;s local ID for the message
38638 <literal>PATH              </literal>   as specified by the <option>path</option> option below
38639 <literal>QUALIFY_DOMAIN    </literal>   the sender qualification domain
38640 <literal>RECIPIENT         </literal>   the complete recipient address
38641 <literal>SENDER            </literal>   the sender of the message (empty if a bounce)
38642 <literal>SHELL             </literal>   <literal>/bin/sh</literal>
38643 <literal>TZ                </literal>   the value of the <option>timezone</option> option, if set
38644 <literal>USER              </literal>   see below
38645 </literallayout>
38646 <para>
38647 When a <command>pipe</command> transport is called directly from (for example) an <command>accept</command>
38648 router, LOCAL_PART is set to the local part of the address. When it is
38649 called as a result of a forward or alias expansion, LOCAL_PART is set to
38650 the local part of the address that was expanded. In both cases, any affixes are
38651 removed from the local part, and made available in LOCAL_PART_PREFIX and
38652 LOCAL_PART_SUFFIX, respectively. LOGNAME and USER are set to the
38653 same value as LOCAL_PART for compatibility with other MTAs.
38654 </para>
38655 <para>
38656 <indexterm role="concept">
38657 <primary>HOST</primary>
38658 </indexterm>
38659 HOST is set only when a <command>pipe</command> transport is called from a router that
38660 associates hosts with an address, typically when using <command>pipe</command> as a
38661 pseudo-remote transport. HOST is set to the first host name specified by
38662 the router.
38663 </para>
38664 <para>
38665 <indexterm role="concept">
38666 <primary>HOME</primary>
38667 </indexterm>
38668 If the transport&#x2019;s generic <option>home_directory</option> option is set, its value is used
38669 for the HOME environment variable. Otherwise, a home directory may be set
38670 by the router&#x2019;s <option>transport_home_directory</option> option, which defaults to the
38671 user&#x2019;s home directory if <option>check_local_user</option> is set.
38672 </para>
38673 </section>
38674 <section>
38675 <title>Private options for pipe</title>
38676 <para>
38677 <indexterm role="concept">
38678 <primary>options</primary>
38679 <secondary><command>pipe</command> transport</secondary>
38680 </indexterm>
38681 </para>
38682 <para>
38683 <indexterm role="option">
38684 <primary>allow_commands</primary>
38685 </indexterm>
38686 </para>
38687 <informaltable frame="all">
38688 <tgroup cols="4" colsep="0" rowsep="0">
38689 <colspec colwidth="8*" align="left"/>
38690 <colspec colwidth="5*" align="center"/>
38691 <colspec colwidth="5*" align="center"/>
38692 <colspec colwidth="6*" align="right"/>
38693 <tbody>
38694 <row>
38695 <entry><option>allow_commands</option></entry>
38696 <entry>Use: <emphasis>pipe</emphasis></entry>
38697 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
38698 <entry>Default: <emphasis>unset</emphasis></entry>
38699 </row>
38700 </tbody>
38701 </tgroup>
38702 </informaltable>
38703 <para>
38704 <indexterm role="concept">
38705 <primary><command>pipe</command> transport</primary>
38706 <secondary>permitted commands</secondary>
38707 </indexterm>
38708 The string is expanded, and is then interpreted as a colon-separated list of
38709 permitted commands. If <option>restrict_to_path</option> is not set, the only commands
38710 permitted are those in the <option>allow_commands</option> list. They need not be absolute
38711 paths; the <option>path</option> option is still used for relative paths. If
38712 <option>restrict_to_path</option> is set with <option>allow_commands</option>, the command must either be
38713 in the <option>allow_commands</option> list, or a name without any slashes that is found on
38714 the path. In other words, if neither <option>allow_commands</option> nor
38715 <option>restrict_to_path</option> is set, there is no restriction on the command, but
38716 otherwise only commands that are permitted by one or the other are allowed. For
38717 example, if
38718 </para>
38719 <literallayout class="monospaced">
38720 allow_commands = /usr/bin/vacation
38721 </literallayout>
38722 <para>
38723 and <option>restrict_to_path</option> is not set, the only permitted command is
38724 <filename>/usr/bin/vacation</filename>. The <option>allow_commands</option> option may not be set if
38725 <option>use_shell</option> is set.
38726 </para>
38727 <para>
38728 <indexterm role="option">
38729 <primary>batch_id</primary>
38730 </indexterm>
38731 </para>
38732 <informaltable frame="all">
38733 <tgroup cols="4" colsep="0" rowsep="0">
38734 <colspec colwidth="8*" align="left"/>
38735 <colspec colwidth="5*" align="center"/>
38736 <colspec colwidth="5*" align="center"/>
38737 <colspec colwidth="6*" align="right"/>
38738 <tbody>
38739 <row>
38740 <entry><option>batch_id</option></entry>
38741 <entry>Use: <emphasis>pipe</emphasis></entry>
38742 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38743 <entry>Default: <emphasis>unset</emphasis></entry>
38744 </row>
38745 </tbody>
38746 </tgroup>
38747 </informaltable>
38748 <para>
38749 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
38750 </para>
38751 <para>
38752 <indexterm role="option">
38753 <primary>batch_max</primary>
38754 </indexterm>
38755 </para>
38756 <informaltable frame="all">
38757 <tgroup cols="4" colsep="0" rowsep="0">
38758 <colspec colwidth="8*" align="left"/>
38759 <colspec colwidth="5*" align="center"/>
38760 <colspec colwidth="5*" align="center"/>
38761 <colspec colwidth="6*" align="right"/>
38762 <tbody>
38763 <row>
38764 <entry><option>batch_max</option></entry>
38765 <entry>Use: <emphasis>pipe</emphasis></entry>
38766 <entry>Type: <emphasis>integer</emphasis></entry>
38767 <entry>Default: <emphasis>1</emphasis></entry>
38768 </row>
38769 </tbody>
38770 </tgroup>
38771 </informaltable>
38772 <para>
38773 This limits the number of addresses that can be handled in a single delivery.
38774 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
38775 </para>
38776 <para>
38777 <indexterm role="option">
38778 <primary>check_string</primary>
38779 </indexterm>
38780 </para>
38781 <informaltable frame="all">
38782 <tgroup cols="4" colsep="0" rowsep="0">
38783 <colspec colwidth="8*" align="left"/>
38784 <colspec colwidth="5*" align="center"/>
38785 <colspec colwidth="5*" align="center"/>
38786 <colspec colwidth="6*" align="right"/>
38787 <tbody>
38788 <row>
38789 <entry><option>check_string</option></entry>
38790 <entry>Use: <emphasis>pipe</emphasis></entry>
38791 <entry>Type: <emphasis>string</emphasis></entry>
38792 <entry>Default: <emphasis>unset</emphasis></entry>
38793 </row>
38794 </tbody>
38795 </tgroup>
38796 </informaltable>
38797 <para>
38798 As <command>pipe</command> writes the message, the start of each line is tested for matching
38799 <option>check_string</option>, and if it does, the initial matching characters are replaced
38800 by the contents of <option>escape_string</option>, provided both are set. The value of
38801 <option>check_string</option> is a literal string, not a regular expression, and the case of
38802 any letters it contains is significant. When <option>use_bsmtp</option> is set, the contents
38803 of <option>check_string</option> and <option>escape_string</option> are forced to values that implement
38804 the SMTP escaping protocol. Any settings made in the configuration file are
38805 ignored.
38806 </para>
38807 <para>
38808 <indexterm role="option">
38809 <primary>command</primary>
38810 </indexterm>
38811 </para>
38812 <informaltable frame="all">
38813 <tgroup cols="4" colsep="0" rowsep="0">
38814 <colspec colwidth="8*" align="left"/>
38815 <colspec colwidth="5*" align="center"/>
38816 <colspec colwidth="5*" align="center"/>
38817 <colspec colwidth="6*" align="right"/>
38818 <tbody>
38819 <row>
38820 <entry><option>command</option></entry>
38821 <entry>Use: <emphasis>pipe</emphasis></entry>
38822 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38823 <entry>Default: <emphasis>unset</emphasis></entry>
38824 </row>
38825 </tbody>
38826 </tgroup>
38827 </informaltable>
38828 <para>
38829 This option need not be set when <command>pipe</command> is being used to deliver to pipes
38830 obtained directly from address redirections. In other cases, the option must be
38831 set, to provide a command to be run. It need not yield an absolute path (see
38832 the <option>path</option> option below). The command is split up into separate arguments by
38833 Exim, and each argument is separately expanded, as described in section
38834 <xref linkend="SECThowcommandrun"/> above.
38835 </para>
38836 <para>
38837 <indexterm role="option">
38838 <primary>environment</primary>
38839 </indexterm>
38840 </para>
38841 <informaltable frame="all">
38842 <tgroup cols="4" colsep="0" rowsep="0">
38843 <colspec colwidth="8*" align="left"/>
38844 <colspec colwidth="5*" align="center"/>
38845 <colspec colwidth="5*" align="center"/>
38846 <colspec colwidth="6*" align="right"/>
38847 <tbody>
38848 <row>
38849 <entry><option>environment</option></entry>
38850 <entry>Use: <emphasis>pipe</emphasis></entry>
38851 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38852 <entry>Default: <emphasis>unset</emphasis></entry>
38853 </row>
38854 </tbody>
38855 </tgroup>
38856 </informaltable>
38857 <para>
38858 <indexterm role="concept">
38859 <primary><command>pipe</command> transport</primary>
38860 <secondary>environment for command</secondary>
38861 </indexterm>
38862 <indexterm role="concept">
38863 <primary>environment for <command>pipe</command> transport</primary>
38864 </indexterm>
38865 This option is used to add additional variables to the environment in which the
38866 command runs (see section <xref linkend="SECTpipeenv"/> for the default list). Its value is
38867 a string which is expanded, and then interpreted as a colon-separated list of
38868 environment settings of the form &lt;<emphasis>name</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt;.
38869 </para>
38870 <para>
38871 <indexterm role="option">
38872 <primary>escape_string</primary>
38873 </indexterm>
38874 </para>
38875 <informaltable frame="all">
38876 <tgroup cols="4" colsep="0" rowsep="0">
38877 <colspec colwidth="8*" align="left"/>
38878 <colspec colwidth="5*" align="center"/>
38879 <colspec colwidth="5*" align="center"/>
38880 <colspec colwidth="6*" align="right"/>
38881 <tbody>
38882 <row>
38883 <entry><option>escape_string</option></entry>
38884 <entry>Use: <emphasis>pipe</emphasis></entry>
38885 <entry>Type: <emphasis>string</emphasis></entry>
38886 <entry>Default: <emphasis>unset</emphasis></entry>
38887 </row>
38888 </tbody>
38889 </tgroup>
38890 </informaltable>
38891 <para>
38892 See <option>check_string</option> above.
38893 </para>
38894 <para>
38895 <indexterm role="option">
38896 <primary>freeze_exec_fail</primary>
38897 </indexterm>
38898 </para>
38899 <informaltable frame="all">
38900 <tgroup cols="4" colsep="0" rowsep="0">
38901 <colspec colwidth="8*" align="left"/>
38902 <colspec colwidth="5*" align="center"/>
38903 <colspec colwidth="5*" align="center"/>
38904 <colspec colwidth="6*" align="right"/>
38905 <tbody>
38906 <row>
38907 <entry><option>freeze_exec_fail</option></entry>
38908 <entry>Use: <emphasis>pipe</emphasis></entry>
38909 <entry>Type: <emphasis>boolean</emphasis></entry>
38910 <entry>Default: <emphasis>false</emphasis></entry>
38911 </row>
38912 </tbody>
38913 </tgroup>
38914 </informaltable>
38915 <para>
38916 <indexterm role="concept">
38917 <primary>exec failure</primary>
38918 </indexterm>
38919 <indexterm role="concept">
38920 <primary>failure of exec</primary>
38921 </indexterm>
38922 <indexterm role="concept">
38923 <primary><command>pipe</command> transport</primary>
38924 <secondary>failure of exec</secondary>
38925 </indexterm>
38926 Failure to exec the command in a pipe transport is by default treated like
38927 any other failure while running the command. However, if <option>freeze_exec_fail</option>
38928 is set, failure to exec is treated specially, and causes the message to be
38929 frozen, whatever the setting of <option>ignore_status</option>.
38930 </para>
38931 <para>
38932 <indexterm role="option">
38933 <primary>ignore_status</primary>
38934 </indexterm>
38935 </para>
38936 <informaltable frame="all">
38937 <tgroup cols="4" colsep="0" rowsep="0">
38938 <colspec colwidth="8*" align="left"/>
38939 <colspec colwidth="5*" align="center"/>
38940 <colspec colwidth="5*" align="center"/>
38941 <colspec colwidth="6*" align="right"/>
38942 <tbody>
38943 <row>
38944 <entry><option>ignore_status</option></entry>
38945 <entry>Use: <emphasis>pipe</emphasis></entry>
38946 <entry>Type: <emphasis>boolean</emphasis></entry>
38947 <entry>Default: <emphasis>false</emphasis></entry>
38948 </row>
38949 </tbody>
38950 </tgroup>
38951 </informaltable>
38952 <para>
38953 If this option is true, the status returned by the subprocess that is set up to
38954 run the command is ignored, and Exim behaves as if zero had been returned.
38955 Otherwise, a non-zero status or termination by signal causes an error return
38956 from the transport unless the status value is one of those listed in
38957 <option>temp_errors</option>; these cause the delivery to be deferred and tried again later.
38958 </para>
38959 <para>
38960 <emphasis role="bold">Note</emphasis>: This option does not apply to timeouts, which do not return a status.
38961 See the <option>timeout_defer</option> option for how timeouts are handled.
38962 </para>
38963 <para>
38964 <indexterm role="option">
38965 <primary>log_defer_output</primary>
38966 </indexterm>
38967 </para>
38968 <informaltable frame="all">
38969 <tgroup cols="4" colsep="0" rowsep="0">
38970 <colspec colwidth="8*" align="left"/>
38971 <colspec colwidth="5*" align="center"/>
38972 <colspec colwidth="5*" align="center"/>
38973 <colspec colwidth="6*" align="right"/>
38974 <tbody>
38975 <row>
38976 <entry><option>log_defer_output</option></entry>
38977 <entry>Use: <emphasis>pipe</emphasis></entry>
38978 <entry>Type: <emphasis>boolean</emphasis></entry>
38979 <entry>Default: <emphasis>false</emphasis></entry>
38980 </row>
38981 </tbody>
38982 </tgroup>
38983 </informaltable>
38984 <para>
38985 <indexterm role="concept">
38986 <primary><command>pipe</command> transport</primary>
38987 <secondary>logging output</secondary>
38988 </indexterm>
38989 If this option is set, and the status returned by the command is
38990 one of the codes listed in <option>temp_errors</option> (that is, delivery was deferred),
38991 and any output was produced, the first line of it is written to the main log.
38992 </para>
38993 <para>
38994 <indexterm role="option">
38995 <primary>log_fail_output</primary>
38996 </indexterm>
38997 </para>
38998 <informaltable frame="all">
38999 <tgroup cols="4" colsep="0" rowsep="0">
39000 <colspec colwidth="8*" align="left"/>
39001 <colspec colwidth="5*" align="center"/>
39002 <colspec colwidth="5*" align="center"/>
39003 <colspec colwidth="6*" align="right"/>
39004 <tbody>
39005 <row>
39006 <entry><option>log_fail_output</option></entry>
39007 <entry>Use: <emphasis>pipe</emphasis></entry>
39008 <entry>Type: <emphasis>boolean</emphasis></entry>
39009 <entry>Default: <emphasis>false</emphasis></entry>
39010 </row>
39011 </tbody>
39012 </tgroup>
39013 </informaltable>
39014 <para>
39015 If this option is set, and the command returns any output, and also ends with a
39016 return code that is neither zero nor one of the return codes listed in
39017 <option>temp_errors</option> (that is, the delivery failed), the first line of output is
39018 written to the main log. This option and <option>log_output</option> are mutually exclusive.
39019 Only one of them may be set.
39020 </para>
39021 <para>
39022 <indexterm role="option">
39023 <primary>log_output</primary>
39024 </indexterm>
39025 </para>
39026 <informaltable frame="all">
39027 <tgroup cols="4" colsep="0" rowsep="0">
39028 <colspec colwidth="8*" align="left"/>
39029 <colspec colwidth="5*" align="center"/>
39030 <colspec colwidth="5*" align="center"/>
39031 <colspec colwidth="6*" align="right"/>
39032 <tbody>
39033 <row>
39034 <entry><option>log_output</option></entry>
39035 <entry>Use: <emphasis>pipe</emphasis></entry>
39036 <entry>Type: <emphasis>boolean</emphasis></entry>
39037 <entry>Default: <emphasis>false</emphasis></entry>
39038 </row>
39039 </tbody>
39040 </tgroup>
39041 </informaltable>
39042 <para>
39043 If this option is set and the command returns any output, the first line of
39044 output is written to the main log, whatever the return code. This option and
39045 <option>log_fail_output</option> are mutually exclusive. Only one of them may be set.
39046 </para>
39047 <para>
39048 <indexterm role="option">
39049 <primary>max_output</primary>
39050 </indexterm>
39051 </para>
39052 <informaltable frame="all">
39053 <tgroup cols="4" colsep="0" rowsep="0">
39054 <colspec colwidth="8*" align="left"/>
39055 <colspec colwidth="5*" align="center"/>
39056 <colspec colwidth="5*" align="center"/>
39057 <colspec colwidth="6*" align="right"/>
39058 <tbody>
39059 <row>
39060 <entry><option>max_output</option></entry>
39061 <entry>Use: <emphasis>pipe</emphasis></entry>
39062 <entry>Type: <emphasis>integer</emphasis></entry>
39063 <entry>Default: <emphasis>20K</emphasis></entry>
39064 </row>
39065 </tbody>
39066 </tgroup>
39067 </informaltable>
39068 <para>
39069 This specifies the maximum amount of output that the command may produce on its
39070 standard output and standard error file combined. If the limit is exceeded, the
39071 process running the command is killed. This is intended as a safety measure to
39072 catch runaway processes. The limit is applied independently of the settings of
39073 the options that control what is done with such output (for example,
39074 <option>return_output</option>). Because of buffering effects, the amount of output may
39075 exceed the limit by a small amount before Exim notices.
39076 </para>
39077 <para>
39078 <indexterm role="option">
39079 <primary>message_prefix</primary>
39080 </indexterm>
39081 </para>
39082 <informaltable frame="all">
39083 <tgroup cols="4" colsep="0" rowsep="0">
39084 <colspec colwidth="8*" align="left"/>
39085 <colspec colwidth="5*" align="center"/>
39086 <colspec colwidth="5*" align="center"/>
39087 <colspec colwidth="6*" align="right"/>
39088 <tbody>
39089 <row>
39090 <entry><option>message_prefix</option></entry>
39091 <entry>Use: <emphasis>pipe</emphasis></entry>
39092 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39093 <entry>Default: <emphasis>see below</emphasis></entry>
39094 </row>
39095 </tbody>
39096 </tgroup>
39097 </informaltable>
39098 <para>
39099 The string specified here is expanded and output at the start of every message.
39100 The default is unset if <option>use_bsmtp</option> is set. Otherwise it is
39101 </para>
39102 <literallayout class="monospaced">
39103 message_prefix = \
39104   From ${if def:return_path{$return_path}{MAILER-DAEMON}}\
39105   ${tod_bsdinbox}\n
39106 </literallayout>
39107 <para>
39108 <indexterm role="concept">
39109 <primary>Cyrus</primary>
39110 </indexterm>
39111 <indexterm role="concept">
39112 <primary><option>tmail</option></primary>
39113 </indexterm>
39114 <indexterm role="concept">
39115 <primary><quote>From</quote> line</primary>
39116 </indexterm>
39117 This is required by the commonly used <filename>/usr/bin/vacation</filename> program.
39118 However, it must <emphasis>not</emphasis> be present if delivery is to the Cyrus IMAP server,
39119 or to the <option>tmail</option> local delivery agent. The prefix can be suppressed by
39120 setting
39121 </para>
39122 <literallayout class="monospaced">
39123 message_prefix =
39124 </literallayout>
39125 <para>
39126 <indexterm role="option">
39127 <primary>message_suffix</primary>
39128 </indexterm>
39129 </para>
39130 <informaltable frame="all">
39131 <tgroup cols="4" colsep="0" rowsep="0">
39132 <colspec colwidth="8*" align="left"/>
39133 <colspec colwidth="5*" align="center"/>
39134 <colspec colwidth="5*" align="center"/>
39135 <colspec colwidth="6*" align="right"/>
39136 <tbody>
39137 <row>
39138 <entry><option>message_suffix</option></entry>
39139 <entry>Use: <emphasis>pipe</emphasis></entry>
39140 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39141 <entry>Default: <emphasis>see below</emphasis></entry>
39142 </row>
39143 </tbody>
39144 </tgroup>
39145 </informaltable>
39146 <para>
39147 The string specified here is expanded and output at the end of every message.
39148 The default is unset if <option>use_bsmtp</option> is set. Otherwise it is a single newline.
39149 The suffix can be suppressed by setting
39150 </para>
39151 <literallayout class="monospaced">
39152 message_suffix =
39153 </literallayout>
39154 <para>
39155 <indexterm role="option">
39156 <primary>path</primary>
39157 </indexterm>
39158 </para>
39159 <informaltable frame="all">
39160 <tgroup cols="4" colsep="0" rowsep="0">
39161 <colspec colwidth="8*" align="left"/>
39162 <colspec colwidth="5*" align="center"/>
39163 <colspec colwidth="5*" align="center"/>
39164 <colspec colwidth="6*" align="right"/>
39165 <tbody>
39166 <row>
39167 <entry><option>path</option></entry>
39168 <entry>Use: <emphasis>pipe</emphasis></entry>
39169 <entry>Type: <emphasis>string</emphasis></entry>
39170 <entry>Default: <emphasis><literal>/bin:/usr/bin</literal></emphasis></entry>
39171 </row>
39172 </tbody>
39173 </tgroup>
39174 </informaltable>
39175 <para>
39176 This option specifies the string that is set up in the PATH environment
39177 variable of the subprocess. If the <option>command</option> option does not yield an
39178 absolute path name, the command is sought in the PATH directories, in the usual
39179 way. <emphasis role="bold">Warning</emphasis>: This does not apply to a command specified as a transport
39180 filter.
39181 </para>
39182 <para>
39183 <indexterm role="option">
39184 <primary>pipe_as_creator</primary>
39185 </indexterm>
39186 </para>
39187 <informaltable frame="all">
39188 <tgroup cols="4" colsep="0" rowsep="0">
39189 <colspec colwidth="8*" align="left"/>
39190 <colspec colwidth="5*" align="center"/>
39191 <colspec colwidth="5*" align="center"/>
39192 <colspec colwidth="6*" align="right"/>
39193 <tbody>
39194 <row>
39195 <entry><option>pipe_as_creator</option></entry>
39196 <entry>Use: <emphasis>pipe</emphasis></entry>
39197 <entry>Type: <emphasis>boolean</emphasis></entry>
39198 <entry>Default: <emphasis>false</emphasis></entry>
39199 </row>
39200 </tbody>
39201 </tgroup>
39202 </informaltable>
39203 <para>
39204 <indexterm role="concept">
39205 <primary>uid (user id)</primary>
39206 <secondary>local delivery</secondary>
39207 </indexterm>
39208 If the generic <option>user</option> option is not set and this option is true, the delivery
39209 process is run under the uid that was in force when Exim was originally called
39210 to accept the message. If the group id is not otherwise set (via the generic
39211 <option>group</option> option), the gid that was in force when Exim was originally called to
39212 accept the message is used.
39213 </para>
39214 <para>
39215 <indexterm role="option">
39216 <primary>restrict_to_path</primary>
39217 </indexterm>
39218 </para>
39219 <informaltable frame="all">
39220 <tgroup cols="4" colsep="0" rowsep="0">
39221 <colspec colwidth="8*" align="left"/>
39222 <colspec colwidth="5*" align="center"/>
39223 <colspec colwidth="5*" align="center"/>
39224 <colspec colwidth="6*" align="right"/>
39225 <tbody>
39226 <row>
39227 <entry><option>restrict_to_path</option></entry>
39228 <entry>Use: <emphasis>pipe</emphasis></entry>
39229 <entry>Type: <emphasis>boolean</emphasis></entry>
39230 <entry>Default: <emphasis>false</emphasis></entry>
39231 </row>
39232 </tbody>
39233 </tgroup>
39234 </informaltable>
39235 <para>
39236 When this option is set, any command name not listed in <option>allow_commands</option> must
39237 contain no slashes. The command is searched for only in the directories listed
39238 in the <option>path</option> option. This option is intended for use in the case when a pipe
39239 command has been generated from a user&#x2019;s <filename>.forward</filename> file. This is usually
39240 handled by a <command>pipe</command> transport called <option>address_pipe</option>.
39241 </para>
39242 <para>
39243 <indexterm role="option">
39244 <primary>return_fail_output</primary>
39245 </indexterm>
39246 </para>
39247 <informaltable frame="all">
39248 <tgroup cols="4" colsep="0" rowsep="0">
39249 <colspec colwidth="8*" align="left"/>
39250 <colspec colwidth="5*" align="center"/>
39251 <colspec colwidth="5*" align="center"/>
39252 <colspec colwidth="6*" align="right"/>
39253 <tbody>
39254 <row>
39255 <entry><option>return_fail_output</option></entry>
39256 <entry>Use: <emphasis>pipe</emphasis></entry>
39257 <entry>Type: <emphasis>boolean</emphasis></entry>
39258 <entry>Default: <emphasis>false</emphasis></entry>
39259 </row>
39260 </tbody>
39261 </tgroup>
39262 </informaltable>
39263 <para>
39264 If this option is true, and the command produced any output and ended with a
39265 return code other than zero or one of the codes listed in <option>temp_errors</option> (that
39266 is, the delivery failed), the output is returned in the bounce message.
39267 However, if the message has a null sender (that is, it is itself a bounce
39268 message), output from the command is discarded. This option and
39269 <option>return_output</option> are mutually exclusive. Only one of them may be set.
39270 </para>
39271 <para>
39272 <indexterm role="option">
39273 <primary>return_output</primary>
39274 </indexterm>
39275 </para>
39276 <informaltable frame="all">
39277 <tgroup cols="4" colsep="0" rowsep="0">
39278 <colspec colwidth="8*" align="left"/>
39279 <colspec colwidth="5*" align="center"/>
39280 <colspec colwidth="5*" align="center"/>
39281 <colspec colwidth="6*" align="right"/>
39282 <tbody>
39283 <row>
39284 <entry><option>return_output</option></entry>
39285 <entry>Use: <emphasis>pipe</emphasis></entry>
39286 <entry>Type: <emphasis>boolean</emphasis></entry>
39287 <entry>Default: <emphasis>false</emphasis></entry>
39288 </row>
39289 </tbody>
39290 </tgroup>
39291 </informaltable>
39292 <para>
39293 If this option is true, and the command produced any output, the delivery is
39294 deemed to have failed whatever the return code from the command, and the output
39295 is returned in the bounce message. Otherwise, the output is just discarded.
39296 However, if the message has a null sender (that is, it is a bounce message),
39297 output from the command is always discarded, whatever the setting of this
39298 option. This option and <option>return_fail_output</option> are mutually exclusive. Only one
39299 of them may be set.
39300 </para>
39301 <para>
39302 <indexterm role="option">
39303 <primary>temp_errors</primary>
39304 </indexterm>
39305 </para>
39306 <informaltable frame="all">
39307 <tgroup cols="4" colsep="0" rowsep="0">
39308 <colspec colwidth="8*" align="left"/>
39309 <colspec colwidth="5*" align="center"/>
39310 <colspec colwidth="5*" align="center"/>
39311 <colspec colwidth="6*" align="right"/>
39312 <tbody>
39313 <row>
39314 <entry><option>temp_errors</option></entry>
39315 <entry>Use: <emphasis>pipe</emphasis></entry>
39316 <entry>Type: <emphasis>string list</emphasis></entry>
39317 <entry>Default: <emphasis>see below</emphasis></entry>
39318 </row>
39319 </tbody>
39320 </tgroup>
39321 </informaltable>
39322 <para>
39323 <indexterm role="concept">
39324 <primary><command>pipe</command> transport</primary>
39325 <secondary>temporary failure</secondary>
39326 </indexterm>
39327 This option contains either a colon-separated list of numbers, or a single
39328 asterisk. If <option>ignore_status</option> is false
39329 and <option>return_output</option> is not set,
39330 and the command exits with a non-zero return code, the failure is treated as
39331 temporary and the delivery is deferred if the return code matches one of the
39332 numbers, or if the setting is a single asterisk. Otherwise, non-zero return
39333 codes are treated as permanent errors. The default setting contains the codes
39334 defined by EX_TEMPFAIL and EX_CANTCREAT in <filename>sysexits.h</filename>. If Exim is
39335 compiled on a system that does not define these macros, it assumes values of 75
39336 and 73, respectively.
39337 </para>
39338 <para>
39339 <indexterm role="option">
39340 <primary>timeout</primary>
39341 </indexterm>
39342 </para>
39343 <informaltable frame="all">
39344 <tgroup cols="4" colsep="0" rowsep="0">
39345 <colspec colwidth="8*" align="left"/>
39346 <colspec colwidth="5*" align="center"/>
39347 <colspec colwidth="5*" align="center"/>
39348 <colspec colwidth="6*" align="right"/>
39349 <tbody>
39350 <row>
39351 <entry><option>timeout</option></entry>
39352 <entry>Use: <emphasis>pipe</emphasis></entry>
39353 <entry>Type: <emphasis>time</emphasis></entry>
39354 <entry>Default: <emphasis>1h</emphasis></entry>
39355 </row>
39356 </tbody>
39357 </tgroup>
39358 </informaltable>
39359 <para>
39360 If the command fails to complete within this time, it is killed. This normally
39361 causes the delivery to fail (but see <option>timeout_defer</option>). A zero time interval
39362 specifies no timeout. In order to ensure that any subprocesses created by the
39363 command are also killed, Exim makes the initial process a process group leader,
39364 and kills the whole process group on a timeout. However, this can be defeated
39365 if one of the processes starts a new process group.
39366 </para>
39367 <para>
39368 <indexterm role="option">
39369 <primary>timeout_defer</primary>
39370 </indexterm>
39371 </para>
39372 <informaltable frame="all">
39373 <tgroup cols="4" colsep="0" rowsep="0">
39374 <colspec colwidth="8*" align="left"/>
39375 <colspec colwidth="5*" align="center"/>
39376 <colspec colwidth="5*" align="center"/>
39377 <colspec colwidth="6*" align="right"/>
39378 <tbody>
39379 <row>
39380 <entry><option>timeout_defer</option></entry>
39381 <entry>Use: <emphasis>pipe</emphasis></entry>
39382 <entry>Type: <emphasis>boolean</emphasis></entry>
39383 <entry>Default: <emphasis>false</emphasis></entry>
39384 </row>
39385 </tbody>
39386 </tgroup>
39387 </informaltable>
39388 <para>
39389 A timeout in a <command>pipe</command> transport, either in the command that the transport
39390 runs, or in a transport filter that is associated with it, is by default
39391 treated as a hard error, and the delivery fails. However, if <option>timeout_defer</option>
39392 is set true, both kinds of timeout become temporary errors, causing the
39393 delivery to be deferred.
39394 </para>
39395 <para>
39396 <indexterm role="option">
39397 <primary>umask</primary>
39398 </indexterm>
39399 </para>
39400 <informaltable frame="all">
39401 <tgroup cols="4" colsep="0" rowsep="0">
39402 <colspec colwidth="8*" align="left"/>
39403 <colspec colwidth="5*" align="center"/>
39404 <colspec colwidth="5*" align="center"/>
39405 <colspec colwidth="6*" align="right"/>
39406 <tbody>
39407 <row>
39408 <entry><option>umask</option></entry>
39409 <entry>Use: <emphasis>pipe</emphasis></entry>
39410 <entry>Type: <emphasis>octal integer</emphasis></entry>
39411 <entry>Default: <emphasis>022</emphasis></entry>
39412 </row>
39413 </tbody>
39414 </tgroup>
39415 </informaltable>
39416 <para>
39417 This specifies the umask setting for the subprocess that runs the command.
39418 </para>
39419 <para>
39420 <indexterm role="option">
39421 <primary>use_bsmtp</primary>
39422 </indexterm>
39423 </para>
39424 <informaltable frame="all">
39425 <tgroup cols="4" colsep="0" rowsep="0">
39426 <colspec colwidth="8*" align="left"/>
39427 <colspec colwidth="5*" align="center"/>
39428 <colspec colwidth="5*" align="center"/>
39429 <colspec colwidth="6*" align="right"/>
39430 <tbody>
39431 <row>
39432 <entry><option>use_bsmtp</option></entry>
39433 <entry>Use: <emphasis>pipe</emphasis></entry>
39434 <entry>Type: <emphasis>boolean</emphasis></entry>
39435 <entry>Default: <emphasis>false</emphasis></entry>
39436 </row>
39437 </tbody>
39438 </tgroup>
39439 </informaltable>
39440 <para>
39441 <indexterm role="concept">
39442 <primary>envelope sender</primary>
39443 </indexterm>
39444 If this option is set true, the <command>pipe</command> transport writes messages in <quote>batch
39445 SMTP</quote> format, with the envelope sender and recipient(s) included as SMTP
39446 commands. If you want to include a leading HELO command with such messages,
39447 you can do so by setting the <option>message_prefix</option> option. See section
39448 <xref linkend="SECTbatchSMTP"/> for details of batch SMTP.
39449 </para>
39450 <para revisionflag="changed">
39451 <indexterm role="option">
39452 <primary>use_classresources</primary>
39453 </indexterm>
39454 </para>
39455 <informaltable frame="all" revisionflag="changed">
39456 <tgroup cols="4" colsep="0" rowsep="0">
39457 <colspec colwidth="8*" align="left"/>
39458 <colspec colwidth="5*" align="center"/>
39459 <colspec colwidth="5*" align="center"/>
39460 <colspec colwidth="6*" align="right"/>
39461 <tbody>
39462 <row>
39463 <entry><option>use_classresources</option></entry>
39464 <entry>Use: <emphasis>pipe</emphasis></entry>
39465 <entry>Type: <emphasis>boolean</emphasis></entry>
39466 <entry>Default: <emphasis>false</emphasis></entry>
39467 </row>
39468 </tbody>
39469 </tgroup>
39470 </informaltable>
39471 <para revisionflag="changed">
39472 <indexterm role="concept">
39473 <primary>class resources (BSD)</primary>
39474 </indexterm>
39475 This option is available only when Exim is running on FreeBSD, NetBSD, or
39476 BSD/OS. If it is set true, the <function>setclassresources()</function> function is used to set
39477 resource limits when a <command>pipe</command> transport is run to perform a delivery. The
39478 limits for the uid under which the pipe is to run are obtained from the login
39479 class database.
39480 </para>
39481 <para>
39482 <indexterm role="option">
39483 <primary>use_crlf</primary>
39484 </indexterm>
39485 </para>
39486 <informaltable frame="all">
39487 <tgroup cols="4" colsep="0" rowsep="0">
39488 <colspec colwidth="8*" align="left"/>
39489 <colspec colwidth="5*" align="center"/>
39490 <colspec colwidth="5*" align="center"/>
39491 <colspec colwidth="6*" align="right"/>
39492 <tbody>
39493 <row>
39494 <entry><option>use_crlf</option></entry>
39495 <entry>Use: <emphasis>pipe</emphasis></entry>
39496 <entry>Type: <emphasis>boolean</emphasis></entry>
39497 <entry>Default: <emphasis>false</emphasis></entry>
39498 </row>
39499 </tbody>
39500 </tgroup>
39501 </informaltable>
39502 <para>
39503 <indexterm role="concept">
39504 <primary>carriage return</primary>
39505 </indexterm>
39506 <indexterm role="concept">
39507 <primary>linefeed</primary>
39508 </indexterm>
39509 This option causes lines to be terminated with the two-character CRLF sequence
39510 (carriage return, linefeed) instead of just a linefeed character. In the case
39511 of batched SMTP, the byte sequence written to the pipe is then an exact image
39512 of what would be sent down a real SMTP connection.
39513 </para>
39514 <para>
39515 The contents of the <option>message_prefix</option> and <option>message_suffix</option> options are
39516 written verbatim, so must contain their own carriage return characters if these
39517 are needed. Since the default values for both <option>message_prefix</option> and
39518 <option>message_suffix</option> end with a single linefeed, their values must be changed to
39519 end with <literal>\r\n</literal> if <option>use_crlf</option> is set.
39520 </para>
39521 <para>
39522 <indexterm role="option">
39523 <primary>use_shell</primary>
39524 </indexterm>
39525 </para>
39526 <informaltable frame="all">
39527 <tgroup cols="4" colsep="0" rowsep="0">
39528 <colspec colwidth="8*" align="left"/>
39529 <colspec colwidth="5*" align="center"/>
39530 <colspec colwidth="5*" align="center"/>
39531 <colspec colwidth="6*" align="right"/>
39532 <tbody>
39533 <row>
39534 <entry><option>use_shell</option></entry>
39535 <entry>Use: <emphasis>pipe</emphasis></entry>
39536 <entry>Type: <emphasis>boolean</emphasis></entry>
39537 <entry>Default: <emphasis>false</emphasis></entry>
39538 </row>
39539 </tbody>
39540 </tgroup>
39541 </informaltable>
39542 <para>
39543 <indexterm role="concept">
39544 <primary><varname>$pipe_addresses</varname></primary>
39545 </indexterm>
39546 If this option is set, it causes the command to be passed to <filename>/bin/sh</filename>
39547 instead of being run directly from the transport, as described in section
39548 <xref linkend="SECThowcommandrun"/>. This is less secure, but is needed in some situations
39549 where the command is expected to be run under a shell and cannot easily be
39550 modified. The <option>allow_commands</option> and <option>restrict_to_path</option> options, and the
39551 <literal>$pipe_addresses</literal> facility are incompatible with <option>use_shell</option>. The
39552 command is expanded as a single string, and handed to <filename>/bin/sh</filename> as data for
39553 its <option>-c</option> option.
39554 </para>
39555 </section>
39556 <section>
39557 <title>Using an external local delivery agent</title>
39558 <para>
39559 <indexterm role="concept">
39560 <primary>local delivery</primary>
39561 <secondary>using an external agent</secondary>
39562 </indexterm>
39563 <indexterm role="concept">
39564 <primary><emphasis>procmail</emphasis></primary>
39565 </indexterm>
39566 <indexterm role="concept">
39567 <primary>external local delivery</primary>
39568 </indexterm>
39569 <indexterm role="concept">
39570 <primary>delivery</primary>
39571 <secondary><emphasis>procmail</emphasis></secondary>
39572 </indexterm>
39573 <indexterm role="concept">
39574 <primary>delivery</primary>
39575 <secondary>by external agent</secondary>
39576 </indexterm>
39577 The <command>pipe</command> transport can be used to pass all messages that require local
39578 delivery to a separate local delivery agent such as <option>procmail</option>. When doing
39579 this, care must be taken to ensure that the pipe is run under an appropriate
39580 uid and gid. In some configurations one wants this to be a uid that is trusted
39581 by the delivery agent to supply the correct sender of the message. It may be
39582 necessary to recompile or reconfigure the delivery agent so that it trusts an
39583 appropriate user. The following is an example transport and router
39584 configuration for <option>procmail</option>:
39585 </para>
39586 <literallayout class="monospaced">
39587 # transport
39588 procmail_pipe:
39589   driver = pipe
39590   command = /usr/local/bin/procmail -d $local_part
39591   return_path_add
39592   delivery_date_add
39593   envelope_to_add
39594   check_string = "From "
39595   escape_string = "&gt;From "
39596   user = $local_part
39597   group = mail
39598
39599 # router
39600 procmail:
39601   driver = accept
39602   check_local_user
39603   transport = procmail_pipe
39604 </literallayout>
39605 <para>
39606 In this example, the pipe is run as the local user, but with the group set to
39607 <emphasis>mail</emphasis>. An alternative is to run the pipe as a specific user such as <emphasis>mail</emphasis>
39608 or <emphasis>exim</emphasis>, but in this case you must arrange for <option>procmail</option> to trust that
39609 user to supply a correct sender address. If you do not specify either a
39610 <option>group</option> or a <option>user</option> option, the pipe command is run as the local user. The
39611 home directory is the user&#x2019;s home directory by default.
39612 </para>
39613 <para>
39614 <emphasis role="bold">Note</emphasis>: The command that the pipe transport runs does <emphasis>not</emphasis> begin with
39615 </para>
39616 <literallayout class="monospaced">
39617 IFS=" "
39618 </literallayout>
39619 <para>
39620 as shown in some <option>procmail</option> documentation, because Exim does not by default
39621 use a shell to run pipe commands.
39622 </para>
39623 <para>
39624 <indexterm role="concept">
39625 <primary>Cyrus</primary>
39626 </indexterm>
39627 The next example shows a transport and a router for a system where local
39628 deliveries are handled by the Cyrus IMAP server.
39629 </para>
39630 <literallayout class="monospaced">
39631 # transport
39632 local_delivery_cyrus:
39633   driver = pipe
39634   command = /usr/cyrus/bin/deliver \
39635             -m ${substr_1:$local_part_suffix} -- $local_part
39636   user = cyrus
39637   group = mail
39638   return_output
39639   log_output
39640   message_prefix =
39641   message_suffix =
39642
39643 # router
39644 local_user_cyrus:
39645   driver = accept
39646   check_local_user
39647   local_part_suffix = .*
39648   transport = local_delivery_cyrus
39649 </literallayout>
39650 <para>
39651 Note the unsetting of <option>message_prefix</option> and <option>message_suffix</option>, and the use of
39652 <option>return_output</option> to cause any text written by Cyrus to be returned to the
39653 sender.
39654 <indexterm role="concept" startref="IIDpiptra1" class="endofrange"/>
39655 <indexterm role="concept" startref="IIDpiptra2" class="endofrange"/>
39656 </para>
39657 </section>
39658 </chapter>
39659
39660 <chapter id="CHAPsmtptrans">
39661 <title>The smtp transport</title>
39662 <para>
39663 <indexterm role="concept" id="IIDsmttra1" class="startofrange">
39664 <primary>transports</primary>
39665 <secondary><command>smtp</command></secondary>
39666 </indexterm>
39667 <indexterm role="concept" id="IIDsmttra2" class="startofrange">
39668 <primary><command>smtp</command> transport</primary>
39669 </indexterm>
39670 The <command>smtp</command> transport delivers messages over TCP/IP connections using the SMTP
39671 or LMTP protocol. The list of hosts to try can either be taken from the address
39672 that is being processed (having been set up by the router), or specified
39673 explicitly for the transport. Timeout and retry processing (see chapter
39674 <xref linkend="CHAPretry"/>) is applied to each IP address independently.
39675 </para>
39676 <section>
39677 <title>Multiple messages on a single connection</title>
39678 <para>
39679 The sending of multiple messages over a single TCP/IP connection can arise in
39680 two ways:
39681 </para>
39682 <itemizedlist>
39683 <listitem>
39684 <para>
39685 If a message contains more than <option>max_rcpt</option> (see below) addresses that are
39686 routed to the same host, more than one copy of the message has to be sent to
39687 that host. In this situation, multiple copies may be sent in a single run of
39688 the <command>smtp</command> transport over a single TCP/IP connection. (What Exim actually
39689 does when it has too many addresses to send in one message also depends on the
39690 value of the global <option>remote_max_parallel</option> option. Details are given in
39691 section <xref linkend="SECToutSMTPTCP"/>.)
39692 </para>
39693 </listitem>
39694 <listitem>
39695 <para>
39696 <indexterm role="concept">
39697 <primary>hints database</primary>
39698 <secondary>remembering routing</secondary>
39699 </indexterm>
39700 When a message has been successfully delivered over a TCP/IP connection, Exim
39701 looks in its hints database to see if there are any other messages awaiting a
39702 connection to the same host. If there are, a new delivery process is started
39703 for one of them, and the current TCP/IP connection is passed on to it. The new
39704 process may in turn send multiple copies and possibly create yet another
39705 process.
39706 </para>
39707 </listitem>
39708 </itemizedlist>
39709 <para>
39710 For each copy sent over the same TCP/IP connection, a sequence counter is
39711 incremented, and if it ever gets to the value of <option>connection_max_messages</option>,
39712 no further messages are sent over that connection.
39713 </para>
39714 </section>
39715 <section>
39716 <title>Use of the $host variable</title>
39717 <para>
39718 <indexterm role="concept">
39719 <primary><varname>$host</varname></primary>
39720 </indexterm>
39721 <indexterm role="concept">
39722 <primary><varname>$host_address</varname></primary>
39723 </indexterm>
39724 At the start of a run of the <command>smtp</command> transport, the values of <varname>$host</varname> and
39725 <varname>$host_address</varname> are the name and IP address of the first host on the host list
39726 passed by the router. However, when the transport is about to connect to a
39727 specific host, and while it is connected to that host, <varname>$host</varname> and
39728 <varname>$host_address</varname> are set to the values for that host. These are the values
39729 that are in force when the <option>helo_data</option>, <option>hosts_try_auth</option>, <option>interface</option>,
39730 <option>serialize_hosts</option>, and the various TLS options are expanded.
39731 </para>
39732 </section>
39733 <section>
39734 <title>Private options for smtp</title>
39735 <para>
39736 <indexterm role="concept">
39737 <primary>options</primary>
39738 <secondary><command>smtp</command> transport</secondary>
39739 </indexterm>
39740 The private options of the <command>smtp</command> transport are as follows:
39741 </para>
39742 <para>
39743 <indexterm role="option">
39744 <primary>allow_localhost</primary>
39745 </indexterm>
39746 </para>
39747 <informaltable frame="all">
39748 <tgroup cols="4" colsep="0" rowsep="0">
39749 <colspec colwidth="8*" align="left"/>
39750 <colspec colwidth="5*" align="center"/>
39751 <colspec colwidth="5*" align="center"/>
39752 <colspec colwidth="6*" align="right"/>
39753 <tbody>
39754 <row>
39755 <entry><option>allow_localhost</option></entry>
39756 <entry>Use: <emphasis>smtp</emphasis></entry>
39757 <entry>Type: <emphasis>boolean</emphasis></entry>
39758 <entry>Default: <emphasis>false</emphasis></entry>
39759 </row>
39760 </tbody>
39761 </tgroup>
39762 </informaltable>
39763 <para>
39764 <indexterm role="concept">
39765 <primary>local host</primary>
39766 <secondary>sending to</secondary>
39767 </indexterm>
39768 <indexterm role="concept">
39769 <primary>fallback</primary>
39770 <secondary>hosts specified on transport</secondary>
39771 </indexterm>
39772 When a host specified in <option>hosts</option> or <option>fallback_hosts</option> (see below) turns out
39773 to be the local host, or is listed in <option>hosts_treat_as_local</option>, delivery is
39774 deferred by default. However, if <option>allow_localhost</option> is set, Exim goes on to do
39775 the delivery anyway. This should be used only in special cases when the
39776 configuration ensures that no looping will result (for example, a differently
39777 configured Exim is listening on the port to which the message is sent).
39778 </para>
39779 <para>
39780 <indexterm role="option">
39781 <primary>authenticated_sender</primary>
39782 </indexterm>
39783 </para>
39784 <informaltable frame="all">
39785 <tgroup cols="4" colsep="0" rowsep="0">
39786 <colspec colwidth="8*" align="left"/>
39787 <colspec colwidth="5*" align="center"/>
39788 <colspec colwidth="5*" align="center"/>
39789 <colspec colwidth="6*" align="right"/>
39790 <tbody>
39791 <row>
39792 <entry><option>authenticated_sender</option></entry>
39793 <entry>Use: <emphasis>smtp</emphasis></entry>
39794 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39795 <entry>Default: <emphasis>unset</emphasis></entry>
39796 </row>
39797 </tbody>
39798 </tgroup>
39799 </informaltable>
39800 <para>
39801 <indexterm role="concept">
39802 <primary>Cyrus</primary>
39803 </indexterm>
39804 </para>
39805 <para revisionflag="changed">
39806 When Exim has authenticated as a client, or if <option>authenticated_sender_force</option>
39807 is true, this option sets a value for the AUTH= item on outgoing MAIL commands,
39808 overriding any existing authenticated sender value. If the string expansion is
39809 forced to fail, the option is ignored. Other expansion failures cause delivery
39810 to be deferred. If the result of expansion is an empty string, that is also
39811 ignored.
39812 </para>
39813 <para revisionflag="changed">
39814 If the SMTP session is not authenticated, the expansion of
39815 <option>authenticated_sender</option> still happens (and can cause the delivery to be
39816 deferred if it fails), but no AUTH= item is added to MAIL commands
39817 unless <option>authenticated_sender_force</option> is true.
39818 </para>
39819 <para>
39820 This option allows you to use the <command>smtp</command> transport in LMTP mode to
39821 deliver mail to Cyrus IMAP and provide the proper local part as the
39822 <quote>authenticated sender</quote>, via a setting such as:
39823 </para>
39824 <literallayout class="monospaced">
39825 authenticated_sender = $local_part
39826 </literallayout>
39827 <para>
39828 This removes the need for IMAP subfolders to be assigned special ACLs to
39829 allow direct delivery to those subfolders.
39830 </para>
39831 <para>
39832 Because of expected uses such as that just described for Cyrus (when no
39833 domain is involved), there is no checking on the syntax of the provided
39834 value.
39835 </para>
39836 <para revisionflag="changed">
39837 <indexterm role="option">
39838 <primary>authenticated_sender_force</primary>
39839 </indexterm>
39840 </para>
39841 <informaltable frame="all" revisionflag="changed">
39842 <tgroup cols="4" colsep="0" rowsep="0">
39843 <colspec colwidth="8*" align="left"/>
39844 <colspec colwidth="5*" align="center"/>
39845 <colspec colwidth="5*" align="center"/>
39846 <colspec colwidth="6*" align="right"/>
39847 <tbody>
39848 <row>
39849 <entry><option>authenticated_sender_force</option></entry>
39850 <entry>Use: <emphasis>smtp</emphasis></entry>
39851 <entry>Type: <emphasis>boolean</emphasis></entry>
39852 <entry>Default: <emphasis>false</emphasis></entry>
39853 </row>
39854 </tbody>
39855 </tgroup>
39856 </informaltable>
39857 <para revisionflag="changed">
39858 If this option is set true, the <option>authenticated_sender</option> option&#x2019;s value
39859 is used for the AUTH= item on outgoing MAIL commands, even if Exim has not
39860 authenticated as a client.
39861 </para>
39862 <para>
39863 <indexterm role="option">
39864 <primary>command_timeout</primary>
39865 </indexterm>
39866 </para>
39867 <informaltable frame="all">
39868 <tgroup cols="4" colsep="0" rowsep="0">
39869 <colspec colwidth="8*" align="left"/>
39870 <colspec colwidth="5*" align="center"/>
39871 <colspec colwidth="5*" align="center"/>
39872 <colspec colwidth="6*" align="right"/>
39873 <tbody>
39874 <row>
39875 <entry><option>command_timeout</option></entry>
39876 <entry>Use: <emphasis>smtp</emphasis></entry>
39877 <entry>Type: <emphasis>time</emphasis></entry>
39878 <entry>Default: <emphasis>5m</emphasis></entry>
39879 </row>
39880 </tbody>
39881 </tgroup>
39882 </informaltable>
39883 <para>
39884 This sets a timeout for receiving a response to an SMTP command that has been
39885 sent out. It is also used when waiting for the initial banner line from the
39886 remote host. Its value must not be zero.
39887 </para>
39888 <para>
39889 <indexterm role="option">
39890 <primary>connect_timeout</primary>
39891 </indexterm>
39892 </para>
39893 <informaltable frame="all">
39894 <tgroup cols="4" colsep="0" rowsep="0">
39895 <colspec colwidth="8*" align="left"/>
39896 <colspec colwidth="5*" align="center"/>
39897 <colspec colwidth="5*" align="center"/>
39898 <colspec colwidth="6*" align="right"/>
39899 <tbody>
39900 <row>
39901 <entry><option>connect_timeout</option></entry>
39902 <entry>Use: <emphasis>smtp</emphasis></entry>
39903 <entry>Type: <emphasis>time</emphasis></entry>
39904 <entry>Default: <emphasis>5m</emphasis></entry>
39905 </row>
39906 </tbody>
39907 </tgroup>
39908 </informaltable>
39909 <para>
39910 This sets a timeout for the <function>connect()</function> function, which sets up a TCP/IP call
39911 to a remote host. A setting of zero allows the system timeout (typically
39912 several minutes) to act. To have any effect, the value of this option must be
39913 less than the system timeout. However, it has been observed that on some
39914 systems there is no system timeout, which is why the default value for this
39915 option is 5 minutes, a value recommended by RFC 1123.
39916 </para>
39917 <para>
39918 <indexterm role="option">
39919 <primary>connection_max_messages</primary>
39920 </indexterm>
39921 </para>
39922 <informaltable frame="all">
39923 <tgroup cols="4" colsep="0" rowsep="0">
39924 <colspec colwidth="8*" align="left"/>
39925 <colspec colwidth="5*" align="center"/>
39926 <colspec colwidth="5*" align="center"/>
39927 <colspec colwidth="6*" align="right"/>
39928 <tbody>
39929 <row>
39930 <entry><option>connection_max_messages</option></entry>
39931 <entry>Use: <emphasis>smtp</emphasis></entry>
39932 <entry>Type: <emphasis>integer</emphasis></entry>
39933 <entry>Default: <emphasis>500</emphasis></entry>
39934 </row>
39935 </tbody>
39936 </tgroup>
39937 </informaltable>
39938 <para>
39939 <indexterm role="concept">
39940 <primary>SMTP</primary>
39941 <secondary>passed connection</secondary>
39942 </indexterm>
39943 <indexterm role="concept">
39944 <primary>SMTP</primary>
39945 <secondary>multiple deliveries</secondary>
39946 </indexterm>
39947 <indexterm role="concept">
39948 <primary>multiple SMTP deliveries</primary>
39949 </indexterm>
39950 This controls the maximum number of separate message deliveries that are sent
39951 over a single TCP/IP connection. If the value is zero, there is no limit.
39952 For testing purposes, this value can be overridden by the <option>-oB</option> command line
39953 option.
39954 </para>
39955 <para>
39956 <indexterm role="option">
39957 <primary>data_timeout</primary>
39958 </indexterm>
39959 </para>
39960 <informaltable frame="all">
39961 <tgroup cols="4" colsep="0" rowsep="0">
39962 <colspec colwidth="8*" align="left"/>
39963 <colspec colwidth="5*" align="center"/>
39964 <colspec colwidth="5*" align="center"/>
39965 <colspec colwidth="6*" align="right"/>
39966 <tbody>
39967 <row>
39968 <entry><option>data_timeout</option></entry>
39969 <entry>Use: <emphasis>smtp</emphasis></entry>
39970 <entry>Type: <emphasis>time</emphasis></entry>
39971 <entry>Default: <emphasis>5m</emphasis></entry>
39972 </row>
39973 </tbody>
39974 </tgroup>
39975 </informaltable>
39976 <para>
39977 This sets a timeout for the transmission of each block in the data portion of
39978 the message. As a result, the overall timeout for a message depends on the size
39979 of the message. Its value must not be zero. See also <option>final_timeout</option>.
39980 </para>
39981 <para>
39982 <indexterm role="option">
39983 <primary>delay_after_cutoff</primary>
39984 </indexterm>
39985 </para>
39986 <informaltable frame="all">
39987 <tgroup cols="4" colsep="0" rowsep="0">
39988 <colspec colwidth="8*" align="left"/>
39989 <colspec colwidth="5*" align="center"/>
39990 <colspec colwidth="5*" align="center"/>
39991 <colspec colwidth="6*" align="right"/>
39992 <tbody>
39993 <row>
39994 <entry><option>delay_after_cutoff</option></entry>
39995 <entry>Use: <emphasis>smtp</emphasis></entry>
39996 <entry>Type: <emphasis>boolean</emphasis></entry>
39997 <entry>Default: <emphasis>true</emphasis></entry>
39998 </row>
39999 </tbody>
40000 </tgroup>
40001 </informaltable>
40002 <para>
40003 This option controls what happens when all remote IP addresses for a given
40004 domain have been inaccessible for so long that they have passed their retry
40005 cutoff times.
40006 </para>
40007 <para>
40008 In the default state, if the next retry time has not been reached for any of
40009 them, the address is bounced without trying any deliveries. In other words,
40010 Exim delays retrying an IP address after the final cutoff time until a new
40011 retry time is reached, and can therefore bounce an address without ever trying
40012 a delivery, when machines have been down for a long time. Some people are
40013 unhappy at this prospect, so...
40014 </para>
40015 <para>
40016 If <option>delay_after_cutoff</option> is set false, Exim behaves differently. If all IP
40017 addresses are past their final cutoff time, Exim tries to deliver to those
40018 IP addresses that have not been tried since the message arrived. If there are
40019 none, of if they all fail, the address is bounced. In other words, it does not
40020 delay when a new message arrives, but immediately tries those expired IP
40021 addresses that haven&#x2019;t been tried since the message arrived. If there is a
40022 continuous stream of messages for the dead hosts, unsetting
40023 <option>delay_after_cutoff</option> means that there will be many more attempts to deliver
40024 to them.
40025 </para>
40026 <para>
40027 <indexterm role="option">
40028 <primary>dns_qualify_single</primary>
40029 </indexterm>
40030 </para>
40031 <informaltable frame="all">
40032 <tgroup cols="4" colsep="0" rowsep="0">
40033 <colspec colwidth="8*" align="left"/>
40034 <colspec colwidth="5*" align="center"/>
40035 <colspec colwidth="5*" align="center"/>
40036 <colspec colwidth="6*" align="right"/>
40037 <tbody>
40038 <row>
40039 <entry><option>dns_qualify_single</option></entry>
40040 <entry>Use: <emphasis>smtp</emphasis></entry>
40041 <entry>Type: <emphasis>boolean</emphasis></entry>
40042 <entry>Default: <emphasis>true</emphasis></entry>
40043 </row>
40044 </tbody>
40045 </tgroup>
40046 </informaltable>
40047 <para>
40048 If the <option>hosts</option> or <option>fallback_hosts</option> option is being used,
40049 and the <option>gethostbyname</option> option is false,
40050 the RES_DEFNAMES resolver option is set. See the <option>qualify_single</option> option
40051 in chapter <xref linkend="CHAPdnslookup"/> for more details.
40052 </para>
40053 <para>
40054 <indexterm role="option">
40055 <primary>dns_search_parents</primary>
40056 </indexterm>
40057 </para>
40058 <informaltable frame="all">
40059 <tgroup cols="4" colsep="0" rowsep="0">
40060 <colspec colwidth="8*" align="left"/>
40061 <colspec colwidth="5*" align="center"/>
40062 <colspec colwidth="5*" align="center"/>
40063 <colspec colwidth="6*" align="right"/>
40064 <tbody>
40065 <row>
40066 <entry><option>dns_search_parents</option></entry>
40067 <entry>Use: <emphasis>smtp</emphasis></entry>
40068 <entry>Type: <emphasis>boolean</emphasis></entry>
40069 <entry>Default: <emphasis>false</emphasis></entry>
40070 </row>
40071 </tbody>
40072 </tgroup>
40073 </informaltable>
40074 <para>
40075 <indexterm role="concept">
40076 <primary><option>search_parents</option></primary>
40077 </indexterm>
40078 If the <option>hosts</option> or <option>fallback_hosts</option> option is being used, and the
40079 <option>gethostbyname</option> option is false, the RES_DNSRCH resolver option is set.
40080 See the <option>search_parents</option> option in chapter <xref linkend="CHAPdnslookup"/> for more
40081 details.
40082 </para>
40083 <para>
40084 <indexterm role="option">
40085 <primary>fallback_hosts</primary>
40086 </indexterm>
40087 </para>
40088 <informaltable frame="all">
40089 <tgroup cols="4" colsep="0" rowsep="0">
40090 <colspec colwidth="8*" align="left"/>
40091 <colspec colwidth="5*" align="center"/>
40092 <colspec colwidth="5*" align="center"/>
40093 <colspec colwidth="6*" align="right"/>
40094 <tbody>
40095 <row>
40096 <entry><option>fallback_hosts</option></entry>
40097 <entry>Use: <emphasis>smtp</emphasis></entry>
40098 <entry>Type: <emphasis>string list</emphasis></entry>
40099 <entry>Default: <emphasis>unset</emphasis></entry>
40100 </row>
40101 </tbody>
40102 </tgroup>
40103 </informaltable>
40104 <para>
40105 <indexterm role="concept">
40106 <primary>fallback</primary>
40107 <secondary>hosts specified on transport</secondary>
40108 </indexterm>
40109 String expansion is not applied to this option. The argument must be a
40110 colon-separated list of host names or IP addresses, optionally also including
40111 port numbers, though the separator can be changed, as described in section
40112 <xref linkend="SECTlistconstruct"/>. Each individual item in the list is the same as an
40113 item in a <option>route_list</option> setting for the <command>manualroute</command> router, as described
40114 in section <xref linkend="SECTformatonehostitem"/>.
40115 </para>
40116 <para>
40117 Fallback hosts can also be specified on routers, which associate them with the
40118 addresses they process. As for the <option>hosts</option> option without <option>hosts_override</option>,
40119 <option>fallback_hosts</option> specified on the transport is used only if the address does
40120 not have its own associated fallback host list. Unlike <option>hosts</option>, a setting of
40121 <option>fallback_hosts</option> on an address is not overridden by <option>hosts_override</option>.
40122 However, <option>hosts_randomize</option> does apply to fallback host lists.
40123 </para>
40124 <para>
40125 If Exim is unable to deliver to any of the hosts for a particular address, and
40126 the errors are not permanent rejections, the address is put on a separate
40127 transport queue with its host list replaced by the fallback hosts, unless the
40128 address was routed via MX records and the current host was in the original MX
40129 list. In that situation, the fallback host list is not used.
40130 </para>
40131 <para>
40132 Once normal deliveries are complete, the fallback queue is delivered by
40133 re-running the same transports with the new host lists. If several failing
40134 addresses have the same fallback hosts (and <option>max_rcpt</option> permits it), a single
40135 copy of the message is sent.
40136 </para>
40137 <para>
40138 The resolution of the host names on the fallback list is controlled by the
40139 <option>gethostbyname</option> option, as for the <option>hosts</option> option. Fallback hosts apply
40140 both to cases when the host list comes with the address and when it is taken
40141 from <option>hosts</option>. This option provides a <quote>use a smart host only if delivery
40142 fails</quote> facility.
40143 </para>
40144 <para>
40145 <indexterm role="option">
40146 <primary>final_timeout</primary>
40147 </indexterm>
40148 </para>
40149 <informaltable frame="all">
40150 <tgroup cols="4" colsep="0" rowsep="0">
40151 <colspec colwidth="8*" align="left"/>
40152 <colspec colwidth="5*" align="center"/>
40153 <colspec colwidth="5*" align="center"/>
40154 <colspec colwidth="6*" align="right"/>
40155 <tbody>
40156 <row>
40157 <entry><option>final_timeout</option></entry>
40158 <entry>Use: <emphasis>smtp</emphasis></entry>
40159 <entry>Type: <emphasis>time</emphasis></entry>
40160 <entry>Default: <emphasis>10m</emphasis></entry>
40161 </row>
40162 </tbody>
40163 </tgroup>
40164 </informaltable>
40165 <para>
40166 This is the timeout that applies while waiting for the response to the final
40167 line containing just <quote>.</quote> that terminates a message. Its value must not be
40168 zero.
40169 </para>
40170 <para>
40171 <indexterm role="option">
40172 <primary>gethostbyname</primary>
40173 </indexterm>
40174 </para>
40175 <informaltable frame="all">
40176 <tgroup cols="4" colsep="0" rowsep="0">
40177 <colspec colwidth="8*" align="left"/>
40178 <colspec colwidth="5*" align="center"/>
40179 <colspec colwidth="5*" align="center"/>
40180 <colspec colwidth="6*" align="right"/>
40181 <tbody>
40182 <row>
40183 <entry><option>gethostbyname</option></entry>
40184 <entry>Use: <emphasis>smtp</emphasis></entry>
40185 <entry>Type: <emphasis>boolean</emphasis></entry>
40186 <entry>Default: <emphasis>false</emphasis></entry>
40187 </row>
40188 </tbody>
40189 </tgroup>
40190 </informaltable>
40191 <para>
40192 If this option is true when the <option>hosts</option> and/or <option>fallback_hosts</option> options are
40193 being used, names are looked up using <function>gethostbyname()</function>
40194 (or <function>getipnodebyname()</function> when available)
40195 instead of using the DNS. Of course, that function may in fact use the DNS, but
40196 it may also consult other sources of information such as <filename>/etc/hosts</filename>.
40197 </para>
40198 <para>
40199 <indexterm role="option">
40200 <primary>helo_data</primary>
40201 </indexterm>
40202 </para>
40203 <informaltable frame="all">
40204 <tgroup cols="4" colsep="0" rowsep="0">
40205 <colspec colwidth="8*" align="left"/>
40206 <colspec colwidth="5*" align="center"/>
40207 <colspec colwidth="5*" align="center"/>
40208 <colspec colwidth="6*" align="right"/>
40209 <tbody>
40210 <row>
40211 <entry><option>helo_data</option></entry>
40212 <entry>Use: <emphasis>smtp</emphasis></entry>
40213 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40214 <entry>Default: <emphasis><literal>$primary_hostname</literal></emphasis></entry>
40215 </row>
40216 </tbody>
40217 </tgroup>
40218 </informaltable>
40219 <para>
40220 <indexterm role="concept">
40221 <primary>HELO argument</primary>
40222 <secondary>setting</secondary>
40223 </indexterm>
40224 <indexterm role="concept">
40225 <primary>EHLO argument</primary>
40226 <secondary>setting</secondary>
40227 </indexterm>
40228 The value of this option is expanded, and used as the argument for the EHLO or
40229 HELO command that starts the outgoing SMTP session. The variables <varname>$host</varname> and
40230 <varname>$host_address</varname> are set to the identity of the remote host, and can be used to
40231 generate different values for different servers.
40232 </para>
40233 <para>
40234 <indexterm role="option">
40235 <primary>hosts</primary>
40236 </indexterm>
40237 </para>
40238 <informaltable frame="all">
40239 <tgroup cols="4" colsep="0" rowsep="0">
40240 <colspec colwidth="8*" align="left"/>
40241 <colspec colwidth="5*" align="center"/>
40242 <colspec colwidth="5*" align="center"/>
40243 <colspec colwidth="6*" align="right"/>
40244 <tbody>
40245 <row>
40246 <entry><option>hosts</option></entry>
40247 <entry>Use: <emphasis>smtp</emphasis></entry>
40248 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
40249 <entry>Default: <emphasis>unset</emphasis></entry>
40250 </row>
40251 </tbody>
40252 </tgroup>
40253 </informaltable>
40254 <para>
40255 Hosts are associated with an address by a router such as <command>dnslookup</command>, which
40256 finds the hosts by looking up the address domain in the DNS, or by
40257 <command>manualroute</command>, which has lists of hosts in its configuration. However,
40258 email addresses can be passed to the <command>smtp</command> transport by any router, and not
40259 all of them can provide an associated list of hosts.
40260 </para>
40261 <para>
40262 The <option>hosts</option> option specifies a list of hosts to be used if the address being
40263 processed does not have any hosts associated with it. The hosts specified by
40264 <option>hosts</option> are also used, whether or not the address has its own hosts, if
40265 <option>hosts_override</option> is set.
40266 </para>
40267 <para>
40268 The string is first expanded, before being interpreted as a colon-separated
40269 list of host names or IP addresses, possibly including port numbers. The
40270 separator may be changed to something other than colon, as described in section
40271 <xref linkend="SECTlistconstruct"/>. Each individual item in the list is the same as an
40272 item in a <option>route_list</option> setting for the <command>manualroute</command> router, as described
40273 in section <xref linkend="SECTformatonehostitem"/>. However, note that the <literal>/MX</literal> facility
40274 of the <command>manualroute</command> router is not available here.
40275 </para>
40276 <para>
40277 If the expansion fails, delivery is deferred. Unless the failure was caused by
40278 the inability to complete a lookup, the error is logged to the panic log as
40279 well as the main log. Host names are looked up either by searching directly for
40280 address records in the DNS or by calling <function>gethostbyname()</function> (or
40281 <function>getipnodebyname()</function> when available), depending on the setting of the
40282 <option>gethostbyname</option> option. When Exim is compiled with IPv6 support, if a host
40283 that is looked up in the DNS has both IPv4 and IPv6 addresses, both types of
40284 address are used.
40285 </para>
40286 <para>
40287 During delivery, the hosts are tried in order, subject to their retry status,
40288 unless <option>hosts_randomize</option> is set.
40289 </para>
40290 <para>
40291 <indexterm role="option">
40292 <primary>hosts_avoid_esmtp</primary>
40293 </indexterm>
40294 </para>
40295 <informaltable frame="all">
40296 <tgroup cols="4" colsep="0" rowsep="0">
40297 <colspec colwidth="8*" align="left"/>
40298 <colspec colwidth="5*" align="center"/>
40299 <colspec colwidth="5*" align="center"/>
40300 <colspec colwidth="6*" align="right"/>
40301 <tbody>
40302 <row>
40303 <entry><option>hosts_avoid_esmtp</option></entry>
40304 <entry>Use: <emphasis>smtp</emphasis></entry>
40305 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
40306 <entry>Default: <emphasis>unset</emphasis></entry>
40307 </row>
40308 </tbody>
40309 </tgroup>
40310 </informaltable>
40311 <para>
40312 <indexterm role="concept">
40313 <primary>ESMTP</primary>
40314 <secondary>avoiding use of</secondary>
40315 </indexterm>
40316 <indexterm role="concept">
40317 <primary>HELO</primary>
40318 <secondary>forcing use of</secondary>
40319 </indexterm>
40320 <indexterm role="concept">
40321 <primary>EHLO</primary>
40322 <secondary>avoiding use of</secondary>
40323 </indexterm>
40324 <indexterm role="concept">
40325 <primary>PIPELINING</primary>
40326 <secondary>avoiding the use of</secondary>
40327 </indexterm>
40328 This option is for use with broken hosts that announce ESMTP facilities (for
40329 example, PIPELINING) and then fail to implement them properly. When a host
40330 matches <option>hosts_avoid_esmtp</option>, Exim sends HELO rather than EHLO at the
40331 start of the SMTP session. This means that it cannot use any of the ESMTP
40332 facilities such as AUTH, PIPELINING, SIZE, and STARTTLS.
40333 </para>
40334 <para>
40335 <indexterm role="option">
40336 <primary>hosts_avoid_tls</primary>
40337 </indexterm>
40338 </para>
40339 <informaltable frame="all">
40340 <tgroup cols="4" colsep="0" rowsep="0">
40341 <colspec colwidth="8*" align="left"/>
40342 <colspec colwidth="5*" align="center"/>
40343 <colspec colwidth="5*" align="center"/>
40344 <colspec colwidth="6*" align="right"/>
40345 <tbody>
40346 <row>
40347 <entry><option>hosts_avoid_tls</option></entry>
40348 <entry>Use: <emphasis>smtp</emphasis></entry>
40349 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
40350 <entry>Default: <emphasis>unset</emphasis></entry>
40351 </row>
40352 </tbody>
40353 </tgroup>
40354 </informaltable>
40355 <para>
40356 <indexterm role="concept">
40357 <primary>TLS</primary>
40358 <secondary>avoiding for certain hosts</secondary>
40359 </indexterm>
40360 Exim will not try to start a TLS session when delivering to any host that
40361 matches this list. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
40362 </para>
40363 <para>
40364 <indexterm role="option">
40365 <primary>hosts_max_try</primary>
40366 </indexterm>
40367 </para>
40368 <informaltable frame="all">
40369 <tgroup cols="4" colsep="0" rowsep="0">
40370 <colspec colwidth="8*" align="left"/>
40371 <colspec colwidth="5*" align="center"/>
40372 <colspec colwidth="5*" align="center"/>
40373 <colspec colwidth="6*" align="right"/>
40374 <tbody>
40375 <row>
40376 <entry><option>hosts_max_try</option></entry>
40377 <entry>Use: <emphasis>smtp</emphasis></entry>
40378 <entry>Type: <emphasis>integer</emphasis></entry>
40379 <entry>Default: <emphasis>5</emphasis></entry>
40380 </row>
40381 </tbody>
40382 </tgroup>
40383 </informaltable>
40384 <para>
40385 <indexterm role="concept">
40386 <primary>host</primary>
40387 <secondary>maximum number to try</secondary>
40388 </indexterm>
40389 <indexterm role="concept">
40390 <primary>limit</primary>
40391 <secondary>number of hosts tried</secondary>
40392 </indexterm>
40393 <indexterm role="concept">
40394 <primary>limit</primary>
40395 <secondary>number of MX tried</secondary>
40396 </indexterm>
40397 <indexterm role="concept">
40398 <primary>MX record</primary>
40399 <secondary>maximum tried</secondary>
40400 </indexterm>
40401 This option limits the number of IP addresses that are tried for any one
40402 delivery in cases where there are temporary delivery errors. Section
40403 <xref linkend="SECTvalhosmax"/> describes in detail how the value of this option is used.
40404 </para>
40405 <para>
40406 <indexterm role="option">
40407 <primary>hosts_max_try_hardlimit</primary>
40408 </indexterm>
40409 </para>
40410 <informaltable frame="all">
40411 <tgroup cols="4" colsep="0" rowsep="0">
40412 <colspec colwidth="8*" align="left"/>
40413 <colspec colwidth="5*" align="center"/>
40414 <colspec colwidth="5*" align="center"/>
40415 <colspec colwidth="6*" align="right"/>
40416 <tbody>
40417 <row>
40418 <entry><option>hosts_max_try_hardlimit</option></entry>
40419 <entry>Use: <emphasis>smtp</emphasis></entry>
40420 <entry>Type: <emphasis>integer</emphasis></entry>
40421 <entry>Default: <emphasis>50</emphasis></entry>
40422 </row>
40423 </tbody>
40424 </tgroup>
40425 </informaltable>
40426 <para>
40427 This is an additional check on the maximum number of IP addresses that Exim
40428 tries for any one delivery. Section <xref linkend="SECTvalhosmax"/> describes its use and
40429 why it exists.
40430 </para>
40431 <para>
40432 <indexterm role="option">
40433 <primary>hosts_nopass_tls</primary>
40434 </indexterm>
40435 </para>
40436 <informaltable frame="all">
40437 <tgroup cols="4" colsep="0" rowsep="0">
40438 <colspec colwidth="8*" align="left"/>
40439 <colspec colwidth="5*" align="center"/>
40440 <colspec colwidth="5*" align="center"/>
40441 <colspec colwidth="6*" align="right"/>
40442 <tbody>
40443 <row>
40444 <entry><option>hosts_nopass_tls</option></entry>
40445 <entry>Use: <emphasis>smtp</emphasis></entry>
40446 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
40447 <entry>Default: <emphasis>unset</emphasis></entry>
40448 </row>
40449 </tbody>
40450 </tgroup>
40451 </informaltable>
40452 <para>
40453 <indexterm role="concept">
40454 <primary>TLS</primary>
40455 <secondary>passing connection</secondary>
40456 </indexterm>
40457 <indexterm role="concept">
40458 <primary>multiple SMTP deliveries</primary>
40459 </indexterm>
40460 <indexterm role="concept">
40461 <primary>TLS</primary>
40462 <secondary>multiple message deliveries</secondary>
40463 </indexterm>
40464 For any host that matches this list, a connection on which a TLS session has
40465 been started will not be passed to a new delivery process for sending another
40466 message on the same connection. See section <xref linkend="SECTmulmessam"/> for an
40467 explanation of when this might be needed.
40468 </para>
40469 <para>
40470 <indexterm role="option">
40471 <primary>hosts_override</primary>
40472 </indexterm>
40473 </para>
40474 <informaltable frame="all">
40475 <tgroup cols="4" colsep="0" rowsep="0">
40476 <colspec colwidth="8*" align="left"/>
40477 <colspec colwidth="5*" align="center"/>
40478 <colspec colwidth="5*" align="center"/>
40479 <colspec colwidth="6*" align="right"/>
40480 <tbody>
40481 <row>
40482 <entry><option>hosts_override</option></entry>
40483 <entry>Use: <emphasis>smtp</emphasis></entry>
40484 <entry>Type: <emphasis>boolean</emphasis></entry>
40485 <entry>Default: <emphasis>false</emphasis></entry>
40486 </row>
40487 </tbody>
40488 </tgroup>
40489 </informaltable>
40490 <para>
40491 If this option is set and the <option>hosts</option> option is also set, any hosts that are
40492 attached to the address are ignored, and instead the hosts specified by the
40493 <option>hosts</option> option are always used. This option does not apply to
40494 <option>fallback_hosts</option>.
40495 </para>
40496 <para>
40497 <indexterm role="option">
40498 <primary>hosts_randomize</primary>
40499 </indexterm>
40500 </para>
40501 <informaltable frame="all">
40502 <tgroup cols="4" colsep="0" rowsep="0">
40503 <colspec colwidth="8*" align="left"/>
40504 <colspec colwidth="5*" align="center"/>
40505 <colspec colwidth="5*" align="center"/>
40506 <colspec colwidth="6*" align="right"/>
40507 <tbody>
40508 <row>
40509 <entry><option>hosts_randomize</option></entry>
40510 <entry>Use: <emphasis>smtp</emphasis></entry>
40511 <entry>Type: <emphasis>boolean</emphasis></entry>
40512 <entry>Default: <emphasis>false</emphasis></entry>
40513 </row>
40514 </tbody>
40515 </tgroup>
40516 </informaltable>
40517 <para>
40518 <indexterm role="concept">
40519 <primary>randomized host list</primary>
40520 </indexterm>
40521 <indexterm role="concept">
40522 <primary>host</primary>
40523 <secondary>list of; randomized</secondary>
40524 </indexterm>
40525 <indexterm role="concept">
40526 <primary>fallback</primary>
40527 <secondary>randomized hosts</secondary>
40528 </indexterm>
40529 If this option is set, and either the list of hosts is taken from the
40530 <option>hosts</option> or the <option>fallback_hosts</option> option, or the hosts supplied by the router
40531 were not obtained from MX records (this includes fallback hosts from the
40532 router), and were not randomizied by the router, the order of trying the hosts
40533 is randomized each time the transport runs. Randomizing the order of a host
40534 list can be used to do crude load sharing.
40535 </para>
40536 <para>
40537 When <option>hosts_randomize</option> is true, a host list may be split into groups whose
40538 order is separately randomized. This makes it possible to set up MX-like
40539 behaviour. The boundaries between groups are indicated by an item that is just
40540 <literal>+</literal> in the host list. For example:
40541 </para>
40542 <literallayout class="monospaced">
40543 hosts = host1:host2:host3:+:host4:host5
40544 </literallayout>
40545 <para>
40546 The order of the first three hosts and the order of the last two hosts is
40547 randomized for each use, but the first three always end up before the last two.
40548 If <option>hosts_randomize</option> is not set, a <literal>+</literal> item in the list is ignored.
40549 </para>
40550 <para>
40551 <indexterm role="option">
40552 <primary>hosts_require_auth</primary>
40553 </indexterm>
40554 </para>
40555 <informaltable frame="all">
40556 <tgroup cols="4" colsep="0" rowsep="0">
40557 <colspec colwidth="8*" align="left"/>
40558 <colspec colwidth="5*" align="center"/>
40559 <colspec colwidth="5*" align="center"/>
40560 <colspec colwidth="6*" align="right"/>
40561 <tbody>
40562 <row>
40563 <entry><option>hosts_require_auth</option></entry>
40564 <entry>Use: <emphasis>smtp</emphasis></entry>
40565 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
40566 <entry>Default: <emphasis>unset</emphasis></entry>
40567 </row>
40568 </tbody>
40569 </tgroup>
40570 </informaltable>
40571 <para>
40572 <indexterm role="concept">
40573 <primary>authentication</primary>
40574 <secondary>required by client</secondary>
40575 </indexterm>
40576 This option provides a list of servers for which authentication must succeed
40577 before Exim will try to transfer a message. If authentication fails for
40578 servers which are not in this list, Exim tries to send unauthenticated. If
40579 authentication fails for one of these servers, delivery is deferred. This
40580 temporary error is detectable in the retry rules, so it can be turned into a
40581 hard failure if required. See also <option>hosts_try_auth</option>, and chapter
40582 <xref linkend="CHAPSMTPAUTH"/> for details of authentication.
40583 </para>
40584 <para>
40585 <indexterm role="option">
40586 <primary>hosts_require_tls</primary>
40587 </indexterm>
40588 </para>
40589 <informaltable frame="all">
40590 <tgroup cols="4" colsep="0" rowsep="0">
40591 <colspec colwidth="8*" align="left"/>
40592 <colspec colwidth="5*" align="center"/>
40593 <colspec colwidth="5*" align="center"/>
40594 <colspec colwidth="6*" align="right"/>
40595 <tbody>
40596 <row>
40597 <entry><option>hosts_require_tls</option></entry>
40598 <entry>Use: <emphasis>smtp</emphasis></entry>
40599 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
40600 <entry>Default: <emphasis>unset</emphasis></entry>
40601 </row>
40602 </tbody>
40603 </tgroup>
40604 </informaltable>
40605 <para>
40606 <indexterm role="concept">
40607 <primary>TLS</primary>
40608 <secondary>requiring for certain servers</secondary>
40609 </indexterm>
40610 Exim will insist on using a TLS session when delivering to any host that
40611 matches this list. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
40612 <emphasis role="bold">Note</emphasis>: This option affects outgoing mail only. To insist on TLS for
40613 incoming messages, use an appropriate ACL.
40614 </para>
40615 <para>
40616 <indexterm role="option">
40617 <primary>hosts_try_auth</primary>
40618 </indexterm>
40619 </para>
40620 <informaltable frame="all">
40621 <tgroup cols="4" colsep="0" rowsep="0">
40622 <colspec colwidth="8*" align="left"/>
40623 <colspec colwidth="5*" align="center"/>
40624 <colspec colwidth="5*" align="center"/>
40625 <colspec colwidth="6*" align="right"/>
40626 <tbody>
40627 <row>
40628 <entry><option>hosts_try_auth</option></entry>
40629 <entry>Use: <emphasis>smtp</emphasis></entry>
40630 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
40631 <entry>Default: <emphasis>unset</emphasis></entry>
40632 </row>
40633 </tbody>
40634 </tgroup>
40635 </informaltable>
40636 <para>
40637 <indexterm role="concept">
40638 <primary>authentication</primary>
40639 <secondary>optional in client</secondary>
40640 </indexterm>
40641 This option provides a list of servers to which, provided they announce
40642 authentication support, Exim will attempt to authenticate as a client when it
40643 connects. If authentication fails, Exim will try to transfer the message
40644 unauthenticated. See also <option>hosts_require_auth</option>, and chapter
40645 <xref linkend="CHAPSMTPAUTH"/> for details of authentication.
40646 </para>
40647 <para>
40648 <indexterm role="option">
40649 <primary>interface</primary>
40650 </indexterm>
40651 </para>
40652 <informaltable frame="all">
40653 <tgroup cols="4" colsep="0" rowsep="0">
40654 <colspec colwidth="8*" align="left"/>
40655 <colspec colwidth="5*" align="center"/>
40656 <colspec colwidth="5*" align="center"/>
40657 <colspec colwidth="6*" align="right"/>
40658 <tbody>
40659 <row>
40660 <entry><option>interface</option></entry>
40661 <entry>Use: <emphasis>smtp</emphasis></entry>
40662 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
40663 <entry>Default: <emphasis>unset</emphasis></entry>
40664 </row>
40665 </tbody>
40666 </tgroup>
40667 </informaltable>
40668 <para>
40669 <indexterm role="concept">
40670 <primary>bind IP address</primary>
40671 </indexterm>
40672 <indexterm role="concept">
40673 <primary>IP address</primary>
40674 <secondary>binding</secondary>
40675 </indexterm>
40676 <indexterm role="concept">
40677 <primary><varname>$host</varname></primary>
40678 </indexterm>
40679 <indexterm role="concept">
40680 <primary><varname>$host_address</varname></primary>
40681 </indexterm>
40682 This option specifies which interface to bind to when making an outgoing SMTP
40683 call. The variables <varname>$host</varname> and <varname>$host_address</varname> refer to the host to which a
40684 connection is about to be made during the expansion of the string. Forced
40685 expansion failure, or an empty string result causes the option to be ignored.
40686 Otherwise, after expansion,
40687 the string must be a list of IP addresses, colon-separated by default, but the
40688 separator can be changed in the usual way.
40689 For example:
40690 </para>
40691 <literallayout class="monospaced">
40692 interface = &lt;; 192.168.123.123 ; 3ffe:ffff:836f::fe86:a061
40693 </literallayout>
40694 <para>
40695 The first interface of the correct type (IPv4 or IPv6) is used for the outgoing
40696 connection. If none of them are the correct type, the option is ignored. If
40697 <option>interface</option> is not set, or is ignored, the system&#x2019;s IP functions choose which
40698 interface to use if the host has more than one.
40699 </para>
40700 <para>
40701 <indexterm role="option">
40702 <primary>keepalive</primary>
40703 </indexterm>
40704 </para>
40705 <informaltable frame="all">
40706 <tgroup cols="4" colsep="0" rowsep="0">
40707 <colspec colwidth="8*" align="left"/>
40708 <colspec colwidth="5*" align="center"/>
40709 <colspec colwidth="5*" align="center"/>
40710 <colspec colwidth="6*" align="right"/>
40711 <tbody>
40712 <row>
40713 <entry><option>keepalive</option></entry>
40714 <entry>Use: <emphasis>smtp</emphasis></entry>
40715 <entry>Type: <emphasis>boolean</emphasis></entry>
40716 <entry>Default: <emphasis>true</emphasis></entry>
40717 </row>
40718 </tbody>
40719 </tgroup>
40720 </informaltable>
40721 <para>
40722 <indexterm role="concept">
40723 <primary>keepalive</primary>
40724 <secondary>on outgoing connection</secondary>
40725 </indexterm>
40726 This option controls the setting of SO_KEEPALIVE on outgoing TCP/IP socket
40727 connections. When set, it causes the kernel to probe idle connections
40728 periodically, by sending packets with <quote>old</quote> sequence numbers. The other end
40729 of the connection should send a acknowledgement if the connection is still okay
40730 or a reset if the connection has been aborted. The reason for doing this is
40731 that it has the beneficial effect of freeing up certain types of connection
40732 that can get stuck when the remote host is disconnected without tidying up the
40733 TCP/IP call properly. The keepalive mechanism takes several hours to detect
40734 unreachable hosts.
40735 </para>
40736 <para>
40737 <indexterm role="option">
40738 <primary>lmtp_ignore_quota</primary>
40739 </indexterm>
40740 </para>
40741 <informaltable frame="all">
40742 <tgroup cols="4" colsep="0" rowsep="0">
40743 <colspec colwidth="8*" align="left"/>
40744 <colspec colwidth="5*" align="center"/>
40745 <colspec colwidth="5*" align="center"/>
40746 <colspec colwidth="6*" align="right"/>
40747 <tbody>
40748 <row>
40749 <entry><option>lmtp_ignore_quota</option></entry>
40750 <entry>Use: <emphasis>smtp</emphasis></entry>
40751 <entry>Type: <emphasis>boolean</emphasis></entry>
40752 <entry>Default: <emphasis>false</emphasis></entry>
40753 </row>
40754 </tbody>
40755 </tgroup>
40756 </informaltable>
40757 <para>
40758 <indexterm role="concept">
40759 <primary>LMTP</primary>
40760 <secondary>ignoring quota errors</secondary>
40761 </indexterm>
40762 If this option is set true when the <option>protocol</option> option is set to <quote>lmtp</quote>, the
40763 string <literal>IGNOREQUOTA</literal> is added to RCPT commands, provided that the LMTP server
40764 has advertised support for IGNOREQUOTA in its response to the LHLO command.
40765 </para>
40766 <para>
40767 <indexterm role="option">
40768 <primary>max_rcpt</primary>
40769 </indexterm>
40770 </para>
40771 <informaltable frame="all">
40772 <tgroup cols="4" colsep="0" rowsep="0">
40773 <colspec colwidth="8*" align="left"/>
40774 <colspec colwidth="5*" align="center"/>
40775 <colspec colwidth="5*" align="center"/>
40776 <colspec colwidth="6*" align="right"/>
40777 <tbody>
40778 <row>
40779 <entry><option>max_rcpt</option></entry>
40780 <entry>Use: <emphasis>smtp</emphasis></entry>
40781 <entry>Type: <emphasis>integer</emphasis></entry>
40782 <entry>Default: <emphasis>100</emphasis></entry>
40783 </row>
40784 </tbody>
40785 </tgroup>
40786 </informaltable>
40787 <para>
40788 <indexterm role="concept">
40789 <primary>RCPT</primary>
40790 <secondary>maximum number of outgoing</secondary>
40791 </indexterm>
40792 This option limits the number of RCPT commands that are sent in a single
40793 SMTP message transaction. Each set of addresses is treated independently, and
40794 so can cause parallel connections to the same host if <option>remote_max_parallel</option>
40795 permits this.
40796 </para>
40797 <para>
40798 <indexterm role="option">
40799 <primary>multi_domain</primary>
40800 </indexterm>
40801 </para>
40802 <informaltable frame="all">
40803 <tgroup cols="4" colsep="0" rowsep="0">
40804 <colspec colwidth="8*" align="left"/>
40805 <colspec colwidth="5*" align="center"/>
40806 <colspec colwidth="5*" align="center"/>
40807 <colspec colwidth="6*" align="right"/>
40808 <tbody>
40809 <row>
40810 <entry><option>multi_domain</option></entry>
40811 <entry>Use: <emphasis>smtp</emphasis></entry>
40812 <entry>Type: <emphasis>boolean</emphasis></entry>
40813 <entry>Default: <emphasis>true</emphasis></entry>
40814 </row>
40815 </tbody>
40816 </tgroup>
40817 </informaltable>
40818 <para>
40819 <indexterm role="concept">
40820 <primary><varname>$domain</varname></primary>
40821 </indexterm>
40822 When this option is set, the <command>smtp</command> transport can handle a number of
40823 addresses containing a mixture of different domains provided they all resolve
40824 to the same list of hosts. Turning the option off restricts the transport to
40825 handling only one domain at a time. This is useful if you want to use
40826 <varname>$domain</varname> in an expansion for the transport, because it is set only when there
40827 is a single domain involved in a remote delivery.
40828 </para>
40829 <para>
40830 <indexterm role="option">
40831 <primary>port</primary>
40832 </indexterm>
40833 </para>
40834 <informaltable frame="all">
40835 <tgroup cols="4" colsep="0" rowsep="0">
40836 <colspec colwidth="8*" align="left"/>
40837 <colspec colwidth="5*" align="center"/>
40838 <colspec colwidth="5*" align="center"/>
40839 <colspec colwidth="6*" align="right"/>
40840 <tbody>
40841 <row>
40842 <entry><option>port</option></entry>
40843 <entry>Use: <emphasis>smtp</emphasis></entry>
40844 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40845 <entry>Default: <emphasis>see below</emphasis></entry>
40846 </row>
40847 </tbody>
40848 </tgroup>
40849 </informaltable>
40850 <para>
40851 <indexterm role="concept">
40852 <primary>port</primary>
40853 <secondary>sending TCP/IP</secondary>
40854 </indexterm>
40855 <indexterm role="concept">
40856 <primary>TCP/IP</primary>
40857 <secondary>setting outgoing port</secondary>
40858 </indexterm>
40859 This option specifies the TCP/IP port on the server to which Exim connects. If
40860 it begins with a digit it is taken as a port number; otherwise it is looked up
40861 using <function>getservbyname()</function>. The default value is normally <quote>smtp</quote>, but if
40862 <option>protocol</option> is set to <quote>lmtp</quote>, the default is <quote>lmtp</quote>.
40863 If the expansion fails, or if a port number cannot be found, delivery is
40864 deferred.
40865 </para>
40866 <para>
40867 <indexterm role="option">
40868 <primary>protocol</primary>
40869 </indexterm>
40870 </para>
40871 <informaltable frame="all">
40872 <tgroup cols="4" colsep="0" rowsep="0">
40873 <colspec colwidth="8*" align="left"/>
40874 <colspec colwidth="5*" align="center"/>
40875 <colspec colwidth="5*" align="center"/>
40876 <colspec colwidth="6*" align="right"/>
40877 <tbody>
40878 <row>
40879 <entry><option>protocol</option></entry>
40880 <entry>Use: <emphasis>smtp</emphasis></entry>
40881 <entry>Type: <emphasis>string</emphasis></entry>
40882 <entry>Default: <emphasis>smtp</emphasis></entry>
40883 </row>
40884 </tbody>
40885 </tgroup>
40886 </informaltable>
40887 <para>
40888 <indexterm role="concept">
40889 <primary>LMTP</primary>
40890 <secondary>over TCP/IP</secondary>
40891 </indexterm>
40892 If this option is set to <quote>lmtp</quote> instead of <quote>smtp</quote>, the default value for
40893 the <option>port</option> option changes to <quote>lmtp</quote>, and the transport operates the LMTP
40894 protocol (RFC 2033) instead of SMTP. This protocol is sometimes used for local
40895 deliveries into closed message stores. Exim also has support for running LMTP
40896 over a pipe to a local process &ndash; see chapter <xref linkend="CHAPLMTP"/>.
40897 </para>
40898 <para>
40899 <indexterm role="option">
40900 <primary>retry_include_ip_address</primary>
40901 </indexterm>
40902 </para>
40903 <informaltable frame="all">
40904 <tgroup cols="4" colsep="0" rowsep="0">
40905 <colspec colwidth="8*" align="left"/>
40906 <colspec colwidth="5*" align="center"/>
40907 <colspec colwidth="5*" align="center"/>
40908 <colspec colwidth="6*" align="right"/>
40909 <tbody>
40910 <row>
40911 <entry><option>retry_include_ip_address</option></entry>
40912 <entry>Use: <emphasis>smtp</emphasis></entry>
40913 <entry>Type: <emphasis>boolean</emphasis></entry>
40914 <entry>Default: <emphasis>true</emphasis></entry>
40915 </row>
40916 </tbody>
40917 </tgroup>
40918 </informaltable>
40919 <para>
40920 Exim normally includes both the host name and the IP address in the key it
40921 constructs for indexing retry data after a temporary delivery failure. This
40922 means that when one of several IP addresses for a host is failing, it gets
40923 tried periodically (controlled by the retry rules), but use of the other IP
40924 addresses is not affected.
40925 </para>
40926 <para>
40927 However, in some dialup environments hosts are assigned a different IP address
40928 each time they connect. In this situation the use of the IP address as part of
40929 the retry key leads to undesirable behaviour. Setting this option false causes
40930 Exim to use only the host name. This should normally be done on a separate
40931 instance of the <command>smtp</command> transport, set up specially to handle the dialup
40932 hosts.
40933 </para>
40934 <para>
40935 <indexterm role="option">
40936 <primary>serialize_hosts</primary>
40937 </indexterm>
40938 </para>
40939 <informaltable frame="all">
40940 <tgroup cols="4" colsep="0" rowsep="0">
40941 <colspec colwidth="8*" align="left"/>
40942 <colspec colwidth="5*" align="center"/>
40943 <colspec colwidth="5*" align="center"/>
40944 <colspec colwidth="6*" align="right"/>
40945 <tbody>
40946 <row>
40947 <entry><option>serialize_hosts</option></entry>
40948 <entry>Use: <emphasis>smtp</emphasis></entry>
40949 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
40950 <entry>Default: <emphasis>unset</emphasis></entry>
40951 </row>
40952 </tbody>
40953 </tgroup>
40954 </informaltable>
40955 <para>
40956 <indexterm role="concept">
40957 <primary>serializing connections</primary>
40958 </indexterm>
40959 <indexterm role="concept">
40960 <primary>host</primary>
40961 <secondary>serializing connections</secondary>
40962 </indexterm>
40963 Because Exim operates in a distributed manner, if several messages for the same
40964 host arrive at around the same time, more than one simultaneous connection to
40965 the remote host can occur. This is not usually a problem except when there is a
40966 slow link between the hosts. In that situation it may be helpful to restrict
40967 Exim to one connection at a time. This can be done by setting
40968 <option>serialize_hosts</option> to match the relevant hosts.
40969 </para>
40970 <para>
40971 <indexterm role="concept">
40972 <primary>hints database</primary>
40973 <secondary>serializing deliveries to a host</secondary>
40974 </indexterm>
40975 Exim implements serialization by means of a hints database in which a record is
40976 written whenever a process connects to one of the restricted hosts. The record
40977 is deleted when the connection is completed. Obviously there is scope for
40978 records to get left lying around if there is a system or program crash. To
40979 guard against this, Exim ignores any records that are more than six hours old.
40980 </para>
40981 <para>
40982 If you set up this kind of serialization, you should also arrange to delete the
40983 relevant hints database whenever your system reboots. The names of the files
40984 start with <filename>misc</filename> and they are kept in the <filename>spool/db</filename> directory. There
40985 may be one or two files, depending on the type of DBM in use. The same files
40986 are used for ETRN serialization.
40987 </para>
40988 <para>
40989 <indexterm role="option">
40990 <primary>size_addition</primary>
40991 </indexterm>
40992 </para>
40993 <informaltable frame="all">
40994 <tgroup cols="4" colsep="0" rowsep="0">
40995 <colspec colwidth="8*" align="left"/>
40996 <colspec colwidth="5*" align="center"/>
40997 <colspec colwidth="5*" align="center"/>
40998 <colspec colwidth="6*" align="right"/>
40999 <tbody>
41000 <row>
41001 <entry><option>size_addition</option></entry>
41002 <entry>Use: <emphasis>smtp</emphasis></entry>
41003 <entry>Type: <emphasis>integer</emphasis></entry>
41004 <entry>Default: <emphasis>1024</emphasis></entry>
41005 </row>
41006 </tbody>
41007 </tgroup>
41008 </informaltable>
41009 <para>
41010 <indexterm role="concept">
41011 <primary>SMTP</primary>
41012 <secondary>SIZE</secondary>
41013 </indexterm>
41014 <indexterm role="concept">
41015 <primary>message</primary>
41016 <secondary>size issue for transport filter</secondary>
41017 </indexterm>
41018 <indexterm role="concept">
41019 <primary>size</primary>
41020 <secondary>of message</secondary>
41021 </indexterm>
41022 <indexterm role="concept">
41023 <primary>transport</primary>
41024 <secondary>filter</secondary>
41025 </indexterm>
41026 <indexterm role="concept">
41027 <primary>filter</primary>
41028 <secondary>transport filter</secondary>
41029 </indexterm>
41030 If a remote SMTP server indicates that it supports the SIZE option of the
41031 MAIL command, Exim uses this to pass over the message size at the start of
41032 an SMTP transaction. It adds the value of <option>size_addition</option> to the value it
41033 sends, to allow for headers and other text that may be added during delivery by
41034 configuration options or in a transport filter. It may be necessary to increase
41035 this if a lot of text is added to messages.
41036 </para>
41037 <para>
41038 Alternatively, if the value of <option>size_addition</option> is set negative, it disables
41039 the use of the SIZE option altogether.
41040 </para>
41041 <para>
41042 <indexterm role="option">
41043 <primary>tls_certificate</primary>
41044 </indexterm>
41045 </para>
41046 <informaltable frame="all">
41047 <tgroup cols="4" colsep="0" rowsep="0">
41048 <colspec colwidth="8*" align="left"/>
41049 <colspec colwidth="5*" align="center"/>
41050 <colspec colwidth="5*" align="center"/>
41051 <colspec colwidth="6*" align="right"/>
41052 <tbody>
41053 <row>
41054 <entry><option>tls_certificate</option></entry>
41055 <entry>Use: <emphasis>smtp</emphasis></entry>
41056 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
41057 <entry>Default: <emphasis>unset</emphasis></entry>
41058 </row>
41059 </tbody>
41060 </tgroup>
41061 </informaltable>
41062 <para>
41063 <indexterm role="concept">
41064 <primary>TLS client certificate</primary>
41065 <secondary>location of</secondary>
41066 </indexterm>
41067 <indexterm role="concept">
41068 <primary>certificate for client</primary>
41069 <secondary>location of</secondary>
41070 </indexterm>
41071 <indexterm role="concept">
41072 <primary><varname>$host</varname></primary>
41073 </indexterm>
41074 <indexterm role="concept">
41075 <primary><varname>$host_address</varname></primary>
41076 </indexterm>
41077 The value of this option must be the absolute path to a file which contains the
41078 client&#x2019;s certificate, for possible use when sending a message over an encrypted
41079 connection. The values of <varname>$host</varname> and <varname>$host_address</varname> are set to the name and
41080 address of the server during the expansion. See chapter <xref linkend="CHAPTLS"/> for
41081 details of TLS.
41082 </para>
41083 <para>
41084 <emphasis role="bold">Note</emphasis>: This option must be set if you want Exim to be able to use a TLS
41085 certificate when sending messages as a client. The global option of the same
41086 name specifies the certificate for Exim as a server; it is not automatically
41087 assumed that the same certificate should be used when Exim is operating as a
41088 client.
41089 </para>
41090 <para>
41091 <indexterm role="option">
41092 <primary>tls_crl</primary>
41093 </indexterm>
41094 </para>
41095 <informaltable frame="all">
41096 <tgroup cols="4" colsep="0" rowsep="0">
41097 <colspec colwidth="8*" align="left"/>
41098 <colspec colwidth="5*" align="center"/>
41099 <colspec colwidth="5*" align="center"/>
41100 <colspec colwidth="6*" align="right"/>
41101 <tbody>
41102 <row>
41103 <entry><option>tls_crl</option></entry>
41104 <entry>Use: <emphasis>smtp</emphasis></entry>
41105 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
41106 <entry>Default: <emphasis>unset</emphasis></entry>
41107 </row>
41108 </tbody>
41109 </tgroup>
41110 </informaltable>
41111 <para>
41112 <indexterm role="concept">
41113 <primary>TLS</primary>
41114 <secondary>client certificate revocation list</secondary>
41115 </indexterm>
41116 <indexterm role="concept">
41117 <primary>certificate</primary>
41118 <secondary>revocation list for client</secondary>
41119 </indexterm>
41120 This option specifies a certificate revocation list. The expanded value must
41121 be the name of a file that contains a CRL in PEM format.
41122 </para>
41123 <para>
41124 <indexterm role="option">
41125 <primary>tls_privatekey</primary>
41126 </indexterm>
41127 </para>
41128 <informaltable frame="all">
41129 <tgroup cols="4" colsep="0" rowsep="0">
41130 <colspec colwidth="8*" align="left"/>
41131 <colspec colwidth="5*" align="center"/>
41132 <colspec colwidth="5*" align="center"/>
41133 <colspec colwidth="6*" align="right"/>
41134 <tbody>
41135 <row>
41136 <entry><option>tls_privatekey</option></entry>
41137 <entry>Use: <emphasis>smtp</emphasis></entry>
41138 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
41139 <entry>Default: <emphasis>unset</emphasis></entry>
41140 </row>
41141 </tbody>
41142 </tgroup>
41143 </informaltable>
41144 <para>
41145 <indexterm role="concept">
41146 <primary>TLS client private key</primary>
41147 <secondary>location of</secondary>
41148 </indexterm>
41149 <indexterm role="concept">
41150 <primary><varname>$host</varname></primary>
41151 </indexterm>
41152 <indexterm role="concept">
41153 <primary><varname>$host_address</varname></primary>
41154 </indexterm>
41155 </para>
41156 <para revisionflag="changed">
41157 The value of this option must be the absolute path to a file which contains the
41158 client&#x2019;s private key. This is used when sending a message over an encrypted
41159 connection using a client certificate. The values of <varname>$host</varname> and
41160 <varname>$host_address</varname> are set to the name and address of the server during the
41161 expansion. If this option is unset, or the expansion is forced to fail, or the
41162 result is an empty string, the private key is assumed to be in the same file as
41163 the certificate. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
41164 </para>
41165 <para>
41166 <indexterm role="option">
41167 <primary>tls_require_ciphers</primary>
41168 </indexterm>
41169 </para>
41170 <informaltable frame="all">
41171 <tgroup cols="4" colsep="0" rowsep="0">
41172 <colspec colwidth="8*" align="left"/>
41173 <colspec colwidth="5*" align="center"/>
41174 <colspec colwidth="5*" align="center"/>
41175 <colspec colwidth="6*" align="right"/>
41176 <tbody>
41177 <row>
41178 <entry><option>tls_require_ciphers</option></entry>
41179 <entry>Use: <emphasis>smtp</emphasis></entry>
41180 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
41181 <entry>Default: <emphasis>unset</emphasis></entry>
41182 </row>
41183 </tbody>
41184 </tgroup>
41185 </informaltable>
41186 <para>
41187 <indexterm role="concept">
41188 <primary>TLS</primary>
41189 <secondary>requiring specific ciphers</secondary>
41190 </indexterm>
41191 <indexterm role="concept">
41192 <primary>cipher</primary>
41193 <secondary>requiring specific</secondary>
41194 </indexterm>
41195 <indexterm role="concept">
41196 <primary><varname>$host</varname></primary>
41197 </indexterm>
41198 <indexterm role="concept">
41199 <primary><varname>$host_address</varname></primary>
41200 </indexterm>
41201 The value of this option must be a list of permitted cipher suites, for use
41202 when setting up an outgoing encrypted connection. (There is a global option of
41203 the same name for controlling incoming connections.) The values of <varname>$host</varname> and
41204 <varname>$host_address</varname> are set to the name and address of the server during the
41205 expansion. See chapter <xref linkend="CHAPTLS"/> for details of TLS; note that this option
41206 is used in different ways by OpenSSL and GnuTLS (see sections
41207 <xref linkend="SECTreqciphssl"/> and <xref linkend="SECTreqciphgnu"/>). For GnuTLS, the order of the
41208 ciphers is a preference order.
41209 </para>
41210 <para>
41211 <indexterm role="option">
41212 <primary>tls_tempfail_tryclear</primary>
41213 </indexterm>
41214 </para>
41215 <informaltable frame="all">
41216 <tgroup cols="4" colsep="0" rowsep="0">
41217 <colspec colwidth="8*" align="left"/>
41218 <colspec colwidth="5*" align="center"/>
41219 <colspec colwidth="5*" align="center"/>
41220 <colspec colwidth="6*" align="right"/>
41221 <tbody>
41222 <row>
41223 <entry><option>tls_tempfail_tryclear</option></entry>
41224 <entry>Use: <emphasis>smtp</emphasis></entry>
41225 <entry>Type: <emphasis>boolean</emphasis></entry>
41226 <entry>Default: <emphasis>true</emphasis></entry>
41227 </row>
41228 </tbody>
41229 </tgroup>
41230 </informaltable>
41231 <para>
41232 When the server host is not in <option>hosts_require_tls</option>, and there is a problem in
41233 setting up a TLS session, this option determines whether or not Exim should try
41234 to deliver the message unencrypted. If it is set false, delivery to the
41235 current host is deferred; if there are other hosts, they are tried. If this
41236 option is set true, Exim attempts to deliver unencrypted after a 4<emphasis>xx</emphasis>
41237 response to STARTTLS. Also, if STARTTLS is accepted, but the subsequent
41238 TLS negotiation fails, Exim closes the current connection (because it is in an
41239 unknown state), opens a new one to the same host, and then tries the delivery
41240 in clear.
41241 </para>
41242 <para>
41243 <indexterm role="option">
41244 <primary>tls_verify_certificates</primary>
41245 </indexterm>
41246 </para>
41247 <informaltable frame="all">
41248 <tgroup cols="4" colsep="0" rowsep="0">
41249 <colspec colwidth="8*" align="left"/>
41250 <colspec colwidth="5*" align="center"/>
41251 <colspec colwidth="5*" align="center"/>
41252 <colspec colwidth="6*" align="right"/>
41253 <tbody>
41254 <row>
41255 <entry><option>tls_verify_certificates</option></entry>
41256 <entry>Use: <emphasis>smtp</emphasis></entry>
41257 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
41258 <entry>Default: <emphasis>unset</emphasis></entry>
41259 </row>
41260 </tbody>
41261 </tgroup>
41262 </informaltable>
41263 <para>
41264 <indexterm role="concept">
41265 <primary>TLS</primary>
41266 <secondary>server certificate verification</secondary>
41267 </indexterm>
41268 <indexterm role="concept">
41269 <primary>certificate</primary>
41270 <secondary>verification of server</secondary>
41271 </indexterm>
41272 <indexterm role="concept">
41273 <primary><varname>$host</varname></primary>
41274 </indexterm>
41275 <indexterm role="concept">
41276 <primary><varname>$host_address</varname></primary>
41277 </indexterm>
41278 The value of this option must be the absolute path to a file containing
41279 permitted server certificates, for use when setting up an encrypted connection.
41280 Alternatively, if you are using OpenSSL, you can set
41281 <option>tls_verify_certificates</option> to the name of a directory containing certificate
41282 files. This does not work with GnuTLS; the option must be set to the name of a
41283 single file if you are using GnuTLS. The values of <varname>$host</varname> and
41284 <varname>$host_address</varname> are set to the name and address of the server during the
41285 expansion of this option. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
41286 </para>
41287 </section>
41288 <section id="SECTvalhosmax">
41289 <title>How the limits for the number of hosts to try are used</title>
41290 <para>
41291 <indexterm role="concept">
41292 <primary>host</primary>
41293 <secondary>maximum number to try</secondary>
41294 </indexterm>
41295 <indexterm role="concept">
41296 <primary>limit</primary>
41297 <secondary>hosts; maximum number tried</secondary>
41298 </indexterm>
41299 There are two options that are concerned with the number of hosts that are
41300 tried when an SMTP delivery takes place. They are <option>hosts_max_try</option> and
41301 <option>hosts_max_try_hardlimit</option>.
41302 </para>
41303 <para>
41304 The <option>hosts_max_try</option> option limits the number of hosts that are tried
41305 for a single delivery. However, despite the term <quote>host</quote> in its name, the
41306 option actually applies to each IP address independently. In other words, a
41307 multihomed host is treated as several independent hosts, just as it is for
41308 retrying.
41309 </para>
41310 <para>
41311 Many of the larger ISPs have multiple MX records which often point to
41312 multihomed hosts. As a result, a list of a dozen or more IP addresses may be
41313 created as a result of routing one of these domains.
41314 </para>
41315 <para>
41316 Trying every single IP address on such a long list does not seem sensible; if
41317 several at the top of the list fail, it is reasonable to assume there is some
41318 problem that is likely to affect all of them. Roughly speaking, the value of
41319 <option>hosts_max_try</option> is the maximum number that are tried before deferring the
41320 delivery. However, the logic cannot be quite that simple.
41321 </para>
41322 <para>
41323 Firstly, IP addresses that are skipped because their retry times have not
41324 arrived do not count, and in addition, addresses that are past their retry
41325 limits are also not counted, even when they are tried. This means that when
41326 some IP addresses are past their retry limits, more than the value of
41327 <option>hosts_max_retry</option> may be tried. The reason for this behaviour is to ensure
41328 that all IP addresses are considered before timing out an email address (but
41329 see below for an exception).
41330 </para>
41331 <para>
41332 Secondly, when the <option>hosts_max_try</option> limit is reached, Exim looks down the host
41333 list to see if there is a subsequent host with a different (higher valued) MX.
41334 If there is, that host is considered next, and the current IP address is used
41335 but not counted. This behaviour helps in the case of a domain with a retry rule
41336 that hardly ever delays any hosts, as is now explained:
41337 </para>
41338 <para>
41339 Consider the case of a long list of hosts with one MX value, and a few with a
41340 higher MX value. If <option>hosts_max_try</option> is small (the default is 5) only a few
41341 hosts at the top of the list are tried at first. With the default retry rule,
41342 which specifies increasing retry times, the higher MX hosts are eventually
41343 tried when those at the top of the list are skipped because they have not
41344 reached their retry times.
41345 </para>
41346 <para>
41347 However, it is common practice to put a fixed short retry time on domains for
41348 large ISPs, on the grounds that their servers are rarely down for very long.
41349 Unfortunately, these are exactly the domains that tend to resolve to long lists
41350 of hosts. The short retry time means that the lowest MX hosts are tried every
41351 time. The attempts may be in a different order because of random sorting, but
41352 without the special MX check, the higher MX hosts would never be tried until
41353 all the lower MX hosts had timed out (which might be several days), because
41354 there are always some lower MX hosts that have reached their retry times. With
41355 the special check, Exim considers at least one IP address from each MX value at
41356 every delivery attempt, even if the <option>hosts_max_try</option> limit has already been
41357 reached.
41358 </para>
41359 <para>
41360 The above logic means that <option>hosts_max_try</option> is not a hard limit, and in
41361 particular, Exim normally eventually tries all the IP addresses before timing
41362 out an email address. When <option>hosts_max_try</option> was implemented, this seemed a
41363 reasonable thing to do. Recently, however, some lunatic DNS configurations have
41364 been set up with hundreds of IP addresses for some domains. It can
41365 take a very long time indeed for an address to time out in these cases.
41366 </para>
41367 <para>
41368 The <option>hosts_max_try_hardlimit</option> option was added to help with this problem.
41369 Exim never tries more than this number of IP addresses; if it hits this limit
41370 and they are all timed out, the email address is bounced, even though not all
41371 possible IP addresses have been tried.
41372 <indexterm role="concept" startref="IIDsmttra1" class="endofrange"/>
41373 <indexterm role="concept" startref="IIDsmttra2" class="endofrange"/>
41374 </para>
41375 </section>
41376 </chapter>
41377
41378 <chapter id="CHAPrewrite">
41379 <title>Address rewriting</title>
41380 <para>
41381 <indexterm role="concept" id="IIDaddrew" class="startofrange">
41382 <primary>rewriting</primary>
41383 <secondary>addresses</secondary>
41384 </indexterm>
41385 There are some circumstances in which Exim automatically rewrites domains in
41386 addresses. The two most common are when an address is given without a domain
41387 (referred to as an <quote>unqualified address</quote>) or when an address contains an
41388 abbreviated domain that is expanded by DNS lookup.
41389 </para>
41390 <para>
41391 Unqualified envelope addresses are accepted only for locally submitted
41392 messages, or for messages that are received from hosts matching
41393 <option>sender_unqualified_hosts</option> or <option>recipient_unqualified_hosts</option>, as
41394 appropriate. Unqualified addresses in header lines are qualified if they are in
41395 locally submitted messages, or messages from hosts that are permitted to send
41396 unqualified envelope addresses. Otherwise, unqualified addresses in header
41397 lines are neither qualified nor rewritten.
41398 </para>
41399 <para>
41400 One situation in which Exim does <emphasis>not</emphasis> automatically rewrite a domain is
41401 when it is the name of a CNAME record in the DNS. The older RFCs suggest that
41402 such a domain should be rewritten using the <quote>canonical</quote> name, and some MTAs
41403 do this. The new RFCs do not contain this suggestion.
41404 </para>
41405 <section>
41406 <title>Explicitly configured address rewriting</title>
41407 <para>
41408 This chapter describes the rewriting rules that can be used in the
41409 main rewrite section of the configuration file, and also in the generic
41410 <option>headers_rewrite</option> option that can be set on any transport.
41411 </para>
41412 <para>
41413 Some people believe that configured address rewriting is a Mortal Sin.
41414 Others believe that life is not possible without it. Exim provides the
41415 facility; you do not have to use it.
41416 </para>
41417 <para>
41418 The main rewriting rules that appear in the <quote>rewrite</quote> section of the
41419 configuration file are applied to addresses in incoming messages, both envelope
41420 addresses and addresses in header lines. Each rule specifies the types of
41421 address to which it applies.
41422 </para>
41423 <para>
41424 Rewriting of addresses in header lines applies only to those headers that
41425 were received with the message, and, in the case of transport rewriting, those
41426 that were added by a system filter. That is, it applies only to those headers
41427 that are common to all copies of the message. Header lines that are added by
41428 individual routers or transports (and which are therefore specific to
41429 individual recipient addresses) are not rewritten.
41430 </para>
41431 <para>
41432 In general, rewriting addresses from your own system or domain has some
41433 legitimacy. Rewriting other addresses should be done only with great care and
41434 in special circumstances. The author of Exim believes that rewriting should be
41435 used sparingly, and mainly for <quote>regularizing</quote> addresses in your own domains.
41436 Although it can sometimes be used as a routing tool, this is very strongly
41437 discouraged.
41438 </para>
41439 <para>
41440 There are two commonly encountered circumstances where rewriting is used, as
41441 illustrated by these examples:
41442 </para>
41443 <itemizedlist>
41444 <listitem>
41445 <para>
41446 The company whose domain is <emphasis>hitch.fict.example</emphasis> has a number of hosts that
41447 exchange mail with each other behind a firewall, but there is only a single
41448 gateway to the outer world. The gateway rewrites <emphasis>*.hitch.fict.example</emphasis> as
41449 <emphasis>hitch.fict.example</emphasis> when sending mail off-site.
41450 </para>
41451 </listitem>
41452 <listitem>
41453 <para>
41454 A host rewrites the local parts of its own users so that, for example,
41455 <emphasis>fp42@hitch.fict.example</emphasis> becomes <emphasis>Ford.Prefect@hitch.fict.example</emphasis>.
41456 </para>
41457 </listitem>
41458 </itemizedlist>
41459 </section>
41460 <section>
41461 <title>When does rewriting happen?</title>
41462 <para>
41463 <indexterm role="concept">
41464 <primary>rewriting</primary>
41465 <secondary>timing of</secondary>
41466 </indexterm>
41467 <indexterm role="concept">
41468 <primary>access control lists (ACLs)</primary>
41469 <secondary>rewriting addresses in</secondary>
41470 </indexterm>
41471 Configured address rewriting can take place at several different stages of a
41472 message&#x2019;s processing.
41473 </para>
41474 <para>
41475 <indexterm role="concept">
41476 <primary><varname>$sender_address</varname></primary>
41477 </indexterm>
41478 At the start of an ACL for MAIL, the sender address may have been rewritten
41479 by a special SMTP-time rewrite rule (see section <xref linkend="SECTrewriteS"/>), but no
41480 ordinary rewrite rules have yet been applied. If, however, the sender address
41481 is verified in the ACL, it is rewritten before verification, and remains
41482 rewritten thereafter. The subsequent value of <varname>$sender_address</varname> is the
41483 rewritten address. This also applies if sender verification happens in a
41484 RCPT ACL. Otherwise, when the sender address is not verified, it is
41485 rewritten as soon as a message&#x2019;s header lines have been received.
41486 </para>
41487 <para>
41488 <indexterm role="concept">
41489 <primary><varname>$domain</varname></primary>
41490 </indexterm>
41491 <indexterm role="concept">
41492 <primary><varname>$local_part</varname></primary>
41493 </indexterm>
41494 Similarly, at the start of an ACL for RCPT, the current recipient&#x2019;s address
41495 may have been rewritten by a special SMTP-time rewrite rule, but no ordinary
41496 rewrite rules have yet been applied to it. However, the behaviour is different
41497 from the sender address when a recipient is verified. The address is rewritten
41498 for the verification, but the rewriting is not remembered at this stage. The
41499 value of <varname>$local_part</varname> and <varname>$domain</varname> after verification are always the same
41500 as they were before (that is, they contain the unrewritten &ndash; except for
41501 SMTP-time rewriting &ndash; address).
41502 </para>
41503 <para revisionflag="changed">
41504 As soon as a message&#x2019;s header lines have been received, all the envelope
41505 recipient addresses are permanently rewritten, and rewriting is also applied to
41506 the addresses in the header lines (if configured). This happens before adding
41507 any header lines that were specified in MAIL or RCPT ACLs, and
41508 <indexterm role="concept">
41509 <primary><function>local_scan()</function> function</primary>
41510 <secondary>address rewriting; timing of</secondary>
41511 </indexterm>
41512 before the DATA ACL and <function>local_scan()</function> functions are run.
41513 </para>
41514 <para>
41515 When an address is being routed, either for delivery or for verification,
41516 rewriting is applied immediately to child addresses that are generated by
41517 redirection, unless <option>no_rewrite</option> is set on the router.
41518 </para>
41519 <para revisionflag="changed">
41520 <indexterm role="concept">
41521 <primary>envelope sender</primary>
41522 <secondary>rewriting at transport time</secondary>
41523 </indexterm>
41524 <indexterm role="concept">
41525 <primary>rewriting</primary>
41526 <secondary>at transport time</secondary>
41527 </indexterm>
41528 <indexterm role="concept">
41529 <primary>header lines</primary>
41530 <secondary>rewriting at transport time</secondary>
41531 </indexterm>
41532 At transport time, additional rewriting of addresses in header lines can be
41533 specified by setting the generic <option>headers_rewrite</option> option on a transport.
41534 This option contains rules that are identical in form to those in the rewrite
41535 section of the configuration file. They are applied to the original message
41536 header lines and any that were added by ACLs or a system filter. They are not
41537 applied to header lines that are added by routers or the transport.
41538 </para>
41539 <para revisionflag="changed">
41540 The outgoing envelope sender can be rewritten by means of the <option>return_path</option>
41541 transport option. However, it is not possible to rewrite envelope recipients at
41542 transport time.
41543 </para>
41544 </section>
41545 <section>
41546 <title>Testing the rewriting rules that apply on input</title>
41547 <para>
41548 <indexterm role="concept">
41549 <primary>rewriting</primary>
41550 <secondary>testing</secondary>
41551 </indexterm>
41552 <indexterm role="concept">
41553 <primary>testing</primary>
41554 <secondary>rewriting</secondary>
41555 </indexterm>
41556 Exim&#x2019;s input rewriting configuration appears in a part of the run time
41557 configuration file headed by <quote>begin rewrite</quote>. It can be tested by the
41558 <option>-brw</option> command line option. This takes an address (which can be a full RFC
41559 2822 address) as its argument. The output is a list of how the address would be
41560 transformed by the rewriting rules for each of the different places it might
41561 appear in an incoming message, that is, for each different header and for the
41562 envelope sender and recipient fields. For example,
41563 </para>
41564 <literallayout class="monospaced">
41565 exim -brw ph10@exim.workshop.example
41566 </literallayout>
41567 <para>
41568 might produce the output
41569 </para>
41570 <literallayout class="monospaced">
41571 sender: Philip.Hazel@exim.workshop.example
41572 from: Philip.Hazel@exim.workshop.example
41573 to: ph10@exim.workshop.example
41574 cc: ph10@exim.workshop.example
41575 bcc: ph10@exim.workshop.example
41576 reply-to: Philip.Hazel@exim.workshop.example
41577 env-from: Philip.Hazel@exim.workshop.example
41578 env-to: ph10@exim.workshop.example
41579 </literallayout>
41580 <para>
41581 which shows that rewriting has been set up for that address when used in any of
41582 the source fields, but not when it appears as a recipient address. At the
41583 present time, there is no equivalent way of testing rewriting rules that are
41584 set for a particular transport.
41585 </para>
41586 </section>
41587 <section>
41588 <title>Rewriting rules</title>
41589 <para>
41590 <indexterm role="concept">
41591 <primary>rewriting</primary>
41592 <secondary>rules</secondary>
41593 </indexterm>
41594 The rewrite section of the configuration file consists of lines of rewriting
41595 rules in the form
41596 </para>
41597 <literallayout>
41598 &lt;<emphasis>source pattern</emphasis>&gt;  &lt;<emphasis>replacement</emphasis>&gt;  &lt;<emphasis>flags</emphasis>&gt;
41599 </literallayout>
41600 <para>
41601 Rewriting rules that are specified for the <option>headers_rewrite</option> generic
41602 transport option are given as a colon-separated list. Each item in the list
41603 takes the same form as a line in the main rewriting configuration (except that
41604 any colons must be doubled, of course).
41605 </para>
41606 <para>
41607 The formats of source patterns and replacement strings are described below.
41608 Each is terminated by white space, unless enclosed in double quotes, in which
41609 case normal quoting conventions apply inside the quotes. The flags are single
41610 characters which may appear in any order. Spaces and tabs between them are
41611 ignored.
41612 </para>
41613 <para>
41614 For each address that could potentially be rewritten, the rules are scanned in
41615 order, and replacements for the address from earlier rules can themselves be
41616 replaced by later rules (but see the <quote>q</quote> and <quote>R</quote> flags).
41617 </para>
41618 <para>
41619 The order in which addresses are rewritten is undefined, may change between
41620 releases, and must not be relied on, with one exception: when a message is
41621 received, the envelope sender is always rewritten first, before any header
41622 lines are rewritten. For example, the replacement string for a rewrite of an
41623 address in <emphasis>To:</emphasis> must not assume that the message&#x2019;s address in <emphasis>From:</emphasis> has
41624 (or has not) already been rewritten. However, a rewrite of <emphasis>From:</emphasis> may assume
41625 that the envelope sender has already been rewritten.
41626 </para>
41627 <para>
41628 <indexterm role="concept">
41629 <primary><varname>$domain</varname></primary>
41630 </indexterm>
41631 <indexterm role="concept">
41632 <primary><varname>$local_part</varname></primary>
41633 </indexterm>
41634 The variables <varname>$local_part</varname> and <varname>$domain</varname> can be used in the replacement
41635 string to refer to the address that is being rewritten. Note that lookup-driven
41636 rewriting can be done by a rule of the form
41637 </para>
41638 <literallayout class="monospaced">
41639 *@*   ${lookup ...
41640 </literallayout>
41641 <para>
41642 where the lookup key uses <varname>$1</varname> and <varname>$2</varname> or <varname>$local_part</varname> and <varname>$domain</varname> to
41643 refer to the address that is being rewritten.
41644 </para>
41645 </section>
41646 <section>
41647 <title>Rewriting patterns</title>
41648 <para>
41649 <indexterm role="concept">
41650 <primary>rewriting</primary>
41651 <secondary>patterns</secondary>
41652 </indexterm>
41653 <indexterm role="concept">
41654 <primary>address list</primary>
41655 <secondary>in a rewriting pattern</secondary>
41656 </indexterm>
41657 The source pattern in a rewriting rule is any item which may appear in an
41658 address list (see section <xref linkend="SECTaddresslist"/>). It is in fact processed as a
41659 single-item address list, which means that it is expanded before being tested
41660 against the address. As always, if you use a regular expression as a pattern,
41661 you must take care to escape dollar and backslash characters, or use the <literal>\N</literal>
41662 facility to suppress string expansion within the regular expression.
41663 </para>
41664 <para>
41665 Domains in patterns should be given in lower case. Local parts in patterns are
41666 case-sensitive. If you want to do case-insensitive matching of local parts, you
41667 can use a regular expression that starts with <literal>^(?i)</literal>.
41668 </para>
41669 <para>
41670 <indexterm role="concept">
41671 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
41672 <secondary>in rewriting rules</secondary>
41673 </indexterm>
41674 After matching, the numerical variables <varname>$1</varname>, <varname>$2</varname>, etc. may be set,
41675 depending on the type of match which occurred. These can be used in the
41676 replacement string to insert portions of the incoming address. <varname>$0</varname> always
41677 refers to the complete incoming address. When a regular expression is used, the
41678 numerical variables are set from its capturing subexpressions. For other types
41679 of pattern they are set as follows:
41680 </para>
41681 <itemizedlist>
41682 <listitem>
41683 <para>
41684 If a local part or domain starts with an asterisk, the numerical variables
41685 refer to the character strings matched by asterisks, with <varname>$1</varname> associated with
41686 the first asterisk, and <varname>$2</varname> with the second, if present. For example, if the
41687 pattern
41688 </para>
41689 <literallayout class="monospaced">
41690 *queen@*.fict.example
41691 </literallayout>
41692 <para>
41693 is matched against the address <emphasis>hearts-queen@wonderland.fict.example</emphasis> then
41694 </para>
41695 <literallayout class="monospaced">
41696 $0 = hearts-queen@wonderland.fict.example
41697 $1 = hearts-
41698 $2 = wonderland
41699 </literallayout>
41700 <para>
41701 Note that if the local part does not start with an asterisk, but the domain
41702 does, it is <varname>$1</varname> that contains the wild part of the domain.
41703 </para>
41704 </listitem>
41705 <listitem>
41706 <para>
41707 If the domain part of the pattern is a partial lookup, the wild and fixed parts
41708 of the domain are placed in the next available numerical variables. Suppose,
41709 for example, that the address <emphasis>foo@bar.baz.example</emphasis> is processed by a
41710 rewriting rule of the form
41711 </para>
41712 <literallayout>
41713 <literal>*@partial-dbm;/some/dbm/file</literal>    &lt;<emphasis>replacement string</emphasis>&gt;
41714 </literallayout>
41715 <para>
41716 and the key in the file that matches the domain is <literal>*.baz.example</literal>. Then
41717 </para>
41718 <literallayout class="monospaced">
41719 $1 = foo
41720 $2 = bar
41721 $3 = baz.example
41722 </literallayout>
41723 <para>
41724 If the address <emphasis>foo@baz.example</emphasis> is looked up, this matches the same
41725 wildcard file entry, and in this case <varname>$2</varname> is set to the empty string, but
41726 <varname>$3</varname> is still set to <emphasis>baz.example</emphasis>. If a non-wild key is matched in a
41727 partial lookup, <varname>$2</varname> is again set to the empty string and <varname>$3</varname> is set to the
41728 whole domain. For non-partial domain lookups, no numerical variables are set.
41729 </para>
41730 </listitem>
41731 </itemizedlist>
41732 </section>
41733 <section>
41734 <title>Rewriting replacements</title>
41735 <para>
41736 <indexterm role="concept">
41737 <primary>rewriting</primary>
41738 <secondary>replacements</secondary>
41739 </indexterm>
41740 If the replacement string for a rule is a single asterisk, addresses that
41741 match the pattern and the flags are <emphasis>not</emphasis> rewritten, and no subsequent
41742 rewriting rules are scanned. For example,
41743 </para>
41744 <literallayout class="monospaced">
41745 hatta@lookingglass.fict.example  *  f
41746 </literallayout>
41747 <para>
41748 specifies that <emphasis>hatta@lookingglass.fict.example</emphasis> is never to be rewritten in
41749 <emphasis>From:</emphasis> headers.
41750 </para>
41751 <para>
41752 <indexterm role="concept">
41753 <primary><varname>$domain</varname></primary>
41754 </indexterm>
41755 <indexterm role="concept">
41756 <primary><varname>$local_part</varname></primary>
41757 </indexterm>
41758 If the replacement string is not a single asterisk, it is expanded, and must
41759 yield a fully qualified address. Within the expansion, the variables
41760 <varname>$local_part</varname> and <varname>$domain</varname> refer to the address that is being rewritten.
41761 Any letters they contain retain their original case &ndash; they are not lower
41762 cased. The numerical variables are set up according to the type of pattern that
41763 matched the address, as described above. If the expansion is forced to fail by
41764 the presence of <quote>fail</quote> in a conditional or lookup item, rewriting by the
41765 current rule is abandoned, but subsequent rules may take effect. Any other
41766 expansion failure causes the entire rewriting operation to be abandoned, and an
41767 entry written to the panic log.
41768 </para>
41769 </section>
41770 <section>
41771 <title>Rewriting flags</title>
41772 <para>
41773 There are three different kinds of flag that may appear on rewriting rules:
41774 </para>
41775 <itemizedlist>
41776 <listitem>
41777 <para>
41778 Flags that specify which headers and envelope addresses to rewrite: E, F, T, b,
41779 c, f, h, r, s, t.
41780 </para>
41781 </listitem>
41782 <listitem>
41783 <para>
41784 A flag that specifies rewriting at SMTP time: S.
41785 </para>
41786 </listitem>
41787 <listitem>
41788 <para>
41789 Flags that control the rewriting process: Q, q, R, w.
41790 </para>
41791 </listitem>
41792 </itemizedlist>
41793 <para>
41794 For rules that are part of the <option>headers_rewrite</option> generic transport option,
41795 E, F, T, and S are not permitted.
41796 </para>
41797 </section>
41798 <section>
41799 <title>Flags specifying which headers and envelope addresses to rewrite</title>
41800 <para>
41801 <indexterm role="concept">
41802 <primary>rewriting</primary>
41803 <secondary>flags</secondary>
41804 </indexterm>
41805 If none of the following flag letters, nor the <quote>S</quote> flag (see section
41806 <xref linkend="SECTrewriteS"/>) are present, a main rewriting rule applies to all headers
41807 and to both the sender and recipient fields of the envelope, whereas a
41808 transport-time rewriting rule just applies to all headers. Otherwise, the
41809 rewriting rule is skipped unless the relevant addresses are being processed.
41810 </para>
41811 <literallayout>
41812 <literal>E</literal>       rewrite all envelope fields
41813 <literal>F</literal>       rewrite the envelope From field
41814 <literal>T</literal>       rewrite the envelope To field
41815 <literal>b</literal>       rewrite the <emphasis>Bcc:</emphasis> header
41816 <literal>c</literal>       rewrite the <emphasis>Cc:</emphasis> header
41817 <literal>f</literal>       rewrite the <emphasis>From:</emphasis> header
41818 <literal>h</literal>       rewrite all headers
41819 <literal>r</literal>       rewrite the <emphasis>Reply-To:</emphasis> header
41820 <literal>s</literal>       rewrite the <emphasis>Sender:</emphasis> header
41821 <literal>t</literal>       rewrite the <emphasis>To:</emphasis> header
41822 </literallayout>
41823 <para>
41824 You should be particularly careful about rewriting <emphasis>Sender:</emphasis> headers, and
41825 restrict this to special known cases in your own domains.
41826 </para>
41827 </section>
41828 <section id="SECTrewriteS">
41829 <title>The SMTP-time rewriting flag</title>
41830 <para>
41831 <indexterm role="concept">
41832 <primary>SMTP</primary>
41833 <secondary>rewriting malformed addresses</secondary>
41834 </indexterm>
41835 <indexterm role="concept">
41836 <primary>RCPT</primary>
41837 <secondary>rewriting argument of</secondary>
41838 </indexterm>
41839 <indexterm role="concept">
41840 <primary>MAIL</primary>
41841 <secondary>rewriting argument of</secondary>
41842 </indexterm>
41843 The rewrite flag <quote>S</quote> specifies a rewrite of incoming envelope addresses at
41844 SMTP time, as soon as an address is received in a MAIL or RCPT command, and
41845 before any other processing; even before syntax checking. The pattern is
41846 required to be a regular expression, and it is matched against the whole of the
41847 data for the command, including any surrounding angle brackets.
41848 </para>
41849 <para>
41850 <indexterm role="concept">
41851 <primary><varname>$domain</varname></primary>
41852 </indexterm>
41853 <indexterm role="concept">
41854 <primary><varname>$local_part</varname></primary>
41855 </indexterm>
41856 This form of rewrite rule allows for the handling of addresses that are not
41857 compliant with RFCs 2821 and 2822 (for example, <quote>bang paths</quote> in batched SMTP
41858 input). Because the input is not required to be a syntactically valid address,
41859 the variables <varname>$local_part</varname> and <varname>$domain</varname> are not available during the
41860 expansion of the replacement string. The result of rewriting replaces the
41861 original address in the MAIL or RCPT command.
41862 </para>
41863 </section>
41864 <section>
41865 <title>Flags controlling the rewriting process</title>
41866 <para>
41867 There are four flags which control the way the rewriting process works. These
41868 take effect only when a rule is invoked, that is, when the address is of the
41869 correct type (matches the flags) and matches the pattern:
41870 </para>
41871 <itemizedlist>
41872 <listitem>
41873 <para>
41874 If the <quote>Q</quote> flag is set on a rule, the rewritten address is permitted to be an
41875 unqualified local part. It is qualified with <option>qualify_recipient</option>. In the
41876 absence of <quote>Q</quote> the rewritten address must always include a domain.
41877 </para>
41878 </listitem>
41879 <listitem>
41880 <para>
41881 If the <quote>q</quote> flag is set on a rule, no further rewriting rules are considered,
41882 even if no rewriting actually takes place because of a <quote>fail</quote> in the
41883 expansion. The <quote>q</quote> flag is not effective if the address is of the wrong type
41884 (does not match the flags) or does not match the pattern.
41885 </para>
41886 </listitem>
41887 <listitem>
41888 <para>
41889 The <quote>R</quote> flag causes a successful rewriting rule to be re-applied to the new
41890 address, up to ten times. It can be combined with the <quote>q</quote> flag, to stop
41891 rewriting once it fails to match (after at least one successful rewrite).
41892 </para>
41893 </listitem>
41894 <listitem>
41895 <para>
41896 <indexterm role="concept">
41897 <primary>rewriting</primary>
41898 <secondary>whole addresses</secondary>
41899 </indexterm>
41900 When an address in a header is rewritten, the rewriting normally applies only
41901 to the working part of the address, with any comments and RFC 2822 <quote>phrase</quote>
41902 left unchanged. For example, rewriting might change
41903 </para>
41904 <literallayout class="monospaced">
41905 From: Ford Prefect &lt;fp42@restaurant.hitch.fict.example&gt;
41906 </literallayout>
41907 <para>
41908 into
41909 </para>
41910 <literallayout class="monospaced">
41911 From: Ford Prefect &lt;prefectf@hitch.fict.example&gt;
41912 </literallayout>
41913 <para>
41914 <indexterm role="concept">
41915 <primary>RFC 2047</primary>
41916 </indexterm>
41917 Sometimes there is a need to replace the whole address item, and this can be
41918 done by adding the flag letter <quote>w</quote> to a rule. If this is set on a rule that
41919 causes an address in a header line to be rewritten, the entire address is
41920 replaced, not just the working part. The replacement must be a complete RFC
41921 2822 address, including the angle brackets if necessary. If text outside angle
41922 brackets contains a character whose value is greater than 126 or less than 32
41923 (except for tab), the text is encoded according to RFC 2047. The character set
41924 is taken from <option>headers_charset</option>, which defaults to ISO-8859-1.
41925 </para>
41926 <para>
41927 When the <quote>w</quote> flag is set on a rule that causes an envelope address to be
41928 rewritten, all but the working part of the replacement address is discarded.
41929 </para>
41930 </listitem>
41931 </itemizedlist>
41932 </section>
41933 <section>
41934 <title>Rewriting examples</title>
41935 <para>
41936 Here is an example of the two common rewriting paradigms:
41937 </para>
41938 <literallayout class="monospaced">
41939 *@*.hitch.fict.example  $1@hitch.fict.example
41940 *@hitch.fict.example    ${lookup{$1}dbm{/etc/realnames}\
41941                      {$value}fail}@hitch.fict.example bctfrF
41942 </literallayout>
41943 <para>
41944 Note the use of <quote>fail</quote> in the lookup expansion in the second rule, forcing
41945 the string expansion to fail if the lookup does not succeed. In this context it
41946 has the effect of leaving the original address unchanged, but Exim goes on to
41947 consider subsequent rewriting rules, if any, because the <quote>q</quote> flag is not
41948 present in that rule. An alternative to <quote>fail</quote> would be to supply <varname>$1</varname>
41949 explicitly, which would cause the rewritten address to be the same as before,
41950 at the cost of a small bit of processing. Not supplying either of these is an
41951 error, since the rewritten address would then contain no local part.
41952 </para>
41953 <para>
41954 The first example above replaces the domain with a superior, more general
41955 domain. This may not be desirable for certain local parts. If the rule
41956 </para>
41957 <literallayout class="monospaced">
41958 root@*.hitch.fict.example  *
41959 </literallayout>
41960 <para>
41961 were inserted before the first rule, rewriting would be suppressed for the
41962 local part <emphasis>root</emphasis> at any domain ending in <emphasis>hitch.fict.example</emphasis>.
41963 </para>
41964 <para>
41965 Rewriting can be made conditional on a number of tests, by making use of
41966 <varname>${if</varname> in the expansion item. For example, to apply a rewriting rule only to
41967 messages that originate outside the local host:
41968 </para>
41969 <literallayout class="monospaced">
41970 *@*.hitch.fict.example  "${if !eq {$sender_host_address}{}\
41971                          {$1@hitch.fict.example}fail}"
41972 </literallayout>
41973 <para>
41974 The replacement string is quoted in this example because it contains white
41975 space.
41976 </para>
41977 <para>
41978 <indexterm role="concept">
41979 <primary>rewriting</primary>
41980 <secondary>bang paths</secondary>
41981 </indexterm>
41982 <indexterm role="concept">
41983 <primary>bang paths</primary>
41984 <secondary>rewriting</secondary>
41985 </indexterm>
41986 Exim does not handle addresses in the form of <quote>bang paths</quote>. If it sees such
41987 an address it treats it as an unqualified local part which it qualifies with
41988 the local qualification domain (if the source of the message is local or if the
41989 remote host is permitted to send unqualified addresses). Rewriting can
41990 sometimes be used to handle simple bang paths with a fixed number of
41991 components. For example, the rule
41992 </para>
41993 <literallayout class="monospaced">
41994 \N^([^!]+)!(.*)@your.domain.example$\N   $2@$1
41995 </literallayout>
41996 <para>
41997 rewrites a two-component bang path <emphasis>host.name!user</emphasis> as the domain address
41998 <emphasis>user@host.name</emphasis>. However, there is a security implication in using this as
41999 a global rewriting rule for envelope addresses. It can provide a backdoor
42000 method for using your system as a relay, because the incoming addresses appear
42001 to be local. If the bang path addresses are received via SMTP, it is safer to
42002 use the <quote>S</quote> flag to rewrite them as they are received, so that relay checking
42003 can be done on the rewritten addresses.
42004 <indexterm role="concept" startref="IIDaddrew" class="endofrange"/>
42005 </para>
42006 </section>
42007 </chapter>
42008
42009 <chapter id="CHAPretry">
42010 <title>Retry configuration</title>
42011 <para>
42012 <indexterm role="concept" id="IIDretconf1" class="startofrange">
42013 <primary>retry configuration</primary>
42014 <secondary>description of</secondary>
42015 </indexterm>
42016 <indexterm role="concept" id="IIDregconf2" class="startofrange">
42017 <primary>configuration file</primary>
42018 <secondary>retry section</secondary>
42019 </indexterm>
42020 The <quote>retry</quote> section of the run time configuration file contains a list of
42021 retry rules that control how often Exim tries to deliver messages that cannot
42022 be delivered at the first attempt. If there are no retry rules, temporary
42023 errors are treated as permanent. The <option>-brt</option> command line option can be used
42024 to test which retry rule will be used for a given address, domain and error.
42025 </para>
42026 <para>
42027 The most common cause of retries is temporary failure to deliver to a remote
42028 host because the host is down, or inaccessible because of a network problem.
42029 Exim&#x2019;s retry processing in this case is applied on a per-host (strictly, per IP
42030 address) basis, not on a per-message basis. Thus, if one message has recently
42031 been delayed, delivery of a new message to the same host is not immediately
42032 tried, but waits for the host&#x2019;s retry time to arrive. If the <option>retry_defer</option>
42033 log selector is set, the message
42034 <indexterm role="concept">
42035 <primary>retry</primary>
42036 <secondary>time not reached</secondary>
42037 </indexterm>
42038 <quote>retry time not reached</quote> is written to the main log whenever a delivery is
42039 skipped for this reason. Section <xref linkend="SECToutSMTPerr"/> contains more details of
42040 the handling of errors during remote deliveries.
42041 </para>
42042 <para>
42043 Retry processing applies to routing as well as to delivering, except as covered
42044 in the next paragraph. The retry rules do not distinguish between these
42045 actions. It is not possible, for example, to specify different behaviour for
42046 failures to route the domain <emphasis>snark.fict.example</emphasis> and failures to deliver to
42047 the host <emphasis>snark.fict.example</emphasis>. I didn&#x2019;t think anyone would ever need this
42048 added complication, so did not implement it. However, although they share the
42049 same retry rule, the actual retry times for routing and transporting a given
42050 domain are maintained independently.
42051 </para>
42052 <para>
42053 When a delivery is not part of a queue run (typically an immediate delivery on
42054 receipt of a message), the routers are always run, and local deliveries are
42055 always attempted, even if retry times are set for them. This makes for better
42056 behaviour if one particular message is causing problems (for example, causing
42057 quota overflow, or provoking an error in a filter file). If such a delivery
42058 suffers a temporary failure, the retry data is updated as normal, and
42059 subsequent delivery attempts from queue runs occur only when the retry time for
42060 the local address is reached.
42061 </para>
42062 <section>
42063 <title>Retry rules</title>
42064 <para>
42065 <indexterm role="concept">
42066 <primary>retry</primary>
42067 <secondary>rules</secondary>
42068 </indexterm>
42069 Each retry rule occupies one line and consists of three or four parts,
42070 separated by white space: a pattern, an error name, an optional list of sender
42071 addresses, and a list of retry parameters. The pattern and sender lists must be
42072 enclosed in double quotes if they contain white space. The rules are searched
42073 in order until one is found where the pattern, error name, and sender list (if
42074 present) match the failing host or address, the error that occurred, and the
42075 message&#x2019;s sender, respectively.
42076 </para>
42077 <para>
42078 The pattern is any single item that may appear in an address list (see section
42079 <xref linkend="SECTaddresslist"/>). It is in fact processed as a one-item address list,
42080 which means that it is expanded before being tested against the address that
42081 has been delayed. Address list processing treats a plain domain name as if it
42082 were preceded by <quote>*@</quote>, which makes it possible for many retry rules to start
42083 with just a domain. For example,
42084 </para>
42085 <literallayout class="monospaced">
42086 lookingglass.fict.example        *  F,24h,30m;
42087 </literallayout>
42088 <para>
42089 provides a rule for any address in the <emphasis>lookingglass.fict.example</emphasis> domain,
42090 whereas
42091 </para>
42092 <literallayout class="monospaced">
42093 alice@lookingglass.fict.example  *  F,24h,30m;
42094 </literallayout>
42095 <para>
42096 applies only to temporary failures involving the local part <option>alice</option>.
42097 In practice, almost all rules start with a domain name pattern without a local
42098 part.
42099 </para>
42100 <para>
42101 <indexterm role="concept">
42102 <primary>regular expressions</primary>
42103 <secondary>in retry rules</secondary>
42104 </indexterm>
42105 <emphasis role="bold">Warning</emphasis>: If you use a regular expression in a routing rule pattern, it
42106 must match a complete address, not just a domain, because that is how regular
42107 expressions work in address lists.
42108 </para>
42109 <literallayout>
42110 <literal>^\Nxyz\d+\.abc\.example$\N        *  G,1h,10m,2</literal>     <option>Wrong</option>
42111 <literal>^\N[^@]+@xyz\d+\.abc\.example$\N  *  G,1h,10m,2</literal>     <option>Right</option>
42112 </literallayout>
42113 </section>
42114 <section>
42115 <title>Choosing which retry rule to use for address errors</title>
42116 <para>
42117 When Exim is looking for a retry rule after a routing attempt has failed (for
42118 example, after a DNS timeout), each line in the retry configuration is tested
42119 against the complete address only if <option>retry_use_local_part</option> is set for the
42120 router. Otherwise, only the domain is used, except when matching against a
42121 regular expression, when the local part of the address is replaced with <quote>*</quote>.
42122 A domain on its own can match a domain pattern, or a pattern that starts with
42123 <quote>*@</quote>. By default, <option>retry_use_local_part</option> is true for routers where
42124 <option>check_local_user</option> is true, and false for other routers.
42125 </para>
42126 <para>
42127 Similarly, when Exim is looking for a retry rule after a local delivery has
42128 failed (for example, after a mailbox full error), each line in the retry
42129 configuration is tested against the complete address only if
42130 <option>retry_use_local_part</option> is set for the transport (it defaults true for all
42131 local transports).
42132 </para>
42133 <para revisionflag="changed">
42134 However, when Exim is looking for a retry rule after a remote delivery attempt
42135 suffers an address error (a 4<emphasis>xx</emphasis> SMTP response for a recipient address), the
42136 whole address is always used as the key when searching the retry rules. The
42137 rule that is found is used to create a retry time for the failing address.
42138 </para>
42139 </section>
42140 <section>
42141 <title>Choosing which retry rule to use for host and message errors</title>
42142 <para>
42143 For a temporary error that is not related to an individual address (for
42144 example, a connection timeout), each line in the retry configuration is checked
42145 twice. First, the name of the remote host is used as a domain name (preceded by
42146 <quote>*@</quote> when matching a regular expression). If this does not match the line,
42147 the domain from the email address is tried in a similar fashion. For example,
42148 suppose the MX records for <emphasis>a.b.c.example</emphasis> are
42149 </para>
42150 <literallayout class="monospaced">
42151 a.b.c.example  MX  5  x.y.z.example
42152                MX  6  p.q.r.example
42153                MX  7  m.n.o.example
42154 </literallayout>
42155 <para>
42156 and the retry rules are
42157 </para>
42158 <literallayout class="monospaced">
42159 p.q.r.example    *      F,24h,30m;
42160 a.b.c.example    *      F,4d,45m;
42161 </literallayout>
42162 <para>
42163 and a delivery to the host <emphasis>x.y.z.example</emphasis> suffers a connection failure. The
42164 first rule matches neither the host nor the domain, so Exim looks at the second
42165 rule. This does not match the host, but it does match the domain, so it is used
42166 to calculate the retry time for the host <emphasis>x.y.z.example</emphasis>. Meanwhile, Exim
42167 tries to deliver to <emphasis>p.q.r.example</emphasis>. If this also suffers a host error, the
42168 first retry rule is used, because it matches the host.
42169 </para>
42170 <para>
42171 In other words, temporary failures to deliver to host <emphasis>p.q.r.example</emphasis> use the
42172 first rule to determine retry times, but for all the other hosts for the domain
42173 <emphasis>a.b.c.example</emphasis>, the second rule is used. The second rule is also used if
42174 routing to <emphasis>a.b.c.example</emphasis> suffers a temporary failure.
42175 </para>
42176 <para>
42177 <emphasis role="bold">Note</emphasis>: The host name is used when matching the patterns, not its IP address.
42178 However, if a message is routed directly to an IP address without the use of a
42179 host name, for example, if a <command>manualroute</command> router contains a setting such as:
42180 </para>
42181 <literallayout class="monospaced">
42182 route_list = *.a.example  192.168.34.23
42183 </literallayout>
42184 <para>
42185 then the <quote>host name</quote> that is used when searching for a retry rule is the
42186 textual form of the IP address.
42187 </para>
42188 </section>
42189 <section>
42190 <title>Retry rules for specific errors</title>
42191 <para>
42192 <indexterm role="concept">
42193 <primary>retry</primary>
42194 <secondary>specific errors; specifying</secondary>
42195 </indexterm>
42196 The second field in a retry rule is the name of a particular error, or an
42197 asterisk, which matches any error. The errors that can be tested for are:
42198 </para>
42199 <variablelist>
42200 <varlistentry>
42201 <term><option>auth_failed</option></term>
42202 <listitem>
42203 <para>
42204 Authentication failed when trying to send to a host in the
42205 <option>hosts_require_auth</option> list in an <command>smtp</command> transport.
42206 </para>
42207 </listitem></varlistentry>
42208 <varlistentry revisionflag="changed">
42209 <term><option>data_4xx</option></term>
42210 <listitem>
42211 <para revisionflag="changed">
42212 A 4<emphasis>xx</emphasis> error was received for an outgoing DATA command, either immediately
42213 after the command, or after sending the message&#x2019;s data.
42214 </para>
42215 </listitem></varlistentry>
42216 <varlistentry revisionflag="changed">
42217 <term><option>mail_4xx</option></term>
42218 <listitem>
42219 <para revisionflag="changed">
42220 A 4<emphasis>xx</emphasis> error was received for an outgoing MAIL command.
42221 </para>
42222 </listitem></varlistentry>
42223 <varlistentry revisionflag="changed">
42224 <term><option>rcpt_4xx</option></term>
42225 <listitem>
42226 <para revisionflag="changed">
42227 A 4<emphasis>xx</emphasis> error was received for an outgoing RCPT command.
42228 </para>
42229 </listitem></varlistentry>
42230 </variablelist>
42231 <para revisionflag="changed">
42232 For the three 4<emphasis>xx</emphasis> errors, either the first or both of the x&#x2019;s can be given
42233 as specific digits, for example: <literal>mail_45x</literal> or <literal>rcpt_436</literal>. For example, to
42234 recognize 452 errors given to RCPT commands for addresses in a certain domain,
42235 and have retries every ten minutes with a one-hour timeout, you could set up a
42236 retry rule of this form:
42237 </para>
42238 <literallayout class="monospaced" revisionflag="changed">
42239 the.domain.name  rcpt_452   F,1h,10m
42240 </literallayout>
42241 <para revisionflag="changed">
42242 These errors apply to both outgoing SMTP (the <command>smtp</command> transport) and outgoing
42243 LMTP (either the <command>lmtp</command> transport, or the <command>smtp</command> transport in LMTP mode).
42244 </para>
42245 <variablelist>
42246 <varlistentry revisionflag="changed">
42247 <term><option>lost_connection</option></term>
42248 <listitem>
42249 <para revisionflag="changed">
42250 A server unexpectedly closed the SMTP connection. There may, of course,
42251 legitimate reasons for this (host died, network died), but if it repeats a lot
42252 for the same host, it indicates something odd.
42253 </para>
42254 </listitem></varlistentry>
42255 <varlistentry>
42256 <term><option>refused_MX</option></term>
42257 <listitem>
42258 <para>
42259 A connection to a host obtained from an MX record was refused.
42260 </para>
42261 </listitem></varlistentry>
42262 <varlistentry>
42263 <term><option>refused_A</option></term>
42264 <listitem>
42265 <para>
42266 A connection to a host not obtained from an MX record was refused.
42267 </para>
42268 </listitem></varlistentry>
42269 <varlistentry>
42270 <term><option>refused</option></term>
42271 <listitem>
42272 <para>
42273 A connection was refused.
42274 </para>
42275 </listitem></varlistentry>
42276 <varlistentry>
42277 <term><option>timeout_connect_MX</option></term>
42278 <listitem>
42279 <para>
42280 A connection attempt to a host obtained from an MX record timed out.
42281 </para>
42282 </listitem></varlistentry>
42283 <varlistentry>
42284 <term><option>timeout_connect_A</option></term>
42285 <listitem>
42286 <para>
42287 A connection attempt to a host not obtained from an MX record timed out.
42288 </para>
42289 </listitem></varlistentry>
42290 <varlistentry>
42291 <term><option>timeout_connect</option></term>
42292 <listitem>
42293 <para>
42294 A connection attempt timed out.
42295 </para>
42296 </listitem></varlistentry>
42297 <varlistentry>
42298 <term><option>timeout_MX</option></term>
42299 <listitem>
42300 <para>
42301 There was a timeout while connecting or during an SMTP session with a host
42302 obtained from an MX record.
42303 </para>
42304 </listitem></varlistentry>
42305 <varlistentry>
42306 <term><option>timeout_A</option></term>
42307 <listitem>
42308 <para>
42309 There was a timeout while connecting or during an SMTP session with a host not
42310 obtained from an MX record.
42311 </para>
42312 </listitem></varlistentry>
42313 <varlistentry>
42314 <term><option>timeout</option></term>
42315 <listitem>
42316 <para>
42317 There was a timeout while connecting or during an SMTP session.
42318 </para>
42319 </listitem></varlistentry>
42320 <varlistentry revisionflag="changed">
42321 <term><option>tls_required</option></term>
42322 <listitem>
42323 <para revisionflag="changed">
42324 The server was required to use TLS (it matched <option>hosts_require_tls</option> in the
42325 <command>smtp</command> transport), but either did not offer TLS, or it responded with 4<emphasis>xx</emphasis>
42326 to STARTTLS, or there was a problem setting up the TLS connection.
42327 </para>
42328 </listitem></varlistentry>
42329 <varlistentry>
42330 <term><option>quota</option></term>
42331 <listitem>
42332 <para>
42333 A mailbox quota was exceeded in a local delivery by the <command>appendfile</command>
42334 transport.
42335 </para>
42336 </listitem></varlistentry>
42337 <varlistentry>
42338 <term><option>quota_</option>&lt;<emphasis>time</emphasis>&gt;</term>
42339 <listitem>
42340 <para>
42341 <indexterm role="concept">
42342 <primary>quota</primary>
42343 <secondary>error testing in retry rule</secondary>
42344 </indexterm>
42345 <indexterm role="concept">
42346 <primary>retry</primary>
42347 <secondary>quota error testing</secondary>
42348 </indexterm>
42349 A mailbox quota was exceeded in a local delivery by the <command>appendfile</command>
42350 transport, and the mailbox has not been accessed for &lt;<emphasis>time</emphasis>&gt;. For example,
42351 <emphasis>quota_4d</emphasis> applies to a quota error when the mailbox has not been accessed
42352 for four days.
42353 </para>
42354 </listitem></varlistentry>
42355 </variablelist>
42356 <para>
42357 <indexterm role="concept">
42358 <primary>mailbox</primary>
42359 <secondary>time of last read</secondary>
42360 </indexterm>
42361 The idea of <option>quota_</option>&lt;<emphasis>time</emphasis>&gt; is to make it possible to have shorter
42362 timeouts when the mailbox is full and is not being read by its owner. Ideally,
42363 it should be based on the last time that the user accessed the mailbox.
42364 However, it is not always possible to determine this. Exim uses the following
42365 heuristic rules:
42366 </para>
42367 <itemizedlist>
42368 <listitem>
42369 <para>
42370 If the mailbox is a single file, the time of last access (the <quote>atime</quote>) is
42371 used. As no new messages are being delivered (because the mailbox is over
42372 quota), Exim does not access the file, so this is the time of last user access.
42373 </para>
42374 </listitem>
42375 <listitem>
42376 <para>
42377 <indexterm role="concept">
42378 <primary>maildir format</primary>
42379 <secondary>time of last read</secondary>
42380 </indexterm>
42381 For a maildir delivery, the time of last modification of the <filename>new</filename>
42382 subdirectory is used. As the mailbox is over quota, no new files are created in
42383 the <filename>new</filename> subdirectory, because no new messages are being delivered. Any
42384 change to the <filename>new</filename> subdirectory is therefore assumed to be the result of an
42385 MUA moving a new message to the <filename>cur</filename> directory when it is first read. The
42386 time that is used is therefore the last time that the user read a new message.
42387 </para>
42388 </listitem>
42389 <listitem>
42390 <para>
42391 For other kinds of multi-file mailbox, the time of last access cannot be
42392 obtained, so a retry rule that uses this type of error field is never matched.
42393 </para>
42394 </listitem>
42395 </itemizedlist>
42396 <para>
42397 The quota errors apply both to system-enforced quotas and to Exim&#x2019;s own quota
42398 mechanism in the <command>appendfile</command> transport. The <emphasis>quota</emphasis> error also applies
42399 when a local delivery is deferred because a partition is full (the ENOSPC
42400 error).
42401 </para>
42402 </section>
42403 <section>
42404 <title>Retry rules for specified senders</title>
42405 <para>
42406 <indexterm role="concept">
42407 <primary>retry</primary>
42408 <secondary>rules; sender-specific</secondary>
42409 </indexterm>
42410 You can specify retry rules that apply only when the failing message has a
42411 specific sender. In particular, this can be used to define retry rules that
42412 apply only to bounce messages. The third item in a retry rule can be of this
42413 form:
42414 </para>
42415 <literallayout>
42416 <literal>senders=</literal>&lt;<emphasis>address list</emphasis>&gt;
42417 </literallayout>
42418 <para>
42419 The retry timings themselves are then the fourth item. For example:
42420 </para>
42421 <literallayout class="monospaced">
42422 *   rcpt_4xx   senders=:   F,1h,30m
42423 </literallayout>
42424 <para revisionflag="changed">
42425 matches recipient 4<emphasis>xx</emphasis> errors for bounce messages sent to any address at any
42426 host. If the address list contains white space, it must be enclosed in quotes.
42427 For example:
42428 </para>
42429 <literallayout class="monospaced" revisionflag="changed">
42430 a.domain  rcpt_452  senders="xb.dom : yc.dom"  G,8h,10m,1.5
42431 </literallayout>
42432 <para>
42433 <emphasis role="bold">Warning</emphasis>: This facility can be unhelpful if it is used for host errors
42434 (which do not depend on the recipient). The reason is that the sender is used
42435 only to match the retry rule. Once the rule has been found for a host error,
42436 its contents are used to set a retry time for the host, and this will apply to
42437 all messages, not just those with specific senders.
42438 </para>
42439 <para>
42440 When testing retry rules using <option>-brt</option>, you can supply a sender using the
42441 <option>-f</option> command line option, like this:
42442 </para>
42443 <literallayout class="monospaced">
42444 exim -f "" -brt user@dom.ain
42445 </literallayout>
42446 <para>
42447 If you do not set <option>-f</option> with <option>-brt</option>, a retry rule that contains a senders
42448 list is never matched.
42449 </para>
42450 </section>
42451 <section>
42452 <title>Retry parameters</title>
42453 <para>
42454 <indexterm role="concept">
42455 <primary>retry</primary>
42456 <secondary>parameters in rules</secondary>
42457 </indexterm>
42458 The third (or fourth, if a senders list is present) field in a retry rule is a
42459 sequence of retry parameter sets, separated by semicolons. Each set consists of
42460 </para>
42461 <literallayout>
42462 &lt;<emphasis>letter</emphasis>&gt;,&lt;<emphasis>cutoff time</emphasis>&gt;,&lt;<emphasis>arguments</emphasis>&gt;
42463 </literallayout>
42464 <para>
42465 The letter identifies the algorithm for computing a new retry time; the cutoff
42466 time is the time beyond which this algorithm no longer applies, and the
42467 arguments vary the algorithm&#x2019;s action. The cutoff time is measured from the
42468 time that the first failure for the domain (combined with the local part if
42469 relevant) was detected, not from the time the message was received.
42470 </para>
42471 <para>
42472 <indexterm role="concept">
42473 <primary>retry</primary>
42474 <secondary>algorithms</secondary>
42475 </indexterm>
42476 <indexterm role="concept">
42477 <primary>retry</primary>
42478 <secondary>fixed intervals</secondary>
42479 </indexterm>
42480 <indexterm role="concept">
42481 <primary>retry</primary>
42482 <secondary>increasing intervals</secondary>
42483 </indexterm>
42484 <indexterm role="concept">
42485 <primary>retry</primary>
42486 <secondary>random intervals</secondary>
42487 </indexterm>
42488 The available algorithms are:
42489 </para>
42490 <itemizedlist>
42491 <listitem>
42492 <para>
42493 <emphasis>F</emphasis>: retry at fixed intervals. There is a single time parameter specifying
42494 the interval.
42495 </para>
42496 </listitem>
42497 <listitem>
42498 <para>
42499 <emphasis>G</emphasis>: retry at geometrically increasing intervals. The first argument
42500 specifies a starting value for the interval, and the second a multiplier, which
42501 is used to increase the size of the interval at each retry.
42502 </para>
42503 </listitem>
42504 <listitem>
42505 <para>
42506 <emphasis>H</emphasis>: retry at randomized intervals. The arguments are as for <emphasis>G</emphasis>. For each
42507 retry, the previous interval is multiplied by the factor in order to get a
42508 maximum for the next interval. The mininum interval is the first argument of
42509 the parameter, and an actual interval is chosen randomly between them. Such a
42510 rule has been found to be helpful in cluster configurations when all the
42511 members of the cluster restart at once, and may therefore synchronize their
42512 queue processing times.
42513 </para>
42514 </listitem>
42515 </itemizedlist>
42516 <para>
42517 When computing the next retry time, the algorithm definitions are scanned in
42518 order until one whose cutoff time has not yet passed is reached. This is then
42519 used to compute a new retry time that is later than the current time. In the
42520 case of fixed interval retries, this simply means adding the interval to the
42521 current time. For geometrically increasing intervals, retry intervals are
42522 computed from the rule&#x2019;s parameters until one that is greater than the previous
42523 interval is found. The main configuration variable
42524 <indexterm role="concept">
42525 <primary>limit</primary>
42526 <secondary>retry interval</secondary>
42527 </indexterm>
42528 <indexterm role="concept">
42529 <primary>retry interval</primary>
42530 <secondary>maximum</secondary>
42531 </indexterm>
42532 <indexterm role="concept">
42533 <primary><option>retry_interval_max</option></primary>
42534 </indexterm>
42535 <option>retry_interval_max</option> limits the maximum interval between retries. <phrase revisionflag="changed">It
42536 cannot be set greater than <literal>24h</literal>, which is its default value.</phrase>
42537 </para>
42538 <para>
42539 A single remote domain may have a number of hosts associated with it, and each
42540 host may have more than one IP address. Retry algorithms are selected on the
42541 basis of the domain name, but are applied to each IP address independently. If,
42542 for example, a host has two IP addresses and one is unusable, Exim will
42543 generate retry times for it and will not try to use it until its next retry
42544 time comes. Thus the good IP address is likely to be tried first most of the
42545 time.
42546 </para>
42547 <para>
42548 <indexterm role="concept">
42549 <primary>hints database</primary>
42550 <secondary>use for retrying</secondary>
42551 </indexterm>
42552 Retry times are hints rather than promises. Exim does not make any attempt to
42553 run deliveries exactly at the computed times. Instead, a queue runner process
42554 starts delivery processes for delayed messages periodically, and these attempt
42555 new deliveries only for those addresses that have passed their next retry time.
42556 If a new message arrives for a deferred address, an immediate delivery attempt
42557 occurs only if the address has passed its retry time. In the absence of new
42558 messages, the minimum time between retries is the interval between queue runner
42559 processes. There is not much point in setting retry times of five minutes if
42560 your queue runners happen only once an hour, unless there are a significant
42561 number of incoming messages (which might be the case on a system that is
42562 sending everything to a smart host, for example).
42563 </para>
42564 <para>
42565 The data in the retry hints database can be inspected by using the
42566 <emphasis>exim_dumpdb</emphasis> or <emphasis>exim_fixdb</emphasis> utility programs (see chapter
42567 <xref linkend="CHAPutils"/>). The latter utility can also be used to change the data. The
42568 <emphasis>exinext</emphasis> utility script can be used to find out what the next retry times
42569 are for the hosts associated with a particular mail domain, and also for local
42570 deliveries that have been deferred.
42571 </para>
42572 </section>
42573 <section>
42574 <title>Retry rule examples</title>
42575 <para>
42576 Here are some example retry rules:
42577 </para>
42578 <literallayout class="monospaced">
42579 alice@wonderland.fict.example quota_5d  F,7d,3h
42580 wonderland.fict.example       quota_5d
42581 wonderland.fict.example       *         F,1h,15m; G,2d,1h,2;
42582 lookingglass.fict.example     *         F,24h,30m;
42583 *                 refused_A   F,2h,20m;
42584 *                 *           F,2h,15m; G,16h,1h,1.5; F,5d,8h
42585 </literallayout>
42586 <para>
42587 The first rule sets up special handling for mail to
42588 <emphasis>alice@wonderland.fict.example</emphasis> when there is an over-quota error and the
42589 mailbox has not been read for at least 5 days. Retries continue every three
42590 hours for 7 days. The second rule handles over-quota errors for all other local
42591 parts at <emphasis>wonderland.fict.example</emphasis>; the absence of a local part has the same
42592 effect as supplying <quote>*@</quote>. As no retry algorithms are supplied, messages that
42593 fail are bounced immediately if the mailbox has not been read for at least 5
42594 days.
42595 </para>
42596 <para>
42597 The third rule handles all other errors at <emphasis>wonderland.fict.example</emphasis>; retries
42598 happen every 15 minutes for an hour, then with geometrically increasing
42599 intervals until two days have passed since a delivery first failed. After the
42600 first hour there is a delay of one hour, then two hours, then four hours, and
42601 so on (this is a rather extreme example).
42602 </para>
42603 <para>
42604 The fourth rule controls retries for the domain <emphasis>lookingglass.fict.example</emphasis>.
42605 They happen every 30 minutes for 24 hours only. The remaining two rules handle
42606 all other domains, with special action for connection refusal from hosts that
42607 were not obtained from an MX record.
42608 </para>
42609 <para>
42610 The final rule in a retry configuration should always have asterisks in the
42611 first two fields so as to provide a general catch-all for any addresses that do
42612 not have their own special handling. This example tries every 15 minutes for 2
42613 hours, then with intervals starting at one hour and increasing by a factor of
42614 1.5 up to 16 hours, then every 8 hours up to 5 days.
42615 </para>
42616 </section>
42617 <section>
42618 <title>Timeout of retry data</title>
42619 <para>
42620 <indexterm role="concept">
42621 <primary>timeout</primary>
42622 <secondary>of retry data</secondary>
42623 </indexterm>
42624 <indexterm role="concept">
42625 <primary><option>retry_data_expire</option></primary>
42626 </indexterm>
42627 <indexterm role="concept">
42628 <primary>hints database</primary>
42629 <secondary>data expiry</secondary>
42630 </indexterm>
42631 <indexterm role="concept">
42632 <primary>retry</primary>
42633 <secondary>timeout of data</secondary>
42634 </indexterm>
42635 Exim timestamps the data that it writes to its retry hints database. When it
42636 consults the data during a delivery it ignores any that is older than the value
42637 set in <option>retry_data_expire</option> (default 7 days). If, for example, a host hasn&#x2019;t
42638 been tried for 7 days, Exim will try to deliver to it immediately a message
42639 arrives, and if that fails, it will calculate a retry time as if it were
42640 failing for the first time.
42641 </para>
42642 <para>
42643 This improves the behaviour for messages routed to rarely-used hosts such as MX
42644 backups. If such a host was down at one time, and happens to be down again when
42645 Exim tries a month later, using the old retry data would imply that it had been
42646 down all the time, which is not a justified assumption.
42647 </para>
42648 <para>
42649 If a host really is permanently dead, this behaviour causes a burst of retries
42650 every now and again, but only if messages routed to it are rare. It there is a
42651 message at least once every 7 days the retry data never expires.
42652 </para>
42653 </section>
42654 <section>
42655 <title>Long-term failures</title>
42656 <para>
42657 <indexterm role="concept">
42658 <primary>delivery failure</primary>
42659 <secondary>long-term</secondary>
42660 </indexterm>
42661 <indexterm role="concept">
42662 <primary>retry</primary>
42663 <secondary>after long-term failure</secondary>
42664 </indexterm>
42665 Special processing happens when an email address has been failing for so long
42666 that the cutoff time for the last algorithm is reached. For example, using the
42667 default retry rule:
42668 </para>
42669 <literallayout class="monospaced">
42670 * * F,2h,15m; G,16h,1h,1.5; F,4d,6h
42671 </literallayout>
42672 <para>
42673 the cutoff time is four days. Reaching the retry cutoff is independent of how
42674 long any specific message has been failing; it is the length of continuous
42675 failure for the recipient address that counts.
42676 </para>
42677 <para>
42678 When the cutoff time is reached for a local delivery, or for all the IP
42679 addresses associated with a remote delivery, a subsequent delivery failure
42680 causes Exim to give up on the address, and a bounce message is generated.
42681 In order to cater for new messages that use the failing address, a next retry
42682 time is still computed from the final algorithm, and is used as follows:
42683 </para>
42684 <para>
42685 For local deliveries, one delivery attempt is always made for any subsequent
42686 messages. If this delivery fails, the address fails immediately. The
42687 post-cutoff retry time is not used.
42688 </para>
42689 <para>
42690 If the delivery is remote, there are two possibilities, controlled by the
42691 <indexterm role="concept">
42692 <primary><option>delay_after_cutoff</option></primary>
42693 </indexterm>
42694 <option>delay_after_cutoff</option> option of the <command>smtp</command> transport. The option is true by
42695 default. Until the post-cutoff retry time for one of the IP addresses is
42696 reached, the failing email address is bounced immediately, without a delivery
42697 attempt taking place. After that time, one new delivery attempt is made to
42698 those IP addresses that are past their retry times, and if that still fails,
42699 the address is bounced and new retry times are computed.
42700 </para>
42701 <para>
42702 In other words, when all the hosts for a given email address have been failing
42703 for a long time, Exim bounces rather then defers until one of the hosts&#x2019; retry
42704 times is reached. Then it tries once, and bounces if that attempt fails. This
42705 behaviour ensures that few resources are wasted in repeatedly trying to deliver
42706 to a broken destination, but if the host does recover, Exim will eventually
42707 notice.
42708 </para>
42709 <para>
42710 If <option>delay_after_cutoff</option> is set false, Exim behaves differently. If all IP
42711 addresses are past their final cutoff time, Exim tries to deliver to those IP
42712 addresses that have not been tried since the message arrived. If there are
42713 no suitable IP addresses, or if they all fail, the address is bounced. In other
42714 words, it does not delay when a new message arrives, but tries the expired
42715 addresses immediately, unless they have been tried since the message arrived.
42716 If there is a continuous stream of messages for the failing domains, setting
42717 <option>delay_after_cutoff</option> false means that there will be many more attempts to
42718 deliver to permanently failing IP addresses than when <option>delay_after_cutoff</option> is
42719 true.
42720 </para>
42721 </section>
42722 <section revisionflag="changed">
42723 <title>Deliveries that work intermittently</title>
42724 <para revisionflag="changed">
42725 <indexterm role="concept">
42726 <primary>retry</primary>
42727 <secondary>intermittently working deliveries</secondary>
42728 </indexterm>
42729 Some additional logic is needed to cope with cases where a host is
42730 intermittently available, or when a message has some attribute that prevents
42731 its delivery when others to the same address get through. In this situation,
42732 because some messages are successfully delivered, the <quote>retry clock</quote> for the
42733 host or address keeps getting restarted, and so a message could remain on the
42734 queue for ever because the cutoff time is never reached.
42735 </para>
42736 <para revisionflag="changed">
42737 Two exceptional actions are applied to prevent this happening. Firstly, if a
42738 message&#x2019;s arrival time is earlier than the <quote>first failed</quote> time for a host or
42739 address, the earlier time is used when scanning the retry rules.
42740 </para>
42741 <para revisionflag="changed">
42742 Secondly, if a message has been on the queue for longer than the cutoff time of
42743 any applicable retry rule for a given address, a delivery is attempted for that
42744 address, even if it is not yet time, and if this delivery fails, the address is
42745 timed out. A new retry time is not computed in this case, so that other
42746 messages for the same address are considered immediately.
42747 </para>
42748 <para revisionflag="changed">
42749 These two actions are probably equivalent; the fact that they both exist is a
42750 a historical accident. The second was implemented first, and was left in place
42751 when the first was added on the grounds that this was harmless, whereas
42752 removing it might have broken something in this rather tricky area.
42753 <indexterm role="concept" startref="IIDretconf1" class="endofrange"/>
42754 <indexterm role="concept" startref="IIDregconf2" class="endofrange"/>
42755 </para>
42756 </section>
42757 </chapter>
42758
42759 <chapter id="CHAPSMTPAUTH">
42760 <title>SMTP authentication</title>
42761 <para>
42762 <indexterm role="concept" id="IIDauthconf1" class="startofrange">
42763 <primary>SMTP</primary>
42764 <secondary>authentication configuration</secondary>
42765 </indexterm>
42766 <indexterm role="concept" id="IIDauthconf2" class="startofrange">
42767 <primary>authentication</primary>
42768 </indexterm>
42769 The <quote>authenticators</quote> section of Exim&#x2019;s run time configuration is concerned
42770 with SMTP authentication. This facility is an extension to the SMTP protocol,
42771 described in RFC 2554, which allows a client SMTP host to authenticate itself
42772 to a server. This is a common way for a server to recognize clients that are
42773 permitted to use it as a relay. SMTP authentication is not of relevance to the
42774 transfer of mail between servers that have no managerial connection with each
42775 other.
42776 </para>
42777 <para>
42778 <indexterm role="concept">
42779 <primary>AUTH</primary>
42780 <secondary>description of</secondary>
42781 </indexterm>
42782 Very briefly, the way SMTP authentication works is as follows:
42783 </para>
42784 <itemizedlist>
42785 <listitem>
42786 <para>
42787 The server advertises a number of authentication <emphasis>mechanisms</emphasis> in response to
42788 the client&#x2019;s EHLO command.
42789 </para>
42790 </listitem>
42791 <listitem>
42792 <para>
42793 The client issues an AUTH command, naming a specific mechanism. The command
42794 may, optionally, contain some authentication data.
42795 </para>
42796 </listitem>
42797 <listitem>
42798 <para>
42799 The server may issue one or more <emphasis>challenges</emphasis>, to which the client must send
42800 appropriate responses. In simple authentication mechanisms, the challenges are
42801 just prompts for user names and passwords. The server does not have to issue
42802 any challenges &ndash; in some mechanisms the relevant data may all be transmitted
42803 with the AUTH command.
42804 </para>
42805 </listitem>
42806 <listitem>
42807 <para>
42808 The server either accepts or denies authentication.
42809 </para>
42810 </listitem>
42811 <listitem>
42812 <para>
42813 If authentication succeeds, the client may optionally make use of the AUTH
42814 option on the MAIL command to pass an authenticated sender in subsequent
42815 mail transactions. Authentication lasts for the remainder of the SMTP
42816 connection.
42817 </para>
42818 </listitem>
42819 <listitem>
42820 <para>
42821 If authentication fails, the client may give up, or it may try a different
42822 authentication mechanism, or it may try transferring mail over the
42823 unauthenticated connection.
42824 </para>
42825 </listitem>
42826 </itemizedlist>
42827 <para>
42828 If you are setting up a client, and want to know which authentication
42829 mechanisms the server supports, you can use Telnet to connect to port 25 (the
42830 SMTP port) on the server, and issue an EHLO command. The response to this
42831 includes the list of supported mechanisms. For example:
42832 </para>
42833 <literallayout>
42834 <literal>$ </literal><emphasis role="bold"><literal>telnet server.example 25</literal></emphasis>
42835 <literal>Trying 192.168.34.25...</literal>
42836 <literal>Connected to server.example.</literal>
42837 <literal>Escape character is '^]'.</literal>
42838 <literal>220 server.example ESMTP Exim 4.20 ...</literal>
42839 <emphasis role="bold"><literal>ehlo client.example</literal></emphasis>
42840 <literal>250-server.example Hello client.example [10.8.4.5]</literal>
42841 <literal>250-SIZE 52428800</literal>
42842 <literal>250-PIPELINING</literal>
42843 <literal>250-AUTH PLAIN</literal>
42844 <literal>250 HELP</literal>
42845 </literallayout>
42846 <para>
42847 The second-last line of this example output shows that the server supports
42848 authentication using the PLAIN mechanism. In Exim, the different authentication
42849 mechanisms are configured by specifying <emphasis>authenticator</emphasis> drivers. Like the
42850 routers and transports, which authenticators are included in the binary is
42851 controlled by build-time definitions. The following are currently available,
42852 included by setting
42853 </para>
42854 <literallayout class="monospaced">
42855 AUTH_CRAM_MD5=yes
42856 AUTH_CYRUS_SASL=yes
42857 AUTH_PLAINTEXT=yes
42858 AUTH_SPA=yes
42859 </literallayout>
42860 <para>
42861 in <filename>Local/Makefile</filename>, respectively. The first of these supports the CRAM-MD5
42862 authentication mechanism (RFC 2195), and the second provides an interface to
42863 the Cyrus SASL authentication library. The third can be configured to support
42864 the PLAIN authentication mechanism (RFC 2595) or the LOGIN mechanism, which is
42865 not formally documented, but used by several MUAs. The fourth authenticator
42866 supports Microsoft&#x2019;s <emphasis>Secure Password Authentication</emphasis> mechanism.
42867 </para>
42868 <para>
42869 The authenticators are configured using the same syntax as other drivers (see
42870 section <xref linkend="SECTfordricon"/>). If no authenticators are required, no
42871 authentication section need be present in the configuration file. Each
42872 authenticator can in principle have both server and client functions. When Exim
42873 is receiving SMTP mail, it is acting as a server; when it is sending out
42874 messages over SMTP, it is acting as a client. Authenticator configuration
42875 options are provided for use in both these circumstances.
42876 </para>
42877 <para>
42878 To make it clear which options apply to which situation, the prefixes
42879 <option>server_</option> and <option>client_</option> are used on option names that are specific to
42880 either the server or the client function, respectively. Server and client
42881 functions are disabled if none of their options are set. If an authenticator is
42882 to be used for both server and client functions, a single definition, using
42883 both sets of options, is required. For example:
42884 </para>
42885 <literallayout class="monospaced">
42886 cram:
42887   driver = cram_md5
42888   public_name = CRAM-MD5
42889   server_secret = ${if eq{$auth1}{ph10}{secret1}fail}
42890   client_name = ph10
42891   client_secret = secret2
42892 </literallayout>
42893 <para>
42894 The <option>server_</option> option is used when Exim is acting as a server, and the
42895 <option>client_</option> options when it is acting as a client.
42896 </para>
42897 <para>
42898 Descriptions of the individual authenticators are given in subsequent chapters.
42899 The remainder of this chapter covers the generic options for the
42900 authenticators, followed by general discussion of the way authentication works
42901 in Exim.
42902 </para>
42903 <section>
42904 <title>Generic options for authenticators</title>
42905 <para>
42906 <indexterm role="concept">
42907 <primary>authentication</primary>
42908 <secondary>generic options</secondary>
42909 </indexterm>
42910 <indexterm role="concept">
42911 <primary>options</primary>
42912 <secondary>generic; for authenticators</secondary>
42913 </indexterm>
42914 </para>
42915 <para>
42916 <indexterm role="option">
42917 <primary>driver</primary>
42918 </indexterm>
42919 </para>
42920 <informaltable frame="all">
42921 <tgroup cols="4" colsep="0" rowsep="0">
42922 <colspec colwidth="8*" align="left"/>
42923 <colspec colwidth="5*" align="center"/>
42924 <colspec colwidth="5*" align="center"/>
42925 <colspec colwidth="6*" align="right"/>
42926 <tbody>
42927 <row>
42928 <entry><option>driver</option></entry>
42929 <entry>Use: <emphasis>authenticators</emphasis></entry>
42930 <entry>Type: <emphasis>string</emphasis></entry>
42931 <entry>Default: <emphasis>unset</emphasis></entry>
42932 </row>
42933 </tbody>
42934 </tgroup>
42935 </informaltable>
42936 <para>
42937 This option must always be set. It specifies which of the available
42938 authenticators is to be used.
42939 </para>
42940 <para>
42941 <indexterm role="option">
42942 <primary>public_name</primary>
42943 </indexterm>
42944 </para>
42945 <informaltable frame="all">
42946 <tgroup cols="4" colsep="0" rowsep="0">
42947 <colspec colwidth="8*" align="left"/>
42948 <colspec colwidth="5*" align="center"/>
42949 <colspec colwidth="5*" align="center"/>
42950 <colspec colwidth="6*" align="right"/>
42951 <tbody>
42952 <row>
42953 <entry><option>public_name</option></entry>
42954 <entry>Use: <emphasis>authenticators</emphasis></entry>
42955 <entry>Type: <emphasis>string</emphasis></entry>
42956 <entry>Default: <emphasis>unset</emphasis></entry>
42957 </row>
42958 </tbody>
42959 </tgroup>
42960 </informaltable>
42961 <para>
42962 This option specifies the name of the authentication mechanism that the driver
42963 implements, and by which it is known to the outside world. These names should
42964 contain only upper case letters, digits, underscores, and hyphens (RFC 2222),
42965 but Exim in fact matches them caselessly. If <option>public_name</option> is not set, it
42966 defaults to the driver&#x2019;s instance name.
42967 </para>
42968 <para>
42969 <indexterm role="option">
42970 <primary>server_advertise_condition</primary>
42971 </indexterm>
42972 </para>
42973 <informaltable frame="all">
42974 <tgroup cols="4" colsep="0" rowsep="0">
42975 <colspec colwidth="8*" align="left"/>
42976 <colspec colwidth="5*" align="center"/>
42977 <colspec colwidth="5*" align="center"/>
42978 <colspec colwidth="6*" align="right"/>
42979 <tbody>
42980 <row>
42981 <entry><option>server_advertise_condition</option></entry>
42982 <entry>Use: <emphasis>authenticators</emphasis></entry>
42983 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
42984 <entry>Default: <emphasis>unset</emphasis></entry>
42985 </row>
42986 </tbody>
42987 </tgroup>
42988 </informaltable>
42989 <para>
42990 When a server is about to advertise an authentication mechanism, the condition
42991 is expanded. If it yields the empty string, <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, the
42992 mechanism is not advertised.
42993 If the expansion fails, the mechanism is not advertised. If the failure was not
42994 forced, and was not caused by a lookup defer, the incident is logged.
42995 See section <xref linkend="SECTauthexiser"/> below for further discussion.
42996 </para>
42997 <para>
42998 <indexterm role="option">
42999 <primary>server_debug_print</primary>
43000 </indexterm>
43001 </para>
43002 <informaltable frame="all">
43003 <tgroup cols="4" colsep="0" rowsep="0">
43004 <colspec colwidth="8*" align="left"/>
43005 <colspec colwidth="5*" align="center"/>
43006 <colspec colwidth="5*" align="center"/>
43007 <colspec colwidth="6*" align="right"/>
43008 <tbody>
43009 <row>
43010 <entry><option>server_debug_print</option></entry>
43011 <entry>Use: <emphasis>authenticators</emphasis></entry>
43012 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43013 <entry>Default: <emphasis>unset</emphasis></entry>
43014 </row>
43015 </tbody>
43016 </tgroup>
43017 </informaltable>
43018 <para>
43019 If this option is set and authentication debugging is enabled (see the <option>-d</option>
43020 command line option), the string is expanded and included in the debugging
43021 output when the authenticator is run as a server. This can help with checking
43022 out the values of variables.
43023 If expansion of the string fails, the error message is written to the debugging
43024 output, and Exim carries on processing.
43025 </para>
43026 <para>
43027 <indexterm role="option">
43028 <primary>server_set_id</primary>
43029 </indexterm>
43030 </para>
43031 <informaltable frame="all">
43032 <tgroup cols="4" colsep="0" rowsep="0">
43033 <colspec colwidth="8*" align="left"/>
43034 <colspec colwidth="5*" align="center"/>
43035 <colspec colwidth="5*" align="center"/>
43036 <colspec colwidth="6*" align="right"/>
43037 <tbody>
43038 <row>
43039 <entry><option>server_set_id</option></entry>
43040 <entry>Use: <emphasis>authenticators</emphasis></entry>
43041 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43042 <entry>Default: <emphasis>unset</emphasis></entry>
43043 </row>
43044 </tbody>
43045 </tgroup>
43046 </informaltable>
43047 <para>
43048 <indexterm role="concept">
43049 <primary><varname>$authenticated_id</varname></primary>
43050 </indexterm>
43051 When an Exim server successfully authenticates a client, this string is
43052 expanded using data from the authentication, and preserved for any incoming
43053 messages in the variable <varname>$authenticated_id</varname>. It is also included in the log
43054 lines for incoming messages. For example, a user/password authenticator
43055 configuration might preserve the user name that was used to authenticate, and
43056 refer to it subsequently during delivery of the message.
43057 If expansion fails, the option is ignored.
43058 </para>
43059 <para>
43060 <indexterm role="option">
43061 <primary>server_mail_auth_condition</primary>
43062 </indexterm>
43063 </para>
43064 <informaltable frame="all">
43065 <tgroup cols="4" colsep="0" rowsep="0">
43066 <colspec colwidth="8*" align="left"/>
43067 <colspec colwidth="5*" align="center"/>
43068 <colspec colwidth="5*" align="center"/>
43069 <colspec colwidth="6*" align="right"/>
43070 <tbody>
43071 <row>
43072 <entry><option>server_mail_auth_condition</option></entry>
43073 <entry>Use: <emphasis>authenticators</emphasis></entry>
43074 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43075 <entry>Default: <emphasis>unset</emphasis></entry>
43076 </row>
43077 </tbody>
43078 </tgroup>
43079 </informaltable>
43080 <para>
43081 This option allows a server to discard authenticated sender addresses supplied
43082 as part of MAIL commands in SMTP connections that are authenticated by the
43083 driver on which <option>server_mail_auth_condition</option> is set. The option is not used
43084 as part of the authentication process; instead its (unexpanded) value is
43085 remembered for later use.
43086 How it is used is described in the following section.
43087 </para>
43088 </section>
43089 <section id="SECTauthparamail">
43090 <title>The AUTH parameter on MAIL commands</title>
43091 <para>
43092 <indexterm role="concept">
43093 <primary>authentication</primary>
43094 <secondary>sender; authenticated</secondary>
43095 </indexterm>
43096 <indexterm role="concept">
43097 <primary>AUTH</primary>
43098 <secondary>on MAIL command</secondary>
43099 </indexterm>
43100 When a client supplied an AUTH= item on a MAIL command, Exim applies
43101 the following checks before accepting it as the authenticated sender of the
43102 message:
43103 </para>
43104 <itemizedlist>
43105 <listitem>
43106 <para>
43107 If the connection is not using extended SMTP (that is, HELO was used rather
43108 than EHLO), the use of AUTH= is a syntax error.
43109 </para>
43110 </listitem>
43111 <listitem>
43112 <para>
43113 If the value of the AUTH= parameter is <quote>&lt;&gt;</quote>, it is ignored.
43114 </para>
43115 </listitem>
43116 <listitem>
43117 <para>
43118 <indexterm role="concept">
43119 <primary><varname>$authenticated_sender</varname></primary>
43120 </indexterm>
43121 If <option>acl_smtp_mailauth</option> is defined, the ACL it specifies is run. While it is
43122 running, the value of <varname>$authenticated_sender</varname> is set to the value obtained
43123 from the AUTH= parameter. If the ACL does not yield <quote>accept</quote>, the value of
43124 <varname>$authenticated_sender</varname> is deleted. The <option>acl_smtp_mailauth</option> ACL may not
43125 return <quote>drop</quote> or <quote>discard</quote>. If it defers, a temporary error code (451) is
43126 given for the MAIL command.
43127 </para>
43128 </listitem>
43129 <listitem>
43130 <para>
43131 If <option>acl_smtp_mailauth</option> is not defined, the value of the AUTH= parameter
43132 is accepted and placed in <varname>$authenticated_sender</varname> only if the client has
43133 authenticated.
43134 </para>
43135 </listitem>
43136 <listitem>
43137 <para>
43138 If the AUTH= value was accepted by either of the two previous rules, and
43139 the client has authenticated, and the authenticator has a setting for the
43140 <option>server_mail_auth_condition</option>, the condition is checked at this point. The
43141 valued that was saved from the authenticator is expanded. If the expansion
43142 fails, or yields an empty string, <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, the value of
43143 <varname>$authenticated_sender</varname> is deleted. If the expansion yields any other value,
43144 the value of <varname>$authenticated_sender</varname> is retained and passed on with the
43145 message.
43146 </para>
43147 </listitem>
43148 </itemizedlist>
43149 <para>
43150 When <varname>$authenticated_sender</varname> is set for a message, it is passed on to other
43151 hosts to which Exim authenticates as a client. Do not confuse this value with
43152 <varname>$authenticated_id</varname>, which is a string obtained from the authentication
43153 process, and which is not usually a complete email address.
43154 </para>
43155 <para>
43156 <indexterm role="concept">
43157 <primary><varname>$sender_address</varname></primary>
43158 </indexterm>
43159 Whenever an AUTH= value is ignored, the incident is logged. The ACL for
43160 MAIL, if defined, is run after AUTH= is accepted or ignored. It can
43161 therefore make use of <varname>$authenticated_sender</varname>. The converse is not true: the
43162 value of <varname>$sender_address</varname> is not yet set up when the <option>acl_smtp_mailauth</option>
43163 ACL is run.
43164 </para>
43165 </section>
43166 <section id="SECTauthexiser">
43167 <title>Authentication on an Exim server</title>
43168 <para>
43169 <indexterm role="concept">
43170 <primary>authentication</primary>
43171 <secondary>on an Exim server</secondary>
43172 </indexterm>
43173 When Exim receives an EHLO command, it advertises the public names of those
43174 authenticators that are configured as servers, subject to the following
43175 conditions:
43176 </para>
43177 <itemizedlist>
43178 <listitem>
43179 <para>
43180 The client host must match <option>auth_advertise_hosts</option> (default *).
43181 </para>
43182 </listitem>
43183 <listitem>
43184 <para>
43185 It the <option>server_advertise_condition</option> option is set, its expansion must not
43186 yield the empty string, <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>.
43187 </para>
43188 </listitem>
43189 </itemizedlist>
43190 <para>
43191 The order in which the authenticators are defined controls the order in which
43192 the mechanisms are advertised.
43193 </para>
43194 <para>
43195 Some mail clients (for example, some versions of Netscape) require the user to
43196 provide a name and password for authentication whenever AUTH is advertised,
43197 even though authentication may not in fact be needed (for example, Exim may be
43198 set up to allow unconditional relaying from the client by an IP address check).
43199 You can make such clients more friendly by not advertising AUTH to them.
43200 For example, if clients on the 10.9.8.0/24 network are permitted (by the ACL
43201 that runs for RCPT) to relay without authentication, you should set
43202 </para>
43203 <literallayout class="monospaced">
43204 auth_advertise_hosts = ! 10.9.8.0/24
43205 </literallayout>
43206 <para>
43207 so that no authentication mechanisms are advertised to them.
43208 </para>
43209 <para>
43210 The <option>server_advertise_condition</option> controls the advertisement of individual
43211 authentication mechanisms. For example, it can be used to restrict the
43212 advertisement of a patricular mechanism to encrypted connections, by a setting
43213 such as:
43214 </para>
43215 <literallayout class="monospaced">
43216 server_advertise_condition = ${if eq{$tls_cipher}{}{no}{yes}}
43217 </literallayout>
43218 <para>
43219 <indexterm role="concept">
43220 <primary><varname>$tls_cipher</varname></primary>
43221 </indexterm>
43222 If the session is encrypted, <varname>$tls_cipher</varname> is not empty, and so the expansion
43223 yields <quote>yes</quote>, which allows the advertisement to happen.
43224 </para>
43225 <para>
43226 When an Exim server receives an AUTH command from a client, it rejects it
43227 immediately if AUTH was not advertised in response to an earlier EHLO
43228 command. This is the case if
43229 </para>
43230 <itemizedlist>
43231 <listitem>
43232 <para>
43233 The client host does not match <option>auth_advertise_hosts</option>; or
43234 </para>
43235 </listitem>
43236 <listitem>
43237 <para>
43238 No authenticators are configured with server options; or
43239 </para>
43240 </listitem>
43241 <listitem>
43242 <para>
43243 Expansion of <option>server_advertise_condition</option> blocked the advertising of all the
43244 server authenticators.
43245 </para>
43246 </listitem>
43247 </itemizedlist>
43248 <para>
43249 Otherwise, Exim runs the ACL specified by <option>acl_smtp_auth</option> in order
43250 to decide whether to accept the command. If <option>acl_smtp_auth</option> is not set,
43251 AUTH is accepted from any client host.
43252 </para>
43253 <para>
43254 If AUTH is not rejected by the ACL, Exim searches its configuration for a
43255 server authentication mechanism that was advertised in response to EHLO and
43256 that matches the one named in the AUTH command. If it finds one, it runs
43257 the appropriate authentication protocol, and authentication either succeeds or
43258 fails. If there is no matching advertised mechanism, the AUTH command is
43259 rejected with a 504 error.
43260 </para>
43261 <para>
43262 <indexterm role="concept">
43263 <primary><varname>$received_protocol</varname></primary>
43264 </indexterm>
43265 <indexterm role="concept">
43266 <primary><varname>$sender_host_authenticated</varname></primary>
43267 </indexterm>
43268 When a message is received from an authenticated host, the value of
43269 <varname>$received_protocol</varname> is set to <quote>esmtpa</quote> or <quote>esmtpsa</quote> instead of <quote>esmtp</quote>
43270 or <quote>esmtps</quote>, and <varname>$sender_host_authenticated</varname> contains the name (not the
43271 public name) of the authenticator driver that successfully authenticated the
43272 client from which the message was received. This variable is empty if there was
43273 no successful authentication.
43274 </para>
43275 </section>
43276 <section>
43277 <title>Testing server authentication</title>
43278 <para>
43279 <indexterm role="concept">
43280 <primary>authentication</primary>
43281 <secondary>testing a server</secondary>
43282 </indexterm>
43283 <indexterm role="concept">
43284 <primary>AUTH</primary>
43285 <secondary>testing a server</secondary>
43286 </indexterm>
43287 <indexterm role="concept">
43288 <primary>base64 encoding</primary>
43289 <secondary>creating authentication test data</secondary>
43290 </indexterm>
43291 Exim&#x2019;s <option>-bh</option> option can be useful for testing server authentication
43292 configurations. The data for the AUTH command has to be sent using base64
43293 encoding. A quick way to produce such data for testing is the following Perl
43294 script:
43295 </para>
43296 <literallayout class="monospaced">
43297 use MIME::Base64;
43298 printf ("%s", encode_base64(eval "\"$ARGV[0]\""));
43299 </literallayout>
43300 <para>
43301 <indexterm role="concept">
43302 <primary>binary zero</primary>
43303 <secondary>in authentication data</secondary>
43304 </indexterm>
43305 This interprets its argument as a Perl string, and then encodes it. The
43306 interpretation as a Perl string allows binary zeros, which are required for
43307 some kinds of authentication, to be included in the data. For example, a
43308 command line to run this script on such data might be
43309 </para>
43310 <literallayout class="monospaced">
43311 encode '\0user\0password'
43312 </literallayout>
43313 <para>
43314 Note the use of single quotes to prevent the shell interpreting the
43315 backslashes, so that they can be interpreted by Perl to specify characters
43316 whose code value is zero.
43317 </para>
43318 <para>
43319 <emphasis role="bold">Warning 1</emphasis>: If either of the user or password strings starts with an octal
43320 digit, you must use three zeros instead of one after the leading backslash. If
43321 you do not, the octal digit that starts your string will be incorrectly
43322 interpreted as part of the code for the first character.
43323 </para>
43324 <para>
43325 <emphasis role="bold">Warning 2</emphasis>: If there are characters in the strings that Perl interprets
43326 specially, you must use a Perl escape to prevent them being misinterpreted. For
43327 example, a command such as
43328 </para>
43329 <literallayout class="monospaced">
43330 encode '\0user@domain.com\0pas$$word'
43331 </literallayout>
43332 <para>
43333 gives an incorrect answer because of the unescaped <quote>@</quote> and <quote>$</quote> characters.
43334 </para>
43335 <para>
43336 If you have the <option>mimencode</option> command installed, another way to do produce
43337 base64-encoded strings is to run the command
43338 </para>
43339 <literallayout class="monospaced">
43340 echo -e -n `\0user\0password' | mimencode
43341 </literallayout>
43342 <para>
43343 The <option>-e</option> option of <option>echo</option> enables the interpretation of backslash escapes
43344 in the argument, and the <option>-n</option> option specifies no newline at the end of its
43345 output. However, not all versions of <option>echo</option> recognize these options, so you
43346 should check your version before relying on this suggestion.
43347 </para>
43348 </section>
43349 <section>
43350 <title>Authentication by an Exim client</title>
43351 <para>
43352 <indexterm role="concept">
43353 <primary>authentication</primary>
43354 <secondary>on an Exim client</secondary>
43355 </indexterm>
43356 The <command>smtp</command> transport has two options called <option>hosts_require_auth</option> and
43357 <option>hosts_try_auth</option>. When the <command>smtp</command> transport connects to a server that
43358 announces support for authentication, and the host matches an entry in either
43359 of these options, Exim (as a client) tries to authenticate as follows:
43360 </para>
43361 <itemizedlist>
43362 <listitem>
43363 <para>
43364 For each authenticator that is configured as a client, it searches the
43365 authentication mechanisms announced by the server for one whose name
43366 matches the public name of the authenticator.
43367 </para>
43368 </listitem>
43369 <listitem>
43370 <para>
43371 <indexterm role="concept">
43372 <primary><varname>$host</varname></primary>
43373 </indexterm>
43374 <indexterm role="concept">
43375 <primary><varname>$host_address</varname></primary>
43376 </indexterm>
43377 When it finds one that matches, it runs the authenticator&#x2019;s client code.
43378 The variables <varname>$host</varname> and <varname>$host_address</varname> are available for any string
43379 expansions that the client might do. They are set to the server&#x2019;s name and
43380 IP address. If any expansion is forced to fail, the authentication attempt
43381 is abandoned,
43382 and Exim moves on to the next authenticator.
43383 Otherwise an expansion failure causes delivery to be
43384 deferred.
43385 </para>
43386 </listitem>
43387 <listitem>
43388 <para>
43389 If the result of the authentication attempt is a temporary error or a timeout,
43390 Exim abandons trying to send the message to the host for the moment. It will
43391 try again later. If there are any backup hosts available, they are tried in the
43392 usual way.
43393 </para>
43394 </listitem>
43395 <listitem>
43396 <para>
43397 If the response to authentication is a permanent error (5<emphasis>xx</emphasis> code), Exim
43398 carries on searching the list of authenticators and tries another one if
43399 possible. If all authentication attempts give permanent errors, or if there are
43400 no attempts because no mechanisms match (or option expansions force failure),
43401 what happens depends on whether the host matches <option>hosts_require_auth</option> or
43402 <option>hosts_try_auth</option>. In the first case, a temporary error is generated, and
43403 delivery is deferred. The error can be detected in the retry rules, and thereby
43404 turned into a permanent error if you wish. In the second case, Exim tries to
43405 deliver the message unauthenticated.
43406 </para>
43407 </listitem>
43408 </itemizedlist>
43409 <para>
43410 <indexterm role="concept">
43411 <primary>AUTH</primary>
43412 <secondary>on MAIL command</secondary>
43413 </indexterm>
43414 When Exim has authenticated itself to a remote server, it adds the AUTH
43415 parameter to the MAIL commands it sends, if it has an authenticated sender for
43416 the message. If the message came from a remote host, the authenticated sender
43417 is the one that was receiving on an incoming MAIL command, provided that the
43418 incoming connection was authenticated and the <option>server_mail_auth</option> condition
43419 allowed the authenticated sender to be retained. If a local process calls Exim
43420 to send a message, the sender address that is built from the login name and
43421 <option>qualify_domain</option> is treated as authenticated. However, if the
43422 <option>authenticated_sender</option> option is set on the <command>smtp</command> transport, it overrides
43423 the authenticated sender that was received with the message.
43424 <indexterm role="concept" startref="IIDauthconf1" class="endofrange"/>
43425 <indexterm role="concept" startref="IIDauthconf2" class="endofrange"/>
43426 </para>
43427 </section>
43428 </chapter>
43429
43430 <chapter id="CHAPplaintext">
43431 <title>The plaintext authenticator</title>
43432 <para>
43433 <indexterm role="concept" id="IIDplaiauth1" class="startofrange">
43434 <primary><command>plaintext</command> authenticator</primary>
43435 </indexterm>
43436 <indexterm role="concept" id="IIDplaiauth2" class="startofrange">
43437 <primary>authenticators</primary>
43438 <secondary><command>plaintext</command></secondary>
43439 </indexterm>
43440 </para>
43441 <para revisionflag="changed">
43442 The <command>plaintext</command> authenticator can be configured to support the PLAIN and
43443 LOGIN authentication mechanisms, both of which transfer authentication data as
43444 plain (unencrypted) text (though base64 encoded). The use of plain text is a
43445 security risk; you are strongly advised to insist on the use of SMTP encryption
43446 (see chapter <xref linkend="CHAPTLS"/>) if you use the PLAIN or LOGIN mechanisms. If you do
43447 use unencrypted plain text, you should not use the same passwords for SMTP
43448 connections as you do for login accounts.
43449 </para>
43450 <section>
43451 <title>Using plaintext in a server</title>
43452 <para>
43453 <indexterm role="concept">
43454 <primary>options</primary>
43455 <secondary><command>plaintext</command> authenticator (server)</secondary>
43456 </indexterm>
43457 When running as a server, <command>plaintext</command> performs the authentication test by
43458 expanding a string. It has the following options:
43459 </para>
43460 <para>
43461 <indexterm role="option">
43462 <primary>server_prompts</primary>
43463 </indexterm>
43464 </para>
43465 <informaltable frame="all">
43466 <tgroup cols="4" colsep="0" rowsep="0">
43467 <colspec colwidth="8*" align="left"/>
43468 <colspec colwidth="5*" align="center"/>
43469 <colspec colwidth="5*" align="center"/>
43470 <colspec colwidth="6*" align="right"/>
43471 <tbody>
43472 <row>
43473 <entry><option>server_prompts</option></entry>
43474 <entry>Use: <emphasis>plaintext</emphasis></entry>
43475 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43476 <entry>Default: <emphasis>unset</emphasis></entry>
43477 </row>
43478 </tbody>
43479 </tgroup>
43480 </informaltable>
43481 <para>
43482 The contents of this option, after expansion, must be a colon-separated list of
43483 prompt strings. If expansion fails, a temporary authentication rejection is
43484 given.
43485 </para>
43486 <para>
43487 <indexterm role="option">
43488 <primary>server_condition</primary>
43489 </indexterm>
43490 </para>
43491 <informaltable frame="all">
43492 <tgroup cols="4" colsep="0" rowsep="0">
43493 <colspec colwidth="8*" align="left"/>
43494 <colspec colwidth="5*" align="center"/>
43495 <colspec colwidth="5*" align="center"/>
43496 <colspec colwidth="6*" align="right"/>
43497 <tbody>
43498 <row>
43499 <entry><option>server_condition</option></entry>
43500 <entry>Use: <emphasis>plaintext</emphasis></entry>
43501 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43502 <entry>Default: <emphasis>unset</emphasis></entry>
43503 </row>
43504 </tbody>
43505 </tgroup>
43506 </informaltable>
43507 <para>
43508 This option must be set in order to configure the driver as a server. Its use
43509 is described below.
43510 </para>
43511 <para>
43512 <indexterm role="concept">
43513 <primary>AUTH</primary>
43514 <secondary>in <command>plaintext</command> authenticator</secondary>
43515 </indexterm>
43516 <indexterm role="concept">
43517 <primary>binary zero</primary>
43518 <secondary>in <command>plaintext</command> authenticator</secondary>
43519 </indexterm>
43520 <indexterm role="concept">
43521 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
43522 <secondary>in <command>plaintext</command> authenticator</secondary>
43523 </indexterm>
43524 <indexterm role="concept">
43525 <primary><varname>$auth1</varname>, <varname>$auth2</varname>, etc</primary>
43526 </indexterm>
43527 <indexterm role="concept">
43528 <primary>base64 encoding</primary>
43529 <secondary>in <command>plaintext</command> authenticator</secondary>
43530 </indexterm>
43531 </para>
43532 <para revisionflag="changed">
43533 The data sent by the client with the AUTH command, or in response to
43534 subsequent prompts, is base64 encoded, and so may contain any byte values
43535 when decoded. If any data is supplied with the command, it is treated as a
43536 list of strings, separated by NULs (binary zeros), the first three of which are
43537 placed in the expansion variables <varname>$auth1</varname>, <varname>$auth2</varname>, and <varname>$auth3</varname> (neither
43538 LOGIN nor PLAIN uses more than three strings).
43539 </para>
43540 <para revisionflag="changed">
43541 For compatibility with previous releases of Exim, the values are also placed in
43542 the expansion variables <varname>$1</varname>, <varname>$2</varname>, and <varname>$3</varname>. However, the use of these
43543 variables for this purpose is now deprecated, as it can lead to confusion in
43544 string expansions that also use them for other things.
43545 </para>
43546 <para>
43547 If there are more strings in <option>server_prompts</option> than the number of strings
43548 supplied with the AUTH command, the remaining prompts are used to obtain more
43549 data. Each response from the client may be a list of NUL-separated strings.
43550 </para>
43551 <para>
43552 <indexterm role="concept">
43553 <primary><varname>$authenticated_id</varname></primary>
43554 </indexterm>
43555 Once a sufficient number of data strings have been received,
43556 <option>server_condition</option> is expanded. If the expansion is forced to fail,
43557 authentication fails. Any other expansion failure causes a temporary error code
43558 to be returned. If the result of a successful expansion is an empty string,
43559 <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, authentication fails. If the result of the
43560 expansion is <quote>1</quote>, <quote>yes</quote>, or <quote>true</quote>, authentication succeeds and the
43561 generic <option>server_set_id</option> option is expanded and saved in <varname>$authenticated_id</varname>.
43562 For any other result, a temporary error code is returned, with the expanded
43563 string as the error text.
43564 </para>
43565 <para>
43566 <emphasis role="bold">Warning</emphasis>: If you use a lookup in the expansion to find the user&#x2019;s
43567 password, be sure to make the authentication fail if the user is unknown.
43568 There are good and bad examples at the end of the next section.
43569 </para>
43570 </section>
43571 <section>
43572 <title>The PLAIN authentication mechanism</title>
43573 <para>
43574 <indexterm role="concept">
43575 <primary>PLAIN authentication mechanism</primary>
43576 </indexterm>
43577 <indexterm role="concept">
43578 <primary>authentication</primary>
43579 <secondary>PLAIN mechanism</secondary>
43580 </indexterm>
43581 <indexterm role="concept">
43582 <primary>binary zero</primary>
43583 <secondary>in <command>plaintext</command> authenticator</secondary>
43584 </indexterm>
43585 The PLAIN authentication mechanism (RFC 2595) specifies that three strings be
43586 sent as one item of data (that is, one combined string containing two NUL
43587 separators). The data is sent either as part of the AUTH command, or
43588 subsequently in response to an empty prompt from the server.
43589 </para>
43590 <para>
43591 The second and third strings are a user name and a corresponding password.
43592 Using a single fixed user name and password as an example, this could be
43593 configured as follows:
43594 </para>
43595 <literallayout class="monospaced" revisionflag="changed">
43596 fixed_plain:
43597   driver = plaintext
43598   public_name = PLAIN
43599   server_prompts = :
43600   server_condition = \
43601     ${if and {{eq{$auth2}{username}}{eq{$auth3}{mysecret}}}\
43602       {yes}{no}}
43603   server_set_id = $auth2
43604 </literallayout>
43605 <para revisionflag="changed">
43606 The <option>server_prompts</option> setting specifies a single, empty prompt (empty items at
43607 the end of a string list are ignored). If all the data comes as part of the
43608 AUTH command, as is commonly the case, the prompt is not used. This
43609 authenticator is advertised in the response to EHLO as
43610 </para>
43611 <literallayout class="monospaced" revisionflag="changed">
43612 250-AUTH PLAIN
43613 </literallayout>
43614 <para revisionflag="changed">
43615 and a client host can authenticate itself by sending the command
43616 </para>
43617 <literallayout class="monospaced" revisionflag="changed">
43618 AUTH PLAIN AHVzZXJuYW1lAG15c2VjcmV0
43619 </literallayout>
43620 <para revisionflag="changed">
43621 As this contains three strings (more than the number of prompts), no further
43622 data is required from the client. Alternatively, the client may just send
43623 </para>
43624 <literallayout class="monospaced" revisionflag="changed">
43625 AUTH PLAIN
43626 </literallayout>
43627 <para revisionflag="changed">
43628 to initiate authentication, in which case the server replies with an empty
43629 prompt. The client must respond with the combined data string.
43630 </para>
43631 <para revisionflag="changed">
43632 The data string is base64 encoded, as required by the RFC. This example,
43633 when decoded, is &lt;<emphasis>NUL</emphasis>&gt;<literal>username</literal>&lt;<emphasis>NUL</emphasis>&gt;<literal>mysecret</literal>, where &lt;<emphasis>NUL</emphasis>&gt;
43634 represents a zero byte. This is split up into three strings, the first of which
43635 is empty. The <option>server_condition</option> option in the authenticator checks that the
43636 second two are <literal>username</literal> and <literal>mysecret</literal> respectively.
43637 </para>
43638 <para revisionflag="changed">
43639 Having just one fixed user name and password, as in this example, is not very
43640 realistic, though for a small organization with only a handful of
43641 authenticating clients it could make sense.
43642 </para>
43643 <para revisionflag="changed">
43644 A more sophisticated instance of this authenticator could use the user name in
43645 <varname>$auth2</varname> to look up a password in a file or database, and maybe do an encrypted
43646 comparison (see <option>crypteq</option> in chapter <xref linkend="CHAPexpand"/>). Here is a example of
43647 this approach, where the passwords are looked up in a DBM file. <emphasis role="bold">Warning</emphasis>:
43648 This is an incorrect example:
43649 </para>
43650 <literallayout class="monospaced" revisionflag="changed">
43651 server_condition = \
43652   ${if eq{$auth3}{${lookup{$auth2}dbm{/etc/authpwd}}}{yes}{no}}
43653 </literallayout>
43654 <para revisionflag="changed">
43655 The expansion uses the user name (<varname>$auth2</varname>) as the key to look up a password,
43656 which it then compares to the supplied password (<varname>$auth3</varname>). Why is this example
43657 incorrect? It works fine for existing users, but consider what happens if a
43658 non-existent user name is given. The lookup fails, but as no success/failure
43659 strings are given for the lookup, it yields an empty string. Thus, to defeat
43660 the authentication, all a client has to do is to supply a non-existent user
43661 name and an empty password. The correct way of writing this test is:
43662 </para>
43663 <literallayout class="monospaced" revisionflag="changed">
43664 server_condition = ${lookup{$auth2}dbm{/etc/authpwd}\
43665   {${if eq{$value}{$auth3}{yes}{no}}}{no}}
43666 </literallayout>
43667 <para>
43668 In this case, if the lookup succeeds, the result is checked; if the lookup
43669 fails, authentication fails. If <option>crypteq</option> is being used instead of <option>eq</option>,
43670 the first example is in fact safe, because <option>crypteq</option> always fails if its
43671 second argument is empty. However, the second way of writing the test makes the
43672 logic clearer.
43673 </para>
43674 </section>
43675 <section>
43676 <title>The LOGIN authentication mechanism</title>
43677 <para>
43678 <indexterm role="concept">
43679 <primary>LOGIN authentication mechanism</primary>
43680 </indexterm>
43681 <indexterm role="concept">
43682 <primary>authentication</primary>
43683 <secondary>LOGIN mechanism</secondary>
43684 </indexterm>
43685 The LOGIN authentication mechanism is not documented in any RFC, but is in use
43686 in a number of programs. No data is sent with the AUTH command. Instead, a
43687 user name and password are supplied separately, in response to prompts. The
43688 plaintext authenticator can be configured to support this as in this example:
43689 </para>
43690 <literallayout class="monospaced" revisionflag="changed">
43691 fixed_login:
43692   driver = plaintext
43693   public_name = LOGIN
43694   server_prompts = User Name : Password
43695   server_condition = \
43696     ${if and {{eq{$auth1}{username}}{eq{$auth2}{mysecret}}}\
43697       {yes}{no}}
43698   server_set_id = $auth1
43699 </literallayout>
43700 <para>
43701 Because of the way plaintext operates, this authenticator accepts data supplied
43702 with the AUTH command (in contravention of the specification of LOGIN), but
43703 if the client does not supply it (as is the case for LOGIN clients), the prompt
43704 strings are used to obtain two data items.
43705 </para>
43706 <para>
43707 Some clients are very particular about the precise text of the prompts. For
43708 example, Outlook Express is reported to recognize only <quote>Username:</quote> and
43709 <quote>Password:</quote>. Here is an example of a LOGIN authenticator that uses those
43710 strings. It uses the <option>ldapauth</option> expansion condition to check the user
43711 name and password by binding to an LDAP server:
43712 </para>
43713 <literallayout class="monospaced" revisionflag="changed">
43714 login:
43715   driver = plaintext
43716   public_name = LOGIN
43717   server_prompts = Username:: : Password::
43718   server_condition = ${if ldapauth \
43719     {user="cn=${quote_ldap_dn:$auth1},ou=people,o=example.org" \
43720     pass=${quote:$auth2} \
43721     ldap://ldap.example.org/}{yes}{no}}
43722   server_set_id = uid=$auth1,ou=people,o=example.org
43723 </literallayout>
43724 <para>
43725 Note the use of the <option>quote_ldap_dn</option> operator to correctly quote the DN for
43726 authentication. However, the basic <option>quote</option> operator, rather than any of the
43727 LDAP quoting operators, is the correct one to use for the password, because
43728 quoting is needed only to make the password conform to the Exim syntax. At the
43729 LDAP level, the password is an uninterpreted string.
43730 </para>
43731 </section>
43732 <section>
43733 <title>Support for different kinds of authentication</title>
43734 <para>
43735 A number of string expansion features are provided for the purpose of
43736 interfacing to different ways of user authentication. These include checking
43737 traditionally encrypted passwords from <filename>/etc/passwd</filename> (or equivalent), PAM,
43738 Radius, <option>ldapauth</option>, <emphasis>pwcheck</emphasis>, and <emphasis>saslauthd</emphasis>. For details see section
43739 <xref linkend="SECTexpcond"/>.
43740 </para>
43741 </section>
43742 <section>
43743 <title>Using plaintext in a client</title>
43744 <para>
43745 <indexterm role="concept">
43746 <primary>options</primary>
43747 <secondary><command>plaintext</command> authenticator (client)</secondary>
43748 </indexterm>
43749 The <command>plaintext</command> authenticator has two client options:
43750 </para>
43751 <para revisionflag="changed">
43752 <indexterm role="option">
43753 <primary>client_ignore_invalid_base64</primary>
43754 </indexterm>
43755 </para>
43756 <informaltable frame="all" revisionflag="changed">
43757 <tgroup cols="4" colsep="0" rowsep="0">
43758 <colspec colwidth="8*" align="left"/>
43759 <colspec colwidth="5*" align="center"/>
43760 <colspec colwidth="5*" align="center"/>
43761 <colspec colwidth="6*" align="right"/>
43762 <tbody>
43763 <row>
43764 <entry><option>client_ignore_invalid_base64</option></entry>
43765 <entry>Use: <emphasis>plaintext</emphasis></entry>
43766 <entry>Type: <emphasis>boolean</emphasis></entry>
43767 <entry>Default: <emphasis>false</emphasis></entry>
43768 </row>
43769 </tbody>
43770 </tgroup>
43771 </informaltable>
43772 <para revisionflag="changed">
43773 If the client receives a server prompt that is not a valid base64 string,
43774 authentication is abandoned by default. However, if this option is set true,
43775 the error in the challenge is ignored and the client sends the response as
43776 usual.
43777 </para>
43778 <para>
43779 <indexterm role="option">
43780 <primary>client_send</primary>
43781 </indexterm>
43782 </para>
43783 <informaltable frame="all">
43784 <tgroup cols="4" colsep="0" rowsep="0">
43785 <colspec colwidth="8*" align="left"/>
43786 <colspec colwidth="5*" align="center"/>
43787 <colspec colwidth="5*" align="center"/>
43788 <colspec colwidth="6*" align="right"/>
43789 <tbody>
43790 <row>
43791 <entry><option>client_send</option></entry>
43792 <entry>Use: <emphasis>plaintext</emphasis></entry>
43793 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43794 <entry>Default: <emphasis>unset</emphasis></entry>
43795 </row>
43796 </tbody>
43797 </tgroup>
43798 </informaltable>
43799 <para revisionflag="changed">
43800 The string is a colon-separated list of authentication data strings. Each
43801 string is independently expanded before being sent to the server. The first
43802 string is sent with the AUTH command; any more strings are sent in response
43803 to prompts from the server. Before each string is expanded, the value of the
43804 most recent prompt is placed in the next <varname>$auth</varname>&lt;<emphasis>n</emphasis>&gt; variable, starting
43805 with <varname>$auth1</varname> for the first prompt. Up to three prompts are stored in this
43806 way. Thus, the prompt that is received in response to sending the first string
43807 (with the AUTH command) can be used in the expansion of the second string, and
43808 so on. If an invalid base64 string is received when
43809 <option>client_ignore_invalid_base64</option> is set, an empty string is put in the
43810 <varname>$auth</varname>&lt;<emphasis>n</emphasis>&gt; variable.
43811 </para>
43812 <para>
43813 <emphasis role="bold">Note</emphasis>: You cannot use expansion to create multiple strings, because
43814 splitting takes priority and happens first.
43815 </para>
43816 <para>
43817 Because the PLAIN authentication mechanism requires NUL (binary zero) bytes in
43818 the data, further processing is applied to each string before it is sent. If
43819 there are any single circumflex characters in the string, they are converted to
43820 NULs. Should an actual circumflex be required as data, it must be doubled in
43821 the string.
43822 </para>
43823 <para>
43824 This is an example of a client configuration that implements the PLAIN
43825 authentication mechanism with a fixed user name and password:
43826 </para>
43827 <literallayout class="monospaced">
43828 fixed_plain:
43829   driver = plaintext
43830   public_name = PLAIN
43831   client_send = ^username^mysecret
43832 </literallayout>
43833 <para>
43834 The lack of colons means that the entire text is sent with the AUTH
43835 command, with the circumflex characters converted to NULs. A similar example
43836 that uses the LOGIN mechanism is:
43837 </para>
43838 <literallayout class="monospaced">
43839 fixed_login:
43840   driver = plaintext
43841   public_name = LOGIN
43842   client_send = : username : mysecret
43843 </literallayout>
43844 <para>
43845 The initial colon means that the first string is empty, so no data is sent with
43846 the AUTH command itself. The remaining strings are sent in response to
43847 prompts.
43848 <indexterm role="concept" startref="IIDplaiauth1" class="endofrange"/>
43849 <indexterm role="concept" startref="IIDplaiauth2" class="endofrange"/>
43850 </para>
43851 </section>
43852 </chapter>
43853
43854 <chapter>
43855 <title>The cram_md5 authenticator</title>
43856 <para>
43857 <indexterm role="concept" id="IIDcramauth1" class="startofrange">
43858 <primary><command>cram_md5</command> authenticator</primary>
43859 </indexterm>
43860 <indexterm role="concept" id="IIDcramauth2" class="startofrange">
43861 <primary>authenticators</primary>
43862 <secondary><command>cram_md5</command></secondary>
43863 </indexterm>
43864 <indexterm role="concept">
43865 <primary>CRAM-MD5 authentication mechanism</primary>
43866 </indexterm>
43867 <indexterm role="concept">
43868 <primary>authentication</primary>
43869 <secondary>CRAM-MD5 mechanism</secondary>
43870 </indexterm>
43871 The CRAM-MD5 authentication mechanism is described in RFC 2195. The server
43872 sends a challenge string to the client, and the response consists of a user
43873 name and the CRAM-MD5 digest of the challenge string combined with a secret
43874 string (password) which is known to both server and client. Thus, the secret
43875 is not sent over the network as plain text, which makes this authenticator more
43876 secure than <command>plaintext</command>. However, the downside is that the secret has to be
43877 available in plain text at either end.
43878 </para>
43879 <section>
43880 <title>Using cram_md5 as a server</title>
43881 <para>
43882 <indexterm role="concept">
43883 <primary>options</primary>
43884 <secondary><command>cram_md5</command> authenticator (server)</secondary>
43885 </indexterm>
43886 This authenticator has one server option, which must be set to configure the
43887 authenticator as a server:
43888 </para>
43889 <para>
43890 <indexterm role="option">
43891 <primary>server_secret</primary>
43892 </indexterm>
43893 </para>
43894 <informaltable frame="all">
43895 <tgroup cols="4" colsep="0" rowsep="0">
43896 <colspec colwidth="8*" align="left"/>
43897 <colspec colwidth="5*" align="center"/>
43898 <colspec colwidth="5*" align="center"/>
43899 <colspec colwidth="6*" align="right"/>
43900 <tbody>
43901 <row>
43902 <entry><option>server_secret</option></entry>
43903 <entry>Use: <emphasis>cram_md5</emphasis></entry>
43904 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43905 <entry>Default: <emphasis>unset</emphasis></entry>
43906 </row>
43907 </tbody>
43908 </tgroup>
43909 </informaltable>
43910 <para>
43911 <indexterm role="concept">
43912 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
43913 <secondary>in <command>cram_md5</command> authenticator</secondary>
43914 </indexterm>
43915 When the server receives the client&#x2019;s response, the user name is placed in
43916 the expansion variable <phrase revisionflag="changed"><varname>$auth1</varname></phrase>, and <option>server_secret</option> is expanded to
43917 obtain the password for that user. The server then computes the CRAM-MD5 digest
43918 that the client should have sent, and checks that it received the correct
43919 string. If the expansion of <option>server_secret</option> is forced to fail, authentication
43920 fails. If the expansion fails for some other reason, a temporary error code is
43921 returned to the client.
43922 </para>
43923 <para revisionflag="changed">
43924 For compatibility with previous releases of Exim, the user name is also placed
43925 in <varname>$1</varname>. However, the use of this variables for this purpose is now
43926 deprecated, as it can lead to confusion in string expansions that also use
43927 numeric variables for other things.
43928 </para>
43929 <para>
43930 For example, the following authenticator checks that the user name given by the
43931 client is <quote>ph10</quote>, and if so, uses <quote>secret</quote> as the password. For any other
43932 user name, authentication fails.
43933 </para>
43934 <literallayout class="monospaced" revisionflag="changed">
43935 fixed_cram:
43936   driver = cram_md5
43937   public_name = CRAM-MD5
43938   server_secret = ${if eq{$auth1}{ph10}{secret}fail}
43939   server_set_id = $auth1
43940 </literallayout>
43941 <para>
43942 <indexterm role="concept">
43943 <primary><varname>$authenticated_id</varname></primary>
43944 </indexterm>
43945 If authentication succeeds, the setting of <option>server_set_id</option> preserves the user
43946 name in <varname>$authenticated_id</varname>. A more tyical configuration might look up the
43947 secret string in a file, using the user name as the key. For example:
43948 </para>
43949 <literallayout class="monospaced" revisionflag="changed">
43950 lookup_cram:
43951   driver = cram_md5
43952   public_name = CRAM-MD5
43953   server_secret = ${lookup{$auth1}lsearch{/etc/authpwd}{$value}fail}
43954   server_set_id = $auth1
43955 </literallayout>
43956 <para>
43957 Note that this expansion explicitly forces failure if the lookup fails
43958 because <varname>$1</varname> contains an unknown user name.
43959 </para>
43960 </section>
43961 <section>
43962 <title>Using cram_md5 as a client</title>
43963 <para>
43964 <indexterm role="concept">
43965 <primary>options</primary>
43966 <secondary><command>cram_md5</command> authenticator (client)</secondary>
43967 </indexterm>
43968 When used as a client, the <command>cram_md5</command> authenticator has two options:
43969 </para>
43970 <para>
43971 <indexterm role="option">
43972 <primary>client_name</primary>
43973 </indexterm>
43974 </para>
43975 <informaltable frame="all">
43976 <tgroup cols="4" colsep="0" rowsep="0">
43977 <colspec colwidth="8*" align="left"/>
43978 <colspec colwidth="5*" align="center"/>
43979 <colspec colwidth="5*" align="center"/>
43980 <colspec colwidth="6*" align="right"/>
43981 <tbody>
43982 <row>
43983 <entry><option>client_name</option></entry>
43984 <entry>Use: <emphasis>cram_md5</emphasis></entry>
43985 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43986 <entry>Default: <emphasis>the primary host name</emphasis></entry>
43987 </row>
43988 </tbody>
43989 </tgroup>
43990 </informaltable>
43991 <para>
43992 This string is expanded, and the result used as the user name data when
43993 computing the response to the server&#x2019;s challenge.
43994 </para>
43995 <para>
43996 <indexterm role="option">
43997 <primary>client_secret</primary>
43998 </indexterm>
43999 </para>
44000 <informaltable frame="all">
44001 <tgroup cols="4" colsep="0" rowsep="0">
44002 <colspec colwidth="8*" align="left"/>
44003 <colspec colwidth="5*" align="center"/>
44004 <colspec colwidth="5*" align="center"/>
44005 <colspec colwidth="6*" align="right"/>
44006 <tbody>
44007 <row>
44008 <entry><option>client_secret</option></entry>
44009 <entry>Use: <emphasis>cram_md5</emphasis></entry>
44010 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
44011 <entry>Default: <emphasis>unset</emphasis></entry>
44012 </row>
44013 </tbody>
44014 </tgroup>
44015 </informaltable>
44016 <para>
44017 This option must be set for the authenticator to work as a client. Its value is
44018 expanded and the result used as the secret string when computing the response.
44019 </para>
44020 <para>
44021 <indexterm role="concept">
44022 <primary><varname>$host</varname></primary>
44023 </indexterm>
44024 <indexterm role="concept">
44025 <primary><varname>$host_address</varname></primary>
44026 </indexterm>
44027 Different user names and secrets can be used for different servers by referring
44028 to <varname>$host</varname> or <varname>$host_address</varname> in the options. Forced failure of either
44029 expansion string is treated as an indication that this authenticator is not
44030 prepared to handle this case. Exim moves on to the next configured client
44031 authenticator. Any other expansion failure causes Exim to give up trying to
44032 send the message to the current server.
44033 </para>
44034 <para>
44035 A simple example configuration of a <command>cram_md5</command> authenticator, using fixed
44036 strings, is:
44037 </para>
44038 <literallayout class="monospaced">
44039 fixed_cram:
44040   driver = cram_md5
44041   public_name = CRAM-MD5
44042   client_name = ph10
44043   client_secret = secret
44044 </literallayout>
44045 <para>
44046 <indexterm role="concept" startref="IIDcramauth1" class="endofrange"/>
44047 <indexterm role="concept" startref="IIDcramauth2" class="endofrange"/>
44048 </para>
44049 </section>
44050 </chapter>
44051
44052 <chapter>
44053 <title>The cyrus_sasl authenticator</title>
44054 <para>
44055 <indexterm role="concept" id="IIDcyrauth1" class="startofrange">
44056 <primary><command>cyrus_sasl</command> authenticator</primary>
44057 </indexterm>
44058 <indexterm role="concept" id="IIDcyrauth2" class="startofrange">
44059 <primary>authenticators</primary>
44060 <secondary><command>cyrus_sasl</command></secondary>
44061 </indexterm>
44062 <indexterm role="concept">
44063 <primary>Cyrus</primary>
44064 <secondary>SASL library</secondary>
44065 </indexterm>
44066 The code for this authenticator was provided by Matthew Byng-Maddick of A L
44067 Digital Ltd (<emphasis role="bold"><ulink url="http://www.aldigital.co.uk">http://www.aldigital.co.uk</ulink></emphasis>).
44068 </para>
44069 <para>
44070 The <command>cyrus_sasl</command> authenticator provides server support for the Cyrus SASL
44071 library implementation of the RFC 2222 (<quote>Simple Authentication and Security
44072 Layer</quote>). This library supports a number of authentication mechanisms,
44073 including PLAIN and LOGIN, but also several others that Exim does not support
44074 directly. In particular, there is support for Kerberos authentication.
44075 </para>
44076 <para>
44077 The <command>cyrus_sasl</command> authenticator provides a gatewaying mechanism directly to
44078 the Cyrus interface, so if your Cyrus library can do, for example, CRAM-MD5,
44079 then so can the <command>cyrus_sasl</command> authenticator. By default it uses the public
44080 name of the driver to determine which mechanism to support.
44081 </para>
44082 <para>
44083 Where access to some kind of secret file is required, for example in GSSAPI
44084 or CRAM-MD5, it is worth noting that the authenticator runs as the Exim
44085 user, and that the Cyrus SASL library has no way of escalating privileges
44086 by default. You may also find you need to set environment variables,
44087 depending on the driver you are using.
44088 </para>
44089 <section>
44090 <title>Using cyrus_sasl as a server</title>
44091 <para revisionflag="changed">
44092 The <command>cyrus_sasl</command> authenticator has four private options. It puts the username
44093 (on a successful authentication) into <varname>$auth1</varname>. For compatibility with
44094 previous releases of Exim, the username is also placed in <varname>$1</varname>. However, the
44095 use of this variable for this purpose is now deprecated, as it can lead to
44096 confusion in string expansions that also use numeric variables for other
44097 things.
44098 </para>
44099 <para>
44100 <indexterm role="option">
44101 <primary>server_hostname</primary>
44102 </indexterm>
44103 </para>
44104 <informaltable frame="all">
44105 <tgroup cols="4" colsep="0" rowsep="0">
44106 <colspec colwidth="8*" align="left"/>
44107 <colspec colwidth="5*" align="center"/>
44108 <colspec colwidth="5*" align="center"/>
44109 <colspec colwidth="6*" align="right"/>
44110 <tbody>
44111 <row>
44112 <entry><option>server_hostname</option></entry>
44113 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
44114 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
44115 <entry>Default: <emphasis><literal>$primary_hostname</literal></emphasis></entry>
44116 </row>
44117 </tbody>
44118 </tgroup>
44119 </informaltable>
44120 <para>
44121 This option selects the hostname that is used when communicating with
44122 the library. It is up to the underlying SASL plug-in what it does with
44123 this data.
44124 </para>
44125 <para>
44126 <indexterm role="option">
44127 <primary>server_mech</primary>
44128 </indexterm>
44129 </para>
44130 <informaltable frame="all">
44131 <tgroup cols="4" colsep="0" rowsep="0">
44132 <colspec colwidth="8*" align="left"/>
44133 <colspec colwidth="5*" align="center"/>
44134 <colspec colwidth="5*" align="center"/>
44135 <colspec colwidth="6*" align="right"/>
44136 <tbody>
44137 <row>
44138 <entry><option>server_mech</option></entry>
44139 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
44140 <entry>Type: <emphasis>string</emphasis></entry>
44141 <entry>Default: <emphasis><literal>public_name</literal></emphasis></entry>
44142 </row>
44143 </tbody>
44144 </tgroup>
44145 </informaltable>
44146 <para>
44147 This option selects the authentication mechanism this driver should
44148 use. It allows you to use a different underlying mechanism from the
44149 advertised name. For example:
44150 </para>
44151 <literallayout class="monospaced" revisionflag="changed">
44152 sasl:
44153   driver = cyrus_sasl
44154   public_name = X-ANYTHING
44155   server_mech = CRAM-MD5
44156   server_set_id = $auth1
44157 </literallayout>
44158 <para>
44159 <indexterm role="option">
44160 <primary>server_realm</primary>
44161 </indexterm>
44162 </para>
44163 <informaltable frame="all">
44164 <tgroup cols="4" colsep="0" rowsep="0">
44165 <colspec colwidth="8*" align="left"/>
44166 <colspec colwidth="5*" align="center"/>
44167 <colspec colwidth="5*" align="center"/>
44168 <colspec colwidth="6*" align="right"/>
44169 <tbody>
44170 <row>
44171 <entry><option>server_realm</option></entry>
44172 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
44173 <entry>Type: <emphasis>string</emphasis></entry>
44174 <entry>Default: <emphasis>unset</emphasis></entry>
44175 </row>
44176 </tbody>
44177 </tgroup>
44178 </informaltable>
44179 <para>
44180 This specifies the SASL realm that the server claims to be in.
44181 </para>
44182 <para>
44183 <indexterm role="option">
44184 <primary>server_service</primary>
44185 </indexterm>
44186 </para>
44187 <informaltable frame="all">
44188 <tgroup cols="4" colsep="0" rowsep="0">
44189 <colspec colwidth="8*" align="left"/>
44190 <colspec colwidth="5*" align="center"/>
44191 <colspec colwidth="5*" align="center"/>
44192 <colspec colwidth="6*" align="right"/>
44193 <tbody>
44194 <row>
44195 <entry><option>server_service</option></entry>
44196 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
44197 <entry>Type: <emphasis>string</emphasis></entry>
44198 <entry>Default: <emphasis><literal>smtp</literal></emphasis></entry>
44199 </row>
44200 </tbody>
44201 </tgroup>
44202 </informaltable>
44203 <para>
44204 This is the SASL service that the server claims to implement.
44205 </para>
44206 <para>
44207 For straightforward cases, you do not need to set any of the authenticator&#x2019;s
44208 private options. All you need to do is to specify an appropriate mechanism as
44209 the public name. Thus, if you have a SASL library that supports CRAM-MD5 and
44210 PLAIN, you could have two authenticators as follows:
44211 </para>
44212 <literallayout class="monospaced" revisionflag="changed">
44213 sasl_cram_md5:
44214   driver = cyrus_sasl
44215   public_name = CRAM-MD5
44216   server_set_id = $auth1
44217
44218 sasl_plain:
44219   driver = cyrus_sasl
44220   public_name = PLAIN
44221   server_set_id = $auth1
44222 </literallayout>
44223 <para>
44224 Cyrus SASL does implement the LOGIN authentication method, even though it is
44225 not a standard method. It is disabled by default in the source distribution,
44226 but it is present in many binary distributions.
44227 <indexterm role="concept" startref="IIDcyrauth1" class="endofrange"/>
44228 <indexterm role="concept" startref="IIDcyrauth2" class="endofrange"/>
44229 </para>
44230 </section>
44231 </chapter>
44232
44233 <chapter id="CHAPspa">
44234 <title>The spa authenticator</title>
44235 <para>
44236 <indexterm role="concept" id="IIDspaauth1" class="startofrange">
44237 <primary><command>spa</command> authenticator</primary>
44238 </indexterm>
44239 <indexterm role="concept" id="IIDspaauth2" class="startofrange">
44240 <primary>authenticators</primary>
44241 <secondary><command>spa</command></secondary>
44242 </indexterm>
44243 <indexterm role="concept">
44244 <primary>authentication</primary>
44245 <secondary>Microsoft Secure Password</secondary>
44246 </indexterm>
44247 <indexterm role="concept">
44248 <primary>authentication</primary>
44249 <secondary>NTLM</secondary>
44250 </indexterm>
44251 <indexterm role="concept">
44252 <primary>Microsoft Secure Password Authentication</primary>
44253 </indexterm>
44254 <indexterm role="concept">
44255 <primary>NTLM authentication</primary>
44256 </indexterm>
44257 The <command>spa</command> authenticator provides client support for Microsoft&#x2019;s <emphasis>Secure
44258 Password Authentication</emphasis> mechanism,
44259 which is also sometimes known as NTLM (NT LanMan). The code for client side of
44260 this authenticator was contributed by Marc Prud&#x2019;hommeaux, and much of it is
44261 taken from the Samba project (<emphasis role="bold"><ulink url="http://www.samba.org">http://www.samba.org</ulink></emphasis>). The code for the
44262 server side was subsequently contributed by Tom Kistner. The mechanism works as
44263 follows:
44264 </para>
44265 <itemizedlist>
44266 <listitem>
44267 <para>
44268 After the AUTH command has been accepted, the client sends an SPA
44269 authentication request based on the user name and optional domain.
44270 </para>
44271 </listitem>
44272 <listitem>
44273 <para>
44274 The server sends back a challenge.
44275 </para>
44276 </listitem>
44277 <listitem>
44278 <para>
44279 The client builds a challenge response which makes use of the user&#x2019;s password
44280 and sends it to the server, which then accepts or rejects it.
44281 </para>
44282 </listitem>
44283 </itemizedlist>
44284 <para>
44285 Encryption is used to protect the password in transit.
44286 </para>
44287 <section>
44288 <title>Using spa as a server</title>
44289 <para>
44290 <indexterm role="concept">
44291 <primary>options</primary>
44292 <secondary><command>spa</command> authenticator (server)</secondary>
44293 </indexterm>
44294 The <command>spa</command> authenticator has just one server option:
44295 </para>
44296 <para>
44297 <indexterm role="option">
44298 <primary>server_password</primary>
44299 </indexterm>
44300 </para>
44301 <informaltable frame="all">
44302 <tgroup cols="4" colsep="0" rowsep="0">
44303 <colspec colwidth="8*" align="left"/>
44304 <colspec colwidth="5*" align="center"/>
44305 <colspec colwidth="5*" align="center"/>
44306 <colspec colwidth="6*" align="right"/>
44307 <tbody>
44308 <row>
44309 <entry><option>server_password</option></entry>
44310 <entry>Use: <emphasis>spa</emphasis></entry>
44311 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
44312 <entry>Default: <emphasis>unset</emphasis></entry>
44313 </row>
44314 </tbody>
44315 </tgroup>
44316 </informaltable>
44317 <para>
44318 <indexterm role="concept">
44319 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
44320 <secondary>in <command>spa</command> authenticator</secondary>
44321 </indexterm>
44322 </para>
44323 <para revisionflag="changed">
44324 This option is expanded, and the result must be the cleartext password for the
44325 authenticating user, whose name is at this point in <varname>$auth1</varname>. For
44326 compatibility with previous releases of Exim, the user name is also placed in
44327 <varname>$1</varname>. However, the use of this variable for this purpose is now deprecated, as
44328 it can lead to confusion in string expansions that also use numeric variables
44329 for other things. For example:
44330 </para>
44331 <literallayout class="monospaced" revisionflag="changed">
44332 spa:
44333   driver = spa
44334   public_name = NTLM
44335   server_password = \
44336     ${lookup{$auth1}lsearch{/etc/exim/spa_clearpass}{$value}fail}
44337 </literallayout>
44338 <para>
44339 If the expansion is forced to fail, authentication fails. Any other expansion
44340 failure causes a temporary error code to be returned.
44341 </para>
44342 </section>
44343 <section>
44344 <title>Using spa as a client</title>
44345 <para>
44346 <indexterm role="concept">
44347 <primary>options</primary>
44348 <secondary><command>spa</command> authenticator (client)</secondary>
44349 </indexterm>
44350 The <command>spa</command> authenticator has the following client options:
44351 </para>
44352 <para>
44353 <indexterm role="option">
44354 <primary>client_domain</primary>
44355 </indexterm>
44356 </para>
44357 <informaltable frame="all">
44358 <tgroup cols="4" colsep="0" rowsep="0">
44359 <colspec colwidth="8*" align="left"/>
44360 <colspec colwidth="5*" align="center"/>
44361 <colspec colwidth="5*" align="center"/>
44362 <colspec colwidth="6*" align="right"/>
44363 <tbody>
44364 <row>
44365 <entry><option>client_domain</option></entry>
44366 <entry>Use: <emphasis>spa</emphasis></entry>
44367 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
44368 <entry>Default: <emphasis>unset</emphasis></entry>
44369 </row>
44370 </tbody>
44371 </tgroup>
44372 </informaltable>
44373 <para>
44374 This option specifies an optional domain for the authentication.
44375 </para>
44376 <para>
44377 <indexterm role="option">
44378 <primary>client_password</primary>
44379 </indexterm>
44380 </para>
44381 <informaltable frame="all">
44382 <tgroup cols="4" colsep="0" rowsep="0">
44383 <colspec colwidth="8*" align="left"/>
44384 <colspec colwidth="5*" align="center"/>
44385 <colspec colwidth="5*" align="center"/>
44386 <colspec colwidth="6*" align="right"/>
44387 <tbody>
44388 <row>
44389 <entry><option>client_password</option></entry>
44390 <entry>Use: <emphasis>spa</emphasis></entry>
44391 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
44392 <entry>Default: <emphasis>unset</emphasis></entry>
44393 </row>
44394 </tbody>
44395 </tgroup>
44396 </informaltable>
44397 <para>
44398 This option specifies the user&#x2019;s password, and must be set.
44399 </para>
44400 <para>
44401 <indexterm role="option">
44402 <primary>client_username</primary>
44403 </indexterm>
44404 </para>
44405 <informaltable frame="all">
44406 <tgroup cols="4" colsep="0" rowsep="0">
44407 <colspec colwidth="8*" align="left"/>
44408 <colspec colwidth="5*" align="center"/>
44409 <colspec colwidth="5*" align="center"/>
44410 <colspec colwidth="6*" align="right"/>
44411 <tbody>
44412 <row>
44413 <entry><option>client_username</option></entry>
44414 <entry>Use: <emphasis>spa</emphasis></entry>
44415 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
44416 <entry>Default: <emphasis>unset</emphasis></entry>
44417 </row>
44418 </tbody>
44419 </tgroup>
44420 </informaltable>
44421 <para>
44422 This option specifies the user name, and must be set. Here is an example of a
44423 configuration of this authenticator for use with the mail servers at
44424 <emphasis>msn.com</emphasis>:
44425 </para>
44426 <literallayout class="monospaced">
44427 msn:
44428   driver = spa
44429   public_name = MSN
44430   client_username = msn/msn_username
44431   client_password = msn_plaintext_password
44432   client_domain = DOMAIN_OR_UNSET
44433 </literallayout>
44434 <para>
44435 <indexterm role="concept" startref="IIDspaauth1" class="endofrange"/>
44436 <indexterm role="concept" startref="IIDspaauth2" class="endofrange"/>
44437 </para>
44438 </section>
44439 </chapter>
44440
44441 <chapter id="CHAPTLS">
44442 <title>Encrypted SMTP connections using TLS/SSL</title>
44443 <titleabbrev>Encrypted SMTP connections</titleabbrev>
44444 <para>
44445 <indexterm role="concept" id="IIDencsmtp1" class="startofrange">
44446 <primary>encryption</primary>
44447 <secondary>on SMTP connection</secondary>
44448 </indexterm>
44449 <indexterm role="concept" id="IIDencsmtp2" class="startofrange">
44450 <primary>SMTP</primary>
44451 <secondary>encryption</secondary>
44452 </indexterm>
44453 <indexterm role="concept">
44454 <primary>TLS</primary>
44455 <secondary>on SMTP connection</secondary>
44456 </indexterm>
44457 <indexterm role="concept">
44458 <primary>OpenSSL</primary>
44459 </indexterm>
44460 <indexterm role="concept">
44461 <primary>GnuTLS</primary>
44462 </indexterm>
44463 Support for TLS (Transport Layer Security), formerly known as SSL (Secure
44464 Sockets Layer), is implemented by making use of the OpenSSL library or the
44465 GnuTLS library (Exim requires GnuTLS release 1.0 or later). There is no
44466 cryptographic code in the Exim distribution itself for implementing TLS. In
44467 order to use this feature you must install OpenSSL or GnuTLS, and then build a
44468 version of Exim that includes TLS support (see section <xref linkend="SECTinctlsssl"/>).
44469 You also need to understand the basic concepts of encryption at a managerial
44470 level, and in particular, the way that public keys, private keys, and
44471 certificates are used.
44472 </para>
44473 <para>
44474 RFC 3207 defines how SMTP connections can make use of encryption. Once a
44475 connection is established, the client issues a STARTTLS command. If the
44476 server accepts this, the client and the server negotiate an encryption
44477 mechanism. If the negotiation succeeds, the data that subsequently passes
44478 between them is encrypted.
44479 </para>
44480 <para>
44481 Exim&#x2019;s ACLs can detect whether the current SMTP session is encrypted or not,
44482 and if so, what cipher suite is in use, whether the client supplied a
44483 certificate, and whether or not that certificate was verified. This makes it
44484 possible for an Exim server to deny or accept certain commands based on the
44485 encryption state.
44486 </para>
44487 <para>
44488 <emphasis role="bold">Warning</emphasis>: Certain types of firewall and certain anti-virus products can
44489 disrupt TLS connections. You need to turn off SMTP scanning for these products
44490 in order to get TLS to work.
44491 </para>
44492 <section>
44493 <title>Support for the legacy <quote>ssmtp</quote> (aka <quote>smtps</quote>) protocol</title>
44494 <para>
44495 <indexterm role="concept">
44496 <primary>ssmtp protocol</primary>
44497 </indexterm>
44498 <indexterm role="concept">
44499 <primary>smtps protocol</primary>
44500 </indexterm>
44501 <indexterm role="concept">
44502 <primary>SMTP</primary>
44503 <secondary>ssmtp protocol</secondary>
44504 </indexterm>
44505 <indexterm role="concept">
44506 <primary>SMTP</primary>
44507 <secondary>smtps protocol</secondary>
44508 </indexterm>
44509 Early implementations of encrypted SMTP used a different TCP port from normal
44510 SMTP, and expected an encryption negotiation to start immediately, instead of
44511 waiting for a STARTTLS command from the client using the standard SMTP
44512 port. The protocol was called <quote>ssmtp</quote> or <quote>smtps</quote>, and port 465 was
44513 allocated for this purpose.
44514 </para>
44515 <para>
44516 This approach was abandoned when encrypted SMTP was standardised, but there are
44517 still some legacy clients that use it. Exim supports these clients by means of
44518 the <option>tls_on_connect_ports</option> global option. Its value must be a list of port
44519 numbers; the most common use is expected to be:
44520 </para>
44521 <literallayout class="monospaced">
44522 tls_on_connect_ports = 465
44523 </literallayout>
44524 <para>
44525 The port numbers specified by this option apply to all SMTP connections, both
44526 via the daemon and via <emphasis>inetd</emphasis>. You still need to specify all the ports that
44527 the daemon uses (by setting <option>daemon_smtp_ports</option> or <option>local_interfaces</option> or
44528 the <option>-oX</option> command line option) because <option>tls_on_connect_ports</option> does not add
44529 an extra port &ndash; rather, it specifies different behaviour on a port that is
44530 defined elsewhere.
44531 </para>
44532 <para>
44533 There is also a <option>-tls-on-connect</option> command line option. This overrides
44534 <option>tls_on_connect_ports</option>; it forces the legacy behaviour for all ports.
44535 </para>
44536 </section>
44537 <section id="SECTopenvsgnu">
44538 <title>OpenSSL vs GnuTLS</title>
44539 <para>
44540 <indexterm role="concept">
44541 <primary>TLS</primary>
44542 <secondary>OpenSSL <emphasis>vs</emphasis> GnuTLS</secondary>
44543 </indexterm>
44544 The first TLS support in Exim was implemented using OpenSSL. Support for GnuTLS
44545 followed later, when the first versions of GnuTLS were released. To build Exim
44546 to use GnuTLS, you need to set
44547 </para>
44548 <literallayout class="monospaced">
44549 USE_GNUTLS=yes
44550 </literallayout>
44551 <para>
44552 in Local/Makefile, in addition to
44553 </para>
44554 <literallayout class="monospaced">
44555 SUPPORT_TLS=yes
44556 </literallayout>
44557 <para>
44558 You must also set TLS_LIBS and TLS_INCLUDE appropriately, so that the
44559 include files and libraries for GnuTLS can be found.
44560 </para>
44561 <para>
44562 There are some differences in usage when using GnuTLS instead of OpenSSL:
44563 </para>
44564 <itemizedlist>
44565 <listitem>
44566 <para>
44567 The <option>tls_verify_certificates</option> option must contain the name of a file, not the
44568 name of a directory (for OpenSSL it can be either).
44569 </para>
44570 </listitem>
44571 <listitem>
44572 <para>
44573 The <option>tls_dhparam</option> option is ignored, because early versions of GnuTLS had no
44574 facility for varying its Diffie-Hellman parameters. I understand that this has
44575 changed, but Exim has not been updated to provide this facility.
44576 </para>
44577 </listitem>
44578 <listitem>
44579 <para>
44580 <indexterm role="concept">
44581 <primary><varname>$tls_peerdn</varname></primary>
44582 </indexterm>
44583 Distinguished Name (DN) strings reported by the OpenSSL library use a slash for
44584 separating fields; GnuTLS uses commas, in accordance with RFC 2253. This
44585 affects the value of the <varname>$tls_peerdn</varname> variable.
44586 </para>
44587 </listitem>
44588 <listitem>
44589 <para>
44590 OpenSSL identifies cipher suites using hyphens as separators, for example:
44591 DES-CBC3-SHA. GnuTLS uses underscores, for example: RSA_ARCFOUR_SHA. What is
44592 more, OpenSSL complains if underscores are present in a cipher list. To make
44593 life simpler, Exim changes underscores to hyhens for OpenSSL and hyphens to
44594 underscores for GnuTLS when processing lists of cipher suites in the
44595 <option>tls_require_ciphers</option> options (the global option and the <command>smtp</command> transport
44596 option).
44597 </para>
44598 </listitem>
44599 <listitem>
44600 <para>
44601 The <option>tls_require_ciphers</option> options operate differently, as described in the
44602 sections <xref linkend="SECTreqciphssl"/> and <xref linkend="SECTreqciphgnu"/>.
44603 </para>
44604 </listitem>
44605 </itemizedlist>
44606 </section>
44607 <section>
44608 <title>GnuTLS parameter computation</title>
44609 <para>
44610 GnuTLS uses RSA and D-H parameters that take a substantial amount of time to
44611 compute. It is unreasonable to re-compute them for every TLS session.
44612 Therefore, Exim keeps this data in a file in its spool directory, called
44613 <filename>gnutls-params</filename>. The file is owned by the Exim user and is readable only by
44614 its owner. Every Exim process that start up GnuTLS reads the RSA and D-H
44615 parameters from this file. If the file does not exist, the first Exim process
44616 that needs it computes the data and writes it to a temporary file which is
44617 renamed once it is complete. It does not matter if several Exim processes do
44618 this simultaneously (apart from wasting a few resources). Once a file is in
44619 place, new Exim processes immediately start using it.
44620 </para>
44621 <para>
44622 For maximum security, the parameters that are stored in this file should be
44623 recalculated periodically, the frequency depending on your paranoia level.
44624 Arranging this is easy in principle; just delete the file when you want new
44625 values to be computed. However, there may be a problem. The calculation of new
44626 parameters needs random numbers, and these are obtained from <filename>/dev/random</filename>.
44627 If the system is not very active, <filename>/dev/random</filename> may delay returning data
44628 until enough randomness (entropy) is available. This may cause Exim to hang for
44629 a substantial amount of time, causing timeouts on incoming connections.
44630 </para>
44631 <para>
44632 The solution is to generate the parameters externally to Exim. They are stored
44633 in <filename>gnutls-params</filename> in PEM format, which means that they can be generated
44634 externally using the <command>certtool</command> command that is part of GnuTLS.
44635 </para>
44636 <para>
44637 To replace the parameters with new ones, instead of deleting the file
44638 and letting Exim re-create it, you can generate new parameters using
44639 <command>certtool</command> and, when this has been done, replace Exim&#x2019;s cache file by
44640 renaming. The relevant commands are something like this:
44641 </para>
44642 <literallayout class="monospaced">
44643 # rm -f new-params
44644 # touch new-params
44645 # chown exim:exim new-params
44646 # chmod 0400 new-params
44647 # certtool --generate-privkey --bits 512 &gt;new-params
44648 # echo "" &gt;&gt;new-params
44649 # certtool --generate-dh-params --bits 1024 &gt;&gt; new-params
44650 # mv new-params gnutls-params
44651 </literallayout>
44652 <para>
44653 If Exim never has to generate the parameters itself, the possibility of
44654 stalling is removed.
44655 </para>
44656 </section>
44657 <section id="SECTreqciphssl">
44658 <title>Requiring specific ciphers in OpenSSL</title>
44659 <para>
44660 <indexterm role="concept">
44661 <primary>TLS</primary>
44662 <secondary>requiring specific ciphers (OpenSSL)</secondary>
44663 </indexterm>
44664 <indexterm role="concept">
44665 <primary><option>tls_require_ciphers</option></primary>
44666 <secondary>OpenSSL</secondary>
44667 </indexterm>
44668 There is a function in the OpenSSL library that can be passed a list of cipher
44669 suites before the cipher negotiation takes place. This specifies which ciphers
44670 are acceptable. The list is colon separated and may contain names like
44671 DES-CBC3-SHA. Exim passes the expanded value of <option>tls_require_ciphers</option>
44672 directly to this function call. The following quotation from the OpenSSL
44673 documentation specifies what forms of item are allowed in the cipher string:
44674 </para>
44675 <itemizedlist>
44676 <listitem>
44677 <para>
44678 It can consist of a single cipher suite such as RC4-SHA.
44679 </para>
44680 </listitem>
44681 <listitem>
44682 <para>
44683 It can represent a list of cipher suites containing a certain algorithm,
44684 or cipher suites of a certain type. For example SHA1 represents all
44685 ciphers suites using the digest algorithm SHA1 and SSLv3 represents all
44686 SSL v3 algorithms.
44687 </para>
44688 </listitem>
44689 <listitem>
44690 <para>
44691 Lists of cipher suites can be combined in a single cipher string using
44692 the + character. This is used as a logical and operation. For example
44693 SHA1+DES represents all cipher suites containing the SHA1 and the DES
44694 algorithms.
44695 </para>
44696 </listitem>
44697 </itemizedlist>
44698 <para>
44699 Each cipher string can be optionally preceded by one of the characters <literal>!</literal>,
44700 <literal>-</literal> or <literal>+</literal>.
44701 </para>
44702 <itemizedlist>
44703 <listitem>
44704 <para>
44705 If <literal>!</literal> is used, the ciphers are permanently deleted from the list. The
44706 ciphers deleted can never reappear in the list even if they are explicitly
44707 stated.
44708 </para>
44709 </listitem>
44710 <listitem>
44711 <para>
44712 If <literal>-</literal> is used, the ciphers are deleted from the list, but some or all
44713 of the ciphers can be added again by later options.
44714 </para>
44715 </listitem>
44716 <listitem>
44717 <para>
44718 If <literal>+</literal> is used, the ciphers are moved to the end of the list. This
44719 option does not add any new ciphers; it just moves matching existing ones.
44720 </para>
44721 </listitem>
44722 </itemizedlist>
44723 <para>
44724 If none of these characters is present, the string is interpreted as
44725 a list of ciphers to be appended to the current preference list. If the list
44726 includes any ciphers already present they will be ignored: that is, they will
44727 not be moved to the end of the list.
44728 </para>
44729 </section>
44730 <section id="SECTreqciphgnu">
44731 <title>Requiring specific ciphers in GnuTLS</title>
44732 <para>
44733 <indexterm role="concept">
44734 <primary>TLS</primary>
44735 <secondary>requiring specific ciphers (GnuTLS)</secondary>
44736 </indexterm>
44737 <indexterm role="concept">
44738 <primary><option>tls_require_ciphers</option></primary>
44739 <secondary>GnuTLS</secondary>
44740 </indexterm>
44741 The GnuTLS library does not have a combined function like OpenSSL. Instead,
44742 it allows the caller to specify separate lists of key-exchange methods,
44743 main cipher algorithms, and MAC algorithms. Unfortunately, these lists are
44744 numerical, and the library does not have a function for turning names into
44745 numbers. Consequently, the list of recognized names has to be built into
44746 the application.
44747 </para>
44748 <para>
44749 At present, Exim permits only the list of main cipher algorithms to be
44750 changed. The <option>tls_require_ciphers</option> option is in the same format as for
44751 OpenSSL. Exim searches each item for the name of available algorithm. For
44752 example, if the list contains RSA_AES_SHA then AES is recognized.
44753 </para>
44754 <para>
44755 The cipher algorithms list starts out with a default set of algorithms. If
44756 the first item in <option>tls_require_ciphers</option> does <emphasis>not</emphasis> start with an
44757 exclamation mark, all the default items are deleted. Thus, only those specified
44758 can be used. If the first item in <option>tls_require_ciphers</option> <emphasis>does</emphasis> start with
44759 an exclamation mark, the defaults are left on the list.
44760 </para>
44761 <para>
44762 Then, any item that starts with an exclamation mark causes the relevant
44763 algorithms to be removed from the list, and any item that does not start
44764 with an exclamation mark causes the relevant algorithms to be added to the
44765 list. Thus,
44766 </para>
44767 <literallayout class="monospaced">
44768 tls_require_ciphers = !RSA_ARCFOUR_SHA
44769 </literallayout>
44770 <para>
44771 allows all the defaults except those that use ARCFOUR, whereas
44772 </para>
44773 <literallayout class="monospaced">
44774 tls_require_ciphers = AES : 3DES
44775 </literallayout>
44776 <para>
44777 allows only cipher suites that use AES and 3DES. The currently recognized
44778 algorithms are: AES_256, AES_128, AES (both of the preceding), 3DES, and
44779 ARCFOUR_128. Unrecognized algorithms are ignored. In a server, the order of the
44780 list is unimportant; the server will advertise the availability of all the
44781 relevant cipher suites. However, in a client, the order of the list specifies a
44782 preference order for the algorithms. The first one in the client&#x2019;s list that is
44783 also advertised by the server is tried first. The default order is as listed
44784 above.
44785 </para>
44786 </section>
44787 <section>
44788 <title>Configuring an Exim server to use TLS</title>
44789 <para>
44790 <indexterm role="concept">
44791 <primary>TLS</primary>
44792 <secondary>configuring an Exim server</secondary>
44793 </indexterm>
44794 When Exim has been built with TLS support, it advertises the availability of
44795 the STARTTLS command to client hosts that match <option>tls_advertise_hosts</option>,
44796 but not to any others. The default value of this option is unset, which means
44797 that STARTTLS is not advertised at all. This default is chosen because you
44798 need to set some other options in order to make TLS avaliable, and also it is
44799 sensible for systems that want to use TLS only as a client.
44800 </para>
44801 <para>
44802 If a client issues a STARTTLS command and there is some configuration
44803 problem in the server, the command is rejected with a 454 error. If the client
44804 persists in trying to issue SMTP commands, all except QUIT are rejected
44805 with the error
44806 </para>
44807 <literallayout class="monospaced">
44808 554 Security failure
44809 </literallayout>
44810 <para>
44811 If a STARTTLS command is issued within an existing TLS session, it is
44812 rejected with a 554 error code.
44813 </para>
44814 <para>
44815 To enable TLS operations on a server, you must set <option>tls_advertise_hosts</option> to
44816 match some hosts. You can, of course, set it to * to match all hosts.
44817 However, this is not all you need to do. TLS sessions to a server won&#x2019;t work
44818 without some further configuration at the server end.
44819 </para>
44820 <para>
44821 It is rumoured that all existing clients that support TLS/SSL use RSA
44822 encryption. To make this work you need to set, in the server,
44823 </para>
44824 <literallayout class="monospaced">
44825 tls_certificate = /some/file/name
44826 tls_privatekey = /some/file/name
44827 </literallayout>
44828 <para revisionflag="changed">
44829 These options are, in fact, expanded strings, so you can make them depend on
44830 the identity of the client that is connected if you wish. The first file
44831 contains the server&#x2019;s X509 certificate, and the second contains the private key
44832 that goes with it. These files need to be readable by the Exim user, and must
44833 always be given as full path names. They can be the same file if both the
44834 certificate and the key are contained within it. If <option>tls_privatekey</option> is not
44835 set, or if its expansion is forced to fail or results in an empty string, this
44836 is assumed to be the case. The certificate file may also contain intermediate
44837 certificates that need to be sent to the client to enable it to authenticate
44838 the server&#x2019;s certificate.
44839 </para>
44840 <para>
44841 If you do not understand about certificates and keys, please try to find a
44842 source of this background information, which is not Exim-specific. (There are a
44843 few comments below in section <xref linkend="SECTcerandall"/>.)
44844 </para>
44845 <para revisionflag="changed">
44846 <emphasis role="bold">Note</emphasis>: These options do not apply when Exim is operating as a client &ndash;
44847 they apply only in the case of a server. If you need to use a certificate in an
44848 Exim client, you must set the options of the same names in an <command>smtp</command>
44849 transport.
44850 </para>
44851 <para revisionflag="changed">
44852 With just these options, an Exim server will be able to use TLS. It does not
44853 require the client to have a certificate (but see below for how to insist on
44854 this). There is one other option that may be needed in other situations. If
44855 </para>
44856 <literallayout class="monospaced">
44857 tls_dhparam = /some/file/name
44858 </literallayout>
44859 <para>
44860 is set, the SSL library is initialized for the use of Diffie-Hellman ciphers
44861 with the parameters contained in the file. This increases the set of cipher
44862 suites that the server supports. See the command
44863 </para>
44864 <literallayout class="monospaced">
44865 openssl dhparam
44866 </literallayout>
44867 <para>
44868 for a way of generating this data. At present, <option>tls_dhparam</option> is used only
44869 when Exim is linked with OpenSSL. It is ignored if GnuTLS is being used.
44870 </para>
44871 <para>
44872 The strings supplied for these three options are expanded every time a client
44873 host connects. It is therefore possible to use different certificates and keys
44874 for different hosts, if you so wish, by making use of the client&#x2019;s IP address
44875 in <varname>$sender_host_address</varname> to control the expansion. If a string expansion is
44876 forced to fail, Exim behaves as if the option is not set.
44877 </para>
44878 <para>
44879 <indexterm role="concept">
44880 <primary>cipher</primary>
44881 <secondary>logging</secondary>
44882 </indexterm>
44883 <indexterm role="concept">
44884 <primary>log</primary>
44885 <secondary>TLS cipher</secondary>
44886 </indexterm>
44887 <indexterm role="concept">
44888 <primary><varname>$tls_cipher</varname></primary>
44889 </indexterm>
44890 The variable <varname>$tls_cipher</varname> is set to the cipher suite that was negotiated for
44891 an incoming TLS connection. It is included in the <emphasis>Received:</emphasis> header of an
44892 incoming message (by default &ndash; you can, of course, change this), and it is
44893 also included in the log line that records a message&#x2019;s arrival, keyed by
44894 <quote>X=</quote>, unless the <option>tls_cipher</option> log selector is turned off. The <option>encrypted</option>
44895 condition can be used to test for specific cipher suites in ACLs.
44896 </para>
44897 <para>
44898 The ACLs that run for subsequent SMTP commands can check the name of the cipher
44899 suite and vary their actions accordingly. The cipher suite names are those used
44900 by OpenSSL. These may differ from the names used elsewhere. For example,
44901 OpenSSL uses the name DES-CBC3-SHA for the cipher suite which in other contexts
44902 is known as TLS_RSA_WITH_3DES_EDE_CBC_SHA. Check the OpenSSL
44903 documentation for more details.
44904 </para>
44905 </section>
44906 <section>
44907 <title>Requesting and verifying client certificates</title>
44908 <para>
44909 <indexterm role="concept">
44910 <primary>certificate</primary>
44911 <secondary>verification of client</secondary>
44912 </indexterm>
44913 <indexterm role="concept">
44914 <primary>TLS</primary>
44915 <secondary>client certificate verification</secondary>
44916 </indexterm>
44917 If you want an Exim server to request a certificate when negotiating a TLS
44918 session with a client, you must set either <option>tls_verify_hosts</option> or
44919 <option>tls_try_verify_hosts</option>. You can, of course, set either of them to * to
44920 apply to all TLS connections. For any host that matches one of these options,
44921 Exim requests a certificate as part of the setup of the TLS session. The
44922 contents of the certificate are verified by comparing it with a list of
44923 expected certificates. These must be available in a file or,
44924 for OpenSSL only (not GnuTLS), a directory, identified by
44925 <option>tls_verify_certificates</option>.
44926 </para>
44927 <para>
44928 A file can contain multiple certificates, concatenated end to end. If a
44929 directory is used
44930 (OpenSSL only),
44931 each certificate must be in a separate file, with a name (or a symbolic link)
44932 of the form &lt;<emphasis>hash</emphasis>&gt;.0, where &lt;<emphasis>hash</emphasis>&gt; is a hash value constructed from the
44933 certificate. You can compute the relevant hash by running the command
44934 </para>
44935 <literallayout class="monospaced">
44936 openssl x509 -hash -noout -in /cert/file
44937 </literallayout>
44938 <para>
44939 where <filename>/cert/file</filename> contains a single certificate.
44940 </para>
44941 <para>
44942 The difference between <option>tls_verify_hosts</option> and <option>tls_try_verify_hosts</option> is
44943 what happens if the client does not supply a certificate, or if the certificate
44944 does not match any of the certificates in the collection named by
44945 <option>tls_verify_certificates</option>. If the client matches <option>tls_verify_hosts</option>, the
44946 attempt to set up a TLS session is aborted, and the incoming connection is
44947 dropped. If the client matches <option>tls_try_verify_hosts</option>, the (encrypted) SMTP
44948 session continues. ACLs that run for subsequent SMTP commands can detect the
44949 fact that no certificate was verified, and vary their actions accordingly. For
44950 example, you can insist on a certificate before accepting a message for
44951 relaying, but not when the message is destined for local delivery.
44952 </para>
44953 <para>
44954 <indexterm role="concept">
44955 <primary><varname>$tls_peerdn</varname></primary>
44956 </indexterm>
44957 When a client supplies a certificate (whether it verifies or not), the value of
44958 the Distinguished Name of the certificate is made available in the variable
44959 <varname>$tls_peerdn</varname> during subsequent processing of the message.
44960 </para>
44961 <para>
44962 <indexterm role="concept">
44963 <primary>log</primary>
44964 <secondary>distinguished name</secondary>
44965 </indexterm>
44966 Because it is often a long text string, it is not included in the log line or
44967 <emphasis>Received:</emphasis> header by default. You can arrange for it to be logged, keyed by
44968 <quote>DN=</quote>, by setting the <option>tls_peerdn</option> log selector, and you can use
44969 <option>received_header_text</option> to change the <emphasis>Received:</emphasis> header. When no
44970 certificate is supplied, <varname>$tls_peerdn</varname> is empty.
44971 </para>
44972 </section>
44973 <section>
44974 <title>Revoked certificates</title>
44975 <para>
44976 <indexterm role="concept">
44977 <primary>TLS</primary>
44978 <secondary>revoked certificates</secondary>
44979 </indexterm>
44980 <indexterm role="concept">
44981 <primary>revocation list</primary>
44982 </indexterm>
44983 <indexterm role="concept">
44984 <primary>certificate</primary>
44985 <secondary>revocation list</secondary>
44986 </indexterm>
44987 Certificate issuing authorities issue Certificate Revocation Lists (CRLs) when
44988 certificates are revoked. If you have such a list, you can pass it to an Exim
44989 server using the global option called <option>tls_crl</option> and to an Exim client using
44990 an identically named option for the <command>smtp</command> transport. In each case, the value
44991 of the option is expanded and must then be the name of a file that contains a
44992 CRL in PEM format.
44993 </para>
44994 </section>
44995 <section>
44996 <title>Configuring an Exim client to use TLS</title>
44997 <para>
44998 <indexterm role="concept">
44999 <primary>cipher</primary>
45000 <secondary>logging</secondary>
45001 </indexterm>
45002 <indexterm role="concept">
45003 <primary>log</primary>
45004 <secondary>TLS cipher</secondary>
45005 </indexterm>
45006 <indexterm role="concept">
45007 <primary>log</primary>
45008 <secondary>distinguished name</secondary>
45009 </indexterm>
45010 <indexterm role="concept">
45011 <primary>TLS</primary>
45012 <secondary>configuring an Exim client</secondary>
45013 </indexterm>
45014 The <option>tls_cipher</option> and <option>tls_peerdn</option> log selectors apply to outgoing SMTP
45015 deliveries as well as to incoming, the latter one causing logging of the
45016 server certificate&#x2019;s DN. The remaining client configuration for TLS is all
45017 within the <command>smtp</command> transport.
45018 </para>
45019 <para>
45020 It is not necessary to set any options to have TLS work in the <command>smtp</command>
45021 transport. If Exim is built with TLS support, and TLS is advertised by a
45022 server, the <command>smtp</command> transport always tries to start a TLS session. However,
45023 this can be prevented by setting <option>hosts_avoid_tls</option> (an option of the
45024 transport) to a list of server hosts for which TLS should not be used.
45025 </para>
45026 <para>
45027 If you do not want Exim to attempt to send messages unencrypted when an attempt
45028 to set up an encrypted connection fails in any way, you can set
45029 <option>hosts_require_tls</option> to a list of hosts for which encryption is mandatory. For
45030 those hosts, delivery is always deferred if an encrypted connection cannot be
45031 set up. If there are any other hosts for the address, they are tried in the
45032 usual way.
45033 </para>
45034 <para>
45035 When the server host is not in <option>hosts_require_tls</option>, Exim may try to deliver
45036 the message unencrypted. It always does this if the response to STARTTLS is
45037 a 5<emphasis>xx</emphasis> code. For a temporary error code, or for a failure to negotiate a TLS
45038 session after a success response code, what happens is controlled by the
45039 <option>tls_tempfail_tryclear</option> option of the <command>smtp</command> transport. If it is false,
45040 delivery to this host is deferred, and other hosts (if available) are tried. If
45041 it is true, Exim attempts to deliver unencrypted after a 4<emphasis>xx</emphasis> response to
45042 STARTTLS, and if STARTTLS is accepted, but the subsequent TLS
45043 negotiation fails, Exim closes the current connection (because it is in an
45044 unknown state), opens a new one to the same host, and then tries the delivery
45045 unencrypted.
45046 </para>
45047 <para>
45048 The <option>tls_certificate</option> and <option>tls_privatekey</option> options of the <command>smtp</command>
45049 transport provide the client with a certificate, which is passed to the server
45050 if it requests it. If the server is Exim, it will request a certificate only if
45051 <option>tls_verify_hosts</option> or <option>tls_try_verify_hosts</option> matches the client. <emphasis role="bold">Note</emphasis>:
45052 These options must be set in the <command>smtp</command> transport for Exim to use TLS when it
45053 is operating as a client. Exim does not assume that a server certificate (set
45054 by the global options of the same name) should also be used when operating as a
45055 client.
45056 </para>
45057 <para>
45058 If <option>tls_verify_certificates</option> is set, it must name a file or,
45059 for OpenSSL only (not GnuTLS), a directory, that contains a collection of
45060 expected server certificates. The client verifies the server&#x2019;s certificate
45061 against this collection, taking into account any revoked certificates that are
45062 in the list defined by <option>tls_crl</option>.
45063 </para>
45064 <para>
45065 If
45066 <option>tls_require_ciphers</option> is set on the <command>smtp</command> transport, it must contain a
45067 list of permitted cipher suites. If either of these checks fails, delivery to
45068 the current host is abandoned, and the <command>smtp</command> transport tries to deliver to
45069 alternative hosts, if any.
45070 </para>
45071 <para>
45072 <indexterm role="concept">
45073 <primary><varname>$host</varname></primary>
45074 </indexterm>
45075 <indexterm role="concept">
45076 <primary><varname>$host_address</varname></primary>
45077 </indexterm>
45078 All the TLS options in the <command>smtp</command> transport are expanded before use, with
45079 <varname>$host</varname> and <varname>$host_address</varname> containing the name and address of the server to
45080 which the client is connected. Forced failure of an expansion causes Exim to
45081 behave as if the relevant option were unset.
45082 </para>
45083 </section>
45084 <section id="SECTmulmessam">
45085 <title>Multiple messages on the same encrypted TCP/IP connection</title>
45086 <para>
45087 <indexterm role="concept">
45088 <primary>multiple SMTP deliveries with TLS</primary>
45089 </indexterm>
45090 <indexterm role="concept">
45091 <primary>TLS</primary>
45092 <secondary>multiple message deliveries</secondary>
45093 </indexterm>
45094 Exim sends multiple messages down the same TCP/IP connection by starting up
45095 an entirely new delivery process for each message, passing the socket from
45096 one process to the next. This implementation does not fit well with the use
45097 of TLS, because there is quite a lot of state information associated with a TLS
45098 connection, not just a socket identification. Passing all the state information
45099 to a new process is not feasible. Consequently, Exim shuts down an existing TLS
45100 session before passing the socket to a new process. The new process may then
45101 try to start a new TLS session, and if successful, may try to re-authenticate
45102 if AUTH is in use, before sending the next message.
45103 </para>
45104 <para>
45105 The RFC is not clear as to whether or not an SMTP session continues in clear
45106 after TLS has been shut down, or whether TLS may be restarted again later, as
45107 just described. However, if the server is Exim, this shutdown and
45108 reinitialization works. It is not known which (if any) other servers operate
45109 successfully if the client closes a TLS session and continues with unencrypted
45110 SMTP, but there are certainly some that do not work. For such servers, Exim
45111 should not pass the socket to another process, because the failure of the
45112 subsequent attempt to use it would cause Exim to record a temporary host error,
45113 and delay other deliveries to that host.
45114 </para>
45115 <para>
45116 To test for this case, Exim sends an EHLO command to the server after
45117 closing down the TLS session. If this fails in any way, the connection is
45118 closed instead of being passed to a new delivery process, but no retry
45119 information is recorded.
45120 </para>
45121 <para>
45122 There is also a manual override; you can set <option>hosts_nopass_tls</option> on the
45123 <command>smtp</command> transport to match those hosts for which Exim should not pass
45124 connections to new processes if TLS has been used.
45125 </para>
45126 </section>
45127 <section id="SECTcerandall">
45128 <title>Certificates and all that</title>
45129 <para>
45130 <indexterm role="concept">
45131 <primary>certificate</primary>
45132 <secondary>references to discussion</secondary>
45133 </indexterm>
45134 In order to understand fully how TLS works, you need to know about
45135 certificates, certificate signing, and certificate authorities. This is not the
45136 place to give a tutorial, especially as I do not know very much about it
45137 myself. Some helpful introduction can be found in the FAQ for the SSL addition
45138 to Apache, currently at
45139 </para>
45140 <literallayout>
45141 <emphasis role="bold"><ulink url="http://www.modssl.org/docs/2.7/ssl_faq.html#ToC24">http://www.modssl.org/docs/2.7/ssl_faq.html#ToC24</ulink></emphasis>
45142 </literallayout>
45143 <para>
45144 Other parts of the <emphasis>modssl</emphasis> documentation are also helpful, and have
45145 links to further files.
45146 Eric Rescorla&#x2019;s book, <emphasis>SSL and TLS</emphasis>, published by Addison-Wesley (ISBN
45147 0-201-61598-3), contains both introductory and more in-depth descriptions.
45148 Some sample programs taken from the book are available from
45149 </para>
45150 <literallayout>
45151 <emphasis role="bold"><ulink url="http://www.rtfm.com/openssl-examples/">http://www.rtfm.com/openssl-examples/</ulink></emphasis>
45152 </literallayout>
45153 </section>
45154 <section>
45155 <title>Certificate chains</title>
45156 <para>
45157 The file named by <option>tls_certificate</option> may contain more than one
45158 certificate. This is useful in the case where the certificate that is being
45159 sent is validated by an intermediate certificate which the other end does
45160 not have. Multiple certificates must be in the correct order in the file.
45161 First the host&#x2019;s certificate itself, then the first intermediate
45162 certificate to validate the issuer of the host certificate, then the next
45163 intermediate certificate to validate the issuer of the first intermediate
45164 certificate, and so on, until finally (optionally) the root certificate.
45165 The root certificate must already be trusted by the recipient for
45166 validation to succeed, of course, but if it&#x2019;s not preinstalled, sending the
45167 root certificate along with the rest makes it available for the user to
45168 install if the receiving end is a client MUA that can interact with a user.
45169 </para>
45170 </section>
45171 <section>
45172 <title>Self-signed certificates</title>
45173 <para>
45174 <indexterm role="concept">
45175 <primary>certificate</primary>
45176 <secondary>self-signed</secondary>
45177 </indexterm>
45178 You can create a self-signed certificate using the <emphasis>req</emphasis> command provided
45179 with OpenSSL, like this:
45180 </para>
45181 <literallayout class="monospaced">
45182 openssl req -x509 -newkey rsa:1024 -keyout file1 -out file2 \
45183             -days 9999 -nodes
45184 </literallayout>
45185 <para>
45186 <filename>file1</filename> and <filename>file2</filename> can be the same file; the key and the certificate are
45187 delimited and so can be identified independently. The <option>-days</option> option
45188 specifies a period for which the certificate is valid. The <option>-nodes</option> option is
45189 important: if you do not set it, the key is encrypted with a passphrase
45190 that you are prompted for, and any use that is made of the key causes more
45191 prompting for the passphrase. This is not helpful if you are going to use
45192 this certificate and key in an MTA, where prompting is not possible.
45193 </para>
45194 <para>
45195 A self-signed certificate made in this way is sufficient for testing, and
45196 may be adequate for all your requirements if you are mainly interested in
45197 encrypting transfers, and not in secure identification.
45198 </para>
45199 <para>
45200 However, many clients require that the certificate presented by the server be a
45201 user (also called <quote>leaf</quote> or <quote>site</quote>) certificate, and not a self-signed
45202 certificate. In this situation, the self-signed certificate described above
45203 must be installed on the client host as a trusted root <emphasis>certification
45204 authority</emphasis> (CA), and the certificate used by Exim must be a user certificate
45205 signed with that self-signed certificate.
45206 </para>
45207 <para>
45208 For information on creating self-signed CA certificates and using them to sign
45209 user certificates, see the <emphasis>General implementation overview</emphasis> chapter of the
45210 Open-source PKI book, available online at
45211 <emphasis role="bold"><ulink url="http://ospkibook.sourceforge.net/">http://ospkibook.sourceforge.net/</ulink></emphasis>.
45212 <indexterm role="concept" startref="IIDencsmtp1" class="endofrange"/>
45213 <indexterm role="concept" startref="IIDencsmtp2" class="endofrange"/>
45214 </para>
45215 </section>
45216 </chapter>
45217
45218 <chapter id="CHAPACL">
45219 <title>Access control lists</title>
45220 <para>
45221 <indexterm role="concept" id="IIDacl" class="startofrange">
45222 <primary>access control lists (ACLs)</primary>
45223 <secondary>description</secondary>
45224 </indexterm>
45225 <indexterm role="concept">
45226 <primary>control of incoming mail</primary>
45227 </indexterm>
45228 <indexterm role="concept">
45229 <primary>message</primary>
45230 <secondary>controlling incoming</secondary>
45231 </indexterm>
45232 <indexterm role="concept">
45233 <primary>policy control</primary>
45234 <secondary>access control lists</secondary>
45235 </indexterm>
45236 Access Control Lists (ACLs) are defined in a separate section of the run time
45237 configuration file, headed by <quote>begin acl</quote>. Each ACL definition starts with a
45238 name, terminated by a colon. Here is a complete ACL section that contains just
45239 one very small ACL:
45240 </para>
45241 <literallayout class="monospaced">
45242 begin acl
45243
45244 small_acl:
45245   accept   hosts = one.host.only
45246 </literallayout>
45247 <para>
45248 You can have as many lists as you like in the ACL section, and the order in
45249 which they appear does not matter. The lists are self-terminating.
45250 </para>
45251 <para>
45252 The majority of ACLs are used to control Exim&#x2019;s behaviour when it receives
45253 certain SMTP commands. This applies both to incoming TCP/IP connections, and
45254 when a local process submits a message using SMTP by specifying the <option>-bs</option>
45255 option. The most common use is for controlling which recipients are accepted
45256 in incoming messages. In addition, you can define an ACL that is used to check
45257 local non-SMTP messages. The default configuration file contains an example of
45258 a realistic ACL for checking RCPT commands. This is discussed in chapter
45259 <xref linkend="CHAPdefconfil"/>.
45260 </para>
45261 <section>
45262 <title>Testing ACLs</title>
45263 <para>
45264 The <option>-bh</option> command line option provides a way of testing your ACL
45265 configuration locally by running a fake SMTP session with which you interact.
45266 The host <emphasis>relay-test.mail-abuse.org</emphasis> provides a service for checking your
45267 relaying configuration (see section <xref linkend="SECTcheralcon"/> for more details).
45268 </para>
45269 </section>
45270 <section>
45271 <title>Specifying when ACLs are used</title>
45272 <para>
45273 <indexterm role="concept">
45274 <primary>access control lists (ACLs)</primary>
45275 <secondary>options for specifying</secondary>
45276 </indexterm>
45277 In order to cause an ACL to be used, you have to name it in one of the relevant
45278 options in the main part of the configuration. These options are:
45279 <indexterm role="concept">
45280 <primary>AUTH</primary>
45281 <secondary>ACL for</secondary>
45282 </indexterm>
45283 <indexterm role="concept">
45284 <primary>DATA</primary>
45285 <secondary>ACLs for</secondary>
45286 </indexterm>
45287 <indexterm role="concept">
45288 <primary>ETRN</primary>
45289 <secondary>ACL for</secondary>
45290 </indexterm>
45291 <indexterm role="concept">
45292 <primary>EXPN</primary>
45293 <secondary>ACL for</secondary>
45294 </indexterm>
45295 <indexterm role="concept">
45296 <primary>HELO</primary>
45297 <secondary>ACL for</secondary>
45298 </indexterm>
45299 <indexterm role="concept">
45300 <primary>EHLO</primary>
45301 <secondary>ACL for</secondary>
45302 </indexterm>
45303 <indexterm role="concept">
45304 <primary>MAIL</primary>
45305 <secondary>ACL for</secondary>
45306 </indexterm>
45307 <indexterm role="concept">
45308 <primary>QUIT</primary>
45309 <secondary>ACL for</secondary>
45310 </indexterm>
45311 <indexterm role="concept">
45312 <primary>RCPT</primary>
45313 <secondary>ACL for</secondary>
45314 </indexterm>
45315 <indexterm role="concept">
45316 <primary>STARTTLS</primary>
45317 <secondary>ACL for</secondary>
45318 </indexterm>
45319 <indexterm role="concept">
45320 <primary>VRFY</primary>
45321 <secondary>ACL for</secondary>
45322 </indexterm>
45323 <indexterm role="concept">
45324 <primary>SMTP connection</primary>
45325 <secondary>ACL for</secondary>
45326 </indexterm>
45327 <indexterm role="concept">
45328 <primary>non-smtp message</primary>
45329 <secondary>ACL for</secondary>
45330 </indexterm>
45331 </para>
45332 <informaltable frame="none">
45333 <tgroup cols="2" colsep="0" rowsep="0">
45334 <colspec colwidth="140pt" align="left"/>
45335 <colspec colwidth="260pt" align="left"/>
45336 <tbody>
45337 <row>
45338 <entry>&nbsp;<option>acl_not_smtp</option></entry>
45339 <entry>ACL for non-SMTP messages</entry>
45340 </row>
45341 <row>
45342 <entry>&nbsp;<option>acl_smtp_auth</option></entry>
45343 <entry>ACL for AUTH</entry>
45344 </row>
45345 <row>
45346 <entry>&nbsp;<option>acl_smtp_connect</option></entry>
45347 <entry>ACL for start of SMTP connection</entry>
45348 </row>
45349 <row>
45350 <entry>&nbsp;<option>acl_smtp_data</option></entry>
45351 <entry>ACL after DATA is complete</entry>
45352 </row>
45353 <row>
45354 <entry>&nbsp;<option>acl_smtp_etrn</option></entry>
45355 <entry>ACL for ETRN</entry>
45356 </row>
45357 <row>
45358 <entry>&nbsp;<option>acl_smtp_expn</option></entry>
45359 <entry>ACL for EXPN</entry>
45360 </row>
45361 <row>
45362 <entry>&nbsp;<option>acl_smtp_helo</option></entry>
45363 <entry>ACL for HELO or EHLO</entry>
45364 </row>
45365 <row>
45366 <entry>&nbsp;<option>acl_smtp_mail</option></entry>
45367 <entry>ACL for MAIL</entry>
45368 </row>
45369 <row>
45370 <entry>&nbsp;<option>acl_smtp_mailauth</option></entry>
45371 <entry>ACL for the AUTH parameter of MAIL</entry>
45372 </row>
45373 <row>
45374 <entry>&nbsp;<option>acl_smtp_mime</option></entry>
45375 <entry>ACL for content-scanning MIME parts</entry>
45376 </row>
45377 <row>
45378 <entry>&nbsp;<option>acl_smtp_predata</option></entry>
45379 <entry>ACL at start of DATA command</entry>
45380 </row>
45381 <row>
45382 <entry>&nbsp;<option>acl_smtp_quit</option></entry>
45383 <entry>ACL for QUIT</entry>
45384 </row>
45385 <row>
45386 <entry>&nbsp;<option>acl_smtp_rcpt</option></entry>
45387 <entry>ACL for RCPT</entry>
45388 </row>
45389 <row>
45390 <entry>&nbsp;<option>acl_smtp_starttls</option></entry>
45391 <entry>ACL for STARTTLS</entry>
45392 </row>
45393 <row>
45394 <entry>&nbsp;<option>acl_smtp_vrfy</option></entry>
45395 <entry>ACL for VRFY</entry>
45396 </row>
45397 </tbody>
45398 </tgroup>
45399 </informaltable>
45400 <para>
45401 For example, if you set
45402 </para>
45403 <literallayout class="monospaced">
45404 acl_smtp_rcpt = small_acl
45405 </literallayout>
45406 <para>
45407 the little ACL defined above is used whenever Exim receives a RCPT command
45408 in an SMTP dialogue. The majority of policy tests on incoming messages can be
45409 done when RCPT commands arrive. A rejection of RCPT should cause the
45410 sending MTA to give up on the recipient address contained in the RCPT
45411 command, whereas rejection at other times may cause the client MTA to keep on
45412 trying to deliver the message. It is therefore recommended that you do as much
45413 testing as possible at RCPT time.
45414 </para>
45415 </section>
45416 <section>
45417 <title>The non-SMTP ACL</title>
45418 <para>
45419 <indexterm role="concept">
45420 <primary>non-smtp message</primary>
45421 <secondary>ACL for</secondary>
45422 </indexterm>
45423 The non-SMTP ACL applies to all non-interactive incoming messages, that is, it
45424 applies to batch SMTP as well as to non-SMTP messages. (Batch SMTP is not
45425 really SMTP.) This ACL is run just before the <function>local_scan()</function> function. Any
45426 kind of rejection is treated as permanent, because there is no way of sending a
45427 temporary error for these kinds of message. Many of the ACL conditions (for
45428 example, host tests, and tests on the state of the SMTP connection such as
45429 encryption and authentication) are not relevant and are forbidden in this ACL.
45430 </para>
45431 </section>
45432 <section>
45433 <title>The connect ACL</title>
45434 <para>
45435 <indexterm role="concept">
45436 <primary>SMTP connection</primary>
45437 <secondary>ACL for</secondary>
45438 </indexterm>
45439 The ACL test specified by <option>acl_smtp_connect</option> happens after the test specified
45440 by <option>host_reject_connection</option> (which is now an anomaly) and any TCP Wrappers
45441 testing (if configured).
45442 </para>
45443 </section>
45444 <section>
45445 <title>The DATA ACLs</title>
45446 <para>
45447 <indexterm role="concept">
45448 <primary>DATA</primary>
45449 <secondary>ACLs for</secondary>
45450 </indexterm>
45451 Two ACLs are associated with the DATA command, because it is two-stage
45452 command, with two responses being sent to the client.
45453 When the DATA command is received, the ACL defined by <option>acl_smtp_predata</option>
45454 is obeyed. This gives you control after all the RCPT commands, but before
45455 the message itself is received. It offers the opportunity to give a negative
45456 response to the DATA command before the data is transmitted. Header lines
45457 added by MAIL or RCPT ACLs are not visible at this time, but any that
45458 are defined here are visible when the <option>acl_smtp_data</option> ACL is run.
45459 </para>
45460 <para>
45461 You cannot test the contents of the message, for example, to verify addresses
45462 in the headers, at RCPT time or when the DATA command is received. Such
45463 tests have to appear in the ACL that is run after the message itself has been
45464 received, before the final response to the DATA command is sent. This is
45465 the ACL specified by <option>acl_smtp_data</option>, which is the second ACL that is
45466 associated with the DATA command.
45467 </para>
45468 <para>
45469 For both of these ACLs, it is not possible to reject individual recipients. An
45470 error response rejects the entire message. Unfortunately, it is known that some
45471 MTAs do not treat hard (5<emphasis>xx</emphasis>) responses to the DATA command (either
45472 before or after the data) correctly &ndash; they keep the message on their queues
45473 and try again later, but that is their problem, though it does waste some of
45474 your resources.
45475 </para>
45476 </section>
45477 <section>
45478 <title>The MIME ACL</title>
45479 <para>
45480 The <option>acl_smtp_mime</option> option is available only when Exim is compiled with the
45481 content-scanning extension. For details, see chapter <xref linkend="CHAPexiscan"/>.
45482 </para>
45483 </section>
45484 <section id="SECTQUITACL">
45485 <title>The QUIT ACL</title>
45486 <para>
45487 <indexterm role="concept">
45488 <primary>QUIT</primary>
45489 <secondary>ACL for</secondary>
45490 </indexterm>
45491 The ACL for the SMTP QUIT command is anomalous, in that the outcome of the ACL
45492 does not affect the response code to QUIT, which is always 221. Thus, the ACL
45493 does not in fact control any access. For this reason, the only verbs that are
45494 permitted are <option>accept</option> and <option>warn</option>.
45495 </para>
45496 <para>
45497 This ACL can be used for tasks such as custom logging at the end of an SMTP
45498 session. For example, you can use ACL variables in other ACLs to count
45499 messages, recipients, etc., and log the totals at QUIT time using one or
45500 more <option>logwrite</option> modifiers on a <option>warn</option> verb.
45501 </para>
45502 <para>
45503 <emphasis role="bold">Warning</emphasis>: Only the <varname>$acl_c</varname><emphasis>x</emphasis> variables can be used for this, because
45504 the <varname>$acl_m</varname><emphasis>x</emphasis> variables are reset at the end of each incoming message.
45505 </para>
45506 <para>
45507 You do not need to have a final <option>accept</option>, but if you do, you can use a
45508 <option>message</option> modifier to specify custom text that is sent as part of the 221
45509 response to QUIT.
45510 </para>
45511 <para>
45512 This ACL is run only for a <quote>normal</quote> QUIT. For certain kinds of disastrous
45513 failure (for example, failure to open a log file, or when Exim is bombing out
45514 because it has detected an unrecoverable error), all SMTP commands from the
45515 client are given temporary error responses until QUIT is received or the
45516 connection is closed. In these special cases, the QUIT ACL does not run.
45517 </para>
45518 </section>
45519 <section>
45520 <title>Finding an ACL to use</title>
45521 <para>
45522 <indexterm role="concept">
45523 <primary>access control lists (ACLs)</primary>
45524 <secondary>finding which to use</secondary>
45525 </indexterm>
45526 The value of an <option>acl_smtp_</option><emphasis>xxx</emphasis> option is expanded before use, so you can
45527 use different ACLs in different circumstances. The resulting string does not
45528 have to be the name of an ACL in the configuration file; there are other
45529 possibilities. Having expanded the string, Exim searches for an ACL as follows:
45530 </para>
45531 <itemizedlist>
45532 <listitem>
45533 <para>
45534 If the string begins with a slash, Exim uses it as a file name, and reads its
45535 contents as an ACL. The lines are processed in the same way as lines in the
45536 Exim configuration file. In particular, continuation lines are supported, blank
45537 lines are ignored, as are lines whose first non-whitespace character is <quote>#</quote>.
45538 If the file does not exist or cannot be read, an error occurs (typically
45539 causing a temporary failure of whatever caused the ACL to be run). For example:
45540 </para>
45541 <literallayout class="monospaced">
45542 acl_smtp_data = /etc/acls/\
45543   ${lookup{$sender_host_address}lsearch\
45544   {/etc/acllist}{$value}{default}}
45545 </literallayout>
45546 <para>
45547 This looks up an ACL file to use on the basis of the host&#x2019;s IP address, falling
45548 back to a default if the lookup fails. If an ACL is successfully read from a
45549 file, it is retained in memory for the duration of the Exim process, so that it
45550 can be re-used without having to re-read the file.
45551 </para>
45552 </listitem>
45553 <listitem>
45554 <para>
45555 If the string does not start with a slash, and does not contain any spaces,
45556 Exim searches the ACL section of the configuration for an ACL whose name
45557 matches the string.
45558 </para>
45559 </listitem>
45560 <listitem>
45561 <para>
45562 If no named ACL is found, or if the string contains spaces, Exim parses
45563 the string as an inline ACL. This can save typing in cases where you just
45564 want to have something like
45565 </para>
45566 <literallayout class="monospaced">
45567 acl_smtp_vrfy = accept
45568 </literallayout>
45569 <para>
45570 in order to allow free use of the VRFY command. Such a string may contain
45571 newlines; it is processed in the same way as an ACL that is read from a file.
45572 </para>
45573 </listitem>
45574 </itemizedlist>
45575 </section>
45576 <section>
45577 <title>ACL return codes</title>
45578 <para>
45579 <indexterm role="concept">
45580 <primary>access control lists (ACLs)</primary>
45581 <secondary>return codes</secondary>
45582 </indexterm>
45583 Except for the QUIT ACL, which does not affect the SMTP return code (see
45584 section <xref linkend="SECTQUITACL"/> above), the result of running an ACL is either
45585 <quote>accept</quote> or <quote>deny</quote>, or, if some test cannot be completed (for example, if a
45586 database is down), <quote>defer</quote>. These results cause 2<emphasis>xx</emphasis>, 5<emphasis>xx</emphasis>, and 4<emphasis>xx</emphasis>
45587 return codes, respectively, to be used in the SMTP dialogue. A fourth return,
45588 <quote>error</quote>, occurs when there is an error such as invalid syntax in the ACL.
45589 This also causes a 4<emphasis>xx</emphasis> return code.
45590 </para>
45591 <para>
45592 For the non-SMTP ACL, <quote>defer</quote> and <quote>error</quote> are treated in the same way as
45593 <quote>deny</quote>, because there is no mechanism for passing temporary errors to the
45594 submitters of non-SMTP messages.
45595 </para>
45596 <para>
45597 ACLs that are relevant to message reception may also return <quote>discard</quote>. This
45598 has the effect of <quote>accept</quote>, but causes either the entire message or an
45599 individual recipient address to be discarded. In other words, it is a
45600 blackholing facility. Use it with care.
45601 </para>
45602 <para>
45603 If the ACL for MAIL returns <quote>discard</quote>, all recipients are discarded, and no
45604 ACL is run for subsequent RCPT commands. The effect of <quote>discard</quote> in a
45605 RCPT ACL is to discard just the one recipient address. If there are no
45606 recipients left when the message&#x2019;s data is received, the DATA ACL is not
45607 run. A <quote>discard</quote> return from the DATA or the non-SMTP ACL discards all the
45608 remaining recipients. The <quote>discard</quote> return is not permitted for the
45609 <option>acl_smtp_predata</option> ACL.
45610 </para>
45611 <para>
45612 <indexterm role="concept">
45613 <primary><function>local_scan()</function> function</primary>
45614 <secondary>when all recipients discarded</secondary>
45615 </indexterm>
45616 The <function>local_scan()</function> function is always run, even if there are no remaining
45617 recipients; it may create new recipients.
45618 </para>
45619 </section>
45620 <section>
45621 <title>Unset ACL options</title>
45622 <para>
45623 <indexterm role="concept">
45624 <primary>access control lists (ACLs)</primary>
45625 <secondary>unset options</secondary>
45626 </indexterm>
45627 The default actions when any of the <option>acl_</option><emphasis>xxx</emphasis> options are unset are not
45628 all the same. <emphasis role="bold">Note</emphasis>: These defaults apply only when the relevant ACL is
45629 not defined at all. For any defined ACL, the default action when control
45630 reaches the end of the ACL statements is <quote>deny</quote>.
45631 </para>
45632 <para>
45633 For <option>acl_not_smtp</option>, <option>acl_smtp_auth</option>, <option>acl_smtp_connect</option>,
45634 <option>acl_smtp_data</option>, <option>acl_smtp_helo</option>, <option>acl_smtp_mail</option>, <option>acl_smtp_mailauth</option>,
45635 <option>acl_smtp_mime</option>, <option>acl_smtp_predata</option>, <option>acl_smtp_quit</option>, and
45636 <option>acl_smtp_starttls</option>, the action when the ACL is not defined is <quote>accept</quote>.
45637 </para>
45638 <para>
45639 For the others (<option>acl_smtp_etrn</option>, <option>acl_smtp_expn</option>, <option>acl_smtp_rcpt</option>, and
45640 <option>acl_smtp_vrfy</option>), the action when the ACL is not defined is <quote>deny</quote>.
45641 This means that <option>acl_smtp_rcpt</option> must be defined in order to receive any
45642 messages over an SMTP connection. For an example, see the ACL in the default
45643 configuration file.
45644 </para>
45645 </section>
45646 <section>
45647 <title>Data for message ACLs</title>
45648 <para>
45649 <indexterm role="concept">
45650 <primary>access control lists (ACLs)</primary>
45651 <secondary>data for message ACL</secondary>
45652 </indexterm>
45653 <indexterm role="concept">
45654 <primary><varname>$domain</varname></primary>
45655 </indexterm>
45656 <indexterm role="concept">
45657 <primary><varname>$local_part</varname></primary>
45658 </indexterm>
45659 <indexterm role="concept">
45660 <primary><varname>$sender_address</varname></primary>
45661 </indexterm>
45662 <indexterm role="concept">
45663 <primary><varname>$sender_host_address</varname></primary>
45664 </indexterm>
45665 <indexterm role="concept">
45666 <primary><varname>$smtp_command</varname></primary>
45667 </indexterm>
45668 When a MAIL or RCPT ACL, or either of the DATA ACLs, is running, the variables
45669 that contain information about the host and the message&#x2019;s sender (for example,
45670 <varname>$sender_host_address</varname> and <varname>$sender_address</varname>) are set, and can be used in ACL
45671 statements. In the case of RCPT (but not MAIL or DATA), <varname>$domain</varname> and
45672 <varname>$local_part</varname> are set from the argument address. The entire SMTP command
45673 is available in <varname>$smtp_command</varname>.
45674 </para>
45675 <para>
45676 When an ACL for the AUTH parameter of MAIL is running, the variables that
45677 contain information about the host are set, but <varname>$sender_address</varname> is not yet
45678 set. Section <xref linkend="SECTauthparamail"/> contains a discussion of this parameter and
45679 how it is used.
45680 </para>
45681 <para>
45682 <indexterm role="concept">
45683 <primary><varname>$message_size</varname></primary>
45684 </indexterm>
45685 The <varname>$message_size</varname> variable is set to the value of the SIZE parameter on
45686 the MAIL command at MAIL, RCPT and pre-data time, or to -1 if
45687 that parameter is not given. The value is updated to the true message size by
45688 the time the final DATA ACL is run (after the message data has been
45689 received).
45690 </para>
45691 <para>
45692 <indexterm role="concept">
45693 <primary><varname>$rcpt_count</varname></primary>
45694 </indexterm>
45695 <indexterm role="concept">
45696 <primary><varname>$recipients_count</varname></primary>
45697 </indexterm>
45698 The <varname>$rcpt_count</varname> variable increases by one for each RCPT command received.
45699 The <varname>$recipients_count</varname> variable increases by one each time a RCPT command is
45700 accepted, so while an ACL for RCPT is being processed, it contains the number
45701 of previously accepted recipients. At DATA time (for both the DATA ACLs),
45702 <varname>$rcpt_count</varname> contains the total number of RCPT commands, and
45703 <varname>$recipients_count</varname> contains the total number of accepted recipients.
45704 </para>
45705 </section>
45706 <section id="SECTdatfornon">
45707 <title>Data for non-message ACLs</title>
45708 <para>
45709 <indexterm role="concept">
45710 <primary>access control lists (ACLs)</primary>
45711 <secondary>data for non-message ACL</secondary>
45712 </indexterm>
45713 <indexterm role="concept">
45714 <primary><varname>$smtp_command_argument</varname></primary>
45715 </indexterm>
45716 <indexterm role="concept">
45717 <primary><varname>$smtp_command</varname></primary>
45718 </indexterm>
45719 When an ACL is being run for AUTH, EHLO, ETRN, EXPN, HELO, STARTTLS, or VRFY,
45720 the remainder of the SMTP command line is placed in <varname>$smtp_command_argument</varname>,
45721 and the entire SMTP command is available in <varname>$smtp_command</varname>.
45722 These variables can be tested using a <option>condition</option> condition. For example,
45723 here is an ACL for use with AUTH, which insists that either the session is
45724 encrypted, or the CRAM-MD5 authentication method is used. In other words, it
45725 does not permit authentication methods that use cleartext passwords on
45726 unencrypted connections.
45727 </para>
45728 <literallayout class="monospaced">
45729 acl_check_auth:
45730   accept encrypted = *
45731   accept condition = ${if eq{${uc:$smtp_command_argument}}\
45732                      {CRAM-MD5}}
45733   deny   message   = TLS encryption or CRAM-MD5 required
45734 </literallayout>
45735 <para>
45736 (Another way of applying this restriction is to arrange for the authenticators
45737 that use cleartext passwords not to be advertised when the connection is not
45738 encrypted. You can use the generic <option>server_advertise_condition</option> authenticator
45739 option to do this.)
45740 </para>
45741 </section>
45742 <section>
45743 <title>Format of an ACL</title>
45744 <para>
45745 <indexterm role="concept">
45746 <primary>access control lists (ACLs)</primary>
45747 <secondary>format of</secondary>
45748 </indexterm>
45749 <indexterm role="concept">
45750 <primary>access control lists (ACLs)</primary>
45751 <secondary>verbs; definition of</secondary>
45752 </indexterm>
45753 An individual ACL consists of a number of statements. Each statement starts
45754 with a verb, optionally followed by a number of conditions and <quote>modifiers</quote>.
45755 Modifiers can change the way the verb operates, define error and log messages,
45756 set variables, insert delays, and vary the processing of accepted messages.
45757 </para>
45758 <para>
45759 If all the conditions are met, the verb is obeyed. The same condition may be
45760 used (with different arguments) more than once in the same statement. This
45761 provides a means of specifying an <quote>and</quote> conjunction between conditions. For
45762 example:
45763 </para>
45764 <literallayout class="monospaced">
45765 deny  dnslists = list1.example
45766 dnslists = list2.example
45767 </literallayout>
45768 <para>
45769 If there are no conditions, the verb is always obeyed. Exim stops evaluating
45770 the conditions and modifiers when it reaches a condition that fails. What
45771 happens then depends on the verb (and in one case, on a special modifier). Not
45772 all the conditions make sense at every testing point. For example, you cannot
45773 test a sender address in the ACL that is run for a VRFY command.
45774 </para>
45775 </section>
45776 <section>
45777 <title>ACL verbs</title>
45778 <para>
45779 The ACL verbs are as follows:
45780 </para>
45781 <itemizedlist>
45782 <listitem>
45783 <para>
45784 <indexterm role="concept">
45785 <primary><option>accept</option></primary>
45786 <secondary>ACL verb</secondary>
45787 </indexterm>
45788 <option>accept</option>: If all the conditions are met, the ACL returns <quote>accept</quote>. If any
45789 of the conditions are not met, what happens depends on whether <option>endpass</option>
45790 appears among the conditions (for syntax see below). If the failing condition
45791 is before <option>endpass</option>, control is passed to the next ACL statement; if it is
45792 after <option>endpass</option>, the ACL returns <quote>deny</quote>. Consider this statement, used to
45793 check a RCPT command:
45794 </para>
45795 <literallayout class="monospaced">
45796 accept domains = +local_domains
45797 endpass
45798 verify = recipient
45799 </literallayout>
45800 <para>
45801 If the recipient domain does not match the <option>domains</option> condition, control
45802 passes to the next statement. If it does match, the recipient is verified, and
45803 the command is accepted if verification succeeds. However, if verification
45804 fails, the ACL yields <quote>deny</quote>, because the failing condition is after
45805 <option>endpass</option>.
45806 </para>
45807 </listitem>
45808 <listitem>
45809 <para>
45810 <indexterm role="concept">
45811 <primary><option>defer</option></primary>
45812 <secondary>ACL verb</secondary>
45813 </indexterm>
45814 <option>defer</option>: If all the conditions are met, the ACL returns <quote>defer</quote> which, in
45815 an SMTP session, causes a 4<emphasis>xx</emphasis> response to be given. For a non-SMTP ACL,
45816 <option>defer</option> is the same as <option>deny</option>, because there is no way of sending a
45817 temporary error. For a RCPT command, <option>defer</option> is much the same as using a
45818 <command>redirect</command> router and <literal>:defer:</literal> while verifying, but the <option>defer</option> verb can
45819 be used in any ACL, and even for a recipient it might be a simpler approach.
45820 </para>
45821 </listitem>
45822 <listitem>
45823 <para>
45824 <indexterm role="concept">
45825 <primary><option>deny</option></primary>
45826 <secondary>ACL verb</secondary>
45827 </indexterm>
45828 <option>deny</option>: If all the conditions are met, the ACL returns <quote>deny</quote>. If any of
45829 the conditions are not met, control is passed to the next ACL statement. For
45830 example,
45831 </para>
45832 <literallayout class="monospaced">
45833 deny dnslists = blackholes.mail-abuse.org
45834 </literallayout>
45835 <para>
45836 rejects commands from hosts that are on a DNS black list.
45837 </para>
45838 </listitem>
45839 <listitem>
45840 <para>
45841 <indexterm role="concept">
45842 <primary><option>discard</option></primary>
45843 <secondary>ACL verb</secondary>
45844 </indexterm>
45845 <option>discard</option>: This verb behaves like <option>accept</option>, except that it returns
45846 <quote>discard</quote> from the ACL instead of <quote>accept</quote>. It is permitted only on ACLs
45847 that are concerned with receiving messages, and it causes recipients to be
45848 discarded. If the <option>log_message</option> modifier is set when <option>discard</option> operates,
45849 its contents are added to the line that is automatically written to the log.
45850 </para>
45851 <para>
45852 If <option>discard</option> is used in an ACL for RCPT, just the one recipient is
45853 discarded; if used for MAIL, DATA or in the non-SMTP ACL, all the
45854 message&#x2019;s recipients are discarded. Recipients that are discarded before
45855 DATA do not appear in the log line when the <option>log_recipients</option> log selector
45856 is set.
45857 </para>
45858 </listitem>
45859 <listitem>
45860 <para>
45861 <indexterm role="concept">
45862 <primary><option>drop</option></primary>
45863 <secondary>ACL verb</secondary>
45864 </indexterm>
45865 <option>drop</option>: This verb behaves like <option>deny</option>, except that an SMTP connection is
45866 forcibly closed after the 5<emphasis>xx</emphasis> error message has been sent. For example:
45867 </para>
45868 <literallayout class="monospaced">
45869 drop   message   = I don't take more than 20 RCPTs
45870        condition = ${if &gt; {$rcpt_count}{20}}
45871 </literallayout>
45872 <para>
45873 There is no difference between <option>deny</option> and <option>drop</option> for the connect-time ACL.
45874 The connection is always dropped after sending a 550 response.
45875 </para>
45876 </listitem>
45877 <listitem>
45878 <para>
45879 <indexterm role="concept">
45880 <primary><option>require</option></primary>
45881 <secondary>ACL verb</secondary>
45882 </indexterm>
45883 <option>require</option>: If all the conditions are met, control is passed to the next ACL
45884 statement. If any of the conditions are not met, the ACL returns <quote>deny</quote>. For
45885 example, when checking a RCPT command,
45886 </para>
45887 <literallayout class="monospaced">
45888 require verify = sender
45889 </literallayout>
45890 <para>
45891 passes control to subsequent statements only if the message&#x2019;s sender can be
45892 verified. Otherwise, it rejects the command.
45893 </para>
45894 </listitem>
45895 <listitem>
45896 <para>
45897 <indexterm role="concept">
45898 <primary><option>warn</option></primary>
45899 <secondary>ACL verb</secondary>
45900 </indexterm>
45901 <option>warn</option>: If all the conditions are met, a header line is added to an incoming
45902 message and/or a line is written to Exim&#x2019;s main log. In all cases, control
45903 passes to the next ACL statement. The text of the added header line and the log
45904 line are specified by modifiers; if they are not present, a <option>warn</option> verb just
45905 checks its conditions and obeys any <quote>immediate</quote> modifiers such as <option>set</option> and
45906 <option>logwrite</option>. There is more about adding header lines in section
45907 <xref linkend="SECTaddheadacl"/>.
45908 </para>
45909 <para>
45910 If any condition on a <option>warn</option> statement cannot be completed (that is, there is
45911 some sort of defer), no header lines are added and the configured log line is
45912 not written. No further conditions or modifiers in the <option>warn</option> statement are
45913 processed. The incident is logged, but the ACL continues to be processed, from
45914 the next statement onwards.
45915 </para>
45916 <para>
45917 If a <option>message</option> modifier is present on a <option>warn</option> verb in an ACL that is not
45918 testing an incoming message, it is ignored, and the incident is logged.
45919 </para>
45920 <para>
45921 A <option>warn</option> statement may use the <option>log_message</option> modifier to cause a line to be
45922 written to the main log when the statement&#x2019;s conditions are true.
45923 If an identical log line is requested several times in the same message, only
45924 one copy is actually written to the log. If you want to force duplicates to be
45925 written, use the <option>logwrite</option> modifier instead.
45926 </para>
45927 <para>
45928 <indexterm role="concept">
45929 <primary><varname>$acl_verify_message</varname></primary>
45930 </indexterm>
45931 When one of the <option>warn</option> conditions is an address verification that fails, the
45932 text of the verification failure message is in <varname>$acl_verify_message</varname>. If you
45933 want this logged, you must set it up explicitly. For example:
45934 </para>
45935 <literallayout class="monospaced">
45936 warn   !verify = sender
45937        log_message = sender verify failed: $acl_verify_message
45938 </literallayout>
45939 </listitem>
45940 </itemizedlist>
45941 <para>
45942 At the end of each ACL there is an implicit unconditional <option>deny</option>.
45943 </para>
45944 <para>
45945 As you can see from the examples above, the conditions and modifiers are
45946 written one to a line, with the first one on the same line as the verb, and
45947 subsequent ones on following lines. If you have a very long condition, you can
45948 continue it onto several physical lines by the usual backslash continuation
45949 mechanism. It is conventional to align the conditions vertically.
45950 </para>
45951 </section>
45952 <section id="SECTaclvariables">
45953 <title>ACL variables</title>
45954 <para>
45955 <indexterm role="concept">
45956 <primary>access control lists (ACLs)</primary>
45957 <secondary>variables</secondary>
45958 </indexterm>
45959 There are some special variables that can be set during ACL processing. They
45960 can be used to pass information between different ACLs, different invocations
45961 of the same ACL in the same SMTP connection, and between ACLs and the routers,
45962 transports, and filters that are used to deliver a message. There are two sets
45963 of these variables:
45964 </para>
45965 <itemizedlist>
45966 <listitem>
45967 <para>
45968 The values of <varname>$acl_c0</varname> to <phrase revisionflag="changed"><varname>$acl_c19</varname></phrase> persist throughout an SMTP
45969 connection. They are never reset. Thus, a value that is set while receiving one
45970 message is still available when receiving the next message on the same SMTP
45971 connection.
45972 </para>
45973 </listitem>
45974 <listitem>
45975 <para>
45976 The values of <varname>$acl_m0</varname> to <phrase revisionflag="changed"><varname>$acl_m19</varname></phrase> persist only while a message is
45977 being received. They are reset afterwards. They are also reset by MAIL, RSET,
45978 EHLO, HELO, and after starting up a TLS session.
45979 </para>
45980 </listitem>
45981 </itemizedlist>
45982 <para>
45983 When a message is accepted, the current values of all the ACL variables are
45984 preserved with the message and are subsequently made available at delivery
45985 time. The ACL variables are set by modifier called <option>set</option>. For example:
45986 </para>
45987 <literallayout class="monospaced">
45988 accept hosts = whatever
45989        set acl_m4 = some value
45990 </literallayout>
45991 <para>
45992 <emphasis role="bold">Note</emphasis>: A leading dollar sign is not used when naming a variable that is to
45993 be set. If you want to set a variable without taking any action, you can use a
45994 <option>warn</option> verb without any other modifiers or conditions.
45995 </para>
45996 </section>
45997 <section>
45998 <title>Condition and modifier processing</title>
45999 <para>
46000 <indexterm role="concept">
46001 <primary>access control lists (ACLs)</primary>
46002 <secondary>conditions; processing</secondary>
46003 </indexterm>
46004 <indexterm role="concept">
46005 <primary>access control lists (ACLs)</primary>
46006 <secondary>modifiers; processing</secondary>
46007 </indexterm>
46008 An exclamation mark preceding a condition negates its result. For example:
46009 </para>
46010 <literallayout class="monospaced">
46011 deny   domains = *.dom.example
46012       !verify  = recipient
46013 </literallayout>
46014 <para>
46015 causes the ACL to return <quote>deny</quote> if the recipient domain ends in
46016 <emphasis>dom.example</emphasis> and the recipient address cannot be verified. Sometimes
46017 negation can be used on the right-hand side of a condition. For example, these
46018 two statements are equivalent:
46019 </para>
46020 <literallayout class="monospaced">
46021 deny  hosts = !192.168.3.4
46022 deny !hosts =  192.168.3.4
46023 </literallayout>
46024 <para>
46025 However, for many conditions (<option>verify</option> being a good example), only left-hand
46026 side negation of the whole condition is possible.
46027 </para>
46028 <para>
46029 The arguments of conditions and modifiers are expanded. A forced failure
46030 of an expansion causes a condition to be ignored, that is, it behaves as if the
46031 condition is true. Consider these two statements:
46032 </para>
46033 <literallayout class="monospaced">
46034 accept  senders = ${lookup{$host_name}lsearch\
46035                   {/some/file}{$value}fail}
46036 accept  senders = ${lookup{$host_name}lsearch\
46037                   {/some/file}{$value}{}}
46038 </literallayout>
46039 <para>
46040 Each attempts to look up a list of acceptable senders. If the lookup succeeds,
46041 the returned list is searched, but if the lookup fails the behaviour is
46042 different in the two cases. The <option>fail</option> in the first statement causes the
46043 condition to be ignored, leaving no further conditions. The <option>accept</option> verb
46044 therefore succeeds. The second statement, however, generates an empty list when
46045 the lookup fails. No sender can match an empty list, so the condition fails,
46046 and therefore the <option>accept</option> also fails.
46047 </para>
46048 <para>
46049 ACL modifiers appear mixed in with conditions in ACL statements. Some of them
46050 specify actions that are taken as the conditions for a statement are checked;
46051 others specify text for messages that are used when access is denied or a
46052 warning is generated. The <option>control</option> modifier affects the way an incoming
46053 message is handled.
46054 </para>
46055 <para>
46056 The positioning of the modifiers in an ACL statement important, because the
46057 processing of a verb ceases as soon as its outcome is known. Only those
46058 modifiers that have already been encountered will take effect. For example,
46059 consider this use of the <option>message</option> modifier:
46060 </para>
46061 <literallayout class="monospaced">
46062 require message = Can't verify sender
46063         verify  = sender
46064         message = Can't verify recipient
46065         verify  = recipient
46066         message = This message cannot be used
46067 </literallayout>
46068 <para>
46069 If sender verification fails, Exim knows that the result of the statement is
46070 <quote>deny</quote>, so it goes no further. The first <option>message</option> modifier has been seen,
46071 so its text is used as the error message. If sender verification succeeds, but
46072 recipient verification fails, the second message is used. If recipient
46073 verification succeeds, the third message becomes <quote>current</quote>, but is never used
46074 because there are no more conditions to cause failure.
46075 </para>
46076 <para>
46077 For the <option>deny</option> verb, on the other hand, it is always the last <option>message</option>
46078 modifier that is used, because all the conditions must be true for rejection to
46079 happen. Specifying more than one <option>message</option> modifier does not make sense, and
46080 the message can even be specified after all the conditions. For example:
46081 </para>
46082 <literallayout class="monospaced">
46083 deny   hosts = ...
46084       !senders = *@my.domain.example
46085        message = Invalid sender from client host
46086 </literallayout>
46087 <para>
46088 The <quote>deny</quote> result does not happen until the end of the statement is reached,
46089 by which time Exim has set up the message.
46090 </para>
46091 </section>
46092 <section id="SECTACLmodi">
46093 <title>ACL modifiers</title>
46094 <para>
46095 <indexterm role="concept">
46096 <primary>access control lists (ACLs)</primary>
46097 <secondary>modifiers; list of</secondary>
46098 </indexterm>
46099 The ACL modifiers are as follows:
46100 </para>
46101 <variablelist>
46102 <varlistentry revisionflag="changed">
46103 <term><emphasis role="bold">add_header</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
46104 <listitem>
46105 <para revisionflag="changed">
46106 This modifier specifies one of more header lines that are to be added to an
46107 incoming message, assuming, of course, that the message is ultimately
46108 accepted. For details, see section <xref linkend="SECTaddheadacl"/>.
46109 </para>
46110 </listitem></varlistentry>
46111 <varlistentry>
46112 <term><emphasis role="bold">control</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
46113 <listitem>
46114 <para>
46115 <indexterm role="concept">
46116 <primary><option>control</option></primary>
46117 <secondary>ACL modifier</secondary>
46118 </indexterm>
46119 This modifier affects the subsequent processing of the SMTP connection or of an
46120 incoming message that is accepted. The effect of the first type of control
46121 lasts for the duration of the connection, whereas the effect of the second type
46122 lasts only until the current message has been received. The message-specific
46123 controls always apply to the whole message, not to individual recipients,
46124 even if the <option>control</option> modifier appears in a RCPT ACL.
46125 </para>
46126 <para>
46127 As there are now quite a few controls that can be applied, they are described
46128 separately in section <xref linkend="SECTcontrols"/>. The <option>control</option> modifier can be used
46129 in several different ways. For example:
46130 </para>
46131 <itemizedlist>
46132 <listitem>
46133 <para>
46134 It can be at the end of an <option>accept</option> statement:
46135 </para>
46136 <literallayout class="monospaced">
46137     accept  ...some conditions
46138             control = queue_only
46139 </literallayout>
46140 <para>
46141 In this case, the control is applied when this statement yields <quote>accept</quote>, in
46142 other words, when the conditions are all true.
46143 </para>
46144 </listitem>
46145 <listitem>
46146 <para>
46147 It can be in the middle of an <option>accept</option> statement:
46148 </para>
46149 <literallayout class="monospaced">
46150     accept  ...some conditions...
46151             control = queue_only
46152             ...some more conditions...
46153 </literallayout>
46154 <para>
46155 If the first set of conditions are true, the control is applied, even if the
46156 statement does not accept because one of the second set of conditions is false.
46157 In this case, some subsequent statement must yield <quote>accept</quote> for the control
46158 to be relevant.
46159 </para>
46160 </listitem>
46161 <listitem>
46162 <para>
46163 It can be used with <option>warn</option> to apply the control, leaving the
46164 decision about accepting or denying to a subsequent verb. For
46165 example:
46166 </para>
46167 <literallayout class="monospaced">
46168     warn    ...some conditions...
46169             control = freeze
46170     accept  ...
46171 </literallayout>
46172 <para>
46173 This example of <option>warn</option> does not contain <option>message</option>, <option>log_message</option>, or
46174 <option>logwrite</option>, so it does not add anything to the message and does not write a
46175 log entry.
46176 </para>
46177 </listitem>
46178 <listitem>
46179 <para>
46180 If you want to apply a control unconditionally, you can use it with a
46181 <option>require</option> verb. For example:
46182 </para>
46183 <literallayout class="monospaced">
46184     require  control = no_multiline_response
46185 </literallayout>
46186 </listitem>
46187 </itemizedlist>
46188 </listitem></varlistentry>
46189 <varlistentry>
46190 <term><emphasis role="bold">delay</emphasis>&nbsp;=&nbsp;&lt;<emphasis>time</emphasis>&gt;</term>
46191 <listitem>
46192 <para>
46193 <indexterm role="concept">
46194 <primary><option>delay</option></primary>
46195 <secondary>ACL modifier</secondary>
46196 </indexterm>
46197 <indexterm role="concept">
46198 <primary><option>-bh</option> option</primary>
46199 </indexterm>
46200 This modifier causes Exim to wait for the time interval before proceeding. The
46201 time is given in the usual Exim notation. This modifier may appear in any ACL.
46202 The delay happens as soon as the modifier is processed. However, when testing
46203 Exim using the <option>-bh</option> option, the delay is not actually imposed (an
46204 appropriate message is output instead).
46205 </para>
46206 <para>
46207 Like <option>control</option>, <option>delay</option> can be used with <option>accept</option> or <option>deny</option>, for
46208 example:
46209 </para>
46210 <literallayout class="monospaced">
46211 deny    ...some conditions...
46212         delay = 30s
46213 </literallayout>
46214 <para>
46215 The delay happens if all the conditions are true, before the statement returns
46216 <quote>deny</quote>. Compare this with:
46217 </para>
46218 <literallayout class="monospaced">
46219 deny    delay = 30s
46220         ...some conditions...
46221 </literallayout>
46222 <para>
46223 which waits for 30s before processing the conditions. The <option>delay</option> modifier
46224 can also be used with <option>warn</option> and together with <option>control</option>:
46225 </para>
46226 <literallayout class="monospaced">
46227 warn    ...some conditions...
46228         delay = 2m
46229         control = freeze
46230 accept  ...
46231 </literallayout>
46232 </listitem></varlistentry>
46233 <varlistentry>
46234 <term><emphasis role="bold">endpass</emphasis></term>
46235 <listitem>
46236 <para>
46237 <indexterm role="concept">
46238 <primary><option>endpass</option></primary>
46239 <secondary>ACL modifier</secondary>
46240 </indexterm>
46241 This modifier, which has no argument, is recognized only in <option>accept</option>
46242 statements. It marks the boundary between the conditions whose failure causes
46243 control to pass to the next statement, and the conditions whose failure causes
46244 the ACL to return <quote>deny</quote>. See the description of <option>accept</option> above.
46245 </para>
46246 </listitem></varlistentry>
46247 <varlistentry>
46248 <term><emphasis role="bold">log_message</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
46249 <listitem>
46250 <para>
46251 <indexterm role="concept">
46252 <primary><option>log_message</option></primary>
46253 <secondary>ACL modifier</secondary>
46254 </indexterm>
46255 This modifier sets up a message that is used as part of the log message if the
46256 ACL denies access or a <option>warn</option> statement&#x2019;s conditions are true. For example:
46257 </para>
46258 <literallayout class="monospaced">
46259 require log_message = wrong cipher suite $tls_cipher
46260         encrypted   = DES-CBC3-SHA
46261 </literallayout>
46262 <para>
46263 <option>log_message</option> adds to any underlying error message that may exist because of
46264 the condition failure. For example, while verifying a recipient address, a
46265 <emphasis>:fail:</emphasis> redirection might have already set up a message. Although the
46266 message is usually defined before the conditions to which it applies, the
46267 expansion does not happen until Exim decides that access is to be denied. This
46268 means that any variables that are set by the condition are available for
46269 inclusion in the message. For example, the <varname>$dnslist_</varname>&lt;<emphasis>xxx</emphasis>&gt; variables are
46270 set after a DNS black list lookup succeeds. If the expansion of <option>log_message</option>
46271 fails, or if the result is an empty string, the modifier is ignored.
46272 </para>
46273 <para>
46274 <indexterm role="concept">
46275 <primary><varname>$acl_verify_message</varname></primary>
46276 </indexterm>
46277 If you want to use a <option>warn</option> statement to log the result of an address
46278 verification, you can use <varname>$acl_verify_message</varname> to include the verification
46279 error message.
46280 </para>
46281 <para>
46282 If <option>log_message</option> is used with a <option>warn</option> statement, <quote>Warning:</quote> is added to
46283 the start of the logged message. If the same warning log message is requested
46284 more than once while receiving  a single email message, only one copy is
46285 actually logged. If you want to log multiple copies, use <option>logwrite</option> instead
46286 of <option>log_message</option>. In the absence of <option>log_message</option> and <option>logwrite</option>, nothing
46287 is logged for a succesful <option>warn</option> statement.
46288 </para>
46289 <para>
46290 If <option>log_message</option> is not present and there is no underlying error message (for
46291 example, from the failure of address verification), but <option>message</option> is present,
46292 the <option>message</option> text is used for logging rejections. However, if any text for
46293 logging contains newlines, only the first line is logged. In the absence of
46294 both <option>log_message</option> and <option>message</option>, a default built-in message is used for
46295 logging rejections.
46296 </para>
46297 </listitem></varlistentry>
46298 <varlistentry>
46299 <term><emphasis role="bold">logwrite</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
46300 <listitem>
46301 <para>
46302 <indexterm role="concept">
46303 <primary><option>logwrite</option></primary>
46304 <secondary>ACL modifier</secondary>
46305 </indexterm>
46306 <indexterm role="concept">
46307 <primary>logging in ACL</primary>
46308 <secondary>immediate</secondary>
46309 </indexterm>
46310 This modifier writes a message to a log file as soon as it is encountered when
46311 processing an ACL. (Compare <option>log_message</option>, which, except in the case of
46312 <option>warn</option>, is used only if the ACL statement denies access.) The <option>logwrite</option>
46313 modifier can be used to log special incidents in ACLs. For example:
46314 </para>
46315 <literallayout>
46316 <literal>accept </literal>&lt;<emphasis>some special conditions</emphasis>&gt;
46317 <literal>       control  = freeze</literal>
46318 <literal>       logwrite = froze message because ...</literal>
46319 </literallayout>
46320 <para>
46321 By default, the message is written to the main log. However, it may begin
46322 with a colon, followed by a comma-separated list of log names, and then
46323 another colon, to specify exactly which logs are to be written. For
46324 example:
46325 </para>
46326 <literallayout class="monospaced">
46327 logwrite = :main,reject: text for main and reject logs
46328 logwrite = :panic: text for panic log only
46329 </literallayout>
46330 </listitem></varlistentry>
46331 <varlistentry>
46332 <term><emphasis role="bold">message</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
46333 <listitem>
46334 <para>
46335 <indexterm role="concept">
46336 <primary><option>message</option></primary>
46337 <secondary>ACL modifier</secondary>
46338 </indexterm>
46339 This modifier sets up a text string that is expanded and used as an error
46340 message if the current statement causes the ACL to deny access. The expansion
46341 happens at the time Exim decides that access is to be denied, not at the time
46342 it processes <option>message</option>. If the expansion fails, or generates an empty string,
46343 the modifier is ignored. For ACLs that are triggered by SMTP commands, the
46344 message is returned as part of the SMTP error response.
46345 </para>
46346 <para>
46347 The text is literal; any quotes are taken as literals, but because the string
46348 is expanded, backslash escapes are processed anyway. If the message contains
46349 newlines, this gives rise to a multi-line SMTP response. Like <option>log_message</option>,
46350 the contents of <option>message</option> are not expanded until after a condition has
46351 failed.
46352 </para>
46353 <para>
46354 <indexterm role="concept">
46355 <primary><varname>$acl_verify_message</varname></primary>
46356 </indexterm>
46357 If <option>message</option> is used on a statement that verifies an address, the message
46358 specified overrides any message that is generated by the verification process.
46359 However, the original message is available in the variable
46360 <varname>$acl_verify_message</varname>, so you can incorporate it into your message if you
46361 wish. In particular, if you want the text from <option>:fail:</option> items in <command>redirect</command>
46362 routers to be passed back as part of the SMTP response, you should either not
46363 use a <option>message</option> modifier, or make use of <varname>$acl_verify_message</varname>.
46364 </para>
46365 <para revisionflag="changed">
46366 For compatibility with previous releases of Exim, a <option>message</option> modifier that
46367 is used with a <option>warn</option> verb behaves in a similar way to the <option>add_header</option>
46368 modifier, but this usage is now deprecated. However, <option>message</option> acts only when
46369 all the conditions are true, wherever it appears in an ACL command, whereas
46370 <option>add_header</option> acts as soon as it is encountered. If <option>message</option> is used with
46371 <option>warn</option> in an ACL that is not concerned with receiving a message, it has no
46372 effect.
46373 </para>
46374 </listitem></varlistentry>
46375 <varlistentry>
46376 <term><emphasis role="bold">set</emphasis>&nbsp;&lt;<emphasis>acl_name</emphasis>&gt;&nbsp;=&nbsp;&lt;<emphasis>value</emphasis>&gt;</term>
46377 <listitem>
46378 <para>
46379 <indexterm role="concept">
46380 <primary><option>set</option></primary>
46381 <secondary>ACL modifier</secondary>
46382 </indexterm>
46383 This modifier puts a value into one of the ACL variables (see section
46384 <xref linkend="SECTaclvariables"/>).
46385 </para>
46386 </listitem></varlistentry>
46387 </variablelist>
46388 </section>
46389 <section id="SECTcontrols">
46390 <title>Use of the control modifier</title>
46391 <para>
46392 <indexterm role="concept">
46393 <primary><option>control</option></primary>
46394 <secondary>ACL modifier</secondary>
46395 </indexterm>
46396 The <option>control</option> modifier supports the following settings:
46397 </para>
46398 <variablelist>
46399 <varlistentry revisionflag="changed">
46400 <term><emphasis role="bold">control&nbsp;=&nbsp;allow_auth_unadvertised</emphasis></term>
46401 <listitem>
46402 <para revisionflag="changed">
46403 This modifier allows a client host to use the SMTP AUTH command even when it
46404 has not been advertised in response to EHLO. Furthermore, because there are
46405 apparently some really broken clients that do this, Exim will accept AUTH after
46406 HELO (rather than EHLO) when this control is set. It should be used only if you
46407 really need it, and you should limit its use to those broken clients that do
46408 not work without it. For example:
46409 </para>
46410 <literallayout class="monospaced" revisionflag="changed">
46411 warn hosts   = 192.168.34.25
46412      control = allow_auth_unadvertised
46413 </literallayout>
46414 <para revisionflag="changed">
46415 Normally, when an Exim server receives an AUTH command, it checks the name of
46416 the authentication mechanism that is given in the command to ensure that it
46417 matches an advertised mechanism. When this control is set, the check that a
46418 mechanism has been advertised is bypassed. Any configured mechanism can be used
46419 by the client. This control is permitted only in the connection and HELO ACLs.
46420 </para>
46421 </listitem></varlistentry>
46422 <varlistentry>
46423 <term><emphasis role="bold">control&nbsp;=&nbsp;caseful_local_part</emphasis></term>
46424 <listitem>
46425 <para>
46426 See below.
46427 </para>
46428 </listitem></varlistentry>
46429 <varlistentry>
46430 <term><emphasis role="bold">control&nbsp;=&nbsp;caselower_local_part</emphasis></term>
46431 <listitem>
46432 <para>
46433 <indexterm role="concept">
46434 <primary>access control lists (ACLs)</primary>
46435 <secondary>case of local part in</secondary>
46436 </indexterm>
46437 <indexterm role="concept">
46438 <primary>case of local parts</primary>
46439 </indexterm>
46440 <indexterm role="concept">
46441 <primary><varname>$local_part</varname></primary>
46442 </indexterm>
46443 These two controls are permitted only in the ACL specified by <option>acl_smtp_rcpt</option>
46444 (that is, during RCPT processing). By default, the contents of <varname>$local_part</varname>
46445 are lower cased before ACL processing. If <quote>caseful_local_part</quote> is specified,
46446 any uppercase letters in the original local part are restored in <varname>$local_part</varname>
46447 for the rest of the ACL, or until a control that sets <quote>caselower_local_part</quote>
46448 is encountered.
46449 </para>
46450 <para>
46451 These controls affect only the current recipient. Moreover, they apply only to
46452 local part handling that takes place directly in the ACL (for example, as a key
46453 in lookups). If a test to verify the recipient is obeyed, the case-related
46454 handling of the local part during the verification is controlled by the router
46455 configuration (see the <option>caseful_local_part</option> generic router option).
46456 </para>
46457 <para>
46458 This facility could be used, for example, to add a spam score to local parts
46459 containing upper case letters. For example, using <varname>$acl_m4</varname> to accumulate the
46460 spam score:
46461 </para>
46462 <literallayout class="monospaced">
46463 warn  control = caseful_local_part
46464       set acl_m4 = ${eval:\
46465                      $acl_m4 + \
46466                      ${if match{$local_part}{[A-Z]}{1}{0}}\
46467                     }
46468       control = caselower_local_part
46469 </literallayout>
46470 <para>
46471 Notice that we put back the lower cased version afterwards, assuming that
46472 is what is wanted for subsequent tests.
46473 </para>
46474 </listitem></varlistentry>
46475 <varlistentry>
46476 <term><emphasis role="bold">control&nbsp;=&nbsp;enforce_sync</emphasis></term>
46477 <listitem>
46478 <para>
46479 See below.
46480 </para>
46481 </listitem></varlistentry>
46482 <varlistentry>
46483 <term><emphasis role="bold">control&nbsp;=&nbsp;no_enforce_sync</emphasis></term>
46484 <listitem>
46485 <para>
46486 <indexterm role="concept">
46487 <primary>SMTP</primary>
46488 <secondary>synchronization checking</secondary>
46489 </indexterm>
46490 <indexterm role="concept">
46491 <primary>synchronization checking in SMTP</primary>
46492 </indexterm>
46493 These controls make it possible to be selective about when SMTP synchronization
46494 is enforced. The global option <option>smtp_enforce_sync</option> specifies the initial
46495 state of the switch (it is true by default). See the description of this option
46496 in chapter <xref linkend="CHAPmainconfig"/> for details of SMTP synchronization checking.
46497 </para>
46498 <para>
46499 The effect of these two controls lasts for the remainder of the SMTP
46500 connection. They can appear in any ACL except the one for the non-SMTP
46501 messages. The most straightforward place to put them is in the ACL defined by
46502 <option>acl_smtp_connect</option>, which is run at the start of an incoming SMTP connection,
46503 before the first synchronization check. The expected use is to turn off the
46504 synchronization checks for badly-behaved hosts that you nevertheless need to
46505 work with.
46506 </para>
46507 </listitem></varlistentry>
46508 <varlistentry>
46509 <term><emphasis role="bold">control&nbsp;=&nbsp;fakedefer/</emphasis>&lt;<emphasis>message</emphasis>&gt;</term>
46510 <listitem>
46511 <para>
46512 <indexterm role="concept">
46513 <primary>fake defer</primary>
46514 </indexterm>
46515 <indexterm role="concept">
46516 <primary>defer</primary>
46517 <secondary>fake</secondary>
46518 </indexterm>
46519 This control works in exactly the same way as <option>fakereject</option> (described below)
46520 except that it causes an SMTP 450 response after the message data instead of a
46521 550 response. You must take care when using <option>fakedefer</option> because it causes the
46522 messages to be duplicated when the sender retries. Therefore, you should not
46523 use <option>fakedefer</option> if the message is to be delivered normally.
46524 </para>
46525 </listitem></varlistentry>
46526 <varlistentry>
46527 <term><emphasis role="bold">control&nbsp;=&nbsp;fakereject/</emphasis>&lt;<emphasis>message</emphasis>&gt;</term>
46528 <listitem>
46529 <para>
46530 <indexterm role="concept">
46531 <primary>fake rejection</primary>
46532 </indexterm>
46533 <indexterm role="concept">
46534 <primary>rejection</primary>
46535 <secondary>fake</secondary>
46536 </indexterm>
46537 This control is permitted only for the MAIL, RCPT, and DATA ACLs, in other
46538 words, only when an SMTP message is being received. If Exim accepts the
46539 message, instead the final 250 response, a 550 rejection message is sent.
46540 However, Exim proceeds to deliver the message as normal. The control applies
46541 only to the current message, not to any subsequent ones that may be received in
46542 the same SMTP connection.
46543 </para>
46544 <para>
46545 The text for the 550 response is taken from the <option>control</option> modifier. If no
46546 message is supplied, the following is used:
46547 </para>
46548 <literallayout class="monospaced">
46549 550-Your message has been rejected but is being
46550 550-kept for evaluation.
46551 550-If it was a legitimate message, it may still be
46552 550 delivered to the target recipient(s).
46553 </literallayout>
46554 <para>
46555 This facilty should be used with extreme caution.
46556 </para>
46557 </listitem></varlistentry>
46558 <varlistentry>
46559 <term><emphasis role="bold">control&nbsp;=&nbsp;freeze</emphasis></term>
46560 <listitem>
46561 <para>
46562 <indexterm role="concept">
46563 <primary>frozen messages</primary>
46564 <secondary>forcing in ACL</secondary>
46565 </indexterm>
46566 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs, in
46567 other words, only when a message is being received. If the message is accepted,
46568 it is placed on Exim&#x2019;s queue and frozen. The control applies only to the
46569 current message, not to any subsequent ones that may be received in the same
46570 SMTP connection.
46571 </para>
46572 <para revisionflag="changed">
46573 This modifier can optionally be followed by <literal>/no_tell</literal>. If the global option
46574 <option>freeze_tell</option> is set, it is ignored for the current message (that is, nobody
46575 is told about the freezing), provided all the <emphasis role="bold">control=freeze</emphasis> modifiers that
46576 are obeyed for the current message have the <literal>/no_tell</literal> option.
46577 </para>
46578 </listitem></varlistentry>
46579 <varlistentry>
46580 <term><emphasis role="bold">control&nbsp;=&nbsp;no_mbox_unspool</emphasis></term>
46581 <listitem>
46582 <para>
46583 This control is available when Exim is compiled with the content scanning
46584 extension. Content scanning may require a copy of the current message, or parts
46585 of it, to be written in <quote>mbox format</quote> to a spool file, for passing to a virus
46586 or spam scanner. Normally, such copies are deleted when they are no longer
46587 needed. If this control is set, the copies are not deleted. The control applies
46588 only to the current message, not to any subsequent ones that may be received in
46589 the same SMTP connection. It is provided for debugging purposes and is unlikely
46590 to be useful in production.
46591 </para>
46592 </listitem></varlistentry>
46593 <varlistentry>
46594 <term><emphasis role="bold">control&nbsp;=&nbsp;no_multiline_response</emphasis></term>
46595 <listitem>
46596 <para>
46597 <indexterm role="concept">
46598 <primary>multiline responses</primary>
46599 <secondary>suppressing</secondary>
46600 </indexterm>
46601 This control is permitted for any ACL except the one for non-SMTP messages.
46602 It seems that there are broken clients in use that cannot handle multiline
46603 SMTP responses, despite the fact that RFC 821 defined them over 20 years ago.
46604 </para>
46605 <para>
46606 If this control is set, multiline SMTP responses from ACL rejections are
46607 suppressed. One way of doing this would have been to put out these responses as
46608 one long line. However, RFC 2821 specifies a maximum of 512 bytes per response
46609 (<quote>use multiline responses for more</quote> it says &ndash; ha!), and some of the
46610 responses might get close to that. So this facility, which is after all only a
46611 sop to broken clients, is implemented by doing two very easy things:
46612 </para>
46613 <itemizedlist>
46614 <listitem>
46615 <para>
46616 Extra information that is normally output as part of a rejection caused by
46617 sender verification failure is omitted. Only the final line (typically <quote>sender
46618 verification failed</quote>) is sent.
46619 </para>
46620 </listitem>
46621 <listitem>
46622 <para>
46623 If a <option>message</option> modifier supplies a multiline response, only the first
46624 line is output.
46625 </para>
46626 </listitem>
46627 </itemizedlist>
46628 <para>
46629 The setting of the switch can, of course, be made conditional on the
46630 calling host. Its effect lasts until the end of the SMTP connection.
46631 </para>
46632 </listitem></varlistentry>
46633 <varlistentry>
46634 <term><emphasis role="bold">control&nbsp;=&nbsp;queue_only</emphasis></term>
46635 <listitem>
46636 <para>
46637 <indexterm role="concept">
46638 <primary><option>queue_only</option></primary>
46639 </indexterm>
46640 <indexterm role="concept">
46641 <primary>queueing incoming messages</primary>
46642 </indexterm>
46643 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs, in
46644 other words, only when a message is being received. If the message is accepted,
46645 it is placed on Exim&#x2019;s queue and left there for delivery by a subsequent queue
46646 runner. No immediate delivery process is started. In other words, it has the
46647 effect as the <option>queue_only</option> global option. However, the control applies only
46648 to the current message, not to any subsequent ones that may be received in the
46649 same SMTP connection.
46650 </para>
46651 </listitem></varlistentry>
46652 <varlistentry>
46653 <term><emphasis role="bold">control&nbsp;=&nbsp;submission/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
46654 <listitem>
46655 <para>
46656 <indexterm role="concept">
46657 <primary>message</primary>
46658 <secondary>submission</secondary>
46659 </indexterm>
46660 <indexterm role="concept">
46661 <primary>submission mode</primary>
46662 </indexterm>
46663 This control is permitted only for the MAIL, RCPT, and start of data ACLs (the
46664 latter is the one defined by <option>acl_smtp_predata</option>). Setting it tells Exim that
46665 the current message is a submission from a local MUA. In this case, Exim
46666 operates in <quote>submission mode</quote>, and applies certain fixups to the message if
46667 necessary. For example, it add a <emphasis>Date:</emphasis> header line if one is not present.
46668 This control is not permitted in the <option>acl_smtp_data</option> ACL, because that is too
46669 late (the message has already been created).
46670 </para>
46671 <para>
46672 Chapter <xref linkend="CHAPmsgproc"/> describes the processing that Exim applies to
46673 messages. Section <xref linkend="SECTsubmodnon"/> covers the processing that happens in
46674 submission mode; the available options for this control are described there.
46675 The control applies only to the current message, not to any subsequent ones
46676 that may be received in the same SMTP connection.
46677 </para>
46678 </listitem></varlistentry>
46679 <varlistentry>
46680 <term><emphasis role="bold">control&nbsp;=&nbsp;suppress_local_fixups</emphasis></term>
46681 <listitem>
46682 <para>
46683 <indexterm role="concept">
46684 <primary>submission fixups</primary>
46685 <secondary>suppressing</secondary>
46686 </indexterm>
46687 This control applies to locally submitted (non TCP/IP) messages, and is the
46688 complement of <literal>control</literal> <literal>=</literal> <literal>submission</literal>. It disables the fixups that are
46689 normally applied to locally-submitted messages. Specifically:
46690 </para>
46691 <itemizedlist>
46692 <listitem>
46693 <para>
46694 Any <emphasis>Sender:</emphasis> header line is left alone (in this respect, it is a
46695 dynamic version of <option>local_sender_retain</option>).
46696 </para>
46697 </listitem>
46698 <listitem>
46699 <para>
46700 No <emphasis>Message-ID:</emphasis>, <emphasis>From:</emphasis>, or <emphasis>Date:</emphasis> header lines are added.
46701 </para>
46702 </listitem>
46703 <listitem>
46704 <para>
46705 There is no check that <emphasis>From:</emphasis> corresponds to the actual sender.
46706 </para>
46707 </listitem>
46708 </itemizedlist>
46709 <para>
46710 This feature may be useful when a remotely-originated message is accepted,
46711 passed to some scanning program, and then re-submitted for delivery.
46712 </para>
46713 </listitem></varlistentry>
46714 </variablelist>
46715 <para>
46716 All four possibilities for message fixups can be specified:
46717 </para>
46718 <itemizedlist>
46719 <listitem>
46720 <para>
46721 Locally submitted, fixups applied: the default.
46722 </para>
46723 </listitem>
46724 <listitem>
46725 <para>
46726 Locally submitted, no fixups applied: use <literal>control</literal> <literal>=</literal>
46727 <literal>suppress_local_fixups</literal>.
46728 </para>
46729 </listitem>
46730 <listitem>
46731 <para>
46732 Remotely submitted, no fixups applied: the default.
46733 </para>
46734 </listitem>
46735 <listitem>
46736 <para>
46737 Remotely submitted, fixups applied: use <literal>control</literal> <literal>=</literal> <literal>submission</literal>.
46738 </para>
46739 </listitem>
46740 </itemizedlist>
46741 </section>
46742 <section id="SECTaddheadacl" revisionflag="changed">
46743 <title>Adding header lines in ACLs</title>
46744 <para revisionflag="changed">
46745 <indexterm role="concept">
46746 <primary>header lines</primary>
46747 <secondary>adding in an ACL</secondary>
46748 </indexterm>
46749 <indexterm role="concept">
46750 <primary>header lines</primary>
46751 <secondary>position of added lines</secondary>
46752 </indexterm>
46753 <indexterm role="concept">
46754 <primary><option>message</option></primary>
46755 <secondary>ACL modifier</secondary>
46756 </indexterm>
46757 The <option>add_header</option> modifier can be used to add one or more extra header lines
46758 to an incoming message, as in this example:
46759 </para>
46760 <literallayout class="monospaced" revisionflag="changed">
46761 warn dnslists = sbl.spamhaus.org : \
46762                 dialup.mail-abuse.org
46763      add_header = X-blacklisted-at: $dnslist_domain
46764 </literallayout>
46765 <para revisionflag="changed">
46766 The <option>add_header</option> modifier is permitted in the MAIL, RCPT, PREDATA, DATA,
46767 MIME, and non-SMTP ACLs (in other words, those that are concerned with
46768 receiving a message). The message must ultimately be accepted for
46769 <option>add_header</option> to have any significant effect. You can use <option>add_header</option> with
46770 any ACL verb, including <option>deny</option> (though this is potentially useful only in a
46771 RCPT ACL).
46772 </para>
46773 <para revisionflag="changed">
46774 If the data for the <option>add_header</option> modifier contains one or more newlines that
46775 are not followed by a space or a tab, it is assumed to contain multiple header
46776 lines. Each one is checked for valid syntax; <literal>X-ACL-Warn:</literal> is added to the
46777 front of any line that is not a valid header line.
46778 </para>
46779 <para revisionflag="changed">
46780 Added header lines are accumulated during the MAIL, RCPT, and predata ACLs.
46781 They are added to the message before processing the DATA and MIME ACLs.
46782 However, if an identical header line is requested more than once, only one copy
46783 is actually added to the message. Further header lines may be accumulated
46784 during the DATA and MIME ACLs, after which they are added to the message, again
46785 with duplicates suppressed. Thus, it is possible to add two identical header
46786 lines to an SMTP message, but only if one is added before DATA and one after.
46787 In the case of non-SMTP messages, new headers are accumulated during the
46788 non-SMTP ACL, and added to the message at the end. If a message is rejected
46789 after DATA or by the non-SMTP ACL, all added header lines are included in the
46790 entry that is written to the reject log.
46791 </para>
46792 <para revisionflag="changed">
46793 <indexterm role="concept">
46794 <primary>header lines</primary>
46795 <secondary>added; visibility of</secondary>
46796 </indexterm>
46797 Header lines are not visible in string expansions until they are added to the
46798 message. It follows that header lines defined in the MAIL, RCPT, and predata
46799 ACLs are not visible until the DATA ACL and MIME ACLs are run. Similarly,
46800 header lines that are added by the DATA or MIME ACLs are not visible in those
46801 ACLs. Because of this restriction, you cannot use header lines as a way of
46802 passing data between (for example) the MAIL and RCPT ACLs. If you want to do
46803 this, you can use ACL variables, as described in section
46804 <xref linkend="SECTaclvariables"/>.
46805 </para>
46806 <para revisionflag="changed">
46807 The <option>add_header</option> modifier acts immediately it is encountered during the
46808 processing of an ACL. Notice the difference between these two cases:
46809 </para>
46810 <literallayout revisionflag="changed">
46811 <literal>accept add_header = ADDED: some text</literal>
46812 <literal>       </literal>&lt;<emphasis>some condition</emphasis>&gt;
46813
46814 <literal>accept </literal>&lt;<emphasis>some condition</emphasis>&gt;
46815 <literal>       add_header = ADDED: some text</literal>
46816 </literallayout>
46817 <para revisionflag="changed">
46818 In the first case, the header line is always added, whether or not the
46819 condition is true. In the second case, the header line is added only if the
46820 condition is true. Multiple occurrences of <option>add_header</option> may occur in the same
46821 ACL statement. All those that are encountered before a condition fails are
46822 honoured.
46823 </para>
46824 <para revisionflag="changed">
46825 <indexterm role="concept">
46826 <primary><option>warn</option></primary>
46827 <secondary>ACL verb</secondary>
46828 </indexterm>
46829 For compatibility with previous versions of Exim, a <option>message</option> modifier for a
46830 <option>warn</option> verb acts in the same way as <option>add_header</option>, except that it takes
46831 effect only if all the conditions are true, even if it appears before some of
46832 them. Furthermore, only the last occurrence of <option>message</option> is honoured. This
46833 usage of <option>message</option> is now deprecated. If both <option>add_header</option> and <option>message</option>
46834 are present on a <option>warn</option> verb, both are processed according to their
46835 specifications.
46836 </para>
46837 <para revisionflag="changed">
46838 By default, new header lines are added to a message at the end of the existing
46839 header lines. However, you can specify that any particular header line should
46840 be added right at the start (before all the <emphasis>Received:</emphasis> lines), immediately
46841 after the first block of <emphasis>Received:</emphasis> lines, or immediately before any line
46842 that is not a <emphasis>Received:</emphasis> or <emphasis>Resent-something:</emphasis> header.
46843 </para>
46844 <para revisionflag="changed">
46845 This is done by specifying <quote>:at_start:</quote>, <quote>:after_received:</quote>, or
46846 <quote>:at_start_rfc:</quote> (or, for completeness, <quote>:at_end:</quote>) before the text of the
46847 header line, respectively. (Header text cannot start with a colon, as there has
46848 to be a header name first.) For example:
46849 </para>
46850 <literallayout class="monospaced" revisionflag="changed">
46851 warn add_header = \
46852        :after_received:X-My-Header: something or other...
46853 </literallayout>
46854 <para revisionflag="changed">
46855 If more than one header line is supplied in a single <option>add_header</option> modifier,
46856 each one is treated independently and can therefore be placed differently. If
46857 you add more than one line at the start, or after the Received: block, they end
46858 up in reverse order.
46859 </para>
46860 <para revisionflag="changed">
46861 <emphasis role="bold">Warning</emphasis>: This facility currently applies only to header lines that are
46862 added in an ACL. It does NOT work for header lines that are added in a
46863 system filter or in a router or transport.
46864 </para>
46865 </section>
46866 <section id="SECTaclconditions">
46867 <title>ACL conditions</title>
46868 <para>
46869 <indexterm role="concept">
46870 <primary>access control lists (ACLs)</primary>
46871 <secondary>conditions; list of</secondary>
46872 </indexterm>
46873 Some of conditions listed in this section are available only when Exim is
46874 compiled with the content-scanning extension. They are included here briefly
46875 for completeness. More detailed descriptions can be found in the discussion on
46876 content scanning in chapter <xref linkend="CHAPexiscan"/>.
46877 </para>
46878 <para>
46879 Not all conditions are relevant in all circumstances. For example, testing
46880 senders and recipients does not make sense in an ACL that is being run as the
46881 result of the arrival of an ETRN command, and checks on message headers can be
46882 done only in the ACLs specified by <option>acl_smtp_data</option> and <option>acl_not_smtp</option>. You
46883 can use the same condition (with different parameters) more than once in the
46884 same ACL statement. This provides a way of specifying an <quote>and</quote> conjunction.
46885 The conditions are as follows:
46886 </para>
46887 <variablelist>
46888 <varlistentry>
46889 <term><emphasis role="bold">acl&nbsp;=&nbsp;</emphasis>&lt;<emphasis>name&nbsp;of&nbsp;acl&nbsp;or&nbsp;ACL&nbsp;string&nbsp;or&nbsp;file&nbsp;name&nbsp;</emphasis>&gt;</term>
46890 <listitem>
46891 <para>
46892 <indexterm role="concept">
46893 <primary>access control lists (ACLs)</primary>
46894 <secondary>nested</secondary>
46895 </indexterm>
46896 <indexterm role="concept">
46897 <primary>access control lists (ACLs)</primary>
46898 <secondary>indirect</secondary>
46899 </indexterm>
46900 <indexterm role="concept">
46901 <primary><option>acl</option></primary>
46902 <secondary>ACL condition</secondary>
46903 </indexterm>
46904 The possible values of the argument are the same as for the
46905 <option>acl_smtp_</option><emphasis>xxx</emphasis> options. The named or inline ACL is run. If it returns
46906 <quote>accept</quote> the condition is true; if it returns <quote>deny</quote> the condition is
46907 false. If it returns <quote>defer</quote>, the current ACL returns <quote>defer</quote> unless the
46908 condition is on a <option>warn</option> verb. In that case, a <quote>defer</quote> return makes the
46909 condition false. This means that further processing of the <option>warn</option> verb
46910 ceases, but processing of the ACL continues.
46911 </para>
46912 <para>
46913 If the nested <option>acl</option> returns <quote>drop</quote> and the outer condition denies access,
46914 the connection is dropped. If it returns <quote>discard</quote>, the verb must be
46915 <option>accept</option> or <option>discard</option>, and the action is taken immediately &ndash; no further
46916 conditions are tested.
46917 </para>
46918 <para>
46919 ACLs may be nested up to 20 deep; the limit exists purely to catch runaway
46920 loops. This condition allows you to use different ACLs in different
46921 circumstances. For example, different ACLs can be used to handle RCPT commands
46922 for different local users or different local domains.
46923 </para>
46924 </listitem></varlistentry>
46925 <varlistentry>
46926 <term><emphasis role="bold">authenticated&nbsp;=&nbsp;</emphasis>&lt;<emphasis>string&nbsp;list</emphasis>&gt;</term>
46927 <listitem>
46928 <para>
46929 <indexterm role="concept">
46930 <primary><option>authenticated</option></primary>
46931 <secondary>ACL condition</secondary>
46932 </indexterm>
46933 <indexterm role="concept">
46934 <primary>authentication</primary>
46935 <secondary>ACL checking</secondary>
46936 </indexterm>
46937 <indexterm role="concept">
46938 <primary>access control lists (ACLs)</primary>
46939 <secondary>testing for authentication</secondary>
46940 </indexterm>
46941 If the SMTP connection is not authenticated, the condition is false. Otherwise,
46942 the name of the authenticator is tested against the list. To test for
46943 authentication by any authenticator, you can set
46944 </para>
46945 <literallayout class="monospaced">
46946 authenticated = *
46947 </literallayout>
46948 </listitem></varlistentry>
46949 <varlistentry>
46950 <term><emphasis role="bold">condition&nbsp;=&nbsp;</emphasis>&lt;<emphasis>string</emphasis>&gt;</term>
46951 <listitem>
46952 <para>
46953 <indexterm role="concept">
46954 <primary><option>condition</option></primary>
46955 <secondary>ACL condition</secondary>
46956 </indexterm>
46957 <indexterm role="concept">
46958 <primary>customizing</primary>
46959 <secondary>ACL condition</secondary>
46960 </indexterm>
46961 <indexterm role="concept">
46962 <primary>access control lists (ACLs)</primary>
46963 <secondary>customized test</secondary>
46964 </indexterm>
46965 <indexterm role="concept">
46966 <primary>access control lists (ACLs)</primary>
46967 <secondary>testing; customized</secondary>
46968 </indexterm>
46969 This feature allows you to make up custom conditions. If the result of
46970 expanding the string is an empty string, the number zero, or one of the strings
46971 <quote>no</quote> or <quote>false</quote>, the condition is false. If the result is any non-zero
46972 number, or one of the strings <quote>yes</quote> or <quote>true</quote>, the condition is true. For
46973 any other values, some error is assumed to have occurred, and the ACL returns
46974 <quote>defer</quote>.
46975 </para>
46976 </listitem></varlistentry>
46977 <varlistentry>
46978 <term><emphasis role="bold">decode&nbsp;=&nbsp;</emphasis>&lt;<emphasis>location</emphasis>&gt;</term>
46979 <listitem>
46980 <para>
46981 <indexterm role="concept">
46982 <primary><option>decode</option></primary>
46983 <secondary>ACL condition</secondary>
46984 </indexterm>
46985 This condition is available only when Exim is compiled with the
46986 content-scanning extension, and it is allowed only the the ACL defined by
46987 <option>acl_smtp_mime</option>. It causes the current MIME part to be decoded into a file.
46988 For details, see chapter <xref linkend="CHAPexiscan"/>.
46989 </para>
46990 </listitem></varlistentry>
46991 <varlistentry>
46992 <term><emphasis role="bold">demime&nbsp;=&nbsp;</emphasis>&lt;<emphasis>extension&nbsp;list</emphasis>&gt;</term>
46993 <listitem>
46994 <para>
46995 <indexterm role="concept">
46996 <primary><option>demime</option></primary>
46997 <secondary>ACL condition</secondary>
46998 </indexterm>
46999 This condition is available only when Exim is compiled with the
47000 content-scanning extension. Its use is described in section
47001 <xref linkend="SECTdemimecond"/>.
47002 </para>
47003 </listitem></varlistentry>
47004 <varlistentry>
47005 <term><emphasis role="bold">dnslists&nbsp;=&nbsp;</emphasis>&lt;<emphasis>list&nbsp;of&nbsp;domain&nbsp;names&nbsp;and&nbsp;other&nbsp;data</emphasis>&gt;</term>
47006 <listitem>
47007 <para>
47008 <indexterm role="concept">
47009 <primary><option>dnslists</option></primary>
47010 <secondary>ACL condition</secondary>
47011 </indexterm>
47012 <indexterm role="concept">
47013 <primary>DNS list</primary>
47014 <secondary>in ACL</secondary>
47015 </indexterm>
47016 <indexterm role="concept">
47017 <primary>black list (DNS)</primary>
47018 </indexterm>
47019 <indexterm role="concept">
47020 <primary>access control lists (ACLs)</primary>
47021 <secondary>testing a DNS list</secondary>
47022 </indexterm>
47023 This condition checks for entries in DNS black lists. These are also known as
47024 <quote>RBL lists</quote>, after the original Realtime Blackhole List, but note that the
47025 use of the lists at <emphasis>mail-abuse.org</emphasis> now carries a charge. There are too many
47026 different variants of this condition to describe briefly here. See sections
47027 <xref linkend="SECTmorednslists"/>--<xref linkend="SECTmorednslistslast"/> for details.
47028 </para>
47029 </listitem></varlistentry>
47030 <varlistentry>
47031 <term><emphasis role="bold">domains&nbsp;=&nbsp;</emphasis>&lt;<emphasis>domain&nbsp;list</emphasis>&gt;</term>
47032 <listitem>
47033 <para>
47034 <indexterm role="concept">
47035 <primary><option>domains</option></primary>
47036 <secondary>ACL condition</secondary>
47037 </indexterm>
47038 <indexterm role="concept">
47039 <primary>domain</primary>
47040 <secondary>ACL checking</secondary>
47041 </indexterm>
47042 <indexterm role="concept">
47043 <primary>access control lists (ACLs)</primary>
47044 <secondary>testing a recipient domain</secondary>
47045 </indexterm>
47046 <indexterm role="concept">
47047 <primary><varname>$domain_data</varname></primary>
47048 </indexterm>
47049 This condition is relevant only after a RCPT command. It checks that the domain
47050 of the recipient address is in the domain list. If percent-hack processing is
47051 enabled, it is done before this test is done. If the check succeeds with a
47052 lookup, the result of the lookup is placed in <varname>$domain_data</varname> until the next
47053 <option>domains</option> test.
47054 </para>
47055 </listitem></varlistentry>
47056 <varlistentry>
47057 <term><emphasis role="bold">encrypted&nbsp;=&nbsp;</emphasis>&lt;<emphasis>string&nbsp;list</emphasis>&gt;</term>
47058 <listitem>
47059 <para>
47060 <indexterm role="concept">
47061 <primary><option>encrypted</option></primary>
47062 <secondary>ACL condition</secondary>
47063 </indexterm>
47064 <indexterm role="concept">
47065 <primary>encryption</primary>
47066 <secondary>checking in an ACL</secondary>
47067 </indexterm>
47068 <indexterm role="concept">
47069 <primary>access control lists (ACLs)</primary>
47070 <secondary>testing for encryption</secondary>
47071 </indexterm>
47072 If the SMTP connection is not encrypted, the condition is false. Otherwise, the
47073 name of the cipher suite in use is tested against the list. To test for
47074 encryption without testing for any specific cipher suite(s), set
47075 </para>
47076 <literallayout class="monospaced">
47077 encrypted = *
47078 </literallayout>
47079 </listitem></varlistentry>
47080 <varlistentry>
47081 <term><emphasis role="bold">hosts&nbsp;=&nbsp;</emphasis>&lt;<emphasis>&nbsp;host&nbsp;list</emphasis>&gt;</term>
47082 <listitem>
47083 <para>
47084 <indexterm role="concept">
47085 <primary><option>hosts</option></primary>
47086 <secondary>ACL condition</secondary>
47087 </indexterm>
47088 <indexterm role="concept">
47089 <primary>host</primary>
47090 <secondary>ACL checking</secondary>
47091 </indexterm>
47092 <indexterm role="concept">
47093 <primary>access control lists (ACLs)</primary>
47094 <secondary>testing the client host</secondary>
47095 </indexterm>
47096 This condition tests that the calling host matches the host list. If you have
47097 name lookups or wildcarded host names and IP addresses in the same host list,
47098 you should normally put the IP addresses first. For example, you could have:
47099 </para>
47100 <literallayout class="monospaced">
47101 accept hosts = 10.9.8.7 : dbm;/etc/friendly/hosts
47102 </literallayout>
47103 <para>
47104 The reason for this lies in the left-to-right way that Exim processes lists.
47105 It can test IP addresses without doing any DNS lookups, but when it reaches an
47106 item that requires a host name, it fails if it cannot find a host name to
47107 compare with the pattern. If the above list is given in the opposite order, the
47108 <option>accept</option> statement fails for a host whose name cannot be found, even if its
47109 IP address is 10.9.8.7.
47110 </para>
47111 <para>
47112 If you really do want to do the name check first, and still recognize the IP
47113 address even if the name lookup fails, you can rewrite the ACL like this:
47114 </para>
47115 <literallayout class="monospaced">
47116 accept hosts = dbm;/etc/friendly/hosts
47117 accept hosts = 10.9.8.7
47118 </literallayout>
47119 <para>
47120 The default action on failing to find the host name is to assume that the host
47121 is not in the list, so the first <option>accept</option> statement fails. The second
47122 statement can then check the IP address.
47123 </para>
47124 <para>
47125 <indexterm role="concept">
47126 <primary><varname>$host_data</varname></primary>
47127 </indexterm>
47128 If a <option>hosts</option> condition is satisfied by means of a lookup, the result
47129 of the lookup is made available in the <varname>$host_data</varname> variable. This
47130 allows you, for example, to set up a statement like this:
47131 </para>
47132 <literallayout class="monospaced">
47133 deny  hosts = net-lsearch;/some/file
47134 message = $host_data
47135 </literallayout>
47136 <para>
47137 which gives a custom error message for each denied host.
47138 </para>
47139 </listitem></varlistentry>
47140 <varlistentry>
47141 <term><emphasis role="bold">local_parts&nbsp;=&nbsp;</emphasis>&lt;<emphasis>local&nbsp;part&nbsp;list</emphasis>&gt;</term>
47142 <listitem>
47143 <para>
47144 <indexterm role="concept">
47145 <primary><option>local_parts</option></primary>
47146 <secondary>ACL condition</secondary>
47147 </indexterm>
47148 <indexterm role="concept">
47149 <primary>local part</primary>
47150 <secondary>ACL checking</secondary>
47151 </indexterm>
47152 <indexterm role="concept">
47153 <primary>access control lists (ACLs)</primary>
47154 <secondary>testing a local part</secondary>
47155 </indexterm>
47156 <indexterm role="concept">
47157 <primary><varname>$local_part_data</varname></primary>
47158 </indexterm>
47159 This condition is relevant only after a RCPT command. It checks that the local
47160 part of the recipient address is in the list. If percent-hack processing is
47161 enabled, it is done before this test. If the check succeeds with a lookup, the
47162 result of the lookup is placed in <varname>$local_part_data</varname>, which remains set until
47163 the next <option>local_parts</option> test.
47164 </para>
47165 </listitem></varlistentry>
47166 <varlistentry>
47167 <term><emphasis role="bold">malware&nbsp;=&nbsp;</emphasis>&lt;<emphasis>option</emphasis>&gt;</term>
47168 <listitem>
47169 <para>
47170 <indexterm role="concept">
47171 <primary><option>malware</option></primary>
47172 <secondary>ACL condition</secondary>
47173 </indexterm>
47174 <indexterm role="concept">
47175 <primary>access control lists (ACLs)</primary>
47176 <secondary>virus scanning</secondary>
47177 </indexterm>
47178 <indexterm role="concept">
47179 <primary>access control lists (ACLs)</primary>
47180 <secondary>scanning for viruses</secondary>
47181 </indexterm>
47182 This condition is available only when Exim is compiled with the
47183 content-scanning extension. It causes the incoming message to be scanned for
47184 viruses. For details, see chapter <xref linkend="CHAPexiscan"/>.
47185 </para>
47186 </listitem></varlistentry>
47187 <varlistentry>
47188 <term><emphasis role="bold">mime_regex&nbsp;=&nbsp;</emphasis>&lt;<emphasis>list&nbsp;of&nbsp;regular&nbsp;expressions</emphasis>&gt;</term>
47189 <listitem>
47190 <para>
47191 <indexterm role="concept">
47192 <primary><option>mime_regex</option></primary>
47193 <secondary>ACL condition</secondary>
47194 </indexterm>
47195 <indexterm role="concept">
47196 <primary>access control lists (ACLs)</primary>
47197 <secondary>testing by regex matching</secondary>
47198 </indexterm>
47199 This condition is available only when Exim is compiled with the
47200 content-scanning extension, and it is allowed only the the ACL defined by
47201 <option>acl_smtp_mime</option>. It causes the current MIME part to be scanned for a match
47202 with any of the regular expressions. For details, see chapter
47203 <xref linkend="CHAPexiscan"/>.
47204 </para>
47205 </listitem></varlistentry>
47206 <varlistentry>
47207 <term><emphasis role="bold">ratelimit&nbsp;=&nbsp;</emphasis>&lt;<emphasis>parameters</emphasis>&gt;</term>
47208 <listitem>
47209 <para>
47210 <indexterm role="concept">
47211 <primary>rate limiting</primary>
47212 </indexterm>
47213 This condition can be used to limit the rate at which a user or host submits
47214 messages. Details are given in section <xref linkend="SECTratelimiting"/>.
47215 </para>
47216 </listitem></varlistentry>
47217 <varlistentry>
47218 <term><emphasis role="bold">recipients&nbsp;=&nbsp;</emphasis>&lt;<emphasis>address&nbsp;list</emphasis>&gt;</term>
47219 <listitem>
47220 <para>
47221 <indexterm role="concept">
47222 <primary><option>recipients</option></primary>
47223 <secondary>ACL condition</secondary>
47224 </indexterm>
47225 <indexterm role="concept">
47226 <primary>recipient</primary>
47227 <secondary>ACL checking</secondary>
47228 </indexterm>
47229 <indexterm role="concept">
47230 <primary>access control lists (ACLs)</primary>
47231 <secondary>testing a recipient</secondary>
47232 </indexterm>
47233 This condition is relevant only after a RCPT command. It checks the entire
47234 recipient address against a list of recipients.
47235 </para>
47236 </listitem></varlistentry>
47237 <varlistentry>
47238 <term><emphasis role="bold">regex&nbsp;=&nbsp;</emphasis>&lt;<emphasis>list&nbsp;of&nbsp;regular&nbsp;expressions</emphasis>&gt;</term>
47239 <listitem>
47240 <para>
47241 <indexterm role="concept">
47242 <primary><option>regex</option></primary>
47243 <secondary>ACL condition</secondary>
47244 </indexterm>
47245 <indexterm role="concept">
47246 <primary>access control lists (ACLs)</primary>
47247 <secondary>testing by regex matching</secondary>
47248 </indexterm>
47249 This condition is available only when Exim is compiled with the
47250 content-scanning extension, and is available only in the DATA, MIME, and
47251 non-SMTP ACLs. It causes the incoming message to be scanned for a match with
47252 any of the regular expressions. For details, see chapter <xref linkend="CHAPexiscan"/>.
47253 </para>
47254 </listitem></varlistentry>
47255 <varlistentry>
47256 <term><emphasis role="bold">sender_domains&nbsp;=&nbsp;</emphasis>&lt;<emphasis>domain&nbsp;list</emphasis>&gt;</term>
47257 <listitem>
47258 <para>
47259 <indexterm role="concept">
47260 <primary><option>sender_domains</option></primary>
47261 <secondary>ACL condition</secondary>
47262 </indexterm>
47263 <indexterm role="concept">
47264 <primary>sender</primary>
47265 <secondary>ACL checking</secondary>
47266 </indexterm>
47267 <indexterm role="concept">
47268 <primary>access control lists (ACLs)</primary>
47269 <secondary>testing a sender domain</secondary>
47270 </indexterm>
47271 <indexterm role="concept">
47272 <primary><varname>$domain</varname></primary>
47273 </indexterm>
47274 <indexterm role="concept">
47275 <primary><varname>$sender_address_domain</varname></primary>
47276 </indexterm>
47277 This condition tests the domain of the sender of the message against the given
47278 domain list. <emphasis role="bold">Note</emphasis>: The domain of the sender address is in
47279 <varname>$sender_address_domain</varname>. It is <emphasis>not</emphasis> put in <varname>$domain</varname> during the testing
47280 of this condition. This is an exception to the general rule for testing domain
47281 lists. It is done this way so that, if this condition is used in an ACL for a
47282 RCPT command, the recipient&#x2019;s domain (which is in <varname>$domain</varname>) can be used to
47283 influence the sender checking.
47284 </para>
47285 <para>
47286 <emphasis role="bold">Warning</emphasis>: It is a bad idea to use this condition on its own as a control on
47287 relaying, because sender addresses are easily, and commonly, forged.
47288 </para>
47289 </listitem></varlistentry>
47290 <varlistentry>
47291 <term><emphasis role="bold">senders&nbsp;=&nbsp;</emphasis>&lt;<emphasis>address&nbsp;list</emphasis>&gt;</term>
47292 <listitem>
47293 <para>
47294 <indexterm role="concept">
47295 <primary><option>senders</option></primary>
47296 <secondary>ACL condition</secondary>
47297 </indexterm>
47298 <indexterm role="concept">
47299 <primary>sender</primary>
47300 <secondary>ACL checking</secondary>
47301 </indexterm>
47302 <indexterm role="concept">
47303 <primary>access control lists (ACLs)</primary>
47304 <secondary>testing a sender</secondary>
47305 </indexterm>
47306 This condition tests the sender of the message against the given list. To test
47307 for a bounce message, which has an empty sender, set
47308 </para>
47309 <literallayout class="monospaced">
47310 senders = :
47311 </literallayout>
47312 <para>
47313 <emphasis role="bold">Warning</emphasis>: It is a bad idea to use this condition on its own as a control on
47314 relaying, because sender addresses are easily, and commonly, forged.
47315 </para>
47316 </listitem></varlistentry>
47317 <varlistentry>
47318 <term><emphasis role="bold">spam&nbsp;=&nbsp;</emphasis>&lt;<emphasis>username</emphasis>&gt;</term>
47319 <listitem>
47320 <para>
47321 <indexterm role="concept">
47322 <primary><option>spam</option></primary>
47323 <secondary>ACL condition</secondary>
47324 </indexterm>
47325 <indexterm role="concept">
47326 <primary>access control lists (ACLs)</primary>
47327 <secondary>scanning for spam</secondary>
47328 </indexterm>
47329 This condition is available only when Exim is compiled with the
47330 content-scanning extension. It causes the incoming message to be scanned by
47331 SpamAssassin. For details, see chapter <xref linkend="CHAPexiscan"/>.
47332 </para>
47333 </listitem></varlistentry>
47334 <varlistentry>
47335 <term><emphasis role="bold">verify&nbsp;=&nbsp;certificate</emphasis></term>
47336 <listitem>
47337 <para>
47338 <indexterm role="concept">
47339 <primary><option>verify</option></primary>
47340 <secondary>ACL condition</secondary>
47341 </indexterm>
47342 <indexterm role="concept">
47343 <primary>TLS</primary>
47344 <secondary>client certificate verification</secondary>
47345 </indexterm>
47346 <indexterm role="concept">
47347 <primary>certificate</primary>
47348 <secondary>verification of client</secondary>
47349 </indexterm>
47350 <indexterm role="concept">
47351 <primary>access control lists (ACLs)</primary>
47352 <secondary>certificate verification</secondary>
47353 </indexterm>
47354 <indexterm role="concept">
47355 <primary>access control lists (ACLs)</primary>
47356 <secondary>testing a TLS certificate</secondary>
47357 </indexterm>
47358 This condition is true in an SMTP session if the session is encrypted, and a
47359 certificate was received from the client, and the certificate was verified. The
47360 server requests a certificate only if the client matches <option>tls_verify_hosts</option>
47361 or <option>tls_try_verify_hosts</option> (see chapter <xref linkend="CHAPTLS"/>).
47362 </para>
47363 </listitem></varlistentry>
47364 <varlistentry>
47365 <term><emphasis role="bold">verify&nbsp;=&nbsp;csa</emphasis></term>
47366 <listitem>
47367 <para>
47368 <indexterm role="concept">
47369 <primary>CSA verification</primary>
47370 </indexterm>
47371 This condition checks whether the sending host (the client) is authorized to
47372 send email. Details of how this works are given in section
47373 <xref linkend="SECTverifyCSA"/>.
47374 </para>
47375 </listitem></varlistentry>
47376 <varlistentry>
47377 <term><emphasis role="bold">verify&nbsp;=&nbsp;header_sender/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
47378 <listitem>
47379 <para>
47380 <indexterm role="concept">
47381 <primary><option>verify</option></primary>
47382 <secondary>ACL condition</secondary>
47383 </indexterm>
47384 <indexterm role="concept">
47385 <primary>access control lists (ACLs)</primary>
47386 <secondary>verifying sender in the header</secondary>
47387 </indexterm>
47388 <indexterm role="concept">
47389 <primary>header lines</primary>
47390 <secondary>verifying the sender in</secondary>
47391 </indexterm>
47392 <indexterm role="concept">
47393 <primary>sender</primary>
47394 <secondary>verifying in header</secondary>
47395 </indexterm>
47396 <indexterm role="concept">
47397 <primary>verifying</primary>
47398 <secondary>sender in header</secondary>
47399 </indexterm>
47400 This condition is relevant only in an ACL that is run after a message has been
47401 received, that is, in an ACL specified by <option>acl_smtp_data</option> or
47402 <option>acl_not_smtp</option>. It checks that there is a verifiable address in at least one
47403 of the <emphasis>Sender:</emphasis>, <emphasis>Reply-To:</emphasis>, or <emphasis>From:</emphasis> header lines. Such an address
47404 is loosely thought of as a <quote>sender</quote> address (hence the name of the test).
47405 However, an address that appears in one of these headers need not be an address
47406 that accepts bounce messages; only sender addresses in envelopes are required
47407 to accept bounces. Therefore, if you use the callout option on this check, you
47408 might want to arrange for a non-empty address in the MAIL command.
47409 </para>
47410 <para>
47411 Details of address verification and the options are given later, starting at
47412 section <xref linkend="SECTaddressverification"/> (callouts are described in section
47413 <xref linkend="SECTcallver"/>). You can combine this condition with the <option>senders</option>
47414 condition to restrict it to bounce messages only:
47415 </para>
47416 <literallayout class="monospaced">
47417 deny    senders = :
47418         message = A valid sender header is required for bounces
47419        !verify  = header_sender
47420 </literallayout>
47421 </listitem></varlistentry>
47422 <varlistentry>
47423 <term><emphasis role="bold">verify&nbsp;=&nbsp;header_syntax</emphasis></term>
47424 <listitem>
47425 <para>
47426 <indexterm role="concept">
47427 <primary><option>verify</option></primary>
47428 <secondary>ACL condition</secondary>
47429 </indexterm>
47430 <indexterm role="concept">
47431 <primary>access control lists (ACLs)</primary>
47432 <secondary>verifying header syntax</secondary>
47433 </indexterm>
47434 <indexterm role="concept">
47435 <primary>header lines</primary>
47436 <secondary>verifying syntax</secondary>
47437 </indexterm>
47438 <indexterm role="concept">
47439 <primary>verifying</primary>
47440 <secondary>header syntax</secondary>
47441 </indexterm>
47442 This condition is relevant only in an ACL that is run after a message has been
47443 received, that is, in an ACL specified by <option>acl_smtp_data</option> or
47444 <option>acl_not_smtp</option>. It checks the syntax of all header lines that can contain
47445 lists of addresses (<emphasis>Sender:</emphasis>, <emphasis>From:</emphasis>, <emphasis>Reply-To:</emphasis>, <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>,
47446 and <emphasis>Bcc:</emphasis>). Unqualified addresses (local parts without domains) are
47447 permitted only in locally generated messages and from hosts that match
47448 <option>sender_unqualified_hosts</option> or <option>recipient_unqualified_hosts</option>, as
47449 appropriate.
47450 </para>
47451 <para>
47452 Note that this condition is a syntax check only. However, a common spamming
47453 ploy used to be to send syntactically invalid headers such as
47454 </para>
47455 <literallayout class="monospaced">
47456 To: @
47457 </literallayout>
47458 <para>
47459 and this condition can be used to reject such messages, though they are not as
47460 common as they used to be.
47461 </para>
47462 </listitem></varlistentry>
47463 <varlistentry>
47464 <term><emphasis role="bold">verify&nbsp;=&nbsp;helo</emphasis></term>
47465 <listitem>
47466 <para>
47467 <indexterm role="concept">
47468 <primary><option>verify</option></primary>
47469 <secondary>ACL condition</secondary>
47470 </indexterm>
47471 <indexterm role="concept">
47472 <primary>access control lists (ACLs)</primary>
47473 <secondary>verifying HELO/EHLO</secondary>
47474 </indexterm>
47475 <indexterm role="concept">
47476 <primary>HELO</primary>
47477 <secondary>verifying</secondary>
47478 </indexterm>
47479 <indexterm role="concept">
47480 <primary>EHLO</primary>
47481 <secondary>verifying</secondary>
47482 </indexterm>
47483 <indexterm role="concept">
47484 <primary>verifying</primary>
47485 <secondary>EHLO</secondary>
47486 </indexterm>
47487 <indexterm role="concept">
47488 <primary>verifying</primary>
47489 <secondary>HELO</secondary>
47490 </indexterm>
47491 This condition is true if a HELO or EHLO command has been received from the
47492 client host, and its contents have been verified. It there has been no previous
47493 attempt to verify the the HELO/EHLO contents, it is carried out when this
47494 condition is encountered. See the description of the <option>helo_verify_hosts</option> and
47495 <option>helo_try_verify_hosts</option> options for details of how to request verification
47496 independently of this condition.
47497 </para>
47498 </listitem></varlistentry>
47499 <varlistentry>
47500 <term><emphasis role="bold">verify&nbsp;=&nbsp;not_blind</emphasis></term>
47501 <listitem>
47502 <para>
47503 <indexterm role="concept">
47504 <primary>verifying</primary>
47505 <secondary>not blind</secondary>
47506 </indexterm>
47507 <indexterm role="concept">
47508 <primary>bcc recipients</primary>
47509 <secondary>verifying none</secondary>
47510 </indexterm>
47511 This condition checks that there are no blind (bcc) recipients in the message.
47512 Every envelope recipient must appear either in a <emphasis>To:</emphasis> header line or in a
47513 <emphasis>Cc:</emphasis> header line for this condition to be true. Local parts are checked
47514 case-sensitively; domains are checked case-insensitively. If <emphasis>Resent-To:</emphasis> or
47515 <emphasis>Resent-Cc:</emphasis> header lines exist, they are also checked. This condition can be
47516 used only in a DATA or non-SMTP ACL.
47517 </para>
47518 <para>
47519 There are, of course, many legitimate messages that make use of blind (bcc)
47520 recipients. This check should not be used on its own for blocking messages.
47521 </para>
47522 </listitem></varlistentry>
47523 <varlistentry>
47524 <term><emphasis role="bold">verify&nbsp;=&nbsp;recipient/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
47525 <listitem>
47526 <para>
47527 <indexterm role="concept">
47528 <primary><option>verify</option></primary>
47529 <secondary>ACL condition</secondary>
47530 </indexterm>
47531 <indexterm role="concept">
47532 <primary>access control lists (ACLs)</primary>
47533 <secondary>verifying recipient</secondary>
47534 </indexterm>
47535 <indexterm role="concept">
47536 <primary>recipient</primary>
47537 <secondary>verifying</secondary>
47538 </indexterm>
47539 <indexterm role="concept">
47540 <primary>verifying</primary>
47541 <secondary>recipient</secondary>
47542 </indexterm>
47543 <indexterm role="concept">
47544 <primary><varname>$address_data</varname></primary>
47545 </indexterm>
47546 This condition is relevant only after a RCPT command. It verifies the current
47547 recipient. Details of address verification are given later, starting at section
47548 <xref linkend="SECTaddressverification"/>. After a recipient has been verified, the value
47549 of <varname>$address_data</varname> is the last value that was set while routing the address.
47550 This applies even if the verification fails. When an address that is being
47551 verified is redirected to a single address, verification continues with the new
47552 address, and in that case, the subsequent value of <varname>$address_data</varname> is the
47553 value for the child address.
47554 </para>
47555 </listitem></varlistentry>
47556 <varlistentry>
47557 <term><emphasis role="bold">verify&nbsp;=&nbsp;reverse_host_lookup</emphasis></term>
47558 <listitem>
47559 <para>
47560 <indexterm role="concept">
47561 <primary><option>verify</option></primary>
47562 <secondary>ACL condition</secondary>
47563 </indexterm>
47564 <indexterm role="concept">
47565 <primary>access control lists (ACLs)</primary>
47566 <secondary>verifying host reverse lookup</secondary>
47567 </indexterm>
47568 <indexterm role="concept">
47569 <primary>host</primary>
47570 <secondary>verifying reverse lookup</secondary>
47571 </indexterm>
47572 This condition ensures that a verified host name has been looked up from the IP
47573 address of the client host. (This may have happened already if the host name
47574 was needed for checking a host list, or if the host matched <option>host_lookup</option>.)
47575 Verification ensures that the host name obtained from a reverse DNS lookup, or
47576 one of its aliases, does, when it is itself looked up in the DNS, yield the
47577 original IP address.
47578 </para>
47579 <para>
47580 If this condition is used for a locally generated message (that is, when there
47581 is no client host involved), it always succeeds.
47582 </para>
47583 </listitem></varlistentry>
47584 <varlistentry>
47585 <term><emphasis role="bold">verify&nbsp;=&nbsp;sender/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
47586 <listitem>
47587 <para>
47588 <indexterm role="concept">
47589 <primary><option>verify</option></primary>
47590 <secondary>ACL condition</secondary>
47591 </indexterm>
47592 <indexterm role="concept">
47593 <primary>access control lists (ACLs)</primary>
47594 <secondary>verifying sender</secondary>
47595 </indexterm>
47596 <indexterm role="concept">
47597 <primary>sender</primary>
47598 <secondary>verifying</secondary>
47599 </indexterm>
47600 <indexterm role="concept">
47601 <primary>verifying</primary>
47602 <secondary>sender</secondary>
47603 </indexterm>
47604 This condition is relevant only after a MAIL or RCPT command, or after a
47605 message has been received (the <option>acl_smtp_data</option> or <option>acl_not_smtp</option> ACLs). If
47606 the message&#x2019;s sender is empty (that is, this is a bounce message), the
47607 condition is true. Otherwise, the sender address is verified.
47608 </para>
47609 <para>
47610 <indexterm role="concept">
47611 <primary><varname>$address_data</varname></primary>
47612 </indexterm>
47613 <indexterm role="concept">
47614 <primary><varname>$sender_address_data</varname></primary>
47615 </indexterm>
47616 If there is data in the <varname>$address_data</varname> variable at the end of routing, its
47617 value is placed in <varname>$sender_address_data</varname> at the end of verification. This
47618 value can be used in subsequent conditions and modifiers in the same ACL
47619 statement. It does not persist after the end of the current statement. If you
47620 want to preserve the value for longer, you can save it in an ACL variable.
47621 </para>
47622 <para>
47623 Details of verification are given later, starting at section
47624 <xref linkend="SECTaddressverification"/>. Exim caches the result of sender verification,
47625 to avoid doing it more than once per message.
47626 </para>
47627 </listitem></varlistentry>
47628 <varlistentry>
47629 <term><emphasis role="bold">verify&nbsp;=&nbsp;sender=</emphasis>&lt;<emphasis>address</emphasis>&gt;<emphasis role="bold">/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
47630 <listitem>
47631 <para>
47632 <indexterm role="concept">
47633 <primary><option>verify</option></primary>
47634 <secondary>ACL condition</secondary>
47635 </indexterm>
47636 This is a variation of the previous option, in which a modified address is
47637 verified as a sender.
47638 </para>
47639 </listitem></varlistentry>
47640 </variablelist>
47641 </section>
47642 <section id="SECTmorednslists">
47643 <title>Using DNS lists</title>
47644 <para>
47645 <indexterm role="concept">
47646 <primary>DNS list</primary>
47647 <secondary>in ACL</secondary>
47648 </indexterm>
47649 <indexterm role="concept">
47650 <primary>black list (DNS)</primary>
47651 </indexterm>
47652 <indexterm role="concept">
47653 <primary>access control lists (ACLs)</primary>
47654 <secondary>testing a DNS list</secondary>
47655 </indexterm>
47656 In its simplest form, the <option>dnslists</option> condition tests whether the calling host
47657 is on at least one of a number of DNS lists by looking up the inverted IP
47658 address in one or more DNS domains. For example, if the calling host&#x2019;s IP
47659 address is 192.168.62.43, and the ACL statement is
47660 </para>
47661 <literallayout class="monospaced">
47662 deny dnslists = blackholes.mail-abuse.org : \
47663                 dialups.mail-abuse.org
47664 </literallayout>
47665 <para>
47666 the following records are looked up:
47667 </para>
47668 <literallayout class="monospaced">
47669 43.62.168.192.blackholes.mail-abuse.org
47670 43.62.168.192.dialups.mail-abuse.org
47671 </literallayout>
47672 <para>
47673 As soon as Exim finds an existing DNS record, processing of the list stops.
47674 Thus, multiple entries on the list provide an <quote>or</quote> conjunction. If you want
47675 to test that a host is on more than one list (an <quote>and</quote> conjunction), you can
47676 use two separate conditions:
47677 </para>
47678 <literallayout class="monospaced">
47679 deny dnslists = blackholes.mail-abuse.org
47680      dnslists = dialups.mail-abuse.org
47681 </literallayout>
47682 <para>
47683 If a DNS lookup times out or otherwise fails to give a decisive answer, Exim
47684 behaves as if the host does not match the list item, that is, as if the DNS
47685 record does not exist. If there are further items in the DNS list, they are
47686 processed.
47687 </para>
47688 <para>
47689 This is usually the required action when <option>dnslists</option> is used with <option>deny</option>
47690 (which is the most common usage), because it prevents a DNS failure from
47691 blocking mail. However, you can change this behaviour by putting one of the
47692 following special items in the list:
47693 </para>
47694 <literallayout>
47695 <literal>+include_unknown </literal>   behave as if the item is on the list
47696 <literal>+exclude_unknown </literal>   behave as if the item is not on the list (default)
47697 <literal>+defer_unknown   </literal>   give a temporary error
47698 </literallayout>
47699 <para>
47700 <indexterm role="concept">
47701 <primary><literal>+include_unknown</literal></primary>
47702 </indexterm>
47703 <indexterm role="concept">
47704 <primary><literal>+exclude_unknown</literal></primary>
47705 </indexterm>
47706 <indexterm role="concept">
47707 <primary><literal>+defer_unknown</literal></primary>
47708 </indexterm>
47709 Each of these applies to any subsequent items on the list. For example:
47710 </para>
47711 <literallayout class="monospaced">
47712 deny dnslists = +defer_unknown : foo.bar.example
47713 </literallayout>
47714 <para>
47715 Testing the list of domains stops as soon as a match is found. If you want to
47716 warn for one list and block for another, you can use two different statements:
47717 </para>
47718 <literallayout class="monospaced">
47719 deny  dnslists = blackholes.mail-abuse.org
47720 warn  message  = X-Warn: sending host is on dialups list
47721       dnslists = dialups.mail-abuse.org
47722 </literallayout>
47723 <para>
47724 DNS list lookups are cached by Exim for the duration of the SMTP session,
47725 so a lookup based on the IP address is done at most once for any incoming
47726 connection. Exim does not share information between multiple incoming
47727 connections (but your local name server cache should be active).
47728 </para>
47729 </section>
47730 <section>
47731 <title>Specifying the IP address for a DNS list lookup</title>
47732 <para>
47733 <indexterm role="concept">
47734 <primary>DNS list</primary>
47735 <secondary>keyed by explicit IP address</secondary>
47736 </indexterm>
47737 By default, the IP address that is used in a DNS list lookup is the IP address
47738 of the calling host. However, you can specify another IP address by listing it
47739 after the domain name, introduced by a slash. For example:
47740 </para>
47741 <literallayout class="monospaced">
47742 deny dnslists = black.list.tld/192.168.1.2
47743 </literallayout>
47744 <para>
47745 This feature is not very helpful with explicit IP addresses; it is intended for
47746 use with IP addresses that are looked up, for example, the IP addresses of the
47747 MX hosts or nameservers of an email sender address. For an example, see section
47748 <xref linkend="SECTmulkeyfor"/> below.
47749 </para>
47750 </section>
47751 <section>
47752 <title>DNS lists keyed on domain names</title>
47753 <para>
47754 <indexterm role="concept">
47755 <primary>DNS list</primary>
47756 <secondary>keyed by domain name</secondary>
47757 </indexterm>
47758 There are some lists that are keyed on domain names rather than inverted IP
47759 addresses (see for example the <emphasis>domain based zones</emphasis> link at
47760 <emphasis role="bold"><ulink url="http://www.rfc-ignorant.org/">http://www.rfc-ignorant.org/</ulink></emphasis>). No reversing of components is used
47761 with these lists. You can change the name that is looked up in a DNS list by
47762 listing it after the domain name, introduced by a slash. For example,
47763 </para>
47764 <literallayout class="monospaced">
47765 deny  message  = Sender's domain is listed at $dnslist_domain
47766       dnslists = dsn.rfc-ignorant.org/$sender_address_domain
47767 </literallayout>
47768 <para>
47769 This particular example is useful only in ACLs that are obeyed after the
47770 RCPT or DATA commands, when a sender address is available. If (for
47771 example) the message&#x2019;s sender is <emphasis>user@tld.example</emphasis> the name that is looked
47772 up by this example is
47773 </para>
47774 <literallayout class="monospaced">
47775 tld.example.dsn.rfc-ignorant.org
47776 </literallayout>
47777 <para>
47778 A single <option>dnslists</option> condition can contain entries for both names and IP
47779 addresses. For example:
47780 </para>
47781 <literallayout class="monospaced">
47782 deny dnslists = sbl.spamhaus.org : \
47783                 dsn.rfc-ignorant.org/$sender_address_domain
47784 </literallayout>
47785 <para>
47786 The first item checks the sending host&#x2019;s IP address; the second checks a domain
47787 name. The whole condition is true if either of the DNS lookups succeeds.
47788 </para>
47789 </section>
47790 <section id="SECTmulkeyfor">
47791 <title>Multiple explicit keys for a DNS list</title>
47792 <para>
47793 <indexterm role="concept">
47794 <primary>DNS list</primary>
47795 <secondary>multiple keys for</secondary>
47796 </indexterm>
47797 The syntax described above for looking up explicitly-defined values (either
47798 names or IP addresses) in a DNS blacklist is a simplification. After the domain
47799 name for the DNS list, what follows the slash can in fact be a list of items.
47800 As with all lists in Exim, the default separator is a colon. However, because
47801 this is a sublist within the list of DNS blacklist domains, it is necessary
47802 either to double the separators like this:
47803 </para>
47804 <literallayout class="monospaced">
47805 dnslists = black.list.tld/name.1::name.2
47806 </literallayout>
47807 <para>
47808 or to change the separator character, like this:
47809 </para>
47810 <literallayout class="monospaced">
47811 dnslists = black.list.tld/&lt;;name.1;name.2
47812 </literallayout>
47813 <para>
47814 If an item in the list is an IP address, it is inverted before the DNS
47815 blacklist domain is appended. If it is not an IP address, no inversion
47816 occurs. Consider this condition:
47817 </para>
47818 <literallayout class="monospaced">
47819 dnslists = black.list.tld/&lt;;192.168.1.2;a.domain
47820 </literallayout>
47821 <para>
47822 The DNS lookups that occur are:
47823 </para>
47824 <literallayout class="monospaced">
47825 2.1.168.192.black.list.tld
47826 a.domain.black.list.tld
47827 </literallayout>
47828 <para>
47829 Once a DNS record has been found (that matches a specific IP return
47830 address, if specified &ndash; see section <xref linkend="SECTaddmatcon"/>), no further lookups
47831 are done. If there is a temporary DNS error, the rest of the sublist of domains
47832 or IP addresses is tried. A temporary error for the whole dnslists item occurs
47833 only if no other DNS lookup in this sublist succeeds. In other words, a
47834 successful lookup for any of the items in the sublist overrides a temporary
47835 error for a previous item.
47836 </para>
47837 <para>
47838 The ability to supply a list of items after the slash is in some sense just a
47839 syntactic convenience. These two examples have the same effect:
47840 </para>
47841 <literallayout class="monospaced">
47842 dnslists = black.list.tld/a.domain : black.list.tld/b.domain
47843 dnslists = black.list.tld/a.domain::b.domain
47844 </literallayout>
47845 <para>
47846 However, when the data for the list is obtained from a lookup, the second form
47847 is usually much more convenient. Consider this example:
47848 </para>
47849 <literallayout class="monospaced">
47850 deny message  = The mail servers for the domain \
47851                 $sender_address_domain \
47852                 are listed at $dnslist_domain ($dnslist_value); \
47853                 see $dnslist_text.
47854      dnslists = sbl.spamhaus.org/&lt;|${lookup dnsdb {&gt;|a=&lt;|\
47855                                    ${lookup dnsdb {&gt;|mxh=\
47856                                    $sender_address_domain} }} }
47857 </literallayout>
47858 <para>
47859 Note the use of <literal>&gt;|</literal> in the dnsdb lookup to specify the separator for
47860 multiple DNS records. The inner dnsdb lookup produces a list of MX hosts
47861 and the outer dnsdb lookup finds the IP addresses for these hosts. The result
47862 of expanding the condition might be something like this:
47863 </para>
47864 <literallayout class="monospaced">
47865 dnslists = sbl.spahmaus.org/&lt;|192.168.2.3|192.168.5.6|...
47866 </literallayout>
47867 <para>
47868 Thus, this example checks whether or not the IP addresses of the sender
47869 domain&#x2019;s mail servers are on the Spamhaus black list.
47870 </para>
47871 </section>
47872 <section>
47873 <title>Data returned by DNS lists</title>
47874 <para>
47875 <indexterm role="concept">
47876 <primary>DNS list</primary>
47877 <secondary>data returned from</secondary>
47878 </indexterm>
47879 DNS lists are constructed using address records in the DNS. The original RBL
47880 just used the address 127.0.0.1 on the right hand side of each record, but the
47881 RBL+ list and some other lists use a number of values with different meanings.
47882 The values used on the RBL+ list are:
47883 </para>
47884 <literallayout>
47885 127.1.0.1  RBL
47886 127.1.0.2  DUL
47887 127.1.0.3  DUL and RBL
47888 127.1.0.4  RSS
47889 127.1.0.5  RSS and RBL
47890 127.1.0.6  RSS and DUL
47891 127.1.0.7  RSS and DUL and RBL
47892 </literallayout>
47893 <para>
47894 Some DNS lists may return more than one address record.
47895 </para>
47896 </section>
47897 <section>
47898 <title>Variables set from DNS lists</title>
47899 <para>
47900 <indexterm role="concept">
47901 <primary>DNS list</primary>
47902 <secondary>variables set from</secondary>
47903 </indexterm>
47904 <indexterm role="concept">
47905 <primary><varname>$dnslist_domain</varname></primary>
47906 </indexterm>
47907 <indexterm role="concept">
47908 <primary><varname>$dnslist_text</varname></primary>
47909 </indexterm>
47910 <indexterm role="concept">
47911 <primary><varname>$dnslist_value</varname></primary>
47912 </indexterm>
47913 When an entry is found in a DNS list, the variable <varname>$dnslist_domain</varname>
47914 contains the name of the domain that matched, <varname>$dnslist_value</varname> contains the
47915 data from the entry, and <varname>$dnslist_text</varname> contains the contents of any
47916 associated TXT record. If more than one address record is returned by the DNS
47917 lookup, all the IP addresses are included in <varname>$dnslist_value</varname>, separated by
47918 commas and spaces.
47919 </para>
47920 <para>
47921 You can use these variables in <option>message</option> or <option>log_message</option> modifiers &ndash;
47922 although these appear before the condition in the ACL, they are not expanded
47923 until after it has failed. For example:
47924 </para>
47925 <literallayout class="monospaced">
47926 deny    hosts = !+local_networks
47927         message = $sender_host_address is listed \
47928                   at $dnslist_domain
47929         dnslists = rbl-plus.mail-abuse.example
47930 </literallayout>
47931 </section>
47932 <section id="SECTaddmatcon">
47933 <title>Additional matching conditions for DNS lists</title>
47934 <para>
47935 <indexterm role="concept">
47936 <primary>DNS list</primary>
47937 <secondary>matching specific returned data</secondary>
47938 </indexterm>
47939 You can add an equals sign and an IP address after a <option>dnslists</option> domain name
47940 in order to restrict its action to DNS records with a matching right hand side.
47941 For example,
47942 </para>
47943 <literallayout class="monospaced">
47944 deny dnslists = rblplus.mail-abuse.org=127.0.0.2
47945 </literallayout>
47946 <para>
47947 rejects only those hosts that yield 127.0.0.2. Without this additional data,
47948 any address record is considered to be a match. If more than one address record
47949 is found on the list, they are all checked for a matching right-hand side.
47950 </para>
47951 <para>
47952 More than one IP address may be given for checking, using a comma as a
47953 separator. These are alternatives &ndash; if any one of them matches, the
47954 <option>dnslists</option> condition is true. For example:
47955 </para>
47956 <literallayout class="monospaced">
47957 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
47958 </literallayout>
47959 <para>
47960 If you want to specify a constraining address list and also specify names or IP
47961 addresses to be looked up, the constraining address list must be specified
47962 first. For example:
47963 </para>
47964 <literallayout class="monospaced">
47965 deny dnslists = dsn.rfc-ignorant.org\
47966                 =127.0.0.2/$sender_address_domain
47967 </literallayout>
47968 <para>
47969 If the character <literal>&amp;</literal> is used instead of <literal>=</literal>, the comparison for each
47970 listed IP address is done by a bitwise <quote>and</quote> instead of by an equality test.
47971 In other words, the listed addresses are used as bit masks. The comparison is
47972 true if all the bits in the mask are present in the address that is being
47973 tested. For example:
47974 </para>
47975 <literallayout class="monospaced">
47976 dnslists = a.b.c&amp;0.0.0.3
47977 </literallayout>
47978 <para>
47979 matches if the address is <emphasis>x.x.x.</emphasis>3, <emphasis>x.x.x.</emphasis>7, <emphasis>x.x.x.</emphasis>11, etc. If you
47980 want to test whether one bit or another bit is present (as opposed to both
47981 being present), you must use multiple values. For example:
47982 </para>
47983 <literallayout class="monospaced">
47984 dnslists = a.b.c&amp;0.0.0.1,0.0.0.2
47985 </literallayout>
47986 <para>
47987 matches if the final component of the address is an odd number or two times
47988 an odd number.
47989 </para>
47990 </section>
47991 <section>
47992 <title>Negated DNS matching conditions</title>
47993 <para>
47994 You can supply a negative list of IP addresses as part of a <option>dnslists</option>
47995 condition. Whereas
47996 </para>
47997 <literallayout class="monospaced">
47998 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
47999 </literallayout>
48000 <para>
48001 means <quote>deny if the host is in the black list at the domain <emphasis>a.b.c</emphasis> and the
48002 IP address yielded by the list is either 127.0.0.2 or 127.0.0.3</quote>,
48003 </para>
48004 <literallayout class="monospaced">
48005 deny  dnslists = a.b.c!=127.0.0.2,127.0.0.3
48006 </literallayout>
48007 <para>
48008 means <quote>deny if the host is in the black list at the domain <emphasis>a.b.c</emphasis> and the
48009 IP address yielded by the list is not 127.0.0.2 and not 127.0.0.3</quote>. In other
48010 words, the result of the test is inverted if an exclamation mark appears before
48011 the <literal>=</literal> (or the <literal>&amp;</literal>) sign.
48012 </para>
48013 <para>
48014 <emphasis role="bold">Note</emphasis>: This kind of negation is not the same as negation in a domain,
48015 host, or address list (which is why the syntax is different).
48016 </para>
48017 <para>
48018 If you are using just one list, the negation syntax does not gain you much. The
48019 previous example is precisely equivalent to
48020 </para>
48021 <literallayout class="monospaced">
48022 deny  dnslists = a.b.c
48023      !dnslists = a.b.c=127.0.0.2,127.0.0.3
48024 </literallayout>
48025 <para>
48026 However, if you are using multiple lists, the negation syntax is clearer.
48027 Consider this example:
48028 </para>
48029 <literallayout class="monospaced">
48030 deny  dnslists = sbl.spamhaus.org : \
48031                  list.dsbl.org : \
48032                  dnsbl.njabl.org!=127.0.0.3 : \
48033                  relays.ordb.org
48034 </literallayout>
48035 <para>
48036 Using only positive lists, this would have to be:
48037 </para>
48038 <literallayout class="monospaced">
48039 deny  dnslists = sbl.spamhaus.org : \
48040                  list.dsbl.org
48041 deny  dnslists = dnsbl.njabl.org
48042      !dnslists = dnsbl.njabl.org=127.0.0.3
48043 deny  dnslists = relays.ordb.org
48044 </literallayout>
48045 <para>
48046 which is less clear, and harder to maintain.
48047 </para>
48048 </section>
48049 <section id="SECTmorednslistslast">
48050 <title>DNS lists and IPv6</title>
48051 <para>
48052 <indexterm role="concept">
48053 <primary>IPv6</primary>
48054 <secondary>DNS black lists</secondary>
48055 </indexterm>
48056 <indexterm role="concept">
48057 <primary>DNS list</primary>
48058 <secondary>IPv6 usage</secondary>
48059 </indexterm>
48060 If Exim is asked to do a dnslist lookup for an IPv6 address, it inverts it
48061 nibble by nibble. For example, if the calling host&#x2019;s IP address is
48062 3ffe:ffff:836f:0a00:000a:0800:200a:c031, Exim might look up
48063 </para>
48064 <literallayout class="monospaced">
48065 1.3.0.c.a.0.0.2.0.0.8.0.a.0.0.0.0.0.a.0.f.6.3.8.
48066   f.f.f.f.e.f.f.3.blackholes.mail-abuse.org
48067 </literallayout>
48068 <para>
48069 (split over two lines here to fit on the page). Unfortunately, some of the DNS
48070 lists contain wildcard records, intended for IPv4, that interact badly with
48071 IPv6. For example, the DNS entry
48072 </para>
48073 <literallayout class="monospaced">
48074 *.3.some.list.example.    A    127.0.0.1
48075 </literallayout>
48076 <para>
48077 is probably intended to put the entire 3.0.0.0/8 IPv4 network on the list.
48078 Unfortunately, it also matches the entire 3::/4 IPv6 network.
48079 </para>
48080 <para>
48081 You can exclude IPv6 addresses from DNS lookups by making use of a suitable
48082 <option>condition</option> condition, as in this example:
48083 </para>
48084 <literallayout class="monospaced">
48085 deny   condition = ${if isip4{$sender_host_address}}
48086        dnslists  = some.list.example
48087 </literallayout>
48088 </section>
48089 <section id="SECTratelimiting">
48090 <title>Rate limiting senders</title>
48091 <para>
48092 <indexterm role="concept">
48093 <primary>rate limiting</primary>
48094 <secondary>client sending</secondary>
48095 </indexterm>
48096 <indexterm role="concept">
48097 <primary>limiting client sending rates</primary>
48098 </indexterm>
48099 <indexterm role="option">
48100 <primary><option>smpt_ratelimit_*</option></primary>
48101 </indexterm>
48102 The <option>ratelimit</option> ACL condition can be used to measure and control the rate at
48103 which clients can send email. This is more powerful than the
48104 <option>smtp_ratelimit_*</option> options, because those options control the rate of
48105 commands in a single SMTP session only, whereas the <option>ratelimit</option> condition
48106 works across all connections (concurrent and sequential) from the same client
48107 host. The syntax of the <option>ratelimit</option> condition is:
48108 </para>
48109 <literallayout>
48110 <literal>ratelimit =</literal> &lt;<emphasis>m</emphasis>&gt; <literal>/</literal> &lt;<emphasis>p</emphasis>&gt; <literal>/</literal> &lt;<emphasis>options</emphasis>&gt; <literal>/</literal> &lt;<emphasis>key</emphasis>&gt;
48111 </literallayout>
48112 <para>
48113 If the average client sending rate is less than <emphasis>m</emphasis> messages per time
48114 period <emphasis>p</emphasis> then the condition is false; otherwise it is true.
48115 </para>
48116 <para>
48117 As a side-effect, the <option>ratelimit</option> condition sets the expansion variable
48118 <varname>$sender_rate</varname> to the client&#x2019;s computed rate, <varname>$sender_rate_limit</varname> to the
48119 configured value of <emphasis>m</emphasis>, and <varname>$sender_rate_period</varname> to the configured value
48120 of <emphasis>p</emphasis>.
48121 </para>
48122 <para>
48123 The parameter <emphasis>p</emphasis> is the smoothing time constant, in the form of an Exim
48124 time interval, for example, <literal>8h</literal> for eight hours. A larger time constant
48125 means that it takes Exim longer to forget a client&#x2019;s past behaviour. The
48126 parameter <emphasis>m</emphasis> is the maximum number of messages that a client is permitted to
48127 send in each time interval. It also specifies the number of messages permitted
48128 in a fast burst. By increasing both <emphasis>m</emphasis> and <emphasis>p</emphasis> but keeping <emphasis>m/p</emphasis>
48129 constant, you can allow a client to send more messages in a burst without
48130 changing its overall sending rate limit. Conversely, if <emphasis>m</emphasis> and <emphasis>p</emphasis> are
48131 both small, messages must be sent at an even rate.
48132 </para>
48133 <para>
48134 There is a script in <filename>util/ratelimit.pl</filename> which extracts sending rates from
48135 log files, to assist with choosing appropriate settings for <emphasis>m</emphasis> and <emphasis>p</emphasis>
48136 when deploying the <option>ratelimit</option> ACL condition. The script prints usage
48137 instructions when it is run with no arguments.
48138 </para>
48139 <para>
48140 The key is used to look up the data for calculating the client&#x2019;s average
48141 sending rate. This data is stored in a database maintained by Exim in its spool
48142 directory, alongside the retry and other hints databases. The default key is
48143 <varname>$sender_host_address</varname>, which applies the limit to each client host IP address.
48144 By changing the key you can change how Exim identifies clients for the purpose
48145 of ratelimiting. For example, to limit the sending rate of each authenticated
48146 user, independent of the computer they are sending from, set the key to
48147 <varname>$authenticated_id</varname>. You must ensure that the lookup key is meaningful; for
48148 example, <varname>$authenticated_id</varname> is only meaningful if the client has
48149 authenticated, and you can check with with the <option>authenticated</option> ACL condition.
48150 </para>
48151 <para>
48152 Internally, Exim includes the smoothing constant <emphasis>p</emphasis> and the options in the
48153 lookup key because they alter the meaning of the stored data. This is not true
48154 for the limit <emphasis>m</emphasis>, so you can alter the configured maximum rate and Exim will
48155 still remember clients&#x2019; past behaviour, but if you alter the other ratelimit
48156 parameters Exim forgets past behaviour.
48157 </para>
48158 <para>
48159 Each <option>ratelimit</option> condition can have up to two options. The first option
48160 specifies what Exim measures the rate of, and the second specifies how Exim
48161 handles excessively fast clients. The options are separated by a slash, like
48162 the other parameters.
48163 </para>
48164 <para>
48165 The <option>per_conn</option> option limits the client&#x2019;s connection rate.
48166 </para>
48167 <para>
48168 The <option>per_mail</option> option limits the client&#x2019;s rate of sending messages. This is
48169 the default if none of the <option>per_*</option> options is specified.
48170 </para>
48171 <para>
48172 The <option>per_byte</option> option limits the sender&#x2019;s email bandwidth. Note that it is
48173 best to use this option in the DATA ACL; if it is used in an earlier ACL it
48174 relies on the SIZE parameter on the MAIL command, which may be inaccurate or
48175 completely missing. You can follow the limit <emphasis>m</emphasis> in the configuration with K,
48176 M, or G to specify limits in kilobytes, megabytes, or gigabytes, respectively.
48177 </para>
48178 <para>
48179 The <option>per_cmd</option> option causes Exim to recompute the rate every time the
48180 condition is processed. This can be used to limit the SMTP command rate. The
48181 alias <option>per_rcpt</option> is provided for use in the RCPT ACL instead of <option>per_cmd</option>
48182 to make it clear that the effect is to limit the rate at which recipients are
48183 accepted. Note that in this case the rate limiting engine will see a message
48184 with many recipients as a large high-speed burst.
48185 </para>
48186 <para>
48187 If a client&#x2019;s average rate is greater than the maximum, the rate limiting
48188 engine can react in two possible ways, depending on the presence of the
48189 <option>strict</option> or <option>leaky</option> options. This is independent of the other
48190 counter-measures (such as rejecting the message) that may be specified by the
48191 rest of the ACL. The default mode is leaky, which avoids a sender&#x2019;s
48192 over-aggressive retry rate preventing it from getting any email through.
48193 </para>
48194 <para>
48195 The <option>strict</option> option means that the client&#x2019;s recorded rate is always updated.
48196 The effect of this is that Exim measures the client&#x2019;s average rate of attempts
48197 to send email, which can be much higher than the maximum. If the client is over
48198 the limit it will be subjected to counter-measures until it slows down below
48199 the maximum rate. The smoothing period determines the time it takes for a high
48200 sending rate to decay exponentially to 37% of its peak value, which means that
48201 you can work out the time (the number of smoothing periods) that a client is
48202 subjected to counter-measures after an over-limit burst with this formula:
48203 </para>
48204 <literallayout class="monospaced">
48205 ln(peakrate/maxrate)
48206 </literallayout>
48207 <para>
48208 The <option>leaky</option> option means that the client&#x2019;s recorded rate is not updated if it
48209 is above the limit. The effect of this is that Exim measures the client&#x2019;s
48210 average rate of successfully sent email, which cannot be greater than the
48211 maximum. If the client is over the limit it will suffer some counter-measures,
48212 but it will still be able to send email at the configured maximum rate,
48213 whatever the rate of its attempts. This is generally the better choice if you
48214 have clients that retry automatically.
48215 </para>
48216 <para>
48217 Exim&#x2019;s other ACL facilities are used to define what counter-measures are taken
48218 when the rate limit is exceeded. This might be anything from logging a warning
48219 (for example, while measuring existing sending rates in order to define
48220 policy), through time delays to slow down fast senders, up to rejecting the
48221 message. For example:
48222 </para>
48223 <literallayout class="monospaced">
48224 # Log all senders' rates
48225 warn
48226   ratelimit = 0 / 1h / strict
48227   log_message = Sender rate $sender_rate / $sender_rate_period
48228
48229 # Slow down fast senders; note the need to truncate $sender_rate
48230 # at the decimal point.
48231 warn
48232   ratelimit = 100 / 1h / per_rcpt / strict
48233   delay     = ${eval: ${sg{$sender_rate}{[.].*}{}} - \
48234                 $sender_rate_limit }s
48235
48236 # Keep authenticated users under control
48237 deny
48238   authenticated = *
48239   ratelimit = 100 / 1d / strict / $authenticated_id
48240
48241 # System-wide rate limit
48242 defer
48243   message = Sorry, too busy. Try again later.
48244   ratelimit = 10 / 1s / $primary_hostname
48245
48246 # Restrict incoming rate from each host, with a default
48247 # set using a macro and special cases looked up in a table.
48248 defer
48249   message = Sender rate exceeds $sender_rate_limit \
48250             messages per $sender_rate_period
48251   ratelimit = ${lookup {$sender_host_address} \
48252                 cdb {DB/ratelimits.cdb} \
48253                 {$value} {RATELIMIT} }
48254 </literallayout>
48255 <para>
48256 <emphasis role="bold">Warning</emphasis>: If you have a busy server with a lot of <option>ratelimit</option> tests,
48257 especially with the <option>per_rcpt</option> option, you may suffer from a performance
48258 bottleneck caused by locking on the ratelimit hints database. Apart from
48259 making your ACLs less complicated, you can reduce the problem by using a
48260 RAM disk for Exim&#x2019;s hints directory (usually <filename>/var/spool/exim/db/</filename>). However
48261 this means that Exim will lose its hints data after a reboot (including retry
48262 hints, the callout cache, and ratelimit data).
48263 </para>
48264 </section>
48265 <section id="SECTaddressverification">
48266 <title>Address verification</title>
48267 <para>
48268 <indexterm role="concept">
48269 <primary>verifying address</primary>
48270 <secondary>options for</secondary>
48271 </indexterm>
48272 <indexterm role="concept">
48273 <primary>policy control</primary>
48274 <secondary>address verification</secondary>
48275 </indexterm>
48276 Several of the <option>verify</option> conditions described in section
48277 <xref linkend="SECTaclconditions"/> cause addresses to be verified. These conditions can be
48278 followed by options that modify the verification process. The options are
48279 separated from the keyword and from each other by slashes, and some of them
48280 contain parameters. For example:
48281 </para>
48282 <literallayout class="monospaced">
48283 verify = sender/callout
48284 verify = recipient/defer_ok/callout=10s,defer_ok
48285 </literallayout>
48286 <para>
48287 The first stage of address verification, which always happens, is to run the
48288 address through the routers, in <quote>verify mode</quote>. Routers can detect the
48289 difference between verification and routing for delivery, and their actions can
48290 be varied by a number of generic options such as <option>verify</option> and <option>verify_only</option>
48291 (see chapter <xref linkend="CHAProutergeneric"/>). If routing fails, verification fails.
48292 The available options are as follows:
48293 </para>
48294 <itemizedlist>
48295 <listitem>
48296 <para>
48297 If the <option>callout</option> option is specified, successful routing to one or more
48298 remote hosts is followed by a <quote>callout</quote> to those hosts as an additional
48299 check. Callouts and their sub-options are discussed in the next section.
48300 </para>
48301 </listitem>
48302 <listitem>
48303 <para>
48304 If there is a defer error while doing verification routing, the ACL
48305 normally returns <quote>defer</quote>. However, if you include <option>defer_ok</option> in the
48306 options, the condition is forced to be true instead. Note that this is a main
48307 verification option as well as a suboption for callouts.
48308 </para>
48309 </listitem>
48310 <listitem>
48311 <para>
48312 The <option>no_details</option> option is covered in section <xref linkend="SECTsenaddver"/>, which
48313 discusses the reporting of sender address verification failures.
48314 </para>
48315 </listitem>
48316 <listitem>
48317 <para>
48318 The <option>success_on_redirect</option> option causes verification always to succeed
48319 immediately after a successful redirection. By default, if a redirection
48320 generates just one address, that address is also verified. See further
48321 discussion in section <xref linkend="SECTredirwhilveri"/>.
48322 </para>
48323 </listitem>
48324 </itemizedlist>
48325 <para>
48326 <indexterm role="concept">
48327 <primary>verifying address</primary>
48328 <secondary>differentiating failures</secondary>
48329 </indexterm>
48330 <indexterm role="concept">
48331 <primary><varname>$recipient_verify_failure</varname></primary>
48332 </indexterm>
48333 <indexterm role="concept">
48334 <primary><varname>$sender_verify_failure</varname></primary>
48335 </indexterm>
48336 <indexterm role="concept">
48337 <primary><varname>$acl_verify_message</varname></primary>
48338 </indexterm>
48339 After an address verification failure, <varname>$acl_verify_message</varname> contains the
48340 error message that is associated with the failure. It can be preserved by
48341 coding like this:
48342 </para>
48343 <literallayout class="monospaced">
48344 warn  !verify = sender
48345        set acl_m0 = $acl_verify_message
48346 </literallayout>
48347 <para>
48348 If you are writing your own custom rejection message or log message when
48349 denying access, you can use this variable to include information about the
48350 verification failure.
48351 </para>
48352 <para>
48353 In addition, <varname>$sender_verify_failure</varname> or <varname>$recipient_verify_failure</varname> (as
48354 appropriate) contains one of the following words:
48355 </para>
48356 <itemizedlist>
48357 <listitem>
48358 <para>
48359 <option>qualify</option>: The address was unqualified (no domain), and the message
48360 was neither local nor came from an exempted host.
48361 </para>
48362 </listitem>
48363 <listitem>
48364 <para>
48365 <option>route</option>: Routing failed.
48366 </para>
48367 </listitem>
48368 <listitem>
48369 <para>
48370 <option>mail</option>: Routing succeeded, and a callout was attempted; rejection
48371 occurred at or before the MAIL command (that is, on initial
48372 connection, HELO, or MAIL).
48373 </para>
48374 </listitem>
48375 <listitem>
48376 <para>
48377 <option>recipient</option>: The RCPT command in a callout was rejected.
48378 </para>
48379 </listitem>
48380 <listitem>
48381 <para>
48382 <option>postmaster</option>: The postmaster check in a callout was rejected.
48383 </para>
48384 </listitem>
48385 </itemizedlist>
48386 <para>
48387 The main use of these variables is expected to be to distinguish between
48388 rejections of MAIL and rejections of RCPT in callouts.
48389 </para>
48390 </section>
48391 <section id="SECTcallver">
48392 <title>Callout verification</title>
48393 <para>
48394 <indexterm role="concept">
48395 <primary>verifying address</primary>
48396 <secondary>by callout</secondary>
48397 </indexterm>
48398 <indexterm role="concept">
48399 <primary>callout</primary>
48400 <secondary>verification</secondary>
48401 </indexterm>
48402 <indexterm role="concept">
48403 <primary>SMTP</primary>
48404 <secondary>callout verification</secondary>
48405 </indexterm>
48406 For non-local addresses, routing verifies the domain, but is unable to do any
48407 checking of the local part. There are situations where some means of verifying
48408 the local part is desirable. One way this can be done is to make an SMTP
48409 <emphasis>callback</emphasis> to a delivery host for the sender address or a <emphasis>callforward</emphasis> to
48410 a subsequent host for a recipient address, to see if the host accepts the
48411 address. We use the term <emphasis>callout</emphasis> to cover both cases. Note that for a
48412 sender address, the callback is not to the client host that is trying to
48413 deliver the message, but to one of the hosts that accepts incoming mail for the
48414 sender&#x2019;s domain.
48415 </para>
48416 <para>
48417 Exim does not do callouts by default. If you want them to happen, you must
48418 request them by setting appropriate options on the <option>verify</option> condition, as
48419 described below. This facility should be used with care, because it can add a
48420 lot of resource usage to the cost of verifying an address. However, Exim does
48421 cache the results of callouts, which helps to reduce the cost. Details of
48422 caching are in section <xref linkend="SECTcallvercache"/>.
48423 </para>
48424 <para>
48425 Recipient callouts are usually used only between hosts that are controlled by
48426 the same administration. For example, a corporate gateway host could use
48427 callouts to check for valid recipients on an internal mailserver. A successful
48428 callout does not guarantee that a real delivery to the address would succeed;
48429 on the other hand, a failing callout does guarantee that a delivery would fail.
48430 </para>
48431 <para>
48432 If the <option>callout</option> option is present on a condition that verifies an address, a
48433 second stage of verification occurs if the address is successfully routed to
48434 one or more remote hosts. The usual case is routing by a <command>dnslookup</command> or a
48435 <command>manualroute</command> router, where the router specifies the hosts. However, if a
48436 router that does not set up hosts routes to an <command>smtp</command> transport with a
48437 <option>hosts</option> setting, the transport&#x2019;s hosts are used. If an <command>smtp</command> transport has
48438 <option>hosts_override</option> set, its hosts are always used, whether or not the router
48439 supplies a host list.
48440 </para>
48441 <para>
48442 The port that is used is taken from the transport, if it is specified and is a
48443 remote transport. (For routers that do verification only, no transport need be
48444 specified.) Otherwise, the default SMTP port is used. If a remote transport
48445 specifies an outgoing interface, this is used; otherwise the interface is not
48446 specified.
48447 </para>
48448 <para>
48449 For a sender callout check, Exim makes SMTP connections to the remote hosts, to
48450 test whether a bounce message could be delivered to the sender address. The
48451 following SMTP commands are sent:
48452 </para>
48453 <literallayout>
48454 <literal>HELO </literal>&lt;<emphasis>smtp active host name</emphasis>&gt;
48455 <literal>MAIL FROM:&lt;&gt;</literal>
48456 <literal>RCPT TO:</literal>&lt;<emphasis>the address to be tested</emphasis>&gt;
48457 <literal>QUIT</literal>
48458 </literallayout>
48459 <para>
48460 LHLO is used instead of HELO if the transport&#x2019;s <option>protocol</option> option is
48461 set to <quote>lmtp</quote>.
48462 </para>
48463 <para>
48464 A recipient callout check is similar. By default, it also uses an empty address
48465 for the sender. This default is chosen because most hosts do not make use of
48466 the sender address when verifying a recipient. Using the same address means
48467 that a single cache entry can be used for each recipient. Some sites, however,
48468 do make use of the sender address when verifying. These are catered for by the
48469 <option>use_sender</option> and <option>use_postmaster</option> options, described in the next section.
48470 </para>
48471 <para>
48472 If the response to the RCPT command is a 2<emphasis>xx</emphasis> code, the verification
48473 succeeds. If it is 5<emphasis>xx</emphasis>, the verification fails. For any other condition,
48474 Exim tries the next host, if any. If there is a problem with all the remote
48475 hosts, the ACL yields <quote>defer</quote>, unless the <option>defer_ok</option> parameter of the
48476 <option>callout</option> option is given, in which case the condition is forced to succeed.
48477 </para>
48478 </section>
48479 <section id="CALLaddparcall">
48480 <title>Additional parameters for callouts</title>
48481 <para>
48482 <indexterm role="concept">
48483 <primary>callout</primary>
48484 <secondary>additional parameters for</secondary>
48485 </indexterm>
48486 The <option>callout</option> option can be followed by an equals sign and a number of
48487 optional parameters, separated by commas. For example:
48488 </para>
48489 <literallayout class="monospaced">
48490 verify = recipient/callout=10s,defer_ok
48491 </literallayout>
48492 <para>
48493 The old syntax, which had <option>callout_defer_ok</option> and <option>check_postmaster</option> as
48494 separate verify options, is retained for backwards compatibility, but is now
48495 deprecated. The additional parameters for <option>callout</option> are as follows:
48496 </para>
48497 <variablelist>
48498 <varlistentry>
48499 <term>&lt;<emphasis>a&nbsp;time&nbsp;interval</emphasis>&gt;</term>
48500 <listitem>
48501 <para>
48502 <indexterm role="concept">
48503 <primary>callout timeout</primary>
48504 <secondary>specifying</secondary>
48505 </indexterm>
48506 This specifies the timeout that applies for the callout attempt to each host.
48507 For example:
48508 </para>
48509 <literallayout class="monospaced">
48510 verify = sender/callout=5s
48511 </literallayout>
48512 <para>
48513 The default is 30 seconds. The timeout is used for each response from the
48514 remote host. It is also used for the intial connection, unless overridden by
48515 the <option>connect</option> parameter.
48516 </para>
48517 </listitem></varlistentry>
48518 <varlistentry>
48519 <term><emphasis role="bold">connect&nbsp;=&nbsp;</emphasis>&lt;<emphasis>time&nbsp;interval</emphasis>&gt;</term>
48520 <listitem>
48521 <para>
48522 <indexterm role="concept">
48523 <primary>callout connection timeout</primary>
48524 <secondary>specifying</secondary>
48525 </indexterm>
48526 This parameter makes it possible to set a different (usually smaller) timeout
48527 for making the SMTP connection. For example:
48528 </para>
48529 <literallayout class="monospaced">
48530 verify = sender/callout=5s,connect=1s
48531 </literallayout>
48532 <para>
48533 If not specified, this timeout defaults to the general timeout value.
48534 </para>
48535 </listitem></varlistentry>
48536 <varlistentry>
48537 <term><emphasis role="bold">defer_ok</emphasis></term>
48538 <listitem>
48539 <para>
48540 <indexterm role="concept">
48541 <primary>callout defer</primary>
48542 <secondary>action on</secondary>
48543 </indexterm>
48544 When this parameter is present, failure to contact any host, or any other kind
48545 of temporary error, is treated as success by the ACL. However, the cache is not
48546 updated in this circumstance.
48547 </para>
48548 </listitem></varlistentry>
48549 <varlistentry>
48550 <term><emphasis role="bold">fullpostmaster</emphasis></term>
48551 <listitem>
48552 <para>
48553 <indexterm role="concept">
48554 <primary>callout</primary>
48555 <secondary>full postmaster check</secondary>
48556 </indexterm>
48557 This operates like the <option>postmaster</option> option (see below), but if the check for
48558 <emphasis>postmaster@domain</emphasis> fails, it tries just <emphasis>postmaster</emphasis>, without a domain, in
48559 accordance with the specification in RFC 2821. The RFC states that the
48560 unqualified address <emphasis>postmaster</emphasis> should be accepted.
48561 </para>
48562 </listitem></varlistentry>
48563 <varlistentry>
48564 <term><emphasis role="bold">mailfrom&nbsp;=&nbsp;</emphasis>&lt;<emphasis>email&nbsp;address</emphasis>&gt;</term>
48565 <listitem>
48566 <para>
48567 <indexterm role="concept">
48568 <primary>callout</primary>
48569 <secondary>sender when verifying header</secondary>
48570 </indexterm>
48571 When verifying addresses in header lines using the <option>header_sender</option>
48572 verification option, Exim behaves by default as if the addresses are envelope
48573 sender addresses from a message. Callout verification therefore tests to see
48574 whether a bounce message could be delivered, by using an empty address in the
48575 MAIL command. However, it is arguable that these addresses might never be used
48576 as envelope senders, and could therefore justifiably reject bounce messages
48577 (empty senders). The <option>mailfrom</option> callout parameter allows you to specify what
48578 address to use in the MAIL command. For example:
48579 </para>
48580 <literallayout class="monospaced">
48581 require  verify = header_sender/callout=mailfrom=abcd@x.y.z
48582 </literallayout>
48583 <para>
48584 This parameter is available only for the <option>header_sender</option> verification option.
48585 </para>
48586 </listitem></varlistentry>
48587 <varlistentry>
48588 <term><emphasis role="bold">maxwait&nbsp;=&nbsp;</emphasis>&lt;<emphasis>time&nbsp;interval</emphasis>&gt;</term>
48589 <listitem>
48590 <para>
48591 <indexterm role="concept">
48592 <primary>callout overall timeout</primary>
48593 <secondary>specifying</secondary>
48594 </indexterm>
48595 This parameter sets an overall timeout for performing a callout verification.
48596 For example:
48597 </para>
48598 <literallayout class="monospaced">
48599 verify = sender/callout=5s,maxwait=30s
48600 </literallayout>
48601 <para>
48602 This timeout defaults to four times the callout timeout for individual SMTP
48603 commands. The overall timeout applies when there is more than one host that can
48604 be tried. The timeout is checked before trying the next host. This prevents
48605 very long delays if there are a large number of hosts and all are timing out
48606 (for example, when network connections are timing out).
48607 </para>
48608 </listitem></varlistentry>
48609 <varlistentry>
48610 <term><emphasis role="bold">no_cache</emphasis></term>
48611 <listitem>
48612 <para>
48613 <indexterm role="concept">
48614 <primary>callout cache</primary>
48615 <secondary>suppressing</secondary>
48616 </indexterm>
48617 <indexterm role="concept">
48618 <primary>caching callout</primary>
48619 <secondary>suppressing</secondary>
48620 </indexterm>
48621 When this parameter is given, the callout cache is neither read nor updated.
48622 </para>
48623 </listitem></varlistentry>
48624 <varlistentry>
48625 <term><emphasis role="bold">postmaster</emphasis></term>
48626 <listitem>
48627 <para>
48628 <indexterm role="concept">
48629 <primary>callout</primary>
48630 <secondary>postmaster; checking</secondary>
48631 </indexterm>
48632 When this parameter is set, a sucessful callout check is followed by a similar
48633 check for the local part <emphasis>postmaster</emphasis> at the same domain. If this address is
48634 rejected, the callout fails (but see <option>fullpostmaster</option> above). The result of
48635 the postmaster check is recorded in a cache record; if it is a failure, this is
48636 used to fail subsequent callouts for the domain without a connection being
48637 made, until the cache record expires.
48638 </para>
48639 </listitem></varlistentry>
48640 <varlistentry>
48641 <term><emphasis role="bold">postmaster_mailfrom&nbsp;=&nbsp;</emphasis>&lt;<emphasis>email&nbsp;address</emphasis>&gt;</term>
48642 <listitem>
48643 <para>
48644 The postmaster check uses an empty sender in the MAIL command by default.
48645 You can use this parameter to do a postmaster check using a different address.
48646 For example:
48647 </para>
48648 <literallayout class="monospaced">
48649 require  verify = sender/callout=postmaster_mailfrom=abc@x.y.z
48650 </literallayout>
48651 <para>
48652 If both <option>postmaster</option> and <option>postmaster_mailfrom</option> are present, the rightmost
48653 one overrides. The <option>postmaster</option> parameter is equivalent to this example:
48654 </para>
48655 <literallayout class="monospaced">
48656 require  verify = sender/callout=postmaster_mailfrom=
48657 </literallayout>
48658 <para>
48659 <emphasis role="bold">Warning</emphasis>: The caching arrangements for postmaster checking do not take
48660 account of the sender address. It is assumed that either the empty address or
48661 a fixed non-empty address will be used. All that Exim remembers is that the
48662 postmaster check for the domain succeeded or failed.
48663 </para>
48664 </listitem></varlistentry>
48665 <varlistentry>
48666 <term><emphasis role="bold">random</emphasis></term>
48667 <listitem>
48668 <para>
48669 <indexterm role="concept">
48670 <primary>callout</primary>
48671 <secondary><quote>random</quote> check</secondary>
48672 </indexterm>
48673 When this parameter is set, before doing the normal callout check, Exim does a
48674 check for a <quote>random</quote> local part at the same domain. The local part is not
48675 really random &ndash; it is defined by the expansion of the option
48676 <option>callout_random_local_part</option>, which defaults to
48677 </para>
48678 <literallayout class="monospaced">
48679 $primary_host_name-$tod_epoch-testing
48680 </literallayout>
48681 <para>
48682 The idea here is to try to determine whether the remote host accepts all local
48683 parts without checking. If it does, there is no point in doing callouts for
48684 specific local parts. If the <quote>random</quote> check succeeds, the result is saved in
48685 a cache record, and used to force the current and subsequent callout checks to
48686 succeed without a connection being made, until the cache record expires.
48687 </para>
48688 </listitem></varlistentry>
48689 <varlistentry>
48690 <term><emphasis role="bold">use_postmaster</emphasis></term>
48691 <listitem>
48692 <para>
48693 <indexterm role="concept">
48694 <primary>callout</primary>
48695 <secondary>sender for recipient check</secondary>
48696 </indexterm>
48697 This parameter applies to recipient callouts only. For example:
48698 </para>
48699 <literallayout class="monospaced">
48700 deny  !verify = recipient/callout=use_postmaster
48701 </literallayout>
48702 <para>
48703 <indexterm role="concept">
48704 <primary><varname>$qualify_domain</varname></primary>
48705 </indexterm>
48706 It causes a non-empty postmaster address to be used in the MAIL command when
48707 performing the callout for the recipient, and also for a <quote>random</quote> check if
48708 that is configured. The local part of the address is <literal>postmaster</literal> and the
48709 domain is the contents of <varname>$qualify_domain</varname>.
48710 </para>
48711 </listitem></varlistentry>
48712 <varlistentry>
48713 <term><emphasis role="bold">use_sender</emphasis></term>
48714 <listitem>
48715 <para>
48716 This option applies to recipient callouts only. For example:
48717 </para>
48718 <literallayout class="monospaced">
48719 require  verify = recipient/callout=use_sender
48720 </literallayout>
48721 <para>
48722 It causes the message&#x2019;s actual sender address to be used in the MAIL
48723 command when performing the callout, instead of an empty address. There is no
48724 need to use this option unless you know that the called hosts make use of the
48725 sender when checking recipients. If used indiscriminately, it reduces the
48726 usefulness of callout caching.
48727 </para>
48728 </listitem></varlistentry>
48729 </variablelist>
48730 <para>
48731 If you use any of the parameters that set a non-empty sender for the MAIL
48732 command (<option>mailfrom</option>, <option>postmaster_mailfrom</option>, <option>use_postmaster</option>, or
48733 <option>use_sender</option>), you should think about possible loops. Recipient checking is
48734 usually done between two hosts that are under the same management, and the host
48735 that receives the callouts is not normally configured to do callouts itself.
48736 Therefore, it is normally safe to use <option>use_postmaster</option> or <option>use_sender</option> in
48737 these circumstances.
48738 </para>
48739 <para>
48740 However, if you use a non-empty sender address for a callout to an arbitrary
48741 host, there is the likelihood that the remote host will itself initiate a
48742 callout check back to your host. As it is checking what appears to be a message
48743 sender, it is likely to use an empty address in MAIL, thus avoiding a
48744 callout loop. However, to be on the safe side it would be best to set up your
48745 own ACLs so that they do not do sender verification checks when the recipient
48746 is the address you use for header sender or postmaster callout checking.
48747 </para>
48748 <para>
48749 Another issue to think about when using non-empty senders for callouts is
48750 caching. When you set <option>mailfrom</option> or <option>use_sender</option>, the cache record is keyed
48751 by the sender/recipient combination; thus, for any given recipient, many more
48752 actual callouts are performed than when an empty sender or postmaster is used.
48753 </para>
48754 </section>
48755 <section id="SECTcallvercache">
48756 <title>Callout caching</title>
48757 <para>
48758 <indexterm role="concept">
48759 <primary>hints database</primary>
48760 <secondary>callout cache</secondary>
48761 </indexterm>
48762 <indexterm role="concept">
48763 <primary>callout</primary>
48764 <secondary>caching</secondary>
48765 </indexterm>
48766 <indexterm role="concept">
48767 <primary>caching</primary>
48768 <secondary>callout</secondary>
48769 </indexterm>
48770 Exim caches the results of callouts in order to reduce the amount of resources
48771 used, unless you specify the <option>no_cache</option> parameter with the <option>callout</option>
48772 option. A hints database called <quote>callout</quote> is used for the cache. Two
48773 different record types are used: one records the result of a callout check for
48774 a specific address, and the other records information that applies to the
48775 entire domain (for example, that it accepts the local part <emphasis>postmaster</emphasis>).
48776 </para>
48777 <para>
48778 When an original callout fails, a detailed SMTP error message is given about
48779 the failure. However, for subsequent failures use the cache data, this message
48780 is not available.
48781 </para>
48782 <para>
48783 The expiry times for negative and positive address cache records are
48784 independent, and can be set by the global options <option>callout_negative_expire</option>
48785 (default 2h) and <option>callout_positive_expire</option> (default 24h), respectively.
48786 </para>
48787 <para>
48788 If a host gives a negative response to an SMTP connection, or rejects any
48789 commands up to and including
48790 </para>
48791 <literallayout class="monospaced">
48792 MAIL FROM:&lt;&gt;
48793 </literallayout>
48794 <para>
48795 (but not including the MAIL command with a non-empty address),
48796 any callout attempt is bound to fail. Exim remembers such failures in a
48797 domain cache record, which it uses to fail callouts for the domain without
48798 making new connections, until the domain record times out. There are two
48799 separate expiry times for domain cache records:
48800 <option>callout_domain_negative_expire</option> (default 3h) and
48801 <option>callout_domain_positive_expire</option> (default 7d).
48802 </para>
48803 <para>
48804 Domain records expire when the negative expiry time is reached if callouts
48805 cannot be made for the domain, or if the postmaster check failed.
48806 Otherwise, they expire when the positive expiry time is reached. This
48807 ensures that, for example, a host that stops accepting <quote>random</quote> local parts
48808 will eventually be noticed.
48809 </para>
48810 <para>
48811 The callout caching mechanism is based on the domain of the address that is
48812 being tested. If the domain routes to several hosts, it is assumed that their
48813 behaviour will be the same.
48814 </para>
48815 </section>
48816 <section id="SECTsenaddver">
48817 <title>Sender address verification reporting</title>
48818 <para>
48819 <indexterm role="concept">
48820 <primary>verifying</primary>
48821 <secondary>suppressing error details</secondary>
48822 </indexterm>
48823 When sender verification fails in an ACL, the details of the failure are
48824 given as additional output lines before the 550 response to the relevant
48825 SMTP command (RCPT or DATA). For example, if sender callout is in use,
48826 you might see:
48827 </para>
48828 <literallayout class="monospaced">
48829 MAIL FROM:&lt;xyz@abc.example&gt;
48830 250 OK
48831 RCPT TO:&lt;pqr@def.example&gt;
48832 550-Verification failed for &lt;xyz@abc.example&gt;
48833 550-Called:   192.168.34.43
48834 550-Sent:     RCPT TO:&lt;xyz@abc.example&gt;
48835 550-Response: 550 Unknown local part xyz in &lt;xyz@abc.example&gt;
48836 550 Sender verification failed
48837 </literallayout>
48838 <para>
48839 If more than one RCPT command fails in the same way, the details are given
48840 only for the first of them. However, some administrators do not want to send
48841 out this much information. You can suppress the details by adding
48842 <literal>/no_details</literal> to the ACL statement that requests sender verification. For
48843 example:
48844 </para>
48845 <literallayout class="monospaced">
48846 verify = sender/no_details
48847 </literallayout>
48848 </section>
48849 <section id="SECTredirwhilveri">
48850 <title>Redirection while verifying</title>
48851 <para>
48852 <indexterm role="concept">
48853 <primary>verifying</primary>
48854 <secondary>redirection while</secondary>
48855 </indexterm>
48856 <indexterm role="concept">
48857 <primary>address redirection</primary>
48858 <secondary>while verifying</secondary>
48859 </indexterm>
48860 A dilemma arises when a local address is redirected by aliasing or forwarding
48861 during verification: should the generated addresses themselves be verified,
48862 or should the successful expansion of the original address be enough to verify
48863 it? By default, Exim takes the following pragmatic approach:
48864 </para>
48865 <itemizedlist>
48866 <listitem>
48867 <para>
48868 When an incoming address is redirected to just one child address, verification
48869 continues with the child address, and if that fails to verify, the original
48870 verification also fails.
48871 </para>
48872 </listitem>
48873 <listitem>
48874 <para>
48875 When an incoming address is redirected to more than one child address,
48876 verification does not continue. A success result is returned.
48877 </para>
48878 </listitem>
48879 </itemizedlist>
48880 <para>
48881 This seems the most reasonable behaviour for the common use of aliasing as a
48882 way of redirecting different local parts to the same mailbox. It means, for
48883 example, that a pair of alias entries of the form
48884 </para>
48885 <literallayout class="monospaced">
48886 A.Wol:   aw123
48887 aw123:   :fail: Gone away, no forwarding address
48888 </literallayout>
48889 <para>
48890 work as expected, with both local parts causing verification failure. When a
48891 redirection generates more than one address, the behaviour is more like a
48892 mailing list, where the existence of the alias itself is sufficient for
48893 verification to succeed.
48894 </para>
48895 <para>
48896 It is possible, however, to change the default behaviour so that all successful
48897 redirections count as successful verifications, however many new addresses are
48898 generated. This is specified by the <option>success_on_redirect</option> verification
48899 option. For example:
48900 </para>
48901 <literallayout class="monospaced">
48902 require verify = recipient/success_on_redirect/callout=10s
48903 </literallayout>
48904 <para>
48905 In this example, verification succeeds if a router generates a new address, and
48906 the callout does not occur, because no address was routed to a remote host.
48907 </para>
48908 </section>
48909 <section id="SECTverifyCSA">
48910 <title>Client SMTP authorization (CSA)</title>
48911 <para>
48912 <indexterm role="concept">
48913 <primary>CSA</primary>
48914 <secondary>verifying</secondary>
48915 </indexterm>
48916 Client SMTP Authorization is a system that allows a site to advertise
48917 which machines are and are not permitted to send email. This is done by placing
48918 special SRV records in the DNS; these are looked up using the client&#x2019;s HELO
48919 domain. At the time of writing, CSA is still an Internet Draft. Client SMTP
48920 Authorization checks in Exim are performed by the ACL condition:
48921 </para>
48922 <literallayout class="monospaced">
48923 verify = csa
48924 </literallayout>
48925 <para>
48926 This fails if the client is not authorized. If there is a DNS problem, or if no
48927 valid CSA SRV record is found, or if the client is authorized, the condition
48928 succeeds. These three cases can be distinguished using the expansion variable
48929 <varname>$csa_status</varname>, which can take one of the values <quote>fail</quote>, <quote>defer</quote>,
48930 <quote>unknown</quote>, or <quote>ok</quote>. The condition does not itself defer because that would
48931 be likely to cause problems for legitimate email.
48932 </para>
48933 <para>
48934 The error messages produced by the CSA code include slightly more
48935 detail. If <varname>$csa_status</varname> is <quote>defer</quote>, this may be because of problems
48936 looking up the CSA SRV record, or problems looking up the CSA target
48937 address record. There are four reasons for <varname>$csa_status</varname> being <quote>fail</quote>:
48938 </para>
48939 <itemizedlist>
48940 <listitem>
48941 <para>
48942 The client&#x2019;s host name is explicitly not authorized.
48943 </para>
48944 </listitem>
48945 <listitem>
48946 <para>
48947 The client&#x2019;s IP address does not match any of the CSA target IP addresses.
48948 </para>
48949 </listitem>
48950 <listitem>
48951 <para>
48952 The client&#x2019;s host name is authorized but it has no valid target IP addresses
48953 (for example, the target&#x2019;s addresses are IPv6 and the client is using IPv4).
48954 </para>
48955 </listitem>
48956 <listitem>
48957 <para>
48958 The client&#x2019;s host name has no CSA SRV record but a parent domain has asserted
48959 that all subdomains must be explicitly authorized.
48960 </para>
48961 </listitem>
48962 </itemizedlist>
48963 <para>
48964 The <option>csa</option> verification condition can take an argument which is the domain to
48965 use for the DNS query. The default is:
48966 </para>
48967 <literallayout class="monospaced">
48968 verify = csa/$sender_helo_name
48969 </literallayout>
48970 <para>
48971 This implementation includes an extension to CSA. If the query domain
48972 is an address literal such as [192.0.2.95], or if it is a bare IP
48973 address, Exim searches for CSA SRV records in the reverse DNS as if
48974 the HELO domain was (for example) <emphasis>95.2.0.192.in-addr.arpa</emphasis>. Therefore it is
48975 meaningful to say:
48976 </para>
48977 <literallayout class="monospaced">
48978 verify = csa/$sender_host_address
48979 </literallayout>
48980 <para>
48981 In fact, this is the check that Exim performs if the client does not say HELO.
48982 This extension can be turned off by setting the main configuration option
48983 <option>dns_csa_use_reverse</option> to be false.
48984 </para>
48985 <para>
48986 If a CSA SRV record is not found for the domain itself, a search
48987 is performed through its parent domains for a record which might be
48988 making assertions about subdomains. The maximum depth of this search is limited
48989 using the main configuration option <option>dns_csa_search_limit</option>, which is 5 by
48990 default. Exim does not look for CSA SRV records in a top level domain, so the
48991 default settings handle HELO domains as long as seven
48992 (<emphasis>hostname.five.four.three.two.one.com</emphasis>). This encompasses the vast majority
48993 of legitimate HELO domains.
48994 </para>
48995 <para>
48996 The <emphasis>dnsdb</emphasis> lookup also has support for CSA. Although <emphasis>dnsdb</emphasis> also supports
48997 direct SRV lookups, this is not sufficient because of the extra parent domain
48998 search behaviour of CSA, and (as with PTR lookups) <emphasis>dnsdb</emphasis> also turns IP
48999 addresses into lookups in the reverse DNS space. The result of a successful
49000 lookup such as:
49001 </para>
49002 <literallayout class="monospaced">
49003 ${lookup dnsdb {csa=$sender_helo_name}}
49004 </literallayout>
49005 <para>
49006 has two space-separated fields: an authorization code and a target host name.
49007 The authorization code can be <quote>Y</quote> for yes, <quote>N</quote> for no, <quote>X</quote> for explicit
49008 authorization required but absent, or <quote>?</quote> for unknown.
49009 </para>
49010 </section>
49011 <section id="SECTverifyPRVS">
49012 <title>Bounce address tag validation</title>
49013 <para>
49014 <indexterm role="concept">
49015 <primary>BATV</primary>
49016 <secondary>verifying</secondary>
49017 </indexterm>
49018 Bounce address tag validation (BATV) is a scheme whereby the envelope senders
49019 of outgoing messages have a cryptographic, timestamped <quote>tag</quote> added to them.
49020 Genuine incoming bounce messages should therefore always be addressed to
49021 recipients that have a valid tag. This scheme is a way of detecting unwanted
49022 bounce messages caused by sender address forgeries (often called <quote>collateral
49023 spam</quote>), because the recipients of such messages do not include valid tags.
49024 </para>
49025 <para>
49026 There are two expansion items to help with the implementation of the BATV
49027 <quote>prvs</quote> (private signature) scheme in an Exim configuration. This scheme signs
49028 the original envelope sender address by using a simple shared key to add a hash
49029 of the address and some time-based randomizing information. The <option>prvs</option>
49030 expansion item creates a signed address, and the <option>prvscheck</option> expansion item
49031 checks one. The syntax of these expansion items is described in section
49032 <xref linkend="SECTexpansionitems"/>.
49033 </para>
49034 <para>
49035 As an example, suppose the secret per-address keys are stored in an MySQL
49036 database. A query to look up the key for an address could be defined as a macro
49037 like this:
49038 </para>
49039 <literallayout class="monospaced">
49040 PRVSCHECK_SQL = ${lookup mysql{SELECT secret FROM batv_prvs \
49041                 WHERE sender='${quote_mysql:$prvscheck_address}'\
49042                 }{$value}}
49043 </literallayout>
49044 <para>
49045 Suppose also that the senders who make use of BATV are defined by an address
49046 list called <option>batv_senders</option>. Then, in the ACL for RCPT commands, you could
49047 use this:
49048 </para>
49049 <literallayout class="monospaced">
49050 # Bounces: drop unsigned addresses for BATV senders
49051 deny message = This address does not send an unsigned reverse path.
49052      senders = :
49053      recipients = +batv_senders
49054
49055 # Bounces: In case of prvs-signed address, check signature.
49056 deny message = Invalid reverse path signature.
49057      senders = :
49058      condition  = ${prvscheck {$local_part@$domain}\
49059                   {PRVSCHECK_SQL}{1}}
49060      !condition = $prvscheck_result
49061 </literallayout>
49062 <para>
49063 The first statement rejects recipients for bounce messages that are addressed
49064 to plain BATV sender addresses, because it is known that BATV senders do not
49065 send out messages with plain sender addresses. The second statement rejects
49066 recipients that are prvs-signed, but with invalid signatures (either because
49067 the key is wrong, or the signature has timed out).
49068 </para>
49069 <para>
49070 A non-prvs-signed address is not rejected by the second statement, because the
49071 <option>prvscheck</option> expansion yields an empty string if its first argument is not a
49072 prvs-signed address, thus causing the <option>condition</option> condition to be false. If
49073 the first argument is a syntactically valid prvs-signed address, the yield is
49074 the third string (in this case <quote>1</quote>), whether or not the cryptographic and
49075 timeout checks succeed. The <varname>$prvscheck_result</varname> variable contains the result
49076 of the checks (empty for failure, <quote>1</quote> for success).
49077 </para>
49078 <para revisionflag="changed">
49079 There are two more issues you must consider when implementing prvs-signing.
49080 Firstly, you need to ensure that prvs-signed addresses are not blocked by your
49081 ACLs. A prvs-signed address contains a slash character, but the default Exim
49082 configuration contains this statement in the RCPT ACL:
49083 </para>
49084 <literallayout class="monospaced" revisionflag="changed">
49085 deny    message       = Restricted characters in address
49086         domains       = +local_domains
49087         local_parts   = ^[.] : ^.*[@%!/|]
49088 </literallayout>
49089 <para revisionflag="changed">
49090 This is a conservative rule that blocks local parts that contain slashes. You
49091 should remove the slash in the last line.
49092 </para>
49093 <para>
49094 Secondly, you have to ensure that the routers accept prvs-signed addresses and
49095 deliver them correctly. The easiest way to handle this is to use a <command>redirect</command>
49096 router to remove the signature with a configuration along these lines:
49097 </para>
49098 <literallayout class="monospaced">
49099 batv_redirect:
49100   driver = redirect
49101   data = ${prvscheck {$local_part@$domain}{PRVSCHECK_SQL}}
49102 </literallayout>
49103 <para>
49104 This works because, if the third argument of <option>prvscheck</option> is empty, the result
49105 of the expansion of a prvs-signed address is the decoded value of the original
49106 address. This router should probably be the first of your routers that handles
49107 local addresses.
49108 </para>
49109 <para>
49110 To create BATV-signed addresses in the first place, a transport of this form
49111 can be used:
49112 </para>
49113 <literallayout class="monospaced">
49114 external_smtp_batv:
49115   driver = smtp
49116   return_path = ${prvs {$return_path} \
49117                        {${lookup mysql{SELECT \
49118                        secret FROM batv_prvs WHERE \
49119                        sender='${quote_mysql:$sender_address}'} \
49120                        {$value}fail}}}
49121 </literallayout>
49122 <para>
49123 If no key can be found for the existing return path, no signing takes place.
49124 </para>
49125 </section>
49126 <section id="SECTrelaycontrol">
49127 <title>Using an ACL to control relaying</title>
49128 <para>
49129 <indexterm role="concept">
49130 <primary>access control lists (ACLs)</primary>
49131 <secondary>relay control</secondary>
49132 </indexterm>
49133 <indexterm role="concept">
49134 <primary>relaying</primary>
49135 <secondary>control by ACL</secondary>
49136 </indexterm>
49137 <indexterm role="concept">
49138 <primary>policy control</primary>
49139 <secondary>relay control</secondary>
49140 </indexterm>
49141 An MTA is said to <emphasis>relay</emphasis> a message if it receives it from some host and
49142 delivers it directly to another host as a result of a remote address contained
49143 within it. Redirecting a local address via an alias or forward file and then
49144 passing the message on to another host is not relaying,
49145 <indexterm role="concept">
49146 <primary><quote>percent hack</quote></primary>
49147 </indexterm>
49148 but a redirection as a result of the <quote>percent hack</quote> is.
49149 </para>
49150 <para>
49151 Two kinds of relaying exist, which are termed <quote>incoming</quote> and <quote>outgoing</quote>.
49152 A host which is acting as a gateway or an MX backup is concerned with incoming
49153 relaying from arbitrary hosts to a specific set of domains. On the other hand,
49154 a host which is acting as a smart host for a number of clients is concerned
49155 with outgoing relaying from those clients to the Internet at large. Often the
49156 same host is fulfilling both functions,
49157 but in principle these two kinds of relaying are entirely independent. What is
49158 not wanted is the transmission of mail from arbitrary remote hosts through your
49159 system to arbitrary domains.
49160 </para>
49161 <para>
49162 You can implement relay control by means of suitable statements in the ACL that
49163 runs for each RCPT command. For convenience, it is often easiest to use
49164 Exim&#x2019;s named list facility to define the domains and hosts involved. For
49165 example, suppose you want to do the following:
49166 </para>
49167 <itemizedlist>
49168 <listitem>
49169 <para>
49170 Deliver a number of domains to mailboxes on the local host (or process them
49171 locally in some other way). Let&#x2019;s say these are <emphasis>my.dom1.example</emphasis> and
49172 <emphasis>my.dom2.example</emphasis>.
49173 </para>
49174 </listitem>
49175 <listitem>
49176 <para>
49177 Relay mail for a number of other domains for which you are the secondary MX.
49178 These might be <emphasis>friend1.example</emphasis> and <emphasis>friend2.example</emphasis>.
49179 </para>
49180 </listitem>
49181 <listitem>
49182 <para>
49183 Relay mail from the hosts on your local LAN, to whatever domains are involved.
49184 Suppose your LAN is 192.168.45.0/24.
49185 </para>
49186 </listitem>
49187 </itemizedlist>
49188 <para>
49189 In the main part of the configuration, you put the following definitions:
49190 </para>
49191 <literallayout class="monospaced">
49192 domainlist local_domains = my.dom1.example : my.dom2.example
49193 domainlist relay_domains = friend1.example : friend2.example
49194 hostlist   relay_hosts   = 192.168.45.0/24
49195 </literallayout>
49196 <para>
49197 Now you can use these definitions in the ACL that is run for every RCPT
49198 command:
49199 </para>
49200 <literallayout class="monospaced">
49201 acl_check_rcpt:
49202   accept domains = +local_domains : +relay_domains
49203   accept hosts   = +relay_hosts
49204 </literallayout>
49205 <para>
49206 The first statement accepts any RCPT command that contains an address in
49207 the local or relay domains. For any other domain, control passes to the second
49208 statement, which accepts the command only if it comes from one of the relay
49209 hosts. In practice, you will probably want to make your ACL more sophisticated
49210 than this, for example, by including sender and recipient verification. The
49211 default configuration includes a more comprehensive example, which is described
49212 in chapter <xref linkend="CHAPdefconfil"/>.
49213 </para>
49214 </section>
49215 <section id="SECTcheralcon">
49216 <title>Checking a relay configuration</title>
49217 <para>
49218 <indexterm role="concept">
49219 <primary>relaying</primary>
49220 <secondary>checking control of</secondary>
49221 </indexterm>
49222 You can check the relay characteristics of your configuration in the same way
49223 that you can test any ACL behaviour for an incoming SMTP connection, by using
49224 the <option>-bh</option> option to run a fake SMTP session with which you interact.
49225 </para>
49226 <para>
49227 For specifically testing for unwanted relaying, the host
49228 <emphasis>relay-test.mail-abuse.org</emphasis> provides a useful service. If you telnet to this
49229 host from the host on which Exim is running, using the normal telnet port, you
49230 will see a normal telnet connection message and then quite a long delay. Be
49231 patient. The remote host is making an SMTP connection back to your host, and
49232 trying a number of common probes to test for open relay vulnerability. The
49233 results of the tests will eventually appear on your terminal.
49234 <indexterm role="concept" startref="IIDacl" class="endofrange"/>
49235 </para>
49236 </section>
49237 </chapter>
49238
49239 <chapter id="CHAPexiscan">
49240 <title>Content scanning at ACL time</title>
49241 <para>
49242 <indexterm role="concept" id="IIDcosca" class="startofrange">
49243 <primary>content scanning</primary>
49244 <secondary>at ACL time</secondary>
49245 </indexterm>
49246 The extension of Exim to include content scanning at ACL time, formerly known
49247 as <quote>exiscan</quote>, was originally implemented as a patch by Tom Kistner. The code
49248 was integrated into the main source for Exim release 4.50, and Tom continues to
49249 maintain it. Most of the wording of this chapter is taken from Tom&#x2019;s
49250 specification.
49251 </para>
49252 <para>
49253 It is also possible to scan the content of messages at other times. The
49254 <function>local_scan()</function> function (see chapter <xref linkend="CHAPlocalscan"/>) allows for content
49255 scanning after all the ACLs have run. A transport filter can be used to scan
49256 messages at delivery time (see the <option>transport_filter</option> option, described in
49257 chapter <xref linkend="CHAPtransportgeneric"/>).
49258 </para>
49259 <para>
49260 If you want to include the ACL-time content-scanning features when you compile
49261 Exim, you need to arrange for WITH_CONTENT_SCAN to be defined in your
49262 <filename>Local/Makefile</filename>. When you do that, the Exim binary is built with:
49263 </para>
49264 <itemizedlist>
49265 <listitem>
49266 <para>
49267 Two additional ACLs (<option>acl_smtp_mime</option> and <option>acl_not_smtp_mime</option>) that are run
49268 for all MIME parts for SMTP and non-SMTP messages, respectively.
49269 </para>
49270 </listitem>
49271 <listitem>
49272 <para>
49273 Additional ACL conditions and modifiers: <option>decode</option>, <option>malware</option>,
49274 <option>mime_regex</option>, <option>regex</option>, and <option>spam</option>. These can be used in the ACL that is
49275 run at the end of message reception (the <option>acl_smtp_data</option> ACL).
49276 </para>
49277 </listitem>
49278 <listitem>
49279 <para>
49280 An additional control feature (<quote>no_mbox_unspool</quote>) that saves spooled copies
49281 of messages, or parts of messages, for debugging purposes.
49282 </para>
49283 </listitem>
49284 <listitem>
49285 <para>
49286 Additional expansion variables that are set in the new ACL and by the new
49287 conditions.
49288 </para>
49289 </listitem>
49290 <listitem>
49291 <para>
49292 Two new main configuration options: <option>av_scanner</option> and <option>spamd_address</option>.
49293 </para>
49294 </listitem>
49295 </itemizedlist>
49296 <para>
49297 There is another content-scanning configuration option for <filename>Local/Makefile</filename>,
49298 called WITH_OLD_DEMIME. If this is set, the old, deprecated <option>demime</option> ACL
49299 condition is compiled, in addition to all the other content-scanning features.
49300 </para>
49301 <para>
49302 Content-scanning is continually evolving, and new features are still being
49303 added. While such features are still unstable and liable to incompatible
49304 changes, they are made available in Exim by setting options whose names begin
49305 EXPERIMENTAL_ in <filename>Local/Makefile</filename>. Such features are not documented in
49306 this manual. You can find out about them by reading the file called
49307 <filename>doc/experimental.txt</filename>.
49308 </para>
49309 <para>
49310 All the content-scanning facilites work on a MBOX copy of the message that is
49311 temporarily created in a file called:
49312 </para>
49313 <literallayout>
49314 &lt;<emphasis>spool_directory</emphasis>&gt;<literal>/scan/</literal>&lt;<emphasis>message_id</emphasis>&gt;/&lt;<emphasis>message_id</emphasis>&gt;<literal>.eml</literal>
49315 </literallayout>
49316 <para>
49317 The <filename>.eml</filename> extension is a friendly hint to virus scanners that they can
49318 expect an MBOX-like structure inside that file. The file is created when the
49319 first content scanning facility is called. Subsequent calls to content
49320 scanning conditions open the same file again. The directory is recursively
49321 removed when the <option>acl_smtp_data</option> ACL has finished running, unless
49322 </para>
49323 <literallayout class="monospaced">
49324 control = no_mbox_unspool
49325 </literallayout>
49326 <para>
49327 has been encountered. When the MIME ACL decodes files, they are put into the
49328 same directory by default.
49329 </para>
49330 <section id="SECTscanvirus">
49331 <title>Scanning for viruses</title>
49332 <para>
49333 <indexterm role="concept">
49334 <primary>virus scanning</primary>
49335 </indexterm>
49336 <indexterm role="concept">
49337 <primary>content scanning</primary>
49338 <secondary>for viruses</secondary>
49339 </indexterm>
49340 <indexterm role="concept">
49341 <primary>content scanning</primary>
49342 <secondary>the <option>malware</option> condition</secondary>
49343 </indexterm>
49344 The <option>malware</option> ACL condition lets you connect virus scanner software to Exim.
49345 It supports a <quote>generic</quote> interface to scanners called via the shell, and
49346 specialized interfaces for <quote>daemon</quote> type virus scanners, which are resident
49347 in memory and thus are much faster.
49348 </para>
49349 <para>
49350 <indexterm role="concept">
49351 <primary><option>av_scanner</option></primary>
49352 </indexterm>
49353 You can set the <option>av_scanner</option> option in first part of the Exim configuration
49354 file to specify which scanner to use, together with any additional options that
49355 are needed. The basic syntax is as follows:
49356 </para>
49357 <literallayout>
49358 <literal>av_scanner = &lt;</literal><emphasis>scanner-type</emphasis><literal>&gt;:&lt;</literal><emphasis>option1</emphasis><literal>&gt;:&lt;</literal><emphasis>option2</emphasis><literal>&gt;:[...]</literal>
49359 </literallayout>
49360 <para>
49361 If you do not set <option>av_scanner</option>, it defaults to
49362 </para>
49363 <literallayout class="monospaced">
49364 av_scanner = sophie:/var/run/sophie
49365 </literallayout>
49366 <para>
49367 If the value of <option>av_scanner</option> starts with dollar character, it is expanded
49368 before use. The following scanner types are supported in this release:
49369 </para>
49370 <variablelist>
49371 <varlistentry>
49372 <term><option>aveserver</option></term>
49373 <listitem>
49374 <para>
49375 <indexterm role="concept">
49376 <primary>virus scanners</primary>
49377 <secondary>Kaspersky</secondary>
49378 </indexterm>
49379 This is the scanner daemon of Kaspersky Version 5. You can get a trial version
49380 at <emphasis role="bold"><ulink url="http://www.kaspersky.com">http://www.kaspersky.com</ulink></emphasis>. This scanner type takes one option,
49381 which is the path to the daemon&#x2019;s UNIX socket. The default is shown in this
49382 example:
49383 </para>
49384 <literallayout class="monospaced">
49385 av_scanner = aveserver:/var/run/aveserver
49386 </literallayout>
49387 </listitem></varlistentry>
49388 <varlistentry>
49389 <term><option>clamd</option></term>
49390 <listitem>
49391 <para>
49392 <indexterm role="concept">
49393 <primary>virus scanners</primary>
49394 <secondary>clamd</secondary>
49395 </indexterm>
49396 This daemon-type scanner is GPL and free. You can get it at
49397 <emphasis role="bold"><ulink url="http://www.clamav.net/">http://www.clamav.net/</ulink></emphasis>. Some older versions of clamd do not seem to
49398 unpack MIME containers, so it used to be recommended to unpack MIME attachments
49399 in the MIME ACL. This no longer believed to be necessary. One option is
49400 required: either the path and name of a UNIX socket file, or a hostname or IP
49401 number, and a port, separated by space, as in the second of these examples:
49402 </para>
49403 <literallayout class="monospaced">
49404 av_scanner = clamd:/opt/clamd/socket
49405 av_scanner = clamd:192.168.2.100 1234
49406 </literallayout>
49407 <para>
49408 If the option is unset, the default is <filename>/tmp/clamd</filename>. Thanks to David Saez for
49409 contributing the code for this scanner.
49410 </para>
49411 </listitem></varlistentry>
49412 <varlistentry>
49413 <term><option>cmdline</option></term>
49414 <listitem>
49415 <para>
49416 <indexterm role="concept">
49417 <primary>virus scanners</primary>
49418 <secondary>command line interface</secondary>
49419 </indexterm>
49420 This is the keyword for the generic command line scanner interface. It can be
49421 used to attach virus scanners that are invoked from the shell. This scanner
49422 type takes 3 mandatory options:
49423 </para>
49424 <orderedlist numeration="arabic">
49425 <listitem>
49426 <para>
49427 The full path and name of the scanner binary, with all command line options,
49428 and a placeholder (<literal>%s</literal>) for the directory to scan.
49429 </para>
49430 </listitem>
49431 <listitem>
49432 <para>
49433 A regular expression to match against the STDOUT and STDERR output of the
49434 virus scanner. If the expression matches, a virus was found. You must make
49435 absolutely sure that this expression matches on <quote>virus found</quote>. This is called
49436 the <quote>trigger</quote> expression.
49437 </para>
49438 </listitem>
49439 <listitem>
49440 <para>
49441 Another regular expression, containing exactly one pair of parentheses, to
49442 match the name of the virus found in the scanners output. This is called the
49443 <quote>name</quote> expression.
49444 </para>
49445 </listitem>
49446 </orderedlist>
49447 <para>
49448 For example, Sophos Sweep reports a virus on a line like this:
49449 </para>
49450 <literallayout class="monospaced">
49451 Virus 'W32/Magistr-B' found in file ./those.bat
49452 </literallayout>
49453 <para>
49454 For the trigger expression, we can just match the word <quote>found</quote>. For the name
49455 expression, we want to extract the W32/Magistr-B string, so we can match for
49456 the single quotes left and right of it. Altogether, this makes the
49457 configuration setting:
49458 </para>
49459 <literallayout class="monospaced">
49460 av_scanner = cmdline:\
49461              /path/to/sweep -all -rec -archive %s:\
49462              found:'(.+)'
49463 </literallayout>
49464 </listitem></varlistentry>
49465 <varlistentry>
49466 <term><option>drweb</option></term>
49467 <listitem>
49468 <para>
49469 <indexterm role="concept">
49470 <primary>virus scanners</primary>
49471 <secondary>DrWeb</secondary>
49472 </indexterm>
49473 The DrWeb daemon scanner (<emphasis role="bold"><ulink url="http://www.sald.com/">http://www.sald.com/</ulink></emphasis>) interface takes one
49474 argument, either a full path to a UNIX socket, or an IP address and port
49475 separated by white space, as in these examples:
49476 </para>
49477 <literallayout class="monospaced">
49478 av_scanner = drweb:/var/run/drwebd.sock
49479 av_scanner = drweb:192.168.2.20 31337
49480 </literallayout>
49481 <para>
49482 If you omit the argument, the default path <filename>/usr/local/drweb/run/drwebd.sock</filename>
49483 is used. Thanks to Alex Miller for contributing the code for this scanner.
49484 </para>
49485 </listitem></varlistentry>
49486 <varlistentry>
49487 <term><option>fsecure</option></term>
49488 <listitem>
49489 <para>
49490 <indexterm role="concept">
49491 <primary>virus scanners</primary>
49492 <secondary>F-Secure</secondary>
49493 </indexterm>
49494 The F-Secure daemon scanner (<emphasis role="bold"><ulink url="http://www.f-secure.com">http://www.f-secure.com</ulink></emphasis>) takes one
49495 argument which is the path to a UNIX socket. For example:
49496 </para>
49497 <literallayout class="monospaced">
49498 av_scanner = fsecure:/path/to/.fsav
49499 </literallayout>
49500 <para>
49501 If no argument is given, the default is <filename>/var/run/.fsav</filename>. Thanks to Johan
49502 Thelmen for contributing the code for this scanner.
49503 </para>
49504 </listitem></varlistentry>
49505 <varlistentry>
49506 <term><option>kavdaemon</option></term>
49507 <listitem>
49508 <para>
49509 <indexterm role="concept">
49510 <primary>virus scanners</primary>
49511 <secondary>Kaspersky</secondary>
49512 </indexterm>
49513 This is the scanner daemon of Kaspersky Version 4. This version of the
49514 Kaspersky scanner is outdated. Please upgrade (see <option>aveserver</option> above). This
49515 scanner type takes one option, which is the path to the daemon&#x2019;s UNIX socket.
49516 For example:
49517 </para>
49518 <literallayout class="monospaced">
49519 av_scanner = kavdaemon:/opt/AVP/AvpCtl
49520 </literallayout>
49521 <para>
49522 The default path is <filename>/var/run/AvpCtl</filename>.
49523 </para>
49524 </listitem></varlistentry>
49525 <varlistentry>
49526 <term><option>mksd</option></term>
49527 <listitem>
49528 <para>
49529 <indexterm role="concept">
49530 <primary>virus scanners</primary>
49531 <secondary>mksd</secondary>
49532 </indexterm>
49533 This is a daemon type scanner that is aimed mainly at Polish users, though some
49534 parts of documentation are now available in English. You can get it at
49535 <emphasis role="bold"><ulink url="http://linux.mks.com.pl/">http://linux.mks.com.pl/</ulink></emphasis>. The only option for this scanner type is
49536 the maximum number of processes used simultaneously to scan the attachments,
49537 provided that the demime facility is employed and also provided that mksd has
49538 been run with at least the same number of child processes. For example:
49539 </para>
49540 <literallayout class="monospaced">
49541 av_scanner = mksd:2
49542 </literallayout>
49543 <para>
49544 You can safely omit this option (the default value is 1).
49545 </para>
49546 </listitem></varlistentry>
49547 <varlistentry>
49548 <term><option>sophie</option></term>
49549 <listitem>
49550 <para>
49551 <indexterm role="concept">
49552 <primary>virus scanners</primary>
49553 <secondary>Sophos and Sophie</secondary>
49554 </indexterm>
49555 Sophie is a daemon that uses Sophos&#x2019; <option>libsavi</option> library to scan for viruses.
49556 You can get Sophie at <emphasis role="bold"><ulink url="http://www.vanja.com/tools/sophie/">http://www.vanja.com/tools/sophie/</ulink></emphasis>. The only
49557 option for this scanner type is the path to the UNIX socket that Sophie uses
49558 for client communication. For example:
49559 </para>
49560 <literallayout class="monospaced">
49561 av_scanner = sophie:/tmp/sophie
49562 </literallayout>
49563 <para>
49564 The default path is <filename>/var/run/sophie</filename>, so if you are using this, you can omit
49565 the option.
49566 </para>
49567 </listitem></varlistentry>
49568 </variablelist>
49569 <para>
49570 When <option>av_scanner</option> is correctly set, you can use the <option>malware</option> condition in
49571 the DATA ACL. <emphasis role="bold">Note</emphasis>: You cannot use the <option>malware</option> condition in the MIME
49572 ACL.
49573 </para>
49574 <para>
49575 The <option>av_scanner</option> option is expanded each time <option>malware</option> is called. This
49576 makes it possible to use different scanners. See further below for an example.
49577 The <option>malware</option> condition caches its results, so when you use it multiple times
49578 for the same message, the actual scanning process is only carried out once.
49579 However, using expandable items in <option>av_scanner</option> disables this caching, in
49580 which case each use of the <option>malware</option> condition causes a new scan of the
49581 message.
49582 </para>
49583 <para>
49584 The <option>malware</option> condition takes a right-hand argument that is expanded before
49585 use. It can then be one of
49586 </para>
49587 <itemizedlist>
49588 <listitem>
49589 <para>
49590 <quote>true</quote>, <quote>*</quote>, or <quote>1</quote>, in which case the message is scanned for viruses.
49591 The condition succeeds if a virus was found, and fail otherwise. This is the
49592 recommended usage.
49593 </para>
49594 </listitem>
49595 <listitem>
49596 <para>
49597 <quote>false</quote> or <quote>0</quote>, in which case no scanning is done and the condition fails
49598 immediately.
49599 </para>
49600 </listitem>
49601 <listitem>
49602 <para>
49603 A regular expression, in which case the message is scanned for viruses. The
49604 condition succeeds if a virus is found and its name matches the regular
49605 expression. This allows you to take special actions on certain types of virus.
49606 </para>
49607 </listitem>
49608 </itemizedlist>
49609 <para>
49610 You can append <literal>/defer_ok</literal> to the <option>malware</option> condition to accept messages
49611 even if there is a problem with the virus scanner.
49612 </para>
49613 <para>
49614 <indexterm role="concept">
49615 <primary><varname>$malware_name</varname></primary>
49616 </indexterm>
49617 When a virus is found, the condition sets up an expansion variable called
49618 <varname>$malware_name</varname> that contains the name of the virus. You can use it in a
49619 <option>message</option> modifier that specifies the error returned to the sender, and/or in
49620 logging data.
49621 </para>
49622 <para>
49623 If your virus scanner cannot unpack MIME and TNEF containers itself, you should
49624 use the <option>demime</option> condition (see section <xref linkend="SECTdemimecond"/>) before the
49625 <option>malware</option> condition.
49626 </para>
49627 <para>
49628 Here is a very simple scanning example:
49629 </para>
49630 <literallayout class="monospaced">
49631 deny message = This message contains malware ($malware_name)
49632      demime = *
49633      malware = *
49634 </literallayout>
49635 <para>
49636 The next example accepts messages when there is a problem with the scanner:
49637 </para>
49638 <literallayout class="monospaced">
49639 deny message = This message contains malware ($malware_name)
49640      demime = *
49641      malware = */defer_ok
49642 </literallayout>
49643 <para>
49644 The next example shows how to use an ACL variable to scan with both sophie and
49645 aveserver. It assumes you have set:
49646 </para>
49647 <literallayout class="monospaced">
49648 av_scanner = $acl_m0
49649 </literallayout>
49650 <para>
49651 in the main Exim configuration.
49652 </para>
49653 <literallayout class="monospaced">
49654 deny message = This message contains malware ($malware_name)
49655      set acl_m0 = sophie
49656      malware = *
49657
49658 deny message = This message contains malware ($malware_name)
49659      set acl_m0 = aveserver
49660      malware = *
49661 </literallayout>
49662 </section>
49663 <section id="SECTscanspamass">
49664 <title>Scanning with SpamAssassin</title>
49665 <para>
49666 <indexterm role="concept">
49667 <primary>content scanning</primary>
49668 <secondary>for spam</secondary>
49669 </indexterm>
49670 <indexterm role="concept">
49671 <primary>spam scanning</primary>
49672 </indexterm>
49673 <indexterm role="concept">
49674 <primary>SpamAssassin</primary>
49675 <secondary>scanning with</secondary>
49676 </indexterm>
49677 The <option>spam</option> ACL condition calls SpamAssassin&#x2019;s <option>spamd</option> daemon to get a spam
49678 score and a report for the message. You can get SpamAssassin at
49679 <emphasis role="bold"><ulink url="http://www.spamassassin.org">http://www.spamassassin.org</ulink></emphasis>, or, if you have a working Perl
49680 installation, you can use CPAN by running:
49681 </para>
49682 <literallayout class="monospaced">
49683 perl -MCPAN -e 'install Mail::SpamAssassin'
49684 </literallayout>
49685 <para>
49686 SpamAssassin has its own set of configuration files. Please review its
49687 documentation to see how you can tweak it. The default installation should work
49688 nicely, however.
49689 </para>
49690 <para>
49691 <indexterm role="concept">
49692 <primary><option>spamd_address</option></primary>
49693 </indexterm>
49694 After having installed and configured SpamAssassin, start the <option>spamd</option> daemon.
49695 By default, it listens on 127.0.0.1, TCP port 783. If you use another host or
49696 port for <option>spamd</option>, you must set the <option>spamd_address</option> option in the global
49697 part of the Exim configuration as follows (example):
49698 </para>
49699 <literallayout class="monospaced">
49700 spamd_address = 192.168.99.45 387
49701 </literallayout>
49702 <para>
49703 You do not need to set this option if you use the default. As of version 2.60,
49704 <option>spamd</option> also supports communication over UNIX sockets. If you want to use
49705 these, supply <option>spamd_address</option> with an absolute file name instead of a
49706 address/port pair:
49707 </para>
49708 <literallayout class="monospaced">
49709 spamd_address = /var/run/spamd_socket
49710 </literallayout>
49711 <para>
49712 You can have multiple <option>spamd</option> servers to improve scalability. These can
49713 reside on other hardware reachable over the network. To specify multiple
49714 <option>spamd</option> servers, put multiple address/port pairs in the <option>spamd_address</option>
49715 option, separated with colons:
49716 </para>
49717 <literallayout class="monospaced">
49718 spamd_address = 192.168.2.10 783 : \
49719                 192.168.2.11 783 : \
49720                 192.168.2.12 783
49721 </literallayout>
49722 <para>
49723 Up to 32 <option>spamd</option> servers are supported. The servers are queried in a random
49724 fashion. When a server fails to respond to the connection attempt, all other
49725 servers are tried until one succeeds. If no server responds, the <option>spam</option>
49726 condition defers.
49727 </para>
49728 <para>
49729 <emphasis role="bold">Warning</emphasis>: It is not possible to use the UNIX socket connection method with
49730 multiple <option>spamd</option> servers.
49731 </para>
49732 </section>
49733 <section>
49734 <title>Calling SpamAssassin from an Exim ACL</title>
49735 <para>
49736 Here is a simple example of the use of the <option>spam</option> condition in a DATA ACL:
49737 </para>
49738 <literallayout class="monospaced">
49739 deny message = This message was classified as SPAM
49740      spam = joe
49741 </literallayout>
49742 <para>
49743 The right-hand side of the <option>spam</option> condition specifies the username that
49744 SpamAssassin should scan for. If you do not want to scan for a particular user,
49745 but rather use the SpamAssassin system-wide default profile, you can scan for
49746 an unknown user, or simply use <quote>nobody</quote>. However, you must put something on
49747 the right-hand side.
49748 </para>
49749 <para>
49750 The username allows you to use per-domain or per-user antispam profiles. The
49751 right-hand side is expanded before being used, so you can put lookups or
49752 conditions there. When the right-hand side evaluates to <quote>0</quote> or <quote>false</quote>, no
49753 scanning is done and the condition fails immediately.
49754 </para>
49755 <para>
49756 Scanning with SpamAssassin uses a lot of resources. If you scan every message,
49757 large ones may cause significant performance degredation. As most spam messages
49758 are quite small, it is recommended that you do not scan the big ones. For
49759 example:
49760 </para>
49761 <literallayout class="monospaced">
49762 deny message = This message was classified as SPAM
49763      condition = ${if &lt; {$message_size}{10K}}
49764      spam = nobody
49765 </literallayout>
49766 <para>
49767 The <option>spam</option> condition returns true if the threshold specified in the user&#x2019;s
49768 SpamAssassin profile has been matched or exceeded. If you want to use the
49769 <option>spam</option> condition for its side effects (see the variables below), you can make
49770 it always return <quote>true</quote> by appending <literal>:true</literal> to the username.
49771 </para>
49772 <para>
49773 <indexterm role="concept">
49774 <primary>spam scanning</primary>
49775 <secondary>returned variables</secondary>
49776 </indexterm>
49777 When the <option>spam</option> condition is run, it sets up the following expansion
49778 variables:
49779 </para>
49780 <variablelist>
49781 <varlistentry>
49782 <term><varname>$spam_score</varname></term>
49783 <listitem>
49784 <para>
49785 The spam score of the message, for example <quote>3.4</quote> or <quote>30.5</quote>. This is useful
49786 for inclusion in log or reject messages.
49787 </para>
49788 </listitem></varlistentry>
49789 <varlistentry>
49790 <term><varname>$spam_score_int</varname></term>
49791 <listitem>
49792 <para>
49793 The spam score of the message, multiplied by ten, as an integer value. For
49794 example <quote>34</quote> or <quote>305</quote>. This is useful for numeric comparisons in
49795 conditions. This variable is special; it is saved with the message, and written
49796 to Exim&#x2019;s spool file. This means that it can be used during the whole life of
49797 the message on your Exim system, in particular, in routers or transports during
49798 the later delivery phase.
49799 </para>
49800 </listitem></varlistentry>
49801 <varlistentry>
49802 <term><varname>$spam_bar</varname></term>
49803 <listitem>
49804 <para>
49805 A string consisting of a number of <quote>+</quote> or <quote>-</quote> characters, representing the
49806 integer part of the spam score value. A spam score of 4.4 would have a
49807 <varname>$spam_bar</varname> value of <quote>++++</quote>. This is useful for inclusion in warning
49808 headers, since MUAs can match on such strings.
49809 </para>
49810 </listitem></varlistentry>
49811 <varlistentry>
49812 <term><varname>$spam_report</varname></term>
49813 <listitem>
49814 <para>
49815 A multiline text table, containing the full SpamAssassin report for the
49816 message. Useful for inclusion in headers or reject messages.
49817 </para>
49818 </listitem></varlistentry>
49819 </variablelist>
49820 <para>
49821 The <option>spam</option> condition caches its results. If you call it again with the same
49822 user name, it does not scan again, but rather returns the same values as
49823 before.
49824 </para>
49825 <para>
49826 The <option>spam</option> condition returns DEFER if there is any error while running the
49827 message through SpamAssassin. If you want to treat DEFER as FAIL (to pass on to
49828 the next ACL statement block), append <literal>/defer_ok</literal> to the right-hand side of
49829 the spam condition, like this:
49830 </para>
49831 <literallayout class="monospaced">
49832 deny message = This message was classified as SPAM
49833      spam    = joe/defer_ok
49834 </literallayout>
49835 <para>
49836 This causes messages to be accepted even if there is a problem with <option>spamd</option>.
49837 </para>
49838 <para>
49839 Here is a longer, commented example of the use of the <option>spam</option>
49840 condition:
49841 </para>
49842 <literallayout class="monospaced">
49843 # put headers in all messages (no matter if spam or not)
49844 warn  message = X-Spam-Score: $spam_score ($spam_bar)
49845       spam = nobody:true
49846 warn  message = X-Spam-Report: $spam_report
49847       spam = nobody:true
49848
49849 # add second subject line with *SPAM* marker when message
49850 # is over threshold
49851 warn  message = Subject: *SPAM* $h_Subject:
49852       spam = nobody
49853
49854 # reject spam at high scores (&gt; 12)
49855 deny  message = This message scored $spam_score spam points.
49856       spam = nobody:true
49857       condition = ${if &gt;{$spam_score_int}{120}{1}{0}}
49858 </literallayout>
49859 </section>
49860 <section id="SECTscanmimepart">
49861 <title>Scanning MIME parts</title>
49862 <para>
49863 <indexterm role="concept">
49864 <primary>content scanning</primary>
49865 <secondary>MIME parts</secondary>
49866 </indexterm>
49867 <indexterm role="concept">
49868 <primary>MIME content scanning</primary>
49869 </indexterm>
49870 <indexterm role="concept">
49871 <primary><option>acl_smtp_mime</option></primary>
49872 </indexterm>
49873 The <option>acl_smtp_mime</option> global option specifies an ACL that is called once for
49874 each MIME part of an SMTP message, including multipart types, in the sequence
49875 of their position in the message. Similarly, the <option>acl_not_smtp_mime</option> option
49876 specifies an ACL that is used for the MIME parts of non-SMTP messages. These
49877 options may both refer to the same ACL if you want the same processing in both
49878 cases.
49879 </para>
49880 <para>
49881 These ACLs are called (possibly many times) just before the <option>acl_smtp_data</option>
49882 ACL in the case of an SMTP message, or just before a non-SMTP message is
49883 accepted. However, a MIME ACL is called only if the message contains a
49884 <emphasis>MIME-Version:</emphasis> header line. When a call to a MIME ACL does not yield
49885 <quote>accept</quote>, ACL processing is aborted and the appropriate result code is sent
49886 to the client. In the case of an SMTP message, the <option>acl_smtp_data</option> ACL is not
49887 called when this happens.
49888 </para>
49889 <para>
49890 You cannot use the <option>malware</option> or <option>spam</option> conditions in a MIME ACL; these can
49891 only be used in the DATA or non-SMTP ACLs. However, you can use the <option>regex</option>
49892 condition to match against the raw MIME part. You can also use the
49893 <option>mime_regex</option> condition to match against the decoded MIME part (see section
49894 <xref linkend="SECTscanregex"/>).
49895 </para>
49896 <para>
49897 At the start of a MIME ACL, a number of variables are set from the header
49898 information for the relevant MIME part. These are described below. The contents
49899 of the MIME part are not by default decoded into a disk file except for MIME
49900 parts whose content-type is <quote>message/rfc822</quote>. If you want to decode a MIME
49901 part into a disk file, you can use the <option>decode</option> modifier. The general syntax
49902 is:
49903 </para>
49904 <literallayout>
49905 <literal>decode = [/</literal>&lt;<emphasis>path</emphasis>&gt;<literal>/]</literal>&lt;<emphasis>filename</emphasis>&gt;
49906 </literallayout>
49907 <para>
49908 The right hand side is expanded before use. After expansion,
49909 the value can be:
49910 </para>
49911 <orderedlist numeration="arabic">
49912 <listitem>
49913 <para>
49914 <quote>0</quote> or <quote>false</quote>, in which case no decoding is done.
49915 </para>
49916 </listitem>
49917 <listitem>
49918 <para>
49919 The string <quote>default</quote>. In that case, the file is put in the temporary
49920 <quote>default</quote> directory &lt;<emphasis>spool_directory</emphasis>&gt;<filename>/scan/</filename>&lt;<emphasis>message_id</emphasis>&gt;<filename>/</filename> with
49921 a sequential file name consisting of the message id and a sequence number. The
49922 full path and name is available in <varname>$mime_decoded_filename</varname> after decoding.
49923 </para>
49924 </listitem>
49925 <listitem>
49926 <para>
49927 A full path name starting with a slash. If the full name is an existing
49928 directory, it is used as a replacement for the default directory. The filename
49929 is then sequentially assigned. If the path does not exist, it is used as
49930 the full path and file name.
49931 </para>
49932 </listitem>
49933 <listitem>
49934 <para>
49935 If the string does not start with a slash, it is used as the
49936 filename, and the default path is then used.
49937 </para>
49938 </listitem>
49939 </orderedlist>
49940 <para>
49941 You can easily decode a file with its original, proposed filename using
49942 </para>
49943 <literallayout class="monospaced">
49944 decode = $mime_filename
49945 </literallayout>
49946 <para>
49947 However, you should keep in mind that <varname>$mime_filename</varname> might contain
49948 anything. If you place files outside of the default path, they are not
49949 automatically unlinked.
49950 </para>
49951 <para>
49952 For RFC822 attachments (these are messages attached to messages, with a
49953 content-type of <quote>message/rfc822</quote>), the ACL is called again in the same manner
49954 as for the primary message, only that the <varname>$mime_is_rfc822</varname> expansion
49955 variable is set (see below). Attached messages are always decoded to disk
49956 before being checked, and the files are unlinked once the check is done.
49957 </para>
49958 <para>
49959 The MIME ACL supports the <option>regex</option> and <option>mime_regex</option> conditions. These can be
49960 used to match regular expressions against raw and decoded MIME parts,
49961 respectively. They are described in section <xref linkend="SECTscanregex"/>.
49962 </para>
49963 <para>
49964 <indexterm role="concept">
49965 <primary>MIME content scanning</primary>
49966 <secondary>returned variables</secondary>
49967 </indexterm>
49968 The following list describes all expansion variables that are
49969 available in the MIME ACL:
49970 </para>
49971 <variablelist>
49972 <varlistentry>
49973 <term><varname>$mime_boundary</varname></term>
49974 <listitem>
49975 <para>
49976 If the current part is a multipart (see <varname>$mime_is_multipart</varname>) below, it should
49977 have a boundary string, which is stored in this variable. If the current part
49978 has no boundary parameter in the <emphasis>Content-Type:</emphasis> header, this variable
49979 contains the empty string.
49980 </para>
49981 </listitem></varlistentry>
49982 <varlistentry>
49983 <term><varname>$mime_charset</varname></term>
49984 <listitem>
49985 <para>
49986 This variable contains the character set identifier, if one was found in the
49987 <emphasis>Content-Type:</emphasis> header. Examples for charset identifiers are:
49988 </para>
49989 <literallayout class="monospaced">
49990 us-ascii
49991 gb2312 (Chinese)
49992 iso-8859-1
49993 </literallayout>
49994 <para>
49995 Please note that this value is not normalized, so you should do matches
49996 case-insensitively.
49997 </para>
49998 </listitem></varlistentry>
49999 <varlistentry>
50000 <term><varname>$mime_content_description</varname></term>
50001 <listitem>
50002 <para>
50003 This variable contains the normalized content of the <emphasis>Content-Description:</emphasis>
50004 header. It can contain a human-readable description of the parts content. Some
50005 implementations repeat the filename for attachments here, but they are usually
50006 only used for display purposes.
50007 </para>
50008 </listitem></varlistentry>
50009 <varlistentry>
50010 <term><varname>$mime_content_disposition</varname></term>
50011 <listitem>
50012 <para>
50013 This variable contains the normalized content of the <emphasis>Content-Disposition:</emphasis>
50014 header. You can expect strings like <quote>attachment</quote> or <quote>inline</quote> here.
50015 </para>
50016 </listitem></varlistentry>
50017 <varlistentry>
50018 <term><varname>$mime_content_id</varname></term>
50019 <listitem>
50020 <para>
50021 This variable contains the normalized content of the <emphasis>Content-ID:</emphasis> header.
50022 This is a unique ID that can be used to reference a part from another part.
50023 </para>
50024 </listitem></varlistentry>
50025 <varlistentry>
50026 <term><varname>$mime_content_size</varname></term>
50027 <listitem>
50028 <para>
50029 This variable is set only after the <option>decode</option> modifier (see above) has been
50030 successfully run. It contains the size of the decoded part in kilobytes. The
50031 size is always rounded up to full kilobytes, so only a completely empty part
50032 has a <varname>$mime_content_size</varname> of zero.
50033 </para>
50034 </listitem></varlistentry>
50035 <varlistentry>
50036 <term><varname>$mime_content_transfer_encoding</varname></term>
50037 <listitem>
50038 <para>
50039 This variable contains the normalized content of the
50040 <emphasis>Content-transfer-encoding:</emphasis> header. This is a symbolic name for an encoding
50041 type. Typical values are <quote>base64</quote> and <quote>quoted-printable</quote>.
50042 </para>
50043 </listitem></varlistentry>
50044 <varlistentry>
50045 <term><varname>$mime_content_type</varname></term>
50046 <listitem>
50047 <para>
50048 If the MIME part has a <emphasis>Content-Type:</emphasis> header, this variable contains its
50049 value, lowercased, and without any options (like <quote>name</quote> or <quote>charset</quote>). Here
50050 are some examples of popular MIME types, as they may appear in this variable:
50051 </para>
50052 <literallayout class="monospaced">
50053 text/plain
50054 text/html
50055 application/octet-stream
50056 image/jpeg
50057 audio/midi
50058 </literallayout>
50059 <para>
50060 If the MIME part has no <emphasis>Content-Type:</emphasis> header, this variable contains the
50061 empty string.
50062 </para>
50063 </listitem></varlistentry>
50064 <varlistentry>
50065 <term><varname>$mime_decoded_filename</varname></term>
50066 <listitem>
50067 <para>
50068 This variable is set only after the <option>decode</option> modifier (see above) has been
50069 successfully run. It contains the full path and file name of the file
50070 containing the decoded data.
50071 </para>
50072 </listitem></varlistentry>
50073 </variablelist>
50074 <para>
50075 <indexterm role="concept">
50076 <primary>RFC 2047</primary>
50077 </indexterm>
50078 </para>
50079 <variablelist>
50080 <varlistentry>
50081 <term><varname>$mime_filename</varname></term>
50082 <listitem>
50083 <para>
50084 This is perhaps the most important of the MIME variables. It contains a
50085 proposed filename for an attachment, if one was found in either the
50086 <emphasis>Content-Type:</emphasis> or <emphasis>Content-Disposition:</emphasis> headers. The filename will be
50087 RFC2047 decoded, but no additional sanity checks are done. If no filename was
50088 found, this variable contains the empty string.
50089 </para>
50090 </listitem></varlistentry>
50091 <varlistentry>
50092 <term><varname>$mime_is_coverletter</varname></term>
50093 <listitem>
50094 <para>
50095 This variable attempts to differentiate the <quote>cover letter</quote> of an e-mail from
50096 attached data. It can be used to clamp down on flashy or unneccessarily encoded
50097 content in the cover letter, while not restricting attachments at all.
50098 </para>
50099 <para>
50100 The variable contains 1 (true) for a MIME part believed to be part of the
50101 cover letter, and 0 (false) for an attachment. At present, the algorithm is as
50102 follows:
50103 </para>
50104 <orderedlist numeration="arabic">
50105 <listitem>
50106 <para>
50107 The outermost MIME part of a message is always a cover letter.
50108 </para>
50109 </listitem>
50110 <listitem>
50111 <para>
50112 If a multipart/alternative or multipart/related MIME part is a cover letter,
50113 so are all MIME subparts within that multipart.
50114 </para>
50115 </listitem>
50116 <listitem>
50117 <para>
50118 If any other multipart is a cover letter, the first subpart is a cover letter,
50119 and the rest are attachments.
50120 </para>
50121 </listitem>
50122 <listitem>
50123 <para>
50124 All parts contained within an attachment multipart are attachments.
50125 </para>
50126 </listitem>
50127 </orderedlist>
50128 <para>
50129 As an example, the following will ban <quote>HTML mail</quote> (including that sent with
50130 alternative plain text), while allowing HTML files to be attached. HTML
50131 coverletter mail attached to non-HMTL coverletter mail will also be allowed:
50132 </para>
50133 <literallayout class="monospaced">
50134 deny message = HTML mail is not accepted here
50135 !condition = $mime_is_rfc822
50136 condition = $mime_is_coverletter
50137 condition = ${if eq{$mime_content_type}{text/html}{1}{0}}
50138 </literallayout>
50139 </listitem></varlistentry>
50140 <varlistentry>
50141 <term><varname>$mime_is_multipart</varname></term>
50142 <listitem>
50143 <para>
50144 This variable has the value 1 (true) when the current part has the main type
50145 <quote>multipart</quote>, for example <quote>multipart/alternative</quote> or <quote>multipart/mixed</quote>.
50146 Since multipart entities only serve as containers for other parts, you may not
50147 want to carry out specific actions on them.
50148 </para>
50149 </listitem></varlistentry>
50150 <varlistentry>
50151 <term><varname>$mime_is_rfc822</varname></term>
50152 <listitem>
50153 <para>
50154 This variable has the value 1 (true) if the current part is not a part of the
50155 checked message itself, but part of an attached message. Attached message
50156 decoding is fully recursive.
50157 </para>
50158 </listitem></varlistentry>
50159 <varlistentry>
50160 <term><varname>$mime_part_count</varname></term>
50161 <listitem>
50162 <para>
50163 This variable is a counter that is raised for each processed MIME part. It
50164 starts at zero for the very first part (which is usually a multipart). The
50165 counter is per-message, so it is reset when processing RFC822 attachments (see
50166 <varname>$mime_is_rfc822</varname>). The counter stays set after <option>acl_smtp_mime</option> is
50167 complete, so you can use it in the DATA ACL to determine the number of MIME
50168 parts of a message. For non-MIME messages, this variable contains the value -1.
50169 </para>
50170 </listitem></varlistentry>
50171 </variablelist>
50172 </section>
50173 <section id="SECTscanregex">
50174 <title>Scanning with regular expressions</title>
50175 <para>
50176 <indexterm role="concept">
50177 <primary>content scanning</primary>
50178 <secondary>with regular expressions</secondary>
50179 </indexterm>
50180 <indexterm role="concept">
50181 <primary>regular expressions</primary>
50182 <secondary>content scanning with</secondary>
50183 </indexterm>
50184 You can specify your own custom regular expression matches on the full body of
50185 the message, or on individual MIME parts.
50186 </para>
50187 <para>
50188 The <option>regex</option> condition takes one or more regular expressions as arguments and
50189 matches them against the full message (when called in the DATA ACL) or a raw
50190 MIME part (when called in the MIME ACL). The <option>regex</option> condition matches
50191 linewise, with a maximum line length of 32K characters. That means you cannot
50192 have multiline matches with the <option>regex</option> condition.
50193 </para>
50194 <para>
50195 The <option>mime_regex</option> condition can be called only in the MIME ACL. It matches up
50196 to 32K of decoded content (the whole content at once, not linewise). If the
50197 part has not been decoded with the <option>decode</option> modifier earlier in the ACL, it
50198 is decoded automatically when <option>mime_regex</option> is executed (using default path
50199 and filename values). If the decoded data is larger than  32K, only the first
50200 32K characters are checked.
50201 </para>
50202 <para>
50203 The regular expressions are passed as a colon-separated list. To include a
50204 literal colon, you must double it. Since the whole right-hand side string is
50205 expanded before being used, you must also escape dollar signs and backslashes
50206 with more backslashes, or use the <literal>\N</literal> facility to disable expansion.
50207 Here is a simple example that contains two regular expressions:
50208 </para>
50209 <literallayout class="monospaced">
50210 deny message = contains blacklisted regex ($regex_match_string)
50211      regex = [Mm]ortgage : URGENT BUSINESS PROPOSAL
50212 </literallayout>
50213 <para>
50214 The conditions returns true if any one of the regular expressions matches. The
50215 <varname>$regex_match_string</varname> expansion variable is then set up and contains the
50216 matching regular expression.
50217 </para>
50218 <para>
50219 <emphasis role="bold">Warning</emphasis>: With large messages, these conditions can be fairly
50220 CPU-intensive.
50221 </para>
50222 </section>
50223 <section id="SECTdemimecond">
50224 <title>The demime condition</title>
50225 <para>
50226 <indexterm role="concept">
50227 <primary>content scanning</primary>
50228 <secondary>MIME checking</secondary>
50229 </indexterm>
50230 <indexterm role="concept">
50231 <primary>MIME content scanning</primary>
50232 </indexterm>
50233 The <option>demime</option> ACL condition provides MIME unpacking, sanity checking and file
50234 extension blocking. It is usable only in the DATA and non-SMTP ACLs. The
50235 <option>demime</option> condition uses a simpler interface to MIME decoding than the MIME
50236 ACL functionality, but provides no additional facilities. Please note that this
50237 condition is deprecated and kept only for backward compatibility. You must set
50238 the WITH_OLD_DEMIME option in <filename>Local/Makefile</filename> at build time to be able to
50239 use the <option>demime</option> condition.
50240 </para>
50241 <para>
50242 The <option>demime</option> condition unpacks MIME containers in the message. It detects
50243 errors in MIME containers and can match file extensions found in the message
50244 against a list. Using this facility produces files containing the unpacked MIME
50245 parts of the message in the temporary scan directory. If you do antivirus
50246 scanning, it is recommened that you use the <option>demime</option> condition before the
50247 antivirus (<option>malware</option>) condition.
50248 </para>
50249 <para>
50250 On the right-hand side of the <option>demime</option> condition you can pass a
50251 colon-separated list of file extensions that it should match against. For
50252 example:
50253 </para>
50254 <literallayout class="monospaced">
50255 deny message = Found blacklisted file attachment
50256      demime  = vbs:com:bat:pif:prf:lnk
50257 </literallayout>
50258 <para>
50259 If one of the file extensions is found, the condition is true, otherwise it is
50260 false. If there is a temporary error while demimeing (for example, <quote>disk
50261 full</quote>), the condition defers, and the message is temporarily rejected (unless
50262 the condition is on a <option>warn</option> verb).
50263 </para>
50264 <para>
50265 The right-hand side is expanded before being treated as a list, so you can have
50266 conditions and lookups there. If it expands to an empty string, <quote>false</quote>, or
50267 zero (<quote>0</quote>), no demimeing is done and the condition is false.
50268 </para>
50269 <para>
50270 The <option>demime</option> condition set the following variables:
50271 </para>
50272 <variablelist>
50273 <varlistentry>
50274 <term><varname>$demime_errorlevel</varname></term>
50275 <listitem>
50276 <para>
50277 <indexterm role="concept">
50278 <primary><varname>$demime_errorlevel</varname></primary>
50279 </indexterm>
50280 When an error is detected in a MIME container, this variable contains the
50281 severity of the error, as an integer number. The higher the value, the more
50282 severe the error (the current maximum value is 3). If this variable is unset or
50283 zero, no error occurred.
50284 </para>
50285 </listitem></varlistentry>
50286 <varlistentry>
50287 <term><varname>$demime_reason</varname></term>
50288 <listitem>
50289 <para>
50290 <indexterm role="concept">
50291 <primary><varname>$demime_reason</varname></primary>
50292 </indexterm>
50293 When <varname>$demime_errorlevel</varname> is greater than zero, this variable contains a
50294 human-readable text string describing the MIME error that occurred.
50295 </para>
50296 </listitem></varlistentry>
50297 </variablelist>
50298 <variablelist>
50299 <varlistentry>
50300 <term><varname>$found_extension</varname></term>
50301 <listitem>
50302 <para>
50303 <indexterm role="concept">
50304 <primary><varname>$found_extension</varname></primary>
50305 </indexterm>
50306 When the <option>demime</option> condition is true, this variable contains the file
50307 extension it found.
50308 </para>
50309 </listitem></varlistentry>
50310 </variablelist>
50311 <para>
50312 Both <varname>$demime_errorlevel</varname> and <varname>$demime_reason</varname> are set by the first call of
50313 the <option>demime</option> condition, and are not changed on subsequent calls.
50314 </para>
50315 <para>
50316 If you do not want to check for file extensions, but rather use the <option>demime</option>
50317 condition for unpacking or error checking purposes, pass <quote>*</quote> as the
50318 right-hand side value. Here is a more elaborate example of how to use this
50319 facility:
50320 </para>
50321 <literallayout class="monospaced">
50322 # Reject messages with serious MIME container errors
50323 deny  message = Found MIME error ($demime_reason).
50324       demime = *
50325       condition = ${if &gt;{$demime_errorlevel}{2}{1}{0}}
50326
50327 # Reject known virus spreading file extensions.
50328 # Accepting these is pretty much braindead.
50329 deny  message = contains $found_extension file (blacklisted).
50330       demime  = com:vbs:bat:pif:scr
50331
50332 # Freeze .exe and .doc files. Postmaster can
50333 # examine them and eventually thaw them.
50334 deny  log_message = Another $found_extension file.
50335       demime = exe:doc
50336       control = freeze
50337 </literallayout>
50338 <para>
50339 <indexterm role="concept" startref="IIDcosca" class="endofrange"/>
50340 </para>
50341 </section>
50342 </chapter>
50343
50344 <chapter id="CHAPlocalscan">
50345 <title>Adding a local scan function to Exim</title>
50346 <titleabbrev>Local scan function</titleabbrev>
50347 <para>
50348 <indexterm role="concept" id="IIDlosca" class="startofrange">
50349 <primary><function>local_scan()</function> function</primary>
50350 <secondary>description of</secondary>
50351 </indexterm>
50352 <indexterm role="concept">
50353 <primary>customizing</primary>
50354 <secondary>input scan using C function</secondary>
50355 </indexterm>
50356 <indexterm role="concept">
50357 <primary>policy control</primary>
50358 <secondary>by local scan function</secondary>
50359 </indexterm>
50360 In these days of email worms, viruses, and ever-increasing spam, some sites
50361 want to apply a lot of checking to messages before accepting them.
50362 </para>
50363 <para>
50364 The content scanning extension (chapter <xref linkend="CHAPexiscan"/>) has facilities for
50365 passing messages to external virus and spam scanning software. You can also do
50366 a certain amount in Exim itself through string expansions and the <option>condition</option>
50367 condition in the ACL that runs after the SMTP DATA command or the ACL for
50368 non-SMTP messages (see chapter <xref linkend="CHAPACL"/>), but this has its limitations.
50369 </para>
50370 <para>
50371 To allow for further customization to a site&#x2019;s own requirements, there is the
50372 possibility of linking Exim with a private message scanning function, written
50373 in C. If you want to run code that is written in something other than C, you
50374 can of course use a little C stub to call it.
50375 </para>
50376 <para>
50377 The local scan function is run once for every incoming message, at the point
50378 when Exim is just about to accept the message.
50379 It can therefore be used to control non-SMTP messages from local processes as
50380 well as messages arriving via SMTP.
50381 </para>
50382 <para>
50383 Exim applies a timeout to calls of the local scan function, and there is an
50384 option called <option>local_scan_timeout</option> for setting it. The default is 5 minutes.
50385 Zero means <quote>no timeout</quote>.
50386 Exim also sets up signal handlers for SIGSEGV, SIGILL, SIGFPE, and SIGBUS
50387 before calling the local scan function, so that the most common types of crash
50388 are caught. If the timeout is exceeded or one of those signals is caught, the
50389 incoming message is rejected with a temporary error if it is an SMTP message.
50390 For a non-SMTP message, the message is dropped and Exim ends with a non-zero
50391 code. The incident is logged on the main and reject logs.
50392 </para>
50393 <section>
50394 <title>Building Exim to use a local scan function</title>
50395 <para>
50396 <indexterm role="concept">
50397 <primary><function>local_scan()</function> function</primary>
50398 <secondary>building Exim to use</secondary>
50399 </indexterm>
50400 To make use of the local scan function feature, you must tell Exim where your
50401 function is before building Exim, by setting LOCAL_SCAN_SOURCE in your
50402 <filename>Local/Makefile</filename>. A recommended place to put it is in the <filename>Local</filename>
50403 directory, so you might set
50404 </para>
50405 <literallayout class="monospaced">
50406 LOCAL_SCAN_SOURCE=Local/local_scan.c
50407 </literallayout>
50408 <para>
50409 for example. The function must be called <function>local_scan()</function>. It is called by
50410 Exim after it has received a message, when the success return code is about to
50411 be sent. This is after all the ACLs have been run. The return code from your
50412 function controls whether the message is actually accepted or not. There is a
50413 commented template function (that just accepts the message) in the file
50414 _src/local_scan.c_.
50415 </para>
50416 <para>
50417 If you want to make use of Exim&#x2019;s run time configuration file to set options
50418 for your <function>local_scan()</function> function, you must also set
50419 </para>
50420 <literallayout class="monospaced">
50421 LOCAL_SCAN_HAS_OPTIONS=yes
50422 </literallayout>
50423 <para>
50424 in <filename>Local/Makefile</filename> (see section <xref linkend="SECTconoptloc"/> below).
50425 </para>
50426 </section>
50427 <section id="SECTapiforloc">
50428 <title>API for local_scan()</title>
50429 <para>
50430 <indexterm role="concept">
50431 <primary><function>local_scan()</function> function</primary>
50432 <secondary>API description</secondary>
50433 </indexterm>
50434 You must include this line near the start of your code:
50435 </para>
50436 <literallayout class="monospaced">
50437 #include "local_scan.h"
50438 </literallayout>
50439 <para>
50440 This header file defines a number of variables and other values, and the
50441 prototype for the function itself. Exim is coded to use unsigned char values
50442 almost exclusively, and one of the things this header defines is a shorthand
50443 for <literal>unsigned char</literal> called <literal>uschar</literal>.
50444 It also contains the following macro definitions, to simplify casting character
50445 strings and pointers to character strings:
50446 </para>
50447 <literallayout class="monospaced">
50448 #define CS   (char *)
50449 #define CCS  (const char *)
50450 #define CSS  (char **)
50451 #define US   (unsigned char *)
50452 #define CUS  (const unsigned char *)
50453 #define USS  (unsigned char **)
50454 </literallayout>
50455 <para>
50456 The function prototype for <function>local_scan()</function> is:
50457 </para>
50458 <literallayout class="monospaced">
50459 extern int local_scan(int fd, uschar **return_text);
50460 </literallayout>
50461 <para>
50462 The arguments are as follows:
50463 </para>
50464 <itemizedlist>
50465 <listitem>
50466 <para>
50467 <option>fd</option> is a file descriptor for the file that contains the body of the message
50468 (the -D file). The file is open for reading and writing, but updating it is not
50469 recommended. <emphasis role="bold">Warning</emphasis>: You must <emphasis>not</emphasis> close this file descriptor.
50470 </para>
50471 <para>
50472 The descriptor is positioned at character 19 of the file, which is the first
50473 character of the body itself, because the first 19 characters are the message
50474 id followed by <literal>-D</literal> and a newline. If you rewind the file, you should use the
50475 macro SPOOL_DATA_START_OFFSET to reset to the start of the data, just in
50476 case this changes in some future version.
50477 </para>
50478 </listitem>
50479 <listitem>
50480 <para>
50481 <option>return_text</option> is an address which you can use to return a pointer to a text
50482 string at the end of the function. The value it points to on entry is NULL.
50483 </para>
50484 </listitem>
50485 </itemizedlist>
50486 <para>
50487 The function must return an <option>int</option> value which is one of the following macros:
50488 </para>
50489 <variablelist>
50490 <varlistentry>
50491 <term><literal>LOCAL_SCAN_ACCEPT</literal></term>
50492 <listitem>
50493 <para>
50494 <indexterm role="concept">
50495 <primary><varname>$local_scan_data</varname></primary>
50496 </indexterm>
50497 The message is accepted. If you pass back a string of text, it is saved with
50498 the message, and made available in the variable <varname>$local_scan_data</varname>. No
50499 newlines are permitted (if there are any, they are turned into spaces) and the
50500 maximum length of text is 1000 characters.
50501 </para>
50502 </listitem></varlistentry>
50503 <varlistentry>
50504 <term><literal>LOCAL_SCAN_ACCEPT_FREEZE</literal></term>
50505 <listitem>
50506 <para>
50507 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
50508 queued without immediate delivery, and is frozen.
50509 </para>
50510 </listitem></varlistentry>
50511 <varlistentry>
50512 <term><literal>LOCAL_SCAN_ACCEPT_QUEUE</literal></term>
50513 <listitem>
50514 <para>
50515 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
50516 queued without immediate delivery.
50517 </para>
50518 </listitem></varlistentry>
50519 <varlistentry>
50520 <term><literal>LOCAL_SCAN_REJECT</literal></term>
50521 <listitem>
50522 <para>
50523 The message is rejected; the returned text is used as an error message which is
50524 passed back to the sender and which is also logged. Newlines are permitted &ndash;
50525 they cause a multiline response for SMTP rejections, but are converted to
50526 <literal>\n</literal> in log lines. If no message is given, <quote>Administrative prohibition</quote> is
50527 used.
50528 </para>
50529 </listitem></varlistentry>
50530 <varlistentry>
50531 <term><literal>LOCAL_SCAN_TEMPREJECT</literal></term>
50532 <listitem>
50533 <para>
50534 The message is temporarily rejected; the returned text is used as an error
50535 message as for LOCAL_SCAN_REJECT. If no message is given, <quote>Temporary local
50536 problem</quote> is used.
50537 </para>
50538 </listitem></varlistentry>
50539 <varlistentry>
50540 <term><literal>LOCAL_SCAN_REJECT_NOLOGHDR</literal></term>
50541 <listitem>
50542 <para>
50543 This behaves as LOCAL_SCAN_REJECT, except that the header of the rejected
50544 message is not written to the reject log. It has the effect of unsetting the
50545 <option>rejected_header</option> log selector for just this rejection. If
50546 <option>rejected_header</option> is already unset (see the discussion of the
50547 <option>log_selection</option> option in section <xref linkend="SECTlogselector"/>), this code is the
50548 same as LOCAL_SCAN_REJECT.
50549 </para>
50550 </listitem></varlistentry>
50551 <varlistentry>
50552 <term><literal>LOCAL_SCAN_TEMPREJECT_NOLOGHDR</literal></term>
50553 <listitem>
50554 <para>
50555 This code is a variation of LOCAL_SCAN_TEMPREJECT in the same way that
50556 LOCAL_SCAN_REJECT_NOLOGHDR is a variation of LOCAL_SCAN_REJECT.
50557 </para>
50558 </listitem></varlistentry>
50559 </variablelist>
50560 <para>
50561 If the message is not being received by interactive SMTP, rejections are
50562 reported by writing to <option>stderr</option> or by sending an email, as configured by the
50563 <option>-oe</option> command line options.
50564 </para>
50565 </section>
50566 <section id="SECTconoptloc">
50567 <title>Configuration options for local_scan()</title>
50568 <para>
50569 <indexterm role="concept">
50570 <primary><function>local_scan()</function> function</primary>
50571 <secondary>configuration options</secondary>
50572 </indexterm>
50573 It is possible to have option settings in the main configuration file
50574 that set values in static variables in the <function>local_scan()</function> module. If you
50575 want to do this, you must have the line
50576 </para>
50577 <literallayout class="monospaced">
50578 LOCAL_SCAN_HAS_OPTIONS=yes
50579 </literallayout>
50580 <para>
50581 in your <filename>Local/Makefile</filename> when you build Exim. (This line is in
50582 <filename>OS/Makefile-Default</filename>, commented out). Then, in the <function>local_scan()</function> source
50583 file, you must define static variables to hold the option values, and a table
50584 to define them.
50585 </para>
50586 <para>
50587 The table must be a vector called <option>local_scan_options</option>, of type
50588 <literal>optionlist</literal>. Each entry is a triplet, consisting of a name, an option type,
50589 and a pointer to the variable that holds the value. The entries must appear in
50590 alphabetical order. Following <option>local_scan_options</option> you must also define a
50591 variable called <option>local_scan_options_count</option> that contains the number of
50592 entries in the table. Here is a short example, showing two kinds of option:
50593 </para>
50594 <literallayout class="monospaced">
50595 static int my_integer_option = 42;
50596 static uschar *my_string_option = US"a default string";
50597
50598 optionlist local_scan_options[] = {
50599   { "my_integer", opt_int,       &amp;my_integer_option },
50600   { "my_string",  opt_stringptr, &amp;my_string_option }
50601 };
50602
50603 int local_scan_options_count =
50604   sizeof(local_scan_options)/sizeof(optionlist);
50605 </literallayout>
50606 <para>
50607 The values of the variables can now be changed from Exim&#x2019;s runtime
50608 configuration file by including a local scan section as in this example:
50609 </para>
50610 <literallayout class="monospaced">
50611 begin local_scan
50612 my_integer = 99
50613 my_string = some string of text...
50614 </literallayout>
50615 <para>
50616 The available types of option data are as follows:
50617 </para>
50618 <variablelist>
50619 <varlistentry>
50620 <term><emphasis role="bold">opt_bool</emphasis></term>
50621 <listitem>
50622 <para>
50623 This specifies a boolean (true/false) option. The address should point to a
50624 variable of type <literal>BOOL</literal>, which will be set to TRUE or FALSE, which are macros
50625 that are defined as <quote>1</quote> and <quote>0</quote>, respectively. If you want to detect
50626 whether such a variable has been set at all, you can initialize it to
50627 TRUE_UNSET. (BOOL variables are integers underneath, so can hold more than two
50628 values.)
50629 </para>
50630 </listitem></varlistentry>
50631 <varlistentry>
50632 <term><emphasis role="bold">opt_fixed</emphasis></term>
50633 <listitem>
50634 <para>
50635 This specifies a fixed point number, such as is used for load averages.
50636 The address should point to a variable of type <literal>int</literal>. The value is stored
50637 multiplied by 1000, so, for example, 1.4142 is truncated and stored as 1414.
50638 </para>
50639 </listitem></varlistentry>
50640 <varlistentry>
50641 <term><emphasis role="bold">opt_int</emphasis></term>
50642 <listitem>
50643 <para>
50644 This specifies an integer; the address should point to a variable of type
50645 <literal>int</literal>. The value may be specified in any of the integer formats accepted by
50646 Exim.
50647 </para>
50648 </listitem></varlistentry>
50649 <varlistentry>
50650 <term><emphasis role="bold">opt_mkint</emphasis></term>
50651 <listitem>
50652 <para>
50653 This is the same as <option>opt_int</option>, except that when such a value is output in a
50654 <option>-bP</option> listing, if it is an exact number of kilobytes or megabytes, it is
50655 printed with the suffix K or M.
50656 </para>
50657 </listitem></varlistentry>
50658 <varlistentry>
50659 <term><emphasis role="bold">opt_octint</emphasis></term>
50660 <listitem>
50661 <para>
50662 This also specifies an integer, but the value is always interpeted as an
50663 octal integer, whether or not it starts with the digit zero, and it is
50664 always output in octal.
50665 </para>
50666 </listitem></varlistentry>
50667 <varlistentry>
50668 <term><emphasis role="bold">opt_stringptr</emphasis></term>
50669 <listitem>
50670 <para>
50671 This specifies a string value; the address must be a pointer to a
50672 variable that points to a string (for example, of type <literal>uschar *</literal>).
50673 </para>
50674 </listitem></varlistentry>
50675 <varlistentry>
50676 <term><emphasis role="bold">opt_time</emphasis></term>
50677 <listitem>
50678 <para>
50679 This specifies a time interval value. The address must point to a variable of
50680 type <literal>int</literal>. The value that is placed there is a number of seconds.
50681 </para>
50682 </listitem></varlistentry>
50683 </variablelist>
50684 <para>
50685 If the <option>-bP</option> command line option is followed by <literal>local_scan</literal>, Exim prints
50686 out the values of all the <function>local_scan()</function> options.
50687 </para>
50688 </section>
50689 <section>
50690 <title>Available Exim variables</title>
50691 <para>
50692 <indexterm role="concept">
50693 <primary><function>local_scan()</function> function</primary>
50694 <secondary>available Exim variables</secondary>
50695 </indexterm>
50696 The header <filename>local_scan.h</filename> gives you access to a number of C variables. These
50697 are the only ones that are guaranteed to be maintained from release to release.
50698 Note, however, that you can obtain the value of any Exim variable by calling
50699 <emphasis>expand_string()</emphasis>. The exported variables are as follows:
50700 </para>
50701 <variablelist>
50702 <varlistentry>
50703 <term><emphasis role="bold">unsigned&nbsp;int&nbsp;debug_selector</emphasis></term>
50704 <listitem>
50705 <para>
50706 This variable is set to zero when no debugging is taking place. Otherwise, it
50707 is a bitmap of debugging selectors. Two bits are identified for use in
50708 <function>local_scan()</function>; they are defined as macros:
50709 </para>
50710 <itemizedlist>
50711 <listitem>
50712 <para>
50713 The <literal>D_v</literal> bit is set when <option>-v</option> was present on the command line. This is a
50714 testing option that is not privileged &ndash; any caller may set it. All the
50715 other selector bits can be set only by admin users.
50716 </para>
50717 </listitem>
50718 <listitem>
50719 <para>
50720 The <literal>D_local_scan</literal> bit is provided for use by <function>local_scan()</function>; it is set
50721 by the <literal>+local_scan</literal> debug selector. It is not included in the default set
50722 of debugging bits.
50723 </para>
50724 </listitem>
50725 </itemizedlist>
50726 <para>
50727 Thus, to write to the debugging output only when <literal>+local_scan</literal> has been
50728 selected, you should use code like this:
50729 </para>
50730 <literallayout class="monospaced">
50731 if ((debug_selector &amp; D_local_scan) != 0)
50732   debug_printf("xxx", ...);
50733 </literallayout>
50734 </listitem></varlistentry>
50735 <varlistentry>
50736 <term><emphasis role="bold">uschar&nbsp;*expand_string_message</emphasis></term>
50737 <listitem>
50738 <para>
50739 After a failing call to <emphasis>expand_string()</emphasis> (returned value NULL), the
50740 variable <option>expand_string_message</option> contains the error message, zero-terminated.
50741 </para>
50742 </listitem></varlistentry>
50743 <varlistentry>
50744 <term><emphasis role="bold">header_line&nbsp;*header_list</emphasis></term>
50745 <listitem>
50746 <para>
50747 A pointer to a chain of header lines. The <option>header_line</option> structure is
50748 discussed below.
50749 </para>
50750 </listitem></varlistentry>
50751 <varlistentry>
50752 <term><emphasis role="bold">header_line&nbsp;*header_last</emphasis></term>
50753 <listitem>
50754 <para>
50755 A pointer to the last of the header lines.
50756 </para>
50757 </listitem></varlistentry>
50758 <varlistentry>
50759 <term><emphasis role="bold">uschar&nbsp;*headers_charset</emphasis></term>
50760 <listitem>
50761 <para>
50762 The value of the <option>headers_charset</option> configuration option.
50763 </para>
50764 </listitem></varlistentry>
50765 <varlistentry>
50766 <term><emphasis role="bold">BOOL&nbsp;host_checking</emphasis></term>
50767 <listitem>
50768 <para>
50769 This variable is TRUE during a host checking session that is initiated by the
50770 <option>-bh</option> command line option.
50771 </para>
50772 </listitem></varlistentry>
50773 <varlistentry>
50774 <term><emphasis role="bold">uschar&nbsp;*interface_address</emphasis></term>
50775 <listitem>
50776 <para>
50777 The IP address of the interface that received the message, as a string. This
50778 is NULL for locally submitted messages.
50779 </para>
50780 </listitem></varlistentry>
50781 <varlistentry>
50782 <term><emphasis role="bold">int&nbsp;interface_port</emphasis></term>
50783 <listitem>
50784 <para>
50785 The port on which this message was received.
50786 </para>
50787 </listitem></varlistentry>
50788 <varlistentry>
50789 <term><emphasis role="bold">uschar&nbsp;*message_id</emphasis></term>
50790 <listitem>
50791 <para>
50792 This variable contains Exim&#x2019;s message id for the incoming message (the value of
50793 <varname>$message_exim_id</varname>) as a zero-terminated string.
50794 </para>
50795 </listitem></varlistentry>
50796 <varlistentry>
50797 <term><emphasis role="bold">uschar&nbsp;*received_protocol</emphasis></term>
50798 <listitem>
50799 <para>
50800 The name of the protocol by which the message was received.
50801 </para>
50802 </listitem></varlistentry>
50803 <varlistentry>
50804 <term><emphasis role="bold">int&nbsp;recipients_count</emphasis></term>
50805 <listitem>
50806 <para>
50807 The number of accepted recipients.
50808 </para>
50809 </listitem></varlistentry>
50810 <varlistentry>
50811 <term><emphasis role="bold">recipient_item&nbsp;*recipients_list</emphasis></term>
50812 <listitem>
50813 <para>
50814 <indexterm role="concept">
50815 <primary>recipient</primary>
50816 <secondary>adding in local scan</secondary>
50817 </indexterm>
50818 <indexterm role="concept">
50819 <primary>recipient</primary>
50820 <secondary>removing in local scan</secondary>
50821 </indexterm>
50822 The list of accepted recipients, held in a vector of length
50823 <option>recipients_count</option>. The <option>recipient_item</option> structure is discussed below. You
50824 can add additional recipients by calling <emphasis>receive_add_recipient()</emphasis> (see
50825 below). You can delete recipients by removing them from the vector and adusting
50826 the value in <option>recipients_count</option>. In particular, by setting
50827 <option>recipients_count</option> to zero you remove all recipients. If you then return the
50828 value <literal>LOCAL_SCAN_ACCEPT</literal>, the message is accepted, but immediately
50829 blackholed. To replace the recipients, you can set <option>recipients_count</option> to zero
50830 and then call <emphasis>receive_add_recipient()</emphasis> as often as needed.
50831 </para>
50832 </listitem></varlistentry>
50833 <varlistentry>
50834 <term><emphasis role="bold">uschar&nbsp;*sender_address</emphasis></term>
50835 <listitem>
50836 <para>
50837 The envelope sender address. For bounce messages this is the empty string.
50838 </para>
50839 </listitem></varlistentry>
50840 <varlistentry>
50841 <term><emphasis role="bold">uschar&nbsp;*sender_host_address</emphasis></term>
50842 <listitem>
50843 <para>
50844 The IP address of the sending host, as a string. This is NULL for
50845 locally-submitted messages.
50846 </para>
50847 </listitem></varlistentry>
50848 <varlistentry>
50849 <term><emphasis role="bold">uschar&nbsp;*sender_host_authenticated</emphasis></term>
50850 <listitem>
50851 <para>
50852 The name of the authentication mechanism that was used, or NULL if the message
50853 was not received over an authenticated SMTP connection.
50854 </para>
50855 </listitem></varlistentry>
50856 <varlistentry>
50857 <term><emphasis role="bold">uschar&nbsp;*sender_host_name</emphasis></term>
50858 <listitem>
50859 <para>
50860 The name of the sending host, if known.
50861 </para>
50862 </listitem></varlistentry>
50863 <varlistentry>
50864 <term><emphasis role="bold">int&nbsp;sender_host_port</emphasis></term>
50865 <listitem>
50866 <para>
50867 The port on the sending host.
50868 </para>
50869 </listitem></varlistentry>
50870 <varlistentry>
50871 <term><emphasis role="bold">BOOL&nbsp;smtp_input</emphasis></term>
50872 <listitem>
50873 <para>
50874 This variable is TRUE for all SMTP input, including BSMTP.
50875 </para>
50876 </listitem></varlistentry>
50877 <varlistentry>
50878 <term><emphasis role="bold">BOOL&nbsp;smtp_batched_input</emphasis></term>
50879 <listitem>
50880 <para>
50881 This variable is TRUE for BSMTP input.
50882 </para>
50883 </listitem></varlistentry>
50884 <varlistentry>
50885 <term><emphasis role="bold">int&nbsp;store_pool</emphasis></term>
50886 <listitem>
50887 <para>
50888 The contents of this variable control which pool of memory is used for new
50889 requests. See section <xref linkend="SECTmemhanloc"/> for details.
50890 </para>
50891 </listitem></varlistentry>
50892 </variablelist>
50893 </section>
50894 <section>
50895 <title>Structure of header lines</title>
50896 <para>
50897 The <option>header_line</option> structure contains the members listed below.
50898 You can add additional header lines by calling the <emphasis>header_add()</emphasis> function
50899 (see below). You can cause header lines to be ignored (deleted) by setting
50900 their type to *.
50901 </para>
50902 <variablelist>
50903 <varlistentry>
50904 <term><emphasis role="bold">struct&nbsp;header_line&nbsp;*next</emphasis></term>
50905 <listitem>
50906 <para>
50907 A pointer to the next header line, or NULL for the last line.
50908 </para>
50909 </listitem></varlistentry>
50910 <varlistentry>
50911 <term><emphasis role="bold">int&nbsp;type</emphasis></term>
50912 <listitem>
50913 <para>
50914 A code identifying certain headers that Exim recognizes. The codes are printing
50915 characters, and are documented in chapter <xref linkend="CHAPspool"/> of this manual.
50916 Notice in particular that any header line whose type is * is not transmitted
50917 with the message. This flagging is used for header lines that have been
50918 rewritten, or are to be removed (for example, <emphasis>Envelope-sender:</emphasis> header
50919 lines.) Effectively, * means <quote>deleted</quote>.
50920 </para>
50921 </listitem></varlistentry>
50922 <varlistentry>
50923 <term><emphasis role="bold">int&nbsp;slen</emphasis></term>
50924 <listitem>
50925 <para>
50926 The number of characters in the header line, including the terminating and any
50927 internal newlines.
50928 </para>
50929 </listitem></varlistentry>
50930 <varlistentry>
50931 <term><emphasis role="bold">uschar&nbsp;*text</emphasis></term>
50932 <listitem>
50933 <para>
50934 A pointer to the text of the header. It always ends with a newline, followed by
50935 a zero byte. Internal newlines are preserved.
50936 </para>
50937 </listitem></varlistentry>
50938 </variablelist>
50939 </section>
50940 <section>
50941 <title>Structure of recipient items</title>
50942 <para>
50943 The <option>recipient_item</option> structure contains these members:
50944 </para>
50945 <variablelist>
50946 <varlistentry>
50947 <term><emphasis role="bold">uschar&nbsp;*address</emphasis></term>
50948 <listitem>
50949 <para>
50950 This is a pointer to the recipient address as it was received.
50951 </para>
50952 </listitem></varlistentry>
50953 <varlistentry>
50954 <term><emphasis role="bold">int&nbsp;pno</emphasis></term>
50955 <listitem>
50956 <para>
50957 This is used in later Exim processing when top level addresses are created by
50958 the <option>one_time</option> option. It is not relevant at the time <function>local_scan()</function> is run
50959 and must always contain -1 at this stage.
50960 </para>
50961 </listitem></varlistentry>
50962 <varlistentry>
50963 <term><emphasis role="bold">uschar&nbsp;*errors_to</emphasis></term>
50964 <listitem>
50965 <para>
50966 If this value is not NULL, bounce messages caused by failing to deliver to the
50967 recipient are sent to the address it contains. In other words, it overrides the
50968 envelope sender for this one recipient. (Compare the <option>errors_to</option> generic
50969 router option.) If a <function>local_scan()</function> function sets an <option>errors_to</option> field to
50970 an unqualified address, Exim qualifies it using the domain from
50971 <option>qualify_recipient</option>. When <function>local_scan()</function> is called, the <option>errors_to</option> field
50972 is NULL for all recipients.
50973 </para>
50974 </listitem></varlistentry>
50975 </variablelist>
50976 </section>
50977 <section>
50978 <title>Available Exim functions</title>
50979 <para>
50980 <indexterm role="concept">
50981 <primary><function>local_scan()</function> function</primary>
50982 <secondary>available Exim functions</secondary>
50983 </indexterm>
50984 The header <filename>local_scan.h</filename> gives you access to a number of Exim functions.
50985 These are the only ones that are guaranteed to be maintained from release to
50986 release:
50987 </para>
50988 <variablelist>
50989 <varlistentry>
50990 <term><emphasis role="bold">pid_t&nbsp;child_open(uschar&nbsp;**argv,&nbsp;uschar&nbsp;**envp,&nbsp;int&nbsp;newumask,&nbsp;int&nbsp;*infdptr,&nbsp;int&nbsp;*outfdptr, &nbsp;&nbsp;BOOL&nbsp;make_leader)</emphasis></term>
50991 <listitem>
50992 <para>
50993 This function creates a child process that runs the command specified by
50994 <option>argv</option>. The environment for the process is specified by <option>envp</option>, which can
50995 be NULL if no environment variables are to be passed. A new umask is supplied
50996 for the process in <option>newumask</option>.
50997 </para>
50998 <para>
50999 Pipes to the standard input and output of the new process are set up
51000 and returned to the caller via the <option>infdptr</option> and <option>outfdptr</option> arguments. The
51001 standard error is cloned to the standard output. If there are any file
51002 descriptors <quote>in the way</quote> in the new process, they are closed. If the final
51003 argument is TRUE, the new process is made into a process group leader.
51004 </para>
51005 <para>
51006 The function returns the pid of the new process, or -1 if things go wrong.
51007 </para>
51008 </listitem></varlistentry>
51009 <varlistentry>
51010 <term><emphasis role="bold">int&nbsp;child_close(pid_t&nbsp;pid,&nbsp;int&nbsp;timeout)</emphasis></term>
51011 <listitem>
51012 <para>
51013 This function waits for a child process to terminate, or for a timeout (in
51014 seconds) to expire. A timeout value of zero means wait as long as it takes. The
51015 return value is as follows:
51016 </para>
51017 <itemizedlist>
51018 <listitem>
51019 <para>
51020 &gt;= 0
51021 </para>
51022 <para>
51023 The process terminated by a normal exit and the value is the process
51024 ending status.
51025 </para>
51026 </listitem>
51027 <listitem>
51028 <para>
51029 &lt; 0 and &gt; &ndash;256
51030 </para>
51031 <para>
51032 The process was terminated by a signal and the value is the negation of the
51033 signal number.
51034 </para>
51035 </listitem>
51036 <listitem>
51037 <para>
51038 &ndash;256
51039 </para>
51040 <para>
51041 The process timed out.
51042 </para>
51043 </listitem>
51044 <listitem>
51045 <para>
51046 &ndash;257
51047 </para>
51048 <para>
51049 The was some other error in wait(); <option>errno</option> is still set.
51050 </para>
51051 </listitem>
51052 </itemizedlist>
51053 </listitem></varlistentry>
51054 <varlistentry>
51055 <term><emphasis role="bold">pid_t&nbsp;child_open_exim(int&nbsp;*fd)</emphasis></term>
51056 <listitem>
51057 <para>
51058 This function provide you with a means of submitting a new message to
51059 Exim. (Of course, you can also call <filename>/usr/sbin/sendmail</filename> yourself if you
51060 want, but this packages it all up for you.) The function creates a pipe,
51061 forks a subprocess that is running
51062 </para>
51063 <literallayout class="monospaced">
51064 exim -t -oem -oi -f &lt;&gt;
51065 </literallayout>
51066 <para>
51067 and returns to you (via the <literal>int *</literal> argument) a file descriptor for the pipe
51068 that is connected to the standard input. The yield of the function is the PID
51069 of the subprocess. You can then write a message to the file descriptor, with
51070 recipients in <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>, and/or <emphasis>Bcc:</emphasis> header lines.
51071 </para>
51072 <para>
51073 When you have finished, call <emphasis>child_close()</emphasis> to wait for the process to
51074 finish and to collect its ending status. A timeout value of zero is usually
51075 fine in this circumstance. Unless you have made a mistake with the recipient
51076 addresses, you should get a return code of zero.
51077 </para>
51078 </listitem></varlistentry>
51079 <varlistentry revisionflag="changed">
51080 <term><emphasis role="bold">pid_t&nbsp;child_open_exim2(int&nbsp;*fd,&nbsp;uschar&nbsp;*sender,&nbsp;uschar&nbsp;*sender_authentication)</emphasis></term>
51081 <listitem>
51082 <para revisionflag="changed">
51083 This function is a more sophisticated version of <emphasis>child_open()</emphasis>. The command
51084 that it runs is:
51085 </para>
51086 <literallayout revisionflag="changed">
51087 <literal>exim -t -oem -oi -f </literal><emphasis>sender</emphasis><literal> -oMas </literal><emphasis>sender_authentication</emphasis>
51088 </literallayout>
51089 <para revisionflag="changed">
51090 The third argument may be NULL, in which case the <option>-oMas</option> option is omitted.
51091 </para>
51092 </listitem></varlistentry>
51093 <varlistentry>
51094 <term><emphasis role="bold">void&nbsp;debug_printf(char&nbsp;*,&nbsp;...)</emphasis></term>
51095 <listitem>
51096 <para>
51097 This is Exim&#x2019;s debugging function, with arguments as for <emphasis>(printf()</emphasis>. The
51098 output is written to the standard error stream. If no debugging is selected,
51099 calls to <emphasis>debug_printf()</emphasis> have no effect. Normally, you should make calls
51100 conditional on the <literal>local_scan</literal> debug selector by coding like this:
51101 </para>
51102 <literallayout class="monospaced">
51103 if ((debug_selector &amp; D_local_scan) != 0)
51104   debug_printf("xxx", ...);
51105 </literallayout>
51106 </listitem></varlistentry>
51107 <varlistentry>
51108 <term><emphasis role="bold">uschar&nbsp;*expand_string(uschar&nbsp;*string)</emphasis></term>
51109 <listitem>
51110 <para>
51111 This is an interface to Exim&#x2019;s string expansion code. The return value is the
51112 expanded string, or NULL if there was an expansion failure.
51113 The C variable <option>expand_string_message</option> contains an error message after an
51114 expansion failure. If expansion does not change the string, the return value is
51115 the pointer to the input string. Otherwise, the return value points to a new
51116 block of memory that was obtained by a call to <emphasis>store_get()</emphasis>. See section
51117 <xref linkend="SECTmemhanloc"/> below for a discussion of memory handling.
51118 </para>
51119 </listitem></varlistentry>
51120 <varlistentry>
51121 <term><emphasis role="bold">void&nbsp;header_add(int&nbsp;type,&nbsp;char&nbsp;*format,&nbsp;...)</emphasis></term>
51122 <listitem>
51123 <para>
51124 This function allows you to an add additional header line at the end of the
51125 existing ones. The first argument is the type, and should normally be a space
51126 character. The second argument is a format string and any number of
51127 substitution arguments as for <function>sprintf()</function>. You may include internal newlines
51128 if you want, and you must ensure that the string ends with a newline.
51129 </para>
51130 </listitem></varlistentry>
51131 <varlistentry>
51132 <term><emphasis role="bold">void&nbsp;header_add_at_position(BOOL&nbsp;after,&nbsp;uschar&nbsp;*name,&nbsp;BOOL&nbsp;topnot,&nbsp;int&nbsp;type,&nbsp;char&nbsp;*format, &nbsp;&nbsp;...)</emphasis></term>
51133 <listitem>
51134 <para>
51135 This function adds a new header line at a specified point in the header
51136 chain. The header itself is specified as for <emphasis>header_add()</emphasis>.
51137 </para>
51138 <para>
51139 If <option>name</option> is NULL, the new header is added at the end of the chain if
51140 <option>after</option> is true, or at the start if <option>after</option> is false. If <option>name</option> is not
51141 NULL, the header lines are searched for the first non-deleted header that
51142 matches the name. If one is found, the new header is added before it if
51143 <option>after</option> is false. If <option>after</option> is true, the new header is added after the
51144 found header and any adjacent subsequent ones with the same name (even if
51145 marked <quote>deleted</quote>). If no matching non-deleted header is found, the <option>topnot</option>
51146 option controls where the header is added. If it is true, addition is at the
51147 top; otherwise at the bottom. Thus, to add a header after all the <emphasis>Received:</emphasis>
51148 headers, or at the top if there are no <emphasis>Received:</emphasis> headers, you could use
51149 </para>
51150 <literallayout class="monospaced">
51151 header_add_at_position(TRUE, US"Received", TRUE,
51152   ' ', "X-xxx: ...");
51153 </literallayout>
51154 <para>
51155 Normally, there is always at least one non-deleted <emphasis>Received:</emphasis> header, but
51156 there may not be if <option>received_header_text</option> expands to an empty string.
51157 </para>
51158 </listitem></varlistentry>
51159 <varlistentry>
51160 <term><emphasis role="bold">void&nbsp;header_remove(int&nbsp;occurrence,&nbsp;uschar&nbsp;*name)</emphasis></term>
51161 <listitem>
51162 <para>
51163 This function removes header lines. If <option>occurrence</option> is zero or negative, all
51164 occurrences of the header are removed. If occurrence is greater than zero, that
51165 particular instance of the header is removed. If no header(s) can be found that
51166 match the specification, the function does nothing.
51167 </para>
51168 </listitem></varlistentry>
51169 <varlistentry>
51170 <term><emphasis role="bold">BOOL&nbsp;header_testname(header_line&nbsp;*hdr,&nbsp;uschar&nbsp;*name,&nbsp;int&nbsp;length,&nbsp;BOOL&nbsp;notdel)</emphasis></term>
51171 <listitem>
51172 <para>
51173 This function tests whether the given header has the given name. It is not just
51174 a string comparison, because white space is permitted between the name and the
51175 colon. If the <option>notdel</option> argument is true, a false return is forced for all
51176 <quote>deleted</quote> headers; otherwise they are not treated specially. For example:
51177 </para>
51178 <literallayout class="monospaced">
51179 if (header_testname(h, US"X-Spam", 6, TRUE)) ...
51180 </literallayout>
51181 </listitem></varlistentry>
51182 <varlistentry>
51183 <term><emphasis role="bold">uschar&nbsp;*lss_b64encode(uschar&nbsp;*cleartext,&nbsp;int&nbsp;length)</emphasis></term>
51184 <listitem>
51185 <para>
51186 <indexterm role="concept">
51187 <primary>base64 encoding</primary>
51188 <secondary>functions for <function>local_scan()</function> use</secondary>
51189 </indexterm>
51190 This function base64-encodes a string, which is passed by address and length.
51191 The text may contain bytes of any value, including zero. The result is passed
51192 back in dynamic memory that is obtained by calling <emphasis>store_get()</emphasis>. It is
51193 zero-terminated.
51194 </para>
51195 </listitem></varlistentry>
51196 <varlistentry>
51197 <term><emphasis role="bold">int&nbsp;lss_b64decode(uschar&nbsp;*codetext,&nbsp;uschar&nbsp;**cleartext)</emphasis></term>
51198 <listitem>
51199 <para>
51200 This function decodes a base64-encoded string. Its arguments are a
51201 zero-terminated base64-encoded string and the address of a variable that is set
51202 to point to the result, which is in dynamic memory. The length of the decoded
51203 string is the yield of the function. If the input is invalid base64 data, the
51204 yield is -1. A zero byte is added to the end of the output string to make it
51205 easy to interpret as a C string (assuming it contains no zeros of its own). The
51206 added zero byte is not included in the returned count.
51207 </para>
51208 </listitem></varlistentry>
51209 <varlistentry>
51210 <term><emphasis role="bold">int&nbsp;lss_match_domain(uschar&nbsp;*domain,&nbsp;uschar&nbsp;*list)</emphasis></term>
51211 <listitem>
51212 <para>
51213 This function checks for a match in a domain list. Domains are always
51214 matched caselessly. The return value is one of the following:
51215 </para>
51216 <literallayout>
51217 <literal>OK     </literal> match succeeded
51218 <literal>FAIL   </literal> match failed
51219 <literal>DEFER  </literal> match deferred
51220 </literallayout>
51221 <para>
51222 DEFER is usually caused by some kind of lookup defer, such as the
51223 inability to contact a database.
51224 </para>
51225 </listitem></varlistentry>
51226 <varlistentry>
51227 <term><emphasis role="bold">int&nbsp;lss_match_local_part(uschar&nbsp;*localpart,&nbsp;uschar&nbsp;*list,&nbsp;BOOL&nbsp;caseless)</emphasis></term>
51228 <listitem>
51229 <para>
51230 This function checks for a match in a local part list. The third argument
51231 controls case-sensitivity. The return values are as for
51232 <emphasis>lss_match_domain()</emphasis>.
51233 </para>
51234 </listitem></varlistentry>
51235 <varlistentry>
51236 <term><emphasis role="bold">int&nbsp;lss_match_address(uschar&nbsp;*address,&nbsp;uschar&nbsp;*list,&nbsp;BOOL&nbsp;caseless)</emphasis></term>
51237 <listitem>
51238 <para>
51239 This function checks for a match in an address list. The third argument
51240 controls the case-sensitivity of the local part match. The domain is always
51241 matched caselessly. The return values are as for <emphasis>lss_match_domain()</emphasis>.
51242 </para>
51243 </listitem></varlistentry>
51244 <varlistentry>
51245 <term><emphasis role="bold">int&nbsp;lss_match_host(uschar&nbsp;*host_name,&nbsp;uschar&nbsp;*host_address,&nbsp;uschar&nbsp;*list)</emphasis></term>
51246 <listitem>
51247 <para>
51248 This function checks for a match in a host list. The most common usage is
51249 expected to be
51250 </para>
51251 <literallayout class="monospaced">
51252 lss_match_host(sender_host_name, sender_host_address, ...)
51253 </literallayout>
51254 <para>
51255 <indexterm role="concept">
51256 <primary><varname>$sender_host_address</varname></primary>
51257 </indexterm>
51258 An empty address field matches an empty item in the host list. If the host name
51259 is NULL, the name corresponding to <varname>$sender_host_address</varname> is automatically
51260 looked up if a host name is required to match an item in the list. The return
51261 values are as for <emphasis>lss_match_domain()</emphasis>, but in addition, <emphasis>lss_match_host()</emphasis>
51262 returns ERROR in the case when it had to look up a host name, but the lookup
51263 failed.
51264 </para>
51265 </listitem></varlistentry>
51266 <varlistentry>
51267 <term><emphasis role="bold">void&nbsp;log_write(unsigned&nbsp;int&nbsp;selector,&nbsp;int&nbsp;which,&nbsp;char&nbsp;*format,&nbsp;...)</emphasis></term>
51268 <listitem>
51269 <para>
51270 This function writes to Exim&#x2019;s log files. The first argument should be zero (it
51271 is concerned with <option>log_selector</option>). The second argument can be <literal>LOG_MAIN</literal> or
51272 <literal>LOG_REJECT</literal> or <literal>LOG_PANIC</literal> or the inclusive <quote>or</quote> of any combination of
51273 them. It specifies to which log or logs the message is written. The remaining
51274 arguments are a format and relevant insertion arguments. The string should not
51275 contain any newlines, not even at the end.
51276 </para>
51277 </listitem></varlistentry>
51278 <varlistentry>
51279 <term><emphasis role="bold">void&nbsp;receive_add_recipient(uschar&nbsp;*address,&nbsp;int&nbsp;pno)</emphasis></term>
51280 <listitem>
51281 <para>
51282 This function adds an additional recipient to the message. The first argument
51283 is the recipient address. If it is unqualified (has no domain), it is qualified
51284 with the <option>qualify_recipient</option> domain. The second argument must always be -1.
51285 </para>
51286 <para>
51287 This function does not allow you to specify a private <option>errors_to</option> address (as
51288 described with the structure of <option>recipient_item</option> above), because it pre-dates
51289 the addition of that field to the structure. However, it is easy to add such a
51290 value afterwards. For example:
51291 </para>
51292 <literallayout class="monospaced">
51293 receive_add_recipient(US"monitor@mydom.example", -1);
51294 recipients_list[recipients_count-1].errors_to =
51295 US"postmaster@mydom.example";
51296 </literallayout>
51297 </listitem></varlistentry>
51298 <varlistentry>
51299 <term><emphasis role="bold">BOOL&nbsp;receive_remove_recipient(uschar&nbsp;*recipient)</emphasis></term>
51300 <listitem>
51301 <para>
51302 This is a convenience function to remove a named recipient from the list of
51303 recipients. It returns true if a recipient was removed, and false if no
51304 matching recipient could be found. The argument must be a complete email
51305 address.
51306 </para>
51307 </listitem></varlistentry>
51308 </variablelist>
51309 <para>
51310 <indexterm role="concept">
51311 <primary>RFC 2047</primary>
51312 </indexterm>
51313 </para>
51314 <variablelist>
51315 <varlistentry>
51316 <term><emphasis role="bold">uschar&nbsp;rfc2047_decode(uschar&nbsp;*string,&nbsp;BOOL&nbsp;lencheck,&nbsp;uschar&nbsp;*target,&nbsp;int&nbsp;zeroval,&nbsp;int&nbsp;*lenptr, &nbsp;&nbsp;uschar&nbsp;**error)</emphasis></term>
51317 <listitem>
51318 <para>
51319 This function decodes strings that are encoded according to RFC 2047. Typically
51320 these are the contents of header lines. First, each <quote>encoded word</quote> is decoded
51321 from the Q or B encoding into a byte-string. Then, if provided with the name of
51322 a charset encoding, and if the <function>iconv()</function> function is available, an attempt is
51323 made  to translate the result to the named character set. If this fails, the
51324 binary string is returned with an error message.
51325 </para>
51326 <para>
51327 The first argument is the string to be decoded. If <option>lencheck</option> is TRUE, the
51328 maximum MIME word length is enforced. The third argument is the target
51329 encoding, or NULL if no translation is wanted.
51330 </para>
51331 <para>
51332 <indexterm role="concept">
51333 <primary>binary zero</primary>
51334 <secondary>in RFC 2047 decoding</secondary>
51335 </indexterm>
51336 <indexterm role="concept">
51337 <primary>RFC 2047</primary>
51338 <secondary>binary zero in</secondary>
51339 </indexterm>
51340 If a binary zero is encountered in the decoded string, it is replaced by the
51341 contents of the <option>zeroval</option> argument. For use with Exim headers, the value must
51342 not be 0 because header lines are handled as zero-terminated strings.
51343 </para>
51344 <para>
51345 The function returns the result of processing the string, zero-terminated; if
51346 <option>lenptr</option> is not NULL, the length of the result is set in the variable to
51347 which it points. When <option>zeroval</option> is 0, <option>lenptr</option> should not be NULL.
51348 </para>
51349 <para>
51350 If an error is encountered, the function returns NULL and uses the <option>error</option>
51351 argument to return an error message. The variable pointed to by <option>error</option> is
51352 set to NULL if there is no error; it may be set non-NULL even when the function
51353 returns a non-NULL value if decoding was successful, but there was a problem
51354 with translation.
51355 </para>
51356 </listitem></varlistentry>
51357 <varlistentry>
51358 <term><emphasis role="bold">int&nbsp;smtp_fflush(void)</emphasis></term>
51359 <listitem>
51360 <para>
51361 This function is used in conjunction with <emphasis>smtp_printf()</emphasis>, as described
51362 below.
51363 </para>
51364 </listitem></varlistentry>
51365 <varlistentry>
51366 <term><emphasis role="bold">void&nbsp;smtp_printf(char&nbsp;*,&nbsp;...)</emphasis></term>
51367 <listitem>
51368 <para>
51369 The arguments of this function are like <function>printf()</function>; it writes to the SMTP
51370 output stream. You should use this function only when there is an SMTP output
51371 stream, that is, when the incoming message is being received via interactive
51372 SMTP. This is the case when <option>smtp_input</option> is TRUE and <option>smtp_batched_input</option>
51373 is FALSE. If you want to test for an incoming message from another host (as
51374 opposed to a local process that used the <option>-bs</option> command line option), you can
51375 test the value of <option>sender_host_address</option>, which is non-NULL when a remote host
51376 is involved.
51377 </para>
51378 <para>
51379 If an SMTP TLS connection is established, <emphasis>smtp_printf()</emphasis> uses the TLS
51380 output function, so it can be used for all forms of SMTP connection.
51381 </para>
51382 <para>
51383 Strings that are written by <emphasis>smtp_printf()</emphasis> from within <function>local_scan()</function>
51384 must start with an appropriate response code: 550 if you are going to return
51385 LOCAL_SCAN_REJECT, 451 if you are going to return
51386 LOCAL_SCAN_TEMPREJECT, and 250 otherwise. Because you are writing the
51387 initial lines of a multi-line response, the code must be followed by a hyphen
51388 to indicate that the line is not the final response line. You must also ensure
51389 that the lines you write terminate with CRLF. For example:
51390 </para>
51391 <literallayout class="monospaced">
51392 smtp_printf("550-this is some extra info\r\n");
51393 return LOCAL_SCAN_REJECT;
51394 </literallayout>
51395 <para>
51396 Note that you can also create multi-line responses by including newlines in
51397 the data returned via the <option>return_text</option> argument. The added value of using
51398 <emphasis>smtp_printf()</emphasis> is that, for instance, you could introduce delays between
51399 multiple output lines.
51400 </para>
51401 <para>
51402 The <emphasis>smtp_printf()</emphasis> function does not return any error indication, because it
51403 does not automatically flush pending output, and therefore does not test
51404 the state of the stream. (In the main code of Exim, flushing and error
51405 detection is done when Exim is ready for the next SMTP input command.) If
51406 you want to flush the output and check for an error (for example, the
51407 dropping of a TCP/IP connection), you can call <emphasis>smtp_fflush()</emphasis>, which has no
51408 arguments. It flushes the output stream, and returns a non-zero value if there
51409 is an error.
51410 </para>
51411 </listitem></varlistentry>
51412 <varlistentry>
51413 <term><emphasis role="bold">void&nbsp;*store_get(int)</emphasis></term>
51414 <listitem>
51415 <para>
51416 This function accesses Exim&#x2019;s internal store (memory) manager. It gets a new
51417 chunk of memory whose size is given by the argument. Exim bombs out if it ever
51418 runs out of memory. See the next section for a discussion of memory handling.
51419 </para>
51420 </listitem></varlistentry>
51421 <varlistentry>
51422 <term><emphasis role="bold">void&nbsp;*store_get_perm(int)</emphasis></term>
51423 <listitem>
51424 <para>
51425 This function is like <emphasis>store_get()</emphasis>, but it always gets memory from the
51426 permanent pool. See the next section for a discussion of memory handling.
51427 </para>
51428 </listitem></varlistentry>
51429 <varlistentry>
51430 <term><emphasis role="bold">uschar&nbsp;*string_copy(uschar&nbsp;*string)</emphasis></term>
51431 <listitem>
51432 <para>
51433 See below.
51434 </para>
51435 </listitem></varlistentry>
51436 <varlistentry>
51437 <term><emphasis role="bold">uschar&nbsp;*string_copyn(uschar&nbsp;*string,&nbsp;int&nbsp;length)</emphasis></term>
51438 <listitem>
51439 <para>
51440 See below.
51441 </para>
51442 </listitem></varlistentry>
51443 <varlistentry>
51444 <term><emphasis role="bold">uschar&nbsp;*string_sprintf(char&nbsp;*format,&nbsp;...)</emphasis></term>
51445 <listitem>
51446 <para>
51447 These three functions create strings using Exim&#x2019;s dynamic memory facilities.
51448 The first makes a copy of an entire string. The second copies up to a maximum
51449 number of characters, indicated by the second argument. The third uses a format
51450 and insertion arguments to create a new string. In each case, the result is a
51451 pointer to a new string in the current memory pool. See the next section for
51452 more discussion.
51453 </para>
51454 </listitem></varlistentry>
51455 </variablelist>
51456 </section>
51457 <section id="SECTmemhanloc">
51458 <title>More about Exim&#x2019;s memory handling</title>
51459 <para>
51460 <indexterm role="concept">
51461 <primary><function>local_scan()</function> function</primary>
51462 <secondary>memory handling</secondary>
51463 </indexterm>
51464 No function is provided for freeing memory, because that is never needed.
51465 The dynamic memory that Exim uses when receiving a message is automatically
51466 recycled if another message is received by the same process (this applies only
51467 to incoming SMTP connections &ndash; other input methods can supply only one
51468 message at a time). After receiving the last message, a reception process
51469 terminates.
51470 </para>
51471 <para>
51472 Because it is recycled, the normal dynamic memory cannot be used for holding
51473 data that must be preserved over a number of incoming messages on the same SMTP
51474 connection. However, Exim in fact uses two pools of dynamic memory; the second
51475 one is not recycled, and can be used for this purpose.
51476 </para>
51477 <para>
51478 If you want to allocate memory that remains available for subsequent messages
51479 in the same SMTP connection, you should set
51480 </para>
51481 <literallayout class="monospaced">
51482 store_pool = POOL_PERM
51483 </literallayout>
51484 <para>
51485 before calling the function that does the allocation. There is no need to
51486 restore the value if you do not need to; however, if you do want to revert to
51487 the normal pool, you can either restore the previous value of <option>store_pool</option> or
51488 set it explicitly to POOL_MAIN.
51489 </para>
51490 <para>
51491 The pool setting applies to all functions that get dynamic memory, including
51492 <emphasis>expand_string()</emphasis>, <emphasis>store_get()</emphasis>, and the <emphasis>string_xxx()</emphasis> functions.
51493 There is also a convenience function called <emphasis>store_get_perm()</emphasis> that gets a
51494 block of memory from the permanent pool while preserving the value of
51495 <option>store_pool</option>.
51496 <indexterm role="concept" startref="IIDlosca" class="endofrange"/>
51497 </para>
51498 </section>
51499 </chapter>
51500
51501 <chapter id="CHAPsystemfilter">
51502 <title>System-wide message filtering</title>
51503 <para>
51504 <indexterm role="concept" id="IIDsysfil1" class="startofrange">
51505 <primary>filter</primary>
51506 <secondary>system filter</secondary>
51507 </indexterm>
51508 <indexterm role="concept" id="IIDsysfil2" class="startofrange">
51509 <primary>filtering all mail</primary>
51510 </indexterm>
51511 <indexterm role="concept" id="IIDsysfil3" class="startofrange">
51512 <primary>system filter</primary>
51513 </indexterm>
51514 The previous chapters (on ACLs and the local scan function) describe checks
51515 that can be applied to messages before they are accepted by a host. There is
51516 also a mechanism for checking messages once they have been received, but before
51517 they are delivered. This is called the <emphasis>system filter</emphasis>.
51518 </para>
51519 <para>
51520 The system filter operates in a similar manner to users&#x2019; filter files, but it
51521 is run just once per message (however many recipients the message has).
51522 It should not normally be used as a substitute for routing, because <option>deliver</option>
51523 commands in a system router provide new envelope recipient addresses.
51524 The system filter must be an Exim filter. It cannot be a Sieve filter.
51525 </para>
51526 <para>
51527 The system filter is run at the start of a delivery attempt, before any routing
51528 is done. If a message fails to be completely delivered at the first attempt,
51529 the system filter is run again at the start of every retry.
51530 If you want your filter to do something only once per message, you can make use
51531 of the <option>first_delivery</option> condition in an <option>if</option> command in the filter to
51532 prevent it happening on retries.
51533 </para>
51534 <para>
51535 <indexterm role="concept">
51536 <primary><varname>$domain</varname></primary>
51537 </indexterm>
51538 <indexterm role="concept">
51539 <primary><varname>$local_part</varname></primary>
51540 </indexterm>
51541 <emphasis role="bold">Warning</emphasis>: Because the system filter runs just once, variables that are
51542 specific to individual recipient addresses, such as <varname>$local_part</varname> and
51543 <varname>$domain</varname>, are not set, and the <quote>personal</quote> condition is not meaningful. If
51544 you want to run a centrally-specified filter for each recipient address
51545 independently, you can do so by setting up a suitable <command>redirect</command> router, as
51546 described in section <xref linkend="SECTperaddfil"/> below.
51547 </para>
51548 <section>
51549 <title>Specifying a system filter</title>
51550 <para>
51551 <indexterm role="concept">
51552 <primary>uid (user id)</primary>
51553 <secondary>system filter</secondary>
51554 </indexterm>
51555 <indexterm role="concept">
51556 <primary>gid (group id)</primary>
51557 <secondary>system filter</secondary>
51558 </indexterm>
51559 The name of the file that contains the system filter must be specified by
51560 setting <option>system_filter</option>. If you want the filter to run under a uid and gid
51561 other than root, you must also set <option>system_filter_user</option> and
51562 <option>system_filter_group</option> as appropriate. For example:
51563 </para>
51564 <literallayout class="monospaced">
51565 system_filter = /etc/mail/exim.filter
51566 system_filter_user = exim
51567 </literallayout>
51568 <para>
51569 If a system filter generates any deliveries directly to files or pipes (via the
51570 <option>save</option> or <option>pipe</option> commands), transports to handle these deliveries must be
51571 specified by setting <option>system_filter_file_transport</option> and
51572 <option>system_filter_pipe_transport</option>, respectively. Similarly,
51573 <option>system_filter_reply_transport</option> must be set to handle any messages generated
51574 by the <option>reply</option> command.
51575 </para>
51576 </section>
51577 <section>
51578 <title>Testing a system filter</title>
51579 <para>
51580 You can run simple tests of a system filter in the same way as for a user
51581 filter, but you should use <option>-bF</option> rather than <option>-bf</option>, so that features that
51582 are permitted only in system filters are recognized.
51583 </para>
51584 <para>
51585 If you want to test the combined effect of a system filter and a user filter,
51586 you can use both <option>-bF</option> and <option>-bf</option> on the same command line.
51587 </para>
51588 </section>
51589 <section>
51590 <title>Contents of a system filter</title>
51591 <para>
51592 The language used to specify system filters is the same as for users&#x2019; filter
51593 files. It is described in the separate end-user document <emphasis>Exim&#x2019;s interface to
51594 mail filtering</emphasis>. However, there are some additional features that are
51595 available only in system filters; these are described in subsequent sections.
51596 If they are encountered in a user&#x2019;s filter file or when testing with <option>-bf</option>,
51597 they cause errors.
51598 </para>
51599 <para>
51600 <indexterm role="concept">
51601 <primary>frozen messages</primary>
51602 <secondary>manual thaw; testing in filter</secondary>
51603 </indexterm>
51604 There are two special conditions which, though available in users&#x2019; filter
51605 files, are designed for use in system filters. The condition <option>first_delivery</option>
51606 is true only for the first attempt at delivering a message, and
51607 <option>manually_thawed</option> is true only if the message has been frozen, and
51608 subsequently thawed by an admin user. An explicit forced delivery counts as a
51609 manual thaw, but thawing as a result of the <option>auto_thaw</option> setting does not.
51610 </para>
51611 <para>
51612 <emphasis role="bold">Warning</emphasis>: If a system filter uses the <option>first_delivery</option> condition to
51613 specify an <quote>unseen</quote> (non-significant) delivery, and that delivery does not
51614 succeed, it will not be tried again.
51615 If you want Exim to retry an unseen delivery until it succeeds, you should
51616 arrange to set it up every time the filter runs.
51617 </para>
51618 <para>
51619 When a system filter finishes running, the values of the variables <varname>$n0</varname> &ndash;
51620 <varname>$n9</varname> are copied into <varname>$sn0</varname> &ndash; <varname>$sn9</varname> and are thereby made available to
51621 users&#x2019; filter files. Thus a system filter can, for example, set up <quote>scores</quote>
51622 to which users&#x2019; filter files can refer.
51623 </para>
51624 </section>
51625 <section>
51626 <title>Additional variable for system filters</title>
51627 <para>
51628 <indexterm role="concept">
51629 <primary><varname>$recipients</varname></primary>
51630 </indexterm>
51631 The expansion variable <varname>$recipients</varname>, containing a list of all the recipients
51632 of the message (separated by commas and white space), is available in system
51633 filters. It is not available in users&#x2019; filters for privacy reasons.
51634 </para>
51635 </section>
51636 <section>
51637 <title>Defer, freeze, and fail commands for system filters</title>
51638 <para>
51639 <indexterm role="concept">
51640 <primary>freezing messages</primary>
51641 </indexterm>
51642 <indexterm role="concept">
51643 <primary>message</primary>
51644 <secondary>freezing</secondary>
51645 </indexterm>
51646 <indexterm role="concept">
51647 <primary>message</primary>
51648 <secondary>forced failure</secondary>
51649 </indexterm>
51650 <indexterm role="concept">
51651 <primary><option>fail</option></primary>
51652 <secondary>in system filter</secondary>
51653 </indexterm>
51654 <indexterm role="concept">
51655 <primary><option>freeze</option> in system filter</primary>
51656 </indexterm>
51657 <indexterm role="concept">
51658 <primary><option>defer</option> in system filter</primary>
51659 </indexterm>
51660 There are three extra commands (<option>defer</option>, <option>freeze</option> and <option>fail</option>) which are
51661 always available in system filters, but are not normally enabled in users&#x2019;
51662 filters. (See the <option>allow_defer</option>, <option>allow_freeze</option> and <option>allow_fail</option> options
51663 for the <command>redirect</command> router.) These commands can optionally be followed by the
51664 word <option>text</option> and a string containing an error message, for example:
51665 </para>
51666 <literallayout class="monospaced">
51667 fail text "this message looks like spam to me"
51668 </literallayout>
51669 <para>
51670 The keyword <option>text</option> is optional if the next character is a double quote.
51671 </para>
51672 <para>
51673 The <option>defer</option> command defers delivery of the original recipients of the
51674 message. The <option>fail</option> command causes all the original recipients to be failed,
51675 and a bounce message to be created. The <option>freeze</option> command suspends all
51676 delivery attempts for the original recipients. In all cases, any new deliveries
51677 that are specified by the filter are attempted as normal after the filter has
51678 run.
51679 </para>
51680 <para>
51681 The <option>freeze</option> command is ignored if the message has been manually unfrozen and
51682 not manually frozen since. This means that automatic freezing by a system
51683 filter can be used as a way of checking out suspicious messages. If a message
51684 is found to be all right, manually unfreezing it allows it to be delivered.
51685 </para>
51686 <para>
51687 <indexterm role="concept">
51688 <primary>log</primary>
51689 <secondary><option>fail</option> command log line</secondary>
51690 </indexterm>
51691 <indexterm role="concept">
51692 <primary><option>fail</option></primary>
51693 <secondary>log line; reducing</secondary>
51694 </indexterm>
51695 The text given with a fail command is used as part of the bounce message as
51696 well as being written to the log. If the message is quite long, this can fill
51697 up a lot of log space when such failures are common. To reduce the size of the
51698 log message, Exim interprets the text in a special way if it starts with the
51699 two characters <literal>&lt;&lt;</literal> and contains <literal>&gt;&gt;</literal> later. The text between these two
51700 strings is written to the log, and the rest of the text is used in the bounce
51701 message. For example:
51702 </para>
51703 <literallayout class="monospaced">
51704 fail "&lt;&lt;filter test 1&gt;&gt;Your message is rejected \
51705      because it contains attachments that we are \
51706      not prepared to receive."
51707 </literallayout>
51708 <para>
51709 <indexterm role="concept">
51710 <primary>loop</primary>
51711 <secondary>caused by <option>fail</option></secondary>
51712 </indexterm>
51713 Take great care with the <option>fail</option> command when basing the decision to fail on
51714 the contents of the message, because the bounce message will of course include
51715 the contents of the original message and will therefore trigger the <option>fail</option>
51716 command again (causing a mail loop) unless steps are taken to prevent this.
51717 Testing the <option>error_message</option> condition is one way to prevent this. You could
51718 use, for example
51719 </para>
51720 <literallayout class="monospaced">
51721 if $message_body contains "this is spam" and not error_message
51722 then fail text "spam is not wanted here" endif
51723 </literallayout>
51724 <para>
51725 though of course that might let through unwanted bounce messages. The
51726 alternative is clever checking of the body and/or headers to detect bounces
51727 generated by the filter.
51728 </para>
51729 <para>
51730 The interpretation of a system filter file ceases after a
51731 <option>defer</option>,
51732 <option>freeze</option>, or <option>fail</option> command is obeyed. However, any deliveries that were
51733 set up earlier in the filter file are honoured, so you can use a sequence such
51734 as
51735 </para>
51736 <literallayout class="monospaced">
51737 mail ...
51738 freeze
51739 </literallayout>
51740 <para>
51741 to send a specified message when the system filter is freezing (or deferring or
51742 failing) a message. The normal deliveries for the message do not, of course,
51743 take place.
51744 </para>
51745 </section>
51746 <section id="SECTaddremheasys">
51747 <title>Adding and removing headers in a system filter</title>
51748 <para>
51749 <indexterm role="concept">
51750 <primary>header lines</primary>
51751 <secondary>adding; in system filter</secondary>
51752 </indexterm>
51753 <indexterm role="concept">
51754 <primary>header lines</primary>
51755 <secondary>removing; in system filter</secondary>
51756 </indexterm>
51757 <indexterm role="concept">
51758 <primary>filter</primary>
51759 <secondary>header lines; adding/removing</secondary>
51760 </indexterm>
51761 Two filter commands that are available only in system filters are:
51762 </para>
51763 <literallayout class="monospaced">
51764 headers add &lt;string&gt;
51765 headers remove &lt;string&gt;
51766 </literallayout>
51767 <para>
51768 The argument for the <option>headers add</option> is a string that is expanded and then
51769 added to the end of the message&#x2019;s headers. It is the responsibility of the
51770 filter maintainer to make sure it conforms to RFC 2822 syntax. Leading white
51771 space is ignored, and if the string is otherwise empty, or if the expansion is
51772 forced to fail, the command has no effect.
51773 </para>
51774 <para>
51775 You can use <quote>\n</quote> within the string, followed by white space, to specify
51776 continued header lines. More than one header may be added in one command by
51777 including <quote>\n</quote> within the string without any following white space. For
51778 example:
51779 </para>
51780 <literallayout class="monospaced">
51781 headers add "X-header-1: ....\n  \
51782              continuation of X-header-1 ...\n\
51783              X-header-2: ...."
51784 </literallayout>
51785 <para>
51786 Note that the header line continuation white space after the first newline must
51787 be placed before the backslash that continues the input string, because white
51788 space after input continuations is ignored.
51789 </para>
51790 <para>
51791 The argument for <option>headers remove</option> is a colon-separated list of header names.
51792 This command applies only to those headers that are stored with the message;
51793 those that are added at delivery time (such as <emphasis>Envelope-To:</emphasis> and
51794 <emphasis>Return-Path:</emphasis>) cannot be removed by this means. If there is more than one
51795 header with the same name, they are all removed.
51796 </para>
51797 <para>
51798 The <option>headers</option> command in a system filter makes an immediate change to the set
51799 of header lines that was received with the message (with possible additions
51800 from ACL processing). Subsequent commands in the system filter operate on the
51801 modified set, which also forms the basis for subsequent message delivery.
51802 Unless further modified during routing or transporting, this set of headers is
51803 used for all recipients of the message.
51804 </para>
51805 <para>
51806 During routing and transporting, the variables that refer to the contents of
51807 header lines refer only to those lines that are in this set. Thus, header lines
51808 that are added by a system filter are visible to users&#x2019; filter files and to all
51809 routers and transports. This contrasts with the manipulation of header lines by
51810 routers and transports, which is not immediate, but which instead is saved up
51811 until the message is actually being written (see section
51812 <xref linkend="SECTheadersaddrem"/>).
51813 </para>
51814 <para>
51815 If the message is not delivered at the first attempt, header lines that were
51816 added by the system filter are stored with the message, and so are still
51817 present at the next delivery attempt. Header lines that were removed are still
51818 present, but marked <quote>deleted</quote> so that they are not transported with the
51819 message. For this reason, it is usual to make the <option>headers</option> command
51820 conditional on <option>first_delivery</option> so that the set of header lines is not
51821 modified more than once.
51822 </para>
51823 <para>
51824 Because header modification in a system filter acts immediately, you have to
51825 use an indirect approach if you want to modify the contents of a header line.
51826 For example:
51827 </para>
51828 <literallayout class="monospaced">
51829 headers add "Old-Subject: $h_subject:"
51830 headers remove "Subject"
51831 headers add "Subject: new subject (was: $h_old-subject:)"
51832 headers remove "Old-Subject"
51833 </literallayout>
51834 </section>
51835 <section>
51836 <title>Setting an errors address in a system filter</title>
51837 <para>
51838 <indexterm role="concept">
51839 <primary>envelope sender</primary>
51840 </indexterm>
51841 In a system filter, if a <option>deliver</option> command is followed by
51842 </para>
51843 <literallayout class="monospaced">
51844 errors_to &lt;some address&gt;
51845 </literallayout>
51846 <para>
51847 in order to change the envelope sender (and hence the error reporting) for that
51848 delivery, any address may be specified. (In a user filter, only the current
51849 user&#x2019;s address can be set.) For example, if some mail is being monitored, you
51850 might use
51851 </para>
51852 <literallayout class="monospaced">
51853 unseen deliver monitor@spying.example errors_to root@local.example
51854 </literallayout>
51855 <para>
51856 to take a copy which would not be sent back to the normal error reporting
51857 address if its delivery failed.
51858 </para>
51859 </section>
51860 <section id="SECTperaddfil">
51861 <title>Per-address filtering</title>
51862 <para>
51863 <indexterm role="concept">
51864 <primary><varname>$domain</varname></primary>
51865 </indexterm>
51866 <indexterm role="concept">
51867 <primary><varname>$local_part</varname></primary>
51868 </indexterm>
51869 In contrast to the system filter, which is run just once per message for each
51870 delivery attempt, it is also possible to set up a system-wide filtering
51871 operation that runs once for each recipient address. In this case, variables
51872 such as <varname>$local_part</varname> and <varname>$domain</varname> can be used, and indeed, the choice of
51873 filter file could be made dependent on them. This is an example of a router
51874 which implements such a filter:
51875 </para>
51876 <literallayout class="monospaced">
51877 central_filter:
51878   check_local_user
51879   driver = redirect
51880   domains = +local_domains
51881   file = /central/filters/$local_part
51882   no_verify
51883   allow_filter
51884   allow_freeze
51885 </literallayout>
51886 <para>
51887 The filter is run in a separate process under its own uid. Therefore, either
51888 <option>check_local_user</option> must be set (as above), in which case the filter is run as
51889 the local user, or the <option>user</option> option must be used to specify which user to
51890 use. If both are set, <option>user</option> overrides.
51891 </para>
51892 <para>
51893 Care should be taken to ensure that none of the commands in the filter file
51894 specify a significant delivery if the message is to go on to be delivered to
51895 its intended recipient. The router will not then claim to have dealt with the
51896 address, so it will be passed on to subsequent routers to be delivered in the
51897 normal way.
51898 <indexterm role="concept" startref="IIDsysfil1" class="endofrange"/>
51899 <indexterm role="concept" startref="IIDsysfil2" class="endofrange"/>
51900 <indexterm role="concept" startref="IIDsysfil3" class="endofrange"/>
51901 </para>
51902 </section>
51903 </chapter>
51904
51905 <chapter id="CHAPmsgproc">
51906 <title>Message processing</title>
51907 <para>
51908 <indexterm role="concept" id="IIDmesproc" class="startofrange">
51909 <primary>message</primary>
51910 <secondary>general processing</secondary>
51911 </indexterm>
51912 Exim performs various transformations on the sender and recipient addresses of
51913 all messages that it handles, and also on the messages&#x2019; header lines. Some of
51914 these are optional and configurable, while others always take place. All of
51915 this processing, except rewriting as a result of routing, and the addition or
51916 removal of header lines while delivering, happens when a message is received,
51917 before it is placed on Exim&#x2019;s queue.
51918 </para>
51919 <para>
51920 Some of the automatic processing takes place by default only for
51921 <quote>locally-originated</quote> messages. This adjective is used to describe messages
51922 that are not received over TCP/IP, but instead are passed to an Exim process on
51923 its standard input. This includes the interactive <quote>local SMTP</quote> case that is
51924 set up by the <option>-bs</option> command line option.
51925 </para>
51926 <para>
51927 <emphasis role="bold">Note</emphasis>: Messages received over TCP/IP on the loopback interface (127.0.0.1
51928 or ::1) are not considered to be locally-originated. Exim does not treat the
51929 loopback interface specially in any way.
51930 </para>
51931 <para>
51932 If you want the loopback interface to be treated specially, you must ensure
51933 that there are appropriate entries in your ACLs.
51934 </para>
51935 <section id="SECTsubmodnon">
51936 <title>Submission mode for non-local messages</title>
51937 <para>
51938 <indexterm role="concept">
51939 <primary>message</primary>
51940 <secondary>submission</secondary>
51941 </indexterm>
51942 <indexterm role="concept">
51943 <primary>submission mode</primary>
51944 </indexterm>
51945 Processing that happens automatically for locally-originated messages (unless
51946 <option>suppress_local_fixups</option> is set) can also be requested for messages that are
51947 received over TCP/IP. The term <quote>submission mode</quote> is used to describe this
51948 state. Submisssion mode is set by the modifier
51949 </para>
51950 <literallayout class="monospaced">
51951 control = submission
51952 </literallayout>
51953 <para>
51954 in a MAIL, RCPT, or pre-data ACL for an incoming message (see sections
51955 <xref linkend="SECTACLmodi"/> and <xref linkend="SECTcontrols"/>). This makes Exim treat the message as
51956 a local submission, and is normally used when the source of the message is
51957 known to be an MUA running on a client host (as opposed to an MTA). For
51958 example, to set submission mode for messages originating on the IPv4 loopback
51959 interface, you could include the following in the MAIL ACL:
51960 </para>
51961 <literallayout class="monospaced">
51962 warn  hosts = 127.0.0.1
51963       control = submission
51964 </literallayout>
51965 <para>
51966 <indexterm role="concept">
51967 <primary><option>sender_retain</option></primary>
51968 </indexterm>
51969 There are some options that can be used when setting submission mode. A slash
51970 is used to separate options. For example:
51971 </para>
51972 <literallayout class="monospaced">
51973 control = submission/sender_retain
51974 </literallayout>
51975 <para>
51976 Specifying <option>sender_retain</option> has the effect of setting <option>local_sender_retain</option>
51977 true and <option>local_from_check</option> false for the current incoming message. The first
51978 of these allows an existing <emphasis>Sender:</emphasis> header in the message to remain, and
51979 the second suppresses the check to ensure that <emphasis>From:</emphasis> matches the
51980 authenticated sender. With this setting, Exim still fixes up messages by adding
51981 <emphasis>Date:</emphasis> and <emphasis>Message-ID:</emphasis> header lines if they are missing, but makes no
51982 attempt to check sender authenticity in header lines.
51983 </para>
51984 <para>
51985 When <option>sender_retain</option> is not set, a submission mode setting may specify a
51986 domain to be used when generating a <emphasis>From:</emphasis> or <emphasis>Sender:</emphasis> header line. For
51987 example:
51988 </para>
51989 <literallayout class="monospaced">
51990 control = submission/domain=some.domain
51991 </literallayout>
51992 <para>
51993 The domain may be empty. How this value is used is described in sections
51994 <xref linkend="SECTthefrohea"/> and <xref linkend="SECTthesenhea"/>. There is also a <option>name</option> option
51995 that allows you to specify the user&#x2019;s full name for inclusion in a created
51996 <emphasis>Sender:</emphasis> or <emphasis>From:</emphasis> header line. For example:
51997 </para>
51998 <literallayout class="monospaced">
51999 accept authenticated = *
52000        control = submission/domain=wonderland.example/\
52001                             name=${lookup {$authenticated_id} \
52002                                    lsearch {/etc/exim/namelist}}
52003 </literallayout>
52004 <para>
52005 Because the name may contain any characters, including slashes, the <option>name</option>
52006 option must be given last. The remainder of the string is used as the name. For
52007 the example above, if <filename>/etc/exim/namelist</filename> contains:
52008 </para>
52009 <literallayout class="monospaced">
52010 bigegg:  Humpty Dumpty
52011 </literallayout>
52012 <para>
52013 then when the sender has authenticated as <emphasis>bigegg</emphasis>, the generated <emphasis>Sender:</emphasis>
52014 line would be:
52015 </para>
52016 <literallayout class="monospaced">
52017 Sender: Humpty Dumpty &lt;bigegg@wonderland.example&gt;
52018 </literallayout>
52019 <para>
52020 <indexterm role="concept">
52021 <primary>return path</primary>
52022 <secondary>in submission mode</secondary>
52023 </indexterm>
52024 By default, submission mode forces the return path to the same address as is
52025 used to create the <emphasis>Sender:</emphasis> header. However, if <option>sender_retain</option> is
52026 specified, the return path is also left unchanged.
52027 </para>
52028 <para>
52029 <emphasis role="bold">Note</emphasis>: The changes caused by submission mode take effect after the predata
52030 ACL. This means that any sender checks performed before the fix-ups use the
52031 untrusted sender address specified by the user, not the trusted sender address
52032 specified by submission mode. Although this might be slightly unexpected, it
52033 does mean that you can configure ACL checks to spot that a user is trying to
52034 spoof another&#x2019;s address.
52035 </para>
52036 </section>
52037 <section id="SECTlineendings">
52038 <title>Line endings</title>
52039 <para>
52040 <indexterm role="concept">
52041 <primary>line endings</primary>
52042 </indexterm>
52043 <indexterm role="concept">
52044 <primary>carriage return</primary>
52045 </indexterm>
52046 <indexterm role="concept">
52047 <primary>linefeed</primary>
52048 </indexterm>
52049 RFC 2821 specifies that CRLF (two characters: carriage-return, followed by
52050 linefeed) is the line ending for messages transmitted over the Internet using
52051 SMTP over TCP/IP. However, within individual operating systems, different
52052 conventions are used. For example, Unix-like systems use just LF, but others
52053 use CRLF or just CR.
52054 </para>
52055 <para>
52056 Exim was designed for Unix-like systems, and internally, it stores messages
52057 using the system&#x2019;s convention of a single LF as a line terminator. When
52058 receiving a message, all line endings are translated to this standard format.
52059 Originally, it was thought that programs that passed messages directly to an
52060 MTA within an operating system would use that system&#x2019;s convention. Experience
52061 has shown that this is not the case; for example, there are Unix applications
52062 that use CRLF in this circumstance. For this reason, and for compatibility with
52063 other MTAs, the way Exim handles line endings for all messages is now as
52064 follows:
52065 </para>
52066 <itemizedlist>
52067 <listitem>
52068 <para>
52069 LF not preceded by CR is treated as a line ending.
52070 </para>
52071 </listitem>
52072 <listitem>
52073 <para>
52074 CR is treated as a line ending; if it is immediately followed by LF, the LF
52075 is ignored.
52076 </para>
52077 </listitem>
52078 <listitem>
52079 <para>
52080 The sequence <quote>CR, dot, CR</quote> does not terminate an incoming SMTP message,
52081 nor a local message in the state where a line containing only a dot is a
52082 terminator.
52083 </para>
52084 </listitem>
52085 <listitem>
52086 <para>
52087 If a bare CR is encountered within a header line, an extra space is added after
52088 the line terminator so as not to end the header line. The reasoning behind this
52089 is that bare CRs in header lines are most likely either to be mistakes, or
52090 people trying to play silly games.
52091 </para>
52092 </listitem>
52093 <listitem>
52094 <para>
52095 If the first header line received in a message ends with CRLF, a subsequent
52096 bare LF in a header line is treated in the same way as a bare CR in a header
52097 line.
52098 </para>
52099 </listitem>
52100 </itemizedlist>
52101 </section>
52102 <section>
52103 <title>Unqualified addresses</title>
52104 <para>
52105 <indexterm role="concept">
52106 <primary>unqualified addresses</primary>
52107 </indexterm>
52108 <indexterm role="concept">
52109 <primary>address</primary>
52110 <secondary>qualification</secondary>
52111 </indexterm>
52112 By default, Exim expects every envelope address it receives from an external
52113 host to be fully qualified. Unqualified addresses cause negative responses to
52114 SMTP commands. However, because SMTP is used as a means of transporting
52115 messages from MUAs running on personal workstations, there is sometimes a
52116 requirement to accept unqualified addresses from specific hosts or IP networks.
52117 </para>
52118 <para>
52119 Exim has two options that separately control which hosts may send unqualified
52120 sender or receipient addresses in SMTP commands, namely
52121 <option>sender_unqualified_hosts</option> and <option>recipient_unqualified_hosts</option>. In both
52122 cases, if an unqualified address is accepted, it is qualified by adding the
52123 value of <option>qualify_domain</option> or <option>qualify_recipient</option>, as appropriate.
52124 </para>
52125 <para>
52126 <indexterm role="concept">
52127 <primary><option>qualify_domain</option></primary>
52128 </indexterm>
52129 <indexterm role="concept">
52130 <primary><option>qualify_recipient</option></primary>
52131 </indexterm>
52132 Unqualified addresses in header lines are automatically qualified for messages
52133 that are locally originated, unless the <option>-bnq</option> option is given on the command
52134 line. For messages received over SMTP, unqualified addresses in header lines
52135 are qualified only if unqualified addresses are permitted in SMTP commands. In
52136 other words, such qualification is also controlled by
52137 <option>sender_unqualified_hosts</option> and <option>recipient_unqualified_hosts</option>,
52138 </para>
52139 </section>
52140 <section>
52141 <title>The UUCP From line</title>
52142 <para>
52143 <indexterm role="concept">
52144 <primary><quote>From</quote> line</primary>
52145 </indexterm>
52146 <indexterm role="concept">
52147 <primary>UUCP</primary>
52148 <secondary><quote>From</quote> line</secondary>
52149 </indexterm>
52150 <indexterm role="concept">
52151 <primary>sender</primary>
52152 <secondary>address</secondary>
52153 </indexterm>
52154 <indexterm role="concept">
52155 <primary><option>uucp_from_pattern</option></primary>
52156 </indexterm>
52157 <indexterm role="concept">
52158 <primary><option>uucp_from_sender</option></primary>
52159 </indexterm>
52160 <indexterm role="concept">
52161 <primary>envelope sender</primary>
52162 </indexterm>
52163 <indexterm role="concept">
52164 <primary>Sendmail compatibility</primary>
52165 <secondary><quote>From</quote> line</secondary>
52166 </indexterm>
52167 Messages that have come from UUCP (and some other applications) often begin
52168 with a line containing the envelope sender and a timestamp, following the word
52169 <quote>From</quote>. Examples of two common formats are:
52170 </para>
52171 <literallayout class="monospaced">
52172 From a.oakley@berlin.mus Fri Jan  5 12:35 GMT 1996
52173 From f.butler@berlin.mus Fri, 7 Jan 97 14:00:00 GMT
52174 </literallayout>
52175 <para>
52176 This line precedes the RFC 2822 header lines. For compatibility with Sendmail,
52177 Exim recognizes such lines at the start of messages that are submitted to it
52178 via the command line (that is, on the standard input). It does not recognize
52179 such lines in incoming SMTP messages, unless the sending host matches
52180 <option>ignore_fromline_hosts</option> or the <option>-bs</option> option was used for a local message
52181 and <option>ignore_fromline_local</option> is set. The recognition is controlled by a
52182 regular expression that is defined by the <option>uucp_from_pattern</option> option, whose
52183 default value matches the two common cases shown above and puts the address
52184 that follows <quote>From</quote> into <varname>$1</varname>.
52185 </para>
52186 <para>
52187 <indexterm role="concept">
52188 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
52189 <secondary>in <quote>From </quote> line handling</secondary>
52190 </indexterm>
52191 When the caller of Exim for a non-SMTP message that contains a <quote>From</quote> line is
52192 a trusted user, the message&#x2019;s sender address is constructed by expanding the
52193 contents of <option>uucp_sender_address</option>, whose default value is <quote>$1</quote>. This is
52194 then parsed as an RFC 2822 address. If there is no domain, the local part is
52195 qualified with <option>qualify_domain</option> unless it is the empty string. However, if
52196 the command line <option>-f</option> option is used, it overrides the <quote>From</quote> line.
52197 </para>
52198 <para>
52199 If the caller of Exim is not trusted, the <quote>From</quote> line is recognized, but the
52200 sender address is not changed. This is also the case for incoming SMTP messages
52201 that are permitted to contain <quote>From</quote> lines.
52202 </para>
52203 <para>
52204 Only one <quote>From</quote> line is recognized. If there is more than one, the second is
52205 treated as a data line that starts the body of the message, as it is not valid
52206 as a header line. This also happens if a <quote>From</quote> line is present in an
52207 incoming SMTP message from a source that is not permitted to send them.
52208 </para>
52209 </section>
52210 <section>
52211 <title>Resent- header lines</title>
52212 <para>
52213 <indexterm role="concept">
52214 <primary><option>Resent-</option> header lines</primary>
52215 </indexterm>
52216 RFC 2822 makes provision for sets of header lines starting with the string
52217 <literal>Resent-</literal> to be added to a message when it is resent by the original
52218 recipient to somebody else. These headers are <emphasis>Resent-Date:</emphasis>,
52219 <emphasis>Resent-From:</emphasis>, <emphasis>Resent-Sender:</emphasis>, <emphasis>Resent-To:</emphasis>, <emphasis>Resent-Cc:</emphasis>,
52220 <emphasis>Resent-Bcc:</emphasis> and <emphasis>Resent-Message-ID:</emphasis>. The RFC says:
52221 </para>
52222 <blockquote>
52223 <para>
52224 <emphasis>Resent fields are strictly informational. They MUST NOT be used in the normal
52225 processing of replies or other such automatic actions on messages.</emphasis>
52226 </para>
52227 </blockquote>
52228 <para>
52229 This leaves things a bit vague as far as other processing actions such as
52230 address rewriting are concerned. Exim treats <option>Resent-</option> header lines as
52231 follows:
52232 </para>
52233 <itemizedlist>
52234 <listitem>
52235 <para>
52236 A <emphasis>Resent-From:</emphasis> line that just contains the login id of the submitting user
52237 is automatically rewritten in the same way as <emphasis>From:</emphasis> (see below).
52238 </para>
52239 </listitem>
52240 <listitem>
52241 <para>
52242 If there&#x2019;s a rewriting rule for a particular header line, it is also applied to
52243 <option>Resent-</option> header lines of the same type. For example, a rule that rewrites
52244 <emphasis>From:</emphasis> also rewrites <emphasis>Resent-From:</emphasis>.
52245 </para>
52246 </listitem>
52247 <listitem>
52248 <para>
52249 For local messages, if <emphasis>Sender:</emphasis> is removed on input, <emphasis>Resent-Sender:</emphasis> is
52250 also removed.
52251 </para>
52252 </listitem>
52253 <listitem>
52254 <para>
52255 For a locally-submitted message,
52256 if there are any <option>Resent-</option> header lines but no <emphasis>Resent-Date:</emphasis>,
52257 <emphasis>Resent-From:</emphasis>, or <emphasis>Resent-Message-Id:</emphasis>, they are added as necessary. It is
52258 the contents of <emphasis>Resent-Message-Id:</emphasis> (rather than <emphasis>Message-Id:</emphasis>) which are
52259 included in log lines in this case.
52260 </para>
52261 </listitem>
52262 <listitem>
52263 <para>
52264 The logic for adding <emphasis>Sender:</emphasis> is duplicated for <emphasis>Resent-Sender:</emphasis> when any
52265 <option>Resent-</option> header lines are present.
52266 </para>
52267 </listitem>
52268 </itemizedlist>
52269 </section>
52270 <section>
52271 <title>The Auto-Submitted: header line</title>
52272 <para revisionflag="changed">
52273 Whenever Exim generates an autoreply, a bounce, or a delay warning message, it
52274 includes the header line:
52275 </para>
52276 <literallayout class="monospaced">
52277 Auto-Submitted: auto-replied
52278 </literallayout>
52279 </section>
52280 <section>
52281 <title>The Bcc: header line</title>
52282 <para>
52283 <indexterm role="concept">
52284 <primary><emphasis>Bcc:</emphasis> header line</primary>
52285 </indexterm>
52286 If Exim is called with the <option>-t</option> option, to take recipient addresses from a
52287 message&#x2019;s header, it removes any <emphasis>Bcc:</emphasis> header line that may exist (after
52288 extracting its addresses). If <option>-t</option> is not present on the command line, any
52289 existing <emphasis>Bcc:</emphasis> is not removed.
52290 </para>
52291 </section>
52292 <section>
52293 <title>The Date: header line</title>
52294 <para>
52295 <indexterm role="concept">
52296 <primary><emphasis>Date:</emphasis> header line</primary>
52297 </indexterm>
52298 If a locally-generated or submission-mode message has no <emphasis>Date:</emphasis> header line,
52299 Exim adds one, using the current date and time, unless the
52300 <option>suppress_local_fixups</option> control has been specified.
52301 </para>
52302 </section>
52303 <section>
52304 <title>The Delivery-date: header line</title>
52305 <para>
52306 <indexterm role="concept">
52307 <primary><emphasis>Delivery-date:</emphasis> header line</primary>
52308 </indexterm>
52309 <indexterm role="concept">
52310 <primary><option>delivery_date_remove</option></primary>
52311 </indexterm>
52312 <emphasis>Delivery-date:</emphasis> header lines are not part of the standard RFC 2822 header
52313 set. Exim can be configured to add them to the final delivery of messages. (See
52314 the generic <option>delivery_date_add</option> transport option.) They should not be present
52315 in messages in transit. If the <option>delivery_date_remove</option> configuration option is
52316 set (the default), Exim removes <emphasis>Delivery-date:</emphasis> header lines from incoming
52317 messages.
52318 </para>
52319 </section>
52320 <section>
52321 <title>The Envelope-to: header line</title>
52322 <para>
52323 <indexterm role="concept">
52324 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
52325 </indexterm>
52326 <indexterm role="concept">
52327 <primary><option>envelope_to_remove</option></primary>
52328 </indexterm>
52329 <emphasis>Envelope-to:</emphasis> header lines are not part of the standard RFC 2822 header set.
52330 Exim can be configured to add them to the final delivery of messages. (See the
52331 generic <option>envelope_to_add</option> transport option.) They should not be present in
52332 messages in transit. If the <option>envelope_to_remove</option> configuration option is set
52333 (the default), Exim removes <emphasis>Envelope-to:</emphasis> header lines from incoming
52334 messages.
52335 </para>
52336 </section>
52337 <section id="SECTthefrohea">
52338 <title>The From: header line</title>
52339 <para>
52340 <indexterm role="concept">
52341 <primary><emphasis>From:</emphasis> header line</primary>
52342 </indexterm>
52343 <indexterm role="concept">
52344 <primary>Sendmail compatibility</primary>
52345 <secondary><quote>From</quote> line</secondary>
52346 </indexterm>
52347 <indexterm role="concept">
52348 <primary>message</primary>
52349 <secondary>submission</secondary>
52350 </indexterm>
52351 <indexterm role="concept">
52352 <primary>submission mode</primary>
52353 </indexterm>
52354 If a submission-mode message does not contain a <emphasis>From:</emphasis> header line, Exim
52355 adds one if either of the following conditions is true:
52356 </para>
52357 <itemizedlist>
52358 <listitem>
52359 <para>
52360 The envelope sender address is not empty (that is, this is not a bounce
52361 message). The added header line copies the envelope sender address.
52362 </para>
52363 </listitem>
52364 <listitem>
52365 <para>
52366 <indexterm role="concept">
52367 <primary><varname>$authenticated_id</varname></primary>
52368 </indexterm>
52369 The SMTP session is authenticated and <varname>$authenticated_id</varname> is not empty.
52370 </para>
52371 <orderedlist numeration="arabic">
52372 <listitem>
52373 <para>
52374 <indexterm role="concept">
52375 <primary><varname>$qualify_domain</varname></primary>
52376 </indexterm>
52377 If no domain is specified by the submission control, the local part is
52378 <varname>$authenticated_id</varname> and the domain is <varname>$qualify_domain</varname>.
52379 </para>
52380 </listitem>
52381 <listitem>
52382 <para>
52383 If a non-empty domain is specified by the submission control, the local
52384 part is <varname>$authenticated_id</varname>, and the the domain is the specified domain.
52385 </para>
52386 </listitem>
52387 <listitem>
52388 <para>
52389 If an empty domain is specified by the submission control,
52390 <varname>$authenticated_id</varname> is assumed to be the complete address.
52391 </para>
52392 </listitem>
52393 </orderedlist>
52394 </listitem>
52395 </itemizedlist>
52396 <para>
52397 A non-empty envelope sender takes precedence.
52398 </para>
52399 <para>
52400 If a locally-generated incoming message does not contain a <emphasis>From:</emphasis> header
52401 line, and the <option>suppress_local_fixups</option> control is not set, Exim adds one
52402 containing the sender&#x2019;s address. The calling user&#x2019;s login name and full name
52403 are used to construct the address, as described in section <xref linkend="SECTconstr"/>.
52404 They are obtained from the password data by calling <function>getpwuid()</function> (but see the
52405 <option>unknown_login</option> configuration option). The address is qualified with
52406 <option>qualify_domain</option>.
52407 </para>
52408 <para>
52409 For compatibility with Sendmail, if an incoming, non-SMTP message has a
52410 <emphasis>From:</emphasis> header line containing just the unqualified login name of the calling
52411 user, this is replaced by an address containing the user&#x2019;s login name and full
52412 name as described in section <xref linkend="SECTconstr"/>.
52413 </para>
52414 </section>
52415 <section>
52416 <title>The Message-ID: header line</title>
52417 <para>
52418 <indexterm role="concept">
52419 <primary><emphasis>Message-ID:</emphasis> header line</primary>
52420 </indexterm>
52421 <indexterm role="concept">
52422 <primary>message</primary>
52423 <secondary>submission</secondary>
52424 </indexterm>
52425 <indexterm role="concept">
52426 <primary><option>message_id_header_text</option></primary>
52427 </indexterm>
52428 If a locally-generated or submission-mode incoming message does not contain a
52429 <emphasis>Message-ID:</emphasis> or <emphasis>Resent-Message-ID:</emphasis> header line, and the
52430 <option>suppress_local_fixups</option> control is not set, Exim adds a suitable header line
52431 to the message. If there are any <emphasis>Resent-:</emphasis> headers in the message, it
52432 creates <emphasis>Resent-Message-ID:</emphasis>. The id is constructed from Exim&#x2019;s internal
52433 message id, preceded by the letter E to ensure it starts with a letter, and
52434 followed by @ and the primary host name. Additional information can be included
52435 in this header line by setting the <option>message_id_header_text</option> and/or
52436 <option>message_id_header_domain</option> options.
52437 </para>
52438 </section>
52439 <section>
52440 <title>The Received: header line</title>
52441 <para>
52442 <indexterm role="concept">
52443 <primary><emphasis>Received:</emphasis> header line</primary>
52444 </indexterm>
52445 A <emphasis>Received:</emphasis> header line is added at the start of every message. The
52446 contents are defined by the <option>received_header_text</option> configuration option, and
52447 Exim automatically adds a semicolon and a timestamp to the configured string.
52448 </para>
52449 <para>
52450 The <emphasis>Received:</emphasis> header is generated as soon as the message&#x2019;s header lines
52451 have been received. At this stage, the timestamp in the <emphasis>Received:</emphasis> header
52452 line is the time that the message started to be received. This is the value
52453 that is seen by the DATA ACL and by the <function>local_scan()</function> function.
52454 </para>
52455 <para>
52456 Once a message is accepted, the timestamp in the <emphasis>Received:</emphasis> header line is
52457 changed to the time of acceptance, which is (apart from a small delay while the
52458 -H spool file is written) the earliest time at which delivery could start.
52459 </para>
52460 </section>
52461 <section revisionflag="changed">
52462 <title>The References: header line</title>
52463 <para revisionflag="changed">
52464 <indexterm role="concept">
52465 <primary><emphasis>References:</emphasis> header line</primary>
52466 </indexterm>
52467 Messages created by the <command>autoreply</command> transport include a <emphasis>References:</emphasis>
52468 header line. This is constructed according to the rules that are described in
52469 section 3.64 of RFC 2822 (which states that replies should contain such a
52470 header line), and section 3.14 of RFC 3834 (which states that automatic
52471 responses are not different in this respect). However, because some mail
52472 processing software does not cope well with very long header lines, no more
52473 than 12 message IDs are copied from the <emphasis>References:</emphasis> header line in the
52474 incoming message. If there are more than 12, the first one and then the final
52475 11 are copied, before adding the message ID of the incoming message.
52476 </para>
52477 </section>
52478 <section>
52479 <title>The Return-path: header line</title>
52480 <para>
52481 <indexterm role="concept">
52482 <primary><emphasis>Return-path:</emphasis> header line</primary>
52483 </indexterm>
52484 <indexterm role="concept">
52485 <primary><option>return_path_remove</option></primary>
52486 </indexterm>
52487 <emphasis>Return-path:</emphasis> header lines are defined as something an MTA may insert when
52488 it does the final delivery of messages. (See the generic <option>return_path_add</option>
52489 transport option.) Therefore, they should not be present in messages in
52490 transit. If the <option>return_path_remove</option> configuration option is set (the
52491 default), Exim removes <emphasis>Return-path:</emphasis> header lines from incoming messages.
52492 </para>
52493 </section>
52494 <section id="SECTthesenhea">
52495 <title>The Sender: header line</title>
52496 <para>
52497 <indexterm role="concept">
52498 <primary><emphasis>Sender:</emphasis> header line</primary>
52499 </indexterm>
52500 <indexterm role="concept">
52501 <primary>message</primary>
52502 <secondary>submission</secondary>
52503 </indexterm>
52504 For a locally-originated message from an untrusted user, Exim may remove an
52505 existing <emphasis>Sender:</emphasis> header line, and it may add a new one. You can modify
52506 these actions by setting the <option>local_sender_retain</option> option true, the
52507 <option>local_from_check</option> option false, or by using the <option>suppress_local_fixups</option>
52508 control setting.
52509 </para>
52510 <para>
52511 When a local message is received from an untrusted user and
52512 <option>local_from_check</option> is true (the default), and the <option>suppress_local_fixups</option>
52513 control has not been set, a check is made to see if the address given in the
52514 <emphasis>From:</emphasis> header line is the correct (local) sender of the message. The address
52515 that is expected has the login name as the local part and the value of
52516 <option>qualify_domain</option> as the domain. Prefixes and suffixes for the local part can
52517 be permitted by setting <option>local_from_prefix</option> and <option>local_from_suffix</option>
52518 appropriately. If <emphasis>From:</emphasis> does not contain the correct sender, a <emphasis>Sender:</emphasis>
52519 line is added to the message.
52520 </para>
52521 <para>
52522 If you set <option>local_from_check</option> false, this checking does not occur. However,
52523 the removal of an existing <emphasis>Sender:</emphasis> line still happens, unless you also set
52524 <option>local_sender_retain</option> to be true. It is not possible to set both of these
52525 options true at the same time.
52526 </para>
52527 <para>
52528 <indexterm role="concept">
52529 <primary>submission mode</primary>
52530 </indexterm>
52531 By default, no processing of <emphasis>Sender:</emphasis> header lines is done for messages
52532 received over TCP/IP or for messages submitted by trusted users. However, when
52533 a message is received over TCP/IP in submission mode, and <option>sender_retain</option> is
52534 not specified on the submission control, the following processing takes place:
52535 </para>
52536 <para>
52537 <indexterm role="concept">
52538 <primary><varname>$authenticated_id</varname></primary>
52539 </indexterm>
52540 First, any existing <emphasis>Sender:</emphasis> lines are removed. Then, if the SMTP session is
52541 authenticated, and <varname>$authenticated_id</varname> is not empty, a sender address is
52542 created as follows:
52543 </para>
52544 <itemizedlist>
52545 <listitem>
52546 <para>
52547 <indexterm role="concept">
52548 <primary><varname>$qualify_domain</varname></primary>
52549 </indexterm>
52550 If no domain is specified by the submission control, the local part is
52551 <varname>$authenticated_id</varname> and the domain is <varname>$qualify_domain</varname>.
52552 </para>
52553 </listitem>
52554 <listitem>
52555 <para>
52556 If a non-empty domain is specified by the submission control, the local part
52557 is <varname>$authenticated_id</varname>, and the the domain is the specified domain.
52558 </para>
52559 </listitem>
52560 <listitem>
52561 <para>
52562 If an empty domain is specified by the submission control,
52563 <varname>$authenticated_id</varname> is assumed to be the complete address.
52564 </para>
52565 </listitem>
52566 </itemizedlist>
52567 <para>
52568 This address is compared with the address in the <emphasis>From:</emphasis> header line. If they
52569 are different, a <emphasis>Sender:</emphasis> header line containing the created address is
52570 added. Prefixes and suffixes for the local part in <emphasis>From:</emphasis> can be permitted
52571 by setting <option>local_from_prefix</option> and <option>local_from_suffix</option> appropriately.
52572 </para>
52573 <para>
52574 <indexterm role="concept">
52575 <primary>return path</primary>
52576 <secondary>created from <emphasis>Sender:</emphasis></secondary>
52577 </indexterm>
52578 <emphasis role="bold">Note</emphasis>: Whenever a <emphasis>Sender:</emphasis> header line is created, the return path for
52579 the message (the envelope sender address) is changed to be the same address,
52580 except in the case of submission mode when <option>sender_retain</option> is specified.
52581 </para>
52582 </section>
52583 <section id="SECTheadersaddrem">
52584 <title>Adding and removing header lines in routers and transports</title>
52585 <para>
52586 <indexterm role="concept">
52587 <primary>header lines</primary>
52588 <secondary>adding; in router or transport</secondary>
52589 </indexterm>
52590 <indexterm role="concept">
52591 <primary>header lines</primary>
52592 <secondary>removing; in router or transport</secondary>
52593 </indexterm>
52594 When a message is delivered, the addition and removal of header lines can be
52595 specified in a system filter, or on any of the routers and transports that
52596 process the message. Section <xref linkend="SECTaddremheasys"/> contains details about
52597 modifying headers in a system filter. Header lines can also be added in an ACL
52598 as a message is received (see section <xref linkend="SECTaddheadacl"/>).
52599 </para>
52600 <para>
52601 In contrast to what happens in a system filter, header modifications that are
52602 specified on routers and transports apply only to the particular recipient
52603 addresses that are being processed by those routers and transports. These
52604 changes do not actually take place until a copy of the message is being
52605 transported. Therefore, they do not affect the basic set of header lines, and
52606 they do not affect the values of the variables that refer to header lines.
52607 </para>
52608 <para>
52609 <emphasis role="bold">Note</emphasis>: In particular, this means that any expansions in the configuration of
52610 the transport cannot refer to the modified header lines, because such
52611 expansions all occur before the message is actually transported.
52612 </para>
52613 <para>
52614 For both routers and transports, the result of expanding a <option>headers_add</option>
52615 option must be in the form of one or more RFC 2822 header lines, separated by
52616 newlines (coded as <quote>\n</quote>). For example:
52617 </para>
52618 <literallayout class="monospaced">
52619 headers_add = X-added-header: added by $primary_hostname\n\
52620               X-added-second: another added header line
52621 </literallayout>
52622 <para>
52623 Exim does not check the syntax of these added header lines.
52624 </para>
52625 <para>
52626 The result of expanding <option>headers_remove</option> must consist of a colon-separated
52627 list of header names. This is confusing, because header names themselves are
52628 often terminated by colons. In this case, the colons are the list separators,
52629 not part of the names. For example:
52630 </para>
52631 <literallayout class="monospaced">
52632 headers_remove = return-receipt-to:acknowledge-to
52633 </literallayout>
52634 <para>
52635 When <option>headers_add</option> or <option>headers_remove</option> is specified on a router, its value
52636 is expanded at routing time, and then associated with all addresses that are
52637 accepted by that router, and also with any new addresses that it generates. If
52638 an address passes through several routers as a result of aliasing or
52639 forwarding, the changes are cumulative.
52640 </para>
52641 <para>
52642 <indexterm role="concept">
52643 <primary><option>unseen</option> option</primary>
52644 </indexterm>
52645 However, this does not apply to multiple routers that result from the use of
52646 the <option>unseen</option> option. Any header modifications that were specified by the
52647 <quote>unseen</quote> router or its predecessors apply only to the <quote>unseen</quote> delivery.
52648 </para>
52649 <para>
52650 Addresses that end up with different <option>headers_add</option> or <option>headers_remove</option>
52651 settings cannot be delivered together in a batch, so a transport is always
52652 dealing with a set of addresses that have the same header-processing
52653 requirements.
52654 </para>
52655 <para>
52656 The transport starts by writing the original set of header lines that arrived
52657 with the message, possibly modified by the system filter. As it writes out
52658 these lines, it consults the list of header names that were attached to the
52659 recipient address(es) by <option>headers_remove</option> options in routers, and it also
52660 consults the transport&#x2019;s own <option>headers_remove</option> option. Header lines whose
52661 names are on either of these lists are not written out. If there are multiple
52662 instances of any listed header, they are all skipped.
52663 </para>
52664 <para>
52665 After the remaining original header lines have been written, new header
52666 lines that were specified by routers&#x2019; <option>headers_add</option> options are written, in
52667 the order in which they were attached to the address. These are followed by any
52668 header lines specified by the transport&#x2019;s <option>headers_add</option> option.
52669 </para>
52670 <para>
52671 This way of handling header line modifications in routers and transports has
52672 the following consequences:
52673 </para>
52674 <itemizedlist>
52675 <listitem>
52676 <para>
52677 The original set of header lines, possibly modified by the system filter,
52678 remains <quote>visible</quote>, in the sense that the <varname>$header_</varname><emphasis>xxx</emphasis> variables refer
52679 to it, at all times.
52680 </para>
52681 </listitem>
52682 <listitem>
52683 <para>
52684 Header lines that are added by a router&#x2019;s
52685 <option>headers_add</option> option are not accessible by means of the <varname>$header_</varname><emphasis>xxx</emphasis>
52686 expansion syntax in subsequent routers or the transport.
52687 </para>
52688 </listitem>
52689 <listitem>
52690 <para>
52691 Conversely, header lines that are specified for removal by <option>headers_remove</option>
52692 in a router remain visible to subsequent routers and the transport.
52693 </para>
52694 </listitem>
52695 <listitem>
52696 <para>
52697 Headers added to an address by <option>headers_add</option> in a router cannot be removed by
52698 a later router or by a transport.
52699 </para>
52700 </listitem>
52701 <listitem>
52702 <para>
52703 An added header can refer to the contents of an original header that is to be
52704 removed, even it has the same name as the added header. For example:
52705 </para>
52706 <literallayout class="monospaced">
52707 headers_remove = subject
52708 headers_add = Subject: new subject (was: $h_subject:)
52709 </literallayout>
52710 </listitem>
52711 </itemizedlist>
52712 <para>
52713 <emphasis role="bold">Warning</emphasis>: The <option>headers_add</option> and <option>headers_remove</option> options cannot be used
52714 for a <command>redirect</command> router that has the <option>one_time</option> option set.
52715 </para>
52716 </section>
52717 <section id="SECTconstr">
52718 <title>Constructed addresses</title>
52719 <para>
52720 <indexterm role="concept">
52721 <primary>address</primary>
52722 <secondary>constructed</secondary>
52723 </indexterm>
52724 <indexterm role="concept">
52725 <primary>constructed address</primary>
52726 </indexterm>
52727 When Exim constructs a sender address for a locally-generated message, it uses
52728 the form
52729 </para>
52730 <literallayout>
52731 &lt;<emphasis>user name</emphasis>&gt;&nbsp;&nbsp;&lt;<emphasis>login</emphasis><literal>@</literal><emphasis>qualify_domain</emphasis>&gt;
52732 </literallayout>
52733 <para>
52734 For example:
52735 </para>
52736 <literallayout class="monospaced">
52737 Zaphod Beeblebrox &lt;zaphod@end.univ.example&gt;
52738 </literallayout>
52739 <para>
52740 The user name is obtained from the <option>-F</option> command line option if set, or
52741 otherwise by looking up the calling user by <function>getpwuid()</function> and extracting the
52742 <quote>gecos</quote> field from the password entry. If the <quote>gecos</quote> field contains an
52743 ampersand character, this is replaced by the login name with the first letter
52744 upper cased, as is conventional in a number of operating systems. See the
52745 <option>gecos_name</option> option for a way to tailor the handling of the <quote>gecos</quote> field.
52746 The <option>unknown_username</option> option can be used to specify user names in cases when
52747 there is no password file entry.
52748 </para>
52749 <para>
52750 <indexterm role="concept">
52751 <primary>RFC 2047</primary>
52752 </indexterm>
52753 In all cases, the user name is made to conform to RFC 2822 by quoting all or
52754 parts of it if necessary. In addition, if it contains any non-printing
52755 characters, it is encoded as described in RFC 2047, which defines a way of
52756 including non-ASCII characters in header lines. The value of the
52757 <option>headers_charset</option> option specifies the name of the encoding that is used (the
52758 characters are assumed to be in this encoding). The setting of
52759 <option>print_topbitchars</option> controls whether characters with the top bit set (that
52760 is, with codes greater than 127) count as printing characters or not.
52761 </para>
52762 </section>
52763 <section>
52764 <title>Case of local parts</title>
52765 <para>
52766 <indexterm role="concept">
52767 <primary>case of local parts</primary>
52768 </indexterm>
52769 <indexterm role="concept">
52770 <primary>local part</primary>
52771 <secondary>case of</secondary>
52772 </indexterm>
52773 RFC 2822 states that the case of letters in the local parts of addresses cannot
52774 be assumed to be non-significant. Exim preserves the case of local parts of
52775 addresses, but by default it uses a lower-cased form when it is routing,
52776 because on most Unix systems, usernames are in lower case and case-insensitive
52777 routing is required. However, any particular router can be made to use the
52778 original case for local parts by setting the <option>caseful_local_part</option> generic
52779 router option.
52780 </para>
52781 <para>
52782 <indexterm role="concept">
52783 <primary>mixed-case login names</primary>
52784 </indexterm>
52785 If you must have mixed-case user names on your system, the best way to proceed,
52786 assuming you want case-independent handling of incoming email, is to set up
52787 your first router to convert incoming local parts in your domains to the
52788 correct case by means of a file lookup. For example:
52789 </para>
52790 <literallayout class="monospaced">
52791 correct_case:
52792   driver = redirect
52793   domains = +local_domains
52794   data = ${lookup{$local_part}cdb\
52795               {/etc/usercased.cdb}{$value}fail}\
52796               @$domain
52797 </literallayout>
52798 <para>
52799 For this router, the local part is forced to lower case by the default action
52800 (<option>caseful_local_part</option> is not set). The lower-cased local part is used to look
52801 up a new local part in the correct case. If you then set <option>caseful_local_part</option>
52802 on any subsequent routers which process your domains, they will operate on
52803 local parts with the correct case in a case-sensitive manner.
52804 </para>
52805 </section>
52806 <section>
52807 <title>Dots in local parts</title>
52808 <para>
52809 <indexterm role="concept">
52810 <primary>dot</primary>
52811 <secondary>in local part</secondary>
52812 </indexterm>
52813 <indexterm role="concept">
52814 <primary>local part</primary>
52815 <secondary>dots in</secondary>
52816 </indexterm>
52817 RFC 2822 forbids empty components in local parts. That is, an unquoted local
52818 part may not begin or end with a dot, nor have two consecutive dots in the
52819 middle. However, it seems that many MTAs do not enforce this, so Exim permits
52820 empty components for compatibility.
52821 </para>
52822 </section>
52823 <section>
52824 <title>Rewriting addresses</title>
52825 <para>
52826 <indexterm role="concept">
52827 <primary>rewriting</primary>
52828 <secondary>addresses</secondary>
52829 </indexterm>
52830 Rewriting of sender and recipient addresses, and addresses in headers, can
52831 happen automatically, or as the result of configuration options, as described
52832 in chapter <xref linkend="CHAPrewrite"/>. The headers that may be affected by this are
52833 <emphasis>Bcc:</emphasis>, <emphasis>Cc:</emphasis>, <emphasis>From:</emphasis>, <emphasis>Reply-To:</emphasis>, <emphasis>Sender:</emphasis>, and <emphasis>To:</emphasis>.
52834 </para>
52835 <para>
52836 Automatic rewriting includes qualification, as mentioned above. The other case
52837 in which it can happen is when an incomplete non-local domain is given. The
52838 routing process may cause this to be expanded into the full domain name. For
52839 example, a header such as
52840 </para>
52841 <literallayout class="monospaced">
52842 To: hare@teaparty
52843 </literallayout>
52844 <para>
52845 might get rewritten as
52846 </para>
52847 <literallayout class="monospaced">
52848 To: hare@teaparty.wonderland.fict.example
52849 </literallayout>
52850 <para>
52851 Rewriting as a result of routing is the one kind of message processing that
52852 does not happen at input time, as it cannot be done until the address has
52853 been routed.
52854 </para>
52855 <para>
52856 Strictly, one should not do <emphasis>any</emphasis> deliveries of a message until all its
52857 addresses have been routed, in case any of the headers get changed as a
52858 result of routing. However, doing this in practice would hold up many
52859 deliveries for unreasonable amounts of time, just because one address could not
52860 immediately be routed. Exim therefore does not delay other deliveries when
52861 routing of one or more addresses is deferred.
52862 <indexterm role="concept" startref="IIDmesproc" class="endofrange"/>
52863 </para>
52864 </section>
52865 </chapter>
52866
52867 <chapter id="CHAPSMTP">
52868 <title>SMTP processing</title>
52869 <para>
52870 <indexterm role="concept" id="IIDsmtpproc1" class="startofrange">
52871 <primary>SMTP</primary>
52872 <secondary>processing details</secondary>
52873 </indexterm>
52874 <indexterm role="concept" id="IIDsmtpproc2" class="startofrange">
52875 <primary>LMTP</primary>
52876 <secondary>processing details</secondary>
52877 </indexterm>
52878 Exim supports a number of different ways of using the SMTP protocol, and its
52879 LMTP variant, which is an interactive protocol for transferring messages into a
52880 closed mail store application. This chapter contains details of how SMTP is
52881 processed. For incoming mail, the following are available:
52882 </para>
52883 <itemizedlist>
52884 <listitem>
52885 <para>
52886 SMTP over TCP/IP (Exim daemon or <emphasis>inetd</emphasis>);
52887 </para>
52888 </listitem>
52889 <listitem>
52890 <para>
52891 SMTP over the standard input and output (the <option>-bs</option> option);
52892 </para>
52893 </listitem>
52894 <listitem>
52895 <para>
52896 Batched SMTP on the standard input (the <option>-bS</option> option).
52897 </para>
52898 </listitem>
52899 </itemizedlist>
52900 <para>
52901 For mail delivery, the following are available:
52902 </para>
52903 <itemizedlist>
52904 <listitem>
52905 <para>
52906 SMTP over TCP/IP (the <command>smtp</command> transport);
52907 </para>
52908 </listitem>
52909 <listitem>
52910 <para>
52911 LMTP over TCP/IP (the <command>smtp</command> transport with the <option>protocol</option> option set to
52912 <quote>lmtp</quote>);
52913 </para>
52914 </listitem>
52915 <listitem>
52916 <para>
52917 LMTP over a pipe to a process running in the local host (the <command>lmtp</command>
52918 transport);
52919 </para>
52920 </listitem>
52921 <listitem>
52922 <para>
52923 Batched SMTP to a file or pipe (the <command>appendfile</command> and <command>pipe</command> transports with
52924 the <option>use_bsmtp</option> option set).
52925 </para>
52926 </listitem>
52927 </itemizedlist>
52928 <para>
52929 <emphasis>Batched SMTP</emphasis> is the name for a process in which batches of messages are
52930 stored in or read from files (or pipes), in a format in which SMTP commands are
52931 used to contain the envelope information.
52932 </para>
52933 <section id="SECToutSMTPTCP">
52934 <title>Outgoing SMTP and LMTP over TCP/IP</title>
52935 <para>
52936 <indexterm role="concept">
52937 <primary>SMTP</primary>
52938 <secondary>outgoing over TCP/IP</secondary>
52939 </indexterm>
52940 <indexterm role="concept">
52941 <primary>outgoing SMTP over TCP/IP</primary>
52942 </indexterm>
52943 <indexterm role="concept">
52944 <primary>LMTP</primary>
52945 <secondary>over TCP/IP</secondary>
52946 </indexterm>
52947 <indexterm role="concept">
52948 <primary>outgoing LMTP over TCP/IP</primary>
52949 </indexterm>
52950 <indexterm role="concept">
52951 <primary>EHLO</primary>
52952 </indexterm>
52953 <indexterm role="concept">
52954 <primary>HELO</primary>
52955 </indexterm>
52956 <indexterm role="concept">
52957 <primary>SIZE option on MAIL command</primary>
52958 </indexterm>
52959 Outgoing SMTP and LMTP over TCP/IP is implemented by the <command>smtp</command> transport.
52960 The <option>protocol</option> option selects which protocol is to be used, but the actual
52961 processing is the same in both cases.
52962 </para>
52963 <para>
52964 If, in response to its EHLO command, Exim is told that the SIZE
52965 parameter is supported, it adds SIZE=&lt;<emphasis>n</emphasis>&gt; to each subsequent MAIL
52966 command. The value of &lt;<emphasis>n</emphasis>&gt; is the message size plus the value of the
52967 <option>size_addition</option> option (default 1024) to allow for additions to the message
52968 such as per-transport header lines, or changes made in a
52969 <indexterm role="concept">
52970 <primary>transport</primary>
52971 <secondary>filter</secondary>
52972 </indexterm>
52973 <indexterm role="concept">
52974 <primary>filter</primary>
52975 <secondary>transport filter</secondary>
52976 </indexterm>
52977 transport filter. If <option>size_addition</option> is set negative, the use of SIZE is
52978 suppressed.
52979 </para>
52980 <para>
52981 If the remote server advertises support for PIPELINING, Exim uses the
52982 pipelining extension to SMTP (RFC 2197) to reduce the number of TCP/IP packets
52983 required for the transaction.
52984 </para>
52985 <para>
52986 If the remote server advertises support for the STARTTLS command, and Exim
52987 was built to support TLS encryption, it tries to start a TLS session unless the
52988 server matches <option>hosts_avoid_tls</option>. See chapter <xref linkend="CHAPTLS"/> for more details.
52989 </para>
52990 <para>
52991 If the remote server advertises support for the AUTH command, Exim scans
52992 the authenticators configuration for any suitable client settings, as described
52993 in chapter <xref linkend="CHAPSMTPAUTH"/>.
52994 </para>
52995 <para>
52996 <indexterm role="concept">
52997 <primary>carriage return</primary>
52998 </indexterm>
52999 <indexterm role="concept">
53000 <primary>linefeed</primary>
53001 </indexterm>
53002 Responses from the remote host are supposed to be terminated by CR followed by
53003 LF. However, there are known to be hosts that do not send CR characters, so in
53004 order to be able to interwork with such hosts, Exim treats LF on its own as a
53005 line terminator.
53006 </para>
53007 <para>
53008 If a message contains a number of different addresses, all those with the same
53009 characteristics (for example, the same envelope sender) that resolve to the
53010 same set of hosts, in the same order, are sent in a single SMTP transaction,
53011 even if they are for different domains, unless there are more than the setting
53012 of the <option>max_rcpts</option> option in the <command>smtp</command> transport allows, in which case
53013 they are split into groups containing no more than <option>max_rcpts</option> addresses
53014 each. If <option>remote_max_parallel</option> is greater than one, such groups may be sent
53015 in parallel sessions. The order of hosts with identical MX values is not
53016 significant when checking whether addresses can be batched in this way.
53017 </para>
53018 <para>
53019 When the <command>smtp</command> transport suffers a temporary failure that is not
53020 message-related, Exim updates its transport-specific database, which contains
53021 records indexed by host name that remember which messages are waiting for each
53022 particular host. It also updates the retry database with new retry times.
53023 </para>
53024 <para>
53025 <indexterm role="concept">
53026 <primary>hints database</primary>
53027 <secondary>retry keys</secondary>
53028 </indexterm>
53029 Exim&#x2019;s retry hints are based on host name plus IP address, so if one address of
53030 a multi-homed host is broken, it will soon be skipped most of the time.
53031 See the next section for more detail about error handling.
53032 </para>
53033 <para>
53034 <indexterm role="concept">
53035 <primary>SMTP</primary>
53036 <secondary>passed connection</secondary>
53037 </indexterm>
53038 <indexterm role="concept">
53039 <primary>SMTP</primary>
53040 <secondary>batching over TCP/IP</secondary>
53041 </indexterm>
53042 When a message is successfully delivered over a TCP/IP SMTP connection, Exim
53043 looks in the hints database for the transport to see if there are any queued
53044 messages waiting for the host to which it is connected. If it finds one, it
53045 creates a new Exim process using the <option>-MC</option> option (which can only be used by
53046 a process running as root or the Exim user) and passes the TCP/IP socket to it
53047 so that it can deliver another message using the same socket. The new process
53048 does only those deliveries that are routed to the connected host, and may in
53049 turn pass the socket on to a third process, and so on.
53050 </para>
53051 <para>
53052 The <option>connection_max_messages</option> option of the <command>smtp</command> transport can be used to
53053 limit the number of messages sent down a single TCP/IP connection.
53054 </para>
53055 <para>
53056 <indexterm role="concept">
53057 <primary>asterisk</primary>
53058 <secondary>after IP address</secondary>
53059 </indexterm>
53060 The second and subsequent messages delivered down an existing connection are
53061 identified in the main log by the addition of an asterisk after the closing
53062 square bracket of the IP address.
53063 </para>
53064 </section>
53065 <section id="SECToutSMTPerr">
53066 <title>Errors in outgoing SMTP</title>
53067 <para>
53068 <indexterm role="concept">
53069 <primary>error</primary>
53070 <secondary>in outgoing SMTP</secondary>
53071 </indexterm>
53072 <indexterm role="concept">
53073 <primary>SMTP</primary>
53074 <secondary>errors in outgoing</secondary>
53075 </indexterm>
53076 <indexterm role="concept">
53077 <primary>host</primary>
53078 <secondary>error</secondary>
53079 </indexterm>
53080 Three different kinds of error are recognized for outgoing SMTP: host errors,
53081 message errors, and recipient errors.
53082 </para>
53083 <variablelist>
53084 <varlistentry>
53085 <term><emphasis role="bold">Host errors</emphasis></term>
53086 <listitem>
53087 <para>
53088 A host error is not associated with a particular message or with a
53089 particular recipient of a message. The host errors are:
53090 </para>
53091 <itemizedlist>
53092 <listitem>
53093 <para>
53094 Connection refused or timed out,
53095 </para>
53096 </listitem>
53097 <listitem>
53098 <para>
53099 Any error response code on connection,
53100 </para>
53101 </listitem>
53102 <listitem>
53103 <para>
53104 Any error response code to EHLO or HELO,
53105 </para>
53106 </listitem>
53107 <listitem>
53108 <para>
53109 Loss of connection at any time, except after <quote>.</quote>,
53110 </para>
53111 </listitem>
53112 <listitem>
53113 <para>
53114 I/O errors at any time,
53115 </para>
53116 </listitem>
53117 <listitem>
53118 <para>
53119 Timeouts during the session, other than in response to MAIL, RCPT or
53120 the <quote>.</quote> at the end of the data.
53121 </para>
53122 </listitem>
53123 </itemizedlist>
53124 <para>
53125 For a host error, a permanent error response on connection, or in response to
53126 EHLO, causes all addresses routed to the host to be failed. Any other host
53127 error causes all addresses to be deferred, and retry data to be created for the
53128 host. It is not tried again, for any message, until its retry time arrives. If
53129 the current set of addresses are not all delivered in this run (to some
53130 alternative host), the message is added to the list of those waiting for this
53131 host, so if it is still undelivered when a subsequent successful delivery is
53132 made to the host, it will be sent down the same SMTP connection.
53133 </para>
53134 </listitem></varlistentry>
53135 <varlistentry>
53136 <term><emphasis role="bold">Message errors</emphasis></term>
53137 <listitem>
53138 <para>
53139 <indexterm role="concept">
53140 <primary>message</primary>
53141 <secondary>error</secondary>
53142 </indexterm>
53143 A message error is associated with a particular message when sent to a
53144 particular host, but not with a particular recipient of the message. The
53145 message errors are:
53146 </para>
53147 <itemizedlist>
53148 <listitem>
53149 <para>
53150 Any error response code to MAIL, DATA, or the <quote>.</quote> that terminates
53151 the data,
53152 </para>
53153 </listitem>
53154 <listitem>
53155 <para>
53156 Timeout after MAIL,
53157 </para>
53158 </listitem>
53159 <listitem>
53160 <para>
53161 Timeout or loss of connection after the <quote>.</quote> that terminates the data. A
53162 timeout after the DATA command itself is treated as a host error, as is loss of
53163 connection at any other time.
53164 </para>
53165 </listitem>
53166 </itemizedlist>
53167 <para>
53168 For a message error, a permanent error response (5<emphasis>xx</emphasis>) causes all addresses
53169 to be failed, and a delivery error report to be returned to the sender. A
53170 temporary error response (4<emphasis>xx</emphasis>), or one of the timeouts, causes all
53171 addresses to be deferred. Retry data is not created for the host, but instead,
53172 a retry record for the combination of host plus message id is created. The
53173 message is not added to the list of those waiting for this host. This ensures
53174 that the failing message will not be sent to this host again until the retry
53175 time arrives. However, other messages that are routed to the host are not
53176 affected, so if it is some property of the message that is causing the error,
53177 it will not stop the delivery of other mail.
53178 </para>
53179 <para>
53180 If the remote host specified support for the SIZE parameter in its response
53181 to EHLO, Exim adds SIZE=<emphasis>nnn</emphasis> to the MAIL command, so an
53182 over-large message will cause a message error because the error arrives as a
53183 response to MAIL.
53184 </para>
53185 </listitem></varlistentry>
53186 <varlistentry>
53187 <term><emphasis role="bold">Recipient errors</emphasis></term>
53188 <listitem>
53189 <para>
53190 <indexterm role="concept">
53191 <primary>recipient</primary>
53192 <secondary>error</secondary>
53193 </indexterm>
53194 A recipient error is associated with a particular recipient of a message. The
53195 recipient errors are:
53196 </para>
53197 <itemizedlist>
53198 <listitem>
53199 <para>
53200 Any error response to RCPT,
53201 </para>
53202 </listitem>
53203 <listitem>
53204 <para>
53205 Timeout after RCPT.
53206 </para>
53207 </listitem>
53208 </itemizedlist>
53209 <para>
53210 For a recipient error, a permanent error response (5<emphasis>xx</emphasis>) causes the
53211 recipient address to be failed, and a bounce message to be returned to the
53212 sender. A temporary error response (4<emphasis>xx</emphasis>) or a timeout causes the failing
53213 address to be deferred, and routing retry data to be created for it. This is
53214 used to delay processing of the address in subsequent queue runs, until its
53215 routing retry time arrives. This applies to all messages, but because it
53216 operates only in queue runs, one attempt will be made to deliver a new message
53217 to the failing address before the delay starts to operate. This ensures that,
53218 if the failure is really related to the message rather than the recipient
53219 (<quote>message too big for this recipient</quote> is a possible example), other messages
53220 have a chance of getting delivered. If a delivery to the address does succeed,
53221 the retry information gets cleared, so all stuck messages get tried again, and
53222 the retry clock is reset.
53223 </para>
53224 <para>
53225 The message is not added to the list of those waiting for this host. Use of the
53226 host for other messages is unaffected, and except in the case of a timeout,
53227 other recipients are processed independently, and may be successfully delivered
53228 in the current SMTP session. After a timeout it is of course impossible to
53229 proceed with the session, so all addresses get deferred. However, those other
53230 than the one that failed do not suffer any subsequent retry delays. Therefore,
53231 if one recipient is causing trouble, the others have a chance of getting
53232 through when a subsequent delivery attempt occurs before the failing
53233 recipient&#x2019;s retry time.
53234 </para>
53235 </listitem></varlistentry>
53236 </variablelist>
53237 <para>
53238 In all cases, if there are other hosts (or IP addresses) available for the
53239 current set of addresses (for example, from multiple MX records), they are
53240 tried in this run for any undelivered addresses, subject of course to their
53241 own retry data. In other words, recipient error retry data does not take effect
53242 until the next delivery attempt.
53243 </para>
53244 <para>
53245 Some hosts have been observed to give temporary error responses to every
53246 MAIL command at certain times (<quote>insufficient space</quote> has been seen). It
53247 would be nice if such circumstances could be recognized, and defer data for the
53248 host itself created, but this is not possible within the current Exim design.
53249 What actually happens is that retry data for every (host, message) combination
53250 is created.
53251 </para>
53252 <para>
53253 The reason that timeouts after MAIL and RCPT are treated specially is that
53254 these can sometimes arise as a result of the remote host&#x2019;s verification
53255 procedures. Exim makes this assumption, and treats them as if a temporary error
53256 response had been received. A timeout after <quote>.</quote> is treated specially because
53257 it is known that some broken implementations fail to recognize the end of the
53258 message if the last character of the last line is a binary zero. Thus, it is
53259 helpful to treat this case as a message error.
53260 </para>
53261 <para>
53262 Timeouts at other times are treated as host errors, assuming a problem with the
53263 host, or the connection to it. If a timeout after MAIL, RCPT,
53264 or <quote>.</quote> is really a connection problem, the assumption is that at the next try
53265 the timeout is likely to occur at some other point in the dialogue, causing it
53266 then to be treated as a host error.
53267 </para>
53268 <para>
53269 There is experimental evidence that some MTAs drop the connection after the
53270 terminating <quote>.</quote> if they do not like the contents of the message for some
53271 reason, in contravention of the RFC, which indicates that a 5<emphasis>xx</emphasis> response
53272 should be given. That is why Exim treats this case as a message rather than a
53273 host error, in order not to delay other messages to the same host.
53274 </para>
53275 </section>
53276 <section>
53277 <title>Incoming SMTP messages over TCP/IP</title>
53278 <para>
53279 <indexterm role="concept">
53280 <primary>SMTP</primary>
53281 <secondary>incoming over TCP/IP</secondary>
53282 </indexterm>
53283 <indexterm role="concept">
53284 <primary>incoming SMTP over TCP/IP</primary>
53285 </indexterm>
53286 <indexterm role="concept">
53287 <primary>inetd</primary>
53288 </indexterm>
53289 <indexterm role="concept">
53290 <primary>daemon</primary>
53291 </indexterm>
53292 Incoming SMTP messages can be accepted in one of two ways: by running a
53293 listening daemon, or by using <emphasis>inetd</emphasis>. In the latter case, the entry in
53294 <filename>/etc/inetd.conf</filename> should be like this:
53295 </para>
53296 <literallayout class="monospaced">
53297 smtp stream tcp nowait exim /opt/exim/bin/exim in.exim -bs
53298 </literallayout>
53299 <para>
53300 Exim distinguishes between this case and the case of a locally running user
53301 agent using the <option>-bs</option> option by checking whether or not the standard input is
53302 a socket. When it is, either the port must be privileged (less than 1024), or
53303 the caller must be root or the Exim user. If any other user passes a socket
53304 with an unprivileged port number, Exim prints a message on the standard error
53305 stream and exits with an error code.
53306 </para>
53307 <para>
53308 By default, Exim does not make a log entry when a remote host connects or
53309 disconnects (either via the daemon or <emphasis>inetd</emphasis>), unless the disconnection is
53310 unexpected. It can be made to write such log entries by setting the
53311 <option>smtp_connection</option> log selector.
53312 </para>
53313 <para>
53314 <indexterm role="concept">
53315 <primary>carriage return</primary>
53316 </indexterm>
53317 <indexterm role="concept">
53318 <primary>linefeed</primary>
53319 </indexterm>
53320 Commands from the remote host are supposed to be terminated by CR followed by
53321 LF. However, there are known to be hosts that do not send CR characters. In
53322 order to be able to interwork with such hosts, Exim treats LF on its own as a
53323 line terminator.
53324 Furthermore, because common code is used for receiving messages from all
53325 sources, a CR on its own is also interpreted as a line terminator. However, the
53326 sequence <quote>CR, dot, CR</quote> does not terminate incoming SMTP data.
53327 </para>
53328 <para>
53329 <indexterm role="concept">
53330 <primary>EHLO</primary>
53331 <secondary>invalid data</secondary>
53332 </indexterm>
53333 <indexterm role="concept">
53334 <primary>HELO</primary>
53335 <secondary>invalid data</secondary>
53336 </indexterm>
53337 One area that sometimes gives rise to problems concerns the EHLO or
53338 HELO commands. Some clients send syntactically invalid versions of these
53339 commands, which Exim rejects by default. (This is nothing to do with verifying
53340 the data that is sent, so <option>helo_verify_hosts</option> is not relevant.) You can tell
53341 Exim not to apply a syntax check by setting <option>helo_accept_junk_hosts</option> to
53342 match the broken hosts that send invalid commands.
53343 </para>
53344 <para>
53345 <indexterm role="concept">
53346 <primary>SIZE option on MAIL command</primary>
53347 </indexterm>
53348 <indexterm role="concept">
53349 <primary>MAIL</primary>
53350 <secondary>SIZE option</secondary>
53351 </indexterm>
53352 The amount of disk space available is checked whenever SIZE is received on
53353 a MAIL command, independently of whether <option>message_size_limit</option> or
53354 <option>check_spool_space</option> is configured, unless <option>smtp_check_spool_space</option> is set
53355 false. A temporary error is given if there is not enough space. If
53356 <option>check_spool_space</option> is set, the check is for that amount of space plus the
53357 value given with SIZE, that is, it checks that the addition of the incoming
53358 message will not reduce the space below the threshold.
53359 </para>
53360 <para>
53361 When a message is successfully received, Exim includes the local message id in
53362 its response to the final <quote>.</quote> that terminates the data. If the remote host
53363 logs this text it can help with tracing what has happened to a message.
53364 </para>
53365 <para>
53366 The Exim daemon can limit the number of simultaneous incoming connections it is
53367 prepared to handle (see the <option>smtp_accept_max</option> option). It can also limit the
53368 number of simultaneous incoming connections from a single remote host (see the
53369 <option>smtp_accept_max_per_host</option> option). Additional connection attempts are
53370 rejected using the SMTP temporary error code 421.
53371 </para>
53372 <para>
53373 The Exim daemon does not rely on the SIGCHLD signal to detect when a
53374 subprocess has finished, as this can get lost at busy times. Instead, it looks
53375 for completed subprocesses every time it wakes up. Provided there are other
53376 things happening (new incoming calls, starts of queue runs), completed
53377 processes will be noticed and tidied away. On very quiet systems you may
53378 sometimes see a <quote>defunct</quote> Exim process hanging about. This is not a problem;
53379 it will be noticed when the daemon next wakes up.
53380 </para>
53381 <para>
53382 When running as a daemon, Exim can reserve some SMTP slots for specific hosts,
53383 and can also be set up to reject SMTP calls from non-reserved hosts at times of
53384 high system load &ndash; for details see the <option>smtp_accept_reserve</option>,
53385 <option>smtp_load_reserve</option>, and <option>smtp_reserve_hosts</option> options. The load check
53386 applies in both the daemon and <emphasis>inetd</emphasis> cases.
53387 </para>
53388 <para>
53389 Exim normally starts a delivery process for each message received, though this
53390 can be varied by means of the <option>-odq</option> command line option and the
53391 <option>queue_only</option>, <option>queue_only_file</option>, and <option>queue_only_load</option> options. The
53392 number of simultaneously running delivery processes started in this way from
53393 SMTP input can be limited by the <option>smtp_accept_queue</option> and
53394 <option>smtp_accept_queue_per_connection</option> options. When either limit is reached,
53395 subsequently received messages are just put on the input queue without starting
53396 a delivery process.
53397 </para>
53398 <para>
53399 The controls that involve counts of incoming SMTP calls (<option>smtp_accept_max</option>,
53400 <option>smtp_accept_queue</option>, <option>smtp_accept_reserve</option>) are not available when Exim is
53401 started up from the <emphasis>inetd</emphasis> daemon, because in that case each connection is
53402 handled by an entirely independent Exim process. Control by load average is,
53403 however, available with <emphasis>inetd</emphasis>.
53404 </para>
53405 <para>
53406 Exim can be configured to verify addresses in incoming SMTP commands as they
53407 are received. See chapter <xref linkend="CHAPACL"/> for details. It can also be configured
53408 to rewrite addresses at this time &ndash; before any syntax checking is done. See
53409 section <xref linkend="SECTrewriteS"/>.
53410 </para>
53411 <para>
53412 Exim can also be configured to limit the rate at which a client host submits
53413 MAIL and RCPT commands in a single SMTP session. See the
53414 <option>smtp_ratelimit_hosts</option> option.
53415 </para>
53416 </section>
53417 <section>
53418 <title>Unrecognized SMTP commands</title>
53419 <para>
53420 <indexterm role="concept">
53421 <primary>SMTP</primary>
53422 <secondary>unrecognized commands</secondary>
53423 </indexterm>
53424 If Exim receives more than <option>smtp_max_unknown_commands</option> unrecognized SMTP
53425 commands during a single SMTP connection, it drops the connection after sending
53426 the error response to the last command. The default value for
53427 <option>smtp_max_unknown_commands</option> is 3. This is a defence against some kinds of
53428 abuse that subvert web servers into making connections to SMTP ports; in these
53429 circumstances, a number of non-SMTP lines are sent first.
53430 </para>
53431 </section>
53432 <section>
53433 <title>Syntax and protocol errors in SMTP commands</title>
53434 <para>
53435 <indexterm role="concept">
53436 <primary>SMTP</primary>
53437 <secondary>syntax errors</secondary>
53438 </indexterm>
53439 <indexterm role="concept">
53440 <primary>SMTP</primary>
53441 <secondary>protocol errors</secondary>
53442 </indexterm>
53443 A syntax error is detected if an SMTP command is recognized, but there is
53444 something syntactically wrong with its data, for example, a malformed email
53445 address in a RCPT command. Protocol errors include invalid command
53446 sequencing such as RCPT before MAIL. If Exim receives more than
53447 <option>smtp_max_synprot_errors</option> such commands during a single SMTP connection, it
53448 drops the connection after sending the error response to the last command. The
53449 default value for <option>smtp_max_synprot_errors</option> is 3. This is a defence against
53450 broken clients that loop sending bad commands (yes, it has been seen).
53451 </para>
53452 </section>
53453 <section>
53454 <title>Use of non-mail SMTP commands</title>
53455 <para>
53456 <indexterm role="concept">
53457 <primary>SMTP</primary>
53458 <secondary>non-mail commands</secondary>
53459 </indexterm>
53460 The <quote>non-mail</quote> SMTP commands are those other than MAIL, RCPT, and
53461 DATA. Exim counts such commands, and drops the connection if there are too
53462 many of them in a single SMTP session. This action catches some
53463 denial-of-service attempts and things like repeated failing AUTHs, or a mad
53464 client looping sending EHLO. The global option <option>smtp_accept_max_nonmail</option>
53465 defines what <quote>too many</quote> means. Its default value is 10.
53466 </para>
53467 <para>
53468 When a new message is expected, one occurrence of RSET is not counted. This
53469 allows a client to send one RSET between messages (this is not necessary,
53470 but some clients do it). Exim also allows one uncounted occurence of HELO
53471 or EHLO, and one occurrence of STARTTLS between messages. After
53472 starting up a TLS session, another EHLO is expected, and so it too is not
53473 counted.
53474 </para>
53475 <para>
53476 The first occurrence of AUTH in a connection, or immediately following
53477 STARTTLS is also not counted. Otherwise, all commands other than MAIL,
53478 RCPT, DATA, and QUIT are counted.
53479 </para>
53480 <para>
53481 You can control which hosts are subject to the limit set by
53482 <option>smtp_accept_max_nonmail</option> by setting
53483 <option>smtp_accept_max_nonmail_hosts</option>. The default value is <literal>*</literal>, which makes
53484 the limit apply to all hosts. This option means that you can exclude any
53485 specific badly-behaved hosts that you have to live with.
53486 </para>
53487 </section>
53488 <section>
53489 <title>The VRFY and EXPN commands</title>
53490 <para>
53491 When Exim receives a VRFY or EXPN command on a TCP/IP connection, it
53492 runs the ACL specified by <option>acl_smtp_vrfy</option> or <option>acl_smtp_expn</option> (as
53493 appropriate) in order to decide whether the command should be accepted or not.
53494 If no ACL is defined, the command is rejected.
53495 </para>
53496 <para>
53497 <indexterm role="concept">
53498 <primary>VRFY</primary>
53499 <secondary>processing</secondary>
53500 </indexterm>
53501 When VRFY is accepted, it runs exactly the same code as when Exim is
53502 called with the <option>-bv</option> option.
53503 </para>
53504 <para>
53505 <indexterm role="concept">
53506 <primary>EXPN</primary>
53507 <secondary>processing</secondary>
53508 </indexterm>
53509 When EXPN is accepted, a single-level expansion of the address is done.
53510 EXPN is treated as an <quote>address test</quote> (similar to the <option>-bt</option> option) rather
53511 than a verification (the <option>-bv</option> option). If an unqualified local part is given
53512 as the argument to EXPN, it is qualified with <option>qualify_domain</option>. Rejections
53513 of VRFY and EXPN commands are logged on the main and reject logs, and
53514 VRFY verification failures are logged on the main log for consistency with
53515 RCPT failures.
53516 </para>
53517 </section>
53518 <section id="SECTETRN">
53519 <title>The ETRN command</title>
53520 <para>
53521 <indexterm role="concept">
53522 <primary>ETRN</primary>
53523 <secondary>processing</secondary>
53524 </indexterm>
53525 RFC 1985 describes an SMTP command called ETRN that is designed to
53526 overcome the security problems of the TURN command (which has fallen into
53527 disuse). When Exim receives an ETRN command on a TCP/IP connection, it runs
53528 the ACL specified by <option>acl_smtp_etrn</option> in order to decide whether the command
53529 should be accepted or not. If no ACL is defined, the command is rejected.
53530 </para>
53531 <para>
53532 The ETRN command is concerned with <quote>releasing</quote> messages that are awaiting
53533 delivery to certain hosts. As Exim does not organize its message queue by host,
53534 the only form of ETRN that is supported by default is the one where the
53535 text starts with the <quote>#</quote> prefix, in which case the remainder of the text is
53536 specific to the SMTP server. A valid ETRN command causes a run of Exim with
53537 the <option>-R</option> option to happen, with the remainder of the ETRN text as its
53538 argument. For example,
53539 </para>
53540 <literallayout class="monospaced">
53541 ETRN #brigadoon
53542 </literallayout>
53543 <para>
53544 runs the command
53545 </para>
53546 <literallayout class="monospaced">
53547 exim -R brigadoon
53548 </literallayout>
53549 <para>
53550 which causes a delivery attempt on all messages with undelivered addresses
53551 containing the text <quote>brigadoon</quote>. When <option>smtp_etrn_serialize</option> is set (the
53552 default), Exim prevents the simultaneous execution of more than one queue run
53553 for the same argument string as a result of an ETRN command. This stops
53554 a misbehaving client from starting more than one queue runner at once.
53555 </para>
53556 <para>
53557 <indexterm role="concept">
53558 <primary>hints database</primary>
53559 <secondary>ETRN serialization</secondary>
53560 </indexterm>
53561 Exim implements the serialization by means of a hints database in which a
53562 record is written whenever a process is started by ETRN, and deleted when
53563 the process completes. However, Exim does not keep the SMTP session waiting for
53564 the ETRN process to complete. Once ETRN is accepted, the client is sent
53565 a <quote>success</quote> return code. Obviously there is scope for hints records to get
53566 left lying around if there is a system or program crash. To guard against this,
53567 Exim ignores any records that are more than six hours old.
53568 </para>
53569 <para>
53570 <indexterm role="concept">
53571 <primary><option>smtp_etrn_command</option></primary>
53572 </indexterm>
53573 For more control over what ETRN does, the <option>smtp_etrn_command</option> option can
53574 used. This specifies a command that is run whenever ETRN is received,
53575 whatever the form of its argument. For
53576 example:
53577 </para>
53578 <literallayout class="monospaced">
53579 smtp_etrn_command = /etc/etrn_command $domain \
53580                     $sender_host_address
53581 </literallayout>
53582 <para>
53583 <indexterm role="concept">
53584 <primary><varname>$domain</varname></primary>
53585 </indexterm>
53586 The string is split up into arguments which are independently expanded. The
53587 expansion variable <varname>$domain</varname> is set to the argument of the ETRN command,
53588 and no syntax checking is done on the contents of this argument. Exim does not
53589 wait for the command to complete, so its status code is not checked. Exim runs
53590 under its own uid and gid when receiving incoming SMTP, so it is not possible
53591 for it to change them before running the command.
53592 </para>
53593 </section>
53594 <section>
53595 <title>Incoming local SMTP</title>
53596 <para>
53597 <indexterm role="concept">
53598 <primary>SMTP</primary>
53599 <secondary>local incoming</secondary>
53600 </indexterm>
53601 Some user agents use SMTP to pass messages to their local MTA using the
53602 standard input and output, as opposed to passing the envelope on the command
53603 line and writing the message to the standard input. This is supported by the
53604 <option>-bs</option> option. This form of SMTP is handled in the same way as incoming
53605 messages over TCP/IP (including the use of ACLs), except that the envelope
53606 sender given in a MAIL command is ignored unless the caller is trusted. In
53607 an ACL you can detect this form of SMTP input by testing for an empty host
53608 identification. It is common to have this as the first line in the ACL that
53609 runs for RCPT commands:
53610 </para>
53611 <literallayout class="monospaced">
53612 accept hosts = :
53613 </literallayout>
53614 <para>
53615 This accepts SMTP messages from local processes without doing any other tests.
53616 </para>
53617 </section>
53618 <section id="SECTbatchSMTP">
53619 <title>Outgoing batched SMTP</title>
53620 <para>
53621 <indexterm role="concept">
53622 <primary>SMTP</primary>
53623 <secondary>batched outgoing</secondary>
53624 </indexterm>
53625 <indexterm role="concept">
53626 <primary>batched SMTP output</primary>
53627 </indexterm>
53628 Both the <command>appendfile</command> and <command>pipe</command> transports can be used for handling
53629 batched SMTP. Each has an option called <option>use_bsmtp</option> which causes messages to
53630 be output in BSMTP format. No SMTP responses are possible for this form of
53631 delivery. All it is doing is using SMTP commands as a way of transmitting the
53632 envelope along with the message.
53633 </para>
53634 <para>
53635 The message is written to the file or pipe preceded by the SMTP commands
53636 MAIL and RCPT, and followed by a line containing a single dot. Lines in
53637 the message that start with a dot have an extra dot added. The SMTP command
53638 HELO is not normally used. If it is required, the <option>message_prefix</option> option
53639 can be used to specify it.
53640 </para>
53641 <para>
53642 Because <command>appendfile</command> and <command>pipe</command> are both local transports, they accept only
53643 one recipient address at a time by default. However, you can arrange for them
53644 to handle several addresses at once by setting the <option>batch_max</option> option. When
53645 this is done for BSMTP, messages may contain multiple RCPT commands. See
53646 chapter <xref linkend="CHAPbatching"/> for more details.
53647 </para>
53648 <para>
53649 <indexterm role="concept">
53650 <primary><varname>$host</varname></primary>
53651 </indexterm>
53652 When one or more addresses are routed to a BSMTP transport by a router that
53653 sets up a host list, the name of the first host on the list is available to the
53654 transport in the variable <varname>$host</varname>. Here is an example of such a transport and
53655 router:
53656 </para>
53657 <literallayout class="monospaced">
53658 begin routers
53659 route_append:
53660   driver = manualroute
53661   transport = smtp_appendfile
53662   route_list = domain.example  batch.host.example
53663
53664 begin transports
53665 smtp_appendfile:
53666   driver = appendfile
53667   directory = /var/bsmtp/$host
53668   batch_max = 1000
53669   use_bsmtp
53670   user = exim
53671 </literallayout>
53672 <para>
53673 This causes messages addressed to <emphasis>domain.example</emphasis> to be written in BSMTP
53674 format to <filename>/var/bsmtp/batch.host.example</filename>, with only a single copy of each
53675 message (unless there are more than 1000 recipients).
53676 </para>
53677 </section>
53678 <section id="SECTincomingbatchedSMTP">
53679 <title>Incoming batched SMTP</title>
53680 <para>
53681 <indexterm role="concept">
53682 <primary>SMTP</primary>
53683 <secondary>batched incoming</secondary>
53684 </indexterm>
53685 <indexterm role="concept">
53686 <primary>batched SMTP input</primary>
53687 </indexterm>
53688 The <option>-bS</option> command line option causes Exim to accept one or more messages by
53689 reading SMTP on the standard input, but to generate no responses. If the caller
53690 is trusted, the senders in the MAIL commands are believed; otherwise the
53691 sender is always the caller of Exim. Unqualified senders and receivers are not
53692 rejected (there seems little point) but instead just get qualified. HELO
53693 and EHLO act as RSET; VRFY, EXPN, ETRN and  HELP, act
53694 as NOOP; QUIT quits.
53695 </para>
53696 <para>
53697 No policy checking is done for BSMTP input. That is, no ACL is run at anytime.
53698 In this respect it is like non-SMTP local input.
53699 </para>
53700 <para>
53701 If an error is detected while reading a message, including a missing <quote>.</quote> at
53702 the end, Exim gives up immediately. It writes details of the error to the
53703 standard output in a stylized way that the calling program should be able to
53704 make some use of automatically, for example:
53705 </para>
53706 <literallayout class="monospaced">
53707 554 Unexpected end of file
53708 Transaction started in line 10
53709 Error detected in line 14
53710 </literallayout>
53711 <para>
53712 It writes a more verbose version, for human consumption, to the standard error
53713 file, for example:
53714 </para>
53715 <literallayout class="monospaced">
53716 An error was detected while processing a file of BSMTP input.
53717 The error message was:
53718
53719 501 '&gt;' missing at end of address
53720
53721 The SMTP transaction started in line 10.
53722 The error was detected in line 12.
53723 The SMTP command at fault was:
53724
53725 rcpt to:&lt;malformed@in.com.plete
53726
53727 1 previous message was successfully processed.
53728 The rest of the batch was abandoned.
53729 </literallayout>
53730 <para>
53731 The return code from Exim is zero only if there were no errors. It is 1 if some
53732 messages were accepted before an error was detected, and 2 if no messages were
53733 accepted.
53734 <indexterm role="concept" startref="IIDsmtpproc1" class="endofrange"/>
53735 <indexterm role="concept" startref="IIDsmtpproc2" class="endofrange"/>
53736 </para>
53737 </section>
53738 </chapter>
53739
53740 <chapter id="CHAPemsgcust">
53741 <title>Customizing bounce and warning messages</title>
53742 <titleabbrev>Customizing messages</titleabbrev>
53743 <para>
53744 When a message fails to be delivered, or remains on the queue for more than a
53745 configured amount of time, Exim sends a message to the original sender, or
53746 to an alternative configured address. The text of these messages is built into
53747 the code of Exim, but it is possible to change it, either by adding a single
53748 string, or by replacing each of the paragraphs by text supplied in a file.
53749 </para>
53750 <para>
53751 The <emphasis>From:</emphasis> and <emphasis>To:</emphasis> header lines are automatically generated; you can
53752 cause a <emphasis>Reply-To:</emphasis> line to be added by setting the <option>errors_reply_to</option>
53753 option. Exim also adds the line
53754 </para>
53755 <literallayout class="monospaced">
53756 Auto-Submitted: auto-generated
53757 </literallayout>
53758 <para>
53759 to all warning and bounce messages,
53760 </para>
53761 <section>
53762 <title>Customizing bounce messages</title>
53763 <para>
53764 <indexterm role="concept">
53765 <primary>customizing</primary>
53766 <secondary>bounce message</secondary>
53767 </indexterm>
53768 <indexterm role="concept">
53769 <primary>bounce message</primary>
53770 <secondary>customizing</secondary>
53771 </indexterm>
53772 If <option>bounce_message_text</option> is set, its contents are included in the default
53773 message immediately after <quote>This message was created automatically by mail
53774 delivery software.</quote> The string is not expanded. It is not used if
53775 <option>bounce_message_file</option> is set.
53776 </para>
53777 <para>
53778 When <option>bounce_message_file</option> is set, it must point to a template file for
53779 constructing error messages. The file consists of a series of text items,
53780 separated by lines consisting of exactly four asterisks. If the file cannot be
53781 opened, default text is used and a message is written to the main and panic
53782 logs. If any text item in the file is empty, default text is used for that
53783 item.
53784 </para>
53785 <para>
53786 <indexterm role="concept">
53787 <primary><varname>$bounce_recipient</varname></primary>
53788 </indexterm>
53789 <indexterm role="concept">
53790 <primary><varname>$bounce_return_size_limit</varname></primary>
53791 </indexterm>
53792 Each item of text that is read from the file is expanded, and there are two
53793 expansion variables which can be of use here: <varname>$bounce_recipient</varname> is set to
53794 the recipient of an error message while it is being created, and
53795 <varname>$bounce_return_size_limit</varname> contains the value of the <option>return_size_limit</option>
53796 option, rounded to a whole number.
53797 </para>
53798 <para>
53799 The items must appear in the file in the following order:
53800 </para>
53801 <itemizedlist>
53802 <listitem>
53803 <para>
53804 The first item is included in the headers, and should include at least a
53805 <emphasis>Subject:</emphasis> header. Exim does not check the syntax of these headers.
53806 </para>
53807 </listitem>
53808 <listitem>
53809 <para>
53810 The second item forms the start of the error message. After it, Exim lists the
53811 failing addresses with their error messages.
53812 </para>
53813 </listitem>
53814 <listitem>
53815 <para>
53816 The third item is used to introduce any text from pipe transports that is to be
53817 returned to the sender. It is omitted if there is no such text.
53818 </para>
53819 </listitem>
53820 <listitem>
53821 <para>
53822 The fourth item is used to introduce the copy of the message that is returned
53823 as part of the error report.
53824 </para>
53825 </listitem>
53826 <listitem>
53827 <para>
53828 The fifth item is added after the fourth one if the returned message is
53829 truncated because it is bigger than <option>return_size_limit</option>.
53830 </para>
53831 </listitem>
53832 <listitem>
53833 <para>
53834 The sixth item is added after the copy of the original message.
53835 </para>
53836 </listitem>
53837 </itemizedlist>
53838 <para>
53839 The default state (<option>bounce_message_file</option> unset) is equivalent to the
53840 following file, in which the sixth item is empty. The <emphasis>Subject:</emphasis> and some
53841 other lines have been split in order to fit them on the page:
53842 </para>
53843 <literallayout class="monospaced">
53844 Subject: Mail delivery failed
53845   ${if eq{$sender_address}{$bounce_recipient}
53846   {: returning message to sender}}
53847 ****
53848 This message was created automatically by mail delivery software.
53849
53850 A message ${if eq{$sender_address}{$bounce_recipient}
53851   {that you sent }{sent by
53852
53853 &lt;$sender_address&gt;
53854
53855 }}could not be delivered to all of its recipients.
53856 The following address(es) failed:
53857 ****
53858 The following text was generated during the delivery attempt(s):
53859 ****
53860 ------ This is a copy of the message, including all the headers.
53861   ------
53862 ****
53863 ------ The body of the message is $message_size characters long;
53864   only the first
53865 ------ $bounce_return_size_limit or so are included here.
53866 ****
53867 </literallayout>
53868 </section>
53869 <section id="SECTcustwarn">
53870 <title>Customizing warning messages</title>
53871 <para>
53872 <indexterm role="concept">
53873 <primary>customizing</primary>
53874 <secondary>warning message</secondary>
53875 </indexterm>
53876 <indexterm role="concept">
53877 <primary>warning of delay</primary>
53878 <secondary>customizing the message</secondary>
53879 </indexterm>
53880 The option <option>warn_message_file</option> can be pointed at a template file for use when
53881 warnings about message delays are created. In this case there are only three
53882 text sections:
53883 </para>
53884 <itemizedlist>
53885 <listitem>
53886 <para>
53887 The first item is included in the headers, and should include at least a
53888 <emphasis>Subject:</emphasis> header. Exim does not check the syntax of these headers.
53889 </para>
53890 </listitem>
53891 <listitem>
53892 <para>
53893 The second item forms the start of the warning message. After it, Exim lists
53894 the delayed addresses.
53895 </para>
53896 </listitem>
53897 <listitem>
53898 <para>
53899 The third item then ends the message.
53900 </para>
53901 </listitem>
53902 </itemizedlist>
53903 <para>
53904 The default state is equivalent to the following file, except that some lines
53905 have been split here, in order to fit them on the page:
53906 </para>
53907 <literallayout class="monospaced">
53908 Subject: Warning: message $message_exim_id delayed
53909   $warn_message_delay
53910 ****
53911 This message was created automatically by mail delivery software.
53912
53913 A message ${if eq{$sender_address}{$warn_message_recipients}
53914 {that you sent }{sent by
53915
53916 &lt;$sender_address&gt;
53917
53918 }}has not been delivered to all of its recipients after
53919 more than $warn_message_delay on the queue on $primary_hostname.
53920
53921 The message identifier is:     $message_exim_id
53922 The subject of the message is: $h_subject
53923 The date of the message is:    $h_date
53924
53925 The following address(es) have not yet been delivered:
53926 ****
53927 No action is required on your part. Delivery attempts will
53928 continue for some time, and this warning may be repeated at
53929 intervals if the message remains undelivered. Eventually the
53930 mail delivery software will give up, and when that happens,
53931 the message will be returned to you.
53932 </literallayout>
53933 <para>
53934 <indexterm role="concept">
53935 <primary><varname>$warn_message_delay</varname></primary>
53936 </indexterm>
53937 <indexterm role="concept">
53938 <primary><varname>$warn_message_recipients</varname></primary>
53939 </indexterm>
53940 However, in the default state the subject and date lines are omitted if no
53941 appropriate headers exist. During the expansion of this file,
53942 <varname>$warn_message_delay</varname> is set to the delay time in one of the forms <quote>&lt;<emphasis>n</emphasis>&gt;
53943 minutes</quote> or <quote>&lt;<emphasis>n</emphasis>&gt; hours</quote>, and <varname>$warn_message_recipients</varname> contains a list
53944 of recipients for the warning message. There may be more than one if there are
53945 multiple addresses with different <option>errors_to</option> settings on the routers that
53946 handled them.
53947 </para>
53948 </section>
53949 </chapter>
53950
53951 <chapter id="CHAPcomconreq">
53952 <title>Some common configuration settings</title>
53953 <para>
53954 This chapter discusses some configuration settings that seem to be fairly
53955 common. More examples and discussion can be found in the Exim book.
53956 </para>
53957 <section>
53958 <title>Sending mail to a smart host</title>
53959 <para>
53960 <indexterm role="concept">
53961 <primary>smart host</primary>
53962 <secondary>example router</secondary>
53963 </indexterm>
53964 If you want to send all mail for non-local domains to a <quote>smart host</quote>, you
53965 should replace the default <command>dnslookup</command> router with a router which does the
53966 routing explicitly:
53967 </para>
53968 <literallayout class="monospaced">
53969 send_to_smart_host:
53970   driver = manualroute
53971   route_list = !+local_domains smart.host.name
53972   transport = remote_smtp
53973 </literallayout>
53974 <para>
53975 You can use the smart host&#x2019;s IP address instead of the name if you wish.
53976 If you are using Exim only to submit messages to a smart host, and not for
53977 receiving incoming messages, you can arrange for it to do the submission
53978 synchronously by setting the <option>mua_wrapper</option> option (see chapter
53979 <xref linkend="CHAPnonqueueing"/>).
53980 </para>
53981 </section>
53982 <section id="SECTmailinglists">
53983 <title>Using Exim to handle mailing lists</title>
53984 <para>
53985 <indexterm role="concept">
53986 <primary>mailing lists</primary>
53987 </indexterm>
53988 Exim can be used to run simple mailing lists, but for large and/or complicated
53989 requirements, the use of additional specialized mailing list software such as
53990 Majordomo or Mailman is recommended.
53991 </para>
53992 <para>
53993 The <command>redirect</command> router can be used to handle mailing lists where each list
53994 is maintained in a separate file, which can therefore be managed by an
53995 independent manager. The <option>domains</option> router option can be used to run these
53996 lists in a separate domain from normal mail. For example:
53997 </para>
53998 <literallayout class="monospaced">
53999 lists:
54000   driver = redirect
54001   domains = lists.example
54002   file = /usr/lists/$local_part
54003   forbid_pipe
54004   forbid_file
54005   errors_to = $local_part-request@lists.example
54006   no_more
54007 </literallayout>
54008 <para>
54009 This router is skipped for domains other than <emphasis>lists.example</emphasis>. For addresses
54010 in that domain, it looks for a file that matches the local part. If there is no
54011 such file, the router declines, but because <option>no_more</option> is set, no subsequent
54012 routers are tried, and so the whole delivery fails.
54013 </para>
54014 <para>
54015 The <option>forbid_pipe</option> and <option>forbid_file</option> options prevent a local part from being
54016 expanded into a file name or a pipe delivery, which is usually inappropriate in
54017 a mailing list.
54018 </para>
54019 <para>
54020 <indexterm role="concept">
54021 <primary><option>errors_to</option></primary>
54022 </indexterm>
54023 The <option>errors_to</option> option specifies that any delivery errors caused by addresses
54024 taken from a mailing list are to be sent to the given address rather than the
54025 original sender of the message. However, before acting on this, Exim verifies
54026 the error address, and ignores it if verification fails.
54027 </para>
54028 <para>
54029 For example, using the configuration above, mail sent to
54030 <emphasis>dicts@lists.example</emphasis> is passed on to those addresses contained in
54031 <filename>/usr/lists/dicts</filename>, with error reports directed to
54032 <emphasis>dicts-request@lists.example</emphasis>, provided that this address can be verified.
54033 There could be a file called <filename>/usr/lists/dicts-request</filename> containing
54034 the address(es) of this particular list&#x2019;s manager(s), but other approaches,
54035 such as setting up an earlier router (possibly using the <option>local_part_prefix</option>
54036 or <option>local_part_suffix</option> options) to handle addresses of the form
54037 <option>owner-</option><emphasis>xxx</emphasis> or <option>xxx-</option><emphasis>request</emphasis>, are also possible.
54038 </para>
54039 </section>
54040 <section>
54041 <title>Syntax errors in mailing lists</title>
54042 <para>
54043 <indexterm role="concept">
54044 <primary>mailing lists</primary>
54045 <secondary>syntax errors in</secondary>
54046 </indexterm>
54047 If an entry in redirection data contains a syntax error, Exim normally defers
54048 delivery of the original address. That means that a syntax error in a mailing
54049 list holds up all deliveries to the list. This may not be appropriate when a
54050 list is being maintained automatically from data supplied by users, and the
54051 addresses are not rigorously checked.
54052 </para>
54053 <para>
54054 If the <option>skip_syntax_errors</option> option is set, the <command>redirect</command> router just skips
54055 entries that fail to parse, noting the incident in the log. If in addition
54056 <option>syntax_errors_to</option> is set to a verifiable address, a message is sent to it
54057 whenever a broken address is skipped. It is usually appropriate to set
54058 <option>syntax_errors_to</option> to the same address as <option>errors_to</option>.
54059 </para>
54060 </section>
54061 <section>
54062 <title>Re-expansion of mailing lists</title>
54063 <para>
54064 <indexterm role="concept">
54065 <primary>mailing lists</primary>
54066 <secondary>re-expansion of</secondary>
54067 </indexterm>
54068 Exim remembers every individual address to which a message has been delivered,
54069 in order to avoid duplication, but it normally stores only the original
54070 recipient addresses with a message. If all the deliveries to a mailing list
54071 cannot be done at the first attempt, the mailing list is re-expanded when the
54072 delivery is next tried. This means that alterations to the list are taken into
54073 account at each delivery attempt, so addresses that have been added to
54074 the list since the message arrived will therefore receive a copy of the
54075 message, even though it pre-dates their subscription.
54076 </para>
54077 <para>
54078 If this behaviour is felt to be undesirable, the <option>one_time</option> option can be set
54079 on the <command>redirect</command> router. If this is done, any addresses generated by the
54080 router that fail to deliver at the first attempt are added to the message as
54081 <quote>top level</quote> addresses, and the parent address that generated them is marked
54082 <quote>delivered</quote>. Thus, expansion of the mailing list does not happen again at the
54083 subsequent delivery attempts. The disadvantage of this is that if any of the
54084 failing addresses are incorrect, correcting them in the file has no effect on
54085 pre-existing messages.
54086 </para>
54087 <para>
54088 The original top-level address is remembered with each of the generated
54089 addresses, and is output in any log messages. However, any intermediate parent
54090 addresses are not recorded. This makes a difference to the log only if the
54091 <option>all_parents</option> selector is set, but for mailing lists there is normally only
54092 one level of expansion anyway.
54093 </para>
54094 </section>
54095 <section>
54096 <title>Closed mailing lists</title>
54097 <para>
54098 <indexterm role="concept">
54099 <primary>mailing lists</primary>
54100 <secondary>closed</secondary>
54101 </indexterm>
54102 The examples so far have assumed open mailing lists, to which anybody may
54103 send mail. It is also possible to set up closed lists, where mail is accepted
54104 from specified senders only. This is done by making use of the generic
54105 <option>senders</option> option to restrict the router that handles the list.
54106 </para>
54107 <para>
54108 The following example uses the same file as a list of recipients and as a list
54109 of permitted senders. It requires three routers:
54110 </para>
54111 <literallayout class="monospaced">
54112 lists_request:
54113   driver = redirect
54114   domains = lists.example
54115   local_part_suffix = -request
54116   file = /usr/lists/$local_part$local_part_suffix
54117   no_more
54118
54119 lists_post:
54120   driver = redirect
54121   domains = lists.example
54122   senders = ${if exists {/usr/lists/$local_part}\
54123              {lsearch;/usr/lists/$local_part}{*}}
54124   file = /usr/lists/$local_part
54125   forbid_pipe
54126   forbid_file
54127   errors_to = $local_part-request@lists.example
54128   no_more
54129
54130 lists_closed:
54131   driver = redirect
54132   domains = lists.example
54133   allow_fail
54134   data = :fail: $local_part@lists.example is a closed mailing list
54135 </literallayout>
54136 <para>
54137 All three routers have the same <option>domains</option> setting, so for any other domains,
54138 they are all skipped. The first router runs only if the local part ends in
54139 <option>-request</option>. It handles messages to the list manager(s) by means of an open
54140 mailing list.
54141 </para>
54142 <para>
54143 The second router runs only if the <option>senders</option> precondition is satisfied. It
54144 checks for the existence of a list that corresponds to the local part, and then
54145 checks that the sender is on the list by means of a linear search. It is
54146 necessary to check for the existence of the file before trying to search it,
54147 because otherwise Exim thinks there is a configuration error. If the file does
54148 not exist, the expansion of <option>senders</option> is *, which matches all senders. This
54149 means that the router runs, but because there is no list, declines, and
54150 <option>no_more</option> ensures that no further routers are run. The address fails with an
54151 <quote>unrouteable address</quote> error.
54152 </para>
54153 <para>
54154 The third router runs only if the second router is skipped, which happens when
54155 a mailing list exists, but the sender is not on it. This router forcibly fails
54156 the address, giving a suitable error message.
54157 </para>
54158 </section>
54159 <section id="SECTverp" revisionflag="changed">
54160 <title>Variable Envelope Return Paths (VERP)</title>
54161 <para revisionflag="changed">
54162 <indexterm role="concept">
54163 <primary>VERP</primary>
54164 </indexterm>
54165 <indexterm role="concept">
54166 <primary>Variable Envelope Return Paths</primary>
54167 </indexterm>
54168 <indexterm role="concept">
54169 <primary>envelope sender</primary>
54170 </indexterm>
54171 Variable Envelope Return Paths &ndash; see <emphasis role="bold"><ulink url="http://cr.yp.to/proto/verp.txt">http://cr.yp.to/proto/verp.txt</ulink></emphasis> &ndash;
54172 are a way of helping mailing list administrators discover which subscription
54173 address is the cause of a particular delivery failure. The idea is to encode
54174 the original recipient address in the outgoing envelope sender address, so that
54175 if the message is forwarded by another host and then subsequently bounces, the
54176 original recipient can be extracted from the recipient address of the bounce.
54177 </para>
54178 <para revisionflag="changed">
54179 <indexterm role="option">
54180 <primary><option>errors_to</option></primary>
54181 </indexterm>
54182 <indexterm role="option">
54183 <primary><option>return_path</option></primary>
54184 </indexterm>
54185 Envelope sender addresses can be modified by Exim using two different
54186 facilities: the <option>errors_to</option> option on a router (as shown in previous mailing
54187 list examples), or the <option>return_path</option> option on a transport. The second of
54188 these is effective only if the message is successfully delivered to another
54189 host; it is not used for errors detected on the local host (see the description
54190 of <option>return_path</option> in chapter <xref linkend="CHAPtransportgeneric"/>). Here is an example
54191 of the use of <option>return_path</option> to implement VERP on an <command>smtp</command> transport:
54192 </para>
54193 <literallayout class="monospaced" revisionflag="changed">
54194 verp_smtp:
54195   driver = smtp
54196   max_rcpt = 1
54197   return_path = \
54198     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
54199       {$1-request=$local_part%$domain@your.dom.example}fail}
54200 </literallayout>
54201 <para revisionflag="changed">
54202 This has the effect of rewriting the return path (envelope sender) on outgoing
54203 SMTP messages, if the local part of the original return path ends in
54204 <quote>-request</quote>, and the domain is <emphasis>your.dom.example</emphasis>. The rewriting inserts the
54205 local part and domain of the recipient into the return path. Suppose, for
54206 example, that a message whose return path has been set to
54207 <emphasis>somelist-request@your.dom.example</emphasis> is sent to
54208 <emphasis>subscriber@other.dom.example</emphasis>. In the transport, the return path is
54209 rewritten as
54210 </para>
54211 <literallayout class="monospaced" revisionflag="changed">
54212 somelist-request=subscriber%other.dom.example@your.dom.example
54213 </literallayout>
54214 <para revisionflag="changed">
54215 <indexterm role="concept">
54216 <primary><varname>$local_part</varname></primary>
54217 </indexterm>
54218 For this to work, you must also arrange for outgoing messages that have
54219 <quote>-request</quote> in their return paths to have just a single recipient. That is
54220 achieved by setting <option>max_rcpt</option> to 1. Without this, a single copy of a message
54221 might be sent to several different recipients in the same domain, in which case
54222 <varname>$local_part</varname> is not available in the transport, because it is not unique.
54223 </para>
54224 <para revisionflag="changed">
54225 Unless your host is doing nothing but mailing list deliveries, you should
54226 probably use a separate transport for the VERP deliveries, so as not to use
54227 extra resources for the others. This can easily be done by expanding the
54228 <option>transport</option> option in the router:
54229 </para>
54230 <literallayout class="monospaced" revisionflag="changed">
54231 dnslookup:
54232   driver = dnslookup
54233   domains = ! +local_domains
54234   transport = \
54235     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
54236       {verp_smtp}{remote_smtp}}
54237   no_more
54238 </literallayout>
54239 <para revisionflag="changed">
54240 If you want to change the return path using <option>errors_to</option> in a router instead
54241 of using <option>return_path</option> in the transport, you need to set <option>errors_to</option> on all
54242 routers that handle mailing list addresses. This will ensure that all delivery
54243 errors, including those detected on the local host, are sent to the VERP
54244 address.
54245 </para>
54246 <para revisionflag="changed">
54247 On a host that does no local deliveries and has no manual routing, only the
54248 <command>dnslookup</command> router needs to be changed. A special transport is not needed for
54249 SMTP deliveries. Every mailing list recipient has its own return path value,
54250 and so Exim must hand them to the transport one at a time. Here is an example
54251 of a <command>dnslookup</command> router that implements VERP:
54252 </para>
54253 <literallayout class="monospaced" revisionflag="changed">
54254 verp_dnslookup:
54255   driver = dnslookup
54256   domains = ! +local_domains
54257   transport = remote_smtp
54258   errors_to = \
54259     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}}
54260      {$1-request=$local_part%$domain@your.dom.example}fail}
54261   no_more
54262 </literallayout>
54263 <para revisionflag="changed">
54264 Before you start sending out messages with VERPed return paths, you must also
54265 configure Exim to accept the bounce messages that come back to those paths.
54266 Typically this is done by setting a <option>local_part_suffix</option> option for a
54267 router, and using this to route the messages to wherever you want to handle
54268 them.
54269 </para>
54270 <para revisionflag="changed">
54271 The overhead incurred in using VERP depends very much on the size of the
54272 message, the number of recipient addresses that resolve to the same remote
54273 host, and the speed of the connection over which the message is being sent. If
54274 a lot of addresses resolve to the same host and the connection is slow, sending
54275 a separate copy of the message for each address may take substantially longer
54276 than sending a single copy with many recipients (for which VERP cannot be
54277 used).
54278 </para>
54279 </section>
54280 <section id="SECTvirtualdomains">
54281 <title>Virtual domains</title>
54282 <para>
54283 <indexterm role="concept">
54284 <primary>virtual domains</primary>
54285 </indexterm>
54286 <indexterm role="concept">
54287 <primary>domain</primary>
54288 <secondary>virtual</secondary>
54289 </indexterm>
54290 The phrase <emphasis>virtual domain</emphasis> is unfortunately used with two rather different
54291 meanings:
54292 </para>
54293 <itemizedlist>
54294 <listitem>
54295 <para>
54296 A domain for which there are no real mailboxes; all valid local parts are
54297 aliases for other email addresses. Common examples are organizational
54298 top-level domains and <quote>vanity</quote> domains.
54299 </para>
54300 </listitem>
54301 <listitem>
54302 <para>
54303 One of a number of independent domains that are all handled by the same host,
54304 with mailboxes on that host, but where the mailbox owners do not necessarily
54305 have login accounts on that host.
54306 </para>
54307 </listitem>
54308 </itemizedlist>
54309 <para>
54310 The first usage is probably more common, and does seem more <quote>virtual</quote> than
54311 the second. This kind of domain can be handled in Exim with a straightforward
54312 aliasing router. One approach is to create a separate alias file for each
54313 virtual domain. Exim can test for the existence of the alias file to determine
54314 whether the domain exists. The <command>dsearch</command> lookup type is useful here, leading
54315 to a router of this form:
54316 </para>
54317 <literallayout class="monospaced">
54318 virtual:
54319   driver = redirect
54320   domains = dsearch;/etc/mail/virtual
54321   data = ${lookup{$local_part}lsearch{/etc/mail/virtual/$domain}}
54322   no_more
54323 </literallayout>
54324 <para>
54325 The <option>domains</option> option specifies that the router is to be skipped, unless there
54326 is a file in the <filename>/etc/mail/virtual</filename> directory whose name is the same as the
54327 domain that is being processed. When the router runs, it looks up the local
54328 part in the file to find a new address (or list of addresses). The <option>no_more</option>
54329 setting ensures that if the lookup fails (leading to <option>data</option> being an empty
54330 string), Exim gives up on the address without trying any subsequent routers.
54331 </para>
54332 <para>
54333 This one router can handle all the virtual domains because the alias file names
54334 follow a fixed pattern. Permissions can be arranged so that appropriate people
54335 can edit the different alias files. A successful aliasing operation results in
54336 a new envelope recipient address, which is then routed from scratch.
54337 </para>
54338 <para>
54339 The other kind of <quote>virtual</quote> domain can also be handled in a straightforward
54340 way. One approach is to create a file for each domain containing a list of
54341 valid local parts, and use it in a router like this:
54342 </para>
54343 <literallayout class="monospaced">
54344 my_domains:
54345   driver = accept
54346   domains = dsearch;/etc/mail/domains
54347   local_parts = lsearch;/etc/mail/domains/$domain
54348   transport = my_mailboxes
54349 </literallayout>
54350 <para>
54351 The address is accepted if there is a file for the domain, and the local part
54352 can be found in the file. The <option>domains</option> option is used to check for the
54353 file&#x2019;s existence because <option>domains</option> is tested before the <option>local_parts</option>
54354 option (see section <xref linkend="SECTrouprecon"/>). You cannot use <option>require_files</option>,
54355 because that option is tested after <option>local_parts</option>. The transport is as
54356 follows:
54357 </para>
54358 <literallayout class="monospaced">
54359 my_mailboxes:
54360   driver = appendfile
54361   file = /var/mail/$domain/$local_part
54362   user = mail
54363 </literallayout>
54364 <para>
54365 This uses a directory of mailboxes for each domain. The <option>user</option> setting is
54366 required, to specify which uid is to be used for writing to the mailboxes.
54367 </para>
54368 <para>
54369 The configuration shown here is just one example of how you might support this
54370 requirement. There are many other ways this kind of configuration can be set
54371 up, for example, by using a database instead of separate files to hold all the
54372 information about the domains.
54373 </para>
54374 </section>
54375 <section id="SECTmulbox">
54376 <title>Multiple user mailboxes</title>
54377 <para>
54378 <indexterm role="concept">
54379 <primary>multiple mailboxes</primary>
54380 </indexterm>
54381 <indexterm role="concept">
54382 <primary>mailbox</primary>
54383 <secondary>multiple</secondary>
54384 </indexterm>
54385 <indexterm role="concept">
54386 <primary>local part</primary>
54387 <secondary>prefix</secondary>
54388 </indexterm>
54389 <indexterm role="concept">
54390 <primary>local part</primary>
54391 <secondary>suffix</secondary>
54392 </indexterm>
54393 Heavy email users often want to operate with multiple mailboxes, into which
54394 incoming mail is automatically sorted. A popular way of handling this is to
54395 allow users to use multiple sender addresses, so that replies can easily be
54396 identified. Users are permitted to add prefixes or suffixes to their local
54397 parts for this purpose. The wildcard facility of the generic router options
54398 <option>local_part_prefix</option> and <option>local_part_suffix</option> can be used for this. For
54399 example, consider this router:
54400 </para>
54401 <literallayout class="monospaced">
54402 userforward:
54403   driver = redirect
54404   check_local_user
54405   file = $home/.forward
54406   local_part_suffix = -*
54407   local_part_suffix_optional
54408   allow_filter
54409 </literallayout>
54410 <para>
54411 <indexterm role="concept">
54412 <primary><varname>$local_part_suffix</varname></primary>
54413 </indexterm>
54414 It runs a user&#x2019;s <filename>.forward</filename> file for all local parts of the form
54415 <emphasis>username-*</emphasis>. Within the filter file the user can distinguish different
54416 cases by testing the variable <varname>$local_part_suffix</varname>. For example:
54417 </para>
54418 <literallayout class="monospaced">
54419 if $local_part_suffix contains -special then
54420 save /home/$local_part/Mail/special
54421 endif
54422 </literallayout>
54423 <para>
54424 If the filter file does not exist, or does not deal with such addresses, they
54425 fall through to subsequent routers, and, assuming no subsequent use of the
54426 <option>local_part_suffix</option> option is made, they presumably fail. Thus, users have
54427 control over which suffixes are valid.
54428 </para>
54429 <para>
54430 Alternatively, a suffix can be used to trigger the use of a different
54431 <filename>.forward</filename> file &ndash; which is the way a similar facility is implemented in
54432 another MTA:
54433 </para>
54434 <literallayout class="monospaced">
54435 userforward:
54436   driver = redirect
54437   check_local_user
54438   file = $home/.forward$local_part_suffix
54439   local_part_suffix = -*
54440   local_part_suffix_optional
54441   allow_filter
54442 </literallayout>
54443 <para>
54444 If there is no suffix, <filename>.forward</filename> is used; if the suffix is <emphasis>-special</emphasis>, for
54445 example, <filename>.forward-special</filename> is used. Once again, if the appropriate file
54446 does not exist, or does not deal with the address, it is passed on to
54447 subsequent routers, which could, if required, look for an unqualified
54448 <filename>.forward</filename> file to use as a default.
54449 </para>
54450 </section>
54451 <section>
54452 <title>Simplified vacation processing</title>
54453 <para>
54454 <indexterm role="concept">
54455 <primary>vacation processing</primary>
54456 </indexterm>
54457 The traditional way of running the <emphasis>vacation</emphasis> program is for a user to set up
54458 a pipe command in a <filename>.forward</filename> file
54459 (see section <xref linkend="SECTspecitredli"/> for syntax details).
54460 This is prone to error by inexperienced users. There are two features of Exim
54461 that can be used to make this process simpler for users:
54462 </para>
54463 <itemizedlist>
54464 <listitem>
54465 <para>
54466 A local part prefix such as <quote>vacation-</quote> can be specified on a router which
54467 can cause the message to be delivered directly to the <emphasis>vacation</emphasis> program, or
54468 alternatively can use Exim&#x2019;s <command>autoreply</command> transport. The contents of a user&#x2019;s
54469 <filename>.forward</filename> file are then much simpler. For example:
54470 </para>
54471 <literallayout class="monospaced">
54472 spqr, vacation-spqr
54473 </literallayout>
54474 </listitem>
54475 <listitem>
54476 <para>
54477 The <option>require_files</option> generic router option can be used to trigger a
54478 vacation delivery by checking for the existence of a certain file in the
54479 user&#x2019;s home directory. The <option>unseen</option> generic option should also be used, to
54480 ensure that the original delivery also proceeds. In this case, all the user has
54481 to do is to create a file called, say, <filename>.vacation</filename>, containing a vacation
54482 message.
54483 </para>
54484 </listitem>
54485 </itemizedlist>
54486 <para>
54487 Another advantage of both these methods is that they both work even when the
54488 use of arbitrary pipes by users is locked out.
54489 </para>
54490 </section>
54491 <section>
54492 <title>Taking copies of mail</title>
54493 <para>
54494 <indexterm role="concept">
54495 <primary>message</primary>
54496 <secondary>copying every</secondary>
54497 </indexterm>
54498 Some installations have policies that require archive copies of all messages to
54499 be made. A single copy of each message can easily be taken by an appropriate
54500 command in a system filter, which could, for example, use a different file for
54501 each day&#x2019;s messages.
54502 </para>
54503 <para>
54504 There is also a shadow transport mechanism that can be used to take copies of
54505 messages that are successfully delivered by local transports, one copy per
54506 delivery. This could be used, <emphasis>inter alia</emphasis>, to implement automatic
54507 notification of delivery by sites that insist on doing such things.
54508 </para>
54509 </section>
54510 <section>
54511 <title>Intermittently connected hosts</title>
54512 <para>
54513 <indexterm role="concept">
54514 <primary>intermittently connected hosts</primary>
54515 </indexterm>
54516 It has become quite common (because it is cheaper) for hosts to connect to the
54517 Internet periodically rather than remain connected all the time. The normal
54518 arrangement is that mail for such hosts accumulates on a system that is
54519 permanently connected.
54520 </para>
54521 <para>
54522 Exim was designed for use on permanently connected hosts, and so it is not
54523 particularly well-suited to use in an intermittently connected environment.
54524 Nevertheless there are some features that can be used.
54525 </para>
54526 </section>
54527 <section>
54528 <title>Exim on the upstream server host</title>
54529 <para>
54530 It is tempting to arrange for incoming mail for the intermittently connected
54531 host to remain on Exim&#x2019;s queue until the client connects. However, this
54532 approach does not scale very well. Two different kinds of waiting message are
54533 being mixed up in the same queue &ndash; those that cannot be delivered because of
54534 some temporary problem, and those that are waiting for their destination host
54535 to connect. This makes it hard to manage the queue, as well as wasting
54536 resources, because each queue runner scans the entire queue.
54537 </para>
54538 <para>
54539 A better approach is to separate off those messages that are waiting for an
54540 intermittently connected host. This can be done by delivering these messages
54541 into local files in batch SMTP, <quote>mailstore</quote>, or other envelope-preserving
54542 format, from where they are transmitted by other software when their
54543 destination connects. This makes it easy to collect all the mail for one host
54544 in a single directory, and to apply local timeout rules on a per-message basis
54545 if required.
54546 </para>
54547 <para>
54548 On a very small scale, leaving the mail on Exim&#x2019;s queue can be made to work. If
54549 you are doing this, you should configure Exim with a long retry period for the
54550 intermittent host. For example:
54551 </para>
54552 <literallayout class="monospaced">
54553 cheshire.wonderland.fict.example    *   F,5d,24h
54554 </literallayout>
54555 <para>
54556 This stops a lot of failed delivery attempts from occurring, but Exim remembers
54557 which messages it has queued up for that host. Once the intermittent host comes
54558 online, forcing delivery of one message (either by using the <option>-M</option> or <option>-R</option>
54559 options, or by using the ETRN SMTP command (see section <xref linkend="SECTETRN"/>)
54560 causes all the queued up messages to be delivered, often down a single SMTP
54561 connection. While the host remains connected, any new messages get delivered
54562 immediately.
54563 </para>
54564 <para>
54565 If the connecting hosts do not have fixed IP addresses, that is, if a host is
54566 issued with a different IP address each time it connects, Exim&#x2019;s retry
54567 mechanisms on the holding host get confused, because the IP address is normally
54568 used as part of the key string for holding retry information. This can be
54569 avoided by unsetting <option>retry_include_ip_address</option> on the <command>smtp</command> transport.
54570 Since this has disadvantages for permanently connected hosts, it is best to
54571 arrange a separate transport for the intermittently connected ones.
54572 </para>
54573 </section>
54574 <section>
54575 <title>Exim on the intermittently connected client host</title>
54576 <para>
54577 The value of <option>smtp_accept_queue_per_connection</option> should probably be
54578 increased, or even set to zero (that is, disabled) on the intermittently
54579 connected host, so that all incoming messages down a single connection get
54580 delivered immediately.
54581 </para>
54582 <para>
54583 <indexterm role="concept">
54584 <primary>SMTP</primary>
54585 <secondary>passed connection</secondary>
54586 </indexterm>
54587 <indexterm role="concept">
54588 <primary>SMTP</primary>
54589 <secondary>multiple deliveries</secondary>
54590 </indexterm>
54591 <indexterm role="concept">
54592 <primary>multiple SMTP deliveries</primary>
54593 </indexterm>
54594 Mail waiting to be sent from an intermittently connected host will probably
54595 not have been routed, because without a connection DNS lookups are not
54596 possible. This means that if a normal queue run is done at connection time,
54597 each message is likely to be sent in a separate SMTP session. This can be
54598 avoided by starting the queue run with a command line option beginning with
54599 <option>-qq</option> instead of <option>-q</option>. In this case, the queue is scanned twice. In the
54600 first pass, routing is done but no deliveries take place. The second pass is a
54601 normal queue run; since all the messages have been previously routed, those
54602 destined for the same host are likely to get sent as multiple deliveries in a
54603 single SMTP connection.
54604 </para>
54605 </section>
54606 </chapter>
54607
54608 <chapter id="CHAPnonqueueing">
54609 <title>Using Exim as a non-queueing client</title>
54610 <titleabbrev>Exim as a non-queueing client</titleabbrev>
54611 <para>
54612 <indexterm role="concept">
54613 <primary>client</primary>
54614 <secondary>non-queueing</secondary>
54615 </indexterm>
54616 <indexterm role="concept">
54617 <primary>smart host</primary>
54618 <secondary>queueing; suppressing</secondary>
54619 </indexterm>
54620 On a personal computer, it is a common requirement for all
54621 email to be sent to a <quote>smart host</quote>. There are plenty of MUAs that can be
54622 configured to operate that way, for all the popular operating systems.
54623 However, there are some MUAs for Unix-like systems that cannot be so
54624 configured: they submit messages using the command line interface of
54625 <filename>/usr/sbin/sendmail</filename>. Furthermore, utility programs such as <emphasis>cron</emphasis> submit
54626 messages this way.
54627 </para>
54628 <para>
54629 If the personal computer runs continuously, there is no problem, because it can
54630 run a conventional MTA that handles delivery to the smart host, and deal with
54631 any delays via its queueing mechanism. However, if the computer does not run
54632 continuously or runs different operating systems at different times, queueing
54633 email is not desirable.
54634 </para>
54635 <para>
54636 There is therefore a requirement for something that can provide the
54637 <filename>/usr/sbin/sendmail</filename> interface but deliver messages to a smart host without
54638 any queueing or retrying facilities. Furthermore, the delivery to the smart
54639 host should be synchronous, so that if it fails, the sending MUA is immediately
54640 informed. In other words, we want something that extends an MUA that submits
54641 to a local MTA via the command line so that it behaves like one that submits
54642 to a remote smart host using TCP/SMTP.
54643 </para>
54644 <para>
54645 There are a number of applications (for example, there is one called <emphasis>ssmtp</emphasis>)
54646 that do this job. However, people have found them to be lacking in various
54647 ways. For instance, you might want to allow aliasing and forwarding to be done
54648 before sending a message to the smart host.
54649 </para>
54650 <para>
54651 Exim already had the necessary infrastructure for doing this job. Just a few
54652 tweaks were needed to make it behave as required, though it is somewhat of an
54653 overkill to use a fully-featured MTA for this purpose.
54654 </para>
54655 <para>
54656 <indexterm role="concept">
54657 <primary><option>mua_wrapper</option></primary>
54658 </indexterm>
54659 There is a Boolean global option called <option>mua_wrapper</option>, defaulting false.
54660 Setting <option>mua_wrapper</option> true causes Exim to run in a special mode where it
54661 assumes that it is being used to <quote>wrap</quote> a command-line MUA in the manner
54662 just described. As well as setting <option>mua_wrapper</option>, you also need to provide a
54663 compatible router and transport configuration. Typically there will be just one
54664 router and one transport, sending everything to a smart host.
54665 </para>
54666 <para>
54667 When run in MUA wrapping mode, the behaviour of Exim changes in the
54668 following ways:
54669 </para>
54670 <itemizedlist>
54671 <listitem>
54672 <para>
54673 A daemon cannot be run, nor will Exim accept incoming messages from <emphasis>inetd</emphasis>.
54674 In other words, the only way to submit messages is via the command line.
54675 </para>
54676 </listitem>
54677 <listitem>
54678 <para>
54679 Each message is synchonously delivered as soon as it is received (<option>-odi</option> is
54680 assumed). All queueing options (<option>queue_only</option>, <option>queue_smtp_domains</option>,
54681 <option>control</option> in an ACL, etc.) are quietly ignored. The Exim reception process
54682 does not finish until the delivery attempt is complete. If the delivery is
54683 successful, a zero return code is given.
54684 </para>
54685 </listitem>
54686 <listitem>
54687 <para>
54688 Address redirection is permitted, but the final routing for all addresses must
54689 be to the same remote transport, and to the same list of hosts. Furthermore,
54690 the return address (envelope sender) must be the same for all recipients, as
54691 must any added or deleted header lines. In other words, it must be possible to
54692 deliver the message in a single SMTP transaction, however many recipients there
54693 are.
54694 </para>
54695 </listitem>
54696 <listitem>
54697 <para>
54698 If these conditions are not met, or if routing any address results in a
54699 failure or defer status, or if Exim is unable to deliver all the recipients
54700 successfully to one of the smart hosts, delivery of the entire message fails.
54701 </para>
54702 </listitem>
54703 <listitem>
54704 <para>
54705 Because no queueing is allowed, all failures are treated as permanent; there
54706 is no distinction between 4<emphasis>xx</emphasis> and 5<emphasis>xx</emphasis> SMTP response codes from the
54707 smart host. Furthermore, because only a single yes/no response can be given to
54708 the caller, it is not possible to deliver to some recipients and not others. If
54709 there is an error (temporary or permanent) for any recipient, all are failed.
54710 </para>
54711 </listitem>
54712 <listitem>
54713 <para>
54714 If more than one smart host is listed, Exim will try another host after a
54715 connection failure or a timeout, in the normal way. However, if this kind of
54716 failure happens for all the hosts, the delivery fails.
54717 </para>
54718 </listitem>
54719 <listitem>
54720 <para>
54721 When delivery fails, an error message is written to the standard error stream
54722 (as well as to Exim&#x2019;s log), and Exim exits to the caller with a return code
54723 value 1. The message is expunged from Exim&#x2019;s spool files. No bounce messages
54724 are ever generated.
54725 </para>
54726 </listitem>
54727 <listitem>
54728 <para>
54729 No retry data is maintained, and any retry rules are ignored.
54730 </para>
54731 </listitem>
54732 <listitem>
54733 <para>
54734 A number of Exim options are overridden: <option>deliver_drop_privilege</option> is forced
54735 true, <option>max_rcpt</option> in the smtp transport is forced to <quote>unlimited</quote>,
54736 <option>remote_max_parallel</option> is forced to one, and fallback hosts are ignored.
54737 </para>
54738 </listitem>
54739 </itemizedlist>
54740 <para>
54741 The overall effect is that Exim makes a single synchronous attempt to deliver
54742 the message, failing if there is any kind of problem. Because no local
54743 deliveries are done and no daemon can be run, Exim does not need root
54744 privilege. It should be possible to run it setuid to <emphasis>exim</emphasis> instead of setuid
54745 to <emphasis>root</emphasis>. See section <xref linkend="SECTrunexiwitpri"/> for a general discussion about
54746 the advantages and disadvantages of running without root privilege.
54747 </para>
54748 </chapter>
54749
54750 <chapter id="CHAPlog">
54751 <title>Log files</title>
54752 <para>
54753 <indexterm role="concept" id="IIDloggen" class="startofrange">
54754 <primary>log</primary>
54755 <secondary>general description</secondary>
54756 </indexterm>
54757 <indexterm role="concept">
54758 <primary>log</primary>
54759 <secondary>types of</secondary>
54760 </indexterm>
54761 Exim writes three different logs, referred to as the main log, the reject log,
54762 and the panic log:
54763 </para>
54764 <itemizedlist>
54765 <listitem>
54766 <para>
54767 <indexterm role="concept">
54768 <primary>main log</primary>
54769 </indexterm>
54770 The main log records the arrival of each message and each delivery in a single
54771 line in each case. The format is as compact as possible, in an attempt to keep
54772 down the size of log files. Two-character flag sequences make it easy to pick
54773 out these lines. A number of other events are recorded in the main log. Some of
54774 them are optional, in which case the <option>log_selector</option> option controls whether
54775 they are included or not. A Perl script called <emphasis>eximstats</emphasis>, which does simple
54776 analysis of main log files, is provided in the Exim distribution (see section
54777 <xref linkend="SECTmailstat"/>).
54778 </para>
54779 </listitem>
54780 <listitem>
54781 <para>
54782 <indexterm role="concept">
54783 <primary>reject log</primary>
54784 </indexterm>
54785 The reject log records information from messages that are rejected as a result
54786 of a configuration option (that is, for policy reasons).
54787 The first line of each rejection is a copy of the line that is also written to
54788 the main log. Then, if the message&#x2019;s header has been read at the time the log
54789 is written, its contents are written to this log. Only the original header
54790 lines are available; header lines added by ACLs are not logged. You can use the
54791 reject log to check that your policy controls are working correctly; on a busy
54792 host this may be easier than scanning the main log for rejection messages. You
54793 can suppress the writing of the reject log by setting <option>write_rejectlog</option>
54794 false.
54795 </para>
54796 </listitem>
54797 <listitem>
54798 <para>
54799 <indexterm role="concept">
54800 <primary>panic log</primary>
54801 </indexterm>
54802 <indexterm role="concept">
54803 <primary>system log</primary>
54804 </indexterm>
54805 When certain serious errors occur, Exim writes entries to its panic log. If the
54806 error is sufficiently disastrous, Exim bombs out afterwards. Panic log entries
54807 are usually written to the main log as well, but can get lost amid the mass of
54808 other entries. The panic log should be empty under normal circumstances. It is
54809 therefore a good idea to check it (or to have a <emphasis>cron</emphasis> script check it)
54810 regularly, in order to become aware of any problems. When Exim cannot open its
54811 panic log, it tries as a last resort to write to the system log (syslog). This
54812 is opened with LOG_PID+LOG_CONS and the facility code of LOG_MAIL. The
54813 message itself is written at priority LOG_CRIT.
54814 </para>
54815 </listitem>
54816 </itemizedlist>
54817 <para>
54818 Every log line starts with a timestamp, in the format shown in the following
54819 example. Note that many of the examples shown in this chapter are line-wrapped.
54820 In the log file, this would be all on one line:
54821 </para>
54822 <literallayout class="monospaced">
54823 2001-09-16 16:09:47 SMTP connection from [127.0.0.1] closed
54824   by QUIT
54825 </literallayout>
54826 <para>
54827 By default, the timestamps are in the local timezone. There are two
54828 ways of changing this:
54829 </para>
54830 <itemizedlist>
54831 <listitem>
54832 <para>
54833 You can set the <option>timezone</option> option to a different time zone; in particular, if
54834 you set
54835 </para>
54836 <literallayout class="monospaced">
54837 timezone = UTC
54838 </literallayout>
54839 <para>
54840 the timestamps will be in UTC (aka GMT).
54841 </para>
54842 </listitem>
54843 <listitem>
54844 <para>
54845 If you set <option>log_timezone</option> true, the time zone is added to the timestamp, for
54846 example:
54847 </para>
54848 <literallayout class="monospaced">
54849 2003-04-25 11:17:07 +0100 Start queue run: pid=12762
54850 </literallayout>
54851 </listitem>
54852 </itemizedlist>
54853 <section id="SECTwhelogwri">
54854 <title>Where the logs are written</title>
54855 <para>
54856 <indexterm role="concept">
54857 <primary>log</primary>
54858 <secondary>destination</secondary>
54859 </indexterm>
54860 <indexterm role="concept">
54861 <primary>log</primary>
54862 <secondary>to file</secondary>
54863 </indexterm>
54864 <indexterm role="concept">
54865 <primary>log</primary>
54866 <secondary>to syslog</secondary>
54867 </indexterm>
54868 <indexterm role="concept">
54869 <primary>syslog</primary>
54870 </indexterm>
54871 The logs may be written to local files, or to syslog, or both. However, it
54872 should be noted that many syslog implementations use UDP as a transport, and
54873 are therefore unreliable in the sense that messages are not guaranteed to
54874 arrive at the loghost, nor is the ordering of messages necessarily maintained.
54875 It has also been reported that on large log files (tens of megabytes) you may
54876 need to tweak syslog to prevent it syncing the file with each write &ndash; on
54877 Linux this has been seen to make syslog take 90% plus of CPU time.
54878 </para>
54879 <para>
54880 The destination for Exim&#x2019;s logs is configured by setting LOG_FILE_PATH in
54881 <filename>Local/Makefile</filename> or by setting <option>log_file_path</option> in the run time
54882 configuration. This latter string is expanded, so it can contain, for example,
54883 references to the host name:
54884 </para>
54885 <literallayout class="monospaced">
54886 log_file_path = /var/log/$primary_hostname/exim_%slog
54887 </literallayout>
54888 <para>
54889 It is generally advisable, however, to set the string in <filename>Local/Makefile</filename>
54890 rather than at run time, because then the setting is available right from the
54891 start of Exim&#x2019;s execution. Otherwise, if there&#x2019;s something it wants to log
54892 before it has read the configuration file (for example, an error in the
54893 configuration file) it will not use the path you want, and may not be able to
54894 log at all.
54895 </para>
54896 <para>
54897 The value of LOG_FILE_PATH or <option>log_file_path</option> is a colon-separated
54898 list, currently limited to at most two items. This is one option where the
54899 facility for changing a list separator may not be used. The list must always be
54900 colon-separated. If an item in the list is <quote>syslog</quote> then syslog is used;
54901 otherwise the item must either be an absolute path, containing <literal>%s</literal> at the
54902 point where <quote>main</quote>, <quote>reject</quote>, or <quote>panic</quote> is to be inserted, or be empty,
54903 implying the use of a default path.
54904 </para>
54905 <para>
54906 When Exim encounters an empty item in the list, it searches the list defined by
54907 LOG_FILE_PATH, and uses the first item it finds that is neither empty nor
54908 <quote>syslog</quote>. This means that an empty item in <option>log_file_path</option> can be used to
54909 mean <quote>use the path specified at build time</quote>. It no such item exists, log
54910 files are written in the <filename>log</filename> subdirectory of the spool directory. This is
54911 equivalent to the setting:
54912 </para>
54913 <literallayout class="monospaced">
54914 log_file_path = $spool_directory/log/%slog
54915 </literallayout>
54916 <para>
54917 If you do not specify anything at build time or run time, that is where the
54918 logs are written.
54919 </para>
54920 <para>
54921 A log file path may also contain <literal>%D</literal> if datestamped log file names are in
54922 use &ndash; see section <xref linkend="SECTdatlogfil"/> below.
54923 </para>
54924 <para>
54925 Here are some examples of possible settings:
54926 </para>
54927 <literallayout>
54928 <literal>LOG_FILE_PATH=syslog                    </literal> syslog only
54929 <literal>LOG_FILE_PATH=:syslog                   </literal> syslog and default path
54930 <literal>LOG_FILE_PATH=syslog : /usr/log/exim_%s </literal> syslog and specified path
54931 <literal>LOG_FILE_PATH=/usr/log/exim_%s          </literal> specified path only
54932 </literallayout>
54933 <para>
54934 If there are more than two paths in the list, the first is used and a panic
54935 error is logged.
54936 </para>
54937 </section>
54938 <section>
54939 <title>Logging to local files that are periodically <quote>cycled</quote></title>
54940 <para>
54941 <indexterm role="concept">
54942 <primary>log</primary>
54943 <secondary>cycling local files</secondary>
54944 </indexterm>
54945 <indexterm role="concept">
54946 <primary>cycling logs</primary>
54947 </indexterm>
54948 <indexterm role="concept">
54949 <primary><emphasis>exicyclog</emphasis></primary>
54950 </indexterm>
54951 <indexterm role="concept">
54952 <primary>log</primary>
54953 <secondary>local files; writing to</secondary>
54954 </indexterm>
54955 Some operating systems provide centralized and standardised methods for cycling
54956 log files. For those that do not, a utility script called <emphasis>exicyclog</emphasis> is
54957 provided (see section <xref linkend="SECTcyclogfil"/>). This renames and compresses the
54958 main and reject logs each time it is called. The maximum number of old logs to
54959 keep can be set. It is suggested this script is run as a daily <emphasis>cron</emphasis> job.
54960 </para>
54961 <para>
54962 An Exim delivery process opens the main log when it first needs to write to it,
54963 and it keeps the file open in case subsequent entries are required &ndash; for
54964 example, if a number of different deliveries are being done for the same
54965 message. However, remote SMTP deliveries can take a long time, and this means
54966 that the file may be kept open long after it is renamed if <emphasis>exicyclog</emphasis> or
54967 something similar is being used to rename log files on a regular basis. To
54968 ensure that a switch of log files is noticed as soon as possible, Exim calls
54969 <function>stat()</function> on the main log&#x2019;s name before reusing an open file, and if the file
54970 does not exist, or its inode has changed, the old file is closed and Exim
54971 tries to open the main log from scratch. Thus, an old log file may remain open
54972 for quite some time, but no Exim processes should write to it once it has been
54973 renamed.
54974 </para>
54975 </section>
54976 <section id="SECTdatlogfil">
54977 <title>Datestamped log files</title>
54978 <para>
54979 <indexterm role="concept">
54980 <primary>log</primary>
54981 <secondary>datestamped files</secondary>
54982 </indexterm>
54983 Instead of cycling the main and reject log files by renaming them
54984 periodically, some sites like to use files whose names contain a datestamp,
54985 for example, <filename>mainlog-20031225</filename>. The datestamp is in the form <filename>yyyymmdd</filename>.
54986 Exim has support for this way of working. It is enabled by setting the
54987 <option>log_file_path</option> option to a path that includes <literal>%D</literal> at the point where the
54988 datestamp is required. For example:
54989 </para>
54990 <literallayout class="monospaced">
54991 log_file_path = /var/spool/exim/log/%slog-%D
54992 log_file_path = /var/log/exim-%s-%D.log
54993 log_file_path = /var/spool/exim/log/%D-%slog
54994 </literallayout>
54995 <para>
54996 As before, <literal>%s</literal> is replaced by <quote>main</quote> or <quote>reject</quote>; the following are
54997 examples of names generated by the above examples:
54998 </para>
54999 <literallayout class="monospaced">
55000 /var/spool/exim/log/mainlog-20021225
55001 /var/log/exim-reject-20021225.log
55002 /var/spool/exim/log/20021225-mainlog
55003 </literallayout>
55004 <para>
55005 When this form of log file is specified, Exim automatically switches to new
55006 files at midnight. It does not make any attempt to compress old logs; you
55007 will need to write your own script if you require this. You should not
55008 run <emphasis>exicyclog</emphasis> with this form of logging.
55009 </para>
55010 <para>
55011 The location of the panic log is also determined by <option>log_file_path</option>, but it
55012 is not datestamped, because rotation of the panic log does not make sense.
55013 When generating the name of the panic log, <literal>%D</literal> is removed from the string.
55014 In addition, if it immediately follows a slash, a following non-alphanumeric
55015 character is removed; otherwise a preceding non-alphanumeric character is
55016 removed. Thus, the three examples above would give these panic log names:
55017 </para>
55018 <literallayout class="monospaced">
55019 /var/spool/exim/log/paniclog
55020 /var/log/exim-panic.log
55021 /var/spool/exim/log/paniclog
55022 </literallayout>
55023 </section>
55024 <section>
55025 <title>Logging to syslog</title>
55026 <para>
55027 <indexterm role="concept">
55028 <primary>log</primary>
55029 <secondary>syslog; writing to</secondary>
55030 </indexterm>
55031 The use of syslog does not change what Exim logs or the format of its messages,
55032 except in one respect. If <option>syslog_timestamp</option> is set false, the timestamps on
55033 Exim&#x2019;s log lines are omitted when these lines are sent to syslog. Apart from
55034 that, the same strings are written to syslog as to log files. The syslog
55035 <quote>facility</quote> is set to LOG_MAIL, and the program name to <quote>exim</quote>
55036 by default, but you can change these by setting the <option>syslog_facility</option> and
55037 <option>syslog_processname</option> options, respectively. If Exim was compiled with
55038 SYSLOG_LOG_PID set in <filename>Local/Makefile</filename> (this is the default in
55039 <filename>src/EDITME</filename>), then, on systems that permit it (all except ULTRIX), the
55040 LOG_PID flag is set so that the <function>syslog()</function> call adds the pid as well as
55041 the time and host name to each line.
55042 The three log streams are mapped onto syslog priorities as follows:
55043 </para>
55044 <itemizedlist>
55045 <listitem>
55046 <para>
55047 <emphasis>mainlog</emphasis> is mapped to LOG_INFO
55048 </para>
55049 </listitem>
55050 <listitem>
55051 <para>
55052 <emphasis>rejectlog</emphasis> is mapped to LOG_NOTICE
55053 </para>
55054 </listitem>
55055 <listitem>
55056 <para>
55057 <emphasis>paniclog</emphasis> is mapped to LOG_ALERT
55058 </para>
55059 </listitem>
55060 </itemizedlist>
55061 <para>
55062 Many log lines are written to both <emphasis>mainlog</emphasis> and <emphasis>rejectlog</emphasis>, and some are
55063 written to both <emphasis>mainlog</emphasis> and <emphasis>paniclog</emphasis>, so there will be duplicates if
55064 these are routed by syslog to the same place. You can suppress this duplication
55065 by setting <option>syslog_duplication</option> false.
55066 </para>
55067 <para>
55068 Exim&#x2019;s log lines can sometimes be very long, and some of its <emphasis>rejectlog</emphasis>
55069 entries contain multiple lines when headers are included. To cope with both
55070 these cases, entries written to syslog are split into separate <function>syslog()</function>
55071 calls at each internal newline, and also after a maximum of
55072 870 data characters. (This allows for a total syslog line length of 1024, when
55073 additions such as timestamps are added.) If you are running a syslog
55074 replacement that can handle lines longer than the 1024 characters allowed by
55075 RFC 3164, you should set
55076 </para>
55077 <literallayout class="monospaced">
55078 SYSLOG_LONG_LINES=yes
55079 </literallayout>
55080 <para>
55081 in <filename>Local/Makefile</filename> before building Exim. That stops Exim from splitting long
55082 lines, but it still splits at internal newlines in <emphasis>reject</emphasis> log entries.
55083 </para>
55084 <para>
55085 To make it easy to re-assemble split lines later, each component of a split
55086 entry starts with a string of the form [&lt;<emphasis>n</emphasis>&gt;/&lt;<emphasis>m</emphasis>&gt;] or [&lt;<emphasis>n</emphasis>&gt;\&lt;<emphasis>m</emphasis>&gt;]
55087 where &lt;<emphasis>n</emphasis>&gt; is the component number and &lt;<emphasis>m</emphasis>&gt; is the total number of
55088 components in the entry. The / delimiter is used when the line was split
55089 because it was too long; if it was split because of an internal newline, the \
55090 delimiter is used. For example, supposing the length limit to be 50 instead of
55091 870, the following would be the result of a typical rejection message to
55092 <emphasis>mainlog</emphasis> (LOG_INFO), each line in addition being preceded by the time, host
55093 name, and pid as added by syslog:
55094 </para>
55095 <literallayout class="monospaced">
55096 [1/5] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from
55097 [2/5]  [127.0.0.1] (ph10): syntax error in 'From' header
55098 [3/5]  when scanning for sender: missing or malformed lo
55099 [4/5] cal part in "&lt;&gt;" (envelope sender is &lt;ph10@cam.exa
55100 [5/5] mple&gt;)
55101 </literallayout>
55102 <para>
55103 The same error might cause the following lines to be written to <quote>rejectlog</quote>
55104 (LOG_NOTICE):
55105 </para>
55106 <literallayout class="monospaced">
55107 [1/18] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected fro
55108 [2/18] m [127.0.0.1] (ph10): syntax error in 'From' head
55109 [3/18] er when scanning for sender: missing or malformed
55110 [4/18]  local part in "&lt;&gt;" (envelope sender is &lt;ph10@cam
55111 [5\18] .example&gt;)
55112 [6\18] Recipients: ph10@some.domain.cam.example
55113 [7\18] P Received: from [127.0.0.1] (ident=ph10)
55114 [8\18]        by xxxxx.cam.example with smtp (Exim 4.00)
55115 [9\18]        id 16RdAL-0006pc-00
55116 [10/18]        for ph10@cam.example; Mon, 16 Sep 2002 16:
55117 [11\18] 09:43 +0100
55118 [12\18] F From: &lt;&gt;
55119 [13\18]   Subject: this is a test header
55120 [18\18]   X-something: this is another header
55121 [15/18] I Message-Id: &lt;E16RdAL-0006pc-00@xxxxx.cam.examp
55122 [16\18] le&gt;
55123 [17\18] B Bcc:
55124 [18/18]   Date: Mon, 16 Sep 2002 16:09:43 +0100
55125 </literallayout>
55126 <para>
55127 Log lines that are neither too long nor contain newlines are written to syslog
55128 without modification.
55129 </para>
55130 <para>
55131 If only syslog is being used, the Exim monitor is unable to provide a log tail
55132 display, unless syslog is routing <emphasis>mainlog</emphasis> to a file on the local host and
55133 the environment variable EXIMON_LOG_FILE_PATH is set to tell the monitor
55134 where it is.
55135 </para>
55136 </section>
55137 <section>
55138 <title>Log line flags</title>
55139 <para>
55140 One line is written to the main log for each message received, and for each
55141 successful, unsuccessful, and delayed delivery. These lines can readily be
55142 picked out by the distinctive two-character flags that immediately follow the
55143 timestamp. The flags are:
55144 </para>
55145 <literallayout>
55146 <literal>&lt;=</literal>     message arrival
55147 <literal>=&gt;</literal>     normal message delivery
55148 <literal>-&gt;</literal>     additional address in same delivery
55149 <literal>*&gt;</literal>     delivery suppressed by <option>-N</option>
55150 <literal>**</literal>     delivery failed; address bounced
55151 <literal>==</literal>     delivery deferred; temporary problem
55152 </literallayout>
55153 </section>
55154 <section>
55155 <title>Logging message reception</title>
55156 <para>
55157 <indexterm role="concept">
55158 <primary>log</primary>
55159 <secondary>reception line</secondary>
55160 </indexterm>
55161 The format of the single-line entry in the main log that is written for every
55162 message received is shown in the basic example below, which is split over
55163 several lines in order to fit it on the page:
55164 </para>
55165 <literallayout class="monospaced">
55166 2002-10-31 08:57:53 16ZCW1-0005MB-00 &lt;= kryten@dwarf.fict.example
55167   H=mailer.fict.example [192.168.123.123] U=exim
55168   P=smtp S=5678 id=&lt;incoming message id&gt;
55169 </literallayout>
55170 <para>
55171 The address immediately following <quote>&lt;=</quote> is the envelope sender address. A
55172 bounce message is shown with the sender address <quote>&lt;&gt;</quote>, and if it is locally
55173 generated, this is followed by an item of the form
55174 </para>
55175 <literallayout class="monospaced">
55176 R=&lt;message id&gt;
55177 </literallayout>
55178 <para>
55179 which is a reference to the message that caused the bounce to be sent.
55180 </para>
55181 <para>
55182 <indexterm role="concept">
55183 <primary>HELO</primary>
55184 </indexterm>
55185 <indexterm role="concept">
55186 <primary>EHLO</primary>
55187 </indexterm>
55188 For messages from other hosts, the H and U fields identify the remote host and
55189 record the RFC 1413 identity of the user that sent the message, if one was
55190 received. The number given in square brackets is the IP address of the sending
55191 host. If there is a single, unparenthesized  host name in the H field, as
55192 above, it has been verified to correspond to the IP address (see the
55193 <option>host_lookup</option> option). If the name is in parentheses, it was the name quoted
55194 by the remote host in the SMTP HELO or EHLO command, and has not been
55195 verified. If verification yields a different name to that given for HELO or
55196 EHLO, the verified name appears first, followed by the HELO or EHLO
55197 name in parentheses.
55198 </para>
55199 <para>
55200 Misconfigured hosts (and mail forgers) sometimes put an IP address, with or
55201 without brackets, in the HELO or EHLO command, leading to entries in
55202 the log containing text like these examples:
55203 </para>
55204 <literallayout class="monospaced">
55205 H=(10.21.32.43) [192.168.8.34]
55206 H=([10.21.32.43]) [192.168.8.34]
55207 </literallayout>
55208 <para>
55209 This can be confusing. Only the final address in square brackets can be relied
55210 on.
55211 </para>
55212 <para>
55213 For locally generated messages (that is, messages not received over TCP/IP),
55214 the H field is omitted, and the U field contains the login name of the caller
55215 of Exim.
55216 </para>
55217 <para>
55218 <indexterm role="concept">
55219 <primary>authentication</primary>
55220 <secondary>logging</secondary>
55221 </indexterm>
55222 <indexterm role="concept">
55223 <primary>AUTH</primary>
55224 <secondary>logging</secondary>
55225 </indexterm>
55226 For all messages, the P field specifies the protocol used to receive the
55227 message. This is the value that is stored in <varname>$received_protocol</varname>. In the case
55228 of incoming SMTP messages, the value indicates whether or not any SMTP
55229 extensions (ESMTP), encryption, or authentication were used. If the SMTP
55230 session was encrypted, there is an additional X field that records the cipher
55231 suite that was used.
55232 </para>
55233 <para>
55234 The protocol is set to <quote>esmptsa</quote> or <quote>esmtpa</quote> for messages received from
55235 hosts that have authenticated themselves using the SMTP AUTH command. The first
55236 value is used when the SMTP connection was encrypted (<quote>secure</quote>). In this case
55237 there is an additional item A= followed by the name of the authenticator that
55238 was used. If an authenticated identification was set up by the authenticator&#x2019;s
55239 <option>server_set_id</option> option, this is logged too, separated by a colon from the
55240 authenticator name.
55241 </para>
55242 <para>
55243 <indexterm role="concept">
55244 <primary>size</primary>
55245 <secondary>of message</secondary>
55246 </indexterm>
55247 The id field records the existing message id, if present. The size of the
55248 received message is given by the S field. When the message is delivered,
55249 headers may be removed or added, so that the size of delivered copies of the
55250 message may not correspond with this value (and indeed may be different to each
55251 other).
55252 </para>
55253 <para>
55254 The <option>log_selector</option> option can be used to request the logging of additional
55255 data when a message is received. See section <xref linkend="SECTlogselector"/> below.
55256 </para>
55257 </section>
55258 <section>
55259 <title>Logging deliveries</title>
55260 <para>
55261 <indexterm role="concept">
55262 <primary>log</primary>
55263 <secondary>delivery line</secondary>
55264 </indexterm>
55265 The format of the single-line entry in the main log that is written for every
55266 delivery is shown in one of the examples below, for local and remote
55267 deliveries, respectively. Each example has been split into two lines in order
55268 to fit it on the page:
55269 </para>
55270 <literallayout class="monospaced">
55271 2002-10-31 08:59:13 16ZCW1-0005MB-00 =&gt; marv
55272   &lt;marv@hitch.fict.example&gt; R=localuser T=local_delivery
55273 2002-10-31 09:00:10 16ZCW1-0005MB-00 =&gt;
55274   monk@holistic.fict.example R=dnslookup T=remote_smtp
55275   H=holistic.fict.example [192.168.234.234]
55276 </literallayout>
55277 <para>
55278 For ordinary local deliveries, the original address is given in angle brackets
55279 after the final delivery address, which might be a pipe or a file. If
55280 intermediate address(es) exist between the original and the final address, the
55281 last of these is given in parentheses after the final address. The R and T
55282 fields record the router and transport that were used to process the address.
55283 </para>
55284 <para>
55285 If a shadow transport was run after a successful local delivery, the log line
55286 for the successful delivery has an item added on the end, of the form
55287 </para>
55288 <literallayout>
55289 <literal>ST=&lt;</literal><emphasis>shadow transport name</emphasis><literal>&gt;</literal>
55290 </literallayout>
55291 <para>
55292 If the shadow transport did not succeed, the error message is put in
55293 parentheses afterwards.
55294 </para>
55295 <para>
55296 <indexterm role="concept">
55297 <primary>asterisk</primary>
55298 <secondary>after IP address</secondary>
55299 </indexterm>
55300 When more than one address is included in a single delivery (for example, two
55301 SMTP RCPT commands in one transaction) the second and subsequent addresses are
55302 flagged with <literal>-&gt;</literal> instead of <literal>=&gt;</literal>. When two or more messages are delivered
55303 down a single SMTP connection, an asterisk follows the IP address in the log
55304 lines for the second and subsequent messages.
55305 </para>
55306 <para>
55307 The generation of a reply message by a filter file gets logged as a
55308 <quote>delivery</quote> to the addressee, preceded by <quote>&gt;</quote>.
55309 </para>
55310 <para>
55311 The <option>log_selector</option> option can be used to request the logging of additional
55312 data when a message is delivered. See section <xref linkend="SECTlogselector"/> below.
55313 </para>
55314 </section>
55315 <section>
55316 <title>Discarded deliveries</title>
55317 <para>
55318 <indexterm role="concept">
55319 <primary>discarded messages</primary>
55320 </indexterm>
55321 <indexterm role="concept">
55322 <primary>message</primary>
55323 <secondary>discarded</secondary>
55324 </indexterm>
55325 <indexterm role="concept">
55326 <primary>delivery</primary>
55327 <secondary>discarded; logging</secondary>
55328 </indexterm>
55329 When a message is discarded as a result of the command <quote>seen finish</quote> being
55330 obeyed in a filter file which generates no deliveries, a log entry of the form
55331 </para>
55332 <literallayout class="monospaced">
55333 2002-12-10 00:50:49 16auJc-0001UB-00 =&gt; discarded
55334   &lt;low.club@bridge.example&gt; R=userforward
55335 </literallayout>
55336 <para>
55337 is written, to record why no deliveries are logged. When a message is discarded
55338 because it is aliased to <quote>:blackhole:</quote> the log line is like this:
55339 </para>
55340 <literallayout class="monospaced">
55341 1999-03-02 09:44:33 10HmaX-0005vi-00 =&gt; :blackhole:
55342   &lt;hole@nowhere.example&gt; R=blackhole_router
55343 </literallayout>
55344 </section>
55345 <section>
55346 <title>Deferred deliveries</title>
55347 <para>
55348 When a delivery is deferred, a line of the following form is logged:
55349 </para>
55350 <literallayout class="monospaced">
55351 2002-12-19 16:20:23 16aiQz-0002Q5-00 == marvin@endrest.example
55352   R=dnslookup T=smtp defer (146): Connection refused
55353 </literallayout>
55354 <para>
55355 In the case of remote deliveries, the error is the one that was given for the
55356 last IP address that was tried. Details of individual SMTP failures are also
55357 written to the log, so the above line would be preceded by something like
55358 </para>
55359 <literallayout class="monospaced">
55360 2002-12-19 16:20:23 16aiQz-0002Q5-00 Failed to connect to
55361   mail1.endrest.example [192.168.239.239]: Connection refused
55362 </literallayout>
55363 <para>
55364 When a deferred address is skipped because its retry time has not been reached,
55365 a message is written to the log, but this can be suppressed by setting an
55366 appropriate value in <option>log_selector</option>.
55367 </para>
55368 </section>
55369 <section>
55370 <title>Delivery failures</title>
55371 <para>
55372 <indexterm role="concept">
55373 <primary>delivery</primary>
55374 <secondary>failure; logging</secondary>
55375 </indexterm>
55376 If a delivery fails because an address cannot be routed, a line of the
55377 following form is logged:
55378 </para>
55379 <literallayout class="monospaced">
55380 1995-12-19 16:20:23 0tRiQz-0002Q5-00 ** jim@trek99.example
55381   &lt;jim@trek99.example&gt;: unknown mail domain
55382 </literallayout>
55383 <para>
55384 If a delivery fails at transport time, the router and transport are shown, and
55385 the response from the remote host is included, as in this example:
55386 </para>
55387 <literallayout class="monospaced">
55388 2002-07-11 07:14:17 17SXDU-000189-00 ** ace400@pb.example
55389   R=dnslookup T=remote_smtp: SMTP error from remote mailer
55390   after pipelined RCPT TO:&lt;ace400@pb.example&gt;: host
55391   pbmail3.py.example [192.168.63.111]: 553 5.3.0
55392   &lt;ace400@pb.example&gt;...Addressee unknown
55393 </literallayout>
55394 <para>
55395 The word <quote>pipelined</quote> indicates that the SMTP PIPELINING extension was being
55396 used. See <option>hosts_avoid_esmtp</option> in the <command>smtp</command> transport for a way of
55397 disabling PIPELINING. The log lines for all forms of delivery failure are
55398 flagged with <literal>**</literal>.
55399 </para>
55400 </section>
55401 <section>
55402 <title>Fake deliveries</title>
55403 <para>
55404 <indexterm role="concept">
55405 <primary>delivery</primary>
55406 <secondary>fake; logging</secondary>
55407 </indexterm>
55408 If a delivery does not actually take place because the <option>-N</option> option has been
55409 used to suppress it, a normal delivery line is written to the log, except that
55410 <quote>=&gt;</quote> is replaced by <quote>*&gt;</quote>.
55411 </para>
55412 </section>
55413 <section>
55414 <title>Completion</title>
55415 <para>
55416 A line of the form
55417 </para>
55418 <literallayout class="monospaced">
55419 2002-10-31 09:00:11 16ZCW1-0005MB-00 Completed
55420 </literallayout>
55421 <para>
55422 is written to the main log when a message is about to be removed from the spool
55423 at the end of its processing.
55424 </para>
55425 </section>
55426 <section>
55427 <title>Summary of Fields in Log Lines</title>
55428 <para>
55429 <indexterm role="concept">
55430 <primary>log</primary>
55431 <secondary>summary of fields</secondary>
55432 </indexterm>
55433 A summary of the field identifiers that are used in log lines is shown in
55434 the following table:
55435 </para>
55436 <literallayout>
55437 <literal>A   </literal>        authenticator name (and optional id)
55438 <literal>C   </literal>        SMTP confirmation on delivery
55439 <literal>CV  </literal>        certificate verification status
55440 <literal>DN  </literal>        distinguished name from peer certificate
55441 <literal>DT  </literal>        on <literal>=&gt;</literal> lines: time taken for a delivery
55442 <literal>F   </literal>        sender address (on delivery lines)
55443 <literal>H   </literal>        host name and IP address
55444 <literal>I   </literal>        local interface used
55445 <literal>id  </literal>        message id for incoming message
55446 <literal>P   </literal>        on <literal>&lt;=</literal> lines: protocol used
55447 <literal>    </literal>        on <literal>=&gt;</literal> and <literal>**</literal> lines: return path
55448 <literal>QT  </literal>        on <literal>=&gt;</literal> lines: time spent on queue so far
55449 <literal>    </literal>        on <quote>Completed</quote> lines: time spent on queue
55450 <literal>R   </literal>        on <literal>&lt;=</literal> lines: reference for local bounce
55451 <literal>    </literal>        on <literal>=&gt;</literal>  <literal>**</literal> and <literal>==</literal> lines: router name
55452 <literal>S   </literal>        size of message
55453 <literal>ST  </literal>        shadow transport name
55454 <literal>T   </literal>        on <literal>&lt;=</literal> lines: message subject (topic)
55455 <literal>    </literal>        on <literal>=&gt;</literal> <literal>**</literal> and <literal>==</literal> lines: transport name
55456 <literal>U   </literal>        local user or RFC 1413 identity
55457 <literal>X   </literal>        TLS cipher suite
55458 </literallayout>
55459 </section>
55460 <section>
55461 <title>Other log entries</title>
55462 <para>
55463 Various other types of log entry are written from time to time. Most should be
55464 self-explanatory. Among the more common are:
55465 </para>
55466 <itemizedlist>
55467 <listitem>
55468 <para>
55469 <indexterm role="concept">
55470 <primary>retry</primary>
55471 <secondary>time not reached</secondary>
55472 </indexterm>
55473 <emphasis>retry time not reached</emphasis>&nbsp;&nbsp;An address previously suffered a temporary error
55474 during routing or local delivery, and the time to retry has not yet arrived.
55475 This message is not written to an individual message log file unless it happens
55476 during the first delivery attempt.
55477 </para>
55478 </listitem>
55479 <listitem>
55480 <para>
55481 <emphasis>retry time not reached for any host</emphasis>&nbsp;&nbsp;An address previously suffered
55482 temporary errors during remote delivery, and the retry time has not yet arrived
55483 for any of the hosts to which it is routed.
55484 </para>
55485 </listitem>
55486 <listitem>
55487 <para>
55488 <indexterm role="concept">
55489 <primary>spool directory</primary>
55490 <secondary>file locked</secondary>
55491 </indexterm>
55492 <emphasis>spool file locked</emphasis>&nbsp;&nbsp;An attempt to deliver a message cannot proceed because
55493 some other Exim process is already working on the message. This can be quite
55494 common if queue running processes are started at frequent intervals. The
55495 <emphasis>exiwhat</emphasis> utility script can be used to find out what Exim processes are
55496 doing.
55497 </para>
55498 </listitem>
55499 <listitem>
55500 <para>
55501 <indexterm role="concept">
55502 <primary>error</primary>
55503 <secondary>ignored</secondary>
55504 </indexterm>
55505 <emphasis>error ignored</emphasis>&nbsp;&nbsp;There are several circumstances that give rise to this
55506 message:
55507 </para>
55508 <orderedlist numeration="arabic">
55509 <listitem>
55510 <para>
55511 Exim failed to deliver a bounce message whose age was greater than
55512 <option>ignore_bounce_errors_after</option>. The bounce was discarded.
55513 </para>
55514 </listitem>
55515 <listitem>
55516 <para>
55517 A filter file set up a delivery using the <quote>noerror</quote> option, and the delivery
55518 failed. The delivery was discarded.
55519 </para>
55520 </listitem>
55521 <listitem>
55522 <para>
55523 A delivery set up by a router configured with
55524 </para>
55525 <literallayout class="monospaced">
55526     errors_to = &lt;&gt;
55527 </literallayout>
55528 <para>
55529 failed. The delivery was discarded.
55530 </para>
55531 </listitem>
55532 </orderedlist>
55533 </listitem>
55534 </itemizedlist>
55535 </section>
55536 <section id="SECTlogselector">
55537 <title>Reducing or increasing what is logged</title>
55538 <para>
55539 <indexterm role="concept">
55540 <primary>log</primary>
55541 <secondary>selectors</secondary>
55542 </indexterm>
55543 By setting the <option>log_selector</option> global option, you can disable some of Exim&#x2019;s
55544 default logging, or you can request additional logging. The value of
55545 <option>log_selector</option> is made up of names preceded by plus or minus characters. For
55546 example:
55547 </para>
55548 <literallayout class="monospaced">
55549 log_selector = +arguments -retry_defer
55550 </literallayout>
55551 <para>
55552 The list of optional log items is in the following table, with the default
55553 selection marked by asterisks:
55554 </para>
55555 <literallayout>
55556 <literal>*acl_warn_skipped           </literal>  skipped <option>warn</option> statement in ACL
55557 <literal> address_rewrite            </literal>  address rewriting
55558 <literal> all_parents                </literal>  all parents in =&gt; lines
55559 <literal> arguments                  </literal>  command line arguments
55560 <literal>*connection_reject          </literal>  connection rejections
55561 <literal>*delay_delivery             </literal>  immediate delivery delayed
55562 <literal> deliver_time               </literal>  time taken to perform delivery
55563 <literal> delivery_size              </literal>  add <literal>S=</literal><emphasis>nnn</emphasis> to =&gt; lines
55564 <literal>*dnslist_defer              </literal>  defers of DNS list (aka RBL) lookups
55565 <literal>*etrn                       </literal>  ETRN commands
55566 <literal>*host_lookup_failed         </literal>  as it says
55567 <literal> ident_timeout              </literal>  timeout for ident connection
55568 <literal> incoming_interface         </literal>  incoming interface on &lt;= lines
55569 <literal> incoming_port              </literal>  incoming port on &lt;= lines
55570 <literal>*lost_incoming_connection   </literal>  as it says (includes timeouts)
55571 <literal> outgoing_port              </literal>  add remote port to =&gt; lines
55572 <literal>*queue_run                  </literal>  start and end queue runs
55573 <literal> queue_time                 </literal>  time on queue for one recipient
55574 <literal> queue_time_overall         </literal>  time on queue for whole message
55575 <literal> received_recipients        </literal>  recipients on &lt;= lines
55576 <literal> received_sender            </literal>  sender on &lt;= lines
55577 <literal>*rejected_header            </literal>  header contents on reject log
55578 <literal>*retry_defer                </literal>  <quote>retry time not reached</quote>
55579 <literal> return_path_on_delivery    </literal>  put return path on =&gt; and *\ lines
55580 <literal> sender_on_delivery         </literal>  add sender to =&gt; lines
55581 <literal>*sender_verify_fail         </literal>  sender verification failures
55582 <literal>*size_reject                </literal>  rejection because too big
55583 <literal>*skip_delivery              </literal>  delivery skipped in a queue run
55584 <literal> smtp_confirmation          </literal>  SMTP confirmation on =&gt; lines
55585 <literal> smtp_connection            </literal>  SMTP connections
55586 <literal> smtp_incomplete_transaction</literal>  incomplete SMTP transactions
55587 <literal> smtp_protocol_error        </literal>  SMTP protocol errors
55588 <literal> smtp_syntax_error          </literal>  SMTP syntax errors
55589 <literal> subject                    </literal>  contents of <emphasis>Subject:</emphasis> on &lt;= lines
55590 <literal> tls_certificate_verified   </literal>  certificate verification status
55591 <literal>*tls_cipher                 </literal>  TLS cipher suite on &lt;= and =&gt; lines
55592 <literal> tls_peerdn                 </literal>  TLS peer DN on &lt;= and =&gt; lines
55593 <literal> unknown_in_list            </literal>  DNS lookup failed in list match
55594
55595 <literal> all                        </literal>  all of the above
55596 </literallayout>
55597 <para>
55598 More details on each of these items follows:
55599 </para>
55600 <itemizedlist>
55601 <listitem>
55602 <para>
55603 <indexterm role="concept">
55604 <primary><option>warn</option> statement</primary>
55605 <secondary>log when skipping</secondary>
55606 </indexterm>
55607 <option>acl_warn_skipped</option>: When an ACL <option>warn</option> statement is skipped because one of
55608 its conditions cannot be evaluated, a log line to this effect is written if
55609 this log selector is set.
55610 </para>
55611 </listitem>
55612 <listitem>
55613 <para>
55614 <indexterm role="concept">
55615 <primary>log</primary>
55616 <secondary>rewriting</secondary>
55617 </indexterm>
55618 <indexterm role="concept">
55619 <primary>rewriting</primary>
55620 <secondary>logging</secondary>
55621 </indexterm>
55622 <option>address_rewrite</option>: This applies both to global rewrites and per-transport
55623 rewrites, but not to rewrites in filters run as an unprivileged user (because
55624 such users cannot access the log).
55625 </para>
55626 </listitem>
55627 <listitem>
55628 <para>
55629 <indexterm role="concept">
55630 <primary>log</primary>
55631 <secondary>full parentage</secondary>
55632 </indexterm>
55633 <option>all_parents</option>: Normally only the original and final addresses are logged on
55634 delivery lines; with this selector, intermediate parents are given in
55635 parentheses between them.
55636 </para>
55637 </listitem>
55638 <listitem>
55639 <para>
55640 <indexterm role="concept">
55641 <primary>log</primary>
55642 <secondary>Exim arguments</secondary>
55643 </indexterm>
55644 <indexterm role="concept">
55645 <primary>Exim arguments</primary>
55646 <secondary>logging</secondary>
55647 </indexterm>
55648 <option>arguments</option>: This causes Exim to write the arguments with which it was called
55649 to the main log, preceded by the current working directory. This is a debugging
55650 feature, added to make it easier to find out how certain MUAs call
55651 <filename>/usr/sbin/sendmail</filename>. The logging does not happen if Exim has given up root
55652 privilege because it was called with the <option>-C</option> or <option>-D</option> options. Arguments
55653 that are empty or that contain white space are quoted. Non-printing characters
55654 are shown as escape sequences. This facility cannot log unrecognized arguments,
55655 because the arguments are checked before the configuration file is read. The
55656 only way to log such cases is to interpose a script such as <filename>util/logargs.sh</filename>
55657 between the caller and Exim.
55658 </para>
55659 </listitem>
55660 <listitem>
55661 <para>
55662 <indexterm role="concept">
55663 <primary>log</primary>
55664 <secondary>connection rejections</secondary>
55665 </indexterm>
55666 <option>connection_reject</option>: A log entry is written whenever an incoming SMTP
55667 connection is rejected, for whatever reason.
55668 </para>
55669 </listitem>
55670 <listitem>
55671 <para>
55672 <indexterm role="concept">
55673 <primary>log</primary>
55674 <secondary>delayed delivery</secondary>
55675 </indexterm>
55676 <indexterm role="concept">
55677 <primary>delayed delivery</primary>
55678 <secondary>logging</secondary>
55679 </indexterm>
55680 <option>delay_delivery</option>: A log entry is written whenever a delivery process is not
55681 started for an incoming message because the load is too high or too many
55682 messages were received on one connection. Logging does not occur if no delivery
55683 process is started because <option>queue_only</option> is set or <option>-odq</option> was used.
55684 </para>
55685 </listitem>
55686 <listitem>
55687 <para>
55688 <indexterm role="concept">
55689 <primary>log</primary>
55690 <secondary>delivery duration</secondary>
55691 </indexterm>
55692 <option>deliver_time</option>: For each delivery, the amount of real time it has taken to
55693 perform the actual delivery is logged as DT=&lt;<emphasis>time</emphasis>&gt;, for example, <literal>DT=1s</literal>.
55694 </para>
55695 </listitem>
55696 <listitem>
55697 <para>
55698 <indexterm role="concept">
55699 <primary>log</primary>
55700 <secondary>message size on delivery</secondary>
55701 </indexterm>
55702 <indexterm role="concept">
55703 <primary>size</primary>
55704 <secondary>of message</secondary>
55705 </indexterm>
55706 <option>delivery_size</option>: For each delivery, the size of message delivered is added to
55707 the <quote>=&gt;</quote> line, tagged with S=.
55708 </para>
55709 </listitem>
55710 <listitem>
55711 <para>
55712 <indexterm role="concept">
55713 <primary>log</primary>
55714 <secondary>dnslist defer</secondary>
55715 </indexterm>
55716 <indexterm role="concept">
55717 <primary>DNS list</primary>
55718 <secondary>logging defer</secondary>
55719 </indexterm>
55720 <indexterm role="concept">
55721 <primary>black list (DNS)</primary>
55722 </indexterm>
55723 <option>dnslist_defer</option>: A log entry is written if an attempt to look up a host in a
55724 DNS black list suffers a temporary error.
55725 </para>
55726 </listitem>
55727 <listitem>
55728 <para>
55729 <indexterm role="concept">
55730 <primary>log</primary>
55731 <secondary>ETRN commands</secondary>
55732 </indexterm>
55733 <indexterm role="concept">
55734 <primary>ETRN</primary>
55735 <secondary>logging</secondary>
55736 </indexterm>
55737 <option>etrn</option>: Every legal ETRN command that is received is logged, before the ACL
55738 is run to determine whether or not it is actually accepted. An invalid ETRN
55739 command, or one received within a message transaction is not logged by this
55740 selector (see <option>smtp_syntax_error</option> and <option>smtp_protocol_error</option>).
55741 </para>
55742 </listitem>
55743 <listitem>
55744 <para>
55745 <indexterm role="concept">
55746 <primary>log</primary>
55747 <secondary>host lookup failure</secondary>
55748 </indexterm>
55749 <option>host_lookup_failed</option>: When a lookup of a host&#x2019;s IP addresses fails to find
55750 any addresses, or when a lookup of an IP address fails to find a host name, a
55751 log line is written. This logging does not apply to direct DNS lookups when
55752 routing email addresses, but it does apply to <quote>byname</quote> lookups.
55753 </para>
55754 </listitem>
55755 <listitem>
55756 <para>
55757 <indexterm role="concept">
55758 <primary>log</primary>
55759 <secondary>ident timeout</secondary>
55760 </indexterm>
55761 <indexterm role="concept">
55762 <primary>RFC 1413</primary>
55763 <secondary>logging timeout</secondary>
55764 </indexterm>
55765 <option>ident_timeout</option>: A log line is written whenever an attempt to connect to a
55766 client&#x2019;s ident port times out.
55767 </para>
55768 </listitem>
55769 <listitem>
55770 <para>
55771 <indexterm role="concept">
55772 <primary>log</primary>
55773 <secondary>incoming interface</secondary>
55774 </indexterm>
55775 <indexterm role="concept">
55776 <primary>interface</primary>
55777 <secondary>logging</secondary>
55778 </indexterm>
55779 <option>incoming_interface</option>: The interface on which a message was received is added
55780 to the <quote>&lt;=</quote> line as an IP address in square brackets, tagged by I= and
55781 followed by a colon and the port number. The local interface and port are also
55782 added to other SMTP log lines, for example <quote>SMTP connection from</quote>, and to
55783 rejection lines.
55784 </para>
55785 </listitem>
55786 <listitem>
55787 <para>
55788 <indexterm role="concept">
55789 <primary>log</primary>
55790 <secondary>incoming remote port</secondary>
55791 </indexterm>
55792 <indexterm role="concept">
55793 <primary>port</primary>
55794 <secondary>logging remote</secondary>
55795 </indexterm>
55796 <indexterm role="concept">
55797 <primary>TCP/IP</primary>
55798 <secondary>logging incoming remote port</secondary>
55799 </indexterm>
55800 <indexterm role="concept">
55801 <primary><varname>$sender_fullhost</varname></primary>
55802 </indexterm>
55803 <indexterm role="concept">
55804 <primary><varname>$sender_rcvhost</varname></primary>
55805 </indexterm>
55806 <option>incoming_port</option>: The remote port number from which a message was received is
55807 added to log entries and <emphasis>Received:</emphasis> header lines, following the IP address
55808 in square brackets, and separated from it by a colon. This is implemented by
55809 changing the value that is put in the <varname>$sender_fullhost</varname> and
55810 <varname>$sender_rcvhost</varname> variables. Recording the remote port number has become more
55811 important with the widening use of NAT (see RFC 2505).
55812 </para>
55813 </listitem>
55814 <listitem>
55815 <para>
55816 <indexterm role="concept">
55817 <primary>log</primary>
55818 <secondary>dropped connection</secondary>
55819 </indexterm>
55820 <option>lost_incoming_connection</option>: A log line is written when an incoming SMTP
55821 connection is unexpectedly dropped.
55822 </para>
55823 </listitem>
55824 <listitem>
55825 <para>
55826 <indexterm role="concept">
55827 <primary>log</primary>
55828 <secondary>outgoing remote port</secondary>
55829 </indexterm>
55830 <indexterm role="concept">
55831 <primary>port</primary>
55832 <secondary>logging outgoint remote</secondary>
55833 </indexterm>
55834 <indexterm role="concept">
55835 <primary>TCP/IP</primary>
55836 <secondary>logging ougtoing remote port</secondary>
55837 </indexterm>
55838 <option>outgoing_port</option>: The remote port number is added to delivery log lines (those
55839 containing =&gt; tags) following the IP address. This option is not included in
55840 the default setting, because for most ordinary configurations, the remote port
55841 number is always 25 (the SMTP port).
55842 </para>
55843 </listitem>
55844 <listitem>
55845 <para>
55846 <indexterm role="concept">
55847 <primary>log</primary>
55848 <secondary>queue run</secondary>
55849 </indexterm>
55850 <indexterm role="concept">
55851 <primary>queue runner</primary>
55852 <secondary>logging</secondary>
55853 </indexterm>
55854 <option>queue_run</option>: The start and end of every queue run are logged.
55855 </para>
55856 </listitem>
55857 <listitem>
55858 <para>
55859 <indexterm role="concept">
55860 <primary>log</primary>
55861 <secondary>queue time</secondary>
55862 </indexterm>
55863 <option>queue_time</option>: The amount of time the message has been in the queue on the
55864 local host is logged as QT=&lt;<emphasis>time</emphasis>&gt; on delivery (<literal>=&gt;</literal>) lines, for example,
55865 <literal>QT=3m45s</literal>. The clock starts when Exim starts to receive the message, so it
55866 includes reception time as well as the delivery time for the current address.
55867 This means that it may be longer than the difference between the arrival and
55868 delivery log line times, because the arrival log line is not written until the
55869 message has been successfully received.
55870 </para>
55871 </listitem>
55872 <listitem>
55873 <para>
55874 <option>queue_time_overall</option>: The amount of time the message has been in the queue on
55875 the local host is logged as QT=&lt;<emphasis>time</emphasis>&gt; on <quote>Completed</quote> lines, for
55876 example, <literal>QT=3m45s</literal>. The clock starts when Exim starts to receive the
55877 message, so it includes reception time as well as the total delivery time.
55878 </para>
55879 </listitem>
55880 <listitem>
55881 <para>
55882 <indexterm role="concept">
55883 <primary>log</primary>
55884 <secondary>recipients</secondary>
55885 </indexterm>
55886 <option>received_recipients</option>: The recipients of a message are listed in the main log
55887 as soon as the message is received. The list appears at the end of the log line
55888 that is written when a message is received, preceded by the word <quote>for</quote>. The
55889 addresses are listed after they have been qualified, but before any rewriting
55890 has taken place.
55891 Recipients that were discarded by an ACL for MAIL or RCPT do not appear
55892 in the list.
55893 </para>
55894 </listitem>
55895 <listitem>
55896 <para>
55897 <indexterm role="concept">
55898 <primary>log</primary>
55899 <secondary>sender reception</secondary>
55900 </indexterm>
55901 <option>received_sender</option>: The unrewritten original sender of a message is added to
55902 the end of the log line that records the message&#x2019;s arrival, after the word
55903 <quote>from</quote> (before the recipients if <option>received_recipients</option> is also set).
55904 </para>
55905 </listitem>
55906 <listitem>
55907 <para>
55908 <indexterm role="concept">
55909 <primary>log</primary>
55910 <secondary>header lines for rejection</secondary>
55911 </indexterm>
55912 <option>rejected_header</option>: If a message&#x2019;s header has been received at the time a
55913 rejection is written to the reject log, the complete header is added to the
55914 log. Header logging can be turned off individually for messages that are
55915 rejected by the <function>local_scan()</function> function (see section <xref linkend="SECTapiforloc"/>).
55916 </para>
55917 </listitem>
55918 <listitem>
55919 <para>
55920 <indexterm role="concept">
55921 <primary>log</primary>
55922 <secondary>retry defer</secondary>
55923 </indexterm>
55924 <option>retry_defer</option>: A log line is written if a delivery is deferred because a
55925 retry time has not yet been reached. However, this <quote>retry time not reached</quote>
55926 message is always omitted from individual message logs after the first delivery
55927 attempt.
55928 </para>
55929 </listitem>
55930 <listitem>
55931 <para>
55932 <indexterm role="concept">
55933 <primary>log</primary>
55934 <secondary>return path</secondary>
55935 </indexterm>
55936 <option>return_path_on_delivery</option>: The return path that is being transmitted with
55937 the message is included in delivery and bounce lines, using the tag P=.
55938 This is omitted if no delivery actually happens, for example, if routing fails,
55939 or if delivery is to <filename>/dev/null</filename> or to <literal>:blackhole:</literal>.
55940 </para>
55941 </listitem>
55942 <listitem>
55943 <para>
55944 <indexterm role="concept">
55945 <primary>log</primary>
55946 <secondary>sender on delivery</secondary>
55947 </indexterm>
55948 <option>sender_on_delivery</option>: The message&#x2019;s sender address is added to every delivery
55949 and bounce line, tagged by F= (for <quote>from</quote>).
55950 This is the original sender that was received with the message; it is not
55951 necessarily the same as the outgoing return path.
55952 </para>
55953 </listitem>
55954 <listitem>
55955 <para revisionflag="changed">
55956 <indexterm role="concept">
55957 <primary>log</primary>
55958 <secondary>sender verify failure</secondary>
55959 </indexterm>
55960 <option>sender_verify_failure</option>: If this selector is unset, the separate log line
55961 that gives details of a sender verification failure is not written. Log lines
55962 for the rejection of SMTP commands contain just <quote>sender verify failed</quote>, so
55963 some detail is lost.
55964 </para>
55965 </listitem>
55966 <listitem>
55967 <para>
55968 <indexterm role="concept">
55969 <primary>log</primary>
55970 <secondary>size rejection</secondary>
55971 </indexterm>
55972 <option>size_reject</option>: A log line is written whenever a message is rejected because
55973 it is too big.
55974 </para>
55975 </listitem>
55976 <listitem>
55977 <para>
55978 <indexterm role="concept">
55979 <primary>log</primary>
55980 <secondary>frozen messages; skipped</secondary>
55981 </indexterm>
55982 <indexterm role="concept">
55983 <primary>frozen messages</primary>
55984 <secondary>logging skipping</secondary>
55985 </indexterm>
55986 <option>skip_delivery</option>: A log line is written whenever a message is skipped during a
55987 queue run because it is frozen or because another process is already delivering
55988 it.
55989 <indexterm role="concept">
55990 <primary><quote>spool file is locked</quote></primary>
55991 </indexterm>
55992 The message that is written is <quote>spool file is locked</quote>.
55993 </para>
55994 </listitem>
55995 <listitem>
55996 <para>
55997 <indexterm role="concept">
55998 <primary>log</primary>
55999 <secondary>smtp confirmation</secondary>
56000 </indexterm>
56001 <indexterm role="concept">
56002 <primary>SMTP</primary>
56003 <secondary>logging confirmation</secondary>
56004 </indexterm>
56005 <option>smtp_confirmation</option>: The response to the final <quote>.</quote> in the SMTP dialogue for
56006 outgoing messages is added to delivery log lines in the form <literal>C=</literal>&lt;<emphasis>text</emphasis>&gt;.
56007 A number of MTAs (including Exim) return an identifying string in this
56008 response.
56009 </para>
56010 </listitem>
56011 <listitem>
56012 <para>
56013 <indexterm role="concept">
56014 <primary>log</primary>
56015 <secondary>SMTP connections</secondary>
56016 </indexterm>
56017 <indexterm role="concept">
56018 <primary>SMTP</primary>
56019 <secondary>logging connections</secondary>
56020 </indexterm>
56021 <option>smtp_connection</option>: A log line is written whenever an SMTP connection is
56022 established or closed, unless the connection is from a host that matches
56023 <option>hosts_connection_nolog</option>. (In contrast, <option>lost_incoming_connection</option> applies
56024 only when the closure is unexpected.) This applies to connections from local
56025 processes that use <option>-bs</option> as well as to TCP/IP connections. If a connection is
56026 dropped in the middle of a message, a log line is always written, whether or
56027 not this selector is set, but otherwise nothing is written at the start and end
56028 of connections unless this selector is enabled.
56029 </para>
56030 <para>
56031 For TCP/IP connections to an Exim daemon, the current number of connections is
56032 included in the log message for each new connection, but note that the count is
56033 reset if the daemon is restarted.
56034 Also, because connections are closed (and the closure is logged) in
56035 subprocesses, the count may not include connections that have been closed but
56036 whose termination the daemon has not yet noticed. Thus, while it is possible to
56037 match up the opening and closing of connections in the log, the value of the
56038 logged counts may not be entirely accurate.
56039 </para>
56040 </listitem>
56041 <listitem>
56042 <para>
56043 <indexterm role="concept">
56044 <primary>log</primary>
56045 <secondary>SMTP transaction; incomplete</secondary>
56046 </indexterm>
56047 <indexterm role="concept">
56048 <primary>SMTP</primary>
56049 <secondary>logging incomplete transactions</secondary>
56050 </indexterm>
56051 <option>smtp_incomplete_transaction</option>: When a mail transaction is aborted by
56052 RSET, QUIT, loss of connection, or otherwise, the incident is logged,
56053 and the message sender plus any accepted recipients are included in the log
56054 line. This can provide evidence of dictionary attacks.
56055 </para>
56056 </listitem>
56057 <listitem>
56058 <para>
56059 <indexterm role="concept">
56060 <primary>log</primary>
56061 <secondary>SMTP protocol error</secondary>
56062 </indexterm>
56063 <indexterm role="concept">
56064 <primary>SMTP</primary>
56065 <secondary>logging protocol error</secondary>
56066 </indexterm>
56067 <option>smtp_protocol_error</option>: A log line is written for every SMTP protocol error
56068 encountered. Exim does not have perfect detection of all protocol errors
56069 because of transmission delays and the use of pipelining. If PIPELINING has
56070 been advertised to a client, an Exim server assumes that the client will use
56071 it, and therefore it does not count <quote>expected</quote> errors (for example, RCPT
56072 received after rejecting MAIL) as protocol errors.
56073 </para>
56074 </listitem>
56075 <listitem>
56076 <para>
56077 <indexterm role="concept">
56078 <primary>SMTP</primary>
56079 <secondary>logging syntax errors</secondary>
56080 </indexterm>
56081 <indexterm role="concept">
56082 <primary>SMTP</primary>
56083 <secondary>syntax errors; logging</secondary>
56084 </indexterm>
56085 <indexterm role="concept">
56086 <primary>SMTP</primary>
56087 <secondary>unknown command; logging</secondary>
56088 </indexterm>
56089 <indexterm role="concept">
56090 <primary>log</primary>
56091 <secondary>unknown SMTP command</secondary>
56092 </indexterm>
56093 <indexterm role="concept">
56094 <primary>log</primary>
56095 <secondary>SMTP syntax error</secondary>
56096 </indexterm>
56097 <option>smtp_syntax_error</option>: A log line is written for every SMTP syntax error
56098 encountered. An unrecognized command is treated as a syntax error. For an
56099 external connection, the host identity is given; for an internal connection
56100 using <option>-bs</option> the sender identification (normally the calling user) is given.
56101 </para>
56102 </listitem>
56103 <listitem>
56104 <para>
56105 <indexterm role="concept">
56106 <primary>log</primary>
56107 <secondary>subject</secondary>
56108 </indexterm>
56109 <indexterm role="concept">
56110 <primary>subject</primary>
56111 <secondary>logging</secondary>
56112 </indexterm>
56113 <option>subject</option>: The subject of the message is added to the arrival log line,
56114 preceded by <quote>T=</quote> (T for <quote>topic</quote>, since S is already used for <quote>size</quote>).
56115 Any MIME <quote>words</quote> in the subject are decoded. The <option>print_topbitchars</option> option
56116 specifies whether characters with values greater than 127 should be logged
56117 unchanged, or whether they should be rendered as escape sequences.
56118 </para>
56119 </listitem>
56120 <listitem>
56121 <para>
56122 <indexterm role="concept">
56123 <primary>log</primary>
56124 <secondary>certificate verification</secondary>
56125 </indexterm>
56126 <option>tls_certificate_verified</option>: An extra item is added to &lt;= and =&gt; log lines
56127 when TLS is in use. The item is <literal>CV=yes</literal> if the peer&#x2019;s certificate was
56128 verified, and <literal>CV=no</literal> if not.
56129 </para>
56130 </listitem>
56131 <listitem>
56132 <para>
56133 <indexterm role="concept">
56134 <primary>log</primary>
56135 <secondary>TLS cipher</secondary>
56136 </indexterm>
56137 <indexterm role="concept">
56138 <primary>TLS</primary>
56139 <secondary>logging cipher</secondary>
56140 </indexterm>
56141 <option>tls_cipher</option>: When a message is sent or received over an encrypted
56142 connection, the cipher suite used is added to the log line, preceded by X=.
56143 </para>
56144 </listitem>
56145 <listitem>
56146 <para>
56147 <indexterm role="concept">
56148 <primary>log</primary>
56149 <secondary>TLS peer DN</secondary>
56150 </indexterm>
56151 <indexterm role="concept">
56152 <primary>TLS</primary>
56153 <secondary>logging peer DN</secondary>
56154 </indexterm>
56155 <option>tls_peerdn</option>: When a message is sent or received over an encrypted
56156 connection, and a certificate is supplied by the remote host, the peer DN is
56157 added to the log line, preceded by DN=.
56158 </para>
56159 </listitem>
56160 <listitem>
56161 <para>
56162 <indexterm role="concept">
56163 <primary>log</primary>
56164 <secondary>DNS failure in list</secondary>
56165 </indexterm>
56166 <option>unknown_in_list</option>: This setting causes a log entry to be written when the
56167 result of a list match is failure because a DNS lookup failed.
56168 </para>
56169 </listitem>
56170 </itemizedlist>
56171 </section>
56172 <section>
56173 <title>Message log</title>
56174 <para>
56175 <indexterm role="concept">
56176 <primary>message</primary>
56177 <secondary>log file for</secondary>
56178 </indexterm>
56179 <indexterm role="concept">
56180 <primary>log</primary>
56181 <secondary>message log; description of</secondary>
56182 </indexterm>
56183 <indexterm role="concept">
56184 <primary><filename>msglog</filename> directory</primary>
56185 </indexterm>
56186 <indexterm role="concept">
56187 <primary><option>preserve_message_logs</option></primary>
56188 </indexterm>
56189 In addition to the general log files, Exim writes a log file for each message
56190 that it handles. The names of these per-message logs are the message ids, and
56191 they are kept in the <filename>msglog</filename> sub-directory of the spool directory. Each
56192 message log contains copies of the log lines that apply to the message. This
56193 makes it easier to inspect the status of an individual message without having
56194 to search the main log. A message log is deleted when processing of the message
56195 is complete, unless <option>preserve_message_logs</option> is set, but this should be used
56196 only with great care because they can fill up your disk very quickly.
56197 </para>
56198 <para>
56199 On a heavily loaded system, it may be desirable to disable the use of
56200 per-message logs, in order to reduce disk I/O. This can be done by setting the
56201 <option>message_logs</option> option false.
56202 <indexterm role="concept" startref="IIDloggen" class="endofrange"/>
56203 </para>
56204 </section>
56205 </chapter>
56206
56207 <chapter id="CHAPutils">
56208 <title>Exim utilities</title>
56209 <para>
56210 <indexterm role="concept" id="IIDutils" class="startofrange">
56211 <primary>utilities</primary>
56212 </indexterm>
56213 A number of utility scripts and programs are supplied with Exim and are
56214 described in this chapter. There is also the Exim Monitor, which is covered in
56215 the next chapter. The utilities described here are:
56216 </para>
56217 <informaltable frame="none">
56218 <tgroup cols="4" colsep="0" rowsep="0">
56219 <colspec colwidth="2*" align="left"/>
56220 <colspec colwidth="8*" align="left"/>
56221 <colspec colwidth="30*" align="left"/>
56222 <colspec colwidth="40*" align="left"/>
56223 <tbody>
56224 <row>
56225 <entry></entry>
56226 <entry><xref linkend="SECTfinoutwha"/></entry>
56227 <entry><emphasis>exiwhat</emphasis></entry>
56228 <entry>list what Exim processes are doing</entry>
56229 </row>
56230 <row>
56231 <entry></entry>
56232 <entry><xref linkend="SECTgreptheque"/></entry>
56233 <entry><emphasis>exiqgrep</emphasis></entry>
56234 <entry>grep the queue</entry>
56235 </row>
56236 <row>
56237 <entry></entry>
56238 <entry><xref linkend="SECTsumtheque"/></entry>
56239 <entry><emphasis>exiqsumm</emphasis></entry>
56240 <entry>summarize the queue</entry>
56241 </row>
56242 <row>
56243 <entry></entry>
56244 <entry><xref linkend="SECTextspeinf"/></entry>
56245 <entry><emphasis>exigrep</emphasis></entry>
56246 <entry>search the main log</entry>
56247 </row>
56248 <row>
56249 <entry></entry>
56250 <entry><xref linkend="SECTexipick"/></entry>
56251 <entry><emphasis>exipick</emphasis></entry>
56252 <entry>select messages on various criteria</entry>
56253 </row>
56254 <row>
56255 <entry></entry>
56256 <entry><xref linkend="SECTcyclogfil"/></entry>
56257 <entry><emphasis>exicyclog</emphasis></entry>
56258 <entry>cycle (rotate) log files</entry>
56259 </row>
56260 <row>
56261 <entry></entry>
56262 <entry><xref linkend="SECTmailstat"/></entry>
56263 <entry><emphasis>eximstats</emphasis></entry>
56264 <entry>extract statistics from the log</entry>
56265 </row>
56266 <row>
56267 <entry></entry>
56268 <entry><xref linkend="SECTcheckaccess"/></entry>
56269 <entry><emphasis>exim_checkaccess</emphasis></entry>
56270 <entry>check address acceptance from given IP</entry>
56271 </row>
56272 <row>
56273 <entry></entry>
56274 <entry><xref linkend="SECTdbmbuild"/></entry>
56275 <entry><emphasis>exim_dbmbuild</emphasis></entry>
56276 <entry>build a DBM file</entry>
56277 </row>
56278 <row>
56279 <entry></entry>
56280 <entry><xref linkend="SECTfinindret"/></entry>
56281 <entry><emphasis>exinext</emphasis></entry>
56282 <entry>extract retry information</entry>
56283 </row>
56284 <row>
56285 <entry></entry>
56286 <entry><xref linkend="SECThindatmai"/></entry>
56287 <entry><emphasis>exim_dumpdb</emphasis></entry>
56288 <entry>dump a hints database</entry>
56289 </row>
56290 <row>
56291 <entry></entry>
56292 <entry><xref linkend="SECThindatmai"/></entry>
56293 <entry><emphasis>exim_tidydb</emphasis></entry>
56294 <entry>clean up a hints database</entry>
56295 </row>
56296 <row>
56297 <entry></entry>
56298 <entry><xref linkend="SECThindatmai"/></entry>
56299 <entry><emphasis>exim_fixdb</emphasis></entry>
56300 <entry>patch a hints database</entry>
56301 </row>
56302 <row>
56303 <entry></entry>
56304 <entry><xref linkend="SECTmailboxmaint"/></entry>
56305 <entry><emphasis>exim_lock</emphasis></entry>
56306 <entry>lock a mailbox file</entry>
56307 </row>
56308 </tbody>
56309 </tgroup>
56310 </informaltable>
56311 <para>
56312 Another utility that might be of use to sites with many MTAs is Tom Kistner&#x2019;s
56313 <emphasis>exilog</emphasis>. It provides log visualizations across multiple Exim servers. See
56314 <emphasis role="bold"><ulink url="http://duncanthrax.net/exilog/">http://duncanthrax.net/exilog/</ulink></emphasis> for details.
56315 </para>
56316 <section id="SECTfinoutwha">
56317 <title>Finding out what Exim processes are doing (exiwhat)</title>
56318 <para>
56319 <indexterm role="concept">
56320 <primary><emphasis>exiwhat</emphasis></primary>
56321 </indexterm>
56322 <indexterm role="concept">
56323 <primary>process</primary>
56324 <secondary>querying</secondary>
56325 </indexterm>
56326 <indexterm role="concept">
56327 <primary>SIGUSR1</primary>
56328 </indexterm>
56329 On operating systems that can restart a system call after receiving a signal
56330 (most modern OS), an Exim process responds to the SIGUSR1 signal by writing
56331 a line describing what it is doing to the file <filename>exim-process.info</filename> in the
56332 Exim spool directory. The <emphasis>exiwhat</emphasis> script sends the signal to all Exim
56333 processes it can find, having first emptied the file. It then waits for one
56334 second to allow the Exim processes to react before displaying the results. In
56335 order to run <emphasis>exiwhat</emphasis> successfully you have to have sufficient privilege to
56336 send the signal to the Exim processes, so it is normally run as root.
56337 </para>
56338 <para>
56339 <emphasis role="bold">Warning</emphasis>: This is not an efficient process. It is intended for occasional
56340 use by system administrators. It is not sensible, for example, to set up a
56341 script that sends SIGUSR1 signals to Exim processes at short intervals.
56342 </para>
56343 <para>
56344 Unfortunately, the <emphasis>ps</emphasis> command that <emphasis>exiwhat</emphasis> uses to find Exim processes
56345 varies in different operating systems. Not only are different options used,
56346 but the format of the output is different. For this reason, there are some
56347 system configuration options that configure exactly how <emphasis>exiwhat</emphasis> works. If
56348 it doesn&#x2019;t seem to be working for you, check the following compile-time
56349 options:
56350 </para>
56351 <literallayout>
56352 <literal>EXIWHAT_PS_CMD    </literal> the command for running <emphasis>ps</emphasis>
56353 <literal>EXIWHAT_PS_ARG    </literal> the argument for <emphasis>ps</emphasis>
56354 <literal>EXIWHAT_EGREP_ARG </literal> the argument for <emphasis>egrep</emphasis> to select from <emphasis>ps</emphasis> output
56355 <literal>EXIWHAT_KILL_ARG  </literal> the argument for the <emphasis>kill</emphasis> command
56356 </literallayout>
56357 <para>
56358 An example of typical output from <emphasis>exiwhat</emphasis> is
56359 </para>
56360 <literallayout class="monospaced">
56361 164 daemon: -q1h, listening on port 25
56362 10483 running queue: waiting for 0tAycK-0002ij-00 (10492)
56363 10492 delivering 0tAycK-0002ij-00 to mail.ref.example
56364   [10.19.42.42] (editor@ref.example)
56365 10592 handling incoming call from [192.168.243.242]
56366 10628 accepting a local non-SMTP message
56367 </literallayout>
56368 <para>
56369 The first number in the output line is the process number. The third line has
56370 been split here, in order to fit it on the page.
56371 </para>
56372 </section>
56373 <section id="SECTgreptheque">
56374 <title>Selective queue listing (exiqgrep)</title>
56375 <para>
56376 <indexterm role="concept">
56377 <primary><emphasis>exiqgrep</emphasis></primary>
56378 </indexterm>
56379 <indexterm role="concept">
56380 <primary>queue</primary>
56381 <secondary>grepping</secondary>
56382 </indexterm>
56383 This utility is a Perl script contributed by Matt Hubbard. It runs
56384 </para>
56385 <literallayout class="monospaced">
56386 exim -bpu
56387 </literallayout>
56388 <para>
56389 to obtain a queue listing with undelivered recipients only, and then greps the
56390 output to select messages that match given criteria. The following selection
56391 options are available:
56392 </para>
56393 <variablelist>
56394 <varlistentry>
56395 <term><emphasis role="bold">-f</emphasis>&nbsp;&lt;<emphasis>regex</emphasis>&gt;</term>
56396 <listitem>
56397 <para>
56398 Match the sender address. The field that is tested is enclosed in angle
56399 brackets, so you can test for bounce messages with
56400 </para>
56401 <literallayout class="monospaced">
56402 exiqgrep -f '^&lt;&gt;$'
56403 </literallayout>
56404 </listitem></varlistentry>
56405 <varlistentry>
56406 <term><emphasis role="bold">-r</emphasis>&nbsp;&lt;<emphasis>regex</emphasis>&gt;</term>
56407 <listitem>
56408 <para>
56409 Match a recipient address. The field that is tested is not enclosed in angle
56410 brackets.
56411 </para>
56412 </listitem></varlistentry>
56413 <varlistentry>
56414 <term><emphasis role="bold">-s</emphasis>&nbsp;&lt;<emphasis>regex</emphasis>&gt;</term>
56415 <listitem>
56416 <para>
56417 Match against the size field.
56418 </para>
56419 </listitem></varlistentry>
56420 <varlistentry>
56421 <term><emphasis role="bold">-y</emphasis>&nbsp;&lt;<emphasis>seconds</emphasis>&gt;</term>
56422 <listitem>
56423 <para>
56424 Match messages that are younger than the given time.
56425 </para>
56426 </listitem></varlistentry>
56427 <varlistentry>
56428 <term><emphasis role="bold">-o</emphasis>&nbsp;&lt;<emphasis>seconds</emphasis>&gt;</term>
56429 <listitem>
56430 <para>
56431 Match messages that are older than the given time.
56432 </para>
56433 </listitem></varlistentry>
56434 <varlistentry>
56435 <term><emphasis role="bold">-z</emphasis></term>
56436 <listitem>
56437 <para>
56438 Match only frozen messages.
56439 </para>
56440 </listitem></varlistentry>
56441 <varlistentry>
56442 <term><emphasis role="bold">-x</emphasis></term>
56443 <listitem>
56444 <para>
56445 Match only non-frozen messages.
56446 </para>
56447 </listitem></varlistentry>
56448 </variablelist>
56449 <para>
56450 The following options control the format of the output:
56451 </para>
56452 <variablelist>
56453 <varlistentry>
56454 <term><emphasis role="bold">-c</emphasis></term>
56455 <listitem>
56456 <para>
56457 Display only the count of matching messages.
56458 </para>
56459 </listitem></varlistentry>
56460 <varlistentry>
56461 <term><emphasis role="bold">-l</emphasis></term>
56462 <listitem>
56463 <para>
56464 Long format &ndash; display the full message information as output by Exim. This is
56465 the default.
56466 </para>
56467 </listitem></varlistentry>
56468 <varlistentry>
56469 <term><emphasis role="bold">-i</emphasis></term>
56470 <listitem>
56471 <para>
56472 Display message ids only.
56473 </para>
56474 </listitem></varlistentry>
56475 <varlistentry>
56476 <term><emphasis role="bold">-b</emphasis></term>
56477 <listitem>
56478 <para>
56479 Brief format &ndash; one line per message.
56480 </para>
56481 </listitem></varlistentry>
56482 <varlistentry>
56483 <term><emphasis role="bold">-R</emphasis></term>
56484 <listitem>
56485 <para>
56486 Display messages in reverse order.
56487 </para>
56488 </listitem></varlistentry>
56489 </variablelist>
56490 <para>
56491 There is one more option, <option>-h</option>, which outputs a list of options.
56492 </para>
56493 </section>
56494 <section id="SECTsumtheque">
56495 <title>Summarising the queue (exiqsumm)</title>
56496 <para>
56497 <indexterm role="concept">
56498 <primary><emphasis>exiqsumm</emphasis></primary>
56499 </indexterm>
56500 <indexterm role="concept">
56501 <primary>queue</primary>
56502 <secondary>summary</secondary>
56503 </indexterm>
56504 The <emphasis>exiqsumm</emphasis> utility is a Perl script which reads the output of <literal>exim
56505 -bp</literal> and produces a summary of the messages on the queue. Thus, you use it by
56506 running a command such as
56507 </para>
56508 <literallayout class="monospaced">
56509 exim -bp | exiqsumm
56510 </literallayout>
56511 <para>
56512 The output consists of one line for each domain that has messages waiting for
56513 it, as in the following example:
56514 </para>
56515 <literallayout class="monospaced">
56516 3   2322   74m   66m  msn.com.example
56517 </literallayout>
56518 <para>
56519 Each line lists the number of
56520 pending deliveries for a domain, their total volume, and the length of time
56521 that the oldest and the newest messages have been waiting. Note that the number
56522 of pending deliveries is greater than the number of messages when messages
56523 have more than one recipient.
56524 </para>
56525 <para>
56526 A summary line is output at the end. By default the output is sorted on the
56527 domain name, but <emphasis>exiqsumm</emphasis> has the options <option>-a</option> and <option>-c</option>, which cause
56528 the output to be sorted by oldest message and by count of messages,
56529 respectively.
56530 </para>
56531 <para>
56532 The output of <emphasis>exim -bp</emphasis> contains the original addresses in the message, so
56533 this also applies to the output from <emphasis>exiqsumm</emphasis>. No domains from addresses
56534 generated by aliasing or forwarding are included (unless the <option>one_time</option>
56535 option of the <command>redirect</command> router has been used to convert them into <quote>top
56536 level</quote> addresses).
56537 </para>
56538 </section>
56539 <section id="SECTextspeinf">
56540 <title>Extracting specific information from the log (exigrep)</title>
56541 <para>
56542 <indexterm role="concept">
56543 <primary><emphasis>exigrep</emphasis></primary>
56544 </indexterm>
56545 <indexterm role="concept">
56546 <primary>log</primary>
56547 <secondary>extracts; grepping for</secondary>
56548 </indexterm>
56549 The <emphasis>exigrep</emphasis> utility is a Perl script that searches one or more main log
56550 files for entries that match a given pattern. When it finds a match, it
56551 extracts all the log entries for the relevant message, not just those that
56552 match the pattern. Thus, <emphasis>exigrep</emphasis> can extract complete log entries for a
56553 given message, or all mail for a given user, or for a given host, for example.
56554 The input files can be in Exim log format or syslog format.
56555 </para>
56556 <para>
56557 If a matching log line is not associated with a specific message, it is always
56558 included in <emphasis>exigrep</emphasis>&#x2019;s output. The usage is:
56559 </para>
56560 <literallayout>
56561 <literal>exigrep [-l] [-t&lt;</literal><emphasis>n</emphasis><literal>&gt;] &lt;</literal><emphasis>pattern</emphasis><literal>&gt; [&lt;</literal><emphasis>log file</emphasis><literal>&gt;] ...</literal>
56562 </literallayout>
56563 <para>
56564 The <option>-t</option> argument specifies a number of seconds. It adds an additional
56565 condition for message selection. Messages that are complete are shown only if
56566 they spent more than &lt;<emphasis>n</emphasis>&gt; seconds on the queue.
56567 </para>
56568 <para>
56569 The <option>-l</option> flag means <quote>literal</quote>, that is, treat all characters in the
56570 pattern as standing for themselves. Otherwise the pattern must be a Perl
56571 regular expression. The pattern match is case-insensitive. If no file names are
56572 given on the command line, the standard input is read.
56573 </para>
56574 <para>
56575 If the location of a <emphasis>zcat</emphasis> command is known from the definition of
56576 ZCAT_COMMAND in <filename>Local/Makefile</filename>, <emphasis>exigrep</emphasis> automatically passes any file
56577 whose name ends in COMPRESS_SUFFIX through <emphasis>zcat</emphasis> as it searches it.
56578 </para>
56579 </section>
56580 <section id="SECTexipick">
56581 <title>Selecting messages by various criteria (exipick)</title>
56582 <para>
56583 <indexterm role="concept">
56584 <primary><emphasis>exipick</emphasis></primary>
56585 </indexterm>
56586 John Jetmore&#x2019;s <emphasis>exipick</emphasis> utility is included in the Exim distribution. It
56587 lists messages from the queue according to a variety of criteria. For details,
56588 run:
56589 </para>
56590 <literallayout class="monospaced">
56591 exipick --help
56592 </literallayout>
56593 </section>
56594 <section id="SECTcyclogfil">
56595 <title>Cycling log files (exicyclog)</title>
56596 <para revisionflag="changed">
56597 <indexterm role="concept">
56598 <primary>log</primary>
56599 <secondary>cycling local files</secondary>
56600 </indexterm>
56601 <indexterm role="concept">
56602 <primary>cycling logs</primary>
56603 </indexterm>
56604 <indexterm role="concept">
56605 <primary><emphasis>exicyclog</emphasis></primary>
56606 </indexterm>
56607 The <emphasis>exicyclog</emphasis> script can be used to cycle (rotate) <emphasis>mainlog</emphasis> and
56608 <emphasis>rejectlog</emphasis> files. This is not necessary if only syslog is being used, or if
56609 you are using log files with datestamps in their names (see section
56610 <xref linkend="SECTdatlogfil"/>). Some operating systems have their own standard mechanisms
56611 for log cycling, and these can be used instead of <emphasis>exicyclog</emphasis> if preferred.
56612 There are two command line options for <emphasis>exicyclog</emphasis>:
56613 </para>
56614 <itemizedlist revisionflag="changed">
56615 <listitem>
56616 <para revisionflag="changed">
56617 <option>-k</option> &lt;<emphasis>count</emphasis>&gt; specifies the number of log files to keep, overriding the
56618 default that is set when Exim is built. The default default is 10.
56619 </para>
56620 </listitem>
56621 <listitem>
56622 <para revisionflag="changed">
56623 <option>-l</option> &lt;<emphasis>path</emphasis>&gt; specifies the log file path, in the same format as Exim&#x2019;s
56624 <option>log_file_path</option> option (for example, <literal>/var/log/exim_%slog</literal>), again
56625 overriding the script&#x2019;s default, which is to find the setting from Exim&#x2019;s
56626 configuration.
56627 </para>
56628 </listitem>
56629 </itemizedlist>
56630 <para revisionflag="changed">
56631 Each time <emphasis>exicyclog</emphasis> is run the file names get <quote>shuffled down</quote> by one. If
56632 the main log file name is <filename>mainlog</filename> (the default) then when <emphasis>exicyclog</emphasis> is
56633 run <filename>mainlog</filename> becomes <filename>mainlog.01</filename>, the previous <filename>mainlog.01</filename> becomes
56634 <filename>mainlog.02</filename> and so on, up to the limit that is set in the script or by the
56635 <option>-k</option> option. Log files whose numbers exceed the limit are discarded. Reject
56636 logs are handled similarly.
56637 </para>
56638 <para>
56639 If the limit is greater than 99, the script uses 3-digit numbers such as
56640 <filename>mainlog.001</filename>, <filename>mainlog.002</filename>, etc. If you change from a number less than 99
56641 to one that is greater, or <emphasis>vice versa</emphasis>, you will have to fix the names of
56642 any existing log files.
56643 </para>
56644 <para>
56645 If no <filename>mainlog</filename> file exists, the script does nothing. Files that <quote>drop off</quote>
56646 the end are deleted. All files with numbers greater than 01 are compressed,
56647 using a compression command which is configured by the COMPRESS_COMMAND
56648 setting in <filename>Local/Makefile</filename>. It is usual to run <emphasis>exicyclog</emphasis> daily from a
56649 root <option>crontab</option> entry of the form
56650 </para>
56651 <literallayout class="monospaced">
56652 1 0 * * * su exim -c /usr/exim/bin/exicyclog
56653 </literallayout>
56654 <para>
56655 assuming you have used the name <quote>exim</quote> for the Exim user. You can run
56656 <emphasis>exicyclog</emphasis> as root if you wish, but there is no need.
56657 </para>
56658 </section>
56659 <section id="SECTmailstat">
56660 <title>Mail statistics (eximstats)</title>
56661 <para>
56662 <indexterm role="concept">
56663 <primary>statistics</primary>
56664 </indexterm>
56665 <indexterm role="concept">
56666 <primary><emphasis>eximstats</emphasis></primary>
56667 </indexterm>
56668 A Perl script called <emphasis>eximstats</emphasis> is provided for extracting statistical
56669 information from log files. The output is either plain text, or HTML.
56670 Exim log files are also suported by the <emphasis>Lire</emphasis> system produced by the
56671 LogReport Foundation <emphasis role="bold"><ulink url="http://www.logreport.org">http://www.logreport.org</ulink></emphasis>.
56672 </para>
56673 <para>
56674 The <emphasis>eximstats</emphasis> script has been hacked about quite a bit over time. The
56675 latest version is the result of some extensive revision by Steve Campbell. A
56676 lot of information is given by default, but there are options for suppressing
56677 various parts of it. Following any options, the arguments to the script are a
56678 list of files, which should be main log files. For example:
56679 </para>
56680 <literallayout class="monospaced">
56681 eximstats -nr /var/spool/exim/log/mainlog.01
56682 </literallayout>
56683 <para>
56684 By default, <emphasis>eximstats</emphasis> extracts information about the number and volume of
56685 messages received from or delivered to various hosts. The information is sorted
56686 both by message count and by volume, and the top fifty hosts in each category
56687 are listed on the standard output. Similar information, based on email
56688 addresses or domains instead of hosts can be requested by means of various
56689 options. For messages delivered and received locally, similar statistics are
56690 also produced per user.
56691 </para>
56692 <para>
56693 The output also includes total counts and statistics about delivery errors, and
56694 histograms showing the number of messages received and deliveries made in each
56695 hour of the day. A delivery with more than one address in its envelope (for
56696 example, an SMTP transaction with more than one RCPT command) is counted
56697 as a single delivery by <emphasis>eximstats</emphasis>.
56698 </para>
56699 <para>
56700 Though normally more deliveries than receipts are reported (as messages may
56701 have multiple recipients), it is possible for <emphasis>eximstats</emphasis> to report more
56702 messages received than delivered, even though the queue is empty at the start
56703 and end of the period in question. If an incoming message contains no valid
56704 recipients, no deliveries are recorded for it. A bounce message is handled as
56705 an entirely separate message.
56706 </para>
56707 <para>
56708 <emphasis>eximstats</emphasis> always outputs a grand total summary giving the volume and number
56709 of messages received and deliveries made, and the number of hosts involved in
56710 each case. It also outputs the number of messages that were delayed (that is,
56711 not completely delivered at the first attempt), and the number that had at
56712 least one address that failed.
56713 </para>
56714 <para>
56715 The remainder of the output is in sections that can be independently disabled
56716 or modified by various options. It consists of a summary of deliveries by
56717 transport, histograms of messages received and delivered per time interval
56718 (default per hour), information about the time messages spent on the queue,
56719 a list of relayed messages, lists of the top fifty sending hosts, local
56720 senders, destination hosts, and destination local users by count and by volume,
56721 and a list of delivery errors that occurred.
56722 </para>
56723 <para>
56724 The relay information lists messages that were actually relayed, that is, they
56725 came from a remote host and were directly delivered to some other remote host,
56726 without being processed (for example, for aliasing or forwarding) locally.
56727 </para>
56728 <para>
56729 There are quite a few options for <emphasis>eximstats</emphasis> to control exactly what it
56730 outputs. These are documented in the Perl script itself, and can be extracted
56731 by running the command <command>perldoc</command> on the script. For example:
56732 </para>
56733 <literallayout class="monospaced">
56734 perldoc /usr/exim/bin/eximstats
56735 </literallayout>
56736 </section>
56737 <section id="SECTcheckaccess">
56738 <title>Checking access policy (exim_checkaccess)</title>
56739 <para>
56740 <indexterm role="concept">
56741 <primary><emphasis>exim_checkaccess</emphasis></primary>
56742 </indexterm>
56743 <indexterm role="concept">
56744 <primary>policy control</primary>
56745 <secondary>checking access</secondary>
56746 </indexterm>
56747 <indexterm role="concept">
56748 <primary>checking access</primary>
56749 </indexterm>
56750 The <option>-bh</option> command line argument allows you to run a fake SMTP session with
56751 debugging output, in order to check what Exim is doing when it is applying
56752 policy controls to incoming SMTP mail. However, not everybody is sufficiently
56753 familiar with the SMTP protocol to be able to make full use of <option>-bh</option>, and
56754 sometimes you just want to answer the question <quote>Does this address have
56755 access?</quote> without bothering with any further details.
56756 </para>
56757 <para>
56758 The <emphasis>exim_checkaccess</emphasis> utility is a <quote>packaged</quote> version of <option>-bh</option>. It takes
56759 two arguments, an IP address and an email address:
56760 </para>
56761 <literallayout class="monospaced">
56762 exim_checkaccess 10.9.8.7 A.User@a.domain.example
56763 </literallayout>
56764 <para>
56765 The utility runs a call to Exim with the <option>-bh</option> option, to test whether the
56766 given email address would be accepted in a RCPT command in a TCP/IP
56767 connection from the host with the given IP address. The output of the utility
56768 is either the word <quote>accepted</quote>, or the SMTP error response, for example:
56769 </para>
56770 <literallayout class="monospaced">
56771 Rejected:
56772 550 Relay not permitted
56773 </literallayout>
56774 <para>
56775 When running this test, the utility uses <literal>&lt;&gt;</literal> as the envelope sender address
56776 for the MAIL command, but you can change this by providing additional
56777 options. These are passed directly to the Exim command. For example, to specify
56778 that the test is to be run with the sender address <emphasis>himself@there.example</emphasis>
56779 you can use:
56780 </para>
56781 <literallayout class="monospaced">
56782 exim_checkaccess 10.9.8.7 A.User@a.domain.example \
56783                  -f himself@there.example
56784 </literallayout>
56785 <para>
56786 Note that these additional Exim command line items must be given after the two
56787 mandatory arguments.
56788 </para>
56789 <para>
56790 Because the <option>exim_checkaccess</option> uses <option>-bh</option>, it does not perform callouts
56791 while running its checks. You can run checks that include callouts by using
56792 <option>-bhc</option>, but this is not yet available in a <quote>packaged</quote> form.
56793 </para>
56794 </section>
56795 <section id="SECTdbmbuild">
56796 <title>Making DBM files (exim_dbmbuild)</title>
56797 <para>
56798 <indexterm role="concept">
56799 <primary>DBM</primary>
56800 <secondary>building dbm files</secondary>
56801 </indexterm>
56802 <indexterm role="concept">
56803 <primary>building DBM files</primary>
56804 </indexterm>
56805 <indexterm role="concept">
56806 <primary><emphasis>exim_dbmbuild</emphasis></primary>
56807 </indexterm>
56808 <indexterm role="concept">
56809 <primary>lower casing</primary>
56810 </indexterm>
56811 <indexterm role="concept">
56812 <primary>binary zero</primary>
56813 <secondary>in lookup key</secondary>
56814 </indexterm>
56815 The <emphasis>exim_dbmbuild</emphasis> program reads an input file containing keys and data in
56816 the format used by the <command>lsearch</command> lookup (see section
56817 <xref linkend="SECTsinglekeylookups"/>). It writes a DBM file using the lower-cased alias
56818 names as keys and the remainder of the information as data. The lower-casing
56819 can be prevented by calling the program with the <option>-nolc</option> option.
56820 </para>
56821 <para>
56822 A terminating zero is included as part of the key string. This is expected by
56823 the <command>dbm</command> lookup type. However, if the option <option>-nozero</option> is given,
56824 <emphasis>exim_dbmbuild</emphasis> creates files without terminating zeroes in either the key
56825 strings or the data strings. The <command>dbmnz</command> lookup type can be used with such
56826 files.
56827 </para>
56828 <para>
56829 The program requires two arguments: the name of the input file (which can be a
56830 single hyphen to indicate the standard input), and the name of the output file.
56831 It creates the output under a temporary name, and then renames it if all went
56832 well.
56833 </para>
56834 <para>
56835 <indexterm role="concept">
56836 <primary>USE_DB</primary>
56837 </indexterm>
56838 If the native DB interface is in use (USE_DB is set in a compile-time
56839 configuration file &ndash; this is common in free versions of Unix) the two file
56840 names must be different, because in this mode the Berkeley DB functions create
56841 a single output file using exactly the name given. For example,
56842 </para>
56843 <literallayout class="monospaced">
56844 exim_dbmbuild /etc/aliases /etc/aliases.db
56845 </literallayout>
56846 <para>
56847 reads the system alias file and creates a DBM version of it in
56848 <filename>/etc/aliases.db</filename>.
56849 </para>
56850 <para>
56851 In systems that use the <emphasis>ndbm</emphasis> routines (mostly proprietary versions of
56852 Unix), two files are used, with the suffixes <filename>.dir</filename> and <filename>.pag</filename>. In this
56853 environment, the suffixes are added to the second argument of
56854 <emphasis>exim_dbmbuild</emphasis>, so it can be the same as the first. This is also the case
56855 when the Berkeley functions are used in compatibility mode (though this is not
56856 recommended), because in that case it adds a <filename>.db</filename> suffix to the file name.
56857 </para>
56858 <para>
56859 If a duplicate key is encountered, the program outputs a warning, and when it
56860 finishes, its return code is 1 rather than zero, unless the <option>-noduperr</option>
56861 option is used. By default, only the first of a set of duplicates is used &ndash;
56862 this makes it compatible with <command>lsearch</command> lookups. There is an option
56863 <option>-lastdup</option> which causes it to use the data for the last duplicate instead.
56864 There is also an option <option>-nowarn</option>, which stops it listing duplicate keys to
56865 <option>stderr</option>. For other errors, where it doesn&#x2019;t actually make a new file, the
56866 return code is 2.
56867 </para>
56868 </section>
56869 <section id="SECTfinindret">
56870 <title>Finding individual retry times (exinext)</title>
56871 <para>
56872 <indexterm role="concept">
56873 <primary>retry</primary>
56874 <secondary>times</secondary>
56875 </indexterm>
56876 <indexterm role="concept">
56877 <primary><emphasis>exinext</emphasis></primary>
56878 </indexterm>
56879 A utility called <emphasis>exinext</emphasis> (mostly a Perl script) provides the ability to
56880 fish specific information out of the retry database. Given a mail domain (or a
56881 complete address), it looks up the hosts for that domain, and outputs any retry
56882 information for the hosts or for the domain. At present, the retry information
56883 is obtained by running <emphasis>exim_dumpdb</emphasis> (see below) and post-processing the
56884 output. For example:
56885 </para>
56886 <literallayout class="monospaced">
56887 $ exinext piglet@milne.fict.example
56888 kanga.milne.example:192.168.8.1 error 146: Connection refused
56889   first failed: 21-Feb-1996 14:57:34
56890   last tried:   21-Feb-1996 14:57:34
56891   next try at:  21-Feb-1996 15:02:34
56892 roo.milne.example:192.168.8.3 error 146: Connection refused
56893   first failed: 20-Jan-1996 13:12:08
56894   last tried:   21-Feb-1996 11:42:03
56895   next try at:  21-Feb-1996 19:42:03
56896   past final cutoff time
56897 </literallayout>
56898 <para>
56899 You can also give <emphasis>exinext</emphasis> a local part, without a domain, and it
56900 will give any retry information for that local part in your default domain.
56901 A message id can be used to obtain retry information pertaining to a specific
56902 message. This exists only when an attempt to deliver a message to a remote host
56903 suffers a message-specific error (see section <xref linkend="SECToutSMTPerr"/>).
56904 <emphasis>exinext</emphasis> is not particularly efficient, but then it is not expected to be
56905 run very often.
56906 </para>
56907 <para>
56908 The <emphasis>exinext</emphasis> utility calls Exim to find out information such as the location
56909 of the spool directory. The utility has <option>-C</option> and <option>-D</option> options, which are
56910 passed on to the <emphasis>exim</emphasis> commands. The first specifies an alternate Exim
56911 configuration file, and the second sets macros for use within the configuration
56912 file. These features are mainly to help in testing, but might also be useful in
56913 environments where more than one configuration file is in use.
56914 </para>
56915 </section>
56916 <section id="SECThindatmai">
56917 <title>Hints database maintenance</title>
56918 <para>
56919 <indexterm role="concept">
56920 <primary>hints database</primary>
56921 <secondary>maintenance</secondary>
56922 </indexterm>
56923 <indexterm role="concept">
56924 <primary>maintaining Exim&#x2019;s hints database</primary>
56925 </indexterm>
56926 Three utility programs are provided for maintaining the DBM files that Exim
56927 uses to contain its delivery hint information. Each program requires two
56928 arguments. The first specifies the name of Exim&#x2019;s spool directory, and the
56929 second is the name of the database it is to operate on. These are as follows:
56930 </para>
56931 <itemizedlist>
56932 <listitem>
56933 <para>
56934 <emphasis>retry</emphasis>: the database of retry information
56935 </para>
56936 </listitem>
56937 <listitem>
56938 <para>
56939 <emphasis>wait-</emphasis>&lt;<emphasis>transport name</emphasis>&gt;: databases of information about messages waiting
56940 for remote hosts
56941 </para>
56942 </listitem>
56943 <listitem>
56944 <para>
56945 <emphasis>callout</emphasis>: the callout cache
56946 </para>
56947 </listitem>
56948 <listitem>
56949 <para>
56950 <emphasis>ratelimit</emphasis>: the data for implementing the ratelimit ACL condition
56951 </para>
56952 </listitem>
56953 <listitem>
56954 <para>
56955 <emphasis>misc</emphasis>: other hints data
56956 </para>
56957 </listitem>
56958 </itemizedlist>
56959 <para>
56960 The <emphasis>misc</emphasis> database is used for
56961 </para>
56962 <itemizedlist>
56963 <listitem>
56964 <para>
56965 Serializing ETRN runs (when <option>smtp_etrn_serialize</option> is set)
56966 </para>
56967 </listitem>
56968 <listitem>
56969 <para>
56970 Serializing delivery to a specific host (when <option>serialize_hosts</option> is set in an
56971 <command>smtp</command> transport)
56972 </para>
56973 </listitem>
56974 </itemizedlist>
56975 </section>
56976 <section>
56977 <title>exim_dumpdb</title>
56978 <para>
56979 <indexterm role="concept">
56980 <primary><emphasis>exim_dumpdb</emphasis></primary>
56981 </indexterm>
56982 The entire contents of a database are written to the standard output by the
56983 <emphasis>exim_dumpdb</emphasis> program, which has no options or arguments other than the
56984 spool and database names. For example, to dump the retry database:
56985 </para>
56986 <literallayout class="monospaced">
56987 exim_dumpdb /var/spool/exim retry
56988 </literallayout>
56989 <para>
56990 Two lines of output are produced for each entry:
56991 </para>
56992 <literallayout class="monospaced">
56993 T:mail.ref.example:192.168.242.242 146 77 Connection refused
56994 31-Oct-1995 12:00:12 02-Nov-1995 12:21:39 02-Nov-1995 20:21:39 *
56995 </literallayout>
56996 <para>
56997 The first item on the first line is the key of the record. It starts with one
56998 of the letters R, or T, depending on whether it refers to a routing or
56999 transport retry. For a local delivery, the next part is the local address; for
57000 a remote delivery it is the name of the remote host, followed by its failing IP
57001 address (unless <option>no_retry_include_ip_address</option> is set on the <command>smtp</command>
57002 transport). If the remote port is not the standard one (port 25), it is added
57003 to the IP address. Then there follows an error code, an additional error code,
57004 and a textual description of the error.
57005 </para>
57006 <para>
57007 The three times on the second line are the time of first failure, the time of
57008 the last delivery attempt, and the computed time for the next attempt. The line
57009 ends with an asterisk if the cutoff time for the last retry rule has been
57010 exceeded.
57011 </para>
57012 <para>
57013 Each output line from <emphasis>exim_dumpdb</emphasis> for the <emphasis>wait-xxx</emphasis> databases
57014 consists of a host name followed by a list of ids for messages that are or were
57015 waiting to be delivered to that host. If there are a very large number for any
57016 one host, continuation records, with a sequence number added to the host name,
57017 may be seen. The data in these records is often out of date, because a message
57018 may be routed to several alternative hosts, and Exim makes no effort to keep
57019 cross-references.
57020 </para>
57021 </section>
57022 <section>
57023 <title>exim_tidydb</title>
57024 <para>
57025 <indexterm role="concept">
57026 <primary><emphasis>exim_tidydb</emphasis></primary>
57027 </indexterm>
57028 The <emphasis>exim_tidydb</emphasis> utility program is used to tidy up the contents of a hints
57029 database. If run with no options, it removes all records that are more than 30
57030 days old. The age is calculated from the date and time that the record was last
57031 updated. Note that, in the case of the retry database, it is <emphasis>not</emphasis> the time
57032 since the first delivery failure. Information about a host that has been down
57033 for more than 30 days will remain in the database, provided that the record is
57034 updated sufficiently often.
57035 </para>
57036 <para>
57037 The cutoff date can be altered by means of the <option>-t</option> option, which must be
57038 followed by a time. For example, to remove all records older than a week from
57039 the retry database:
57040 </para>
57041 <literallayout class="monospaced">
57042 exim_tidydb -t 7d /var/spool/exim retry
57043 </literallayout>
57044 <para>
57045 Both the <emphasis>wait-xxx</emphasis> and <emphasis>retry</emphasis> databases contain items that involve
57046 message ids. In the former these appear as data in records keyed by host &ndash;
57047 they were messages that were waiting for that host &ndash; and in the latter they
57048 are the keys for retry information for messages that have suffered certain
57049 types of error. When <emphasis>exim_tidydb</emphasis> is run, a check is made to ensure that
57050 message ids in database records are those of messages that are still on the
57051 queue. Message ids for messages that no longer exist are removed from
57052 <emphasis>wait-xxx</emphasis> records, and if this leaves any records empty, they are deleted.
57053 For the <emphasis>retry</emphasis> database, records whose keys are non-existent message ids are
57054 removed. The <emphasis>exim_tidydb</emphasis> utility outputs comments on the standard output
57055 whenever it removes information from the database.
57056 </para>
57057 <para>
57058 Certain records are automatically removed by Exim when they are no longer
57059 needed, but others are not. For example, if all the MX hosts for a domain are
57060 down, a retry record is created for each one. If the primary MX host comes back
57061 first, its record is removed when Exim successfully delivers to it, but the
57062 records for the others remain because Exim has not tried to use those hosts.
57063 </para>
57064 <para>
57065 It is important, therefore, to run <emphasis>exim_tidydb</emphasis> periodically on all the
57066 hints databases. You should do this at a quiet time of day, because it requires
57067 a database to be locked (and therefore inaccessible to Exim) while it does its
57068 work. Removing records from a DBM file does not normally make the file smaller,
57069 but all the common DBM libraries are able to re-use the space that is released.
57070 After an initial phase of increasing in size, the databases normally reach a
57071 point at which they no longer get any bigger, as long as they are regularly
57072 tidied.
57073 </para>
57074 <para>
57075 <emphasis role="bold">Warning</emphasis>: If you never run <emphasis>exim_tidydb</emphasis>, the space used by the hints
57076 databases is likely to keep on increasing.
57077 </para>
57078 </section>
57079 <section>
57080 <title>exim_fixdb</title>
57081 <para>
57082 <indexterm role="concept">
57083 <primary><emphasis>exim_fixdb</emphasis></primary>
57084 </indexterm>
57085 The <emphasis>exim_fixdb</emphasis> program is a utility for interactively modifying databases.
57086 Its main use is for testing Exim, but it might also be occasionally useful for
57087 getting round problems in a live system. It has no options, and its interface
57088 is somewhat crude. On entry, it prompts for input with a right angle-bracket. A
57089 key of a database record can then be entered, and the data for that record is
57090 displayed.
57091 </para>
57092 <para>
57093 If <quote>d</quote> is typed at the next prompt, the entire record is deleted. For all
57094 except the <emphasis>retry</emphasis> database, that is the only operation that can be carried
57095 out. For the <emphasis>retry</emphasis> database, each field is output preceded by a number, and
57096 data for individual fields can be changed by typing the field number followed
57097 by new data, for example:
57098 </para>
57099 <literallayout class="monospaced">
57100 &gt; 4 951102:1000
57101 </literallayout>
57102 <para>
57103 resets the time of the next delivery attempt. Time values are given as a
57104 sequence of digit pairs for year, month, day, hour, and minute. Colons can be
57105 used as optional separators.
57106 </para>
57107 </section>
57108 <section id="SECTmailboxmaint">
57109 <title>Mailbox maintenance (exim_lock)</title>
57110 <para>
57111 <indexterm role="concept">
57112 <primary>mailbox</primary>
57113 <secondary>maintenance</secondary>
57114 </indexterm>
57115 <indexterm role="concept">
57116 <primary><emphasis>exim_lock</emphasis></primary>
57117 </indexterm>
57118 <indexterm role="concept">
57119 <primary>locking mailboxes</primary>
57120 </indexterm>
57121 The <emphasis>exim_lock</emphasis> utility locks a mailbox file using the same algorithm as
57122 Exim. For a discussion of locking issues, see section <xref linkend="SECTopappend"/>.
57123 <emphasis>Exim_lock</emphasis> can be used to prevent any modification of a mailbox by Exim or
57124 a user agent while investigating a problem. The utility requires the name of
57125 the file as its first argument. If the locking is successful, the second
57126 argument is run as a command (using C&#x2019;s <function>system()</function> function); if there is no
57127 second argument, the value of the SHELL environment variable is used; if this
57128 is unset or empty, <filename>/bin/sh</filename> is run. When the command finishes, the mailbox
57129 is unlocked and the utility ends. The following options are available:
57130 </para>
57131 <variablelist>
57132 <varlistentry>
57133 <term><option>-fcntl</option></term>
57134 <listitem>
57135 <para>
57136 Use <function>fcntl()</function> locking on the open mailbox.
57137 </para>
57138 </listitem></varlistentry>
57139 <varlistentry>
57140 <term><option>-flock</option></term>
57141 <listitem>
57142 <para>
57143 Use <function>flock()</function> locking on the open mailbox, provided the operating system
57144 supports it.
57145 </para>
57146 </listitem></varlistentry>
57147 <varlistentry>
57148 <term><option>-interval</option></term>
57149 <listitem>
57150 <para>
57151 This must be followed by a number, which is a number of seconds; it sets the
57152 interval to sleep between retries (default 3).
57153 </para>
57154 </listitem></varlistentry>
57155 <varlistentry>
57156 <term><option>-lockfile</option></term>
57157 <listitem>
57158 <para>
57159 Create a lock file before opening the mailbox.
57160 </para>
57161 </listitem></varlistentry>
57162 <varlistentry>
57163 <term><option>-mbx</option></term>
57164 <listitem>
57165 <para>
57166 Lock the mailbox using MBX rules.
57167 </para>
57168 </listitem></varlistentry>
57169 <varlistentry>
57170 <term><option>-q</option></term>
57171 <listitem>
57172 <para>
57173 Suppress verification output.
57174 </para>
57175 </listitem></varlistentry>
57176 <varlistentry>
57177 <term><option>-retries</option></term>
57178 <listitem>
57179 <para>
57180 This must be followed by a number; it sets the number of times to try to get
57181 the lock (default 10).
57182 </para>
57183 </listitem></varlistentry>
57184 <varlistentry>
57185 <term><option>-restore_time</option></term>
57186 <listitem>
57187 <para>
57188 This option causes <option>exim_lock</option> to restore the modified and read times to the
57189 locked file before exiting. This allows you to access a locked mailbox (for
57190 example, to take a backup copy) without disturbing the times that the user
57191 subsequently sees.
57192 </para>
57193 </listitem></varlistentry>
57194 <varlistentry>
57195 <term><option>-timeout</option></term>
57196 <listitem>
57197 <para>
57198 This must be followed by a number, which is a number of seconds; it sets a
57199 timeout to be used with a blocking <function>fcntl()</function> lock. If it is not set (the
57200 default), a non-blocking call is used.
57201 </para>
57202 </listitem></varlistentry>
57203 <varlistentry>
57204 <term><option>-v</option></term>
57205 <listitem>
57206 <para>
57207 Generate verbose output.
57208 </para>
57209 </listitem></varlistentry>
57210 </variablelist>
57211 <para>
57212 If none of <option>-fcntl</option>, <option>-flock</option>, <option>-lockfile</option> or <option>-mbx</option> are given, the
57213 default is to create a lock file and also to use <function>fcntl()</function> locking on the
57214 mailbox, which is the same as Exim&#x2019;s default. The use of <option>-flock</option> or
57215 <option>-fcntl</option> requires that the file be writeable; the use of <option>-lockfile</option>
57216 requires that the directory containing the file be writeable. Locking by lock
57217 file does not last for ever; Exim assumes that a lock file is expired if it is
57218 more than 30 minutes old.
57219 </para>
57220 <para>
57221 The <option>-mbx</option> option can be used with either or both of <option>-fcntl</option> or
57222 <option>-flock</option>. It assumes <option>-fcntl</option> by default. MBX locking causes a shared lock
57223 to be taken out on the open mailbox, and an exclusive lock on the file
57224 <filename>/tmp/.n.m</filename> where <emphasis>n</emphasis> and <emphasis>m</emphasis> are the device number and inode
57225 number of the mailbox file. When the locking is released, if an exclusive lock
57226 can be obtained for the mailbox, the file in <filename>/tmp</filename> is deleted.
57227 </para>
57228 <para>
57229 The default output contains verification of the locking that takes place. The
57230 <option>-v</option> option causes some additional information to be given. The <option>-q</option> option
57231 suppresses all output except error messages.
57232 </para>
57233 <para>
57234 A command such as
57235 </para>
57236 <literallayout class="monospaced">
57237 exim_lock /var/spool/mail/spqr
57238 </literallayout>
57239 <para>
57240 runs an interactive shell while the file is locked, whereas
57241 </para>
57242 <literallayout>
57243 <literal>exim_lock -q /var/spool/mail/spqr &lt;&lt;End</literal>
57244 &lt;<emphasis>some commands</emphasis>&gt;
57245 <literal>End</literal>
57246 </literallayout>
57247 <para>
57248 runs a specific non-interactive sequence of commands while the file is locked,
57249 suppressing all verification output. A single command can be run by a command
57250 such as
57251 </para>
57252 <literallayout class="monospaced">
57253 exim_lock -q /var/spool/mail/spqr \
57254   "cp /var/spool/mail/spqr /some/where"
57255 </literallayout>
57256 <para>
57257 Note that if a command is supplied, it must be entirely contained within the
57258 second argument &ndash; hence the quotes.
57259 <indexterm role="concept" startref="IIDutils" class="endofrange"/>
57260 </para>
57261 </section>
57262 </chapter>
57263
57264 <chapter id="CHAPeximon">
57265 <title>The Exim monitor</title>
57266 <para>
57267 <indexterm role="concept" id="IIDeximon" class="startofrange">
57268 <primary>Exim monitor</primary>
57269 <secondary>description</secondary>
57270 </indexterm>
57271 <indexterm role="concept">
57272 <primary>X-windows</primary>
57273 </indexterm>
57274 <indexterm role="concept">
57275 <primary><emphasis>eximon</emphasis></primary>
57276 </indexterm>
57277 <indexterm role="concept">
57278 <primary>Local/eximon.conf</primary>
57279 </indexterm>
57280 <indexterm role="concept">
57281 <primary>_exim_monitor/EDITME_</primary>
57282 </indexterm>
57283 The Exim monitor is an application which displays in an X window information
57284 about the state of Exim&#x2019;s queue and what Exim is doing. An admin user can
57285 perform certain operations on messages from this GUI interface; however all
57286 such facilities are also available from the command line, and indeed, the
57287 monitor itself makes use of the command line to perform any actions requested.
57288 </para>
57289 <section>
57290 <title>Running the monitor</title>
57291 <para>
57292 The monitor is started by running the script called <emphasis>eximon</emphasis>. This is a shell
57293 script that sets up a number of environment variables, and then runs the
57294 binary called <filename>eximon.bin</filename>. The default appearance of the monitor window can
57295 be changed by editing the <filename>Local/eximon.conf</filename> file created by editing
57296 <filename>exim_monitor/EDITME</filename>. Comments in that file describe what the various
57297 parameters are for.
57298 </para>
57299 <para>
57300 The parameters that get built into the <emphasis>eximon</emphasis> script can be overridden for
57301 a particular invocation by setting up environment variables of the same names,
57302 preceded by <literal>EXIMON_</literal>. For example, a shell command such as
57303 </para>
57304 <literallayout class="monospaced">
57305 EXIMON_LOG_DEPTH=400 eximon
57306 </literallayout>
57307 <para>
57308 (in a Bourne-compatible shell) runs <emphasis>eximon</emphasis> with an overriding setting of
57309 the LOG_DEPTH parameter. If EXIMON_LOG_FILE_PATH is set in the environment, it
57310 overrides the Exim log file configuration. This makes it possible to have
57311 <emphasis>eximon</emphasis> tailing log data that is written to syslog, provided that MAIL.INFO
57312 syslog messages are routed to a file on the local host.
57313 </para>
57314 <para>
57315 X resources can be used to change the appearance of the window in the normal
57316 way. For example, a resource setting of the form
57317 </para>
57318 <literallayout class="monospaced">
57319 Eximon*background: gray94
57320 </literallayout>
57321 <para>
57322 changes the colour of the background to light grey rather than white. The
57323 stripcharts are drawn with both the data lines and the reference lines in
57324 black. This means that the reference lines are not visible when on top of the
57325 data. However, their colour can be changed by setting a resource called
57326 <quote>highlight</quote> (an odd name, but that&#x2019;s what the Athena stripchart widget uses).
57327 For example, if your X server is running Unix, you could set up lighter
57328 reference lines in the stripcharts by obeying
57329 </para>
57330 <literallayout class="monospaced">
57331 xrdb -merge &lt;&lt;End
57332 Eximon*highlight: gray
57333 End
57334 </literallayout>
57335 <para>
57336 <indexterm role="concept">
57337 <primary>admin user</primary>
57338 </indexterm>
57339 In order to see the contents of messages on the queue, and to operate on them,
57340 <emphasis>eximon</emphasis> must either be run as root or by an admin user.
57341 </para>
57342 <para>
57343 The monitor&#x2019;s window is divided into three parts. The first contains one or
57344 more stripcharts and two action buttons, the second contains a <quote>tail</quote> of the
57345 main log file, and the third is a display of the queue of messages awaiting
57346 delivery, with two more action buttons. The following sections describe these
57347 different parts of the display.
57348 </para>
57349 </section>
57350 <section>
57351 <title>The stripcharts</title>
57352 <para>
57353 <indexterm role="concept">
57354 <primary>stripchart</primary>
57355 </indexterm>
57356 The first stripchart is always a count of messages on the queue. Its name can
57357 be configured by setting QUEUE_STRIPCHART_NAME in the
57358 <filename>Local/eximon.conf</filename> file. The remaining stripcharts are defined in the
57359 configuration script by regular expression matches on log file entries, making
57360 it possible to display, for example, counts of messages delivered to certain
57361 hosts or using certain transports. The supplied defaults display counts of
57362 received and delivered messages, and of local and SMTP deliveries. The default
57363 period between stripchart updates is one minute; this can be adjusted by a
57364 parameter in the <filename>Local/eximon.conf</filename> file.
57365 </para>
57366 <para>
57367 The stripchart displays rescale themselves automatically as the value they are
57368 displaying changes. There are always 10 horizontal lines in each chart; the
57369 title string indicates the value of each division when it is greater than one.
57370 For example, <quote>x2</quote> means that each division represents a value of 2.
57371 </para>
57372 <para>
57373 It is also possible to have a stripchart which shows the percentage fullness of
57374 a particular disk partition, which is useful when local deliveries are confined
57375 to a single partition.
57376 </para>
57377 <para>
57378 <indexterm role="concept">
57379 <primary><option>statvfs</option> function</primary>
57380 </indexterm>
57381 This relies on the availability of the <function>statvfs()</function> function or equivalent in
57382 the operating system. Most, but not all versions of Unix that support Exim have
57383 this. For this particular stripchart, the top of the chart always represents
57384 100%, and the scale is given as <quote>x10%</quote>. This chart is configured by setting
57385 SIZE_STRIPCHART and (optionally) SIZE_STRIPCHART_NAME in the
57386 <filename>Local/eximon.conf</filename> file.
57387 </para>
57388 </section>
57389 <section>
57390 <title>Main action buttons</title>
57391 <para>
57392 <indexterm role="concept">
57393 <primary>size</primary>
57394 <secondary>of monitor window</secondary>
57395 </indexterm>
57396 <indexterm role="concept">
57397 <primary>Exim monitor</primary>
57398 <secondary>window size</secondary>
57399 </indexterm>
57400 <indexterm role="concept">
57401 <primary>window size</primary>
57402 </indexterm>
57403 Below the stripcharts there is an action button for quitting the monitor. Next
57404 to this is another button marked <quote>Size</quote>. They are placed here so that
57405 shrinking the window to its default minimum size leaves just the queue count
57406 stripchart and these two buttons visible. Pressing the <quote>Size</quote> button causes
57407 the window to expand to its maximum size, unless it is already at the maximum,
57408 in which case it is reduced to its minimum.
57409 </para>
57410 <para>
57411 When expanding to the maximum, if the window cannot be fully seen where it
57412 currently is, it is moved back to where it was the last time it was at full
57413 size. When it is expanding from its minimum size, the old position is
57414 remembered, and next time it is reduced to the minimum it is moved back there.
57415 </para>
57416 <para>
57417 The idea is that you can keep a reduced window just showing one or two
57418 stripcharts at a convenient place on your screen, easily expand it to show
57419 the full window when required, and just as easily put it back to what it was.
57420 The idea is copied from what the <emphasis>twm</emphasis> window manager does for its
57421 <emphasis>f.fullzoom</emphasis> action. The minimum size of the window can be changed by setting
57422 the MIN_HEIGHT and MIN_WIDTH values in <filename>Local/eximon.conf</filename>.
57423 </para>
57424 <para>
57425 Normally, the monitor starts up with the window at its full size, but it can be
57426 built so that it starts up with the window at its smallest size, by setting
57427 START_SMALL=yes in <filename>Local/eximon.conf</filename>.
57428 </para>
57429 </section>
57430 <section>
57431 <title>The log display</title>
57432 <para>
57433 <indexterm role="concept">
57434 <primary>log</primary>
57435 <secondary>tail of; in monitor</secondary>
57436 </indexterm>
57437 The second section of the window is an area in which a display of the tail of
57438 the main log is maintained.
57439 To save space on the screen, the timestamp on each log line is shortened by
57440 removing the date and, if <option>log_timezone</option> is set, the timezone.
57441 The log tail is not available when the only destination for logging data is
57442 syslog, unless the syslog lines are routed to a local file whose name is passed
57443 to <emphasis>eximon</emphasis> via the EXIMON_LOG_FILE_PATH environment variable.
57444 </para>
57445 <para>
57446 The log sub-window has a scroll bar at its lefthand side which can be used to
57447 move back to look at earlier text, and the up and down arrow keys also have a
57448 scrolling effect. The amount of log that is kept depends on the setting of
57449 LOG_BUFFER in <filename>Local/eximon.conf</filename>, which specifies the amount of memory
57450 to use. When this is full, the earlier 50% of data is discarded &ndash; this is
57451 much more efficient than throwing it away line by line. The sub-window also has
57452 a horizontal scroll bar for accessing the ends of long log lines. This is the
57453 only means of horizontal scrolling; the right and left arrow keys are not
57454 available. Text can be cut from this part of the window using the mouse in the
57455 normal way. The size of this subwindow is controlled by parameters in the
57456 configuration file <filename>Local/eximon.conf</filename>.
57457 </para>
57458 <para>
57459 Searches of the text in the log window can be carried out by means of the ^R
57460 and ^S keystrokes, which default to a reverse and a forward search,
57461 respectively. The search covers only the text that is displayed in the window.
57462 It cannot go further back up the log.
57463 </para>
57464 <para>
57465 The point from which the search starts is indicated by a caret marker. This is
57466 normally at the end of the text in the window, but can be positioned explicitly
57467 by pointing and clicking with the left mouse button, and is moved automatically
57468 by a successful search. If new text arrives in the window when it is scrolled
57469 back, the caret remains where it is, but if the window is not scrolled back,
57470 the caret is moved to the end of the new text.
57471 </para>
57472 <para>
57473 Pressing ^R or ^S pops up a window into which the search text can be typed.
57474 There are buttons for selecting forward or reverse searching, for carrying out
57475 the search, and for cancelling. If the <quote>Search</quote> button is pressed, the search
57476 happens and the window remains so that further searches can be done. If the
57477 <quote>Return</quote> key is pressed, a single search is done and the window is closed. If
57478 ^C is typed the search is cancelled.
57479 </para>
57480 <para>
57481 The searching facility is implemented using the facilities of the Athena text
57482 widget. By default this pops up a window containing both <quote>search</quote> and
57483 <quote>replace</quote> options. In order to suppress the unwanted <quote>replace</quote> portion for
57484 eximon, a modified version of the <option>TextPop</option> widget is distributed with Exim.
57485 However, the linkers in BSDI and HP-UX seem unable to handle an externally
57486 provided version of <option>TextPop</option> when the remaining parts of the text widget
57487 come from the standard libraries. The compile-time option EXIMON_TEXTPOP can be
57488 unset to cut out the modified <option>TextPop</option>, making it possible to build Eximon
57489 on these systems, at the expense of having unwanted items in the search popup
57490 window.
57491 </para>
57492 </section>
57493 <section>
57494 <title>The queue display</title>
57495 <para>
57496 <indexterm role="concept">
57497 <primary>queue</primary>
57498 <secondary>display in monitor</secondary>
57499 </indexterm>
57500 The bottom section of the monitor window contains a list of all messages that
57501 are on the queue, which includes those currently being received or delivered,
57502 as well as those awaiting delivery. The size of this subwindow is controlled by
57503 parameters in the configuration file <filename>Local/eximon.conf</filename>, and the frequency
57504 at which it is updated is controlled by another parameter in the same file &ndash;
57505 the default is 5 minutes, since queue scans can be quite expensive. However,
57506 there is an <quote>Update</quote> action button just above the display which can be used
57507 to force an update of the queue display at any time.
57508 </para>
57509 <para>
57510 When a host is down for some time, a lot of pending mail can build up for it,
57511 and this can make it hard to deal with other messages on the queue. To help
57512 with this situation there is a button next to <quote>Update</quote> called <quote>Hide</quote>. If
57513 pressed, a dialogue box called <quote>Hide addresses ending with</quote> is put up. If you
57514 type anything in here and press <quote>Return</quote>, the text is added to a chain of
57515 such texts, and if every undelivered address in a message matches at least one
57516 of the texts, the message is not displayed.
57517 </para>
57518 <para>
57519 If there is an address that does not match any of the texts, all the addresses
57520 are displayed as normal. The matching happens on the ends of addresses so, for
57521 example, <emphasis>cam.ac.uk</emphasis> specifies all addresses in Cambridge, while
57522 <emphasis>xxx@foo.com.example</emphasis> specifies just one specific address. When any hiding
57523 has been set up, a button called <quote>Unhide</quote> is displayed. If pressed, it
57524 cancels all hiding. Also, to ensure that hidden messages do not get forgotten,
57525 a hide request is automatically cancelled after one hour.
57526 </para>
57527 <para>
57528 While the dialogue box is displayed, you can&#x2019;t press any buttons or do anything
57529 else to the monitor window. For this reason, if you want to cut text from the
57530 queue display to use in the dialogue box, you have to do the cutting before
57531 pressing the <quote>Hide</quote> button.
57532 </para>
57533 <para>
57534 The queue display contains, for each unhidden queued message, the length of
57535 time it has been on the queue, the size of the message, the message id, the
57536 message sender, and the first undelivered recipient, all on one line. If it is
57537 a bounce message, the sender is shown as <quote>&lt;&gt;</quote>. If there is more than one
57538 recipient to which the message has not yet been delivered, subsequent ones are
57539 listed on additional lines, up to a maximum configured number, following which
57540 an ellipsis is displayed. Recipients that have already received the message are
57541 not shown.
57542 </para>
57543 <para>
57544 <indexterm role="concept">
57545 <primary>frozen messages</primary>
57546 <secondary>display</secondary>
57547 </indexterm>
57548 If a message is frozen, an asterisk is displayed at the left-hand side.
57549 </para>
57550 <para>
57551 The queue display has a vertical scroll bar, and can also be scrolled by means
57552 of the arrow keys. Text can be cut from it using the mouse in the normal way.
57553 The text searching facilities, as described above for the log window, are also
57554 available, but the caret is always moved to the end of the text when the queue
57555 display is updated.
57556 </para>
57557 </section>
57558 <section>
57559 <title>The queue menu</title>
57560 <para>
57561 <indexterm role="concept">
57562 <primary>queue</primary>
57563 <secondary>menu in monitor</secondary>
57564 </indexterm>
57565 If the <option>shift</option> key is held down and the left button is clicked when the mouse
57566 pointer is over the text for any message, an action menu pops up, and the first
57567 line of the queue display for the message is highlighted. This does not affect
57568 any selected text.
57569 </para>
57570 <para>
57571 If you want to use some other event for popping up the menu, you can set the
57572 MENU_EVENT parameter in <filename>Local/eximon.conf</filename> to change the default, or
57573 set EXIMON_MENU_EVENT in the environment before starting the monitor. The
57574 value set in this parameter is a standard X event description. For example, to
57575 run eximon using <option>ctrl</option> rather than <option>shift</option> you could use
57576 </para>
57577 <literallayout class="monospaced">
57578 EXIMON_MENU_EVENT='Ctrl&lt;Btn1Down&gt;' eximon
57579 </literallayout>
57580 <para>
57581 The title of the menu is the message id, and it contains entries which act as
57582 follows:
57583 </para>
57584 <itemizedlist>
57585 <listitem>
57586 <para>
57587 <emphasis>message log</emphasis>: The contents of the message log for the message are displayed
57588 in a new text window.
57589 </para>
57590 </listitem>
57591 <listitem>
57592 <para>
57593 <emphasis>headers</emphasis>: Information from the spool file that contains the envelope
57594 information and headers is displayed in a new text window. See chapter
57595 <xref linkend="CHAPspool"/> for a description of the format of spool files.
57596 </para>
57597 </listitem>
57598 <listitem>
57599 <para>
57600 <emphasis>body</emphasis>: The contents of the spool file containing the body of the message are
57601 displayed in a new text window. There is a default limit of 20,000 bytes to the
57602 amount of data displayed. This can be changed by setting the BODY_MAX
57603 option at compile time, or the EXIMON_BODY_MAX option at run time.
57604 </para>
57605 </listitem>
57606 <listitem>
57607 <para>
57608 <emphasis>deliver message</emphasis>: A call to Exim is made using the <option>-M</option> option to request
57609 delivery of the message. This causes an automatic thaw if the message is
57610 frozen. The <option>-v</option> option is also set, and the output from Exim is displayed in
57611 a new text window. The delivery is run in a separate process, to avoid holding
57612 up the monitor while the delivery proceeds.
57613 </para>
57614 </listitem>
57615 <listitem>
57616 <para>
57617 <emphasis>freeze message</emphasis>: A call to Exim is made using the <option>-Mf</option> option to request
57618 that the message be frozen.
57619 </para>
57620 </listitem>
57621 <listitem>
57622 <para>
57623 <indexterm role="concept">
57624 <primary>thawing messages</primary>
57625 </indexterm>
57626 <indexterm role="concept">
57627 <primary>unfreezing messages</primary>
57628 </indexterm>
57629 <indexterm role="concept">
57630 <primary>frozen messages</primary>
57631 <secondary>thawing</secondary>
57632 </indexterm>
57633 <emphasis>thaw message</emphasis>: A call to Exim is made using the <option>-Mt</option> option to request
57634 that the message be thawed.
57635 </para>
57636 </listitem>
57637 <listitem>
57638 <para>
57639 <indexterm role="concept">
57640 <primary>delivery</primary>
57641 <secondary>forcing failure</secondary>
57642 </indexterm>
57643 <emphasis>give up on msg</emphasis>: A call to Exim is made using the <option>-Mg</option> option to request
57644 that Exim gives up trying to deliver the message. A bounce message is generated
57645 for any remaining undelivered addresses.
57646 </para>
57647 </listitem>
57648 <listitem>
57649 <para>
57650 <emphasis>remove message</emphasis>: A call to Exim is made using the <option>-Mrm</option> option to request
57651 that the message be deleted from the system without generating a bounce
57652 message.
57653 </para>
57654 </listitem>
57655 <listitem>
57656 <para>
57657 <emphasis>add recipient</emphasis>: A dialog box is displayed into which a recipient address can
57658 be typed. If the address is not qualified and the QUALIFY_DOMAIN parameter
57659 is set in <filename>Local/eximon.conf</filename>, the address is qualified with that domain.
57660 Otherwise it must be entered as a fully qualified address. Pressing RETURN
57661 causes a call to Exim to be made using the <option>-Mar</option> option to request that an
57662 additional recipient be added to the message, unless the entry box is empty, in
57663 which case no action is taken.
57664 </para>
57665 </listitem>
57666 <listitem>
57667 <para>
57668 <emphasis>mark delivered</emphasis>: A dialog box is displayed into which a recipient address
57669 can be typed. If the address is not qualified and the QUALIFY_DOMAIN parameter
57670 is set in <filename>Local/eximon.conf</filename>, the address is qualified with that domain.
57671 Otherwise it must be entered as a fully qualified address. Pressing RETURN
57672 causes a call to Exim to be made using the <option>-Mmd</option> option to mark the given
57673 recipient address as already delivered, unless the entry box is empty, in which
57674 case no action is taken.
57675 </para>
57676 </listitem>
57677 <listitem>
57678 <para>
57679 <emphasis>mark all delivered</emphasis>: A call to Exim is made using the <option>-Mmad</option> option to
57680 mark all recipient addresses as already delivered.
57681 </para>
57682 </listitem>
57683 <listitem>
57684 <para>
57685 <emphasis>edit sender</emphasis>: A dialog box is displayed initialized with the current
57686 sender&#x2019;s address. Pressing RETURN causes a call to Exim to be made using the
57687 <option>-Mes</option> option to replace the sender address, unless the entry box is empty,
57688 in which case no action is taken. If you want to set an empty sender (as in
57689 bounce messages), you must specify it as <quote>&lt;&gt;</quote>. Otherwise, if the address is
57690 not qualified and the QUALIFY_DOMAIN parameter is set in <filename>Local/eximon.conf</filename>,
57691 the address is qualified with that domain.
57692 </para>
57693 </listitem>
57694 </itemizedlist>
57695 <para>
57696 When a delivery is forced, a window showing the <option>-v</option> output is displayed. In
57697 other cases when a call to Exim is made, if there is any output from Exim (in
57698 particular, if the command fails) a window containing the command and the
57699 output is displayed. Otherwise, the results of the action are normally apparent
57700 from the log and queue displays. However, if you set ACTION_OUTPUT=yes in
57701 <filename>Local/eximon.conf</filename>, a window showing the Exim command is always opened, even
57702 if no output is generated.
57703 </para>
57704 <para>
57705 The queue display is automatically updated for actions such as freezing and
57706 thawing, unless ACTION_QUEUE_UPDATE=no has been set in
57707 <filename>Local/eximon.conf</filename>. In this case the <quote>Update</quote> button has to be used to
57708 force an update of the display after one of these actions.
57709 </para>
57710 <para>
57711 In any text window that is displayed as result of a menu action, the normal
57712 cut-and-paste facility is available, and searching can be carried out using ^R
57713 and ^S, as described above for the log tail window.
57714 <indexterm role="concept" startref="IIDeximon" class="endofrange"/>
57715 </para>
57716 </section>
57717 </chapter>
57718
57719 <chapter id="CHAPsecurity">
57720 <title>Security considerations</title>
57721 <para>
57722 <indexterm role="concept" id="IIDsecurcon" class="startofrange">
57723 <primary>security</primary>
57724 <secondary>discussion of</secondary>
57725 </indexterm>
57726 This chapter discusses a number of issues concerned with security, some of
57727 which are also covered in other parts of this manual.
57728 </para>
57729 <para>
57730 For reasons that this author does not understand, some people have promoted
57731 Exim as a <quote>particularly secure</quote> mailer. Perhaps it is because of the
57732 existence of this chapter in the documentation. However, the intent of the
57733 chapter is simply to describe the way Exim works in relation to certain
57734 security concerns, not to make any specific claims about the effectiveness of
57735 its security as compared with other MTAs.
57736 </para>
57737 <para>
57738 What follows is a description of the way Exim is supposed to be. Best efforts
57739 have been made to try to ensure that the code agrees with the theory, but an
57740 absence of bugs can never be guaranteed. Any that are reported will get fixed
57741 as soon as possible.
57742 </para>
57743 <section>
57744 <title>Building a more <quote>hardened</quote> Exim</title>
57745 <para>
57746 <indexterm role="concept">
57747 <primary>security</primary>
57748 <secondary>build-time features</secondary>
57749 </indexterm>
57750 There are a number of build-time options that can be set in <filename>Local/Makefile</filename>
57751 to create Exim binaries that are <quote>harder</quote> to attack, in particular by a rogue
57752 Exim administrator who does not have the root password, or by someone who has
57753 penetrated the Exim (but not the root) account. These options are as follows:
57754 </para>
57755 <itemizedlist>
57756 <listitem>
57757 <para>
57758 ALT_CONFIG_PREFIX can be set to a string that is required to match the
57759 start of any file names used with the <option>-C</option> option. When it is set, these file
57760 names are also not allowed to contain the sequence <quote>/../</quote>. (However, if the
57761 value of the <option>-C</option> option is identical to the value of CONFIGURE_FILE in
57762 <filename>Local/Makefile</filename>, Exim ignores <option>-C</option> and proceeds as usual.) There is no
57763 default setting for <option>ALT_CONFIG_PREFIX</option>.
57764 </para>
57765 <para>
57766 If the permitted configuration files are confined to a directory to
57767 which only root has access, this guards against someone who has broken
57768 into the Exim account from running a privileged Exim with an arbitrary
57769 configuration file, and using it to break into other accounts.
57770 </para>
57771 </listitem>
57772 <listitem>
57773 <para>
57774 If ALT_CONFIG_ROOT_ONLY is defined, root privilege is retained for <option>-C</option>
57775 and <option>-D</option> only if the caller of Exim is root. Without it, the Exim user may
57776 also use <option>-C</option> and <option>-D</option> and retain privilege. Setting this option locks out
57777 the possibility of testing a configuration using <option>-C</option> right through message
57778 reception and delivery, even if the caller is root. The reception works, but by
57779 that time, Exim is running as the Exim user, so when it re-execs to regain
57780 privilege for the delivery, the use of <option>-C</option> causes privilege to be lost.
57781 However, root can test reception and delivery using two separate commands.
57782 ALT_CONFIG_ROOT_ONLY is not set by default.
57783 </para>
57784 </listitem>
57785 <listitem>
57786 <para>
57787 If DISABLE_D_OPTION is defined, the use of the <option>-D</option> command line option
57788 is disabled.
57789 </para>
57790 </listitem>
57791 <listitem>
57792 <para>
57793 FIXED_NEVER_USERS can be set to a colon-separated list of users that are
57794 never to be used for any deliveries. This is like the <option>never_users</option> runtime
57795 option, but it cannot be overridden; the runtime option adds additional users
57796 to the list. The default setting is <quote>root</quote>; this prevents a non-root user who
57797 is permitted to modify the runtime file from using Exim as a way to get root.
57798 </para>
57799 </listitem>
57800 </itemizedlist>
57801 </section>
57802 <section>
57803 <title>Root privilege</title>
57804 <para>
57805 <indexterm role="concept">
57806 <primary>setuid</primary>
57807 </indexterm>
57808 <indexterm role="concept">
57809 <primary>root privilege</primary>
57810 </indexterm>
57811 The Exim binary is normally setuid to root, which means that it gains root
57812 privilege (runs as root) when it starts execution. In some special cases (for
57813 example, when the daemon is not in use and there are no local deliveries), it
57814 may be possible to run Exim setuid to some user other than root. This is
57815 discussed in the next section. However, in most installations, root privilege
57816 is required for two things:
57817 </para>
57818 <itemizedlist>
57819 <listitem>
57820 <para>
57821 To set up a socket connected to the standard SMTP port (25) when initialising
57822 the listening daemon. If Exim is run from <emphasis>inetd</emphasis>, this privileged action is
57823 not required.
57824 </para>
57825 </listitem>
57826 <listitem>
57827 <para>
57828 To be able to change uid and gid in order to read users&#x2019; <filename>.forward</filename> files and
57829 perform local deliveries as the receiving user or as specified in the
57830 configuration.
57831 </para>
57832 </listitem>
57833 </itemizedlist>
57834 <para>
57835 It is not necessary to be root to do any of the other things Exim does, such as
57836 receiving messages and delivering them externally over SMTP, and it is
57837 obviously more secure if Exim does not run as root except when necessary.
57838 For this reason, a user and group for Exim to use must be defined in
57839 <filename>Local/Makefile</filename>. These are known as <quote>the Exim user</quote> and <quote>the Exim
57840 group</quote>. Their values can be changed by the run time configuration, though this
57841 is not recommended. Often a user called <emphasis>exim</emphasis> is used, but some sites use
57842 <emphasis>mail</emphasis> or another user name altogether.
57843 </para>
57844 <para>
57845 Exim uses <function>setuid()</function> whenever it gives up root privilege. This is a permanent
57846 abdication; the process cannot regain root afterwards. Prior to release 4.00,
57847 <function>seteuid()</function> was used in some circumstances, but this is no longer the case.
57848 </para>
57849 <para>
57850 After a new Exim process has interpreted its command line options, it changes
57851 uid and gid in the following cases:
57852 </para>
57853 <itemizedlist>
57854 <listitem>
57855 <para>
57856 <indexterm role="concept">
57857 <primary><option>-C</option> option</primary>
57858 </indexterm>
57859 <indexterm role="concept">
57860 <primary><option>-D</option> option</primary>
57861 </indexterm>
57862 If the <option>-C</option> option is used to specify an alternate configuration file, or if
57863 the <option>-D</option> option is used to define macro values for the configuration, and the
57864 calling process is not running as root or the Exim user, the uid and gid are
57865 changed to those of the calling process.
57866 However, if ALT_CONFIG_ROOT_ONLY is defined in <filename>Local/Makefile</filename>, only
57867 root callers may use <option>-C</option> and <option>-D</option> without losing privilege, and if
57868 DISABLE_D_OPTION is set, the <option>-D</option> option may not be used at all.
57869 </para>
57870 </listitem>
57871 <listitem>
57872 <para>
57873 <indexterm role="concept">
57874 <primary><option>-be</option> option</primary>
57875 </indexterm>
57876 <indexterm role="concept">
57877 <primary><option>-bf</option> option</primary>
57878 </indexterm>
57879 <indexterm role="concept">
57880 <primary><option>-bF</option> option</primary>
57881 </indexterm>
57882 If the expansion test option (<option>-be</option>) or one of the filter testing options
57883 (<option>-bf</option> or <option>-bF</option>) are used, the uid and gid are changed to those of the
57884 calling process.
57885 </para>
57886 </listitem>
57887 <listitem>
57888 <para>
57889 If the process is not a daemon process or a queue runner process or a delivery
57890 process or a process for testing address routing (started with <option>-bt</option>), the
57891 uid and gid are changed to the Exim user and group. This means that Exim always
57892 runs under its own uid and gid when receiving messages. This also applies when
57893 testing address verification
57894 <indexterm role="concept">
57895 <primary><option>-bv</option> option</primary>
57896 </indexterm>
57897 <indexterm role="concept">
57898 <primary><option>-bh</option> option</primary>
57899 </indexterm>
57900 (the <option>-bv</option> option) and testing incoming message policy controls (the <option>-bh</option>
57901 option).
57902 </para>
57903 </listitem>
57904 <listitem>
57905 <para>
57906 For a daemon, queue runner, delivery, or address testing process, the uid
57907 remains as root at this stage, but the gid is changed to the Exim group.
57908 </para>
57909 </listitem>
57910 </itemizedlist>
57911 <para>
57912 The processes that initially retain root privilege behave as follows:
57913 </para>
57914 <itemizedlist>
57915 <listitem>
57916 <para>
57917 A daemon process changes the gid to the Exim group and the uid to the Exim
57918 user after setting up one or more listening sockets. The <function>initgroups()</function>
57919 function is called, so that if the Exim user is in any additional groups, they
57920 will be used during message reception.
57921 </para>
57922 </listitem>
57923 <listitem>
57924 <para>
57925 A queue runner process retains root privilege throughout its execution. Its
57926 job is to fork a controlled sequence of delivery processes.
57927 </para>
57928 </listitem>
57929 <listitem>
57930 <para>
57931 A delivery process retains root privilege throughout most of its execution,
57932 but any actual deliveries (that is, the transports themselves) are run in
57933 subprocesses which always change to a non-root uid and gid. For local
57934 deliveries this is typically the uid and gid of the owner of the mailbox; for
57935 remote deliveries, the Exim uid and gid are used. Once all the delivery
57936 subprocesses have been run, a delivery process changes to the Exim uid and gid
57937 while doing post-delivery tidying up such as updating the retry database and
57938 generating bounce and warning messages.
57939 </para>
57940 <para>
57941 While the recipient addresses in a message are being routed, the delivery
57942 process runs as root. However, if a user&#x2019;s filter file has to be processed,
57943 this is done in a subprocess that runs under the individual user&#x2019;s uid and
57944 gid. A system filter is run as root unless <option>system_filter_user</option> is set.
57945 </para>
57946 </listitem>
57947 <listitem>
57948 <para>
57949 A process that is testing addresses (the <option>-bt</option> option) runs as root so that
57950 the routing is done in the same environment as a message delivery.
57951 </para>
57952 </listitem>
57953 </itemizedlist>
57954 </section>
57955 <section id="SECTrunexiwitpri">
57956 <title>Running Exim without privilege</title>
57957 <para>
57958 <indexterm role="concept">
57959 <primary>privilege</primary>
57960 <secondary>running without</secondary>
57961 </indexterm>
57962 <indexterm role="concept">
57963 <primary>unprivileged running</primary>
57964 </indexterm>
57965 <indexterm role="concept">
57966 <primary>root privilege</primary>
57967 <secondary>running without</secondary>
57968 </indexterm>
57969 Some installations like to run Exim in an unprivileged state for more of its
57970 operation, for added security. Support for this mode of operation is provided
57971 by the global option <option>deliver_drop_privilege</option>. When this is set, the uid and
57972 gid are changed to the Exim user and group at the start of a delivery process
57973 (and also queue runner and address testing processes). This means that address
57974 routing is no longer run as root, and the deliveries themselves cannot change
57975 to any other uid.
57976 </para>
57977 <para>
57978 Leaving the binary setuid to root, but setting <option>deliver_drop_privilege</option> means
57979 that the daemon can still be started in the usual way, and it can respond
57980 correctly to SIGHUP because the re-invocation regains root privilege.
57981 </para>
57982 <para>
57983 An alternative approach is to make Exim setuid to the Exim user and also setgid
57984 to the Exim group.
57985 If you do this, the daemon must be started from a root process. (Calling
57986 Exim from a root process makes it behave in the way it does when it is setuid
57987 root.) However, the daemon cannot restart itself after a SIGHUP signal because
57988 it cannot regain privilege.
57989 </para>
57990 <para>
57991 It is still useful to set <option>deliver_drop_privilege</option> in this case, because it
57992 stops Exim from trying to re-invoke itself to do a delivery after a message has
57993 been received. Such a re-invocation is a waste of resources because it has no
57994 effect.
57995 </para>
57996 <para>
57997 If restarting the daemon is not an issue (for example, if <option>mua_wrapper</option> is
57998 set, or <emphasis>inetd</emphasis> is being used instead of a daemon), having the binary setuid
57999 to the Exim user seems a clean approach, but there is one complication:
58000 </para>
58001 <para>
58002 In this style of operation, Exim is running with the real uid and gid set to
58003 those of the calling process, and the effective uid/gid set to Exim&#x2019;s values.
58004 Ideally, any association with the calling process&#x2019; uid/gid should be dropped,
58005 that is, the real uid/gid should be reset to the effective values so as to
58006 discard any privileges that the caller may have. While some operating systems
58007 have a function that permits this action for a non-root effective uid, quite a
58008 number of them do not. Because of this lack of standardization, Exim does not
58009 address this problem at this time.
58010 </para>
58011 <para>
58012 For this reason, the recommended approach for <quote>mostly unprivileged</quote> running
58013 is to keep the Exim binary setuid to root, and to set
58014 <option>deliver_drop_privilege</option>. This also has the advantage of allowing a daemon to
58015 be used in the most straightforward way.
58016 </para>
58017 <para>
58018 If you configure Exim not to run delivery processes as root, there are a
58019 number of restrictions on what you can do:
58020 </para>
58021 <itemizedlist>
58022 <listitem>
58023 <para>
58024 You can deliver only as the Exim user/group. You should  explicitly use the
58025 <option>user</option> and <option>group</option> options to override routers or local transports that
58026 normally deliver as the recipient. This makes sure that configurations that
58027 work in this mode function the same way in normal mode. Any implicit or
58028 explicit specification of another user causes an error.
58029 </para>
58030 </listitem>
58031 <listitem>
58032 <para>
58033 Use of <filename>.forward</filename> files is severely restricted, such that it is usually
58034 not worthwhile to include them in the configuration.
58035 </para>
58036 </listitem>
58037 <listitem>
58038 <para>
58039 Users who wish to use <filename>.forward</filename> would have to make their home directory and
58040 the file itself accessible to the Exim user. Pipe and append-to-file entries,
58041 and their equivalents in Exim filters, cannot be used. While they could be
58042 enabled in the Exim user&#x2019;s name, that would be insecure and not very useful.
58043 </para>
58044 </listitem>
58045 <listitem>
58046 <para>
58047 Unless the local user mailboxes are all owned by the Exim user (possible in
58048 some POP3 or IMAP-only environments):
58049 </para>
58050 <orderedlist numeration="arabic">
58051 <listitem>
58052 <para>
58053 They must be owned by the Exim group and be writable by that group. This
58054 implies you must set <option>mode</option> in the appendfile configuration, as well as the
58055 mode of the mailbox files themselves.
58056 </para>
58057 </listitem>
58058 <listitem>
58059 <para>
58060 You must set <option>no_check_owner</option>, since most or all of the files will not be
58061 owned by the Exim user.
58062 </para>
58063 </listitem>
58064 <listitem>
58065 <para>
58066 You must set <option>file_must_exist</option>, because Exim cannot set the owner correctly
58067 on a newly created mailbox when unprivileged. This also implies that new
58068 mailboxes need to be created manually.
58069 </para>
58070 </listitem>
58071 </orderedlist>
58072 </listitem>
58073 </itemizedlist>
58074 <para>
58075 These restrictions severely restrict what can be done in local deliveries.
58076 However, there are no restrictions on remote deliveries. If you are running a
58077 gateway host that does no local deliveries, setting <option>deliver_drop_privilege</option>
58078 gives more security at essentially no cost.
58079 </para>
58080 <para>
58081 If you are using the <option>mua_wrapper</option> facility (see chapter
58082 <xref linkend="CHAPnonqueueing"/>), <option>deliver_drop_privilege</option> is forced to be true.
58083 </para>
58084 </section>
58085 <section>
58086 <title>Delivering to local files</title>
58087 <para>
58088 Full details of the checks applied by <command>appendfile</command> before it writes to a file
58089 are given in chapter <xref linkend="CHAPappendfile"/>.
58090 </para>
58091 </section>
58092 <section>
58093 <title>IPv4 source routing</title>
58094 <para>
58095 <indexterm role="concept">
58096 <primary>source routing</primary>
58097 <secondary>in IP packets</secondary>
58098 </indexterm>
58099 <indexterm role="concept">
58100 <primary>IP source routing</primary>
58101 </indexterm>
58102 Many operating systems suppress IP source-routed packets in the kernel, but
58103 some cannot be made to do this, so Exim does its own check. It logs incoming
58104 IPv4 source-routed TCP calls, and then drops them. Things are all different in
58105 IPv6. No special checking is currently done.
58106 </para>
58107 </section>
58108 <section>
58109 <title>The VRFY, EXPN, and ETRN commands in SMTP</title>
58110 <para>
58111 Support for these SMTP commands is disabled by default. If required, they can
58112 be enabled by defining suitable ACLs.
58113 </para>
58114 </section>
58115 <section>
58116 <title>Privileged users</title>
58117 <para>
58118 <indexterm role="concept">
58119 <primary>trusted user</primary>
58120 </indexterm>
58121 <indexterm role="concept">
58122 <primary>admin user</primary>
58123 </indexterm>
58124 <indexterm role="concept">
58125 <primary>privileged user</primary>
58126 </indexterm>
58127 <indexterm role="concept">
58128 <primary>user</primary>
58129 <secondary>trusted</secondary>
58130 </indexterm>
58131 <indexterm role="concept">
58132 <primary>user</primary>
58133 <secondary>admin</secondary>
58134 </indexterm>
58135 Exim recognises two sets of users with special privileges. Trusted users are
58136 able to submit new messages to Exim locally, but supply their own sender
58137 addresses and information about a sending host. For other users submitting
58138 local messages, Exim sets up the sender address from the uid, and doesn&#x2019;t
58139 permit a remote host to be specified.
58140 </para>
58141 <para>
58142 <indexterm role="concept">
58143 <primary><option>-f</option> option</primary>
58144 </indexterm>
58145 However, an untrusted user is permitted to use the <option>-f</option> command line option
58146 in the special form <option>-f &lt;&gt;</option> to indicate that a delivery failure for the
58147 message should not cause an error report. This affects the message&#x2019;s envelope,
58148 but it does not affect the <emphasis>Sender:</emphasis> header. Untrusted users may also be
58149 permitted to use specific forms of address with the <option>-f</option> option by setting
58150 the <option>untrusted_set_sender</option> option.
58151 </para>
58152 <para>
58153 Trusted users are used to run processes that receive mail messages from some
58154 other mail domain and pass them on to Exim for delivery either locally, or over
58155 the Internet. Exim trusts a caller that is running as root, as the Exim user,
58156 as any user listed in the <option>trusted_users</option> configuration option, or under any
58157 group listed in the <option>trusted_groups</option> option.
58158 </para>
58159 <para>
58160 Admin users are permitted to do things to the messages on Exim&#x2019;s queue. They
58161 can freeze or thaw messages, cause them to be returned to their senders, remove
58162 them entirely, or modify them in various ways. In addition, admin users can run
58163 the Exim monitor and see all the information it is capable of providing, which
58164 includes the contents of files on the spool.
58165 </para>
58166 <para>
58167 <indexterm role="concept">
58168 <primary><option>-M</option> option</primary>
58169 </indexterm>
58170 <indexterm role="concept">
58171 <primary><option>-q</option> option</primary>
58172 </indexterm>
58173 By default, the use of the <option>-M</option> and <option>-q</option> options to cause Exim to attempt
58174 delivery of messages on its queue is restricted to admin users. This
58175 restriction can be relaxed by setting the <option>no_prod_requires_admin</option> option.
58176 Similarly, the use of <option>-bp</option> (and its variants) to list the contents of the
58177 queue is also restricted to admin users. This restriction can be relaxed by
58178 setting <option>no_queue_list_requires_admin</option>.
58179 </para>
58180 <para>
58181 Exim recognises an admin user if the calling process is running as root or as
58182 the Exim user or if any of the groups associated with the calling process is
58183 the Exim group. It is not necessary actually to be running under the Exim
58184 group. However, if admin users who are not root or the Exim user are to access
58185 the contents of files on the spool via the Exim monitor (which runs
58186 unprivileged), Exim must be built to allow group read access to its spool
58187 files.
58188 </para>
58189 </section>
58190 <section>
58191 <title>Spool files</title>
58192 <para>
58193 <indexterm role="concept">
58194 <primary>spool directory</primary>
58195 <secondary>files</secondary>
58196 </indexterm>
58197 Exim&#x2019;s spool directory and everything it contains is owned by the Exim user and
58198 set to the Exim group. The mode for spool files is defined in the
58199 <filename>Local/Makefile</filename> configuration file, and defaults to 0640. This means that
58200 any user who is a member of the Exim group can access these files.
58201 </para>
58202 </section>
58203 <section>
58204 <title>Use of argv[0]</title>
58205 <para>
58206 Exim examines the last component of <option>argv[0]</option>, and if it matches one of a set
58207 of specific strings, Exim assumes certain options. For example, calling Exim
58208 with the last component of <option>argv[0]</option> set to <quote>rsmtp</quote> is exactly equivalent
58209 to calling it with the option <option>-bS</option>. There are no security implications in
58210 this.
58211 </para>
58212 </section>
58213 <section>
58214 <title>Use of %f formatting</title>
58215 <para>
58216 The only use made of <quote>%f</quote> by Exim is in formatting load average values. These
58217 are actually stored in integer variables as 1000 times the load average.
58218 Consequently, their range is limited and so therefore is the length of the
58219 converted output.
58220 </para>
58221 </section>
58222 <section>
58223 <title>Embedded Exim path</title>
58224 <para>
58225 Exim uses its own path name, which is embedded in the code, only when it needs
58226 to re-exec in order to regain root privilege. Therefore, it is not root when it
58227 does so. If some bug allowed the path to get overwritten, it would lead to an
58228 arbitrary program&#x2019;s being run as exim, not as root.
58229 </para>
58230 </section>
58231 <section>
58232 <title>Use of sprintf()</title>
58233 <para>
58234 <indexterm role="concept">
58235 <primary><function>sprintf()</function></primary>
58236 </indexterm>
58237 A large number of occurrences of <quote>sprintf</quote> in the code are actually calls to
58238 <emphasis>string_sprintf()</emphasis>, a function that returns the result in malloc&#x2019;d store.
58239 The intermediate formatting is done into a large fixed buffer by a function
58240 that runs through the format string itself, and checks the length of each
58241 conversion before performing it, thus preventing buffer overruns.
58242 </para>
58243 <para>
58244 The remaining uses of <function>sprintf()</function> happen in controlled circumstances where
58245 the output buffer is known to be sufficiently long to contain the converted
58246 string.
58247 </para>
58248 </section>
58249 <section>
58250 <title>Use of debug_printf() and log_write()</title>
58251 <para>
58252 Arbitrary strings are passed to both these functions, but they do their
58253 formatting by calling the function <emphasis>string_vformat()</emphasis>, which runs through
58254 the format string itself, and checks the length of each conversion.
58255 </para>
58256 </section>
58257 <section>
58258 <title>Use of strcat() and strcpy()</title>
58259 <para>
58260 These are used only in cases where the output buffer is known to be large
58261 enough to hold the result.
58262 <indexterm role="concept" startref="IIDsecurcon" class="endofrange"/>
58263 </para>
58264 </section>
58265 </chapter>
58266
58267 <chapter id="CHAPspool">
58268 <title>Format of spool files</title>
58269 <para>
58270 <indexterm role="concept" id="IIDforspo1" class="startofrange">
58271 <primary>format</primary>
58272 <secondary>spool files</secondary>
58273 </indexterm>
58274 <indexterm role="concept" id="IIDforspo2" class="startofrange">
58275 <primary>spool directory</primary>
58276 <secondary>format of files</secondary>
58277 </indexterm>
58278 <indexterm role="concept" id="IIDforspo3" class="startofrange">
58279 <primary>spool files</primary>
58280 <secondary>format of</secondary>
58281 </indexterm>
58282 <indexterm role="concept">
58283 <primary>spool files</primary>
58284 <secondary>editing</secondary>
58285 </indexterm>
58286 A message on Exim&#x2019;s queue consists of two files, whose names are the message id
58287 followed by -D and -H, respectively. The data portion of the message is kept in
58288 the -D file on its own. The message&#x2019;s envelope, status, and headers are all
58289 kept in the -H file, whose format is described in this chapter. Each of these
58290 two files contains the final component of its own name as its first line. This
58291 is insurance against disk crashes where the directory is lost but the files
58292 themselves are recoverable.
58293 </para>
58294 <para>
58295 Some people are tempted into editing -D files in order to modify messages. You
58296 need to be extremely careful if you do this; it is not recommended and you are
58297 on your own if you do it. Here are some of the pitfalls:
58298 </para>
58299 <itemizedlist>
58300 <listitem>
58301 <para>
58302 You must ensure that Exim does not try to deliver the message while you are
58303 fiddling with it. The safest way is to take out a write lock on the -D file,
58304 which is what Exim itself does, using <function>fcntl()</function>. If you update the file in
58305 place, the lock will be retained. If you write a new file and rename it, the
58306 lock will be lost at the instant of rename.
58307 </para>
58308 </listitem>
58309 <listitem>
58310 <para>
58311 <indexterm role="concept">
58312 <primary><varname>$body_linecount</varname></primary>
58313 </indexterm>
58314 If you change the number of lines in the file, the value of
58315 <varname>$body_linecount</varname>, which is stored in the -H file, will be incorrect. At
58316 present, this value is not used by Exim, but there is no guarantee that this
58317 will always be the case.
58318 </para>
58319 </listitem>
58320 <listitem>
58321 <para>
58322 If the message is in MIME format, you must take care not to break it.
58323 </para>
58324 </listitem>
58325 <listitem>
58326 <para>
58327 If the message is cryptographically signed, any change will invalidate the
58328 signature.
58329 </para>
58330 </listitem>
58331 </itemizedlist>
58332 <para>
58333 Files whose names end with -J may also be seen in the <filename>input</filename> directory (or
58334 its subdirectories when <option>split_spool_directory</option> is set). These are journal
58335 files, used to record addresses to which the message has been delivered during
58336 the course of a delivery run. At the end of the run, the -H file is updated,
58337 and the -J file is deleted.
58338 </para>
58339 <section>
58340 <title>Format of the -H file</title>
58341 <para>
58342 <indexterm role="concept">
58343 <primary>uid (user id)</primary>
58344 <secondary>in spool file</secondary>
58345 </indexterm>
58346 <indexterm role="concept">
58347 <primary>gid (group id)</primary>
58348 <secondary>in spool file</secondary>
58349 </indexterm>
58350 The second line of the -H file contains the login name for the uid of the
58351 process that called Exim to read the message, followed by the numerical uid and
58352 gid. For a locally generated message, this is normally the user who sent the
58353 message. For a message received over TCP/IP, it is normally the Exim user.
58354 </para>
58355 <para>
58356 The third line of the file contains the address of the message&#x2019;s sender as
58357 transmitted in the envelope, contained in angle brackets. The sender address is
58358 empty for bounce messages. For incoming SMTP mail, the sender address is given
58359 in the MAIL command. For locally generated mail, the sender address is
58360 created by Exim from the login name of the current user and the configured
58361 <option>qualify_domain</option>. However, this can be overridden by the <option>-f</option> option or a
58362 leading <quote>From&nbsp;</quote> line if the caller is trusted, or if the supplied address is
58363 <quote>&lt;&gt;</quote> or an address that matches <option>untrusted_set_senders</option>.
58364 </para>
58365 <para>
58366 The fourth line contains two numbers. The first is the time that the message
58367 was received, in the conventional Unix form &ndash; the number of seconds since the
58368 start of the epoch. The second number is a count of the number of messages
58369 warning of delayed delivery that have been sent to the sender.
58370 </para>
58371 <para>
58372 There follow a number of lines starting with a hyphen. These can appear in any
58373 order, and are omitted when not relevant:
58374 </para>
58375 <variablelist>
58376 <varlistentry>
58377 <term><option>-acl</option> &lt;<emphasis>number</emphasis>&gt; &lt;<emphasis>length</emphasis>&gt;</term>
58378 <listitem>
58379 <para revisionflag="changed">
58380 This item is obsolete, and is not generated from Exim release 4.61 onwards;
58381 <option>-aclc</option> and <option>-aclm</option> are used instead. However, <option>-acl</option> is still
58382 recognized, to provide backward compatibility. In the old format, a line of
58383 this form is present for every ACL variable that is not empty. The number
58384 identifies the variable; the <option>acl_c</option><emphasis role="bold">x</emphasis> variables are numbered 0&ndash;9 and
58385 the <option>acl_m</option><emphasis role="bold">x</emphasis> variables are numbered 10&ndash;19. The length is the length of
58386 the data string for the variable. The string itself starts at the beginning of
58387 the next line, and is followed by a newline character. It may contain internal
58388 newlines.
58389 </para>
58390 </listitem></varlistentry>
58391 <varlistentry revisionflag="changed">
58392 <term><option>-aclc</option> &lt;<emphasis>number</emphasis>&gt; &lt;<emphasis>length</emphasis>&gt;</term>
58393 <listitem>
58394 <para revisionflag="changed">
58395 A line of this form is present for every ACL connection variable that is not
58396 empty. The number identifies the variable. The length is the length of the data
58397 string for the variable. The string itself starts at the beginning of the next
58398 line, and is followed by a newline character. It may contain internal newlines.
58399 </para>
58400 </listitem></varlistentry>
58401 <varlistentry revisionflag="changed">
58402 <term><option>-aclm</option> &lt;<emphasis>number</emphasis>&gt; &lt;<emphasis>length</emphasis>&gt;</term>
58403 <listitem>
58404 <para revisionflag="changed">
58405 A line of this form is present for every ACL message variable that is not
58406 empty. The number identifies the variable. The length is the length of the data
58407 string for the variable. The string itself starts at the beginning of the next
58408 line, and is followed by a newline character. It may contain internal newlines.
58409 </para>
58410 </listitem></varlistentry>
58411 <varlistentry>
58412 <term><option>-active_hostname</option> &lt;<emphasis>hostname</emphasis>&gt;</term>
58413 <listitem>
58414 <para>
58415 This is present if, when the message was received over SMTP, the value of
58416 <varname>$smtp_active_hostname</varname> was different to the value of <varname>$primary_hostname</varname>.
58417 </para>
58418 </listitem></varlistentry>
58419 <varlistentry>
58420 <term><option>-allow_unqualified_recipient</option></term>
58421 <listitem>
58422 <para>
58423 This is present if unqualified recipient addresses are permitted in header
58424 lines (to stop such addresses from being qualified if rewriting occurs at
58425 transport time). Local messages that were input using <option>-bnq</option> and remote
58426 messages from hosts that match <option>recipient_unqualified_hosts</option> set this flag.
58427 </para>
58428 </listitem></varlistentry>
58429 <varlistentry>
58430 <term><option>-allow_unqualified_sender</option></term>
58431 <listitem>
58432 <para>
58433 This is present if unqualified sender addresses are permitted in header lines
58434 (to stop such addresses from being qualified if rewriting occurs at transport
58435 time). Local messages that were input using <option>-bnq</option> and remote messages from
58436 hosts that match <option>sender_unqualified_hosts</option> set this flag.
58437 </para>
58438 </listitem></varlistentry>
58439 <varlistentry>
58440 <term><option>-auth_id</option> &lt;<emphasis>text</emphasis>&gt;</term>
58441 <listitem>
58442 <para>
58443 The id information for a message received on an authenticated SMTP connection
58444 &ndash; the value of the <varname>$authenticated_id</varname> variable.
58445 </para>
58446 </listitem></varlistentry>
58447 <varlistentry>
58448 <term><option>-auth_sender</option> &lt;<emphasis>address</emphasis>&gt;</term>
58449 <listitem>
58450 <para>
58451 The address of an authenticated sender &ndash; the value of the
58452 <varname>$authenticated_sender</varname> variable.
58453 </para>
58454 </listitem></varlistentry>
58455 <varlistentry>
58456 <term><option>-body_linecount</option> &lt;<emphasis>number</emphasis>&gt;</term>
58457 <listitem>
58458 <para>
58459 This records the number of lines in the body of the message, and is always
58460 present.
58461 </para>
58462 </listitem></varlistentry>
58463 <varlistentry>
58464 <term><option>-body_zerocount</option> &lt;<emphasis>number</emphasis>&gt;</term>
58465 <listitem>
58466 <para>
58467 This records the number of binary zero bytes in the body of the message, and is
58468 present if the number is greater than zero.
58469 </para>
58470 </listitem></varlistentry>
58471 <varlistentry>
58472 <term><option>-deliver_firsttime</option></term>
58473 <listitem>
58474 <para>
58475 This is written when a new message is first added to the spool. When the spool
58476 file is updated after a deferral, it is omitted.
58477 </para>
58478 </listitem></varlistentry>
58479 <varlistentry>
58480 <term><option>-frozen</option> &lt;<emphasis>time</emphasis>&gt;</term>
58481 <listitem>
58482 <para>
58483 <indexterm role="concept">
58484 <primary>frozen messages</primary>
58485 <secondary>spool data</secondary>
58486 </indexterm>
58487 The message is frozen, and the freezing happened at &lt;<emphasis>time</emphasis>&gt;.
58488 </para>
58489 </listitem></varlistentry>
58490 <varlistentry>
58491 <term><option>-helo_name</option> &lt;<emphasis>text</emphasis>&gt;</term>
58492 <listitem>
58493 <para>
58494 This records the host name as specified by a remote host in a HELO or EHLO
58495 command.
58496 </para>
58497 </listitem></varlistentry>
58498 <varlistentry>
58499 <term><option>-host_address</option> &lt;<emphasis>address</emphasis>&gt;.&lt;<emphasis>port</emphasis>&gt;</term>
58500 <listitem>
58501 <para>
58502 This records the IP address of the host from which the message was received and
58503 the remote port number that was used. It is omitted for locally generated
58504 messages.
58505 </para>
58506 </listitem></varlistentry>
58507 <varlistentry>
58508 <term><option>-host_auth</option> &lt;<emphasis>text</emphasis>&gt;</term>
58509 <listitem>
58510 <para>
58511 If the message was received on an authenticated SMTP connection, this records
58512 the name of the authenticator &ndash; the value of the
58513 <varname>$sender_host_authenticated</varname> variable.
58514 </para>
58515 </listitem></varlistentry>
58516 <varlistentry>
58517 <term><option>-host_lookup_failed</option></term>
58518 <listitem>
58519 <para>
58520 This is present if an attempt to look up the sending host&#x2019;s name from its IP
58521 address failed. It corresponds to the <varname>$host_lookup_failed</varname> variable.
58522 </para>
58523 </listitem></varlistentry>
58524 <varlistentry>
58525 <term><option>-host_name</option> &lt;<emphasis>text</emphasis>&gt;</term>
58526 <listitem>
58527 <para>
58528 <indexterm role="concept">
58529 <primary>reverse DNS lookup</primary>
58530 </indexterm>
58531 <indexterm role="concept">
58532 <primary>DNS</primary>
58533 <secondary>reverse lookup</secondary>
58534 </indexterm>
58535 This records the name of the remote host from which the message was received,
58536 if the host name was looked up from the IP address when the message was being
58537 received. It is not present if no reverse lookup was done.
58538 </para>
58539 </listitem></varlistentry>
58540 <varlistentry>
58541 <term><option>-ident</option> &lt;<emphasis>text</emphasis>&gt;</term>
58542 <listitem>
58543 <para>
58544 For locally submitted messages, this records the login of the originating user,
58545 unless it was a trusted user and the <option>-oMt</option> option was used to specify an
58546 ident value. For messages received over TCP/IP, this records the ident string
58547 supplied by the remote host, if any.
58548 </para>
58549 </listitem></varlistentry>
58550 <varlistentry>
58551 <term><option>-interface_address</option> &lt;<emphasis>address</emphasis>&gt;.&lt;<emphasis>port</emphasis>&gt;</term>
58552 <listitem>
58553 <para>
58554 This records the IP address of the local interface and the port number through
58555 which a message was received from a remote host. It is omitted for locally
58556 generated messages.
58557 </para>
58558 </listitem></varlistentry>
58559 <varlistentry>
58560 <term><option>-local</option></term>
58561 <listitem>
58562 <para>
58563 The message is from a local sender.
58564 </para>
58565 </listitem></varlistentry>
58566 <varlistentry>
58567 <term><option>-localerror</option></term>
58568 <listitem>
58569 <para>
58570 The message is a locally-generated bounce message.
58571 </para>
58572 </listitem></varlistentry>
58573 <varlistentry>
58574 <term><option>-local_scan</option> &lt;<emphasis>string</emphasis>&gt;</term>
58575 <listitem>
58576 <para>
58577 This records the data string that was returned by the <function>local_scan()</function> function
58578 when the message was received &ndash; the value of the <varname>$local_scan_data</varname>
58579 variable. It is omitted if no data was returned.
58580 </para>
58581 </listitem></varlistentry>
58582 <varlistentry>
58583 <term><option>-manual_thaw</option></term>
58584 <listitem>
58585 <para>
58586 The message was frozen but has been thawed manually, that is, by an explicit
58587 Exim command rather than via the auto-thaw process.
58588 </para>
58589 </listitem></varlistentry>
58590 <varlistentry>
58591 <term><option>-N</option></term>
58592 <listitem>
58593 <para>
58594 A testing delivery process was started using the <option>-N</option> option to suppress any
58595 actual deliveries, but delivery was deferred. At any further delivery attempts,
58596 <option>-N</option> is assumed.
58597 </para>
58598 </listitem></varlistentry>
58599 <varlistentry>
58600 <term><option>-received_protocol</option></term>
58601 <listitem>
58602 <para>
58603 This records the value of the <varname>$received_protocol</varname> variable, which contains
58604 the name of the protocol by which the message was received.
58605 </para>
58606 </listitem></varlistentry>
58607 <varlistentry>
58608 <term><option>-sender_set_untrusted</option></term>
58609 <listitem>
58610 <para>
58611 The envelope sender of this message was set by an untrusted local caller (used
58612 to ensure that the caller is displayed in queue listings).
58613 </para>
58614 </listitem></varlistentry>
58615 <varlistentry>
58616 <term><option>-spam_score_int</option> &lt;<emphasis>number</emphasis>&gt;</term>
58617 <listitem>
58618 <para>
58619 If a message was scanned by SpamAssassin, this is present. It records the value
58620 of <varname>$spam_score_int</varname>.
58621 </para>
58622 </listitem></varlistentry>
58623 <varlistentry>
58624 <term><option>-tls_certificate_verified</option></term>
58625 <listitem>
58626 <para>
58627 A TLS certificate was received from the client that sent this message, and the
58628 certificate was verified by the server.
58629 </para>
58630 </listitem></varlistentry>
58631 <varlistentry>
58632 <term><option>-tls_cipher</option> &lt;<emphasis>cipher name</emphasis>&gt;</term>
58633 <listitem>
58634 <para>
58635 When the message was received over an encrypted connection, this records the
58636 name of the cipher suite that was used.
58637 </para>
58638 </listitem></varlistentry>
58639 <varlistentry>
58640 <term><option>-tls_peerdn</option> &lt;<emphasis>peer DN</emphasis>&gt;</term>
58641 <listitem>
58642 <para>
58643 When the message was received over an encrypted connection, and a certificate
58644 was received from the client, this records the Distinguished Name from that
58645 certificate.
58646 </para>
58647 </listitem></varlistentry>
58648 </variablelist>
58649 <para>
58650 Following the options there is a list of those addresses to which the message
58651 is not to be delivered. This set of addresses is initialized from the command
58652 line when the <option>-t</option> option is used and <option>extract_addresses_remove_arguments</option>
58653 is set; otherwise it starts out empty. Whenever a successful delivery is made,
58654 the address is added to this set. The addresses are kept internally as a
58655 balanced binary tree, and it is a representation of that tree which is written
58656 to the spool file. If an address is expanded via an alias or forward file, the
58657 original address is added to the tree when deliveries to all its child
58658 addresses are complete.
58659 </para>
58660 <para>
58661 If the tree is empty, there is a single line in the spool file containing just
58662 the text <quote>XX</quote>. Otherwise, each line consists of two letters, which are either
58663 Y or N, followed by an address. The address is the value for the node of the
58664 tree, and the letters indicate whether the node has a left branch and/or a
58665 right branch attached to it, respectively. If branches exist, they immediately
58666 follow. Here is an example of a three-node tree:
58667 </para>
58668 <literallayout class="monospaced">
58669 YY darcy@austen.fict.example
58670 NN alice@wonderland.fict.example
58671 NN editor@thesaurus.ref.example
58672 </literallayout>
58673 <para>
58674 After the non-recipients tree, there is a list of the message&#x2019;s recipients.
58675 This is a simple list, preceded by a count. It includes all the original
58676 recipients of the message, including those to whom the message has already been
58677 delivered. In the simplest case, the list contains one address per line. For
58678 example:
58679 </para>
58680 <literallayout class="monospaced">
58681 4
58682 editor@thesaurus.ref.example
58683 darcy@austen.fict.example
58684 rdo@foundation
58685 alice@wonderland.fict.example
58686 </literallayout>
58687 <para>
58688 However, when a child address has been added to the top-level addresses as a
58689 result of the use of the <option>one_time</option> option on a <command>redirect</command> router, each
58690 line is of the following form:
58691 </para>
58692 <literallayout>
58693 &lt;<emphasis>top-level address</emphasis>&gt; &lt;<emphasis>errors_to address</emphasis>&gt; &lt;<emphasis>length</emphasis>&gt;,&lt;<emphasis>parent number</emphasis>&gt;#&lt;<emphasis>flag bits</emphasis>&gt;
58694 </literallayout>
58695 <para>
58696 The 01 flag bit indicates the presence of the three other fields that follow
58697 the top-level address. Other bits may be used in future to support additional
58698 fields. The &lt;<emphasis>parent number</emphasis>&gt; is the offset in the recipients list of the
58699 original parent of the <quote>one time</quote> address. The first two fields are the
58700 envelope sender that is associated with this address and its length. If the
58701 length is zero, there is no special envelope sender (there are then two space
58702 characters in the line). A non-empty field can arise from a <command>redirect</command> router
58703 that has an <option>errors_to</option> setting.
58704 </para>
58705 <para>
58706 A blank line separates the envelope and status information from the headers
58707 which follow. A header may occupy several lines of the file, and to save effort
58708 when reading it in, each header is preceded by a number and an identifying
58709 character. The number is the number of characters in the header, including any
58710 embedded newlines and the terminating newline. The character is one of the
58711 following:
58712 </para>
58713 <informaltable frame="none">
58714 <tgroup cols="2" colsep="0" rowsep="0">
58715 <colspec colwidth="50pt" align="left"/>
58716 <colspec colwidth="260pt" align="left"/>
58717 <tbody>
58718 <row>
58719 <entry>&lt;<emphasis>blank</emphasis>&gt;</entry>
58720 <entry>header in which Exim has no special interest</entry>
58721 </row>
58722 <row>
58723 <entry><literal>B</literal></entry>
58724 <entry><emphasis>Bcc:</emphasis> header</entry>
58725 </row>
58726 <row>
58727 <entry><literal>C</literal></entry>
58728 <entry><emphasis>Cc:</emphasis> header</entry>
58729 </row>
58730 <row>
58731 <entry><literal>F</literal></entry>
58732 <entry><emphasis>From:</emphasis> header</entry>
58733 </row>
58734 <row>
58735 <entry><literal>I</literal></entry>
58736 <entry><emphasis>Message-id:</emphasis> header</entry>
58737 </row>
58738 <row>
58739 <entry><literal>P</literal></entry>
58740 <entry><emphasis>Received:</emphasis> header &ndash; P for <quote>postmark</quote></entry>
58741 </row>
58742 <row>
58743 <entry><literal>R</literal></entry>
58744 <entry><emphasis>Reply-To:</emphasis> header</entry>
58745 </row>
58746 <row>
58747 <entry><literal>S</literal></entry>
58748 <entry><emphasis>Sender:</emphasis> header</entry>
58749 </row>
58750 <row>
58751 <entry><literal>T</literal></entry>
58752 <entry><emphasis>To:</emphasis> header</entry>
58753 </row>
58754 <row>
58755 <entry><literal>*</literal></entry>
58756 <entry>replaced or deleted header</entry>
58757 </row>
58758 </tbody>
58759 </tgroup>
58760 </informaltable>
58761 <para>
58762 Deleted or replaced (rewritten) headers remain in the spool file for debugging
58763 purposes. They are not transmitted when the message is delivered. Here is a
58764 typical set of headers:
58765 </para>
58766 <literallayout class="monospaced">
58767 111P Received: by hobbit.fict.example with local (Exim 4.00)
58768 id 14y9EI-00026G-00; Fri, 11 May 2001 10:28:59 +0100
58769 049  Message-Id: &lt;E14y9EI-00026G-00@hobbit.fict.example&gt;
58770 038* X-rewrote-sender: bb@hobbit.fict.example
58771 042* From: Bilbo Baggins &lt;bb@hobbit.fict.example&gt;
58772 049F From: Bilbo Baggins &lt;B.Baggins@hobbit.fict.example&gt;
58773 099* To: alice@wonderland.fict.example, rdo@foundation,
58774 darcy@austen.fict.example, editor@thesaurus.ref.example
58775 104T To: alice@wonderland.fict.example, rdo@foundation.example,
58776 darcy@austen.fict.example, editor@thesaurus.ref.example
58777 038  Date: Fri, 11 May 2001 10:28:59 +0100
58778 </literallayout>
58779 <para>
58780 The asterisked headers indicate that the envelope sender, <emphasis>From:</emphasis> header, and
58781 <emphasis>To:</emphasis> header have been rewritten, the last one because routing expanded the
58782 unqualified domain <emphasis>foundation</emphasis>.
58783 <indexterm role="concept" startref="IIDforspo1" class="endofrange"/>
58784 <indexterm role="concept" startref="IIDforspo2" class="endofrange"/>
58785 <indexterm role="concept" startref="IIDforspo3" class="endofrange"/>
58786 </para>
58787 </section>
58788 </chapter>
58789
58790 <chapter>
58791 <title>Adding new drivers or lookup types</title>
58792 <titleabbrev>Adding drivers or lookups</titleabbrev>
58793 <para>
58794 <indexterm role="concept">
58795 <primary>adding drivers</primary>
58796 </indexterm>
58797 <indexterm role="concept">
58798 <primary>new drivers</primary>
58799 <secondary>adding</secondary>
58800 </indexterm>
58801 <indexterm role="concept">
58802 <primary>drivers</primary>
58803 <secondary>adding new</secondary>
58804 </indexterm>
58805 The following actions have to be taken in order to add a new router, transport,
58806 authenticator, or lookup type to Exim:
58807 </para>
58808 <orderedlist numeration="arabic">
58809 <listitem>
58810 <para>
58811 Choose a name for the driver or lookup type that does not conflict with any
58812 existing name; I will use <quote>newdriver</quote> in what follows.
58813 </para>
58814 </listitem>
58815 <listitem>
58816 <para>
58817 Add to <filename>src/EDITME</filename> the line:
58818 </para>
58819 <literallayout>
58820 &lt;<emphasis>type</emphasis>&gt;<literal>_NEWDRIVER=yes</literal>
58821 </literallayout>
58822 <para>
58823 where &lt;<emphasis>type</emphasis>&gt; is ROUTER, TRANSPORT, AUTH, or LOOKUP. If the
58824 code is not to be included in the binary by default, comment this line out. You
58825 should also add any relevant comments about the driver or lookup type.
58826 </para>
58827 </listitem>
58828 <listitem>
58829 <para>
58830 Add to <filename>src/config.h.defaults</filename> the line:
58831 </para>
58832 <literallayout class="monospaced">
58833 #define &lt;type&gt;_NEWDRIVER
58834 </literallayout>
58835 </listitem>
58836 <listitem>
58837 <para>
58838 Edit <filename>src/drtables.c</filename>, adding conditional code to pull in the private header
58839 and create a table entry as is done for all the other drivers and lookup types.
58840 </para>
58841 </listitem>
58842 <listitem>
58843 <para>
58844 Edit <filename>Makefile</filename> in the appropriate sub-directory (<filename>src/routers</filename>,
58845 <filename>src/transports</filename>, <filename>src/auths</filename>, or <filename>src/lookups</filename>); add a line for the new
58846 driver or lookup type and add it to the definition of OBJ.
58847 </para>
58848 </listitem>
58849 <listitem>
58850 <para>
58851 Create <filename>newdriver.h</filename> and <filename>newdriver.c</filename> in the appropriate sub-directory of
58852 <filename>src</filename>.
58853 </para>
58854 </listitem>
58855 <listitem>
58856 <para>
58857 Edit <filename>scripts/MakeLinks</filename> and add commands to link the <filename>.h</filename> and <filename>.c</filename> files
58858 as for other drivers and lookups.
58859 </para>
58860 </listitem>
58861 </orderedlist>
58862 <para>
58863 Then all you need to do is write the code! A good way to start is to make a
58864 proforma by copying an existing module of the same type, globally changing all
58865 occurrences of the name, and cutting out most of the code. Note that any
58866 options you create must be listed in alphabetical order, because the tables are
58867 searched using a binary chop procedure.
58868 </para>
58869 <para>
58870 There is a <filename>README</filename> file in each of the sub-directories of <filename>src</filename> describing
58871 the interface that is expected.
58872 </para>
58873 </chapter>
58874
58875 <index role="option">
58876 <title>Option index</title>
58877 </index>
58878
58879 <index role="concept">
58880 <title>Concept index</title>
58881 </index>
58882
58883 </book>