Release 4.94
[exim-website.git] / docbook / 4.73 / 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
4
5 <?sdop
6   foot_right_recto="&chaptertitle; (&chapternumber;)"
7   foot_right_verso="&chaptertitle; (&chapternumber;)"
8   toc_chapter_blanks="yes,yes"
9   table_warn_overflow="overprint"
10 ?>
11 <book>
12 <bookinfo>
13 <title>Specification of the Exim Mail Transfer Agent</title>
14 <titleabbrev>The Exim MTA</titleabbrev>
15 <date>29 May 2010</date>
16 <author><firstname>Exim</firstname><surname>Maintainers</surname></author>
17 <authorinitials>EM</authorinitials>
18 <revhistory><revision>
19   <revnumber>4.73</revnumber>
20   <date>19 Nov 2010</date>
21   <authorinitials>EM</authorinitials>
22 </revision></revhistory>
23 <copyright><year>2009</year><holder>University of Cambridge</holder></copyright>
24 </bookinfo>
25 <chapter id="CHID1">
26 <title>Introduction</title>
27
28 <indexterm role="variable">
29   <primary>$1, $2, etc.</primary>
30   <see><emphasis>numerical variables</emphasis></see>
31 </indexterm>
32 <indexterm role="concept">
33   <primary>address</primary>
34   <secondary>rewriting</secondary>
35   <see><emphasis>rewriting</emphasis></see>
36 </indexterm>
37 <indexterm role="concept">
38   <primary>Bounce Address Tag Validation</primary>
39   <see><emphasis>BATV</emphasis></see>
40 </indexterm>
41 <indexterm role="concept">
42   <primary>Client SMTP Authorization</primary>
43   <see><emphasis>CSA</emphasis></see>
44 </indexterm>
45 <indexterm role="concept">
46   <primary>CR character</primary>
47   <see><emphasis>carriage return</emphasis></see>
48 </indexterm>
49 <indexterm role="concept">
50   <primary>CRL</primary>
51   <see><emphasis>certificate revocation list</emphasis></see>
52 </indexterm>
53 <indexterm role="concept">
54   <primary>delivery</primary>
55   <secondary>failure report</secondary>
56   <see><emphasis>bounce message</emphasis></see>
57 </indexterm>
58 <indexterm role="concept">
59   <primary>dialup</primary>
60   <see><emphasis>intermittently connected hosts</emphasis></see>
61 </indexterm>
62 <indexterm role="concept">
63   <primary>exiscan</primary>
64   <see><emphasis>content scanning</emphasis></see>
65 </indexterm>
66 <indexterm role="concept">
67   <primary>failover</primary>
68   <see><emphasis>fallback</emphasis></see>
69 </indexterm>
70 <indexterm role="concept">
71   <primary>fallover</primary>
72   <see><emphasis>fallback</emphasis></see>
73 </indexterm>
74 <indexterm role="concept">
75   <primary>filter</primary>
76   <secondary>Sieve</secondary>
77   <see><emphasis>Sieve filter</emphasis></see>
78 </indexterm>
79 <indexterm role="concept">
80   <primary>ident</primary>
81   <see><emphasis>RFC 1413</emphasis></see>
82 </indexterm>
83 <indexterm role="concept">
84   <primary>LF character</primary>
85   <see><emphasis>linefeed</emphasis></see>
86 </indexterm>
87 <indexterm role="concept">
88   <primary>maximum</primary>
89   <seealso><emphasis>limit</emphasis></seealso>
90 </indexterm>
91 <indexterm role="concept">
92   <primary>monitor</primary>
93   <see><emphasis>Exim monitor</emphasis></see>
94 </indexterm>
95 <indexterm role="concept">
96   <primary>no_<emphasis>xxx</emphasis></primary>
97   <see>entry for xxx</see>
98 </indexterm>
99 <indexterm role="concept">
100   <primary>NUL</primary>
101   <see><emphasis>binary zero</emphasis></see>
102 </indexterm>
103 <indexterm role="concept">
104   <primary>passwd file</primary>
105   <see><emphasis>/etc/passwd</emphasis></see>
106 </indexterm>
107 <indexterm role="concept">
108   <primary>process id</primary>
109   <see><emphasis>pid</emphasis></see>
110 </indexterm>
111 <indexterm role="concept">
112   <primary>RBL</primary>
113   <see><emphasis>DNS list</emphasis></see>
114 </indexterm>
115 <indexterm role="concept">
116   <primary>redirection</primary>
117   <see><emphasis>address redirection</emphasis></see>
118 </indexterm>
119 <indexterm role="concept">
120   <primary>return path</primary>
121   <seealso><emphasis>envelope sender</emphasis></seealso>
122 </indexterm>
123 <indexterm role="concept">
124   <primary>scanning</primary>
125   <see><emphasis>content scanning</emphasis></see>
126 </indexterm>
127 <indexterm role="concept">
128   <primary>SSL</primary>
129   <see><emphasis>TLS</emphasis></see>
130 </indexterm>
131 <indexterm role="concept">
132   <primary>string</primary>
133   <secondary>expansion</secondary>
134   <see><emphasis>expansion</emphasis></see>
135 </indexterm>
136 <indexterm role="concept">
137   <primary>top bit</primary>
138   <see><emphasis>8-bit characters</emphasis></see>
139 </indexterm>
140 <indexterm role="concept">
141   <primary>variables</primary>
142   <see><emphasis>expansion, variables</emphasis></see>
143 </indexterm>
144 <indexterm role="concept">
145   <primary>zero, binary</primary>
146   <see><emphasis>binary zero</emphasis></see>
147 </indexterm>
148
149 <para>
150 Exim is a mail transfer agent (MTA) for hosts that are running Unix or
151 Unix-like operating systems. It was designed on the assumption that it would be
152 run on hosts that are permanently connected to the Internet. However, it can be
153 used on intermittently connected hosts with suitable configuration adjustments.
154 </para>
155 <para>
156 Configuration files currently exist for the following operating systems: AIX,
157 BSD/OS (aka BSDI), Darwin (Mac OS X), DGUX, Dragonfly, FreeBSD, GNU/Hurd,
158 GNU/Linux, HI-OSF (Hitachi), HI-UX, HP-UX, IRIX, MIPS RISCOS, NetBSD, OpenBSD,
159 OpenUNIX, QNX, SCO, SCO SVR4.2 (aka UNIX-SV), Solaris (aka SunOS5), SunOS4,
160 Tru64-Unix (formerly Digital UNIX, formerly DEC-OSF1), Ultrix, and Unixware.
161 Some of these operating systems are no longer current and cannot easily be
162 tested, so the configuration files may no longer work in practice.
163 </para>
164 <para>
165 There are also configuration files for compiling Exim in the Cygwin environment
166 that can be installed on systems running Windows. However, this document does
167 not contain any information about running Exim in the Cygwin environment.
168 </para>
169 <para>
170 The terms and conditions for the use and distribution of Exim are contained in
171 the file <filename>NOTICE</filename>. Exim is distributed under the terms of the GNU General
172 Public Licence, a copy of which may be found in the file <filename>LICENCE</filename>.
173 </para>
174 <para>
175 The use, supply or promotion of Exim for the purpose of sending bulk,
176 unsolicited electronic mail is incompatible with the basic aims of the program,
177 which revolve around the free provision of a service that enhances the quality
178 of personal communications. The author of Exim regards indiscriminate
179 mass-mailing as an antisocial, irresponsible abuse of the Internet.
180 </para>
181 <para>
182 Exim owes a great deal to Smail 3 and its author, Ron Karr. Without the
183 experience of running and working on the Smail 3 code, I could never have
184 contemplated starting to write a new MTA. Many of the ideas and user interfaces
185 were originally taken from Smail 3, though the actual code of Exim is entirely
186 new, and has developed far beyond the initial concept.
187 </para>
188 <para>
189 Many people, both in Cambridge and around the world, have contributed to the
190 development and the testing of Exim, and to porting it to various operating
191 systems. I am grateful to them all. The distribution now contains a file called
192 <filename>ACKNOWLEDGMENTS</filename>, in which I have started recording the names of
193 contributors.
194 </para>
195 <section id="SECID1">
196 <title>Exim documentation</title>
197 <para revisionflag="changed">
198 <indexterm role="concept">
199 <primary>documentation</primary>
200 </indexterm>
201 This edition of the Exim specification applies to version 4.73 of Exim.
202 Substantive changes from the 4.72 edition are marked in some
203 renditions of the document; this paragraph is so marked if the rendition is
204 capable of showing a change indicator.
205 </para>
206 <para>
207 This document is very much a reference manual; it is not a tutorial. The reader
208 is expected to have some familiarity with the SMTP mail transfer protocol and
209 with general Unix system administration. Although there are some discussions
210 and examples in places, the information is mostly organized in a way that makes
211 it easy to look up, rather than in a natural order for sequential reading.
212 Furthermore, the manual aims to cover every aspect of Exim in detail, including
213 a number of rarely-used, special-purpose features that are unlikely to be of
214 very wide interest.
215 </para>
216 <para>
217 <indexterm role="concept">
218 <primary>books about Exim</primary>
219 </indexterm>
220 An <quote>easier</quote> discussion of Exim which provides more in-depth explanatory,
221 introductory, and tutorial material can be found in a book entitled <emphasis>The Exim
222 SMTP Mail Server</emphasis> (second edition, 2007), published by UIT Cambridge
223 (<emphasis role="bold"><ulink url="http://www.uit.co.uk/exim-book/">http://www.uit.co.uk/exim-book/</ulink></emphasis>).
224 </para>
225 <para>
226 This book also contains a chapter that gives a general introduction to SMTP and
227 Internet mail. Inevitably, however, the book is unlikely to be fully up-to-date
228 with the latest release of Exim. (Note that the earlier book about Exim,
229 published by O&#x2019;Reilly, covers Exim 3, and many things have changed in Exim 4.)
230 </para>
231 <para>
232 <indexterm role="concept">
233 <primary>Debian</primary>
234 <secondary>information sources</secondary>
235 </indexterm>
236 If you are using a Debian distribution of Exim, you will find information about
237 Debian-specific features in the file
238 <filename>/usr/share/doc/exim4-base/README.Debian</filename>.
239 The command <command>man update-exim.conf</command> is another source of Debian-specific
240 information.
241 </para>
242 <para>
243 <indexterm role="concept">
244 <primary><filename>doc/NewStuff</filename></primary>
245 </indexterm>
246 <indexterm role="concept">
247 <primary><filename>doc/ChangeLog</filename></primary>
248 </indexterm>
249 <indexterm role="concept">
250 <primary>change log</primary>
251 </indexterm>
252 As the program develops, there may be features in newer versions that have not
253 yet made it into this document, which is updated only when the most significant
254 digit of the fractional part of the version number changes. Specifications of
255 new features that are not yet in this manual are placed in the file
256 <filename>doc/NewStuff</filename> in the Exim distribution.
257 </para>
258 <para>
259 Some features may be classified as <quote>experimental</quote>. These may change
260 incompatibly while they are developing, or even be withdrawn. For this reason,
261 they are not documented in this manual. Information about experimental features
262 can be found in the file <filename>doc/experimental.txt</filename>.
263 </para>
264 <para>
265 All changes to the program (whether new features, bug fixes, or other kinds of
266 change) are noted briefly in the file called <filename>doc/ChangeLog</filename>.
267 </para>
268 <para>
269 <indexterm role="concept">
270 <primary><filename>doc/spec.txt</filename></primary>
271 </indexterm>
272 This specification itself is available as an ASCII file in <filename>doc/spec.txt</filename> so
273 that it can easily be searched with a text editor. Other files in the <filename>doc</filename>
274 directory are:
275 </para>
276 <informaltable frame="none">
277 <tgroup cols="2" colsep="0" rowsep="0">
278 <colspec colwidth="100pt" align="left"/>
279 <colspec colwidth="254pt" align="left"/>
280 <tbody>
281 <row>
282 <entry><filename>OptionLists.txt</filename></entry>
283 <entry>list of all options in alphabetical order</entry>
284 </row>
285 <row>
286 <entry><filename>dbm.discuss.txt</filename></entry>
287 <entry>discussion about DBM libraries</entry>
288 </row>
289 <row>
290 <entry><filename>exim.8</filename></entry>
291 <entry>a man page of Exim&#x2019;s command line options</entry>
292 </row>
293 <row>
294 <entry><filename>experimental.txt</filename></entry>
295 <entry>documentation of experimental features</entry>
296 </row>
297 <row>
298 <entry><filename>filter.txt</filename></entry>
299 <entry>specification of the filter language</entry>
300 </row>
301 <row>
302 <entry><filename>Exim3.upgrade</filename></entry>
303 <entry>upgrade notes from release 2 to release 3</entry>
304 </row>
305 <row>
306 <entry><filename>Exim4.upgrade</filename></entry>
307 <entry>upgrade notes from release 3 to release 4</entry>
308 </row>
309 </tbody>
310 </tgroup>
311 </informaltable>
312 <para>
313 The main specification and the specification of the filtering language are also
314 available in other formats (HTML, PostScript, PDF, and Texinfo). Section
315 <xref linkend="SECTavail"/> below tells you how to get hold of these.
316 </para>
317 </section>
318 <section id="SECID2">
319 <title>FTP and web sites</title>
320 <para>
321 <indexterm role="concept">
322 <primary>web site</primary>
323 </indexterm>
324 <indexterm role="concept">
325 <primary>FTP site</primary>
326 </indexterm>
327 The primary site for Exim source distributions is currently the University of
328 Cambridge&#x2019;s FTP site, whose contents are described in <emphasis>Where to find the Exim
329 distribution</emphasis> below. In addition, there is a web site and an FTP site at
330 <option>exim.org</option>. These are now also hosted at the University of Cambridge. The
331 <option>exim.org</option> site was previously hosted for a number of years by Energis
332 Squared, formerly Planet Online Ltd, whose support I gratefully acknowledge.
333 </para>
334 <para>
335 <indexterm role="concept">
336 <primary>wiki</primary>
337 </indexterm>
338 <indexterm role="concept">
339 <primary>FAQ</primary>
340 </indexterm>
341 As well as Exim distribution tar files, the Exim web site contains a number of
342 differently formatted versions of the documentation. A recent addition to the
343 online information is the Exim wiki (<emphasis role="bold"><ulink url="http://wiki.exim.org">http://wiki.exim.org</ulink></emphasis>),
344 which contains what used to be a separate FAQ, as well as various other
345 examples, tips, and know-how that have been contributed by Exim users.
346 </para>
347 <para>
348 <indexterm role="concept">
349 <primary>Bugzilla</primary>
350 </indexterm>
351 An Exim Bugzilla exists at <emphasis role="bold"><ulink url="http://bugs.exim.org">http://bugs.exim.org</ulink></emphasis>. You can use
352 this to report bugs, and also to add items to the wish list. Please search
353 first to check that you are not duplicating a previous entry.
354 </para>
355 </section>
356 <section id="SECID3">
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 Exim mailing lists exist:
364 </para>
365 <informaltable frame="none">
366 <tgroup cols="2" colsep="0" rowsep="0">
367 <colspec colwidth="140pt" align="left"/>
368 <colspec colwidth="254pt" 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 <row>
383 <entry><emphasis>exim-future@exim.org</emphasis></entry>
384 <entry>Discussion of long-term development</entry>
385 </row>
386 </tbody>
387 </tgroup>
388 </informaltable>
389 <para>
390 You can subscribe to these lists, change your existing subscriptions, and view
391 or search the archives via the mailing lists link on the Exim home page.
392 <indexterm role="concept">
393 <primary>Debian</primary>
394 <secondary>mailing list for</secondary>
395 </indexterm>
396 If you are using a Debian distribution of Exim, you may wish to subscribe to
397 the Debian-specific mailing list <emphasis>pkg-exim4-users@lists.alioth.debian.org</emphasis>
398 via this web page:
399 </para>
400 <literallayout>
401 <emphasis role="bold"><ulink url="http://lists.alioth.debian.org/mailman/listinfo/pkg-exim4-users">http://lists.alioth.debian.org/mailman/listinfo/pkg-exim4-users</ulink></emphasis>
402 </literallayout>
403 <para>
404 Please ask Debian-specific questions on this list and not on the general Exim
405 lists.
406 </para>
407 </section>
408 <section id="SECID4">
409 <title>Exim training</title>
410 <para>
411 <indexterm role="concept">
412 <primary>training courses</primary>
413 </indexterm>
414 Training courses in Cambridge (UK) used to be run annually by the author of
415 Exim, before he retired. At the time of writing, there are no plans to run
416 further Exim courses in Cambridge. However, if that changes, relevant
417 information will be posted at <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>.
418 </para>
419 </section>
420 <section id="SECID5">
421 <title>Bug reports</title>
422 <para>
423 <indexterm role="concept">
424 <primary>bug reports</primary>
425 </indexterm>
426 <indexterm role="concept">
427 <primary>reporting bugs</primary>
428 </indexterm>
429 Reports of obvious bugs can be emailed to <emphasis>bugs@exim.org</emphasis> or reported
430 via the Bugzilla (<emphasis role="bold"><ulink url="http://bugs.exim.org">http://bugs.exim.org</ulink></emphasis>). However, if you are unsure
431 whether some behaviour is a bug or not, the best thing to do is to post a
432 message to the <emphasis>exim-dev</emphasis> mailing list and have it discussed.
433 </para>
434 </section>
435 <section id="SECTavail">
436 <title>Where to find the Exim distribution</title>
437 <para>
438 <indexterm role="concept">
439 <primary>FTP site</primary>
440 </indexterm>
441 <indexterm role="concept">
442 <primary>distribution</primary>
443 <secondary>ftp site</secondary>
444 </indexterm>
445 The master ftp site for the Exim distribution is
446 </para>
447 <literallayout>
448 <emphasis role="bold">ftp://ftp.csx.cam.ac.uk/pub/software/email/exim</emphasis>
449 </literallayout>
450 <para>
451 This is mirrored by
452 </para>
453 <literallayout>
454 <emphasis role="bold">ftp://ftp.exim.org/pub/exim</emphasis>
455 </literallayout>
456 <para>
457 The file references that follow are relative to the <filename>exim</filename> directories at
458 these sites. There are now quite a number of independent mirror sites around
459 the world. Those that I know about are listed in the file called <filename>Mirrors</filename>.
460 </para>
461 <para>
462 Within the <filename>exim</filename> directory there are subdirectories called <filename>exim3</filename> (for
463 previous Exim 3 distributions), <filename>exim4</filename> (for the latest Exim 4
464 distributions), and <filename>Testing</filename> for testing versions. In the <filename>exim4</filename>
465 subdirectory, the current release can always be found in files called
466 </para>
467 <literallayout>
468 <filename>exim-n.nn.tar.gz</filename>
469 <filename>exim-n.nn.tar.bz2</filename>
470 </literallayout>
471 <para>
472 where <emphasis>n.nn</emphasis> is the highest such version number in the directory. The two
473 files contain identical data; the only difference is the type of compression.
474 The <filename>.bz2</filename> file is usually a lot smaller than the <filename>.gz</filename> file.
475 </para>
476 <para>
477 <indexterm role="concept">
478 <primary>distribution</primary>
479 <secondary>signing details</secondary>
480 </indexterm>
481 <indexterm role="concept">
482 <primary>distribution</primary>
483 <secondary>public key</secondary>
484 </indexterm>
485 <indexterm role="concept">
486 <primary>public key for signed distribution</primary>
487 </indexterm>
488 The distributions are currently signed with Nigel Metheringham&#x2019;s GPG key. The
489 corresponding public key is available from a number of keyservers, and there is
490 also a copy in the file <filename>nigel-pubkey.asc</filename>. The signatures for the tar bundles are
491 in:
492 </para>
493 <literallayout>
494 <filename>exim-n.nn.tar.gz.asc</filename>
495 <filename>exim-n.nn.tar.bz2.asc</filename>
496 </literallayout>
497 <para>
498 For each released version, the log of changes is made separately available in a
499 separate file in the directory <filename>ChangeLogs</filename> so that it is possible to
500 find out what has changed without having to download the entire distribution.
501 </para>
502 <para>
503 <indexterm role="concept">
504 <primary>documentation</primary>
505 <secondary>available formats</secondary>
506 </indexterm>
507 The main distribution contains ASCII versions of this specification and other
508 documentation; other formats of the documents are available in separate files
509 inside the <filename>exim4</filename> directory of the FTP site:
510 </para>
511 <literallayout>
512 <filename>exim-html-n.nn.tar.gz</filename>
513 <filename>exim-pdf-n.nn.tar.gz</filename>
514 <filename>exim-postscript-n.nn.tar.gz</filename>
515 <filename>exim-texinfo-n.nn.tar.gz</filename>
516 </literallayout>
517 <para>
518 These tar files contain only the <filename>doc</filename> directory, not the complete
519 distribution, and are also available in <filename>.bz2</filename> as well as <filename>.gz</filename> forms.
520 </para>
521 </section>
522 <section id="SECID6">
523 <title>Limitations</title>
524 <itemizedlist>
525 <listitem>
526 <para>
527 <indexterm role="concept">
528 <primary>limitations of Exim</primary>
529 </indexterm>
530 <indexterm role="concept">
531 <primary>bang paths</primary>
532 <secondary>not handled by Exim</secondary>
533 </indexterm>
534 Exim is designed for use as an Internet MTA, and therefore handles addresses in
535 RFC 2822 domain format only. It cannot handle UUCP <quote>bang paths</quote>, though
536 simple two-component bang paths can be converted by a straightforward rewriting
537 configuration. This restriction does not prevent Exim from being interfaced to
538 UUCP as a transport mechanism, provided that domain addresses are used.
539 </para>
540 </listitem>
541 <listitem>
542 <para>
543 <indexterm role="concept">
544 <primary>domainless addresses</primary>
545 </indexterm>
546 <indexterm role="concept">
547 <primary>address</primary>
548 <secondary>without domain</secondary>
549 </indexterm>
550 Exim insists that every address it handles has a domain attached. For incoming
551 local messages, domainless addresses are automatically qualified with a
552 configured domain value. Configuration options specify from which remote
553 systems unqualified addresses are acceptable. These are then qualified on
554 arrival.
555 </para>
556 </listitem>
557 <listitem>
558 <para>
559 <indexterm role="concept">
560 <primary>transport</primary>
561 <secondary>external</secondary>
562 </indexterm>
563 <indexterm role="concept">
564 <primary>external transports</primary>
565 </indexterm>
566 The only external transport mechanisms that are currently implemented are SMTP
567 and LMTP over a TCP/IP network (including support for IPv6). However, a pipe
568 transport is available, and there are facilities for writing messages to files
569 and pipes, optionally in <emphasis>batched SMTP</emphasis> format; these facilities can be used
570 to send messages to other transport mechanisms such as UUCP, provided they can
571 handle domain-style addresses. Batched SMTP input is also catered for.
572 </para>
573 </listitem>
574 <listitem>
575 <para>
576 Exim is not designed for storing mail for dial-in hosts. When the volumes of
577 such mail are large, it is better to get the messages <quote>delivered</quote> into files
578 (that is, off Exim&#x2019;s queue) and subsequently passed on to the dial-in hosts by
579 other means.
580 </para>
581 </listitem>
582 <listitem>
583 <para>
584 Although Exim does have basic facilities for scanning incoming messages, these
585 are not comprehensive enough to do full virus or spam scanning. Such operations
586 are best carried out using additional specialized software packages. If you
587 compile Exim with the content-scanning extension, straightforward interfaces to
588 a number of common scanners are provided.
589 </para>
590 </listitem>
591 </itemizedlist>
592 </section>
593 <section id="SECID7">
594 <title>Run time configuration</title>
595 <para>
596 Exim&#x2019;s run time configuration is held in a single text file that is divided
597 into a number of sections. The entries in this file consist of keywords and
598 values, in the style of Smail 3 configuration files. A default configuration
599 file which is suitable for simple online installations is provided in the
600 distribution, and is described in chapter <xref linkend="CHAPdefconfil"/> below.
601 </para>
602 </section>
603 <section id="SECID8">
604 <title>Calling interface</title>
605 <para>
606 <indexterm role="concept">
607 <primary>Sendmail compatibility</primary>
608 <secondary>command line interface</secondary>
609 </indexterm>
610 Like many MTAs, Exim has adopted the Sendmail command line interface so that it
611 can be a straight replacement for <filename>/usr/lib/sendmail</filename> or
612 <filename>/usr/sbin/sendmail</filename> when sending mail, but you do not need to know anything
613 about Sendmail in order to run Exim. For actions other than sending messages,
614 Sendmail-compatible options also exist, but those that produce output (for
615 example, <option>-bp</option>, which lists the messages on the queue) do so in Exim&#x2019;s own
616 format. There are also some additional options that are compatible with Smail
617 3, and some further options that are new to Exim. Chapter <xref linkend="CHAPcommandline"/>
618 documents all Exim&#x2019;s command line options. This information is automatically
619 made into the man page that forms part of the Exim distribution.
620 </para>
621 <para>
622 Control of messages on the queue can be done via certain privileged command
623 line options. There is also an optional monitor program called <emphasis>eximon</emphasis>,
624 which displays current information in an X window, and which contains a menu
625 interface to Exim&#x2019;s command line administration options.
626 </para>
627 </section>
628 <section id="SECID9">
629 <title>Terminology</title>
630 <para>
631 <indexterm role="concept">
632 <primary>terminology definitions</primary>
633 </indexterm>
634 <indexterm role="concept">
635 <primary>body of message</primary>
636 <secondary>definition of</secondary>
637 </indexterm>
638 The <emphasis>body</emphasis> of a message is the actual data that the sender wants to transmit.
639 It is the last part of a message, and is separated from the <emphasis>header</emphasis> (see
640 below) by a blank line.
641 </para>
642 <para>
643 <indexterm role="concept">
644 <primary>bounce message</primary>
645 <secondary>definition of</secondary>
646 </indexterm>
647 When a message cannot be delivered, it is normally returned to the sender in a
648 delivery failure message or a <quote>non-delivery report</quote> (NDR). The term
649 <emphasis>bounce</emphasis> is commonly used for this action, and the error reports are often
650 called <emphasis>bounce messages</emphasis>. This is a convenient shorthand for <quote>delivery
651 failure error report</quote>. Such messages have an empty sender address in the
652 message&#x2019;s <emphasis>envelope</emphasis> (see below) to ensure that they cannot themselves give
653 rise to further bounce messages.
654 </para>
655 <para>
656 The term <emphasis>default</emphasis> appears frequently in this manual. It is used to qualify a
657 value which is used in the absence of any setting in the configuration. It may
658 also qualify an action which is taken unless a configuration setting specifies
659 otherwise.
660 </para>
661 <para>
662 The term <emphasis>defer</emphasis> is used when the delivery of a message to a specific
663 destination cannot immediately take place for some reason (a remote host may be
664 down, or a user&#x2019;s local mailbox may be full). Such deliveries are <emphasis>deferred</emphasis>
665 until a later time.
666 </para>
667 <para>
668 The word <emphasis>domain</emphasis> is sometimes used to mean all but the first component of a
669 host&#x2019;s name. It is <emphasis>not</emphasis> used in that sense here, where it normally refers to
670 the part of an email address following the @ sign.
671 </para>
672 <para>
673 <indexterm role="concept">
674 <primary>envelope, definition of</primary>
675 </indexterm>
676 <indexterm role="concept">
677 <primary>sender</primary>
678 <secondary>definition of</secondary>
679 </indexterm>
680 A message in transit has an associated <emphasis>envelope</emphasis>, as well as a header and a
681 body. The envelope contains a sender address (to which bounce messages should
682 be delivered), and any number of recipient addresses. References to the
683 sender or the recipients of a message usually mean the addresses in the
684 envelope. An MTA uses these addresses for delivery, and for returning bounce
685 messages, not the addresses that appear in the header lines.
686 </para>
687 <para>
688 <indexterm role="concept">
689 <primary>message</primary>
690 <secondary>header, definition of</secondary>
691 </indexterm>
692 <indexterm role="concept">
693 <primary>header section</primary>
694 <secondary>definition of</secondary>
695 </indexterm>
696 The <emphasis>header</emphasis> of a message is the first part of a message&#x2019;s text, consisting
697 of a number of lines, each of which has a name such as <emphasis>From:</emphasis>, <emphasis>To:</emphasis>,
698 <emphasis>Subject:</emphasis>, etc. Long header lines can be split over several text lines by
699 indenting the continuations. The header is separated from the body by a blank
700 line.
701 </para>
702 <para>
703 <indexterm role="concept">
704 <primary>local part</primary>
705 <secondary>definition of</secondary>
706 </indexterm>
707 <indexterm role="concept">
708 <primary>domain</primary>
709 <secondary>definition of</secondary>
710 </indexterm>
711 The term <emphasis>local part</emphasis>, which is taken from RFC 2822, is used to refer to that
712 part of an email address that precedes the @ sign. The part that follows the
713 @ sign is called the <emphasis>domain</emphasis> or <emphasis>mail domain</emphasis>.
714 </para>
715 <para>
716 <indexterm role="concept">
717 <primary>local delivery</primary>
718 <secondary>definition of</secondary>
719 </indexterm>
720 <indexterm role="concept">
721 <primary>remote delivery, definition of</primary>
722 </indexterm>
723 The terms <emphasis>local delivery</emphasis> and <emphasis>remote delivery</emphasis> are used to distinguish
724 delivery to a file or a pipe on the local host from delivery by SMTP over
725 TCP/IP to another host. As far as Exim is concerned, all hosts other than the
726 host it is running on are <emphasis>remote</emphasis>.
727 </para>
728 <para>
729 <indexterm role="concept">
730 <primary>return path</primary>
731 <secondary>definition of</secondary>
732 </indexterm>
733 <emphasis>Return path</emphasis> is another name that is used for the sender address in a
734 message&#x2019;s envelope.
735 </para>
736 <para>
737 <indexterm role="concept">
738 <primary>queue</primary>
739 <secondary>definition of</secondary>
740 </indexterm>
741 The term <emphasis>queue</emphasis> is used to refer to the set of messages awaiting delivery,
742 because this term is in widespread use in the context of MTAs. However, in
743 Exim&#x2019;s case the reality is more like a pool than a queue, because there is
744 normally no ordering of waiting messages.
745 </para>
746 <para>
747 <indexterm role="concept">
748 <primary>queue runner</primary>
749 <secondary>definition of</secondary>
750 </indexterm>
751 The term <emphasis>queue runner</emphasis> is used to describe a process that scans the queue
752 and attempts to deliver those messages whose retry times have come. This term
753 is used by other MTAs, and also relates to the command <option>runq</option>, but in Exim
754 the waiting messages are normally processed in an unpredictable order.
755 </para>
756 <para>
757 <indexterm role="concept">
758 <primary>spool directory</primary>
759 <secondary>definition of</secondary>
760 </indexterm>
761 The term <emphasis>spool directory</emphasis> is used for a directory in which Exim keeps the
762 messages on its queue &ndash; that is, those that it is in the process of
763 delivering. This should not be confused with the directory in which local
764 mailboxes are stored, which is called a <quote>spool directory</quote> by some people. In
765 the Exim documentation, <quote>spool</quote> is always used in the first sense.
766 </para>
767 </section>
768 </chapter>
769
770 <chapter id="CHID2">
771 <title>Incorporated code</title>
772 <para>
773 <indexterm role="concept">
774 <primary>incorporated code</primary>
775 </indexterm>
776 <indexterm role="concept">
777 <primary>regular expressions</primary>
778 <secondary>library</secondary>
779 </indexterm>
780 <indexterm role="concept">
781 <primary>PCRE</primary>
782 </indexterm>
783 A number of pieces of external code are included in the Exim distribution.
784 </para>
785 <itemizedlist>
786 <listitem>
787 <para>
788 Regular expressions are supported in the main Exim program and in the
789 Exim monitor using the freely-distributable PCRE library, copyright
790 &copy; University of Cambridge. The source to PCRE is no longer shipped with
791 Exim, so you will need to use the version of PCRE shipped with your system,
792 or obtain and install the full version of the library from
793 <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>.
794 </para>
795 </listitem>
796 <listitem>
797 <para>
798 <indexterm role="concept">
799 <primary>cdb</primary>
800 <secondary>acknowledgment</secondary>
801 </indexterm>
802 Support for the cdb (Constant DataBase) lookup method is provided by code
803 contributed by Nigel Metheringham of (at the time he contributed it) Planet
804 Online Ltd. The implementation is completely contained within the code of Exim.
805 It does not link against an external cdb library. The code contains the
806 following statements:
807 </para>
808 <blockquote>
809 <para>
810 Copyright &copy; 1998 Nigel Metheringham, Planet Online Ltd
811 </para>
812 <para>
813 This program is free software; you can redistribute it and/or modify it under
814 the terms of the GNU General Public License as published by the Free Software
815 Foundation; either version 2 of the License, or (at your option) any later
816 version.
817 This code implements Dan Bernstein&#x2019;s Constant DataBase (cdb) spec. Information,
818 the spec and sample code for cdb can be obtained from
819 <emphasis role="bold"><ulink url="http://www.pobox.com/~djb/cdb.html">http://www.pobox.com/~djb/cdb.html</ulink></emphasis>. This implementation borrows
820 some code from Dan Bernstein&#x2019;s implementation (which has no license
821 restrictions applied to it).
822 </para>
823 </blockquote>
824 </listitem>
825 <listitem>
826 <para>
827 <indexterm role="concept">
828 <primary>SPA authentication</primary>
829 </indexterm>
830 <indexterm role="concept">
831 <primary>Samba project</primary>
832 </indexterm>
833 <indexterm role="concept">
834 <primary>Microsoft Secure Password Authentication</primary>
835 </indexterm>
836 Client support for Microsoft&#x2019;s <emphasis>Secure Password Authentication</emphasis> is provided
837 by code contributed by Marc Prud&#x2019;hommeaux. Server support was contributed by
838 Tom Kistner. This includes code taken from the Samba project, which is released
839 under the Gnu GPL.
840 </para>
841 </listitem>
842 <listitem>
843 <para>
844 <indexterm role="concept">
845 <primary>Cyrus</primary>
846 </indexterm>
847 <indexterm role="concept">
848 <primary><emphasis>pwcheck</emphasis> daemon</primary>
849 </indexterm>
850 <indexterm role="concept">
851 <primary><emphasis>pwauthd</emphasis> daemon</primary>
852 </indexterm>
853 Support for calling the Cyrus <emphasis>pwcheck</emphasis> and <emphasis>saslauthd</emphasis> daemons is provided
854 by code taken from the Cyrus-SASL library and adapted by Alexander S.
855 Sabourenkov. The permission notice appears below, in accordance with the
856 conditions expressed therein.
857 </para>
858 <blockquote>
859 <para>
860 Copyright &copy; 2001 Carnegie Mellon University.  All rights reserved.
861 </para>
862 <para>
863 Redistribution and use in source and binary forms, with or without
864 modification, are permitted provided that the following conditions
865 are met:
866 </para>
867 <orderedlist numeration="arabic">
868 <listitem>
869 <para>
870 Redistributions of source code must retain the above copyright
871 notice, this list of conditions and the following disclaimer.
872 </para>
873 </listitem>
874 <listitem>
875 <para>
876 Redistributions in binary form must reproduce the above copyright
877 notice, this list of conditions and the following disclaimer in
878 the documentation and/or other materials provided with the
879 distribution.
880 </para>
881 </listitem>
882 <listitem>
883 <para>
884 The name <quote>Carnegie Mellon University</quote> must not be used to
885 endorse or promote products derived from this software without
886 prior written permission. For permission or any other legal
887 details, please contact
888 </para>
889 <literallayout>
890               Office of Technology Transfer
891               Carnegie Mellon University
892               5000 Forbes Avenue
893               Pittsburgh, PA  15213-3890
894               (412) 268-4387, fax: (412) 268-7395
895               tech-transfer@andrew.cmu.edu
896 </literallayout>
897 </listitem>
898 <listitem>
899 <para>
900 Redistributions of any form whatsoever must retain the following
901 acknowledgment:
902 </para>
903 <para>
904 <quote>This product includes software developed by Computing Services
905 at Carnegie Mellon University (<emphasis role="bold"><ulink url="http://www.cmu.edu/computing/">http://www.cmu.edu/computing/</ulink></emphasis>.</quote>
906 </para>
907 <para>
908 CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
909 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
910 AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
911 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
912 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
913 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
914 OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
915 </para>
916 </listitem>
917 </orderedlist>
918 </blockquote>
919 </listitem>
920 <listitem>
921 <para>
922 <indexterm role="concept">
923 <primary>Exim monitor</primary>
924 <secondary>acknowledgment</secondary>
925 </indexterm>
926 <indexterm role="concept">
927 <primary>X-windows</primary>
928 </indexterm>
929 <indexterm role="concept">
930 <primary>Athena</primary>
931 </indexterm>
932 The Exim Monitor program, which is an X-Window application, includes
933 modified versions of the Athena StripChart and TextPop widgets.
934 This code is copyright by DEC and MIT, and their permission notice appears
935 below, in accordance with the conditions expressed therein.
936 </para>
937 <blockquote>
938 <para>
939 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
940 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
941 </para>
942 <para>
943 All Rights Reserved
944 </para>
945 <para>
946 Permission to use, copy, modify, and distribute this software and its
947 documentation for any purpose and without fee is hereby granted,
948 provided that the above copyright notice appear in all copies and that
949 both that copyright notice and this permission notice appear in
950 supporting documentation, and that the names of Digital or MIT not be
951 used in advertising or publicity pertaining to distribution of the
952 software without specific, written prior permission.
953 </para>
954 <para>
955 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
956 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
957 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
958 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
959 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
960 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
961 SOFTWARE.
962 </para>
963 </blockquote>
964 </listitem>
965 <listitem>
966 <para>
967 Many people have contributed code fragments, some large, some small, that were
968 not covered by any specific licence requirements. It is assumed that the
969 contributors are happy to see their code incorporated into Exim under the GPL.
970 </para>
971 </listitem>
972 </itemizedlist>
973 </chapter>
974
975 <chapter id="CHID11">
976 <title>How Exim receives and delivers mail</title>
977 <titleabbrev>Receiving and delivering mail</titleabbrev>
978 <section id="SECID10">
979 <title>Overall philosophy</title>
980 <para>
981 <indexterm role="concept">
982 <primary>design philosophy</primary>
983 </indexterm>
984 Exim is designed to work efficiently on systems that are permanently connected
985 to the Internet and are handling a general mix of mail. In such circumstances,
986 most messages can be delivered immediately. Consequently, Exim does not
987 maintain independent queues of messages for specific domains or hosts, though
988 it does try to send several messages in a single SMTP connection after a host
989 has been down, and it also maintains per-host retry information.
990 </para>
991 </section>
992 <section id="SECID11">
993 <title>Policy control</title>
994 <para>
995 <indexterm role="concept">
996 <primary>policy control</primary>
997 <secondary>overview</secondary>
998 </indexterm>
999 Policy controls are now an important feature of MTAs that are connected to the
1000 Internet. Perhaps their most important job is to stop MTAs being abused as
1001 <quote>open relays</quote> by misguided individuals who send out vast amounts of
1002 unsolicited junk, and want to disguise its source. Exim provides flexible
1003 facilities for specifying policy controls on incoming mail:
1004 </para>
1005 <itemizedlist>
1006 <listitem>
1007 <para>
1008 <indexterm role="concept">
1009 <primary>access control lists (ACLs)</primary>
1010 <secondary>introduction</secondary>
1011 </indexterm>
1012 Exim 4 (unlike previous versions of Exim) implements policy controls on
1013 incoming mail by means of <emphasis>Access Control Lists</emphasis> (ACLs). Each list is a
1014 series of statements that may either grant or deny access. ACLs can be used at
1015 several places in the SMTP dialogue while receiving a message from a remote
1016 host. However, the most common places are after each RCPT command, and at the
1017 very end of the message. The sysadmin can specify conditions for accepting or
1018 rejecting individual recipients or the entire message, respectively, at these
1019 two points (see chapter <xref linkend="CHAPACL"/>). Denial of access results in an SMTP
1020 error code.
1021 </para>
1022 </listitem>
1023 <listitem>
1024 <para>
1025 An ACL is also available for locally generated, non-SMTP messages. In this
1026 case, the only available actions are to accept or deny the entire message.
1027 </para>
1028 </listitem>
1029 <listitem>
1030 <para>
1031 When Exim is compiled with the content-scanning extension, facilities are
1032 provided in the ACL mechanism for passing the message to external virus and/or
1033 spam scanning software. The result of such a scan is passed back to the ACL,
1034 which can then use it to decide what to do with the message.
1035 </para>
1036 </listitem>
1037 <listitem>
1038 <para>
1039 When a message has been received, either from a remote host or from the local
1040 host, but before the final acknowledgment has been sent, a locally supplied C
1041 function called <function>local_scan()</function> can be run to inspect the message and decide
1042 whether to accept it or not (see chapter <xref linkend="CHAPlocalscan"/>). If the message
1043 is accepted, the list of recipients can be modified by the function.
1044 </para>
1045 </listitem>
1046 <listitem>
1047 <para>
1048 Using the <function>local_scan()</function> mechanism is another way of calling external scanner
1049 software. The <option>SA-Exim</option> add-on package works this way. It does not require
1050 Exim to be compiled with the content-scanning extension.
1051 </para>
1052 </listitem>
1053 <listitem>
1054 <para>
1055 After a message has been accepted, a further checking mechanism is available in
1056 the form of the <emphasis>system filter</emphasis> (see chapter <xref linkend="CHAPsystemfilter"/>). This
1057 runs at the start of every delivery process.
1058 </para>
1059 </listitem>
1060 </itemizedlist>
1061 </section>
1062 <section id="SECID12">
1063 <title>User filters</title>
1064 <para>
1065 <indexterm role="concept">
1066 <primary>filter</primary>
1067 <secondary>introduction</secondary>
1068 </indexterm>
1069 <indexterm role="concept">
1070 <primary>Sieve filter</primary>
1071 </indexterm>
1072 In a conventional Exim configuration, users are able to run private filters by
1073 setting up appropriate <filename>.forward</filename> files in their home directories. See
1074 chapter <xref linkend="CHAPredirect"/> (about the <command>redirect</command> router) for the
1075 configuration needed to support this, and the separate document entitled
1076 <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis> for user details. Two different kinds
1077 of filtering are available:
1078 </para>
1079 <itemizedlist>
1080 <listitem>
1081 <para>
1082 Sieve filters are written in the standard filtering language that is defined
1083 by RFC 3028.
1084 </para>
1085 </listitem>
1086 <listitem>
1087 <para>
1088 Exim filters are written in a syntax that is unique to Exim, but which is more
1089 powerful than Sieve, which it pre-dates.
1090 </para>
1091 </listitem>
1092 </itemizedlist>
1093 <para>
1094 User filters are run as part of the routing process, described below.
1095 </para>
1096 </section>
1097 <section id="SECTmessiden">
1098 <title>Message identification</title>
1099 <para>
1100 <indexterm role="concept">
1101 <primary>message ids</primary>
1102 <secondary>details of format</secondary>
1103 </indexterm>
1104 <indexterm role="concept">
1105 <primary>format</primary>
1106 <secondary>of message id</secondary>
1107 </indexterm>
1108 <indexterm role="concept">
1109 <primary>id of message</primary>
1110 </indexterm>
1111 <indexterm role="concept">
1112 <primary>base62</primary>
1113 </indexterm>
1114 <indexterm role="concept">
1115 <primary>base36</primary>
1116 </indexterm>
1117 <indexterm role="concept">
1118 <primary>Darwin</primary>
1119 </indexterm>
1120 <indexterm role="concept">
1121 <primary>Cygwin</primary>
1122 </indexterm>
1123 Every message handled by Exim is given a <emphasis>message id</emphasis> which is sixteen
1124 characters long. It is divided into three parts, separated by hyphens, for
1125 example <literal>16VDhn-0001bo-D3</literal>. Each part is a sequence of letters and digits,
1126 normally encoding numbers in base 62. However, in the Darwin operating
1127 system (Mac OS X) and when Exim is compiled to run under Cygwin, base 36
1128 (avoiding the use of lower case letters) is used instead, because the message
1129 id is used to construct file names, and the names of files in those systems are
1130 not always case-sensitive.
1131 </para>
1132 <para>
1133 <indexterm role="concept">
1134 <primary>pid (process id)</primary>
1135 <secondary>re-use of</secondary>
1136 </indexterm>
1137 The detail of the contents of the message id have changed as Exim has evolved.
1138 Earlier versions relied on the operating system not re-using a process id (pid)
1139 within one second. On modern operating systems, this assumption can no longer
1140 be made, so the algorithm had to be changed. To retain backward compatibility,
1141 the format of the message id was retained, which is why the following rules are
1142 somewhat eccentric:
1143 </para>
1144 <itemizedlist>
1145 <listitem>
1146 <para>
1147 The first six characters of the message id are the time at which the message
1148 started to be received, to a granularity of one second. That is, this field
1149 contains the number of seconds since the start of the epoch (the normal Unix
1150 way of representing the date and time of day).
1151 </para>
1152 </listitem>
1153 <listitem>
1154 <para>
1155 After the first hyphen, the next six characters are the id of the process that
1156 received the message.
1157 </para>
1158 </listitem>
1159 <listitem>
1160 <para>
1161 There are two different possibilities for the final two characters:
1162 </para>
1163 <orderedlist numeration="arabic">
1164 <listitem>
1165 <para>
1166 <indexterm role="option">
1167 <primary><option>localhost_number</option></primary>
1168 </indexterm>
1169 If <option>localhost_number</option> is not set, this value is the fractional part of the
1170 time of reception, normally in units of 1/2000 of a second, but for systems
1171 that must use base 36 instead of base 62 (because of case-insensitive file
1172 systems), the units are 1/1000 of a second.
1173 </para>
1174 </listitem>
1175 <listitem>
1176 <para>
1177 If <option>localhost_number</option> is set, it is multiplied by 200 (100) and added to
1178 the fractional part of the time, which in this case is in units of 1/200
1179 (1/100) of a second.
1180 </para>
1181 </listitem>
1182 </orderedlist>
1183 </listitem>
1184 </itemizedlist>
1185 <para>
1186 After a message has been received, Exim waits for the clock to tick at the
1187 appropriate resolution before proceeding, so that if another message is
1188 received by the same process, or by another process with the same (re-used)
1189 pid, it is guaranteed that the time will be different. In most cases, the clock
1190 will already have ticked while the message was being received.
1191 </para>
1192 </section>
1193 <section id="SECID13">
1194 <title>Receiving mail</title>
1195 <para>
1196 <indexterm role="concept">
1197 <primary>receiving mail</primary>
1198 </indexterm>
1199 <indexterm role="concept">
1200 <primary>message</primary>
1201 <secondary>reception</secondary>
1202 </indexterm>
1203 The only way Exim can receive mail from another host is using SMTP over
1204 TCP/IP, in which case the sender and recipient addresses are transferred using
1205 SMTP commands. However, from a locally running process (such as a user&#x2019;s MUA),
1206 there are several possibilities:
1207 </para>
1208 <itemizedlist>
1209 <listitem>
1210 <para>
1211 If the process runs Exim with the <option>-bm</option> option, the message is read
1212 non-interactively (usually via a pipe), with the recipients taken from the
1213 command line, or from the body of the message if <option>-t</option> is also used.
1214 </para>
1215 </listitem>
1216 <listitem>
1217 <para>
1218 If the process runs Exim with the <option>-bS</option> option, the message is also read
1219 non-interactively, but in this case the recipients are listed at the start of
1220 the message in a series of SMTP RCPT commands, terminated by a DATA
1221 command. This is so-called <quote>batch SMTP</quote> format,
1222 but it isn&#x2019;t really SMTP. The SMTP commands are just another way of passing
1223 envelope addresses in a non-interactive submission.
1224 </para>
1225 </listitem>
1226 <listitem>
1227 <para>
1228 If the process runs Exim with the <option>-bs</option> option, the message is read
1229 interactively, using the SMTP protocol. A two-way pipe is normally used for
1230 passing data between the local process and the Exim process.
1231 This is <quote>real</quote> SMTP and is handled in the same way as SMTP over TCP/IP. For
1232 example, the ACLs for SMTP commands are used for this form of submission.
1233 </para>
1234 </listitem>
1235 <listitem>
1236 <para>
1237 A local process may also make a TCP/IP call to the host&#x2019;s loopback address
1238 (127.0.0.1) or any other of its IP addresses. When receiving messages, Exim
1239 does not treat the loopback address specially. It treats all such connections
1240 in the same way as connections from other hosts.
1241 </para>
1242 </listitem>
1243 </itemizedlist>
1244 <para>
1245 <indexterm role="concept">
1246 <primary>message sender, constructed by Exim</primary>
1247 </indexterm>
1248 <indexterm role="concept">
1249 <primary>sender</primary>
1250 <secondary>constructed by Exim</secondary>
1251 </indexterm>
1252 In the three cases that do not involve TCP/IP, the sender address is
1253 constructed from the login name of the user that called Exim and a default
1254 qualification domain (which can be set by the <option>qualify_domain</option> configuration
1255 option). For local or batch SMTP, a sender address that is passed using the
1256 SMTP MAIL command is ignored. However, the system administrator may allow
1257 certain users (<quote>trusted users</quote>) to specify a different sender address
1258 unconditionally, or all users to specify certain forms of different sender
1259 address. The <option>-f</option> option or the SMTP MAIL command is used to specify these
1260 different addresses. See section <xref linkend="SECTtrustedadmin"/> for details of trusted
1261 users, and the <option>untrusted_set_sender</option> option for a way of allowing untrusted
1262 users to change sender addresses.
1263 </para>
1264 <para>
1265 Messages received by either of the non-interactive mechanisms are subject to
1266 checking by the non-SMTP ACL, if one is defined. Messages received using SMTP
1267 (either over TCP/IP, or interacting with a local process) can be checked by a
1268 number of ACLs that operate at different times during the SMTP session. Either
1269 individual recipients, or the entire message, can be rejected if local policy
1270 requirements are not met. The <function>local_scan()</function> function (see chapter
1271 <xref linkend="CHAPlocalscan"/>) is run for all incoming messages.
1272 </para>
1273 <para>
1274 Exim can be configured not to start a delivery process when a message is
1275 received; this can be unconditional, or depend on the number of incoming SMTP
1276 connections or the system load. In these situations, new messages wait on the
1277 queue until a queue runner process picks them up. However, in standard
1278 configurations under normal conditions, delivery is started as soon as a
1279 message is received.
1280 </para>
1281 </section>
1282 <section id="SECID14">
1283 <title>Handling an incoming message</title>
1284 <para>
1285 <indexterm role="concept">
1286 <primary>spool directory</primary>
1287 <secondary>files that hold a message</secondary>
1288 </indexterm>
1289 <indexterm role="concept">
1290 <primary>file</primary>
1291 <secondary>how a message is held</secondary>
1292 </indexterm>
1293 When Exim accepts a message, it writes two files in its spool directory. The
1294 first contains the envelope information, the current status of the message, and
1295 the header lines, and the second contains the body of the message. The names of
1296 the two spool files consist of the message id, followed by <literal>-H</literal> for the
1297 file containing the envelope and header, and <literal>-D</literal> for the data file.
1298 </para>
1299 <para>
1300 <indexterm role="concept">
1301 <primary>spool directory</primary>
1302 <secondary><filename>input</filename> sub-directory</secondary>
1303 </indexterm>
1304 By default all these message files are held in a single directory called
1305 <filename>input</filename> inside the general Exim spool directory. Some operating systems do
1306 not perform very well if the number of files in a directory gets large; to
1307 improve performance in such cases, the <option>split_spool_directory</option> option can be
1308 used. This causes Exim to split up the input files into 62 sub-directories
1309 whose names are single letters or digits. When this is done, the queue is
1310 processed one sub-directory at a time instead of all at once, which can improve
1311 overall performance even when there are not enough files in each directory to
1312 affect file system performance.
1313 </para>
1314 <para>
1315 The envelope information consists of the address of the message&#x2019;s sender and
1316 the addresses of the recipients. This information is entirely separate from
1317 any addresses contained in the header lines. The status of the message includes
1318 a list of recipients who have already received the message. The format of the
1319 first spool file is described in chapter <xref linkend="CHAPspool"/>.
1320 </para>
1321 <para>
1322 <indexterm role="concept">
1323 <primary>rewriting</primary>
1324 <secondary>addresses</secondary>
1325 </indexterm>
1326 Address rewriting that is specified in the rewrite section of the configuration
1327 (see chapter <xref linkend="CHAPrewrite"/>) is done once and for all on incoming addresses,
1328 both in the header lines and the envelope, at the time the message is accepted.
1329 If during the course of delivery additional addresses are generated (for
1330 example, via aliasing), these new addresses are rewritten as soon as they are
1331 generated. At the time a message is actually delivered (transported) further
1332 rewriting can take place; because this is a transport option, it can be
1333 different for different forms of delivery. It is also possible to specify the
1334 addition or removal of certain header lines at the time the message is
1335 delivered (see chapters <xref linkend="CHAProutergeneric"/> and
1336 <xref linkend="CHAPtransportgeneric"/>).
1337 </para>
1338 </section>
1339 <section id="SECID15">
1340 <title>Life of a message</title>
1341 <para>
1342 <indexterm role="concept">
1343 <primary>message</primary>
1344 <secondary>life of</secondary>
1345 </indexterm>
1346 <indexterm role="concept">
1347 <primary>message</primary>
1348 <secondary>frozen</secondary>
1349 </indexterm>
1350 A message remains in the spool directory until it is completely delivered to
1351 its recipients or to an error address, or until it is deleted by an
1352 administrator or by the user who originally created it. In cases when delivery
1353 cannot proceed &ndash; for example, when a message can neither be delivered to its
1354 recipients nor returned to its sender, the message is marked <quote>frozen</quote> on the
1355 spool, and no more deliveries are attempted.
1356 </para>
1357 <para>
1358 <indexterm role="concept">
1359 <primary>frozen messages</primary>
1360 <secondary>thawing</secondary>
1361 </indexterm>
1362 <indexterm role="concept">
1363 <primary>message</primary>
1364 <secondary>thawing frozen</secondary>
1365 </indexterm>
1366 An administrator can <quote>thaw</quote> such messages when the problem has been
1367 corrected, and can also freeze individual messages by hand if necessary. In
1368 addition, an administrator can force a delivery error, causing a bounce message
1369 to be sent.
1370 </para>
1371 <para>
1372 <indexterm role="option">
1373 <primary><option>timeout_frozen_after</option></primary>
1374 </indexterm>
1375 <indexterm role="option">
1376 <primary><option>ignore_bounce_errors_after</option></primary>
1377 </indexterm>
1378 There are options called <option>ignore_bounce_errors_after</option> and
1379 <option>timeout_frozen_after</option>, which discard frozen messages after a certain time.
1380 The first applies only to frozen bounces, the second to any frozen messages.
1381 </para>
1382 <para>
1383 <indexterm role="concept">
1384 <primary>message</primary>
1385 <secondary>log file for</secondary>
1386 </indexterm>
1387 <indexterm role="concept">
1388 <primary>log</primary>
1389 <secondary>file for each message</secondary>
1390 </indexterm>
1391 While Exim is working on a message, it writes information about each delivery
1392 attempt to its main log file. This includes successful, unsuccessful, and
1393 delayed deliveries for each recipient (see chapter <xref linkend="CHAPlog"/>). The log
1394 lines are also written to a separate <emphasis>message log</emphasis> file for each message.
1395 These logs are solely for the benefit of the administrator, and are normally
1396 deleted along with the spool files when processing of a message is complete.
1397 The use of individual message logs can be disabled by setting
1398 <option>no_message_logs</option>; this might give an improvement in performance on very busy
1399 systems.
1400 </para>
1401 <para>
1402 <indexterm role="concept">
1403 <primary>journal file</primary>
1404 </indexterm>
1405 <indexterm role="concept">
1406 <primary>file</primary>
1407 <secondary>journal</secondary>
1408 </indexterm>
1409 All the information Exim itself needs to set up a delivery is kept in the first
1410 spool file, along with the header lines. When a successful delivery occurs, the
1411 address is immediately written at the end of a journal file, whose name is the
1412 message id followed by <literal>-J</literal>. At the end of a delivery run, if there are some
1413 addresses left to be tried again later, the first spool file (the <literal>-H</literal> file)
1414 is updated to indicate which these are, and the journal file is then deleted.
1415 Updating the spool file is done by writing a new file and renaming it, to
1416 minimize the possibility of data loss.
1417 </para>
1418 <para>
1419 Should the system or the program crash after a successful delivery but before
1420 the spool file has been updated, the journal is left lying around. The next
1421 time Exim attempts to deliver the message, it reads the journal file and
1422 updates the spool file before proceeding. This minimizes the chances of double
1423 deliveries caused by crashes.
1424 </para>
1425 </section>
1426 <section id="SECTprocaddress">
1427 <title>Processing an address for delivery</title>
1428 <para>
1429 <indexterm role="concept">
1430 <primary>drivers</primary>
1431 <secondary>definition of</secondary>
1432 </indexterm>
1433 <indexterm role="concept">
1434 <primary>router</primary>
1435 <secondary>definition of</secondary>
1436 </indexterm>
1437 <indexterm role="concept">
1438 <primary>transport</primary>
1439 <secondary>definition of</secondary>
1440 </indexterm>
1441 The main delivery processing elements of Exim are called <emphasis>routers</emphasis> and
1442 <emphasis>transports</emphasis>, and collectively these are known as <emphasis>drivers</emphasis>. Code for a
1443 number of them is provided in the source distribution, and compile-time options
1444 specify which ones are included in the binary. Run time options specify which
1445 ones are actually used for delivering messages.
1446 </para>
1447 <para>
1448 <indexterm role="concept">
1449 <primary>drivers</primary>
1450 <secondary>instance definition</secondary>
1451 </indexterm>
1452 Each driver that is specified in the run time configuration is an <emphasis>instance</emphasis>
1453 of that particular driver type. Multiple instances are allowed; for example,
1454 you can set up several different <command>smtp</command> transports, each with different
1455 option values that might specify different ports or different timeouts. Each
1456 instance has its own identifying name. In what follows we will normally use the
1457 instance name when discussing one particular instance (that is, one specific
1458 configuration of the driver), and the generic driver name when discussing
1459 the driver&#x2019;s features in general.
1460 </para>
1461 <para>
1462 A <emphasis>router</emphasis> is a driver that operates on an address, either determining how
1463 its delivery should happen, by assigning it to a specific transport, or
1464 converting the address into one or more new addresses (for example, via an
1465 alias file). A router may also explicitly choose to fail an address, causing it
1466 to be bounced.
1467 </para>
1468 <para>
1469 A <emphasis>transport</emphasis> is a driver that transmits a copy of the message from Exim&#x2019;s
1470 spool to some destination. There are two kinds of transport: for a <emphasis>local</emphasis>
1471 transport, the destination is a file or a pipe on the local host, whereas for a
1472 <emphasis>remote</emphasis> transport the destination is some other host. A message is passed
1473 to a specific transport as a result of successful routing. If a message has
1474 several recipients, it may be passed to a number of different transports.
1475 </para>
1476 <para>
1477 <indexterm role="concept">
1478 <primary>preconditions</primary>
1479 <secondary>definition of</secondary>
1480 </indexterm>
1481 An address is processed by passing it to each configured router instance in
1482 turn, subject to certain preconditions, until a router accepts the address or
1483 specifies that it should be bounced. We will describe this process in more
1484 detail shortly. First, as a simple example, we consider how each recipient
1485 address in a message is processed in a small configuration of three routers.
1486 </para>
1487 <para>
1488 To make this a more concrete example, it is described in terms of some actual
1489 routers, but remember, this is only an example. You can configure Exim&#x2019;s
1490 routers in many different ways, and there may be any number of routers in a
1491 configuration.
1492 </para>
1493 <para>
1494 The first router that is specified in a configuration is often one that handles
1495 addresses in domains that are not recognized specially by the local host. These
1496 are typically addresses for arbitrary domains on the Internet. A precondition
1497 is set up which looks for the special domains known to the host (for example,
1498 its own domain name), and the router is run for addresses that do <emphasis>not</emphasis>
1499 match. Typically, this is a router that looks up domains in the DNS in order to
1500 find the hosts to which this address routes. If it succeeds, the address is
1501 assigned to a suitable SMTP transport; if it does not succeed, the router is
1502 configured to fail the address.
1503 </para>
1504 <para>
1505 The second router is reached only when the domain is recognized as one that
1506 <quote>belongs</quote> to the local host. This router does redirection &ndash; also known as
1507 aliasing and forwarding. When it generates one or more new addresses from the
1508 original, each of them is routed independently from the start. Otherwise, the
1509 router may cause an address to fail, or it may simply decline to handle the
1510 address, in which case the address is passed to the next router.
1511 </para>
1512 <para>
1513 The final router in many configurations is one that checks to see if the
1514 address belongs to a local mailbox. The precondition may involve a check to
1515 see if the local part is the name of a login account, or it may look up the
1516 local part in a file or a database. If its preconditions are not met, or if
1517 the router declines, we have reached the end of the routers. When this happens,
1518 the address is bounced.
1519 </para>
1520 </section>
1521 <section id="SECID16">
1522 <title>Processing an address for verification</title>
1523 <para>
1524 <indexterm role="concept">
1525 <primary>router</primary>
1526 <secondary>for verification</secondary>
1527 </indexterm>
1528 <indexterm role="concept">
1529 <primary>verifying address</primary>
1530 <secondary>overview</secondary>
1531 </indexterm>
1532 As well as being used to decide how to deliver to an address, Exim&#x2019;s routers
1533 are also used for <emphasis>address verification</emphasis>. Verification can be requested as
1534 one of the checks to be performed in an ACL for incoming messages, on both
1535 sender and recipient addresses, and it can be tested using the <option>-bv</option> and
1536 <option>-bvs</option> command line options.
1537 </para>
1538 <para>
1539 When an address is being verified, the routers are run in <quote>verify mode</quote>. This
1540 does not affect the way the routers work, but it is a state that can be
1541 detected. By this means, a router can be skipped or made to behave differently
1542 when verifying. A common example is a configuration in which the first router
1543 sends all messages to a message-scanning program, unless they have been
1544 previously scanned. Thus, the first router accepts all addresses without any
1545 checking, making it useless for verifying. Normally, the <option>no_verify</option> option
1546 would be set for such a router, causing it to be skipped in verify mode.
1547 </para>
1548 </section>
1549 <section id="SECTrunindrou">
1550 <title>Running an individual router</title>
1551 <para>
1552 <indexterm role="concept">
1553 <primary>router</primary>
1554 <secondary>running details</secondary>
1555 </indexterm>
1556 <indexterm role="concept">
1557 <primary>preconditions</primary>
1558 <secondary>checking</secondary>
1559 </indexterm>
1560 <indexterm role="concept">
1561 <primary>router</primary>
1562 <secondary>result of running</secondary>
1563 </indexterm>
1564 As explained in the example above, a number of preconditions are checked before
1565 running a router. If any are not met, the router is skipped, and the address is
1566 passed to the next router. When all the preconditions on a router <emphasis>are</emphasis> met,
1567 the router is run. What happens next depends on the outcome, which is one of
1568 the following:
1569 </para>
1570 <itemizedlist>
1571 <listitem>
1572 <para>
1573 <emphasis>accept</emphasis>: The router accepts the address, and either assigns it to a
1574 transport, or generates one or more <quote>child</quote> addresses. Processing the
1575 original address ceases,
1576 <indexterm role="option">
1577 <primary><option>unseen</option></primary>
1578 </indexterm>
1579 unless the <option>unseen</option> option is set on the router. This option
1580 can be used to set up multiple deliveries with different routing (for example,
1581 for keeping archive copies of messages). When <option>unseen</option> is set, the address is
1582 passed to the next router. Normally, however, an <emphasis>accept</emphasis> return marks the
1583 end of routing.
1584 </para>
1585 <para>
1586 Any child addresses generated by the router are processed independently,
1587 starting with the first router by default. It is possible to change this by
1588 setting the <option>redirect_router</option> option to specify which router to start at for
1589 child addresses. Unlike <option>pass_router</option> (see below) the router specified by
1590 <option>redirect_router</option> may be anywhere in the router configuration.
1591 </para>
1592 </listitem>
1593 <listitem>
1594 <para>
1595 <emphasis>pass</emphasis>: The router recognizes the address, but cannot handle it itself. It
1596 requests that the address be passed to another router. By default the address
1597 is passed to the next router, but this can be changed by setting the
1598 <option>pass_router</option> option. However, (unlike <option>redirect_router</option>) the named router
1599 must be below the current router (to avoid loops).
1600 </para>
1601 </listitem>
1602 <listitem>
1603 <para>
1604 <emphasis>decline</emphasis>: The router declines to accept the address because it does not
1605 recognize it at all. By default, the address is passed to the next router, but
1606 this can be prevented by setting the <option>no_more</option> option. When <option>no_more</option> is
1607 set, all the remaining routers are skipped. In effect, <option>no_more</option> converts
1608 <emphasis>decline</emphasis> into <emphasis>fail</emphasis>.
1609 </para>
1610 </listitem>
1611 <listitem>
1612 <para>
1613 <emphasis>fail</emphasis>: The router determines that the address should fail, and queues it for
1614 the generation of a bounce message. There is no further processing of the
1615 original address unless <option>unseen</option> is set on the router.
1616 </para>
1617 </listitem>
1618 <listitem>
1619 <para>
1620 <emphasis>defer</emphasis>: The router cannot handle the address at the present time. (A
1621 database may be offline, or a DNS lookup may have timed out.) No further
1622 processing of the address happens in this delivery attempt. It is tried again
1623 next time the message is considered for delivery.
1624 </para>
1625 </listitem>
1626 <listitem>
1627 <para>
1628 <emphasis>error</emphasis>: There is some error in the router (for example, a syntax error in
1629 its configuration). The action is as for defer.
1630 </para>
1631 </listitem>
1632 </itemizedlist>
1633 <para>
1634 If an address reaches the end of the routers without having been accepted by
1635 any of them, it is bounced as unrouteable. The default error message in this
1636 situation is <quote>unrouteable address</quote>, but you can set your own message by
1637 making use of the <option>cannot_route_message</option> option. This can be set for any
1638 router; the value from the last router that <quote>saw</quote> the address is used.
1639 </para>
1640 <para>
1641 Sometimes while routing you want to fail a delivery when some conditions are
1642 met but others are not, instead of passing the address on for further routing.
1643 You can do this by having a second router that explicitly fails the delivery
1644 when the relevant conditions are met. The <command>redirect</command> router has a <quote>fail</quote>
1645 facility for this purpose.
1646 </para>
1647 </section>
1648 <section id="SECID17">
1649 <title>Duplicate addresses</title>
1650 <para>
1651 <indexterm role="concept">
1652 <primary>case of local parts</primary>
1653 </indexterm>
1654 <indexterm role="concept">
1655 <primary>address duplicate, discarding</primary>
1656 </indexterm>
1657 <indexterm role="concept">
1658 <primary>duplicate addresses</primary>
1659 </indexterm>
1660 Once routing is complete, Exim scans the addresses that are assigned to local
1661 and remote transports, and discards any duplicates that it finds. During this
1662 check, local parts are treated as case-sensitive. This happens only when
1663 actually delivering a message; when testing routers with <option>-bt</option>, all the
1664 routed addresses are shown.
1665 </para>
1666 </section>
1667 <section id="SECTrouprecon">
1668 <title>Router preconditions</title>
1669 <para>
1670 <indexterm role="concept">
1671 <primary>router</primary>
1672 <secondary>preconditions, order of processing</secondary>
1673 </indexterm>
1674 <indexterm role="concept">
1675 <primary>preconditions</primary>
1676 <secondary>order of processing</secondary>
1677 </indexterm>
1678 The preconditions that are tested for each router are listed below, in the
1679 order in which they are tested. The individual configuration options are
1680 described in more detail in chapter <xref linkend="CHAProutergeneric"/>.
1681 </para>
1682 <itemizedlist>
1683 <listitem>
1684 <para>
1685 The <option>local_part_prefix</option> and <option>local_part_suffix</option> options can specify that
1686 the local parts handled by the router may or must have certain prefixes and/or
1687 suffixes. If a mandatory affix (prefix or suffix) is not present, the router is
1688 skipped. These conditions are tested first. When an affix is present, it is
1689 removed from the local part before further processing, including the evaluation
1690 of any other conditions.
1691 </para>
1692 </listitem>
1693 <listitem>
1694 <para>
1695 Routers can be designated for use only when not verifying an address, that is,
1696 only when routing it for delivery (or testing its delivery routing). If the
1697 <option>verify</option> option is set false, the router is skipped when Exim is verifying an
1698 address.
1699 Setting the <option>verify</option> option actually sets two options, <option>verify_sender</option> and
1700 <option>verify_recipient</option>, which independently control the use of the router for
1701 sender and recipient verification. You can set these options directly if
1702 you want a router to be used for only one type of verification.
1703 </para>
1704 </listitem>
1705 <listitem>
1706 <para>
1707 If the <option>address_test</option> option is set false, the router is skipped when Exim is
1708 run with the <option>-bt</option> option to test an address routing. This can be helpful
1709 when the first router sends all new messages to a scanner of some sort; it
1710 makes it possible to use <option>-bt</option> to test subsequent delivery routing without
1711 having to simulate the effect of the scanner.
1712 </para>
1713 </listitem>
1714 <listitem>
1715 <para>
1716 Routers can be designated for use only when verifying an address, as
1717 opposed to routing it for delivery. The <option>verify_only</option> option controls this.
1718 </para>
1719 </listitem>
1720 <listitem>
1721 <para>
1722 Individual routers can be explicitly skipped when running the routers to
1723 check an address given in the SMTP EXPN command (see the <option>expn</option> option).
1724 </para>
1725 </listitem>
1726 <listitem>
1727 <para>
1728 If the <option>domains</option> option is set, the domain of the address must be in the set
1729 of domains that it defines.
1730 </para>
1731 </listitem>
1732 <listitem>
1733 <para>
1734 <indexterm role="variable">
1735 <primary><varname>$local_part_prefix</varname></primary>
1736 </indexterm>
1737 <indexterm role="variable">
1738 <primary><varname>$local_part</varname></primary>
1739 </indexterm>
1740 <indexterm role="variable">
1741 <primary><varname>$local_part_suffix</varname></primary>
1742 </indexterm>
1743 If the <option>local_parts</option> option is set, the local part of the address must be in
1744 the set of local parts that it defines. If <option>local_part_prefix</option> or
1745 <option>local_part_suffix</option> is in use, the prefix or suffix is removed from the local
1746 part before this check. If you want to do precondition tests on local parts
1747 that include affixes, you can do so by using a <option>condition</option> option (see below)
1748 that uses the variables <varname>$local_part</varname>, <varname>$local_part_prefix</varname>, and
1749 <varname>$local_part_suffix</varname> as necessary.
1750 </para>
1751 </listitem>
1752 <listitem>
1753 <para>
1754 <indexterm role="variable">
1755 <primary><varname>$local_user_uid</varname></primary>
1756 </indexterm>
1757 <indexterm role="variable">
1758 <primary><varname>$local_user_gid</varname></primary>
1759 </indexterm>
1760 <indexterm role="variable">
1761 <primary><varname>$home</varname></primary>
1762 </indexterm>
1763 If the <option>check_local_user</option> option is set, the local part must be the name of
1764 an account on the local host. If this check succeeds, the uid and gid of the
1765 local user are placed in <varname>$local_user_uid</varname> and <varname>$local_user_gid</varname> and the
1766 user&#x2019;s home directory is placed in <varname>$home</varname>; these values can be used in the
1767 remaining preconditions.
1768 </para>
1769 </listitem>
1770 <listitem>
1771 <para>
1772 If the <option>router_home_directory</option> option is set, it is expanded at this point,
1773 because it overrides the value of <varname>$home</varname>. If this expansion were left till
1774 later, the value of <varname>$home</varname> as set by <option>check_local_user</option> would be used in
1775 subsequent tests. Having two different values of <varname>$home</varname> in the same router
1776 could lead to confusion.
1777 </para>
1778 </listitem>
1779 <listitem>
1780 <para>
1781 If the <option>senders</option> option is set, the envelope sender address must be in the
1782 set of addresses that it defines.
1783 </para>
1784 </listitem>
1785 <listitem>
1786 <para>
1787 If the <option>require_files</option> option is set, the existence or non-existence of
1788 specified files is tested.
1789 </para>
1790 </listitem>
1791 <listitem>
1792 <para>
1793 <indexterm role="concept">
1794 <primary>customizing</primary>
1795 <secondary>precondition</secondary>
1796 </indexterm>
1797 If the <option>condition</option> option is set, it is evaluated and tested. This option
1798 uses an expanded string to allow you to set up your own custom preconditions.
1799 Expanded strings are described in chapter <xref linkend="CHAPexpand"/>.
1800 </para>
1801 </listitem>
1802 </itemizedlist>
1803 <para>
1804 Note that <option>require_files</option> comes near the end of the list, so you cannot use
1805 it to check for the existence of a file in which to lookup up a domain, local
1806 part, or sender. However, as these options are all expanded, you can use the
1807 <option>exists</option> expansion condition to make such tests within each condition. The
1808 <option>require_files</option> option is intended for checking files that the router may be
1809 going to use internally, or which are needed by a specific transport (for
1810 example, <filename>.procmailrc</filename>).
1811 </para>
1812 </section>
1813 <section id="SECID18">
1814 <title>Delivery in detail</title>
1815 <para>
1816 <indexterm role="concept">
1817 <primary>delivery</primary>
1818 <secondary>in detail</secondary>
1819 </indexterm>
1820 When a message is to be delivered, the sequence of events is as follows:
1821 </para>
1822 <itemizedlist>
1823 <listitem>
1824 <para>
1825 If a system-wide filter file is specified, the message is passed to it. The
1826 filter may add recipients to the message, replace the recipients, discard the
1827 message, cause a new message to be generated, or cause the message delivery to
1828 fail. The format of the system filter file is the same as for Exim user filter
1829 files, described in the separate document entitled <emphasis>Exim&#x2019;s interfaces to mail
1830 filtering</emphasis>.
1831 <indexterm role="concept">
1832 <primary>Sieve filter</primary>
1833 <secondary>not available for system filter</secondary>
1834 </indexterm>
1835 (<emphasis role="bold">Note</emphasis>: Sieve cannot be used for system filter files.)
1836 </para>
1837 <para>
1838 Some additional features are available in system filters &ndash; see chapter
1839 <xref linkend="CHAPsystemfilter"/> for details. Note that a message is passed to the system
1840 filter only once per delivery attempt, however many recipients it has. However,
1841 if there are several delivery attempts because one or more addresses could not
1842 be immediately delivered, the system filter is run each time. The filter
1843 condition <option>first_delivery</option> can be used to detect the first run of the system
1844 filter.
1845 </para>
1846 </listitem>
1847 <listitem>
1848 <para>
1849 Each recipient address is offered to each configured router in turn, subject to
1850 its preconditions, until one is able to handle it. If no router can handle the
1851 address, that is, if they all decline, the address is failed. Because routers
1852 can be targeted at particular domains, several locally handled domains can be
1853 processed entirely independently of each other.
1854 </para>
1855 </listitem>
1856 <listitem>
1857 <para>
1858 <indexterm role="concept">
1859 <primary>routing</primary>
1860 <secondary>loops in</secondary>
1861 </indexterm>
1862 <indexterm role="concept">
1863 <primary>loop</primary>
1864 <secondary>while routing</secondary>
1865 </indexterm>
1866 A router that accepts an address may assign it to a local or a remote
1867 transport. However, the transport is not run at this time. Instead, the address
1868 is placed on a list for the particular transport, which will be run later.
1869 Alternatively, the router may generate one or more new addresses (typically
1870 from alias, forward, or filter files). New addresses are fed back into this
1871 process from the top, but in order to avoid loops, a router ignores any address
1872 which has an identically-named ancestor that was processed by itself.
1873 </para>
1874 </listitem>
1875 <listitem>
1876 <para>
1877 When all the routing has been done, addresses that have been successfully
1878 handled are passed to their assigned transports. When local transports are
1879 doing real local deliveries, they handle only one address at a time, but if a
1880 local transport is being used as a pseudo-remote transport (for example, to
1881 collect batched SMTP messages for transmission by some other means) multiple
1882 addresses can be handled. Remote transports can always handle more than one
1883 address at a time, but can be configured not to do so, or to restrict multiple
1884 addresses to the same domain.
1885 </para>
1886 </listitem>
1887 <listitem>
1888 <para>
1889 Each local delivery to a file or a pipe runs in a separate process under a
1890 non-privileged uid, and these deliveries are run one at a time. Remote
1891 deliveries also run in separate processes, normally under a uid that is private
1892 to Exim (<quote>the Exim user</quote>), but in this case, several remote deliveries can be
1893 run in parallel. The maximum number of simultaneous remote deliveries for any
1894 one message is set by the <option>remote_max_parallel</option> option.
1895 The order in which deliveries are done is not defined, except that all local
1896 deliveries happen before any remote deliveries.
1897 </para>
1898 </listitem>
1899 <listitem>
1900 <para>
1901 <indexterm role="concept">
1902 <primary>queue runner</primary>
1903 </indexterm>
1904 When it encounters a local delivery during a queue run, Exim checks its retry
1905 database to see if there has been a previous temporary delivery failure for the
1906 address before running the local transport. If there was a previous failure,
1907 Exim does not attempt a new delivery until the retry time for the address is
1908 reached. However, this happens only for delivery attempts that are part of a
1909 queue run. Local deliveries are always attempted when delivery immediately
1910 follows message reception, even if retry times are set for them. This makes for
1911 better behaviour if one particular message is causing problems (for example,
1912 causing quota overflow, or provoking an error in a filter file).
1913 </para>
1914 </listitem>
1915 <listitem>
1916 <para>
1917 <indexterm role="concept">
1918 <primary>delivery</primary>
1919 <secondary>retry in remote transports</secondary>
1920 </indexterm>
1921 Remote transports do their own retry handling, since an address may be
1922 deliverable to one of a number of hosts, each of which may have a different
1923 retry time. If there have been previous temporary failures and no host has
1924 reached its retry time, no delivery is attempted, whether in a queue run or
1925 not. See chapter <xref linkend="CHAPretry"/> for details of retry strategies.
1926 </para>
1927 </listitem>
1928 <listitem>
1929 <para>
1930 If there were any permanent errors, a bounce message is returned to an
1931 appropriate address (the sender in the common case), with details of the error
1932 for each failing address. Exim can be configured to send copies of bounce
1933 messages to other addresses.
1934 </para>
1935 </listitem>
1936 <listitem>
1937 <para>
1938 <indexterm role="concept">
1939 <primary>delivery</primary>
1940 <secondary>deferral</secondary>
1941 </indexterm>
1942 If one or more addresses suffered a temporary failure, the message is left on
1943 the queue, to be tried again later. Delivery of these addresses is said to be
1944 <emphasis>deferred</emphasis>.
1945 </para>
1946 </listitem>
1947 <listitem>
1948 <para>
1949 When all the recipient addresses have either been delivered or bounced,
1950 handling of the message is complete. The spool files and message log are
1951 deleted, though the message log can optionally be preserved if required.
1952 </para>
1953 </listitem>
1954 </itemizedlist>
1955 </section>
1956 <section id="SECID19">
1957 <title>Retry mechanism</title>
1958 <para>
1959 <indexterm role="concept">
1960 <primary>delivery</primary>
1961 <secondary>retry mechanism</secondary>
1962 </indexterm>
1963 <indexterm role="concept">
1964 <primary>retry</primary>
1965 <secondary>description of mechanism</secondary>
1966 </indexterm>
1967 <indexterm role="concept">
1968 <primary>queue runner</primary>
1969 </indexterm>
1970 Exim&#x2019;s mechanism for retrying messages that fail to get delivered at the first
1971 attempt is the queue runner process. You must either run an Exim daemon that
1972 uses the <option>-q</option> option with a time interval to start queue runners at regular
1973 intervals, or use some other means (such as <emphasis>cron</emphasis>) to start them. If you do
1974 not arrange for queue runners to be run, messages that fail temporarily at the
1975 first attempt will remain on your queue for ever. A queue runner process works
1976 its way through the queue, one message at a time, trying each delivery that has
1977 passed its retry time.
1978 You can run several queue runners at once.
1979 </para>
1980 <para>
1981 Exim uses a set of configured rules to determine when next to retry the failing
1982 address (see chapter <xref linkend="CHAPretry"/>). These rules also specify when Exim
1983 should give up trying to deliver to the address, at which point it generates a
1984 bounce message. If no retry rules are set for a particular host, address, and
1985 error combination, no retries are attempted, and temporary errors are treated
1986 as permanent.
1987 </para>
1988 </section>
1989 <section id="SECID20">
1990 <title>Temporary delivery failure</title>
1991 <para>
1992 <indexterm role="concept">
1993 <primary>delivery</primary>
1994 <secondary>temporary failure</secondary>
1995 </indexterm>
1996 There are many reasons why a message may not be immediately deliverable to a
1997 particular address. Failure to connect to a remote machine (because it, or the
1998 connection to it, is down) is one of the most common. Temporary failures may be
1999 detected during routing as well as during the transport stage of delivery.
2000 Local deliveries may be delayed if NFS files are unavailable, or if a mailbox
2001 is on a file system where the user is over quota. Exim can be configured to
2002 impose its own quotas on local mailboxes; where system quotas are set they will
2003 also apply.
2004 </para>
2005 <para>
2006 If a host is unreachable for a period of time, a number of messages may be
2007 waiting for it by the time it recovers, and sending them in a single SMTP
2008 connection is clearly beneficial. Whenever a delivery to a remote host is
2009 deferred,
2010 <indexterm role="concept">
2011 <primary>hints database</primary>
2012 </indexterm>
2013 Exim makes a note in its hints database, and whenever a successful
2014 SMTP delivery has happened, it looks to see if any other messages are waiting
2015 for the same host. If any are found, they are sent over the same SMTP
2016 connection, subject to a configuration limit as to the maximum number in any
2017 one connection.
2018 </para>
2019 </section>
2020 <section id="SECID21">
2021 <title>Permanent delivery failure</title>
2022 <para>
2023 <indexterm role="concept">
2024 <primary>delivery</primary>
2025 <secondary>permanent failure</secondary>
2026 </indexterm>
2027 <indexterm role="concept">
2028 <primary>bounce message</primary>
2029 <secondary>when generated</secondary>
2030 </indexterm>
2031 When a message cannot be delivered to some or all of its intended recipients, a
2032 bounce message is generated. Temporary delivery failures turn into permanent
2033 errors when their timeout expires. All the addresses that fail in a given
2034 delivery attempt are listed in a single message. If the original message has
2035 many recipients, it is possible for some addresses to fail in one delivery
2036 attempt and others to fail subsequently, giving rise to more than one bounce
2037 message. The wording of bounce messages can be customized by the administrator.
2038 See chapter <xref linkend="CHAPemsgcust"/> for details.
2039 </para>
2040 <para>
2041 <indexterm role="concept">
2042 <primary><emphasis>X-Failed-Recipients:</emphasis> header line</primary>
2043 </indexterm>
2044 Bounce messages contain an <emphasis>X-Failed-Recipients:</emphasis> header line that lists the
2045 failed addresses, for the benefit of programs that try to analyse such messages
2046 automatically.
2047 </para>
2048 <para>
2049 <indexterm role="concept">
2050 <primary>bounce message</primary>
2051 <secondary>recipient of</secondary>
2052 </indexterm>
2053 A bounce message is normally sent to the sender of the original message, as
2054 obtained from the message&#x2019;s envelope. For incoming SMTP messages, this is the
2055 address given in the MAIL command. However, when an address is expanded via a
2056 forward or alias file, an alternative address can be specified for delivery
2057 failures of the generated addresses. For a mailing list expansion (see section
2058 <xref linkend="SECTmailinglists"/>) it is common to direct bounce messages to the manager
2059 of the list.
2060 </para>
2061 </section>
2062 <section id="SECID22">
2063 <title>Failures to deliver bounce messages</title>
2064 <para>
2065 <indexterm role="concept">
2066 <primary>bounce message</primary>
2067 <secondary>failure to deliver</secondary>
2068 </indexterm>
2069 If a bounce message (either locally generated or received from a remote host)
2070 itself suffers a permanent delivery failure, the message is left on the queue,
2071 but it is frozen, awaiting the attention of an administrator. There are options
2072 that can be used to make Exim discard such failed messages, or to keep them
2073 for only a short time (see <option>timeout_frozen_after</option> and
2074 <option>ignore_bounce_errors_after</option>).
2075 </para>
2076 </section>
2077 </chapter>
2078
2079 <chapter id="CHID3">
2080 <title>Building and installing Exim</title>
2081 <para>
2082 <indexterm role="concept" id="IIDbuex" class="startofrange">
2083 <primary>building Exim</primary>
2084 </indexterm>
2085 </para>
2086 <section id="SECID23">
2087 <title>Unpacking</title>
2088 <para>
2089 Exim is distributed as a gzipped or bzipped tar file which, when unpacked,
2090 creates a directory with the name of the current release (for example,
2091 <filename>exim-4.73</filename>) into which the following files are placed:
2092 </para>
2093 <informaltable frame="none">
2094 <tgroup cols="2" colsep="0" rowsep="0">
2095 <colspec colwidth="140pt" align="left"/>
2096 <colspec colwidth="254pt" align="left"/>
2097 <tbody>
2098 <row>
2099 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>ACKNOWLEDGMENTS</filename></entry>
2100 <entry>contains some acknowledgments</entry>
2101 </row>
2102 <row>
2103 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>CHANGES</filename></entry>
2104 <entry>contains a reference to where changes are documented</entry>
2105 </row>
2106 <row>
2107 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>LICENCE</filename></entry>
2108 <entry>the GNU General Public Licence</entry>
2109 </row>
2110 <row>
2111 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>Makefile</filename></entry>
2112 <entry>top-level make file</entry>
2113 </row>
2114 <row>
2115 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>NOTICE</filename></entry>
2116 <entry>conditions for the use of Exim</entry>
2117 </row>
2118 <row>
2119 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>README</filename></entry>
2120 <entry>list of files, directories and simple build instructions</entry>
2121 </row>
2122 </tbody>
2123 </tgroup>
2124 </informaltable>
2125 <para>
2126 Other files whose names begin with <filename>README</filename> may also be present. The
2127 following subdirectories are created:
2128 </para>
2129 <informaltable frame="none">
2130 <tgroup cols="2" colsep="0" rowsep="0">
2131 <colspec colwidth="140pt" align="left"/>
2132 <colspec colwidth="254pt" align="left"/>
2133 <tbody>
2134 <row>
2135 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>Local</filename></entry>
2136 <entry>an empty directory for local configuration files</entry>
2137 </row>
2138 <row>
2139 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>OS</filename></entry>
2140 <entry>OS-specific files</entry>
2141 </row>
2142 <row>
2143 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>doc</filename></entry>
2144 <entry>documentation files</entry>
2145 </row>
2146 <row>
2147 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>exim_monitor</filename></entry>
2148 <entry>source files for the Exim monitor</entry>
2149 </row>
2150 <row>
2151 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>scripts</filename></entry>
2152 <entry>scripts used in the build process</entry>
2153 </row>
2154 <row>
2155 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>src</filename></entry>
2156 <entry>remaining source files</entry>
2157 </row>
2158 <row>
2159 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>util</filename></entry>
2160 <entry>independent utilities</entry>
2161 </row>
2162 </tbody>
2163 </tgroup>
2164 </informaltable>
2165 <para>
2166 The main utility programs are contained in the <filename>src</filename> directory, and are built
2167 with the Exim binary. The <filename>util</filename> directory contains a few optional scripts
2168 that may be useful to some sites.
2169 </para>
2170 </section>
2171 <section id="SECID24">
2172 <title>Multiple machine architectures and operating systems</title>
2173 <para>
2174 <indexterm role="concept">
2175 <primary>building Exim</primary>
2176 <secondary>multiple OS/architectures</secondary>
2177 </indexterm>
2178 The building process for Exim is arranged to make it easy to build binaries for
2179 a number of different architectures and operating systems from the same set of
2180 source files. Compilation does not take place in the <filename>src</filename> directory.
2181 Instead, a <emphasis>build directory</emphasis> is created for each architecture and operating
2182 system.
2183 <indexterm role="concept">
2184 <primary>symbolic link</primary>
2185 <secondary>to build directory</secondary>
2186 </indexterm>
2187 Symbolic links to the sources are installed in this directory, which is where
2188 the actual building takes place. In most cases, Exim can discover the machine
2189 architecture and operating system for itself, but the defaults can be
2190 overridden if necessary.
2191 </para>
2192 </section>
2193 <section id="SECTpcre">
2194 <title>PCRE library</title>
2195 <para>
2196 <indexterm role="concept">
2197 <primary>PCRE library</primary>
2198 </indexterm>
2199 Exim no longer has an embedded PCRE library as the vast majority of
2200 modern systems include PCRE as a system library, although you may need
2201 to install the PCRE or PCRE development package for your operating
2202 system. If your system has a normal PCRE installation the Exim build
2203 process will need no further configuration. If the library or the
2204 headers are in an unusual location you will need to set the PCRE_LIBS
2205 and INCLUDE directives appropriately. If your operating system has no
2206 PCRE support then you will need to obtain and build the current PCRE
2207 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>.
2208 </para>
2209 </section>
2210 <section id="SECTdb">
2211 <title>DBM libraries</title>
2212 <para>
2213 <indexterm role="concept">
2214 <primary>DBM libraries</primary>
2215 <secondary>discussion of</secondary>
2216 </indexterm>
2217 <indexterm role="concept">
2218 <primary>hints database</primary>
2219 <secondary>DBM files used for</secondary>
2220 </indexterm>
2221 Even if you do not use any DBM files in your configuration, Exim still needs a
2222 DBM library in order to operate, because it uses indexed files for its hints
2223 databases. Unfortunately, there are a number of DBM libraries in existence, and
2224 different operating systems often have different ones installed.
2225 </para>
2226 <para>
2227 <indexterm role="concept">
2228 <primary>Solaris</primary>
2229 <secondary>DBM library for</secondary>
2230 </indexterm>
2231 <indexterm role="concept">
2232 <primary>IRIX, DBM library for</primary>
2233 </indexterm>
2234 <indexterm role="concept">
2235 <primary>BSD, DBM library for</primary>
2236 </indexterm>
2237 <indexterm role="concept">
2238 <primary>Linux, DBM library for</primary>
2239 </indexterm>
2240 If you are using Solaris, IRIX, one of the modern BSD systems, or a modern
2241 Linux distribution, the DBM configuration should happen automatically, and you
2242 may be able to ignore this section. Otherwise, you may have to learn more than
2243 you would like about DBM libraries from what follows.
2244 </para>
2245 <para>
2246 <indexterm role="concept">
2247 <primary><emphasis>ndbm</emphasis> DBM library</primary>
2248 </indexterm>
2249 Licensed versions of Unix normally contain a library of DBM functions operating
2250 via the <emphasis>ndbm</emphasis> interface, and this is what Exim expects by default. Free
2251 versions of Unix seem to vary in what they contain as standard. In particular,
2252 some early versions of Linux have no default DBM library, and different
2253 distributors have chosen to bundle different libraries with their packaged
2254 versions. However, the more recent releases seem to have standardized on the
2255 Berkeley DB library.
2256 </para>
2257 <para>
2258 Different DBM libraries have different conventions for naming the files they
2259 use. When a program opens a file called <filename>dbmfile</filename>, there are several
2260 possibilities:
2261 </para>
2262 <orderedlist numeration="arabic">
2263 <listitem>
2264 <para>
2265 A traditional <emphasis>ndbm</emphasis> implementation, such as that supplied as part of
2266 Solaris, operates on two files called <filename>dbmfile.dir</filename> and <filename>dbmfile.pag</filename>.
2267 </para>
2268 </listitem>
2269 <listitem>
2270 <para>
2271 <indexterm role="concept">
2272 <primary><emphasis>gdbm</emphasis> DBM library</primary>
2273 </indexterm>
2274 The GNU library, <emphasis>gdbm</emphasis>, operates on a single file. If used via its <emphasis>ndbm</emphasis>
2275 compatibility interface it makes two different hard links to it with names
2276 <filename>dbmfile.dir</filename> and <filename>dbmfile.pag</filename>, but if used via its native interface, the
2277 file name is used unmodified.
2278 </para>
2279 </listitem>
2280 <listitem>
2281 <para>
2282 <indexterm role="concept">
2283 <primary>Berkeley DB library</primary>
2284 </indexterm>
2285 The Berkeley DB package, if called via its <emphasis>ndbm</emphasis> compatibility interface,
2286 operates on a single file called <filename>dbmfile.db</filename>, but otherwise looks to the
2287 programmer exactly the same as the traditional <emphasis>ndbm</emphasis> implementation.
2288 </para>
2289 </listitem>
2290 <listitem>
2291 <para>
2292 If the Berkeley package is used in its native mode, it operates on a single
2293 file called <filename>dbmfile</filename>; the programmer&#x2019;s interface is somewhat different to
2294 the traditional <emphasis>ndbm</emphasis> interface.
2295 </para>
2296 </listitem>
2297 <listitem>
2298 <para>
2299 To complicate things further, there are several very different versions of the
2300 Berkeley DB package. Version 1.85 was stable for a very long time, releases
2301 2.<emphasis>x</emphasis> and 3.<emphasis>x</emphasis> were current for a while, but the latest versions are now
2302 numbered 4.<emphasis>x</emphasis>. Maintenance of some of the earlier releases has ceased. All
2303 versions of Berkeley DB can be obtained from
2304 <emphasis role="bold"><ulink url="http://www.sleepycat.com/">http://www.sleepycat.com/</ulink></emphasis>.
2305 </para>
2306 </listitem>
2307 <listitem>
2308 <para>
2309 <indexterm role="concept">
2310 <primary><emphasis>tdb</emphasis> DBM library</primary>
2311 </indexterm>
2312 Yet another DBM library, called <emphasis>tdb</emphasis>, is available from
2313 <emphasis role="bold"><ulink url="http://download.sourceforge.net/tdb">http://download.sourceforge.net/tdb</ulink></emphasis>. It has its own interface, and also
2314 operates on a single file.
2315 </para>
2316 </listitem>
2317 </orderedlist>
2318 <para>
2319 <indexterm role="concept">
2320 <primary>USE_DB</primary>
2321 </indexterm>
2322 <indexterm role="concept">
2323 <primary>DBM libraries</primary>
2324 <secondary>configuration for building</secondary>
2325 </indexterm>
2326 Exim and its utilities can be compiled to use any of these interfaces. In order
2327 to use any version of the Berkeley DB package in native mode, you must set
2328 USE_DB in an appropriate configuration file (typically
2329 <filename>Local/Makefile</filename>). For example:
2330 </para>
2331 <literallayout class="monospaced">
2332 USE_DB=yes
2333 </literallayout>
2334 <para>
2335 Similarly, for gdbm you set USE_GDBM, and for tdb you set USE_TDB. An
2336 error is diagnosed if you set more than one of these.
2337 </para>
2338 <para>
2339 At the lowest level, the build-time configuration sets none of these options,
2340 thereby assuming an interface of type (1). However, some operating system
2341 configuration files (for example, those for the BSD operating systems and
2342 Linux) assume type (4) by setting USE_DB as their default, and the
2343 configuration files for Cygwin set USE_GDBM. Anything you set in
2344 <filename>Local/Makefile</filename>, however, overrides these system defaults.
2345 </para>
2346 <para>
2347 As well as setting USE_DB, USE_GDBM, or USE_TDB, it may also be
2348 necessary to set DBMLIB, to cause inclusion of the appropriate library, as
2349 in one of these lines:
2350 </para>
2351 <literallayout class="monospaced">
2352 DBMLIB = -ldb
2353 DBMLIB = -ltdb
2354 </literallayout>
2355 <para>
2356 Settings like that will work if the DBM library is installed in the standard
2357 place. Sometimes it is not, and the library&#x2019;s header file may also not be in
2358 the default path. You may need to set INCLUDE to specify where the header
2359 file is, and to specify the path to the library more fully in DBMLIB, as in
2360 this example:
2361 </para>
2362 <literallayout class="monospaced">
2363 INCLUDE=-I/usr/local/include/db-4.1
2364 DBMLIB=/usr/local/lib/db-4.1/libdb.a
2365 </literallayout>
2366 <para>
2367 There is further detailed discussion about the various DBM libraries in the
2368 file <filename>doc/dbm.discuss.txt</filename> in the Exim distribution.
2369 </para>
2370 </section>
2371 <section id="SECID25">
2372 <title>Pre-building configuration</title>
2373 <para>
2374 <indexterm role="concept">
2375 <primary>building Exim</primary>
2376 <secondary>pre-building configuration</secondary>
2377 </indexterm>
2378 <indexterm role="concept">
2379 <primary>configuration for building Exim</primary>
2380 </indexterm>
2381 <indexterm role="concept">
2382 <primary><filename>Local/Makefile</filename></primary>
2383 </indexterm>
2384 <indexterm role="concept">
2385 <primary><filename>src/EDITME</filename></primary>
2386 </indexterm>
2387 Before building Exim, a local configuration file that specifies options
2388 independent of any operating system has to be created with the name
2389 <filename>Local/Makefile</filename>. A template for this file is supplied as the file
2390 <filename>src/EDITME</filename>, and it contains full descriptions of all the option settings
2391 therein. These descriptions are therefore not repeated here. If you are
2392 building Exim for the first time, the simplest thing to do is to copy
2393 <filename>src/EDITME</filename> to <filename>Local/Makefile</filename>, then read it and edit it appropriately.
2394 </para>
2395 <para>
2396 There are three settings that you must supply, because Exim will not build
2397 without them. They are the location of the run time configuration file
2398 (CONFIGURE_FILE), the directory in which Exim binaries will be installed
2399 (BIN_DIRECTORY), and the identity of the Exim user (EXIM_USER and
2400 maybe EXIM_GROUP as well). The value of CONFIGURE_FILE can in fact be
2401 a colon-separated list of file names; Exim uses the first of them that exists.
2402 </para>
2403 <para>
2404 There are a few other parameters that can be specified either at build time or
2405 at run time, to enable the same binary to be used on a number of different
2406 machines. However, if the locations of Exim&#x2019;s spool directory and log file
2407 directory (if not within the spool directory) are fixed, it is recommended that
2408 you specify them in <filename>Local/Makefile</filename> instead of at run time, so that errors
2409 detected early in Exim&#x2019;s execution (such as a malformed configuration file) can
2410 be logged.
2411 </para>
2412 <para>
2413 <indexterm role="concept">
2414 <primary>content scanning</primary>
2415 <secondary>specifying at build time</secondary>
2416 </indexterm>
2417 Exim&#x2019;s interfaces for calling virus and spam scanning software directly from
2418 access control lists are not compiled by default. If you want to include these
2419 facilities, you need to set
2420 </para>
2421 <literallayout class="monospaced">
2422 WITH_CONTENT_SCAN=yes
2423 </literallayout>
2424 <para>
2425 in your <filename>Local/Makefile</filename>. For details of the facilities themselves, see
2426 chapter <xref linkend="CHAPexiscan"/>.
2427 </para>
2428 <para>
2429 <indexterm role="concept">
2430 <primary><filename>Local/eximon.conf</filename></primary>
2431 </indexterm>
2432 <indexterm role="concept">
2433 <primary><filename>exim_monitor/EDITME</filename></primary>
2434 </indexterm>
2435 If you are going to build the Exim monitor, a similar configuration process is
2436 required. The file <filename>exim_monitor/EDITME</filename> must be edited appropriately for
2437 your installation and saved under the name <filename>Local/eximon.conf</filename>. If you are
2438 happy with the default settings described in <filename>exim_monitor/EDITME</filename>,
2439 <filename>Local/eximon.conf</filename> can be empty, but it must exist.
2440 </para>
2441 <para>
2442 This is all the configuration that is needed in straightforward cases for known
2443 operating systems. However, the building process is set up so that it is easy
2444 to override options that are set by default or by operating-system-specific
2445 configuration files, for example to change the name of the C compiler, which
2446 defaults to <option>gcc</option>. See section <xref linkend="SECToverride"/> below for details of how to
2447 do this.
2448 </para>
2449 </section>
2450 <section id="SECID26">
2451 <title>Support for iconv()</title>
2452 <para>
2453 <indexterm role="concept">
2454 <primary><function>iconv()</function> support</primary>
2455 </indexterm>
2456 <indexterm role="concept">
2457 <primary>RFC 2047</primary>
2458 </indexterm>
2459 The contents of header lines in messages may be encoded according to the rules
2460 described RFC 2047. This makes it possible to transmit characters that are not
2461 in the ASCII character set, and to label them as being in a particular
2462 character set. When Exim is inspecting header lines by means of the <option>$h_</option>
2463 mechanism, it decodes them, and translates them into a specified character set
2464 (default ISO-8859-1). The translation is possible only if the operating system
2465 supports the <function>iconv()</function> function.
2466 </para>
2467 <para>
2468 However, some of the operating systems that supply <function>iconv()</function> do not support
2469 very many conversions. The GNU <option>libiconv</option> library (available from
2470 <emphasis role="bold"><ulink url="http://www.gnu.org/software/libiconv/">http://www.gnu.org/software/libiconv/</ulink></emphasis>) can be installed on such
2471 systems to remedy this deficiency, as well as on systems that do not supply
2472 <function>iconv()</function> at all. After installing <option>libiconv</option>, you should add
2473 </para>
2474 <literallayout class="monospaced">
2475 HAVE_ICONV=yes
2476 </literallayout>
2477 <para>
2478 to your <filename>Local/Makefile</filename> and rebuild Exim.
2479 </para>
2480 </section>
2481 <section id="SECTinctlsssl">
2482 <title>Including TLS/SSL encryption support</title>
2483 <para>
2484 <indexterm role="concept">
2485 <primary>TLS</primary>
2486 <secondary>including support for TLS</secondary>
2487 </indexterm>
2488 <indexterm role="concept">
2489 <primary>encryption</primary>
2490 <secondary>including support for</secondary>
2491 </indexterm>
2492 <indexterm role="concept">
2493 <primary>SUPPORT_TLS</primary>
2494 </indexterm>
2495 <indexterm role="concept">
2496 <primary>OpenSSL</primary>
2497 <secondary>building Exim with</secondary>
2498 </indexterm>
2499 <indexterm role="concept">
2500 <primary>GnuTLS</primary>
2501 <secondary>building Exim with</secondary>
2502 </indexterm>
2503 Exim can be built to support encrypted SMTP connections, using the STARTTLS
2504 command as per RFC 2487. It can also support legacy clients that expect to
2505 start a TLS session immediately on connection to a non-standard port (see the
2506 <option>tls_on_connect_ports</option> runtime option and the <option>-tls-on-connect</option> command
2507 line option).
2508 </para>
2509 <para>
2510 If you want to build Exim with TLS support, you must first install either the
2511 OpenSSL or GnuTLS library. There is no cryptographic code in Exim itself for
2512 implementing SSL.
2513 </para>
2514 <para>
2515 If OpenSSL is installed, you should set
2516 </para>
2517 <literallayout class="monospaced">
2518 SUPPORT_TLS=yes
2519 TLS_LIBS=-lssl -lcrypto
2520 </literallayout>
2521 <para>
2522 in <filename>Local/Makefile</filename>. You may also need to specify the locations of the
2523 OpenSSL library and include files. For example:
2524 </para>
2525 <literallayout class="monospaced">
2526 SUPPORT_TLS=yes
2527 TLS_LIBS=-L/usr/local/openssl/lib -lssl -lcrypto
2528 TLS_INCLUDE=-I/usr/local/openssl/include/
2529 </literallayout>
2530 <para>
2531 <indexterm role="concept">
2532 <primary>USE_GNUTLS</primary>
2533 </indexterm>
2534 If GnuTLS is installed, you should set
2535 </para>
2536 <literallayout class="monospaced">
2537 SUPPORT_TLS=yes
2538 USE_GNUTLS=yes
2539 TLS_LIBS=-lgnutls -ltasn1 -lgcrypt
2540 </literallayout>
2541 <para>
2542 in <filename>Local/Makefile</filename>, and again you may need to specify the locations of the
2543 library and include files. For example:
2544 </para>
2545 <literallayout class="monospaced">
2546 SUPPORT_TLS=yes
2547 USE_GNUTLS=yes
2548 TLS_LIBS=-L/usr/gnu/lib -lgnutls -ltasn1 -lgcrypt
2549 TLS_INCLUDE=-I/usr/gnu/include
2550 </literallayout>
2551 <para>
2552 You do not need to set TLS_INCLUDE if the relevant directory is already
2553 specified in INCLUDE. Details of how to configure Exim to make use of TLS are
2554 given in chapter <xref linkend="CHAPTLS"/>.
2555 </para>
2556 </section>
2557 <section id="SECID27">
2558 <title>Use of tcpwrappers</title>
2559 <para revisionflag="changed">
2560 <indexterm role="concept">
2561 <primary>tcpwrappers, building Exim to support</primary>
2562 </indexterm>
2563 <indexterm role="concept">
2564 <primary>USE_TCP_WRAPPERS</primary>
2565 </indexterm>
2566 <indexterm role="concept">
2567 <primary>TCP_WRAPPERS_DAEMON_NAME</primary>
2568 </indexterm>
2569 <indexterm role="concept">
2570 <primary>tcp_wrappers_daemon_name</primary>
2571 </indexterm>
2572 Exim can be linked with the <emphasis>tcpwrappers</emphasis> library in order to check incoming
2573 SMTP calls using the <emphasis>tcpwrappers</emphasis> control files. This may be a convenient
2574 alternative to Exim&#x2019;s own checking facilities for installations that are
2575 already making use of <emphasis>tcpwrappers</emphasis> for other purposes. To do this, you
2576 should set USE_TCP_WRAPPERS in <filename>Local/Makefile</filename>, arrange for the file
2577 <filename>tcpd.h</filename> to be available at compile time, and also ensure that the library
2578 <filename>libwrap.a</filename> is available at link time, typically by including <option>-lwrap</option> in
2579 EXTRALIBS_EXIM. For example, if <emphasis>tcpwrappers</emphasis> is installed in <filename>/usr/local</filename>,
2580 you might have
2581 </para>
2582 <literallayout class="monospaced" revisionflag="changed">
2583 USE_TCP_WRAPPERS=yes
2584 CFLAGS=-O -I/usr/local/include
2585 EXTRALIBS_EXIM=-L/usr/local/lib -lwrap
2586 </literallayout>
2587 <para revisionflag="changed">
2588 in <filename>Local/Makefile</filename>. The daemon name to use in the <emphasis>tcpwrappers</emphasis> control
2589 files is <quote>exim</quote>. For example, the line
2590 </para>
2591 <literallayout class="monospaced" revisionflag="changed">
2592 exim : LOCAL  192.168.1.  .friendly.domain.example
2593 </literallayout>
2594 <para revisionflag="changed">
2595 in your <filename>/etc/hosts.allow</filename> file allows connections from the local host, from
2596 the subnet 192.168.1.0/24, and from all hosts in <emphasis>friendly.domain.example</emphasis>.
2597 All other connections are denied. The daemon name used by <emphasis>tcpwrappers</emphasis>
2598 can be changed at build time by setting TCP_WRAPPERS_DAEMON_NAME in
2599 in <filename>Local/Makefile</filename>, or by setting tcp_wrappers_daemon_name in the
2600 configure file. Consult the <emphasis>tcpwrappers</emphasis> documentation for
2601 further details.
2602 </para>
2603 </section>
2604 <section id="SECID28">
2605 <title>Including support for IPv6</title>
2606 <para>
2607 <indexterm role="concept">
2608 <primary>IPv6</primary>
2609 <secondary>including support for</secondary>
2610 </indexterm>
2611 Exim contains code for use on systems that have IPv6 support. Setting
2612 <literal>HAVE_IPV6=YES</literal> in <filename>Local/Makefile</filename> causes the IPv6 code to be included;
2613 it may also be necessary to set IPV6_INCLUDE and IPV6_LIBS on systems
2614 where the IPv6 support is not fully integrated into the normal include and
2615 library files.
2616 </para>
2617 <para>
2618 Two different types of DNS record for handling IPv6 addresses have been
2619 defined. AAAA records (analogous to A records for IPv4) are in use, and are
2620 currently seen as the mainstream. Another record type called A6 was proposed
2621 as better than AAAA because it had more flexibility. However, it was felt to be
2622 over-complex, and its status was reduced to <quote>experimental</quote>. It is not known
2623 if anyone is actually using A6 records. Exim has support for A6 records, but
2624 this is included only if you set <literal>SUPPORT_A6=YES</literal> in <filename>Local/Makefile</filename>. The
2625 support has not been tested for some time.
2626 </para>
2627 </section>
2628 <section id="SECID29">
2629 <title>The building process</title>
2630 <para>
2631 <indexterm role="concept">
2632 <primary>build directory</primary>
2633 </indexterm>
2634 Once <filename>Local/Makefile</filename> (and <filename>Local/eximon.conf</filename>, if required) have been
2635 created, run <emphasis>make</emphasis> at the top level. It determines the architecture and
2636 operating system types, and creates a build directory if one does not exist.
2637 For example, on a Sun system running Solaris 8, the directory
2638 <filename>build-SunOS5-5.8-sparc</filename> is created.
2639 <indexterm role="concept">
2640 <primary>symbolic link</primary>
2641 <secondary>to source files</secondary>
2642 </indexterm>
2643 Symbolic links to relevant source files are installed in the build directory.
2644 </para>
2645 <para>
2646 <emphasis role="bold">Warning</emphasis>: The <option>-j</option> (parallel) flag must not be used with <emphasis>make</emphasis>; the
2647 building process fails if it is set.
2648 </para>
2649 <para>
2650 If this is the first time <emphasis>make</emphasis> has been run, it calls a script that builds
2651 a make file inside the build directory, using the configuration files from the
2652 <filename>Local</filename> directory. The new make file is then passed to another instance of
2653 <emphasis>make</emphasis>. This does the real work, building a number of utility scripts, and
2654 then compiling and linking the binaries for the Exim monitor (if configured), a
2655 number of utility programs, and finally Exim itself. The command <literal>make
2656 makefile</literal> can be used to force a rebuild of the make file in the build
2657 directory, should this ever be necessary.
2658 </para>
2659 <para>
2660 If you have problems building Exim, check for any comments there may be in the
2661 <filename>README</filename> file concerning your operating system, and also take a look at the
2662 FAQ, where some common problems are covered.
2663 </para>
2664 </section>
2665 <section id="SECID283">
2666 <title>Output from <quote>make</quote></title>
2667 <para>
2668 The output produced by the <emphasis>make</emphasis> process for compile lines is often very
2669 unreadable, because these lines can be very long. For this reason, the normal
2670 output is suppressed by default, and instead output similar to that which
2671 appears when compiling the 2.6 Linux kernel is generated: just a short line for
2672 each module that is being compiled or linked. However, it is still possible to
2673 get the full output, by calling <emphasis>make</emphasis> like this:
2674 </para>
2675 <literallayout class="monospaced">
2676 FULLECHO='' make -e
2677 </literallayout>
2678 <para>
2679 The value of FULLECHO defaults to <quote>@</quote>, the flag character that suppresses
2680 command reflection in <emphasis>make</emphasis>. When you ask for the full output, it is
2681 given in addition to the short output.
2682 </para>
2683 </section>
2684 <section id="SECToverride">
2685 <title>Overriding build-time options for Exim</title>
2686 <para>
2687 <indexterm role="concept">
2688 <primary>build-time options, overriding</primary>
2689 </indexterm>
2690 The main make file that is created at the beginning of the building process
2691 consists of the concatenation of a number of files which set configuration
2692 values, followed by a fixed set of <emphasis>make</emphasis> instructions. If a value is set
2693 more than once, the last setting overrides any previous ones. This provides a
2694 convenient way of overriding defaults. The files that are concatenated are, in
2695 order:
2696 </para>
2697 <literallayout>
2698 <filename>OS/Makefile-Default</filename>
2699 <filename>OS/Makefile-</filename>&lt;<emphasis>ostype</emphasis>&gt;
2700 <filename>Local/Makefile</filename>
2701 <filename>Local/Makefile-</filename>&lt;<emphasis>ostype</emphasis>&gt;
2702 <filename>Local/Makefile-</filename>&lt;<emphasis>archtype</emphasis>&gt;
2703 <filename>Local/Makefile-</filename>&lt;<emphasis>ostype</emphasis>&gt;-&lt;<emphasis>archtype</emphasis>&gt;
2704 <filename>OS/Makefile-Base</filename>
2705 </literallayout>
2706 <para>
2707 <indexterm role="concept">
2708 <primary><filename>Local/Makefile</filename></primary>
2709 </indexterm>
2710 <indexterm role="concept">
2711 <primary>building Exim</primary>
2712 <secondary>operating system type</secondary>
2713 </indexterm>
2714 <indexterm role="concept">
2715 <primary>building Exim</primary>
2716 <secondary>architecture type</secondary>
2717 </indexterm>
2718 where &lt;<emphasis>ostype</emphasis>&gt; is the operating system type and &lt;<emphasis>archtype</emphasis>&gt; is the
2719 architecture type. <filename>Local/Makefile</filename> is required to exist, and the building
2720 process fails if it is absent. The other three <filename>Local</filename> files are optional,
2721 and are often not needed.
2722 </para>
2723 <para>
2724 The values used for &lt;<emphasis>ostype</emphasis>&gt; and &lt;<emphasis>archtype</emphasis>&gt; are obtained from scripts
2725 called <filename>scripts/os-type</filename> and <filename>scripts/arch-type</filename> respectively. If either of
2726 the environment variables EXIM_OSTYPE or EXIM_ARCHTYPE is set, their
2727 values are used, thereby providing a means of forcing particular settings.
2728 Otherwise, the scripts try to get values from the <option>uname</option> command. If this
2729 fails, the shell variables OSTYPE and ARCHTYPE are inspected. A number
2730 of <emphasis>ad hoc</emphasis> transformations are then applied, to produce the standard names
2731 that Exim expects. You can run these scripts directly from the shell in order
2732 to find out what values are being used on your system.
2733 </para>
2734 <para>
2735 <filename>OS/Makefile-Default</filename> contains comments about the variables that are set
2736 therein. Some (but not all) are mentioned below. If there is something that
2737 needs changing, review the contents of this file and the contents of the make
2738 file for your operating system (<filename>OS/Makefile-&lt;ostype&gt;</filename>) to see what the
2739 default values are.
2740 </para>
2741 <para>
2742 <indexterm role="concept">
2743 <primary>building Exim</primary>
2744 <secondary>overriding default settings</secondary>
2745 </indexterm>
2746 If you need to change any of the values that are set in <filename>OS/Makefile-Default</filename>
2747 or in <filename>OS/Makefile-&lt;ostype&gt;</filename>, or to add any new definitions, you do not
2748 need to change the original files. Instead, you should make the changes by
2749 putting the new values in an appropriate <filename>Local</filename> file. For example,
2750 <indexterm role="concept">
2751 <primary>Tru64-Unix build-time settings</primary>
2752 </indexterm>
2753 when building Exim in many releases of the Tru64-Unix (formerly Digital UNIX,
2754 formerly DEC-OSF1) operating system, it is necessary to specify that the C
2755 compiler is called <emphasis>cc</emphasis> rather than <emphasis>gcc</emphasis>. Also, the compiler must be
2756 called with the option <option>-std1</option>, to make it recognize some of the features of
2757 Standard C that Exim uses. (Most other compilers recognize Standard C by
2758 default.) To do this, you should create a file called <filename>Local/Makefile-OSF1</filename>
2759 containing the lines
2760 </para>
2761 <literallayout class="monospaced">
2762 CC=cc
2763 CFLAGS=-std1
2764 </literallayout>
2765 <para>
2766 If you are compiling for just one operating system, it may be easier to put
2767 these lines directly into <filename>Local/Makefile</filename>.
2768 </para>
2769 <para>
2770 Keeping all your local configuration settings separate from the distributed
2771 files makes it easy to transfer them to new versions of Exim simply by copying
2772 the contents of the <filename>Local</filename> directory.
2773 </para>
2774 <para>
2775 <indexterm role="concept">
2776 <primary>NIS lookup type</primary>
2777 <secondary>including support for</secondary>
2778 </indexterm>
2779 <indexterm role="concept">
2780 <primary>NIS+ lookup type</primary>
2781 <secondary>including support for</secondary>
2782 </indexterm>
2783 <indexterm role="concept">
2784 <primary>LDAP</primary>
2785 <secondary>including support for</secondary>
2786 </indexterm>
2787 <indexterm role="concept">
2788 <primary>lookup</primary>
2789 <secondary>inclusion in binary</secondary>
2790 </indexterm>
2791 Exim contains support for doing LDAP, NIS, NIS+, and other kinds of file
2792 lookup, but not all systems have these components installed, so the default is
2793 not to include the relevant code in the binary. All the different kinds of file
2794 and database lookup that Exim supports are implemented as separate code modules
2795 which are included only if the relevant compile-time options are set. In the
2796 case of LDAP, NIS, and NIS+, the settings for <filename>Local/Makefile</filename> are:
2797 </para>
2798 <literallayout class="monospaced">
2799 LOOKUP_LDAP=yes
2800 LOOKUP_NIS=yes
2801 LOOKUP_NISPLUS=yes
2802 </literallayout>
2803 <para>
2804 and similar settings apply to the other lookup types. They are all listed in
2805 <filename>src/EDITME</filename>. In many cases the relevant include files and interface
2806 libraries need to be installed before compiling Exim.
2807 <indexterm role="concept">
2808 <primary>cdb</primary>
2809 <secondary>including support for</secondary>
2810 </indexterm>
2811 However, there are some optional lookup types (such as cdb) for which
2812 the code is entirely contained within Exim, and no external include
2813 files or libraries are required. When a lookup type is not included in the
2814 binary, attempts to configure Exim to use it cause run time configuration
2815 errors.
2816 </para>
2817 <para>
2818 <indexterm role="concept">
2819 <primary>Perl</primary>
2820 <secondary>including support for</secondary>
2821 </indexterm>
2822 Exim can be linked with an embedded Perl interpreter, allowing Perl
2823 subroutines to be called during string expansion. To enable this facility,
2824 </para>
2825 <literallayout class="monospaced">
2826 EXIM_PERL=perl.o
2827 </literallayout>
2828 <para>
2829 must be defined in <filename>Local/Makefile</filename>. Details of this facility are given in
2830 chapter <xref linkend="CHAPperl"/>.
2831 </para>
2832 <para>
2833 <indexterm role="concept">
2834 <primary>X11 libraries, location of</primary>
2835 </indexterm>
2836 The location of the X11 libraries is something that varies a lot between
2837 operating systems, and there may be different versions of X11 to cope
2838 with. Exim itself makes no use of X11, but if you are compiling the Exim
2839 monitor, the X11 libraries must be available.
2840 The following three variables are set in <filename>OS/Makefile-Default</filename>:
2841 </para>
2842 <literallayout class="monospaced">
2843 X11=/usr/X11R6
2844 XINCLUDE=-I$(X11)/include
2845 XLFLAGS=-L$(X11)/lib
2846 </literallayout>
2847 <para>
2848 These are overridden in some of the operating-system configuration files. For
2849 example, in <filename>OS/Makefile-SunOS5</filename> there is
2850 </para>
2851 <literallayout class="monospaced">
2852 X11=/usr/openwin
2853 XINCLUDE=-I$(X11)/include
2854 XLFLAGS=-L$(X11)/lib -R$(X11)/lib
2855 </literallayout>
2856 <para>
2857 If you need to override the default setting for your operating system, place a
2858 definition of all three of these variables into your
2859 <filename>Local/Makefile-&lt;ostype&gt;</filename> file.
2860 </para>
2861 <para>
2862 <indexterm role="concept">
2863 <primary>EXTRALIBS</primary>
2864 </indexterm>
2865 If you need to add any extra libraries to the link steps, these can be put in a
2866 variable called EXTRALIBS, which appears in all the link commands, but by
2867 default is not defined. In contrast, EXTRALIBS_EXIM is used only on the
2868 command for linking the main Exim binary, and not for any associated utilities.
2869 </para>
2870 <para>
2871 <indexterm role="concept">
2872 <primary>DBM libraries</primary>
2873 <secondary>configuration for building</secondary>
2874 </indexterm>
2875 There is also DBMLIB, which appears in the link commands for binaries that
2876 use DBM functions (see also section <xref linkend="SECTdb"/>). Finally, there is
2877 EXTRALIBS_EXIMON, which appears only in the link step for the Exim monitor
2878 binary, and which can be used, for example, to include additional X11
2879 libraries.
2880 </para>
2881 <para>
2882 <indexterm role="concept">
2883 <primary>configuration file</primary>
2884 <secondary>editing</secondary>
2885 </indexterm>
2886 The make file copes with rebuilding Exim correctly if any of the configuration
2887 files are edited. However, if an optional configuration file is deleted, it is
2888 necessary to touch the associated non-optional file (that is,
2889 <filename>Local/Makefile</filename> or <filename>Local/eximon.conf</filename>) before rebuilding.
2890 </para>
2891 </section>
2892 <section id="SECID30">
2893 <title>OS-specific header files</title>
2894 <para>
2895 <indexterm role="concept">
2896 <primary><filename>os.h</filename></primary>
2897 </indexterm>
2898 <indexterm role="concept">
2899 <primary>building Exim</primary>
2900 <secondary>OS-specific C header files</secondary>
2901 </indexterm>
2902 The <filename>OS</filename> directory contains a number of files with names of the form
2903 <filename>os.h-&lt;ostype&gt;</filename>. These are system-specific C header files that should not
2904 normally need to be changed. There is a list of macro settings that are
2905 recognized in the file <filename>OS/os.configuring</filename>, which should be consulted if you
2906 are porting Exim to a new operating system.
2907 </para>
2908 </section>
2909 <section id="SECID31">
2910 <title>Overriding build-time options for the monitor</title>
2911 <para>
2912 <indexterm role="concept">
2913 <primary>building Eximon</primary>
2914 </indexterm>
2915 A similar process is used for overriding things when building the Exim monitor,
2916 where the files that are involved are
2917 </para>
2918 <literallayout>
2919 <filename>OS/eximon.conf-Default</filename>
2920 <filename>OS/eximon.conf-</filename>&lt;<emphasis>ostype</emphasis>&gt;
2921 <filename>Local/eximon.conf</filename>
2922 <filename>Local/eximon.conf-</filename>&lt;<emphasis>ostype</emphasis>&gt;
2923 <filename>Local/eximon.conf-</filename>&lt;<emphasis>archtype</emphasis>&gt;
2924 <filename>Local/eximon.conf-</filename>&lt;<emphasis>ostype</emphasis>&gt;-&lt;<emphasis>archtype</emphasis>&gt;
2925 </literallayout>
2926 <para>
2927 <indexterm role="concept">
2928 <primary><filename>Local/eximon.conf</filename></primary>
2929 </indexterm>
2930 As with Exim itself, the final three files need not exist, and in this case the
2931 <filename>OS/eximon.conf-&lt;ostype&gt;</filename> file is also optional. The default values in
2932 <filename>OS/eximon.conf-Default</filename> can be overridden dynamically by setting environment
2933 variables of the same name, preceded by EXIMON_. For example, setting
2934 EXIMON_LOG_DEPTH in the environment overrides the value of
2935 LOG_DEPTH at run time.
2936 <indexterm role="concept" startref="IIDbuex" class="endofrange"/>
2937 </para>
2938 </section>
2939 <section id="SECID32">
2940 <title>Installing Exim binaries and scripts</title>
2941 <para>
2942 <indexterm role="concept">
2943 <primary>installing Exim</primary>
2944 </indexterm>
2945 <indexterm role="concept">
2946 <primary>BIN_DIRECTORY</primary>
2947 </indexterm>
2948 The command <literal>make install</literal> runs the <command>exim_install</command> script with no
2949 arguments. The script copies binaries and utility scripts into the directory
2950 whose name is specified by the BIN_DIRECTORY setting in <filename>Local/Makefile</filename>.
2951 <indexterm role="concept">
2952 <primary>setuid</primary>
2953 <secondary>installing Exim with</secondary>
2954 </indexterm>
2955 The install script copies files only if they are newer than the files they are
2956 going to replace. The Exim binary is required to be owned by root and have the
2957 <emphasis>setuid</emphasis> bit set, for normal configurations. Therefore, you must run <literal>make
2958 install</literal> as root so that it can set up the Exim binary in this way. However, in
2959 some special situations (for example, if a host is doing no local deliveries)
2960 it may be possible to run Exim without making the binary setuid root (see
2961 chapter <xref linkend="CHAPsecurity"/> for details).
2962 </para>
2963 <para>
2964 <indexterm role="concept">
2965 <primary>CONFIGURE_FILE</primary>
2966 </indexterm>
2967 Exim&#x2019;s run time configuration file is named by the CONFIGURE_FILE setting
2968 in <filename>Local/Makefile</filename>. If this names a single file, and the file does not
2969 exist, the default configuration file <filename>src/configure.default</filename> is copied there
2970 by the installation script. If a run time configuration file already exists, it
2971 is left alone. If CONFIGURE_FILE is a colon-separated list, naming several
2972 alternative files, no default is installed.
2973 </para>
2974 <para>
2975 <indexterm role="concept">
2976 <primary>system aliases file</primary>
2977 </indexterm>
2978 <indexterm role="concept">
2979 <primary><filename>/etc/aliases</filename></primary>
2980 </indexterm>
2981 One change is made to the default configuration file when it is installed: the
2982 default configuration contains a router that references a system aliases file.
2983 The path to this file is set to the value specified by
2984 SYSTEM_ALIASES_FILE in <filename>Local/Makefile</filename> (<filename>/etc/aliases</filename> by default).
2985 If the system aliases file does not exist, the installation script creates it,
2986 and outputs a comment to the user.
2987 </para>
2988 <para>
2989 The created file contains no aliases, but it does contain comments about the
2990 aliases a site should normally have. Mail aliases have traditionally been
2991 kept in <filename>/etc/aliases</filename>. However, some operating systems are now using
2992 <filename>/etc/mail/aliases</filename>. You should check if yours is one of these, and change
2993 Exim&#x2019;s configuration if necessary.
2994 </para>
2995 <para>
2996 The default configuration uses the local host&#x2019;s name as the only local domain,
2997 and is set up to do local deliveries into the shared directory <filename>/var/mail</filename>,
2998 running as the local user. System aliases and <filename>.forward</filename> files in users&#x2019; home
2999 directories are supported, but no NIS or NIS+ support is configured. Domains
3000 other than the name of the local host are routed using the DNS, with delivery
3001 over SMTP.
3002 </para>
3003 <para>
3004 It is possible to install Exim for special purposes (such as building a binary
3005 distribution) in a private part of the file system. You can do this by a
3006 command such as
3007 </para>
3008 <literallayout class="monospaced">
3009 make DESTDIR=/some/directory/ install
3010 </literallayout>
3011 <para>
3012 This has the effect of pre-pending the specified directory to all the file
3013 paths, except the name of the system aliases file that appears in the default
3014 configuration. (If a default alias file is created, its name <emphasis>is</emphasis> modified.)
3015 For backwards compatibility, ROOT is used if DESTDIR is not set,
3016 but this usage is deprecated.
3017 </para>
3018 <para>
3019 <indexterm role="concept">
3020 <primary>installing Exim</primary>
3021 <secondary>what is not installed</secondary>
3022 </indexterm>
3023 Running <emphasis>make install</emphasis> does not copy the Exim 4 conversion script
3024 <emphasis>convert4r4</emphasis>. You will probably run this only once if you are
3025 upgrading from Exim 3. None of the documentation files in the <filename>doc</filename>
3026 directory are copied, except for the info files when you have set
3027 INFO_DIRECTORY, as described in section <xref linkend="SECTinsinfdoc"/> below.
3028 </para>
3029 <para>
3030 For the utility programs, old versions are renamed by adding the suffix <filename>.O</filename>
3031 to their names. The Exim binary itself, however, is handled differently. It is
3032 installed under a name that includes the version number and the compile number,
3033 for example <filename>exim-4.73-1</filename>. The script then arranges for a symbolic link
3034 called <filename>exim</filename> to point to the binary. If you are updating a previous version
3035 of Exim, the script takes care to ensure that the name <filename>exim</filename> is never absent
3036 from the directory (as seen by other processes).
3037 </para>
3038 <para>
3039 <indexterm role="concept">
3040 <primary>installing Exim</primary>
3041 <secondary>testing the script</secondary>
3042 </indexterm>
3043 If you want to see what the <emphasis>make install</emphasis> will do before running it for
3044 real, you can pass the <option>-n</option> option to the installation script by this
3045 command:
3046 </para>
3047 <literallayout class="monospaced">
3048 make INSTALL_ARG=-n install
3049 </literallayout>
3050 <para>
3051 The contents of the variable INSTALL_ARG are passed to the installation
3052 script. You do not need to be root to run this test. Alternatively, you can run
3053 the installation script directly, but this must be from within the build
3054 directory. For example, from the top-level Exim directory you could use this
3055 command:
3056 </para>
3057 <literallayout class="monospaced">
3058 (cd build-SunOS5-5.5.1-sparc; ../scripts/exim_install -n)
3059 </literallayout>
3060 <para>
3061 <indexterm role="concept">
3062 <primary>installing Exim</primary>
3063 <secondary>install script options</secondary>
3064 </indexterm>
3065 There are two other options that can be supplied to the installation script.
3066 </para>
3067 <itemizedlist>
3068 <listitem>
3069 <para>
3070 <option>-no_chown</option> bypasses the call to change the owner of the installed binary
3071 to root, and the call to make it a setuid binary.
3072 </para>
3073 </listitem>
3074 <listitem>
3075 <para>
3076 <option>-no_symlink</option> bypasses the setting up of the symbolic link <filename>exim</filename> to the
3077 installed binary.
3078 </para>
3079 </listitem>
3080 </itemizedlist>
3081 <para>
3082 INSTALL_ARG can be used to pass these options to the script. For example:
3083 </para>
3084 <literallayout class="monospaced">
3085 make INSTALL_ARG=-no_symlink install
3086 </literallayout>
3087 <para>
3088 The installation script can also be given arguments specifying which files are
3089 to be copied. For example, to install just the Exim binary, and nothing else,
3090 without creating the symbolic link, you could use:
3091 </para>
3092 <literallayout class="monospaced">
3093 make INSTALL_ARG='-no_symlink exim' install
3094 </literallayout>
3095 </section>
3096 <section id="SECTinsinfdoc">
3097 <title>Installing info documentation</title>
3098 <para>
3099 <indexterm role="concept">
3100 <primary>installing Exim</primary>
3101 <secondary><emphasis>info</emphasis> documentation</secondary>
3102 </indexterm>
3103 Not all systems use the GNU <emphasis>info</emphasis> system for documentation, and for this
3104 reason, the Texinfo source of Exim&#x2019;s documentation is not included in the main
3105 distribution. Instead it is available separately from the ftp site (see section
3106 <xref linkend="SECTavail"/>).
3107 </para>
3108 <para>
3109 If you have defined INFO_DIRECTORY in <filename>Local/Makefile</filename> and the Texinfo
3110 source of the documentation is found in the source tree, running <literal>make
3111 install</literal> automatically builds the info files and installs them.
3112 </para>
3113 </section>
3114 <section id="SECID33">
3115 <title>Setting up the spool directory</title>
3116 <para>
3117 <indexterm role="concept">
3118 <primary>spool directory</primary>
3119 <secondary>creating</secondary>
3120 </indexterm>
3121 When it starts up, Exim tries to create its spool directory if it does not
3122 exist. The Exim uid and gid are used for the owner and group of the spool
3123 directory. Sub-directories are automatically created in the spool directory as
3124 necessary.
3125 </para>
3126 </section>
3127 <section id="SECID34">
3128 <title>Testing</title>
3129 <para>
3130 <indexterm role="concept">
3131 <primary>testing</primary>
3132 <secondary>installation</secondary>
3133 </indexterm>
3134 Having installed Exim, you can check that the run time configuration file is
3135 syntactically valid by running the following command, which assumes that the
3136 Exim binary directory is within your PATH environment variable:
3137 </para>
3138 <literallayout class="monospaced">
3139 exim -bV
3140 </literallayout>
3141 <para>
3142 If there are any errors in the configuration file, Exim outputs error messages.
3143 Otherwise it outputs the version number and build date,
3144 the DBM library that is being used, and information about which drivers and
3145 other optional code modules are included in the binary.
3146 Some simple routing tests can be done by using the address testing option. For
3147 example,
3148 </para>
3149 <literallayout>
3150 <literal>exim -bt</literal> &lt;<emphasis>local username</emphasis>&gt;
3151 </literallayout>
3152 <para>
3153 should verify that it recognizes a local mailbox, and
3154 </para>
3155 <literallayout>
3156 <literal>exim -bt</literal> &lt;<emphasis>remote address</emphasis>&gt;
3157 </literallayout>
3158 <para>
3159 a remote one. Then try getting it to deliver mail, both locally and remotely.
3160 This can be done by passing messages directly to Exim, without going through a
3161 user agent. For example:
3162 </para>
3163 <literallayout class="monospaced">
3164 exim -v postmaster@your.domain.example
3165 From: user@your.domain.example
3166 To: postmaster@your.domain.example
3167 Subject: Testing Exim
3168
3169 This is a test message.
3170 ^D
3171 </literallayout>
3172 <para>
3173 The <option>-v</option> option causes Exim to output some verification of what it is doing.
3174 In this case you should see copies of three log lines, one for the message&#x2019;s
3175 arrival, one for its delivery, and one containing <quote>Completed</quote>.
3176 </para>
3177 <para>
3178 <indexterm role="concept">
3179 <primary>delivery</primary>
3180 <secondary>problems with</secondary>
3181 </indexterm>
3182 If you encounter problems, look at Exim&#x2019;s log files (<emphasis>mainlog</emphasis> and
3183 <emphasis>paniclog</emphasis>) to see if there is any relevant information there. Another source
3184 of information is running Exim with debugging turned on, by specifying the
3185 <option>-d</option> option. If a message is stuck on Exim&#x2019;s spool, you can force a delivery
3186 with debugging turned on by a command of the form
3187 </para>
3188 <literallayout>
3189 <literal>exim -d -M</literal> &lt;<emphasis>exim-message-id</emphasis>&gt;
3190 </literallayout>
3191 <para>
3192 You must be root or an <quote>admin user</quote> in order to do this. The <option>-d</option> option
3193 produces rather a lot of output, but you can cut this down to specific areas.
3194 For example, if you use <option>-d-all+route</option> only the debugging information
3195 relevant to routing is included. (See the <option>-d</option> option in chapter
3196 <xref linkend="CHAPcommandline"/> for more details.)
3197 </para>
3198 <para>
3199 <indexterm role="concept">
3200 <primary><quote>sticky</quote> bit</primary>
3201 </indexterm>
3202 <indexterm role="concept">
3203 <primary>lock files</primary>
3204 </indexterm>
3205 One specific problem that has shown up on some sites is the inability to do
3206 local deliveries into a shared mailbox directory, because it does not have the
3207 <quote>sticky bit</quote> set on it. By default, Exim tries to create a lock file before
3208 writing to a mailbox file, and if it cannot create the lock file, the delivery
3209 is deferred. You can get round this either by setting the <quote>sticky bit</quote> on the
3210 directory, or by setting a specific group for local deliveries and allowing
3211 that group to create files in the directory (see the comments above the
3212 <command>local_delivery</command> transport in the default configuration file). Another
3213 approach is to configure Exim not to use lock files, but just to rely on
3214 <function>fcntl()</function> locking instead. However, you should do this only if all user
3215 agents also use <function>fcntl()</function> locking. For further discussion of locking issues,
3216 see chapter <xref linkend="CHAPappendfile"/>.
3217 </para>
3218 <para>
3219 One thing that cannot be tested on a system that is already running an MTA is
3220 the receipt of incoming SMTP mail on the standard SMTP port. However, the
3221 <option>-oX</option> option can be used to run an Exim daemon that listens on some other
3222 port, or <emphasis>inetd</emphasis> can be used to do this. The <option>-bh</option> option and the
3223 <emphasis>exim_checkaccess</emphasis> utility can be used to check out policy controls on
3224 incoming SMTP mail.
3225 </para>
3226 <para>
3227 Testing a new version on a system that is already running Exim can most easily
3228 be done by building a binary with a different CONFIGURE_FILE setting. From
3229 within the run time configuration, all other file and directory names
3230 that Exim uses can be altered, in order to keep it entirely clear of the
3231 production version.
3232 </para>
3233 </section>
3234 <section id="SECID35">
3235 <title>Replacing another MTA with Exim</title>
3236 <para>
3237 <indexterm role="concept">
3238 <primary>replacing another MTA</primary>
3239 </indexterm>
3240 Building and installing Exim for the first time does not of itself put it in
3241 general use. The name by which the system&#x2019;s MTA is called by mail user agents
3242 is either <filename>/usr/sbin/sendmail</filename>, or <filename>/usr/lib/sendmail</filename> (depending on the
3243 operating system), and it is necessary to make this name point to the <emphasis>exim</emphasis>
3244 binary in order to get the user agents to pass messages to Exim. This is
3245 normally done by renaming any existing file and making <filename>/usr/sbin/sendmail</filename>
3246 or <filename>/usr/lib/sendmail</filename>
3247 <indexterm role="concept">
3248 <primary>symbolic link</primary>
3249 <secondary>to <emphasis>exim</emphasis> binary</secondary>
3250 </indexterm>
3251 a symbolic link to the <emphasis>exim</emphasis> binary. It is a good idea to remove any setuid
3252 privilege and executable status from the old MTA. It is then necessary to stop
3253 and restart the mailer daemon, if one is running.
3254 </para>
3255 <para>
3256 <indexterm role="concept">
3257 <primary>FreeBSD, MTA indirection</primary>
3258 </indexterm>
3259 <indexterm role="concept">
3260 <primary><filename>/etc/mail/mailer.conf</filename></primary>
3261 </indexterm>
3262 Some operating systems have introduced alternative ways of switching MTAs. For
3263 example, if you are running FreeBSD, you need to edit the file
3264 <filename>/etc/mail/mailer.conf</filename> instead of setting up a symbolic link as just
3265 described. A typical example of the contents of this file for running Exim is
3266 as follows:
3267 </para>
3268 <literallayout class="monospaced">
3269 sendmail            /usr/exim/bin/exim
3270 send-mail           /usr/exim/bin/exim
3271 mailq               /usr/exim/bin/exim -bp
3272 newaliases          /usr/bin/true
3273 </literallayout>
3274 <para>
3275 Once you have set up the symbolic link, or edited <filename>/etc/mail/mailer.conf</filename>,
3276 your Exim installation is <quote>live</quote>. Check it by sending a message from your
3277 favourite user agent.
3278 </para>
3279 <para>
3280 You should consider what to tell your users about the change of MTA. Exim may
3281 have different capabilities to what was previously running, and there are
3282 various operational differences such as the text of messages produced by
3283 command line options and in bounce messages. If you allow your users to make
3284 use of Exim&#x2019;s filtering capabilities, you should make the document entitled
3285 <emphasis>Exim&#x2019;s interface to mail filtering</emphasis> available to them.
3286 </para>
3287 </section>
3288 <section id="SECID36">
3289 <title>Upgrading Exim</title>
3290 <para>
3291 <indexterm role="concept">
3292 <primary>upgrading Exim</primary>
3293 </indexterm>
3294 If you are already running Exim on your host, building and installing a new
3295 version automatically makes it available to MUAs, or any other programs that
3296 call the MTA directly. However, if you are running an Exim daemon, you do need
3297 to send it a HUP signal, to make it re-execute itself, and thereby pick up the
3298 new binary. You do not need to stop processing mail in order to install a new
3299 version of Exim. The install script does not modify an existing runtime
3300 configuration file.
3301 </para>
3302 </section>
3303 <section id="SECID37">
3304 <title>Stopping the Exim daemon on Solaris</title>
3305 <para>
3306 <indexterm role="concept">
3307 <primary>Solaris</primary>
3308 <secondary>stopping Exim on</secondary>
3309 </indexterm>
3310 The standard command for stopping the mailer daemon on Solaris is
3311 </para>
3312 <literallayout class="monospaced">
3313 /etc/init.d/sendmail stop
3314 </literallayout>
3315 <para>
3316 If <filename>/usr/lib/sendmail</filename> has been turned into a symbolic link, this script
3317 fails to stop Exim because it uses the command <emphasis>ps -e</emphasis> and greps the output
3318 for the text <quote>sendmail</quote>; this is not present because the actual program name
3319 (that is, <quote>exim</quote>) is given by the <emphasis>ps</emphasis> command with these options. A
3320 solution is to replace the line that finds the process id with something like
3321 </para>
3322 <literallayout class="monospaced">
3323 pid=`cat /var/spool/exim/exim-daemon.pid`
3324 </literallayout>
3325 <para>
3326 to obtain the daemon&#x2019;s pid directly from the file that Exim saves it in.
3327 </para>
3328 <para>
3329 Note, however, that stopping the daemon does not <quote>stop Exim</quote>. Messages can
3330 still be received from local processes, and if automatic delivery is configured
3331 (the normal case), deliveries will still occur.
3332 </para>
3333 </section>
3334 </chapter>
3335
3336 <chapter id="CHAPcommandline">
3337 <title>The Exim command line</title>
3338 <para>
3339 <indexterm role="concept" id="IIDclo1" class="startofrange">
3340 <primary>command line</primary>
3341 <secondary>options</secondary>
3342 </indexterm>
3343 <indexterm role="concept" id="IIDclo2" class="startofrange">
3344 <primary>options</primary>
3345 <secondary>command line</secondary>
3346 </indexterm>
3347 Exim&#x2019;s command line takes the standard Unix form of a sequence of options,
3348 each starting with a hyphen character, followed by a number of arguments. The
3349 options are compatible with the main options of Sendmail, and there are also
3350 some additional options, some of which are compatible with Smail 3. Certain
3351 combinations of options do not make sense, and provoke an error if used.
3352 The form of the arguments depends on which options are set.
3353 </para>
3354 <section id="SECID38">
3355 <title>Setting options by program name</title>
3356 <para>
3357 <indexterm role="concept">
3358 <primary><emphasis>mailq</emphasis></primary>
3359 </indexterm>
3360 If Exim is called under the name <emphasis>mailq</emphasis>, it behaves as if the option <option>-bp</option>
3361 were present before any other options.
3362 The <option>-bp</option> option requests a listing of the contents of the mail queue on the
3363 standard output.
3364 This feature is for compatibility with some systems that contain a command of
3365 that name in one of the standard libraries, symbolically linked to
3366 <filename>/usr/sbin/sendmail</filename> or <filename>/usr/lib/sendmail</filename>.
3367 </para>
3368 <para>
3369 <indexterm role="concept">
3370 <primary><emphasis>rsmtp</emphasis></primary>
3371 </indexterm>
3372 If Exim is called under the name <emphasis>rsmtp</emphasis> it behaves as if the option <option>-bS</option>
3373 were present before any other options, for compatibility with Smail. The
3374 <option>-bS</option> option is used for reading in a number of messages in batched SMTP
3375 format.
3376 </para>
3377 <para>
3378 <indexterm role="concept">
3379 <primary><emphasis>rmail</emphasis></primary>
3380 </indexterm>
3381 If Exim is called under the name <emphasis>rmail</emphasis> it behaves as if the <option>-i</option> and
3382 <option>-oee</option> options were present before any other options, for compatibility with
3383 Smail. The name <emphasis>rmail</emphasis> is used as an interface by some UUCP systems.
3384 </para>
3385 <para>
3386 <indexterm role="concept">
3387 <primary><emphasis>runq</emphasis></primary>
3388 </indexterm>
3389 <indexterm role="concept">
3390 <primary>queue runner</primary>
3391 </indexterm>
3392 If Exim is called under the name <emphasis>runq</emphasis> it behaves as if the option <option>-q</option>
3393 were present before any other options, for compatibility with Smail. The <option>-q</option>
3394 option causes a single queue runner process to be started.
3395 </para>
3396 <para>
3397 <indexterm role="concept">
3398 <primary><emphasis>newaliases</emphasis></primary>
3399 </indexterm>
3400 <indexterm role="concept">
3401 <primary>alias file</primary>
3402 <secondary>building</secondary>
3403 </indexterm>
3404 <indexterm role="concept">
3405 <primary>Sendmail compatibility</primary>
3406 <secondary>calling Exim as <emphasis>newaliases</emphasis></secondary>
3407 </indexterm>
3408 If Exim is called under the name <emphasis>newaliases</emphasis> it behaves as if the option
3409 <option>-bi</option> were present before any other options, for compatibility with Sendmail.
3410 This option is used for rebuilding Sendmail&#x2019;s alias file. Exim does not have
3411 the concept of a single alias file, but can be configured to run a given
3412 command if called with the <option>-bi</option> option.
3413 </para>
3414 </section>
3415 <section id="SECTtrustedadmin">
3416 <title>Trusted and admin users</title>
3417 <para>
3418 Some Exim options are available only to <emphasis>trusted users</emphasis> and others are
3419 available only to <emphasis>admin users</emphasis>. In the description below, the phrases <quote>Exim
3420 user</quote> and <quote>Exim group</quote> mean the user and group defined by EXIM_USER and
3421 EXIM_GROUP in <filename>Local/Makefile</filename> or set by the <option>exim_user</option> and
3422 <option>exim_group</option> options. These do not necessarily have to use the name <quote>exim</quote>.
3423 </para>
3424 <itemizedlist>
3425 <listitem>
3426 <para>
3427 <indexterm role="concept">
3428 <primary>trusted users</primary>
3429 <secondary>definition of</secondary>
3430 </indexterm>
3431 <indexterm role="concept">
3432 <primary>user</primary>
3433 <secondary>trusted definition of</secondary>
3434 </indexterm>
3435 The trusted users are root, the Exim user, any user listed in the
3436 <option>trusted_users</option> configuration option, and any user whose current group or any
3437 supplementary group is one of those listed in the <option>trusted_groups</option>
3438 configuration option. Note that the Exim group is not automatically trusted.
3439 </para>
3440 <para>
3441 <indexterm role="concept">
3442 <primary><quote>From</quote> line</primary>
3443 </indexterm>
3444 <indexterm role="concept">
3445 <primary>envelope sender</primary>
3446 </indexterm>
3447 Trusted users are always permitted to use the <option>-f</option> option or a leading
3448 <quote>From&nbsp;</quote> line to specify the envelope sender of a message that is passed to
3449 Exim through the local interface (see the <option>-bm</option> and <option>-f</option> options below).
3450 See the <option>untrusted_set_sender</option> option for a way of permitting non-trusted
3451 users to set envelope senders.
3452 </para>
3453 <para>
3454 <indexterm role="concept">
3455 <primary><emphasis>From:</emphasis> header line</primary>
3456 </indexterm>
3457 <indexterm role="concept">
3458 <primary><emphasis>Sender:</emphasis> header line</primary>
3459 </indexterm>
3460 For a trusted user, there is never any check on the contents of the <emphasis>From:</emphasis>
3461 header line, and a <emphasis>Sender:</emphasis> line is never added. Furthermore, any existing
3462 <emphasis>Sender:</emphasis> line in incoming local (non-TCP/IP) messages is not removed.
3463 </para>
3464 <para>
3465 Trusted users may also specify a host name, host address, interface address,
3466 protocol name, ident value, and authentication data when submitting a message
3467 locally. Thus, they are able to insert messages into Exim&#x2019;s queue locally that
3468 have the characteristics of messages received from a remote host. Untrusted
3469 users may in some circumstances use <option>-f</option>, but can never set the other values
3470 that are available to trusted users.
3471 </para>
3472 </listitem>
3473 <listitem>
3474 <para>
3475 <indexterm role="concept">
3476 <primary>user</primary>
3477 <secondary>admin definition of</secondary>
3478 </indexterm>
3479 <indexterm role="concept">
3480 <primary>admin user</primary>
3481 <secondary>definition of</secondary>
3482 </indexterm>
3483 The admin users are root, the Exim user, and any user that is a member of the
3484 Exim group or of any group listed in the <option>admin_groups</option> configuration option.
3485 The current group does not have to be one of these groups.
3486 </para>
3487 <para>
3488 Admin users are permitted to list the queue, and to carry out certain
3489 operations on messages, for example, to force delivery failures. It is also
3490 necessary to be an admin user in order to see the full information provided by
3491 the Exim monitor, and full debugging output.
3492 </para>
3493 <para>
3494 By default, the use of the <option>-M</option>, <option>-q</option>, <option>-R</option>, and <option>-S</option> options to cause
3495 Exim to attempt delivery of messages on its queue is restricted to admin users.
3496 However, this restriction can be relaxed by setting the <option>prod_requires_admin</option>
3497 option false (that is, specifying <option>no_prod_requires_admin</option>).
3498 </para>
3499 <para>
3500 Similarly, the use of the <option>-bp</option> option to list all the messages in the queue
3501 is restricted to admin users unless <option>queue_list_requires_admin</option> is set
3502 false.
3503 </para>
3504 </listitem>
3505 </itemizedlist>
3506 <para>
3507 <emphasis role="bold">Warning</emphasis>: If you configure your system so that admin users are able to
3508 edit Exim&#x2019;s configuration file, you are giving those users an easy way of
3509 getting root. There is further discussion of this issue at the start of chapter
3510 <xref linkend="CHAPconf"/>.
3511 </para>
3512 </section>
3513 <section id="SECID39">
3514 <title>Command line options</title>
3515 <para>
3516 Exim&#x2019;s command line options are described in alphabetical order below. If none
3517 of the options that specifies a specific action (such as starting the daemon or
3518 a queue runner, or testing an address, or receiving a message in a specific
3519 format, or listing the queue) are present, and there is at least one argument
3520 on the command line, <option>-bm</option> (accept a local message on the standard input,
3521 with the arguments specifying the recipients) is assumed. Otherwise, Exim
3522 outputs a brief message about itself and exits.
3523 </para>
3524 <!-- === Start of command line options === -->
3525 <variablelist>
3526 <varlistentry>
3527 <term><option>--</option></term>
3528 <listitem>
3529 <para>
3530 <indexterm role="option">
3531 <primary>--</primary>
3532 </indexterm>
3533 <indexterm role="concept">
3534 <primary>options</primary>
3535 <secondary>command line; terminating</secondary>
3536 </indexterm>
3537 This is a pseudo-option whose only purpose is to terminate the options and
3538 therefore to cause subsequent command line items to be treated as arguments
3539 rather than options, even if they begin with hyphens.
3540 </para>
3541 </listitem></varlistentry>
3542 <varlistentry>
3543 <term><option>--help</option></term>
3544 <listitem>
3545 <para>
3546 <indexterm role="option">
3547 <primary><option>--help</option></primary>
3548 </indexterm>
3549 This option causes Exim to output a few sentences stating what it is.
3550 The same output is generated if the Exim binary is called with no options and
3551 no arguments.
3552 </para>
3553 </listitem></varlistentry>
3554 <varlistentry revisionflag="changed">
3555 <term><option>--version</option></term>
3556 <listitem>
3557 <para revisionflag="changed">
3558 <indexterm role="option">
3559 <primary><option>--version</option></primary>
3560 </indexterm>
3561 This option is an alias for <option>-bV</option> and causes version information to be
3562 displayed.
3563 </para>
3564 </listitem></varlistentry>
3565 <varlistentry>
3566 <term><option>-B</option>&lt;<emphasis>type</emphasis>&gt;</term>
3567 <listitem>
3568 <para>
3569 <indexterm role="option">
3570 <primary><option>-B</option></primary>
3571 </indexterm>
3572 <indexterm role="concept">
3573 <primary>8-bit characters</primary>
3574 </indexterm>
3575 <indexterm role="concept">
3576 <primary>Sendmail compatibility</primary>
3577 <secondary>8-bit characters</secondary>
3578 </indexterm>
3579 This is a Sendmail option for selecting 7 or 8 bit processing. Exim is 8-bit
3580 clean; it ignores this option.
3581 </para>
3582 </listitem></varlistentry>
3583 <varlistentry>
3584 <term><option>-bd</option></term>
3585 <listitem>
3586 <para>
3587 <indexterm role="option">
3588 <primary><option>-bd</option></primary>
3589 </indexterm>
3590 <indexterm role="concept">
3591 <primary>daemon</primary>
3592 </indexterm>
3593 <indexterm role="concept">
3594 <primary>SMTP</primary>
3595 <secondary>listener</secondary>
3596 </indexterm>
3597 <indexterm role="concept">
3598 <primary>queue runner</primary>
3599 </indexterm>
3600 This option runs Exim as a daemon, awaiting incoming SMTP connections. Usually
3601 the <option>-bd</option> option is combined with the <option>-q</option>&lt;<emphasis>time</emphasis>&gt; option, to specify
3602 that the daemon should also initiate periodic queue runs.
3603 </para>
3604 <para>
3605 The <option>-bd</option> option can be used only by an admin user. If either of the <option>-d</option>
3606 (debugging) or <option>-v</option> (verifying) options are set, the daemon does not
3607 disconnect from the controlling terminal. When running this way, it can be
3608 stopped by pressing ctrl-C.
3609 </para>
3610 <para>
3611 By default, Exim listens for incoming connections to the standard SMTP port on
3612 all the host&#x2019;s running interfaces. However, it is possible to listen on other
3613 ports, on multiple ports, and only on specific interfaces. Chapter
3614 <xref linkend="CHAPinterfaces"/> contains a description of the options that control this.
3615 </para>
3616 <para>
3617 When a listening daemon
3618 <indexterm role="concept">
3619 <primary>daemon</primary>
3620 <secondary>process id (pid)</secondary>
3621 </indexterm>
3622 <indexterm role="concept">
3623 <primary>pid (process id)</primary>
3624 <secondary>of daemon</secondary>
3625 </indexterm>
3626 is started without the use of <option>-oX</option> (that is, without overriding the normal
3627 configuration), it writes its process id to a file called <filename>exim-daemon.pid</filename>
3628 in Exim&#x2019;s spool directory. This location can be overridden by setting
3629 PID_FILE_PATH in <filename>Local/Makefile</filename>. The file is written while Exim is still
3630 running as root.
3631 </para>
3632 <para>
3633 When <option>-oX</option> is used on the command line to start a listening daemon, the
3634 process id is not written to the normal pid file path. However, <option>-oP</option> can be
3635 used to specify a path on the command line if a pid file is required.
3636 </para>
3637 <para>
3638 The SIGHUP signal
3639 <indexterm role="concept">
3640 <primary>SIGHUP</primary>
3641 </indexterm>
3642 <indexterm role="concept">
3643 <primary>daemon</primary>
3644 <secondary>restarting</secondary>
3645 </indexterm>
3646 can be used to cause the daemon to re-execute itself. This should be done
3647 whenever Exim&#x2019;s configuration file, or any file that is incorporated into it by
3648 means of the <option>.include</option> facility, is changed, and also whenever a new version
3649 of Exim is installed. It is not necessary to do this when other files that are
3650 referenced from the configuration (for example, alias files) are changed,
3651 because these are reread each time they are used.
3652 </para>
3653 </listitem></varlistentry>
3654 <varlistentry>
3655 <term><option>-bdf</option></term>
3656 <listitem>
3657 <para>
3658 <indexterm role="option">
3659 <primary><option>-bdf</option></primary>
3660 </indexterm>
3661 This option has the same effect as <option>-bd</option> except that it never disconnects
3662 from the controlling terminal, even when no debugging is specified.
3663 </para>
3664 </listitem></varlistentry>
3665 <varlistentry>
3666 <term><option>-be</option></term>
3667 <listitem>
3668 <para>
3669 <indexterm role="option">
3670 <primary><option>-be</option></primary>
3671 </indexterm>
3672 <indexterm role="concept">
3673 <primary>testing</primary>
3674 <secondary>string expansion</secondary>
3675 </indexterm>
3676 <indexterm role="concept">
3677 <primary>expansion</primary>
3678 <secondary>testing</secondary>
3679 </indexterm>
3680 Run Exim in expansion testing mode. Exim discards its root privilege, to
3681 prevent ordinary users from using this mode to read otherwise inaccessible
3682 files. If no arguments are given, Exim runs interactively, prompting for lines
3683 of data. Otherwise, it processes each argument in turn.
3684 </para>
3685 <para>
3686 If Exim was built with USE_READLINE=yes in <filename>Local/Makefile</filename>, it tries
3687 to load the <option>libreadline</option> library dynamically whenever the <option>-be</option> option is
3688 used without command line arguments. If successful, it uses the <function>readline()</function>
3689 function, which provides extensive line-editing facilities, for reading the
3690 test data. A line history is supported.
3691 </para>
3692 <para>
3693 Long expansion expressions can be split over several lines by using backslash
3694 continuations. As in Exim&#x2019;s run time configuration, white space at the start of
3695 continuation lines is ignored. Each argument or data line is passed through the
3696 string expansion mechanism, and the result is output. Variable values from the
3697 configuration file (for example, <varname>$qualify_domain</varname>) are available, but no
3698 message-specific values (such as <varname>$sender_domain</varname>) are set, because no message
3699 is being processed (but see <option>-bem</option> and <option>-Mset</option>).
3700 </para>
3701 <para>
3702 <emphasis role="bold">Note</emphasis>: If you use this mechanism to test lookups, and you change the data
3703 files or databases you are using, you must exit and restart Exim before trying
3704 the same lookup again. Otherwise, because each Exim process caches the results
3705 of lookups, you will just get the same result as before.
3706 </para>
3707 </listitem></varlistentry>
3708 <varlistentry>
3709 <term><option>-bem</option>&nbsp;&lt;<emphasis>filename</emphasis>&gt;</term>
3710 <listitem>
3711 <para>
3712 <indexterm role="option">
3713 <primary><option>-bem</option></primary>
3714 </indexterm>
3715 <indexterm role="concept">
3716 <primary>testing</primary>
3717 <secondary>string expansion</secondary>
3718 </indexterm>
3719 <indexterm role="concept">
3720 <primary>expansion</primary>
3721 <secondary>testing</secondary>
3722 </indexterm>
3723 This option operates like <option>-be</option> except that it must be followed by the name
3724 of a file. For example:
3725 </para>
3726 <literallayout class="monospaced">
3727 exim -bem /tmp/testmessage
3728 </literallayout>
3729 <para>
3730 The file is read as a message (as if receiving a locally-submitted non-SMTP
3731 message) before any of the test expansions are done. Thus, message-specific
3732 variables such as <varname>$message_size</varname> and <varname>$header_from:</varname> are available. However,
3733 no <emphasis>Received:</emphasis> header is added to the message. If the <option>-t</option> option is set,
3734 recipients are read from the headers in the normal way, and are shown in the
3735 <varname>$recipients</varname> variable. Note that recipients cannot be given on the command
3736 line, because further arguments are taken as strings to expand (just like
3737 <option>-be</option>).
3738 </para>
3739 </listitem></varlistentry>
3740 <varlistentry>
3741 <term><option>-bF</option>&nbsp;&lt;<emphasis>filename</emphasis>&gt;</term>
3742 <listitem>
3743 <para>
3744 <indexterm role="option">
3745 <primary><option>-bF</option></primary>
3746 </indexterm>
3747 <indexterm role="concept">
3748 <primary>system filter</primary>
3749 <secondary>testing</secondary>
3750 </indexterm>
3751 <indexterm role="concept">
3752 <primary>testing</primary>
3753 <secondary>system filter</secondary>
3754 </indexterm>
3755 This option is the same as <option>-bf</option> except that it assumes that the filter being
3756 tested is a system filter. The additional commands that are available only in
3757 system filters are recognized.
3758 </para>
3759 </listitem></varlistentry>
3760 <varlistentry>
3761 <term><option>-bf</option>&nbsp;&lt;<emphasis>filename</emphasis>&gt;</term>
3762 <listitem>
3763 <para>
3764 <indexterm role="option">
3765 <primary><option>-bf</option></primary>
3766 </indexterm>
3767 <indexterm role="concept">
3768 <primary>filter</primary>
3769 <secondary>testing</secondary>
3770 </indexterm>
3771 <indexterm role="concept">
3772 <primary>testing</primary>
3773 <secondary>filter file</secondary>
3774 </indexterm>
3775 <indexterm role="concept">
3776 <primary>forward file</primary>
3777 <secondary>testing</secondary>
3778 </indexterm>
3779 <indexterm role="concept">
3780 <primary>testing</primary>
3781 <secondary>forward file</secondary>
3782 </indexterm>
3783 <indexterm role="concept">
3784 <primary>Sieve filter</primary>
3785 <secondary>testing</secondary>
3786 </indexterm>
3787 This option runs Exim in user filter testing mode; the file is the filter file
3788 to be tested, and a test message must be supplied on the standard input. If
3789 there are no message-dependent tests in the filter, an empty file can be
3790 supplied.
3791 </para>
3792 <para>
3793 If you want to test a system filter file, use <option>-bF</option> instead of <option>-bf</option>. You
3794 can use both <option>-bF</option> and <option>-bf</option> on the same command, in order to test a system
3795 filter and a user filter in the same run. For example:
3796 </para>
3797 <literallayout class="monospaced">
3798 exim -bF /system/filter -bf /user/filter &lt;/test/message
3799 </literallayout>
3800 <para>
3801 This is helpful when the system filter adds header lines or sets filter
3802 variables that are used by the user filter.
3803 </para>
3804 <para>
3805 If the test filter file does not begin with one of the special lines
3806 </para>
3807 <literallayout class="monospaced">
3808 # Exim filter
3809 # Sieve filter
3810 </literallayout>
3811 <para>
3812 it is taken to be a normal <filename>.forward</filename> file, and is tested for validity under
3813 that interpretation. See sections <xref linkend="SECTitenonfilred"/> to
3814 <xref linkend="SECTspecitredli"/> for a description of the possible contents of non-filter
3815 redirection lists.
3816 </para>
3817 <para>
3818 The result of an Exim command that uses <option>-bf</option>, provided no errors are
3819 detected, is a list of the actions that Exim would try to take if presented
3820 with the message for real. More details of filter testing are given in the
3821 separate document entitled <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis>.
3822 </para>
3823 <para>
3824 When testing a filter file,
3825 <indexterm role="concept">
3826 <primary><quote>From</quote> line</primary>
3827 </indexterm>
3828 <indexterm role="concept">
3829 <primary>envelope sender</primary>
3830 </indexterm>
3831 <indexterm role="option">
3832 <primary><option>-f</option></primary>
3833 <secondary>for filter testing</secondary>
3834 </indexterm>
3835 the envelope sender can be set by the <option>-f</option> option,
3836 or by a <quote>From&nbsp;</quote> line at the start of the test message. Various parameters
3837 that would normally be taken from the envelope recipient address of the message
3838 can be set by means of additional command line options (see the next four
3839 options).
3840 </para>
3841 </listitem></varlistentry>
3842 <varlistentry>
3843 <term><option>-bfd</option>&nbsp;&lt;<emphasis>domain</emphasis>&gt;</term>
3844 <listitem>
3845 <para>
3846 <indexterm role="option">
3847 <primary><option>-bfd</option></primary>
3848 </indexterm>
3849 <indexterm role="variable">
3850 <primary><varname>$qualify_domain</varname></primary>
3851 </indexterm>
3852 This sets the domain of the recipient address when a filter file is being
3853 tested by means of the <option>-bf</option> option. The default is the value of
3854 <varname>$qualify_domain</varname>.
3855 </para>
3856 </listitem></varlistentry>
3857 <varlistentry>
3858 <term><option>-bfl</option>&nbsp;&lt;<emphasis>local&nbsp;part</emphasis>&gt;</term>
3859 <listitem>
3860 <para>
3861 <indexterm role="option">
3862 <primary><option>-bfl</option></primary>
3863 </indexterm>
3864 This sets the local part of the recipient address when a filter file is being
3865 tested by means of the <option>-bf</option> option. The default is the username of the
3866 process that calls Exim. A local part should be specified with any prefix or
3867 suffix stripped, because that is how it appears to the filter when a message is
3868 actually being delivered.
3869 </para>
3870 </listitem></varlistentry>
3871 <varlistentry>
3872 <term><option>-bfp</option>&nbsp;&lt;<emphasis>prefix</emphasis>&gt;</term>
3873 <listitem>
3874 <para>
3875 <indexterm role="option">
3876 <primary><option>-bfp</option></primary>
3877 </indexterm>
3878 This sets the prefix of the local part of the recipient address when a filter
3879 file is being tested by means of the <option>-bf</option> option. The default is an empty
3880 prefix.
3881 </para>
3882 </listitem></varlistentry>
3883 <varlistentry>
3884 <term><option>-bfs</option>&nbsp;&lt;<emphasis>suffix</emphasis>&gt;</term>
3885 <listitem>
3886 <para>
3887 <indexterm role="option">
3888 <primary><option>-bfs</option></primary>
3889 </indexterm>
3890 This sets the suffix of the local part of the recipient address when a filter
3891 file is being tested by means of the <option>-bf</option> option. The default is an empty
3892 suffix.
3893 </para>
3894 </listitem></varlistentry>
3895 <varlistentry>
3896 <term><option>-bh</option>&nbsp;&lt;<emphasis>IP&nbsp;address</emphasis>&gt;</term>
3897 <listitem>
3898 <para>
3899 <indexterm role="option">
3900 <primary><option>-bh</option></primary>
3901 </indexterm>
3902 <indexterm role="concept">
3903 <primary>testing</primary>
3904 <secondary>incoming SMTP</secondary>
3905 </indexterm>
3906 <indexterm role="concept">
3907 <primary>SMTP</primary>
3908 <secondary>testing incoming</secondary>
3909 </indexterm>
3910 <indexterm role="concept">
3911 <primary>testing</primary>
3912 <secondary>relay control</secondary>
3913 </indexterm>
3914 <indexterm role="concept">
3915 <primary>relaying</primary>
3916 <secondary>testing configuration</secondary>
3917 </indexterm>
3918 <indexterm role="concept">
3919 <primary>policy control</primary>
3920 <secondary>testing</secondary>
3921 </indexterm>
3922 <indexterm role="concept">
3923 <primary>debugging</primary>
3924 <secondary><option>-bh</option> option</secondary>
3925 </indexterm>
3926 This option runs a fake SMTP session as if from the given IP address, using the
3927 standard input and output. The IP address may include a port number at the end,
3928 after a full stop. For example:
3929 </para>
3930 <literallayout class="monospaced">
3931 exim -bh 10.9.8.7.1234
3932 exim -bh fe80::a00:20ff:fe86:a061.5678
3933 </literallayout>
3934 <para>
3935 When an IPv6 address is given, it is converted into canonical form. In the case
3936 of the second example above, the value of <varname>$sender_host_address</varname> after
3937 conversion to the canonical form is
3938 <literal>fe80:0000:0000:0a00:20ff:fe86:a061.5678</literal>.
3939 </para>
3940 <para>
3941 Comments as to what is going on are written to the standard error file. These
3942 include lines beginning with <quote>LOG</quote> for anything that would have been logged.
3943 This facility is provided for testing configuration options for incoming
3944 messages, to make sure they implement the required policy. For example, you can
3945 test your relay controls using <option>-bh</option>.
3946 </para>
3947 <para>
3948 <emphasis role="bold">Warning 1</emphasis>:
3949 <indexterm role="concept">
3950 <primary>RFC 1413</primary>
3951 </indexterm>
3952 You can test features of the configuration that rely on ident (RFC 1413)
3953 information by using the <option>-oMt</option> option. However, Exim cannot actually perform
3954 an ident callout when testing using <option>-bh</option> because there is no incoming SMTP
3955 connection.
3956 </para>
3957 <para>
3958 <emphasis role="bold">Warning 2</emphasis>: Address verification callouts (see section <xref linkend="SECTcallver"/>)
3959 are also skipped when testing using <option>-bh</option>. If you want these callouts to
3960 occur, use <option>-bhc</option> instead.
3961 </para>
3962 <para>
3963 Messages supplied during the testing session are discarded, and nothing is
3964 written to any of the real log files. There may be pauses when DNS (and other)
3965 lookups are taking place, and of course these may time out. The <option>-oMi</option> option
3966 can be used to specify a specific IP interface and port if this is important,
3967 and <option>-oMaa</option> and <option>-oMai</option> can be used to set parameters as if the SMTP
3968 session were authenticated.
3969 </para>
3970 <para>
3971 The <emphasis>exim_checkaccess</emphasis> utility is a <quote>packaged</quote> version of <option>-bh</option> whose
3972 output just states whether a given recipient address from a given host is
3973 acceptable or not. See section <xref linkend="SECTcheckaccess"/>.
3974 </para>
3975 <para>
3976 Features such as authentication and encryption, where the client input is not
3977 plain text, cannot easily be tested with <option>-bh</option>. Instead, you should use a
3978 specialized SMTP test program such as
3979 <emphasis role="bold"><ulink url="http://jetmore.org/john/code/#swaks">swaks</ulink></emphasis>.
3980 </para>
3981 </listitem></varlistentry>
3982 <varlistentry>
3983 <term><option>-bhc</option>&nbsp;&lt;<emphasis>IP&nbsp;address</emphasis>&gt;</term>
3984 <listitem>
3985 <para>
3986 <indexterm role="option">
3987 <primary><option>-bhc</option></primary>
3988 </indexterm>
3989 This option operates in the same way as <option>-bh</option>, except that address
3990 verification callouts are performed if required. This includes consulting and
3991 updating the callout cache database.
3992 </para>
3993 </listitem></varlistentry>
3994 <varlistentry>
3995 <term><option>-bi</option></term>
3996 <listitem>
3997 <para>
3998 <indexterm role="option">
3999 <primary><option>-bi</option></primary>
4000 </indexterm>
4001 <indexterm role="concept">
4002 <primary>alias file</primary>
4003 <secondary>building</secondary>
4004 </indexterm>
4005 <indexterm role="concept">
4006 <primary>building alias file</primary>
4007 </indexterm>
4008 <indexterm role="concept">
4009 <primary>Sendmail compatibility</primary>
4010 <secondary><option>-bi</option> option</secondary>
4011 </indexterm>
4012 Sendmail interprets the <option>-bi</option> option as a request to rebuild its alias file.
4013 Exim does not have the concept of a single alias file, and so it cannot mimic
4014 this behaviour. However, calls to <filename>/usr/lib/sendmail</filename> with the <option>-bi</option> option
4015 tend to appear in various scripts such as NIS make files, so the option must be
4016 recognized.
4017 </para>
4018 <para>
4019 If <option>-bi</option> is encountered, the command specified by the <option>bi_command</option>
4020 configuration option is run, under the uid and gid of the caller of Exim. If
4021 the <option>-oA</option> option is used, its value is passed to the command as an argument.
4022 The command set by <option>bi_command</option> may not contain arguments. The command can
4023 use the <emphasis>exim_dbmbuild</emphasis> utility, or some other means, to rebuild alias files
4024 if this is required. If the <option>bi_command</option> option is not set, calling Exim with
4025 <option>-bi</option> is a no-op.
4026 </para>
4027 </listitem></varlistentry>
4028 <varlistentry>
4029 <term><option>-bm</option></term>
4030 <listitem>
4031 <para>
4032 <indexterm role="option">
4033 <primary><option>-bm</option></primary>
4034 </indexterm>
4035 <indexterm role="concept">
4036 <primary>local message reception</primary>
4037 </indexterm>
4038 This option runs an Exim receiving process that accepts an incoming,
4039 locally-generated message on the current input. The recipients are given as the
4040 command arguments (except when <option>-t</option> is also present &ndash; see below). Each
4041 argument can be a comma-separated list of RFC 2822 addresses. This is the
4042 default option for selecting the overall action of an Exim call; it is assumed
4043 if no other conflicting option is present.
4044 </para>
4045 <para>
4046 If any addresses in the message are unqualified (have no domain), they are
4047 qualified by the values of the <option>qualify_domain</option> or <option>qualify_recipient</option>
4048 options, as appropriate. The <option>-bnq</option> option (see below) provides a way of
4049 suppressing this for special cases.
4050 </para>
4051 <para>
4052 Policy checks on the contents of local messages can be enforced by means of
4053 the non-SMTP ACL. See chapter <xref linkend="CHAPACL"/> for details.
4054 </para>
4055 <para>
4056 <indexterm role="concept">
4057 <primary>return code</primary>
4058 <secondary>for <option>-bm</option></secondary>
4059 </indexterm>
4060 The return code is zero if the message is successfully accepted. Otherwise, the
4061 action is controlled by the <option>-oe</option><emphasis>x</emphasis> option setting &ndash; see below.
4062 </para>
4063 <para>
4064 The format
4065 <indexterm role="concept">
4066 <primary>message</primary>
4067 <secondary>format</secondary>
4068 </indexterm>
4069 <indexterm role="concept">
4070 <primary>format</primary>
4071 <secondary>message</secondary>
4072 </indexterm>
4073 <indexterm role="concept">
4074 <primary><quote>From</quote> line</primary>
4075 </indexterm>
4076 <indexterm role="concept">
4077 <primary>UUCP</primary>
4078 <secondary><quote>From</quote> line</secondary>
4079 </indexterm>
4080 <indexterm role="concept">
4081 <primary>Sendmail compatibility</primary>
4082 <secondary><quote>From</quote> line</secondary>
4083 </indexterm>
4084 of the message must be as defined in RFC 2822, except that, for
4085 compatibility with Sendmail and Smail, a line in one of the forms
4086 </para>
4087 <literallayout class="monospaced">
4088 From sender Fri Jan  5 12:55 GMT 1997
4089 From sender Fri, 5 Jan 97 12:55:01
4090 </literallayout>
4091 <para>
4092 (with the weekday optional, and possibly with additional text after the date)
4093 is permitted to appear at the start of the message. There appears to be no
4094 authoritative specification of the format of this line. Exim recognizes it by
4095 matching against the regular expression defined by the <option>uucp_from_pattern</option>
4096 option, which can be changed if necessary.
4097 </para>
4098 <para>
4099 <indexterm role="option">
4100 <primary><option>-f</option></primary>
4101 <secondary>overriding <quote>From</quote> line</secondary>
4102 </indexterm>
4103 The specified sender is treated as if it were given as the argument to the
4104 <option>-f</option> option, but if a <option>-f</option> option is also present, its argument is used in
4105 preference to the address taken from the message. The caller of Exim must be a
4106 trusted user for the sender of a message to be set in this way.
4107 </para>
4108 </listitem></varlistentry>
4109 <varlistentry>
4110 <term><option>-bnq</option></term>
4111 <listitem>
4112 <para>
4113 <indexterm role="option">
4114 <primary><option>-bnq</option></primary>
4115 </indexterm>
4116 <indexterm role="concept">
4117 <primary>address qualification, suppressing</primary>
4118 </indexterm>
4119 By default, Exim automatically qualifies unqualified addresses (those
4120 without domains) that appear in messages that are submitted locally (that
4121 is, not over TCP/IP). This qualification applies both to addresses in
4122 envelopes, and addresses in header lines. Sender addresses are qualified using
4123 <option>qualify_domain</option>, and recipient addresses using <option>qualify_recipient</option> (which
4124 defaults to the value of <option>qualify_domain</option>).
4125 </para>
4126 <para>
4127 Sometimes, qualification is not wanted. For example, if <option>-bS</option> (batch SMTP) is
4128 being used to re-submit messages that originally came from remote hosts after
4129 content scanning, you probably do not want to qualify unqualified addresses in
4130 header lines. (Such lines will be present only if you have not enabled a header
4131 syntax check in the appropriate ACL.)
4132 </para>
4133 <para>
4134 The <option>-bnq</option> option suppresses all qualification of unqualified addresses in
4135 messages that originate on the local host. When this is used, unqualified
4136 addresses in the envelope provoke errors (causing message rejection) and
4137 unqualified addresses in header lines are left alone.
4138 </para>
4139 </listitem></varlistentry>
4140 <varlistentry>
4141 <term><option>-bP</option></term>
4142 <listitem>
4143 <para>
4144 <indexterm role="option">
4145 <primary><option>-bP</option></primary>
4146 </indexterm>
4147 <indexterm role="concept">
4148 <primary>configuration options</primary>
4149 <secondary>extracting</secondary>
4150 </indexterm>
4151 <indexterm role="concept">
4152 <primary>options</primary>
4153 <secondary>configuration &ndash; extracting</secondary>
4154 </indexterm>
4155 If this option is given with no arguments, it causes the values of all Exim&#x2019;s
4156 main configuration options to be written to the standard output. The values
4157 of one or more specific options can be requested by giving their names as
4158 arguments, for example:
4159 </para>
4160 <literallayout class="monospaced">
4161 exim -bP qualify_domain hold_domains
4162 </literallayout>
4163 <para>
4164 <indexterm role="concept">
4165 <primary>hiding configuration option values</primary>
4166 </indexterm>
4167 <indexterm role="concept">
4168 <primary>configuration options</primary>
4169 <secondary>hiding value of</secondary>
4170 </indexterm>
4171 <indexterm role="concept">
4172 <primary>options</primary>
4173 <secondary>hiding value of</secondary>
4174 </indexterm>
4175 However, any option setting that is preceded by the word <quote>hide</quote> in the
4176 configuration file is not shown in full, except to an admin user. For other
4177 users, the output is as in this example:
4178 </para>
4179 <literallayout class="monospaced">
4180 mysql_servers = &lt;value not displayable&gt;
4181 </literallayout>
4182 <para>
4183 If <option>configure_file</option> is given as an argument, the name of the run time
4184 configuration file is output.
4185 If a list of configuration files was supplied, the value that is output here
4186 is the name of the file that was actually used.
4187 </para>
4188 <para>
4189 <indexterm role="concept">
4190 <primary>daemon</primary>
4191 <secondary>process id (pid)</secondary>
4192 </indexterm>
4193 <indexterm role="concept">
4194 <primary>pid (process id)</primary>
4195 <secondary>of daemon</secondary>
4196 </indexterm>
4197 If <option>log_file_path</option> or <option>pid_file_path</option> are given, the names of the
4198 directories where log files and daemon pid files are written are output,
4199 respectively. If these values are unset, log files are written in a
4200 sub-directory of the spool directory called <option>log</option>, and the pid file is
4201 written directly into the spool directory.
4202 </para>
4203 <para>
4204 If <option>-bP</option> is followed by a name preceded by <literal>+</literal>, for example,
4205 </para>
4206 <literallayout class="monospaced">
4207 exim -bP +local_domains
4208 </literallayout>
4209 <para>
4210 it searches for a matching named list of any type (domain, host, address, or
4211 local part) and outputs what it finds.
4212 </para>
4213 <para>
4214 <indexterm role="concept">
4215 <primary>options</primary>
4216 <secondary>router &ndash; extracting</secondary>
4217 </indexterm>
4218 <indexterm role="concept">
4219 <primary>options</primary>
4220 <secondary>transport &ndash; extracting</secondary>
4221 </indexterm>
4222 <indexterm role="concept">
4223 <primary>options</primary>
4224 <secondary>authenticator &ndash; extracting</secondary>
4225 </indexterm>
4226 If one of the words <option>router</option>, <option>transport</option>, or <option>authenticator</option> is given,
4227 followed by the name of an appropriate driver instance, the option settings for
4228 that driver are output. For example:
4229 </para>
4230 <literallayout class="monospaced">
4231 exim -bP transport local_delivery
4232 </literallayout>
4233 <para>
4234 The generic driver options are output first, followed by the driver&#x2019;s private
4235 options. A list of the names of drivers of a particular type can be obtained by
4236 using one of the words <option>router_list</option>, <option>transport_list</option>, or
4237 <option>authenticator_list</option>, and a complete list of all drivers with their option
4238 settings can be obtained by using <option>routers</option>, <option>transports</option>, or
4239 <option>authenticators</option>.
4240 </para>
4241 <para>
4242 <indexterm role="concept">
4243 <primary>options</primary>
4244 <secondary>macro &ndash; extracting</secondary>
4245 </indexterm>
4246 If invoked by an admin user, then <option>macro</option>, <option>macro_list</option> and <option>macros</option>
4247 are available, similarly to the drivers.  Because macros are sometimes used
4248 for storing passwords, this option is restricted.
4249 The output format is one item per line.
4250 </para>
4251 </listitem></varlistentry>
4252 <varlistentry>
4253 <term><option>-bp</option></term>
4254 <listitem>
4255 <para>
4256 <indexterm role="option">
4257 <primary><option>-bp</option></primary>
4258 </indexterm>
4259 <indexterm role="concept">
4260 <primary>queue</primary>
4261 <secondary>listing messages on</secondary>
4262 </indexterm>
4263 <indexterm role="concept">
4264 <primary>listing</primary>
4265 <secondary>messages on the queue</secondary>
4266 </indexterm>
4267 This option requests a listing of the contents of the mail queue on the
4268 standard output. If the <option>-bp</option> option is followed by a list of message ids,
4269 just those messages are listed. By default, this option can be used only by an
4270 admin user. However, the <option>queue_list_requires_admin</option> option can be set false
4271 to allow any user to see the queue.
4272 </para>
4273 <para>
4274 Each message on the queue is displayed as in the following example:
4275 </para>
4276 <literallayout class="monospaced">
4277 25m  2.9K 0t5C6f-0000c8-00 &lt;alice@wonderland.fict.example&gt;
4278           red.king@looking-glass.fict.example
4279           &lt;other addresses&gt;
4280 </literallayout>
4281 <para>
4282 <indexterm role="concept">
4283 <primary>message</primary>
4284 <secondary>size in queue listing</secondary>
4285 </indexterm>
4286 <indexterm role="concept">
4287 <primary>size</primary>
4288 <secondary>of message</secondary>
4289 </indexterm>
4290 The first line contains the length of time the message has been on the queue
4291 (in this case 25 minutes), the size of the message (2.9K), the unique local
4292 identifier for the message, and the message sender, as contained in the
4293 envelope. For bounce messages, the sender address is empty, and appears as
4294 <quote>&lt;&gt;</quote>. If the message was submitted locally by an untrusted user who overrode
4295 the default sender address, the user&#x2019;s login name is shown in parentheses
4296 before the sender address.
4297 </para>
4298 <para>
4299 <indexterm role="concept">
4300 <primary>frozen messages</primary>
4301 <secondary>in queue listing</secondary>
4302 </indexterm>
4303 If the message is frozen (attempts to deliver it are suspended) then the text
4304 <quote>*** frozen ***</quote> is displayed at the end of this line.
4305 </para>
4306 <para>
4307 The recipients of the message (taken from the envelope, not the headers) are
4308 displayed on subsequent lines. Those addresses to which the message has already
4309 been delivered are marked with the letter D. If an original address gets
4310 expanded into several addresses via an alias or forward file, the original is
4311 displayed with a D only when deliveries for all of its child addresses are
4312 complete.
4313 </para>
4314 </listitem></varlistentry>
4315 <varlistentry>
4316 <term><option>-bpa</option></term>
4317 <listitem>
4318 <para>
4319 <indexterm role="option">
4320 <primary><option>-bpa</option></primary>
4321 </indexterm>
4322 This option operates like <option>-bp</option>, but in addition it shows delivered addresses
4323 that were generated from the original top level address(es) in each message by
4324 alias or forwarding operations. These addresses are flagged with <quote>+D</quote> instead
4325 of just <quote>D</quote>.
4326 </para>
4327 </listitem></varlistentry>
4328 <varlistentry>
4329 <term><option>-bpc</option></term>
4330 <listitem>
4331 <para>
4332 <indexterm role="option">
4333 <primary><option>-bpc</option></primary>
4334 </indexterm>
4335 <indexterm role="concept">
4336 <primary>queue</primary>
4337 <secondary>count of messages on</secondary>
4338 </indexterm>
4339 This option counts the number of messages on the queue, and writes the total
4340 to the standard output. It is restricted to admin users, unless
4341 <option>queue_list_requires_admin</option> is set false.
4342 </para>
4343 </listitem></varlistentry>
4344 <varlistentry>
4345 <term><option>-bpr</option></term>
4346 <listitem>
4347 <para>
4348 <indexterm role="option">
4349 <primary><option>-bpr</option></primary>
4350 </indexterm>
4351 This option operates like <option>-bp</option>, but the output is not sorted into
4352 chronological order of message arrival. This can speed it up when there are
4353 lots of messages on the queue, and is particularly useful if the output is
4354 going to be post-processed in a way that doesn&#x2019;t need the sorting.
4355 </para>
4356 </listitem></varlistentry>
4357 <varlistentry>
4358 <term><option>-bpra</option></term>
4359 <listitem>
4360 <para>
4361 <indexterm role="option">
4362 <primary><option>-bpra</option></primary>
4363 </indexterm>
4364 This option is a combination of <option>-bpr</option> and <option>-bpa</option>.
4365 </para>
4366 </listitem></varlistentry>
4367 <varlistentry>
4368 <term><option>-bpru</option></term>
4369 <listitem>
4370 <para>
4371 <indexterm role="option">
4372 <primary><option>-bpru</option></primary>
4373 </indexterm>
4374 This option is a combination of <option>-bpr</option> and <option>-bpu</option>.
4375 </para>
4376 </listitem></varlistentry>
4377 <varlistentry>
4378 <term><option>-bpu</option></term>
4379 <listitem>
4380 <para>
4381 <indexterm role="option">
4382 <primary><option>-bpu</option></primary>
4383 </indexterm>
4384 This option operates like <option>-bp</option> but shows only undelivered top-level
4385 addresses for each message displayed. Addresses generated by aliasing or
4386 forwarding are not shown, unless the message was deferred after processing by a
4387 router with the <option>one_time</option> option set.
4388 </para>
4389 </listitem></varlistentry>
4390 <varlistentry>
4391 <term><option>-brt</option></term>
4392 <listitem>
4393 <para>
4394 <indexterm role="option">
4395 <primary><option>-brt</option></primary>
4396 </indexterm>
4397 <indexterm role="concept">
4398 <primary>testing</primary>
4399 <secondary>retry configuration</secondary>
4400 </indexterm>
4401 <indexterm role="concept">
4402 <primary>retry</primary>
4403 <secondary>configuration testing</secondary>
4404 </indexterm>
4405 This option is for testing retry rules, and it must be followed by up to three
4406 arguments. It causes Exim to look for a retry rule that matches the values
4407 and to write it to the standard output. For example:
4408 </para>
4409 <literallayout class="monospaced">
4410 exim -brt bach.comp.mus.example
4411 Retry rule: *.comp.mus.example  F,2h,15m; F,4d,30m;
4412 </literallayout>
4413 <para>
4414 See chapter <xref linkend="CHAPretry"/> for a description of Exim&#x2019;s retry rules. The first
4415 argument, which is required, can be a complete address in the form
4416 <emphasis>local_part@domain</emphasis>, or it can be just a domain name. If the second argument
4417 contains a dot, it is interpreted as an optional second domain name; if no
4418 retry rule is found for the first argument, the second is tried. This ties in
4419 with Exim&#x2019;s behaviour when looking for retry rules for remote hosts &ndash; if no
4420 rule is found that matches the host, one that matches the mail domain is
4421 sought. Finally, an argument that is the name of a specific delivery error, as
4422 used in setting up retry rules, can be given. For example:
4423 </para>
4424 <literallayout class="monospaced">
4425 exim -brt haydn.comp.mus.example quota_3d
4426 Retry rule: *@haydn.comp.mus.example quota_3d  F,1h,15m
4427 </literallayout>
4428 </listitem></varlistentry>
4429 <varlistentry>
4430 <term><option>-brw</option></term>
4431 <listitem>
4432 <para>
4433 <indexterm role="option">
4434 <primary><option>-brw</option></primary>
4435 </indexterm>
4436 <indexterm role="concept">
4437 <primary>testing</primary>
4438 <secondary>rewriting</secondary>
4439 </indexterm>
4440 <indexterm role="concept">
4441 <primary>rewriting</primary>
4442 <secondary>testing</secondary>
4443 </indexterm>
4444 This option is for testing address rewriting rules, and it must be followed by
4445 a single argument, consisting of either a local part without a domain, or a
4446 complete address with a fully qualified domain. Exim outputs how this address
4447 would be rewritten for each possible place it might appear. See chapter
4448 <xref linkend="CHAPrewrite"/> for further details.
4449 </para>
4450 </listitem></varlistentry>
4451 <varlistentry>
4452 <term><option>-bS</option></term>
4453 <listitem>
4454 <para>
4455 <indexterm role="option">
4456 <primary><option>-bS</option></primary>
4457 </indexterm>
4458 <indexterm role="concept">
4459 <primary>SMTP</primary>
4460 <secondary>batched incoming</secondary>
4461 </indexterm>
4462 <indexterm role="concept">
4463 <primary>batched SMTP input</primary>
4464 </indexterm>
4465 This option is used for batched SMTP input, which is an alternative interface
4466 for non-interactive local message submission. A number of messages can be
4467 submitted in a single run. However, despite its name, this is not really SMTP
4468 input. Exim reads each message&#x2019;s envelope from SMTP commands on the standard
4469 input, but generates no responses. If the caller is trusted, or
4470 <option>untrusted_set_sender</option> is set, the senders in the SMTP MAIL commands are
4471 believed; otherwise the sender is always the caller of Exim.
4472 </para>
4473 <para>
4474 The message itself is read from the standard input, in SMTP format (leading
4475 dots doubled), terminated by a line containing just a single dot. An error is
4476 provoked if the terminating dot is missing. A further message may then follow.
4477 </para>
4478 <para>
4479 As for other local message submissions, the contents of incoming batch SMTP
4480 messages can be checked using the non-SMTP ACL (see chapter <xref linkend="CHAPACL"/>).
4481 Unqualified addresses are automatically qualified using <option>qualify_domain</option> and
4482 <option>qualify_recipient</option>, as appropriate, unless the <option>-bnq</option> option is used.
4483 </para>
4484 <para>
4485 Some other SMTP commands are recognized in the input. HELO and EHLO act
4486 as RSET; VRFY, EXPN, ETRN, and HELP act as NOOP;
4487 QUIT quits, ignoring the rest of the standard input.
4488 </para>
4489 <para>
4490 <indexterm role="concept">
4491 <primary>return code</primary>
4492 <secondary>for <option>-bS</option></secondary>
4493 </indexterm>
4494 If any error is encountered, reports are written to the standard output and
4495 error streams, and Exim gives up immediately. The return code is 0 if no error
4496 was detected; it is 1 if one or more messages were accepted before the error
4497 was detected; otherwise it is 2.
4498 </para>
4499 <para>
4500 More details of input using batched SMTP are given in section
4501 <xref linkend="SECTincomingbatchedSMTP"/>.
4502 </para>
4503 </listitem></varlistentry>
4504 <varlistentry>
4505 <term><option>-bs</option></term>
4506 <listitem>
4507 <para>
4508 <indexterm role="option">
4509 <primary><option>-bs</option></primary>
4510 </indexterm>
4511 <indexterm role="concept">
4512 <primary>SMTP</primary>
4513 <secondary>local input</secondary>
4514 </indexterm>
4515 <indexterm role="concept">
4516 <primary>local SMTP input</primary>
4517 </indexterm>
4518 This option causes Exim to accept one or more messages by reading SMTP commands
4519 on the standard input, and producing SMTP replies on the standard output. SMTP
4520 policy controls, as defined in ACLs (see chapter <xref linkend="CHAPACL"/>) are applied.
4521 Some user agents use this interface as a way of passing locally-generated
4522 messages to the MTA.
4523 </para>
4524 <para>
4525 In
4526 <indexterm role="concept">
4527 <primary>sender</primary>
4528 <secondary>source of</secondary>
4529 </indexterm>
4530 this usage, if the caller of Exim is trusted, or <option>untrusted_set_sender</option> is
4531 set, the senders of messages are taken from the SMTP MAIL commands.
4532 Otherwise the content of these commands is ignored and the sender is set up as
4533 the calling user. Unqualified addresses are automatically qualified using
4534 <option>qualify_domain</option> and <option>qualify_recipient</option>, as appropriate, unless the
4535 <option>-bnq</option> option is used.
4536 </para>
4537 <para>
4538 <indexterm role="concept">
4539 <primary>inetd</primary>
4540 </indexterm>
4541 The
4542 <option>-bs</option> option is also used to run Exim from <emphasis>inetd</emphasis>, as an alternative to
4543 using a listening daemon. Exim can distinguish the two cases by checking
4544 whether the standard input is a TCP/IP socket. When Exim is called from
4545 <emphasis>inetd</emphasis>, the source of the mail is assumed to be remote, and the comments
4546 above concerning senders and qualification do not apply. In this situation,
4547 Exim behaves in exactly the same way as it does when receiving a message via
4548 the listening daemon.
4549 </para>
4550 </listitem></varlistentry>
4551 <varlistentry revisionflag="changed">
4552 <term><option>-bmalware</option>&nbsp;&lt;<emphasis>filename</emphasis>&gt;</term>
4553 <listitem>
4554 <para revisionflag="changed">
4555 <indexterm role="option">
4556 <primary><option>-bmalware</option></primary>
4557 </indexterm>
4558 <indexterm role="concept">
4559 <primary>testing</primary>
4560 <secondary>,</secondary>
4561 </indexterm>
4562 <indexterm role="concept">
4563 <primary>malware scan test</primary>
4564 </indexterm>
4565 This debugging option causes Exim to scan the given file,
4566 using the malware scanning framework.  The option of <option>av_scanner</option> influences
4567 this option, so if <option>av_scanner</option>&#x2019;s value is dependent upon an expansion then
4568 the expansion should have defaults which apply to this invocation.  ACLs are
4569 not invoked, so if <option>av_scanner</option> references an ACL variable then that variable
4570 will never be populated and <option>-bmalware</option> will fail.
4571 </para>
4572 <para revisionflag="changed">
4573 Exim will have changed working directory before resolving the filename, so
4574 using fully qualified pathnames is advisable.  Exim will be running as the Exim
4575 user when it tries to open the file, rather than as the invoking user.
4576 This option requires admin privileges.
4577 </para>
4578 <para revisionflag="changed">
4579 The <option>-bmalware</option> option will not be extended to be more generally useful,
4580 there are better tools for file-scanning.  This option exists to help
4581 administrators verify their Exim and AV scanner configuration.
4582 </para>
4583 </listitem></varlistentry>
4584 <varlistentry>
4585 <term><option>-bt</option></term>
4586 <listitem>
4587 <para>
4588 <indexterm role="option">
4589 <primary><option>-bt</option></primary>
4590 </indexterm>
4591 <indexterm role="concept">
4592 <primary>testing</primary>
4593 <secondary>addresses</secondary>
4594 </indexterm>
4595 <indexterm role="concept">
4596 <primary>address</primary>
4597 <secondary>testing</secondary>
4598 </indexterm>
4599 This option runs Exim in address testing mode, in which each argument is taken
4600 as a recipient address to be tested for deliverability. The results are
4601 written to the standard output. If a test fails, and the caller is not an admin
4602 user, no details of the failure are output, because these might contain
4603 sensitive information such as usernames and passwords for database lookups.
4604 </para>
4605 <para>
4606 If no arguments are given, Exim runs in an interactive manner, prompting with a
4607 right angle bracket for addresses to be tested.
4608 </para>
4609 <para>
4610 Unlike the <option>-be</option> test option, you cannot arrange for Exim to use the
4611 <function>readline()</function> function, because it is running as <emphasis>root</emphasis> and there are
4612 security issues.
4613 </para>
4614 <para>
4615 Each address is handled as if it were the recipient address of a message
4616 (compare the <option>-bv</option> option). It is passed to the routers and the result is
4617 written to the standard output. However, any router that has
4618 <option>no_address_test</option> set is bypassed. This can make <option>-bt</option> easier to use for
4619 genuine routing tests if your first router passes everything to a scanner
4620 program.
4621 </para>
4622 <para>
4623 <indexterm role="concept">
4624 <primary>return code</primary>
4625 <secondary>for <option>-bt</option></secondary>
4626 </indexterm>
4627 The return code is 2 if any address failed outright; it is 1 if no address
4628 failed outright but at least one could not be resolved for some reason. Return
4629 code 0 is given only when all addresses succeed.
4630 </para>
4631 <para>
4632 <indexterm role="concept">
4633 <primary>duplicate addresses</primary>
4634 </indexterm>
4635 <emphasis role="bold">Note</emphasis>: When actually delivering a message, Exim removes duplicate recipient
4636 addresses after routing is complete, so that only one delivery takes place.
4637 This does not happen when testing with <option>-bt</option>; the full results of routing are
4638 always shown.
4639 </para>
4640 <para>
4641 <emphasis role="bold">Warning</emphasis>: <option>-bt</option> can only do relatively simple testing. If any of the
4642 routers in the configuration makes any tests on the sender address of a
4643 message,
4644 <indexterm role="option">
4645 <primary><option>-f</option></primary>
4646 <secondary>for address testing</secondary>
4647 </indexterm>
4648 you can use the <option>-f</option> option to set an appropriate sender when running
4649 <option>-bt</option> tests. Without it, the sender is assumed to be the calling user at the
4650 default qualifying domain. However, if you have set up (for example) routers
4651 whose behaviour depends on the contents of an incoming message, you cannot test
4652 those conditions using <option>-bt</option>. The <option>-N</option> option provides a possible way of
4653 doing such tests.
4654 </para>
4655 </listitem></varlistentry>
4656 <varlistentry>
4657 <term><option>-bV</option></term>
4658 <listitem>
4659 <para>
4660 <indexterm role="option">
4661 <primary><option>-bV</option></primary>
4662 </indexterm>
4663 <indexterm role="concept">
4664 <primary>version number of Exim</primary>
4665 </indexterm>
4666 This option causes Exim to write the current version number, compilation
4667 number, and compilation date of the <emphasis>exim</emphasis> binary to the standard output.
4668 It also lists the DBM library that is being used, the optional modules (such as
4669 specific lookup types), the drivers that are included in the binary, and the
4670 name of the run time configuration file that is in use.
4671 </para>
4672 <para>
4673 As part of its operation, <option>-bV</option> causes Exim to read and syntax check its
4674 configuration file. However, this is a static check only. It cannot check
4675 values that are to be expanded. For example, although a misspelt ACL verb is
4676 detected, an error in the verb&#x2019;s arguments is not. You cannot rely on <option>-bV</option>
4677 alone to discover (for example) all the typos in the configuration; some
4678 realistic testing is needed. The <option>-bh</option> and <option>-N</option> options provide more
4679 dynamic testing facilities.
4680 </para>
4681 </listitem></varlistentry>
4682 <varlistentry>
4683 <term><option>-bv</option></term>
4684 <listitem>
4685 <para>
4686 <indexterm role="option">
4687 <primary><option>-bv</option></primary>
4688 </indexterm>
4689 <indexterm role="concept">
4690 <primary>verifying address</primary>
4691 <secondary>using <option>-bv</option></secondary>
4692 </indexterm>
4693 <indexterm role="concept">
4694 <primary>address</primary>
4695 <secondary>verification</secondary>
4696 </indexterm>
4697 This option runs Exim in address verification mode, in which each argument is
4698 taken as a recipient address to be verified by the routers. (This does
4699 not involve any verification callouts). During normal operation, verification
4700 happens mostly as a consequence processing a <option>verify</option> condition in an ACL
4701 (see chapter <xref linkend="CHAPACL"/>). If you want to test an entire ACL, possibly
4702 including callouts, see the <option>-bh</option> and <option>-bhc</option> options.
4703 </para>
4704 <para>
4705 If verification fails, and the caller is not an admin user, no details of the
4706 failure are output, because these might contain sensitive information such as
4707 usernames and passwords for database lookups.
4708 </para>
4709 <para>
4710 If no arguments are given, Exim runs in an interactive manner, prompting with a
4711 right angle bracket for addresses to be verified.
4712 </para>
4713 <para>
4714 Unlike the <option>-be</option> test option, you cannot arrange for Exim to use the
4715 <function>readline()</function> function, because it is running as <emphasis>exim</emphasis> and there are
4716 security issues.
4717 </para>
4718 <para>
4719 Verification differs from address testing (the <option>-bt</option> option) in that routers
4720 that have <option>no_verify</option> set are skipped, and if the address is accepted by a
4721 router that has <option>fail_verify</option> set, verification fails. The address is
4722 verified as a recipient if <option>-bv</option> is used; to test verification for a sender
4723 address, <option>-bvs</option> should be used.
4724 </para>
4725 <para>
4726 If the <option>-v</option> option is not set, the output consists of a single line for each
4727 address, stating whether it was verified or not, and giving a reason in the
4728 latter case. Without <option>-v</option>, generating more than one address by redirection
4729 causes verification to end successfully, without considering the generated
4730 addresses. However, if just one address is generated, processing continues,
4731 and the generated address must verify successfully for the overall verification
4732 to succeed.
4733 </para>
4734 <para>
4735 When <option>-v</option> is set, more details are given of how the address has been handled,
4736 and in the case of address redirection, all the generated addresses are also
4737 considered. Verification may succeed for some and fail for others.
4738 </para>
4739 <para>
4740 The
4741 <indexterm role="concept">
4742 <primary>return code</primary>
4743 <secondary>for <option>-bv</option></secondary>
4744 </indexterm>
4745 return code is 2 if any address failed outright; it is 1 if no address
4746 failed outright but at least one could not be resolved for some reason. Return
4747 code 0 is given only when all addresses succeed.
4748 </para>
4749 <para>
4750 If any of the routers in the configuration makes any tests on the sender
4751 address of a message, you should use the <option>-f</option> option to set an appropriate
4752 sender when running <option>-bv</option> tests. Without it, the sender is assumed to be the
4753 calling user at the default qualifying domain.
4754 </para>
4755 </listitem></varlistentry>
4756 <varlistentry>
4757 <term><option>-bvs</option></term>
4758 <listitem>
4759 <para>
4760 <indexterm role="option">
4761 <primary><option>-bvs</option></primary>
4762 </indexterm>
4763 This option acts like <option>-bv</option>, but verifies the address as a sender rather
4764 than a recipient address. This affects any rewriting and qualification that
4765 might happen.
4766 </para>
4767 </listitem></varlistentry>
4768 <varlistentry revisionflag="changed">
4769 <term><option>-C</option>&nbsp;&lt;<emphasis>filelist</emphasis>&gt;</term>
4770 <listitem>
4771 <para revisionflag="changed">
4772 <indexterm role="option">
4773 <primary><option>-C</option></primary>
4774 </indexterm>
4775 <indexterm role="concept">
4776 <primary>configuration file</primary>
4777 <secondary>alternate</secondary>
4778 </indexterm>
4779 <indexterm role="concept">
4780 <primary>CONFIGURE_FILE</primary>
4781 </indexterm>
4782 <indexterm role="concept">
4783 <primary>alternate configuration file</primary>
4784 </indexterm>
4785 This option causes Exim to find the run time configuration file from the given
4786 list instead of from the list specified by the CONFIGURE_FILE
4787 compile-time setting. Usually, the list will consist of just a single file
4788 name, but it can be a colon-separated list of names. In this case, the first
4789 file that exists is used. Failure to open an existing file stops Exim from
4790 proceeding any further along the list, and an error is generated.
4791 </para>
4792 <para revisionflag="changed">
4793 When this option is used by a caller other than root, and the list is different
4794 from the compiled-in list, Exim gives up its root privilege immediately, and
4795 runs with the real and effective uid and gid set to those of the caller.
4796 However, if a TRUSTED_CONFIG_LIST file is defined in <filename>Local/Makefile</filename>, that
4797 file contains a list of full pathnames, one per line, for configuration files
4798 which are trusted. Root privilege is retained for any configuration file so
4799 listed, as long as the caller is the Exim user (or the user specified in the
4800 CONFIGURE_OWNER option, if any), and as long as the configuration file is
4801 not writeable by inappropriate users or groups.
4802 </para>
4803 <para revisionflag="changed">
4804 Leaving TRUSTED_CONFIG_LIST unset precludes the possibility of testing a
4805 configuration using <option>-C</option> right through message reception and delivery,
4806 even if the caller is root. The reception works, but by that time, Exim is
4807 running as the Exim user, so when it re-executes to regain privilege for the
4808 delivery, the use of <option>-C</option> causes privilege to be lost. However, root can
4809 test reception and delivery using two separate commands (one to put a message
4810 on the queue, using <option>-odq</option>, and another to do the delivery, using <option>-M</option>).
4811 </para>
4812 <para revisionflag="changed">
4813 If ALT_CONFIG_PREFIX is defined <filename>in Local/Makefile</filename>, it specifies a
4814 prefix string with which any file named in a <option>-C</option> command line option
4815 must start. In addition, the file name must not contain the sequence <literal>/../</literal>.
4816 However, if the value of the <option>-C</option> option is identical to the value of
4817 CONFIGURE_FILE in <filename>Local/Makefile</filename>, Exim ignores <option>-C</option> and proceeds as
4818 usual. There is no default setting for ALT_CONFIG_PREFIX; when it is
4819 unset, any file name can be used with <option>-C</option>.
4820 </para>
4821 <para revisionflag="changed">
4822 ALT_CONFIG_PREFIX can be used to confine alternative configuration files
4823 to a directory to which only root has access. This prevents someone who has
4824 broken into the Exim account from running a privileged Exim with an arbitrary
4825 configuration file.
4826 </para>
4827 <para revisionflag="changed">
4828 The <option>-C</option> facility is useful for ensuring that configuration files are
4829 syntactically correct, but cannot be used for test deliveries, unless the
4830 caller is privileged, or unless it is an exotic configuration that does not
4831 require privilege. No check is made on the owner or group of the files
4832 specified by this option.
4833 </para>
4834 </listitem></varlistentry>
4835 <varlistentry revisionflag="changed">
4836 <term><option>-D</option>&lt;<emphasis>macro</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt;</term>
4837 <listitem>
4838 <para revisionflag="changed">
4839 <indexterm role="option">
4840 <primary><option>-D</option></primary>
4841 </indexterm>
4842 <indexterm role="concept">
4843 <primary>macro</primary>
4844 <secondary>setting on command line</secondary>
4845 </indexterm>
4846 This option can be used to override macro definitions in the configuration file
4847 (see section <xref linkend="SECTmacrodefs"/>). However, like <option>-C</option>, if it is used by an
4848 unprivileged caller, it causes Exim to give up its root privilege.
4849 If DISABLE_D_OPTION is defined in <filename>Local/Makefile</filename>, the use of <option>-D</option> is
4850 completely disabled, and its use causes an immediate error exit.
4851 </para>
4852 <para revisionflag="changed">
4853 If WHITELIST_D_MACROS is defined in <filename>Local/Makefile</filename> then it should be a
4854 colon-separated list of macros which are considered safe and, if <option>-D</option> only
4855 supplies macros from this list, and the values are acceptable, then Exim will
4856 not give up root privilege if the caller is root, the Exim run-time user, or
4857 the CONFIGURE_OWNER, if set.  This is a transition mechanism and is expected
4858 to be removed in the future.  Acceptable values for the macros satisfy the
4859 regexp: <literal>^[A-Za-z0-9_/.-]*$</literal>
4860 </para>
4861 <para revisionflag="changed">
4862 The entire option (including equals sign if present) must all be within one
4863 command line item. <option>-D</option> can be used to set the value of a macro to the empty
4864 string, in which case the equals sign is optional. These two commands are
4865 synonymous:
4866 </para>
4867 <literallayout class="monospaced" revisionflag="changed">
4868 exim -DABC  ...
4869 exim -DABC= ...
4870 </literallayout>
4871 <para revisionflag="changed">
4872 To include spaces in a macro definition item, quotes must be used. If you use
4873 quotes, spaces are permitted around the macro name and the equals sign. For
4874 example:
4875 </para>
4876 <literallayout class="monospaced" revisionflag="changed">
4877 exim '-D ABC = something' ...
4878 </literallayout>
4879 <para revisionflag="changed">
4880 <option>-D</option> may be repeated up to 10 times on a command line.
4881 </para>
4882 </listitem></varlistentry>
4883 <varlistentry>
4884 <term><option>-d</option>&lt;<emphasis>debug&nbsp;options</emphasis>&gt;</term>
4885 <listitem>
4886 <para>
4887 <indexterm role="option">
4888 <primary><option>-d</option></primary>
4889 </indexterm>
4890 <indexterm role="concept">
4891 <primary>debugging</primary>
4892 <secondary>list of selectors</secondary>
4893 </indexterm>
4894 <indexterm role="concept">
4895 <primary>debugging</primary>
4896 <secondary><option>-d</option> option</secondary>
4897 </indexterm>
4898 This option causes debugging information to be written to the standard
4899 error stream. It is restricted to admin users because debugging output may show
4900 database queries that contain password information. Also, the details of users&#x2019;
4901 filter files should be protected. If a non-admin user uses <option>-d</option>, Exim
4902 writes an error message to the standard error stream and exits with a non-zero
4903 return code.
4904 </para>
4905 <para>
4906 When <option>-d</option> is used, <option>-v</option> is assumed. If <option>-d</option> is given on its own, a lot of
4907 standard debugging data is output. This can be reduced, or increased to include
4908 some more rarely needed information, by directly following <option>-d</option> with a string
4909 made up of names preceded by plus or minus characters. These add or remove sets
4910 of debugging data, respectively. For example, <option>-d+filter</option> adds filter
4911 debugging, whereas <option>-d-all+filter</option> selects only filter debugging. Note that
4912 no spaces are allowed in the debug setting. The available debugging categories
4913 are:
4914 </para>
4915 <literallayout>
4916 <literal>acl            </literal> ACL interpretation
4917 <literal>auth           </literal> authenticators
4918 <literal>deliver        </literal> general delivery logic
4919 <literal>dns            </literal> DNS lookups (see also resolver)
4920 <literal>dnsbl          </literal> DNS black list (aka RBL) code
4921 <literal>exec           </literal> arguments for <function>execv()</function> calls
4922 <literal>expand         </literal> detailed debugging for string expansions
4923 <literal>filter         </literal> filter handling
4924 <literal>hints_lookup   </literal> hints data lookups
4925 <literal>host_lookup    </literal> all types of name-to-IP address handling
4926 <literal>ident          </literal> ident lookup
4927 <literal>interface      </literal> lists of local interfaces
4928 <literal>lists          </literal> matching things in lists
4929 <literal>load           </literal> system load checks
4930 <literal>local_scan     </literal> can be used by <function>local_scan()</function> (see chapter <xref linkend="CHAPlocalscan"/>)
4931 <literal>lookup         </literal> general lookup code and all lookups
4932 <literal>memory         </literal> memory handling
4933 <literal>pid            </literal> add pid to debug output lines
4934 <literal>process_info   </literal> setting info for the process log
4935 <literal>queue_run      </literal> queue runs
4936 <literal>receive        </literal> general message reception logic
4937 <literal>resolver       </literal> turn on the DNS resolver&#x2019;s debugging output
4938 <literal>retry          </literal> retry handling
4939 <literal>rewrite        </literal> address rewriting
4940 <literal>route          </literal> address routing
4941 <literal>timestamp      </literal> add timestamp to debug output lines
4942 <literal>tls            </literal> TLS logic
4943 <literal>transport      </literal> transports
4944 <literal>uid            </literal> changes of uid/gid and looking up uid/gid
4945 <literal>verify         </literal> address verification logic
4946 <literal>all            </literal> almost all of the above (see below), and also <option>-v</option>
4947 </literallayout>
4948 <para>
4949 The <literal>all</literal> option excludes <literal>memory</literal> when used as <literal>+all</literal>, but includes it
4950 for <literal>-all</literal>. The reason for this is that <literal>+all</literal> is something that people
4951 tend to use when generating debug output for Exim maintainers. If <literal>+memory</literal>
4952 is included, an awful lot of output that is very rarely of interest is
4953 generated, so it now has to be explicitly requested. However, <literal>-all</literal> does
4954 turn everything off.
4955 </para>
4956 <para>
4957 <indexterm role="concept">
4958 <primary>resolver, debugging output</primary>
4959 </indexterm>
4960 <indexterm role="concept">
4961 <primary>DNS resolver, debugging output</primary>
4962 </indexterm>
4963 The <literal>resolver</literal> option produces output only if the DNS resolver was compiled
4964 with DEBUG enabled. This is not the case in some operating systems. Also,
4965 unfortunately, debugging output from the DNS resolver is written to stdout
4966 rather than stderr.
4967 </para>
4968 <para>
4969 The default (<option>-d</option> with no argument) omits <literal>expand</literal>, <literal>filter</literal>,
4970 <literal>interface</literal>, <literal>load</literal>, <literal>memory</literal>, <literal>pid</literal>, <literal>resolver</literal>, and <literal>timestamp</literal>.
4971 However, the <literal>pid</literal> selector is forced when debugging is turned on for a
4972 daemon, which then passes it on to any re-executed Exims. Exim also
4973 automatically adds the pid to debug lines when several remote deliveries are
4974 run in parallel.
4975 </para>
4976 <para>
4977 The <literal>timestamp</literal> selector causes the current time to be inserted at the start
4978 of all debug output lines. This can be useful when trying to track down delays
4979 in processing.
4980 </para>
4981 <para>
4982 If the <option>debug_print</option> option is set in any driver, it produces output whenever
4983 any debugging is selected, or if <option>-v</option> is used.
4984 </para>
4985 </listitem></varlistentry>
4986 <varlistentry>
4987 <term><option>-dd</option>&lt;<emphasis>debug&nbsp;options</emphasis>&gt;</term>
4988 <listitem>
4989 <para>
4990 <indexterm role="option">
4991 <primary><option>-dd</option></primary>
4992 </indexterm>
4993 This option behaves exactly like <option>-d</option> except when used on a command that
4994 starts a daemon process. In that case, debugging is turned off for the
4995 subprocesses that the daemon creates. Thus, it is useful for monitoring the
4996 behaviour of the daemon without creating as much output as full debugging does.
4997 </para>
4998 </listitem></varlistentry>
4999 <varlistentry>
5000 <term><option>-dropcr</option></term>
5001 <listitem>
5002 <para>
5003 <indexterm role="option">
5004 <primary><option>-dropcr</option></primary>
5005 </indexterm>
5006 This is an obsolete option that is now a no-op. It used to affect the way Exim
5007 handled CR and LF characters in incoming messages. What happens now is
5008 described in section <xref linkend="SECTlineendings"/>.
5009 </para>
5010 </listitem></varlistentry>
5011 <varlistentry>
5012 <term><option>-E</option></term>
5013 <listitem>
5014 <para>
5015 <indexterm role="option">
5016 <primary><option>-E</option></primary>
5017 </indexterm>
5018 <indexterm role="concept">
5019 <primary>bounce message</primary>
5020 <secondary>generating</secondary>
5021 </indexterm>
5022 This option specifies that an incoming message is a locally-generated delivery
5023 failure report. It is used internally by Exim when handling delivery failures
5024 and is not intended for external use. Its only effect is to stop Exim
5025 generating certain messages to the postmaster, as otherwise message cascades
5026 could occur in some situations. As part of the same option, a message id may
5027 follow the characters <option>-E</option>. If it does, the log entry for the receipt of the
5028 new message contains the id, following <quote>R=</quote>, as a cross-reference.
5029 </para>
5030 </listitem></varlistentry>
5031 <varlistentry>
5032 <term><option>-e</option><emphasis>x</emphasis></term>
5033 <listitem>
5034 <para>
5035 <indexterm role="option">
5036 <primary><option>-e</option><emphasis>x</emphasis></primary>
5037 </indexterm>
5038 There are a number of Sendmail options starting with <option>-oe</option> which seem to be
5039 called by various programs without the leading <option>o</option> in the option. For
5040 example, the <option>vacation</option> program uses <option>-eq</option>. Exim treats all options of the
5041 form <option>-e</option><emphasis>x</emphasis> as synonymous with the corresponding <option>-oe</option><emphasis>x</emphasis> options.
5042 </para>
5043 </listitem></varlistentry>
5044 <varlistentry>
5045 <term><option>-F</option>&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
5046 <listitem>
5047 <para>
5048 <indexterm role="option">
5049 <primary><option>-F</option></primary>
5050 </indexterm>
5051 <indexterm role="concept">
5052 <primary>sender</primary>
5053 <secondary>name</secondary>
5054 </indexterm>
5055 <indexterm role="concept">
5056 <primary>name</primary>
5057 <secondary>of sender</secondary>
5058 </indexterm>
5059 This option sets the sender&#x2019;s full name for use when a locally-generated
5060 message is being accepted. In the absence of this option, the user&#x2019;s <emphasis>gecos</emphasis>
5061 entry from the password data is used. As users are generally permitted to alter
5062 their <emphasis>gecos</emphasis> entries, no security considerations are involved. White space
5063 between <option>-F</option> and the &lt;<emphasis>string</emphasis>&gt; is optional.
5064 </para>
5065 </listitem></varlistentry>
5066 <varlistentry>
5067 <term><option>-f</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;</term>
5068 <listitem>
5069 <para>
5070 <indexterm role="option">
5071 <primary><option>-f</option></primary>
5072 </indexterm>
5073 <indexterm role="concept">
5074 <primary>sender</primary>
5075 <secondary>address</secondary>
5076 </indexterm>
5077 <indexterm role="concept">
5078 <primary>address</primary>
5079 <secondary>sender</secondary>
5080 </indexterm>
5081 <indexterm role="concept">
5082 <primary>trusted users</primary>
5083 </indexterm>
5084 <indexterm role="concept">
5085 <primary>envelope sender</primary>
5086 </indexterm>
5087 <indexterm role="concept">
5088 <primary>user</primary>
5089 <secondary>trusted</secondary>
5090 </indexterm>
5091 This option sets the address of the envelope sender of a locally-generated
5092 message (also known as the return path). The option can normally be used only
5093 by a trusted user, but <option>untrusted_set_sender</option> can be set to allow untrusted
5094 users to use it.
5095 </para>
5096 <para>
5097 Processes running as root or the Exim user are always trusted. Other
5098 trusted users are defined by the <option>trusted_users</option> or <option>trusted_groups</option>
5099 options. In the absence of <option>-f</option>, or if the caller is not trusted, the sender
5100 of a local message is set to the caller&#x2019;s login name at the default qualify
5101 domain.
5102 </para>
5103 <para>
5104 There is one exception to the restriction on the use of <option>-f</option>: an empty sender
5105 can be specified by any user, trusted or not, to create a message that can
5106 never provoke a bounce. An empty sender can be specified either as an empty
5107 string, or as a pair of angle brackets with nothing between them, as in these
5108 examples of shell commands:
5109 </para>
5110 <literallayout class="monospaced">
5111 exim -f '&lt;&gt;' user@domain
5112 exim -f "" user@domain
5113 </literallayout>
5114 <para>
5115 In addition, the use of <option>-f</option> is not restricted when testing a filter file
5116 with <option>-bf</option> or when testing or verifying addresses using the <option>-bt</option> or
5117 <option>-bv</option> options.
5118 </para>
5119 <para>
5120 Allowing untrusted users to change the sender address does not of itself make
5121 it possible to send anonymous mail. Exim still checks that the <emphasis>From:</emphasis> header
5122 refers to the local user, and if it does not, it adds a <emphasis>Sender:</emphasis> header,
5123 though this can be overridden by setting <option>no_local_from_check</option>.
5124 </para>
5125 <para>
5126 White
5127 <indexterm role="concept">
5128 <primary><quote>From</quote> line</primary>
5129 </indexterm>
5130 space between <option>-f</option> and the &lt;<emphasis>address</emphasis>&gt; is optional (that is, they can be
5131 given as two arguments or one combined argument). The sender of a
5132 locally-generated message can also be set (when permitted) by an initial
5133 <quote>From&nbsp;</quote> line in the message &ndash; see the description of <option>-bm</option> above &ndash; but
5134 if <option>-f</option> is also present, it overrides <quote>From&nbsp;</quote>.
5135 </para>
5136 </listitem></varlistentry>
5137 <varlistentry>
5138 <term><option>-G</option></term>
5139 <listitem>
5140 <para>
5141 <indexterm role="option">
5142 <primary><option>-G</option></primary>
5143 </indexterm>
5144 <indexterm role="concept">
5145 <primary>Sendmail compatibility</primary>
5146 <secondary><option>-G</option> option ignored</secondary>
5147 </indexterm>
5148 This is a Sendmail option which is ignored by Exim.
5149 </para>
5150 </listitem></varlistentry>
5151 <varlistentry>
5152 <term><option>-h</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;</term>
5153 <listitem>
5154 <para>
5155 <indexterm role="option">
5156 <primary><option>-h</option></primary>
5157 </indexterm>
5158 <indexterm role="concept">
5159 <primary>Sendmail compatibility</primary>
5160 <secondary><option>-h</option> option ignored</secondary>
5161 </indexterm>
5162 This option is accepted for compatibility with Sendmail, but has no effect. (In
5163 Sendmail it overrides the <quote>hop count</quote> obtained by counting <emphasis>Received:</emphasis>
5164 headers.)
5165 </para>
5166 </listitem></varlistentry>
5167 <varlistentry>
5168 <term><option>-i</option></term>
5169 <listitem>
5170 <para>
5171 <indexterm role="option">
5172 <primary><option>-i</option></primary>
5173 </indexterm>
5174 <indexterm role="concept">
5175 <primary>Solaris</primary>
5176 <secondary><emphasis>mail</emphasis> command</secondary>
5177 </indexterm>
5178 <indexterm role="concept">
5179 <primary>dot</primary>
5180 <secondary>in incoming non-SMTP message</secondary>
5181 </indexterm>
5182 This option, which has the same effect as <option>-oi</option>, specifies that a dot on a
5183 line by itself should not terminate an incoming, non-SMTP message. I can find
5184 no documentation for this option in Solaris 2.4 Sendmail, but the <emphasis>mailx</emphasis>
5185 command in Solaris 2.4 uses it. See also <option>-ti</option>.
5186 </para>
5187 </listitem></varlistentry>
5188 <varlistentry>
5189 <term><option>-M</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5190 <listitem>
5191 <para>
5192 <indexterm role="option">
5193 <primary><option>-M</option></primary>
5194 </indexterm>
5195 <indexterm role="concept">
5196 <primary>forcing delivery</primary>
5197 </indexterm>
5198 <indexterm role="concept">
5199 <primary>delivery</primary>
5200 <secondary>forcing attempt</secondary>
5201 </indexterm>
5202 <indexterm role="concept">
5203 <primary>frozen messages</primary>
5204 <secondary>forcing delivery</secondary>
5205 </indexterm>
5206 This option requests Exim to run a delivery attempt on each message in turn. If
5207 any of the messages are frozen, they are automatically thawed before the
5208 delivery attempt. The settings of <option>queue_domains</option>, <option>queue_smtp_domains</option>,
5209 and <option>hold_domains</option> are ignored.
5210 </para>
5211 <para>
5212 Retry
5213 <indexterm role="concept">
5214 <primary>hints database</primary>
5215 <secondary>overriding retry hints</secondary>
5216 </indexterm>
5217 hints for any of the addresses are overridden &ndash; Exim tries to deliver even if
5218 the normal retry time has not yet been reached. This option requires the caller
5219 to be an admin user. However, there is an option called <option>prod_requires_admin</option>
5220 which can be set false to relax this restriction (and also the same requirement
5221 for the <option>-q</option>, <option>-R</option>, and <option>-S</option> options).
5222 </para>
5223 <para>
5224 The deliveries happen synchronously, that is, the original Exim process does
5225 not terminate until all the delivery attempts have finished. No output is
5226 produced unless there is a serious error. If you want to see what is happening,
5227 use the <option>-v</option> option as well, or inspect Exim&#x2019;s main log.
5228 </para>
5229 </listitem></varlistentry>
5230 <varlistentry>
5231 <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>
5232 <listitem>
5233 <para>
5234 <indexterm role="option">
5235 <primary><option>-Mar</option></primary>
5236 </indexterm>
5237 <indexterm role="concept">
5238 <primary>message</primary>
5239 <secondary>adding recipients</secondary>
5240 </indexterm>
5241 <indexterm role="concept">
5242 <primary>recipient</primary>
5243 <secondary>adding</secondary>
5244 </indexterm>
5245 This option requests Exim to add the addresses to the list of recipients of the
5246 message (<quote>ar</quote> for <quote>add recipients</quote>). The first argument must be a message
5247 id, and the remaining ones must be email addresses. However, if the message is
5248 active (in the middle of a delivery attempt), it is not altered. This option
5249 can be used only by an admin user.
5250 </para>
5251 </listitem></varlistentry>
5252 <varlistentry>
5253 <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>
5254 <listitem>
5255 <para>
5256 <indexterm role="option">
5257 <primary><option>-MC</option></primary>
5258 </indexterm>
5259 <indexterm role="concept">
5260 <primary>SMTP</primary>
5261 <secondary>passed connection</secondary>
5262 </indexterm>
5263 <indexterm role="concept">
5264 <primary>SMTP</primary>
5265 <secondary>multiple deliveries</secondary>
5266 </indexterm>
5267 <indexterm role="concept">
5268 <primary>multiple SMTP deliveries</primary>
5269 </indexterm>
5270 This option is not intended for use by external callers. It is used internally
5271 by Exim to invoke another instance of itself to deliver a waiting message using
5272 an existing SMTP connection, which is passed as the standard input. Details are
5273 given in chapter <xref linkend="CHAPSMTP"/>. This must be the final option, and the caller
5274 must be root or the Exim user in order to use it.
5275 </para>
5276 </listitem></varlistentry>
5277 <varlistentry>
5278 <term><option>-MCA</option></term>
5279 <listitem>
5280 <para>
5281 <indexterm role="option">
5282 <primary><option>-MCA</option></primary>
5283 </indexterm>
5284 This option is not intended for use by external callers. It is used internally
5285 by Exim in conjunction with the <option>-MC</option> option. It signifies that the
5286 connection to the remote host has been authenticated.
5287 </para>
5288 </listitem></varlistentry>
5289 <varlistentry>
5290 <term><option>-MCP</option></term>
5291 <listitem>
5292 <para>
5293 <indexterm role="option">
5294 <primary><option>-MCP</option></primary>
5295 </indexterm>
5296 This option is not intended for use by external callers. It is used internally
5297 by Exim in conjunction with the <option>-MC</option> option. It signifies that the server to
5298 which Exim is connected supports pipelining.
5299 </para>
5300 </listitem></varlistentry>
5301 <varlistentry>
5302 <term><option>-MCQ</option>&nbsp;&lt;<emphasis>process&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>pipe&nbsp;fd</emphasis>&gt;</term>
5303 <listitem>
5304 <para>
5305 <indexterm role="option">
5306 <primary><option>-MCQ</option></primary>
5307 </indexterm>
5308 This option is not intended for use by external callers. It is used internally
5309 by Exim in conjunction with the <option>-MC</option> option when the original delivery was
5310 started by a queue runner. It passes on the process id of the queue runner,
5311 together with the file descriptor number of an open pipe. Closure of the pipe
5312 signals the final completion of the sequence of processes that are passing
5313 messages through the same SMTP connection.
5314 </para>
5315 </listitem></varlistentry>
5316 <varlistentry>
5317 <term><option>-MCS</option></term>
5318 <listitem>
5319 <para>
5320 <indexterm role="option">
5321 <primary><option>-MCS</option></primary>
5322 </indexterm>
5323 This option is not intended for use by external callers. It is used internally
5324 by Exim in conjunction with the <option>-MC</option> option, and passes on the fact that the
5325 SMTP SIZE option should be used on messages delivered down the existing
5326 connection.
5327 </para>
5328 </listitem></varlistentry>
5329 <varlistentry>
5330 <term><option>-MCT</option></term>
5331 <listitem>
5332 <para>
5333 <indexterm role="option">
5334 <primary><option>-MCT</option></primary>
5335 </indexterm>
5336 This option is not intended for use by external callers. It is used internally
5337 by Exim in conjunction with the <option>-MC</option> option, and passes on the fact that the
5338 host to which Exim is connected supports TLS encryption.
5339 </para>
5340 </listitem></varlistentry>
5341 <varlistentry>
5342 <term><option>-Mc</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5343 <listitem>
5344 <para>
5345 <indexterm role="option">
5346 <primary><option>-Mc</option></primary>
5347 </indexterm>
5348 <indexterm role="concept">
5349 <primary>hints database</primary>
5350 <secondary>not overridden by <option>-Mc</option></secondary>
5351 </indexterm>
5352 <indexterm role="concept">
5353 <primary>delivery</primary>
5354 <secondary>manually started &ndash; not forced</secondary>
5355 </indexterm>
5356 This option requests Exim to run a delivery attempt on each message in turn,
5357 but unlike the <option>-M</option> option, it does check for retry hints, and respects any
5358 that are found. This option is not very useful to external callers. It is
5359 provided mainly for internal use by Exim when it needs to re-invoke itself in
5360 order to regain root privilege for a delivery (see chapter <xref linkend="CHAPsecurity"/>).
5361 However, <option>-Mc</option> can be useful when testing, in order to run a delivery that
5362 respects retry times and other options such as <option>hold_domains</option> that are
5363 overridden when <option>-M</option> is used. Such a delivery does not count as a queue run.
5364 If you want to run a specific delivery as if in a queue run, you should use
5365 <option>-q</option> with a message id argument. A distinction between queue run deliveries
5366 and other deliveries is made in one or two places.
5367 </para>
5368 </listitem></varlistentry>
5369 <varlistentry>
5370 <term><option>-Mes</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>address</emphasis>&gt;</term>
5371 <listitem>
5372 <para>
5373 <indexterm role="option">
5374 <primary><option>-Mes</option></primary>
5375 </indexterm>
5376 <indexterm role="concept">
5377 <primary>message</primary>
5378 <secondary>changing sender</secondary>
5379 </indexterm>
5380 <indexterm role="concept">
5381 <primary>sender</primary>
5382 <secondary>changing</secondary>
5383 </indexterm>
5384 This option requests Exim to change the sender address in the message to the
5385 given address, which must be a fully qualified address or <quote>&lt;&gt;</quote> (<quote>es</quote> for
5386 <quote>edit sender</quote>). There must be exactly two arguments. The first argument must
5387 be a message id, and the second one an email address. However, if the message
5388 is active (in the middle of a delivery attempt), its status is not altered.
5389 This option can be used only by an admin user.
5390 </para>
5391 </listitem></varlistentry>
5392 <varlistentry>
5393 <term><option>-Mf</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5394 <listitem>
5395 <para>
5396 <indexterm role="option">
5397 <primary><option>-Mf</option></primary>
5398 </indexterm>
5399 <indexterm role="concept">
5400 <primary>freezing messages</primary>
5401 </indexterm>
5402 <indexterm role="concept">
5403 <primary>message</primary>
5404 <secondary>manually freezing</secondary>
5405 </indexterm>
5406 This option requests Exim to mark each listed message as <quote>frozen</quote>. This
5407 prevents any delivery attempts taking place until the message is <quote>thawed</quote>,
5408 either manually or as a result of the <option>auto_thaw</option> configuration option.
5409 However, if any of the messages are active (in the middle of a delivery
5410 attempt), their status is not altered. This option can be used only by an admin
5411 user.
5412 </para>
5413 </listitem></varlistentry>
5414 <varlistentry>
5415 <term><option>-Mg</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5416 <listitem>
5417 <para>
5418 <indexterm role="option">
5419 <primary><option>-Mg</option></primary>
5420 </indexterm>
5421 <indexterm role="concept">
5422 <primary>giving up on messages</primary>
5423 </indexterm>
5424 <indexterm role="concept">
5425 <primary>message</primary>
5426 <secondary>abandoning delivery attempts</secondary>
5427 </indexterm>
5428 <indexterm role="concept">
5429 <primary>delivery</primary>
5430 <secondary>abandoning further attempts</secondary>
5431 </indexterm>
5432 This option requests Exim to give up trying to deliver the listed messages,
5433 including any that are frozen. However, if any of the messages are active,
5434 their status is not altered. For non-bounce messages, a delivery error message
5435 is sent to the sender, containing the text <quote>cancelled by administrator</quote>.
5436 Bounce messages are just discarded. This option can be used only by an admin
5437 user.
5438 </para>
5439 </listitem></varlistentry>
5440 <varlistentry>
5441 <term><option>-Mmad</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5442 <listitem>
5443 <para>
5444 <indexterm role="option">
5445 <primary><option>-Mmad</option></primary>
5446 </indexterm>
5447 <indexterm role="concept">
5448 <primary>delivery</primary>
5449 <secondary>cancelling all</secondary>
5450 </indexterm>
5451 This option requests Exim to mark all the recipient addresses in the messages
5452 as already delivered (<quote>mad</quote> for <quote>mark all delivered</quote>). However, if any
5453 message is active (in the middle of a delivery attempt), its status is not
5454 altered. This option can be used only by an admin user.
5455 </para>
5456 </listitem></varlistentry>
5457 <varlistentry>
5458 <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>
5459 <listitem>
5460 <para>
5461 <indexterm role="option">
5462 <primary><option>-Mmd</option></primary>
5463 </indexterm>
5464 <indexterm role="concept">
5465 <primary>delivery</primary>
5466 <secondary>cancelling by address</secondary>
5467 </indexterm>
5468 <indexterm role="concept">
5469 <primary>recipient</primary>
5470 <secondary>removing</secondary>
5471 </indexterm>
5472 <indexterm role="concept">
5473 <primary>removing recipients</primary>
5474 </indexterm>
5475 This option requests Exim to mark the given addresses as already delivered
5476 (<quote>md</quote> for <quote>mark delivered</quote>). The first argument must be a message id, and
5477 the remaining ones must be email addresses. These are matched to recipient
5478 addresses in the message in a case-sensitive manner. If the message is active
5479 (in the middle of a delivery attempt), its status is not altered. This option
5480 can be used only by an admin user.
5481 </para>
5482 </listitem></varlistentry>
5483 <varlistentry>
5484 <term><option>-Mrm</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5485 <listitem>
5486 <para>
5487 <indexterm role="option">
5488 <primary><option>-Mrm</option></primary>
5489 </indexterm>
5490 <indexterm role="concept">
5491 <primary>removing messages</primary>
5492 </indexterm>
5493 <indexterm role="concept">
5494 <primary>abandoning mail</primary>
5495 </indexterm>
5496 <indexterm role="concept">
5497 <primary>message</primary>
5498 <secondary>manually discarding</secondary>
5499 </indexterm>
5500 This option requests Exim to remove the given messages from the queue. No
5501 bounce messages are sent; each message is simply forgotten. However, if any of
5502 the messages are active, their status is not altered. This option can be used
5503 only by an admin user or by the user who originally caused the message to be
5504 placed on the queue.
5505 </para>
5506 </listitem></varlistentry>
5507 <varlistentry>
5508 <term><option>-Mset</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
5509 <listitem>
5510 <para>
5511 <indexterm role="option">
5512 <primary><option>-Mset</option></primary>
5513 </indexterm>
5514 <indexterm role="concept">
5515 <primary>testing</primary>
5516 <secondary>string expansion</secondary>
5517 </indexterm>
5518 <indexterm role="concept">
5519 <primary>expansion</primary>
5520 <secondary>testing</secondary>
5521 </indexterm>
5522 This option is useful only in conjunction with <option>-be</option> (that is, when testing
5523 string expansions). Exim loads the given message from its spool before doing
5524 the test expansions, thus setting message-specific variables such as
5525 <varname>$message_size</varname> and the header variables. The <varname>$recipients</varname> variable is made
5526 available. This feature is provided to make it easier to test expansions that
5527 make use of these variables. However, this option can be used only by an admin
5528 user. See also <option>-bem</option>.
5529 </para>
5530 </listitem></varlistentry>
5531 <varlistentry>
5532 <term><option>-Mt</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5533 <listitem>
5534 <para>
5535 <indexterm role="option">
5536 <primary><option>-Mt</option></primary>
5537 </indexterm>
5538 <indexterm role="concept">
5539 <primary>thawing messages</primary>
5540 </indexterm>
5541 <indexterm role="concept">
5542 <primary>unfreezing messages</primary>
5543 </indexterm>
5544 <indexterm role="concept">
5545 <primary>frozen messages</primary>
5546 <secondary>thawing</secondary>
5547 </indexterm>
5548 <indexterm role="concept">
5549 <primary>message</primary>
5550 <secondary>thawing frozen</secondary>
5551 </indexterm>
5552 This option requests Exim to <quote>thaw</quote> any of the listed messages that are
5553 <quote>frozen</quote>, so that delivery attempts can resume. However, if any of the
5554 messages are active, their status is not altered. This option can be used only
5555 by an admin user.
5556 </para>
5557 </listitem></varlistentry>
5558 <varlistentry>
5559 <term><option>-Mvb</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
5560 <listitem>
5561 <para>
5562 <indexterm role="option">
5563 <primary><option>-Mvb</option></primary>
5564 </indexterm>
5565 <indexterm role="concept">
5566 <primary>listing</primary>
5567 <secondary>message body</secondary>
5568 </indexterm>
5569 <indexterm role="concept">
5570 <primary>message</primary>
5571 <secondary>listing body of</secondary>
5572 </indexterm>
5573 This option causes the contents of the message body (-D) spool file to be
5574 written to the standard output. This option can be used only by an admin user.
5575 </para>
5576 </listitem></varlistentry>
5577 <varlistentry>
5578 <term><option>-Mvc</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
5579 <listitem>
5580 <para>
5581 <indexterm role="option">
5582 <primary><option>-Mvc</option></primary>
5583 </indexterm>
5584 <indexterm role="concept">
5585 <primary>message</primary>
5586 <secondary>listing in RFC 2822 format</secondary>
5587 </indexterm>
5588 <indexterm role="concept">
5589 <primary>listing</primary>
5590 <secondary>message in RFC 2822 format</secondary>
5591 </indexterm>
5592 This option causes a copy of the complete message (header lines plus body) to
5593 be written to the standard output in RFC 2822 format. This option can be used
5594 only by an admin user.
5595 </para>
5596 </listitem></varlistentry>
5597 <varlistentry>
5598 <term><option>-Mvh</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
5599 <listitem>
5600 <para>
5601 <indexterm role="option">
5602 <primary><option>-Mvh</option></primary>
5603 </indexterm>
5604 <indexterm role="concept">
5605 <primary>listing</primary>
5606 <secondary>message headers</secondary>
5607 </indexterm>
5608 <indexterm role="concept">
5609 <primary>header lines</primary>
5610 <secondary>listing</secondary>
5611 </indexterm>
5612 <indexterm role="concept">
5613 <primary>message</primary>
5614 <secondary>listing header lines</secondary>
5615 </indexterm>
5616 This option causes the contents of the message headers (-H) spool file to be
5617 written to the standard output. This option can be used only by an admin user.
5618 </para>
5619 </listitem></varlistentry>
5620 <varlistentry>
5621 <term><option>-Mvl</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
5622 <listitem>
5623 <para>
5624 <indexterm role="option">
5625 <primary><option>-Mvl</option></primary>
5626 </indexterm>
5627 <indexterm role="concept">
5628 <primary>listing</primary>
5629 <secondary>message log</secondary>
5630 </indexterm>
5631 <indexterm role="concept">
5632 <primary>message</primary>
5633 <secondary>listing message log</secondary>
5634 </indexterm>
5635 This option causes the contents of the message log spool file to be written to
5636 the standard output. This option can be used only by an admin user.
5637 </para>
5638 </listitem></varlistentry>
5639 <varlistentry>
5640 <term><option>-m</option></term>
5641 <listitem>
5642 <para>
5643 <indexterm role="option">
5644 <primary><option>-m</option></primary>
5645 </indexterm>
5646 This is apparently a synonym for <option>-om</option> that is accepted by Sendmail, so Exim
5647 treats it that way too.
5648 </para>
5649 </listitem></varlistentry>
5650 <varlistentry>
5651 <term><option>-N</option></term>
5652 <listitem>
5653 <para>
5654 <indexterm role="option">
5655 <primary><option>-N</option></primary>
5656 </indexterm>
5657 <indexterm role="concept">
5658 <primary>debugging</primary>
5659 <secondary><option>-N</option> option</secondary>
5660 </indexterm>
5661 <indexterm role="concept">
5662 <primary>debugging</primary>
5663 <secondary>suppressing delivery</secondary>
5664 </indexterm>
5665 This is a debugging option that inhibits delivery of a message at the transport
5666 level. It implies <option>-v</option>. Exim goes through many of the motions of delivery &ndash;
5667 it just doesn&#x2019;t actually transport the message, but instead behaves as if it
5668 had successfully done so. However, it does not make any updates to the retry
5669 database, and the log entries for deliveries are flagged with <quote>*&gt;</quote> rather
5670 than <quote>=&gt;</quote>.
5671 </para>
5672 <para>
5673 Because <option>-N</option> discards any message to which it applies, only root or the Exim
5674 user are allowed to use it with <option>-bd</option>, <option>-q</option>, <option>-R</option> or <option>-M</option>. In other
5675 words, an ordinary user can use it only when supplying an incoming message to
5676 which it will apply. Although transportation never fails when <option>-N</option> is set, an
5677 address may be deferred because of a configuration problem on a transport, or a
5678 routing problem. Once <option>-N</option> has been used for a delivery attempt, it sticks to
5679 the message, and applies to any subsequent delivery attempts that may happen
5680 for that message.
5681 </para>
5682 </listitem></varlistentry>
5683 <varlistentry>
5684 <term><option>-n</option></term>
5685 <listitem>
5686 <para>
5687 <indexterm role="option">
5688 <primary><option>-n</option></primary>
5689 </indexterm>
5690 <indexterm role="concept">
5691 <primary>Sendmail compatibility</primary>
5692 <secondary><option>-n</option> option ignored</secondary>
5693 </indexterm>
5694 This option is interpreted by Sendmail to mean <quote>no aliasing</quote>. It is ignored
5695 by Exim.
5696 </para>
5697 </listitem></varlistentry>
5698 <varlistentry>
5699 <term><option>-O</option>&nbsp;&lt;<emphasis>data</emphasis>&gt;</term>
5700 <listitem>
5701 <para>
5702 <indexterm role="option">
5703 <primary><option>-O</option></primary>
5704 </indexterm>
5705 This option is interpreted by Sendmail to mean <literal>set option</literal>. It is ignored by
5706 Exim.
5707 </para>
5708 </listitem></varlistentry>
5709 <varlistentry>
5710 <term><option>-oA</option>&nbsp;&lt;<emphasis>file&nbsp;name</emphasis>&gt;</term>
5711 <listitem>
5712 <para>
5713 <indexterm role="option">
5714 <primary><option>-oA</option></primary>
5715 </indexterm>
5716 <indexterm role="concept">
5717 <primary>Sendmail compatibility</primary>
5718 <secondary><option>-oA</option> option</secondary>
5719 </indexterm>
5720 This option is used by Sendmail in conjunction with <option>-bi</option> to specify an
5721 alternative alias file name. Exim handles <option>-bi</option> differently; see the
5722 description above.
5723 </para>
5724 </listitem></varlistentry>
5725 <varlistentry>
5726 <term><option>-oB</option>&nbsp;&lt;<emphasis>n</emphasis>&gt;</term>
5727 <listitem>
5728 <para>
5729 <indexterm role="option">
5730 <primary><option>-oB</option></primary>
5731 </indexterm>
5732 <indexterm role="concept">
5733 <primary>SMTP</primary>
5734 <secondary>passed connection</secondary>
5735 </indexterm>
5736 <indexterm role="concept">
5737 <primary>SMTP</primary>
5738 <secondary>multiple deliveries</secondary>
5739 </indexterm>
5740 <indexterm role="concept">
5741 <primary>multiple SMTP deliveries</primary>
5742 </indexterm>
5743 This is a debugging option which limits the maximum number of messages that can
5744 be delivered down one SMTP connection, overriding the value set in any <command>smtp</command>
5745 transport. If &lt;<emphasis>n</emphasis>&gt; is omitted, the limit is set to 1.
5746 </para>
5747 </listitem></varlistentry>
5748 <varlistentry>
5749 <term><option>-odb</option></term>
5750 <listitem>
5751 <para>
5752 <indexterm role="option">
5753 <primary><option>-odb</option></primary>
5754 </indexterm>
5755 <indexterm role="concept">
5756 <primary>background delivery</primary>
5757 </indexterm>
5758 <indexterm role="concept">
5759 <primary>delivery</primary>
5760 <secondary>in the background</secondary>
5761 </indexterm>
5762 This option applies to all modes in which Exim accepts incoming messages,
5763 including the listening daemon. It requests <quote>background</quote> delivery of such
5764 messages, which means that the accepting process automatically starts a
5765 delivery process for each message received, but does not wait for the delivery
5766 processes to finish.
5767 </para>
5768 <para>
5769 When all the messages have been received, the reception process exits,
5770 leaving the delivery processes to finish in their own time. The standard output
5771 and error streams are closed at the start of each delivery process.
5772 This is the default action if none of the <option>-od</option> options are present.
5773 </para>
5774 <para>
5775 If one of the queueing options in the configuration file
5776 (<option>queue_only</option> or <option>queue_only_file</option>, for example) is in effect, <option>-odb</option>
5777 overrides it if <option>queue_only_override</option> is set true, which is the default
5778 setting. If <option>queue_only_override</option> is set false, <option>-odb</option> has no effect.
5779 </para>
5780 </listitem></varlistentry>
5781 <varlistentry>
5782 <term><option>-odf</option></term>
5783 <listitem>
5784 <para>
5785 <indexterm role="option">
5786 <primary><option>-odf</option></primary>
5787 </indexterm>
5788 <indexterm role="concept">
5789 <primary>foreground delivery</primary>
5790 </indexterm>
5791 <indexterm role="concept">
5792 <primary>delivery</primary>
5793 <secondary>in the foreground</secondary>
5794 </indexterm>
5795 This option requests <quote>foreground</quote> (synchronous) delivery when Exim has
5796 accepted a locally-generated message. (For the daemon it is exactly the same as
5797 <option>-odb</option>.) A delivery process is automatically started to deliver the message,
5798 and Exim waits for it to complete before proceeding.
5799 </para>
5800 <para>
5801 The original Exim reception process does not finish until the delivery
5802 process for the final message has ended. The standard error stream is left open
5803 during deliveries.
5804 </para>
5805 <para>
5806 However, like <option>-odb</option>, this option has no effect if <option>queue_only_override</option> is
5807 false and one of the queueing options in the configuration file is in effect.
5808 </para>
5809 <para>
5810 If there is a temporary delivery error during foreground delivery, the
5811 message is left on the queue for later delivery, and the original reception
5812 process exits. See chapter <xref linkend="CHAPnonqueueing"/> for a way of setting up a
5813 restricted configuration that never queues messages.
5814 </para>
5815 </listitem></varlistentry>
5816 <varlistentry>
5817 <term><option>-odi</option></term>
5818 <listitem>
5819 <para>
5820 <indexterm role="option">
5821 <primary><option>-odi</option></primary>
5822 </indexterm>
5823 This option is synonymous with <option>-odf</option>. It is provided for compatibility with
5824 Sendmail.
5825 </para>
5826 </listitem></varlistentry>
5827 <varlistentry>
5828 <term><option>-odq</option></term>
5829 <listitem>
5830 <para>
5831 <indexterm role="option">
5832 <primary><option>-odq</option></primary>
5833 </indexterm>
5834 <indexterm role="concept">
5835 <primary>non-immediate delivery</primary>
5836 </indexterm>
5837 <indexterm role="concept">
5838 <primary>delivery</primary>
5839 <secondary>suppressing immediate</secondary>
5840 </indexterm>
5841 <indexterm role="concept">
5842 <primary>queueing incoming messages</primary>
5843 </indexterm>
5844 This option applies to all modes in which Exim accepts incoming messages,
5845 including the listening daemon. It specifies that the accepting process should
5846 not automatically start a delivery process for each message received. Messages
5847 are placed on the queue, and remain there until a subsequent queue runner
5848 process encounters them. There are several configuration options (such as
5849 <option>queue_only</option>) that can be used to queue incoming messages under certain
5850 conditions. This option overrides all of them and also <option>-odqs</option>. It always
5851 forces queueing.
5852 </para>
5853 </listitem></varlistentry>
5854 <varlistentry>
5855 <term><option>-odqs</option></term>
5856 <listitem>
5857 <para>
5858 <indexterm role="option">
5859 <primary><option>-odqs</option></primary>
5860 </indexterm>
5861 <indexterm role="concept">
5862 <primary>SMTP</primary>
5863 <secondary>delaying delivery</secondary>
5864 </indexterm>
5865 This option is a hybrid between <option>-odb</option>/<option>-odi</option> and <option>-odq</option>.
5866 However, like <option>-odb</option> and <option>-odi</option>, this option has no effect if
5867 <option>queue_only_override</option> is false and one of the queueing options in the
5868 configuration file is in effect.
5869 </para>
5870 <para>
5871 When <option>-odqs</option> does operate, a delivery process is started for each incoming
5872 message, in the background by default, but in the foreground if <option>-odi</option> is
5873 also present. The recipient addresses are routed, and local deliveries are done
5874 in the normal way. However, if any SMTP deliveries are required, they are not
5875 done at this time, so the message remains on the queue until a subsequent queue
5876 runner process encounters it. Because routing was done, Exim knows which
5877 messages are waiting for which hosts, and so a number of messages for the same
5878 host can be sent in a single SMTP connection. The <option>queue_smtp_domains</option>
5879 configuration option has the same effect for specific domains. See also the
5880 <option>-qq</option> option.
5881 </para>
5882 </listitem></varlistentry>
5883 <varlistentry>
5884 <term><option>-oee</option></term>
5885 <listitem>
5886 <para>
5887 <indexterm role="option">
5888 <primary><option>-oee</option></primary>
5889 </indexterm>
5890 <indexterm role="concept">
5891 <primary>error</primary>
5892 <secondary>reporting</secondary>
5893 </indexterm>
5894 If an error is detected while a non-SMTP message is being received (for
5895 example, a malformed address), the error is reported to the sender in a mail
5896 message.
5897 </para>
5898 <para>
5899 <indexterm role="concept">
5900 <primary>return code</primary>
5901 <secondary>for <option>-oee</option></secondary>
5902 </indexterm>
5903 Provided
5904 this error message is successfully sent, the Exim receiving process
5905 exits with a return code of zero. If not, the return code is 2 if the problem
5906 is that the original message has no recipients, or 1 any other error. This is
5907 the default <option>-oe</option><emphasis>x</emphasis> option if Exim is called as <emphasis>rmail</emphasis>.
5908 </para>
5909 </listitem></varlistentry>
5910 <varlistentry>
5911 <term><option>-oem</option></term>
5912 <listitem>
5913 <para>
5914 <indexterm role="option">
5915 <primary><option>-oem</option></primary>
5916 </indexterm>
5917 <indexterm role="concept">
5918 <primary>error</primary>
5919 <secondary>reporting</secondary>
5920 </indexterm>
5921 <indexterm role="concept">
5922 <primary>return code</primary>
5923 <secondary>for <option>-oem</option></secondary>
5924 </indexterm>
5925 This is the same as <option>-oee</option>, except that Exim always exits with a non-zero
5926 return code, whether or not the error message was successfully sent.
5927 This is the default <option>-oe</option><emphasis>x</emphasis> option, unless Exim is called as <emphasis>rmail</emphasis>.
5928 </para>
5929 </listitem></varlistentry>
5930 <varlistentry>
5931 <term><option>-oep</option></term>
5932 <listitem>
5933 <para>
5934 <indexterm role="option">
5935 <primary><option>-oep</option></primary>
5936 </indexterm>
5937 <indexterm role="concept">
5938 <primary>error</primary>
5939 <secondary>reporting</secondary>
5940 </indexterm>
5941 If an error is detected while a non-SMTP message is being received, the
5942 error is reported by writing a message to the standard error file (stderr).
5943 <indexterm role="concept">
5944 <primary>return code</primary>
5945 <secondary>for <option>-oep</option></secondary>
5946 </indexterm>
5947 The return code is 1 for all errors.
5948 </para>
5949 </listitem></varlistentry>
5950 <varlistentry>
5951 <term><option>-oeq</option></term>
5952 <listitem>
5953 <para>
5954 <indexterm role="option">
5955 <primary><option>-oeq</option></primary>
5956 </indexterm>
5957 <indexterm role="concept">
5958 <primary>error</primary>
5959 <secondary>reporting</secondary>
5960 </indexterm>
5961 This option is supported for compatibility with Sendmail, but has the same
5962 effect as <option>-oep</option>.
5963 </para>
5964 </listitem></varlistentry>
5965 <varlistentry>
5966 <term><option>-oew</option></term>
5967 <listitem>
5968 <para>
5969 <indexterm role="option">
5970 <primary><option>-oew</option></primary>
5971 </indexterm>
5972 <indexterm role="concept">
5973 <primary>error</primary>
5974 <secondary>reporting</secondary>
5975 </indexterm>
5976 This option is supported for compatibility with Sendmail, but has the same
5977 effect as <option>-oem</option>.
5978 </para>
5979 </listitem></varlistentry>
5980 <varlistentry>
5981 <term><option>-oi</option></term>
5982 <listitem>
5983 <para>
5984 <indexterm role="option">
5985 <primary><option>-oi</option></primary>
5986 </indexterm>
5987 <indexterm role="concept">
5988 <primary>dot</primary>
5989 <secondary>in incoming non-SMTP message</secondary>
5990 </indexterm>
5991 This option, which has the same effect as <option>-i</option>, specifies that a dot on a
5992 line by itself should not terminate an incoming, non-SMTP message. Otherwise, a
5993 single dot does terminate, though Exim does no special processing for other
5994 lines that start with a dot. This option is set by default if Exim is called as
5995 <emphasis>rmail</emphasis>. See also <option>-ti</option>.
5996 </para>
5997 </listitem></varlistentry>
5998 <varlistentry>
5999 <term><option>-oitrue</option></term>
6000 <listitem>
6001 <para>
6002 <indexterm role="option">
6003 <primary><option>-oitrue</option></primary>
6004 </indexterm>
6005 This option is treated as synonymous with <option>-oi</option>.
6006 </para>
6007 </listitem></varlistentry>
6008 <varlistentry>
6009 <term><option>-oMa</option>&nbsp;&lt;<emphasis>host&nbsp;address</emphasis>&gt;</term>
6010 <listitem>
6011 <para>
6012 <indexterm role="option">
6013 <primary><option>-oMa</option></primary>
6014 </indexterm>
6015 <indexterm role="concept">
6016 <primary>sender</primary>
6017 <secondary>host address, specifying for local message</secondary>
6018 </indexterm>
6019 A number of options starting with <option>-oM</option> can be used to set values associated
6020 with remote hosts on locally-submitted messages (that is, messages not received
6021 over TCP/IP). These options can be used by any caller in conjunction with the
6022 <option>-bh</option>, <option>-be</option>, <option>-bf</option>, <option>-bF</option>, <option>-bt</option>, or <option>-bv</option> testing options. In
6023 other circumstances, they are ignored unless the caller is trusted.
6024 </para>
6025 <para>
6026 The <option>-oMa</option> option sets the sender host address. This may include a port
6027 number at the end, after a full stop (period). For example:
6028 </para>
6029 <literallayout class="monospaced">
6030 exim -bs -oMa 10.9.8.7.1234
6031 </literallayout>
6032 <para>
6033 An alternative syntax is to enclose the IP address in square brackets,
6034 followed by a colon and the port number:
6035 </para>
6036 <literallayout class="monospaced">
6037 exim -bs -oMa [10.9.8.7]:1234
6038 </literallayout>
6039 <para>
6040 The IP address is placed in the <varname>$sender_host_address</varname> variable, and the
6041 port, if present, in <varname>$sender_host_port</varname>. If both <option>-oMa</option> and <option>-bh</option>
6042 are present on the command line, the sender host IP address is taken from
6043 whichever one is last.
6044 </para>
6045 </listitem></varlistentry>
6046 <varlistentry>
6047 <term><option>-oMaa</option>&nbsp;&lt;<emphasis>name</emphasis>&gt;</term>
6048 <listitem>
6049 <para>
6050 <indexterm role="option">
6051 <primary><option>-oMaa</option></primary>
6052 </indexterm>
6053 <indexterm role="concept">
6054 <primary>authentication</primary>
6055 <secondary>name, specifying for local message</secondary>
6056 </indexterm>
6057 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMaa</option>
6058 option sets the value of <varname>$sender_host_authenticated</varname> (the authenticator
6059 name). See chapter <xref linkend="CHAPSMTPAUTH"/> for a discussion of SMTP authentication.
6060 This option can be used with <option>-bh</option> and <option>-bs</option> to set up an
6061 authenticated SMTP session without actually using the SMTP AUTH command.
6062 </para>
6063 </listitem></varlistentry>
6064 <varlistentry>
6065 <term><option>-oMai</option>&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
6066 <listitem>
6067 <para>
6068 <indexterm role="option">
6069 <primary><option>-oMai</option></primary>
6070 </indexterm>
6071 <indexterm role="concept">
6072 <primary>authentication</primary>
6073 <secondary>id, specifying for local message</secondary>
6074 </indexterm>
6075 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMai</option>
6076 option sets the value of <varname>$authenticated_id</varname> (the id that was authenticated).
6077 This overrides the default value (the caller&#x2019;s login id, except with <option>-bh</option>,
6078 where there is no default) for messages from local sources. See chapter
6079 <xref linkend="CHAPSMTPAUTH"/> for a discussion of authenticated ids.
6080 </para>
6081 </listitem></varlistentry>
6082 <varlistentry>
6083 <term><option>-oMas</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;</term>
6084 <listitem>
6085 <para>
6086 <indexterm role="option">
6087 <primary><option>-oMas</option></primary>
6088 </indexterm>
6089 <indexterm role="concept">
6090 <primary>authentication</primary>
6091 <secondary>sender, specifying for local message</secondary>
6092 </indexterm>
6093 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMas</option>
6094 option sets the authenticated sender value in <varname>$authenticated_sender</varname>. It
6095 overrides the sender address that is created from the caller&#x2019;s login id for
6096 messages from local sources, except when <option>-bh</option> is used, when there is no
6097 default. For both <option>-bh</option> and <option>-bs</option>, an authenticated sender that is
6098 specified on a MAIL command overrides this value. See chapter
6099 <xref linkend="CHAPSMTPAUTH"/> for a discussion of authenticated senders.
6100 </para>
6101 </listitem></varlistentry>
6102 <varlistentry>
6103 <term><option>-oMi</option>&nbsp;&lt;<emphasis>interface&nbsp;address</emphasis>&gt;</term>
6104 <listitem>
6105 <para>
6106 <indexterm role="option">
6107 <primary><option>-oMi</option></primary>
6108 </indexterm>
6109 <indexterm role="concept">
6110 <primary>interface</primary>
6111 <secondary>address, specifying for local message</secondary>
6112 </indexterm>
6113 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMi</option>
6114 option sets the IP interface address value. A port number may be included,
6115 using the same syntax as for <option>-oMa</option>. The interface address is placed in
6116 <varname>$received_ip_address</varname> and the port number, if present, in <varname>$received_port</varname>.
6117 </para>
6118 </listitem></varlistentry>
6119 <varlistentry>
6120 <term><option>-oMr</option>&nbsp;&lt;<emphasis>protocol&nbsp;name</emphasis>&gt;</term>
6121 <listitem>
6122 <para>
6123 <indexterm role="option">
6124 <primary><option>-oMr</option></primary>
6125 </indexterm>
6126 <indexterm role="concept">
6127 <primary>protocol, specifying for local message</primary>
6128 </indexterm>
6129 <indexterm role="variable">
6130 <primary><varname>$received_protocol</varname></primary>
6131 </indexterm>
6132 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMr</option>
6133 option sets the received protocol value that is stored in
6134 <varname>$received_protocol</varname>. However, it does not apply (and is ignored) when <option>-bh</option>
6135 or <option>-bs</option> is used. For <option>-bh</option>, the protocol is forced to one of the standard
6136 SMTP protocol names (see the description of <varname>$received_protocol</varname> in section
6137 <xref linkend="SECTexpvar"/>). For <option>-bs</option>, the protocol is always <quote>local-</quote> followed by
6138 one of those same names. For <option>-bS</option> (batched SMTP) however, the protocol can
6139 be set by <option>-oMr</option>.
6140 </para>
6141 </listitem></varlistentry>
6142 <varlistentry>
6143 <term><option>-oMs</option>&nbsp;&lt;<emphasis>host&nbsp;name</emphasis>&gt;</term>
6144 <listitem>
6145 <para>
6146 <indexterm role="option">
6147 <primary><option>-oMs</option></primary>
6148 </indexterm>
6149 <indexterm role="concept">
6150 <primary>sender</primary>
6151 <secondary>host name, specifying for local message</secondary>
6152 </indexterm>
6153 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMs</option>
6154 option sets the sender host name in <varname>$sender_host_name</varname>. When this option is
6155 present, Exim does not attempt to look up a host name from an IP address; it
6156 uses the name it is given.
6157 </para>
6158 </listitem></varlistentry>
6159 <varlistentry>
6160 <term><option>-oMt</option>&nbsp;&lt;<emphasis>ident&nbsp;string</emphasis>&gt;</term>
6161 <listitem>
6162 <para>
6163 <indexterm role="option">
6164 <primary><option>-oMt</option></primary>
6165 </indexterm>
6166 <indexterm role="concept">
6167 <primary>sender</primary>
6168 <secondary>ident string, specifying for local message</secondary>
6169 </indexterm>
6170 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMt</option>
6171 option sets the sender ident value in <varname>$sender_ident</varname>. The default setting for
6172 local callers is the login id of the calling process, except when <option>-bh</option> is
6173 used, when there is no default.
6174 </para>
6175 </listitem></varlistentry>
6176 <varlistentry>
6177 <term><option>-om</option></term>
6178 <listitem>
6179 <para>
6180 <indexterm role="option">
6181 <primary><option>-om</option></primary>
6182 </indexterm>
6183 <indexterm role="concept">
6184 <primary>Sendmail compatibility</primary>
6185 <secondary><option>-om</option> option ignored</secondary>
6186 </indexterm>
6187 In Sendmail, this option means <quote>me too</quote>, indicating that the sender of a
6188 message should receive a copy of the message if the sender appears in an alias
6189 expansion. Exim always does this, so the option does nothing.
6190 </para>
6191 </listitem></varlistentry>
6192 <varlistentry>
6193 <term><option>-oo</option></term>
6194 <listitem>
6195 <para>
6196 <indexterm role="option">
6197 <primary><option>-oo</option></primary>
6198 </indexterm>
6199 <indexterm role="concept">
6200 <primary>Sendmail compatibility</primary>
6201 <secondary><option>-oo</option> option ignored</secondary>
6202 </indexterm>
6203 This option is ignored. In Sendmail it specifies <quote>old style headers</quote>,
6204 whatever that means.
6205 </para>
6206 </listitem></varlistentry>
6207 <varlistentry>
6208 <term><option>-oP</option>&nbsp;&lt;<emphasis>path</emphasis>&gt;</term>
6209 <listitem>
6210 <para>
6211 <indexterm role="option">
6212 <primary><option>-oP</option></primary>
6213 </indexterm>
6214 <indexterm role="concept">
6215 <primary>pid (process id)</primary>
6216 <secondary>of daemon</secondary>
6217 </indexterm>
6218 <indexterm role="concept">
6219 <primary>daemon</primary>
6220 <secondary>process id (pid)</secondary>
6221 </indexterm>
6222 This option is useful only in conjunction with <option>-bd</option> or <option>-q</option> with a time
6223 value. The option specifies the file to which the process id of the daemon is
6224 written. When <option>-oX</option> is used with <option>-bd</option>, or when <option>-q</option> with a time is used
6225 without <option>-bd</option>, this is the only way of causing Exim to write a pid file,
6226 because in those cases, the normal pid file is not used.
6227 </para>
6228 </listitem></varlistentry>
6229 <varlistentry>
6230 <term><option>-or</option>&nbsp;&lt;<emphasis>time</emphasis>&gt;</term>
6231 <listitem>
6232 <para>
6233 <indexterm role="option">
6234 <primary><option>-or</option></primary>
6235 </indexterm>
6236 <indexterm role="concept">
6237 <primary>timeout</primary>
6238 <secondary>for non-SMTP input</secondary>
6239 </indexterm>
6240 This option sets a timeout value for incoming non-SMTP messages. If it is not
6241 set, Exim will wait forever for the standard input. The value can also be set
6242 by the <option>receive_timeout</option> option. The format used for specifying times is
6243 described in section <xref linkend="SECTtimeformat"/>.
6244 </para>
6245 </listitem></varlistentry>
6246 <varlistentry>
6247 <term><option>-os</option>&nbsp;&lt;<emphasis>time</emphasis>&gt;</term>
6248 <listitem>
6249 <para>
6250 <indexterm role="option">
6251 <primary><option>-os</option></primary>
6252 </indexterm>
6253 <indexterm role="concept">
6254 <primary>timeout</primary>
6255 <secondary>for SMTP input</secondary>
6256 </indexterm>
6257 <indexterm role="concept">
6258 <primary>SMTP</primary>
6259 <secondary>input timeout</secondary>
6260 </indexterm>
6261 This option sets a timeout value for incoming SMTP messages. The timeout
6262 applies to each SMTP command and block of data. The value can also be set by
6263 the <option>smtp_receive_timeout</option> option; it defaults to 5 minutes. The format used
6264 for specifying times is described in section <xref linkend="SECTtimeformat"/>.
6265 </para>
6266 </listitem></varlistentry>
6267 <varlistentry>
6268 <term><option>-ov</option></term>
6269 <listitem>
6270 <para>
6271 <indexterm role="option">
6272 <primary><option>-ov</option></primary>
6273 </indexterm>
6274 This option has exactly the same effect as <option>-v</option>.
6275 </para>
6276 </listitem></varlistentry>
6277 <varlistentry>
6278 <term><option>-oX</option>&nbsp;&lt;<emphasis>number&nbsp;or&nbsp;string</emphasis>&gt;</term>
6279 <listitem>
6280 <para>
6281 <indexterm role="option">
6282 <primary><option>-oX</option></primary>
6283 </indexterm>
6284 <indexterm role="concept">
6285 <primary>TCP/IP</primary>
6286 <secondary>setting listening ports</secondary>
6287 </indexterm>
6288 <indexterm role="concept">
6289 <primary>TCP/IP</primary>
6290 <secondary>setting listening interfaces</secondary>
6291 </indexterm>
6292 <indexterm role="concept">
6293 <primary>port</primary>
6294 <secondary>receiving TCP/IP</secondary>
6295 </indexterm>
6296 This option is relevant only when the <option>-bd</option> (start listening daemon) option
6297 is also given. It controls which ports and interfaces the daemon uses. Details
6298 of the syntax, and how it interacts with configuration file options, are given
6299 in chapter <xref linkend="CHAPinterfaces"/>. When <option>-oX</option> is used to start a daemon, no pid
6300 file is written unless <option>-oP</option> is also present to specify a pid file name.
6301 </para>
6302 </listitem></varlistentry>
6303 <varlistentry>
6304 <term><option>-pd</option></term>
6305 <listitem>
6306 <para>
6307 <indexterm role="option">
6308 <primary><option>-pd</option></primary>
6309 </indexterm>
6310 <indexterm role="concept">
6311 <primary>Perl</primary>
6312 <secondary>starting the interpreter</secondary>
6313 </indexterm>
6314 This option applies when an embedded Perl interpreter is linked with Exim (see
6315 chapter <xref linkend="CHAPperl"/>). It overrides the setting of the <option>perl_at_start</option>
6316 option, forcing the starting of the interpreter to be delayed until it is
6317 needed.
6318 </para>
6319 </listitem></varlistentry>
6320 <varlistentry>
6321 <term><option>-ps</option></term>
6322 <listitem>
6323 <para>
6324 <indexterm role="option">
6325 <primary><option>-ps</option></primary>
6326 </indexterm>
6327 <indexterm role="concept">
6328 <primary>Perl</primary>
6329 <secondary>starting the interpreter</secondary>
6330 </indexterm>
6331 This option applies when an embedded Perl interpreter is linked with Exim (see
6332 chapter <xref linkend="CHAPperl"/>). It overrides the setting of the <option>perl_at_start</option>
6333 option, forcing the starting of the interpreter to occur as soon as Exim is
6334 started.
6335 </para>
6336 </listitem></varlistentry>
6337 <varlistentry>
6338 <term><option>-p</option>&lt;<emphasis>rval</emphasis>&gt;:&lt;<emphasis>sval</emphasis>&gt;</term>
6339 <listitem>
6340 <para>
6341 <indexterm role="option">
6342 <primary><option>-p</option></primary>
6343 </indexterm>
6344 For compatibility with Sendmail, this option is equivalent to
6345 </para>
6346 <literallayout>
6347 <literal>-oMr</literal> &lt;<emphasis>rval</emphasis>&gt; <literal>-oMs</literal> &lt;<emphasis>sval</emphasis>&gt;
6348 </literallayout>
6349 <para>
6350 It sets the incoming protocol and host name (for trusted callers). The
6351 host name and its colon can be omitted when only the protocol is to be set.
6352 Note the Exim already has two private options, <option>-pd</option> and <option>-ps</option>, that refer
6353 to embedded Perl. It is therefore impossible to set a protocol value of <literal>p</literal>
6354 or <literal>s</literal> using this option (but that does not seem a real limitation).
6355 </para>
6356 </listitem></varlistentry>
6357 <varlistentry>
6358 <term><option>-q</option></term>
6359 <listitem>
6360 <para>
6361 <indexterm role="option">
6362 <primary><option>-q</option></primary>
6363 </indexterm>
6364 <indexterm role="concept">
6365 <primary>queue runner</primary>
6366 <secondary>starting manually</secondary>
6367 </indexterm>
6368 This option is normally restricted to admin users. However, there is a
6369 configuration option called <option>prod_requires_admin</option> which can be set false to
6370 relax this restriction (and also the same requirement for the <option>-M</option>, <option>-R</option>,
6371 and <option>-S</option> options).
6372 </para>
6373 <para>
6374 <indexterm role="concept">
6375 <primary>queue runner</primary>
6376 <secondary>description of operation</secondary>
6377 </indexterm>
6378 The <option>-q</option> option starts one queue runner process. This scans the queue of
6379 waiting messages, and runs a delivery process for each one in turn. It waits
6380 for each delivery process to finish before starting the next one. A delivery
6381 process may not actually do any deliveries if the retry times for the addresses
6382 have not been reached. Use <option>-qf</option> (see below) if you want to override this.
6383 </para>
6384 <para>
6385 If
6386 <indexterm role="concept">
6387 <primary>SMTP</primary>
6388 <secondary>passed connection</secondary>
6389 </indexterm>
6390 <indexterm role="concept">
6391 <primary>SMTP</primary>
6392 <secondary>multiple deliveries</secondary>
6393 </indexterm>
6394 <indexterm role="concept">
6395 <primary>multiple SMTP deliveries</primary>
6396 </indexterm>
6397 the delivery process spawns other processes to deliver other messages down
6398 passed SMTP connections, the queue runner waits for these to finish before
6399 proceeding.
6400 </para>
6401 <para>
6402 When all the queued messages have been considered, the original queue runner
6403 process terminates. In other words, a single pass is made over the waiting
6404 mail, one message at a time. Use <option>-q</option> with a time (see below) if you want
6405 this to be repeated periodically.
6406 </para>
6407 <para>
6408 Exim processes the waiting messages in an unpredictable order. It isn&#x2019;t very
6409 random, but it is likely to be different each time, which is all that matters.
6410 If one particular message screws up a remote MTA, other messages to the same
6411 MTA have a chance of getting through if they get tried first.
6412 </para>
6413 <para>
6414 It is possible to cause the messages to be processed in lexical message id
6415 order, which is essentially the order in which they arrived, by setting the
6416 <option>queue_run_in_order</option> option, but this is not recommended for normal use.
6417 </para>
6418 </listitem></varlistentry>
6419 <varlistentry>
6420 <term><option>-q</option>&lt;<emphasis>qflags</emphasis>&gt;</term>
6421 <listitem>
6422 <para>
6423 The <option>-q</option> option may be followed by one or more flag letters that change its
6424 behaviour. They are all optional, but if more than one is present, they must
6425 appear in the correct order. Each flag is described in a separate item below.
6426 </para>
6427 </listitem></varlistentry>
6428 <varlistentry>
6429 <term><option>-qq...</option></term>
6430 <listitem>
6431 <para>
6432 <indexterm role="option">
6433 <primary><option>-qq</option></primary>
6434 </indexterm>
6435 <indexterm role="concept">
6436 <primary>queue</primary>
6437 <secondary>double scanning</secondary>
6438 </indexterm>
6439 <indexterm role="concept">
6440 <primary>queue</primary>
6441 <secondary>routing</secondary>
6442 </indexterm>
6443 <indexterm role="concept">
6444 <primary>routing</primary>
6445 <secondary>whole queue before delivery</secondary>
6446 </indexterm>
6447 An option starting with <option>-qq</option> requests a two-stage queue run. In the first
6448 stage, the queue is scanned as if the <option>queue_smtp_domains</option> option matched
6449 every domain. Addresses are routed, local deliveries happen, but no remote
6450 transports are run.
6451 </para>
6452 <para>
6453 <indexterm role="concept">
6454 <primary>hints database</primary>
6455 <secondary>remembering routing</secondary>
6456 </indexterm>
6457 The hints database that remembers which messages are waiting for specific hosts
6458 is updated, as if delivery to those hosts had been deferred. After this is
6459 complete, a second, normal queue scan happens, with routing and delivery taking
6460 place as normal. Messages that are routed to the same host should mostly be
6461 delivered down a single SMTP
6462 <indexterm role="concept">
6463 <primary>SMTP</primary>
6464 <secondary>passed connection</secondary>
6465 </indexterm>
6466 <indexterm role="concept">
6467 <primary>SMTP</primary>
6468 <secondary>multiple deliveries</secondary>
6469 </indexterm>
6470 <indexterm role="concept">
6471 <primary>multiple SMTP deliveries</primary>
6472 </indexterm>
6473 connection because of the hints that were set up during the first queue scan.
6474 This option may be useful for hosts that are connected to the Internet
6475 intermittently.
6476 </para>
6477 </listitem></varlistentry>
6478 <varlistentry>
6479 <term><option>-q[q]i...</option></term>
6480 <listitem>
6481 <para>
6482 <indexterm role="option">
6483 <primary><option>-qi</option></primary>
6484 </indexterm>
6485 <indexterm role="concept">
6486 <primary>queue</primary>
6487 <secondary>initial delivery</secondary>
6488 </indexterm>
6489 If the <emphasis>i</emphasis> flag is present, the queue runner runs delivery processes only for
6490 those messages that haven&#x2019;t previously been tried. (<emphasis>i</emphasis> stands for <quote>initial
6491 delivery</quote>.) This can be helpful if you are putting messages on the queue using
6492 <option>-odq</option> and want a queue runner just to process the new messages.
6493 </para>
6494 </listitem></varlistentry>
6495 <varlistentry>
6496 <term><option>-q[q][i]f...</option></term>
6497 <listitem>
6498 <para>
6499 <indexterm role="option">
6500 <primary><option>-qf</option></primary>
6501 </indexterm>
6502 <indexterm role="concept">
6503 <primary>queue</primary>
6504 <secondary>forcing delivery</secondary>
6505 </indexterm>
6506 <indexterm role="concept">
6507 <primary>delivery</primary>
6508 <secondary>forcing in queue run</secondary>
6509 </indexterm>
6510 If one <emphasis>f</emphasis> flag is present, a delivery attempt is forced for each non-frozen
6511 message, whereas without <emphasis>f</emphasis> only those non-frozen addresses that have passed
6512 their retry times are tried.
6513 </para>
6514 </listitem></varlistentry>
6515 <varlistentry>
6516 <term><option>-q[q][i]ff...</option></term>
6517 <listitem>
6518 <para>
6519 <indexterm role="option">
6520 <primary><option>-qff</option></primary>
6521 </indexterm>
6522 <indexterm role="concept">
6523 <primary>frozen messages</primary>
6524 <secondary>forcing delivery</secondary>
6525 </indexterm>
6526 If <emphasis>ff</emphasis> is present, a delivery attempt is forced for every message, whether
6527 frozen or not.
6528 </para>
6529 </listitem></varlistentry>
6530 <varlistentry>
6531 <term><option>-q[q][i][f[f]]l</option></term>
6532 <listitem>
6533 <para>
6534 <indexterm role="option">
6535 <primary><option>-ql</option></primary>
6536 </indexterm>
6537 <indexterm role="concept">
6538 <primary>queue</primary>
6539 <secondary>local deliveries only</secondary>
6540 </indexterm>
6541 The <emphasis>l</emphasis> (the letter <quote>ell</quote>) flag specifies that only local deliveries are to
6542 be done. If a message requires any remote deliveries, it remains on the queue
6543 for later delivery.
6544 </para>
6545 </listitem></varlistentry>
6546 <varlistentry>
6547 <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>
6548 <listitem>
6549 <para>
6550 <indexterm role="concept">
6551 <primary>queue</primary>
6552 <secondary>delivering specific messages</secondary>
6553 </indexterm>
6554 When scanning the queue, Exim can be made to skip over messages whose ids are
6555 lexically less than a given value by following the <option>-q</option> option with a
6556 starting message id. For example:
6557 </para>
6558 <literallayout class="monospaced">
6559 exim -q 0t5C6f-0000c8-00
6560 </literallayout>
6561 <para>
6562 Messages that arrived earlier than <literal>0t5C6f-0000c8-00</literal> are not inspected. If a
6563 second message id is given, messages whose ids are lexically greater than it
6564 are also skipped. If the same id is given twice, for example,
6565 </para>
6566 <literallayout class="monospaced">
6567 exim -q 0t5C6f-0000c8-00 0t5C6f-0000c8-00
6568 </literallayout>
6569 <para>
6570 just one delivery process is started, for that message. This differs from
6571 <option>-M</option> in that retry data is respected, and it also differs from <option>-Mc</option> in
6572 that it counts as a delivery from a queue run. Note that the selection
6573 mechanism does not affect the order in which the messages are scanned. There
6574 are also other ways of selecting specific sets of messages for delivery in a
6575 queue run &ndash; see <option>-R</option> and <option>-S</option>.
6576 </para>
6577 </listitem></varlistentry>
6578 <varlistentry>
6579 <term><option>-q</option>&lt;<emphasis>qflags</emphasis>&gt;&lt;<emphasis>time</emphasis>&gt;</term>
6580 <listitem>
6581 <para>
6582 <indexterm role="concept">
6583 <primary>queue runner</primary>
6584 <secondary>starting periodically</secondary>
6585 </indexterm>
6586 <indexterm role="concept">
6587 <primary>periodic queue running</primary>
6588 </indexterm>
6589 When a time value is present, the <option>-q</option> option causes Exim to run as a daemon,
6590 starting a queue runner process at intervals specified by the given time value
6591 (whose format is described in section <xref linkend="SECTtimeformat"/>). This form of the
6592 <option>-q</option> option is commonly combined with the <option>-bd</option> option, in which case a
6593 single daemon process handles both functions. A common way of starting up a
6594 combined daemon at system boot time is to use a command such as
6595 </para>
6596 <literallayout class="monospaced">
6597 /usr/exim/bin/exim -bd -q30m
6598 </literallayout>
6599 <para>
6600 Such a daemon listens for incoming SMTP calls, and also starts a queue runner
6601 process every 30 minutes.
6602 </para>
6603 <para>
6604 When a daemon is started by <option>-q</option> with a time value, but without <option>-bd</option>, no
6605 pid file is written unless one is explicitly requested by the <option>-oP</option> option.
6606 </para>
6607 </listitem></varlistentry>
6608 <varlistentry>
6609 <term><option>-qR</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
6610 <listitem>
6611 <para>
6612 <indexterm role="option">
6613 <primary><option>-qR</option></primary>
6614 </indexterm>
6615 This option is synonymous with <option>-R</option>. It is provided for Sendmail
6616 compatibility.
6617 </para>
6618 </listitem></varlistentry>
6619 <varlistentry>
6620 <term><option>-qS</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
6621 <listitem>
6622 <para>
6623 <indexterm role="option">
6624 <primary><option>-qS</option></primary>
6625 </indexterm>
6626 This option is synonymous with <option>-S</option>.
6627 </para>
6628 </listitem></varlistentry>
6629 <varlistentry>
6630 <term><option>-R</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
6631 <listitem>
6632 <para>
6633 <indexterm role="option">
6634 <primary><option>-R</option></primary>
6635 </indexterm>
6636 <indexterm role="concept">
6637 <primary>queue runner</primary>
6638 <secondary>for specific recipients</secondary>
6639 </indexterm>
6640 <indexterm role="concept">
6641 <primary>delivery</primary>
6642 <secondary>to given domain</secondary>
6643 </indexterm>
6644 <indexterm role="concept">
6645 <primary>domain</primary>
6646 <secondary>delivery to</secondary>
6647 </indexterm>
6648 The &lt;<emphasis>rsflags</emphasis>&gt; may be empty, in which case the white space before the string
6649 is optional, unless the string is <emphasis>f</emphasis>, <emphasis>ff</emphasis>, <emphasis>r</emphasis>, <emphasis>rf</emphasis>, or <emphasis>rff</emphasis>,
6650 which are the possible values for &lt;<emphasis>rsflags</emphasis>&gt;. White space is required if
6651 &lt;<emphasis>rsflags</emphasis>&gt; is not empty.
6652 </para>
6653 <para>
6654 This option is similar to <option>-q</option> with no time value, that is, it causes Exim to
6655 perform a single queue run, except that, when scanning the messages on the
6656 queue, Exim processes only those that have at least one undelivered recipient
6657 address containing the given string, which is checked in a case-independent
6658 way. If the &lt;<emphasis>rsflags</emphasis>&gt; start with <emphasis>r</emphasis>, &lt;<emphasis>string</emphasis>&gt; is interpreted as a
6659 regular expression; otherwise it is a literal string.
6660 </para>
6661 <para>
6662 If you want to do periodic queue runs for messages with specific recipients,
6663 you can combine <option>-R</option> with <option>-q</option> and a time value. For example:
6664 </para>
6665 <literallayout class="monospaced">
6666 exim -q25m -R @special.domain.example
6667 </literallayout>
6668 <para>
6669 This example does a queue run for messages with recipients in the given domain
6670 every 25 minutes. Any additional flags that are specified with <option>-q</option> are
6671 applied to each queue run.
6672 </para>
6673 <para>
6674 Once a message is selected for delivery by this mechanism, all its addresses
6675 are processed. For the first selected message, Exim overrides any retry
6676 information and forces a delivery attempt for each undelivered address. This
6677 means that if delivery of any address in the first message is successful, any
6678 existing retry information is deleted, and so delivery attempts for that
6679 address in subsequently selected messages (which are processed without forcing)
6680 will run. However, if delivery of any address does not succeed, the retry
6681 information is updated, and in subsequently selected messages, the failing
6682 address will be skipped.
6683 </para>
6684 <para>
6685 <indexterm role="concept">
6686 <primary>frozen messages</primary>
6687 <secondary>forcing delivery</secondary>
6688 </indexterm>
6689 If the &lt;<emphasis>rsflags</emphasis>&gt; contain <emphasis>f</emphasis> or <emphasis>ff</emphasis>, the delivery forcing applies to
6690 all selected messages, not just the first; frozen messages are included when
6691 <emphasis>ff</emphasis> is present.
6692 </para>
6693 <para>
6694 The <option>-R</option> option makes it straightforward to initiate delivery of all messages
6695 to a given domain after a host has been down for some time. When the SMTP
6696 command ETRN is accepted by its ACL (see chapter <xref linkend="CHAPACL"/>), its default
6697 effect is to run Exim with the <option>-R</option> option, but it can be configured to run
6698 an arbitrary command instead.
6699 </para>
6700 </listitem></varlistentry>
6701 <varlistentry>
6702 <term><option>-r</option></term>
6703 <listitem>
6704 <para>
6705 <indexterm role="option">
6706 <primary><option>-r</option></primary>
6707 </indexterm>
6708 This is a documented (for Sendmail) obsolete alternative name for <option>-f</option>.
6709 </para>
6710 </listitem></varlistentry>
6711 <varlistentry>
6712 <term><option>-S</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
6713 <listitem>
6714 <para>
6715 <indexterm role="option">
6716 <primary><option>-S</option></primary>
6717 </indexterm>
6718 <indexterm role="concept">
6719 <primary>delivery</primary>
6720 <secondary>from given sender</secondary>
6721 </indexterm>
6722 <indexterm role="concept">
6723 <primary>queue runner</primary>
6724 <secondary>for specific senders</secondary>
6725 </indexterm>
6726 This option acts like <option>-R</option> except that it checks the string against each
6727 message&#x2019;s sender instead of against the recipients. If <option>-R</option> is also set, both
6728 conditions must be met for a message to be selected. If either of the options
6729 has <emphasis>f</emphasis> or <emphasis>ff</emphasis> in its flags, the associated action is taken.
6730 </para>
6731 </listitem></varlistentry>
6732 <varlistentry>
6733 <term><option>-Tqt</option>&nbsp;&lt;<emphasis>times</emphasis>&gt;</term>
6734 <listitem>
6735 <para>
6736 <indexterm role="option">
6737 <primary><option>-Tqt</option></primary>
6738 </indexterm>
6739 This an option that is exclusively for use by the Exim testing suite. It is not
6740 recognized when Exim is run normally. It allows for the setting up of explicit
6741 <quote>queue times</quote> so that various warning/retry features can be tested.
6742 </para>
6743 </listitem></varlistentry>
6744 <varlistentry>
6745 <term><option>-t</option></term>
6746 <listitem>
6747 <para>
6748 <indexterm role="option">
6749 <primary><option>-t</option></primary>
6750 </indexterm>
6751 <indexterm role="concept">
6752 <primary>recipient</primary>
6753 <secondary>extracting from header lines</secondary>
6754 </indexterm>
6755 <indexterm role="concept">
6756 <primary><emphasis>Bcc:</emphasis> header line</primary>
6757 </indexterm>
6758 <indexterm role="concept">
6759 <primary><emphasis>Cc:</emphasis> header line</primary>
6760 </indexterm>
6761 <indexterm role="concept">
6762 <primary><emphasis>To:</emphasis> header line</primary>
6763 </indexterm>
6764 When Exim is receiving a locally-generated, non-SMTP message on its standard
6765 input, the <option>-t</option> option causes the recipients of the message to be obtained
6766 from the <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>, and <emphasis>Bcc:</emphasis> header lines in the message instead of
6767 from the command arguments. The addresses are extracted before any rewriting
6768 takes place and the <emphasis>Bcc:</emphasis> header line, if present, is then removed.
6769 </para>
6770 <para>
6771 <indexterm role="concept">
6772 <primary>Sendmail compatibility</primary>
6773 <secondary><option>-t</option> option</secondary>
6774 </indexterm>
6775 If the command has any arguments, they specify addresses to which the message
6776 is <emphasis>not</emphasis> to be delivered. That is, the argument addresses are removed from
6777 the recipients list obtained from the headers. This is compatible with Smail 3
6778 and in accordance with the documented behaviour of several versions of
6779 Sendmail, as described in man pages on a number of operating systems (e.g.
6780 Solaris 8, IRIX 6.5, HP-UX 11). However, some versions of Sendmail <emphasis>add</emphasis>
6781 argument addresses to those obtained from the headers, and the O&#x2019;Reilly
6782 Sendmail book documents it that way. Exim can be made to add argument addresses
6783 instead of subtracting them by setting the option
6784 <option>extract_addresses_remove_arguments</option> false.
6785 </para>
6786 <para>
6787 <indexterm role="concept">
6788 <primary><option>Resent-</option> header lines</primary>
6789 <secondary>with <option>-t</option></secondary>
6790 </indexterm>
6791 If there are any <option>Resent-</option> header lines in the message, Exim extracts
6792 recipients from all <emphasis>Resent-To:</emphasis>, <emphasis>Resent-Cc:</emphasis>, and <emphasis>Resent-Bcc:</emphasis> header
6793 lines instead of from <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>, and <emphasis>Bcc:</emphasis>. This is for compatibility
6794 with Sendmail and other MTAs. (Prior to release 4.20, Exim gave an error if
6795 <option>-t</option> was used in conjunction with <option>Resent-</option> header lines.)
6796 </para>
6797 <para>
6798 RFC 2822 talks about different sets of <option>Resent-</option> header lines (for when a
6799 message is resent several times). The RFC also specifies that they should be
6800 added at the front of the message, and separated by <emphasis>Received:</emphasis> lines. It is
6801 not at all clear how <option>-t</option> should operate in the present of multiple sets,
6802 nor indeed exactly what constitutes a <quote>set</quote>.
6803 In practice, it seems that MUAs do not follow the RFC. The <option>Resent-</option> lines
6804 are often added at the end of the header, and if a message is resent more than
6805 once, it is common for the original set of <option>Resent-</option> headers to be renamed as
6806 <option>X-Resent-</option> when a new set is added. This removes any possible ambiguity.
6807 </para>
6808 </listitem></varlistentry>
6809 <varlistentry>
6810 <term><option>-ti</option></term>
6811 <listitem>
6812 <para>
6813 <indexterm role="option">
6814 <primary><option>-ti</option></primary>
6815 </indexterm>
6816 This option is exactly equivalent to <option>-t</option> <option>-i</option>. It is provided for
6817 compatibility with Sendmail.
6818 </para>
6819 </listitem></varlistentry>
6820 <varlistentry>
6821 <term><option>-tls-on-connect</option></term>
6822 <listitem>
6823 <para>
6824 <indexterm role="option">
6825 <primary><option>-tls-on-connect</option></primary>
6826 </indexterm>
6827 <indexterm role="concept">
6828 <primary>TLS</primary>
6829 <secondary>use without STARTTLS</secondary>
6830 </indexterm>
6831 <indexterm role="concept">
6832 <primary>TLS</primary>
6833 <secondary>automatic start</secondary>
6834 </indexterm>
6835 This option is available when Exim is compiled with TLS support. It forces all
6836 incoming SMTP connections to behave as if the incoming port is listed in the
6837 <option>tls_on_connect_ports</option> option. See section <xref linkend="SECTsupobssmt"/> and chapter
6838 <xref linkend="CHAPTLS"/> for further details.
6839 </para>
6840 </listitem></varlistentry>
6841 <varlistentry>
6842 <term><option>-U</option></term>
6843 <listitem>
6844 <para>
6845 <indexterm role="option">
6846 <primary><option>-U</option></primary>
6847 </indexterm>
6848 <indexterm role="concept">
6849 <primary>Sendmail compatibility</primary>
6850 <secondary><option>-U</option> option ignored</secondary>
6851 </indexterm>
6852 Sendmail uses this option for <quote>initial message submission</quote>, and its
6853 documentation states that in future releases, it may complain about
6854 syntactically invalid messages rather than fixing them when this flag is not
6855 set. Exim ignores this option.
6856 </para>
6857 </listitem></varlistentry>
6858 <varlistentry>
6859 <term><option>-v</option></term>
6860 <listitem>
6861 <para>
6862 <indexterm role="option">
6863 <primary><option>-v</option></primary>
6864 </indexterm>
6865 This option causes Exim to write information to the standard error stream,
6866 describing what it is doing. In particular, it shows the log lines for
6867 receiving and delivering a message, and if an SMTP connection is made, the SMTP
6868 dialogue is shown. Some of the log lines shown may not actually be written to
6869 the log if the setting of <option>log_selector</option> discards them. Any relevant
6870 selectors are shown with each log line. If none are shown, the logging is
6871 unconditional.
6872 </para>
6873 </listitem></varlistentry>
6874 <varlistentry>
6875 <term><option>-x</option></term>
6876 <listitem>
6877 <para>
6878 <indexterm role="option">
6879 <primary><option>-x</option></primary>
6880 </indexterm>
6881 AIX uses <option>-x</option> for a private purpose (<quote>mail from a local mail program has
6882 National Language Support extended characters in the body of the mail item</quote>).
6883 It sets <option>-x</option> when calling the MTA from its <option>mail</option> command. Exim ignores
6884 this option.
6885 </para>
6886 </listitem></varlistentry>
6887 </variablelist>
6888 <para>
6889 <indexterm role="concept" startref="IIDclo1" class="endofrange"/>
6890 <indexterm role="concept" startref="IIDclo2" class="endofrange"/>
6891 </para>
6892 <!-- === End of command line options === -->
6893 </section>
6894 </chapter>
6895
6896 <chapter id="CHAPconf">
6897 <title>The Exim run time configuration file</title>
6898 <titleabbrev>The runtime configuration file</titleabbrev>
6899 <para>
6900 <indexterm role="concept">
6901 <primary>run time configuration</primary>
6902 </indexterm>
6903 <indexterm role="concept">
6904 <primary>configuration file</primary>
6905 <secondary>general description</secondary>
6906 </indexterm>
6907 <indexterm role="concept">
6908 <primary>CONFIGURE_FILE</primary>
6909 </indexterm>
6910 <indexterm role="concept">
6911 <primary>configuration file</primary>
6912 <secondary>errors in</secondary>
6913 </indexterm>
6914 <indexterm role="concept">
6915 <primary>error</primary>
6916 <secondary>in configuration file</secondary>
6917 </indexterm>
6918 <indexterm role="concept">
6919 <primary>return code</primary>
6920 <secondary>for bad configuration</secondary>
6921 </indexterm>
6922 Exim uses a single run time configuration file that is read whenever an Exim
6923 binary is executed. Note that in normal operation, this happens frequently,
6924 because Exim is designed to operate in a distributed manner, without central
6925 control.
6926 </para>
6927 <para>
6928 If a syntax error is detected while reading the configuration file, Exim
6929 writes a message on the standard error, and exits with a non-zero return code.
6930 The message is also written to the panic log. <emphasis role="bold">Note</emphasis>: Only simple syntax
6931 errors can be detected at this time. The values of any expanded options are
6932 not checked until the expansion happens, even when the expansion does not
6933 actually alter the string.
6934 </para>
6935 <para>
6936 The name of the configuration file is compiled into the binary for security
6937 reasons, and is specified by the CONFIGURE_FILE compilation option. In
6938 most configurations, this specifies a single file. However, it is permitted to
6939 give a colon-separated list of file names, in which case Exim uses the first
6940 existing file in the list.
6941 </para>
6942 <para revisionflag="changed">
6943 <indexterm role="concept">
6944 <primary>EXIM_USER</primary>
6945 </indexterm>
6946 <indexterm role="concept">
6947 <primary>EXIM_GROUP</primary>
6948 </indexterm>
6949 <indexterm role="concept">
6950 <primary>CONFIGURE_OWNER</primary>
6951 </indexterm>
6952 <indexterm role="concept">
6953 <primary>CONFIGURE_GROUP</primary>
6954 </indexterm>
6955 <indexterm role="concept">
6956 <primary>configuration file</primary>
6957 <secondary>ownership</secondary>
6958 </indexterm>
6959 <indexterm role="concept">
6960 <primary>ownership</primary>
6961 <secondary>configuration file</secondary>
6962 </indexterm>
6963 The run time configuration file must be owned by root or by the user that is
6964 specified at compile time by the CONFIGURE_OWNER option (if set). The
6965 configuration file must not be world-writeable, or group-writeable unless its
6966 group is the root group or the one specified at compile time by the
6967 CONFIGURE_GROUP option.
6968 </para>
6969 <para revisionflag="changed">
6970 <emphasis role="bold">Warning</emphasis>: In a conventional configuration, where the Exim binary is setuid
6971 to root, anybody who is able to edit the run time configuration file has an
6972 easy way to run commands as root. If you specify a user or group in the
6973 CONFIGURE_OWNER or CONFIGURE_GROUP options, then that user and/or any users
6974 who are members of that group will trivially be able to obtain root privileges.
6975 </para>
6976 <para revisionflag="changed">
6977 Up to Exim version 4.72, the run time configuration file was also permitted to
6978 be writeable by the Exim user and/or group. That has been changed in Exim 4.73
6979 since it offered a simple privilege escalation for any attacker who managed to
6980 compromise the Exim user account.
6981 </para>
6982 <para revisionflag="changed">
6983 A default configuration file, which will work correctly in simple situations,
6984 is provided in the file <filename>src/configure.default</filename>. If CONFIGURE_FILE
6985 defines just one file name, the installation process copies the default
6986 configuration to a new file of that name if it did not previously exist. If
6987 CONFIGURE_FILE is a list, no default is automatically installed. Chapter
6988 <xref linkend="CHAPdefconfil"/> is a <quote>walk-through</quote> discussion of the default
6989 configuration.
6990 </para>
6991 <section id="SECID40">
6992 <title>Using a different configuration file</title>
6993 <para>
6994 <indexterm role="concept">
6995 <primary>configuration file</primary>
6996 <secondary>alternate</secondary>
6997 </indexterm>
6998 A one-off alternate configuration can be specified by the <option>-C</option> command line
6999 option, which may specify a single file or a list of files. However, when
7000 <option>-C</option> is used, Exim gives up its root privilege, unless called by root (or
7001 unless the argument for <option>-C</option> is identical to the built-in value from
7002 CONFIGURE_FILE), or is listed in the TRUSTED_CONFIG_LIST file and the caller
7003 is the Exim user or the user specified in the CONFIGURE_OWNER setting. <option>-C</option>
7004 is useful mainly for checking the syntax of configuration files before
7005 installing them. No owner or group checks are done on a configuration file
7006 specified by <option>-C</option>, if root privilege has been dropped.
7007 </para>
7008 <para>
7009 Even the Exim user is not trusted to specify an arbitrary configuration file
7010 with the <option>-C</option> option to be used with root privileges, unless that file is
7011 listed in the TRUSTED_CONFIG_LIST file. This locks out the possibility of
7012 testing a configuration using <option>-C</option> right through message reception and
7013 delivery, even if the caller is root. The reception works, but by that time,
7014 Exim is running as the Exim user, so when it re-execs to regain privilege for
7015 the delivery, the use of <option>-C</option> causes privilege to be lost. However, root
7016 can test reception and delivery using two separate commands (one to put a
7017 message on the queue, using <option>-odq</option>, and another to do the delivery, using
7018 <option>-M</option>).
7019 </para>
7020 <para>
7021 If ALT_CONFIG_PREFIX is defined <filename>in Local/Makefile</filename>, it specifies a
7022 prefix string with which any file named in a <option>-C</option> command line option must
7023 start. In addition, the file name must not contain the sequence <quote><literal>/../</literal></quote>.
7024 There is no default setting for ALT_CONFIG_PREFIX; when it is unset, any file
7025 name can be used with <option>-C</option>.
7026 </para>
7027 <para>
7028 One-off changes to a configuration can be specified by the <option>-D</option> command line
7029 option, which defines and overrides values for macros used inside the
7030 configuration file. However, like <option>-C</option>, the use of this option by a
7031 non-privileged user causes Exim to discard its root privilege.
7032 If DISABLE_D_OPTION is defined in <filename>Local/Makefile</filename>, the use of <option>-D</option> is
7033 completely disabled, and its use causes an immediate error exit.
7034 </para>
7035 <para revisionflag="changed">
7036 The WHITELIST_D_MACROS option in <filename>Local/Makefile</filename> permits the binary builder
7037 to declare certain macro names trusted, such that root privilege will not
7038 necessarily be discarded.
7039 WHITELIST_D_MACROS defines a colon-separated list of macros which are
7040 considered safe and, if <option>-D</option> only supplies macros from this list, and the
7041 values are acceptable, then Exim will not give up root privilege if the caller
7042 is root, the Exim run-time user, or the CONFIGURE_OWNER, if set.  This is a
7043 transition mechanism and is expected to be removed in the future.  Acceptable
7044 values for the macros satisfy the regexp: <literal>^[A-Za-z0-9_/.-]*$</literal>
7045 </para>
7046 <para>
7047 Some sites may wish to use the same Exim binary on different machines that
7048 share a file system, but to use different configuration files on each machine.
7049 If CONFIGURE_FILE_USE_NODE is defined in <filename>Local/Makefile</filename>, Exim first
7050 looks for a file whose name is the configuration file name followed by a dot
7051 and the machine&#x2019;s node name, as obtained from the <function>uname()</function> function. If this
7052 file does not exist, the standard name is tried. This processing occurs for
7053 each file name in the list given by CONFIGURE_FILE or <option>-C</option>.
7054 </para>
7055 <para>
7056 In some esoteric situations different versions of Exim may be run under
7057 different effective uids and the CONFIGURE_FILE_USE_EUID is defined to
7058 help with this. See the comments in <filename>src/EDITME</filename> for details.
7059 </para>
7060 </section>
7061 <section id="SECTconffilfor">
7062 <title>Configuration file format</title>
7063 <para>
7064 <indexterm role="concept">
7065 <primary>configuration file</primary>
7066 <secondary>format of</secondary>
7067 </indexterm>
7068 <indexterm role="concept">
7069 <primary>format</primary>
7070 <secondary>configuration file</secondary>
7071 </indexterm>
7072 Exim&#x2019;s configuration file is divided into a number of different parts. General
7073 option settings must always appear at the start of the file. The other parts
7074 are all optional, and may appear in any order. Each part other than the first
7075 is introduced by the word <quote>begin</quote> followed by the name of the part. The
7076 optional parts are:
7077 </para>
7078 <itemizedlist>
7079 <listitem>
7080 <para>
7081 <emphasis>ACL</emphasis>: Access control lists for controlling incoming SMTP mail (see chapter
7082 <xref linkend="CHAPACL"/>).
7083 </para>
7084 </listitem>
7085 <listitem>
7086 <para>
7087 <indexterm role="concept">
7088 <primary>AUTH</primary>
7089 <secondary>configuration</secondary>
7090 </indexterm>
7091 <emphasis>authenticators</emphasis>: Configuration settings for the authenticator drivers. These
7092 are concerned with the SMTP AUTH command (see chapter <xref linkend="CHAPSMTPAUTH"/>).
7093 </para>
7094 </listitem>
7095 <listitem>
7096 <para>
7097 <emphasis>routers</emphasis>: Configuration settings for the router drivers. Routers process
7098 addresses and determine how the message is to be delivered (see chapters
7099 <xref linkend="CHAProutergeneric"/>&ndash;<xref linkend="CHAPredirect"/>).
7100 </para>
7101 </listitem>
7102 <listitem>
7103 <para>
7104 <emphasis>transports</emphasis>: Configuration settings for the transport drivers. Transports
7105 define mechanisms for copying messages to destinations (see chapters
7106 <xref linkend="CHAPtransportgeneric"/>&ndash;<xref linkend="CHAPsmtptrans"/>).
7107 </para>
7108 </listitem>
7109 <listitem>
7110 <para>
7111 <emphasis>retry</emphasis>: Retry rules, for use when a message cannot be delivered immediately.
7112 If there is no retry section, or if it is empty (that is, no retry rules are
7113 defined), Exim will not retry deliveries. In this situation, temporary errors
7114 are treated the same as permanent errors. Retry rules are discussed in chapter
7115 <xref linkend="CHAPretry"/>.
7116 </para>
7117 </listitem>
7118 <listitem>
7119 <para>
7120 <emphasis>rewrite</emphasis>: Global address rewriting rules, for use when a message arrives and
7121 when new addresses are generated during delivery. Rewriting is discussed in
7122 chapter <xref linkend="CHAPrewrite"/>.
7123 </para>
7124 </listitem>
7125 <listitem>
7126 <para>
7127 <emphasis>local_scan</emphasis>: Private options for the <function>local_scan()</function> function. If you
7128 want to use this feature, you must set
7129 </para>
7130 <literallayout class="monospaced">
7131 LOCAL_SCAN_HAS_OPTIONS=yes
7132 </literallayout>
7133 <para>
7134 in <filename>Local/Makefile</filename> before building Exim. Details of the <function>local_scan()</function>
7135 facility are given in chapter <xref linkend="CHAPlocalscan"/>.
7136 </para>
7137 </listitem>
7138 </itemizedlist>
7139 <para>
7140 <indexterm role="concept">
7141 <primary>configuration file</primary>
7142 <secondary>leading white space in</secondary>
7143 </indexterm>
7144 <indexterm role="concept">
7145 <primary>configuration file</primary>
7146 <secondary>trailing white space in</secondary>
7147 </indexterm>
7148 <indexterm role="concept">
7149 <primary>white space</primary>
7150 <secondary>in configuration file</secondary>
7151 </indexterm>
7152 Leading and trailing white space in configuration lines is always ignored.
7153 </para>
7154 <para>
7155 Blank lines in the file, and lines starting with a # character (ignoring
7156 leading white space) are treated as comments and are ignored. <emphasis role="bold">Note</emphasis>: A
7157 # character other than at the beginning of a line is not treated specially,
7158 and does not introduce a comment.
7159 </para>
7160 <para>
7161 Any non-comment line can be continued by ending it with a backslash. Note that
7162 the general rule for white space means that trailing white space after the
7163 backslash and leading white space at the start of continuation
7164 lines is ignored. Comment lines beginning with # (but not empty lines) may
7165 appear in the middle of a sequence of continuation lines.
7166 </para>
7167 <para>
7168 A convenient way to create a configuration file is to start from the
7169 default, which is supplied in <filename>src/configure.default</filename>, and add, delete, or
7170 change settings as required.
7171 </para>
7172 <para>
7173 The ACLs, retry rules, and rewriting rules have their own syntax which is
7174 described in chapters <xref linkend="CHAPACL"/>, <xref linkend="CHAPretry"/>, and <xref linkend="CHAPrewrite"/>,
7175 respectively. The other parts of the configuration file have some syntactic
7176 items in common, and these are described below, from section <xref linkend="SECTcos"/>
7177 onwards. Before that, the inclusion, macro, and conditional facilities are
7178 described.
7179 </para>
7180 </section>
7181 <section id="SECID41">
7182 <title>File inclusions in the configuration file</title>
7183 <para>
7184 <indexterm role="concept">
7185 <primary>inclusions in configuration file</primary>
7186 </indexterm>
7187 <indexterm role="concept">
7188 <primary>configuration file</primary>
7189 <secondary>including other files</secondary>
7190 </indexterm>
7191 <indexterm role="concept">
7192 <primary><literal>.include</literal> in configuration file</primary>
7193 </indexterm>
7194 <indexterm role="concept">
7195 <primary><literal>.include_if_exists</literal> in configuration file</primary>
7196 </indexterm>
7197 You can include other files inside Exim&#x2019;s run time configuration file by
7198 using this syntax:
7199 </para>
7200 <literallayout>
7201 <literal>.include</literal> &lt;<emphasis>file name</emphasis>&gt;
7202 <literal>.include_if_exists</literal> &lt;<emphasis>file name</emphasis>&gt;
7203 </literallayout>
7204 <para>
7205 on a line by itself. Double quotes round the file name are optional. If you use
7206 the first form, a configuration error occurs if the file does not exist; the
7207 second form does nothing for non-existent files. In all cases, an absolute file
7208 name is required.
7209 </para>
7210 <para>
7211 Includes may be nested to any depth, but remember that Exim reads its
7212 configuration file often, so it is a good idea to keep them to a minimum.
7213 If you change the contents of an included file, you must HUP the daemon,
7214 because an included file is read only when the configuration itself is read.
7215 </para>
7216 <para>
7217 The processing of inclusions happens early, at a physical line level, so, like
7218 comment lines, an inclusion can be used in the middle of an option setting,
7219 for example:
7220 </para>
7221 <literallayout class="monospaced">
7222 hosts_lookup = a.b.c \
7223                .include /some/file
7224 </literallayout>
7225 <para>
7226 Include processing happens after macro processing (see below). Its effect is to
7227 process the lines of the included file as if they occurred inline where the
7228 inclusion appears.
7229 </para>
7230 </section>
7231 <section id="SECTmacrodefs">
7232 <title>Macros in the configuration file</title>
7233 <para>
7234 <indexterm role="concept">
7235 <primary>macro</primary>
7236 <secondary>description of</secondary>
7237 </indexterm>
7238 <indexterm role="concept">
7239 <primary>configuration file</primary>
7240 <secondary>macros</secondary>
7241 </indexterm>
7242 If a line in the main part of the configuration (that is, before the first
7243 <quote>begin</quote> line) begins with an upper case letter, it is taken as a macro
7244 definition, and must be of the form
7245 </para>
7246 <literallayout>
7247 &lt;<emphasis>name</emphasis>&gt; = &lt;<emphasis>rest of line</emphasis>&gt;
7248 </literallayout>
7249 <para>
7250 The name must consist of letters, digits, and underscores, and need not all be
7251 in upper case, though that is recommended. The rest of the line, including any
7252 continuations, is the replacement text, and has leading and trailing white
7253 space removed. Quotes are not removed. The replacement text can never end with
7254 a backslash character, but this doesn&#x2019;t seem to be a serious limitation.
7255 </para>
7256 <para>
7257 Macros may also be defined between router, transport, authenticator, or ACL
7258 definitions. They may not, however, be defined within an individual driver or
7259 ACL, or in the <option>local_scan</option>, retry, or rewrite sections of the configuration.
7260 </para>
7261 </section>
7262 <section id="SECID42">
7263 <title>Macro substitution</title>
7264 <para>
7265 Once a macro is defined, all subsequent lines in the file (and any included
7266 files) are scanned for the macro name; if there are several macros, the line is
7267 scanned for each in turn, in the order in which the macros are defined. The
7268 replacement text is not re-scanned for the current macro, though it is scanned
7269 for subsequently defined macros. For this reason, a macro name may not contain
7270 the name of a previously defined macro as a substring. You could, for example,
7271 define
7272 </para>
7273 <literallayout>
7274 <literal>ABCD_XYZ = </literal>&lt;<emphasis>something</emphasis>&gt;
7275 <literal>ABCD = </literal>&lt;<emphasis>something else</emphasis>&gt;
7276 </literallayout>
7277 <para>
7278 but putting the definitions in the opposite order would provoke a configuration
7279 error. Macro expansion is applied to individual physical lines from the file,
7280 before checking for line continuation or file inclusion (see above). If a line
7281 consists solely of a macro name, and the expansion of the macro is empty, the
7282 line is ignored. A macro at the start of a line may turn the line into a
7283 comment line or a <literal>.include</literal> line.
7284 </para>
7285 </section>
7286 <section id="SECID43">
7287 <title>Redefining macros</title>
7288 <para>
7289 Once defined, the value of a macro can be redefined later in the configuration
7290 (or in an included file). Redefinition is specified by using <emphasis>==</emphasis> instead of
7291 <emphasis>=</emphasis>. For example:
7292 </para>
7293 <literallayout class="monospaced">
7294 MAC =  initial value
7295 ...
7296 MAC == updated value
7297 </literallayout>
7298 <para>
7299 Redefinition does not alter the order in which the macros are applied to the
7300 subsequent lines of the configuration file. It is still the same order in which
7301 the macros were originally defined. All that changes is the macro&#x2019;s value.
7302 Redefinition makes it possible to accumulate values. For example:
7303 </para>
7304 <literallayout class="monospaced">
7305 MAC =  initial value
7306 ...
7307 MAC == MAC and something added
7308 </literallayout>
7309 <para>
7310 This can be helpful in situations where the configuration file is built
7311 from a number of other files.
7312 </para>
7313 </section>
7314 <section id="SECID44">
7315 <title>Overriding macro values</title>
7316 <para>
7317 The values set for macros in the configuration file can be overridden by the
7318 <option>-D</option> command line option, but Exim gives up its root privilege when <option>-D</option> is
7319 used, unless called by root or the Exim user. A definition on the command line
7320 using the <option>-D</option> option causes all definitions and redefinitions within the
7321 file to be ignored.
7322 </para>
7323 </section>
7324 <section id="SECID45">
7325 <title>Example of macro usage</title>
7326 <para>
7327 As an example of macro usage, consider a configuration where aliases are looked
7328 up in a MySQL database. It helps to keep the file less cluttered if long
7329 strings such as SQL statements are defined separately as macros, for example:
7330 </para>
7331 <literallayout class="monospaced">
7332 ALIAS_QUERY = select mailbox from user where \
7333               login='${quote_mysql:$local_part}';
7334 </literallayout>
7335 <para>
7336 This can then be used in a <command>redirect</command> router setting like this:
7337 </para>
7338 <literallayout class="monospaced">
7339 data = ${lookup mysql{ALIAS_QUERY}}
7340 </literallayout>
7341 <para>
7342 In earlier versions of Exim macros were sometimes used for domain, host, or
7343 address lists. In Exim 4 these are handled better by named lists &ndash; see
7344 section <xref linkend="SECTnamedlists"/>.
7345 </para>
7346 </section>
7347 <section id="SECID46">
7348 <title>Conditional skips in the configuration file</title>
7349 <para>
7350 <indexterm role="concept">
7351 <primary>configuration file</primary>
7352 <secondary>conditional skips</secondary>
7353 </indexterm>
7354 <indexterm role="concept">
7355 <primary><literal>.ifdef</literal></primary>
7356 </indexterm>
7357 You can use the directives <literal>.ifdef</literal>, <literal>.ifndef</literal>, <literal>.elifdef</literal>,
7358 <literal>.elifndef</literal>, <literal>.else</literal>, and <literal>.endif</literal> to dynamically include or exclude
7359 portions of the configuration file. The processing happens whenever the file is
7360 read (that is, when an Exim binary starts to run).
7361 </para>
7362 <para>
7363 The implementation is very simple. Instances of the first four directives must
7364 be followed by text that includes the names of one or macros. The condition
7365 that is tested is whether or not any macro substitution has taken place in the
7366 line. Thus:
7367 </para>
7368 <literallayout class="monospaced">
7369 .ifdef AAA
7370 message_size_limit = 50M
7371 .else
7372 message_size_limit = 100M
7373 .endif
7374 </literallayout>
7375 <para>
7376 sets a message size limit of 50M if the macro <literal>AAA</literal> is defined, and 100M
7377 otherwise. If there is more than one macro named on the line, the condition
7378 is true if any of them are defined. That is, it is an <quote>or</quote> condition. To
7379 obtain an <quote>and</quote> condition, you need to use nested <literal>.ifdef</literal>s.
7380 </para>
7381 <para>
7382 Although you can use a macro expansion to generate one of these directives,
7383 it is not very useful, because the condition <quote>there was a macro substitution
7384 in this line</quote> will always be true.
7385 </para>
7386 <para>
7387 Text following <literal>.else</literal> and <literal>.endif</literal> is ignored, and can be used as comment
7388 to clarify complicated nestings.
7389 </para>
7390 </section>
7391 <section id="SECTcos">
7392 <title>Common option syntax</title>
7393 <para>
7394 <indexterm role="concept">
7395 <primary>common option syntax</primary>
7396 </indexterm>
7397 <indexterm role="concept">
7398 <primary>syntax of common options</primary>
7399 </indexterm>
7400 <indexterm role="concept">
7401 <primary>configuration file</primary>
7402 <secondary>common option syntax</secondary>
7403 </indexterm>
7404 For the main set of options, driver options, and <function>local_scan()</function> options,
7405 each setting is on a line by itself, and starts with a name consisting of
7406 lower-case letters and underscores. Many options require a data value, and in
7407 these cases the name must be followed by an equals sign (with optional white
7408 space) and then the value. For example:
7409 </para>
7410 <literallayout class="monospaced">
7411 qualify_domain = mydomain.example.com
7412 </literallayout>
7413 <para>
7414 <indexterm role="concept">
7415 <primary>hiding configuration option values</primary>
7416 </indexterm>
7417 <indexterm role="concept">
7418 <primary>configuration options</primary>
7419 <secondary>hiding value of</secondary>
7420 </indexterm>
7421 <indexterm role="concept">
7422 <primary>options</primary>
7423 <secondary>hiding value of</secondary>
7424 </indexterm>
7425 Some option settings may contain sensitive data, for example, passwords for
7426 accessing databases. To stop non-admin users from using the <option>-bP</option> command
7427 line option to read these values, you can precede the option settings with the
7428 word <quote>hide</quote>. For example:
7429 </para>
7430 <literallayout class="monospaced">
7431 hide mysql_servers = localhost/users/admin/secret-password
7432 </literallayout>
7433 <para>
7434 For non-admin users, such options are displayed like this:
7435 </para>
7436 <literallayout class="monospaced">
7437 mysql_servers = &lt;value not displayable&gt;
7438 </literallayout>
7439 <para>
7440 If <quote>hide</quote> is used on a driver option, it hides the value of that option on
7441 all instances of the same driver.
7442 </para>
7443 <para>
7444 The following sections describe the syntax used for the different data types
7445 that are found in option settings.
7446 </para>
7447 </section>
7448 <section id="SECID47">
7449 <title>Boolean options</title>
7450 <para>
7451 <indexterm role="concept">
7452 <primary>format</primary>
7453 <secondary>boolean</secondary>
7454 </indexterm>
7455 <indexterm role="concept">
7456 <primary>boolean configuration values</primary>
7457 </indexterm>
7458 <indexterm role="option">
7459 <primary><option>no_</option><emphasis>xxx</emphasis></primary>
7460 </indexterm>
7461 <indexterm role="option">
7462 <primary><option>not_</option><emphasis>xxx</emphasis></primary>
7463 </indexterm>
7464 Options whose type is given as boolean are on/off switches. There are two
7465 different ways of specifying such options: with and without a data value. If
7466 the option name is specified on its own without data, the switch is turned on;
7467 if it is preceded by <quote>no_</quote> or <quote>not_</quote> the switch is turned off. However,
7468 boolean options may be followed by an equals sign and one of the words
7469 <quote>true</quote>, <quote>false</quote>, <quote>yes</quote>, or <quote>no</quote>, as an alternative syntax. For example,
7470 the following two settings have exactly the same effect:
7471 </para>
7472 <literallayout class="monospaced">
7473 queue_only
7474 queue_only = true
7475 </literallayout>
7476 <para>
7477 The following two lines also have the same (opposite) effect:
7478 </para>
7479 <literallayout class="monospaced">
7480 no_queue_only
7481 queue_only = false
7482 </literallayout>
7483 <para>
7484 You can use whichever syntax you prefer.
7485 </para>
7486 </section>
7487 <section id="SECID48">
7488 <title>Integer values</title>
7489 <para>
7490 <indexterm role="concept">
7491 <primary>integer configuration values</primary>
7492 </indexterm>
7493 <indexterm role="concept">
7494 <primary>format</primary>
7495 <secondary>integer</secondary>
7496 </indexterm>
7497 If an option&#x2019;s type is given as <quote>integer</quote>, the value can be given in decimal,
7498 hexadecimal, or octal. If it starts with a digit greater than zero, a decimal
7499 number is assumed. Otherwise, it is treated as an octal number unless it starts
7500 with the characters <quote>0x</quote>, in which case the remainder is interpreted as a
7501 hexadecimal number.
7502 </para>
7503 <para>
7504 If an integer value is followed by the letter K, it is multiplied by 1024; if
7505 it is followed by the letter M, it is multiplied by 1024x1024. When the values
7506 of integer option settings are output, values which are an exact multiple of
7507 1024 or 1024x1024 are sometimes, but not always, printed using the letters K
7508 and M. The printing style is independent of the actual input format that was
7509 used.
7510 </para>
7511 </section>
7512 <section id="SECID49">
7513 <title>Octal integer values</title>
7514 <para>
7515 <indexterm role="concept">
7516 <primary>integer format</primary>
7517 </indexterm>
7518 <indexterm role="concept">
7519 <primary>format</primary>
7520 <secondary>octal integer</secondary>
7521 </indexterm>
7522 If an option&#x2019;s type is given as <quote>octal integer</quote>, its value is always
7523 interpreted as an octal number, whether or not it starts with the digit zero.
7524 Such options are always output in octal.
7525 </para>
7526 </section>
7527 <section id="SECID50">
7528 <title>Fixed point numbers</title>
7529 <para>
7530 <indexterm role="concept">
7531 <primary>fixed point configuration values</primary>
7532 </indexterm>
7533 <indexterm role="concept">
7534 <primary>format</primary>
7535 <secondary>fixed point</secondary>
7536 </indexterm>
7537 If an option&#x2019;s type is given as <quote>fixed-point</quote>, its value must be a decimal
7538 integer, optionally followed by a decimal point and up to three further digits.
7539 </para>
7540 </section>
7541 <section id="SECTtimeformat">
7542 <title>Time intervals</title>
7543 <para>
7544 <indexterm role="concept">
7545 <primary>time interval</primary>
7546 <secondary>specifying in configuration</secondary>
7547 </indexterm>
7548 <indexterm role="concept">
7549 <primary>format</primary>
7550 <secondary>time interval</secondary>
7551 </indexterm>
7552 A time interval is specified as a sequence of numbers, each followed by one of
7553 the following letters, with no intervening white space:
7554 </para>
7555 <informaltable frame="none">
7556 <tgroup cols="2" colsep="0" rowsep="0">
7557 <colspec colwidth="30pt" align="left"/>
7558 <colspec colwidth="254pt" align="left"/>
7559 <tbody>
7560 <row>
7561 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>s</option></entry>
7562 <entry>seconds</entry>
7563 </row>
7564 <row>
7565 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>m</option></entry>
7566 <entry>minutes</entry>
7567 </row>
7568 <row>
7569 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>h</option></entry>
7570 <entry>hours</entry>
7571 </row>
7572 <row>
7573 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>d</option></entry>
7574 <entry>days</entry>
7575 </row>
7576 <row>
7577 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>w</option></entry>
7578 <entry>weeks</entry>
7579 </row>
7580 </tbody>
7581 </tgroup>
7582 </informaltable>
7583 <para>
7584 For example, <quote>3h50m</quote> specifies 3 hours and 50 minutes. The values of time
7585 intervals are output in the same format. Exim does not restrict the values; it
7586 is perfectly acceptable, for example, to specify <quote>90m</quote> instead of <quote>1h30m</quote>.
7587 </para>
7588 </section>
7589 <section id="SECTstrings">
7590 <title>String values</title>
7591 <para>
7592 <indexterm role="concept">
7593 <primary>string</primary>
7594 <secondary>format of configuration values</secondary>
7595 </indexterm>
7596 <indexterm role="concept">
7597 <primary>format</primary>
7598 <secondary>string</secondary>
7599 </indexterm>
7600 If an option&#x2019;s type is specified as <quote>string</quote>, the value can be specified with
7601 or without double-quotes. If it does not start with a double-quote, the value
7602 consists of the remainder of the line plus any continuation lines, starting at
7603 the first character after any leading white space, with trailing white space
7604 removed, and with no interpretation of the characters in the string. Because
7605 Exim removes comment lines (those beginning with #) at an early stage, they can
7606 appear in the middle of a multi-line string. The following two settings are
7607 therefore equivalent:
7608 </para>
7609 <literallayout class="monospaced">
7610 trusted_users = uucp:mail
7611 trusted_users = uucp:\
7612                 # This comment line is ignored
7613                 mail
7614 </literallayout>
7615 <para>
7616 <indexterm role="concept">
7617 <primary>string</primary>
7618 <secondary>quoted</secondary>
7619 </indexterm>
7620 <indexterm role="concept">
7621 <primary>escape characters in quoted strings</primary>
7622 </indexterm>
7623 If a string does start with a double-quote, it must end with a closing
7624 double-quote, and any backslash characters other than those used for line
7625 continuation are interpreted as escape characters, as follows:
7626 </para>
7627 <informaltable frame="none">
7628 <tgroup cols="2" colsep="0" rowsep="0">
7629 <colspec colwidth="100pt" align="left"/>
7630 <colspec colwidth="254pt" align="left"/>
7631 <tbody>
7632 <row>
7633 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\\</literal></entry>
7634 <entry>single backslash</entry>
7635 </row>
7636 <row>
7637 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\n</literal></entry>
7638 <entry>newline</entry>
7639 </row>
7640 <row>
7641 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\r</literal></entry>
7642 <entry>carriage return</entry>
7643 </row>
7644 <row>
7645 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\t</literal></entry>
7646 <entry>tab</entry>
7647 </row>
7648 <row>
7649 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\</literal>&lt;<emphasis>octal digits</emphasis>&gt;</entry>
7650 <entry>up to 3 octal digits specify one character</entry>
7651 </row>
7652 <row>
7653 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\x</literal>&lt;<emphasis>hex digits</emphasis>&gt;</entry>
7654 <entry>up to 2 hexadecimal digits specify one character</entry>
7655 </row>
7656 </tbody>
7657 </tgroup>
7658 </informaltable>
7659 <para>
7660 If a backslash is followed by some other character, including a double-quote
7661 character, that character replaces the pair.
7662 </para>
7663 <para>
7664 Quoting is necessary only if you want to make use of the backslash escapes to
7665 insert special characters, or if you need to specify a value with leading or
7666 trailing spaces. These cases are rare, so quoting is almost never needed in
7667 current versions of Exim. In versions of Exim before 3.14, quoting was required
7668 in order to continue lines, so you may come across older configuration files
7669 and examples that apparently quote unnecessarily.
7670 </para>
7671 </section>
7672 <section id="SECID51">
7673 <title>Expanded strings</title>
7674 <para>
7675 <indexterm role="concept">
7676 <primary>expansion</primary>
7677 <secondary>definition of</secondary>
7678 </indexterm>
7679 Some strings in the configuration file are subjected to <emphasis>string expansion</emphasis>,
7680 by which means various parts of the string may be changed according to the
7681 circumstances (see chapter <xref linkend="CHAPexpand"/>). The input syntax for such strings
7682 is as just described; in particular, the handling of backslashes in quoted
7683 strings is done as part of the input process, before expansion takes place.
7684 However, backslash is also an escape character for the expander, so any
7685 backslashes that are required for that reason must be doubled if they are
7686 within a quoted configuration string.
7687 </para>
7688 </section>
7689 <section id="SECID52">
7690 <title>User and group names</title>
7691 <para>
7692 <indexterm role="concept">
7693 <primary>user name</primary>
7694 <secondary>format of</secondary>
7695 </indexterm>
7696 <indexterm role="concept">
7697 <primary>format</primary>
7698 <secondary>user name</secondary>
7699 </indexterm>
7700 <indexterm role="concept">
7701 <primary>groups</primary>
7702 <secondary>name format</secondary>
7703 </indexterm>
7704 <indexterm role="concept">
7705 <primary>format</primary>
7706 <secondary>group name</secondary>
7707 </indexterm>
7708 User and group names are specified as strings, using the syntax described
7709 above, but the strings are interpreted specially. A user or group name must
7710 either consist entirely of digits, or be a name that can be looked up using the
7711 <function>getpwnam()</function> or <function>getgrnam()</function> function, as appropriate.
7712 </para>
7713 </section>
7714 <section id="SECTlistconstruct">
7715 <title>List construction</title>
7716 <para>
7717 <indexterm role="concept">
7718 <primary>list</primary>
7719 <secondary>syntax of in configuration</secondary>
7720 </indexterm>
7721 <indexterm role="concept">
7722 <primary>format</primary>
7723 <secondary>list item in configuration</secondary>
7724 </indexterm>
7725 <indexterm role="concept">
7726 <primary>string</primary>
7727 <secondary>list, definition of</secondary>
7728 </indexterm>
7729 The data for some configuration options is a list of items, with colon as the
7730 default separator. Many of these options are shown with type <quote>string list</quote> in
7731 the descriptions later in this document. Others are listed as <quote>domain list</quote>,
7732 <quote>host list</quote>, <quote>address list</quote>, or <quote>local part list</quote>. Syntactically, they
7733 are all the same; however, those other than <quote>string list</quote> are subject to
7734 particular kinds of interpretation, as described in chapter
7735 <xref linkend="CHAPdomhosaddlists"/>.
7736 </para>
7737 <para>
7738 In all these cases, the entire list is treated as a single string as far as the
7739 input syntax is concerned. The <option>trusted_users</option> setting in section
7740 <xref linkend="SECTstrings"/> above is an example. If a colon is actually needed in an item
7741 in a list, it must be entered as two colons. Leading and trailing white space
7742 on each item in a list is ignored. This makes it possible to include items that
7743 start with a colon, and in particular, certain forms of IPv6 address. For
7744 example, the list
7745 </para>
7746 <literallayout class="monospaced">
7747 local_interfaces = 127.0.0.1 : ::::1
7748 </literallayout>
7749 <para>
7750 contains two IP addresses, the IPv4 address 127.0.0.1 and the IPv6 address ::1.
7751 </para>
7752 <para>
7753 <emphasis role="bold">Note</emphasis>: Although leading and trailing white space is ignored in individual
7754 list items, it is not ignored when parsing the list. The space after the first
7755 colon in the example above is necessary. If it were not there, the list would
7756 be interpreted as the two items 127.0.0.1:: and 1.
7757 </para>
7758 </section>
7759 <section id="SECID53">
7760 <title>Changing list separators</title>
7761 <para>
7762 <indexterm role="concept">
7763 <primary>list separator</primary>
7764 <secondary>changing</secondary>
7765 </indexterm>
7766 <indexterm role="concept">
7767 <primary>IPv6</primary>
7768 <secondary>addresses in lists</secondary>
7769 </indexterm>
7770 Doubling colons in IPv6 addresses is an unwelcome chore, so a mechanism was
7771 introduced to allow the separator character to be changed. If a list begins
7772 with a left angle bracket, followed by any punctuation character, that
7773 character is used instead of colon as the list separator. For example, the list
7774 above can be rewritten to use a semicolon separator like this:
7775 </para>
7776 <literallayout class="monospaced">
7777 local_interfaces = &lt;; 127.0.0.1 ; ::1
7778 </literallayout>
7779 <para>
7780 This facility applies to all lists, with the exception of the list in
7781 <option>log_file_path</option>. It is recommended that the use of non-colon separators be
7782 confined to circumstances where they really are needed.
7783 </para>
7784 <para>
7785 <indexterm role="concept">
7786 <primary>list separator</primary>
7787 <secondary>newline as</secondary>
7788 </indexterm>
7789 <indexterm role="concept">
7790 <primary>newline</primary>
7791 <secondary>as list separator</secondary>
7792 </indexterm>
7793 It is also possible to use newline and other control characters (those with
7794 code values less than 32, plus DEL) as separators in lists. Such separators
7795 must be provided literally at the time the list is processed. For options that
7796 are string-expanded, you can write the separator using a normal escape
7797 sequence. This will be processed by the expander before the string is
7798 interpreted as a list. For example, if a newline-separated list of domains is
7799 generated by a lookup, you can process it directly by a line such as this:
7800 </para>
7801 <literallayout class="monospaced">
7802 domains = &lt;\n ${lookup mysql{.....}}
7803 </literallayout>
7804 <para>
7805 This avoids having to change the list separator in such data. You are unlikely
7806 to want to use a control character as a separator in an option that is not
7807 expanded, because the value is literal text. However, it can be done by giving
7808 the value in quotes. For example:
7809 </para>
7810 <literallayout class="monospaced">
7811 local_interfaces = "&lt;\n 127.0.0.1 \n ::1"
7812 </literallayout>
7813 <para>
7814 Unlike printing character separators, which can be included in list items by
7815 doubling, it is not possible to include a control character as data when it is
7816 set as the separator. Two such characters in succession are interpreted as
7817 enclosing an empty list item.
7818 </para>
7819 </section>
7820 <section id="SECTempitelis">
7821 <title>Empty items in lists</title>
7822 <para>
7823 <indexterm role="concept">
7824 <primary>list</primary>
7825 <secondary>empty item in</secondary>
7826 </indexterm>
7827 An empty item at the end of a list is always ignored. In other words, trailing
7828 separator characters are ignored. Thus, the list in
7829 </para>
7830 <literallayout class="monospaced">
7831 senders = user@domain :
7832 </literallayout>
7833 <para>
7834 contains only a single item. If you want to include an empty string as one item
7835 in a list, it must not be the last item. For example, this list contains three
7836 items, the second of which is empty:
7837 </para>
7838 <literallayout class="monospaced">
7839 senders = user1@domain : : user2@domain
7840 </literallayout>
7841 <para>
7842 <emphasis role="bold">Note</emphasis>: There must be white space between the two colons, as otherwise they
7843 are interpreted as representing a single colon data character (and the list
7844 would then contain just one item). If you want to specify a list that contains
7845 just one, empty item, you can do it as in this example:
7846 </para>
7847 <literallayout class="monospaced">
7848 senders = :
7849 </literallayout>
7850 <para>
7851 In this case, the first item is empty, and the second is discarded because it
7852 is at the end of the list.
7853 </para>
7854 </section>
7855 <section id="SECTfordricon">
7856 <title>Format of driver configurations</title>
7857 <para>
7858 <indexterm role="concept">
7859 <primary>drivers</primary>
7860 <secondary>configuration format</secondary>
7861 </indexterm>
7862 There are separate parts in the configuration for defining routers, transports,
7863 and authenticators. In each part, you are defining a number of driver
7864 instances, each with its own set of options. Each driver instance is defined by
7865 a sequence of lines like this:
7866 </para>
7867 <literallayout>
7868 &lt;<emphasis>instance name</emphasis>&gt;:
7869   &lt;<emphasis>option</emphasis>&gt;
7870   ...
7871   &lt;<emphasis>option</emphasis>&gt;
7872 </literallayout>
7873 <para>
7874 In the following example, the instance name is <command>localuser</command>, and it is
7875 followed by three options settings:
7876 </para>
7877 <literallayout class="monospaced">
7878 localuser:
7879   driver = accept
7880   check_local_user
7881   transport = local_delivery
7882 </literallayout>
7883 <para>
7884 For each driver instance, you specify which Exim code module it uses &ndash; by the
7885 setting of the <option>driver</option> option &ndash; and (optionally) some configuration
7886 settings. For example, in the case of transports, if you want a transport to
7887 deliver with SMTP you would use the <command>smtp</command> driver; if you want to deliver to
7888 a local file you would use the <command>appendfile</command> driver. Each of the drivers is
7889 described in detail in its own separate chapter later in this manual.
7890 </para>
7891 <para>
7892 You can have several routers, transports, or authenticators that are based on
7893 the same underlying driver (each must have a different instance name).
7894 </para>
7895 <para>
7896 The order in which routers are defined is important, because addresses are
7897 passed to individual routers one by one, in order. The order in which
7898 transports are defined does not matter at all. The order in which
7899 authenticators are defined is used only when Exim, as a client, is searching
7900 them to find one that matches an authentication mechanism offered by the
7901 server.
7902 </para>
7903 <para>
7904 <indexterm role="concept">
7905 <primary>generic options</primary>
7906 </indexterm>
7907 <indexterm role="concept">
7908 <primary>options</primary>
7909 <secondary>generic &ndash; definition of</secondary>
7910 </indexterm>
7911 Within a driver instance definition, there are two kinds of option: <emphasis>generic</emphasis>
7912 and <emphasis>private</emphasis>. The generic options are those that apply to all drivers of the
7913 same type (that is, all routers, all transports or all authenticators). The
7914 <option>driver</option> option is a generic option that must appear in every definition.
7915 <indexterm role="concept">
7916 <primary>private options</primary>
7917 </indexterm>
7918 The private options are special for each driver, and none need appear, because
7919 they all have default values.
7920 </para>
7921 <para>
7922 The options may appear in any order, except that the <option>driver</option> option must
7923 precede any private options, since these depend on the particular driver. For
7924 this reason, it is recommended that <option>driver</option> always be the first option.
7925 </para>
7926 <para>
7927 Driver instance names, which are used for reference in log entries and
7928 elsewhere, can be any sequence of letters, digits, and underscores (starting
7929 with a letter) and must be unique among drivers of the same type. A router and
7930 a transport (for example) can each have the same name, but no two router
7931 instances can have the same name. The name of a driver instance should not be
7932 confused with the name of the underlying driver module. For example, the
7933 configuration lines:
7934 </para>
7935 <literallayout class="monospaced">
7936 remote_smtp:
7937   driver = smtp
7938 </literallayout>
7939 <para>
7940 create an instance of the <command>smtp</command> transport driver whose name is
7941 <command>remote_smtp</command>. The same driver code can be used more than once, with
7942 different instance names and different option settings each time. A second
7943 instance of the <command>smtp</command> transport, with different options, might be defined
7944 thus:
7945 </para>
7946 <literallayout class="monospaced">
7947 special_smtp:
7948   driver = smtp
7949   port = 1234
7950   command_timeout = 10s
7951 </literallayout>
7952 <para>
7953 The names <command>remote_smtp</command> and <command>special_smtp</command> would be used to reference
7954 these transport instances from routers, and these names would appear in log
7955 lines.
7956 </para>
7957 <para>
7958 Comment lines may be present in the middle of driver specifications. The full
7959 list of option settings for any particular driver instance, including all the
7960 defaulted values, can be extracted by making use of the <option>-bP</option> command line
7961 option.
7962 </para>
7963 </section>
7964 </chapter>
7965
7966 <chapter id="CHAPdefconfil">
7967 <title>The default configuration file</title>
7968 <para>
7969 <indexterm role="concept" id="IIDconfiwal" class="startofrange">
7970 <primary>configuration file</primary>
7971 <secondary>default <quote>walk through</quote></secondary>
7972 </indexterm>
7973 <indexterm role="concept">
7974 <primary>default</primary>
7975 <secondary>configuration file <quote>walk through</quote></secondary>
7976 </indexterm>
7977 The default configuration file supplied with Exim as <filename>src/configure.default</filename>
7978 is sufficient for a host with simple mail requirements. As an introduction to
7979 the way Exim is configured, this chapter <quote>walks through</quote> the default
7980 configuration, giving brief explanations of the settings. Detailed descriptions
7981 of the options are given in subsequent chapters. The default configuration file
7982 itself contains extensive comments about ways you might want to modify the
7983 initial settings. However, note that there are many options that are not
7984 mentioned at all in the default configuration.
7985 </para>
7986 <section id="SECTdefconfmain">
7987 <title>Main configuration settings</title>
7988 <para>
7989 The main (global) configuration option settings must always come first in the
7990 file. The first thing you&#x2019;ll see in the file, after some initial comments, is
7991 the line
7992 </para>
7993 <literallayout class="monospaced">
7994 # primary_hostname =
7995 </literallayout>
7996 <para>
7997 This is a commented-out setting of the <option>primary_hostname</option> option. Exim needs
7998 to know the official, fully qualified name of your host, and this is where you
7999 can specify it. However, in most cases you do not need to set this option. When
8000 it is unset, Exim uses the <function>uname()</function> system function to obtain the host name.
8001 </para>
8002 <para>
8003 The first three non-comment configuration lines are as follows:
8004 </para>
8005 <literallayout class="monospaced">
8006 domainlist local_domains = @
8007 domainlist relay_to_domains =
8008 hostlist   relay_from_hosts = 127.0.0.1
8009 </literallayout>
8010 <para>
8011 These are not, in fact, option settings. They are definitions of two named
8012 domain lists and one named host list. Exim allows you to give names to lists of
8013 domains, hosts, and email addresses, in order to make it easier to manage the
8014 configuration file (see section <xref linkend="SECTnamedlists"/>).
8015 </para>
8016 <para>
8017 The first line defines a domain list called <emphasis>local_domains</emphasis>; this is used
8018 later in the configuration to identify domains that are to be delivered
8019 on the local host.
8020 </para>
8021 <para>
8022 <indexterm role="concept">
8023 <primary>@ in a domain list</primary>
8024 </indexterm>
8025 There is just one item in this list, the string <quote>@</quote>. This is a special form
8026 of entry which means <quote>the name of the local host</quote>. Thus, if the local host is
8027 called <emphasis>a.host.example</emphasis>, mail to <emphasis>any.user@a.host.example</emphasis> is expected to
8028 be delivered locally. Because the local host&#x2019;s name is referenced indirectly,
8029 the same configuration file can be used on different hosts.
8030 </para>
8031 <para>
8032 The second line defines a domain list called <emphasis>relay_to_domains</emphasis>, but the
8033 list itself is empty. Later in the configuration we will come to the part that
8034 controls mail relaying through the local host; it allows relaying to any
8035 domains in this list. By default, therefore, no relaying on the basis of a mail
8036 domain is permitted.
8037 </para>
8038 <para>
8039 The third line defines a host list called <emphasis>relay_from_hosts</emphasis>. This list is
8040 used later in the configuration to permit relaying from any host or IP address
8041 that matches the list. The default contains just the IP address of the IPv4
8042 loopback interface, which means that processes on the local host are able to
8043 submit mail for relaying by sending it over TCP/IP to that interface. No other
8044 hosts are permitted to submit messages for relaying.
8045 </para>
8046 <para>
8047 Just to be sure there&#x2019;s no misunderstanding: at this point in the configuration
8048 we aren&#x2019;t actually setting up any controls. We are just defining some domains
8049 and hosts that will be used in the controls that are specified later.
8050 </para>
8051 <para>
8052 The next two configuration lines are genuine option settings:
8053 </para>
8054 <literallayout class="monospaced">
8055 acl_smtp_rcpt = acl_check_rcpt
8056 acl_smtp_data = acl_check_data
8057 </literallayout>
8058 <para>
8059 These options specify <emphasis>Access Control Lists</emphasis> (ACLs) that are to be used
8060 during an incoming SMTP session for every recipient of a message (every RCPT
8061 command), and after the contents of the message have been received,
8062 respectively. The names of the lists are <emphasis>acl_check_rcpt</emphasis> and
8063 <emphasis>acl_check_data</emphasis>, and we will come to their definitions below, in the ACL
8064 section of the configuration. The RCPT ACL controls which recipients are
8065 accepted for an incoming message &ndash; if a configuration does not provide an ACL
8066 to check recipients, no SMTP mail can be accepted. The DATA ACL allows the
8067 contents of a message to be checked.
8068 </para>
8069 <para>
8070 Two commented-out option settings are next:
8071 </para>
8072 <literallayout class="monospaced">
8073 # av_scanner = clamd:/tmp/clamd
8074 # spamd_address = 127.0.0.1 783
8075 </literallayout>
8076 <para>
8077 These are example settings that can be used when Exim is compiled with the
8078 content-scanning extension. The first specifies the interface to the virus
8079 scanner, and the second specifies the interface to SpamAssassin. Further
8080 details are given in chapter <xref linkend="CHAPexiscan"/>.
8081 </para>
8082 <para>
8083 Three more commented-out option settings follow:
8084 </para>
8085 <literallayout class="monospaced">
8086 # tls_advertise_hosts = *
8087 # tls_certificate = /etc/ssl/exim.crt
8088 # tls_privatekey = /etc/ssl/exim.pem
8089 </literallayout>
8090 <para>
8091 These are example settings that can be used when Exim is compiled with
8092 support for TLS (aka SSL) as described in section <xref linkend="SECTinctlsssl"/>. The
8093 first one specifies the list of clients that are allowed to use TLS when
8094 connecting to this server; in this case the wildcard means all clients. The
8095 other options specify where Exim should find its TLS certificate and private
8096 key, which together prove the server&#x2019;s identity to any clients that connect.
8097 More details are given in chapter <xref linkend="CHAPTLS"/>.
8098 </para>
8099 <para>
8100 Another two commented-out option settings follow:
8101 </para>
8102 <literallayout class="monospaced">
8103 # daemon_smtp_ports = 25 : 465 : 587
8104 # tls_on_connect_ports = 465
8105 </literallayout>
8106 <para>
8107 <indexterm role="concept">
8108 <primary>port</primary>
8109 <secondary>465 and 587</secondary>
8110 </indexterm>
8111 <indexterm role="concept">
8112 <primary>port</primary>
8113 <secondary>for message submission</secondary>
8114 </indexterm>
8115 <indexterm role="concept">
8116 <primary>message</primary>
8117 <secondary>submission, ports for</secondary>
8118 </indexterm>
8119 <indexterm role="concept">
8120 <primary>ssmtp protocol</primary>
8121 </indexterm>
8122 <indexterm role="concept">
8123 <primary>smtps protocol</primary>
8124 </indexterm>
8125 <indexterm role="concept">
8126 <primary>SMTP</primary>
8127 <secondary>ssmtp protocol</secondary>
8128 </indexterm>
8129 <indexterm role="concept">
8130 <primary>SMTP</primary>
8131 <secondary>smtps protocol</secondary>
8132 </indexterm>
8133 These options provide better support for roaming users who wish to use this
8134 server for message submission. They are not much use unless you have turned on
8135 TLS (as described in the previous paragraph) and authentication (about which
8136 more in section <xref linkend="SECTdefconfauth"/>). The usual SMTP port 25 is often blocked
8137 on end-user networks, so RFC 4409 specifies that message submission should use
8138 port 587 instead. However some software (notably Microsoft Outlook) cannot be
8139 configured to use port 587 correctly, so these settings also enable the
8140 non-standard <quote>smtps</quote> (aka <quote>ssmtp</quote>) port 465 (see section
8141 <xref linkend="SECTsupobssmt"/>).
8142 </para>
8143 <para>
8144 Two more commented-out options settings follow:
8145 </para>
8146 <literallayout class="monospaced">
8147 # qualify_domain =
8148 # qualify_recipient =
8149 </literallayout>
8150 <para>
8151 The first of these specifies a domain that Exim uses when it constructs a
8152 complete email address from a local login name. This is often needed when Exim
8153 receives a message from a local process. If you do not set <option>qualify_domain</option>,
8154 the value of <option>primary_hostname</option> is used. If you set both of these options,
8155 you can have different qualification domains for sender and recipient
8156 addresses. If you set only the first one, its value is used in both cases.
8157 </para>
8158 <para>
8159 <indexterm role="concept">
8160 <primary>domain literal</primary>
8161 <secondary>recognizing format</secondary>
8162 </indexterm>
8163 The following line must be uncommented if you want Exim to recognize
8164 addresses of the form <emphasis>user@[10.11.12.13]</emphasis> that is, with a <quote>domain literal</quote>
8165 (an IP address within square brackets) instead of a named domain.
8166 </para>
8167 <literallayout class="monospaced">
8168 # allow_domain_literals
8169 </literallayout>
8170 <para>
8171 The RFCs still require this form, but many people think that in the modern
8172 Internet it makes little sense to permit mail to be sent to specific hosts by
8173 quoting their IP addresses. This ancient format has been used by people who
8174 try to abuse hosts by using them for unwanted relaying. However, some
8175 people believe there are circumstances (for example, messages addressed to
8176 <emphasis>postmaster</emphasis>) where domain literals are still useful.
8177 </para>
8178 <para>
8179 The next configuration line is a kind of trigger guard:
8180 </para>
8181 <literallayout class="monospaced">
8182 never_users = root
8183 </literallayout>
8184 <para>
8185 It specifies that no delivery must ever be run as the root user. The normal
8186 convention is to set up <emphasis>root</emphasis> as an alias for the system administrator. This
8187 setting is a guard against slips in the configuration.
8188 The list of users specified by <option>never_users</option> is not, however, the complete
8189 list; the build-time configuration in <filename>Local/Makefile</filename> has an option called
8190 FIXED_NEVER_USERS specifying a list that cannot be overridden. The
8191 contents of <option>never_users</option> are added to this list. By default
8192 FIXED_NEVER_USERS also specifies root.
8193 </para>
8194 <para>
8195 When a remote host connects to Exim in order to send mail, the only information
8196 Exim has about the host&#x2019;s identity is its IP address. The next configuration
8197 line,
8198 </para>
8199 <literallayout class="monospaced">
8200 host_lookup = *
8201 </literallayout>
8202 <para>
8203 specifies that Exim should do a reverse DNS lookup on all incoming connections,
8204 in order to get a host name. This improves the quality of the logging
8205 information, but if you feel it is too expensive, you can remove it entirely,
8206 or restrict the lookup to hosts on <quote>nearby</quote> networks.
8207 Note that it is not always possible to find a host name from an IP address,
8208 because not all DNS reverse zones are maintained, and sometimes DNS servers are
8209 unreachable.
8210 </para>
8211 <para>
8212 The next two lines are concerned with <emphasis>ident</emphasis> callbacks, as defined by RFC
8213 1413 (hence their names):
8214 </para>
8215 <literallayout class="monospaced">
8216 rfc1413_hosts = *
8217 rfc1413_query_timeout = 5s
8218 </literallayout>
8219 <para>
8220 These settings cause Exim to make ident callbacks for all incoming SMTP calls.
8221 You can limit the hosts to which these calls are made, or change the timeout
8222 that is used. If you set the timeout to zero, all ident calls are disabled.
8223 Although they are cheap and can provide useful information for tracing problem
8224 messages, some hosts and firewalls have problems with ident calls. This can
8225 result in a timeout instead of an immediate refused connection, leading to
8226 delays on starting up an incoming SMTP session.
8227 </para>
8228 <para>
8229 When Exim receives messages over SMTP connections, it expects all addresses to
8230 be fully qualified with a domain, as required by the SMTP definition. However,
8231 if you are running a server to which simple clients submit messages, you may
8232 find that they send unqualified addresses. The two commented-out options:
8233 </para>
8234 <literallayout class="monospaced">
8235 # sender_unqualified_hosts =
8236 # recipient_unqualified_hosts =
8237 </literallayout>
8238 <para>
8239 show how you can specify hosts that are permitted to send unqualified sender
8240 and recipient addresses, respectively.
8241 </para>
8242 <para>
8243 The <option>percent_hack_domains</option> option is also commented out:
8244 </para>
8245 <literallayout class="monospaced">
8246 # percent_hack_domains =
8247 </literallayout>
8248 <para>
8249 It provides a list of domains for which the <quote>percent hack</quote> is to operate.
8250 This is an almost obsolete form of explicit email routing. If you do not know
8251 anything about it, you can safely ignore this topic.
8252 </para>
8253 <para>
8254 The last two settings in the main part of the default configuration are
8255 concerned with messages that have been <quote>frozen</quote> on Exim&#x2019;s queue. When a
8256 message is frozen, Exim no longer continues to try to deliver it. Freezing
8257 occurs when a bounce message encounters a permanent failure because the sender
8258 address of the original message that caused the bounce is invalid, so the
8259 bounce cannot be delivered. This is probably the most common case, but there
8260 are also other conditions that cause freezing, and frozen messages are not
8261 always bounce messages.
8262 </para>
8263 <literallayout class="monospaced">
8264 ignore_bounce_errors_after = 2d
8265 timeout_frozen_after = 7d
8266 </literallayout>
8267 <para>
8268 The first of these options specifies that failing bounce messages are to be
8269 discarded after 2 days on the queue. The second specifies that any frozen
8270 message (whether a bounce message or not) is to be timed out (and discarded)
8271 after a week. In this configuration, the first setting ensures that no failing
8272 bounce message ever lasts a week.
8273 </para>
8274 </section>
8275 <section id="SECID54">
8276 <title>ACL configuration</title>
8277 <para>
8278 <indexterm role="concept">
8279 <primary>default</primary>
8280 <secondary>ACLs</secondary>
8281 </indexterm>
8282 <indexterm role="concept">
8283 <primary>access control lists (ACLs)</primary>
8284 <secondary>default configuration</secondary>
8285 </indexterm>
8286 In the default configuration, the ACL section follows the main configuration.
8287 It starts with the line
8288 </para>
8289 <literallayout class="monospaced">
8290 begin acl
8291 </literallayout>
8292 <para>
8293 and it contains the definitions of two ACLs, called <emphasis>acl_check_rcpt</emphasis> and
8294 <emphasis>acl_check_data</emphasis>, that were referenced in the settings of <option>acl_smtp_rcpt</option>
8295 and <option>acl_smtp_data</option> above.
8296 </para>
8297 <para>
8298 <indexterm role="concept">
8299 <primary>RCPT</primary>
8300 <secondary>ACL for</secondary>
8301 </indexterm>
8302 The first ACL is used for every RCPT command in an incoming SMTP message. Each
8303 RCPT command specifies one of the message&#x2019;s recipients. The ACL statements
8304 are considered in order, until the recipient address is either accepted or
8305 rejected. The RCPT command is then accepted or rejected, according to the
8306 result of the ACL processing.
8307 </para>
8308 <literallayout class="monospaced">
8309 acl_check_rcpt:
8310 </literallayout>
8311 <para>
8312 This line, consisting of a name terminated by a colon, marks the start of the
8313 ACL, and names it.
8314 </para>
8315 <literallayout class="monospaced">
8316 accept  hosts = :
8317 </literallayout>
8318 <para>
8319 This ACL statement accepts the recipient if the sending host matches the list.
8320 But what does that strange list mean? It doesn&#x2019;t actually contain any host
8321 names or IP addresses. The presence of the colon puts an empty item in the
8322 list; Exim matches this only if the incoming message did not come from a remote
8323 host, because in that case, the remote hostname is empty. The colon is
8324 important. Without it, the list itself is empty, and can never match anything.
8325 </para>
8326 <para>
8327 What this statement is doing is to accept unconditionally all recipients in
8328 messages that are submitted by SMTP from local processes using the standard
8329 input and output (that is, not using TCP/IP). A number of MUAs operate in this
8330 manner.
8331 </para>
8332 <literallayout class="monospaced">
8333 deny    message       = Restricted characters in address
8334         domains       = +local_domains
8335         local_parts   = ^[.] : ^.*[@%!/|]
8336
8337 deny    message       = Restricted characters in address
8338         domains       = !+local_domains
8339         local_parts   = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
8340 </literallayout>
8341 <para>
8342 These statements are concerned with local parts that contain any of the
8343 characters <quote>@</quote>, <quote>%</quote>, <quote>!</quote>, <quote>/</quote>, <quote>|</quote>, or dots in unusual places.
8344 Although these characters are entirely legal in local parts (in the case of
8345 <quote>@</quote> and leading dots, only if correctly quoted), they do not commonly occur
8346 in Internet mail addresses.
8347 </para>
8348 <para>
8349 The first three have in the past been associated with explicitly routed
8350 addresses (percent is still sometimes used &ndash; see the <option>percent_hack_domains</option>
8351 option). Addresses containing these characters are regularly tried by spammers
8352 in an attempt to bypass relaying restrictions, and also by open relay testing
8353 programs. Unless you really need them it is safest to reject these characters
8354 at this early stage. This configuration is heavy-handed in rejecting these
8355 characters for all messages it accepts from remote hosts. This is a deliberate
8356 policy of being as safe as possible.
8357 </para>
8358 <para>
8359 The first rule above is stricter, and is applied to messages that are addressed
8360 to one of the local domains handled by this host. This is implemented by the
8361 first condition, which restricts it to domains that are listed in the
8362 <emphasis>local_domains</emphasis> domain list. The <quote>+</quote> character is used to indicate a
8363 reference to a named list. In this configuration, there is just one domain in
8364 <emphasis>local_domains</emphasis>, but in general there may be many.
8365 </para>
8366 <para>
8367 The second condition on the first statement uses two regular expressions to
8368 block local parts that begin with a dot or contain <quote>@</quote>, <quote>%</quote>, <quote>!</quote>, <quote>/</quote>,
8369 or <quote>|</quote>. If you have local accounts that include these characters, you will
8370 have to modify this rule.
8371 </para>
8372 <para>
8373 Empty components (two dots in a row) are not valid in RFC 2822, but Exim
8374 allows them because they have been encountered in practice. (Consider the
8375 common convention of local parts constructed as
8376 <quote><emphasis>first-initial.second-initial.family-name</emphasis></quote> when applied to someone like
8377 the author of Exim, who has no second initial.) However, a local part starting
8378 with a dot or containing <quote>/../</quote> can cause trouble if it is used as part of a
8379 file name (for example, for a mailing list). This is also true for local parts
8380 that contain slashes. A pipe symbol can also be troublesome if the local part
8381 is incorporated unthinkingly into a shell command line.
8382 </para>
8383 <para>
8384 The second rule above applies to all other domains, and is less strict. This
8385 allows your own users to send outgoing messages to sites that use slashes
8386 and vertical bars in their local parts. It blocks local parts that begin
8387 with a dot, slash, or vertical bar, but allows these characters within the
8388 local part. However, the sequence <quote>/../</quote> is barred. The use of <quote>@</quote>, <quote>%</quote>,
8389 and <quote>!</quote> is blocked, as before. The motivation here is to prevent your users
8390 (or your users&#x2019; viruses) from mounting certain kinds of attack on remote sites.
8391 </para>
8392 <literallayout class="monospaced">
8393 accept  local_parts   = postmaster
8394         domains       = +local_domains
8395 </literallayout>
8396 <para>
8397 This statement, which has two conditions, accepts an incoming address if the
8398 local part is <emphasis>postmaster</emphasis> and the domain is one of those listed in the
8399 <emphasis>local_domains</emphasis> domain list. The <quote>+</quote> character is used to indicate a
8400 reference to a named list. In this configuration, there is just one domain in
8401 <emphasis>local_domains</emphasis>, but in general there may be many.
8402 </para>
8403 <para>
8404 The presence of this statement means that mail to postmaster is never blocked
8405 by any of the subsequent tests. This can be helpful while sorting out problems
8406 in cases where the subsequent tests are incorrectly denying access.
8407 </para>
8408 <literallayout class="monospaced">
8409 require verify        = sender
8410 </literallayout>
8411 <para>
8412 This statement requires the sender address to be verified before any subsequent
8413 ACL statement can be used. If verification fails, the incoming recipient
8414 address is refused. Verification consists of trying to route the address, to
8415 see if a bounce message could be delivered to it. In the case of remote
8416 addresses, basic verification checks only the domain, but <emphasis>callouts</emphasis> can be
8417 used for more verification if required. Section <xref linkend="SECTaddressverification"/>
8418 discusses the details of address verification.
8419 </para>
8420 <literallayout class="monospaced">
8421 accept  hosts         = +relay_from_hosts
8422         control       = submission
8423 </literallayout>
8424 <para>
8425 This statement accepts the address if the message is coming from one of the
8426 hosts that are defined as being allowed to relay through this host. Recipient
8427 verification is omitted here, because in many cases the clients are dumb MUAs
8428 that do not cope well with SMTP error responses. For the same reason, the
8429 second line specifies <quote>submission mode</quote> for messages that are accepted. This
8430 is described in detail in section <xref linkend="SECTsubmodnon"/>; it causes Exim to fix
8431 messages that are deficient in some way, for example, because they lack a
8432 <emphasis>Date:</emphasis> header line. If you are actually relaying out from MTAs, you should
8433 probably add recipient verification here, and disable submission mode.
8434 </para>
8435 <literallayout class="monospaced">
8436 accept  authenticated = *
8437         control       = submission
8438 </literallayout>
8439 <para>
8440 This statement accepts the address if the client host has authenticated itself.
8441 Submission mode is again specified, on the grounds that such messages are most
8442 likely to come from MUAs. The default configuration does not define any
8443 authenticators, though it does include some nearly complete commented-out
8444 examples described in <xref linkend="SECTdefconfauth"/>. This means that no client can in
8445 fact authenticate until you complete the authenticator definitions.
8446 </para>
8447 <literallayout class="monospaced">
8448 require message = relay not permitted
8449         domains = +local_domains : +relay_domains
8450 </literallayout>
8451 <para>
8452 This statement rejects the address if its domain is neither a local domain nor
8453 one of the domains for which this host is a relay.
8454 </para>
8455 <literallayout class="monospaced">
8456 require verify = recipient
8457 </literallayout>
8458 <para>
8459 This statement requires the recipient address to be verified; if verification
8460 fails, the address is rejected.
8461 </para>
8462 <literallayout class="monospaced">
8463 # deny    message     = rejected because $sender_host_address \
8464 #                       is in a black list at $dnslist_domain\n\
8465 #                       $dnslist_text
8466 #         dnslists    = black.list.example
8467 #
8468 # warn    dnslists    = black.list.example
8469 #         add_header  = X-Warning: $sender_host_address is in \
8470 #                       a black list at $dnslist_domain
8471 #         log_message = found in $dnslist_domain
8472 </literallayout>
8473 <para>
8474 These commented-out lines are examples of how you could configure Exim to check
8475 sending hosts against a DNS black list. The first statement rejects messages
8476 from blacklisted hosts, whereas the second just inserts a warning header
8477 line.
8478 </para>
8479 <literallayout class="monospaced">
8480 # require verify = csa
8481 </literallayout>
8482 <para>
8483 This commented-out line is an example of how you could turn on client SMTP
8484 authorization (CSA) checking. Such checks do DNS lookups for special SRV
8485 records.
8486 </para>
8487 <literallayout class="monospaced">
8488 accept
8489 </literallayout>
8490 <para>
8491 The final statement in the first ACL unconditionally accepts any recipient
8492 address that has successfully passed all the previous tests.
8493 </para>
8494 <literallayout class="monospaced">
8495 acl_check_data:
8496 </literallayout>
8497 <para>
8498 This line marks the start of the second ACL, and names it. Most of the contents
8499 of this ACL are commented out:
8500 </para>
8501 <literallayout class="monospaced">
8502 # deny    malware   = *
8503 #         message   = This message contains a virus \
8504 #                     ($malware_name).
8505 </literallayout>
8506 <para>
8507 These lines are examples of how to arrange for messages to be scanned for
8508 viruses when Exim has been compiled with the content-scanning extension, and a
8509 suitable virus scanner is installed. If the message is found to contain a
8510 virus, it is rejected with the given custom error message.
8511 </para>
8512 <literallayout class="monospaced">
8513 # warn    spam      = nobody
8514 #         message   = X-Spam_score: $spam_score\n\
8515 #                     X-Spam_score_int: $spam_score_int\n\
8516 #                     X-Spam_bar: $spam_bar\n\
8517 #                     X-Spam_report: $spam_report
8518 </literallayout>
8519 <para>
8520 These lines are an example of how to arrange for messages to be scanned by
8521 SpamAssassin when Exim has been compiled with the content-scanning extension,
8522 and SpamAssassin has been installed. The SpamAssassin check is run with
8523 <literal>nobody</literal> as its user parameter, and the results are added to the message as a
8524 series of extra header line. In this case, the message is not rejected,
8525 whatever the spam score.
8526 </para>
8527 <literallayout class="monospaced">
8528 accept
8529 </literallayout>
8530 <para>
8531 This final line in the DATA ACL accepts the message unconditionally.
8532 </para>
8533 </section>
8534 <section id="SECID55">
8535 <title>Router configuration</title>
8536 <para>
8537 <indexterm role="concept">
8538 <primary>default</primary>
8539 <secondary>routers</secondary>
8540 </indexterm>
8541 <indexterm role="concept">
8542 <primary>routers</primary>
8543 <secondary>default</secondary>
8544 </indexterm>
8545 The router configuration comes next in the default configuration, introduced
8546 by the line
8547 </para>
8548 <literallayout class="monospaced">
8549 begin routers
8550 </literallayout>
8551 <para>
8552 Routers are the modules in Exim that make decisions about where to send
8553 messages. An address is passed to each router in turn, until it is either
8554 accepted, or failed. This means that the order in which you define the routers
8555 matters. Each router is fully described in its own chapter later in this
8556 manual. Here we give only brief overviews.
8557 </para>
8558 <literallayout class="monospaced">
8559 # domain_literal:
8560 #   driver = ipliteral
8561 #   domains = !+local_domains
8562 #   transport = remote_smtp
8563 </literallayout>
8564 <para>
8565 <indexterm role="concept">
8566 <primary>domain literal</primary>
8567 <secondary>default router</secondary>
8568 </indexterm>
8569 This router is commented out because the majority of sites do not want to
8570 support domain literal addresses (those of the form <emphasis>user@[10.9.8.7]</emphasis>). If
8571 you uncomment this router, you also need to uncomment the setting of
8572 <option>allow_domain_literals</option> in the main part of the configuration.
8573 </para>
8574 <literallayout class="monospaced">
8575 dnslookup:
8576   driver = dnslookup
8577   domains = ! +local_domains
8578   transport = remote_smtp
8579   ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
8580   no_more
8581 </literallayout>
8582 <para>
8583 The first uncommented router handles addresses that do not involve any local
8584 domains. This is specified by the line
8585 </para>
8586 <literallayout class="monospaced">
8587 domains = ! +local_domains
8588 </literallayout>
8589 <para>
8590 The <option>domains</option> option lists the domains to which this router applies, but the
8591 exclamation mark is a negation sign, so the router is used only for domains
8592 that are not in the domain list called <emphasis>local_domains</emphasis> (which was defined at
8593 the start of the configuration). The plus sign before <emphasis>local_domains</emphasis>
8594 indicates that it is referring to a named list. Addresses in other domains are
8595 passed on to the following routers.
8596 </para>
8597 <para>
8598 The name of the router driver is <command>dnslookup</command>,
8599 and is specified by the <option>driver</option> option. Do not be confused by the fact that
8600 the name of this router instance is the same as the name of the driver. The
8601 instance name is arbitrary, but the name set in the <option>driver</option> option must be
8602 one of the driver modules that is in the Exim binary.
8603 </para>
8604 <para>
8605 The <command>dnslookup</command> router routes addresses by looking up their domains in the
8606 DNS in order to obtain a list of hosts to which the address is routed. If the
8607 router succeeds, the address is queued for the <command>remote_smtp</command> transport, as
8608 specified by the <option>transport</option> option. If the router does not find the domain
8609 in the DNS, no further routers are tried because of the <option>no_more</option> setting, so
8610 the address fails and is bounced.
8611 </para>
8612 <para>
8613 The <option>ignore_target_hosts</option> option specifies a list of IP addresses that are to
8614 be entirely ignored. This option is present because a number of cases have been
8615 encountered where MX records in the DNS point to host names
8616 whose IP addresses are 0.0.0.0 or are in the 127 subnet (typically 127.0.0.1).
8617 Completely ignoring these IP addresses causes Exim to fail to route the
8618 email address, so it bounces. Otherwise, Exim would log a routing problem, and
8619 continue to try to deliver the message periodically until the address timed
8620 out.
8621 </para>
8622 <literallayout class="monospaced">
8623 system_aliases:
8624   driver = redirect
8625   allow_fail
8626   allow_defer
8627   data = ${lookup{$local_part}lsearch{/etc/aliases}}
8628 # user = exim
8629   file_transport = address_file
8630   pipe_transport = address_pipe
8631 </literallayout>
8632 <para>
8633 Control reaches this and subsequent routers only for addresses in the local
8634 domains. This router checks to see whether the local part is defined as an
8635 alias in the <filename>/etc/aliases</filename> file, and if so, redirects it according to the
8636 data that it looks up from that file. If no data is found for the local part,
8637 the value of the <option>data</option> option is empty, causing the address to be passed to
8638 the next router.
8639 </para>
8640 <para>
8641 <filename>/etc/aliases</filename> is a conventional name for the system aliases file that is
8642 often used. That is why it is referenced by from the default configuration
8643 file. However, you can change this by setting SYSTEM_ALIASES_FILE in
8644 <filename>Local/Makefile</filename> before building Exim.
8645 </para>
8646 <literallayout class="monospaced">
8647 userforward:
8648   driver = redirect
8649   check_local_user
8650 # local_part_suffix = +* : -*
8651 # local_part_suffix_optional
8652   file = $home/.forward
8653 # allow_filter
8654   no_verify
8655   no_expn
8656   check_ancestor
8657   file_transport = address_file
8658   pipe_transport = address_pipe
8659   reply_transport = address_reply
8660 </literallayout>
8661 <para>
8662 This is the most complicated router in the default configuration. It is another
8663 redirection router, but this time it is looking for forwarding data set up by
8664 individual users. The <option>check_local_user</option> setting specifies a check that the
8665 local part of the address is the login name of a local user. If it is not, the
8666 router is skipped. The two commented options that follow <option>check_local_user</option>,
8667 namely:
8668 </para>
8669 <literallayout class="monospaced">
8670 # local_part_suffix = +* : -*
8671 # local_part_suffix_optional
8672 </literallayout>
8673 <para>
8674 <indexterm role="variable">
8675 <primary><varname>$local_part_suffix</varname></primary>
8676 </indexterm>
8677 show how you can specify the recognition of local part suffixes. If the first
8678 is uncommented, a suffix beginning with either a plus or a minus sign, followed
8679 by any sequence of characters, is removed from the local part and placed in the
8680 variable <varname>$local_part_suffix</varname>. The second suffix option specifies that the
8681 presence of a suffix in the local part is optional. When a suffix is present,
8682 the check for a local login uses the local part with the suffix removed.
8683 </para>
8684 <para>
8685 When a local user account is found, the file called <filename>.forward</filename> in the user&#x2019;s
8686 home directory is consulted. If it does not exist, or is empty, the router
8687 declines. Otherwise, the contents of <filename>.forward</filename> are interpreted as
8688 redirection data (see chapter <xref linkend="CHAPredirect"/> for more details).
8689 </para>
8690 <para>
8691 <indexterm role="concept">
8692 <primary>Sieve filter</primary>
8693 <secondary>enabling in default router</secondary>
8694 </indexterm>
8695 Traditional <filename>.forward</filename> files contain just a list of addresses, pipes, or
8696 files. Exim supports this by default. However, if <option>allow_filter</option> is set (it
8697 is commented out by default), the contents of the file are interpreted as a set
8698 of Exim or Sieve filtering instructions, provided the file begins with <quote>#Exim
8699 filter</quote> or <quote>#Sieve filter</quote>, respectively. User filtering is discussed in the
8700 separate document entitled <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis>.
8701 </para>
8702 <para>
8703 The <option>no_verify</option> and <option>no_expn</option> options mean that this router is skipped when
8704 verifying addresses, or when running as a consequence of an SMTP EXPN command.
8705 There are two reasons for doing this:
8706 </para>
8707 <orderedlist numeration="arabic">
8708 <listitem>
8709 <para>
8710 Whether or not a local user has a <filename>.forward</filename> file is not really relevant when
8711 checking an address for validity; it makes sense not to waste resources doing
8712 unnecessary work.
8713 </para>
8714 </listitem>
8715 <listitem>
8716 <para>
8717 More importantly, when Exim is verifying addresses or handling an EXPN
8718 command during an SMTP session, it is running as the Exim user, not as root.
8719 The group is the Exim group, and no additional groups are set up.
8720 It may therefore not be possible for Exim to read users&#x2019; <filename>.forward</filename> files at
8721 this time.
8722 </para>
8723 </listitem>
8724 </orderedlist>
8725 <para>
8726 The setting of <option>check_ancestor</option> prevents the router from generating a new
8727 address that is the same as any previous address that was redirected. (This
8728 works round a problem concerning a bad interaction between aliasing and
8729 forwarding &ndash; see section <xref linkend="SECTredlocmai"/>).
8730 </para>
8731 <para>
8732 The final three option settings specify the transports that are to be used when
8733 forwarding generates a direct delivery to a file, or to a pipe, or sets up an
8734 auto-reply, respectively. For example, if a <filename>.forward</filename> file contains
8735 </para>
8736 <literallayout class="monospaced">
8737 a.nother@elsewhere.example, /home/spqr/archive
8738 </literallayout>
8739 <para>
8740 the delivery to <filename>/home/spqr/archive</filename> is done by running the <option>address_file</option>
8741 transport.
8742 </para>
8743 <literallayout class="monospaced">
8744 localuser:
8745   driver = accept
8746   check_local_user
8747 # local_part_suffix = +* : -*
8748 # local_part_suffix_optional
8749   transport = local_delivery
8750 </literallayout>
8751 <para>
8752 The final router sets up delivery into local mailboxes, provided that the local
8753 part is the name of a local login, by accepting the address and assigning it to
8754 the <command>local_delivery</command> transport. Otherwise, we have reached the end of the
8755 routers, so the address is bounced. The commented suffix settings fulfil the
8756 same purpose as they do for the <command>userforward</command> router.
8757 </para>
8758 </section>
8759 <section id="SECID56">
8760 <title>Transport configuration</title>
8761 <para>
8762 <indexterm role="concept">
8763 <primary>default</primary>
8764 <secondary>transports</secondary>
8765 </indexterm>
8766 <indexterm role="concept">
8767 <primary>transports</primary>
8768 <secondary>default</secondary>
8769 </indexterm>
8770 Transports define mechanisms for actually delivering messages. They operate
8771 only when referenced from routers, so the order in which they are defined does
8772 not matter. The transports section of the configuration starts with
8773 </para>
8774 <literallayout class="monospaced">
8775 begin transports
8776 </literallayout>
8777 <para>
8778 One remote transport and four local transports are defined.
8779 </para>
8780 <literallayout class="monospaced">
8781 remote_smtp:
8782   driver = smtp
8783 </literallayout>
8784 <para>
8785 This transport is used for delivering messages over SMTP connections. All its
8786 options are defaulted. The list of remote hosts comes from the router.
8787 </para>
8788 <literallayout class="monospaced">
8789 local_delivery:
8790   driver = appendfile
8791   file = /var/mail/$local_part
8792   delivery_date_add
8793   envelope_to_add
8794   return_path_add
8795 # group = mail
8796 # mode = 0660
8797 </literallayout>
8798 <para>
8799 This <command>appendfile</command> transport is used for local delivery to user mailboxes in
8800 traditional BSD mailbox format. By default it runs under the uid and gid of the
8801 local user, which requires the sticky bit to be set on the <filename>/var/mail</filename>
8802 directory. Some systems use the alternative approach of running mail deliveries
8803 under a particular group instead of using the sticky bit. The commented options
8804 show how this can be done.
8805 </para>
8806 <para>
8807 Exim adds three headers to the message as it delivers it: <emphasis>Delivery-date:</emphasis>,
8808 <emphasis>Envelope-to:</emphasis> and <emphasis>Return-path:</emphasis>. This action is requested by the three
8809 similarly-named options above.
8810 </para>
8811 <literallayout class="monospaced">
8812 address_pipe:
8813   driver = pipe
8814   return_output
8815 </literallayout>
8816 <para>
8817 This transport is used for handling deliveries to pipes that are generated by
8818 redirection (aliasing or users&#x2019; <filename>.forward</filename> files). The <option>return_output</option>
8819 option specifies that any output generated by the pipe is to be returned to the
8820 sender.
8821 </para>
8822 <literallayout class="monospaced">
8823 address_file:
8824   driver = appendfile
8825   delivery_date_add
8826   envelope_to_add
8827   return_path_add
8828 </literallayout>
8829 <para>
8830 This transport is used for handling deliveries to files that are generated by
8831 redirection. The name of the file is not specified in this instance of
8832 <command>appendfile</command>, because it comes from the <command>redirect</command> router.
8833 </para>
8834 <literallayout class="monospaced">
8835 address_reply:
8836   driver = autoreply
8837 </literallayout>
8838 <para>
8839 This transport is used for handling automatic replies generated by users&#x2019;
8840 filter files.
8841 </para>
8842 </section>
8843 <section id="SECID57">
8844 <title>Default retry rule</title>
8845 <para>
8846 <indexterm role="concept">
8847 <primary>retry</primary>
8848 <secondary>default rule</secondary>
8849 </indexterm>
8850 <indexterm role="concept">
8851 <primary>default</primary>
8852 <secondary>retry rule</secondary>
8853 </indexterm>
8854 The retry section of the configuration file contains rules which affect the way
8855 Exim retries deliveries that cannot be completed at the first attempt. It is
8856 introduced by the line
8857 </para>
8858 <literallayout class="monospaced">
8859 begin retry
8860 </literallayout>
8861 <para>
8862 In the default configuration, there is just one rule, which applies to all
8863 errors:
8864 </para>
8865 <literallayout class="monospaced">
8866 *   *   F,2h,15m; G,16h,1h,1.5; F,4d,6h
8867 </literallayout>
8868 <para>
8869 This causes any temporarily failing address to be retried every 15 minutes for
8870 2 hours, then at intervals starting at one hour and increasing by a factor of
8871 1.5 until 16 hours have passed, then every 6 hours up to 4 days. If an address
8872 is not delivered after 4 days of temporary failure, it is bounced.
8873 </para>
8874 <para>
8875 If the retry section is removed from the configuration, or is empty (that is,
8876 if no retry rules are defined), Exim will not retry deliveries. This turns
8877 temporary errors into permanent errors.
8878 </para>
8879 </section>
8880 <section id="SECID58">
8881 <title>Rewriting configuration</title>
8882 <para>
8883 The rewriting section of the configuration, introduced by
8884 </para>
8885 <literallayout class="monospaced">
8886 begin rewrite
8887 </literallayout>
8888 <para>
8889 contains rules for rewriting addresses in messages as they arrive. There are no
8890 rewriting rules in the default configuration file.
8891 </para>
8892 </section>
8893 <section id="SECTdefconfauth">
8894 <title>Authenticators configuration</title>
8895 <para>
8896 <indexterm role="concept">
8897 <primary>AUTH</primary>
8898 <secondary>configuration</secondary>
8899 </indexterm>
8900 The authenticators section of the configuration, introduced by
8901 </para>
8902 <literallayout class="monospaced">
8903 begin authenticators
8904 </literallayout>
8905 <para>
8906 defines mechanisms for the use of the SMTP AUTH command. The default
8907 configuration file contains two commented-out example authenticators
8908 which support plaintext username/password authentication using the
8909 standard PLAIN mechanism and the traditional but non-standard LOGIN
8910 mechanism, with Exim acting as the server. PLAIN and LOGIN are enough
8911 to support most MUA software.
8912 </para>
8913 <para>
8914 The example PLAIN authenticator looks like this:
8915 </para>
8916 <literallayout class="monospaced">
8917 #PLAIN:
8918 #  driver                  = plaintext
8919 #  server_set_id           = $auth2
8920 #  server_prompts          = :
8921 #  server_condition        = Authentication is not yet configured
8922 #  server_advertise_condition = ${if def:tls_cipher }
8923 </literallayout>
8924 <para>
8925 And the example LOGIN authenticator looks like this:
8926 </para>
8927 <literallayout class="monospaced">
8928 #LOGIN:
8929 #  driver                  = plaintext
8930 #  server_set_id           = $auth1
8931 #  server_prompts          = &lt;| Username: | Password:
8932 #  server_condition        = Authentication is not yet configured
8933 #  server_advertise_condition = ${if def:tls_cipher }
8934 </literallayout>
8935 <para>
8936 The <option>server_set_id</option> option makes Exim remember the authenticated username
8937 in <varname>$authenticated_id</varname>, which can be used later in ACLs or routers. The
8938 <option>server_prompts</option> option configures the <command>plaintext</command> authenticator so
8939 that it implements the details of the specific authentication mechanism,
8940 i.e. PLAIN or LOGIN. The <option>server_advertise_condition</option> setting controls
8941 when Exim offers authentication to clients; in the examples, this is only
8942 when TLS or SSL has been started, so to enable the authenticators you also
8943 need to add support for TLS as described in <xref linkend="SECTdefconfmain"/>.
8944 </para>
8945 <para>
8946 The <option>server_condition</option> setting defines how to verify that the username and
8947 password are correct. In the examples it just produces an error message.
8948 To make the authenticators work, you can use a string expansion
8949 expression like one of the examples in <xref linkend="CHAPplaintext"/>.
8950 </para>
8951 <para>
8952 Beware that the sequence of the parameters to PLAIN and LOGIN differ; the
8953 usercode and password are in different positions.  <xref linkend="CHAPplaintext"/>
8954 covers both.
8955 </para>
8956 <para>
8957 <indexterm role="concept" startref="IIDconfiwal" class="endofrange"/>
8958 </para>
8959 </section>
8960 </chapter>
8961
8962 <chapter id="CHAPregexp">
8963 <title>Regular expressions</title>
8964 <para>
8965 <indexterm role="concept">
8966 <primary>regular expressions</primary>
8967 <secondary>library</secondary>
8968 </indexterm>
8969 <indexterm role="concept">
8970 <primary>PCRE</primary>
8971 </indexterm>
8972 Exim supports the use of regular expressions in many of its options. It
8973 uses the PCRE regular expression library; this provides regular expression
8974 matching that is compatible with Perl 5. The syntax and semantics of
8975 regular expressions is discussed in many Perl reference books, and also in
8976 Jeffrey Friedl&#x2019;s <emphasis>Mastering Regular Expressions</emphasis>, which is published by
8977 O&#x2019;Reilly (see <emphasis role="bold"><ulink url="http://www.oreilly.com/catalog/regex2/">http://www.oreilly.com/catalog/regex2/</ulink></emphasis>).
8978 </para>
8979 <para>
8980 The documentation for the syntax and semantics of the regular expressions that
8981 are supported by PCRE is included in the PCRE distribution, and no further
8982 description is included here. The PCRE functions are called from Exim using
8983 the default option settings (that is, with no PCRE options set), except that
8984 the PCRE_CASELESS option is set when the matching is required to be
8985 case-insensitive.
8986 </para>
8987 <para>
8988 In most cases, when a regular expression is required in an Exim configuration,
8989 it has to start with a circumflex, in order to distinguish it from plain text
8990 or an <quote>ends with</quote> wildcard. In this example of a configuration setting, the
8991 second item in the colon-separated list is a regular expression.
8992 </para>
8993 <literallayout class="monospaced">
8994 domains = a.b.c : ^\\d{3} : *.y.z : ...
8995 </literallayout>
8996 <para>
8997 The doubling of the backslash is required because of string expansion that
8998 precedes interpretation &ndash; see section <xref linkend="SECTlittext"/> for more discussion
8999 of this issue, and a way of avoiding the need for doubling backslashes. The
9000 regular expression that is eventually used in this example contains just one
9001 backslash. The circumflex is included in the regular expression, and has the
9002 normal effect of <quote>anchoring</quote> it to the start of the string that is being
9003 matched.
9004 </para>
9005 <para>
9006 There are, however, two cases where a circumflex is not required for the
9007 recognition of a regular expression: these are the <option>match</option> condition in a
9008 string expansion, and the <option>matches</option> condition in an Exim filter file. In
9009 these cases, the relevant string is always treated as a regular expression; if
9010 it does not start with a circumflex, the expression is not anchored, and can
9011 match anywhere in the subject string.
9012 </para>
9013 <para>
9014 In all cases, if you want a regular expression to match at the end of a string,
9015 you must code the $ metacharacter to indicate this. For example:
9016 </para>
9017 <literallayout class="monospaced">
9018 domains = ^\\d{3}\\.example
9019 </literallayout>
9020 <para>
9021 matches the domain <emphasis>123.example</emphasis>, but it also matches <emphasis>123.example.com</emphasis>.
9022 You need to use:
9023 </para>
9024 <literallayout class="monospaced">
9025 domains = ^\\d{3}\\.example\$
9026 </literallayout>
9027 <para>
9028 if you want <emphasis>example</emphasis> to be the top-level domain. The backslash before the
9029 $ is needed because string expansion also interprets dollar characters.
9030 </para>
9031 </chapter>
9032
9033 <chapter id="CHAPfdlookup">
9034 <title>File and database lookups</title>
9035 <para>
9036 <indexterm role="concept" id="IIDfidalo1" class="startofrange">
9037 <primary>file</primary>
9038 <secondary>lookups</secondary>
9039 </indexterm>
9040 <indexterm role="concept" id="IIDfidalo2" class="startofrange">
9041 <primary>database</primary>
9042 <secondary>lookups</secondary>
9043 </indexterm>
9044 <indexterm role="concept">
9045 <primary>lookup</primary>
9046 <secondary>description of</secondary>
9047 </indexterm>
9048 Exim can be configured to look up data in files or databases as it processes
9049 messages. Two different kinds of syntax are used:
9050 </para>
9051 <orderedlist numeration="arabic">
9052 <listitem>
9053 <para>
9054 A string that is to be expanded may contain explicit lookup requests. These
9055 cause parts of the string to be replaced by data that is obtained from the
9056 lookup. Lookups of this type are conditional expansion items. Different results
9057 can be defined for the cases of lookup success and failure. See chapter
9058 <xref linkend="CHAPexpand"/>, where string expansions are described in detail.
9059 </para>
9060 </listitem>
9061 <listitem>
9062 <para>
9063 Lists of domains, hosts, and email addresses can contain lookup requests as a
9064 way of avoiding excessively long linear lists. In this case, the data that is
9065 returned by the lookup is often (but not always) discarded; whether the lookup
9066 succeeds or fails is what really counts. These kinds of list are described in
9067 chapter <xref linkend="CHAPdomhosaddlists"/>.
9068 </para>
9069 </listitem>
9070 </orderedlist>
9071 <para>
9072 String expansions, lists, and lookups interact with each other in such a way
9073 that there is no order in which to describe any one of them that does not
9074 involve references to the others. Each of these three chapters makes more sense
9075 if you have read the other two first. If you are reading this for the first
9076 time, be aware that some of it will make a lot more sense after you have read
9077 chapters <xref linkend="CHAPdomhosaddlists"/> and <xref linkend="CHAPexpand"/>.
9078 </para>
9079 <section id="SECID60">
9080 <title>Examples of different lookup syntax</title>
9081 <para>
9082 It is easy to confuse the two different kinds of lookup, especially as the
9083 lists that may contain the second kind are always expanded before being
9084 processed as lists. Therefore, they may also contain lookups of the first kind.
9085 Be careful to distinguish between the following two examples:
9086 </para>
9087 <literallayout class="monospaced">
9088 domains = ${lookup{$sender_host_address}lsearch{/some/file}}
9089 domains = lsearch;/some/file
9090 </literallayout>
9091 <para>
9092 The first uses a string expansion, the result of which must be a domain list.
9093 No strings have been specified for a successful or a failing lookup; the
9094 defaults in this case are the looked-up data and an empty string, respectively.
9095 The expansion takes place before the string is processed as a list, and the
9096 file that is searched could contain lines like this:
9097 </para>
9098 <literallayout class="monospaced">
9099 192.168.3.4: domain1:domain2:...
9100 192.168.1.9: domain3:domain4:...
9101 </literallayout>
9102 <para>
9103 When the lookup succeeds, the result of the expansion is a list of domains (and
9104 possibly other types of item that are allowed in domain lists).
9105 </para>
9106 <para>
9107 In the second example, the lookup is a single item in a domain list. It causes
9108 Exim to use a lookup to see if the domain that is being processed can be found
9109 in the file. The file could contains lines like this:
9110 </para>
9111 <literallayout class="monospaced">
9112 domain1:
9113 domain2:
9114 </literallayout>
9115 <para>
9116 Any data that follows the keys is not relevant when checking that the domain
9117 matches the list item.
9118 </para>
9119 <para>
9120 It is possible, though no doubt confusing, to use both kinds of lookup at once.
9121 Consider a file containing lines like this:
9122 </para>
9123 <literallayout class="monospaced">
9124 192.168.5.6: lsearch;/another/file
9125 </literallayout>
9126 <para>
9127 If the value of <varname>$sender_host_address</varname> is 192.168.5.6, expansion of the
9128 first <option>domains</option> setting above generates the second setting, which therefore
9129 causes a second lookup to occur.
9130 </para>
9131 <para>
9132 The rest of this chapter describes the different lookup types that are
9133 available. Any of them can be used in any part of the configuration where a
9134 lookup is permitted.
9135 </para>
9136 </section>
9137 <section id="SECID61">
9138 <title>Lookup types</title>
9139 <para>
9140 <indexterm role="concept">
9141 <primary>lookup</primary>
9142 <secondary>types of</secondary>
9143 </indexterm>
9144 <indexterm role="concept">
9145 <primary>single-key lookup</primary>
9146 <secondary>definition of</secondary>
9147 </indexterm>
9148 Two different types of data lookup are implemented:
9149 </para>
9150 <itemizedlist>
9151 <listitem>
9152 <para>
9153 The <emphasis>single-key</emphasis> type requires the specification of a file in which to look,
9154 and a single key to search for. The key must be a non-empty string for the
9155 lookup to succeed. The lookup type determines how the file is searched.
9156 </para>
9157 </listitem>
9158 <listitem>
9159 <para>
9160 <indexterm role="concept">
9161 <primary>query-style lookup</primary>
9162 <secondary>definition of</secondary>
9163 </indexterm>
9164 The <emphasis>query-style</emphasis> type accepts a generalized database query. No particular
9165 key value is assumed by Exim for query-style lookups. You can use whichever
9166 Exim variables you need to construct the database query.
9167 </para>
9168 </listitem>
9169 </itemizedlist>
9170 <para>
9171 The code for each lookup type is in a separate source file that is included in
9172 the binary of Exim only if the corresponding compile-time option is set. The
9173 default settings in <filename>src/EDITME</filename> are:
9174 </para>
9175 <literallayout class="monospaced">
9176 LOOKUP_DBM=yes
9177 LOOKUP_LSEARCH=yes
9178 </literallayout>
9179 <para>
9180 which means that only linear searching and DBM lookups are included by default.
9181 For some types of lookup (e.g. SQL databases), you need to install appropriate
9182 libraries and header files before building Exim.
9183 </para>
9184 </section>
9185 <section id="SECTsinglekeylookups">
9186 <title>Single-key lookup types</title>
9187 <para>
9188 <indexterm role="concept">
9189 <primary>lookup</primary>
9190 <secondary>single-key types</secondary>
9191 </indexterm>
9192 <indexterm role="concept">
9193 <primary>single-key lookup</primary>
9194 <secondary>list of types</secondary>
9195 </indexterm>
9196 The following single-key lookup types are implemented:
9197 </para>
9198 <itemizedlist>
9199 <listitem>
9200 <para>
9201 <indexterm role="concept">
9202 <primary>cdb</primary>
9203 <secondary>description of</secondary>
9204 </indexterm>
9205 <indexterm role="concept">
9206 <primary>lookup</primary>
9207 <secondary>cdb</secondary>
9208 </indexterm>
9209 <indexterm role="concept">
9210 <primary>binary zero</primary>
9211 <secondary>in lookup key</secondary>
9212 </indexterm>
9213 <command>cdb</command>: The given file is searched as a Constant DataBase file, using the key
9214 string without a terminating binary zero. The cdb format is designed for
9215 indexed files that are read frequently and never updated, except by total
9216 re-creation. As such, it is particularly suitable for large files containing
9217 aliases or other indexed data referenced by an MTA. Information about cdb can
9218 be found in several places:
9219 </para>
9220 <literallayout>
9221 <emphasis role="bold"><ulink url="http://www.pobox.com/~djb/cdb.html">http://www.pobox.com/~djb/cdb.html</ulink></emphasis>
9222 <emphasis role="bold"><ulink url="ftp://ftp.corpit.ru/pub/tinycdb/">ftp://ftp.corpit.ru/pub/tinycdb/</ulink></emphasis>
9223 <emphasis role="bold"><ulink url="http://packages.debian.org/stable/utils/freecdb.html">http://packages.debian.org/stable/utils/freecdb.html</ulink></emphasis>
9224 </literallayout>
9225 <para>
9226 A cdb distribution is not needed in order to build Exim with cdb support,
9227 because the code for reading cdb files is included directly in Exim itself.
9228 However, no means of building or testing cdb files is provided with Exim, so
9229 you need to obtain a cdb distribution in order to do this.
9230 </para>
9231 </listitem>
9232 <listitem>
9233 <para>
9234 <indexterm role="concept">
9235 <primary>DBM</primary>
9236 <secondary>lookup type</secondary>
9237 </indexterm>
9238 <indexterm role="concept">
9239 <primary>lookup</primary>
9240 <secondary>dbm</secondary>
9241 </indexterm>
9242 <indexterm role="concept">
9243 <primary>binary zero</primary>
9244 <secondary>in lookup key</secondary>
9245 </indexterm>
9246 <command>dbm</command>: Calls to DBM library functions are used to extract data from the given
9247 DBM file by looking up the record with the given key. A terminating binary
9248 zero is included in the key that is passed to the DBM library. See section
9249 <xref linkend="SECTdb"/> for a discussion of DBM libraries.
9250 </para>
9251 <para>
9252 <indexterm role="concept">
9253 <primary>Berkeley DB library</primary>
9254 <secondary>file format</secondary>
9255 </indexterm>
9256 For all versions of Berkeley DB, Exim uses the DB_HASH style of database
9257 when building DBM files using the <option>exim_dbmbuild</option> utility. However, when
9258 using Berkeley DB versions 3 or 4, it opens existing databases for reading with
9259 the DB_UNKNOWN option. This enables it to handle any of the types of database
9260 that the library supports, and can be useful for accessing DBM files created by
9261 other applications. (For earlier DB versions, DB_HASH is always used.)
9262 </para>
9263 </listitem>
9264 <listitem>
9265 <para>
9266 <indexterm role="concept">
9267 <primary>lookup</primary>
9268 <secondary>dbmnz</secondary>
9269 </indexterm>
9270 <indexterm role="concept">
9271 <primary>lookup</primary>
9272 <secondary>dbm &ndash; terminating zero</secondary>
9273 </indexterm>
9274 <indexterm role="concept">
9275 <primary>binary zero</primary>
9276 <secondary>in lookup key</secondary>
9277 </indexterm>
9278 <indexterm role="concept">
9279 <primary>Courier</primary>
9280 </indexterm>
9281 <indexterm role="concept">
9282 <primary><filename>/etc/userdbshadow.dat</filename></primary>
9283 </indexterm>
9284 <indexterm role="concept">
9285 <primary>dmbnz lookup type</primary>
9286 </indexterm>
9287 <command>dbmnz</command>: This is the same as <command>dbm</command>, except that a terminating binary zero
9288 is not included in the key that is passed to the DBM library. You may need this
9289 if you want to look up data in files that are created by or shared with some
9290 other application that does not use terminating zeros. For example, you need to
9291 use <command>dbmnz</command> rather than <command>dbm</command> if you want to authenticate incoming SMTP
9292 calls using the passwords from Courier&#x2019;s <filename>/etc/userdbshadow.dat</filename> file. Exim&#x2019;s
9293 utility program for creating DBM files (<emphasis>exim_dbmbuild</emphasis>) includes the zeros
9294 by default, but has an option to omit them (see section <xref linkend="SECTdbmbuild"/>).
9295 </para>
9296 </listitem>
9297 <listitem>
9298 <para>
9299 <indexterm role="concept">
9300 <primary>lookup</primary>
9301 <secondary>dsearch</secondary>
9302 </indexterm>
9303 <indexterm role="concept">
9304 <primary>dsearch lookup type</primary>
9305 </indexterm>
9306 <command>dsearch</command>: The given file must be a directory; this is searched for an entry
9307 whose name is the key by calling the <function>lstat()</function> function. The key may not
9308 contain any forward slash characters. If <function>lstat()</function> succeeds, the result of
9309 the lookup is the name of the entry, which may be a file, directory,
9310 symbolic link, or any other kind of directory entry. An example of how this
9311 lookup can be used to support virtual domains is given in section
9312 <xref linkend="SECTvirtualdomains"/>.
9313 </para>
9314 </listitem>
9315 <listitem>
9316 <para>
9317 <indexterm role="concept">
9318 <primary>lookup</primary>
9319 <secondary>iplsearch</secondary>
9320 </indexterm>
9321 <indexterm role="concept">
9322 <primary>iplsearch lookup type</primary>
9323 </indexterm>
9324 <command>iplsearch</command>: The given file is a text file containing keys and data. A key is
9325 terminated by a colon or white space or the end of the line. The keys in the
9326 file must be IP addresses, or IP addresses with CIDR masks. Keys that involve
9327 IPv6 addresses must be enclosed in quotes to prevent the first internal colon
9328 being interpreted as a key terminator. For example:
9329 </para>
9330 <literallayout class="monospaced">
9331 1.2.3.4:           data for 1.2.3.4
9332 192.168.0.0/16:    data for 192.168.0.0/16
9333 "abcd::cdab":      data for abcd::cdab
9334 "abcd:abcd::/32"   data for abcd:abcd::/32
9335 </literallayout>
9336 <para>
9337 The key for an <command>iplsearch</command> lookup must be an IP address (without a mask). The
9338 file is searched linearly, using the CIDR masks where present, until a matching
9339 key is found. The first key that matches is used; there is no attempt to find a
9340 <quote>best</quote> match. Apart from the way the keys are matched, the processing for
9341 <command>iplsearch</command> is the same as for <command>lsearch</command>.
9342 </para>
9343 <para>
9344 <emphasis role="bold">Warning 1</emphasis>: Unlike most other single-key lookup types, a file of data for
9345 <command>iplsearch</command> can <emphasis>not</emphasis> be turned into a DBM or cdb file, because those
9346 lookup types support only literal keys.
9347 </para>
9348 <para>
9349 <emphasis role="bold">Warning 2</emphasis>: In a host list, you must always use <command>net-iplsearch</command> so that
9350 the implicit key is the host&#x2019;s IP address rather than its name (see section
9351 <xref linkend="SECThoslispatsikey"/>).
9352 </para>
9353 </listitem>
9354 <listitem>
9355 <para>
9356 <indexterm role="concept">
9357 <primary>linear search</primary>
9358 </indexterm>
9359 <indexterm role="concept">
9360 <primary>lookup</primary>
9361 <secondary>lsearch</secondary>
9362 </indexterm>
9363 <indexterm role="concept">
9364 <primary>lsearch lookup type</primary>
9365 </indexterm>
9366 <indexterm role="concept">
9367 <primary>case sensitivity</primary>
9368 <secondary>in lsearch lookup</secondary>
9369 </indexterm>
9370 <command>lsearch</command>: The given file is a text file that is searched linearly for a
9371 line beginning with the search key, terminated by a colon or white space or the
9372 end of the line. The search is case-insensitive; that is, upper and lower case
9373 letters are treated as the same. The first occurrence of the key that is found
9374 in the file is used.
9375 </para>
9376 <para>
9377 White space between the key and the colon is permitted. The remainder of the
9378 line, with leading and trailing white space removed, is the data. This can be
9379 continued onto subsequent lines by starting them with any amount of white
9380 space, but only a single space character is included in the data at such a
9381 junction. If the data begins with a colon, the key must be terminated by a
9382 colon, for example:
9383 </para>
9384 <literallayout class="monospaced">
9385 baduser:  :fail:
9386 </literallayout>
9387 <para>
9388 Empty lines and lines beginning with # are ignored, even if they occur in the
9389 middle of an item. This is the traditional textual format of alias files. Note
9390 that the keys in an <command>lsearch</command> file are literal strings. There is no
9391 wildcarding of any kind.
9392 </para>
9393 <para>
9394 <indexterm role="concept">
9395 <primary>lookup</primary>
9396 <secondary>lsearch &ndash; colons in keys</secondary>
9397 </indexterm>
9398 <indexterm role="concept">
9399 <primary>white space</primary>
9400 <secondary>in lsearch key</secondary>
9401 </indexterm>
9402 In most <command>lsearch</command> files, keys are not required to contain colons or #
9403 characters, or white space. However, if you need this feature, it is available.
9404 If a key begins with a doublequote character, it is terminated only by a
9405 matching quote (or end of line), and the normal escaping rules apply to its
9406 contents (see section <xref linkend="SECTstrings"/>). An optional colon is permitted after
9407 quoted keys (exactly as for unquoted keys). There is no special handling of
9408 quotes for the data part of an <command>lsearch</command> line.
9409 </para>
9410 </listitem>
9411 <listitem>
9412 <para>
9413 <indexterm role="concept">
9414 <primary>NIS lookup type</primary>
9415 </indexterm>
9416 <indexterm role="concept">
9417 <primary>lookup</primary>
9418 <secondary>NIS</secondary>
9419 </indexterm>
9420 <indexterm role="concept">
9421 <primary>binary zero</primary>
9422 <secondary>in lookup key</secondary>
9423 </indexterm>
9424 <command>nis</command>: The given file is the name of a NIS map, and a NIS lookup is done with
9425 the given key, without a terminating binary zero. There is a variant called
9426 <command>nis0</command> which does include the terminating binary zero in the key. This is
9427 reportedly needed for Sun-style alias files. Exim does not recognize NIS
9428 aliases; the full map names must be used.
9429 </para>
9430 </listitem>
9431 <listitem>
9432 <para>
9433 <indexterm role="concept">
9434 <primary>wildlsearch lookup type</primary>
9435 </indexterm>
9436 <indexterm role="concept">
9437 <primary>lookup</primary>
9438 <secondary>wildlsearch</secondary>
9439 </indexterm>
9440 <indexterm role="concept">
9441 <primary>nwildlsearch lookup type</primary>
9442 </indexterm>
9443 <indexterm role="concept">
9444 <primary>lookup</primary>
9445 <secondary>nwildlsearch</secondary>
9446 </indexterm>
9447 <command>wildlsearch</command> or <command>nwildlsearch</command>: These search a file linearly, like
9448 <command>lsearch</command>, but instead of being interpreted as a literal string, each key in
9449 the file may be wildcarded. The difference between these two lookup types is
9450 that for <command>wildlsearch</command>, each key in the file is string-expanded before being
9451 used, whereas for <command>nwildlsearch</command>, no expansion takes place.
9452 </para>
9453 <para>
9454 <indexterm role="concept">
9455 <primary>case sensitivity</primary>
9456 <secondary>in (n)wildlsearch lookup</secondary>
9457 </indexterm>
9458 Like <command>lsearch</command>, the testing is done case-insensitively. However, keys in the
9459 file that are regular expressions can be made case-sensitive by the use of
9460 <literal>(-i)</literal> within the pattern. The following forms of wildcard are recognized:
9461 </para>
9462 <orderedlist numeration="arabic">
9463 <listitem>
9464 <para>
9465 The string may begin with an asterisk to mean <quote>ends with</quote>. For example:
9466 </para>
9467 <literallayout class="monospaced">
9468     *.a.b.c       data for anything.a.b.c
9469     *fish         data for anythingfish
9470 </literallayout>
9471 </listitem>
9472 <listitem>
9473 <para>
9474 The string may begin with a circumflex to indicate a regular expression. For
9475 example, for <command>wildlsearch</command>:
9476 </para>
9477 <literallayout class="monospaced">
9478     ^\N\d+\.a\.b\N    data for &lt;digits&gt;.a.b
9479 </literallayout>
9480 <para>
9481 Note the use of <literal>\N</literal> to disable expansion of the contents of the regular
9482 expression. If you are using <command>nwildlsearch</command>, where the keys are not
9483 string-expanded, the equivalent entry is:
9484 </para>
9485 <literallayout class="monospaced">
9486     ^\d+\.a\.b        data for &lt;digits&gt;.a.b
9487 </literallayout>
9488 <para>
9489 The case-insensitive flag is set at the start of compiling the regular
9490 expression, but it can be turned off by using <literal>(-i)</literal> at an appropriate point.
9491 For example, to make the entire pattern case-sensitive:
9492 </para>
9493 <literallayout class="monospaced">
9494     ^(?-i)\d+\.a\.b        data for &lt;digits&gt;.a.b
9495 </literallayout>
9496 <para>
9497 If the regular expression contains white space or colon characters, you must
9498 either quote it (see <command>lsearch</command> above), or represent these characters in other
9499 ways. For example, <literal>\s</literal> can be used for white space and <literal>\x3A</literal> for a
9500 colon. This may be easier than quoting, because if you quote, you have to
9501 escape all the backslashes inside the quotes.
9502 </para>
9503 <para>
9504 <emphasis role="bold">Note</emphasis>: It is not possible to capture substrings in a regular expression
9505 match for later use, because the results of all lookups are cached. If a lookup
9506 is repeated, the result is taken from the cache, and no actual pattern matching
9507 takes place. The values of all the numeric variables are unset after a
9508 <command>(n)wildlsearch</command> match.
9509 </para>
9510 </listitem>
9511 <listitem>
9512 <para>
9513 Although I cannot see it being of much use, the general matching function that
9514 is used to implement <command>(n)wildlsearch</command> means that the string may begin with a
9515 lookup name terminated by a semicolon, and followed by lookup data. For
9516 example:
9517 </para>
9518 <literallayout class="monospaced">
9519     cdb;/some/file  data for keys that match the file
9520 </literallayout>
9521 <para>
9522 The data that is obtained from the nested lookup is discarded.
9523 </para>
9524 </listitem>
9525 </orderedlist>
9526 <para>
9527 Keys that do not match any of these patterns are interpreted literally. The
9528 continuation rules for the data are the same as for <command>lsearch</command>, and keys may
9529 be followed by optional colons.
9530 </para>
9531 <para>
9532 <emphasis role="bold">Warning</emphasis>: Unlike most other single-key lookup types, a file of data for
9533 <command>(n)wildlsearch</command> can <emphasis>not</emphasis> be turned into a DBM or cdb file, because those
9534 lookup types support only literal keys.
9535 </para>
9536 </listitem>
9537 </itemizedlist>
9538 </section>
9539 <section id="SECID62">
9540 <title>Query-style lookup types</title>
9541 <para>
9542 <indexterm role="concept">
9543 <primary>lookup</primary>
9544 <secondary>query-style types</secondary>
9545 </indexterm>
9546 <indexterm role="concept">
9547 <primary>query-style lookup</primary>
9548 <secondary>list of types</secondary>
9549 </indexterm>
9550 The supported query-style lookup types are listed below. Further details about
9551 many of them are given in later sections.
9552 </para>
9553 <itemizedlist>
9554 <listitem>
9555 <para>
9556 <indexterm role="concept">
9557 <primary>DNS</primary>
9558 <secondary>as a lookup type</secondary>
9559 </indexterm>
9560 <indexterm role="concept">
9561 <primary>lookup</primary>
9562 <secondary>DNS</secondary>
9563 </indexterm>
9564 <command>dnsdb</command>: This does a DNS search for one or more records whose domain names
9565 are given in the supplied query. The resulting data is the contents of the
9566 records. See section <xref linkend="SECTdnsdb"/>.
9567 </para>
9568 </listitem>
9569 <listitem>
9570 <para>
9571 <indexterm role="concept">
9572 <primary>InterBase lookup type</primary>
9573 </indexterm>
9574 <indexterm role="concept">
9575 <primary>lookup</primary>
9576 <secondary>InterBase</secondary>
9577 </indexterm>
9578 <command>ibase</command>: This does a lookup in an InterBase database.
9579 </para>
9580 </listitem>
9581 <listitem>
9582 <para>
9583 <indexterm role="concept">
9584 <primary>LDAP</primary>
9585 <secondary>lookup type</secondary>
9586 </indexterm>
9587 <indexterm role="concept">
9588 <primary>lookup</primary>
9589 <secondary>LDAP</secondary>
9590 </indexterm>
9591 <command>ldap</command>: This does an LDAP lookup using a query in the form of a URL, and
9592 returns attributes from a single entry. There is a variant called <command>ldapm</command>
9593 that permits values from multiple entries to be returned. A third variant
9594 called <command>ldapdn</command> returns the Distinguished Name of a single entry instead of
9595 any attribute values. See section <xref linkend="SECTldap"/>.
9596 </para>
9597 </listitem>
9598 <listitem>
9599 <para>
9600 <indexterm role="concept">
9601 <primary>MySQL</primary>
9602 <secondary>lookup type</secondary>
9603 </indexterm>
9604 <indexterm role="concept">
9605 <primary>lookup</primary>
9606 <secondary>MySQL</secondary>
9607 </indexterm>
9608 <command>mysql</command>: The format of the query is an SQL statement that is passed to a
9609 MySQL database. See section <xref linkend="SECTsql"/>.
9610 </para>
9611 </listitem>
9612 <listitem>
9613 <para>
9614 <indexterm role="concept">
9615 <primary>NIS+ lookup type</primary>
9616 </indexterm>
9617 <indexterm role="concept">
9618 <primary>lookup</primary>
9619 <secondary>NIS+</secondary>
9620 </indexterm>
9621 <command>nisplus</command>: This does a NIS+ lookup using a query that can specify the name of
9622 the field to be returned. See section <xref linkend="SECTnisplus"/>.
9623 </para>
9624 </listitem>
9625 <listitem>
9626 <para>
9627 <indexterm role="concept">
9628 <primary>Oracle</primary>
9629 <secondary>lookup type</secondary>
9630 </indexterm>
9631 <indexterm role="concept">
9632 <primary>lookup</primary>
9633 <secondary>Oracle</secondary>
9634 </indexterm>
9635 <command>oracle</command>: The format of the query is an SQL statement that is passed to an
9636 Oracle database. See section <xref linkend="SECTsql"/>.
9637 </para>
9638 </listitem>
9639 <listitem>
9640 <para>
9641 <indexterm role="concept">
9642 <primary>lookup</primary>
9643 <secondary>passwd</secondary>
9644 </indexterm>
9645 <indexterm role="concept">
9646 <primary>passwd lookup type</primary>
9647 </indexterm>
9648 <indexterm role="concept">
9649 <primary><filename>/etc/passwd</filename></primary>
9650 </indexterm>
9651 <command>passwd</command> is a query-style lookup with queries that are just user names. The
9652 lookup calls <function>getpwnam()</function> to interrogate the system password data, and on
9653 success, the result string is the same as you would get from an <command>lsearch</command>
9654 lookup on a traditional <filename>/etc/passwd file</filename>, though with <literal>*</literal> for the
9655 password value. For example:
9656 </para>
9657 <literallayout class="monospaced">
9658 *:42:42:King Rat:/home/kr:/bin/bash
9659 </literallayout>
9660 </listitem>
9661 <listitem>
9662 <para>
9663 <indexterm role="concept">
9664 <primary>PostgreSQL lookup type</primary>
9665 </indexterm>
9666 <indexterm role="concept">
9667 <primary>lookup</primary>
9668 <secondary>PostgreSQL</secondary>
9669 </indexterm>
9670 <command>pgsql</command>: The format of the query is an SQL statement that is passed to a
9671 PostgreSQL database. See section <xref linkend="SECTsql"/>.
9672 </para>
9673 </listitem>
9674 <listitem>
9675 <para>
9676 <indexterm role="concept">
9677 <primary>sqlite lookup type</primary>
9678 </indexterm>
9679 <indexterm role="concept">
9680 <primary>lookup</primary>
9681 <secondary>sqlite</secondary>
9682 </indexterm>
9683 <command>sqlite</command>: The format of the query is a file name followed by an SQL statement
9684 that is passed to an SQLite database. See section <xref linkend="SECTsqlite"/>.
9685 </para>
9686 </listitem>
9687 <listitem>
9688 <para>
9689 <command>testdb</command>: This is a lookup type that is used for testing Exim. It is
9690 not likely to be useful in normal operation.
9691 </para>
9692 </listitem>
9693 <listitem>
9694 <para>
9695 <indexterm role="concept">
9696 <primary>whoson lookup type</primary>
9697 </indexterm>
9698 <indexterm role="concept">
9699 <primary>lookup</primary>
9700 <secondary>whoson</secondary>
9701 </indexterm>
9702 <command>whoson</command>: <emphasis>Whoson</emphasis> (<emphasis role="bold"><ulink url="http://whoson.sourceforge.net">http://whoson.sourceforge.net</ulink></emphasis>) is a protocol that
9703 allows a server to check whether a particular (dynamically allocated) IP
9704 address is currently allocated to a known (trusted) user and, optionally, to
9705 obtain the identity of the said user. For SMTP servers, <emphasis>Whoson</emphasis> was popular
9706 at one time for <quote>POP before SMTP</quote> authentication, but that approach has been
9707 superseded by SMTP authentication. In Exim, <emphasis>Whoson</emphasis> can be used to implement
9708 <quote>POP before SMTP</quote> checking using ACL statements such as
9709 </para>
9710 <literallayout class="monospaced">
9711 require condition = \
9712   ${lookup whoson {$sender_host_address}{yes}{no}}
9713 </literallayout>
9714 <para>
9715 The query consists of a single IP address. The value returned is the name of
9716 the authenticated user, which is stored in the variable <varname>$value</varname>. However, in
9717 this example, the data in <varname>$value</varname> is not used; the result of the lookup is
9718 one of the fixed strings <quote>yes</quote> or <quote>no</quote>.
9719 </para>
9720 </listitem>
9721 </itemizedlist>
9722 </section>
9723 <section id="SECID63">
9724 <title>Temporary errors in lookups</title>
9725 <para>
9726 <indexterm role="concept">
9727 <primary>lookup</primary>
9728 <secondary>temporary error in</secondary>
9729 </indexterm>
9730 Lookup functions can return temporary error codes if the lookup cannot be
9731 completed. For example, an SQL or LDAP database might be unavailable. For this
9732 reason, it is not advisable to use a lookup that might do this for critical
9733 options such as a list of local domains.
9734 </para>
9735 <para>
9736 When a lookup cannot be completed in a router or transport, delivery
9737 of the message (to the relevant address) is deferred, as for any other
9738 temporary error. In other circumstances Exim may assume the lookup has failed,
9739 or may give up altogether.
9740 </para>
9741 </section>
9742 <section id="SECTdefaultvaluelookups">
9743 <title>Default values in single-key lookups</title>
9744 <para>
9745 <indexterm role="concept">
9746 <primary>wildcard lookups</primary>
9747 </indexterm>
9748 <indexterm role="concept">
9749 <primary>lookup</primary>
9750 <secondary>default values</secondary>
9751 </indexterm>
9752 <indexterm role="concept">
9753 <primary>lookup</primary>
9754 <secondary>wildcard</secondary>
9755 </indexterm>
9756 <indexterm role="concept">
9757 <primary>lookup</primary>
9758 <secondary>* added to type</secondary>
9759 </indexterm>
9760 <indexterm role="concept">
9761 <primary>default</primary>
9762 <secondary>in single-key lookups</secondary>
9763 </indexterm>
9764 In this context, a <quote>default value</quote> is a value specified by the administrator
9765 that is to be used if a lookup fails.
9766 </para>
9767 <para>
9768 <emphasis role="bold">Note:</emphasis> This section applies only to single-key lookups. For query-style
9769 lookups, the facilities of the query language must be used. An attempt to
9770 specify a default for a query-style lookup provokes an error.
9771 </para>
9772 <para>
9773 If <quote>*</quote> is added to a single-key lookup type (for example, <option>lsearch*</option>)
9774 and the initial lookup fails, the key <quote>*</quote> is looked up in the file to
9775 provide a default value. See also the section on partial matching below.
9776 </para>
9777 <para>
9778 <indexterm role="concept">
9779 <primary>*@ with single-key lookup</primary>
9780 </indexterm>
9781 <indexterm role="concept">
9782 <primary>lookup</primary>
9783 <secondary>*@ added to type</secondary>
9784 </indexterm>
9785 <indexterm role="concept">
9786 <primary>alias file</primary>
9787 <secondary>per-domain default</secondary>
9788 </indexterm>
9789 Alternatively, if <quote>*@</quote> is added to a single-key lookup type (for example
9790 <option>dbm*@</option>) then, if the initial lookup fails and the key contains an @
9791 character, a second lookup is done with everything before the last @ replaced
9792 by *. This makes it possible to provide per-domain defaults in alias files
9793 that include the domains in the keys. If the second lookup fails (or doesn&#x2019;t
9794 take place because there is no @ in the key), <quote>*</quote> is looked up.
9795 For example, a <command>redirect</command> router might contain:
9796 </para>
9797 <literallayout class="monospaced">
9798 data = ${lookup{$local_part@$domain}lsearch*@{/etc/mix-aliases}}
9799 </literallayout>
9800 <para>
9801 Suppose the address that is being processed is <emphasis>jane@eyre.example</emphasis>. Exim
9802 looks up these keys, in this order:
9803 </para>
9804 <literallayout class="monospaced">
9805 jane@eyre.example
9806 *@eyre.example
9807 *
9808 </literallayout>
9809 <para>
9810 The data is taken from whichever key it finds first. <emphasis role="bold">Note</emphasis>: In an
9811 <command>lsearch</command> file, this does not mean the first of these keys in the file. A
9812 complete scan is done for each key, and only if it is not found at all does
9813 Exim move on to try the next key.
9814 </para>
9815 </section>
9816 <section id="SECTpartiallookup">
9817 <title>Partial matching in single-key lookups</title>
9818 <para>
9819 <indexterm role="concept">
9820 <primary>partial matching</primary>
9821 </indexterm>
9822 <indexterm role="concept">
9823 <primary>wildcard lookups</primary>
9824 </indexterm>
9825 <indexterm role="concept">
9826 <primary>lookup</primary>
9827 <secondary>partial matching</secondary>
9828 </indexterm>
9829 <indexterm role="concept">
9830 <primary>lookup</primary>
9831 <secondary>wildcard</secondary>
9832 </indexterm>
9833 <indexterm role="concept">
9834 <primary>asterisk</primary>
9835 <secondary>in search type</secondary>
9836 </indexterm>
9837 The normal operation of a single-key lookup is to search the file for an exact
9838 match with the given key. However, in a number of situations where domains are
9839 being looked up, it is useful to be able to do partial matching. In this case,
9840 information in the file that has a key starting with <quote>*.</quote> is matched by any
9841 domain that ends with the components that follow the full stop. For example, if
9842 a key in a DBM file is
9843 </para>
9844 <literallayout class="monospaced">
9845 *.dates.fict.example
9846 </literallayout>
9847 <para>
9848 then when partial matching is enabled this is matched by (amongst others)
9849 <emphasis>2001.dates.fict.example</emphasis> and <emphasis>1984.dates.fict.example</emphasis>. It is also matched
9850 by <emphasis>dates.fict.example</emphasis>, if that does not appear as a separate key in the
9851 file.
9852 </para>
9853 <para>
9854 <emphasis role="bold">Note</emphasis>: Partial matching is not available for query-style lookups. It is
9855 also not available for any lookup items in address lists (see section
9856 <xref linkend="SECTaddresslist"/>).
9857 </para>
9858 <para>
9859 Partial matching is implemented by doing a series of separate lookups using
9860 keys constructed by modifying the original subject key. This means that it can
9861 be used with any of the single-key lookup types, provided that
9862 partial matching keys
9863 beginning with a special prefix (default <quote>*.</quote>) are included in the data file.
9864 Keys in the file that do not begin with the prefix are matched only by
9865 unmodified subject keys when partial matching is in use.
9866 </para>
9867 <para>
9868 Partial matching is requested by adding the string <quote>partial-</quote> to the front of
9869 the name of a single-key lookup type, for example, <option>partial-dbm</option>. When this
9870 is done, the subject key is first looked up unmodified; if that fails, <quote>*.</quote>
9871 is added at the start of the subject key, and it is looked up again. If that
9872 fails, further lookups are tried with dot-separated components removed from the
9873 start of the subject key, one-by-one, and <quote>*.</quote> added on the front of what
9874 remains.
9875 </para>
9876 <para>
9877 A minimum number of two non-* components are required. This can be adjusted
9878 by including a number before the hyphen in the search type. For example,
9879 <option>partial3-lsearch</option> specifies a minimum of three non-* components in the
9880 modified keys. Omitting the number is equivalent to <quote>partial2-</quote>. If the
9881 subject key is <emphasis>2250.dates.fict.example</emphasis> then the following keys are looked
9882 up when the minimum number of non-* components is two:
9883 </para>
9884 <literallayout class="monospaced">
9885 2250.dates.fict.example
9886 *.2250.dates.fict.example
9887 *.dates.fict.example
9888 *.fict.example
9889 </literallayout>
9890 <para>
9891 As soon as one key in the sequence is successfully looked up, the lookup
9892 finishes.
9893 </para>
9894 <para>
9895 <indexterm role="concept">
9896 <primary>lookup</primary>
9897 <secondary>partial matching &ndash; changing prefix</secondary>
9898 </indexterm>
9899 <indexterm role="concept">
9900 <primary>prefix</primary>
9901 <secondary>for partial matching</secondary>
9902 </indexterm>
9903 The use of <quote>*.</quote> as the partial matching prefix is a default that can be
9904 changed. The motivation for this feature is to allow Exim to operate with file
9905 formats that are used by other MTAs. A different prefix can be supplied in
9906 parentheses instead of the hyphen after <quote>partial</quote>. For example:
9907 </para>
9908 <literallayout class="monospaced">
9909 domains = partial(.)lsearch;/some/file
9910 </literallayout>
9911 <para>
9912 In this example, if the domain is <emphasis>a.b.c</emphasis>, the sequence of lookups is
9913 <literal>a.b.c</literal>, <literal>.a.b.c</literal>, and <literal>.b.c</literal> (the default minimum of 2 non-wild
9914 components is unchanged). The prefix may consist of any punctuation characters
9915 other than a closing parenthesis. It may be empty, for example:
9916 </para>
9917 <literallayout class="monospaced">
9918 domains = partial1()cdb;/some/file
9919 </literallayout>
9920 <para>
9921 For this example, if the domain is <emphasis>a.b.c</emphasis>, the sequence of lookups is
9922 <literal>a.b.c</literal>, <literal>b.c</literal>, and <literal>c</literal>.
9923 </para>
9924 <para>
9925 If <quote>partial0</quote> is specified, what happens at the end (when the lookup with
9926 just one non-wild component has failed, and the original key is shortened right
9927 down to the null string) depends on the prefix:
9928 </para>
9929 <itemizedlist>
9930 <listitem>
9931 <para>
9932 If the prefix has zero length, the whole lookup fails.
9933 </para>
9934 </listitem>
9935 <listitem>
9936 <para>
9937 If the prefix has length 1, a lookup for just the prefix is done. For
9938 example, the final lookup for <quote>partial0(.)</quote> is for <literal>.</literal> alone.
9939 </para>
9940 </listitem>
9941 <listitem>
9942 <para>
9943 Otherwise, if the prefix ends in a dot, the dot is removed, and the
9944 remainder is looked up. With the default prefix, therefore, the final lookup is
9945 for <quote>*</quote> on its own.
9946 </para>
9947 </listitem>
9948 <listitem>
9949 <para>
9950 Otherwise, the whole prefix is looked up.
9951 </para>
9952 </listitem>
9953 </itemizedlist>
9954 <para>
9955 If the search type ends in <quote>*</quote> or <quote>*@</quote> (see section
9956 <xref linkend="SECTdefaultvaluelookups"/> above), the search for an ultimate default that
9957 this implies happens after all partial lookups have failed. If <quote>partial0</quote> is
9958 specified, adding <quote>*</quote> to the search type has no effect with the default
9959 prefix, because the <quote>*</quote> key is already included in the sequence of partial
9960 lookups. However, there might be a use for lookup types such as
9961 <quote>partial0(.)lsearch*</quote>.
9962 </para>
9963 <para>
9964 The use of <quote>*</quote> in lookup partial matching differs from its use as a wildcard
9965 in domain lists and the like. Partial matching works only in terms of
9966 dot-separated components; a key such as <literal>*fict.example</literal>
9967 in a database file is useless, because the asterisk in a partial matching
9968 subject key is always followed by a dot.
9969 </para>
9970 </section>
9971 <section id="SECID64">
9972 <title>Lookup caching</title>
9973 <para>
9974 <indexterm role="concept">
9975 <primary>lookup</primary>
9976 <secondary>caching</secondary>
9977 </indexterm>
9978 <indexterm role="concept">
9979 <primary>caching</primary>
9980 <secondary>lookup data</secondary>
9981 </indexterm>
9982 Exim caches all lookup results in order to avoid needless repetition of
9983 lookups. However, because (apart from the daemon) Exim operates as a collection
9984 of independent, short-lived processes, this caching applies only within a
9985 single Exim process. There is no inter-process lookup caching facility.
9986 </para>
9987 <para>
9988 For single-key lookups, Exim keeps the relevant files open in case there is
9989 another lookup that needs them. In some types of configuration this can lead to
9990 many files being kept open for messages with many recipients. To avoid hitting
9991 the operating system limit on the number of simultaneously open files, Exim
9992 closes the least recently used file when it needs to open more files than its
9993 own internal limit, which can be changed via the <option>lookup_open_max</option> option.
9994 </para>
9995 <para>
9996 The single-key lookup files are closed and the lookup caches are flushed at
9997 strategic points during delivery &ndash; for example, after all routing is
9998 complete.
9999 </para>
10000 </section>
10001 <section id="SECID65">
10002 <title>Quoting lookup data</title>
10003 <para>
10004 <indexterm role="concept">
10005 <primary>lookup</primary>
10006 <secondary>quoting</secondary>
10007 </indexterm>
10008 <indexterm role="concept">
10009 <primary>quoting</primary>
10010 <secondary>in lookups</secondary>
10011 </indexterm>
10012 When data from an incoming message is included in a query-style lookup, there
10013 is the possibility of special characters in the data messing up the syntax of
10014 the query. For example, a NIS+ query that contains
10015 </para>
10016 <literallayout class="monospaced">
10017 [name=$local_part]
10018 </literallayout>
10019 <para>
10020 will be broken if the local part happens to contain a closing square bracket.
10021 For NIS+, data can be enclosed in double quotes like this:
10022 </para>
10023 <literallayout class="monospaced">
10024 [name="$local_part"]
10025 </literallayout>
10026 <para>
10027 but this still leaves the problem of a double quote in the data. The rule for
10028 NIS+ is that double quotes must be doubled. Other lookup types have different
10029 rules, and to cope with the differing requirements, an expansion operator
10030 of the following form is provided:
10031 </para>
10032 <literallayout class="monospaced">
10033 ${quote_&lt;lookup-type&gt;:&lt;string&gt;}
10034 </literallayout>
10035 <para>
10036 For example, the safest way to write the NIS+ query is
10037 </para>
10038 <literallayout class="monospaced">
10039 [name="${quote_nisplus:$local_part}"]
10040 </literallayout>
10041 <para>
10042 See chapter <xref linkend="CHAPexpand"/> for full coverage of string expansions. The quote
10043 operator can be used for all lookup types, but has no effect for single-key
10044 lookups, since no quoting is ever needed in their key strings.
10045 </para>
10046 </section>
10047 <section id="SECTdnsdb">
10048 <title>More about dnsdb</title>
10049 <para>
10050 <indexterm role="concept">
10051 <primary>dnsdb lookup</primary>
10052 </indexterm>
10053 <indexterm role="concept">
10054 <primary>lookup</primary>
10055 <secondary>dnsdb</secondary>
10056 </indexterm>
10057 <indexterm role="concept">
10058 <primary>DNS</primary>
10059 <secondary>as a lookup type</secondary>
10060 </indexterm>
10061 The <command>dnsdb</command> lookup type uses the DNS as its database. A simple query consists
10062 of a record type and a domain name, separated by an equals sign. For example,
10063 an expansion string could contain:
10064 </para>
10065 <literallayout class="monospaced">
10066 ${lookup dnsdb{mx=a.b.example}{$value}fail}
10067 </literallayout>
10068 <para>
10069 If the lookup succeeds, the result is placed in <varname>$value</varname>, which in this case
10070 is used on its own as the result. If the lookup does not succeed, the
10071 <literal>fail</literal> keyword causes a <emphasis>forced expansion failure</emphasis> &ndash; see section
10072 <xref linkend="SECTforexpfai"/> for an explanation of what this means.
10073 </para>
10074 <para>
10075 The supported DNS record types are A, CNAME, MX, NS, PTR, SRV, and TXT, and,
10076 when Exim is compiled with IPv6 support, AAAA (and A6 if that is also
10077 configured). If no type is given, TXT is assumed. When the type is PTR,
10078 the data can be an IP address, written as normal; inversion and the addition of
10079 <option>in-addr.arpa</option> or <option>ip6.arpa</option> happens automatically. For example:
10080 </para>
10081 <literallayout class="monospaced">
10082 ${lookup dnsdb{ptr=192.168.4.5}{$value}fail}
10083 </literallayout>
10084 <para>
10085 If the data for a PTR record is not a syntactically valid IP address, it is not
10086 altered and nothing is added.
10087 </para>
10088 <para>
10089 <indexterm role="concept">
10090 <primary>MX record</primary>
10091 <secondary>in <command>dnsdb</command> lookup</secondary>
10092 </indexterm>
10093 <indexterm role="concept">
10094 <primary>SRV record</primary>
10095 <secondary>in <command>dnsdb</command> lookup</secondary>
10096 </indexterm>
10097 For an MX lookup, both the preference value and the host name are returned for
10098 each record, separated by a space. For an SRV lookup, the priority, weight,
10099 port, and host name are returned for each record, separated by spaces.
10100 </para>
10101 <para>
10102 For any record type, if multiple records are found (or, for A6 lookups, if a
10103 single record leads to multiple addresses), the data is returned as a
10104 concatenation, with newline as the default separator. The order, of course,
10105 depends on the DNS resolver. You can specify a different separator character
10106 between multiple records by putting a right angle-bracket followed immediately
10107 by the new separator at the start of the query. For example:
10108 </para>
10109 <literallayout class="monospaced">
10110 ${lookup dnsdb{&gt;: a=host1.example}}
10111 </literallayout>
10112 <para>
10113 It is permitted to specify a space as the separator character. Further
10114 white space is ignored.
10115 </para>
10116 <para>
10117 <indexterm role="concept">
10118 <primary>TXT record</primary>
10119 <secondary>in <command>dnsdb</command> lookup</secondary>
10120 </indexterm>
10121 For TXT records with multiple items of data, only the first item is returned,
10122 unless a separator for them is specified using a comma after the separator
10123 character followed immediately by the TXT record item separator. To concatenate
10124 items without a separator, use a semicolon instead.
10125 </para>
10126 <literallayout class="monospaced">
10127 ${lookup dnsdb{&gt;\n,: txt=a.b.example}}
10128 ${lookup dnsdb{&gt;\n; txt=a.b.example}}
10129 </literallayout>
10130 <para>
10131 It is permitted to specify a space as the separator character. Further
10132 white space is ignored.
10133 </para>
10134 </section>
10135 <section id="SECID66">
10136 <title>Pseudo dnsdb record types</title>
10137 <para>
10138 <indexterm role="concept">
10139 <primary>MX record</primary>
10140 <secondary>in <command>dnsdb</command> lookup</secondary>
10141 </indexterm>
10142 By default, both the preference value and the host name are returned for
10143 each MX record, separated by a space. If you want only host names, you can use
10144 the pseudo-type MXH:
10145 </para>
10146 <literallayout class="monospaced">
10147 ${lookup dnsdb{mxh=a.b.example}}
10148 </literallayout>
10149 <para>
10150 In this case, the preference values are omitted, and just the host names are
10151 returned.
10152 </para>
10153 <para>
10154 <indexterm role="concept">
10155 <primary>name server for enclosing domain</primary>
10156 </indexterm>
10157 Another pseudo-type is ZNS (for <quote>zone NS</quote>). It performs a lookup for NS
10158 records on the given domain, but if none are found, it removes the first
10159 component of the domain name, and tries again. This process continues until NS
10160 records are found or there are no more components left (or there is a DNS
10161 error). In other words, it may return the name servers for a top-level domain,
10162 but it never returns the root name servers. If there are no NS records for the
10163 top-level domain, the lookup fails. Consider these examples:
10164 </para>
10165 <literallayout class="monospaced">
10166 ${lookup dnsdb{zns=xxx.quercite.com}}
10167 ${lookup dnsdb{zns=xxx.edu}}
10168 </literallayout>
10169 <para>
10170 Assuming that in each case there are no NS records for the full domain name,
10171 the first returns the name servers for <option>quercite.com</option>, and the second returns
10172 the name servers for <option>edu</option>.
10173 </para>
10174 <para>
10175 You should be careful about how you use this lookup because, unless the
10176 top-level domain does not exist, the lookup always returns some host names. The
10177 sort of use to which this might be put is for seeing if the name servers for a
10178 given domain are on a blacklist. You can probably assume that the name servers
10179 for the high-level domains such as <option>com</option> or <option>co.uk</option> are not going to be on
10180 such a list.
10181 </para>
10182 <para>
10183 <indexterm role="concept">
10184 <primary>CSA</primary>
10185 <secondary>in <command>dnsdb</command> lookup</secondary>
10186 </indexterm>
10187 A third pseudo-type is CSA (Client SMTP Authorization). This looks up SRV
10188 records according to the CSA rules, which are described in section
10189 <xref linkend="SECTverifyCSA"/>. Although <command>dnsdb</command> supports SRV lookups directly, this is
10190 not sufficient because of the extra parent domain search behaviour of CSA. The
10191 result of a successful lookup such as:
10192 </para>
10193 <literallayout class="monospaced">
10194 ${lookup dnsdb {csa=$sender_helo_name}}
10195 </literallayout>
10196 <para>
10197 has two space-separated fields: an authorization code and a target host name.
10198 The authorization code can be <quote>Y</quote> for yes, <quote>N</quote> for no, <quote>X</quote> for explicit
10199 authorization required but absent, or <quote>?</quote> for unknown.
10200 </para>
10201 </section>
10202 <section id="SECID67">
10203 <title>Multiple dnsdb lookups</title>
10204 <para>
10205 In the previous sections, <command>dnsdb</command> lookups for a single domain are described.
10206 However, you can specify a list of domains or IP addresses in a single
10207 <command>dnsdb</command> lookup. The list is specified in the normal Exim way, with colon as
10208 the default separator, but with the ability to change this. For example:
10209 </para>
10210 <literallayout class="monospaced">
10211 ${lookup dnsdb{one.domain.com:two.domain.com}}
10212 ${lookup dnsdb{a=one.host.com:two.host.com}}
10213 ${lookup dnsdb{ptr = &lt;; 1.2.3.4 ; 4.5.6.8}}
10214 </literallayout>
10215 <para>
10216 In order to retain backwards compatibility, there is one special case: if
10217 the lookup type is PTR and no change of separator is specified, Exim looks
10218 to see if the rest of the string is precisely one IPv6 address. In this
10219 case, it does not treat it as a list.
10220 </para>
10221 <para>
10222 The data from each lookup is concatenated, with newline separators by default,
10223 in the same way that multiple DNS records for a single item are handled. A
10224 different separator can be specified, as described above.
10225 </para>
10226 <para>
10227 The <command>dnsdb</command> lookup fails only if all the DNS lookups fail. If there is a
10228 temporary DNS error for any of them, the behaviour is controlled by
10229 an optional keyword followed by a comma that may appear before the record
10230 type. The possible keywords are <quote>defer_strict</quote>, <quote>defer_never</quote>, and
10231 <quote>defer_lax</quote>. With <quote>strict</quote> behaviour, any temporary DNS error causes the
10232 whole lookup to defer. With <quote>never</quote> behaviour, a temporary DNS error is
10233 ignored, and the behaviour is as if the DNS lookup failed to find anything.
10234 With <quote>lax</quote> behaviour, all the queries are attempted, but a temporary DNS
10235 error causes the whole lookup to defer only if none of the other lookups
10236 succeed. The default is <quote>lax</quote>, so the following lookups are equivalent:
10237 </para>
10238 <literallayout class="monospaced">
10239 ${lookup dnsdb{defer_lax,a=one.host.com:two.host.com}}
10240 ${lookup dnsdb{a=one.host.com:two.host.com}}
10241 </literallayout>
10242 <para>
10243 Thus, in the default case, as long as at least one of the DNS lookups
10244 yields some data, the lookup succeeds.
10245 </para>
10246 </section>
10247 <section id="SECTldap">
10248 <title>More about LDAP</title>
10249 <para>
10250 <indexterm role="concept">
10251 <primary>LDAP</primary>
10252 <secondary>lookup, more about</secondary>
10253 </indexterm>
10254 <indexterm role="concept">
10255 <primary>lookup</primary>
10256 <secondary>LDAP</secondary>
10257 </indexterm>
10258 <indexterm role="concept">
10259 <primary>Solaris</primary>
10260 <secondary>LDAP</secondary>
10261 </indexterm>
10262 The original LDAP implementation came from the University of Michigan; this has
10263 become <quote>Open LDAP</quote>, and there are now two different releases. Another
10264 implementation comes from Netscape, and Solaris 7 and subsequent releases
10265 contain inbuilt LDAP support. Unfortunately, though these are all compatible at
10266 the lookup function level, their error handling is different. For this reason
10267 it is necessary to set a compile-time variable when building Exim with LDAP, to
10268 indicate which LDAP library is in use. One of the following should appear in
10269 your <filename>Local/Makefile</filename>:
10270 </para>
10271 <literallayout class="monospaced">
10272 LDAP_LIB_TYPE=UMICHIGAN
10273 LDAP_LIB_TYPE=OPENLDAP1
10274 LDAP_LIB_TYPE=OPENLDAP2
10275 LDAP_LIB_TYPE=NETSCAPE
10276 LDAP_LIB_TYPE=SOLARIS
10277 </literallayout>
10278 <para>
10279 If LDAP_LIB_TYPE is not set, Exim assumes <literal>OPENLDAP1</literal>, which has the
10280 same interface as the University of Michigan version.
10281 </para>
10282 <para>
10283 There are three LDAP lookup types in Exim. These behave slightly differently in
10284 the way they handle the results of a query:
10285 </para>
10286 <itemizedlist>
10287 <listitem>
10288 <para>
10289 <command>ldap</command> requires the result to contain just one entry; if there are more, it
10290 gives an error.
10291 </para>
10292 </listitem>
10293 <listitem>
10294 <para>
10295 <command>ldapdn</command> also requires the result to contain just one entry, but it is the
10296 Distinguished Name that is returned rather than any attribute values.
10297 </para>
10298 </listitem>
10299 <listitem>
10300 <para>
10301 <command>ldapm</command> permits the result to contain more than one entry; the attributes
10302 from all of them are returned.
10303 </para>
10304 </listitem>
10305 </itemizedlist>
10306 <para>
10307 For <command>ldap</command> and <command>ldapm</command>, if a query finds only entries with no attributes,
10308 Exim behaves as if the entry did not exist, and the lookup fails. The format of
10309 the data returned by a successful lookup is described in the next section.
10310 First we explain how LDAP queries are coded.
10311 </para>
10312 </section>
10313 <section id="SECTforldaque">
10314 <title>Format of LDAP queries</title>
10315 <para>
10316 <indexterm role="concept">
10317 <primary>LDAP</primary>
10318 <secondary>query format</secondary>
10319 </indexterm>
10320 An LDAP query takes the form of a URL as defined in RFC 2255. For example, in
10321 the configuration of a <command>redirect</command> router one might have this setting:
10322 </para>
10323 <literallayout class="monospaced">
10324 data = ${lookup ldap \
10325   {ldap:///cn=$local_part,o=University%20of%20Cambridge,\
10326   c=UK?mailbox?base?}}
10327 </literallayout>
10328 <para>
10329 <indexterm role="concept">
10330 <primary>LDAP</primary>
10331 <secondary>with TLS</secondary>
10332 </indexterm>
10333 The URL may begin with <literal>ldap</literal> or <literal>ldaps</literal> if your LDAP library supports
10334 secure (encrypted) LDAP connections. The second of these ensures that an
10335 encrypted TLS connection is used.
10336 </para>
10337 </section>
10338 <section id="SECID68">
10339 <title>LDAP quoting</title>
10340 <para>
10341 <indexterm role="concept">
10342 <primary>LDAP</primary>
10343 <secondary>quoting</secondary>
10344 </indexterm>
10345 Two levels of quoting are required in LDAP queries, the first for LDAP itself
10346 and the second because the LDAP query is represented as a URL. Furthermore,
10347 within an LDAP query, two different kinds of quoting are required. For this
10348 reason, there are two different LDAP-specific quoting operators.
10349 </para>
10350 <para>
10351 The <option>quote_ldap</option> operator is designed for use on strings that are part of
10352 filter specifications. Conceptually, it first does the following conversions on
10353 the string:
10354 </para>
10355 <literallayout class="monospaced">
10356 *   =&gt;   \2A
10357 (   =&gt;   \28
10358 )   =&gt;   \29
10359 \   =&gt;   \5C
10360 </literallayout>
10361 <para>
10362 in accordance with RFC 2254. The resulting string is then quoted according
10363 to the rules for URLs, that is, all non-alphanumeric characters except
10364 </para>
10365 <literallayout class="monospaced">
10366 ! $ ' - . _ ( ) * +
10367 </literallayout>
10368 <para>
10369 are converted to their hex values, preceded by a percent sign. For example:
10370 </para>
10371 <literallayout class="monospaced">
10372 ${quote_ldap: a(bc)*, a&lt;yz&gt;; }
10373 </literallayout>
10374 <para>
10375 yields
10376 </para>
10377 <literallayout class="monospaced">
10378 %20a%5C28bc%5C29%5C2A%2C%20a%3Cyz%3E%3B%20
10379 </literallayout>
10380 <para>
10381 Removing the URL quoting, this is (with a leading and a trailing space):
10382 </para>
10383 <literallayout class="monospaced">
10384 a\28bc\29\2A, a&lt;yz&gt;;
10385 </literallayout>
10386 <para>
10387 The <option>quote_ldap_dn</option> operator is designed for use on strings that are part of
10388 base DN specifications in queries. Conceptually, it first converts the string
10389 by inserting a backslash in front of any of the following characters:
10390 </para>
10391 <literallayout class="monospaced">
10392 , + " \ &lt; &gt; ;
10393 </literallayout>
10394 <para>
10395 It also inserts a backslash before any leading spaces or # characters, and
10396 before any trailing spaces. (These rules are in RFC 2253.) The resulting string
10397 is then quoted according to the rules for URLs. For example:
10398 </para>
10399 <literallayout class="monospaced">
10400 ${quote_ldap_dn: a(bc)*, a&lt;yz&gt;; }
10401 </literallayout>
10402 <para>
10403 yields
10404 </para>
10405 <literallayout class="monospaced">
10406 %5C%20a(bc)*%5C%2C%20a%5C%3Cyz%5C%3E%5C%3B%5C%20
10407 </literallayout>
10408 <para>
10409 Removing the URL quoting, this is (with a trailing space):
10410 </para>
10411 <literallayout class="monospaced">
10412 \ a(bc)*\, a\&lt;yz\&gt;\;\
10413 </literallayout>
10414 <para>
10415 There are some further comments about quoting in the section on LDAP
10416 authentication below.
10417 </para>
10418 </section>
10419 <section id="SECID69">
10420 <title>LDAP connections</title>
10421 <para>
10422 <indexterm role="concept">
10423 <primary>LDAP</primary>
10424 <secondary>connections</secondary>
10425 </indexterm>
10426 The connection to an LDAP server may either be over TCP/IP, or, when OpenLDAP
10427 is in use, via a Unix domain socket. The example given above does not specify
10428 an LDAP server. A server that is reached by TCP/IP can be specified in a query
10429 by starting it with
10430 </para>
10431 <literallayout class="monospaced">
10432 ldap://&lt;hostname&gt;:&lt;port&gt;/...
10433 </literallayout>
10434 <para>
10435 If the port (and preceding colon) are omitted, the standard LDAP port (389) is
10436 used. When no server is specified in a query, a list of default servers is
10437 taken from the <option>ldap_default_servers</option> configuration option. This supplies a
10438 colon-separated list of servers which are tried in turn until one successfully
10439 handles a query, or there is a serious error. Successful handling either
10440 returns the requested data, or indicates that it does not exist. Serious errors
10441 are syntactical, or multiple values when only a single value is expected.
10442 Errors which cause the next server to be tried are connection failures, bind
10443 failures, and timeouts.
10444 </para>
10445 <para>
10446 For each server name in the list, a port number can be given. The standard way
10447 of specifying a host and port is to use a colon separator (RFC 1738). Because
10448 <option>ldap_default_servers</option> is a colon-separated list, such colons have to be
10449 doubled. For example
10450 </para>
10451 <literallayout class="monospaced">
10452 ldap_default_servers = ldap1.example.com::145:ldap2.example.com
10453 </literallayout>
10454 <para>
10455 If <option>ldap_default_servers</option> is unset, a URL with no server name is passed
10456 to the LDAP library with no server name, and the library&#x2019;s default (normally
10457 the local host) is used.
10458 </para>
10459 <para>
10460 If you are using the OpenLDAP library, you can connect to an LDAP server using
10461 a Unix domain socket instead of a TCP/IP connection. This is specified by using
10462 <literal>ldapi</literal> instead of <literal>ldap</literal> in LDAP queries. What follows here applies only
10463 to OpenLDAP. If Exim is compiled with a different LDAP library, this feature is
10464 not available.
10465 </para>
10466 <para>
10467 For this type of connection, instead of a host name for the server, a pathname
10468 for the socket is required, and the port number is not relevant. The pathname
10469 can be specified either as an item in <option>ldap_default_servers</option>, or inline in
10470 the query. In the former case, you can have settings such as
10471 </para>
10472 <literallayout class="monospaced">
10473 ldap_default_servers = /tmp/ldap.sock : backup.ldap.your.domain
10474 </literallayout>
10475 <para>
10476 When the pathname is given in the query, you have to escape the slashes as
10477 <literal>%2F</literal> to fit in with the LDAP URL syntax. For example:
10478 </para>
10479 <literallayout class="monospaced">
10480 ${lookup ldap {ldapi://%2Ftmp%2Fldap.sock/o=...
10481 </literallayout>
10482 <para>
10483 When Exim processes an LDAP lookup and finds that the <quote>hostname</quote> is really
10484 a pathname, it uses the Unix domain socket code, even if the query actually
10485 specifies <literal>ldap</literal> or <literal>ldaps</literal>. In particular, no encryption is used for a
10486 socket connection. This behaviour means that you can use a setting of
10487 <option>ldap_default_servers</option> such as in the example above with traditional <literal>ldap</literal>
10488 or <literal>ldaps</literal> queries, and it will work. First, Exim tries a connection via
10489 the Unix domain socket; if that fails, it tries a TCP/IP connection to the
10490 backup host.
10491 </para>
10492 <para>
10493 If an explicit <literal>ldapi</literal> type is given in a query when a host name is
10494 specified, an error is diagnosed. However, if there are more items in
10495 <option>ldap_default_servers</option>, they are tried. In other words:
10496 </para>
10497 <itemizedlist>
10498 <listitem>
10499 <para>
10500 Using a pathname with <literal>ldap</literal> or <literal>ldaps</literal> forces the use of the Unix domain
10501 interface.
10502 </para>
10503 </listitem>
10504 <listitem>
10505 <para>
10506 Using <literal>ldapi</literal> with a host name causes an error.
10507 </para>
10508 </listitem>
10509 </itemizedlist>
10510 <para>
10511 Using <literal>ldapi</literal> with no host or path in the query, and no setting of
10512 <option>ldap_default_servers</option>, does whatever the library does by default.
10513 </para>
10514 </section>
10515 <section id="SECID70">
10516 <title>LDAP authentication and control information</title>
10517 <para>
10518 <indexterm role="concept">
10519 <primary>LDAP</primary>
10520 <secondary>authentication</secondary>
10521 </indexterm>
10522 The LDAP URL syntax provides no way of passing authentication and other control
10523 information to the server. To make this possible, the URL in an LDAP query may
10524 be preceded by any number of &lt;<emphasis>name</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt; settings, separated by
10525 spaces. If a value contains spaces it must be enclosed in double quotes, and
10526 when double quotes are used, backslash is interpreted in the usual way inside
10527 them. The following names are recognized:
10528 </para>
10529 <literallayout>
10530 <literal>DEREFERENCE</literal>  set the dereferencing parameter
10531 <literal>NETTIME    </literal>  set a timeout for a network operation
10532 <literal>USER       </literal>  set the DN, for authenticating the LDAP bind
10533 <literal>PASS       </literal>  set the password, likewise
10534 <literal>REFERRALS  </literal>  set the referrals parameter
10535 <literal>SIZE       </literal>  set the limit for the number of entries returned
10536 <literal>TIME       </literal>  set the maximum waiting time for a query
10537 </literallayout>
10538 <para>
10539 The value of the DEREFERENCE parameter must be one of the words <quote>never</quote>,
10540 <quote>searching</quote>, <quote>finding</quote>, or <quote>always</quote>. The value of the REFERRALS parameter
10541 must be <quote>follow</quote> (the default) or <quote>nofollow</quote>. The latter stops the LDAP
10542 library from trying to follow referrals issued by the LDAP server.
10543 </para>
10544 <para>
10545 The name CONNECT is an obsolete name for NETTIME, retained for
10546 backwards compatibility. This timeout (specified as a number of seconds) is
10547 enforced from the client end for operations that can be carried out over a
10548 network. Specifically, it applies to network connections and calls to the
10549 <emphasis>ldap_result()</emphasis> function. If the value is greater than zero, it is used if
10550 LDAP_OPT_NETWORK_TIMEOUT is defined in the LDAP headers (OpenLDAP), or
10551 if LDAP_X_OPT_CONNECT_TIMEOUT is defined in the LDAP headers (Netscape
10552 SDK 4.1). A value of zero forces an explicit setting of <quote>no timeout</quote> for
10553 Netscape SDK; for OpenLDAP no action is taken.
10554 </para>
10555 <para>
10556 The TIME parameter (also a number of seconds) is passed to the server to
10557 set a server-side limit on the time taken to complete a search.
10558 </para>
10559 <para>
10560 Here is an example of an LDAP query in an Exim lookup that uses some of these
10561 values. This is a single line, folded to fit on the page:
10562 </para>
10563 <literallayout class="monospaced">
10564 ${lookup ldap
10565   {user="cn=manager,o=University of Cambridge,c=UK" pass=secret
10566   ldap:///o=University%20of%20Cambridge,c=UK?sn?sub?(cn=foo)}
10567   {$value}fail}
10568 </literallayout>
10569 <para>
10570 The encoding of spaces as <literal>%20</literal> is a URL thing which should not be done for
10571 any of the auxiliary data. Exim configuration settings that include lookups
10572 which contain password information should be preceded by <quote>hide</quote> to prevent
10573 non-admin users from using the <option>-bP</option> option to see their values.
10574 </para>
10575 <para>
10576 The auxiliary data items may be given in any order. The default is no
10577 connection timeout (the system timeout is used), no user or password, no limit
10578 on the number of entries returned, and no time limit on queries.
10579 </para>
10580 <para>
10581 When a DN is quoted in the USER= setting for LDAP authentication, Exim
10582 removes any URL quoting that it may contain before passing it LDAP. Apparently
10583 some libraries do this for themselves, but some do not. Removing the URL
10584 quoting has two advantages:
10585 </para>
10586 <itemizedlist>
10587 <listitem>
10588 <para>
10589 It makes it possible to use the same <option>quote_ldap_dn</option> expansion for USER=
10590 DNs as with DNs inside actual queries.
10591 </para>
10592 </listitem>
10593 <listitem>
10594 <para>
10595 It permits spaces inside USER= DNs.
10596 </para>
10597 </listitem>
10598 </itemizedlist>
10599 <para>
10600 For example, a setting such as
10601 </para>
10602 <literallayout class="monospaced">
10603 USER=cn=${quote_ldap_dn:$1}
10604 </literallayout>
10605 <para>
10606 should work even if <varname>$1</varname> contains spaces.
10607 </para>
10608 <para>
10609 Expanded data for the PASS= value should be quoted using the <option>quote</option>
10610 expansion operator, rather than the LDAP quote operators. The only reason this
10611 field needs quoting is to ensure that it conforms to the Exim syntax, which
10612 does not allow unquoted spaces. For example:
10613 </para>
10614 <literallayout class="monospaced">
10615 PASS=${quote:$3}
10616 </literallayout>
10617 <para>
10618 The LDAP authentication mechanism can be used to check passwords as part of
10619 SMTP authentication. See the <option>ldapauth</option> expansion string condition in chapter
10620 <xref linkend="CHAPexpand"/>.
10621 </para>
10622 </section>
10623 <section id="SECID71">
10624 <title>Format of data returned by LDAP</title>
10625 <para>
10626 <indexterm role="concept">
10627 <primary>LDAP</primary>
10628 <secondary>returned data formats</secondary>
10629 </indexterm>
10630 The <command>ldapdn</command> lookup type returns the Distinguished Name from a single entry
10631 as a sequence of values, for example
10632 </para>
10633 <literallayout class="monospaced">
10634 cn=manager, o=University of Cambridge, c=UK
10635 </literallayout>
10636 <para>
10637 The <command>ldap</command> lookup type generates an error if more than one entry matches the
10638 search filter, whereas <command>ldapm</command> permits this case, and inserts a newline in
10639 the result between the data from different entries. It is possible for multiple
10640 values to be returned for both <command>ldap</command> and <command>ldapm</command>, but in the former case
10641 you know that whatever values are returned all came from a single entry in the
10642 directory.
10643 </para>
10644 <para>
10645 In the common case where you specify a single attribute in your LDAP query, the
10646 result is not quoted, and does not contain the attribute name. If the attribute
10647 has multiple values, they are separated by commas.
10648 </para>
10649 <para>
10650 If you specify multiple attributes, the result contains space-separated, quoted
10651 strings, each preceded by the attribute name and an equals sign. Within the
10652 quotes, the quote character, backslash, and newline are escaped with
10653 backslashes, and commas are used to separate multiple values for the attribute.
10654 Apart from the escaping, the string within quotes takes the same form as the
10655 output when a single attribute is requested. Specifying no attributes is the
10656 same as specifying all of an entry&#x2019;s attributes.
10657 </para>
10658 <para>
10659 Here are some examples of the output format. The first line of each pair is an
10660 LDAP query, and the second is the data that is returned. The attribute called
10661 <option>attr1</option> has two values, whereas <option>attr2</option> has only one value:
10662 </para>
10663 <literallayout class="monospaced">
10664 ldap:///o=base?attr1?sub?(uid=fred)
10665 value1.1, value1.2
10666
10667 ldap:///o=base?attr2?sub?(uid=fred)
10668 value two
10669
10670 ldap:///o=base?attr1,attr2?sub?(uid=fred)
10671 attr1="value1.1, value1.2" attr2="value two"
10672
10673 ldap:///o=base??sub?(uid=fred)
10674 objectClass="top" attr1="value1.1, value1.2" attr2="value two"
10675 </literallayout>
10676 <para>
10677 The <option>extract</option> operator in string expansions can be used to pick out
10678 individual fields from data that consists of <emphasis>key</emphasis>=<emphasis>value</emphasis> pairs. You can
10679 make use of Exim&#x2019;s <option>-be</option> option to run expansion tests and thereby check the
10680 results of LDAP lookups.
10681 </para>
10682 </section>
10683 <section id="SECTnisplus">
10684 <title>More about NIS+</title>
10685 <para>
10686 <indexterm role="concept">
10687 <primary>NIS+ lookup type</primary>
10688 </indexterm>
10689 <indexterm role="concept">
10690 <primary>lookup</primary>
10691 <secondary>NIS+</secondary>
10692 </indexterm>
10693 NIS+ queries consist of a NIS+ <emphasis>indexed name</emphasis> followed by an optional colon
10694 and field name. If this is given, the result of a successful query is the
10695 contents of the named field; otherwise the result consists of a concatenation
10696 of <emphasis>field-name=field-value</emphasis> pairs, separated by spaces. Empty values and
10697 values containing spaces are quoted. For example, the query
10698 </para>
10699 <literallayout class="monospaced">
10700 [name=mg1456],passwd.org_dir
10701 </literallayout>
10702 <para>
10703 might return the string
10704 </para>
10705 <literallayout class="monospaced">
10706 name=mg1456 passwd="" uid=999 gid=999 gcos="Martin Guerre"
10707 home=/home/mg1456 shell=/bin/bash shadow=""
10708 </literallayout>
10709 <para>
10710 (split over two lines here to fit on the page), whereas
10711 </para>
10712 <literallayout class="monospaced">
10713 [name=mg1456],passwd.org_dir:gcos
10714 </literallayout>
10715 <para>
10716 would just return
10717 </para>
10718 <literallayout class="monospaced">
10719 Martin Guerre
10720 </literallayout>
10721 <para>
10722 with no quotes. A NIS+ lookup fails if NIS+ returns more than one table entry
10723 for the given indexed key. The effect of the <option>quote_nisplus</option> expansion
10724 operator is to double any quote characters within the text.
10725 </para>
10726 </section>
10727 <section id="SECTsql">
10728 <title>SQL lookups</title>
10729 <para>
10730 <indexterm role="concept">
10731 <primary>SQL lookup types</primary>
10732 </indexterm>
10733 <indexterm role="concept">
10734 <primary>MySQL</primary>
10735 <secondary>lookup type</secondary>
10736 </indexterm>
10737 <indexterm role="concept">
10738 <primary>PostgreSQL lookup type</primary>
10739 </indexterm>
10740 <indexterm role="concept">
10741 <primary>lookup</primary>
10742 <secondary>MySQL</secondary>
10743 </indexterm>
10744 <indexterm role="concept">
10745 <primary>lookup</primary>
10746 <secondary>PostgreSQL</secondary>
10747 </indexterm>
10748 <indexterm role="concept">
10749 <primary>Oracle</primary>
10750 <secondary>lookup type</secondary>
10751 </indexterm>
10752 <indexterm role="concept">
10753 <primary>lookup</primary>
10754 <secondary>Oracle</secondary>
10755 </indexterm>
10756 <indexterm role="concept">
10757 <primary>InterBase lookup type</primary>
10758 </indexterm>
10759 <indexterm role="concept">
10760 <primary>lookup</primary>
10761 <secondary>InterBase</secondary>
10762 </indexterm>
10763 Exim can support lookups in InterBase, MySQL, Oracle, PostgreSQL, and SQLite
10764 databases. Queries for these databases contain SQL statements, so an example
10765 might be
10766 </para>
10767 <literallayout class="monospaced">
10768 ${lookup mysql{select mailbox from users where id='userx'}\
10769   {$value}fail}
10770 </literallayout>
10771 <para>
10772 If the result of the query contains more than one field, the data for each
10773 field in the row is returned, preceded by its name, so the result of
10774 </para>
10775 <literallayout class="monospaced">
10776 ${lookup pgsql{select home,name from users where id='userx'}\
10777   {$value}}
10778 </literallayout>
10779 <para>
10780 might be
10781 </para>
10782 <literallayout class="monospaced">
10783 home=/home/userx name="Mister X"
10784 </literallayout>
10785 <para>
10786 Empty values and values containing spaces are double quoted, with embedded
10787 quotes escaped by a backslash. If the result of the query contains just one
10788 field, the value is passed back verbatim, without a field name, for example:
10789 </para>
10790 <literallayout class="monospaced">
10791 Mister X
10792 </literallayout>
10793 <para>
10794 If the result of the query yields more than one row, it is all concatenated,
10795 with a newline between the data for each row.
10796 </para>
10797 </section>
10798 <section id="SECID72">
10799 <title>More about MySQL, PostgreSQL, Oracle, and InterBase</title>
10800 <para>
10801 <indexterm role="concept">
10802 <primary>MySQL</primary>
10803 <secondary>lookup type</secondary>
10804 </indexterm>
10805 <indexterm role="concept">
10806 <primary>PostgreSQL lookup type</primary>
10807 </indexterm>
10808 <indexterm role="concept">
10809 <primary>lookup</primary>
10810 <secondary>MySQL</secondary>
10811 </indexterm>
10812 <indexterm role="concept">
10813 <primary>lookup</primary>
10814 <secondary>PostgreSQL</secondary>
10815 </indexterm>
10816 <indexterm role="concept">
10817 <primary>Oracle</primary>
10818 <secondary>lookup type</secondary>
10819 </indexterm>
10820 <indexterm role="concept">
10821 <primary>lookup</primary>
10822 <secondary>Oracle</secondary>
10823 </indexterm>
10824 <indexterm role="concept">
10825 <primary>InterBase lookup type</primary>
10826 </indexterm>
10827 <indexterm role="concept">
10828 <primary>lookup</primary>
10829 <secondary>InterBase</secondary>
10830 </indexterm>
10831 If any MySQL, PostgreSQL, Oracle, or InterBase lookups are used, the
10832 <option>mysql_servers</option>, <option>pgsql_servers</option>, <option>oracle_servers</option>, or <option>ibase_servers</option>
10833 option (as appropriate) must be set to a colon-separated list of server
10834 information.
10835 (For MySQL and PostgreSQL only, the global option need not be set if all
10836 queries contain their own server information &ndash; see section
10837 <xref linkend="SECTspeserque"/>.) Each item in the list is a slash-separated list of four
10838 items: host name, database name, user name, and password. In the case of
10839 Oracle, the host name field is used for the <quote>service name</quote>, and the database
10840 name field is not used and should be empty. For example:
10841 </para>
10842 <literallayout class="monospaced">
10843 hide oracle_servers = oracle.plc.example//userx/abcdwxyz
10844 </literallayout>
10845 <para>
10846 Because password data is sensitive, you should always precede the setting with
10847 <quote>hide</quote>, to prevent non-admin users from obtaining the setting via the <option>-bP</option>
10848 option. Here is an example where two MySQL servers are listed:
10849 </para>
10850 <literallayout class="monospaced">
10851 hide mysql_servers = localhost/users/root/secret:\
10852                      otherhost/users/root/othersecret
10853 </literallayout>
10854 <para>
10855 For MySQL and PostgreSQL, a host may be specified as &lt;<emphasis>name</emphasis>&gt;:&lt;<emphasis>port</emphasis>&gt; but
10856 because this is a colon-separated list, the colon has to be doubled. For each
10857 query, these parameter groups are tried in order until a connection is made and
10858 a query is successfully processed. The result of a query may be that no data is
10859 found, but that is still a successful query. In other words, the list of
10860 servers provides a backup facility, not a list of different places to look.
10861 </para>
10862 <para>
10863 The <option>quote_mysql</option>, <option>quote_pgsql</option>, and <option>quote_oracle</option> expansion operators
10864 convert newline, tab, carriage return, and backspace to \n, \t, \r, and \b
10865 respectively, and the characters single-quote, double-quote, and backslash
10866 itself are escaped with backslashes. The <option>quote_pgsql</option> expansion operator, in
10867 addition, escapes the percent and underscore characters. This cannot be done
10868 for MySQL because these escapes are not recognized in contexts where these
10869 characters are not special.
10870 </para>
10871 </section>
10872 <section id="SECTspeserque">
10873 <title>Specifying the server in the query</title>
10874 <para>
10875 For MySQL and PostgreSQL lookups (but not currently for Oracle and InterBase),
10876 it is possible to specify a list of servers with an individual query. This is
10877 done by starting the query with
10878 </para>
10879 <literallayout>
10880 <literal>servers=</literal><emphasis>server1:server2:server3:...</emphasis><literal>;</literal>
10881 </literallayout>
10882 <para>
10883 Each item in the list may take one of two forms:
10884 </para>
10885 <orderedlist numeration="arabic">
10886 <listitem>
10887 <para>
10888 If it contains no slashes it is assumed to be just a host name. The appropriate
10889 global option (<option>mysql_servers</option> or <option>pgsql_servers</option>) is searched for a host
10890 of the same name, and the remaining parameters (database, user, password) are
10891 taken from there.
10892 </para>
10893 </listitem>
10894 <listitem>
10895 <para>
10896 If it contains any slashes, it is taken as a complete parameter set.
10897 </para>
10898 </listitem>
10899 </orderedlist>
10900 <para>
10901 The list of servers is used in exactly the same way as the global list.
10902 Once a connection to a server has happened and a query has been
10903 successfully executed, processing of the lookup ceases.
10904 </para>
10905 <para>
10906 This feature is intended for use in master/slave situations where updates
10907 are occurring and you want to update the master rather than a slave. If the
10908 master is in the list as a backup for reading, you might have a global setting
10909 like this:
10910 </para>
10911 <literallayout class="monospaced">
10912 mysql_servers = slave1/db/name/pw:\
10913                 slave2/db/name/pw:\
10914                 master/db/name/pw
10915 </literallayout>
10916 <para>
10917 In an updating lookup, you could then write:
10918 </para>
10919 <literallayout class="monospaced">
10920 ${lookup mysql{servers=master; UPDATE ...} }
10921 </literallayout>
10922 <para>
10923 That query would then be sent only to the master server. If, on the other hand,
10924 the master is not to be used for reading, and so is not present in the global
10925 option, you can still update it by a query of this form:
10926 </para>
10927 <literallayout class="monospaced">
10928 ${lookup pgsql{servers=master/db/name/pw; UPDATE ...} }
10929 </literallayout>
10930 </section>
10931 <section id="SECID73">
10932 <title>Special MySQL features</title>
10933 <para>
10934 For MySQL, an empty host name or the use of <quote>localhost</quote> in <option>mysql_servers</option>
10935 causes a connection to the server on the local host by means of a Unix domain
10936 socket. An alternate socket can be specified in parentheses. The full syntax of
10937 each item in <option>mysql_servers</option> is:
10938 </para>
10939 <literallayout>
10940 &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;
10941 </literallayout>
10942 <para>
10943 Any of the three sub-parts of the first field can be omitted. For normal use on
10944 the local host it can be left blank or set to just <quote>localhost</quote>.
10945 </para>
10946 <para>
10947 No database need be supplied &ndash; but if it is absent here, it must be given in
10948 the queries.
10949 </para>
10950 <para>
10951 If a MySQL query is issued that does not request any data (an insert, update,
10952 or delete command), the result of the lookup is the number of rows affected.
10953 </para>
10954 <para>
10955 <emphasis role="bold">Warning</emphasis>: This can be misleading. If an update does not actually change
10956 anything (for example, setting a field to the value it already has), the result
10957 is zero because no rows are affected.
10958 </para>
10959 </section>
10960 <section id="SECID74">
10961 <title>Special PostgreSQL features</title>
10962 <para>
10963 PostgreSQL lookups can also use Unix domain socket connections to the database.
10964 This is usually faster and costs less CPU time than a TCP/IP connection.
10965 However it can be used only if the mail server runs on the same machine as the
10966 database server. A configuration line for PostgreSQL via Unix domain sockets
10967 looks like this:
10968 </para>
10969 <literallayout class="monospaced">
10970 hide pgsql_servers = (/tmp/.s.PGSQL.5432)/db/user/password : ...
10971 </literallayout>
10972 <para>
10973 In other words, instead of supplying a host name, a path to the socket is
10974 given. The path name is enclosed in parentheses so that its slashes aren&#x2019;t
10975 visually confused with the delimiters for the other server parameters.
10976 </para>
10977 <para>
10978 If a PostgreSQL query is issued that does not request any data (an insert,
10979 update, or delete command), the result of the lookup is the number of rows
10980 affected.
10981 </para>
10982 </section>
10983 <section id="SECTsqlite">
10984 <title>More about SQLite</title>
10985 <para>
10986 <indexterm role="concept">
10987 <primary>lookup</primary>
10988 <secondary>SQLite</secondary>
10989 </indexterm>
10990 <indexterm role="concept">
10991 <primary>sqlite lookup type</primary>
10992 </indexterm>
10993 SQLite is different to the other SQL lookups because a file name is required in
10994 addition to the SQL query. An SQLite database is a single file, and there is no
10995 daemon as in the other SQL databases. The interface to Exim requires the name
10996 of the file, as an absolute path, to be given at the start of the query. It is
10997 separated from the query by white space. This means that the path name cannot
10998 contain white space. Here is a lookup expansion example:
10999 </para>
11000 <literallayout class="monospaced">
11001 ${lookup sqlite {/some/thing/sqlitedb \
11002   select name from aliases where id='userx';}}
11003 </literallayout>
11004 <para>
11005 In a list, the syntax is similar. For example:
11006 </para>
11007 <literallayout class="monospaced">
11008 domainlist relay_domains = sqlite;/some/thing/sqlitedb \
11009    select * from relays where ip='$sender_host_address';
11010 </literallayout>
11011 <para>
11012 The only character affected by the <option>quote_sqlite</option> operator is a single
11013 quote, which it doubles.
11014 </para>
11015 <para>
11016 The SQLite library handles multiple simultaneous accesses to the database
11017 internally. Multiple readers are permitted, but only one process can
11018 update at once. Attempts to access the database while it is being updated
11019 are rejected after a timeout period, during which the SQLite library
11020 waits for the lock to be released. In Exim, the default timeout is set
11021 to 5 seconds, but it can be changed by means of the <option>sqlite_lock_timeout</option>
11022 option.
11023 <indexterm role="concept" startref="IIDfidalo1" class="endofrange"/>
11024 <indexterm role="concept" startref="IIDfidalo2" class="endofrange"/>
11025 </para>
11026 </section>
11027 </chapter>
11028
11029 <chapter id="CHAPdomhosaddlists">
11030 <title>Domain, host, address, and local part lists</title>
11031 <titleabbrev>Domain, host, and address lists</titleabbrev>
11032 <para>
11033 <indexterm role="concept" id="IIDdohoadli" class="startofrange">
11034 <primary>lists of domains; hosts; etc.</primary>
11035 </indexterm>
11036 A number of Exim configuration options contain lists of domains, hosts,
11037 email addresses, or local parts. For example, the <option>hold_domains</option> option
11038 contains a list of domains whose delivery is currently suspended. These lists
11039 are also used as data in ACL statements (see chapter <xref linkend="CHAPACL"/>), and as
11040 arguments to expansion conditions such as <option>match_domain</option>.
11041 </para>
11042 <para>
11043 Each item in one of these lists is a pattern to be matched against a domain,
11044 host, email address, or local part, respectively. In the sections below, the
11045 different types of pattern for each case are described, but first we cover some
11046 general facilities that apply to all four kinds of list.
11047 </para>
11048 <section id="SECID75">
11049 <title>Expansion of lists</title>
11050 <para>
11051 <indexterm role="concept">
11052 <primary>expansion</primary>
11053 <secondary>of lists</secondary>
11054 </indexterm>
11055 Each list is expanded as a single string before it is used. The result of
11056 expansion must be a list, possibly containing empty items, which is split up
11057 into separate items for matching. By default, colon is the separator character,
11058 but this can be varied if necessary. See sections <xref linkend="SECTlistconstruct"/> and
11059 <xref linkend="SECTempitelis"/> for details of the list syntax; the second of these
11060 discusses the way to specify empty list items.
11061 </para>
11062 <para>
11063 If the string expansion is forced to fail, Exim behaves as if the item it is
11064 testing (domain, host, address, or local part) is not in the list. Other
11065 expansion failures cause temporary errors.
11066 </para>
11067 <para>
11068 If an item in a list is a regular expression, backslashes, dollars and possibly
11069 other special characters in the expression must be protected against
11070 misinterpretation by the string expander. The easiest way to do this is to use
11071 the <literal>\N</literal> expansion feature to indicate that the contents of the regular
11072 expression should not be expanded. For example, in an ACL you might have:
11073 </para>
11074 <literallayout class="monospaced">
11075 deny senders = \N^\d{8}\w@.*\.baddomain\.example$\N : \
11076                ${lookup{$domain}lsearch{/badsenders/bydomain}}
11077 </literallayout>
11078 <para>
11079 The first item is a regular expression that is protected from expansion by
11080 <literal>\N</literal>, whereas the second uses the expansion to obtain a list of unwanted
11081 senders based on the receiving domain.
11082 </para>
11083 </section>
11084 <section id="SECID76">
11085 <title>Negated items in lists</title>
11086 <para>
11087 <indexterm role="concept">
11088 <primary>list</primary>
11089 <secondary>negation</secondary>
11090 </indexterm>
11091 <indexterm role="concept">
11092 <primary>negation</primary>
11093 <secondary>in lists</secondary>
11094 </indexterm>
11095 Items in a list may be positive or negative. Negative items are indicated by a
11096 leading exclamation mark, which may be followed by optional white space. A list
11097 defines a set of items (domains, etc). When Exim processes one of these lists,
11098 it is trying to find out whether a domain, host, address, or local part
11099 (respectively) is in the set that is defined by the list. It works like this:
11100 </para>
11101 <para>
11102 The list is scanned from left to right. If a positive item is matched, the
11103 subject that is being checked is in the set; if a negative item is matched, the
11104 subject is not in the set. If the end of the list is reached without the
11105 subject having matched any of the patterns, it is in the set if the last item
11106 was a negative one, but not if it was a positive one. For example, the list in
11107 </para>
11108 <literallayout class="monospaced">
11109 domainlist relay_domains = !a.b.c : *.b.c
11110 </literallayout>
11111 <para>
11112 matches any domain ending in <emphasis>.b.c</emphasis> except for <emphasis>a.b.c</emphasis>. Domains that match
11113 neither <emphasis>a.b.c</emphasis> nor <emphasis>*.b.c</emphasis> do not match, because the last item in the
11114 list is positive. However, if the setting were
11115 </para>
11116 <literallayout class="monospaced">
11117 domainlist relay_domains = !a.b.c
11118 </literallayout>
11119 <para>
11120 then all domains other than <emphasis>a.b.c</emphasis> would match because the last item in the
11121 list is negative. In other words, a list that ends with a negative item behaves
11122 as if it had an extra item <literal>:*</literal> on the end.
11123 </para>
11124 <para>
11125 Another way of thinking about positive and negative items in lists is to read
11126 the connector as <quote>or</quote> after a positive item and as <quote>and</quote> after a negative
11127 item.
11128 </para>
11129 </section>
11130 <section id="SECTfilnamlis">
11131 <title>File names in lists</title>
11132 <para>
11133 <indexterm role="concept">
11134 <primary>list</primary>
11135 <secondary>file name in</secondary>
11136 </indexterm>
11137 If an item in a domain, host, address, or local part list is an absolute file
11138 name (beginning with a slash character), each line of the file is read and
11139 processed as if it were an independent item in the list, except that further
11140 file names are not allowed,
11141 and no expansion of the data from the file takes place.
11142 Empty lines in the file are ignored, and the file may also contain comment
11143 lines:
11144 </para>
11145 <itemizedlist>
11146 <listitem>
11147 <para>
11148 For domain and host lists, if a # character appears anywhere in a line of the
11149 file, it and all following characters are ignored.
11150 </para>
11151 </listitem>
11152 <listitem>
11153 <para>
11154 Because local parts may legitimately contain # characters, a comment in an
11155 address list or local part list file is recognized only if # is preceded by
11156 white space or the start of the line. For example:
11157 </para>
11158 <literallayout class="monospaced">
11159 not#comment@x.y.z   # but this is a comment
11160 </literallayout>
11161 </listitem>
11162 </itemizedlist>
11163 <para>
11164 Putting a file name in a list has the same effect as inserting each line of the
11165 file as an item in the list (blank lines and comments excepted). However, there
11166 is one important difference: the file is read each time the list is processed,
11167 so if its contents vary over time, Exim&#x2019;s behaviour changes.
11168 </para>
11169 <para>
11170 If a file name is preceded by an exclamation mark, the sense of any match
11171 within the file is inverted. For example, if
11172 </para>
11173 <literallayout class="monospaced">
11174 hold_domains = !/etc/nohold-domains
11175 </literallayout>
11176 <para>
11177 and the file contains the lines
11178 </para>
11179 <literallayout class="monospaced">
11180 !a.b.c
11181 *.b.c
11182 </literallayout>
11183 <para>
11184 then <emphasis>a.b.c</emphasis> is in the set of domains defined by <option>hold_domains</option>, whereas
11185 any domain matching <literal>*.b.c</literal> is not.
11186 </para>
11187 </section>
11188 <section id="SECID77">
11189 <title>An lsearch file is not an out-of-line list</title>
11190 <para>
11191 As will be described in the sections that follow, lookups can be used in lists
11192 to provide indexed methods of checking list membership. There has been some
11193 confusion about the way <command>lsearch</command> lookups work in lists. Because
11194 an <command>lsearch</command> file contains plain text and is scanned sequentially, it is
11195 sometimes thought that it is allowed to contain wild cards and other kinds of
11196 non-constant pattern. This is not the case. The keys in an <command>lsearch</command> file are
11197 always fixed strings, just as for any other single-key lookup type.
11198 </para>
11199 <para>
11200 If you want to use a file to contain wild-card patterns that form part of a
11201 list, just give the file name on its own, without a search type, as described
11202 in the previous section. You could also use the <command>wildlsearch</command> or
11203 <command>nwildlsearch</command>, but there is no advantage in doing this.
11204 </para>
11205 </section>
11206 <section id="SECTnamedlists">
11207 <title>Named lists</title>
11208 <para>
11209 <indexterm role="concept">
11210 <primary>named lists</primary>
11211 </indexterm>
11212 <indexterm role="concept">
11213 <primary>list</primary>
11214 <secondary>named</secondary>
11215 </indexterm>
11216 A list of domains, hosts, email addresses, or local parts can be given a name
11217 which is then used to refer to the list elsewhere in the configuration. This is
11218 particularly convenient if the same list is required in several different
11219 places. It also allows lists to be given meaningful names, which can improve
11220 the readability of the configuration. For example, it is conventional to define
11221 a domain list called <emphasis>local_domains</emphasis> for all the domains that are handled
11222 locally on a host, using a configuration line such as
11223 </para>
11224 <literallayout class="monospaced">
11225 domainlist local_domains = localhost:my.dom.example
11226 </literallayout>
11227 <para>
11228 Named lists are referenced by giving their name preceded by a plus sign, so,
11229 for example, a router that is intended to handle local domains would be
11230 configured with the line
11231 </para>
11232 <literallayout class="monospaced">
11233 domains = +local_domains
11234 </literallayout>
11235 <para>
11236 The first router in a configuration is often one that handles all domains
11237 except the local ones, using a configuration with a negated item like this:
11238 </para>
11239 <literallayout class="monospaced">
11240 dnslookup:
11241   driver = dnslookup
11242   domains = ! +local_domains
11243   transport = remote_smtp
11244   no_more
11245 </literallayout>
11246 <para>
11247 The four kinds of named list are created by configuration lines starting with
11248 the words <option>domainlist</option>, <option>hostlist</option>, <option>addresslist</option>, or <option>localpartlist</option>,
11249 respectively. Then there follows the name that you are defining, followed by an
11250 equals sign and the list itself. For example:
11251 </para>
11252 <literallayout class="monospaced">
11253 hostlist    relay_hosts = 192.168.23.0/24 : my.friend.example
11254 addresslist bad_senders = cdb;/etc/badsenders
11255 </literallayout>
11256 <para>
11257 A named list may refer to other named lists:
11258 </para>
11259 <literallayout class="monospaced">
11260 domainlist  dom1 = first.example : second.example
11261 domainlist  dom2 = +dom1 : third.example
11262 domainlist  dom3 = fourth.example : +dom2 : fifth.example
11263 </literallayout>
11264 <para>
11265 <emphasis role="bold">Warning</emphasis>: If the last item in a referenced list is a negative one, the
11266 effect may not be what you intended, because the negation does not propagate
11267 out to the higher level. For example, consider:
11268 </para>
11269 <literallayout class="monospaced">
11270 domainlist  dom1 = !a.b
11271 domainlist  dom2 = +dom1 : *.b
11272 </literallayout>
11273 <para>
11274 The second list specifies <quote>either in the <option>dom1</option> list or <emphasis>*.b</emphasis></quote>. The first
11275 list specifies just <quote>not <emphasis>a.b</emphasis></quote>, so the domain <emphasis>x.y</emphasis> matches it. That
11276 means it matches the second list as well. The effect is not the same as
11277 </para>
11278 <literallayout class="monospaced">
11279 domainlist  dom2 = !a.b : *.b
11280 </literallayout>
11281 <para>
11282 where <emphasis>x.y</emphasis> does not match. It&#x2019;s best to avoid negation altogether in
11283 referenced lists if you can.
11284 </para>
11285 <para>
11286 Named lists may have a performance advantage. When Exim is routing an
11287 address or checking an incoming message, it caches the result of tests on named
11288 lists. So, if you have a setting such as
11289 </para>
11290 <literallayout class="monospaced">
11291 domains = +local_domains
11292 </literallayout>
11293 <para>
11294 on several of your routers
11295 or in several ACL statements,
11296 the actual test is done only for the first one. However, the caching works only
11297 if there are no expansions within the list itself or any sublists that it
11298 references. In other words, caching happens only for lists that are known to be
11299 the same each time they are referenced.
11300 </para>
11301 <para>
11302 By default, there may be up to 16 named lists of each type. This limit can be
11303 extended by changing a compile-time variable. The use of domain and host lists
11304 is recommended for concepts such as local domains, relay domains, and relay
11305 hosts. The default configuration is set up like this.
11306 </para>
11307 </section>
11308 <section id="SECID78">
11309 <title>Named lists compared with macros</title>
11310 <para>
11311 <indexterm role="concept">
11312 <primary>list</primary>
11313 <secondary>named compared with macro</secondary>
11314 </indexterm>
11315 <indexterm role="concept">
11316 <primary>macro</primary>
11317 <secondary>compared with named list</secondary>
11318 </indexterm>
11319 At first sight, named lists might seem to be no different from macros in the
11320 configuration file. However, macros are just textual substitutions. If you
11321 write
11322 </para>
11323 <literallayout class="monospaced">
11324 ALIST = host1 : host2
11325 auth_advertise_hosts = !ALIST
11326 </literallayout>
11327 <para>
11328 it probably won&#x2019;t do what you want, because that is exactly the same as
11329 </para>
11330 <literallayout class="monospaced">
11331 auth_advertise_hosts = !host1 : host2
11332 </literallayout>
11333 <para>
11334 Notice that the second host name is not negated. However, if you use a host
11335 list, and write
11336 </para>
11337 <literallayout class="monospaced">
11338 hostlist alist = host1 : host2
11339 auth_advertise_hosts = ! +alist
11340 </literallayout>
11341 <para>
11342 the negation applies to the whole list, and so that is equivalent to
11343 </para>
11344 <literallayout class="monospaced">
11345 auth_advertise_hosts = !host1 : !host2
11346 </literallayout>
11347 </section>
11348 <section id="SECID79">
11349 <title>Named list caching</title>
11350 <para>
11351 <indexterm role="concept">
11352 <primary>list</primary>
11353 <secondary>caching of named</secondary>
11354 </indexterm>
11355 <indexterm role="concept">
11356 <primary>caching</primary>
11357 <secondary>named lists</secondary>
11358 </indexterm>
11359 While processing a message, Exim caches the result of checking a named list if
11360 it is sure that the list is the same each time. In practice, this means that
11361 the cache operates only if the list contains no $ characters, which guarantees
11362 that it will not change when it is expanded. Sometimes, however, you may have
11363 an expanded list that you know will be the same each time within a given
11364 message. For example:
11365 </para>
11366 <literallayout class="monospaced">
11367 domainlist special_domains = \
11368            ${lookup{$sender_host_address}cdb{/some/file}}
11369 </literallayout>
11370 <para>
11371 This provides a list of domains that depends only on the sending host&#x2019;s IP
11372 address. If this domain list is referenced a number of times (for example,
11373 in several ACL lines, or in several routers) the result of the check is not
11374 cached by default, because Exim does not know that it is going to be the
11375 same list each time.
11376 </para>
11377 <para>
11378 By appending <literal>_cache</literal> to <literal>domainlist</literal> you can tell Exim to go ahead and
11379 cache the result anyway. For example:
11380 </para>
11381 <literallayout class="monospaced">
11382 domainlist_cache special_domains = ${lookup{...
11383 </literallayout>
11384 <para>
11385 If you do this, you should be absolutely sure that caching is going to do
11386 the right thing in all cases. When in doubt, leave it out.
11387 </para>
11388 </section>
11389 <section id="SECTdomainlist">
11390 <title>Domain lists</title>
11391 <para>
11392 <indexterm role="concept">
11393 <primary>domain list</primary>
11394 <secondary>patterns for</secondary>
11395 </indexterm>
11396 <indexterm role="concept">
11397 <primary>list</primary>
11398 <secondary>domain list</secondary>
11399 </indexterm>
11400 Domain lists contain patterns that are to be matched against a mail domain.
11401 The following types of item may appear in domain lists:
11402 </para>
11403 <itemizedlist>
11404 <listitem>
11405 <para>
11406 <indexterm role="concept">
11407 <primary>primary host name</primary>
11408 </indexterm>
11409 <indexterm role="concept">
11410 <primary>host name</primary>
11411 <secondary>matched in domain list</secondary>
11412 </indexterm>
11413 <indexterm role="option">
11414 <primary><option>primary_hostname</option></primary>
11415 </indexterm>
11416 <indexterm role="concept">
11417 <primary>domain list</primary>
11418 <secondary>matching primary host name</secondary>
11419 </indexterm>
11420 <indexterm role="concept">
11421 <primary>@ in a domain list</primary>
11422 </indexterm>
11423 If a pattern consists of a single @ character, it matches the local host name,
11424 as set by the <option>primary_hostname</option> option (or defaulted). This makes it
11425 possible to use the same configuration file on several different hosts that
11426 differ only in their names.
11427 </para>
11428 </listitem>
11429 <listitem>
11430 <para>
11431 <indexterm role="concept">
11432 <primary>@[] in a domain list</primary>
11433 </indexterm>
11434 <indexterm role="concept">
11435 <primary>domain list</primary>
11436 <secondary>matching local IP interfaces</secondary>
11437 </indexterm>
11438 <indexterm role="concept">
11439 <primary>domain literal</primary>
11440 </indexterm>
11441 If a pattern consists of the string <literal>@[]</literal> it matches an IP address enclosed
11442 in square brackets (as in an email address that contains a domain literal), but
11443 only if that IP address is recognized as local for email routing purposes. The
11444 <option>local_interfaces</option> and <option>extra_local_interfaces</option> options can be used to
11445 control which of a host&#x2019;s several IP addresses are treated as local.
11446 In today&#x2019;s Internet, the use of domain literals is controversial.
11447 </para>
11448 </listitem>
11449 <listitem>
11450 <para>
11451 <indexterm role="concept">
11452 <primary>@mx_any</primary>
11453 </indexterm>
11454 <indexterm role="concept">
11455 <primary>@mx_primary</primary>
11456 </indexterm>
11457 <indexterm role="concept">
11458 <primary>@mx_secondary</primary>
11459 </indexterm>
11460 <indexterm role="concept">
11461 <primary>domain list</primary>
11462 <secondary>matching MX pointers to local host</secondary>
11463 </indexterm>
11464 If a pattern consists of the string <literal>@mx_any</literal> it matches any domain that
11465 has an MX record pointing to the local host or to any host that is listed in
11466 <indexterm role="option">
11467 <primary><option>hosts_treat_as_local</option></primary>
11468 </indexterm>
11469 <option>hosts_treat_as_local</option>. The items <literal>@mx_primary</literal> and <literal>@mx_secondary</literal>
11470 are similar, except that the first matches only when a primary MX target is the
11471 local host, and the second only when no primary MX target is the local host,
11472 but a secondary MX target is. <quote>Primary</quote> means an MX record with the lowest
11473 preference value &ndash; there may of course be more than one of them.
11474 </para>
11475 <para>
11476 The MX lookup that takes place when matching a pattern of this type is
11477 performed with the resolver options for widening names turned off. Thus, for
11478 example, a single-component domain will <emphasis>not</emphasis> be expanded by adding the
11479 resolver&#x2019;s default domain. See the <option>qualify_single</option> and <option>search_parents</option>
11480 options of the <command>dnslookup</command> router for a discussion of domain widening.
11481 </para>
11482 <para>
11483 Sometimes you may want to ignore certain IP addresses when using one of these
11484 patterns. You can specify this by following the pattern with <literal>/ignore=</literal>&lt;<emphasis>ip
11485 list</emphasis>&gt;, where &lt;<emphasis>ip list</emphasis>&gt; is a list of IP addresses. These addresses are
11486 ignored when processing the pattern (compare the <option>ignore_target_hosts</option> option
11487 on a router). For example:
11488 </para>
11489 <literallayout class="monospaced">
11490 domains = @mx_any/ignore=127.0.0.1
11491 </literallayout>
11492 <para>
11493 This example matches any domain that has an MX record pointing to one of
11494 the local host&#x2019;s IP addresses other than 127.0.0.1.
11495 </para>
11496 <para>
11497 The list of IP addresses is in fact processed by the same code that processes
11498 host lists, so it may contain CIDR-coded network specifications and it may also
11499 contain negative items.
11500 </para>
11501 <para>
11502 Because the list of IP addresses is a sublist within a domain list, you have to
11503 be careful about delimiters if there is more than one address. Like any other
11504 list, the default delimiter can be changed. Thus, you might have:
11505 </para>
11506 <literallayout class="monospaced">
11507 domains = @mx_any/ignore=&lt;;127.0.0.1;0.0.0.0 : \
11508           an.other.domain : ...
11509 </literallayout>
11510 <para>
11511 so that the sublist uses semicolons for delimiters. When IPv6 addresses are
11512 involved, it is easiest to change the delimiter for the main list as well:
11513 </para>
11514 <literallayout class="monospaced">
11515 domains = &lt;? @mx_any/ignore=&lt;;127.0.0.1;::1 ? \
11516           an.other.domain ? ...
11517 </literallayout>
11518 </listitem>
11519 <listitem>
11520 <para>
11521 <indexterm role="concept">
11522 <primary>asterisk</primary>
11523 <secondary>in domain list</secondary>
11524 </indexterm>
11525 <indexterm role="concept">
11526 <primary>domain list</primary>
11527 <secondary>asterisk in</secondary>
11528 </indexterm>
11529 <indexterm role="concept">
11530 <primary>domain list</primary>
11531 <secondary>matching <quote>ends with</quote></secondary>
11532 </indexterm>
11533 If a pattern starts with an asterisk, the remaining characters of the pattern
11534 are compared with the terminating characters of the domain. The use of <quote>*</quote> in
11535 domain lists differs from its use in partial matching lookups. In a domain
11536 list, the character following the asterisk need not be a dot, whereas partial
11537 matching works only in terms of dot-separated components. For example, a domain
11538 list item such as <literal>*key.ex</literal> matches <emphasis>donkey.ex</emphasis> as well as
11539 <emphasis>cipher.key.ex</emphasis>.
11540 </para>
11541 </listitem>
11542 <listitem>
11543 <para>
11544 <indexterm role="concept">
11545 <primary>regular expressions</primary>
11546 <secondary>in domain list</secondary>
11547 </indexterm>
11548 <indexterm role="concept">
11549 <primary>domain list</primary>
11550 <secondary>matching regular expression</secondary>
11551 </indexterm>
11552 If a pattern starts with a circumflex character, it is treated as a regular
11553 expression, and matched against the domain using a regular expression matching
11554 function. The circumflex is treated as part of the regular expression.
11555 Email domains are case-independent, so this regular expression match is by
11556 default case-independent, but you can make it case-dependent by starting it
11557 with <literal>(?-i)</literal>. References to descriptions of the syntax of regular expressions
11558 are given in chapter <xref linkend="CHAPregexp"/>.
11559 </para>
11560 <para>
11561 <emphasis role="bold">Warning</emphasis>: Because domain lists are expanded before being processed, you
11562 must escape any backslash and dollar characters in the regular expression, or
11563 use the special <literal>\N</literal> sequence (see chapter <xref linkend="CHAPexpand"/>) to specify that
11564 it is not to be expanded (unless you really do want to build a regular
11565 expression by expansion, of course).
11566 </para>
11567 </listitem>
11568 <listitem>
11569 <para>
11570 <indexterm role="concept">
11571 <primary>lookup</primary>
11572 <secondary>in domain list</secondary>
11573 </indexterm>
11574 <indexterm role="concept">
11575 <primary>domain list</primary>
11576 <secondary>matching by lookup</secondary>
11577 </indexterm>
11578 If a pattern starts with the name of a single-key lookup type followed by a
11579 semicolon (for example, <quote>dbm;</quote> or <quote>lsearch;</quote>), the remainder of the pattern
11580 must be a file name in a suitable format for the lookup type. For example, for
11581 <quote>cdb;</quote> it must be an absolute path:
11582 </para>
11583 <literallayout class="monospaced">
11584 domains = cdb;/etc/mail/local_domains.cdb
11585 </literallayout>
11586 <para>
11587 The appropriate type of lookup is done on the file using the domain name as the
11588 key. In most cases, the data that is looked up is not used; Exim is interested
11589 only in whether or not the key is present in the file. However, when a lookup
11590 is used for the <option>domains</option> option on a router
11591 or a <option>domains</option> condition in an ACL statement, the data is preserved in the
11592 <varname>$domain_data</varname> variable and can be referred to in other router options or
11593 other statements in the same ACL.
11594 </para>
11595 </listitem>
11596 <listitem>
11597 <para>
11598 Any of the single-key lookup type names may be preceded by
11599 <literal>partial</literal>&lt;<emphasis>n</emphasis>&gt;<literal>-</literal>, where the &lt;<emphasis>n</emphasis>&gt; is optional, for example,
11600 </para>
11601 <literallayout class="monospaced">
11602 domains = partial-dbm;/partial/domains
11603 </literallayout>
11604 <para>
11605 This causes partial matching logic to be invoked; a description of how this
11606 works is given in section <xref linkend="SECTpartiallookup"/>.
11607 </para>
11608 </listitem>
11609 <listitem>
11610 <para>
11611 <indexterm role="concept">
11612 <primary>asterisk</primary>
11613 <secondary>in lookup type</secondary>
11614 </indexterm>
11615 Any of the single-key lookup types may be followed by an asterisk. This causes
11616 a default lookup for a key consisting of a single asterisk to be done if the
11617 original lookup fails. This is not a useful feature when using a domain list to
11618 select particular domains (because any domain would match), but it might have
11619 value if the result of the lookup is being used via the <varname>$domain_data</varname>
11620 expansion variable.
11621 </para>
11622 </listitem>
11623 <listitem>
11624 <para>
11625 If the pattern starts with the name of a query-style lookup type followed by a
11626 semicolon (for example, <quote>nisplus;</quote> or <quote>ldap;</quote>), the remainder of the
11627 pattern must be an appropriate query for the lookup type, as described in
11628 chapter <xref linkend="CHAPfdlookup"/>. For example:
11629 </para>
11630 <literallayout class="monospaced">
11631 hold_domains = mysql;select domain from holdlist \
11632   where domain = '$domain';
11633 </literallayout>
11634 <para>
11635 In most cases, the data that is looked up is not used (so for an SQL query, for
11636 example, it doesn&#x2019;t matter what field you select). Exim is interested only in
11637 whether or not the query succeeds. However, when a lookup is used for the
11638 <option>domains</option> option on a router, the data is preserved in the <varname>$domain_data</varname>
11639 variable and can be referred to in other options.
11640 </para>
11641 </listitem>
11642 <listitem>
11643 <para>
11644 <indexterm role="concept">
11645 <primary>domain list</primary>
11646 <secondary>matching literal domain name</secondary>
11647 </indexterm>
11648 If none of the above cases apply, a caseless textual comparison is made
11649 between the pattern and the domain.
11650 </para>
11651 </listitem>
11652 </itemizedlist>
11653 <para>
11654 Here is an example that uses several different kinds of pattern:
11655 </para>
11656 <literallayout class="monospaced">
11657 domainlist funny_domains = \
11658   @ : \
11659   lib.unseen.edu : \
11660   *.foundation.fict.example : \
11661   \N^[1-2]\d{3}\.fict\.example$\N : \
11662   partial-dbm;/opt/data/penguin/book : \
11663   nis;domains.byname : \
11664   nisplus;[name=$domain,status=local],domains.org_dir
11665 </literallayout>
11666 <para>
11667 There are obvious processing trade-offs among the various matching modes. Using
11668 an asterisk is faster than a regular expression, and listing a few names
11669 explicitly probably is too. The use of a file or database lookup is expensive,
11670 but may be the only option if hundreds of names are required. Because the
11671 patterns are tested in order, it makes sense to put the most commonly matched
11672 patterns earlier.
11673 </para>
11674 </section>
11675 <section id="SECThostlist">
11676 <title>Host lists</title>
11677 <para>
11678 <indexterm role="concept">
11679 <primary>host list</primary>
11680 <secondary>patterns in</secondary>
11681 </indexterm>
11682 <indexterm role="concept">
11683 <primary>list</primary>
11684 <secondary>host list</secondary>
11685 </indexterm>
11686 Host lists are used to control what remote hosts are allowed to do. For
11687 example, some hosts may be allowed to use the local host as a relay, and some
11688 may be permitted to use the SMTP ETRN command. Hosts can be identified in
11689 two different ways, by name or by IP address. In a host list, some types of
11690 pattern are matched to a host name, and some are matched to an IP address.
11691 You need to be particularly careful with this when single-key lookups are
11692 involved, to ensure that the right value is being used as the key.
11693 </para>
11694 </section>
11695 <section id="SECID80">
11696 <title>Special host list patterns</title>
11697 <para>
11698 <indexterm role="concept">
11699 <primary>empty item in hosts list</primary>
11700 </indexterm>
11701 <indexterm role="concept">
11702 <primary>host list</primary>
11703 <secondary>empty string in</secondary>
11704 </indexterm>
11705 If a host list item is the empty string, it matches only when no remote host is
11706 involved. This is the case when a message is being received from a local
11707 process using SMTP on the standard input, that is, when a TCP/IP connection is
11708 not used.
11709 </para>
11710 <para>
11711 <indexterm role="concept">
11712 <primary>asterisk</primary>
11713 <secondary>in host list</secondary>
11714 </indexterm>
11715 The special pattern <quote>*</quote> in a host list matches any host or no host. Neither
11716 the IP address nor the name is actually inspected.
11717 </para>
11718 </section>
11719 <section id="SECThoslispatip">
11720 <title>Host list patterns that match by IP address</title>
11721 <para>
11722 <indexterm role="concept">
11723 <primary>host list</primary>
11724 <secondary>matching IP addresses</secondary>
11725 </indexterm>
11726 If an IPv4 host calls an IPv6 host and the call is accepted on an IPv6 socket,
11727 the incoming address actually appears in the IPv6 host as
11728 <literal>::ffff:</literal>&lt;<emphasis>v4address</emphasis>&gt;. When such an address is tested against a host
11729 list, it is converted into a traditional IPv4 address first. (Not all operating
11730 systems accept IPv4 calls on IPv6 sockets, as there have been some security
11731 concerns.)
11732 </para>
11733 <para>
11734 The following types of pattern in a host list check the remote host by
11735 inspecting its IP address:
11736 </para>
11737 <itemizedlist>
11738 <listitem>
11739 <para>
11740 If the pattern is a plain domain name (not a regular expression, not starting
11741 with *, not a lookup of any kind), Exim calls the operating system function
11742 to find the associated IP address(es). Exim uses the newer
11743 <function>getipnodebyname()</function> function when available, otherwise <function>gethostbyname()</function>.
11744 This typically causes a forward DNS lookup of the name. The result is compared
11745 with the IP address of the subject host.
11746 </para>
11747 <para>
11748 If there is a temporary problem (such as a DNS timeout) with the host name
11749 lookup, a temporary error occurs. For example, if the list is being used in an
11750 ACL condition, the ACL gives a <quote>defer</quote> response, usually leading to a
11751 temporary SMTP error code. If no IP address can be found for the host name,
11752 what happens is described in section <xref linkend="SECTbehipnot"/> below.
11753 </para>
11754 </listitem>
11755 <listitem>
11756 <para>
11757 <indexterm role="concept">
11758 <primary>@ in a host list</primary>
11759 </indexterm>
11760 If the pattern is <quote>@</quote>, the primary host name is substituted and used as a
11761 domain name, as just described.
11762 </para>
11763 </listitem>
11764 <listitem>
11765 <para>
11766 If the pattern is an IP address, it is matched against the IP address of the
11767 subject host. IPv4 addresses are given in the normal <quote>dotted-quad</quote> notation.
11768 IPv6 addresses can be given in colon-separated format, but the colons have to
11769 be doubled so as not to be taken as item separators when the default list
11770 separator is used. IPv6 addresses are recognized even when Exim is compiled
11771 without IPv6 support. This means that if they appear in a host list on an
11772 IPv4-only host, Exim will not treat them as host names. They are just addresses
11773 that can never match a client host.
11774 </para>
11775 </listitem>
11776 <listitem>
11777 <para>
11778 <indexterm role="concept">
11779 <primary>@[] in a host list</primary>
11780 </indexterm>
11781 If the pattern is <quote>@[]</quote>, it matches the IP address of any IP interface on
11782 the local host. For example, if the local host is an IPv4 host with one
11783 interface address 10.45.23.56, these two ACL statements have the same effect:
11784 </para>
11785 <literallayout class="monospaced">
11786 accept hosts = 127.0.0.1 : 10.45.23.56
11787 accept hosts = @[]
11788 </literallayout>
11789 </listitem>
11790 <listitem>
11791 <para>
11792 <indexterm role="concept">
11793 <primary>CIDR notation</primary>
11794 </indexterm>
11795 If the pattern is an IP address followed by a slash and a mask length (for
11796 example 10.11.42.0/24), it is matched against the IP address of the subject
11797 host under the given mask. This allows, an entire network of hosts to be
11798 included (or excluded) by a single item. The mask uses CIDR notation; it
11799 specifies the number of address bits that must match, starting from the most
11800 significant end of the address.
11801 </para>
11802 <para>
11803 <emphasis role="bold">Note</emphasis>: The mask is <emphasis>not</emphasis> a count of addresses, nor is it the high number
11804 of a range of addresses. It is the number of bits in the network portion of the
11805 address. The above example specifies a 24-bit netmask, so it matches all 256
11806 addresses in the 10.11.42.0 network. An item such as
11807 </para>
11808 <literallayout class="monospaced">
11809 192.168.23.236/31
11810 </literallayout>
11811 <para>
11812 matches just two addresses, 192.168.23.236 and 192.168.23.237. A mask value of
11813 32 for an IPv4 address is the same as no mask at all; just a single address
11814 matches.
11815 </para>
11816 <para>
11817 Here is another example which shows an IPv4 and an IPv6 network:
11818 </para>
11819 <literallayout class="monospaced">
11820 recipient_unqualified_hosts = 192.168.0.0/16: \
11821                               3ffe::ffff::836f::::/48
11822 </literallayout>
11823 <para>
11824 The doubling of list separator characters applies only when these items
11825 appear inline in a host list. It is not required when indirecting via a file.
11826 For example:
11827 </para>
11828 <literallayout class="monospaced">
11829 recipient_unqualified_hosts = /opt/exim/unqualnets
11830 </literallayout>
11831 <para>
11832 could make use of a file containing
11833 </para>
11834 <literallayout class="monospaced">
11835 172.16.0.0/12
11836 3ffe:ffff:836f::/48
11837 </literallayout>
11838 <para>
11839 to have exactly the same effect as the previous example. When listing IPv6
11840 addresses inline, it is usually more convenient to use the facility for
11841 changing separator characters. This list contains the same two networks:
11842 </para>
11843 <literallayout class="monospaced">
11844 recipient_unqualified_hosts = &lt;; 172.16.0.0/12; \
11845                                  3ffe:ffff:836f::/48
11846 </literallayout>
11847 <para>
11848 The separator is changed to semicolon by the leading <quote>&lt;;</quote> at the start of the
11849 list.
11850 </para>
11851 </listitem>
11852 </itemizedlist>
11853 </section>
11854 <section id="SECThoslispatsikey">
11855 <title>Host list patterns for single-key lookups by host address</title>
11856 <para>
11857 <indexterm role="concept">
11858 <primary>host list</primary>
11859 <secondary>lookup of IP address</secondary>
11860 </indexterm>
11861 When a host is to be identified by a single-key lookup of its complete IP
11862 address, the pattern takes this form:
11863 </para>
11864 <literallayout>
11865 <literal>net-&lt;</literal><emphasis>single-key-search-type</emphasis><literal>&gt;;&lt;</literal><emphasis>search-data</emphasis><literal>&gt;</literal>
11866 </literallayout>
11867 <para>
11868 For example:
11869 </para>
11870 <literallayout class="monospaced">
11871 hosts_lookup = net-cdb;/hosts-by-ip.db
11872 </literallayout>
11873 <para>
11874 The text form of the IP address of the subject host is used as the lookup key.
11875 IPv6 addresses are converted to an unabbreviated form, using lower case
11876 letters, with dots as separators because colon is the key terminator in
11877 <command>lsearch</command> files. [Colons can in fact be used in keys in <command>lsearch</command> files by
11878 quoting the keys, but this is a facility that was added later.] The data
11879 returned by the lookup is not used.
11880 </para>
11881 <para>
11882 <indexterm role="concept">
11883 <primary>IP address</primary>
11884 <secondary>masking</secondary>
11885 </indexterm>
11886 <indexterm role="concept">
11887 <primary>host list</primary>
11888 <secondary>masked IP address</secondary>
11889 </indexterm>
11890 Single-key lookups can also be performed using masked IP addresses, using
11891 patterns of this form:
11892 </para>
11893 <literallayout>
11894 <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>
11895 </literallayout>
11896 <para>
11897 For example:
11898 </para>
11899 <literallayout class="monospaced">
11900 net24-dbm;/networks.db
11901 </literallayout>
11902 <para>
11903 The IP address of the subject host is masked using &lt;<emphasis>number</emphasis>&gt; as the mask
11904 length. A textual string is constructed from the masked value, followed by the
11905 mask, and this is used as the lookup key. For example, if the host&#x2019;s IP address
11906 is 192.168.34.6, the key that is looked up for the above example is
11907 <quote>192.168.34.0/24</quote>.
11908 </para>
11909 <para>
11910 When an IPv6 address is converted to a string, dots are normally used instead
11911 of colons, so that keys in <command>lsearch</command> files need not contain colons (which
11912 terminate <command>lsearch</command> keys). This was implemented some time before the ability
11913 to quote keys was made available in <command>lsearch</command> files. However, the more
11914 recently implemented <command>iplsearch</command> files do require colons in IPv6 keys
11915 (notated using the quoting facility) so as to distinguish them from IPv4 keys.
11916 For this reason, when the lookup type is <command>iplsearch</command>, IPv6 addresses are
11917 converted using colons and not dots. In all cases, full, unabbreviated IPv6
11918 addresses are always used.
11919 </para>
11920 <para>
11921 Ideally, it would be nice to tidy up this anomalous situation by changing to
11922 colons in all cases, given that quoting is now available for <command>lsearch</command>.
11923 However, this would be an incompatible change that might break some existing
11924 configurations.
11925 </para>
11926 <para>
11927 <emphasis role="bold">Warning</emphasis>: Specifying <option>net32-</option> (for an IPv4 address) or <option>net128-</option> (for an
11928 IPv6 address) is not the same as specifying just <option>net-</option> without a number. In
11929 the former case the key strings include the mask value, whereas in the latter
11930 case the IP address is used on its own.
11931 </para>
11932 </section>
11933 <section id="SECThoslispatnam">
11934 <title>Host list patterns that match by host name</title>
11935 <para>
11936 <indexterm role="concept">
11937 <primary>host</primary>
11938 <secondary>lookup failures</secondary>
11939 </indexterm>
11940 <indexterm role="concept">
11941 <primary>unknown host name</primary>
11942 </indexterm>
11943 <indexterm role="concept">
11944 <primary>host list</primary>
11945 <secondary>matching host name</secondary>
11946 </indexterm>
11947 There are several types of pattern that require Exim to know the name of the
11948 remote host. These are either wildcard patterns or lookups by name. (If a
11949 complete hostname is given without any wildcarding, it is used to find an IP
11950 address to match against, as described in the section <xref linkend="SECThoslispatip"/>
11951 above.)
11952 </para>
11953 <para>
11954 If the remote host name is not already known when Exim encounters one of these
11955 patterns, it has to be found from the IP address.
11956 Although many sites on the Internet are conscientious about maintaining reverse
11957 DNS data for their hosts, there are also many that do not do this.
11958 Consequently, a name cannot always be found, and this may lead to unwanted
11959 effects. Take care when configuring host lists with wildcarded name patterns.
11960 Consider what will happen if a name cannot be found.
11961 </para>
11962 <para>
11963 Because of the problems of determining host names from IP addresses, matching
11964 against host names is not as common as matching against IP addresses.
11965 </para>
11966 <para>
11967 By default, in order to find a host name, Exim first does a reverse DNS lookup;
11968 if no name is found in the DNS, the system function (<function>gethostbyaddr()</function> or
11969 <function>getipnodebyaddr()</function> if available) is tried. The order in which these lookups
11970 are done can be changed by setting the <option>host_lookup_order</option> option. For
11971 security, once Exim has found one or more names, it looks up the IP addresses
11972 for these names and compares them with the IP address that it started with.
11973 Only those names whose IP addresses match are accepted. Any other names are
11974 discarded. If no names are left, Exim behaves as if the host name cannot be
11975 found. In the most common case there is only one name and one IP address.
11976 </para>
11977 <para>
11978 There are some options that control what happens if a host name cannot be
11979 found. These are described in section <xref linkend="SECTbehipnot"/> below.
11980 </para>
11981 <para>
11982 <indexterm role="concept">
11983 <primary>host</primary>
11984 <secondary>alias for</secondary>
11985 </indexterm>
11986 <indexterm role="concept">
11987 <primary>alias for host</primary>
11988 </indexterm>
11989 As a result of aliasing, hosts may have more than one name. When processing any
11990 of the following types of pattern, all the host&#x2019;s names are checked:
11991 </para>
11992 <itemizedlist>
11993 <listitem>
11994 <para>
11995 <indexterm role="concept">
11996 <primary>asterisk</primary>
11997 <secondary>in host list</secondary>
11998 </indexterm>
11999 If a pattern starts with <quote>*</quote> the remainder of the item must match the end of
12000 the host name. For example, <literal>*.b.c</literal> matches all hosts whose names end in
12001 <emphasis>.b.c</emphasis>. This special simple form is provided because this is a very common
12002 requirement. Other kinds of wildcarding require the use of a regular
12003 expression.
12004 </para>
12005 </listitem>
12006 <listitem>
12007 <para>
12008 <indexterm role="concept">
12009 <primary>regular expressions</primary>
12010 <secondary>in host list</secondary>
12011 </indexterm>
12012 <indexterm role="concept">
12013 <primary>host list</primary>
12014 <secondary>regular expression in</secondary>
12015 </indexterm>
12016 If the item starts with <quote>^</quote> it is taken to be a regular expression which is
12017 matched against the host name. Host names are case-independent, so this regular
12018 expression match is by default case-independent, but you can make it
12019 case-dependent by starting it with <literal>(?-i)</literal>. References to descriptions of the
12020 syntax of regular expressions are given in chapter <xref linkend="CHAPregexp"/>. For
12021 example,
12022 </para>
12023 <literallayout class="monospaced">
12024 ^(a|b)\.c\.d$
12025 </literallayout>
12026 <para>
12027 is a regular expression that matches either of the two hosts <emphasis>a.c.d</emphasis> or
12028 <emphasis>b.c.d</emphasis>. When a regular expression is used in a host list, you must take care
12029 that backslash and dollar characters are not misinterpreted as part of the
12030 string expansion. The simplest way to do this is to use <literal>\N</literal> to mark that
12031 part of the string as non-expandable. For example:
12032 </para>
12033 <literallayout class="monospaced">
12034 sender_unqualified_hosts = \N^(a|b)\.c\.d$\N : ....
12035 </literallayout>
12036 <para>
12037 <emphasis role="bold">Warning</emphasis>: If you want to match a complete host name, you must include the
12038 <literal>$</literal> terminating metacharacter in the regular expression, as in the above
12039 example. Without it, a match at the start of the host name is all that is
12040 required.
12041 </para>
12042 </listitem>
12043 </itemizedlist>
12044 </section>
12045 <section id="SECTbehipnot">
12046 <title>Behaviour when an IP address or name cannot be found</title>
12047 <para>
12048 <indexterm role="concept">
12049 <primary>host</primary>
12050 <secondary>lookup failures, permanent</secondary>
12051 </indexterm>
12052 While processing a host list, Exim may need to look up an IP address from a
12053 name (see section <xref linkend="SECThoslispatip"/>), or it may need to look up a host name
12054 from an IP address (see section <xref linkend="SECThoslispatnam"/>). In either case, the
12055 behaviour when it fails to find the information it is seeking is the same.
12056 </para>
12057 <para>
12058 <emphasis role="bold">Note</emphasis>: This section applies to permanent lookup failures. It does <emphasis>not</emphasis>
12059 apply to temporary DNS errors, whose handling is described in the next section.
12060 </para>
12061 <para>
12062 <indexterm role="concept">
12063 <primary><literal>+include_unknown</literal></primary>
12064 </indexterm>
12065 <indexterm role="concept">
12066 <primary><literal>+ignore_unknown</literal></primary>
12067 </indexterm>
12068 By default, Exim behaves as if the host does not match the list. This may not
12069 always be what you want to happen. To change Exim&#x2019;s behaviour, the special
12070 items <literal>+include_unknown</literal> or <literal>+ignore_unknown</literal> may appear in the list (at
12071 top level &ndash; they are not recognized in an indirected file).
12072 </para>
12073 <itemizedlist>
12074 <listitem>
12075 <para>
12076 If any item that follows <literal>+include_unknown</literal> requires information that
12077 cannot found, Exim behaves as if the host does match the list. For example,
12078 </para>
12079 <literallayout class="monospaced">
12080 host_reject_connection = +include_unknown:*.enemy.ex
12081 </literallayout>
12082 <para>
12083 rejects connections from any host whose name matches <literal>*.enemy.ex</literal>, and also
12084 any hosts whose name it cannot find.
12085 </para>
12086 </listitem>
12087 <listitem>
12088 <para>
12089 If any item that follows <literal>+ignore_unknown</literal> requires information that cannot
12090 be found, Exim ignores that item and proceeds to the rest of the list. For
12091 example:
12092 </para>
12093 <literallayout class="monospaced">
12094 accept hosts = +ignore_unknown : friend.example : \
12095                192.168.4.5
12096 </literallayout>
12097 <para>
12098 accepts from any host whose name is <emphasis>friend.example</emphasis> and from 192.168.4.5,
12099 whether or not its host name can be found. Without <literal>+ignore_unknown</literal>, if no
12100 name can be found for 192.168.4.5, it is rejected.
12101 </para>
12102 </listitem>
12103 </itemizedlist>
12104 <para>
12105 Both <literal>+include_unknown</literal> and <literal>+ignore_unknown</literal> may appear in the same
12106 list. The effect of each one lasts until the next, or until the end of the
12107 list.
12108 </para>
12109 </section>
12110 <section id="SECTtemdnserr">
12111 <title>Temporary DNS errors when looking up host information</title>
12112 <para>
12113 <indexterm role="concept">
12114 <primary>host</primary>
12115 <secondary>lookup failures, temporary</secondary>
12116 </indexterm>
12117 <indexterm role="concept">
12118 <primary><literal>+include_defer</literal></primary>
12119 </indexterm>
12120 <indexterm role="concept">
12121 <primary><literal>+ignore_defer</literal></primary>
12122 </indexterm>
12123 A temporary DNS lookup failure normally causes a defer action (except when
12124 <option>dns_again_means_nonexist</option> converts it into a permanent error). However,
12125 host lists can include <literal>+ignore_defer</literal> and <literal>+include_defer</literal>, analagous to
12126 <literal>+ignore_unknown</literal> and <literal>+include_unknown</literal>, as described in the previous
12127 section. These options should be used with care, probably only in non-critical
12128 host lists such as whitelists.
12129 </para>
12130 </section>
12131 <section id="SECThoslispatnamsk">
12132 <title>Host list patterns for single-key lookups by host name</title>
12133 <para>
12134 <indexterm role="concept">
12135 <primary>unknown host name</primary>
12136 </indexterm>
12137 <indexterm role="concept">
12138 <primary>host list</primary>
12139 <secondary>matching host name</secondary>
12140 </indexterm>
12141 If a pattern is of the form
12142 </para>
12143 <literallayout>
12144 &lt;<emphasis>single-key-search-type</emphasis>&gt;;&lt;<emphasis>search-data</emphasis>&gt;
12145 </literallayout>
12146 <para>
12147 for example
12148 </para>
12149 <literallayout class="monospaced">
12150 dbm;/host/accept/list
12151 </literallayout>
12152 <para>
12153 a single-key lookup is performed, using the host name as its key. If the
12154 lookup succeeds, the host matches the item. The actual data that is looked up
12155 is not used.
12156 </para>
12157 <para>
12158 <emphasis role="bold">Reminder</emphasis>: With this kind of pattern, you must have host <emphasis>names</emphasis> as
12159 keys in the file, not IP addresses. If you want to do lookups based on IP
12160 addresses, you must precede the search type with <quote>net-</quote> (see section
12161 <xref linkend="SECThoslispatsikey"/>). There is, however, no reason why you could not use
12162 two items in the same list, one doing an address lookup and one doing a name
12163 lookup, both using the same file.
12164 </para>
12165 </section>
12166 <section id="SECID81">
12167 <title>Host list patterns for query-style lookups</title>
12168 <para>
12169 If a pattern is of the form
12170 </para>
12171 <literallayout>
12172 &lt;<emphasis>query-style-search-type</emphasis>&gt;;&lt;<emphasis>query</emphasis>&gt;
12173 </literallayout>
12174 <para>
12175 the query is obeyed, and if it succeeds, the host matches the item. The actual
12176 data that is looked up is not used. The variables <varname>$sender_host_address</varname> and
12177 <varname>$sender_host_name</varname> can be used in the query. For example:
12178 </para>
12179 <literallayout class="monospaced">
12180 hosts_lookup = pgsql;\
12181   select ip from hostlist where ip='$sender_host_address'
12182 </literallayout>
12183 <para>
12184 The value of <varname>$sender_host_address</varname> for an IPv6 address contains colons. You
12185 can use the <option>sg</option> expansion item to change this if you need to. If you want to
12186 use masked IP addresses in database queries, you can use the <option>mask</option> expansion
12187 operator.
12188 </para>
12189 <para>
12190 If the query contains a reference to <varname>$sender_host_name</varname>, Exim automatically
12191 looks up the host name if has not already done so. (See section
12192 <xref linkend="SECThoslispatnam"/> for comments on finding host names.)
12193 </para>
12194 <para>
12195 Historical note: prior to release 4.30, Exim would always attempt to find a
12196 host name before running the query, unless the search type was preceded by
12197 <literal>net-</literal>. This is no longer the case. For backwards compatibility, <literal>net-</literal> is
12198 still recognized for query-style lookups, but its presence or absence has no
12199 effect. (Of course, for single-key lookups, <literal>net-</literal> <emphasis>is</emphasis> important.
12200 See section <xref linkend="SECThoslispatsikey"/>.)
12201 </para>
12202 </section>
12203 <section id="SECTmixwilhos">
12204 <title>Mixing wildcarded host names and addresses in host lists</title>
12205 <para>
12206 <indexterm role="concept">
12207 <primary>host list</primary>
12208 <secondary>mixing names and addresses in</secondary>
12209 </indexterm>
12210 If you have name lookups or wildcarded host names and IP addresses in the same
12211 host list, you should normally put the IP addresses first. For example, in an
12212 ACL you could have:
12213 </para>
12214 <literallayout class="monospaced">
12215 accept hosts = 10.9.8.7 : *.friend.example
12216 </literallayout>
12217 <para>
12218 The reason for this lies in the left-to-right way that Exim processes lists.
12219 It can test IP addresses without doing any DNS lookups, but when it reaches an
12220 item that requires a host name, it fails if it cannot find a host name to
12221 compare with the pattern. If the above list is given in the opposite order, the
12222 <option>accept</option> statement fails for a host whose name cannot be found, even if its
12223 IP address is 10.9.8.7.
12224 </para>
12225 <para>
12226 If you really do want to do the name check first, and still recognize the IP
12227 address, you can rewrite the ACL like this:
12228 </para>
12229 <literallayout class="monospaced">
12230 accept hosts = *.friend.example
12231 accept hosts = 10.9.8.7
12232 </literallayout>
12233 <para>
12234 If the first <option>accept</option> fails, Exim goes on to try the second one. See chapter
12235 <xref linkend="CHAPACL"/> for details of ACLs.
12236 </para>
12237 </section>
12238 <section id="SECTaddresslist">
12239 <title>Address lists</title>
12240 <para>
12241 <indexterm role="concept">
12242 <primary>list</primary>
12243 <secondary>address list</secondary>
12244 </indexterm>
12245 <indexterm role="concept">
12246 <primary>address list</primary>
12247 <secondary>empty item</secondary>
12248 </indexterm>
12249 <indexterm role="concept">
12250 <primary>address list</primary>
12251 <secondary>patterns</secondary>
12252 </indexterm>
12253 Address lists contain patterns that are matched against mail addresses. There
12254 is one special case to be considered: the sender address of a bounce message is
12255 always empty. You can test for this by providing an empty item in an address
12256 list. For example, you can set up a router to process bounce messages by
12257 using this option setting:
12258 </para>
12259 <literallayout class="monospaced">
12260 senders = :
12261 </literallayout>
12262 <para>
12263 The presence of the colon creates an empty item. If you do not provide any
12264 data, the list is empty and matches nothing. The empty sender can also be
12265 detected by a regular expression that matches an empty string,
12266 and by a query-style lookup that succeeds when <varname>$sender_address</varname> is empty.
12267 </para>
12268 <para>
12269 Non-empty items in an address list can be straightforward email addresses. For
12270 example:
12271 </para>
12272 <literallayout class="monospaced">
12273 senders = jbc@askone.example : hs@anacreon.example
12274 </literallayout>
12275 <para>
12276 A certain amount of wildcarding is permitted. If a pattern contains an @
12277 character, but is not a regular expression and does not begin with a
12278 semicolon-terminated lookup type (described below), the local part of the
12279 subject address is compared with the local part of the pattern, which may start
12280 with an asterisk. If the local parts match, the domain is checked in exactly
12281 the same way as for a pattern in a domain list. For example, the domain can be
12282 wildcarded, refer to a named list, or be a lookup:
12283 </para>
12284 <literallayout class="monospaced">
12285 deny senders = *@*.spamming.site:\
12286                *@+hostile_domains:\
12287                bozo@partial-lsearch;/list/of/dodgy/sites:\
12288                *@dbm;/bad/domains.db
12289 </literallayout>
12290 <para>
12291 <indexterm role="concept">
12292 <primary>local part</primary>
12293 <secondary>starting with !</secondary>
12294 </indexterm>
12295 <indexterm role="concept">
12296 <primary>address list</primary>
12297 <secondary>local part starting with !</secondary>
12298 </indexterm>
12299 If a local part that begins with an exclamation mark is required, it has to be
12300 specified using a regular expression, because otherwise the exclamation mark is
12301 treated as a sign of negation, as is standard in lists.
12302 </para>
12303 <para>
12304 If a non-empty pattern that is not a regular expression or a lookup does not
12305 contain an @ character, it is matched against the domain part of the subject
12306 address. The only two formats that are recognized this way are a literal
12307 domain, or a domain pattern that starts with *. In both these cases, the effect
12308 is the same as if <literal>*@</literal> preceded the pattern. For example:
12309 </para>
12310 <literallayout class="monospaced">
12311 deny senders = enemy.domain : *.enemy.domain
12312 </literallayout>
12313 <para>
12314 The following kinds of more complicated address list pattern can match any
12315 address, including the empty address that is characteristic of bounce message
12316 senders:
12317 </para>
12318 <itemizedlist>
12319 <listitem>
12320 <para>
12321 <indexterm role="concept">
12322 <primary>regular expressions</primary>
12323 <secondary>in address list</secondary>
12324 </indexterm>
12325 <indexterm role="concept">
12326 <primary>address list</primary>
12327 <secondary>regular expression in</secondary>
12328 </indexterm>
12329 If (after expansion) a pattern starts with <quote>^</quote>, a regular expression match is
12330 done against the complete address, with the pattern as the regular expression.
12331 You must take care that backslash and dollar characters are not misinterpreted
12332 as part of the string expansion. The simplest way to do this is to use <literal>\N</literal>
12333 to mark that part of the string as non-expandable. For example:
12334 </para>
12335 <literallayout class="monospaced">
12336 deny senders = \N^.*this.*@example\.com$\N : \
12337                \N^\d{8}.+@spamhaus.example$\N : ...
12338 </literallayout>
12339 <para>
12340 The <literal>\N</literal> sequences are removed by the expansion, so these items do indeed
12341 start with <quote>^</quote> by the time they are being interpreted as address patterns.
12342 </para>
12343 </listitem>
12344 <listitem>
12345 <para>
12346 <indexterm role="concept">
12347 <primary>address list</primary>
12348 <secondary>lookup for complete address</secondary>
12349 </indexterm>
12350 Complete addresses can be looked up by using a pattern that starts with a
12351 lookup type terminated by a semicolon, followed by the data for the lookup. For
12352 example:
12353 </para>
12354 <literallayout class="monospaced">
12355 deny senders = cdb;/etc/blocked.senders : \
12356   mysql;select address from blocked where \
12357   address='${quote_mysql:$sender_address}'
12358 </literallayout>
12359 <para>
12360 Both query-style and single-key lookup types can be used. For a single-key
12361 lookup type, Exim uses the complete address as the key. However, empty keys are
12362 not supported for single-key lookups, so a match against the empty address
12363 always fails. This restriction does not apply to query-style lookups.
12364 </para>
12365 <para>
12366 Partial matching for single-key lookups (section <xref linkend="SECTpartiallookup"/>)
12367 cannot be used, and is ignored if specified, with an entry being written to the
12368 panic log.
12369 <indexterm role="concept">
12370 <primary>*@ with single-key lookup</primary>
12371 </indexterm>
12372 However, you can configure lookup defaults, as described in section
12373 <xref linkend="SECTdefaultvaluelookups"/>, but this is useful only for the <quote>*@</quote> type of
12374 default. For example, with this lookup:
12375 </para>
12376 <literallayout class="monospaced">
12377 accept senders = lsearch*@;/some/file
12378 </literallayout>
12379 <para>
12380 the file could contains lines like this:
12381 </para>
12382 <literallayout class="monospaced">
12383 user1@domain1.example
12384 *@domain2.example
12385 </literallayout>
12386 <para>
12387 and for the sender address <emphasis>nimrod@jaeger.example</emphasis>, the sequence of keys
12388 that are tried is:
12389 </para>
12390 <literallayout class="monospaced">
12391 nimrod@jaeger.example
12392 *@jaeger.example
12393 *
12394 </literallayout>
12395 <para>
12396 <emphasis role="bold">Warning 1</emphasis>: Do not include a line keyed by <quote>*</quote> in the file, because that
12397 would mean that every address matches, thus rendering the test useless.
12398 </para>
12399 <para>
12400 <emphasis role="bold">Warning 2</emphasis>: Do not confuse these two kinds of item:
12401 </para>
12402 <literallayout class="monospaced">
12403 deny recipients = dbm*@;/some/file
12404 deny recipients = *@dbm;/some/file
12405 </literallayout>
12406 <para>
12407 The first does a whole address lookup, with defaulting, as just described,
12408 because it starts with a lookup type. The second matches the local part and
12409 domain independently, as described in a bullet point below.
12410 </para>
12411 </listitem>
12412 </itemizedlist>
12413 <para>
12414 The following kinds of address list pattern can match only non-empty addresses.
12415 If the subject address is empty, a match against any of these pattern types
12416 always fails.
12417 </para>
12418 <itemizedlist>
12419 <listitem>
12420 <para>
12421 <indexterm role="concept">
12422 <primary>@@ with single-key lookup</primary>
12423 </indexterm>
12424 <indexterm role="concept">
12425 <primary>address list</primary>
12426 <secondary>@@ lookup type</secondary>
12427 </indexterm>
12428 <indexterm role="concept">
12429 <primary>address list</primary>
12430 <secondary>split local part and domain</secondary>
12431 </indexterm>
12432 If a pattern starts with <quote>@@</quote> followed by a single-key lookup item
12433 (for example, <literal>@@lsearch;/some/file</literal>), the address that is being checked is
12434 split into a local part and a domain. The domain is looked up in the file. If
12435 it is not found, there is no match. If it is found, the data that is looked up
12436 from the file is treated as a colon-separated list of local part patterns, each
12437 of which is matched against the subject local part in turn.
12438 </para>
12439 <para>
12440 <indexterm role="concept">
12441 <primary>asterisk</primary>
12442 <secondary>in address list</secondary>
12443 </indexterm>
12444 The lookup may be a partial one, and/or one involving a search for a default
12445 keyed by <quote>*</quote> (see section <xref linkend="SECTdefaultvaluelookups"/>). The local part
12446 patterns that are looked up can be regular expressions or begin with <quote>*</quote>, or
12447 even be further lookups. They may also be independently negated. For example,
12448 with
12449 </para>
12450 <literallayout class="monospaced">
12451 deny senders = @@dbm;/etc/reject-by-domain
12452 </literallayout>
12453 <para>
12454 the data from which the DBM file is built could contain lines like
12455 </para>
12456 <literallayout class="monospaced">
12457 baddomain.com:  !postmaster : *
12458 </literallayout>
12459 <para>
12460 to reject all senders except <option>postmaster</option> from that domain.
12461 </para>
12462 <para>
12463 <indexterm role="concept">
12464 <primary>local part</primary>
12465 <secondary>starting with !</secondary>
12466 </indexterm>
12467 If a local part that actually begins with an exclamation mark is required, it
12468 has to be specified using a regular expression. In <command>lsearch</command> files, an entry
12469 may be split over several lines by indenting the second and subsequent lines,
12470 but the separating colon must still be included at line breaks. White space
12471 surrounding the colons is ignored. For example:
12472 </para>
12473 <literallayout class="monospaced">
12474 aol.com:  spammer1 : spammer2 : ^[0-9]+$ :
12475 spammer3 : spammer4
12476 </literallayout>
12477 <para>
12478 As in all colon-separated lists in Exim, a colon can be included in an item by
12479 doubling.
12480 </para>
12481 <para>
12482 If the last item in the list starts with a right angle-bracket, the remainder
12483 of the item is taken as a new key to look up in order to obtain a continuation
12484 list of local parts. The new key can be any sequence of characters. Thus one
12485 might have entries like
12486 </para>
12487 <literallayout class="monospaced">
12488 aol.com: spammer1 : spammer 2 : &gt;*
12489 xyz.com: spammer3 : &gt;*
12490 *:       ^\d{8}$
12491 </literallayout>
12492 <para>
12493 in a file that was searched with <option>@@dbm*</option>, to specify a match for 8-digit
12494 local parts for all domains, in addition to the specific local parts listed for
12495 each domain. Of course, using this feature costs another lookup each time a
12496 chain is followed, but the effort needed to maintain the data is reduced.
12497 </para>
12498 <para>
12499 <indexterm role="concept">
12500 <primary>loop</primary>
12501 <secondary>in lookups</secondary>
12502 </indexterm>
12503 It is possible to construct loops using this facility, and in order to catch
12504 them, the chains may be no more than fifty items long.
12505 </para>
12506 </listitem>
12507 <listitem>
12508 <para>
12509 The @@&lt;<emphasis>lookup</emphasis>&gt; style of item can also be used with a query-style
12510 lookup, but in this case, the chaining facility is not available. The lookup
12511 can only return a single list of local parts.
12512 </para>
12513 </listitem>
12514 </itemizedlist>
12515 <para>
12516 <emphasis role="bold">Warning</emphasis>: There is an important difference between the address list items
12517 in these two examples:
12518 </para>
12519 <literallayout class="monospaced">
12520 senders = +my_list
12521 senders = *@+my_list
12522 </literallayout>
12523 <para>
12524 In the first one, <literal>my_list</literal> is a named address list, whereas in the second
12525 example it is a named domain list.
12526 </para>
12527 </section>
12528 <section id="SECTcasletadd">
12529 <title>Case of letters in address lists</title>
12530 <para>
12531 <indexterm role="concept">
12532 <primary>case of local parts</primary>
12533 </indexterm>
12534 <indexterm role="concept">
12535 <primary>address list</primary>
12536 <secondary>case forcing</secondary>
12537 </indexterm>
12538 <indexterm role="concept">
12539 <primary>case forcing in address lists</primary>
12540 </indexterm>
12541 Domains in email addresses are always handled caselessly, but for local parts
12542 case may be significant on some systems (see <option>caseful_local_part</option> for how
12543 Exim deals with this when routing addresses). However, RFC 2505 (<emphasis>Anti-Spam
12544 Recommendations for SMTP MTAs</emphasis>) suggests that matching of addresses to
12545 blocking lists should be done in a case-independent manner. Since most address
12546 lists in Exim are used for this kind of control, Exim attempts to do this by
12547 default.
12548 </para>
12549 <para>
12550 The domain portion of an address is always lowercased before matching it to an
12551 address list. The local part is lowercased by default, and any string
12552 comparisons that take place are done caselessly. This means that the data in
12553 the address list itself, in files included as plain file names, and in any file
12554 that is looked up using the <quote>@@</quote> mechanism, can be in any case. However, the
12555 keys in files that are looked up by a search type other than <command>lsearch</command> (which
12556 works caselessly) must be in lower case, because these lookups are not
12557 case-independent.
12558 </para>
12559 <para>
12560 <indexterm role="concept">
12561 <primary><literal>+caseful</literal></primary>
12562 </indexterm>
12563 To allow for the possibility of caseful address list matching, if an item in
12564 an address list is the string <quote>+caseful</quote>, the original case of the local
12565 part is restored for any comparisons that follow, and string comparisons are no
12566 longer case-independent. This does not affect the domain, which remains in
12567 lower case. However, although independent matches on the domain alone are still
12568 performed caselessly, regular expressions that match against an entire address
12569 become case-sensitive after <quote>+caseful</quote> has been seen.
12570 </para>
12571 </section>
12572 <section id="SECTlocparlis">
12573 <title>Local part lists</title>
12574 <para>
12575 <indexterm role="concept">
12576 <primary>list</primary>
12577 <secondary>local part list</secondary>
12578 </indexterm>
12579 <indexterm role="concept">
12580 <primary>local part</primary>
12581 <secondary>list</secondary>
12582 </indexterm>
12583 Case-sensitivity in local part lists is handled in the same way as for address
12584 lists, as just described. The <quote>+caseful</quote> item can be used if required. In a
12585 setting of the <option>local_parts</option> option in a router with <option>caseful_local_part</option>
12586 set false, the subject is lowercased and the matching is initially
12587 case-insensitive. In this case, <quote>+caseful</quote> will restore case-sensitive
12588 matching in the local part list, but not elsewhere in the router. If
12589 <option>caseful_local_part</option> is set true in a router, matching in the <option>local_parts</option>
12590 option is case-sensitive from the start.
12591 </para>
12592 <para>
12593 If a local part list is indirected to a file (see section <xref linkend="SECTfilnamlis"/>),
12594 comments are handled in the same way as address lists &ndash; they are recognized
12595 only if the # is preceded by white space or the start of the line.
12596 Otherwise, local part lists are matched in the same way as domain lists, except
12597 that the special items that refer to the local host (<literal>@</literal>, <literal>@[]</literal>,
12598 <literal>@mx_any</literal>, <literal>@mx_primary</literal>, and <literal>@mx_secondary</literal>) are not recognized.
12599 Refer to section <xref linkend="SECTdomainlist"/> for details of the other available item
12600 types.
12601 <indexterm role="concept" startref="IIDdohoadli" class="endofrange"/>
12602 </para>
12603 </section>
12604 </chapter>
12605
12606 <chapter id="CHAPexpand">
12607 <title>String expansions</title>
12608 <para>
12609 <indexterm role="concept" id="IIDstrexp" class="startofrange">
12610 <primary>expansion</primary>
12611 <secondary>of strings</secondary>
12612 </indexterm>
12613 Many strings in Exim&#x2019;s run time configuration are expanded before use. Some of
12614 them are expanded every time they are used; others are expanded only once.
12615 </para>
12616 <para>
12617 When a string is being expanded it is copied verbatim from left to right except
12618 when a dollar or backslash character is encountered. A dollar specifies the
12619 start of a portion of the string that is interpreted and replaced as described
12620 below in section <xref linkend="SECTexpansionitems"/> onwards. Backslash is used as an
12621 escape character, as described in the following section.
12622 </para>
12623 <section id="SECTlittext">
12624 <title>Literal text in expanded strings</title>
12625 <para>
12626 <indexterm role="concept">
12627 <primary>expansion</primary>
12628 <secondary>including literal text</secondary>
12629 </indexterm>
12630 An uninterpreted dollar can be included in an expanded string by putting a
12631 backslash in front of it. A backslash can be used to prevent any special
12632 character being treated specially in an expansion, including backslash itself.
12633 If the string appears in quotes in the configuration file, two backslashes are
12634 required because the quotes themselves cause interpretation of backslashes when
12635 the string is read in (see section <xref linkend="SECTstrings"/>).
12636 </para>
12637 <para>
12638 <indexterm role="concept">
12639 <primary>expansion</primary>
12640 <secondary>non-expandable substrings</secondary>
12641 </indexterm>
12642 A portion of the string can specified as non-expandable by placing it between
12643 two occurrences of <literal>\N</literal>. This is particularly useful for protecting regular
12644 expressions, which often contain backslashes and dollar signs. For example:
12645 </para>
12646 <literallayout class="monospaced">
12647 deny senders = \N^\d{8}[a-z]@some\.site\.example$\N
12648 </literallayout>
12649 <para>
12650 On encountering the first <literal>\N</literal>, the expander copies subsequent characters
12651 without interpretation until it reaches the next <literal>\N</literal> or the end of the
12652 string.
12653 </para>
12654 </section>
12655 <section id="SECID82">
12656 <title>Character escape sequences in expanded strings</title>
12657 <para>
12658 <indexterm role="concept">
12659 <primary>expansion</primary>
12660 <secondary>escape sequences</secondary>
12661 </indexterm>
12662 A backslash followed by one of the letters <quote>n</quote>, <quote>r</quote>, or <quote>t</quote> in an
12663 expanded string is recognized as an escape sequence for the character newline,
12664 carriage return, or tab, respectively. A backslash followed by up to three
12665 octal digits is recognized as an octal encoding for a single character, and a
12666 backslash followed by <quote>x</quote> and up to two hexadecimal digits is a hexadecimal
12667 encoding.
12668 </para>
12669 <para>
12670 These escape sequences are also recognized in quoted strings when they are read
12671 in. Their interpretation in expansions as well is useful for unquoted strings,
12672 and for other cases such as looked-up strings that are then expanded.
12673 </para>
12674 </section>
12675 <section id="SECID83">
12676 <title>Testing string expansions</title>
12677 <para>
12678 <indexterm role="concept">
12679 <primary>expansion</primary>
12680 <secondary>testing</secondary>
12681 </indexterm>
12682 <indexterm role="concept">
12683 <primary>testing</primary>
12684 <secondary>string expansion</secondary>
12685 </indexterm>
12686 <indexterm role="option">
12687 <primary><option>-be</option></primary>
12688 </indexterm>
12689 Many expansions can be tested by calling Exim with the <option>-be</option> option. This
12690 takes the command arguments, or lines from the standard input if there are no
12691 arguments, runs them through the string expansion code, and writes the results
12692 to the standard output. Variables based on configuration values are set up, but
12693 since no message is being processed, variables such as <varname>$local_part</varname> have no
12694 value. Nevertheless the <option>-be</option> option can be useful for checking out file and
12695 database lookups, and the use of expansion operators such as <option>sg</option>, <option>substr</option>
12696 and <option>nhash</option>.
12697 </para>
12698 <para>
12699 Exim gives up its root privilege when it is called with the <option>-be</option> option, and
12700 instead runs under the uid and gid it was called with, to prevent users from
12701 using <option>-be</option> for reading files to which they do not have access.
12702 </para>
12703 <para>
12704 <indexterm role="option">
12705 <primary><option>-bem</option></primary>
12706 </indexterm>
12707 If you want to test expansions that include variables whose values are taken
12708 from a message, there are two other options that can be used. The <option>-bem</option>
12709 option is like <option>-be</option> except that it is followed by a file name. The file is
12710 read as a message before doing the test expansions. For example:
12711 </para>
12712 <literallayout class="monospaced">
12713 exim -bem /tmp/test.message '$h_subject:'
12714 </literallayout>
12715 <para>
12716 The <option>-Mset</option> option is used in conjunction with <option>-be</option> and is followed by an
12717 Exim message identifier. For example:
12718 </para>
12719 <literallayout class="monospaced">
12720 exim -be -Mset 1GrA8W-0004WS-LQ '$recipients'
12721 </literallayout>
12722 <para>
12723 This loads the message from Exim&#x2019;s spool before doing the test expansions, and
12724 is therefore restricted to admin users.
12725 </para>
12726 </section>
12727 <section id="SECTforexpfai">
12728 <title>Forced expansion failure</title>
12729 <para>
12730 <indexterm role="concept">
12731 <primary>expansion</primary>
12732 <secondary>forced failure</secondary>
12733 </indexterm>
12734 A number of expansions that are described in the following section have
12735 alternative <quote>true</quote> and <quote>false</quote> substrings, enclosed in brace characters
12736 (which are sometimes called <quote>curly brackets</quote>). Which of the two strings is
12737 used depends on some condition that is evaluated as part of the expansion. If,
12738 instead of a <quote>false</quote> substring, the word <quote>fail</quote> is used (not in braces),
12739 the entire string expansion fails in a way that can be detected by the code
12740 that requested the expansion. This is called <quote>forced expansion failure</quote>, and
12741 its consequences depend on the circumstances. In some cases it is no different
12742 from any other expansion failure, but in others a different action may be
12743 taken. Such variations are mentioned in the documentation of the option that is
12744 being expanded.
12745 </para>
12746 </section>
12747 <section id="SECTexpansionitems">
12748 <title>Expansion items</title>
12749 <para>
12750 The following items are recognized in expanded strings. White space may be used
12751 between sub-items that are keywords or substrings enclosed in braces inside an
12752 outer set of braces, to improve readability. <emphasis role="bold">Warning</emphasis>: Within braces,
12753 white space is significant.
12754 </para>
12755 <variablelist>
12756 <varlistentry>
12757 <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>
12758 <listitem>
12759 <para>
12760 <indexterm role="concept">
12761 <primary>expansion</primary>
12762 <secondary>variables</secondary>
12763 </indexterm>
12764 Substitute the contents of the named variable, for example:
12765 </para>
12766 <literallayout class="monospaced">
12767 $local_part
12768 ${domain}
12769 </literallayout>
12770 <para>
12771 The second form can be used to separate the name from subsequent alphanumeric
12772 characters. This form (using braces) is available only for variables; it does
12773 <emphasis>not</emphasis> apply to message headers. The names of the variables are given in
12774 section <xref linkend="SECTexpvar"/> below. If the name of a non-existent variable is
12775 given, the expansion fails.
12776 </para>
12777 </listitem></varlistentry>
12778 <varlistentry>
12779 <term><emphasis role="bold">${</emphasis>&lt;<emphasis>op</emphasis>&gt;<emphasis role="bold">:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
12780 <listitem>
12781 <para>
12782 <indexterm role="concept">
12783 <primary>expansion</primary>
12784 <secondary>operators</secondary>
12785 </indexterm>
12786 The string is first itself expanded, and then the operation specified by
12787 &lt;<emphasis>op</emphasis>&gt; is applied to it. For example:
12788 </para>
12789 <literallayout class="monospaced">
12790 ${lc:$local_part}
12791 </literallayout>
12792 <para>
12793 The string starts with the first character after the colon, which may be
12794 leading white space. A list of operators is given in section <xref linkend="SECTexpop"/>
12795 below. The operator notation is used for simple expansion items that have just
12796 one argument, because it reduces the number of braces and therefore makes the
12797 string easier to understand.
12798 </para>
12799 </listitem></varlistentry>
12800 <varlistentry>
12801 <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>
12802 <listitem>
12803 <para>
12804 This item inserts <quote>basic</quote> header lines. It is described with the <option>header</option>
12805 expansion item below.
12806 </para>
12807 </listitem></varlistentry>
12808 <varlistentry>
12809 <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>
12810 <listitem>
12811 <para>
12812 <indexterm role="concept">
12813 <primary><option>dlfunc</option></primary>
12814 </indexterm>
12815 This expansion dynamically loads and then calls a locally-written C function.
12816 This functionality is available only if Exim is compiled with
12817 </para>
12818 <literallayout class="monospaced">
12819 EXPAND_DLFUNC=yes
12820 </literallayout>
12821 <para>
12822 set in <filename>Local/Makefile</filename>. Once loaded, Exim remembers the dynamically loaded
12823 object so that it doesn&#x2019;t reload the same object file in the same Exim process
12824 (but of course Exim does start new processes frequently).
12825 </para>
12826 <para>
12827 There may be from zero to eight arguments to the function. When compiling
12828 a local function that is to be called in this way, <filename>local_scan.h</filename> should be
12829 included. The Exim variables and functions that are defined by that API
12830 are also available for dynamically loaded functions. The function itself
12831 must have the following type:
12832 </para>
12833 <literallayout class="monospaced">
12834 int dlfunction(uschar **yield, int argc, uschar *argv[])
12835 </literallayout>
12836 <para>
12837 Where <literal>uschar</literal> is a typedef for <literal>unsigned char</literal> in <filename>local_scan.h</filename>. The
12838 function should return one of the following values:
12839 </para>
12840 <para>
12841 <literal>OK</literal>: Success. The string that is placed in the variable <emphasis>yield</emphasis> is put
12842 into the expanded string that is being built.
12843 </para>
12844 <para>
12845 <literal>FAIL</literal>: A non-forced expansion failure occurs, with the error message taken
12846 from <emphasis>yield</emphasis>, if it is set.
12847 </para>
12848 <para>
12849 <literal>FAIL_FORCED</literal>: A forced expansion failure occurs, with the error message
12850 taken from <emphasis>yield</emphasis> if it is set.
12851 </para>
12852 <para>
12853 <literal>ERROR</literal>: Same as <literal>FAIL</literal>, except that a panic log entry is written.
12854 </para>
12855 <para>
12856 When compiling a function that is to be used in this way with gcc,
12857 you need to add <option>-shared</option> to the gcc command. Also, in the Exim build-time
12858 configuration, you must add <option>-export-dynamic</option> to EXTRALIBS.
12859 </para>
12860 </listitem></varlistentry>
12861 <varlistentry>
12862 <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>
12863 <listitem>
12864 <para>
12865 <indexterm role="concept">
12866 <primary>expansion</primary>
12867 <secondary>extracting substrings by key</secondary>
12868 </indexterm>
12869 <indexterm role="concept">
12870 <primary><option>extract</option></primary>
12871 <secondary>substrings by key</secondary>
12872 </indexterm>
12873 The key and &lt;<emphasis>string1</emphasis>&gt; are first expanded separately. Leading and trailing
12874 white space is removed from the key (but not from any of the strings). The key
12875 must not consist entirely of digits. The expanded &lt;<emphasis>string1</emphasis>&gt; must be of the
12876 form:
12877 </para>
12878 <literallayout>
12879 &lt;<emphasis>key1</emphasis>&gt; = &lt;<emphasis>value1</emphasis>&gt;  &lt;<emphasis>key2</emphasis>&gt; = &lt;<emphasis>value2</emphasis>&gt; ...
12880 </literallayout>
12881 <para>
12882 <indexterm role="variable">
12883 <primary><varname>$value</varname></primary>
12884 </indexterm>
12885 where the equals signs and spaces (but not both) are optional. If any of the
12886 values contain white space, they must be enclosed in double quotes, and any
12887 values that are enclosed in double quotes are subject to escape processing as
12888 described in section <xref linkend="SECTstrings"/>. The expanded &lt;<emphasis>string1</emphasis>&gt; is searched
12889 for the value that corresponds to the key. The search is case-insensitive. If
12890 the key is found, &lt;<emphasis>string2</emphasis>&gt; is expanded, and replaces the whole item;
12891 otherwise &lt;<emphasis>string3</emphasis>&gt; is used. During the expansion of &lt;<emphasis>string2</emphasis>&gt; the
12892 variable <varname>$value</varname> contains the value that has been extracted. Afterwards, it
12893 is restored to any previous value it might have had.
12894 </para>
12895 <para>
12896 If {&lt;<emphasis>string3</emphasis>&gt;} is omitted, the item is replaced by an empty string if the
12897 key is not found. If {&lt;<emphasis>string2</emphasis>&gt;} is also omitted, the value that was
12898 extracted is used. Thus, for example, these two expansions are identical, and
12899 yield <quote>2001</quote>:
12900 </para>
12901 <literallayout class="monospaced">
12902 ${extract{gid}{uid=1984 gid=2001}}
12903 ${extract{gid}{uid=1984 gid=2001}{$value}}
12904 </literallayout>
12905 <para>
12906 Instead of {&lt;<emphasis>string3</emphasis>&gt;} the word <quote>fail</quote> (not in curly brackets) can
12907 appear, for example:
12908 </para>
12909 <literallayout class="monospaced">
12910 ${extract{Z}{A=... B=...}{$value} fail }
12911 </literallayout>
12912 <para>
12913 This forces an expansion failure (see section <xref linkend="SECTforexpfai"/>);
12914 {&lt;<emphasis>string2</emphasis>&gt;} must be present for <quote>fail</quote> to be recognized.
12915 </para>
12916 </listitem></varlistentry>
12917 <varlistentry>
12918 <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>
12919 <listitem>
12920 <para>
12921 <indexterm role="concept">
12922 <primary>expansion</primary>
12923 <secondary>extracting substrings by number</secondary>
12924 </indexterm>
12925 <indexterm role="concept">
12926 <primary><option>extract</option></primary>
12927 <secondary>substrings by number</secondary>
12928 </indexterm>
12929 The &lt;<emphasis>number</emphasis>&gt; argument must consist entirely of decimal digits,
12930 apart from leading and trailing white space, which is ignored.
12931 This is what distinguishes this form of <option>extract</option> from the previous kind. It
12932 behaves in the same way, except that, instead of extracting a named field, it
12933 extracts from &lt;<emphasis>string1</emphasis>&gt; the field whose number is given as the first
12934 argument. You can use <varname>$value</varname> in &lt;<emphasis>string2</emphasis>&gt; or <literal>fail</literal> instead of
12935 &lt;<emphasis>string3</emphasis>&gt; as before.
12936 </para>
12937 <para>
12938 The fields in the string are separated by any one of the characters in the
12939 separator string. These may include space or tab characters.
12940 The first field is numbered one. If the number is negative, the fields are
12941 counted from the end of the string, with the rightmost one numbered -1. If the
12942 number given is zero, the entire string is returned. If the modulus of the
12943 number is greater than the number of fields in the string, the result is the
12944 expansion of &lt;<emphasis>string3</emphasis>&gt;, or the empty string if &lt;<emphasis>string3</emphasis>&gt; is not
12945 provided. For example:
12946 </para>
12947 <literallayout class="monospaced">
12948 ${extract{2}{:}{x:42:99:&amp; Mailer::/bin/bash}}
12949 </literallayout>
12950 <para>
12951 yields <quote>42</quote>, and
12952 </para>
12953 <literallayout class="monospaced">
12954 ${extract{-4}{:}{x:42:99:&amp; Mailer::/bin/bash}}
12955 </literallayout>
12956 <para>
12957 yields <quote>99</quote>. Two successive separators mean that the field between them is
12958 empty (for example, the fifth field above).
12959 </para>
12960 </listitem></varlistentry>
12961 <varlistentry>
12962 <term><emphasis role="bold">${filter{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>condition</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
12963 <listitem>
12964 <para>
12965 <indexterm role="concept">
12966 <primary>list</primary>
12967 <secondary>selecting by condition</secondary>
12968 </indexterm>
12969 <indexterm role="concept">
12970 <primary>expansion</primary>
12971 <secondary>selecting from list by condition</secondary>
12972 </indexterm>
12973 <indexterm role="variable">
12974 <primary><varname>$item</varname></primary>
12975 </indexterm>
12976 After expansion, &lt;<emphasis>string</emphasis>&gt; is interpreted as a list, colon-separated by
12977 default, but the separator can be changed in the usual way. For each item
12978 in this list, its value is place in <varname>$item</varname>, and then the condition is
12979 evaluated. If the condition is true, <varname>$item</varname> is added to the output as an
12980 item in a new list; if the condition is false, the item is discarded. The
12981 separator used for the output list is the same as the one used for the
12982 input, but a separator setting is not included in the output. For example:
12983 </para>
12984 <literallayout class="monospaced">
12985 ${filter{a:b:c}{!eq{$item}{b}}
12986 </literallayout>
12987 <para>
12988 yields <literal>a:c</literal>. At the end of the expansion, the value of <varname>$item</varname> is restored
12989 to what it was before. See also the <emphasis role="bold">map</emphasis> and <emphasis role="bold">reduce</emphasis> expansion items.
12990 </para>
12991 </listitem></varlistentry>
12992 <varlistentry>
12993 <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>
12994 <listitem>
12995 <para>
12996 <indexterm role="concept">
12997 <primary>hash function</primary>
12998 <secondary>textual</secondary>
12999 </indexterm>
13000 <indexterm role="concept">
13001 <primary>expansion</primary>
13002 <secondary>textual hash</secondary>
13003 </indexterm>
13004 This is a textual hashing function, and was the first to be implemented in
13005 early versions of Exim. In current releases, there are other hashing functions
13006 (numeric, MD5, and SHA-1), which are described below.
13007 </para>
13008 <para>
13009 The first two strings, after expansion, must be numbers. Call them &lt;<emphasis>m</emphasis>&gt; and
13010 &lt;<emphasis>n</emphasis>&gt;. If you are using fixed values for these numbers, that is, if
13011 &lt;<emphasis>string1</emphasis>&gt; and &lt;<emphasis>string2</emphasis>&gt; do not change when they are expanded, you can
13012 use the simpler operator notation that avoids some of the braces:
13013 </para>
13014 <literallayout class="monospaced">
13015 ${hash_&lt;n&gt;_&lt;m&gt;:&lt;string&gt;}
13016 </literallayout>
13017 <para>
13018 The second number is optional (in both notations). If &lt;<emphasis>n</emphasis>&gt; is greater than
13019 or equal to the length of the string, the expansion item returns the string.
13020 Otherwise it computes a new string of length &lt;<emphasis>n</emphasis>&gt; by applying a hashing
13021 function to the string. The new string consists of characters taken from the
13022 first &lt;<emphasis>m</emphasis>&gt; characters of the string
13023 </para>
13024 <literallayout class="monospaced">
13025 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQWRSTUVWXYZ0123456789
13026 </literallayout>
13027 <para>
13028 If &lt;<emphasis>m</emphasis>&gt; is not present the value 26 is used, so that only lower case
13029 letters appear. For example:
13030 </para>
13031 <literallayout>
13032 <literal>$hash{3}{monty}}           </literal>   yields  <literal>jmg</literal>
13033 <literal>$hash{5}{monty}}           </literal>   yields  <literal>monty</literal>
13034 <literal>$hash{4}{62}{monty python}}</literal>   yields  <literal>fbWx</literal>
13035 </literallayout>
13036 </listitem></varlistentry>
13037 <varlistentry>
13038 <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>
13039 <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>
13040 <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>
13041 <listitem>
13042 <para>
13043 <indexterm role="concept">
13044 <primary>expansion</primary>
13045 <secondary>header insertion</secondary>
13046 </indexterm>
13047 <indexterm role="variable">
13048 <primary><varname>$header_</varname></primary>
13049 </indexterm>
13050 <indexterm role="variable">
13051 <primary><varname>$bheader_</varname></primary>
13052 </indexterm>
13053 <indexterm role="variable">
13054 <primary><varname>$rheader_</varname></primary>
13055 </indexterm>
13056 <indexterm role="concept">
13057 <primary>header lines</primary>
13058 <secondary>in expansion strings</secondary>
13059 </indexterm>
13060 <indexterm role="concept">
13061 <primary>header lines</primary>
13062 <secondary>character sets</secondary>
13063 </indexterm>
13064 <indexterm role="concept">
13065 <primary>header lines</primary>
13066 <secondary>decoding</secondary>
13067 </indexterm>
13068 Substitute the contents of the named message header line, for example
13069 </para>
13070 <literallayout class="monospaced">
13071 $header_reply-to:
13072 </literallayout>
13073 <para>
13074 The newline that terminates a header line is not included in the expansion, but
13075 internal newlines (caused by splitting the header line over several physical
13076 lines) may be present.
13077 </para>
13078 <para>
13079 The difference between <option>rheader</option>, <option>bheader</option>, and <option>header</option> is in the way
13080 the data in the header line is interpreted.
13081 </para>
13082 <itemizedlist>
13083 <listitem>
13084 <para>
13085 <indexterm role="concept">
13086 <primary>white space</primary>
13087 <secondary>in header lines</secondary>
13088 </indexterm>
13089 <option>rheader</option> gives the original <quote>raw</quote> content of the header line, with no
13090 processing at all, and without the removal of leading and trailing white space.
13091 </para>
13092 </listitem>
13093 <listitem>
13094 <para>
13095 <indexterm role="concept">
13096 <primary>base64 encoding</primary>
13097 <secondary>in header lines</secondary>
13098 </indexterm>
13099 <option>bheader</option> removes leading and trailing white space, and then decodes base64
13100 or quoted-printable MIME <quote>words</quote> within the header text, but does no
13101 character set translation. If decoding of what looks superficially like a MIME
13102 <quote>word</quote> fails, the raw string is returned. If decoding
13103 <indexterm role="concept">
13104 <primary>binary zero</primary>
13105 <secondary>in header line</secondary>
13106 </indexterm>
13107 produces a binary zero character, it is replaced by a question mark &ndash; this is
13108 what Exim does for binary zeros that are actually received in header lines.
13109 </para>
13110 </listitem>
13111 <listitem>
13112 <para>
13113 <option>header</option> tries to translate the string as decoded by <option>bheader</option> to a
13114 standard character set. This is an attempt to produce the same string as would
13115 be displayed on a user&#x2019;s MUA. If translation fails, the <option>bheader</option> string is
13116 returned. Translation is attempted only on operating systems that support the
13117 <function>iconv()</function> function. This is indicated by the compile-time macro HAVE_ICONV in
13118 a system Makefile or in <filename>Local/Makefile</filename>.
13119 </para>
13120 </listitem>
13121 </itemizedlist>
13122 <para>
13123 In a filter file, the target character set for <option>header</option> can be specified by a
13124 command of the following form:
13125 </para>
13126 <literallayout class="monospaced">
13127 headers charset "UTF-8"
13128 </literallayout>
13129 <para>
13130 This command affects all references to <varname>$h_</varname> (or <varname>$header_</varname>) expansions in
13131 subsequently obeyed filter commands. In the absence of this command, the target
13132 character set in a filter is taken from the setting of the <option>headers_charset</option>
13133 option in the runtime configuration. The value of this option defaults to the
13134 value of HEADERS_CHARSET in <filename>Local/Makefile</filename>. The ultimate default is
13135 ISO-8859-1.
13136 </para>
13137 <para>
13138 Header names follow the syntax of RFC 2822, which states that they may contain
13139 any printing characters except space and colon. Consequently, curly brackets
13140 <emphasis>do not</emphasis> terminate header names, and should not be used to enclose them as
13141 if they were variables. Attempting to do so causes a syntax error.
13142 </para>
13143 <para>
13144 Only header lines that are common to all copies of a message are visible to
13145 this mechanism. These are the original header lines that are received with the
13146 message, and any that are added by an ACL statement or by a system
13147 filter. Header lines that are added to a particular copy of a message by a
13148 router or transport are not accessible.
13149 </para>
13150 <para>
13151 For incoming SMTP messages, no header lines are visible in ACLs that are obeyed
13152 before the DATA ACL, because the header structure is not set up until the
13153 message is received. Header lines that are added in a RCPT ACL (for example)
13154 are saved until the message&#x2019;s incoming header lines are available, at which
13155 point they are added. When a DATA ACL is running, however, header lines added
13156 by earlier ACLs are visible.
13157 </para>
13158 <para>
13159 Upper case and lower case letters are synonymous in header names. If the
13160 following character is white space, the terminating colon may be omitted, but
13161 this is not recommended, because you may then forget it when it is needed. When
13162 white space terminates the header name, it is included in the expanded string.
13163 If the message does not contain the given header, the expansion item is
13164 replaced by an empty string. (See the <option>def</option> condition in section
13165 <xref linkend="SECTexpcond"/> for a means of testing for the existence of a header.)
13166 </para>
13167 <para>
13168 If there is more than one header with the same name, they are all concatenated
13169 to form the substitution string, up to a maximum length of 64K. Unless
13170 <option>rheader</option> is being used, leading and trailing white space is removed from
13171 each header before concatenation, and a completely empty header is ignored. A
13172 newline character is then inserted between non-empty headers, but there is no
13173 newline at the very end. For the <option>header</option> and <option>bheader</option> expansion, for
13174 those headers that contain lists of addresses, a comma is also inserted at the
13175 junctions between headers. This does not happen for the <option>rheader</option> expansion.
13176 </para>
13177 </listitem></varlistentry>
13178 <varlistentry>
13179 <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>
13180 <listitem>
13181 <para>
13182 <indexterm role="concept">
13183 <primary>expansion</primary>
13184 <secondary>hmac hashing</secondary>
13185 </indexterm>
13186 <indexterm role="concept">
13187 <primary><option>hmac</option></primary>
13188 </indexterm>
13189 This function uses cryptographic hashing (either MD5 or SHA-1) to convert a
13190 shared secret and some text into a message authentication code, as specified in
13191 RFC 2104. This differs from <literal>${md5:secret_text...}</literal> or
13192 <literal>${sha1:secret_text...}</literal> in that the hmac step adds a signature to the
13193 cryptographic hash, allowing for authentication that is not possible with MD5
13194 or SHA-1 alone. The hash name must expand to either <literal>md5</literal> or <literal>sha1</literal> at
13195 present. For example:
13196 </para>
13197 <literallayout class="monospaced">
13198 ${hmac{md5}{somesecret}{$primary_hostname $tod_log}}
13199 </literallayout>
13200 <para>
13201 For the hostname <emphasis>mail.example.com</emphasis> and time 2002-10-17 11:30:59, this
13202 produces:
13203 </para>
13204 <literallayout class="monospaced">
13205 dd97e3ba5d1a61b5006108f8c8252953
13206 </literallayout>
13207 <para>
13208 As an example of how this might be used, you might put in the main part of
13209 an Exim configuration:
13210 </para>
13211 <literallayout class="monospaced">
13212 SPAMSCAN_SECRET=cohgheeLei2thahw
13213 </literallayout>
13214 <para>
13215 In a router or a transport you could then have:
13216 </para>
13217 <literallayout class="monospaced">
13218 headers_add = \
13219   X-Spam-Scanned: ${primary_hostname} ${message_exim_id} \
13220   ${hmac{md5}{SPAMSCAN_SECRET}\
13221   {${primary_hostname},${message_exim_id},$h_message-id:}}
13222 </literallayout>
13223 <para>
13224 Then given a message, you can check where it was scanned by looking at the
13225 <emphasis>X-Spam-Scanned:</emphasis> header line. If you know the secret, you can check that
13226 this header line is authentic by recomputing the authentication code from the
13227 host name, message ID and the <emphasis>Message-id:</emphasis> header line. This can be done
13228 using Exim&#x2019;s <option>-be</option> option, or by other means, for example by using the
13229 <emphasis>hmac_md5_hex()</emphasis> function in Perl.
13230 </para>
13231 </listitem></varlistentry>
13232 <varlistentry>
13233 <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>
13234 <listitem>
13235 <para>
13236 <indexterm role="concept">
13237 <primary>expansion</primary>
13238 <secondary>conditional</secondary>
13239 </indexterm>
13240 <indexterm role="concept">
13241 <primary><option>if</option>, expansion item</primary>
13242 </indexterm>
13243 If &lt;<emphasis>condition</emphasis>&gt; is true, &lt;<emphasis>string1</emphasis>&gt; is expanded and replaces the whole
13244 item; otherwise &lt;<emphasis>string2</emphasis>&gt; is used. The available conditions are described
13245 in section <xref linkend="SECTexpcond"/> below. For example:
13246 </para>
13247 <literallayout class="monospaced">
13248 ${if eq {$local_part}{postmaster} {yes}{no} }
13249 </literallayout>
13250 <para>
13251 The second string need not be present; if it is not and the condition is not
13252 true, the item is replaced with nothing. Alternatively, the word <quote>fail</quote> may
13253 be present instead of the second string (without any curly brackets). In this
13254 case, the expansion is forced to fail if the condition is not true (see section
13255 <xref linkend="SECTforexpfai"/>).
13256 </para>
13257 <para>
13258 If both strings are omitted, the result is the string <literal>true</literal> if the condition
13259 is true, and the empty string if the condition is false. This makes it less
13260 cumbersome to write custom ACL and router conditions. For example, instead of
13261 </para>
13262 <literallayout class="monospaced">
13263 condition = ${if &gt;{$acl_m4}{3}{true}{false}}
13264 </literallayout>
13265 <para>
13266 you can use
13267 </para>
13268 <literallayout class="monospaced">
13269 condition = ${if &gt;{$acl_m4}{3}}
13270 </literallayout>
13271 </listitem></varlistentry>
13272 <varlistentry>
13273 <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>
13274 <listitem>
13275 <para>
13276 <indexterm role="concept">
13277 <primary>expansion</primary>
13278 <secondary>string truncation</secondary>
13279 </indexterm>
13280 <indexterm role="concept">
13281 <primary><option>length</option> expansion item</primary>
13282 </indexterm>
13283 The <option>length</option> item is used to extract the initial portion of a string. Both
13284 strings are expanded, and the first one must yield a number, &lt;<emphasis>n</emphasis>&gt;, say. If
13285 you are using a fixed value for the number, that is, if &lt;<emphasis>string1</emphasis>&gt; does not
13286 change when expanded, you can use the simpler operator notation that avoids
13287 some of the braces:
13288 </para>
13289 <literallayout class="monospaced">
13290 ${length_&lt;n&gt;:&lt;string&gt;}
13291 </literallayout>
13292 <para>
13293 The result of this item is either the first &lt;<emphasis>n</emphasis>&gt; characters or the whole
13294 of &lt;<emphasis>string2</emphasis>&gt;, whichever is the shorter. Do not confuse <option>length</option> with
13295 <option>strlen</option>, which gives the length of a string.
13296 </para>
13297 </listitem></varlistentry>
13298 <varlistentry>
13299 <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>
13300 <listitem>
13301 <para>
13302 This is the first of one of two different types of lookup item, which are both
13303 described in the next item.
13304 </para>
13305 </listitem></varlistentry>
13306 <varlistentry>
13307 <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>
13308 <listitem>
13309 <para>
13310 <indexterm role="concept">
13311 <primary>expansion</primary>
13312 <secondary>lookup in</secondary>
13313 </indexterm>
13314 <indexterm role="concept">
13315 <primary>file</primary>
13316 <secondary>lookups</secondary>
13317 </indexterm>
13318 <indexterm role="concept">
13319 <primary>lookup</primary>
13320 <secondary>in expanded string</secondary>
13321 </indexterm>
13322 The two forms of lookup item specify data lookups in files and databases, as
13323 discussed in chapter <xref linkend="CHAPfdlookup"/>. The first form is used for single-key
13324 lookups, and the second is used for query-style lookups. The &lt;<emphasis>key</emphasis>&gt;,
13325 &lt;<emphasis>file</emphasis>&gt;, and &lt;<emphasis>query</emphasis>&gt; strings are expanded before use.
13326 </para>
13327 <para>
13328 If there is any white space in a lookup item which is part of a filter command,
13329 a retry or rewrite rule, a routing rule for the <command>manualroute</command> router, or any
13330 other place where white space is significant, the lookup item must be enclosed
13331 in double quotes. The use of data lookups in users&#x2019; filter files may be locked
13332 out by the system administrator.
13333 </para>
13334 <para>
13335 <indexterm role="variable">
13336 <primary><varname>$value</varname></primary>
13337 </indexterm>
13338 If the lookup succeeds, &lt;<emphasis>string1</emphasis>&gt; is expanded and replaces the entire item.
13339 During its expansion, the variable <varname>$value</varname> contains the data returned by the
13340 lookup. Afterwards it reverts to the value it had previously (at the outer
13341 level it is empty). If the lookup fails, &lt;<emphasis>string2</emphasis>&gt; is expanded and replaces
13342 the entire item. If {&lt;<emphasis>string2</emphasis>&gt;} is omitted, the replacement is the empty
13343 string on failure. If &lt;<emphasis>string2</emphasis>&gt; is provided, it can itself be a nested
13344 lookup, thus providing a mechanism for looking up a default value when the
13345 original lookup fails.
13346 </para>
13347 <para>
13348 If a nested lookup is used as part of &lt;<emphasis>string1</emphasis>&gt;, <varname>$value</varname> contains the
13349 data for the outer lookup while the parameters of the second lookup are
13350 expanded, and also while &lt;<emphasis>string2</emphasis>&gt; of the second lookup is expanded, should
13351 the second lookup fail. Instead of {&lt;<emphasis>string2</emphasis>&gt;} the word <quote>fail</quote> can
13352 appear, and in this case, if the lookup fails, the entire expansion is forced
13353 to fail (see section <xref linkend="SECTforexpfai"/>). If both {&lt;<emphasis>string1</emphasis>&gt;} and
13354 {&lt;<emphasis>string2</emphasis>&gt;} are omitted, the result is the looked up value in the case of a
13355 successful lookup, and nothing in the case of failure.
13356 </para>
13357 <para>
13358 For single-key lookups, the string <quote>partial</quote> is permitted to precede the
13359 search type in order to do partial matching, and * or *@ may follow a search
13360 type to request default lookups if the key does not match (see sections
13361 <xref linkend="SECTdefaultvaluelookups"/> and <xref linkend="SECTpartiallookup"/> for details).
13362 </para>
13363 <para>
13364 <indexterm role="concept">
13365 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
13366 <secondary>in lookup expansion</secondary>
13367 </indexterm>
13368 If a partial search is used, the variables <varname>$1</varname> and <varname>$2</varname> contain the wild
13369 and non-wild parts of the key during the expansion of the replacement text.
13370 They return to their previous values at the end of the lookup item.
13371 </para>
13372 <para>
13373 This example looks up the postmaster alias in the conventional alias file:
13374 </para>
13375 <literallayout class="monospaced">
13376 ${lookup {postmaster} lsearch {/etc/aliases} {$value}}
13377 </literallayout>
13378 <para>
13379 This example uses NIS+ to look up the full name of the user corresponding to
13380 the local part of an address, forcing the expansion to fail if it is not found:
13381 </para>
13382 <literallayout class="monospaced">
13383 ${lookup nisplus {[name=$local_part],passwd.org_dir:gcos} \
13384   {$value}fail}
13385 </literallayout>
13386 </listitem></varlistentry>
13387 <varlistentry>
13388 <term><emphasis role="bold">${map{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
13389 <listitem>
13390 <para>
13391 <indexterm role="concept">
13392 <primary>expansion</primary>
13393 <secondary>list creation</secondary>
13394 </indexterm>
13395 <indexterm role="variable">
13396 <primary><varname>$item</varname></primary>
13397 </indexterm>
13398 After expansion, &lt;<emphasis>string1</emphasis>&gt; is interpreted as a list, colon-separated by
13399 default, but the separator can be changed in the usual way. For each item
13400 in this list, its value is place in <varname>$item</varname>, and then &lt;<emphasis>string2</emphasis>&gt; is
13401 expanded and added to the output as an item in a new list. The separator used
13402 for the output list is the same as the one used for the input, but a separator
13403 setting is not included in the output. For example:
13404 </para>
13405 <literallayout class="monospaced">
13406 ${map{a:b:c}{[$item]}} ${map{&lt;- x-y-z}{($item)}}
13407 </literallayout>
13408 <para>
13409 expands to <literal>[a]:[b]:[c] (x)-(y)-(z)</literal>. At the end of the expansion, the
13410 value of <varname>$item</varname> is restored to what it was before. See also the <emphasis role="bold">filter</emphasis>
13411 and <emphasis role="bold">reduce</emphasis> expansion items.
13412 </para>
13413 </listitem></varlistentry>
13414 <varlistentry>
13415 <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>
13416 <listitem>
13417 <para>
13418 <indexterm role="concept">
13419 <primary>expansion</primary>
13420 <secondary>numeric hash</secondary>
13421 </indexterm>
13422 <indexterm role="concept">
13423 <primary>hash function</primary>
13424 <secondary>numeric</secondary>
13425 </indexterm>
13426 The three strings are expanded; the first two must yield numbers. Call them
13427 &lt;<emphasis>n</emphasis>&gt; and &lt;<emphasis>m</emphasis>&gt;. If you are using fixed values for these numbers, that is,
13428 if &lt;<emphasis>string1</emphasis>&gt; and &lt;<emphasis>string2</emphasis>&gt; do not change when they are expanded, you
13429 can use the simpler operator notation that avoids some of the braces:
13430 </para>
13431 <literallayout class="monospaced">
13432 ${nhash_&lt;n&gt;_&lt;m&gt;:&lt;string&gt;}
13433 </literallayout>
13434 <para>
13435 The second number is optional (in both notations). If there is only one number,
13436 the result is a number in the range 0&ndash;&lt;<emphasis>n</emphasis>&gt;-1. Otherwise, the string is
13437 processed by a div/mod hash function that returns two numbers, separated by a
13438 slash, in the ranges 0 to &lt;<emphasis>n</emphasis>&gt;-1 and 0 to &lt;<emphasis>m</emphasis>&gt;-1, respectively. For
13439 example,
13440 </para>
13441 <literallayout class="monospaced">
13442 ${nhash{8}{64}{supercalifragilisticexpialidocious}}
13443 </literallayout>
13444 <para>
13445 returns the string <quote>6/33</quote>.
13446 </para>
13447 </listitem></varlistentry>
13448 <varlistentry>
13449 <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>
13450 <listitem>
13451 <para>
13452 <indexterm role="concept">
13453 <primary>Perl</primary>
13454 <secondary>use in expanded string</secondary>
13455 </indexterm>
13456 <indexterm role="concept">
13457 <primary>expansion</primary>
13458 <secondary>calling Perl from</secondary>
13459 </indexterm>
13460 This item is available only if Exim has been built to include an embedded Perl
13461 interpreter. The subroutine name and the arguments are first separately
13462 expanded, and then the Perl subroutine is called with those arguments. No
13463 additional arguments need be given; the maximum number permitted, including the
13464 name of the subroutine, is nine.
13465 </para>
13466 <para>
13467 The return value of the subroutine is inserted into the expanded string, unless
13468 the return value is <option>undef</option>. In that case, the expansion fails in the same
13469 way as an explicit <quote>fail</quote> on a lookup item. The return value is a scalar.
13470 Whatever you return is evaluated in a scalar context. For example, if you
13471 return the name of a Perl vector, the return value is the size of the vector,
13472 not its contents.
13473 </para>
13474 <para>
13475 If the subroutine exits by calling Perl&#x2019;s <option>die</option> function, the expansion fails
13476 with the error message that was passed to <option>die</option>. More details of the embedded
13477 Perl facility are given in chapter <xref linkend="CHAPperl"/>.
13478 </para>
13479 <para>
13480 The <command>redirect</command> router has an option called <option>forbid_filter_perl</option> which locks
13481 out the use of this expansion item in filter files.
13482 </para>
13483 </listitem></varlistentry>
13484 <varlistentry>
13485 <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>
13486 <listitem>
13487 <para>
13488 <indexterm role="concept">
13489 <primary><option>prvs</option> expansion item</primary>
13490 </indexterm>
13491 The first argument is a complete email address and the second is secret
13492 keystring. The third argument, specifying a key number, is optional. If absent,
13493 it defaults to 0. The result of the expansion is a prvs-signed email address,
13494 to be typically used with the <option>return_path</option> option on an <command>smtp</command> transport
13495 as part of a bounce address tag validation (BATV) scheme. For more discussion
13496 and an example, see section <xref linkend="SECTverifyPRVS"/>.
13497 </para>
13498 </listitem></varlistentry>
13499 <varlistentry>
13500 <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>
13501 <listitem>
13502 <para>
13503 <indexterm role="concept">
13504 <primary><option>prvscheck</option> expansion item</primary>
13505 </indexterm>
13506 This expansion item is the complement of the <option>prvs</option> item. It is used for
13507 checking prvs-signed addresses. If the expansion of the first argument does not
13508 yield a syntactically valid prvs-signed address, the whole item expands to the
13509 empty string. When the first argument does expand to a syntactically valid
13510 prvs-signed address, the second argument is expanded, with the prvs-decoded
13511 version of the address and the key number extracted from the address in the
13512 variables <varname>$prvscheck_address</varname> and <varname>$prvscheck_keynum</varname>, respectively.
13513 </para>
13514 <para>
13515 These two variables can be used in the expansion of the second argument to
13516 retrieve the secret. The validity of the prvs-signed address is then checked
13517 against the secret. The result is stored in the variable <varname>$prvscheck_result</varname>,
13518 which is empty for failure or <quote>1</quote> for success.
13519 </para>
13520 <para>
13521 The third argument is optional; if it is missing, it defaults to an empty
13522 string. This argument is now expanded. If the result is an empty string, the
13523 result of the expansion is the decoded version of the address. This is the case
13524 whether or not the signature was valid. Otherwise, the result of the expansion
13525 is the expansion of the third argument.
13526 </para>
13527 <para>
13528 All three variables can be used in the expansion of the third argument.
13529 However, once the expansion is complete, only <varname>$prvscheck_result</varname> remains set.
13530 For more discussion and an example, see section <xref linkend="SECTverifyPRVS"/>.
13531 </para>
13532 </listitem></varlistentry>
13533 <varlistentry>
13534 <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>
13535 <listitem>
13536 <para>
13537 <indexterm role="concept">
13538 <primary>expansion</primary>
13539 <secondary>inserting an entire file</secondary>
13540 </indexterm>
13541 <indexterm role="concept">
13542 <primary>file</primary>
13543 <secondary>inserting into expansion</secondary>
13544 </indexterm>
13545 <indexterm role="concept">
13546 <primary><option>readfile</option> expansion item</primary>
13547 </indexterm>
13548 The file name and end-of-line string are first expanded separately. The file is
13549 then read, and its contents replace the entire item. All newline characters in
13550 the file are replaced by the end-of-line string if it is present. Otherwise,
13551 newlines are left in the string.
13552 String expansion is not applied to the contents of the file. If you want this,
13553 you must wrap the item in an <option>expand</option> operator. If the file cannot be read,
13554 the string expansion fails.
13555 </para>
13556 <para>
13557 The <command>redirect</command> router has an option called <option>forbid_filter_readfile</option> which
13558 locks out the use of this expansion item in filter files.
13559 </para>
13560 </listitem></varlistentry>
13561 <varlistentry>
13562 <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>
13563 <listitem>
13564 <para>
13565 <indexterm role="concept">
13566 <primary>expansion</primary>
13567 <secondary>inserting from a socket</secondary>
13568 </indexterm>
13569 <indexterm role="concept">
13570 <primary>socket, use of in expansion</primary>
13571 </indexterm>
13572 <indexterm role="concept">
13573 <primary><option>readsocket</option> expansion item</primary>
13574 </indexterm>
13575 This item inserts data from a Unix domain or Internet socket into the expanded
13576 string. The minimal way of using it uses just two arguments, as in these
13577 examples:
13578 </para>
13579 <literallayout class="monospaced">
13580 ${readsocket{/socket/name}{request string}}
13581 ${readsocket{inet:some.host:1234}{request string}}
13582 </literallayout>
13583 <para>
13584 For a Unix domain socket, the first substring must be the path to the socket.
13585 For an Internet socket, the first substring must contain <literal>inet:</literal> followed by
13586 a host name or IP address, followed by a colon and a port, which can be a
13587 number or the name of a TCP port in <filename>/etc/services</filename>. An IP address may
13588 optionally be enclosed in square brackets. This is best for IPv6 addresses. For
13589 example:
13590 </para>
13591 <literallayout class="monospaced">
13592 ${readsocket{inet:[::1]:1234}{request string}}
13593 </literallayout>
13594 <para>
13595 Only a single host name may be given, but if looking it up yields more than
13596 one IP address, they are each tried in turn until a connection is made. For
13597 both kinds of socket, Exim makes a connection, writes the request string
13598 (unless it is an empty string) and reads from the socket until an end-of-file
13599 is read. A timeout of 5 seconds is applied. Additional, optional arguments
13600 extend what can be done. Firstly, you can vary the timeout. For example:
13601 </para>
13602 <literallayout class="monospaced">
13603 ${readsocket{/socket/name}{request string}{3s}}
13604 </literallayout>
13605 <para>
13606 A fourth argument allows you to change any newlines that are in the data
13607 that is read, in the same way as for <option>readfile</option> (see above). This example
13608 turns them into spaces:
13609 </para>
13610 <literallayout class="monospaced">
13611 ${readsocket{inet:127.0.0.1:3294}{request string}{3s}{ }}
13612 </literallayout>
13613 <para>
13614 As with all expansions, the substrings are expanded before the processing
13615 happens. Errors in these sub-expansions cause the expansion to fail. In
13616 addition, the following errors can occur:
13617 </para>
13618 <itemizedlist>
13619 <listitem>
13620 <para>
13621 Failure to create a socket file descriptor;
13622 </para>
13623 </listitem>
13624 <listitem>
13625 <para>
13626 Failure to connect the socket;
13627 </para>
13628 </listitem>
13629 <listitem>
13630 <para>
13631 Failure to write the request string;
13632 </para>
13633 </listitem>
13634 <listitem>
13635 <para>
13636 Timeout on reading from the socket.
13637 </para>
13638 </listitem>
13639 </itemizedlist>
13640 <para>
13641 By default, any of these errors causes the expansion to fail. However, if
13642 you supply a fifth substring, it is expanded and used when any of the above
13643 errors occurs. For example:
13644 </para>
13645 <literallayout class="monospaced">
13646 ${readsocket{/socket/name}{request string}{3s}{\n}\
13647   {socket failure}}
13648 </literallayout>
13649 <para>
13650 You can test for the existence of a Unix domain socket by wrapping this
13651 expansion in <literal>${if exists</literal>, but there is a race condition between that test
13652 and the actual opening of the socket, so it is safer to use the fifth argument
13653 if you want to be absolutely sure of avoiding an expansion error for a
13654 non-existent Unix domain socket, or a failure to connect to an Internet socket.
13655 </para>
13656 <para>
13657 The <command>redirect</command> router has an option called <option>forbid_filter_readsocket</option> which
13658 locks out the use of this expansion item in filter files.
13659 </para>
13660 </listitem></varlistentry>
13661 <varlistentry>
13662 <term><emphasis role="bold">${reduce{</emphasis>&lt;<emphasis>string1</emphasis>&gt;}{&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string3</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
13663 <listitem>
13664 <para>
13665 <indexterm role="concept">
13666 <primary>expansion</primary>
13667 <secondary>reducing a list to a scalar</secondary>
13668 </indexterm>
13669 <indexterm role="concept">
13670 <primary>list</primary>
13671 <secondary>reducing to a scalar</secondary>
13672 </indexterm>
13673 <indexterm role="variable">
13674 <primary><varname>$value</varname></primary>
13675 </indexterm>
13676 <indexterm role="variable">
13677 <primary><varname>$item</varname></primary>
13678 </indexterm>
13679 This operation reduces a list to a single, scalar string. After expansion,
13680 &lt;<emphasis>string1</emphasis>&gt; is interpreted as a list, colon-separated by default, but the
13681 separator can be changed in the usual way. Then &lt;<emphasis>string2</emphasis>&gt; is expanded and
13682 assigned to the <varname>$value</varname> variable. After this, each item in the &lt;<emphasis>string1</emphasis>&gt;
13683 list is assigned to <varname>$item</varname> in turn, and &lt;<emphasis>string3</emphasis>&gt; is expanded for each of
13684 them. The result of that expansion is assigned to <varname>$value</varname> before the next
13685 iteration. When the end of the list is reached, the final value of <varname>$value</varname> is
13686 added to the expansion output. The <emphasis role="bold">reduce</emphasis> expansion item can be used in a
13687 number of ways. For example, to add up a list of numbers:
13688 </para>
13689 <literallayout class="monospaced">
13690 ${reduce {&lt;, 1,2,3}{0}{${eval:$value+$item}}}
13691 </literallayout>
13692 <para>
13693 The result of that expansion would be <literal>6</literal>. The maximum of a list of numbers
13694 can be found:
13695 </para>
13696 <literallayout class="monospaced">
13697 ${reduce {3:0:9:4:6}{0}{${if &gt;{$item}{$value}{$item}{$value}}}}
13698 </literallayout>
13699 <para>
13700 At the end of a <emphasis role="bold">reduce</emphasis> expansion, the values of <varname>$item</varname> and <varname>$value</varname> are
13701 restored to what they were before. See also the <emphasis role="bold">filter</emphasis> and <emphasis role="bold">map</emphasis>
13702 expansion items.
13703 </para>
13704 </listitem></varlistentry>
13705 <varlistentry>
13706 <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>
13707 <listitem>
13708 <para>
13709 This item inserts <quote>raw</quote> header lines. It is described with the <option>header</option>
13710 expansion item above.
13711 </para>
13712 </listitem></varlistentry>
13713 <varlistentry>
13714 <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>
13715 <listitem>
13716 <para>
13717 <indexterm role="concept">
13718 <primary>expansion</primary>
13719 <secondary>running a command</secondary>
13720 </indexterm>
13721 <indexterm role="concept">
13722 <primary><option>run</option> expansion item</primary>
13723 </indexterm>
13724 The command and its arguments are first expanded separately, and then the
13725 command is run in a separate process, but under the same uid and gid. As in
13726 other command executions from Exim, a shell is not used by default. If you want
13727 a shell, you must explicitly code it.
13728 </para>
13729 <para>
13730 The standard input for the command exists, but is empty. The standard output
13731 and standard error are set to the same file descriptor.
13732 <indexterm role="concept">
13733 <primary>return code</primary>
13734 <secondary>from <option>run</option> expansion</secondary>
13735 </indexterm>
13736 <indexterm role="variable">
13737 <primary><varname>$value</varname></primary>
13738 </indexterm>
13739 If the command succeeds (gives a zero return code) &lt;<emphasis>string1</emphasis>&gt; is expanded
13740 and replaces the entire item; during this expansion, the standard output/error
13741 from the command is in the variable <varname>$value</varname>. If the command fails,
13742 &lt;<emphasis>string2</emphasis>&gt;, if present, is expanded and used. Once again, during the
13743 expansion, the standard output/error from the command is in the variable
13744 <varname>$value</varname>.
13745 </para>
13746 <para>
13747 If &lt;<emphasis>string2</emphasis>&gt; is absent, the result is empty. Alternatively, &lt;<emphasis>string2</emphasis>&gt;
13748 can be the word <quote>fail</quote> (not in braces) to force expansion failure if the
13749 command does not succeed. If both strings are omitted, the result is contents
13750 of the standard output/error on success, and nothing on failure.
13751 </para>
13752 <para>
13753 <indexterm role="variable">
13754 <primary><varname>$runrc</varname></primary>
13755 </indexterm>
13756 The return code from the command is put in the variable <varname>$runrc</varname>, and this
13757 remains set afterwards, so in a filter file you can do things like this:
13758 </para>
13759 <literallayout class="monospaced">
13760 if "${run{x y z}{}}$runrc" is 1 then ...
13761   elif $runrc is 2 then ...
13762   ...
13763 endif
13764 </literallayout>
13765 <para>
13766 If execution of the command fails (for example, the command does not exist),
13767 the return code is 127 &ndash; the same code that shells use for non-existent
13768 commands.
13769 </para>
13770 <para>
13771 <emphasis role="bold">Warning</emphasis>: In a router or transport, you cannot assume the order in which
13772 option values are expanded, except for those preconditions whose order of
13773 testing is documented. Therefore, you cannot reliably expect to set <varname>$runrc</varname>
13774 by the expansion of one option, and use it in another.
13775 </para>
13776 <para>
13777 The <command>redirect</command> router has an option called <option>forbid_filter_run</option> which locks
13778 out the use of this expansion item in filter files.
13779 </para>
13780 </listitem></varlistentry>
13781 <varlistentry>
13782 <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>
13783 <listitem>
13784 <para>
13785 <indexterm role="concept">
13786 <primary>expansion</primary>
13787 <secondary>string substitution</secondary>
13788 </indexterm>
13789 <indexterm role="concept">
13790 <primary><option>sg</option> expansion item</primary>
13791 </indexterm>
13792 This item works like Perl&#x2019;s substitution operator (s) with the global (/g)
13793 option; hence its name. However, unlike the Perl equivalent, Exim does not
13794 modify the subject string; instead it returns the modified string for insertion
13795 into the overall expansion. The item takes three arguments: the subject string,
13796 a regular expression, and a substitution string. For example:
13797 </para>
13798 <literallayout class="monospaced">
13799 ${sg{abcdefabcdef}{abc}{xyz}}
13800 </literallayout>
13801 <para>
13802 yields <quote>xyzdefxyzdef</quote>. Because all three arguments are expanded before use,
13803 if any $ or \ characters are required in the regular expression or in the
13804 substitution string, they have to be escaped. For example:
13805 </para>
13806 <literallayout class="monospaced">
13807 ${sg{abcdef}{^(...)(...)\$}{\$2\$1}}
13808 </literallayout>
13809 <para>
13810 yields <quote>defabc</quote>, and
13811 </para>
13812 <literallayout class="monospaced">
13813 ${sg{1=A 4=D 3=C}{\N(\d+)=\N}{K\$1=}}
13814 </literallayout>
13815 <para>
13816 yields <quote>K1=A K4=D K3=C</quote>. Note the use of <literal>\N</literal> to protect the contents of
13817 the regular expression from string expansion.
13818 </para>
13819 </listitem></varlistentry>
13820 <varlistentry>
13821 <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>
13822 <listitem>
13823 <para>
13824 <indexterm role="concept">
13825 <primary><option>substr</option> expansion item</primary>
13826 </indexterm>
13827 <indexterm role="concept">
13828 <primary>substring extraction</primary>
13829 </indexterm>
13830 <indexterm role="concept">
13831 <primary>expansion</primary>
13832 <secondary>substring extraction</secondary>
13833 </indexterm>
13834 The three strings are expanded; the first two must yield numbers. Call them
13835 &lt;<emphasis>n</emphasis>&gt; and &lt;<emphasis>m</emphasis>&gt;. If you are using fixed values for these numbers, that is,
13836 if &lt;<emphasis>string1</emphasis>&gt; and &lt;<emphasis>string2</emphasis>&gt; do not change when they are expanded, you
13837 can use the simpler operator notation that avoids some of the braces:
13838 </para>
13839 <literallayout class="monospaced">
13840 ${substr_&lt;n&gt;_&lt;m&gt;:&lt;string&gt;}
13841 </literallayout>
13842 <para>
13843 The second number is optional (in both notations).
13844 If it is absent in the simpler format, the preceding underscore must also be
13845 omitted.
13846 </para>
13847 <para>
13848 The <option>substr</option> item can be used to extract more general substrings than
13849 <option>length</option>. The first number, &lt;<emphasis>n</emphasis>&gt;, is a starting offset, and &lt;<emphasis>m</emphasis>&gt; is the
13850 length required. For example
13851 </para>
13852 <literallayout class="monospaced">
13853 ${substr{3}{2}{$local_part}}
13854 </literallayout>
13855 <para>
13856 If the starting offset is greater than the string length the result is the
13857 null string; if the length plus starting offset is greater than the string
13858 length, the result is the right-hand part of the string, starting from the
13859 given offset. The first character in the string has offset zero.
13860 </para>
13861 <para>
13862 The <option>substr</option> expansion item can take negative offset values to count
13863 from the right-hand end of its operand. The last character is offset -1, the
13864 second-last is offset -2, and so on. Thus, for example,
13865 </para>
13866 <literallayout class="monospaced">
13867 ${substr{-5}{2}{1234567}}
13868 </literallayout>
13869 <para>
13870 yields <quote>34</quote>. If the absolute value of a negative offset is greater than the
13871 length of the string, the substring starts at the beginning of the string, and
13872 the length is reduced by the amount of overshoot. Thus, for example,
13873 </para>
13874 <literallayout class="monospaced">
13875 ${substr{-5}{2}{12}}
13876 </literallayout>
13877 <para>
13878 yields an empty string, but
13879 </para>
13880 <literallayout class="monospaced">
13881 ${substr{-3}{2}{12}}
13882 </literallayout>
13883 <para>
13884 yields <quote>1</quote>.
13885 </para>
13886 <para>
13887 When the second number is omitted from <option>substr</option>, the remainder of the string
13888 is taken if the offset is positive. If it is negative, all characters in the
13889 string preceding the offset point are taken. For example, an offset of -1 and
13890 no length, as in these semantically identical examples:
13891 </para>
13892 <literallayout class="monospaced">
13893 ${substr_-1:abcde}
13894 ${substr{-1}{abcde}}
13895 </literallayout>
13896 <para>
13897 yields all but the last character of the string, that is, <quote>abcd</quote>.
13898 </para>
13899 </listitem></varlistentry>
13900 <varlistentry>
13901 <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>
13902 <listitem>
13903 <para>
13904 <indexterm role="concept">
13905 <primary>expansion</primary>
13906 <secondary>character translation</secondary>
13907 </indexterm>
13908 <indexterm role="concept">
13909 <primary><option>tr</option> expansion item</primary>
13910 </indexterm>
13911 This item does single-character translation on its subject string. The second
13912 argument is a list of characters to be translated in the subject string. Each
13913 matching character is replaced by the corresponding character from the
13914 replacement list. For example
13915 </para>
13916 <literallayout class="monospaced">
13917 ${tr{abcdea}{ac}{13}}
13918 </literallayout>
13919 <para>
13920 yields <literal>1b3de1</literal>. If there are duplicates in the second character string, the
13921 last occurrence is used. If the third string is shorter than the second, its
13922 last character is replicated. However, if it is empty, no translation takes
13923 place.
13924 </para>
13925 </listitem></varlistentry>
13926 </variablelist>
13927 </section>
13928 <section id="SECTexpop">
13929 <title>Expansion operators</title>
13930 <para>
13931 <indexterm role="concept">
13932 <primary>expansion</primary>
13933 <secondary>operators</secondary>
13934 </indexterm>
13935 For expansion items that perform transformations on a single argument string,
13936 the <quote>operator</quote> notation is used because it is simpler and uses fewer braces.
13937 The substring is first expanded before the operation is applied to it. The
13938 following operations can be performed:
13939 </para>
13940 <variablelist>
13941 <varlistentry>
13942 <term><emphasis role="bold">${address:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13943 <listitem>
13944 <para>
13945 <indexterm role="concept">
13946 <primary>expansion</primary>
13947 <secondary>RFC 2822 address handling</secondary>
13948 </indexterm>
13949 <indexterm role="concept">
13950 <primary><option>address</option> expansion item</primary>
13951 </indexterm>
13952 The string is interpreted as an RFC 2822 address, as it might appear in a
13953 header line, and the effective address is extracted from it. If the string does
13954 not parse successfully, the result is empty.
13955 </para>
13956 </listitem></varlistentry>
13957 <varlistentry>
13958 <term><emphasis role="bold">${addresses:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13959 <listitem>
13960 <para>
13961 <indexterm role="concept">
13962 <primary>expansion</primary>
13963 <secondary>RFC 2822 address handling</secondary>
13964 </indexterm>
13965 <indexterm role="concept">
13966 <primary><option>addresses</option> expansion item</primary>
13967 </indexterm>
13968 The string (after expansion) is interpreted as a list of addresses in RFC
13969 2822 format, such as can be found in a <emphasis>To:</emphasis> or <emphasis>Cc:</emphasis> header line. The
13970 operative address (<emphasis>local-part@domain</emphasis>) is extracted from each item, and the
13971 result of the expansion is a colon-separated list, with appropriate
13972 doubling of colons should any happen to be present in the email addresses.
13973 Syntactically invalid RFC2822 address items are omitted from the output.
13974 </para>
13975 <para>
13976 It is possible to specify a character other than colon for the output
13977 separator by starting the string with &gt; followed by the new separator
13978 character. For example:
13979 </para>
13980 <literallayout class="monospaced">
13981 ${addresses:&gt;&amp; Chief &lt;ceo@up.stairs&gt;, sec@base.ment (dogsbody)}
13982 </literallayout>
13983 <para>
13984 expands to <literal>ceo@up.stairs&amp;sec@base.ment</literal>. Compare the <emphasis role="bold">address</emphasis> (singular)
13985 expansion item, which extracts the working address from a single RFC2822
13986 address. See the <emphasis role="bold">filter</emphasis>, <emphasis role="bold">map</emphasis>, and <emphasis role="bold">reduce</emphasis> items for ways of
13987 processing lists.
13988 </para>
13989 </listitem></varlistentry>
13990 <varlistentry>
13991 <term><emphasis role="bold">${base62:</emphasis>&lt;<emphasis>digits</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13992 <listitem>
13993 <para>
13994 <indexterm role="concept">
13995 <primary><option>base62</option> expansion item</primary>
13996 </indexterm>
13997 <indexterm role="concept">
13998 <primary>expansion</primary>
13999 <secondary>conversion to base 62</secondary>
14000 </indexterm>
14001 The string must consist entirely of decimal digits. The number is converted to
14002 base 62 and output as a string of six characters, including leading zeros. In
14003 the few operating environments where Exim uses base 36 instead of base 62 for
14004 its message identifiers (because those systems do not have case-sensitive file
14005 names), base 36 is used by this operator, despite its name. <emphasis role="bold">Note</emphasis>: Just to
14006 be absolutely clear: this is <emphasis>not</emphasis> base64 encoding.
14007 </para>
14008 </listitem></varlistentry>
14009 <varlistentry>
14010 <term><emphasis role="bold">${base62d:</emphasis>&lt;<emphasis>base-62&nbsp;digits</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14011 <listitem>
14012 <para>
14013 <indexterm role="concept">
14014 <primary><option>base62d</option> expansion item</primary>
14015 </indexterm>
14016 <indexterm role="concept">
14017 <primary>expansion</primary>
14018 <secondary>conversion to base 62</secondary>
14019 </indexterm>
14020 The string must consist entirely of base-62 digits, or, in operating
14021 environments where Exim uses base 36 instead of base 62 for its message
14022 identifiers, base-36 digits. The number is converted to decimal and output as a
14023 string.
14024 </para>
14025 </listitem></varlistentry>
14026 <varlistentry>
14027 <term><emphasis role="bold">${domain:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14028 <listitem>
14029 <para>
14030 <indexterm role="concept">
14031 <primary>domain</primary>
14032 <secondary>extraction</secondary>
14033 </indexterm>
14034 <indexterm role="concept">
14035 <primary>expansion</primary>
14036 <secondary>domain extraction</secondary>
14037 </indexterm>
14038 The string is interpreted as an RFC 2822 address and the domain is extracted
14039 from it. If the string does not parse successfully, the result is empty.
14040 </para>
14041 </listitem></varlistentry>
14042 <varlistentry>
14043 <term><emphasis role="bold">${escape:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14044 <listitem>
14045 <para>
14046 <indexterm role="concept">
14047 <primary>expansion</primary>
14048 <secondary>escaping non-printing characters</secondary>
14049 </indexterm>
14050 <indexterm role="concept">
14051 <primary><option>escape</option> expansion item</primary>
14052 </indexterm>
14053 If the string contains any non-printing characters, they are converted to
14054 escape sequences starting with a backslash. Whether characters with the most
14055 significant bit set (so-called <quote>8-bit characters</quote>) count as printing or not
14056 is controlled by the <option>print_topbitchars</option> option.
14057 </para>
14058 </listitem></varlistentry>
14059 <varlistentry>
14060 <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>
14061 <listitem>
14062 <para>
14063 <indexterm role="concept">
14064 <primary>expansion</primary>
14065 <secondary>expression evaluation</secondary>
14066 </indexterm>
14067 <indexterm role="concept">
14068 <primary>expansion</primary>
14069 <secondary>arithmetic expression</secondary>
14070 </indexterm>
14071 <indexterm role="concept">
14072 <primary><option>eval</option> expansion item</primary>
14073 </indexterm>
14074 These items supports simple arithmetic and bitwise logical operations in
14075 expansion strings. The string (after expansion) must be a conventional
14076 arithmetic expression, but it is limited to basic arithmetic operators, bitwise
14077 logical operators, and parentheses. All operations are carried out using
14078 integer arithmetic. The operator priorities are as follows (the same as in the
14079 C programming language):
14080 </para>
14081 <informaltable frame="none">
14082 <tgroup cols="2" colsep="0" rowsep="0">
14083 <colspec colwidth="70pt" align="left"/>
14084 <colspec colwidth="300pt" align="left"/>
14085 <tbody>
14086 <row>
14087 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>highest:</emphasis></entry>
14088 <entry>not (~), negate (-)</entry>
14089 </row>
14090 <row>
14091 <entry>&nbsp;&nbsp;&nbsp;&nbsp;</entry>
14092 <entry>multiply (*), divide (/), remainder (%)</entry>
14093 </row>
14094 <row>
14095 <entry>&nbsp;&nbsp;&nbsp;&nbsp;</entry>
14096 <entry>plus (+), minus (-)</entry>
14097 </row>
14098 <row>
14099 <entry>&nbsp;&nbsp;&nbsp;&nbsp;</entry>
14100 <entry>shift-left (&lt;&lt;), shift-right (&gt;&gt;)</entry>
14101 </row>
14102 <row>
14103 <entry>&nbsp;&nbsp;&nbsp;&nbsp;</entry>
14104 <entry>and (&amp;)</entry>
14105 </row>
14106 <row>
14107 <entry>&nbsp;&nbsp;&nbsp;&nbsp;</entry>
14108 <entry>xor (^)</entry>
14109 </row>
14110 <row>
14111 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>lowest:</emphasis></entry>
14112 <entry>or (|)</entry>
14113 </row>
14114 </tbody>
14115 </tgroup>
14116 </informaltable>
14117 <para>
14118 Binary operators with the same priority are evaluated from left to right. White
14119 space is permitted before or after operators.
14120 </para>
14121 <para>
14122 For <option>eval</option>, numbers may be decimal, octal (starting with <quote>0</quote>) or
14123 hexadecimal (starting with <quote>0x</quote>). For <option>eval10</option>, all numbers are taken as
14124 decimal, even if they start with a leading zero; hexadecimal numbers are not
14125 permitted. This can be useful when processing numbers extracted from dates or
14126 times, which often do have leading zeros.
14127 </para>
14128 <para>
14129 A number may be followed by <quote>K</quote> or <quote>M</quote> to multiply it by 1024 or 1024*1024,
14130 respectively. Negative numbers are supported. The result of the computation is
14131 a decimal representation of the answer (without <quote>K</quote> or <quote>M</quote>). For example:
14132 </para>
14133 <literallayout>
14134 <literal>${eval:1+1}            </literal>  yields 2
14135 <literal>${eval:1+2*3}          </literal>  yields 7
14136 <literal>${eval:(1+2)*3}        </literal>  yields 9
14137 <literal>${eval:2+42%5}         </literal>  yields 4
14138 <literal>${eval:0xc&amp;5}          </literal>  yields 4
14139 <literal>${eval:0xc|5}          </literal>  yields 13
14140 <literal>${eval:0xc^5}          </literal>  yields 9
14141 <literal>${eval:0xc&gt;&gt;1}         </literal>  yields 6
14142 <literal>${eval:0xc&lt;&lt;1}         </literal>  yields 24
14143 <literal>${eval:~255&amp;0x1234}    </literal>  yields 4608
14144 <literal>${eval:-(~255&amp;0x1234)} </literal>  yields -4608
14145 </literallayout>
14146 <para>
14147 As a more realistic example, in an ACL you might have
14148 </para>
14149 <literallayout class="monospaced">
14150 deny   message = Too many bad recipients
14151        condition =                    \
14152          ${if and {                   \
14153            {&gt;{$rcpt_count}{10}}       \
14154            {                          \
14155            &lt;                          \
14156              {$recipients_count}      \
14157              {${eval:$rcpt_count/2}}  \
14158            }                          \
14159          }{yes}{no}}
14160 </literallayout>
14161 <para>
14162 The condition is true if there have been more than 10 RCPT commands and
14163 fewer than half of them have resulted in a valid recipient.
14164 </para>
14165 </listitem></varlistentry>
14166 <varlistentry>
14167 <term><emphasis role="bold">${expand:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14168 <listitem>
14169 <para>
14170 <indexterm role="concept">
14171 <primary>expansion</primary>
14172 <secondary>re-expansion of substring</secondary>
14173 </indexterm>
14174 The <option>expand</option> operator causes a string to be expanded for a second time. For
14175 example,
14176 </para>
14177 <literallayout class="monospaced">
14178 ${expand:${lookup{$domain}dbm{/some/file}{$value}}}
14179 </literallayout>
14180 <para>
14181 first looks up a string in a file while expanding the operand for <option>expand</option>,
14182 and then re-expands what it has found.
14183 </para>
14184 </listitem></varlistentry>
14185 <varlistentry>
14186 <term><emphasis role="bold">${from_utf8:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14187 <listitem>
14188 <para>
14189 <indexterm role="concept">
14190 <primary>Unicode</primary>
14191 </indexterm>
14192 <indexterm role="concept">
14193 <primary>UTF-8</primary>
14194 <secondary>conversion from</secondary>
14195 </indexterm>
14196 <indexterm role="concept">
14197 <primary>expansion</primary>
14198 <secondary>UTF-8 conversion</secondary>
14199 </indexterm>
14200 <indexterm role="concept">
14201 <primary><option>from_utf8</option> expansion item</primary>
14202 </indexterm>
14203 The world is slowly moving towards Unicode, although there are no standards for
14204 email yet. However, other applications (including some databases) are starting
14205 to store data in Unicode, using UTF-8 encoding. This operator converts from a
14206 UTF-8 string to an ISO-8859-1 string. UTF-8 code values greater than 255 are
14207 converted to underscores. The input must be a valid UTF-8 string. If it is not,
14208 the result is an undefined sequence of bytes.
14209 </para>
14210 <para>
14211 Unicode code points with values less than 256 are compatible with ASCII and
14212 ISO-8859-1 (also known as Latin-1).
14213 For example, character 169 is the copyright symbol in both cases, though the
14214 way it is encoded is different. In UTF-8, more than one byte is needed for
14215 characters with code values greater than 127, whereas ISO-8859-1 is a
14216 single-byte encoding (but thereby limited to 256 characters). This makes
14217 translation from UTF-8 to ISO-8859-1 straightforward.
14218 </para>
14219 </listitem></varlistentry>
14220 <varlistentry>
14221 <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>
14222 <listitem>
14223 <para>
14224 <indexterm role="concept">
14225 <primary>hash function</primary>
14226 <secondary>textual</secondary>
14227 </indexterm>
14228 <indexterm role="concept">
14229 <primary>expansion</primary>
14230 <secondary>textual hash</secondary>
14231 </indexterm>
14232 The <option>hash</option> operator is a simpler interface to the hashing function that can
14233 be used when the two parameters are fixed numbers (as opposed to strings that
14234 change when expanded). The effect is the same as
14235 </para>
14236 <literallayout class="monospaced">
14237 ${hash{&lt;n&gt;}{&lt;m&gt;}{&lt;string&gt;}}
14238 </literallayout>
14239 <para>
14240 See the description of the general <option>hash</option> item above for details. The
14241 abbreviation <option>h</option> can be used when <option>hash</option> is used as an operator.
14242 </para>
14243 </listitem></varlistentry>
14244 <varlistentry>
14245 <term><emphasis role="bold">${hex2b64:</emphasis>&lt;<emphasis>hexstring</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14246 <listitem>
14247 <para>
14248 <indexterm role="concept">
14249 <primary>base64 encoding</primary>
14250 <secondary>conversion from hex</secondary>
14251 </indexterm>
14252 <indexterm role="concept">
14253 <primary>expansion</primary>
14254 <secondary>hex to base64</secondary>
14255 </indexterm>
14256 <indexterm role="concept">
14257 <primary><option>hex2b64</option> expansion item</primary>
14258 </indexterm>
14259 This operator converts a hex string into one that is base64 encoded. This can
14260 be useful for processing the output of the MD5 and SHA-1 hashing functions.
14261 </para>
14262 </listitem></varlistentry>
14263 <varlistentry>
14264 <term><emphasis role="bold">${lc:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14265 <listitem>
14266 <para>
14267 <indexterm role="concept">
14268 <primary>case forcing in strings</primary>
14269 </indexterm>
14270 <indexterm role="concept">
14271 <primary>string</primary>
14272 <secondary>case forcing</secondary>
14273 </indexterm>
14274 <indexterm role="concept">
14275 <primary>lower casing</primary>
14276 </indexterm>
14277 <indexterm role="concept">
14278 <primary>expansion</primary>
14279 <secondary>case forcing</secondary>
14280 </indexterm>
14281 <indexterm role="concept">
14282 <primary><option>lc</option> expansion item</primary>
14283 </indexterm>
14284 This forces the letters in the string into lower-case, for example:
14285 </para>
14286 <literallayout class="monospaced">
14287 ${lc:$local_part}
14288 </literallayout>
14289 </listitem></varlistentry>
14290 <varlistentry>
14291 <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>
14292 <listitem>
14293 <para>
14294 <indexterm role="concept">
14295 <primary>expansion</primary>
14296 <secondary>string truncation</secondary>
14297 </indexterm>
14298 <indexterm role="concept">
14299 <primary><option>length</option> expansion item</primary>
14300 </indexterm>
14301 The <option>length</option> operator is a simpler interface to the <option>length</option> function that
14302 can be used when the parameter is a fixed number (as opposed to a string that
14303 changes when expanded). The effect is the same as
14304 </para>
14305 <literallayout class="monospaced">
14306 ${length{&lt;number&gt;}{&lt;string&gt;}}
14307 </literallayout>
14308 <para>
14309 See the description of the general <option>length</option> item above for details. Note that
14310 <option>length</option> is not the same as <option>strlen</option>. The abbreviation <option>l</option> can be used
14311 when <option>length</option> is used as an operator.
14312 </para>
14313 </listitem></varlistentry>
14314 <varlistentry>
14315 <term><emphasis role="bold">${local_part:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14316 <listitem>
14317 <para>
14318 <indexterm role="concept">
14319 <primary>expansion</primary>
14320 <secondary>local part extraction</secondary>
14321 </indexterm>
14322 <indexterm role="concept">
14323 <primary><option>local_part</option> expansion item</primary>
14324 </indexterm>
14325 The string is interpreted as an RFC 2822 address and the local part is
14326 extracted from it. If the string does not parse successfully, the result is
14327 empty.
14328 </para>
14329 </listitem></varlistentry>
14330 <varlistentry>
14331 <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>
14332 <listitem>
14333 <para>
14334 <indexterm role="concept">
14335 <primary>masked IP address</primary>
14336 </indexterm>
14337 <indexterm role="concept">
14338 <primary>IP address</primary>
14339 <secondary>masking</secondary>
14340 </indexterm>
14341 <indexterm role="concept">
14342 <primary>CIDR notation</primary>
14343 </indexterm>
14344 <indexterm role="concept">
14345 <primary>expansion</primary>
14346 <secondary>IP address masking</secondary>
14347 </indexterm>
14348 <indexterm role="concept">
14349 <primary><option>mask</option> expansion item</primary>
14350 </indexterm>
14351 If the form of the string to be operated on is not an IP address followed by a
14352 slash and an integer (that is, a network address in CIDR notation), the
14353 expansion fails. Otherwise, this operator converts the IP address to binary,
14354 masks off the least significant bits according to the bit count, and converts
14355 the result back to text, with mask appended. For example,
14356 </para>
14357 <literallayout class="monospaced">
14358 ${mask:10.111.131.206/28}
14359 </literallayout>
14360 <para>
14361 returns the string <quote>10.111.131.192/28</quote>. Since this operation is expected to
14362 be mostly used for looking up masked addresses in files, the result for an IPv6
14363 address uses dots to separate components instead of colons, because colon
14364 terminates a key string in lsearch files. So, for example,
14365 </para>
14366 <literallayout class="monospaced">
14367 ${mask:3ffe:ffff:836f:0a00:000a:0800:200a:c031/99}
14368 </literallayout>
14369 <para>
14370 returns the string
14371 </para>
14372 <literallayout class="monospaced">
14373 3ffe.ffff.836f.0a00.000a.0800.2000.0000/99
14374 </literallayout>
14375 <para>
14376 Letters in IPv6 addresses are always output in lower case.
14377 </para>
14378 </listitem></varlistentry>
14379 <varlistentry>
14380 <term><emphasis role="bold">${md5:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14381 <listitem>
14382 <para>
14383 <indexterm role="concept">
14384 <primary>MD5 hash</primary>
14385 </indexterm>
14386 <indexterm role="concept">
14387 <primary>expansion</primary>
14388 <secondary>MD5 hash</secondary>
14389 </indexterm>
14390 <indexterm role="concept">
14391 <primary><option>md5</option> expansion item</primary>
14392 </indexterm>
14393 The <option>md5</option> operator computes the MD5 hash value of the string, and returns it
14394 as a 32-digit hexadecimal number, in which any letters are in lower case.
14395 </para>
14396 </listitem></varlistentry>
14397 <varlistentry>
14398 <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>
14399 <listitem>
14400 <para>
14401 <indexterm role="concept">
14402 <primary>expansion</primary>
14403 <secondary>numeric hash</secondary>
14404 </indexterm>
14405 <indexterm role="concept">
14406 <primary>hash function</primary>
14407 <secondary>numeric</secondary>
14408 </indexterm>
14409 The <option>nhash</option> operator is a simpler interface to the numeric hashing function
14410 that can be used when the two parameters are fixed numbers (as opposed to
14411 strings that change when expanded). The effect is the same as
14412 </para>
14413 <literallayout class="monospaced">
14414 ${nhash{&lt;n&gt;}{&lt;m&gt;}{&lt;string&gt;}}
14415 </literallayout>
14416 <para>
14417 See the description of the general <option>nhash</option> item above for details.
14418 </para>
14419 </listitem></varlistentry>
14420 <varlistentry>
14421 <term><emphasis role="bold">${quote:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14422 <listitem>
14423 <para>
14424 <indexterm role="concept">
14425 <primary>quoting</primary>
14426 <secondary>in string expansions</secondary>
14427 </indexterm>
14428 <indexterm role="concept">
14429 <primary>expansion</primary>
14430 <secondary>quoting</secondary>
14431 </indexterm>
14432 <indexterm role="concept">
14433 <primary><option>quote</option> expansion item</primary>
14434 </indexterm>
14435 The <option>quote</option> operator puts its argument into double quotes if it
14436 is an empty string or
14437 contains anything other than letters, digits, underscores, dots, and hyphens.
14438 Any occurrences of double quotes and backslashes are escaped with a backslash.
14439 Newlines and carriage returns are converted to <literal>\n</literal> and <literal>\r</literal>,
14440 respectively For example,
14441 </para>
14442 <literallayout class="monospaced">
14443 ${quote:ab"*"cd}
14444 </literallayout>
14445 <para>
14446 becomes
14447 </para>
14448 <literallayout class="monospaced">
14449 "ab\"*\"cd"
14450 </literallayout>
14451 <para>
14452 The place where this is useful is when the argument is a substitution from a
14453 variable or a message header.
14454 </para>
14455 </listitem></varlistentry>
14456 <varlistentry>
14457 <term><emphasis role="bold">${quote_local_part:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14458 <listitem>
14459 <para>
14460 <indexterm role="concept">
14461 <primary><option>quote_local_part</option> expansion item</primary>
14462 </indexterm>
14463 This operator is like <option>quote</option>, except that it quotes the string only if
14464 required to do so by the rules of RFC 2822 for quoting local parts. For
14465 example, a plus sign would not cause quoting (but it would for <option>quote</option>).
14466 If you are creating a new email address from the contents of <varname>$local_part</varname>
14467 (or any other unknown data), you should always use this operator.
14468 </para>
14469 </listitem></varlistentry>
14470 <varlistentry>
14471 <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>
14472 <listitem>
14473 <para>
14474 <indexterm role="concept">
14475 <primary>quoting</primary>
14476 <secondary>lookup-specific</secondary>
14477 </indexterm>
14478 This operator applies lookup-specific quoting rules to the string. Each
14479 query-style lookup type has its own quoting rules which are described with
14480 the lookups in chapter <xref linkend="CHAPfdlookup"/>. For example,
14481 </para>
14482 <literallayout class="monospaced">
14483 ${quote_ldap:two * two}
14484 </literallayout>
14485 <para>
14486 returns
14487 </para>
14488 <literallayout class="monospaced">
14489 two%20%5C2A%20two
14490 </literallayout>
14491 <para>
14492 For single-key lookup types, no quoting is ever necessary and this operator
14493 yields an unchanged string.
14494 </para>
14495 </listitem></varlistentry>
14496 <varlistentry>
14497 <term><emphasis role="bold">${randint:</emphasis>&lt;<emphasis>n</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14498 <listitem>
14499 <para>
14500 <indexterm role="concept">
14501 <primary>random number</primary>
14502 </indexterm>
14503 This operator returns a somewhat random number which is less than the
14504 supplied number and is at least 0.  The quality of this randomness depends
14505 on how Exim was built; the values are not suitable for keying material.
14506 If Exim is linked against OpenSSL then RAND_pseudo_bytes() is used.
14507 Otherwise, the implementation may be arc4random(), random() seeded by
14508 srandomdev() or srandom(), or a custom implementation even weaker than
14509 random().
14510 </para>
14511 </listitem></varlistentry>
14512 <varlistentry revisionflag="changed">
14513 <term><emphasis role="bold">${reverse_ip:</emphasis>&lt;<emphasis>ipaddr</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14514 <listitem>
14515 <para revisionflag="changed">
14516 <indexterm role="concept">
14517 <primary>expansion</primary>
14518 <secondary>IP address</secondary>
14519 </indexterm>
14520 This operator reverses an IP address; for IPv4 addresses, the result is in
14521 dotted-quad decimal form, while for IPv6 addreses the result is in
14522 dotted-nibble hexadecimal form.  In both cases, this is the "natural" form
14523 for DNS.  For example,
14524 </para>
14525 <literallayout class="monospaced" revisionflag="changed">
14526 ${reverse_ip:192.0.2.4} and ${reverse_ip:2001:0db8:c42:9:1:abcd:192.0.2.3}
14527 </literallayout>
14528 <para revisionflag="changed">
14529 returns
14530 </para>
14531 <literallayout class="monospaced" revisionflag="changed">
14532 4.2.0.192 and 3.0.2.0.0.0.0.c.d.c.b.a.1.0.0.0.9.0.0.0.2.4.c.0.8.b.d.0.1.0.0.2
14533 </literallayout>
14534 </listitem></varlistentry>
14535 <varlistentry>
14536 <term><emphasis role="bold">${rfc2047:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14537 <listitem>
14538 <para>
14539 <indexterm role="concept">
14540 <primary>expansion</primary>
14541 <secondary>RFC 2047</secondary>
14542 </indexterm>
14543 <indexterm role="concept">
14544 <primary>RFC 2047</primary>
14545 <secondary>expansion operator</secondary>
14546 </indexterm>
14547 <indexterm role="concept">
14548 <primary><option>rfc2047</option> expansion item</primary>
14549 </indexterm>
14550 This operator encodes text according to the rules of RFC 2047. This is an
14551 encoding that is used in header lines to encode non-ASCII characters. It is
14552 assumed that the input string is in the encoding specified by the
14553 <option>headers_charset</option> option, which defaults to ISO-8859-1. If the string
14554 contains only characters in the range 33&ndash;126, and no instances of the
14555 characters
14556 </para>
14557 <literallayout class="monospaced">
14558 ? = ( ) &lt; &gt; @ , ; : \ " . [ ] _
14559 </literallayout>
14560 <para>
14561 it is not modified. Otherwise, the result is the RFC 2047 encoding of the
14562 string, using as many <quote>encoded words</quote> as necessary to encode all the
14563 characters.
14564 </para>
14565 </listitem></varlistentry>
14566 <varlistentry>
14567 <term><emphasis role="bold">${rfc2047d:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14568 <listitem>
14569 <para>
14570 <indexterm role="concept">
14571 <primary>expansion</primary>
14572 <secondary>RFC 2047</secondary>
14573 </indexterm>
14574 <indexterm role="concept">
14575 <primary>RFC 2047</primary>
14576 <secondary>decoding</secondary>
14577 </indexterm>
14578 <indexterm role="concept">
14579 <primary><option>rfc2047d</option> expansion item</primary>
14580 </indexterm>
14581 This operator decodes strings that are encoded as per RFC 2047. Binary zero
14582 bytes are replaced by question marks. Characters are converted into the
14583 character set defined by <option>headers_charset</option>. Overlong RFC 2047 <quote>words</quote> are
14584 not recognized unless <option>check_rfc2047_length</option> is set false.
14585 </para>
14586 <para>
14587 <emphasis role="bold">Note</emphasis>: If you use <option>$header</option>_<emphasis>xxx</emphasis><emphasis role="bold">:</emphasis> (or <option>$h</option>_<emphasis>xxx</emphasis><emphasis role="bold">:</emphasis>) to
14588 access a header line, RFC 2047 decoding is done automatically. You do not need
14589 to use this operator as well.
14590 </para>
14591 </listitem></varlistentry>
14592 <varlistentry>
14593 <term><emphasis role="bold">${rxquote:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14594 <listitem>
14595 <para>
14596 <indexterm role="concept">
14597 <primary>quoting</primary>
14598 <secondary>in regular expressions</secondary>
14599 </indexterm>
14600 <indexterm role="concept">
14601 <primary>regular expressions</primary>
14602 <secondary>quoting</secondary>
14603 </indexterm>
14604 <indexterm role="concept">
14605 <primary><option>rxquote</option> expansion item</primary>
14606 </indexterm>
14607 The <option>rxquote</option> operator inserts a backslash before any non-alphanumeric
14608 characters in its argument. This is useful when substituting the values of
14609 variables or headers inside regular expressions.
14610 </para>
14611 </listitem></varlistentry>
14612 <varlistentry>
14613 <term><emphasis role="bold">${sha1:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14614 <listitem>
14615 <para>
14616 <indexterm role="concept">
14617 <primary>SHA-1 hash</primary>
14618 </indexterm>
14619 <indexterm role="concept">
14620 <primary>expansion</primary>
14621 <secondary>SHA-1 hashing</secondary>
14622 </indexterm>
14623 <indexterm role="concept">
14624 <primary><option>sha2</option> expansion item</primary>
14625 </indexterm>
14626 The <option>sha1</option> operator computes the SHA-1 hash value of the string, and returns
14627 it as a 40-digit hexadecimal number, in which any letters are in upper case.
14628 </para>
14629 </listitem></varlistentry>
14630 <varlistentry>
14631 <term><emphasis role="bold">${stat:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14632 <listitem>
14633 <para>
14634 <indexterm role="concept">
14635 <primary>expansion</primary>
14636 <secondary>statting a file</secondary>
14637 </indexterm>
14638 <indexterm role="concept">
14639 <primary>file</primary>
14640 <secondary>extracting characteristics</secondary>
14641 </indexterm>
14642 <indexterm role="concept">
14643 <primary><option>stat</option> expansion item</primary>
14644 </indexterm>
14645 The string, after expansion, must be a file path. A call to the <function>stat()</function>
14646 function is made for this path. If <function>stat()</function> fails, an error occurs and the
14647 expansion fails. If it succeeds, the data from the stat replaces the item, as a
14648 series of &lt;<emphasis>name</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt; pairs, where the values are all numerical,
14649 except for the value of <quote>smode</quote>. The names are: <quote>mode</quote> (giving the mode as
14650 a 4-digit octal number), <quote>smode</quote> (giving the mode in symbolic format as a
14651 10-character string, as for the <emphasis>ls</emphasis> command), <quote>inode</quote>, <quote>device</quote>,
14652 <quote>links</quote>, <quote>uid</quote>, <quote>gid</quote>, <quote>size</quote>, <quote>atime</quote>, <quote>mtime</quote>, and <quote>ctime</quote>. You
14653 can extract individual fields using the <option>extract</option> expansion item.
14654 </para>
14655 <para>
14656 The use of the <option>stat</option> expansion in users&#x2019; filter files can be locked out by
14657 the system administrator. <emphasis role="bold">Warning</emphasis>: The file size may be incorrect on 32-bit
14658 systems for files larger than 2GB.
14659 </para>
14660 </listitem></varlistentry>
14661 <varlistentry>
14662 <term><emphasis role="bold">${str2b64:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14663 <listitem>
14664 <para>
14665 <indexterm role="concept">
14666 <primary>expansion</primary>
14667 <secondary>base64 encoding</secondary>
14668 </indexterm>
14669 <indexterm role="concept">
14670 <primary>base64 encoding</primary>
14671 <secondary>in string expansion</secondary>
14672 </indexterm>
14673 <indexterm role="concept">
14674 <primary><option>str2b64</option> expansion item</primary>
14675 </indexterm>
14676 This operator converts a string into one that is base64 encoded.
14677 </para>
14678 </listitem></varlistentry>
14679 <varlistentry>
14680 <term><emphasis role="bold">${strlen:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14681 <listitem>
14682 <para>
14683 <indexterm role="concept">
14684 <primary>expansion</primary>
14685 <secondary>string length</secondary>
14686 </indexterm>
14687 <indexterm role="concept">
14688 <primary>string</primary>
14689 <secondary>length in expansion</secondary>
14690 </indexterm>
14691 <indexterm role="concept">
14692 <primary><option>strlen</option> expansion item</primary>
14693 </indexterm>
14694 The item is replace by the length of the expanded string, expressed as a
14695 decimal number. <emphasis role="bold">Note</emphasis>: Do not confuse <option>strlen</option> with <option>length</option>.
14696 </para>
14697 </listitem></varlistentry>
14698 <varlistentry>
14699 <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>
14700 <listitem>
14701 <para>
14702 <indexterm role="concept">
14703 <primary><option>substr</option> expansion item</primary>
14704 </indexterm>
14705 <indexterm role="concept">
14706 <primary>substring extraction</primary>
14707 </indexterm>
14708 <indexterm role="concept">
14709 <primary>expansion</primary>
14710 <secondary>substring expansion</secondary>
14711 </indexterm>
14712 The <option>substr</option> operator is a simpler interface to the <option>substr</option> function that
14713 can be used when the two parameters are fixed numbers (as opposed to strings
14714 that change when expanded). The effect is the same as
14715 </para>
14716 <literallayout class="monospaced">
14717 ${substr{&lt;start&gt;}{&lt;length&gt;}{&lt;string&gt;}}
14718 </literallayout>
14719 <para>
14720 See the description of the general <option>substr</option> item above for details. The
14721 abbreviation <option>s</option> can be used when <option>substr</option> is used as an operator.
14722 </para>
14723 </listitem></varlistentry>
14724 <varlistentry>
14725 <term><emphasis role="bold">${time_eval:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14726 <listitem>
14727 <para>
14728 <indexterm role="concept">
14729 <primary><option>time_eval</option> expansion item</primary>
14730 </indexterm>
14731 <indexterm role="concept">
14732 <primary>time interval</primary>
14733 <secondary>decoding</secondary>
14734 </indexterm>
14735 This item converts an Exim time interval such as <literal>2d4h5m</literal> into a number of
14736 seconds.
14737 </para>
14738 </listitem></varlistentry>
14739 <varlistentry>
14740 <term><emphasis role="bold">${time_interval:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14741 <listitem>
14742 <para>
14743 <indexterm role="concept">
14744 <primary><option>time_interval</option> expansion item</primary>
14745 </indexterm>
14746 <indexterm role="concept">
14747 <primary>time interval</primary>
14748 <secondary>formatting</secondary>
14749 </indexterm>
14750 The argument (after sub-expansion) must be a sequence of decimal digits that
14751 represents an interval of time as a number of seconds. It is converted into a
14752 number of larger units and output in Exim&#x2019;s normal time format, for example,
14753 <literal>1w3d4h2m6s</literal>.
14754 </para>
14755 </listitem></varlistentry>
14756 <varlistentry>
14757 <term><emphasis role="bold">${uc:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14758 <listitem>
14759 <para>
14760 <indexterm role="concept">
14761 <primary>case forcing in strings</primary>
14762 </indexterm>
14763 <indexterm role="concept">
14764 <primary>string</primary>
14765 <secondary>case forcing</secondary>
14766 </indexterm>
14767 <indexterm role="concept">
14768 <primary>upper casing</primary>
14769 </indexterm>
14770 <indexterm role="concept">
14771 <primary>expansion</primary>
14772 <secondary>case forcing</secondary>
14773 </indexterm>
14774 <indexterm role="concept">
14775 <primary><option>uc</option> expansion item</primary>
14776 </indexterm>
14777 This forces the letters in the string into upper-case.
14778 </para>
14779 </listitem></varlistentry>
14780 </variablelist>
14781 </section>
14782 <section id="SECTexpcond">
14783 <title>Expansion conditions</title>
14784 <para>
14785 <indexterm role="concept" id="IIDexpcond" class="startofrange">
14786 <primary>expansion</primary>
14787 <secondary>conditions</secondary>
14788 </indexterm>
14789 The following conditions are available for testing by the <option>${if</option> construct
14790 while expanding strings:
14791 </para>
14792 <variablelist>
14793 <varlistentry>
14794 <term><emphasis role="bold">!</emphasis>&lt;<emphasis>condition</emphasis>&gt;</term>
14795 <listitem>
14796 <para>
14797 <indexterm role="concept">
14798 <primary>expansion</primary>
14799 <secondary>negating a condition</secondary>
14800 </indexterm>
14801 <indexterm role="concept">
14802 <primary>negation</primary>
14803 <secondary>in expansion condition</secondary>
14804 </indexterm>
14805 Preceding any condition with an exclamation mark negates the result of the
14806 condition.
14807 </para>
14808 </listitem></varlistentry>
14809 <varlistentry>
14810 <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>
14811 <listitem>
14812 <para>
14813 <indexterm role="concept">
14814 <primary>numeric comparison</primary>
14815 </indexterm>
14816 <indexterm role="concept">
14817 <primary>expansion</primary>
14818 <secondary>numeric comparison</secondary>
14819 </indexterm>
14820 There are a number of symbolic operators for doing numeric comparisons. They
14821 are:
14822 </para>
14823 <literallayout>
14824 <literal>=   </literal>   equal
14825 <literal>==  </literal>   equal
14826 <literal>&gt;   </literal>   greater
14827 <literal>&gt;=  </literal>   greater or equal
14828 <literal>&lt;   </literal>   less
14829 <literal>&lt;=  </literal>   less or equal
14830 </literallayout>
14831 <para>
14832 For example:
14833 </para>
14834 <literallayout class="monospaced">
14835 ${if &gt;{$message_size}{10M} ...
14836 </literallayout>
14837 <para>
14838 Note that the general negation operator provides for inequality testing. The
14839 two strings must take the form of optionally signed decimal integers,
14840 optionally followed by one of the letters <quote>K</quote> or <quote>M</quote> (in either upper or
14841 lower case), signifying multiplication by 1024 or 1024*1024, respectively.
14842 As a special case, the numerical value of an empty string is taken as
14843 zero.
14844 </para>
14845 </listitem></varlistentry>
14846 <varlistentry revisionflag="changed">
14847 <term><emphasis role="bold">bool&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14848 <listitem>
14849 <para revisionflag="changed">
14850 <indexterm role="concept">
14851 <primary>expansion</primary>
14852 <secondary>boolean parsing</secondary>
14853 </indexterm>
14854 <indexterm role="concept">
14855 <primary><option>bool</option> expansion condition</primary>
14856 </indexterm>
14857 This condition turns a string holding a true or false representation into
14858 a boolean state.  It parses <quote>true</quote>, <quote>false</quote>, <quote>yes</quote> and <quote>no</quote>
14859 (case-insensitively); also positive integer numbers map to true if non-zero,
14860 false if zero.  Leading and trailing whitespace is ignored.
14861 All other string values will result in expansion failure.
14862 </para>
14863 <para revisionflag="changed">
14864 When combined with ACL variables, this expansion condition will let you
14865 make decisions in one place and act on those decisions in another place.
14866 For example:
14867 </para>
14868 <literallayout class="monospaced" revisionflag="changed">
14869 ${if bool{$acl_m_privileged_sender} ...
14870 </literallayout>
14871 </listitem></varlistentry>
14872 <varlistentry>
14873 <term><emphasis role="bold">bool_lax&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14874 <listitem>
14875 <para>
14876 <indexterm role="concept">
14877 <primary>expansion</primary>
14878 <secondary>boolean parsing</secondary>
14879 </indexterm>
14880 <indexterm role="concept">
14881 <primary><option>bool_lax</option> expansion condition</primary>
14882 </indexterm>
14883 Like <option>bool</option>, this condition turns a string into a boolean state.  But
14884 where <option>bool</option> accepts a strict set of strings, <option>bool_lax</option> uses the same
14885 loose definition that the Router <option>condition</option> option uses.  The empty string
14886 and the values <quote>false</quote>, <quote>no</quote> and <quote>0</quote> map to false, all others map to
14887 true.  Leading and trailing whitespace is ignored.
14888 </para>
14889 <para>
14890 Note that where <quote>bool{00}</quote> is false, <quote>bool_lax{00}</quote> is true.
14891 </para>
14892 </listitem></varlistentry>
14893 <varlistentry>
14894 <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>
14895 <listitem>
14896 <para>
14897 <indexterm role="concept">
14898 <primary>expansion</primary>
14899 <secondary>encrypted comparison</secondary>
14900 </indexterm>
14901 <indexterm role="concept">
14902 <primary>encrypted strings, comparing</primary>
14903 </indexterm>
14904 <indexterm role="concept">
14905 <primary><option>crypteq</option> expansion condition</primary>
14906 </indexterm>
14907 This condition is included in the Exim binary if it is built to support any
14908 authentication mechanisms (see chapter <xref linkend="CHAPSMTPAUTH"/>). Otherwise, it is
14909 necessary to define SUPPORT_CRYPTEQ in <filename>Local/Makefile</filename> to get <option>crypteq</option>
14910 included in the binary.
14911 </para>
14912 <para>
14913 The <option>crypteq</option> condition has two arguments. The first is encrypted and
14914 compared against the second, which is already encrypted. The second string may
14915 be in the LDAP form for storing encrypted strings, which starts with the
14916 encryption type in curly brackets, followed by the data. If the second string
14917 does not begin with <quote>{</quote> it is assumed to be encrypted with <function>crypt()</function> or
14918 <function>crypt16()</function> (see below), since such strings cannot begin with <quote>{</quote>.
14919 Typically this will be a field from a password file. An example of an encrypted
14920 string in LDAP form is:
14921 </para>
14922 <literallayout class="monospaced">
14923 {md5}CY9rzUYh03PK3k6DJie09g==
14924 </literallayout>
14925 <para>
14926 If such a string appears directly in an expansion, the curly brackets have to
14927 be quoted, because they are part of the expansion syntax. For example:
14928 </para>
14929 <literallayout class="monospaced">
14930 ${if crypteq {test}{\{md5\}CY9rzUYh03PK3k6DJie09g==}{yes}{no}}
14931 </literallayout>
14932 <para>
14933 The following encryption types (whose names are matched case-independently) are
14934 supported:
14935 </para>
14936 <itemizedlist>
14937 <listitem>
14938 <para>
14939 <indexterm role="concept">
14940 <primary>MD5 hash</primary>
14941 </indexterm>
14942 <indexterm role="concept">
14943 <primary>base64 encoding</primary>
14944 <secondary>in encrypted password</secondary>
14945 </indexterm>
14946 <option>{md5}</option> computes the MD5 digest of the first string, and expresses this as
14947 printable characters to compare with the remainder of the second string. If the
14948 length of the comparison string is 24, Exim assumes that it is base64 encoded
14949 (as in the above example). If the length is 32, Exim assumes that it is a
14950 hexadecimal encoding of the MD5 digest. If the length not 24 or 32, the
14951 comparison fails.
14952 </para>
14953 </listitem>
14954 <listitem>
14955 <para>
14956 <indexterm role="concept">
14957 <primary>SHA-1 hash</primary>
14958 </indexterm>
14959 <option>{sha1}</option> computes the SHA-1 digest of the first string, and expresses this as
14960 printable characters to compare with the remainder of the second string. If the
14961 length of the comparison string is 28, Exim assumes that it is base64 encoded.
14962 If the length is 40, Exim assumes that it is a hexadecimal encoding of the
14963 SHA-1 digest. If the length is not 28 or 40, the comparison fails.
14964 </para>
14965 </listitem>
14966 <listitem>
14967 <para>
14968 <indexterm role="concept">
14969 <primary><function>crypt()</function></primary>
14970 </indexterm>
14971 <option>{crypt}</option> calls the <function>crypt()</function> function, which traditionally used to use
14972 only the first eight characters of the password. However, in modern operating
14973 systems this is no longer true, and in many cases the entire password is used,
14974 whatever its length.
14975 </para>
14976 </listitem>
14977 <listitem>
14978 <para>
14979 <indexterm role="concept">
14980 <primary><function>crypt16()</function></primary>
14981 </indexterm>
14982 <option>{crypt16}</option> calls the <function>crypt16()</function> function, which was originally created to
14983 use up to 16 characters of the password in some operating systems. Again, in
14984 modern operating systems, more characters may be used.
14985 </para>
14986 </listitem>
14987 </itemizedlist>
14988 <para>
14989 Exim has its own version of <function>crypt16()</function>, which is just a double call to
14990 <function>crypt()</function>. For operating systems that have their own version, setting
14991 HAVE_CRYPT16 in <filename>Local/Makefile</filename> when building Exim causes it to use the
14992 operating system version instead of its own. This option is set by default in
14993 the OS-dependent <filename>Makefile</filename> for those operating systems that are known to
14994 support <function>crypt16()</function>.
14995 </para>
14996 <para>
14997 Some years after Exim&#x2019;s <function>crypt16()</function> was implemented, a user discovered that
14998 it was not using the same algorithm as some operating systems&#x2019; versions. It
14999 turns out that as well as <function>crypt16()</function> there is a function called
15000 <function>bigcrypt()</function> in some operating systems. This may or may not use the same
15001 algorithm, and both of them may be different to Exim&#x2019;s built-in <function>crypt16()</function>.
15002 </para>
15003 <para>
15004 However, since there is now a move away from the traditional <function>crypt()</function>
15005 functions towards using SHA1 and other algorithms, tidying up this area of
15006 Exim is seen as very low priority.
15007 </para>
15008 <para>
15009 If you do not put a encryption type (in curly brackets) in a <option>crypteq</option>
15010 comparison, the default is usually either <literal>{crypt}</literal> or <literal>{crypt16}</literal>, as
15011 determined by the setting of DEFAULT_CRYPT in <filename>Local/Makefile</filename>. The default
15012 default is <literal>{crypt}</literal>. Whatever the default, you can always use either
15013 function by specifying it explicitly in curly brackets.
15014 </para>
15015 </listitem></varlistentry>
15016 <varlistentry>
15017 <term><emphasis role="bold">def:</emphasis>&lt;<emphasis>variable&nbsp;name</emphasis>&gt;</term>
15018 <listitem>
15019 <para>
15020 <indexterm role="concept">
15021 <primary>expansion</primary>
15022 <secondary>checking for empty variable</secondary>
15023 </indexterm>
15024 <indexterm role="concept">
15025 <primary><option>def</option> expansion condition</primary>
15026 </indexterm>
15027 The <option>def</option> condition must be followed by the name of one of the expansion
15028 variables defined in section <xref linkend="SECTexpvar"/>. The condition is true if the
15029 variable does not contain the empty string. For example:
15030 </para>
15031 <literallayout class="monospaced">
15032 ${if def:sender_ident {from $sender_ident}}
15033 </literallayout>
15034 <para>
15035 Note that the variable name is given without a leading <option>$</option> character. If the
15036 variable does not exist, the expansion fails.
15037 </para>
15038 </listitem></varlistentry>
15039 <varlistentry>
15040 <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>
15041 <listitem>
15042 <para>
15043 <indexterm role="concept">
15044 <primary>expansion</primary>
15045 <secondary>checking header line existence</secondary>
15046 </indexterm>
15047 This condition is true if a message is being processed and the named header
15048 exists in the message. For example,
15049 </para>
15050 <literallayout class="monospaced">
15051 ${if def:header_reply-to:{$h_reply-to:}{$h_from:}}
15052 </literallayout>
15053 <para>
15054 <emphasis role="bold">Note</emphasis>: No <option>$</option> appears before <option>header_</option> or <option>h_</option> in the condition, and
15055 the header name must be terminated by a colon if white space does not follow.
15056 </para>
15057 </listitem></varlistentry>
15058 <varlistentry>
15059 <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>
15060 <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>
15061 <listitem>
15062 <para>
15063 <indexterm role="concept">
15064 <primary>string</primary>
15065 <secondary>comparison</secondary>
15066 </indexterm>
15067 <indexterm role="concept">
15068 <primary>expansion</primary>
15069 <secondary>string comparison</secondary>
15070 </indexterm>
15071 <indexterm role="concept">
15072 <primary><option>eq</option> expansion condition</primary>
15073 </indexterm>
15074 <indexterm role="concept">
15075 <primary><option>eqi</option> expansion condition</primary>
15076 </indexterm>
15077 The two substrings are first expanded. The condition is true if the two
15078 resulting strings are identical. For <option>eq</option> the comparison includes the case of
15079 letters, whereas for <option>eqi</option> the comparison is case-independent.
15080 </para>
15081 </listitem></varlistentry>
15082 <varlistentry>
15083 <term><emphasis role="bold">exists&nbsp;{</emphasis>&lt;<emphasis>file&nbsp;name</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15084 <listitem>
15085 <para>
15086 <indexterm role="concept">
15087 <primary>expansion</primary>
15088 <secondary>file existence test</secondary>
15089 </indexterm>
15090 <indexterm role="concept">
15091 <primary>file</primary>
15092 <secondary>existence test</secondary>
15093 </indexterm>
15094 <indexterm role="concept">
15095 <primary><option>exists</option>, expansion condition</primary>
15096 </indexterm>
15097 The substring is first expanded and then interpreted as an absolute path. The
15098 condition is true if the named file (or directory) exists. The existence test
15099 is done by calling the <function>stat()</function> function. The use of the <option>exists</option> test in
15100 users&#x2019; filter files may be locked out by the system administrator.
15101 </para>
15102 </listitem></varlistentry>
15103 <varlistentry>
15104 <term><emphasis role="bold">first_delivery</emphasis></term>
15105 <listitem>
15106 <para>
15107 <indexterm role="concept">
15108 <primary>delivery</primary>
15109 <secondary>first</secondary>
15110 </indexterm>
15111 <indexterm role="concept">
15112 <primary>first delivery</primary>
15113 </indexterm>
15114 <indexterm role="concept">
15115 <primary>expansion</primary>
15116 <secondary>first delivery test</secondary>
15117 </indexterm>
15118 <indexterm role="concept">
15119 <primary><option>first_delivery</option> expansion condition</primary>
15120 </indexterm>
15121 This condition, which has no data, is true during a message&#x2019;s first delivery
15122 attempt. It is false during any subsequent delivery attempts.
15123 </para>
15124 </listitem></varlistentry>
15125 <varlistentry>
15126 <term><emphasis role="bold">forall{</emphasis>&lt;<emphasis>a list</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>a condition</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15127 <term><emphasis role="bold">forany{</emphasis>&lt;<emphasis>a list</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>a condition</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15128 <listitem>
15129 <para>
15130 <indexterm role="concept">
15131 <primary>list</primary>
15132 <secondary>iterative conditions</secondary>
15133 </indexterm>
15134 <indexterm role="concept">
15135 <primary>expansion</primary>
15136 <secondary><emphasis role="bold">forall</emphasis> condition</secondary>
15137 </indexterm>
15138 <indexterm role="concept">
15139 <primary>expansion</primary>
15140 <secondary><emphasis role="bold">forany</emphasis> condition</secondary>
15141 </indexterm>
15142 <indexterm role="variable">
15143 <primary><varname>$item</varname></primary>
15144 </indexterm>
15145 These conditions iterate over a list. The first argument is expanded to form
15146 the list. By default, the list separator is a colon, but it can be changed by
15147 the normal method. The second argument is interpreted as a condition that is to
15148 be applied to each item in the list in turn. During the interpretation of the
15149 condition, the current list item is placed in a variable called <varname>$item</varname>.
15150 </para>
15151 <itemizedlist>
15152 <listitem>
15153 <para>
15154 For <emphasis role="bold">forany</emphasis>, interpretation stops if the condition is true for any item, and
15155 the result of the whole condition is true. If the condition is false for all
15156 items in the list, the overall condition is false.
15157 </para>
15158 </listitem>
15159 <listitem>
15160 <para>
15161 For <emphasis role="bold">forall</emphasis>, interpretation stops if the condition is false for any item,
15162 and the result of the whole condition is false. If the condition is true for
15163 all items in the list, the overall condition is true.
15164 </para>
15165 </listitem>
15166 </itemizedlist>
15167 <para>
15168 Note that negation of <emphasis role="bold">forany</emphasis> means that the condition must be false for all
15169 items for the overall condition to succeed, and negation of <emphasis role="bold">forall</emphasis> means
15170 that the condition must be false for at least one item. In this example, the
15171 list separator is changed to a comma:
15172 </para>
15173 <literallayout class="monospaced">
15174 ${if forany{&lt;, $recipients}{match{$item}{^user3@}}{yes}{no}}
15175 </literallayout>
15176 <para>
15177 The value of <varname>$item</varname> is saved and restored while <emphasis role="bold">forany</emphasis> or <emphasis role="bold">forall</emphasis> is
15178 being processed, to enable these expansion items to be nested.
15179 </para>
15180 </listitem></varlistentry>
15181 <varlistentry>
15182 <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>
15183 <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>
15184 <listitem>
15185 <para>
15186 <indexterm role="concept">
15187 <primary>string</primary>
15188 <secondary>comparison</secondary>
15189 </indexterm>
15190 <indexterm role="concept">
15191 <primary>expansion</primary>
15192 <secondary>string comparison</secondary>
15193 </indexterm>
15194 <indexterm role="concept">
15195 <primary><option>ge</option> expansion condition</primary>
15196 </indexterm>
15197 <indexterm role="concept">
15198 <primary><option>gei</option> expansion condition</primary>
15199 </indexterm>
15200 The two substrings are first expanded. The condition is true if the first
15201 string is lexically greater than or equal to the second string. For <option>ge</option> the
15202 comparison includes the case of letters, whereas for <option>gei</option> the comparison is
15203 case-independent.
15204 </para>
15205 </listitem></varlistentry>
15206 <varlistentry>
15207 <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>
15208 <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>
15209 <listitem>
15210 <para>
15211 <indexterm role="concept">
15212 <primary>string</primary>
15213 <secondary>comparison</secondary>
15214 </indexterm>
15215 <indexterm role="concept">
15216 <primary>expansion</primary>
15217 <secondary>string comparison</secondary>
15218 </indexterm>
15219 <indexterm role="concept">
15220 <primary><option>gt</option> expansion condition</primary>
15221 </indexterm>
15222 <indexterm role="concept">
15223 <primary><option>gti</option> expansion condition</primary>
15224 </indexterm>
15225 The two substrings are first expanded. The condition is true if the first
15226 string is lexically greater than the second string. For <option>gt</option> the comparison
15227 includes the case of letters, whereas for <option>gti</option> the comparison is
15228 case-independent.
15229 </para>
15230 </listitem></varlistentry>
15231 <varlistentry>
15232 <term><emphasis role="bold">isip&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15233 <term><emphasis role="bold">isip4&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15234 <term><emphasis role="bold">isip6&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15235 <listitem>
15236 <para>
15237 <indexterm role="concept">
15238 <primary>IP address</primary>
15239 <secondary>testing string format</secondary>
15240 </indexterm>
15241 <indexterm role="concept">
15242 <primary>string</primary>
15243 <secondary>testing for IP address</secondary>
15244 </indexterm>
15245 <indexterm role="concept">
15246 <primary><option>isip</option> expansion condition</primary>
15247 </indexterm>
15248 <indexterm role="concept">
15249 <primary><option>isip4</option> expansion condition</primary>
15250 </indexterm>
15251 <indexterm role="concept">
15252 <primary><option>isip6</option> expansion condition</primary>
15253 </indexterm>
15254 The substring is first expanded, and then tested to see if it has the form of
15255 an IP address. Both IPv4 and IPv6 addresses are valid for <option>isip</option>, whereas
15256 <option>isip4</option> and <option>isip6</option> test specifically for IPv4 or IPv6 addresses.
15257 </para>
15258 <para>
15259 For an IPv4 address, the test is for four dot-separated components, each of
15260 which consists of from one to three digits. For an IPv6 address, up to eight
15261 colon-separated components are permitted, each containing from one to four
15262 hexadecimal digits. There may be fewer than eight components if an empty
15263 component (adjacent colons) is present. Only one empty component is permitted.
15264 </para>
15265 <para>
15266 <emphasis role="bold">Note</emphasis>: The checks are just on the form of the address; actual numerical
15267 values are not considered. Thus, for example, 999.999.999.999 passes the IPv4
15268 check. The main use of these tests is to distinguish between IP addresses and
15269 host names, or between IPv4 and IPv6 addresses. For example, you could use
15270 </para>
15271 <literallayout class="monospaced">
15272 ${if isip4{$sender_host_address}...
15273 </literallayout>
15274 <para>
15275 to test which IP version an incoming SMTP connection is using.
15276 </para>
15277 </listitem></varlistentry>
15278 <varlistentry>
15279 <term><emphasis role="bold">ldapauth&nbsp;{</emphasis>&lt;<emphasis>ldap&nbsp;query</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15280 <listitem>
15281 <para>
15282 <indexterm role="concept">
15283 <primary>LDAP</primary>
15284 <secondary>use for authentication</secondary>
15285 </indexterm>
15286 <indexterm role="concept">
15287 <primary>expansion</primary>
15288 <secondary>LDAP authentication test</secondary>
15289 </indexterm>
15290 <indexterm role="concept">
15291 <primary><option>ldapauth</option> expansion condition</primary>
15292 </indexterm>
15293 This condition supports user authentication using LDAP. See section
15294 <xref linkend="SECTldap"/> for details of how to use LDAP in lookups and the syntax of
15295 queries. For this use, the query must contain a user name and password. The
15296 query itself is not used, and can be empty. The condition is true if the
15297 password is not empty, and the user name and password are accepted by the LDAP
15298 server. An empty password is rejected without calling LDAP because LDAP binds
15299 with an empty password are considered anonymous regardless of the username, and
15300 will succeed in most configurations. See chapter <xref linkend="CHAPSMTPAUTH"/> for details
15301 of SMTP authentication, and chapter <xref linkend="CHAPplaintext"/> for an example of how
15302 this can be used.
15303 </para>
15304 </listitem></varlistentry>
15305 <varlistentry>
15306 <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>
15307 <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>
15308 <listitem>
15309 <para>
15310 <indexterm role="concept">
15311 <primary>string</primary>
15312 <secondary>comparison</secondary>
15313 </indexterm>
15314 <indexterm role="concept">
15315 <primary>expansion</primary>
15316 <secondary>string comparison</secondary>
15317 </indexterm>
15318 <indexterm role="concept">
15319 <primary><option>le</option> expansion condition</primary>
15320 </indexterm>
15321 <indexterm role="concept">
15322 <primary><option>lei</option> expansion condition</primary>
15323 </indexterm>
15324 The two substrings are first expanded. The condition is true if the first
15325 string is lexically less than or equal to the second string. For <option>le</option> the
15326 comparison includes the case of letters, whereas for <option>lei</option> the comparison is
15327 case-independent.
15328 </para>
15329 </listitem></varlistentry>
15330 <varlistentry>
15331 <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>
15332 <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>
15333 <listitem>
15334 <para>
15335 <indexterm role="concept">
15336 <primary>string</primary>
15337 <secondary>comparison</secondary>
15338 </indexterm>
15339 <indexterm role="concept">
15340 <primary>expansion</primary>
15341 <secondary>string comparison</secondary>
15342 </indexterm>
15343 <indexterm role="concept">
15344 <primary><option>lt</option> expansion condition</primary>
15345 </indexterm>
15346 <indexterm role="concept">
15347 <primary><option>lti</option> expansion condition</primary>
15348 </indexterm>
15349 The two substrings are first expanded. The condition is true if the first
15350 string is lexically less than the second string. For <option>lt</option> the comparison
15351 includes the case of letters, whereas for <option>lti</option> the comparison is
15352 case-independent.
15353 </para>
15354 </listitem></varlistentry>
15355 <varlistentry>
15356 <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>
15357 <listitem>
15358 <para>
15359 <indexterm role="concept">
15360 <primary>expansion</primary>
15361 <secondary>regular expression comparison</secondary>
15362 </indexterm>
15363 <indexterm role="concept">
15364 <primary>regular expressions</primary>
15365 <secondary>match in expanded string</secondary>
15366 </indexterm>
15367 <indexterm role="concept">
15368 <primary><option>match</option> expansion condition</primary>
15369 </indexterm>
15370 The two substrings are first expanded. The second is then treated as a regular
15371 expression and applied to the first. Because of the pre-expansion, if the
15372 regular expression contains dollar, or backslash characters, they must be
15373 escaped. Care must also be taken if the regular expression contains braces
15374 (curly brackets). A closing brace must be escaped so that it is not taken as a
15375 premature termination of &lt;<emphasis>string2</emphasis>&gt;. The easiest approach is to use the
15376 <literal>\N</literal> feature to disable expansion of the regular expression.
15377 For example,
15378 </para>
15379 <literallayout class="monospaced">
15380 ${if match {$local_part}{\N^\d{3}\N} ...
15381 </literallayout>
15382 <para>
15383 If the whole expansion string is in double quotes, further escaping of
15384 backslashes is also required.
15385 </para>
15386 <para>
15387 The condition is true if the regular expression match succeeds.
15388 The regular expression is not required to begin with a circumflex
15389 metacharacter, but if there is no circumflex, the expression is not anchored,
15390 and it may match anywhere in the subject, not just at the start. If you want
15391 the pattern to match at the end of the subject, you must include the <literal>$</literal>
15392 metacharacter at an appropriate point.
15393 </para>
15394 <para>
15395 <indexterm role="concept">
15396 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
15397 <secondary>in <option>if</option> expansion</secondary>
15398 </indexterm>
15399 At the start of an <option>if</option> expansion the values of the numeric variable
15400 substitutions <varname>$1</varname> etc. are remembered. Obeying a <option>match</option> condition that
15401 succeeds causes them to be reset to the substrings of that condition and they
15402 will have these values during the expansion of the success string. At the end
15403 of the <option>if</option> expansion, the previous values are restored. After testing a
15404 combination of conditions using <option>or</option>, the subsequent values of the numeric
15405 variables are those of the condition that succeeded.
15406 </para>
15407 </listitem></varlistentry>
15408 <varlistentry>
15409 <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>
15410 <listitem>
15411 <para>
15412 <indexterm role="concept">
15413 <primary><option>match_address</option> expansion condition</primary>
15414 </indexterm>
15415 See <emphasis role="bold">match_local_part</emphasis>.
15416 </para>
15417 </listitem></varlistentry>
15418 <varlistentry>
15419 <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>
15420 <listitem>
15421 <para>
15422 <indexterm role="concept">
15423 <primary><option>match_domain</option> expansion condition</primary>
15424 </indexterm>
15425 See <emphasis role="bold">match_local_part</emphasis>.
15426 </para>
15427 </listitem></varlistentry>
15428 <varlistentry>
15429 <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>
15430 <listitem>
15431 <para>
15432 <indexterm role="concept">
15433 <primary><option>match_ip</option> expansion condition</primary>
15434 </indexterm>
15435 This condition matches an IP address to a list of IP address patterns. It must
15436 be followed by two argument strings. The first (after expansion) must be an IP
15437 address or an empty string. The second (after expansion) is a restricted host
15438 list that can match only an IP address, not a host name. For example:
15439 </para>
15440 <literallayout class="monospaced">
15441 ${if match_ip{$sender_host_address}{1.2.3.4:5.6.7.8}{...}{...}}
15442 </literallayout>
15443 <para>
15444 The specific types of host list item that are permitted in the list are:
15445 </para>
15446 <itemizedlist>
15447 <listitem>
15448 <para>
15449 An IP address, optionally with a CIDR mask.
15450 </para>
15451 </listitem>
15452 <listitem>
15453 <para>
15454 A single asterisk, which matches any IP address.
15455 </para>
15456 </listitem>
15457 <listitem>
15458 <para>
15459 An empty item, which matches only if the IP address is empty. This could be
15460 useful for testing for a locally submitted message or one from specific hosts
15461 in a single test such as
15462 </para>
15463 <literallayout class="monospaced">
15464   ${if match_ip{$sender_host_address}{:4.3.2.1:...}{...}{...}}
15465 </literallayout>
15466 <para>
15467 where the first item in the list is the empty string.
15468 </para>
15469 </listitem>
15470 <listitem>
15471 <para>
15472 The item @[] matches any of the local host&#x2019;s interface addresses.
15473 </para>
15474 </listitem>
15475 <listitem>
15476 <para>
15477 Single-key lookups are assumed to be like <quote>net-</quote> style lookups in host lists,
15478 even if <literal>net-</literal> is not specified. There is never any attempt to turn the IP
15479 address into a host name. The most common type of linear search for
15480 <emphasis role="bold">match_ip</emphasis> is likely to be <emphasis role="bold">iplsearch</emphasis>, in which the file can contain CIDR
15481 masks. For example:
15482 </para>
15483 <literallayout class="monospaced">
15484   ${if match_ip{$sender_host_address}{iplsearch;/some/file}...
15485 </literallayout>
15486 <para>
15487 It is of course possible to use other kinds of lookup, and in such a case, you
15488 do need to specify the <literal>net-</literal> prefix if you want to specify a specific
15489 address mask, for example:
15490 </para>
15491 <literallayout class="monospaced">
15492   ${if match_ip{$sender_host_address}{net24-dbm;/some/file}...
15493 </literallayout>
15494 <para>
15495 However, unless you are combining a <option>match_ip</option> condition with others, it is
15496 just as easy to use the fact that a lookup is itself a condition, and write:
15497 </para>
15498 <literallayout class="monospaced">
15499   ${lookup{${mask:$sender_host_address/24}}dbm{/a/file}...
15500 </literallayout>
15501 </listitem>
15502 </itemizedlist>
15503 <para>
15504 Consult section <xref linkend="SECThoslispatip"/> for further details of these patterns.
15505 </para>
15506 </listitem></varlistentry>
15507 <varlistentry>
15508 <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>
15509 <listitem>
15510 <para>
15511 <indexterm role="concept">
15512 <primary>domain list</primary>
15513 <secondary>in expansion condition</secondary>
15514 </indexterm>
15515 <indexterm role="concept">
15516 <primary>address list</primary>
15517 <secondary>in expansion condition</secondary>
15518 </indexterm>
15519 <indexterm role="concept">
15520 <primary>local part</primary>
15521 <secondary>list, in expansion condition</secondary>
15522 </indexterm>
15523 <indexterm role="concept">
15524 <primary><option>match_local_part</option> expansion condition</primary>
15525 </indexterm>
15526 This condition, together with <option>match_address</option> and <option>match_domain</option>, make it
15527 possible to test domain, address, and local part lists within expansions. Each
15528 condition requires two arguments: an item and a list to match. A trivial
15529 example is:
15530 </para>
15531 <literallayout class="monospaced">
15532 ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
15533 </literallayout>
15534 <para>
15535 In each case, the second argument may contain any of the allowable items for a
15536 list of the appropriate type. Also, because the second argument (after
15537 expansion) is a standard form of list, it is possible to refer to a named list.
15538 Thus, you can use conditions like this:
15539 </para>
15540 <literallayout class="monospaced">
15541 ${if match_domain{$domain}{+local_domains}{...
15542 </literallayout>
15543 <para>
15544 <indexterm role="concept">
15545 <primary><literal>+caseful</literal></primary>
15546 </indexterm>
15547 For address lists, the matching starts off caselessly, but the <literal>+caseful</literal>
15548 item can be used, as in all address lists, to cause subsequent items to
15549 have their local parts matched casefully. Domains are always matched
15550 caselessly.
15551 </para>
15552 <para>
15553 <emphasis role="bold">Note</emphasis>: Host lists are <emphasis>not</emphasis> supported in this way. This is because
15554 hosts have two identities: a name and an IP address, and it is not clear
15555 how to specify cleanly how such a test would work. However, IP addresses can be
15556 matched using <option>match_ip</option>.
15557 </para>
15558 </listitem></varlistentry>
15559 <varlistentry>
15560 <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>
15561 <listitem>
15562 <para>
15563 <indexterm role="concept">
15564 <primary>PAM authentication</primary>
15565 </indexterm>
15566 <indexterm role="concept">
15567 <primary>AUTH</primary>
15568 <secondary>with PAM</secondary>
15569 </indexterm>
15570 <indexterm role="concept">
15571 <primary>Solaris</primary>
15572 <secondary>PAM support</secondary>
15573 </indexterm>
15574 <indexterm role="concept">
15575 <primary>expansion</primary>
15576 <secondary>PAM authentication test</secondary>
15577 </indexterm>
15578 <indexterm role="concept">
15579 <primary><option>pam</option> expansion condition</primary>
15580 </indexterm>
15581 <emphasis>Pluggable Authentication Modules</emphasis>
15582 (<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
15583 available in the latest releases of Solaris and in some GNU/Linux
15584 distributions. The Exim support, which is intended for use in conjunction with
15585 the SMTP AUTH command, is available only if Exim is compiled with
15586 </para>
15587 <literallayout class="monospaced">
15588 SUPPORT_PAM=yes
15589 </literallayout>
15590 <para>
15591 in <filename>Local/Makefile</filename>. You probably need to add <option>-lpam</option> to EXTRALIBS, and
15592 in some releases of GNU/Linux <option>-ldl</option> is also needed.
15593 </para>
15594 <para>
15595 The argument string is first expanded, and the result must be a
15596 colon-separated list of strings. Leading and trailing white space is ignored.
15597 The PAM module is initialized with the service name <quote>exim</quote> and the user name
15598 taken from the first item in the colon-separated data string (&lt;<emphasis>string1</emphasis>&gt;).
15599 The remaining items in the data string are passed over in response to requests
15600 from the authentication function. In the simple case there will only be one
15601 request, for a password, so the data consists of just two strings.
15602 </para>
15603 <para>
15604 There can be problems if any of the strings are permitted to contain colon
15605 characters. In the usual way, these have to be doubled to avoid being taken as
15606 separators. If the data is being inserted from a variable, the <option>sg</option> expansion
15607 item can be used to double any existing colons. For example, the configuration
15608 of a LOGIN authenticator might contain this setting:
15609 </para>
15610 <literallayout class="monospaced">
15611 server_condition = ${if pam{$auth1:${sg{$auth2}{:}{::}}}}
15612 </literallayout>
15613 <para>
15614 For a PLAIN authenticator you could use:
15615 </para>
15616 <literallayout class="monospaced">
15617 server_condition = ${if pam{$auth2:${sg{$auth3}{:}{::}}}}
15618 </literallayout>
15619 <para>
15620 In some operating systems, PAM authentication can be done only from a process
15621 running as root. Since Exim is running as the Exim user when receiving
15622 messages, this means that PAM cannot be used directly in those systems.
15623 A patched version of the <emphasis>pam_unix</emphasis> module that comes with the
15624 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>.
15625 The patched module allows one special uid/gid combination, in addition to root,
15626 to authenticate. If you build the patched module to allow the Exim user and
15627 group, PAM can then be used from an Exim authenticator.
15628 </para>
15629 </listitem></varlistentry>
15630 <varlistentry>
15631 <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>
15632 <listitem>
15633 <para>
15634 <indexterm role="concept">
15635 <primary><emphasis>pwcheck</emphasis> daemon</primary>
15636 </indexterm>
15637 <indexterm role="concept">
15638 <primary>Cyrus</primary>
15639 </indexterm>
15640 <indexterm role="concept">
15641 <primary>expansion</primary>
15642 <secondary><emphasis>pwcheck</emphasis> authentication test</secondary>
15643 </indexterm>
15644 <indexterm role="concept">
15645 <primary><option>pwcheck</option> expansion condition</primary>
15646 </indexterm>
15647 This condition supports user authentication using the Cyrus <emphasis>pwcheck</emphasis> daemon.
15648 This is one way of making it possible for passwords to be checked by a process
15649 that is not running as root. <emphasis role="bold">Note</emphasis>: The use of <emphasis>pwcheck</emphasis> is now
15650 deprecated. Its replacement is <emphasis>saslauthd</emphasis> (see below).
15651 </para>
15652 <para>
15653 The pwcheck support is not included in Exim by default. You need to specify
15654 the location of the pwcheck daemon&#x2019;s socket in <filename>Local/Makefile</filename> before
15655 building Exim. For example:
15656 </para>
15657 <literallayout class="monospaced">
15658 CYRUS_PWCHECK_SOCKET=/var/pwcheck/pwcheck
15659 </literallayout>
15660 <para>
15661 You do not need to install the full Cyrus software suite in order to use
15662 the pwcheck daemon. You can compile and install just the daemon alone
15663 from the Cyrus SASL library. Ensure that <emphasis>exim</emphasis> is the only user that has
15664 access to the <filename>/var/pwcheck</filename> directory.
15665 </para>
15666 <para>
15667 The <option>pwcheck</option> condition takes one argument, which must be the user name and
15668 password, separated by a colon. For example, in a LOGIN authenticator
15669 configuration, you might have this:
15670 </para>
15671 <literallayout class="monospaced">
15672 server_condition = ${if pwcheck{$auth1:$auth2}}
15673 </literallayout>
15674 <para>
15675 Again, for a PLAIN authenticator configuration, this would be:
15676 </para>
15677 <literallayout class="monospaced">
15678 server_condition = ${if pwcheck{$auth2:$auth3}}
15679 </literallayout>
15680 </listitem></varlistentry>
15681 <varlistentry>
15682 <term><emphasis role="bold">queue_running</emphasis></term>
15683 <listitem>
15684 <para>
15685 <indexterm role="concept">
15686 <primary>queue runner</primary>
15687 <secondary>detecting when delivering from</secondary>
15688 </indexterm>
15689 <indexterm role="concept">
15690 <primary>expansion</primary>
15691 <secondary>queue runner test</secondary>
15692 </indexterm>
15693 <indexterm role="concept">
15694 <primary><option>queue_running</option> expansion condition</primary>
15695 </indexterm>
15696 This condition, which has no data, is true during delivery attempts that are
15697 initiated by queue runner processes, and false otherwise.
15698 </para>
15699 </listitem></varlistentry>
15700 <varlistentry>
15701 <term><emphasis role="bold">radius&nbsp;{</emphasis>&lt;<emphasis>authentication&nbsp;string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15702 <listitem>
15703 <para>
15704 <indexterm role="concept">
15705 <primary>Radius</primary>
15706 </indexterm>
15707 <indexterm role="concept">
15708 <primary>expansion</primary>
15709 <secondary>Radius authentication</secondary>
15710 </indexterm>
15711 <indexterm role="concept">
15712 <primary><option>radius</option> expansion condition</primary>
15713 </indexterm>
15714 Radius authentication (RFC 2865) is supported in a similar way to PAM. You must
15715 set RADIUS_CONFIG_FILE in <filename>Local/Makefile</filename> to specify the location of
15716 the Radius client configuration file in order to build Exim with Radius
15717 support.
15718 </para>
15719 <para>
15720 With just that one setting, Exim expects to be linked with the <option>radiusclient</option>
15721 library, using the original API. If you are using release 0.4.0 or later of
15722 this library, you need to set
15723 </para>
15724 <literallayout class="monospaced">
15725 RADIUS_LIB_TYPE=RADIUSCLIENTNEW
15726 </literallayout>
15727 <para>
15728 in <filename>Local/Makefile</filename> when building Exim. You can also link Exim with the
15729 <option>libradius</option> library that comes with FreeBSD. To do this, set
15730 </para>
15731 <literallayout class="monospaced">
15732 RADIUS_LIB_TYPE=RADLIB
15733 </literallayout>
15734 <para>
15735 in <filename>Local/Makefile</filename>, in addition to setting RADIUS_CONFIGURE_FILE.
15736 You may also have to supply a suitable setting in EXTRALIBS so that the
15737 Radius library can be found when Exim is linked.
15738 </para>
15739 <para>
15740 The string specified by RADIUS_CONFIG_FILE is expanded and passed to the
15741 Radius client library, which calls the Radius server. The condition is true if
15742 the authentication is successful. For example:
15743 </para>
15744 <literallayout class="monospaced">
15745 server_condition = ${if radius{&lt;arguments&gt;}}
15746 </literallayout>
15747 </listitem></varlistentry>
15748 <varlistentry>
15749 <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>
15750 <listitem>
15751 <para>
15752 <indexterm role="concept">
15753 <primary><emphasis>saslauthd</emphasis> daemon</primary>
15754 </indexterm>
15755 <indexterm role="concept">
15756 <primary>Cyrus</primary>
15757 </indexterm>
15758 <indexterm role="concept">
15759 <primary>expansion</primary>
15760 <secondary><emphasis>saslauthd</emphasis> authentication test</secondary>
15761 </indexterm>
15762 <indexterm role="concept">
15763 <primary><option>saslauthd</option> expansion condition</primary>
15764 </indexterm>
15765 This condition supports user authentication using the Cyrus <emphasis>saslauthd</emphasis>
15766 daemon. This replaces the older <emphasis>pwcheck</emphasis> daemon, which is now deprecated.
15767 Using this daemon is one way of making it possible for passwords to be checked
15768 by a process that is not running as root.
15769 </para>
15770 <para>
15771 The saslauthd support is not included in Exim by default. You need to specify
15772 the location of the saslauthd daemon&#x2019;s socket in <filename>Local/Makefile</filename> before
15773 building Exim. For example:
15774 </para>
15775 <literallayout class="monospaced">
15776 CYRUS_SASLAUTHD_SOCKET=/var/state/saslauthd/mux
15777 </literallayout>
15778 <para>
15779 You do not need to install the full Cyrus software suite in order to use
15780 the saslauthd daemon. You can compile and install just the daemon alone
15781 from the Cyrus SASL library.
15782 </para>
15783 <para>
15784 Up to four arguments can be supplied to the <option>saslauthd</option> condition, but only
15785 two are mandatory. For example:
15786 </para>
15787 <literallayout class="monospaced">
15788 server_condition = ${if saslauthd{{$auth1}{$auth2}}}
15789 </literallayout>
15790 <para>
15791 The service and the realm are optional (which is why the arguments are enclosed
15792 in their own set of braces). For details of the meaning of the service and
15793 realm, and how to run the daemon, consult the Cyrus documentation.
15794 </para>
15795 </listitem></varlistentry>
15796 </variablelist>
15797 </section>
15798 <section id="SECID84">
15799 <title>Combining expansion conditions</title>
15800 <para>
15801 <indexterm role="concept">
15802 <primary>expansion</primary>
15803 <secondary>combining conditions</secondary>
15804 </indexterm>
15805 Several conditions can be tested at once by combining them using the <option>and</option>
15806 and <option>or</option> combination conditions. Note that <option>and</option> and <option>or</option> are complete
15807 conditions on their own, and precede their lists of sub-conditions. Each
15808 sub-condition must be enclosed in braces within the overall braces that contain
15809 the list. No repetition of <option>if</option> is used.
15810 </para>
15811 <variablelist>
15812 <varlistentry>
15813 <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>
15814 <listitem>
15815 <para>
15816 <indexterm role="concept">
15817 <primary><quote>or</quote> expansion condition</primary>
15818 </indexterm>
15819 <indexterm role="concept">
15820 <primary>expansion</primary>
15821 <secondary><quote>or</quote> of conditions</secondary>
15822 </indexterm>
15823 The sub-conditions are evaluated from left to right. The condition is true if
15824 any one of the sub-conditions is true.
15825 For example,
15826 </para>
15827 <literallayout class="monospaced">
15828 ${if or {{eq{$local_part}{spqr}}{eq{$domain}{testing.com}}}...
15829 </literallayout>
15830 <para>
15831 When a true sub-condition is found, the following ones are parsed but not
15832 evaluated. If there are several <quote>match</quote> sub-conditions the values of the
15833 numeric variables afterwards are taken from the first one that succeeds.
15834 </para>
15835 </listitem></varlistentry>
15836 <varlistentry>
15837 <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>
15838 <listitem>
15839 <para>
15840 <indexterm role="concept">
15841 <primary><quote>and</quote> expansion condition</primary>
15842 </indexterm>
15843 <indexterm role="concept">
15844 <primary>expansion</primary>
15845 <secondary><quote>and</quote> of conditions</secondary>
15846 </indexterm>
15847 The sub-conditions are evaluated from left to right. The condition is true if
15848 all of the sub-conditions are true. If there are several <quote>match</quote>
15849 sub-conditions, the values of the numeric variables afterwards are taken from
15850 the last one. When a false sub-condition is found, the following ones are
15851 parsed but not evaluated.
15852 </para>
15853 </listitem></varlistentry>
15854 </variablelist>
15855 <para>
15856 <indexterm role="concept" startref="IIDexpcond" class="endofrange"/>
15857 </para>
15858 </section>
15859 <section id="SECTexpvar">
15860 <title>Expansion variables</title>
15861 <para>
15862 <indexterm role="concept">
15863 <primary>expansion</primary>
15864 <secondary>variables, list of</secondary>
15865 </indexterm>
15866 This section contains an alphabetical list of all the expansion variables. Some
15867 of them are available only when Exim is compiled with specific options such as
15868 support for TLS or the content scanning extension.
15869 </para>
15870 <variablelist>
15871 <varlistentry>
15872 <term><varname>$0</varname>, <varname>$1</varname>, etc</term>
15873 <listitem>
15874 <para>
15875 <indexterm role="concept">
15876 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
15877 </indexterm>
15878 When a <option>match</option> expansion condition succeeds, these variables contain the
15879 captured substrings identified by the regular expression during subsequent
15880 processing of the success string of the containing <option>if</option> expansion item.
15881 However, they do not retain their values afterwards; in fact, their previous
15882 values are restored at the end of processing an <option>if</option> item. The numerical
15883 variables may also be set externally by some other matching process which
15884 precedes the expansion of the string. For example, the commands available in
15885 Exim filter files include an <option>if</option> command with its own regular expression
15886 matching condition.
15887 </para>
15888 </listitem></varlistentry>
15889 <varlistentry>
15890 <term><varname>$acl_c...</varname></term>
15891 <listitem>
15892 <para>
15893 Values can be placed in these variables by the <option>set</option> modifier in an ACL. They
15894 can be given any name that starts with <varname>$acl_c</varname> and is at least six characters
15895 long, but the sixth character must be either a digit or an underscore. For
15896 example: <varname>$acl_c5</varname>, <varname>$acl_c_mycount</varname>. The values of the <varname>$acl_c...</varname>
15897 variables persist throughout the lifetime of an SMTP connection. They can be
15898 used to pass information between ACLs and between different invocations of the
15899 same ACL. When a message is received, the values of these variables are saved
15900 with the message, and can be accessed by filters, routers, and transports
15901 during subsequent delivery.
15902 </para>
15903 </listitem></varlistentry>
15904 <varlistentry>
15905 <term><varname>$acl_m...</varname></term>
15906 <listitem>
15907 <para>
15908 These variables are like the <varname>$acl_c...</varname> variables, except that their values
15909 are reset after a message has been received. Thus, if several messages are
15910 received in one SMTP connection, <varname>$acl_m...</varname> values are not passed on from one
15911 message to the next, as <varname>$acl_c...</varname> values are. The <varname>$acl_m...</varname> variables are
15912 also reset by MAIL, RSET, EHLO, HELO, and after starting a TLS session. When a
15913 message is received, the values of these variables are saved with the message,
15914 and can be accessed by filters, routers, and transports during subsequent
15915 delivery.
15916 </para>
15917 </listitem></varlistentry>
15918 <varlistentry>
15919 <term><varname>$acl_verify_message</varname></term>
15920 <listitem>
15921 <para>
15922 <indexterm role="variable">
15923 <primary><varname>$acl_verify_message</varname></primary>
15924 </indexterm>
15925 After an address verification has failed, this variable contains the failure
15926 message. It retains its value for use in subsequent modifiers. The message can
15927 be preserved by coding like this:
15928 </para>
15929 <literallayout class="monospaced">
15930 warn !verify = sender
15931      set acl_m0 = $acl_verify_message
15932 </literallayout>
15933 <para>
15934 You can use <varname>$acl_verify_message</varname> during the expansion of the <option>message</option> or
15935 <option>log_message</option> modifiers, to include information about the verification
15936 failure.
15937 </para>
15938 </listitem></varlistentry>
15939 <varlistentry>
15940 <term><varname>$address_data</varname></term>
15941 <listitem>
15942 <para>
15943 <indexterm role="variable">
15944 <primary><varname>$address_data</varname></primary>
15945 </indexterm>
15946 This variable is set by means of the <option>address_data</option> option in routers. The
15947 value then remains with the address while it is processed by subsequent routers
15948 and eventually a transport. If the transport is handling multiple addresses,
15949 the value from the first address is used. See chapter <xref linkend="CHAProutergeneric"/>
15950 for more details. <emphasis role="bold">Note</emphasis>: The contents of <varname>$address_data</varname> are visible in
15951 user filter files.
15952 </para>
15953 <para>
15954 If <varname>$address_data</varname> is set when the routers are called from an ACL to verify
15955 a recipient address, the final value is still in the variable for subsequent
15956 conditions and modifiers of the ACL statement. If routing the address caused it
15957 to be redirected to just one address, the child address is also routed as part
15958 of the verification, and in this case the final value of <varname>$address_data</varname> is
15959 from the child&#x2019;s routing.
15960 </para>
15961 <para>
15962 If <varname>$address_data</varname> is set when the routers are called from an ACL to verify a
15963 sender address, the final value is also preserved, but this time in
15964 <varname>$sender_address_data</varname>, to distinguish it from data from a recipient
15965 address.
15966 </para>
15967 <para>
15968 In both cases (recipient and sender verification), the value does not persist
15969 after the end of the current ACL statement. If you want to preserve
15970 these values for longer, you can save them in ACL variables.
15971 </para>
15972 </listitem></varlistentry>
15973 <varlistentry>
15974 <term><varname>$address_file</varname></term>
15975 <listitem>
15976 <para>
15977 <indexterm role="variable">
15978 <primary><varname>$address_file</varname></primary>
15979 </indexterm>
15980 When, as a result of aliasing, forwarding, or filtering, a message is directed
15981 to a specific file, this variable holds the name of the file when the transport
15982 is running. At other times, the variable is empty. For example, using the
15983 default configuration, if user <option>r2d2</option> has a <filename>.forward</filename> file containing
15984 </para>
15985 <literallayout class="monospaced">
15986 /home/r2d2/savemail
15987 </literallayout>
15988 <para>
15989 then when the <command>address_file</command> transport is running, <varname>$address_file</varname>
15990 contains the text string <literal>/home/r2d2/savemail</literal>.
15991 <indexterm role="concept">
15992 <primary>Sieve filter</primary>
15993 <secondary>value of <varname>$address_file</varname></secondary>
15994 </indexterm>
15995 For Sieve filters, the value may be <quote>inbox</quote> or a relative folder name. It is
15996 then up to the transport configuration to generate an appropriate absolute path
15997 to the relevant file.
15998 </para>
15999 </listitem></varlistentry>
16000 <varlistentry>
16001 <term><varname>$address_pipe</varname></term>
16002 <listitem>
16003 <para>
16004 <indexterm role="variable">
16005 <primary><varname>$address_pipe</varname></primary>
16006 </indexterm>
16007 When, as a result of aliasing or forwarding, a message is directed to a pipe,
16008 this variable holds the pipe command when the transport is running.
16009 </para>
16010 </listitem></varlistentry>
16011 <varlistentry>
16012 <term><varname>$auth1</varname> &ndash; <varname>$auth3</varname></term>
16013 <listitem>
16014 <para>
16015 <indexterm role="variable">
16016 <primary><varname>$auth1</varname>, <varname>$auth2</varname>, etc</primary>
16017 </indexterm>
16018 These variables are used in SMTP authenticators (see chapters
16019 <xref linkend="CHAPplaintext"/>&ndash;<xref linkend="CHAPspa"/>). Elsewhere, they are empty.
16020 </para>
16021 </listitem></varlistentry>
16022 <varlistentry>
16023 <term><varname>$authenticated_id</varname></term>
16024 <listitem>
16025 <para>
16026 <indexterm role="concept">
16027 <primary>authentication</primary>
16028 <secondary>id</secondary>
16029 </indexterm>
16030 <indexterm role="variable">
16031 <primary><varname>$authenticated_id</varname></primary>
16032 </indexterm>
16033 When a server successfully authenticates a client it may be configured to
16034 preserve some of the authentication information in the variable
16035 <varname>$authenticated_id</varname> (see chapter <xref linkend="CHAPSMTPAUTH"/>). For example, a
16036 user/password authenticator configuration might preserve the user name for use
16037 in the routers. Note that this is not the same information that is saved in
16038 <varname>$sender_host_authenticated</varname>.
16039 When a message is submitted locally (that is, not over a TCP connection)
16040 the value of <varname>$authenticated_id</varname> is normally the login name of the calling
16041 process. However, a trusted user can override this by means of the <option>-oMai</option>
16042 command line option.
16043 </para>
16044 </listitem></varlistentry>
16045 <varlistentry>
16046 <term><varname>$authenticated_sender</varname></term>
16047 <listitem>
16048 <para>
16049 <indexterm role="concept">
16050 <primary>sender</primary>
16051 <secondary>authenticated</secondary>
16052 </indexterm>
16053 <indexterm role="concept">
16054 <primary>authentication</primary>
16055 <secondary>sender</secondary>
16056 </indexterm>
16057 <indexterm role="concept">
16058 <primary>AUTH</primary>
16059 <secondary>on MAIL command</secondary>
16060 </indexterm>
16061 <indexterm role="variable">
16062 <primary><varname>$authenticated_sender</varname></primary>
16063 </indexterm>
16064 When acting as a server, Exim takes note of the AUTH= parameter on an incoming
16065 SMTP MAIL command if it believes the sender is sufficiently trusted, as
16066 described in section <xref linkend="SECTauthparamail"/>. Unless the data is the string
16067 <quote>&lt;&gt;</quote>, it is set as the authenticated sender of the message, and the value is
16068 available during delivery in the <varname>$authenticated_sender</varname> variable. If the
16069 sender is not trusted, Exim accepts the syntax of AUTH=, but ignores the data.
16070 </para>
16071 <para>
16072 <indexterm role="variable">
16073 <primary><varname>$qualify_domain</varname></primary>
16074 </indexterm>
16075 When a message is submitted locally (that is, not over a TCP connection), the
16076 value of <varname>$authenticated_sender</varname> is an address constructed from the login
16077 name of the calling process and <varname>$qualify_domain</varname>, except that a trusted user
16078 can override this by means of the <option>-oMas</option> command line option.
16079 </para>
16080 </listitem></varlistentry>
16081 <varlistentry>
16082 <term><varname>$authentication_failed</varname></term>
16083 <listitem>
16084 <para>
16085 <indexterm role="concept">
16086 <primary>authentication</primary>
16087 <secondary>failure</secondary>
16088 </indexterm>
16089 <indexterm role="variable">
16090 <primary><varname>$authentication_failed</varname></primary>
16091 </indexterm>
16092 This variable is set to <quote>1</quote> in an Exim server if a client issues an AUTH
16093 command that does not succeed. Otherwise it is set to <quote>0</quote>. This makes it
16094 possible to distinguish between <quote>did not try to authenticate</quote>
16095 (<varname>$sender_host_authenticated</varname> is empty and <varname>$authentication_failed</varname> is set to
16096 <quote>0</quote>) and <quote>tried to authenticate but failed</quote> (<varname>$sender_host_authenticated</varname>
16097 is empty and <varname>$authentication_failed</varname> is set to <quote>1</quote>). Failure includes any
16098 negative response to an AUTH command, including (for example) an attempt to use
16099 an undefined mechanism.
16100 </para>
16101 </listitem></varlistentry>
16102 <varlistentry>
16103 <term><varname>$body_linecount</varname></term>
16104 <listitem>
16105 <para>
16106 <indexterm role="concept">
16107 <primary>message body</primary>
16108 <secondary>line count</secondary>
16109 </indexterm>
16110 <indexterm role="concept">
16111 <primary>body of message</primary>
16112 <secondary>line count</secondary>
16113 </indexterm>
16114 <indexterm role="variable">
16115 <primary><varname>$body_linecount</varname></primary>
16116 </indexterm>
16117 When a message is being received or delivered, this variable contains the
16118 number of lines in the message&#x2019;s body. See also <varname>$message_linecount</varname>.
16119 </para>
16120 </listitem></varlistentry>
16121 <varlistentry>
16122 <term><varname>$body_zerocount</varname></term>
16123 <listitem>
16124 <para>
16125 <indexterm role="concept">
16126 <primary>message body</primary>
16127 <secondary>binary zero count</secondary>
16128 </indexterm>
16129 <indexterm role="concept">
16130 <primary>body of message</primary>
16131 <secondary>binary zero count</secondary>
16132 </indexterm>
16133 <indexterm role="concept">
16134 <primary>binary zero</primary>
16135 <secondary>in message body</secondary>
16136 </indexterm>
16137 <indexterm role="variable">
16138 <primary><varname>$body_zerocount</varname></primary>
16139 </indexterm>
16140 When a message is being received or delivered, this variable contains the
16141 number of binary zero bytes in the message&#x2019;s body.
16142 </para>
16143 </listitem></varlistentry>
16144 <varlistentry>
16145 <term><varname>$bounce_recipient</varname></term>
16146 <listitem>
16147 <para>
16148 <indexterm role="variable">
16149 <primary><varname>$bounce_recipient</varname></primary>
16150 </indexterm>
16151 This is set to the recipient address of a bounce message while Exim is creating
16152 it. It is useful if a customized bounce message text file is in use (see
16153 chapter <xref linkend="CHAPemsgcust"/>).
16154 </para>
16155 </listitem></varlistentry>
16156 <varlistentry>
16157 <term><varname>$bounce_return_size_limit</varname></term>
16158 <listitem>
16159 <para>
16160 <indexterm role="variable">
16161 <primary><varname>$bounce_return_size_limit</varname></primary>
16162 </indexterm>
16163 This contains the value set in the <option>bounce_return_size_limit</option> option, rounded
16164 up to a multiple of 1000. It is useful when a customized error message text
16165 file is in use (see chapter <xref linkend="CHAPemsgcust"/>).
16166 </para>
16167 </listitem></varlistentry>
16168 <varlistentry>
16169 <term><varname>$caller_gid</varname></term>
16170 <listitem>
16171 <para>
16172 <indexterm role="concept">
16173 <primary>gid (group id)</primary>
16174 <secondary>caller</secondary>
16175 </indexterm>
16176 <indexterm role="variable">
16177 <primary><varname>$caller_gid</varname></primary>
16178 </indexterm>
16179 The real group id under which the process that called Exim was running. This is
16180 not the same as the group id of the originator of a message (see
16181 <varname>$originator_gid</varname>). If Exim re-execs itself, this variable in the new
16182 incarnation normally contains the Exim gid.
16183 </para>
16184 </listitem></varlistentry>
16185 <varlistentry>
16186 <term><varname>$caller_uid</varname></term>
16187 <listitem>
16188 <para>
16189 <indexterm role="concept">
16190 <primary>uid (user id)</primary>
16191 <secondary>caller</secondary>
16192 </indexterm>
16193 <indexterm role="variable">
16194 <primary><varname>$caller_uid</varname></primary>
16195 </indexterm>
16196 The real user id under which the process that called Exim was running. This is
16197 not the same as the user id of the originator of a message (see
16198 <varname>$originator_uid</varname>). If Exim re-execs itself, this variable in the new
16199 incarnation normally contains the Exim uid.
16200 </para>
16201 </listitem></varlistentry>
16202 <varlistentry>
16203 <term><varname>$compile_date</varname></term>
16204 <listitem>
16205 <para>
16206 <indexterm role="variable">
16207 <primary><varname>$compile_date</varname></primary>
16208 </indexterm>
16209 The date on which the Exim binary was compiled.
16210 </para>
16211 </listitem></varlistentry>
16212 <varlistentry>
16213 <term><varname>$compile_number</varname></term>
16214 <listitem>
16215 <para>
16216 <indexterm role="variable">
16217 <primary><varname>$compile_number</varname></primary>
16218 </indexterm>
16219 The building process for Exim keeps a count of the number
16220 of times it has been compiled. This serves to distinguish different
16221 compilations of the same version of the program.
16222 </para>
16223 </listitem></varlistentry>
16224 <varlistentry>
16225 <term><varname>$demime_errorlevel</varname></term>
16226 <listitem>
16227 <para>
16228 <indexterm role="variable">
16229 <primary><varname>$demime_errorlevel</varname></primary>
16230 </indexterm>
16231 This variable is available when Exim is compiled with
16232 the content-scanning extension and the obsolete <option>demime</option> condition. For
16233 details, see section <xref linkend="SECTdemimecond"/>.
16234 </para>
16235 </listitem></varlistentry>
16236 <varlistentry>
16237 <term><varname>$demime_reason</varname></term>
16238 <listitem>
16239 <para>
16240 <indexterm role="variable">
16241 <primary><varname>$demime_reason</varname></primary>
16242 </indexterm>
16243 This variable is available when Exim is compiled with the
16244 content-scanning extension and the obsolete <option>demime</option> condition. For details,
16245 see section <xref linkend="SECTdemimecond"/>.
16246 </para>
16247 </listitem></varlistentry>
16248 <varlistentry>
16249 <term><varname>$dnslist_domain</varname></term>
16250 <term><varname>$dnslist_matched</varname></term>
16251 <term><varname>$dnslist_text</varname></term>
16252 <term><varname>$dnslist_value</varname></term>
16253 <listitem>
16254 <para>
16255 <indexterm role="variable">
16256 <primary><varname>$dnslist_domain</varname></primary>
16257 </indexterm>
16258 <indexterm role="variable">
16259 <primary><varname>$dnslist_matched</varname></primary>
16260 </indexterm>
16261 <indexterm role="variable">
16262 <primary><varname>$dnslist_text</varname></primary>
16263 </indexterm>
16264 <indexterm role="variable">
16265 <primary><varname>$dnslist_value</varname></primary>
16266 </indexterm>
16267 <indexterm role="concept">
16268 <primary>black list (DNS)</primary>
16269 </indexterm>
16270 When a DNS (black) list lookup succeeds, these variables are set to contain
16271 the following data from the lookup: the list&#x2019;s domain name, the key that was
16272 looked up, the contents of any associated TXT record, and the value from the
16273 main A record. See section <xref linkend="SECID204"/> for more details.
16274 </para>
16275 </listitem></varlistentry>
16276 <varlistentry>
16277 <term><varname>$domain</varname></term>
16278 <listitem>
16279 <para>
16280 <indexterm role="variable">
16281 <primary><varname>$domain</varname></primary>
16282 </indexterm>
16283 When an address is being routed, or delivered on its own, this variable
16284 contains the domain. Uppercase letters in the domain are converted into lower
16285 case for <varname>$domain</varname>.
16286 </para>
16287 <para>
16288 Global address rewriting happens when a message is received, so the value of
16289 <varname>$domain</varname> during routing and delivery is the value after rewriting. <varname>$domain</varname>
16290 is set during user filtering, but not during system filtering, because a
16291 message may have many recipients and the system filter is called just once.
16292 </para>
16293 <para>
16294 When more than one address is being delivered at once (for example, several
16295 RCPT commands in one SMTP delivery), <varname>$domain</varname> is set only if they all
16296 have the same domain. Transports can be restricted to handling only one domain
16297 at a time if the value of <varname>$domain</varname> is required at transport time &ndash; this is
16298 the default for local transports. For further details of the environment in
16299 which local transports are run, see chapter <xref linkend="CHAPenvironment"/>.
16300 </para>
16301 <para>
16302 <indexterm role="option">
16303 <primary><option>delay_warning_condition</option></primary>
16304 </indexterm>
16305 At the end of a delivery, if all deferred addresses have the same domain, it is
16306 set in <varname>$domain</varname> during the expansion of <option>delay_warning_condition</option>.
16307 </para>
16308 <para>
16309 The <varname>$domain</varname> variable is also used in some other circumstances:
16310 </para>
16311 <itemizedlist>
16312 <listitem>
16313 <para>
16314 When an ACL is running for a RCPT command, <varname>$domain</varname> contains the domain of
16315 the recipient address. The domain of the <emphasis>sender</emphasis> address is in
16316 <varname>$sender_address_domain</varname> at both MAIL time and at RCPT time. <varname>$domain</varname> is not
16317 normally set during the running of the MAIL ACL. However, if the sender address
16318 is verified with a callout during the MAIL ACL, the sender domain is placed in
16319 <varname>$domain</varname> during the expansions of <option>hosts</option>, <option>interface</option>, and <option>port</option> in
16320 the <command>smtp</command> transport.
16321 </para>
16322 </listitem>
16323 <listitem>
16324 <para>
16325 When a rewrite item is being processed (see chapter <xref linkend="CHAPrewrite"/>),
16326 <varname>$domain</varname> contains the domain portion of the address that is being rewritten;
16327 it can be used in the expansion of the replacement address, for example, to
16328 rewrite domains by file lookup.
16329 </para>
16330 </listitem>
16331 <listitem>
16332 <para>
16333 With one important exception, whenever a domain list is being scanned,
16334 <varname>$domain</varname> contains the subject domain. <emphasis role="bold">Exception</emphasis>: When a domain list in
16335 a <option>sender_domains</option> condition in an ACL is being processed, the subject domain
16336 is in <varname>$sender_address_domain</varname> and not in <varname>$domain</varname>. It works this way so
16337 that, in a RCPT ACL, the sender domain list can be dependent on the
16338 recipient domain (which is what is in <varname>$domain</varname> at this time).
16339 </para>
16340 </listitem>
16341 <listitem>
16342 <para>
16343 <indexterm role="concept">
16344 <primary>ETRN</primary>
16345 <secondary>value of <varname>$domain</varname></secondary>
16346 </indexterm>
16347 <indexterm role="option">
16348 <primary><option>smtp_etrn_command</option></primary>
16349 </indexterm>
16350 When the <option>smtp_etrn_command</option> option is being expanded, <varname>$domain</varname> contains
16351 the complete argument of the ETRN command (see section <xref linkend="SECTETRN"/>).
16352 </para>
16353 </listitem>
16354 </itemizedlist>
16355 </listitem></varlistentry>
16356 <varlistentry>
16357 <term><varname>$domain_data</varname></term>
16358 <listitem>
16359 <para>
16360 <indexterm role="variable">
16361 <primary><varname>$domain_data</varname></primary>
16362 </indexterm>
16363 When the <option>domains</option> option on a router matches a domain by
16364 means of a lookup, the data read by the lookup is available during the running
16365 of the router as <varname>$domain_data</varname>. In addition, if the driver routes the
16366 address to a transport, the value is available in that transport. If the
16367 transport is handling multiple addresses, the value from the first address is
16368 used.
16369 </para>
16370 <para>
16371 <varname>$domain_data</varname> is also set when the <option>domains</option> condition in an ACL matches a
16372 domain by means of a lookup. The data read by the lookup is available during
16373 the rest of the ACL statement. In all other situations, this variable expands
16374 to nothing.
16375 </para>
16376 </listitem></varlistentry>
16377 <varlistentry>
16378 <term><varname>$exim_gid</varname></term>
16379 <listitem>
16380 <para>
16381 <indexterm role="variable">
16382 <primary><varname>$exim_gid</varname></primary>
16383 </indexterm>
16384 This variable contains the numerical value of the Exim group id.
16385 </para>
16386 </listitem></varlistentry>
16387 <varlistentry>
16388 <term><varname>$exim_path</varname></term>
16389 <listitem>
16390 <para>
16391 <indexterm role="variable">
16392 <primary><varname>$exim_path</varname></primary>
16393 </indexterm>
16394 This variable contains the path to the Exim binary.
16395 </para>
16396 </listitem></varlistentry>
16397 <varlistentry>
16398 <term><varname>$exim_uid</varname></term>
16399 <listitem>
16400 <para>
16401 <indexterm role="variable">
16402 <primary><varname>$exim_uid</varname></primary>
16403 </indexterm>
16404 This variable contains the numerical value of the Exim user id.
16405 </para>
16406 </listitem></varlistentry>
16407 <varlistentry>
16408 <term><varname>$found_extension</varname></term>
16409 <listitem>
16410 <para>
16411 <indexterm role="variable">
16412 <primary><varname>$found_extension</varname></primary>
16413 </indexterm>
16414 This variable is available when Exim is compiled with the
16415 content-scanning extension and the obsolete <option>demime</option> condition. For details,
16416 see section <xref linkend="SECTdemimecond"/>.
16417 </para>
16418 </listitem></varlistentry>
16419 <varlistentry>
16420 <term><varname>$header_</varname>&lt;<emphasis>name</emphasis>&gt;</term>
16421 <listitem>
16422 <para>
16423 This is not strictly an expansion variable. It is expansion syntax for
16424 inserting the message header line with the given name. Note that the name must
16425 be terminated by colon or white space, because it may contain a wide variety of
16426 characters. Note also that braces must <emphasis>not</emphasis> be used.
16427 </para>
16428 </listitem></varlistentry>
16429 <varlistentry>
16430 <term><varname>$home</varname></term>
16431 <listitem>
16432 <para>
16433 <indexterm role="variable">
16434 <primary><varname>$home</varname></primary>
16435 </indexterm>
16436 When the <option>check_local_user</option> option is set for a router, the user&#x2019;s home
16437 directory is placed in <varname>$home</varname> when the check succeeds. In particular, this
16438 means it is set during the running of users&#x2019; filter files. A router may also
16439 explicitly set a home directory for use by a transport; this can be overridden
16440 by a setting on the transport itself.
16441 </para>
16442 <para>
16443 When running a filter test via the <option>-bf</option> option, <varname>$home</varname> is set to the value
16444 of the environment variable HOME.
16445 </para>
16446 </listitem></varlistentry>
16447 <varlistentry>
16448 <term><varname>$host</varname></term>
16449 <listitem>
16450 <para>
16451 <indexterm role="variable">
16452 <primary><varname>$host</varname></primary>
16453 </indexterm>
16454 If a router assigns an address to a transport (any transport), and passes a
16455 list of hosts with the address, the value of <varname>$host</varname> when the transport starts
16456 to run is the name of the first host on the list. Note that this applies both
16457 to local and remote transports.
16458 </para>
16459 <para>
16460 <indexterm role="concept">
16461 <primary>transport</primary>
16462 <secondary>filter</secondary>
16463 </indexterm>
16464 <indexterm role="concept">
16465 <primary>filter</primary>
16466 <secondary>transport filter</secondary>
16467 </indexterm>
16468 For the <command>smtp</command> transport, if there is more than one host, the value of
16469 <varname>$host</varname> changes as the transport works its way through the list. In
16470 particular, when the <command>smtp</command> transport is expanding its options for encryption
16471 using TLS, or for specifying a transport filter (see chapter
16472 <xref linkend="CHAPtransportgeneric"/>), <varname>$host</varname> contains the name of the host to which it
16473 is connected.
16474 </para>
16475 <para>
16476 When used in the client part of an authenticator configuration (see chapter
16477 <xref linkend="CHAPSMTPAUTH"/>), <varname>$host</varname> contains the name of the server to which the
16478 client is connected.
16479 </para>
16480 </listitem></varlistentry>
16481 <varlistentry>
16482 <term><varname>$host_address</varname></term>
16483 <listitem>
16484 <para>
16485 <indexterm role="variable">
16486 <primary><varname>$host_address</varname></primary>
16487 </indexterm>
16488 This variable is set to the remote host&#x2019;s IP address whenever <varname>$host</varname> is set
16489 for a remote connection. It is also set to the IP address that is being checked
16490 when the <option>ignore_target_hosts</option> option is being processed.
16491 </para>
16492 </listitem></varlistentry>
16493 <varlistentry>
16494 <term><varname>$host_data</varname></term>
16495 <listitem>
16496 <para>
16497 <indexterm role="variable">
16498 <primary><varname>$host_data</varname></primary>
16499 </indexterm>
16500 If a <option>hosts</option> condition in an ACL is satisfied by means of a lookup, the
16501 result of the lookup is made available in the <varname>$host_data</varname> variable. This
16502 allows you, for example, to do things like this:
16503 </para>
16504 <literallayout class="monospaced">
16505 deny  hosts = net-lsearch;/some/file
16506 message = $host_data
16507 </literallayout>
16508 </listitem></varlistentry>
16509 <varlistentry>
16510 <term><varname>$host_lookup_deferred</varname></term>
16511 <listitem>
16512 <para>
16513 <indexterm role="concept">
16514 <primary>host name</primary>
16515 <secondary>lookup, failure of</secondary>
16516 </indexterm>
16517 <indexterm role="variable">
16518 <primary><varname>$host_lookup_deferred</varname></primary>
16519 </indexterm>
16520 This variable normally contains <quote>0</quote>, as does <varname>$host_lookup_failed</varname>. When a
16521 message comes from a remote host and there is an attempt to look up the host&#x2019;s
16522 name from its IP address, and the attempt is not successful, one of these
16523 variables is set to <quote>1</quote>.
16524 </para>
16525 <itemizedlist>
16526 <listitem>
16527 <para>
16528 If the lookup receives a definite negative response (for example, a DNS lookup
16529 succeeded, but no records were found), <varname>$host_lookup_failed</varname> is set to <quote>1</quote>.
16530 </para>
16531 </listitem>
16532 <listitem>
16533 <para>
16534 If there is any kind of problem during the lookup, such that Exim cannot
16535 tell whether or not the host name is defined (for example, a timeout for a DNS
16536 lookup), <varname>$host_lookup_deferred</varname> is set to <quote>1</quote>.
16537 </para>
16538 </listitem>
16539 </itemizedlist>
16540 <para>
16541 Looking up a host&#x2019;s name from its IP address consists of more than just a
16542 single reverse lookup. Exim checks that a forward lookup of at least one of the
16543 names it receives from a reverse lookup yields the original IP address. If this
16544 is not the case, Exim does not accept the looked up name(s), and
16545 <varname>$host_lookup_failed</varname> is set to <quote>1</quote>. Thus, being able to find a name from an
16546 IP address (for example, the existence of a PTR record in the DNS) is not
16547 sufficient on its own for the success of a host name lookup. If the reverse
16548 lookup succeeds, but there is a lookup problem such as a timeout when checking
16549 the result, the name is not accepted, and <varname>$host_lookup_deferred</varname> is set to
16550 <quote>1</quote>. See also <varname>$sender_host_name</varname>.
16551 </para>
16552 </listitem></varlistentry>
16553 <varlistentry>
16554 <term><varname>$host_lookup_failed</varname></term>
16555 <listitem>
16556 <para>
16557 <indexterm role="variable">
16558 <primary><varname>$host_lookup_failed</varname></primary>
16559 </indexterm>
16560 See <varname>$host_lookup_deferred</varname>.
16561 </para>
16562 </listitem></varlistentry>
16563 <varlistentry>
16564 <term><varname>$inode</varname></term>
16565 <listitem>
16566 <para>
16567 <indexterm role="variable">
16568 <primary><varname>$inode</varname></primary>
16569 </indexterm>
16570 The only time this variable is set is while expanding the <option>directory_file</option>
16571 option in the <command>appendfile</command> transport. The variable contains the inode number
16572 of the temporary file which is about to be renamed. It can be used to construct
16573 a unique name for the file.
16574 </para>
16575 </listitem></varlistentry>
16576 <varlistentry>
16577 <term><varname>$interface_address</varname></term>
16578 <listitem>
16579 <para>
16580 <indexterm role="variable">
16581 <primary><varname>$interface_address</varname></primary>
16582 </indexterm>
16583 This is an obsolete name for <varname>$received_ip_address</varname>.
16584 </para>
16585 </listitem></varlistentry>
16586 <varlistentry>
16587 <term><varname>$interface_port</varname></term>
16588 <listitem>
16589 <para>
16590 <indexterm role="variable">
16591 <primary><varname>$interface_port</varname></primary>
16592 </indexterm>
16593 This is an obsolete name for <varname>$received_port</varname>.
16594 </para>
16595 </listitem></varlistentry>
16596 <varlistentry>
16597 <term><varname>$item</varname></term>
16598 <listitem>
16599 <para>
16600 <indexterm role="variable">
16601 <primary><varname>$item</varname></primary>
16602 </indexterm>
16603 This variable is used during the expansion of <emphasis role="bold">forall</emphasis> and <emphasis role="bold">forany</emphasis>
16604 conditions (see section <xref linkend="SECTexpcond"/>), and <emphasis role="bold">filter</emphasis>, <emphasis role="bold">map</emphasis>, and
16605 <emphasis role="bold">reduce</emphasis> items (see section <xref linkend="SECTexpcond"/>). In other circumstances, it is
16606 empty.
16607 </para>
16608 </listitem></varlistentry>
16609 <varlistentry>
16610 <term><varname>$ldap_dn</varname></term>
16611 <listitem>
16612 <para>
16613 <indexterm role="variable">
16614 <primary><varname>$ldap_dn</varname></primary>
16615 </indexterm>
16616 This variable, which is available only when Exim is compiled with LDAP support,
16617 contains the DN from the last entry in the most recently successful LDAP
16618 lookup.
16619 </para>
16620 </listitem></varlistentry>
16621 <varlistentry>
16622 <term><varname>$load_average</varname></term>
16623 <listitem>
16624 <para>
16625 <indexterm role="variable">
16626 <primary><varname>$load_average</varname></primary>
16627 </indexterm>
16628 This variable contains the system load average, multiplied by 1000 so that it
16629 is an integer. For example, if the load average is 0.21, the value of the
16630 variable is 210. The value is recomputed every time the variable is referenced.
16631 </para>
16632 </listitem></varlistentry>
16633 <varlistentry>
16634 <term><varname>$local_part</varname></term>
16635 <listitem>
16636 <para>
16637 <indexterm role="variable">
16638 <primary><varname>$local_part</varname></primary>
16639 </indexterm>
16640 When an address is being routed, or delivered on its own, this
16641 variable contains the local part. When a number of addresses are being
16642 delivered together (for example, multiple RCPT commands in an SMTP
16643 session), <varname>$local_part</varname> is not set.
16644 </para>
16645 <para>
16646 Global address rewriting happens when a message is received, so the value of
16647 <varname>$local_part</varname> during routing and delivery is the value after rewriting.
16648 <varname>$local_part</varname> is set during user filtering, but not during system filtering,
16649 because a message may have many recipients and the system filter is called just
16650 once.
16651 </para>
16652 <para>
16653 <indexterm role="variable">
16654 <primary><varname>$local_part_prefix</varname></primary>
16655 </indexterm>
16656 <indexterm role="variable">
16657 <primary><varname>$local_part_suffix</varname></primary>
16658 </indexterm>
16659 If a local part prefix or suffix has been recognized, it is not included in the
16660 value of <varname>$local_part</varname> during routing and subsequent delivery. The values of
16661 any prefix or suffix are in <varname>$local_part_prefix</varname> and
16662 <varname>$local_part_suffix</varname>, respectively.
16663 </para>
16664 <para>
16665 When a message is being delivered to a file, pipe, or autoreply transport as a
16666 result of aliasing or forwarding, <varname>$local_part</varname> is set to the local part of
16667 the parent address, not to the file name or command (see <varname>$address_file</varname> and
16668 <varname>$address_pipe</varname>).
16669 </para>
16670 <para>
16671 When an ACL is running for a RCPT command, <varname>$local_part</varname> contains the
16672 local part of the recipient address.
16673 </para>
16674 <para>
16675 When a rewrite item is being processed (see chapter <xref linkend="CHAPrewrite"/>),
16676 <varname>$local_part</varname> contains the local part of the address that is being rewritten;
16677 it can be used in the expansion of the replacement address, for example.
16678 </para>
16679 <para>
16680 In all cases, all quoting is removed from the local part. For example, for both
16681 the addresses
16682 </para>
16683 <literallayout class="monospaced">
16684 "abc:xyz"@test.example
16685 abc\:xyz@test.example
16686 </literallayout>
16687 <para>
16688 the value of <varname>$local_part</varname> is
16689 </para>
16690 <literallayout class="monospaced">
16691 abc:xyz
16692 </literallayout>
16693 <para>
16694 If you use <varname>$local_part</varname> to create another address, you should always wrap it
16695 inside a quoting operator. For example, in a <command>redirect</command> router you could
16696 have:
16697 </para>
16698 <literallayout class="monospaced">
16699 data = ${quote_local_part:$local_part}@new.domain.example
16700 </literallayout>
16701 <para>
16702 <emphasis role="bold">Note</emphasis>: The value of <varname>$local_part</varname> is normally lower cased. If you want
16703 to process local parts in a case-dependent manner in a router, you can set the
16704 <option>caseful_local_part</option> option (see chapter <xref linkend="CHAProutergeneric"/>).
16705 </para>
16706 </listitem></varlistentry>
16707 <varlistentry>
16708 <term><varname>$local_part_data</varname></term>
16709 <listitem>
16710 <para>
16711 <indexterm role="variable">
16712 <primary><varname>$local_part_data</varname></primary>
16713 </indexterm>
16714 When the <option>local_parts</option> option on a router matches a local part by means of a
16715 lookup, the data read by the lookup is available during the running of the
16716 router as <varname>$local_part_data</varname>. In addition, if the driver routes the address
16717 to a transport, the value is available in that transport. If the transport is
16718 handling multiple addresses, the value from the first address is used.
16719 </para>
16720 <para>
16721 <varname>$local_part_data</varname> is also set when the <option>local_parts</option> condition in an ACL
16722 matches a local part by means of a lookup. The data read by the lookup is
16723 available during the rest of the ACL statement. In all other situations, this
16724 variable expands to nothing.
16725 </para>
16726 </listitem></varlistentry>
16727 <varlistentry>
16728 <term><varname>$local_part_prefix</varname></term>
16729 <listitem>
16730 <para>
16731 <indexterm role="variable">
16732 <primary><varname>$local_part_prefix</varname></primary>
16733 </indexterm>
16734 When an address is being routed or delivered, and a
16735 specific prefix for the local part was recognized, it is available in this
16736 variable, having been removed from <varname>$local_part</varname>.
16737 </para>
16738 </listitem></varlistentry>
16739 <varlistentry>
16740 <term><varname>$local_part_suffix</varname></term>
16741 <listitem>
16742 <para>
16743 <indexterm role="variable">
16744 <primary><varname>$local_part_suffix</varname></primary>
16745 </indexterm>
16746 When an address is being routed or delivered, and a
16747 specific suffix for the local part was recognized, it is available in this
16748 variable, having been removed from <varname>$local_part</varname>.
16749 </para>
16750 </listitem></varlistentry>
16751 <varlistentry>
16752 <term><varname>$local_scan_data</varname></term>
16753 <listitem>
16754 <para>
16755 <indexterm role="variable">
16756 <primary><varname>$local_scan_data</varname></primary>
16757 </indexterm>
16758 This variable contains the text returned by the <function>local_scan()</function> function when
16759 a message is received. See chapter <xref linkend="CHAPlocalscan"/> for more details.
16760 </para>
16761 </listitem></varlistentry>
16762 <varlistentry>
16763 <term><varname>$local_user_gid</varname></term>
16764 <listitem>
16765 <para>
16766 <indexterm role="variable">
16767 <primary><varname>$local_user_gid</varname></primary>
16768 </indexterm>
16769 See <varname>$local_user_uid</varname>.
16770 </para>
16771 </listitem></varlistentry>
16772 <varlistentry>
16773 <term><varname>$local_user_uid</varname></term>
16774 <listitem>
16775 <para>
16776 <indexterm role="variable">
16777 <primary><varname>$local_user_uid</varname></primary>
16778 </indexterm>
16779 This variable and <varname>$local_user_gid</varname> are set to the uid and gid after the
16780 <option>check_local_user</option> router precondition succeeds. This means that their values
16781 are available for the remaining preconditions (<option>senders</option>, <option>require_files</option>,
16782 and <option>condition</option>), for the <option>address_data</option> expansion, and for any
16783 router-specific expansions. At all other times, the values in these variables
16784 are <literal>(uid_t)(-1)</literal> and <literal>(gid_t)(-1)</literal>, respectively.
16785 </para>
16786 </listitem></varlistentry>
16787 <varlistentry>
16788 <term><varname>$localhost_number</varname></term>
16789 <listitem>
16790 <para>
16791 <indexterm role="variable">
16792 <primary><varname>$localhost_number</varname></primary>
16793 </indexterm>
16794 This contains the expanded value of the
16795 <option>localhost_number</option> option. The expansion happens after the main options have
16796 been read.
16797 </para>
16798 </listitem></varlistentry>
16799 <varlistentry>
16800 <term><varname>$log_inodes</varname></term>
16801 <listitem>
16802 <para>
16803 <indexterm role="variable">
16804 <primary><varname>$log_inodes</varname></primary>
16805 </indexterm>
16806 The number of free inodes in the disk partition where Exim&#x2019;s
16807 log files are being written. The value is recalculated whenever the variable is
16808 referenced. If the relevant file system does not have the concept of inodes,
16809 the value of is -1. See also the <option>check_log_inodes</option> option.
16810 </para>
16811 </listitem></varlistentry>
16812 <varlistentry>
16813 <term><varname>$log_space</varname></term>
16814 <listitem>
16815 <para>
16816 <indexterm role="variable">
16817 <primary><varname>$log_space</varname></primary>
16818 </indexterm>
16819 The amount of free space (as a number of kilobytes) in the disk
16820 partition where Exim&#x2019;s log files are being written. The value is recalculated
16821 whenever the variable is referenced. If the operating system does not have the
16822 ability to find the amount of free space (only true for experimental systems),
16823 the space value is -1. See also the <option>check_log_space</option> option.
16824 </para>
16825 </listitem></varlistentry>
16826 <varlistentry>
16827 <term><varname>$mailstore_basename</varname></term>
16828 <listitem>
16829 <para>
16830 <indexterm role="variable">
16831 <primary><varname>$mailstore_basename</varname></primary>
16832 </indexterm>
16833 This variable is set only when doing deliveries in <quote>mailstore</quote> format in the
16834 <command>appendfile</command> transport. During the expansion of the <option>mailstore_prefix</option>,
16835 <option>mailstore_suffix</option>, <option>message_prefix</option>, and <option>message_suffix</option> options, it
16836 contains the basename of the files that are being written, that is, the name
16837 without the <quote>.tmp</quote>, <quote>.env</quote>, or <quote>.msg</quote> suffix. At all other times, this
16838 variable is empty.
16839 </para>
16840 </listitem></varlistentry>
16841 <varlistentry>
16842 <term><varname>$malware_name</varname></term>
16843 <listitem>
16844 <para>
16845 <indexterm role="variable">
16846 <primary><varname>$malware_name</varname></primary>
16847 </indexterm>
16848 This variable is available when Exim is compiled with the
16849 content-scanning extension. It is set to the name of the virus that was found
16850 when the ACL <option>malware</option> condition is true (see section <xref linkend="SECTscanvirus"/>).
16851 </para>
16852 </listitem></varlistentry>
16853 <varlistentry>
16854 <term><varname>$max_received_linelength</varname></term>
16855 <listitem>
16856 <para>
16857 <indexterm role="variable">
16858 <primary><varname>$max_received_linelength</varname></primary>
16859 </indexterm>
16860 <indexterm role="concept">
16861 <primary>maximum</primary>
16862 <secondary>line length</secondary>
16863 </indexterm>
16864 <indexterm role="concept">
16865 <primary>line length</primary>
16866 <secondary>maximum</secondary>
16867 </indexterm>
16868 This variable contains the number of bytes in the longest line that was
16869 received as part of the message, not counting the line termination
16870 character(s).
16871 </para>
16872 </listitem></varlistentry>
16873 <varlistentry>
16874 <term><varname>$message_age</varname></term>
16875 <listitem>
16876 <para>
16877 <indexterm role="concept">
16878 <primary>message</primary>
16879 <secondary>age of</secondary>
16880 </indexterm>
16881 <indexterm role="variable">
16882 <primary><varname>$message_age</varname></primary>
16883 </indexterm>
16884 This variable is set at the start of a delivery attempt to contain the number
16885 of seconds since the message was received. It does not change during a single
16886 delivery attempt.
16887 </para>
16888 </listitem></varlistentry>
16889 <varlistentry>
16890 <term><varname>$message_body</varname></term>
16891 <listitem>
16892 <para>
16893 <indexterm role="concept">
16894 <primary>body of message</primary>
16895 <secondary>expansion variable</secondary>
16896 </indexterm>
16897 <indexterm role="concept">
16898 <primary>message body</primary>
16899 <secondary>in expansion</secondary>
16900 </indexterm>
16901 <indexterm role="concept">
16902 <primary>binary zero</primary>
16903 <secondary>in message body</secondary>
16904 </indexterm>
16905 <indexterm role="variable">
16906 <primary><varname>$message_body</varname></primary>
16907 </indexterm>
16908 <indexterm role="option">
16909 <primary><option>message_body_visible</option></primary>
16910 </indexterm>
16911 This variable contains the initial portion of a message&#x2019;s body while it is
16912 being delivered, and is intended mainly for use in filter files. The maximum
16913 number of characters of the body that are put into the variable is set by the
16914 <option>message_body_visible</option> configuration option; the default is 500.
16915 </para>
16916 <para>
16917 <indexterm role="option">
16918 <primary><option>message_body_newlines</option></primary>
16919 </indexterm>
16920 By default, newlines are converted into spaces in <varname>$message_body</varname>, to make it
16921 easier to search for phrases that might be split over a line break. However,
16922 this can be disabled by setting <option>message_body_newlines</option> to be true. Binary
16923 zeros are always converted into spaces.
16924 </para>
16925 </listitem></varlistentry>
16926 <varlistentry>
16927 <term><varname>$message_body_end</varname></term>
16928 <listitem>
16929 <para>
16930 <indexterm role="concept">
16931 <primary>body of message</primary>
16932 <secondary>expansion variable</secondary>
16933 </indexterm>
16934 <indexterm role="concept">
16935 <primary>message body</primary>
16936 <secondary>in expansion</secondary>
16937 </indexterm>
16938 <indexterm role="variable">
16939 <primary><varname>$message_body_end</varname></primary>
16940 </indexterm>
16941 This variable contains the final portion of a message&#x2019;s
16942 body while it is being delivered. The format and maximum size are as for
16943 <varname>$message_body</varname>.
16944 </para>
16945 </listitem></varlistentry>
16946 <varlistentry>
16947 <term><varname>$message_body_size</varname></term>
16948 <listitem>
16949 <para>
16950 <indexterm role="concept">
16951 <primary>body of message</primary>
16952 <secondary>size</secondary>
16953 </indexterm>
16954 <indexterm role="concept">
16955 <primary>message body</primary>
16956 <secondary>size</secondary>
16957 </indexterm>
16958 <indexterm role="variable">
16959 <primary><varname>$message_body_size</varname></primary>
16960 </indexterm>
16961 When a message is being delivered, this variable contains the size of the body
16962 in bytes. The count starts from the character after the blank line that
16963 separates the body from the header. Newlines are included in the count. See
16964 also <varname>$message_size</varname>, <varname>$body_linecount</varname>, and <varname>$body_zerocount</varname>.
16965 </para>
16966 </listitem></varlistentry>
16967 <varlistentry>
16968 <term><varname>$message_exim_id</varname></term>
16969 <listitem>
16970 <para>
16971 <indexterm role="variable">
16972 <primary><varname>$message_exim_id</varname></primary>
16973 </indexterm>
16974 When a message is being received or delivered, this variable contains the
16975 unique message id that is generated and used by Exim to identify the message.
16976 An id is not created for a message until after its header has been successfully
16977 received. <emphasis role="bold">Note</emphasis>: This is <emphasis>not</emphasis> the contents of the <emphasis>Message-ID:</emphasis> header
16978 line; it is the local id that Exim assigns to the message, for example:
16979 <literal>1BXTIK-0001yO-VA</literal>.
16980 </para>
16981 </listitem></varlistentry>
16982 <varlistentry>
16983 <term><varname>$message_headers</varname></term>
16984 <listitem>
16985 <para>
16986 <indexterm role="variable">
16987 <primary><varname>$message_headers</varname></primary>
16988 </indexterm>
16989 This variable contains a concatenation of all the header lines when a message
16990 is being processed, except for lines added by routers or transports. The header
16991 lines are separated by newline characters. Their contents are decoded in the
16992 same way as a header line that is inserted by <option>bheader</option>.
16993 </para>
16994 </listitem></varlistentry>
16995 <varlistentry>
16996 <term><varname>$message_headers_raw</varname></term>
16997 <listitem>
16998 <para>
16999 <indexterm role="variable">
17000 <primary><varname>$message_headers_raw</varname></primary>
17001 </indexterm>
17002 This variable is like <varname>$message_headers</varname> except that no processing of the
17003 contents of header lines is done.
17004 </para>
17005 </listitem></varlistentry>
17006 <varlistentry>
17007 <term><varname>$message_id</varname></term>
17008 <listitem>
17009 <para>
17010 This is an old name for <varname>$message_exim_id</varname>, which is now deprecated.
17011 </para>
17012 </listitem></varlistentry>
17013 <varlistentry>
17014 <term><varname>$message_linecount</varname></term>
17015 <listitem>
17016 <para>
17017 <indexterm role="variable">
17018 <primary><varname>$message_linecount</varname></primary>
17019 </indexterm>
17020 This variable contains the total number of lines in the header and body of the
17021 message. Compare <varname>$body_linecount</varname>, which is the count for the body only.
17022 During the DATA and content-scanning ACLs, <varname>$message_linecount</varname> contains the
17023 number of lines received. Before delivery happens (that is, before filters,
17024 routers, and transports run) the count is increased to include the
17025 <emphasis>Received:</emphasis> header line that Exim standardly adds, and also any other header
17026 lines that are added by ACLs. The blank line that separates the message header
17027 from the body is not counted. Here is an example of the use of this variable in
17028 a DATA ACL:
17029 </para>
17030 <literallayout class="monospaced">
17031 deny message   = Too many lines in message header
17032      condition = \
17033       ${if &lt;{250}{${eval:$message_linecount - $body_linecount}}}
17034 </literallayout>
17035 <para>
17036 In the MAIL and RCPT ACLs, the value is zero because at that stage the
17037 message has not yet been received.
17038 </para>
17039 </listitem></varlistentry>
17040 <varlistentry>
17041 <term><varname>$message_size</varname></term>
17042 <listitem>
17043 <para>
17044 <indexterm role="concept">
17045 <primary>size</primary>
17046 <secondary>of message</secondary>
17047 </indexterm>
17048 <indexterm role="concept">
17049 <primary>message</primary>
17050 <secondary>size</secondary>
17051 </indexterm>
17052 <indexterm role="variable">
17053 <primary><varname>$message_size</varname></primary>
17054 </indexterm>
17055 When a message is being processed, this variable contains its size in bytes. In
17056 most cases, the size includes those headers that were received with the
17057 message, but not those (such as <emphasis>Envelope-to:</emphasis>) that are added to individual
17058 deliveries as they are written. However, there is one special case: during the
17059 expansion of the <option>maildir_tag</option> option in the <command>appendfile</command> transport while
17060 doing a delivery in maildir format, the value of <varname>$message_size</varname> is the
17061 precise size of the file that has been written. See also
17062 <varname>$message_body_size</varname>, <varname>$body_linecount</varname>, and <varname>$body_zerocount</varname>.
17063 </para>
17064 <para>
17065 <indexterm role="concept">
17066 <primary>RCPT</primary>
17067 <secondary>value of <varname>$message_size</varname></secondary>
17068 </indexterm>
17069 While running a per message ACL (mail/rcpt/predata), <varname>$message_size</varname>
17070 contains the size supplied on the MAIL command, or -1 if no size was given. The
17071 value may not, of course, be truthful.
17072 </para>
17073 </listitem></varlistentry>
17074 <varlistentry>
17075 <term><varname>$mime_</varname><emphasis>xxx</emphasis></term>
17076 <listitem>
17077 <para>
17078 A number of variables whose names start with <varname>$mime</varname> are
17079 available when Exim is compiled with the content-scanning extension. For
17080 details, see section <xref linkend="SECTscanmimepart"/>.
17081 </para>
17082 </listitem></varlistentry>
17083 <varlistentry>
17084 <term><varname>$n0</varname> &ndash; <varname>$n9</varname></term>
17085 <listitem>
17086 <para>
17087 These variables are counters that can be incremented by means
17088 of the <option>add</option> command in filter files.
17089 </para>
17090 </listitem></varlistentry>
17091 <varlistentry>
17092 <term><varname>$original_domain</varname></term>
17093 <listitem>
17094 <para>
17095 <indexterm role="variable">
17096 <primary><varname>$domain</varname></primary>
17097 </indexterm>
17098 <indexterm role="variable">
17099 <primary><varname>$original_domain</varname></primary>
17100 </indexterm>
17101 When a top-level address is being processed for delivery, this contains the
17102 same value as <varname>$domain</varname>. However, if a <quote>child</quote> address (for example,
17103 generated by an alias, forward, or filter file) is being processed, this
17104 variable contains the domain of the original address (lower cased). This
17105 differs from <varname>$parent_domain</varname> only when there is more than one level of
17106 aliasing or forwarding. When more than one address is being delivered in a
17107 single transport run, <varname>$original_domain</varname> is not set.
17108 </para>
17109 <para>
17110 If a new address is created by means of a <option>deliver</option> command in a system
17111 filter, it is set up with an artificial <quote>parent</quote> address. This has the local
17112 part <emphasis>system-filter</emphasis> and the default qualify domain.
17113 </para>
17114 </listitem></varlistentry>
17115 <varlistentry>
17116 <term><varname>$original_local_part</varname></term>
17117 <listitem>
17118 <para>
17119 <indexterm role="variable">
17120 <primary><varname>$local_part</varname></primary>
17121 </indexterm>
17122 <indexterm role="variable">
17123 <primary><varname>$original_local_part</varname></primary>
17124 </indexterm>
17125 When a top-level address is being processed for delivery, this contains the
17126 same value as <varname>$local_part</varname>, unless a prefix or suffix was removed from the
17127 local part, because <varname>$original_local_part</varname> always contains the full local
17128 part. When a <quote>child</quote> address (for example, generated by an alias, forward, or
17129 filter file) is being processed, this variable contains the full local part of
17130 the original address.
17131 </para>
17132 <para>
17133 If the router that did the redirection processed the local part
17134 case-insensitively, the value in <varname>$original_local_part</varname> is in lower case.
17135 This variable differs from <varname>$parent_local_part</varname> only when there is more than
17136 one level of aliasing or forwarding. When more than one address is being
17137 delivered in a single transport run, <varname>$original_local_part</varname> is not set.
17138 </para>
17139 <para>
17140 If a new address is created by means of a <option>deliver</option> command in a system
17141 filter, it is set up with an artificial <quote>parent</quote> address. This has the local
17142 part <emphasis>system-filter</emphasis> and the default qualify domain.
17143 </para>
17144 </listitem></varlistentry>
17145 <varlistentry>
17146 <term><varname>$originator_gid</varname></term>
17147 <listitem>
17148 <para>
17149 <indexterm role="concept">
17150 <primary>gid (group id)</primary>
17151 <secondary>of originating user</secondary>
17152 </indexterm>
17153 <indexterm role="concept">
17154 <primary>sender</primary>
17155 <secondary>gid</secondary>
17156 </indexterm>
17157 <indexterm role="variable">
17158 <primary><varname>$caller_gid</varname></primary>
17159 </indexterm>
17160 <indexterm role="variable">
17161 <primary><varname>$originator_gid</varname></primary>
17162 </indexterm>
17163 This variable contains the value of <varname>$caller_gid</varname> that was set when the
17164 message was received. For messages received via the command line, this is the
17165 gid of the sending user. For messages received by SMTP over TCP/IP, this is
17166 normally the gid of the Exim user.
17167 </para>
17168 </listitem></varlistentry>
17169 <varlistentry>
17170 <term><varname>$originator_uid</varname></term>
17171 <listitem>
17172 <para>
17173 <indexterm role="concept">
17174 <primary>uid (user id)</primary>
17175 <secondary>of originating user</secondary>
17176 </indexterm>
17177 <indexterm role="concept">
17178 <primary>sender</primary>
17179 <secondary>uid</secondary>
17180 </indexterm>
17181 <indexterm role="variable">
17182 <primary><varname>$caller_uid</varname></primary>
17183 </indexterm>
17184 <indexterm role="variable">
17185 <primary><varname>$originaltor_uid</varname></primary>
17186 </indexterm>
17187 The value of <varname>$caller_uid</varname> that was set when the message was received. For
17188 messages received via the command line, this is the uid of the sending user.
17189 For messages received by SMTP over TCP/IP, this is normally the uid of the Exim
17190 user.
17191 </para>
17192 </listitem></varlistentry>
17193 <varlistentry>
17194 <term><varname>$parent_domain</varname></term>
17195 <listitem>
17196 <para>
17197 <indexterm role="variable">
17198 <primary><varname>$parent_domain</varname></primary>
17199 </indexterm>
17200 This variable is similar to <varname>$original_domain</varname> (see
17201 above), except that it refers to the immediately preceding parent address.
17202 </para>
17203 </listitem></varlistentry>
17204 <varlistentry>
17205 <term><varname>$parent_local_part</varname></term>
17206 <listitem>
17207 <para>
17208 <indexterm role="variable">
17209 <primary><varname>$parent_local_part</varname></primary>
17210 </indexterm>
17211 This variable is similar to <varname>$original_local_part</varname>
17212 (see above), except that it refers to the immediately preceding parent address.
17213 </para>
17214 </listitem></varlistentry>
17215 <varlistentry>
17216 <term><varname>$pid</varname></term>
17217 <listitem>
17218 <para>
17219 <indexterm role="concept">
17220 <primary>pid (process id)</primary>
17221 <secondary>of current process</secondary>
17222 </indexterm>
17223 <indexterm role="variable">
17224 <primary><varname>$pid</varname></primary>
17225 </indexterm>
17226 This variable contains the current process id.
17227 </para>
17228 </listitem></varlistentry>
17229 <varlistentry>
17230 <term><varname>$pipe_addresses</varname></term>
17231 <listitem>
17232 <para>
17233 <indexterm role="concept">
17234 <primary>filter</primary>
17235 <secondary>transport filter</secondary>
17236 </indexterm>
17237 <indexterm role="concept">
17238 <primary>transport</primary>
17239 <secondary>filter</secondary>
17240 </indexterm>
17241 <indexterm role="variable">
17242 <primary><varname>$pipe_addresses</varname></primary>
17243 </indexterm>
17244 This is not an expansion variable, but is mentioned here because the string
17245 <literal>$pipe_addresses</literal> is handled specially in the command specification for the
17246 <command>pipe</command> transport (chapter <xref linkend="CHAPpipetransport"/>) and in transport filters
17247 (described under <option>transport_filter</option> in chapter <xref linkend="CHAPtransportgeneric"/>).
17248 It cannot be used in general expansion strings, and provokes an <quote>unknown
17249 variable</quote> error if encountered.
17250 </para>
17251 </listitem></varlistentry>
17252 <varlistentry>
17253 <term><varname>$primary_hostname</varname></term>
17254 <listitem>
17255 <para>
17256 <indexterm role="variable">
17257 <primary><varname>$primary_hostname</varname></primary>
17258 </indexterm>
17259 This variable contains the value set by <option>primary_hostname</option> in the
17260 configuration file, or read by the <function>uname()</function> function. If <function>uname()</function> returns
17261 a single-component name, Exim calls <function>gethostbyname()</function> (or
17262 <function>getipnodebyname()</function> where available) in an attempt to acquire a fully
17263 qualified host name. See also <varname>$smtp_active_hostname</varname>.
17264 </para>
17265 </listitem></varlistentry>
17266 <varlistentry>
17267 <term><varname>$prvscheck_address</varname></term>
17268 <listitem>
17269 <para>
17270 This variable is used in conjunction with the <option>prvscheck</option> expansion item,
17271 which is described in sections <xref linkend="SECTexpansionitems"/> and
17272 <xref linkend="SECTverifyPRVS"/>.
17273 </para>
17274 </listitem></varlistentry>
17275 <varlistentry>
17276 <term><varname>$prvscheck_keynum</varname></term>
17277 <listitem>
17278 <para>
17279 This variable is used in conjunction with the <option>prvscheck</option> expansion item,
17280 which is described in sections <xref linkend="SECTexpansionitems"/> and
17281 <xref linkend="SECTverifyPRVS"/>.
17282 </para>
17283 </listitem></varlistentry>
17284 <varlistentry>
17285 <term><varname>$prvscheck_result</varname></term>
17286 <listitem>
17287 <para>
17288 This variable is used in conjunction with the <option>prvscheck</option> expansion item,
17289 which is described in sections <xref linkend="SECTexpansionitems"/> and
17290 <xref linkend="SECTverifyPRVS"/>.
17291 </para>
17292 </listitem></varlistentry>
17293 <varlistentry>
17294 <term><varname>$qualify_domain</varname></term>
17295 <listitem>
17296 <para>
17297 <indexterm role="variable">
17298 <primary><varname>$qualify_domain</varname></primary>
17299 </indexterm>
17300 The value set for the <option>qualify_domain</option> option in the configuration file.
17301 </para>
17302 </listitem></varlistentry>
17303 <varlistentry>
17304 <term><varname>$qualify_recipient</varname></term>
17305 <listitem>
17306 <para>
17307 <indexterm role="variable">
17308 <primary><varname>$qualify_recipient</varname></primary>
17309 </indexterm>
17310 The value set for the <option>qualify_recipient</option> option in the configuration file,
17311 or if not set, the value of <varname>$qualify_domain</varname>.
17312 </para>
17313 </listitem></varlistentry>
17314 <varlistentry>
17315 <term><varname>$rcpt_count</varname></term>
17316 <listitem>
17317 <para>
17318 <indexterm role="variable">
17319 <primary><varname>$rcpt_count</varname></primary>
17320 </indexterm>
17321 When a message is being received by SMTP, this variable contains the number of
17322 RCPT commands received for the current message. If this variable is used in a
17323 RCPT ACL, its value includes the current command.
17324 </para>
17325 </listitem></varlistentry>
17326 <varlistentry>
17327 <term><varname>$rcpt_defer_count</varname></term>
17328 <listitem>
17329 <para>
17330 <indexterm role="variable">
17331 <primary><varname>$rcpt_defer_count</varname></primary>
17332 </indexterm>
17333 <indexterm role="concept">
17334 <primary>4<emphasis>xx</emphasis> responses</primary>
17335 <secondary>count of</secondary>
17336 </indexterm>
17337 When a message is being received by SMTP, this variable contains the number of
17338 RCPT commands in the current message that have previously been rejected with a
17339 temporary (4<emphasis>xx</emphasis>) response.
17340 </para>
17341 </listitem></varlistentry>
17342 <varlistentry>
17343 <term><varname>$rcpt_fail_count</varname></term>
17344 <listitem>
17345 <para>
17346 <indexterm role="variable">
17347 <primary><varname>$rcpt_fail_count</varname></primary>
17348 </indexterm>
17349 When a message is being received by SMTP, this variable contains the number of
17350 RCPT commands in the current message that have previously been rejected with a
17351 permanent (5<emphasis>xx</emphasis>) response.
17352 </para>
17353 </listitem></varlistentry>
17354 <varlistentry>
17355 <term><varname>$received_count</varname></term>
17356 <listitem>
17357 <para>
17358 <indexterm role="variable">
17359 <primary><varname>$received_count</varname></primary>
17360 </indexterm>
17361 This variable contains the number of <emphasis>Received:</emphasis> header lines in the message,
17362 including the one added by Exim (so its value is always greater than zero). It
17363 is available in the DATA ACL, the non-SMTP ACL, and while routing and
17364 delivering.
17365 </para>
17366 </listitem></varlistentry>
17367 <varlistentry>
17368 <term><varname>$received_for</varname></term>
17369 <listitem>
17370 <para>
17371 <indexterm role="variable">
17372 <primary><varname>$received_for</varname></primary>
17373 </indexterm>
17374 If there is only a single recipient address in an incoming message, this
17375 variable contains that address when the <emphasis>Received:</emphasis> header line is being
17376 built. The value is copied after recipient rewriting has happened, but before
17377 the <function>local_scan()</function> function is run.
17378 </para>
17379 </listitem></varlistentry>
17380 <varlistentry>
17381 <term><varname>$received_ip_address</varname></term>
17382 <listitem>
17383 <para>
17384 <indexterm role="variable">
17385 <primary><varname>$received_ip_address</varname></primary>
17386 </indexterm>
17387 As soon as an Exim server starts processing an incoming TCP/IP connection, this
17388 variable is set to the address of the local IP interface, and <varname>$received_port</varname>
17389 is set to the local port number. (The remote IP address and port are in
17390 <varname>$sender_host_address</varname> and <varname>$sender_host_port</varname>.) When testing with <option>-bh</option>,
17391 the port value is -1 unless it has been set using the <option>-oMi</option> command line
17392 option.
17393 </para>
17394 <para>
17395 As well as being useful in ACLs (including the <quote>connect</quote> ACL), these variable
17396 could be used, for example, to make the file name for a TLS certificate depend
17397 on which interface and/or port is being used for the incoming connection. The
17398 values of <varname>$received_ip_address</varname> and <varname>$received_port</varname> are saved with any
17399 messages that are received, thus making these variables available at delivery
17400 time.
17401 </para>
17402 <para>
17403 <emphasis role="bold">Note:</emphasis> There are no equivalent variables for outgoing connections, because
17404 the values are unknown (unless they are explicitly set by options of the
17405 <command>smtp</command> transport).
17406 </para>
17407 </listitem></varlistentry>
17408 <varlistentry>
17409 <term><varname>$received_port</varname></term>
17410 <listitem>
17411 <para>
17412 <indexterm role="variable">
17413 <primary><varname>$received_port</varname></primary>
17414 </indexterm>
17415 See <varname>$received_ip_address</varname>.
17416 </para>
17417 </listitem></varlistentry>
17418 <varlistentry>
17419 <term><varname>$received_protocol</varname></term>
17420 <listitem>
17421 <para>
17422 <indexterm role="variable">
17423 <primary><varname>$received_protocol</varname></primary>
17424 </indexterm>
17425 When a message is being processed, this variable contains the name of the
17426 protocol by which it was received. Most of the names used by Exim are defined
17427 by RFCs 821, 2821, and 3848. They start with <quote>smtp</quote> (the client used HELO) or
17428 <quote>esmtp</quote> (the client used EHLO). This can be followed by <quote>s</quote> for secure
17429 (encrypted) and/or <quote>a</quote> for authenticated. Thus, for example, if the protocol
17430 is set to <quote>esmtpsa</quote>, the message was received over an encrypted SMTP
17431 connection and the client was successfully authenticated.
17432 </para>
17433 <para>
17434 Exim uses the protocol name <quote>smtps</quote> for the case when encryption is
17435 automatically set up on connection without the use of STARTTLS (see
17436 <option>tls_on_connect_ports</option>), and the client uses HELO to initiate the
17437 encrypted SMTP session. The name <quote>smtps</quote> is also used for the rare situation
17438 where the client initially uses EHLO, sets up an encrypted connection using
17439 STARTTLS, and then uses HELO afterwards.
17440 </para>
17441 <para>
17442 The <option>-oMr</option> option provides a way of specifying a custom protocol name for
17443 messages that are injected locally by trusted callers. This is commonly used to
17444 identify messages that are being re-injected after some kind of scanning.
17445 </para>
17446 </listitem></varlistentry>
17447 <varlistentry>
17448 <term><varname>$received_time</varname></term>
17449 <listitem>
17450 <para>
17451 <indexterm role="variable">
17452 <primary><varname>$received_time</varname></primary>
17453 </indexterm>
17454 This variable contains the date and time when the current message was received,
17455 as a number of seconds since the start of the Unix epoch.
17456 </para>
17457 </listitem></varlistentry>
17458 <varlistentry>
17459 <term><varname>$recipient_data</varname></term>
17460 <listitem>
17461 <para>
17462 <indexterm role="variable">
17463 <primary><varname>$recipient_data</varname></primary>
17464 </indexterm>
17465 This variable is set after an indexing lookup success in an ACL <option>recipients</option>
17466 condition. It contains the data from the lookup, and the value remains set
17467 until the next <option>recipients</option> test. Thus, you can do things like this:
17468 </para>
17469 <literallayout>
17470 <literal>require recipients  = cdb*@;/some/file</literal>
17471 <literal>deny    </literal><emphasis>some further test involving</emphasis> <literal>$recipient_data</literal>
17472 </literallayout>
17473 <para>
17474 <emphasis role="bold">Warning</emphasis>: This variable is set only when a lookup is used as an indexing
17475 method in the address list, using the semicolon syntax as in the example above.
17476 The variable is not set for a lookup that is used as part of the string
17477 expansion that all such lists undergo before being interpreted.
17478 </para>
17479 </listitem></varlistentry>
17480 <varlistentry>
17481 <term><varname>$recipient_verify_failure</varname></term>
17482 <listitem>
17483 <para>
17484 <indexterm role="variable">
17485 <primary><varname>$recipient_verify_failure</varname></primary>
17486 </indexterm>
17487 In an ACL, when a recipient verification fails, this variable contains
17488 information about the failure. It is set to one of the following words:
17489 </para>
17490 <itemizedlist>
17491 <listitem>
17492 <para>
17493 <quote>qualify</quote>: The address was unqualified (no domain), and the message
17494 was neither local nor came from an exempted host.
17495 </para>
17496 </listitem>
17497 <listitem>
17498 <para>
17499 <quote>route</quote>: Routing failed.
17500 </para>
17501 </listitem>
17502 <listitem>
17503 <para>
17504 <quote>mail</quote>: Routing succeeded, and a callout was attempted; rejection occurred at
17505 or before the MAIL command (that is, on initial connection, HELO, or
17506 MAIL).
17507 </para>
17508 </listitem>
17509 <listitem>
17510 <para>
17511 <quote>recipient</quote>: The RCPT command in a callout was rejected.
17512 </para>
17513 </listitem>
17514 <listitem>
17515 <para>
17516 <quote>postmaster</quote>: The postmaster check in a callout was rejected.
17517 </para>
17518 </listitem>
17519 </itemizedlist>
17520 <para>
17521 The main use of this variable is expected to be to distinguish between
17522 rejections of MAIL and rejections of RCPT.
17523 </para>
17524 </listitem></varlistentry>
17525 <varlistentry>
17526 <term><varname>$recipients</varname></term>
17527 <listitem>
17528 <para>
17529 <indexterm role="variable">
17530 <primary><varname>$recipients</varname></primary>
17531 </indexterm>
17532 This variable contains a list of envelope recipients for a message. A comma and
17533 a space separate the addresses in the replacement text. However, the variable
17534 is not generally available, to prevent exposure of Bcc recipients in
17535 unprivileged users&#x2019; filter files. You can use <varname>$recipients</varname> only in these
17536 cases:
17537 </para>
17538 <orderedlist numeration="arabic">
17539 <listitem>
17540 <para>
17541 In a system filter file.
17542 </para>
17543 </listitem>
17544 <listitem>
17545 <para>
17546 In the ACLs associated with the DATA command and with non-SMTP messages, that
17547 is, the ACLs defined by <option>acl_smtp_predata</option>, <option>acl_smtp_data</option>,
17548 <option>acl_smtp_mime</option>, <option>acl_not_smtp_start</option>, <option>acl_not_smtp</option>, and
17549 <option>acl_not_smtp_mime</option>.
17550 </para>
17551 </listitem>
17552 <listitem>
17553 <para>
17554 From within a <function>local_scan()</function> function.
17555 </para>
17556 </listitem>
17557 </orderedlist>
17558 </listitem></varlistentry>
17559 <varlistentry>
17560 <term><varname>$recipients_count</varname></term>
17561 <listitem>
17562 <para>
17563 <indexterm role="variable">
17564 <primary><varname>$recipients_count</varname></primary>
17565 </indexterm>
17566 When a message is being processed, this variable contains the number of
17567 envelope recipients that came with the message. Duplicates are not excluded
17568 from the count. While a message is being received over SMTP, the number
17569 increases for each accepted recipient. It can be referenced in an ACL.
17570 </para>
17571 </listitem></varlistentry>
17572 <varlistentry>
17573 <term><varname>$regex_match_string</varname></term>
17574 <listitem>
17575 <para>
17576 <indexterm role="variable">
17577 <primary><varname>$regex_match_string</varname></primary>
17578 </indexterm>
17579 This variable is set to contain the matching regular expression after a
17580 <option>regex</option> ACL condition has matched (see section <xref linkend="SECTscanregex"/>).
17581 </para>
17582 </listitem></varlistentry>
17583 <varlistentry>
17584 <term><varname>$reply_address</varname></term>
17585 <listitem>
17586 <para>
17587 <indexterm role="variable">
17588 <primary><varname>$reply_address</varname></primary>
17589 </indexterm>
17590 When a message is being processed, this variable contains the contents of the
17591 <emphasis>Reply-To:</emphasis> header line if one exists and it is not empty, or otherwise the
17592 contents of the <emphasis>From:</emphasis> header line. Apart from the removal of leading
17593 white space, the value is not processed in any way. In particular, no RFC 2047
17594 decoding or character code translation takes place.
17595 </para>
17596 </listitem></varlistentry>
17597 <varlistentry>
17598 <term><varname>$return_path</varname></term>
17599 <listitem>
17600 <para>
17601 <indexterm role="variable">
17602 <primary><varname>$return_path</varname></primary>
17603 </indexterm>
17604 When a message is being delivered, this variable contains the return path &ndash;
17605 the sender field that will be sent as part of the envelope. It is not enclosed
17606 in &lt;&gt; characters. At the start of routing an address, <varname>$return_path</varname> has the
17607 same value as <varname>$sender_address</varname>, but if, for example, an incoming message to a
17608 mailing list has been expanded by a router which specifies a different address
17609 for bounce messages, <varname>$return_path</varname> subsequently contains the new bounce
17610 address, whereas <varname>$sender_address</varname> always contains the original sender address
17611 that was received with the message. In other words, <varname>$sender_address</varname> contains
17612 the incoming envelope sender, and <varname>$return_path</varname> contains the outgoing
17613 envelope sender.
17614 </para>
17615 </listitem></varlistentry>
17616 <varlistentry>
17617 <term><varname>$return_size_limit</varname></term>
17618 <listitem>
17619 <para>
17620 <indexterm role="variable">
17621 <primary><varname>$return_size_limit</varname></primary>
17622 </indexterm>
17623 This is an obsolete name for <varname>$bounce_return_size_limit</varname>.
17624 </para>
17625 </listitem></varlistentry>
17626 <varlistentry>
17627 <term><varname>$runrc</varname></term>
17628 <listitem>
17629 <para>
17630 <indexterm role="concept">
17631 <primary>return code</primary>
17632 <secondary>from <option>run</option> expansion</secondary>
17633 </indexterm>
17634 <indexterm role="variable">
17635 <primary><varname>$runrc</varname></primary>
17636 </indexterm>
17637 This variable contains the return code from a command that is run by the
17638 <option>${run...}</option> expansion item. <emphasis role="bold">Warning</emphasis>: In a router or transport, you cannot
17639 assume the order in which option values are expanded, except for those
17640 preconditions whose order of testing is documented. Therefore, you cannot
17641 reliably expect to set <varname>$runrc</varname> by the expansion of one option, and use it in
17642 another.
17643 </para>
17644 </listitem></varlistentry>
17645 <varlistentry>
17646 <term><varname>$self_hostname</varname></term>
17647 <listitem>
17648 <para>
17649 <indexterm role="option">
17650 <primary><option>self</option></primary>
17651 <secondary>value of host name</secondary>
17652 </indexterm>
17653 <indexterm role="variable">
17654 <primary><varname>$self_hostname</varname></primary>
17655 </indexterm>
17656 When an address is routed to a supposedly remote host that turns out to be the
17657 local host, what happens is controlled by the <option>self</option> generic router option.
17658 One of its values causes the address to be passed to another router. When this
17659 happens, <varname>$self_hostname</varname> is set to the name of the local host that the
17660 original router encountered. In other circumstances its contents are null.
17661 </para>
17662 </listitem></varlistentry>
17663 <varlistentry>
17664 <term><varname>$sender_address</varname></term>
17665 <listitem>
17666 <para>
17667 <indexterm role="variable">
17668 <primary><varname>$sender_address</varname></primary>
17669 </indexterm>
17670 When a message is being processed, this variable contains the sender&#x2019;s address
17671 that was received in the message&#x2019;s envelope. The case of letters in the address
17672 is retained, in both the local part and the domain. For bounce messages, the
17673 value of this variable is the empty string. See also <varname>$return_path</varname>.
17674 </para>
17675 </listitem></varlistentry>
17676 <varlistentry>
17677 <term><varname>$sender_address_data</varname></term>
17678 <listitem>
17679 <para>
17680 <indexterm role="variable">
17681 <primary><varname>$address_data</varname></primary>
17682 </indexterm>
17683 <indexterm role="variable">
17684 <primary><varname>$sender_address_data</varname></primary>
17685 </indexterm>
17686 If <varname>$address_data</varname> is set when the routers are called from an ACL to verify a
17687 sender address, the final value is preserved in <varname>$sender_address_data</varname>, to
17688 distinguish it from data from a recipient address. The value does not persist
17689 after the end of the current ACL statement. If you want to preserve it for
17690 longer, you can save it in an ACL variable.
17691 </para>
17692 </listitem></varlistentry>
17693 <varlistentry>
17694 <term><varname>$sender_address_domain</varname></term>
17695 <listitem>
17696 <para>
17697 <indexterm role="variable">
17698 <primary><varname>$sender_address_domain</varname></primary>
17699 </indexterm>
17700 The domain portion of <varname>$sender_address</varname>.
17701 </para>
17702 </listitem></varlistentry>
17703 <varlistentry>
17704 <term><varname>$sender_address_local_part</varname></term>
17705 <listitem>
17706 <para>
17707 <indexterm role="variable">
17708 <primary><varname>$sender_address_local_part</varname></primary>
17709 </indexterm>
17710 The local part portion of <varname>$sender_address</varname>.
17711 </para>
17712 </listitem></varlistentry>
17713 <varlistentry>
17714 <term><varname>$sender_data</varname></term>
17715 <listitem>
17716 <para>
17717 <indexterm role="variable">
17718 <primary><varname>$sender_data</varname></primary>
17719 </indexterm>
17720 This variable is set after a lookup success in an ACL <option>senders</option> condition or
17721 in a router <option>senders</option> option. It contains the data from the lookup, and the
17722 value remains set until the next <option>senders</option> test. Thus, you can do things like
17723 this:
17724 </para>
17725 <literallayout>
17726 <literal>require senders      = cdb*@;/some/file</literal>
17727 <literal>deny    </literal><emphasis>some further test involving</emphasis> <literal>$sender_data</literal>
17728 </literallayout>
17729 <para>
17730 <emphasis role="bold">Warning</emphasis>: This variable is set only when a lookup is used as an indexing
17731 method in the address list, using the semicolon syntax as in the example above.
17732 The variable is not set for a lookup that is used as part of the string
17733 expansion that all such lists undergo before being interpreted.
17734 </para>
17735 </listitem></varlistentry>
17736 <varlistentry>
17737 <term><varname>$sender_fullhost</varname></term>
17738 <listitem>
17739 <para>
17740 <indexterm role="variable">
17741 <primary><varname>$sender_fullhost</varname></primary>
17742 </indexterm>
17743 When a message is received from a remote host, this variable contains the host
17744 name and IP address in a single string. It ends with the IP address in square
17745 brackets, followed by a colon and a port number if the logging of ports is
17746 enabled. The format of the rest of the string depends on whether the host
17747 issued a HELO or EHLO SMTP command, and whether the host name was verified by
17748 looking up its IP address. (Looking up the IP address can be forced by the
17749 <option>host_lookup</option> option, independent of verification.) A plain host name at the
17750 start of the string is a verified host name; if this is not present,
17751 verification either failed or was not requested. A host name in parentheses is
17752 the argument of a HELO or EHLO command. This is omitted if it is identical to
17753 the verified host name or to the host&#x2019;s IP address in square brackets.
17754 </para>
17755 </listitem></varlistentry>
17756 <varlistentry>
17757 <term><varname>$sender_helo_name</varname></term>
17758 <listitem>
17759 <para>
17760 <indexterm role="variable">
17761 <primary><varname>$sender_helo_name</varname></primary>
17762 </indexterm>
17763 When a message is received from a remote host that has issued a HELO or EHLO
17764 command, the argument of that command is placed in this variable. It is also
17765 set if HELO or EHLO is used when a message is received using SMTP locally via
17766 the <option>-bs</option> or <option>-bS</option> options.
17767 </para>
17768 </listitem></varlistentry>
17769 <varlistentry>
17770 <term><varname>$sender_host_address</varname></term>
17771 <listitem>
17772 <para>
17773 <indexterm role="variable">
17774 <primary><varname>$sender_host_address</varname></primary>
17775 </indexterm>
17776 When a message is received from a remote host, this variable contains that
17777 host&#x2019;s IP address. For locally submitted messages, it is empty.
17778 </para>
17779 </listitem></varlistentry>
17780 <varlistentry>
17781 <term><varname>$sender_host_authenticated</varname></term>
17782 <listitem>
17783 <para>
17784 <indexterm role="variable">
17785 <primary><varname>$sender_host_authenticated</varname></primary>
17786 </indexterm>
17787 This variable contains the name (not the public name) of the authenticator
17788 driver that successfully authenticated the client from which the message was
17789 received. It is empty if there was no successful authentication. See also
17790 <varname>$authenticated_id</varname>.
17791 </para>
17792 </listitem></varlistentry>
17793 <varlistentry>
17794 <term><varname>$sender_host_name</varname></term>
17795 <listitem>
17796 <para>
17797 <indexterm role="variable">
17798 <primary><varname>$sender_host_name</varname></primary>
17799 </indexterm>
17800 When a message is received from a remote host, this variable contains the
17801 host&#x2019;s name as obtained by looking up its IP address. For messages received by
17802 other means, this variable is empty.
17803 </para>
17804 <para>
17805 <indexterm role="variable">
17806 <primary><varname>$host_lookup_failed</varname></primary>
17807 </indexterm>
17808 If the host name has not previously been looked up, a reference to
17809 <varname>$sender_host_name</varname> triggers a lookup (for messages from remote hosts).
17810 A looked up name is accepted only if it leads back to the original IP address
17811 via a forward lookup. If either the reverse or the forward lookup fails to find
17812 any data, or if the forward lookup does not yield the original IP address,
17813 <varname>$sender_host_name</varname> remains empty, and <varname>$host_lookup_failed</varname> is set to <quote>1</quote>.
17814 </para>
17815 <para>
17816 <indexterm role="variable">
17817 <primary><varname>$host_lookup_deferred</varname></primary>
17818 </indexterm>
17819 However, if either of the lookups cannot be completed (for example, there is a
17820 DNS timeout), <varname>$host_lookup_deferred</varname> is set to <quote>1</quote>, and
17821 <varname>$host_lookup_failed</varname> remains set to <quote>0</quote>.
17822 </para>
17823 <para>
17824 Once <varname>$host_lookup_failed</varname> is set to <quote>1</quote>, Exim does not try to look up the
17825 host name again if there is a subsequent reference to <varname>$sender_host_name</varname>
17826 in the same Exim process, but it does try again if <varname>$host_lookup_deferred</varname>
17827 is set to <quote>1</quote>.
17828 </para>
17829 <para>
17830 Exim does not automatically look up every calling host&#x2019;s name. If you want
17831 maximum efficiency, you should arrange your configuration so that it avoids
17832 these lookups altogether. The lookup happens only if one or more of the
17833 following are true:
17834 </para>
17835 <itemizedlist>
17836 <listitem>
17837 <para>
17838 A string containing <varname>$sender_host_name</varname> is expanded.
17839 </para>
17840 </listitem>
17841 <listitem>
17842 <para>
17843 The calling host matches the list in <option>host_lookup</option>. In the default
17844 configuration, this option is set to *, so it must be changed if lookups are
17845 to be avoided. (In the code, the default for <option>host_lookup</option> is unset.)
17846 </para>
17847 </listitem>
17848 <listitem>
17849 <para>
17850 Exim needs the host name in order to test an item in a host list. The items
17851 that require this are described in sections <xref linkend="SECThoslispatnam"/> and
17852 <xref linkend="SECThoslispatnamsk"/>.
17853 </para>
17854 </listitem>
17855 <listitem>
17856 <para>
17857 The calling host matches <option>helo_try_verify_hosts</option> or <option>helo_verify_hosts</option>.
17858 In this case, the host name is required to compare with the name quoted in any
17859 EHLO or HELO commands that the client issues.
17860 </para>
17861 </listitem>
17862 <listitem>
17863 <para>
17864 The remote host issues a EHLO or HELO command that quotes one of the
17865 domains in <option>helo_lookup_domains</option>. The default value of this option is
17866 </para>
17867 <literallayout class="monospaced">
17868   helo_lookup_domains = @ : @[]
17869 </literallayout>
17870 <para>
17871 which causes a lookup if a remote host (incorrectly) gives the server&#x2019;s name or
17872 IP address in an EHLO or HELO command.
17873 </para>
17874 </listitem>
17875 </itemizedlist>
17876 </listitem></varlistentry>
17877 <varlistentry>
17878 <term><varname>$sender_host_port</varname></term>
17879 <listitem>
17880 <para>
17881 <indexterm role="variable">
17882 <primary><varname>$sender_host_port</varname></primary>
17883 </indexterm>
17884 When a message is received from a remote host, this variable contains the port
17885 number that was used on the remote host.
17886 </para>
17887 </listitem></varlistentry>
17888 <varlistentry>
17889 <term><varname>$sender_ident</varname></term>
17890 <listitem>
17891 <para>
17892 <indexterm role="variable">
17893 <primary><varname>$sender_ident</varname></primary>
17894 </indexterm>
17895 When a message is received from a remote host, this variable contains the
17896 identification received in response to an RFC 1413 request. When a message has
17897 been received locally, this variable contains the login name of the user that
17898 called Exim.
17899 </para>
17900 </listitem></varlistentry>
17901 <varlistentry>
17902 <term><varname>$sender_rate_</varname><emphasis>xxx</emphasis></term>
17903 <listitem>
17904 <para>
17905 A number of variables whose names begin <varname>$sender_rate_</varname> are set as part of the
17906 <option>ratelimit</option> ACL condition. Details are given in section
17907 <xref linkend="SECTratelimiting"/>.
17908 </para>
17909 </listitem></varlistentry>
17910 <varlistentry>
17911 <term><varname>$sender_rcvhost</varname></term>
17912 <listitem>
17913 <para>
17914 <indexterm role="concept">
17915 <primary>DNS</primary>
17916 <secondary>reverse lookup</secondary>
17917 </indexterm>
17918 <indexterm role="concept">
17919 <primary>reverse DNS lookup</primary>
17920 </indexterm>
17921 <indexterm role="variable">
17922 <primary><varname>$sender_rcvhost</varname></primary>
17923 </indexterm>
17924 This is provided specifically for use in <emphasis>Received:</emphasis> headers. It starts with
17925 either the verified host name (as obtained from a reverse DNS lookup) or, if
17926 there is no verified host name, the IP address in square brackets. After that
17927 there may be text in parentheses. When the first item is a verified host name,
17928 the first thing in the parentheses is the IP address in square brackets,
17929 followed by a colon and a port number if port logging is enabled. When the
17930 first item is an IP address, the port is recorded as <quote>port=<emphasis>xxxx</emphasis></quote> inside
17931 the parentheses.
17932 </para>
17933 <para>
17934 There may also be items of the form <quote>helo=<emphasis>xxxx</emphasis></quote> if HELO or EHLO
17935 was used and its argument was not identical to the real host name or IP
17936 address, and <quote>ident=<emphasis>xxxx</emphasis></quote> if an RFC 1413 ident string is available. If
17937 all three items are present in the parentheses, a newline and tab are inserted
17938 into the string, to improve the formatting of the <emphasis>Received:</emphasis> header.
17939 </para>
17940 </listitem></varlistentry>
17941 <varlistentry>
17942 <term><varname>$sender_verify_failure</varname></term>
17943 <listitem>
17944 <para>
17945 <indexterm role="variable">
17946 <primary><varname>$sender_verify_failure</varname></primary>
17947 </indexterm>
17948 In an ACL, when a sender verification fails, this variable contains information
17949 about the failure. The details are the same as for
17950 <varname>$recipient_verify_failure</varname>.
17951 </para>
17952 </listitem></varlistentry>
17953 <varlistentry>
17954 <term><varname>$sending_ip_address</varname></term>
17955 <listitem>
17956 <para>
17957 <indexterm role="variable">
17958 <primary><varname>$sending_ip_address</varname></primary>
17959 </indexterm>
17960 This variable is set whenever an outgoing SMTP connection to another host has
17961 been set up. It contains the IP address of the local interface that is being
17962 used. This is useful if a host that has more than one IP address wants to take
17963 on different personalities depending on which one is being used. For incoming
17964 connections, see <varname>$received_ip_address</varname>.
17965 </para>
17966 </listitem></varlistentry>
17967 <varlistentry>
17968 <term><varname>$sending_port</varname></term>
17969 <listitem>
17970 <para>
17971 <indexterm role="variable">
17972 <primary><varname>$sending_port</varname></primary>
17973 </indexterm>
17974 This variable is set whenever an outgoing SMTP connection to another host has
17975 been set up. It contains the local port that is being used. For incoming
17976 connections, see <varname>$received_port</varname>.
17977 </para>
17978 </listitem></varlistentry>
17979 <varlistentry>
17980 <term><varname>$smtp_active_hostname</varname></term>
17981 <listitem>
17982 <para>
17983 <indexterm role="variable">
17984 <primary><varname>$smtp_active_hostname</varname></primary>
17985 </indexterm>
17986 During an incoming SMTP session, this variable contains the value of the active
17987 host name, as specified by the <option>smtp_active_hostname</option> option. The value of
17988 <varname>$smtp_active_hostname</varname> is saved with any message that is received, so its
17989 value can be consulted during routing and delivery.
17990 </para>
17991 </listitem></varlistentry>
17992 <varlistentry>
17993 <term><varname>$smtp_command</varname></term>
17994 <listitem>
17995 <para>
17996 <indexterm role="variable">
17997 <primary><varname>$smtp_command</varname></primary>
17998 </indexterm>
17999 During the processing of an incoming SMTP command, this variable contains the
18000 entire command. This makes it possible to distinguish between HELO and EHLO in
18001 the HELO ACL, and also to distinguish between commands such as these:
18002 </para>
18003 <literallayout class="monospaced">
18004 MAIL FROM:&lt;&gt;
18005 MAIL FROM: &lt;&gt;
18006 </literallayout>
18007 <para>
18008 For a MAIL command, extra parameters such as SIZE can be inspected. For a RCPT
18009 command, the address in <varname>$smtp_command</varname> is the original address before any
18010 rewriting, whereas the values in <varname>$local_part</varname> and <varname>$domain</varname> are taken from
18011 the address after SMTP-time rewriting.
18012 </para>
18013 </listitem></varlistentry>
18014 <varlistentry>
18015 <term><varname>$smtp_command_argument</varname></term>
18016 <listitem>
18017 <para>
18018 <indexterm role="concept">
18019 <primary>SMTP</primary>
18020 <secondary>command, argument for</secondary>
18021 </indexterm>
18022 <indexterm role="variable">
18023 <primary><varname>$smtp_command_argument</varname></primary>
18024 </indexterm>
18025 While an ACL is running to check an SMTP command, this variable contains the
18026 argument, that is, the text that follows the command name, with leading white
18027 space removed. Following the introduction of <varname>$smtp_command</varname>, this variable is
18028 somewhat redundant, but is retained for backwards compatibility.
18029 </para>
18030 </listitem></varlistentry>
18031 <varlistentry>
18032 <term><varname>$smtp_count_at_connection_start</varname></term>
18033 <listitem>
18034 <para>
18035 <indexterm role="variable">
18036 <primary><varname>$smtp_count_at_connection_start</varname></primary>
18037 </indexterm>
18038 This variable is set greater than zero only in processes spawned by the Exim
18039 daemon for handling incoming SMTP connections. The name is deliberately long,
18040 in order to emphasize what the contents are. When the daemon accepts a new
18041 connection, it increments this variable. A copy of the variable is passed to
18042 the child process that handles the connection, but its value is fixed, and
18043 never changes. It is only an approximation of how many incoming connections
18044 there actually are, because many other connections may come and go while a
18045 single connection is being processed. When a child process terminates, the
18046 daemon decrements its copy of the variable.
18047 </para>
18048 </listitem></varlistentry>
18049 <varlistentry>
18050 <term><varname>$sn0</varname> &ndash; <varname>$sn9</varname></term>
18051 <listitem>
18052 <para>
18053 These variables are copies of the values of the <varname>$n0</varname> &ndash; <varname>$n9</varname> accumulators
18054 that were current at the end of the system filter file. This allows a system
18055 filter file to set values that can be tested in users&#x2019; filter files. For
18056 example, a system filter could set a value indicating how likely it is that a
18057 message is junk mail.
18058 </para>
18059 </listitem></varlistentry>
18060 <varlistentry>
18061 <term><varname>$spam_</varname><emphasis>xxx</emphasis></term>
18062 <listitem>
18063 <para>
18064 A number of variables whose names start with <varname>$spam</varname> are available when Exim
18065 is compiled with the content-scanning extension. For details, see section
18066 <xref linkend="SECTscanspamass"/>.
18067 </para>
18068 </listitem></varlistentry>
18069 <varlistentry>
18070 <term><varname>$spool_directory</varname></term>
18071 <listitem>
18072 <para>
18073 <indexterm role="variable">
18074 <primary><varname>$spool_directory</varname></primary>
18075 </indexterm>
18076 The name of Exim&#x2019;s spool directory.
18077 </para>
18078 </listitem></varlistentry>
18079 <varlistentry>
18080 <term><varname>$spool_inodes</varname></term>
18081 <listitem>
18082 <para>
18083 <indexterm role="variable">
18084 <primary><varname>$spool_inodes</varname></primary>
18085 </indexterm>
18086 The number of free inodes in the disk partition where Exim&#x2019;s spool files are
18087 being written. The value is recalculated whenever the variable is referenced.
18088 If the relevant file system does not have the concept of inodes, the value of
18089 is -1. See also the <option>check_spool_inodes</option> option.
18090 </para>
18091 </listitem></varlistentry>
18092 <varlistentry>
18093 <term><varname>$spool_space</varname></term>
18094 <listitem>
18095 <para>
18096 <indexterm role="variable">
18097 <primary><varname>$spool_space</varname></primary>
18098 </indexterm>
18099 The amount of free space (as a number of kilobytes) in the disk partition where
18100 Exim&#x2019;s spool files are being written. The value is recalculated whenever the
18101 variable is referenced. If the operating system does not have the ability to
18102 find the amount of free space (only true for experimental systems), the space
18103 value is -1. For example, to check in an ACL that there is at least 50
18104 megabytes free on the spool, you could write:
18105 </para>
18106 <literallayout class="monospaced">
18107 condition = ${if &gt; {$spool_space}{50000}}
18108 </literallayout>
18109 <para>
18110 See also the <option>check_spool_space</option> option.
18111 </para>
18112 </listitem></varlistentry>
18113 <varlistentry>
18114 <term><varname>$thisaddress</varname></term>
18115 <listitem>
18116 <para>
18117 <indexterm role="variable">
18118 <primary><varname>$thisaddress</varname></primary>
18119 </indexterm>
18120 This variable is set only during the processing of the <option>foranyaddress</option>
18121 command in a filter file. Its use is explained in the description of that
18122 command, which can be found in the separate document entitled <emphasis>Exim&#x2019;s
18123 interfaces to mail filtering</emphasis>.
18124 </para>
18125 </listitem></varlistentry>
18126 <varlistentry>
18127 <term><varname>$tls_certificate_verified</varname></term>
18128 <listitem>
18129 <para>
18130 <indexterm role="variable">
18131 <primary><varname>$tls_certificate_verified</varname></primary>
18132 </indexterm>
18133 This variable is set to <quote>1</quote> if a TLS certificate was verified when the
18134 message was received, and <quote>0</quote> otherwise.
18135 </para>
18136 </listitem></varlistentry>
18137 <varlistentry>
18138 <term><varname>$tls_cipher</varname></term>
18139 <listitem>
18140 <para>
18141 <indexterm role="variable">
18142 <primary><varname>$tls_cipher</varname></primary>
18143 </indexterm>
18144 When a message is received from a remote host over an encrypted SMTP
18145 connection, this variable is set to the cipher suite that was negotiated, for
18146 example DES-CBC3-SHA. In other circumstances, in particular, for message
18147 received over unencrypted connections, the variable is empty. Testing
18148 <varname>$tls_cipher</varname> for emptiness is one way of distinguishing between encrypted and
18149 non-encrypted connections during ACL processing.
18150 </para>
18151 <para>
18152 The <varname>$tls_cipher</varname> variable retains its value during message delivery, except
18153 when an outward SMTP delivery takes place via the <command>smtp</command> transport. In this
18154 case, <varname>$tls_cipher</varname> is cleared before any outgoing SMTP connection is made,
18155 and then set to the outgoing cipher suite if one is negotiated. See chapter
18156 <xref linkend="CHAPTLS"/> for details of TLS support and chapter <xref linkend="CHAPsmtptrans"/> for
18157 details of the <command>smtp</command> transport.
18158 </para>
18159 </listitem></varlistentry>
18160 <varlistentry>
18161 <term><varname>$tls_peerdn</varname></term>
18162 <listitem>
18163 <para>
18164 <indexterm role="variable">
18165 <primary><varname>$tls_peerdn</varname></primary>
18166 </indexterm>
18167 When a message is received from a remote host over an encrypted SMTP
18168 connection, and Exim is configured to request a certificate from the client,
18169 the value of the Distinguished Name of the certificate is made available in the
18170 <varname>$tls_peerdn</varname> during subsequent processing. Like <varname>$tls_cipher</varname>, the
18171 value is retained during message delivery, except during outbound SMTP
18172 deliveries.
18173 </para>
18174 </listitem></varlistentry>
18175 <varlistentry>
18176 <term><varname>$tod_bsdinbox</varname></term>
18177 <listitem>
18178 <para>
18179 <indexterm role="variable">
18180 <primary><varname>$tod_bsdinbox</varname></primary>
18181 </indexterm>
18182 The time of day and the date, in the format required for BSD-style mailbox
18183 files, for example: Thu Oct 17 17:14:09 1995.
18184 </para>
18185 </listitem></varlistentry>
18186 <varlistentry>
18187 <term><varname>$tod_epoch</varname></term>
18188 <listitem>
18189 <para>
18190 <indexterm role="variable">
18191 <primary><varname>$tod_epoch</varname></primary>
18192 </indexterm>
18193 The time and date as a number of seconds since the start of the Unix epoch.
18194 </para>
18195 </listitem></varlistentry>
18196 <varlistentry>
18197 <term><varname>$tod_full</varname></term>
18198 <listitem>
18199 <para>
18200 <indexterm role="variable">
18201 <primary><varname>$tod_full</varname></primary>
18202 </indexterm>
18203 A full version of the time and date, for example: Wed, 16 Oct 1995 09:51:40
18204 +0100. The timezone is always given as a numerical offset from UTC, with
18205 positive values used for timezones that are ahead (east) of UTC, and negative
18206 values for those that are behind (west).
18207 </para>
18208 </listitem></varlistentry>
18209 <varlistentry>
18210 <term><varname>$tod_log</varname></term>
18211 <listitem>
18212 <para>
18213 <indexterm role="variable">
18214 <primary><varname>$tod_log</varname></primary>
18215 </indexterm>
18216 The time and date in the format used for writing Exim&#x2019;s log files, for example:
18217 1995-10-12 15:32:29, but without a timezone.
18218 </para>
18219 </listitem></varlistentry>
18220 <varlistentry>
18221 <term><varname>$tod_logfile</varname></term>
18222 <listitem>
18223 <para>
18224 <indexterm role="variable">
18225 <primary><varname>$tod_logfile</varname></primary>
18226 </indexterm>
18227 This variable contains the date in the format yyyymmdd. This is the format that
18228 is used for datestamping log files when <option>log_file_path</option> contains the <literal>%D</literal>
18229 flag.
18230 </para>
18231 </listitem></varlistentry>
18232 <varlistentry>
18233 <term><varname>$tod_zone</varname></term>
18234 <listitem>
18235 <para>
18236 <indexterm role="variable">
18237 <primary><varname>$tod_zone</varname></primary>
18238 </indexterm>
18239 This variable contains the numerical value of the local timezone, for example:
18240 -0500.
18241 </para>
18242 </listitem></varlistentry>
18243 <varlistentry>
18244 <term><varname>$tod_zulu</varname></term>
18245 <listitem>
18246 <para>
18247 <indexterm role="variable">
18248 <primary><varname>$tod_zulu</varname></primary>
18249 </indexterm>
18250 This variable contains the UTC date and time in <quote>Zulu</quote> format, as specified
18251 by ISO 8601, for example: 20030221154023Z.
18252 </para>
18253 </listitem></varlistentry>
18254 <varlistentry>
18255 <term><varname>$value</varname></term>
18256 <listitem>
18257 <para>
18258 <indexterm role="variable">
18259 <primary><varname>$value</varname></primary>
18260 </indexterm>
18261 This variable contains the result of an expansion lookup, extraction operation,
18262 or external command, as described above. It is also used during a
18263 <emphasis role="bold">reduce</emphasis> expansion.
18264 </para>
18265 </listitem></varlistentry>
18266 <varlistentry>
18267 <term><varname>$version_number</varname></term>
18268 <listitem>
18269 <para>
18270 <indexterm role="variable">
18271 <primary><varname>$version_number</varname></primary>
18272 </indexterm>
18273 The version number of Exim.
18274 </para>
18275 </listitem></varlistentry>
18276 <varlistentry>
18277 <term><varname>$warn_message_delay</varname></term>
18278 <listitem>
18279 <para>
18280 <indexterm role="variable">
18281 <primary><varname>$warn_message_delay</varname></primary>
18282 </indexterm>
18283 This variable is set only during the creation of a message warning about a
18284 delivery delay. Details of its use are explained in section <xref linkend="SECTcustwarn"/>.
18285 </para>
18286 </listitem></varlistentry>
18287 <varlistentry>
18288 <term><varname>$warn_message_recipients</varname></term>
18289 <listitem>
18290 <para>
18291 <indexterm role="variable">
18292 <primary><varname>$warn_message_recipients</varname></primary>
18293 </indexterm>
18294 This variable is set only during the creation of a message warning about a
18295 delivery delay. Details of its use are explained in section <xref linkend="SECTcustwarn"/>.
18296 </para>
18297 </listitem></varlistentry>
18298 </variablelist>
18299 <para>
18300 <indexterm role="concept" startref="IIDstrexp" class="endofrange"/>
18301 </para>
18302 </section>
18303 </chapter>
18304
18305 <chapter id="CHAPperl">
18306 <title>Embedded Perl</title>
18307 <para>
18308 <indexterm role="concept" id="IIDperl" class="startofrange">
18309 <primary>Perl</primary>
18310 <secondary>calling from Exim</secondary>
18311 </indexterm>
18312 Exim can be built to include an embedded Perl interpreter. When this is done,
18313 Perl subroutines can be called as part of the string expansion process. To make
18314 use of the Perl support, you need version 5.004 or later of Perl installed on
18315 your system. To include the embedded interpreter in the Exim binary, include
18316 the line
18317 </para>
18318 <literallayout class="monospaced">
18319 EXIM_PERL = perl.o
18320 </literallayout>
18321 <para>
18322 in your <filename>Local/Makefile</filename> and then build Exim in the normal way.
18323 </para>
18324 <section id="SECID85">
18325 <title>Setting up so Perl can be used</title>
18326 <para>
18327 <indexterm role="option">
18328 <primary><option>perl_startup</option></primary>
18329 </indexterm>
18330 Access to Perl subroutines is via a global configuration option called
18331 <option>perl_startup</option> and an expansion string operator <option>${perl ...}</option>. If there is
18332 no <option>perl_startup</option> option in the Exim configuration file then no Perl
18333 interpreter is started and there is almost no overhead for Exim (since none of
18334 the Perl library will be paged in unless used). If there is a <option>perl_startup</option>
18335 option then the associated value is taken to be Perl code which is executed in
18336 a newly created Perl interpreter.
18337 </para>
18338 <para>
18339 The value of <option>perl_startup</option> is not expanded in the Exim sense, so you do not
18340 need backslashes before any characters to escape special meanings. The option
18341 should usually be something like
18342 </para>
18343 <literallayout class="monospaced">
18344 perl_startup = do '/etc/exim.pl'
18345 </literallayout>
18346 <para>
18347 where <filename>/etc/exim.pl</filename> is Perl code which defines any subroutines you want to
18348 use from Exim. Exim can be configured either to start up a Perl interpreter as
18349 soon as it is entered, or to wait until the first time it is needed. Starting
18350 the interpreter at the beginning ensures that it is done while Exim still has
18351 its setuid privilege, but can impose an unnecessary overhead if Perl is not in
18352 fact used in a particular run. Also, note that this does not mean that Exim is
18353 necessarily running as root when Perl is called at a later time. By default,
18354 the interpreter is started only when it is needed, but this can be changed in
18355 two ways:
18356 </para>
18357 <itemizedlist>
18358 <listitem>
18359 <para>
18360 <indexterm role="option">
18361 <primary><option>perl_at_start</option></primary>
18362 </indexterm>
18363 Setting <option>perl_at_start</option> (a boolean option) in the configuration requests
18364 a startup when Exim is entered.
18365 </para>
18366 </listitem>
18367 <listitem>
18368 <para>
18369 The command line option <option>-ps</option> also requests a startup when Exim is entered,
18370 overriding the setting of <option>perl_at_start</option>.
18371 </para>
18372 </listitem>
18373 </itemizedlist>
18374 <para>
18375 There is also a command line option <option>-pd</option> (for delay) which suppresses the
18376 initial startup, even if <option>perl_at_start</option> is set.
18377 </para>
18378 </section>
18379 <section id="SECID86">
18380 <title>Calling Perl subroutines</title>
18381 <para>
18382 When the configuration file includes a <option>perl_startup</option> option you can make use
18383 of the string expansion item to call the Perl subroutines that are defined
18384 by the <option>perl_startup</option> code. The operator is used in any of the following
18385 forms:
18386 </para>
18387 <literallayout class="monospaced">
18388 ${perl{foo}}
18389 ${perl{foo}{argument}}
18390 ${perl{foo}{argument1}{argument2} ... }
18391 </literallayout>
18392 <para>
18393 which calls the subroutine <option>foo</option> with the given arguments. A maximum of eight
18394 arguments may be passed. Passing more than this results in an expansion failure
18395 with an error message of the form
18396 </para>
18397 <literallayout class="monospaced">
18398 Too many arguments passed to Perl subroutine "foo" (max is 8)
18399 </literallayout>
18400 <para>
18401 The return value of the Perl subroutine is evaluated in a scalar context before
18402 it is passed back to Exim to be inserted into the expanded string. If the
18403 return value is <emphasis>undef</emphasis>, the expansion is forced to fail in the same way as
18404 an explicit <quote>fail</quote> on an <option>if</option> or <option>lookup</option> item. If the subroutine aborts
18405 by obeying Perl&#x2019;s <option>die</option> function, the expansion fails with the error message
18406 that was passed to <option>die</option>.
18407 </para>
18408 </section>
18409 <section id="SECID87">
18410 <title>Calling Exim functions from Perl</title>
18411 <para>
18412 Within any Perl code called from Exim, the function <emphasis>Exim::expand_string()</emphasis>
18413 is available to call back into Exim&#x2019;s string expansion function. For example,
18414 the Perl code
18415 </para>
18416 <literallayout class="monospaced">
18417 my $lp = Exim::expand_string('$local_part');
18418 </literallayout>
18419 <para>
18420 makes the current Exim <varname>$local_part</varname> available in the Perl variable <varname>$lp</varname>.
18421 Note those are single quotes and not double quotes to protect against
18422 <varname>$local_part</varname> being interpolated as a Perl variable.
18423 </para>
18424 <para>
18425 If the string expansion is forced to fail by a <quote>fail</quote> item, the result of
18426 <emphasis>Exim::expand_string()</emphasis> is <option>undef</option>. If there is a syntax error in the
18427 expansion string, the Perl call from the original expansion string fails with
18428 an appropriate error message, in the same way as if <option>die</option> were used.
18429 </para>
18430 <para>
18431 <indexterm role="concept">
18432 <primary>debugging</primary>
18433 <secondary>from embedded Perl</secondary>
18434 </indexterm>
18435 <indexterm role="concept">
18436 <primary>log</primary>
18437 <secondary>writing from embedded Perl</secondary>
18438 </indexterm>
18439 Two other Exim functions are available for use from within Perl code.
18440 <emphasis>Exim::debug_write()</emphasis> writes a string to the standard error stream if Exim&#x2019;s
18441 debugging is enabled. If you want a newline at the end, you must supply it.
18442 <emphasis>Exim::log_write()</emphasis> writes a string to Exim&#x2019;s main log, adding a leading
18443 timestamp. In this case, you should not supply a terminating newline.
18444 </para>
18445 </section>
18446 <section id="SECID88">
18447 <title>Use of standard output and error by Perl</title>
18448 <para>
18449 <indexterm role="concept">
18450 <primary>Perl</primary>
18451 <secondary>standard output and error</secondary>
18452 </indexterm>
18453 You should not write to the standard error or output streams from within your
18454 Perl code, as it is not defined how these are set up. In versions of Exim
18455 before 4.50, it is possible for the standard output or error to refer to the
18456 SMTP connection during message reception via the daemon. Writing to this stream
18457 is certain to cause chaos. From Exim 4.50 onwards, the standard output and
18458 error streams are connected to <filename>/dev/null</filename> in the daemon. The chaos is
18459 avoided, but the output is lost.
18460 </para>
18461 <para>
18462 <indexterm role="concept">
18463 <primary>Perl</primary>
18464 <secondary>use of <option>warn</option></secondary>
18465 </indexterm>
18466 The Perl <option>warn</option> statement writes to the standard error stream by default.
18467 Calls to <option>warn</option> may be embedded in Perl modules that you use, but over which
18468 you have no control. When Exim starts up the Perl interpreter, it arranges for
18469 output from the <option>warn</option> statement to be written to the Exim main log. You can
18470 change this by including appropriate Perl magic somewhere in your Perl code.
18471 For example, to discard <option>warn</option> output completely, you need this:
18472 </para>
18473 <literallayout class="monospaced">
18474 $SIG{__WARN__} = sub { };
18475 </literallayout>
18476 <para>
18477 Whenever a <option>warn</option> is obeyed, the anonymous subroutine is called. In this
18478 example, the code for the subroutine is empty, so it does nothing, but you can
18479 include any Perl code that you like. The text of the <option>warn</option> message is passed
18480 as the first subroutine argument.
18481 <indexterm role="concept" startref="IIDperl" class="endofrange"/>
18482 </para>
18483 </section>
18484 </chapter>
18485
18486 <chapter id="CHAPinterfaces">
18487 <title>Starting the daemon and the use of network interfaces</title>
18488 <titleabbrev>Starting the daemon</titleabbrev>
18489 <para>
18490 <indexterm role="concept">
18491 <primary>daemon</primary>
18492 <secondary>starting</secondary>
18493 </indexterm>
18494 <indexterm role="concept">
18495 <primary>interface</primary>
18496 <secondary>listening</secondary>
18497 </indexterm>
18498 <indexterm role="concept">
18499 <primary>network interface</primary>
18500 </indexterm>
18501 <indexterm role="concept">
18502 <primary>interface</primary>
18503 <secondary>network</secondary>
18504 </indexterm>
18505 <indexterm role="concept">
18506 <primary>IP address</primary>
18507 <secondary>for listening</secondary>
18508 </indexterm>
18509 <indexterm role="concept">
18510 <primary>daemon</primary>
18511 <secondary>listening IP addresses</secondary>
18512 </indexterm>
18513 <indexterm role="concept">
18514 <primary>TCP/IP</primary>
18515 <secondary>setting listening interfaces</secondary>
18516 </indexterm>
18517 <indexterm role="concept">
18518 <primary>TCP/IP</primary>
18519 <secondary>setting listening ports</secondary>
18520 </indexterm>
18521 A host that is connected to a TCP/IP network may have one or more physical
18522 hardware network interfaces. Each of these interfaces may be configured as one
18523 or more <quote>logical</quote> interfaces, which are the entities that a program actually
18524 works with. Each of these logical interfaces is associated with an IP address.
18525 In addition, TCP/IP software supports <quote>loopback</quote> interfaces (127.0.0.1 in
18526 IPv4 and ::1 in IPv6), which do not use any physical hardware. Exim requires
18527 knowledge about the host&#x2019;s interfaces for use in three different circumstances:
18528 </para>
18529 <orderedlist numeration="arabic">
18530 <listitem>
18531 <para>
18532 When a listening daemon is started, Exim needs to know which interfaces
18533 and ports to listen on.
18534 </para>
18535 </listitem>
18536 <listitem>
18537 <para>
18538 When Exim is routing an address, it needs to know which IP addresses
18539 are associated with local interfaces. This is required for the correct
18540 processing of MX lists by removing the local host and others with the
18541 same or higher priority values. Also, Exim needs to detect cases
18542 when an address is routed to an IP address that in fact belongs to the
18543 local host. Unless the <option>self</option> router option or the <option>allow_localhost</option>
18544 option of the smtp transport is set (as appropriate), this is treated
18545 as an error situation.
18546 </para>
18547 </listitem>
18548 <listitem>
18549 <para>
18550 When Exim connects to a remote host, it may need to know which interface to use
18551 for the outgoing connection.
18552 </para>
18553 </listitem>
18554 </orderedlist>
18555 <para>
18556 Exim&#x2019;s default behaviour is likely to be appropriate in the vast majority
18557 of cases. If your host has only one interface, and you want all its IP
18558 addresses to be treated in the same way, and you are using only the
18559 standard SMTP port, you should not need to take any special action. The
18560 rest of this chapter does not apply to you.
18561 </para>
18562 <para>
18563 In a more complicated situation you may want to listen only on certain
18564 interfaces, or on different ports, and for this reason there are a number of
18565 options that can be used to influence Exim&#x2019;s behaviour. The rest of this
18566 chapter describes how they operate.
18567 </para>
18568 <para>
18569 When a message is received over TCP/IP, the interface and port that were
18570 actually used are set in <varname>$received_ip_address</varname> and <varname>$received_port</varname>.
18571 </para>
18572 <section id="SECID89">
18573 <title>Starting a listening daemon</title>
18574 <para>
18575 When a listening daemon is started (by means of the <option>-bd</option> command line
18576 option), the interfaces and ports on which it listens are controlled by the
18577 following options:
18578 </para>
18579 <itemizedlist>
18580 <listitem>
18581 <para>
18582 <option>daemon_smtp_ports</option> contains a list of default ports. (For backward
18583 compatibility, this option can also be specified in the singular.)
18584 </para>
18585 </listitem>
18586 <listitem>
18587 <para>
18588 <option>local_interfaces</option> contains list of interface IP addresses on which to
18589 listen. Each item may optionally also specify a port.
18590 </para>
18591 </listitem>
18592 </itemizedlist>
18593 <para>
18594 The default list separator in both cases is a colon, but this can be changed as
18595 described in section <xref linkend="SECTlistconstruct"/>. When IPv6 addresses are involved,
18596 it is usually best to change the separator to avoid having to double all the
18597 colons. For example:
18598 </para>
18599 <literallayout class="monospaced">
18600 local_interfaces = &lt;; 127.0.0.1 ; \
18601                       192.168.23.65 ; \
18602                       ::1 ; \
18603                       3ffe:ffff:836f::fe86:a061
18604 </literallayout>
18605 <para>
18606 There are two different formats for specifying a port along with an IP address
18607 in <option>local_interfaces</option>:
18608 </para>
18609 <orderedlist numeration="arabic">
18610 <listitem>
18611 <para>
18612 The port is added onto the address with a dot separator. For example, to listen
18613 on port 1234 on two different IP addresses:
18614 </para>
18615 <literallayout class="monospaced">
18616 local_interfaces = &lt;; 192.168.23.65.1234 ; \
18617                       3ffe:ffff:836f::fe86:a061.1234
18618 </literallayout>
18619 </listitem>
18620 <listitem>
18621 <para>
18622 The IP address is enclosed in square brackets, and the port is added
18623 with a colon separator, for example:
18624 </para>
18625 <literallayout class="monospaced">
18626 local_interfaces = &lt;; [192.168.23.65]:1234 ; \
18627                       [3ffe:ffff:836f::fe86:a061]:1234
18628 </literallayout>
18629 </listitem>
18630 </orderedlist>
18631 <para>
18632 When a port is not specified, the value of <option>daemon_smtp_ports</option> is used. The
18633 default setting contains just one port:
18634 </para>
18635 <literallayout class="monospaced">
18636 daemon_smtp_ports = smtp
18637 </literallayout>
18638 <para>
18639 If more than one port is listed, each interface that does not have its own port
18640 specified listens on all of them. Ports that are listed in
18641 <option>daemon_smtp_ports</option> can be identified either by name (defined in
18642 <filename>/etc/services</filename>) or by number. However, when ports are given with individual
18643 IP addresses in <option>local_interfaces</option>, only numbers (not names) can be used.
18644 </para>
18645 </section>
18646 <section id="SECID90">
18647 <title>Special IP listening addresses</title>
18648 <para>
18649 The addresses 0.0.0.0 and ::0 are treated specially. They are interpreted
18650 as <quote>all IPv4 interfaces</quote> and <quote>all IPv6 interfaces</quote>, respectively. In each
18651 case, Exim tells the TCP/IP stack to <quote>listen on all IPv<emphasis>x</emphasis> interfaces</quote>
18652 instead of setting up separate listening sockets for each interface. The
18653 default value of <option>local_interfaces</option> is
18654 </para>
18655 <literallayout class="monospaced">
18656 local_interfaces = 0.0.0.0
18657 </literallayout>
18658 <para>
18659 when Exim is built without IPv6 support; otherwise it is:
18660 </para>
18661 <literallayout class="monospaced">
18662 local_interfaces = &lt;; ::0 ; 0.0.0.0
18663 </literallayout>
18664 <para>
18665 Thus, by default, Exim listens on all available interfaces, on the SMTP port.
18666 </para>
18667 </section>
18668 <section id="SECID91">
18669 <title>Overriding local_interfaces and daemon_smtp_ports</title>
18670 <para>
18671 The <option>-oX</option> command line option can be used to override the values of
18672 <option>daemon_smtp_ports</option> and/or <option>local_interfaces</option> for a particular daemon
18673 instance. Another way of doing this would be to use macros and the <option>-D</option>
18674 option. However, <option>-oX</option> can be used by any admin user, whereas modification of
18675 the runtime configuration by <option>-D</option> is allowed only when the caller is root or
18676 exim.
18677 </para>
18678 <para>
18679 The value of <option>-oX</option> is a list of items. The default colon separator can be
18680 changed in the usual way if required. If there are any items that do not
18681 contain dots or colons (that is, are not IP addresses), the value of
18682 <option>daemon_smtp_ports</option> is replaced by the list of those items. If there are any
18683 items that do contain dots or colons, the value of <option>local_interfaces</option> is
18684 replaced by those items. Thus, for example,
18685 </para>
18686 <literallayout class="monospaced">
18687 -oX 1225
18688 </literallayout>
18689 <para>
18690 overrides <option>daemon_smtp_ports</option>, but leaves <option>local_interfaces</option> unchanged,
18691 whereas
18692 </para>
18693 <literallayout class="monospaced">
18694 -oX 192.168.34.5.1125
18695 </literallayout>
18696 <para>
18697 overrides <option>local_interfaces</option>, leaving <option>daemon_smtp_ports</option> unchanged.
18698 (However, since <option>local_interfaces</option> now contains no items without ports, the
18699 value of <option>daemon_smtp_ports</option> is no longer relevant in this example.)
18700 </para>
18701 </section>
18702 <section id="SECTsupobssmt">
18703 <title>Support for the obsolete SSMTP (or SMTPS) protocol</title>
18704 <para>
18705 <indexterm role="concept">
18706 <primary>ssmtp protocol</primary>
18707 </indexterm>
18708 <indexterm role="concept">
18709 <primary>smtps protocol</primary>
18710 </indexterm>
18711 <indexterm role="concept">
18712 <primary>SMTP</primary>
18713 <secondary>ssmtp protocol</secondary>
18714 </indexterm>
18715 <indexterm role="concept">
18716 <primary>SMTP</primary>
18717 <secondary>smtps protocol</secondary>
18718 </indexterm>
18719 Exim supports the obsolete SSMTP protocol (also known as SMTPS) that was used
18720 before the STARTTLS command was standardized for SMTP. Some legacy clients
18721 still use this protocol. If the <option>tls_on_connect_ports</option> option is set to a
18722 list of port numbers, connections to those ports must use SSMTP. The most
18723 common use of this option is expected to be
18724 </para>
18725 <literallayout class="monospaced">
18726 tls_on_connect_ports = 465
18727 </literallayout>
18728 <para>
18729 because 465 is the usual port number used by the legacy clients. There is also
18730 a command line option <option>-tls-on-connect</option>, which forces all ports to behave in
18731 this way when a daemon is started.
18732 </para>
18733 <para>
18734 <emphasis role="bold">Warning</emphasis>: Setting <option>tls_on_connect_ports</option> does not of itself cause the
18735 daemon to listen on those ports. You must still specify them in
18736 <option>daemon_smtp_ports</option>, <option>local_interfaces</option>, or the <option>-oX</option> option. (This is
18737 because <option>tls_on_connect_ports</option> applies to <option>inetd</option> connections as well as to
18738 connections via the daemon.)
18739 </para>
18740 </section>
18741 <section id="SECID92">
18742 <title>IPv6 address scopes</title>
18743 <para>
18744 <indexterm role="concept">
18745 <primary>IPv6</primary>
18746 <secondary>address scopes</secondary>
18747 </indexterm>
18748 IPv6 addresses have <quote>scopes</quote>, and a host with multiple hardware interfaces
18749 can, in principle, have the same link-local IPv6 address on different
18750 interfaces. Thus, additional information is needed, over and above the IP
18751 address, to distinguish individual interfaces. A convention of using a
18752 percent sign followed by something (often the interface name) has been
18753 adopted in some cases, leading to addresses like this:
18754 </para>
18755 <literallayout class="monospaced">
18756 fe80::202:b3ff:fe03:45c1%eth0
18757 </literallayout>
18758 <para>
18759 To accommodate this usage, a percent sign followed by an arbitrary string is
18760 allowed at the end of an IPv6 address. By default, Exim calls <function>getaddrinfo()</function>
18761 to convert a textual IPv6 address for actual use. This function recognizes the
18762 percent convention in operating systems that support it, and it processes the
18763 address appropriately. Unfortunately, some older libraries have problems with
18764 <function>getaddrinfo()</function>. If
18765 </para>
18766 <literallayout class="monospaced">
18767 IPV6_USE_INET_PTON=yes
18768 </literallayout>
18769 <para>
18770 is set in <filename>Local/Makefile</filename> (or an OS-dependent Makefile) when Exim is built,
18771 Exim uses <emphasis>inet_pton()</emphasis> to convert a textual IPv6 address for actual use,
18772 instead of <function>getaddrinfo()</function>. (Before version 4.14, it always used this
18773 function.) Of course, this means that the additional functionality of
18774 <function>getaddrinfo()</function> &ndash; recognizing scoped addresses &ndash; is lost.
18775 </para>
18776 </section>
18777 <section id="SECID93">
18778 <title>Disabling IPv6</title>
18779 <para>
18780 <indexterm role="concept">
18781 <primary>IPv6</primary>
18782 <secondary>disabling</secondary>
18783 </indexterm>
18784 Sometimes it happens that an Exim binary that was compiled with IPv6 support is
18785 run on a host whose kernel does not support IPv6. The binary will fall back to
18786 using IPv4, but it may waste resources looking up AAAA records, and trying to
18787 connect to IPv6 addresses, causing delays to mail delivery. If you set the
18788 <indexterm role="option">
18789 <primary><option>disable_ipv6</option></primary>
18790 </indexterm>
18791 <option>disable_ipv6</option> option true, even if the Exim binary has IPv6 support, no IPv6
18792 activities take place. AAAA records are never looked up, and any IPv6 addresses
18793 that are listed in <option>local_interfaces</option>, data for the <command>manualroute</command> router,
18794 etc. are ignored. If IP literals are enabled, the <command>ipliteral</command> router declines
18795 to handle IPv6 literal addresses.
18796 </para>
18797 <para>
18798 On the other hand, when IPv6 is in use, there may be times when you want to
18799 disable it for certain hosts or domains. You can use the <option>dns_ipv4_lookup</option>
18800 option to globally suppress the lookup of AAAA records for specified domains,
18801 and you can use the <option>ignore_target_hosts</option> generic router option to ignore
18802 IPv6 addresses in an individual router.
18803 </para>
18804 </section>
18805 <section id="SECID94">
18806 <title>Examples of starting a listening daemon</title>
18807 <para>
18808 The default case in an IPv6 environment is
18809 </para>
18810 <literallayout class="monospaced">
18811 daemon_smtp_ports = smtp
18812 local_interfaces = &lt;; ::0 ; 0.0.0.0
18813 </literallayout>
18814 <para>
18815 This specifies listening on the smtp port on all IPv6 and IPv4 interfaces.
18816 Either one or two sockets may be used, depending on the characteristics of
18817 the TCP/IP stack. (This is complicated and messy; for more information,
18818 read the comments in the <filename>daemon.c</filename> source file.)
18819 </para>
18820 <para>
18821 To specify listening on ports 25 and 26 on all interfaces:
18822 </para>
18823 <literallayout class="monospaced">
18824 daemon_smtp_ports = 25 : 26
18825 </literallayout>
18826 <para>
18827 (leaving <option>local_interfaces</option> at the default setting) or, more explicitly:
18828 </para>
18829 <literallayout class="monospaced">
18830 local_interfaces = &lt;; ::0.25     ; ::0.26 \
18831                       0.0.0.0.25 ; 0.0.0.0.26
18832 </literallayout>
18833 <para>
18834 To listen on the default port on all IPv4 interfaces, and on port 26 on the
18835 IPv4 loopback address only:
18836 </para>
18837 <literallayout class="monospaced">
18838 local_interfaces = 0.0.0.0 : 127.0.0.1.26
18839 </literallayout>
18840 <para>
18841 To specify listening on the default port on specific interfaces only:
18842 </para>
18843 <literallayout class="monospaced">
18844 local_interfaces = 192.168.34.67 : 192.168.34.67
18845 </literallayout>
18846 <para>
18847 <emphasis role="bold">Warning</emphasis>: Such a setting excludes listening on the loopback interfaces.
18848 </para>
18849 </section>
18850 <section id="SECTreclocipadd">
18851 <title>Recognizing the local host</title>
18852 <para>
18853 The <option>local_interfaces</option> option is also used when Exim needs to determine
18854 whether or not an IP address refers to the local host. That is, the IP
18855 addresses of all the interfaces on which a daemon is listening are always
18856 treated as local.
18857 </para>
18858 <para>
18859 For this usage, port numbers in <option>local_interfaces</option> are ignored. If either of
18860 the items 0.0.0.0 or ::0 are encountered, Exim gets a complete list of
18861 available interfaces from the operating system, and extracts the relevant
18862 (that is, IPv4 or IPv6) addresses to use for checking.
18863 </para>
18864 <para>
18865 Some systems set up large numbers of virtual interfaces in order to provide
18866 many virtual web servers. In this situation, you may want to listen for
18867 email on only a few of the available interfaces, but nevertheless treat all
18868 interfaces as local when routing. You can do this by setting
18869 <option>extra_local_interfaces</option> to a list of IP addresses, possibly including the
18870 <quote>all</quote> wildcard values. These addresses are recognized as local, but are not
18871 used for listening. Consider this example:
18872 </para>
18873 <literallayout class="monospaced">
18874 local_interfaces = &lt;; 127.0.0.1 ; ::1 ; \
18875                       192.168.53.235 ; \
18876                       3ffe:2101:12:1:a00:20ff:fe86:a061
18877
18878 extra_local_interfaces = &lt;; ::0 ; 0.0.0.0
18879 </literallayout>
18880 <para>
18881 The daemon listens on the loopback interfaces and just one IPv4 and one IPv6
18882 address, but all available interface addresses are treated as local when
18883 Exim is routing.
18884 </para>
18885 <para>
18886 In some environments the local host name may be in an MX list, but with an IP
18887 address that is not assigned to any local interface. In other cases it may be
18888 desirable to treat other host names as if they referred to the local host. Both
18889 these cases can be handled by setting the <option>hosts_treat_as_local</option> option.
18890 This contains host names rather than IP addresses. When a host is referenced
18891 during routing, either via an MX record or directly, it is treated as the local
18892 host if its name matches <option>hosts_treat_as_local</option>, or if any of its IP
18893 addresses match <option>local_interfaces</option> or <option>extra_local_interfaces</option>.
18894 </para>
18895 </section>
18896 <section id="SECID95">
18897 <title>Delivering to a remote host</title>
18898 <para>
18899 Delivery to a remote host is handled by the smtp transport. By default, it
18900 allows the system&#x2019;s TCP/IP functions to choose which interface to use (if
18901 there is more than one) when connecting to a remote host. However, the
18902 <option>interface</option> option can be set to specify which interface is used. See the
18903 description of the smtp transport in chapter <xref linkend="CHAPsmtptrans"/> for more
18904 details.
18905 </para>
18906 </section>
18907 </chapter>
18908
18909 <chapter id="CHAPmainconfig">
18910 <title>Main configuration</title>
18911 <para>
18912 <indexterm role="concept" id="IIDconfima" class="startofrange">
18913 <primary>configuration file</primary>
18914 <secondary>main section</secondary>
18915 </indexterm>
18916 <indexterm role="concept" id="IIDmaiconf" class="startofrange">
18917 <primary>main configuration</primary>
18918 </indexterm>
18919 The first part of the run time configuration file contains three types of item:
18920 </para>
18921 <itemizedlist>
18922 <listitem>
18923 <para>
18924 Macro definitions: These lines start with an upper case letter. See section
18925 <xref linkend="SECTmacrodefs"/> for details of macro processing.
18926 </para>
18927 </listitem>
18928 <listitem>
18929 <para>
18930 Named list definitions: These lines start with one of the words <quote>domainlist</quote>,
18931 <quote>hostlist</quote>, <quote>addresslist</quote>, or <quote>localpartlist</quote>. Their use is described in
18932 section <xref linkend="SECTnamedlists"/>.
18933 </para>
18934 </listitem>
18935 <listitem>
18936 <para>
18937 Main configuration settings: Each setting occupies one line of the file
18938 (with possible continuations). If any setting is preceded by the word
18939 <quote>hide</quote>, the <option>-bP</option> command line option displays its value to admin users
18940 only. See section <xref linkend="SECTcos"/> for a description of the syntax of these option
18941 settings.
18942 </para>
18943 </listitem>
18944 </itemizedlist>
18945 <para>
18946 This chapter specifies all the main configuration options, along with their
18947 types and default values. For ease of finding a particular option, they appear
18948 in alphabetical order in section <xref linkend="SECTalomo"/> below. However, because there
18949 are now so many options, they are first listed briefly in functional groups, as
18950 an aid to finding the name of the option you are looking for. Some options are
18951 listed in more than one group.
18952 </para>
18953 <section id="SECID96">
18954 <title>Miscellaneous</title>
18955 <informaltable frame="none">
18956 <tgroup cols="2" colsep="0" rowsep="0">
18957 <colspec colwidth="196pt" align="left"/>
18958 <colspec colwidth="254pt" align="left"/>
18959 <tbody>
18960 <row>
18961 <entry><option>bi_command</option></entry>
18962 <entry>to run for <option>-bi</option> command line option</entry>
18963 </row>
18964 <row>
18965 <entry><option>disable_ipv6</option></entry>
18966 <entry>do no IPv6 processing</entry>
18967 </row>
18968 <row>
18969 <entry><option>keep_malformed</option></entry>
18970 <entry>for broken files &ndash; should not happen</entry>
18971 </row>
18972 <row>
18973 <entry><option>localhost_number</option></entry>
18974 <entry>for unique message ids in clusters</entry>
18975 </row>
18976 <row>
18977 <entry><option>message_body_newlines</option></entry>
18978 <entry>retain newlines in <varname>$message_body</varname></entry>
18979 </row>
18980 <row>
18981 <entry><option>message_body_visible</option></entry>
18982 <entry>how much to show in <varname>$message_body</varname></entry>
18983 </row>
18984 <row>
18985 <entry><option>mua_wrapper</option></entry>
18986 <entry>run in <quote>MUA wrapper</quote> mode</entry>
18987 </row>
18988 <row>
18989 <entry><option>print_topbitchars</option></entry>
18990 <entry>top-bit characters are printing</entry>
18991 </row>
18992 <row>
18993 <entry><option>timezone</option></entry>
18994 <entry>force time zone</entry>
18995 </row>
18996 </tbody>
18997 </tgroup>
18998 </informaltable>
18999 </section>
19000 <section id="SECID97">
19001 <title>Exim parameters</title>
19002 <informaltable frame="none">
19003 <tgroup cols="2" colsep="0" rowsep="0">
19004 <colspec colwidth="196pt" align="left"/>
19005 <colspec colwidth="254pt" align="left"/>
19006 <tbody>
19007 <row>
19008 <entry><option>exim_group</option></entry>
19009 <entry>override compiled-in value</entry>
19010 </row>
19011 <row>
19012 <entry><option>exim_path</option></entry>
19013 <entry>override compiled-in value</entry>
19014 </row>
19015 <row>
19016 <entry><option>exim_user</option></entry>
19017 <entry>override compiled-in value</entry>
19018 </row>
19019 <row>
19020 <entry><option>primary_hostname</option></entry>
19021 <entry>default from <function>uname()</function></entry>
19022 </row>
19023 <row>
19024 <entry><option>split_spool_directory</option></entry>
19025 <entry>use multiple directories</entry>
19026 </row>
19027 <row>
19028 <entry><option>spool_directory</option></entry>
19029 <entry>override compiled-in value</entry>
19030 </row>
19031 </tbody>
19032 </tgroup>
19033 </informaltable>
19034 </section>
19035 <section id="SECID98">
19036 <title>Privilege controls</title>
19037 <informaltable frame="none">
19038 <tgroup cols="2" colsep="0" rowsep="0">
19039 <colspec colwidth="196pt" align="left"/>
19040 <colspec colwidth="254pt" align="left"/>
19041 <tbody>
19042 <row>
19043 <entry><option>admin_groups</option></entry>
19044 <entry>groups that are Exim admin users</entry>
19045 </row>
19046 <row>
19047 <entry><option>deliver_drop_privilege</option></entry>
19048 <entry>drop root for delivery processes</entry>
19049 </row>
19050 <row>
19051 <entry><option>local_from_check</option></entry>
19052 <entry>insert <emphasis>Sender:</emphasis> if necessary</entry>
19053 </row>
19054 <row>
19055 <entry><option>local_from_prefix</option></entry>
19056 <entry>for testing <emphasis>From:</emphasis> for local sender</entry>
19057 </row>
19058 <row>
19059 <entry><option>local_from_suffix</option></entry>
19060 <entry>for testing <emphasis>From:</emphasis> for local sender</entry>
19061 </row>
19062 <row>
19063 <entry><option>local_sender_retain</option></entry>
19064 <entry>keep <emphasis>Sender:</emphasis> from untrusted user</entry>
19065 </row>
19066 <row>
19067 <entry><option>never_users</option></entry>
19068 <entry>do not run deliveries as these</entry>
19069 </row>
19070 <row>
19071 <entry><option>prod_requires_admin</option></entry>
19072 <entry>forced delivery requires admin user</entry>
19073 </row>
19074 <row>
19075 <entry><option>queue_list_requires_admin</option></entry>
19076 <entry>queue listing requires admin user</entry>
19077 </row>
19078 <row>
19079 <entry><option>trusted_groups</option></entry>
19080 <entry>groups that are trusted</entry>
19081 </row>
19082 <row>
19083 <entry><option>trusted_users</option></entry>
19084 <entry>users that are trusted</entry>
19085 </row>
19086 </tbody>
19087 </tgroup>
19088 </informaltable>
19089 </section>
19090 <section id="SECID99">
19091 <title>Logging</title>
19092 <informaltable frame="none">
19093 <tgroup cols="2" colsep="0" rowsep="0">
19094 <colspec colwidth="196pt" align="left"/>
19095 <colspec colwidth="254pt" align="left"/>
19096 <tbody>
19097 <row>
19098 <entry><option>hosts_connection_nolog</option></entry>
19099 <entry>exemption from connect logging</entry>
19100 </row>
19101 <row>
19102 <entry><option>log_file_path</option></entry>
19103 <entry>override compiled-in value</entry>
19104 </row>
19105 <row>
19106 <entry><option>log_selector</option></entry>
19107 <entry>set/unset optional logging</entry>
19108 </row>
19109 <row>
19110 <entry><option>log_timezone</option></entry>
19111 <entry>add timezone to log lines</entry>
19112 </row>
19113 <row>
19114 <entry><option>message_logs</option></entry>
19115 <entry>create per-message logs</entry>
19116 </row>
19117 <row>
19118 <entry><option>preserve_message_logs</option></entry>
19119 <entry>after message completion</entry>
19120 </row>
19121 <row>
19122 <entry><option>process_log_path</option></entry>
19123 <entry>for SIGUSR1 and <emphasis>exiwhat</emphasis></entry>
19124 </row>
19125 <row>
19126 <entry><option>syslog_duplication</option></entry>
19127 <entry>controls duplicate log lines on syslog</entry>
19128 </row>
19129 <row>
19130 <entry><option>syslog_facility</option></entry>
19131 <entry>set syslog <quote>facility</quote> field</entry>
19132 </row>
19133 <row>
19134 <entry><option>syslog_processname</option></entry>
19135 <entry>set syslog <quote>ident</quote> field</entry>
19136 </row>
19137 <row>
19138 <entry><option>syslog_timestamp</option></entry>
19139 <entry>timestamp syslog lines</entry>
19140 </row>
19141 <row>
19142 <entry><option>write_rejectlog</option></entry>
19143 <entry>control use of message log</entry>
19144 </row>
19145 </tbody>
19146 </tgroup>
19147 </informaltable>
19148 </section>
19149 <section id="SECID100">
19150 <title>Frozen messages</title>
19151 <informaltable frame="none">
19152 <tgroup cols="2" colsep="0" rowsep="0">
19153 <colspec colwidth="196pt" align="left"/>
19154 <colspec colwidth="254pt" align="left"/>
19155 <tbody>
19156 <row>
19157 <entry><option>auto_thaw</option></entry>
19158 <entry>sets time for retrying frozen messages</entry>
19159 </row>
19160 <row>
19161 <entry><option>freeze_tell</option></entry>
19162 <entry>send message when freezing</entry>
19163 </row>
19164 <row>
19165 <entry><option>move_frozen_messages</option></entry>
19166 <entry>to another directory</entry>
19167 </row>
19168 <row>
19169 <entry><option>timeout_frozen_after</option></entry>
19170 <entry>keep frozen messages only so long</entry>
19171 </row>
19172 </tbody>
19173 </tgroup>
19174 </informaltable>
19175 </section>
19176 <section id="SECID101">
19177 <title>Data lookups</title>
19178 <informaltable frame="none">
19179 <tgroup cols="2" colsep="0" rowsep="0">
19180 <colspec colwidth="196pt" align="left"/>
19181 <colspec colwidth="254pt" align="left"/>
19182 <tbody>
19183 <row>
19184 <entry><option>ibase_servers</option></entry>
19185 <entry>InterBase servers</entry>
19186 </row>
19187 <row>
19188 <entry><option>ldap_default_servers</option></entry>
19189 <entry>used if no server in query</entry>
19190 </row>
19191 <row>
19192 <entry><option>ldap_version</option></entry>
19193 <entry>set protocol version</entry>
19194 </row>
19195 <row>
19196 <entry><option>lookup_open_max</option></entry>
19197 <entry>lookup files held open</entry>
19198 </row>
19199 <row>
19200 <entry><option>mysql_servers</option></entry>
19201 <entry>default MySQL servers</entry>
19202 </row>
19203 <row>
19204 <entry><option>oracle_servers</option></entry>
19205 <entry>Oracle servers</entry>
19206 </row>
19207 <row>
19208 <entry><option>pgsql_servers</option></entry>
19209 <entry>default PostgreSQL servers</entry>
19210 </row>
19211 <row>
19212 <entry><option>sqlite_lock_timeout</option></entry>
19213 <entry>as it says</entry>
19214 </row>
19215 </tbody>
19216 </tgroup>
19217 </informaltable>
19218 </section>
19219 <section id="SECID102">
19220 <title>Message ids</title>
19221 <informaltable frame="none">
19222 <tgroup cols="2" colsep="0" rowsep="0">
19223 <colspec colwidth="196pt" align="left"/>
19224 <colspec colwidth="254pt" align="left"/>
19225 <tbody>
19226 <row>
19227 <entry><option>message_id_header_domain</option></entry>
19228 <entry>used to build <emphasis>Message-ID:</emphasis> header</entry>
19229 </row>
19230 <row>
19231 <entry><option>message_id_header_text</option></entry>
19232 <entry>ditto</entry>
19233 </row>
19234 </tbody>
19235 </tgroup>
19236 </informaltable>
19237 </section>
19238 <section id="SECID103">
19239 <title>Embedded Perl Startup</title>
19240 <informaltable frame="none">
19241 <tgroup cols="2" colsep="0" rowsep="0">
19242 <colspec colwidth="196pt" align="left"/>
19243 <colspec colwidth="254pt" align="left"/>
19244 <tbody>
19245 <row>
19246 <entry><option>perl_at_start</option></entry>
19247 <entry>always start the interpreter</entry>
19248 </row>
19249 <row>
19250 <entry><option>perl_startup</option></entry>
19251 <entry>code to obey when starting Perl</entry>
19252 </row>
19253 </tbody>
19254 </tgroup>
19255 </informaltable>
19256 </section>
19257 <section id="SECID104">
19258 <title>Daemon</title>
19259 <informaltable frame="none">
19260 <tgroup cols="2" colsep="0" rowsep="0">
19261 <colspec colwidth="196pt" align="left"/>
19262 <colspec colwidth="254pt" align="left"/>
19263 <tbody>
19264 <row>
19265 <entry><option>daemon_smtp_ports</option></entry>
19266 <entry>default ports</entry>
19267 </row>
19268 <row>
19269 <entry><option>daemon_startup_retries</option></entry>
19270 <entry>number of times to retry</entry>
19271 </row>
19272 <row>
19273 <entry><option>daemon_startup_sleep</option></entry>
19274 <entry>time to sleep between tries</entry>
19275 </row>
19276 <row>
19277 <entry><option>extra_local_interfaces</option></entry>
19278 <entry>not necessarily listened on</entry>
19279 </row>
19280 <row>
19281 <entry><option>local_interfaces</option></entry>
19282 <entry>on which to listen, with optional ports</entry>
19283 </row>
19284 <row>
19285 <entry><option>pid_file_path</option></entry>
19286 <entry>override compiled-in value</entry>
19287 </row>
19288 <row>
19289 <entry><option>queue_run_max</option></entry>
19290 <entry>maximum simultaneous queue runners</entry>
19291 </row>
19292 </tbody>
19293 </tgroup>
19294 </informaltable>
19295 </section>
19296 <section id="SECID105">
19297 <title>Resource control</title>
19298 <informaltable frame="none">
19299 <tgroup cols="2" colsep="0" rowsep="0">
19300 <colspec colwidth="196pt" align="left"/>
19301 <colspec colwidth="254pt" align="left"/>
19302 <tbody>
19303 <row>
19304 <entry><option>check_log_inodes</option></entry>
19305 <entry>before accepting a message</entry>
19306 </row>
19307 <row>
19308 <entry><option>check_log_space</option></entry>
19309 <entry>before accepting a message</entry>
19310 </row>
19311 <row>
19312 <entry><option>check_spool_inodes</option></entry>
19313 <entry>before accepting a message</entry>
19314 </row>
19315 <row>
19316 <entry><option>check_spool_space</option></entry>
19317 <entry>before accepting a message</entry>
19318 </row>
19319 <row>
19320 <entry><option>deliver_queue_load_max</option></entry>
19321 <entry>no queue deliveries if load high</entry>
19322 </row>
19323 <row>
19324 <entry><option>queue_only_load</option></entry>
19325 <entry>queue incoming if load high</entry>
19326 </row>
19327 <row>
19328 <entry><option>queue_only_load_latch</option></entry>
19329 <entry>don&#x2019;t re-evaluate load for each message</entry>
19330 </row>
19331 <row>
19332 <entry><option>queue_run_max</option></entry>
19333 <entry>maximum simultaneous queue runners</entry>
19334 </row>
19335 <row>
19336 <entry><option>remote_max_parallel</option></entry>
19337 <entry>parallel SMTP delivery per message</entry>
19338 </row>
19339 <row>
19340 <entry><option>smtp_accept_max</option></entry>
19341 <entry>simultaneous incoming connections</entry>
19342 </row>
19343 <row>
19344 <entry><option>smtp_accept_max_nonmail</option></entry>
19345 <entry>non-mail commands</entry>
19346 </row>
19347 <row>
19348 <entry><option>smtp_accept_max_nonmail_hosts</option></entry>
19349 <entry>hosts to which the limit applies</entry>
19350 </row>
19351 <row>
19352 <entry><option>smtp_accept_max_per_connection</option></entry>
19353 <entry>messages per connection</entry>
19354 </row>
19355 <row>
19356 <entry><option>smtp_accept_max_per_host</option></entry>
19357 <entry>connections from one host</entry>
19358 </row>
19359 <row>
19360 <entry><option>smtp_accept_queue</option></entry>
19361 <entry>queue mail if more connections</entry>
19362 </row>
19363 <row>
19364 <entry><option>smtp_accept_queue_per_connection</option></entry>
19365 <entry>queue if more messages per connection</entry>
19366 </row>
19367 <row>
19368 <entry><option>smtp_accept_reserve</option></entry>
19369 <entry>only reserve hosts if more connections</entry>
19370 </row>
19371 <row>
19372 <entry><option>smtp_check_spool_space</option></entry>
19373 <entry>from SIZE on MAIL command</entry>
19374 </row>
19375 <row>
19376 <entry><option>smtp_connect_backlog</option></entry>
19377 <entry>passed to TCP/IP stack</entry>
19378 </row>
19379 <row>
19380 <entry><option>smtp_load_reserve</option></entry>
19381 <entry>SMTP from reserved hosts if load high</entry>
19382 </row>
19383 <row>
19384 <entry><option>smtp_reserve_hosts</option></entry>
19385 <entry>these are the reserve hosts</entry>
19386 </row>
19387 </tbody>
19388 </tgroup>
19389 </informaltable>
19390 </section>
19391 <section id="SECID106">
19392 <title>Policy controls</title>
19393 <informaltable frame="none">
19394 <tgroup cols="2" colsep="0" rowsep="0">
19395 <colspec colwidth="196pt" align="left"/>
19396 <colspec colwidth="254pt" align="left"/>
19397 <tbody>
19398 <row>
19399 <entry><option>acl_not_smtp</option></entry>
19400 <entry>ACL for non-SMTP messages</entry>
19401 </row>
19402 <row>
19403 <entry><option>acl_not_smtp_mime</option></entry>
19404 <entry>ACL for non-SMTP MIME parts</entry>
19405 </row>
19406 <row>
19407 <entry><option>acl_not_smtp_start</option></entry>
19408 <entry>ACL for start of non-SMTP message</entry>
19409 </row>
19410 <row>
19411 <entry><option>acl_smtp_auth</option></entry>
19412 <entry>ACL for AUTH</entry>
19413 </row>
19414 <row>
19415 <entry><option>acl_smtp_connect</option></entry>
19416 <entry>ACL for connection</entry>
19417 </row>
19418 <row>
19419 <entry><option>acl_smtp_data</option></entry>
19420 <entry>ACL for DATA</entry>
19421 </row>
19422 <row>
19423 <entry><option>acl_smtp_dkim</option></entry>
19424 <entry>ACL for DKIM verification</entry>
19425 </row>
19426 <row>
19427 <entry><option>acl_smtp_etrn</option></entry>
19428 <entry>ACL for ETRN</entry>
19429 </row>
19430 <row>
19431 <entry><option>acl_smtp_expn</option></entry>
19432 <entry>ACL for EXPN</entry>
19433 </row>
19434 <row>
19435 <entry><option>acl_smtp_helo</option></entry>
19436 <entry>ACL for EHLO or HELO</entry>
19437 </row>
19438 <row>
19439 <entry><option>acl_smtp_mail</option></entry>
19440 <entry>ACL for MAIL</entry>
19441 </row>
19442 <row>
19443 <entry><option>acl_smtp_mailauth</option></entry>
19444 <entry>ACL for AUTH on MAIL command</entry>
19445 </row>
19446 <row>
19447 <entry><option>acl_smtp_mime</option></entry>
19448 <entry>ACL for MIME parts</entry>
19449 </row>
19450 <row>
19451 <entry><option>acl_smtp_predata</option></entry>
19452 <entry>ACL for start of data</entry>
19453 </row>
19454 <row>
19455 <entry><option>acl_smtp_quit</option></entry>
19456 <entry>ACL for QUIT</entry>
19457 </row>
19458 <row>
19459 <entry><option>acl_smtp_rcpt</option></entry>
19460 <entry>ACL for RCPT</entry>
19461 </row>
19462 <row>
19463 <entry><option>acl_smtp_starttls</option></entry>
19464 <entry>ACL for STARTTLS</entry>
19465 </row>
19466 <row>
19467 <entry><option>acl_smtp_vrfy</option></entry>
19468 <entry>ACL for VRFY</entry>
19469 </row>
19470 <row>
19471 <entry><option>av_scanner</option></entry>
19472 <entry>specify virus scanner</entry>
19473 </row>
19474 <row>
19475 <entry><option>check_rfc2047_length</option></entry>
19476 <entry>check length of RFC 2047 <quote>encoded words</quote></entry>
19477 </row>
19478 <row>
19479 <entry><option>dns_csa_search_limit</option></entry>
19480 <entry>control CSA parent search depth</entry>
19481 </row>
19482 <row>
19483 <entry><option>dns_csa_use_reverse</option></entry>
19484 <entry>en/disable CSA IP reverse search</entry>
19485 </row>
19486 <row>
19487 <entry><option>header_maxsize</option></entry>
19488 <entry>total size of message header</entry>
19489 </row>
19490 <row>
19491 <entry><option>header_line_maxsize</option></entry>
19492 <entry>individual header line limit</entry>
19493 </row>
19494 <row>
19495 <entry><option>helo_accept_junk_hosts</option></entry>
19496 <entry>allow syntactic junk from these hosts</entry>
19497 </row>
19498 <row>
19499 <entry><option>helo_allow_chars</option></entry>
19500 <entry>allow illegal chars in HELO names</entry>
19501 </row>
19502 <row>
19503 <entry><option>helo_lookup_domains</option></entry>
19504 <entry>lookup hostname for these HELO names</entry>
19505 </row>
19506 <row>
19507 <entry><option>helo_try_verify_hosts</option></entry>
19508 <entry>HELO soft-checked for these hosts</entry>
19509 </row>
19510 <row>
19511 <entry><option>helo_verify_hosts</option></entry>
19512 <entry>HELO hard-checked for these hosts</entry>
19513 </row>
19514 <row>
19515 <entry><option>host_lookup</option></entry>
19516 <entry>host name looked up for these hosts</entry>
19517 </row>
19518 <row>
19519 <entry><option>host_lookup_order</option></entry>
19520 <entry>order of DNS and local name lookups</entry>
19521 </row>
19522 <row>
19523 <entry><option>host_reject_connection</option></entry>
19524 <entry>reject connection from these hosts</entry>
19525 </row>
19526 <row>
19527 <entry><option>hosts_treat_as_local</option></entry>
19528 <entry>useful in some cluster configurations</entry>
19529 </row>
19530 <row>
19531 <entry><option>local_scan_timeout</option></entry>
19532 <entry>timeout for <function>local_scan()</function></entry>
19533 </row>
19534 <row>
19535 <entry><option>message_size_limit</option></entry>
19536 <entry>for all messages</entry>
19537 </row>
19538 <row>
19539 <entry><option>percent_hack_domains</option></entry>
19540 <entry>recognize %-hack for these domains</entry>
19541 </row>
19542 <row>
19543 <entry><option>spamd_address</option></entry>
19544 <entry>set interface to SpamAssassin</entry>
19545 </row>
19546 <row>
19547 <entry><option>strict_acl_vars</option></entry>
19548 <entry>object to unset ACL variables</entry>
19549 </row>
19550 </tbody>
19551 </tgroup>
19552 </informaltable>
19553 </section>
19554 <section id="SECID107">
19555 <title>Callout cache</title>
19556 <informaltable frame="none">
19557 <tgroup cols="2" colsep="0" rowsep="0">
19558 <colspec colwidth="196pt" align="left"/>
19559 <colspec colwidth="254pt" align="left"/>
19560 <tbody>
19561 <row>
19562 <entry><option>callout_domain_negative_expire</option></entry>
19563 <entry>timeout for negative domain cache item</entry>
19564 </row>
19565 <row>
19566 <entry><option>callout_domain_positive_expire</option></entry>
19567 <entry>timeout for positive domain cache item</entry>
19568 </row>
19569 <row>
19570 <entry><option>callout_negative_expire</option></entry>
19571 <entry>timeout for negative address cache item</entry>
19572 </row>
19573 <row>
19574 <entry><option>callout_positive_expire</option></entry>
19575 <entry>timeout for positive address cache item</entry>
19576 </row>
19577 <row>
19578 <entry><option>callout_random_local_part</option></entry>
19579 <entry>string to use for <quote>random</quote> testing</entry>
19580 </row>
19581 </tbody>
19582 </tgroup>
19583 </informaltable>
19584 </section>
19585 <section id="SECID108">
19586 <title>TLS</title>
19587 <informaltable frame="none">
19588 <tgroup cols="2" colsep="0" rowsep="0">
19589 <colspec colwidth="196pt" align="left"/>
19590 <colspec colwidth="254pt" align="left"/>
19591 <tbody>
19592 <row>
19593 <entry><option>gnutls_require_kx</option></entry>
19594 <entry>control GnuTLS key exchanges</entry>
19595 </row>
19596 <row>
19597 <entry><option>gnutls_require_mac</option></entry>
19598 <entry>control GnuTLS MAC algorithms</entry>
19599 </row>
19600 <row>
19601 <entry><option>gnutls_require_protocols</option></entry>
19602 <entry>control GnuTLS protocols</entry>
19603 </row>
19604 <row>
19605 <entry><option>gnutls_compat_mode</option></entry>
19606 <entry>use GnuTLS compatibility mode</entry>
19607 </row>
19608 <row>
19609 <entry><option>openssl_options</option></entry>
19610 <entry>adjust OpenSSL compatibility options</entry>
19611 </row>
19612 <row>
19613 <entry><option>tls_advertise_hosts</option></entry>
19614 <entry>advertise TLS to these hosts</entry>
19615 </row>
19616 <row>
19617 <entry><option>tls_certificate</option></entry>
19618 <entry>location of server certificate</entry>
19619 </row>
19620 <row>
19621 <entry><option>tls_crl</option></entry>
19622 <entry>certificate revocation list</entry>
19623 </row>
19624 <row>
19625 <entry><option>tls_dhparam</option></entry>
19626 <entry>DH parameters for server</entry>
19627 </row>
19628 <row>
19629 <entry><option>tls_on_connect_ports</option></entry>
19630 <entry>specify SSMTP (SMTPS) ports</entry>
19631 </row>
19632 <row>
19633 <entry><option>tls_privatekey</option></entry>
19634 <entry>location of server private key</entry>
19635 </row>
19636 <row>
19637 <entry><option>tls_remember_esmtp</option></entry>
19638 <entry>don&#x2019;t reset after starting TLS</entry>
19639 </row>
19640 <row>
19641 <entry><option>tls_require_ciphers</option></entry>
19642 <entry>specify acceptable ciphers</entry>
19643 </row>
19644 <row>
19645 <entry><option>tls_try_verify_hosts</option></entry>
19646 <entry>try to verify client certificate</entry>
19647 </row>
19648 <row>
19649 <entry><option>tls_verify_certificates</option></entry>
19650 <entry>expected client certificates</entry>
19651 </row>
19652 <row>
19653 <entry><option>tls_verify_hosts</option></entry>
19654 <entry>insist on client certificate verify</entry>
19655 </row>
19656 </tbody>
19657 </tgroup>
19658 </informaltable>
19659 </section>
19660 <section id="SECID109">
19661 <title>Local user handling</title>
19662 <informaltable frame="none">
19663 <tgroup cols="2" colsep="0" rowsep="0">
19664 <colspec colwidth="196pt" align="left"/>
19665 <colspec colwidth="254pt" align="left"/>
19666 <tbody>
19667 <row>
19668 <entry><option>finduser_retries</option></entry>
19669 <entry>useful in NIS environments</entry>
19670 </row>
19671 <row>
19672 <entry><option>gecos_name</option></entry>
19673 <entry>used when creating <emphasis>Sender:</emphasis></entry>
19674 </row>
19675 <row>
19676 <entry><option>gecos_pattern</option></entry>
19677 <entry>ditto</entry>
19678 </row>
19679 <row>
19680 <entry><option>max_username_length</option></entry>
19681 <entry>for systems that truncate</entry>
19682 </row>
19683 <row>
19684 <entry><option>unknown_login</option></entry>
19685 <entry>used when no login name found</entry>
19686 </row>
19687 <row>
19688 <entry><option>unknown_username</option></entry>
19689 <entry>ditto</entry>
19690 </row>
19691 <row>
19692 <entry><option>uucp_from_pattern</option></entry>
19693 <entry>for recognizing <quote>From </quote> lines</entry>
19694 </row>
19695 <row>
19696 <entry><option>uucp_from_sender</option></entry>
19697 <entry>ditto</entry>
19698 </row>
19699 </tbody>
19700 </tgroup>
19701 </informaltable>
19702 </section>
19703 <section id="SECID110">
19704 <title>All incoming messages (SMTP and non-SMTP)</title>
19705 <informaltable frame="none">
19706 <tgroup cols="2" colsep="0" rowsep="0">
19707 <colspec colwidth="196pt" align="left"/>
19708 <colspec colwidth="254pt" align="left"/>
19709 <tbody>
19710 <row>
19711 <entry><option>header_maxsize</option></entry>
19712 <entry>total size of message header</entry>
19713 </row>
19714 <row>
19715 <entry><option>header_line_maxsize</option></entry>
19716 <entry>individual header line limit</entry>
19717 </row>
19718 <row>
19719 <entry><option>message_size_limit</option></entry>
19720 <entry>applies to all messages</entry>
19721 </row>
19722 <row>
19723 <entry><option>percent_hack_domains</option></entry>
19724 <entry>recognize %-hack for these domains</entry>
19725 </row>
19726 <row>
19727 <entry><option>received_header_text</option></entry>
19728 <entry>expanded to make <emphasis>Received:</emphasis></entry>
19729 </row>
19730 <row>
19731 <entry><option>received_headers_max</option></entry>
19732 <entry>for mail loop detection</entry>
19733 </row>
19734 <row>
19735 <entry><option>recipients_max</option></entry>
19736 <entry>limit per message</entry>
19737 </row>
19738 <row>
19739 <entry><option>recipients_max_reject</option></entry>
19740 <entry>permanently reject excess recipients</entry>
19741 </row>
19742 </tbody>
19743 </tgroup>
19744 </informaltable>
19745 </section>
19746 <section id="SECID111">
19747 <title>Non-SMTP incoming messages</title>
19748 <informaltable frame="none">
19749 <tgroup cols="2" colsep="0" rowsep="0">
19750 <colspec colwidth="196pt" align="left"/>
19751 <colspec colwidth="254pt" align="left"/>
19752 <tbody>
19753 <row>
19754 <entry><option>receive_timeout</option></entry>
19755 <entry>for non-SMTP messages</entry>
19756 </row>
19757 </tbody>
19758 </tgroup>
19759 </informaltable>
19760 </section>
19761 <section id="SECID112">
19762 <title>Incoming SMTP messages</title>
19763 <para>
19764 See also the <emphasis>Policy controls</emphasis> section above.
19765 </para>
19766 <informaltable frame="none">
19767 <tgroup cols="2" colsep="0" rowsep="0">
19768 <colspec colwidth="196pt" align="left"/>
19769 <colspec colwidth="254pt" align="left"/>
19770 <tbody>
19771 <row>
19772 <entry><option>host_lookup</option></entry>
19773 <entry>host name looked up for these hosts</entry>
19774 </row>
19775 <row>
19776 <entry><option>host_lookup_order</option></entry>
19777 <entry>order of DNS and local name lookups</entry>
19778 </row>
19779 <row>
19780 <entry><option>recipient_unqualified_hosts</option></entry>
19781 <entry>may send unqualified recipients</entry>
19782 </row>
19783 <row>
19784 <entry><option>rfc1413_hosts</option></entry>
19785 <entry>make ident calls to these hosts</entry>
19786 </row>
19787 <row>
19788 <entry><option>rfc1413_query_timeout</option></entry>
19789 <entry>zero disables ident calls</entry>
19790 </row>
19791 <row>
19792 <entry><option>sender_unqualified_hosts</option></entry>
19793 <entry>may send unqualified senders</entry>
19794 </row>
19795 <row>
19796 <entry><option>smtp_accept_keepalive</option></entry>
19797 <entry>some TCP/IP magic</entry>
19798 </row>
19799 <row>
19800 <entry><option>smtp_accept_max</option></entry>
19801 <entry>simultaneous incoming connections</entry>
19802 </row>
19803 <row>
19804 <entry><option>smtp_accept_max_nonmail</option></entry>
19805 <entry>non-mail commands</entry>
19806 </row>
19807 <row>
19808 <entry><option>smtp_accept_max_nonmail_hosts</option></entry>
19809 <entry>hosts to which the limit applies</entry>
19810 </row>
19811 <row>
19812 <entry><option>smtp_accept_max_per_connection</option></entry>
19813 <entry>messages per connection</entry>
19814 </row>
19815 <row>
19816 <entry><option>smtp_accept_max_per_host</option></entry>
19817 <entry>connections from one host</entry>
19818 </row>
19819 <row>
19820 <entry><option>smtp_accept_queue</option></entry>
19821 <entry>queue mail if more connections</entry>
19822 </row>
19823 <row>
19824 <entry><option>smtp_accept_queue_per_connection</option></entry>
19825 <entry>queue if more messages per connection</entry>
19826 </row>
19827 <row>
19828 <entry><option>smtp_accept_reserve</option></entry>
19829 <entry>only reserve hosts if more connections</entry>
19830 </row>
19831 <row>
19832 <entry><option>smtp_active_hostname</option></entry>
19833 <entry>host name to use in messages</entry>
19834 </row>
19835 <row>
19836 <entry><option>smtp_banner</option></entry>
19837 <entry>text for welcome banner</entry>
19838 </row>
19839 <row>
19840 <entry><option>smtp_check_spool_space</option></entry>
19841 <entry>from SIZE on MAIL command</entry>
19842 </row>
19843 <row>
19844 <entry><option>smtp_connect_backlog</option></entry>
19845 <entry>passed to TCP/IP stack</entry>
19846 </row>
19847 <row>
19848 <entry><option>smtp_enforce_sync</option></entry>
19849 <entry>of SMTP command/responses</entry>
19850 </row>
19851 <row>
19852 <entry><option>smtp_etrn_command</option></entry>
19853 <entry>what to run for ETRN</entry>
19854 </row>
19855 <row>
19856 <entry><option>smtp_etrn_serialize</option></entry>
19857 <entry>only one at once</entry>
19858 </row>
19859 <row>
19860 <entry><option>smtp_load_reserve</option></entry>
19861 <entry>only reserve hosts if this load</entry>
19862 </row>
19863 <row>
19864 <entry><option>smtp_max_unknown_commands</option></entry>
19865 <entry>before dropping connection</entry>
19866 </row>
19867 <row>
19868 <entry><option>smtp_ratelimit_hosts</option></entry>
19869 <entry>apply ratelimiting to these hosts</entry>
19870 </row>
19871 <row>
19872 <entry><option>smtp_ratelimit_mail</option></entry>
19873 <entry>ratelimit for MAIL commands</entry>
19874 </row>
19875 <row>
19876 <entry><option>smtp_ratelimit_rcpt</option></entry>
19877 <entry>ratelimit for RCPT commands</entry>
19878 </row>
19879 <row>
19880 <entry><option>smtp_receive_timeout</option></entry>
19881 <entry>per command or data line</entry>
19882 </row>
19883 <row>
19884 <entry><option>smtp_reserve_hosts</option></entry>
19885 <entry>these are the reserve hosts</entry>
19886 </row>
19887 <row>
19888 <entry><option>smtp_return_error_details</option></entry>
19889 <entry>give detail on rejections</entry>
19890 </row>
19891 </tbody>
19892 </tgroup>
19893 </informaltable>
19894 </section>
19895 <section id="SECID113">
19896 <title>SMTP extensions</title>
19897 <informaltable frame="none">
19898 <tgroup cols="2" colsep="0" rowsep="0">
19899 <colspec colwidth="196pt" align="left"/>
19900 <colspec colwidth="254pt" align="left"/>
19901 <tbody>
19902 <row>
19903 <entry><option>accept_8bitmime</option></entry>
19904 <entry>advertise 8BITMIME</entry>
19905 </row>
19906 <row>
19907 <entry><option>auth_advertise_hosts</option></entry>
19908 <entry>advertise AUTH to these hosts</entry>
19909 </row>
19910 <row>
19911 <entry><option>ignore_fromline_hosts</option></entry>
19912 <entry>allow <quote>From </quote> from these hosts</entry>
19913 </row>
19914 <row>
19915 <entry><option>ignore_fromline_local</option></entry>
19916 <entry>allow <quote>From </quote> from local SMTP</entry>
19917 </row>
19918 <row>
19919 <entry><option>pipelining_advertise_hosts</option></entry>
19920 <entry>advertise pipelining to these hosts</entry>
19921 </row>
19922 <row>
19923 <entry><option>tls_advertise_hosts</option></entry>
19924 <entry>advertise TLS to these hosts</entry>
19925 </row>
19926 </tbody>
19927 </tgroup>
19928 </informaltable>
19929 </section>
19930 <section id="SECID114">
19931 <title>Processing messages</title>
19932 <informaltable frame="none">
19933 <tgroup cols="2" colsep="0" rowsep="0">
19934 <colspec colwidth="196pt" align="left"/>
19935 <colspec colwidth="254pt" align="left"/>
19936 <tbody>
19937 <row>
19938 <entry><option>allow_domain_literals</option></entry>
19939 <entry>recognize domain literal syntax</entry>
19940 </row>
19941 <row>
19942 <entry><option>allow_mx_to_ip</option></entry>
19943 <entry>allow MX to point to IP address</entry>
19944 </row>
19945 <row>
19946 <entry><option>allow_utf8_domains</option></entry>
19947 <entry>in addresses</entry>
19948 </row>
19949 <row>
19950 <entry><option>check_rfc2047_length</option></entry>
19951 <entry>check length of RFC 2047 <quote>encoded words</quote></entry>
19952 </row>
19953 <row>
19954 <entry><option>delivery_date_remove</option></entry>
19955 <entry>from incoming messages</entry>
19956 </row>
19957 <row>
19958 <entry><option>envelope_to_remove</option></entry>
19959 <entry>from incoming messages</entry>
19960 </row>
19961 <row>
19962 <entry><option>extract_addresses_remove_arguments</option></entry>
19963 <entry>affects <option>-t</option> processing</entry>
19964 </row>
19965 <row>
19966 <entry><option>headers_charset</option></entry>
19967 <entry>default for translations</entry>
19968 </row>
19969 <row>
19970 <entry><option>qualify_domain</option></entry>
19971 <entry>default for senders</entry>
19972 </row>
19973 <row>
19974 <entry><option>qualify_recipient</option></entry>
19975 <entry>default for recipients</entry>
19976 </row>
19977 <row>
19978 <entry><option>return_path_remove</option></entry>
19979 <entry>from incoming messages</entry>
19980 </row>
19981 <row>
19982 <entry><option>strip_excess_angle_brackets</option></entry>
19983 <entry>in addresses</entry>
19984 </row>
19985 <row>
19986 <entry><option>strip_trailing_dot</option></entry>
19987 <entry>at end of addresses</entry>
19988 </row>
19989 <row>
19990 <entry><option>untrusted_set_sender</option></entry>
19991 <entry>untrusted can set envelope sender</entry>
19992 </row>
19993 </tbody>
19994 </tgroup>
19995 </informaltable>
19996 </section>
19997 <section id="SECID115">
19998 <title>System filter</title>
19999 <informaltable frame="none">
20000 <tgroup cols="2" colsep="0" rowsep="0">
20001 <colspec colwidth="196pt" align="left"/>
20002 <colspec colwidth="254pt" align="left"/>
20003 <tbody>
20004 <row>
20005 <entry><option>system_filter</option></entry>
20006 <entry>locate system filter</entry>
20007 </row>
20008 <row>
20009 <entry><option>system_filter_directory_transport</option></entry>
20010 <entry>transport for delivery to a directory</entry>
20011 </row>
20012 <row>
20013 <entry><option>system_filter_file_transport</option></entry>
20014 <entry>transport for delivery to a file</entry>
20015 </row>
20016 <row>
20017 <entry><option>system_filter_group</option></entry>
20018 <entry>group for filter running</entry>
20019 </row>
20020 <row>
20021 <entry><option>system_filter_pipe_transport</option></entry>
20022 <entry>transport for delivery to a pipe</entry>
20023 </row>
20024 <row>
20025 <entry><option>system_filter_reply_transport</option></entry>
20026 <entry>transport for autoreply delivery</entry>
20027 </row>
20028 <row>
20029 <entry><option>system_filter_user</option></entry>
20030 <entry>user for filter running</entry>
20031 </row>
20032 </tbody>
20033 </tgroup>
20034 </informaltable>
20035 </section>
20036 <section id="SECID116">
20037 <title>Routing and delivery</title>
20038 <informaltable frame="none">
20039 <tgroup cols="2" colsep="0" rowsep="0">
20040 <colspec colwidth="196pt" align="left"/>
20041 <colspec colwidth="254pt" align="left"/>
20042 <tbody>
20043 <row>
20044 <entry><option>disable_ipv6</option></entry>
20045 <entry>do no IPv6 processing</entry>
20046 </row>
20047 <row>
20048 <entry><option>dns_again_means_nonexist</option></entry>
20049 <entry>for broken domains</entry>
20050 </row>
20051 <row>
20052 <entry><option>dns_check_names_pattern</option></entry>
20053 <entry>pre-DNS syntax check</entry>
20054 </row>
20055 <row>
20056 <entry><option>dns_ipv4_lookup</option></entry>
20057 <entry>only v4 lookup for these domains</entry>
20058 </row>
20059 <row>
20060 <entry><option>dns_retrans</option></entry>
20061 <entry>parameter for resolver</entry>
20062 </row>
20063 <row>
20064 <entry><option>dns_retry</option></entry>
20065 <entry>parameter for resolver</entry>
20066 </row>
20067 <row>
20068 <entry><option>hold_domains</option></entry>
20069 <entry>hold delivery for these domains</entry>
20070 </row>
20071 <row>
20072 <entry><option>local_interfaces</option></entry>
20073 <entry>for routing checks</entry>
20074 </row>
20075 <row>
20076 <entry><option>queue_domains</option></entry>
20077 <entry>no immediate delivery for these</entry>
20078 </row>
20079 <row>
20080 <entry><option>queue_only</option></entry>
20081 <entry>no immediate delivery at all</entry>
20082 </row>
20083 <row>
20084 <entry><option>queue_only_file</option></entry>
20085 <entry>no immediate delivery if file exists</entry>
20086 </row>
20087 <row>
20088 <entry><option>queue_only_load</option></entry>
20089 <entry>no immediate delivery if load is high</entry>
20090 </row>
20091 <row>
20092 <entry><option>queue_only_load_latch</option></entry>
20093 <entry>don&#x2019;t re-evaluate load for each message</entry>
20094 </row>
20095 <row>
20096 <entry><option>queue_only_override</option></entry>
20097 <entry>allow command line to override</entry>
20098 </row>
20099 <row>
20100 <entry><option>queue_run_in_order</option></entry>
20101 <entry>order of arrival</entry>
20102 </row>
20103 <row>
20104 <entry><option>queue_run_max</option></entry>
20105 <entry>of simultaneous queue runners</entry>
20106 </row>
20107 <row>
20108 <entry><option>queue_smtp_domains</option></entry>
20109 <entry>no immediate SMTP delivery for these</entry>
20110 </row>
20111 <row>
20112 <entry><option>remote_max_parallel</option></entry>
20113 <entry>parallel SMTP delivery per message</entry>
20114 </row>
20115 <row>
20116 <entry><option>remote_sort_domains</option></entry>
20117 <entry>order of remote deliveries</entry>
20118 </row>
20119 <row>
20120 <entry><option>retry_data_expire</option></entry>
20121 <entry>timeout for retry data</entry>
20122 </row>
20123 <row>
20124 <entry><option>retry_interval_max</option></entry>
20125 <entry>safety net for retry rules</entry>
20126 </row>
20127 </tbody>
20128 </tgroup>
20129 </informaltable>
20130 </section>
20131 <section id="SECID117">
20132 <title>Bounce and warning messages</title>
20133 <informaltable frame="none">
20134 <tgroup cols="2" colsep="0" rowsep="0">
20135 <colspec colwidth="196pt" align="left"/>
20136 <colspec colwidth="254pt" align="left"/>
20137 <tbody>
20138 <row>
20139 <entry><option>bounce_message_file</option></entry>
20140 <entry>content of bounce</entry>
20141 </row>
20142 <row>
20143 <entry><option>bounce_message_text</option></entry>
20144 <entry>content of bounce</entry>
20145 </row>
20146 <row>
20147 <entry><option>bounce_return_body</option></entry>
20148 <entry>include body if returning message</entry>
20149 </row>
20150 <row>
20151 <entry><option>bounce_return_message</option></entry>
20152 <entry>include original message in bounce</entry>
20153 </row>
20154 <row>
20155 <entry><option>bounce_return_size_limit</option></entry>
20156 <entry>limit on returned message</entry>
20157 </row>
20158 <row>
20159 <entry><option>bounce_sender_authentication</option></entry>
20160 <entry>send authenticated sender with bounce</entry>
20161 </row>
20162 <row>
20163 <entry><option>dsn_from</option></entry>
20164 <entry>set <emphasis>From:</emphasis> contents in bounces</entry>
20165 </row>
20166 <row>
20167 <entry><option>errors_copy</option></entry>
20168 <entry>copy bounce messages</entry>
20169 </row>
20170 <row>
20171 <entry><option>errors_reply_to</option></entry>
20172 <entry><emphasis>Reply-to:</emphasis> in bounces</entry>
20173 </row>
20174 <row>
20175 <entry><option>delay_warning</option></entry>
20176 <entry>time schedule</entry>
20177 </row>
20178 <row>
20179 <entry><option>delay_warning_condition</option></entry>
20180 <entry>condition for warning messages</entry>
20181 </row>
20182 <row>
20183 <entry><option>ignore_bounce_errors_after</option></entry>
20184 <entry>discard undeliverable bounces</entry>
20185 </row>
20186 <row>
20187 <entry><option>smtp_return_error_details</option></entry>
20188 <entry>give detail on rejections</entry>
20189 </row>
20190 <row>
20191 <entry><option>warn_message_file</option></entry>
20192 <entry>content of warning message</entry>
20193 </row>
20194 </tbody>
20195 </tgroup>
20196 </informaltable>
20197 </section>
20198 <section id="SECTalomo">
20199 <title>Alphabetical list of main options</title>
20200 <para>
20201 Those options that undergo string expansion before use are marked with
20202 &dagger;.
20203 </para>
20204 <para>
20205 <indexterm role="option">
20206 <primary><option>accept_8bitmime</option></primary>
20207 </indexterm>
20208 </para>
20209 <informaltable frame="all">
20210 <tgroup cols="4" colsep="0" rowsep="0">
20211 <colspec colwidth="8*" align="left"/>
20212 <colspec colwidth="6*" align="center"/>
20213 <colspec colwidth="6*" align="center"/>
20214 <colspec colwidth="6*" align="right"/>
20215 <tbody>
20216 <row>
20217 <entry><option>accept_8bitmime</option></entry>
20218 <entry>Use: <emphasis>main</emphasis></entry>
20219 <entry>Type: <emphasis>boolean</emphasis></entry>
20220 <entry>Default: <emphasis>false</emphasis></entry>
20221 </row>
20222 </tbody>
20223 </tgroup>
20224 </informaltable>
20225 <para>
20226 <indexterm role="concept">
20227 <primary>8BITMIME</primary>
20228 </indexterm>
20229 <indexterm role="concept">
20230 <primary>8-bit characters</primary>
20231 </indexterm>
20232 This option causes Exim to send 8BITMIME in its response to an SMTP
20233 EHLO command, and to accept the BODY= parameter on MAIL commands.
20234 However, though Exim is 8-bit clean, it is not a protocol converter, and it
20235 takes no steps to do anything special with messages received by this route.
20236 Consequently, this option is turned off by default.
20237 </para>
20238 <para>
20239 <indexterm role="option">
20240 <primary><option>acl_not_smtp</option></primary>
20241 </indexterm>
20242 </para>
20243 <informaltable frame="all">
20244 <tgroup cols="4" colsep="0" rowsep="0">
20245 <colspec colwidth="8*" align="left"/>
20246 <colspec colwidth="6*" align="center"/>
20247 <colspec colwidth="6*" align="center"/>
20248 <colspec colwidth="6*" align="right"/>
20249 <tbody>
20250 <row>
20251 <entry><option>acl_not_smtp</option></entry>
20252 <entry>Use: <emphasis>main</emphasis></entry>
20253 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20254 <entry>Default: <emphasis>unset</emphasis></entry>
20255 </row>
20256 </tbody>
20257 </tgroup>
20258 </informaltable>
20259 <para>
20260 <indexterm role="concept">
20261 <primary>access control lists (ACLs)</primary>
20262 <secondary>for non-SMTP messages</secondary>
20263 </indexterm>
20264 <indexterm role="concept">
20265 <primary>non-SMTP messages</primary>
20266 <secondary>ACLs for</secondary>
20267 </indexterm>
20268 This option defines the ACL that is run when a non-SMTP message has been
20269 read and is on the point of being accepted. See chapter <xref linkend="CHAPACL"/> for
20270 further details.
20271 </para>
20272 <para>
20273 <indexterm role="option">
20274 <primary><option>acl_not_smtp_mime</option></primary>
20275 </indexterm>
20276 </para>
20277 <informaltable frame="all">
20278 <tgroup cols="4" colsep="0" rowsep="0">
20279 <colspec colwidth="8*" align="left"/>
20280 <colspec colwidth="6*" align="center"/>
20281 <colspec colwidth="6*" align="center"/>
20282 <colspec colwidth="6*" align="right"/>
20283 <tbody>
20284 <row>
20285 <entry><option>acl_not_smtp_mime</option></entry>
20286 <entry>Use: <emphasis>main</emphasis></entry>
20287 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20288 <entry>Default: <emphasis>unset</emphasis></entry>
20289 </row>
20290 </tbody>
20291 </tgroup>
20292 </informaltable>
20293 <para>
20294 This option defines the ACL that is run for individual MIME parts of non-SMTP
20295 messages. It operates in exactly the same way as <option>acl_smtp_mime</option> operates for
20296 SMTP messages.
20297 </para>
20298 <para>
20299 <indexterm role="option">
20300 <primary><option>acl_not_smtp_start</option></primary>
20301 </indexterm>
20302 </para>
20303 <informaltable frame="all">
20304 <tgroup cols="4" colsep="0" rowsep="0">
20305 <colspec colwidth="8*" align="left"/>
20306 <colspec colwidth="6*" align="center"/>
20307 <colspec colwidth="6*" align="center"/>
20308 <colspec colwidth="6*" align="right"/>
20309 <tbody>
20310 <row>
20311 <entry><option>acl_not_smtp_start</option></entry>
20312 <entry>Use: <emphasis>main</emphasis></entry>
20313 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20314 <entry>Default: <emphasis>unset</emphasis></entry>
20315 </row>
20316 </tbody>
20317 </tgroup>
20318 </informaltable>
20319 <para>
20320 <indexterm role="concept">
20321 <primary>access control lists (ACLs)</primary>
20322 <secondary>at start of non-SMTP message</secondary>
20323 </indexterm>
20324 <indexterm role="concept">
20325 <primary>non-SMTP messages</primary>
20326 <secondary>ACLs for</secondary>
20327 </indexterm>
20328 This option defines the ACL that is run before Exim starts reading a
20329 non-SMTP message. See chapter <xref linkend="CHAPACL"/> for further details.
20330 </para>
20331 <para>
20332 <indexterm role="option">
20333 <primary><option>acl_smtp_auth</option></primary>
20334 </indexterm>
20335 </para>
20336 <informaltable frame="all">
20337 <tgroup cols="4" colsep="0" rowsep="0">
20338 <colspec colwidth="8*" align="left"/>
20339 <colspec colwidth="6*" align="center"/>
20340 <colspec colwidth="6*" align="center"/>
20341 <colspec colwidth="6*" align="right"/>
20342 <tbody>
20343 <row>
20344 <entry><option>acl_smtp_auth</option></entry>
20345 <entry>Use: <emphasis>main</emphasis></entry>
20346 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20347 <entry>Default: <emphasis>unset</emphasis></entry>
20348 </row>
20349 </tbody>
20350 </tgroup>
20351 </informaltable>
20352 <para>
20353 <indexterm role="concept">
20354 <primary>access control lists (ACLs)</primary>
20355 <secondary>setting up for SMTP commands</secondary>
20356 </indexterm>
20357 <indexterm role="concept">
20358 <primary>AUTH</primary>
20359 <secondary>ACL for</secondary>
20360 </indexterm>
20361 This option defines the ACL that is run when an SMTP AUTH command is
20362 received. See chapter <xref linkend="CHAPACL"/> for further details.
20363 </para>
20364 <para>
20365 <indexterm role="option">
20366 <primary><option>acl_smtp_connect</option></primary>
20367 </indexterm>
20368 </para>
20369 <informaltable frame="all">
20370 <tgroup cols="4" colsep="0" rowsep="0">
20371 <colspec colwidth="8*" align="left"/>
20372 <colspec colwidth="6*" align="center"/>
20373 <colspec colwidth="6*" align="center"/>
20374 <colspec colwidth="6*" align="right"/>
20375 <tbody>
20376 <row>
20377 <entry><option>acl_smtp_connect</option></entry>
20378 <entry>Use: <emphasis>main</emphasis></entry>
20379 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20380 <entry>Default: <emphasis>unset</emphasis></entry>
20381 </row>
20382 </tbody>
20383 </tgroup>
20384 </informaltable>
20385 <para>
20386 <indexterm role="concept">
20387 <primary>access control lists (ACLs)</primary>
20388 <secondary>on SMTP connection</secondary>
20389 </indexterm>
20390 This option defines the ACL that is run when an SMTP connection is received.
20391 See chapter <xref linkend="CHAPACL"/> for further details.
20392 </para>
20393 <para>
20394 <indexterm role="option">
20395 <primary><option>acl_smtp_data</option></primary>
20396 </indexterm>
20397 </para>
20398 <informaltable frame="all">
20399 <tgroup cols="4" colsep="0" rowsep="0">
20400 <colspec colwidth="8*" align="left"/>
20401 <colspec colwidth="6*" align="center"/>
20402 <colspec colwidth="6*" align="center"/>
20403 <colspec colwidth="6*" align="right"/>
20404 <tbody>
20405 <row>
20406 <entry><option>acl_smtp_data</option></entry>
20407 <entry>Use: <emphasis>main</emphasis></entry>
20408 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20409 <entry>Default: <emphasis>unset</emphasis></entry>
20410 </row>
20411 </tbody>
20412 </tgroup>
20413 </informaltable>
20414 <para>
20415 <indexterm role="concept">
20416 <primary>DATA</primary>
20417 <secondary>ACL for</secondary>
20418 </indexterm>
20419 This option defines the ACL that is run after an SMTP DATA command has been
20420 processed and the message itself has been received, but before the final
20421 acknowledgment is sent. See chapter <xref linkend="CHAPACL"/> for further details.
20422 </para>
20423 <para>
20424 <indexterm role="option">
20425 <primary><option>acl_smtp_etrn</option></primary>
20426 </indexterm>
20427 </para>
20428 <informaltable frame="all">
20429 <tgroup cols="4" colsep="0" rowsep="0">
20430 <colspec colwidth="8*" align="left"/>
20431 <colspec colwidth="6*" align="center"/>
20432 <colspec colwidth="6*" align="center"/>
20433 <colspec colwidth="6*" align="right"/>
20434 <tbody>
20435 <row>
20436 <entry><option>acl_smtp_etrn</option></entry>
20437 <entry>Use: <emphasis>main</emphasis></entry>
20438 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20439 <entry>Default: <emphasis>unset</emphasis></entry>
20440 </row>
20441 </tbody>
20442 </tgroup>
20443 </informaltable>
20444 <para>
20445 <indexterm role="concept">
20446 <primary>ETRN</primary>
20447 <secondary>ACL for</secondary>
20448 </indexterm>
20449 This option defines the ACL that is run when an SMTP ETRN command is
20450 received. See chapter <xref linkend="CHAPACL"/> for further details.
20451 </para>
20452 <para>
20453 <indexterm role="option">
20454 <primary><option>acl_smtp_expn</option></primary>
20455 </indexterm>
20456 </para>
20457 <informaltable frame="all">
20458 <tgroup cols="4" colsep="0" rowsep="0">
20459 <colspec colwidth="8*" align="left"/>
20460 <colspec colwidth="6*" align="center"/>
20461 <colspec colwidth="6*" align="center"/>
20462 <colspec colwidth="6*" align="right"/>
20463 <tbody>
20464 <row>
20465 <entry><option>acl_smtp_expn</option></entry>
20466 <entry>Use: <emphasis>main</emphasis></entry>
20467 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20468 <entry>Default: <emphasis>unset</emphasis></entry>
20469 </row>
20470 </tbody>
20471 </tgroup>
20472 </informaltable>
20473 <para>
20474 <indexterm role="concept">
20475 <primary>EXPN</primary>
20476 <secondary>ACL for</secondary>
20477 </indexterm>
20478 This option defines the ACL that is run when an SMTP EXPN command is
20479 received. See chapter <xref linkend="CHAPACL"/> for further details.
20480 </para>
20481 <para>
20482 <indexterm role="option">
20483 <primary><option>acl_smtp_helo</option></primary>
20484 </indexterm>
20485 </para>
20486 <informaltable frame="all">
20487 <tgroup cols="4" colsep="0" rowsep="0">
20488 <colspec colwidth="8*" align="left"/>
20489 <colspec colwidth="6*" align="center"/>
20490 <colspec colwidth="6*" align="center"/>
20491 <colspec colwidth="6*" align="right"/>
20492 <tbody>
20493 <row>
20494 <entry><option>acl_smtp_helo</option></entry>
20495 <entry>Use: <emphasis>main</emphasis></entry>
20496 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20497 <entry>Default: <emphasis>unset</emphasis></entry>
20498 </row>
20499 </tbody>
20500 </tgroup>
20501 </informaltable>
20502 <para>
20503 <indexterm role="concept">
20504 <primary>EHLO</primary>
20505 <secondary>ACL for</secondary>
20506 </indexterm>
20507 <indexterm role="concept">
20508 <primary>HELO</primary>
20509 <secondary>ACL for</secondary>
20510 </indexterm>
20511 This option defines the ACL that is run when an SMTP EHLO or HELO
20512 command is received. See chapter <xref linkend="CHAPACL"/> for further details.
20513 </para>
20514 <para>
20515 <indexterm role="option">
20516 <primary><option>acl_smtp_mail</option></primary>
20517 </indexterm>
20518 </para>
20519 <informaltable frame="all">
20520 <tgroup cols="4" colsep="0" rowsep="0">
20521 <colspec colwidth="8*" align="left"/>
20522 <colspec colwidth="6*" align="center"/>
20523 <colspec colwidth="6*" align="center"/>
20524 <colspec colwidth="6*" align="right"/>
20525 <tbody>
20526 <row>
20527 <entry><option>acl_smtp_mail</option></entry>
20528 <entry>Use: <emphasis>main</emphasis></entry>
20529 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20530 <entry>Default: <emphasis>unset</emphasis></entry>
20531 </row>
20532 </tbody>
20533 </tgroup>
20534 </informaltable>
20535 <para>
20536 <indexterm role="concept">
20537 <primary>MAIL</primary>
20538 <secondary>ACL for</secondary>
20539 </indexterm>
20540 This option defines the ACL that is run when an SMTP MAIL command is
20541 received. See chapter <xref linkend="CHAPACL"/> for further details.
20542 </para>
20543 <para>
20544 <indexterm role="option">
20545 <primary><option>acl_smtp_mailauth</option></primary>
20546 </indexterm>
20547 </para>
20548 <informaltable frame="all">
20549 <tgroup cols="4" colsep="0" rowsep="0">
20550 <colspec colwidth="8*" align="left"/>
20551 <colspec colwidth="6*" align="center"/>
20552 <colspec colwidth="6*" align="center"/>
20553 <colspec colwidth="6*" align="right"/>
20554 <tbody>
20555 <row>
20556 <entry><option>acl_smtp_mailauth</option></entry>
20557 <entry>Use: <emphasis>main</emphasis></entry>
20558 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20559 <entry>Default: <emphasis>unset</emphasis></entry>
20560 </row>
20561 </tbody>
20562 </tgroup>
20563 </informaltable>
20564 <para>
20565 <indexterm role="concept">
20566 <primary>AUTH</primary>
20567 <secondary>on MAIL command</secondary>
20568 </indexterm>
20569 This option defines the ACL that is run when there is an AUTH parameter on
20570 a MAIL command. See chapter <xref linkend="CHAPACL"/> for details of ACLs, and chapter
20571 <xref linkend="CHAPSMTPAUTH"/> for details of authentication.
20572 </para>
20573 <para>
20574 <indexterm role="option">
20575 <primary><option>acl_smtp_mime</option></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="6*" align="center"/>
20582 <colspec colwidth="6*" align="center"/>
20583 <colspec colwidth="6*" align="right"/>
20584 <tbody>
20585 <row>
20586 <entry><option>acl_smtp_mime</option></entry>
20587 <entry>Use: <emphasis>main</emphasis></entry>
20588 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20589 <entry>Default: <emphasis>unset</emphasis></entry>
20590 </row>
20591 </tbody>
20592 </tgroup>
20593 </informaltable>
20594 <para>
20595 <indexterm role="concept">
20596 <primary>MIME content scanning</primary>
20597 <secondary>ACL for</secondary>
20598 </indexterm>
20599 This option is available when Exim is built with the content-scanning
20600 extension. It defines the ACL that is run for each MIME part in a message. See
20601 section <xref linkend="SECTscanmimepart"/> for details.
20602 </para>
20603 <para>
20604 <indexterm role="option">
20605 <primary><option>acl_smtp_predata</option></primary>
20606 </indexterm>
20607 </para>
20608 <informaltable frame="all">
20609 <tgroup cols="4" colsep="0" rowsep="0">
20610 <colspec colwidth="8*" align="left"/>
20611 <colspec colwidth="6*" align="center"/>
20612 <colspec colwidth="6*" align="center"/>
20613 <colspec colwidth="6*" align="right"/>
20614 <tbody>
20615 <row>
20616 <entry><option>acl_smtp_predata</option></entry>
20617 <entry>Use: <emphasis>main</emphasis></entry>
20618 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20619 <entry>Default: <emphasis>unset</emphasis></entry>
20620 </row>
20621 </tbody>
20622 </tgroup>
20623 </informaltable>
20624 <para>
20625 This option defines the ACL that is run when an SMTP DATA command is
20626 received, before the message itself is received. See chapter <xref linkend="CHAPACL"/> for
20627 further details.
20628 </para>
20629 <para>
20630 <indexterm role="option">
20631 <primary><option>acl_smtp_quit</option></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="6*" align="center"/>
20638 <colspec colwidth="6*" align="center"/>
20639 <colspec colwidth="6*" align="right"/>
20640 <tbody>
20641 <row>
20642 <entry><option>acl_smtp_quit</option></entry>
20643 <entry>Use: <emphasis>main</emphasis></entry>
20644 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20645 <entry>Default: <emphasis>unset</emphasis></entry>
20646 </row>
20647 </tbody>
20648 </tgroup>
20649 </informaltable>
20650 <para>
20651 <indexterm role="concept">
20652 <primary>QUIT, ACL for</primary>
20653 </indexterm>
20654 This option defines the ACL that is run when an SMTP QUIT command is
20655 received. See chapter <xref linkend="CHAPACL"/> for further details.
20656 </para>
20657 <para>
20658 <indexterm role="option">
20659 <primary><option>acl_smtp_rcpt</option></primary>
20660 </indexterm>
20661 </para>
20662 <informaltable frame="all">
20663 <tgroup cols="4" colsep="0" rowsep="0">
20664 <colspec colwidth="8*" align="left"/>
20665 <colspec colwidth="6*" align="center"/>
20666 <colspec colwidth="6*" align="center"/>
20667 <colspec colwidth="6*" align="right"/>
20668 <tbody>
20669 <row>
20670 <entry><option>acl_smtp_rcpt</option></entry>
20671 <entry>Use: <emphasis>main</emphasis></entry>
20672 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20673 <entry>Default: <emphasis>unset</emphasis></entry>
20674 </row>
20675 </tbody>
20676 </tgroup>
20677 </informaltable>
20678 <para>
20679 <indexterm role="concept">
20680 <primary>RCPT</primary>
20681 <secondary>ACL for</secondary>
20682 </indexterm>
20683 This option defines the ACL that is run when an SMTP RCPT command is
20684 received. See chapter <xref linkend="CHAPACL"/> for further details.
20685 </para>
20686 <para>
20687 <indexterm role="option">
20688 <primary><option>acl_smtp_starttls</option></primary>
20689 </indexterm>
20690 </para>
20691 <informaltable frame="all">
20692 <tgroup cols="4" colsep="0" rowsep="0">
20693 <colspec colwidth="8*" align="left"/>
20694 <colspec colwidth="6*" align="center"/>
20695 <colspec colwidth="6*" align="center"/>
20696 <colspec colwidth="6*" align="right"/>
20697 <tbody>
20698 <row>
20699 <entry><option>acl_smtp_starttls</option></entry>
20700 <entry>Use: <emphasis>main</emphasis></entry>
20701 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20702 <entry>Default: <emphasis>unset</emphasis></entry>
20703 </row>
20704 </tbody>
20705 </tgroup>
20706 </informaltable>
20707 <para>
20708 <indexterm role="concept">
20709 <primary>STARTTLS, ACL for</primary>
20710 </indexterm>
20711 This option defines the ACL that is run when an SMTP STARTTLS command is
20712 received. See chapter <xref linkend="CHAPACL"/> for further details.
20713 </para>
20714 <para>
20715 <indexterm role="option">
20716 <primary><option>acl_smtp_vrfy</option></primary>
20717 </indexterm>
20718 </para>
20719 <informaltable frame="all">
20720 <tgroup cols="4" colsep="0" rowsep="0">
20721 <colspec colwidth="8*" align="left"/>
20722 <colspec colwidth="6*" align="center"/>
20723 <colspec colwidth="6*" align="center"/>
20724 <colspec colwidth="6*" align="right"/>
20725 <tbody>
20726 <row>
20727 <entry><option>acl_smtp_vrfy</option></entry>
20728 <entry>Use: <emphasis>main</emphasis></entry>
20729 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20730 <entry>Default: <emphasis>unset</emphasis></entry>
20731 </row>
20732 </tbody>
20733 </tgroup>
20734 </informaltable>
20735 <para>
20736 <indexterm role="concept">
20737 <primary>VRFY</primary>
20738 <secondary>ACL for</secondary>
20739 </indexterm>
20740 This option defines the ACL that is run when an SMTP VRFY command is
20741 received. See chapter <xref linkend="CHAPACL"/> for further details.
20742 </para>
20743 <para>
20744 <indexterm role="option">
20745 <primary><option>admin_groups</option></primary>
20746 </indexterm>
20747 </para>
20748 <informaltable frame="all">
20749 <tgroup cols="4" colsep="0" rowsep="0">
20750 <colspec colwidth="8*" align="left"/>
20751 <colspec colwidth="6*" align="center"/>
20752 <colspec colwidth="6*" align="center"/>
20753 <colspec colwidth="6*" align="right"/>
20754 <tbody>
20755 <row>
20756 <entry><option>admin_groups</option></entry>
20757 <entry>Use: <emphasis>main</emphasis></entry>
20758 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
20759 <entry>Default: <emphasis>unset</emphasis></entry>
20760 </row>
20761 </tbody>
20762 </tgroup>
20763 </informaltable>
20764 <para>
20765 <indexterm role="concept">
20766 <primary>admin user</primary>
20767 </indexterm>
20768 This option is expanded just once, at the start of Exim&#x2019;s processing. If the
20769 current group or any of the supplementary groups of an Exim caller is in this
20770 colon-separated list, the caller has admin privileges. If all your system
20771 programmers are in a specific group, for example, you can give them all Exim
20772 admin privileges by putting that group in <option>admin_groups</option>. However, this does
20773 not permit them to read Exim&#x2019;s spool files (whose group owner is the Exim gid).
20774 To permit this, you have to add individuals to the Exim group.
20775 </para>
20776 <para>
20777 <indexterm role="option">
20778 <primary><option>allow_domain_literals</option></primary>
20779 </indexterm>
20780 </para>
20781 <informaltable frame="all">
20782 <tgroup cols="4" colsep="0" rowsep="0">
20783 <colspec colwidth="8*" align="left"/>
20784 <colspec colwidth="6*" align="center"/>
20785 <colspec colwidth="6*" align="center"/>
20786 <colspec colwidth="6*" align="right"/>
20787 <tbody>
20788 <row>
20789 <entry><option>allow_domain_literals</option></entry>
20790 <entry>Use: <emphasis>main</emphasis></entry>
20791 <entry>Type: <emphasis>boolean</emphasis></entry>
20792 <entry>Default: <emphasis>false</emphasis></entry>
20793 </row>
20794 </tbody>
20795 </tgroup>
20796 </informaltable>
20797 <para>
20798 <indexterm role="concept">
20799 <primary>domain literal</primary>
20800 </indexterm>
20801 If this option is set, the RFC 2822 domain literal format is permitted in
20802 email addresses. The option is not set by default, because the domain literal
20803 format is not normally required these days, and few people know about it. It
20804 has, however, been exploited by mail abusers.
20805 </para>
20806 <para>
20807 Unfortunately, it seems that some DNS black list maintainers are using this
20808 format to report black listing to postmasters. If you want to accept messages
20809 addressed to your hosts by IP address, you need to set
20810 <option>allow_domain_literals</option> true, and also to add <literal>@[]</literal> to the list of local
20811 domains (defined in the named domain list <option>local_domains</option> in the default
20812 configuration). This <quote>magic string</quote> matches the domain literal form of all
20813 the local host&#x2019;s IP addresses.
20814 </para>
20815 <para>
20816 <indexterm role="option">
20817 <primary><option>allow_mx_to_ip</option></primary>
20818 </indexterm>
20819 </para>
20820 <informaltable frame="all">
20821 <tgroup cols="4" colsep="0" rowsep="0">
20822 <colspec colwidth="8*" align="left"/>
20823 <colspec colwidth="6*" align="center"/>
20824 <colspec colwidth="6*" align="center"/>
20825 <colspec colwidth="6*" align="right"/>
20826 <tbody>
20827 <row>
20828 <entry><option>allow_mx_to_ip</option></entry>
20829 <entry>Use: <emphasis>main</emphasis></entry>
20830 <entry>Type: <emphasis>boolean</emphasis></entry>
20831 <entry>Default: <emphasis>false</emphasis></entry>
20832 </row>
20833 </tbody>
20834 </tgroup>
20835 </informaltable>
20836 <para>
20837 <indexterm role="concept">
20838 <primary>MX record</primary>
20839 <secondary>pointing to IP address</secondary>
20840 </indexterm>
20841 It appears that more and more DNS zone administrators are breaking the rules
20842 and putting domain names that look like IP addresses on the right hand side of
20843 MX records. Exim follows the rules and rejects this, giving an error message
20844 that explains the mis-configuration. However, some other MTAs support this
20845 practice, so to avoid <quote>Why can&#x2019;t Exim do this?</quote> complaints,
20846 <option>allow_mx_to_ip</option> exists, in order to enable this heinous activity. It is not
20847 recommended, except when you have no other choice.
20848 </para>
20849 <para>
20850 <indexterm role="option">
20851 <primary><option>allow_utf8_domains</option></primary>
20852 </indexterm>
20853 </para>
20854 <informaltable frame="all">
20855 <tgroup cols="4" colsep="0" rowsep="0">
20856 <colspec colwidth="8*" align="left"/>
20857 <colspec colwidth="6*" align="center"/>
20858 <colspec colwidth="6*" align="center"/>
20859 <colspec colwidth="6*" align="right"/>
20860 <tbody>
20861 <row>
20862 <entry><option>allow_utf8_domains</option></entry>
20863 <entry>Use: <emphasis>main</emphasis></entry>
20864 <entry>Type: <emphasis>boolean</emphasis></entry>
20865 <entry>Default: <emphasis>false</emphasis></entry>
20866 </row>
20867 </tbody>
20868 </tgroup>
20869 </informaltable>
20870 <para>
20871 <indexterm role="concept">
20872 <primary>domain</primary>
20873 <secondary>UTF-8 characters in</secondary>
20874 </indexterm>
20875 <indexterm role="concept">
20876 <primary>UTF-8</primary>
20877 <secondary>in domain name</secondary>
20878 </indexterm>
20879 Lots of discussion is going on about internationalized domain names. One
20880 camp is strongly in favour of just using UTF-8 characters, and it seems
20881 that at least two other MTAs permit this. This option allows Exim users to
20882 experiment if they wish.
20883 </para>
20884 <para>
20885 If it is set true, Exim&#x2019;s domain parsing function allows valid
20886 UTF-8 multicharacters to appear in domain name components, in addition to
20887 letters, digits, and hyphens. However, just setting this option is not
20888 enough; if you want to look up these domain names in the DNS, you must also
20889 adjust the value of <option>dns_check_names_pattern</option> to match the extended form. A
20890 suitable setting is:
20891 </para>
20892 <literallayout class="monospaced">
20893 dns_check_names_pattern = (?i)^(?&gt;(?(1)\.|())[a-z0-9\xc0-\xff]\
20894   (?&gt;[-a-z0-9\x80-\xff]*[a-z0-9\x80-\xbf])?)+$
20895 </literallayout>
20896 <para>
20897 Alternatively, you can just disable this feature by setting
20898 </para>
20899 <literallayout class="monospaced">
20900 dns_check_names_pattern =
20901 </literallayout>
20902 <para>
20903 That is, set the option to an empty string so that no check is done.
20904 </para>
20905 <para>
20906 <indexterm role="option">
20907 <primary><option>auth_advertise_hosts</option></primary>
20908 </indexterm>
20909 </para>
20910 <informaltable frame="all">
20911 <tgroup cols="4" colsep="0" rowsep="0">
20912 <colspec colwidth="8*" align="left"/>
20913 <colspec colwidth="6*" align="center"/>
20914 <colspec colwidth="6*" align="center"/>
20915 <colspec colwidth="6*" align="right"/>
20916 <tbody>
20917 <row>
20918 <entry><option>auth_advertise_hosts</option></entry>
20919 <entry>Use: <emphasis>main</emphasis></entry>
20920 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
20921 <entry>Default: <emphasis>*</emphasis></entry>
20922 </row>
20923 </tbody>
20924 </tgroup>
20925 </informaltable>
20926 <para>
20927 <indexterm role="concept">
20928 <primary>authentication</primary>
20929 <secondary>advertising</secondary>
20930 </indexterm>
20931 <indexterm role="concept">
20932 <primary>AUTH</primary>
20933 <secondary>advertising</secondary>
20934 </indexterm>
20935 If any server authentication mechanisms are configured, Exim advertises them in
20936 response to an EHLO command only if the calling host matches this list.
20937 Otherwise, Exim does not advertise AUTH.
20938 Exim does not accept AUTH commands from clients to which it has not
20939 advertised the availability of AUTH. The advertising of individual
20940 authentication mechanisms can be controlled by the use of the
20941 <option>server_advertise_condition</option> generic authenticator option on the individual
20942 authenticators. See chapter <xref linkend="CHAPSMTPAUTH"/> for further details.
20943 </para>
20944 <para>
20945 Certain mail clients (for example, Netscape) require the user to provide a name
20946 and password for authentication if AUTH is advertised, even though it may
20947 not be needed (the host may accept messages from hosts on its local LAN without
20948 authentication, for example). The <option>auth_advertise_hosts</option> option can be used
20949 to make these clients more friendly by excluding them from the set of hosts to
20950 which Exim advertises AUTH.
20951 </para>
20952 <para>
20953 <indexterm role="concept">
20954 <primary>AUTH</primary>
20955 <secondary>advertising when encrypted</secondary>
20956 </indexterm>
20957 If you want to advertise the availability of AUTH only when the connection
20958 is encrypted using TLS, you can make use of the fact that the value of this
20959 option is expanded, with a setting like this:
20960 </para>
20961 <literallayout class="monospaced">
20962 auth_advertise_hosts = ${if eq{$tls_cipher}{}{}{*}}
20963 </literallayout>
20964 <para>
20965 <indexterm role="variable">
20966 <primary><varname>$tls_cipher</varname></primary>
20967 </indexterm>
20968 If <varname>$tls_cipher</varname> is empty, the session is not encrypted, and the result of
20969 the expansion is empty, thus matching no hosts. Otherwise, the result of the
20970 expansion is *, which matches all hosts.
20971 </para>
20972 <para>
20973 <indexterm role="option">
20974 <primary><option>auto_thaw</option></primary>
20975 </indexterm>
20976 </para>
20977 <informaltable frame="all">
20978 <tgroup cols="4" colsep="0" rowsep="0">
20979 <colspec colwidth="8*" align="left"/>
20980 <colspec colwidth="6*" align="center"/>
20981 <colspec colwidth="6*" align="center"/>
20982 <colspec colwidth="6*" align="right"/>
20983 <tbody>
20984 <row>
20985 <entry><option>auto_thaw</option></entry>
20986 <entry>Use: <emphasis>main</emphasis></entry>
20987 <entry>Type: <emphasis>time</emphasis></entry>
20988 <entry>Default: <emphasis>0s</emphasis></entry>
20989 </row>
20990 </tbody>
20991 </tgroup>
20992 </informaltable>
20993 <para>
20994 <indexterm role="concept">
20995 <primary>thawing messages</primary>
20996 </indexterm>
20997 <indexterm role="concept">
20998 <primary>unfreezing messages</primary>
20999 </indexterm>
21000 If this option is set to a time greater than zero, a queue runner will try a
21001 new delivery attempt on any frozen message, other than a bounce message, if
21002 this much time has passed since it was frozen. This may result in the message
21003 being re-frozen if nothing has changed since the last attempt. It is a way of
21004 saying <quote>keep on trying, even though there are big problems</quote>.
21005 </para>
21006 <para>
21007 <emphasis role="bold">Note</emphasis>: This is an old option, which predates <option>timeout_frozen_after</option> and
21008 <option>ignore_bounce_errors_after</option>. It is retained for compatibility, but it is not
21009 thought to be very useful any more, and its use should probably be avoided.
21010 </para>
21011 <para>
21012 <indexterm role="option">
21013 <primary><option>av_scanner</option></primary>
21014 </indexterm>
21015 </para>
21016 <informaltable frame="all">
21017 <tgroup cols="4" colsep="0" rowsep="0">
21018 <colspec colwidth="8*" align="left"/>
21019 <colspec colwidth="6*" align="center"/>
21020 <colspec colwidth="6*" align="center"/>
21021 <colspec colwidth="6*" align="right"/>
21022 <tbody>
21023 <row>
21024 <entry><option>av_scanner</option></entry>
21025 <entry>Use: <emphasis>main</emphasis></entry>
21026 <entry>Type: <emphasis>string</emphasis></entry>
21027 <entry>Default: <emphasis>see below</emphasis></entry>
21028 </row>
21029 </tbody>
21030 </tgroup>
21031 </informaltable>
21032 <para>
21033 This option is available if Exim is built with the content-scanning extension.
21034 It specifies which anti-virus scanner to use. The default value is:
21035 </para>
21036 <literallayout class="monospaced">
21037 sophie:/var/run/sophie
21038 </literallayout>
21039 <para>
21040 If the value of <option>av_scanner</option> starts with a dollar character, it is expanded
21041 before use. See section <xref linkend="SECTscanvirus"/> for further details.
21042 </para>
21043 <para>
21044 <indexterm role="option">
21045 <primary><option>bi_command</option></primary>
21046 </indexterm>
21047 </para>
21048 <informaltable frame="all">
21049 <tgroup cols="4" colsep="0" rowsep="0">
21050 <colspec colwidth="8*" align="left"/>
21051 <colspec colwidth="6*" align="center"/>
21052 <colspec colwidth="6*" align="center"/>
21053 <colspec colwidth="6*" align="right"/>
21054 <tbody>
21055 <row>
21056 <entry><option>bi_command</option></entry>
21057 <entry>Use: <emphasis>main</emphasis></entry>
21058 <entry>Type: <emphasis>string</emphasis></entry>
21059 <entry>Default: <emphasis>unset</emphasis></entry>
21060 </row>
21061 </tbody>
21062 </tgroup>
21063 </informaltable>
21064 <para>
21065 <indexterm role="option">
21066 <primary><option>-bi</option></primary>
21067 </indexterm>
21068 This option supplies the name of a command that is run when Exim is called with
21069 the <option>-bi</option> option (see chapter <xref linkend="CHAPcommandline"/>). The string value is
21070 just the command name, it is not a complete command line. If an argument is
21071 required, it must come from the <option>-oA</option> command line option.
21072 </para>
21073 <para>
21074 <indexterm role="option">
21075 <primary><option>bounce_message_file</option></primary>
21076 </indexterm>
21077 </para>
21078 <informaltable frame="all">
21079 <tgroup cols="4" colsep="0" rowsep="0">
21080 <colspec colwidth="8*" align="left"/>
21081 <colspec colwidth="6*" align="center"/>
21082 <colspec colwidth="6*" align="center"/>
21083 <colspec colwidth="6*" align="right"/>
21084 <tbody>
21085 <row>
21086 <entry><option>bounce_message_file</option></entry>
21087 <entry>Use: <emphasis>main</emphasis></entry>
21088 <entry>Type: <emphasis>string</emphasis></entry>
21089 <entry>Default: <emphasis>unset</emphasis></entry>
21090 </row>
21091 </tbody>
21092 </tgroup>
21093 </informaltable>
21094 <para>
21095 <indexterm role="concept">
21096 <primary>bounce message</primary>
21097 <secondary>customizing</secondary>
21098 </indexterm>
21099 <indexterm role="concept">
21100 <primary>customizing</primary>
21101 <secondary>bounce message</secondary>
21102 </indexterm>
21103 This option defines a template file containing paragraphs of text to be used
21104 for constructing bounce messages.  Details of the file&#x2019;s contents are given in
21105 chapter <xref linkend="CHAPemsgcust"/>. See also <option>warn_message_file</option>.
21106 </para>
21107 <para>
21108 <indexterm role="option">
21109 <primary><option>bounce_message_text</option></primary>
21110 </indexterm>
21111 </para>
21112 <informaltable frame="all">
21113 <tgroup cols="4" colsep="0" rowsep="0">
21114 <colspec colwidth="8*" align="left"/>
21115 <colspec colwidth="6*" align="center"/>
21116 <colspec colwidth="6*" align="center"/>
21117 <colspec colwidth="6*" align="right"/>
21118 <tbody>
21119 <row>
21120 <entry><option>bounce_message_text</option></entry>
21121 <entry>Use: <emphasis>main</emphasis></entry>
21122 <entry>Type: <emphasis>string</emphasis></entry>
21123 <entry>Default: <emphasis>unset</emphasis></entry>
21124 </row>
21125 </tbody>
21126 </tgroup>
21127 </informaltable>
21128 <para>
21129 When this option is set, its contents are included in the default bounce
21130 message immediately after <quote>This message was created automatically by mail
21131 delivery software.</quote> It is not used if <option>bounce_message_file</option> is set.
21132 </para>
21133 <para>
21134 <indexterm role="option">
21135 <primary><option>bounce_return_body</option></primary>
21136 </indexterm>
21137 </para>
21138 <informaltable frame="all">
21139 <tgroup cols="4" colsep="0" rowsep="0">
21140 <colspec colwidth="8*" align="left"/>
21141 <colspec colwidth="6*" align="center"/>
21142 <colspec colwidth="6*" align="center"/>
21143 <colspec colwidth="6*" align="right"/>
21144 <tbody>
21145 <row>
21146 <entry><option>bounce_return_body</option></entry>
21147 <entry>Use: <emphasis>main</emphasis></entry>
21148 <entry>Type: <emphasis>boolean</emphasis></entry>
21149 <entry>Default: <emphasis>true</emphasis></entry>
21150 </row>
21151 </tbody>
21152 </tgroup>
21153 </informaltable>
21154 <para>
21155 <indexterm role="concept">
21156 <primary>bounce message</primary>
21157 <secondary>including body</secondary>
21158 </indexterm>
21159 This option controls whether the body of an incoming message is included in a
21160 bounce message when <option>bounce_return_message</option> is true. The default setting
21161 causes the entire message, both header and body, to be returned (subject to the
21162 value of <option>bounce_return_size_limit</option>). If this option is false, only the
21163 message header is included. In the case of a non-SMTP message containing an
21164 error that is detected during reception, only those header lines preceding the
21165 point at which the error was detected are returned.
21166 <indexterm role="concept">
21167 <primary>bounce message</primary>
21168 <secondary>including original</secondary>
21169 </indexterm>
21170 </para>
21171 <para>
21172 <indexterm role="option">
21173 <primary><option>bounce_return_message</option></primary>
21174 </indexterm>
21175 </para>
21176 <informaltable frame="all">
21177 <tgroup cols="4" colsep="0" rowsep="0">
21178 <colspec colwidth="8*" align="left"/>
21179 <colspec colwidth="6*" align="center"/>
21180 <colspec colwidth="6*" align="center"/>
21181 <colspec colwidth="6*" align="right"/>
21182 <tbody>
21183 <row>
21184 <entry><option>bounce_return_message</option></entry>
21185 <entry>Use: <emphasis>main</emphasis></entry>
21186 <entry>Type: <emphasis>boolean</emphasis></entry>
21187 <entry>Default: <emphasis>true</emphasis></entry>
21188 </row>
21189 </tbody>
21190 </tgroup>
21191 </informaltable>
21192 <para>
21193 If this option is set false, none of the original message is included in
21194 bounce messages generated by Exim. See also <option>bounce_return_size_limit</option> and
21195 <option>bounce_return_body</option>.
21196 </para>
21197 <para>
21198 <indexterm role="option">
21199 <primary><option>bounce_return_size_limit</option></primary>
21200 </indexterm>
21201 </para>
21202 <informaltable frame="all">
21203 <tgroup cols="4" colsep="0" rowsep="0">
21204 <colspec colwidth="8*" align="left"/>
21205 <colspec colwidth="6*" align="center"/>
21206 <colspec colwidth="6*" align="center"/>
21207 <colspec colwidth="6*" align="right"/>
21208 <tbody>
21209 <row>
21210 <entry><option>bounce_return_size_limit</option></entry>
21211 <entry>Use: <emphasis>main</emphasis></entry>
21212 <entry>Type: <emphasis>integer</emphasis></entry>
21213 <entry>Default: <emphasis>100K</emphasis></entry>
21214 </row>
21215 </tbody>
21216 </tgroup>
21217 </informaltable>
21218 <para>
21219 <indexterm role="concept">
21220 <primary>size</primary>
21221 <secondary>of bounce, limit</secondary>
21222 </indexterm>
21223 <indexterm role="concept">
21224 <primary>bounce message</primary>
21225 <secondary>size limit</secondary>
21226 </indexterm>
21227 <indexterm role="concept">
21228 <primary>limit</primary>
21229 <secondary>bounce message size</secondary>
21230 </indexterm>
21231 This option sets a limit in bytes on the size of messages that are returned to
21232 senders as part of bounce messages when <option>bounce_return_message</option> is true. The
21233 limit should be less than the value of the global <option>message_size_limit</option> and of
21234 any <option>message_size_limit</option> settings on transports, to allow for the bounce text
21235 that Exim generates. If this option is set to zero there is no limit.
21236 </para>
21237 <para>
21238 When the body of any message that is to be included in a bounce message is
21239 greater than the limit, it is truncated, and a comment pointing this out is
21240 added at the top. The actual cutoff may be greater than the value given, owing
21241 to the use of buffering for transferring the message in chunks (typically 8K in
21242 size). The idea is to save bandwidth on those undeliverable 15-megabyte
21243 messages.
21244 </para>
21245 <para>
21246 <indexterm role="option">
21247 <primary><option>bounce_sender_authentication</option></primary>
21248 </indexterm>
21249 </para>
21250 <informaltable frame="all">
21251 <tgroup cols="4" colsep="0" rowsep="0">
21252 <colspec colwidth="8*" align="left"/>
21253 <colspec colwidth="6*" align="center"/>
21254 <colspec colwidth="6*" align="center"/>
21255 <colspec colwidth="6*" align="right"/>
21256 <tbody>
21257 <row>
21258 <entry><option>bounce_sender_authentication</option></entry>
21259 <entry>Use: <emphasis>main</emphasis></entry>
21260 <entry>Type: <emphasis>string</emphasis></entry>
21261 <entry>Default: <emphasis>unset</emphasis></entry>
21262 </row>
21263 </tbody>
21264 </tgroup>
21265 </informaltable>
21266 <para>
21267 <indexterm role="concept">
21268 <primary>bounce message</primary>
21269 <secondary>sender authentication</secondary>
21270 </indexterm>
21271 <indexterm role="concept">
21272 <primary>authentication</primary>
21273 <secondary>bounce message</secondary>
21274 </indexterm>
21275 <indexterm role="concept">
21276 <primary>AUTH</primary>
21277 <secondary>on bounce message</secondary>
21278 </indexterm>
21279 This option provides an authenticated sender address that is sent with any
21280 bounce messages generated by Exim that are sent over an authenticated SMTP
21281 connection. A typical setting might be:
21282 </para>
21283 <literallayout class="monospaced">
21284 bounce_sender_authentication = mailer-daemon@my.domain.example
21285 </literallayout>
21286 <para>
21287 which would cause bounce messages to be sent using the SMTP command:
21288 </para>
21289 <literallayout class="monospaced">
21290 MAIL FROM:&lt;&gt; AUTH=mailer-daemon@my.domain.example
21291 </literallayout>
21292 <para>
21293 The value of <option>bounce_sender_authentication</option> must always be a complete email
21294 address.
21295 </para>
21296 <para>
21297 <indexterm role="option">
21298 <primary><option>callout_domain_negative_expire</option></primary>
21299 </indexterm>
21300 </para>
21301 <informaltable frame="all">
21302 <tgroup cols="4" colsep="0" rowsep="0">
21303 <colspec colwidth="8*" align="left"/>
21304 <colspec colwidth="6*" align="center"/>
21305 <colspec colwidth="6*" align="center"/>
21306 <colspec colwidth="6*" align="right"/>
21307 <tbody>
21308 <row>
21309 <entry><option>callout_domain_negative_expire</option></entry>
21310 <entry>Use: <emphasis>main</emphasis></entry>
21311 <entry>Type: <emphasis>time</emphasis></entry>
21312 <entry>Default: <emphasis>3h</emphasis></entry>
21313 </row>
21314 </tbody>
21315 </tgroup>
21316 </informaltable>
21317 <para>
21318 <indexterm role="concept">
21319 <primary>caching</primary>
21320 <secondary>callout timeouts</secondary>
21321 </indexterm>
21322 <indexterm role="concept">
21323 <primary>callout</primary>
21324 <secondary>caching timeouts</secondary>
21325 </indexterm>
21326 This option specifies the expiry time for negative callout cache data for a
21327 domain. See section <xref linkend="SECTcallver"/> for details of callout verification, and
21328 section <xref linkend="SECTcallvercache"/> for details of the caching.
21329 </para>
21330 <para>
21331 <indexterm role="option">
21332 <primary><option>callout_domain_positive_expire</option></primary>
21333 </indexterm>
21334 </para>
21335 <informaltable frame="all">
21336 <tgroup cols="4" colsep="0" rowsep="0">
21337 <colspec colwidth="8*" align="left"/>
21338 <colspec colwidth="6*" align="center"/>
21339 <colspec colwidth="6*" align="center"/>
21340 <colspec colwidth="6*" align="right"/>
21341 <tbody>
21342 <row>
21343 <entry><option>callout_domain_positive_expire</option></entry>
21344 <entry>Use: <emphasis>main</emphasis></entry>
21345 <entry>Type: <emphasis>time</emphasis></entry>
21346 <entry>Default: <emphasis>7d</emphasis></entry>
21347 </row>
21348 </tbody>
21349 </tgroup>
21350 </informaltable>
21351 <para>
21352 This option specifies the expiry time for positive callout cache data for a
21353 domain. See section <xref linkend="SECTcallver"/> for details of callout verification, and
21354 section <xref linkend="SECTcallvercache"/> for details of the caching.
21355 </para>
21356 <para>
21357 <indexterm role="option">
21358 <primary><option>callout_negative_expire</option></primary>
21359 </indexterm>
21360 </para>
21361 <informaltable frame="all">
21362 <tgroup cols="4" colsep="0" rowsep="0">
21363 <colspec colwidth="8*" align="left"/>
21364 <colspec colwidth="6*" align="center"/>
21365 <colspec colwidth="6*" align="center"/>
21366 <colspec colwidth="6*" align="right"/>
21367 <tbody>
21368 <row>
21369 <entry><option>callout_negative_expire</option></entry>
21370 <entry>Use: <emphasis>main</emphasis></entry>
21371 <entry>Type: <emphasis>time</emphasis></entry>
21372 <entry>Default: <emphasis>2h</emphasis></entry>
21373 </row>
21374 </tbody>
21375 </tgroup>
21376 </informaltable>
21377 <para>
21378 This option specifies the expiry time for negative callout cache data for an
21379 address. See section <xref linkend="SECTcallver"/> for details of callout verification, and
21380 section <xref linkend="SECTcallvercache"/> for details of the caching.
21381 </para>
21382 <para>
21383 <indexterm role="option">
21384 <primary><option>callout_positive_expire</option></primary>
21385 </indexterm>
21386 </para>
21387 <informaltable frame="all">
21388 <tgroup cols="4" colsep="0" rowsep="0">
21389 <colspec colwidth="8*" align="left"/>
21390 <colspec colwidth="6*" align="center"/>
21391 <colspec colwidth="6*" align="center"/>
21392 <colspec colwidth="6*" align="right"/>
21393 <tbody>
21394 <row>
21395 <entry><option>callout_positive_expire</option></entry>
21396 <entry>Use: <emphasis>main</emphasis></entry>
21397 <entry>Type: <emphasis>time</emphasis></entry>
21398 <entry>Default: <emphasis>24h</emphasis></entry>
21399 </row>
21400 </tbody>
21401 </tgroup>
21402 </informaltable>
21403 <para>
21404 This option specifies the expiry time for positive callout cache data for an
21405 address. See section <xref linkend="SECTcallver"/> for details of callout verification, and
21406 section <xref linkend="SECTcallvercache"/> for details of the caching.
21407 </para>
21408 <para>
21409 <indexterm role="option">
21410 <primary><option>callout_random_local_part</option></primary>
21411 </indexterm>
21412 </para>
21413 <informaltable frame="all">
21414 <tgroup cols="4" colsep="0" rowsep="0">
21415 <colspec colwidth="8*" align="left"/>
21416 <colspec colwidth="6*" align="center"/>
21417 <colspec colwidth="6*" align="center"/>
21418 <colspec colwidth="6*" align="right"/>
21419 <tbody>
21420 <row>
21421 <entry><option>callout_random_local_part</option></entry>
21422 <entry>Use: <emphasis>main</emphasis></entry>
21423 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
21424 <entry>Default: <emphasis>see below</emphasis></entry>
21425 </row>
21426 </tbody>
21427 </tgroup>
21428 </informaltable>
21429 <para>
21430 This option defines the <quote>random</quote> local part that can be used as part of
21431 callout verification. The default value is
21432 </para>
21433 <literallayout class="monospaced">
21434 $primary_host_name-$tod_epoch-testing
21435 </literallayout>
21436 <para>
21437 See section <xref linkend="CALLaddparcall"/> for details of how this value is used.
21438 </para>
21439 <para>
21440 <indexterm role="option">
21441 <primary><option>check_log_inodes</option></primary>
21442 </indexterm>
21443 </para>
21444 <informaltable frame="all">
21445 <tgroup cols="4" colsep="0" rowsep="0">
21446 <colspec colwidth="8*" align="left"/>
21447 <colspec colwidth="6*" align="center"/>
21448 <colspec colwidth="6*" align="center"/>
21449 <colspec colwidth="6*" align="right"/>
21450 <tbody>
21451 <row>
21452 <entry><option>check_log_inodes</option></entry>
21453 <entry>Use: <emphasis>main</emphasis></entry>
21454 <entry>Type: <emphasis>integer</emphasis></entry>
21455 <entry>Default: <emphasis>0</emphasis></entry>
21456 </row>
21457 </tbody>
21458 </tgroup>
21459 </informaltable>
21460 <para>
21461 See <option>check_spool_space</option> below.
21462 </para>
21463 <para>
21464 <indexterm role="option">
21465 <primary><option>check_log_space</option></primary>
21466 </indexterm>
21467 </para>
21468 <informaltable frame="all">
21469 <tgroup cols="4" colsep="0" rowsep="0">
21470 <colspec colwidth="8*" align="left"/>
21471 <colspec colwidth="6*" align="center"/>
21472 <colspec colwidth="6*" align="center"/>
21473 <colspec colwidth="6*" align="right"/>
21474 <tbody>
21475 <row>
21476 <entry><option>check_log_space</option></entry>
21477 <entry>Use: <emphasis>main</emphasis></entry>
21478 <entry>Type: <emphasis>integer</emphasis></entry>
21479 <entry>Default: <emphasis>0</emphasis></entry>
21480 </row>
21481 </tbody>
21482 </tgroup>
21483 </informaltable>
21484 <para>
21485 See <option>check_spool_space</option> below.
21486 </para>
21487 <para>
21488 <indexterm role="option">
21489 <primary><option>check_rfc2047_length</option></primary>
21490 </indexterm>
21491 <indexterm role="concept">
21492 <primary>RFC 2047</primary>
21493 <secondary>disabling length check</secondary>
21494 </indexterm>
21495 <indexterm role="option">
21496 <primary><option>check_rfc2047_length</option></primary>
21497 </indexterm>
21498 </para>
21499 <informaltable frame="all">
21500 <tgroup cols="4" colsep="0" rowsep="0">
21501 <colspec colwidth="8*" align="left"/>
21502 <colspec colwidth="6*" align="center"/>
21503 <colspec colwidth="6*" align="center"/>
21504 <colspec colwidth="6*" align="right"/>
21505 <tbody>
21506 <row>
21507 <entry><option>check_rfc2047_length</option></entry>
21508 <entry>Use: <emphasis>main</emphasis></entry>
21509 <entry>Type: <emphasis>boolean</emphasis></entry>
21510 <entry>Default: <emphasis>true</emphasis></entry>
21511 </row>
21512 </tbody>
21513 </tgroup>
21514 </informaltable>
21515 <para>
21516 RFC 2047 defines a way of encoding non-ASCII characters in headers using a
21517 system of <quote>encoded words</quote>. The RFC specifies a maximum length for an encoded
21518 word; strings to be encoded that exceed this length are supposed to use
21519 multiple encoded words. By default, Exim does not recognize encoded words that
21520 exceed the maximum length. However, it seems that some software, in violation
21521 of the RFC, generates overlong encoded words. If <option>check_rfc2047_length</option> is
21522 set false, Exim recognizes encoded words of any length.
21523 </para>
21524 <para>
21525 <indexterm role="option">
21526 <primary><option>check_spool_inodes</option></primary>
21527 </indexterm>
21528 </para>
21529 <informaltable frame="all">
21530 <tgroup cols="4" colsep="0" rowsep="0">
21531 <colspec colwidth="8*" align="left"/>
21532 <colspec colwidth="6*" align="center"/>
21533 <colspec colwidth="6*" align="center"/>
21534 <colspec colwidth="6*" align="right"/>
21535 <tbody>
21536 <row>
21537 <entry><option>check_spool_inodes</option></entry>
21538 <entry>Use: <emphasis>main</emphasis></entry>
21539 <entry>Type: <emphasis>integer</emphasis></entry>
21540 <entry>Default: <emphasis>0</emphasis></entry>
21541 </row>
21542 </tbody>
21543 </tgroup>
21544 </informaltable>
21545 <para>
21546 See <option>check_spool_space</option> below.
21547 </para>
21548 <para>
21549 <indexterm role="option">
21550 <primary><option>check_spool_space</option></primary>
21551 </indexterm>
21552 </para>
21553 <informaltable frame="all">
21554 <tgroup cols="4" colsep="0" rowsep="0">
21555 <colspec colwidth="8*" align="left"/>
21556 <colspec colwidth="6*" align="center"/>
21557 <colspec colwidth="6*" align="center"/>
21558 <colspec colwidth="6*" align="right"/>
21559 <tbody>
21560 <row>
21561 <entry><option>check_spool_space</option></entry>
21562 <entry>Use: <emphasis>main</emphasis></entry>
21563 <entry>Type: <emphasis>integer</emphasis></entry>
21564 <entry>Default: <emphasis>0</emphasis></entry>
21565 </row>
21566 </tbody>
21567 </tgroup>
21568 </informaltable>
21569 <para>
21570 <indexterm role="concept">
21571 <primary>checking disk space</primary>
21572 </indexterm>
21573 <indexterm role="concept">
21574 <primary>disk space, checking</primary>
21575 </indexterm>
21576 <indexterm role="concept">
21577 <primary>spool directory</primary>
21578 <secondary>checking space</secondary>
21579 </indexterm>
21580 The four <option>check_...</option> options allow for checking of disk resources before a
21581 message is accepted.
21582 </para>
21583 <para>
21584 <indexterm role="variable">
21585 <primary><varname>$log_inodes</varname></primary>
21586 </indexterm>
21587 <indexterm role="variable">
21588 <primary><varname>$log_space</varname></primary>
21589 </indexterm>
21590 <indexterm role="variable">
21591 <primary><varname>$spool_inodes</varname></primary>
21592 </indexterm>
21593 <indexterm role="variable">
21594 <primary><varname>$spool_space</varname></primary>
21595 </indexterm>
21596 When any of these options are set, they apply to all incoming messages. If you
21597 want to apply different checks to different kinds of message, you can do so by
21598 testing the variables <varname>$log_inodes</varname>, <varname>$log_space</varname>, <varname>$spool_inodes</varname>, and
21599 <varname>$spool_space</varname> in an ACL with appropriate additional conditions.
21600 </para>
21601 <para>
21602 <option>check_spool_space</option> and <option>check_spool_inodes</option> check the spool partition if
21603 either value is greater than zero, for example:
21604 </para>
21605 <literallayout class="monospaced">
21606 check_spool_space = 10M
21607 check_spool_inodes = 100
21608 </literallayout>
21609 <para>
21610 The spool partition is the one that contains the directory defined by
21611 SPOOL_DIRECTORY in <filename>Local/Makefile</filename>. It is used for holding messages in
21612 transit.
21613 </para>
21614 <para>
21615 <option>check_log_space</option> and <option>check_log_inodes</option>  check the partition in which log
21616 files are written if either is greater than zero. These should be set only if
21617 <option>log_file_path</option> and <option>spool_directory</option> refer to different partitions.
21618 </para>
21619 <para>
21620 If there is less space or fewer inodes than requested, Exim refuses to accept
21621 incoming mail. In the case of SMTP input this is done by giving a 452 temporary
21622 error response to the MAIL command. If ESMTP is in use and there was a
21623 SIZE parameter on the MAIL command, its value is added to the
21624 <option>check_spool_space</option> value, and the check is performed even if
21625 <option>check_spool_space</option> is zero, unless <option>no_smtp_check_spool_space</option> is set.
21626 </para>
21627 <para>
21628 The values for <option>check_spool_space</option> and <option>check_log_space</option> are held as a
21629 number of kilobytes. If a non-multiple of 1024 is specified, it is rounded up.
21630 </para>
21631 <para>
21632 For non-SMTP input and for batched SMTP input, the test is done at start-up; on
21633 failure a message is written to stderr and Exim exits with a non-zero code, as
21634 it obviously cannot send an error message of any kind.
21635 </para>
21636 <para>
21637 <indexterm role="option">
21638 <primary><option>daemon_smtp_ports</option></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="6*" align="center"/>
21645 <colspec colwidth="6*" align="center"/>
21646 <colspec colwidth="6*" align="right"/>
21647 <tbody>
21648 <row>
21649 <entry><option>daemon_smtp_ports</option></entry>
21650 <entry>Use: <emphasis>main</emphasis></entry>
21651 <entry>Type: <emphasis>string</emphasis></entry>
21652 <entry>Default: <emphasis><literal>smtp</literal></emphasis></entry>
21653 </row>
21654 </tbody>
21655 </tgroup>
21656 </informaltable>
21657 <para>
21658 <indexterm role="concept">
21659 <primary>port</primary>
21660 <secondary>for daemon</secondary>
21661 </indexterm>
21662 <indexterm role="concept">
21663 <primary>TCP/IP</primary>
21664 <secondary>setting listening ports</secondary>
21665 </indexterm>
21666 This option specifies one or more default SMTP ports on which the Exim daemon
21667 listens. See chapter <xref linkend="CHAPinterfaces"/> for details of how it is used. For
21668 backward compatibility, <option>daemon_smtp_port</option> (singular) is a synonym.
21669 </para>
21670 <para>
21671 <indexterm role="option">
21672 <primary><option>daemon_startup_retries</option></primary>
21673 </indexterm>
21674 </para>
21675 <informaltable frame="all">
21676 <tgroup cols="4" colsep="0" rowsep="0">
21677 <colspec colwidth="8*" align="left"/>
21678 <colspec colwidth="6*" align="center"/>
21679 <colspec colwidth="6*" align="center"/>
21680 <colspec colwidth="6*" align="right"/>
21681 <tbody>
21682 <row>
21683 <entry><option>daemon_startup_retries</option></entry>
21684 <entry>Use: <emphasis>main</emphasis></entry>
21685 <entry>Type: <emphasis>integer</emphasis></entry>
21686 <entry>Default: <emphasis>9</emphasis></entry>
21687 </row>
21688 </tbody>
21689 </tgroup>
21690 </informaltable>
21691 <para>
21692 <indexterm role="concept">
21693 <primary>daemon startup, retrying</primary>
21694 </indexterm>
21695 This option, along with <option>daemon_startup_sleep</option>, controls the retrying done by
21696 the daemon at startup when it cannot immediately bind a listening socket
21697 (typically because the socket is already in use): <option>daemon_startup_retries</option>
21698 defines the number of retries after the first failure, and
21699 <option>daemon_startup_sleep</option> defines the length of time to wait between retries.
21700 </para>
21701 <para>
21702 <indexterm role="option">
21703 <primary><option>daemon_startup_sleep</option></primary>
21704 </indexterm>
21705 </para>
21706 <informaltable frame="all">
21707 <tgroup cols="4" colsep="0" rowsep="0">
21708 <colspec colwidth="8*" align="left"/>
21709 <colspec colwidth="6*" align="center"/>
21710 <colspec colwidth="6*" align="center"/>
21711 <colspec colwidth="6*" align="right"/>
21712 <tbody>
21713 <row>
21714 <entry><option>daemon_startup_sleep</option></entry>
21715 <entry>Use: <emphasis>main</emphasis></entry>
21716 <entry>Type: <emphasis>time</emphasis></entry>
21717 <entry>Default: <emphasis>30s</emphasis></entry>
21718 </row>
21719 </tbody>
21720 </tgroup>
21721 </informaltable>
21722 <para>
21723 See <option>daemon_startup_retries</option>.
21724 </para>
21725 <para>
21726 <indexterm role="option">
21727 <primary><option>delay_warning</option></primary>
21728 </indexterm>
21729 </para>
21730 <informaltable frame="all">
21731 <tgroup cols="4" colsep="0" rowsep="0">
21732 <colspec colwidth="8*" align="left"/>
21733 <colspec colwidth="6*" align="center"/>
21734 <colspec colwidth="6*" align="center"/>
21735 <colspec colwidth="6*" align="right"/>
21736 <tbody>
21737 <row>
21738 <entry><option>delay_warning</option></entry>
21739 <entry>Use: <emphasis>main</emphasis></entry>
21740 <entry>Type: <emphasis>time list</emphasis></entry>
21741 <entry>Default: <emphasis>24h</emphasis></entry>
21742 </row>
21743 </tbody>
21744 </tgroup>
21745 </informaltable>
21746 <para>
21747 <indexterm role="concept">
21748 <primary>warning of delay</primary>
21749 </indexterm>
21750 <indexterm role="concept">
21751 <primary>delay warning, specifying</primary>
21752 </indexterm>
21753 When a message is delayed, Exim sends a warning message to the sender at
21754 intervals specified by this option. The data is a colon-separated list of times
21755 after which to send warning messages. If the value of the option is an empty
21756 string or a zero time, no warnings are sent. Up to 10 times may be given. If a
21757 message has been on the queue for longer than the last time, the last interval
21758 between the times is used to compute subsequent warning times. For example,
21759 with
21760 </para>
21761 <literallayout class="monospaced">
21762 delay_warning = 4h:8h:24h
21763 </literallayout>
21764 <para>
21765 the first message is sent after 4 hours, the second after 8 hours, and
21766 the third one after 24 hours. After that, messages are sent every 16 hours,
21767 because that is the interval between the last two times on the list. If you set
21768 just one time, it specifies the repeat interval. For example, with:
21769 </para>
21770 <literallayout class="monospaced">
21771 delay_warning = 6h
21772 </literallayout>
21773 <para>
21774 messages are repeated every six hours. To stop warnings after a given time, set
21775 a very large time at the end of the list. For example:
21776 </para>
21777 <literallayout class="monospaced">
21778 delay_warning = 2h:12h:99d
21779 </literallayout>
21780 <para>
21781 <indexterm role="option">
21782 <primary><option>delay_warning_condition</option></primary>
21783 </indexterm>
21784 </para>
21785 <informaltable frame="all">
21786 <tgroup cols="4" colsep="0" rowsep="0">
21787 <colspec colwidth="8*" align="left"/>
21788 <colspec colwidth="6*" align="center"/>
21789 <colspec colwidth="6*" align="center"/>
21790 <colspec colwidth="6*" align="right"/>
21791 <tbody>
21792 <row>
21793 <entry><option>delay_warning_condition</option></entry>
21794 <entry>Use: <emphasis>main</emphasis></entry>
21795 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
21796 <entry>Default: <emphasis>see below</emphasis></entry>
21797 </row>
21798 </tbody>
21799 </tgroup>
21800 </informaltable>
21801 <para>
21802 <indexterm role="variable">
21803 <primary><varname>$domain</varname></primary>
21804 </indexterm>
21805 The string is expanded at the time a warning message might be sent. If all the
21806 deferred addresses have the same domain, it is set in <varname>$domain</varname> during the
21807 expansion. Otherwise <varname>$domain</varname> is empty. If the result of the expansion is a
21808 forced failure, an empty string, or a string matching any of <quote>0</quote>, <quote>no</quote> or
21809 <quote>false</quote> (the comparison being done caselessly) then the warning message is
21810 not sent. The default is:
21811 </para>
21812 <literallayout class="monospaced">
21813 delay_warning_condition = ${if or {\
21814   { !eq{$h_list-id:$h_list-post:$h_list-subscribe:}{} }\
21815   { match{$h_precedence:}{(?i)bulk|list|junk} }\
21816   { match{$h_auto-submitted:}{(?i)auto-generated|auto-replied} }\
21817   } {no}{yes}}
21818 </literallayout>
21819 <para>
21820 This suppresses the sending of warnings for messages that contain <emphasis>List-ID:</emphasis>,
21821 <emphasis>List-Post:</emphasis>, or <emphasis>List-Subscribe:</emphasis> headers, or have <quote>bulk</quote>, <quote>list</quote> or
21822 <quote>junk</quote> in a <emphasis>Precedence:</emphasis> header, or have <quote>auto-generated</quote> or
21823 <quote>auto-replied</quote> in an <emphasis>Auto-Submitted:</emphasis> header.
21824 </para>
21825 <para>
21826 <indexterm role="option">
21827 <primary><option>deliver_drop_privilege</option></primary>
21828 </indexterm>
21829 </para>
21830 <informaltable frame="all">
21831 <tgroup cols="4" colsep="0" rowsep="0">
21832 <colspec colwidth="8*" align="left"/>
21833 <colspec colwidth="6*" align="center"/>
21834 <colspec colwidth="6*" align="center"/>
21835 <colspec colwidth="6*" align="right"/>
21836 <tbody>
21837 <row>
21838 <entry><option>deliver_drop_privilege</option></entry>
21839 <entry>Use: <emphasis>main</emphasis></entry>
21840 <entry>Type: <emphasis>boolean</emphasis></entry>
21841 <entry>Default: <emphasis>false</emphasis></entry>
21842 </row>
21843 </tbody>
21844 </tgroup>
21845 </informaltable>
21846 <para>
21847 <indexterm role="concept">
21848 <primary>unprivileged delivery</primary>
21849 </indexterm>
21850 <indexterm role="concept">
21851 <primary>delivery</primary>
21852 <secondary>unprivileged</secondary>
21853 </indexterm>
21854 If this option is set true, Exim drops its root privilege at the start of a
21855 delivery process, and runs as the Exim user throughout. This severely restricts
21856 the kinds of local delivery that are possible, but is viable in certain types
21857 of configuration. There is a discussion about the use of root privilege in
21858 chapter <xref linkend="CHAPsecurity"/>.
21859 </para>
21860 <para>
21861 <indexterm role="option">
21862 <primary><option>deliver_queue_load_max</option></primary>
21863 </indexterm>
21864 </para>
21865 <informaltable frame="all">
21866 <tgroup cols="4" colsep="0" rowsep="0">
21867 <colspec colwidth="8*" align="left"/>
21868 <colspec colwidth="6*" align="center"/>
21869 <colspec colwidth="6*" align="center"/>
21870 <colspec colwidth="6*" align="right"/>
21871 <tbody>
21872 <row>
21873 <entry><option>deliver_queue_load_max</option></entry>
21874 <entry>Use: <emphasis>main</emphasis></entry>
21875 <entry>Type: <emphasis>fixed-point</emphasis></entry>
21876 <entry>Default: <emphasis>unset</emphasis></entry>
21877 </row>
21878 </tbody>
21879 </tgroup>
21880 </informaltable>
21881 <para>
21882 <indexterm role="concept">
21883 <primary>load average</primary>
21884 </indexterm>
21885 <indexterm role="concept">
21886 <primary>queue runner</primary>
21887 <secondary>abandoning</secondary>
21888 </indexterm>
21889 When this option is set, a queue run is abandoned if the system load average
21890 becomes greater than the value of the option. The option has no effect on
21891 ancient operating systems on which Exim cannot determine the load average.
21892 See also <option>queue_only_load</option> and <option>smtp_load_reserve</option>.
21893 </para>
21894 <para>
21895 <indexterm role="option">
21896 <primary><option>delivery_date_remove</option></primary>
21897 </indexterm>
21898 </para>
21899 <informaltable frame="all">
21900 <tgroup cols="4" colsep="0" rowsep="0">
21901 <colspec colwidth="8*" align="left"/>
21902 <colspec colwidth="6*" align="center"/>
21903 <colspec colwidth="6*" align="center"/>
21904 <colspec colwidth="6*" align="right"/>
21905 <tbody>
21906 <row>
21907 <entry><option>delivery_date_remove</option></entry>
21908 <entry>Use: <emphasis>main</emphasis></entry>
21909 <entry>Type: <emphasis>boolean</emphasis></entry>
21910 <entry>Default: <emphasis>true</emphasis></entry>
21911 </row>
21912 </tbody>
21913 </tgroup>
21914 </informaltable>
21915 <para>
21916 <indexterm role="concept">
21917 <primary><emphasis>Delivery-date:</emphasis> header line</primary>
21918 </indexterm>
21919 Exim&#x2019;s transports have an option for adding a <emphasis>Delivery-date:</emphasis> header to a
21920 message when it is delivered, in exactly the same way as <emphasis>Return-path:</emphasis> is
21921 handled. <emphasis>Delivery-date:</emphasis> records the actual time of delivery. Such headers
21922 should not be present in incoming messages, and this option causes them to be
21923 removed at the time the message is received, to avoid any problems that might
21924 occur when a delivered message is subsequently sent on to some other recipient.
21925 </para>
21926 <para>
21927 <indexterm role="option">
21928 <primary><option>disable_fsync</option></primary>
21929 </indexterm>
21930 </para>
21931 <informaltable frame="all">
21932 <tgroup cols="4" colsep="0" rowsep="0">
21933 <colspec colwidth="8*" align="left"/>
21934 <colspec colwidth="6*" align="center"/>
21935 <colspec colwidth="6*" align="center"/>
21936 <colspec colwidth="6*" align="right"/>
21937 <tbody>
21938 <row>
21939 <entry><option>disable_fsync</option></entry>
21940 <entry>Use: <emphasis>main</emphasis></entry>
21941 <entry>Type: <emphasis>boolean</emphasis></entry>
21942 <entry>Default: <emphasis>false</emphasis></entry>
21943 </row>
21944 </tbody>
21945 </tgroup>
21946 </informaltable>
21947 <para>
21948 <indexterm role="concept">
21949 <primary><function>fsync()</function>, disabling</primary>
21950 </indexterm>
21951 This option is available only if Exim was built with the compile-time option
21952 ENABLE_DISABLE_FSYNC. When this is not set, a reference to <option>disable_fsync</option> in
21953 a runtime configuration generates an <quote>unknown option</quote> error. You should not
21954 build Exim with ENABLE_DISABLE_FSYNC or set <option>disable_fsync</option> unless you
21955 really, really, really understand what you are doing. <emphasis>No pre-compiled
21956 distributions of Exim should ever make this option available.</emphasis>
21957 </para>
21958 <para>
21959 When <option>disable_fsync</option> is set true, Exim no longer calls <function>fsync()</function> to force
21960 updated files&#x2019; data to be written to disc before continuing. Unexpected events
21961 such as crashes and power outages may cause data to be lost or scrambled.
21962 Here be Dragons. <emphasis role="bold">Beware.</emphasis>
21963 </para>
21964 <para>
21965 <indexterm role="option">
21966 <primary><option>disable_ipv6</option></primary>
21967 </indexterm>
21968 </para>
21969 <informaltable frame="all">
21970 <tgroup cols="4" colsep="0" rowsep="0">
21971 <colspec colwidth="8*" align="left"/>
21972 <colspec colwidth="6*" align="center"/>
21973 <colspec colwidth="6*" align="center"/>
21974 <colspec colwidth="6*" align="right"/>
21975 <tbody>
21976 <row>
21977 <entry><option>disable_ipv6</option></entry>
21978 <entry>Use: <emphasis>main</emphasis></entry>
21979 <entry>Type: <emphasis>boolean</emphasis></entry>
21980 <entry>Default: <emphasis>false</emphasis></entry>
21981 </row>
21982 </tbody>
21983 </tgroup>
21984 </informaltable>
21985 <para>
21986 <indexterm role="concept">
21987 <primary>IPv6</primary>
21988 <secondary>disabling</secondary>
21989 </indexterm>
21990 If this option is set true, even if the Exim binary has IPv6 support, no IPv6
21991 activities take place. AAAA records are never looked up, and any IPv6 addresses
21992 that are listed in <option>local_interfaces</option>, data for the <option>manualroute</option> router,
21993 etc. are ignored. If IP literals are enabled, the <command>ipliteral</command> router declines
21994 to handle IPv6 literal addresses.
21995 </para>
21996 <para>
21997 <indexterm role="option">
21998 <primary><option>dns_again_means_nonexist</option></primary>
21999 </indexterm>
22000 </para>
22001 <informaltable frame="all">
22002 <tgroup cols="4" colsep="0" rowsep="0">
22003 <colspec colwidth="8*" align="left"/>
22004 <colspec colwidth="6*" align="center"/>
22005 <colspec colwidth="6*" align="center"/>
22006 <colspec colwidth="6*" align="right"/>
22007 <tbody>
22008 <row>
22009 <entry><option>dns_again_means_nonexist</option></entry>
22010 <entry>Use: <emphasis>main</emphasis></entry>
22011 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
22012 <entry>Default: <emphasis>unset</emphasis></entry>
22013 </row>
22014 </tbody>
22015 </tgroup>
22016 </informaltable>
22017 <para>
22018 <indexterm role="concept">
22019 <primary>DNS</primary>
22020 <secondary><quote>try again</quote> response; overriding</secondary>
22021 </indexterm>
22022 DNS lookups give a <quote>try again</quote> response for the DNS errors
22023 <quote>non-authoritative host not found</quote> and <quote>SERVERFAIL</quote>. This can cause Exim to
22024 keep trying to deliver a message, or to give repeated temporary errors to
22025 incoming mail. Sometimes the effect is caused by a badly set up name server and
22026 may persist for a long time. If a domain which exhibits this problem matches
22027 anything in <option>dns_again_means_nonexist</option>, it is treated as if it did not exist.
22028 This option should be used with care. You can make it apply to reverse lookups
22029 by a setting such as this:
22030 </para>
22031 <literallayout class="monospaced">
22032 dns_again_means_nonexist = *.in-addr.arpa
22033 </literallayout>
22034 <para>
22035 This option applies to all DNS lookups that Exim does. It also applies when the
22036 <function>gethostbyname()</function> or <function>getipnodebyname()</function> functions give temporary errors,
22037 since these are most likely to be caused by DNS lookup problems. The
22038 <command>dnslookup</command> router has some options of its own for controlling what happens
22039 when lookups for MX or SRV records give temporary errors. These more specific
22040 options are applied after this global option.
22041 </para>
22042 <para>
22043 <indexterm role="option">
22044 <primary><option>dns_check_names_pattern</option></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="6*" align="center"/>
22051 <colspec colwidth="6*" align="center"/>
22052 <colspec colwidth="6*" align="right"/>
22053 <tbody>
22054 <row>
22055 <entry><option>dns_check_names_pattern</option></entry>
22056 <entry>Use: <emphasis>main</emphasis></entry>
22057 <entry>Type: <emphasis>string</emphasis></entry>
22058 <entry>Default: <emphasis>see below</emphasis></entry>
22059 </row>
22060 </tbody>
22061 </tgroup>
22062 </informaltable>
22063 <para>
22064 <indexterm role="concept">
22065 <primary>DNS</primary>
22066 <secondary>pre-check of name syntax</secondary>
22067 </indexterm>
22068 When this option is set to a non-empty string, it causes Exim to check domain
22069 names for characters that are not allowed in host names before handing them to
22070 the DNS resolver, because some resolvers give temporary errors for names that
22071 contain unusual characters. If a domain name contains any unwanted characters,
22072 a <quote>not found</quote> result is forced, and the resolver is not called. The check is
22073 done by matching the domain name against a regular expression, which is the
22074 value of this option. The default pattern is
22075 </para>
22076 <literallayout class="monospaced">
22077 dns_check_names_pattern = \
22078   (?i)^(?&gt;(?(1)\.|())[^\W_](?&gt;[a-z0-9/-]*[^\W_])?)+$
22079 </literallayout>
22080 <para>
22081 which permits only letters, digits, slashes, and hyphens in components, but
22082 they must start and end with a letter or digit. Slashes are not, in fact,
22083 permitted in host names, but they are found in certain NS records (which can be
22084 accessed in Exim by using a <option>dnsdb</option> lookup). If you set
22085 <option>allow_utf8_domains</option>, you must modify this pattern, or set the option to an
22086 empty string.
22087 </para>
22088 <para>
22089 <indexterm role="option">
22090 <primary><option>dns_csa_search_limit</option></primary>
22091 </indexterm>
22092 </para>
22093 <informaltable frame="all">
22094 <tgroup cols="4" colsep="0" rowsep="0">
22095 <colspec colwidth="8*" align="left"/>
22096 <colspec colwidth="6*" align="center"/>
22097 <colspec colwidth="6*" align="center"/>
22098 <colspec colwidth="6*" align="right"/>
22099 <tbody>
22100 <row>
22101 <entry><option>dns_csa_search_limit</option></entry>
22102 <entry>Use: <emphasis>main</emphasis></entry>
22103 <entry>Type: <emphasis>integer</emphasis></entry>
22104 <entry>Default: <emphasis>5</emphasis></entry>
22105 </row>
22106 </tbody>
22107 </tgroup>
22108 </informaltable>
22109 <para>
22110 This option controls the depth of parental searching for CSA SRV records in the
22111 DNS, as described in more detail in section <xref linkend="SECTverifyCSA"/>.
22112 </para>
22113 <para>
22114 <indexterm role="option">
22115 <primary><option>dns_csa_use_reverse</option></primary>
22116 </indexterm>
22117 </para>
22118 <informaltable frame="all">
22119 <tgroup cols="4" colsep="0" rowsep="0">
22120 <colspec colwidth="8*" align="left"/>
22121 <colspec colwidth="6*" align="center"/>
22122 <colspec colwidth="6*" align="center"/>
22123 <colspec colwidth="6*" align="right"/>
22124 <tbody>
22125 <row>
22126 <entry><option>dns_csa_use_reverse</option></entry>
22127 <entry>Use: <emphasis>main</emphasis></entry>
22128 <entry>Type: <emphasis>boolean</emphasis></entry>
22129 <entry>Default: <emphasis>true</emphasis></entry>
22130 </row>
22131 </tbody>
22132 </tgroup>
22133 </informaltable>
22134 <para>
22135 This option controls whether or not an IP address, given as a CSA domain, is
22136 reversed and looked up in the reverse DNS, as described in more detail in
22137 section <xref linkend="SECTverifyCSA"/>.
22138 </para>
22139 <para>
22140 <indexterm role="option">
22141 <primary><option>dns_ipv4_lookup</option></primary>
22142 </indexterm>
22143 </para>
22144 <informaltable frame="all">
22145 <tgroup cols="4" colsep="0" rowsep="0">
22146 <colspec colwidth="8*" align="left"/>
22147 <colspec colwidth="6*" align="center"/>
22148 <colspec colwidth="6*" align="center"/>
22149 <colspec colwidth="6*" align="right"/>
22150 <tbody>
22151 <row>
22152 <entry><option>dns_ipv4_lookup</option></entry>
22153 <entry>Use: <emphasis>main</emphasis></entry>
22154 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
22155 <entry>Default: <emphasis>unset</emphasis></entry>
22156 </row>
22157 </tbody>
22158 </tgroup>
22159 </informaltable>
22160 <para>
22161 <indexterm role="concept">
22162 <primary>IPv6</primary>
22163 <secondary>DNS lookup for AAAA records</secondary>
22164 </indexterm>
22165 <indexterm role="concept">
22166 <primary>DNS</primary>
22167 <secondary>IPv6 lookup for AAAA records</secondary>
22168 </indexterm>
22169 When Exim is compiled with IPv6 support and <option>disable_ipv6</option> is not set, it
22170 looks for IPv6 address records (AAAA records) as well as IPv4 address records
22171 (A records) when trying to find IP addresses for hosts, unless the host&#x2019;s
22172 domain matches this list.
22173 </para>
22174 <para>
22175 This is a fudge to help with name servers that give big delays or otherwise do
22176 not work for the AAAA record type. In due course, when the world&#x2019;s name
22177 servers have all been upgraded, there should be no need for this option.
22178 </para>
22179 <para>
22180 <indexterm role="option">
22181 <primary><option>dns_retrans</option></primary>
22182 </indexterm>
22183 </para>
22184 <informaltable frame="all">
22185 <tgroup cols="4" colsep="0" rowsep="0">
22186 <colspec colwidth="8*" align="left"/>
22187 <colspec colwidth="6*" align="center"/>
22188 <colspec colwidth="6*" align="center"/>
22189 <colspec colwidth="6*" align="right"/>
22190 <tbody>
22191 <row>
22192 <entry><option>dns_retrans</option></entry>
22193 <entry>Use: <emphasis>main</emphasis></entry>
22194 <entry>Type: <emphasis>time</emphasis></entry>
22195 <entry>Default: <emphasis>0s</emphasis></entry>
22196 </row>
22197 </tbody>
22198 </tgroup>
22199 </informaltable>
22200 <para>
22201 <indexterm role="concept">
22202 <primary>DNS</primary>
22203 <secondary>resolver options</secondary>
22204 </indexterm>
22205 The options <option>dns_retrans</option> and <option>dns_retry</option> can be used to set the
22206 retransmission and retry parameters for DNS lookups. Values of zero (the
22207 defaults) leave the system default settings unchanged. The first value is the
22208 time between retries, and the second is the number of retries. It isn&#x2019;t
22209 totally clear exactly how these settings affect the total time a DNS lookup may
22210 take. I haven&#x2019;t found any documentation about timeouts on DNS lookups; these
22211 parameter values are available in the external resolver interface structure,
22212 but nowhere does it seem to describe how they are used or what you might want
22213 to set in them.
22214 </para>
22215 <para>
22216 <indexterm role="option">
22217 <primary><option>dns_retry</option></primary>
22218 </indexterm>
22219 </para>
22220 <informaltable frame="all">
22221 <tgroup cols="4" colsep="0" rowsep="0">
22222 <colspec colwidth="8*" align="left"/>
22223 <colspec colwidth="6*" align="center"/>
22224 <colspec colwidth="6*" align="center"/>
22225 <colspec colwidth="6*" align="right"/>
22226 <tbody>
22227 <row>
22228 <entry><option>dns_retry</option></entry>
22229 <entry>Use: <emphasis>main</emphasis></entry>
22230 <entry>Type: <emphasis>integer</emphasis></entry>
22231 <entry>Default: <emphasis>0</emphasis></entry>
22232 </row>
22233 </tbody>
22234 </tgroup>
22235 </informaltable>
22236 <para>
22237 See <option>dns_retrans</option> above.
22238 </para>
22239 <para>
22240 <indexterm role="option">
22241 <primary><option>drop_cr</option></primary>
22242 </indexterm>
22243 </para>
22244 <informaltable frame="all">
22245 <tgroup cols="4" colsep="0" rowsep="0">
22246 <colspec colwidth="8*" align="left"/>
22247 <colspec colwidth="6*" align="center"/>
22248 <colspec colwidth="6*" align="center"/>
22249 <colspec colwidth="6*" align="right"/>
22250 <tbody>
22251 <row>
22252 <entry><option>drop_cr</option></entry>
22253 <entry>Use: <emphasis>main</emphasis></entry>
22254 <entry>Type: <emphasis>boolean</emphasis></entry>
22255 <entry>Default: <emphasis>false</emphasis></entry>
22256 </row>
22257 </tbody>
22258 </tgroup>
22259 </informaltable>
22260 <para>
22261 This is an obsolete option that is now a no-op. It used to affect the way Exim
22262 handled CR and LF characters in incoming messages. What happens now is
22263 described in section <xref linkend="SECTlineendings"/>.
22264 </para>
22265 <para>
22266 <indexterm role="option">
22267 <primary><option>dsn_from</option></primary>
22268 </indexterm>
22269 </para>
22270 <informaltable frame="all">
22271 <tgroup cols="4" colsep="0" rowsep="0">
22272 <colspec colwidth="8*" align="left"/>
22273 <colspec colwidth="6*" align="center"/>
22274 <colspec colwidth="6*" align="center"/>
22275 <colspec colwidth="6*" align="right"/>
22276 <tbody>
22277 <row>
22278 <entry><option>dsn_from</option></entry>
22279 <entry>Use: <emphasis>main</emphasis></entry>
22280 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
22281 <entry>Default: <emphasis>see below</emphasis></entry>
22282 </row>
22283 </tbody>
22284 </tgroup>
22285 </informaltable>
22286 <para>
22287 <indexterm role="concept">
22288 <primary><emphasis>From:</emphasis> header line</primary>
22289 <secondary>in bounces</secondary>
22290 </indexterm>
22291 <indexterm role="concept">
22292 <primary>bounce messages</primary>
22293 <secondary><emphasis>From:</emphasis> line, specifying</secondary>
22294 </indexterm>
22295 This option can be used to vary the contents of <emphasis>From:</emphasis> header lines in
22296 bounces and other automatically generated messages (<quote>Delivery Status
22297 Notifications</quote> &ndash; hence the name of the option). The default setting is:
22298 </para>
22299 <literallayout class="monospaced">
22300 dsn_from = Mail Delivery System &lt;Mailer-Daemon@$qualify_domain&gt;
22301 </literallayout>
22302 <para>
22303 The value is expanded every time it is needed. If the expansion fails, a
22304 panic is logged, and the default value is used.
22305 </para>
22306 <para>
22307 <indexterm role="option">
22308 <primary><option>envelope_to_remove</option></primary>
22309 </indexterm>
22310 </para>
22311 <informaltable frame="all">
22312 <tgroup cols="4" colsep="0" rowsep="0">
22313 <colspec colwidth="8*" align="left"/>
22314 <colspec colwidth="6*" align="center"/>
22315 <colspec colwidth="6*" align="center"/>
22316 <colspec colwidth="6*" align="right"/>
22317 <tbody>
22318 <row>
22319 <entry><option>envelope_to_remove</option></entry>
22320 <entry>Use: <emphasis>main</emphasis></entry>
22321 <entry>Type: <emphasis>boolean</emphasis></entry>
22322 <entry>Default: <emphasis>true</emphasis></entry>
22323 </row>
22324 </tbody>
22325 </tgroup>
22326 </informaltable>
22327 <para>
22328 <indexterm role="concept">
22329 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
22330 </indexterm>
22331 Exim&#x2019;s transports have an option for adding an <emphasis>Envelope-to:</emphasis> header to a
22332 message when it is delivered, in exactly the same way as <emphasis>Return-path:</emphasis> is
22333 handled. <emphasis>Envelope-to:</emphasis> records the original recipient address from the
22334 messages&#x2019;s envelope that caused the delivery to happen. Such headers should not
22335 be present in incoming messages, and this option causes them to be removed at
22336 the time the message is received, to avoid any problems that might occur when a
22337 delivered message is subsequently sent on to some other recipient.
22338 </para>
22339 <para>
22340 <indexterm role="option">
22341 <primary><option>errors_copy</option></primary>
22342 </indexterm>
22343 </para>
22344 <informaltable frame="all">
22345 <tgroup cols="4" colsep="0" rowsep="0">
22346 <colspec colwidth="8*" align="left"/>
22347 <colspec colwidth="6*" align="center"/>
22348 <colspec colwidth="6*" align="center"/>
22349 <colspec colwidth="6*" align="right"/>
22350 <tbody>
22351 <row>
22352 <entry><option>errors_copy</option></entry>
22353 <entry>Use: <emphasis>main</emphasis></entry>
22354 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
22355 <entry>Default: <emphasis>unset</emphasis></entry>
22356 </row>
22357 </tbody>
22358 </tgroup>
22359 </informaltable>
22360 <para>
22361 <indexterm role="concept">
22362 <primary>bounce message</primary>
22363 <secondary>copy to other address</secondary>
22364 </indexterm>
22365 <indexterm role="concept">
22366 <primary>copy of bounce message</primary>
22367 </indexterm>
22368 Setting this option causes Exim to send bcc copies of bounce messages that it
22369 generates to other addresses. <emphasis role="bold">Note</emphasis>: This does not apply to bounce messages
22370 coming from elsewhere. The value of the option is a colon-separated list of
22371 items. Each item consists of a pattern, terminated by white space, followed by
22372 a comma-separated list of email addresses. If a pattern contains spaces, it
22373 must be enclosed in double quotes.
22374 </para>
22375 <para>
22376 Each pattern is processed in the same way as a single item in an address list
22377 (see section <xref linkend="SECTaddresslist"/>). When a pattern matches the recipient of
22378 the bounce message, the message is copied to the addresses on the list. The
22379 items are scanned in order, and once a matching one is found, no further items
22380 are examined. For example:
22381 </para>
22382 <literallayout class="monospaced">
22383 errors_copy = spqr@mydomain   postmaster@mydomain.example :\
22384               rqps@mydomain   hostmaster@mydomain.example,\
22385                               postmaster@mydomain.example
22386 </literallayout>
22387 <para>
22388 <indexterm role="variable">
22389 <primary><varname>$domain</varname></primary>
22390 </indexterm>
22391 <indexterm role="variable">
22392 <primary><varname>$local_part</varname></primary>
22393 </indexterm>
22394 The address list is expanded before use. The expansion variables <varname>$local_part</varname>
22395 and <varname>$domain</varname> are set from the original recipient of the error message, and if
22396 there was any wildcard matching in the pattern, the expansion
22397 <indexterm role="concept">
22398 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
22399 <secondary>in <option>errors_copy</option></secondary>
22400 </indexterm>
22401 variables <varname>$0</varname>, <varname>$1</varname>, etc. are set in the normal way.
22402 </para>
22403 <para>
22404 <indexterm role="option">
22405 <primary><option>errors_reply_to</option></primary>
22406 </indexterm>
22407 </para>
22408 <informaltable frame="all">
22409 <tgroup cols="4" colsep="0" rowsep="0">
22410 <colspec colwidth="8*" align="left"/>
22411 <colspec colwidth="6*" align="center"/>
22412 <colspec colwidth="6*" align="center"/>
22413 <colspec colwidth="6*" align="right"/>
22414 <tbody>
22415 <row>
22416 <entry><option>errors_reply_to</option></entry>
22417 <entry>Use: <emphasis>main</emphasis></entry>
22418 <entry>Type: <emphasis>string</emphasis></entry>
22419 <entry>Default: <emphasis>unset</emphasis></entry>
22420 </row>
22421 </tbody>
22422 </tgroup>
22423 </informaltable>
22424 <para>
22425 <indexterm role="concept">
22426 <primary>bounce message</primary>
22427 <secondary><emphasis>Reply-to:</emphasis> in</secondary>
22428 </indexterm>
22429 By default, Exim&#x2019;s bounce and delivery warning messages contain the header line
22430 </para>
22431 <literallayout>
22432 <literal>From: Mail Delivery System &lt;Mailer-Daemon@</literal><emphasis>qualify-domain</emphasis><literal>&gt;</literal>
22433 </literallayout>
22434 <para>
22435 <indexterm role="option">
22436 <primary><option>quota_warn_message</option></primary>
22437 </indexterm>
22438 where <emphasis>qualify-domain</emphasis> is the value of the <option>qualify_domain</option> option.
22439 A warning message that is generated by the <option>quota_warn_message</option> option in an
22440 <command>appendfile</command> transport may contain its own <emphasis>From:</emphasis> header line that
22441 overrides the default.
22442 </para>
22443 <para>
22444 Experience shows that people reply to bounce messages. If the
22445 <option>errors_reply_to</option> option is set, a <emphasis>Reply-To:</emphasis> header is added to bounce
22446 and warning messages. For example:
22447 </para>
22448 <literallayout class="monospaced">
22449 errors_reply_to = postmaster@my.domain.example
22450 </literallayout>
22451 <para>
22452 The value of the option is not expanded. It must specify a valid RFC 2822
22453 address. However, if a warning message that is generated by the
22454 <option>quota_warn_message</option> option in an <command>appendfile</command> transport contain its
22455 own <emphasis>Reply-To:</emphasis> header line, the value of the <option>errors_reply_to</option> option is
22456 not used.
22457 </para>
22458 <para>
22459 <indexterm role="option">
22460 <primary><option>exim_group</option></primary>
22461 </indexterm>
22462 </para>
22463 <informaltable frame="all">
22464 <tgroup cols="4" colsep="0" rowsep="0">
22465 <colspec colwidth="8*" align="left"/>
22466 <colspec colwidth="6*" align="center"/>
22467 <colspec colwidth="6*" align="center"/>
22468 <colspec colwidth="6*" align="right"/>
22469 <tbody>
22470 <row>
22471 <entry><option>exim_group</option></entry>
22472 <entry>Use: <emphasis>main</emphasis></entry>
22473 <entry>Type: <emphasis>string</emphasis></entry>
22474 <entry>Default: <emphasis>compile-time configured</emphasis></entry>
22475 </row>
22476 </tbody>
22477 </tgroup>
22478 </informaltable>
22479 <para>
22480 <indexterm role="concept">
22481 <primary>gid (group id)</primary>
22482 <secondary>Exim&#x2019;s own</secondary>
22483 </indexterm>
22484 <indexterm role="concept">
22485 <primary>Exim group</primary>
22486 </indexterm>
22487 This option changes the gid under which Exim runs when it gives up root
22488 privilege. The default value is compiled into the binary. The value of this
22489 option is used only when <option>exim_user</option> is also set. Unless it consists entirely
22490 of digits, the string is looked up using <function>getgrnam()</function>, and failure causes a
22491 configuration error. See chapter <xref linkend="CHAPsecurity"/> for a discussion of
22492 security issues.
22493 </para>
22494 <para>
22495 <indexterm role="option">
22496 <primary><option>exim_path</option></primary>
22497 </indexterm>
22498 </para>
22499 <informaltable frame="all">
22500 <tgroup cols="4" colsep="0" rowsep="0">
22501 <colspec colwidth="8*" align="left"/>
22502 <colspec colwidth="6*" align="center"/>
22503 <colspec colwidth="6*" align="center"/>
22504 <colspec colwidth="6*" align="right"/>
22505 <tbody>
22506 <row>
22507 <entry><option>exim_path</option></entry>
22508 <entry>Use: <emphasis>main</emphasis></entry>
22509 <entry>Type: <emphasis>string</emphasis></entry>
22510 <entry>Default: <emphasis>see below</emphasis></entry>
22511 </row>
22512 </tbody>
22513 </tgroup>
22514 </informaltable>
22515 <para>
22516 <indexterm role="concept">
22517 <primary>Exim binary, path name</primary>
22518 </indexterm>
22519 This option specifies the path name of the Exim binary, which is used when Exim
22520 needs to re-exec itself. The default is set up to point to the file <emphasis>exim</emphasis> in
22521 the directory configured at compile time by the BIN_DIRECTORY setting. It
22522 is necessary to change <option>exim_path</option> if, exceptionally, Exim is run from some
22523 other place.
22524 <emphasis role="bold">Warning</emphasis>: Do not use a macro to define the value of this option, because
22525 you will break those Exim utilities that scan the configuration file to find
22526 where the binary is. (They then use the <option>-bP</option> option to extract option
22527 settings such as the value of <option>spool_directory</option>.)
22528 </para>
22529 <para>
22530 <indexterm role="option">
22531 <primary><option>exim_user</option></primary>
22532 </indexterm>
22533 </para>
22534 <informaltable frame="all">
22535 <tgroup cols="4" colsep="0" rowsep="0">
22536 <colspec colwidth="8*" align="left"/>
22537 <colspec colwidth="6*" align="center"/>
22538 <colspec colwidth="6*" align="center"/>
22539 <colspec colwidth="6*" align="right"/>
22540 <tbody>
22541 <row>
22542 <entry><option>exim_user</option></entry>
22543 <entry>Use: <emphasis>main</emphasis></entry>
22544 <entry>Type: <emphasis>string</emphasis></entry>
22545 <entry>Default: <emphasis>compile-time configured</emphasis></entry>
22546 </row>
22547 </tbody>
22548 </tgroup>
22549 </informaltable>
22550 <para>
22551 <indexterm role="concept">
22552 <primary>uid (user id)</primary>
22553 <secondary>Exim&#x2019;s own</secondary>
22554 </indexterm>
22555 <indexterm role="concept">
22556 <primary>Exim user</primary>
22557 </indexterm>
22558 This option changes the uid under which Exim runs when it gives up root
22559 privilege. The default value is compiled into the binary. Ownership of the run
22560 time configuration file and the use of the <option>-C</option> and <option>-D</option> command line
22561 options is checked against the values in the binary, not what is set here.
22562 </para>
22563 <para>
22564 Unless it consists entirely of digits, the string is looked up using
22565 <function>getpwnam()</function>, and failure causes a configuration error. If <option>exim_group</option> is
22566 not also supplied, the gid is taken from the result of <function>getpwnam()</function> if it is
22567 used. See chapter <xref linkend="CHAPsecurity"/> for a discussion of security issues.
22568 </para>
22569 <para>
22570 <indexterm role="option">
22571 <primary><option>extra_local_interfaces</option></primary>
22572 </indexterm>
22573 </para>
22574 <informaltable frame="all">
22575 <tgroup cols="4" colsep="0" rowsep="0">
22576 <colspec colwidth="8*" align="left"/>
22577 <colspec colwidth="6*" align="center"/>
22578 <colspec colwidth="6*" align="center"/>
22579 <colspec colwidth="6*" align="right"/>
22580 <tbody>
22581 <row>
22582 <entry><option>extra_local_interfaces</option></entry>
22583 <entry>Use: <emphasis>main</emphasis></entry>
22584 <entry>Type: <emphasis>string list</emphasis></entry>
22585 <entry>Default: <emphasis>unset</emphasis></entry>
22586 </row>
22587 </tbody>
22588 </tgroup>
22589 </informaltable>
22590 <para>
22591 This option defines network interfaces that are to be considered local when
22592 routing, but which are not used for listening by the daemon. See section
22593 <xref linkend="SECTreclocipadd"/> for details.
22594 </para>
22595 <para>
22596 <indexterm role="option">
22597 <primary><option>extract_addresses_remove_arguments</option></primary>
22598 </indexterm>
22599 </para>
22600 <informaltable frame="all">
22601 <tgroup cols="4" colsep="0" rowsep="0">
22602 <colspec colwidth="8*" align="left"/>
22603 <colspec colwidth="6*" align="center"/>
22604 <colspec colwidth="6*" align="center"/>
22605 <colspec colwidth="6*" align="right"/>
22606 <tbody>
22607 <row>
22608 <entry><option>extract_addresses_remove_ &nbsp;&nbsp;arguments</option></entry>
22609 <entry>Use: <emphasis>main</emphasis></entry>
22610 <entry>Type: <emphasis>boolean</emphasis></entry>
22611 <entry>Default: <emphasis>true</emphasis></entry>
22612 </row>
22613 </tbody>
22614 </tgroup>
22615 </informaltable>
22616 <para>
22617 <indexterm role="option">
22618 <primary><option>-t</option></primary>
22619 </indexterm>
22620 <indexterm role="concept">
22621 <primary>command line</primary>
22622 <secondary>addresses with <option>-t</option></secondary>
22623 </indexterm>
22624 <indexterm role="concept">
22625 <primary>Sendmail compatibility</primary>
22626 <secondary><option>-t</option> option</secondary>
22627 </indexterm>
22628 According to some Sendmail documentation (Sun, IRIX, HP-UX), if any addresses
22629 are present on the command line when the <option>-t</option> option is used to build an
22630 envelope from a message&#x2019;s <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis> and <emphasis>Bcc:</emphasis> headers, the command
22631 line addresses are removed from the recipients list. This is also how Smail
22632 behaves. However, other Sendmail documentation (the O&#x2019;Reilly book) states that
22633 command line addresses are added to those obtained from the header lines. When
22634 <option>extract_addresses_remove_arguments</option> is true (the default), Exim subtracts
22635 argument headers. If it is set false, Exim adds rather than removes argument
22636 addresses.
22637 </para>
22638 <para>
22639 <indexterm role="option">
22640 <primary><option>finduser_retries</option></primary>
22641 </indexterm>
22642 </para>
22643 <informaltable frame="all">
22644 <tgroup cols="4" colsep="0" rowsep="0">
22645 <colspec colwidth="8*" align="left"/>
22646 <colspec colwidth="6*" align="center"/>
22647 <colspec colwidth="6*" align="center"/>
22648 <colspec colwidth="6*" align="right"/>
22649 <tbody>
22650 <row>
22651 <entry><option>finduser_retries</option></entry>
22652 <entry>Use: <emphasis>main</emphasis></entry>
22653 <entry>Type: <emphasis>integer</emphasis></entry>
22654 <entry>Default: <emphasis>0</emphasis></entry>
22655 </row>
22656 </tbody>
22657 </tgroup>
22658 </informaltable>
22659 <para>
22660 <indexterm role="concept">
22661 <primary>NIS, retrying user lookups</primary>
22662 </indexterm>
22663 On systems running NIS or other schemes in which user and group information is
22664 distributed from a remote system, there can be times when <function>getpwnam()</function> and
22665 related functions fail, even when given valid data, because things time out.
22666 Unfortunately these failures cannot be distinguished from genuine <quote>not found</quote>
22667 errors. If <option>finduser_retries</option> is set greater than zero, Exim will try that
22668 many extra times to find a user or a group, waiting for one second between
22669 retries.
22670 </para>
22671 <para>
22672 <indexterm role="concept">
22673 <primary><filename>/etc/passwd</filename></primary>
22674 <secondary>multiple reading of</secondary>
22675 </indexterm>
22676 You should not set this option greater than zero if your user information is in
22677 a traditional <filename>/etc/passwd</filename> file, because it will cause Exim needlessly to
22678 search the file multiple times for non-existent users, and also cause delay.
22679 </para>
22680 <para>
22681 <indexterm role="option">
22682 <primary><option>freeze_tell</option></primary>
22683 </indexterm>
22684 </para>
22685 <informaltable frame="all">
22686 <tgroup cols="4" colsep="0" rowsep="0">
22687 <colspec colwidth="8*" align="left"/>
22688 <colspec colwidth="6*" align="center"/>
22689 <colspec colwidth="6*" align="center"/>
22690 <colspec colwidth="6*" align="right"/>
22691 <tbody>
22692 <row>
22693 <entry><option>freeze_tell</option></entry>
22694 <entry>Use: <emphasis>main</emphasis></entry>
22695 <entry>Type: <emphasis>string list, comma separated</emphasis></entry>
22696 <entry>Default: <emphasis>unset</emphasis></entry>
22697 </row>
22698 </tbody>
22699 </tgroup>
22700 </informaltable>
22701 <para>
22702 <indexterm role="concept">
22703 <primary>freezing messages</primary>
22704 <secondary>sending a message when freezing</secondary>
22705 </indexterm>
22706 On encountering certain errors, or when configured to do so in a system filter,
22707 ACL, or special router, Exim freezes a message. This means that no further
22708 delivery attempts take place until an administrator thaws the message, or the
22709 <option>auto_thaw</option>, <option>ignore_bounce_errors_after</option>, or <option>timeout_frozen_after</option>
22710 feature cause it to be processed. If <option>freeze_tell</option> is set, Exim generates a
22711 warning message whenever it freezes something, unless the message it is
22712 freezing is a locally-generated bounce message. (Without this exception there
22713 is the possibility of looping.) The warning message is sent to the addresses
22714 supplied as the comma-separated value of this option. If several of the
22715 message&#x2019;s addresses cause freezing, only a single message is sent. If the
22716 freezing was automatic, the reason(s) for freezing can be found in the message
22717 log. If you configure freezing in a filter or ACL, you must arrange for any
22718 logging that you require.
22719 </para>
22720 <para>
22721 <indexterm role="option">
22722 <primary><option>gecos_name</option></primary>
22723 </indexterm>
22724 </para>
22725 <informaltable frame="all">
22726 <tgroup cols="4" colsep="0" rowsep="0">
22727 <colspec colwidth="8*" align="left"/>
22728 <colspec colwidth="6*" align="center"/>
22729 <colspec colwidth="6*" align="center"/>
22730 <colspec colwidth="6*" align="right"/>
22731 <tbody>
22732 <row>
22733 <entry><option>gecos_name</option></entry>
22734 <entry>Use: <emphasis>main</emphasis></entry>
22735 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
22736 <entry>Default: <emphasis>unset</emphasis></entry>
22737 </row>
22738 </tbody>
22739 </tgroup>
22740 </informaltable>
22741 <para>
22742 <indexterm role="concept">
22743 <primary>HP-UX</primary>
22744 </indexterm>
22745 <indexterm role="concept">
22746 <primary><quote>gecos</quote> field, parsing</primary>
22747 </indexterm>
22748 Some operating systems, notably HP-UX, use the <quote>gecos</quote> field in the system
22749 password file to hold other information in addition to users&#x2019; real names. Exim
22750 looks up this field for use when it is creating <emphasis>Sender:</emphasis> or <emphasis>From:</emphasis>
22751 headers. If either <option>gecos_pattern</option> or <option>gecos_name</option> are unset, the contents
22752 of the field are used unchanged, except that, if an ampersand is encountered,
22753 it is replaced by the user&#x2019;s login name with the first character forced to
22754 upper case, since this is a convention that is observed on many systems.
22755 </para>
22756 <para>
22757 When these options are set, <option>gecos_pattern</option> is treated as a regular
22758 expression that is to be applied to the field (again with &amp; replaced by the
22759 login name), and if it matches, <option>gecos_name</option> is expanded and used as the
22760 user&#x2019;s name.
22761 </para>
22762 <para>
22763 <indexterm role="concept">
22764 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
22765 <secondary>in <option>gecos_name</option></secondary>
22766 </indexterm>
22767 Numeric variables such as <varname>$1</varname>, <varname>$2</varname>, etc. can be used in the expansion to
22768 pick up sub-fields that were matched by the pattern. In HP-UX, where the user&#x2019;s
22769 name terminates at the first comma, the following can be used:
22770 </para>
22771 <literallayout class="monospaced">
22772 gecos_pattern = ([^,]*)
22773 gecos_name = $1
22774 </literallayout>
22775 <para>
22776 <indexterm role="option">
22777 <primary><option>gecos_pattern</option></primary>
22778 </indexterm>
22779 </para>
22780 <informaltable frame="all">
22781 <tgroup cols="4" colsep="0" rowsep="0">
22782 <colspec colwidth="8*" align="left"/>
22783 <colspec colwidth="6*" align="center"/>
22784 <colspec colwidth="6*" align="center"/>
22785 <colspec colwidth="6*" align="right"/>
22786 <tbody>
22787 <row>
22788 <entry><option>gecos_pattern</option></entry>
22789 <entry>Use: <emphasis>main</emphasis></entry>
22790 <entry>Type: <emphasis>string</emphasis></entry>
22791 <entry>Default: <emphasis>unset</emphasis></entry>
22792 </row>
22793 </tbody>
22794 </tgroup>
22795 </informaltable>
22796 <para>
22797 See <option>gecos_name</option> above.
22798 </para>
22799 <para>
22800 <indexterm role="option">
22801 <primary><option>gnutls_require_kx</option></primary>
22802 </indexterm>
22803 </para>
22804 <informaltable frame="all">
22805 <tgroup cols="4" colsep="0" rowsep="0">
22806 <colspec colwidth="8*" align="left"/>
22807 <colspec colwidth="6*" align="center"/>
22808 <colspec colwidth="6*" align="center"/>
22809 <colspec colwidth="6*" align="right"/>
22810 <tbody>
22811 <row>
22812 <entry><option>gnutls_require_kx</option></entry>
22813 <entry>Use: <emphasis>main</emphasis></entry>
22814 <entry>Type: <emphasis>string</emphasis></entry>
22815 <entry>Default: <emphasis>unset</emphasis></entry>
22816 </row>
22817 </tbody>
22818 </tgroup>
22819 </informaltable>
22820 <para>
22821 This option controls the key exchange mechanisms when GnuTLS is used in an Exim
22822 server. For details, see section <xref linkend="SECTreqciphgnu"/>.
22823 </para>
22824 <para>
22825 <indexterm role="option">
22826 <primary><option>gnutls_require_mac</option></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="6*" align="center"/>
22833 <colspec colwidth="6*" align="center"/>
22834 <colspec colwidth="6*" align="right"/>
22835 <tbody>
22836 <row>
22837 <entry><option>gnutls_require_mac</option></entry>
22838 <entry>Use: <emphasis>main</emphasis></entry>
22839 <entry>Type: <emphasis>string</emphasis></entry>
22840 <entry>Default: <emphasis>unset</emphasis></entry>
22841 </row>
22842 </tbody>
22843 </tgroup>
22844 </informaltable>
22845 <para>
22846 This option controls the MAC algorithms when GnuTLS is used in an Exim
22847 server. For details, see section <xref linkend="SECTreqciphgnu"/>.
22848 </para>
22849 <para>
22850 <indexterm role="option">
22851 <primary><option>gnutls_require_protocols</option></primary>
22852 </indexterm>
22853 </para>
22854 <informaltable frame="all">
22855 <tgroup cols="4" colsep="0" rowsep="0">
22856 <colspec colwidth="8*" align="left"/>
22857 <colspec colwidth="6*" align="center"/>
22858 <colspec colwidth="6*" align="center"/>
22859 <colspec colwidth="6*" align="right"/>
22860 <tbody>
22861 <row>
22862 <entry><option>gnutls_require_protocols</option></entry>
22863 <entry>Use: <emphasis>main</emphasis></entry>
22864 <entry>Type: <emphasis>string</emphasis></entry>
22865 <entry>Default: <emphasis>unset</emphasis></entry>
22866 </row>
22867 </tbody>
22868 </tgroup>
22869 </informaltable>
22870 <para>
22871 This option controls the protocols when GnuTLS is used in an Exim
22872 server. For details, see section <xref linkend="SECTreqciphgnu"/>.
22873 </para>
22874 <para>
22875 <indexterm role="option">
22876 <primary><option>gnutls_compat_mode</option></primary>
22877 </indexterm>
22878 </para>
22879 <informaltable frame="all">
22880 <tgroup cols="4" colsep="0" rowsep="0">
22881 <colspec colwidth="8*" align="left"/>
22882 <colspec colwidth="6*" align="center"/>
22883 <colspec colwidth="6*" align="center"/>
22884 <colspec colwidth="6*" align="right"/>
22885 <tbody>
22886 <row>
22887 <entry><option>gnutls_compat_mode</option></entry>
22888 <entry>Use: <emphasis>main</emphasis></entry>
22889 <entry>Type: <emphasis>boolean</emphasis></entry>
22890 <entry>Default: <emphasis>unset</emphasis></entry>
22891 </row>
22892 </tbody>
22893 </tgroup>
22894 </informaltable>
22895 <para>
22896 This option controls whether GnuTLS is used in compatibility mode in an Exim
22897 server. This reduces security slightly, but improves interworking with older
22898 implementations of TLS.
22899 </para>
22900 <para>
22901 <indexterm role="option">
22902 <primary><option>headers_charset</option></primary>
22903 </indexterm>
22904 </para>
22905 <informaltable frame="all">
22906 <tgroup cols="4" colsep="0" rowsep="0">
22907 <colspec colwidth="8*" align="left"/>
22908 <colspec colwidth="6*" align="center"/>
22909 <colspec colwidth="6*" align="center"/>
22910 <colspec colwidth="6*" align="right"/>
22911 <tbody>
22912 <row>
22913 <entry><option>headers_charset</option></entry>
22914 <entry>Use: <emphasis>main</emphasis></entry>
22915 <entry>Type: <emphasis>string</emphasis></entry>
22916 <entry>Default: <emphasis>see below</emphasis></entry>
22917 </row>
22918 </tbody>
22919 </tgroup>
22920 </informaltable>
22921 <para>
22922 This option sets a default character set for translating from encoded MIME
22923 <quote>words</quote> in header lines, when referenced by an <varname>$h_xxx</varname> expansion item. The
22924 default is the value of HEADERS_CHARSET in <filename>Local/Makefile</filename>. The
22925 ultimate default is ISO-8859-1. For more details see the description of header
22926 insertions in section <xref linkend="SECTexpansionitems"/>.
22927 </para>
22928 <para>
22929 <indexterm role="option">
22930 <primary><option>header_maxsize</option></primary>
22931 </indexterm>
22932 </para>
22933 <informaltable frame="all">
22934 <tgroup cols="4" colsep="0" rowsep="0">
22935 <colspec colwidth="8*" align="left"/>
22936 <colspec colwidth="6*" align="center"/>
22937 <colspec colwidth="6*" align="center"/>
22938 <colspec colwidth="6*" align="right"/>
22939 <tbody>
22940 <row>
22941 <entry><option>header_maxsize</option></entry>
22942 <entry>Use: <emphasis>main</emphasis></entry>
22943 <entry>Type: <emphasis>integer</emphasis></entry>
22944 <entry>Default: <emphasis>see below</emphasis></entry>
22945 </row>
22946 </tbody>
22947 </tgroup>
22948 </informaltable>
22949 <para>
22950 <indexterm role="concept">
22951 <primary>header section</primary>
22952 <secondary>maximum size of</secondary>
22953 </indexterm>
22954 <indexterm role="concept">
22955 <primary>limit</primary>
22956 <secondary>size of message header section</secondary>
22957 </indexterm>
22958 This option controls the overall maximum size of a message&#x2019;s header
22959 section. The default is the value of HEADER_MAXSIZE in
22960 <filename>Local/Makefile</filename>; the default for that is 1M. Messages with larger header
22961 sections are rejected.
22962 </para>
22963 <para>
22964 <indexterm role="option">
22965 <primary><option>header_line_maxsize</option></primary>
22966 </indexterm>
22967 </para>
22968 <informaltable frame="all">
22969 <tgroup cols="4" colsep="0" rowsep="0">
22970 <colspec colwidth="8*" align="left"/>
22971 <colspec colwidth="6*" align="center"/>
22972 <colspec colwidth="6*" align="center"/>
22973 <colspec colwidth="6*" align="right"/>
22974 <tbody>
22975 <row>
22976 <entry><option>header_line_maxsize</option></entry>
22977 <entry>Use: <emphasis>main</emphasis></entry>
22978 <entry>Type: <emphasis>integer</emphasis></entry>
22979 <entry>Default: <emphasis>0</emphasis></entry>
22980 </row>
22981 </tbody>
22982 </tgroup>
22983 </informaltable>
22984 <para>
22985 <indexterm role="concept">
22986 <primary>header lines</primary>
22987 <secondary>maximum size of</secondary>
22988 </indexterm>
22989 <indexterm role="concept">
22990 <primary>limit</primary>
22991 <secondary>size of one header line</secondary>
22992 </indexterm>
22993 This option limits the length of any individual header line in a message, after
22994 all the continuations have been joined together. Messages with individual
22995 header lines that are longer than the limit are rejected. The default value of
22996 zero means <quote>no limit</quote>.
22997 </para>
22998 <para>
22999 <indexterm role="option">
23000 <primary><option>helo_accept_junk_hosts</option></primary>
23001 </indexterm>
23002 </para>
23003 <informaltable frame="all">
23004 <tgroup cols="4" colsep="0" rowsep="0">
23005 <colspec colwidth="8*" align="left"/>
23006 <colspec colwidth="6*" align="center"/>
23007 <colspec colwidth="6*" align="center"/>
23008 <colspec colwidth="6*" align="right"/>
23009 <tbody>
23010 <row>
23011 <entry><option>helo_accept_junk_hosts</option></entry>
23012 <entry>Use: <emphasis>main</emphasis></entry>
23013 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
23014 <entry>Default: <emphasis>unset</emphasis></entry>
23015 </row>
23016 </tbody>
23017 </tgroup>
23018 </informaltable>
23019 <para>
23020 <indexterm role="concept">
23021 <primary>HELO</primary>
23022 <secondary>accepting junk data</secondary>
23023 </indexterm>
23024 <indexterm role="concept">
23025 <primary>EHLO</primary>
23026 <secondary>accepting junk data</secondary>
23027 </indexterm>
23028 Exim checks the syntax of HELO and EHLO commands for incoming SMTP
23029 mail, and gives an error response for invalid data. Unfortunately, there are
23030 some SMTP clients that send syntactic junk. They can be accommodated by setting
23031 this option. Note that this is a syntax check only. See <option>helo_verify_hosts</option>
23032 if you want to do semantic checking.
23033 See also <option>helo_allow_chars</option> for a way of extending the permitted character
23034 set.
23035 </para>
23036 <para>
23037 <indexterm role="option">
23038 <primary><option>helo_allow_chars</option></primary>
23039 </indexterm>
23040 </para>
23041 <informaltable frame="all">
23042 <tgroup cols="4" colsep="0" rowsep="0">
23043 <colspec colwidth="8*" align="left"/>
23044 <colspec colwidth="6*" align="center"/>
23045 <colspec colwidth="6*" align="center"/>
23046 <colspec colwidth="6*" align="right"/>
23047 <tbody>
23048 <row>
23049 <entry><option>helo_allow_chars</option></entry>
23050 <entry>Use: <emphasis>main</emphasis></entry>
23051 <entry>Type: <emphasis>string</emphasis></entry>
23052 <entry>Default: <emphasis>unset</emphasis></entry>
23053 </row>
23054 </tbody>
23055 </tgroup>
23056 </informaltable>
23057 <para>
23058 <indexterm role="concept">
23059 <primary>HELO</primary>
23060 <secondary>underscores in</secondary>
23061 </indexterm>
23062 <indexterm role="concept">
23063 <primary>EHLO</primary>
23064 <secondary>underscores in</secondary>
23065 </indexterm>
23066 <indexterm role="concept">
23067 <primary>underscore in EHLO/HELO</primary>
23068 </indexterm>
23069 This option can be set to a string of rogue characters that are permitted in
23070 all EHLO and HELO names in addition to the standard letters, digits,
23071 hyphens, and dots. If you really must allow underscores, you can set
23072 </para>
23073 <literallayout class="monospaced">
23074 helo_allow_chars = _
23075 </literallayout>
23076 <para>
23077 Note that the value is one string, not a list.
23078 </para>
23079 <para>
23080 <indexterm role="option">
23081 <primary><option>helo_lookup_domains</option></primary>
23082 </indexterm>
23083 </para>
23084 <informaltable frame="all">
23085 <tgroup cols="4" colsep="0" rowsep="0">
23086 <colspec colwidth="8*" align="left"/>
23087 <colspec colwidth="6*" align="center"/>
23088 <colspec colwidth="6*" align="center"/>
23089 <colspec colwidth="6*" align="right"/>
23090 <tbody>
23091 <row>
23092 <entry><option>helo_lookup_domains</option></entry>
23093 <entry>Use: <emphasis>main</emphasis></entry>
23094 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
23095 <entry>Default: <emphasis><literal>@:@[]</literal></emphasis></entry>
23096 </row>
23097 </tbody>
23098 </tgroup>
23099 </informaltable>
23100 <para>
23101 <indexterm role="concept">
23102 <primary>HELO</primary>
23103 <secondary>forcing reverse lookup</secondary>
23104 </indexterm>
23105 <indexterm role="concept">
23106 <primary>EHLO</primary>
23107 <secondary>forcing reverse lookup</secondary>
23108 </indexterm>
23109 If the domain given by a client in a HELO or EHLO command matches this
23110 list, a reverse lookup is done in order to establish the host&#x2019;s true name. The
23111 default forces a lookup if the client host gives the server&#x2019;s name or any of
23112 its IP addresses (in brackets), something that broken clients have been seen to
23113 do.
23114 </para>
23115 <para>
23116 <indexterm role="option">
23117 <primary><option>helo_try_verify_hosts</option></primary>
23118 </indexterm>
23119 </para>
23120 <informaltable frame="all">
23121 <tgroup cols="4" colsep="0" rowsep="0">
23122 <colspec colwidth="8*" align="left"/>
23123 <colspec colwidth="6*" align="center"/>
23124 <colspec colwidth="6*" align="center"/>
23125 <colspec colwidth="6*" align="right"/>
23126 <tbody>
23127 <row>
23128 <entry><option>helo_try_verify_hosts</option></entry>
23129 <entry>Use: <emphasis>main</emphasis></entry>
23130 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
23131 <entry>Default: <emphasis>unset</emphasis></entry>
23132 </row>
23133 </tbody>
23134 </tgroup>
23135 </informaltable>
23136 <para>
23137 <indexterm role="concept">
23138 <primary>HELO verifying</primary>
23139 <secondary>optional</secondary>
23140 </indexterm>
23141 <indexterm role="concept">
23142 <primary>EHLO</primary>
23143 <secondary>verifying, optional</secondary>
23144 </indexterm>
23145 By default, Exim just checks the syntax of HELO and EHLO commands (see
23146 <option>helo_accept_junk_hosts</option> and <option>helo_allow_chars</option>). However, some sites like
23147 to do more extensive checking of the data supplied by these commands. The ACL
23148 condition <literal>verify = helo</literal> is provided to make this possible.
23149 Formerly, it was necessary also to set this option (<option>helo_try_verify_hosts</option>)
23150 to force the check to occur. From release 4.53 onwards, this is no longer
23151 necessary. If the check has not been done before <literal>verify = helo</literal> is
23152 encountered, it is done at that time. Consequently, this option is obsolete.
23153 Its specification is retained here for backwards compatibility.
23154 </para>
23155 <para>
23156 When an EHLO or HELO command is received, if the calling host matches
23157 <option>helo_try_verify_hosts</option>, Exim checks that the host name given in the HELO or
23158 EHLO command either:
23159 </para>
23160 <itemizedlist>
23161 <listitem>
23162 <para>
23163 is an IP literal matching the calling address of the host, or
23164 </para>
23165 </listitem>
23166 <listitem>
23167 <para>
23168 <indexterm role="concept">
23169 <primary>DNS</primary>
23170 <secondary>reverse lookup</secondary>
23171 </indexterm>
23172 <indexterm role="concept">
23173 <primary>reverse DNS lookup</primary>
23174 </indexterm>
23175 matches the host name that Exim obtains by doing a reverse lookup of the
23176 calling host address, or
23177 </para>
23178 </listitem>
23179 <listitem>
23180 <para>
23181 when looked up using <function>gethostbyname()</function> (or <function>getipnodebyname()</function> when
23182 available) yields the calling host address.
23183 </para>
23184 </listitem>
23185 </itemizedlist>
23186 <para>
23187 However, the EHLO or HELO command is not rejected if any of the checks
23188 fail. Processing continues, but the result of the check is remembered, and can
23189 be detected later in an ACL by the <literal>verify = helo</literal> condition.
23190 </para>
23191 <para>
23192 <indexterm role="option">
23193 <primary><option>helo_verify_hosts</option></primary>
23194 </indexterm>
23195 </para>
23196 <informaltable frame="all">
23197 <tgroup cols="4" colsep="0" rowsep="0">
23198 <colspec colwidth="8*" align="left"/>
23199 <colspec colwidth="6*" align="center"/>
23200 <colspec colwidth="6*" align="center"/>
23201 <colspec colwidth="6*" align="right"/>
23202 <tbody>
23203 <row>
23204 <entry><option>helo_verify_hosts</option></entry>
23205 <entry>Use: <emphasis>main</emphasis></entry>
23206 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
23207 <entry>Default: <emphasis>unset</emphasis></entry>
23208 </row>
23209 </tbody>
23210 </tgroup>
23211 </informaltable>
23212 <para>
23213 <indexterm role="concept">
23214 <primary>HELO verifying</primary>
23215 <secondary>mandatory</secondary>
23216 </indexterm>
23217 <indexterm role="concept">
23218 <primary>EHLO</primary>
23219 <secondary>verifying, mandatory</secondary>
23220 </indexterm>
23221 Like <option>helo_try_verify_hosts</option>, this option is obsolete, and retained only for
23222 backwards compatibility. For hosts that match this option, Exim checks the host
23223 name given in the HELO or EHLO in the same way as for
23224 <option>helo_try_verify_hosts</option>. If the check fails, the HELO or EHLO command is
23225 rejected with a 550 error, and entries are written to the main and reject logs.
23226 If a MAIL command is received before EHLO or HELO, it is rejected with a 503
23227 error.
23228 </para>
23229 <para>
23230 <indexterm role="option">
23231 <primary><option>hold_domains</option></primary>
23232 </indexterm>
23233 </para>
23234 <informaltable frame="all">
23235 <tgroup cols="4" colsep="0" rowsep="0">
23236 <colspec colwidth="8*" align="left"/>
23237 <colspec colwidth="6*" align="center"/>
23238 <colspec colwidth="6*" align="center"/>
23239 <colspec colwidth="6*" align="right"/>
23240 <tbody>
23241 <row>
23242 <entry><option>hold_domains</option></entry>
23243 <entry>Use: <emphasis>main</emphasis></entry>
23244 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
23245 <entry>Default: <emphasis>unset</emphasis></entry>
23246 </row>
23247 </tbody>
23248 </tgroup>
23249 </informaltable>
23250 <para>
23251 <indexterm role="concept">
23252 <primary>domain</primary>
23253 <secondary>delaying delivery</secondary>
23254 </indexterm>
23255 <indexterm role="concept">
23256 <primary>delivery</primary>
23257 <secondary>delaying certain domains</secondary>
23258 </indexterm>
23259 This option allows mail for particular domains to be held on the queue
23260 manually. The option is overridden if a message delivery is forced with the
23261 <option>-M</option>, <option>-qf</option>, <option>-Rf</option> or <option>-Sf</option> options, and also while testing or
23262 verifying addresses using <option>-bt</option> or <option>-bv</option>. Otherwise, if a domain matches an
23263 item in <option>hold_domains</option>, no routing or delivery for that address is done, and
23264 it is deferred every time the message is looked at.
23265 </para>
23266 <para>
23267 This option is intended as a temporary operational measure for delaying the
23268 delivery of mail while some problem is being sorted out, or some new
23269 configuration tested. If you just want to delay the processing of some
23270 domains until a queue run occurs, you should use <option>queue_domains</option> or
23271 <option>queue_smtp_domains</option>, not <option>hold_domains</option>.
23272 </para>
23273 <para>
23274 A setting of <option>hold_domains</option> does not override Exim&#x2019;s code for removing
23275 messages from the queue if they have been there longer than the longest retry
23276 time in any retry rule. If you want to hold messages for longer than the normal
23277 retry times, insert a dummy retry rule with a long retry time.
23278 </para>
23279 <para>
23280 <indexterm role="option">
23281 <primary><option>host_lookup</option></primary>
23282 </indexterm>
23283 </para>
23284 <informaltable frame="all">
23285 <tgroup cols="4" colsep="0" rowsep="0">
23286 <colspec colwidth="8*" align="left"/>
23287 <colspec colwidth="6*" align="center"/>
23288 <colspec colwidth="6*" align="center"/>
23289 <colspec colwidth="6*" align="right"/>
23290 <tbody>
23291 <row>
23292 <entry><option>host_lookup</option></entry>
23293 <entry>Use: <emphasis>main</emphasis></entry>
23294 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
23295 <entry>Default: <emphasis>unset</emphasis></entry>
23296 </row>
23297 </tbody>
23298 </tgroup>
23299 </informaltable>
23300 <para>
23301 <indexterm role="concept">
23302 <primary>host name</primary>
23303 <secondary>lookup, forcing</secondary>
23304 </indexterm>
23305 Exim does not look up the name of a calling host from its IP address unless it
23306 is required to compare against some host list, or the host matches
23307 <option>helo_try_verify_hosts</option> or <option>helo_verify_hosts</option>, or the host matches this
23308 option (which normally contains IP addresses rather than host names). The
23309 default configuration file contains
23310 </para>
23311 <literallayout class="monospaced">
23312 host_lookup = *
23313 </literallayout>
23314 <para>
23315 which causes a lookup to happen for all hosts. If the expense of these lookups
23316 is felt to be too great, the setting can be changed or removed.
23317 </para>
23318 <para>
23319 After a successful reverse lookup, Exim does a forward lookup on the name it
23320 has obtained, to verify that it yields the IP address that it started with. If
23321 this check fails, Exim behaves as if the name lookup failed.
23322 </para>
23323 <para>
23324 <indexterm role="variable">
23325 <primary><varname>$host_lookup_failed</varname></primary>
23326 </indexterm>
23327 <indexterm role="variable">
23328 <primary><varname>$sender_host_name</varname></primary>
23329 </indexterm>
23330 After any kind of failure, the host name (in <varname>$sender_host_name</varname>) remains
23331 unset, and <varname>$host_lookup_failed</varname> is set to the string <quote>1</quote>. See also
23332 <option>dns_again_means_nonexist</option>, <option>helo_lookup_domains</option>, and
23333 <literal>verify = reverse_host_lookup</literal> in ACLs.
23334 </para>
23335 <para>
23336 <indexterm role="option">
23337 <primary><option>host_lookup_order</option></primary>
23338 </indexterm>
23339 </para>
23340 <informaltable frame="all">
23341 <tgroup cols="4" colsep="0" rowsep="0">
23342 <colspec colwidth="8*" align="left"/>
23343 <colspec colwidth="6*" align="center"/>
23344 <colspec colwidth="6*" align="center"/>
23345 <colspec colwidth="6*" align="right"/>
23346 <tbody>
23347 <row>
23348 <entry><option>host_lookup_order</option></entry>
23349 <entry>Use: <emphasis>main</emphasis></entry>
23350 <entry>Type: <emphasis>string list</emphasis></entry>
23351 <entry>Default: <emphasis><literal>bydns:byaddr</literal></emphasis></entry>
23352 </row>
23353 </tbody>
23354 </tgroup>
23355 </informaltable>
23356 <para>
23357 This option specifies the order of different lookup methods when Exim is trying
23358 to find a host name from an IP address. The default is to do a DNS lookup
23359 first, and then to try a local lookup (using <function>gethostbyaddr()</function> or equivalent)
23360 if that fails. You can change the order of these lookups, or omit one entirely,
23361 if you want.
23362 </para>
23363 <para>
23364 <emphasis role="bold">Warning</emphasis>: The <quote>byaddr</quote> method does not always yield aliases when there are
23365 multiple PTR records in the DNS and the IP address is not listed in
23366 <filename>/etc/hosts</filename>. Different operating systems give different results in this
23367 case. That is why the default tries a DNS lookup first.
23368 </para>
23369 <para>
23370 <indexterm role="option">
23371 <primary><option>host_reject_connection</option></primary>
23372 </indexterm>
23373 </para>
23374 <informaltable frame="all">
23375 <tgroup cols="4" colsep="0" rowsep="0">
23376 <colspec colwidth="8*" align="left"/>
23377 <colspec colwidth="6*" align="center"/>
23378 <colspec colwidth="6*" align="center"/>
23379 <colspec colwidth="6*" align="right"/>
23380 <tbody>
23381 <row>
23382 <entry><option>host_reject_connection</option></entry>
23383 <entry>Use: <emphasis>main</emphasis></entry>
23384 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
23385 <entry>Default: <emphasis>unset</emphasis></entry>
23386 </row>
23387 </tbody>
23388 </tgroup>
23389 </informaltable>
23390 <para>
23391 <indexterm role="concept">
23392 <primary>host</primary>
23393 <secondary>rejecting connections from</secondary>
23394 </indexterm>
23395 If this option is set, incoming SMTP calls from the hosts listed are rejected
23396 as soon as the connection is made.
23397 This option is obsolete, and retained only for backward compatibility, because
23398 nowadays the ACL specified by <option>acl_smtp_connect</option> can also reject incoming
23399 connections immediately.
23400 </para>
23401 <para>
23402 The ability to give an immediate rejection (either by this option or using an
23403 ACL) is provided for use in unusual cases. Many hosts will just try again,
23404 sometimes without much delay. Normally, it is better to use an ACL to reject
23405 incoming messages at a later stage, such as after RCPT commands. See
23406 chapter <xref linkend="CHAPACL"/>.
23407 </para>
23408 <para>
23409 <indexterm role="option">
23410 <primary><option>hosts_connection_nolog</option></primary>
23411 </indexterm>
23412 </para>
23413 <informaltable frame="all">
23414 <tgroup cols="4" colsep="0" rowsep="0">
23415 <colspec colwidth="8*" align="left"/>
23416 <colspec colwidth="6*" align="center"/>
23417 <colspec colwidth="6*" align="center"/>
23418 <colspec colwidth="6*" align="right"/>
23419 <tbody>
23420 <row>
23421 <entry><option>hosts_connection_nolog</option></entry>
23422 <entry>Use: <emphasis>main</emphasis></entry>
23423 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
23424 <entry>Default: <emphasis>unset</emphasis></entry>
23425 </row>
23426 </tbody>
23427 </tgroup>
23428 </informaltable>
23429 <para>
23430 <indexterm role="concept">
23431 <primary>host</primary>
23432 <secondary>not logging connections from</secondary>
23433 </indexterm>
23434 This option defines a list of hosts for which connection logging does not
23435 happen, even though the <option>smtp_connection</option> log selector is set. For example,
23436 you might want not to log SMTP connections from local processes, or from
23437 127.0.0.1, or from your local LAN. This option is consulted in the main loop of
23438 the daemon; you should therefore strive to restrict its value to a short inline
23439 list of IP addresses and networks. To disable logging SMTP connections from
23440 local processes, you must create a host list with an empty item. For example:
23441 </para>
23442 <literallayout class="monospaced">
23443 hosts_connection_nolog = :
23444 </literallayout>
23445 <para>
23446 If the <option>smtp_connection</option> log selector is not set, this option has no effect.
23447 </para>
23448 <para>
23449 <indexterm role="option">
23450 <primary><option>hosts_treat_as_local</option></primary>
23451 </indexterm>
23452 </para>
23453 <informaltable frame="all">
23454 <tgroup cols="4" colsep="0" rowsep="0">
23455 <colspec colwidth="8*" align="left"/>
23456 <colspec colwidth="6*" align="center"/>
23457 <colspec colwidth="6*" align="center"/>
23458 <colspec colwidth="6*" align="right"/>
23459 <tbody>
23460 <row>
23461 <entry><option>hosts_treat_as_local</option></entry>
23462 <entry>Use: <emphasis>main</emphasis></entry>
23463 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
23464 <entry>Default: <emphasis>unset</emphasis></entry>
23465 </row>
23466 </tbody>
23467 </tgroup>
23468 </informaltable>
23469 <para>
23470 <indexterm role="concept">
23471 <primary>local host</primary>
23472 <secondary>domains treated as</secondary>
23473 </indexterm>
23474 <indexterm role="concept">
23475 <primary>host</primary>
23476 <secondary>treated as local</secondary>
23477 </indexterm>
23478 If this option is set, any host names that match the domain list are treated as
23479 if they were the local host when Exim is scanning host lists obtained from MX
23480 records
23481 or other sources. Note that the value of this option is a domain list, not a
23482 host list, because it is always used to check host names, not IP addresses.
23483 </para>
23484 <para>
23485 This option also applies when Exim is matching the special items
23486 <literal>@mx_any</literal>, <literal>@mx_primary</literal>, and <literal>@mx_secondary</literal> in a domain list (see
23487 section <xref linkend="SECTdomainlist"/>), and when checking the <option>hosts</option> option in the
23488 <command>smtp</command> transport for the local host (see the <option>allow_localhost</option> option in
23489 that transport). See also <option>local_interfaces</option>, <option>extra_local_interfaces</option>, and
23490 chapter <xref linkend="CHAPinterfaces"/>, which contains a discussion about local network
23491 interfaces and recognizing the local host.
23492 </para>
23493 <para>
23494 <indexterm role="option">
23495 <primary><option>ibase_servers</option></primary>
23496 </indexterm>
23497 </para>
23498 <informaltable frame="all">
23499 <tgroup cols="4" colsep="0" rowsep="0">
23500 <colspec colwidth="8*" align="left"/>
23501 <colspec colwidth="6*" align="center"/>
23502 <colspec colwidth="6*" align="center"/>
23503 <colspec colwidth="6*" align="right"/>
23504 <tbody>
23505 <row>
23506 <entry><option>ibase_servers</option></entry>
23507 <entry>Use: <emphasis>main</emphasis></entry>
23508 <entry>Type: <emphasis>string list</emphasis></entry>
23509 <entry>Default: <emphasis>unset</emphasis></entry>
23510 </row>
23511 </tbody>
23512 </tgroup>
23513 </informaltable>
23514 <para>
23515 <indexterm role="concept">
23516 <primary>InterBase</primary>
23517 <secondary>server list</secondary>
23518 </indexterm>
23519 This option provides a list of InterBase servers and associated connection data,
23520 to be used in conjunction with <command>ibase</command> lookups (see section <xref linkend="SECID72"/>).
23521 The option is available only if Exim has been built with InterBase support.
23522 </para>
23523 <para>
23524 <indexterm role="option">
23525 <primary><option>ignore_bounce_errors_after</option></primary>
23526 </indexterm>
23527 </para>
23528 <informaltable frame="all">
23529 <tgroup cols="4" colsep="0" rowsep="0">
23530 <colspec colwidth="8*" align="left"/>
23531 <colspec colwidth="6*" align="center"/>
23532 <colspec colwidth="6*" align="center"/>
23533 <colspec colwidth="6*" align="right"/>
23534 <tbody>
23535 <row>
23536 <entry><option>ignore_bounce_errors_after</option></entry>
23537 <entry>Use: <emphasis>main</emphasis></entry>
23538 <entry>Type: <emphasis>time</emphasis></entry>
23539 <entry>Default: <emphasis>10w</emphasis></entry>
23540 </row>
23541 </tbody>
23542 </tgroup>
23543 </informaltable>
23544 <para>
23545 <indexterm role="concept">
23546 <primary>bounce message</primary>
23547 <secondary>discarding</secondary>
23548 </indexterm>
23549 <indexterm role="concept">
23550 <primary>discarding bounce message</primary>
23551 </indexterm>
23552 This option affects the processing of bounce messages that cannot be delivered,
23553 that is, those that suffer a permanent delivery failure. (Bounce messages that
23554 suffer temporary delivery failures are of course retried in the usual way.)
23555 </para>
23556 <para>
23557 After a permanent delivery failure, bounce messages are frozen,
23558 because there is no sender to whom they can be returned. When a frozen bounce
23559 message has been on the queue for more than the given time, it is unfrozen at
23560 the next queue run, and a further delivery is attempted. If delivery fails
23561 again, the bounce message is discarded. This makes it possible to keep failed
23562 bounce messages around for a shorter time than the normal maximum retry time
23563 for frozen messages. For example,
23564 </para>
23565 <literallayout class="monospaced">
23566 ignore_bounce_errors_after = 12h
23567 </literallayout>
23568 <para>
23569 retries failed bounce message deliveries after 12 hours, discarding any further
23570 failures. If the value of this option is set to a zero time period, bounce
23571 failures are discarded immediately. Setting a very long time (as in the default
23572 value) has the effect of disabling this option. For ways of automatically
23573 dealing with other kinds of frozen message, see <option>auto_thaw</option> and
23574 <option>timeout_frozen_after</option>.
23575 </para>
23576 <para>
23577 <indexterm role="option">
23578 <primary><option>ignore_fromline_hosts</option></primary>
23579 </indexterm>
23580 </para>
23581 <informaltable frame="all">
23582 <tgroup cols="4" colsep="0" rowsep="0">
23583 <colspec colwidth="8*" align="left"/>
23584 <colspec colwidth="6*" align="center"/>
23585 <colspec colwidth="6*" align="center"/>
23586 <colspec colwidth="6*" align="right"/>
23587 <tbody>
23588 <row>
23589 <entry><option>ignore_fromline_hosts</option></entry>
23590 <entry>Use: <emphasis>main</emphasis></entry>
23591 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
23592 <entry>Default: <emphasis>unset</emphasis></entry>
23593 </row>
23594 </tbody>
23595 </tgroup>
23596 </informaltable>
23597 <para>
23598 <indexterm role="concept">
23599 <primary><quote>From</quote> line</primary>
23600 </indexterm>
23601 <indexterm role="concept">
23602 <primary>UUCP</primary>
23603 <secondary><quote>From</quote> line</secondary>
23604 </indexterm>
23605 Some broken SMTP clients insist on sending a UUCP-like <quote>From&nbsp;</quote> line before
23606 the headers of a message. By default this is treated as the start of the
23607 message&#x2019;s body, which means that any following headers are not recognized as
23608 such. Exim can be made to ignore it by setting <option>ignore_fromline_hosts</option> to
23609 match those hosts that insist on sending it. If the sender is actually a local
23610 process rather than a remote host, and is using <option>-bs</option> to inject the messages,
23611 <option>ignore_fromline_local</option> must be set to achieve this effect.
23612 </para>
23613 <para>
23614 <indexterm role="option">
23615 <primary><option>ignore_fromline_local</option></primary>
23616 </indexterm>
23617 </para>
23618 <informaltable frame="all">
23619 <tgroup cols="4" colsep="0" rowsep="0">
23620 <colspec colwidth="8*" align="left"/>
23621 <colspec colwidth="6*" align="center"/>
23622 <colspec colwidth="6*" align="center"/>
23623 <colspec colwidth="6*" align="right"/>
23624 <tbody>
23625 <row>
23626 <entry><option>ignore_fromline_local</option></entry>
23627 <entry>Use: <emphasis>main</emphasis></entry>
23628 <entry>Type: <emphasis>boolean</emphasis></entry>
23629 <entry>Default: <emphasis>false</emphasis></entry>
23630 </row>
23631 </tbody>
23632 </tgroup>
23633 </informaltable>
23634 <para>
23635 See <option>ignore_fromline_hosts</option> above.
23636 </para>
23637 <para>
23638 <indexterm role="option">
23639 <primary><option>keep_malformed</option></primary>
23640 </indexterm>
23641 </para>
23642 <informaltable frame="all">
23643 <tgroup cols="4" colsep="0" rowsep="0">
23644 <colspec colwidth="8*" align="left"/>
23645 <colspec colwidth="6*" align="center"/>
23646 <colspec colwidth="6*" align="center"/>
23647 <colspec colwidth="6*" align="right"/>
23648 <tbody>
23649 <row>
23650 <entry><option>keep_malformed</option></entry>
23651 <entry>Use: <emphasis>main</emphasis></entry>
23652 <entry>Type: <emphasis>time</emphasis></entry>
23653 <entry>Default: <emphasis>4d</emphasis></entry>
23654 </row>
23655 </tbody>
23656 </tgroup>
23657 </informaltable>
23658 <para>
23659 This option specifies the length of time to keep messages whose spool files
23660 have been corrupted in some way. This should, of course, never happen. At the
23661 next attempt to deliver such a message, it gets removed. The incident is
23662 logged.
23663 </para>
23664 <para>
23665 <indexterm role="option">
23666 <primary><option>ldap_default_servers</option></primary>
23667 </indexterm>
23668 </para>
23669 <informaltable frame="all">
23670 <tgroup cols="4" colsep="0" rowsep="0">
23671 <colspec colwidth="8*" align="left"/>
23672 <colspec colwidth="6*" align="center"/>
23673 <colspec colwidth="6*" align="center"/>
23674 <colspec colwidth="6*" align="right"/>
23675 <tbody>
23676 <row>
23677 <entry><option>ldap_default_servers</option></entry>
23678 <entry>Use: <emphasis>main</emphasis></entry>
23679 <entry>Type: <emphasis>string list</emphasis></entry>
23680 <entry>Default: <emphasis>unset</emphasis></entry>
23681 </row>
23682 </tbody>
23683 </tgroup>
23684 </informaltable>
23685 <para>
23686 <indexterm role="concept">
23687 <primary>LDAP</primary>
23688 <secondary>default servers</secondary>
23689 </indexterm>
23690 This option provides a list of LDAP servers which are tried in turn when an
23691 LDAP query does not contain a server. See section <xref linkend="SECTforldaque"/> for
23692 details of LDAP queries. This option is available only when Exim has been built
23693 with LDAP support.
23694 </para>
23695 <para>
23696 <indexterm role="option">
23697 <primary><option>ldap_version</option></primary>
23698 </indexterm>
23699 </para>
23700 <informaltable frame="all">
23701 <tgroup cols="4" colsep="0" rowsep="0">
23702 <colspec colwidth="8*" align="left"/>
23703 <colspec colwidth="6*" align="center"/>
23704 <colspec colwidth="6*" align="center"/>
23705 <colspec colwidth="6*" align="right"/>
23706 <tbody>
23707 <row>
23708 <entry><option>ldap_version</option></entry>
23709 <entry>Use: <emphasis>main</emphasis></entry>
23710 <entry>Type: <emphasis>integer</emphasis></entry>
23711 <entry>Default: <emphasis>unset</emphasis></entry>
23712 </row>
23713 </tbody>
23714 </tgroup>
23715 </informaltable>
23716 <para>
23717 <indexterm role="concept">
23718 <primary>LDAP</primary>
23719 <secondary>protocol version, forcing</secondary>
23720 </indexterm>
23721 This option can be used to force Exim to set a specific protocol version for
23722 LDAP. If it option is unset, it is shown by the <option>-bP</option> command line option as
23723 -1. When this is the case, the default is 3 if LDAP_VERSION3 is defined in
23724 the LDAP headers; otherwise it is 2. This option is available only when Exim
23725 has been built with LDAP support.
23726 </para>
23727 <para>
23728 <indexterm role="option">
23729 <primary><option>local_from_check</option></primary>
23730 </indexterm>
23731 </para>
23732 <informaltable frame="all">
23733 <tgroup cols="4" colsep="0" rowsep="0">
23734 <colspec colwidth="8*" align="left"/>
23735 <colspec colwidth="6*" align="center"/>
23736 <colspec colwidth="6*" align="center"/>
23737 <colspec colwidth="6*" align="right"/>
23738 <tbody>
23739 <row>
23740 <entry><option>local_from_check</option></entry>
23741 <entry>Use: <emphasis>main</emphasis></entry>
23742 <entry>Type: <emphasis>boolean</emphasis></entry>
23743 <entry>Default: <emphasis>true</emphasis></entry>
23744 </row>
23745 </tbody>
23746 </tgroup>
23747 </informaltable>
23748 <para>
23749 <indexterm role="concept">
23750 <primary><emphasis>Sender:</emphasis> header line</primary>
23751 <secondary>disabling addition of</secondary>
23752 </indexterm>
23753 <indexterm role="concept">
23754 <primary><emphasis>From:</emphasis> header line</primary>
23755 <secondary>disabling checking of</secondary>
23756 </indexterm>
23757 When a message is submitted locally (that is, not over a TCP/IP connection) by
23758 an untrusted user, Exim removes any existing <emphasis>Sender:</emphasis> header line, and
23759 checks that the <emphasis>From:</emphasis> header line matches the login of the calling user and
23760 the domain specified by <option>qualify_domain</option>.
23761 </para>
23762 <para>
23763 <emphasis role="bold">Note</emphasis>: An unqualified address (no domain) in the <emphasis>From:</emphasis> header in a
23764 locally submitted message is automatically qualified by Exim, unless the
23765 <option>-bnq</option> command line option is used.
23766 </para>
23767 <para>
23768 You can use <option>local_from_prefix</option> and <option>local_from_suffix</option> to permit affixes
23769 on the local part. If the <emphasis>From:</emphasis> header line does not match, Exim adds a
23770 <emphasis>Sender:</emphasis> header with an address constructed from the calling user&#x2019;s login
23771 and the default qualify domain.
23772 </para>
23773 <para>
23774 If <option>local_from_check</option> is set false, the <emphasis>From:</emphasis> header check is disabled,
23775 and no <emphasis>Sender:</emphasis> header is ever added. If, in addition, you want to retain
23776 <emphasis>Sender:</emphasis> header lines supplied by untrusted users, you must also set
23777 <option>local_sender_retain</option> to be true.
23778 </para>
23779 <para>
23780 <indexterm role="concept">
23781 <primary>envelope sender</primary>
23782 </indexterm>
23783 These options affect only the header lines in the message. The envelope sender
23784 is still forced to be the login id at the qualify domain unless
23785 <option>untrusted_set_sender</option> permits the user to supply an envelope sender.
23786 </para>
23787 <para>
23788 For messages received over TCP/IP, an ACL can specify <quote>submission mode</quote> to
23789 request similar header line checking. See section <xref linkend="SECTthesenhea"/>, which
23790 has more details about <emphasis>Sender:</emphasis> processing.
23791 </para>
23792 <para>
23793 <indexterm role="option">
23794 <primary><option>local_from_prefix</option></primary>
23795 </indexterm>
23796 </para>
23797 <informaltable frame="all">
23798 <tgroup cols="4" colsep="0" rowsep="0">
23799 <colspec colwidth="8*" align="left"/>
23800 <colspec colwidth="6*" align="center"/>
23801 <colspec colwidth="6*" align="center"/>
23802 <colspec colwidth="6*" align="right"/>
23803 <tbody>
23804 <row>
23805 <entry><option>local_from_prefix</option></entry>
23806 <entry>Use: <emphasis>main</emphasis></entry>
23807 <entry>Type: <emphasis>string</emphasis></entry>
23808 <entry>Default: <emphasis>unset</emphasis></entry>
23809 </row>
23810 </tbody>
23811 </tgroup>
23812 </informaltable>
23813 <para>
23814 When Exim checks the <emphasis>From:</emphasis> header line of locally submitted messages for
23815 matching the login id (see <option>local_from_check</option> above), it can be configured to
23816 ignore certain prefixes and suffixes in the local part of the address. This is
23817 done by setting <option>local_from_prefix</option> and/or <option>local_from_suffix</option> to
23818 appropriate lists, in the same form as the <option>local_part_prefix</option> and
23819 <option>local_part_suffix</option> router options (see chapter <xref linkend="CHAProutergeneric"/>). For
23820 example, if
23821 </para>
23822 <literallayout class="monospaced">
23823 local_from_prefix = *-
23824 </literallayout>
23825 <para>
23826 is set, a <emphasis>From:</emphasis> line containing
23827 </para>
23828 <literallayout class="monospaced">
23829 From: anything-user@your.domain.example
23830 </literallayout>
23831 <para>
23832 will not cause a <emphasis>Sender:</emphasis> header to be added if <emphasis>user@your.domain.example</emphasis>
23833 matches the actual sender address that is constructed from the login name and
23834 qualify domain.
23835 </para>
23836 <para>
23837 <indexterm role="option">
23838 <primary><option>local_from_suffix</option></primary>
23839 </indexterm>
23840 </para>
23841 <informaltable frame="all">
23842 <tgroup cols="4" colsep="0" rowsep="0">
23843 <colspec colwidth="8*" align="left"/>
23844 <colspec colwidth="6*" align="center"/>
23845 <colspec colwidth="6*" align="center"/>
23846 <colspec colwidth="6*" align="right"/>
23847 <tbody>
23848 <row>
23849 <entry><option>local_from_suffix</option></entry>
23850 <entry>Use: <emphasis>main</emphasis></entry>
23851 <entry>Type: <emphasis>string</emphasis></entry>
23852 <entry>Default: <emphasis>unset</emphasis></entry>
23853 </row>
23854 </tbody>
23855 </tgroup>
23856 </informaltable>
23857 <para>
23858 See <option>local_from_prefix</option> above.
23859 </para>
23860 <para>
23861 <indexterm role="option">
23862 <primary><option>local_interfaces</option></primary>
23863 </indexterm>
23864 </para>
23865 <informaltable frame="all">
23866 <tgroup cols="4" colsep="0" rowsep="0">
23867 <colspec colwidth="8*" align="left"/>
23868 <colspec colwidth="6*" align="center"/>
23869 <colspec colwidth="6*" align="center"/>
23870 <colspec colwidth="6*" align="right"/>
23871 <tbody>
23872 <row>
23873 <entry><option>local_interfaces</option></entry>
23874 <entry>Use: <emphasis>main</emphasis></entry>
23875 <entry>Type: <emphasis>string list</emphasis></entry>
23876 <entry>Default: <emphasis>see below</emphasis></entry>
23877 </row>
23878 </tbody>
23879 </tgroup>
23880 </informaltable>
23881 <para>
23882 This option controls which network interfaces are used by the daemon for
23883 listening; they are also used to identify the local host when routing. Chapter
23884 <xref linkend="CHAPinterfaces"/> contains a full description of this option and the related
23885 options <option>daemon_smtp_ports</option>, <option>extra_local_interfaces</option>,
23886 <option>hosts_treat_as_local</option>, and <option>tls_on_connect_ports</option>. The default value for
23887 <option>local_interfaces</option> is
23888 </para>
23889 <literallayout class="monospaced">
23890 local_interfaces = 0.0.0.0
23891 </literallayout>
23892 <para>
23893 when Exim is built without IPv6 support; otherwise it is
23894 </para>
23895 <literallayout class="monospaced">
23896 local_interfaces = &lt;; ::0 ; 0.0.0.0
23897 </literallayout>
23898 <para>
23899 <indexterm role="option">
23900 <primary><option>local_scan_timeout</option></primary>
23901 </indexterm>
23902 </para>
23903 <informaltable frame="all">
23904 <tgroup cols="4" colsep="0" rowsep="0">
23905 <colspec colwidth="8*" align="left"/>
23906 <colspec colwidth="6*" align="center"/>
23907 <colspec colwidth="6*" align="center"/>
23908 <colspec colwidth="6*" align="right"/>
23909 <tbody>
23910 <row>
23911 <entry><option>local_scan_timeout</option></entry>
23912 <entry>Use: <emphasis>main</emphasis></entry>
23913 <entry>Type: <emphasis>time</emphasis></entry>
23914 <entry>Default: <emphasis>5m</emphasis></entry>
23915 </row>
23916 </tbody>
23917 </tgroup>
23918 </informaltable>
23919 <para>
23920 <indexterm role="concept">
23921 <primary>timeout</primary>
23922 <secondary>for <function>local_scan()</function> function</secondary>
23923 </indexterm>
23924 <indexterm role="concept">
23925 <primary><function>local_scan()</function> function</primary>
23926 <secondary>timeout</secondary>
23927 </indexterm>
23928 This timeout applies to the <function>local_scan()</function> function (see chapter
23929 <xref linkend="CHAPlocalscan"/>). Zero means <quote>no timeout</quote>. If the timeout is exceeded,
23930 the incoming message is rejected with a temporary error if it is an SMTP
23931 message. For a non-SMTP message, the message is dropped and Exim ends with a
23932 non-zero code. The incident is logged on the main and reject logs.
23933 </para>
23934 <para>
23935 <indexterm role="option">
23936 <primary><option>local_sender_retain</option></primary>
23937 </indexterm>
23938 </para>
23939 <informaltable frame="all">
23940 <tgroup cols="4" colsep="0" rowsep="0">
23941 <colspec colwidth="8*" align="left"/>
23942 <colspec colwidth="6*" align="center"/>
23943 <colspec colwidth="6*" align="center"/>
23944 <colspec colwidth="6*" align="right"/>
23945 <tbody>
23946 <row>
23947 <entry><option>local_sender_retain</option></entry>
23948 <entry>Use: <emphasis>main</emphasis></entry>
23949 <entry>Type: <emphasis>boolean</emphasis></entry>
23950 <entry>Default: <emphasis>false</emphasis></entry>
23951 </row>
23952 </tbody>
23953 </tgroup>
23954 </informaltable>
23955 <para>
23956 <indexterm role="concept">
23957 <primary><emphasis>Sender:</emphasis> header line</primary>
23958 <secondary>retaining from local submission</secondary>
23959 </indexterm>
23960 When a message is submitted locally (that is, not over a TCP/IP connection) by
23961 an untrusted user, Exim removes any existing <emphasis>Sender:</emphasis> header line. If you
23962 do not want this to happen, you must set <option>local_sender_retain</option>, and you must
23963 also set <option>local_from_check</option> to be false (Exim will complain if you do not).
23964 See also the ACL modifier <literal>control = suppress_local_fixups</literal>. Section
23965 <xref linkend="SECTthesenhea"/> has more details about <emphasis>Sender:</emphasis> processing.
23966 </para>
23967 <para>
23968 <indexterm role="option">
23969 <primary><option>localhost_number</option></primary>
23970 </indexterm>
23971 </para>
23972 <informaltable frame="all">
23973 <tgroup cols="4" colsep="0" rowsep="0">
23974 <colspec colwidth="8*" align="left"/>
23975 <colspec colwidth="6*" align="center"/>
23976 <colspec colwidth="6*" align="center"/>
23977 <colspec colwidth="6*" align="right"/>
23978 <tbody>
23979 <row>
23980 <entry><option>localhost_number</option></entry>
23981 <entry>Use: <emphasis>main</emphasis></entry>
23982 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23983 <entry>Default: <emphasis>unset</emphasis></entry>
23984 </row>
23985 </tbody>
23986 </tgroup>
23987 </informaltable>
23988 <para>
23989 <indexterm role="concept">
23990 <primary>host</primary>
23991 <secondary>locally unique number for</secondary>
23992 </indexterm>
23993 <indexterm role="concept">
23994 <primary>message ids</primary>
23995 <secondary>with multiple hosts</secondary>
23996 </indexterm>
23997 <indexterm role="variable">
23998 <primary><varname>$localhost_number</varname></primary>
23999 </indexterm>
24000 Exim&#x2019;s message ids are normally unique only within the local host. If
24001 uniqueness among a set of hosts is required, each host must set a different
24002 value for the <option>localhost_number</option> option. The string is expanded immediately
24003 after reading the configuration file (so that a number can be computed from the
24004 host name, for example) and the result of the expansion must be a number in the
24005 range 0&ndash;16 (or 0&ndash;10 on operating systems with case-insensitive file
24006 systems). This is available in subsequent string expansions via the variable
24007 <varname>$localhost_number</varname>. When <option>localhost_number is set</option>, the final two
24008 characters of the message id, instead of just being a fractional part of the
24009 time, are computed from the time and the local host number as described in
24010 section <xref linkend="SECTmessiden"/>.
24011 </para>
24012 <para>
24013 <indexterm role="option">
24014 <primary><option>log_file_path</option></primary>
24015 </indexterm>
24016 </para>
24017 <informaltable frame="all">
24018 <tgroup cols="4" colsep="0" rowsep="0">
24019 <colspec colwidth="8*" align="left"/>
24020 <colspec colwidth="6*" align="center"/>
24021 <colspec colwidth="6*" align="center"/>
24022 <colspec colwidth="6*" align="right"/>
24023 <tbody>
24024 <row>
24025 <entry><option>log_file_path</option></entry>
24026 <entry>Use: <emphasis>main</emphasis></entry>
24027 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
24028 <entry>Default: <emphasis>set at compile time</emphasis></entry>
24029 </row>
24030 </tbody>
24031 </tgroup>
24032 </informaltable>
24033 <para>
24034 <indexterm role="concept">
24035 <primary>log</primary>
24036 <secondary>file path for</secondary>
24037 </indexterm>
24038 This option sets the path which is used to determine the names of Exim&#x2019;s log
24039 files, or indicates that logging is to be to syslog, or both. It is expanded
24040 when Exim is entered, so it can, for example, contain a reference to the host
24041 name. If no specific path is set for the log files at compile or run time, they
24042 are written in a sub-directory called <filename>log</filename> in Exim&#x2019;s spool directory.
24043 Chapter <xref linkend="CHAPlog"/> contains further details about Exim&#x2019;s logging, and
24044 section <xref linkend="SECTwhelogwri"/> describes how the contents of <option>log_file_path</option> are
24045 used. If this string is fixed at your installation (contains no expansion
24046 variables) it is recommended that you do not set this option in the
24047 configuration file, but instead supply the path using LOG_FILE_PATH in
24048 <filename>Local/Makefile</filename> so that it is available to Exim for logging errors detected
24049 early on &ndash; in particular, failure to read the configuration file.
24050 </para>
24051 <para>
24052 <indexterm role="option">
24053 <primary><option>log_selector</option></primary>
24054 </indexterm>
24055 </para>
24056 <informaltable frame="all">
24057 <tgroup cols="4" colsep="0" rowsep="0">
24058 <colspec colwidth="8*" align="left"/>
24059 <colspec colwidth="6*" align="center"/>
24060 <colspec colwidth="6*" align="center"/>
24061 <colspec colwidth="6*" align="right"/>
24062 <tbody>
24063 <row>
24064 <entry><option>log_selector</option></entry>
24065 <entry>Use: <emphasis>main</emphasis></entry>
24066 <entry>Type: <emphasis>string</emphasis></entry>
24067 <entry>Default: <emphasis>unset</emphasis></entry>
24068 </row>
24069 </tbody>
24070 </tgroup>
24071 </informaltable>
24072 <para>
24073 <indexterm role="concept">
24074 <primary>log</primary>
24075 <secondary>selectors</secondary>
24076 </indexterm>
24077 This option can be used to reduce or increase the number of things that Exim
24078 writes to its log files. Its argument is made up of names preceded by plus or
24079 minus characters. For example:
24080 </para>
24081 <literallayout class="monospaced">
24082 log_selector = +arguments -retry_defer
24083 </literallayout>
24084 <para>
24085 A list of possible names and what they control is given in the chapter on
24086 logging, in section <xref linkend="SECTlogselector"/>.
24087 </para>
24088 <para>
24089 <indexterm role="option">
24090 <primary><option>log_timezone</option></primary>
24091 </indexterm>
24092 </para>
24093 <informaltable frame="all">
24094 <tgroup cols="4" colsep="0" rowsep="0">
24095 <colspec colwidth="8*" align="left"/>
24096 <colspec colwidth="6*" align="center"/>
24097 <colspec colwidth="6*" align="center"/>
24098 <colspec colwidth="6*" align="right"/>
24099 <tbody>
24100 <row>
24101 <entry><option>log_timezone</option></entry>
24102 <entry>Use: <emphasis>main</emphasis></entry>
24103 <entry>Type: <emphasis>boolean</emphasis></entry>
24104 <entry>Default: <emphasis>false</emphasis></entry>
24105 </row>
24106 </tbody>
24107 </tgroup>
24108 </informaltable>
24109 <para>
24110 <indexterm role="concept">
24111 <primary>log</primary>
24112 <secondary>timezone for entries</secondary>
24113 </indexterm>
24114 <indexterm role="variable">
24115 <primary><varname>$tod_log</varname></primary>
24116 </indexterm>
24117 <indexterm role="variable">
24118 <primary><varname>$tod_zone</varname></primary>
24119 </indexterm>
24120 By default, the timestamps on log lines are in local time without the
24121 timezone. This means that if your timezone changes twice a year, the timestamps
24122 in log lines are ambiguous for an hour when the clocks go back. One way of
24123 avoiding this problem is to set the timezone to UTC. An alternative is to set
24124 <option>log_timezone</option> true. This turns on the addition of the timezone offset to
24125 timestamps in log lines. Turning on this option can add quite a lot to the size
24126 of log files because each line is extended by 6 characters. Note that the
24127 <varname>$tod_log</varname> variable contains the log timestamp without the zone, but there is
24128 another variable called <varname>$tod_zone</varname> that contains just the timezone offset.
24129 </para>
24130 <para>
24131 <indexterm role="option">
24132 <primary><option>lookup_open_max</option></primary>
24133 </indexterm>
24134 </para>
24135 <informaltable frame="all">
24136 <tgroup cols="4" colsep="0" rowsep="0">
24137 <colspec colwidth="8*" align="left"/>
24138 <colspec colwidth="6*" align="center"/>
24139 <colspec colwidth="6*" align="center"/>
24140 <colspec colwidth="6*" align="right"/>
24141 <tbody>
24142 <row>
24143 <entry><option>lookup_open_max</option></entry>
24144 <entry>Use: <emphasis>main</emphasis></entry>
24145 <entry>Type: <emphasis>integer</emphasis></entry>
24146 <entry>Default: <emphasis>25</emphasis></entry>
24147 </row>
24148 </tbody>
24149 </tgroup>
24150 </informaltable>
24151 <para>
24152 <indexterm role="concept">
24153 <primary>too many open files</primary>
24154 </indexterm>
24155 <indexterm role="concept">
24156 <primary>open files, too many</primary>
24157 </indexterm>
24158 <indexterm role="concept">
24159 <primary>file</primary>
24160 <secondary>too many open</secondary>
24161 </indexterm>
24162 <indexterm role="concept">
24163 <primary>lookup</primary>
24164 <secondary>maximum open files</secondary>
24165 </indexterm>
24166 <indexterm role="concept">
24167 <primary>limit</primary>
24168 <secondary>open files for lookups</secondary>
24169 </indexterm>
24170 This option limits the number of simultaneously open files for single-key
24171 lookups that use regular files (that is, <command>lsearch</command>, <command>dbm</command>, and <command>cdb</command>).
24172 Exim normally keeps these files open during routing, because often the same
24173 file is required several times. If the limit is reached, Exim closes the least
24174 recently used file. Note that if you are using the <emphasis>ndbm</emphasis> library, it
24175 actually opens two files for each logical DBM database, though it still counts
24176 as one for the purposes of <option>lookup_open_max</option>. If you are getting <quote>too many
24177 open files</quote> errors with NDBM, you need to reduce the value of
24178 <option>lookup_open_max</option>.
24179 </para>
24180 <para>
24181 <indexterm role="option">
24182 <primary><option>max_username_length</option></primary>
24183 </indexterm>
24184 </para>
24185 <informaltable frame="all">
24186 <tgroup cols="4" colsep="0" rowsep="0">
24187 <colspec colwidth="8*" align="left"/>
24188 <colspec colwidth="6*" align="center"/>
24189 <colspec colwidth="6*" align="center"/>
24190 <colspec colwidth="6*" align="right"/>
24191 <tbody>
24192 <row>
24193 <entry><option>max_username_length</option></entry>
24194 <entry>Use: <emphasis>main</emphasis></entry>
24195 <entry>Type: <emphasis>integer</emphasis></entry>
24196 <entry>Default: <emphasis>0</emphasis></entry>
24197 </row>
24198 </tbody>
24199 </tgroup>
24200 </informaltable>
24201 <para>
24202 <indexterm role="concept">
24203 <primary>length of login name</primary>
24204 </indexterm>
24205 <indexterm role="concept">
24206 <primary>user name</primary>
24207 <secondary>maximum length</secondary>
24208 </indexterm>
24209 <indexterm role="concept">
24210 <primary>limit</primary>
24211 <secondary>user name length</secondary>
24212 </indexterm>
24213 Some operating systems are broken in that they truncate long arguments to
24214 <function>getpwnam()</function> to eight characters, instead of returning <quote>no such user</quote>. If
24215 this option is set greater than zero, any attempt to call <function>getpwnam()</function> with
24216 an argument that is longer behaves as if <function>getpwnam()</function> failed.
24217 </para>
24218 <para>
24219 <indexterm role="option">
24220 <primary><option>message_body_newlines</option></primary>
24221 </indexterm>
24222 </para>
24223 <informaltable frame="all">
24224 <tgroup cols="4" colsep="0" rowsep="0">
24225 <colspec colwidth="8*" align="left"/>
24226 <colspec colwidth="6*" align="center"/>
24227 <colspec colwidth="6*" align="center"/>
24228 <colspec colwidth="6*" align="right"/>
24229 <tbody>
24230 <row>
24231 <entry><option>message_body_newlines</option></entry>
24232 <entry>Use: <emphasis>main</emphasis></entry>
24233 <entry>Type: <emphasis>bool</emphasis></entry>
24234 <entry>Default: <emphasis>false</emphasis></entry>
24235 </row>
24236 </tbody>
24237 </tgroup>
24238 </informaltable>
24239 <para>
24240 <indexterm role="concept">
24241 <primary>message body</primary>
24242 <secondary>newlines in variables</secondary>
24243 </indexterm>
24244 <indexterm role="concept">
24245 <primary>newline</primary>
24246 <secondary>in message body variables</secondary>
24247 </indexterm>
24248 <indexterm role="variable">
24249 <primary><varname>$message_body</varname></primary>
24250 </indexterm>
24251 <indexterm role="variable">
24252 <primary><varname>$message_body_end</varname></primary>
24253 </indexterm>
24254 By default, newlines in the message body are replaced by spaces when setting
24255 the <varname>$message_body</varname> and <varname>$message_body_end</varname> expansion variables. If this
24256 option is set true, this no longer happens.
24257 </para>
24258 <para>
24259 <indexterm role="option">
24260 <primary><option>message_body_visible</option></primary>
24261 </indexterm>
24262 </para>
24263 <informaltable frame="all">
24264 <tgroup cols="4" colsep="0" rowsep="0">
24265 <colspec colwidth="8*" align="left"/>
24266 <colspec colwidth="6*" align="center"/>
24267 <colspec colwidth="6*" align="center"/>
24268 <colspec colwidth="6*" align="right"/>
24269 <tbody>
24270 <row>
24271 <entry><option>message_body_visible</option></entry>
24272 <entry>Use: <emphasis>main</emphasis></entry>
24273 <entry>Type: <emphasis>integer</emphasis></entry>
24274 <entry>Default: <emphasis>500</emphasis></entry>
24275 </row>
24276 </tbody>
24277 </tgroup>
24278 </informaltable>
24279 <para>
24280 <indexterm role="concept">
24281 <primary>body of message</primary>
24282 <secondary>visible size</secondary>
24283 </indexterm>
24284 <indexterm role="concept">
24285 <primary>message body</primary>
24286 <secondary>visible size</secondary>
24287 </indexterm>
24288 <indexterm role="variable">
24289 <primary><varname>$message_body</varname></primary>
24290 </indexterm>
24291 <indexterm role="variable">
24292 <primary><varname>$message_body_end</varname></primary>
24293 </indexterm>
24294 This option specifies how much of a message&#x2019;s body is to be included in the
24295 <varname>$message_body</varname> and <varname>$message_body_end</varname> expansion variables.
24296 </para>
24297 <para>
24298 <indexterm role="option">
24299 <primary><option>message_id_header_domain</option></primary>
24300 </indexterm>
24301 </para>
24302 <informaltable frame="all">
24303 <tgroup cols="4" colsep="0" rowsep="0">
24304 <colspec colwidth="8*" align="left"/>
24305 <colspec colwidth="6*" align="center"/>
24306 <colspec colwidth="6*" align="center"/>
24307 <colspec colwidth="6*" align="right"/>
24308 <tbody>
24309 <row>
24310 <entry><option>message_id_header_domain</option></entry>
24311 <entry>Use: <emphasis>main</emphasis></entry>
24312 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
24313 <entry>Default: <emphasis>unset</emphasis></entry>
24314 </row>
24315 </tbody>
24316 </tgroup>
24317 </informaltable>
24318 <para>
24319 <indexterm role="concept">
24320 <primary><emphasis>Message-ID:</emphasis> header line</primary>
24321 </indexterm>
24322 If this option is set, the string is expanded and used as the right hand side
24323 (domain) of the <emphasis>Message-ID:</emphasis> header that Exim creates if a
24324 locally-originated incoming message does not have one. <quote>Locally-originated</quote>
24325 means <quote>not received over TCP/IP.</quote>
24326 Otherwise, the primary host name is used.
24327 Only letters, digits, dot and hyphen are accepted; any other characters are
24328 replaced by hyphens. If the expansion is forced to fail, or if the result is an
24329 empty string, the option is ignored.
24330 </para>
24331 <para>
24332 <indexterm role="option">
24333 <primary><option>message_id_header_text</option></primary>
24334 </indexterm>
24335 </para>
24336 <informaltable frame="all">
24337 <tgroup cols="4" colsep="0" rowsep="0">
24338 <colspec colwidth="8*" align="left"/>
24339 <colspec colwidth="6*" align="center"/>
24340 <colspec colwidth="6*" align="center"/>
24341 <colspec colwidth="6*" align="right"/>
24342 <tbody>
24343 <row>
24344 <entry><option>message_id_header_text</option></entry>
24345 <entry>Use: <emphasis>main</emphasis></entry>
24346 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
24347 <entry>Default: <emphasis>unset</emphasis></entry>
24348 </row>
24349 </tbody>
24350 </tgroup>
24351 </informaltable>
24352 <para>
24353 If this variable is set, the string is expanded and used to augment the text of
24354 the <emphasis>Message-id:</emphasis> header that Exim creates if a locally-originated incoming
24355 message does not have one. The text of this header is required by RFC 2822 to
24356 take the form of an address. By default, Exim uses its internal message id as
24357 the local part, and the primary host name as the domain. If this option is set,
24358 it is expanded, and provided the expansion is not forced to fail, and does not
24359 yield an empty string, the result is inserted into the header immediately
24360 before the @, separated from the internal message id by a dot. Any characters
24361 that are illegal in an address are automatically converted into hyphens. This
24362 means that variables such as <varname>$tod_log</varname> can be used, because the spaces and
24363 colons will become hyphens.
24364 </para>
24365 <para>
24366 <indexterm role="option">
24367 <primary><option>message_logs</option></primary>
24368 </indexterm>
24369 </para>
24370 <informaltable frame="all">
24371 <tgroup cols="4" colsep="0" rowsep="0">
24372 <colspec colwidth="8*" align="left"/>
24373 <colspec colwidth="6*" align="center"/>
24374 <colspec colwidth="6*" align="center"/>
24375 <colspec colwidth="6*" align="right"/>
24376 <tbody>
24377 <row>
24378 <entry><option>message_logs</option></entry>
24379 <entry>Use: <emphasis>main</emphasis></entry>
24380 <entry>Type: <emphasis>boolean</emphasis></entry>
24381 <entry>Default: <emphasis>true</emphasis></entry>
24382 </row>
24383 </tbody>
24384 </tgroup>
24385 </informaltable>
24386 <para>
24387 <indexterm role="concept">
24388 <primary>message logs</primary>
24389 <secondary>disabling</secondary>
24390 </indexterm>
24391 <indexterm role="concept">
24392 <primary>log</primary>
24393 <secondary>message log; disabling</secondary>
24394 </indexterm>
24395 If this option is turned off, per-message log files are not created in the
24396 <filename>msglog</filename> spool sub-directory. This reduces the amount of disk I/O required by
24397 Exim, by reducing the number of files involved in handling a message from a
24398 minimum of four (header spool file, body spool file, delivery journal, and
24399 per-message log) to three. The other major I/O activity is Exim&#x2019;s main log,
24400 which is not affected by this option.
24401 </para>
24402 <para>
24403 <indexterm role="option">
24404 <primary><option>message_size_limit</option></primary>
24405 </indexterm>
24406 </para>
24407 <informaltable frame="all">
24408 <tgroup cols="4" colsep="0" rowsep="0">
24409 <colspec colwidth="8*" align="left"/>
24410 <colspec colwidth="6*" align="center"/>
24411 <colspec colwidth="6*" align="center"/>
24412 <colspec colwidth="6*" align="right"/>
24413 <tbody>
24414 <row>
24415 <entry><option>message_size_limit</option></entry>
24416 <entry>Use: <emphasis>main</emphasis></entry>
24417 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
24418 <entry>Default: <emphasis>50M</emphasis></entry>
24419 </row>
24420 </tbody>
24421 </tgroup>
24422 </informaltable>
24423 <para>
24424 <indexterm role="concept">
24425 <primary>message</primary>
24426 <secondary>size limit</secondary>
24427 </indexterm>
24428 <indexterm role="concept">
24429 <primary>limit</primary>
24430 <secondary>message size</secondary>
24431 </indexterm>
24432 <indexterm role="concept">
24433 <primary>size</primary>
24434 <secondary>of message, limit</secondary>
24435 </indexterm>
24436 This option limits the maximum size of message that Exim will process. The
24437 value is expanded for each incoming connection so, for example, it can be made
24438 to depend on the IP address of the remote host for messages arriving via
24439 TCP/IP. After expansion, the value must be a sequence of decimal digits,
24440 optionally followed by K or M.
24441 </para>
24442 <para>
24443 <emphasis role="bold">Note</emphasis>: This limit cannot be made to depend on a message&#x2019;s sender or any
24444 other properties of an individual message, because it has to be advertised in
24445 the server&#x2019;s response to EHLO. String expansion failure causes a temporary
24446 error. A value of zero means no limit, but its use is not recommended. See also
24447 <option>bounce_return_size_limit</option>.
24448 </para>
24449 <para>
24450 Incoming SMTP messages are failed with a 552 error if the limit is
24451 exceeded; locally-generated messages either get a stderr message or a delivery
24452 failure message to the sender, depending on the <option>-oe</option> setting. Rejection of
24453 an oversized message is logged in both the main and the reject logs. See also
24454 the generic transport option <option>message_size_limit</option>, which limits the size of
24455 message that an individual transport can process.
24456 </para>
24457 <para revisionflag="changed">
24458 If you use a virus-scanner and set this option to to a value larger than the
24459 maximum size that your virus-scanner is configured to support, you may get
24460 failures triggered by large mails.  The right size to configure for the
24461 virus-scanner depends upon what data is passed and the options in use but it&#x2019;s
24462 probably safest to just set it to a little larger than this value.  Eg, with a
24463 default Exim message size of 50M and a default ClamAV StreamMaxLength of 10M,
24464 some problems may result.
24465 </para>
24466 <para>
24467 <indexterm role="option">
24468 <primary><option>move_frozen_messages</option></primary>
24469 </indexterm>
24470 </para>
24471 <informaltable frame="all">
24472 <tgroup cols="4" colsep="0" rowsep="0">
24473 <colspec colwidth="8*" align="left"/>
24474 <colspec colwidth="6*" align="center"/>
24475 <colspec colwidth="6*" align="center"/>
24476 <colspec colwidth="6*" align="right"/>
24477 <tbody>
24478 <row>
24479 <entry><option>move_frozen_messages</option></entry>
24480 <entry>Use: <emphasis>main</emphasis></entry>
24481 <entry>Type: <emphasis>boolean</emphasis></entry>
24482 <entry>Default: <emphasis>false</emphasis></entry>
24483 </row>
24484 </tbody>
24485 </tgroup>
24486 </informaltable>
24487 <para>
24488 <indexterm role="concept">
24489 <primary>frozen messages</primary>
24490 <secondary>moving</secondary>
24491 </indexterm>
24492 This option, which is available only if Exim has been built with the setting
24493 </para>
24494 <literallayout class="monospaced">
24495 SUPPORT_MOVE_FROZEN_MESSAGES=yes
24496 </literallayout>
24497 <para>
24498 in <filename>Local/Makefile</filename>, causes frozen messages and their message logs to be
24499 moved from the <filename>input</filename> and <filename>msglog</filename> directories on the spool to <filename>Finput</filename>
24500 and <filename>Fmsglog</filename>, respectively. There is currently no support in Exim or the
24501 standard utilities for handling such moved messages, and they do not show up in
24502 lists generated by <option>-bp</option> or by the Exim monitor.
24503 </para>
24504 <para>
24505 <indexterm role="option">
24506 <primary><option>mua_wrapper</option></primary>
24507 </indexterm>
24508 </para>
24509 <informaltable frame="all">
24510 <tgroup cols="4" colsep="0" rowsep="0">
24511 <colspec colwidth="8*" align="left"/>
24512 <colspec colwidth="6*" align="center"/>
24513 <colspec colwidth="6*" align="center"/>
24514 <colspec colwidth="6*" align="right"/>
24515 <tbody>
24516 <row>
24517 <entry><option>mua_wrapper</option></entry>
24518 <entry>Use: <emphasis>main</emphasis></entry>
24519 <entry>Type: <emphasis>boolean</emphasis></entry>
24520 <entry>Default: <emphasis>false</emphasis></entry>
24521 </row>
24522 </tbody>
24523 </tgroup>
24524 </informaltable>
24525 <para>
24526 Setting this option true causes Exim to run in a very restrictive mode in which
24527 it passes messages synchronously to a smart host. Chapter <xref linkend="CHAPnonqueueing"/>
24528 contains a full description of this facility.
24529 </para>
24530 <para>
24531 <indexterm role="option">
24532 <primary><option>mysql_servers</option></primary>
24533 </indexterm>
24534 </para>
24535 <informaltable frame="all">
24536 <tgroup cols="4" colsep="0" rowsep="0">
24537 <colspec colwidth="8*" align="left"/>
24538 <colspec colwidth="6*" align="center"/>
24539 <colspec colwidth="6*" align="center"/>
24540 <colspec colwidth="6*" align="right"/>
24541 <tbody>
24542 <row>
24543 <entry><option>mysql_servers</option></entry>
24544 <entry>Use: <emphasis>main</emphasis></entry>
24545 <entry>Type: <emphasis>string list</emphasis></entry>
24546 <entry>Default: <emphasis>unset</emphasis></entry>
24547 </row>
24548 </tbody>
24549 </tgroup>
24550 </informaltable>
24551 <para>
24552 <indexterm role="concept">
24553 <primary>MySQL</primary>
24554 <secondary>server list</secondary>
24555 </indexterm>
24556 This option provides a list of MySQL servers and associated connection data, to
24557 be used in conjunction with <command>mysql</command> lookups (see section <xref linkend="SECID72"/>). The
24558 option is available only if Exim has been built with MySQL support.
24559 </para>
24560 <para>
24561 <indexterm role="option">
24562 <primary><option>never_users</option></primary>
24563 </indexterm>
24564 </para>
24565 <informaltable frame="all">
24566 <tgroup cols="4" colsep="0" rowsep="0">
24567 <colspec colwidth="8*" align="left"/>
24568 <colspec colwidth="6*" align="center"/>
24569 <colspec colwidth="6*" align="center"/>
24570 <colspec colwidth="6*" align="right"/>
24571 <tbody>
24572 <row>
24573 <entry><option>never_users</option></entry>
24574 <entry>Use: <emphasis>main</emphasis></entry>
24575 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
24576 <entry>Default: <emphasis>unset</emphasis></entry>
24577 </row>
24578 </tbody>
24579 </tgroup>
24580 </informaltable>
24581 <para>
24582 This option is expanded just once, at the start of Exim&#x2019;s processing. Local
24583 message deliveries are normally run in processes that are setuid to the
24584 recipient, and remote deliveries are normally run under Exim&#x2019;s own uid and gid.
24585 It is usually desirable to prevent any deliveries from running as root, as a
24586 safety precaution.
24587 </para>
24588 <para>
24589 When Exim is built, an option called FIXED_NEVER_USERS can be set to a
24590 list of users that must not be used for local deliveries. This list is fixed in
24591 the binary and cannot be overridden by the configuration file. By default, it
24592 contains just the single user name <quote>root</quote>. The <option>never_users</option> runtime option
24593 can be used to add more users to the fixed list.
24594 </para>
24595 <para>
24596 If a message is to be delivered as one of the users on the fixed list or the
24597 <option>never_users</option> list, an error occurs, and delivery is deferred. A common
24598 example is
24599 </para>
24600 <literallayout class="monospaced">
24601 never_users = root:daemon:bin
24602 </literallayout>
24603 <para>
24604 Including root is redundant if it is also on the fixed list, but it does no
24605 harm. This option overrides the <option>pipe_as_creator</option> option of the <command>pipe</command>
24606 transport driver.
24607 </para>
24608 <para revisionflag="changed">
24609 <indexterm role="option">
24610 <primary><option>openssl_options</option></primary>
24611 </indexterm>
24612 </para>
24613 <informaltable frame="all" revisionflag="changed">
24614 <tgroup cols="4" colsep="0" rowsep="0">
24615 <colspec colwidth="8*" align="left"/>
24616 <colspec colwidth="6*" align="center"/>
24617 <colspec colwidth="6*" align="center"/>
24618 <colspec colwidth="6*" align="right"/>
24619 <tbody>
24620 <row>
24621 <entry><option>openssl_options</option></entry>
24622 <entry>Use: <emphasis>main</emphasis></entry>
24623 <entry>Type: <emphasis>string list</emphasis></entry>
24624 <entry>Default: <emphasis>+dont_insert_empty_fragments</emphasis></entry>
24625 </row>
24626 </tbody>
24627 </tgroup>
24628 </informaltable>
24629 <para revisionflag="changed">
24630 <indexterm role="concept">
24631 <primary>OpenSSL </primary>
24632 <secondary>compatibility</secondary>
24633 </indexterm>
24634 This option allows an administrator to adjust the SSL options applied
24635 by OpenSSL to connections.  It is given as a space-separated list of items,
24636 each one to be +added or -subtracted from the current value.  The default
24637 value is one option which happens to have been set historically.  You can
24638 remove all options with:
24639 </para>
24640 <literallayout class="monospaced" revisionflag="changed">
24641 openssl_options = -all
24642 </literallayout>
24643 <para revisionflag="changed">
24644 This option is only available if Exim is built against OpenSSL.  The values
24645 available for this option vary according to the age of your OpenSSL install.
24646 The <quote>all</quote> value controls a subset of flags which are available, typically
24647 the bug workaround options.  The <emphasis>SSL_CTX_set_options</emphasis> man page will
24648 list the values known on your system and Exim should support all the
24649 <quote>bug workaround</quote> options and many of the <quote>modifying</quote> options.  The Exim
24650 names lose the leading <quote>SSL_OP_</quote> and are lower-cased.
24651 </para>
24652 <para revisionflag="changed">
24653 Note that adjusting the options can have severe impact upon the security of
24654 SSL as used by Exim.  It is possible to disable safety checks and shoot
24655 yourself in the foot in various unpleasant ways.  This option should not be
24656 adjusted lightly.  An unrecognised item will be detected at by invoking Exim
24657 with the <option>-bV</option> flag.
24658 </para>
24659 <para revisionflag="changed">
24660 An example:
24661 </para>
24662 <literallayout class="monospaced" revisionflag="changed">
24663 openssl_options = -all +microsoft_big_sslv3_buffer
24664 </literallayout>
24665 <para>
24666 <indexterm role="option">
24667 <primary><option>oracle_servers</option></primary>
24668 </indexterm>
24669 </para>
24670 <informaltable frame="all">
24671 <tgroup cols="4" colsep="0" rowsep="0">
24672 <colspec colwidth="8*" align="left"/>
24673 <colspec colwidth="6*" align="center"/>
24674 <colspec colwidth="6*" align="center"/>
24675 <colspec colwidth="6*" align="right"/>
24676 <tbody>
24677 <row>
24678 <entry><option>oracle_servers</option></entry>
24679 <entry>Use: <emphasis>main</emphasis></entry>
24680 <entry>Type: <emphasis>string list</emphasis></entry>
24681 <entry>Default: <emphasis>unset</emphasis></entry>
24682 </row>
24683 </tbody>
24684 </tgroup>
24685 </informaltable>
24686 <para>
24687 <indexterm role="concept">
24688 <primary>Oracle</primary>
24689 <secondary>server list</secondary>
24690 </indexterm>
24691 This option provides a list of Oracle servers and associated connection data,
24692 to be used in conjunction with <command>oracle</command> lookups (see section <xref linkend="SECID72"/>).
24693 The option is available only if Exim has been built with Oracle support.
24694 </para>
24695 <para>
24696 <indexterm role="option">
24697 <primary><option>percent_hack_domains</option></primary>
24698 </indexterm>
24699 </para>
24700 <informaltable frame="all">
24701 <tgroup cols="4" colsep="0" rowsep="0">
24702 <colspec colwidth="8*" align="left"/>
24703 <colspec colwidth="6*" align="center"/>
24704 <colspec colwidth="6*" align="center"/>
24705 <colspec colwidth="6*" align="right"/>
24706 <tbody>
24707 <row>
24708 <entry><option>percent_hack_domains</option></entry>
24709 <entry>Use: <emphasis>main</emphasis></entry>
24710 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
24711 <entry>Default: <emphasis>unset</emphasis></entry>
24712 </row>
24713 </tbody>
24714 </tgroup>
24715 </informaltable>
24716 <para>
24717 <indexterm role="concept">
24718 <primary><quote>percent hack</quote></primary>
24719 </indexterm>
24720 <indexterm role="concept">
24721 <primary>source routing</primary>
24722 <secondary>in email address</secondary>
24723 </indexterm>
24724 <indexterm role="concept">
24725 <primary>address</primary>
24726 <secondary>source-routed</secondary>
24727 </indexterm>
24728 The <quote>percent hack</quote> is the convention whereby a local part containing a
24729 percent sign is re-interpreted as a new email address, with the percent
24730 replaced by @. This is sometimes called <quote>source routing</quote>, though that term is
24731 also applied to RFC 2822 addresses that begin with an @ character. If this
24732 option is set, Exim implements the percent facility for those domains listed,
24733 but no others. This happens before an incoming SMTP address is tested against
24734 an ACL.
24735 </para>
24736 <para>
24737 <emphasis role="bold">Warning</emphasis>: The <quote>percent hack</quote> has often been abused by people who are
24738 trying to get round relaying restrictions. For this reason, it is best avoided
24739 if at all possible. Unfortunately, a number of less security-conscious MTAs
24740 implement it unconditionally. If you are running Exim on a gateway host, and
24741 routing mail through to internal MTAs without processing the local parts, it is
24742 a good idea to reject recipient addresses with percent characters in their
24743 local parts. Exim&#x2019;s default configuration does this.
24744 </para>
24745 <para>
24746 <indexterm role="option">
24747 <primary><option>perl_at_start</option></primary>
24748 </indexterm>
24749 </para>
24750 <informaltable frame="all">
24751 <tgroup cols="4" colsep="0" rowsep="0">
24752 <colspec colwidth="8*" align="left"/>
24753 <colspec colwidth="6*" align="center"/>
24754 <colspec colwidth="6*" align="center"/>
24755 <colspec colwidth="6*" align="right"/>
24756 <tbody>
24757 <row>
24758 <entry><option>perl_at_start</option></entry>
24759 <entry>Use: <emphasis>main</emphasis></entry>
24760 <entry>Type: <emphasis>boolean</emphasis></entry>
24761 <entry>Default: <emphasis>false</emphasis></entry>
24762 </row>
24763 </tbody>
24764 </tgroup>
24765 </informaltable>
24766 <para>
24767 This option is available only when Exim is built with an embedded Perl
24768 interpreter. See chapter <xref linkend="CHAPperl"/> for details of its use.
24769 </para>
24770 <para>
24771 <indexterm role="option">
24772 <primary><option>perl_startup</option></primary>
24773 </indexterm>
24774 </para>
24775 <informaltable frame="all">
24776 <tgroup cols="4" colsep="0" rowsep="0">
24777 <colspec colwidth="8*" align="left"/>
24778 <colspec colwidth="6*" align="center"/>
24779 <colspec colwidth="6*" align="center"/>
24780 <colspec colwidth="6*" align="right"/>
24781 <tbody>
24782 <row>
24783 <entry><option>perl_startup</option></entry>
24784 <entry>Use: <emphasis>main</emphasis></entry>
24785 <entry>Type: <emphasis>string</emphasis></entry>
24786 <entry>Default: <emphasis>unset</emphasis></entry>
24787 </row>
24788 </tbody>
24789 </tgroup>
24790 </informaltable>
24791 <para>
24792 This option is available only when Exim is built with an embedded Perl
24793 interpreter. See chapter <xref linkend="CHAPperl"/> for details of its use.
24794 </para>
24795 <para>
24796 <indexterm role="option">
24797 <primary><option>pgsql_servers</option></primary>
24798 </indexterm>
24799 </para>
24800 <informaltable frame="all">
24801 <tgroup cols="4" colsep="0" rowsep="0">
24802 <colspec colwidth="8*" align="left"/>
24803 <colspec colwidth="6*" align="center"/>
24804 <colspec colwidth="6*" align="center"/>
24805 <colspec colwidth="6*" align="right"/>
24806 <tbody>
24807 <row>
24808 <entry><option>pgsql_servers</option></entry>
24809 <entry>Use: <emphasis>main</emphasis></entry>
24810 <entry>Type: <emphasis>string list</emphasis></entry>
24811 <entry>Default: <emphasis>unset</emphasis></entry>
24812 </row>
24813 </tbody>
24814 </tgroup>
24815 </informaltable>
24816 <para>
24817 <indexterm role="concept">
24818 <primary>PostgreSQL lookup type</primary>
24819 <secondary>server list</secondary>
24820 </indexterm>
24821 This option provides a list of PostgreSQL servers and associated connection
24822 data, to be used in conjunction with <command>pgsql</command> lookups (see section
24823 <xref linkend="SECID72"/>). The option is available only if Exim has been built with
24824 PostgreSQL support.
24825 </para>
24826 <para>
24827 <indexterm role="option">
24828 <primary><option>pid_file_path</option></primary>
24829 </indexterm>
24830 </para>
24831 <informaltable frame="all">
24832 <tgroup cols="4" colsep="0" rowsep="0">
24833 <colspec colwidth="8*" align="left"/>
24834 <colspec colwidth="6*" align="center"/>
24835 <colspec colwidth="6*" align="center"/>
24836 <colspec colwidth="6*" align="right"/>
24837 <tbody>
24838 <row>
24839 <entry><option>pid_file_path</option></entry>
24840 <entry>Use: <emphasis>main</emphasis></entry>
24841 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
24842 <entry>Default: <emphasis>set at compile time</emphasis></entry>
24843 </row>
24844 </tbody>
24845 </tgroup>
24846 </informaltable>
24847 <para>
24848 <indexterm role="concept">
24849 <primary>daemon</primary>
24850 <secondary>pid file path</secondary>
24851 </indexterm>
24852 <indexterm role="concept">
24853 <primary>pid file, path for</primary>
24854 </indexterm>
24855 This option sets the name of the file to which the Exim daemon writes its
24856 process id. The string is expanded, so it can contain, for example, references
24857 to the host name:
24858 </para>
24859 <literallayout class="monospaced">
24860 pid_file_path = /var/log/$primary_hostname/exim.pid
24861 </literallayout>
24862 <para>
24863 If no path is set, the pid is written to the file <filename>exim-daemon.pid</filename> in Exim&#x2019;s
24864 spool directory.
24865 The value set by the option can be overridden by the <option>-oP</option> command line
24866 option. A pid file is not written if a <quote>non-standard</quote> daemon is run by means
24867 of the <option>-oX</option> option, unless a path is explicitly supplied by <option>-oP</option>.
24868 </para>
24869 <para>
24870 <indexterm role="option">
24871 <primary><option>pipelining_advertise_hosts</option></primary>
24872 </indexterm>
24873 </para>
24874 <informaltable frame="all">
24875 <tgroup cols="4" colsep="0" rowsep="0">
24876 <colspec colwidth="8*" align="left"/>
24877 <colspec colwidth="6*" align="center"/>
24878 <colspec colwidth="6*" align="center"/>
24879 <colspec colwidth="6*" align="right"/>
24880 <tbody>
24881 <row>
24882 <entry><option>pipelining_advertise_hosts</option></entry>
24883 <entry>Use: <emphasis>main</emphasis></entry>
24884 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
24885 <entry>Default: <emphasis>*</emphasis></entry>
24886 </row>
24887 </tbody>
24888 </tgroup>
24889 </informaltable>
24890 <para>
24891 <indexterm role="concept">
24892 <primary>PIPELINING</primary>
24893 <secondary>suppressing advertising</secondary>
24894 </indexterm>
24895 This option can be used to suppress the advertisement of the SMTP
24896 PIPELINING extension to specific hosts. See also the <emphasis role="bold">no_pipelining</emphasis>
24897 control in section <xref linkend="SECTcontrols"/>. When PIPELINING is not advertised and
24898 <option>smtp_enforce_sync</option> is true, an Exim server enforces strict synchronization
24899 for each SMTP command and response. When PIPELINING is advertised, Exim assumes
24900 that clients will use it; <quote>out of order</quote> commands that are <quote>expected</quote> do
24901 not count as protocol errors (see <option>smtp_max_synprot_errors</option>).
24902 </para>
24903 <para>
24904 <indexterm role="option">
24905 <primary><option>preserve_message_logs</option></primary>
24906 </indexterm>
24907 </para>
24908 <informaltable frame="all">
24909 <tgroup cols="4" colsep="0" rowsep="0">
24910 <colspec colwidth="8*" align="left"/>
24911 <colspec colwidth="6*" align="center"/>
24912 <colspec colwidth="6*" align="center"/>
24913 <colspec colwidth="6*" align="right"/>
24914 <tbody>
24915 <row>
24916 <entry><option>preserve_message_logs</option></entry>
24917 <entry>Use: <emphasis>main</emphasis></entry>
24918 <entry>Type: <emphasis>boolean</emphasis></entry>
24919 <entry>Default: <emphasis>false</emphasis></entry>
24920 </row>
24921 </tbody>
24922 </tgroup>
24923 </informaltable>
24924 <para>
24925 <indexterm role="concept">
24926 <primary>message logs</primary>
24927 <secondary>preserving</secondary>
24928 </indexterm>
24929 If this option is set, message log files are not deleted when messages are
24930 completed. Instead, they are moved to a sub-directory of the spool directory
24931 called <filename>msglog.OLD</filename>, where they remain available for statistical or debugging
24932 purposes. This is a dangerous option to set on systems with any appreciable
24933 volume of mail. Use with care!
24934 </para>
24935 <para>
24936 <indexterm role="option">
24937 <primary><option>primary_hostname</option></primary>
24938 </indexterm>
24939 </para>
24940 <informaltable frame="all">
24941 <tgroup cols="4" colsep="0" rowsep="0">
24942 <colspec colwidth="8*" align="left"/>
24943 <colspec colwidth="6*" align="center"/>
24944 <colspec colwidth="6*" align="center"/>
24945 <colspec colwidth="6*" align="right"/>
24946 <tbody>
24947 <row>
24948 <entry><option>primary_hostname</option></entry>
24949 <entry>Use: <emphasis>main</emphasis></entry>
24950 <entry>Type: <emphasis>string</emphasis></entry>
24951 <entry>Default: <emphasis>see below</emphasis></entry>
24952 </row>
24953 </tbody>
24954 </tgroup>
24955 </informaltable>
24956 <para>
24957 <indexterm role="concept">
24958 <primary>name</primary>
24959 <secondary>of local host</secondary>
24960 </indexterm>
24961 <indexterm role="concept">
24962 <primary>host</primary>
24963 <secondary>name of local</secondary>
24964 </indexterm>
24965 <indexterm role="concept">
24966 <primary>local host</primary>
24967 <secondary>name of</secondary>
24968 </indexterm>
24969 <indexterm role="variable">
24970 <primary><varname>$primary_hostname</varname></primary>
24971 </indexterm>
24972 This specifies the name of the current host. It is used in the default EHLO or
24973 HELO command for outgoing SMTP messages (changeable via the <option>helo_data</option>
24974 option in the <command>smtp</command> transport), and as the default for <option>qualify_domain</option>.
24975 The value is also used by default in some SMTP response messages from an Exim
24976 server. This can be changed dynamically by setting <option>smtp_active_hostname</option>.
24977 </para>
24978 <para>
24979 If <option>primary_hostname</option> is not set, Exim calls <function>uname()</function> to find the host
24980 name. If this fails, Exim panics and dies. If the name returned by <function>uname()</function>
24981 contains only one component, Exim passes it to <function>gethostbyname()</function> (or
24982 <function>getipnodebyname()</function> when available) in order to obtain the fully qualified
24983 version. The variable <varname>$primary_hostname</varname> contains the host name, whether set
24984 explicitly by this option, or defaulted.
24985 </para>
24986 <para>
24987 <indexterm role="option">
24988 <primary><option>print_topbitchars</option></primary>
24989 </indexterm>
24990 </para>
24991 <informaltable frame="all">
24992 <tgroup cols="4" colsep="0" rowsep="0">
24993 <colspec colwidth="8*" align="left"/>
24994 <colspec colwidth="6*" align="center"/>
24995 <colspec colwidth="6*" align="center"/>
24996 <colspec colwidth="6*" align="right"/>
24997 <tbody>
24998 <row>
24999 <entry><option>print_topbitchars</option></entry>
25000 <entry>Use: <emphasis>main</emphasis></entry>
25001 <entry>Type: <emphasis>boolean</emphasis></entry>
25002 <entry>Default: <emphasis>false</emphasis></entry>
25003 </row>
25004 </tbody>
25005 </tgroup>
25006 </informaltable>
25007 <para>
25008 <indexterm role="concept">
25009 <primary>printing characters</primary>
25010 </indexterm>
25011 <indexterm role="concept">
25012 <primary>8-bit characters</primary>
25013 </indexterm>
25014 By default, Exim considers only those characters whose codes lie in the range
25015 32&ndash;126 to be printing characters. In a number of circumstances (for example,
25016 when writing log entries) non-printing characters are converted into escape
25017 sequences, primarily to avoid messing up the layout. If <option>print_topbitchars</option>
25018 is set, code values of 128 and above are also considered to be printing
25019 characters.
25020 </para>
25021 <para>
25022 This option also affects the header syntax checks performed by the
25023 <command>autoreply</command> transport, and whether Exim uses RFC 2047 encoding of
25024 the user&#x2019;s full name when constructing From: and Sender: addresses (as
25025 described in section <xref linkend="SECTconstr"/>). Setting this option can cause
25026 Exim to generate eight bit message headers that do not conform to the
25027 standards.
25028 </para>
25029 <para>
25030 <indexterm role="option">
25031 <primary><option>process_log_path</option></primary>
25032 </indexterm>
25033 </para>
25034 <informaltable frame="all">
25035 <tgroup cols="4" colsep="0" rowsep="0">
25036 <colspec colwidth="8*" align="left"/>
25037 <colspec colwidth="6*" align="center"/>
25038 <colspec colwidth="6*" align="center"/>
25039 <colspec colwidth="6*" align="right"/>
25040 <tbody>
25041 <row>
25042 <entry><option>process_log_path</option></entry>
25043 <entry>Use: <emphasis>main</emphasis></entry>
25044 <entry>Type: <emphasis>string</emphasis></entry>
25045 <entry>Default: <emphasis>unset</emphasis></entry>
25046 </row>
25047 </tbody>
25048 </tgroup>
25049 </informaltable>
25050 <para>
25051 <indexterm role="concept">
25052 <primary>process log path</primary>
25053 </indexterm>
25054 <indexterm role="concept">
25055 <primary>log</primary>
25056 <secondary>process log</secondary>
25057 </indexterm>
25058 <indexterm role="concept">
25059 <primary><emphasis>exiwhat</emphasis></primary>
25060 </indexterm>
25061 This option sets the name of the file to which an Exim process writes its
25062 <quote>process log</quote> when sent a USR1 signal. This is used by the <emphasis>exiwhat</emphasis>
25063 utility script. If this option is unset, the file called <filename>exim-process.info</filename>
25064 in Exim&#x2019;s spool directory is used. The ability to specify the name explicitly
25065 can be useful in environments where two different Exims are running, using
25066 different spool directories.
25067 </para>
25068 <para>
25069 <indexterm role="option">
25070 <primary><option>prod_requires_admin</option></primary>
25071 </indexterm>
25072 </para>
25073 <informaltable frame="all">
25074 <tgroup cols="4" colsep="0" rowsep="0">
25075 <colspec colwidth="8*" align="left"/>
25076 <colspec colwidth="6*" align="center"/>
25077 <colspec colwidth="6*" align="center"/>
25078 <colspec colwidth="6*" align="right"/>
25079 <tbody>
25080 <row>
25081 <entry><option>prod_requires_admin</option></entry>
25082 <entry>Use: <emphasis>main</emphasis></entry>
25083 <entry>Type: <emphasis>boolean</emphasis></entry>
25084 <entry>Default: <emphasis>true</emphasis></entry>
25085 </row>
25086 </tbody>
25087 </tgroup>
25088 </informaltable>
25089 <para>
25090 <indexterm role="option">
25091 <primary><option>-M</option></primary>
25092 </indexterm>
25093 <indexterm role="option">
25094 <primary><option>-R</option></primary>
25095 </indexterm>
25096 <indexterm role="option">
25097 <primary><option>-q</option></primary>
25098 </indexterm>
25099 The <option>-M</option>, <option>-R</option>, and <option>-q</option> command-line options require the caller to be an
25100 admin user unless <option>prod_requires_admin</option> is set false. See also
25101 <option>queue_list_requires_admin</option>.
25102 </para>
25103 <para>
25104 <indexterm role="option">
25105 <primary><option>qualify_domain</option></primary>
25106 </indexterm>
25107 </para>
25108 <informaltable frame="all">
25109 <tgroup cols="4" colsep="0" rowsep="0">
25110 <colspec colwidth="8*" align="left"/>
25111 <colspec colwidth="6*" align="center"/>
25112 <colspec colwidth="6*" align="center"/>
25113 <colspec colwidth="6*" align="right"/>
25114 <tbody>
25115 <row>
25116 <entry><option>qualify_domain</option></entry>
25117 <entry>Use: <emphasis>main</emphasis></entry>
25118 <entry>Type: <emphasis>string</emphasis></entry>
25119 <entry>Default: <emphasis>see below</emphasis></entry>
25120 </row>
25121 </tbody>
25122 </tgroup>
25123 </informaltable>
25124 <para>
25125 <indexterm role="concept">
25126 <primary>domain</primary>
25127 <secondary>for qualifying addresses</secondary>
25128 </indexterm>
25129 <indexterm role="concept">
25130 <primary>address</primary>
25131 <secondary>qualification</secondary>
25132 </indexterm>
25133 This option specifies the domain name that is added to any envelope sender
25134 addresses that do not have a domain qualification. It also applies to
25135 recipient addresses if <option>qualify_recipient</option> is not set. Unqualified addresses
25136 are accepted by default only for locally-generated messages. Qualification is
25137 also applied to addresses in header lines such as <emphasis>From:</emphasis> and <emphasis>To:</emphasis> for
25138 locally-generated messages, unless the <option>-bnq</option> command line option is used.
25139 </para>
25140 <para>
25141 Messages from external sources must always contain fully qualified addresses,
25142 unless the sending host matches <option>sender_unqualified_hosts</option> or
25143 <option>recipient_unqualified_hosts</option> (as appropriate), in which case incoming
25144 addresses are qualified with <option>qualify_domain</option> or <option>qualify_recipient</option> as
25145 necessary. Internally, Exim always works with fully qualified envelope
25146 addresses. If <option>qualify_domain</option> is not set, it defaults to the
25147 <option>primary_hostname</option> value.
25148 </para>
25149 <para>
25150 <indexterm role="option">
25151 <primary><option>qualify_recipient</option></primary>
25152 </indexterm>
25153 </para>
25154 <informaltable frame="all">
25155 <tgroup cols="4" colsep="0" rowsep="0">
25156 <colspec colwidth="8*" align="left"/>
25157 <colspec colwidth="6*" align="center"/>
25158 <colspec colwidth="6*" align="center"/>
25159 <colspec colwidth="6*" align="right"/>
25160 <tbody>
25161 <row>
25162 <entry><option>qualify_recipient</option></entry>
25163 <entry>Use: <emphasis>main</emphasis></entry>
25164 <entry>Type: <emphasis>string</emphasis></entry>
25165 <entry>Default: <emphasis>see below</emphasis></entry>
25166 </row>
25167 </tbody>
25168 </tgroup>
25169 </informaltable>
25170 <para>
25171 This option allows you to specify a different domain for qualifying recipient
25172 addresses to the one that is used for senders. See <option>qualify_domain</option> above.
25173 </para>
25174 <para>
25175 <indexterm role="option">
25176 <primary><option>queue_domains</option></primary>
25177 </indexterm>
25178 </para>
25179 <informaltable frame="all">
25180 <tgroup cols="4" colsep="0" rowsep="0">
25181 <colspec colwidth="8*" align="left"/>
25182 <colspec colwidth="6*" align="center"/>
25183 <colspec colwidth="6*" align="center"/>
25184 <colspec colwidth="6*" align="right"/>
25185 <tbody>
25186 <row>
25187 <entry><option>queue_domains</option></entry>
25188 <entry>Use: <emphasis>main</emphasis></entry>
25189 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
25190 <entry>Default: <emphasis>unset</emphasis></entry>
25191 </row>
25192 </tbody>
25193 </tgroup>
25194 </informaltable>
25195 <para>
25196 <indexterm role="concept">
25197 <primary>domain</primary>
25198 <secondary>specifying non-immediate delivery</secondary>
25199 </indexterm>
25200 <indexterm role="concept">
25201 <primary>queueing incoming messages</primary>
25202 </indexterm>
25203 <indexterm role="concept">
25204 <primary>message</primary>
25205 <secondary>queueing certain domains</secondary>
25206 </indexterm>
25207 This option lists domains for which immediate delivery is not required.
25208 A delivery process is started whenever a message is received, but only those
25209 domains that do not match are processed. All other deliveries wait until the
25210 next queue run. See also <option>hold_domains</option> and <option>queue_smtp_domains</option>.
25211 </para>
25212 <para>
25213 <indexterm role="option">
25214 <primary><option>queue_list_requires_admin</option></primary>
25215 </indexterm>
25216 </para>
25217 <informaltable frame="all">
25218 <tgroup cols="4" colsep="0" rowsep="0">
25219 <colspec colwidth="8*" align="left"/>
25220 <colspec colwidth="6*" align="center"/>
25221 <colspec colwidth="6*" align="center"/>
25222 <colspec colwidth="6*" align="right"/>
25223 <tbody>
25224 <row>
25225 <entry><option>queue_list_requires_admin</option></entry>
25226 <entry>Use: <emphasis>main</emphasis></entry>
25227 <entry>Type: <emphasis>boolean</emphasis></entry>
25228 <entry>Default: <emphasis>true</emphasis></entry>
25229 </row>
25230 </tbody>
25231 </tgroup>
25232 </informaltable>
25233 <para>
25234 <indexterm role="option">
25235 <primary><option>-bp</option></primary>
25236 </indexterm>
25237 The <option>-bp</option> command-line option, which lists the messages that are on the
25238 queue, requires the caller to be an admin user unless
25239 <option>queue_list_requires_admin</option> is set false. See also <option>prod_requires_admin</option>.
25240 </para>
25241 <para>
25242 <indexterm role="option">
25243 <primary><option>queue_only</option></primary>
25244 </indexterm>
25245 </para>
25246 <informaltable frame="all">
25247 <tgroup cols="4" colsep="0" rowsep="0">
25248 <colspec colwidth="8*" align="left"/>
25249 <colspec colwidth="6*" align="center"/>
25250 <colspec colwidth="6*" align="center"/>
25251 <colspec colwidth="6*" align="right"/>
25252 <tbody>
25253 <row>
25254 <entry><option>queue_only</option></entry>
25255 <entry>Use: <emphasis>main</emphasis></entry>
25256 <entry>Type: <emphasis>boolean</emphasis></entry>
25257 <entry>Default: <emphasis>false</emphasis></entry>
25258 </row>
25259 </tbody>
25260 </tgroup>
25261 </informaltable>
25262 <para>
25263 <indexterm role="concept">
25264 <primary>queueing incoming messages</primary>
25265 </indexterm>
25266 <indexterm role="concept">
25267 <primary>message</primary>
25268 <secondary>queueing unconditionally</secondary>
25269 </indexterm>
25270 If <option>queue_only</option> is set, a delivery process is not automatically started
25271 whenever a message is received. Instead, the message waits on the queue for the
25272 next queue run. Even if <option>queue_only</option> is false, incoming messages may not get
25273 delivered immediately when certain conditions (such as heavy load) occur.
25274 </para>
25275 <para>
25276 The <option>-odq</option> command line has the same effect as <option>queue_only</option>. The <option>-odb</option>
25277 and <option>-odi</option> command line options override <option>queue_only</option> unless
25278 <option>queue_only_override</option> is set false. See also <option>queue_only_file</option>,
25279 <option>queue_only_load</option>, and <option>smtp_accept_queue</option>.
25280 </para>
25281 <para>
25282 <indexterm role="option">
25283 <primary><option>queue_only_file</option></primary>
25284 </indexterm>
25285 </para>
25286 <informaltable frame="all">
25287 <tgroup cols="4" colsep="0" rowsep="0">
25288 <colspec colwidth="8*" align="left"/>
25289 <colspec colwidth="6*" align="center"/>
25290 <colspec colwidth="6*" align="center"/>
25291 <colspec colwidth="6*" align="right"/>
25292 <tbody>
25293 <row>
25294 <entry><option>queue_only_file</option></entry>
25295 <entry>Use: <emphasis>main</emphasis></entry>
25296 <entry>Type: <emphasis>string</emphasis></entry>
25297 <entry>Default: <emphasis>unset</emphasis></entry>
25298 </row>
25299 </tbody>
25300 </tgroup>
25301 </informaltable>
25302 <para>
25303 <indexterm role="concept">
25304 <primary>queueing incoming messages</primary>
25305 </indexterm>
25306 <indexterm role="concept">
25307 <primary>message</primary>
25308 <secondary>queueing by file existence</secondary>
25309 </indexterm>
25310 This option can be set to a colon-separated list of absolute path names, each
25311 one optionally preceded by <quote>smtp</quote>. When Exim is receiving a message,
25312 it tests for the existence of each listed path using a call to <function>stat()</function>. For
25313 each path that exists, the corresponding queueing option is set.
25314 For paths with no prefix, <option>queue_only</option> is set; for paths prefixed by
25315 <quote>smtp</quote>, <option>queue_smtp_domains</option> is set to match all domains. So, for example,
25316 </para>
25317 <literallayout class="monospaced">
25318 queue_only_file = smtp/some/file
25319 </literallayout>
25320 <para>
25321 causes Exim to behave as if <option>queue_smtp_domains</option> were set to <quote>*</quote> whenever
25322 <filename>/some/file</filename> exists.
25323 </para>
25324 <para>
25325 <indexterm role="option">
25326 <primary><option>queue_only_load</option></primary>
25327 </indexterm>
25328 </para>
25329 <informaltable frame="all">
25330 <tgroup cols="4" colsep="0" rowsep="0">
25331 <colspec colwidth="8*" align="left"/>
25332 <colspec colwidth="6*" align="center"/>
25333 <colspec colwidth="6*" align="center"/>
25334 <colspec colwidth="6*" align="right"/>
25335 <tbody>
25336 <row>
25337 <entry><option>queue_only_load</option></entry>
25338 <entry>Use: <emphasis>main</emphasis></entry>
25339 <entry>Type: <emphasis>fixed-point</emphasis></entry>
25340 <entry>Default: <emphasis>unset</emphasis></entry>
25341 </row>
25342 </tbody>
25343 </tgroup>
25344 </informaltable>
25345 <para>
25346 <indexterm role="concept">
25347 <primary>load average</primary>
25348 </indexterm>
25349 <indexterm role="concept">
25350 <primary>queueing incoming messages</primary>
25351 </indexterm>
25352 <indexterm role="concept">
25353 <primary>message</primary>
25354 <secondary>queueing by load</secondary>
25355 </indexterm>
25356 If the system load average is higher than this value, incoming messages from
25357 all sources are queued, and no automatic deliveries are started. If this
25358 happens during local or remote SMTP input, all subsequent messages received on
25359 the same SMTP connection are queued by default, whatever happens to the load in
25360 the meantime, but this can be changed by setting <option>queue_only_load_latch</option>
25361 false.
25362 </para>
25363 <para>
25364 Deliveries will subsequently be performed by queue runner processes. This
25365 option has no effect on ancient operating systems on which Exim cannot
25366 determine the load average. See also <option>deliver_queue_load_max</option> and
25367 <option>smtp_load_reserve</option>.
25368 </para>
25369 <para>
25370 <indexterm role="option">
25371 <primary><option>queue_only_load_latch</option></primary>
25372 </indexterm>
25373 </para>
25374 <informaltable frame="all">
25375 <tgroup cols="4" colsep="0" rowsep="0">
25376 <colspec colwidth="8*" align="left"/>
25377 <colspec colwidth="6*" align="center"/>
25378 <colspec colwidth="6*" align="center"/>
25379 <colspec colwidth="6*" align="right"/>
25380 <tbody>
25381 <row>
25382 <entry><option>queue_only_load_latch</option></entry>
25383 <entry>Use: <emphasis>main</emphasis></entry>
25384 <entry>Type: <emphasis>boolean</emphasis></entry>
25385 <entry>Default: <emphasis>true</emphasis></entry>
25386 </row>
25387 </tbody>
25388 </tgroup>
25389 </informaltable>
25390 <para>
25391 <indexterm role="concept">
25392 <primary>load average</primary>
25393 <secondary>re-evaluating per message</secondary>
25394 </indexterm>
25395 When this option is true (the default), once one message has been queued
25396 because the load average is higher than the value set by <option>queue_only_load</option>,
25397 all subsequent messages received on the same SMTP connection are also queued.
25398 This is a deliberate choice; even though the load average may fall below the
25399 threshold, it doesn&#x2019;t seem right to deliver later messages on the same
25400 connection when not delivering earlier ones. However, there are special
25401 circumstances such as very long-lived connections from scanning appliances
25402 where this is not the best strategy. In such cases, <option>queue_only_load_latch</option>
25403 should be set false. This causes the value of the load average to be
25404 re-evaluated for each message.
25405 </para>
25406 <para>
25407 <indexterm role="option">
25408 <primary><option>queue_only_override</option></primary>
25409 </indexterm>
25410 </para>
25411 <informaltable frame="all">
25412 <tgroup cols="4" colsep="0" rowsep="0">
25413 <colspec colwidth="8*" align="left"/>
25414 <colspec colwidth="6*" align="center"/>
25415 <colspec colwidth="6*" align="center"/>
25416 <colspec colwidth="6*" align="right"/>
25417 <tbody>
25418 <row>
25419 <entry><option>queue_only_override</option></entry>
25420 <entry>Use: <emphasis>main</emphasis></entry>
25421 <entry>Type: <emphasis>boolean</emphasis></entry>
25422 <entry>Default: <emphasis>true</emphasis></entry>
25423 </row>
25424 </tbody>
25425 </tgroup>
25426 </informaltable>
25427 <para>
25428 <indexterm role="concept">
25429 <primary>queueing incoming messages</primary>
25430 </indexterm>
25431 When this option is true, the <option>-od</option><emphasis>x</emphasis> command line options override the
25432 setting of <option>queue_only</option> or <option>queue_only_file</option> in the configuration file. If
25433 <option>queue_only_override</option> is set false, the <option>-od</option><emphasis>x</emphasis> options cannot be used
25434 to override; they are accepted, but ignored.
25435 </para>
25436 <para>
25437 <indexterm role="option">
25438 <primary><option>queue_run_in_order</option></primary>
25439 </indexterm>
25440 </para>
25441 <informaltable frame="all">
25442 <tgroup cols="4" colsep="0" rowsep="0">
25443 <colspec colwidth="8*" align="left"/>
25444 <colspec colwidth="6*" align="center"/>
25445 <colspec colwidth="6*" align="center"/>
25446 <colspec colwidth="6*" align="right"/>
25447 <tbody>
25448 <row>
25449 <entry><option>queue_run_in_order</option></entry>
25450 <entry>Use: <emphasis>main</emphasis></entry>
25451 <entry>Type: <emphasis>boolean</emphasis></entry>
25452 <entry>Default: <emphasis>false</emphasis></entry>
25453 </row>
25454 </tbody>
25455 </tgroup>
25456 </informaltable>
25457 <para>
25458 <indexterm role="concept">
25459 <primary>queue runner</primary>
25460 <secondary>processing messages in order</secondary>
25461 </indexterm>
25462 If this option is set, queue runs happen in order of message arrival instead of
25463 in an arbitrary order. For this to happen, a complete list of the entire queue
25464 must be set up before the deliveries start. When the queue is all held in a
25465 single directory (the default), a single list is created for both the ordered
25466 and the non-ordered cases. However, if <option>split_spool_directory</option> is set, a
25467 single list is not created when <option>queue_run_in_order</option> is false. In this case,
25468 the sub-directories are processed one at a time (in a random order), and this
25469 avoids setting up one huge list for the whole queue. Thus, setting
25470 <option>queue_run_in_order</option> with <option>split_spool_directory</option> may degrade performance
25471 when the queue is large, because of the extra work in setting up the single,
25472 large list. In most situations, <option>queue_run_in_order</option> should not be set.
25473 </para>
25474 <para>
25475 <indexterm role="option">
25476 <primary><option>queue_run_max</option></primary>
25477 </indexterm>
25478 </para>
25479 <informaltable frame="all">
25480 <tgroup cols="4" colsep="0" rowsep="0">
25481 <colspec colwidth="8*" align="left"/>
25482 <colspec colwidth="6*" align="center"/>
25483 <colspec colwidth="6*" align="center"/>
25484 <colspec colwidth="6*" align="right"/>
25485 <tbody>
25486 <row>
25487 <entry><option>queue_run_max</option></entry>
25488 <entry>Use: <emphasis>main</emphasis></entry>
25489 <entry>Type: <emphasis>integer</emphasis></entry>
25490 <entry>Default: <emphasis>5</emphasis></entry>
25491 </row>
25492 </tbody>
25493 </tgroup>
25494 </informaltable>
25495 <para>
25496 <indexterm role="concept">
25497 <primary>queue runner</primary>
25498 <secondary>maximum number of</secondary>
25499 </indexterm>
25500 This controls the maximum number of queue runner processes that an Exim daemon
25501 can run simultaneously. This does not mean that it starts them all at once,
25502 but rather that if the maximum number are still running when the time comes to
25503 start another one, it refrains from starting another one. This can happen with
25504 very large queues and/or very sluggish deliveries. This option does not,
25505 however, interlock with other processes, so additional queue runners can be
25506 started by other means, or by killing and restarting the daemon.
25507 </para>
25508 <para>
25509 Setting this option to zero does not suppress queue runs; rather, it disables
25510 the limit, allowing any number of simultaneous queue runner processes to be
25511 run. If you do not want queue runs to occur, omit the <option>-q</option><emphasis>xx</emphasis> setting on
25512 the daemon&#x2019;s command line.
25513 </para>
25514 <para>
25515 <indexterm role="option">
25516 <primary><option>queue_smtp_domains</option></primary>
25517 </indexterm>
25518 </para>
25519 <informaltable frame="all">
25520 <tgroup cols="4" colsep="0" rowsep="0">
25521 <colspec colwidth="8*" align="left"/>
25522 <colspec colwidth="6*" align="center"/>
25523 <colspec colwidth="6*" align="center"/>
25524 <colspec colwidth="6*" align="right"/>
25525 <tbody>
25526 <row>
25527 <entry><option>queue_smtp_domains</option></entry>
25528 <entry>Use: <emphasis>main</emphasis></entry>
25529 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
25530 <entry>Default: <emphasis>unset</emphasis></entry>
25531 </row>
25532 </tbody>
25533 </tgroup>
25534 </informaltable>
25535 <para>
25536 <indexterm role="concept">
25537 <primary>queueing incoming messages</primary>
25538 </indexterm>
25539 <indexterm role="concept">
25540 <primary>message</primary>
25541 <secondary>queueing remote deliveries</secondary>
25542 </indexterm>
25543 When this option is set, a delivery process is started whenever a message is
25544 received, routing is performed, and local deliveries take place.
25545 However, if any SMTP deliveries are required for domains that match
25546 <option>queue_smtp_domains</option>, they are not immediately delivered, but instead the
25547 message waits on the queue for the next queue run. Since routing of the message
25548 has taken place, Exim knows to which remote hosts it must be delivered, and so
25549 when the queue run happens, multiple messages for the same host are delivered
25550 over a single SMTP connection. The <option>-odqs</option> command line option causes all
25551 SMTP deliveries to be queued in this way, and is equivalent to setting
25552 <option>queue_smtp_domains</option> to <quote>*</quote>. See also <option>hold_domains</option> and
25553 <option>queue_domains</option>.
25554 </para>
25555 <para>
25556 <indexterm role="option">
25557 <primary><option>receive_timeout</option></primary>
25558 </indexterm>
25559 </para>
25560 <informaltable frame="all">
25561 <tgroup cols="4" colsep="0" rowsep="0">
25562 <colspec colwidth="8*" align="left"/>
25563 <colspec colwidth="6*" align="center"/>
25564 <colspec colwidth="6*" align="center"/>
25565 <colspec colwidth="6*" align="right"/>
25566 <tbody>
25567 <row>
25568 <entry><option>receive_timeout</option></entry>
25569 <entry>Use: <emphasis>main</emphasis></entry>
25570 <entry>Type: <emphasis>time</emphasis></entry>
25571 <entry>Default: <emphasis>0s</emphasis></entry>
25572 </row>
25573 </tbody>
25574 </tgroup>
25575 </informaltable>
25576 <para>
25577 <indexterm role="concept">
25578 <primary>timeout</primary>
25579 <secondary>for non-SMTP input</secondary>
25580 </indexterm>
25581 This option sets the timeout for accepting a non-SMTP message, that is, the
25582 maximum time that Exim waits when reading a message on the standard input. If
25583 the value is zero, it will wait for ever. This setting is overridden by the
25584 <option>-or</option> command line option. The timeout for incoming SMTP messages is
25585 controlled by <option>smtp_receive_timeout</option>.
25586 </para>
25587 <para>
25588 <indexterm role="option">
25589 <primary><option>received_header_text</option></primary>
25590 </indexterm>
25591 </para>
25592 <informaltable frame="all">
25593 <tgroup cols="4" colsep="0" rowsep="0">
25594 <colspec colwidth="8*" align="left"/>
25595 <colspec colwidth="6*" align="center"/>
25596 <colspec colwidth="6*" align="center"/>
25597 <colspec colwidth="6*" align="right"/>
25598 <tbody>
25599 <row>
25600 <entry><option>received_header_text</option></entry>
25601 <entry>Use: <emphasis>main</emphasis></entry>
25602 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
25603 <entry>Default: <emphasis>see below</emphasis></entry>
25604 </row>
25605 </tbody>
25606 </tgroup>
25607 </informaltable>
25608 <para>
25609 <indexterm role="concept">
25610 <primary>customizing</primary>
25611 <secondary><emphasis>Received:</emphasis> header</secondary>
25612 </indexterm>
25613 <indexterm role="concept">
25614 <primary><emphasis>Received:</emphasis> header line</primary>
25615 <secondary>customizing</secondary>
25616 </indexterm>
25617 This string defines the contents of the <emphasis>Received:</emphasis> message header that is
25618 added to each message, except for the timestamp, which is automatically added
25619 on at the end (preceded by a semicolon). The string is expanded each time it is
25620 used. If the expansion yields an empty string, no <emphasis>Received:</emphasis> header line is
25621 added to the message. Otherwise, the string should start with the text
25622 <quote>Received:</quote> and conform to the RFC 2822 specification for <emphasis>Received:</emphasis>
25623 header lines. The default setting is:
25624 </para>
25625 <literallayout class="monospaced">
25626 received_header_text = Received: \
25627   ${if def:sender_rcvhost {from $sender_rcvhost\n\t}\
25628   {${if def:sender_ident \
25629   {from ${quote_local_part:$sender_ident} }}\
25630   ${if def:sender_helo_name {(helo=$sender_helo_name)\n\t}}}}\
25631   by $primary_hostname \
25632   ${if def:received_protocol {with $received_protocol}} \
25633   ${if def:tls_cipher {($tls_cipher)\n\t}}\
25634   (Exim $version_number)\n\t\
25635   ${if def:sender_address \
25636   {(envelope-from &lt;$sender_address&gt;)\n\t}}\
25637   id $message_exim_id\
25638   ${if def:received_for {\n\tfor $received_for}}
25639 </literallayout>
25640 <para>
25641 The reference to the TLS cipher is omitted when Exim is built without TLS
25642 support. The use of conditional expansions ensures that this works for both
25643 locally generated messages and messages received from remote hosts, giving
25644 header lines such as the following:
25645 </para>
25646 <literallayout class="monospaced">
25647 Received: from scrooge.carol.example ([192.168.12.25] ident=root)
25648 by marley.carol.example with esmtp (Exim 4.00)
25649 (envelope-from &lt;bob@carol.example&gt;)
25650 id 16IOWa-00019l-00
25651 for chas@dickens.example; Tue, 25 Dec 2001 14:43:44 +0000
25652 Received: by scrooge.carol.example with local (Exim 4.00)
25653 id 16IOWW-000083-00; Tue, 25 Dec 2001 14:43:41 +0000
25654 </literallayout>
25655 <para>
25656 Until the body of the message has been received, the timestamp is the time when
25657 the message started to be received. Once the body has arrived, and all policy
25658 checks have taken place, the timestamp is updated to the time at which the
25659 message was accepted.
25660 </para>
25661 <para>
25662 <indexterm role="option">
25663 <primary><option>received_headers_max</option></primary>
25664 </indexterm>
25665 </para>
25666 <informaltable frame="all">
25667 <tgroup cols="4" colsep="0" rowsep="0">
25668 <colspec colwidth="8*" align="left"/>
25669 <colspec colwidth="6*" align="center"/>
25670 <colspec colwidth="6*" align="center"/>
25671 <colspec colwidth="6*" align="right"/>
25672 <tbody>
25673 <row>
25674 <entry><option>received_headers_max</option></entry>
25675 <entry>Use: <emphasis>main</emphasis></entry>
25676 <entry>Type: <emphasis>integer</emphasis></entry>
25677 <entry>Default: <emphasis>30</emphasis></entry>
25678 </row>
25679 </tbody>
25680 </tgroup>
25681 </informaltable>
25682 <para>
25683 <indexterm role="concept">
25684 <primary>loop</primary>
25685 <secondary>prevention</secondary>
25686 </indexterm>
25687 <indexterm role="concept">
25688 <primary>mail loop prevention</primary>
25689 </indexterm>
25690 <indexterm role="concept">
25691 <primary><emphasis>Received:</emphasis> header line</primary>
25692 <secondary>counting</secondary>
25693 </indexterm>
25694 When a message is to be delivered, the number of <emphasis>Received:</emphasis> headers is
25695 counted, and if it is greater than this parameter, a mail loop is assumed to
25696 have occurred, the delivery is abandoned, and an error message is generated.
25697 This applies to both local and remote deliveries.
25698 </para>
25699 <para>
25700 <indexterm role="option">
25701 <primary><option>recipient_unqualified_hosts</option></primary>
25702 </indexterm>
25703 </para>
25704 <informaltable frame="all">
25705 <tgroup cols="4" colsep="0" rowsep="0">
25706 <colspec colwidth="8*" align="left"/>
25707 <colspec colwidth="6*" align="center"/>
25708 <colspec colwidth="6*" align="center"/>
25709 <colspec colwidth="6*" align="right"/>
25710 <tbody>
25711 <row>
25712 <entry><option>recipient_unqualified_hosts</option></entry>
25713 <entry>Use: <emphasis>main</emphasis></entry>
25714 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
25715 <entry>Default: <emphasis>unset</emphasis></entry>
25716 </row>
25717 </tbody>
25718 </tgroup>
25719 </informaltable>
25720 <para>
25721 <indexterm role="concept">
25722 <primary>unqualified addresses</primary>
25723 </indexterm>
25724 <indexterm role="concept">
25725 <primary>host</primary>
25726 <secondary>unqualified addresses from</secondary>
25727 </indexterm>
25728 This option lists those hosts from which Exim is prepared to accept unqualified
25729 recipient addresses in message envelopes. The addresses are made fully
25730 qualified by the addition of the <option>qualify_recipient</option> value. This option also
25731 affects message header lines. Exim does not reject unqualified recipient
25732 addresses in headers, but it qualifies them only if the message came from a
25733 host that matches <option>recipient_unqualified_hosts</option>,
25734 or if the message was submitted locally (not using TCP/IP), and the <option>-bnq</option>
25735 option was not set.
25736 </para>
25737 <para>
25738 <indexterm role="option">
25739 <primary><option>recipients_max</option></primary>
25740 </indexterm>
25741 </para>
25742 <informaltable frame="all">
25743 <tgroup cols="4" colsep="0" rowsep="0">
25744 <colspec colwidth="8*" align="left"/>
25745 <colspec colwidth="6*" align="center"/>
25746 <colspec colwidth="6*" align="center"/>
25747 <colspec colwidth="6*" align="right"/>
25748 <tbody>
25749 <row>
25750 <entry><option>recipients_max</option></entry>
25751 <entry>Use: <emphasis>main</emphasis></entry>
25752 <entry>Type: <emphasis>integer</emphasis></entry>
25753 <entry>Default: <emphasis>0</emphasis></entry>
25754 </row>
25755 </tbody>
25756 </tgroup>
25757 </informaltable>
25758 <para>
25759 <indexterm role="concept">
25760 <primary>limit</primary>
25761 <secondary>number of recipients</secondary>
25762 </indexterm>
25763 <indexterm role="concept">
25764 <primary>recipient</primary>
25765 <secondary>maximum number</secondary>
25766 </indexterm>
25767 If this option is set greater than zero, it specifies the maximum number of
25768 original recipients for any message. Additional recipients that are generated
25769 by aliasing or forwarding do not count. SMTP messages get a 452 response for
25770 all recipients over the limit; earlier recipients are delivered as normal.
25771 Non-SMTP messages with too many recipients are failed, and no deliveries are
25772 done.
25773 </para>
25774 <para>
25775 <indexterm role="concept">
25776 <primary>RCPT</primary>
25777 <secondary>maximum number of incoming</secondary>
25778 </indexterm>
25779 <emphasis role="bold">Note</emphasis>: The RFCs specify that an SMTP server should accept at least 100
25780 RCPT commands in a single message.
25781 </para>
25782 <para>
25783 <indexterm role="option">
25784 <primary><option>recipients_max_reject</option></primary>
25785 </indexterm>
25786 </para>
25787 <informaltable frame="all">
25788 <tgroup cols="4" colsep="0" rowsep="0">
25789 <colspec colwidth="8*" align="left"/>
25790 <colspec colwidth="6*" align="center"/>
25791 <colspec colwidth="6*" align="center"/>
25792 <colspec colwidth="6*" align="right"/>
25793 <tbody>
25794 <row>
25795 <entry><option>recipients_max_reject</option></entry>
25796 <entry>Use: <emphasis>main</emphasis></entry>
25797 <entry>Type: <emphasis>boolean</emphasis></entry>
25798 <entry>Default: <emphasis>false</emphasis></entry>
25799 </row>
25800 </tbody>
25801 </tgroup>
25802 </informaltable>
25803 <para>
25804 If this option is set true, Exim rejects SMTP messages containing too many
25805 recipients by giving 552 errors to the surplus RCPT commands, and a 554
25806 error to the eventual DATA command. Otherwise (the default) it gives a 452
25807 error to the surplus RCPT commands and accepts the message on behalf of the
25808 initial set of recipients. The remote server should then re-send the message
25809 for the remaining recipients at a later time.
25810 </para>
25811 <para>
25812 <indexterm role="option">
25813 <primary><option>remote_max_parallel</option></primary>
25814 </indexterm>
25815 </para>
25816 <informaltable frame="all">
25817 <tgroup cols="4" colsep="0" rowsep="0">
25818 <colspec colwidth="8*" align="left"/>
25819 <colspec colwidth="6*" align="center"/>
25820 <colspec colwidth="6*" align="center"/>
25821 <colspec colwidth="6*" align="right"/>
25822 <tbody>
25823 <row>
25824 <entry><option>remote_max_parallel</option></entry>
25825 <entry>Use: <emphasis>main</emphasis></entry>
25826 <entry>Type: <emphasis>integer</emphasis></entry>
25827 <entry>Default: <emphasis>2</emphasis></entry>
25828 </row>
25829 </tbody>
25830 </tgroup>
25831 </informaltable>
25832 <para>
25833 <indexterm role="concept">
25834 <primary>delivery</primary>
25835 <secondary>parallelism for remote</secondary>
25836 </indexterm>
25837 This option controls parallel delivery of one message to a number of remote
25838 hosts. If the value is less than 2, parallel delivery is disabled, and Exim
25839 does all the remote deliveries for a message one by one. Otherwise, if a single
25840 message has to be delivered to more than one remote host, or if several copies
25841 have to be sent to the same remote host, up to <option>remote_max_parallel</option>
25842 deliveries are done simultaneously. If more than <option>remote_max_parallel</option>
25843 deliveries are required, the maximum number of processes are started, and as
25844 each one finishes, another is begun. The order of starting processes is the
25845 same as if sequential delivery were being done, and can be controlled by the
25846 <option>remote_sort_domains</option> option. If parallel delivery takes place while running
25847 with debugging turned on, the debugging output from each delivery process is
25848 tagged with its process id.
25849 </para>
25850 <para>
25851 This option controls only the maximum number of parallel deliveries for one
25852 message in one Exim delivery process. Because Exim has no central queue
25853 manager, there is no way of controlling the total number of simultaneous
25854 deliveries if the configuration allows a delivery attempt as soon as a message
25855 is received.
25856 </para>
25857 <para>
25858 <indexterm role="concept">
25859 <primary>number of deliveries</primary>
25860 </indexterm>
25861 <indexterm role="concept">
25862 <primary>delivery</primary>
25863 <secondary>maximum number of</secondary>
25864 </indexterm>
25865 If you want to control the total number of deliveries on the system, you
25866 need to set the <option>queue_only</option> option. This ensures that all incoming messages
25867 are added to the queue without starting a delivery process. Then set up an Exim
25868 daemon to start queue runner processes at appropriate intervals (probably
25869 fairly often, for example, every minute), and limit the total number of queue
25870 runners by setting the <option>queue_run_max</option> parameter. Because each queue runner
25871 delivers only one message at a time, the maximum number of deliveries that can
25872 then take place at once is <option>queue_run_max</option> multiplied by
25873 <option>remote_max_parallel</option>.
25874 </para>
25875 <para>
25876 If it is purely remote deliveries you want to control, use
25877 <option>queue_smtp_domains</option> instead of <option>queue_only</option>. This has the added benefit of
25878 doing the SMTP routing before queueing, so that several messages for the same
25879 host will eventually get delivered down the same connection.
25880 </para>
25881 <para>
25882 <indexterm role="option">
25883 <primary><option>remote_sort_domains</option></primary>
25884 </indexterm>
25885 </para>
25886 <informaltable frame="all">
25887 <tgroup cols="4" colsep="0" rowsep="0">
25888 <colspec colwidth="8*" align="left"/>
25889 <colspec colwidth="6*" align="center"/>
25890 <colspec colwidth="6*" align="center"/>
25891 <colspec colwidth="6*" align="right"/>
25892 <tbody>
25893 <row>
25894 <entry><option>remote_sort_domains</option></entry>
25895 <entry>Use: <emphasis>main</emphasis></entry>
25896 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
25897 <entry>Default: <emphasis>unset</emphasis></entry>
25898 </row>
25899 </tbody>
25900 </tgroup>
25901 </informaltable>
25902 <para>
25903 <indexterm role="concept">
25904 <primary>sorting remote deliveries</primary>
25905 </indexterm>
25906 <indexterm role="concept">
25907 <primary>delivery</primary>
25908 <secondary>sorting remote</secondary>
25909 </indexterm>
25910 When there are a number of remote deliveries for a message, they are sorted by
25911 domain into the order given by this list. For example,
25912 </para>
25913 <literallayout class="monospaced">
25914 remote_sort_domains = *.cam.ac.uk:*.uk
25915 </literallayout>
25916 <para>
25917 would attempt to deliver to all addresses in the <emphasis>cam.ac.uk</emphasis> domain first,
25918 then to those in the <option>uk</option> domain, then to any others.
25919 </para>
25920 <para>
25921 <indexterm role="option">
25922 <primary><option>retry_data_expire</option></primary>
25923 </indexterm>
25924 </para>
25925 <informaltable frame="all">
25926 <tgroup cols="4" colsep="0" rowsep="0">
25927 <colspec colwidth="8*" align="left"/>
25928 <colspec colwidth="6*" align="center"/>
25929 <colspec colwidth="6*" align="center"/>
25930 <colspec colwidth="6*" align="right"/>
25931 <tbody>
25932 <row>
25933 <entry><option>retry_data_expire</option></entry>
25934 <entry>Use: <emphasis>main</emphasis></entry>
25935 <entry>Type: <emphasis>time</emphasis></entry>
25936 <entry>Default: <emphasis>7d</emphasis></entry>
25937 </row>
25938 </tbody>
25939 </tgroup>
25940 </informaltable>
25941 <para>
25942 <indexterm role="concept">
25943 <primary>hints database</primary>
25944 <secondary>data expiry</secondary>
25945 </indexterm>
25946 This option sets a <quote>use before</quote> time on retry information in Exim&#x2019;s hints
25947 database. Any older retry data is ignored. This means that, for example, once a
25948 host has not been tried for 7 days, Exim behaves as if it has no knowledge of
25949 past failures.
25950 </para>
25951 <para>
25952 <indexterm role="option">
25953 <primary><option>retry_interval_max</option></primary>
25954 </indexterm>
25955 </para>
25956 <informaltable frame="all">
25957 <tgroup cols="4" colsep="0" rowsep="0">
25958 <colspec colwidth="8*" align="left"/>
25959 <colspec colwidth="6*" align="center"/>
25960 <colspec colwidth="6*" align="center"/>
25961 <colspec colwidth="6*" align="right"/>
25962 <tbody>
25963 <row>
25964 <entry><option>retry_interval_max</option></entry>
25965 <entry>Use: <emphasis>main</emphasis></entry>
25966 <entry>Type: <emphasis>time</emphasis></entry>
25967 <entry>Default: <emphasis>24h</emphasis></entry>
25968 </row>
25969 </tbody>
25970 </tgroup>
25971 </informaltable>
25972 <para>
25973 <indexterm role="concept">
25974 <primary>retry</primary>
25975 <secondary>limit on interval</secondary>
25976 </indexterm>
25977 <indexterm role="concept">
25978 <primary>limit</primary>
25979 <secondary>on retry interval</secondary>
25980 </indexterm>
25981 Chapter <xref linkend="CHAPretry"/> describes Exim&#x2019;s mechanisms for controlling the
25982 intervals between delivery attempts for messages that cannot be delivered
25983 straight away. This option sets an overall limit to the length of time between
25984 retries. It cannot be set greater than 24 hours; any attempt to do so forces
25985 the default value.
25986 </para>
25987 <para>
25988 <indexterm role="option">
25989 <primary><option>return_path_remove</option></primary>
25990 </indexterm>
25991 </para>
25992 <informaltable frame="all">
25993 <tgroup cols="4" colsep="0" rowsep="0">
25994 <colspec colwidth="8*" align="left"/>
25995 <colspec colwidth="6*" align="center"/>
25996 <colspec colwidth="6*" align="center"/>
25997 <colspec colwidth="6*" align="right"/>
25998 <tbody>
25999 <row>
26000 <entry><option>return_path_remove</option></entry>
26001 <entry>Use: <emphasis>main</emphasis></entry>
26002 <entry>Type: <emphasis>boolean</emphasis></entry>
26003 <entry>Default: <emphasis>true</emphasis></entry>
26004 </row>
26005 </tbody>
26006 </tgroup>
26007 </informaltable>
26008 <para>
26009 <indexterm role="concept">
26010 <primary><emphasis>Return-path:</emphasis> header line</primary>
26011 <secondary>removing</secondary>
26012 </indexterm>
26013 RFC 2821, section 4.4, states that an SMTP server must insert a
26014 <emphasis>Return-path:</emphasis> header line into a message when it makes a <quote>final delivery</quote>.
26015 The <emphasis>Return-path:</emphasis> header preserves the sender address as received in the
26016 MAIL command. This description implies that this header should not be present
26017 in an incoming message. If <option>return_path_remove</option> is true, any existing
26018 <emphasis>Return-path:</emphasis> headers are removed from messages at the time they are
26019 received. Exim&#x2019;s transports have options for adding <emphasis>Return-path:</emphasis> headers at
26020 the time of delivery. They are normally used only for final local deliveries.
26021 </para>
26022 <para>
26023 <indexterm role="option">
26024 <primary><option>return_size_limit</option></primary>
26025 </indexterm>
26026 </para>
26027 <informaltable frame="all">
26028 <tgroup cols="4" colsep="0" rowsep="0">
26029 <colspec colwidth="8*" align="left"/>
26030 <colspec colwidth="6*" align="center"/>
26031 <colspec colwidth="6*" align="center"/>
26032 <colspec colwidth="6*" align="right"/>
26033 <tbody>
26034 <row>
26035 <entry><option>return_size_limit</option></entry>
26036 <entry>Use: <emphasis>main</emphasis></entry>
26037 <entry>Type: <emphasis>integer</emphasis></entry>
26038 <entry>Default: <emphasis>100K</emphasis></entry>
26039 </row>
26040 </tbody>
26041 </tgroup>
26042 </informaltable>
26043 <para>
26044 This option is an obsolete synonym for <option>bounce_return_size_limit</option>.
26045 </para>
26046 <para>
26047 <indexterm role="option">
26048 <primary><option>rfc1413_hosts</option></primary>
26049 </indexterm>
26050 </para>
26051 <informaltable frame="all">
26052 <tgroup cols="4" colsep="0" rowsep="0">
26053 <colspec colwidth="8*" align="left"/>
26054 <colspec colwidth="6*" align="center"/>
26055 <colspec colwidth="6*" align="center"/>
26056 <colspec colwidth="6*" align="right"/>
26057 <tbody>
26058 <row>
26059 <entry><option>rfc1413_hosts</option></entry>
26060 <entry>Use: <emphasis>main</emphasis></entry>
26061 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
26062 <entry>Default: <emphasis>*</emphasis></entry>
26063 </row>
26064 </tbody>
26065 </tgroup>
26066 </informaltable>
26067 <para>
26068 <indexterm role="concept">
26069 <primary>RFC 1413</primary>
26070 </indexterm>
26071 <indexterm role="concept">
26072 <primary>host</primary>
26073 <secondary>for RFC 1413 calls</secondary>
26074 </indexterm>
26075 RFC 1413 identification calls are made to any client host which matches an item
26076 in the list.
26077 </para>
26078 <para>
26079 <indexterm role="option">
26080 <primary><option>rfc1413_query_timeout</option></primary>
26081 </indexterm>
26082 </para>
26083 <informaltable frame="all">
26084 <tgroup cols="4" colsep="0" rowsep="0">
26085 <colspec colwidth="8*" align="left"/>
26086 <colspec colwidth="6*" align="center"/>
26087 <colspec colwidth="6*" align="center"/>
26088 <colspec colwidth="6*" align="right"/>
26089 <tbody>
26090 <row>
26091 <entry><option>rfc1413_query_timeout</option></entry>
26092 <entry>Use: <emphasis>main</emphasis></entry>
26093 <entry>Type: <emphasis>time</emphasis></entry>
26094 <entry>Default: <emphasis>5s</emphasis></entry>
26095 </row>
26096 </tbody>
26097 </tgroup>
26098 </informaltable>
26099 <para>
26100 <indexterm role="concept">
26101 <primary>RFC 1413</primary>
26102 <secondary>query timeout</secondary>
26103 </indexterm>
26104 <indexterm role="concept">
26105 <primary>timeout</primary>
26106 <secondary>for RFC 1413 call</secondary>
26107 </indexterm>
26108 This sets the timeout on RFC 1413 identification calls. If it is set to zero,
26109 no RFC 1413 calls are ever made.
26110 </para>
26111 <para>
26112 <indexterm role="option">
26113 <primary><option>sender_unqualified_hosts</option></primary>
26114 </indexterm>
26115 </para>
26116 <informaltable frame="all">
26117 <tgroup cols="4" colsep="0" rowsep="0">
26118 <colspec colwidth="8*" align="left"/>
26119 <colspec colwidth="6*" align="center"/>
26120 <colspec colwidth="6*" align="center"/>
26121 <colspec colwidth="6*" align="right"/>
26122 <tbody>
26123 <row>
26124 <entry><option>sender_unqualified_hosts</option></entry>
26125 <entry>Use: <emphasis>main</emphasis></entry>
26126 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
26127 <entry>Default: <emphasis>unset</emphasis></entry>
26128 </row>
26129 </tbody>
26130 </tgroup>
26131 </informaltable>
26132 <para>
26133 <indexterm role="concept">
26134 <primary>unqualified addresses</primary>
26135 </indexterm>
26136 <indexterm role="concept">
26137 <primary>host</primary>
26138 <secondary>unqualified addresses from</secondary>
26139 </indexterm>
26140 This option lists those hosts from which Exim is prepared to accept unqualified
26141 sender addresses. The addresses are made fully qualified by the addition of
26142 <option>qualify_domain</option>. This option also affects message header lines. Exim does
26143 not reject unqualified addresses in headers that contain sender addresses, but
26144 it qualifies them only if the message came from a host that matches
26145 <option>sender_unqualified_hosts</option>, or if the message was submitted locally (not
26146 using TCP/IP), and the <option>-bnq</option> option was not set.
26147 </para>
26148 <para>
26149 <indexterm role="option">
26150 <primary><option>smtp_accept_keepalive</option></primary>
26151 </indexterm>
26152 </para>
26153 <informaltable frame="all">
26154 <tgroup cols="4" colsep="0" rowsep="0">
26155 <colspec colwidth="8*" align="left"/>
26156 <colspec colwidth="6*" align="center"/>
26157 <colspec colwidth="6*" align="center"/>
26158 <colspec colwidth="6*" align="right"/>
26159 <tbody>
26160 <row>
26161 <entry><option>smtp_accept_keepalive</option></entry>
26162 <entry>Use: <emphasis>main</emphasis></entry>
26163 <entry>Type: <emphasis>boolean</emphasis></entry>
26164 <entry>Default: <emphasis>true</emphasis></entry>
26165 </row>
26166 </tbody>
26167 </tgroup>
26168 </informaltable>
26169 <para>
26170 <indexterm role="concept">
26171 <primary>keepalive</primary>
26172 <secondary>on incoming connection</secondary>
26173 </indexterm>
26174 This option controls the setting of the SO_KEEPALIVE option on incoming
26175 TCP/IP socket connections. When set, it causes the kernel to probe idle
26176 connections periodically, by sending packets with <quote>old</quote> sequence numbers. The
26177 other end of the connection should send an acknowledgment if the connection is
26178 still okay or a reset if the connection has been aborted. The reason for doing
26179 this is that it has the beneficial effect of freeing up certain types of
26180 connection that can get stuck when the remote host is disconnected without
26181 tidying up the TCP/IP call properly. The keepalive mechanism takes several
26182 hours to detect unreachable hosts.
26183 </para>
26184 <para>
26185 <indexterm role="option">
26186 <primary><option>smtp_accept_max</option></primary>
26187 </indexterm>
26188 </para>
26189 <informaltable frame="all">
26190 <tgroup cols="4" colsep="0" rowsep="0">
26191 <colspec colwidth="8*" align="left"/>
26192 <colspec colwidth="6*" align="center"/>
26193 <colspec colwidth="6*" align="center"/>
26194 <colspec colwidth="6*" align="right"/>
26195 <tbody>
26196 <row>
26197 <entry><option>smtp_accept_max</option></entry>
26198 <entry>Use: <emphasis>main</emphasis></entry>
26199 <entry>Type: <emphasis>integer</emphasis></entry>
26200 <entry>Default: <emphasis>20</emphasis></entry>
26201 </row>
26202 </tbody>
26203 </tgroup>
26204 </informaltable>
26205 <para>
26206 <indexterm role="concept">
26207 <primary>limit</primary>
26208 <secondary>incoming SMTP connections</secondary>
26209 </indexterm>
26210 <indexterm role="concept">
26211 <primary>SMTP</primary>
26212 <secondary>incoming connection count</secondary>
26213 </indexterm>
26214 <indexterm role="concept">
26215 <primary>inetd</primary>
26216 </indexterm>
26217 This option specifies the maximum number of simultaneous incoming SMTP calls
26218 that Exim will accept. It applies only to the listening daemon; there is no
26219 control (in Exim) when incoming SMTP is being handled by <emphasis>inetd</emphasis>. If the
26220 value is set to zero, no limit is applied. However, it is required to be
26221 non-zero if either <option>smtp_accept_max_per_host</option> or <option>smtp_accept_queue</option> is
26222 set. See also <option>smtp_accept_reserve</option> and <option>smtp_load_reserve</option>.
26223 </para>
26224 <para>
26225 A new SMTP connection is immediately rejected if the <option>smtp_accept_max</option> limit
26226 has been reached. If not, Exim first checks <option>smtp_accept_max_per_host</option>. If
26227 that limit has not been reached for the client host, <option>smtp_accept_reserve</option>
26228 and <option>smtp_load_reserve</option> are then checked before accepting the connection.
26229 </para>
26230 <para>
26231 <indexterm role="option">
26232 <primary><option>smtp_accept_max_nonmail</option></primary>
26233 </indexterm>
26234 </para>
26235 <informaltable frame="all">
26236 <tgroup cols="4" colsep="0" rowsep="0">
26237 <colspec colwidth="8*" align="left"/>
26238 <colspec colwidth="6*" align="center"/>
26239 <colspec colwidth="6*" align="center"/>
26240 <colspec colwidth="6*" align="right"/>
26241 <tbody>
26242 <row>
26243 <entry><option>smtp_accept_max_nonmail</option></entry>
26244 <entry>Use: <emphasis>main</emphasis></entry>
26245 <entry>Type: <emphasis>integer</emphasis></entry>
26246 <entry>Default: <emphasis>10</emphasis></entry>
26247 </row>
26248 </tbody>
26249 </tgroup>
26250 </informaltable>
26251 <para>
26252 <indexterm role="concept">
26253 <primary>limit</primary>
26254 <secondary>non-mail SMTP commands</secondary>
26255 </indexterm>
26256 <indexterm role="concept">
26257 <primary>SMTP</primary>
26258 <secondary>limiting non-mail commands</secondary>
26259 </indexterm>
26260 Exim counts the number of <quote>non-mail</quote> commands in an SMTP session, and drops
26261 the connection if there are too many. This option defines <quote>too many</quote>. The
26262 check catches some denial-of-service attacks, repeated failing AUTHs, or a mad
26263 client looping sending EHLO, for example. The check is applied only if the
26264 client host matches <option>smtp_accept_max_nonmail_hosts</option>.
26265 </para>
26266 <para>
26267 When a new message is expected, one occurrence of RSET is not counted. This
26268 allows a client to send one RSET between messages (this is not necessary,
26269 but some clients do it). Exim also allows one uncounted occurrence of HELO
26270 or EHLO, and one occurrence of STARTTLS between messages. After
26271 starting up a TLS session, another EHLO is expected, and so it too is not
26272 counted. The first occurrence of AUTH in a connection, or immediately
26273 following STARTTLS is not counted. Otherwise, all commands other than
26274 MAIL, RCPT, DATA, and QUIT are counted.
26275 </para>
26276 <para>
26277 <indexterm role="option">
26278 <primary><option>smtp_accept_max_nonmail_hosts</option></primary>
26279 </indexterm>
26280 </para>
26281 <informaltable frame="all">
26282 <tgroup cols="4" colsep="0" rowsep="0">
26283 <colspec colwidth="8*" align="left"/>
26284 <colspec colwidth="6*" align="center"/>
26285 <colspec colwidth="6*" align="center"/>
26286 <colspec colwidth="6*" align="right"/>
26287 <tbody>
26288 <row>
26289 <entry><option>smtp_accept_max_nonmail_hosts</option></entry>
26290 <entry>Use: <emphasis>main</emphasis></entry>
26291 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
26292 <entry>Default: <emphasis>*</emphasis></entry>
26293 </row>
26294 </tbody>
26295 </tgroup>
26296 </informaltable>
26297 <para>
26298 You can control which hosts are subject to the <option>smtp_accept_max_nonmail</option>
26299 check by setting this option. The default value makes it apply to all hosts. By
26300 changing the value, you can exclude any badly-behaved hosts that you have to
26301 live with.
26302 </para>
26303 <para>
26304 <indexterm role="option">
26305 <primary><option>smtp_accept_max_per_connection</option></primary>
26306 </indexterm>
26307 </para>
26308 <informaltable frame="all">
26309 <tgroup cols="4" colsep="0" rowsep="0">
26310 <colspec colwidth="8*" align="left"/>
26311 <colspec colwidth="6*" align="center"/>
26312 <colspec colwidth="6*" align="center"/>
26313 <colspec colwidth="6*" align="right"/>
26314 <tbody>
26315 <row>
26316 <entry><option>smtp_accept_max_per_ &nbsp;&nbsp;connection</option></entry>
26317 <entry>Use: <emphasis>main</emphasis></entry>
26318 <entry>Type: <emphasis>integer</emphasis></entry>
26319 <entry>Default: <emphasis>1000</emphasis></entry>
26320 </row>
26321 </tbody>
26322 </tgroup>
26323 </informaltable>
26324 <para>
26325 <indexterm role="concept">
26326 <primary>SMTP</primary>
26327 <secondary>limiting incoming message count</secondary>
26328 </indexterm>
26329 <indexterm role="concept">
26330 <primary>limit</primary>
26331 <secondary>messages per SMTP connection</secondary>
26332 </indexterm>
26333 The value of this option limits the number of MAIL commands that Exim is
26334 prepared to accept over a single SMTP connection, whether or not each command
26335 results in the transfer of a message. After the limit is reached, a 421
26336 response is given to subsequent MAIL commands. This limit is a safety
26337 precaution against a client that goes mad (incidents of this type have been
26338 seen).
26339 </para>
26340 <para>
26341 <indexterm role="option">
26342 <primary><option>smtp_accept_max_per_host</option></primary>
26343 </indexterm>
26344 </para>
26345 <informaltable frame="all">
26346 <tgroup cols="4" colsep="0" rowsep="0">
26347 <colspec colwidth="8*" align="left"/>
26348 <colspec colwidth="6*" align="center"/>
26349 <colspec colwidth="6*" align="center"/>
26350 <colspec colwidth="6*" align="right"/>
26351 <tbody>
26352 <row>
26353 <entry><option>smtp_accept_max_per_host</option></entry>
26354 <entry>Use: <emphasis>main</emphasis></entry>
26355 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26356 <entry>Default: <emphasis>unset</emphasis></entry>
26357 </row>
26358 </tbody>
26359 </tgroup>
26360 </informaltable>
26361 <para>
26362 <indexterm role="concept">
26363 <primary>limit</primary>
26364 <secondary>SMTP connections from one host</secondary>
26365 </indexterm>
26366 <indexterm role="concept">
26367 <primary>host</primary>
26368 <secondary>limiting SMTP connections from</secondary>
26369 </indexterm>
26370 This option restricts the number of simultaneous IP connections from a single
26371 host (strictly, from a single IP address) to the Exim daemon. The option is
26372 expanded, to enable different limits to be applied to different hosts by
26373 reference to <varname>$sender_host_address</varname>. Once the limit is reached, additional
26374 connection attempts from the same host are rejected with error code 421. This
26375 is entirely independent of <option>smtp_accept_reserve</option>. The option&#x2019;s default value
26376 of zero imposes no limit. If this option is set greater than zero, it is
26377 required that <option>smtp_accept_max</option> be non-zero.
26378 </para>
26379 <para>
26380 <emphasis role="bold">Warning</emphasis>: When setting this option you should not use any expansion
26381 constructions that take an appreciable amount of time. The expansion and test
26382 happen in the main daemon loop, in order to reject additional connections
26383 without forking additional processes (otherwise a denial-of-service attack
26384 could cause a vast number or processes to be created). While the daemon is
26385 doing this processing, it cannot accept any other incoming connections.
26386 </para>
26387 <para>
26388 <indexterm role="option">
26389 <primary><option>smtp_accept_queue</option></primary>
26390 </indexterm>
26391 </para>
26392 <informaltable frame="all">
26393 <tgroup cols="4" colsep="0" rowsep="0">
26394 <colspec colwidth="8*" align="left"/>
26395 <colspec colwidth="6*" align="center"/>
26396 <colspec colwidth="6*" align="center"/>
26397 <colspec colwidth="6*" align="right"/>
26398 <tbody>
26399 <row>
26400 <entry><option>smtp_accept_queue</option></entry>
26401 <entry>Use: <emphasis>main</emphasis></entry>
26402 <entry>Type: <emphasis>integer</emphasis></entry>
26403 <entry>Default: <emphasis>0</emphasis></entry>
26404 </row>
26405 </tbody>
26406 </tgroup>
26407 </informaltable>
26408 <para>
26409 <indexterm role="concept">
26410 <primary>SMTP</primary>
26411 <secondary>incoming connection count</secondary>
26412 </indexterm>
26413 <indexterm role="concept">
26414 <primary>queueing incoming messages</primary>
26415 </indexterm>
26416 <indexterm role="concept">
26417 <primary>message</primary>
26418 <secondary>queueing by SMTP connection count</secondary>
26419 </indexterm>
26420 If the number of simultaneous incoming SMTP connections being handled via the
26421 listening daemon exceeds this value, messages received by SMTP are just placed
26422 on the queue; no delivery processes are started automatically. The count is
26423 fixed at the start of an SMTP connection. It cannot be updated in the
26424 subprocess that receives messages, and so the queueing or not queueing applies
26425 to all messages received in the same connection.
26426 </para>
26427 <para>
26428 A value of zero implies no limit, and clearly any non-zero value is useful only
26429 if it is less than the <option>smtp_accept_max</option> value (unless that is zero). See
26430 also <option>queue_only</option>, <option>queue_only_load</option>, <option>queue_smtp_domains</option>, and the
26431 various <option>-od</option><emphasis>x</emphasis> command line options.
26432 </para>
26433 <para>
26434 <indexterm role="option">
26435 <primary><option>smtp_accept_queue_per_connection</option></primary>
26436 </indexterm>
26437 </para>
26438 <informaltable frame="all">
26439 <tgroup cols="4" colsep="0" rowsep="0">
26440 <colspec colwidth="8*" align="left"/>
26441 <colspec colwidth="6*" align="center"/>
26442 <colspec colwidth="6*" align="center"/>
26443 <colspec colwidth="6*" align="right"/>
26444 <tbody>
26445 <row>
26446 <entry><option>smtp_accept_queue_per_ &nbsp;&nbsp;connection</option></entry>
26447 <entry>Use: <emphasis>main</emphasis></entry>
26448 <entry>Type: <emphasis>integer</emphasis></entry>
26449 <entry>Default: <emphasis>10</emphasis></entry>
26450 </row>
26451 </tbody>
26452 </tgroup>
26453 </informaltable>
26454 <para>
26455 <indexterm role="concept">
26456 <primary>queueing incoming messages</primary>
26457 </indexterm>
26458 <indexterm role="concept">
26459 <primary>message</primary>
26460 <secondary>queueing by message count</secondary>
26461 </indexterm>
26462 This option limits the number of delivery processes that Exim starts
26463 automatically when receiving messages via SMTP, whether via the daemon or by
26464 the use of <option>-bs</option> or <option>-bS</option>. If the value of the option is greater than zero,
26465 and the number of messages received in a single SMTP session exceeds this
26466 number, subsequent messages are placed on the queue, but no delivery processes
26467 are started. This helps to limit the number of Exim processes when a server
26468 restarts after downtime and there is a lot of mail waiting for it on other
26469 systems. On large systems, the default should probably be increased, and on
26470 dial-in client systems it should probably be set to zero (that is, disabled).
26471 </para>
26472 <para>
26473 <indexterm role="option">
26474 <primary><option>smtp_accept_reserve</option></primary>
26475 </indexterm>
26476 </para>
26477 <informaltable frame="all">
26478 <tgroup cols="4" colsep="0" rowsep="0">
26479 <colspec colwidth="8*" align="left"/>
26480 <colspec colwidth="6*" align="center"/>
26481 <colspec colwidth="6*" align="center"/>
26482 <colspec colwidth="6*" align="right"/>
26483 <tbody>
26484 <row>
26485 <entry><option>smtp_accept_reserve</option></entry>
26486 <entry>Use: <emphasis>main</emphasis></entry>
26487 <entry>Type: <emphasis>integer</emphasis></entry>
26488 <entry>Default: <emphasis>0</emphasis></entry>
26489 </row>
26490 </tbody>
26491 </tgroup>
26492 </informaltable>
26493 <para>
26494 <indexterm role="concept">
26495 <primary>SMTP</primary>
26496 <secondary>incoming call count</secondary>
26497 </indexterm>
26498 <indexterm role="concept">
26499 <primary>host</primary>
26500 <secondary>reserved</secondary>
26501 </indexterm>
26502 When <option>smtp_accept_max</option> is set greater than zero, this option specifies a
26503 number of SMTP connections that are reserved for connections from the hosts
26504 that are specified in <option>smtp_reserve_hosts</option>. The value set in
26505 <option>smtp_accept_max</option> includes this reserve pool. The specified hosts are not
26506 restricted to this number of connections; the option specifies a minimum number
26507 of connection slots for them, not a maximum. It is a guarantee that this group
26508 of hosts can always get at least <option>smtp_accept_reserve</option> connections. However,
26509 the limit specified by <option>smtp_accept_max_per_host</option> is still applied to each
26510 individual host.
26511 </para>
26512 <para>
26513 For example, if <option>smtp_accept_max</option> is set to 50 and <option>smtp_accept_reserve</option> is
26514 set to 5, once there are 45 active connections (from any hosts), new
26515 connections are accepted only from hosts listed in <option>smtp_reserve_hosts</option>,
26516 provided the other criteria for acceptance are met.
26517 </para>
26518 <para>
26519 <indexterm role="option">
26520 <primary><option>smtp_active_hostname</option></primary>
26521 </indexterm>
26522 </para>
26523 <informaltable frame="all">
26524 <tgroup cols="4" colsep="0" rowsep="0">
26525 <colspec colwidth="8*" align="left"/>
26526 <colspec colwidth="6*" align="center"/>
26527 <colspec colwidth="6*" align="center"/>
26528 <colspec colwidth="6*" align="right"/>
26529 <tbody>
26530 <row>
26531 <entry><option>smtp_active_hostname</option></entry>
26532 <entry>Use: <emphasis>main</emphasis></entry>
26533 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26534 <entry>Default: <emphasis>unset</emphasis></entry>
26535 </row>
26536 </tbody>
26537 </tgroup>
26538 </informaltable>
26539 <para>
26540 <indexterm role="concept">
26541 <primary>host</primary>
26542 <secondary>name in SMTP responses</secondary>
26543 </indexterm>
26544 <indexterm role="concept">
26545 <primary>SMTP</primary>
26546 <secondary>host name in responses</secondary>
26547 </indexterm>
26548 <indexterm role="variable">
26549 <primary><varname>$primary_hostname</varname></primary>
26550 </indexterm>
26551 This option is provided for multi-homed servers that want to masquerade as
26552 several different hosts. At the start of an incoming SMTP connection, its value
26553 is expanded and used instead of the value of <varname>$primary_hostname</varname> in SMTP
26554 responses. For example, it is used as domain name in the response to an
26555 incoming HELO or EHLO command.
26556 </para>
26557 <para>
26558 <indexterm role="variable">
26559 <primary><varname>$smtp_active_hostname</varname></primary>
26560 </indexterm>
26561 The active hostname is placed in the <varname>$smtp_active_hostname</varname> variable, which
26562 is saved with any messages that are received. It is therefore available for use
26563 in routers and transports when the message is later delivered.
26564 </para>
26565 <para>
26566 If this option is unset, or if its expansion is forced to fail, or if the
26567 expansion results in an empty string, the value of <varname>$primary_hostname</varname> is
26568 used. Other expansion failures cause a message to be written to the main and
26569 panic logs, and the SMTP command receives a temporary error. Typically, the
26570 value of <option>smtp_active_hostname</option> depends on the incoming interface address.
26571 For example:
26572 </para>
26573 <literallayout class="monospaced">
26574 smtp_active_hostname = ${if eq{$received_ip_address}{10.0.0.1}\
26575   {cox.mydomain}{box.mydomain}}
26576 </literallayout>
26577 <para>
26578 Although <varname>$smtp_active_hostname</varname> is primarily concerned with incoming
26579 messages, it is also used as the default for HELO commands in callout
26580 verification if there is no remote transport from which to obtain a
26581 <option>helo_data</option> value.
26582 </para>
26583 <para>
26584 <indexterm role="option">
26585 <primary><option>smtp_banner</option></primary>
26586 </indexterm>
26587 </para>
26588 <informaltable frame="all">
26589 <tgroup cols="4" colsep="0" rowsep="0">
26590 <colspec colwidth="8*" align="left"/>
26591 <colspec colwidth="6*" align="center"/>
26592 <colspec colwidth="6*" align="center"/>
26593 <colspec colwidth="6*" align="right"/>
26594 <tbody>
26595 <row>
26596 <entry><option>smtp_banner</option></entry>
26597 <entry>Use: <emphasis>main</emphasis></entry>
26598 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26599 <entry>Default: <emphasis>see below</emphasis></entry>
26600 </row>
26601 </tbody>
26602 </tgroup>
26603 </informaltable>
26604 <para>
26605 <indexterm role="concept">
26606 <primary>SMTP</primary>
26607 <secondary>welcome banner</secondary>
26608 </indexterm>
26609 <indexterm role="concept">
26610 <primary>banner for SMTP</primary>
26611 </indexterm>
26612 <indexterm role="concept">
26613 <primary>welcome banner for SMTP</primary>
26614 </indexterm>
26615 <indexterm role="concept">
26616 <primary>customizing</primary>
26617 <secondary>SMTP banner</secondary>
26618 </indexterm>
26619 This string, which is expanded every time it is used, is output as the initial
26620 positive response to an SMTP connection. The default setting is:
26621 </para>
26622 <literallayout class="monospaced">
26623 smtp_banner = $smtp_active_hostname ESMTP Exim \
26624   $version_number $tod_full
26625 </literallayout>
26626 <para>
26627 Failure to expand the string causes a panic error. If you want to create a
26628 multiline response to the initial SMTP connection, use <quote>\n</quote> in the string at
26629 appropriate points, but not at the end. Note that the 220 code is not included
26630 in this string. Exim adds it automatically (several times in the case of a
26631 multiline response).
26632 </para>
26633 <para>
26634 <indexterm role="option">
26635 <primary><option>smtp_check_spool_space</option></primary>
26636 </indexterm>
26637 </para>
26638 <informaltable frame="all">
26639 <tgroup cols="4" colsep="0" rowsep="0">
26640 <colspec colwidth="8*" align="left"/>
26641 <colspec colwidth="6*" align="center"/>
26642 <colspec colwidth="6*" align="center"/>
26643 <colspec colwidth="6*" align="right"/>
26644 <tbody>
26645 <row>
26646 <entry><option>smtp_check_spool_space</option></entry>
26647 <entry>Use: <emphasis>main</emphasis></entry>
26648 <entry>Type: <emphasis>boolean</emphasis></entry>
26649 <entry>Default: <emphasis>true</emphasis></entry>
26650 </row>
26651 </tbody>
26652 </tgroup>
26653 </informaltable>
26654 <para>
26655 <indexterm role="concept">
26656 <primary>checking disk space</primary>
26657 </indexterm>
26658 <indexterm role="concept">
26659 <primary>disk space, checking</primary>
26660 </indexterm>
26661 <indexterm role="concept">
26662 <primary>spool directory</primary>
26663 <secondary>checking space</secondary>
26664 </indexterm>
26665 When this option is set, if an incoming SMTP session encounters the SIZE
26666 option on a MAIL command, it checks that there is enough space in the
26667 spool directory&#x2019;s partition to accept a message of that size, while still
26668 leaving free the amount specified by <option>check_spool_space</option> (even if that value
26669 is zero). If there isn&#x2019;t enough space, a temporary error code is returned.
26670 </para>
26671 <para>
26672 <indexterm role="option">
26673 <primary><option>smtp_connect_backlog</option></primary>
26674 </indexterm>
26675 </para>
26676 <informaltable frame="all">
26677 <tgroup cols="4" colsep="0" rowsep="0">
26678 <colspec colwidth="8*" align="left"/>
26679 <colspec colwidth="6*" align="center"/>
26680 <colspec colwidth="6*" align="center"/>
26681 <colspec colwidth="6*" align="right"/>
26682 <tbody>
26683 <row>
26684 <entry><option>smtp_connect_backlog</option></entry>
26685 <entry>Use: <emphasis>main</emphasis></entry>
26686 <entry>Type: <emphasis>integer</emphasis></entry>
26687 <entry>Default: <emphasis>20</emphasis></entry>
26688 </row>
26689 </tbody>
26690 </tgroup>
26691 </informaltable>
26692 <para>
26693 <indexterm role="concept">
26694 <primary>connection backlog</primary>
26695 </indexterm>
26696 <indexterm role="concept">
26697 <primary>SMTP</primary>
26698 <secondary>connection backlog</secondary>
26699 </indexterm>
26700 <indexterm role="concept">
26701 <primary>backlog of connections</primary>
26702 </indexterm>
26703 This option specifies a maximum number of waiting SMTP connections. Exim passes
26704 this value to the TCP/IP system when it sets up its listener. Once this number
26705 of connections are waiting for the daemon&#x2019;s attention, subsequent connection
26706 attempts are refused at the TCP/IP level. At least, that is what the manuals
26707 say; in some circumstances such connection attempts have been observed to time
26708 out instead. For large systems it is probably a good idea to increase the
26709 value (to 50, say). It also gives some protection against denial-of-service
26710 attacks by SYN flooding.
26711 </para>
26712 <para>
26713 <indexterm role="option">
26714 <primary><option>smtp_enforce_sync</option></primary>
26715 </indexterm>
26716 </para>
26717 <informaltable frame="all">
26718 <tgroup cols="4" colsep="0" rowsep="0">
26719 <colspec colwidth="8*" align="left"/>
26720 <colspec colwidth="6*" align="center"/>
26721 <colspec colwidth="6*" align="center"/>
26722 <colspec colwidth="6*" align="right"/>
26723 <tbody>
26724 <row>
26725 <entry><option>smtp_enforce_sync</option></entry>
26726 <entry>Use: <emphasis>main</emphasis></entry>
26727 <entry>Type: <emphasis>boolean</emphasis></entry>
26728 <entry>Default: <emphasis>true</emphasis></entry>
26729 </row>
26730 </tbody>
26731 </tgroup>
26732 </informaltable>
26733 <para>
26734 <indexterm role="concept">
26735 <primary>SMTP</primary>
26736 <secondary>synchronization checking</secondary>
26737 </indexterm>
26738 <indexterm role="concept">
26739 <primary>synchronization checking in SMTP</primary>
26740 </indexterm>
26741 The SMTP protocol specification requires the client to wait for a response from
26742 the server at certain points in the dialogue. Without PIPELINING these
26743 synchronization points are after every command; with PIPELINING they are
26744 fewer, but they still exist.
26745 </para>
26746 <para>
26747 Some spamming sites send out a complete set of SMTP commands without waiting
26748 for any response. Exim protects against this by rejecting a message if the
26749 client has sent further input when it should not have. The error response <quote>554
26750 SMTP synchronization error</quote> is sent, and the connection is dropped. Testing
26751 for this error cannot be perfect because of transmission delays (unexpected
26752 input may be on its way but not yet received when Exim checks). However, it
26753 does detect many instances.
26754 </para>
26755 <para>
26756 The check can be globally disabled by setting <option>smtp_enforce_sync</option> false.
26757 If you want to disable the check selectively (for example, only for certain
26758 hosts), you can do so by an appropriate use of a <option>control</option> modifier in an ACL
26759 (see section <xref linkend="SECTcontrols"/>). See also <option>pipelining_advertise_hosts</option>.
26760 </para>
26761 <para>
26762 <indexterm role="option">
26763 <primary><option>smtp_etrn_command</option></primary>
26764 </indexterm>
26765 </para>
26766 <informaltable frame="all">
26767 <tgroup cols="4" colsep="0" rowsep="0">
26768 <colspec colwidth="8*" align="left"/>
26769 <colspec colwidth="6*" align="center"/>
26770 <colspec colwidth="6*" align="center"/>
26771 <colspec colwidth="6*" align="right"/>
26772 <tbody>
26773 <row>
26774 <entry><option>smtp_etrn_command</option></entry>
26775 <entry>Use: <emphasis>main</emphasis></entry>
26776 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26777 <entry>Default: <emphasis>unset</emphasis></entry>
26778 </row>
26779 </tbody>
26780 </tgroup>
26781 </informaltable>
26782 <para>
26783 <indexterm role="concept">
26784 <primary>ETRN</primary>
26785 <secondary>command to be run</secondary>
26786 </indexterm>
26787 <indexterm role="variable">
26788 <primary><varname>$domain</varname></primary>
26789 </indexterm>
26790 If this option is set, the given command is run whenever an SMTP ETRN
26791 command is received from a host that is permitted to issue such commands (see
26792 chapter <xref linkend="CHAPACL"/>). The string is split up into separate arguments which
26793 are independently expanded. The expansion variable <varname>$domain</varname> is set to the
26794 argument of the ETRN command, and no syntax checking is done on it. For
26795 example:
26796 </para>
26797 <literallayout class="monospaced">
26798 smtp_etrn_command = /etc/etrn_command $domain \
26799                     $sender_host_address
26800 </literallayout>
26801 <para>
26802 A new process is created to run the command, but Exim does not wait for it to
26803 complete. Consequently, its status cannot be checked. If the command cannot be
26804 run, a line is written to the panic log, but the ETRN caller still receives
26805 a 250 success response. Exim is normally running under its own uid when
26806 receiving SMTP, so it is not possible for it to change the uid before running
26807 the command.
26808 </para>
26809 <para>
26810 <indexterm role="option">
26811 <primary><option>smtp_etrn_serialize</option></primary>
26812 </indexterm>
26813 </para>
26814 <informaltable frame="all">
26815 <tgroup cols="4" colsep="0" rowsep="0">
26816 <colspec colwidth="8*" align="left"/>
26817 <colspec colwidth="6*" align="center"/>
26818 <colspec colwidth="6*" align="center"/>
26819 <colspec colwidth="6*" align="right"/>
26820 <tbody>
26821 <row>
26822 <entry><option>smtp_etrn_serialize</option></entry>
26823 <entry>Use: <emphasis>main</emphasis></entry>
26824 <entry>Type: <emphasis>boolean</emphasis></entry>
26825 <entry>Default: <emphasis>true</emphasis></entry>
26826 </row>
26827 </tbody>
26828 </tgroup>
26829 </informaltable>
26830 <para>
26831 <indexterm role="concept">
26832 <primary>ETRN</primary>
26833 <secondary>serializing</secondary>
26834 </indexterm>
26835 When this option is set, it prevents the simultaneous execution of more than
26836 one identical command as a result of ETRN in an SMTP connection. See
26837 section <xref linkend="SECTETRN"/> for details.
26838 </para>
26839 <para>
26840 <indexterm role="option">
26841 <primary><option>smtp_load_reserve</option></primary>
26842 </indexterm>
26843 </para>
26844 <informaltable frame="all">
26845 <tgroup cols="4" colsep="0" rowsep="0">
26846 <colspec colwidth="8*" align="left"/>
26847 <colspec colwidth="6*" align="center"/>
26848 <colspec colwidth="6*" align="center"/>
26849 <colspec colwidth="6*" align="right"/>
26850 <tbody>
26851 <row>
26852 <entry><option>smtp_load_reserve</option></entry>
26853 <entry>Use: <emphasis>main</emphasis></entry>
26854 <entry>Type: <emphasis>fixed-point</emphasis></entry>
26855 <entry>Default: <emphasis>unset</emphasis></entry>
26856 </row>
26857 </tbody>
26858 </tgroup>
26859 </informaltable>
26860 <para>
26861 <indexterm role="concept">
26862 <primary>load average</primary>
26863 </indexterm>
26864 If the system load average ever gets higher than this, incoming SMTP calls are
26865 accepted only from those hosts that match an entry in <option>smtp_reserve_hosts</option>.
26866 If <option>smtp_reserve_hosts</option> is not set, no incoming SMTP calls are accepted when
26867 the load is over the limit. The option has no effect on ancient operating
26868 systems on which Exim cannot determine the load average. See also
26869 <option>deliver_queue_load_max</option> and <option>queue_only_load</option>.
26870 </para>
26871 <para>
26872 <indexterm role="option">
26873 <primary><option>smtp_max_synprot_errors</option></primary>
26874 </indexterm>
26875 </para>
26876 <informaltable frame="all">
26877 <tgroup cols="4" colsep="0" rowsep="0">
26878 <colspec colwidth="8*" align="left"/>
26879 <colspec colwidth="6*" align="center"/>
26880 <colspec colwidth="6*" align="center"/>
26881 <colspec colwidth="6*" align="right"/>
26882 <tbody>
26883 <row>
26884 <entry><option>smtp_max_synprot_errors</option></entry>
26885 <entry>Use: <emphasis>main</emphasis></entry>
26886 <entry>Type: <emphasis>integer</emphasis></entry>
26887 <entry>Default: <emphasis>3</emphasis></entry>
26888 </row>
26889 </tbody>
26890 </tgroup>
26891 </informaltable>
26892 <para>
26893 <indexterm role="concept">
26894 <primary>SMTP</primary>
26895 <secondary>limiting syntax and protocol errors</secondary>
26896 </indexterm>
26897 <indexterm role="concept">
26898 <primary>limit</primary>
26899 <secondary>SMTP syntax and protocol errors</secondary>
26900 </indexterm>
26901 Exim rejects SMTP commands that contain syntax or protocol errors. In
26902 particular, a syntactically invalid email address, as in this command:
26903 </para>
26904 <literallayout class="monospaced">
26905 RCPT TO:&lt;abc xyz@a.b.c&gt;
26906 </literallayout>
26907 <para>
26908 causes immediate rejection of the command, before any other tests are done.
26909 (The ACL cannot be run if there is no valid address to set up for it.) An
26910 example of a protocol error is receiving RCPT before MAIL. If there are
26911 too many syntax or protocol errors in one SMTP session, the connection is
26912 dropped. The limit is set by this option.
26913 </para>
26914 <para>
26915 <indexterm role="concept">
26916 <primary>PIPELINING</primary>
26917 <secondary>expected errors</secondary>
26918 </indexterm>
26919 When the PIPELINING extension to SMTP is in use, some protocol errors are
26920 <quote>expected</quote>, for instance, a RCPT command after a rejected MAIL command.
26921 Exim assumes that PIPELINING will be used if it advertises it (see
26922 <option>pipelining_advertise_hosts</option>), and in this situation, <quote>expected</quote> errors do
26923 not count towards the limit.
26924 </para>
26925 <para>
26926 <indexterm role="option">
26927 <primary><option>smtp_max_unknown_commands</option></primary>
26928 </indexterm>
26929 </para>
26930 <informaltable frame="all">
26931 <tgroup cols="4" colsep="0" rowsep="0">
26932 <colspec colwidth="8*" align="left"/>
26933 <colspec colwidth="6*" align="center"/>
26934 <colspec colwidth="6*" align="center"/>
26935 <colspec colwidth="6*" align="right"/>
26936 <tbody>
26937 <row>
26938 <entry><option>smtp_max_unknown_commands</option></entry>
26939 <entry>Use: <emphasis>main</emphasis></entry>
26940 <entry>Type: <emphasis>integer</emphasis></entry>
26941 <entry>Default: <emphasis>3</emphasis></entry>
26942 </row>
26943 </tbody>
26944 </tgroup>
26945 </informaltable>
26946 <para>
26947 <indexterm role="concept">
26948 <primary>SMTP</primary>
26949 <secondary>limiting unknown commands</secondary>
26950 </indexterm>
26951 <indexterm role="concept">
26952 <primary>limit</primary>
26953 <secondary>unknown SMTP commands</secondary>
26954 </indexterm>
26955 If there are too many unrecognized commands in an incoming SMTP session, an
26956 Exim server drops the connection. This is a defence against some kinds of abuse
26957 that subvert web
26958 clients
26959 into making connections to SMTP ports; in these circumstances, a number of
26960 non-SMTP command lines are sent first.
26961 </para>
26962 <para>
26963 <indexterm role="option">
26964 <primary><option>smtp_ratelimit_hosts</option></primary>
26965 </indexterm>
26966 </para>
26967 <informaltable frame="all">
26968 <tgroup cols="4" colsep="0" rowsep="0">
26969 <colspec colwidth="8*" align="left"/>
26970 <colspec colwidth="6*" align="center"/>
26971 <colspec colwidth="6*" align="center"/>
26972 <colspec colwidth="6*" align="right"/>
26973 <tbody>
26974 <row>
26975 <entry><option>smtp_ratelimit_hosts</option></entry>
26976 <entry>Use: <emphasis>main</emphasis></entry>
26977 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
26978 <entry>Default: <emphasis>unset</emphasis></entry>
26979 </row>
26980 </tbody>
26981 </tgroup>
26982 </informaltable>
26983 <para>
26984 <indexterm role="concept">
26985 <primary>SMTP</primary>
26986 <secondary>rate limiting</secondary>
26987 </indexterm>
26988 <indexterm role="concept">
26989 <primary>limit</primary>
26990 <secondary>rate of message arrival</secondary>
26991 </indexterm>
26992 <indexterm role="concept">
26993 <primary>RCPT</primary>
26994 <secondary>rate limiting</secondary>
26995 </indexterm>
26996 Some sites find it helpful to be able to limit the rate at which certain hosts
26997 can send them messages, and the rate at which an individual message can specify
26998 recipients.
26999 </para>
27000 <para>
27001 Exim has two rate-limiting facilities. This section describes the older
27002 facility, which can limit rates within a single connection. The newer
27003 <option>ratelimit</option> ACL condition can limit rates across all connections. See section
27004 <xref linkend="SECTratelimiting"/> for details of the newer facility.
27005 </para>
27006 <para>
27007 When a host matches <option>smtp_ratelimit_hosts</option>, the values of
27008 <option>smtp_ratelimit_mail</option> and <option>smtp_ratelimit_rcpt</option> are used to control the
27009 rate of acceptance of MAIL and RCPT commands in a single SMTP session,
27010 respectively. Each option, if set, must contain a set of four comma-separated
27011 values:
27012 </para>
27013 <itemizedlist>
27014 <listitem>
27015 <para>
27016 A threshold, before which there is no rate limiting.
27017 </para>
27018 </listitem>
27019 <listitem>
27020 <para>
27021 An initial time delay. Unlike other times in Exim, numbers with decimal
27022 fractional parts are allowed here.
27023 </para>
27024 </listitem>
27025 <listitem>
27026 <para>
27027 A factor by which to increase the delay each time.
27028 </para>
27029 </listitem>
27030 <listitem>
27031 <para>
27032 A maximum value for the delay. This should normally be less than 5 minutes,
27033 because after that time, the client is liable to timeout the SMTP command.
27034 </para>
27035 </listitem>
27036 </itemizedlist>
27037 <para>
27038 For example, these settings have been used successfully at the site which
27039 first suggested this feature, for controlling mail from their customers:
27040 </para>
27041 <literallayout class="monospaced">
27042 smtp_ratelimit_mail = 2,0.5s,1.05,4m
27043 smtp_ratelimit_rcpt = 4,0.25s,1.015,4m
27044 </literallayout>
27045 <para>
27046 The first setting specifies delays that are applied to MAIL commands after
27047 two have been received over a single connection. The initial delay is 0.5
27048 seconds, increasing by a factor of 1.05 each time. The second setting applies
27049 delays to RCPT commands when more than four occur in a single message.
27050 </para>
27051 <para>
27052 <indexterm role="option">
27053 <primary><option>smtp_ratelimit_mail</option></primary>
27054 </indexterm>
27055 </para>
27056 <informaltable frame="all">
27057 <tgroup cols="4" colsep="0" rowsep="0">
27058 <colspec colwidth="8*" align="left"/>
27059 <colspec colwidth="6*" align="center"/>
27060 <colspec colwidth="6*" align="center"/>
27061 <colspec colwidth="6*" align="right"/>
27062 <tbody>
27063 <row>
27064 <entry><option>smtp_ratelimit_mail</option></entry>
27065 <entry>Use: <emphasis>main</emphasis></entry>
27066 <entry>Type: <emphasis>string</emphasis></entry>
27067 <entry>Default: <emphasis>unset</emphasis></entry>
27068 </row>
27069 </tbody>
27070 </tgroup>
27071 </informaltable>
27072 <para>
27073 See <option>smtp_ratelimit_hosts</option> above.
27074 </para>
27075 <para>
27076 <indexterm role="option">
27077 <primary><option>smtp_ratelimit_rcpt</option></primary>
27078 </indexterm>
27079 </para>
27080 <informaltable frame="all">
27081 <tgroup cols="4" colsep="0" rowsep="0">
27082 <colspec colwidth="8*" align="left"/>
27083 <colspec colwidth="6*" align="center"/>
27084 <colspec colwidth="6*" align="center"/>
27085 <colspec colwidth="6*" align="right"/>
27086 <tbody>
27087 <row>
27088 <entry><option>smtp_ratelimit_rcpt</option></entry>
27089 <entry>Use: <emphasis>main</emphasis></entry>
27090 <entry>Type: <emphasis>string</emphasis></entry>
27091 <entry>Default: <emphasis>unset</emphasis></entry>
27092 </row>
27093 </tbody>
27094 </tgroup>
27095 </informaltable>
27096 <para>
27097 See <option>smtp_ratelimit_hosts</option> above.
27098 </para>
27099 <para>
27100 <indexterm role="option">
27101 <primary><option>smtp_receive_timeout</option></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="6*" align="center"/>
27108 <colspec colwidth="6*" align="center"/>
27109 <colspec colwidth="6*" align="right"/>
27110 <tbody>
27111 <row>
27112 <entry><option>smtp_receive_timeout</option></entry>
27113 <entry>Use: <emphasis>main</emphasis></entry>
27114 <entry>Type: <emphasis>time</emphasis></entry>
27115 <entry>Default: <emphasis>5m</emphasis></entry>
27116 </row>
27117 </tbody>
27118 </tgroup>
27119 </informaltable>
27120 <para>
27121 <indexterm role="concept">
27122 <primary>timeout</primary>
27123 <secondary>for SMTP input</secondary>
27124 </indexterm>
27125 <indexterm role="concept">
27126 <primary>SMTP</primary>
27127 <secondary>input timeout</secondary>
27128 </indexterm>
27129 This sets a timeout value for SMTP reception. It applies to all forms of SMTP
27130 input, including batch SMTP. If a line of input (either an SMTP command or a
27131 data line) is not received within this time, the SMTP connection is dropped and
27132 the message is abandoned.
27133 A line is written to the log containing one of the following messages:
27134 </para>
27135 <literallayout class="monospaced">
27136 SMTP command timeout on connection from...
27137 SMTP data timeout on connection from...
27138 </literallayout>
27139 <para>
27140 The former means that Exim was expecting to read an SMTP command; the latter
27141 means that it was in the DATA phase, reading the contents of a message.
27142 </para>
27143 <para>
27144 <indexterm role="option">
27145 <primary><option>-os</option></primary>
27146 </indexterm>
27147 The value set by this option can be overridden by the
27148 <option>-os</option> command-line option. A setting of zero time disables the timeout, but
27149 this should never be used for SMTP over TCP/IP. (It can be useful in some cases
27150 of local input using <option>-bs</option> or <option>-bS</option>.) For non-SMTP input, the reception
27151 timeout is controlled by <option>receive_timeout</option> and <option>-or</option>.
27152 </para>
27153 <para>
27154 <indexterm role="option">
27155 <primary><option>smtp_reserve_hosts</option></primary>
27156 </indexterm>
27157 </para>
27158 <informaltable frame="all">
27159 <tgroup cols="4" colsep="0" rowsep="0">
27160 <colspec colwidth="8*" align="left"/>
27161 <colspec colwidth="6*" align="center"/>
27162 <colspec colwidth="6*" align="center"/>
27163 <colspec colwidth="6*" align="right"/>
27164 <tbody>
27165 <row>
27166 <entry><option>smtp_reserve_hosts</option></entry>
27167 <entry>Use: <emphasis>main</emphasis></entry>
27168 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
27169 <entry>Default: <emphasis>unset</emphasis></entry>
27170 </row>
27171 </tbody>
27172 </tgroup>
27173 </informaltable>
27174 <para>
27175 This option defines hosts for which SMTP connections are reserved; see
27176 <option>smtp_accept_reserve</option> and <option>smtp_load_reserve</option> above.
27177 </para>
27178 <para>
27179 <indexterm role="option">
27180 <primary><option>smtp_return_error_details</option></primary>
27181 </indexterm>
27182 </para>
27183 <informaltable frame="all">
27184 <tgroup cols="4" colsep="0" rowsep="0">
27185 <colspec colwidth="8*" align="left"/>
27186 <colspec colwidth="6*" align="center"/>
27187 <colspec colwidth="6*" align="center"/>
27188 <colspec colwidth="6*" align="right"/>
27189 <tbody>
27190 <row>
27191 <entry><option>smtp_return_error_details</option></entry>
27192 <entry>Use: <emphasis>main</emphasis></entry>
27193 <entry>Type: <emphasis>boolean</emphasis></entry>
27194 <entry>Default: <emphasis>false</emphasis></entry>
27195 </row>
27196 </tbody>
27197 </tgroup>
27198 </informaltable>
27199 <para>
27200 <indexterm role="concept">
27201 <primary>SMTP</primary>
27202 <secondary>details policy failures</secondary>
27203 </indexterm>
27204 <indexterm role="concept">
27205 <primary>policy control</primary>
27206 <secondary>rejection, returning details</secondary>
27207 </indexterm>
27208 In the default state, Exim uses bland messages such as
27209 <quote>Administrative prohibition</quote> when it rejects SMTP commands for policy
27210 reasons. Many sysadmins like this because it gives away little information
27211 to spammers. However, some other sysadmins who are applying strict checking
27212 policies want to give out much fuller information about failures. Setting
27213 <option>smtp_return_error_details</option> true causes Exim to be more forthcoming. For
27214 example, instead of <quote>Administrative prohibition</quote>, it might give:
27215 </para>
27216 <literallayout class="monospaced">
27217 550-Rejected after DATA: '&gt;' missing at end of address:
27218 550 failing address in "From" header is: &lt;user@dom.ain
27219 </literallayout>
27220 <para>
27221 <indexterm role="option">
27222 <primary><option>spamd_address</option></primary>
27223 </indexterm>
27224 </para>
27225 <informaltable frame="all">
27226 <tgroup cols="4" colsep="0" rowsep="0">
27227 <colspec colwidth="8*" align="left"/>
27228 <colspec colwidth="6*" align="center"/>
27229 <colspec colwidth="6*" align="center"/>
27230 <colspec colwidth="6*" align="right"/>
27231 <tbody>
27232 <row>
27233 <entry><option>spamd_address</option></entry>
27234 <entry>Use: <emphasis>main</emphasis></entry>
27235 <entry>Type: <emphasis>string</emphasis></entry>
27236 <entry>Default: <emphasis>see below</emphasis></entry>
27237 </row>
27238 </tbody>
27239 </tgroup>
27240 </informaltable>
27241 <para>
27242 This option is available when Exim is compiled with the content-scanning
27243 extension. It specifies how Exim connects to SpamAssassin&#x2019;s <option>spamd</option> daemon.
27244 The default value is
27245 </para>
27246 <literallayout class="monospaced">
27247 127.0.0.1 783
27248 </literallayout>
27249 <para>
27250 See section <xref linkend="SECTscanspamass"/> for more details.
27251 </para>
27252 <para>
27253 <indexterm role="option">
27254 <primary><option>split_spool_directory</option></primary>
27255 </indexterm>
27256 </para>
27257 <informaltable frame="all">
27258 <tgroup cols="4" colsep="0" rowsep="0">
27259 <colspec colwidth="8*" align="left"/>
27260 <colspec colwidth="6*" align="center"/>
27261 <colspec colwidth="6*" align="center"/>
27262 <colspec colwidth="6*" align="right"/>
27263 <tbody>
27264 <row>
27265 <entry><option>split_spool_directory</option></entry>
27266 <entry>Use: <emphasis>main</emphasis></entry>
27267 <entry>Type: <emphasis>boolean</emphasis></entry>
27268 <entry>Default: <emphasis>false</emphasis></entry>
27269 </row>
27270 </tbody>
27271 </tgroup>
27272 </informaltable>
27273 <para>
27274 <indexterm role="concept">
27275 <primary>multiple spool directories</primary>
27276 </indexterm>
27277 <indexterm role="concept">
27278 <primary>spool directory</primary>
27279 <secondary>split</secondary>
27280 </indexterm>
27281 <indexterm role="concept">
27282 <primary>directories, multiple</primary>
27283 </indexterm>
27284 If this option is set, it causes Exim to split its input directory into 62
27285 subdirectories, each with a single alphanumeric character as its name. The
27286 sixth character of the message id is used to allocate messages to
27287 subdirectories; this is the least significant base-62 digit of the time of
27288 arrival of the message.
27289 </para>
27290 <para>
27291 Splitting up the spool in this way may provide better performance on systems
27292 where there are long mail queues, by reducing the number of files in any one
27293 directory. The msglog directory is also split up in a similar way to the input
27294 directory; however, if <option>preserve_message_logs</option> is set, all old msglog files
27295 are still placed in the single directory <filename>msglog.OLD</filename>.
27296 </para>
27297 <para>
27298 It is not necessary to take any special action for existing messages when
27299 changing <option>split_spool_directory</option>. Exim notices messages that are in the
27300 <quote>wrong</quote> place, and continues to process them. If the option is turned off
27301 after a period of being on, the subdirectories will eventually empty and be
27302 automatically deleted.
27303 </para>
27304 <para>
27305 When <option>split_spool_directory</option> is set, the behaviour of queue runner processes
27306 changes. Instead of creating a list of all messages in the queue, and then
27307 trying to deliver each one in turn, it constructs a list of those in one
27308 sub-directory and tries to deliver them, before moving on to the next
27309 sub-directory. The sub-directories are processed in a random order. This
27310 spreads out the scanning of the input directories, and uses less memory. It is
27311 particularly beneficial when there are lots of messages on the queue. However,
27312 if <option>queue_run_in_order</option> is set, none of this new processing happens. The
27313 entire queue has to be scanned and sorted before any deliveries can start.
27314 </para>
27315 <para>
27316 <indexterm role="option">
27317 <primary><option>spool_directory</option></primary>
27318 </indexterm>
27319 </para>
27320 <informaltable frame="all">
27321 <tgroup cols="4" colsep="0" rowsep="0">
27322 <colspec colwidth="8*" align="left"/>
27323 <colspec colwidth="6*" align="center"/>
27324 <colspec colwidth="6*" align="center"/>
27325 <colspec colwidth="6*" align="right"/>
27326 <tbody>
27327 <row>
27328 <entry><option>spool_directory</option></entry>
27329 <entry>Use: <emphasis>main</emphasis></entry>
27330 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27331 <entry>Default: <emphasis>set at compile time</emphasis></entry>
27332 </row>
27333 </tbody>
27334 </tgroup>
27335 </informaltable>
27336 <para>
27337 <indexterm role="concept">
27338 <primary>spool directory</primary>
27339 <secondary>path to</secondary>
27340 </indexterm>
27341 This defines the directory in which Exim keeps its spool, that is, the messages
27342 it is waiting to deliver. The default value is taken from the compile-time
27343 configuration setting, if there is one. If not, this option must be set. The
27344 string is expanded, so it can contain, for example, a reference to
27345 <varname>$primary_hostname</varname>.
27346 </para>
27347 <para>
27348 If the spool directory name is fixed on your installation, it is recommended
27349 that you set it at build time rather than from this option, particularly if the
27350 log files are being written to the spool directory (see <option>log_file_path</option>).
27351 Otherwise log files cannot be used for errors that are detected early on, such
27352 as failures in the configuration file.
27353 </para>
27354 <para>
27355 By using this option to override the compiled-in path, it is possible to run
27356 tests of Exim without using the standard spool.
27357 </para>
27358 <para>
27359 <indexterm role="option">
27360 <primary><option>sqlite_lock_timeout</option></primary>
27361 </indexterm>
27362 </para>
27363 <informaltable frame="all">
27364 <tgroup cols="4" colsep="0" rowsep="0">
27365 <colspec colwidth="8*" align="left"/>
27366 <colspec colwidth="6*" align="center"/>
27367 <colspec colwidth="6*" align="center"/>
27368 <colspec colwidth="6*" align="right"/>
27369 <tbody>
27370 <row>
27371 <entry><option>sqlite_lock_timeout</option></entry>
27372 <entry>Use: <emphasis>main</emphasis></entry>
27373 <entry>Type: <emphasis>time</emphasis></entry>
27374 <entry>Default: <emphasis>5s</emphasis></entry>
27375 </row>
27376 </tbody>
27377 </tgroup>
27378 </informaltable>
27379 <para>
27380 <indexterm role="concept">
27381 <primary>sqlite lookup type</primary>
27382 <secondary>lock timeout</secondary>
27383 </indexterm>
27384 This option controls the timeout that the <command>sqlite</command> lookup uses when trying to
27385 access an SQLite database. See section <xref linkend="SECTsqlite"/> for more details.
27386 </para>
27387 <para>
27388 <indexterm role="option">
27389 <primary><option>strict_acl_vars</option></primary>
27390 </indexterm>
27391 </para>
27392 <informaltable frame="all">
27393 <tgroup cols="4" colsep="0" rowsep="0">
27394 <colspec colwidth="8*" align="left"/>
27395 <colspec colwidth="6*" align="center"/>
27396 <colspec colwidth="6*" align="center"/>
27397 <colspec colwidth="6*" align="right"/>
27398 <tbody>
27399 <row>
27400 <entry><option>strict_acl_vars</option></entry>
27401 <entry>Use: <emphasis>main</emphasis></entry>
27402 <entry>Type: <emphasis>boolean</emphasis></entry>
27403 <entry>Default: <emphasis>false</emphasis></entry>
27404 </row>
27405 </tbody>
27406 </tgroup>
27407 </informaltable>
27408 <para>
27409 <indexterm role="concept">
27410 <primary>access control lists (ACLs)</primary>
27411 <secondary>variables, handling unset</secondary>
27412 </indexterm>
27413 This option controls what happens if a syntactically valid but undefined ACL
27414 variable is referenced. If it is false (the default), an empty string
27415 is substituted; if it is true, an error is generated. See section
27416 <xref linkend="SECTaclvariables"/> for details of ACL variables.
27417 </para>
27418 <para>
27419 <indexterm role="option">
27420 <primary><option>strip_excess_angle_brackets</option></primary>
27421 </indexterm>
27422 </para>
27423 <informaltable frame="all">
27424 <tgroup cols="4" colsep="0" rowsep="0">
27425 <colspec colwidth="8*" align="left"/>
27426 <colspec colwidth="6*" align="center"/>
27427 <colspec colwidth="6*" align="center"/>
27428 <colspec colwidth="6*" align="right"/>
27429 <tbody>
27430 <row>
27431 <entry><option>strip_excess_angle_brackets</option></entry>
27432 <entry>Use: <emphasis>main</emphasis></entry>
27433 <entry>Type: <emphasis>boolean</emphasis></entry>
27434 <entry>Default: <emphasis>false</emphasis></entry>
27435 </row>
27436 </tbody>
27437 </tgroup>
27438 </informaltable>
27439 <para>
27440 <indexterm role="concept">
27441 <primary>angle brackets, excess</primary>
27442 </indexterm>
27443 If this option is set, redundant pairs of angle brackets round <quote>route-addr</quote>
27444 items in addresses are stripped. For example, <emphasis>&lt;&lt;xxx@a.b.c.d&gt;&gt;</emphasis> is
27445 treated as <emphasis>&lt;xxx@a.b.c.d&gt;</emphasis>. If this is in the envelope and the message is
27446 passed on to another MTA, the excess angle brackets are not passed on. If this
27447 option is not set, multiple pairs of angle brackets cause a syntax error.
27448 </para>
27449 <para>
27450 <indexterm role="option">
27451 <primary><option>strip_trailing_dot</option></primary>
27452 </indexterm>
27453 </para>
27454 <informaltable frame="all">
27455 <tgroup cols="4" colsep="0" rowsep="0">
27456 <colspec colwidth="8*" align="left"/>
27457 <colspec colwidth="6*" align="center"/>
27458 <colspec colwidth="6*" align="center"/>
27459 <colspec colwidth="6*" align="right"/>
27460 <tbody>
27461 <row>
27462 <entry><option>strip_trailing_dot</option></entry>
27463 <entry>Use: <emphasis>main</emphasis></entry>
27464 <entry>Type: <emphasis>boolean</emphasis></entry>
27465 <entry>Default: <emphasis>false</emphasis></entry>
27466 </row>
27467 </tbody>
27468 </tgroup>
27469 </informaltable>
27470 <para>
27471 <indexterm role="concept">
27472 <primary>trailing dot on domain</primary>
27473 </indexterm>
27474 <indexterm role="concept">
27475 <primary>dot</primary>
27476 <secondary>trailing on domain</secondary>
27477 </indexterm>
27478 If this option is set, a trailing dot at the end of a domain in an address is
27479 ignored. If this is in the envelope and the message is passed on to another
27480 MTA, the dot is not passed on. If this option is not set, a dot at the end of a
27481 domain causes a syntax error.
27482 However, addresses in header lines are checked only when an ACL requests header
27483 syntax checking.
27484 </para>
27485 <para>
27486 <indexterm role="option">
27487 <primary><option>syslog_duplication</option></primary>
27488 </indexterm>
27489 </para>
27490 <informaltable frame="all">
27491 <tgroup cols="4" colsep="0" rowsep="0">
27492 <colspec colwidth="8*" align="left"/>
27493 <colspec colwidth="6*" align="center"/>
27494 <colspec colwidth="6*" align="center"/>
27495 <colspec colwidth="6*" align="right"/>
27496 <tbody>
27497 <row>
27498 <entry><option>syslog_duplication</option></entry>
27499 <entry>Use: <emphasis>main</emphasis></entry>
27500 <entry>Type: <emphasis>boolean</emphasis></entry>
27501 <entry>Default: <emphasis>true</emphasis></entry>
27502 </row>
27503 </tbody>
27504 </tgroup>
27505 </informaltable>
27506 <para>
27507 <indexterm role="concept">
27508 <primary>syslog</primary>
27509 <secondary>duplicate log lines; suppressing</secondary>
27510 </indexterm>
27511 When Exim is logging to syslog, it writes the log lines for its three
27512 separate logs at different syslog priorities so that they can in principle
27513 be separated on the logging hosts. Some installations do not require this
27514 separation, and in those cases, the duplication of certain log lines is a
27515 nuisance. If <option>syslog_duplication</option> is set false, only one copy of any
27516 particular log line is written to syslog. For lines that normally go to
27517 both the main log and the reject log, the reject log version (possibly
27518 containing message header lines) is written, at LOG_NOTICE priority.
27519 Lines that normally go to both the main and the panic log are written at
27520 the LOG_ALERT priority.
27521 </para>
27522 <para>
27523 <indexterm role="option">
27524 <primary><option>syslog_facility</option></primary>
27525 </indexterm>
27526 </para>
27527 <informaltable frame="all">
27528 <tgroup cols="4" colsep="0" rowsep="0">
27529 <colspec colwidth="8*" align="left"/>
27530 <colspec colwidth="6*" align="center"/>
27531 <colspec colwidth="6*" align="center"/>
27532 <colspec colwidth="6*" align="right"/>
27533 <tbody>
27534 <row>
27535 <entry><option>syslog_facility</option></entry>
27536 <entry>Use: <emphasis>main</emphasis></entry>
27537 <entry>Type: <emphasis>string</emphasis></entry>
27538 <entry>Default: <emphasis>unset</emphasis></entry>
27539 </row>
27540 </tbody>
27541 </tgroup>
27542 </informaltable>
27543 <para>
27544 <indexterm role="concept">
27545 <primary>syslog</primary>
27546 <secondary>facility; setting</secondary>
27547 </indexterm>
27548 This option sets the syslog <quote>facility</quote> name, used when Exim is logging to
27549 syslog. The value must be one of the strings <quote>mail</quote>, <quote>user</quote>, <quote>news</quote>,
27550 <quote>uucp</quote>, <quote>daemon</quote>, or <quote>local<emphasis>x</emphasis></quote> where <emphasis>x</emphasis> is a digit between 0 and 7.
27551 If this option is unset, <quote>mail</quote> is used. See chapter <xref linkend="CHAPlog"/> for
27552 details of Exim&#x2019;s logging.
27553 </para>
27554 <para>
27555 <indexterm role="option">
27556 <primary><option>syslog_processname</option></primary>
27557 </indexterm>
27558 </para>
27559 <informaltable frame="all">
27560 <tgroup cols="4" colsep="0" rowsep="0">
27561 <colspec colwidth="8*" align="left"/>
27562 <colspec colwidth="6*" align="center"/>
27563 <colspec colwidth="6*" align="center"/>
27564 <colspec colwidth="6*" align="right"/>
27565 <tbody>
27566 <row>
27567 <entry><option>syslog_processname</option></entry>
27568 <entry>Use: <emphasis>main</emphasis></entry>
27569 <entry>Type: <emphasis>string</emphasis></entry>
27570 <entry>Default: <emphasis><literal>exim</literal></emphasis></entry>
27571 </row>
27572 </tbody>
27573 </tgroup>
27574 </informaltable>
27575 <para>
27576 <indexterm role="concept">
27577 <primary>syslog</primary>
27578 <secondary>process name; setting</secondary>
27579 </indexterm>
27580 This option sets the syslog <quote>ident</quote> name, used when Exim is logging to
27581 syslog. The value must be no longer than 32 characters. See chapter
27582 <xref linkend="CHAPlog"/> for details of Exim&#x2019;s logging.
27583 </para>
27584 <para>
27585 <indexterm role="option">
27586 <primary><option>syslog_timestamp</option></primary>
27587 </indexterm>
27588 </para>
27589 <informaltable frame="all">
27590 <tgroup cols="4" colsep="0" rowsep="0">
27591 <colspec colwidth="8*" align="left"/>
27592 <colspec colwidth="6*" align="center"/>
27593 <colspec colwidth="6*" align="center"/>
27594 <colspec colwidth="6*" align="right"/>
27595 <tbody>
27596 <row>
27597 <entry><option>syslog_timestamp</option></entry>
27598 <entry>Use: <emphasis>main</emphasis></entry>
27599 <entry>Type: <emphasis>boolean</emphasis></entry>
27600 <entry>Default: <emphasis>true</emphasis></entry>
27601 </row>
27602 </tbody>
27603 </tgroup>
27604 </informaltable>
27605 <para>
27606 <indexterm role="concept">
27607 <primary>syslog</primary>
27608 <secondary>timestamps</secondary>
27609 </indexterm>
27610 If <option>syslog_timestamp</option> is set false, the timestamps on Exim&#x2019;s log lines are
27611 omitted when these lines are sent to syslog. See chapter <xref linkend="CHAPlog"/> for
27612 details of Exim&#x2019;s logging.
27613 </para>
27614 <para>
27615 <indexterm role="option">
27616 <primary><option>system_filter</option></primary>
27617 </indexterm>
27618 </para>
27619 <informaltable frame="all">
27620 <tgroup cols="4" colsep="0" rowsep="0">
27621 <colspec colwidth="8*" align="left"/>
27622 <colspec colwidth="6*" align="center"/>
27623 <colspec colwidth="6*" align="center"/>
27624 <colspec colwidth="6*" align="right"/>
27625 <tbody>
27626 <row>
27627 <entry><option>system_filter</option></entry>
27628 <entry>Use: <emphasis>main</emphasis></entry>
27629 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27630 <entry>Default: <emphasis>unset</emphasis></entry>
27631 </row>
27632 </tbody>
27633 </tgroup>
27634 </informaltable>
27635 <para>
27636 <indexterm role="concept">
27637 <primary>filter</primary>
27638 <secondary>system filter</secondary>
27639 </indexterm>
27640 <indexterm role="concept">
27641 <primary>system filter</primary>
27642 <secondary>specifying</secondary>
27643 </indexterm>
27644 <indexterm role="concept">
27645 <primary>Sieve filter</primary>
27646 <secondary>not available for system filter</secondary>
27647 </indexterm>
27648 This option specifies an Exim filter file that is applied to all messages at
27649 the start of each delivery attempt, before any routing is done. System filters
27650 must be Exim filters; they cannot be Sieve filters. If the system filter
27651 generates any deliveries to files or pipes, or any new mail messages, the
27652 appropriate <option>system_filter_..._transport</option> option(s) must be set, to define
27653 which transports are to be used. Details of this facility are given in chapter
27654 <xref linkend="CHAPsystemfilter"/>.
27655 </para>
27656 <para>
27657 <indexterm role="option">
27658 <primary><option>system_filter_directory_transport</option></primary>
27659 </indexterm>
27660 </para>
27661 <informaltable frame="all">
27662 <tgroup cols="4" colsep="0" rowsep="0">
27663 <colspec colwidth="8*" align="left"/>
27664 <colspec colwidth="6*" align="center"/>
27665 <colspec colwidth="6*" align="center"/>
27666 <colspec colwidth="6*" align="right"/>
27667 <tbody>
27668 <row>
27669 <entry><option>system_filter_directory_transport</option></entry>
27670 <entry>Use: <emphasis>main</emphasis></entry>
27671 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27672 <entry>Default: <emphasis>unset</emphasis></entry>
27673 </row>
27674 </tbody>
27675 </tgroup>
27676 </informaltable>
27677 <para>
27678 <indexterm role="variable">
27679 <primary><varname>$address_file</varname></primary>
27680 </indexterm>
27681 This sets the name of the transport driver that is to be used when the
27682 <option>save</option> command in a system message filter specifies a path ending in <quote>/</quote>,
27683 implying delivery of each message into a separate file in some directory.
27684 During the delivery, the variable <varname>$address_file</varname> contains the path name.
27685 </para>
27686 <para>
27687 <indexterm role="option">
27688 <primary><option>system_filter_file_transport</option></primary>
27689 </indexterm>
27690 </para>
27691 <informaltable frame="all">
27692 <tgroup cols="4" colsep="0" rowsep="0">
27693 <colspec colwidth="8*" align="left"/>
27694 <colspec colwidth="6*" align="center"/>
27695 <colspec colwidth="6*" align="center"/>
27696 <colspec colwidth="6*" align="right"/>
27697 <tbody>
27698 <row>
27699 <entry><option>system_filter_file_transport</option></entry>
27700 <entry>Use: <emphasis>main</emphasis></entry>
27701 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27702 <entry>Default: <emphasis>unset</emphasis></entry>
27703 </row>
27704 </tbody>
27705 </tgroup>
27706 </informaltable>
27707 <para>
27708 <indexterm role="concept">
27709 <primary>file</primary>
27710 <secondary>transport for system filter</secondary>
27711 </indexterm>
27712 This sets the name of the transport driver that is to be used when the <option>save</option>
27713 command in a system message filter specifies a path not ending in <quote>/</quote>. During
27714 the delivery, the variable <varname>$address_file</varname> contains the path name.
27715 </para>
27716 <para>
27717 <indexterm role="option">
27718 <primary><option>system_filter_group</option></primary>
27719 </indexterm>
27720 </para>
27721 <informaltable frame="all">
27722 <tgroup cols="4" colsep="0" rowsep="0">
27723 <colspec colwidth="8*" align="left"/>
27724 <colspec colwidth="6*" align="center"/>
27725 <colspec colwidth="6*" align="center"/>
27726 <colspec colwidth="6*" align="right"/>
27727 <tbody>
27728 <row>
27729 <entry><option>system_filter_group</option></entry>
27730 <entry>Use: <emphasis>main</emphasis></entry>
27731 <entry>Type: <emphasis>string</emphasis></entry>
27732 <entry>Default: <emphasis>unset</emphasis></entry>
27733 </row>
27734 </tbody>
27735 </tgroup>
27736 </informaltable>
27737 <para>
27738 <indexterm role="concept">
27739 <primary>gid (group id)</primary>
27740 <secondary>system filter</secondary>
27741 </indexterm>
27742 This option is used only when <option>system_filter_user</option> is also set. It sets the
27743 gid under which the system filter is run, overriding any gid that is associated
27744 with the user. The value may be numerical or symbolic.
27745 </para>
27746 <para>
27747 <indexterm role="option">
27748 <primary><option>system_filter_pipe_transport</option></primary>
27749 </indexterm>
27750 </para>
27751 <informaltable frame="all">
27752 <tgroup cols="4" colsep="0" rowsep="0">
27753 <colspec colwidth="8*" align="left"/>
27754 <colspec colwidth="6*" align="center"/>
27755 <colspec colwidth="6*" align="center"/>
27756 <colspec colwidth="6*" align="right"/>
27757 <tbody>
27758 <row>
27759 <entry><option>system_filter_pipe_transport</option></entry>
27760 <entry>Use: <emphasis>main</emphasis></entry>
27761 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27762 <entry>Default: <emphasis>unset</emphasis></entry>
27763 </row>
27764 </tbody>
27765 </tgroup>
27766 </informaltable>
27767 <para>
27768 <indexterm role="concept">
27769 <primary><command>pipe</command> transport</primary>
27770 <secondary>for system filter</secondary>
27771 </indexterm>
27772 <indexterm role="variable">
27773 <primary><varname>$address_pipe</varname></primary>
27774 </indexterm>
27775 This specifies the transport driver that is to be used when a <option>pipe</option> command
27776 is used in a system filter. During the delivery, the variable <varname>$address_pipe</varname>
27777 contains the pipe command.
27778 </para>
27779 <para>
27780 <indexterm role="option">
27781 <primary><option>system_filter_reply_transport</option></primary>
27782 </indexterm>
27783 </para>
27784 <informaltable frame="all">
27785 <tgroup cols="4" colsep="0" rowsep="0">
27786 <colspec colwidth="8*" align="left"/>
27787 <colspec colwidth="6*" align="center"/>
27788 <colspec colwidth="6*" align="center"/>
27789 <colspec colwidth="6*" align="right"/>
27790 <tbody>
27791 <row>
27792 <entry><option>system_filter_reply_transport</option></entry>
27793 <entry>Use: <emphasis>main</emphasis></entry>
27794 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27795 <entry>Default: <emphasis>unset</emphasis></entry>
27796 </row>
27797 </tbody>
27798 </tgroup>
27799 </informaltable>
27800 <para>
27801 <indexterm role="concept">
27802 <primary><command>autoreply</command> transport</primary>
27803 <secondary>for system filter</secondary>
27804 </indexterm>
27805 This specifies the transport driver that is to be used when a <option>mail</option> command
27806 is used in a system filter.
27807 </para>
27808 <para revisionflag="changed">
27809 <indexterm role="option">
27810 <primary><option>system_filter_user</option></primary>
27811 </indexterm>
27812 </para>
27813 <informaltable frame="all" revisionflag="changed">
27814 <tgroup cols="4" colsep="0" rowsep="0">
27815 <colspec colwidth="8*" align="left"/>
27816 <colspec colwidth="6*" align="center"/>
27817 <colspec colwidth="6*" align="center"/>
27818 <colspec colwidth="6*" align="right"/>
27819 <tbody>
27820 <row>
27821 <entry><option>system_filter_user</option></entry>
27822 <entry>Use: <emphasis>main</emphasis></entry>
27823 <entry>Type: <emphasis>string</emphasis></entry>
27824 <entry>Default: <emphasis>unset</emphasis></entry>
27825 </row>
27826 </tbody>
27827 </tgroup>
27828 </informaltable>
27829 <para revisionflag="changed">
27830 <indexterm role="concept">
27831 <primary>uid (user id)</primary>
27832 <secondary>system filter</secondary>
27833 </indexterm>
27834 If this option is set to root, the system filter is run in the main Exim
27835 delivery process, as root.  Otherwise, the system filter runs in a separate
27836 process, as the given user, defaulting to the Exim run-time user.
27837 Unless the string consists entirely of digits, it
27838 is looked up in the password data. Failure to find the named user causes a
27839 configuration error. The gid is either taken from the password data, or
27840 specified by <option>system_filter_group</option>. When the uid is specified numerically,
27841 <option>system_filter_group</option> is required to be set.
27842 </para>
27843 <para revisionflag="changed">
27844 If the system filter generates any pipe, file, or reply deliveries, the uid
27845 under which the filter is run is used when transporting them, unless a
27846 transport option overrides.
27847 </para>
27848 <para>
27849 <indexterm role="option">
27850 <primary><option>tcp_nodelay</option></primary>
27851 </indexterm>
27852 </para>
27853 <informaltable frame="all">
27854 <tgroup cols="4" colsep="0" rowsep="0">
27855 <colspec colwidth="8*" align="left"/>
27856 <colspec colwidth="6*" align="center"/>
27857 <colspec colwidth="6*" align="center"/>
27858 <colspec colwidth="6*" align="right"/>
27859 <tbody>
27860 <row>
27861 <entry><option>tcp_nodelay</option></entry>
27862 <entry>Use: <emphasis>main</emphasis></entry>
27863 <entry>Type: <emphasis>boolean</emphasis></entry>
27864 <entry>Default: <emphasis>true</emphasis></entry>
27865 </row>
27866 </tbody>
27867 </tgroup>
27868 </informaltable>
27869 <para>
27870 <indexterm role="concept">
27871 <primary>daemon</primary>
27872 <secondary>TCP_NODELAY on sockets</secondary>
27873 </indexterm>
27874 <indexterm role="concept">
27875 <primary>Nagle algorithm</primary>
27876 </indexterm>
27877 <indexterm role="concept">
27878 <primary>TCP_NODELAY on listening sockets</primary>
27879 </indexterm>
27880 If this option is set false, it stops the Exim daemon setting the
27881 TCP_NODELAY option on its listening sockets. Setting TCP_NODELAY
27882 turns off the <quote>Nagle algorithm</quote>, which is a way of improving network
27883 performance in interactive (character-by-character) situations. Turning it off
27884 should improve Exim&#x2019;s performance a bit, so that is what happens by default.
27885 However, it appears that some broken clients cannot cope, and time out. Hence
27886 this option. It affects only those sockets that are set up for listening by the
27887 daemon. Sockets created by the smtp transport for delivering mail always set
27888 TCP_NODELAY.
27889 </para>
27890 <para>
27891 <indexterm role="option">
27892 <primary><option>timeout_frozen_after</option></primary>
27893 </indexterm>
27894 </para>
27895 <informaltable frame="all">
27896 <tgroup cols="4" colsep="0" rowsep="0">
27897 <colspec colwidth="8*" align="left"/>
27898 <colspec colwidth="6*" align="center"/>
27899 <colspec colwidth="6*" align="center"/>
27900 <colspec colwidth="6*" align="right"/>
27901 <tbody>
27902 <row>
27903 <entry><option>timeout_frozen_after</option></entry>
27904 <entry>Use: <emphasis>main</emphasis></entry>
27905 <entry>Type: <emphasis>time</emphasis></entry>
27906 <entry>Default: <emphasis>0s</emphasis></entry>
27907 </row>
27908 </tbody>
27909 </tgroup>
27910 </informaltable>
27911 <para>
27912 <indexterm role="concept">
27913 <primary>frozen messages</primary>
27914 <secondary>timing out</secondary>
27915 </indexterm>
27916 <indexterm role="concept">
27917 <primary>timeout</primary>
27918 <secondary>frozen messages</secondary>
27919 </indexterm>
27920 If <option>timeout_frozen_after</option> is set to a time greater than zero, a frozen
27921 message of any kind that has been on the queue for longer than the given time
27922 is automatically cancelled at the next queue run. If the frozen message is a
27923 bounce message, it is just discarded; otherwise, a bounce is sent to the
27924 sender, in a similar manner to cancellation by the <option>-Mg</option> command line option.
27925 If you want to timeout frozen bounce messages earlier than other kinds of
27926 frozen message, see <option>ignore_bounce_errors_after</option>.
27927 </para>
27928 <para>
27929 <emphasis role="bold">Note:</emphasis> the default value of zero means no timeouts; with this setting,
27930 frozen messages remain on the queue forever (except for any frozen bounce
27931 messages that are released by <option>ignore_bounce_errors_after</option>).
27932 </para>
27933 <para>
27934 <indexterm role="option">
27935 <primary><option>timezone</option></primary>
27936 </indexterm>
27937 </para>
27938 <informaltable frame="all">
27939 <tgroup cols="4" colsep="0" rowsep="0">
27940 <colspec colwidth="8*" align="left"/>
27941 <colspec colwidth="6*" align="center"/>
27942 <colspec colwidth="6*" align="center"/>
27943 <colspec colwidth="6*" align="right"/>
27944 <tbody>
27945 <row>
27946 <entry><option>timezone</option></entry>
27947 <entry>Use: <emphasis>main</emphasis></entry>
27948 <entry>Type: <emphasis>string</emphasis></entry>
27949 <entry>Default: <emphasis>unset</emphasis></entry>
27950 </row>
27951 </tbody>
27952 </tgroup>
27953 </informaltable>
27954 <para>
27955 <indexterm role="concept">
27956 <primary>timezone, setting</primary>
27957 </indexterm>
27958 The value of <option>timezone</option> is used to set the environment variable TZ while
27959 running Exim (if it is different on entry). This ensures that all timestamps
27960 created by Exim are in the required timezone. If you want all your timestamps
27961 to be in UTC (aka GMT) you should set
27962 </para>
27963 <literallayout class="monospaced">
27964 timezone = UTC
27965 </literallayout>
27966 <para>
27967 The default value is taken from TIMEZONE_DEFAULT in <filename>Local/Makefile</filename>,
27968 or, if that is not set, from the value of the TZ environment variable when Exim
27969 is built. If <option>timezone</option> is set to the empty string, either at build or run
27970 time, any existing TZ variable is removed from the environment when Exim
27971 runs. This is appropriate behaviour for obtaining wall-clock time on some, but
27972 unfortunately not all, operating systems.
27973 </para>
27974 <para>
27975 <indexterm role="option">
27976 <primary><option>tls_advertise_hosts</option></primary>
27977 </indexterm>
27978 </para>
27979 <informaltable frame="all">
27980 <tgroup cols="4" colsep="0" rowsep="0">
27981 <colspec colwidth="8*" align="left"/>
27982 <colspec colwidth="6*" align="center"/>
27983 <colspec colwidth="6*" align="center"/>
27984 <colspec colwidth="6*" align="right"/>
27985 <tbody>
27986 <row>
27987 <entry><option>tls_advertise_hosts</option></entry>
27988 <entry>Use: <emphasis>main</emphasis></entry>
27989 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
27990 <entry>Default: <emphasis>unset</emphasis></entry>
27991 </row>
27992 </tbody>
27993 </tgroup>
27994 </informaltable>
27995 <para>
27996 <indexterm role="concept">
27997 <primary>TLS</primary>
27998 <secondary>advertising</secondary>
27999 </indexterm>
28000 <indexterm role="concept">
28001 <primary>encryption</primary>
28002 <secondary>on SMTP connection</secondary>
28003 </indexterm>
28004 <indexterm role="concept">
28005 <primary>SMTP</primary>
28006 <secondary>encrypted connection</secondary>
28007 </indexterm>
28008 When Exim is built with support for TLS encrypted connections, the availability
28009 of the STARTTLS command to set up an encrypted session is advertised in
28010 response to EHLO only to those client hosts that match this option. See
28011 chapter <xref linkend="CHAPTLS"/> for details of Exim&#x2019;s support for TLS.
28012 </para>
28013 <para>
28014 <indexterm role="option">
28015 <primary><option>tls_certificate</option></primary>
28016 </indexterm>
28017 </para>
28018 <informaltable frame="all">
28019 <tgroup cols="4" colsep="0" rowsep="0">
28020 <colspec colwidth="8*" align="left"/>
28021 <colspec colwidth="6*" align="center"/>
28022 <colspec colwidth="6*" align="center"/>
28023 <colspec colwidth="6*" align="right"/>
28024 <tbody>
28025 <row>
28026 <entry><option>tls_certificate</option></entry>
28027 <entry>Use: <emphasis>main</emphasis></entry>
28028 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28029 <entry>Default: <emphasis>unset</emphasis></entry>
28030 </row>
28031 </tbody>
28032 </tgroup>
28033 </informaltable>
28034 <para>
28035 <indexterm role="concept">
28036 <primary>TLS</primary>
28037 <secondary>server certificate; location of</secondary>
28038 </indexterm>
28039 <indexterm role="concept">
28040 <primary>certificate</primary>
28041 <secondary>server, location of</secondary>
28042 </indexterm>
28043 The value of this option is expanded, and must then be the absolute path to a
28044 file which contains the server&#x2019;s certificates. The server&#x2019;s private key is also
28045 assumed to be in this file if <option>tls_privatekey</option> is unset. See chapter
28046 <xref linkend="CHAPTLS"/> for further details.
28047 </para>
28048 <para>
28049 <emphasis role="bold">Note</emphasis>: The certificates defined by this option are used only when Exim is
28050 receiving incoming messages as a server. If you want to supply certificates for
28051 use when sending messages as a client, you must set the <option>tls_certificate</option>
28052 option in the relevant <command>smtp</command> transport.
28053 </para>
28054 <para>
28055 <indexterm role="option">
28056 <primary><option>tls_crl</option></primary>
28057 </indexterm>
28058 </para>
28059 <informaltable frame="all">
28060 <tgroup cols="4" colsep="0" rowsep="0">
28061 <colspec colwidth="8*" align="left"/>
28062 <colspec colwidth="6*" align="center"/>
28063 <colspec colwidth="6*" align="center"/>
28064 <colspec colwidth="6*" align="right"/>
28065 <tbody>
28066 <row>
28067 <entry><option>tls_crl</option></entry>
28068 <entry>Use: <emphasis>main</emphasis></entry>
28069 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28070 <entry>Default: <emphasis>unset</emphasis></entry>
28071 </row>
28072 </tbody>
28073 </tgroup>
28074 </informaltable>
28075 <para>
28076 <indexterm role="concept">
28077 <primary>TLS</primary>
28078 <secondary>server certificate revocation list</secondary>
28079 </indexterm>
28080 <indexterm role="concept">
28081 <primary>certificate</primary>
28082 <secondary>revocation list for server</secondary>
28083 </indexterm>
28084 This option specifies a certificate revocation list. The expanded value must
28085 be the name of a file that contains a CRL in PEM format.
28086 </para>
28087 <para>
28088 <indexterm role="option">
28089 <primary><option>tls_dhparam</option></primary>
28090 </indexterm>
28091 </para>
28092 <informaltable frame="all">
28093 <tgroup cols="4" colsep="0" rowsep="0">
28094 <colspec colwidth="8*" align="left"/>
28095 <colspec colwidth="6*" align="center"/>
28096 <colspec colwidth="6*" align="center"/>
28097 <colspec colwidth="6*" align="right"/>
28098 <tbody>
28099 <row>
28100 <entry><option>tls_dhparam</option></entry>
28101 <entry>Use: <emphasis>main</emphasis></entry>
28102 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28103 <entry>Default: <emphasis>unset</emphasis></entry>
28104 </row>
28105 </tbody>
28106 </tgroup>
28107 </informaltable>
28108 <para>
28109 <indexterm role="concept">
28110 <primary>TLS</primary>
28111 <secondary>D-H parameters for server</secondary>
28112 </indexterm>
28113 The value of this option is expanded, and must then be the absolute path to
28114 a file which contains the server&#x2019;s DH parameter values.
28115 This is used only for OpenSSL. When Exim is linked with GnuTLS, this option is
28116 ignored. See section <xref linkend="SECTopenvsgnu"/> for further details.
28117 </para>
28118 <para>
28119 <indexterm role="option">
28120 <primary><option>tls_on_connect_ports</option></primary>
28121 </indexterm>
28122 </para>
28123 <informaltable frame="all">
28124 <tgroup cols="4" colsep="0" rowsep="0">
28125 <colspec colwidth="8*" align="left"/>
28126 <colspec colwidth="6*" align="center"/>
28127 <colspec colwidth="6*" align="center"/>
28128 <colspec colwidth="6*" align="right"/>
28129 <tbody>
28130 <row>
28131 <entry><option>tls_on_connect_ports</option></entry>
28132 <entry>Use: <emphasis>main</emphasis></entry>
28133 <entry>Type: <emphasis>string list</emphasis></entry>
28134 <entry>Default: <emphasis>unset</emphasis></entry>
28135 </row>
28136 </tbody>
28137 </tgroup>
28138 </informaltable>
28139 <para>
28140 This option specifies a list of incoming SSMTP (aka SMTPS) ports that should
28141 operate the obsolete SSMTP (SMTPS) protocol, where a TLS session is immediately
28142 set up without waiting for the client to issue a STARTTLS command. For
28143 further details, see section <xref linkend="SECTsupobssmt"/>.
28144 </para>
28145 <para>
28146 <indexterm role="option">
28147 <primary><option>tls_privatekey</option></primary>
28148 </indexterm>
28149 </para>
28150 <informaltable frame="all">
28151 <tgroup cols="4" colsep="0" rowsep="0">
28152 <colspec colwidth="8*" align="left"/>
28153 <colspec colwidth="6*" align="center"/>
28154 <colspec colwidth="6*" align="center"/>
28155 <colspec colwidth="6*" align="right"/>
28156 <tbody>
28157 <row>
28158 <entry><option>tls_privatekey</option></entry>
28159 <entry>Use: <emphasis>main</emphasis></entry>
28160 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28161 <entry>Default: <emphasis>unset</emphasis></entry>
28162 </row>
28163 </tbody>
28164 </tgroup>
28165 </informaltable>
28166 <para>
28167 <indexterm role="concept">
28168 <primary>TLS</primary>
28169 <secondary>server private key; location of</secondary>
28170 </indexterm>
28171 The value of this option is expanded, and must then be the absolute path to a
28172 file which contains the server&#x2019;s private key. If this option is unset, or if
28173 the expansion is forced to fail, or the result is an empty string, the private
28174 key is assumed to be in the same file as the server&#x2019;s certificates. See chapter
28175 <xref linkend="CHAPTLS"/> for further details.
28176 </para>
28177 <para>
28178 <indexterm role="option">
28179 <primary><option>tls_remember_esmtp</option></primary>
28180 </indexterm>
28181 </para>
28182 <informaltable frame="all">
28183 <tgroup cols="4" colsep="0" rowsep="0">
28184 <colspec colwidth="8*" align="left"/>
28185 <colspec colwidth="6*" align="center"/>
28186 <colspec colwidth="6*" align="center"/>
28187 <colspec colwidth="6*" align="right"/>
28188 <tbody>
28189 <row>
28190 <entry><option>tls_remember_esmtp</option></entry>
28191 <entry>Use: <emphasis>main</emphasis></entry>
28192 <entry>Type: <emphasis>boolean</emphasis></entry>
28193 <entry>Default: <emphasis>false</emphasis></entry>
28194 </row>
28195 </tbody>
28196 </tgroup>
28197 </informaltable>
28198 <para>
28199 <indexterm role="concept">
28200 <primary>TLS</primary>
28201 <secondary>esmtp state; remembering</secondary>
28202 </indexterm>
28203 <indexterm role="concept">
28204 <primary>TLS</primary>
28205 <secondary>broken clients</secondary>
28206 </indexterm>
28207 If this option is set true, Exim violates the RFCs by remembering that it is in
28208 <quote>esmtp</quote> state after successfully negotiating a TLS session. This provides
28209 support for broken clients that fail to send a new EHLO after starting a
28210 TLS session.
28211 </para>
28212 <para>
28213 <indexterm role="option">
28214 <primary><option>tls_require_ciphers</option></primary>
28215 </indexterm>
28216 </para>
28217 <informaltable frame="all">
28218 <tgroup cols="4" colsep="0" rowsep="0">
28219 <colspec colwidth="8*" align="left"/>
28220 <colspec colwidth="6*" align="center"/>
28221 <colspec colwidth="6*" align="center"/>
28222 <colspec colwidth="6*" align="right"/>
28223 <tbody>
28224 <row>
28225 <entry><option>tls_require_ciphers</option></entry>
28226 <entry>Use: <emphasis>main</emphasis></entry>
28227 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28228 <entry>Default: <emphasis>unset</emphasis></entry>
28229 </row>
28230 </tbody>
28231 </tgroup>
28232 </informaltable>
28233 <para>
28234 <indexterm role="concept">
28235 <primary>TLS</primary>
28236 <secondary>requiring specific ciphers</secondary>
28237 </indexterm>
28238 <indexterm role="concept">
28239 <primary>cipher</primary>
28240 <secondary>requiring specific</secondary>
28241 </indexterm>
28242 This option controls which ciphers can be used for incoming TLS connections.
28243 The <command>smtp</command> transport has an option of the same name for controlling outgoing
28244 connections. This option is expanded for each connection, so can be varied for
28245 different clients if required. The value of this option must be a list of
28246 permitted cipher suites. The OpenSSL and GnuTLS libraries handle cipher control
28247 in somewhat different ways. If GnuTLS is being used, the client controls the
28248 preference order of the available ciphers. Details are given in sections
28249 <xref linkend="SECTreqciphssl"/> and <xref linkend="SECTreqciphgnu"/>.
28250 </para>
28251 <para>
28252 <indexterm role="option">
28253 <primary><option>tls_try_verify_hosts</option></primary>
28254 </indexterm>
28255 </para>
28256 <informaltable frame="all">
28257 <tgroup cols="4" colsep="0" rowsep="0">
28258 <colspec colwidth="8*" align="left"/>
28259 <colspec colwidth="6*" align="center"/>
28260 <colspec colwidth="6*" align="center"/>
28261 <colspec colwidth="6*" align="right"/>
28262 <tbody>
28263 <row>
28264 <entry><option>tls_try_verify_hosts</option></entry>
28265 <entry>Use: <emphasis>main</emphasis></entry>
28266 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
28267 <entry>Default: <emphasis>unset</emphasis></entry>
28268 </row>
28269 </tbody>
28270 </tgroup>
28271 </informaltable>
28272 <para>
28273 <indexterm role="concept">
28274 <primary>TLS</primary>
28275 <secondary>client certificate verification</secondary>
28276 </indexterm>
28277 <indexterm role="concept">
28278 <primary>certificate</primary>
28279 <secondary>verification of client</secondary>
28280 </indexterm>
28281 See <option>tls_verify_hosts</option> below.
28282 </para>
28283 <para>
28284 <indexterm role="option">
28285 <primary><option>tls_verify_certificates</option></primary>
28286 </indexterm>
28287 </para>
28288 <informaltable frame="all">
28289 <tgroup cols="4" colsep="0" rowsep="0">
28290 <colspec colwidth="8*" align="left"/>
28291 <colspec colwidth="6*" align="center"/>
28292 <colspec colwidth="6*" align="center"/>
28293 <colspec colwidth="6*" align="right"/>
28294 <tbody>
28295 <row>
28296 <entry><option>tls_verify_certificates</option></entry>
28297 <entry>Use: <emphasis>main</emphasis></entry>
28298 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28299 <entry>Default: <emphasis>unset</emphasis></entry>
28300 </row>
28301 </tbody>
28302 </tgroup>
28303 </informaltable>
28304 <para>
28305 <indexterm role="concept">
28306 <primary>TLS</primary>
28307 <secondary>client certificate verification</secondary>
28308 </indexterm>
28309 <indexterm role="concept">
28310 <primary>certificate</primary>
28311 <secondary>verification of client</secondary>
28312 </indexterm>
28313 The value of this option is expanded, and must then be the absolute path to
28314 a file containing permitted certificates for clients that
28315 match <option>tls_verify_hosts</option> or <option>tls_try_verify_hosts</option>. Alternatively, if you
28316 are using OpenSSL, you can set <option>tls_verify_certificates</option> to the name of a
28317 directory containing certificate files. This does not work with GnuTLS; the
28318 option must be set to the name of a single file if you are using GnuTLS.
28319 </para>
28320 <para>
28321 <indexterm role="option">
28322 <primary><option>tls_verify_hosts</option></primary>
28323 </indexterm>
28324 </para>
28325 <informaltable frame="all">
28326 <tgroup cols="4" colsep="0" rowsep="0">
28327 <colspec colwidth="8*" align="left"/>
28328 <colspec colwidth="6*" align="center"/>
28329 <colspec colwidth="6*" align="center"/>
28330 <colspec colwidth="6*" align="right"/>
28331 <tbody>
28332 <row>
28333 <entry><option>tls_verify_hosts</option></entry>
28334 <entry>Use: <emphasis>main</emphasis></entry>
28335 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
28336 <entry>Default: <emphasis>unset</emphasis></entry>
28337 </row>
28338 </tbody>
28339 </tgroup>
28340 </informaltable>
28341 <para>
28342 <indexterm role="concept">
28343 <primary>TLS</primary>
28344 <secondary>client certificate verification</secondary>
28345 </indexterm>
28346 <indexterm role="concept">
28347 <primary>certificate</primary>
28348 <secondary>verification of client</secondary>
28349 </indexterm>
28350 This option, along with <option>tls_try_verify_hosts</option>, controls the checking of
28351 certificates from clients. The expected certificates are defined by
28352 <option>tls_verify_certificates</option>, which must be set. A configuration error occurs if
28353 either <option>tls_verify_hosts</option> or <option>tls_try_verify_hosts</option> is set and
28354 <option>tls_verify_certificates</option> is not set.
28355 </para>
28356 <para>
28357 Any client that matches <option>tls_verify_hosts</option> is constrained by
28358 <option>tls_verify_certificates</option>. When the client initiates a TLS session, it must
28359 present one of the listed certificates. If it does not, the connection is
28360 aborted. <emphasis role="bold">Warning</emphasis>: Including a host in <option>tls_verify_hosts</option> does not require
28361 the host to use TLS. It can still send SMTP commands through unencrypted
28362 connections. Forcing a client to use TLS has to be done separately using an
28363 ACL to reject inappropriate commands when the connection is not encrypted.
28364 </para>
28365 <para>
28366 A weaker form of checking is provided by <option>tls_try_verify_hosts</option>. If a client
28367 matches this option (but not <option>tls_verify_hosts</option>), Exim requests a
28368 certificate and checks it against <option>tls_verify_certificates</option>, but does not
28369 abort the connection if there is no certificate or if it does not match. This
28370 state can be detected in an ACL, which makes it possible to implement policies
28371 such as <quote>accept for relay only if a verified certificate has been received,
28372 but accept for local delivery if encrypted, even without a verified
28373 certificate</quote>.
28374 </para>
28375 <para>
28376 Client hosts that match neither of these lists are not asked to present
28377 certificates.
28378 </para>
28379 <para>
28380 <indexterm role="option">
28381 <primary><option>trusted_groups</option></primary>
28382 </indexterm>
28383 </para>
28384 <informaltable frame="all">
28385 <tgroup cols="4" colsep="0" rowsep="0">
28386 <colspec colwidth="8*" align="left"/>
28387 <colspec colwidth="6*" align="center"/>
28388 <colspec colwidth="6*" align="center"/>
28389 <colspec colwidth="6*" align="right"/>
28390 <tbody>
28391 <row>
28392 <entry><option>trusted_groups</option></entry>
28393 <entry>Use: <emphasis>main</emphasis></entry>
28394 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
28395 <entry>Default: <emphasis>unset</emphasis></entry>
28396 </row>
28397 </tbody>
28398 </tgroup>
28399 </informaltable>
28400 <para>
28401 <indexterm role="concept">
28402 <primary>trusted groups</primary>
28403 </indexterm>
28404 <indexterm role="concept">
28405 <primary>groups</primary>
28406 <secondary>trusted</secondary>
28407 </indexterm>
28408 This option is expanded just once, at the start of Exim&#x2019;s processing. If this
28409 option is set, any process that is running in one of the listed groups, or
28410 which has one of them as a supplementary group, is trusted. The groups can be
28411 specified numerically or by name. See section <xref linkend="SECTtrustedadmin"/> for
28412 details of what trusted callers are permitted to do. If neither
28413 <option>trusted_groups</option> nor <option>trusted_users</option> is set, only root and the Exim user
28414 are trusted.
28415 </para>
28416 <para>
28417 <indexterm role="option">
28418 <primary><option>trusted_users</option></primary>
28419 </indexterm>
28420 </para>
28421 <informaltable frame="all">
28422 <tgroup cols="4" colsep="0" rowsep="0">
28423 <colspec colwidth="8*" align="left"/>
28424 <colspec colwidth="6*" align="center"/>
28425 <colspec colwidth="6*" align="center"/>
28426 <colspec colwidth="6*" align="right"/>
28427 <tbody>
28428 <row>
28429 <entry><option>trusted_users</option></entry>
28430 <entry>Use: <emphasis>main</emphasis></entry>
28431 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
28432 <entry>Default: <emphasis>unset</emphasis></entry>
28433 </row>
28434 </tbody>
28435 </tgroup>
28436 </informaltable>
28437 <para>
28438 <indexterm role="concept">
28439 <primary>trusted users</primary>
28440 </indexterm>
28441 <indexterm role="concept">
28442 <primary>user</primary>
28443 <secondary>trusted</secondary>
28444 </indexterm>
28445 This option is expanded just once, at the start of Exim&#x2019;s processing. If this
28446 option is set, any process that is running as one of the listed users is
28447 trusted. The users can be specified numerically or by name. See section
28448 <xref linkend="SECTtrustedadmin"/> for details of what trusted callers are permitted to do.
28449 If neither <option>trusted_groups</option> nor <option>trusted_users</option> is set, only root and the
28450 Exim user are trusted.
28451 </para>
28452 <para>
28453 <indexterm role="option">
28454 <primary><option>unknown_login</option></primary>
28455 </indexterm>
28456 </para>
28457 <informaltable frame="all">
28458 <tgroup cols="4" colsep="0" rowsep="0">
28459 <colspec colwidth="8*" align="left"/>
28460 <colspec colwidth="6*" align="center"/>
28461 <colspec colwidth="6*" align="center"/>
28462 <colspec colwidth="6*" align="right"/>
28463 <tbody>
28464 <row>
28465 <entry><option>unknown_login</option></entry>
28466 <entry>Use: <emphasis>main</emphasis></entry>
28467 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28468 <entry>Default: <emphasis>unset</emphasis></entry>
28469 </row>
28470 </tbody>
28471 </tgroup>
28472 </informaltable>
28473 <para>
28474 <indexterm role="concept">
28475 <primary>uid (user id)</primary>
28476 <secondary>unknown caller</secondary>
28477 </indexterm>
28478 <indexterm role="variable">
28479 <primary><varname>$caller_uid</varname></primary>
28480 </indexterm>
28481 This is a specialized feature for use in unusual configurations. By default, if
28482 the uid of the caller of Exim cannot be looked up using <function>getpwuid()</function>, Exim
28483 gives up. The <option>unknown_login</option> option can be used to set a login name to be
28484 used in this circumstance. It is expanded, so values like <option>user$caller_uid</option>
28485 can be set. When <option>unknown_login</option> is used, the value of <option>unknown_username</option>
28486 is used for the user&#x2019;s real name (gecos field), unless this has been set by the
28487 <option>-F</option> option.
28488 </para>
28489 <para>
28490 <indexterm role="option">
28491 <primary><option>unknown_username</option></primary>
28492 </indexterm>
28493 </para>
28494 <informaltable frame="all">
28495 <tgroup cols="4" colsep="0" rowsep="0">
28496 <colspec colwidth="8*" align="left"/>
28497 <colspec colwidth="6*" align="center"/>
28498 <colspec colwidth="6*" align="center"/>
28499 <colspec colwidth="6*" align="right"/>
28500 <tbody>
28501 <row>
28502 <entry><option>unknown_username</option></entry>
28503 <entry>Use: <emphasis>main</emphasis></entry>
28504 <entry>Type: <emphasis>string</emphasis></entry>
28505 <entry>Default: <emphasis>unset</emphasis></entry>
28506 </row>
28507 </tbody>
28508 </tgroup>
28509 </informaltable>
28510 <para>
28511 See <option>unknown_login</option>.
28512 </para>
28513 <para>
28514 <indexterm role="option">
28515 <primary><option>untrusted_set_sender</option></primary>
28516 </indexterm>
28517 </para>
28518 <informaltable frame="all">
28519 <tgroup cols="4" colsep="0" rowsep="0">
28520 <colspec colwidth="8*" align="left"/>
28521 <colspec colwidth="6*" align="center"/>
28522 <colspec colwidth="6*" align="center"/>
28523 <colspec colwidth="6*" align="right"/>
28524 <tbody>
28525 <row>
28526 <entry><option>untrusted_set_sender</option></entry>
28527 <entry>Use: <emphasis>main</emphasis></entry>
28528 <entry>Type: <emphasis>address list</emphasis>&dagger;<emphasis></emphasis></entry>
28529 <entry>Default: <emphasis>unset</emphasis></entry>
28530 </row>
28531 </tbody>
28532 </tgroup>
28533 </informaltable>
28534 <para>
28535 <indexterm role="concept">
28536 <primary>trusted users</primary>
28537 </indexterm>
28538 <indexterm role="concept">
28539 <primary>sender</primary>
28540 <secondary>setting by untrusted user</secondary>
28541 </indexterm>
28542 <indexterm role="concept">
28543 <primary>untrusted user setting sender</primary>
28544 </indexterm>
28545 <indexterm role="concept">
28546 <primary>user</primary>
28547 <secondary>untrusted setting sender</secondary>
28548 </indexterm>
28549 <indexterm role="concept">
28550 <primary>envelope sender</primary>
28551 </indexterm>
28552 When an untrusted user submits a message to Exim using the standard input, Exim
28553 normally creates an envelope sender address from the user&#x2019;s login and the
28554 default qualification domain. Data from the <option>-f</option> option (for setting envelope
28555 senders on non-SMTP messages) or the SMTP MAIL command (if <option>-bs</option> or <option>-bS</option>
28556 is used) is ignored.
28557 </para>
28558 <para>
28559 However, untrusted users are permitted to set an empty envelope sender address,
28560 to declare that a message should never generate any bounces. For example:
28561 </para>
28562 <literallayout class="monospaced">
28563 exim -f '&lt;&gt;' user@domain.example
28564 </literallayout>
28565 <para>
28566 <indexterm role="variable">
28567 <primary><varname>$sender_ident</varname></primary>
28568 </indexterm>
28569 The <option>untrusted_set_sender</option> option allows you to permit untrusted users to set
28570 other envelope sender addresses in a controlled way. When it is set, untrusted
28571 users are allowed to set envelope sender addresses that match any of the
28572 patterns in the list. Like all address lists, the string is expanded. The
28573 identity of the user is in <varname>$sender_ident</varname>, so you can, for example, restrict
28574 users to setting senders that start with their login ids
28575 followed by a hyphen
28576 by a setting like this:
28577 </para>
28578 <literallayout class="monospaced">
28579 untrusted_set_sender = ^$sender_ident-
28580 </literallayout>
28581 <para>
28582 If you want to allow untrusted users to set envelope sender addresses without
28583 restriction, you can use
28584 </para>
28585 <literallayout class="monospaced">
28586 untrusted_set_sender = *
28587 </literallayout>
28588 <para>
28589 The <option>untrusted_set_sender</option> option applies to all forms of local input, but
28590 only to the setting of the envelope sender. It does not permit untrusted users
28591 to use the other options which trusted user can use to override message
28592 parameters. Furthermore, it does not stop Exim from removing an existing
28593 <emphasis>Sender:</emphasis> header in the message, or from adding a <emphasis>Sender:</emphasis> header if
28594 necessary. See <option>local_sender_retain</option> and <option>local_from_check</option> for ways of
28595 overriding these actions. The handling of the <emphasis>Sender:</emphasis> header is also
28596 described in section <xref linkend="SECTthesenhea"/>.
28597 </para>
28598 <para>
28599 The log line for a message&#x2019;s arrival shows the envelope sender following
28600 <quote>&lt;=</quote>. For local messages, the user&#x2019;s login always follows, after <quote>U=</quote>. In
28601 <option>-bp</option> displays, and in the Exim monitor, if an untrusted user sets an
28602 envelope sender address, the user&#x2019;s login is shown in parentheses after the
28603 sender address.
28604 </para>
28605 <para>
28606 <indexterm role="option">
28607 <primary><option>uucp_from_pattern</option></primary>
28608 </indexterm>
28609 </para>
28610 <informaltable frame="all">
28611 <tgroup cols="4" colsep="0" rowsep="0">
28612 <colspec colwidth="8*" align="left"/>
28613 <colspec colwidth="6*" align="center"/>
28614 <colspec colwidth="6*" align="center"/>
28615 <colspec colwidth="6*" align="right"/>
28616 <tbody>
28617 <row>
28618 <entry><option>uucp_from_pattern</option></entry>
28619 <entry>Use: <emphasis>main</emphasis></entry>
28620 <entry>Type: <emphasis>string</emphasis></entry>
28621 <entry>Default: <emphasis>see below</emphasis></entry>
28622 </row>
28623 </tbody>
28624 </tgroup>
28625 </informaltable>
28626 <para>
28627 <indexterm role="concept">
28628 <primary><quote>From</quote> line</primary>
28629 </indexterm>
28630 <indexterm role="concept">
28631 <primary>UUCP</primary>
28632 <secondary><quote>From</quote> line</secondary>
28633 </indexterm>
28634 Some applications that pass messages to an MTA via a command line interface use
28635 an initial line starting with <quote>From&nbsp;</quote> to pass the envelope sender. In
28636 particular, this is used by UUCP software. Exim recognizes such a line by means
28637 of a regular expression that is set in <option>uucp_from_pattern</option>. When the pattern
28638 matches, the sender address is constructed by expanding the contents of
28639 <option>uucp_from_sender</option>, provided that the caller of Exim is a trusted user. The
28640 default pattern recognizes lines in the following two forms:
28641 </para>
28642 <literallayout class="monospaced">
28643 From ph10 Fri Jan  5 12:35 GMT 1996
28644 From ph10 Fri, 7 Jan 97 14:00:00 GMT
28645 </literallayout>
28646 <para>
28647 The pattern can be seen by running
28648 </para>
28649 <literallayout class="monospaced">
28650 exim -bP uucp_from_pattern
28651 </literallayout>
28652 <para>
28653 It checks only up to the hours and minutes, and allows for a 2-digit or 4-digit
28654 year in the second case. The first word after <quote>From&nbsp;</quote> is matched in the
28655 regular expression by a parenthesized subpattern. The default value for
28656 <option>uucp_from_sender</option> is <quote>$1</quote>, which therefore just uses this first word
28657 (<quote>ph10</quote> in the example above) as the message&#x2019;s sender. See also
28658 <option>ignore_fromline_hosts</option>.
28659 </para>
28660 <para>
28661 <indexterm role="option">
28662 <primary><option>uucp_from_sender</option></primary>
28663 </indexterm>
28664 </para>
28665 <informaltable frame="all">
28666 <tgroup cols="4" colsep="0" rowsep="0">
28667 <colspec colwidth="8*" align="left"/>
28668 <colspec colwidth="6*" align="center"/>
28669 <colspec colwidth="6*" align="center"/>
28670 <colspec colwidth="6*" align="right"/>
28671 <tbody>
28672 <row>
28673 <entry><option>uucp_from_sender</option></entry>
28674 <entry>Use: <emphasis>main</emphasis></entry>
28675 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28676 <entry>Default: <emphasis><literal>$1</literal></emphasis></entry>
28677 </row>
28678 </tbody>
28679 </tgroup>
28680 </informaltable>
28681 <para>
28682 See <option>uucp_from_pattern</option> above.
28683 </para>
28684 <para>
28685 <indexterm role="option">
28686 <primary><option>warn_message_file</option></primary>
28687 </indexterm>
28688 </para>
28689 <informaltable frame="all">
28690 <tgroup cols="4" colsep="0" rowsep="0">
28691 <colspec colwidth="8*" align="left"/>
28692 <colspec colwidth="6*" align="center"/>
28693 <colspec colwidth="6*" align="center"/>
28694 <colspec colwidth="6*" align="right"/>
28695 <tbody>
28696 <row>
28697 <entry><option>warn_message_file</option></entry>
28698 <entry>Use: <emphasis>main</emphasis></entry>
28699 <entry>Type: <emphasis>string</emphasis></entry>
28700 <entry>Default: <emphasis>unset</emphasis></entry>
28701 </row>
28702 </tbody>
28703 </tgroup>
28704 </informaltable>
28705 <para>
28706 <indexterm role="concept">
28707 <primary>warning of delay</primary>
28708 <secondary>customizing the message</secondary>
28709 </indexterm>
28710 <indexterm role="concept">
28711 <primary>customizing</primary>
28712 <secondary>warning message</secondary>
28713 </indexterm>
28714 This option defines a template file containing paragraphs of text to be used
28715 for constructing the warning message which is sent by Exim when a message has
28716 been on the queue for a specified amount of time, as specified by
28717 <option>delay_warning</option>. Details of the file&#x2019;s contents are given in chapter
28718 <xref linkend="CHAPemsgcust"/>. See also <option>bounce_message_file</option>.
28719 </para>
28720 <para>
28721 <indexterm role="option">
28722 <primary><option>write_rejectlog</option></primary>
28723 </indexterm>
28724 </para>
28725 <informaltable frame="all">
28726 <tgroup cols="4" colsep="0" rowsep="0">
28727 <colspec colwidth="8*" align="left"/>
28728 <colspec colwidth="6*" align="center"/>
28729 <colspec colwidth="6*" align="center"/>
28730 <colspec colwidth="6*" align="right"/>
28731 <tbody>
28732 <row>
28733 <entry><option>write_rejectlog</option></entry>
28734 <entry>Use: <emphasis>main</emphasis></entry>
28735 <entry>Type: <emphasis>boolean</emphasis></entry>
28736 <entry>Default: <emphasis>true</emphasis></entry>
28737 </row>
28738 </tbody>
28739 </tgroup>
28740 </informaltable>
28741 <para>
28742 <indexterm role="concept">
28743 <primary>reject log</primary>
28744 <secondary>disabling</secondary>
28745 </indexterm>
28746 If this option is set false, Exim no longer writes anything to the reject log.
28747 See chapter <xref linkend="CHAPlog"/> for details of what Exim writes to its logs.
28748 <indexterm role="concept" startref="IIDconfima" class="endofrange"/>
28749 <indexterm role="concept" startref="IIDmaiconf" class="endofrange"/>
28750 </para>
28751 </section>
28752 </chapter>
28753
28754 <chapter id="CHAProutergeneric">
28755 <title>Generic options for routers</title>
28756 <para>
28757 <indexterm role="concept" id="IIDgenoprou1" class="startofrange">
28758 <primary>options</primary>
28759 <secondary>generic; for routers</secondary>
28760 </indexterm>
28761 <indexterm role="concept" id="IIDgenoprou2" class="startofrange">
28762 <primary>generic options</primary>
28763 <secondary>router</secondary>
28764 </indexterm>
28765 This chapter describes the generic options that apply to all routers.
28766 Those that are preconditions are marked with &Dagger; in the <quote>use</quote> field.
28767 </para>
28768 <para>
28769 For a general description of how a router operates, see sections
28770 <xref linkend="SECTrunindrou"/> and <xref linkend="SECTrouprecon"/>. The latter specifies the order in
28771 which the preconditions are tested. The order of expansion of the options that
28772 provide data for a transport is: <option>errors_to</option>, <option>headers_add</option>,
28773 <option>headers_remove</option>, <option>transport</option>.
28774 </para>
28775 <para>
28776 <indexterm role="option">
28777 <primary><option>address_data</option></primary>
28778 </indexterm>
28779 </para>
28780 <informaltable frame="all">
28781 <tgroup cols="4" colsep="0" rowsep="0">
28782 <colspec colwidth="8*" align="left"/>
28783 <colspec colwidth="6*" align="center"/>
28784 <colspec colwidth="6*" align="center"/>
28785 <colspec colwidth="6*" align="right"/>
28786 <tbody>
28787 <row>
28788 <entry><option>address_data</option></entry>
28789 <entry>Use: <emphasis>routers</emphasis></entry>
28790 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28791 <entry>Default: <emphasis>unset</emphasis></entry>
28792 </row>
28793 </tbody>
28794 </tgroup>
28795 </informaltable>
28796 <para>
28797 <indexterm role="concept">
28798 <primary>router</primary>
28799 <secondary>data attached to address</secondary>
28800 </indexterm>
28801 The string is expanded just before the router is run, that is, after all the
28802 precondition tests have succeeded. If the expansion is forced to fail, the
28803 router declines, the value of <option>address_data</option> remains unchanged, and the
28804 <option>more</option> option controls what happens next. Other expansion failures cause
28805 delivery of the address to be deferred.
28806 </para>
28807 <para>
28808 <indexterm role="variable">
28809 <primary><varname>$address_data</varname></primary>
28810 </indexterm>
28811 When the expansion succeeds, the value is retained with the address, and can be
28812 accessed using the variable <varname>$address_data</varname> in the current router, subsequent
28813 routers, and the eventual transport.
28814 </para>
28815 <para>
28816 <emphasis role="bold">Warning</emphasis>: If the current or any subsequent router is a <command>redirect</command> router
28817 that runs a user&#x2019;s filter file, the contents of <varname>$address_data</varname> are accessible
28818 in the filter. This is not normally a problem, because such data is usually
28819 either not confidential or it <quote>belongs</quote> to the current user, but if you do
28820 put confidential data into <varname>$address_data</varname> you need to remember this point.
28821 </para>
28822 <para>
28823 Even if the router declines or passes, the value of <varname>$address_data</varname> remains
28824 with the address, though it can be changed by another <option>address_data</option> setting
28825 on a subsequent router. If a router generates child addresses, the value of
28826 <varname>$address_data</varname> propagates to them. This also applies to the special kind of
28827 <quote>child</quote> that is generated by a router with the <option>unseen</option> option.
28828 </para>
28829 <para>
28830 The idea of <option>address_data</option> is that you can use it to look up a lot of data
28831 for the address once, and then pick out parts of the data later. For example,
28832 you could use a single LDAP lookup to return a string of the form
28833 </para>
28834 <literallayout class="monospaced">
28835 uid=1234 gid=5678 mailbox=/mail/xyz forward=/home/xyz/.forward
28836 </literallayout>
28837 <para>
28838 In the transport you could pick out the mailbox by a setting such as
28839 </para>
28840 <literallayout class="monospaced">
28841 file = ${extract{mailbox}{$address_data}}
28842 </literallayout>
28843 <para>
28844 This makes the configuration file less messy, and also reduces the number of
28845 lookups (though Exim does cache lookups).
28846 </para>
28847 <para>
28848 <indexterm role="variable">
28849 <primary><varname>$sender_address_data</varname></primary>
28850 </indexterm>
28851 <indexterm role="variable">
28852 <primary><varname>$address_data</varname></primary>
28853 </indexterm>
28854 The <option>address_data</option> facility is also useful as a means of passing information
28855 from one router to another, and from a router to a transport. In addition, if
28856 <varname>$address_data</varname> is set by a router when verifying a recipient address from an
28857 ACL, it remains available for use in the rest of the ACL statement. After
28858 verifying a sender, the value is transferred to <varname>$sender_address_data</varname>.
28859 </para>
28860 <para>
28861 <indexterm role="option">
28862 <primary><option>address_test</option></primary>
28863 </indexterm>
28864 </para>
28865 <informaltable frame="all">
28866 <tgroup cols="4" colsep="0" rowsep="0">
28867 <colspec colwidth="8*" align="left"/>
28868 <colspec colwidth="6*" align="center"/>
28869 <colspec colwidth="6*" align="center"/>
28870 <colspec colwidth="6*" align="right"/>
28871 <tbody>
28872 <row>
28873 <entry><option>address_test</option></entry>
28874 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
28875 <entry>Type: <emphasis>boolean</emphasis></entry>
28876 <entry>Default: <emphasis>true</emphasis></entry>
28877 </row>
28878 </tbody>
28879 </tgroup>
28880 </informaltable>
28881 <para>
28882 <indexterm role="option">
28883 <primary><option>-bt</option></primary>
28884 </indexterm>
28885 <indexterm role="concept">
28886 <primary>router</primary>
28887 <secondary>skipping when address testing</secondary>
28888 </indexterm>
28889 If this option is set false, the router is skipped when routing is being tested
28890 by means of the <option>-bt</option> command line option. This can be a convenience when
28891 your first router sends messages to an external scanner, because it saves you
28892 having to set the <quote>already scanned</quote> indicator when testing real address
28893 routing.
28894 </para>
28895 <para>
28896 <indexterm role="option">
28897 <primary><option>cannot_route_message</option></primary>
28898 </indexterm>
28899 </para>
28900 <informaltable frame="all">
28901 <tgroup cols="4" colsep="0" rowsep="0">
28902 <colspec colwidth="8*" align="left"/>
28903 <colspec colwidth="6*" align="center"/>
28904 <colspec colwidth="6*" align="center"/>
28905 <colspec colwidth="6*" align="right"/>
28906 <tbody>
28907 <row>
28908 <entry><option>cannot_route_message</option></entry>
28909 <entry>Use: <emphasis>routers</emphasis></entry>
28910 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28911 <entry>Default: <emphasis>unset</emphasis></entry>
28912 </row>
28913 </tbody>
28914 </tgroup>
28915 </informaltable>
28916 <para>
28917 <indexterm role="concept">
28918 <primary>router</primary>
28919 <secondary>customizing <quote>cannot route</quote> message</secondary>
28920 </indexterm>
28921 <indexterm role="concept">
28922 <primary>customizing</primary>
28923 <secondary><quote>cannot route</quote> message</secondary>
28924 </indexterm>
28925 This option specifies a text message that is used when an address cannot be
28926 routed because Exim has run out of routers. The default message is
28927 <quote>Unrouteable address</quote>. This option is useful only on routers that have
28928 <option>more</option> set false, or on the very last router in a configuration, because the
28929 value that is used is taken from the last router that is considered. This
28930 includes a router that is skipped because its preconditions are not met, as
28931 well as a router that declines. For example, using the default configuration,
28932 you could put:
28933 </para>
28934 <literallayout class="monospaced">
28935 cannot_route_message = Remote domain not found in DNS
28936 </literallayout>
28937 <para>
28938 on the first router, which is a <command>dnslookup</command> router with <option>more</option> set false,
28939 and
28940 </para>
28941 <literallayout class="monospaced">
28942 cannot_route_message = Unknown local user
28943 </literallayout>
28944 <para>
28945 on the final router that checks for local users. If string expansion fails for
28946 this option, the default message is used. Unless the expansion failure was
28947 explicitly forced, a message about the failure is written to the main and panic
28948 logs, in addition to the normal message about the routing failure.
28949 </para>
28950 <para>
28951 <indexterm role="option">
28952 <primary><option>caseful_local_part</option></primary>
28953 </indexterm>
28954 </para>
28955 <informaltable frame="all">
28956 <tgroup cols="4" colsep="0" rowsep="0">
28957 <colspec colwidth="8*" align="left"/>
28958 <colspec colwidth="6*" align="center"/>
28959 <colspec colwidth="6*" align="center"/>
28960 <colspec colwidth="6*" align="right"/>
28961 <tbody>
28962 <row>
28963 <entry><option>caseful_local_part</option></entry>
28964 <entry>Use: <emphasis>routers</emphasis></entry>
28965 <entry>Type: <emphasis>boolean</emphasis></entry>
28966 <entry>Default: <emphasis>false</emphasis></entry>
28967 </row>
28968 </tbody>
28969 </tgroup>
28970 </informaltable>
28971 <para>
28972 <indexterm role="concept">
28973 <primary>case of local parts</primary>
28974 </indexterm>
28975 <indexterm role="concept">
28976 <primary>router</primary>
28977 <secondary>case of local parts</secondary>
28978 </indexterm>
28979 By default, routers handle the local parts of addresses in a case-insensitive
28980 manner, though the actual case is preserved for transmission with the message.
28981 If you want the case of letters to be significant in a router, you must set
28982 this option true. For individual router options that contain address or local
28983 part lists (for example, <option>local_parts</option>), case-sensitive matching can be
28984 turned on by <quote>+caseful</quote> as a list item. See section <xref linkend="SECTcasletadd"/> for
28985 more details.
28986 </para>
28987 <para>
28988 <indexterm role="variable">
28989 <primary><varname>$local_part</varname></primary>
28990 </indexterm>
28991 <indexterm role="variable">
28992 <primary><varname>$original_local_part</varname></primary>
28993 </indexterm>
28994 <indexterm role="variable">
28995 <primary><varname>$parent_local_part</varname></primary>
28996 </indexterm>
28997 The value of the <varname>$local_part</varname> variable is forced to lower case while a
28998 router is running unless <option>caseful_local_part</option> is set. When a router assigns
28999 an address to a transport, the value of <varname>$local_part</varname> when the transport runs
29000 is the same as it was in the router. Similarly, when a router generates child
29001 addresses by aliasing or forwarding, the values of <varname>$original_local_part</varname>
29002 and <varname>$parent_local_part</varname> are those that were used by the redirecting router.
29003 </para>
29004 <para>
29005 This option applies to the processing of an address by a router. When a
29006 recipient address is being processed in an ACL, there is a separate <option>control</option>
29007 modifier that can be used to specify case-sensitive processing within the ACL
29008 (see section <xref linkend="SECTcontrols"/>).
29009 </para>
29010 <para>
29011 <indexterm role="option">
29012 <primary><option>check_local_user</option></primary>
29013 </indexterm>
29014 </para>
29015 <informaltable frame="all">
29016 <tgroup cols="4" colsep="0" rowsep="0">
29017 <colspec colwidth="8*" align="left"/>
29018 <colspec colwidth="6*" align="center"/>
29019 <colspec colwidth="6*" align="center"/>
29020 <colspec colwidth="6*" align="right"/>
29021 <tbody>
29022 <row>
29023 <entry><option>check_local_user</option></entry>
29024 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29025 <entry>Type: <emphasis>boolean</emphasis></entry>
29026 <entry>Default: <emphasis>false</emphasis></entry>
29027 </row>
29028 </tbody>
29029 </tgroup>
29030 </informaltable>
29031 <para>
29032 <indexterm role="concept">
29033 <primary>local user, checking in router</primary>
29034 </indexterm>
29035 <indexterm role="concept">
29036 <primary>router</primary>
29037 <secondary>checking for local user</secondary>
29038 </indexterm>
29039 <indexterm role="concept">
29040 <primary><filename>/etc/passwd</filename></primary>
29041 </indexterm>
29042 <indexterm role="variable">
29043 <primary><varname>$home</varname></primary>
29044 </indexterm>
29045 When this option is true, Exim checks that the local part of the recipient
29046 address (with affixes removed if relevant) is the name of an account on the
29047 local system. The check is done by calling the <function>getpwnam()</function> function rather
29048 than trying to read <filename>/etc/passwd</filename> directly. This means that other methods of
29049 holding password data (such as NIS) are supported. If the local part is a local
29050 user, <varname>$home</varname> is set from the password data, and can be tested in other
29051 preconditions that are evaluated after this one (the order of evaluation is
29052 given in section <xref linkend="SECTrouprecon"/>). However, the value of <varname>$home</varname> can be
29053 overridden by <option>router_home_directory</option>. If the local part is not a local user,
29054 the router is skipped.
29055 </para>
29056 <para>
29057 If you want to check that the local part is either the name of a local user
29058 or matches something else, you cannot combine <option>check_local_user</option> with a
29059 setting of <option>local_parts</option>, because that specifies the logical <emphasis>and</emphasis> of the
29060 two conditions. However, you can use a <command>passwd</command> lookup in a <option>local_parts</option>
29061 setting to achieve this. For example:
29062 </para>
29063 <literallayout class="monospaced">
29064 local_parts = passwd;$local_part : lsearch;/etc/other/users
29065 </literallayout>
29066 <para>
29067 Note, however, that the side effects of <option>check_local_user</option> (such as setting
29068 up a home directory) do not occur when a <command>passwd</command> lookup is used in a
29069 <option>local_parts</option> (or any other) precondition.
29070 </para>
29071 <para>
29072 <indexterm role="option">
29073 <primary><option>condition</option></primary>
29074 </indexterm>
29075 </para>
29076 <informaltable frame="all">
29077 <tgroup cols="4" colsep="0" rowsep="0">
29078 <colspec colwidth="8*" align="left"/>
29079 <colspec colwidth="6*" align="center"/>
29080 <colspec colwidth="6*" align="center"/>
29081 <colspec colwidth="6*" align="right"/>
29082 <tbody>
29083 <row>
29084 <entry><option>condition</option></entry>
29085 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29086 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29087 <entry>Default: <emphasis>unset</emphasis></entry>
29088 </row>
29089 </tbody>
29090 </tgroup>
29091 </informaltable>
29092 <para>
29093 <indexterm role="concept">
29094 <primary>router</primary>
29095 <secondary>customized precondition</secondary>
29096 </indexterm>
29097 This option specifies a general precondition test that has to succeed for the
29098 router to be called. The <option>condition</option> option is the last precondition to be
29099 evaluated (see section <xref linkend="SECTrouprecon"/>). The string is expanded, and if the
29100 result is a forced failure, or an empty string, or one of the strings <quote>0</quote> or
29101 <quote>no</quote> or <quote>false</quote> (checked without regard to the case of the letters), the
29102 router is skipped, and the address is offered to the next one.
29103 </para>
29104 <para>
29105 If the result is any other value, the router is run (as this is the last
29106 precondition to be evaluated, all the other preconditions must be true).
29107 </para>
29108 <para revisionflag="changed">
29109 This option is unique in that multiple <option>condition</option> options may be present.
29110 All <option>condition</option> options must succeed.
29111 </para>
29112 <para>
29113 The <option>condition</option> option provides a means of applying custom conditions to the
29114 running of routers. Note that in the case of a simple conditional expansion,
29115 the default expansion values are exactly what is wanted. For example:
29116 </para>
29117 <literallayout class="monospaced">
29118 condition = ${if &gt;{$message_age}{600}}
29119 </literallayout>
29120 <para>
29121 Because of the default behaviour of the string expansion, this is equivalent to
29122 </para>
29123 <literallayout class="monospaced">
29124 condition = ${if &gt;{$message_age}{600}{true}{}}
29125 </literallayout>
29126 <para revisionflag="changed">
29127 A multiple condition example, which succeeds:
29128 </para>
29129 <literallayout class="monospaced" revisionflag="changed">
29130 condition = ${if &gt;{$message_age}{600}}
29131 condition = ${if !eq{${lc:$local_part}}{postmaster}}
29132 condition = foobar
29133 </literallayout>
29134 <para>
29135 If the expansion fails (other than forced failure) delivery is deferred. Some
29136 of the other precondition options are common special cases that could in fact
29137 be specified using <option>condition</option>.
29138 </para>
29139 <para>
29140 <indexterm role="option">
29141 <primary><option>debug_print</option></primary>
29142 </indexterm>
29143 </para>
29144 <informaltable frame="all">
29145 <tgroup cols="4" colsep="0" rowsep="0">
29146 <colspec colwidth="8*" align="left"/>
29147 <colspec colwidth="6*" align="center"/>
29148 <colspec colwidth="6*" align="center"/>
29149 <colspec colwidth="6*" align="right"/>
29150 <tbody>
29151 <row>
29152 <entry><option>debug_print</option></entry>
29153 <entry>Use: <emphasis>routers</emphasis></entry>
29154 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29155 <entry>Default: <emphasis>unset</emphasis></entry>
29156 </row>
29157 </tbody>
29158 </tgroup>
29159 </informaltable>
29160 <para>
29161 <indexterm role="concept">
29162 <primary>testing</primary>
29163 <secondary>variables in drivers</secondary>
29164 </indexterm>
29165 If this option is set and debugging is enabled (see the <option>-d</option> command line
29166 option), the string is expanded and included in the debugging output.
29167 If expansion of the string fails, the error message is written to the debugging
29168 output, and Exim carries on processing.
29169 This option is provided to help with checking out the values of variables and
29170 so on when debugging router configurations. For example, if a <option>condition</option>
29171 option appears not to be working, <option>debug_print</option> can be used to output the
29172 variables it references. The output happens after checks for <option>domains</option>,
29173 <option>local_parts</option>, and <option>check_local_user</option> but before any other preconditions
29174 are tested. A newline is added to the text if it does not end with one.
29175 </para>
29176 <para>
29177 <indexterm role="option">
29178 <primary><option>disable_logging</option></primary>
29179 </indexterm>
29180 </para>
29181 <informaltable frame="all">
29182 <tgroup cols="4" colsep="0" rowsep="0">
29183 <colspec colwidth="8*" align="left"/>
29184 <colspec colwidth="6*" align="center"/>
29185 <colspec colwidth="6*" align="center"/>
29186 <colspec colwidth="6*" align="right"/>
29187 <tbody>
29188 <row>
29189 <entry><option>disable_logging</option></entry>
29190 <entry>Use: <emphasis>routers</emphasis></entry>
29191 <entry>Type: <emphasis>boolean</emphasis></entry>
29192 <entry>Default: <emphasis>false</emphasis></entry>
29193 </row>
29194 </tbody>
29195 </tgroup>
29196 </informaltable>
29197 <para>
29198 If this option is set true, nothing is logged for any routing errors
29199 or for any deliveries caused by this router. You should not set this option
29200 unless you really, really know what you are doing. See also the generic
29201 transport option of the same name.
29202 </para>
29203 <para>
29204 <indexterm role="option">
29205 <primary><option>domains</option></primary>
29206 </indexterm>
29207 </para>
29208 <informaltable frame="all">
29209 <tgroup cols="4" colsep="0" rowsep="0">
29210 <colspec colwidth="8*" align="left"/>
29211 <colspec colwidth="6*" align="center"/>
29212 <colspec colwidth="6*" align="center"/>
29213 <colspec colwidth="6*" align="right"/>
29214 <tbody>
29215 <row>
29216 <entry><option>domains</option></entry>
29217 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29218 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
29219 <entry>Default: <emphasis>unset</emphasis></entry>
29220 </row>
29221 </tbody>
29222 </tgroup>
29223 </informaltable>
29224 <para>
29225 <indexterm role="concept">
29226 <primary>router</primary>
29227 <secondary>restricting to specific domains</secondary>
29228 </indexterm>
29229 <indexterm role="variable">
29230 <primary><varname>$domain_data</varname></primary>
29231 </indexterm>
29232 If this option is set, the router is skipped unless the current domain matches
29233 the list. If the match is achieved by means of a file lookup, the data that the
29234 lookup returned for the domain is placed in <varname>$domain_data</varname> for use in string
29235 expansions of the driver&#x2019;s private options. See section <xref linkend="SECTrouprecon"/> for
29236 a list of the order in which preconditions are evaluated.
29237 </para>
29238 <para>
29239 <indexterm role="option">
29240 <primary><option>driver</option></primary>
29241 </indexterm>
29242 </para>
29243 <informaltable frame="all">
29244 <tgroup cols="4" colsep="0" rowsep="0">
29245 <colspec colwidth="8*" align="left"/>
29246 <colspec colwidth="6*" align="center"/>
29247 <colspec colwidth="6*" align="center"/>
29248 <colspec colwidth="6*" align="right"/>
29249 <tbody>
29250 <row>
29251 <entry><option>driver</option></entry>
29252 <entry>Use: <emphasis>routers</emphasis></entry>
29253 <entry>Type: <emphasis>string</emphasis></entry>
29254 <entry>Default: <emphasis>unset</emphasis></entry>
29255 </row>
29256 </tbody>
29257 </tgroup>
29258 </informaltable>
29259 <para>
29260 This option must always be set. It specifies which of the available routers is
29261 to be used.
29262 </para>
29263 <para>
29264 <indexterm role="option">
29265 <primary><option>errors_to</option></primary>
29266 </indexterm>
29267 </para>
29268 <informaltable frame="all">
29269 <tgroup cols="4" colsep="0" rowsep="0">
29270 <colspec colwidth="8*" align="left"/>
29271 <colspec colwidth="6*" align="center"/>
29272 <colspec colwidth="6*" align="center"/>
29273 <colspec colwidth="6*" align="right"/>
29274 <tbody>
29275 <row>
29276 <entry><option>errors_to</option></entry>
29277 <entry>Use: <emphasis>routers</emphasis></entry>
29278 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29279 <entry>Default: <emphasis>unset</emphasis></entry>
29280 </row>
29281 </tbody>
29282 </tgroup>
29283 </informaltable>
29284 <para>
29285 <indexterm role="concept">
29286 <primary>envelope sender</primary>
29287 </indexterm>
29288 <indexterm role="concept">
29289 <primary>router</primary>
29290 <secondary>changing address for errors</secondary>
29291 </indexterm>
29292 If a router successfully handles an address, it may assign the address to a
29293 transport for delivery or it may generate child addresses. In both cases, if
29294 there is a delivery problem during later processing, the resulting bounce
29295 message is sent to the address that results from expanding this string,
29296 provided that the address verifies successfully. The <option>errors_to</option> option is
29297 expanded before <option>headers_add</option>, <option>headers_remove</option>, and <option>transport</option>.
29298 </para>
29299 <para>
29300 The <option>errors_to</option> setting associated with an address can be overridden if it
29301 subsequently passes through other routers that have their own <option>errors_to</option>
29302 settings, or if the message is delivered by a transport with a <option>return_path</option>
29303 setting.
29304 </para>
29305 <para>
29306 If <option>errors_to</option> is unset, or the expansion is forced to fail, or the result of
29307 the expansion fails to verify, the errors address associated with the incoming
29308 address is used. At top level, this is the envelope sender. A non-forced
29309 expansion failure causes delivery to be deferred.
29310 </para>
29311 <para>
29312 If an address for which <option>errors_to</option> has been set ends up being delivered over
29313 SMTP, the envelope sender for that delivery is the <option>errors_to</option> value, so that
29314 any bounces that are generated by other MTAs on the delivery route are also
29315 sent there. You can set <option>errors_to</option> to the empty string by either of these
29316 settings:
29317 </para>
29318 <literallayout class="monospaced">
29319 errors_to =
29320 errors_to = ""
29321 </literallayout>
29322 <para>
29323 An expansion item that yields an empty string has the same effect. If you do
29324 this, a locally detected delivery error for addresses processed by this router
29325 no longer gives rise to a bounce message; the error is discarded. If the
29326 address is delivered to a remote host, the return path is set to <literal>&lt;&gt;</literal>, unless
29327 overridden by the <option>return_path</option> option on the transport.
29328 </para>
29329 <para>
29330 <indexterm role="variable">
29331 <primary><varname>$address_data</varname></primary>
29332 </indexterm>
29333 If for some reason you want to discard local errors, but use a non-empty
29334 MAIL command for remote delivery, you can preserve the original return
29335 path in <varname>$address_data</varname> in the router, and reinstate it in the transport by
29336 setting <option>return_path</option>.
29337 </para>
29338 <para>
29339 The most common use of <option>errors_to</option> is to direct mailing list bounces to the
29340 manager of the list, as described in section <xref linkend="SECTmailinglists"/>, or to
29341 implement VERP (Variable Envelope Return Paths) (see section <xref linkend="SECTverp"/>).
29342 </para>
29343 <para>
29344 <indexterm role="option">
29345 <primary><option>expn</option></primary>
29346 </indexterm>
29347 </para>
29348 <informaltable frame="all">
29349 <tgroup cols="4" colsep="0" rowsep="0">
29350 <colspec colwidth="8*" align="left"/>
29351 <colspec colwidth="6*" align="center"/>
29352 <colspec colwidth="6*" align="center"/>
29353 <colspec colwidth="6*" align="right"/>
29354 <tbody>
29355 <row>
29356 <entry><option>expn</option></entry>
29357 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29358 <entry>Type: <emphasis>boolean</emphasis></entry>
29359 <entry>Default: <emphasis>true</emphasis></entry>
29360 </row>
29361 </tbody>
29362 </tgroup>
29363 </informaltable>
29364 <para>
29365 <indexterm role="concept">
29366 <primary>address</primary>
29367 <secondary>testing</secondary>
29368 </indexterm>
29369 <indexterm role="concept">
29370 <primary>testing</primary>
29371 <secondary>addresses</secondary>
29372 </indexterm>
29373 <indexterm role="concept">
29374 <primary>EXPN</primary>
29375 <secondary>router skipping</secondary>
29376 </indexterm>
29377 <indexterm role="concept">
29378 <primary>router</primary>
29379 <secondary>skipping for EXPN</secondary>
29380 </indexterm>
29381 If this option is turned off, the router is skipped when testing an address
29382 as a result of processing an SMTP EXPN command. You might, for example,
29383 want to turn it off on a router for users&#x2019; <filename>.forward</filename> files, while leaving it
29384 on for the system alias file.
29385 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
29386 are evaluated.
29387 </para>
29388 <para>
29389 The use of the SMTP EXPN command is controlled by an ACL (see chapter
29390 <xref linkend="CHAPACL"/>). When Exim is running an EXPN command, it is similar to testing
29391 an address with <option>-bt</option>. Compare VRFY, whose counterpart is <option>-bv</option>.
29392 </para>
29393 <para>
29394 <indexterm role="option">
29395 <primary><option>fail_verify</option></primary>
29396 </indexterm>
29397 </para>
29398 <informaltable frame="all">
29399 <tgroup cols="4" colsep="0" rowsep="0">
29400 <colspec colwidth="8*" align="left"/>
29401 <colspec colwidth="6*" align="center"/>
29402 <colspec colwidth="6*" align="center"/>
29403 <colspec colwidth="6*" align="right"/>
29404 <tbody>
29405 <row>
29406 <entry><option>fail_verify</option></entry>
29407 <entry>Use: <emphasis>routers</emphasis></entry>
29408 <entry>Type: <emphasis>boolean</emphasis></entry>
29409 <entry>Default: <emphasis>false</emphasis></entry>
29410 </row>
29411 </tbody>
29412 </tgroup>
29413 </informaltable>
29414 <para>
29415 <indexterm role="concept">
29416 <primary>router</primary>
29417 <secondary>forcing verification failure</secondary>
29418 </indexterm>
29419 Setting this option has the effect of setting both <option>fail_verify_sender</option> and
29420 <option>fail_verify_recipient</option> to the same value.
29421 </para>
29422 <para>
29423 <indexterm role="option">
29424 <primary><option>fail_verify_recipient</option></primary>
29425 </indexterm>
29426 </para>
29427 <informaltable frame="all">
29428 <tgroup cols="4" colsep="0" rowsep="0">
29429 <colspec colwidth="8*" align="left"/>
29430 <colspec colwidth="6*" align="center"/>
29431 <colspec colwidth="6*" align="center"/>
29432 <colspec colwidth="6*" align="right"/>
29433 <tbody>
29434 <row>
29435 <entry><option>fail_verify_recipient</option></entry>
29436 <entry>Use: <emphasis>routers</emphasis></entry>
29437 <entry>Type: <emphasis>boolean</emphasis></entry>
29438 <entry>Default: <emphasis>false</emphasis></entry>
29439 </row>
29440 </tbody>
29441 </tgroup>
29442 </informaltable>
29443 <para>
29444 If this option is true and an address is accepted by this router when
29445 verifying a recipient, verification fails.
29446 </para>
29447 <para>
29448 <indexterm role="option">
29449 <primary><option>fail_verify_sender</option></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="6*" align="center"/>
29456 <colspec colwidth="6*" align="center"/>
29457 <colspec colwidth="6*" align="right"/>
29458 <tbody>
29459 <row>
29460 <entry><option>fail_verify_sender</option></entry>
29461 <entry>Use: <emphasis>routers</emphasis></entry>
29462 <entry>Type: <emphasis>boolean</emphasis></entry>
29463 <entry>Default: <emphasis>false</emphasis></entry>
29464 </row>
29465 </tbody>
29466 </tgroup>
29467 </informaltable>
29468 <para>
29469 If this option is true and an address is accepted by this router when
29470 verifying a sender, verification fails.
29471 </para>
29472 <para>
29473 <indexterm role="option">
29474 <primary><option>fallback_hosts</option></primary>
29475 </indexterm>
29476 </para>
29477 <informaltable frame="all">
29478 <tgroup cols="4" colsep="0" rowsep="0">
29479 <colspec colwidth="8*" align="left"/>
29480 <colspec colwidth="6*" align="center"/>
29481 <colspec colwidth="6*" align="center"/>
29482 <colspec colwidth="6*" align="right"/>
29483 <tbody>
29484 <row>
29485 <entry><option>fallback_hosts</option></entry>
29486 <entry>Use: <emphasis>routers</emphasis></entry>
29487 <entry>Type: <emphasis>string list</emphasis></entry>
29488 <entry>Default: <emphasis>unset</emphasis></entry>
29489 </row>
29490 </tbody>
29491 </tgroup>
29492 </informaltable>
29493 <para>
29494 <indexterm role="concept">
29495 <primary>router</primary>
29496 <secondary>fallback hosts</secondary>
29497 </indexterm>
29498 <indexterm role="concept">
29499 <primary>fallback</primary>
29500 <secondary>hosts specified on router</secondary>
29501 </indexterm>
29502 String expansion is not applied to this option. The argument must be a
29503 colon-separated list of host names or IP addresses. The list separator can be
29504 changed (see section <xref linkend="SECTlistconstruct"/>), and a port can be specified with
29505 each name or address. In fact, the format of each item is exactly the same as
29506 defined for the list of hosts in a <command>manualroute</command> router (see section
29507 <xref linkend="SECTformatonehostitem"/>).
29508 </para>
29509 <para>
29510 If a router queues an address for a remote transport, this host list is
29511 associated with the address, and used instead of the transport&#x2019;s fallback host
29512 list. If <option>hosts_randomize</option> is set on the transport, the order of the list is
29513 randomized for each use. See the <option>fallback_hosts</option> option of the <command>smtp</command>
29514 transport for further details.
29515 </para>
29516 <para>
29517 <indexterm role="option">
29518 <primary><option>group</option></primary>
29519 </indexterm>
29520 </para>
29521 <informaltable frame="all">
29522 <tgroup cols="4" colsep="0" rowsep="0">
29523 <colspec colwidth="8*" align="left"/>
29524 <colspec colwidth="6*" align="center"/>
29525 <colspec colwidth="6*" align="center"/>
29526 <colspec colwidth="6*" align="right"/>
29527 <tbody>
29528 <row>
29529 <entry><option>group</option></entry>
29530 <entry>Use: <emphasis>routers</emphasis></entry>
29531 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29532 <entry>Default: <emphasis>see below</emphasis></entry>
29533 </row>
29534 </tbody>
29535 </tgroup>
29536 </informaltable>
29537 <para>
29538 <indexterm role="concept">
29539 <primary>gid (group id)</primary>
29540 <secondary>local delivery</secondary>
29541 </indexterm>
29542 <indexterm role="concept">
29543 <primary>local transports</primary>
29544 <secondary>uid and gid</secondary>
29545 </indexterm>
29546 <indexterm role="concept">
29547 <primary>transport</primary>
29548 <secondary>local</secondary>
29549 </indexterm>
29550 <indexterm role="concept">
29551 <primary>router</primary>
29552 <secondary>setting group</secondary>
29553 </indexterm>
29554 When a router queues an address for a transport, and the transport does not
29555 specify a group, the group given here is used when running the delivery
29556 process.
29557 The group may be specified numerically or by name. If expansion fails, the
29558 error is logged and delivery is deferred.
29559 The default is unset, unless <option>check_local_user</option> is set, when the default
29560 is taken from the password information. See also <option>initgroups</option> and <option>user</option>
29561 and the discussion in chapter <xref linkend="CHAPenvironment"/>.
29562 </para>
29563 <para>
29564 <indexterm role="option">
29565 <primary><option>headers_add</option></primary>
29566 </indexterm>
29567 </para>
29568 <informaltable frame="all">
29569 <tgroup cols="4" colsep="0" rowsep="0">
29570 <colspec colwidth="8*" align="left"/>
29571 <colspec colwidth="6*" align="center"/>
29572 <colspec colwidth="6*" align="center"/>
29573 <colspec colwidth="6*" align="right"/>
29574 <tbody>
29575 <row>
29576 <entry><option>headers_add</option></entry>
29577 <entry>Use: <emphasis>routers</emphasis></entry>
29578 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29579 <entry>Default: <emphasis>unset</emphasis></entry>
29580 </row>
29581 </tbody>
29582 </tgroup>
29583 </informaltable>
29584 <para>
29585 <indexterm role="concept">
29586 <primary>header lines</primary>
29587 <secondary>adding</secondary>
29588 </indexterm>
29589 <indexterm role="concept">
29590 <primary>router</primary>
29591 <secondary>adding header lines</secondary>
29592 </indexterm>
29593 This option specifies a string of text that is expanded at routing time, and
29594 associated with any addresses that are accepted by the router. However, this
29595 option has no effect when an address is just being verified. The way in which
29596 the text is used to add header lines at transport time is described in section
29597 <xref linkend="SECTheadersaddrem"/>. New header lines are not actually added until the
29598 message is in the process of being transported. This means that references to
29599 header lines in string expansions in the transport&#x2019;s configuration do not
29600 <quote>see</quote> the added header lines.
29601 </para>
29602 <para>
29603 The <option>headers_add</option> option is expanded after <option>errors_to</option>, but before
29604 <option>headers_remove</option> and <option>transport</option>. If the expanded string is empty, or if
29605 the expansion is forced to fail, the option has no effect. Other expansion
29606 failures are treated as configuration errors.
29607 </para>
29608 <para>
29609 <emphasis role="bold">Warning 1</emphasis>: The <option>headers_add</option> option cannot be used for a <command>redirect</command>
29610 router that has the <option>one_time</option> option set.
29611 </para>
29612 <para>
29613 <indexterm role="concept">
29614 <primary>duplicate addresses</primary>
29615 </indexterm>
29616 <indexterm role="option">
29617 <primary><option>unseen</option></primary>
29618 </indexterm>
29619 <emphasis role="bold">Warning 2</emphasis>: If the <option>unseen</option> option is set on the router, all header
29620 additions are deleted when the address is passed on to subsequent routers.
29621 For a <option>redirect</option> router, if a generated address is the same as the incoming
29622 address, this can lead to duplicate addresses with different header
29623 modifications. Exim does not do duplicate deliveries (except, in certain
29624 circumstances, to pipes -- see section <xref linkend="SECTdupaddr"/>), but it is undefined
29625 which of the duplicates is discarded, so this ambiguous situation should be
29626 avoided. The <option>repeat_use</option> option of the <option>redirect</option> router may be of help.
29627 </para>
29628 <para>
29629 <indexterm role="option">
29630 <primary><option>headers_remove</option></primary>
29631 </indexterm>
29632 </para>
29633 <informaltable frame="all">
29634 <tgroup cols="4" colsep="0" rowsep="0">
29635 <colspec colwidth="8*" align="left"/>
29636 <colspec colwidth="6*" align="center"/>
29637 <colspec colwidth="6*" align="center"/>
29638 <colspec colwidth="6*" align="right"/>
29639 <tbody>
29640 <row>
29641 <entry><option>headers_remove</option></entry>
29642 <entry>Use: <emphasis>routers</emphasis></entry>
29643 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29644 <entry>Default: <emphasis>unset</emphasis></entry>
29645 </row>
29646 </tbody>
29647 </tgroup>
29648 </informaltable>
29649 <para>
29650 <indexterm role="concept">
29651 <primary>header lines</primary>
29652 <secondary>removing</secondary>
29653 </indexterm>
29654 <indexterm role="concept">
29655 <primary>router</primary>
29656 <secondary>removing header lines</secondary>
29657 </indexterm>
29658 This option specifies a string of text that is expanded at routing time, and
29659 associated with any addresses that are accepted by the router. However, this
29660 option has no effect when an address is just being verified. The way in which
29661 the text is used to remove header lines at transport time is described in
29662 section <xref linkend="SECTheadersaddrem"/>. Header lines are not actually removed until
29663 the message is in the process of being transported. This means that references
29664 to header lines in string expansions in the transport&#x2019;s configuration still
29665 <quote>see</quote> the original header lines.
29666 </para>
29667 <para>
29668 The <option>headers_remove</option> option is expanded after <option>errors_to</option> and
29669 <option>headers_add</option>, but before <option>transport</option>. If the expansion is forced to fail,
29670 the option has no effect. Other expansion failures are treated as configuration
29671 errors.
29672 </para>
29673 <para>
29674 <emphasis role="bold">Warning 1</emphasis>: The <option>headers_remove</option> option cannot be used for a <command>redirect</command>
29675 router that has the <option>one_time</option> option set.
29676 </para>
29677 <para>
29678 <emphasis role="bold">Warning 2</emphasis>: If the <option>unseen</option> option is set on the router, all header
29679 removal requests are deleted when the address is passed on to subsequent
29680 routers, and this can lead to problems with duplicates -- see the similar
29681 warning for <option>headers_add</option> above.
29682 </para>
29683 <para>
29684 <indexterm role="option">
29685 <primary><option>ignore_target_hosts</option></primary>
29686 </indexterm>
29687 </para>
29688 <informaltable frame="all">
29689 <tgroup cols="4" colsep="0" rowsep="0">
29690 <colspec colwidth="8*" align="left"/>
29691 <colspec colwidth="6*" align="center"/>
29692 <colspec colwidth="6*" align="center"/>
29693 <colspec colwidth="6*" align="right"/>
29694 <tbody>
29695 <row>
29696 <entry><option>ignore_target_hosts</option></entry>
29697 <entry>Use: <emphasis>routers</emphasis></entry>
29698 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
29699 <entry>Default: <emphasis>unset</emphasis></entry>
29700 </row>
29701 </tbody>
29702 </tgroup>
29703 </informaltable>
29704 <para>
29705 <indexterm role="concept">
29706 <primary>IP address</primary>
29707 <secondary>discarding</secondary>
29708 </indexterm>
29709 <indexterm role="concept">
29710 <primary>router</primary>
29711 <secondary>discarding IP addresses</secondary>
29712 </indexterm>
29713 Although this option is a host list, it should normally contain IP address
29714 entries rather than names. If any host that is looked up by the router has an
29715 IP address that matches an item in this list, Exim behaves as if that IP
29716 address did not exist. This option allows you to cope with rogue DNS entries
29717 like
29718 </para>
29719 <literallayout class="monospaced">
29720 remote.domain.example.  A  127.0.0.1
29721 </literallayout>
29722 <para>
29723 by setting
29724 </para>
29725 <literallayout class="monospaced">
29726 ignore_target_hosts = 127.0.0.1
29727 </literallayout>
29728 <para>
29729 on the relevant router. If all the hosts found by a <command>dnslookup</command> router are
29730 discarded in this way, the router declines. In a conventional configuration, an
29731 attempt to mail to such a domain would normally provoke the <quote>unrouteable
29732 domain</quote> error, and an attempt to verify an address in the domain would fail.
29733 Similarly, if <option>ignore_target_hosts</option> is set on an <command>ipliteral</command> router, the
29734 router declines if presented with one of the listed addresses.
29735 </para>
29736 <para>
29737 You can use this option to disable the use of IPv4 or IPv6 for mail delivery by
29738 means of the first or the second of the following settings, respectively:
29739 </para>
29740 <literallayout class="monospaced">
29741 ignore_target_hosts = 0.0.0.0/0
29742 ignore_target_hosts = &lt;; 0::0/0
29743 </literallayout>
29744 <para>
29745 The pattern in the first line matches all IPv4 addresses, whereas the pattern
29746 in the second line matches all IPv6 addresses.
29747 </para>
29748 <para>
29749 This option may also be useful for ignoring link-local and site-local IPv6
29750 addresses. Because, like all host lists, the value of <option>ignore_target_hosts</option>
29751 is expanded before use as a list, it is possible to make it dependent on the
29752 domain that is being routed.
29753 </para>
29754 <para>
29755 <indexterm role="variable">
29756 <primary><varname>$host_address</varname></primary>
29757 </indexterm>
29758 During its expansion, <varname>$host_address</varname> is set to the IP address that is being
29759 checked.
29760 </para>
29761 <para>
29762 <indexterm role="option">
29763 <primary><option>initgroups</option></primary>
29764 </indexterm>
29765 </para>
29766 <informaltable frame="all">
29767 <tgroup cols="4" colsep="0" rowsep="0">
29768 <colspec colwidth="8*" align="left"/>
29769 <colspec colwidth="6*" align="center"/>
29770 <colspec colwidth="6*" align="center"/>
29771 <colspec colwidth="6*" align="right"/>
29772 <tbody>
29773 <row>
29774 <entry><option>initgroups</option></entry>
29775 <entry>Use: <emphasis>routers</emphasis></entry>
29776 <entry>Type: <emphasis>boolean</emphasis></entry>
29777 <entry>Default: <emphasis>false</emphasis></entry>
29778 </row>
29779 </tbody>
29780 </tgroup>
29781 </informaltable>
29782 <para>
29783 <indexterm role="concept">
29784 <primary>additional groups</primary>
29785 </indexterm>
29786 <indexterm role="concept">
29787 <primary>groups</primary>
29788 <secondary>additional</secondary>
29789 </indexterm>
29790 <indexterm role="concept">
29791 <primary>local transports</primary>
29792 <secondary>uid and gid</secondary>
29793 </indexterm>
29794 <indexterm role="concept">
29795 <primary>transport</primary>
29796 <secondary>local</secondary>
29797 </indexterm>
29798 If the router queues an address for a transport, and this option is true, and
29799 the uid supplied by the router is not overridden by the transport, the
29800 <function>initgroups()</function> function is called when running the transport to ensure that
29801 any additional groups associated with the uid are set up. See also <option>group</option>
29802 and <option>user</option> and the discussion in chapter <xref linkend="CHAPenvironment"/>.
29803 </para>
29804 <para>
29805 <indexterm role="option">
29806 <primary><option>local_part_prefix</option></primary>
29807 </indexterm>
29808 </para>
29809 <informaltable frame="all">
29810 <tgroup cols="4" colsep="0" rowsep="0">
29811 <colspec colwidth="8*" align="left"/>
29812 <colspec colwidth="6*" align="center"/>
29813 <colspec colwidth="6*" align="center"/>
29814 <colspec colwidth="6*" align="right"/>
29815 <tbody>
29816 <row>
29817 <entry><option>local_part_prefix</option></entry>
29818 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29819 <entry>Type: <emphasis>string list</emphasis></entry>
29820 <entry>Default: <emphasis>unset</emphasis></entry>
29821 </row>
29822 </tbody>
29823 </tgroup>
29824 </informaltable>
29825 <para>
29826 <indexterm role="concept">
29827 <primary>router</primary>
29828 <secondary>prefix for local part</secondary>
29829 </indexterm>
29830 <indexterm role="concept">
29831 <primary>prefix</primary>
29832 <secondary>for local part, used in router</secondary>
29833 </indexterm>
29834 If this option is set, the router is skipped unless the local part starts with
29835 one of the given strings, or <option>local_part_prefix_optional</option> is true. See
29836 section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions are
29837 evaluated.
29838 </para>
29839 <para>
29840 The list is scanned from left to right, and the first prefix that matches is
29841 used. A limited form of wildcard is available; if the prefix begins with an
29842 asterisk, it matches the longest possible sequence of arbitrary characters at
29843 the start of the local part. An asterisk should therefore always be followed by
29844 some character that does not occur in normal local parts.
29845 <indexterm role="concept">
29846 <primary>multiple mailboxes</primary>
29847 </indexterm>
29848 <indexterm role="concept">
29849 <primary>mailbox</primary>
29850 <secondary>multiple</secondary>
29851 </indexterm>
29852 Wildcarding can be used to set up multiple user mailboxes, as described in
29853 section <xref linkend="SECTmulbox"/>.
29854 </para>
29855 <para>
29856 <indexterm role="variable">
29857 <primary><varname>$local_part</varname></primary>
29858 </indexterm>
29859 <indexterm role="variable">
29860 <primary><varname>$local_part_prefix</varname></primary>
29861 </indexterm>
29862 During the testing of the <option>local_parts</option> option, and while the router is
29863 running, the prefix is removed from the local part, and is available in the
29864 expansion variable <varname>$local_part_prefix</varname>. When a message is being delivered, if
29865 the router accepts the address, this remains true during subsequent delivery by
29866 a transport. In particular, the local part that is transmitted in the RCPT
29867 command for LMTP, SMTP, and BSMTP deliveries has the prefix removed by default.
29868 This behaviour can be overridden by setting <option>rcpt_include_affixes</option> true on
29869 the relevant transport.
29870 </para>
29871 <para>
29872 When an address is being verified, <option>local_part_prefix</option> affects only the
29873 behaviour of the router. If the callout feature of verification is in use, this
29874 means that the full address, including the prefix, will be used during the
29875 callout.
29876 </para>
29877 <para>
29878 The prefix facility is commonly used to handle local parts of the form
29879 <option>owner-something</option>. Another common use is to support local parts of the form
29880 <option>real-username</option> to bypass a user&#x2019;s <filename>.forward</filename> file &ndash; helpful when trying
29881 to tell a user their forwarding is broken &ndash; by placing a router like this one
29882 immediately before the router that handles <filename>.forward</filename> files:
29883 </para>
29884 <literallayout class="monospaced">
29885 real_localuser:
29886   driver = accept
29887   local_part_prefix = real-
29888   check_local_user
29889   transport = local_delivery
29890 </literallayout>
29891 <para>
29892 For security, it would probably be a good idea to restrict the use of this
29893 router to locally-generated messages, using a condition such as this:
29894 </para>
29895 <literallayout class="monospaced">
29896   condition = ${if match {$sender_host_address}\
29897                          {\N^(|127\.0\.0\.1)$\N}}
29898 </literallayout>
29899 <para>
29900 If both <option>local_part_prefix</option> and <option>local_part_suffix</option> are set for a router,
29901 both conditions must be met if not optional. Care must be taken if wildcards
29902 are used in both a prefix and a suffix on the same router. Different
29903 separator characters must be used to avoid ambiguity.
29904 </para>
29905 <para>
29906 <indexterm role="option">
29907 <primary><option>local_part_prefix_optional</option></primary>
29908 </indexterm>
29909 </para>
29910 <informaltable frame="all">
29911 <tgroup cols="4" colsep="0" rowsep="0">
29912 <colspec colwidth="8*" align="left"/>
29913 <colspec colwidth="6*" align="center"/>
29914 <colspec colwidth="6*" align="center"/>
29915 <colspec colwidth="6*" align="right"/>
29916 <tbody>
29917 <row>
29918 <entry><option>local_part_prefix_optional</option></entry>
29919 <entry>Use: <emphasis>routers</emphasis></entry>
29920 <entry>Type: <emphasis>boolean</emphasis></entry>
29921 <entry>Default: <emphasis>false</emphasis></entry>
29922 </row>
29923 </tbody>
29924 </tgroup>
29925 </informaltable>
29926 <para>
29927 See <option>local_part_prefix</option> above.
29928 </para>
29929 <para>
29930 <indexterm role="option">
29931 <primary><option>local_part_suffix</option></primary>
29932 </indexterm>
29933 </para>
29934 <informaltable frame="all">
29935 <tgroup cols="4" colsep="0" rowsep="0">
29936 <colspec colwidth="8*" align="left"/>
29937 <colspec colwidth="6*" align="center"/>
29938 <colspec colwidth="6*" align="center"/>
29939 <colspec colwidth="6*" align="right"/>
29940 <tbody>
29941 <row>
29942 <entry><option>local_part_suffix</option></entry>
29943 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29944 <entry>Type: <emphasis>string list</emphasis></entry>
29945 <entry>Default: <emphasis>unset</emphasis></entry>
29946 </row>
29947 </tbody>
29948 </tgroup>
29949 </informaltable>
29950 <para>
29951 <indexterm role="concept">
29952 <primary>router</primary>
29953 <secondary>suffix for local part</secondary>
29954 </indexterm>
29955 <indexterm role="concept">
29956 <primary>suffix for local part</primary>
29957 <secondary>used in router</secondary>
29958 </indexterm>
29959 This option operates in the same way as <option>local_part_prefix</option>, except that the
29960 local part must end (rather than start) with the given string, the
29961 <option>local_part_suffix_optional</option> option determines whether the suffix is
29962 mandatory, and the wildcard * character, if present, must be the last
29963 character of the suffix. This option facility is commonly used to handle local
29964 parts of the form <option>something-request</option> and multiple user mailboxes of the form
29965 <option>username-foo</option>.
29966 </para>
29967 <para>
29968 <indexterm role="option">
29969 <primary><option>local_part_suffix_optional</option></primary>
29970 </indexterm>
29971 </para>
29972 <informaltable frame="all">
29973 <tgroup cols="4" colsep="0" rowsep="0">
29974 <colspec colwidth="8*" align="left"/>
29975 <colspec colwidth="6*" align="center"/>
29976 <colspec colwidth="6*" align="center"/>
29977 <colspec colwidth="6*" align="right"/>
29978 <tbody>
29979 <row>
29980 <entry><option>local_part_suffix_optional</option></entry>
29981 <entry>Use: <emphasis>routers</emphasis></entry>
29982 <entry>Type: <emphasis>boolean</emphasis></entry>
29983 <entry>Default: <emphasis>false</emphasis></entry>
29984 </row>
29985 </tbody>
29986 </tgroup>
29987 </informaltable>
29988 <para>
29989 See <option>local_part_suffix</option> above.
29990 </para>
29991 <para>
29992 <indexterm role="option">
29993 <primary><option>local_parts</option></primary>
29994 </indexterm>
29995 </para>
29996 <informaltable frame="all">
29997 <tgroup cols="4" colsep="0" rowsep="0">
29998 <colspec colwidth="8*" align="left"/>
29999 <colspec colwidth="6*" align="center"/>
30000 <colspec colwidth="6*" align="center"/>
30001 <colspec colwidth="6*" align="right"/>
30002 <tbody>
30003 <row>
30004 <entry><option>local_parts</option></entry>
30005 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
30006 <entry>Type: <emphasis>local part list</emphasis>&dagger;<emphasis></emphasis></entry>
30007 <entry>Default: <emphasis>unset</emphasis></entry>
30008 </row>
30009 </tbody>
30010 </tgroup>
30011 </informaltable>
30012 <para>
30013 <indexterm role="concept">
30014 <primary>router</primary>
30015 <secondary>restricting to specific local parts</secondary>
30016 </indexterm>
30017 <indexterm role="concept">
30018 <primary>local part</primary>
30019 <secondary>checking in router</secondary>
30020 </indexterm>
30021 The router is run only if the local part of the address matches the list.
30022 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
30023 are evaluated, and
30024 section <xref linkend="SECTlocparlis"/> for a discussion of local part lists. Because the
30025 string is expanded, it is possible to make it depend on the domain, for
30026 example:
30027 </para>
30028 <literallayout class="monospaced">
30029 local_parts = dbm;/usr/local/specials/$domain
30030 </literallayout>
30031 <para>
30032 <indexterm role="variable">
30033 <primary><varname>$local_part_data</varname></primary>
30034 </indexterm>
30035 If the match is achieved by a lookup, the data that the lookup returned
30036 for the local part is placed in the variable <varname>$local_part_data</varname> for use in
30037 expansions of the router&#x2019;s private options. You might use this option, for
30038 example, if you have a large number of local virtual domains, and you want to
30039 send all postmaster mail to the same place without having to set up an alias in
30040 each virtual domain:
30041 </para>
30042 <literallayout class="monospaced">
30043 postmaster:
30044   driver = redirect
30045   local_parts = postmaster
30046   data = postmaster@real.domain.example
30047 </literallayout>
30048 <para>
30049 <indexterm role="option">
30050 <primary><option>log_as_local</option></primary>
30051 </indexterm>
30052 </para>
30053 <informaltable frame="all">
30054 <tgroup cols="4" colsep="0" rowsep="0">
30055 <colspec colwidth="8*" align="left"/>
30056 <colspec colwidth="6*" align="center"/>
30057 <colspec colwidth="6*" align="center"/>
30058 <colspec colwidth="6*" align="right"/>
30059 <tbody>
30060 <row>
30061 <entry><option>log_as_local</option></entry>
30062 <entry>Use: <emphasis>routers</emphasis></entry>
30063 <entry>Type: <emphasis>boolean</emphasis></entry>
30064 <entry>Default: <emphasis>see below</emphasis></entry>
30065 </row>
30066 </tbody>
30067 </tgroup>
30068 </informaltable>
30069 <para>
30070 <indexterm role="concept">
30071 <primary>log</primary>
30072 <secondary>delivery line</secondary>
30073 </indexterm>
30074 <indexterm role="concept">
30075 <primary>delivery</primary>
30076 <secondary>log line format</secondary>
30077 </indexterm>
30078 Exim has two logging styles for delivery, the idea being to make local
30079 deliveries stand out more visibly from remote ones. In the <quote>local</quote> style, the
30080 recipient address is given just as the local part, without a domain. The use of
30081 this style is controlled by this option. It defaults to true for the <command>accept</command>
30082 router, and false for all the others. This option applies only when a
30083 router assigns an address to a transport. It has no effect on routers that
30084 redirect addresses.
30085 </para>
30086 <para>
30087 <indexterm role="option">
30088 <primary><option>more</option></primary>
30089 </indexterm>
30090 </para>
30091 <informaltable frame="all">
30092 <tgroup cols="4" colsep="0" rowsep="0">
30093 <colspec colwidth="8*" align="left"/>
30094 <colspec colwidth="6*" align="center"/>
30095 <colspec colwidth="6*" align="center"/>
30096 <colspec colwidth="6*" align="right"/>
30097 <tbody>
30098 <row>
30099 <entry><option>more</option></entry>
30100 <entry>Use: <emphasis>routers</emphasis></entry>
30101 <entry>Type: <emphasis>boolean</emphasis>&dagger;<emphasis></emphasis></entry>
30102 <entry>Default: <emphasis>true</emphasis></entry>
30103 </row>
30104 </tbody>
30105 </tgroup>
30106 </informaltable>
30107 <para>
30108 The result of string expansion for this option must be a valid boolean value,
30109 that is, one of the strings <quote>yes</quote>, <quote>no</quote>, <quote>true</quote>, or <quote>false</quote>. Any other
30110 result causes an error, and delivery is deferred. If the expansion is forced to
30111 fail, the default value for the option (true) is used. Other failures cause
30112 delivery to be deferred.
30113 </para>
30114 <para>
30115 If this option is set false, and the router declines to handle the address, no
30116 further routers are tried, routing fails, and the address is bounced.
30117 <indexterm role="option">
30118 <primary><option>self</option></primary>
30119 </indexterm>
30120 However, if the router explicitly passes an address to the following router by
30121 means of the setting
30122 </para>
30123 <literallayout class="monospaced">
30124 self = pass
30125 </literallayout>
30126 <para>
30127 or otherwise, the setting of <option>more</option> is ignored. Also, the setting of <option>more</option>
30128 does not affect the behaviour if one of the precondition tests fails. In that
30129 case, the address is always passed to the next router.
30130 </para>
30131 <para>
30132 Note that <option>address_data</option> is not considered to be a precondition. If its
30133 expansion is forced to fail, the router declines, and the value of <option>more</option>
30134 controls what happens next.
30135 </para>
30136 <para>
30137 <indexterm role="option">
30138 <primary><option>pass_on_timeout</option></primary>
30139 </indexterm>
30140 </para>
30141 <informaltable frame="all">
30142 <tgroup cols="4" colsep="0" rowsep="0">
30143 <colspec colwidth="8*" align="left"/>
30144 <colspec colwidth="6*" align="center"/>
30145 <colspec colwidth="6*" align="center"/>
30146 <colspec colwidth="6*" align="right"/>
30147 <tbody>
30148 <row>
30149 <entry><option>pass_on_timeout</option></entry>
30150 <entry>Use: <emphasis>routers</emphasis></entry>
30151 <entry>Type: <emphasis>boolean</emphasis></entry>
30152 <entry>Default: <emphasis>false</emphasis></entry>
30153 </row>
30154 </tbody>
30155 </tgroup>
30156 </informaltable>
30157 <para>
30158 <indexterm role="concept">
30159 <primary>timeout</primary>
30160 <secondary>of router</secondary>
30161 </indexterm>
30162 <indexterm role="concept">
30163 <primary>router</primary>
30164 <secondary>timeout</secondary>
30165 </indexterm>
30166 If a router times out during a host lookup, it normally causes deferral of the
30167 address. If <option>pass_on_timeout</option> is set, the address is passed on to the next
30168 router, overriding <option>no_more</option>. This may be helpful for systems that are
30169 intermittently connected to the Internet, or those that want to pass to a smart
30170 host any messages that cannot immediately be delivered.
30171 </para>
30172 <para>
30173 There are occasional other temporary errors that can occur while doing DNS
30174 lookups. They are treated in the same way as a timeout, and this option
30175 applies to all of them.
30176 </para>
30177 <para>
30178 <indexterm role="option">
30179 <primary><option>pass_router</option></primary>
30180 </indexterm>
30181 </para>
30182 <informaltable frame="all">
30183 <tgroup cols="4" colsep="0" rowsep="0">
30184 <colspec colwidth="8*" align="left"/>
30185 <colspec colwidth="6*" align="center"/>
30186 <colspec colwidth="6*" align="center"/>
30187 <colspec colwidth="6*" align="right"/>
30188 <tbody>
30189 <row>
30190 <entry><option>pass_router</option></entry>
30191 <entry>Use: <emphasis>routers</emphasis></entry>
30192 <entry>Type: <emphasis>string</emphasis></entry>
30193 <entry>Default: <emphasis>unset</emphasis></entry>
30194 </row>
30195 </tbody>
30196 </tgroup>
30197 </informaltable>
30198 <para>
30199 <indexterm role="concept">
30200 <primary>router</primary>
30201 <secondary>go to after <quote>pass</quote></secondary>
30202 </indexterm>
30203 Routers that recognize the generic <option>self</option> option (<command>dnslookup</command>,
30204 <command>ipliteral</command>, and <command>manualroute</command>) are able to return <quote>pass</quote>, forcing
30205 routing to continue, and overriding a false setting of <option>more</option>. When one of
30206 these routers returns <quote>pass</quote>, the address is normally handed on to the next
30207 router in sequence. This can be changed by setting <option>pass_router</option> to the name
30208 of another router. However (unlike <option>redirect_router</option>) the named router must
30209 be below the current router, to avoid loops. Note that this option applies only
30210 to the special case of <quote>pass</quote>. It does not apply when a router returns
30211 <quote>decline</quote> because it cannot handle an address.
30212 </para>
30213 <para>
30214 <indexterm role="option">
30215 <primary><option>redirect_router</option></primary>
30216 </indexterm>
30217 </para>
30218 <informaltable frame="all">
30219 <tgroup cols="4" colsep="0" rowsep="0">
30220 <colspec colwidth="8*" align="left"/>
30221 <colspec colwidth="6*" align="center"/>
30222 <colspec colwidth="6*" align="center"/>
30223 <colspec colwidth="6*" align="right"/>
30224 <tbody>
30225 <row>
30226 <entry><option>redirect_router</option></entry>
30227 <entry>Use: <emphasis>routers</emphasis></entry>
30228 <entry>Type: <emphasis>string</emphasis></entry>
30229 <entry>Default: <emphasis>unset</emphasis></entry>
30230 </row>
30231 </tbody>
30232 </tgroup>
30233 </informaltable>
30234 <para>
30235 <indexterm role="concept">
30236 <primary>router</primary>
30237 <secondary>start at after redirection</secondary>
30238 </indexterm>
30239 Sometimes an administrator knows that it is pointless to reprocess addresses
30240 generated from alias or forward files with the same router again. For
30241 example, if an alias file translates real names into login ids there is no
30242 point searching the alias file a second time, especially if it is a large file.
30243 </para>
30244 <para>
30245 The <option>redirect_router</option> option can be set to the name of any router instance.
30246 It causes the routing of any generated addresses to start at the named router
30247 instead of at the first router. This option has no effect if the router in
30248 which it is set does not generate new addresses.
30249 </para>
30250 <para>
30251 <indexterm role="option">
30252 <primary><option>require_files</option></primary>
30253 </indexterm>
30254 </para>
30255 <informaltable frame="all">
30256 <tgroup cols="4" colsep="0" rowsep="0">
30257 <colspec colwidth="8*" align="left"/>
30258 <colspec colwidth="6*" align="center"/>
30259 <colspec colwidth="6*" align="center"/>
30260 <colspec colwidth="6*" align="right"/>
30261 <tbody>
30262 <row>
30263 <entry><option>require_files</option></entry>
30264 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
30265 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
30266 <entry>Default: <emphasis>unset</emphasis></entry>
30267 </row>
30268 </tbody>
30269 </tgroup>
30270 </informaltable>
30271 <para>
30272 <indexterm role="concept">
30273 <primary>file</primary>
30274 <secondary>requiring for router</secondary>
30275 </indexterm>
30276 <indexterm role="concept">
30277 <primary>router</primary>
30278 <secondary>requiring file existence</secondary>
30279 </indexterm>
30280 This option provides a general mechanism for predicating the running of a
30281 router on the existence or non-existence of certain files or directories.
30282 Before running a router, as one of its precondition tests, Exim works its way
30283 through the <option>require_files</option> list, expanding each item separately.
30284 </para>
30285 <para>
30286 Because the list is split before expansion, any colons in expansion items must
30287 be doubled, or the facility for using a different list separator must be used.
30288 If any expansion is forced to fail, the item is ignored. Other expansion
30289 failures cause routing of the address to be deferred.
30290 </para>
30291 <para>
30292 If any expanded string is empty, it is ignored. Otherwise, except as described
30293 below, each string must be a fully qualified file path, optionally preceded by
30294 <quote>!</quote>. The paths are passed to the <function>stat()</function> function to test for the
30295 existence of the files or directories. The router is skipped if any paths not
30296 preceded by <quote>!</quote> do not exist, or if any paths preceded by <quote>!</quote> do exist.
30297 </para>
30298 <para>
30299 <indexterm role="concept">
30300 <primary>NFS</primary>
30301 </indexterm>
30302 If <function>stat()</function> cannot determine whether a file exists or not, delivery of
30303 the message is deferred. This can happen when NFS-mounted filesystems are
30304 unavailable.
30305 </para>
30306 <para>
30307 This option is checked after the <option>domains</option>, <option>local_parts</option>, and <option>senders</option>
30308 options, so you cannot use it to check for the existence of a file in which to
30309 look up a domain, local part, or sender. (See section <xref linkend="SECTrouprecon"/> for a
30310 full list of the order in which preconditions are evaluated.) However, as
30311 these options are all expanded, you can use the <option>exists</option> expansion condition
30312 to make such tests. The <option>require_files</option> option is intended for checking files
30313 that the router may be going to use internally, or which are needed by a
30314 transport (for example <filename>.procmailrc</filename>).
30315 </para>
30316 <para>
30317 During delivery, the <function>stat()</function> function is run as root, but there is a
30318 facility for some checking of the accessibility of a file by another user.
30319 This is not a proper permissions check, but just a <quote>rough</quote> check that
30320 operates as follows:
30321 </para>
30322 <para>
30323 If an item in a <option>require_files</option> list does not contain any forward slash
30324 characters, it is taken to be the user (and optional group, separated by a
30325 comma) to be checked for subsequent files in the list. If no group is specified
30326 but the user is specified symbolically, the gid associated with the uid is
30327 used. For example:
30328 </para>
30329 <literallayout class="monospaced">
30330 require_files = mail:/some/file
30331 require_files = $local_part:$home/.procmailrc
30332 </literallayout>
30333 <para>
30334 If a user or group name in a <option>require_files</option> list does not exist, the
30335 <option>require_files</option> condition fails.
30336 </para>
30337 <para>
30338 Exim performs the check by scanning along the components of the file path, and
30339 checking the access for the given uid and gid. It checks for <quote>x</quote> access on
30340 directories, and <quote>r</quote> access on the final file. Note that this means that file
30341 access control lists, if the operating system has them, are ignored.
30342 </para>
30343 <para>
30344 <emphasis role="bold">Warning 1</emphasis>: When the router is being run to verify addresses for an
30345 incoming SMTP message, Exim is not running as root, but under its own uid. This
30346 may affect the result of a <option>require_files</option> check. In particular, <function>stat()</function>
30347 may yield the error EACCES (<quote>Permission denied</quote>). This means that the Exim
30348 user is not permitted to read one of the directories on the file&#x2019;s path.
30349 </para>
30350 <para>
30351 <emphasis role="bold">Warning 2</emphasis>: Even when Exim is running as root while delivering a message,
30352 <function>stat()</function> can yield EACCES for a file in an NFS directory that is mounted
30353 without root access. In this case, if a check for access by a particular user
30354 is requested, Exim creates a subprocess that runs as that user, and tries the
30355 check again in that process.
30356 </para>
30357 <para>
30358 The default action for handling an unresolved EACCES is to consider it to
30359 be caused by a configuration error, and routing is deferred because the
30360 existence or non-existence of the file cannot be determined. However, in some
30361 circumstances it may be desirable to treat this condition as if the file did
30362 not exist. If the file name (or the exclamation mark that precedes the file
30363 name for non-existence) is preceded by a plus sign, the EACCES error is treated
30364 as if the file did not exist. For example:
30365 </para>
30366 <literallayout class="monospaced">
30367 require_files = +/some/file
30368 </literallayout>
30369 <para>
30370 If the router is not an essential part of verification (for example, it
30371 handles users&#x2019; <filename>.forward</filename> files), another solution is to set the <option>verify</option>
30372 option false so that the router is skipped when verifying.
30373 </para>
30374 <para>
30375 <indexterm role="option">
30376 <primary><option>retry_use_local_part</option></primary>
30377 </indexterm>
30378 </para>
30379 <informaltable frame="all">
30380 <tgroup cols="4" colsep="0" rowsep="0">
30381 <colspec colwidth="8*" align="left"/>
30382 <colspec colwidth="6*" align="center"/>
30383 <colspec colwidth="6*" align="center"/>
30384 <colspec colwidth="6*" align="right"/>
30385 <tbody>
30386 <row>
30387 <entry><option>retry_use_local_part</option></entry>
30388 <entry>Use: <emphasis>routers</emphasis></entry>
30389 <entry>Type: <emphasis>boolean</emphasis></entry>
30390 <entry>Default: <emphasis>see below</emphasis></entry>
30391 </row>
30392 </tbody>
30393 </tgroup>
30394 </informaltable>
30395 <para>
30396 <indexterm role="concept">
30397 <primary>hints database</primary>
30398 <secondary>retry keys</secondary>
30399 </indexterm>
30400 <indexterm role="concept">
30401 <primary>local part</primary>
30402 <secondary>in retry keys</secondary>
30403 </indexterm>
30404 When a delivery suffers a temporary routing failure, a retry record is created
30405 in Exim&#x2019;s hints database. For addresses whose routing depends only on the
30406 domain, the key for the retry record should not involve the local part, but for
30407 other addresses, both the domain and the local part should be included.
30408 Usually, remote routing is of the former kind, and local routing is of the
30409 latter kind.
30410 </para>
30411 <para>
30412 This option controls whether the local part is used to form the key for retry
30413 hints for addresses that suffer temporary errors while being handled by this
30414 router. The default value is true for any router that has <option>check_local_user</option>
30415 set, and false otherwise. Note that this option does not apply to hints keys
30416 for transport delays; they are controlled by a generic transport option of the
30417 same name.
30418 </para>
30419 <para>
30420 The setting of <option>retry_use_local_part</option> applies only to the router on which it
30421 appears. If the router generates child addresses, they are routed
30422 independently; this setting does not become attached to them.
30423 </para>
30424 <para>
30425 <indexterm role="option">
30426 <primary><option>router_home_directory</option></primary>
30427 </indexterm>
30428 </para>
30429 <informaltable frame="all">
30430 <tgroup cols="4" colsep="0" rowsep="0">
30431 <colspec colwidth="8*" align="left"/>
30432 <colspec colwidth="6*" align="center"/>
30433 <colspec colwidth="6*" align="center"/>
30434 <colspec colwidth="6*" align="right"/>
30435 <tbody>
30436 <row>
30437 <entry><option>router_home_directory</option></entry>
30438 <entry>Use: <emphasis>routers</emphasis></entry>
30439 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30440 <entry>Default: <emphasis>unset</emphasis></entry>
30441 </row>
30442 </tbody>
30443 </tgroup>
30444 </informaltable>
30445 <para>
30446 <indexterm role="concept">
30447 <primary>router</primary>
30448 <secondary>home directory for</secondary>
30449 </indexterm>
30450 <indexterm role="concept">
30451 <primary>home directory</primary>
30452 <secondary>for router</secondary>
30453 </indexterm>
30454 <indexterm role="variable">
30455 <primary><varname>$home</varname></primary>
30456 </indexterm>
30457 This option sets a home directory for use while the router is running. (Compare
30458 <option>transport_home_directory</option>, which sets a home directory for later
30459 transporting.) In particular, if used on a <command>redirect</command> router, this option
30460 sets a value for <varname>$home</varname> while a filter is running. The value is expanded;
30461 forced expansion failure causes the option to be ignored &ndash; other failures
30462 cause the router to defer.
30463 </para>
30464 <para>
30465 Expansion of <option>router_home_directory</option> happens immediately after the
30466 <option>check_local_user</option> test (if configured), before any further expansions take
30467 place.
30468 (See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
30469 are evaluated.)
30470 While the router is running, <option>router_home_directory</option> overrides the value of
30471 <varname>$home</varname> that came from <option>check_local_user</option>.
30472 </para>
30473 <para>
30474 When a router accepts an address and assigns it to a local transport (including
30475 the cases when a <command>redirect</command> router generates a pipe, file, or autoreply
30476 delivery), the home directory setting for the transport is taken from the first
30477 of these values that is set:
30478 </para>
30479 <itemizedlist>
30480 <listitem>
30481 <para>
30482 The <option>home_directory</option> option on the transport;
30483 </para>
30484 </listitem>
30485 <listitem>
30486 <para>
30487 The <option>transport_home_directory</option> option on the router;
30488 </para>
30489 </listitem>
30490 <listitem>
30491 <para>
30492 The password data if <option>check_local_user</option> is set on the router;
30493 </para>
30494 </listitem>
30495 <listitem>
30496 <para>
30497 The <option>router_home_directory</option> option on the router.
30498 </para>
30499 </listitem>
30500 </itemizedlist>
30501 <para>
30502 In other words, <option>router_home_directory</option> overrides the password data for the
30503 router, but not for the transport.
30504 </para>
30505 <para>
30506 <indexterm role="option">
30507 <primary><option>self</option></primary>
30508 </indexterm>
30509 </para>
30510 <informaltable frame="all">
30511 <tgroup cols="4" colsep="0" rowsep="0">
30512 <colspec colwidth="8*" align="left"/>
30513 <colspec colwidth="6*" align="center"/>
30514 <colspec colwidth="6*" align="center"/>
30515 <colspec colwidth="6*" align="right"/>
30516 <tbody>
30517 <row>
30518 <entry><option>self</option></entry>
30519 <entry>Use: <emphasis>routers</emphasis></entry>
30520 <entry>Type: <emphasis>string</emphasis></entry>
30521 <entry>Default: <emphasis>freeze</emphasis></entry>
30522 </row>
30523 </tbody>
30524 </tgroup>
30525 </informaltable>
30526 <para>
30527 <indexterm role="concept">
30528 <primary>MX record</primary>
30529 <secondary>pointing to local host</secondary>
30530 </indexterm>
30531 <indexterm role="concept">
30532 <primary>local host</primary>
30533 <secondary>MX pointing to</secondary>
30534 </indexterm>
30535 This option applies to those routers that use a recipient address to find a
30536 list of remote hosts. Currently, these are the <command>dnslookup</command>, <command>ipliteral</command>,
30537 and <command>manualroute</command> routers.
30538 Certain configurations of the <command>queryprogram</command> router can also specify a list
30539 of remote hosts.
30540 Usually such routers are configured to send the message to a remote host via an
30541 <command>smtp</command> transport. The <option>self</option> option specifies what happens when the first
30542 host on the list turns out to be the local host.
30543 The way in which Exim checks for the local host is described in section
30544 <xref linkend="SECTreclocipadd"/>.
30545 </para>
30546 <para>
30547 Normally this situation indicates either an error in Exim&#x2019;s configuration (for
30548 example, the router should be configured not to process this domain), or an
30549 error in the DNS (for example, the MX should not point to this host). For this
30550 reason, the default action is to log the incident, defer the address, and
30551 freeze the message. The following alternatives are provided for use in special
30552 cases:
30553 </para>
30554 <variablelist>
30555 <varlistentry>
30556 <term><option>defer</option></term>
30557 <listitem>
30558 <para>
30559 Delivery of the message is tried again later, but the message is not frozen.
30560 </para>
30561 </listitem></varlistentry>
30562 <varlistentry>
30563 <term><option>reroute</option>: &lt;<emphasis>domain</emphasis>&gt;</term>
30564 <listitem>
30565 <para>
30566 The domain is changed to the given domain, and the address is passed back to
30567 be reprocessed by the routers. No rewriting of headers takes place. This
30568 behaviour is essentially a redirection.
30569 </para>
30570 </listitem></varlistentry>
30571 <varlistentry>
30572 <term><option>reroute: rewrite:</option> &lt;<emphasis>domain</emphasis>&gt;</term>
30573 <listitem>
30574 <para>
30575 The domain is changed to the given domain, and the address is passed back to be
30576 reprocessed by the routers. Any headers that contain the original domain are
30577 rewritten.
30578 </para>
30579 </listitem></varlistentry>
30580 <varlistentry>
30581 <term><option>pass</option></term>
30582 <listitem>
30583 <para>
30584 <indexterm role="option">
30585 <primary><option>more</option></primary>
30586 </indexterm>
30587 <indexterm role="variable">
30588 <primary><varname>$self_hostname</varname></primary>
30589 </indexterm>
30590 The router passes the address to the next router, or to the router named in the
30591 <option>pass_router</option> option if it is set. This overrides <option>no_more</option>. During
30592 subsequent routing and delivery, the variable <varname>$self_hostname</varname> contains the
30593 name of the local host that the router encountered. This can be used to
30594 distinguish between different cases for hosts with multiple names. The
30595 combination
30596 </para>
30597 <literallayout class="monospaced">
30598 self = pass
30599 no_more
30600 </literallayout>
30601 <para>
30602 ensures that only those addresses that routed to the local host are passed on.
30603 Without <option>no_more</option>, addresses that were declined for other reasons would also
30604 be passed to the next router.
30605 </para>
30606 </listitem></varlistentry>
30607 <varlistentry>
30608 <term><option>fail</option></term>
30609 <listitem>
30610 <para>
30611 Delivery fails and an error report is generated.
30612 </para>
30613 </listitem></varlistentry>
30614 <varlistentry>
30615 <term><option>send</option></term>
30616 <listitem>
30617 <para>
30618 <indexterm role="concept">
30619 <primary>local host</primary>
30620 <secondary>sending to</secondary>
30621 </indexterm>
30622 The anomaly is ignored and the address is queued for the transport. This
30623 setting should be used with extreme caution. For an <command>smtp</command> transport, it
30624 makes sense only in cases where the program that is listening on the SMTP port
30625 is not this version of Exim. That is, it must be some other MTA, or Exim with a
30626 different configuration file that handles the domain in another way.
30627 </para>
30628 </listitem></varlistentry>
30629 </variablelist>
30630 <para>
30631 <indexterm role="option">
30632 <primary><option>senders</option></primary>
30633 </indexterm>
30634 </para>
30635 <informaltable frame="all">
30636 <tgroup cols="4" colsep="0" rowsep="0">
30637 <colspec colwidth="8*" align="left"/>
30638 <colspec colwidth="6*" align="center"/>
30639 <colspec colwidth="6*" align="center"/>
30640 <colspec colwidth="6*" align="right"/>
30641 <tbody>
30642 <row>
30643 <entry><option>senders</option></entry>
30644 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
30645 <entry>Type: <emphasis>address list</emphasis>&dagger;<emphasis></emphasis></entry>
30646 <entry>Default: <emphasis>unset</emphasis></entry>
30647 </row>
30648 </tbody>
30649 </tgroup>
30650 </informaltable>
30651 <para>
30652 <indexterm role="concept">
30653 <primary>router</primary>
30654 <secondary>checking senders</secondary>
30655 </indexterm>
30656 If this option is set, the router is skipped unless the message&#x2019;s sender
30657 address matches something on the list.
30658 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
30659 are evaluated.
30660 </para>
30661 <para>
30662 There are issues concerning verification when the running of routers is
30663 dependent on the sender. When Exim is verifying the address in an <option>errors_to</option>
30664 setting, it sets the sender to the null string. When using the <option>-bt</option> option
30665 to check a configuration file, it is necessary also to use the <option>-f</option> option to
30666 set an appropriate sender. For incoming mail, the sender is unset when
30667 verifying the sender, but is available when verifying any recipients. If the
30668 SMTP VRFY command is enabled, it must be used after MAIL if the sender address
30669 matters.
30670 </para>
30671 <para>
30672 <indexterm role="option">
30673 <primary><option>translate_ip_address</option></primary>
30674 </indexterm>
30675 </para>
30676 <informaltable frame="all">
30677 <tgroup cols="4" colsep="0" rowsep="0">
30678 <colspec colwidth="8*" align="left"/>
30679 <colspec colwidth="6*" align="center"/>
30680 <colspec colwidth="6*" align="center"/>
30681 <colspec colwidth="6*" align="right"/>
30682 <tbody>
30683 <row>
30684 <entry><option>translate_ip_address</option></entry>
30685 <entry>Use: <emphasis>routers</emphasis></entry>
30686 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30687 <entry>Default: <emphasis>unset</emphasis></entry>
30688 </row>
30689 </tbody>
30690 </tgroup>
30691 </informaltable>
30692 <para>
30693 <indexterm role="concept">
30694 <primary>IP address</primary>
30695 <secondary>translating</secondary>
30696 </indexterm>
30697 <indexterm role="concept">
30698 <primary>packet radio</primary>
30699 </indexterm>
30700 <indexterm role="concept">
30701 <primary>router</primary>
30702 <secondary>IP address translation</secondary>
30703 </indexterm>
30704 There exist some rare networking situations (for example, packet radio) where
30705 it is helpful to be able to translate IP addresses generated by normal routing
30706 mechanisms into other IP addresses, thus performing a kind of manual IP
30707 routing. This should be done only if the normal IP routing of the TCP/IP stack
30708 is inadequate or broken. Because this is an extremely uncommon requirement, the
30709 code to support this option is not included in the Exim binary unless
30710 SUPPORT_TRANSLATE_IP_ADDRESS=yes is set in <filename>Local/Makefile</filename>.
30711 </para>
30712 <para>
30713 <indexterm role="variable">
30714 <primary><varname>$host_address</varname></primary>
30715 </indexterm>
30716 The <option>translate_ip_address</option> string is expanded for every IP address generated
30717 by the router, with the generated address set in <varname>$host_address</varname>. If the
30718 expansion is forced to fail, no action is taken.
30719 For any other expansion error, delivery of the message is deferred.
30720 If the result of the expansion is an IP address, that replaces the original
30721 address; otherwise the result is assumed to be a host name &ndash; this is looked
30722 up using <function>gethostbyname()</function> (or <function>getipnodebyname()</function> when available) to
30723 produce one or more replacement IP addresses. For example, to subvert all IP
30724 addresses in some specific networks, this could be added to a router:
30725 </para>
30726 <literallayout class="monospaced">
30727 translate_ip_address = \
30728   ${lookup{${mask:$host_address/26}}lsearch{/some/file}\
30729     {$value}fail}}
30730 </literallayout>
30731 <para>
30732 The file would contain lines like
30733 </para>
30734 <literallayout class="monospaced">
30735 10.2.3.128/26    some.host
30736 10.8.4.34/26     10.44.8.15
30737 </literallayout>
30738 <para>
30739 You should not make use of this facility unless you really understand what you
30740 are doing.
30741 </para>
30742 <para>
30743 <indexterm role="option">
30744 <primary><option>transport</option></primary>
30745 </indexterm>
30746 </para>
30747 <informaltable frame="all">
30748 <tgroup cols="4" colsep="0" rowsep="0">
30749 <colspec colwidth="8*" align="left"/>
30750 <colspec colwidth="6*" align="center"/>
30751 <colspec colwidth="6*" align="center"/>
30752 <colspec colwidth="6*" align="right"/>
30753 <tbody>
30754 <row>
30755 <entry><option>transport</option></entry>
30756 <entry>Use: <emphasis>routers</emphasis></entry>
30757 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30758 <entry>Default: <emphasis>unset</emphasis></entry>
30759 </row>
30760 </tbody>
30761 </tgroup>
30762 </informaltable>
30763 <para>
30764 This option specifies the transport to be used when a router accepts an address
30765 and sets it up for delivery. A transport is never needed if a router is used
30766 only for verification. The value of the option is expanded at routing time,
30767 after the expansion of <option>errors_to</option>, <option>headers_add</option>, and <option>headers_remove</option>,
30768 and result must be the name of one of the configured transports. If it is not,
30769 delivery is deferred.
30770 </para>
30771 <para>
30772 The <option>transport</option> option is not used by the <command>redirect</command> router, but it does
30773 have some private options that set up transports for pipe and file deliveries
30774 (see chapter <xref linkend="CHAPredirect"/>).
30775 </para>
30776 <para>
30777 <indexterm role="option">
30778 <primary><option>transport_current_directory</option></primary>
30779 </indexterm>
30780 </para>
30781 <informaltable frame="all">
30782 <tgroup cols="4" colsep="0" rowsep="0">
30783 <colspec colwidth="8*" align="left"/>
30784 <colspec colwidth="6*" align="center"/>
30785 <colspec colwidth="6*" align="center"/>
30786 <colspec colwidth="6*" align="right"/>
30787 <tbody>
30788 <row>
30789 <entry><option>transport_current_directory</option></entry>
30790 <entry>Use: <emphasis>routers</emphasis></entry>
30791 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30792 <entry>Default: <emphasis>unset</emphasis></entry>
30793 </row>
30794 </tbody>
30795 </tgroup>
30796 </informaltable>
30797 <para>
30798 <indexterm role="concept">
30799 <primary>current directory for local transport</primary>
30800 </indexterm>
30801 This option associates a current directory with any address that is routed
30802 to a local transport. This can happen either because a transport is
30803 explicitly configured for the router, or because it generates a delivery to a
30804 file or a pipe. During the delivery process (that is, at transport time), this
30805 option string is expanded and is set as the current directory, unless
30806 overridden by a setting on the transport.
30807 If the expansion fails for any reason, including forced failure, an error is
30808 logged, and delivery is deferred.
30809 See chapter <xref linkend="CHAPenvironment"/> for details of the local delivery
30810 environment.
30811 </para>
30812 <para>
30813 <indexterm role="option">
30814 <primary><option>transport_home_directory</option></primary>
30815 </indexterm>
30816 </para>
30817 <informaltable frame="all">
30818 <tgroup cols="4" colsep="0" rowsep="0">
30819 <colspec colwidth="8*" align="left"/>
30820 <colspec colwidth="6*" align="center"/>
30821 <colspec colwidth="6*" align="center"/>
30822 <colspec colwidth="6*" align="right"/>
30823 <tbody>
30824 <row>
30825 <entry><option>transport_home_directory</option></entry>
30826 <entry>Use: <emphasis>routers</emphasis></entry>
30827 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30828 <entry>Default: <emphasis>see below</emphasis></entry>
30829 </row>
30830 </tbody>
30831 </tgroup>
30832 </informaltable>
30833 <para>
30834 <indexterm role="concept">
30835 <primary>home directory</primary>
30836 <secondary>for local transport</secondary>
30837 </indexterm>
30838 This option associates a home directory with any address that is routed to a
30839 local transport. This can happen either because a transport is explicitly
30840 configured for the router, or because it generates a delivery to a file or a
30841 pipe. During the delivery process (that is, at transport time), the option
30842 string is expanded and is set as the home directory, unless overridden by a
30843 setting of <option>home_directory</option> on the transport.
30844 If the expansion fails for any reason, including forced failure, an error is
30845 logged, and delivery is deferred.
30846 </para>
30847 <para>
30848 If the transport does not specify a home directory, and
30849 <option>transport_home_directory</option> is not set for the router, the home directory for
30850 the transport is taken from the password data if <option>check_local_user</option> is set for
30851 the router. Otherwise it is taken from <option>router_home_directory</option> if that option
30852 is set; if not, no home directory is set for the transport.
30853 </para>
30854 <para>
30855 See chapter <xref linkend="CHAPenvironment"/> for further details of the local delivery
30856 environment.
30857 </para>
30858 <para>
30859 <indexterm role="option">
30860 <primary><option>unseen</option></primary>
30861 </indexterm>
30862 </para>
30863 <informaltable frame="all">
30864 <tgroup cols="4" colsep="0" rowsep="0">
30865 <colspec colwidth="8*" align="left"/>
30866 <colspec colwidth="6*" align="center"/>
30867 <colspec colwidth="6*" align="center"/>
30868 <colspec colwidth="6*" align="right"/>
30869 <tbody>
30870 <row>
30871 <entry><option>unseen</option></entry>
30872 <entry>Use: <emphasis>routers</emphasis></entry>
30873 <entry>Type: <emphasis>boolean</emphasis>&dagger;<emphasis></emphasis></entry>
30874 <entry>Default: <emphasis>false</emphasis></entry>
30875 </row>
30876 </tbody>
30877 </tgroup>
30878 </informaltable>
30879 <para>
30880 <indexterm role="concept">
30881 <primary>router</primary>
30882 <secondary>carrying on after success</secondary>
30883 </indexterm>
30884 The result of string expansion for this option must be a valid boolean value,
30885 that is, one of the strings <quote>yes</quote>, <quote>no</quote>, <quote>true</quote>, or <quote>false</quote>. Any other
30886 result causes an error, and delivery is deferred. If the expansion is forced to
30887 fail, the default value for the option (false) is used. Other failures cause
30888 delivery to be deferred.
30889 </para>
30890 <para>
30891 When this option is set true, routing does not cease if the router accepts the
30892 address. Instead, a copy of the incoming address is passed to the next router,
30893 overriding a false setting of <option>more</option>. There is little point in setting
30894 <option>more</option> false if <option>unseen</option> is always true, but it may be useful in cases when
30895 the value of <option>unseen</option> contains expansion items (and therefore, presumably, is
30896 sometimes true and sometimes false).
30897 </para>
30898 <para>
30899 <indexterm role="concept">
30900 <primary>copy of message (<option>unseen</option> option)</primary>
30901 </indexterm>
30902 Setting the <option>unseen</option> option has a similar effect to the <option>unseen</option> command
30903 qualifier in filter files. It can be used to cause copies of messages to be
30904 delivered to some other destination, while also carrying out a normal delivery.
30905 In effect, the current address is made into a <quote>parent</quote> that has two children
30906 &ndash; one that is delivered as specified by this router, and a clone that goes on
30907 to be routed further. For this reason, <option>unseen</option> may not be combined with the
30908 <option>one_time</option> option in a <command>redirect</command> router.
30909 </para>
30910 <para>
30911 <emphasis role="bold">Warning</emphasis>: Header lines added to the address (or specified for removal) by
30912 this router or by previous routers affect the <quote>unseen</quote> copy of the message
30913 only. The clone that continues to be processed by further routers starts with
30914 no added headers and none specified for removal. For a <option>redirect</option> router, if
30915 a generated address is the same as the incoming address, this can lead to
30916 duplicate addresses with different header modifications. Exim does not do
30917 duplicate deliveries (except, in certain circumstances, to pipes -- see section
30918 <xref linkend="SECTdupaddr"/>), but it is undefined which of the duplicates is discarded,
30919 so this ambiguous situation should be avoided. The <option>repeat_use</option> option of the
30920 <option>redirect</option> router may be of help.
30921 </para>
30922 <para>
30923 Unlike the handling of header modifications, any data that was set by the
30924 <option>address_data</option> option in the current or previous routers <emphasis>is</emphasis> passed on to
30925 subsequent routers.
30926 </para>
30927 <para>
30928 <indexterm role="option">
30929 <primary><option>user</option></primary>
30930 </indexterm>
30931 </para>
30932 <informaltable frame="all">
30933 <tgroup cols="4" colsep="0" rowsep="0">
30934 <colspec colwidth="8*" align="left"/>
30935 <colspec colwidth="6*" align="center"/>
30936 <colspec colwidth="6*" align="center"/>
30937 <colspec colwidth="6*" align="right"/>
30938 <tbody>
30939 <row>
30940 <entry><option>user</option></entry>
30941 <entry>Use: <emphasis>routers</emphasis></entry>
30942 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30943 <entry>Default: <emphasis>see below</emphasis></entry>
30944 </row>
30945 </tbody>
30946 </tgroup>
30947 </informaltable>
30948 <para>
30949 <indexterm role="concept">
30950 <primary>uid (user id)</primary>
30951 <secondary>local delivery</secondary>
30952 </indexterm>
30953 <indexterm role="concept">
30954 <primary>local transports</primary>
30955 <secondary>uid and gid</secondary>
30956 </indexterm>
30957 <indexterm role="concept">
30958 <primary>transport</primary>
30959 <secondary>local</secondary>
30960 </indexterm>
30961 <indexterm role="concept">
30962 <primary>router</primary>
30963 <secondary>user for filter processing</secondary>
30964 </indexterm>
30965 <indexterm role="concept">
30966 <primary>filter</primary>
30967 <secondary>user for processing</secondary>
30968 </indexterm>
30969 When a router queues an address for a transport, and the transport does not
30970 specify a user, the user given here is used when running the delivery process.
30971 The user may be specified numerically or by name. If expansion fails, the
30972 error is logged and delivery is deferred.
30973 This user is also used by the <command>redirect</command> router when running a filter file.
30974 The default is unset, except when <option>check_local_user</option> is set. In this case,
30975 the default is taken from the password information. If the user is specified as
30976 a name, and <option>group</option> is not set, the group associated with the user is used.
30977 See also <option>initgroups</option> and <option>group</option> and the discussion in chapter
30978 <xref linkend="CHAPenvironment"/>.
30979 </para>
30980 <para>
30981 <indexterm role="option">
30982 <primary><option>verify</option></primary>
30983 </indexterm>
30984 </para>
30985 <informaltable frame="all">
30986 <tgroup cols="4" colsep="0" rowsep="0">
30987 <colspec colwidth="8*" align="left"/>
30988 <colspec colwidth="6*" align="center"/>
30989 <colspec colwidth="6*" align="center"/>
30990 <colspec colwidth="6*" align="right"/>
30991 <tbody>
30992 <row>
30993 <entry><option>verify</option></entry>
30994 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
30995 <entry>Type: <emphasis>boolean</emphasis></entry>
30996 <entry>Default: <emphasis>true</emphasis></entry>
30997 </row>
30998 </tbody>
30999 </tgroup>
31000 </informaltable>
31001 <para>
31002 Setting this option has the effect of setting <option>verify_sender</option> and
31003 <option>verify_recipient</option> to the same value.
31004 </para>
31005 <para>
31006 <indexterm role="option">
31007 <primary><option>verify_only</option></primary>
31008 </indexterm>
31009 </para>
31010 <informaltable frame="all">
31011 <tgroup cols="4" colsep="0" rowsep="0">
31012 <colspec colwidth="8*" align="left"/>
31013 <colspec colwidth="6*" align="center"/>
31014 <colspec colwidth="6*" align="center"/>
31015 <colspec colwidth="6*" align="right"/>
31016 <tbody>
31017 <row>
31018 <entry><option>verify_only</option></entry>
31019 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
31020 <entry>Type: <emphasis>boolean</emphasis></entry>
31021 <entry>Default: <emphasis>false</emphasis></entry>
31022 </row>
31023 </tbody>
31024 </tgroup>
31025 </informaltable>
31026 <para>
31027 <indexterm role="concept">
31028 <primary>EXPN</primary>
31029 <secondary>with <option>verify_only</option></secondary>
31030 </indexterm>
31031 <indexterm role="option">
31032 <primary><option>-bv</option></primary>
31033 </indexterm>
31034 <indexterm role="concept">
31035 <primary>router</primary>
31036 <secondary>used only when verifying</secondary>
31037 </indexterm>
31038 If this option is set, the router is used only when verifying an address or
31039 testing with the <option>-bv</option> option, not when actually doing a delivery, testing
31040 with the <option>-bt</option> option, or running the SMTP EXPN command. It can be further
31041 restricted to verifying only senders or recipients by means of
31042 <option>verify_sender</option> and <option>verify_recipient</option>.
31043 </para>
31044 <para>
31045 <emphasis role="bold">Warning</emphasis>: When the router is being run to verify addresses for an incoming
31046 SMTP message, Exim is not running as root, but under its own uid. If the router
31047 accesses any files, you need to make sure that they are accessible to the Exim
31048 user or group.
31049 </para>
31050 <para>
31051 <indexterm role="option">
31052 <primary><option>verify_recipient</option></primary>
31053 </indexterm>
31054 </para>
31055 <informaltable frame="all">
31056 <tgroup cols="4" colsep="0" rowsep="0">
31057 <colspec colwidth="8*" align="left"/>
31058 <colspec colwidth="6*" align="center"/>
31059 <colspec colwidth="6*" align="center"/>
31060 <colspec colwidth="6*" align="right"/>
31061 <tbody>
31062 <row>
31063 <entry><option>verify_recipient</option></entry>
31064 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
31065 <entry>Type: <emphasis>boolean</emphasis></entry>
31066 <entry>Default: <emphasis>true</emphasis></entry>
31067 </row>
31068 </tbody>
31069 </tgroup>
31070 </informaltable>
31071 <para>
31072 If this option is false, the router is skipped when verifying recipient
31073 addresses
31074 or testing recipient verification using <option>-bv</option>.
31075 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
31076 are evaluated.
31077 </para>
31078 <para>
31079 <indexterm role="option">
31080 <primary><option>verify_sender</option></primary>
31081 </indexterm>
31082 </para>
31083 <informaltable frame="all">
31084 <tgroup cols="4" colsep="0" rowsep="0">
31085 <colspec colwidth="8*" align="left"/>
31086 <colspec colwidth="6*" align="center"/>
31087 <colspec colwidth="6*" align="center"/>
31088 <colspec colwidth="6*" align="right"/>
31089 <tbody>
31090 <row>
31091 <entry><option>verify_sender</option></entry>
31092 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
31093 <entry>Type: <emphasis>boolean</emphasis></entry>
31094 <entry>Default: <emphasis>true</emphasis></entry>
31095 </row>
31096 </tbody>
31097 </tgroup>
31098 </informaltable>
31099 <para>
31100 If this option is false, the router is skipped when verifying sender addresses
31101 or testing sender verification using <option>-bvs</option>.
31102 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
31103 are evaluated.
31104 <indexterm role="concept" startref="IIDgenoprou1" class="endofrange"/>
31105 <indexterm role="concept" startref="IIDgenoprou2" class="endofrange"/>
31106 </para>
31107 </chapter>
31108
31109 <chapter id="CHID4">
31110 <title>The accept router</title>
31111 <para>
31112 <indexterm role="concept">
31113 <primary><command>accept</command> router</primary>
31114 </indexterm>
31115 <indexterm role="concept">
31116 <primary>routers</primary>
31117 <secondary><command>accept</command></secondary>
31118 </indexterm>
31119 The <command>accept</command> router has no private options of its own. Unless it is being
31120 used purely for verification (see <option>verify_only</option>) a transport is required to
31121 be defined by the generic <option>transport</option> option. If the preconditions that are
31122 specified by generic options are met, the router accepts the address and queues
31123 it for the given transport. The most common use of this router is for setting
31124 up deliveries to local mailboxes. For example:
31125 </para>
31126 <literallayout class="monospaced">
31127 localusers:
31128   driver = accept
31129   domains = mydomain.example
31130   check_local_user
31131   transport = local_delivery
31132 </literallayout>
31133 <para>
31134 The <option>domains</option> condition in this example checks the domain of the address, and
31135 <option>check_local_user</option> checks that the local part is the login of a local user.
31136 When both preconditions are met, the <command>accept</command> router runs, and queues the
31137 address for the <command>local_delivery</command> transport.
31138 </para>
31139 </chapter>
31140
31141 <chapter id="CHAPdnslookup">
31142 <title>The dnslookup router</title>
31143 <para>
31144 <indexterm role="concept" id="IIDdnsrou1" class="startofrange">
31145 <primary><command>dnslookup</command> router</primary>
31146 </indexterm>
31147 <indexterm role="concept" id="IIDdnsrou2" class="startofrange">
31148 <primary>routers</primary>
31149 <secondary><command>dnslookup</command></secondary>
31150 </indexterm>
31151 The <command>dnslookup</command> router looks up the hosts that handle mail for the
31152 recipient&#x2019;s domain in the DNS. A transport must always be set for this router,
31153 unless <option>verify_only</option> is set.
31154 </para>
31155 <para>
31156 If SRV support is configured (see <option>check_srv</option> below), Exim first searches for
31157 SRV records. If none are found, or if SRV support is not configured,
31158 MX records are looked up. If no MX records exist, address records are sought.
31159 However, <option>mx_domains</option> can be set to disable the direct use of address
31160 records.
31161 </para>
31162 <para>
31163 MX records of equal priority are sorted by Exim into a random order. Exim then
31164 looks for address records for the host names obtained from MX or SRV records.
31165 When a host has more than one IP address, they are sorted into a random order,
31166 except that IPv6 addresses are always sorted before IPv4 addresses. If all the
31167 IP addresses found are discarded by a setting of the <option>ignore_target_hosts</option>
31168 generic option, the router declines.
31169 </para>
31170 <para>
31171 Unless they have the highest priority (lowest MX value), MX records that point
31172 to the local host, or to any host name that matches <option>hosts_treat_as_local</option>,
31173 are discarded, together with any other MX records of equal or lower priority.
31174 </para>
31175 <para>
31176 <indexterm role="concept">
31177 <primary>MX record</primary>
31178 <secondary>pointing to local host</secondary>
31179 </indexterm>
31180 <indexterm role="concept">
31181 <primary>local host</primary>
31182 <secondary>MX pointing to</secondary>
31183 </indexterm>
31184 <indexterm role="option">
31185 <primary><option>self</option></primary>
31186 <secondary>in <command>dnslookup</command> router</secondary>
31187 </indexterm>
31188 If the host pointed to by the highest priority MX record, or looked up as an
31189 address record, is the local host, or matches <option>hosts_treat_as_local</option>, what
31190 happens is controlled by the generic <option>self</option> option.
31191 </para>
31192 <section id="SECTprowitdnsloo">
31193 <title>Problems with DNS lookups</title>
31194 <para>
31195 There have been problems with DNS servers when SRV records are looked up.
31196 Some mis-behaving servers return a DNS error or timeout when a non-existent
31197 SRV record is sought. Similar problems have in the past been reported for
31198 MX records. The global <option>dns_again_means_nonexist</option> option can help with this
31199 problem, but it is heavy-handed because it is a global option.
31200 </para>
31201 <para>
31202 For this reason, there are two options, <option>srv_fail_domains</option> and
31203 <option>mx_fail_domains</option>, that control what happens when a DNS lookup in a
31204 <command>dnslookup</command> router results in a DNS failure or a <quote>try again</quote> response. If
31205 an attempt to look up an SRV or MX record causes one of these results, and the
31206 domain matches the relevant list, Exim behaves as if the DNS had responded <quote>no
31207 such record</quote>. In the case of an SRV lookup, this means that the router
31208 proceeds to look for MX records; in the case of an MX lookup, it proceeds to
31209 look for A or AAAA records, unless the domain matches <option>mx_domains</option>, in which
31210 case routing fails.
31211 </para>
31212 </section>
31213 <section id="SECID118">
31214 <title>Private options for dnslookup</title>
31215 <para>
31216 <indexterm role="concept">
31217 <primary>options</primary>
31218 <secondary><command>dnslookup</command> router</secondary>
31219 </indexterm>
31220 The private options for the <command>dnslookup</command> router are as follows:
31221 </para>
31222 <para>
31223 <indexterm role="option">
31224 <primary><option>check_secondary_mx</option></primary>
31225 </indexterm>
31226 </para>
31227 <informaltable frame="all">
31228 <tgroup cols="4" colsep="0" rowsep="0">
31229 <colspec colwidth="8*" align="left"/>
31230 <colspec colwidth="6*" align="center"/>
31231 <colspec colwidth="6*" align="center"/>
31232 <colspec colwidth="6*" align="right"/>
31233 <tbody>
31234 <row>
31235 <entry><option>check_secondary_mx</option></entry>
31236 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31237 <entry>Type: <emphasis>boolean</emphasis></entry>
31238 <entry>Default: <emphasis>false</emphasis></entry>
31239 </row>
31240 </tbody>
31241 </tgroup>
31242 </informaltable>
31243 <para>
31244 <indexterm role="concept">
31245 <primary>MX record</primary>
31246 <secondary>checking for secondary</secondary>
31247 </indexterm>
31248 If this option is set, the router declines unless the local host is found in
31249 (and removed from) the list of hosts obtained by MX lookup. This can be used to
31250 process domains for which the local host is a secondary mail exchanger
31251 differently to other domains. The way in which Exim decides whether a host is
31252 the local host is described in section <xref linkend="SECTreclocipadd"/>.
31253 </para>
31254 <para>
31255 <indexterm role="option">
31256 <primary><option>check_srv</option></primary>
31257 </indexterm>
31258 </para>
31259 <informaltable frame="all">
31260 <tgroup cols="4" colsep="0" rowsep="0">
31261 <colspec colwidth="8*" align="left"/>
31262 <colspec colwidth="6*" align="center"/>
31263 <colspec colwidth="6*" align="center"/>
31264 <colspec colwidth="6*" align="right"/>
31265 <tbody>
31266 <row>
31267 <entry><option>check_srv</option></entry>
31268 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31269 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
31270 <entry>Default: <emphasis>unset</emphasis></entry>
31271 </row>
31272 </tbody>
31273 </tgroup>
31274 </informaltable>
31275 <para>
31276 <indexterm role="concept">
31277 <primary>SRV record</primary>
31278 <secondary>enabling use of</secondary>
31279 </indexterm>
31280 The <command>dnslookup</command> router supports the use of SRV records (see RFC 2782) in
31281 addition to MX and address records. The support is disabled by default. To
31282 enable SRV support, set the <option>check_srv</option> option to the name of the service
31283 required. For example,
31284 </para>
31285 <literallayout class="monospaced">
31286 check_srv = smtp
31287 </literallayout>
31288 <para>
31289 looks for SRV records that refer to the normal smtp service. The option is
31290 expanded, so the service name can vary from message to message or address
31291 to address. This might be helpful if SRV records are being used for a
31292 submission service. If the expansion is forced to fail, the <option>check_srv</option>
31293 option is ignored, and the router proceeds to look for MX records in the
31294 normal way.
31295 </para>
31296 <para>
31297 When the expansion succeeds, the router searches first for SRV records for
31298 the given service (it assumes TCP protocol). A single SRV record with a
31299 host name that consists of just a single dot indicates <quote>no such service for
31300 this domain</quote>; if this is encountered, the router declines. If other kinds of
31301 SRV record are found, they are used to construct a host list for delivery
31302 according to the rules of RFC 2782. MX records are not sought in this case.
31303 </para>
31304 <para>
31305 When no SRV records are found, MX records (and address records) are sought in
31306 the traditional way. In other words, SRV records take precedence over MX
31307 records, just as MX records take precedence over address records. Note that
31308 this behaviour is not sanctioned by RFC 2782, though a previous draft RFC
31309 defined it. It is apparently believed that MX records are sufficient for email
31310 and that SRV records should not be used for this purpose. However, SRV records
31311 have an additional <quote>weight</quote> feature which some people might find useful when
31312 trying to split an SMTP load between hosts of different power.
31313 </para>
31314 <para>
31315 See section <xref linkend="SECTprowitdnsloo"/> above for a discussion of Exim&#x2019;s behaviour
31316 when there is a DNS lookup error.
31317 </para>
31318 <para>
31319 <indexterm role="option">
31320 <primary><option>mx_domains</option></primary>
31321 </indexterm>
31322 </para>
31323 <informaltable frame="all">
31324 <tgroup cols="4" colsep="0" rowsep="0">
31325 <colspec colwidth="8*" align="left"/>
31326 <colspec colwidth="6*" align="center"/>
31327 <colspec colwidth="6*" align="center"/>
31328 <colspec colwidth="6*" align="right"/>
31329 <tbody>
31330 <row>
31331 <entry><option>mx_domains</option></entry>
31332 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31333 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
31334 <entry>Default: <emphasis>unset</emphasis></entry>
31335 </row>
31336 </tbody>
31337 </tgroup>
31338 </informaltable>
31339 <para>
31340 <indexterm role="concept">
31341 <primary>MX record</primary>
31342 <secondary>required to exist</secondary>
31343 </indexterm>
31344 <indexterm role="concept">
31345 <primary>SRV record</primary>
31346 <secondary>required to exist</secondary>
31347 </indexterm>
31348 A domain that matches <option>mx_domains</option> is required to have either an MX or an SRV
31349 record in order to be recognized. (The name of this option could be improved.)
31350 For example, if all the mail hosts in <emphasis>fict.example</emphasis> are known to have MX
31351 records, except for those in <emphasis>discworld.fict.example</emphasis>, you could use this
31352 setting:
31353 </para>
31354 <literallayout class="monospaced">
31355 mx_domains = ! *.discworld.fict.example : *.fict.example
31356 </literallayout>
31357 <para>
31358 This specifies that messages addressed to a domain that matches the list but
31359 has no MX record should be bounced immediately instead of being routed using
31360 the address record.
31361 </para>
31362 <para>
31363 <indexterm role="option">
31364 <primary><option>mx_fail_domains</option></primary>
31365 </indexterm>
31366 </para>
31367 <informaltable frame="all">
31368 <tgroup cols="4" colsep="0" rowsep="0">
31369 <colspec colwidth="8*" align="left"/>
31370 <colspec colwidth="6*" align="center"/>
31371 <colspec colwidth="6*" align="center"/>
31372 <colspec colwidth="6*" align="right"/>
31373 <tbody>
31374 <row>
31375 <entry><option>mx_fail_domains</option></entry>
31376 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31377 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
31378 <entry>Default: <emphasis>unset</emphasis></entry>
31379 </row>
31380 </tbody>
31381 </tgroup>
31382 </informaltable>
31383 <para>
31384 If the DNS lookup for MX records for one of the domains in this list causes a
31385 DNS lookup error, Exim behaves as if no MX records were found. See section
31386 <xref linkend="SECTprowitdnsloo"/> for more discussion.
31387 </para>
31388 <para>
31389 <indexterm role="option">
31390 <primary><option>qualify_single</option></primary>
31391 </indexterm>
31392 </para>
31393 <informaltable frame="all">
31394 <tgroup cols="4" colsep="0" rowsep="0">
31395 <colspec colwidth="8*" align="left"/>
31396 <colspec colwidth="6*" align="center"/>
31397 <colspec colwidth="6*" align="center"/>
31398 <colspec colwidth="6*" align="right"/>
31399 <tbody>
31400 <row>
31401 <entry><option>qualify_single</option></entry>
31402 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31403 <entry>Type: <emphasis>boolean</emphasis></entry>
31404 <entry>Default: <emphasis>true</emphasis></entry>
31405 </row>
31406 </tbody>
31407 </tgroup>
31408 </informaltable>
31409 <para>
31410 <indexterm role="concept">
31411 <primary>DNS</primary>
31412 <secondary>resolver options</secondary>
31413 </indexterm>
31414 <indexterm role="concept">
31415 <primary>DNS</primary>
31416 <secondary>qualifying single-component names</secondary>
31417 </indexterm>
31418 When this option is true, the resolver option RES_DEFNAMES is set for DNS
31419 lookups. Typically, but not standardly, this causes the resolver to qualify
31420 single-component names with the default domain. For example, on a machine
31421 called <emphasis>dictionary.ref.example</emphasis>, the domain <emphasis>thesaurus</emphasis> would be changed to
31422 <emphasis>thesaurus.ref.example</emphasis> inside the resolver. For details of what your
31423 resolver actually does, consult your man pages for <emphasis>resolver</emphasis> and
31424 <emphasis>resolv.conf</emphasis>.
31425 </para>
31426 <para>
31427 <indexterm role="option">
31428 <primary><option>rewrite_headers</option></primary>
31429 </indexterm>
31430 </para>
31431 <informaltable frame="all">
31432 <tgroup cols="4" colsep="0" rowsep="0">
31433 <colspec colwidth="8*" align="left"/>
31434 <colspec colwidth="6*" align="center"/>
31435 <colspec colwidth="6*" align="center"/>
31436 <colspec colwidth="6*" align="right"/>
31437 <tbody>
31438 <row>
31439 <entry><option>rewrite_headers</option></entry>
31440 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31441 <entry>Type: <emphasis>boolean</emphasis></entry>
31442 <entry>Default: <emphasis>true</emphasis></entry>
31443 </row>
31444 </tbody>
31445 </tgroup>
31446 </informaltable>
31447 <para>
31448 <indexterm role="concept">
31449 <primary>rewriting</primary>
31450 <secondary>header lines</secondary>
31451 </indexterm>
31452 <indexterm role="concept">
31453 <primary>header lines</primary>
31454 <secondary>rewriting</secondary>
31455 </indexterm>
31456 If the domain name in the address that is being processed is not fully
31457 qualified, it may be expanded to its full form by a DNS lookup. For example, if
31458 an address is specified as <emphasis>dormouse@teaparty</emphasis>, the domain might be
31459 expanded to <emphasis>teaparty.wonderland.fict.example</emphasis>. Domain expansion can also
31460 occur as a result of setting the <option>widen_domains</option> option. If
31461 <option>rewrite_headers</option> is true, all occurrences of the abbreviated domain name in
31462 any <emphasis>Bcc:</emphasis>, <emphasis>Cc:</emphasis>, <emphasis>From:</emphasis>, <emphasis>Reply-to:</emphasis>, <emphasis>Sender:</emphasis>, and <emphasis>To:</emphasis>
31463 header lines of the message are rewritten with the full domain name.
31464 </para>
31465 <para>
31466 This option should be turned off only when it is known that no message is
31467 ever going to be sent outside an environment where the abbreviation makes
31468 sense.
31469 </para>
31470 <para>
31471 When an MX record is looked up in the DNS and matches a wildcard record, name
31472 servers normally return a record containing the name that has been looked up,
31473 making it impossible to detect whether a wildcard was present or not. However,
31474 some name servers have recently been seen to return the wildcard entry. If the
31475 name returned by a DNS lookup begins with an asterisk, it is not used for
31476 header rewriting.
31477 </para>
31478 <para>
31479 <indexterm role="option">
31480 <primary><option>same_domain_copy_routing</option></primary>
31481 </indexterm>
31482 </para>
31483 <informaltable frame="all">
31484 <tgroup cols="4" colsep="0" rowsep="0">
31485 <colspec colwidth="8*" align="left"/>
31486 <colspec colwidth="6*" align="center"/>
31487 <colspec colwidth="6*" align="center"/>
31488 <colspec colwidth="6*" align="right"/>
31489 <tbody>
31490 <row>
31491 <entry><option>same_domain_copy_routing</option></entry>
31492 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31493 <entry>Type: <emphasis>boolean</emphasis></entry>
31494 <entry>Default: <emphasis>false</emphasis></entry>
31495 </row>
31496 </tbody>
31497 </tgroup>
31498 </informaltable>
31499 <para>
31500 <indexterm role="concept">
31501 <primary>address</primary>
31502 <secondary>copying routing</secondary>
31503 </indexterm>
31504 Addresses with the same domain are normally routed by the <command>dnslookup</command> router
31505 to the same list of hosts. However, this cannot be presumed, because the router
31506 options and preconditions may refer to the local part of the address. By
31507 default, therefore, Exim routes each address in a message independently. DNS
31508 servers run caches, so repeated DNS lookups are not normally expensive, and in
31509 any case, personal messages rarely have more than a few recipients.
31510 </para>
31511 <para>
31512 If you are running mailing lists with large numbers of subscribers at the same
31513 domain, and you are using a <command>dnslookup</command> router which is independent of the
31514 local part, you can set <option>same_domain_copy_routing</option> to bypass repeated DNS
31515 lookups for identical domains in one message. In this case, when <command>dnslookup</command>
31516 routes an address to a remote transport, any other unrouted addresses in the
31517 message that have the same domain are automatically given the same routing
31518 without processing them independently,
31519 provided the following conditions are met:
31520 </para>
31521 <itemizedlist>
31522 <listitem>
31523 <para>
31524 No router that processed the address specified <option>headers_add</option> or
31525 <option>headers_remove</option>.
31526 </para>
31527 </listitem>
31528 <listitem>
31529 <para>
31530 The router did not change the address in any way, for example, by <quote>widening</quote>
31531 the domain.
31532 </para>
31533 </listitem>
31534 </itemizedlist>
31535 <para>
31536 <indexterm role="option">
31537 <primary><option>search_parents</option></primary>
31538 </indexterm>
31539 </para>
31540 <informaltable frame="all">
31541 <tgroup cols="4" colsep="0" rowsep="0">
31542 <colspec colwidth="8*" align="left"/>
31543 <colspec colwidth="6*" align="center"/>
31544 <colspec colwidth="6*" align="center"/>
31545 <colspec colwidth="6*" align="right"/>
31546 <tbody>
31547 <row>
31548 <entry><option>search_parents</option></entry>
31549 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31550 <entry>Type: <emphasis>boolean</emphasis></entry>
31551 <entry>Default: <emphasis>false</emphasis></entry>
31552 </row>
31553 </tbody>
31554 </tgroup>
31555 </informaltable>
31556 <para>
31557 <indexterm role="concept">
31558 <primary>DNS</primary>
31559 <secondary>resolver options</secondary>
31560 </indexterm>
31561 When this option is true, the resolver option RES_DNSRCH is set for DNS
31562 lookups. This is different from the <option>qualify_single</option> option in that it
31563 applies to domains containing dots. Typically, but not standardly, it causes
31564 the resolver to search for the name in the current domain and in parent
31565 domains. For example, on a machine in the <emphasis>fict.example</emphasis> domain, if looking
31566 up <emphasis>teaparty.wonderland</emphasis> failed, the resolver would try
31567 <emphasis>teaparty.wonderland.fict.example</emphasis>. For details of what your resolver
31568 actually does, consult your man pages for <emphasis>resolver</emphasis> and <emphasis>resolv.conf</emphasis>.
31569 </para>
31570 <para>
31571 Setting this option true can cause problems in domains that have a wildcard MX
31572 record, because any domain that does not have its own MX record matches the
31573 local wildcard.
31574 </para>
31575 <para>
31576 <indexterm role="option">
31577 <primary><option>srv_fail_domains</option></primary>
31578 </indexterm>
31579 </para>
31580 <informaltable frame="all">
31581 <tgroup cols="4" colsep="0" rowsep="0">
31582 <colspec colwidth="8*" align="left"/>
31583 <colspec colwidth="6*" align="center"/>
31584 <colspec colwidth="6*" align="center"/>
31585 <colspec colwidth="6*" align="right"/>
31586 <tbody>
31587 <row>
31588 <entry><option>srv_fail_domains</option></entry>
31589 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31590 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
31591 <entry>Default: <emphasis>unset</emphasis></entry>
31592 </row>
31593 </tbody>
31594 </tgroup>
31595 </informaltable>
31596 <para>
31597 If the DNS lookup for SRV records for one of the domains in this list causes a
31598 DNS lookup error, Exim behaves as if no SRV records were found. See section
31599 <xref linkend="SECTprowitdnsloo"/> for more discussion.
31600 </para>
31601 <para>
31602 <indexterm role="option">
31603 <primary><option>widen_domains</option></primary>
31604 </indexterm>
31605 </para>
31606 <informaltable frame="all">
31607 <tgroup cols="4" colsep="0" rowsep="0">
31608 <colspec colwidth="8*" align="left"/>
31609 <colspec colwidth="6*" align="center"/>
31610 <colspec colwidth="6*" align="center"/>
31611 <colspec colwidth="6*" align="right"/>
31612 <tbody>
31613 <row>
31614 <entry><option>widen_domains</option></entry>
31615 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31616 <entry>Type: <emphasis>string list</emphasis></entry>
31617 <entry>Default: <emphasis>unset</emphasis></entry>
31618 </row>
31619 </tbody>
31620 </tgroup>
31621 </informaltable>
31622 <para>
31623 <indexterm role="concept">
31624 <primary>domain</primary>
31625 <secondary>partial; widening</secondary>
31626 </indexterm>
31627 If a DNS lookup fails and this option is set, each of its strings in turn is
31628 added onto the end of the domain, and the lookup is tried again. For example,
31629 if
31630 </para>
31631 <literallayout class="monospaced">
31632 widen_domains = fict.example:ref.example
31633 </literallayout>
31634 <para>
31635 is set and a lookup of <emphasis>klingon.dictionary</emphasis> fails,
31636 <emphasis>klingon.dictionary.fict.example</emphasis> is looked up, and if this fails,
31637 <emphasis>klingon.dictionary.ref.example</emphasis> is tried. Note that the <option>qualify_single</option>
31638 and <option>search_parents</option> options can cause some widening to be undertaken inside
31639 the DNS resolver. <option>widen_domains</option> is not applied to sender addresses
31640 when verifying, unless <option>rewrite_headers</option> is false (not the default).
31641 </para>
31642 </section>
31643 <section id="SECID119">
31644 <title>Effect of qualify_single and search_parents</title>
31645 <para>
31646 When a domain from an envelope recipient is changed by the resolver as a result
31647 of the <option>qualify_single</option> or <option>search_parents</option> options, Exim rewrites the
31648 corresponding address in the message&#x2019;s header lines unless <option>rewrite_headers</option>
31649 is set false. Exim then re-routes the address, using the full domain.
31650 </para>
31651 <para>
31652 These two options affect only the DNS lookup that takes place inside the router
31653 for the domain of the address that is being routed. They do not affect lookups
31654 such as that implied by
31655 </para>
31656 <literallayout class="monospaced">
31657 domains = @mx_any
31658 </literallayout>
31659 <para>
31660 that may happen while processing a router precondition before the router is
31661 entered. No widening ever takes place for these lookups.
31662 <indexterm role="concept" startref="IIDdnsrou1" class="endofrange"/>
31663 <indexterm role="concept" startref="IIDdnsrou2" class="endofrange"/>
31664 </para>
31665 </section>
31666 </chapter>
31667
31668 <chapter id="CHID5">
31669 <title>The ipliteral router</title>
31670 <para>
31671 <indexterm role="concept">
31672 <primary><command>ipliteral</command> router</primary>
31673 </indexterm>
31674 <indexterm role="concept">
31675 <primary>domain literal</primary>
31676 <secondary>routing</secondary>
31677 </indexterm>
31678 <indexterm role="concept">
31679 <primary>routers</primary>
31680 <secondary><command>ipliteral</command></secondary>
31681 </indexterm>
31682 This router has no private options. Unless it is being used purely for
31683 verification (see <option>verify_only</option>) a transport is required to be defined by the
31684 generic <option>transport</option> option. The router accepts the address if its domain part
31685 takes the form of an RFC 2822 domain literal. For example, the <command>ipliteral</command>
31686 router handles the address
31687 </para>
31688 <literallayout class="monospaced">
31689 root@[192.168.1.1]
31690 </literallayout>
31691 <para>
31692 by setting up delivery to the host with that IP address. IPv4 domain literals
31693 consist of an IPv4 address enclosed in square brackets. IPv6 domain literals
31694 are similar, but the address is preceded by <literal>ipv6:</literal>. For example:
31695 </para>
31696 <literallayout class="monospaced">
31697 postmaster@[ipv6:fe80::a00:20ff:fe86:a061.5678]
31698 </literallayout>
31699 <para>
31700 Exim allows <literal>ipv4:</literal> before IPv4 addresses, for consistency, and on the
31701 grounds that sooner or later somebody will try it.
31702 </para>
31703 <para>
31704 <indexterm role="option">
31705 <primary><option>self</option></primary>
31706 <secondary>in <command>ipliteral</command> router</secondary>
31707 </indexterm>
31708 If the IP address matches something in <option>ignore_target_hosts</option>, the router
31709 declines. If an IP literal turns out to refer to the local host, the generic
31710 <option>self</option> option determines what happens.
31711 </para>
31712 <para>
31713 The RFCs require support for domain literals; however, their use is
31714 controversial in today&#x2019;s Internet. If you want to use this router, you must
31715 also set the main configuration option <option>allow_domain_literals</option>. Otherwise,
31716 Exim will not recognize the domain literal syntax in addresses.
31717 </para>
31718 </chapter>
31719
31720 <chapter id="CHID6">
31721 <title>The iplookup router</title>
31722 <para>
31723 <indexterm role="concept">
31724 <primary><command>iplookup</command> router</primary>
31725 </indexterm>
31726 <indexterm role="concept">
31727 <primary>routers</primary>
31728 <secondary><command>iplookup</command></secondary>
31729 </indexterm>
31730 The <command>iplookup</command> router was written to fulfil a specific requirement in
31731 Cambridge University (which in fact no longer exists). For this reason, it is
31732 not included in the binary of Exim by default. If you want to include it, you
31733 must set
31734 </para>
31735 <literallayout class="monospaced">
31736 ROUTER_IPLOOKUP=yes
31737 </literallayout>
31738 <para>
31739 in your <filename>Local/Makefile</filename> configuration file.
31740 </para>
31741 <para>
31742 The <command>iplookup</command> router routes an address by sending it over a TCP or UDP
31743 connection to one or more specific hosts. The host can then return the same or
31744 a different address &ndash; in effect rewriting the recipient address in the
31745 message&#x2019;s envelope. The new address is then passed on to subsequent routers. If
31746 this process fails, the address can be passed on to other routers, or delivery
31747 can be deferred. Since <command>iplookup</command> is just a rewriting router, a transport
31748 must not be specified for it.
31749 </para>
31750 <para>
31751 <indexterm role="concept">
31752 <primary>options</primary>
31753 <secondary><command>iplookup</command> router</secondary>
31754 </indexterm>
31755 <indexterm role="option">
31756 <primary><option>hosts</option></primary>
31757 </indexterm>
31758 </para>
31759 <informaltable frame="all">
31760 <tgroup cols="4" colsep="0" rowsep="0">
31761 <colspec colwidth="8*" align="left"/>
31762 <colspec colwidth="6*" align="center"/>
31763 <colspec colwidth="6*" align="center"/>
31764 <colspec colwidth="6*" align="right"/>
31765 <tbody>
31766 <row>
31767 <entry><option>hosts</option></entry>
31768 <entry>Use: <emphasis>iplookup</emphasis></entry>
31769 <entry>Type: <emphasis>string</emphasis></entry>
31770 <entry>Default: <emphasis>unset</emphasis></entry>
31771 </row>
31772 </tbody>
31773 </tgroup>
31774 </informaltable>
31775 <para>
31776 This option must be supplied. Its value is a colon-separated list of host
31777 names. The hosts are looked up using <function>gethostbyname()</function>
31778 (or <function>getipnodebyname()</function> when available)
31779 and are tried in order until one responds to the query. If none respond, what
31780 happens is controlled by <option>optional</option>.
31781 </para>
31782 <para>
31783 <indexterm role="option">
31784 <primary><option>optional</option></primary>
31785 </indexterm>
31786 </para>
31787 <informaltable frame="all">
31788 <tgroup cols="4" colsep="0" rowsep="0">
31789 <colspec colwidth="8*" align="left"/>
31790 <colspec colwidth="6*" align="center"/>
31791 <colspec colwidth="6*" align="center"/>
31792 <colspec colwidth="6*" align="right"/>
31793 <tbody>
31794 <row>
31795 <entry><option>optional</option></entry>
31796 <entry>Use: <emphasis>iplookup</emphasis></entry>
31797 <entry>Type: <emphasis>boolean</emphasis></entry>
31798 <entry>Default: <emphasis>false</emphasis></entry>
31799 </row>
31800 </tbody>
31801 </tgroup>
31802 </informaltable>
31803 <para>
31804 If <option>optional</option> is true, if no response is obtained from any host, the address
31805 is passed to the next router, overriding <option>no_more</option>. If <option>optional</option> is false,
31806 delivery to the address is deferred.
31807 </para>
31808 <para>
31809 <indexterm role="option">
31810 <primary><option>port</option></primary>
31811 </indexterm>
31812 </para>
31813 <informaltable frame="all">
31814 <tgroup cols="4" colsep="0" rowsep="0">
31815 <colspec colwidth="8*" align="left"/>
31816 <colspec colwidth="6*" align="center"/>
31817 <colspec colwidth="6*" align="center"/>
31818 <colspec colwidth="6*" align="right"/>
31819 <tbody>
31820 <row>
31821 <entry><option>port</option></entry>
31822 <entry>Use: <emphasis>iplookup</emphasis></entry>
31823 <entry>Type: <emphasis>integer</emphasis></entry>
31824 <entry>Default: <emphasis>0</emphasis></entry>
31825 </row>
31826 </tbody>
31827 </tgroup>
31828 </informaltable>
31829 <para>
31830 <indexterm role="concept">
31831 <primary>port</primary>
31832 <secondary><command>iplookup</command> router</secondary>
31833 </indexterm>
31834 This option must be supplied. It specifies the port number for the TCP or UDP
31835 call.
31836 </para>
31837 <para>
31838 <indexterm role="option">
31839 <primary><option>protocol</option></primary>
31840 </indexterm>
31841 </para>
31842 <informaltable frame="all">
31843 <tgroup cols="4" colsep="0" rowsep="0">
31844 <colspec colwidth="8*" align="left"/>
31845 <colspec colwidth="6*" align="center"/>
31846 <colspec colwidth="6*" align="center"/>
31847 <colspec colwidth="6*" align="right"/>
31848 <tbody>
31849 <row>
31850 <entry><option>protocol</option></entry>
31851 <entry>Use: <emphasis>iplookup</emphasis></entry>
31852 <entry>Type: <emphasis>string</emphasis></entry>
31853 <entry>Default: <emphasis>udp</emphasis></entry>
31854 </row>
31855 </tbody>
31856 </tgroup>
31857 </informaltable>
31858 <para>
31859 This option can be set to <quote>udp</quote> or <quote>tcp</quote> to specify which of the two
31860 protocols is to be used.
31861 </para>
31862 <para>
31863 <indexterm role="option">
31864 <primary><option>query</option></primary>
31865 </indexterm>
31866 </para>
31867 <informaltable frame="all">
31868 <tgroup cols="4" colsep="0" rowsep="0">
31869 <colspec colwidth="8*" align="left"/>
31870 <colspec colwidth="6*" align="center"/>
31871 <colspec colwidth="6*" align="center"/>
31872 <colspec colwidth="6*" align="right"/>
31873 <tbody>
31874 <row>
31875 <entry><option>query</option></entry>
31876 <entry>Use: <emphasis>iplookup</emphasis></entry>
31877 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
31878 <entry>Default: <emphasis>see below</emphasis></entry>
31879 </row>
31880 </tbody>
31881 </tgroup>
31882 </informaltable>
31883 <para>
31884 This defines the content of the query that is sent to the remote hosts. The
31885 default value is:
31886 </para>
31887 <literallayout class="monospaced">
31888 $local_part@$domain $local_part@$domain
31889 </literallayout>
31890 <para>
31891 The repetition serves as a way of checking that a response is to the correct
31892 query in the default case (see <option>response_pattern</option> below).
31893 </para>
31894 <para>
31895 <indexterm role="option">
31896 <primary><option>reroute</option></primary>
31897 </indexterm>
31898 </para>
31899 <informaltable frame="all">
31900 <tgroup cols="4" colsep="0" rowsep="0">
31901 <colspec colwidth="8*" align="left"/>
31902 <colspec colwidth="6*" align="center"/>
31903 <colspec colwidth="6*" align="center"/>
31904 <colspec colwidth="6*" align="right"/>
31905 <tbody>
31906 <row>
31907 <entry><option>reroute</option></entry>
31908 <entry>Use: <emphasis>iplookup</emphasis></entry>
31909 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
31910 <entry>Default: <emphasis>unset</emphasis></entry>
31911 </row>
31912 </tbody>
31913 </tgroup>
31914 </informaltable>
31915 <para>
31916 If this option is not set, the rerouted address is precisely the byte string
31917 returned by the remote host, up to the first white space, if any. If set, the
31918 string is expanded to form the rerouted address. It can include parts matched
31919 in the response by <option>response_pattern</option> by means of numeric variables such as
31920 <varname>$1</varname>, <varname>$2</varname>, etc. The variable <varname>$0</varname> refers to the entire input string,
31921 whether or not a pattern is in use. In all cases, the rerouted address must end
31922 up in the form <emphasis>local_part@domain</emphasis>.
31923 </para>
31924 <para>
31925 <indexterm role="option">
31926 <primary><option>response_pattern</option></primary>
31927 </indexterm>
31928 </para>
31929 <informaltable frame="all">
31930 <tgroup cols="4" colsep="0" rowsep="0">
31931 <colspec colwidth="8*" align="left"/>
31932 <colspec colwidth="6*" align="center"/>
31933 <colspec colwidth="6*" align="center"/>
31934 <colspec colwidth="6*" align="right"/>
31935 <tbody>
31936 <row>
31937 <entry><option>response_pattern</option></entry>
31938 <entry>Use: <emphasis>iplookup</emphasis></entry>
31939 <entry>Type: <emphasis>string</emphasis></entry>
31940 <entry>Default: <emphasis>unset</emphasis></entry>
31941 </row>
31942 </tbody>
31943 </tgroup>
31944 </informaltable>
31945 <para>
31946 This option can be set to a regular expression that is applied to the string
31947 returned from the remote host. If the pattern does not match the response, the
31948 router declines. If <option>response_pattern</option> is not set, no checking of the
31949 response is done, unless the query was defaulted, in which case there is a
31950 check that the text returned after the first white space is the original
31951 address. This checks that the answer that has been received is in response to
31952 the correct question. For example, if the response is just a new domain, the
31953 following could be used:
31954 </para>
31955 <literallayout class="monospaced">
31956 response_pattern = ^([^@]+)$
31957 reroute = $local_part@$1
31958 </literallayout>
31959 <para>
31960 <indexterm role="option">
31961 <primary><option>timeout</option></primary>
31962 </indexterm>
31963 </para>
31964 <informaltable frame="all">
31965 <tgroup cols="4" colsep="0" rowsep="0">
31966 <colspec colwidth="8*" align="left"/>
31967 <colspec colwidth="6*" align="center"/>
31968 <colspec colwidth="6*" align="center"/>
31969 <colspec colwidth="6*" align="right"/>
31970 <tbody>
31971 <row>
31972 <entry><option>timeout</option></entry>
31973 <entry>Use: <emphasis>iplookup</emphasis></entry>
31974 <entry>Type: <emphasis>time</emphasis></entry>
31975 <entry>Default: <emphasis>5s</emphasis></entry>
31976 </row>
31977 </tbody>
31978 </tgroup>
31979 </informaltable>
31980 <para>
31981 This specifies the amount of time to wait for a response from the remote
31982 machine. The same timeout is used for the <function>connect()</function> function for a TCP
31983 call. It does not apply to UDP.
31984 </para>
31985 </chapter>
31986
31987 <chapter id="CHID7">
31988 <title>The manualroute router</title>
31989 <para>
31990 <indexterm role="concept" id="IIDmanrou1" class="startofrange">
31991 <primary><command>manualroute</command> router</primary>
31992 </indexterm>
31993 <indexterm role="concept" id="IIDmanrou2" class="startofrange">
31994 <primary>routers</primary>
31995 <secondary><command>manualroute</command></secondary>
31996 </indexterm>
31997 <indexterm role="concept">
31998 <primary>domain</primary>
31999 <secondary>manually routing</secondary>
32000 </indexterm>
32001 The <command>manualroute</command> router is so-called because it provides a way of manually
32002 routing an address according to its domain. It is mainly used when you want to
32003 route addresses to remote hosts according to your own rules, bypassing the
32004 normal DNS routing that looks up MX records. However, <command>manualroute</command> can also
32005 route to local transports, a facility that may be useful if you want to save
32006 messages for dial-in hosts in local files.
32007 </para>
32008 <para>
32009 The <command>manualroute</command> router compares a list of domain patterns with the domain
32010 it is trying to route. If there is no match, the router declines. Each pattern
32011 has associated with it a list of hosts and some other optional data, which may
32012 include a transport. The combination of a pattern and its data is called a
32013 <quote>routing rule</quote>. For patterns that do not have an associated transport, the
32014 generic <option>transport</option> option must specify a transport, unless the router is
32015 being used purely for verification (see <option>verify_only</option>).
32016 </para>
32017 <para>
32018 <indexterm role="variable">
32019 <primary><varname>$host</varname></primary>
32020 </indexterm>
32021 In the case of verification, matching the domain pattern is sufficient for the
32022 router to accept the address. When actually routing an address for delivery,
32023 an address that matches a domain pattern is queued for the associated
32024 transport. If the transport is not a local one, a host list must be associated
32025 with the pattern; IP addresses are looked up for the hosts, and these are
32026 passed to the transport along with the mail address. For local transports, a
32027 host list is optional. If it is present, it is passed in <varname>$host</varname> as a single
32028 text string.
32029 </para>
32030 <para>
32031 The list of routing rules can be provided as an inline string in
32032 <option>route_list</option>, or the data can be obtained by looking up the domain in a file
32033 or database by setting <option>route_data</option>. Only one of these settings may appear in
32034 any one instance of <command>manualroute</command>. The format of routing rules is described
32035 below, following the list of private options.
32036 </para>
32037 <section id="SECTprioptman">
32038 <title>Private options for manualroute</title>
32039 <para>
32040 <indexterm role="concept">
32041 <primary>options</primary>
32042 <secondary><command>manualroute</command> router</secondary>
32043 </indexterm>
32044 The private options for the <command>manualroute</command> router are as follows:
32045 </para>
32046 <para>
32047 <indexterm role="option">
32048 <primary><option>host_all_ignored</option></primary>
32049 </indexterm>
32050 </para>
32051 <informaltable frame="all">
32052 <tgroup cols="4" colsep="0" rowsep="0">
32053 <colspec colwidth="8*" align="left"/>
32054 <colspec colwidth="6*" align="center"/>
32055 <colspec colwidth="6*" align="center"/>
32056 <colspec colwidth="6*" align="right"/>
32057 <tbody>
32058 <row>
32059 <entry><option>host_all_ignored</option></entry>
32060 <entry>Use: <emphasis>manualroute</emphasis></entry>
32061 <entry>Type: <emphasis>string</emphasis></entry>
32062 <entry>Default: <emphasis>defer</emphasis></entry>
32063 </row>
32064 </tbody>
32065 </tgroup>
32066 </informaltable>
32067 <para>
32068 See <option>host_find_failed</option>.
32069 </para>
32070 <para>
32071 <indexterm role="option">
32072 <primary><option>host_find_failed</option></primary>
32073 </indexterm>
32074 </para>
32075 <informaltable frame="all">
32076 <tgroup cols="4" colsep="0" rowsep="0">
32077 <colspec colwidth="8*" align="left"/>
32078 <colspec colwidth="6*" align="center"/>
32079 <colspec colwidth="6*" align="center"/>
32080 <colspec colwidth="6*" align="right"/>
32081 <tbody>
32082 <row>
32083 <entry><option>host_find_failed</option></entry>
32084 <entry>Use: <emphasis>manualroute</emphasis></entry>
32085 <entry>Type: <emphasis>string</emphasis></entry>
32086 <entry>Default: <emphasis>freeze</emphasis></entry>
32087 </row>
32088 </tbody>
32089 </tgroup>
32090 </informaltable>
32091 <para>
32092 This option controls what happens when <command>manualroute</command> tries to find an IP
32093 address for a host, and the host does not exist. The option can be set to one
32094 of the following values:
32095 </para>
32096 <literallayout class="monospaced">
32097 decline
32098 defer
32099 fail
32100 freeze
32101 ignore
32102 pass
32103 </literallayout>
32104 <para>
32105 The default (<quote>freeze</quote>) assumes that this state is a serious configuration
32106 error. The difference between <quote>pass</quote> and <quote>decline</quote> is that the former
32107 forces the address to be passed to the next router (or the router defined by
32108 <option>pass_router</option>),
32109 <indexterm role="option">
32110 <primary><option>more</option></primary>
32111 </indexterm>
32112 overriding <option>no_more</option>, whereas the latter passes the address to the next
32113 router only if <option>more</option> is true.
32114 </para>
32115 <para>
32116 The value <quote>ignore</quote> causes Exim to completely ignore a host whose IP address
32117 cannot be found. If all the hosts in the list are ignored, the behaviour is
32118 controlled by the <option>host_all_ignored</option> option. This takes the same values
32119 as <option>host_find_failed</option>, except that it cannot be set to <quote>ignore</quote>.
32120 </para>
32121 <para>
32122 The <option>host_find_failed</option> option applies only to a definite <quote>does not exist</quote>
32123 state; if a host lookup gets a temporary error, delivery is deferred unless the
32124 generic <option>pass_on_timeout</option> option is set.
32125 </para>
32126 <para>
32127 <indexterm role="option">
32128 <primary><option>hosts_randomize</option></primary>
32129 </indexterm>
32130 </para>
32131 <informaltable frame="all">
32132 <tgroup cols="4" colsep="0" rowsep="0">
32133 <colspec colwidth="8*" align="left"/>
32134 <colspec colwidth="6*" align="center"/>
32135 <colspec colwidth="6*" align="center"/>
32136 <colspec colwidth="6*" align="right"/>
32137 <tbody>
32138 <row>
32139 <entry><option>hosts_randomize</option></entry>
32140 <entry>Use: <emphasis>manualroute</emphasis></entry>
32141 <entry>Type: <emphasis>boolean</emphasis></entry>
32142 <entry>Default: <emphasis>false</emphasis></entry>
32143 </row>
32144 </tbody>
32145 </tgroup>
32146 </informaltable>
32147 <para>
32148 <indexterm role="concept">
32149 <primary>randomized host list</primary>
32150 </indexterm>
32151 <indexterm role="concept">
32152 <primary>host</primary>
32153 <secondary>list of; randomized</secondary>
32154 </indexterm>
32155 If this option is set, the order of the items in a host list in a routing rule
32156 is randomized each time the list is used, unless an option in the routing rule
32157 overrides (see below). Randomizing the order of a host list can be used to do
32158 crude load sharing. However, if more than one mail address is routed by the
32159 same router to the same host list, the host lists are considered to be the same
32160 (even though they may be randomized into different orders) for the purpose of
32161 deciding whether to batch the deliveries into a single SMTP transaction.
32162 </para>
32163 <para>
32164 When <option>hosts_randomize</option> is true, a host list may be split
32165 into groups whose order is separately randomized. This makes it possible to
32166 set up MX-like behaviour. The boundaries between groups are indicated by an
32167 item that is just <literal>+</literal> in the host list. For example:
32168 </para>
32169 <literallayout class="monospaced">
32170 route_list = * host1:host2:host3:+:host4:host5
32171 </literallayout>
32172 <para>
32173 The order of the first three hosts and the order of the last two hosts is
32174 randomized for each use, but the first three always end up before the last two.
32175 If <option>hosts_randomize</option> is not set, a <literal>+</literal> item in the list is ignored. If a
32176 randomized host list is passed to an <command>smtp</command> transport that also has
32177 <option>hosts_randomize set</option>, the list is not re-randomized.
32178 </para>
32179 <para>
32180 <indexterm role="option">
32181 <primary><option>route_data</option></primary>
32182 </indexterm>
32183 </para>
32184 <informaltable frame="all">
32185 <tgroup cols="4" colsep="0" rowsep="0">
32186 <colspec colwidth="8*" align="left"/>
32187 <colspec colwidth="6*" align="center"/>
32188 <colspec colwidth="6*" align="center"/>
32189 <colspec colwidth="6*" align="right"/>
32190 <tbody>
32191 <row>
32192 <entry><option>route_data</option></entry>
32193 <entry>Use: <emphasis>manualroute</emphasis></entry>
32194 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32195 <entry>Default: <emphasis>unset</emphasis></entry>
32196 </row>
32197 </tbody>
32198 </tgroup>
32199 </informaltable>
32200 <para>
32201 If this option is set, it must expand to yield the data part of a routing rule.
32202 Typically, the expansion string includes a lookup based on the domain. For
32203 example:
32204 </para>
32205 <literallayout class="monospaced">
32206 route_data = ${lookup{$domain}dbm{/etc/routes}}
32207 </literallayout>
32208 <para>
32209 If the expansion is forced to fail, or the result is an empty string, the
32210 router declines. Other kinds of expansion failure cause delivery to be
32211 deferred.
32212 </para>
32213 <para>
32214 <indexterm role="option">
32215 <primary><option>route_list</option></primary>
32216 </indexterm>
32217 </para>
32218 <informaltable frame="all">
32219 <tgroup cols="4" colsep="0" rowsep="0">
32220 <colspec colwidth="8*" align="left"/>
32221 <colspec colwidth="6*" align="center"/>
32222 <colspec colwidth="6*" align="center"/>
32223 <colspec colwidth="6*" align="right"/>
32224 <tbody>
32225 <row>
32226 <entry><option>route_list</option></entry>
32227 <entry>Use: <emphasis>manualroute</emphasis></entry>
32228 <entry>Type: <emphasis>string list</emphasis></entry>
32229 <entry>Default: <emphasis>unset</emphasis></entry>
32230 </row>
32231 </tbody>
32232 </tgroup>
32233 </informaltable>
32234 <para>
32235 This string is a list of routing rules, in the form defined below. Note that,
32236 unlike most string lists, the items are separated by semicolons. This is so
32237 that they may contain colon-separated host lists.
32238 </para>
32239 <para>
32240 <indexterm role="option">
32241 <primary><option>same_domain_copy_routing</option></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="6*" align="center"/>
32248 <colspec colwidth="6*" align="center"/>
32249 <colspec colwidth="6*" align="right"/>
32250 <tbody>
32251 <row>
32252 <entry><option>same_domain_copy_routing</option></entry>
32253 <entry>Use: <emphasis>manualroute</emphasis></entry>
32254 <entry>Type: <emphasis>boolean</emphasis></entry>
32255 <entry>Default: <emphasis>false</emphasis></entry>
32256 </row>
32257 </tbody>
32258 </tgroup>
32259 </informaltable>
32260 <para>
32261 <indexterm role="concept">
32262 <primary>address</primary>
32263 <secondary>copying routing</secondary>
32264 </indexterm>
32265 Addresses with the same domain are normally routed by the <command>manualroute</command>
32266 router to the same list of hosts. However, this cannot be presumed, because the
32267 router options and preconditions may refer to the local part of the address. By
32268 default, therefore, Exim routes each address in a message independently. DNS
32269 servers run caches, so repeated DNS lookups are not normally expensive, and in
32270 any case, personal messages rarely have more than a few recipients.
32271 </para>
32272 <para>
32273 If you are running mailing lists with large numbers of subscribers at the same
32274 domain, and you are using a <command>manualroute</command> router which is independent of the
32275 local part, you can set <option>same_domain_copy_routing</option> to bypass repeated DNS
32276 lookups for identical domains in one message. In this case, when
32277 <command>manualroute</command> routes an address to a remote transport, any other unrouted
32278 addresses in the message that have the same domain are automatically given the
32279 same routing without processing them independently. However, this is only done
32280 if <option>headers_add</option> and <option>headers_remove</option> are unset.
32281 </para>
32282 </section>
32283 <section id="SECID120">
32284 <title>Routing rules in route_list</title>
32285 <para>
32286 The value of <option>route_list</option> is a string consisting of a sequence of routing
32287 rules, separated by semicolons. If a semicolon is needed in a rule, it can be
32288 entered as two semicolons. Alternatively, the list separator can be changed as
32289 described (for colon-separated lists) in section <xref linkend="SECTlistconstruct"/>.
32290 Empty rules are ignored. The format of each rule is
32291 </para>
32292 <literallayout>
32293 &lt;<emphasis>domain pattern</emphasis>&gt;  &lt;<emphasis>list of hosts</emphasis>&gt;  &lt;<emphasis>options</emphasis>&gt;
32294 </literallayout>
32295 <para>
32296 The following example contains two rules, each with a simple domain pattern and
32297 no options:
32298 </para>
32299 <literallayout class="monospaced">
32300 route_list = \
32301   dict.ref.example  mail-1.ref.example:mail-2.ref.example ; \
32302   thes.ref.example  mail-3.ref.example:mail-4.ref.example
32303 </literallayout>
32304 <para>
32305 The three parts of a rule are separated by white space. The pattern and the
32306 list of hosts can be enclosed in quotes if necessary, and if they are, the
32307 usual quoting rules apply. Each rule in a <option>route_list</option> must start with a
32308 single domain pattern, which is the only mandatory item in the rule. The
32309 pattern is in the same format as one item in a domain list (see section
32310 <xref linkend="SECTdomainlist"/>),
32311 except that it may not be the name of an interpolated file.
32312 That is, it may be wildcarded, or a regular expression, or a file or database
32313 lookup (with semicolons doubled, because of the use of semicolon as a separator
32314 in a <option>route_list</option>).
32315 </para>
32316 <para>
32317 The rules in <option>route_list</option> are searched in order until one of the patterns
32318 matches the domain that is being routed. The list of hosts and then options are
32319 then used as described below. If there is no match, the router declines. When
32320 <option>route_list</option> is set, <option>route_data</option> must not be set.
32321 </para>
32322 </section>
32323 <section id="SECID121">
32324 <title>Routing rules in route_data</title>
32325 <para>
32326 The use of <option>route_list</option> is convenient when there are only a small number of
32327 routing rules. For larger numbers, it is easier to use a file or database to
32328 hold the routing information, and use the <option>route_data</option> option instead.
32329 The value of <option>route_data</option> is a list of hosts, followed by (optional) options.
32330 Most commonly, <option>route_data</option> is set as a string that contains an
32331 expansion lookup. For example, suppose we place two routing rules in a file
32332 like this:
32333 </para>
32334 <literallayout class="monospaced">
32335 dict.ref.example:  mail-1.ref.example:mail-2.ref.example
32336 thes.ref.example:  mail-3.ref.example:mail-4.ref.example
32337 </literallayout>
32338 <para>
32339 This data can be accessed by setting
32340 </para>
32341 <literallayout class="monospaced">
32342 route_data = ${lookup{$domain}lsearch{/the/file/name}}
32343 </literallayout>
32344 <para>
32345 Failure of the lookup results in an empty string, causing the router to
32346 decline. However, you do not have to use a lookup in <option>route_data</option>. The only
32347 requirement is that the result of expanding the string is a list of hosts,
32348 possibly followed by options, separated by white space. The list of hosts must
32349 be enclosed in quotes if it contains white space.
32350 </para>
32351 </section>
32352 <section id="SECID122">
32353 <title>Format of the list of hosts</title>
32354 <para>
32355 A list of hosts, whether obtained via <option>route_data</option> or <option>route_list</option>, is
32356 always separately expanded before use. If the expansion fails, the router
32357 declines. The result of the expansion must be a colon-separated list of names
32358 and/or IP addresses, optionally also including ports. The format of each item
32359 in the list is described in the next section. The list separator can be changed
32360 as described in section <xref linkend="SECTlistconstruct"/>.
32361 </para>
32362 <para>
32363 If the list of hosts was obtained from a <option>route_list</option> item, the following
32364 variables are set during its expansion:
32365 </para>
32366 <itemizedlist>
32367 <listitem>
32368 <para>
32369 <indexterm role="concept">
32370 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname>  etc)</primary>
32371 <secondary>in <command>manualroute</command> router</secondary>
32372 </indexterm>
32373 If the domain was matched against a regular expression, the numeric variables
32374 <varname>$1</varname>, <varname>$2</varname>, etc. may be set. For example:
32375 </para>
32376 <literallayout class="monospaced">
32377 route_list = ^domain(\d+)   host-$1.text.example
32378 </literallayout>
32379 </listitem>
32380 <listitem>
32381 <para>
32382 <varname>$0</varname> is always set to the entire domain.
32383 </para>
32384 </listitem>
32385 <listitem>
32386 <para>
32387 <varname>$1</varname> is also set when partial matching is done in a file lookup.
32388 </para>
32389 </listitem>
32390 <listitem>
32391 <para>
32392 <indexterm role="variable">
32393 <primary><varname>$value</varname></primary>
32394 </indexterm>
32395 If the pattern that matched the domain was a lookup item, the data that was
32396 looked up is available in the expansion variable <varname>$value</varname>. For example:
32397 </para>
32398 <literallayout class="monospaced">
32399 route_list = lsearch;;/some/file.routes  $value
32400 </literallayout>
32401 </listitem>
32402 </itemizedlist>
32403 <para>
32404 Note the doubling of the semicolon in the pattern that is necessary because
32405 semicolon is the default route list separator.
32406 </para>
32407 </section>
32408 <section id="SECTformatonehostitem">
32409 <title>Format of one host item</title>
32410 <para>
32411 Each item in the list of hosts is either a host name or an IP address,
32412 optionally with an attached port number. When no port is given, an IP address
32413 is not enclosed in brackets. When a port is specified, it overrides the port
32414 specification on the transport. The port is separated from the name or address
32415 by a colon. This leads to some complications:
32416 </para>
32417 <itemizedlist>
32418 <listitem>
32419 <para>
32420 Because colon is the default separator for the list of hosts, either
32421 the colon that specifies a port must be doubled, or the list separator must
32422 be changed. The following two examples have the same effect:
32423 </para>
32424 <literallayout class="monospaced">
32425 route_list = * "host1.tld::1225 : host2.tld::1226"
32426 route_list = * "&lt;+ host1.tld:1225 + host2.tld:1226"
32427 </literallayout>
32428 </listitem>
32429 <listitem>
32430 <para>
32431 When IPv6 addresses are involved, it gets worse, because they contain
32432 colons of their own. To make this case easier, it is permitted to
32433 enclose an IP address (either v4 or v6) in square brackets if a port
32434 number follows. For example:
32435 </para>
32436 <literallayout class="monospaced">
32437 route_list = * "&lt;/ [10.1.1.1]:1225 / [::1]:1226"
32438 </literallayout>
32439 </listitem>
32440 </itemizedlist>
32441 </section>
32442 <section id="SECThostshowused">
32443 <title>How the list of hosts is used</title>
32444 <para>
32445 When an address is routed to an <command>smtp</command> transport by <command>manualroute</command>, each of
32446 the hosts is tried, in the order specified, when carrying out the SMTP
32447 delivery. However, the order can be changed by setting the <option>hosts_randomize</option>
32448 option, either on the router (see section <xref linkend="SECTprioptman"/> above), or on the
32449 transport.
32450 </para>
32451 <para>
32452 Hosts may be listed by name or by IP address. An unadorned name in the list of
32453 hosts is interpreted as a host name. A name that is followed by <literal>/MX</literal> is
32454 interpreted as an indirection to a sublist of hosts obtained by looking up MX
32455 records in the DNS. For example:
32456 </para>
32457 <literallayout class="monospaced">
32458 route_list = *  x.y.z:p.q.r/MX:e.f.g
32459 </literallayout>
32460 <para>
32461 If this feature is used with a port specifier, the port must come last. For
32462 example:
32463 </para>
32464 <literallayout class="monospaced">
32465 route_list = *  dom1.tld/mx::1225
32466 </literallayout>
32467 <para>
32468 If the <option>hosts_randomize</option> option is set, the order of the items in the list is
32469 randomized before any lookups are done. Exim then scans the list; for any name
32470 that is not followed by <literal>/MX</literal> it looks up an IP address. If this turns out to
32471 be an interface on the local host and the item is not the first in the list,
32472 Exim discards it and any subsequent items. If it is the first item, what
32473 happens is controlled by the
32474 <indexterm role="option">
32475 <primary><option>self</option></primary>
32476 <secondary>in <command>manualroute</command> router</secondary>
32477 </indexterm>
32478 <option>self</option> option of the router.
32479 </para>
32480 <para>
32481 A name on the list that is followed by <literal>/MX</literal> is replaced with the list of
32482 hosts obtained by looking up MX records for the name. This is always a DNS
32483 lookup; the <option>bydns</option> and <option>byname</option> options (see section <xref linkend="SECThowoptused"/>
32484 below) are not relevant here. The order of these hosts is determined by the
32485 preference values in the MX records, according to the usual rules. Because
32486 randomizing happens before the MX lookup, it does not affect the order that is
32487 defined by MX preferences.
32488 </para>
32489 <para>
32490 If the local host is present in the sublist obtained from MX records, but is
32491 not the most preferred host in that list, it and any equally or less
32492 preferred hosts are removed before the sublist is inserted into the main list.
32493 </para>
32494 <para>
32495 If the local host is the most preferred host in the MX list, what happens
32496 depends on where in the original list of hosts the <literal>/MX</literal> item appears. If it
32497 is not the first item (that is, there are previous hosts in the main list),
32498 Exim discards this name and any subsequent items in the main list.
32499 </para>
32500 <para>
32501 If the MX item is first in the list of hosts, and the local host is the
32502 most preferred host, what happens is controlled by the <option>self</option> option of the
32503 router.
32504 </para>
32505 <para>
32506 DNS failures when lookup up the MX records are treated in the same way as DNS
32507 failures when looking up IP addresses: <option>pass_on_timeout</option> and
32508 <option>host_find_failed</option> are used when relevant.
32509 </para>
32510 <para>
32511 The generic <option>ignore_target_hosts</option> option applies to all hosts in the list,
32512 whether obtained from an MX lookup or not.
32513 </para>
32514 </section>
32515 <section id="SECThowoptused">
32516 <title>How the options are used</title>
32517 <para>
32518 The options are a sequence of words; in practice no more than three are ever
32519 present. One of the words can be the name of a transport; this overrides the
32520 <option>transport</option> option on the router for this particular routing rule only. The
32521 other words (if present) control randomization of the list of hosts on a
32522 per-rule basis, and how the IP addresses of the hosts are to be found when
32523 routing to a remote transport. These options are as follows:
32524 </para>
32525 <itemizedlist>
32526 <listitem>
32527 <para>
32528 <option>randomize</option>: randomize the order of the hosts in this list, overriding the
32529 setting of <option>hosts_randomize</option> for this routing rule only.
32530 </para>
32531 </listitem>
32532 <listitem>
32533 <para>
32534 <option>no_randomize</option>: do not randomize the order of the hosts in this list,
32535 overriding the setting of <option>hosts_randomize</option> for this routing rule only.
32536 </para>
32537 </listitem>
32538 <listitem>
32539 <para>
32540 <option>byname</option>: use <function>getipnodebyname()</function> (<function>gethostbyname()</function> on older systems) to
32541 find IP addresses. This function may ultimately cause a DNS lookup, but it may
32542 also look in <filename>/etc/hosts</filename> or other sources of information.
32543 </para>
32544 </listitem>
32545 <listitem>
32546 <para>
32547 <option>bydns</option>: look up address records for the hosts directly in the DNS; fail if
32548 no address records are found. If there is a temporary DNS error (such as a
32549 timeout), delivery is deferred.
32550 </para>
32551 </listitem>
32552 </itemizedlist>
32553 <para>
32554 For example:
32555 </para>
32556 <literallayout class="monospaced">
32557 route_list = domain1  host1:host2:host3  randomize bydns;\
32558              domain2  host4:host5
32559 </literallayout>
32560 <para>
32561 If neither <option>byname</option> nor <option>bydns</option> is given, Exim behaves as follows: First, a
32562 DNS lookup is done. If this yields anything other than HOST_NOT_FOUND, that
32563 result is used. Otherwise, Exim goes on to try a call to <function>getipnodebyname()</function>
32564 or <function>gethostbyname()</function>, and the result of the lookup is the result of that
32565 call.
32566 </para>
32567 <para>
32568 <emphasis role="bold">Warning</emphasis>: It has been discovered that on some systems, if a DNS lookup
32569 called via <function>getipnodebyname()</function> times out, HOST_NOT_FOUND is returned
32570 instead of TRY_AGAIN. That is why the default action is to try a DNS
32571 lookup first. Only if that gives a definite <quote>no such host</quote> is the local
32572 function called.
32573 </para>
32574 <para>
32575 If no IP address for a host can be found, what happens is controlled by the
32576 <option>host_find_failed</option> option.
32577 </para>
32578 <para>
32579 <indexterm role="variable">
32580 <primary><varname>$host</varname></primary>
32581 </indexterm>
32582 When an address is routed to a local transport, IP addresses are not looked up.
32583 The host list is passed to the transport in the <varname>$host</varname> variable.
32584 </para>
32585 </section>
32586 <section id="SECID123">
32587 <title>Manualroute examples</title>
32588 <para>
32589 In some of the examples that follow, the presence of the <option>remote_smtp</option>
32590 transport, as defined in the default configuration file, is assumed:
32591 </para>
32592 <itemizedlist>
32593 <listitem>
32594 <para>
32595 <indexterm role="concept">
32596 <primary>smart host</primary>
32597 <secondary>example router</secondary>
32598 </indexterm>
32599 The <command>manualroute</command> router can be used to forward all external mail to a
32600 <emphasis>smart host</emphasis>. If you have set up, in the main part of the configuration, a
32601 named domain list that contains your local domains, for example:
32602 </para>
32603 <literallayout class="monospaced">
32604 domainlist local_domains = my.domain.example
32605 </literallayout>
32606 <para>
32607 You can arrange for all other domains to be routed to a smart host by making
32608 your first router something like this:
32609 </para>
32610 <literallayout class="monospaced">
32611 smart_route:
32612   driver = manualroute
32613   domains = !+local_domains
32614   transport = remote_smtp
32615   route_list = * smarthost.ref.example
32616 </literallayout>
32617 <para>
32618 This causes all non-local addresses to be sent to the single host
32619 <emphasis>smarthost.ref.example</emphasis>. If a colon-separated list of smart hosts is given,
32620 they are tried in order
32621 (but you can use <option>hosts_randomize</option> to vary the order each time).
32622 Another way of configuring the same thing is this:
32623 </para>
32624 <literallayout class="monospaced">
32625 smart_route:
32626   driver = manualroute
32627   transport = remote_smtp
32628   route_list = !+local_domains  smarthost.ref.example
32629 </literallayout>
32630 <para>
32631 There is no difference in behaviour between these two routers as they stand.
32632 However, they behave differently if <option>no_more</option> is added to them. In the first
32633 example, the router is skipped if the domain does not match the <option>domains</option>
32634 precondition; the following router is always tried. If the router runs, it
32635 always matches the domain and so can never decline. Therefore, <option>no_more</option>
32636 would have no effect. In the second case, the router is never skipped; it
32637 always runs. However, if it doesn&#x2019;t match the domain, it declines. In this case
32638 <option>no_more</option> would prevent subsequent routers from running.
32639 </para>
32640 </listitem>
32641 <listitem>
32642 <para>
32643 <indexterm role="concept">
32644 <primary>mail hub example</primary>
32645 </indexterm>
32646 A <emphasis>mail hub</emphasis> is a host which receives mail for a number of domains via MX
32647 records in the DNS and delivers it via its own private routing mechanism. Often
32648 the final destinations are behind a firewall, with the mail hub being the one
32649 machine that can connect to machines both inside and outside the firewall. The
32650 <command>manualroute</command> router is usually used on a mail hub to route incoming messages
32651 to the correct hosts. For a small number of domains, the routing can be inline,
32652 using the <option>route_list</option> option, but for a larger number a file or database
32653 lookup is easier to manage.
32654 </para>
32655 <para>
32656 If the domain names are in fact the names of the machines to which the mail is
32657 to be sent by the mail hub, the configuration can be quite simple. For
32658 example:
32659 </para>
32660 <literallayout class="monospaced">
32661 hub_route:
32662   driver = manualroute
32663   transport = remote_smtp
32664   route_list = *.rhodes.tvs.example  $domain
32665 </literallayout>
32666 <para>
32667 This configuration routes domains that match <literal>*.rhodes.tvs.example</literal> to hosts
32668 whose names are the same as the mail domains. A similar approach can be taken
32669 if the host name can be obtained from the domain name by a string manipulation
32670 that the expansion facilities can handle. Otherwise, a lookup based on the
32671 domain can be used to find the host:
32672 </para>
32673 <literallayout class="monospaced">
32674 through_firewall:
32675   driver = manualroute
32676   transport = remote_smtp
32677   route_data = ${lookup {$domain} cdb {/internal/host/routes}}
32678 </literallayout>
32679 <para>
32680 The result of the lookup must be the name or IP address of the host (or
32681 hosts) to which the address is to be routed. If the lookup fails, the route
32682 data is empty, causing the router to decline. The address then passes to the
32683 next router.
32684 </para>
32685 </listitem>
32686 <listitem>
32687 <para>
32688 <indexterm role="concept">
32689 <primary>batched SMTP output example</primary>
32690 </indexterm>
32691 <indexterm role="concept">
32692 <primary>SMTP</primary>
32693 <secondary>batched outgoing; example</secondary>
32694 </indexterm>
32695 You can use <command>manualroute</command> to deliver messages to pipes or files in batched
32696 SMTP format for onward transportation by some other means. This is one way of
32697 storing mail for a dial-up host when it is not connected. The route list entry
32698 can be as simple as a single domain name in a configuration like this:
32699 </para>
32700 <literallayout class="monospaced">
32701 save_in_file:
32702   driver = manualroute
32703   transport = batchsmtp_appendfile
32704   route_list = saved.domain.example
32705 </literallayout>
32706 <para>
32707 though often a pattern is used to pick up more than one domain. If there are
32708 several domains or groups of domains with different transport requirements,
32709 different transports can be listed in the routing information:
32710 </para>
32711 <literallayout class="monospaced">
32712 save_in_file:
32713   driver = manualroute
32714   route_list = \
32715     *.saved.domain1.example  $domain  batch_appendfile; \
32716     *.saved.domain2.example  \
32717       ${lookup{$domain}dbm{/domain2/hosts}{$value}fail} \
32718       batch_pipe
32719 </literallayout>
32720 <para>
32721 <indexterm role="variable">
32722 <primary><varname>$domain</varname></primary>
32723 </indexterm>
32724 <indexterm role="variable">
32725 <primary><varname>$host</varname></primary>
32726 </indexterm>
32727 The first of these just passes the domain in the <varname>$host</varname> variable, which
32728 doesn&#x2019;t achieve much (since it is also in <varname>$domain</varname>), but the second does a
32729 file lookup to find a value to pass, causing the router to decline to handle
32730 the address if the lookup fails.
32731 </para>
32732 </listitem>
32733 <listitem>
32734 <para>
32735 <indexterm role="concept">
32736 <primary>UUCP</primary>
32737 <secondary>example of router for</secondary>
32738 </indexterm>
32739 Routing mail directly to UUCP software is a specific case of the use of
32740 <command>manualroute</command> in a gateway to another mail environment. This is an example of
32741 one way it can be done:
32742 </para>
32743 <literallayout class="monospaced">
32744 # Transport
32745 uucp:
32746   driver = pipe
32747   user = nobody
32748   command = /usr/local/bin/uux -r - \
32749     ${substr_-5:$host}!rmail ${local_part}
32750   return_fail_output = true
32751
32752 # Router
32753 uucphost:
32754   transport = uucp
32755   driver = manualroute
32756   route_data = \
32757     ${lookup{$domain}lsearch{/usr/local/exim/uucphosts}}
32758 </literallayout>
32759 <para>
32760 The file <filename>/usr/local/exim/uucphosts</filename> contains entries like
32761 </para>
32762 <literallayout class="monospaced">
32763 darksite.ethereal.example:           darksite.UUCP
32764 </literallayout>
32765 <para>
32766 It can be set up more simply without adding and removing <quote>.UUCP</quote> but this way
32767 makes clear the distinction between the domain name
32768 <emphasis>darksite.ethereal.example</emphasis> and the UUCP host name <emphasis>darksite</emphasis>.
32769 </para>
32770 </listitem>
32771 </itemizedlist>
32772 <para>
32773 <indexterm role="concept" startref="IIDmanrou1" class="endofrange"/>
32774 <indexterm role="concept" startref="IIDmanrou2" class="endofrange"/>
32775 </para>
32776 </section>
32777 </chapter>
32778
32779 <chapter id="CHAPdriverlast">
32780 <title>The queryprogram router</title>
32781 <para>
32782 <indexterm role="concept" id="IIDquerou1" class="startofrange">
32783 <primary><command>queryprogram</command> router</primary>
32784 </indexterm>
32785 <indexterm role="concept" id="IIDquerou2" class="startofrange">
32786 <primary>routers</primary>
32787 <secondary><command>queryprogram</command></secondary>
32788 </indexterm>
32789 <indexterm role="concept">
32790 <primary>routing</primary>
32791 <secondary>by external program</secondary>
32792 </indexterm>
32793 The <command>queryprogram</command> router routes an address by running an external command
32794 and acting on its output. This is an expensive way to route, and is intended
32795 mainly for use in lightly-loaded systems, or for performing experiments.
32796 However, if it is possible to use the precondition options (<option>domains</option>,
32797 <option>local_parts</option>, etc) to skip this router for most addresses, it could sensibly
32798 be used in special cases, even on a busy host. There are the following private
32799 options:
32800 <indexterm role="concept">
32801 <primary>options</primary>
32802 <secondary><command>queryprogram</command> router</secondary>
32803 </indexterm>
32804 </para>
32805 <para>
32806 <indexterm role="option">
32807 <primary><option>command</option></primary>
32808 </indexterm>
32809 </para>
32810 <informaltable frame="all">
32811 <tgroup cols="4" colsep="0" rowsep="0">
32812 <colspec colwidth="8*" align="left"/>
32813 <colspec colwidth="6*" align="center"/>
32814 <colspec colwidth="6*" align="center"/>
32815 <colspec colwidth="6*" align="right"/>
32816 <tbody>
32817 <row>
32818 <entry><option>command</option></entry>
32819 <entry>Use: <emphasis>queryprogram</emphasis></entry>
32820 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32821 <entry>Default: <emphasis>unset</emphasis></entry>
32822 </row>
32823 </tbody>
32824 </tgroup>
32825 </informaltable>
32826 <para>
32827 This option must be set. It specifies the command that is to be run. The
32828 command is split up into a command name and arguments, and then each is
32829 expanded separately (exactly as for a <command>pipe</command> transport, described in chapter
32830 <xref linkend="CHAPpipetransport"/>).
32831 </para>
32832 <para>
32833 <indexterm role="option">
32834 <primary><option>command_group</option></primary>
32835 </indexterm>
32836 </para>
32837 <informaltable frame="all">
32838 <tgroup cols="4" colsep="0" rowsep="0">
32839 <colspec colwidth="8*" align="left"/>
32840 <colspec colwidth="6*" align="center"/>
32841 <colspec colwidth="6*" align="center"/>
32842 <colspec colwidth="6*" align="right"/>
32843 <tbody>
32844 <row>
32845 <entry><option>command_group</option></entry>
32846 <entry>Use: <emphasis>queryprogram</emphasis></entry>
32847 <entry>Type: <emphasis>string</emphasis></entry>
32848 <entry>Default: <emphasis>unset</emphasis></entry>
32849 </row>
32850 </tbody>
32851 </tgroup>
32852 </informaltable>
32853 <para>
32854 <indexterm role="concept">
32855 <primary>gid (group id)</primary>
32856 <secondary>in <command>queryprogram</command> router</secondary>
32857 </indexterm>
32858 This option specifies a gid to be set when running the command while routing an
32859 address for deliver. It must be set if <option>command_user</option> specifies a numerical
32860 uid. If it begins with a digit, it is interpreted as the numerical value of the
32861 gid. Otherwise it is looked up using <function>getgrnam()</function>.
32862 </para>
32863 <para>
32864 <indexterm role="option">
32865 <primary><option>command_user</option></primary>
32866 </indexterm>
32867 </para>
32868 <informaltable frame="all">
32869 <tgroup cols="4" colsep="0" rowsep="0">
32870 <colspec colwidth="8*" align="left"/>
32871 <colspec colwidth="6*" align="center"/>
32872 <colspec colwidth="6*" align="center"/>
32873 <colspec colwidth="6*" align="right"/>
32874 <tbody>
32875 <row>
32876 <entry><option>command_user</option></entry>
32877 <entry>Use: <emphasis>queryprogram</emphasis></entry>
32878 <entry>Type: <emphasis>string</emphasis></entry>
32879 <entry>Default: <emphasis>unset</emphasis></entry>
32880 </row>
32881 </tbody>
32882 </tgroup>
32883 </informaltable>
32884 <para>
32885 <indexterm role="concept">
32886 <primary>uid (user id)</primary>
32887 <secondary>for <command>queryprogram</command></secondary>
32888 </indexterm>
32889 This option must be set. It specifies the uid which is set when running the
32890 command while routing an address for delivery. If the value begins with a digit,
32891 it is interpreted as the numerical value of the uid. Otherwise, it is looked up
32892 using <function>getpwnam()</function> to obtain a value for the uid and, if <option>command_group</option> is
32893 not set, a value for the gid also.
32894 </para>
32895 <para>
32896 <emphasis role="bold">Warning:</emphasis> Changing uid and gid is possible only when Exim is running as
32897 root, which it does during a normal delivery in a conventional configuration.
32898 However, when an address is being verified during message reception, Exim is
32899 usually running as the Exim user, not as root. If the <command>queryprogram</command> router
32900 is called from a non-root process, Exim cannot change uid or gid before running
32901 the command. In this circumstance the command runs under the current uid and
32902 gid.
32903 </para>
32904 <para>
32905 <indexterm role="option">
32906 <primary><option>current_directory</option></primary>
32907 </indexterm>
32908 </para>
32909 <informaltable frame="all">
32910 <tgroup cols="4" colsep="0" rowsep="0">
32911 <colspec colwidth="8*" align="left"/>
32912 <colspec colwidth="6*" align="center"/>
32913 <colspec colwidth="6*" align="center"/>
32914 <colspec colwidth="6*" align="right"/>
32915 <tbody>
32916 <row>
32917 <entry><option>current_directory</option></entry>
32918 <entry>Use: <emphasis>queryprogram</emphasis></entry>
32919 <entry>Type: <emphasis>string</emphasis></entry>
32920 <entry>Default: <emphasis>/</emphasis></entry>
32921 </row>
32922 </tbody>
32923 </tgroup>
32924 </informaltable>
32925 <para>
32926 This option specifies an absolute path which is made the current directory
32927 before running the command.
32928 </para>
32929 <para>
32930 <indexterm role="option">
32931 <primary><option>timeout</option></primary>
32932 </indexterm>
32933 </para>
32934 <informaltable frame="all">
32935 <tgroup cols="4" colsep="0" rowsep="0">
32936 <colspec colwidth="8*" align="left"/>
32937 <colspec colwidth="6*" align="center"/>
32938 <colspec colwidth="6*" align="center"/>
32939 <colspec colwidth="6*" align="right"/>
32940 <tbody>
32941 <row>
32942 <entry><option>timeout</option></entry>
32943 <entry>Use: <emphasis>queryprogram</emphasis></entry>
32944 <entry>Type: <emphasis>time</emphasis></entry>
32945 <entry>Default: <emphasis>1h</emphasis></entry>
32946 </row>
32947 </tbody>
32948 </tgroup>
32949 </informaltable>
32950 <para>
32951 If the command does not complete within the timeout period, its process group
32952 is killed and the message is frozen. A value of zero time specifies no
32953 timeout.
32954 </para>
32955 <para>
32956 The standard output of the command is connected to a pipe, which is read when
32957 the command terminates. It should consist of a single line of output,
32958 containing up to five fields, separated by white space. The maximum length of
32959 the line is 1023 characters. Longer lines are silently truncated. The first
32960 field is one of the following words (case-insensitive):
32961 </para>
32962 <itemizedlist>
32963 <listitem>
32964 <para>
32965 <emphasis>Accept</emphasis>: routing succeeded; the remaining fields specify what to do (see
32966 below).
32967 </para>
32968 </listitem>
32969 <listitem>
32970 <para>
32971 <emphasis>Decline</emphasis>: the router declines; pass the address to the next router, unless
32972 <option>no_more</option> is set.
32973 </para>
32974 </listitem>
32975 <listitem>
32976 <para>
32977 <emphasis>Fail</emphasis>: routing failed; do not pass the address to any more routers. Any
32978 subsequent text on the line is an error message. If the router is run as part
32979 of address verification during an incoming SMTP message, the message is
32980 included in the SMTP response.
32981 </para>
32982 </listitem>
32983 <listitem>
32984 <para>
32985 <emphasis>Defer</emphasis>: routing could not be completed at this time; try again later. Any
32986 subsequent text on the line is an error message which is logged. It is not
32987 included in any SMTP response.
32988 </para>
32989 </listitem>
32990 <listitem>
32991 <para>
32992 <emphasis>Freeze</emphasis>: the same as <emphasis>defer</emphasis>, except that the message is frozen.
32993 </para>
32994 </listitem>
32995 <listitem>
32996 <para>
32997 <emphasis>Pass</emphasis>: pass the address to the next router (or the router specified by
32998 <option>pass_router</option>), overriding <option>no_more</option>.
32999 </para>
33000 </listitem>
33001 <listitem>
33002 <para>
33003 <emphasis>Redirect</emphasis>: the message is redirected. The remainder of the line is a list of
33004 new addresses, which are routed independently, starting with the first router,
33005 or the router specified by <option>redirect_router</option>, if set.
33006 </para>
33007 </listitem>
33008 </itemizedlist>
33009 <para>
33010 When the first word is <emphasis>accept</emphasis>, the remainder of the line consists of a
33011 number of keyed data values, as follows (split into two lines here, to fit on
33012 the page):
33013 </para>
33014 <literallayout class="monospaced">
33015 ACCEPT TRANSPORT=&lt;transport&gt; HOSTS=&lt;list of hosts&gt;
33016 LOOKUP=byname|bydns DATA=&lt;text&gt;
33017 </literallayout>
33018 <para>
33019 The data items can be given in any order, and all are optional. If no transport
33020 is included, the transport specified by the generic <option>transport</option> option is
33021 used. The list of hosts and the lookup type are needed only if the transport is
33022 an <command>smtp</command> transport that does not itself supply a list of hosts.
33023 </para>
33024 <para>
33025 The format of the list of hosts is the same as for the <command>manualroute</command> router.
33026 As well as host names and IP addresses with optional port numbers, as described
33027 in section <xref linkend="SECTformatonehostitem"/>, it may contain names followed by
33028 <literal>/MX</literal> to specify sublists of hosts that are obtained by looking up MX records
33029 (see section <xref linkend="SECThostshowused"/>).
33030 </para>
33031 <para>
33032 If the lookup type is not specified, Exim behaves as follows when trying to
33033 find an IP address for each host: First, a DNS lookup is done. If this yields
33034 anything other than HOST_NOT_FOUND, that result is used. Otherwise, Exim
33035 goes on to try a call to <function>getipnodebyname()</function> or <function>gethostbyname()</function>, and the
33036 result of the lookup is the result of that call.
33037 </para>
33038 <para>
33039 <indexterm role="variable">
33040 <primary><varname>$address_data</varname></primary>
33041 </indexterm>
33042 If the DATA field is set, its value is placed in the <varname>$address_data</varname>
33043 variable. For example, this return line
33044 </para>
33045 <literallayout class="monospaced">
33046 accept hosts=x1.y.example:x2.y.example data="rule1"
33047 </literallayout>
33048 <para>
33049 routes the address to the default transport, passing a list of two hosts. When
33050 the transport runs, the string <quote>rule1</quote> is in <varname>$address_data</varname>.
33051 <indexterm role="concept" startref="IIDquerou1" class="endofrange"/>
33052 <indexterm role="concept" startref="IIDquerou2" class="endofrange"/>
33053 </para>
33054 </chapter>
33055
33056 <chapter id="CHAPredirect">
33057 <title>The redirect router</title>
33058 <para>
33059 <indexterm role="concept" id="IIDredrou1" class="startofrange">
33060 <primary><command>redirect</command> router</primary>
33061 </indexterm>
33062 <indexterm role="concept" id="IIDredrou2" class="startofrange">
33063 <primary>routers</primary>
33064 <secondary><command>redirect</command></secondary>
33065 </indexterm>
33066 <indexterm role="concept">
33067 <primary>alias file</primary>
33068 <secondary>in a <command>redirect</command> router</secondary>
33069 </indexterm>
33070 <indexterm role="concept">
33071 <primary>address redirection</primary>
33072 <secondary><command>redirect</command> router</secondary>
33073 </indexterm>
33074 The <command>redirect</command> router handles several kinds of address redirection. Its most
33075 common uses are for resolving local part aliases from a central alias file
33076 (usually called <filename>/etc/aliases</filename>) and for handling users&#x2019; personal <filename>.forward</filename>
33077 files, but it has many other potential uses. The incoming address can be
33078 redirected in several different ways:
33079 </para>
33080 <itemizedlist>
33081 <listitem>
33082 <para>
33083 It can be replaced by one or more new addresses which are themselves routed
33084 independently.
33085 </para>
33086 </listitem>
33087 <listitem>
33088 <para>
33089 It can be routed to be delivered to a given file or directory.
33090 </para>
33091 </listitem>
33092 <listitem>
33093 <para>
33094 It can be routed to be delivered to a specified pipe command.
33095 </para>
33096 </listitem>
33097 <listitem>
33098 <para>
33099 It can cause an automatic reply to be generated.
33100 </para>
33101 </listitem>
33102 <listitem>
33103 <para>
33104 It can be forced to fail, optionally with a custom error message.
33105 </para>
33106 </listitem>
33107 <listitem>
33108 <para>
33109 It can be temporarily deferred, optionally with a custom message.
33110 </para>
33111 </listitem>
33112 <listitem>
33113 <para>
33114 It can be discarded.
33115 </para>
33116 </listitem>
33117 </itemizedlist>
33118 <para>
33119 The generic <option>transport</option> option must not be set for <command>redirect</command> routers.
33120 However, there are some private options which define transports for delivery to
33121 files and pipes, and for generating autoreplies. See the <option>file_transport</option>,
33122 <option>pipe_transport</option> and <option>reply_transport</option> descriptions below.
33123 </para>
33124 <section id="SECID124">
33125 <title>Redirection data</title>
33126 <para>
33127 The router operates by interpreting a text string which it obtains either by
33128 expanding the contents of the <option>data</option> option, or by reading the entire
33129 contents of a file whose name is given in the <option>file</option> option. These two
33130 options are mutually exclusive. The first is commonly used for handling system
33131 aliases, in a configuration like this:
33132 </para>
33133 <literallayout class="monospaced">
33134 system_aliases:
33135   driver = redirect
33136   data = ${lookup{$local_part}lsearch{/etc/aliases}}
33137 </literallayout>
33138 <para>
33139 If the lookup fails, the expanded string in this example is empty. When the
33140 expansion of <option>data</option> results in an empty string, the router declines. A forced
33141 expansion failure also causes the router to decline; other expansion failures
33142 cause delivery to be deferred.
33143 </para>
33144 <para>
33145 A configuration using <option>file</option> is commonly used for handling users&#x2019;
33146 <filename>.forward</filename> files, like this:
33147 </para>
33148 <literallayout class="monospaced">
33149 userforward:
33150   driver = redirect
33151   check_local_user
33152   file = $home/.forward
33153   no_verify
33154 </literallayout>
33155 <para>
33156 If the file does not exist, or causes no action to be taken (for example, it is
33157 empty or consists only of comments), the router declines. <emphasis role="bold">Warning</emphasis>: This
33158 is not the case when the file contains syntactically valid items that happen to
33159 yield empty addresses, for example, items containing only RFC 2822 address
33160 comments.
33161 </para>
33162 </section>
33163 <section id="SECID125">
33164 <title>Forward files and address verification</title>
33165 <para>
33166 <indexterm role="concept">
33167 <primary>address redirection</primary>
33168 <secondary>while verifying</secondary>
33169 </indexterm>
33170 It is usual to set <option>no_verify</option> on <command>redirect</command> routers which handle users&#x2019;
33171 <filename>.forward</filename> files, as in the example above. There are two reasons for this:
33172 </para>
33173 <itemizedlist>
33174 <listitem>
33175 <para>
33176 When Exim is receiving an incoming SMTP message from a remote host, it is
33177 running under the Exim uid, not as root. Exim is unable to change uid to read
33178 the file as the user, and it may not be able to read it as the Exim user. So in
33179 practice the router may not be able to operate.
33180 </para>
33181 </listitem>
33182 <listitem>
33183 <para>
33184 However, even when the router can operate, the existence of a <filename>.forward</filename> file
33185 is unimportant when verifying an address. What should be checked is whether the
33186 local part is a valid user name or not. Cutting out the redirection processing
33187 saves some resources.
33188 </para>
33189 </listitem>
33190 </itemizedlist>
33191 </section>
33192 <section id="SECID126">
33193 <title>Interpreting redirection data</title>
33194 <para>
33195 <indexterm role="concept">
33196 <primary>Sieve filter</primary>
33197 <secondary>specifying in redirection data</secondary>
33198 </indexterm>
33199 <indexterm role="concept">
33200 <primary>filter</primary>
33201 <secondary>specifying in redirection data</secondary>
33202 </indexterm>
33203 The contents of the data string, whether obtained from <option>data</option> or <option>file</option>,
33204 can be interpreted in two different ways:
33205 </para>
33206 <itemizedlist>
33207 <listitem>
33208 <para>
33209 If the <option>allow_filter</option> option is set true, and the data begins with the text
33210 <quote>#Exim filter</quote> or <quote>#Sieve filter</quote>, it is interpreted as a list of
33211 <emphasis>filtering</emphasis> instructions in the form of an Exim or Sieve filter file,
33212 respectively. Details of the syntax and semantics of filter files are described
33213 in a separate document entitled <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis>; this
33214 document is intended for use by end users.
33215 </para>
33216 </listitem>
33217 <listitem>
33218 <para>
33219 Otherwise, the data must be a comma-separated list of redirection items, as
33220 described in the next section.
33221 </para>
33222 </listitem>
33223 </itemizedlist>
33224 <para>
33225 When a message is redirected to a file (a <quote>mail folder</quote>), the file name given
33226 in a non-filter redirection list must always be an absolute path. A filter may
33227 generate a relative path &ndash; how this is handled depends on the transport&#x2019;s
33228 configuration. See section <xref linkend="SECTfildiropt"/> for a discussion of this issue
33229 for the <command>appendfile</command> transport.
33230 </para>
33231 </section>
33232 <section id="SECTitenonfilred">
33233 <title>Items in a non-filter redirection list</title>
33234 <para>
33235 <indexterm role="concept">
33236 <primary>address redirection</primary>
33237 <secondary>non-filter list items</secondary>
33238 </indexterm>
33239 When the redirection data is not an Exim or Sieve filter, for example, if it
33240 comes from a conventional alias or forward file, it consists of a list of
33241 addresses, file names, pipe commands, or certain special items (see section
33242 <xref linkend="SECTspecitredli"/> below). The special items can be individually enabled or
33243 disabled by means of options whose names begin with <option>allow_</option> or <option>forbid_</option>,
33244 depending on their default values. The items in the list are separated by
33245 commas or newlines.
33246 If a comma is required in an item, the entire item must be enclosed in double
33247 quotes.
33248 </para>
33249 <para>
33250 Lines starting with a # character are comments, and are ignored, and # may
33251 also appear following a comma, in which case everything between the # and the
33252 next newline character is ignored.
33253 </para>
33254 <para>
33255 If an item is entirely enclosed in double quotes, these are removed. Otherwise
33256 double quotes are retained because some forms of mail address require their use
33257 (but never to enclose the entire address). In the following description,
33258 <quote>item</quote> refers to what remains after any surrounding double quotes have been
33259 removed.
33260 </para>
33261 <para>
33262 <indexterm role="variable">
33263 <primary><varname>$local_part</varname></primary>
33264 </indexterm>
33265 <emphasis role="bold">Warning</emphasis>: If you use an Exim expansion to construct a redirection address,
33266 and the expansion contains a reference to <varname>$local_part</varname>, you should make use
33267 of the <option>quote_local_part</option> expansion operator, in case the local part contains
33268 special characters. For example, to redirect all mail for the domain
33269 <emphasis>obsolete.example</emphasis>, retaining the existing local part, you could use this
33270 setting:
33271 </para>
33272 <literallayout class="monospaced">
33273 data = ${quote_local_part:$local_part}@newdomain.example
33274 </literallayout>
33275 </section>
33276 <section id="SECTredlocmai">
33277 <title>Redirecting to a local mailbox</title>
33278 <para>
33279 <indexterm role="concept">
33280 <primary>routing</primary>
33281 <secondary>loops in</secondary>
33282 </indexterm>
33283 <indexterm role="concept">
33284 <primary>loop</primary>
33285 <secondary>while routing, avoidance of</secondary>
33286 </indexterm>
33287 <indexterm role="concept">
33288 <primary>address redirection</primary>
33289 <secondary>to local mailbox</secondary>
33290 </indexterm>
33291 A redirection item may safely be the same as the address currently under
33292 consideration. This does not cause a routing loop, because a router is
33293 automatically skipped if any ancestor of the address that is being processed
33294 is the same as the current address and was processed by the current router.
33295 Such an address is therefore passed to the following routers, so it is handled
33296 as if there were no redirection. When making this loop-avoidance test, the
33297 complete local part, including any prefix or suffix, is used.
33298 </para>
33299 <para>
33300 <indexterm role="concept">
33301 <primary>address redirection</primary>
33302 <secondary>local part without domain</secondary>
33303 </indexterm>
33304 Specifying the same local part without a domain is a common usage in personal
33305 filter files when the user wants to have messages delivered to the local
33306 mailbox and also forwarded elsewhere. For example, the user whose login is
33307 <emphasis>cleo</emphasis> might have a <filename>.forward</filename> file containing this:
33308 </para>
33309 <literallayout class="monospaced">
33310 cleo, cleopatra@egypt.example
33311 </literallayout>
33312 <para>
33313 <indexterm role="concept">
33314 <primary>backslash in alias file</primary>
33315 </indexterm>
33316 <indexterm role="concept">
33317 <primary>alias file</primary>
33318 <secondary>backslash in</secondary>
33319 </indexterm>
33320 For compatibility with other MTAs, such unqualified local parts may be
33321 preceded by <quote>\</quote>, but this is not a requirement for loop prevention. However,
33322 it does make a difference if more than one domain is being handled
33323 synonymously.
33324 </para>
33325 <para>
33326 If an item begins with <quote>\</quote> and the rest of the item parses as a valid RFC
33327 2822 address that does not include a domain, the item is qualified using the
33328 domain of the incoming address. In the absence of a leading <quote>\</quote>, unqualified
33329 addresses are qualified using the value in <option>qualify_recipient</option>, but you can
33330 force the incoming domain to be used by setting <option>qualify_preserve_domain</option>.
33331 </para>
33332 <para>
33333 Care must be taken if there are alias names for local users.
33334 Consider an MTA handling a single local domain where the system alias file
33335 contains:
33336 </para>
33337 <literallayout class="monospaced">
33338 Sam.Reman: spqr
33339 </literallayout>
33340 <para>
33341 Now suppose that Sam (whose login id is <emphasis>spqr</emphasis>) wants to save copies of
33342 messages in the local mailbox, and also forward copies elsewhere. He creates
33343 this forward file:
33344 </para>
33345 <literallayout class="monospaced">
33346 Sam.Reman, spqr@reme.elsewhere.example
33347 </literallayout>
33348 <para>
33349 With these settings, an incoming message addressed to <emphasis>Sam.Reman</emphasis> fails. The
33350 <command>redirect</command> router for system aliases does not process <emphasis>Sam.Reman</emphasis> the
33351 second time round, because it has previously routed it,
33352 and the following routers presumably cannot handle the alias. The forward file
33353 should really contain
33354 </para>
33355 <literallayout class="monospaced">
33356 spqr, spqr@reme.elsewhere.example
33357 </literallayout>
33358 <para>
33359 but because this is such a common error, the <option>check_ancestor</option> option (see
33360 below) exists to provide a way to get round it. This is normally set on a
33361 <command>redirect</command> router that is handling users&#x2019; <filename>.forward</filename> files.
33362 </para>
33363 </section>
33364 <section id="SECTspecitredli">
33365 <title>Special items in redirection lists</title>
33366 <para>
33367 In addition to addresses, the following types of item may appear in redirection
33368 lists (that is, in non-filter redirection data):
33369 </para>
33370 <itemizedlist>
33371 <listitem>
33372 <para>
33373 <indexterm role="concept">
33374 <primary>pipe</primary>
33375 <secondary>in redirection list</secondary>
33376 </indexterm>
33377 <indexterm role="concept">
33378 <primary>address redirection</primary>
33379 <secondary>to pipe</secondary>
33380 </indexterm>
33381 An item is treated as a pipe command if it begins with <quote>|</quote> and does not parse
33382 as a valid RFC 2822 address that includes a domain. A transport for running the
33383 command must be specified by the <option>pipe_transport</option> option.
33384 Normally, either the router or the transport specifies a user and a group under
33385 which to run the delivery. The default is to use the Exim user and group.
33386 </para>
33387 <para>
33388 Single or double quotes can be used for enclosing the individual arguments of
33389 the pipe command; no interpretation of escapes is done for single quotes. If
33390 the command contains a comma character, it is necessary to put the whole item
33391 in double quotes, for example:
33392 </para>
33393 <literallayout class="monospaced">
33394 "|/some/command ready,steady,go"
33395 </literallayout>
33396 <para>
33397 since items in redirection lists are terminated by commas. Do not, however,
33398 quote just the command. An item such as
33399 </para>
33400 <literallayout class="monospaced">
33401 |"/some/command ready,steady,go"
33402 </literallayout>
33403 <para>
33404 is interpreted as a pipe with a rather strange command name, and no arguments.
33405 </para>
33406 </listitem>
33407 <listitem>
33408 <para>
33409 <indexterm role="concept">
33410 <primary>file</primary>
33411 <secondary>in redirection list</secondary>
33412 </indexterm>
33413 <indexterm role="concept">
33414 <primary>address redirection</primary>
33415 <secondary>to file</secondary>
33416 </indexterm>
33417 An item is interpreted as a path name if it begins with <quote>/</quote> and does not
33418 parse as a valid RFC 2822 address that includes a domain. For example,
33419 </para>
33420 <literallayout class="monospaced">
33421 /home/world/minbari
33422 </literallayout>
33423 <para>
33424 is treated as a file name, but
33425 </para>
33426 <literallayout class="monospaced">
33427 /s=molari/o=babylon/@x400gate.way
33428 </literallayout>
33429 <para>
33430 is treated as an address. For a file name, a transport must be specified using
33431 the <option>file_transport</option> option. However, if the generated path name ends with a
33432 forward slash character, it is interpreted as a directory name rather than a
33433 file name, and <option>directory_transport</option> is used instead.
33434 </para>
33435 <para>
33436 Normally, either the router or the transport specifies a user and a group under
33437 which to run the delivery. The default is to use the Exim user and group.
33438 </para>
33439 <para>
33440 <indexterm role="concept">
33441 <primary><filename>/dev/null</filename></primary>
33442 </indexterm>
33443 However, if a redirection item is the path <filename>/dev/null</filename>, delivery to it is
33444 bypassed at a high level, and the log entry shows <quote>**bypassed**</quote>
33445 instead of a transport name. In this case the user and group are not used.
33446 </para>
33447 </listitem>
33448 <listitem>
33449 <para>
33450 <indexterm role="concept">
33451 <primary>included address list</primary>
33452 </indexterm>
33453 <indexterm role="concept">
33454 <primary>address redirection</primary>
33455 <secondary>included external list</secondary>
33456 </indexterm>
33457 If an item is of the form
33458 </para>
33459 <literallayout class="monospaced">
33460 :include:&lt;path name&gt;
33461 </literallayout>
33462 <para>
33463 a list of further items is taken from the given file and included at that
33464 point. <emphasis role="bold">Note</emphasis>: Such a file can not be a filter file; it is just an
33465 out-of-line addition to the list. The items in the included list are separated
33466 by commas or newlines and are not subject to expansion. If this is the first
33467 item in an alias list in an <command>lsearch</command> file, a colon must be used to terminate
33468 the alias name. This example is incorrect:
33469 </para>
33470 <literallayout class="monospaced">
33471 list1    :include:/opt/lists/list1
33472 </literallayout>
33473 <para>
33474 It must be given as
33475 </para>
33476 <literallayout class="monospaced">
33477 list1:   :include:/opt/lists/list1
33478 </literallayout>
33479 </listitem>
33480 <listitem>
33481 <para>
33482 <indexterm role="concept">
33483 <primary>address redirection</primary>
33484 <secondary>to black hole</secondary>
33485 </indexterm>
33486 Sometimes you want to throw away mail to a particular local part. Making the
33487 <option>data</option> option expand to an empty string does not work, because that causes
33488 the router to decline. Instead, the alias item
33489 <indexterm role="concept">
33490 <primary>black hole</primary>
33491 </indexterm>
33492 <indexterm role="concept">
33493 <primary>abandoning mail</primary>
33494 </indexterm>
33495 <emphasis>:blackhole:</emphasis> can be used. It does what its name implies. No delivery is
33496 done, and no error message is generated. This has the same effect as specifing
33497 <filename>/dev/null</filename> as a destination, but it can be independently disabled.
33498 </para>
33499 <para>
33500 <emphasis role="bold">Warning</emphasis>: If <emphasis>:blackhole:</emphasis> appears anywhere in a redirection list, no
33501 delivery is done for the original local part, even if other redirection items
33502 are present. If you are generating a multi-item list (for example, by reading a
33503 database) and need the ability to provide a no-op item, you must use
33504 <filename>/dev/null</filename>.
33505 </para>
33506 </listitem>
33507 <listitem>
33508 <para>
33509 <indexterm role="concept">
33510 <primary>delivery</primary>
33511 <secondary>forcing failure</secondary>
33512 </indexterm>
33513 <indexterm role="concept">
33514 <primary>delivery</primary>
33515 <secondary>forcing deferral</secondary>
33516 </indexterm>
33517 <indexterm role="concept">
33518 <primary>failing delivery</primary>
33519 <secondary>forcing</secondary>
33520 </indexterm>
33521 <indexterm role="concept">
33522 <primary>deferred delivery, forcing</primary>
33523 </indexterm>
33524 <indexterm role="concept">
33525 <primary>customizing</primary>
33526 <secondary>failure message</secondary>
33527 </indexterm>
33528 An attempt to deliver a particular address can be deferred or forced to fail by
33529 redirection items of the form
33530 </para>
33531 <literallayout class="monospaced">
33532 :defer:
33533 :fail:
33534 </literallayout>
33535 <para>
33536 respectively. When a redirection list contains such an item, it applies
33537 to the entire redirection; any other items in the list are ignored. Any
33538 text following <emphasis>:fail:</emphasis> or <emphasis>:defer:</emphasis> is placed in the error text
33539 associated with the failure. For example, an alias file might contain:
33540 </para>
33541 <literallayout class="monospaced">
33542 X.Employee:  :fail: Gone away, no forwarding address
33543 </literallayout>
33544 <para>
33545 In the case of an address that is being verified from an ACL or as the subject
33546 of a
33547 <indexterm role="concept">
33548 <primary>VRFY</primary>
33549 <secondary>error text, display of</secondary>
33550 </indexterm>
33551 VRFY command, the text is included in the SMTP error response by
33552 default.
33553 <indexterm role="concept">
33554 <primary>EXPN</primary>
33555 <secondary>error text, display of</secondary>
33556 </indexterm>
33557 The text is not included in the response to an EXPN command. In non-SMTP cases
33558 the text is included in the error message that Exim generates.
33559 </para>
33560 <para>
33561 <indexterm role="concept">
33562 <primary>SMTP</primary>
33563 <secondary>error codes</secondary>
33564 </indexterm>
33565 By default, Exim sends a 451 SMTP code for a <emphasis>:defer:</emphasis>, and 550 for
33566 <emphasis>:fail:</emphasis>. However, if the message starts with three digits followed by a
33567 space, optionally followed by an extended code of the form <emphasis>n.n.n</emphasis>, also
33568 followed by a space, and the very first digit is the same as the default error
33569 code, the code from the message is used instead. If the very first digit is
33570 incorrect, a panic error is logged, and the default code is used. You can
33571 suppress the use of the supplied code in a redirect router by setting the
33572 <option>forbid_smtp_code</option> option true. In this case, any SMTP code is quietly
33573 ignored.
33574 </para>
33575 <para>
33576 <indexterm role="variable">
33577 <primary><varname>$acl_verify_message</varname></primary>
33578 </indexterm>
33579 In an ACL, an explicitly provided message overrides the default, but the
33580 default message is available in the variable <varname>$acl_verify_message</varname> and can
33581 therefore be included in a custom message if this is desired.
33582 </para>
33583 <para>
33584 Normally the error text is the rest of the redirection list &ndash; a comma does
33585 not terminate it &ndash; but a newline does act as a terminator. Newlines are not
33586 normally present in alias expansions. In <command>lsearch</command> lookups they are removed
33587 as part of the continuation process, but they may exist in other kinds of
33588 lookup and in <emphasis>:include:</emphasis> files.
33589 </para>
33590 <para>
33591 During routing for message delivery (as opposed to verification), a redirection
33592 containing <emphasis>:fail:</emphasis> causes an immediate failure of the incoming address,
33593 whereas <emphasis>:defer:</emphasis> causes the message to remain on the queue so that a
33594 subsequent delivery attempt can happen at a later time. If an address is
33595 deferred for too long, it will ultimately fail, because the normal retry
33596 rules still apply.
33597 </para>
33598 </listitem>
33599 <listitem>
33600 <para>
33601 <indexterm role="concept">
33602 <primary>alias file</primary>
33603 <secondary>exception to default</secondary>
33604 </indexterm>
33605 Sometimes it is useful to use a single-key search type with a default (see
33606 chapter <xref linkend="CHAPfdlookup"/>) to look up aliases. However, there may be a need
33607 for exceptions to the default. These can be handled by aliasing them to
33608 <emphasis>:unknown:</emphasis>. This differs from <emphasis>:fail:</emphasis> in that it causes the <command>redirect</command>
33609 router to decline, whereas <emphasis>:fail:</emphasis> forces routing to fail. A lookup which
33610 results in an empty redirection list has the same effect.
33611 </para>
33612 </listitem>
33613 </itemizedlist>
33614 </section>
33615 <section id="SECTdupaddr">
33616 <title>Duplicate addresses</title>
33617 <para>
33618 <indexterm role="concept">
33619 <primary>duplicate addresses</primary>
33620 </indexterm>
33621 <indexterm role="concept">
33622 <primary>address duplicate, discarding</primary>
33623 </indexterm>
33624 <indexterm role="concept">
33625 <primary>pipe</primary>
33626 <secondary>duplicated</secondary>
33627 </indexterm>
33628 Exim removes duplicate addresses from the list to which it is delivering, so as
33629 to deliver just one copy to each address. This does not apply to deliveries
33630 routed to pipes by different immediate parent addresses, but an indirect
33631 aliasing scheme of the type
33632 </para>
33633 <literallayout class="monospaced">
33634 pipe:       |/some/command $local_part
33635 localpart1: pipe
33636 localpart2: pipe
33637 </literallayout>
33638 <para>
33639 does not work with a message that is addressed to both local parts, because
33640 when the second is aliased to the intermediate local part <quote>pipe</quote> it gets
33641 discarded as being the same as a previously handled address. However, a scheme
33642 such as
33643 </para>
33644 <literallayout class="monospaced">
33645 localpart1: |/some/command $local_part
33646 localpart2: |/some/command $local_part
33647 </literallayout>
33648 <para>
33649 does result in two different pipe deliveries, because the immediate parents of
33650 the pipes are distinct.
33651 </para>
33652 </section>
33653 <section id="SECID128">
33654 <title>Repeated redirection expansion</title>
33655 <para>
33656 <indexterm role="concept">
33657 <primary>repeated redirection expansion</primary>
33658 </indexterm>
33659 <indexterm role="concept">
33660 <primary>address redirection</primary>
33661 <secondary>repeated for each delivery attempt</secondary>
33662 </indexterm>
33663 When a message cannot be delivered to all of its recipients immediately,
33664 leading to two or more delivery attempts, redirection expansion is carried out
33665 afresh each time for those addresses whose children were not all previously
33666 delivered. If redirection is being used as a mailing list, this can lead to new
33667 members of the list receiving copies of old messages. The <option>one_time</option> option
33668 can be used to avoid this.
33669 </para>
33670 </section>
33671 <section id="SECID129">
33672 <title>Errors in redirection lists</title>
33673 <para>
33674 <indexterm role="concept">
33675 <primary>address redirection</primary>
33676 <secondary>errors</secondary>
33677 </indexterm>
33678 If <option>skip_syntax_errors</option> is set, a malformed address that causes a parsing
33679 error is skipped, and an entry is written to the main log. This may be useful
33680 for mailing lists that are automatically managed. Otherwise, if an error is
33681 detected while generating the list of new addresses, the original address is
33682 deferred. See also <option>syntax_errors_to</option>.
33683 </para>
33684 </section>
33685 <section id="SECID130">
33686 <title>Private options for the redirect router</title>
33687 <para>
33688 <indexterm role="concept">
33689 <primary>options</primary>
33690 <secondary><command>redirect</command> router</secondary>
33691 </indexterm>
33692 The private options for the <command>redirect</command> router are as follows:
33693 </para>
33694 <para>
33695 <indexterm role="option">
33696 <primary><option>allow_defer</option></primary>
33697 </indexterm>
33698 </para>
33699 <informaltable frame="all">
33700 <tgroup cols="4" colsep="0" rowsep="0">
33701 <colspec colwidth="8*" align="left"/>
33702 <colspec colwidth="6*" align="center"/>
33703 <colspec colwidth="6*" align="center"/>
33704 <colspec colwidth="6*" align="right"/>
33705 <tbody>
33706 <row>
33707 <entry><option>allow_defer</option></entry>
33708 <entry>Use: <emphasis>redirect</emphasis></entry>
33709 <entry>Type: <emphasis>boolean</emphasis></entry>
33710 <entry>Default: <emphasis>false</emphasis></entry>
33711 </row>
33712 </tbody>
33713 </tgroup>
33714 </informaltable>
33715 <para>
33716 Setting this option allows the use of <emphasis>:defer:</emphasis> in non-filter redirection
33717 data, or the <option>defer</option> command in an Exim filter file.
33718 </para>
33719 <para>
33720 <indexterm role="option">
33721 <primary><option>allow_fail</option></primary>
33722 </indexterm>
33723 </para>
33724 <informaltable frame="all">
33725 <tgroup cols="4" colsep="0" rowsep="0">
33726 <colspec colwidth="8*" align="left"/>
33727 <colspec colwidth="6*" align="center"/>
33728 <colspec colwidth="6*" align="center"/>
33729 <colspec colwidth="6*" align="right"/>
33730 <tbody>
33731 <row>
33732 <entry><option>allow_fail</option></entry>
33733 <entry>Use: <emphasis>redirect</emphasis></entry>
33734 <entry>Type: <emphasis>boolean</emphasis></entry>
33735 <entry>Default: <emphasis>false</emphasis></entry>
33736 </row>
33737 </tbody>
33738 </tgroup>
33739 </informaltable>
33740 <para>
33741 <indexterm role="concept">
33742 <primary>failing delivery</primary>
33743 <secondary>from filter</secondary>
33744 </indexterm>
33745 If this option is true, the <emphasis>:fail:</emphasis> item can be used in a redirection list,
33746 and the <option>fail</option> command may be used in an Exim filter file.
33747 </para>
33748 <para>
33749 <indexterm role="option">
33750 <primary><option>allow_filter</option></primary>
33751 </indexterm>
33752 </para>
33753 <informaltable frame="all">
33754 <tgroup cols="4" colsep="0" rowsep="0">
33755 <colspec colwidth="8*" align="left"/>
33756 <colspec colwidth="6*" align="center"/>
33757 <colspec colwidth="6*" align="center"/>
33758 <colspec colwidth="6*" align="right"/>
33759 <tbody>
33760 <row>
33761 <entry><option>allow_filter</option></entry>
33762 <entry>Use: <emphasis>redirect</emphasis></entry>
33763 <entry>Type: <emphasis>boolean</emphasis></entry>
33764 <entry>Default: <emphasis>false</emphasis></entry>
33765 </row>
33766 </tbody>
33767 </tgroup>
33768 </informaltable>
33769 <para>
33770 <indexterm role="concept">
33771 <primary>filter</primary>
33772 <secondary>enabling use of</secondary>
33773 </indexterm>
33774 <indexterm role="concept">
33775 <primary>Sieve filter</primary>
33776 <secondary>enabling use of</secondary>
33777 </indexterm>
33778 Setting this option allows Exim to interpret redirection data that starts with
33779 <quote>#Exim filter</quote> or <quote>#Sieve filter</quote> as a set of filtering instructions. There
33780 are some features of Exim filter files that some administrators may wish to
33781 lock out; see the <option>forbid_filter_</option><emphasis>xxx</emphasis> options below.
33782 </para>
33783 <para>
33784 It is also possible to lock out Exim filters or Sieve filters while allowing
33785 the other type; see <option>forbid_exim_filter</option> and <option>forbid_sieve_filter</option>.
33786 </para>
33787 <para>
33788 The filter is run using the uid and gid set by the generic <option>user</option> and
33789 <option>group</option> options. These take their defaults from the password data if
33790 <option>check_local_user</option> is set, so in the normal case of users&#x2019; personal filter
33791 files, the filter is run as the relevant user. When <option>allow_filter</option> is set
33792 true, Exim insists that either <option>check_local_user</option> or <option>user</option> is set.
33793 </para>
33794 <para>
33795 <indexterm role="option">
33796 <primary><option>allow_freeze</option></primary>
33797 </indexterm>
33798 </para>
33799 <informaltable frame="all">
33800 <tgroup cols="4" colsep="0" rowsep="0">
33801 <colspec colwidth="8*" align="left"/>
33802 <colspec colwidth="6*" align="center"/>
33803 <colspec colwidth="6*" align="center"/>
33804 <colspec colwidth="6*" align="right"/>
33805 <tbody>
33806 <row>
33807 <entry><option>allow_freeze</option></entry>
33808 <entry>Use: <emphasis>redirect</emphasis></entry>
33809 <entry>Type: <emphasis>boolean</emphasis></entry>
33810 <entry>Default: <emphasis>false</emphasis></entry>
33811 </row>
33812 </tbody>
33813 </tgroup>
33814 </informaltable>
33815 <para>
33816 <indexterm role="concept">
33817 <primary>freezing messages</primary>
33818 <secondary>allowing in filter</secondary>
33819 </indexterm>
33820 Setting this option allows the use of the <option>freeze</option> command in an Exim filter.
33821 This command is more normally encountered in system filters, and is disabled by
33822 default for redirection filters because it isn&#x2019;t something you usually want to
33823 let ordinary users do.
33824 </para>
33825 <para>
33826 <indexterm role="option">
33827 <primary><option>check_ancestor</option></primary>
33828 </indexterm>
33829 </para>
33830 <informaltable frame="all">
33831 <tgroup cols="4" colsep="0" rowsep="0">
33832 <colspec colwidth="8*" align="left"/>
33833 <colspec colwidth="6*" align="center"/>
33834 <colspec colwidth="6*" align="center"/>
33835 <colspec colwidth="6*" align="right"/>
33836 <tbody>
33837 <row>
33838 <entry><option>check_ancestor</option></entry>
33839 <entry>Use: <emphasis>redirect</emphasis></entry>
33840 <entry>Type: <emphasis>boolean</emphasis></entry>
33841 <entry>Default: <emphasis>false</emphasis></entry>
33842 </row>
33843 </tbody>
33844 </tgroup>
33845 </informaltable>
33846 <para>
33847 This option is concerned with handling generated addresses that are the same
33848 as some address in the list of redirection ancestors of the current address.
33849 Although it is turned off by default in the code, it is set in the default
33850 configuration file for handling users&#x2019; <filename>.forward</filename> files. It is recommended
33851 for this use of the <command>redirect</command> router.
33852 </para>
33853 <para>
33854 When <option>check_ancestor</option> is set, if a generated address (including the domain)
33855 is the same as any ancestor of the current address, it is replaced by a copy of
33856 the current address. This helps in the case where local part A is aliased to B,
33857 and B has a <filename>.forward</filename> file pointing back to A. For example, within a single
33858 domain, the local part <quote>Joe.Bloggs</quote> is aliased to <quote>jb</quote> and
33859 <filename>&nbsp;jb/.forward</filename> contains:
33860 </para>
33861 <literallayout class="monospaced">
33862 \Joe.Bloggs, &lt;other item(s)&gt;
33863 </literallayout>
33864 <para>
33865 Without the <option>check_ancestor</option> setting, either local part (<quote>jb</quote> or
33866 <quote>joe.bloggs</quote>) gets processed once by each router and so ends up as it was
33867 originally. If <quote>jb</quote> is the real mailbox name, mail to <quote>jb</quote> gets delivered
33868 (having been turned into <quote>joe.bloggs</quote> by the <filename>.forward</filename> file and back to
33869 <quote>jb</quote> by the alias), but mail to <quote>joe.bloggs</quote> fails. Setting
33870 <option>check_ancestor</option> on the <command>redirect</command> router that handles the <filename>.forward</filename>
33871 file prevents it from turning <quote>jb</quote> back into <quote>joe.bloggs</quote> when that was the
33872 original address. See also the <option>repeat_use</option> option below.
33873 </para>
33874 <para>
33875 <indexterm role="option">
33876 <primary><option>check_group</option></primary>
33877 </indexterm>
33878 </para>
33879 <informaltable frame="all">
33880 <tgroup cols="4" colsep="0" rowsep="0">
33881 <colspec colwidth="8*" align="left"/>
33882 <colspec colwidth="6*" align="center"/>
33883 <colspec colwidth="6*" align="center"/>
33884 <colspec colwidth="6*" align="right"/>
33885 <tbody>
33886 <row>
33887 <entry><option>check_group</option></entry>
33888 <entry>Use: <emphasis>redirect</emphasis></entry>
33889 <entry>Type: <emphasis>boolean</emphasis></entry>
33890 <entry>Default: <emphasis>see below</emphasis></entry>
33891 </row>
33892 </tbody>
33893 </tgroup>
33894 </informaltable>
33895 <para>
33896 When the <option>file</option> option is used, the group owner of the file is checked only
33897 when this option is set. The permitted groups are those listed in the
33898 <option>owngroups</option> option, together with the user&#x2019;s default group if
33899 <option>check_local_user</option> is set. If the file has the wrong group, routing is
33900 deferred. The default setting for this option is true if <option>check_local_user</option>
33901 is set and the <option>modemask</option> option permits the group write bit, or if the
33902 <option>owngroups</option> option is set. Otherwise it is false, and no group check occurs.
33903 </para>
33904 <para>
33905 <indexterm role="option">
33906 <primary><option>check_owner</option></primary>
33907 </indexterm>
33908 </para>
33909 <informaltable frame="all">
33910 <tgroup cols="4" colsep="0" rowsep="0">
33911 <colspec colwidth="8*" align="left"/>
33912 <colspec colwidth="6*" align="center"/>
33913 <colspec colwidth="6*" align="center"/>
33914 <colspec colwidth="6*" align="right"/>
33915 <tbody>
33916 <row>
33917 <entry><option>check_owner</option></entry>
33918 <entry>Use: <emphasis>redirect</emphasis></entry>
33919 <entry>Type: <emphasis>boolean</emphasis></entry>
33920 <entry>Default: <emphasis>see below</emphasis></entry>
33921 </row>
33922 </tbody>
33923 </tgroup>
33924 </informaltable>
33925 <para>
33926 When the <option>file</option> option is used, the owner of the file is checked only when
33927 this option is set. If <option>check_local_user</option> is set, the local user is
33928 permitted; otherwise the owner must be one of those listed in the <option>owners</option>
33929 option. The default value for this option is true if <option>check_local_user</option> or
33930 <option>owners</option> is set. Otherwise the default is false, and no owner check occurs.
33931 </para>
33932 <para>
33933 <indexterm role="option">
33934 <primary><option>data</option></primary>
33935 </indexterm>
33936 </para>
33937 <informaltable frame="all">
33938 <tgroup cols="4" colsep="0" rowsep="0">
33939 <colspec colwidth="8*" align="left"/>
33940 <colspec colwidth="6*" align="center"/>
33941 <colspec colwidth="6*" align="center"/>
33942 <colspec colwidth="6*" align="right"/>
33943 <tbody>
33944 <row>
33945 <entry><option>data</option></entry>
33946 <entry>Use: <emphasis>redirect</emphasis></entry>
33947 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33948 <entry>Default: <emphasis>unset</emphasis></entry>
33949 </row>
33950 </tbody>
33951 </tgroup>
33952 </informaltable>
33953 <para>
33954 This option is mutually exclusive with <option>file</option>. One or other of them must be
33955 set, but not both. The contents of <option>data</option> are expanded, and then used as the
33956 list of forwarding items, or as a set of filtering instructions. If the
33957 expansion is forced to fail, or the result is an empty string or a string that
33958 has no effect (consists entirely of comments), the router declines.
33959 </para>
33960 <para>
33961 When filtering instructions are used, the string must begin with <quote>#Exim
33962 filter</quote>, and all comments in the string, including this initial one, must be
33963 terminated with newline characters. For example:
33964 </para>
33965 <literallayout class="monospaced">
33966 data = #Exim filter\n\
33967        if $h_to: contains Exim then save $home/mail/exim endif
33968 </literallayout>
33969 <para>
33970 If you are reading the data from a database where newlines cannot be included,
33971 you can use the <varname>${sg}</varname> expansion item to turn the escape string of your
33972 choice into a newline.
33973 </para>
33974 <para>
33975 <indexterm role="option">
33976 <primary><option>directory_transport</option></primary>
33977 </indexterm>
33978 </para>
33979 <informaltable frame="all">
33980 <tgroup cols="4" colsep="0" rowsep="0">
33981 <colspec colwidth="8*" align="left"/>
33982 <colspec colwidth="6*" align="center"/>
33983 <colspec colwidth="6*" align="center"/>
33984 <colspec colwidth="6*" align="right"/>
33985 <tbody>
33986 <row>
33987 <entry><option>directory_transport</option></entry>
33988 <entry>Use: <emphasis>redirect</emphasis></entry>
33989 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33990 <entry>Default: <emphasis>unset</emphasis></entry>
33991 </row>
33992 </tbody>
33993 </tgroup>
33994 </informaltable>
33995 <para>
33996 A <command>redirect</command> router sets up a direct delivery to a directory when a path name
33997 ending with a slash is specified as a new <quote>address</quote>. The transport used is
33998 specified by this option, which, after expansion, must be the name of a
33999 configured transport. This should normally be an <command>appendfile</command> transport.
34000 </para>
34001 <para>
34002 <indexterm role="option">
34003 <primary><option>file</option></primary>
34004 </indexterm>
34005 </para>
34006 <informaltable frame="all">
34007 <tgroup cols="4" colsep="0" rowsep="0">
34008 <colspec colwidth="8*" align="left"/>
34009 <colspec colwidth="6*" align="center"/>
34010 <colspec colwidth="6*" align="center"/>
34011 <colspec colwidth="6*" align="right"/>
34012 <tbody>
34013 <row>
34014 <entry><option>file</option></entry>
34015 <entry>Use: <emphasis>redirect</emphasis></entry>
34016 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34017 <entry>Default: <emphasis>unset</emphasis></entry>
34018 </row>
34019 </tbody>
34020 </tgroup>
34021 </informaltable>
34022 <para>
34023 This option specifies the name of a file that contains the redirection data. It
34024 is mutually exclusive with the <option>data</option> option. The string is expanded before
34025 use; if the expansion is forced to fail, the router declines. Other expansion
34026 failures cause delivery to be deferred. The result of a successful expansion
34027 must be an absolute path. The entire file is read and used as the redirection
34028 data. If the data is an empty string or a string that has no effect (consists
34029 entirely of comments), the router declines.
34030 </para>
34031 <para>
34032 <indexterm role="concept">
34033 <primary>NFS</primary>
34034 <secondary>checking for file existence</secondary>
34035 </indexterm>
34036 If the attempt to open the file fails with a <quote>does not exist</quote> error, Exim
34037 runs a check on the containing directory,
34038 unless <option>ignore_enotdir</option> is true (see below).
34039 If the directory does not appear to exist, delivery is deferred. This can
34040 happen when users&#x2019; <filename>.forward</filename> files are in NFS-mounted directories, and there
34041 is a mount problem. If the containing directory does exist, but the file does
34042 not, the router declines.
34043 </para>
34044 <para>
34045 <indexterm role="option">
34046 <primary><option>file_transport</option></primary>
34047 </indexterm>
34048 </para>
34049 <informaltable frame="all">
34050 <tgroup cols="4" colsep="0" rowsep="0">
34051 <colspec colwidth="8*" align="left"/>
34052 <colspec colwidth="6*" align="center"/>
34053 <colspec colwidth="6*" align="center"/>
34054 <colspec colwidth="6*" align="right"/>
34055 <tbody>
34056 <row>
34057 <entry><option>file_transport</option></entry>
34058 <entry>Use: <emphasis>redirect</emphasis></entry>
34059 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34060 <entry>Default: <emphasis>unset</emphasis></entry>
34061 </row>
34062 </tbody>
34063 </tgroup>
34064 </informaltable>
34065 <para>
34066 <indexterm role="variable">
34067 <primary><varname>$address_file</varname></primary>
34068 </indexterm>
34069 A <command>redirect</command> router sets up a direct delivery to a file when a path name not
34070 ending in a slash is specified as a new <quote>address</quote>. The transport used is
34071 specified by this option, which, after expansion, must be the name of a
34072 configured transport. This should normally be an <command>appendfile</command> transport. When
34073 it is running, the file name is in <varname>$address_file</varname>.
34074 </para>
34075 <para>
34076 <indexterm role="option">
34077 <primary><option>filter_prepend_home</option></primary>
34078 </indexterm>
34079 </para>
34080 <informaltable frame="all">
34081 <tgroup cols="4" colsep="0" rowsep="0">
34082 <colspec colwidth="8*" align="left"/>
34083 <colspec colwidth="6*" align="center"/>
34084 <colspec colwidth="6*" align="center"/>
34085 <colspec colwidth="6*" align="right"/>
34086 <tbody>
34087 <row>
34088 <entry><option>filter_prepend_home</option></entry>
34089 <entry>Use: <emphasis>redirect</emphasis></entry>
34090 <entry>Type: <emphasis>boolean</emphasis></entry>
34091 <entry>Default: <emphasis>true</emphasis></entry>
34092 </row>
34093 </tbody>
34094 </tgroup>
34095 </informaltable>
34096 <para>
34097 When this option is true, if a <command>save</command> command in an Exim filter specifies a
34098 relative path, and <varname>$home</varname> is defined, it is automatically prepended to the
34099 relative path. If this option is set false, this action does not happen. The
34100 relative path is then passed to the transport unmodified.
34101 </para>
34102 <para>
34103 <indexterm role="option">
34104 <primary><option>forbid_blackhole</option></primary>
34105 </indexterm>
34106 </para>
34107 <informaltable frame="all">
34108 <tgroup cols="4" colsep="0" rowsep="0">
34109 <colspec colwidth="8*" align="left"/>
34110 <colspec colwidth="6*" align="center"/>
34111 <colspec colwidth="6*" align="center"/>
34112 <colspec colwidth="6*" align="right"/>
34113 <tbody>
34114 <row>
34115 <entry><option>forbid_blackhole</option></entry>
34116 <entry>Use: <emphasis>redirect</emphasis></entry>
34117 <entry>Type: <emphasis>boolean</emphasis></entry>
34118 <entry>Default: <emphasis>false</emphasis></entry>
34119 </row>
34120 </tbody>
34121 </tgroup>
34122 </informaltable>
34123 <para>
34124 If this option is true, the <emphasis>:blackhole:</emphasis> item may not appear in a
34125 redirection list.
34126 </para>
34127 <para>
34128 <indexterm role="option">
34129 <primary><option>forbid_exim_filter</option></primary>
34130 </indexterm>
34131 </para>
34132 <informaltable frame="all">
34133 <tgroup cols="4" colsep="0" rowsep="0">
34134 <colspec colwidth="8*" align="left"/>
34135 <colspec colwidth="6*" align="center"/>
34136 <colspec colwidth="6*" align="center"/>
34137 <colspec colwidth="6*" align="right"/>
34138 <tbody>
34139 <row>
34140 <entry><option>forbid_exim_filter</option></entry>
34141 <entry>Use: <emphasis>redirect</emphasis></entry>
34142 <entry>Type: <emphasis>boolean</emphasis></entry>
34143 <entry>Default: <emphasis>false</emphasis></entry>
34144 </row>
34145 </tbody>
34146 </tgroup>
34147 </informaltable>
34148 <para>
34149 If this option is set true, only Sieve filters are permitted when
34150 <option>allow_filter</option> is true.
34151 </para>
34152 <para>
34153 <indexterm role="option">
34154 <primary><option>forbid_file</option></primary>
34155 </indexterm>
34156 </para>
34157 <informaltable frame="all">
34158 <tgroup cols="4" colsep="0" rowsep="0">
34159 <colspec colwidth="8*" align="left"/>
34160 <colspec colwidth="6*" align="center"/>
34161 <colspec colwidth="6*" align="center"/>
34162 <colspec colwidth="6*" align="right"/>
34163 <tbody>
34164 <row>
34165 <entry><option>forbid_file</option></entry>
34166 <entry>Use: <emphasis>redirect</emphasis></entry>
34167 <entry>Type: <emphasis>boolean</emphasis></entry>
34168 <entry>Default: <emphasis>false</emphasis></entry>
34169 </row>
34170 </tbody>
34171 </tgroup>
34172 </informaltable>
34173 <para>
34174 <indexterm role="concept">
34175 <primary>delivery</primary>
34176 <secondary>to file; forbidding</secondary>
34177 </indexterm>
34178 <indexterm role="concept">
34179 <primary>Sieve filter</primary>
34180 <secondary>forbidding delivery to a file</secondary>
34181 </indexterm>
34182 <indexterm role="concept">
34183 <primary>Sieve filter</primary>
34184 <secondary><quote>keep</quote> facility; disabling</secondary>
34185 </indexterm>
34186 If this option is true, this router may not generate a new address that
34187 specifies delivery to a local file or directory, either from a filter or from a
34188 conventional forward file. This option is forced to be true if <option>one_time</option> is
34189 set. It applies to Sieve filters as well as to Exim filters, but if true, it
34190 locks out the Sieve&#x2019;s <quote>keep</quote> facility.
34191 </para>
34192 <para>
34193 <indexterm role="option">
34194 <primary><option>forbid_filter_dlfunc</option></primary>
34195 </indexterm>
34196 </para>
34197 <informaltable frame="all">
34198 <tgroup cols="4" colsep="0" rowsep="0">
34199 <colspec colwidth="8*" align="left"/>
34200 <colspec colwidth="6*" align="center"/>
34201 <colspec colwidth="6*" align="center"/>
34202 <colspec colwidth="6*" align="right"/>
34203 <tbody>
34204 <row>
34205 <entry><option>forbid_filter_dlfunc</option></entry>
34206 <entry>Use: <emphasis>redirect</emphasis></entry>
34207 <entry>Type: <emphasis>boolean</emphasis></entry>
34208 <entry>Default: <emphasis>false</emphasis></entry>
34209 </row>
34210 </tbody>
34211 </tgroup>
34212 </informaltable>
34213 <para>
34214 <indexterm role="concept">
34215 <primary>filter</primary>
34216 <secondary>locking out certain features</secondary>
34217 </indexterm>
34218 If this option is true, string expansions in Exim filters are not allowed to
34219 make use of the <option>dlfunc</option> expansion facility to run dynamically loaded
34220 functions.
34221 </para>
34222 <para>
34223 <indexterm role="option">
34224 <primary><option>forbid_filter_existstest</option></primary>
34225 </indexterm>
34226 </para>
34227 <informaltable frame="all">
34228 <tgroup cols="4" colsep="0" rowsep="0">
34229 <colspec colwidth="8*" align="left"/>
34230 <colspec colwidth="6*" align="center"/>
34231 <colspec colwidth="6*" align="center"/>
34232 <colspec colwidth="6*" align="right"/>
34233 <tbody>
34234 <row>
34235 <entry><option>forbid_filter_existstest</option></entry>
34236 <entry>Use: <emphasis>redirect</emphasis></entry>
34237 <entry>Type: <emphasis>boolean</emphasis></entry>
34238 <entry>Default: <emphasis>false</emphasis></entry>
34239 </row>
34240 </tbody>
34241 </tgroup>
34242 </informaltable>
34243 <para>
34244 <indexterm role="concept">
34245 <primary>expansion</primary>
34246 <secondary>statting a file</secondary>
34247 </indexterm>
34248 If this option is true, string expansions in Exim filters are not allowed to
34249 make use of the <option>exists</option> condition or the <option>stat</option> expansion item.
34250 </para>
34251 <para>
34252 <indexterm role="option">
34253 <primary><option>forbid_filter_logwrite</option></primary>
34254 </indexterm>
34255 </para>
34256 <informaltable frame="all">
34257 <tgroup cols="4" colsep="0" rowsep="0">
34258 <colspec colwidth="8*" align="left"/>
34259 <colspec colwidth="6*" align="center"/>
34260 <colspec colwidth="6*" align="center"/>
34261 <colspec colwidth="6*" align="right"/>
34262 <tbody>
34263 <row>
34264 <entry><option>forbid_filter_logwrite</option></entry>
34265 <entry>Use: <emphasis>redirect</emphasis></entry>
34266 <entry>Type: <emphasis>boolean</emphasis></entry>
34267 <entry>Default: <emphasis>false</emphasis></entry>
34268 </row>
34269 </tbody>
34270 </tgroup>
34271 </informaltable>
34272 <para>
34273 If this option is true, use of the logging facility in Exim filters is not
34274 permitted. Logging is in any case available only if the filter is being run
34275 under some unprivileged uid (which is normally the case for ordinary users&#x2019;
34276 <filename>.forward</filename> files).
34277 </para>
34278 <para>
34279 <indexterm role="option">
34280 <primary><option>forbid_filter_lookup</option></primary>
34281 </indexterm>
34282 </para>
34283 <informaltable frame="all">
34284 <tgroup cols="4" colsep="0" rowsep="0">
34285 <colspec colwidth="8*" align="left"/>
34286 <colspec colwidth="6*" align="center"/>
34287 <colspec colwidth="6*" align="center"/>
34288 <colspec colwidth="6*" align="right"/>
34289 <tbody>
34290 <row>
34291 <entry><option>forbid_filter_lookup</option></entry>
34292 <entry>Use: <emphasis>redirect</emphasis></entry>
34293 <entry>Type: <emphasis>boolean</emphasis></entry>
34294 <entry>Default: <emphasis>false</emphasis></entry>
34295 </row>
34296 </tbody>
34297 </tgroup>
34298 </informaltable>
34299 <para>
34300 If this option is true, string expansions in Exim filter files are not allowed
34301 to make use of <option>lookup</option> items.
34302 </para>
34303 <para>
34304 <indexterm role="option">
34305 <primary><option>forbid_filter_perl</option></primary>
34306 </indexterm>
34307 </para>
34308 <informaltable frame="all">
34309 <tgroup cols="4" colsep="0" rowsep="0">
34310 <colspec colwidth="8*" align="left"/>
34311 <colspec colwidth="6*" align="center"/>
34312 <colspec colwidth="6*" align="center"/>
34313 <colspec colwidth="6*" align="right"/>
34314 <tbody>
34315 <row>
34316 <entry><option>forbid_filter_perl</option></entry>
34317 <entry>Use: <emphasis>redirect</emphasis></entry>
34318 <entry>Type: <emphasis>boolean</emphasis></entry>
34319 <entry>Default: <emphasis>false</emphasis></entry>
34320 </row>
34321 </tbody>
34322 </tgroup>
34323 </informaltable>
34324 <para>
34325 This option has an effect only if Exim is built with embedded Perl support. If
34326 it is true, string expansions in Exim filter files are not allowed to make use
34327 of the embedded Perl support.
34328 </para>
34329 <para>
34330 <indexterm role="option">
34331 <primary><option>forbid_filter_readfile</option></primary>
34332 </indexterm>
34333 </para>
34334 <informaltable frame="all">
34335 <tgroup cols="4" colsep="0" rowsep="0">
34336 <colspec colwidth="8*" align="left"/>
34337 <colspec colwidth="6*" align="center"/>
34338 <colspec colwidth="6*" align="center"/>
34339 <colspec colwidth="6*" align="right"/>
34340 <tbody>
34341 <row>
34342 <entry><option>forbid_filter_readfile</option></entry>
34343 <entry>Use: <emphasis>redirect</emphasis></entry>
34344 <entry>Type: <emphasis>boolean</emphasis></entry>
34345 <entry>Default: <emphasis>false</emphasis></entry>
34346 </row>
34347 </tbody>
34348 </tgroup>
34349 </informaltable>
34350 <para>
34351 If this option is true, string expansions in Exim filter files are not allowed
34352 to make use of <option>readfile</option> items.
34353 </para>
34354 <para>
34355 <indexterm role="option">
34356 <primary><option>forbid_filter_readsocket</option></primary>
34357 </indexterm>
34358 </para>
34359 <informaltable frame="all">
34360 <tgroup cols="4" colsep="0" rowsep="0">
34361 <colspec colwidth="8*" align="left"/>
34362 <colspec colwidth="6*" align="center"/>
34363 <colspec colwidth="6*" align="center"/>
34364 <colspec colwidth="6*" align="right"/>
34365 <tbody>
34366 <row>
34367 <entry><option>forbid_filter_readsocket</option></entry>
34368 <entry>Use: <emphasis>redirect</emphasis></entry>
34369 <entry>Type: <emphasis>boolean</emphasis></entry>
34370 <entry>Default: <emphasis>false</emphasis></entry>
34371 </row>
34372 </tbody>
34373 </tgroup>
34374 </informaltable>
34375 <para>
34376 If this option is true, string expansions in Exim filter files are not allowed
34377 to make use of <option>readsocket</option> items.
34378 </para>
34379 <para>
34380 <indexterm role="option">
34381 <primary><option>forbid_filter_reply</option></primary>
34382 </indexterm>
34383 </para>
34384 <informaltable frame="all">
34385 <tgroup cols="4" colsep="0" rowsep="0">
34386 <colspec colwidth="8*" align="left"/>
34387 <colspec colwidth="6*" align="center"/>
34388 <colspec colwidth="6*" align="center"/>
34389 <colspec colwidth="6*" align="right"/>
34390 <tbody>
34391 <row>
34392 <entry><option>forbid_filter_reply</option></entry>
34393 <entry>Use: <emphasis>redirect</emphasis></entry>
34394 <entry>Type: <emphasis>boolean</emphasis></entry>
34395 <entry>Default: <emphasis>false</emphasis></entry>
34396 </row>
34397 </tbody>
34398 </tgroup>
34399 </informaltable>
34400 <para>
34401 If this option is true, this router may not generate an automatic reply
34402 message. Automatic replies can be generated only from Exim or Sieve filter
34403 files, not from traditional forward files. This option is forced to be true if
34404 <option>one_time</option> is set.
34405 </para>
34406 <para>
34407 <indexterm role="option">
34408 <primary><option>forbid_filter_run</option></primary>
34409 </indexterm>
34410 </para>
34411 <informaltable frame="all">
34412 <tgroup cols="4" colsep="0" rowsep="0">
34413 <colspec colwidth="8*" align="left"/>
34414 <colspec colwidth="6*" align="center"/>
34415 <colspec colwidth="6*" align="center"/>
34416 <colspec colwidth="6*" align="right"/>
34417 <tbody>
34418 <row>
34419 <entry><option>forbid_filter_run</option></entry>
34420 <entry>Use: <emphasis>redirect</emphasis></entry>
34421 <entry>Type: <emphasis>boolean</emphasis></entry>
34422 <entry>Default: <emphasis>false</emphasis></entry>
34423 </row>
34424 </tbody>
34425 </tgroup>
34426 </informaltable>
34427 <para>
34428 If this option is true, string expansions in Exim filter files are not allowed
34429 to make use of <option>run</option> items.
34430 </para>
34431 <para>
34432 <indexterm role="option">
34433 <primary><option>forbid_include</option></primary>
34434 </indexterm>
34435 </para>
34436 <informaltable frame="all">
34437 <tgroup cols="4" colsep="0" rowsep="0">
34438 <colspec colwidth="8*" align="left"/>
34439 <colspec colwidth="6*" align="center"/>
34440 <colspec colwidth="6*" align="center"/>
34441 <colspec colwidth="6*" align="right"/>
34442 <tbody>
34443 <row>
34444 <entry><option>forbid_include</option></entry>
34445 <entry>Use: <emphasis>redirect</emphasis></entry>
34446 <entry>Type: <emphasis>boolean</emphasis></entry>
34447 <entry>Default: <emphasis>false</emphasis></entry>
34448 </row>
34449 </tbody>
34450 </tgroup>
34451 </informaltable>
34452 <para>
34453 If this option is true, items of the form
34454 </para>
34455 <literallayout class="monospaced">
34456 :include:&lt;path name&gt;
34457 </literallayout>
34458 <para>
34459 are not permitted in non-filter redirection lists.
34460 </para>
34461 <para>
34462 <indexterm role="option">
34463 <primary><option>forbid_pipe</option></primary>
34464 </indexterm>
34465 </para>
34466 <informaltable frame="all">
34467 <tgroup cols="4" colsep="0" rowsep="0">
34468 <colspec colwidth="8*" align="left"/>
34469 <colspec colwidth="6*" align="center"/>
34470 <colspec colwidth="6*" align="center"/>
34471 <colspec colwidth="6*" align="right"/>
34472 <tbody>
34473 <row>
34474 <entry><option>forbid_pipe</option></entry>
34475 <entry>Use: <emphasis>redirect</emphasis></entry>
34476 <entry>Type: <emphasis>boolean</emphasis></entry>
34477 <entry>Default: <emphasis>false</emphasis></entry>
34478 </row>
34479 </tbody>
34480 </tgroup>
34481 </informaltable>
34482 <para>
34483 <indexterm role="concept">
34484 <primary>delivery</primary>
34485 <secondary>to pipe; forbidding</secondary>
34486 </indexterm>
34487 If this option is true, this router may not generate a new address which
34488 specifies delivery to a pipe, either from an Exim filter or from a conventional
34489 forward file. This option is forced to be true if <option>one_time</option> is set.
34490 </para>
34491 <para>
34492 <indexterm role="option">
34493 <primary><option>forbid_sieve_filter</option></primary>
34494 </indexterm>
34495 </para>
34496 <informaltable frame="all">
34497 <tgroup cols="4" colsep="0" rowsep="0">
34498 <colspec colwidth="8*" align="left"/>
34499 <colspec colwidth="6*" align="center"/>
34500 <colspec colwidth="6*" align="center"/>
34501 <colspec colwidth="6*" align="right"/>
34502 <tbody>
34503 <row>
34504 <entry><option>forbid_sieve_filter</option></entry>
34505 <entry>Use: <emphasis>redirect</emphasis></entry>
34506 <entry>Type: <emphasis>boolean</emphasis></entry>
34507 <entry>Default: <emphasis>false</emphasis></entry>
34508 </row>
34509 </tbody>
34510 </tgroup>
34511 </informaltable>
34512 <para>
34513 If this option is set true, only Exim filters are permitted when
34514 <option>allow_filter</option> is true.
34515 </para>
34516 <para>
34517 <indexterm role="concept">
34518 <primary>SMTP</primary>
34519 <secondary>error codes</secondary>
34520 </indexterm>
34521 <indexterm role="option">
34522 <primary><option>forbid_smtp_code</option></primary>
34523 </indexterm>
34524 </para>
34525 <informaltable frame="all">
34526 <tgroup cols="4" colsep="0" rowsep="0">
34527 <colspec colwidth="8*" align="left"/>
34528 <colspec colwidth="6*" align="center"/>
34529 <colspec colwidth="6*" align="center"/>
34530 <colspec colwidth="6*" align="right"/>
34531 <tbody>
34532 <row>
34533 <entry><option>forbid_smtp_code</option></entry>
34534 <entry>Use: <emphasis>redirect</emphasis></entry>
34535 <entry>Type: <emphasis>boolean</emphasis></entry>
34536 <entry>Default: <emphasis>false</emphasis></entry>
34537 </row>
34538 </tbody>
34539 </tgroup>
34540 </informaltable>
34541 <para>
34542 If this option is set true, any SMTP error codes that are present at the start
34543 of messages specified for <literal>:defer:</literal> or <literal>:fail:</literal> are quietly ignored, and
34544 the default codes (451 and 550, respectively) are always used.
34545 </para>
34546 <para>
34547 <indexterm role="option">
34548 <primary><option>hide_child_in_errmsg</option></primary>
34549 </indexterm>
34550 </para>
34551 <informaltable frame="all">
34552 <tgroup cols="4" colsep="0" rowsep="0">
34553 <colspec colwidth="8*" align="left"/>
34554 <colspec colwidth="6*" align="center"/>
34555 <colspec colwidth="6*" align="center"/>
34556 <colspec colwidth="6*" align="right"/>
34557 <tbody>
34558 <row>
34559 <entry><option>hide_child_in_errmsg</option></entry>
34560 <entry>Use: <emphasis>redirect</emphasis></entry>
34561 <entry>Type: <emphasis>boolean</emphasis></entry>
34562 <entry>Default: <emphasis>false</emphasis></entry>
34563 </row>
34564 </tbody>
34565 </tgroup>
34566 </informaltable>
34567 <para>
34568 <indexterm role="concept">
34569 <primary>bounce message</primary>
34570 <secondary>redirection details; suppressing</secondary>
34571 </indexterm>
34572 If this option is true, it prevents Exim from quoting a child address if it
34573 generates a bounce or delay message for it. Instead it says <quote>an address
34574 generated from &lt;<emphasis>the top level address</emphasis>&gt;</quote>. Of course, this applies only to
34575 bounces generated locally. If a message is forwarded to another host, <emphasis>its</emphasis>
34576 bounce may well quote the generated address.
34577 </para>
34578 <para>
34579 <indexterm role="option">
34580 <primary><option>ignore_eacces</option></primary>
34581 </indexterm>
34582 </para>
34583 <informaltable frame="all">
34584 <tgroup cols="4" colsep="0" rowsep="0">
34585 <colspec colwidth="8*" align="left"/>
34586 <colspec colwidth="6*" align="center"/>
34587 <colspec colwidth="6*" align="center"/>
34588 <colspec colwidth="6*" align="right"/>
34589 <tbody>
34590 <row>
34591 <entry><option>ignore_eacces</option></entry>
34592 <entry>Use: <emphasis>redirect</emphasis></entry>
34593 <entry>Type: <emphasis>boolean</emphasis></entry>
34594 <entry>Default: <emphasis>false</emphasis></entry>
34595 </row>
34596 </tbody>
34597 </tgroup>
34598 </informaltable>
34599 <para>
34600 <indexterm role="concept">
34601 <primary>EACCES</primary>
34602 </indexterm>
34603 If this option is set and an attempt to open a redirection file yields the
34604 EACCES error (permission denied), the <command>redirect</command> router behaves as if the
34605 file did not exist.
34606 </para>
34607 <para>
34608 <indexterm role="option">
34609 <primary><option>ignore_enotdir</option></primary>
34610 </indexterm>
34611 </para>
34612 <informaltable frame="all">
34613 <tgroup cols="4" colsep="0" rowsep="0">
34614 <colspec colwidth="8*" align="left"/>
34615 <colspec colwidth="6*" align="center"/>
34616 <colspec colwidth="6*" align="center"/>
34617 <colspec colwidth="6*" align="right"/>
34618 <tbody>
34619 <row>
34620 <entry><option>ignore_enotdir</option></entry>
34621 <entry>Use: <emphasis>redirect</emphasis></entry>
34622 <entry>Type: <emphasis>boolean</emphasis></entry>
34623 <entry>Default: <emphasis>false</emphasis></entry>
34624 </row>
34625 </tbody>
34626 </tgroup>
34627 </informaltable>
34628 <para>
34629 <indexterm role="concept">
34630 <primary>ENOTDIR</primary>
34631 </indexterm>
34632 If this option is set and an attempt to open a redirection file yields the
34633 ENOTDIR error (something on the path is not a directory), the <command>redirect</command>
34634 router behaves as if the file did not exist.
34635 </para>
34636 <para>
34637 Setting <option>ignore_enotdir</option> has another effect as well: When a <command>redirect</command>
34638 router that has the <option>file</option> option set discovers that the file does not exist
34639 (the ENOENT error), it tries to <function>stat()</function> the parent directory, as a check
34640 against unmounted NFS directories. If the parent can not be statted, delivery
34641 is deferred. However, it seems wrong to do this check when <option>ignore_enotdir</option>
34642 is set, because that option tells Exim to ignore <quote>something on the path is not
34643 a directory</quote> (the ENOTDIR error). This is a confusing area, because it seems
34644 that some operating systems give ENOENT where others give ENOTDIR.
34645 </para>
34646 <para>
34647 <indexterm role="option">
34648 <primary><option>include_directory</option></primary>
34649 </indexterm>
34650 </para>
34651 <informaltable frame="all">
34652 <tgroup cols="4" colsep="0" rowsep="0">
34653 <colspec colwidth="8*" align="left"/>
34654 <colspec colwidth="6*" align="center"/>
34655 <colspec colwidth="6*" align="center"/>
34656 <colspec colwidth="6*" align="right"/>
34657 <tbody>
34658 <row>
34659 <entry><option>include_directory</option></entry>
34660 <entry>Use: <emphasis>redirect</emphasis></entry>
34661 <entry>Type: <emphasis>string</emphasis></entry>
34662 <entry>Default: <emphasis>unset</emphasis></entry>
34663 </row>
34664 </tbody>
34665 </tgroup>
34666 </informaltable>
34667 <para>
34668 If this option is set, the path names of any <emphasis>:include:</emphasis> items in a
34669 redirection list must start with this directory.
34670 </para>
34671 <para>
34672 <indexterm role="option">
34673 <primary><option>modemask</option></primary>
34674 </indexterm>
34675 </para>
34676 <informaltable frame="all">
34677 <tgroup cols="4" colsep="0" rowsep="0">
34678 <colspec colwidth="8*" align="left"/>
34679 <colspec colwidth="6*" align="center"/>
34680 <colspec colwidth="6*" align="center"/>
34681 <colspec colwidth="6*" align="right"/>
34682 <tbody>
34683 <row>
34684 <entry><option>modemask</option></entry>
34685 <entry>Use: <emphasis>redirect</emphasis></entry>
34686 <entry>Type: <emphasis>octal integer</emphasis></entry>
34687 <entry>Default: <emphasis>022</emphasis></entry>
34688 </row>
34689 </tbody>
34690 </tgroup>
34691 </informaltable>
34692 <para>
34693 This specifies mode bits which must not be set for a file specified by the
34694 <option>file</option> option. If any of the forbidden bits are set, delivery is deferred.
34695 </para>
34696 <para>
34697 <indexterm role="option">
34698 <primary><option>one_time</option></primary>
34699 </indexterm>
34700 </para>
34701 <informaltable frame="all">
34702 <tgroup cols="4" colsep="0" rowsep="0">
34703 <colspec colwidth="8*" align="left"/>
34704 <colspec colwidth="6*" align="center"/>
34705 <colspec colwidth="6*" align="center"/>
34706 <colspec colwidth="6*" align="right"/>
34707 <tbody>
34708 <row>
34709 <entry><option>one_time</option></entry>
34710 <entry>Use: <emphasis>redirect</emphasis></entry>
34711 <entry>Type: <emphasis>boolean</emphasis></entry>
34712 <entry>Default: <emphasis>false</emphasis></entry>
34713 </row>
34714 </tbody>
34715 </tgroup>
34716 </informaltable>
34717 <para>
34718 <indexterm role="concept">
34719 <primary>one-time aliasing/forwarding expansion</primary>
34720 </indexterm>
34721 <indexterm role="concept">
34722 <primary>alias file</primary>
34723 <secondary>one-time expansion</secondary>
34724 </indexterm>
34725 <indexterm role="concept">
34726 <primary>forward file</primary>
34727 <secondary>one-time expansion</secondary>
34728 </indexterm>
34729 <indexterm role="concept">
34730 <primary>mailing lists</primary>
34731 <secondary>one-time expansion</secondary>
34732 </indexterm>
34733 <indexterm role="concept">
34734 <primary>address redirection</primary>
34735 <secondary>one-time expansion</secondary>
34736 </indexterm>
34737 Sometimes the fact that Exim re-evaluates aliases and reprocesses redirection
34738 files each time it tries to deliver a message causes a problem when one or more
34739 of the generated addresses fails be delivered at the first attempt. The problem
34740 is not one of duplicate delivery &ndash; Exim is clever enough to handle that &ndash;
34741 but of what happens when the redirection list changes during the time that the
34742 message is on Exim&#x2019;s queue. This is particularly true in the case of mailing
34743 lists, where new subscribers might receive copies of messages that were posted
34744 before they subscribed.
34745 </para>
34746 <para>
34747 If <option>one_time</option> is set and any addresses generated by the router fail to
34748 deliver at the first attempt, the failing addresses are added to the message as
34749 <quote>top level</quote> addresses, and the parent address that generated them is marked
34750 <quote>delivered</quote>. Thus, redirection does not happen again at the next delivery
34751 attempt.
34752 </para>
34753 <para>
34754 <emphasis role="bold">Warning 1</emphasis>: Any header line addition or removal that is specified by this
34755 router would be lost if delivery did not succeed at the first attempt. For this
34756 reason, the <option>headers_add</option> and <option>headers_remove</option> generic options are not
34757 permitted when <option>one_time</option> is set.
34758 </para>
34759 <para>
34760 <emphasis role="bold">Warning 2</emphasis>: To ensure that the router generates only addresses (as opposed
34761 to pipe or file deliveries or auto-replies) <option>forbid_file</option>, <option>forbid_pipe</option>,
34762 and <option>forbid_filter_reply</option> are forced to be true when <option>one_time</option> is set.
34763 </para>
34764 <para>
34765 <emphasis role="bold">Warning 3</emphasis>: The <option>unseen</option> generic router option may not be set with
34766 <option>one_time</option>.
34767 </para>
34768 <para>
34769 The original top-level address is remembered with each of the generated
34770 addresses, and is output in any log messages. However, any intermediate parent
34771 addresses are not recorded. This makes a difference to the log only if
34772 <option>all_parents</option> log selector is set. It is expected that <option>one_time</option> will
34773 typically be used for mailing lists, where there is normally just one level of
34774 expansion.
34775 </para>
34776 <para>
34777 <indexterm role="option">
34778 <primary><option>owners</option></primary>
34779 </indexterm>
34780 </para>
34781 <informaltable frame="all">
34782 <tgroup cols="4" colsep="0" rowsep="0">
34783 <colspec colwidth="8*" align="left"/>
34784 <colspec colwidth="6*" align="center"/>
34785 <colspec colwidth="6*" align="center"/>
34786 <colspec colwidth="6*" align="right"/>
34787 <tbody>
34788 <row>
34789 <entry><option>owners</option></entry>
34790 <entry>Use: <emphasis>redirect</emphasis></entry>
34791 <entry>Type: <emphasis>string list</emphasis></entry>
34792 <entry>Default: <emphasis>unset</emphasis></entry>
34793 </row>
34794 </tbody>
34795 </tgroup>
34796 </informaltable>
34797 <para>
34798 <indexterm role="concept">
34799 <primary>ownership</primary>
34800 <secondary>alias file</secondary>
34801 </indexterm>
34802 <indexterm role="concept">
34803 <primary>ownership</primary>
34804 <secondary>forward file</secondary>
34805 </indexterm>
34806 <indexterm role="concept">
34807 <primary>alias file</primary>
34808 <secondary>ownership</secondary>
34809 </indexterm>
34810 <indexterm role="concept">
34811 <primary>forward file</primary>
34812 <secondary>ownership</secondary>
34813 </indexterm>
34814 This specifies a list of permitted owners for the file specified by <option>file</option>.
34815 This list is in addition to the local user when <option>check_local_user</option> is set.
34816 See <option>check_owner</option> above.
34817 </para>
34818 <para>
34819 <indexterm role="option">
34820 <primary><option>owngroups</option></primary>
34821 </indexterm>
34822 </para>
34823 <informaltable frame="all">
34824 <tgroup cols="4" colsep="0" rowsep="0">
34825 <colspec colwidth="8*" align="left"/>
34826 <colspec colwidth="6*" align="center"/>
34827 <colspec colwidth="6*" align="center"/>
34828 <colspec colwidth="6*" align="right"/>
34829 <tbody>
34830 <row>
34831 <entry><option>owngroups</option></entry>
34832 <entry>Use: <emphasis>redirect</emphasis></entry>
34833 <entry>Type: <emphasis>string list</emphasis></entry>
34834 <entry>Default: <emphasis>unset</emphasis></entry>
34835 </row>
34836 </tbody>
34837 </tgroup>
34838 </informaltable>
34839 <para>
34840 This specifies a list of permitted groups for the file specified by <option>file</option>.
34841 The list is in addition to the local user&#x2019;s primary group when
34842 <option>check_local_user</option> is set. See <option>check_group</option> above.
34843 </para>
34844 <para>
34845 <indexterm role="option">
34846 <primary><option>pipe_transport</option></primary>
34847 </indexterm>
34848 </para>
34849 <informaltable frame="all">
34850 <tgroup cols="4" colsep="0" rowsep="0">
34851 <colspec colwidth="8*" align="left"/>
34852 <colspec colwidth="6*" align="center"/>
34853 <colspec colwidth="6*" align="center"/>
34854 <colspec colwidth="6*" align="right"/>
34855 <tbody>
34856 <row>
34857 <entry><option>pipe_transport</option></entry>
34858 <entry>Use: <emphasis>redirect</emphasis></entry>
34859 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34860 <entry>Default: <emphasis>unset</emphasis></entry>
34861 </row>
34862 </tbody>
34863 </tgroup>
34864 </informaltable>
34865 <para>
34866 <indexterm role="variable">
34867 <primary><varname>$address_pipe</varname></primary>
34868 </indexterm>
34869 A <command>redirect</command> router sets up a direct delivery to a pipe when a string
34870 starting with a vertical bar character is specified as a new <quote>address</quote>. The
34871 transport used is specified by this option, which, after expansion, must be the
34872 name of a configured transport. This should normally be a <command>pipe</command> transport.
34873 When the transport is run, the pipe command is in <varname>$address_pipe</varname>.
34874 </para>
34875 <para>
34876 <indexterm role="option">
34877 <primary><option>qualify_domain</option></primary>
34878 </indexterm>
34879 </para>
34880 <informaltable frame="all">
34881 <tgroup cols="4" colsep="0" rowsep="0">
34882 <colspec colwidth="8*" align="left"/>
34883 <colspec colwidth="6*" align="center"/>
34884 <colspec colwidth="6*" align="center"/>
34885 <colspec colwidth="6*" align="right"/>
34886 <tbody>
34887 <row>
34888 <entry><option>qualify_domain</option></entry>
34889 <entry>Use: <emphasis>redirect</emphasis></entry>
34890 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34891 <entry>Default: <emphasis>unset</emphasis></entry>
34892 </row>
34893 </tbody>
34894 </tgroup>
34895 </informaltable>
34896 <para>
34897 <indexterm role="variable">
34898 <primary><varname>$qualify_recipient</varname></primary>
34899 </indexterm>
34900 If this option is set, and an unqualified address (one without a domain) is
34901 generated, and that address would normally be qualified by the global setting
34902 in <option>qualify_recipient</option>, it is instead qualified with the domain specified by
34903 expanding this string. If the expansion fails, the router declines. If you want
34904 to revert to the default, you can have the expansion generate
34905 <varname>$qualify_recipient</varname>.
34906 </para>
34907 <para>
34908 This option applies to all unqualified addresses generated by Exim filters,
34909 but for traditional <filename>.forward</filename> files, it applies only to addresses that are
34910 not preceded by a backslash. Sieve filters cannot generate unqualified
34911 addresses.
34912 </para>
34913 <para>
34914 <indexterm role="option">
34915 <primary><option>qualify_preserve_domain</option></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="6*" align="center"/>
34922 <colspec colwidth="6*" align="center"/>
34923 <colspec colwidth="6*" align="right"/>
34924 <tbody>
34925 <row>
34926 <entry><option>qualify_preserve_domain</option></entry>
34927 <entry>Use: <emphasis>redirect</emphasis></entry>
34928 <entry>Type: <emphasis>boolean</emphasis></entry>
34929 <entry>Default: <emphasis>false</emphasis></entry>
34930 </row>
34931 </tbody>
34932 </tgroup>
34933 </informaltable>
34934 <para>
34935 <indexterm role="concept">
34936 <primary>domain</primary>
34937 <secondary>in redirection; preserving</secondary>
34938 </indexterm>
34939 <indexterm role="concept">
34940 <primary>preserving domain in redirection</primary>
34941 </indexterm>
34942 <indexterm role="concept">
34943 <primary>address redirection</primary>
34944 <secondary>domain; preserving</secondary>
34945 </indexterm>
34946 If this option is set, the router&#x2019;s local <option>qualify_domain</option> option must not be
34947 set (a configuration error occurs if it is). If an unqualified address (one
34948 without a domain) is generated, it is qualified with the domain of the parent
34949 address (the immediately preceding ancestor) instead of the global
34950 <option>qualify_recipient</option> value. In the case of a traditional <filename>.forward</filename> file,
34951 this applies whether or not the address is preceded by a backslash.
34952 </para>
34953 <para>
34954 <indexterm role="option">
34955 <primary><option>repeat_use</option></primary>
34956 </indexterm>
34957 </para>
34958 <informaltable frame="all">
34959 <tgroup cols="4" colsep="0" rowsep="0">
34960 <colspec colwidth="8*" align="left"/>
34961 <colspec colwidth="6*" align="center"/>
34962 <colspec colwidth="6*" align="center"/>
34963 <colspec colwidth="6*" align="right"/>
34964 <tbody>
34965 <row>
34966 <entry><option>repeat_use</option></entry>
34967 <entry>Use: <emphasis>redirect</emphasis></entry>
34968 <entry>Type: <emphasis>boolean</emphasis></entry>
34969 <entry>Default: <emphasis>true</emphasis></entry>
34970 </row>
34971 </tbody>
34972 </tgroup>
34973 </informaltable>
34974 <para>
34975 If this option is set false, the router is skipped for a child address that has
34976 any ancestor that was routed by this router. This test happens before any of
34977 the other preconditions are tested. Exim&#x2019;s default anti-looping rules skip
34978 only when the ancestor is the same as the current address. See also
34979 <option>check_ancestor</option> above and the generic <option>redirect_router</option> option.
34980 </para>
34981 <para>
34982 <indexterm role="option">
34983 <primary><option>reply_transport</option></primary>
34984 </indexterm>
34985 </para>
34986 <informaltable frame="all">
34987 <tgroup cols="4" colsep="0" rowsep="0">
34988 <colspec colwidth="8*" align="left"/>
34989 <colspec colwidth="6*" align="center"/>
34990 <colspec colwidth="6*" align="center"/>
34991 <colspec colwidth="6*" align="right"/>
34992 <tbody>
34993 <row>
34994 <entry><option>reply_transport</option></entry>
34995 <entry>Use: <emphasis>redirect</emphasis></entry>
34996 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34997 <entry>Default: <emphasis>unset</emphasis></entry>
34998 </row>
34999 </tbody>
35000 </tgroup>
35001 </informaltable>
35002 <para>
35003 A <command>redirect</command> router sets up an automatic reply when a <option>mail</option> or
35004 <option>vacation</option> command is used in a filter file. The transport used is specified
35005 by this option, which, after expansion, must be the name of a configured
35006 transport. This should normally be an <command>autoreply</command> transport. Other transports
35007 are unlikely to do anything sensible or useful.
35008 </para>
35009 <para>
35010 <indexterm role="option">
35011 <primary><option>rewrite</option></primary>
35012 </indexterm>
35013 </para>
35014 <informaltable frame="all">
35015 <tgroup cols="4" colsep="0" rowsep="0">
35016 <colspec colwidth="8*" align="left"/>
35017 <colspec colwidth="6*" align="center"/>
35018 <colspec colwidth="6*" align="center"/>
35019 <colspec colwidth="6*" align="right"/>
35020 <tbody>
35021 <row>
35022 <entry><option>rewrite</option></entry>
35023 <entry>Use: <emphasis>redirect</emphasis></entry>
35024 <entry>Type: <emphasis>boolean</emphasis></entry>
35025 <entry>Default: <emphasis>true</emphasis></entry>
35026 </row>
35027 </tbody>
35028 </tgroup>
35029 </informaltable>
35030 <para>
35031 <indexterm role="concept">
35032 <primary>address redirection</primary>
35033 <secondary>disabling rewriting</secondary>
35034 </indexterm>
35035 If this option is set false, addresses generated by the router are not
35036 subject to address rewriting. Otherwise, they are treated like new addresses
35037 and are rewritten according to the global rewriting rules.
35038 </para>
35039 <para>
35040 <indexterm role="option">
35041 <primary><option>sieve_subaddress</option></primary>
35042 </indexterm>
35043 </para>
35044 <informaltable frame="all">
35045 <tgroup cols="4" colsep="0" rowsep="0">
35046 <colspec colwidth="8*" align="left"/>
35047 <colspec colwidth="6*" align="center"/>
35048 <colspec colwidth="6*" align="center"/>
35049 <colspec colwidth="6*" align="right"/>
35050 <tbody>
35051 <row>
35052 <entry><option>sieve_subaddress</option></entry>
35053 <entry>Use: <emphasis>redirect</emphasis></entry>
35054 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35055 <entry>Default: <emphasis>unset</emphasis></entry>
35056 </row>
35057 </tbody>
35058 </tgroup>
35059 </informaltable>
35060 <para>
35061 The value of this option is passed to a Sieve filter to specify the
35062 :subaddress part of an address.
35063 </para>
35064 <para>
35065 <indexterm role="option">
35066 <primary><option>sieve_useraddress</option></primary>
35067 </indexterm>
35068 </para>
35069 <informaltable frame="all">
35070 <tgroup cols="4" colsep="0" rowsep="0">
35071 <colspec colwidth="8*" align="left"/>
35072 <colspec colwidth="6*" align="center"/>
35073 <colspec colwidth="6*" align="center"/>
35074 <colspec colwidth="6*" align="right"/>
35075 <tbody>
35076 <row>
35077 <entry><option>sieve_useraddress</option></entry>
35078 <entry>Use: <emphasis>redirect</emphasis></entry>
35079 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35080 <entry>Default: <emphasis>unset</emphasis></entry>
35081 </row>
35082 </tbody>
35083 </tgroup>
35084 </informaltable>
35085 <para>
35086 The value of this option is passed to a Sieve filter to specify the :user part
35087 of an address. However, if it is unset, the entire original local part
35088 (including any prefix or suffix) is used for :user.
35089 </para>
35090 <para>
35091 <indexterm role="option">
35092 <primary><option>sieve_vacation_directory</option></primary>
35093 </indexterm>
35094 </para>
35095 <informaltable frame="all">
35096 <tgroup cols="4" colsep="0" rowsep="0">
35097 <colspec colwidth="8*" align="left"/>
35098 <colspec colwidth="6*" align="center"/>
35099 <colspec colwidth="6*" align="center"/>
35100 <colspec colwidth="6*" align="right"/>
35101 <tbody>
35102 <row>
35103 <entry><option>sieve_vacation_directory</option></entry>
35104 <entry>Use: <emphasis>redirect</emphasis></entry>
35105 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35106 <entry>Default: <emphasis>unset</emphasis></entry>
35107 </row>
35108 </tbody>
35109 </tgroup>
35110 </informaltable>
35111 <para>
35112 <indexterm role="concept">
35113 <primary>Sieve filter</primary>
35114 <secondary>vacation directory</secondary>
35115 </indexterm>
35116 To enable the <quote>vacation</quote> extension for Sieve filters, you must set
35117 <option>sieve_vacation_directory</option> to the directory where vacation databases are held
35118 (do not put anything else in that directory), and ensure that the
35119 <option>reply_transport</option> option refers to an <command>autoreply</command> transport. Each user
35120 needs their own directory; Exim will create it if necessary.
35121 </para>
35122 <para>
35123 <indexterm role="option">
35124 <primary><option>skip_syntax_errors</option></primary>
35125 </indexterm>
35126 </para>
35127 <informaltable frame="all">
35128 <tgroup cols="4" colsep="0" rowsep="0">
35129 <colspec colwidth="8*" align="left"/>
35130 <colspec colwidth="6*" align="center"/>
35131 <colspec colwidth="6*" align="center"/>
35132 <colspec colwidth="6*" align="right"/>
35133 <tbody>
35134 <row>
35135 <entry><option>skip_syntax_errors</option></entry>
35136 <entry>Use: <emphasis>redirect</emphasis></entry>
35137 <entry>Type: <emphasis>boolean</emphasis></entry>
35138 <entry>Default: <emphasis>false</emphasis></entry>
35139 </row>
35140 </tbody>
35141 </tgroup>
35142 </informaltable>
35143 <para>
35144 <indexterm role="concept">
35145 <primary>forward file</primary>
35146 <secondary>broken</secondary>
35147 </indexterm>
35148 <indexterm role="concept">
35149 <primary>address redirection</primary>
35150 <secondary>broken files</secondary>
35151 </indexterm>
35152 <indexterm role="concept">
35153 <primary>alias file</primary>
35154 <secondary>broken</secondary>
35155 </indexterm>
35156 <indexterm role="concept">
35157 <primary>broken alias or forward files</primary>
35158 </indexterm>
35159 <indexterm role="concept">
35160 <primary>ignoring faulty addresses</primary>
35161 </indexterm>
35162 <indexterm role="concept">
35163 <primary>skipping faulty addresses</primary>
35164 </indexterm>
35165 <indexterm role="concept">
35166 <primary>error</primary>
35167 <secondary>skipping bad syntax</secondary>
35168 </indexterm>
35169 If <option>skip_syntax_errors</option> is set, syntactically malformed addresses in
35170 non-filter redirection data are skipped, and each failing address is logged. If
35171 <option>syntax_errors_to</option> is set, a message is sent to the address it defines,
35172 giving details of the failures. If <option>syntax_errors_text</option> is set, its contents
35173 are expanded and placed at the head of the error message generated by
35174 <option>syntax_errors_to</option>. Usually it is appropriate to set <option>syntax_errors_to</option> to
35175 be the same address as the generic <option>errors_to</option> option. The
35176 <option>skip_syntax_errors</option> option is often used when handling mailing lists.
35177 </para>
35178 <para>
35179 If all the addresses in a redirection list are skipped because of syntax
35180 errors, the router declines to handle the original address, and it is passed to
35181 the following routers.
35182 </para>
35183 <para>
35184 If <option>skip_syntax_errors</option> is set when an Exim filter is interpreted, any syntax
35185 error in the filter causes filtering to be abandoned without any action being
35186 taken. The incident is logged, and the router declines to handle the address,
35187 so it is passed to the following routers.
35188 </para>
35189 <para>
35190 <indexterm role="concept">
35191 <primary>Sieve filter</primary>
35192 <secondary>syntax errors in</secondary>
35193 </indexterm>
35194 Syntax errors in a Sieve filter file cause the <quote>keep</quote> action to occur. This
35195 action is specified by RFC 3028. The values of <option>skip_syntax_errors</option>,
35196 <option>syntax_errors_to</option>, and <option>syntax_errors_text</option> are not used.
35197 </para>
35198 <para>
35199 <option>skip_syntax_errors</option> can be used to specify that errors in users&#x2019; forward
35200 lists or filter files should not prevent delivery. The <option>syntax_errors_to</option>
35201 option, used with an address that does not get redirected, can be used to
35202 notify users of these errors, by means of a router like this:
35203 </para>
35204 <literallayout class="monospaced">
35205 userforward:
35206   driver = redirect
35207   allow_filter
35208   check_local_user
35209   file = $home/.forward
35210   file_transport = address_file
35211   pipe_transport = address_pipe
35212   reply_transport = address_reply
35213   no_verify
35214   skip_syntax_errors
35215   syntax_errors_to = real-$local_part@$domain
35216   syntax_errors_text = \
35217    This is an automatically generated message. An error has\n\
35218    been found in your .forward file. Details of the error are\n\
35219    reported below. While this error persists, you will receive\n\
35220    a copy of this message for every message that is addressed\n\
35221    to you. If your .forward file is a filter file, or if it is\n\
35222    a non-filter file containing no valid forwarding addresses,\n\
35223    a copy of each incoming message will be put in your normal\n\
35224    mailbox. If a non-filter file contains at least one valid\n\
35225    forwarding address, forwarding to the valid addresses will\n\
35226    happen, and those will be the only deliveries that occur.
35227 </literallayout>
35228 <para>
35229 You also need a router to ensure that local addresses that are prefixed by
35230 <literal>real-</literal> are recognized, but not forwarded or filtered. For example, you could
35231 put this immediately before the <command>userforward</command> router:
35232 </para>
35233 <literallayout class="monospaced">
35234 real_localuser:
35235   driver = accept
35236   check_local_user
35237   local_part_prefix = real-
35238   transport = local_delivery
35239 </literallayout>
35240 <para>
35241 For security, it would probably be a good idea to restrict the use of this
35242 router to locally-generated messages, using a condition such as this:
35243 </para>
35244 <literallayout class="monospaced">
35245   condition = ${if match {$sender_host_address}\
35246                          {\N^(|127\.0\.0\.1)$\N}}
35247 </literallayout>
35248 <para>
35249 <indexterm role="option">
35250 <primary><option>syntax_errors_text</option></primary>
35251 </indexterm>
35252 </para>
35253 <informaltable frame="all">
35254 <tgroup cols="4" colsep="0" rowsep="0">
35255 <colspec colwidth="8*" align="left"/>
35256 <colspec colwidth="6*" align="center"/>
35257 <colspec colwidth="6*" align="center"/>
35258 <colspec colwidth="6*" align="right"/>
35259 <tbody>
35260 <row>
35261 <entry><option>syntax_errors_text</option></entry>
35262 <entry>Use: <emphasis>redirect</emphasis></entry>
35263 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35264 <entry>Default: <emphasis>unset</emphasis></entry>
35265 </row>
35266 </tbody>
35267 </tgroup>
35268 </informaltable>
35269 <para>
35270 See <option>skip_syntax_errors</option> above.
35271 </para>
35272 <para>
35273 <indexterm role="option">
35274 <primary><option>syntax_errors_to</option></primary>
35275 </indexterm>
35276 </para>
35277 <informaltable frame="all">
35278 <tgroup cols="4" colsep="0" rowsep="0">
35279 <colspec colwidth="8*" align="left"/>
35280 <colspec colwidth="6*" align="center"/>
35281 <colspec colwidth="6*" align="center"/>
35282 <colspec colwidth="6*" align="right"/>
35283 <tbody>
35284 <row>
35285 <entry><option>syntax_errors_to</option></entry>
35286 <entry>Use: <emphasis>redirect</emphasis></entry>
35287 <entry>Type: <emphasis>string</emphasis></entry>
35288 <entry>Default: <emphasis>unset</emphasis></entry>
35289 </row>
35290 </tbody>
35291 </tgroup>
35292 </informaltable>
35293 <para>
35294 See <option>skip_syntax_errors</option> above.
35295 <indexterm role="concept" startref="IIDredrou1" class="endofrange"/>
35296 <indexterm role="concept" startref="IIDredrou2" class="endofrange"/>
35297 </para>
35298 </section>
35299 </chapter>
35300
35301 <chapter id="CHAPenvironment">
35302 <title>Environment for running local transports</title>
35303 <titleabbrev>Environment for local transports</titleabbrev>
35304 <para>
35305 <indexterm role="concept" id="IIDenvlotra1" class="startofrange">
35306 <primary>local transports</primary>
35307 <secondary>environment for</secondary>
35308 </indexterm>
35309 <indexterm role="concept" id="IIDenvlotra2" class="startofrange">
35310 <primary>environment for local transports</primary>
35311 </indexterm>
35312 <indexterm role="concept" id="IIDenvlotra3" class="startofrange">
35313 <primary>transport</primary>
35314 <secondary>local; environment for</secondary>
35315 </indexterm>
35316 Local transports handle deliveries to files and pipes. (The <command>autoreply</command>
35317 transport can be thought of as similar to a pipe.) Exim always runs transports
35318 in subprocesses, under specified uids and gids. Typical deliveries to local
35319 mailboxes run under the uid and gid of the local user.
35320 </para>
35321 <para>
35322 Exim also sets a specific current directory while running the transport; for
35323 some transports a home directory setting is also relevant. The <command>pipe</command>
35324 transport is the only one that sets up environment variables; see section
35325 <xref linkend="SECTpipeenv"/> for details.
35326 </para>
35327 <para>
35328 The values used for the uid, gid, and the directories may come from several
35329 different places. In many cases, the router that handles the address associates
35330 settings with that address as a result of its <option>check_local_user</option>, <option>group</option>,
35331 or <option>user</option> options. However, values may also be given in the transport&#x2019;s own
35332 configuration, and these override anything that comes from the router.
35333 </para>
35334 <section id="SECID131">
35335 <title>Concurrent deliveries</title>
35336 <para>
35337 <indexterm role="concept">
35338 <primary>concurrent deliveries</primary>
35339 </indexterm>
35340 <indexterm role="concept">
35341 <primary>simultaneous deliveries</primary>
35342 </indexterm>
35343 If two different messages for the same local recipient arrive more or less
35344 simultaneously, the two delivery processes are likely to run concurrently. When
35345 the <command>appendfile</command> transport is used to write to a file, Exim applies locking
35346 rules to stop concurrent processes from writing to the same file at the same
35347 time.
35348 </para>
35349 <para>
35350 However, when you use a <command>pipe</command> transport, it is up to you to arrange any
35351 locking that is needed. Here is a silly example:
35352 </para>
35353 <literallayout class="monospaced">
35354 my_transport:
35355   driver = pipe
35356   command = /bin/sh -c 'cat &gt;&gt;/some/file'
35357 </literallayout>
35358 <para>
35359 This is supposed to write the message at the end of the file. However, if two
35360 messages arrive at the same time, the file will be scrambled. You can use the
35361 <option>exim_lock</option> utility program (see section <xref linkend="SECTmailboxmaint"/>) to lock a
35362 file using the same algorithm that Exim itself uses.
35363 </para>
35364 </section>
35365 <section id="SECTenvuidgid">
35366 <title>Uids and gids</title>
35367 <para>
35368 <indexterm role="concept">
35369 <primary>local transports</primary>
35370 <secondary>uid and gid</secondary>
35371 </indexterm>
35372 <indexterm role="concept">
35373 <primary>transport</primary>
35374 <secondary>local; uid and gid</secondary>
35375 </indexterm>
35376 All transports have the options <option>group</option> and <option>user</option>. If <option>group</option> is set, it
35377 overrides any group that the router set in the address, even if <option>user</option> is not
35378 set for the transport. This makes it possible, for example, to run local mail
35379 delivery under the uid of the recipient (set by the router), but in a special
35380 group (set by the transport). For example:
35381 </para>
35382 <literallayout class="monospaced">
35383 # Routers ...
35384 # User/group are set by check_local_user in this router
35385 local_users:
35386   driver = accept
35387   check_local_user
35388   transport = group_delivery
35389
35390 # Transports ...
35391 # This transport overrides the group
35392 group_delivery:
35393   driver = appendfile
35394   file = /var/spool/mail/$local_part
35395   group = mail
35396 </literallayout>
35397 <para>
35398 If <option>user</option> is set for a transport, its value overrides what is set in the
35399 address by the router. If <option>user</option> is non-numeric and <option>group</option> is not set, the
35400 gid associated with the user is used. If <option>user</option> is numeric, <option>group</option> must be
35401 set.
35402 </para>
35403 <para>
35404 <indexterm role="option">
35405 <primary><option>initgroups</option></primary>
35406 </indexterm>
35407 When the uid is taken from the transport&#x2019;s configuration, the <function>initgroups()</function>
35408 function is called for the groups associated with that uid if the
35409 <option>initgroups</option> option is set for the transport. When the uid is not specified
35410 by the transport, but is associated with the address by a router, the option
35411 for calling <function>initgroups()</function> is taken from the router configuration.
35412 </para>
35413 <para>
35414 <indexterm role="concept">
35415 <primary><command>pipe</command> transport</primary>
35416 <secondary>uid for</secondary>
35417 </indexterm>
35418 The <command>pipe</command> transport contains the special option <option>pipe_as_creator</option>. If this
35419 is set and <option>user</option> is not set, the uid of the process that called Exim to
35420 receive the message is used, and if <option>group</option> is not set, the corresponding
35421 original gid is also used.
35422 </para>
35423 <para>
35424 This is the detailed preference order for obtaining a gid; the first of the
35425 following that is set is used:
35426 </para>
35427 <itemizedlist>
35428 <listitem>
35429 <para>
35430 A <option>group</option> setting of the transport;
35431 </para>
35432 </listitem>
35433 <listitem>
35434 <para>
35435 A <option>group</option> setting of the router;
35436 </para>
35437 </listitem>
35438 <listitem>
35439 <para>
35440 A gid associated with a user setting of the router, either as a result of
35441 <option>check_local_user</option> or an explicit non-numeric <option>user</option> setting;
35442 </para>
35443 </listitem>
35444 <listitem>
35445 <para>
35446 The group associated with a non-numeric <option>user</option> setting of the transport;
35447 </para>
35448 </listitem>
35449 <listitem>
35450 <para>
35451 In a <command>pipe</command> transport, the creator&#x2019;s gid if <option>deliver_as_creator</option> is set and
35452 the uid is the creator&#x2019;s uid;
35453 </para>
35454 </listitem>
35455 <listitem>
35456 <para>
35457 The Exim gid if the Exim uid is being used as a default.
35458 </para>
35459 </listitem>
35460 </itemizedlist>
35461 <para>
35462 If, for example, the user is specified numerically on the router and there are
35463 no group settings, no gid is available. In this situation, an error occurs.
35464 This is different for the uid, for which there always is an ultimate default.
35465 The first of the following that is set is used:
35466 </para>
35467 <itemizedlist>
35468 <listitem>
35469 <para>
35470 A <option>user</option> setting of the transport;
35471 </para>
35472 </listitem>
35473 <listitem>
35474 <para>
35475 In a <command>pipe</command> transport, the creator&#x2019;s uid if <option>deliver_as_creator</option> is set;
35476 </para>
35477 </listitem>
35478 <listitem>
35479 <para>
35480 A <option>user</option> setting of the router;
35481 </para>
35482 </listitem>
35483 <listitem>
35484 <para>
35485 A <option>check_local_user</option> setting of the router;
35486 </para>
35487 </listitem>
35488 <listitem>
35489 <para>
35490 The Exim uid.
35491 </para>
35492 </listitem>
35493 </itemizedlist>
35494 <para>
35495 Of course, an error will still occur if the uid that is chosen is on the
35496 <option>never_users</option> list.
35497 </para>
35498 </section>
35499 <section id="SECID132">
35500 <title>Current and home directories</title>
35501 <para>
35502 <indexterm role="concept">
35503 <primary>current directory for local transport</primary>
35504 </indexterm>
35505 <indexterm role="concept">
35506 <primary>home directory</primary>
35507 <secondary>for local transport</secondary>
35508 </indexterm>
35509 <indexterm role="concept">
35510 <primary>transport</primary>
35511 <secondary>local; home directory for</secondary>
35512 </indexterm>
35513 <indexterm role="concept">
35514 <primary>transport</primary>
35515 <secondary>local; current directory for</secondary>
35516 </indexterm>
35517 Routers may set current and home directories for local transports by means of
35518 the <option>transport_current_directory</option> and <option>transport_home_directory</option> options.
35519 However, if the transport&#x2019;s <option>current_directory</option> or <option>home_directory</option> options
35520 are set, they override the router&#x2019;s values. In detail, the home directory
35521 for a local transport is taken from the first of these values that is set:
35522 </para>
35523 <itemizedlist>
35524 <listitem>
35525 <para>
35526 The <option>home_directory</option> option on the transport;
35527 </para>
35528 </listitem>
35529 <listitem>
35530 <para>
35531 The <option>transport_home_directory</option> option on the router;
35532 </para>
35533 </listitem>
35534 <listitem>
35535 <para>
35536 The password data if <option>check_local_user</option> is set on the router;
35537 </para>
35538 </listitem>
35539 <listitem>
35540 <para>
35541 The <option>router_home_directory</option> option on the router.
35542 </para>
35543 </listitem>
35544 </itemizedlist>
35545 <para>
35546 The current directory is taken from the first of these values that is set:
35547 </para>
35548 <itemizedlist>
35549 <listitem>
35550 <para>
35551 The <option>current_directory</option> option on the transport;
35552 </para>
35553 </listitem>
35554 <listitem>
35555 <para>
35556 The <option>transport_current_directory</option> option on the router.
35557 </para>
35558 </listitem>
35559 </itemizedlist>
35560 <para>
35561 If neither the router nor the transport sets a current directory, Exim uses the
35562 value of the home directory, if it is set. Otherwise it sets the current
35563 directory to <filename>/</filename> before running a local transport.
35564 </para>
35565 </section>
35566 <section id="SECID133">
35567 <title>Expansion variables derived from the address</title>
35568 <para>
35569 <indexterm role="variable">
35570 <primary><varname>$domain</varname></primary>
35571 </indexterm>
35572 <indexterm role="variable">
35573 <primary><varname>$local_part</varname></primary>
35574 </indexterm>
35575 <indexterm role="variable">
35576 <primary><varname>$original_domain</varname></primary>
35577 </indexterm>
35578 Normally a local delivery is handling a single address, and in that case the
35579 variables such as <varname>$domain</varname> and <varname>$local_part</varname> are set during local
35580 deliveries. However, in some circumstances more than one address may be handled
35581 at once (for example, while writing batch SMTP for onward transmission by some
35582 other means). In this case, the variables associated with the local part are
35583 never set, <varname>$domain</varname> is set only if all the addresses have the same domain,
35584 and <varname>$original_domain</varname> is never set.
35585 <indexterm role="concept" startref="IIDenvlotra1" class="endofrange"/>
35586 <indexterm role="concept" startref="IIDenvlotra2" class="endofrange"/>
35587 <indexterm role="concept" startref="IIDenvlotra3" class="endofrange"/>
35588 </para>
35589 </section>
35590 </chapter>
35591
35592 <chapter id="CHAPtransportgeneric">
35593 <title>Generic options for transports</title>
35594 <para>
35595 <indexterm role="concept" id="IIDgenoptra1" class="startofrange">
35596 <primary>generic options</primary>
35597 <secondary>transport</secondary>
35598 </indexterm>
35599 <indexterm role="concept" id="IIDgenoptra2" class="startofrange">
35600 <primary>options</primary>
35601 <secondary>generic; for transports</secondary>
35602 </indexterm>
35603 <indexterm role="concept" id="IIDgenoptra3" class="startofrange">
35604 <primary>transport</primary>
35605 <secondary>generic options for</secondary>
35606 </indexterm>
35607 The following generic options apply to all transports:
35608 </para>
35609 <para>
35610 <indexterm role="option">
35611 <primary><option>body_only</option></primary>
35612 </indexterm>
35613 </para>
35614 <informaltable frame="all">
35615 <tgroup cols="4" colsep="0" rowsep="0">
35616 <colspec colwidth="8*" align="left"/>
35617 <colspec colwidth="6*" align="center"/>
35618 <colspec colwidth="6*" align="center"/>
35619 <colspec colwidth="6*" align="right"/>
35620 <tbody>
35621 <row>
35622 <entry><option>body_only</option></entry>
35623 <entry>Use: <emphasis>transports</emphasis></entry>
35624 <entry>Type: <emphasis>boolean</emphasis></entry>
35625 <entry>Default: <emphasis>false</emphasis></entry>
35626 </row>
35627 </tbody>
35628 </tgroup>
35629 </informaltable>
35630 <para>
35631 <indexterm role="concept">
35632 <primary>transport</primary>
35633 <secondary>body only</secondary>
35634 </indexterm>
35635 <indexterm role="concept">
35636 <primary>message</primary>
35637 <secondary>transporting body only</secondary>
35638 </indexterm>
35639 <indexterm role="concept">
35640 <primary>body of message</primary>
35641 <secondary>transporting</secondary>
35642 </indexterm>
35643 If this option is set, the message&#x2019;s headers are not transported. It is
35644 mutually exclusive with <option>headers_only</option>. If it is used with the <command>appendfile</command>
35645 or <command>pipe</command> transports, the settings of <option>message_prefix</option> and
35646 <option>message_suffix</option> should be checked, because this option does not
35647 automatically suppress them.
35648 </para>
35649 <para>
35650 <indexterm role="option">
35651 <primary><option>current_directory</option></primary>
35652 </indexterm>
35653 </para>
35654 <informaltable frame="all">
35655 <tgroup cols="4" colsep="0" rowsep="0">
35656 <colspec colwidth="8*" align="left"/>
35657 <colspec colwidth="6*" align="center"/>
35658 <colspec colwidth="6*" align="center"/>
35659 <colspec colwidth="6*" align="right"/>
35660 <tbody>
35661 <row>
35662 <entry><option>current_directory</option></entry>
35663 <entry>Use: <emphasis>transports</emphasis></entry>
35664 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35665 <entry>Default: <emphasis>unset</emphasis></entry>
35666 </row>
35667 </tbody>
35668 </tgroup>
35669 </informaltable>
35670 <para>
35671 <indexterm role="concept">
35672 <primary>transport</primary>
35673 <secondary>current directory for</secondary>
35674 </indexterm>
35675 This specifies the current directory that is to be set while running the
35676 transport, overriding any value that may have been set by the router.
35677 If the expansion fails for any reason, including forced failure, an error is
35678 logged, and delivery is deferred.
35679 </para>
35680 <para>
35681 <indexterm role="option">
35682 <primary><option>disable_logging</option></primary>
35683 </indexterm>
35684 </para>
35685 <informaltable frame="all">
35686 <tgroup cols="4" colsep="0" rowsep="0">
35687 <colspec colwidth="8*" align="left"/>
35688 <colspec colwidth="6*" align="center"/>
35689 <colspec colwidth="6*" align="center"/>
35690 <colspec colwidth="6*" align="right"/>
35691 <tbody>
35692 <row>
35693 <entry><option>disable_logging</option></entry>
35694 <entry>Use: <emphasis>transports</emphasis></entry>
35695 <entry>Type: <emphasis>boolean</emphasis></entry>
35696 <entry>Default: <emphasis>false</emphasis></entry>
35697 </row>
35698 </tbody>
35699 </tgroup>
35700 </informaltable>
35701 <para>
35702 If this option is set true, nothing is logged for any
35703 deliveries by the transport or for any
35704 transport errors. You should not set this option unless you really, really know
35705 what you are doing.
35706 </para>
35707 <para>
35708 <indexterm role="option">
35709 <primary><option>debug_print</option></primary>
35710 </indexterm>
35711 </para>
35712 <informaltable frame="all">
35713 <tgroup cols="4" colsep="0" rowsep="0">
35714 <colspec colwidth="8*" align="left"/>
35715 <colspec colwidth="6*" align="center"/>
35716 <colspec colwidth="6*" align="center"/>
35717 <colspec colwidth="6*" align="right"/>
35718 <tbody>
35719 <row>
35720 <entry><option>debug_print</option></entry>
35721 <entry>Use: <emphasis>transports</emphasis></entry>
35722 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35723 <entry>Default: <emphasis>unset</emphasis></entry>
35724 </row>
35725 </tbody>
35726 </tgroup>
35727 </informaltable>
35728 <para>
35729 <indexterm role="concept">
35730 <primary>testing</primary>
35731 <secondary>variables in drivers</secondary>
35732 </indexterm>
35733 If this option is set and debugging is enabled (see the <option>-d</option> command line
35734 option), the string is expanded and included in the debugging output when the
35735 transport is run.
35736 If expansion of the string fails, the error message is written to the debugging
35737 output, and Exim carries on processing.
35738 This facility is provided to help with checking out the values of variables and
35739 so on when debugging driver configurations. For example, if a <option>headers_add</option>
35740 option is not working properly, <option>debug_print</option> could be used to output the
35741 variables it references. A newline is added to the text if it does not end with
35742 one.
35743 </para>
35744 <para>
35745 <indexterm role="option">
35746 <primary><option>delivery_date_add</option></primary>
35747 </indexterm>
35748 </para>
35749 <informaltable frame="all">
35750 <tgroup cols="4" colsep="0" rowsep="0">
35751 <colspec colwidth="8*" align="left"/>
35752 <colspec colwidth="6*" align="center"/>
35753 <colspec colwidth="6*" align="center"/>
35754 <colspec colwidth="6*" align="right"/>
35755 <tbody>
35756 <row>
35757 <entry><option>delivery_date_add</option></entry>
35758 <entry>Use: <emphasis>transports</emphasis></entry>
35759 <entry>Type: <emphasis>boolean</emphasis></entry>
35760 <entry>Default: <emphasis>false</emphasis></entry>
35761 </row>
35762 </tbody>
35763 </tgroup>
35764 </informaltable>
35765 <para>
35766 <indexterm role="concept">
35767 <primary><emphasis>Delivery-date:</emphasis> header line</primary>
35768 </indexterm>
35769 If this option is true, a <emphasis>Delivery-date:</emphasis> header is added to the message.
35770 This gives the actual time the delivery was made. As this is not a standard
35771 header, Exim has a configuration option (<option>delivery_date_remove</option>) which
35772 requests its removal from incoming messages, so that delivered messages can
35773 safely be resent to other recipients.
35774 </para>
35775 <para>
35776 <indexterm role="option">
35777 <primary><option>driver</option></primary>
35778 </indexterm>
35779 </para>
35780 <informaltable frame="all">
35781 <tgroup cols="4" colsep="0" rowsep="0">
35782 <colspec colwidth="8*" align="left"/>
35783 <colspec colwidth="6*" align="center"/>
35784 <colspec colwidth="6*" align="center"/>
35785 <colspec colwidth="6*" align="right"/>
35786 <tbody>
35787 <row>
35788 <entry><option>driver</option></entry>
35789 <entry>Use: <emphasis>transports</emphasis></entry>
35790 <entry>Type: <emphasis>string</emphasis></entry>
35791 <entry>Default: <emphasis>unset</emphasis></entry>
35792 </row>
35793 </tbody>
35794 </tgroup>
35795 </informaltable>
35796 <para>
35797 This specifies which of the available transport drivers is to be used.
35798 There is no default, and this option must be set for every transport.
35799 </para>
35800 <para>
35801 <indexterm role="option">
35802 <primary><option>envelope_to_add</option></primary>
35803 </indexterm>
35804 </para>
35805 <informaltable frame="all">
35806 <tgroup cols="4" colsep="0" rowsep="0">
35807 <colspec colwidth="8*" align="left"/>
35808 <colspec colwidth="6*" align="center"/>
35809 <colspec colwidth="6*" align="center"/>
35810 <colspec colwidth="6*" align="right"/>
35811 <tbody>
35812 <row>
35813 <entry><option>envelope_to_add</option></entry>
35814 <entry>Use: <emphasis>transports</emphasis></entry>
35815 <entry>Type: <emphasis>boolean</emphasis></entry>
35816 <entry>Default: <emphasis>false</emphasis></entry>
35817 </row>
35818 </tbody>
35819 </tgroup>
35820 </informaltable>
35821 <para>
35822 <indexterm role="concept">
35823 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
35824 </indexterm>
35825 If this option is true, an <emphasis>Envelope-to:</emphasis> header is added to the message.
35826 This gives the original address(es) in the incoming envelope that caused this
35827 delivery to happen. More than one address may be present if the transport is
35828 configured to handle several addresses at once, or if more than one original
35829 address was redirected to the same final address. As this is not a standard
35830 header, Exim has a configuration option (<option>envelope_to_remove</option>) which requests
35831 its removal from incoming messages, so that delivered messages can safely be
35832 resent to other recipients.
35833 </para>
35834 <para>
35835 <indexterm role="option">
35836 <primary><option>group</option></primary>
35837 </indexterm>
35838 </para>
35839 <informaltable frame="all">
35840 <tgroup cols="4" colsep="0" rowsep="0">
35841 <colspec colwidth="8*" align="left"/>
35842 <colspec colwidth="6*" align="center"/>
35843 <colspec colwidth="6*" align="center"/>
35844 <colspec colwidth="6*" align="right"/>
35845 <tbody>
35846 <row>
35847 <entry><option>group</option></entry>
35848 <entry>Use: <emphasis>transports</emphasis></entry>
35849 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35850 <entry>Default: <emphasis>Exim group</emphasis></entry>
35851 </row>
35852 </tbody>
35853 </tgroup>
35854 </informaltable>
35855 <para>
35856 <indexterm role="concept">
35857 <primary>transport</primary>
35858 <secondary>group; specifying</secondary>
35859 </indexterm>
35860 This option specifies a gid for running the transport process, overriding any
35861 value that the router supplies, and also overriding any value associated with
35862 <option>user</option> (see below).
35863 </para>
35864 <para>
35865 <indexterm role="option">
35866 <primary><option>headers_add</option></primary>
35867 </indexterm>
35868 </para>
35869 <informaltable frame="all">
35870 <tgroup cols="4" colsep="0" rowsep="0">
35871 <colspec colwidth="8*" align="left"/>
35872 <colspec colwidth="6*" align="center"/>
35873 <colspec colwidth="6*" align="center"/>
35874 <colspec colwidth="6*" align="right"/>
35875 <tbody>
35876 <row>
35877 <entry><option>headers_add</option></entry>
35878 <entry>Use: <emphasis>transports</emphasis></entry>
35879 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35880 <entry>Default: <emphasis>unset</emphasis></entry>
35881 </row>
35882 </tbody>
35883 </tgroup>
35884 </informaltable>
35885 <para>
35886 <indexterm role="concept">
35887 <primary>header lines</primary>
35888 <secondary>adding in transport</secondary>
35889 </indexterm>
35890 <indexterm role="concept">
35891 <primary>transport</primary>
35892 <secondary>header lines; adding</secondary>
35893 </indexterm>
35894 This option specifies a string of text that is expanded and added to the header
35895 portion of a message as it is transported, as described in section
35896 <xref linkend="SECTheadersaddrem"/>. Additional header lines can also be specified by
35897 routers. If the result of the expansion is an empty string, or if the expansion
35898 is forced to fail, no action is taken. Other expansion failures are treated as
35899 errors and cause the delivery to be deferred.
35900 </para>
35901 <para>
35902 <indexterm role="option">
35903 <primary><option>headers_only</option></primary>
35904 </indexterm>
35905 </para>
35906 <informaltable frame="all">
35907 <tgroup cols="4" colsep="0" rowsep="0">
35908 <colspec colwidth="8*" align="left"/>
35909 <colspec colwidth="6*" align="center"/>
35910 <colspec colwidth="6*" align="center"/>
35911 <colspec colwidth="6*" align="right"/>
35912 <tbody>
35913 <row>
35914 <entry><option>headers_only</option></entry>
35915 <entry>Use: <emphasis>transports</emphasis></entry>
35916 <entry>Type: <emphasis>boolean</emphasis></entry>
35917 <entry>Default: <emphasis>false</emphasis></entry>
35918 </row>
35919 </tbody>
35920 </tgroup>
35921 </informaltable>
35922 <para>
35923 <indexterm role="concept">
35924 <primary>transport</primary>
35925 <secondary>header lines only</secondary>
35926 </indexterm>
35927 <indexterm role="concept">
35928 <primary>message</primary>
35929 <secondary>transporting headers only</secondary>
35930 </indexterm>
35931 <indexterm role="concept">
35932 <primary>header lines</primary>
35933 <secondary>transporting</secondary>
35934 </indexterm>
35935 If this option is set, the message&#x2019;s body is not transported. It is mutually
35936 exclusive with <option>body_only</option>. If it is used with the <command>appendfile</command> or <command>pipe</command>
35937 transports, the settings of <option>message_prefix</option> and <option>message_suffix</option> should be
35938 checked, since this option does not automatically suppress them.
35939 </para>
35940 <para>
35941 <indexterm role="option">
35942 <primary><option>headers_remove</option></primary>
35943 </indexterm>
35944 </para>
35945 <informaltable frame="all">
35946 <tgroup cols="4" colsep="0" rowsep="0">
35947 <colspec colwidth="8*" align="left"/>
35948 <colspec colwidth="6*" align="center"/>
35949 <colspec colwidth="6*" align="center"/>
35950 <colspec colwidth="6*" align="right"/>
35951 <tbody>
35952 <row>
35953 <entry><option>headers_remove</option></entry>
35954 <entry>Use: <emphasis>transports</emphasis></entry>
35955 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35956 <entry>Default: <emphasis>unset</emphasis></entry>
35957 </row>
35958 </tbody>
35959 </tgroup>
35960 </informaltable>
35961 <para>
35962 <indexterm role="concept">
35963 <primary>header lines</primary>
35964 <secondary>removing</secondary>
35965 </indexterm>
35966 <indexterm role="concept">
35967 <primary>transport</primary>
35968 <secondary>header lines; removing</secondary>
35969 </indexterm>
35970 This option specifies a string that is expanded into a list of header names;
35971 these headers are omitted from the message as it is transported, as described
35972 in section <xref linkend="SECTheadersaddrem"/>. Header removal can also be specified by
35973 routers. If the result of the expansion is an empty string, or if the expansion
35974 is forced to fail, no action is taken. Other expansion failures are treated as
35975 errors and cause the delivery to be deferred.
35976 </para>
35977 <para>
35978 <indexterm role="option">
35979 <primary><option>headers_rewrite</option></primary>
35980 </indexterm>
35981 </para>
35982 <informaltable frame="all">
35983 <tgroup cols="4" colsep="0" rowsep="0">
35984 <colspec colwidth="8*" align="left"/>
35985 <colspec colwidth="6*" align="center"/>
35986 <colspec colwidth="6*" align="center"/>
35987 <colspec colwidth="6*" align="right"/>
35988 <tbody>
35989 <row>
35990 <entry><option>headers_rewrite</option></entry>
35991 <entry>Use: <emphasis>transports</emphasis></entry>
35992 <entry>Type: <emphasis>string</emphasis></entry>
35993 <entry>Default: <emphasis>unset</emphasis></entry>
35994 </row>
35995 </tbody>
35996 </tgroup>
35997 </informaltable>
35998 <para>
35999 <indexterm role="concept">
36000 <primary>transport</primary>
36001 <secondary>header lines; rewriting</secondary>
36002 </indexterm>
36003 <indexterm role="concept">
36004 <primary>rewriting</primary>
36005 <secondary>at transport time</secondary>
36006 </indexterm>
36007 This option allows addresses in header lines to be rewritten at transport time,
36008 that is, as the message is being copied to its destination. The contents of the
36009 option are a colon-separated list of rewriting rules. Each rule is in exactly
36010 the same form as one of the general rewriting rules that are applied when a
36011 message is received. These are described in chapter <xref linkend="CHAPrewrite"/>. For
36012 example,
36013 </para>
36014 <literallayout class="monospaced">
36015 headers_rewrite = a@b c@d f : \
36016                   x@y w@z
36017 </literallayout>
36018 <para>
36019 changes <emphasis>a@b</emphasis> into <emphasis>c@d</emphasis> in <emphasis>From:</emphasis> header lines, and <emphasis>x@y</emphasis> into
36020 <emphasis>w@z</emphasis> in all address-bearing header lines. The rules are applied to the
36021 header lines just before they are written out at transport time, so they affect
36022 only those copies of the message that pass through the transport. However, only
36023 the message&#x2019;s original header lines, and any that were added by a system
36024 filter, are rewritten. If a router or transport adds header lines, they are not
36025 affected by this option. These rewriting rules are <emphasis>not</emphasis> applied to the
36026 envelope. You can change the return path using <option>return_path</option>, but you cannot
36027 change envelope recipients at this time.
36028 </para>
36029 <para>
36030 <indexterm role="option">
36031 <primary><option>home_directory</option></primary>
36032 </indexterm>
36033 </para>
36034 <informaltable frame="all">
36035 <tgroup cols="4" colsep="0" rowsep="0">
36036 <colspec colwidth="8*" align="left"/>
36037 <colspec colwidth="6*" align="center"/>
36038 <colspec colwidth="6*" align="center"/>
36039 <colspec colwidth="6*" align="right"/>
36040 <tbody>
36041 <row>
36042 <entry><option>home_directory</option></entry>
36043 <entry>Use: <emphasis>transports</emphasis></entry>
36044 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36045 <entry>Default: <emphasis>unset</emphasis></entry>
36046 </row>
36047 </tbody>
36048 </tgroup>
36049 </informaltable>
36050 <para>
36051 <indexterm role="concept">
36052 <primary>transport</primary>
36053 <secondary>home directory for</secondary>
36054 </indexterm>
36055 <indexterm role="variable">
36056 <primary><varname>$home</varname></primary>
36057 </indexterm>
36058 This option specifies a home directory setting for a local transport,
36059 overriding any value that may be set by the router. The home directory is
36060 placed in <varname>$home</varname> while expanding the transport&#x2019;s private options. It is also
36061 used as the current directory if no current directory is set by the
36062 <option>current_directory</option> option on the transport or the
36063 <option>transport_current_directory</option> option on the router. If the expansion fails
36064 for any reason, including forced failure, an error is logged, and delivery is
36065 deferred.
36066 </para>
36067 <para>
36068 <indexterm role="option">
36069 <primary><option>initgroups</option></primary>
36070 </indexterm>
36071 </para>
36072 <informaltable frame="all">
36073 <tgroup cols="4" colsep="0" rowsep="0">
36074 <colspec colwidth="8*" align="left"/>
36075 <colspec colwidth="6*" align="center"/>
36076 <colspec colwidth="6*" align="center"/>
36077 <colspec colwidth="6*" align="right"/>
36078 <tbody>
36079 <row>
36080 <entry><option>initgroups</option></entry>
36081 <entry>Use: <emphasis>transports</emphasis></entry>
36082 <entry>Type: <emphasis>boolean</emphasis></entry>
36083 <entry>Default: <emphasis>false</emphasis></entry>
36084 </row>
36085 </tbody>
36086 </tgroup>
36087 </informaltable>
36088 <para>
36089 <indexterm role="concept">
36090 <primary>additional groups</primary>
36091 </indexterm>
36092 <indexterm role="concept">
36093 <primary>groups</primary>
36094 <secondary>additional</secondary>
36095 </indexterm>
36096 <indexterm role="concept">
36097 <primary>transport</primary>
36098 <secondary>group; additional</secondary>
36099 </indexterm>
36100 If this option is true and the uid for the delivery process is provided by the
36101 transport, the <function>initgroups()</function> function is called when running the transport
36102 to ensure that any additional groups associated with the uid are set up.
36103 </para>
36104 <para>
36105 <indexterm role="option">
36106 <primary><option>message_size_limit</option></primary>
36107 </indexterm>
36108 </para>
36109 <informaltable frame="all">
36110 <tgroup cols="4" colsep="0" rowsep="0">
36111 <colspec colwidth="8*" align="left"/>
36112 <colspec colwidth="6*" align="center"/>
36113 <colspec colwidth="6*" align="center"/>
36114 <colspec colwidth="6*" align="right"/>
36115 <tbody>
36116 <row>
36117 <entry><option>message_size_limit</option></entry>
36118 <entry>Use: <emphasis>transports</emphasis></entry>
36119 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36120 <entry>Default: <emphasis>0</emphasis></entry>
36121 </row>
36122 </tbody>
36123 </tgroup>
36124 </informaltable>
36125 <para>
36126 <indexterm role="concept">
36127 <primary>limit</primary>
36128 <secondary>message size per transport</secondary>
36129 </indexterm>
36130 <indexterm role="concept">
36131 <primary>size</primary>
36132 <secondary>of message, limit</secondary>
36133 </indexterm>
36134 <indexterm role="concept">
36135 <primary>transport</primary>
36136 <secondary>message size; limiting</secondary>
36137 </indexterm>
36138 This option controls the size of messages passed through the transport. It is
36139 expanded before use; the result of the expansion must be a sequence of decimal
36140 digits, optionally followed by K or M. If the expansion fails for any reason,
36141 including forced failure, or if the result is not of the required form,
36142 delivery is deferred. If the value is greater than zero and the size of a
36143 message exceeds this limit, the address is failed. If there is any chance that
36144 the resulting bounce message could be routed to the same transport, you should
36145 ensure that <option>return_size_limit</option> is less than the transport&#x2019;s
36146 <option>message_size_limit</option>, as otherwise the bounce message will fail to get
36147 delivered.
36148 </para>
36149 <para>
36150 <indexterm role="option">
36151 <primary><option>rcpt_include_affixes</option></primary>
36152 </indexterm>
36153 </para>
36154 <informaltable frame="all">
36155 <tgroup cols="4" colsep="0" rowsep="0">
36156 <colspec colwidth="8*" align="left"/>
36157 <colspec colwidth="6*" align="center"/>
36158 <colspec colwidth="6*" align="center"/>
36159 <colspec colwidth="6*" align="right"/>
36160 <tbody>
36161 <row>
36162 <entry><option>rcpt_include_affixes</option></entry>
36163 <entry>Use: <emphasis>transports</emphasis></entry>
36164 <entry>Type: <emphasis>boolean</emphasis></entry>
36165 <entry>Default: <emphasis>false</emphasis></entry>
36166 </row>
36167 </tbody>
36168 </tgroup>
36169 </informaltable>
36170 <para>
36171 <indexterm role="concept">
36172 <primary>prefix</primary>
36173 <secondary>for local part, including in envelope</secondary>
36174 </indexterm>
36175 <indexterm role="concept">
36176 <primary>suffix for local part</primary>
36177 <secondary>including in envelope</secondary>
36178 </indexterm>
36179 <indexterm role="concept">
36180 <primary>local part</primary>
36181 <secondary>prefix</secondary>
36182 </indexterm>
36183 <indexterm role="concept">
36184 <primary>local part</primary>
36185 <secondary>suffix</secondary>
36186 </indexterm>
36187 When this option is false (the default), and an address that has had any
36188 affixes (prefixes or suffixes) removed from the local part is delivered by any
36189 form of SMTP or LMTP, the affixes are not included. For example, if a router
36190 that contains
36191 </para>
36192 <literallayout class="monospaced">
36193 local_part_prefix = *-
36194 </literallayout>
36195 <para>
36196 routes the address <emphasis>abc-xyz@some.domain</emphasis> to an SMTP transport, the envelope
36197 is delivered with
36198 </para>
36199 <literallayout class="monospaced">
36200 RCPT TO:&lt;xyz@some.domain&gt;
36201 </literallayout>
36202 <para>
36203 This is also the case when an ACL-time callout is being used to verify a
36204 recipient address. However, if <option>rcpt_include_affixes</option> is set true, the
36205 whole local part is included in the RCPT command. This option applies to BSMTP
36206 deliveries by the <command>appendfile</command> and <command>pipe</command> transports as well as to the
36207 <command>lmtp</command> and <command>smtp</command> transports.
36208 </para>
36209 <para>
36210 <indexterm role="option">
36211 <primary><option>retry_use_local_part</option></primary>
36212 </indexterm>
36213 </para>
36214 <informaltable frame="all">
36215 <tgroup cols="4" colsep="0" rowsep="0">
36216 <colspec colwidth="8*" align="left"/>
36217 <colspec colwidth="6*" align="center"/>
36218 <colspec colwidth="6*" align="center"/>
36219 <colspec colwidth="6*" align="right"/>
36220 <tbody>
36221 <row>
36222 <entry><option>retry_use_local_part</option></entry>
36223 <entry>Use: <emphasis>transports</emphasis></entry>
36224 <entry>Type: <emphasis>boolean</emphasis></entry>
36225 <entry>Default: <emphasis>see below</emphasis></entry>
36226 </row>
36227 </tbody>
36228 </tgroup>
36229 </informaltable>
36230 <para>
36231 <indexterm role="concept">
36232 <primary>hints database</primary>
36233 <secondary>retry keys</secondary>
36234 </indexterm>
36235 When a delivery suffers a temporary failure, a retry record is created
36236 in Exim&#x2019;s hints database. For remote deliveries, the key for the retry record
36237 is based on the name and/or IP address of the failing remote host. For local
36238 deliveries, the key is normally the entire address, including both the local
36239 part and the domain. This is suitable for most common cases of local delivery
36240 temporary failure &ndash; for example, exceeding a mailbox quota should delay only
36241 deliveries to that mailbox, not to the whole domain.
36242 </para>
36243 <para>
36244 However, in some special cases you may want to treat a temporary local delivery
36245 as a failure associated with the domain, and not with a particular local part.
36246 (For example, if you are storing all mail for some domain in files.) You can do
36247 this by setting <option>retry_use_local_part</option> false.
36248 </para>
36249 <para>
36250 For all the local transports, its default value is true. For remote transports,
36251 the default value is false for tidiness, but changing the value has no effect
36252 on a remote transport in the current implementation.
36253 </para>
36254 <para>
36255 <indexterm role="option">
36256 <primary><option>return_path</option></primary>
36257 </indexterm>
36258 </para>
36259 <informaltable frame="all">
36260 <tgroup cols="4" colsep="0" rowsep="0">
36261 <colspec colwidth="8*" align="left"/>
36262 <colspec colwidth="6*" align="center"/>
36263 <colspec colwidth="6*" align="center"/>
36264 <colspec colwidth="6*" align="right"/>
36265 <tbody>
36266 <row>
36267 <entry><option>return_path</option></entry>
36268 <entry>Use: <emphasis>transports</emphasis></entry>
36269 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36270 <entry>Default: <emphasis>unset</emphasis></entry>
36271 </row>
36272 </tbody>
36273 </tgroup>
36274 </informaltable>
36275 <para>
36276 <indexterm role="concept">
36277 <primary>envelope sender</primary>
36278 </indexterm>
36279 <indexterm role="concept">
36280 <primary>transport</primary>
36281 <secondary>return path; changing</secondary>
36282 </indexterm>
36283 <indexterm role="concept">
36284 <primary>return path</primary>
36285 <secondary>changing in transport</secondary>
36286 </indexterm>
36287 If this option is set, the string is expanded at transport time and replaces
36288 the existing return path (envelope sender) value in the copy of the message
36289 that is being delivered. An empty return path is permitted. This feature is
36290 designed for remote deliveries, where the value of this option is used in the
36291 SMTP MAIL command. If you set <option>return_path</option> for a local transport, the
36292 only effect is to change the address that is placed in the <emphasis>Return-path:</emphasis>
36293 header line, if one is added to the message (see the next option).
36294 </para>
36295 <para>
36296 <emphasis role="bold">Note:</emphasis> A changed return path is not logged unless you add
36297 <option>return_path_on_delivery</option> to the log selector.
36298 </para>
36299 <para>
36300 <indexterm role="variable">
36301 <primary><varname>$return_path</varname></primary>
36302 </indexterm>
36303 The expansion can refer to the existing value via <varname>$return_path</varname>. This is
36304 either the message&#x2019;s envelope sender, or an address set by the
36305 <option>errors_to</option> option on a router. If the expansion is forced to fail, no
36306 replacement occurs; if it fails for another reason, delivery is deferred. This
36307 option can be used to support VERP (Variable Envelope Return Paths) &ndash; see
36308 section <xref linkend="SECTverp"/>.
36309 </para>
36310 <para>
36311 <emphasis role="bold">Note</emphasis>: If a delivery error is detected locally, including the case when a
36312 remote server rejects a message at SMTP time, the bounce message is not sent to
36313 the value of this option. It is sent to the previously set errors address.
36314 This defaults to the incoming sender address, but can be changed by setting
36315 <option>errors_to</option> in a router.
36316 </para>
36317 <para>
36318 <indexterm role="option">
36319 <primary><option>return_path_add</option></primary>
36320 </indexterm>
36321 </para>
36322 <informaltable frame="all">
36323 <tgroup cols="4" colsep="0" rowsep="0">
36324 <colspec colwidth="8*" align="left"/>
36325 <colspec colwidth="6*" align="center"/>
36326 <colspec colwidth="6*" align="center"/>
36327 <colspec colwidth="6*" align="right"/>
36328 <tbody>
36329 <row>
36330 <entry><option>return_path_add</option></entry>
36331 <entry>Use: <emphasis>transports</emphasis></entry>
36332 <entry>Type: <emphasis>boolean</emphasis></entry>
36333 <entry>Default: <emphasis>false</emphasis></entry>
36334 </row>
36335 </tbody>
36336 </tgroup>
36337 </informaltable>
36338 <para>
36339 <indexterm role="concept">
36340 <primary><emphasis>Return-path:</emphasis> header line</primary>
36341 </indexterm>
36342 If this option is true, a <emphasis>Return-path:</emphasis> header is added to the message.
36343 Although the return path is normally available in the prefix line of BSD
36344 mailboxes, this is commonly not displayed by MUAs, and so the user does not
36345 have easy access to it.
36346 </para>
36347 <para>
36348 RFC 2821 states that the <emphasis>Return-path:</emphasis> header is added to a message <quote>when
36349 the delivery SMTP server makes the final delivery</quote>. This implies that this
36350 header should not be present in incoming messages. Exim has a configuration
36351 option, <option>return_path_remove</option>, which requests removal of this header from
36352 incoming messages, so that delivered messages can safely be resent to other
36353 recipients.
36354 </para>
36355 <para>
36356 <indexterm role="option">
36357 <primary><option>shadow_condition</option></primary>
36358 </indexterm>
36359 </para>
36360 <informaltable frame="all">
36361 <tgroup cols="4" colsep="0" rowsep="0">
36362 <colspec colwidth="8*" align="left"/>
36363 <colspec colwidth="6*" align="center"/>
36364 <colspec colwidth="6*" align="center"/>
36365 <colspec colwidth="6*" align="right"/>
36366 <tbody>
36367 <row>
36368 <entry><option>shadow_condition</option></entry>
36369 <entry>Use: <emphasis>transports</emphasis></entry>
36370 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36371 <entry>Default: <emphasis>unset</emphasis></entry>
36372 </row>
36373 </tbody>
36374 </tgroup>
36375 </informaltable>
36376 <para>
36377 See <option>shadow_transport</option> below.
36378 </para>
36379 <para>
36380 <indexterm role="option">
36381 <primary><option>shadow_transport</option></primary>
36382 </indexterm>
36383 </para>
36384 <informaltable frame="all">
36385 <tgroup cols="4" colsep="0" rowsep="0">
36386 <colspec colwidth="8*" align="left"/>
36387 <colspec colwidth="6*" align="center"/>
36388 <colspec colwidth="6*" align="center"/>
36389 <colspec colwidth="6*" align="right"/>
36390 <tbody>
36391 <row>
36392 <entry><option>shadow_transport</option></entry>
36393 <entry>Use: <emphasis>transports</emphasis></entry>
36394 <entry>Type: <emphasis>string</emphasis></entry>
36395 <entry>Default: <emphasis>unset</emphasis></entry>
36396 </row>
36397 </tbody>
36398 </tgroup>
36399 </informaltable>
36400 <para>
36401 <indexterm role="concept">
36402 <primary>shadow transport</primary>
36403 </indexterm>
36404 <indexterm role="concept">
36405 <primary>transport</primary>
36406 <secondary>shadow</secondary>
36407 </indexterm>
36408 A local transport may set the <option>shadow_transport</option> option to the name of
36409 another local transport. Shadow remote transports are not supported.
36410 </para>
36411 <para>
36412 Whenever a delivery to the main transport succeeds, and either
36413 <option>shadow_condition</option> is unset, or its expansion does not result in the empty
36414 string or one of the strings <quote>0</quote> or <quote>no</quote> or <quote>false</quote>, the message is also
36415 passed to the shadow transport, with the same delivery address or addresses. If
36416 expansion fails, no action is taken except that non-forced expansion failures
36417 cause a log line to be written.
36418 </para>
36419 <para>
36420 The result of the shadow transport is discarded and does not affect the
36421 subsequent processing of the message. Only a single level of shadowing is
36422 provided; the <option>shadow_transport</option> option is ignored on any transport when it
36423 is running as a shadow. Options concerned with output from pipes are also
36424 ignored. The log line for the successful delivery has an item added on the end,
36425 of the form
36426 </para>
36427 <literallayout class="monospaced">
36428 ST=&lt;shadow transport name&gt;
36429 </literallayout>
36430 <para>
36431 If the shadow transport did not succeed, the error message is put in
36432 parentheses afterwards. Shadow transports can be used for a number of different
36433 purposes, including keeping more detailed log information than Exim normally
36434 provides, and implementing automatic acknowledgment policies based on message
36435 headers that some sites insist on.
36436 </para>
36437 <para>
36438 <indexterm role="option">
36439 <primary><option>transport_filter</option></primary>
36440 </indexterm>
36441 </para>
36442 <informaltable frame="all">
36443 <tgroup cols="4" colsep="0" rowsep="0">
36444 <colspec colwidth="8*" align="left"/>
36445 <colspec colwidth="6*" align="center"/>
36446 <colspec colwidth="6*" align="center"/>
36447 <colspec colwidth="6*" align="right"/>
36448 <tbody>
36449 <row>
36450 <entry><option>transport_filter</option></entry>
36451 <entry>Use: <emphasis>transports</emphasis></entry>
36452 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36453 <entry>Default: <emphasis>unset</emphasis></entry>
36454 </row>
36455 </tbody>
36456 </tgroup>
36457 </informaltable>
36458 <para>
36459 <indexterm role="concept">
36460 <primary>transport</primary>
36461 <secondary>filter</secondary>
36462 </indexterm>
36463 <indexterm role="concept">
36464 <primary>filter</primary>
36465 <secondary>transport filter</secondary>
36466 </indexterm>
36467 This option sets up a filtering (in the Unix shell sense) process for messages
36468 at transport time. It should not be confused with mail filtering as set up by
36469 individual users or via a system filter.
36470 </para>
36471 <para>
36472 When the message is about to be written out, the command specified by
36473 <option>transport_filter</option> is started up in a separate, parallel process, and
36474 the entire message, including the header lines, is passed to it on its standard
36475 input (this in fact is done from a third process, to avoid deadlock). The
36476 command must be specified as an absolute path.
36477 </para>
36478 <para>
36479 The lines of the message that are written to the transport filter are
36480 terminated by newline (<quote>\n</quote>). The message is passed to the filter before any
36481 SMTP-specific processing, such as turning <quote>\n</quote> into <quote>\r\n</quote> and escaping
36482 lines beginning with a dot, and also before any processing implied by the
36483 settings of <option>check_string</option> and <option>escape_string</option> in the <command>appendfile</command> or
36484 <command>pipe</command> transports.
36485 </para>
36486 <para>
36487 The standard error for the filter process is set to the same destination as its
36488 standard output; this is read and written to the message&#x2019;s ultimate
36489 destination. The process that writes the message to the filter, the
36490 filter itself, and the original process that reads the result and delivers it
36491 are all run in parallel, like a shell pipeline.
36492 </para>
36493 <para>
36494 The filter can perform any transformations it likes, but of course should take
36495 care not to break RFC 2822 syntax. Exim does not check the result, except to
36496 test for a final newline when SMTP is in use. All messages transmitted over
36497 SMTP must end with a newline, so Exim supplies one if it is missing.
36498 </para>
36499 <para>
36500 <indexterm role="concept">
36501 <primary>content scanning</primary>
36502 <secondary>per user</secondary>
36503 </indexterm>
36504 A transport filter can be used to provide content-scanning on a per-user basis
36505 at delivery time if the only required effect of the scan is to modify the
36506 message. For example, a content scan could insert a new header line containing
36507 a spam score. This could be interpreted by a filter in the user&#x2019;s MUA. It is
36508 not possible to discard a message at this stage.
36509 </para>
36510 <para>
36511 <indexterm role="concept">
36512 <primary>SMTP</primary>
36513 <secondary>SIZE</secondary>
36514 </indexterm>
36515 A problem might arise if the filter increases the size of a message that is
36516 being sent down an SMTP connection. If the receiving SMTP server has indicated
36517 support for the SIZE parameter, Exim will have sent the size of the message
36518 at the start of the SMTP session. If what is actually sent is substantially
36519 more, the server might reject the message. This can be worked round by setting
36520 the <option>size_addition</option> option on the <command>smtp</command> transport, either to allow for
36521 additions to the message, or to disable the use of SIZE altogether.
36522 </para>
36523 <para>
36524 <indexterm role="variable">
36525 <primary><varname>$pipe_addresses</varname></primary>
36526 </indexterm>
36527 The value of the <option>transport_filter</option> option is the command string for starting
36528 the filter, which is run directly from Exim, not under a shell. The string is
36529 parsed by Exim in the same way as a command string for the <command>pipe</command> transport:
36530 Exim breaks it up into arguments and then expands each argument separately (see
36531 section <xref linkend="SECThowcommandrun"/>). Any kind of expansion failure causes delivery
36532 to be deferred. The special argument <varname>$pipe_addresses</varname> is replaced by a number
36533 of arguments, one for each address that applies to this delivery. (This isn&#x2019;t
36534 an ideal name for this feature here, but as it was already implemented for the
36535 <command>pipe</command> transport, it seemed sensible not to change it.)
36536 </para>
36537 <para>
36538 <indexterm role="variable">
36539 <primary><varname>$host</varname></primary>
36540 </indexterm>
36541 <indexterm role="variable">
36542 <primary><varname>$host_address</varname></primary>
36543 </indexterm>
36544 The expansion variables <varname>$host</varname> and <varname>$host_address</varname> are available when the
36545 transport is a remote one. They contain the name and IP address of the host to
36546 which the message is being sent. For example:
36547 </para>
36548 <literallayout class="monospaced">
36549 transport_filter = /some/directory/transport-filter.pl \
36550   $host $host_address $sender_address $pipe_addresses
36551 </literallayout>
36552 <para>
36553 Two problems arise if you want to use more complicated expansion items to
36554 generate transport filter commands, both of which due to the fact that the
36555 command is split up <emphasis>before</emphasis> expansion.
36556 </para>
36557 <itemizedlist>
36558 <listitem>
36559 <para>
36560 If an expansion item contains white space, you must quote it, so that it is all
36561 part of the same command item. If the entire option setting is one such
36562 expansion item, you have to take care what kind of quoting you use. For
36563 example:
36564 </para>
36565 <literallayout class="monospaced">
36566 transport_filter = '/bin/cmd${if eq{$host}{a.b.c}{1}{2}}'
36567 </literallayout>
36568 <para>
36569 This runs the command <command>/bin/cmd1</command> if the host name is <emphasis>a.b.c</emphasis>, and
36570 <command>/bin/cmd2</command> otherwise. If double quotes had been used, they would have been
36571 stripped by Exim when it read the option&#x2019;s value. When the value is used, if
36572 the single quotes were missing, the line would be split into two items,
36573 <literal>/bin/cmd${if</literal> and <literal>eq{$host}{a.b.c}{1}{2}</literal>, and an error would occur when
36574 Exim tried to expand the first one.
36575 </para>
36576 </listitem>
36577 <listitem>
36578 <para>
36579 Except for the special case of <varname>$pipe_addresses</varname> that is mentioned above, an
36580 expansion cannot generate multiple arguments, or a command name followed by
36581 arguments. Consider this example:
36582 </para>
36583 <literallayout class="monospaced">
36584 transport_filter = ${lookup{$host}lsearch{/a/file}\
36585                     {$value}{/bin/cat}}
36586 </literallayout>
36587 <para>
36588 The result of the lookup is interpreted as the name of the command, even
36589 if it contains white space. The simplest way round this is to use a shell:
36590 </para>
36591 <literallayout class="monospaced">
36592 transport_filter = /bin/sh -c ${lookup{$host}lsearch{/a/file}\
36593                                {$value}{/bin/cat}}
36594 </literallayout>
36595 </listitem>
36596 </itemizedlist>
36597 <para>
36598 The filter process is run under the same uid and gid as the normal delivery.
36599 For remote deliveries this is the Exim uid/gid by default. The command should
36600 normally yield a zero return code. Transport filters are not supposed to fail.
36601 A non-zero code is taken to mean that the transport filter encountered some
36602 serious problem. Delivery of the message is deferred; the message remains on
36603 the queue and is tried again later. It is not possible to cause a message to be
36604 bounced from a transport filter.
36605 </para>
36606 <para>
36607 If a transport filter is set on an autoreply transport, the original message is
36608 passed through the filter as it is being copied into the newly generated
36609 message, which happens if the <option>return_message</option> option is set.
36610 </para>
36611 <para>
36612 <indexterm role="option">
36613 <primary><option>transport_filter_timeout</option></primary>
36614 </indexterm>
36615 </para>
36616 <informaltable frame="all">
36617 <tgroup cols="4" colsep="0" rowsep="0">
36618 <colspec colwidth="8*" align="left"/>
36619 <colspec colwidth="6*" align="center"/>
36620 <colspec colwidth="6*" align="center"/>
36621 <colspec colwidth="6*" align="right"/>
36622 <tbody>
36623 <row>
36624 <entry><option>transport_filter_timeout</option></entry>
36625 <entry>Use: <emphasis>transports</emphasis></entry>
36626 <entry>Type: <emphasis>time</emphasis></entry>
36627 <entry>Default: <emphasis>5m</emphasis></entry>
36628 </row>
36629 </tbody>
36630 </tgroup>
36631 </informaltable>
36632 <para>
36633 <indexterm role="concept">
36634 <primary>transport</primary>
36635 <secondary>filter, timeout</secondary>
36636 </indexterm>
36637 When Exim is reading the output of a transport filter, it a applies a timeout
36638 that can be set by this option. Exceeding the timeout is normally treated as a
36639 temporary delivery failure. However, if a transport filter is used with a
36640 <command>pipe</command> transport, a timeout in the transport filter is treated in the same
36641 way as a timeout in the pipe command itself. By default, a timeout is a hard
36642 error, but if the <command>pipe</command> transport&#x2019;s <option>timeout_defer</option> option is set true, it
36643 becomes a temporary error.
36644 </para>
36645 <para>
36646 <indexterm role="option">
36647 <primary><option>user</option></primary>
36648 </indexterm>
36649 </para>
36650 <informaltable frame="all">
36651 <tgroup cols="4" colsep="0" rowsep="0">
36652 <colspec colwidth="8*" align="left"/>
36653 <colspec colwidth="6*" align="center"/>
36654 <colspec colwidth="6*" align="center"/>
36655 <colspec colwidth="6*" align="right"/>
36656 <tbody>
36657 <row>
36658 <entry><option>user</option></entry>
36659 <entry>Use: <emphasis>transports</emphasis></entry>
36660 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36661 <entry>Default: <emphasis>Exim user</emphasis></entry>
36662 </row>
36663 </tbody>
36664 </tgroup>
36665 </informaltable>
36666 <para>
36667 <indexterm role="concept">
36668 <primary>uid (user id)</primary>
36669 <secondary>local delivery</secondary>
36670 </indexterm>
36671 <indexterm role="concept">
36672 <primary>transport</primary>
36673 <secondary>user, specifying</secondary>
36674 </indexterm>
36675 This option specifies the user under whose uid the delivery process is to be
36676 run, overriding any uid that may have been set by the router. If the user is
36677 given as a name, the uid is looked up from the password data, and the
36678 associated group is taken as the value of the gid to be used if the <option>group</option>
36679 option is not set.
36680 </para>
36681 <para>
36682 For deliveries that use local transports, a user and group are normally
36683 specified explicitly or implicitly (for example, as a result of
36684 <option>check_local_user</option>) by the router or transport.
36685 </para>
36686 <para>
36687 <indexterm role="concept">
36688 <primary>hints database</primary>
36689 <secondary>access by remote transport</secondary>
36690 </indexterm>
36691 For remote transports, you should leave this option unset unless you really are
36692 sure you know what you are doing. When a remote transport is running, it needs
36693 to be able to access Exim&#x2019;s hints databases, because each host may have its own
36694 retry data.
36695 <indexterm role="concept" startref="IIDgenoptra1" class="endofrange"/>
36696 <indexterm role="concept" startref="IIDgenoptra2" class="endofrange"/>
36697 <indexterm role="concept" startref="IIDgenoptra3" class="endofrange"/>
36698 </para>
36699 </chapter>
36700
36701 <chapter id="CHAPbatching">
36702 <title>Address batching in local transports</title>
36703 <titleabbrev>Address batching</titleabbrev>
36704 <para>
36705 <indexterm role="concept">
36706 <primary>transport</primary>
36707 <secondary>local; address batching in</secondary>
36708 </indexterm>
36709 The only remote transport (<command>smtp</command>) is normally configured to handle more than
36710 one address at a time, so that when several addresses are routed to the same
36711 remote host, just one copy of the message is sent. Local transports, however,
36712 normally handle one address at a time. That is, a separate instance of the
36713 transport is run for each address that is routed to the transport. A separate
36714 copy of the message is delivered each time.
36715 </para>
36716 <para>
36717 <indexterm role="concept">
36718 <primary>batched local delivery</primary>
36719 </indexterm>
36720 <indexterm role="option">
36721 <primary><option>batch_max</option></primary>
36722 </indexterm>
36723 <indexterm role="option">
36724 <primary><option>batch_id</option></primary>
36725 </indexterm>
36726 In special cases, it may be desirable to handle several addresses at once in a
36727 local transport, for example:
36728 </para>
36729 <itemizedlist>
36730 <listitem>
36731 <para>
36732 In an <command>appendfile</command> transport, when storing messages in files for later
36733 delivery by some other means, a single copy of the message with multiple
36734 recipients saves space.
36735 </para>
36736 </listitem>
36737 <listitem>
36738 <para>
36739 In an <command>lmtp</command> transport, when delivering over <quote>local SMTP</quote> to some process,
36740 a single copy saves time, and is the normal way LMTP is expected to work.
36741 </para>
36742 </listitem>
36743 <listitem>
36744 <para>
36745 In a <command>pipe</command> transport, when passing the message
36746 to a scanner program or
36747 to some other delivery mechanism such as UUCP, multiple recipients may be
36748 acceptable.
36749 </para>
36750 </listitem>
36751 </itemizedlist>
36752 <para>
36753 These three local transports all have the same options for controlling multiple
36754 (<quote>batched</quote>) deliveries, namely <option>batch_max</option> and <option>batch_id</option>. To save
36755 repeating the information for each transport, these options are described here.
36756 </para>
36757 <para>
36758 The <option>batch_max</option> option specifies the maximum number of addresses that can be
36759 delivered together in a single run of the transport. Its default value is one
36760 (no batching). When more than one address is routed to a transport that has a
36761 <option>batch_max</option> value greater than one, the addresses are delivered in a batch
36762 (that is, in a single run of the transport with multiple recipients), subject
36763 to certain conditions:
36764 </para>
36765 <itemizedlist>
36766 <listitem>
36767 <para>
36768 <indexterm role="variable">
36769 <primary><varname>$local_part</varname></primary>
36770 </indexterm>
36771 If any of the transport&#x2019;s options contain a reference to <varname>$local_part</varname>, no
36772 batching is possible.
36773 </para>
36774 </listitem>
36775 <listitem>
36776 <para>
36777 <indexterm role="variable">
36778 <primary><varname>$domain</varname></primary>
36779 </indexterm>
36780 If any of the transport&#x2019;s options contain a reference to <varname>$domain</varname>, only
36781 addresses with the same domain are batched.
36782 </para>
36783 </listitem>
36784 <listitem>
36785 <para>
36786 <indexterm role="concept">
36787 <primary>customizing</primary>
36788 <secondary>batching condition</secondary>
36789 </indexterm>
36790 If <option>batch_id</option> is set, it is expanded for each address, and only those
36791 addresses with the same expanded value are batched. This allows you to specify
36792 customized batching conditions. Failure of the expansion for any reason,
36793 including forced failure, disables batching, but it does not stop the delivery
36794 from taking place.
36795 </para>
36796 </listitem>
36797 <listitem>
36798 <para>
36799 Batched addresses must also have the same errors address (where to send
36800 delivery errors), the same header additions and removals, the same user and
36801 group for the transport, and if a host list is present, the first host must
36802 be the same.
36803 </para>
36804 </listitem>
36805 </itemizedlist>
36806 <para>
36807 In the case of the <command>appendfile</command> and <command>pipe</command> transports, batching applies
36808 both when the file or pipe command is specified in the transport, and when it
36809 is specified by a <command>redirect</command> router, but all the batched addresses must of
36810 course be routed to the same file or pipe command. These two transports have an
36811 option called <option>use_bsmtp</option>, which causes them to deliver the message in
36812 <quote>batched SMTP</quote> format, with the envelope represented as SMTP commands. The
36813 <option>check_string</option> and <option>escape_string</option> options are forced to the values
36814 </para>
36815 <literallayout class="monospaced">
36816 check_string = "."
36817 escape_string = ".."
36818 </literallayout>
36819 <para>
36820 when batched SMTP is in use. A full description of the batch SMTP mechanism is
36821 given in section <xref linkend="SECTbatchSMTP"/>. The <command>lmtp</command> transport does not have a
36822 <option>use_bsmtp</option> option, because it always delivers using the SMTP protocol.
36823 </para>
36824 <para>
36825 <indexterm role="concept">
36826 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
36827 </indexterm>
36828 If the generic <option>envelope_to_add</option> option is set for a batching transport, the
36829 <emphasis>Envelope-to:</emphasis> header that is added to the message contains all the addresses
36830 that are being processed together. If you are using a batching <command>appendfile</command>
36831 transport without <option>use_bsmtp</option>, the only way to preserve the recipient
36832 addresses is to set the <option>envelope_to_add</option> option.
36833 </para>
36834 <para>
36835 <indexterm role="concept">
36836 <primary><command>pipe</command> transport</primary>
36837 <secondary>with multiple addresses</secondary>
36838 </indexterm>
36839 <indexterm role="variable">
36840 <primary><varname>$pipe_addresses</varname></primary>
36841 </indexterm>
36842 If you are using a <command>pipe</command> transport without BSMTP, and setting the
36843 transport&#x2019;s <option>command</option> option, you can include <varname>$pipe_addresses</varname> as part of
36844 the command. This is not a true variable; it is a bit of magic that causes each
36845 of the recipient addresses to be inserted into the command as a separate
36846 argument. This provides a way of accessing all the addresses that are being
36847 delivered in the batch. <emphasis role="bold">Note:</emphasis> This is not possible for pipe commands that
36848 are specified by a <command>redirect</command> router.
36849 </para>
36850 </chapter>
36851
36852 <chapter id="CHAPappendfile">
36853 <title>The appendfile transport</title>
36854 <para>
36855 <indexterm role="concept" id="IIDapptra1" class="startofrange">
36856 <primary><command>appendfile</command> transport</primary>
36857 </indexterm>
36858 <indexterm role="concept" id="IIDapptra2" class="startofrange">
36859 <primary>transports</primary>
36860 <secondary><command>appendfile</command></secondary>
36861 </indexterm>
36862 <indexterm role="concept">
36863 <primary>directory creation</primary>
36864 </indexterm>
36865 <indexterm role="concept">
36866 <primary>creating directories</primary>
36867 </indexterm>
36868 The <command>appendfile</command> transport delivers a message by appending it to an existing
36869 file, or by creating an entirely new file in a specified directory. Single
36870 files to which messages are appended can be in the traditional Unix mailbox
36871 format, or optionally in the MBX format supported by the Pine MUA and
36872 University of Washington IMAP daemon, <emphasis>inter alia</emphasis>. When each message is
36873 being delivered as a separate file, <quote>maildir</quote> format can optionally be used
36874 to give added protection against failures that happen part-way through the
36875 delivery. A third form of separate-file delivery known as <quote>mailstore</quote> is also
36876 supported. For all file formats, Exim attempts to create as many levels of
36877 directory as necessary, provided that <option>create_directory</option> is set.
36878 </para>
36879 <para>
36880 The code for the optional formats is not included in the Exim binary by
36881 default. It is necessary to set SUPPORT_MBX, SUPPORT_MAILDIR and/or
36882 SUPPORT_MAILSTORE in <filename>Local/Makefile</filename> to have the appropriate code
36883 included.
36884 </para>
36885 <para>
36886 <indexterm role="concept">
36887 <primary>quota</primary>
36888 <secondary>system</secondary>
36889 </indexterm>
36890 Exim recognizes system quota errors, and generates an appropriate message. Exim
36891 also supports its own quota control within the transport, for use when the
36892 system facility is unavailable or cannot be used for some reason.
36893 </para>
36894 <para>
36895 If there is an error while appending to a file (for example, quota exceeded or
36896 partition filled), Exim attempts to reset the file&#x2019;s length and last
36897 modification time back to what they were before. If there is an error while
36898 creating an entirely new file, the new file is removed.
36899 </para>
36900 <para>
36901 Before appending to a file, a number of security checks are made, and the
36902 file is locked. A detailed description is given below, after the list of
36903 private options.
36904 </para>
36905 <para>
36906 The <command>appendfile</command> transport is most commonly used for local deliveries to
36907 users&#x2019; mailboxes. However, it can also be used as a pseudo-remote transport for
36908 putting messages into files for remote delivery by some means other than Exim.
36909 <quote>Batch SMTP</quote> format is often used in this case (see the <option>use_bsmtp</option>
36910 option).
36911 </para>
36912 <section id="SECTfildiropt">
36913 <title>The file and directory options</title>
36914 <para>
36915 The <option>file</option> option specifies a single file, to which the message is appended;
36916 the <option>directory</option> option specifies a directory, in which a new file containing
36917 the message is created. Only one of these two options can be set, and for
36918 normal deliveries to mailboxes, one of them <emphasis>must</emphasis> be set.
36919 </para>
36920 <para>
36921 <indexterm role="variable">
36922 <primary><varname>$address_file</varname></primary>
36923 </indexterm>
36924 <indexterm role="variable">
36925 <primary><varname>$local_part</varname></primary>
36926 </indexterm>
36927 However, <command>appendfile</command> is also used for delivering messages to files or
36928 directories whose names (or parts of names) are obtained from alias,
36929 forwarding, or filtering operations (for example, a <option>save</option> command in a
36930 user&#x2019;s Exim filter). When such a transport is running, <varname>$local_part</varname> contains
36931 the local part that was aliased or forwarded, and <varname>$address_file</varname> contains the
36932 name (or partial name) of the file or directory generated by the redirection
36933 operation. There are two cases:
36934 </para>
36935 <itemizedlist>
36936 <listitem>
36937 <para>
36938 If neither <option>file</option> nor <option>directory</option> is set, the redirection operation
36939 must specify an absolute path (one that begins with <literal>/</literal>). This is the most
36940 common case when users with local accounts use filtering to sort mail into
36941 different folders. See for example, the <command>address_file</command> transport in the
36942 default configuration. If the path ends with a slash, it is assumed to be the
36943 name of a directory. A delivery to a directory can also be forced by setting
36944 <option>maildir_format</option> or <option>mailstore_format</option>.
36945 </para>
36946 </listitem>
36947 <listitem>
36948 <para>
36949 If <option>file</option> or <option>directory</option> is set for a delivery from a redirection, it is
36950 used to determine the file or directory name for the delivery. Normally, the
36951 contents of <varname>$address_file</varname> are used in some way in the string expansion.
36952 </para>
36953 </listitem>
36954 </itemizedlist>
36955 <para>
36956 <indexterm role="concept">
36957 <primary>Sieve filter</primary>
36958 <secondary>configuring <command>appendfile</command></secondary>
36959 </indexterm>
36960 <indexterm role="concept">
36961 <primary>Sieve filter</primary>
36962 <secondary>relative mailbox path handling</secondary>
36963 </indexterm>
36964 As an example of the second case, consider an environment where users do not
36965 have home directories. They may be permitted to use Exim filter commands of the
36966 form:
36967 </para>
36968 <literallayout class="monospaced">
36969 save folder23
36970 </literallayout>
36971 <para>
36972 or Sieve filter commands of the form:
36973 </para>
36974 <literallayout class="monospaced">
36975 require "fileinto";
36976 fileinto "folder23";
36977 </literallayout>
36978 <para>
36979 In this situation, the expansion of <option>file</option> or <option>directory</option> in the transport
36980 must transform the relative path into an appropriate absolute file name. In the
36981 case of Sieve filters, the name <emphasis>inbox</emphasis> must be handled. It is the name that
36982 is used as a result of a <quote>keep</quote> action in the filter. This example shows one
36983 way of handling this requirement:
36984 </para>
36985 <literallayout class="monospaced">
36986 file = ${if eq{$address_file}{inbox} \
36987             {/var/mail/$local_part} \
36988             {${if eq{${substr_0_1:$address_file}}{/} \
36989                   {$address_file} \
36990                   {$home/mail/$address_file} \
36991             }} \
36992        }
36993 </literallayout>
36994 <para>
36995 With this setting of <option>file</option>, <emphasis>inbox</emphasis> refers to the standard mailbox
36996 location, absolute paths are used without change, and other folders are in the
36997 <filename>mail</filename> directory within the home directory.
36998 </para>
36999 <para>
37000 <emphasis role="bold">Note 1</emphasis>: While processing an Exim filter, a relative path such as
37001 <filename>folder23</filename> is turned into an absolute path if a home directory is known to
37002 the router. In particular, this is the case if <option>check_local_user</option> is set. If
37003 you want to prevent this happening at routing time, you can set
37004 <option>router_home_directory</option> empty. This forces the router to pass the relative
37005 path to the transport.
37006 </para>
37007 <para>
37008 <emphasis role="bold">Note 2</emphasis>: An absolute path in <varname>$address_file</varname> is not treated specially;
37009 the <option>file</option> or <option>directory</option> option is still used if it is set.
37010 </para>
37011 </section>
37012 <section id="SECID134">
37013 <title>Private options for appendfile</title>
37014 <para>
37015 <indexterm role="concept">
37016 <primary>options</primary>
37017 <secondary><command>appendfile</command> transport</secondary>
37018 </indexterm>
37019 </para>
37020 <para>
37021 <indexterm role="option">
37022 <primary><option>allow_fifo</option></primary>
37023 </indexterm>
37024 </para>
37025 <informaltable frame="all">
37026 <tgroup cols="4" colsep="0" rowsep="0">
37027 <colspec colwidth="8*" align="left"/>
37028 <colspec colwidth="6*" align="center"/>
37029 <colspec colwidth="6*" align="center"/>
37030 <colspec colwidth="6*" align="right"/>
37031 <tbody>
37032 <row>
37033 <entry><option>allow_fifo</option></entry>
37034 <entry>Use: <emphasis>appendfile</emphasis></entry>
37035 <entry>Type: <emphasis>boolean</emphasis></entry>
37036 <entry>Default: <emphasis>false</emphasis></entry>
37037 </row>
37038 </tbody>
37039 </tgroup>
37040 </informaltable>
37041 <para>
37042 <indexterm role="concept">
37043 <primary>fifo (named pipe)</primary>
37044 </indexterm>
37045 <indexterm role="concept">
37046 <primary>named pipe (fifo)</primary>
37047 </indexterm>
37048 <indexterm role="concept">
37049 <primary>pipe</primary>
37050 <secondary>named (fifo)</secondary>
37051 </indexterm>
37052 Setting this option permits delivery to named pipes (FIFOs) as well as to
37053 regular files. If no process is reading the named pipe at delivery time, the
37054 delivery is deferred.
37055 </para>
37056 <para>
37057 <indexterm role="option">
37058 <primary><option>allow_symlink</option></primary>
37059 </indexterm>
37060 </para>
37061 <informaltable frame="all">
37062 <tgroup cols="4" colsep="0" rowsep="0">
37063 <colspec colwidth="8*" align="left"/>
37064 <colspec colwidth="6*" align="center"/>
37065 <colspec colwidth="6*" align="center"/>
37066 <colspec colwidth="6*" align="right"/>
37067 <tbody>
37068 <row>
37069 <entry><option>allow_symlink</option></entry>
37070 <entry>Use: <emphasis>appendfile</emphasis></entry>
37071 <entry>Type: <emphasis>boolean</emphasis></entry>
37072 <entry>Default: <emphasis>false</emphasis></entry>
37073 </row>
37074 </tbody>
37075 </tgroup>
37076 </informaltable>
37077 <para>
37078 <indexterm role="concept">
37079 <primary>symbolic link</primary>
37080 <secondary>to mailbox</secondary>
37081 </indexterm>
37082 <indexterm role="concept">
37083 <primary>mailbox</primary>
37084 <secondary>symbolic link</secondary>
37085 </indexterm>
37086 By default, <command>appendfile</command> will not deliver if the path name for the file is
37087 that of a symbolic link. Setting this option relaxes that constraint, but there
37088 are security issues involved in the use of symbolic links. Be sure you know
37089 what you are doing if you set this. Details of exactly what this option affects
37090 are included in the discussion which follows this list of options.
37091 </para>
37092 <para>
37093 <indexterm role="option">
37094 <primary><option>batch_id</option></primary>
37095 </indexterm>
37096 </para>
37097 <informaltable frame="all">
37098 <tgroup cols="4" colsep="0" rowsep="0">
37099 <colspec colwidth="8*" align="left"/>
37100 <colspec colwidth="6*" align="center"/>
37101 <colspec colwidth="6*" align="center"/>
37102 <colspec colwidth="6*" align="right"/>
37103 <tbody>
37104 <row>
37105 <entry><option>batch_id</option></entry>
37106 <entry>Use: <emphasis>appendfile</emphasis></entry>
37107 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37108 <entry>Default: <emphasis>unset</emphasis></entry>
37109 </row>
37110 </tbody>
37111 </tgroup>
37112 </informaltable>
37113 <para>
37114 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
37115 However, batching is automatically disabled for <command>appendfile</command> deliveries that
37116 happen as a result of forwarding or aliasing or other redirection directly to a
37117 file.
37118 </para>
37119 <para>
37120 <indexterm role="option">
37121 <primary><option>batch_max</option></primary>
37122 </indexterm>
37123 </para>
37124 <informaltable frame="all">
37125 <tgroup cols="4" colsep="0" rowsep="0">
37126 <colspec colwidth="8*" align="left"/>
37127 <colspec colwidth="6*" align="center"/>
37128 <colspec colwidth="6*" align="center"/>
37129 <colspec colwidth="6*" align="right"/>
37130 <tbody>
37131 <row>
37132 <entry><option>batch_max</option></entry>
37133 <entry>Use: <emphasis>appendfile</emphasis></entry>
37134 <entry>Type: <emphasis>integer</emphasis></entry>
37135 <entry>Default: <emphasis>1</emphasis></entry>
37136 </row>
37137 </tbody>
37138 </tgroup>
37139 </informaltable>
37140 <para>
37141 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
37142 </para>
37143 <para>
37144 <indexterm role="option">
37145 <primary><option>check_group</option></primary>
37146 </indexterm>
37147 </para>
37148 <informaltable frame="all">
37149 <tgroup cols="4" colsep="0" rowsep="0">
37150 <colspec colwidth="8*" align="left"/>
37151 <colspec colwidth="6*" align="center"/>
37152 <colspec colwidth="6*" align="center"/>
37153 <colspec colwidth="6*" align="right"/>
37154 <tbody>
37155 <row>
37156 <entry><option>check_group</option></entry>
37157 <entry>Use: <emphasis>appendfile</emphasis></entry>
37158 <entry>Type: <emphasis>boolean</emphasis></entry>
37159 <entry>Default: <emphasis>false</emphasis></entry>
37160 </row>
37161 </tbody>
37162 </tgroup>
37163 </informaltable>
37164 <para>
37165 When this option is set, the group owner of the file defined by the <option>file</option>
37166 option is checked to see that it is the same as the group under which the
37167 delivery process is running. The default setting is false because the default
37168 file mode is 0600, which means that the group is irrelevant.
37169 </para>
37170 <para>
37171 <indexterm role="option">
37172 <primary><option>check_owner</option></primary>
37173 </indexterm>
37174 </para>
37175 <informaltable frame="all">
37176 <tgroup cols="4" colsep="0" rowsep="0">
37177 <colspec colwidth="8*" align="left"/>
37178 <colspec colwidth="6*" align="center"/>
37179 <colspec colwidth="6*" align="center"/>
37180 <colspec colwidth="6*" align="right"/>
37181 <tbody>
37182 <row>
37183 <entry><option>check_owner</option></entry>
37184 <entry>Use: <emphasis>appendfile</emphasis></entry>
37185 <entry>Type: <emphasis>boolean</emphasis></entry>
37186 <entry>Default: <emphasis>true</emphasis></entry>
37187 </row>
37188 </tbody>
37189 </tgroup>
37190 </informaltable>
37191 <para>
37192 When this option is set, the owner of the file defined by the <option>file</option> option
37193 is checked to ensure that it is the same as the user under which the delivery
37194 process is running.
37195 </para>
37196 <para>
37197 <indexterm role="option">
37198 <primary><option>check_string</option></primary>
37199 </indexterm>
37200 </para>
37201 <informaltable frame="all">
37202 <tgroup cols="4" colsep="0" rowsep="0">
37203 <colspec colwidth="8*" align="left"/>
37204 <colspec colwidth="6*" align="center"/>
37205 <colspec colwidth="6*" align="center"/>
37206 <colspec colwidth="6*" align="right"/>
37207 <tbody>
37208 <row>
37209 <entry><option>check_string</option></entry>
37210 <entry>Use: <emphasis>appendfile</emphasis></entry>
37211 <entry>Type: <emphasis>string</emphasis></entry>
37212 <entry>Default: <emphasis>see below</emphasis></entry>
37213 </row>
37214 </tbody>
37215 </tgroup>
37216 </informaltable>
37217 <para>
37218 <indexterm role="concept">
37219 <primary><quote>From</quote> line</primary>
37220 </indexterm>
37221 As <command>appendfile</command> writes the message, the start of each line is tested for
37222 matching <option>check_string</option>, and if it does, the initial matching characters are
37223 replaced by the contents of <option>escape_string</option>. The value of <option>check_string</option> is
37224 a literal string, not a regular expression, and the case of any letters it
37225 contains is significant.
37226 </para>
37227 <para>
37228 If <option>use_bsmtp</option> is set the values of <option>check_string</option> and <option>escape_string</option>
37229 are forced to <quote>.</quote> and <quote>..</quote> respectively, and any settings in the
37230 configuration are ignored. Otherwise, they default to <quote>From&nbsp;</quote> and
37231 <quote>&gt;From&nbsp;</quote> when the <option>file</option> option is set, and unset when any of the
37232 <option>directory</option>, <option>maildir</option>, or <option>mailstore</option> options are set.
37233 </para>
37234 <para>
37235 The default settings, along with <option>message_prefix</option> and <option>message_suffix</option>, are
37236 suitable for traditional <quote>BSD</quote> mailboxes, where a line beginning with
37237 <quote>From&nbsp;</quote> indicates the start of a new message. All four options need changing
37238 if another format is used. For example, to deliver to mailboxes in MMDF format:
37239 <indexterm role="concept">
37240 <primary>MMDF format mailbox</primary>
37241 </indexterm>
37242 <indexterm role="concept">
37243 <primary>mailbox</primary>
37244 <secondary>MMDF format</secondary>
37245 </indexterm>
37246 </para>
37247 <literallayout class="monospaced">
37248 check_string = "\1\1\1\1\n"
37249 escape_string = "\1\1\1\1 \n"
37250 message_prefix = "\1\1\1\1\n"
37251 message_suffix = "\1\1\1\1\n"
37252 </literallayout>
37253 <para>
37254 <indexterm role="option">
37255 <primary><option>create_directory</option></primary>
37256 </indexterm>
37257 </para>
37258 <informaltable frame="all">
37259 <tgroup cols="4" colsep="0" rowsep="0">
37260 <colspec colwidth="8*" align="left"/>
37261 <colspec colwidth="6*" align="center"/>
37262 <colspec colwidth="6*" align="center"/>
37263 <colspec colwidth="6*" align="right"/>
37264 <tbody>
37265 <row>
37266 <entry><option>create_directory</option></entry>
37267 <entry>Use: <emphasis>appendfile</emphasis></entry>
37268 <entry>Type: <emphasis>boolean</emphasis></entry>
37269 <entry>Default: <emphasis>true</emphasis></entry>
37270 </row>
37271 </tbody>
37272 </tgroup>
37273 </informaltable>
37274 <para>
37275 <indexterm role="concept">
37276 <primary>directory creation</primary>
37277 </indexterm>
37278 When this option is true, Exim attempts to create any missing superior
37279 directories for the file that it is about to write. A created directory&#x2019;s mode
37280 is given by the <option>directory_mode</option> option.
37281 </para>
37282 <para>
37283 The group ownership of a newly created directory is highly dependent on the
37284 operating system (and possibly the file system) that is being used. For
37285 example, in Solaris, if the parent directory has the setgid bit set, its group
37286 is propagated to the child; if not, the currently set group is used. However,
37287 in FreeBSD, the parent&#x2019;s group is always used.
37288 </para>
37289 <para>
37290 <indexterm role="option">
37291 <primary><option>create_file</option></primary>
37292 </indexterm>
37293 </para>
37294 <informaltable frame="all">
37295 <tgroup cols="4" colsep="0" rowsep="0">
37296 <colspec colwidth="8*" align="left"/>
37297 <colspec colwidth="6*" align="center"/>
37298 <colspec colwidth="6*" align="center"/>
37299 <colspec colwidth="6*" align="right"/>
37300 <tbody>
37301 <row>
37302 <entry><option>create_file</option></entry>
37303 <entry>Use: <emphasis>appendfile</emphasis></entry>
37304 <entry>Type: <emphasis>string</emphasis></entry>
37305 <entry>Default: <emphasis>anywhere</emphasis></entry>
37306 </row>
37307 </tbody>
37308 </tgroup>
37309 </informaltable>
37310 <para>
37311 This option constrains the location of files and directories that are created
37312 by this transport. It applies to files defined by the <option>file</option> option and
37313 directories defined by the <option>directory</option> option. In the case of maildir
37314 delivery, it applies to the top level directory, not the maildir directories
37315 beneath.
37316 </para>
37317 <para>
37318 The option must be set to one of the words <quote>anywhere</quote>, <quote>inhome</quote>, or
37319 <quote>belowhome</quote>. In the second and third cases, a home directory must have been
37320 set for the transport. This option is not useful when an explicit file name is
37321 given for normal mailbox deliveries. It is intended for the case when file
37322 names are generated from users&#x2019; <filename>.forward</filename> files. These are usually handled
37323 by an <command>appendfile</command> transport called <option>address_file</option>. See also
37324 <option>file_must_exist</option>.
37325 </para>
37326 <para>
37327 <indexterm role="option">
37328 <primary><option>directory</option></primary>
37329 </indexterm>
37330 </para>
37331 <informaltable frame="all">
37332 <tgroup cols="4" colsep="0" rowsep="0">
37333 <colspec colwidth="8*" align="left"/>
37334 <colspec colwidth="6*" align="center"/>
37335 <colspec colwidth="6*" align="center"/>
37336 <colspec colwidth="6*" align="right"/>
37337 <tbody>
37338 <row>
37339 <entry><option>directory</option></entry>
37340 <entry>Use: <emphasis>appendfile</emphasis></entry>
37341 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37342 <entry>Default: <emphasis>unset</emphasis></entry>
37343 </row>
37344 </tbody>
37345 </tgroup>
37346 </informaltable>
37347 <para>
37348 This option is mutually exclusive with the <option>file</option> option, but one of <option>file</option>
37349 or <option>directory</option> must be set, unless the delivery is the direct result of a
37350 redirection (see section <xref linkend="SECTfildiropt"/>).
37351 </para>
37352 <para>
37353 When <option>directory</option> is set, the string is expanded, and the message is delivered
37354 into a new file or files in or below the given directory, instead of being
37355 appended to a single mailbox file. A number of different formats are provided
37356 (see <option>maildir_format</option> and <option>mailstore_format</option>), and see section
37357 <xref linkend="SECTopdir"/> for further details of this form of delivery.
37358 </para>
37359 <para>
37360 <indexterm role="option">
37361 <primary><option>directory_file</option></primary>
37362 </indexterm>
37363 </para>
37364 <informaltable frame="all">
37365 <tgroup cols="4" colsep="0" rowsep="0">
37366 <colspec colwidth="8*" align="left"/>
37367 <colspec colwidth="6*" align="center"/>
37368 <colspec colwidth="6*" align="center"/>
37369 <colspec colwidth="6*" align="right"/>
37370 <tbody>
37371 <row>
37372 <entry><option>directory_file</option></entry>
37373 <entry>Use: <emphasis>appendfile</emphasis></entry>
37374 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37375 <entry>Default: <emphasis>see below</emphasis></entry>
37376 </row>
37377 </tbody>
37378 </tgroup>
37379 </informaltable>
37380 <para>
37381 <indexterm role="concept">
37382 <primary>base62</primary>
37383 </indexterm>
37384 <indexterm role="variable">
37385 <primary><varname>$inode</varname></primary>
37386 </indexterm>
37387 When <option>directory</option> is set, but neither <option>maildir_format</option> nor
37388 <option>mailstore_format</option> is set, <command>appendfile</command> delivers each message into a file
37389 whose name is obtained by expanding this string. The default value is:
37390 </para>
37391 <literallayout class="monospaced">
37392 q${base62:$tod_epoch}-$inode
37393 </literallayout>
37394 <para>
37395 This generates a unique name from the current time, in base 62 form, and the
37396 inode of the file. The variable <varname>$inode</varname> is available only when expanding this
37397 option.
37398 </para>
37399 <para>
37400 <indexterm role="option">
37401 <primary><option>directory_mode</option></primary>
37402 </indexterm>
37403 </para>
37404 <informaltable frame="all">
37405 <tgroup cols="4" colsep="0" rowsep="0">
37406 <colspec colwidth="8*" align="left"/>
37407 <colspec colwidth="6*" align="center"/>
37408 <colspec colwidth="6*" align="center"/>
37409 <colspec colwidth="6*" align="right"/>
37410 <tbody>
37411 <row>
37412 <entry><option>directory_mode</option></entry>
37413 <entry>Use: <emphasis>appendfile</emphasis></entry>
37414 <entry>Type: <emphasis>octal integer</emphasis></entry>
37415 <entry>Default: <emphasis>0700</emphasis></entry>
37416 </row>
37417 </tbody>
37418 </tgroup>
37419 </informaltable>
37420 <para>
37421 If <command>appendfile</command> creates any directories as a result of the
37422 <option>create_directory</option> option, their mode is specified by this option.
37423 </para>
37424 <para>
37425 <indexterm role="option">
37426 <primary><option>escape_string</option></primary>
37427 </indexterm>
37428 </para>
37429 <informaltable frame="all">
37430 <tgroup cols="4" colsep="0" rowsep="0">
37431 <colspec colwidth="8*" align="left"/>
37432 <colspec colwidth="6*" align="center"/>
37433 <colspec colwidth="6*" align="center"/>
37434 <colspec colwidth="6*" align="right"/>
37435 <tbody>
37436 <row>
37437 <entry><option>escape_string</option></entry>
37438 <entry>Use: <emphasis>appendfile</emphasis></entry>
37439 <entry>Type: <emphasis>string</emphasis></entry>
37440 <entry>Default: <emphasis>see description</emphasis></entry>
37441 </row>
37442 </tbody>
37443 </tgroup>
37444 </informaltable>
37445 <para>
37446 See <option>check_string</option> above.
37447 </para>
37448 <para>
37449 <indexterm role="option">
37450 <primary><option>file</option></primary>
37451 </indexterm>
37452 </para>
37453 <informaltable frame="all">
37454 <tgroup cols="4" colsep="0" rowsep="0">
37455 <colspec colwidth="8*" align="left"/>
37456 <colspec colwidth="6*" align="center"/>
37457 <colspec colwidth="6*" align="center"/>
37458 <colspec colwidth="6*" align="right"/>
37459 <tbody>
37460 <row>
37461 <entry><option>file</option></entry>
37462 <entry>Use: <emphasis>appendfile</emphasis></entry>
37463 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37464 <entry>Default: <emphasis>unset</emphasis></entry>
37465 </row>
37466 </tbody>
37467 </tgroup>
37468 </informaltable>
37469 <para>
37470 This option is mutually exclusive with the <option>directory</option> option, but one of
37471 <option>file</option> or <option>directory</option> must be set, unless the delivery is the direct result
37472 of a redirection (see section <xref linkend="SECTfildiropt"/>). The <option>file</option> option
37473 specifies a single file, to which the message is appended. One or more of
37474 <option>use_fcntl_lock</option>, <option>use_flock_lock</option>, or <option>use_lockfile</option> must be set with
37475 <option>file</option>.
37476 </para>
37477 <para>
37478 <indexterm role="concept">
37479 <primary>NFS</primary>
37480 <secondary>lock file</secondary>
37481 </indexterm>
37482 <indexterm role="concept">
37483 <primary>locking files</primary>
37484 </indexterm>
37485 <indexterm role="concept">
37486 <primary>lock files</primary>
37487 </indexterm>
37488 If you are using more than one host to deliver over NFS into the same
37489 mailboxes, you should always use lock files.
37490 </para>
37491 <para>
37492 The string value is expanded for each delivery, and must yield an absolute
37493 path. The most common settings of this option are variations on one of these
37494 examples:
37495 </para>
37496 <literallayout class="monospaced">
37497 file = /var/spool/mail/$local_part
37498 file = /home/$local_part/inbox
37499 file = $home/inbox
37500 </literallayout>
37501 <para>
37502 <indexterm role="concept">
37503 <primary><quote>sticky</quote> bit</primary>
37504 </indexterm>
37505 In the first example, all deliveries are done into the same directory. If Exim
37506 is configured to use lock files (see <option>use_lockfile</option> below) it must be able to
37507 create a file in the directory, so the <quote>sticky</quote> bit must be turned on for
37508 deliveries to be possible, or alternatively the <option>group</option> option can be used to
37509 run the delivery under a group id which has write access to the directory.
37510 </para>
37511 <para>
37512 <indexterm role="option">
37513 <primary><option>file_format</option></primary>
37514 </indexterm>
37515 </para>
37516 <informaltable frame="all">
37517 <tgroup cols="4" colsep="0" rowsep="0">
37518 <colspec colwidth="8*" align="left"/>
37519 <colspec colwidth="6*" align="center"/>
37520 <colspec colwidth="6*" align="center"/>
37521 <colspec colwidth="6*" align="right"/>
37522 <tbody>
37523 <row>
37524 <entry><option>file_format</option></entry>
37525 <entry>Use: <emphasis>appendfile</emphasis></entry>
37526 <entry>Type: <emphasis>string</emphasis></entry>
37527 <entry>Default: <emphasis>unset</emphasis></entry>
37528 </row>
37529 </tbody>
37530 </tgroup>
37531 </informaltable>
37532 <para>
37533 <indexterm role="concept">
37534 <primary>file</primary>
37535 <secondary>mailbox; checking existing format</secondary>
37536 </indexterm>
37537 This option requests the transport to check the format of an existing file
37538 before adding to it. The check consists of matching a specific string at the
37539 start of the file. The value of the option consists of an even number of
37540 colon-separated strings. The first of each pair is the test string, and the
37541 second is the name of a transport. If the transport associated with a matched
37542 string is not the current transport, control is passed over to the other
37543 transport. For example, suppose the standard <command>local_delivery</command> transport has
37544 this added to it:
37545 </para>
37546 <literallayout class="monospaced">
37547 file_format = "From       : local_delivery :\
37548                \1\1\1\1\n : local_mmdf_delivery"
37549 </literallayout>
37550 <para>
37551 Mailboxes that begin with <quote>From</quote> are still handled by this transport, but if
37552 a mailbox begins with four binary ones followed by a newline, control is passed
37553 to a transport called <option>local_mmdf_delivery</option>, which presumably is configured
37554 to do the delivery in MMDF format. If a mailbox does not exist or is empty, it
37555 is assumed to match the current transport. If the start of a mailbox doesn&#x2019;t
37556 match any string, or if the transport named for a given string is not defined,
37557 delivery is deferred.
37558 </para>
37559 <para>
37560 <indexterm role="option">
37561 <primary><option>file_must_exist</option></primary>
37562 </indexterm>
37563 </para>
37564 <informaltable frame="all">
37565 <tgroup cols="4" colsep="0" rowsep="0">
37566 <colspec colwidth="8*" align="left"/>
37567 <colspec colwidth="6*" align="center"/>
37568 <colspec colwidth="6*" align="center"/>
37569 <colspec colwidth="6*" align="right"/>
37570 <tbody>
37571 <row>
37572 <entry><option>file_must_exist</option></entry>
37573 <entry>Use: <emphasis>appendfile</emphasis></entry>
37574 <entry>Type: <emphasis>boolean</emphasis></entry>
37575 <entry>Default: <emphasis>false</emphasis></entry>
37576 </row>
37577 </tbody>
37578 </tgroup>
37579 </informaltable>
37580 <para>
37581 If this option is true, the file specified by the <option>file</option> option must exist.
37582 A temporary error occurs if it does not, causing delivery to be deferred.
37583 If this option is false, the file is created if it does not exist.
37584 </para>
37585 <para>
37586 <indexterm role="option">
37587 <primary><option>lock_fcntl_timeout</option></primary>
37588 </indexterm>
37589 </para>
37590 <informaltable frame="all">
37591 <tgroup cols="4" colsep="0" rowsep="0">
37592 <colspec colwidth="8*" align="left"/>
37593 <colspec colwidth="6*" align="center"/>
37594 <colspec colwidth="6*" align="center"/>
37595 <colspec colwidth="6*" align="right"/>
37596 <tbody>
37597 <row>
37598 <entry><option>lock_fcntl_timeout</option></entry>
37599 <entry>Use: <emphasis>appendfile</emphasis></entry>
37600 <entry>Type: <emphasis>time</emphasis></entry>
37601 <entry>Default: <emphasis>0s</emphasis></entry>
37602 </row>
37603 </tbody>
37604 </tgroup>
37605 </informaltable>
37606 <para>
37607 <indexterm role="concept">
37608 <primary>timeout</primary>
37609 <secondary>mailbox locking</secondary>
37610 </indexterm>
37611 <indexterm role="concept">
37612 <primary>mailbox</primary>
37613 <secondary>locking, blocking and non-blocking</secondary>
37614 </indexterm>
37615 <indexterm role="concept">
37616 <primary>locking files</primary>
37617 </indexterm>
37618 By default, the <command>appendfile</command> transport uses non-blocking calls to <function>fcntl()</function>
37619 when locking an open mailbox file. If the call fails, the delivery process
37620 sleeps for <option>lock_interval</option> and tries again, up to <option>lock_retries</option> times.
37621 Non-blocking calls are used so that the file is not kept open during the wait
37622 for the lock; the reason for this is to make it as safe as possible for
37623 deliveries over NFS in the case when processes might be accessing an NFS
37624 mailbox without using a lock file. This should not be done, but
37625 misunderstandings and hence misconfigurations are not unknown.
37626 </para>
37627 <para>
37628 On a busy system, however, the performance of a non-blocking lock approach is
37629 not as good as using a blocking lock with a timeout. In this case, the waiting
37630 is done inside the system call, and Exim&#x2019;s delivery process acquires the lock
37631 and can proceed as soon as the previous lock holder releases it.
37632 </para>
37633 <para>
37634 If <option>lock_fcntl_timeout</option> is set to a non-zero time, blocking locks, with that
37635 timeout, are used. There may still be some retrying: the maximum number of
37636 retries is
37637 </para>
37638 <literallayout class="monospaced">
37639 (lock_retries * lock_interval) / lock_fcntl_timeout
37640 </literallayout>
37641 <para>
37642 rounded up to the next whole number. In other words, the total time during
37643 which <command>appendfile</command> is trying to get a lock is roughly the same, unless
37644 <option>lock_fcntl_timeout</option> is set very large.
37645 </para>
37646 <para>
37647 You should consider setting this option if you are getting a lot of delayed
37648 local deliveries because of errors of the form
37649 </para>
37650 <literallayout class="monospaced">
37651 failed to lock mailbox /some/file (fcntl)
37652 </literallayout>
37653 <para>
37654 <indexterm role="option">
37655 <primary><option>lock_flock_timeout</option></primary>
37656 </indexterm>
37657 </para>
37658 <informaltable frame="all">
37659 <tgroup cols="4" colsep="0" rowsep="0">
37660 <colspec colwidth="8*" align="left"/>
37661 <colspec colwidth="6*" align="center"/>
37662 <colspec colwidth="6*" align="center"/>
37663 <colspec colwidth="6*" align="right"/>
37664 <tbody>
37665 <row>
37666 <entry><option>lock_flock_timeout</option></entry>
37667 <entry>Use: <emphasis>appendfile</emphasis></entry>
37668 <entry>Type: <emphasis>time</emphasis></entry>
37669 <entry>Default: <emphasis>0s</emphasis></entry>
37670 </row>
37671 </tbody>
37672 </tgroup>
37673 </informaltable>
37674 <para>
37675 This timeout applies to file locking when using <function>flock()</function> (see
37676 <option>use_flock</option>); the timeout operates in a similar manner to
37677 <option>lock_fcntl_timeout</option>.
37678 </para>
37679 <para>
37680 <indexterm role="option">
37681 <primary><option>lock_interval</option></primary>
37682 </indexterm>
37683 </para>
37684 <informaltable frame="all">
37685 <tgroup cols="4" colsep="0" rowsep="0">
37686 <colspec colwidth="8*" align="left"/>
37687 <colspec colwidth="6*" align="center"/>
37688 <colspec colwidth="6*" align="center"/>
37689 <colspec colwidth="6*" align="right"/>
37690 <tbody>
37691 <row>
37692 <entry><option>lock_interval</option></entry>
37693 <entry>Use: <emphasis>appendfile</emphasis></entry>
37694 <entry>Type: <emphasis>time</emphasis></entry>
37695 <entry>Default: <emphasis>3s</emphasis></entry>
37696 </row>
37697 </tbody>
37698 </tgroup>
37699 </informaltable>
37700 <para>
37701 This specifies the time to wait between attempts to lock the file. See below
37702 for details of locking.
37703 </para>
37704 <para>
37705 <indexterm role="option">
37706 <primary><option>lock_retries</option></primary>
37707 </indexterm>
37708 </para>
37709 <informaltable frame="all">
37710 <tgroup cols="4" colsep="0" rowsep="0">
37711 <colspec colwidth="8*" align="left"/>
37712 <colspec colwidth="6*" align="center"/>
37713 <colspec colwidth="6*" align="center"/>
37714 <colspec colwidth="6*" align="right"/>
37715 <tbody>
37716 <row>
37717 <entry><option>lock_retries</option></entry>
37718 <entry>Use: <emphasis>appendfile</emphasis></entry>
37719 <entry>Type: <emphasis>integer</emphasis></entry>
37720 <entry>Default: <emphasis>10</emphasis></entry>
37721 </row>
37722 </tbody>
37723 </tgroup>
37724 </informaltable>
37725 <para>
37726 This specifies the maximum number of attempts to lock the file. A value of zero
37727 is treated as 1. See below for details of locking.
37728 </para>
37729 <para>
37730 <indexterm role="option">
37731 <primary><option>lockfile_mode</option></primary>
37732 </indexterm>
37733 </para>
37734 <informaltable frame="all">
37735 <tgroup cols="4" colsep="0" rowsep="0">
37736 <colspec colwidth="8*" align="left"/>
37737 <colspec colwidth="6*" align="center"/>
37738 <colspec colwidth="6*" align="center"/>
37739 <colspec colwidth="6*" align="right"/>
37740 <tbody>
37741 <row>
37742 <entry><option>lockfile_mode</option></entry>
37743 <entry>Use: <emphasis>appendfile</emphasis></entry>
37744 <entry>Type: <emphasis>octal integer</emphasis></entry>
37745 <entry>Default: <emphasis>0600</emphasis></entry>
37746 </row>
37747 </tbody>
37748 </tgroup>
37749 </informaltable>
37750 <para>
37751 This specifies the mode of the created lock file, when a lock file is being
37752 used (see <option>use_lockfile</option> and <option>use_mbx_lock</option>).
37753 </para>
37754 <para>
37755 <indexterm role="option">
37756 <primary><option>lockfile_timeout</option></primary>
37757 </indexterm>
37758 </para>
37759 <informaltable frame="all">
37760 <tgroup cols="4" colsep="0" rowsep="0">
37761 <colspec colwidth="8*" align="left"/>
37762 <colspec colwidth="6*" align="center"/>
37763 <colspec colwidth="6*" align="center"/>
37764 <colspec colwidth="6*" align="right"/>
37765 <tbody>
37766 <row>
37767 <entry><option>lockfile_timeout</option></entry>
37768 <entry>Use: <emphasis>appendfile</emphasis></entry>
37769 <entry>Type: <emphasis>time</emphasis></entry>
37770 <entry>Default: <emphasis>30m</emphasis></entry>
37771 </row>
37772 </tbody>
37773 </tgroup>
37774 </informaltable>
37775 <para>
37776 <indexterm role="concept">
37777 <primary>timeout</primary>
37778 <secondary>mailbox locking</secondary>
37779 </indexterm>
37780 When a lock file is being used (see <option>use_lockfile</option>), if a lock file already
37781 exists and is older than this value, it is assumed to have been left behind by
37782 accident, and Exim attempts to remove it.
37783 </para>
37784 <para>
37785 <indexterm role="option">
37786 <primary><option>mailbox_filecount</option></primary>
37787 </indexterm>
37788 </para>
37789 <informaltable frame="all">
37790 <tgroup cols="4" colsep="0" rowsep="0">
37791 <colspec colwidth="8*" align="left"/>
37792 <colspec colwidth="6*" align="center"/>
37793 <colspec colwidth="6*" align="center"/>
37794 <colspec colwidth="6*" align="right"/>
37795 <tbody>
37796 <row>
37797 <entry><option>mailbox_filecount</option></entry>
37798 <entry>Use: <emphasis>appendfile</emphasis></entry>
37799 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37800 <entry>Default: <emphasis>unset</emphasis></entry>
37801 </row>
37802 </tbody>
37803 </tgroup>
37804 </informaltable>
37805 <para>
37806 <indexterm role="concept">
37807 <primary>mailbox</primary>
37808 <secondary>specifying size of</secondary>
37809 </indexterm>
37810 <indexterm role="concept">
37811 <primary>size</primary>
37812 <secondary>of mailbox</secondary>
37813 </indexterm>
37814 If this option is set, it is expanded, and the result is taken as the current
37815 number of files in the mailbox. It must be a decimal number, optionally
37816 followed by K or M. This provides a way of obtaining this information from an
37817 external source that maintains the data.
37818 </para>
37819 <para>
37820 <indexterm role="option">
37821 <primary><option>mailbox_size</option></primary>
37822 </indexterm>
37823 </para>
37824 <informaltable frame="all">
37825 <tgroup cols="4" colsep="0" rowsep="0">
37826 <colspec colwidth="8*" align="left"/>
37827 <colspec colwidth="6*" align="center"/>
37828 <colspec colwidth="6*" align="center"/>
37829 <colspec colwidth="6*" align="right"/>
37830 <tbody>
37831 <row>
37832 <entry><option>mailbox_size</option></entry>
37833 <entry>Use: <emphasis>appendfile</emphasis></entry>
37834 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37835 <entry>Default: <emphasis>unset</emphasis></entry>
37836 </row>
37837 </tbody>
37838 </tgroup>
37839 </informaltable>
37840 <para>
37841 <indexterm role="concept">
37842 <primary>mailbox</primary>
37843 <secondary>specifying size of</secondary>
37844 </indexterm>
37845 <indexterm role="concept">
37846 <primary>size</primary>
37847 <secondary>of mailbox</secondary>
37848 </indexterm>
37849 If this option is set, it is expanded, and the result is taken as the current
37850 size the mailbox. It must be a decimal number, optionally followed by K or M.
37851 This provides a way of obtaining this information from an external source that
37852 maintains the data. This is likely to be helpful for maildir deliveries where
37853 it is computationally expensive to compute the size of a mailbox.
37854 </para>
37855 <para>
37856 <indexterm role="option">
37857 <primary><option>maildir_format</option></primary>
37858 </indexterm>
37859 </para>
37860 <informaltable frame="all">
37861 <tgroup cols="4" colsep="0" rowsep="0">
37862 <colspec colwidth="8*" align="left"/>
37863 <colspec colwidth="6*" align="center"/>
37864 <colspec colwidth="6*" align="center"/>
37865 <colspec colwidth="6*" align="right"/>
37866 <tbody>
37867 <row>
37868 <entry><option>maildir_format</option></entry>
37869 <entry>Use: <emphasis>appendfile</emphasis></entry>
37870 <entry>Type: <emphasis>boolean</emphasis></entry>
37871 <entry>Default: <emphasis>false</emphasis></entry>
37872 </row>
37873 </tbody>
37874 </tgroup>
37875 </informaltable>
37876 <para>
37877 <indexterm role="concept">
37878 <primary>maildir format</primary>
37879 <secondary>specifying</secondary>
37880 </indexterm>
37881 If this option is set with the <option>directory</option> option, the delivery is into a new
37882 file, in the <quote>maildir</quote> format that is used by other mail software. When the
37883 transport is activated directly from a <command>redirect</command> router (for example, the
37884 <command>address_file</command> transport in the default configuration), setting
37885 <option>maildir_format</option> causes the path received from the router to be treated as a
37886 directory, whether or not it ends with <literal>/</literal>. This option is available only if
37887 SUPPORT_MAILDIR is present in <filename>Local/Makefile</filename>. See section
37888 <xref linkend="SECTmaildirdelivery"/> below for further details.
37889 </para>
37890 <para>
37891 <indexterm role="option">
37892 <primary><option>maildir_quota_directory_regex</option></primary>
37893 </indexterm>
37894 </para>
37895 <informaltable frame="all">
37896 <tgroup cols="4" colsep="0" rowsep="0">
37897 <colspec colwidth="8*" align="left"/>
37898 <colspec colwidth="6*" align="center"/>
37899 <colspec colwidth="6*" align="center"/>
37900 <colspec colwidth="6*" align="right"/>
37901 <tbody>
37902 <row>
37903 <entry><option>maildir_quota_directory_regex</option></entry>
37904 <entry>Use: <emphasis>appendfile</emphasis></entry>
37905 <entry>Type: <emphasis>string</emphasis></entry>
37906 <entry>Default: <emphasis>See below</emphasis></entry>
37907 </row>
37908 </tbody>
37909 </tgroup>
37910 </informaltable>
37911 <para>
37912 <indexterm role="concept">
37913 <primary>maildir format</primary>
37914 <secondary>quota; directories included in</secondary>
37915 </indexterm>
37916 <indexterm role="concept">
37917 <primary>quota</primary>
37918 <secondary>maildir; directories included in</secondary>
37919 </indexterm>
37920 This option is relevant only when <option>maildir_use_size_file</option> is set. It defines
37921 a regular expression for specifying directories, relative to the quota
37922 directory (see <option>quota_directory</option>), that should be included in the quota
37923 calculation. The default value is:
37924 </para>
37925 <literallayout class="monospaced">
37926 maildir_quota_directory_regex = ^(?:cur|new|\..*)$
37927 </literallayout>
37928 <para>
37929 This includes the <filename>cur</filename> and <filename>new</filename> directories, and any maildir++ folders
37930 (directories whose names begin with a dot). If you want to exclude the
37931 <filename>Trash</filename>
37932 folder from the count (as some sites do), you need to change this setting to
37933 </para>
37934 <literallayout class="monospaced">
37935 maildir_quota_directory_regex = ^(?:cur|new|\.(?!Trash).*)$
37936 </literallayout>
37937 <para>
37938 This uses a negative lookahead in the regular expression to exclude the
37939 directory whose name is <filename>.Trash</filename>. When a directory is excluded from quota
37940 calculations, quota processing is bypassed for any messages that are delivered
37941 directly into that directory.
37942 </para>
37943 <para>
37944 <indexterm role="option">
37945 <primary><option>maildir_retries</option></primary>
37946 </indexterm>
37947 </para>
37948 <informaltable frame="all">
37949 <tgroup cols="4" colsep="0" rowsep="0">
37950 <colspec colwidth="8*" align="left"/>
37951 <colspec colwidth="6*" align="center"/>
37952 <colspec colwidth="6*" align="center"/>
37953 <colspec colwidth="6*" align="right"/>
37954 <tbody>
37955 <row>
37956 <entry><option>maildir_retries</option></entry>
37957 <entry>Use: <emphasis>appendfile</emphasis></entry>
37958 <entry>Type: <emphasis>integer</emphasis></entry>
37959 <entry>Default: <emphasis>10</emphasis></entry>
37960 </row>
37961 </tbody>
37962 </tgroup>
37963 </informaltable>
37964 <para>
37965 This option specifies the number of times to retry when writing a file in
37966 <quote>maildir</quote> format. See section <xref linkend="SECTmaildirdelivery"/> below.
37967 </para>
37968 <para>
37969 <indexterm role="option">
37970 <primary><option>maildir_tag</option></primary>
37971 </indexterm>
37972 </para>
37973 <informaltable frame="all">
37974 <tgroup cols="4" colsep="0" rowsep="0">
37975 <colspec colwidth="8*" align="left"/>
37976 <colspec colwidth="6*" align="center"/>
37977 <colspec colwidth="6*" align="center"/>
37978 <colspec colwidth="6*" align="right"/>
37979 <tbody>
37980 <row>
37981 <entry><option>maildir_tag</option></entry>
37982 <entry>Use: <emphasis>appendfile</emphasis></entry>
37983 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37984 <entry>Default: <emphasis>unset</emphasis></entry>
37985 </row>
37986 </tbody>
37987 </tgroup>
37988 </informaltable>
37989 <para>
37990 This option applies only to deliveries in maildir format, and is described in
37991 section <xref linkend="SECTmaildirdelivery"/> below.
37992 </para>
37993 <para>
37994 <indexterm role="option">
37995 <primary><option>maildir_use_size_file</option></primary>
37996 </indexterm>
37997 </para>
37998 <informaltable frame="all">
37999 <tgroup cols="4" colsep="0" rowsep="0">
38000 <colspec colwidth="8*" align="left"/>
38001 <colspec colwidth="6*" align="center"/>
38002 <colspec colwidth="6*" align="center"/>
38003 <colspec colwidth="6*" align="right"/>
38004 <tbody>
38005 <row>
38006 <entry><option>maildir_use_size_file</option></entry>
38007 <entry>Use: <emphasis>appendfile</emphasis></entry>
38008 <entry>Type: <emphasis>boolean</emphasis></entry>
38009 <entry>Default: <emphasis>false</emphasis></entry>
38010 </row>
38011 </tbody>
38012 </tgroup>
38013 </informaltable>
38014 <para>
38015 <indexterm role="concept">
38016 <primary>maildir format</primary>
38017 <secondary><filename>maildirsize</filename> file</secondary>
38018 </indexterm>
38019 Setting this option true enables support for <filename>maildirsize</filename> files. Exim
38020 creates a <filename>maildirsize</filename> file in a maildir if one does not exist, taking the
38021 quota from the <option>quota</option> option of the transport. If <option>quota</option> is unset, the
38022 value is zero. See <option>maildir_quota_directory_regex</option> above and section
38023 <xref linkend="SECTmaildirdelivery"/> below for further details.
38024 </para>
38025 <para>
38026 <indexterm role="option">
38027 <primary><option>maildirfolder_create_regex</option></primary>
38028 </indexterm>
38029 </para>
38030 <informaltable frame="all">
38031 <tgroup cols="4" colsep="0" rowsep="0">
38032 <colspec colwidth="8*" align="left"/>
38033 <colspec colwidth="6*" align="center"/>
38034 <colspec colwidth="6*" align="center"/>
38035 <colspec colwidth="6*" align="right"/>
38036 <tbody>
38037 <row>
38038 <entry><option>maildirfolder_create_regex</option></entry>
38039 <entry>Use: <emphasis>appendfile</emphasis></entry>
38040 <entry>Type: <emphasis>string</emphasis></entry>
38041 <entry>Default: <emphasis>unset</emphasis></entry>
38042 </row>
38043 </tbody>
38044 </tgroup>
38045 </informaltable>
38046 <para>
38047 <indexterm role="concept">
38048 <primary>maildir format</primary>
38049 <secondary><filename>maildirfolder</filename> file</secondary>
38050 </indexterm>
38051 <indexterm role="concept">
38052 <primary><filename>maildirfolder</filename>, creating</primary>
38053 </indexterm>
38054 The value of this option is a regular expression. If it is unset, it has no
38055 effect. Otherwise, before a maildir delivery takes place, the pattern is
38056 matched against the name of the maildir directory, that is, the directory
38057 containing the <filename>new</filename> and <filename>tmp</filename> subdirectories that will be used for the
38058 delivery. If there is a match, Exim checks for the existence of a file called
38059 <filename>maildirfolder</filename> in the directory, and creates it if it does not exist.
38060 See section <xref linkend="SECTmaildirdelivery"/> for more details.
38061 </para>
38062 <para>
38063 <indexterm role="option">
38064 <primary><option>mailstore_format</option></primary>
38065 </indexterm>
38066 </para>
38067 <informaltable frame="all">
38068 <tgroup cols="4" colsep="0" rowsep="0">
38069 <colspec colwidth="8*" align="left"/>
38070 <colspec colwidth="6*" align="center"/>
38071 <colspec colwidth="6*" align="center"/>
38072 <colspec colwidth="6*" align="right"/>
38073 <tbody>
38074 <row>
38075 <entry><option>mailstore_format</option></entry>
38076 <entry>Use: <emphasis>appendfile</emphasis></entry>
38077 <entry>Type: <emphasis>boolean</emphasis></entry>
38078 <entry>Default: <emphasis>false</emphasis></entry>
38079 </row>
38080 </tbody>
38081 </tgroup>
38082 </informaltable>
38083 <para>
38084 <indexterm role="concept">
38085 <primary>mailstore format</primary>
38086 <secondary>specifying</secondary>
38087 </indexterm>
38088 If this option is set with the <option>directory</option> option, the delivery is into two
38089 new files in  <quote>mailstore</quote> format. The option is available only if
38090 SUPPORT_MAILSTORE is present in <filename>Local/Makefile</filename>. See section <xref linkend="SECTopdir"/>
38091 below for further details.
38092 </para>
38093 <para>
38094 <indexterm role="option">
38095 <primary><option>mailstore_prefix</option></primary>
38096 </indexterm>
38097 </para>
38098 <informaltable frame="all">
38099 <tgroup cols="4" colsep="0" rowsep="0">
38100 <colspec colwidth="8*" align="left"/>
38101 <colspec colwidth="6*" align="center"/>
38102 <colspec colwidth="6*" align="center"/>
38103 <colspec colwidth="6*" align="right"/>
38104 <tbody>
38105 <row>
38106 <entry><option>mailstore_prefix</option></entry>
38107 <entry>Use: <emphasis>appendfile</emphasis></entry>
38108 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38109 <entry>Default: <emphasis>unset</emphasis></entry>
38110 </row>
38111 </tbody>
38112 </tgroup>
38113 </informaltable>
38114 <para>
38115 This option applies only to deliveries in mailstore format, and is described in
38116 section <xref linkend="SECTopdir"/> below.
38117 </para>
38118 <para>
38119 <indexterm role="option">
38120 <primary><option>mailstore_suffix</option></primary>
38121 </indexterm>
38122 </para>
38123 <informaltable frame="all">
38124 <tgroup cols="4" colsep="0" rowsep="0">
38125 <colspec colwidth="8*" align="left"/>
38126 <colspec colwidth="6*" align="center"/>
38127 <colspec colwidth="6*" align="center"/>
38128 <colspec colwidth="6*" align="right"/>
38129 <tbody>
38130 <row>
38131 <entry><option>mailstore_suffix</option></entry>
38132 <entry>Use: <emphasis>appendfile</emphasis></entry>
38133 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38134 <entry>Default: <emphasis>unset</emphasis></entry>
38135 </row>
38136 </tbody>
38137 </tgroup>
38138 </informaltable>
38139 <para>
38140 This option applies only to deliveries in mailstore format, and is described in
38141 section <xref linkend="SECTopdir"/> below.
38142 </para>
38143 <para>
38144 <indexterm role="option">
38145 <primary><option>mbx_format</option></primary>
38146 </indexterm>
38147 </para>
38148 <informaltable frame="all">
38149 <tgroup cols="4" colsep="0" rowsep="0">
38150 <colspec colwidth="8*" align="left"/>
38151 <colspec colwidth="6*" align="center"/>
38152 <colspec colwidth="6*" align="center"/>
38153 <colspec colwidth="6*" align="right"/>
38154 <tbody>
38155 <row>
38156 <entry><option>mbx_format</option></entry>
38157 <entry>Use: <emphasis>appendfile</emphasis></entry>
38158 <entry>Type: <emphasis>boolean</emphasis></entry>
38159 <entry>Default: <emphasis>false</emphasis></entry>
38160 </row>
38161 </tbody>
38162 </tgroup>
38163 </informaltable>
38164 <para>
38165 <indexterm role="concept">
38166 <primary>locking files</primary>
38167 </indexterm>
38168 <indexterm role="concept">
38169 <primary>file</primary>
38170 <secondary>locking</secondary>
38171 </indexterm>
38172 <indexterm role="concept">
38173 <primary>file</primary>
38174 <secondary>MBX format</secondary>
38175 </indexterm>
38176 <indexterm role="concept">
38177 <primary>MBX format, specifying</primary>
38178 </indexterm>
38179 This option is available only if Exim has been compiled with SUPPORT_MBX
38180 set in <filename>Local/Makefile</filename>. If <option>mbx_format</option> is set with the <option>file</option> option,
38181 the message is appended to the mailbox file in MBX format instead of
38182 traditional Unix format. This format is supported by Pine4 and its associated
38183 IMAP and POP daemons, by means of the <emphasis>c-client</emphasis> library that they all use.
38184 </para>
38185 <para>
38186 <emphasis role="bold">Note</emphasis>: The <option>message_prefix</option> and <option>message_suffix</option> options are not
38187 automatically changed by the use of <option>mbx_format</option>. They should normally be set
38188 empty when using MBX format, so this option almost always appears in this
38189 combination:
38190 </para>
38191 <literallayout class="monospaced">
38192 mbx_format = true
38193 message_prefix =
38194 message_suffix =
38195 </literallayout>
38196 <para>
38197 If none of the locking options are mentioned in the configuration,
38198 <option>use_mbx_lock</option> is assumed and the other locking options default to false. It
38199 is possible to specify the other kinds of locking with <option>mbx_format</option>, but
38200 <option>use_fcntl_lock</option> and <option>use_mbx_lock</option> are mutually exclusive. MBX locking
38201 interworks with <emphasis>c-client</emphasis>, providing for shared access to the mailbox. It
38202 should not be used if any program that does not use this form of locking is
38203 going to access the mailbox, nor should it be used if the mailbox file is NFS
38204 mounted, because it works only when the mailbox is accessed from a single host.
38205 </para>
38206 <para>
38207 If you set <option>use_fcntl_lock</option> with an MBX-format mailbox, you cannot use
38208 the standard version of <emphasis>c-client</emphasis>, because as long as it has a mailbox open
38209 (this means for the whole of a Pine or IMAP session), Exim will not be able to
38210 append messages to it.
38211 </para>
38212 <para>
38213 <indexterm role="option">
38214 <primary><option>message_prefix</option></primary>
38215 </indexterm>
38216 </para>
38217 <informaltable frame="all">
38218 <tgroup cols="4" colsep="0" rowsep="0">
38219 <colspec colwidth="8*" align="left"/>
38220 <colspec colwidth="6*" align="center"/>
38221 <colspec colwidth="6*" align="center"/>
38222 <colspec colwidth="6*" align="right"/>
38223 <tbody>
38224 <row>
38225 <entry><option>message_prefix</option></entry>
38226 <entry>Use: <emphasis>appendfile</emphasis></entry>
38227 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38228 <entry>Default: <emphasis>see below</emphasis></entry>
38229 </row>
38230 </tbody>
38231 </tgroup>
38232 </informaltable>
38233 <para>
38234 <indexterm role="concept">
38235 <primary><quote>From</quote> line</primary>
38236 </indexterm>
38237 The string specified here is expanded and output at the start of every message.
38238 The default is unset unless <option>file</option> is specified and <option>use_bsmtp</option> is not set,
38239 in which case it is:
38240 </para>
38241 <literallayout class="monospaced">
38242 message_prefix = "From ${if def:return_path{$return_path}\
38243   {MAILER-DAEMON}} $tod_bsdinbox\n"
38244 </literallayout>
38245 <para>
38246 <emphasis role="bold">Note:</emphasis> If you set <option>use_crlf</option> true, you must change any occurrences of
38247 <literal>\n</literal> to <literal>\r\n</literal> in <option>message_prefix</option>.
38248 </para>
38249 <para>
38250 <indexterm role="option">
38251 <primary><option>message_suffix</option></primary>
38252 </indexterm>
38253 </para>
38254 <informaltable frame="all">
38255 <tgroup cols="4" colsep="0" rowsep="0">
38256 <colspec colwidth="8*" align="left"/>
38257 <colspec colwidth="6*" align="center"/>
38258 <colspec colwidth="6*" align="center"/>
38259 <colspec colwidth="6*" align="right"/>
38260 <tbody>
38261 <row>
38262 <entry><option>message_suffix</option></entry>
38263 <entry>Use: <emphasis>appendfile</emphasis></entry>
38264 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38265 <entry>Default: <emphasis>see below</emphasis></entry>
38266 </row>
38267 </tbody>
38268 </tgroup>
38269 </informaltable>
38270 <para>
38271 The string specified here is expanded and output at the end of every message.
38272 The default is unset unless <option>file</option> is specified and <option>use_bsmtp</option> is not set,
38273 in which case it is a single newline character. The suffix can be suppressed by
38274 setting
38275 </para>
38276 <literallayout class="monospaced">
38277 message_suffix =
38278 </literallayout>
38279 <para>
38280 <emphasis role="bold">Note:</emphasis> If you set <option>use_crlf</option> true, you must change any occurrences of
38281 <literal>\n</literal> to <literal>\r\n</literal> in <option>message_suffix</option>.
38282 </para>
38283 <para>
38284 <indexterm role="option">
38285 <primary><option>mode</option></primary>
38286 </indexterm>
38287 </para>
38288 <informaltable frame="all">
38289 <tgroup cols="4" colsep="0" rowsep="0">
38290 <colspec colwidth="8*" align="left"/>
38291 <colspec colwidth="6*" align="center"/>
38292 <colspec colwidth="6*" align="center"/>
38293 <colspec colwidth="6*" align="right"/>
38294 <tbody>
38295 <row>
38296 <entry><option>mode</option></entry>
38297 <entry>Use: <emphasis>appendfile</emphasis></entry>
38298 <entry>Type: <emphasis>octal integer</emphasis></entry>
38299 <entry>Default: <emphasis>0600</emphasis></entry>
38300 </row>
38301 </tbody>
38302 </tgroup>
38303 </informaltable>
38304 <para>
38305 If the output file is created, it is given this mode. If it already exists and
38306 has wider permissions, they are reduced to this mode. If it has narrower
38307 permissions, an error occurs unless <option>mode_fail_narrower</option> is false. However,
38308 if the delivery is the result of a <option>save</option> command in a filter file specifying
38309 a particular mode, the mode of the output file is always forced to take that
38310 value, and this option is ignored.
38311 </para>
38312 <para>
38313 <indexterm role="option">
38314 <primary><option>mode_fail_narrower</option></primary>
38315 </indexterm>
38316 </para>
38317 <informaltable frame="all">
38318 <tgroup cols="4" colsep="0" rowsep="0">
38319 <colspec colwidth="8*" align="left"/>
38320 <colspec colwidth="6*" align="center"/>
38321 <colspec colwidth="6*" align="center"/>
38322 <colspec colwidth="6*" align="right"/>
38323 <tbody>
38324 <row>
38325 <entry><option>mode_fail_narrower</option></entry>
38326 <entry>Use: <emphasis>appendfile</emphasis></entry>
38327 <entry>Type: <emphasis>boolean</emphasis></entry>
38328 <entry>Default: <emphasis>true</emphasis></entry>
38329 </row>
38330 </tbody>
38331 </tgroup>
38332 </informaltable>
38333 <para>
38334 This option applies in the case when an existing mailbox file has a narrower
38335 mode than that specified by the <option>mode</option> option. If <option>mode_fail_narrower</option> is
38336 true, the delivery is deferred (<quote>mailbox has the wrong mode</quote>); otherwise Exim
38337 continues with the delivery attempt, using the existing mode of the file.
38338 </para>
38339 <para>
38340 <indexterm role="option">
38341 <primary><option>notify_comsat</option></primary>
38342 </indexterm>
38343 </para>
38344 <informaltable frame="all">
38345 <tgroup cols="4" colsep="0" rowsep="0">
38346 <colspec colwidth="8*" align="left"/>
38347 <colspec colwidth="6*" align="center"/>
38348 <colspec colwidth="6*" align="center"/>
38349 <colspec colwidth="6*" align="right"/>
38350 <tbody>
38351 <row>
38352 <entry><option>notify_comsat</option></entry>
38353 <entry>Use: <emphasis>appendfile</emphasis></entry>
38354 <entry>Type: <emphasis>boolean</emphasis></entry>
38355 <entry>Default: <emphasis>false</emphasis></entry>
38356 </row>
38357 </tbody>
38358 </tgroup>
38359 </informaltable>
38360 <para>
38361 If this option is true, the <emphasis>comsat</emphasis> daemon is notified after every
38362 successful delivery to a user mailbox. This is the daemon that notifies logged
38363 on users about incoming mail.
38364 </para>
38365 <para>
38366 <indexterm role="option">
38367 <primary><option>quota</option></primary>
38368 </indexterm>
38369 </para>
38370 <informaltable frame="all">
38371 <tgroup cols="4" colsep="0" rowsep="0">
38372 <colspec colwidth="8*" align="left"/>
38373 <colspec colwidth="6*" align="center"/>
38374 <colspec colwidth="6*" align="center"/>
38375 <colspec colwidth="6*" align="right"/>
38376 <tbody>
38377 <row>
38378 <entry><option>quota</option></entry>
38379 <entry>Use: <emphasis>appendfile</emphasis></entry>
38380 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38381 <entry>Default: <emphasis>unset</emphasis></entry>
38382 </row>
38383 </tbody>
38384 </tgroup>
38385 </informaltable>
38386 <para>
38387 <indexterm role="concept">
38388 <primary>quota</primary>
38389 <secondary>imposed by Exim</secondary>
38390 </indexterm>
38391 This option imposes a limit on the size of the file to which Exim is appending,
38392 or to the total space used in the directory tree when the <option>directory</option> option
38393 is set. In the latter case, computation of the space used is expensive, because
38394 all the files in the directory (and any sub-directories) have to be
38395 individually inspected and their sizes summed. (See <option>quota_size_regex</option> and
38396 <option>maildir_use_size_file</option> for ways to avoid this in environments where users
38397 have no shell access to their mailboxes).
38398 </para>
38399 <para>
38400 As there is no interlock against two simultaneous deliveries into a
38401 multi-file mailbox, it is possible for the quota to be overrun in this case.
38402 For single-file mailboxes, of course, an interlock is a necessity.
38403 </para>
38404 <para>
38405 A file&#x2019;s size is taken as its <emphasis>used</emphasis> value. Because of blocking effects, this
38406 may be a lot less than the actual amount of disk space allocated to the file.
38407 If the sizes of a number of files are being added up, the rounding effect can
38408 become quite noticeable, especially on systems that have large block sizes.
38409 Nevertheless, it seems best to stick to the <emphasis>used</emphasis> figure, because this is
38410 the obvious value which users understand most easily.
38411 </para>
38412 <para>
38413 The value of the option is expanded, and must then be a numerical value
38414 (decimal point allowed), optionally followed by one of the letters K, M, or G,
38415 for kilobytes, megabytes, or gigabytes. If Exim is running on a system with
38416 large file support (Linux and FreeBSD have this), mailboxes larger than 2G can
38417 be handled.
38418 </para>
38419 <para>
38420 <emphasis role="bold">Note</emphasis>: A value of zero is interpreted as <quote>no quota</quote>.
38421 </para>
38422 <para>
38423 The expansion happens while Exim is running as root, before it changes uid for
38424 the delivery. This means that files that are inaccessible to the end user can
38425 be used to hold quota values that are looked up in the expansion. When delivery
38426 fails because this quota is exceeded, the handling of the error is as for
38427 system quota failures.
38428 </para>
38429 <para>
38430 By default, Exim&#x2019;s quota checking mimics system quotas, and restricts the
38431 mailbox to the specified maximum size, though the value is not accurate to the
38432 last byte, owing to separator lines and additional headers that may get added
38433 during message delivery. When a mailbox is nearly full, large messages may get
38434 refused even though small ones are accepted, because the size of the current
38435 message is added to the quota when the check is made. This behaviour can be
38436 changed by setting <option>quota_is_inclusive</option> false. When this is done, the check
38437 for exceeding the quota does not include the current message. Thus, deliveries
38438 continue until the quota has been exceeded; thereafter, no further messages are
38439 delivered. See also <option>quota_warn_threshold</option>.
38440 </para>
38441 <para>
38442 <indexterm role="option">
38443 <primary><option>quota_directory</option></primary>
38444 </indexterm>
38445 </para>
38446 <informaltable frame="all">
38447 <tgroup cols="4" colsep="0" rowsep="0">
38448 <colspec colwidth="8*" align="left"/>
38449 <colspec colwidth="6*" align="center"/>
38450 <colspec colwidth="6*" align="center"/>
38451 <colspec colwidth="6*" align="right"/>
38452 <tbody>
38453 <row>
38454 <entry><option>quota_directory</option></entry>
38455 <entry>Use: <emphasis>appendfile</emphasis></entry>
38456 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38457 <entry>Default: <emphasis>unset</emphasis></entry>
38458 </row>
38459 </tbody>
38460 </tgroup>
38461 </informaltable>
38462 <para>
38463 This option defines the directory to check for quota purposes when delivering
38464 into individual files. The default is the delivery directory, or, if a file
38465 called <filename>maildirfolder</filename> exists in a maildir directory, the parent of the
38466 delivery directory.
38467 </para>
38468 <para>
38469 <indexterm role="option">
38470 <primary><option>quota_filecount</option></primary>
38471 </indexterm>
38472 </para>
38473 <informaltable frame="all">
38474 <tgroup cols="4" colsep="0" rowsep="0">
38475 <colspec colwidth="8*" align="left"/>
38476 <colspec colwidth="6*" align="center"/>
38477 <colspec colwidth="6*" align="center"/>
38478 <colspec colwidth="6*" align="right"/>
38479 <tbody>
38480 <row>
38481 <entry><option>quota_filecount</option></entry>
38482 <entry>Use: <emphasis>appendfile</emphasis></entry>
38483 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38484 <entry>Default: <emphasis>0</emphasis></entry>
38485 </row>
38486 </tbody>
38487 </tgroup>
38488 </informaltable>
38489 <para>
38490 This option applies when the <option>directory</option> option is set. It limits the total
38491 number of files in the directory (compare the inode limit in system quotas). It
38492 can only be used if <option>quota</option> is also set. The value is expanded; an expansion
38493 failure causes delivery to be deferred. A value of zero is interpreted as
38494 <quote>no quota</quote>.
38495 </para>
38496 <para>
38497 <indexterm role="option">
38498 <primary><option>quota_is_inclusive</option></primary>
38499 </indexterm>
38500 </para>
38501 <informaltable frame="all">
38502 <tgroup cols="4" colsep="0" rowsep="0">
38503 <colspec colwidth="8*" align="left"/>
38504 <colspec colwidth="6*" align="center"/>
38505 <colspec colwidth="6*" align="center"/>
38506 <colspec colwidth="6*" align="right"/>
38507 <tbody>
38508 <row>
38509 <entry><option>quota_is_inclusive</option></entry>
38510 <entry>Use: <emphasis>appendfile</emphasis></entry>
38511 <entry>Type: <emphasis>boolean</emphasis></entry>
38512 <entry>Default: <emphasis>true</emphasis></entry>
38513 </row>
38514 </tbody>
38515 </tgroup>
38516 </informaltable>
38517 <para>
38518 See <option>quota</option> above.
38519 </para>
38520 <para>
38521 <indexterm role="option">
38522 <primary><option>quota_size_regex</option></primary>
38523 </indexterm>
38524 </para>
38525 <informaltable frame="all">
38526 <tgroup cols="4" colsep="0" rowsep="0">
38527 <colspec colwidth="8*" align="left"/>
38528 <colspec colwidth="6*" align="center"/>
38529 <colspec colwidth="6*" align="center"/>
38530 <colspec colwidth="6*" align="right"/>
38531 <tbody>
38532 <row>
38533 <entry><option>quota_size_regex</option></entry>
38534 <entry>Use: <emphasis>appendfile</emphasis></entry>
38535 <entry>Type: <emphasis>string</emphasis></entry>
38536 <entry>Default: <emphasis>unset</emphasis></entry>
38537 </row>
38538 </tbody>
38539 </tgroup>
38540 </informaltable>
38541 <para>
38542 This option applies when one of the delivery modes that writes a separate file
38543 for each message is being used. When Exim wants to find the size of one of
38544 these files in order to test the quota, it first checks <option>quota_size_regex</option>.
38545 If this is set to a regular expression that matches the file name, and it
38546 captures one string, that string is interpreted as a representation of the
38547 file&#x2019;s size. The value of <option>quota_size_regex</option> is not expanded.
38548 </para>
38549 <para>
38550 This feature is useful only when users have no shell access to their mailboxes
38551 &ndash; otherwise they could defeat the quota simply by renaming the files. This
38552 facility can be used with maildir deliveries, by setting <option>maildir_tag</option> to add
38553 the file length to the file name. For example:
38554 </para>
38555 <literallayout class="monospaced">
38556 maildir_tag = ,S=$message_size
38557 quota_size_regex = ,S=(\d+)
38558 </literallayout>
38559 <para>
38560 An alternative to <varname>$message_size</varname> is <varname>$message_linecount</varname>, which contains the
38561 number of lines in the message.
38562 </para>
38563 <para>
38564 The regular expression should not assume that the length is at the end of the
38565 file name (even though <option>maildir_tag</option> puts it there) because maildir MUAs
38566 sometimes add other information onto the ends of message file names.
38567 </para>
38568 <para>
38569 <indexterm role="option">
38570 <primary><option>quota_warn_message</option></primary>
38571 </indexterm>
38572 </para>
38573 <informaltable frame="all">
38574 <tgroup cols="4" colsep="0" rowsep="0">
38575 <colspec colwidth="8*" align="left"/>
38576 <colspec colwidth="6*" align="center"/>
38577 <colspec colwidth="6*" align="center"/>
38578 <colspec colwidth="6*" align="right"/>
38579 <tbody>
38580 <row>
38581 <entry><option>quota_warn_message</option></entry>
38582 <entry>Use: <emphasis>appendfile</emphasis></entry>
38583 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38584 <entry>Default: <emphasis>see below</emphasis></entry>
38585 </row>
38586 </tbody>
38587 </tgroup>
38588 </informaltable>
38589 <para>
38590 See below for the use of this option. If it is not set when
38591 <option>quota_warn_threshold</option> is set, it defaults to
38592 </para>
38593 <literallayout class="monospaced">
38594 quota_warn_message = "\
38595   To: $local_part@$domain\n\
38596   Subject: Your mailbox\n\n\
38597   This message is automatically created \
38598   by mail delivery software.\n\n\
38599   The size of your mailbox has exceeded \
38600   a warning threshold that is\n\
38601   set by the system administrator.\n"
38602 </literallayout>
38603 <para>
38604 <indexterm role="option">
38605 <primary><option>quota_warn_threshold</option></primary>
38606 </indexterm>
38607 </para>
38608 <informaltable frame="all">
38609 <tgroup cols="4" colsep="0" rowsep="0">
38610 <colspec colwidth="8*" align="left"/>
38611 <colspec colwidth="6*" align="center"/>
38612 <colspec colwidth="6*" align="center"/>
38613 <colspec colwidth="6*" align="right"/>
38614 <tbody>
38615 <row>
38616 <entry><option>quota_warn_threshold</option></entry>
38617 <entry>Use: <emphasis>appendfile</emphasis></entry>
38618 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38619 <entry>Default: <emphasis>0</emphasis></entry>
38620 </row>
38621 </tbody>
38622 </tgroup>
38623 </informaltable>
38624 <para>
38625 <indexterm role="concept">
38626 <primary>quota</primary>
38627 <secondary>warning threshold</secondary>
38628 </indexterm>
38629 <indexterm role="concept">
38630 <primary>mailbox</primary>
38631 <secondary>size warning</secondary>
38632 </indexterm>
38633 <indexterm role="concept">
38634 <primary>size</primary>
38635 <secondary>of mailbox</secondary>
38636 </indexterm>
38637 This option is expanded in the same way as <option>quota</option> (see above). If the
38638 resulting value is greater than zero, and delivery of the message causes the
38639 size of the file or total space in the directory tree to cross the given
38640 threshold, a warning message is sent. If <option>quota</option> is also set, the threshold
38641 may be specified as a percentage of it by following the value with a percent
38642 sign. For example:
38643 </para>
38644 <literallayout class="monospaced">
38645 quota = 10M
38646 quota_warn_threshold = 75%
38647 </literallayout>
38648 <para>
38649 If <option>quota</option> is not set, a setting of <option>quota_warn_threshold</option> that ends with a
38650 percent sign is ignored.
38651 </para>
38652 <para>
38653 The warning message itself is specified by the <option>quota_warn_message</option> option,
38654 and it must start with a <emphasis>To:</emphasis> header line containing the recipient(s) of the
38655 warning message. These do not necessarily have to include the recipient(s) of
38656 the original message. A <emphasis>Subject:</emphasis> line should also normally be supplied. You
38657 can include any other header lines that you want. If you do not include a
38658 <emphasis>From:</emphasis> line, the default is:
38659 </para>
38660 <literallayout class="monospaced">
38661 From: Mail Delivery System &lt;mailer-daemon@$qualify_domain_sender&gt;
38662 </literallayout>
38663 <para>
38664 <indexterm role="option">
38665 <primary><option>errors_reply_to</option></primary>
38666 </indexterm>
38667 If you supply a <emphasis>Reply-To:</emphasis> line, it overrides the global <option>errors_reply_to</option>
38668 option.
38669 </para>
38670 <para>
38671 The <option>quota</option> option does not have to be set in order to use this option; they
38672 are independent of one another except when the threshold is specified as a
38673 percentage.
38674 </para>
38675 <para>
38676 <indexterm role="option">
38677 <primary><option>use_bsmtp</option></primary>
38678 </indexterm>
38679 </para>
38680 <informaltable frame="all">
38681 <tgroup cols="4" colsep="0" rowsep="0">
38682 <colspec colwidth="8*" align="left"/>
38683 <colspec colwidth="6*" align="center"/>
38684 <colspec colwidth="6*" align="center"/>
38685 <colspec colwidth="6*" align="right"/>
38686 <tbody>
38687 <row>
38688 <entry><option>use_bsmtp</option></entry>
38689 <entry>Use: <emphasis>appendfile</emphasis></entry>
38690 <entry>Type: <emphasis>boolean</emphasis></entry>
38691 <entry>Default: <emphasis>false</emphasis></entry>
38692 </row>
38693 </tbody>
38694 </tgroup>
38695 </informaltable>
38696 <para>
38697 <indexterm role="concept">
38698 <primary>envelope sender</primary>
38699 </indexterm>
38700 If this option is set true, <command>appendfile</command> writes messages in <quote>batch SMTP</quote>
38701 format, with the envelope sender and recipient(s) included as SMTP commands. If
38702 you want to include a leading HELO command with such messages, you can do
38703 so by setting the <option>message_prefix</option> option. See section <xref linkend="SECTbatchSMTP"/>
38704 for details of batch SMTP.
38705 </para>
38706 <para>
38707 <indexterm role="option">
38708 <primary><option>use_crlf</option></primary>
38709 </indexterm>
38710 </para>
38711 <informaltable frame="all">
38712 <tgroup cols="4" colsep="0" rowsep="0">
38713 <colspec colwidth="8*" align="left"/>
38714 <colspec colwidth="6*" align="center"/>
38715 <colspec colwidth="6*" align="center"/>
38716 <colspec colwidth="6*" align="right"/>
38717 <tbody>
38718 <row>
38719 <entry><option>use_crlf</option></entry>
38720 <entry>Use: <emphasis>appendfile</emphasis></entry>
38721 <entry>Type: <emphasis>boolean</emphasis></entry>
38722 <entry>Default: <emphasis>false</emphasis></entry>
38723 </row>
38724 </tbody>
38725 </tgroup>
38726 </informaltable>
38727 <para>
38728 <indexterm role="concept">
38729 <primary>carriage return</primary>
38730 </indexterm>
38731 <indexterm role="concept">
38732 <primary>linefeed</primary>
38733 </indexterm>
38734 This option causes lines to be terminated with the two-character CRLF sequence
38735 (carriage return, linefeed) instead of just a linefeed character. In the case
38736 of batched SMTP, the byte sequence written to the file is then an exact image
38737 of what would be sent down a real SMTP connection.
38738 </para>
38739 <para>
38740 <emphasis role="bold">Note:</emphasis> The contents of the <option>message_prefix</option> and <option>message_suffix</option> options
38741 (which are used to supply the traditional <quote>From&nbsp;</quote> and blank line separators
38742 in Berkeley-style mailboxes) are written verbatim, so must contain their own
38743 carriage return characters if these are needed. In cases where these options
38744 have non-empty defaults, the values end with a single linefeed, so they must be
38745 changed to end with <literal>\r\n</literal> if <option>use_crlf</option> is set.
38746 </para>
38747 <para>
38748 <indexterm role="option">
38749 <primary><option>use_fcntl_lock</option></primary>
38750 </indexterm>
38751 </para>
38752 <informaltable frame="all">
38753 <tgroup cols="4" colsep="0" rowsep="0">
38754 <colspec colwidth="8*" align="left"/>
38755 <colspec colwidth="6*" align="center"/>
38756 <colspec colwidth="6*" align="center"/>
38757 <colspec colwidth="6*" align="right"/>
38758 <tbody>
38759 <row>
38760 <entry><option>use_fcntl_lock</option></entry>
38761 <entry>Use: <emphasis>appendfile</emphasis></entry>
38762 <entry>Type: <emphasis>boolean</emphasis></entry>
38763 <entry>Default: <emphasis>see below</emphasis></entry>
38764 </row>
38765 </tbody>
38766 </tgroup>
38767 </informaltable>
38768 <para>
38769 This option controls the use of the <function>fcntl()</function> function to lock a file for
38770 exclusive use when a message is being appended. It is set by default unless
38771 <option>use_flock_lock</option> is set. Otherwise, it should be turned off only if you know
38772 that all your MUAs use lock file locking. When both <option>use_fcntl_lock</option> and
38773 <option>use_flock_lock</option> are unset, <option>use_lockfile</option> must be set.
38774 </para>
38775 <para>
38776 <indexterm role="option">
38777 <primary><option>use_flock_lock</option></primary>
38778 </indexterm>
38779 </para>
38780 <informaltable frame="all">
38781 <tgroup cols="4" colsep="0" rowsep="0">
38782 <colspec colwidth="8*" align="left"/>
38783 <colspec colwidth="6*" align="center"/>
38784 <colspec colwidth="6*" align="center"/>
38785 <colspec colwidth="6*" align="right"/>
38786 <tbody>
38787 <row>
38788 <entry><option>use_flock_lock</option></entry>
38789 <entry>Use: <emphasis>appendfile</emphasis></entry>
38790 <entry>Type: <emphasis>boolean</emphasis></entry>
38791 <entry>Default: <emphasis>false</emphasis></entry>
38792 </row>
38793 </tbody>
38794 </tgroup>
38795 </informaltable>
38796 <para>
38797 This option is provided to support the use of <function>flock()</function> for file locking, for
38798 the few situations where it is needed. Most modern operating systems support
38799 <function>fcntl()</function> and <function>lockf()</function> locking, and these two functions interwork with
38800 each other. Exim uses <function>fcntl()</function> locking by default.
38801 </para>
38802 <para>
38803 This option is required only if you are using an operating system where
38804 <function>flock()</function> is used by programs that access mailboxes (typically MUAs), and
38805 where <function>flock()</function> does not correctly interwork with <function>fcntl()</function>. You can use
38806 both <function>fcntl()</function> and <function>flock()</function> locking simultaneously if you want.
38807 </para>
38808 <para>
38809 <indexterm role="concept">
38810 <primary>Solaris</primary>
38811 <secondary><function>flock()</function> support</secondary>
38812 </indexterm>
38813 Not all operating systems provide <function>flock()</function>. Some versions of Solaris do not
38814 have it (and some, I think, provide a not quite right version built on top of
38815 <function>lockf()</function>). If the OS does not have <function>flock()</function>, Exim will be built without
38816 the ability to use it, and any attempt to do so will cause a configuration
38817 error.
38818 </para>
38819 <para>
38820 <emphasis role="bold">Warning</emphasis>: <function>flock()</function> locks do not work on NFS files (unless <function>flock()</function>
38821 is just being mapped onto <function>fcntl()</function> by the OS).
38822 </para>
38823 <para>
38824 <indexterm role="option">
38825 <primary><option>use_lockfile</option></primary>
38826 </indexterm>
38827 </para>
38828 <informaltable frame="all">
38829 <tgroup cols="4" colsep="0" rowsep="0">
38830 <colspec colwidth="8*" align="left"/>
38831 <colspec colwidth="6*" align="center"/>
38832 <colspec colwidth="6*" align="center"/>
38833 <colspec colwidth="6*" align="right"/>
38834 <tbody>
38835 <row>
38836 <entry><option>use_lockfile</option></entry>
38837 <entry>Use: <emphasis>appendfile</emphasis></entry>
38838 <entry>Type: <emphasis>boolean</emphasis></entry>
38839 <entry>Default: <emphasis>see below</emphasis></entry>
38840 </row>
38841 </tbody>
38842 </tgroup>
38843 </informaltable>
38844 <para>
38845 If this option is turned off, Exim does not attempt to create a lock file when
38846 appending to a mailbox file. In this situation, the only locking is by
38847 <function>fcntl()</function>. You should only turn <option>use_lockfile</option> off if you are absolutely
38848 sure that every MUA that is ever going to look at your users&#x2019; mailboxes uses
38849 <function>fcntl()</function> rather than a lock file, and even then only when you are not
38850 delivering over NFS from more than one host.
38851 </para>
38852 <para>
38853 <indexterm role="concept">
38854 <primary>NFS</primary>
38855 <secondary>lock file</secondary>
38856 </indexterm>
38857 In order to append to an NFS file safely from more than one host, it is
38858 necessary to take out a lock <emphasis>before</emphasis> opening the file, and the lock file
38859 achieves this. Otherwise, even with <function>fcntl()</function> locking, there is a risk of
38860 file corruption.
38861 </para>
38862 <para>
38863 The <option>use_lockfile</option> option is set by default unless <option>use_mbx_lock</option> is set.
38864 It is not possible to turn both <option>use_lockfile</option> and <option>use_fcntl_lock</option> off,
38865 except when <option>mbx_format</option> is set.
38866 </para>
38867 <para>
38868 <indexterm role="option">
38869 <primary><option>use_mbx_lock</option></primary>
38870 </indexterm>
38871 </para>
38872 <informaltable frame="all">
38873 <tgroup cols="4" colsep="0" rowsep="0">
38874 <colspec colwidth="8*" align="left"/>
38875 <colspec colwidth="6*" align="center"/>
38876 <colspec colwidth="6*" align="center"/>
38877 <colspec colwidth="6*" align="right"/>
38878 <tbody>
38879 <row>
38880 <entry><option>use_mbx_lock</option></entry>
38881 <entry>Use: <emphasis>appendfile</emphasis></entry>
38882 <entry>Type: <emphasis>boolean</emphasis></entry>
38883 <entry>Default: <emphasis>see below</emphasis></entry>
38884 </row>
38885 </tbody>
38886 </tgroup>
38887 </informaltable>
38888 <para>
38889 This option is available only if Exim has been compiled with SUPPORT_MBX
38890 set in <filename>Local/Makefile</filename>. Setting the option specifies that special MBX
38891 locking rules be used. It is set by default if <option>mbx_format</option> is set and none
38892 of the locking options are mentioned in the configuration. The locking rules
38893 are the same as are used by the <emphasis>c-client</emphasis> library that underlies Pine and
38894 the IMAP4 and POP daemons that come with it (see the discussion below). The
38895 rules allow for shared access to the mailbox. However, this kind of locking
38896 does not work when the mailbox is NFS mounted.
38897 </para>
38898 <para>
38899 You can set <option>use_mbx_lock</option> with either (or both) of <option>use_fcntl_lock</option> and
38900 <option>use_flock_lock</option> to control what kind of locking is used in implementing the
38901 MBX locking rules. The default is to use <function>fcntl()</function> if <option>use_mbx_lock</option> is set
38902 without <option>use_fcntl_lock</option> or <option>use_flock_lock</option>.
38903 </para>
38904 </section>
38905 <section id="SECTopappend">
38906 <title>Operational details for appending</title>
38907 <para>
38908 <indexterm role="concept">
38909 <primary>appending to a file</primary>
38910 </indexterm>
38911 <indexterm role="concept">
38912 <primary>file</primary>
38913 <secondary>appending</secondary>
38914 </indexterm>
38915 Before appending to a file, the following preparations are made:
38916 </para>
38917 <itemizedlist>
38918 <listitem>
38919 <para>
38920 If the name of the file is <filename>/dev/null</filename>, no action is taken, and a success
38921 return is given.
38922 </para>
38923 </listitem>
38924 <listitem>
38925 <para>
38926 <indexterm role="concept">
38927 <primary>directory creation</primary>
38928 </indexterm>
38929 If any directories on the file&#x2019;s path are missing, Exim creates them if the
38930 <option>create_directory</option> option is set. A created directory&#x2019;s mode is given by the
38931 <option>directory_mode</option> option.
38932 </para>
38933 </listitem>
38934 <listitem>
38935 <para>
38936 If <option>file_format</option> is set, the format of an existing file is checked. If this
38937 indicates that a different transport should be used, control is passed to that
38938 transport.
38939 </para>
38940 </listitem>
38941 <listitem>
38942 <para>
38943 <indexterm role="concept">
38944 <primary>file</primary>
38945 <secondary>locking</secondary>
38946 </indexterm>
38947 <indexterm role="concept">
38948 <primary>locking files</primary>
38949 </indexterm>
38950 <indexterm role="concept">
38951 <primary>NFS</primary>
38952 <secondary>lock file</secondary>
38953 </indexterm>
38954 If <option>use_lockfile</option> is set, a lock file is built in a way that will work
38955 reliably over NFS, as follows:
38956 </para>
38957 <orderedlist numeration="arabic">
38958 <listitem>
38959 <para>
38960 Create a <quote>hitching post</quote> file whose name is that of the lock file with the
38961 current time, primary host name, and process id added, by opening for writing
38962 as a new file. If this fails with an access error, delivery is deferred.
38963 </para>
38964 </listitem>
38965 <listitem>
38966 <para>
38967 Close the hitching post file, and hard link it to the lock file name.
38968 </para>
38969 </listitem>
38970 <listitem>
38971 <para>
38972 If the call to <function>link()</function> succeeds, creation of the lock file has succeeded.
38973 Unlink the hitching post name.
38974 </para>
38975 </listitem>
38976 <listitem>
38977 <para>
38978 Otherwise, use <function>stat()</function> to get information about the hitching post file, and
38979 then unlink hitching post name. If the number of links is exactly two, creation
38980 of the lock file succeeded but something (for example, an NFS server crash and
38981 restart) caused this fact not to be communicated to the <function>link()</function> call.
38982 </para>
38983 </listitem>
38984 <listitem>
38985 <para>
38986 If creation of the lock file failed, wait for <option>lock_interval</option> and try again,
38987 up to <option>lock_retries</option> times. However, since any program that writes to a
38988 mailbox should complete its task very quickly, it is reasonable to time out old
38989 lock files that are normally the result of user agent and system crashes. If an
38990 existing lock file is older than <option>lockfile_timeout</option> Exim attempts to unlink
38991 it before trying again.
38992 </para>
38993 </listitem>
38994 </orderedlist>
38995 </listitem>
38996 <listitem>
38997 <para>
38998 A call is made to <function>lstat()</function> to discover whether the main file exists, and if
38999 so, what its characteristics are. If <function>lstat()</function> fails for any reason other
39000 than non-existence, delivery is deferred.
39001 </para>
39002 </listitem>
39003 <listitem>
39004 <para>
39005 <indexterm role="concept">
39006 <primary>symbolic link</primary>
39007 <secondary>to mailbox</secondary>
39008 </indexterm>
39009 <indexterm role="concept">
39010 <primary>mailbox</primary>
39011 <secondary>symbolic link</secondary>
39012 </indexterm>
39013 If the file does exist and is a symbolic link, delivery is deferred, unless the
39014 <option>allow_symlink</option> option is set, in which case the ownership of the link is
39015 checked, and then <function>stat()</function> is called to find out about the real file, which
39016 is then subjected to the checks below. The check on the top-level link
39017 ownership prevents one user creating a link for another&#x2019;s mailbox in a sticky
39018 directory, though allowing symbolic links in this case is definitely not a good
39019 idea. If there is a chain of symbolic links, the intermediate ones are not
39020 checked.
39021 </para>
39022 </listitem>
39023 <listitem>
39024 <para>
39025 If the file already exists but is not a regular file, or if the file&#x2019;s owner
39026 and group (if the group is being checked &ndash; see <option>check_group</option> above) are
39027 different from the user and group under which the delivery is running,
39028 delivery is deferred.
39029 </para>
39030 </listitem>
39031 <listitem>
39032 <para>
39033 If the file&#x2019;s permissions are more generous than specified, they are reduced.
39034 If they are insufficient, delivery is deferred, unless <option>mode_fail_narrower</option>
39035 is set false, in which case the delivery is tried using the existing
39036 permissions.
39037 </para>
39038 </listitem>
39039 <listitem>
39040 <para>
39041 The file&#x2019;s inode number is saved, and the file is then opened for appending.
39042 If this fails because the file has vanished, <command>appendfile</command> behaves as if it
39043 hadn&#x2019;t existed (see below). For any other failures, delivery is deferred.
39044 </para>
39045 </listitem>
39046 <listitem>
39047 <para>
39048 If the file is opened successfully, check that the inode number hasn&#x2019;t
39049 changed, that it is still a regular file, and that the owner and permissions
39050 have not changed. If anything is wrong, defer delivery and freeze the message.
39051 </para>
39052 </listitem>
39053 <listitem>
39054 <para>
39055 If the file did not exist originally, defer delivery if the <option>file_must_exist</option>
39056 option is set. Otherwise, check that the file is being created in a permitted
39057 directory if the <option>create_file</option> option is set (deferring on failure), and then
39058 open for writing as a new file, with the O_EXCL and O_CREAT options,
39059 except when dealing with a symbolic link (the <option>allow_symlink</option> option must be
39060 set). In this case, which can happen if the link points to a non-existent file,
39061 the file is opened for writing using O_CREAT but not O_EXCL, because
39062 that prevents link following.
39063 </para>
39064 </listitem>
39065 <listitem>
39066 <para>
39067 <indexterm role="concept">
39068 <primary>loop</primary>
39069 <secondary>while file testing</secondary>
39070 </indexterm>
39071 If opening fails because the file exists, obey the tests given above for
39072 existing files. However, to avoid looping in a situation where the file is
39073 being continuously created and destroyed, the exists/not-exists loop is broken
39074 after 10 repetitions, and the message is then frozen.
39075 </para>
39076 </listitem>
39077 <listitem>
39078 <para>
39079 If opening fails with any other error, defer delivery.
39080 </para>
39081 </listitem>
39082 <listitem>
39083 <para>
39084 <indexterm role="concept">
39085 <primary>file</primary>
39086 <secondary>locking</secondary>
39087 </indexterm>
39088 <indexterm role="concept">
39089 <primary>locking files</primary>
39090 </indexterm>
39091 Once the file is open, unless both <option>use_fcntl_lock</option> and <option>use_flock_lock</option>
39092 are false, it is locked using <function>fcntl()</function> or <function>flock()</function> or both. If
39093 <option>use_mbx_lock</option> is false, an exclusive lock is requested in each case.
39094 However, if <option>use_mbx_lock</option> is true, Exim takes out a shared lock on the open
39095 file, and an exclusive lock on the file whose name is
39096 </para>
39097 <literallayout class="monospaced">
39098 /tmp/.&lt;device-number&gt;.&lt;inode-number&gt;
39099 </literallayout>
39100 <para>
39101 using the device and inode numbers of the open mailbox file, in accordance with
39102 the MBX locking rules. This file is created with a mode that is specified by
39103 the <option>lockfile_mode</option> option.
39104 </para>
39105 <para>
39106 If Exim fails to lock the file, there are two possible courses of action,
39107 depending on the value of the locking timeout. This is obtained from
39108 <option>lock_fcntl_timeout</option> or <option>lock_flock_timeout</option>, as appropriate.
39109 </para>
39110 <para>
39111 If the timeout value is zero, the file is closed, Exim waits for
39112 <option>lock_interval</option>, and then goes back and re-opens the file as above and tries
39113 to lock it again. This happens up to <option>lock_retries</option> times, after which the
39114 delivery is deferred.
39115 </para>
39116 <para>
39117 If the timeout has a value greater than zero, blocking calls to <function>fcntl()</function> or
39118 <function>flock()</function> are used (with the given timeout), so there has already been some
39119 waiting involved by the time locking fails. Nevertheless, Exim does not give up
39120 immediately. It retries up to
39121 </para>
39122 <literallayout class="monospaced">
39123 (lock_retries * lock_interval) / &lt;timeout&gt;
39124 </literallayout>
39125 <para>
39126 times (rounded up).
39127 </para>
39128 </listitem>
39129 </itemizedlist>
39130 <para>
39131 At the end of delivery, Exim closes the file (which releases the <function>fcntl()</function>
39132 and/or <function>flock()</function> locks) and then deletes the lock file if one was created.
39133 </para>
39134 </section>
39135 <section id="SECTopdir">
39136 <title>Operational details for delivery to a new file</title>
39137 <para>
39138 <indexterm role="concept">
39139 <primary>delivery</primary>
39140 <secondary>to single file</secondary>
39141 </indexterm>
39142 <indexterm role="concept">
39143 <primary><quote>From</quote> line</primary>
39144 </indexterm>
39145 When the <option>directory</option> option is set instead of <option>file</option>, each message is
39146 delivered into a newly-created file or set of files. When <command>appendfile</command> is
39147 activated directly from a <command>redirect</command> router, neither <option>file</option> nor
39148 <option>directory</option> is normally set, because the path for delivery is supplied by the
39149 router. (See for example, the <command>address_file</command> transport in the default
39150 configuration.) In this case, delivery is to a new file if either the path name
39151 ends in <literal>/</literal>, or the <option>maildir_format</option> or <option>mailstore_format</option> option is set.
39152 </para>
39153 <para>
39154 No locking is required while writing the message to a new file, so the various
39155 locking options of the transport are ignored. The <quote>From</quote> line that by default
39156 separates messages in a single file is not normally needed, nor is the escaping
39157 of message lines that start with <quote>From</quote>, and there is no need to ensure a
39158 newline at the end of each message. Consequently, the default values for
39159 <option>check_string</option>, <option>message_prefix</option>, and <option>message_suffix</option> are all unset when
39160 any of <option>directory</option>, <option>maildir_format</option>, or <option>mailstore_format</option> is set.
39161 </para>
39162 <para>
39163 If Exim is required to check a <option>quota</option> setting, it adds up the sizes of all
39164 the files in the delivery directory by default. However, you can specify a
39165 different directory by setting <option>quota_directory</option>. Also, for maildir
39166 deliveries (see below) the <filename>maildirfolder</filename> convention is honoured.
39167 </para>
39168 <para>
39169 <indexterm role="concept">
39170 <primary>maildir format</primary>
39171 </indexterm>
39172 <indexterm role="concept">
39173 <primary>mailstore format</primary>
39174 </indexterm>
39175 There are three different ways in which delivery to individual files can be
39176 done, controlled by the settings of the <option>maildir_format</option> and
39177 <option>mailstore_format</option> options. Note that code to support maildir or mailstore
39178 formats is not included in the binary unless SUPPORT_MAILDIR or
39179 SUPPORT_MAILSTORE, respectively, is set in <filename>Local/Makefile</filename>.
39180 </para>
39181 <para>
39182 <indexterm role="concept">
39183 <primary>directory creation</primary>
39184 </indexterm>
39185 In all three cases an attempt is made to create the directory and any necessary
39186 sub-directories if they do not exist, provided that the <option>create_directory</option>
39187 option is set (the default). The location of a created directory can be
39188 constrained by setting <option>create_file</option>. A created directory&#x2019;s mode is given by
39189 the <option>directory_mode</option> option. If creation fails, or if the
39190 <option>create_directory</option> option is not set when creation is required, delivery is
39191 deferred.
39192 </para>
39193 </section>
39194 <section id="SECTmaildirdelivery">
39195 <title>Maildir delivery</title>
39196 <para>
39197 <indexterm role="concept">
39198 <primary>maildir format</primary>
39199 <secondary>description of</secondary>
39200 </indexterm>
39201 If the <option>maildir_format</option> option is true, Exim delivers each message by writing
39202 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
39203 directory that is defined by the <option>directory</option> option (the <quote>delivery
39204 directory</quote>). If the delivery is successful, the file is renamed into the
39205 <filename>new</filename> subdirectory.
39206 </para>
39207 <para>
39208 In the file name, &lt;<emphasis>stime</emphasis>&gt; is the current time of day in seconds, and
39209 &lt;<emphasis>mtime</emphasis>&gt; is the microsecond fraction of the time. After a maildir delivery,
39210 Exim checks that the time-of-day clock has moved on by at least one microsecond
39211 before terminating the delivery process. This guarantees uniqueness for the
39212 file name. However, as a precaution, Exim calls <function>stat()</function> for the file before
39213 opening it. If any response other than ENOENT (does not exist) is given,
39214 Exim waits 2 seconds and tries again, up to <option>maildir_retries</option> times.
39215 </para>
39216 <para>
39217 Before Exim carries out a maildir delivery, it ensures that subdirectories
39218 called <filename>new</filename>, <filename>cur</filename>, and <filename>tmp</filename> exist in the delivery directory. If they
39219 do not exist, Exim tries to create them and any superior directories in their
39220 path, subject to the <option>create_directory</option> and <option>create_file</option> options. If the
39221 <option>maildirfolder_create_regex</option> option is set, and the regular expression it
39222 contains matches the delivery directory, Exim also ensures that a file called
39223 <filename>maildirfolder</filename> exists in the delivery directory. If a missing directory or
39224 <filename>maildirfolder</filename> file cannot be created, delivery is deferred.
39225 </para>
39226 <para>
39227 These features make it possible to use Exim to create all the necessary files
39228 and directories in a maildir mailbox, including subdirectories for maildir++
39229 folders. Consider this example:
39230 </para>
39231 <literallayout class="monospaced">
39232 maildir_format = true
39233 directory = /var/mail/$local_part\
39234            ${if eq{$local_part_suffix}{}{}\
39235            {/.${substr_1:$local_part_suffix}}}
39236 maildirfolder_create_regex = /\.[^/]+$
39237 </literallayout>
39238 <para>
39239 If <varname>$local_part_suffix</varname> is empty (there was no suffix for the local part),
39240 delivery is into a toplevel maildir with a name like <filename>/var/mail/pimbo</filename> (for
39241 the user called <emphasis>pimbo</emphasis>). The pattern in <option>maildirfolder_create_regex</option> does
39242 not match this name, so Exim will not look for or create the file
39243 <filename>/var/mail/pimbo/maildirfolder</filename>, though it will create
39244 <filename>/var/mail/pimbo/{cur,new,tmp}</filename> if necessary.
39245 </para>
39246 <para>
39247 However, if <varname>$local_part_suffix</varname> contains <literal>-eximusers</literal> (for example),
39248 delivery is into the maildir++ folder <filename>/var/mail/pimbo/.eximusers</filename>, which
39249 does match <option>maildirfolder_create_regex</option>. In this case, Exim will create
39250 <filename>/var/mail/pimbo/.eximusers/maildirfolder</filename> as well as the three maildir
39251 directories <filename>/var/mail/pimbo/.eximusers/{cur,new,tmp}</filename>.
39252 </para>
39253 <para>
39254 <emphasis role="bold">Warning:</emphasis> Take care when setting <option>maildirfolder_create_regex</option> that it does
39255 not inadvertently match the toplevel maildir directory, because a
39256 <filename>maildirfolder</filename> file at top level would completely break quota calculations.
39257 </para>
39258 <para>
39259 <indexterm role="concept">
39260 <primary>quota</primary>
39261 <secondary>in maildir delivery</secondary>
39262 </indexterm>
39263 <indexterm role="concept">
39264 <primary>maildir++</primary>
39265 </indexterm>
39266 If Exim is required to check a <option>quota</option> setting before a maildir delivery, and
39267 <option>quota_directory</option> is not set, it looks for a file called <filename>maildirfolder</filename> in
39268 the maildir directory (alongside <filename>new</filename>, <filename>cur</filename>, <filename>tmp</filename>). If this exists,
39269 Exim assumes the directory is a maildir++ folder directory, which is one level
39270 down from the user&#x2019;s top level mailbox directory. This causes it to start at
39271 the parent directory instead of the current directory when calculating the
39272 amount of space used.
39273 </para>
39274 <para>
39275 One problem with delivering into a multi-file mailbox is that it is
39276 computationally expensive to compute the size of the mailbox for quota
39277 checking. Various approaches have been taken to reduce the amount of work
39278 needed. The next two sections describe two of them. A third alternative is to
39279 use some external process for maintaining the size data, and use the expansion
39280 of the <option>mailbox_size</option> option as a way of importing it into Exim.
39281 </para>
39282 </section>
39283 <section id="SECID135">
39284 <title>Using tags to record message sizes</title>
39285 <para>
39286 If <option>maildir_tag</option> is set, the string is expanded for each delivery.
39287 When the maildir file is renamed into the <filename>new</filename> sub-directory, the
39288 tag is added to its name. However, if adding the tag takes the length of the
39289 name to the point where the test <function>stat()</function> call fails with ENAMETOOLONG,
39290 the tag is dropped and the maildir file is created with no tag.
39291 </para>
39292 <para>
39293 <indexterm role="variable">
39294 <primary><varname>$message_size</varname></primary>
39295 </indexterm>
39296 Tags can be used to encode the size of files in their names; see
39297 <option>quota_size_regex</option> above for an example. The expansion of <option>maildir_tag</option>
39298 happens after the message has been written. The value of the <varname>$message_size</varname>
39299 variable is set to the number of bytes actually written. If the expansion is
39300 forced to fail, the tag is ignored, but a non-forced failure causes delivery to
39301 be deferred. The expanded tag may contain any printing characters except <quote>/</quote>.
39302 Non-printing characters in the string are ignored; if the resulting string is
39303 empty, it is ignored. If it starts with an alphanumeric character, a leading
39304 colon is inserted.
39305 </para>
39306 </section>
39307 <section id="SECID136">
39308 <title>Using a maildirsize file</title>
39309 <para>
39310 <indexterm role="concept">
39311 <primary>quota</primary>
39312 <secondary>in maildir delivery</secondary>
39313 </indexterm>
39314 <indexterm role="concept">
39315 <primary>maildir format</primary>
39316 <secondary><filename>maildirsize</filename> file</secondary>
39317 </indexterm>
39318 If <option>maildir_use_size_file</option> is true, Exim implements the maildir++ rules for
39319 storing quota and message size information in a file called <filename>maildirsize</filename>
39320 within the toplevel maildir directory. If this file does not exist, Exim
39321 creates it, setting the quota from the <option>quota</option> option of the transport. If
39322 the maildir directory itself does not exist, it is created before any attempt
39323 to write a <filename>maildirsize</filename> file.
39324 </para>
39325 <para>
39326 The <filename>maildirsize</filename> file is used to hold information about the sizes of
39327 messages in the maildir, thus speeding up quota calculations. The quota value
39328 in the file is just a cache; if the quota is changed in the transport, the new
39329 value overrides the cached value when the next message is delivered. The cache
39330 is maintained for the benefit of other programs that access the maildir and
39331 need to know the quota.
39332 </para>
39333 <para>
39334 If the <option>quota</option> option in the transport is unset or zero, the <filename>maildirsize</filename>
39335 file is maintained (with a zero quota setting), but no quota is imposed.
39336 </para>
39337 <para>
39338 A regular expression is available for controlling which directories in the
39339 maildir participate in quota calculations when a <filename>maildirsizefile</filename> is in use.
39340 See the description of the <option>maildir_quota_directory_regex</option> option above for
39341 details.
39342 </para>
39343 </section>
39344 <section id="SECID137">
39345 <title>Mailstore delivery</title>
39346 <para>
39347 <indexterm role="concept">
39348 <primary>mailstore format</primary>
39349 <secondary>description of</secondary>
39350 </indexterm>
39351 If the <option>mailstore_format</option> option is true, each message is written as two
39352 files in the given directory. A unique base name is constructed from the
39353 message id and the current delivery process, and the files that are written use
39354 this base name plus the suffixes <filename>.env</filename> and <filename>.msg</filename>. The <filename>.env</filename> file
39355 contains the message&#x2019;s envelope, and the <filename>.msg</filename> file contains the message
39356 itself. The base name is placed in the variable <varname>$mailstore_basename</varname>.
39357 </para>
39358 <para>
39359 During delivery, the envelope is first written to a file with the suffix
39360 <filename>.tmp</filename>. The <filename>.msg</filename> file is then written, and when it is complete, the
39361 <filename>.tmp</filename> file is renamed as the <filename>.env</filename> file. Programs that access messages in
39362 mailstore format should wait for the presence of both a <filename>.msg</filename> and a <filename>.env</filename>
39363 file before accessing either of them. An alternative approach is to wait for
39364 the absence of a <filename>.tmp</filename> file.
39365 </para>
39366 <para>
39367 The envelope file starts with any text defined by the <option>mailstore_prefix</option>
39368 option, expanded and terminated by a newline if there isn&#x2019;t one. Then follows
39369 the sender address on one line, then all the recipient addresses, one per line.
39370 There can be more than one recipient only if the <option>batch_max</option> option is set
39371 greater than one. Finally, <option>mailstore_suffix</option> is expanded and the result
39372 appended to the file, followed by a newline if it does not end with one.
39373 </para>
39374 <para>
39375 If expansion of <option>mailstore_prefix</option> or <option>mailstore_suffix</option> ends with a forced
39376 failure, it is ignored. Other expansion errors are treated as serious
39377 configuration errors, and delivery is deferred. The variable
39378 <varname>$mailstore_basename</varname> is available for use during these expansions.
39379 </para>
39380 </section>
39381 <section id="SECID138">
39382 <title>Non-special new file delivery</title>
39383 <para>
39384 If neither <option>maildir_format</option> nor <option>mailstore_format</option> is set, a single new
39385 file is created directly in the named directory. For example, when delivering
39386 messages into files in batched SMTP format for later delivery to some host (see
39387 section <xref linkend="SECTbatchSMTP"/>), a setting such as
39388 </para>
39389 <literallayout class="monospaced">
39390 directory = /var/bsmtp/$host
39391 </literallayout>
39392 <para>
39393 might be used. A message is written to a file with a temporary name, which is
39394 then renamed when the delivery is complete. The final name is obtained by
39395 expanding the contents of the <option>directory_file</option> option.
39396 <indexterm role="concept" startref="IIDapptra1" class="endofrange"/>
39397 <indexterm role="concept" startref="IIDapptra2" class="endofrange"/>
39398 </para>
39399 </section>
39400 </chapter>
39401
39402 <chapter id="CHID8">
39403 <title>The autoreply transport</title>
39404 <para>
39405 <indexterm role="concept" id="IIDauttra1" class="startofrange">
39406 <primary>transports</primary>
39407 <secondary><command>autoreply</command></secondary>
39408 </indexterm>
39409 <indexterm role="concept" id="IIDauttra2" class="startofrange">
39410 <primary><command>autoreply</command> transport</primary>
39411 </indexterm>
39412 The <command>autoreply</command> transport is not a true transport in that it does not cause
39413 the message to be transmitted. Instead, it generates a new mail message as an
39414 automatic reply to the incoming message. <emphasis>References:</emphasis> and
39415 <emphasis>Auto-Submitted:</emphasis> header lines are included. These are constructed according
39416 to the rules in RFCs 2822 and 3834, respectively.
39417 </para>
39418 <para>
39419 If the router that passes the message to this transport does not have the
39420 <option>unseen</option> option set, the original message (for the current recipient) is not
39421 delivered anywhere. However, when the <option>unseen</option> option is set on the router
39422 that passes the message to this transport, routing of the address continues, so
39423 another router can set up a normal message delivery.
39424 </para>
39425 <para>
39426 The <command>autoreply</command> transport is usually run as the result of mail filtering, a
39427 <quote>vacation</quote> message being the standard example. However, it can also be run
39428 directly from a router like any other transport. To reduce the possibility of
39429 message cascades, messages created by the <command>autoreply</command> transport always have
39430 empty envelope sender addresses, like bounce messages.
39431 </para>
39432 <para>
39433 The parameters of the message to be sent can be specified in the configuration
39434 by options described below. However, these are used only when the address
39435 passed to the transport does not contain its own reply information. When the
39436 transport is run as a consequence of a
39437 <option>mail</option>
39438 or <option>vacation</option> command in a filter file, the parameters of the message are
39439 supplied by the filter, and passed with the address. The transport&#x2019;s options
39440 that define the message are then ignored (so they are not usually set in this
39441 case). The message is specified entirely by the filter or by the transport; it
39442 is never built from a mixture of options. However, the <option>file_optional</option>,
39443 <option>mode</option>, and <option>return_message</option> options apply in all cases.
39444 </para>
39445 <para>
39446 <command>Autoreply</command> is implemented as a local transport. When used as a result of a
39447 command in a user&#x2019;s filter file, <command>autoreply</command> normally runs under the uid and
39448 gid of the user, and with appropriate current and home directories (see chapter
39449 <xref linkend="CHAPenvironment"/>).
39450 </para>
39451 <para>
39452 There is a subtle difference between routing a message to a <command>pipe</command> transport
39453 that generates some text to be returned to the sender, and routing it to an
39454 <command>autoreply</command> transport. This difference is noticeable only if more than one
39455 address from the same message is so handled. In the case of a pipe, the
39456 separate outputs from the different addresses are gathered up and returned to
39457 the sender in a single message, whereas if <command>autoreply</command> is used, a separate
39458 message is generated for each address that is passed to it.
39459 </para>
39460 <para>
39461 Non-printing characters are not permitted in the header lines generated for the
39462 message that <command>autoreply</command> creates, with the exception of newlines that are
39463 immediately followed by white space. If any non-printing characters are found,
39464 the transport defers.
39465 Whether characters with the top bit set count as printing characters or not is
39466 controlled by the <option>print_topbitchars</option> global option.
39467 </para>
39468 <para>
39469 If any of the generic options for manipulating headers (for example,
39470 <option>headers_add</option>) are set on an <command>autoreply</command> transport, they apply to the copy
39471 of the original message that is included in the generated message when
39472 <option>return_message</option> is set. They do not apply to the generated message itself.
39473 </para>
39474 <para>
39475 <indexterm role="variable">
39476 <primary><varname>$sender_address</varname></primary>
39477 </indexterm>
39478 If the <command>autoreply</command> transport receives return code 2 from Exim when it submits
39479 the message, indicating that there were no recipients, it does not treat this
39480 as an error. This means that autoreplies sent to <varname>$sender_address</varname> when this
39481 is empty (because the incoming message is a bounce message) do not cause
39482 problems. They are just discarded.
39483 </para>
39484 <section id="SECID139">
39485 <title>Private options for autoreply</title>
39486 <para>
39487 <indexterm role="concept">
39488 <primary>options</primary>
39489 <secondary><command>autoreply</command> transport</secondary>
39490 </indexterm>
39491 </para>
39492 <para>
39493 <indexterm role="option">
39494 <primary><option>bcc</option></primary>
39495 </indexterm>
39496 </para>
39497 <informaltable frame="all">
39498 <tgroup cols="4" colsep="0" rowsep="0">
39499 <colspec colwidth="8*" align="left"/>
39500 <colspec colwidth="6*" align="center"/>
39501 <colspec colwidth="6*" align="center"/>
39502 <colspec colwidth="6*" align="right"/>
39503 <tbody>
39504 <row>
39505 <entry><option>bcc</option></entry>
39506 <entry>Use: <emphasis>autoreply</emphasis></entry>
39507 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39508 <entry>Default: <emphasis>unset</emphasis></entry>
39509 </row>
39510 </tbody>
39511 </tgroup>
39512 </informaltable>
39513 <para>
39514 This specifies the addresses that are to receive <quote>blind carbon copies</quote> of the
39515 message when the message is specified by the transport.
39516 </para>
39517 <para>
39518 <indexterm role="option">
39519 <primary><option>cc</option></primary>
39520 </indexterm>
39521 </para>
39522 <informaltable frame="all">
39523 <tgroup cols="4" colsep="0" rowsep="0">
39524 <colspec colwidth="8*" align="left"/>
39525 <colspec colwidth="6*" align="center"/>
39526 <colspec colwidth="6*" align="center"/>
39527 <colspec colwidth="6*" align="right"/>
39528 <tbody>
39529 <row>
39530 <entry><option>cc</option></entry>
39531 <entry>Use: <emphasis>autoreply</emphasis></entry>
39532 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39533 <entry>Default: <emphasis>unset</emphasis></entry>
39534 </row>
39535 </tbody>
39536 </tgroup>
39537 </informaltable>
39538 <para>
39539 This specifies recipients of the message and the contents of the <emphasis>Cc:</emphasis> header
39540 when the message is specified by the transport.
39541 </para>
39542 <para>
39543 <indexterm role="option">
39544 <primary><option>file</option></primary>
39545 </indexterm>
39546 </para>
39547 <informaltable frame="all">
39548 <tgroup cols="4" colsep="0" rowsep="0">
39549 <colspec colwidth="8*" align="left"/>
39550 <colspec colwidth="6*" align="center"/>
39551 <colspec colwidth="6*" align="center"/>
39552 <colspec colwidth="6*" align="right"/>
39553 <tbody>
39554 <row>
39555 <entry><option>file</option></entry>
39556 <entry>Use: <emphasis>autoreply</emphasis></entry>
39557 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39558 <entry>Default: <emphasis>unset</emphasis></entry>
39559 </row>
39560 </tbody>
39561 </tgroup>
39562 </informaltable>
39563 <para>
39564 The contents of the file are sent as the body of the message when the message
39565 is specified by the transport. If both <option>file</option> and <option>text</option> are set, the text
39566 string comes first.
39567 </para>
39568 <para>
39569 <indexterm role="option">
39570 <primary><option>file_expand</option></primary>
39571 </indexterm>
39572 </para>
39573 <informaltable frame="all">
39574 <tgroup cols="4" colsep="0" rowsep="0">
39575 <colspec colwidth="8*" align="left"/>
39576 <colspec colwidth="6*" align="center"/>
39577 <colspec colwidth="6*" align="center"/>
39578 <colspec colwidth="6*" align="right"/>
39579 <tbody>
39580 <row>
39581 <entry><option>file_expand</option></entry>
39582 <entry>Use: <emphasis>autoreply</emphasis></entry>
39583 <entry>Type: <emphasis>boolean</emphasis></entry>
39584 <entry>Default: <emphasis>false</emphasis></entry>
39585 </row>
39586 </tbody>
39587 </tgroup>
39588 </informaltable>
39589 <para>
39590 If this is set, the contents of the file named by the <option>file</option> option are
39591 subjected to string expansion as they are added to the message.
39592 </para>
39593 <para>
39594 <indexterm role="option">
39595 <primary><option>file_optional</option></primary>
39596 </indexterm>
39597 </para>
39598 <informaltable frame="all">
39599 <tgroup cols="4" colsep="0" rowsep="0">
39600 <colspec colwidth="8*" align="left"/>
39601 <colspec colwidth="6*" align="center"/>
39602 <colspec colwidth="6*" align="center"/>
39603 <colspec colwidth="6*" align="right"/>
39604 <tbody>
39605 <row>
39606 <entry><option>file_optional</option></entry>
39607 <entry>Use: <emphasis>autoreply</emphasis></entry>
39608 <entry>Type: <emphasis>boolean</emphasis></entry>
39609 <entry>Default: <emphasis>false</emphasis></entry>
39610 </row>
39611 </tbody>
39612 </tgroup>
39613 </informaltable>
39614 <para>
39615 If this option is true, no error is generated if the file named by the <option>file</option>
39616 option or passed with the address does not exist or cannot be read.
39617 </para>
39618 <para>
39619 <indexterm role="option">
39620 <primary><option>from</option></primary>
39621 </indexterm>
39622 </para>
39623 <informaltable frame="all">
39624 <tgroup cols="4" colsep="0" rowsep="0">
39625 <colspec colwidth="8*" align="left"/>
39626 <colspec colwidth="6*" align="center"/>
39627 <colspec colwidth="6*" align="center"/>
39628 <colspec colwidth="6*" align="right"/>
39629 <tbody>
39630 <row>
39631 <entry><option>from</option></entry>
39632 <entry>Use: <emphasis>autoreply</emphasis></entry>
39633 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39634 <entry>Default: <emphasis>unset</emphasis></entry>
39635 </row>
39636 </tbody>
39637 </tgroup>
39638 </informaltable>
39639 <para>
39640 This specifies the contents of the <emphasis>From:</emphasis> header when the message is
39641 specified by the transport.
39642 </para>
39643 <para>
39644 <indexterm role="option">
39645 <primary><option>headers</option></primary>
39646 </indexterm>
39647 </para>
39648 <informaltable frame="all">
39649 <tgroup cols="4" colsep="0" rowsep="0">
39650 <colspec colwidth="8*" align="left"/>
39651 <colspec colwidth="6*" align="center"/>
39652 <colspec colwidth="6*" align="center"/>
39653 <colspec colwidth="6*" align="right"/>
39654 <tbody>
39655 <row>
39656 <entry><option>headers</option></entry>
39657 <entry>Use: <emphasis>autoreply</emphasis></entry>
39658 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39659 <entry>Default: <emphasis>unset</emphasis></entry>
39660 </row>
39661 </tbody>
39662 </tgroup>
39663 </informaltable>
39664 <para>
39665 This specifies additional RFC 2822 headers that are to be added to the message
39666 when the message is specified by the transport. Several can be given by using
39667 <quote>\n</quote> to separate them. There is no check on the format.
39668 </para>
39669 <para>
39670 <indexterm role="option">
39671 <primary><option>log</option></primary>
39672 </indexterm>
39673 </para>
39674 <informaltable frame="all">
39675 <tgroup cols="4" colsep="0" rowsep="0">
39676 <colspec colwidth="8*" align="left"/>
39677 <colspec colwidth="6*" align="center"/>
39678 <colspec colwidth="6*" align="center"/>
39679 <colspec colwidth="6*" align="right"/>
39680 <tbody>
39681 <row>
39682 <entry><option>log</option></entry>
39683 <entry>Use: <emphasis>autoreply</emphasis></entry>
39684 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39685 <entry>Default: <emphasis>unset</emphasis></entry>
39686 </row>
39687 </tbody>
39688 </tgroup>
39689 </informaltable>
39690 <para>
39691 This option names a file in which a record of every message sent is logged when
39692 the message is specified by the transport.
39693 </para>
39694 <para>
39695 <indexterm role="option">
39696 <primary><option>mode</option></primary>
39697 </indexterm>
39698 </para>
39699 <informaltable frame="all">
39700 <tgroup cols="4" colsep="0" rowsep="0">
39701 <colspec colwidth="8*" align="left"/>
39702 <colspec colwidth="6*" align="center"/>
39703 <colspec colwidth="6*" align="center"/>
39704 <colspec colwidth="6*" align="right"/>
39705 <tbody>
39706 <row>
39707 <entry><option>mode</option></entry>
39708 <entry>Use: <emphasis>autoreply</emphasis></entry>
39709 <entry>Type: <emphasis>octal integer</emphasis></entry>
39710 <entry>Default: <emphasis>0600</emphasis></entry>
39711 </row>
39712 </tbody>
39713 </tgroup>
39714 </informaltable>
39715 <para>
39716 If either the log file or the <quote>once</quote> file has to be created, this mode is
39717 used.
39718 </para>
39719 <para>
39720 <indexterm role="option">
39721 <primary><option>never_mail</option></primary>
39722 </indexterm>
39723 </para>
39724 <informaltable frame="all">
39725 <tgroup cols="4" colsep="0" rowsep="0">
39726 <colspec colwidth="8*" align="left"/>
39727 <colspec colwidth="6*" align="center"/>
39728 <colspec colwidth="6*" align="center"/>
39729 <colspec colwidth="6*" align="right"/>
39730 <tbody>
39731 <row>
39732 <entry><option>never_mail</option></entry>
39733 <entry>Use: <emphasis>autoreply</emphasis></entry>
39734 <entry>Type: <emphasis>address list</emphasis>&dagger;<emphasis></emphasis></entry>
39735 <entry>Default: <emphasis>unset</emphasis></entry>
39736 </row>
39737 </tbody>
39738 </tgroup>
39739 </informaltable>
39740 <para>
39741 If any run of the transport creates a message with a recipient that matches any
39742 item in the list, that recipient is quietly discarded. If all recipients are
39743 discarded, no message is created. This applies both when the recipients are
39744 generated by a filter and when they are specified in the transport.
39745 </para>
39746 <para>
39747 <indexterm role="option">
39748 <primary><option>once</option></primary>
39749 </indexterm>
39750 </para>
39751 <informaltable frame="all">
39752 <tgroup cols="4" colsep="0" rowsep="0">
39753 <colspec colwidth="8*" align="left"/>
39754 <colspec colwidth="6*" align="center"/>
39755 <colspec colwidth="6*" align="center"/>
39756 <colspec colwidth="6*" align="right"/>
39757 <tbody>
39758 <row>
39759 <entry><option>once</option></entry>
39760 <entry>Use: <emphasis>autoreply</emphasis></entry>
39761 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39762 <entry>Default: <emphasis>unset</emphasis></entry>
39763 </row>
39764 </tbody>
39765 </tgroup>
39766 </informaltable>
39767 <para>
39768 This option names a file or DBM database in which a record of each <emphasis>To:</emphasis>
39769 recipient is kept when the message is specified by the transport. <emphasis role="bold">Note</emphasis>:
39770 This does not apply to <emphasis>Cc:</emphasis> or <emphasis>Bcc:</emphasis> recipients.
39771 </para>
39772 <para>
39773 If <option>once</option> is unset, or is set to an empty string, the message is always sent.
39774 By default, if <option>once</option> is set to a non-empty file name, the message
39775 is not sent if a potential recipient is already listed in the database.
39776 However, if the <option>once_repeat</option> option specifies a time greater than zero, the
39777 message is sent if that much time has elapsed since a message was last sent to
39778 this recipient. A setting of zero time for <option>once_repeat</option> (the default)
39779 prevents a message from being sent a second time &ndash; in this case, zero means
39780 infinity.
39781 </para>
39782 <para>
39783 If <option>once_file_size</option> is zero, a DBM database is used to remember recipients,
39784 and it is allowed to grow as large as necessary. If <option>once_file_size</option> is set
39785 greater than zero, it changes the way Exim implements the <option>once</option> option.
39786 Instead of using a DBM file to record every recipient it sends to, it uses a
39787 regular file, whose size will never get larger than the given value.
39788 </para>
39789 <para>
39790 In the file, Exim keeps a linear list of recipient addresses and the times at
39791 which they were sent messages. If the file is full when a new address needs to
39792 be added, the oldest address is dropped. If <option>once_repeat</option> is not set, this
39793 means that a given recipient may receive multiple messages, but at
39794 unpredictable intervals that depend on the rate of turnover of addresses in the
39795 file. If <option>once_repeat</option> is set, it specifies a maximum time between repeats.
39796 </para>
39797 <para>
39798 <indexterm role="option">
39799 <primary><option>once_file_size</option></primary>
39800 </indexterm>
39801 </para>
39802 <informaltable frame="all">
39803 <tgroup cols="4" colsep="0" rowsep="0">
39804 <colspec colwidth="8*" align="left"/>
39805 <colspec colwidth="6*" align="center"/>
39806 <colspec colwidth="6*" align="center"/>
39807 <colspec colwidth="6*" align="right"/>
39808 <tbody>
39809 <row>
39810 <entry><option>once_file_size</option></entry>
39811 <entry>Use: <emphasis>autoreply</emphasis></entry>
39812 <entry>Type: <emphasis>integer</emphasis></entry>
39813 <entry>Default: <emphasis>0</emphasis></entry>
39814 </row>
39815 </tbody>
39816 </tgroup>
39817 </informaltable>
39818 <para>
39819 See <option>once</option> above.
39820 </para>
39821 <para>
39822 <indexterm role="option">
39823 <primary><option>once_repeat</option></primary>
39824 </indexterm>
39825 </para>
39826 <informaltable frame="all">
39827 <tgroup cols="4" colsep="0" rowsep="0">
39828 <colspec colwidth="8*" align="left"/>
39829 <colspec colwidth="6*" align="center"/>
39830 <colspec colwidth="6*" align="center"/>
39831 <colspec colwidth="6*" align="right"/>
39832 <tbody>
39833 <row>
39834 <entry><option>once_repeat</option></entry>
39835 <entry>Use: <emphasis>autoreply</emphasis></entry>
39836 <entry>Type: <emphasis>time</emphasis>&dagger;<emphasis></emphasis></entry>
39837 <entry>Default: <emphasis>0s</emphasis></entry>
39838 </row>
39839 </tbody>
39840 </tgroup>
39841 </informaltable>
39842 <para>
39843 See <option>once</option> above.
39844 After expansion, the value of this option must be a valid time value.
39845 </para>
39846 <para>
39847 <indexterm role="option">
39848 <primary><option>reply_to</option></primary>
39849 </indexterm>
39850 </para>
39851 <informaltable frame="all">
39852 <tgroup cols="4" colsep="0" rowsep="0">
39853 <colspec colwidth="8*" align="left"/>
39854 <colspec colwidth="6*" align="center"/>
39855 <colspec colwidth="6*" align="center"/>
39856 <colspec colwidth="6*" align="right"/>
39857 <tbody>
39858 <row>
39859 <entry><option>reply_to</option></entry>
39860 <entry>Use: <emphasis>autoreply</emphasis></entry>
39861 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39862 <entry>Default: <emphasis>unset</emphasis></entry>
39863 </row>
39864 </tbody>
39865 </tgroup>
39866 </informaltable>
39867 <para>
39868 This specifies the contents of the <emphasis>Reply-To:</emphasis> header when the message is
39869 specified by the transport.
39870 </para>
39871 <para>
39872 <indexterm role="option">
39873 <primary><option>return_message</option></primary>
39874 </indexterm>
39875 </para>
39876 <informaltable frame="all">
39877 <tgroup cols="4" colsep="0" rowsep="0">
39878 <colspec colwidth="8*" align="left"/>
39879 <colspec colwidth="6*" align="center"/>
39880 <colspec colwidth="6*" align="center"/>
39881 <colspec colwidth="6*" align="right"/>
39882 <tbody>
39883 <row>
39884 <entry><option>return_message</option></entry>
39885 <entry>Use: <emphasis>autoreply</emphasis></entry>
39886 <entry>Type: <emphasis>boolean</emphasis></entry>
39887 <entry>Default: <emphasis>false</emphasis></entry>
39888 </row>
39889 </tbody>
39890 </tgroup>
39891 </informaltable>
39892 <para>
39893 If this is set, a copy of the original message is returned with the new
39894 message, subject to the maximum size set in the <option>return_size_limit</option> global
39895 configuration option.
39896 </para>
39897 <para>
39898 <indexterm role="option">
39899 <primary><option>subject</option></primary>
39900 </indexterm>
39901 </para>
39902 <informaltable frame="all">
39903 <tgroup cols="4" colsep="0" rowsep="0">
39904 <colspec colwidth="8*" align="left"/>
39905 <colspec colwidth="6*" align="center"/>
39906 <colspec colwidth="6*" align="center"/>
39907 <colspec colwidth="6*" align="right"/>
39908 <tbody>
39909 <row>
39910 <entry><option>subject</option></entry>
39911 <entry>Use: <emphasis>autoreply</emphasis></entry>
39912 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39913 <entry>Default: <emphasis>unset</emphasis></entry>
39914 </row>
39915 </tbody>
39916 </tgroup>
39917 </informaltable>
39918 <para>
39919 This specifies the contents of the <emphasis>Subject:</emphasis> header when the message is
39920 specified by the transport. It is tempting to quote the original subject in
39921 automatic responses. For example:
39922 </para>
39923 <literallayout class="monospaced">
39924 subject = Re: $h_subject:
39925 </literallayout>
39926 <para>
39927 There is a danger in doing this, however. It may allow a third party to
39928 subscribe your users to an opt-in mailing list, provided that the list accepts
39929 bounce messages as subscription confirmations. Well-managed lists require a
39930 non-bounce message to confirm a subscription, so the danger is relatively
39931 small.
39932 </para>
39933 <para>
39934 <indexterm role="option">
39935 <primary><option>text</option></primary>
39936 </indexterm>
39937 </para>
39938 <informaltable frame="all">
39939 <tgroup cols="4" colsep="0" rowsep="0">
39940 <colspec colwidth="8*" align="left"/>
39941 <colspec colwidth="6*" align="center"/>
39942 <colspec colwidth="6*" align="center"/>
39943 <colspec colwidth="6*" align="right"/>
39944 <tbody>
39945 <row>
39946 <entry><option>text</option></entry>
39947 <entry>Use: <emphasis>autoreply</emphasis></entry>
39948 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39949 <entry>Default: <emphasis>unset</emphasis></entry>
39950 </row>
39951 </tbody>
39952 </tgroup>
39953 </informaltable>
39954 <para>
39955 This specifies a single string to be used as the body of the message when the
39956 message is specified by the transport. If both <option>text</option> and <option>file</option> are set,
39957 the text comes first.
39958 </para>
39959 <para>
39960 <indexterm role="option">
39961 <primary><option>to</option></primary>
39962 </indexterm>
39963 </para>
39964 <informaltable frame="all">
39965 <tgroup cols="4" colsep="0" rowsep="0">
39966 <colspec colwidth="8*" align="left"/>
39967 <colspec colwidth="6*" align="center"/>
39968 <colspec colwidth="6*" align="center"/>
39969 <colspec colwidth="6*" align="right"/>
39970 <tbody>
39971 <row>
39972 <entry><option>to</option></entry>
39973 <entry>Use: <emphasis>autoreply</emphasis></entry>
39974 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39975 <entry>Default: <emphasis>unset</emphasis></entry>
39976 </row>
39977 </tbody>
39978 </tgroup>
39979 </informaltable>
39980 <para>
39981 This specifies recipients of the message and the contents of the <emphasis>To:</emphasis> header
39982 when the message is specified by the transport.
39983 <indexterm role="concept" startref="IIDauttra1" class="endofrange"/>
39984 <indexterm role="concept" startref="IIDauttra2" class="endofrange"/>
39985 </para>
39986 </section>
39987 </chapter>
39988
39989 <chapter id="CHAPLMTP">
39990 <title>The lmtp transport</title>
39991 <para>
39992 <indexterm role="concept">
39993 <primary>transports</primary>
39994 <secondary><command>lmtp</command></secondary>
39995 </indexterm>
39996 <indexterm role="concept">
39997 <primary><command>lmtp</command> transport</primary>
39998 </indexterm>
39999 <indexterm role="concept">
40000 <primary>LMTP</primary>
40001 <secondary>over a pipe</secondary>
40002 </indexterm>
40003 <indexterm role="concept">
40004 <primary>LMTP</primary>
40005 <secondary>over a socket</secondary>
40006 </indexterm>
40007 The <command>lmtp</command> transport runs the LMTP protocol (RFC 2033) over a pipe to a
40008 specified command
40009 or by interacting with a Unix domain socket.
40010 This transport is something of a cross between the <command>pipe</command> and <command>smtp</command>
40011 transports. Exim also has support for using LMTP over TCP/IP; this is
40012 implemented as an option for the <command>smtp</command> transport. Because LMTP is expected
40013 to be of minority interest, the default build-time configure in <filename>src/EDITME</filename>
40014 has it commented out. You need to ensure that
40015 </para>
40016 <literallayout class="monospaced">
40017 TRANSPORT_LMTP=yes
40018 </literallayout>
40019 <para>
40020 <indexterm role="concept">
40021 <primary>options</primary>
40022 <secondary><command>lmtp</command> transport</secondary>
40023 </indexterm>
40024 is present in your <filename>Local/Makefile</filename> in order to have the <command>lmtp</command> transport
40025 included in the Exim binary. The private options of the <command>lmtp</command> transport are
40026 as follows:
40027 </para>
40028 <para>
40029 <indexterm role="option">
40030 <primary><option>batch_id</option></primary>
40031 </indexterm>
40032 </para>
40033 <informaltable frame="all">
40034 <tgroup cols="4" colsep="0" rowsep="0">
40035 <colspec colwidth="8*" align="left"/>
40036 <colspec colwidth="6*" align="center"/>
40037 <colspec colwidth="6*" align="center"/>
40038 <colspec colwidth="6*" align="right"/>
40039 <tbody>
40040 <row>
40041 <entry><option>batch_id</option></entry>
40042 <entry>Use: <emphasis>lmtp</emphasis></entry>
40043 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40044 <entry>Default: <emphasis>unset</emphasis></entry>
40045 </row>
40046 </tbody>
40047 </tgroup>
40048 </informaltable>
40049 <para>
40050 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
40051 </para>
40052 <para>
40053 <indexterm role="option">
40054 <primary><option>batch_max</option></primary>
40055 </indexterm>
40056 </para>
40057 <informaltable frame="all">
40058 <tgroup cols="4" colsep="0" rowsep="0">
40059 <colspec colwidth="8*" align="left"/>
40060 <colspec colwidth="6*" align="center"/>
40061 <colspec colwidth="6*" align="center"/>
40062 <colspec colwidth="6*" align="right"/>
40063 <tbody>
40064 <row>
40065 <entry><option>batch_max</option></entry>
40066 <entry>Use: <emphasis>lmtp</emphasis></entry>
40067 <entry>Type: <emphasis>integer</emphasis></entry>
40068 <entry>Default: <emphasis>1</emphasis></entry>
40069 </row>
40070 </tbody>
40071 </tgroup>
40072 </informaltable>
40073 <para>
40074 This limits the number of addresses that can be handled in a single delivery.
40075 Most LMTP servers can handle several addresses at once, so it is normally a
40076 good idea to increase this value. See the description of local delivery
40077 batching in chapter <xref linkend="CHAPbatching"/>.
40078 </para>
40079 <para>
40080 <indexterm role="option">
40081 <primary><option>command</option></primary>
40082 </indexterm>
40083 </para>
40084 <informaltable frame="all">
40085 <tgroup cols="4" colsep="0" rowsep="0">
40086 <colspec colwidth="8*" align="left"/>
40087 <colspec colwidth="6*" align="center"/>
40088 <colspec colwidth="6*" align="center"/>
40089 <colspec colwidth="6*" align="right"/>
40090 <tbody>
40091 <row>
40092 <entry><option>command</option></entry>
40093 <entry>Use: <emphasis>lmtp</emphasis></entry>
40094 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40095 <entry>Default: <emphasis>unset</emphasis></entry>
40096 </row>
40097 </tbody>
40098 </tgroup>
40099 </informaltable>
40100 <para>
40101 This option must be set if <option>socket</option> is not set. The string is a command which
40102 is run in a separate process. It is split up into a command name and list of
40103 arguments, each of which is separately expanded (so expansion cannot change the
40104 number of arguments). The command is run directly, not via a shell. The message
40105 is passed to the new process using the standard input and output to operate the
40106 LMTP protocol.
40107 </para>
40108 <para>
40109 <indexterm role="option">
40110 <primary><option>ignore_quota</option></primary>
40111 </indexterm>
40112 </para>
40113 <informaltable frame="all">
40114 <tgroup cols="4" colsep="0" rowsep="0">
40115 <colspec colwidth="8*" align="left"/>
40116 <colspec colwidth="6*" align="center"/>
40117 <colspec colwidth="6*" align="center"/>
40118 <colspec colwidth="6*" align="right"/>
40119 <tbody>
40120 <row>
40121 <entry><option>ignore_quota</option></entry>
40122 <entry>Use: <emphasis>lmtp</emphasis></entry>
40123 <entry>Type: <emphasis>boolean</emphasis></entry>
40124 <entry>Default: <emphasis>false</emphasis></entry>
40125 </row>
40126 </tbody>
40127 </tgroup>
40128 </informaltable>
40129 <para>
40130 <indexterm role="concept">
40131 <primary>LMTP</primary>
40132 <secondary>ignoring quota errors</secondary>
40133 </indexterm>
40134 If this option is set true, the string <literal>IGNOREQUOTA</literal> is added to RCPT
40135 commands, provided that the LMTP server has advertised support for IGNOREQUOTA
40136 in its response to the LHLO command.
40137 </para>
40138 <para>
40139 <indexterm role="option">
40140 <primary><option>socket</option></primary>
40141 </indexterm>
40142 </para>
40143 <informaltable frame="all">
40144 <tgroup cols="4" colsep="0" rowsep="0">
40145 <colspec colwidth="8*" align="left"/>
40146 <colspec colwidth="6*" align="center"/>
40147 <colspec colwidth="6*" align="center"/>
40148 <colspec colwidth="6*" align="right"/>
40149 <tbody>
40150 <row>
40151 <entry><option>socket</option></entry>
40152 <entry>Use: <emphasis>lmtp</emphasis></entry>
40153 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40154 <entry>Default: <emphasis>unset</emphasis></entry>
40155 </row>
40156 </tbody>
40157 </tgroup>
40158 </informaltable>
40159 <para>
40160 This option must be set if <option>command</option> is not set. The result of expansion must
40161 be the name of a Unix domain socket. The transport connects to the socket and
40162 delivers the message to it using the LMTP protocol.
40163 </para>
40164 <para>
40165 <indexterm role="option">
40166 <primary><option>timeout</option></primary>
40167 </indexterm>
40168 </para>
40169 <informaltable frame="all">
40170 <tgroup cols="4" colsep="0" rowsep="0">
40171 <colspec colwidth="8*" align="left"/>
40172 <colspec colwidth="6*" align="center"/>
40173 <colspec colwidth="6*" align="center"/>
40174 <colspec colwidth="6*" align="right"/>
40175 <tbody>
40176 <row>
40177 <entry><option>timeout</option></entry>
40178 <entry>Use: <emphasis>lmtp</emphasis></entry>
40179 <entry>Type: <emphasis>time</emphasis></entry>
40180 <entry>Default: <emphasis>5m</emphasis></entry>
40181 </row>
40182 </tbody>
40183 </tgroup>
40184 </informaltable>
40185 <para>
40186 The transport is aborted if the created process or Unix domain socket does not
40187 respond to LMTP commands or message input within this timeout. Delivery
40188 is deferred, and will be tried again later. Here is an example of a typical
40189 LMTP transport:
40190 </para>
40191 <literallayout class="monospaced">
40192 lmtp:
40193   driver = lmtp
40194   command = /some/local/lmtp/delivery/program
40195   batch_max = 20
40196   user = exim
40197 </literallayout>
40198 <para>
40199 This delivers up to 20 addresses at a time, in a mixture of domains if
40200 necessary, running as the user <emphasis>exim</emphasis>.
40201 </para>
40202 </chapter>
40203
40204 <chapter id="CHAPpipetransport">
40205 <title>The pipe transport</title>
40206 <para>
40207 <indexterm role="concept" id="IIDpiptra1" class="startofrange">
40208 <primary>transports</primary>
40209 <secondary><command>pipe</command></secondary>
40210 </indexterm>
40211 <indexterm role="concept" id="IIDpiptra2" class="startofrange">
40212 <primary><command>pipe</command> transport</primary>
40213 </indexterm>
40214 The <command>pipe</command> transport is used to deliver messages via a pipe to a command
40215 running in another process. One example is the use of <command>pipe</command> as a
40216 pseudo-remote transport for passing messages to some other delivery mechanism
40217 (such as UUCP). Another is the use by individual users to automatically process
40218 their incoming messages. The <command>pipe</command> transport can be used in one of the
40219 following ways:
40220 </para>
40221 <itemizedlist>
40222 <listitem>
40223 <para>
40224 <indexterm role="variable">
40225 <primary><varname>$local_part</varname></primary>
40226 </indexterm>
40227 A router routes one address to a transport in the normal way, and the
40228 transport is configured as a <command>pipe</command> transport. In this case, <varname>$local_part</varname>
40229 contains the local part of the address (as usual), and the command that is run
40230 is specified by the <option>command</option> option on the transport.
40231 </para>
40232 </listitem>
40233 <listitem>
40234 <para>
40235 <indexterm role="variable">
40236 <primary><varname>$pipe_addresses</varname></primary>
40237 </indexterm>
40238 If the <option>batch_max</option> option is set greater than 1 (the default is 1), the
40239 transport can handle more than one address in a single run. In this case, when
40240 more than one address is routed to the transport, <varname>$local_part</varname> is not set
40241 (because it is not unique). However, the pseudo-variable <varname>$pipe_addresses</varname>
40242 (described in section <xref linkend="SECThowcommandrun"/> below) contains all the addresses
40243 that are routed to the transport.
40244 </para>
40245 </listitem>
40246 <listitem>
40247 <para>
40248 <indexterm role="variable">
40249 <primary><varname>$address_pipe</varname></primary>
40250 </indexterm>
40251 A router redirects an address directly to a pipe command (for example, from an
40252 alias or forward file). In this case, <varname>$address_pipe</varname> contains the text of the
40253 pipe command, and the <option>command</option> option on the transport is ignored. If only
40254 one address is being transported (<option>batch_max</option> is not greater than one, or
40255 only one address was redirected to this pipe command), <varname>$local_part</varname> contains
40256 the local part that was redirected.
40257 </para>
40258 </listitem>
40259 </itemizedlist>
40260 <para>
40261 The <command>pipe</command> transport is a non-interactive delivery method. Exim can also
40262 deliver messages over pipes using the LMTP interactive protocol. This is
40263 implemented by the <command>lmtp</command> transport.
40264 </para>
40265 <para>
40266 In the case when <command>pipe</command> is run as a consequence of an entry in a local user&#x2019;s
40267 <filename>.forward</filename> file, the command runs under the uid and gid of that user. In
40268 other cases, the uid and gid have to be specified explicitly, either on the
40269 transport or on the router that handles the address. Current and <quote>home</quote>
40270 directories are also controllable. See chapter <xref linkend="CHAPenvironment"/> for
40271 details of the local delivery environment and chapter <xref linkend="CHAPbatching"/>
40272 for a discussion of local delivery batching.
40273 </para>
40274 <section id="SECID140">
40275 <title>Concurrent delivery</title>
40276 <para>
40277 If two messages arrive at almost the same time, and both are routed to a pipe
40278 delivery, the two pipe transports may be run concurrently. You must ensure that
40279 any pipe commands you set up are robust against this happening. If the commands
40280 write to a file, the <option>exim_lock</option> utility might be of use.
40281 </para>
40282 </section>
40283 <section id="SECID141">
40284 <title>Returned status and data</title>
40285 <para>
40286 <indexterm role="concept">
40287 <primary><command>pipe</command> transport</primary>
40288 <secondary>returned data</secondary>
40289 </indexterm>
40290 If the command exits with a non-zero return code, the delivery is deemed to
40291 have failed, unless either the <option>ignore_status</option> option is set (in which case
40292 the return code is treated as zero), or the return code is one of those listed
40293 in the <option>temp_errors</option> option, which are interpreted as meaning <quote>try again
40294 later</quote>. In this case, delivery is deferred. Details of a permanent failure are
40295 logged, but are not included in the bounce message, which merely contains
40296 <quote>local delivery failed</quote>.
40297 </para>
40298 <para>
40299 If the return code is greater than 128 and the command being run is a shell
40300 script, it normally means that the script was terminated by a signal whose
40301 value is the return code minus 128.
40302 </para>
40303 <para>
40304 If Exim is unable to run the command (that is, if <function>execve()</function> fails), the
40305 return code is set to 127. This is the value that a shell returns if it is
40306 asked to run a non-existent command. The wording for the log line suggests that
40307 a non-existent command may be the problem.
40308 </para>
40309 <para>
40310 The <option>return_output</option> option can affect the result of a pipe delivery. If it is
40311 set and the command produces any output on its standard output or standard
40312 error streams, the command is considered to have failed, even if it gave a zero
40313 return code or if <option>ignore_status</option> is set. The output from the command is
40314 included as part of the bounce message. The <option>return_fail_output</option> option is
40315 similar, except that output is returned only when the command exits with a
40316 failure return code, that is, a value other than zero or a code that matches
40317 <option>temp_errors</option>.
40318 </para>
40319 </section>
40320 <section id="SECThowcommandrun">
40321 <title>How the command is run</title>
40322 <para>
40323 <indexterm role="concept">
40324 <primary><command>pipe</command> transport</primary>
40325 <secondary>path for command</secondary>
40326 </indexterm>
40327 The command line is (by default) broken down into a command name and arguments
40328 by the <command>pipe</command> transport itself. The <option>allow_commands</option> and
40329 <option>restrict_to_path</option> options can be used to restrict the commands that may be
40330 run.
40331 </para>
40332 <para>
40333 <indexterm role="concept">
40334 <primary>quoting</primary>
40335 <secondary>in pipe command</secondary>
40336 </indexterm>
40337 Unquoted arguments are delimited by white space. If an argument appears in
40338 double quotes, backslash is interpreted as an escape character in the usual
40339 way. If an argument appears in single quotes, no escaping is done.
40340 </para>
40341 <para>
40342 String expansion is applied to the command line except when it comes from a
40343 traditional <filename>.forward</filename> file (commands from a filter file are expanded). The
40344 expansion is applied to each argument in turn rather than to the whole line.
40345 For this reason, any string expansion item that contains white space must be
40346 quoted so as to be contained within a single argument. A setting such as
40347 </para>
40348 <literallayout class="monospaced">
40349 command = /some/path ${if eq{$local_part}{postmaster}{xx}{yy}}
40350 </literallayout>
40351 <para>
40352 will not work, because the expansion item gets split between several
40353 arguments. You have to write
40354 </para>
40355 <literallayout class="monospaced">
40356 command = /some/path "${if eq{$local_part}{postmaster}{xx}{yy}}"
40357 </literallayout>
40358 <para>
40359 to ensure that it is all in one argument. The expansion is done in this way,
40360 argument by argument, so that the number of arguments cannot be changed as a
40361 result of expansion, and quotes or backslashes in inserted variables do not
40362 interact with external quoting. However, this leads to problems if you want to
40363 generate multiple arguments (or the command name plus arguments) from a single
40364 expansion. In this situation, the simplest solution is to use a shell. For
40365 example:
40366 </para>
40367 <literallayout class="monospaced">
40368 command = /bin/sh -c ${lookup{$local_part}lsearch{/some/file}}
40369 </literallayout>
40370 <para>
40371 <indexterm role="concept">
40372 <primary>transport</primary>
40373 <secondary>filter</secondary>
40374 </indexterm>
40375 <indexterm role="concept">
40376 <primary>filter</primary>
40377 <secondary>transport filter</secondary>
40378 </indexterm>
40379 <indexterm role="variable">
40380 <primary><varname>$pipe_addresses</varname></primary>
40381 </indexterm>
40382 Special handling takes place when an argument consists of precisely the text
40383 <literal>$pipe_addresses</literal>. This is not a general expansion variable; the only
40384 place this string is recognized is when it appears as an argument for a pipe or
40385 transport filter command. It causes each address that is being handled to be
40386 inserted in the argument list at that point <emphasis>as a separate argument</emphasis>. This
40387 avoids any problems with spaces or shell metacharacters, and is of use when a
40388 <command>pipe</command> transport is handling groups of addresses in a batch.
40389 </para>
40390 <para>
40391 After splitting up into arguments and expansion, the resulting command is run
40392 in a subprocess directly from the transport, <emphasis>not</emphasis> under a shell. The
40393 message that is being delivered is supplied on the standard input, and the
40394 standard output and standard error are both connected to a single pipe that is
40395 read by Exim. The <option>max_output</option> option controls how much output the command
40396 may produce, and the <option>return_output</option> and <option>return_fail_output</option> options
40397 control what is done with it.
40398 </para>
40399 <para>
40400 Not running the command under a shell (by default) lessens the security risks
40401 in cases when a command from a user&#x2019;s filter file is built out of data that was
40402 taken from an incoming message. If a shell is required, it can of course be
40403 explicitly specified as the command to be run. However, there are circumstances
40404 where existing commands (for example, in <filename>.forward</filename> files) expect to be run
40405 under a shell and cannot easily be modified. To allow for these cases, there is
40406 an option called <option>use_shell</option>, which changes the way the <command>pipe</command> transport
40407 works. Instead of breaking up the command line as just described, it expands it
40408 as a single string and passes the result to <filename>/bin/sh</filename>. The
40409 <option>restrict_to_path</option> option and the <varname>$pipe_addresses</varname> facility cannot be used
40410 with <option>use_shell</option>, and the whole mechanism is inherently less secure.
40411 </para>
40412 </section>
40413 <section id="SECTpipeenv">
40414 <title>Environment variables</title>
40415 <para>
40416 <indexterm role="concept">
40417 <primary><command>pipe</command> transport</primary>
40418 <secondary>environment for command</secondary>
40419 </indexterm>
40420 <indexterm role="concept">
40421 <primary>environment for pipe transport</primary>
40422 </indexterm>
40423 The environment variables listed below are set up when the command is invoked.
40424 This list is a compromise for maximum compatibility with other MTAs. Note that
40425 the <option>environment</option> option can be used to add additional variables to this
40426 environment.
40427 </para>
40428 <literallayout>
40429 <literal>DOMAIN            </literal>   the domain of the address
40430 <literal>HOME              </literal>   the home directory, if set
40431 <literal>HOST              </literal>   the host name when called from a router (see below)
40432 <literal>LOCAL_PART        </literal>   see below
40433 <literal>LOCAL_PART_PREFIX </literal>   see below
40434 <literal>LOCAL_PART_SUFFIX </literal>   see below
40435 <literal>LOGNAME           </literal>   see below
40436 <literal>MESSAGE_ID        </literal>   Exim&#x2019;s local ID for the message
40437 <literal>PATH              </literal>   as specified by the <option>path</option> option below
40438 <literal>QUALIFY_DOMAIN    </literal>   the sender qualification domain
40439 <literal>RECIPIENT         </literal>   the complete recipient address
40440 <literal>SENDER            </literal>   the sender of the message (empty if a bounce)
40441 <literal>SHELL             </literal>   <literal>/bin/sh</literal>
40442 <literal>TZ                </literal>   the value of the <option>timezone</option> option, if set
40443 <literal>USER              </literal>   see below
40444 </literallayout>
40445 <para>
40446 When a <command>pipe</command> transport is called directly from (for example) an <command>accept</command>
40447 router, LOCAL_PART is set to the local part of the address. When it is
40448 called as a result of a forward or alias expansion, LOCAL_PART is set to
40449 the local part of the address that was expanded. In both cases, any affixes are
40450 removed from the local part, and made available in LOCAL_PART_PREFIX and
40451 LOCAL_PART_SUFFIX, respectively. LOGNAME and USER are set to the
40452 same value as LOCAL_PART for compatibility with other MTAs.
40453 </para>
40454 <para>
40455 <indexterm role="concept">
40456 <primary>HOST</primary>
40457 </indexterm>
40458 HOST is set only when a <command>pipe</command> transport is called from a router that
40459 associates hosts with an address, typically when using <command>pipe</command> as a
40460 pseudo-remote transport. HOST is set to the first host name specified by
40461 the router.
40462 </para>
40463 <para>
40464 <indexterm role="concept">
40465 <primary>HOME</primary>
40466 </indexterm>
40467 If the transport&#x2019;s generic <option>home_directory</option> option is set, its value is used
40468 for the HOME environment variable. Otherwise, a home directory may be set
40469 by the router&#x2019;s <option>transport_home_directory</option> option, which defaults to the
40470 user&#x2019;s home directory if <option>check_local_user</option> is set.
40471 </para>
40472 </section>
40473 <section id="SECID142">
40474 <title>Private options for pipe</title>
40475 <para>
40476 <indexterm role="concept">
40477 <primary>options</primary>
40478 <secondary><command>pipe</command> transport</secondary>
40479 </indexterm>
40480 </para>
40481 <para>
40482 <indexterm role="option">
40483 <primary><option>allow_commands</option></primary>
40484 </indexterm>
40485 </para>
40486 <informaltable frame="all">
40487 <tgroup cols="4" colsep="0" rowsep="0">
40488 <colspec colwidth="8*" align="left"/>
40489 <colspec colwidth="6*" align="center"/>
40490 <colspec colwidth="6*" align="center"/>
40491 <colspec colwidth="6*" align="right"/>
40492 <tbody>
40493 <row>
40494 <entry><option>allow_commands</option></entry>
40495 <entry>Use: <emphasis>pipe</emphasis></entry>
40496 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
40497 <entry>Default: <emphasis>unset</emphasis></entry>
40498 </row>
40499 </tbody>
40500 </tgroup>
40501 </informaltable>
40502 <para>
40503 <indexterm role="concept">
40504 <primary><command>pipe</command> transport</primary>
40505 <secondary>permitted commands</secondary>
40506 </indexterm>
40507 The string is expanded, and is then interpreted as a colon-separated list of
40508 permitted commands. If <option>restrict_to_path</option> is not set, the only commands
40509 permitted are those in the <option>allow_commands</option> list. They need not be absolute
40510 paths; the <option>path</option> option is still used for relative paths. If
40511 <option>restrict_to_path</option> is set with <option>allow_commands</option>, the command must either be
40512 in the <option>allow_commands</option> list, or a name without any slashes that is found on
40513 the path. In other words, if neither <option>allow_commands</option> nor
40514 <option>restrict_to_path</option> is set, there is no restriction on the command, but
40515 otherwise only commands that are permitted by one or the other are allowed. For
40516 example, if
40517 </para>
40518 <literallayout class="monospaced">
40519 allow_commands = /usr/bin/vacation
40520 </literallayout>
40521 <para>
40522 and <option>restrict_to_path</option> is not set, the only permitted command is
40523 <filename>/usr/bin/vacation</filename>. The <option>allow_commands</option> option may not be set if
40524 <option>use_shell</option> is set.
40525 </para>
40526 <para>
40527 <indexterm role="option">
40528 <primary><option>batch_id</option></primary>
40529 </indexterm>
40530 </para>
40531 <informaltable frame="all">
40532 <tgroup cols="4" colsep="0" rowsep="0">
40533 <colspec colwidth="8*" align="left"/>
40534 <colspec colwidth="6*" align="center"/>
40535 <colspec colwidth="6*" align="center"/>
40536 <colspec colwidth="6*" align="right"/>
40537 <tbody>
40538 <row>
40539 <entry><option>batch_id</option></entry>
40540 <entry>Use: <emphasis>pipe</emphasis></entry>
40541 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40542 <entry>Default: <emphasis>unset</emphasis></entry>
40543 </row>
40544 </tbody>
40545 </tgroup>
40546 </informaltable>
40547 <para>
40548 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
40549 </para>
40550 <para>
40551 <indexterm role="option">
40552 <primary><option>batch_max</option></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="6*" align="center"/>
40559 <colspec colwidth="6*" align="center"/>
40560 <colspec colwidth="6*" align="right"/>
40561 <tbody>
40562 <row>
40563 <entry><option>batch_max</option></entry>
40564 <entry>Use: <emphasis>pipe</emphasis></entry>
40565 <entry>Type: <emphasis>integer</emphasis></entry>
40566 <entry>Default: <emphasis>1</emphasis></entry>
40567 </row>
40568 </tbody>
40569 </tgroup>
40570 </informaltable>
40571 <para>
40572 This limits the number of addresses that can be handled in a single delivery.
40573 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
40574 </para>
40575 <para>
40576 <indexterm role="option">
40577 <primary><option>check_string</option></primary>
40578 </indexterm>
40579 </para>
40580 <informaltable frame="all">
40581 <tgroup cols="4" colsep="0" rowsep="0">
40582 <colspec colwidth="8*" align="left"/>
40583 <colspec colwidth="6*" align="center"/>
40584 <colspec colwidth="6*" align="center"/>
40585 <colspec colwidth="6*" align="right"/>
40586 <tbody>
40587 <row>
40588 <entry><option>check_string</option></entry>
40589 <entry>Use: <emphasis>pipe</emphasis></entry>
40590 <entry>Type: <emphasis>string</emphasis></entry>
40591 <entry>Default: <emphasis>unset</emphasis></entry>
40592 </row>
40593 </tbody>
40594 </tgroup>
40595 </informaltable>
40596 <para>
40597 As <command>pipe</command> writes the message, the start of each line is tested for matching
40598 <option>check_string</option>, and if it does, the initial matching characters are replaced
40599 by the contents of <option>escape_string</option>, provided both are set. The value of
40600 <option>check_string</option> is a literal string, not a regular expression, and the case of
40601 any letters it contains is significant. When <option>use_bsmtp</option> is set, the contents
40602 of <option>check_string</option> and <option>escape_string</option> are forced to values that implement
40603 the SMTP escaping protocol. Any settings made in the configuration file are
40604 ignored.
40605 </para>
40606 <para>
40607 <indexterm role="option">
40608 <primary><option>command</option></primary>
40609 </indexterm>
40610 </para>
40611 <informaltable frame="all">
40612 <tgroup cols="4" colsep="0" rowsep="0">
40613 <colspec colwidth="8*" align="left"/>
40614 <colspec colwidth="6*" align="center"/>
40615 <colspec colwidth="6*" align="center"/>
40616 <colspec colwidth="6*" align="right"/>
40617 <tbody>
40618 <row>
40619 <entry><option>command</option></entry>
40620 <entry>Use: <emphasis>pipe</emphasis></entry>
40621 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40622 <entry>Default: <emphasis>unset</emphasis></entry>
40623 </row>
40624 </tbody>
40625 </tgroup>
40626 </informaltable>
40627 <para>
40628 This option need not be set when <command>pipe</command> is being used to deliver to pipes
40629 obtained directly from address redirections. In other cases, the option must be
40630 set, to provide a command to be run. It need not yield an absolute path (see
40631 the <option>path</option> option below). The command is split up into separate arguments by
40632 Exim, and each argument is separately expanded, as described in section
40633 <xref linkend="SECThowcommandrun"/> above.
40634 </para>
40635 <para>
40636 <indexterm role="option">
40637 <primary><option>environment</option></primary>
40638 </indexterm>
40639 </para>
40640 <informaltable frame="all">
40641 <tgroup cols="4" colsep="0" rowsep="0">
40642 <colspec colwidth="8*" align="left"/>
40643 <colspec colwidth="6*" align="center"/>
40644 <colspec colwidth="6*" align="center"/>
40645 <colspec colwidth="6*" align="right"/>
40646 <tbody>
40647 <row>
40648 <entry><option>environment</option></entry>
40649 <entry>Use: <emphasis>pipe</emphasis></entry>
40650 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40651 <entry>Default: <emphasis>unset</emphasis></entry>
40652 </row>
40653 </tbody>
40654 </tgroup>
40655 </informaltable>
40656 <para>
40657 <indexterm role="concept">
40658 <primary><command>pipe</command> transport</primary>
40659 <secondary>environment for command</secondary>
40660 </indexterm>
40661 <indexterm role="concept">
40662 <primary>environment for <command>pipe</command> transport</primary>
40663 </indexterm>
40664 This option is used to add additional variables to the environment in which the
40665 command runs (see section <xref linkend="SECTpipeenv"/> for the default list). Its value is
40666 a string which is expanded, and then interpreted as a colon-separated list of
40667 environment settings of the form &lt;<emphasis>name</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt;.
40668 </para>
40669 <para>
40670 <indexterm role="option">
40671 <primary><option>escape_string</option></primary>
40672 </indexterm>
40673 </para>
40674 <informaltable frame="all">
40675 <tgroup cols="4" colsep="0" rowsep="0">
40676 <colspec colwidth="8*" align="left"/>
40677 <colspec colwidth="6*" align="center"/>
40678 <colspec colwidth="6*" align="center"/>
40679 <colspec colwidth="6*" align="right"/>
40680 <tbody>
40681 <row>
40682 <entry><option>escape_string</option></entry>
40683 <entry>Use: <emphasis>pipe</emphasis></entry>
40684 <entry>Type: <emphasis>string</emphasis></entry>
40685 <entry>Default: <emphasis>unset</emphasis></entry>
40686 </row>
40687 </tbody>
40688 </tgroup>
40689 </informaltable>
40690 <para>
40691 See <option>check_string</option> above.
40692 </para>
40693 <para>
40694 <indexterm role="option">
40695 <primary><option>freeze_exec_fail</option></primary>
40696 </indexterm>
40697 </para>
40698 <informaltable frame="all">
40699 <tgroup cols="4" colsep="0" rowsep="0">
40700 <colspec colwidth="8*" align="left"/>
40701 <colspec colwidth="6*" align="center"/>
40702 <colspec colwidth="6*" align="center"/>
40703 <colspec colwidth="6*" align="right"/>
40704 <tbody>
40705 <row>
40706 <entry><option>freeze_exec_fail</option></entry>
40707 <entry>Use: <emphasis>pipe</emphasis></entry>
40708 <entry>Type: <emphasis>boolean</emphasis></entry>
40709 <entry>Default: <emphasis>false</emphasis></entry>
40710 </row>
40711 </tbody>
40712 </tgroup>
40713 </informaltable>
40714 <para>
40715 <indexterm role="concept">
40716 <primary>exec failure</primary>
40717 </indexterm>
40718 <indexterm role="concept">
40719 <primary>failure of exec</primary>
40720 </indexterm>
40721 <indexterm role="concept">
40722 <primary><command>pipe</command> transport</primary>
40723 <secondary>failure of exec</secondary>
40724 </indexterm>
40725 Failure to exec the command in a pipe transport is by default treated like
40726 any other failure while running the command. However, if <option>freeze_exec_fail</option>
40727 is set, failure to exec is treated specially, and causes the message to be
40728 frozen, whatever the setting of <option>ignore_status</option>.
40729 </para>
40730 <para>
40731 <indexterm role="option">
40732 <primary><option>ignore_status</option></primary>
40733 </indexterm>
40734 </para>
40735 <informaltable frame="all">
40736 <tgroup cols="4" colsep="0" rowsep="0">
40737 <colspec colwidth="8*" align="left"/>
40738 <colspec colwidth="6*" align="center"/>
40739 <colspec colwidth="6*" align="center"/>
40740 <colspec colwidth="6*" align="right"/>
40741 <tbody>
40742 <row>
40743 <entry><option>ignore_status</option></entry>
40744 <entry>Use: <emphasis>pipe</emphasis></entry>
40745 <entry>Type: <emphasis>boolean</emphasis></entry>
40746 <entry>Default: <emphasis>false</emphasis></entry>
40747 </row>
40748 </tbody>
40749 </tgroup>
40750 </informaltable>
40751 <para>
40752 If this option is true, the status returned by the subprocess that is set up to
40753 run the command is ignored, and Exim behaves as if zero had been returned.
40754 Otherwise, a non-zero status or termination by signal causes an error return
40755 from the transport unless the status value is one of those listed in
40756 <option>temp_errors</option>; these cause the delivery to be deferred and tried again later.
40757 </para>
40758 <para>
40759 <emphasis role="bold">Note</emphasis>: This option does not apply to timeouts, which do not return a status.
40760 See the <option>timeout_defer</option> option for how timeouts are handled.
40761 </para>
40762 <para>
40763 <indexterm role="option">
40764 <primary><option>log_defer_output</option></primary>
40765 </indexterm>
40766 </para>
40767 <informaltable frame="all">
40768 <tgroup cols="4" colsep="0" rowsep="0">
40769 <colspec colwidth="8*" align="left"/>
40770 <colspec colwidth="6*" align="center"/>
40771 <colspec colwidth="6*" align="center"/>
40772 <colspec colwidth="6*" align="right"/>
40773 <tbody>
40774 <row>
40775 <entry><option>log_defer_output</option></entry>
40776 <entry>Use: <emphasis>pipe</emphasis></entry>
40777 <entry>Type: <emphasis>boolean</emphasis></entry>
40778 <entry>Default: <emphasis>false</emphasis></entry>
40779 </row>
40780 </tbody>
40781 </tgroup>
40782 </informaltable>
40783 <para>
40784 <indexterm role="concept">
40785 <primary><command>pipe</command> transport</primary>
40786 <secondary>logging output</secondary>
40787 </indexterm>
40788 If this option is set, and the status returned by the command is
40789 one of the codes listed in <option>temp_errors</option> (that is, delivery was deferred),
40790 and any output was produced, the first line of it is written to the main log.
40791 </para>
40792 <para>
40793 <indexterm role="option">
40794 <primary><option>log_fail_output</option></primary>
40795 </indexterm>
40796 </para>
40797 <informaltable frame="all">
40798 <tgroup cols="4" colsep="0" rowsep="0">
40799 <colspec colwidth="8*" align="left"/>
40800 <colspec colwidth="6*" align="center"/>
40801 <colspec colwidth="6*" align="center"/>
40802 <colspec colwidth="6*" align="right"/>
40803 <tbody>
40804 <row>
40805 <entry><option>log_fail_output</option></entry>
40806 <entry>Use: <emphasis>pipe</emphasis></entry>
40807 <entry>Type: <emphasis>boolean</emphasis></entry>
40808 <entry>Default: <emphasis>false</emphasis></entry>
40809 </row>
40810 </tbody>
40811 </tgroup>
40812 </informaltable>
40813 <para>
40814 If this option is set, and the command returns any output, and also ends with a
40815 return code that is neither zero nor one of the return codes listed in
40816 <option>temp_errors</option> (that is, the delivery failed), the first line of output is
40817 written to the main log. This option and <option>log_output</option> are mutually exclusive.
40818 Only one of them may be set.
40819 </para>
40820 <para>
40821 <indexterm role="option">
40822 <primary><option>log_output</option></primary>
40823 </indexterm>
40824 </para>
40825 <informaltable frame="all">
40826 <tgroup cols="4" colsep="0" rowsep="0">
40827 <colspec colwidth="8*" align="left"/>
40828 <colspec colwidth="6*" align="center"/>
40829 <colspec colwidth="6*" align="center"/>
40830 <colspec colwidth="6*" align="right"/>
40831 <tbody>
40832 <row>
40833 <entry><option>log_output</option></entry>
40834 <entry>Use: <emphasis>pipe</emphasis></entry>
40835 <entry>Type: <emphasis>boolean</emphasis></entry>
40836 <entry>Default: <emphasis>false</emphasis></entry>
40837 </row>
40838 </tbody>
40839 </tgroup>
40840 </informaltable>
40841 <para>
40842 If this option is set and the command returns any output, the first line of
40843 output is written to the main log, whatever the return code. This option and
40844 <option>log_fail_output</option> are mutually exclusive. Only one of them may be set.
40845 </para>
40846 <para>
40847 <indexterm role="option">
40848 <primary><option>max_output</option></primary>
40849 </indexterm>
40850 </para>
40851 <informaltable frame="all">
40852 <tgroup cols="4" colsep="0" rowsep="0">
40853 <colspec colwidth="8*" align="left"/>
40854 <colspec colwidth="6*" align="center"/>
40855 <colspec colwidth="6*" align="center"/>
40856 <colspec colwidth="6*" align="right"/>
40857 <tbody>
40858 <row>
40859 <entry><option>max_output</option></entry>
40860 <entry>Use: <emphasis>pipe</emphasis></entry>
40861 <entry>Type: <emphasis>integer</emphasis></entry>
40862 <entry>Default: <emphasis>20K</emphasis></entry>
40863 </row>
40864 </tbody>
40865 </tgroup>
40866 </informaltable>
40867 <para>
40868 This specifies the maximum amount of output that the command may produce on its
40869 standard output and standard error file combined. If the limit is exceeded, the
40870 process running the command is killed. This is intended as a safety measure to
40871 catch runaway processes. The limit is applied independently of the settings of
40872 the options that control what is done with such output (for example,
40873 <option>return_output</option>). Because of buffering effects, the amount of output may
40874 exceed the limit by a small amount before Exim notices.
40875 </para>
40876 <para>
40877 <indexterm role="option">
40878 <primary><option>message_prefix</option></primary>
40879 </indexterm>
40880 </para>
40881 <informaltable frame="all">
40882 <tgroup cols="4" colsep="0" rowsep="0">
40883 <colspec colwidth="8*" align="left"/>
40884 <colspec colwidth="6*" align="center"/>
40885 <colspec colwidth="6*" align="center"/>
40886 <colspec colwidth="6*" align="right"/>
40887 <tbody>
40888 <row>
40889 <entry><option>message_prefix</option></entry>
40890 <entry>Use: <emphasis>pipe</emphasis></entry>
40891 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40892 <entry>Default: <emphasis>see below</emphasis></entry>
40893 </row>
40894 </tbody>
40895 </tgroup>
40896 </informaltable>
40897 <para>
40898 The string specified here is expanded and output at the start of every message.
40899 The default is unset if <option>use_bsmtp</option> is set. Otherwise it is
40900 </para>
40901 <literallayout class="monospaced">
40902 message_prefix = \
40903   From ${if def:return_path{$return_path}{MAILER-DAEMON}}\
40904   ${tod_bsdinbox}\n
40905 </literallayout>
40906 <para>
40907 <indexterm role="concept">
40908 <primary>Cyrus</primary>
40909 </indexterm>
40910 <indexterm role="concept">
40911 <primary><option>tmail</option></primary>
40912 </indexterm>
40913 <indexterm role="concept">
40914 <primary><quote>From</quote> line</primary>
40915 </indexterm>
40916 This is required by the commonly used <filename>/usr/bin/vacation</filename> program.
40917 However, it must <emphasis>not</emphasis> be present if delivery is to the Cyrus IMAP server,
40918 or to the <option>tmail</option> local delivery agent. The prefix can be suppressed by
40919 setting
40920 </para>
40921 <literallayout class="monospaced">
40922 message_prefix =
40923 </literallayout>
40924 <para>
40925 <emphasis role="bold">Note:</emphasis> If you set <option>use_crlf</option> true, you must change any occurrences of
40926 <literal>\n</literal> to <literal>\r\n</literal> in <option>message_prefix</option>.
40927 </para>
40928 <para>
40929 <indexterm role="option">
40930 <primary><option>message_suffix</option></primary>
40931 </indexterm>
40932 </para>
40933 <informaltable frame="all">
40934 <tgroup cols="4" colsep="0" rowsep="0">
40935 <colspec colwidth="8*" align="left"/>
40936 <colspec colwidth="6*" align="center"/>
40937 <colspec colwidth="6*" align="center"/>
40938 <colspec colwidth="6*" align="right"/>
40939 <tbody>
40940 <row>
40941 <entry><option>message_suffix</option></entry>
40942 <entry>Use: <emphasis>pipe</emphasis></entry>
40943 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40944 <entry>Default: <emphasis>see below</emphasis></entry>
40945 </row>
40946 </tbody>
40947 </tgroup>
40948 </informaltable>
40949 <para>
40950 The string specified here is expanded and output at the end of every message.
40951 The default is unset if <option>use_bsmtp</option> is set. Otherwise it is a single newline.
40952 The suffix can be suppressed by setting
40953 </para>
40954 <literallayout class="monospaced">
40955 message_suffix =
40956 </literallayout>
40957 <para>
40958 <emphasis role="bold">Note:</emphasis> If you set <option>use_crlf</option> true, you must change any occurrences of
40959 <literal>\n</literal> to <literal>\r\n</literal> in <option>message_suffix</option>.
40960 </para>
40961 <para>
40962 <indexterm role="option">
40963 <primary><option>path</option></primary>
40964 </indexterm>
40965 </para>
40966 <informaltable frame="all">
40967 <tgroup cols="4" colsep="0" rowsep="0">
40968 <colspec colwidth="8*" align="left"/>
40969 <colspec colwidth="6*" align="center"/>
40970 <colspec colwidth="6*" align="center"/>
40971 <colspec colwidth="6*" align="right"/>
40972 <tbody>
40973 <row>
40974 <entry><option>path</option></entry>
40975 <entry>Use: <emphasis>pipe</emphasis></entry>
40976 <entry>Type: <emphasis>string</emphasis></entry>
40977 <entry>Default: <emphasis>see below</emphasis></entry>
40978 </row>
40979 </tbody>
40980 </tgroup>
40981 </informaltable>
40982 <para>
40983 This option specifies the string that is set up in the PATH environment
40984 variable of the subprocess. The default is:
40985 </para>
40986 <literallayout class="monospaced">
40987 /bin:/usr/bin
40988 </literallayout>
40989 <para>
40990 If the <option>command</option> option does not yield an absolute path name, the command is
40991 sought in the PATH directories, in the usual way. <emphasis role="bold">Warning</emphasis>: This does not
40992 apply to a command specified as a transport filter.
40993 </para>
40994 <para revisionflag="changed">
40995 <indexterm role="option">
40996 <primary><option>permit_coredump</option></primary>
40997 </indexterm>
40998 </para>
40999 <informaltable frame="all" revisionflag="changed">
41000 <tgroup cols="4" colsep="0" rowsep="0">
41001 <colspec colwidth="8*" align="left"/>
41002 <colspec colwidth="6*" align="center"/>
41003 <colspec colwidth="6*" align="center"/>
41004 <colspec colwidth="6*" align="right"/>
41005 <tbody>
41006 <row>
41007 <entry><option>permit_coredump</option></entry>
41008 <entry>Use: <emphasis>pipe</emphasis></entry>
41009 <entry>Type: <emphasis>boolean</emphasis></entry>
41010 <entry>Default: <emphasis>false</emphasis></entry>
41011 </row>
41012 </tbody>
41013 </tgroup>
41014 </informaltable>
41015 <para revisionflag="changed">
41016 Normally Exim inhibits core-dumps during delivery.  If you have a need to get
41017 a core-dump of a pipe command, enable this command.  This enables core-dumps
41018 during delivery and affects both the Exim binary and the pipe command run.
41019 It is recommended that this option remain off unless and until you have a need
41020 for it and that this only be enabled when needed, as the risk of excessive
41021 resource consumption can be quite high.  Note also that Exim is typically
41022 installed as a setuid binary and most operating systems will inhibit coredumps
41023 of these by default, so further OS-specific action may be required.
41024 </para>
41025 <para>
41026 <indexterm role="option">
41027 <primary><option>pipe_as_creator</option></primary>
41028 </indexterm>
41029 </para>
41030 <informaltable frame="all">
41031 <tgroup cols="4" colsep="0" rowsep="0">
41032 <colspec colwidth="8*" align="left"/>
41033 <colspec colwidth="6*" align="center"/>
41034 <colspec colwidth="6*" align="center"/>
41035 <colspec colwidth="6*" align="right"/>
41036 <tbody>
41037 <row>
41038 <entry><option>pipe_as_creator</option></entry>
41039 <entry>Use: <emphasis>pipe</emphasis></entry>
41040 <entry>Type: <emphasis>boolean</emphasis></entry>
41041 <entry>Default: <emphasis>false</emphasis></entry>
41042 </row>
41043 </tbody>
41044 </tgroup>
41045 </informaltable>
41046 <para>
41047 <indexterm role="concept">
41048 <primary>uid (user id)</primary>
41049 <secondary>local delivery</secondary>
41050 </indexterm>
41051 If the generic <option>user</option> option is not set and this option is true, the delivery
41052 process is run under the uid that was in force when Exim was originally called
41053 to accept the message. If the group id is not otherwise set (via the generic
41054 <option>group</option> option), the gid that was in force when Exim was originally called to
41055 accept the message is used.
41056 </para>
41057 <para>
41058 <indexterm role="option">
41059 <primary><option>restrict_to_path</option></primary>
41060 </indexterm>
41061 </para>
41062 <informaltable frame="all">
41063 <tgroup cols="4" colsep="0" rowsep="0">
41064 <colspec colwidth="8*" align="left"/>
41065 <colspec colwidth="6*" align="center"/>
41066 <colspec colwidth="6*" align="center"/>
41067 <colspec colwidth="6*" align="right"/>
41068 <tbody>
41069 <row>
41070 <entry><option>restrict_to_path</option></entry>
41071 <entry>Use: <emphasis>pipe</emphasis></entry>
41072 <entry>Type: <emphasis>boolean</emphasis></entry>
41073 <entry>Default: <emphasis>false</emphasis></entry>
41074 </row>
41075 </tbody>
41076 </tgroup>
41077 </informaltable>
41078 <para>
41079 When this option is set, any command name not listed in <option>allow_commands</option> must
41080 contain no slashes. The command is searched for only in the directories listed
41081 in the <option>path</option> option. This option is intended for use in the case when a pipe
41082 command has been generated from a user&#x2019;s <filename>.forward</filename> file. This is usually
41083 handled by a <command>pipe</command> transport called <option>address_pipe</option>.
41084 </para>
41085 <para>
41086 <indexterm role="option">
41087 <primary><option>return_fail_output</option></primary>
41088 </indexterm>
41089 </para>
41090 <informaltable frame="all">
41091 <tgroup cols="4" colsep="0" rowsep="0">
41092 <colspec colwidth="8*" align="left"/>
41093 <colspec colwidth="6*" align="center"/>
41094 <colspec colwidth="6*" align="center"/>
41095 <colspec colwidth="6*" align="right"/>
41096 <tbody>
41097 <row>
41098 <entry><option>return_fail_output</option></entry>
41099 <entry>Use: <emphasis>pipe</emphasis></entry>
41100 <entry>Type: <emphasis>boolean</emphasis></entry>
41101 <entry>Default: <emphasis>false</emphasis></entry>
41102 </row>
41103 </tbody>
41104 </tgroup>
41105 </informaltable>
41106 <para>
41107 If this option is true, and the command produced any output and ended with a
41108 return code other than zero or one of the codes listed in <option>temp_errors</option> (that
41109 is, the delivery failed), the output is returned in the bounce message.
41110 However, if the message has a null sender (that is, it is itself a bounce
41111 message), output from the command is discarded. This option and
41112 <option>return_output</option> are mutually exclusive. Only one of them may be set.
41113 </para>
41114 <para>
41115 <indexterm role="option">
41116 <primary><option>return_output</option></primary>
41117 </indexterm>
41118 </para>
41119 <informaltable frame="all">
41120 <tgroup cols="4" colsep="0" rowsep="0">
41121 <colspec colwidth="8*" align="left"/>
41122 <colspec colwidth="6*" align="center"/>
41123 <colspec colwidth="6*" align="center"/>
41124 <colspec colwidth="6*" align="right"/>
41125 <tbody>
41126 <row>
41127 <entry><option>return_output</option></entry>
41128 <entry>Use: <emphasis>pipe</emphasis></entry>
41129 <entry>Type: <emphasis>boolean</emphasis></entry>
41130 <entry>Default: <emphasis>false</emphasis></entry>
41131 </row>
41132 </tbody>
41133 </tgroup>
41134 </informaltable>
41135 <para>
41136 If this option is true, and the command produced any output, the delivery is
41137 deemed to have failed whatever the return code from the command, and the output
41138 is returned in the bounce message. Otherwise, the output is just discarded.
41139 However, if the message has a null sender (that is, it is a bounce message),
41140 output from the command is always discarded, whatever the setting of this
41141 option. This option and <option>return_fail_output</option> are mutually exclusive. Only one
41142 of them may be set.
41143 </para>
41144 <para>
41145 <indexterm role="option">
41146 <primary><option>temp_errors</option></primary>
41147 </indexterm>
41148 </para>
41149 <informaltable frame="all">
41150 <tgroup cols="4" colsep="0" rowsep="0">
41151 <colspec colwidth="8*" align="left"/>
41152 <colspec colwidth="6*" align="center"/>
41153 <colspec colwidth="6*" align="center"/>
41154 <colspec colwidth="6*" align="right"/>
41155 <tbody>
41156 <row>
41157 <entry><option>temp_errors</option></entry>
41158 <entry>Use: <emphasis>pipe</emphasis></entry>
41159 <entry>Type: <emphasis>string list</emphasis></entry>
41160 <entry>Default: <emphasis>see below</emphasis></entry>
41161 </row>
41162 </tbody>
41163 </tgroup>
41164 </informaltable>
41165 <para>
41166 <indexterm role="concept">
41167 <primary><command>pipe</command> transport</primary>
41168 <secondary>temporary failure</secondary>
41169 </indexterm>
41170 This option contains either a colon-separated list of numbers, or a single
41171 asterisk. If <option>ignore_status</option> is false
41172 and <option>return_output</option> is not set,
41173 and the command exits with a non-zero return code, the failure is treated as
41174 temporary and the delivery is deferred if the return code matches one of the
41175 numbers, or if the setting is a single asterisk. Otherwise, non-zero return
41176 codes are treated as permanent errors. The default setting contains the codes
41177 defined by EX_TEMPFAIL and EX_CANTCREAT in <filename>sysexits.h</filename>. If Exim is
41178 compiled on a system that does not define these macros, it assumes values of 75
41179 and 73, respectively.
41180 </para>
41181 <para>
41182 <indexterm role="option">
41183 <primary><option>timeout</option></primary>
41184 </indexterm>
41185 </para>
41186 <informaltable frame="all">
41187 <tgroup cols="4" colsep="0" rowsep="0">
41188 <colspec colwidth="8*" align="left"/>
41189 <colspec colwidth="6*" align="center"/>
41190 <colspec colwidth="6*" align="center"/>
41191 <colspec colwidth="6*" align="right"/>
41192 <tbody>
41193 <row>
41194 <entry><option>timeout</option></entry>
41195 <entry>Use: <emphasis>pipe</emphasis></entry>
41196 <entry>Type: <emphasis>time</emphasis></entry>
41197 <entry>Default: <emphasis>1h</emphasis></entry>
41198 </row>
41199 </tbody>
41200 </tgroup>
41201 </informaltable>
41202 <para>
41203 If the command fails to complete within this time, it is killed. This normally
41204 causes the delivery to fail (but see <option>timeout_defer</option>). A zero time interval
41205 specifies no timeout. In order to ensure that any subprocesses created by the
41206 command are also killed, Exim makes the initial process a process group leader,
41207 and kills the whole process group on a timeout. However, this can be defeated
41208 if one of the processes starts a new process group.
41209 </para>
41210 <para>
41211 <indexterm role="option">
41212 <primary><option>timeout_defer</option></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="6*" align="center"/>
41219 <colspec colwidth="6*" align="center"/>
41220 <colspec colwidth="6*" align="right"/>
41221 <tbody>
41222 <row>
41223 <entry><option>timeout_defer</option></entry>
41224 <entry>Use: <emphasis>pipe</emphasis></entry>
41225 <entry>Type: <emphasis>boolean</emphasis></entry>
41226 <entry>Default: <emphasis>false</emphasis></entry>
41227 </row>
41228 </tbody>
41229 </tgroup>
41230 </informaltable>
41231 <para>
41232 A timeout in a <command>pipe</command> transport, either in the command that the transport
41233 runs, or in a transport filter that is associated with it, is by default
41234 treated as a hard error, and the delivery fails. However, if <option>timeout_defer</option>
41235 is set true, both kinds of timeout become temporary errors, causing the
41236 delivery to be deferred.
41237 </para>
41238 <para>
41239 <indexterm role="option">
41240 <primary><option>umask</option></primary>
41241 </indexterm>
41242 </para>
41243 <informaltable frame="all">
41244 <tgroup cols="4" colsep="0" rowsep="0">
41245 <colspec colwidth="8*" align="left"/>
41246 <colspec colwidth="6*" align="center"/>
41247 <colspec colwidth="6*" align="center"/>
41248 <colspec colwidth="6*" align="right"/>
41249 <tbody>
41250 <row>
41251 <entry><option>umask</option></entry>
41252 <entry>Use: <emphasis>pipe</emphasis></entry>
41253 <entry>Type: <emphasis>octal integer</emphasis></entry>
41254 <entry>Default: <emphasis>022</emphasis></entry>
41255 </row>
41256 </tbody>
41257 </tgroup>
41258 </informaltable>
41259 <para>
41260 This specifies the umask setting for the subprocess that runs the command.
41261 </para>
41262 <para>
41263 <indexterm role="option">
41264 <primary><option>use_bsmtp</option></primary>
41265 </indexterm>
41266 </para>
41267 <informaltable frame="all">
41268 <tgroup cols="4" colsep="0" rowsep="0">
41269 <colspec colwidth="8*" align="left"/>
41270 <colspec colwidth="6*" align="center"/>
41271 <colspec colwidth="6*" align="center"/>
41272 <colspec colwidth="6*" align="right"/>
41273 <tbody>
41274 <row>
41275 <entry><option>use_bsmtp</option></entry>
41276 <entry>Use: <emphasis>pipe</emphasis></entry>
41277 <entry>Type: <emphasis>boolean</emphasis></entry>
41278 <entry>Default: <emphasis>false</emphasis></entry>
41279 </row>
41280 </tbody>
41281 </tgroup>
41282 </informaltable>
41283 <para>
41284 <indexterm role="concept">
41285 <primary>envelope sender</primary>
41286 </indexterm>
41287 If this option is set true, the <command>pipe</command> transport writes messages in <quote>batch
41288 SMTP</quote> format, with the envelope sender and recipient(s) included as SMTP
41289 commands. If you want to include a leading HELO command with such messages,
41290 you can do so by setting the <option>message_prefix</option> option. See section
41291 <xref linkend="SECTbatchSMTP"/> for details of batch SMTP.
41292 </para>
41293 <para>
41294 <indexterm role="option">
41295 <primary><option>use_classresources</option></primary>
41296 </indexterm>
41297 </para>
41298 <informaltable frame="all">
41299 <tgroup cols="4" colsep="0" rowsep="0">
41300 <colspec colwidth="8*" align="left"/>
41301 <colspec colwidth="6*" align="center"/>
41302 <colspec colwidth="6*" align="center"/>
41303 <colspec colwidth="6*" align="right"/>
41304 <tbody>
41305 <row>
41306 <entry><option>use_classresources</option></entry>
41307 <entry>Use: <emphasis>pipe</emphasis></entry>
41308 <entry>Type: <emphasis>boolean</emphasis></entry>
41309 <entry>Default: <emphasis>false</emphasis></entry>
41310 </row>
41311 </tbody>
41312 </tgroup>
41313 </informaltable>
41314 <para>
41315 <indexterm role="concept">
41316 <primary>class resources (BSD)</primary>
41317 </indexterm>
41318 This option is available only when Exim is running on FreeBSD, NetBSD, or
41319 BSD/OS. If it is set true, the <function>setclassresources()</function> function is used to set
41320 resource limits when a <command>pipe</command> transport is run to perform a delivery. The
41321 limits for the uid under which the pipe is to run are obtained from the login
41322 class database.
41323 </para>
41324 <para>
41325 <indexterm role="option">
41326 <primary><option>use_crlf</option></primary>
41327 </indexterm>
41328 </para>
41329 <informaltable frame="all">
41330 <tgroup cols="4" colsep="0" rowsep="0">
41331 <colspec colwidth="8*" align="left"/>
41332 <colspec colwidth="6*" align="center"/>
41333 <colspec colwidth="6*" align="center"/>
41334 <colspec colwidth="6*" align="right"/>
41335 <tbody>
41336 <row>
41337 <entry><option>use_crlf</option></entry>
41338 <entry>Use: <emphasis>pipe</emphasis></entry>
41339 <entry>Type: <emphasis>boolean</emphasis></entry>
41340 <entry>Default: <emphasis>false</emphasis></entry>
41341 </row>
41342 </tbody>
41343 </tgroup>
41344 </informaltable>
41345 <para>
41346 <indexterm role="concept">
41347 <primary>carriage return</primary>
41348 </indexterm>
41349 <indexterm role="concept">
41350 <primary>linefeed</primary>
41351 </indexterm>
41352 This option causes lines to be terminated with the two-character CRLF sequence
41353 (carriage return, linefeed) instead of just a linefeed character. In the case
41354 of batched SMTP, the byte sequence written to the pipe is then an exact image
41355 of what would be sent down a real SMTP connection.
41356 </para>
41357 <para>
41358 The contents of the <option>message_prefix</option> and <option>message_suffix</option> options are
41359 written verbatim, so must contain their own carriage return characters if these
41360 are needed. When <option>use_bsmtp</option> is not set, the default values for both
41361 <option>message_prefix</option> and <option>message_suffix</option> end with a single linefeed, so their
41362 values must be changed to end with <literal>\r\n</literal> if <option>use_crlf</option> is set.
41363 </para>
41364 <para>
41365 <indexterm role="option">
41366 <primary><option>use_shell</option></primary>
41367 </indexterm>
41368 </para>
41369 <informaltable frame="all">
41370 <tgroup cols="4" colsep="0" rowsep="0">
41371 <colspec colwidth="8*" align="left"/>
41372 <colspec colwidth="6*" align="center"/>
41373 <colspec colwidth="6*" align="center"/>
41374 <colspec colwidth="6*" align="right"/>
41375 <tbody>
41376 <row>
41377 <entry><option>use_shell</option></entry>
41378 <entry>Use: <emphasis>pipe</emphasis></entry>
41379 <entry>Type: <emphasis>boolean</emphasis></entry>
41380 <entry>Default: <emphasis>false</emphasis></entry>
41381 </row>
41382 </tbody>
41383 </tgroup>
41384 </informaltable>
41385 <para>
41386 <indexterm role="variable">
41387 <primary><varname>$pipe_addresses</varname></primary>
41388 </indexterm>
41389 If this option is set, it causes the command to be passed to <filename>/bin/sh</filename>
41390 instead of being run directly from the transport, as described in section
41391 <xref linkend="SECThowcommandrun"/>. This is less secure, but is needed in some situations
41392 where the command is expected to be run under a shell and cannot easily be
41393 modified. The <option>allow_commands</option> and <option>restrict_to_path</option> options, and the
41394 <literal>$pipe_addresses</literal> facility are incompatible with <option>use_shell</option>. The
41395 command is expanded as a single string, and handed to <filename>/bin/sh</filename> as data for
41396 its <option>-c</option> option.
41397 </para>
41398 </section>
41399 <section id="SECID143">
41400 <title>Using an external local delivery agent</title>
41401 <para>
41402 <indexterm role="concept">
41403 <primary>local delivery</primary>
41404 <secondary>using an external agent</secondary>
41405 </indexterm>
41406 <indexterm role="concept">
41407 <primary><emphasis>procmail</emphasis></primary>
41408 </indexterm>
41409 <indexterm role="concept">
41410 <primary>external local delivery</primary>
41411 </indexterm>
41412 <indexterm role="concept">
41413 <primary>delivery</primary>
41414 <secondary><emphasis>procmail</emphasis></secondary>
41415 </indexterm>
41416 <indexterm role="concept">
41417 <primary>delivery</primary>
41418 <secondary>by external agent</secondary>
41419 </indexterm>
41420 The <command>pipe</command> transport can be used to pass all messages that require local
41421 delivery to a separate local delivery agent such as <option>procmail</option>. When doing
41422 this, care must be taken to ensure that the pipe is run under an appropriate
41423 uid and gid. In some configurations one wants this to be a uid that is trusted
41424 by the delivery agent to supply the correct sender of the message. It may be
41425 necessary to recompile or reconfigure the delivery agent so that it trusts an
41426 appropriate user. The following is an example transport and router
41427 configuration for <option>procmail</option>:
41428 </para>
41429 <literallayout class="monospaced">
41430 # transport
41431 procmail_pipe:
41432   driver = pipe
41433   command = /usr/local/bin/procmail -d $local_part
41434   return_path_add
41435   delivery_date_add
41436   envelope_to_add
41437   check_string = "From "
41438   escape_string = "&gt;From "
41439   umask = 077
41440   user = $local_part
41441   group = mail
41442
41443 # router
41444 procmail:
41445   driver = accept
41446   check_local_user
41447   transport = procmail_pipe
41448 </literallayout>
41449 <para>
41450 In this example, the pipe is run as the local user, but with the group set to
41451 <emphasis>mail</emphasis>. An alternative is to run the pipe as a specific user such as <emphasis>mail</emphasis>
41452 or <emphasis>exim</emphasis>, but in this case you must arrange for <option>procmail</option> to trust that
41453 user to supply a correct sender address. If you do not specify either a
41454 <option>group</option> or a <option>user</option> option, the pipe command is run as the local user. The
41455 home directory is the user&#x2019;s home directory by default.
41456 </para>
41457 <para>
41458 <emphasis role="bold">Note</emphasis>: The command that the pipe transport runs does <emphasis>not</emphasis> begin with
41459 </para>
41460 <literallayout class="monospaced">
41461 IFS=" "
41462 </literallayout>
41463 <para>
41464 as shown in some <option>procmail</option> documentation, because Exim does not by default
41465 use a shell to run pipe commands.
41466 </para>
41467 <para>
41468 <indexterm role="concept">
41469 <primary>Cyrus</primary>
41470 </indexterm>
41471 The next example shows a transport and a router for a system where local
41472 deliveries are handled by the Cyrus IMAP server.
41473 </para>
41474 <literallayout class="monospaced">
41475 # transport
41476 local_delivery_cyrus:
41477   driver = pipe
41478   command = /usr/cyrus/bin/deliver \
41479             -m ${substr_1:$local_part_suffix} -- $local_part
41480   user = cyrus
41481   group = mail
41482   return_output
41483   log_output
41484   message_prefix =
41485   message_suffix =
41486
41487 # router
41488 local_user_cyrus:
41489   driver = accept
41490   check_local_user
41491   local_part_suffix = .*
41492   transport = local_delivery_cyrus
41493 </literallayout>
41494 <para>
41495 Note the unsetting of <option>message_prefix</option> and <option>message_suffix</option>, and the use of
41496 <option>return_output</option> to cause any text written by Cyrus to be returned to the
41497 sender.
41498 <indexterm role="concept" startref="IIDpiptra1" class="endofrange"/>
41499 <indexterm role="concept" startref="IIDpiptra2" class="endofrange"/>
41500 </para>
41501 </section>
41502 </chapter>
41503
41504 <chapter id="CHAPsmtptrans">
41505 <title>The smtp transport</title>
41506 <para>
41507 <indexterm role="concept" id="IIDsmttra1" class="startofrange">
41508 <primary>transports</primary>
41509 <secondary><command>smtp</command></secondary>
41510 </indexterm>
41511 <indexterm role="concept" id="IIDsmttra2" class="startofrange">
41512 <primary><command>smtp</command> transport</primary>
41513 </indexterm>
41514 The <command>smtp</command> transport delivers messages over TCP/IP connections using the SMTP
41515 or LMTP protocol. The list of hosts to try can either be taken from the address
41516 that is being processed (having been set up by the router), or specified
41517 explicitly for the transport. Timeout and retry processing (see chapter
41518 <xref linkend="CHAPretry"/>) is applied to each IP address independently.
41519 </para>
41520 <section id="SECID144">
41521 <title>Multiple messages on a single connection</title>
41522 <para>
41523 The sending of multiple messages over a single TCP/IP connection can arise in
41524 two ways:
41525 </para>
41526 <itemizedlist>
41527 <listitem>
41528 <para>
41529 If a message contains more than <option>max_rcpt</option> (see below) addresses that are
41530 routed to the same host, more than one copy of the message has to be sent to
41531 that host. In this situation, multiple copies may be sent in a single run of
41532 the <command>smtp</command> transport over a single TCP/IP connection. (What Exim actually
41533 does when it has too many addresses to send in one message also depends on the
41534 value of the global <option>remote_max_parallel</option> option. Details are given in
41535 section <xref linkend="SECToutSMTPTCP"/>.)
41536 </para>
41537 </listitem>
41538 <listitem>
41539 <para>
41540 <indexterm role="concept">
41541 <primary>hints database</primary>
41542 <secondary>remembering routing</secondary>
41543 </indexterm>
41544 When a message has been successfully delivered over a TCP/IP connection, Exim
41545 looks in its hints database to see if there are any other messages awaiting a
41546 connection to the same host. If there are, a new delivery process is started
41547 for one of them, and the current TCP/IP connection is passed on to it. The new
41548 process may in turn send multiple copies and possibly create yet another
41549 process.
41550 </para>
41551 </listitem>
41552 </itemizedlist>
41553 <para>
41554 For each copy sent over the same TCP/IP connection, a sequence counter is
41555 incremented, and if it ever gets to the value of <option>connection_max_messages</option>,
41556 no further messages are sent over that connection.
41557 </para>
41558 </section>
41559 <section id="SECID145">
41560 <title>Use of the $host and $host_address variables</title>
41561 <para>
41562 <indexterm role="variable">
41563 <primary><varname>$host</varname></primary>
41564 </indexterm>
41565 <indexterm role="variable">
41566 <primary><varname>$host_address</varname></primary>
41567 </indexterm>
41568 At the start of a run of the <command>smtp</command> transport, the values of <varname>$host</varname> and
41569 <varname>$host_address</varname> are the name and IP address of the first host on the host list
41570 passed by the router. However, when the transport is about to connect to a
41571 specific host, and while it is connected to that host, <varname>$host</varname> and
41572 <varname>$host_address</varname> are set to the values for that host. These are the values
41573 that are in force when the <option>helo_data</option>, <option>hosts_try_auth</option>, <option>interface</option>,
41574 <option>serialize_hosts</option>, and the various TLS options are expanded.
41575 </para>
41576 </section>
41577 <section id="usecippeer">
41578 <title>Use of $tls_cipher and $tls_peerdn</title>
41579 <para>
41580 <indexterm role="variable">
41581 <primary><varname>$tls_cipher</varname></primary>
41582 </indexterm>
41583 <indexterm role="variable">
41584 <primary><varname>$tls_peerdn</varname></primary>
41585 </indexterm>
41586 At the start of a run of the <command>smtp</command> transport, the values of <varname>$tls_cipher</varname>
41587 and <varname>$tls_peerdn</varname> are the values that were set when the message was received.
41588 These are the values that are used for options that are expanded before any
41589 SMTP connections are made. Just before each connection is made, these two
41590 variables are emptied. If TLS is subsequently started, they are set to the
41591 appropriate values for the outgoing connection, and these are the values that
41592 are in force when any authenticators are run and when the
41593 <option>authenticated_sender</option> option is expanded.
41594 </para>
41595 </section>
41596 <section id="SECID146">
41597 <title>Private options for smtp</title>
41598 <para>
41599 <indexterm role="concept">
41600 <primary>options</primary>
41601 <secondary><command>smtp</command> transport</secondary>
41602 </indexterm>
41603 The private options of the <command>smtp</command> transport are as follows:
41604 </para>
41605 <para>
41606 <indexterm role="option">
41607 <primary><option>address_retry_include_sender</option></primary>
41608 </indexterm>
41609 </para>
41610 <informaltable frame="all">
41611 <tgroup cols="4" colsep="0" rowsep="0">
41612 <colspec colwidth="8*" align="left"/>
41613 <colspec colwidth="6*" align="center"/>
41614 <colspec colwidth="6*" align="center"/>
41615 <colspec colwidth="6*" align="right"/>
41616 <tbody>
41617 <row>
41618 <entry><option>address_retry_include_sender</option></entry>
41619 <entry>Use: <emphasis>smtp</emphasis></entry>
41620 <entry>Type: <emphasis>boolean</emphasis></entry>
41621 <entry>Default: <emphasis>true</emphasis></entry>
41622 </row>
41623 </tbody>
41624 </tgroup>
41625 </informaltable>
41626 <para>
41627 <indexterm role="concept">
41628 <primary>4<emphasis>xx</emphasis> responses</primary>
41629 <secondary>retrying after</secondary>
41630 </indexterm>
41631 When an address is delayed because of a 4<emphasis>xx</emphasis> response to a RCPT command, it
41632 is the combination of sender and recipient that is delayed in subsequent queue
41633 runs until the retry time is reached. You can delay the recipient without
41634 reference to the sender (which is what earlier versions of Exim did), by
41635 setting <option>address_retry_include_sender</option> false. However, this can lead to
41636 problems with servers that regularly issue 4<emphasis>xx</emphasis> responses to RCPT commands.
41637 </para>
41638 <para>
41639 <indexterm role="option">
41640 <primary><option>allow_localhost</option></primary>
41641 </indexterm>
41642 </para>
41643 <informaltable frame="all">
41644 <tgroup cols="4" colsep="0" rowsep="0">
41645 <colspec colwidth="8*" align="left"/>
41646 <colspec colwidth="6*" align="center"/>
41647 <colspec colwidth="6*" align="center"/>
41648 <colspec colwidth="6*" align="right"/>
41649 <tbody>
41650 <row>
41651 <entry><option>allow_localhost</option></entry>
41652 <entry>Use: <emphasis>smtp</emphasis></entry>
41653 <entry>Type: <emphasis>boolean</emphasis></entry>
41654 <entry>Default: <emphasis>false</emphasis></entry>
41655 </row>
41656 </tbody>
41657 </tgroup>
41658 </informaltable>
41659 <para>
41660 <indexterm role="concept">
41661 <primary>local host</primary>
41662 <secondary>sending to</secondary>
41663 </indexterm>
41664 <indexterm role="concept">
41665 <primary>fallback</primary>
41666 <secondary>hosts specified on transport</secondary>
41667 </indexterm>
41668 When a host specified in <option>hosts</option> or <option>fallback_hosts</option> (see below) turns out
41669 to be the local host, or is listed in <option>hosts_treat_as_local</option>, delivery is
41670 deferred by default. However, if <option>allow_localhost</option> is set, Exim goes on to do
41671 the delivery anyway. This should be used only in special cases when the
41672 configuration ensures that no looping will result (for example, a differently
41673 configured Exim is listening on the port to which the message is sent).
41674 </para>
41675 <para>
41676 <indexterm role="option">
41677 <primary><option>authenticated_sender</option></primary>
41678 </indexterm>
41679 </para>
41680 <informaltable frame="all">
41681 <tgroup cols="4" colsep="0" rowsep="0">
41682 <colspec colwidth="8*" align="left"/>
41683 <colspec colwidth="6*" align="center"/>
41684 <colspec colwidth="6*" align="center"/>
41685 <colspec colwidth="6*" align="right"/>
41686 <tbody>
41687 <row>
41688 <entry><option>authenticated_sender</option></entry>
41689 <entry>Use: <emphasis>smtp</emphasis></entry>
41690 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
41691 <entry>Default: <emphasis>unset</emphasis></entry>
41692 </row>
41693 </tbody>
41694 </tgroup>
41695 </informaltable>
41696 <para>
41697 <indexterm role="concept">
41698 <primary>Cyrus</primary>
41699 </indexterm>
41700 When Exim has authenticated as a client, or if <option>authenticated_sender_force</option>
41701 is true, this option sets a value for the AUTH= item on outgoing MAIL commands,
41702 overriding any existing authenticated sender value. If the string expansion is
41703 forced to fail, the option is ignored. Other expansion failures cause delivery
41704 to be deferred. If the result of expansion is an empty string, that is also
41705 ignored.
41706 </para>
41707 <para>
41708 The expansion happens after the outgoing connection has been made and TLS
41709 started, if required. This means that the <varname>$host</varname>, <varname>$host_address</varname>,
41710 <varname>$tls_cipher</varname>, and <varname>$tls_peerdn</varname> variables are set according to the
41711 particular connection.
41712 </para>
41713 <para>
41714 If the SMTP session is not authenticated, the expansion of
41715 <option>authenticated_sender</option> still happens (and can cause the delivery to be
41716 deferred if it fails), but no AUTH= item is added to MAIL commands
41717 unless <option>authenticated_sender_force</option> is true.
41718 </para>
41719 <para>
41720 This option allows you to use the <command>smtp</command> transport in LMTP mode to
41721 deliver mail to Cyrus IMAP and provide the proper local part as the
41722 <quote>authenticated sender</quote>, via a setting such as:
41723 </para>
41724 <literallayout class="monospaced">
41725 authenticated_sender = $local_part
41726 </literallayout>
41727 <para>
41728 This removes the need for IMAP subfolders to be assigned special ACLs to
41729 allow direct delivery to those subfolders.
41730 </para>
41731 <para>
41732 Because of expected uses such as that just described for Cyrus (when no
41733 domain is involved), there is no checking on the syntax of the provided
41734 value.
41735 </para>
41736 <para>
41737 <indexterm role="option">
41738 <primary><option>authenticated_sender_force</option></primary>
41739 </indexterm>
41740 </para>
41741 <informaltable frame="all">
41742 <tgroup cols="4" colsep="0" rowsep="0">
41743 <colspec colwidth="8*" align="left"/>
41744 <colspec colwidth="6*" align="center"/>
41745 <colspec colwidth="6*" align="center"/>
41746 <colspec colwidth="6*" align="right"/>
41747 <tbody>
41748 <row>
41749 <entry><option>authenticated_sender_force</option></entry>
41750 <entry>Use: <emphasis>smtp</emphasis></entry>
41751 <entry>Type: <emphasis>boolean</emphasis></entry>
41752 <entry>Default: <emphasis>false</emphasis></entry>
41753 </row>
41754 </tbody>
41755 </tgroup>
41756 </informaltable>
41757 <para>
41758 If this option is set true, the <option>authenticated_sender</option> option&#x2019;s value
41759 is used for the AUTH= item on outgoing MAIL commands, even if Exim has not
41760 authenticated as a client.
41761 </para>
41762 <para>
41763 <indexterm role="option">
41764 <primary><option>command_timeout</option></primary>
41765 </indexterm>
41766 </para>
41767 <informaltable frame="all">
41768 <tgroup cols="4" colsep="0" rowsep="0">
41769 <colspec colwidth="8*" align="left"/>
41770 <colspec colwidth="6*" align="center"/>
41771 <colspec colwidth="6*" align="center"/>
41772 <colspec colwidth="6*" align="right"/>
41773 <tbody>
41774 <row>
41775 <entry><option>command_timeout</option></entry>
41776 <entry>Use: <emphasis>smtp</emphasis></entry>
41777 <entry>Type: <emphasis>time</emphasis></entry>
41778 <entry>Default: <emphasis>5m</emphasis></entry>
41779 </row>
41780 </tbody>
41781 </tgroup>
41782 </informaltable>
41783 <para>
41784 This sets a timeout for receiving a response to an SMTP command that has been
41785 sent out. It is also used when waiting for the initial banner line from the
41786 remote host. Its value must not be zero.
41787 </para>
41788 <para>
41789 <indexterm role="option">
41790 <primary><option>connect_timeout</option></primary>
41791 </indexterm>
41792 </para>
41793 <informaltable frame="all">
41794 <tgroup cols="4" colsep="0" rowsep="0">
41795 <colspec colwidth="8*" align="left"/>
41796 <colspec colwidth="6*" align="center"/>
41797 <colspec colwidth="6*" align="center"/>
41798 <colspec colwidth="6*" align="right"/>
41799 <tbody>
41800 <row>
41801 <entry><option>connect_timeout</option></entry>
41802 <entry>Use: <emphasis>smtp</emphasis></entry>
41803 <entry>Type: <emphasis>time</emphasis></entry>
41804 <entry>Default: <emphasis>5m</emphasis></entry>
41805 </row>
41806 </tbody>
41807 </tgroup>
41808 </informaltable>
41809 <para>
41810 This sets a timeout for the <function>connect()</function> function, which sets up a TCP/IP call
41811 to a remote host. A setting of zero allows the system timeout (typically
41812 several minutes) to act. To have any effect, the value of this option must be
41813 less than the system timeout. However, it has been observed that on some
41814 systems there is no system timeout, which is why the default value for this
41815 option is 5 minutes, a value recommended by RFC 1123.
41816 </para>
41817 <para>
41818 <indexterm role="option">
41819 <primary><option>connection_max_messages</option></primary>
41820 </indexterm>
41821 </para>
41822 <informaltable frame="all">
41823 <tgroup cols="4" colsep="0" rowsep="0">
41824 <colspec colwidth="8*" align="left"/>
41825 <colspec colwidth="6*" align="center"/>
41826 <colspec colwidth="6*" align="center"/>
41827 <colspec colwidth="6*" align="right"/>
41828 <tbody>
41829 <row>
41830 <entry><option>connection_max_messages</option></entry>
41831 <entry>Use: <emphasis>smtp</emphasis></entry>
41832 <entry>Type: <emphasis>integer</emphasis></entry>
41833 <entry>Default: <emphasis>500</emphasis></entry>
41834 </row>
41835 </tbody>
41836 </tgroup>
41837 </informaltable>
41838 <para>
41839 <indexterm role="concept">
41840 <primary>SMTP</primary>
41841 <secondary>passed connection</secondary>
41842 </indexterm>
41843 <indexterm role="concept">
41844 <primary>SMTP</primary>
41845 <secondary>multiple deliveries</secondary>
41846 </indexterm>
41847 <indexterm role="concept">
41848 <primary>multiple SMTP deliveries</primary>
41849 </indexterm>
41850 This controls the maximum number of separate message deliveries that are sent
41851 over a single TCP/IP connection. If the value is zero, there is no limit.
41852 For testing purposes, this value can be overridden by the <option>-oB</option> command line
41853 option.
41854 </para>
41855 <para>
41856 <indexterm role="option">
41857 <primary><option>data_timeout</option></primary>
41858 </indexterm>
41859 </para>
41860 <informaltable frame="all">
41861 <tgroup cols="4" colsep="0" rowsep="0">
41862 <colspec colwidth="8*" align="left"/>
41863 <colspec colwidth="6*" align="center"/>
41864 <colspec colwidth="6*" align="center"/>
41865 <colspec colwidth="6*" align="right"/>
41866 <tbody>
41867 <row>
41868 <entry><option>data_timeout</option></entry>
41869 <entry>Use: <emphasis>smtp</emphasis></entry>
41870 <entry>Type: <emphasis>time</emphasis></entry>
41871 <entry>Default: <emphasis>5m</emphasis></entry>
41872 </row>
41873 </tbody>
41874 </tgroup>
41875 </informaltable>
41876 <para>
41877 This sets a timeout for the transmission of each block in the data portion of
41878 the message. As a result, the overall timeout for a message depends on the size
41879 of the message. Its value must not be zero. See also <option>final_timeout</option>.
41880 </para>
41881 <para>
41882 <indexterm role="option">
41883 <primary><option>delay_after_cutoff</option></primary>
41884 </indexterm>
41885 </para>
41886 <informaltable frame="all">
41887 <tgroup cols="4" colsep="0" rowsep="0">
41888 <colspec colwidth="8*" align="left"/>
41889 <colspec colwidth="6*" align="center"/>
41890 <colspec colwidth="6*" align="center"/>
41891 <colspec colwidth="6*" align="right"/>
41892 <tbody>
41893 <row>
41894 <entry><option>delay_after_cutoff</option></entry>
41895 <entry>Use: <emphasis>smtp</emphasis></entry>
41896 <entry>Type: <emphasis>boolean</emphasis></entry>
41897 <entry>Default: <emphasis>true</emphasis></entry>
41898 </row>
41899 </tbody>
41900 </tgroup>
41901 </informaltable>
41902 <para>
41903 This option controls what happens when all remote IP addresses for a given
41904 domain have been inaccessible for so long that they have passed their retry
41905 cutoff times.
41906 </para>
41907 <para>
41908 In the default state, if the next retry time has not been reached for any of
41909 them, the address is bounced without trying any deliveries. In other words,
41910 Exim delays retrying an IP address after the final cutoff time until a new
41911 retry time is reached, and can therefore bounce an address without ever trying
41912 a delivery, when machines have been down for a long time. Some people are
41913 unhappy at this prospect, so...
41914 </para>
41915 <para>
41916 If <option>delay_after_cutoff</option> is set false, Exim behaves differently. If all IP
41917 addresses are past their final cutoff time, Exim tries to deliver to those
41918 IP addresses that have not been tried since the message arrived. If there are
41919 none, of if they all fail, the address is bounced. In other words, it does not
41920 delay when a new message arrives, but immediately tries those expired IP
41921 addresses that haven&#x2019;t been tried since the message arrived. If there is a
41922 continuous stream of messages for the dead hosts, unsetting
41923 <option>delay_after_cutoff</option> means that there will be many more attempts to deliver
41924 to them.
41925 </para>
41926 <para>
41927 <indexterm role="option">
41928 <primary><option>dns_qualify_single</option></primary>
41929 </indexterm>
41930 </para>
41931 <informaltable frame="all">
41932 <tgroup cols="4" colsep="0" rowsep="0">
41933 <colspec colwidth="8*" align="left"/>
41934 <colspec colwidth="6*" align="center"/>
41935 <colspec colwidth="6*" align="center"/>
41936 <colspec colwidth="6*" align="right"/>
41937 <tbody>
41938 <row>
41939 <entry><option>dns_qualify_single</option></entry>
41940 <entry>Use: <emphasis>smtp</emphasis></entry>
41941 <entry>Type: <emphasis>boolean</emphasis></entry>
41942 <entry>Default: <emphasis>true</emphasis></entry>
41943 </row>
41944 </tbody>
41945 </tgroup>
41946 </informaltable>
41947 <para>
41948 If the <option>hosts</option> or <option>fallback_hosts</option> option is being used,
41949 and the <option>gethostbyname</option> option is false,
41950 the RES_DEFNAMES resolver option is set. See the <option>qualify_single</option> option
41951 in chapter <xref linkend="CHAPdnslookup"/> for more details.
41952 </para>
41953 <para>
41954 <indexterm role="option">
41955 <primary><option>dns_search_parents</option></primary>
41956 </indexterm>
41957 </para>
41958 <informaltable frame="all">
41959 <tgroup cols="4" colsep="0" rowsep="0">
41960 <colspec colwidth="8*" align="left"/>
41961 <colspec colwidth="6*" align="center"/>
41962 <colspec colwidth="6*" align="center"/>
41963 <colspec colwidth="6*" align="right"/>
41964 <tbody>
41965 <row>
41966 <entry><option>dns_search_parents</option></entry>
41967 <entry>Use: <emphasis>smtp</emphasis></entry>
41968 <entry>Type: <emphasis>boolean</emphasis></entry>
41969 <entry>Default: <emphasis>false</emphasis></entry>
41970 </row>
41971 </tbody>
41972 </tgroup>
41973 </informaltable>
41974 <para>
41975 If the <option>hosts</option> or <option>fallback_hosts</option> option is being used, and the
41976 <option>gethostbyname</option> option is false, the RES_DNSRCH resolver option is set.
41977 See the <option>search_parents</option> option in chapter <xref linkend="CHAPdnslookup"/> for more
41978 details.
41979 </para>
41980 <para>
41981 <indexterm role="option">
41982 <primary><option>fallback_hosts</option></primary>
41983 </indexterm>
41984 </para>
41985 <informaltable frame="all">
41986 <tgroup cols="4" colsep="0" rowsep="0">
41987 <colspec colwidth="8*" align="left"/>
41988 <colspec colwidth="6*" align="center"/>
41989 <colspec colwidth="6*" align="center"/>
41990 <colspec colwidth="6*" align="right"/>
41991 <tbody>
41992 <row>
41993 <entry><option>fallback_hosts</option></entry>
41994 <entry>Use: <emphasis>smtp</emphasis></entry>
41995 <entry>Type: <emphasis>string list</emphasis></entry>
41996 <entry>Default: <emphasis>unset</emphasis></entry>
41997 </row>
41998 </tbody>
41999 </tgroup>
42000 </informaltable>
42001 <para>
42002 <indexterm role="concept">
42003 <primary>fallback</primary>
42004 <secondary>hosts specified on transport</secondary>
42005 </indexterm>
42006 String expansion is not applied to this option. The argument must be a
42007 colon-separated list of host names or IP addresses, optionally also including
42008 port numbers, though the separator can be changed, as described in section
42009 <xref linkend="SECTlistconstruct"/>. Each individual item in the list is the same as an
42010 item in a <option>route_list</option> setting for the <command>manualroute</command> router, as described
42011 in section <xref linkend="SECTformatonehostitem"/>.
42012 </para>
42013 <para>
42014 Fallback hosts can also be specified on routers, which associate them with the
42015 addresses they process. As for the <option>hosts</option> option without <option>hosts_override</option>,
42016 <option>fallback_hosts</option> specified on the transport is used only if the address does
42017 not have its own associated fallback host list. Unlike <option>hosts</option>, a setting of
42018 <option>fallback_hosts</option> on an address is not overridden by <option>hosts_override</option>.
42019 However, <option>hosts_randomize</option> does apply to fallback host lists.
42020 </para>
42021 <para>
42022 If Exim is unable to deliver to any of the hosts for a particular address, and
42023 the errors are not permanent rejections, the address is put on a separate
42024 transport queue with its host list replaced by the fallback hosts, unless the
42025 address was routed via MX records and the current host was in the original MX
42026 list. In that situation, the fallback host list is not used.
42027 </para>
42028 <para>
42029 Once normal deliveries are complete, the fallback queue is delivered by
42030 re-running the same transports with the new host lists. If several failing
42031 addresses have the same fallback hosts (and <option>max_rcpt</option> permits it), a single
42032 copy of the message is sent.
42033 </para>
42034 <para>
42035 The resolution of the host names on the fallback list is controlled by the
42036 <option>gethostbyname</option> option, as for the <option>hosts</option> option. Fallback hosts apply
42037 both to cases when the host list comes with the address and when it is taken
42038 from <option>hosts</option>. This option provides a <quote>use a smart host only if delivery
42039 fails</quote> facility.
42040 </para>
42041 <para>
42042 <indexterm role="option">
42043 <primary><option>final_timeout</option></primary>
42044 </indexterm>
42045 </para>
42046 <informaltable frame="all">
42047 <tgroup cols="4" colsep="0" rowsep="0">
42048 <colspec colwidth="8*" align="left"/>
42049 <colspec colwidth="6*" align="center"/>
42050 <colspec colwidth="6*" align="center"/>
42051 <colspec colwidth="6*" align="right"/>
42052 <tbody>
42053 <row>
42054 <entry><option>final_timeout</option></entry>
42055 <entry>Use: <emphasis>smtp</emphasis></entry>
42056 <entry>Type: <emphasis>time</emphasis></entry>
42057 <entry>Default: <emphasis>10m</emphasis></entry>
42058 </row>
42059 </tbody>
42060 </tgroup>
42061 </informaltable>
42062 <para>
42063 This is the timeout that applies while waiting for the response to the final
42064 line containing just <quote>.</quote> that terminates a message. Its value must not be
42065 zero.
42066 </para>
42067 <para>
42068 <indexterm role="option">
42069 <primary><option>gethostbyname</option></primary>
42070 </indexterm>
42071 </para>
42072 <informaltable frame="all">
42073 <tgroup cols="4" colsep="0" rowsep="0">
42074 <colspec colwidth="8*" align="left"/>
42075 <colspec colwidth="6*" align="center"/>
42076 <colspec colwidth="6*" align="center"/>
42077 <colspec colwidth="6*" align="right"/>
42078 <tbody>
42079 <row>
42080 <entry><option>gethostbyname</option></entry>
42081 <entry>Use: <emphasis>smtp</emphasis></entry>
42082 <entry>Type: <emphasis>boolean</emphasis></entry>
42083 <entry>Default: <emphasis>false</emphasis></entry>
42084 </row>
42085 </tbody>
42086 </tgroup>
42087 </informaltable>
42088 <para>
42089 If this option is true when the <option>hosts</option> and/or <option>fallback_hosts</option> options are
42090 being used, names are looked up using <function>gethostbyname()</function>
42091 (or <function>getipnodebyname()</function> when available)
42092 instead of using the DNS. Of course, that function may in fact use the DNS, but
42093 it may also consult other sources of information such as <filename>/etc/hosts</filename>.
42094 </para>
42095 <para>
42096 <indexterm role="option">
42097 <primary><option>gnutls_require_kx</option></primary>
42098 </indexterm>
42099 </para>
42100 <informaltable frame="all">
42101 <tgroup cols="4" colsep="0" rowsep="0">
42102 <colspec colwidth="8*" align="left"/>
42103 <colspec colwidth="6*" align="center"/>
42104 <colspec colwidth="6*" align="center"/>
42105 <colspec colwidth="6*" align="right"/>
42106 <tbody>
42107 <row>
42108 <entry><option>gnutls_require_kx</option></entry>
42109 <entry>Use: <emphasis>smtp</emphasis></entry>
42110 <entry>Type: <emphasis>string</emphasis></entry>
42111 <entry>Default: <emphasis>unset</emphasis></entry>
42112 </row>
42113 </tbody>
42114 </tgroup>
42115 </informaltable>
42116 <para>
42117 This option controls the key exchange mechanisms when GnuTLS is used in an Exim
42118 client. For details, see section <xref linkend="SECTreqciphgnu"/>.
42119 </para>
42120 <para>
42121 <indexterm role="option">
42122 <primary><option>gnutls_require_mac</option></primary>
42123 </indexterm>
42124 </para>
42125 <informaltable frame="all">
42126 <tgroup cols="4" colsep="0" rowsep="0">
42127 <colspec colwidth="8*" align="left"/>
42128 <colspec colwidth="6*" align="center"/>
42129 <colspec colwidth="6*" align="center"/>
42130 <colspec colwidth="6*" align="right"/>
42131 <tbody>
42132 <row>
42133 <entry><option>gnutls_require_mac</option></entry>
42134 <entry>Use: <emphasis>smtp</emphasis></entry>
42135 <entry>Type: <emphasis>string</emphasis></entry>
42136 <entry>Default: <emphasis>unset</emphasis></entry>
42137 </row>
42138 </tbody>
42139 </tgroup>
42140 </informaltable>
42141 <para>
42142 This option controls the MAC algorithms when GnuTLS is used in an Exim
42143 client. For details, see section <xref linkend="SECTreqciphgnu"/>.
42144 </para>
42145 <para>
42146 <indexterm role="option">
42147 <primary><option>gnutls_require_protocols</option></primary>
42148 </indexterm>
42149 </para>
42150 <informaltable frame="all">
42151 <tgroup cols="4" colsep="0" rowsep="0">
42152 <colspec colwidth="8*" align="left"/>
42153 <colspec colwidth="6*" align="center"/>
42154 <colspec colwidth="6*" align="center"/>
42155 <colspec colwidth="6*" align="right"/>
42156 <tbody>
42157 <row>
42158 <entry><option>gnutls_require_protocols</option></entry>
42159 <entry>Use: <emphasis>smtp</emphasis></entry>
42160 <entry>Type: <emphasis>string</emphasis></entry>
42161 <entry>Default: <emphasis>unset</emphasis></entry>
42162 </row>
42163 </tbody>
42164 </tgroup>
42165 </informaltable>
42166 <para>
42167 This option controls the protocols when GnuTLS is used in an Exim
42168 client. For details, see section <xref linkend="SECTreqciphgnu"/>.
42169 </para>
42170 <para>
42171 <indexterm role="option">
42172 <primary><option>gnutls_compat_mode</option></primary>
42173 </indexterm>
42174 </para>
42175 <informaltable frame="all">
42176 <tgroup cols="4" colsep="0" rowsep="0">
42177 <colspec colwidth="8*" align="left"/>
42178 <colspec colwidth="6*" align="center"/>
42179 <colspec colwidth="6*" align="center"/>
42180 <colspec colwidth="6*" align="right"/>
42181 <tbody>
42182 <row>
42183 <entry><option>gnutls_compat_mode</option></entry>
42184 <entry>Use: <emphasis>smtp</emphasis></entry>
42185 <entry>Type: <emphasis>boolean</emphasis></entry>
42186 <entry>Default: <emphasis>unset</emphasis></entry>
42187 </row>
42188 </tbody>
42189 </tgroup>
42190 </informaltable>
42191 <para>
42192 This option controls whether GnuTLS is used in compatibility mode in an Exim
42193 server. This reduces security slightly, but improves interworking with older
42194 implementations of TLS.
42195 </para>
42196 <para>
42197 <indexterm role="option">
42198 <primary><option>helo_data</option></primary>
42199 </indexterm>
42200 </para>
42201 <informaltable frame="all">
42202 <tgroup cols="4" colsep="0" rowsep="0">
42203 <colspec colwidth="8*" align="left"/>
42204 <colspec colwidth="6*" align="center"/>
42205 <colspec colwidth="6*" align="center"/>
42206 <colspec colwidth="6*" align="right"/>
42207 <tbody>
42208 <row>
42209 <entry><option>helo_data</option></entry>
42210 <entry>Use: <emphasis>smtp</emphasis></entry>
42211 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
42212 <entry>Default: <emphasis>see below</emphasis></entry>
42213 </row>
42214 </tbody>
42215 </tgroup>
42216 </informaltable>
42217 <para>
42218 <indexterm role="concept">
42219 <primary>HELO</primary>
42220 <secondary>argument, setting</secondary>
42221 </indexterm>
42222 <indexterm role="concept">
42223 <primary>EHLO</primary>
42224 <secondary>argument, setting</secondary>
42225 </indexterm>
42226 <indexterm role="concept">
42227 <primary>LHLO argument setting</primary>
42228 </indexterm>
42229 The value of this option is expanded after a connection to a another host has
42230 been set up. The result is used as the argument for the EHLO, HELO, or LHLO
42231 command that starts the outgoing SMTP or LMTP session. The default value of the
42232 option is:
42233 </para>
42234 <literallayout class="monospaced">
42235 $primary_hostname
42236 </literallayout>
42237 <para>
42238 During the expansion, the variables <varname>$host</varname> and <varname>$host_address</varname> are set to
42239 the identity of the remote host, and the variables <varname>$sending_ip_address</varname> and
42240 <varname>$sending_port</varname> are set to the local IP address and port number that are being
42241 used. These variables can be used to generate different values for different
42242 servers or different local IP addresses. For example, if you want the string
42243 that is used for <option>helo_data</option> to be obtained by a DNS lookup of the outgoing
42244 interface address, you could use this:
42245 </para>
42246 <literallayout class="monospaced">
42247 helo_data = ${lookup dnsdb{ptr=$sending_ip_address}{$value}\
42248   {$primary_hostname}}
42249 </literallayout>
42250 <para>
42251 The use of <option>helo_data</option> applies both to sending messages and when doing
42252 callouts.
42253 </para>
42254 <para>
42255 <indexterm role="option">
42256 <primary><option>hosts</option></primary>
42257 </indexterm>
42258 </para>
42259 <informaltable frame="all">
42260 <tgroup cols="4" colsep="0" rowsep="0">
42261 <colspec colwidth="8*" align="left"/>
42262 <colspec colwidth="6*" align="center"/>
42263 <colspec colwidth="6*" align="center"/>
42264 <colspec colwidth="6*" align="right"/>
42265 <tbody>
42266 <row>
42267 <entry><option>hosts</option></entry>
42268 <entry>Use: <emphasis>smtp</emphasis></entry>
42269 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
42270 <entry>Default: <emphasis>unset</emphasis></entry>
42271 </row>
42272 </tbody>
42273 </tgroup>
42274 </informaltable>
42275 <para>
42276 Hosts are associated with an address by a router such as <command>dnslookup</command>, which
42277 finds the hosts by looking up the address domain in the DNS, or by
42278 <command>manualroute</command>, which has lists of hosts in its configuration. However,
42279 email addresses can be passed to the <command>smtp</command> transport by any router, and not
42280 all of them can provide an associated list of hosts.
42281 </para>
42282 <para>
42283 The <option>hosts</option> option specifies a list of hosts to be used if the address being
42284 processed does not have any hosts associated with it. The hosts specified by
42285 <option>hosts</option> are also used, whether or not the address has its own hosts, if
42286 <option>hosts_override</option> is set.
42287 </para>
42288 <para>
42289 The string is first expanded, before being interpreted as a colon-separated
42290 list of host names or IP addresses, possibly including port numbers. The
42291 separator may be changed to something other than colon, as described in section
42292 <xref linkend="SECTlistconstruct"/>. Each individual item in the list is the same as an
42293 item in a <option>route_list</option> setting for the <command>manualroute</command> router, as described
42294 in section <xref linkend="SECTformatonehostitem"/>. However, note that the <literal>/MX</literal> facility
42295 of the <command>manualroute</command> router is not available here.
42296 </para>
42297 <para>
42298 If the expansion fails, delivery is deferred. Unless the failure was caused by
42299 the inability to complete a lookup, the error is logged to the panic log as
42300 well as the main log. Host names are looked up either by searching directly for
42301 address records in the DNS or by calling <function>gethostbyname()</function> (or
42302 <function>getipnodebyname()</function> when available), depending on the setting of the
42303 <option>gethostbyname</option> option. When Exim is compiled with IPv6 support, if a host
42304 that is looked up in the DNS has both IPv4 and IPv6 addresses, both types of
42305 address are used.
42306 </para>
42307 <para>
42308 During delivery, the hosts are tried in order, subject to their retry status,
42309 unless <option>hosts_randomize</option> is set.
42310 </para>
42311 <para>
42312 <indexterm role="option">
42313 <primary><option>hosts_avoid_esmtp</option></primary>
42314 </indexterm>
42315 </para>
42316 <informaltable frame="all">
42317 <tgroup cols="4" colsep="0" rowsep="0">
42318 <colspec colwidth="8*" align="left"/>
42319 <colspec colwidth="6*" align="center"/>
42320 <colspec colwidth="6*" align="center"/>
42321 <colspec colwidth="6*" align="right"/>
42322 <tbody>
42323 <row>
42324 <entry><option>hosts_avoid_esmtp</option></entry>
42325 <entry>Use: <emphasis>smtp</emphasis></entry>
42326 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
42327 <entry>Default: <emphasis>unset</emphasis></entry>
42328 </row>
42329 </tbody>
42330 </tgroup>
42331 </informaltable>
42332 <para>
42333 <indexterm role="concept">
42334 <primary>ESMTP, avoiding use of</primary>
42335 </indexterm>
42336 <indexterm role="concept">
42337 <primary>HELO</primary>
42338 <secondary>forcing use of</secondary>
42339 </indexterm>
42340 <indexterm role="concept">
42341 <primary>EHLO</primary>
42342 <secondary>avoiding use of</secondary>
42343 </indexterm>
42344 <indexterm role="concept">
42345 <primary>PIPELINING</primary>
42346 <secondary>avoiding the use of</secondary>
42347 </indexterm>
42348 This option is for use with broken hosts that announce ESMTP facilities (for
42349 example, PIPELINING) and then fail to implement them properly. When a host
42350 matches <option>hosts_avoid_esmtp</option>, Exim sends HELO rather than EHLO at the
42351 start of the SMTP session. This means that it cannot use any of the ESMTP
42352 facilities such as AUTH, PIPELINING, SIZE, and STARTTLS.
42353 </para>
42354 <para>
42355 <indexterm role="option">
42356 <primary><option>hosts_avoid_pipelining</option></primary>
42357 </indexterm>
42358 </para>
42359 <informaltable frame="all">
42360 <tgroup cols="4" colsep="0" rowsep="0">
42361 <colspec colwidth="8*" align="left"/>
42362 <colspec colwidth="6*" align="center"/>
42363 <colspec colwidth="6*" align="center"/>
42364 <colspec colwidth="6*" align="right"/>
42365 <tbody>
42366 <row>
42367 <entry><option>hosts_avoid_pipelining</option></entry>
42368 <entry>Use: <emphasis>smtp</emphasis></entry>
42369 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
42370 <entry>Default: <emphasis>unset</emphasis></entry>
42371 </row>
42372 </tbody>
42373 </tgroup>
42374 </informaltable>
42375 <para>
42376 <indexterm role="concept">
42377 <primary>PIPELINING</primary>
42378 <secondary>avoiding the use of</secondary>
42379 </indexterm>
42380 Exim will not use the SMTP PIPELINING extension when delivering to any host
42381 that matches this list, even if the server host advertises PIPELINING support.
42382 </para>
42383 <para>
42384 <indexterm role="option">
42385 <primary><option>hosts_avoid_tls</option></primary>
42386 </indexterm>
42387 </para>
42388 <informaltable frame="all">
42389 <tgroup cols="4" colsep="0" rowsep="0">
42390 <colspec colwidth="8*" align="left"/>
42391 <colspec colwidth="6*" align="center"/>
42392 <colspec colwidth="6*" align="center"/>
42393 <colspec colwidth="6*" align="right"/>
42394 <tbody>
42395 <row>
42396 <entry><option>hosts_avoid_tls</option></entry>
42397 <entry>Use: <emphasis>smtp</emphasis></entry>
42398 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
42399 <entry>Default: <emphasis>unset</emphasis></entry>
42400 </row>
42401 </tbody>
42402 </tgroup>
42403 </informaltable>
42404 <para>
42405 <indexterm role="concept">
42406 <primary>TLS</primary>
42407 <secondary>avoiding for certain hosts</secondary>
42408 </indexterm>
42409 Exim will not try to start a TLS session when delivering to any host that
42410 matches this list. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
42411 </para>
42412 <para>
42413 <indexterm role="option">
42414 <primary><option>hosts_max_try</option></primary>
42415 </indexterm>
42416 </para>
42417 <informaltable frame="all">
42418 <tgroup cols="4" colsep="0" rowsep="0">
42419 <colspec colwidth="8*" align="left"/>
42420 <colspec colwidth="6*" align="center"/>
42421 <colspec colwidth="6*" align="center"/>
42422 <colspec colwidth="6*" align="right"/>
42423 <tbody>
42424 <row>
42425 <entry><option>hosts_max_try</option></entry>
42426 <entry>Use: <emphasis>smtp</emphasis></entry>
42427 <entry>Type: <emphasis>integer</emphasis></entry>
42428 <entry>Default: <emphasis>5</emphasis></entry>
42429 </row>
42430 </tbody>
42431 </tgroup>
42432 </informaltable>
42433 <para>
42434 <indexterm role="concept">
42435 <primary>host</primary>
42436 <secondary>maximum number to try</secondary>
42437 </indexterm>
42438 <indexterm role="concept">
42439 <primary>limit</primary>
42440 <secondary>number of hosts tried</secondary>
42441 </indexterm>
42442 <indexterm role="concept">
42443 <primary>limit</primary>
42444 <secondary>number of MX tried</secondary>
42445 </indexterm>
42446 <indexterm role="concept">
42447 <primary>MX record</primary>
42448 <secondary>maximum tried</secondary>
42449 </indexterm>
42450 This option limits the number of IP addresses that are tried for any one
42451 delivery in cases where there are temporary delivery errors. Section
42452 <xref linkend="SECTvalhosmax"/> describes in detail how the value of this option is used.
42453 </para>
42454 <para>
42455 <indexterm role="option">
42456 <primary><option>hosts_max_try_hardlimit</option></primary>
42457 </indexterm>
42458 </para>
42459 <informaltable frame="all">
42460 <tgroup cols="4" colsep="0" rowsep="0">
42461 <colspec colwidth="8*" align="left"/>
42462 <colspec colwidth="6*" align="center"/>
42463 <colspec colwidth="6*" align="center"/>
42464 <colspec colwidth="6*" align="right"/>
42465 <tbody>
42466 <row>
42467 <entry><option>hosts_max_try_hardlimit</option></entry>
42468 <entry>Use: <emphasis>smtp</emphasis></entry>
42469 <entry>Type: <emphasis>integer</emphasis></entry>
42470 <entry>Default: <emphasis>50</emphasis></entry>
42471 </row>
42472 </tbody>
42473 </tgroup>
42474 </informaltable>
42475 <para>
42476 This is an additional check on the maximum number of IP addresses that Exim
42477 tries for any one delivery. Section <xref linkend="SECTvalhosmax"/> describes its use and
42478 why it exists.
42479 </para>
42480 <para>
42481 <indexterm role="option">
42482 <primary><option>hosts_nopass_tls</option></primary>
42483 </indexterm>
42484 </para>
42485 <informaltable frame="all">
42486 <tgroup cols="4" colsep="0" rowsep="0">
42487 <colspec colwidth="8*" align="left"/>
42488 <colspec colwidth="6*" align="center"/>
42489 <colspec colwidth="6*" align="center"/>
42490 <colspec colwidth="6*" align="right"/>
42491 <tbody>
42492 <row>
42493 <entry><option>hosts_nopass_tls</option></entry>
42494 <entry>Use: <emphasis>smtp</emphasis></entry>
42495 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
42496 <entry>Default: <emphasis>unset</emphasis></entry>
42497 </row>
42498 </tbody>
42499 </tgroup>
42500 </informaltable>
42501 <para>
42502 <indexterm role="concept">
42503 <primary>TLS</primary>
42504 <secondary>passing connection</secondary>
42505 </indexterm>
42506 <indexterm role="concept">
42507 <primary>multiple SMTP deliveries</primary>
42508 </indexterm>
42509 <indexterm role="concept">
42510 <primary>TLS</primary>
42511 <secondary>multiple message deliveries</secondary>
42512 </indexterm>
42513 For any host that matches this list, a connection on which a TLS session has
42514 been started will not be passed to a new delivery process for sending another
42515 message on the same connection. See section <xref linkend="SECTmulmessam"/> for an
42516 explanation of when this might be needed.
42517 </para>
42518 <para>
42519 <indexterm role="option">
42520 <primary><option>hosts_override</option></primary>
42521 </indexterm>
42522 </para>
42523 <informaltable frame="all">
42524 <tgroup cols="4" colsep="0" rowsep="0">
42525 <colspec colwidth="8*" align="left"/>
42526 <colspec colwidth="6*" align="center"/>
42527 <colspec colwidth="6*" align="center"/>
42528 <colspec colwidth="6*" align="right"/>
42529 <tbody>
42530 <row>
42531 <entry><option>hosts_override</option></entry>
42532 <entry>Use: <emphasis>smtp</emphasis></entry>
42533 <entry>Type: <emphasis>boolean</emphasis></entry>
42534 <entry>Default: <emphasis>false</emphasis></entry>
42535 </row>
42536 </tbody>
42537 </tgroup>
42538 </informaltable>
42539 <para>
42540 If this option is set and the <option>hosts</option> option is also set, any hosts that are
42541 attached to the address are ignored, and instead the hosts specified by the
42542 <option>hosts</option> option are always used. This option does not apply to
42543 <option>fallback_hosts</option>.
42544 </para>
42545 <para>
42546 <indexterm role="option">
42547 <primary><option>hosts_randomize</option></primary>
42548 </indexterm>
42549 </para>
42550 <informaltable frame="all">
42551 <tgroup cols="4" colsep="0" rowsep="0">
42552 <colspec colwidth="8*" align="left"/>
42553 <colspec colwidth="6*" align="center"/>
42554 <colspec colwidth="6*" align="center"/>
42555 <colspec colwidth="6*" align="right"/>
42556 <tbody>
42557 <row>
42558 <entry><option>hosts_randomize</option></entry>
42559 <entry>Use: <emphasis>smtp</emphasis></entry>
42560 <entry>Type: <emphasis>boolean</emphasis></entry>
42561 <entry>Default: <emphasis>false</emphasis></entry>
42562 </row>
42563 </tbody>
42564 </tgroup>
42565 </informaltable>
42566 <para>
42567 <indexterm role="concept">
42568 <primary>randomized host list</primary>
42569 </indexterm>
42570 <indexterm role="concept">
42571 <primary>host</primary>
42572 <secondary>list of; randomized</secondary>
42573 </indexterm>
42574 <indexterm role="concept">
42575 <primary>fallback</primary>
42576 <secondary>randomized hosts</secondary>
42577 </indexterm>
42578 If this option is set, and either the list of hosts is taken from the
42579 <option>hosts</option> or the <option>fallback_hosts</option> option, or the hosts supplied by the router
42580 were not obtained from MX records (this includes fallback hosts from the
42581 router), and were not randomized by the router, the order of trying the hosts
42582 is randomized each time the transport runs. Randomizing the order of a host
42583 list can be used to do crude load sharing.
42584 </para>
42585 <para>
42586 When <option>hosts_randomize</option> is true, a host list may be split into groups whose
42587 order is separately randomized. This makes it possible to set up MX-like
42588 behaviour. The boundaries between groups are indicated by an item that is just
42589 <literal>+</literal> in the host list. For example:
42590 </para>
42591 <literallayout class="monospaced">
42592 hosts = host1:host2:host3:+:host4:host5
42593 </literallayout>
42594 <para>
42595 The order of the first three hosts and the order of the last two hosts is
42596 randomized for each use, but the first three always end up before the last two.
42597 If <option>hosts_randomize</option> is not set, a <literal>+</literal> item in the list is ignored.
42598 </para>
42599 <para>
42600 <indexterm role="option">
42601 <primary><option>hosts_require_auth</option></primary>
42602 </indexterm>
42603 </para>
42604 <informaltable frame="all">
42605 <tgroup cols="4" colsep="0" rowsep="0">
42606 <colspec colwidth="8*" align="left"/>
42607 <colspec colwidth="6*" align="center"/>
42608 <colspec colwidth="6*" align="center"/>
42609 <colspec colwidth="6*" align="right"/>
42610 <tbody>
42611 <row>
42612 <entry><option>hosts_require_auth</option></entry>
42613 <entry>Use: <emphasis>smtp</emphasis></entry>
42614 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
42615 <entry>Default: <emphasis>unset</emphasis></entry>
42616 </row>
42617 </tbody>
42618 </tgroup>
42619 </informaltable>
42620 <para>
42621 <indexterm role="concept">
42622 <primary>authentication</primary>
42623 <secondary>required by client</secondary>
42624 </indexterm>
42625 This option provides a list of servers for which authentication must succeed
42626 before Exim will try to transfer a message. If authentication fails for
42627 servers which are not in this list, Exim tries to send unauthenticated. If
42628 authentication fails for one of these servers, delivery is deferred. This
42629 temporary error is detectable in the retry rules, so it can be turned into a
42630 hard failure if required. See also <option>hosts_try_auth</option>, and chapter
42631 <xref linkend="CHAPSMTPAUTH"/> for details of authentication.
42632 </para>
42633 <para>
42634 <indexterm role="option">
42635 <primary><option>hosts_require_tls</option></primary>
42636 </indexterm>
42637 </para>
42638 <informaltable frame="all">
42639 <tgroup cols="4" colsep="0" rowsep="0">
42640 <colspec colwidth="8*" align="left"/>
42641 <colspec colwidth="6*" align="center"/>
42642 <colspec colwidth="6*" align="center"/>
42643 <colspec colwidth="6*" align="right"/>
42644 <tbody>
42645 <row>
42646 <entry><option>hosts_require_tls</option></entry>
42647 <entry>Use: <emphasis>smtp</emphasis></entry>
42648 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
42649 <entry>Default: <emphasis>unset</emphasis></entry>
42650 </row>
42651 </tbody>
42652 </tgroup>
42653 </informaltable>
42654 <para>
42655 <indexterm role="concept">
42656 <primary>TLS</primary>
42657 <secondary>requiring for certain servers</secondary>
42658 </indexterm>
42659 Exim will insist on using a TLS session when delivering to any host that
42660 matches this list. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
42661 <emphasis role="bold">Note</emphasis>: This option affects outgoing mail only. To insist on TLS for
42662 incoming messages, use an appropriate ACL.
42663 </para>
42664 <para>
42665 <indexterm role="option">
42666 <primary><option>hosts_try_auth</option></primary>
42667 </indexterm>
42668 </para>
42669 <informaltable frame="all">
42670 <tgroup cols="4" colsep="0" rowsep="0">
42671 <colspec colwidth="8*" align="left"/>
42672 <colspec colwidth="6*" align="center"/>
42673 <colspec colwidth="6*" align="center"/>
42674 <colspec colwidth="6*" align="right"/>
42675 <tbody>
42676 <row>
42677 <entry><option>hosts_try_auth</option></entry>
42678 <entry>Use: <emphasis>smtp</emphasis></entry>
42679 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
42680 <entry>Default: <emphasis>unset</emphasis></entry>
42681 </row>
42682 </tbody>
42683 </tgroup>
42684 </informaltable>
42685 <para>
42686 <indexterm role="concept">
42687 <primary>authentication</primary>
42688 <secondary>optional in client</secondary>
42689 </indexterm>
42690 This option provides a list of servers to which, provided they announce
42691 authentication support, Exim will attempt to authenticate as a client when it
42692 connects. If authentication fails, Exim will try to transfer the message
42693 unauthenticated. See also <option>hosts_require_auth</option>, and chapter
42694 <xref linkend="CHAPSMTPAUTH"/> for details of authentication.
42695 </para>
42696 <para>
42697 <indexterm role="option">
42698 <primary><option>interface</option></primary>
42699 </indexterm>
42700 </para>
42701 <informaltable frame="all">
42702 <tgroup cols="4" colsep="0" rowsep="0">
42703 <colspec colwidth="8*" align="left"/>
42704 <colspec colwidth="6*" align="center"/>
42705 <colspec colwidth="6*" align="center"/>
42706 <colspec colwidth="6*" align="right"/>
42707 <tbody>
42708 <row>
42709 <entry><option>interface</option></entry>
42710 <entry>Use: <emphasis>smtp</emphasis></entry>
42711 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
42712 <entry>Default: <emphasis>unset</emphasis></entry>
42713 </row>
42714 </tbody>
42715 </tgroup>
42716 </informaltable>
42717 <para>
42718 <indexterm role="concept">
42719 <primary>bind IP address</primary>
42720 </indexterm>
42721 <indexterm role="concept">
42722 <primary>IP address</primary>
42723 <secondary>binding</secondary>
42724 </indexterm>
42725 <indexterm role="variable">
42726 <primary><varname>$host</varname></primary>
42727 </indexterm>
42728 <indexterm role="variable">
42729 <primary><varname>$host_address</varname></primary>
42730 </indexterm>
42731 This option specifies which interface to bind to when making an outgoing SMTP
42732 call. The value is an IP address, not an interface name such as
42733 <literal>eth0</literal>. Do not confuse this with the interface address that was used when a
42734 message was received, which is in <varname>$received_ip_address</varname>, formerly known as
42735 <varname>$interface_address</varname>. The name was changed to minimize confusion with the
42736 outgoing interface address. There is no variable that contains an outgoing
42737 interface address because, unless it is set by this option, its value is
42738 unknown.
42739 </para>
42740 <para>
42741 During the expansion of the <option>interface</option> option the variables <varname>$host</varname> and
42742 <varname>$host_address</varname> refer to the host to which a connection is about to be made
42743 during the expansion of the string. Forced expansion failure, or an empty
42744 string result causes the option to be ignored. Otherwise, after expansion, the
42745 string must be a list of IP addresses, colon-separated by default, but the
42746 separator can be changed in the usual way. For example:
42747 </para>
42748 <literallayout class="monospaced">
42749 interface = &lt;; 192.168.123.123 ; 3ffe:ffff:836f::fe86:a061
42750 </literallayout>
42751 <para>
42752 The first interface of the correct type (IPv4 or IPv6) is used for the outgoing
42753 connection. If none of them are the correct type, the option is ignored. If
42754 <option>interface</option> is not set, or is ignored, the system&#x2019;s IP functions choose which
42755 interface to use if the host has more than one.
42756 </para>
42757 <para>
42758 <indexterm role="option">
42759 <primary><option>keepalive</option></primary>
42760 </indexterm>
42761 </para>
42762 <informaltable frame="all">
42763 <tgroup cols="4" colsep="0" rowsep="0">
42764 <colspec colwidth="8*" align="left"/>
42765 <colspec colwidth="6*" align="center"/>
42766 <colspec colwidth="6*" align="center"/>
42767 <colspec colwidth="6*" align="right"/>
42768 <tbody>
42769 <row>
42770 <entry><option>keepalive</option></entry>
42771 <entry>Use: <emphasis>smtp</emphasis></entry>
42772 <entry>Type: <emphasis>boolean</emphasis></entry>
42773 <entry>Default: <emphasis>true</emphasis></entry>
42774 </row>
42775 </tbody>
42776 </tgroup>
42777 </informaltable>
42778 <para>
42779 <indexterm role="concept">
42780 <primary>keepalive</primary>
42781 <secondary>on outgoing connection</secondary>
42782 </indexterm>
42783 This option controls the setting of SO_KEEPALIVE on outgoing TCP/IP socket
42784 connections. When set, it causes the kernel to probe idle connections
42785 periodically, by sending packets with <quote>old</quote> sequence numbers. The other end
42786 of the connection should send a acknowledgment if the connection is still okay
42787 or a reset if the connection has been aborted. The reason for doing this is
42788 that it has the beneficial effect of freeing up certain types of connection
42789 that can get stuck when the remote host is disconnected without tidying up the
42790 TCP/IP call properly. The keepalive mechanism takes several hours to detect
42791 unreachable hosts.
42792 </para>
42793 <para>
42794 <indexterm role="option">
42795 <primary><option>lmtp_ignore_quota</option></primary>
42796 </indexterm>
42797 </para>
42798 <informaltable frame="all">
42799 <tgroup cols="4" colsep="0" rowsep="0">
42800 <colspec colwidth="8*" align="left"/>
42801 <colspec colwidth="6*" align="center"/>
42802 <colspec colwidth="6*" align="center"/>
42803 <colspec colwidth="6*" align="right"/>
42804 <tbody>
42805 <row>
42806 <entry><option>lmtp_ignore_quota</option></entry>
42807 <entry>Use: <emphasis>smtp</emphasis></entry>
42808 <entry>Type: <emphasis>boolean</emphasis></entry>
42809 <entry>Default: <emphasis>false</emphasis></entry>
42810 </row>
42811 </tbody>
42812 </tgroup>
42813 </informaltable>
42814 <para>
42815 <indexterm role="concept">
42816 <primary>LMTP</primary>
42817 <secondary>ignoring quota errors</secondary>
42818 </indexterm>
42819 If this option is set true when the <option>protocol</option> option is set to <quote>lmtp</quote>, the
42820 string <literal>IGNOREQUOTA</literal> is added to RCPT commands, provided that the LMTP server
42821 has advertised support for IGNOREQUOTA in its response to the LHLO command.
42822 </para>
42823 <para>
42824 <indexterm role="option">
42825 <primary><option>max_rcpt</option></primary>
42826 </indexterm>
42827 </para>
42828 <informaltable frame="all">
42829 <tgroup cols="4" colsep="0" rowsep="0">
42830 <colspec colwidth="8*" align="left"/>
42831 <colspec colwidth="6*" align="center"/>
42832 <colspec colwidth="6*" align="center"/>
42833 <colspec colwidth="6*" align="right"/>
42834 <tbody>
42835 <row>
42836 <entry><option>max_rcpt</option></entry>
42837 <entry>Use: <emphasis>smtp</emphasis></entry>
42838 <entry>Type: <emphasis>integer</emphasis></entry>
42839 <entry>Default: <emphasis>100</emphasis></entry>
42840 </row>
42841 </tbody>
42842 </tgroup>
42843 </informaltable>
42844 <para>
42845 <indexterm role="concept">
42846 <primary>RCPT</primary>
42847 <secondary>maximum number of outgoing</secondary>
42848 </indexterm>
42849 This option limits the number of RCPT commands that are sent in a single
42850 SMTP message transaction. Each set of addresses is treated independently, and
42851 so can cause parallel connections to the same host if <option>remote_max_parallel</option>
42852 permits this.
42853 </para>
42854 <para>
42855 <indexterm role="option">
42856 <primary><option>multi_domain</option></primary>
42857 </indexterm>
42858 </para>
42859 <informaltable frame="all">
42860 <tgroup cols="4" colsep="0" rowsep="0">
42861 <colspec colwidth="8*" align="left"/>
42862 <colspec colwidth="6*" align="center"/>
42863 <colspec colwidth="6*" align="center"/>
42864 <colspec colwidth="6*" align="right"/>
42865 <tbody>
42866 <row>
42867 <entry><option>multi_domain</option></entry>
42868 <entry>Use: <emphasis>smtp</emphasis></entry>
42869 <entry>Type: <emphasis>boolean</emphasis></entry>
42870 <entry>Default: <emphasis>true</emphasis></entry>
42871 </row>
42872 </tbody>
42873 </tgroup>
42874 </informaltable>
42875 <para>
42876 <indexterm role="variable">
42877 <primary><varname>$domain</varname></primary>
42878 </indexterm>
42879 When this option is set, the <command>smtp</command> transport can handle a number of
42880 addresses containing a mixture of different domains provided they all resolve
42881 to the same list of hosts. Turning the option off restricts the transport to
42882 handling only one domain at a time. This is useful if you want to use
42883 <varname>$domain</varname> in an expansion for the transport, because it is set only when there
42884 is a single domain involved in a remote delivery.
42885 </para>
42886 <para>
42887 <indexterm role="option">
42888 <primary><option>port</option></primary>
42889 </indexterm>
42890 </para>
42891 <informaltable frame="all">
42892 <tgroup cols="4" colsep="0" rowsep="0">
42893 <colspec colwidth="8*" align="left"/>
42894 <colspec colwidth="6*" align="center"/>
42895 <colspec colwidth="6*" align="center"/>
42896 <colspec colwidth="6*" align="right"/>
42897 <tbody>
42898 <row>
42899 <entry><option>port</option></entry>
42900 <entry>Use: <emphasis>smtp</emphasis></entry>
42901 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
42902 <entry>Default: <emphasis>see below</emphasis></entry>
42903 </row>
42904 </tbody>
42905 </tgroup>
42906 </informaltable>
42907 <para>
42908 <indexterm role="concept">
42909 <primary>port</primary>
42910 <secondary>sending TCP/IP</secondary>
42911 </indexterm>
42912 <indexterm role="concept">
42913 <primary>TCP/IP</primary>
42914 <secondary>setting outgoing port</secondary>
42915 </indexterm>
42916 This option specifies the TCP/IP port on the server to which Exim connects.
42917 <emphasis role="bold">Note:</emphasis> Do not confuse this with the port that was used when a message was
42918 received, which is in <varname>$received_port</varname>, formerly known as <varname>$interface_port</varname>.
42919 The name was changed to minimize confusion with the outgoing port. There is no
42920 variable that contains an outgoing port.
42921 </para>
42922 <para>
42923 If the value of this option begins with a digit it is taken as a port number;
42924 otherwise it is looked up using <function>getservbyname()</function>. The default value is
42925 normally <quote>smtp</quote>, but if <option>protocol</option> is set to <quote>lmtp</quote>, the default is
42926 <quote>lmtp</quote>. If the expansion fails, or if a port number cannot be found, delivery
42927 is deferred.
42928 </para>
42929 <para>
42930 <indexterm role="option">
42931 <primary><option>protocol</option></primary>
42932 </indexterm>
42933 </para>
42934 <informaltable frame="all">
42935 <tgroup cols="4" colsep="0" rowsep="0">
42936 <colspec colwidth="8*" align="left"/>
42937 <colspec colwidth="6*" align="center"/>
42938 <colspec colwidth="6*" align="center"/>
42939 <colspec colwidth="6*" align="right"/>
42940 <tbody>
42941 <row>
42942 <entry><option>protocol</option></entry>
42943 <entry>Use: <emphasis>smtp</emphasis></entry>
42944 <entry>Type: <emphasis>string</emphasis></entry>
42945 <entry>Default: <emphasis>smtp</emphasis></entry>
42946 </row>
42947 </tbody>
42948 </tgroup>
42949 </informaltable>
42950 <para>
42951 <indexterm role="concept">
42952 <primary>LMTP</primary>
42953 <secondary>over TCP/IP</secondary>
42954 </indexterm>
42955 If this option is set to <quote>lmtp</quote> instead of <quote>smtp</quote>, the default value for
42956 the <option>port</option> option changes to <quote>lmtp</quote>, and the transport operates the LMTP
42957 protocol (RFC 2033) instead of SMTP. This protocol is sometimes used for local
42958 deliveries into closed message stores. Exim also has support for running LMTP
42959 over a pipe to a local process &ndash; see chapter <xref linkend="CHAPLMTP"/>.
42960 </para>
42961 <para>
42962 <indexterm role="option">
42963 <primary><option>retry_include_ip_address</option></primary>
42964 </indexterm>
42965 </para>
42966 <informaltable frame="all">
42967 <tgroup cols="4" colsep="0" rowsep="0">
42968 <colspec colwidth="8*" align="left"/>
42969 <colspec colwidth="6*" align="center"/>
42970 <colspec colwidth="6*" align="center"/>
42971 <colspec colwidth="6*" align="right"/>
42972 <tbody>
42973 <row>
42974 <entry><option>retry_include_ip_address</option></entry>
42975 <entry>Use: <emphasis>smtp</emphasis></entry>
42976 <entry>Type: <emphasis>boolean</emphasis></entry>
42977 <entry>Default: <emphasis>true</emphasis></entry>
42978 </row>
42979 </tbody>
42980 </tgroup>
42981 </informaltable>
42982 <para>
42983 Exim normally includes both the host name and the IP address in the key it
42984 constructs for indexing retry data after a temporary delivery failure. This
42985 means that when one of several IP addresses for a host is failing, it gets
42986 tried periodically (controlled by the retry rules), but use of the other IP
42987 addresses is not affected.
42988 </para>
42989 <para>
42990 However, in some dialup environments hosts are assigned a different IP address
42991 each time they connect. In this situation the use of the IP address as part of
42992 the retry key leads to undesirable behaviour. Setting this option false causes
42993 Exim to use only the host name. This should normally be done on a separate
42994 instance of the <command>smtp</command> transport, set up specially to handle the dialup
42995 hosts.
42996 </para>
42997 <para>
42998 <indexterm role="option">
42999 <primary><option>serialize_hosts</option></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="6*" align="center"/>
43006 <colspec colwidth="6*" align="center"/>
43007 <colspec colwidth="6*" align="right"/>
43008 <tbody>
43009 <row>
43010 <entry><option>serialize_hosts</option></entry>
43011 <entry>Use: <emphasis>smtp</emphasis></entry>
43012 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
43013 <entry>Default: <emphasis>unset</emphasis></entry>
43014 </row>
43015 </tbody>
43016 </tgroup>
43017 </informaltable>
43018 <para>
43019 <indexterm role="concept">
43020 <primary>serializing connections</primary>
43021 </indexterm>
43022 <indexterm role="concept">
43023 <primary>host</primary>
43024 <secondary>serializing connections</secondary>
43025 </indexterm>
43026 Because Exim operates in a distributed manner, if several messages for the same
43027 host arrive at around the same time, more than one simultaneous connection to
43028 the remote host can occur. This is not usually a problem except when there is a
43029 slow link between the hosts. In that situation it may be helpful to restrict
43030 Exim to one connection at a time. This can be done by setting
43031 <option>serialize_hosts</option> to match the relevant hosts.
43032 </para>
43033 <para>
43034 <indexterm role="concept">
43035 <primary>hints database</primary>
43036 <secondary>serializing deliveries to a host</secondary>
43037 </indexterm>
43038 Exim implements serialization by means of a hints database in which a record is
43039 written whenever a process connects to one of the restricted hosts. The record
43040 is deleted when the connection is completed. Obviously there is scope for
43041 records to get left lying around if there is a system or program crash. To
43042 guard against this, Exim ignores any records that are more than six hours old.
43043 </para>
43044 <para>
43045 If you set up this kind of serialization, you should also arrange to delete the
43046 relevant hints database whenever your system reboots. The names of the files
43047 start with <filename>misc</filename> and they are kept in the <filename>spool/db</filename> directory. There
43048 may be one or two files, depending on the type of DBM in use. The same files
43049 are used for ETRN serialization.
43050 </para>
43051 <para>
43052 <indexterm role="option">
43053 <primary><option>size_addition</option></primary>
43054 </indexterm>
43055 </para>
43056 <informaltable frame="all">
43057 <tgroup cols="4" colsep="0" rowsep="0">
43058 <colspec colwidth="8*" align="left"/>
43059 <colspec colwidth="6*" align="center"/>
43060 <colspec colwidth="6*" align="center"/>
43061 <colspec colwidth="6*" align="right"/>
43062 <tbody>
43063 <row>
43064 <entry><option>size_addition</option></entry>
43065 <entry>Use: <emphasis>smtp</emphasis></entry>
43066 <entry>Type: <emphasis>integer</emphasis></entry>
43067 <entry>Default: <emphasis>1024</emphasis></entry>
43068 </row>
43069 </tbody>
43070 </tgroup>
43071 </informaltable>
43072 <para>
43073 <indexterm role="concept">
43074 <primary>SMTP</primary>
43075 <secondary>SIZE</secondary>
43076 </indexterm>
43077 <indexterm role="concept">
43078 <primary>message</primary>
43079 <secondary>size issue for transport filter</secondary>
43080 </indexterm>
43081 <indexterm role="concept">
43082 <primary>size</primary>
43083 <secondary>of message</secondary>
43084 </indexterm>
43085 <indexterm role="concept">
43086 <primary>transport</primary>
43087 <secondary>filter</secondary>
43088 </indexterm>
43089 <indexterm role="concept">
43090 <primary>filter</primary>
43091 <secondary>transport filter</secondary>
43092 </indexterm>
43093 If a remote SMTP server indicates that it supports the SIZE option of the
43094 MAIL command, Exim uses this to pass over the message size at the start of
43095 an SMTP transaction. It adds the value of <option>size_addition</option> to the value it
43096 sends, to allow for headers and other text that may be added during delivery by
43097 configuration options or in a transport filter. It may be necessary to increase
43098 this if a lot of text is added to messages.
43099 </para>
43100 <para>
43101 Alternatively, if the value of <option>size_addition</option> is set negative, it disables
43102 the use of the SIZE option altogether.
43103 </para>
43104 <para>
43105 <indexterm role="option">
43106 <primary><option>tls_certificate</option></primary>
43107 </indexterm>
43108 </para>
43109 <informaltable frame="all">
43110 <tgroup cols="4" colsep="0" rowsep="0">
43111 <colspec colwidth="8*" align="left"/>
43112 <colspec colwidth="6*" align="center"/>
43113 <colspec colwidth="6*" align="center"/>
43114 <colspec colwidth="6*" align="right"/>
43115 <tbody>
43116 <row>
43117 <entry><option>tls_certificate</option></entry>
43118 <entry>Use: <emphasis>smtp</emphasis></entry>
43119 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43120 <entry>Default: <emphasis>unset</emphasis></entry>
43121 </row>
43122 </tbody>
43123 </tgroup>
43124 </informaltable>
43125 <para>
43126 <indexterm role="concept">
43127 <primary>TLS</primary>
43128 <secondary>client certificate, location of</secondary>
43129 </indexterm>
43130 <indexterm role="concept">
43131 <primary>certificate</primary>
43132 <secondary>client, location of</secondary>
43133 </indexterm>
43134 <indexterm role="variable">
43135 <primary><varname>$host</varname></primary>
43136 </indexterm>
43137 <indexterm role="variable">
43138 <primary><varname>$host_address</varname></primary>
43139 </indexterm>
43140 The value of this option must be the absolute path to a file which contains the
43141 client&#x2019;s certificate, for possible use when sending a message over an encrypted
43142 connection. The values of <varname>$host</varname> and <varname>$host_address</varname> are set to the name and
43143 address of the server during the expansion. See chapter <xref linkend="CHAPTLS"/> for
43144 details of TLS.
43145 </para>
43146 <para>
43147 <emphasis role="bold">Note</emphasis>: This option must be set if you want Exim to be able to use a TLS
43148 certificate when sending messages as a client. The global option of the same
43149 name specifies the certificate for Exim as a server; it is not automatically
43150 assumed that the same certificate should be used when Exim is operating as a
43151 client.
43152 </para>
43153 <para>
43154 <indexterm role="option">
43155 <primary><option>tls_crl</option></primary>
43156 </indexterm>
43157 </para>
43158 <informaltable frame="all">
43159 <tgroup cols="4" colsep="0" rowsep="0">
43160 <colspec colwidth="8*" align="left"/>
43161 <colspec colwidth="6*" align="center"/>
43162 <colspec colwidth="6*" align="center"/>
43163 <colspec colwidth="6*" align="right"/>
43164 <tbody>
43165 <row>
43166 <entry><option>tls_crl</option></entry>
43167 <entry>Use: <emphasis>smtp</emphasis></entry>
43168 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43169 <entry>Default: <emphasis>unset</emphasis></entry>
43170 </row>
43171 </tbody>
43172 </tgroup>
43173 </informaltable>
43174 <para>
43175 <indexterm role="concept">
43176 <primary>TLS</primary>
43177 <secondary>client certificate revocation list</secondary>
43178 </indexterm>
43179 <indexterm role="concept">
43180 <primary>certificate</primary>
43181 <secondary>revocation list for client</secondary>
43182 </indexterm>
43183 This option specifies a certificate revocation list. The expanded value must
43184 be the name of a file that contains a CRL in PEM format.
43185 </para>
43186 <para>
43187 <indexterm role="option">
43188 <primary><option>tls_privatekey</option></primary>
43189 </indexterm>
43190 </para>
43191 <informaltable frame="all">
43192 <tgroup cols="4" colsep="0" rowsep="0">
43193 <colspec colwidth="8*" align="left"/>
43194 <colspec colwidth="6*" align="center"/>
43195 <colspec colwidth="6*" align="center"/>
43196 <colspec colwidth="6*" align="right"/>
43197 <tbody>
43198 <row>
43199 <entry><option>tls_privatekey</option></entry>
43200 <entry>Use: <emphasis>smtp</emphasis></entry>
43201 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43202 <entry>Default: <emphasis>unset</emphasis></entry>
43203 </row>
43204 </tbody>
43205 </tgroup>
43206 </informaltable>
43207 <para>
43208 <indexterm role="concept">
43209 <primary>TLS</primary>
43210 <secondary>client private key, location of</secondary>
43211 </indexterm>
43212 <indexterm role="variable">
43213 <primary><varname>$host</varname></primary>
43214 </indexterm>
43215 <indexterm role="variable">
43216 <primary><varname>$host_address</varname></primary>
43217 </indexterm>
43218 The value of this option must be the absolute path to a file which contains the
43219 client&#x2019;s private key. This is used when sending a message over an encrypted
43220 connection using a client certificate. The values of <varname>$host</varname> and
43221 <varname>$host_address</varname> are set to the name and address of the server during the
43222 expansion. If this option is unset, or the expansion is forced to fail, or the
43223 result is an empty string, the private key is assumed to be in the same file as
43224 the certificate. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
43225 </para>
43226 <para>
43227 <indexterm role="option">
43228 <primary><option>tls_require_ciphers</option></primary>
43229 </indexterm>
43230 </para>
43231 <informaltable frame="all">
43232 <tgroup cols="4" colsep="0" rowsep="0">
43233 <colspec colwidth="8*" align="left"/>
43234 <colspec colwidth="6*" align="center"/>
43235 <colspec colwidth="6*" align="center"/>
43236 <colspec colwidth="6*" align="right"/>
43237 <tbody>
43238 <row>
43239 <entry><option>tls_require_ciphers</option></entry>
43240 <entry>Use: <emphasis>smtp</emphasis></entry>
43241 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43242 <entry>Default: <emphasis>unset</emphasis></entry>
43243 </row>
43244 </tbody>
43245 </tgroup>
43246 </informaltable>
43247 <para>
43248 <indexterm role="concept">
43249 <primary>TLS</primary>
43250 <secondary>requiring specific ciphers</secondary>
43251 </indexterm>
43252 <indexterm role="concept">
43253 <primary>cipher</primary>
43254 <secondary>requiring specific</secondary>
43255 </indexterm>
43256 <indexterm role="variable">
43257 <primary><varname>$host</varname></primary>
43258 </indexterm>
43259 <indexterm role="variable">
43260 <primary><varname>$host_address</varname></primary>
43261 </indexterm>
43262 The value of this option must be a list of permitted cipher suites, for use
43263 when setting up an outgoing encrypted connection. (There is a global option of
43264 the same name for controlling incoming connections.) The values of <varname>$host</varname> and
43265 <varname>$host_address</varname> are set to the name and address of the server during the
43266 expansion. See chapter <xref linkend="CHAPTLS"/> for details of TLS; note that this option
43267 is used in different ways by OpenSSL and GnuTLS (see sections
43268 <xref linkend="SECTreqciphssl"/> and <xref linkend="SECTreqciphgnu"/>). For GnuTLS, the order of the
43269 ciphers is a preference order.
43270 </para>
43271 <para>
43272 <indexterm role="option">
43273 <primary><option>tls_tempfail_tryclear</option></primary>
43274 </indexterm>
43275 </para>
43276 <informaltable frame="all">
43277 <tgroup cols="4" colsep="0" rowsep="0">
43278 <colspec colwidth="8*" align="left"/>
43279 <colspec colwidth="6*" align="center"/>
43280 <colspec colwidth="6*" align="center"/>
43281 <colspec colwidth="6*" align="right"/>
43282 <tbody>
43283 <row>
43284 <entry><option>tls_tempfail_tryclear</option></entry>
43285 <entry>Use: <emphasis>smtp</emphasis></entry>
43286 <entry>Type: <emphasis>boolean</emphasis></entry>
43287 <entry>Default: <emphasis>true</emphasis></entry>
43288 </row>
43289 </tbody>
43290 </tgroup>
43291 </informaltable>
43292 <para>
43293 <indexterm role="concept">
43294 <primary>4<emphasis>xx</emphasis> responses</primary>
43295 <secondary>to STARTTLS</secondary>
43296 </indexterm>
43297 When the server host is not in <option>hosts_require_tls</option>, and there is a problem in
43298 setting up a TLS session, this option determines whether or not Exim should try
43299 to deliver the message unencrypted. If it is set false, delivery to the
43300 current host is deferred; if there are other hosts, they are tried. If this
43301 option is set true, Exim attempts to deliver unencrypted after a 4<emphasis>xx</emphasis>
43302 response to STARTTLS. Also, if STARTTLS is accepted, but the subsequent
43303 TLS negotiation fails, Exim closes the current connection (because it is in an
43304 unknown state), opens a new one to the same host, and then tries the delivery
43305 in clear.
43306 </para>
43307 <para>
43308 <indexterm role="option">
43309 <primary><option>tls_verify_certificates</option></primary>
43310 </indexterm>
43311 </para>
43312 <informaltable frame="all">
43313 <tgroup cols="4" colsep="0" rowsep="0">
43314 <colspec colwidth="8*" align="left"/>
43315 <colspec colwidth="6*" align="center"/>
43316 <colspec colwidth="6*" align="center"/>
43317 <colspec colwidth="6*" align="right"/>
43318 <tbody>
43319 <row>
43320 <entry><option>tls_verify_certificates</option></entry>
43321 <entry>Use: <emphasis>smtp</emphasis></entry>
43322 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43323 <entry>Default: <emphasis>unset</emphasis></entry>
43324 </row>
43325 </tbody>
43326 </tgroup>
43327 </informaltable>
43328 <para>
43329 <indexterm role="concept">
43330 <primary>TLS</primary>
43331 <secondary>server certificate verification</secondary>
43332 </indexterm>
43333 <indexterm role="concept">
43334 <primary>certificate</primary>
43335 <secondary>verification of server</secondary>
43336 </indexterm>
43337 <indexterm role="variable">
43338 <primary><varname>$host</varname></primary>
43339 </indexterm>
43340 <indexterm role="variable">
43341 <primary><varname>$host_address</varname></primary>
43342 </indexterm>
43343 The value of this option must be the absolute path to a file containing
43344 permitted server certificates, for use when setting up an encrypted connection.
43345 Alternatively, if you are using OpenSSL, you can set
43346 <option>tls_verify_certificates</option> to the name of a directory containing certificate
43347 files. This does not work with GnuTLS; the option must be set to the name of a
43348 single file if you are using GnuTLS. The values of <varname>$host</varname> and
43349 <varname>$host_address</varname> are set to the name and address of the server during the
43350 expansion of this option. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
43351 </para>
43352 </section>
43353 <section id="SECTvalhosmax">
43354 <title>How the limits for the number of hosts to try are used</title>
43355 <para>
43356 <indexterm role="concept">
43357 <primary>host</primary>
43358 <secondary>maximum number to try</secondary>
43359 </indexterm>
43360 <indexterm role="concept">
43361 <primary>limit</primary>
43362 <secondary>hosts; maximum number tried</secondary>
43363 </indexterm>
43364 There are two options that are concerned with the number of hosts that are
43365 tried when an SMTP delivery takes place. They are <option>hosts_max_try</option> and
43366 <option>hosts_max_try_hardlimit</option>.
43367 </para>
43368 <para>
43369 The <option>hosts_max_try</option> option limits the number of hosts that are tried
43370 for a single delivery. However, despite the term <quote>host</quote> in its name, the
43371 option actually applies to each IP address independently. In other words, a
43372 multihomed host is treated as several independent hosts, just as it is for
43373 retrying.
43374 </para>
43375 <para>
43376 Many of the larger ISPs have multiple MX records which often point to
43377 multihomed hosts. As a result, a list of a dozen or more IP addresses may be
43378 created as a result of routing one of these domains.
43379 </para>
43380 <para>
43381 Trying every single IP address on such a long list does not seem sensible; if
43382 several at the top of the list fail, it is reasonable to assume there is some
43383 problem that is likely to affect all of them. Roughly speaking, the value of
43384 <option>hosts_max_try</option> is the maximum number that are tried before deferring the
43385 delivery. However, the logic cannot be quite that simple.
43386 </para>
43387 <para>
43388 Firstly, IP addresses that are skipped because their retry times have not
43389 arrived do not count, and in addition, addresses that are past their retry
43390 limits are also not counted, even when they are tried. This means that when
43391 some IP addresses are past their retry limits, more than the value of
43392 <option>hosts_max_retry</option> may be tried. The reason for this behaviour is to ensure
43393 that all IP addresses are considered before timing out an email address (but
43394 see below for an exception).
43395 </para>
43396 <para>
43397 Secondly, when the <option>hosts_max_try</option> limit is reached, Exim looks down the host
43398 list to see if there is a subsequent host with a different (higher valued) MX.
43399 If there is, that host is considered next, and the current IP address is used
43400 but not counted. This behaviour helps in the case of a domain with a retry rule
43401 that hardly ever delays any hosts, as is now explained:
43402 </para>
43403 <para>
43404 Consider the case of a long list of hosts with one MX value, and a few with a
43405 higher MX value. If <option>hosts_max_try</option> is small (the default is 5) only a few
43406 hosts at the top of the list are tried at first. With the default retry rule,
43407 which specifies increasing retry times, the higher MX hosts are eventually
43408 tried when those at the top of the list are skipped because they have not
43409 reached their retry times.
43410 </para>
43411 <para>
43412 However, it is common practice to put a fixed short retry time on domains for
43413 large ISPs, on the grounds that their servers are rarely down for very long.
43414 Unfortunately, these are exactly the domains that tend to resolve to long lists
43415 of hosts. The short retry time means that the lowest MX hosts are tried every
43416 time. The attempts may be in a different order because of random sorting, but
43417 without the special MX check, the higher MX hosts would never be tried until
43418 all the lower MX hosts had timed out (which might be several days), because
43419 there are always some lower MX hosts that have reached their retry times. With
43420 the special check, Exim considers at least one IP address from each MX value at
43421 every delivery attempt, even if the <option>hosts_max_try</option> limit has already been
43422 reached.
43423 </para>
43424 <para>
43425 The above logic means that <option>hosts_max_try</option> is not a hard limit, and in
43426 particular, Exim normally eventually tries all the IP addresses before timing
43427 out an email address. When <option>hosts_max_try</option> was implemented, this seemed a
43428 reasonable thing to do. Recently, however, some lunatic DNS configurations have
43429 been set up with hundreds of IP addresses for some domains. It can
43430 take a very long time indeed for an address to time out in these cases.
43431 </para>
43432 <para>
43433 The <option>hosts_max_try_hardlimit</option> option was added to help with this problem.
43434 Exim never tries more than this number of IP addresses; if it hits this limit
43435 and they are all timed out, the email address is bounced, even though not all
43436 possible IP addresses have been tried.
43437 <indexterm role="concept" startref="IIDsmttra1" class="endofrange"/>
43438 <indexterm role="concept" startref="IIDsmttra2" class="endofrange"/>
43439 </para>
43440 </section>
43441 </chapter>
43442
43443 <chapter id="CHAPrewrite">
43444 <title>Address rewriting</title>
43445 <para>
43446 <indexterm role="concept" id="IIDaddrew" class="startofrange">
43447 <primary>rewriting</primary>
43448 <secondary>addresses</secondary>
43449 </indexterm>
43450 There are some circumstances in which Exim automatically rewrites domains in
43451 addresses. The two most common are when an address is given without a domain
43452 (referred to as an <quote>unqualified address</quote>) or when an address contains an
43453 abbreviated domain that is expanded by DNS lookup.
43454 </para>
43455 <para>
43456 Unqualified envelope addresses are accepted only for locally submitted
43457 messages, or for messages that are received from hosts matching
43458 <option>sender_unqualified_hosts</option> or <option>recipient_unqualified_hosts</option>, as
43459 appropriate. Unqualified addresses in header lines are qualified if they are in
43460 locally submitted messages, or messages from hosts that are permitted to send
43461 unqualified envelope addresses. Otherwise, unqualified addresses in header
43462 lines are neither qualified nor rewritten.
43463 </para>
43464 <para>
43465 One situation in which Exim does <emphasis>not</emphasis> automatically rewrite a domain is
43466 when it is the name of a CNAME record in the DNS. The older RFCs suggest that
43467 such a domain should be rewritten using the <quote>canonical</quote> name, and some MTAs
43468 do this. The new RFCs do not contain this suggestion.
43469 </para>
43470 <section id="SECID147">
43471 <title>Explicitly configured address rewriting</title>
43472 <para>
43473 This chapter describes the rewriting rules that can be used in the
43474 main rewrite section of the configuration file, and also in the generic
43475 <option>headers_rewrite</option> option that can be set on any transport.
43476 </para>
43477 <para>
43478 Some people believe that configured address rewriting is a Mortal Sin.
43479 Others believe that life is not possible without it. Exim provides the
43480 facility; you do not have to use it.
43481 </para>
43482 <para>
43483 The main rewriting rules that appear in the <quote>rewrite</quote> section of the
43484 configuration file are applied to addresses in incoming messages, both envelope
43485 addresses and addresses in header lines. Each rule specifies the types of
43486 address to which it applies.
43487 </para>
43488 <para>
43489 Whether or not addresses in header lines are rewritten depends on the origin of
43490 the headers and the type of rewriting. Global rewriting, that is, rewriting
43491 rules from the rewrite section of the configuration file, is applied only to
43492 those headers that were received with the message. Header lines that are added
43493 by ACLs or by a system filter or by individual routers or transports (which
43494 are specific to individual recipient addresses) are not rewritten by the global
43495 rules.
43496 </para>
43497 <para>
43498 Rewriting at transport time, by means of the <option>headers_rewrite</option> option,
43499 applies all headers except those added by routers and transports. That is, as
43500 well as the headers that were received with the message, it also applies to
43501 headers that were added by an ACL or a system filter.
43502 </para>
43503 <para>
43504 In general, rewriting addresses from your own system or domain has some
43505 legitimacy. Rewriting other addresses should be done only with great care and
43506 in special circumstances. The author of Exim believes that rewriting should be
43507 used sparingly, and mainly for <quote>regularizing</quote> addresses in your own domains.
43508 Although it can sometimes be used as a routing tool, this is very strongly
43509 discouraged.
43510 </para>
43511 <para>
43512 There are two commonly encountered circumstances where rewriting is used, as
43513 illustrated by these examples:
43514 </para>
43515 <itemizedlist>
43516 <listitem>
43517 <para>
43518 The company whose domain is <emphasis>hitch.fict.example</emphasis> has a number of hosts that
43519 exchange mail with each other behind a firewall, but there is only a single
43520 gateway to the outer world. The gateway rewrites <emphasis>*.hitch.fict.example</emphasis> as
43521 <emphasis>hitch.fict.example</emphasis> when sending mail off-site.
43522 </para>
43523 </listitem>
43524 <listitem>
43525 <para>
43526 A host rewrites the local parts of its own users so that, for example,
43527 <emphasis>fp42@hitch.fict.example</emphasis> becomes <emphasis>Ford.Prefect@hitch.fict.example</emphasis>.
43528 </para>
43529 </listitem>
43530 </itemizedlist>
43531 </section>
43532 <section id="SECID148">
43533 <title>When does rewriting happen?</title>
43534 <para>
43535 <indexterm role="concept">
43536 <primary>rewriting</primary>
43537 <secondary>timing of</secondary>
43538 </indexterm>
43539 <indexterm role="concept">
43540 <primary>access control lists (ACLs)</primary>
43541 <secondary>rewriting addresses in</secondary>
43542 </indexterm>
43543 Configured address rewriting can take place at several different stages of a
43544 message&#x2019;s processing.
43545 </para>
43546 <para>
43547 <indexterm role="variable">
43548 <primary><varname>$sender_address</varname></primary>
43549 </indexterm>
43550 At the start of an ACL for MAIL, the sender address may have been rewritten
43551 by a special SMTP-time rewrite rule (see section <xref linkend="SECTrewriteS"/>), but no
43552 ordinary rewrite rules have yet been applied. If, however, the sender address
43553 is verified in the ACL, it is rewritten before verification, and remains
43554 rewritten thereafter. The subsequent value of <varname>$sender_address</varname> is the
43555 rewritten address. This also applies if sender verification happens in a
43556 RCPT ACL. Otherwise, when the sender address is not verified, it is
43557 rewritten as soon as a message&#x2019;s header lines have been received.
43558 </para>
43559 <para>
43560 <indexterm role="variable">
43561 <primary><varname>$domain</varname></primary>
43562 </indexterm>
43563 <indexterm role="variable">
43564 <primary><varname>$local_part</varname></primary>
43565 </indexterm>
43566 Similarly, at the start of an ACL for RCPT, the current recipient&#x2019;s address
43567 may have been rewritten by a special SMTP-time rewrite rule, but no ordinary
43568 rewrite rules have yet been applied to it. However, the behaviour is different
43569 from the sender address when a recipient is verified. The address is rewritten
43570 for the verification, but the rewriting is not remembered at this stage. The
43571 value of <varname>$local_part</varname> and <varname>$domain</varname> after verification are always the same
43572 as they were before (that is, they contain the unrewritten &ndash; except for
43573 SMTP-time rewriting &ndash; address).
43574 </para>
43575 <para>
43576 As soon as a message&#x2019;s header lines have been received, all the envelope
43577 recipient addresses are permanently rewritten, and rewriting is also applied to
43578 the addresses in the header lines (if configured). This happens before adding
43579 any header lines that were specified in MAIL or RCPT ACLs, and
43580 <indexterm role="concept">
43581 <primary><function>local_scan()</function> function</primary>
43582 <secondary>address rewriting; timing of</secondary>
43583 </indexterm>
43584 before the DATA ACL and <function>local_scan()</function> functions are run.
43585 </para>
43586 <para>
43587 When an address is being routed, either for delivery or for verification,
43588 rewriting is applied immediately to child addresses that are generated by
43589 redirection, unless <option>no_rewrite</option> is set on the router.
43590 </para>
43591 <para>
43592 <indexterm role="concept">
43593 <primary>envelope sender</primary>
43594 <secondary>rewriting at transport time</secondary>
43595 </indexterm>
43596 <indexterm role="concept">
43597 <primary>rewriting</primary>
43598 <secondary>at transport time</secondary>
43599 </indexterm>
43600 <indexterm role="concept">
43601 <primary>header lines</primary>
43602 <secondary>rewriting at transport time</secondary>
43603 </indexterm>
43604 At transport time, additional rewriting of addresses in header lines can be
43605 specified by setting the generic <option>headers_rewrite</option> option on a transport.
43606 This option contains rules that are identical in form to those in the rewrite
43607 section of the configuration file. They are applied to the original message
43608 header lines and any that were added by ACLs or a system filter. They are not
43609 applied to header lines that are added by routers or the transport.
43610 </para>
43611 <para>
43612 The outgoing envelope sender can be rewritten by means of the <option>return_path</option>
43613 transport option. However, it is not possible to rewrite envelope recipients at
43614 transport time.
43615 </para>
43616 </section>
43617 <section id="SECID149">
43618 <title>Testing the rewriting rules that apply on input</title>
43619 <para>
43620 <indexterm role="concept">
43621 <primary>rewriting</primary>
43622 <secondary>testing</secondary>
43623 </indexterm>
43624 <indexterm role="concept">
43625 <primary>testing</primary>
43626 <secondary>rewriting</secondary>
43627 </indexterm>
43628 Exim&#x2019;s input rewriting configuration appears in a part of the run time
43629 configuration file headed by <quote>begin rewrite</quote>. It can be tested by the
43630 <option>-brw</option> command line option. This takes an address (which can be a full RFC
43631 2822 address) as its argument. The output is a list of how the address would be
43632 transformed by the rewriting rules for each of the different places it might
43633 appear in an incoming message, that is, for each different header and for the
43634 envelope sender and recipient fields. For example,
43635 </para>
43636 <literallayout class="monospaced">
43637 exim -brw ph10@exim.workshop.example
43638 </literallayout>
43639 <para>
43640 might produce the output
43641 </para>
43642 <literallayout class="monospaced">
43643 sender: Philip.Hazel@exim.workshop.example
43644 from: Philip.Hazel@exim.workshop.example
43645 to: ph10@exim.workshop.example
43646 cc: ph10@exim.workshop.example
43647 bcc: ph10@exim.workshop.example
43648 reply-to: Philip.Hazel@exim.workshop.example
43649 env-from: Philip.Hazel@exim.workshop.example
43650 env-to: ph10@exim.workshop.example
43651 </literallayout>
43652 <para>
43653 which shows that rewriting has been set up for that address when used in any of
43654 the source fields, but not when it appears as a recipient address. At the
43655 present time, there is no equivalent way of testing rewriting rules that are
43656 set for a particular transport.
43657 </para>
43658 </section>
43659 <section id="SECID150">
43660 <title>Rewriting rules</title>
43661 <para>
43662 <indexterm role="concept">
43663 <primary>rewriting</primary>
43664 <secondary>rules</secondary>
43665 </indexterm>
43666 The rewrite section of the configuration file consists of lines of rewriting
43667 rules in the form
43668 </para>
43669 <literallayout>
43670 &lt;<emphasis>source pattern</emphasis>&gt;  &lt;<emphasis>replacement</emphasis>&gt;  &lt;<emphasis>flags</emphasis>&gt;
43671 </literallayout>
43672 <para>
43673 Rewriting rules that are specified for the <option>headers_rewrite</option> generic
43674 transport option are given as a colon-separated list. Each item in the list
43675 takes the same form as a line in the main rewriting configuration (except that
43676 any colons must be doubled, of course).
43677 </para>
43678 <para>
43679 The formats of source patterns and replacement strings are described below.
43680 Each is terminated by white space, unless enclosed in double quotes, in which
43681 case normal quoting conventions apply inside the quotes. The flags are single
43682 characters which may appear in any order. Spaces and tabs between them are
43683 ignored.
43684 </para>
43685 <para>
43686 For each address that could potentially be rewritten, the rules are scanned in
43687 order, and replacements for the address from earlier rules can themselves be
43688 replaced by later rules (but see the <quote>q</quote> and <quote>R</quote> flags).
43689 </para>
43690 <para>
43691 The order in which addresses are rewritten is undefined, may change between
43692 releases, and must not be relied on, with one exception: when a message is
43693 received, the envelope sender is always rewritten first, before any header
43694 lines are rewritten. For example, the replacement string for a rewrite of an
43695 address in <emphasis>To:</emphasis> must not assume that the message&#x2019;s address in <emphasis>From:</emphasis> has
43696 (or has not) already been rewritten. However, a rewrite of <emphasis>From:</emphasis> may assume
43697 that the envelope sender has already been rewritten.
43698 </para>
43699 <para>
43700 <indexterm role="variable">
43701 <primary><varname>$domain</varname></primary>
43702 </indexterm>
43703 <indexterm role="variable">
43704 <primary><varname>$local_part</varname></primary>
43705 </indexterm>
43706 The variables <varname>$local_part</varname> and <varname>$domain</varname> can be used in the replacement
43707 string to refer to the address that is being rewritten. Note that lookup-driven
43708 rewriting can be done by a rule of the form
43709 </para>
43710 <literallayout class="monospaced">
43711 *@*   ${lookup ...
43712 </literallayout>
43713 <para>
43714 where the lookup key uses <varname>$1</varname> and <varname>$2</varname> or <varname>$local_part</varname> and <varname>$domain</varname> to
43715 refer to the address that is being rewritten.
43716 </para>
43717 </section>
43718 <section id="SECID151">
43719 <title>Rewriting patterns</title>
43720 <para>
43721 <indexterm role="concept">
43722 <primary>rewriting</primary>
43723 <secondary>patterns</secondary>
43724 </indexterm>
43725 <indexterm role="concept">
43726 <primary>address list</primary>
43727 <secondary>in a rewriting pattern</secondary>
43728 </indexterm>
43729 The source pattern in a rewriting rule is any item which may appear in an
43730 address list (see section <xref linkend="SECTaddresslist"/>). It is in fact processed as a
43731 single-item address list, which means that it is expanded before being tested
43732 against the address. As always, if you use a regular expression as a pattern,
43733 you must take care to escape dollar and backslash characters, or use the <literal>\N</literal>
43734 facility to suppress string expansion within the regular expression.
43735 </para>
43736 <para>
43737 Domains in patterns should be given in lower case. Local parts in patterns are
43738 case-sensitive. If you want to do case-insensitive matching of local parts, you
43739 can use a regular expression that starts with <literal>^(?i)</literal>.
43740 </para>
43741 <para>
43742 <indexterm role="concept">
43743 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
43744 <secondary>in rewriting rules</secondary>
43745 </indexterm>
43746 After matching, the numerical variables <varname>$1</varname>, <varname>$2</varname>, etc. may be set,
43747 depending on the type of match which occurred. These can be used in the
43748 replacement string to insert portions of the incoming address. <varname>$0</varname> always
43749 refers to the complete incoming address. When a regular expression is used, the
43750 numerical variables are set from its capturing subexpressions. For other types
43751 of pattern they are set as follows:
43752 </para>
43753 <itemizedlist>
43754 <listitem>
43755 <para>
43756 If a local part or domain starts with an asterisk, the numerical variables
43757 refer to the character strings matched by asterisks, with <varname>$1</varname> associated with
43758 the first asterisk, and <varname>$2</varname> with the second, if present. For example, if the
43759 pattern
43760 </para>
43761 <literallayout class="monospaced">
43762 *queen@*.fict.example
43763 </literallayout>
43764 <para>
43765 is matched against the address <emphasis>hearts-queen@wonderland.fict.example</emphasis> then
43766 </para>
43767 <literallayout class="monospaced">
43768 $0 = hearts-queen@wonderland.fict.example
43769 $1 = hearts-
43770 $2 = wonderland
43771 </literallayout>
43772 <para>
43773 Note that if the local part does not start with an asterisk, but the domain
43774 does, it is <varname>$1</varname> that contains the wild part of the domain.
43775 </para>
43776 </listitem>
43777 <listitem>
43778 <para>
43779 If the domain part of the pattern is a partial lookup, the wild and fixed parts
43780 of the domain are placed in the next available numerical variables. Suppose,
43781 for example, that the address <emphasis>foo@bar.baz.example</emphasis> is processed by a
43782 rewriting rule of the form
43783 </para>
43784 <literallayout>
43785 <literal>*@partial-dbm;/some/dbm/file</literal>    &lt;<emphasis>replacement string</emphasis>&gt;
43786 </literallayout>
43787 <para>
43788 and the key in the file that matches the domain is <literal>*.baz.example</literal>. Then
43789 </para>
43790 <literallayout class="monospaced">
43791 $1 = foo
43792 $2 = bar
43793 $3 = baz.example
43794 </literallayout>
43795 <para>
43796 If the address <emphasis>foo@baz.example</emphasis> is looked up, this matches the same
43797 wildcard file entry, and in this case <varname>$2</varname> is set to the empty string, but
43798 <varname>$3</varname> is still set to <emphasis>baz.example</emphasis>. If a non-wild key is matched in a
43799 partial lookup, <varname>$2</varname> is again set to the empty string and <varname>$3</varname> is set to the
43800 whole domain. For non-partial domain lookups, no numerical variables are set.
43801 </para>
43802 </listitem>
43803 </itemizedlist>
43804 </section>
43805 <section id="SECID152">
43806 <title>Rewriting replacements</title>
43807 <para>
43808 <indexterm role="concept">
43809 <primary>rewriting</primary>
43810 <secondary>replacements</secondary>
43811 </indexterm>
43812 If the replacement string for a rule is a single asterisk, addresses that
43813 match the pattern and the flags are <emphasis>not</emphasis> rewritten, and no subsequent
43814 rewriting rules are scanned. For example,
43815 </para>
43816 <literallayout class="monospaced">
43817 hatta@lookingglass.fict.example  *  f
43818 </literallayout>
43819 <para>
43820 specifies that <emphasis>hatta@lookingglass.fict.example</emphasis> is never to be rewritten in
43821 <emphasis>From:</emphasis> headers.
43822 </para>
43823 <para>
43824 <indexterm role="variable">
43825 <primary><varname>$domain</varname></primary>
43826 </indexterm>
43827 <indexterm role="variable">
43828 <primary><varname>$local_part</varname></primary>
43829 </indexterm>
43830 If the replacement string is not a single asterisk, it is expanded, and must
43831 yield a fully qualified address. Within the expansion, the variables
43832 <varname>$local_part</varname> and <varname>$domain</varname> refer to the address that is being rewritten.
43833 Any letters they contain retain their original case &ndash; they are not lower
43834 cased. The numerical variables are set up according to the type of pattern that
43835 matched the address, as described above. If the expansion is forced to fail by
43836 the presence of <quote>fail</quote> in a conditional or lookup item, rewriting by the
43837 current rule is abandoned, but subsequent rules may take effect. Any other
43838 expansion failure causes the entire rewriting operation to be abandoned, and an
43839 entry written to the panic log.
43840 </para>
43841 </section>
43842 <section id="SECID153">
43843 <title>Rewriting flags</title>
43844 <para>
43845 There are three different kinds of flag that may appear on rewriting rules:
43846 </para>
43847 <itemizedlist>
43848 <listitem>
43849 <para>
43850 Flags that specify which headers and envelope addresses to rewrite: E, F, T, b,
43851 c, f, h, r, s, t.
43852 </para>
43853 </listitem>
43854 <listitem>
43855 <para>
43856 A flag that specifies rewriting at SMTP time: S.
43857 </para>
43858 </listitem>
43859 <listitem>
43860 <para>
43861 Flags that control the rewriting process: Q, q, R, w.
43862 </para>
43863 </listitem>
43864 </itemizedlist>
43865 <para>
43866 For rules that are part of the <option>headers_rewrite</option> generic transport option,
43867 E, F, T, and S are not permitted.
43868 </para>
43869 </section>
43870 <section id="SECID154">
43871 <title>Flags specifying which headers and envelope addresses to rewrite</title>
43872 <para>
43873 <indexterm role="concept">
43874 <primary>rewriting</primary>
43875 <secondary>flags</secondary>
43876 </indexterm>
43877 If none of the following flag letters, nor the <quote>S</quote> flag (see section
43878 <xref linkend="SECTrewriteS"/>) are present, a main rewriting rule applies to all headers
43879 and to both the sender and recipient fields of the envelope, whereas a
43880 transport-time rewriting rule just applies to all headers. Otherwise, the
43881 rewriting rule is skipped unless the relevant addresses are being processed.
43882 </para>
43883 <literallayout>
43884 <literal>E</literal>       rewrite all envelope fields
43885 <literal>F</literal>       rewrite the envelope From field
43886 <literal>T</literal>       rewrite the envelope To field
43887 <literal>b</literal>       rewrite the <emphasis>Bcc:</emphasis> header
43888 <literal>c</literal>       rewrite the <emphasis>Cc:</emphasis> header
43889 <literal>f</literal>       rewrite the <emphasis>From:</emphasis> header
43890 <literal>h</literal>       rewrite all headers
43891 <literal>r</literal>       rewrite the <emphasis>Reply-To:</emphasis> header
43892 <literal>s</literal>       rewrite the <emphasis>Sender:</emphasis> header
43893 <literal>t</literal>       rewrite the <emphasis>To:</emphasis> header
43894 </literallayout>
43895 <para>
43896 "All headers" means all of the headers listed above that can be selected
43897 individually, plus their <emphasis>Resent-</emphasis> versions. It does not include
43898 other headers such as <emphasis>Subject:</emphasis> etc.
43899 </para>
43900 <para>
43901 You should be particularly careful about rewriting <emphasis>Sender:</emphasis> headers, and
43902 restrict this to special known cases in your own domains.
43903 </para>
43904 </section>
43905 <section id="SECTrewriteS">
43906 <title>The SMTP-time rewriting flag</title>
43907 <para>
43908 <indexterm role="concept">
43909 <primary>SMTP</primary>
43910 <secondary>rewriting malformed addresses</secondary>
43911 </indexterm>
43912 <indexterm role="concept">
43913 <primary>RCPT</primary>
43914 <secondary>rewriting argument of</secondary>
43915 </indexterm>
43916 <indexterm role="concept">
43917 <primary>MAIL</primary>
43918 <secondary>rewriting argument of</secondary>
43919 </indexterm>
43920 The rewrite flag <quote>S</quote> specifies a rewrite of incoming envelope addresses at
43921 SMTP time, as soon as an address is received in a MAIL or RCPT command, and
43922 before any other processing; even before syntax checking. The pattern is
43923 required to be a regular expression, and it is matched against the whole of the
43924 data for the command, including any surrounding angle brackets.
43925 </para>
43926 <para>
43927 <indexterm role="variable">
43928 <primary><varname>$domain</varname></primary>
43929 </indexterm>
43930 <indexterm role="variable">
43931 <primary><varname>$local_part</varname></primary>
43932 </indexterm>
43933 This form of rewrite rule allows for the handling of addresses that are not
43934 compliant with RFCs 2821 and 2822 (for example, <quote>bang paths</quote> in batched SMTP
43935 input). Because the input is not required to be a syntactically valid address,
43936 the variables <varname>$local_part</varname> and <varname>$domain</varname> are not available during the
43937 expansion of the replacement string. The result of rewriting replaces the
43938 original address in the MAIL or RCPT command.
43939 </para>
43940 </section>
43941 <section id="SECID155">
43942 <title>Flags controlling the rewriting process</title>
43943 <para>
43944 There are four flags which control the way the rewriting process works. These
43945 take effect only when a rule is invoked, that is, when the address is of the
43946 correct type (matches the flags) and matches the pattern:
43947 </para>
43948 <itemizedlist>
43949 <listitem>
43950 <para>
43951 If the <quote>Q</quote> flag is set on a rule, the rewritten address is permitted to be an
43952 unqualified local part. It is qualified with <option>qualify_recipient</option>. In the
43953 absence of <quote>Q</quote> the rewritten address must always include a domain.
43954 </para>
43955 </listitem>
43956 <listitem>
43957 <para>
43958 If the <quote>q</quote> flag is set on a rule, no further rewriting rules are considered,
43959 even if no rewriting actually takes place because of a <quote>fail</quote> in the
43960 expansion. The <quote>q</quote> flag is not effective if the address is of the wrong type
43961 (does not match the flags) or does not match the pattern.
43962 </para>
43963 </listitem>
43964 <listitem>
43965 <para>
43966 The <quote>R</quote> flag causes a successful rewriting rule to be re-applied to the new
43967 address, up to ten times. It can be combined with the <quote>q</quote> flag, to stop
43968 rewriting once it fails to match (after at least one successful rewrite).
43969 </para>
43970 </listitem>
43971 <listitem>
43972 <para>
43973 <indexterm role="concept">
43974 <primary>rewriting</primary>
43975 <secondary>whole addresses</secondary>
43976 </indexterm>
43977 When an address in a header is rewritten, the rewriting normally applies only
43978 to the working part of the address, with any comments and RFC 2822 <quote>phrase</quote>
43979 left unchanged. For example, rewriting might change
43980 </para>
43981 <literallayout class="monospaced">
43982 From: Ford Prefect &lt;fp42@restaurant.hitch.fict.example&gt;
43983 </literallayout>
43984 <para>
43985 into
43986 </para>
43987 <literallayout class="monospaced">
43988 From: Ford Prefect &lt;prefectf@hitch.fict.example&gt;
43989 </literallayout>
43990 <para>
43991 <indexterm role="concept">
43992 <primary>RFC 2047</primary>
43993 </indexterm>
43994 Sometimes there is a need to replace the whole address item, and this can be
43995 done by adding the flag letter <quote>w</quote> to a rule. If this is set on a rule that
43996 causes an address in a header line to be rewritten, the entire address is
43997 replaced, not just the working part. The replacement must be a complete RFC
43998 2822 address, including the angle brackets if necessary. If text outside angle
43999 brackets contains a character whose value is greater than 126 or less than 32
44000 (except for tab), the text is encoded according to RFC 2047. The character set
44001 is taken from <option>headers_charset</option>, which defaults to ISO-8859-1.
44002 </para>
44003 <para>
44004 When the <quote>w</quote> flag is set on a rule that causes an envelope address to be
44005 rewritten, all but the working part of the replacement address is discarded.
44006 </para>
44007 </listitem>
44008 </itemizedlist>
44009 </section>
44010 <section id="SECID156">
44011 <title>Rewriting examples</title>
44012 <para>
44013 Here is an example of the two common rewriting paradigms:
44014 </para>
44015 <literallayout class="monospaced">
44016 *@*.hitch.fict.example  $1@hitch.fict.example
44017 *@hitch.fict.example    ${lookup{$1}dbm{/etc/realnames}\
44018                      {$value}fail}@hitch.fict.example bctfrF
44019 </literallayout>
44020 <para>
44021 Note the use of <quote>fail</quote> in the lookup expansion in the second rule, forcing
44022 the string expansion to fail if the lookup does not succeed. In this context it
44023 has the effect of leaving the original address unchanged, but Exim goes on to
44024 consider subsequent rewriting rules, if any, because the <quote>q</quote> flag is not
44025 present in that rule. An alternative to <quote>fail</quote> would be to supply <varname>$1</varname>
44026 explicitly, which would cause the rewritten address to be the same as before,
44027 at the cost of a small bit of processing. Not supplying either of these is an
44028 error, since the rewritten address would then contain no local part.
44029 </para>
44030 <para>
44031 The first example above replaces the domain with a superior, more general
44032 domain. This may not be desirable for certain local parts. If the rule
44033 </para>
44034 <literallayout class="monospaced">
44035 root@*.hitch.fict.example  *
44036 </literallayout>
44037 <para>
44038 were inserted before the first rule, rewriting would be suppressed for the
44039 local part <emphasis>root</emphasis> at any domain ending in <emphasis>hitch.fict.example</emphasis>.
44040 </para>
44041 <para>
44042 Rewriting can be made conditional on a number of tests, by making use of
44043 <varname>${if</varname> in the expansion item. For example, to apply a rewriting rule only to
44044 messages that originate outside the local host:
44045 </para>
44046 <literallayout class="monospaced">
44047 *@*.hitch.fict.example  "${if !eq {$sender_host_address}{}\
44048                          {$1@hitch.fict.example}fail}"
44049 </literallayout>
44050 <para>
44051 The replacement string is quoted in this example because it contains white
44052 space.
44053 </para>
44054 <para>
44055 <indexterm role="concept">
44056 <primary>rewriting</primary>
44057 <secondary>bang paths</secondary>
44058 </indexterm>
44059 <indexterm role="concept">
44060 <primary>bang paths</primary>
44061 <secondary>rewriting</secondary>
44062 </indexterm>
44063 Exim does not handle addresses in the form of <quote>bang paths</quote>. If it sees such
44064 an address it treats it as an unqualified local part which it qualifies with
44065 the local qualification domain (if the source of the message is local or if the
44066 remote host is permitted to send unqualified addresses). Rewriting can
44067 sometimes be used to handle simple bang paths with a fixed number of
44068 components. For example, the rule
44069 </para>
44070 <literallayout class="monospaced">
44071 \N^([^!]+)!(.*)@your.domain.example$\N   $2@$1
44072 </literallayout>
44073 <para>
44074 rewrites a two-component bang path <emphasis>host.name!user</emphasis> as the domain address
44075 <emphasis>user@host.name</emphasis>. However, there is a security implication in using this as
44076 a global rewriting rule for envelope addresses. It can provide a backdoor
44077 method for using your system as a relay, because the incoming addresses appear
44078 to be local. If the bang path addresses are received via SMTP, it is safer to
44079 use the <quote>S</quote> flag to rewrite them as they are received, so that relay checking
44080 can be done on the rewritten addresses.
44081 <indexterm role="concept" startref="IIDaddrew" class="endofrange"/>
44082 </para>
44083 </section>
44084 </chapter>
44085
44086 <chapter id="CHAPretry">
44087 <title>Retry configuration</title>
44088 <para>
44089 <indexterm role="concept" id="IIDretconf1" class="startofrange">
44090 <primary>retry</primary>
44091 <secondary>configuration, description of</secondary>
44092 </indexterm>
44093 <indexterm role="concept" id="IIDregconf2" class="startofrange">
44094 <primary>configuration file</primary>
44095 <secondary>retry section</secondary>
44096 </indexterm>
44097 The <quote>retry</quote> section of the runtime configuration file contains a list of
44098 retry rules that control how often Exim tries to deliver messages that cannot
44099 be delivered at the first attempt. If there are no retry rules (the section is
44100 empty or not present), there are no retries. In this situation, temporary
44101 errors are treated as permanent. The default configuration contains a single,
44102 general-purpose retry rule (see section <xref linkend="SECID57"/>). The <option>-brt</option> command
44103 line option can be used to test which retry rule will be used for a given
44104 address, domain and error.
44105 </para>
44106 <para>
44107 The most common cause of retries is temporary failure to deliver to a remote
44108 host because the host is down, or inaccessible because of a network problem.
44109 Exim&#x2019;s retry processing in this case is applied on a per-host (strictly, per IP
44110 address) basis, not on a per-message basis. Thus, if one message has recently
44111 been delayed, delivery of a new message to the same host is not immediately
44112 tried, but waits for the host&#x2019;s retry time to arrive. If the <option>retry_defer</option>
44113 log selector is set, the message
44114 <indexterm role="concept">
44115 <primary>retry</primary>
44116 <secondary>time not reached</secondary>
44117 </indexterm>
44118 <quote>retry time not reached</quote> is written to the main log whenever a delivery is
44119 skipped for this reason. Section <xref linkend="SECToutSMTPerr"/> contains more details of
44120 the handling of errors during remote deliveries.
44121 </para>
44122 <para>
44123 Retry processing applies to routing as well as to delivering, except as covered
44124 in the next paragraph. The retry rules do not distinguish between these
44125 actions. It is not possible, for example, to specify different behaviour for
44126 failures to route the domain <emphasis>snark.fict.example</emphasis> and failures to deliver to
44127 the host <emphasis>snark.fict.example</emphasis>. I didn&#x2019;t think anyone would ever need this
44128 added complication, so did not implement it. However, although they share the
44129 same retry rule, the actual retry times for routing and transporting a given
44130 domain are maintained independently.
44131 </para>
44132 <para>
44133 When a delivery is not part of a queue run (typically an immediate delivery on
44134 receipt of a message), the routers are always run, and local deliveries are
44135 always attempted, even if retry times are set for them. This makes for better
44136 behaviour if one particular message is causing problems (for example, causing
44137 quota overflow, or provoking an error in a filter file). If such a delivery
44138 suffers a temporary failure, the retry data is updated as normal, and
44139 subsequent delivery attempts from queue runs occur only when the retry time for
44140 the local address is reached.
44141 </para>
44142 <section id="SECID157">
44143 <title>Changing retry rules</title>
44144 <para>
44145 If you change the retry rules in your configuration, you should consider
44146 whether or not to delete the retry data that is stored in Exim&#x2019;s spool area in
44147 files with names like <filename>db/retry</filename>. Deleting any of Exim&#x2019;s hints files is
44148 always safe; that is why they are called <quote>hints</quote>.
44149 </para>
44150 <para>
44151 The hints retry data contains suggested retry times based on the previous
44152 rules. In the case of a long-running problem with a remote host, it might
44153 record the fact that the host has timed out. If your new rules increase the
44154 timeout time for such a host, you should definitely remove the old retry data
44155 and let Exim recreate it, based on the new rules. Otherwise Exim might bounce
44156 messages that it should now be retaining.
44157 </para>
44158 </section>
44159 <section id="SECID158">
44160 <title>Format of retry rules</title>
44161 <para>
44162 <indexterm role="concept">
44163 <primary>retry</primary>
44164 <secondary>rules</secondary>
44165 </indexterm>
44166 Each retry rule occupies one line and consists of three or four parts,
44167 separated by white space: a pattern, an error name, an optional list of sender
44168 addresses, and a list of retry parameters. The pattern and sender lists must be
44169 enclosed in double quotes if they contain white space. The rules are searched
44170 in order until one is found where the pattern, error name, and sender list (if
44171 present) match the failing host or address, the error that occurred, and the
44172 message&#x2019;s sender, respectively.
44173 </para>
44174 <para>
44175 The pattern is any single item that may appear in an address list (see section
44176 <xref linkend="SECTaddresslist"/>). It is in fact processed as a one-item address list,
44177 which means that it is expanded before being tested against the address that
44178 has been delayed. A negated address list item is permitted. Address
44179 list processing treats a plain domain name as if it were preceded by <quote>*@</quote>,
44180 which makes it possible for many retry rules to start with just a domain. For
44181 example,
44182 </para>
44183 <literallayout class="monospaced">
44184 lookingglass.fict.example        *  F,24h,30m;
44185 </literallayout>
44186 <para>
44187 provides a rule for any address in the <emphasis>lookingglass.fict.example</emphasis> domain,
44188 whereas
44189 </para>
44190 <literallayout class="monospaced">
44191 alice@lookingglass.fict.example  *  F,24h,30m;
44192 </literallayout>
44193 <para>
44194 applies only to temporary failures involving the local part <option>alice</option>.
44195 In practice, almost all rules start with a domain name pattern without a local
44196 part.
44197 </para>
44198 <para>
44199 <indexterm role="concept">
44200 <primary>regular expressions</primary>
44201 <secondary>in retry rules</secondary>
44202 </indexterm>
44203 <emphasis role="bold">Warning</emphasis>: If you use a regular expression in a routing rule pattern, it
44204 must match a complete address, not just a domain, because that is how regular
44205 expressions work in address lists.
44206 </para>
44207 <literallayout>
44208 <literal>^\Nxyz\d+\.abc\.example$\N        *  G,1h,10m,2</literal>     <option>Wrong</option>
44209 <literal>^\N[^@]+@xyz\d+\.abc\.example$\N  *  G,1h,10m,2</literal>     <option>Right</option>
44210 </literallayout>
44211 </section>
44212 <section id="SECID159">
44213 <title>Choosing which retry rule to use for address errors</title>
44214 <para>
44215 When Exim is looking for a retry rule after a routing attempt has failed (for
44216 example, after a DNS timeout), each line in the retry configuration is tested
44217 against the complete address only if <option>retry_use_local_part</option> is set for the
44218 router. Otherwise, only the domain is used, except when matching against a
44219 regular expression, when the local part of the address is replaced with <quote>*</quote>.
44220 A domain on its own can match a domain pattern, or a pattern that starts with
44221 <quote>*@</quote>. By default, <option>retry_use_local_part</option> is true for routers where
44222 <option>check_local_user</option> is true, and false for other routers.
44223 </para>
44224 <para>
44225 Similarly, when Exim is looking for a retry rule after a local delivery has
44226 failed (for example, after a mailbox full error), each line in the retry
44227 configuration is tested against the complete address only if
44228 <option>retry_use_local_part</option> is set for the transport (it defaults true for all
44229 local transports).
44230 </para>
44231 <para>
44232 <indexterm role="concept">
44233 <primary>4<emphasis>xx</emphasis> responses</primary>
44234 <secondary>retry rules for</secondary>
44235 </indexterm>
44236 However, when Exim is looking for a retry rule after a remote delivery attempt
44237 suffers an address error (a 4<emphasis>xx</emphasis> SMTP response for a recipient address), the
44238 whole address is always used as the key when searching the retry rules. The
44239 rule that is found is used to create a retry time for the combination of the
44240 failing address and the message&#x2019;s sender. It is the combination of sender and
44241 recipient that is delayed in subsequent queue runs until its retry time is
44242 reached. You can delay the recipient without regard to the sender by setting
44243 <option>address_retry_include_sender</option> false in the <command>smtp</command> transport but this can
44244 lead to problems with servers that regularly issue 4<emphasis>xx</emphasis> responses to RCPT
44245 commands.
44246 </para>
44247 </section>
44248 <section id="SECID160">
44249 <title>Choosing which retry rule to use for host and message errors</title>
44250 <para>
44251 For a temporary error that is not related to an individual address (for
44252 example, a connection timeout), each line in the retry configuration is checked
44253 twice. First, the name of the remote host is used as a domain name (preceded by
44254 <quote>*@</quote> when matching a regular expression). If this does not match the line,
44255 the domain from the email address is tried in a similar fashion. For example,
44256 suppose the MX records for <emphasis>a.b.c.example</emphasis> are
44257 </para>
44258 <literallayout class="monospaced">
44259 a.b.c.example  MX  5  x.y.z.example
44260                MX  6  p.q.r.example
44261                MX  7  m.n.o.example
44262 </literallayout>
44263 <para>
44264 and the retry rules are
44265 </para>
44266 <literallayout class="monospaced">
44267 p.q.r.example    *      F,24h,30m;
44268 a.b.c.example    *      F,4d,45m;
44269 </literallayout>
44270 <para>
44271 and a delivery to the host <emphasis>x.y.z.example</emphasis> suffers a connection failure. The
44272 first rule matches neither the host nor the domain, so Exim looks at the second
44273 rule. This does not match the host, but it does match the domain, so it is used
44274 to calculate the retry time for the host <emphasis>x.y.z.example</emphasis>. Meanwhile, Exim
44275 tries to deliver to <emphasis>p.q.r.example</emphasis>. If this also suffers a host error, the
44276 first retry rule is used, because it matches the host.
44277 </para>
44278 <para>
44279 In other words, temporary failures to deliver to host <emphasis>p.q.r.example</emphasis> use the
44280 first rule to determine retry times, but for all the other hosts for the domain
44281 <emphasis>a.b.c.example</emphasis>, the second rule is used. The second rule is also used if
44282 routing to <emphasis>a.b.c.example</emphasis> suffers a temporary failure.
44283 </para>
44284 <para>
44285 <emphasis role="bold">Note</emphasis>: The host name is used when matching the patterns, not its IP address.
44286 However, if a message is routed directly to an IP address without the use of a
44287 host name, for example, if a <command>manualroute</command> router contains a setting such as:
44288 </para>
44289 <literallayout class="monospaced">
44290 route_list = *.a.example  192.168.34.23
44291 </literallayout>
44292 <para>
44293 then the <quote>host name</quote> that is used when searching for a retry rule is the
44294 textual form of the IP address.
44295 </para>
44296 </section>
44297 <section id="SECID161">
44298 <title>Retry rules for specific errors</title>
44299 <para>
44300 <indexterm role="concept">
44301 <primary>retry</primary>
44302 <secondary>specific errors; specifying</secondary>
44303 </indexterm>
44304 The second field in a retry rule is the name of a particular error, or an
44305 asterisk, which matches any error. The errors that can be tested for are:
44306 </para>
44307 <variablelist>
44308 <varlistentry>
44309 <term><option>auth_failed</option></term>
44310 <listitem>
44311 <para>
44312 Authentication failed when trying to send to a host in the
44313 <option>hosts_require_auth</option> list in an <command>smtp</command> transport.
44314 </para>
44315 </listitem></varlistentry>
44316 <varlistentry>
44317 <term><option>data_4xx</option></term>
44318 <listitem>
44319 <para>
44320 A 4<emphasis>xx</emphasis> error was received for an outgoing DATA command, either immediately
44321 after the command, or after sending the message&#x2019;s data.
44322 </para>
44323 </listitem></varlistentry>
44324 <varlistentry>
44325 <term><option>mail_4xx</option></term>
44326 <listitem>
44327 <para>
44328 A 4<emphasis>xx</emphasis> error was received for an outgoing MAIL command.
44329 </para>
44330 </listitem></varlistentry>
44331 <varlistentry>
44332 <term><option>rcpt_4xx</option></term>
44333 <listitem>
44334 <para>
44335 A 4<emphasis>xx</emphasis> error was received for an outgoing RCPT command.
44336 </para>
44337 </listitem></varlistentry>
44338 </variablelist>
44339 <para>
44340 For the three 4<emphasis>xx</emphasis> errors, either the first or both of the x&#x2019;s can be given
44341 as specific digits, for example: <literal>mail_45x</literal> or <literal>rcpt_436</literal>. For example, to
44342 recognize 452 errors given to RCPT commands for addresses in a certain domain,
44343 and have retries every ten minutes with a one-hour timeout, you could set up a
44344 retry rule of this form:
44345 </para>
44346 <literallayout class="monospaced">
44347 the.domain.name  rcpt_452   F,1h,10m
44348 </literallayout>
44349 <para>
44350 These errors apply to both outgoing SMTP (the <command>smtp</command> transport) and outgoing
44351 LMTP (either the <command>lmtp</command> transport, or the <command>smtp</command> transport in LMTP mode).
44352 </para>
44353 <variablelist>
44354 <varlistentry>
44355 <term><option>lost_connection</option></term>
44356 <listitem>
44357 <para>
44358 A server unexpectedly closed the SMTP connection. There may, of course,
44359 legitimate reasons for this (host died, network died), but if it repeats a lot
44360 for the same host, it indicates something odd.
44361 </para>
44362 </listitem></varlistentry>
44363 <varlistentry>
44364 <term><option>refused_MX</option></term>
44365 <listitem>
44366 <para>
44367 A connection to a host obtained from an MX record was refused.
44368 </para>
44369 </listitem></varlistentry>
44370 <varlistentry>
44371 <term><option>refused_A</option></term>
44372 <listitem>
44373 <para>
44374 A connection to a host not obtained from an MX record was refused.
44375 </para>
44376 </listitem></varlistentry>
44377 <varlistentry>
44378 <term><option>refused</option></term>
44379 <listitem>
44380 <para>
44381 A connection was refused.
44382 </para>
44383 </listitem></varlistentry>
44384 <varlistentry>
44385 <term><option>timeout_connect_MX</option></term>
44386 <listitem>
44387 <para>
44388 A connection attempt to a host obtained from an MX record timed out.
44389 </para>
44390 </listitem></varlistentry>
44391 <varlistentry>
44392 <term><option>timeout_connect_A</option></term>
44393 <listitem>
44394 <para>
44395 A connection attempt to a host not obtained from an MX record timed out.
44396 </para>
44397 </listitem></varlistentry>
44398 <varlistentry>
44399 <term><option>timeout_connect</option></term>
44400 <listitem>
44401 <para>
44402 A connection attempt timed out.
44403 </para>
44404 </listitem></varlistentry>
44405 <varlistentry>
44406 <term><option>timeout_MX</option></term>
44407 <listitem>
44408 <para>
44409 There was a timeout while connecting or during an SMTP session with a host
44410 obtained from an MX record.
44411 </para>
44412 </listitem></varlistentry>
44413 <varlistentry>
44414 <term><option>timeout_A</option></term>
44415 <listitem>
44416 <para>
44417 There was a timeout while connecting or during an SMTP session with a host not
44418 obtained from an MX record.
44419 </para>
44420 </listitem></varlistentry>
44421 <varlistentry>
44422 <term><option>timeout</option></term>
44423 <listitem>
44424 <para>
44425 There was a timeout while connecting or during an SMTP session.
44426 </para>
44427 </listitem></varlistentry>
44428 <varlistentry>
44429 <term><option>tls_required</option></term>
44430 <listitem>
44431 <para>
44432 The server was required to use TLS (it matched <option>hosts_require_tls</option> in the
44433 <command>smtp</command> transport), but either did not offer TLS, or it responded with 4<emphasis>xx</emphasis>
44434 to STARTTLS, or there was a problem setting up the TLS connection.
44435 </para>
44436 </listitem></varlistentry>
44437 <varlistentry>
44438 <term><option>quota</option></term>
44439 <listitem>
44440 <para>
44441 A mailbox quota was exceeded in a local delivery by the <command>appendfile</command>
44442 transport.
44443 </para>
44444 </listitem></varlistentry>
44445 <varlistentry>
44446 <term><option>quota_</option>&lt;<emphasis>time</emphasis>&gt;</term>
44447 <listitem>
44448 <para>
44449 <indexterm role="concept">
44450 <primary>quota</primary>
44451 <secondary>error testing in retry rule</secondary>
44452 </indexterm>
44453 <indexterm role="concept">
44454 <primary>retry</primary>
44455 <secondary>quota error testing</secondary>
44456 </indexterm>
44457 A mailbox quota was exceeded in a local delivery by the <command>appendfile</command>
44458 transport, and the mailbox has not been accessed for &lt;<emphasis>time</emphasis>&gt;. For example,
44459 <emphasis>quota_4d</emphasis> applies to a quota error when the mailbox has not been accessed
44460 for four days.
44461 </para>
44462 </listitem></varlistentry>
44463 </variablelist>
44464 <para>
44465 <indexterm role="concept">
44466 <primary>mailbox</primary>
44467 <secondary>time of last read</secondary>
44468 </indexterm>
44469 The idea of <option>quota_</option>&lt;<emphasis>time</emphasis>&gt; is to make it possible to have shorter
44470 timeouts when the mailbox is full and is not being read by its owner. Ideally,
44471 it should be based on the last time that the user accessed the mailbox.
44472 However, it is not always possible to determine this. Exim uses the following
44473 heuristic rules:
44474 </para>
44475 <itemizedlist>
44476 <listitem>
44477 <para>
44478 If the mailbox is a single file, the time of last access (the <quote>atime</quote>) is
44479 used. As no new messages are being delivered (because the mailbox is over
44480 quota), Exim does not access the file, so this is the time of last user access.
44481 </para>
44482 </listitem>
44483 <listitem>
44484 <para>
44485 <indexterm role="concept">
44486 <primary>maildir format</primary>
44487 <secondary>time of last read</secondary>
44488 </indexterm>
44489 For a maildir delivery, the time of last modification of the <filename>new</filename>
44490 subdirectory is used. As the mailbox is over quota, no new files are created in
44491 the <filename>new</filename> subdirectory, because no new messages are being delivered. Any
44492 change to the <filename>new</filename> subdirectory is therefore assumed to be the result of an
44493 MUA moving a new message to the <filename>cur</filename> directory when it is first read. The
44494 time that is used is therefore the last time that the user read a new message.
44495 </para>
44496 </listitem>
44497 <listitem>
44498 <para>
44499 For other kinds of multi-file mailbox, the time of last access cannot be
44500 obtained, so a retry rule that uses this type of error field is never matched.
44501 </para>
44502 </listitem>
44503 </itemizedlist>
44504 <para>
44505 The quota errors apply both to system-enforced quotas and to Exim&#x2019;s own quota
44506 mechanism in the <command>appendfile</command> transport. The <emphasis>quota</emphasis> error also applies
44507 when a local delivery is deferred because a partition is full (the ENOSPC
44508 error).
44509 </para>
44510 </section>
44511 <section id="SECID162">
44512 <title>Retry rules for specified senders</title>
44513 <para>
44514 <indexterm role="concept">
44515 <primary>retry</primary>
44516 <secondary>rules; sender-specific</secondary>
44517 </indexterm>
44518 You can specify retry rules that apply only when the failing message has a
44519 specific sender. In particular, this can be used to define retry rules that
44520 apply only to bounce messages. The third item in a retry rule can be of this
44521 form:
44522 </para>
44523 <literallayout>
44524 <literal>senders=</literal>&lt;<emphasis>address list</emphasis>&gt;
44525 </literallayout>
44526 <para>
44527 The retry timings themselves are then the fourth item. For example:
44528 </para>
44529 <literallayout class="monospaced">
44530 *   rcpt_4xx   senders=:   F,1h,30m
44531 </literallayout>
44532 <para>
44533 matches recipient 4<emphasis>xx</emphasis> errors for bounce messages sent to any address at any
44534 host. If the address list contains white space, it must be enclosed in quotes.
44535 For example:
44536 </para>
44537 <literallayout class="monospaced">
44538 a.domain  rcpt_452  senders="xb.dom : yc.dom"  G,8h,10m,1.5
44539 </literallayout>
44540 <para>
44541 <emphasis role="bold">Warning</emphasis>: This facility can be unhelpful if it is used for host errors
44542 (which do not depend on the recipient). The reason is that the sender is used
44543 only to match the retry rule. Once the rule has been found for a host error,
44544 its contents are used to set a retry time for the host, and this will apply to
44545 all messages, not just those with specific senders.
44546 </para>
44547 <para>
44548 When testing retry rules using <option>-brt</option>, you can supply a sender using the
44549 <option>-f</option> command line option, like this:
44550 </para>
44551 <literallayout class="monospaced">
44552 exim -f "" -brt user@dom.ain
44553 </literallayout>
44554 <para>
44555 If you do not set <option>-f</option> with <option>-brt</option>, a retry rule that contains a senders
44556 list is never matched.
44557 </para>
44558 </section>
44559 <section id="SECID163">
44560 <title>Retry parameters</title>
44561 <para>
44562 <indexterm role="concept">
44563 <primary>retry</primary>
44564 <secondary>parameters in rules</secondary>
44565 </indexterm>
44566 The third (or fourth, if a senders list is present) field in a retry rule is a
44567 sequence of retry parameter sets, separated by semicolons. Each set consists of
44568 </para>
44569 <literallayout>
44570 &lt;<emphasis>letter</emphasis>&gt;,&lt;<emphasis>cutoff time</emphasis>&gt;,&lt;<emphasis>arguments</emphasis>&gt;
44571 </literallayout>
44572 <para>
44573 The letter identifies the algorithm for computing a new retry time; the cutoff
44574 time is the time beyond which this algorithm no longer applies, and the
44575 arguments vary the algorithm&#x2019;s action. The cutoff time is measured from the
44576 time that the first failure for the domain (combined with the local part if
44577 relevant) was detected, not from the time the message was received.
44578 </para>
44579 <para>
44580 <indexterm role="concept">
44581 <primary>retry</primary>
44582 <secondary>algorithms</secondary>
44583 </indexterm>
44584 <indexterm role="concept">
44585 <primary>retry</primary>
44586 <secondary>fixed intervals</secondary>
44587 </indexterm>
44588 <indexterm role="concept">
44589 <primary>retry</primary>
44590 <secondary>increasing intervals</secondary>
44591 </indexterm>
44592 <indexterm role="concept">
44593 <primary>retry</primary>
44594 <secondary>random intervals</secondary>
44595 </indexterm>
44596 The available algorithms are:
44597 </para>
44598 <itemizedlist>
44599 <listitem>
44600 <para>
44601 <emphasis>F</emphasis>: retry at fixed intervals. There is a single time parameter specifying
44602 the interval.
44603 </para>
44604 </listitem>
44605 <listitem>
44606 <para>
44607 <emphasis>G</emphasis>: retry at geometrically increasing intervals. The first argument
44608 specifies a starting value for the interval, and the second a multiplier, which
44609 is used to increase the size of the interval at each retry.
44610 </para>
44611 </listitem>
44612 <listitem>
44613 <para>
44614 <emphasis>H</emphasis>: retry at randomized intervals. The arguments are as for <emphasis>G</emphasis>. For each
44615 retry, the previous interval is multiplied by the factor in order to get a
44616 maximum for the next interval. The minimum interval is the first argument of
44617 the parameter, and an actual interval is chosen randomly between them. Such a
44618 rule has been found to be helpful in cluster configurations when all the
44619 members of the cluster restart at once, and may therefore synchronize their
44620 queue processing times.
44621 </para>
44622 </listitem>
44623 </itemizedlist>
44624 <para>
44625 When computing the next retry time, the algorithm definitions are scanned in
44626 order until one whose cutoff time has not yet passed is reached. This is then
44627 used to compute a new retry time that is later than the current time. In the
44628 case of fixed interval retries, this simply means adding the interval to the
44629 current time. For geometrically increasing intervals, retry intervals are
44630 computed from the rule&#x2019;s parameters until one that is greater than the previous
44631 interval is found. The main configuration variable
44632 <indexterm role="concept">
44633 <primary>limit</primary>
44634 <secondary>retry interval</secondary>
44635 </indexterm>
44636 <indexterm role="concept">
44637 <primary>retry</primary>
44638 <secondary>interval, maximum</secondary>
44639 </indexterm>
44640 <indexterm role="option">
44641 <primary><option>retry_interval_max</option></primary>
44642 </indexterm>
44643 <option>retry_interval_max</option> limits the maximum interval between retries. It
44644 cannot be set greater than <literal>24h</literal>, which is its default value.
44645 </para>
44646 <para>
44647 A single remote domain may have a number of hosts associated with it, and each
44648 host may have more than one IP address. Retry algorithms are selected on the
44649 basis of the domain name, but are applied to each IP address independently. If,
44650 for example, a host has two IP addresses and one is unusable, Exim will
44651 generate retry times for it and will not try to use it until its next retry
44652 time comes. Thus the good IP address is likely to be tried first most of the
44653 time.
44654 </para>
44655 <para>
44656 <indexterm role="concept">
44657 <primary>hints database</primary>
44658 <secondary>use for retrying</secondary>
44659 </indexterm>
44660 Retry times are hints rather than promises. Exim does not make any attempt to
44661 run deliveries exactly at the computed times. Instead, a queue runner process
44662 starts delivery processes for delayed messages periodically, and these attempt
44663 new deliveries only for those addresses that have passed their next retry time.
44664 If a new message arrives for a deferred address, an immediate delivery attempt
44665 occurs only if the address has passed its retry time. In the absence of new
44666 messages, the minimum time between retries is the interval between queue runner
44667 processes. There is not much point in setting retry times of five minutes if
44668 your queue runners happen only once an hour, unless there are a significant
44669 number of incoming messages (which might be the case on a system that is
44670 sending everything to a smart host, for example).
44671 </para>
44672 <para>
44673 The data in the retry hints database can be inspected by using the
44674 <emphasis>exim_dumpdb</emphasis> or <emphasis>exim_fixdb</emphasis> utility programs (see chapter
44675 <xref linkend="CHAPutils"/>). The latter utility can also be used to change the data. The
44676 <emphasis>exinext</emphasis> utility script can be used to find out what the next retry times
44677 are for the hosts associated with a particular mail domain, and also for local
44678 deliveries that have been deferred.
44679 </para>
44680 </section>
44681 <section id="SECID164">
44682 <title>Retry rule examples</title>
44683 <para>
44684 Here are some example retry rules:
44685 </para>
44686 <literallayout class="monospaced">
44687 alice@wonderland.fict.example quota_5d  F,7d,3h
44688 wonderland.fict.example       quota_5d
44689 wonderland.fict.example       *         F,1h,15m; G,2d,1h,2;
44690 lookingglass.fict.example     *         F,24h,30m;
44691 *                 refused_A   F,2h,20m;
44692 *                 *           F,2h,15m; G,16h,1h,1.5; F,5d,8h
44693 </literallayout>
44694 <para>
44695 The first rule sets up special handling for mail to
44696 <emphasis>alice@wonderland.fict.example</emphasis> when there is an over-quota error and the
44697 mailbox has not been read for at least 5 days. Retries continue every three
44698 hours for 7 days. The second rule handles over-quota errors for all other local
44699 parts at <emphasis>wonderland.fict.example</emphasis>; the absence of a local part has the same
44700 effect as supplying <quote>*@</quote>. As no retry algorithms are supplied, messages that
44701 fail are bounced immediately if the mailbox has not been read for at least 5
44702 days.
44703 </para>
44704 <para>
44705 The third rule handles all other errors at <emphasis>wonderland.fict.example</emphasis>; retries
44706 happen every 15 minutes for an hour, then with geometrically increasing
44707 intervals until two days have passed since a delivery first failed. After the
44708 first hour there is a delay of one hour, then two hours, then four hours, and
44709 so on (this is a rather extreme example).
44710 </para>
44711 <para>
44712 The fourth rule controls retries for the domain <emphasis>lookingglass.fict.example</emphasis>.
44713 They happen every 30 minutes for 24 hours only. The remaining two rules handle
44714 all other domains, with special action for connection refusal from hosts that
44715 were not obtained from an MX record.
44716 </para>
44717 <para>
44718 The final rule in a retry configuration should always have asterisks in the
44719 first two fields so as to provide a general catch-all for any addresses that do
44720 not have their own special handling. This example tries every 15 minutes for 2
44721 hours, then with intervals starting at one hour and increasing by a factor of
44722 1.5 up to 16 hours, then every 8 hours up to 5 days.
44723 </para>
44724 </section>
44725 <section id="SECID165">
44726 <title>Timeout of retry data</title>
44727 <para>
44728 <indexterm role="concept">
44729 <primary>timeout</primary>
44730 <secondary>of retry data</secondary>
44731 </indexterm>
44732 <indexterm role="option">
44733 <primary><option>retry_data_expire</option></primary>
44734 </indexterm>
44735 <indexterm role="concept">
44736 <primary>hints database</primary>
44737 <secondary>data expiry</secondary>
44738 </indexterm>
44739 <indexterm role="concept">
44740 <primary>retry</primary>
44741 <secondary>timeout of data</secondary>
44742 </indexterm>
44743 Exim timestamps the data that it writes to its retry hints database. When it
44744 consults the data during a delivery it ignores any that is older than the value
44745 set in <option>retry_data_expire</option> (default 7 days). If, for example, a host hasn&#x2019;t
44746 been tried for 7 days, Exim will try to deliver to it immediately a message
44747 arrives, and if that fails, it will calculate a retry time as if it were
44748 failing for the first time.
44749 </para>
44750 <para>
44751 This improves the behaviour for messages routed to rarely-used hosts such as MX
44752 backups. If such a host was down at one time, and happens to be down again when
44753 Exim tries a month later, using the old retry data would imply that it had been
44754 down all the time, which is not a justified assumption.
44755 </para>
44756 <para>
44757 If a host really is permanently dead, this behaviour causes a burst of retries
44758 every now and again, but only if messages routed to it are rare. If there is a
44759 message at least once every 7 days the retry data never expires.
44760 </para>
44761 </section>
44762 <section id="SECID166">
44763 <title>Long-term failures</title>
44764 <para>
44765 <indexterm role="concept">
44766 <primary>delivery failure, long-term</primary>
44767 </indexterm>
44768 <indexterm role="concept">
44769 <primary>retry</primary>
44770 <secondary>after long-term failure</secondary>
44771 </indexterm>
44772 Special processing happens when an email address has been failing for so long
44773 that the cutoff time for the last algorithm is reached. For example, using the
44774 default retry rule:
44775 </para>
44776 <literallayout class="monospaced">
44777 * * F,2h,15m; G,16h,1h,1.5; F,4d,6h
44778 </literallayout>
44779 <para>
44780 the cutoff time is four days. Reaching the retry cutoff is independent of how
44781 long any specific message has been failing; it is the length of continuous
44782 failure for the recipient address that counts.
44783 </para>
44784 <para>
44785 When the cutoff time is reached for a local delivery, or for all the IP
44786 addresses associated with a remote delivery, a subsequent delivery failure
44787 causes Exim to give up on the address, and a bounce message is generated.
44788 In order to cater for new messages that use the failing address, a next retry
44789 time is still computed from the final algorithm, and is used as follows:
44790 </para>
44791 <para>
44792 For local deliveries, one delivery attempt is always made for any subsequent
44793 messages. If this delivery fails, the address fails immediately. The
44794 post-cutoff retry time is not used.
44795 </para>
44796 <para>
44797 If the delivery is remote, there are two possibilities, controlled by the
44798 <indexterm role="option">
44799 <primary><option>delay_after_cutoff</option></primary>
44800 </indexterm>
44801 <option>delay_after_cutoff</option> option of the <command>smtp</command> transport. The option is true by
44802 default. Until the post-cutoff retry time for one of the IP addresses is
44803 reached, the failing email address is bounced immediately, without a delivery
44804 attempt taking place. After that time, one new delivery attempt is made to
44805 those IP addresses that are past their retry times, and if that still fails,
44806 the address is bounced and new retry times are computed.
44807 </para>
44808 <para>
44809 In other words, when all the hosts for a given email address have been failing
44810 for a long time, Exim bounces rather then defers until one of the hosts&#x2019; retry
44811 times is reached. Then it tries once, and bounces if that attempt fails. This
44812 behaviour ensures that few resources are wasted in repeatedly trying to deliver
44813 to a broken destination, but if the host does recover, Exim will eventually
44814 notice.
44815 </para>
44816 <para>
44817 If <option>delay_after_cutoff</option> is set false, Exim behaves differently. If all IP
44818 addresses are past their final cutoff time, Exim tries to deliver to those IP
44819 addresses that have not been tried since the message arrived. If there are
44820 no suitable IP addresses, or if they all fail, the address is bounced. In other
44821 words, it does not delay when a new message arrives, but tries the expired
44822 addresses immediately, unless they have been tried since the message arrived.
44823 If there is a continuous stream of messages for the failing domains, setting
44824 <option>delay_after_cutoff</option> false means that there will be many more attempts to
44825 deliver to permanently failing IP addresses than when <option>delay_after_cutoff</option> is
44826 true.
44827 </para>
44828 </section>
44829 <section id="SECID167">
44830 <title>Deliveries that work intermittently</title>
44831 <para>
44832 <indexterm role="concept">
44833 <primary>retry</primary>
44834 <secondary>intermittently working deliveries</secondary>
44835 </indexterm>
44836 Some additional logic is needed to cope with cases where a host is
44837 intermittently available, or when a message has some attribute that prevents
44838 its delivery when others to the same address get through. In this situation,
44839 because some messages are successfully delivered, the <quote>retry clock</quote> for the
44840 host or address keeps getting reset by the successful deliveries, and so
44841 failing messages remain on the queue for ever because the cutoff time is never
44842 reached.
44843 </para>
44844 <para>
44845 Two exceptional actions are applied to prevent this happening. The first
44846 applies to errors that are related to a message rather than a remote host.
44847 Section <xref linkend="SECToutSMTPerr"/> has a discussion of the different kinds of error;
44848 examples of message-related errors are 4<emphasis>xx</emphasis> responses to MAIL or DATA
44849 commands, and quota failures. For this type of error, if a message&#x2019;s arrival
44850 time is earlier than the <quote>first failed</quote> time for the error, the earlier time
44851 is used when scanning the retry rules to decide when to try next and when to
44852 time out the address.
44853 </para>
44854 <para>
44855 The exceptional second action applies in all cases. If a message has been on
44856 the queue for longer than the cutoff time of any applicable retry rule for a
44857 given address, a delivery is attempted for that address, even if it is not yet
44858 time, and if this delivery fails, the address is timed out. A new retry time is
44859 not computed in this case, so that other messages for the same address are
44860 considered immediately.
44861 <indexterm role="concept" startref="IIDretconf1" class="endofrange"/>
44862 <indexterm role="concept" startref="IIDregconf2" class="endofrange"/>
44863 </para>
44864 </section>
44865 </chapter>
44866
44867 <chapter id="CHAPSMTPAUTH">
44868 <title>SMTP authentication</title>
44869 <para>
44870 <indexterm role="concept" id="IIDauthconf1" class="startofrange">
44871 <primary>SMTP</primary>
44872 <secondary>authentication configuration</secondary>
44873 </indexterm>
44874 <indexterm role="concept" id="IIDauthconf2" class="startofrange">
44875 <primary>authentication</primary>
44876 </indexterm>
44877 The <quote>authenticators</quote> section of Exim&#x2019;s run time configuration is concerned
44878 with SMTP authentication. This facility is an extension to the SMTP protocol,
44879 described in RFC 2554, which allows a client SMTP host to authenticate itself
44880 to a server. This is a common way for a server to recognize clients that are
44881 permitted to use it as a relay. SMTP authentication is not of relevance to the
44882 transfer of mail between servers that have no managerial connection with each
44883 other.
44884 </para>
44885 <para>
44886 <indexterm role="concept">
44887 <primary>AUTH</primary>
44888 <secondary>description of</secondary>
44889 </indexterm>
44890 Very briefly, the way SMTP authentication works is as follows:
44891 </para>
44892 <itemizedlist>
44893 <listitem>
44894 <para>
44895 The server advertises a number of authentication <emphasis>mechanisms</emphasis> in response to
44896 the client&#x2019;s EHLO command.
44897 </para>
44898 </listitem>
44899 <listitem>
44900 <para>
44901 The client issues an AUTH command, naming a specific mechanism. The command
44902 may, optionally, contain some authentication data.
44903 </para>
44904 </listitem>
44905 <listitem>
44906 <para>
44907 The server may issue one or more <emphasis>challenges</emphasis>, to which the client must send
44908 appropriate responses. In simple authentication mechanisms, the challenges are
44909 just prompts for user names and passwords. The server does not have to issue
44910 any challenges &ndash; in some mechanisms the relevant data may all be transmitted
44911 with the AUTH command.
44912 </para>
44913 </listitem>
44914 <listitem>
44915 <para>
44916 The server either accepts or denies authentication.
44917 </para>
44918 </listitem>
44919 <listitem>
44920 <para>
44921 If authentication succeeds, the client may optionally make use of the AUTH
44922 option on the MAIL command to pass an authenticated sender in subsequent
44923 mail transactions. Authentication lasts for the remainder of the SMTP
44924 connection.
44925 </para>
44926 </listitem>
44927 <listitem>
44928 <para>
44929 If authentication fails, the client may give up, or it may try a different
44930 authentication mechanism, or it may try transferring mail over the
44931 unauthenticated connection.
44932 </para>
44933 </listitem>
44934 </itemizedlist>
44935 <para>
44936 If you are setting up a client, and want to know which authentication
44937 mechanisms the server supports, you can use Telnet to connect to port 25 (the
44938 SMTP port) on the server, and issue an EHLO command. The response to this
44939 includes the list of supported mechanisms. For example:
44940 </para>
44941 <literallayout>
44942 <literal>$ </literal><emphasis role="bold"><literal>telnet server.example 25</literal></emphasis>
44943 <literal>Trying 192.168.34.25...</literal>
44944 <literal>Connected to server.example.</literal>
44945 <literal>Escape character is &#x0027;^]&#x0027;.</literal>
44946 <literal>220 server.example ESMTP Exim 4.20 ...</literal>
44947 <emphasis role="bold"><literal>ehlo client.example</literal></emphasis>
44948 <literal>250-server.example Hello client.example [10.8.4.5]</literal>
44949 <literal>250-SIZE 52428800</literal>
44950 <literal>250-PIPELINING</literal>
44951 <literal>250-AUTH PLAIN</literal>
44952 <literal>250 HELP</literal>
44953 </literallayout>
44954 <para>
44955 The second-last line of this example output shows that the server supports
44956 authentication using the PLAIN mechanism. In Exim, the different authentication
44957 mechanisms are configured by specifying <emphasis>authenticator</emphasis> drivers. Like the
44958 routers and transports, which authenticators are included in the binary is
44959 controlled by build-time definitions. The following are currently available,
44960 included by setting
44961 </para>
44962 <literallayout class="monospaced">
44963 AUTH_CRAM_MD5=yes
44964 AUTH_CYRUS_SASL=yes
44965 AUTH_PLAINTEXT=yes
44966 AUTH_SPA=yes
44967 </literallayout>
44968 <para>
44969 in <filename>Local/Makefile</filename>, respectively. The first of these supports the CRAM-MD5
44970 authentication mechanism (RFC 2195), and the second provides an interface to
44971 the Cyrus SASL authentication library. The third can be configured to support
44972 the PLAIN authentication mechanism (RFC 2595) or the LOGIN mechanism, which is
44973 not formally documented, but used by several MUAs. The fourth authenticator
44974 supports Microsoft&#x2019;s <emphasis>Secure Password Authentication</emphasis> mechanism.
44975 </para>
44976 <para>
44977 The authenticators are configured using the same syntax as other drivers (see
44978 section <xref linkend="SECTfordricon"/>). If no authenticators are required, no
44979 authentication section need be present in the configuration file. Each
44980 authenticator can in principle have both server and client functions. When Exim
44981 is receiving SMTP mail, it is acting as a server; when it is sending out
44982 messages over SMTP, it is acting as a client. Authenticator configuration
44983 options are provided for use in both these circumstances.
44984 </para>
44985 <para>
44986 To make it clear which options apply to which situation, the prefixes
44987 <option>server_</option> and <option>client_</option> are used on option names that are specific to
44988 either the server or the client function, respectively. Server and client
44989 functions are disabled if none of their options are set. If an authenticator is
44990 to be used for both server and client functions, a single definition, using
44991 both sets of options, is required. For example:
44992 </para>
44993 <literallayout class="monospaced">
44994 cram:
44995   driver = cram_md5
44996   public_name = CRAM-MD5
44997   server_secret = ${if eq{$auth1}{ph10}{secret1}fail}
44998   client_name = ph10
44999   client_secret = secret2
45000 </literallayout>
45001 <para>
45002 The <option>server_</option> option is used when Exim is acting as a server, and the
45003 <option>client_</option> options when it is acting as a client.
45004 </para>
45005 <para>
45006 Descriptions of the individual authenticators are given in subsequent chapters.
45007 The remainder of this chapter covers the generic options for the
45008 authenticators, followed by general discussion of the way authentication works
45009 in Exim.
45010 </para>
45011 <section id="SECID168">
45012 <title>Generic options for authenticators</title>
45013 <para>
45014 <indexterm role="concept">
45015 <primary>authentication</primary>
45016 <secondary>generic options</secondary>
45017 </indexterm>
45018 <indexterm role="concept">
45019 <primary>options</primary>
45020 <secondary>generic; for authenticators</secondary>
45021 </indexterm>
45022 </para>
45023 <para>
45024 <indexterm role="option">
45025 <primary><option>client_condition</option></primary>
45026 </indexterm>
45027 </para>
45028 <informaltable frame="all">
45029 <tgroup cols="4" colsep="0" rowsep="0">
45030 <colspec colwidth="8*" align="left"/>
45031 <colspec colwidth="6*" align="center"/>
45032 <colspec colwidth="6*" align="center"/>
45033 <colspec colwidth="6*" align="right"/>
45034 <tbody>
45035 <row>
45036 <entry><option>client_condition</option></entry>
45037 <entry>Use: <emphasis>authenticators</emphasis></entry>
45038 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45039 <entry>Default: <emphasis>unset</emphasis></entry>
45040 </row>
45041 </tbody>
45042 </tgroup>
45043 </informaltable>
45044 <para>
45045 When Exim is authenticating as a client, it skips any authenticator whose
45046 <option>client_condition</option> expansion yields <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>. This can be
45047 used, for example, to skip plain text authenticators when the connection is not
45048 encrypted by a setting such as:
45049 </para>
45050 <literallayout class="monospaced">
45051 client_condition = ${if !eq{$tls_cipher}{}}
45052 </literallayout>
45053 <para>
45054 (Older documentation incorrectly states that <varname>$tls_cipher</varname> contains the cipher
45055 used for incoming messages. In fact, during SMTP delivery, it contains the
45056 cipher used for the delivery.)
45057 </para>
45058 <para>
45059 <indexterm role="option">
45060 <primary><option>driver</option></primary>
45061 </indexterm>
45062 </para>
45063 <informaltable frame="all">
45064 <tgroup cols="4" colsep="0" rowsep="0">
45065 <colspec colwidth="8*" align="left"/>
45066 <colspec colwidth="6*" align="center"/>
45067 <colspec colwidth="6*" align="center"/>
45068 <colspec colwidth="6*" align="right"/>
45069 <tbody>
45070 <row>
45071 <entry><option>driver</option></entry>
45072 <entry>Use: <emphasis>authenticators</emphasis></entry>
45073 <entry>Type: <emphasis>string</emphasis></entry>
45074 <entry>Default: <emphasis>unset</emphasis></entry>
45075 </row>
45076 </tbody>
45077 </tgroup>
45078 </informaltable>
45079 <para>
45080 This option must always be set. It specifies which of the available
45081 authenticators is to be used.
45082 </para>
45083 <para>
45084 <indexterm role="option">
45085 <primary><option>public_name</option></primary>
45086 </indexterm>
45087 </para>
45088 <informaltable frame="all">
45089 <tgroup cols="4" colsep="0" rowsep="0">
45090 <colspec colwidth="8*" align="left"/>
45091 <colspec colwidth="6*" align="center"/>
45092 <colspec colwidth="6*" align="center"/>
45093 <colspec colwidth="6*" align="right"/>
45094 <tbody>
45095 <row>
45096 <entry><option>public_name</option></entry>
45097 <entry>Use: <emphasis>authenticators</emphasis></entry>
45098 <entry>Type: <emphasis>string</emphasis></entry>
45099 <entry>Default: <emphasis>unset</emphasis></entry>
45100 </row>
45101 </tbody>
45102 </tgroup>
45103 </informaltable>
45104 <para>
45105 This option specifies the name of the authentication mechanism that the driver
45106 implements, and by which it is known to the outside world. These names should
45107 contain only upper case letters, digits, underscores, and hyphens (RFC 2222),
45108 but Exim in fact matches them caselessly. If <option>public_name</option> is not set, it
45109 defaults to the driver&#x2019;s instance name.
45110 </para>
45111 <para>
45112 <indexterm role="option">
45113 <primary><option>server_advertise_condition</option></primary>
45114 </indexterm>
45115 </para>
45116 <informaltable frame="all">
45117 <tgroup cols="4" colsep="0" rowsep="0">
45118 <colspec colwidth="8*" align="left"/>
45119 <colspec colwidth="6*" align="center"/>
45120 <colspec colwidth="6*" align="center"/>
45121 <colspec colwidth="6*" align="right"/>
45122 <tbody>
45123 <row>
45124 <entry><option>server_advertise_condition</option></entry>
45125 <entry>Use: <emphasis>authenticators</emphasis></entry>
45126 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45127 <entry>Default: <emphasis>unset</emphasis></entry>
45128 </row>
45129 </tbody>
45130 </tgroup>
45131 </informaltable>
45132 <para>
45133 When a server is about to advertise an authentication mechanism, the condition
45134 is expanded. If it yields the empty string, <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, the
45135 mechanism is not advertised.
45136 If the expansion fails, the mechanism is not advertised. If the failure was not
45137 forced, and was not caused by a lookup defer, the incident is logged.
45138 See section <xref linkend="SECTauthexiser"/> below for further discussion.
45139 </para>
45140 <para>
45141 <indexterm role="option">
45142 <primary><option>server_condition</option></primary>
45143 </indexterm>
45144 </para>
45145 <informaltable frame="all">
45146 <tgroup cols="4" colsep="0" rowsep="0">
45147 <colspec colwidth="8*" align="left"/>
45148 <colspec colwidth="6*" align="center"/>
45149 <colspec colwidth="6*" align="center"/>
45150 <colspec colwidth="6*" align="right"/>
45151 <tbody>
45152 <row>
45153 <entry><option>server_condition</option></entry>
45154 <entry>Use: <emphasis>authenticators</emphasis></entry>
45155 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45156 <entry>Default: <emphasis>unset</emphasis></entry>
45157 </row>
45158 </tbody>
45159 </tgroup>
45160 </informaltable>
45161 <para>
45162 This option must be set for a <option>plaintext</option> server authenticator, where it
45163 is used directly to control authentication. See section <xref linkend="SECTplainserver"/>
45164 for details.
45165 </para>
45166 <para>
45167 For the other authenticators, <option>server_condition</option> can be used as an additional
45168 authentication or authorization mechanism that is applied after the other
45169 authenticator conditions succeed. If it is set, it is expanded when the
45170 authenticator would otherwise return a success code. If the expansion is forced
45171 to fail, authentication fails. Any other expansion failure causes a temporary
45172 error code to be returned. If the result of a successful expansion is an empty
45173 string, <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, authentication fails. If the result of the
45174 expansion is <quote>1</quote>, <quote>yes</quote>, or <quote>true</quote>, authentication succeeds. For any
45175 other result, a temporary error code is returned, with the expanded string as
45176 the error text.
45177 </para>
45178 <para>
45179 <indexterm role="option">
45180 <primary><option>server_debug_print</option></primary>
45181 </indexterm>
45182 </para>
45183 <informaltable frame="all">
45184 <tgroup cols="4" colsep="0" rowsep="0">
45185 <colspec colwidth="8*" align="left"/>
45186 <colspec colwidth="6*" align="center"/>
45187 <colspec colwidth="6*" align="center"/>
45188 <colspec colwidth="6*" align="right"/>
45189 <tbody>
45190 <row>
45191 <entry><option>server_debug_print</option></entry>
45192 <entry>Use: <emphasis>authenticators</emphasis></entry>
45193 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45194 <entry>Default: <emphasis>unset</emphasis></entry>
45195 </row>
45196 </tbody>
45197 </tgroup>
45198 </informaltable>
45199 <para>
45200 If this option is set and authentication debugging is enabled (see the <option>-d</option>
45201 command line option), the string is expanded and included in the debugging
45202 output when the authenticator is run as a server. This can help with checking
45203 out the values of variables.
45204 If expansion of the string fails, the error message is written to the debugging
45205 output, and Exim carries on processing.
45206 </para>
45207 <para>
45208 <indexterm role="option">
45209 <primary><option>server_set_id</option></primary>
45210 </indexterm>
45211 </para>
45212 <informaltable frame="all">
45213 <tgroup cols="4" colsep="0" rowsep="0">
45214 <colspec colwidth="8*" align="left"/>
45215 <colspec colwidth="6*" align="center"/>
45216 <colspec colwidth="6*" align="center"/>
45217 <colspec colwidth="6*" align="right"/>
45218 <tbody>
45219 <row>
45220 <entry><option>server_set_id</option></entry>
45221 <entry>Use: <emphasis>authenticators</emphasis></entry>
45222 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45223 <entry>Default: <emphasis>unset</emphasis></entry>
45224 </row>
45225 </tbody>
45226 </tgroup>
45227 </informaltable>
45228 <para>
45229 <indexterm role="variable">
45230 <primary><varname>$authenticated_id</varname></primary>
45231 </indexterm>
45232 When an Exim server successfully authenticates a client, this string is
45233 expanded using data from the authentication, and preserved for any incoming
45234 messages in the variable <varname>$authenticated_id</varname>. It is also included in the log
45235 lines for incoming messages. For example, a user/password authenticator
45236 configuration might preserve the user name that was used to authenticate, and
45237 refer to it subsequently during delivery of the message.
45238 If expansion fails, the option is ignored.
45239 </para>
45240 <para>
45241 <indexterm role="option">
45242 <primary><option>server_mail_auth_condition</option></primary>
45243 </indexterm>
45244 </para>
45245 <informaltable frame="all">
45246 <tgroup cols="4" colsep="0" rowsep="0">
45247 <colspec colwidth="8*" align="left"/>
45248 <colspec colwidth="6*" align="center"/>
45249 <colspec colwidth="6*" align="center"/>
45250 <colspec colwidth="6*" align="right"/>
45251 <tbody>
45252 <row>
45253 <entry><option>server_mail_auth_condition</option></entry>
45254 <entry>Use: <emphasis>authenticators</emphasis></entry>
45255 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45256 <entry>Default: <emphasis>unset</emphasis></entry>
45257 </row>
45258 </tbody>
45259 </tgroup>
45260 </informaltable>
45261 <para>
45262 This option allows a server to discard authenticated sender addresses supplied
45263 as part of MAIL commands in SMTP connections that are authenticated by the
45264 driver on which <option>server_mail_auth_condition</option> is set. The option is not used
45265 as part of the authentication process; instead its (unexpanded) value is
45266 remembered for later use.
45267 How it is used is described in the following section.
45268 </para>
45269 </section>
45270 <section id="SECTauthparamail">
45271 <title>The AUTH parameter on MAIL commands</title>
45272 <para>
45273 <indexterm role="concept">
45274 <primary>authentication</primary>
45275 <secondary>sender; authenticated</secondary>
45276 </indexterm>
45277 <indexterm role="concept">
45278 <primary>AUTH</primary>
45279 <secondary>on MAIL command</secondary>
45280 </indexterm>
45281 When a client supplied an AUTH= item on a MAIL command, Exim applies
45282 the following checks before accepting it as the authenticated sender of the
45283 message:
45284 </para>
45285 <itemizedlist>
45286 <listitem>
45287 <para>
45288 If the connection is not using extended SMTP (that is, HELO was used rather
45289 than EHLO), the use of AUTH= is a syntax error.
45290 </para>
45291 </listitem>
45292 <listitem>
45293 <para>
45294 If the value of the AUTH= parameter is <quote>&lt;&gt;</quote>, it is ignored.
45295 </para>
45296 </listitem>
45297 <listitem>
45298 <para>
45299 <indexterm role="variable">
45300 <primary><varname>$authenticated_sender</varname></primary>
45301 </indexterm>
45302 If <option>acl_smtp_mailauth</option> is defined, the ACL it specifies is run. While it is
45303 running, the value of <varname>$authenticated_sender</varname> is set to the value obtained
45304 from the AUTH= parameter. If the ACL does not yield <quote>accept</quote>, the value of
45305 <varname>$authenticated_sender</varname> is deleted. The <option>acl_smtp_mailauth</option> ACL may not
45306 return <quote>drop</quote> or <quote>discard</quote>. If it defers, a temporary error code (451) is
45307 given for the MAIL command.
45308 </para>
45309 </listitem>
45310 <listitem>
45311 <para>
45312 If <option>acl_smtp_mailauth</option> is not defined, the value of the AUTH= parameter
45313 is accepted and placed in <varname>$authenticated_sender</varname> only if the client has
45314 authenticated.
45315 </para>
45316 </listitem>
45317 <listitem>
45318 <para>
45319 If the AUTH= value was accepted by either of the two previous rules, and
45320 the client has authenticated, and the authenticator has a setting for the
45321 <option>server_mail_auth_condition</option>, the condition is checked at this point. The
45322 valued that was saved from the authenticator is expanded. If the expansion
45323 fails, or yields an empty string, <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, the value of
45324 <varname>$authenticated_sender</varname> is deleted. If the expansion yields any other value,
45325 the value of <varname>$authenticated_sender</varname> is retained and passed on with the
45326 message.
45327 </para>
45328 </listitem>
45329 </itemizedlist>
45330 <para>
45331 When <varname>$authenticated_sender</varname> is set for a message, it is passed on to other
45332 hosts to which Exim authenticates as a client. Do not confuse this value with
45333 <varname>$authenticated_id</varname>, which is a string obtained from the authentication
45334 process, and which is not usually a complete email address.
45335 </para>
45336 <para>
45337 <indexterm role="variable">
45338 <primary><varname>$sender_address</varname></primary>
45339 </indexterm>
45340 Whenever an AUTH= value is ignored, the incident is logged. The ACL for
45341 MAIL, if defined, is run after AUTH= is accepted or ignored. It can
45342 therefore make use of <varname>$authenticated_sender</varname>. The converse is not true: the
45343 value of <varname>$sender_address</varname> is not yet set up when the <option>acl_smtp_mailauth</option>
45344 ACL is run.
45345 </para>
45346 </section>
45347 <section id="SECTauthexiser">
45348 <title>Authentication on an Exim server</title>
45349 <para>
45350 <indexterm role="concept">
45351 <primary>authentication</primary>
45352 <secondary>on an Exim server</secondary>
45353 </indexterm>
45354 When Exim receives an EHLO command, it advertises the public names of those
45355 authenticators that are configured as servers, subject to the following
45356 conditions:
45357 </para>
45358 <itemizedlist>
45359 <listitem>
45360 <para>
45361 The client host must match <option>auth_advertise_hosts</option> (default *).
45362 </para>
45363 </listitem>
45364 <listitem>
45365 <para>
45366 It the <option>server_advertise_condition</option> option is set, its expansion must not
45367 yield the empty string, <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>.
45368 </para>
45369 </listitem>
45370 </itemizedlist>
45371 <para>
45372 The order in which the authenticators are defined controls the order in which
45373 the mechanisms are advertised.
45374 </para>
45375 <para>
45376 Some mail clients (for example, some versions of Netscape) require the user to
45377 provide a name and password for authentication whenever AUTH is advertised,
45378 even though authentication may not in fact be needed (for example, Exim may be
45379 set up to allow unconditional relaying from the client by an IP address check).
45380 You can make such clients more friendly by not advertising AUTH to them.
45381 For example, if clients on the 10.9.8.0/24 network are permitted (by the ACL
45382 that runs for RCPT) to relay without authentication, you should set
45383 </para>
45384 <literallayout class="monospaced">
45385 auth_advertise_hosts = ! 10.9.8.0/24
45386 </literallayout>
45387 <para>
45388 so that no authentication mechanisms are advertised to them.
45389 </para>
45390 <para>
45391 The <option>server_advertise_condition</option> controls the advertisement of individual
45392 authentication mechanisms. For example, it can be used to restrict the
45393 advertisement of a particular mechanism to encrypted connections, by a setting
45394 such as:
45395 </para>
45396 <literallayout class="monospaced">
45397 server_advertise_condition = ${if eq{$tls_cipher}{}{no}{yes}}
45398 </literallayout>
45399 <para>
45400 <indexterm role="variable">
45401 <primary><varname>$tls_cipher</varname></primary>
45402 </indexterm>
45403 If the session is encrypted, <varname>$tls_cipher</varname> is not empty, and so the expansion
45404 yields <quote>yes</quote>, which allows the advertisement to happen.
45405 </para>
45406 <para>
45407 When an Exim server receives an AUTH command from a client, it rejects it
45408 immediately if AUTH was not advertised in response to an earlier EHLO
45409 command. This is the case if
45410 </para>
45411 <itemizedlist>
45412 <listitem>
45413 <para>
45414 The client host does not match <option>auth_advertise_hosts</option>; or
45415 </para>
45416 </listitem>
45417 <listitem>
45418 <para>
45419 No authenticators are configured with server options; or
45420 </para>
45421 </listitem>
45422 <listitem>
45423 <para>
45424 Expansion of <option>server_advertise_condition</option> blocked the advertising of all the
45425 server authenticators.
45426 </para>
45427 </listitem>
45428 </itemizedlist>
45429 <para>
45430 Otherwise, Exim runs the ACL specified by <option>acl_smtp_auth</option> in order
45431 to decide whether to accept the command. If <option>acl_smtp_auth</option> is not set,
45432 AUTH is accepted from any client host.
45433 </para>
45434 <para>
45435 If AUTH is not rejected by the ACL, Exim searches its configuration for a
45436 server authentication mechanism that was advertised in response to EHLO and
45437 that matches the one named in the AUTH command. If it finds one, it runs
45438 the appropriate authentication protocol, and authentication either succeeds or
45439 fails. If there is no matching advertised mechanism, the AUTH command is
45440 rejected with a 504 error.
45441 </para>
45442 <para>
45443 <indexterm role="variable">
45444 <primary><varname>$received_protocol</varname></primary>
45445 </indexterm>
45446 <indexterm role="variable">
45447 <primary><varname>$sender_host_authenticated</varname></primary>
45448 </indexterm>
45449 When a message is received from an authenticated host, the value of
45450 <varname>$received_protocol</varname> is set to <quote>esmtpa</quote> or <quote>esmtpsa</quote> instead of <quote>esmtp</quote>
45451 or <quote>esmtps</quote>, and <varname>$sender_host_authenticated</varname> contains the name (not the
45452 public name) of the authenticator driver that successfully authenticated the
45453 client from which the message was received. This variable is empty if there was
45454 no successful authentication.
45455 </para>
45456 </section>
45457 <section id="SECID169">
45458 <title>Testing server authentication</title>
45459 <para>
45460 <indexterm role="concept">
45461 <primary>authentication</primary>
45462 <secondary>testing a server</secondary>
45463 </indexterm>
45464 <indexterm role="concept">
45465 <primary>AUTH</primary>
45466 <secondary>testing a server</secondary>
45467 </indexterm>
45468 <indexterm role="concept">
45469 <primary>base64 encoding</primary>
45470 <secondary>creating authentication test data</secondary>
45471 </indexterm>
45472 Exim&#x2019;s <option>-bh</option> option can be useful for testing server authentication
45473 configurations. The data for the AUTH command has to be sent using base64
45474 encoding. A quick way to produce such data for testing is the following Perl
45475 script:
45476 </para>
45477 <literallayout class="monospaced">
45478 use MIME::Base64;
45479 printf ("%s", encode_base64(eval "\"$ARGV[0]\""));
45480 </literallayout>
45481 <para>
45482 <indexterm role="concept">
45483 <primary>binary zero</primary>
45484 <secondary>in authentication data</secondary>
45485 </indexterm>
45486 This interprets its argument as a Perl string, and then encodes it. The
45487 interpretation as a Perl string allows binary zeros, which are required for
45488 some kinds of authentication, to be included in the data. For example, a
45489 command line to run this script on such data might be
45490 </para>
45491 <literallayout class="monospaced">
45492 encode '\0user\0password'
45493 </literallayout>
45494 <para>
45495 Note the use of single quotes to prevent the shell interpreting the
45496 backslashes, so that they can be interpreted by Perl to specify characters
45497 whose code value is zero.
45498 </para>
45499 <para>
45500 <emphasis role="bold">Warning 1</emphasis>: If either of the user or password strings starts with an octal
45501 digit, you must use three zeros instead of one after the leading backslash. If
45502 you do not, the octal digit that starts your string will be incorrectly
45503 interpreted as part of the code for the first character.
45504 </para>
45505 <para>
45506 <emphasis role="bold">Warning 2</emphasis>: If there are characters in the strings that Perl interprets
45507 specially, you must use a Perl escape to prevent them being misinterpreted. For
45508 example, a command such as
45509 </para>
45510 <literallayout class="monospaced">
45511 encode '\0user@domain.com\0pas$$word'
45512 </literallayout>
45513 <para>
45514 gives an incorrect answer because of the unescaped <quote>@</quote> and <quote>$</quote> characters.
45515 </para>
45516 <para>
45517 If you have the <option>mimencode</option> command installed, another way to do produce
45518 base64-encoded strings is to run the command
45519 </para>
45520 <literallayout class="monospaced">
45521 echo -e -n `\0user\0password' | mimencode
45522 </literallayout>
45523 <para>
45524 The <option>-e</option> option of <option>echo</option> enables the interpretation of backslash escapes
45525 in the argument, and the <option>-n</option> option specifies no newline at the end of its
45526 output. However, not all versions of <option>echo</option> recognize these options, so you
45527 should check your version before relying on this suggestion.
45528 </para>
45529 </section>
45530 <section id="SECID170">
45531 <title>Authentication by an Exim client</title>
45532 <para>
45533 <indexterm role="concept">
45534 <primary>authentication</primary>
45535 <secondary>on an Exim client</secondary>
45536 </indexterm>
45537 The <command>smtp</command> transport has two options called <option>hosts_require_auth</option> and
45538 <option>hosts_try_auth</option>. When the <command>smtp</command> transport connects to a server that
45539 announces support for authentication, and the host matches an entry in either
45540 of these options, Exim (as a client) tries to authenticate as follows:
45541 </para>
45542 <itemizedlist>
45543 <listitem>
45544 <para>
45545 For each authenticator that is configured as a client, in the order in which
45546 they are defined in the configuration, it searches the authentication
45547 mechanisms announced by the server for one whose name matches the public name
45548 of the authenticator.
45549 </para>
45550 </listitem>
45551 <listitem>
45552 <para>
45553 <indexterm role="variable">
45554 <primary><varname>$host</varname></primary>
45555 </indexterm>
45556 <indexterm role="variable">
45557 <primary><varname>$host_address</varname></primary>
45558 </indexterm>
45559 When it finds one that matches, it runs the authenticator&#x2019;s client code. The
45560 variables <varname>$host</varname> and <varname>$host_address</varname> are available for any string expansions
45561 that the client might do. They are set to the server&#x2019;s name and IP address. If
45562 any expansion is forced to fail, the authentication attempt is abandoned, and
45563 Exim moves on to the next authenticator. Otherwise an expansion failure causes
45564 delivery to be deferred.
45565 </para>
45566 </listitem>
45567 <listitem>
45568 <para>
45569 If the result of the authentication attempt is a temporary error or a timeout,
45570 Exim abandons trying to send the message to the host for the moment. It will
45571 try again later. If there are any backup hosts available, they are tried in the
45572 usual way.
45573 </para>
45574 </listitem>
45575 <listitem>
45576 <para>
45577 If the response to authentication is a permanent error (5<emphasis>xx</emphasis> code), Exim
45578 carries on searching the list of authenticators and tries another one if
45579 possible. If all authentication attempts give permanent errors, or if there are
45580 no attempts because no mechanisms match (or option expansions force failure),
45581 what happens depends on whether the host matches <option>hosts_require_auth</option> or
45582 <option>hosts_try_auth</option>. In the first case, a temporary error is generated, and
45583 delivery is deferred. The error can be detected in the retry rules, and thereby
45584 turned into a permanent error if you wish. In the second case, Exim tries to
45585 deliver the message unauthenticated.
45586 </para>
45587 </listitem>
45588 </itemizedlist>
45589 <para>
45590 <indexterm role="concept">
45591 <primary>AUTH</primary>
45592 <secondary>on MAIL command</secondary>
45593 </indexterm>
45594 When Exim has authenticated itself to a remote server, it adds the AUTH
45595 parameter to the MAIL commands it sends, if it has an authenticated sender for
45596 the message. If the message came from a remote host, the authenticated sender
45597 is the one that was receiving on an incoming MAIL command, provided that the
45598 incoming connection was authenticated and the <option>server_mail_auth</option> condition
45599 allowed the authenticated sender to be retained. If a local process calls Exim
45600 to send a message, the sender address that is built from the login name and
45601 <option>qualify_domain</option> is treated as authenticated. However, if the
45602 <option>authenticated_sender</option> option is set on the <command>smtp</command> transport, it overrides
45603 the authenticated sender that was received with the message.
45604 <indexterm role="concept" startref="IIDauthconf1" class="endofrange"/>
45605 <indexterm role="concept" startref="IIDauthconf2" class="endofrange"/>
45606 </para>
45607 </section>
45608 </chapter>
45609
45610 <chapter id="CHAPplaintext">
45611 <title>The plaintext authenticator</title>
45612 <para>
45613 <indexterm role="concept" id="IIDplaiauth1" class="startofrange">
45614 <primary><command>plaintext</command> authenticator</primary>
45615 </indexterm>
45616 <indexterm role="concept" id="IIDplaiauth2" class="startofrange">
45617 <primary>authenticators</primary>
45618 <secondary><command>plaintext</command></secondary>
45619 </indexterm>
45620 The <command>plaintext</command> authenticator can be configured to support the PLAIN and
45621 LOGIN authentication mechanisms, both of which transfer authentication data as
45622 plain (unencrypted) text (though base64 encoded). The use of plain text is a
45623 security risk; you are strongly advised to insist on the use of SMTP encryption
45624 (see chapter <xref linkend="CHAPTLS"/>) if you use the PLAIN or LOGIN mechanisms. If you do
45625 use unencrypted plain text, you should not use the same passwords for SMTP
45626 connections as you do for login accounts.
45627 </para>
45628 <section id="SECID171">
45629 <title>Plaintext options</title>
45630 <para>
45631 <indexterm role="concept">
45632 <primary>options</primary>
45633 <secondary><command>plaintext</command> authenticator (server)</secondary>
45634 </indexterm>
45635 When configured as a server, <command>plaintext</command> uses the following options:
45636 </para>
45637 <para>
45638 <indexterm role="option">
45639 <primary><option>server_condition</option></primary>
45640 </indexterm>
45641 </para>
45642 <informaltable frame="all">
45643 <tgroup cols="4" colsep="0" rowsep="0">
45644 <colspec colwidth="8*" align="left"/>
45645 <colspec colwidth="6*" align="center"/>
45646 <colspec colwidth="6*" align="center"/>
45647 <colspec colwidth="6*" align="right"/>
45648 <tbody>
45649 <row>
45650 <entry><option>server_condition</option></entry>
45651 <entry>Use: <emphasis>authenticators</emphasis></entry>
45652 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45653 <entry>Default: <emphasis>unset</emphasis></entry>
45654 </row>
45655 </tbody>
45656 </tgroup>
45657 </informaltable>
45658 <para>
45659 This is actually a global authentication option, but it must be set in order to
45660 configure the <command>plaintext</command> driver as a server. Its use is described below.
45661 </para>
45662 <para>
45663 <indexterm role="option">
45664 <primary><option>server_prompts</option></primary>
45665 </indexterm>
45666 </para>
45667 <informaltable frame="all">
45668 <tgroup cols="4" colsep="0" rowsep="0">
45669 <colspec colwidth="8*" align="left"/>
45670 <colspec colwidth="6*" align="center"/>
45671 <colspec colwidth="6*" align="center"/>
45672 <colspec colwidth="6*" align="right"/>
45673 <tbody>
45674 <row>
45675 <entry><option>server_prompts</option></entry>
45676 <entry>Use: <emphasis>plaintext</emphasis></entry>
45677 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45678 <entry>Default: <emphasis>unset</emphasis></entry>
45679 </row>
45680 </tbody>
45681 </tgroup>
45682 </informaltable>
45683 <para>
45684 The contents of this option, after expansion, must be a colon-separated list of
45685 prompt strings. If expansion fails, a temporary authentication rejection is
45686 given.
45687 </para>
45688 </section>
45689 <section id="SECTplainserver">
45690 <title>Using plaintext in a server</title>
45691 <para>
45692 <indexterm role="concept">
45693 <primary>AUTH</primary>
45694 <secondary>in <command>plaintext</command> authenticator</secondary>
45695 </indexterm>
45696 <indexterm role="concept">
45697 <primary>binary zero</primary>
45698 <secondary>in <command>plaintext</command> authenticator</secondary>
45699 </indexterm>
45700 <indexterm role="concept">
45701 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
45702 <secondary>in <command>plaintext</command> authenticator</secondary>
45703 </indexterm>
45704 <indexterm role="variable">
45705 <primary><varname>$auth1</varname>, <varname>$auth2</varname>, etc</primary>
45706 </indexterm>
45707 <indexterm role="concept">
45708 <primary>base64 encoding</primary>
45709 <secondary>in <command>plaintext</command> authenticator</secondary>
45710 </indexterm>
45711 </para>
45712 <para>
45713 When running as a server, <command>plaintext</command> performs the authentication test by
45714 expanding a string. The data sent by the client with the AUTH command, or in
45715 response to subsequent prompts, is base64 encoded, and so may contain any byte
45716 values when decoded. If any data is supplied with the command, it is treated as
45717 a list of strings, separated by NULs (binary zeros), the first three of which
45718 are placed in the expansion variables <varname>$auth1</varname>, <varname>$auth2</varname>, and <varname>$auth3</varname>
45719 (neither LOGIN nor PLAIN uses more than three strings).
45720 </para>
45721 <para>
45722 For compatibility with previous releases of Exim, the values are also placed in
45723 the expansion variables <varname>$1</varname>, <varname>$2</varname>, and <varname>$3</varname>. However, the use of these
45724 variables for this purpose is now deprecated, as it can lead to confusion in
45725 string expansions that also use them for other things.
45726 </para>
45727 <para>
45728 If there are more strings in <option>server_prompts</option> than the number of strings
45729 supplied with the AUTH command, the remaining prompts are used to obtain more
45730 data. Each response from the client may be a list of NUL-separated strings.
45731 </para>
45732 <para>
45733 <indexterm role="variable">
45734 <primary><varname>$authenticated_id</varname></primary>
45735 </indexterm>
45736 Once a sufficient number of data strings have been received,
45737 <option>server_condition</option> is expanded. If the expansion is forced to fail,
45738 authentication fails. Any other expansion failure causes a temporary error code
45739 to be returned. If the result of a successful expansion is an empty string,
45740 <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, authentication fails. If the result of the
45741 expansion is <quote>1</quote>, <quote>yes</quote>, or <quote>true</quote>, authentication succeeds and the
45742 generic <option>server_set_id</option> option is expanded and saved in <varname>$authenticated_id</varname>.
45743 For any other result, a temporary error code is returned, with the expanded
45744 string as the error text.
45745 </para>
45746 <para>
45747 <emphasis role="bold">Warning</emphasis>: If you use a lookup in the expansion to find the user&#x2019;s
45748 password, be sure to make the authentication fail if the user is unknown.
45749 There are good and bad examples at the end of the next section.
45750 </para>
45751 </section>
45752 <section id="SECID172">
45753 <title>The PLAIN authentication mechanism</title>
45754 <para>
45755 <indexterm role="concept">
45756 <primary>PLAIN authentication mechanism</primary>
45757 </indexterm>
45758 <indexterm role="concept">
45759 <primary>authentication</primary>
45760 <secondary>PLAIN mechanism</secondary>
45761 </indexterm>
45762 <indexterm role="concept">
45763 <primary>binary zero</primary>
45764 <secondary>in <command>plaintext</command> authenticator</secondary>
45765 </indexterm>
45766 The PLAIN authentication mechanism (RFC 2595) specifies that three strings be
45767 sent as one item of data (that is, one combined string containing two NUL
45768 separators). The data is sent either as part of the AUTH command, or
45769 subsequently in response to an empty prompt from the server.
45770 </para>
45771 <para>
45772 The second and third strings are a user name and a corresponding password.
45773 Using a single fixed user name and password as an example, this could be
45774 configured as follows:
45775 </para>
45776 <literallayout class="monospaced">
45777 fixed_plain:
45778   driver = plaintext
45779   public_name = PLAIN
45780   server_prompts = :
45781   server_condition = \
45782     ${if and {{eq{$auth2}{username}}{eq{$auth3}{mysecret}}}}
45783   server_set_id = $auth2
45784 </literallayout>
45785 <para>
45786 Note that the default result strings from <option>if</option> (<quote>true</quote> or an empty string)
45787 are exactly what we want here, so they need not be specified. Obviously, if the
45788 password contains expansion-significant characters such as dollar, backslash,
45789 or closing brace, they have to be escaped.
45790 </para>
45791 <para>
45792 The <option>server_prompts</option> setting specifies a single, empty prompt (empty items at
45793 the end of a string list are ignored). If all the data comes as part of the
45794 AUTH command, as is commonly the case, the prompt is not used. This
45795 authenticator is advertised in the response to EHLO as
45796 </para>
45797 <literallayout class="monospaced">
45798 250-AUTH PLAIN
45799 </literallayout>
45800 <para>
45801 and a client host can authenticate itself by sending the command
45802 </para>
45803 <literallayout class="monospaced">
45804 AUTH PLAIN AHVzZXJuYW1lAG15c2VjcmV0
45805 </literallayout>
45806 <para>
45807 As this contains three strings (more than the number of prompts), no further
45808 data is required from the client. Alternatively, the client may just send
45809 </para>
45810 <literallayout class="monospaced">
45811 AUTH PLAIN
45812 </literallayout>
45813 <para>
45814 to initiate authentication, in which case the server replies with an empty
45815 prompt. The client must respond with the combined data string.
45816 </para>
45817 <para>
45818 The data string is base64 encoded, as required by the RFC. This example,
45819 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;
45820 represents a zero byte. This is split up into three strings, the first of which
45821 is empty. The <option>server_condition</option> option in the authenticator checks that the
45822 second two are <literal>username</literal> and <literal>mysecret</literal> respectively.
45823 </para>
45824 <para>
45825 Having just one fixed user name and password, as in this example, is not very
45826 realistic, though for a small organization with only a handful of
45827 authenticating clients it could make sense.
45828 </para>
45829 <para>
45830 A more sophisticated instance of this authenticator could use the user name in
45831 <varname>$auth2</varname> to look up a password in a file or database, and maybe do an encrypted
45832 comparison (see <option>crypteq</option> in chapter <xref linkend="CHAPexpand"/>). Here is a example of
45833 this approach, where the passwords are looked up in a DBM file. <emphasis role="bold">Warning</emphasis>:
45834 This is an incorrect example:
45835 </para>
45836 <literallayout class="monospaced">
45837 server_condition = \
45838   ${if eq{$auth3}{${lookup{$auth2}dbm{/etc/authpwd}}}}
45839 </literallayout>
45840 <para>
45841 The expansion uses the user name (<varname>$auth2</varname>) as the key to look up a password,
45842 which it then compares to the supplied password (<varname>$auth3</varname>). Why is this example
45843 incorrect? It works fine for existing users, but consider what happens if a
45844 non-existent user name is given. The lookup fails, but as no success/failure
45845 strings are given for the lookup, it yields an empty string. Thus, to defeat
45846 the authentication, all a client has to do is to supply a non-existent user
45847 name and an empty password. The correct way of writing this test is:
45848 </para>
45849 <literallayout class="monospaced">
45850 server_condition = ${lookup{$auth2}dbm{/etc/authpwd}\
45851   {${if eq{$value}{$auth3}}} {false}}
45852 </literallayout>
45853 <para>
45854 In this case, if the lookup succeeds, the result is checked; if the lookup
45855 fails, <quote>false</quote> is returned and authentication fails. If <option>crypteq</option> is being
45856 used instead of <option>eq</option>, the first example is in fact safe, because <option>crypteq</option>
45857 always fails if its second argument is empty. However, the second way of
45858 writing the test makes the logic clearer.
45859 </para>
45860 </section>
45861 <section id="SECID173">
45862 <title>The LOGIN authentication mechanism</title>
45863 <para>
45864 <indexterm role="concept">
45865 <primary>LOGIN authentication mechanism</primary>
45866 </indexterm>
45867 <indexterm role="concept">
45868 <primary>authentication</primary>
45869 <secondary>LOGIN mechanism</secondary>
45870 </indexterm>
45871 The LOGIN authentication mechanism is not documented in any RFC, but is in use
45872 in a number of programs. No data is sent with the AUTH command. Instead, a
45873 user name and password are supplied separately, in response to prompts. The
45874 plaintext authenticator can be configured to support this as in this example:
45875 </para>
45876 <literallayout class="monospaced">
45877 fixed_login:
45878   driver = plaintext
45879   public_name = LOGIN
45880   server_prompts = User Name : Password
45881   server_condition = \
45882     ${if and {{eq{$auth1}{username}}{eq{$auth2}{mysecret}}}}
45883   server_set_id = $auth1
45884 </literallayout>
45885 <para>
45886 Because of the way plaintext operates, this authenticator accepts data supplied
45887 with the AUTH command (in contravention of the specification of LOGIN), but
45888 if the client does not supply it (as is the case for LOGIN clients), the prompt
45889 strings are used to obtain two data items.
45890 </para>
45891 <para>
45892 Some clients are very particular about the precise text of the prompts. For
45893 example, Outlook Express is reported to recognize only <quote>Username:</quote> and
45894 <quote>Password:</quote>. Here is an example of a LOGIN authenticator that uses those
45895 strings. It uses the <option>ldapauth</option> expansion condition to check the user
45896 name and password by binding to an LDAP server:
45897 </para>
45898 <literallayout class="monospaced">
45899 login:
45900   driver = plaintext
45901   public_name = LOGIN
45902   server_prompts = Username:: : Password::
45903   server_condition = ${if and{{ \
45904     !eq{}{$auth1} }{ \
45905     ldapauth{user="cn=${quote_ldap_dn:$auth1},ou=people,o=example.org" \
45906              pass=${quote:$auth2} \
45907              ldap://ldap.example.org/} }} }
45908   server_set_id = uid=$auth1,ou=people,o=example.org
45909 </literallayout>
45910 <para>
45911 We have to check that the username is not empty before using it, because LDAP
45912 does not permit empty DN components. We must also use the <option>quote_ldap_dn</option>
45913 operator to correctly quote the DN for authentication. However, the basic
45914 <option>quote</option> operator, rather than any of the LDAP quoting operators, is the
45915 correct one to use for the password, because quoting is needed only to make
45916 the password conform to the Exim syntax. At the LDAP level, the password is an
45917 uninterpreted string.
45918 </para>
45919 </section>
45920 <section id="SECID174">
45921 <title>Support for different kinds of authentication</title>
45922 <para>
45923 A number of string expansion features are provided for the purpose of
45924 interfacing to different ways of user authentication. These include checking
45925 traditionally encrypted passwords from <filename>/etc/passwd</filename> (or equivalent), PAM,
45926 Radius, <option>ldapauth</option>, <emphasis>pwcheck</emphasis>, and <emphasis>saslauthd</emphasis>. For details see section
45927 <xref linkend="SECTexpcond"/>.
45928 </para>
45929 </section>
45930 <section id="SECID175">
45931 <title>Using plaintext in a client</title>
45932 <para>
45933 <indexterm role="concept">
45934 <primary>options</primary>
45935 <secondary><command>plaintext</command> authenticator (client)</secondary>
45936 </indexterm>
45937 The <command>plaintext</command> authenticator has two client options:
45938 </para>
45939 <para>
45940 <indexterm role="option">
45941 <primary><option>client_ignore_invalid_base64</option></primary>
45942 </indexterm>
45943 </para>
45944 <informaltable frame="all">
45945 <tgroup cols="4" colsep="0" rowsep="0">
45946 <colspec colwidth="8*" align="left"/>
45947 <colspec colwidth="6*" align="center"/>
45948 <colspec colwidth="6*" align="center"/>
45949 <colspec colwidth="6*" align="right"/>
45950 <tbody>
45951 <row>
45952 <entry><option>client_ignore_invalid_base64</option></entry>
45953 <entry>Use: <emphasis>plaintext</emphasis></entry>
45954 <entry>Type: <emphasis>boolean</emphasis></entry>
45955 <entry>Default: <emphasis>false</emphasis></entry>
45956 </row>
45957 </tbody>
45958 </tgroup>
45959 </informaltable>
45960 <para>
45961 If the client receives a server prompt that is not a valid base64 string,
45962 authentication is abandoned by default. However, if this option is set true,
45963 the error in the challenge is ignored and the client sends the response as
45964 usual.
45965 </para>
45966 <para>
45967 <indexterm role="option">
45968 <primary><option>client_send</option></primary>
45969 </indexterm>
45970 </para>
45971 <informaltable frame="all">
45972 <tgroup cols="4" colsep="0" rowsep="0">
45973 <colspec colwidth="8*" align="left"/>
45974 <colspec colwidth="6*" align="center"/>
45975 <colspec colwidth="6*" align="center"/>
45976 <colspec colwidth="6*" align="right"/>
45977 <tbody>
45978 <row>
45979 <entry><option>client_send</option></entry>
45980 <entry>Use: <emphasis>plaintext</emphasis></entry>
45981 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45982 <entry>Default: <emphasis>unset</emphasis></entry>
45983 </row>
45984 </tbody>
45985 </tgroup>
45986 </informaltable>
45987 <para>
45988 The string is a colon-separated list of authentication data strings. Each
45989 string is independently expanded before being sent to the server. The first
45990 string is sent with the AUTH command; any more strings are sent in response
45991 to prompts from the server. Before each string is expanded, the value of the
45992 most recent prompt is placed in the next <varname>$auth</varname>&lt;<emphasis>n</emphasis>&gt; variable, starting
45993 with <varname>$auth1</varname> for the first prompt. Up to three prompts are stored in this
45994 way. Thus, the prompt that is received in response to sending the first string
45995 (with the AUTH command) can be used in the expansion of the second string, and
45996 so on. If an invalid base64 string is received when
45997 <option>client_ignore_invalid_base64</option> is set, an empty string is put in the
45998 <varname>$auth</varname>&lt;<emphasis>n</emphasis>&gt; variable.
45999 </para>
46000 <para>
46001 <emphasis role="bold">Note</emphasis>: You cannot use expansion to create multiple strings, because
46002 splitting takes priority and happens first.
46003 </para>
46004 <para>
46005 Because the PLAIN authentication mechanism requires NUL (binary zero) bytes in
46006 the data, further processing is applied to each string before it is sent. If
46007 there are any single circumflex characters in the string, they are converted to
46008 NULs. Should an actual circumflex be required as data, it must be doubled in
46009 the string.
46010 </para>
46011 <para>
46012 This is an example of a client configuration that implements the PLAIN
46013 authentication mechanism with a fixed user name and password:
46014 </para>
46015 <literallayout class="monospaced">
46016 fixed_plain:
46017   driver = plaintext
46018   public_name = PLAIN
46019   client_send = ^username^mysecret
46020 </literallayout>
46021 <para>
46022 The lack of colons means that the entire text is sent with the AUTH
46023 command, with the circumflex characters converted to NULs. A similar example
46024 that uses the LOGIN mechanism is:
46025 </para>
46026 <literallayout class="monospaced">
46027 fixed_login:
46028   driver = plaintext
46029   public_name = LOGIN
46030   client_send = : username : mysecret
46031 </literallayout>
46032 <para>
46033 The initial colon means that the first string is empty, so no data is sent with
46034 the AUTH command itself. The remaining strings are sent in response to
46035 prompts.
46036 <indexterm role="concept" startref="IIDplaiauth1" class="endofrange"/>
46037 <indexterm role="concept" startref="IIDplaiauth2" class="endofrange"/>
46038 </para>
46039 </section>
46040 </chapter>
46041
46042 <chapter id="CHID9">
46043 <title>The cram_md5 authenticator</title>
46044 <para>
46045 <indexterm role="concept" id="IIDcramauth1" class="startofrange">
46046 <primary><command>cram_md5</command> authenticator</primary>
46047 </indexterm>
46048 <indexterm role="concept" id="IIDcramauth2" class="startofrange">
46049 <primary>authenticators</primary>
46050 <secondary><command>cram_md5</command></secondary>
46051 </indexterm>
46052 <indexterm role="concept">
46053 <primary>CRAM-MD5 authentication mechanism</primary>
46054 </indexterm>
46055 <indexterm role="concept">
46056 <primary>authentication</primary>
46057 <secondary>CRAM-MD5 mechanism</secondary>
46058 </indexterm>
46059 The CRAM-MD5 authentication mechanism is described in RFC 2195. The server
46060 sends a challenge string to the client, and the response consists of a user
46061 name and the CRAM-MD5 digest of the challenge string combined with a secret
46062 string (password) which is known to both server and client. Thus, the secret
46063 is not sent over the network as plain text, which makes this authenticator more
46064 secure than <command>plaintext</command>. However, the downside is that the secret has to be
46065 available in plain text at either end.
46066 </para>
46067 <section id="SECID176">
46068 <title>Using cram_md5 as a server</title>
46069 <para>
46070 <indexterm role="concept">
46071 <primary>options</primary>
46072 <secondary><command>cram_md5</command> authenticator (server)</secondary>
46073 </indexterm>
46074 This authenticator has one server option, which must be set to configure the
46075 authenticator as a server:
46076 </para>
46077 <para>
46078 <indexterm role="option">
46079 <primary><option>server_secret</option></primary>
46080 </indexterm>
46081 </para>
46082 <informaltable frame="all">
46083 <tgroup cols="4" colsep="0" rowsep="0">
46084 <colspec colwidth="8*" align="left"/>
46085 <colspec colwidth="6*" align="center"/>
46086 <colspec colwidth="6*" align="center"/>
46087 <colspec colwidth="6*" align="right"/>
46088 <tbody>
46089 <row>
46090 <entry><option>server_secret</option></entry>
46091 <entry>Use: <emphasis>cram_md5</emphasis></entry>
46092 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46093 <entry>Default: <emphasis>unset</emphasis></entry>
46094 </row>
46095 </tbody>
46096 </tgroup>
46097 </informaltable>
46098 <para>
46099 <indexterm role="concept">
46100 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
46101 <secondary>in <command>cram_md5</command> authenticator</secondary>
46102 </indexterm>
46103 When the server receives the client&#x2019;s response, the user name is placed in
46104 the expansion variable <varname>$auth1</varname>, and <option>server_secret</option> is expanded to
46105 obtain the password for that user. The server then computes the CRAM-MD5 digest
46106 that the client should have sent, and checks that it received the correct
46107 string. If the expansion of <option>server_secret</option> is forced to fail, authentication
46108 fails. If the expansion fails for some other reason, a temporary error code is
46109 returned to the client.
46110 </para>
46111 <para>
46112 For compatibility with previous releases of Exim, the user name is also placed
46113 in <varname>$1</varname>. However, the use of this variables for this purpose is now
46114 deprecated, as it can lead to confusion in string expansions that also use
46115 numeric variables for other things.
46116 </para>
46117 <para>
46118 For example, the following authenticator checks that the user name given by the
46119 client is <quote>ph10</quote>, and if so, uses <quote>secret</quote> as the password. For any other
46120 user name, authentication fails.
46121 </para>
46122 <literallayout class="monospaced">
46123 fixed_cram:
46124   driver = cram_md5
46125   public_name = CRAM-MD5
46126   server_secret = ${if eq{$auth1}{ph10}{secret}fail}
46127   server_set_id = $auth1
46128 </literallayout>
46129 <para>
46130 <indexterm role="variable">
46131 <primary><varname>$authenticated_id</varname></primary>
46132 </indexterm>
46133 If authentication succeeds, the setting of <option>server_set_id</option> preserves the user
46134 name in <varname>$authenticated_id</varname>. A more typical configuration might look up the
46135 secret string in a file, using the user name as the key. For example:
46136 </para>
46137 <literallayout class="monospaced">
46138 lookup_cram:
46139   driver = cram_md5
46140   public_name = CRAM-MD5
46141   server_secret = ${lookup{$auth1}lsearch{/etc/authpwd}\
46142                   {$value}fail}
46143   server_set_id = $auth1
46144 </literallayout>
46145 <para>
46146 Note that this expansion explicitly forces failure if the lookup fails
46147 because <varname>$auth1</varname> contains an unknown user name.
46148 </para>
46149 </section>
46150 <section id="SECID177">
46151 <title>Using cram_md5 as a client</title>
46152 <para>
46153 <indexterm role="concept">
46154 <primary>options</primary>
46155 <secondary><command>cram_md5</command> authenticator (client)</secondary>
46156 </indexterm>
46157 When used as a client, the <command>cram_md5</command> authenticator has two options:
46158 </para>
46159 <para>
46160 <indexterm role="option">
46161 <primary><option>client_name</option></primary>
46162 </indexterm>
46163 </para>
46164 <informaltable frame="all">
46165 <tgroup cols="4" colsep="0" rowsep="0">
46166 <colspec colwidth="8*" align="left"/>
46167 <colspec colwidth="6*" align="center"/>
46168 <colspec colwidth="6*" align="center"/>
46169 <colspec colwidth="6*" align="right"/>
46170 <tbody>
46171 <row>
46172 <entry><option>client_name</option></entry>
46173 <entry>Use: <emphasis>cram_md5</emphasis></entry>
46174 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46175 <entry>Default: <emphasis>the primary host name</emphasis></entry>
46176 </row>
46177 </tbody>
46178 </tgroup>
46179 </informaltable>
46180 <para>
46181 This string is expanded, and the result used as the user name data when
46182 computing the response to the server&#x2019;s challenge.
46183 </para>
46184 <para>
46185 <indexterm role="option">
46186 <primary><option>client_secret</option></primary>
46187 </indexterm>
46188 </para>
46189 <informaltable frame="all">
46190 <tgroup cols="4" colsep="0" rowsep="0">
46191 <colspec colwidth="8*" align="left"/>
46192 <colspec colwidth="6*" align="center"/>
46193 <colspec colwidth="6*" align="center"/>
46194 <colspec colwidth="6*" align="right"/>
46195 <tbody>
46196 <row>
46197 <entry><option>client_secret</option></entry>
46198 <entry>Use: <emphasis>cram_md5</emphasis></entry>
46199 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46200 <entry>Default: <emphasis>unset</emphasis></entry>
46201 </row>
46202 </tbody>
46203 </tgroup>
46204 </informaltable>
46205 <para>
46206 This option must be set for the authenticator to work as a client. Its value is
46207 expanded and the result used as the secret string when computing the response.
46208 </para>
46209 <para>
46210 <indexterm role="variable">
46211 <primary><varname>$host</varname></primary>
46212 </indexterm>
46213 <indexterm role="variable">
46214 <primary><varname>$host_address</varname></primary>
46215 </indexterm>
46216 Different user names and secrets can be used for different servers by referring
46217 to <varname>$host</varname> or <varname>$host_address</varname> in the options. Forced failure of either
46218 expansion string is treated as an indication that this authenticator is not
46219 prepared to handle this case. Exim moves on to the next configured client
46220 authenticator. Any other expansion failure causes Exim to give up trying to
46221 send the message to the current server.
46222 </para>
46223 <para>
46224 A simple example configuration of a <command>cram_md5</command> authenticator, using fixed
46225 strings, is:
46226 </para>
46227 <literallayout class="monospaced">
46228 fixed_cram:
46229   driver = cram_md5
46230   public_name = CRAM-MD5
46231   client_name = ph10
46232   client_secret = secret
46233 </literallayout>
46234 <para>
46235 <indexterm role="concept" startref="IIDcramauth1" class="endofrange"/>
46236 <indexterm role="concept" startref="IIDcramauth2" class="endofrange"/>
46237 </para>
46238 </section>
46239 </chapter>
46240
46241 <chapter id="CHID10">
46242 <title>The cyrus_sasl authenticator</title>
46243 <para>
46244 <indexterm role="concept" id="IIDcyrauth1" class="startofrange">
46245 <primary><command>cyrus_sasl</command> authenticator</primary>
46246 </indexterm>
46247 <indexterm role="concept" id="IIDcyrauth2" class="startofrange">
46248 <primary>authenticators</primary>
46249 <secondary><command>cyrus_sasl</command></secondary>
46250 </indexterm>
46251 <indexterm role="concept">
46252 <primary>Cyrus</primary>
46253 <secondary>SASL library</secondary>
46254 </indexterm>
46255 <indexterm role="concept">
46256 <primary>Kerberos</primary>
46257 </indexterm>
46258 The code for this authenticator was provided by Matthew Byng-Maddick of A L
46259 Digital Ltd (<emphasis role="bold"><ulink url="http://www.aldigital.co.uk">http://www.aldigital.co.uk</ulink></emphasis>).
46260 </para>
46261 <para>
46262 The <command>cyrus_sasl</command> authenticator provides server support for the Cyrus SASL
46263 library implementation of the RFC 2222 (<quote>Simple Authentication and Security
46264 Layer</quote>). This library supports a number of authentication mechanisms,
46265 including PLAIN and LOGIN, but also several others that Exim does not support
46266 directly. In particular, there is support for Kerberos authentication.
46267 </para>
46268 <para>
46269 The <command>cyrus_sasl</command> authenticator provides a gatewaying mechanism directly to
46270 the Cyrus interface, so if your Cyrus library can do, for example, CRAM-MD5,
46271 then so can the <command>cyrus_sasl</command> authenticator. By default it uses the public
46272 name of the driver to determine which mechanism to support.
46273 </para>
46274 <para>
46275 Where access to some kind of secret file is required, for example in GSSAPI
46276 or CRAM-MD5, it is worth noting that the authenticator runs as the Exim
46277 user, and that the Cyrus SASL library has no way of escalating privileges
46278 by default. You may also find you need to set environment variables,
46279 depending on the driver you are using.
46280 </para>
46281 <para>
46282 The application name provided by Exim is <quote>exim</quote>, so various SASL options may
46283 be set in <filename>exim.conf</filename> in your SASL directory. If you are using GSSAPI for
46284 Kerberos, note that because of limitations in the GSSAPI interface,
46285 changing the server keytab might need to be communicated down to the Kerberos
46286 layer independently. The mechanism for doing so is dependent upon the Kerberos
46287 implementation. For example, for Heimdal, the environment variable KRB5_KTNAME
46288 may be set to point to an alternative keytab file. Exim will pass this
46289 variable through from its own inherited environment when started as root or the
46290 Exim user. The keytab file needs to be readable by the Exim user.
46291 </para>
46292 <section id="SECID178">
46293 <title>Using cyrus_sasl as a server</title>
46294 <para>
46295 The <command>cyrus_sasl</command> authenticator has four private options. It puts the username
46296 (on a successful authentication) into <varname>$auth1</varname>. For compatibility with
46297 previous releases of Exim, the username is also placed in <varname>$1</varname>. However, the
46298 use of this variable for this purpose is now deprecated, as it can lead to
46299 confusion in string expansions that also use numeric variables for other
46300 things.
46301 </para>
46302 <para>
46303 <indexterm role="option">
46304 <primary><option>server_hostname</option></primary>
46305 </indexterm>
46306 </para>
46307 <informaltable frame="all">
46308 <tgroup cols="4" colsep="0" rowsep="0">
46309 <colspec colwidth="8*" align="left"/>
46310 <colspec colwidth="6*" align="center"/>
46311 <colspec colwidth="6*" align="center"/>
46312 <colspec colwidth="6*" align="right"/>
46313 <tbody>
46314 <row>
46315 <entry><option>server_hostname</option></entry>
46316 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
46317 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46318 <entry>Default: <emphasis>see below</emphasis></entry>
46319 </row>
46320 </tbody>
46321 </tgroup>
46322 </informaltable>
46323 <para>
46324 This option selects the hostname that is used when communicating with the
46325 library. The default value is <literal>$primary_hostname</literal>. It is up to the underlying
46326 SASL plug-in what it does with this data.
46327 </para>
46328 <para>
46329 <indexterm role="option">
46330 <primary><option>server_mech</option></primary>
46331 </indexterm>
46332 </para>
46333 <informaltable frame="all">
46334 <tgroup cols="4" colsep="0" rowsep="0">
46335 <colspec colwidth="8*" align="left"/>
46336 <colspec colwidth="6*" align="center"/>
46337 <colspec colwidth="6*" align="center"/>
46338 <colspec colwidth="6*" align="right"/>
46339 <tbody>
46340 <row>
46341 <entry><option>server_mech</option></entry>
46342 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
46343 <entry>Type: <emphasis>string</emphasis></entry>
46344 <entry>Default: <emphasis>see below</emphasis></entry>
46345 </row>
46346 </tbody>
46347 </tgroup>
46348 </informaltable>
46349 <para>
46350 This option selects the authentication mechanism this driver should use. The
46351 default is the value of the generic <option>public_name</option> option. This option allows
46352 you to use a different underlying mechanism from the advertised name. For
46353 example:
46354 </para>
46355 <literallayout class="monospaced">
46356 sasl:
46357   driver = cyrus_sasl
46358   public_name = X-ANYTHING
46359   server_mech = CRAM-MD5
46360   server_set_id = $auth1
46361 </literallayout>
46362 <para>
46363 <indexterm role="option">
46364 <primary><option>server_realm</option></primary>
46365 </indexterm>
46366 </para>
46367 <informaltable frame="all">
46368 <tgroup cols="4" colsep="0" rowsep="0">
46369 <colspec colwidth="8*" align="left"/>
46370 <colspec colwidth="6*" align="center"/>
46371 <colspec colwidth="6*" align="center"/>
46372 <colspec colwidth="6*" align="right"/>
46373 <tbody>
46374 <row>
46375 <entry><option>server_realm</option></entry>
46376 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
46377 <entry>Type: <emphasis>string</emphasis></entry>
46378 <entry>Default: <emphasis>unset</emphasis></entry>
46379 </row>
46380 </tbody>
46381 </tgroup>
46382 </informaltable>
46383 <para>
46384 This specifies the SASL realm that the server claims to be in.
46385 </para>
46386 <para>
46387 <indexterm role="option">
46388 <primary><option>server_service</option></primary>
46389 </indexterm>
46390 </para>
46391 <informaltable frame="all">
46392 <tgroup cols="4" colsep="0" rowsep="0">
46393 <colspec colwidth="8*" align="left"/>
46394 <colspec colwidth="6*" align="center"/>
46395 <colspec colwidth="6*" align="center"/>
46396 <colspec colwidth="6*" align="right"/>
46397 <tbody>
46398 <row>
46399 <entry><option>server_service</option></entry>
46400 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
46401 <entry>Type: <emphasis>string</emphasis></entry>
46402 <entry>Default: <emphasis><literal>smtp</literal></emphasis></entry>
46403 </row>
46404 </tbody>
46405 </tgroup>
46406 </informaltable>
46407 <para>
46408 This is the SASL service that the server claims to implement.
46409 </para>
46410 <para>
46411 For straightforward cases, you do not need to set any of the authenticator&#x2019;s
46412 private options. All you need to do is to specify an appropriate mechanism as
46413 the public name. Thus, if you have a SASL library that supports CRAM-MD5 and
46414 PLAIN, you could have two authenticators as follows:
46415 </para>
46416 <literallayout class="monospaced">
46417 sasl_cram_md5:
46418   driver = cyrus_sasl
46419   public_name = CRAM-MD5
46420   server_set_id = $auth1
46421
46422 sasl_plain:
46423   driver = cyrus_sasl
46424   public_name = PLAIN
46425   server_set_id = $auth2
46426 </literallayout>
46427 <para>
46428 Cyrus SASL does implement the LOGIN authentication method, even though it is
46429 not a standard method. It is disabled by default in the source distribution,
46430 but it is present in many binary distributions.
46431 <indexterm role="concept" startref="IIDcyrauth1" class="endofrange"/>
46432 <indexterm role="concept" startref="IIDcyrauth2" class="endofrange"/>
46433 </para>
46434 </section>
46435 </chapter>
46436
46437 <chapter id="CHAPdovecot">
46438 <title>The dovecot authenticator</title>
46439 <para>
46440 <indexterm role="concept" id="IIDdcotauth1" class="startofrange">
46441 <primary><command>dovecot</command> authenticator</primary>
46442 </indexterm>
46443 <indexterm role="concept" id="IIDdcotauth2" class="startofrange">
46444 <primary>authenticators</primary>
46445 <secondary><command>dovecot</command></secondary>
46446 </indexterm>
46447 This authenticator is an interface to the authentication facility of the
46448 Dovecot POP/IMAP server, which can support a number of authentication methods.
46449 If you are using Dovecot to authenticate POP/IMAP clients, it might be helpful
46450 to use the same mechanisms for SMTP authentication. This is a server
46451 authenticator only. There is only one option:
46452 </para>
46453 <para>
46454 <indexterm role="option">
46455 <primary><option>server_socket</option></primary>
46456 </indexterm>
46457 </para>
46458 <informaltable frame="all">
46459 <tgroup cols="4" colsep="0" rowsep="0">
46460 <colspec colwidth="8*" align="left"/>
46461 <colspec colwidth="6*" align="center"/>
46462 <colspec colwidth="6*" align="center"/>
46463 <colspec colwidth="6*" align="right"/>
46464 <tbody>
46465 <row>
46466 <entry><option>server_socket</option></entry>
46467 <entry>Use: <emphasis>dovecot</emphasis></entry>
46468 <entry>Type: <emphasis>string</emphasis></entry>
46469 <entry>Default: <emphasis>unset</emphasis></entry>
46470 </row>
46471 </tbody>
46472 </tgroup>
46473 </informaltable>
46474 <para>
46475 This option must specify the socket that is the interface to Dovecot
46476 authentication. The <option>public_name</option> option must specify an authentication
46477 mechanism that Dovecot is configured to support. You can have several
46478 authenticators for different mechanisms. For example:
46479 </para>
46480 <literallayout class="monospaced">
46481 dovecot_plain:
46482   driver = dovecot
46483   public_name = PLAIN
46484   server_socket = /var/run/dovecot/auth-client
46485   server_set_id = $auth2
46486
46487 dovecot_ntlm:
46488   driver = dovecot
46489   public_name = NTLM
46490   server_socket = /var/run/dovecot/auth-client
46491   server_set_id = $auth1
46492 </literallayout>
46493 <para>
46494 If the SMTP connection is encrypted, or if <varname>$sender_host_address</varname> is equal to
46495 <varname>$received_ip_address</varname> (that is, the connection is local), the <quote>secured</quote>
46496 option is passed in the Dovecot authentication command. If, for a TLS
46497 connection, a client certificate has been verified, the <quote>valid-client-cert</quote>
46498 option is passed. When authentication succeeds, the identity of the user
46499 who authenticated is placed in <varname>$auth1</varname>.
46500 <indexterm role="concept" startref="IIDdcotauth1" class="endofrange"/>
46501 <indexterm role="concept" startref="IIDdcotauth2" class="endofrange"/>
46502 </para>
46503 </chapter>
46504
46505 <chapter id="CHAPspa">
46506 <title>The spa authenticator</title>
46507 <para>
46508 <indexterm role="concept" id="IIDspaauth1" class="startofrange">
46509 <primary><command>spa</command> authenticator</primary>
46510 </indexterm>
46511 <indexterm role="concept" id="IIDspaauth2" class="startofrange">
46512 <primary>authenticators</primary>
46513 <secondary><command>spa</command></secondary>
46514 </indexterm>
46515 <indexterm role="concept">
46516 <primary>authentication</primary>
46517 <secondary>Microsoft Secure Password</secondary>
46518 </indexterm>
46519 <indexterm role="concept">
46520 <primary>authentication</primary>
46521 <secondary>NTLM</secondary>
46522 </indexterm>
46523 <indexterm role="concept">
46524 <primary>Microsoft Secure Password Authentication</primary>
46525 </indexterm>
46526 <indexterm role="concept">
46527 <primary>NTLM authentication</primary>
46528 </indexterm>
46529 The <command>spa</command> authenticator provides client support for Microsoft&#x2019;s <emphasis>Secure
46530 Password Authentication</emphasis> mechanism,
46531 which is also sometimes known as NTLM (NT LanMan). The code for client side of
46532 this authenticator was contributed by Marc Prud&#x2019;hommeaux, and much of it is
46533 taken from the Samba project (<emphasis role="bold"><ulink url="http://www.samba.org">http://www.samba.org</ulink></emphasis>). The code for the
46534 server side was subsequently contributed by Tom Kistner. The mechanism works as
46535 follows:
46536 </para>
46537 <itemizedlist>
46538 <listitem>
46539 <para>
46540 After the AUTH command has been accepted, the client sends an SPA
46541 authentication request based on the user name and optional domain.
46542 </para>
46543 </listitem>
46544 <listitem>
46545 <para>
46546 The server sends back a challenge.
46547 </para>
46548 </listitem>
46549 <listitem>
46550 <para>
46551 The client builds a challenge response which makes use of the user&#x2019;s password
46552 and sends it to the server, which then accepts or rejects it.
46553 </para>
46554 </listitem>
46555 </itemizedlist>
46556 <para>
46557 Encryption is used to protect the password in transit.
46558 </para>
46559 <section id="SECID179">
46560 <title>Using spa as a server</title>
46561 <para>
46562 <indexterm role="concept">
46563 <primary>options</primary>
46564 <secondary><command>spa</command> authenticator (server)</secondary>
46565 </indexterm>
46566 The <command>spa</command> authenticator has just one server option:
46567 </para>
46568 <para>
46569 <indexterm role="option">
46570 <primary><option>server_password</option></primary>
46571 </indexterm>
46572 </para>
46573 <informaltable frame="all">
46574 <tgroup cols="4" colsep="0" rowsep="0">
46575 <colspec colwidth="8*" align="left"/>
46576 <colspec colwidth="6*" align="center"/>
46577 <colspec colwidth="6*" align="center"/>
46578 <colspec colwidth="6*" align="right"/>
46579 <tbody>
46580 <row>
46581 <entry><option>server_password</option></entry>
46582 <entry>Use: <emphasis>spa</emphasis></entry>
46583 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46584 <entry>Default: <emphasis>unset</emphasis></entry>
46585 </row>
46586 </tbody>
46587 </tgroup>
46588 </informaltable>
46589 <para>
46590 <indexterm role="concept">
46591 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
46592 <secondary>in <command>spa</command> authenticator</secondary>
46593 </indexterm>
46594 This option is expanded, and the result must be the cleartext password for the
46595 authenticating user, whose name is at this point in <varname>$auth1</varname>. For
46596 compatibility with previous releases of Exim, the user name is also placed in
46597 <varname>$1</varname>. However, the use of this variable for this purpose is now deprecated, as
46598 it can lead to confusion in string expansions that also use numeric variables
46599 for other things. For example:
46600 </para>
46601 <literallayout class="monospaced">
46602 spa:
46603   driver = spa
46604   public_name = NTLM
46605   server_password = \
46606     ${lookup{$auth1}lsearch{/etc/exim/spa_clearpass}{$value}fail}
46607 </literallayout>
46608 <para>
46609 If the expansion is forced to fail, authentication fails. Any other expansion
46610 failure causes a temporary error code to be returned.
46611 </para>
46612 </section>
46613 <section id="SECID180">
46614 <title>Using spa as a client</title>
46615 <para>
46616 <indexterm role="concept">
46617 <primary>options</primary>
46618 <secondary><command>spa</command> authenticator (client)</secondary>
46619 </indexterm>
46620 The <command>spa</command> authenticator has the following client options:
46621 </para>
46622 <para>
46623 <indexterm role="option">
46624 <primary><option>client_domain</option></primary>
46625 </indexterm>
46626 </para>
46627 <informaltable frame="all">
46628 <tgroup cols="4" colsep="0" rowsep="0">
46629 <colspec colwidth="8*" align="left"/>
46630 <colspec colwidth="6*" align="center"/>
46631 <colspec colwidth="6*" align="center"/>
46632 <colspec colwidth="6*" align="right"/>
46633 <tbody>
46634 <row>
46635 <entry><option>client_domain</option></entry>
46636 <entry>Use: <emphasis>spa</emphasis></entry>
46637 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46638 <entry>Default: <emphasis>unset</emphasis></entry>
46639 </row>
46640 </tbody>
46641 </tgroup>
46642 </informaltable>
46643 <para>
46644 This option specifies an optional domain for the authentication.
46645 </para>
46646 <para>
46647 <indexterm role="option">
46648 <primary><option>client_password</option></primary>
46649 </indexterm>
46650 </para>
46651 <informaltable frame="all">
46652 <tgroup cols="4" colsep="0" rowsep="0">
46653 <colspec colwidth="8*" align="left"/>
46654 <colspec colwidth="6*" align="center"/>
46655 <colspec colwidth="6*" align="center"/>
46656 <colspec colwidth="6*" align="right"/>
46657 <tbody>
46658 <row>
46659 <entry><option>client_password</option></entry>
46660 <entry>Use: <emphasis>spa</emphasis></entry>
46661 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46662 <entry>Default: <emphasis>unset</emphasis></entry>
46663 </row>
46664 </tbody>
46665 </tgroup>
46666 </informaltable>
46667 <para>
46668 This option specifies the user&#x2019;s password, and must be set.
46669 </para>
46670 <para>
46671 <indexterm role="option">
46672 <primary><option>client_username</option></primary>
46673 </indexterm>
46674 </para>
46675 <informaltable frame="all">
46676 <tgroup cols="4" colsep="0" rowsep="0">
46677 <colspec colwidth="8*" align="left"/>
46678 <colspec colwidth="6*" align="center"/>
46679 <colspec colwidth="6*" align="center"/>
46680 <colspec colwidth="6*" align="right"/>
46681 <tbody>
46682 <row>
46683 <entry><option>client_username</option></entry>
46684 <entry>Use: <emphasis>spa</emphasis></entry>
46685 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46686 <entry>Default: <emphasis>unset</emphasis></entry>
46687 </row>
46688 </tbody>
46689 </tgroup>
46690 </informaltable>
46691 <para>
46692 This option specifies the user name, and must be set. Here is an example of a
46693 configuration of this authenticator for use with the mail servers at
46694 <emphasis>msn.com</emphasis>:
46695 </para>
46696 <literallayout class="monospaced">
46697 msn:
46698   driver = spa
46699   public_name = MSN
46700   client_username = msn/msn_username
46701   client_password = msn_plaintext_password
46702   client_domain = DOMAIN_OR_UNSET
46703 </literallayout>
46704 <para>
46705 <indexterm role="concept" startref="IIDspaauth1" class="endofrange"/>
46706 <indexterm role="concept" startref="IIDspaauth2" class="endofrange"/>
46707 </para>
46708 </section>
46709 </chapter>
46710
46711 <chapter id="CHAPTLS">
46712 <title>Encrypted SMTP connections using TLS/SSL</title>
46713 <titleabbrev>Encrypted SMTP connections</titleabbrev>
46714 <para>
46715 <indexterm role="concept" id="IIDencsmtp1" class="startofrange">
46716 <primary>encryption</primary>
46717 <secondary>on SMTP connection</secondary>
46718 </indexterm>
46719 <indexterm role="concept" id="IIDencsmtp2" class="startofrange">
46720 <primary>SMTP</primary>
46721 <secondary>encryption</secondary>
46722 </indexterm>
46723 <indexterm role="concept">
46724 <primary>TLS</primary>
46725 <secondary>on SMTP connection</secondary>
46726 </indexterm>
46727 <indexterm role="concept">
46728 <primary>OpenSSL</primary>
46729 </indexterm>
46730 <indexterm role="concept">
46731 <primary>GnuTLS</primary>
46732 </indexterm>
46733 Support for TLS (Transport Layer Security), formerly known as SSL (Secure
46734 Sockets Layer), is implemented by making use of the OpenSSL library or the
46735 GnuTLS library (Exim requires GnuTLS release 1.0 or later). There is no
46736 cryptographic code in the Exim distribution itself for implementing TLS. In
46737 order to use this feature you must install OpenSSL or GnuTLS, and then build a
46738 version of Exim that includes TLS support (see section <xref linkend="SECTinctlsssl"/>).
46739 You also need to understand the basic concepts of encryption at a managerial
46740 level, and in particular, the way that public keys, private keys, and
46741 certificates are used.
46742 </para>
46743 <para>
46744 RFC 3207 defines how SMTP connections can make use of encryption. Once a
46745 connection is established, the client issues a STARTTLS command. If the
46746 server accepts this, the client and the server negotiate an encryption
46747 mechanism. If the negotiation succeeds, the data that subsequently passes
46748 between them is encrypted.
46749 </para>
46750 <para>
46751 Exim&#x2019;s ACLs can detect whether the current SMTP session is encrypted or not,
46752 and if so, what cipher suite is in use, whether the client supplied a
46753 certificate, and whether or not that certificate was verified. This makes it
46754 possible for an Exim server to deny or accept certain commands based on the
46755 encryption state.
46756 </para>
46757 <para>
46758 <emphasis role="bold">Warning</emphasis>: Certain types of firewall and certain anti-virus products can
46759 disrupt TLS connections. You need to turn off SMTP scanning for these products
46760 in order to get TLS to work.
46761 </para>
46762 <section id="SECID284">
46763 <title>Support for the legacy <quote>ssmtp</quote> (aka <quote>smtps</quote>) protocol</title>
46764 <para>
46765 <indexterm role="concept">
46766 <primary>ssmtp protocol</primary>
46767 </indexterm>
46768 <indexterm role="concept">
46769 <primary>smtps protocol</primary>
46770 </indexterm>
46771 <indexterm role="concept">
46772 <primary>SMTP</primary>
46773 <secondary>ssmtp protocol</secondary>
46774 </indexterm>
46775 <indexterm role="concept">
46776 <primary>SMTP</primary>
46777 <secondary>smtps protocol</secondary>
46778 </indexterm>
46779 Early implementations of encrypted SMTP used a different TCP port from normal
46780 SMTP, and expected an encryption negotiation to start immediately, instead of
46781 waiting for a STARTTLS command from the client using the standard SMTP
46782 port. The protocol was called <quote>ssmtp</quote> or <quote>smtps</quote>, and port 465 was
46783 allocated for this purpose.
46784 </para>
46785 <para>
46786 This approach was abandoned when encrypted SMTP was standardized, but there are
46787 still some legacy clients that use it. Exim supports these clients by means of
46788 the <option>tls_on_connect_ports</option> global option. Its value must be a list of port
46789 numbers; the most common use is expected to be:
46790 </para>
46791 <literallayout class="monospaced">
46792 tls_on_connect_ports = 465
46793 </literallayout>
46794 <para>
46795 The port numbers specified by this option apply to all SMTP connections, both
46796 via the daemon and via <emphasis>inetd</emphasis>. You still need to specify all the ports that
46797 the daemon uses (by setting <option>daemon_smtp_ports</option> or <option>local_interfaces</option> or
46798 the <option>-oX</option> command line option) because <option>tls_on_connect_ports</option> does not add
46799 an extra port &ndash; rather, it specifies different behaviour on a port that is
46800 defined elsewhere.
46801 </para>
46802 <para>
46803 There is also a <option>-tls-on-connect</option> command line option. This overrides
46804 <option>tls_on_connect_ports</option>; it forces the legacy behaviour for all ports.
46805 </para>
46806 </section>
46807 <section id="SECTopenvsgnu">
46808 <title>OpenSSL vs GnuTLS</title>
46809 <para>
46810 <indexterm role="concept">
46811 <primary>TLS</primary>
46812 <secondary>OpenSSL <emphasis>vs</emphasis> GnuTLS</secondary>
46813 </indexterm>
46814 The first TLS support in Exim was implemented using OpenSSL. Support for GnuTLS
46815 followed later, when the first versions of GnuTLS were released. To build Exim
46816 to use GnuTLS, you need to set
46817 </para>
46818 <literallayout class="monospaced">
46819 USE_GNUTLS=yes
46820 </literallayout>
46821 <para>
46822 in Local/Makefile, in addition to
46823 </para>
46824 <literallayout class="monospaced">
46825 SUPPORT_TLS=yes
46826 </literallayout>
46827 <para>
46828 You must also set TLS_LIBS and TLS_INCLUDE appropriately, so that the
46829 include files and libraries for GnuTLS can be found.
46830 </para>
46831 <para>
46832 There are some differences in usage when using GnuTLS instead of OpenSSL:
46833 </para>
46834 <itemizedlist>
46835 <listitem>
46836 <para>
46837 The <option>tls_verify_certificates</option> option must contain the name of a file, not the
46838 name of a directory (for OpenSSL it can be either).
46839 </para>
46840 </listitem>
46841 <listitem>
46842 <para>
46843 The <option>tls_dhparam</option> option is ignored, because early versions of GnuTLS had no
46844 facility for varying its Diffie-Hellman parameters. I understand that this has
46845 changed, but Exim has not been updated to provide this facility.
46846 </para>
46847 </listitem>
46848 <listitem>
46849 <para>
46850 <indexterm role="variable">
46851 <primary><varname>$tls_peerdn</varname></primary>
46852 </indexterm>
46853 Distinguished Name (DN) strings reported by the OpenSSL library use a slash for
46854 separating fields; GnuTLS uses commas, in accordance with RFC 2253. This
46855 affects the value of the <varname>$tls_peerdn</varname> variable.
46856 </para>
46857 </listitem>
46858 <listitem>
46859 <para>
46860 OpenSSL identifies cipher suites using hyphens as separators, for example:
46861 DES-CBC3-SHA. GnuTLS uses underscores, for example: RSA_ARCFOUR_SHA. What is
46862 more, OpenSSL complains if underscores are present in a cipher list. To make
46863 life simpler, Exim changes underscores to hyphens for OpenSSL and hyphens to
46864 underscores for GnuTLS when processing lists of cipher suites in the
46865 <option>tls_require_ciphers</option> options (the global option and the <command>smtp</command> transport
46866 option).
46867 </para>
46868 </listitem>
46869 <listitem>
46870 <para>
46871 The <option>tls_require_ciphers</option> options operate differently, as described in the
46872 sections <xref linkend="SECTreqciphssl"/> and <xref linkend="SECTreqciphgnu"/>.
46873 </para>
46874 </listitem>
46875 </itemizedlist>
46876 </section>
46877 <section id="SECID181">
46878 <title>GnuTLS parameter computation</title>
46879 <para>
46880 GnuTLS uses D-H parameters that may take a substantial amount of time
46881 to compute. It is unreasonable to re-compute them for every TLS session.
46882 Therefore, Exim keeps this data in a file in its spool directory, called
46883 <filename>gnutls-params</filename>. The file is owned by the Exim user and is readable only by
46884 its owner. Every Exim process that start up GnuTLS reads the D-H
46885 parameters from this file. If the file does not exist, the first Exim process
46886 that needs it computes the data and writes it to a temporary file which is
46887 renamed once it is complete. It does not matter if several Exim processes do
46888 this simultaneously (apart from wasting a few resources). Once a file is in
46889 place, new Exim processes immediately start using it.
46890 </para>
46891 <para>
46892 For maximum security, the parameters that are stored in this file should be
46893 recalculated periodically, the frequency depending on your paranoia level.
46894 Arranging this is easy in principle; just delete the file when you want new
46895 values to be computed. However, there may be a problem. The calculation of new
46896 parameters needs random numbers, and these are obtained from <filename>/dev/random</filename>.
46897 If the system is not very active, <filename>/dev/random</filename> may delay returning data
46898 until enough randomness (entropy) is available. This may cause Exim to hang for
46899 a substantial amount of time, causing timeouts on incoming connections.
46900 </para>
46901 <para>
46902 The solution is to generate the parameters externally to Exim. They are stored
46903 in <filename>gnutls-params</filename> in PEM format, which means that they can be generated
46904 externally using the <command>certtool</command> command that is part of GnuTLS.
46905 </para>
46906 <para>
46907 To replace the parameters with new ones, instead of deleting the file
46908 and letting Exim re-create it, you can generate new parameters using
46909 <command>certtool</command> and, when this has been done, replace Exim&#x2019;s cache file by
46910 renaming. The relevant commands are something like this:
46911 </para>
46912 <literallayout class="monospaced">
46913 # rm -f new-params
46914 # touch new-params
46915 # chown exim:exim new-params
46916 # chmod 0400 new-params
46917 # certtool --generate-privkey --bits 512 &gt;new-params
46918 # echo "" &gt;&gt;new-params
46919 # certtool --generate-dh-params --bits 1024 &gt;&gt; new-params
46920 # mv new-params gnutls-params
46921 </literallayout>
46922 <para>
46923 If Exim never has to generate the parameters itself, the possibility of
46924 stalling is removed.
46925 </para>
46926 </section>
46927 <section id="SECTreqciphssl">
46928 <title>Requiring specific ciphers in OpenSSL</title>
46929 <para>
46930 <indexterm role="concept">
46931 <primary>TLS</primary>
46932 <secondary>requiring specific ciphers (OpenSSL)</secondary>
46933 </indexterm>
46934 <indexterm role="option">
46935 <primary><option>tls_require_ciphers</option></primary>
46936 <secondary>OpenSSL</secondary>
46937 </indexterm>
46938 There is a function in the OpenSSL library that can be passed a list of cipher
46939 suites before the cipher negotiation takes place. This specifies which ciphers
46940 are acceptable. The list is colon separated and may contain names like
46941 DES-CBC3-SHA. Exim passes the expanded value of <option>tls_require_ciphers</option>
46942 directly to this function call. The following quotation from the OpenSSL
46943 documentation specifies what forms of item are allowed in the cipher string:
46944 </para>
46945 <itemizedlist>
46946 <listitem>
46947 <para>
46948 It can consist of a single cipher suite such as RC4-SHA.
46949 </para>
46950 </listitem>
46951 <listitem>
46952 <para>
46953 It can represent a list of cipher suites containing a certain algorithm,
46954 or cipher suites of a certain type. For example SHA1 represents all
46955 ciphers suites using the digest algorithm SHA1 and SSLv3 represents all
46956 SSL v3 algorithms.
46957 </para>
46958 </listitem>
46959 <listitem>
46960 <para>
46961 Lists of cipher suites can be combined in a single cipher string using
46962 the + character. This is used as a logical and operation. For example
46963 SHA1+DES represents all cipher suites containing the SHA1 and the DES
46964 algorithms.
46965 </para>
46966 </listitem>
46967 </itemizedlist>
46968 <para>
46969 Each cipher string can be optionally preceded by one of the characters <literal>!</literal>,
46970 <literal>-</literal> or <literal>+</literal>.
46971 </para>
46972 <itemizedlist>
46973 <listitem>
46974 <para>
46975 If <literal>!</literal> is used, the ciphers are permanently deleted from the list. The
46976 ciphers deleted can never reappear in the list even if they are explicitly
46977 stated.
46978 </para>
46979 </listitem>
46980 <listitem>
46981 <para>
46982 If <literal>-</literal> is used, the ciphers are deleted from the list, but some or all
46983 of the ciphers can be added again by later options.
46984 </para>
46985 </listitem>
46986 <listitem>
46987 <para>
46988 If <literal>+</literal> is used, the ciphers are moved to the end of the list. This
46989 option does not add any new ciphers; it just moves matching existing ones.
46990 </para>
46991 </listitem>
46992 </itemizedlist>
46993 <para>
46994 If none of these characters is present, the string is interpreted as
46995 a list of ciphers to be appended to the current preference list. If the list
46996 includes any ciphers already present they will be ignored: that is, they will
46997 not be moved to the end of the list.
46998 </para>
46999 </section>
47000 <section id="SECTreqciphgnu">
47001 <title>Requiring specific ciphers or other parameters in GnuTLS</title>
47002 <para>
47003 <indexterm role="concept">
47004 <primary>GnuTLS</primary>
47005 <secondary>specifying parameters for</secondary>
47006 </indexterm>
47007 <indexterm role="concept">
47008 <primary>TLS</primary>
47009 <secondary>specifying ciphers (GnuTLS)</secondary>
47010 </indexterm>
47011 <indexterm role="concept">
47012 <primary>TLS</primary>
47013 <secondary>specifying key exchange methods (GnuTLS)</secondary>
47014 </indexterm>
47015 <indexterm role="concept">
47016 <primary>TLS</primary>
47017 <secondary>specifying MAC algorithms (GnuTLS)</secondary>
47018 </indexterm>
47019 <indexterm role="concept">
47020 <primary>TLS</primary>
47021 <secondary>specifying protocols (GnuTLS)</secondary>
47022 </indexterm>
47023 <indexterm role="option">
47024 <primary><option>tls_require_ciphers</option></primary>
47025 <secondary>GnuTLS</secondary>
47026 </indexterm>
47027 The GnuTLS library allows the caller to specify separate lists of permitted key
47028 exchange methods, main cipher algorithms, MAC algorithms, and protocols.
47029 Unfortunately, these lists are numerical, and the library does not have a
47030 function for turning names into numbers. Consequently, lists of recognized
47031 names have to be built into the application. The permitted key exchange
47032 methods, ciphers, and MAC algorithms may be used in any combination to form a
47033 cipher suite. This is unlike OpenSSL, where complete cipher suite names are
47034 passed to its control function.
47035 </para>
47036 <para>
47037 For compatibility with OpenSSL, the <option>tls_require_ciphers</option> option can be set
47038 to complete cipher suite names such as RSA_ARCFOUR_SHA, but for GnuTLS this
47039 option controls only the cipher algorithms. Exim searches each item in the
47040 list for the name of an available algorithm. For example, if the list
47041 contains RSA_AES_SHA, then AES is recognized, and the behaviour is exactly
47042 the same as if just AES were given.
47043 </para>
47044 <para>
47045 <indexterm role="option">
47046 <primary><option>gnutls_require_kx</option></primary>
47047 </indexterm>
47048 <indexterm role="option">
47049 <primary><option>gnutls_require_mac</option></primary>
47050 </indexterm>
47051 <indexterm role="option">
47052 <primary><option>gnutls_require_protocols</option></primary>
47053 </indexterm>
47054 There are additional options called <option>gnutls_require_kx</option>,
47055 <option>gnutls_require_mac</option>, and <option>gnutls_require_protocols</option> that can be used to
47056 restrict the key exchange methods, MAC algorithms, and protocols, respectively.
47057 These options are ignored if OpenSSL is in use.
47058 </para>
47059 <para>
47060 All four options are available as global options, controlling how Exim
47061 behaves as a server, and also as options of the <command>smtp</command> transport, controlling
47062 how Exim behaves as a client. All the values are string expanded. After
47063 expansion, the values must be colon-separated lists, though the separator
47064 can be changed in the usual way.
47065 </para>
47066 <para>
47067 Each of the four lists starts out with a default set of algorithms. If the
47068 first item in a list does <emphasis>not</emphasis> start with an exclamation mark, all the
47069 default items are deleted. In this case, only those that are explicitly
47070 specified can be used. If the first item in a list <emphasis>does</emphasis> start with an
47071 exclamation mark, the defaults are left on the list.
47072 </para>
47073 <para>
47074 Then, any item that starts with an exclamation mark causes the relevant
47075 entry to be removed from the list, and any item that does not start with an
47076 exclamation mark causes a new entry to be added to the list. Unrecognized
47077 items in the list are ignored. Thus:
47078 </para>
47079 <literallayout class="monospaced">
47080 tls_require_ciphers = !ARCFOUR
47081 </literallayout>
47082 <para>
47083 allows all the defaults except ARCFOUR, whereas
47084 </para>
47085 <literallayout class="monospaced">
47086 tls_require_ciphers = AES : 3DES
47087 </literallayout>
47088 <para>
47089 allows only cipher suites that use AES or 3DES.
47090 </para>
47091 <para>
47092 For <option>tls_require_ciphers</option> the recognized names are AES_256, AES_128, AES
47093 (both of the preceding), 3DES, ARCFOUR_128, ARCFOUR_40, and ARCFOUR (both of
47094 the preceding). The default list does not contain all of these; it just has
47095 AES_256, AES_128, 3DES, and ARCFOUR_128.
47096 </para>
47097 <para>
47098 For <option>gnutls_require_kx</option>, the recognized names are DHE_RSA, RSA (which
47099 includes DHE_RSA), DHE_DSS, and DHE (which includes both DHE_RSA and
47100 DHE_DSS). The default list contains RSA, DHE_DSS, DHE_RSA.
47101 </para>
47102 <para>
47103 For <option>gnutls_require_mac</option>, the recognized names are SHA (synonym SHA1), and
47104 MD5. The default list contains SHA, MD5.
47105 </para>
47106 <para>
47107 For <option>gnutls_require_protocols</option>, the recognized names are TLS1 and SSL3.
47108 The default list contains TLS1, SSL3.
47109 </para>
47110 <para>
47111 In a server, the order of items in these lists is unimportant. The server
47112 advertises the availability of all the relevant cipher suites. However, in a
47113 client, the order in the <option>tls_require_ciphers</option> list specifies a preference
47114 order for the cipher algorithms. The first one in the client&#x2019;s list that is
47115 also advertised by the server is tried first. The default order is as listed
47116 above.
47117 </para>
47118 </section>
47119 <section id="SECID182">
47120 <title>Configuring an Exim server to use TLS</title>
47121 <para>
47122 <indexterm role="concept">
47123 <primary>TLS</primary>
47124 <secondary>configuring an Exim server</secondary>
47125 </indexterm>
47126 When Exim has been built with TLS support, it advertises the availability of
47127 the STARTTLS command to client hosts that match <option>tls_advertise_hosts</option>,
47128 but not to any others. The default value of this option is unset, which means
47129 that STARTTLS is not advertised at all. This default is chosen because you
47130 need to set some other options in order to make TLS available, and also it is
47131 sensible for systems that want to use TLS only as a client.
47132 </para>
47133 <para>
47134 If a client issues a STARTTLS command and there is some configuration
47135 problem in the server, the command is rejected with a 454 error. If the client
47136 persists in trying to issue SMTP commands, all except QUIT are rejected
47137 with the error
47138 </para>
47139 <literallayout class="monospaced">
47140 554 Security failure
47141 </literallayout>
47142 <para>
47143 If a STARTTLS command is issued within an existing TLS session, it is
47144 rejected with a 554 error code.
47145 </para>
47146 <para>
47147 To enable TLS operations on a server, you must set <option>tls_advertise_hosts</option> to
47148 match some hosts. You can, of course, set it to * to match all hosts.
47149 However, this is not all you need to do. TLS sessions to a server won&#x2019;t work
47150 without some further configuration at the server end.
47151 </para>
47152 <para>
47153 It is rumoured that all existing clients that support TLS/SSL use RSA
47154 encryption. To make this work you need to set, in the server,
47155 </para>
47156 <literallayout class="monospaced">
47157 tls_certificate = /some/file/name
47158 tls_privatekey = /some/file/name
47159 </literallayout>
47160 <para>
47161 These options are, in fact, expanded strings, so you can make them depend on
47162 the identity of the client that is connected if you wish. The first file
47163 contains the server&#x2019;s X509 certificate, and the second contains the private key
47164 that goes with it. These files need to be readable by the Exim user, and must
47165 always be given as full path names. They can be the same file if both the
47166 certificate and the key are contained within it. If <option>tls_privatekey</option> is not
47167 set, or if its expansion is forced to fail or results in an empty string, this
47168 is assumed to be the case. The certificate file may also contain intermediate
47169 certificates that need to be sent to the client to enable it to authenticate
47170 the server&#x2019;s certificate.
47171 </para>
47172 <para>
47173 If you do not understand about certificates and keys, please try to find a
47174 source of this background information, which is not Exim-specific. (There are a
47175 few comments below in section <xref linkend="SECTcerandall"/>.)
47176 </para>
47177 <para>
47178 <emphasis role="bold">Note</emphasis>: These options do not apply when Exim is operating as a client &ndash;
47179 they apply only in the case of a server. If you need to use a certificate in an
47180 Exim client, you must set the options of the same names in an <command>smtp</command>
47181 transport.
47182 </para>
47183 <para>
47184 With just these options, an Exim server will be able to use TLS. It does not
47185 require the client to have a certificate (but see below for how to insist on
47186 this). There is one other option that may be needed in other situations. If
47187 </para>
47188 <literallayout class="monospaced">
47189 tls_dhparam = /some/file/name
47190 </literallayout>
47191 <para>
47192 is set, the SSL library is initialized for the use of Diffie-Hellman ciphers
47193 with the parameters contained in the file. This increases the set of cipher
47194 suites that the server supports. See the command
47195 </para>
47196 <literallayout class="monospaced">
47197 openssl dhparam
47198 </literallayout>
47199 <para>
47200 for a way of generating this data. At present, <option>tls_dhparam</option> is used only
47201 when Exim is linked with OpenSSL. It is ignored if GnuTLS is being used.
47202 </para>
47203 <para>
47204 The strings supplied for these three options are expanded every time a client
47205 host connects. It is therefore possible to use different certificates and keys
47206 for different hosts, if you so wish, by making use of the client&#x2019;s IP address
47207 in <varname>$sender_host_address</varname> to control the expansion. If a string expansion is
47208 forced to fail, Exim behaves as if the option is not set.
47209 </para>
47210 <para>
47211 <indexterm role="concept">
47212 <primary>cipher</primary>
47213 <secondary>logging</secondary>
47214 </indexterm>
47215 <indexterm role="concept">
47216 <primary>log</primary>
47217 <secondary>TLS cipher</secondary>
47218 </indexterm>
47219 <indexterm role="variable">
47220 <primary><varname>$tls_cipher</varname></primary>
47221 </indexterm>
47222 The variable <varname>$tls_cipher</varname> is set to the cipher suite that was negotiated for
47223 an incoming TLS connection. It is included in the <emphasis>Received:</emphasis> header of an
47224 incoming message (by default &ndash; you can, of course, change this), and it is
47225 also included in the log line that records a message&#x2019;s arrival, keyed by
47226 <quote>X=</quote>, unless the <option>tls_cipher</option> log selector is turned off. The <option>encrypted</option>
47227 condition can be used to test for specific cipher suites in ACLs.
47228 (For outgoing SMTP deliveries, <varname>$tls_cipher</varname> is reset &ndash; see section
47229 <xref linkend="SECID185"/>.)
47230 </para>
47231 <para>
47232 Once TLS has been established, the ACLs that run for subsequent SMTP commands
47233 can check the name of the cipher suite and vary their actions accordingly. The
47234 cipher suite names vary, depending on which TLS library is being used. For
47235 example, OpenSSL uses the name DES-CBC3-SHA for the cipher suite which in other
47236 contexts is known as TLS_RSA_WITH_3DES_EDE_CBC_SHA. Check the OpenSSL or GnuTLS
47237 documentation for more details.
47238 </para>
47239 </section>
47240 <section id="SECID183">
47241 <title>Requesting and verifying client certificates</title>
47242 <para>
47243 <indexterm role="concept">
47244 <primary>certificate</primary>
47245 <secondary>verification of client</secondary>
47246 </indexterm>
47247 <indexterm role="concept">
47248 <primary>TLS</primary>
47249 <secondary>client certificate verification</secondary>
47250 </indexterm>
47251 If you want an Exim server to request a certificate when negotiating a TLS
47252 session with a client, you must set either <option>tls_verify_hosts</option> or
47253 <option>tls_try_verify_hosts</option>. You can, of course, set either of them to * to
47254 apply to all TLS connections. For any host that matches one of these options,
47255 Exim requests a certificate as part of the setup of the TLS session. The
47256 contents of the certificate are verified by comparing it with a list of
47257 expected certificates. These must be available in a file or,
47258 for OpenSSL only (not GnuTLS), a directory, identified by
47259 <option>tls_verify_certificates</option>.
47260 </para>
47261 <para>
47262 A file can contain multiple certificates, concatenated end to end. If a
47263 directory is used
47264 (OpenSSL only),
47265 each certificate must be in a separate file, with a name (or a symbolic link)
47266 of the form &lt;<emphasis>hash</emphasis>&gt;.0, where &lt;<emphasis>hash</emphasis>&gt; is a hash value constructed from the
47267 certificate. You can compute the relevant hash by running the command
47268 </para>
47269 <literallayout class="monospaced">
47270 openssl x509 -hash -noout -in /cert/file
47271 </literallayout>
47272 <para>
47273 where <filename>/cert/file</filename> contains a single certificate.
47274 </para>
47275 <para>
47276 The difference between <option>tls_verify_hosts</option> and <option>tls_try_verify_hosts</option> is
47277 what happens if the client does not supply a certificate, or if the certificate
47278 does not match any of the certificates in the collection named by
47279 <option>tls_verify_certificates</option>. If the client matches <option>tls_verify_hosts</option>, the
47280 attempt to set up a TLS session is aborted, and the incoming connection is
47281 dropped. If the client matches <option>tls_try_verify_hosts</option>, the (encrypted) SMTP
47282 session continues. ACLs that run for subsequent SMTP commands can detect the
47283 fact that no certificate was verified, and vary their actions accordingly. For
47284 example, you can insist on a certificate before accepting a message for
47285 relaying, but not when the message is destined for local delivery.
47286 </para>
47287 <para>
47288 <indexterm role="variable">
47289 <primary><varname>$tls_peerdn</varname></primary>
47290 </indexterm>
47291 When a client supplies a certificate (whether it verifies or not), the value of
47292 the Distinguished Name of the certificate is made available in the variable
47293 <varname>$tls_peerdn</varname> during subsequent processing of the message.
47294 </para>
47295 <para>
47296 <indexterm role="concept">
47297 <primary>log</primary>
47298 <secondary>distinguished name</secondary>
47299 </indexterm>
47300 Because it is often a long text string, it is not included in the log line or
47301 <emphasis>Received:</emphasis> header by default. You can arrange for it to be logged, keyed by
47302 <quote>DN=</quote>, by setting the <option>tls_peerdn</option> log selector, and you can use
47303 <option>received_header_text</option> to change the <emphasis>Received:</emphasis> header. When no
47304 certificate is supplied, <varname>$tls_peerdn</varname> is empty.
47305 </para>
47306 </section>
47307 <section id="SECID184">
47308 <title>Revoked certificates</title>
47309 <para>
47310 <indexterm role="concept">
47311 <primary>TLS</primary>
47312 <secondary>revoked certificates</secondary>
47313 </indexterm>
47314 <indexterm role="concept">
47315 <primary>revocation list</primary>
47316 </indexterm>
47317 <indexterm role="concept">
47318 <primary>certificate</primary>
47319 <secondary>revocation list</secondary>
47320 </indexterm>
47321 Certificate issuing authorities issue Certificate Revocation Lists (CRLs) when
47322 certificates are revoked. If you have such a list, you can pass it to an Exim
47323 server using the global option called <option>tls_crl</option> and to an Exim client using
47324 an identically named option for the <command>smtp</command> transport. In each case, the value
47325 of the option is expanded and must then be the name of a file that contains a
47326 CRL in PEM format.
47327 </para>
47328 </section>
47329 <section id="SECID185">
47330 <title>Configuring an Exim client to use TLS</title>
47331 <para>
47332 <indexterm role="concept">
47333 <primary>cipher</primary>
47334 <secondary>logging</secondary>
47335 </indexterm>
47336 <indexterm role="concept">
47337 <primary>log</primary>
47338 <secondary>TLS cipher</secondary>
47339 </indexterm>
47340 <indexterm role="concept">
47341 <primary>log</primary>
47342 <secondary>distinguished name</secondary>
47343 </indexterm>
47344 <indexterm role="concept">
47345 <primary>TLS</primary>
47346 <secondary>configuring an Exim client</secondary>
47347 </indexterm>
47348 The <option>tls_cipher</option> and <option>tls_peerdn</option> log selectors apply to outgoing SMTP
47349 deliveries as well as to incoming, the latter one causing logging of the
47350 server certificate&#x2019;s DN. The remaining client configuration for TLS is all
47351 within the <command>smtp</command> transport.
47352 </para>
47353 <para>
47354 It is not necessary to set any options to have TLS work in the <command>smtp</command>
47355 transport. If Exim is built with TLS support, and TLS is advertised by a
47356 server, the <command>smtp</command> transport always tries to start a TLS session. However,
47357 this can be prevented by setting <option>hosts_avoid_tls</option> (an option of the
47358 transport) to a list of server hosts for which TLS should not be used.
47359 </para>
47360 <para>
47361 If you do not want Exim to attempt to send messages unencrypted when an attempt
47362 to set up an encrypted connection fails in any way, you can set
47363 <option>hosts_require_tls</option> to a list of hosts for which encryption is mandatory. For
47364 those hosts, delivery is always deferred if an encrypted connection cannot be
47365 set up. If there are any other hosts for the address, they are tried in the
47366 usual way.
47367 </para>
47368 <para>
47369 When the server host is not in <option>hosts_require_tls</option>, Exim may try to deliver
47370 the message unencrypted. It always does this if the response to STARTTLS is
47371 a 5<emphasis>xx</emphasis> code. For a temporary error code, or for a failure to negotiate a TLS
47372 session after a success response code, what happens is controlled by the
47373 <option>tls_tempfail_tryclear</option> option of the <command>smtp</command> transport. If it is false,
47374 delivery to this host is deferred, and other hosts (if available) are tried. If
47375 it is true, Exim attempts to deliver unencrypted after a 4<emphasis>xx</emphasis> response to
47376 STARTTLS, and if STARTTLS is accepted, but the subsequent TLS
47377 negotiation fails, Exim closes the current connection (because it is in an
47378 unknown state), opens a new one to the same host, and then tries the delivery
47379 unencrypted.
47380 </para>
47381 <para>
47382 The <option>tls_certificate</option> and <option>tls_privatekey</option> options of the <command>smtp</command>
47383 transport provide the client with a certificate, which is passed to the server
47384 if it requests it. If the server is Exim, it will request a certificate only if
47385 <option>tls_verify_hosts</option> or <option>tls_try_verify_hosts</option> matches the client.
47386 </para>
47387 <para>
47388 If the <option>tls_verify_certificates</option> option is set on the <command>smtp</command> transport, it
47389 must name a file or,
47390 for OpenSSL only (not GnuTLS), a directory, that contains a collection of
47391 expected server certificates. The client verifies the server&#x2019;s certificate
47392 against this collection, taking into account any revoked certificates that are
47393 in the list defined by <option>tls_crl</option>.
47394 </para>
47395 <para>
47396 If
47397 <option>tls_require_ciphers</option> is set on the <command>smtp</command> transport, it must contain a
47398 list of permitted cipher suites. If either of these checks fails, delivery to
47399 the current host is abandoned, and the <command>smtp</command> transport tries to deliver to
47400 alternative hosts, if any.
47401 </para>
47402 <para>
47403  <emphasis role="bold">Note</emphasis>:
47404 These options must be set in the <command>smtp</command> transport for Exim to use TLS when it
47405 is operating as a client. Exim does not assume that a server certificate (set
47406 by the global options of the same name) should also be used when operating as a
47407 client.
47408 </para>
47409 <para>
47410 <indexterm role="variable">
47411 <primary><varname>$host</varname></primary>
47412 </indexterm>
47413 <indexterm role="variable">
47414 <primary><varname>$host_address</varname></primary>
47415 </indexterm>
47416 All the TLS options in the <command>smtp</command> transport are expanded before use, with
47417 <varname>$host</varname> and <varname>$host_address</varname> containing the name and address of the server to
47418 which the client is connected. Forced failure of an expansion causes Exim to
47419 behave as if the relevant option were unset.
47420 </para>
47421 <para>
47422 <indexterm role="variable">
47423 <primary><varname>$tls_cipher</varname></primary>
47424 </indexterm>
47425 <indexterm role="variable">
47426 <primary><varname>$tls_peerdn</varname></primary>
47427 </indexterm>
47428 Before an SMTP connection is established, the <varname>$tls_cipher</varname> and <varname>$tls_peerdn</varname>
47429 variables are emptied. (Until the first connection, they contain the values
47430 that were set when the message was received.) If STARTTLS is subsequently
47431 successfully obeyed, these variables are set to the relevant values for the
47432 outgoing connection.
47433 </para>
47434 </section>
47435 <section id="SECTmulmessam">
47436 <title>Multiple messages on the same encrypted TCP/IP connection</title>
47437 <para>
47438 <indexterm role="concept">
47439 <primary>multiple SMTP deliveries with TLS</primary>
47440 </indexterm>
47441 <indexterm role="concept">
47442 <primary>TLS</primary>
47443 <secondary>multiple message deliveries</secondary>
47444 </indexterm>
47445 Exim sends multiple messages down the same TCP/IP connection by starting up
47446 an entirely new delivery process for each message, passing the socket from
47447 one process to the next. This implementation does not fit well with the use
47448 of TLS, because there is quite a lot of state information associated with a TLS
47449 connection, not just a socket identification. Passing all the state information
47450 to a new process is not feasible. Consequently, Exim shuts down an existing TLS
47451 session before passing the socket to a new process. The new process may then
47452 try to start a new TLS session, and if successful, may try to re-authenticate
47453 if AUTH is in use, before sending the next message.
47454 </para>
47455 <para>
47456 The RFC is not clear as to whether or not an SMTP session continues in clear
47457 after TLS has been shut down, or whether TLS may be restarted again later, as
47458 just described. However, if the server is Exim, this shutdown and
47459 reinitialization works. It is not known which (if any) other servers operate
47460 successfully if the client closes a TLS session and continues with unencrypted
47461 SMTP, but there are certainly some that do not work. For such servers, Exim
47462 should not pass the socket to another process, because the failure of the
47463 subsequent attempt to use it would cause Exim to record a temporary host error,
47464 and delay other deliveries to that host.
47465 </para>
47466 <para>
47467 To test for this case, Exim sends an EHLO command to the server after
47468 closing down the TLS session. If this fails in any way, the connection is
47469 closed instead of being passed to a new delivery process, but no retry
47470 information is recorded.
47471 </para>
47472 <para>
47473 There is also a manual override; you can set <option>hosts_nopass_tls</option> on the
47474 <command>smtp</command> transport to match those hosts for which Exim should not pass
47475 connections to new processes if TLS has been used.
47476 </para>
47477 </section>
47478 <section id="SECTcerandall">
47479 <title>Certificates and all that</title>
47480 <para>
47481 <indexterm role="concept">
47482 <primary>certificate</primary>
47483 <secondary>references to discussion</secondary>
47484 </indexterm>
47485 In order to understand fully how TLS works, you need to know about
47486 certificates, certificate signing, and certificate authorities. This is not the
47487 place to give a tutorial, especially as I do not know very much about it
47488 myself. Some helpful introduction can be found in the FAQ for the SSL addition
47489 to Apache, currently at
47490 </para>
47491 <literallayout>
47492 <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>
47493 </literallayout>
47494 <para>
47495 Other parts of the <emphasis>modssl</emphasis> documentation are also helpful, and have
47496 links to further files.
47497 Eric Rescorla&#x2019;s book, <emphasis>SSL and TLS</emphasis>, published by Addison-Wesley (ISBN
47498 0-201-61598-3), contains both introductory and more in-depth descriptions.
47499 Some sample programs taken from the book are available from
47500 </para>
47501 <literallayout>
47502 <emphasis role="bold"><ulink url="http://www.rtfm.com/openssl-examples/">http://www.rtfm.com/openssl-examples/</ulink></emphasis>
47503 </literallayout>
47504 </section>
47505 <section id="SECID186">
47506 <title>Certificate chains</title>
47507 <para>
47508 The file named by <option>tls_certificate</option> may contain more than one
47509 certificate. This is useful in the case where the certificate that is being
47510 sent is validated by an intermediate certificate which the other end does
47511 not have. Multiple certificates must be in the correct order in the file.
47512 First the host&#x2019;s certificate itself, then the first intermediate
47513 certificate to validate the issuer of the host certificate, then the next
47514 intermediate certificate to validate the issuer of the first intermediate
47515 certificate, and so on, until finally (optionally) the root certificate.
47516 The root certificate must already be trusted by the recipient for
47517 validation to succeed, of course, but if it&#x2019;s not preinstalled, sending the
47518 root certificate along with the rest makes it available for the user to
47519 install if the receiving end is a client MUA that can interact with a user.
47520 </para>
47521 </section>
47522 <section id="SECID187">
47523 <title>Self-signed certificates</title>
47524 <para>
47525 <indexterm role="concept">
47526 <primary>certificate</primary>
47527 <secondary>self-signed</secondary>
47528 </indexterm>
47529 You can create a self-signed certificate using the <emphasis>req</emphasis> command provided
47530 with OpenSSL, like this:
47531 </para>
47532 <literallayout class="monospaced">
47533 openssl req -x509 -newkey rsa:1024 -keyout file1 -out file2 \
47534             -days 9999 -nodes
47535 </literallayout>
47536 <para>
47537 <filename>file1</filename> and <filename>file2</filename> can be the same file; the key and the certificate are
47538 delimited and so can be identified independently. The <option>-days</option> option
47539 specifies a period for which the certificate is valid. The <option>-nodes</option> option is
47540 important: if you do not set it, the key is encrypted with a passphrase
47541 that you are prompted for, and any use that is made of the key causes more
47542 prompting for the passphrase. This is not helpful if you are going to use
47543 this certificate and key in an MTA, where prompting is not possible.
47544 </para>
47545 <para>
47546 A self-signed certificate made in this way is sufficient for testing, and
47547 may be adequate for all your requirements if you are mainly interested in
47548 encrypting transfers, and not in secure identification.
47549 </para>
47550 <para>
47551 However, many clients require that the certificate presented by the server be a
47552 user (also called <quote>leaf</quote> or <quote>site</quote>) certificate, and not a self-signed
47553 certificate. In this situation, the self-signed certificate described above
47554 must be installed on the client host as a trusted root <emphasis>certification
47555 authority</emphasis> (CA), and the certificate used by Exim must be a user certificate
47556 signed with that self-signed certificate.
47557 </para>
47558 <para>
47559 For information on creating self-signed CA certificates and using them to sign
47560 user certificates, see the <emphasis>General implementation overview</emphasis> chapter of the
47561 Open-source PKI book, available online at
47562 <emphasis role="bold"><ulink url="http://ospkibook.sourceforge.net/">http://ospkibook.sourceforge.net/</ulink></emphasis>.
47563 <indexterm role="concept" startref="IIDencsmtp1" class="endofrange"/>
47564 <indexterm role="concept" startref="IIDencsmtp2" class="endofrange"/>
47565 </para>
47566 </section>
47567 </chapter>
47568
47569 <chapter id="CHAPACL">
47570 <title>Access control lists</title>
47571 <para>
47572 <indexterm role="concept" id="IIDacl" class="startofrange">
47573 <primary>access control lists (ACLs)</primary>
47574 <secondary>description</secondary>
47575 </indexterm>
47576 <indexterm role="concept">
47577 <primary>control of incoming mail</primary>
47578 </indexterm>
47579 <indexterm role="concept">
47580 <primary>message</primary>
47581 <secondary>controlling incoming</secondary>
47582 </indexterm>
47583 <indexterm role="concept">
47584 <primary>policy control</primary>
47585 <secondary>access control lists</secondary>
47586 </indexterm>
47587 Access Control Lists (ACLs) are defined in a separate section of the run time
47588 configuration file, headed by <quote>begin acl</quote>. Each ACL definition starts with a
47589 name, terminated by a colon. Here is a complete ACL section that contains just
47590 one very small ACL:
47591 </para>
47592 <literallayout class="monospaced">
47593 begin acl
47594 small_acl:
47595   accept   hosts = one.host.only
47596 </literallayout>
47597 <para>
47598 You can have as many lists as you like in the ACL section, and the order in
47599 which they appear does not matter. The lists are self-terminating.
47600 </para>
47601 <para>
47602 The majority of ACLs are used to control Exim&#x2019;s behaviour when it receives
47603 certain SMTP commands. This applies both to incoming TCP/IP connections, and
47604 when a local process submits a message using SMTP by specifying the <option>-bs</option>
47605 option. The most common use is for controlling which recipients are accepted
47606 in incoming messages. In addition, you can define an ACL that is used to check
47607 local non-SMTP messages. The default configuration file contains an example of
47608 a realistic ACL for checking RCPT commands. This is discussed in chapter
47609 <xref linkend="CHAPdefconfil"/>.
47610 </para>
47611 <section id="SECID188">
47612 <title>Testing ACLs</title>
47613 <para>
47614 The <option>-bh</option> command line option provides a way of testing your ACL
47615 configuration locally by running a fake SMTP session with which you interact.
47616 The host <emphasis>relay-test.mail-abuse.org</emphasis> provides a service for checking your
47617 relaying configuration (see section <xref linkend="SECTcheralcon"/> for more details).
47618 </para>
47619 </section>
47620 <section id="SECID189">
47621 <title>Specifying when ACLs are used</title>
47622 <para>
47623 <indexterm role="concept">
47624 <primary>access control lists (ACLs)</primary>
47625 <secondary>options for specifying</secondary>
47626 </indexterm>
47627 In order to cause an ACL to be used, you have to name it in one of the relevant
47628 options in the main part of the configuration. These options are:
47629 <indexterm role="concept">
47630 <primary>AUTH</primary>
47631 <secondary>ACL for</secondary>
47632 </indexterm>
47633 <indexterm role="concept">
47634 <primary>DATA</primary>
47635 <secondary>ACLs for</secondary>
47636 </indexterm>
47637 <indexterm role="concept">
47638 <primary>ETRN</primary>
47639 <secondary>ACL for</secondary>
47640 </indexterm>
47641 <indexterm role="concept">
47642 <primary>EXPN</primary>
47643 <secondary>ACL for</secondary>
47644 </indexterm>
47645 <indexterm role="concept">
47646 <primary>HELO</primary>
47647 <secondary>ACL for</secondary>
47648 </indexterm>
47649 <indexterm role="concept">
47650 <primary>EHLO</primary>
47651 <secondary>ACL for</secondary>
47652 </indexterm>
47653 <indexterm role="concept">
47654 <primary>MAIL</primary>
47655 <secondary>ACL for</secondary>
47656 </indexterm>
47657 <indexterm role="concept">
47658 <primary>QUIT, ACL for</primary>
47659 </indexterm>
47660 <indexterm role="concept">
47661 <primary>RCPT</primary>
47662 <secondary>ACL for</secondary>
47663 </indexterm>
47664 <indexterm role="concept">
47665 <primary>STARTTLS, ACL for</primary>
47666 </indexterm>
47667 <indexterm role="concept">
47668 <primary>VRFY</primary>
47669 <secondary>ACL for</secondary>
47670 </indexterm>
47671 <indexterm role="concept">
47672 <primary>SMTP</primary>
47673 <secondary>connection, ACL for</secondary>
47674 </indexterm>
47675 <indexterm role="concept">
47676 <primary>non-SMTP messages</primary>
47677 <secondary>ACLs for</secondary>
47678 </indexterm>
47679 <indexterm role="concept">
47680 <primary>MIME content scanning</primary>
47681 <secondary>ACL for</secondary>
47682 </indexterm>
47683 </para>
47684 <informaltable frame="none">
47685 <tgroup cols="2" colsep="0" rowsep="0">
47686 <colspec colwidth="140pt" align="left"/>
47687 <colspec colwidth="254pt" align="left"/>
47688 <tbody>
47689 <row>
47690 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_not_smtp</option></entry>
47691 <entry>ACL for non-SMTP messages</entry>
47692 </row>
47693 <row>
47694 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_not_smtp_mime</option></entry>
47695 <entry>ACL for non-SMTP MIME parts</entry>
47696 </row>
47697 <row>
47698 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_not_smtp_start</option></entry>
47699 <entry>ACL at start of non-SMTP message</entry>
47700 </row>
47701 <row>
47702 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_auth</option></entry>
47703 <entry>ACL for AUTH</entry>
47704 </row>
47705 <row>
47706 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_connect</option></entry>
47707 <entry>ACL for start of SMTP connection</entry>
47708 </row>
47709 <row>
47710 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_data</option></entry>
47711 <entry>ACL after DATA is complete</entry>
47712 </row>
47713 <row>
47714 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_etrn</option></entry>
47715 <entry>ACL for ETRN</entry>
47716 </row>
47717 <row>
47718 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_expn</option></entry>
47719 <entry>ACL for EXPN</entry>
47720 </row>
47721 <row>
47722 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_helo</option></entry>
47723 <entry>ACL for HELO or EHLO</entry>
47724 </row>
47725 <row>
47726 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_mail</option></entry>
47727 <entry>ACL for MAIL</entry>
47728 </row>
47729 <row>
47730 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_mailauth</option></entry>
47731 <entry>ACL for the AUTH parameter of MAIL</entry>
47732 </row>
47733 <row>
47734 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_mime</option></entry>
47735 <entry>ACL for content-scanning MIME parts</entry>
47736 </row>
47737 <row>
47738 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_notquit</option></entry>
47739 <entry>ACL for non-QUIT terminations</entry>
47740 </row>
47741 <row>
47742 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_predata</option></entry>
47743 <entry>ACL at start of DATA command</entry>
47744 </row>
47745 <row>
47746 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_quit</option></entry>
47747 <entry>ACL for QUIT</entry>
47748 </row>
47749 <row>
47750 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_rcpt</option></entry>
47751 <entry>ACL for RCPT</entry>
47752 </row>
47753 <row>
47754 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_starttls</option></entry>
47755 <entry>ACL for STARTTLS</entry>
47756 </row>
47757 <row>
47758 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_vrfy</option></entry>
47759 <entry>ACL for VRFY</entry>
47760 </row>
47761 </tbody>
47762 </tgroup>
47763 </informaltable>
47764 <para>
47765 For example, if you set
47766 </para>
47767 <literallayout class="monospaced">
47768 acl_smtp_rcpt = small_acl
47769 </literallayout>
47770 <para>
47771 the little ACL defined above is used whenever Exim receives a RCPT command
47772 in an SMTP dialogue. The majority of policy tests on incoming messages can be
47773 done when RCPT commands arrive. A rejection of RCPT should cause the
47774 sending MTA to give up on the recipient address contained in the RCPT
47775 command, whereas rejection at other times may cause the client MTA to keep on
47776 trying to deliver the message. It is therefore recommended that you do as much
47777 testing as possible at RCPT time.
47778 </para>
47779 </section>
47780 <section id="SECID190">
47781 <title>The non-SMTP ACLs</title>
47782 <para>
47783 <indexterm role="concept">
47784 <primary>non-SMTP messages</primary>
47785 <secondary>ACLs for</secondary>
47786 </indexterm>
47787 The non-SMTP ACLs apply to all non-interactive incoming messages, that is, they
47788 apply to batched SMTP as well as to non-SMTP messages. (Batched SMTP is not
47789 really SMTP.) Many of the ACL conditions (for example, host tests, and tests on
47790 the state of the SMTP connection such as encryption and authentication) are not
47791 relevant and are forbidden in these ACLs. However, the sender and recipients
47792 are known, so the <option>senders</option> and <option>sender_domains</option> conditions and the
47793 <varname>$sender_address</varname> and <varname>$recipients</varname> variables can be used. Variables such as
47794 <varname>$authenticated_sender</varname> are also available. You can specify added header lines
47795 in any of these ACLs.
47796 </para>
47797 <para>
47798 The <option>acl_not_smtp_start</option> ACL is run right at the start of receiving a
47799 non-SMTP message, before any of the message has been read. (This is the
47800 analogue of the <option>acl_smtp_predata</option> ACL for SMTP input.) In the case of
47801 batched SMTP input, it runs after the DATA command has been reached. The
47802 result of this ACL is ignored; it cannot be used to reject a message. If you
47803 really need to, you could set a value in an ACL variable here and reject based
47804 on that in the <option>acl_not_smtp</option> ACL. However, this ACL can be used to set
47805 controls, and in particular, it can be used to set
47806 </para>
47807 <literallayout class="monospaced">
47808 control = suppress_local_fixups
47809 </literallayout>
47810 <para>
47811 This cannot be used in the other non-SMTP ACLs because by the time they are
47812 run, it is too late.
47813 </para>
47814 <para>
47815 The <option>acl_not_smtp_mime</option> ACL is available only when Exim is compiled with the
47816 content-scanning extension. For details, see chapter <xref linkend="CHAPexiscan"/>.
47817 </para>
47818 <para>
47819 The <option>acl_not_smtp</option> ACL is run just before the <function>local_scan()</function> function. Any
47820 kind of rejection is treated as permanent, because there is no way of sending a
47821 temporary error for these kinds of message.
47822 </para>
47823 </section>
47824 <section id="SECID191">
47825 <title>The SMTP connect ACL</title>
47826 <para>
47827 <indexterm role="concept">
47828 <primary>SMTP</primary>
47829 <secondary>connection, ACL for</secondary>
47830 </indexterm>
47831 <indexterm role="option">
47832 <primary><option>smtp_banner</option></primary>
47833 </indexterm>
47834 The ACL test specified by <option>acl_smtp_connect</option> happens at the start of an SMTP
47835 session, after the test specified by <option>host_reject_connection</option> (which is now
47836 an anomaly) and any TCP Wrappers testing (if configured). If the connection is
47837 accepted by an <option>accept</option> verb that has a <option>message</option> modifier, the contents of
47838 the message override the banner message that is otherwise specified by the
47839 <option>smtp_banner</option> option.
47840 </para>
47841 </section>
47842 <section id="SECID192">
47843 <title>The EHLO/HELO ACL</title>
47844 <para>
47845 <indexterm role="concept">
47846 <primary>EHLO</primary>
47847 <secondary>ACL for</secondary>
47848 </indexterm>
47849 <indexterm role="concept">
47850 <primary>HELO</primary>
47851 <secondary>ACL for</secondary>
47852 </indexterm>
47853 The ACL test specified by <option>acl_smtp_helo</option> happens when the client issues an
47854 EHLO or HELO command, after the tests specified by <option>helo_accept_junk_hosts</option>,
47855 <option>helo_allow_chars</option>, <option>helo_verify_hosts</option>, and <option>helo_try_verify_hosts</option>.
47856 Note that a client may issue more than one EHLO or HELO command in an SMTP
47857 session, and indeed is required to issue a new EHLO or HELO after successfully
47858 setting up encryption following a STARTTLS command.
47859 </para>
47860 <para>
47861 If the command is accepted by an <option>accept</option> verb that has a <option>message</option>
47862 modifier, the message may not contain more than one line (it will be truncated
47863 at the first newline and a panic logged if it does). Such a message cannot
47864 affect the EHLO options that are listed on the second and subsequent lines of
47865 an EHLO response.
47866 </para>
47867 </section>
47868 <section id="SECID193">
47869 <title>The DATA ACLs</title>
47870 <para>
47871 <indexterm role="concept">
47872 <primary>DATA</primary>
47873 <secondary>ACLs for</secondary>
47874 </indexterm>
47875 Two ACLs are associated with the DATA command, because it is two-stage
47876 command, with two responses being sent to the client.
47877 When the DATA command is received, the ACL defined by <option>acl_smtp_predata</option>
47878 is obeyed. This gives you control after all the RCPT commands, but before
47879 the message itself is received. It offers the opportunity to give a negative
47880 response to the DATA command before the data is transmitted. Header lines
47881 added by MAIL or RCPT ACLs are not visible at this time, but any that
47882 are defined here are visible when the <option>acl_smtp_data</option> ACL is run.
47883 </para>
47884 <para>
47885 You cannot test the contents of the message, for example, to verify addresses
47886 in the headers, at RCPT time or when the DATA command is received. Such
47887 tests have to appear in the ACL that is run after the message itself has been
47888 received, before the final response to the DATA command is sent. This is
47889 the ACL specified by <option>acl_smtp_data</option>, which is the second ACL that is
47890 associated with the DATA command.
47891 </para>
47892 <para>
47893 For both of these ACLs, it is not possible to reject individual recipients. An
47894 error response rejects the entire message. Unfortunately, it is known that some
47895 MTAs do not treat hard (5<emphasis>xx</emphasis>) responses to the DATA command (either
47896 before or after the data) correctly &ndash; they keep the message on their queues
47897 and try again later, but that is their problem, though it does waste some of
47898 your resources.
47899 </para>
47900 </section>
47901 <section id="SECTDKIMACL" revisionflag="changed">
47902 <title>The SMTP DKIM ACL</title>
47903 <para revisionflag="changed">
47904 The <option>acl_smtp_dkim</option> ACL is available only when Exim is compiled with DKIM support
47905 enabled (which is the default).
47906 </para>
47907 <para revisionflag="changed">
47908 The ACL test specified by <option>acl_smtp_dkim</option> happens after a message has been
47909 received, and is executed for each DKIM signature found in a message.  If not
47910 otherwise specified, the default action is to accept.
47911 </para>
47912 <para revisionflag="changed">
47913 For details on the operation of DKIM, see chapter <xref linkend="CHID12"/>.
47914 </para>
47915 </section>
47916 <section id="SECID194">
47917 <title>The SMTP MIME ACL</title>
47918 <para>
47919 The <option>acl_smtp_mime</option> option is available only when Exim is compiled with the
47920 content-scanning extension. For details, see chapter <xref linkend="CHAPexiscan"/>.
47921 </para>
47922 </section>
47923 <section id="SECTQUITACL">
47924 <title>The QUIT ACL</title>
47925 <para>
47926 <indexterm role="concept">
47927 <primary>QUIT, ACL for</primary>
47928 </indexterm>
47929 The ACL for the SMTP QUIT command is anomalous, in that the outcome of the ACL
47930 does not affect the response code to QUIT, which is always 221. Thus, the ACL
47931 does not in fact control any access. For this reason, the only verbs that are
47932 permitted are <option>accept</option> and <option>warn</option>.
47933 </para>
47934 <para>
47935 This ACL can be used for tasks such as custom logging at the end of an SMTP
47936 session. For example, you can use ACL variables in other ACLs to count
47937 messages, recipients, etc., and log the totals at QUIT time using one or
47938 more <option>logwrite</option> modifiers on a <option>warn</option> verb.
47939 </para>
47940 <para>
47941 <emphasis role="bold">Warning</emphasis>: Only the <varname>$acl_c</varname><emphasis>x</emphasis> variables can be used for this, because
47942 the <varname>$acl_m</varname><emphasis>x</emphasis> variables are reset at the end of each incoming message.
47943 </para>
47944 <para>
47945 You do not need to have a final <option>accept</option>, but if you do, you can use a
47946 <option>message</option> modifier to specify custom text that is sent as part of the 221
47947 response to QUIT.
47948 </para>
47949 <para>
47950 This ACL is run only for a <quote>normal</quote> QUIT. For certain kinds of disastrous
47951 failure (for example, failure to open a log file, or when Exim is bombing out
47952 because it has detected an unrecoverable error), all SMTP commands from the
47953 client are given temporary error responses until QUIT is received or the
47954 connection is closed. In these special cases, the QUIT ACL does not run.
47955 </para>
47956 </section>
47957 <section id="SECTNOTQUITACL">
47958 <title>The not-QUIT ACL</title>
47959 <para>
47960 <indexterm role="variable">
47961 <primary><varname>$acl_smtp_notquit</varname></primary>
47962 </indexterm>
47963 The not-QUIT ACL, specified by <option>acl_smtp_notquit</option>, is run in most cases when
47964 an SMTP session ends without sending QUIT. However, when Exim itself is is bad
47965 trouble, such as being unable to write to its log files, this ACL is not run,
47966 because it might try to do things (such as write to log files) that make the
47967 situation even worse.
47968 </para>
47969 <para>
47970 Like the QUIT ACL, this ACL is provided to make it possible to do customized
47971 logging or to gather statistics, and its outcome is ignored. The <option>delay</option>
47972 modifier is forbidden in this ACL, and the only permitted verbs are <option>accept</option>
47973 and <option>warn</option>.
47974 </para>
47975 <para>
47976 <indexterm role="variable">
47977 <primary><varname>$smtp_notquit_reason</varname></primary>
47978 </indexterm>
47979 When the not-QUIT ACL is running, the variable <varname>$smtp_notquit_reason</varname> is set
47980 to a string that indicates the reason for the termination of the SMTP
47981 connection. The possible values are:
47982 </para>
47983 <informaltable frame="none">
47984 <tgroup cols="2" colsep="0" rowsep="0">
47985 <colspec colwidth="196pt" align="left"/>
47986 <colspec colwidth="254pt" align="left"/>
47987 <tbody>
47988 <row>
47989 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>acl-drop</literal></entry>
47990 <entry>Another ACL issued a <option>drop</option> command</entry>
47991 </row>
47992 <row>
47993 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>bad-commands</literal></entry>
47994 <entry>Too many unknown or non-mail commands</entry>
47995 </row>
47996 <row>
47997 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>command-timeout</literal></entry>
47998 <entry>Timeout while reading SMTP commands</entry>
47999 </row>
48000 <row>
48001 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>connection-lost</literal></entry>
48002 <entry>The SMTP connection has been lost</entry>
48003 </row>
48004 <row>
48005 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>data-timeout</literal></entry>
48006 <entry>Timeout while reading message data</entry>
48007 </row>
48008 <row>
48009 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>local-scan-error</literal></entry>
48010 <entry>The <function>local_scan()</function> function crashed</entry>
48011 </row>
48012 <row>
48013 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>local-scan-timeout</literal></entry>
48014 <entry>The <function>local_scan()</function> function timed out</entry>
48015 </row>
48016 <row>
48017 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>signal-exit</literal></entry>
48018 <entry>SIGTERM or SIGINT</entry>
48019 </row>
48020 <row>
48021 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>synchronization-error</literal></entry>
48022 <entry>SMTP synchronization error</entry>
48023 </row>
48024 <row>
48025 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>tls-failed</literal></entry>
48026 <entry>TLS failed to start</entry>
48027 </row>
48028 </tbody>
48029 </tgroup>
48030 </informaltable>
48031 <para>
48032 In most cases when an SMTP connection is closed without having received QUIT,
48033 Exim sends an SMTP response message before actually closing the connection.
48034 With the exception of the <literal>acl-drop</literal> case, the default message can be
48035 overridden by the <option>message</option> modifier in the not-QUIT ACL. In the case of a
48036 <option>drop</option> verb in another ACL, it is the message from the other ACL that is
48037 used.
48038 </para>
48039 </section>
48040 <section id="SECID195">
48041 <title>Finding an ACL to use</title>
48042 <para>
48043 <indexterm role="concept">
48044 <primary>access control lists (ACLs)</primary>
48045 <secondary>finding which to use</secondary>
48046 </indexterm>
48047 The value of an <option>acl_smtp_</option><emphasis>xxx</emphasis> option is expanded before use, so
48048 you can use different ACLs in different circumstances. For example,
48049 </para>
48050 <literallayout class="monospaced">
48051 acl_smtp_rcpt = ${if ={25}{$interface_port} \
48052                      {acl_check_rcpt} {acl_check_rcpt_submit} }
48053 </literallayout>
48054 <para>
48055 In the default configuration file there are some example settings for
48056 providing an RFC 4409 message submission service on port 587 and a
48057 non-standard <quote>smtps</quote> service on port 465. You can use a string
48058 expansion like this to choose an ACL for MUAs on these ports which is
48059 more appropriate for this purpose than the default ACL on port 25.
48060 </para>
48061 <para>
48062 The expanded string does not have to be the name of an ACL in the
48063 configuration file; there are other possibilities. Having expanded the
48064 string, Exim searches for an ACL as follows:
48065 </para>
48066 <itemizedlist>
48067 <listitem>
48068 <para>
48069 If the string begins with a slash, Exim uses it as a file name, and reads its
48070 contents as an ACL. The lines are processed in the same way as lines in the
48071 Exim configuration file. In particular, continuation lines are supported, blank
48072 lines are ignored, as are lines whose first non-whitespace character is <quote>#</quote>.
48073 If the file does not exist or cannot be read, an error occurs (typically
48074 causing a temporary failure of whatever caused the ACL to be run). For example:
48075 </para>
48076 <literallayout class="monospaced">
48077 acl_smtp_data = /etc/acls/\
48078   ${lookup{$sender_host_address}lsearch\
48079   {/etc/acllist}{$value}{default}}
48080 </literallayout>
48081 <para>
48082 This looks up an ACL file to use on the basis of the host&#x2019;s IP address, falling
48083 back to a default if the lookup fails. If an ACL is successfully read from a
48084 file, it is retained in memory for the duration of the Exim process, so that it
48085 can be re-used without having to re-read the file.
48086 </para>
48087 </listitem>
48088 <listitem>
48089 <para>
48090 If the string does not start with a slash, and does not contain any spaces,
48091 Exim searches the ACL section of the configuration for an ACL whose name
48092 matches the string.
48093 </para>
48094 </listitem>
48095 <listitem>
48096 <para>
48097 If no named ACL is found, or if the string contains spaces, Exim parses
48098 the string as an inline ACL. This can save typing in cases where you just
48099 want to have something like
48100 </para>
48101 <literallayout class="monospaced">
48102 acl_smtp_vrfy = accept
48103 </literallayout>
48104 <para>
48105 in order to allow free use of the VRFY command. Such a string may contain
48106 newlines; it is processed in the same way as an ACL that is read from a file.
48107 </para>
48108 </listitem>
48109 </itemizedlist>
48110 </section>
48111 <section id="SECID196">
48112 <title>ACL return codes</title>
48113 <para>
48114 <indexterm role="concept">
48115 <primary>access control lists (ACLs)</primary>
48116 <secondary>return codes</secondary>
48117 </indexterm>
48118 Except for the QUIT ACL, which does not affect the SMTP return code (see
48119 section <xref linkend="SECTQUITACL"/> above), the result of running an ACL is either
48120 <quote>accept</quote> or <quote>deny</quote>, or, if some test cannot be completed (for example, if a
48121 database is down), <quote>defer</quote>. These results cause 2<emphasis>xx</emphasis>, 5<emphasis>xx</emphasis>, and 4<emphasis>xx</emphasis>
48122 return codes, respectively, to be used in the SMTP dialogue. A fourth return,
48123 <quote>error</quote>, occurs when there is an error such as invalid syntax in the ACL.
48124 This also causes a 4<emphasis>xx</emphasis> return code.
48125 </para>
48126 <para>
48127 For the non-SMTP ACL, <quote>defer</quote> and <quote>error</quote> are treated in the same way as
48128 <quote>deny</quote>, because there is no mechanism for passing temporary errors to the
48129 submitters of non-SMTP messages.
48130 </para>
48131 <para>
48132 ACLs that are relevant to message reception may also return <quote>discard</quote>. This
48133 has the effect of <quote>accept</quote>, but causes either the entire message or an
48134 individual recipient address to be discarded. In other words, it is a
48135 blackholing facility. Use it with care.
48136 </para>
48137 <para>
48138 If the ACL for MAIL returns <quote>discard</quote>, all recipients are discarded, and no
48139 ACL is run for subsequent RCPT commands. The effect of <quote>discard</quote> in a
48140 RCPT ACL is to discard just the one recipient address. If there are no
48141 recipients left when the message&#x2019;s data is received, the DATA ACL is not
48142 run. A <quote>discard</quote> return from the DATA or the non-SMTP ACL discards all the
48143 remaining recipients. The <quote>discard</quote> return is not permitted for the
48144 <option>acl_smtp_predata</option> ACL.
48145 </para>
48146 <para>
48147 <indexterm role="concept">
48148 <primary><function>local_scan()</function> function</primary>
48149 <secondary>when all recipients discarded</secondary>
48150 </indexterm>
48151 The <function>local_scan()</function> function is always run, even if there are no remaining
48152 recipients; it may create new recipients.
48153 </para>
48154 </section>
48155 <section id="SECID197">
48156 <title>Unset ACL options</title>
48157 <para>
48158 <indexterm role="concept">
48159 <primary>access control lists (ACLs)</primary>
48160 <secondary>unset options</secondary>
48161 </indexterm>
48162 The default actions when any of the <option>acl_</option><emphasis>xxx</emphasis> options are unset are not
48163 all the same. <emphasis role="bold">Note</emphasis>: These defaults apply only when the relevant ACL is
48164 not defined at all. For any defined ACL, the default action when control
48165 reaches the end of the ACL statements is <quote>deny</quote>.
48166 </para>
48167 <para>
48168 For <option>acl_smtp_quit</option> and <option>acl_not_smtp_start</option> there is no default because
48169 these two are ACLs that are used only for their side effects. They cannot be
48170 used to accept or reject anything.
48171 </para>
48172 <para>
48173 For <option>acl_not_smtp</option>, <option>acl_smtp_auth</option>, <option>acl_smtp_connect</option>,
48174 <option>acl_smtp_data</option>, <option>acl_smtp_helo</option>, <option>acl_smtp_mail</option>, <option>acl_smtp_mailauth</option>,
48175 <option>acl_smtp_mime</option>, <option>acl_smtp_predata</option>, and <option>acl_smtp_starttls</option>, the action
48176 when the ACL is not defined is <quote>accept</quote>.
48177 </para>
48178 <para>
48179 For the others (<option>acl_smtp_etrn</option>, <option>acl_smtp_expn</option>, <option>acl_smtp_rcpt</option>, and
48180 <option>acl_smtp_vrfy</option>), the action when the ACL is not defined is <quote>deny</quote>.
48181 This means that <option>acl_smtp_rcpt</option> must be defined in order to receive any
48182 messages over an SMTP connection. For an example, see the ACL in the default
48183 configuration file.
48184 </para>
48185 </section>
48186 <section id="SECID198">
48187 <title>Data for message ACLs</title>
48188 <para>
48189 <indexterm role="concept">
48190 <primary>access control lists (ACLs)</primary>
48191 <secondary>data for message ACL</secondary>
48192 </indexterm>
48193 <indexterm role="variable">
48194 <primary><varname>$domain</varname></primary>
48195 </indexterm>
48196 <indexterm role="variable">
48197 <primary><varname>$local_part</varname></primary>
48198 </indexterm>
48199 <indexterm role="variable">
48200 <primary><varname>$sender_address</varname></primary>
48201 </indexterm>
48202 <indexterm role="variable">
48203 <primary><varname>$sender_host_address</varname></primary>
48204 </indexterm>
48205 <indexterm role="variable">
48206 <primary><varname>$smtp_command</varname></primary>
48207 </indexterm>
48208 When a MAIL or RCPT ACL, or either of the DATA ACLs, is running, the variables
48209 that contain information about the host and the message&#x2019;s sender (for example,
48210 <varname>$sender_host_address</varname> and <varname>$sender_address</varname>) are set, and can be used in ACL
48211 statements. In the case of RCPT (but not MAIL or DATA), <varname>$domain</varname> and
48212 <varname>$local_part</varname> are set from the argument address. The entire SMTP command
48213 is available in <varname>$smtp_command</varname>.
48214 </para>
48215 <para>
48216 When an ACL for the AUTH parameter of MAIL is running, the variables that
48217 contain information about the host are set, but <varname>$sender_address</varname> is not yet
48218 set. Section <xref linkend="SECTauthparamail"/> contains a discussion of this parameter and
48219 how it is used.
48220 </para>
48221 <para>
48222 <indexterm role="variable">
48223 <primary><varname>$message_size</varname></primary>
48224 </indexterm>
48225 The <varname>$message_size</varname> variable is set to the value of the SIZE parameter on
48226 the MAIL command at MAIL, RCPT and pre-data time, or to -1 if
48227 that parameter is not given. The value is updated to the true message size by
48228 the time the final DATA ACL is run (after the message data has been
48229 received).
48230 </para>
48231 <para>
48232 <indexterm role="variable">
48233 <primary><varname>$rcpt_count</varname></primary>
48234 </indexterm>
48235 <indexterm role="variable">
48236 <primary><varname>$recipients_count</varname></primary>
48237 </indexterm>
48238 The <varname>$rcpt_count</varname> variable increases by one for each RCPT command received.
48239 The <varname>$recipients_count</varname> variable increases by one each time a RCPT command is
48240 accepted, so while an ACL for RCPT is being processed, it contains the number
48241 of previously accepted recipients. At DATA time (for both the DATA ACLs),
48242 <varname>$rcpt_count</varname> contains the total number of RCPT commands, and
48243 <varname>$recipients_count</varname> contains the total number of accepted recipients.
48244 </para>
48245 </section>
48246 <section id="SECTdatfornon">
48247 <title>Data for non-message ACLs</title>
48248 <para>
48249 <indexterm role="concept">
48250 <primary>access control lists (ACLs)</primary>
48251 <secondary>data for non-message ACL</secondary>
48252 </indexterm>
48253 <indexterm role="variable">
48254 <primary><varname>$smtp_command_argument</varname></primary>
48255 </indexterm>
48256 <indexterm role="variable">
48257 <primary><varname>$smtp_command</varname></primary>
48258 </indexterm>
48259 When an ACL is being run for AUTH, EHLO, ETRN, EXPN, HELO, STARTTLS, or VRFY,
48260 the remainder of the SMTP command line is placed in <varname>$smtp_command_argument</varname>,
48261 and the entire SMTP command is available in <varname>$smtp_command</varname>.
48262 These variables can be tested using a <option>condition</option> condition. For example,
48263 here is an ACL for use with AUTH, which insists that either the session is
48264 encrypted, or the CRAM-MD5 authentication method is used. In other words, it
48265 does not permit authentication methods that use cleartext passwords on
48266 unencrypted connections.
48267 </para>
48268 <literallayout class="monospaced">
48269 acl_check_auth:
48270   accept encrypted = *
48271   accept condition = ${if eq{${uc:$smtp_command_argument}}\
48272                      {CRAM-MD5}}
48273   deny   message   = TLS encryption or CRAM-MD5 required
48274 </literallayout>
48275 <para>
48276 (Another way of applying this restriction is to arrange for the authenticators
48277 that use cleartext passwords not to be advertised when the connection is not
48278 encrypted. You can use the generic <option>server_advertise_condition</option> authenticator
48279 option to do this.)
48280 </para>
48281 </section>
48282 <section id="SECID199">
48283 <title>Format of an ACL</title>
48284 <para>
48285 <indexterm role="concept">
48286 <primary>access control lists (ACLs)</primary>
48287 <secondary>format of</secondary>
48288 </indexterm>
48289 <indexterm role="concept">
48290 <primary>access control lists (ACLs)</primary>
48291 <secondary>verbs, definition of</secondary>
48292 </indexterm>
48293 An individual ACL consists of a number of statements. Each statement starts
48294 with a verb, optionally followed by a number of conditions and <quote>modifiers</quote>.
48295 Modifiers can change the way the verb operates, define error and log messages,
48296 set variables, insert delays, and vary the processing of accepted messages.
48297 </para>
48298 <para>
48299 If all the conditions are met, the verb is obeyed. The same condition may be
48300 used (with different arguments) more than once in the same statement. This
48301 provides a means of specifying an <quote>and</quote> conjunction between conditions. For
48302 example:
48303 </para>
48304 <literallayout class="monospaced">
48305 deny  dnslists = list1.example
48306 dnslists = list2.example
48307 </literallayout>
48308 <para>
48309 If there are no conditions, the verb is always obeyed. Exim stops evaluating
48310 the conditions and modifiers when it reaches a condition that fails. What
48311 happens then depends on the verb (and in one case, on a special modifier). Not
48312 all the conditions make sense at every testing point. For example, you cannot
48313 test a sender address in the ACL that is run for a VRFY command.
48314 </para>
48315 </section>
48316 <section id="SECID200">
48317 <title>ACL verbs</title>
48318 <para>
48319 The ACL verbs are as follows:
48320 </para>
48321 <itemizedlist>
48322 <listitem>
48323 <para>
48324 <indexterm role="concept">
48325 <primary><option>accept</option> ACL verb</primary>
48326 </indexterm>
48327 <option>accept</option>: If all the conditions are met, the ACL returns <quote>accept</quote>. If any
48328 of the conditions are not met, what happens depends on whether <option>endpass</option>
48329 appears among the conditions (for syntax see below). If the failing condition
48330 is before <option>endpass</option>, control is passed to the next ACL statement; if it is
48331 after <option>endpass</option>, the ACL returns <quote>deny</quote>. Consider this statement, used to
48332 check a RCPT command:
48333 </para>
48334 <literallayout class="monospaced">
48335 accept domains = +local_domains
48336 endpass
48337 verify = recipient
48338 </literallayout>
48339 <para>
48340 If the recipient domain does not match the <option>domains</option> condition, control
48341 passes to the next statement. If it does match, the recipient is verified, and
48342 the command is accepted if verification succeeds. However, if verification
48343 fails, the ACL yields <quote>deny</quote>, because the failing condition is after
48344 <option>endpass</option>.
48345 </para>
48346 <para>
48347 The <option>endpass</option> feature has turned out to be confusing to many people, so its
48348 use is not recommended nowadays. It is always possible to rewrite an ACL so
48349 that <option>endpass</option> is not needed, and it is no longer used in the default
48350 configuration.
48351 </para>
48352 <para>
48353 <indexterm role="concept">
48354 <primary><option>message</option> ACL modifier</primary>
48355 <secondary>with <option>accept</option></secondary>
48356 </indexterm>
48357 If a <option>message</option> modifier appears on an <option>accept</option> statement, its action
48358 depends on whether or not <option>endpass</option> is present. In the absence of <option>endpass</option>
48359 (when an <option>accept</option> verb either accepts or passes control to the next
48360 statement), <option>message</option> can be used to vary the message that is sent when an
48361 SMTP command is accepted. For example, in a RCPT ACL you could have:
48362 </para>
48363 <literallayout>
48364 <literal>accept  </literal>&lt;<emphasis>some conditions</emphasis>&gt;
48365 <literal>        message = OK, I will allow you through today</literal>
48366 </literallayout>
48367 <para>
48368 You can specify an SMTP response code, optionally followed by an <quote>extended
48369 response code</quote> at the start of the message, but the first digit must be the
48370 same as would be sent by default, which is 2 for an <option>accept</option> verb.
48371 </para>
48372 <para>
48373 If <option>endpass</option> is present in an <option>accept</option> statement, <option>message</option> specifies
48374 an error message that is used when access is denied. This behaviour is retained
48375 for backward compatibility, but current <quote>best practice</quote> is to avoid the use
48376 of <option>endpass</option>.
48377 </para>
48378 </listitem>
48379 <listitem>
48380 <para>
48381 <indexterm role="concept">
48382 <primary><option>defer</option> ACL verb</primary>
48383 </indexterm>
48384 <option>defer</option>: If all the conditions are true, the ACL returns <quote>defer</quote> which, in
48385 an SMTP session, causes a 4<emphasis>xx</emphasis> response to be given. For a non-SMTP ACL,
48386 <option>defer</option> is the same as <option>deny</option>, because there is no way of sending a
48387 temporary error. For a RCPT command, <option>defer</option> is much the same as using a
48388 <command>redirect</command> router and <literal>:defer:</literal> while verifying, but the <option>defer</option> verb can
48389 be used in any ACL, and even for a recipient it might be a simpler approach.
48390 </para>
48391 </listitem>
48392 <listitem>
48393 <para>
48394 <indexterm role="concept">
48395 <primary><option>deny</option> ACL verb</primary>
48396 </indexterm>
48397 <option>deny</option>: If all the conditions are met, the ACL returns <quote>deny</quote>. If any of
48398 the conditions are not met, control is passed to the next ACL statement. For
48399 example,
48400 </para>
48401 <literallayout class="monospaced">
48402 deny dnslists = blackholes.mail-abuse.org
48403 </literallayout>
48404 <para>
48405 rejects commands from hosts that are on a DNS black list.
48406 </para>
48407 </listitem>
48408 <listitem>
48409 <para>
48410 <indexterm role="concept">
48411 <primary><option>discard</option> ACL verb</primary>
48412 </indexterm>
48413 <option>discard</option>: This verb behaves like <option>accept</option>, except that it returns
48414 <quote>discard</quote> from the ACL instead of <quote>accept</quote>. It is permitted only on ACLs
48415 that are concerned with receiving messages. When all the conditions are true,
48416 the sending entity receives a <quote>success</quote> response. However, <option>discard</option> causes
48417 recipients to be discarded. If it is used in an ACL for RCPT, just the one
48418 recipient is discarded; if used for MAIL, DATA or in the non-SMTP ACL, all the
48419 message&#x2019;s recipients are discarded. Recipients that are discarded before DATA
48420 do not appear in the log line when the <option>received_recipients</option> log selector is set.
48421 </para>
48422 <para>
48423 If the <option>log_message</option> modifier is set when <option>discard</option> operates,
48424 its contents are added to the line that is automatically written to the log.
48425 The <option>message</option> modifier operates exactly as it does for <option>accept</option>.
48426 </para>
48427 </listitem>
48428 <listitem>
48429 <para>
48430 <indexterm role="concept">
48431 <primary><option>drop</option> ACL verb</primary>
48432 </indexterm>
48433 <option>drop</option>: This verb behaves like <option>deny</option>, except that an SMTP connection is
48434 forcibly closed after the 5<emphasis>xx</emphasis> error message has been sent. For example:
48435 </para>
48436 <literallayout class="monospaced">
48437 drop   message   = I don't take more than 20 RCPTs
48438        condition = ${if &gt; {$rcpt_count}{20}}
48439 </literallayout>
48440 <para>
48441 There is no difference between <option>deny</option> and <option>drop</option> for the connect-time ACL.
48442 The connection is always dropped after sending a 550 response.
48443 </para>
48444 </listitem>
48445 <listitem>
48446 <para>
48447 <indexterm role="concept">
48448 <primary><option>require</option> ACL verb</primary>
48449 </indexterm>
48450 <option>require</option>: If all the conditions are met, control is passed to the next ACL
48451 statement. If any of the conditions are not met, the ACL returns <quote>deny</quote>. For
48452 example, when checking a RCPT command,
48453 </para>
48454 <literallayout class="monospaced">
48455 require message = Sender did not verify
48456         verify  = sender
48457 </literallayout>
48458 <para>
48459 passes control to subsequent statements only if the message&#x2019;s sender can be
48460 verified. Otherwise, it rejects the command. Note the positioning of the
48461 <option>message</option> modifier, before the <option>verify</option> condition. The reason for this is
48462 discussed in section <xref linkend="SECTcondmodproc"/>.
48463 </para>
48464 </listitem>
48465 <listitem>
48466 <para>
48467 <indexterm role="concept">
48468 <primary><option>warn</option> ACL verb</primary>
48469 </indexterm>
48470 <option>warn</option>: If all the conditions are true, a line specified by the
48471 <option>log_message</option> modifier is written to Exim&#x2019;s main log. Control always passes
48472 to the next ACL statement. If any condition is false, the log line is not
48473 written. If an identical log line is requested several times in the same
48474 message, only one copy is actually written to the log. If you want to force
48475 duplicates to be written, use the <option>logwrite</option> modifier instead.
48476 </para>
48477 <para>
48478 If <option>log_message</option> is not present, a <option>warn</option> verb just checks its conditions
48479 and obeys any <quote>immediate</quote> modifiers (such as <option>control</option>, <option>set</option>,
48480 <option>logwrite</option>, and <option>add_header</option>) that appear before the first failing
48481 condition. There is more about adding header lines in section
48482 <xref linkend="SECTaddheadacl"/>.
48483 </para>
48484 <para>
48485 If any condition on a <option>warn</option> statement cannot be completed (that is, there is
48486 some sort of defer), the log line specified by <option>log_message</option> is not written.
48487 This does not include the case of a forced failure from a lookup, which
48488 is considered to be a successful completion. After a defer, no further
48489 conditions or modifiers in the <option>warn</option> statement are processed. The incident
48490 is logged, and the ACL continues to be processed, from the next statement
48491 onwards.
48492 </para>
48493 <para>
48494 <indexterm role="variable">
48495 <primary><varname>$acl_verify_message</varname></primary>
48496 </indexterm>
48497 When one of the <option>warn</option> conditions is an address verification that fails, the
48498 text of the verification failure message is in <varname>$acl_verify_message</varname>. If you
48499 want this logged, you must set it up explicitly. For example:
48500 </para>
48501 <literallayout class="monospaced">
48502 warn   !verify = sender
48503        log_message = sender verify failed: $acl_verify_message
48504 </literallayout>
48505 </listitem>
48506 </itemizedlist>
48507 <para>
48508 At the end of each ACL there is an implicit unconditional <option>deny</option>.
48509 </para>
48510 <para>
48511 As you can see from the examples above, the conditions and modifiers are
48512 written one to a line, with the first one on the same line as the verb, and
48513 subsequent ones on following lines. If you have a very long condition, you can
48514 continue it onto several physical lines by the usual backslash continuation
48515 mechanism. It is conventional to align the conditions vertically.
48516 </para>
48517 </section>
48518 <section id="SECTaclvariables">
48519 <title>ACL variables</title>
48520 <para>
48521 <indexterm role="concept">
48522 <primary>access control lists (ACLs)</primary>
48523 <secondary>variables</secondary>
48524 </indexterm>
48525 There are some special variables that can be set during ACL processing. They
48526 can be used to pass information between different ACLs, different invocations
48527 of the same ACL in the same SMTP connection, and between ACLs and the routers,
48528 transports, and filters that are used to deliver a message. The names of these
48529 variables must begin with <varname>$acl_c</varname> or <varname>$acl_m</varname>, followed either by a digit or
48530 an underscore, but the remainder of the name can be any sequence of
48531 alphanumeric characters and underscores that you choose. There is no limit on
48532 the number of ACL variables. The two sets act as follows:
48533 </para>
48534 <itemizedlist>
48535 <listitem>
48536 <para>
48537 The values of those variables whose names begin with <varname>$acl_c</varname> persist
48538 throughout an SMTP connection. They are never reset. Thus, a value that is set
48539 while receiving one message is still available when receiving the next message
48540 on the same SMTP connection.
48541 </para>
48542 </listitem>
48543 <listitem>
48544 <para>
48545 The values of those variables whose names begin with <varname>$acl_m</varname> persist only
48546 while a message is being received. They are reset afterwards. They are also
48547 reset by MAIL, RSET, EHLO, HELO, and after starting up a TLS session.
48548 </para>
48549 </listitem>
48550 </itemizedlist>
48551 <para>
48552 When a message is accepted, the current values of all the ACL variables are
48553 preserved with the message and are subsequently made available at delivery
48554 time. The ACL variables are set by a modifier called <option>set</option>. For example:
48555 </para>
48556 <literallayout class="monospaced">
48557 accept hosts = whatever
48558        set acl_m4 = some value
48559 accept authenticated = *
48560        set acl_c_auth = yes
48561 </literallayout>
48562 <para>
48563 <emphasis role="bold">Note</emphasis>: A leading dollar sign is not used when naming a variable that is to
48564 be set. If you want to set a variable without taking any action, you can use a
48565 <option>warn</option> verb without any other modifiers or conditions.
48566 </para>
48567 <para>
48568 <indexterm role="option">
48569 <primary><option>strict_acl_vars</option></primary>
48570 </indexterm>
48571 What happens if a syntactically valid but undefined ACL variable is
48572 referenced depends on the setting of the <option>strict_acl_vars</option> option. If it is
48573 false (the default), an empty string is substituted; if it is true, an
48574 error is generated.
48575 </para>
48576 <para>
48577 Versions of Exim before 4.64 have a limited set of numbered variables, but
48578 their names are compatible, so there is no problem with upgrading.
48579 </para>
48580 </section>
48581 <section id="SECTcondmodproc">
48582 <title>Condition and modifier processing</title>
48583 <para>
48584 <indexterm role="concept">
48585 <primary>access control lists (ACLs)</primary>
48586 <secondary>conditions; processing</secondary>
48587 </indexterm>
48588 <indexterm role="concept">
48589 <primary>access control lists (ACLs)</primary>
48590 <secondary>modifiers; processing</secondary>
48591 </indexterm>
48592 An exclamation mark preceding a condition negates its result. For example:
48593 </para>
48594 <literallayout class="monospaced">
48595 deny   domains = *.dom.example
48596       !verify  = recipient
48597 </literallayout>
48598 <para>
48599 causes the ACL to return <quote>deny</quote> if the recipient domain ends in
48600 <emphasis>dom.example</emphasis> and the recipient address cannot be verified. Sometimes
48601 negation can be used on the right-hand side of a condition. For example, these
48602 two statements are equivalent:
48603 </para>
48604 <literallayout class="monospaced">
48605 deny  hosts = !192.168.3.4
48606 deny !hosts =  192.168.3.4
48607 </literallayout>
48608 <para>
48609 However, for many conditions (<option>verify</option> being a good example), only left-hand
48610 side negation of the whole condition is possible.
48611 </para>
48612 <para>
48613 The arguments of conditions and modifiers are expanded. A forced failure
48614 of an expansion causes a condition to be ignored, that is, it behaves as if the
48615 condition is true. Consider these two statements:
48616 </para>
48617 <literallayout class="monospaced">
48618 accept  senders = ${lookup{$host_name}lsearch\
48619                   {/some/file}{$value}fail}
48620 accept  senders = ${lookup{$host_name}lsearch\
48621                   {/some/file}{$value}{}}
48622 </literallayout>
48623 <para>
48624 Each attempts to look up a list of acceptable senders. If the lookup succeeds,
48625 the returned list is searched, but if the lookup fails the behaviour is
48626 different in the two cases. The <option>fail</option> in the first statement causes the
48627 condition to be ignored, leaving no further conditions. The <option>accept</option> verb
48628 therefore succeeds. The second statement, however, generates an empty list when
48629 the lookup fails. No sender can match an empty list, so the condition fails,
48630 and therefore the <option>accept</option> also fails.
48631 </para>
48632 <para>
48633 ACL modifiers appear mixed in with conditions in ACL statements. Some of them
48634 specify actions that are taken as the conditions for a statement are checked;
48635 others specify text for messages that are used when access is denied or a
48636 warning is generated. The <option>control</option> modifier affects the way an incoming
48637 message is handled.
48638 </para>
48639 <para>
48640 The positioning of the modifiers in an ACL statement important, because the
48641 processing of a verb ceases as soon as its outcome is known. Only those
48642 modifiers that have already been encountered will take effect. For example,
48643 consider this use of the <option>message</option> modifier:
48644 </para>
48645 <literallayout class="monospaced">
48646 require message = Can't verify sender
48647         verify  = sender
48648         message = Can't verify recipient
48649         verify  = recipient
48650         message = This message cannot be used
48651 </literallayout>
48652 <para>
48653 If sender verification fails, Exim knows that the result of the statement is
48654 <quote>deny</quote>, so it goes no further. The first <option>message</option> modifier has been seen,
48655 so its text is used as the error message. If sender verification succeeds, but
48656 recipient verification fails, the second message is used. If recipient
48657 verification succeeds, the third message becomes <quote>current</quote>, but is never used
48658 because there are no more conditions to cause failure.
48659 </para>
48660 <para>
48661 For the <option>deny</option> verb, on the other hand, it is always the last <option>message</option>
48662 modifier that is used, because all the conditions must be true for rejection to
48663 happen. Specifying more than one <option>message</option> modifier does not make sense, and
48664 the message can even be specified after all the conditions. For example:
48665 </para>
48666 <literallayout class="monospaced">
48667 deny   hosts = ...
48668       !senders = *@my.domain.example
48669        message = Invalid sender from client host
48670 </literallayout>
48671 <para>
48672 The <quote>deny</quote> result does not happen until the end of the statement is reached,
48673 by which time Exim has set up the message.
48674 </para>
48675 </section>
48676 <section id="SECTACLmodi">
48677 <title>ACL modifiers</title>
48678 <para>
48679 <indexterm role="concept">
48680 <primary>access control lists (ACLs)</primary>
48681 <secondary>modifiers; list of</secondary>
48682 </indexterm>
48683 The ACL modifiers are as follows:
48684 </para>
48685 <variablelist>
48686 <varlistentry>
48687 <term><emphasis role="bold">add_header</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
48688 <listitem>
48689 <para>
48690 This modifier specifies one or more header lines that are to be added to an
48691 incoming message, assuming, of course, that the message is ultimately
48692 accepted. For details, see section <xref linkend="SECTaddheadacl"/>.
48693 </para>
48694 </listitem></varlistentry>
48695 <varlistentry>
48696 <term><emphasis role="bold">continue</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
48697 <listitem>
48698 <para>
48699 <indexterm role="concept">
48700 <primary><option>continue</option> ACL modifier</primary>
48701 </indexterm>
48702 <indexterm role="concept">
48703 <primary>database</primary>
48704 <secondary>updating in ACL</secondary>
48705 </indexterm>
48706 This modifier does nothing of itself, and processing of the ACL always
48707 continues with the next condition or modifier. The value of <option>continue</option> is in
48708 the side effects of expanding its argument. Typically this could be used to
48709 update a database. It is really just a syntactic tidiness, to avoid having to
48710 write rather ugly lines like this:
48711 </para>
48712 <literallayout>
48713 <literal>condition = ${if eq{0}{</literal>&lt;<emphasis>some expansion</emphasis>&gt;<literal>}{true}{true}}</literal>
48714 </literallayout>
48715 <para>
48716 Instead, all you need is
48717 </para>
48718 <literallayout>
48719 <literal>continue = </literal>&lt;<emphasis>some expansion</emphasis>&gt;
48720 </literallayout>
48721 </listitem></varlistentry>
48722 <varlistentry>
48723 <term><emphasis role="bold">control</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
48724 <listitem>
48725 <para>
48726 <indexterm role="concept">
48727 <primary><option>control</option> ACL modifier</primary>
48728 </indexterm>
48729 This modifier affects the subsequent processing of the SMTP connection or of an
48730 incoming message that is accepted. The effect of the first type of control
48731 lasts for the duration of the connection, whereas the effect of the second type
48732 lasts only until the current message has been received. The message-specific
48733 controls always apply to the whole message, not to individual recipients,
48734 even if the <option>control</option> modifier appears in a RCPT ACL.
48735 </para>
48736 <para>
48737 As there are now quite a few controls that can be applied, they are described
48738 separately in section <xref linkend="SECTcontrols"/>. The <option>control</option> modifier can be used
48739 in several different ways. For example:
48740 </para>
48741 <itemizedlist>
48742 <listitem>
48743 <para>
48744 It can be at the end of an <option>accept</option> statement:
48745 </para>
48746 <literallayout class="monospaced">
48747     accept  ...some conditions
48748             control = queue_only
48749 </literallayout>
48750 <para>
48751 In this case, the control is applied when this statement yields <quote>accept</quote>, in
48752 other words, when the conditions are all true.
48753 </para>
48754 </listitem>
48755 <listitem>
48756 <para>
48757 It can be in the middle of an <option>accept</option> statement:
48758 </para>
48759 <literallayout class="monospaced">
48760     accept  ...some conditions...
48761             control = queue_only
48762             ...some more conditions...
48763 </literallayout>
48764 <para>
48765 If the first set of conditions are true, the control is applied, even if the
48766 statement does not accept because one of the second set of conditions is false.
48767 In this case, some subsequent statement must yield <quote>accept</quote> for the control
48768 to be relevant.
48769 </para>
48770 </listitem>
48771 <listitem>
48772 <para>
48773 It can be used with <option>warn</option> to apply the control, leaving the
48774 decision about accepting or denying to a subsequent verb. For
48775 example:
48776 </para>
48777 <literallayout class="monospaced">
48778     warn    ...some conditions...
48779             control = freeze
48780     accept  ...
48781 </literallayout>
48782 <para>
48783 This example of <option>warn</option> does not contain <option>message</option>, <option>log_message</option>, or
48784 <option>logwrite</option>, so it does not add anything to the message and does not write a
48785 log entry.
48786 </para>
48787 </listitem>
48788 <listitem>
48789 <para>
48790 If you want to apply a control unconditionally, you can use it with a
48791 <option>require</option> verb. For example:
48792 </para>
48793 <literallayout class="monospaced">
48794     require  control = no_multiline_responses
48795 </literallayout>
48796 </listitem>
48797 </itemizedlist>
48798 </listitem></varlistentry>
48799 <varlistentry>
48800 <term><emphasis role="bold">delay</emphasis>&nbsp;=&nbsp;&lt;<emphasis>time</emphasis>&gt;</term>
48801 <listitem>
48802 <para>
48803 <indexterm role="concept">
48804 <primary><option>delay</option> ACL modifier</primary>
48805 </indexterm>
48806 <indexterm role="option">
48807 <primary><option>-bh</option></primary>
48808 </indexterm>
48809 This modifier may appear in any ACL. It causes Exim to wait for the time
48810 interval before proceeding. However, when testing Exim using the <option>-bh</option>
48811 option, the delay is not actually imposed (an appropriate message is output
48812 instead). The time is given in the usual Exim notation, and the delay happens
48813 as soon as the modifier is processed. In an SMTP session, pending output is
48814 flushed before the delay is imposed.
48815 </para>
48816 <para>
48817 Like <option>control</option>, <option>delay</option> can be used with <option>accept</option> or <option>deny</option>, for
48818 example:
48819 </para>
48820 <literallayout class="monospaced">
48821 deny    ...some conditions...
48822         delay = 30s
48823 </literallayout>
48824 <para>
48825 The delay happens if all the conditions are true, before the statement returns
48826 <quote>deny</quote>. Compare this with:
48827 </para>
48828 <literallayout class="monospaced">
48829 deny    delay = 30s
48830         ...some conditions...
48831 </literallayout>
48832 <para>
48833 which waits for 30s before processing the conditions. The <option>delay</option> modifier
48834 can also be used with <option>warn</option> and together with <option>control</option>:
48835 </para>
48836 <literallayout class="monospaced">
48837 warn    ...some conditions...
48838         delay = 2m
48839         control = freeze
48840 accept  ...
48841 </literallayout>
48842 <para>
48843 If <option>delay</option> is encountered when the SMTP PIPELINING extension is in use,
48844 responses to several commands are no longer buffered and sent in one packet (as
48845 they would normally be) because all output is flushed before imposing the
48846 delay. This optimization is disabled so that a number of small delays do not
48847 appear to the client as one large aggregated delay that might provoke an
48848 unwanted timeout. You can, however, disable output flushing for <option>delay</option> by
48849 using a <option>control</option> modifier to set <option>no_delay_flush</option>.
48850 </para>
48851 </listitem></varlistentry>
48852 <varlistentry>
48853 <term><emphasis role="bold">endpass</emphasis></term>
48854 <listitem>
48855 <para>
48856 <indexterm role="concept">
48857 <primary><option>endpass</option> ACL modifier</primary>
48858 </indexterm>
48859 This modifier, which has no argument, is recognized only in <option>accept</option> and
48860 <option>discard</option> statements. It marks the boundary between the conditions whose
48861 failure causes control to pass to the next statement, and the conditions whose
48862 failure causes the ACL to return <quote>deny</quote>. This concept has proved to be
48863 confusing to some people, so the use of <option>endpass</option> is no longer recommended as
48864 <quote>best practice</quote>. See the description of <option>accept</option> above for more details.
48865 </para>
48866 </listitem></varlistentry>
48867 <varlistentry>
48868 <term><emphasis role="bold">log_message</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
48869 <listitem>
48870 <para>
48871 <indexterm role="concept">
48872 <primary><option>log_message</option> ACL modifier</primary>
48873 </indexterm>
48874 This modifier sets up a message that is used as part of the log message if the
48875 ACL denies access or a <option>warn</option> statement&#x2019;s conditions are true. For example:
48876 </para>
48877 <literallayout class="monospaced">
48878 require log_message = wrong cipher suite $tls_cipher
48879         encrypted   = DES-CBC3-SHA
48880 </literallayout>
48881 <para>
48882 <option>log_message</option> is also used when recipients are discarded by <option>discard</option>. For
48883 example:
48884 </para>
48885 <literallayout>
48886 <literal>discard </literal>&lt;<emphasis>some conditions</emphasis>&gt;
48887 <literal>        log_message = Discarded $local_part@$domain because...</literal>
48888 </literallayout>
48889 <para>
48890 When access is denied, <option>log_message</option> adds to any underlying error message
48891 that may exist because of a condition failure. For example, while verifying a
48892 recipient address, a <emphasis>:fail:</emphasis> redirection might have already set up a
48893 message.
48894 </para>
48895 <para>
48896 The message may be defined before the conditions to which it applies, because
48897 the string expansion does not happen until Exim decides that access is to be
48898 denied. This means that any variables that are set by the condition are
48899 available for inclusion in the message. For example, the <varname>$dnslist_</varname>&lt;<emphasis>xxx</emphasis>&gt;
48900 variables are set after a DNS black list lookup succeeds. If the expansion of
48901 <option>log_message</option> fails, or if the result is an empty string, the modifier is
48902 ignored.
48903 </para>
48904 <para>
48905 <indexterm role="variable">
48906 <primary><varname>$acl_verify_message</varname></primary>
48907 </indexterm>
48908 If you want to use a <option>warn</option> statement to log the result of an address
48909 verification, you can use <varname>$acl_verify_message</varname> to include the verification
48910 error message.
48911 </para>
48912 <para>
48913 If <option>log_message</option> is used with a <option>warn</option> statement, <quote>Warning:</quote> is added to
48914 the start of the logged message. If the same warning log message is requested
48915 more than once while receiving  a single email message, only one copy is
48916 actually logged. If you want to log multiple copies, use <option>logwrite</option> instead
48917 of <option>log_message</option>. In the absence of <option>log_message</option> and <option>logwrite</option>, nothing
48918 is logged for a successful <option>warn</option> statement.
48919 </para>
48920 <para>
48921 If <option>log_message</option> is not present and there is no underlying error message (for
48922 example, from the failure of address verification), but <option>message</option> is present,
48923 the <option>message</option> text is used for logging rejections. However, if any text for
48924 logging contains newlines, only the first line is logged. In the absence of
48925 both <option>log_message</option> and <option>message</option>, a default built-in message is used for
48926 logging rejections.
48927 </para>
48928 </listitem></varlistentry>
48929 <varlistentry>
48930 <term><emphasis role="bold">log_reject_target</emphasis>&nbsp;=&nbsp;&lt;<emphasis>log name list</emphasis>&gt;</term>
48931 <listitem>
48932 <para>
48933 <indexterm role="concept">
48934 <primary><option>log_reject_target</option> ACL modifier</primary>
48935 </indexterm>
48936 <indexterm role="concept">
48937 <primary>logging in ACL</primary>
48938 <secondary>specifying which log</secondary>
48939 </indexterm>
48940 This modifier makes it possible to specify which logs are used for messages
48941 about ACL rejections. Its argument is a colon-separated list of words that can
48942 be <quote>main</quote>, <quote>reject</quote>, or <quote>panic</quote>. The default is <literal>main:reject</literal>. The list
48943 may be empty, in which case a rejection is not logged at all. For example, this
48944 ACL fragment writes no logging information when access is denied:
48945 </para>
48946 <literallayout>
48947 <literal>deny </literal>&lt;<emphasis>some conditions</emphasis>&gt;
48948 <literal>     log_reject_target =</literal>
48949 </literallayout>
48950 <para>
48951 This modifier can be used in SMTP and non-SMTP ACLs. It applies to both
48952 permanent and temporary rejections. Its effect lasts for the rest of the
48953 current ACL.
48954 </para>
48955 </listitem></varlistentry>
48956 <varlistentry>
48957 <term><emphasis role="bold">logwrite</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
48958 <listitem>
48959 <para>
48960 <indexterm role="concept">
48961 <primary><option>logwrite</option> ACL modifier</primary>
48962 </indexterm>
48963 <indexterm role="concept">
48964 <primary>logging in ACL</primary>
48965 <secondary>immediate</secondary>
48966 </indexterm>
48967 This modifier writes a message to a log file as soon as it is encountered when
48968 processing an ACL. (Compare <option>log_message</option>, which, except in the case of
48969 <option>warn</option> and <option>discard</option>, is used only if the ACL statement denies
48970 access.) The <option>logwrite</option> modifier can be used to log special incidents in
48971 ACLs. For example:
48972 </para>
48973 <literallayout>
48974 <literal>accept </literal>&lt;<emphasis>some special conditions</emphasis>&gt;
48975 <literal>       control  = freeze</literal>
48976 <literal>       logwrite = froze message because ...</literal>
48977 </literallayout>
48978 <para>
48979 By default, the message is written to the main log. However, it may begin
48980 with a colon, followed by a comma-separated list of log names, and then
48981 another colon, to specify exactly which logs are to be written. For
48982 example:
48983 </para>
48984 <literallayout class="monospaced">
48985 logwrite = :main,reject: text for main and reject logs
48986 logwrite = :panic: text for panic log only
48987 </literallayout>
48988 </listitem></varlistentry>
48989 <varlistentry>
48990 <term><emphasis role="bold">message</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
48991 <listitem>
48992 <para>
48993 <indexterm role="concept">
48994 <primary><option>message</option> ACL modifier</primary>
48995 </indexterm>
48996 This modifier sets up a text string that is expanded and used as a response
48997 message when an ACL statement terminates the ACL with an <quote>accept</quote>, <quote>deny</quote>,
48998 or <quote>defer</quote> response. (In the case of the <option>accept</option> and <option>discard</option> verbs,
48999 there is some complication if <option>endpass</option> is involved; see the description of
49000 <option>accept</option> for details.)
49001 </para>
49002 <para>
49003 The expansion of the message happens at the time Exim decides that the ACL is
49004 to end, not at the time it processes <option>message</option>. If the expansion fails, or
49005 generates an empty string, the modifier is ignored. Here is an example where
49006 <option>message</option> must be specified first, because the ACL ends with a rejection if
49007 the <option>hosts</option> condition fails:
49008 </para>
49009 <literallayout class="monospaced">
49010 require  message = Host not recognized
49011          hosts = 10.0.0.0/8
49012 </literallayout>
49013 <para>
49014 (Once a condition has failed, no further conditions or modifiers are
49015 processed.)
49016 </para>
49017 <para>
49018 <indexterm role="concept">
49019 <primary>SMTP</primary>
49020 <secondary>error codes</secondary>
49021 </indexterm>
49022 <indexterm role="option">
49023 <primary><option>smtp_banner</option></primary>
49024 </indexterm>
49025 For ACLs that are triggered by SMTP commands, the message is returned as part
49026 of the SMTP response. The use of <option>message</option> with <option>accept</option> (or <option>discard</option>)
49027 is meaningful only for SMTP, as no message is returned when a non-SMTP message
49028 is accepted. In the case of the connect ACL, accepting with a message modifier
49029 overrides the value of <option>smtp_banner</option>. For the EHLO/HELO ACL, a customized
49030 accept message may not contain more than one line (otherwise it will be
49031 truncated at the first newline and a panic logged), and it cannot affect the
49032 EHLO options.
49033 </para>
49034 <para>
49035 When SMTP is involved, the message may begin with an overriding response code,
49036 consisting of three digits optionally followed by an <quote>extended response code</quote>
49037 of the form <emphasis>n.n.n</emphasis>, each code being followed by a space. For example:
49038 </para>
49039 <literallayout class="monospaced">
49040 deny  message = 599 1.2.3 Host not welcome
49041       hosts = 192.168.34.0/24
49042 </literallayout>
49043 <para>
49044 The first digit of the supplied response code must be the same as would be sent
49045 by default. A panic occurs if it is not. Exim uses a 550 code when it denies
49046 access, but for the predata ACL, note that the default success code is 354, not
49047 2<emphasis>xx</emphasis>.
49048 </para>
49049 <para>
49050 Notwithstanding the previous paragraph, for the QUIT ACL, unlike the others,
49051 the message modifier cannot override the 221 response code.
49052 </para>
49053 <para>
49054 The text in a <option>message</option> modifier is literal; any quotes are taken as
49055 literals, but because the string is expanded, backslash escapes are processed
49056 anyway. If the message contains newlines, this gives rise to a multi-line SMTP
49057 response.
49058 </para>
49059 <para>
49060 <indexterm role="variable">
49061 <primary><varname>$acl_verify_message</varname></primary>
49062 </indexterm>
49063 If <option>message</option> is used on a statement that verifies an address, the message
49064 specified overrides any message that is generated by the verification process.
49065 However, the original message is available in the variable
49066 <varname>$acl_verify_message</varname>, so you can incorporate it into your message if you
49067 wish. In particular, if you want the text from <option>:fail:</option> items in <command>redirect</command>
49068 routers to be passed back as part of the SMTP response, you should either not
49069 use a <option>message</option> modifier, or make use of <varname>$acl_verify_message</varname>.
49070 </para>
49071 <para>
49072 For compatibility with previous releases of Exim, a <option>message</option> modifier that
49073 is used with a <option>warn</option> verb behaves in a similar way to the <option>add_header</option>
49074 modifier, but this usage is now deprecated. However, <option>message</option> acts only when
49075 all the conditions are true, wherever it appears in an ACL command, whereas
49076 <option>add_header</option> acts as soon as it is encountered. If <option>message</option> is used with
49077 <option>warn</option> in an ACL that is not concerned with receiving a message, it has no
49078 effect.
49079 </para>
49080 </listitem></varlistentry>
49081 <varlistentry>
49082 <term><emphasis role="bold">set</emphasis>&nbsp;&lt;<emphasis>acl_name</emphasis>&gt;&nbsp;=&nbsp;&lt;<emphasis>value</emphasis>&gt;</term>
49083 <listitem>
49084 <para>
49085 <indexterm role="concept">
49086 <primary><option>set</option> ACL modifier</primary>
49087 </indexterm>
49088 This modifier puts a value into one of the ACL variables (see section
49089 <xref linkend="SECTaclvariables"/>).
49090 </para>
49091 </listitem></varlistentry>
49092 </variablelist>
49093 </section>
49094 <section id="SECTcontrols">
49095 <title>Use of the control modifier</title>
49096 <para>
49097 <indexterm role="concept">
49098 <primary><option>control</option> ACL modifier</primary>
49099 </indexterm>
49100 The <option>control</option> modifier supports the following settings:
49101 </para>
49102 <variablelist>
49103 <varlistentry>
49104 <term><emphasis role="bold">control&nbsp;=&nbsp;allow_auth_unadvertised</emphasis></term>
49105 <listitem>
49106 <para>
49107 This modifier allows a client host to use the SMTP AUTH command even when it
49108 has not been advertised in response to EHLO. Furthermore, because there are
49109 apparently some really broken clients that do this, Exim will accept AUTH after
49110 HELO (rather than EHLO) when this control is set. It should be used only if you
49111 really need it, and you should limit its use to those broken clients that do
49112 not work without it. For example:
49113 </para>
49114 <literallayout class="monospaced">
49115 warn hosts   = 192.168.34.25
49116      control = allow_auth_unadvertised
49117 </literallayout>
49118 <para>
49119 Normally, when an Exim server receives an AUTH command, it checks the name of
49120 the authentication mechanism that is given in the command to ensure that it
49121 matches an advertised mechanism. When this control is set, the check that a
49122 mechanism has been advertised is bypassed. Any configured mechanism can be used
49123 by the client. This control is permitted only in the connection and HELO ACLs.
49124 </para>
49125 </listitem></varlistentry>
49126 <varlistentry>
49127 <term><emphasis role="bold">control&nbsp;=&nbsp;caseful_local_part</emphasis></term>
49128 <term><emphasis role="bold">control&nbsp;=&nbsp;caselower_local_part</emphasis></term>
49129 <listitem>
49130 <para>
49131 <indexterm role="concept">
49132 <primary>access control lists (ACLs)</primary>
49133 <secondary>case of local part in</secondary>
49134 </indexterm>
49135 <indexterm role="concept">
49136 <primary>case of local parts</primary>
49137 </indexterm>
49138 <indexterm role="variable">
49139 <primary><varname>$local_part</varname></primary>
49140 </indexterm>
49141 These two controls are permitted only in the ACL specified by <option>acl_smtp_rcpt</option>
49142 (that is, during RCPT processing). By default, the contents of <varname>$local_part</varname>
49143 are lower cased before ACL processing. If <quote>caseful_local_part</quote> is specified,
49144 any uppercase letters in the original local part are restored in <varname>$local_part</varname>
49145 for the rest of the ACL, or until a control that sets <quote>caselower_local_part</quote>
49146 is encountered.
49147 </para>
49148 <para>
49149 These controls affect only the current recipient. Moreover, they apply only to
49150 local part handling that takes place directly in the ACL (for example, as a key
49151 in lookups). If a test to verify the recipient is obeyed, the case-related
49152 handling of the local part during the verification is controlled by the router
49153 configuration (see the <option>caseful_local_part</option> generic router option).
49154 </para>
49155 <para>
49156 This facility could be used, for example, to add a spam score to local parts
49157 containing upper case letters. For example, using <varname>$acl_m4</varname> to accumulate the
49158 spam score:
49159 </para>
49160 <literallayout class="monospaced">
49161 warn  control = caseful_local_part
49162       set acl_m4 = ${eval:\
49163                      $acl_m4 + \
49164                      ${if match{$local_part}{[A-Z]}{1}{0}}\
49165                     }
49166       control = caselower_local_part
49167 </literallayout>
49168 <para>
49169 Notice that we put back the lower cased version afterwards, assuming that
49170 is what is wanted for subsequent tests.
49171 </para>
49172 </listitem></varlistentry>
49173 <varlistentry revisionflag="changed">
49174 <term><emphasis role="bold">control&nbsp;=&nbsp;debug/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
49175 <listitem>
49176 <para revisionflag="changed">
49177 <indexterm role="concept">
49178 <primary>access control lists (ACLs)</primary>
49179 <secondary>enabling debug logging</secondary>
49180 </indexterm>
49181 <indexterm role="concept">
49182 <primary>debugging</primary>
49183 <secondary>enabling from an ACL</secondary>
49184 </indexterm>
49185 This control turns on debug logging, almost as though Exim had been invoked
49186 with <literal>-d</literal>, with the output going to a new logfile, by default called
49187 <emphasis>debuglog</emphasis>.  The filename can be adjusted with the <emphasis>tag</emphasis> option, which
49188 may access any variables already defined.  The logging may be adjusted with
49189 the <emphasis>opts</emphasis> option, which takes the same values as the <literal>-d</literal> command-line
49190 option.  Some examples (which depend on variables that don&#x2019;t exist in all
49191 contexts):
49192 </para>
49193 <literallayout class="monospaced" revisionflag="changed">
49194       control = debug
49195       control = debug/tag=.$sender_host_address
49196       control = debug/opts=+expand+acl
49197       control = debug/tag=.$message_exim_id/opts=+expand
49198 </literallayout>
49199 </listitem></varlistentry>
49200 <varlistentry>
49201 <term><emphasis role="bold">control&nbsp;=&nbsp;enforce_sync</emphasis></term>
49202 <term><emphasis role="bold">control&nbsp;=&nbsp;no_enforce_sync</emphasis></term>
49203 <listitem>
49204 <para>
49205 <indexterm role="concept">
49206 <primary>SMTP</primary>
49207 <secondary>synchronization checking</secondary>
49208 </indexterm>
49209 <indexterm role="concept">
49210 <primary>synchronization checking in SMTP</primary>
49211 </indexterm>
49212 These controls make it possible to be selective about when SMTP synchronization
49213 is enforced. The global option <option>smtp_enforce_sync</option> specifies the initial
49214 state of the switch (it is true by default). See the description of this option
49215 in chapter <xref linkend="CHAPmainconfig"/> for details of SMTP synchronization checking.
49216 </para>
49217 <para>
49218 The effect of these two controls lasts for the remainder of the SMTP
49219 connection. They can appear in any ACL except the one for the non-SMTP
49220 messages. The most straightforward place to put them is in the ACL defined by
49221 <option>acl_smtp_connect</option>, which is run at the start of an incoming SMTP connection,
49222 before the first synchronization check. The expected use is to turn off the
49223 synchronization checks for badly-behaved hosts that you nevertheless need to
49224 work with.
49225 </para>
49226 </listitem></varlistentry>
49227 <varlistentry>
49228 <term><emphasis role="bold">control&nbsp;=&nbsp;fakedefer/</emphasis>&lt;<emphasis>message</emphasis>&gt;</term>
49229 <listitem>
49230 <para>
49231 <indexterm role="concept">
49232 <primary>fake defer</primary>
49233 </indexterm>
49234 <indexterm role="concept">
49235 <primary>defer, fake</primary>
49236 </indexterm>
49237 This control works in exactly the same way as <option>fakereject</option> (described below)
49238 except that it causes an SMTP 450 response after the message data instead of a
49239 550 response. You must take care when using <option>fakedefer</option> because it causes the
49240 messages to be duplicated when the sender retries. Therefore, you should not
49241 use <option>fakedefer</option> if the message is to be delivered normally.
49242 </para>
49243 </listitem></varlistentry>
49244 <varlistentry>
49245 <term><emphasis role="bold">control&nbsp;=&nbsp;fakereject/</emphasis>&lt;<emphasis>message</emphasis>&gt;</term>
49246 <listitem>
49247 <para>
49248 <indexterm role="concept">
49249 <primary>fake rejection</primary>
49250 </indexterm>
49251 <indexterm role="concept">
49252 <primary>rejection, fake</primary>
49253 </indexterm>
49254 This control is permitted only for the MAIL, RCPT, and DATA ACLs, in other
49255 words, only when an SMTP message is being received. If Exim accepts the
49256 message, instead the final 250 response, a 550 rejection message is sent.
49257 However, Exim proceeds to deliver the message as normal. The control applies
49258 only to the current message, not to any subsequent ones that may be received in
49259 the same SMTP connection.
49260 </para>
49261 <para>
49262 The text for the 550 response is taken from the <option>control</option> modifier. If no
49263 message is supplied, the following is used:
49264 </para>
49265 <literallayout class="monospaced">
49266 550-Your message has been rejected but is being
49267 550-kept for evaluation.
49268 550-If it was a legitimate message, it may still be
49269 550 delivered to the target recipient(s).
49270 </literallayout>
49271 <para>
49272 This facility should be used with extreme caution.
49273 </para>
49274 </listitem></varlistentry>
49275 <varlistentry>
49276 <term><emphasis role="bold">control&nbsp;=&nbsp;freeze</emphasis></term>
49277 <listitem>
49278 <para>
49279 <indexterm role="concept">
49280 <primary>frozen messages</primary>
49281 <secondary>forcing in ACL</secondary>
49282 </indexterm>
49283 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs, in
49284 other words, only when a message is being received. If the message is accepted,
49285 it is placed on Exim&#x2019;s queue and frozen. The control applies only to the
49286 current message, not to any subsequent ones that may be received in the same
49287 SMTP connection.
49288 </para>
49289 <para>
49290 This modifier can optionally be followed by <literal>/no_tell</literal>. If the global option
49291 <option>freeze_tell</option> is set, it is ignored for the current message (that is, nobody
49292 is told about the freezing), provided all the <emphasis role="bold">control=freeze</emphasis> modifiers that
49293 are obeyed for the current message have the <literal>/no_tell</literal> option.
49294 </para>
49295 </listitem></varlistentry>
49296 <varlistentry>
49297 <term><emphasis role="bold">control&nbsp;=&nbsp;no_delay_flush</emphasis></term>
49298 <listitem>
49299 <para>
49300 <indexterm role="concept">
49301 <primary>SMTP</primary>
49302 <secondary>output flushing, disabling for delay</secondary>
49303 </indexterm>
49304 Exim normally flushes SMTP output before implementing a delay in an ACL, to
49305 avoid unexpected timeouts in clients when the SMTP PIPELINING extension is in
49306 use. This control, as long as it is encountered before the <option>delay</option> modifier,
49307 disables such output flushing.
49308 </para>
49309 </listitem></varlistentry>
49310 <varlistentry>
49311 <term><emphasis role="bold">control&nbsp;=&nbsp;no_callout_flush</emphasis></term>
49312 <listitem>
49313 <para>
49314 <indexterm role="concept">
49315 <primary>SMTP</primary>
49316 <secondary>output flushing, disabling for callout</secondary>
49317 </indexterm>
49318 Exim normally flushes SMTP output before performing a callout in an ACL, to
49319 avoid unexpected timeouts in clients when the SMTP PIPELINING extension is in
49320 use. This control, as long as it is encountered before the <option>verify</option> condition
49321 that causes the callout, disables such output flushing.
49322 </para>
49323 </listitem></varlistentry>
49324 <varlistentry>
49325 <term><emphasis role="bold">control&nbsp;=&nbsp;no_mbox_unspool</emphasis></term>
49326 <listitem>
49327 <para>
49328 This control is available when Exim is compiled with the content scanning
49329 extension. Content scanning may require a copy of the current message, or parts
49330 of it, to be written in <quote>mbox format</quote> to a spool file, for passing to a virus
49331 or spam scanner. Normally, such copies are deleted when they are no longer
49332 needed. If this control is set, the copies are not deleted. The control applies
49333 only to the current message, not to any subsequent ones that may be received in
49334 the same SMTP connection. It is provided for debugging purposes and is unlikely
49335 to be useful in production.
49336 </para>
49337 </listitem></varlistentry>
49338 <varlistentry>
49339 <term><emphasis role="bold">control&nbsp;=&nbsp;no_multiline_responses</emphasis></term>
49340 <listitem>
49341 <para>
49342 <indexterm role="concept">
49343 <primary>multiline responses, suppressing</primary>
49344 </indexterm>
49345 This control is permitted for any ACL except the one for non-SMTP messages.
49346 It seems that there are broken clients in use that cannot handle multiline
49347 SMTP responses, despite the fact that RFC 821 defined them over 20 years ago.
49348 </para>
49349 <para>
49350 If this control is set, multiline SMTP responses from ACL rejections are
49351 suppressed. One way of doing this would have been to put out these responses as
49352 one long line. However, RFC 2821 specifies a maximum of 512 bytes per response
49353 (<quote>use multiline responses for more</quote> it says &ndash; ha!), and some of the
49354 responses might get close to that. So this facility, which is after all only a
49355 sop to broken clients, is implemented by doing two very easy things:
49356 </para>
49357 <itemizedlist>
49358 <listitem>
49359 <para>
49360 Extra information that is normally output as part of a rejection caused by
49361 sender verification failure is omitted. Only the final line (typically <quote>sender
49362 verification failed</quote>) is sent.
49363 </para>
49364 </listitem>
49365 <listitem>
49366 <para>
49367 If a <option>message</option> modifier supplies a multiline response, only the first
49368 line is output.
49369 </para>
49370 </listitem>
49371 </itemizedlist>
49372 <para>
49373 The setting of the switch can, of course, be made conditional on the
49374 calling host. Its effect lasts until the end of the SMTP connection.
49375 </para>
49376 </listitem></varlistentry>
49377 <varlistentry>
49378 <term><emphasis role="bold">control&nbsp;=&nbsp;no_pipelining</emphasis></term>
49379 <listitem>
49380 <para>
49381 <indexterm role="concept">
49382 <primary>PIPELINING</primary>
49383 <secondary>suppressing advertising</secondary>
49384 </indexterm>
49385 This control turns off the advertising of the PIPELINING extension to SMTP in
49386 the current session. To be useful, it must be obeyed before Exim sends its
49387 response to an EHLO command. Therefore, it should normally appear in an ACL
49388 controlled by <option>acl_smtp_connect</option> or <option>acl_smtp_helo</option>. See also
49389 <option>pipelining_advertise_hosts</option>.
49390 </para>
49391 </listitem></varlistentry>
49392 <varlistentry>
49393 <term><emphasis role="bold">control&nbsp;=&nbsp;queue_only</emphasis></term>
49394 <listitem>
49395 <para>
49396 <indexterm role="option">
49397 <primary><option>queue_only</option></primary>
49398 </indexterm>
49399 <indexterm role="concept">
49400 <primary>queueing incoming messages</primary>
49401 </indexterm>
49402 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs, in
49403 other words, only when a message is being received. If the message is accepted,
49404 it is placed on Exim&#x2019;s queue and left there for delivery by a subsequent queue
49405 runner. No immediate delivery process is started. In other words, it has the
49406 effect as the <option>queue_only</option> global option. However, the control applies only
49407 to the current message, not to any subsequent ones that may be received in the
49408 same SMTP connection.
49409 </para>
49410 </listitem></varlistentry>
49411 <varlistentry>
49412 <term><emphasis role="bold">control&nbsp;=&nbsp;submission/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
49413 <listitem>
49414 <para>
49415 <indexterm role="concept">
49416 <primary>message</primary>
49417 <secondary>submission</secondary>
49418 </indexterm>
49419 <indexterm role="concept">
49420 <primary>submission mode</primary>
49421 </indexterm>
49422 This control is permitted only for the MAIL, RCPT, and start of data ACLs (the
49423 latter is the one defined by <option>acl_smtp_predata</option>). Setting it tells Exim that
49424 the current message is a submission from a local MUA. In this case, Exim
49425 operates in <quote>submission mode</quote>, and applies certain fixups to the message if
49426 necessary. For example, it adds a <emphasis>Date:</emphasis> header line if one is not present.
49427 This control is not permitted in the <option>acl_smtp_data</option> ACL, because that is too
49428 late (the message has already been created).
49429 </para>
49430 <para>
49431 Chapter <xref linkend="CHAPmsgproc"/> describes the processing that Exim applies to
49432 messages. Section <xref linkend="SECTsubmodnon"/> covers the processing that happens in
49433 submission mode; the available options for this control are described there.
49434 The control applies only to the current message, not to any subsequent ones
49435 that may be received in the same SMTP connection.
49436 </para>
49437 </listitem></varlistentry>
49438 <varlistentry>
49439 <term><emphasis role="bold">control&nbsp;=&nbsp;suppress_local_fixups</emphasis></term>
49440 <listitem>
49441 <para>
49442 <indexterm role="concept">
49443 <primary>submission fixups, suppressing</primary>
49444 </indexterm>
49445 This control applies to locally submitted (non TCP/IP) messages, and is the
49446 complement of <literal>control = submission</literal>. It disables the fixups that are
49447 normally applied to locally-submitted messages. Specifically:
49448 </para>
49449 <itemizedlist>
49450 <listitem>
49451 <para>
49452 Any <emphasis>Sender:</emphasis> header line is left alone (in this respect, it is a
49453 dynamic version of <option>local_sender_retain</option>).
49454 </para>
49455 </listitem>
49456 <listitem>
49457 <para>
49458 No <emphasis>Message-ID:</emphasis>, <emphasis>From:</emphasis>, or <emphasis>Date:</emphasis> header lines are added.
49459 </para>
49460 </listitem>
49461 <listitem>
49462 <para>
49463 There is no check that <emphasis>From:</emphasis> corresponds to the actual sender.
49464 </para>
49465 </listitem>
49466 </itemizedlist>
49467 <para>
49468 This control may be useful when a remotely-originated message is accepted,
49469 passed to some scanning program, and then re-submitted for delivery. It can be
49470 used only in the <option>acl_smtp_mail</option>, <option>acl_smtp_rcpt</option>, <option>acl_smtp_predata</option>,
49471 and <option>acl_not_smtp_start</option> ACLs, because it has to be set before the message&#x2019;s
49472 data is read.
49473 </para>
49474 <para>
49475 <emphasis role="bold">Note:</emphasis> This control applies only to the current message, not to any others
49476 that are being submitted at the same time using <option>-bs</option> or <option>-bS</option>.
49477 </para>
49478 </listitem></varlistentry>
49479 </variablelist>
49480 </section>
49481 <section id="SECTsummesfix">
49482 <title>Summary of message fixup control</title>
49483 <para>
49484 All four possibilities for message fixups can be specified:
49485 </para>
49486 <itemizedlist>
49487 <listitem>
49488 <para>
49489 Locally submitted, fixups applied: the default.
49490 </para>
49491 </listitem>
49492 <listitem>
49493 <para>
49494 Locally submitted, no fixups applied: use
49495 <literal>control = suppress_local_fixups</literal>.
49496 </para>
49497 </listitem>
49498 <listitem>
49499 <para>
49500 Remotely submitted, no fixups applied: the default.
49501 </para>
49502 </listitem>
49503 <listitem>
49504 <para>
49505 Remotely submitted, fixups applied: use <literal>control = submission</literal>.
49506 </para>
49507 </listitem>
49508 </itemizedlist>
49509 </section>
49510 <section id="SECTaddheadacl">
49511 <title>Adding header lines in ACLs</title>
49512 <para>
49513 <indexterm role="concept">
49514 <primary>header lines</primary>
49515 <secondary>adding in an ACL</secondary>
49516 </indexterm>
49517 <indexterm role="concept">
49518 <primary>header lines</primary>
49519 <secondary>position of added lines</secondary>
49520 </indexterm>
49521 <indexterm role="concept">
49522 <primary><option>message</option> ACL modifier</primary>
49523 </indexterm>
49524 The <option>add_header</option> modifier can be used to add one or more extra header lines
49525 to an incoming message, as in this example:
49526 </para>
49527 <literallayout class="monospaced">
49528 warn dnslists = sbl.spamhaus.org : \
49529                 dialup.mail-abuse.org
49530      add_header = X-blacklisted-at: $dnslist_domain
49531 </literallayout>
49532 <para>
49533 The <option>add_header</option> modifier is permitted in the MAIL, RCPT, PREDATA, DATA,
49534 MIME, and non-SMTP ACLs (in other words, those that are concerned with
49535 receiving a message). The message must ultimately be accepted for
49536 <option>add_header</option> to have any significant effect. You can use <option>add_header</option> with
49537 any ACL verb, including <option>deny</option> (though this is potentially useful only in a
49538 RCPT ACL).
49539 </para>
49540 <para>
49541 If the data for the <option>add_header</option> modifier contains one or more newlines that
49542 are not followed by a space or a tab, it is assumed to contain multiple header
49543 lines. Each one is checked for valid syntax; <literal>X-ACL-Warn:</literal> is added to the
49544 front of any line that is not a valid header line.
49545 </para>
49546 <para>
49547 Added header lines are accumulated during the MAIL, RCPT, and predata ACLs.
49548 They are added to the message before processing the DATA and MIME ACLs.
49549 However, if an identical header line is requested more than once, only one copy
49550 is actually added to the message. Further header lines may be accumulated
49551 during the DATA and MIME ACLs, after which they are added to the message, again
49552 with duplicates suppressed. Thus, it is possible to add two identical header
49553 lines to an SMTP message, but only if one is added before DATA and one after.
49554 In the case of non-SMTP messages, new headers are accumulated during the
49555 non-SMTP ACLs, and are added to the message after all the ACLs have run. If a
49556 message is rejected after DATA or by the non-SMTP ACL, all added header lines
49557 are included in the entry that is written to the reject log.
49558 </para>
49559 <para>
49560 <indexterm role="concept">
49561 <primary>header lines</primary>
49562 <secondary>added; visibility of</secondary>
49563 </indexterm>
49564 Header lines are not visible in string expansions until they are added to the
49565 message. It follows that header lines defined in the MAIL, RCPT, and predata
49566 ACLs are not visible until the DATA ACL and MIME ACLs are run. Similarly,
49567 header lines that are added by the DATA or MIME ACLs are not visible in those
49568 ACLs. Because of this restriction, you cannot use header lines as a way of
49569 passing data between (for example) the MAIL and RCPT ACLs. If you want to do
49570 this, you can use ACL variables, as described in section
49571 <xref linkend="SECTaclvariables"/>.
49572 </para>
49573 <para>
49574 The <option>add_header</option> modifier acts immediately it is encountered during the
49575 processing of an ACL. Notice the difference between these two cases:
49576 </para>
49577 <literallayout>
49578 <literal>accept add_header = ADDED: some text</literal>
49579 <literal>       </literal>&lt;<emphasis>some condition</emphasis>&gt;
49580
49581 <literal>accept </literal>&lt;<emphasis>some condition</emphasis>&gt;
49582 <literal>       add_header = ADDED: some text</literal>
49583 </literallayout>
49584 <para>
49585 In the first case, the header line is always added, whether or not the
49586 condition is true. In the second case, the header line is added only if the
49587 condition is true. Multiple occurrences of <option>add_header</option> may occur in the same
49588 ACL statement. All those that are encountered before a condition fails are
49589 honoured.
49590 </para>
49591 <para>
49592 <indexterm role="concept">
49593 <primary><option>warn</option> ACL verb</primary>
49594 </indexterm>
49595 For compatibility with previous versions of Exim, a <option>message</option> modifier for a
49596 <option>warn</option> verb acts in the same way as <option>add_header</option>, except that it takes
49597 effect only if all the conditions are true, even if it appears before some of
49598 them. Furthermore, only the last occurrence of <option>message</option> is honoured. This
49599 usage of <option>message</option> is now deprecated. If both <option>add_header</option> and <option>message</option>
49600 are present on a <option>warn</option> verb, both are processed according to their
49601 specifications.
49602 </para>
49603 <para>
49604 By default, new header lines are added to a message at the end of the existing
49605 header lines. However, you can specify that any particular header line should
49606 be added right at the start (before all the <emphasis>Received:</emphasis> lines), immediately
49607 after the first block of <emphasis>Received:</emphasis> lines, or immediately before any line
49608 that is not a <emphasis>Received:</emphasis> or <emphasis>Resent-something:</emphasis> header.
49609 </para>
49610 <para>
49611 This is done by specifying <quote>:at_start:</quote>, <quote>:after_received:</quote>, or
49612 <quote>:at_start_rfc:</quote> (or, for completeness, <quote>:at_end:</quote>) before the text of the
49613 header line, respectively. (Header text cannot start with a colon, as there has
49614 to be a header name first.) For example:
49615 </para>
49616 <literallayout class="monospaced">
49617 warn add_header = \
49618        :after_received:X-My-Header: something or other...
49619 </literallayout>
49620 <para>
49621 If more than one header line is supplied in a single <option>add_header</option> modifier,
49622 each one is treated independently and can therefore be placed differently. If
49623 you add more than one line at the start, or after the Received: block, they end
49624 up in reverse order.
49625 </para>
49626 <para>
49627 <emphasis role="bold">Warning</emphasis>: This facility currently applies only to header lines that are
49628 added in an ACL. It does NOT work for header lines that are added in a
49629 system filter or in a router or transport.
49630 </para>
49631 </section>
49632 <section id="SECTaclconditions">
49633 <title>ACL conditions</title>
49634 <para>
49635 <indexterm role="concept">
49636 <primary>access control lists (ACLs)</primary>
49637 <secondary>conditions; list of</secondary>
49638 </indexterm>
49639 Some of conditions listed in this section are available only when Exim is
49640 compiled with the content-scanning extension. They are included here briefly
49641 for completeness. More detailed descriptions can be found in the discussion on
49642 content scanning in chapter <xref linkend="CHAPexiscan"/>.
49643 </para>
49644 <para>
49645 Not all conditions are relevant in all circumstances. For example, testing
49646 senders and recipients does not make sense in an ACL that is being run as the
49647 result of the arrival of an ETRN command, and checks on message headers can be
49648 done only in the ACLs specified by <option>acl_smtp_data</option> and <option>acl_not_smtp</option>. You
49649 can use the same condition (with different parameters) more than once in the
49650 same ACL statement. This provides a way of specifying an <quote>and</quote> conjunction.
49651 The conditions are as follows:
49652 </para>
49653 <variablelist>
49654 <varlistentry>
49655 <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>
49656 <listitem>
49657 <para>
49658 <indexterm role="concept">
49659 <primary>access control lists (ACLs)</primary>
49660 <secondary>nested</secondary>
49661 </indexterm>
49662 <indexterm role="concept">
49663 <primary>access control lists (ACLs)</primary>
49664 <secondary>indirect</secondary>
49665 </indexterm>
49666 <indexterm role="concept">
49667 <primary><option>acl</option> ACL condition</primary>
49668 </indexterm>
49669 The possible values of the argument are the same as for the
49670 <option>acl_smtp_</option><emphasis>xxx</emphasis> options. The named or inline ACL is run. If it returns
49671 <quote>accept</quote> the condition is true; if it returns <quote>deny</quote> the condition is
49672 false. If it returns <quote>defer</quote>, the current ACL returns <quote>defer</quote> unless the
49673 condition is on a <option>warn</option> verb. In that case, a <quote>defer</quote> return makes the
49674 condition false. This means that further processing of the <option>warn</option> verb
49675 ceases, but processing of the ACL continues.
49676 </para>
49677 <para>
49678 If the nested <option>acl</option> returns <quote>drop</quote> and the outer condition denies access,
49679 the connection is dropped. If it returns <quote>discard</quote>, the verb must be
49680 <option>accept</option> or <option>discard</option>, and the action is taken immediately &ndash; no further
49681 conditions are tested.
49682 </para>
49683 <para>
49684 ACLs may be nested up to 20 deep; the limit exists purely to catch runaway
49685 loops. This condition allows you to use different ACLs in different
49686 circumstances. For example, different ACLs can be used to handle RCPT commands
49687 for different local users or different local domains.
49688 </para>
49689 </listitem></varlistentry>
49690 <varlistentry>
49691 <term><emphasis role="bold">authenticated&nbsp;=&nbsp;</emphasis>&lt;<emphasis>string&nbsp;list</emphasis>&gt;</term>
49692 <listitem>
49693 <para>
49694 <indexterm role="concept">
49695 <primary><option>authenticated</option> ACL condition</primary>
49696 </indexterm>
49697 <indexterm role="concept">
49698 <primary>authentication</primary>
49699 <secondary>ACL checking</secondary>
49700 </indexterm>
49701 <indexterm role="concept">
49702 <primary>access control lists (ACLs)</primary>
49703 <secondary>testing for authentication</secondary>
49704 </indexterm>
49705 If the SMTP connection is not authenticated, the condition is false. Otherwise,
49706 the name of the authenticator is tested against the list. To test for
49707 authentication by any authenticator, you can set
49708 </para>
49709 <literallayout class="monospaced">
49710 authenticated = *
49711 </literallayout>
49712 </listitem></varlistentry>
49713 <varlistentry>
49714 <term><emphasis role="bold">condition&nbsp;=&nbsp;</emphasis>&lt;<emphasis>string</emphasis>&gt;</term>
49715 <listitem>
49716 <para>
49717 <indexterm role="concept">
49718 <primary><option>condition</option> ACL condition</primary>
49719 </indexterm>
49720 <indexterm role="concept">
49721 <primary>customizing</primary>
49722 <secondary>ACL condition</secondary>
49723 </indexterm>
49724 <indexterm role="concept">
49725 <primary>access control lists (ACLs)</primary>
49726 <secondary>customized test</secondary>
49727 </indexterm>
49728 <indexterm role="concept">
49729 <primary>access control lists (ACLs)</primary>
49730 <secondary>testing, customized</secondary>
49731 </indexterm>
49732 This feature allows you to make up custom conditions. If the result of
49733 expanding the string is an empty string, the number zero, or one of the strings
49734 <quote>no</quote> or <quote>false</quote>, the condition is false. If the result is any non-zero
49735 number, or one of the strings <quote>yes</quote> or <quote>true</quote>, the condition is true. For
49736 any other value, some error is assumed to have occurred, and the ACL returns
49737 <quote>defer</quote>. However, if the expansion is forced to fail, the condition is
49738 ignored. The effect is to treat it as true, whether it is positive or
49739 negative.
49740 </para>
49741 </listitem></varlistentry>
49742 <varlistentry>
49743 <term><emphasis role="bold">decode&nbsp;=&nbsp;</emphasis>&lt;<emphasis>location</emphasis>&gt;</term>
49744 <listitem>
49745 <para>
49746 <indexterm role="concept">
49747 <primary><option>decode</option> ACL condition</primary>
49748 </indexterm>
49749 This condition is available only when Exim is compiled with the
49750 content-scanning extension, and it is allowed only in the ACL defined by
49751 <option>acl_smtp_mime</option>. It causes the current MIME part to be decoded into a file.
49752 If all goes well, the condition is true. It is false only if there are
49753 problems such as a syntax error or a memory shortage. For more details, see
49754 chapter <xref linkend="CHAPexiscan"/>.
49755 </para>
49756 </listitem></varlistentry>
49757 <varlistentry>
49758 <term><emphasis role="bold">demime&nbsp;=&nbsp;</emphasis>&lt;<emphasis>extension&nbsp;list</emphasis>&gt;</term>
49759 <listitem>
49760 <para>
49761 <indexterm role="concept">
49762 <primary><option>demime</option> ACL condition</primary>
49763 </indexterm>
49764 This condition is available only when Exim is compiled with the
49765 content-scanning extension. Its use is described in section
49766 <xref linkend="SECTdemimecond"/>.
49767 </para>
49768 </listitem></varlistentry>
49769 <varlistentry>
49770 <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>
49771 <listitem>
49772 <para>
49773 <indexterm role="concept">
49774 <primary><option>dnslists</option> ACL condition</primary>
49775 </indexterm>
49776 <indexterm role="concept">
49777 <primary>DNS list</primary>
49778 <secondary>in ACL</secondary>
49779 </indexterm>
49780 <indexterm role="concept">
49781 <primary>black list (DNS)</primary>
49782 </indexterm>
49783 <indexterm role="concept">
49784 <primary>access control lists (ACLs)</primary>
49785 <secondary>testing a DNS list</secondary>
49786 </indexterm>
49787 This condition checks for entries in DNS black lists. These are also known as
49788 <quote>RBL lists</quote>, after the original Realtime Blackhole List, but note that the
49789 use of the lists at <emphasis>mail-abuse.org</emphasis> now carries a charge. There are too many
49790 different variants of this condition to describe briefly here. See sections
49791 <xref linkend="SECTmorednslists"/>&ndash;<xref linkend="SECTmorednslistslast"/> for details.
49792 </para>
49793 </listitem></varlistentry>
49794 <varlistentry>
49795 <term><emphasis role="bold">domains&nbsp;=&nbsp;</emphasis>&lt;<emphasis>domain&nbsp;list</emphasis>&gt;</term>
49796 <listitem>
49797 <para>
49798 <indexterm role="concept">
49799 <primary><option>domains</option> ACL condition</primary>
49800 </indexterm>
49801 <indexterm role="concept">
49802 <primary>domain</primary>
49803 <secondary>ACL checking</secondary>
49804 </indexterm>
49805 <indexterm role="concept">
49806 <primary>access control lists (ACLs)</primary>
49807 <secondary>testing a recipient domain</secondary>
49808 </indexterm>
49809 <indexterm role="variable">
49810 <primary><varname>$domain_data</varname></primary>
49811 </indexterm>
49812 This condition is relevant only after a RCPT command. It checks that the domain
49813 of the recipient address is in the domain list. If percent-hack processing is
49814 enabled, it is done before this test is done. If the check succeeds with a
49815 lookup, the result of the lookup is placed in <varname>$domain_data</varname> until the next
49816 <option>domains</option> test.
49817 </para>
49818 <para>
49819 <emphasis role="bold">Note carefully</emphasis> (because many people seem to fall foul of this): you cannot
49820 use <option>domains</option> in a DATA ACL.
49821 </para>
49822 </listitem></varlistentry>
49823 <varlistentry>
49824 <term><emphasis role="bold">encrypted&nbsp;=&nbsp;</emphasis>&lt;<emphasis>string&nbsp;list</emphasis>&gt;</term>
49825 <listitem>
49826 <para>
49827 <indexterm role="concept">
49828 <primary><option>encrypted</option> ACL condition</primary>
49829 </indexterm>
49830 <indexterm role="concept">
49831 <primary>encryption</primary>
49832 <secondary>checking in an ACL</secondary>
49833 </indexterm>
49834 <indexterm role="concept">
49835 <primary>access control lists (ACLs)</primary>
49836 <secondary>testing for encryption</secondary>
49837 </indexterm>
49838 If the SMTP connection is not encrypted, the condition is false. Otherwise, the
49839 name of the cipher suite in use is tested against the list. To test for
49840 encryption without testing for any specific cipher suite(s), set
49841 </para>
49842 <literallayout class="monospaced">
49843 encrypted = *
49844 </literallayout>
49845 </listitem></varlistentry>
49846 <varlistentry>
49847 <term><emphasis role="bold">hosts&nbsp;=&nbsp;</emphasis>&lt;<emphasis>&nbsp;host&nbsp;list</emphasis>&gt;</term>
49848 <listitem>
49849 <para>
49850 <indexterm role="concept">
49851 <primary><option>hosts</option> ACL condition</primary>
49852 </indexterm>
49853 <indexterm role="concept">
49854 <primary>host</primary>
49855 <secondary>ACL checking</secondary>
49856 </indexterm>
49857 <indexterm role="concept">
49858 <primary>access control lists (ACLs)</primary>
49859 <secondary>testing the client host</secondary>
49860 </indexterm>
49861 This condition tests that the calling host matches the host list. If you have
49862 name lookups or wildcarded host names and IP addresses in the same host list,
49863 you should normally put the IP addresses first. For example, you could have:
49864 </para>
49865 <literallayout class="monospaced">
49866 accept hosts = 10.9.8.7 : dbm;/etc/friendly/hosts
49867 </literallayout>
49868 <para>
49869 The lookup in this example uses the host name for its key. This is implied by
49870 the lookup type <quote>dbm</quote>. (For a host address lookup you would use <quote>net-dbm</quote>
49871 and it wouldn&#x2019;t matter which way round you had these two items.)
49872 </para>
49873 <para>
49874 The reason for the problem with host names lies in the left-to-right way that
49875 Exim processes lists. It can test IP addresses without doing any DNS lookups,
49876 but when it reaches an item that requires a host name, it fails if it cannot
49877 find a host name to compare with the pattern. If the above list is given in the
49878 opposite order, the <option>accept</option> statement fails for a host whose name cannot be
49879 found, even if its IP address is 10.9.8.7.
49880 </para>
49881 <para>
49882 If you really do want to do the name check first, and still recognize the IP
49883 address even if the name lookup fails, you can rewrite the ACL like this:
49884 </para>
49885 <literallayout class="monospaced">
49886 accept hosts = dbm;/etc/friendly/hosts
49887 accept hosts = 10.9.8.7
49888 </literallayout>
49889 <para>
49890 The default action on failing to find the host name is to assume that the host
49891 is not in the list, so the first <option>accept</option> statement fails. The second
49892 statement can then check the IP address.
49893 </para>
49894 <para>
49895 <indexterm role="variable">
49896 <primary><varname>$host_data</varname></primary>
49897 </indexterm>
49898 If a <option>hosts</option> condition is satisfied by means of a lookup, the result
49899 of the lookup is made available in the <varname>$host_data</varname> variable. This
49900 allows you, for example, to set up a statement like this:
49901 </para>
49902 <literallayout class="monospaced">
49903 deny  hosts = net-lsearch;/some/file
49904 message = $host_data
49905 </literallayout>
49906 <para>
49907 which gives a custom error message for each denied host.
49908 </para>
49909 </listitem></varlistentry>
49910 <varlistentry>
49911 <term><emphasis role="bold">local_parts&nbsp;=&nbsp;</emphasis>&lt;<emphasis>local&nbsp;part&nbsp;list</emphasis>&gt;</term>
49912 <listitem>
49913 <para>
49914 <indexterm role="concept">
49915 <primary><option>local_parts</option> ACL condition</primary>
49916 </indexterm>
49917 <indexterm role="concept">
49918 <primary>local part</primary>
49919 <secondary>ACL checking</secondary>
49920 </indexterm>
49921 <indexterm role="concept">
49922 <primary>access control lists (ACLs)</primary>
49923 <secondary>testing a local part</secondary>
49924 </indexterm>
49925 <indexterm role="variable">
49926 <primary><varname>$local_part_data</varname></primary>
49927 </indexterm>
49928 This condition is relevant only after a RCPT command. It checks that the local
49929 part of the recipient address is in the list. If percent-hack processing is
49930 enabled, it is done before this test. If the check succeeds with a lookup, the
49931 result of the lookup is placed in <varname>$local_part_data</varname>, which remains set until
49932 the next <option>local_parts</option> test.
49933 </para>
49934 </listitem></varlistentry>
49935 <varlistentry>
49936 <term><emphasis role="bold">malware&nbsp;=&nbsp;</emphasis>&lt;<emphasis>option</emphasis>&gt;</term>
49937 <listitem>
49938 <para>
49939 <indexterm role="concept">
49940 <primary><option>malware</option> ACL condition</primary>
49941 </indexterm>
49942 <indexterm role="concept">
49943 <primary>access control lists (ACLs)</primary>
49944 <secondary>virus scanning</secondary>
49945 </indexterm>
49946 <indexterm role="concept">
49947 <primary>access control lists (ACLs)</primary>
49948 <secondary>scanning for viruses</secondary>
49949 </indexterm>
49950 This condition is available only when Exim is compiled with the
49951 content-scanning extension. It causes the incoming message to be scanned for
49952 viruses. For details, see chapter <xref linkend="CHAPexiscan"/>.
49953 </para>
49954 </listitem></varlistentry>
49955 <varlistentry>
49956 <term><emphasis role="bold">mime_regex&nbsp;=&nbsp;</emphasis>&lt;<emphasis>list&nbsp;of&nbsp;regular&nbsp;expressions</emphasis>&gt;</term>
49957 <listitem>
49958 <para>
49959 <indexterm role="concept">
49960 <primary><option>mime_regex</option> ACL condition</primary>
49961 </indexterm>
49962 <indexterm role="concept">
49963 <primary>access control lists (ACLs)</primary>
49964 <secondary>testing by regex matching</secondary>
49965 </indexterm>
49966 This condition is available only when Exim is compiled with the
49967 content-scanning extension, and it is allowed only in the ACL defined by
49968 <option>acl_smtp_mime</option>. It causes the current MIME part to be scanned for a match
49969 with any of the regular expressions. For details, see chapter
49970 <xref linkend="CHAPexiscan"/>.
49971 </para>
49972 </listitem></varlistentry>
49973 <varlistentry>
49974 <term><emphasis role="bold">ratelimit&nbsp;=&nbsp;</emphasis>&lt;<emphasis>parameters</emphasis>&gt;</term>
49975 <listitem>
49976 <para>
49977 <indexterm role="concept">
49978 <primary>rate limiting</primary>
49979 </indexterm>
49980 This condition can be used to limit the rate at which a user or host submits
49981 messages. Details are given in section <xref linkend="SECTratelimiting"/>.
49982 </para>
49983 </listitem></varlistentry>
49984 <varlistentry>
49985 <term><emphasis role="bold">recipients&nbsp;=&nbsp;</emphasis>&lt;<emphasis>address&nbsp;list</emphasis>&gt;</term>
49986 <listitem>
49987 <para>
49988 <indexterm role="concept">
49989 <primary><option>recipients</option> ACL condition</primary>
49990 </indexterm>
49991 <indexterm role="concept">
49992 <primary>recipient</primary>
49993 <secondary>ACL checking</secondary>
49994 </indexterm>
49995 <indexterm role="concept">
49996 <primary>access control lists (ACLs)</primary>
49997 <secondary>testing a recipient</secondary>
49998 </indexterm>
49999 This condition is relevant only after a RCPT command. It checks the entire
50000 recipient address against a list of recipients.
50001 </para>
50002 </listitem></varlistentry>
50003 <varlistentry>
50004 <term><emphasis role="bold">regex&nbsp;=&nbsp;</emphasis>&lt;<emphasis>list&nbsp;of&nbsp;regular&nbsp;expressions</emphasis>&gt;</term>
50005 <listitem>
50006 <para>
50007 <indexterm role="concept">
50008 <primary><option>regex</option> ACL condition</primary>
50009 </indexterm>
50010 <indexterm role="concept">
50011 <primary>access control lists (ACLs)</primary>
50012 <secondary>testing by regex matching</secondary>
50013 </indexterm>
50014 This condition is available only when Exim is compiled with the
50015 content-scanning extension, and is available only in the DATA, MIME, and
50016 non-SMTP ACLs. It causes the incoming message to be scanned for a match with
50017 any of the regular expressions. For details, see chapter <xref linkend="CHAPexiscan"/>.
50018 </para>
50019 </listitem></varlistentry>
50020 <varlistentry>
50021 <term><emphasis role="bold">sender_domains&nbsp;=&nbsp;</emphasis>&lt;<emphasis>domain&nbsp;list</emphasis>&gt;</term>
50022 <listitem>
50023 <para>
50024 <indexterm role="concept">
50025 <primary><option>sender_domains</option> ACL condition</primary>
50026 </indexterm>
50027 <indexterm role="concept">
50028 <primary>sender</primary>
50029 <secondary>ACL checking</secondary>
50030 </indexterm>
50031 <indexterm role="concept">
50032 <primary>access control lists (ACLs)</primary>
50033 <secondary>testing a sender domain</secondary>
50034 </indexterm>
50035 <indexterm role="variable">
50036 <primary><varname>$domain</varname></primary>
50037 </indexterm>
50038 <indexterm role="variable">
50039 <primary><varname>$sender_address_domain</varname></primary>
50040 </indexterm>
50041 This condition tests the domain of the sender of the message against the given
50042 domain list. <emphasis role="bold">Note</emphasis>: The domain of the sender address is in
50043 <varname>$sender_address_domain</varname>. It is <emphasis>not</emphasis> put in <varname>$domain</varname> during the testing
50044 of this condition. This is an exception to the general rule for testing domain
50045 lists. It is done this way so that, if this condition is used in an ACL for a
50046 RCPT command, the recipient&#x2019;s domain (which is in <varname>$domain</varname>) can be used to
50047 influence the sender checking.
50048 </para>
50049 <para>
50050 <emphasis role="bold">Warning</emphasis>: It is a bad idea to use this condition on its own as a control on
50051 relaying, because sender addresses are easily, and commonly, forged.
50052 </para>
50053 </listitem></varlistentry>
50054 <varlistentry>
50055 <term><emphasis role="bold">senders&nbsp;=&nbsp;</emphasis>&lt;<emphasis>address&nbsp;list</emphasis>&gt;</term>
50056 <listitem>
50057 <para>
50058 <indexterm role="concept">
50059 <primary><option>senders</option> ACL condition</primary>
50060 </indexterm>
50061 <indexterm role="concept">
50062 <primary>sender</primary>
50063 <secondary>ACL checking</secondary>
50064 </indexterm>
50065 <indexterm role="concept">
50066 <primary>access control lists (ACLs)</primary>
50067 <secondary>testing a sender</secondary>
50068 </indexterm>
50069 This condition tests the sender of the message against the given list. To test
50070 for a bounce message, which has an empty sender, set
50071 </para>
50072 <literallayout class="monospaced">
50073 senders = :
50074 </literallayout>
50075 <para>
50076 <emphasis role="bold">Warning</emphasis>: It is a bad idea to use this condition on its own as a control on
50077 relaying, because sender addresses are easily, and commonly, forged.
50078 </para>
50079 </listitem></varlistentry>
50080 <varlistentry>
50081 <term><emphasis role="bold">spam&nbsp;=&nbsp;</emphasis>&lt;<emphasis>username</emphasis>&gt;</term>
50082 <listitem>
50083 <para>
50084 <indexterm role="concept">
50085 <primary><option>spam</option> ACL condition</primary>
50086 </indexterm>
50087 <indexterm role="concept">
50088 <primary>access control lists (ACLs)</primary>
50089 <secondary>scanning for spam</secondary>
50090 </indexterm>
50091 This condition is available only when Exim is compiled with the
50092 content-scanning extension. It causes the incoming message to be scanned by
50093 SpamAssassin. For details, see chapter <xref linkend="CHAPexiscan"/>.
50094 </para>
50095 </listitem></varlistentry>
50096 <varlistentry>
50097 <term><emphasis role="bold">verify&nbsp;=&nbsp;certificate</emphasis></term>
50098 <listitem>
50099 <para>
50100 <indexterm role="concept">
50101 <primary><option>verify</option> ACL condition</primary>
50102 </indexterm>
50103 <indexterm role="concept">
50104 <primary>TLS</primary>
50105 <secondary>client certificate verification</secondary>
50106 </indexterm>
50107 <indexterm role="concept">
50108 <primary>certificate</primary>
50109 <secondary>verification of client</secondary>
50110 </indexterm>
50111 <indexterm role="concept">
50112 <primary>access control lists (ACLs)</primary>
50113 <secondary>certificate verification</secondary>
50114 </indexterm>
50115 <indexterm role="concept">
50116 <primary>access control lists (ACLs)</primary>
50117 <secondary>testing a TLS certificate</secondary>
50118 </indexterm>
50119 This condition is true in an SMTP session if the session is encrypted, and a
50120 certificate was received from the client, and the certificate was verified. The
50121 server requests a certificate only if the client matches <option>tls_verify_hosts</option>
50122 or <option>tls_try_verify_hosts</option> (see chapter <xref linkend="CHAPTLS"/>).
50123 </para>
50124 </listitem></varlistentry>
50125 <varlistentry>
50126 <term><emphasis role="bold">verify&nbsp;=&nbsp;csa</emphasis></term>
50127 <listitem>
50128 <para>
50129 <indexterm role="concept">
50130 <primary>CSA verification</primary>
50131 </indexterm>
50132 This condition checks whether the sending host (the client) is authorized to
50133 send email. Details of how this works are given in section
50134 <xref linkend="SECTverifyCSA"/>.
50135 </para>
50136 </listitem></varlistentry>
50137 <varlistentry>
50138 <term><emphasis role="bold">verify&nbsp;=&nbsp;header_sender/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
50139 <listitem>
50140 <para>
50141 <indexterm role="concept">
50142 <primary><option>verify</option> ACL condition</primary>
50143 </indexterm>
50144 <indexterm role="concept">
50145 <primary>access control lists (ACLs)</primary>
50146 <secondary>verifying sender in the header</secondary>
50147 </indexterm>
50148 <indexterm role="concept">
50149 <primary>header lines</primary>
50150 <secondary>verifying the sender in</secondary>
50151 </indexterm>
50152 <indexterm role="concept">
50153 <primary>sender</primary>
50154 <secondary>verifying in header</secondary>
50155 </indexterm>
50156 <indexterm role="concept">
50157 <primary>verifying</primary>
50158 <secondary>sender in header</secondary>
50159 </indexterm>
50160 This condition is relevant only in an ACL that is run after a message has been
50161 received, that is, in an ACL specified by <option>acl_smtp_data</option> or
50162 <option>acl_not_smtp</option>. It checks that there is a verifiable address in at least one
50163 of the <emphasis>Sender:</emphasis>, <emphasis>Reply-To:</emphasis>, or <emphasis>From:</emphasis> header lines. Such an address
50164 is loosely thought of as a <quote>sender</quote> address (hence the name of the test).
50165 However, an address that appears in one of these headers need not be an address
50166 that accepts bounce messages; only sender addresses in envelopes are required
50167 to accept bounces. Therefore, if you use the callout option on this check, you
50168 might want to arrange for a non-empty address in the MAIL command.
50169 </para>
50170 <para>
50171 Details of address verification and the options are given later, starting at
50172 section <xref linkend="SECTaddressverification"/> (callouts are described in section
50173 <xref linkend="SECTcallver"/>). You can combine this condition with the <option>senders</option>
50174 condition to restrict it to bounce messages only:
50175 </para>
50176 <literallayout class="monospaced">
50177 deny    senders = :
50178         message = A valid sender header is required for bounces
50179        !verify  = header_sender
50180 </literallayout>
50181 </listitem></varlistentry>
50182 <varlistentry>
50183 <term><emphasis role="bold">verify&nbsp;=&nbsp;header_syntax</emphasis></term>
50184 <listitem>
50185 <para>
50186 <indexterm role="concept">
50187 <primary><option>verify</option> ACL condition</primary>
50188 </indexterm>
50189 <indexterm role="concept">
50190 <primary>access control lists (ACLs)</primary>
50191 <secondary>verifying header syntax</secondary>
50192 </indexterm>
50193 <indexterm role="concept">
50194 <primary>header lines</primary>
50195 <secondary>verifying syntax</secondary>
50196 </indexterm>
50197 <indexterm role="concept">
50198 <primary>verifying</primary>
50199 <secondary>header syntax</secondary>
50200 </indexterm>
50201 This condition is relevant only in an ACL that is run after a message has been
50202 received, that is, in an ACL specified by <option>acl_smtp_data</option> or
50203 <option>acl_not_smtp</option>. It checks the syntax of all header lines that can contain
50204 lists of addresses (<emphasis>Sender:</emphasis>, <emphasis>From:</emphasis>, <emphasis>Reply-To:</emphasis>, <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>,
50205 and <emphasis>Bcc:</emphasis>). Unqualified addresses (local parts without domains) are
50206 permitted only in locally generated messages and from hosts that match
50207 <option>sender_unqualified_hosts</option> or <option>recipient_unqualified_hosts</option>, as
50208 appropriate.
50209 </para>
50210 <para>
50211 Note that this condition is a syntax check only. However, a common spamming
50212 ploy used to be to send syntactically invalid headers such as
50213 </para>
50214 <literallayout class="monospaced">
50215 To: @
50216 </literallayout>
50217 <para>
50218 and this condition can be used to reject such messages, though they are not as
50219 common as they used to be.
50220 </para>
50221 </listitem></varlistentry>
50222 <varlistentry>
50223 <term><emphasis role="bold">verify&nbsp;=&nbsp;helo</emphasis></term>
50224 <listitem>
50225 <para>
50226 <indexterm role="concept">
50227 <primary><option>verify</option> ACL condition</primary>
50228 </indexterm>
50229 <indexterm role="concept">
50230 <primary>access control lists (ACLs)</primary>
50231 <secondary>verifying HELO/EHLO</secondary>
50232 </indexterm>
50233 <indexterm role="concept">
50234 <primary>HELO</primary>
50235 <secondary>verifying</secondary>
50236 </indexterm>
50237 <indexterm role="concept">
50238 <primary>EHLO</primary>
50239 <secondary>verifying</secondary>
50240 </indexterm>
50241 <indexterm role="concept">
50242 <primary>verifying</primary>
50243 <secondary>EHLO</secondary>
50244 </indexterm>
50245 <indexterm role="concept">
50246 <primary>verifying</primary>
50247 <secondary>HELO</secondary>
50248 </indexterm>
50249 This condition is true if a HELO or EHLO command has been received from the
50250 client host, and its contents have been verified. If there has been no previous
50251 attempt to verify the HELO/EHLO contents, it is carried out when this
50252 condition is encountered. See the description of the <option>helo_verify_hosts</option> and
50253 <option>helo_try_verify_hosts</option> options for details of how to request verification
50254 independently of this condition.
50255 </para>
50256 <para>
50257 For SMTP input that does not come over TCP/IP (the <option>-bs</option> command line
50258 option), this condition is always true.
50259 </para>
50260 </listitem></varlistentry>
50261 <varlistentry>
50262 <term><emphasis role="bold">verify&nbsp;=&nbsp;not_blind</emphasis></term>
50263 <listitem>
50264 <para>
50265 <indexterm role="concept">
50266 <primary>verifying</primary>
50267 <secondary>not blind</secondary>
50268 </indexterm>
50269 <indexterm role="concept">
50270 <primary>bcc recipients, verifying none</primary>
50271 </indexterm>
50272 This condition checks that there are no blind (bcc) recipients in the message.
50273 Every envelope recipient must appear either in a <emphasis>To:</emphasis> header line or in a
50274 <emphasis>Cc:</emphasis> header line for this condition to be true. Local parts are checked
50275 case-sensitively; domains are checked case-insensitively. If <emphasis>Resent-To:</emphasis> or
50276 <emphasis>Resent-Cc:</emphasis> header lines exist, they are also checked. This condition can be
50277 used only in a DATA or non-SMTP ACL.
50278 </para>
50279 <para>
50280 There are, of course, many legitimate messages that make use of blind (bcc)
50281 recipients. This check should not be used on its own for blocking messages.
50282 </para>
50283 </listitem></varlistentry>
50284 <varlistentry>
50285 <term><emphasis role="bold">verify&nbsp;=&nbsp;recipient/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
50286 <listitem>
50287 <para>
50288 <indexterm role="concept">
50289 <primary><option>verify</option> ACL condition</primary>
50290 </indexterm>
50291 <indexterm role="concept">
50292 <primary>access control lists (ACLs)</primary>
50293 <secondary>verifying recipient</secondary>
50294 </indexterm>
50295 <indexterm role="concept">
50296 <primary>recipient</primary>
50297 <secondary>verifying</secondary>
50298 </indexterm>
50299 <indexterm role="concept">
50300 <primary>verifying</primary>
50301 <secondary>recipient</secondary>
50302 </indexterm>
50303 <indexterm role="variable">
50304 <primary><varname>$address_data</varname></primary>
50305 </indexterm>
50306 This condition is relevant only after a RCPT command. It verifies the current
50307 recipient. Details of address verification are given later, starting at section
50308 <xref linkend="SECTaddressverification"/>. After a recipient has been verified, the value
50309 of <varname>$address_data</varname> is the last value that was set while routing the address.
50310 This applies even if the verification fails. When an address that is being
50311 verified is redirected to a single address, verification continues with the new
50312 address, and in that case, the subsequent value of <varname>$address_data</varname> is the
50313 value for the child address.
50314 </para>
50315 </listitem></varlistentry>
50316 <varlistentry>
50317 <term><emphasis role="bold">verify&nbsp;=&nbsp;reverse_host_lookup</emphasis></term>
50318 <listitem>
50319 <para>
50320 <indexterm role="concept">
50321 <primary><option>verify</option> ACL condition</primary>
50322 </indexterm>
50323 <indexterm role="concept">
50324 <primary>access control lists (ACLs)</primary>
50325 <secondary>verifying host reverse lookup</secondary>
50326 </indexterm>
50327 <indexterm role="concept">
50328 <primary>host</primary>
50329 <secondary>verifying reverse lookup</secondary>
50330 </indexterm>
50331 This condition ensures that a verified host name has been looked up from the IP
50332 address of the client host. (This may have happened already if the host name
50333 was needed for checking a host list, or if the host matched <option>host_lookup</option>.)
50334 Verification ensures that the host name obtained from a reverse DNS lookup, or
50335 one of its aliases, does, when it is itself looked up in the DNS, yield the
50336 original IP address.
50337 </para>
50338 <para>
50339 If this condition is used for a locally generated message (that is, when there
50340 is no client host involved), it always succeeds.
50341 </para>
50342 </listitem></varlistentry>
50343 <varlistentry>
50344 <term><emphasis role="bold">verify&nbsp;=&nbsp;sender/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
50345 <listitem>
50346 <para>
50347 <indexterm role="concept">
50348 <primary><option>verify</option> ACL condition</primary>
50349 </indexterm>
50350 <indexterm role="concept">
50351 <primary>access control lists (ACLs)</primary>
50352 <secondary>verifying sender</secondary>
50353 </indexterm>
50354 <indexterm role="concept">
50355 <primary>sender</primary>
50356 <secondary>verifying</secondary>
50357 </indexterm>
50358 <indexterm role="concept">
50359 <primary>verifying</primary>
50360 <secondary>sender</secondary>
50361 </indexterm>
50362 This condition is relevant only after a MAIL or RCPT command, or after a
50363 message has been received (the <option>acl_smtp_data</option> or <option>acl_not_smtp</option> ACLs). If
50364 the message&#x2019;s sender is empty (that is, this is a bounce message), the
50365 condition is true. Otherwise, the sender address is verified.
50366 </para>
50367 <para>
50368 <indexterm role="variable">
50369 <primary><varname>$address_data</varname></primary>
50370 </indexterm>
50371 <indexterm role="variable">
50372 <primary><varname>$sender_address_data</varname></primary>
50373 </indexterm>
50374 If there is data in the <varname>$address_data</varname> variable at the end of routing, its
50375 value is placed in <varname>$sender_address_data</varname> at the end of verification. This
50376 value can be used in subsequent conditions and modifiers in the same ACL
50377 statement. It does not persist after the end of the current statement. If you
50378 want to preserve the value for longer, you can save it in an ACL variable.
50379 </para>
50380 <para>
50381 Details of verification are given later, starting at section
50382 <xref linkend="SECTaddressverification"/>. Exim caches the result of sender verification,
50383 to avoid doing it more than once per message.
50384 </para>
50385 </listitem></varlistentry>
50386 <varlistentry>
50387 <term><emphasis role="bold">verify&nbsp;=&nbsp;sender=</emphasis>&lt;<emphasis>address</emphasis>&gt;<emphasis role="bold">/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
50388 <listitem>
50389 <para>
50390 <indexterm role="concept">
50391 <primary><option>verify</option> ACL condition</primary>
50392 </indexterm>
50393 This is a variation of the previous option, in which a modified address is
50394 verified as a sender.
50395 </para>
50396 </listitem></varlistentry>
50397 </variablelist>
50398 </section>
50399 <section id="SECTmorednslists">
50400 <title>Using DNS lists</title>
50401 <para>
50402 <indexterm role="concept">
50403 <primary>DNS list</primary>
50404 <secondary>in ACL</secondary>
50405 </indexterm>
50406 <indexterm role="concept">
50407 <primary>black list (DNS)</primary>
50408 </indexterm>
50409 <indexterm role="concept">
50410 <primary>access control lists (ACLs)</primary>
50411 <secondary>testing a DNS list</secondary>
50412 </indexterm>
50413 In its simplest form, the <option>dnslists</option> condition tests whether the calling host
50414 is on at least one of a number of DNS lists by looking up the inverted IP
50415 address in one or more DNS domains. (Note that DNS list domains are not mail
50416 domains, so the <literal>+</literal> syntax for named lists doesn&#x2019;t work - it is used for
50417 special options instead.) For example, if the calling host&#x2019;s IP
50418 address is 192.168.62.43, and the ACL statement is
50419 </para>
50420 <literallayout class="monospaced">
50421 deny dnslists = blackholes.mail-abuse.org : \
50422                 dialups.mail-abuse.org
50423 </literallayout>
50424 <para>
50425 the following records are looked up:
50426 </para>
50427 <literallayout class="monospaced">
50428 43.62.168.192.blackholes.mail-abuse.org
50429 43.62.168.192.dialups.mail-abuse.org
50430 </literallayout>
50431 <para>
50432 As soon as Exim finds an existing DNS record, processing of the list stops.
50433 Thus, multiple entries on the list provide an <quote>or</quote> conjunction. If you want
50434 to test that a host is on more than one list (an <quote>and</quote> conjunction), you can
50435 use two separate conditions:
50436 </para>
50437 <literallayout class="monospaced">
50438 deny dnslists = blackholes.mail-abuse.org
50439      dnslists = dialups.mail-abuse.org
50440 </literallayout>
50441 <para>
50442 If a DNS lookup times out or otherwise fails to give a decisive answer, Exim
50443 behaves as if the host does not match the list item, that is, as if the DNS
50444 record does not exist. If there are further items in the DNS list, they are
50445 processed.
50446 </para>
50447 <para>
50448 This is usually the required action when <option>dnslists</option> is used with <option>deny</option>
50449 (which is the most common usage), because it prevents a DNS failure from
50450 blocking mail. However, you can change this behaviour by putting one of the
50451 following special items in the list:
50452 </para>
50453 <literallayout>
50454 <literal>+include_unknown </literal>   behave as if the item is on the list
50455 <literal>+exclude_unknown </literal>   behave as if the item is not on the list (default)
50456 <literal>+defer_unknown   </literal>   give a temporary error
50457 </literallayout>
50458 <para>
50459 <indexterm role="concept">
50460 <primary><literal>+include_unknown</literal></primary>
50461 </indexterm>
50462 <indexterm role="concept">
50463 <primary><literal>+exclude_unknown</literal></primary>
50464 </indexterm>
50465 <indexterm role="concept">
50466 <primary><literal>+defer_unknown</literal></primary>
50467 </indexterm>
50468 Each of these applies to any subsequent items on the list. For example:
50469 </para>
50470 <literallayout class="monospaced">
50471 deny dnslists = +defer_unknown : foo.bar.example
50472 </literallayout>
50473 <para>
50474 Testing the list of domains stops as soon as a match is found. If you want to
50475 warn for one list and block for another, you can use two different statements:
50476 </para>
50477 <literallayout class="monospaced">
50478 deny  dnslists = blackholes.mail-abuse.org
50479 warn  message  = X-Warn: sending host is on dialups list
50480       dnslists = dialups.mail-abuse.org
50481 </literallayout>
50482 <para>
50483 DNS list lookups are cached by Exim for the duration of the SMTP session,
50484 so a lookup based on the IP address is done at most once for any incoming
50485 connection. Exim does not share information between multiple incoming
50486 connections (but your local name server cache should be active).
50487 </para>
50488 </section>
50489 <section id="SECID201">
50490 <title>Specifying the IP address for a DNS list lookup</title>
50491 <para>
50492 <indexterm role="concept">
50493 <primary>DNS list</primary>
50494 <secondary>keyed by explicit IP address</secondary>
50495 </indexterm>
50496 By default, the IP address that is used in a DNS list lookup is the IP address
50497 of the calling host. However, you can specify another IP address by listing it
50498 after the domain name, introduced by a slash. For example:
50499 </para>
50500 <literallayout class="monospaced">
50501 deny dnslists = black.list.tld/192.168.1.2
50502 </literallayout>
50503 <para>
50504 This feature is not very helpful with explicit IP addresses; it is intended for
50505 use with IP addresses that are looked up, for example, the IP addresses of the
50506 MX hosts or nameservers of an email sender address. For an example, see section
50507 <xref linkend="SECTmulkeyfor"/> below.
50508 </para>
50509 </section>
50510 <section id="SECID202">
50511 <title>DNS lists keyed on domain names</title>
50512 <para>
50513 <indexterm role="concept">
50514 <primary>DNS list</primary>
50515 <secondary>keyed by domain name</secondary>
50516 </indexterm>
50517 There are some lists that are keyed on domain names rather than inverted IP
50518 addresses (see for example the <emphasis>domain based zones</emphasis> link at
50519 <emphasis role="bold"><ulink url="http://www.rfc-ignorant.org/">http://www.rfc-ignorant.org/</ulink></emphasis>). No reversing of components is used
50520 with these lists. You can change the name that is looked up in a DNS list by
50521 listing it after the domain name, introduced by a slash. For example,
50522 </para>
50523 <literallayout class="monospaced">
50524 deny  message  = Sender's domain is listed at $dnslist_domain
50525       dnslists = dsn.rfc-ignorant.org/$sender_address_domain
50526 </literallayout>
50527 <para>
50528 This particular example is useful only in ACLs that are obeyed after the
50529 RCPT or DATA commands, when a sender address is available. If (for
50530 example) the message&#x2019;s sender is <emphasis>user@tld.example</emphasis> the name that is looked
50531 up by this example is
50532 </para>
50533 <literallayout class="monospaced">
50534 tld.example.dsn.rfc-ignorant.org
50535 </literallayout>
50536 <para>
50537 A single <option>dnslists</option> condition can contain entries for both names and IP
50538 addresses. For example:
50539 </para>
50540 <literallayout class="monospaced">
50541 deny dnslists = sbl.spamhaus.org : \
50542                 dsn.rfc-ignorant.org/$sender_address_domain
50543 </literallayout>
50544 <para>
50545 The first item checks the sending host&#x2019;s IP address; the second checks a domain
50546 name. The whole condition is true if either of the DNS lookups succeeds.
50547 </para>
50548 </section>
50549 <section id="SECTmulkeyfor">
50550 <title>Multiple explicit keys for a DNS list</title>
50551 <para>
50552 <indexterm role="concept">
50553 <primary>DNS list</primary>
50554 <secondary>multiple keys for</secondary>
50555 </indexterm>
50556 The syntax described above for looking up explicitly-defined values (either
50557 names or IP addresses) in a DNS blacklist is a simplification. After the domain
50558 name for the DNS list, what follows the slash can in fact be a list of items.
50559 As with all lists in Exim, the default separator is a colon. However, because
50560 this is a sublist within the list of DNS blacklist domains, it is necessary
50561 either to double the separators like this:
50562 </para>
50563 <literallayout class="monospaced">
50564 dnslists = black.list.tld/name.1::name.2
50565 </literallayout>
50566 <para>
50567 or to change the separator character, like this:
50568 </para>
50569 <literallayout class="monospaced">
50570 dnslists = black.list.tld/&lt;;name.1;name.2
50571 </literallayout>
50572 <para>
50573 If an item in the list is an IP address, it is inverted before the DNS
50574 blacklist domain is appended. If it is not an IP address, no inversion
50575 occurs. Consider this condition:
50576 </para>
50577 <literallayout class="monospaced">
50578 dnslists = black.list.tld/&lt;;192.168.1.2;a.domain
50579 </literallayout>
50580 <para>
50581 The DNS lookups that occur are:
50582 </para>
50583 <literallayout class="monospaced">
50584 2.1.168.192.black.list.tld
50585 a.domain.black.list.tld
50586 </literallayout>
50587 <para>
50588 Once a DNS record has been found (that matches a specific IP return
50589 address, if specified &ndash; see section <xref linkend="SECTaddmatcon"/>), no further lookups
50590 are done. If there is a temporary DNS error, the rest of the sublist of domains
50591 or IP addresses is tried. A temporary error for the whole dnslists item occurs
50592 only if no other DNS lookup in this sublist succeeds. In other words, a
50593 successful lookup for any of the items in the sublist overrides a temporary
50594 error for a previous item.
50595 </para>
50596 <para>
50597 The ability to supply a list of items after the slash is in some sense just a
50598 syntactic convenience. These two examples have the same effect:
50599 </para>
50600 <literallayout class="monospaced">
50601 dnslists = black.list.tld/a.domain : black.list.tld/b.domain
50602 dnslists = black.list.tld/a.domain::b.domain
50603 </literallayout>
50604 <para>
50605 However, when the data for the list is obtained from a lookup, the second form
50606 is usually much more convenient. Consider this example:
50607 </para>
50608 <literallayout class="monospaced">
50609 deny message  = The mail servers for the domain \
50610                 $sender_address_domain \
50611                 are listed at $dnslist_domain ($dnslist_value); \
50612                 see $dnslist_text.
50613      dnslists = sbl.spamhaus.org/&lt;|${lookup dnsdb {&gt;|a=&lt;|\
50614                                    ${lookup dnsdb {&gt;|mxh=\
50615                                    $sender_address_domain} }} }
50616 </literallayout>
50617 <para>
50618 Note the use of <literal>&gt;|</literal> in the dnsdb lookup to specify the separator for
50619 multiple DNS records. The inner dnsdb lookup produces a list of MX hosts
50620 and the outer dnsdb lookup finds the IP addresses for these hosts. The result
50621 of expanding the condition might be something like this:
50622 </para>
50623 <literallayout class="monospaced">
50624 dnslists = sbl.spahmaus.org/&lt;|192.168.2.3|192.168.5.6|...
50625 </literallayout>
50626 <para>
50627 Thus, this example checks whether or not the IP addresses of the sender
50628 domain&#x2019;s mail servers are on the Spamhaus black list.
50629 </para>
50630 <para>
50631 The key that was used for a successful DNS list lookup is put into the variable
50632 <varname>$dnslist_matched</varname> (see section <xref linkend="SECID204"/>).
50633 </para>
50634 </section>
50635 <section id="SECID203">
50636 <title>Data returned by DNS lists</title>
50637 <para>
50638 <indexterm role="concept">
50639 <primary>DNS list</primary>
50640 <secondary>data returned from</secondary>
50641 </indexterm>
50642 DNS lists are constructed using address records in the DNS. The original RBL
50643 just used the address 127.0.0.1 on the right hand side of each record, but the
50644 RBL+ list and some other lists use a number of values with different meanings.
50645 The values used on the RBL+ list are:
50646 </para>
50647 <literallayout>
50648 127.1.0.1  RBL
50649 127.1.0.2  DUL
50650 127.1.0.3  DUL and RBL
50651 127.1.0.4  RSS
50652 127.1.0.5  RSS and RBL
50653 127.1.0.6  RSS and DUL
50654 127.1.0.7  RSS and DUL and RBL
50655 </literallayout>
50656 <para>
50657 Section <xref linkend="SECTaddmatcon"/> below describes how you can distinguish between
50658 different values. Some DNS lists may return more than one address record;
50659 see section <xref linkend="SECThanmuldnsrec"/> for details of how they are checked.
50660 </para>
50661 </section>
50662 <section id="SECID204">
50663 <title>Variables set from DNS lists</title>
50664 <para>
50665 <indexterm role="concept">
50666 <primary>expansion</primary>
50667 <secondary>variables, set from DNS list</secondary>
50668 </indexterm>
50669 <indexterm role="concept">
50670 <primary>DNS list</primary>
50671 <secondary>variables set from</secondary>
50672 </indexterm>
50673 <indexterm role="variable">
50674 <primary><varname>$dnslist_domain</varname></primary>
50675 </indexterm>
50676 <indexterm role="variable">
50677 <primary><varname>$dnslist_matched</varname></primary>
50678 </indexterm>
50679 <indexterm role="variable">
50680 <primary><varname>$dnslist_text</varname></primary>
50681 </indexterm>
50682 <indexterm role="variable">
50683 <primary><varname>$dnslist_value</varname></primary>
50684 </indexterm>
50685 When an entry is found in a DNS list, the variable <varname>$dnslist_domain</varname> contains
50686 the name of the overall domain that matched (for example,
50687 <literal>spamhaus.example</literal>), <varname>$dnslist_matched</varname> contains the key within that domain
50688 (for example, <literal>192.168.5.3</literal>), and <varname>$dnslist_value</varname> contains the data from
50689 the DNS record. When the key is an IP address, it is not reversed in
50690 <varname>$dnslist_matched</varname> (though it is, of course, in the actual lookup). In simple
50691 cases, for example:
50692 </para>
50693 <literallayout class="monospaced">
50694 deny dnslists = spamhaus.example
50695 </literallayout>
50696 <para>
50697 the key is also available in another variable (in this case,
50698 <varname>$sender_host_address</varname>). In more complicated cases, however, this is not true.
50699 For example, using a data lookup (as described in section <xref linkend="SECTmulkeyfor"/>)
50700 might generate a dnslists lookup like this:
50701 </para>
50702 <literallayout class="monospaced">
50703 deny dnslists = spamhaus.example/&lt;|192.168.1.2|192.168.6.7|...
50704 </literallayout>
50705 <para>
50706 If this condition succeeds, the value in <varname>$dnslist_matched</varname> might be
50707 <literal>192.168.6.7</literal> (for example).
50708 </para>
50709 <para>
50710 If more than one address record is returned by the DNS lookup, all the IP
50711 addresses are included in <varname>$dnslist_value</varname>, separated by commas and spaces.
50712 The variable <varname>$dnslist_text</varname> contains the contents of any associated TXT
50713 record. For lists such as RBL+ the TXT record for a merged entry is often not
50714 very meaningful. See section <xref linkend="SECTmordetinf"/> for a way of obtaining more
50715 information.
50716 </para>
50717 <para>
50718 You can use the DNS list variables in <option>message</option> or <option>log_message</option> modifiers
50719 &ndash; although these appear before the condition in the ACL, they are not
50720 expanded until after it has failed. For example:
50721 </para>
50722 <literallayout class="monospaced">
50723 deny    hosts = !+local_networks
50724         message = $sender_host_address is listed \
50725                   at $dnslist_domain
50726         dnslists = rbl-plus.mail-abuse.example
50727 </literallayout>
50728 </section>
50729 <section id="SECTaddmatcon">
50730 <title>Additional matching conditions for DNS lists</title>
50731 <para>
50732 <indexterm role="concept">
50733 <primary>DNS list</primary>
50734 <secondary>matching specific returned data</secondary>
50735 </indexterm>
50736 You can add an equals sign and an IP address after a <option>dnslists</option> domain name
50737 in order to restrict its action to DNS records with a matching right hand side.
50738 For example,
50739 </para>
50740 <literallayout class="monospaced">
50741 deny dnslists = rblplus.mail-abuse.org=127.0.0.2
50742 </literallayout>
50743 <para>
50744 rejects only those hosts that yield 127.0.0.2. Without this additional data,
50745 any address record is considered to be a match. For the moment, we assume
50746 that the DNS lookup returns just one record. Section <xref linkend="SECThanmuldnsrec"/>
50747 describes how multiple records are handled.
50748 </para>
50749 <para>
50750 More than one IP address may be given for checking, using a comma as a
50751 separator. These are alternatives &ndash; if any one of them matches, the
50752 <option>dnslists</option> condition is true. For example:
50753 </para>
50754 <literallayout class="monospaced">
50755 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
50756 </literallayout>
50757 <para>
50758 If you want to specify a constraining address list and also specify names or IP
50759 addresses to be looked up, the constraining address list must be specified
50760 first. For example:
50761 </para>
50762 <literallayout class="monospaced">
50763 deny dnslists = dsn.rfc-ignorant.org\
50764                 =127.0.0.2/$sender_address_domain
50765 </literallayout>
50766 <para>
50767 If the character <literal>&amp;</literal> is used instead of <literal>=</literal>, the comparison for each
50768 listed IP address is done by a bitwise <quote>and</quote> instead of by an equality test.
50769 In other words, the listed addresses are used as bit masks. The comparison is
50770 true if all the bits in the mask are present in the address that is being
50771 tested. For example:
50772 </para>
50773 <literallayout class="monospaced">
50774 dnslists = a.b.c&amp;0.0.0.3
50775 </literallayout>
50776 <para>
50777 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
50778 want to test whether one bit or another bit is present (as opposed to both
50779 being present), you must use multiple values. For example:
50780 </para>
50781 <literallayout class="monospaced">
50782 dnslists = a.b.c&amp;0.0.0.1,0.0.0.2
50783 </literallayout>
50784 <para>
50785 matches if the final component of the address is an odd number or two times
50786 an odd number.
50787 </para>
50788 </section>
50789 <section id="SECID205">
50790 <title>Negated DNS matching conditions</title>
50791 <para>
50792 You can supply a negative list of IP addresses as part of a <option>dnslists</option>
50793 condition. Whereas
50794 </para>
50795 <literallayout class="monospaced">
50796 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
50797 </literallayout>
50798 <para>
50799 means <quote>deny if the host is in the black list at the domain <emphasis>a.b.c</emphasis> and the
50800 IP address yielded by the list is either 127.0.0.2 or 127.0.0.3</quote>,
50801 </para>
50802 <literallayout class="monospaced">
50803 deny  dnslists = a.b.c!=127.0.0.2,127.0.0.3
50804 </literallayout>
50805 <para>
50806 means <quote>deny if the host is in the black list at the domain <emphasis>a.b.c</emphasis> and the
50807 IP address yielded by the list is not 127.0.0.2 and not 127.0.0.3</quote>. In other
50808 words, the result of the test is inverted if an exclamation mark appears before
50809 the <literal>=</literal> (or the <literal>&amp;</literal>) sign.
50810 </para>
50811 <para>
50812 <emphasis role="bold">Note</emphasis>: This kind of negation is not the same as negation in a domain,
50813 host, or address list (which is why the syntax is different).
50814 </para>
50815 <para>
50816 If you are using just one list, the negation syntax does not gain you much. The
50817 previous example is precisely equivalent to
50818 </para>
50819 <literallayout class="monospaced">
50820 deny  dnslists = a.b.c
50821      !dnslists = a.b.c=127.0.0.2,127.0.0.3
50822 </literallayout>
50823 <para>
50824 However, if you are using multiple lists, the negation syntax is clearer.
50825 Consider this example:
50826 </para>
50827 <literallayout class="monospaced">
50828 deny  dnslists = sbl.spamhaus.org : \
50829                  list.dsbl.org : \
50830                  dnsbl.njabl.org!=127.0.0.3 : \
50831                  relays.ordb.org
50832 </literallayout>
50833 <para>
50834 Using only positive lists, this would have to be:
50835 </para>
50836 <literallayout class="monospaced">
50837 deny  dnslists = sbl.spamhaus.org : \
50838                  list.dsbl.org
50839 deny  dnslists = dnsbl.njabl.org
50840      !dnslists = dnsbl.njabl.org=127.0.0.3
50841 deny  dnslists = relays.ordb.org
50842 </literallayout>
50843 <para>
50844 which is less clear, and harder to maintain.
50845 </para>
50846 </section>
50847 <section id="SECThanmuldnsrec">
50848 <title>Handling multiple DNS records from a DNS list</title>
50849 <para>
50850 A DNS lookup for a <option>dnslists</option> condition may return more than one DNS record,
50851 thereby providing more than one IP address. When an item in a <option>dnslists</option> list
50852 is followed by <literal>=</literal> or <literal>&amp;</literal> and a list of IP addresses, in order to restrict
50853 the match to specific results from the DNS lookup, there are two ways in which
50854 the checking can be handled. For example, consider the condition:
50855 </para>
50856 <literallayout class="monospaced">
50857 dnslists = a.b.c=127.0.0.1
50858 </literallayout>
50859 <para>
50860 What happens if the DNS lookup for the incoming IP address yields both
50861 127.0.0.1 and 127.0.0.2 by means of two separate DNS records? Is the
50862 condition true because at least one given value was found, or is it false
50863 because at least one of the found values was not listed? And how does this
50864 affect negated conditions? Both possibilities are provided for with the help of
50865 additional separators <literal>==</literal> and <literal>=&amp;</literal>.
50866 </para>
50867 <itemizedlist>
50868 <listitem>
50869 <para>
50870 If <literal>=</literal> or <literal>&amp;</literal> is used, the condition is true if any one of the looked up
50871 IP addresses matches one of the listed addresses. For the example above, the
50872 condition is true because 127.0.0.1 matches.
50873 </para>
50874 </listitem>
50875 <listitem>
50876 <para>
50877 If <literal>==</literal> or <literal>=&amp;</literal> is used, the condition is true only if every one of the
50878 looked up IP addresses matches one of the listed addresses. If the condition is
50879 changed to:
50880 </para>
50881 <literallayout class="monospaced">
50882 dnslists = a.b.c==127.0.0.1
50883 </literallayout>
50884 <para>
50885 and the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
50886 false because 127.0.0.2 is not listed. You would need to have:
50887 </para>
50888 <literallayout class="monospaced">
50889 dnslists = a.b.c==127.0.0.1,127.0.0.2
50890 </literallayout>
50891 <para>
50892 for the condition to be true.
50893 </para>
50894 </listitem>
50895 </itemizedlist>
50896 <para>
50897 When <literal>!</literal> is used to negate IP address matching, it inverts the result, giving
50898 the precise opposite of the behaviour above. Thus:
50899 </para>
50900 <itemizedlist>
50901 <listitem>
50902 <para>
50903 If <literal>!=</literal> or <literal>!&amp;</literal> is used, the condition is true if none of the looked up IP
50904 addresses matches one of the listed addresses. Consider:
50905 </para>
50906 <literallayout class="monospaced">
50907 dnslists = a.b.c!&amp;0.0.0.1
50908 </literallayout>
50909 <para>
50910 If the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
50911 false because 127.0.0.1 matches.
50912 </para>
50913 </listitem>
50914 <listitem>
50915 <para>
50916 If <literal>!==</literal> or <literal>!=&amp;</literal> is used, the condition is true there is at least one
50917 looked up IP address that does not match. Consider:
50918 </para>
50919 <literallayout class="monospaced">
50920 dnslists = a.b.c!=&amp;0.0.0.1
50921 </literallayout>
50922 <para>
50923 If the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
50924 true, because 127.0.0.2 does not match. You would need to have:
50925 </para>
50926 <literallayout class="monospaced">
50927 dnslists = a.b.c!=&amp;0.0.0.1,0.0.0.2
50928 </literallayout>
50929 <para>
50930 for the condition to be false.
50931 </para>
50932 </listitem>
50933 </itemizedlist>
50934 <para>
50935 When the DNS lookup yields only a single IP address, there is no difference
50936 between <literal>=</literal> and <literal>==</literal> and between <literal>&amp;</literal> and <literal>=&amp;</literal>.
50937 </para>
50938 </section>
50939 <section id="SECTmordetinf">
50940 <title>Detailed information from merged DNS lists</title>
50941 <para>
50942 <indexterm role="concept">
50943 <primary>DNS list</primary>
50944 <secondary>information from merged</secondary>
50945 </indexterm>
50946 When the facility for restricting the matching IP values in a DNS list is used,
50947 the text from the TXT record that is set in <varname>$dnslist_text</varname> may not reflect
50948 the true reason for rejection. This happens when lists are merged and the IP
50949 address in the A record is used to distinguish them; unfortunately there is
50950 only one TXT record. One way round this is not to use merged lists, but that
50951 can be inefficient because it requires multiple DNS lookups where one would do
50952 in the vast majority of cases when the host of interest is not on any of the
50953 lists.
50954 </para>
50955 <para>
50956 A less inefficient way of solving this problem is available. If
50957 two domain names, comma-separated, are given, the second is used first to
50958 do an initial check, making use of any IP value restrictions that are set.
50959 If there is a match, the first domain is used, without any IP value
50960 restrictions, to get the TXT record. As a byproduct of this, there is also
50961 a check that the IP being tested is indeed on the first list. The first
50962 domain is the one that is put in <varname>$dnslist_domain</varname>. For example:
50963 </para>
50964 <literallayout class="monospaced">
50965 reject message  = \
50966          rejected because $sender_host_address is blacklisted \
50967          at $dnslist_domain\n$dnslist_text
50968        dnslists = \
50969          sbl.spamhaus.org,sbl-xbl.spamhaus.org=127.0.0.2 : \
50970          dul.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.10
50971 </literallayout>
50972 <para>
50973 For the first blacklist item, this starts by doing a lookup in
50974 <emphasis>sbl-xbl.spamhaus.org</emphasis> and testing for a 127.0.0.2 return. If there is a
50975 match, it then looks in <emphasis>sbl.spamhaus.org</emphasis>, without checking the return
50976 value, and as long as something is found, it looks for the corresponding TXT
50977 record. If there is no match in <emphasis>sbl-xbl.spamhaus.org</emphasis>, nothing more is done.
50978 The second blacklist item is processed similarly.
50979 </para>
50980 <para>
50981 If you are interested in more than one merged list, the same list must be
50982 given several times, but because the results of the DNS lookups are cached,
50983 the DNS calls themselves are not repeated. For example:
50984 </para>
50985 <literallayout class="monospaced">
50986 reject dnslists = \
50987          http.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.2 : \
50988          socks.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.3 : \
50989          misc.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.4 : \
50990          dul.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.10
50991 </literallayout>
50992 <para>
50993 In this case there is one lookup in <emphasis>dnsbl.sorbs.net</emphasis>, and if none of the IP
50994 values matches (or if no record is found), this is the only lookup that is
50995 done. Only if there is a match is one of the more specific lists consulted.
50996 </para>
50997 </section>
50998 <section id="SECTmorednslistslast">
50999 <title>DNS lists and IPv6</title>
51000 <para>
51001 <indexterm role="concept">
51002 <primary>IPv6</primary>
51003 <secondary>DNS black lists</secondary>
51004 </indexterm>
51005 <indexterm role="concept">
51006 <primary>DNS list</primary>
51007 <secondary>IPv6 usage</secondary>
51008 </indexterm>
51009 If Exim is asked to do a dnslist lookup for an IPv6 address, it inverts it
51010 nibble by nibble. For example, if the calling host&#x2019;s IP address is
51011 3ffe:ffff:836f:0a00:000a:0800:200a:c031, Exim might look up
51012 </para>
51013 <literallayout class="monospaced">
51014 1.3.0.c.a.0.0.2.0.0.8.0.a.0.0.0.0.0.a.0.f.6.3.8.
51015   f.f.f.f.e.f.f.3.blackholes.mail-abuse.org
51016 </literallayout>
51017 <para>
51018 (split over two lines here to fit on the page). Unfortunately, some of the DNS
51019 lists contain wildcard records, intended for IPv4, that interact badly with
51020 IPv6. For example, the DNS entry
51021 </para>
51022 <literallayout class="monospaced">
51023 *.3.some.list.example.    A    127.0.0.1
51024 </literallayout>
51025 <para>
51026 is probably intended to put the entire 3.0.0.0/8 IPv4 network on the list.
51027 Unfortunately, it also matches the entire 3::/4 IPv6 network.
51028 </para>
51029 <para>
51030 You can exclude IPv6 addresses from DNS lookups by making use of a suitable
51031 <option>condition</option> condition, as in this example:
51032 </para>
51033 <literallayout class="monospaced">
51034 deny   condition = ${if isip4{$sender_host_address}}
51035        dnslists  = some.list.example
51036 </literallayout>
51037 </section>
51038 <section id="SECTratelimiting">
51039 <title>Rate limiting incoming messages</title>
51040 <para>
51041 <indexterm role="concept">
51042 <primary>rate limiting</primary>
51043 <secondary>client sending</secondary>
51044 </indexterm>
51045 <indexterm role="concept">
51046 <primary>limiting client sending rates</primary>
51047 </indexterm>
51048 <indexterm role="option">
51049 <primary><option>smtp_ratelimit_*</option></primary>
51050 </indexterm>
51051 The <option>ratelimit</option> ACL condition can be used to measure and control the rate at
51052 which clients can send email. This is more powerful than the
51053 <option>smtp_ratelimit_*</option> options, because those options control the rate of
51054 commands in a single SMTP session only, whereas the <option>ratelimit</option> condition
51055 works across all connections (concurrent and sequential) from the same client
51056 host. The syntax of the <option>ratelimit</option> condition is:
51057 </para>
51058 <literallayout>
51059 <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;
51060 </literallayout>
51061 <para>
51062 If the average client sending rate is less than <emphasis>m</emphasis> messages per time
51063 period <emphasis>p</emphasis> then the condition is false; otherwise it is true.
51064 </para>
51065 <para>
51066 As a side-effect, the <option>ratelimit</option> condition sets the expansion variable
51067 <varname>$sender_rate</varname> to the client&#x2019;s computed rate, <varname>$sender_rate_limit</varname> to the
51068 configured value of <emphasis>m</emphasis>, and <varname>$sender_rate_period</varname> to the configured value
51069 of <emphasis>p</emphasis>.
51070 </para>
51071 <para>
51072 The parameter <emphasis>p</emphasis> is the smoothing time constant, in the form of an Exim
51073 time interval, for example, <literal>8h</literal> for eight hours. A larger time constant
51074 means that it takes Exim longer to forget a client&#x2019;s past behaviour. The
51075 parameter <emphasis>m</emphasis> is the maximum number of messages that a client is permitted to
51076 send in each time interval. It also specifies the number of messages permitted
51077 in a fast burst. By increasing both <emphasis>m</emphasis> and <emphasis>p</emphasis> but keeping <emphasis>m/p</emphasis>
51078 constant, you can allow a client to send more messages in a burst without
51079 changing its long-term sending rate limit. Conversely, if <emphasis>m</emphasis> and <emphasis>p</emphasis> are
51080 both small, messages must be sent at an even rate.
51081 </para>
51082 <para>
51083 There is a script in <filename>util/ratelimit.pl</filename> which extracts sending rates from
51084 log files, to assist with choosing appropriate settings for <emphasis>m</emphasis> and <emphasis>p</emphasis>
51085 when deploying the <option>ratelimit</option> ACL condition. The script prints usage
51086 instructions when it is run with no arguments.
51087 </para>
51088 <para>
51089 The key is used to look up the data for calculating the client&#x2019;s average
51090 sending rate. This data is stored in Exim&#x2019;s spool directory, alongside the
51091 retry and other hints databases. The default key is <varname>$sender_host_address</varname>,
51092 which means Exim computes the sending rate of each client host IP address.
51093 By changing the key you can change how Exim identifies clients for the purpose
51094 of ratelimiting. For example, to limit the sending rate of each authenticated
51095 user, independent of the computer they are sending from, set the key to
51096 <varname>$authenticated_id</varname>. You must ensure that the lookup key is meaningful; for
51097 example, <varname>$authenticated_id</varname> is only meaningful if the client has
51098 authenticated (which you can check with the <option>authenticated</option> ACL condition).
51099 </para>
51100 <para>
51101 The lookup key does not have to identify clients: If you want to limit the
51102 rate at which a recipient receives messages, you can use the key
51103 <literal>$local_part@$domain</literal> with the <option>per_rcpt</option> option (see below) in a RCPT
51104 ACL.
51105 </para>
51106 <para>
51107 Internally, Exim appends the smoothing constant <emphasis>p</emphasis> and the options onto the
51108 lookup key because they alter the meaning of the stored data. This is not true
51109 for the limit <emphasis>m</emphasis>, so you can alter the configured maximum rate and Exim will
51110 still remember clients&#x2019; past behaviour, but if you alter the other ratelimit
51111 parameters Exim forgets past behaviour.
51112 </para>
51113 <para>
51114 Each <option>ratelimit</option> condition can have up to three options. One option
51115 specifies what Exim measures the rate of, and the second specifies how Exim
51116 handles excessively fast clients. The third option can be <literal>noupdate</literal>, to
51117 disable updating of the ratelimiting database (see section <xref linkend="rearatdat"/>).
51118 The options are separated by a slash, like the other parameters. They may
51119 appear in any order.
51120 </para>
51121 </section>
51122 <section id="ratoptmea">
51123 <title>Ratelimit options for what is being measured</title>
51124 <para>
51125 The <option>per_conn</option> option limits the client&#x2019;s connection rate.
51126 </para>
51127 <para>
51128 The <option>per_mail</option> option limits the client&#x2019;s rate of sending messages. This is
51129 the default if none of the <option>per_*</option> options is specified.
51130 </para>
51131 <para>
51132 The <option>per_byte</option> option limits the sender&#x2019;s email bandwidth. Note that it is
51133 best to use this option in the DATA ACL; if it is used in an earlier ACL it
51134 relies on the SIZE parameter specified by the client in its MAIL command,
51135 which may be inaccurate or completely missing. You can follow the limit <emphasis>m</emphasis>
51136 in the configuration with K, M, or G to specify limits in kilobytes,
51137 megabytes, or gigabytes, respectively.
51138 </para>
51139 <para>
51140 The <option>per_rcpt</option> option causes Exim to limit the rate at which
51141 recipients are accepted. To be effective, it would need to be used in
51142 either the <option>acl_smtp_rcpt</option> or the <option>acl_not_smtp</option> ACL. In the
51143 <option>acl_smtp_rcpt</option> ACL, the number of recipients is incremented by one.
51144 In the case of a locally submitted message in the <option>acl_not_smtp</option> ACL,
51145 the number of recipients is incremented by the <option>$recipients_count</option>
51146 for the entire message. Note that in either case the rate limiting
51147 engine will see a message with many recipients as a large high-speed
51148 burst.
51149 </para>
51150 <para>
51151 The <option>per_cmd</option> option causes Exim to recompute the rate every time the
51152 condition is processed. This can be used to limit the SMTP command rate.
51153 This command is essentially an alias of <option>per_rcpt</option> to make it clear
51154 that the effect is to limit the rate at which individual commands,
51155 rather than recipients, are accepted.
51156 </para>
51157 </section>
51158 <section id="ratophanfas">
51159 <title>Ratelimit options for handling fast clients</title>
51160 <para>
51161 If a client&#x2019;s average rate is greater than the maximum, the rate limiting
51162 engine can react in two possible ways, depending on the presence of the
51163 <option>strict</option> or <option>leaky</option> options. This is independent of the other
51164 counter-measures (such as rejecting the message) that may be specified by the
51165 rest of the ACL. The default mode is leaky, which avoids a sender&#x2019;s
51166 over-aggressive retry rate preventing it from getting any email through.
51167 </para>
51168 <para>
51169 The <option>strict</option> option means that the client&#x2019;s recorded rate is always
51170 updated. The effect of this is that Exim measures the client&#x2019;s average rate
51171 of attempts to send email, which can be much higher than the maximum it is
51172 actually allowed. If the client is over the limit it may be subjected to
51173 counter-measures by the ACL until it slows down below the maximum rate. If
51174 the client stops attempting to send email for the time specified in the <emphasis>p</emphasis>
51175 parameter then its computed rate will decay exponentially to 37% of its peak
51176 value. You can work out the time (the number of smoothing periods) that a
51177 client is subjected to counter-measures after an over-limit burst with this
51178 formula:
51179 </para>
51180 <literallayout class="monospaced">
51181         ln(peakrate/maxrate)
51182 </literallayout>
51183 <para>
51184 The <option>leaky</option> (default) option means that the client&#x2019;s recorded rate is not
51185 updated if it is above the limit. The effect of this is that Exim measures the
51186 client&#x2019;s average rate of successfully sent email, which cannot be greater than
51187 the maximum allowed. If the client is over the limit it may suffer some
51188 counter-measures (as specified in the ACL), but it will still be able to send
51189 email at the configured maximum rate, whatever the rate of its attempts. This
51190 is generally the better choice if you have clients that retry automatically.
51191 </para>
51192 </section>
51193 <section id="useratlim">
51194 <title>Using rate limiting</title>
51195 <para>
51196 Exim&#x2019;s other ACL facilities are used to define what counter-measures are taken
51197 when the rate limit is exceeded. This might be anything from logging a warning
51198 (for example, while measuring existing sending rates in order to define
51199 policy), through time delays to slow down fast senders, up to rejecting the
51200 message. For example:
51201 </para>
51202 <literallayout class="monospaced">
51203 # Log all senders' rates
51204 warn ratelimit = 0 / 1h / strict
51205      log_message = Sender rate $sender_rate / $sender_rate_period
51206
51207 # Slow down fast senders; note the need to truncate $sender_rate
51208 # at the decimal point.
51209 warn ratelimit = 100 / 1h / per_rcpt / strict
51210      delay     = ${eval: ${sg{$sender_rate}{[.].*}{}} - \
51211                    $sender_rate_limit }s
51212
51213 # Keep authenticated users under control
51214 deny authenticated = *
51215      ratelimit = 100 / 1d / strict / $authenticated_id
51216
51217 # System-wide rate limit
51218 defer message = Sorry, too busy. Try again later.
51219      ratelimit = 10 / 1s / $primary_hostname
51220
51221 # Restrict incoming rate from each host, with a default
51222 # set using a macro and special cases looked up in a table.
51223 defer message = Sender rate exceeds $sender_rate_limit \
51224                messages per $sender_rate_period
51225      ratelimit = ${lookup {$sender_host_address} \
51226                    cdb {DB/ratelimits.cdb} \
51227                    {$value} {RATELIMIT} }
51228 </literallayout>
51229 <para>
51230 <emphasis role="bold">Warning</emphasis>: If you have a busy server with a lot of <option>ratelimit</option> tests,
51231 especially with the <option>per_rcpt</option> option, you may suffer from a performance
51232 bottleneck caused by locking on the ratelimit hints database. Apart from
51233 making your ACLs less complicated, you can reduce the problem by using a
51234 RAM disk for Exim&#x2019;s hints directory (usually <filename>/var/spool/exim/db/</filename>). However
51235 this means that Exim will lose its hints data after a reboot (including retry
51236 hints, the callout cache, and ratelimit data).
51237 </para>
51238 </section>
51239 <section id="rearatdat">
51240 <title>Reading ratelimit data without updating</title>
51241 <para>
51242 <indexterm role="concept">
51243 <primary>rate limitint</primary>
51244 <secondary>reading data without updating</secondary>
51245 </indexterm>
51246 If the <option>noupdate</option> option is present on a <option>ratelimit</option> ACL condition, Exim
51247 computes the rate and checks the limit as normal, but it does not update the
51248 saved data. This means that, in relevant ACLs, it is possible to lookup the
51249 existence of a specified (or auto-generated) ratelimit key without incrementing
51250 the ratelimit counter for that key. In order for this to be useful, another ACL
51251 entry must set the rate for the same key (otherwise it will always be zero).
51252 For example:
51253 </para>
51254 <literallayout class="monospaced">
51255 acl_check_connect:
51256   deny ratelimit = 100 / 5m / strict / per_cmd / noupdate
51257        log_message = RATE: $sender_rate/$sender_rate_period \
51258                      (max $sender_rate_limit)
51259 </literallayout>
51260 <literallayout>
51261 <emphasis>... some other logic and tests...</emphasis>
51262 </literallayout>
51263 <literallayout class="monospaced">
51264 acl_check_mail:
51265   warn ratelimit = 100 / 5m / strict / per_cmd
51266        condition = ${if le{$sender_rate}{$sender_rate_limit}}
51267        logwrite  = RATE UPDATE: $sender_rate/$sender_rate_period \
51268                      (max $sender_rate_limit)
51269 </literallayout>
51270 <para>
51271 In this example, the rate is tested and used to deny access (when it is too
51272 high) in the connect ACL, but the actual computation of the remembered rate
51273 happens later, on a per-command basis, in another ACL.
51274 </para>
51275 </section>
51276 <section id="SECTaddressverification">
51277 <title>Address verification</title>
51278 <para>
51279 <indexterm role="concept">
51280 <primary>verifying address</primary>
51281 <secondary>options for</secondary>
51282 </indexterm>
51283 <indexterm role="concept">
51284 <primary>policy control</primary>
51285 <secondary>address verification</secondary>
51286 </indexterm>
51287 Several of the <option>verify</option> conditions described in section
51288 <xref linkend="SECTaclconditions"/> cause addresses to be verified. Section
51289 <xref linkend="SECTsenaddver"/> discusses the reporting of sender verification failures.
51290 The verification conditions can be followed by options that modify the
51291 verification process. The options are separated from the keyword and from each
51292 other by slashes, and some of them contain parameters. For example:
51293 </para>
51294 <literallayout class="monospaced">
51295 verify = sender/callout
51296 verify = recipient/defer_ok/callout=10s,defer_ok
51297 </literallayout>
51298 <para>
51299 The first stage of address verification, which always happens, is to run the
51300 address through the routers, in <quote>verify mode</quote>. Routers can detect the
51301 difference between verification and routing for delivery, and their actions can
51302 be varied by a number of generic options such as <option>verify</option> and <option>verify_only</option>
51303 (see chapter <xref linkend="CHAProutergeneric"/>). If routing fails, verification fails.
51304 The available options are as follows:
51305 </para>
51306 <itemizedlist>
51307 <listitem>
51308 <para>
51309 If the <option>callout</option> option is specified, successful routing to one or more
51310 remote hosts is followed by a <quote>callout</quote> to those hosts as an additional
51311 check. Callouts and their sub-options are discussed in the next section.
51312 </para>
51313 </listitem>
51314 <listitem>
51315 <para>
51316 If there is a defer error while doing verification routing, the ACL
51317 normally returns <quote>defer</quote>. However, if you include <option>defer_ok</option> in the
51318 options, the condition is forced to be true instead. Note that this is a main
51319 verification option as well as a suboption for callouts.
51320 </para>
51321 </listitem>
51322 <listitem>
51323 <para>
51324 The <option>no_details</option> option is covered in section <xref linkend="SECTsenaddver"/>, which
51325 discusses the reporting of sender address verification failures.
51326 </para>
51327 </listitem>
51328 <listitem>
51329 <para>
51330 The <option>success_on_redirect</option> option causes verification always to succeed
51331 immediately after a successful redirection. By default, if a redirection
51332 generates just one address, that address is also verified. See further
51333 discussion in section <xref linkend="SECTredirwhilveri"/>.
51334 </para>
51335 </listitem>
51336 </itemizedlist>
51337 <para>
51338 <indexterm role="concept">
51339 <primary>verifying address</primary>
51340 <secondary>differentiating failures</secondary>
51341 </indexterm>
51342 <indexterm role="variable">
51343 <primary><varname>$recipient_verify_failure</varname></primary>
51344 </indexterm>
51345 <indexterm role="variable">
51346 <primary><varname>$sender_verify_failure</varname></primary>
51347 </indexterm>
51348 <indexterm role="variable">
51349 <primary><varname>$acl_verify_message</varname></primary>
51350 </indexterm>
51351 After an address verification failure, <varname>$acl_verify_message</varname> contains the
51352 error message that is associated with the failure. It can be preserved by
51353 coding like this:
51354 </para>
51355 <literallayout class="monospaced">
51356 warn  !verify = sender
51357        set acl_m0 = $acl_verify_message
51358 </literallayout>
51359 <para>
51360 If you are writing your own custom rejection message or log message when
51361 denying access, you can use this variable to include information about the
51362 verification failure.
51363 </para>
51364 <para>
51365 In addition, <varname>$sender_verify_failure</varname> or <varname>$recipient_verify_failure</varname> (as
51366 appropriate) contains one of the following words:
51367 </para>
51368 <itemizedlist>
51369 <listitem>
51370 <para>
51371 <option>qualify</option>: The address was unqualified (no domain), and the message
51372 was neither local nor came from an exempted host.
51373 </para>
51374 </listitem>
51375 <listitem>
51376 <para>
51377 <option>route</option>: Routing failed.
51378 </para>
51379 </listitem>
51380 <listitem>
51381 <para>
51382 <option>mail</option>: Routing succeeded, and a callout was attempted; rejection
51383 occurred at or before the MAIL command (that is, on initial
51384 connection, HELO, or MAIL).
51385 </para>
51386 </listitem>
51387 <listitem>
51388 <para>
51389 <option>recipient</option>: The RCPT command in a callout was rejected.
51390 </para>
51391 </listitem>
51392 <listitem>
51393 <para>
51394 <option>postmaster</option>: The postmaster check in a callout was rejected.
51395 </para>
51396 </listitem>
51397 </itemizedlist>
51398 <para>
51399 The main use of these variables is expected to be to distinguish between
51400 rejections of MAIL and rejections of RCPT in callouts.
51401 </para>
51402 </section>
51403 <section id="SECTcallver">
51404 <title>Callout verification</title>
51405 <para>
51406 <indexterm role="concept">
51407 <primary>verifying address</primary>
51408 <secondary>by callout</secondary>
51409 </indexterm>
51410 <indexterm role="concept">
51411 <primary>callout</primary>
51412 <secondary>verification</secondary>
51413 </indexterm>
51414 <indexterm role="concept">
51415 <primary>SMTP</primary>
51416 <secondary>callout verification</secondary>
51417 </indexterm>
51418 For non-local addresses, routing verifies the domain, but is unable to do any
51419 checking of the local part. There are situations where some means of verifying
51420 the local part is desirable. One way this can be done is to make an SMTP
51421 <emphasis>callback</emphasis> to a delivery host for the sender address or a <emphasis>callforward</emphasis> to
51422 a subsequent host for a recipient address, to see if the host accepts the
51423 address. We use the term <emphasis>callout</emphasis> to cover both cases. Note that for a
51424 sender address, the callback is not to the client host that is trying to
51425 deliver the message, but to one of the hosts that accepts incoming mail for the
51426 sender&#x2019;s domain.
51427 </para>
51428 <para>
51429 Exim does not do callouts by default. If you want them to happen, you must
51430 request them by setting appropriate options on the <option>verify</option> condition, as
51431 described below. This facility should be used with care, because it can add a
51432 lot of resource usage to the cost of verifying an address. However, Exim does
51433 cache the results of callouts, which helps to reduce the cost. Details of
51434 caching are in section <xref linkend="SECTcallvercache"/>.
51435 </para>
51436 <para>
51437 Recipient callouts are usually used only between hosts that are controlled by
51438 the same administration. For example, a corporate gateway host could use
51439 callouts to check for valid recipients on an internal mailserver. A successful
51440 callout does not guarantee that a real delivery to the address would succeed;
51441 on the other hand, a failing callout does guarantee that a delivery would fail.
51442 </para>
51443 <para>
51444 If the <option>callout</option> option is present on a condition that verifies an address, a
51445 second stage of verification occurs if the address is successfully routed to
51446 one or more remote hosts. The usual case is routing by a <command>dnslookup</command> or a
51447 <command>manualroute</command> router, where the router specifies the hosts. However, if a
51448 router that does not set up hosts routes to an <command>smtp</command> transport with a
51449 <option>hosts</option> setting, the transport&#x2019;s hosts are used. If an <command>smtp</command> transport has
51450 <option>hosts_override</option> set, its hosts are always used, whether or not the router
51451 supplies a host list.
51452 </para>
51453 <para>
51454 The port that is used is taken from the transport, if it is specified and is a
51455 remote transport. (For routers that do verification only, no transport need be
51456 specified.) Otherwise, the default SMTP port is used. If a remote transport
51457 specifies an outgoing interface, this is used; otherwise the interface is not
51458 specified. Likewise, the text that is used for the HELO command is taken from
51459 the transport&#x2019;s <option>helo_data</option> option; if there is no transport, the value of
51460 <varname>$smtp_active_hostname</varname> is used.
51461 </para>
51462 <para>
51463 For a sender callout check, Exim makes SMTP connections to the remote hosts, to
51464 test whether a bounce message could be delivered to the sender address. The
51465 following SMTP commands are sent:
51466 </para>
51467 <literallayout>
51468 <literal>HELO </literal>&lt;<emphasis>local host name</emphasis>&gt;
51469 <literal>MAIL FROM:&lt;&gt;</literal>
51470 <literal>RCPT TO:</literal>&lt;<emphasis>the address to be tested</emphasis>&gt;
51471 <literal>QUIT</literal>
51472 </literallayout>
51473 <para>
51474 LHLO is used instead of HELO if the transport&#x2019;s <option>protocol</option> option is
51475 set to <quote>lmtp</quote>.
51476 </para>
51477 <para>
51478 A recipient callout check is similar. By default, it also uses an empty address
51479 for the sender. This default is chosen because most hosts do not make use of
51480 the sender address when verifying a recipient. Using the same address means
51481 that a single cache entry can be used for each recipient. Some sites, however,
51482 do make use of the sender address when verifying. These are catered for by the
51483 <option>use_sender</option> and <option>use_postmaster</option> options, described in the next section.
51484 </para>
51485 <para>
51486 If the response to the RCPT command is a 2<emphasis>xx</emphasis> code, the verification
51487 succeeds. If it is 5<emphasis>xx</emphasis>, the verification fails. For any other condition,
51488 Exim tries the next host, if any. If there is a problem with all the remote
51489 hosts, the ACL yields <quote>defer</quote>, unless the <option>defer_ok</option> parameter of the
51490 <option>callout</option> option is given, in which case the condition is forced to succeed.
51491 </para>
51492 <para>
51493 <indexterm role="concept">
51494 <primary>SMTP</primary>
51495 <secondary>output flushing, disabling for callout</secondary>
51496 </indexterm>
51497 A callout may take a little time. For this reason, Exim normally flushes SMTP
51498 output before performing a callout in an ACL, to avoid unexpected timeouts in
51499 clients when the SMTP PIPELINING extension is in use. The flushing can be
51500 disabled by using a <option>control</option> modifier to set <option>no_callout_flush</option>.
51501 </para>
51502 </section>
51503 <section id="CALLaddparcall">
51504 <title>Additional parameters for callouts</title>
51505 <para>
51506 <indexterm role="concept">
51507 <primary>callout</primary>
51508 <secondary>additional parameters for</secondary>
51509 </indexterm>
51510 The <option>callout</option> option can be followed by an equals sign and a number of
51511 optional parameters, separated by commas. For example:
51512 </para>
51513 <literallayout class="monospaced">
51514 verify = recipient/callout=10s,defer_ok
51515 </literallayout>
51516 <para>
51517 The old syntax, which had <option>callout_defer_ok</option> and <option>check_postmaster</option> as
51518 separate verify options, is retained for backwards compatibility, but is now
51519 deprecated. The additional parameters for <option>callout</option> are as follows:
51520 </para>
51521 <variablelist>
51522 <varlistentry>
51523 <term>&lt;<emphasis>a&nbsp;time&nbsp;interval</emphasis>&gt;</term>
51524 <listitem>
51525 <para>
51526 <indexterm role="concept">
51527 <primary>callout</primary>
51528 <secondary>timeout, specifying</secondary>
51529 </indexterm>
51530 This specifies the timeout that applies for the callout attempt to each host.
51531 For example:
51532 </para>
51533 <literallayout class="monospaced">
51534 verify = sender/callout=5s
51535 </literallayout>
51536 <para>
51537 The default is 30 seconds. The timeout is used for each response from the
51538 remote host. It is also used for the initial connection, unless overridden by
51539 the <option>connect</option> parameter.
51540 </para>
51541 </listitem></varlistentry>
51542 <varlistentry>
51543 <term><emphasis role="bold">connect&nbsp;=&nbsp;</emphasis>&lt;<emphasis>time&nbsp;interval</emphasis>&gt;</term>
51544 <listitem>
51545 <para>
51546 <indexterm role="concept">
51547 <primary>callout</primary>
51548 <secondary>connection timeout, specifying</secondary>
51549 </indexterm>
51550 This parameter makes it possible to set a different (usually smaller) timeout
51551 for making the SMTP connection. For example:
51552 </para>
51553 <literallayout class="monospaced">
51554 verify = sender/callout=5s,connect=1s
51555 </literallayout>
51556 <para>
51557 If not specified, this timeout defaults to the general timeout value.
51558 </para>
51559 </listitem></varlistentry>
51560 <varlistentry>
51561 <term><emphasis role="bold">defer_ok</emphasis></term>
51562 <listitem>
51563 <para>
51564 <indexterm role="concept">
51565 <primary>callout</primary>
51566 <secondary>defer, action on</secondary>
51567 </indexterm>
51568 When this parameter is present, failure to contact any host, or any other kind
51569 of temporary error, is treated as success by the ACL. However, the cache is not
51570 updated in this circumstance.
51571 </para>
51572 </listitem></varlistentry>
51573 <varlistentry>
51574 <term><emphasis role="bold">fullpostmaster</emphasis></term>
51575 <listitem>
51576 <para>
51577 <indexterm role="concept">
51578 <primary>callout</primary>
51579 <secondary>full postmaster check</secondary>
51580 </indexterm>
51581 This operates like the <option>postmaster</option> option (see below), but if the check for
51582 <emphasis>postmaster@domain</emphasis> fails, it tries just <emphasis>postmaster</emphasis>, without a domain, in
51583 accordance with the specification in RFC 2821. The RFC states that the
51584 unqualified address <emphasis>postmaster</emphasis> should be accepted.
51585 </para>
51586 </listitem></varlistentry>
51587 <varlistentry>
51588 <term><emphasis role="bold">mailfrom&nbsp;=&nbsp;</emphasis>&lt;<emphasis>email&nbsp;address</emphasis>&gt;</term>
51589 <listitem>
51590 <para>
51591 <indexterm role="concept">
51592 <primary>callout</primary>
51593 <secondary>sender when verifying header</secondary>
51594 </indexterm>
51595 When verifying addresses in header lines using the <option>header_sender</option>
51596 verification option, Exim behaves by default as if the addresses are envelope
51597 sender addresses from a message. Callout verification therefore tests to see
51598 whether a bounce message could be delivered, by using an empty address in the
51599 MAIL command. However, it is arguable that these addresses might never be used
51600 as envelope senders, and could therefore justifiably reject bounce messages
51601 (empty senders). The <option>mailfrom</option> callout parameter allows you to specify what
51602 address to use in the MAIL command. For example:
51603 </para>
51604 <literallayout class="monospaced">
51605 require  verify = header_sender/callout=mailfrom=abcd@x.y.z
51606 </literallayout>
51607 <para>
51608 This parameter is available only for the <option>header_sender</option> verification option.
51609 </para>
51610 </listitem></varlistentry>
51611 <varlistentry>
51612 <term><emphasis role="bold">maxwait&nbsp;=&nbsp;</emphasis>&lt;<emphasis>time&nbsp;interval</emphasis>&gt;</term>
51613 <listitem>
51614 <para>
51615 <indexterm role="concept">
51616 <primary>callout</primary>
51617 <secondary>overall timeout, specifying</secondary>
51618 </indexterm>
51619 This parameter sets an overall timeout for performing a callout verification.
51620 For example:
51621 </para>
51622 <literallayout class="monospaced">
51623 verify = sender/callout=5s,maxwait=30s
51624 </literallayout>
51625 <para>
51626 This timeout defaults to four times the callout timeout for individual SMTP
51627 commands. The overall timeout applies when there is more than one host that can
51628 be tried. The timeout is checked before trying the next host. This prevents
51629 very long delays if there are a large number of hosts and all are timing out
51630 (for example, when network connections are timing out).
51631 </para>
51632 </listitem></varlistentry>
51633 <varlistentry>
51634 <term><emphasis role="bold">no_cache</emphasis></term>
51635 <listitem>
51636 <para>
51637 <indexterm role="concept">
51638 <primary>callout</primary>
51639 <secondary>cache, suppressing</secondary>
51640 </indexterm>
51641 <indexterm role="concept">
51642 <primary>caching callout, suppressing</primary>
51643 </indexterm>
51644 When this parameter is given, the callout cache is neither read nor updated.
51645 </para>
51646 </listitem></varlistentry>
51647 <varlistentry>
51648 <term><emphasis role="bold">postmaster</emphasis></term>
51649 <listitem>
51650 <para>
51651 <indexterm role="concept">
51652 <primary>callout</primary>
51653 <secondary>postmaster; checking</secondary>
51654 </indexterm>
51655 When this parameter is set, a successful callout check is followed by a similar
51656 check for the local part <emphasis>postmaster</emphasis> at the same domain. If this address is
51657 rejected, the callout fails (but see <option>fullpostmaster</option> above). The result of
51658 the postmaster check is recorded in a cache record; if it is a failure, this is
51659 used to fail subsequent callouts for the domain without a connection being
51660 made, until the cache record expires.
51661 </para>
51662 </listitem></varlistentry>
51663 <varlistentry>
51664 <term><emphasis role="bold">postmaster_mailfrom&nbsp;=&nbsp;</emphasis>&lt;<emphasis>email&nbsp;address</emphasis>&gt;</term>
51665 <listitem>
51666 <para>
51667 The postmaster check uses an empty sender in the MAIL command by default.
51668 You can use this parameter to do a postmaster check using a different address.
51669 For example:
51670 </para>
51671 <literallayout class="monospaced">
51672 require  verify = sender/callout=postmaster_mailfrom=abc@x.y.z
51673 </literallayout>
51674 <para>
51675 If both <option>postmaster</option> and <option>postmaster_mailfrom</option> are present, the rightmost
51676 one overrides. The <option>postmaster</option> parameter is equivalent to this example:
51677 </para>
51678 <literallayout class="monospaced">
51679 require  verify = sender/callout=postmaster_mailfrom=
51680 </literallayout>
51681 <para>
51682 <emphasis role="bold">Warning</emphasis>: The caching arrangements for postmaster checking do not take
51683 account of the sender address. It is assumed that either the empty address or
51684 a fixed non-empty address will be used. All that Exim remembers is that the
51685 postmaster check for the domain succeeded or failed.
51686 </para>
51687 </listitem></varlistentry>
51688 <varlistentry>
51689 <term><emphasis role="bold">random</emphasis></term>
51690 <listitem>
51691 <para>
51692 <indexterm role="concept">
51693 <primary>callout</primary>
51694 <secondary><quote>random</quote> check</secondary>
51695 </indexterm>
51696 When this parameter is set, before doing the normal callout check, Exim does a
51697 check for a <quote>random</quote> local part at the same domain. The local part is not
51698 really random &ndash; it is defined by the expansion of the option
51699 <option>callout_random_local_part</option>, which defaults to
51700 </para>
51701 <literallayout class="monospaced">
51702 $primary_host_name-$tod_epoch-testing
51703 </literallayout>
51704 <para>
51705 The idea here is to try to determine whether the remote host accepts all local
51706 parts without checking. If it does, there is no point in doing callouts for
51707 specific local parts. If the <quote>random</quote> check succeeds, the result is saved in
51708 a cache record, and used to force the current and subsequent callout checks to
51709 succeed without a connection being made, until the cache record expires.
51710 </para>
51711 </listitem></varlistentry>
51712 <varlistentry>
51713 <term><emphasis role="bold">use_postmaster</emphasis></term>
51714 <listitem>
51715 <para>
51716 <indexterm role="concept">
51717 <primary>callout</primary>
51718 <secondary>sender for recipient check</secondary>
51719 </indexterm>
51720 This parameter applies to recipient callouts only. For example:
51721 </para>
51722 <literallayout class="monospaced">
51723 deny  !verify = recipient/callout=use_postmaster
51724 </literallayout>
51725 <para>
51726 <indexterm role="variable">
51727 <primary><varname>$qualify_domain</varname></primary>
51728 </indexterm>
51729 It causes a non-empty postmaster address to be used in the MAIL command when
51730 performing the callout for the recipient, and also for a <quote>random</quote> check if
51731 that is configured. The local part of the address is <literal>postmaster</literal> and the
51732 domain is the contents of <varname>$qualify_domain</varname>.
51733 </para>
51734 </listitem></varlistentry>
51735 <varlistentry>
51736 <term><emphasis role="bold">use_sender</emphasis></term>
51737 <listitem>
51738 <para>
51739 This option applies to recipient callouts only. For example:
51740 </para>
51741 <literallayout class="monospaced">
51742 require  verify = recipient/callout=use_sender
51743 </literallayout>
51744 <para>
51745 It causes the message&#x2019;s actual sender address to be used in the MAIL
51746 command when performing the callout, instead of an empty address. There is no
51747 need to use this option unless you know that the called hosts make use of the
51748 sender when checking recipients. If used indiscriminately, it reduces the
51749 usefulness of callout caching.
51750 </para>
51751 </listitem></varlistentry>
51752 </variablelist>
51753 <para>
51754 If you use any of the parameters that set a non-empty sender for the MAIL
51755 command (<option>mailfrom</option>, <option>postmaster_mailfrom</option>, <option>use_postmaster</option>, or
51756 <option>use_sender</option>), you should think about possible loops. Recipient checking is
51757 usually done between two hosts that are under the same management, and the host
51758 that receives the callouts is not normally configured to do callouts itself.
51759 Therefore, it is normally safe to use <option>use_postmaster</option> or <option>use_sender</option> in
51760 these circumstances.
51761 </para>
51762 <para>
51763 However, if you use a non-empty sender address for a callout to an arbitrary
51764 host, there is the likelihood that the remote host will itself initiate a
51765 callout check back to your host. As it is checking what appears to be a message
51766 sender, it is likely to use an empty address in MAIL, thus avoiding a
51767 callout loop. However, to be on the safe side it would be best to set up your
51768 own ACLs so that they do not do sender verification checks when the recipient
51769 is the address you use for header sender or postmaster callout checking.
51770 </para>
51771 <para>
51772 Another issue to think about when using non-empty senders for callouts is
51773 caching. When you set <option>mailfrom</option> or <option>use_sender</option>, the cache record is keyed
51774 by the sender/recipient combination; thus, for any given recipient, many more
51775 actual callouts are performed than when an empty sender or postmaster is used.
51776 </para>
51777 </section>
51778 <section id="SECTcallvercache">
51779 <title>Callout caching</title>
51780 <para>
51781 <indexterm role="concept">
51782 <primary>hints database</primary>
51783 <secondary>callout cache</secondary>
51784 </indexterm>
51785 <indexterm role="concept">
51786 <primary>callout</primary>
51787 <secondary>cache, description of</secondary>
51788 </indexterm>
51789 <indexterm role="concept">
51790 <primary>caching</primary>
51791 <secondary>callout</secondary>
51792 </indexterm>
51793 Exim caches the results of callouts in order to reduce the amount of resources
51794 used, unless you specify the <option>no_cache</option> parameter with the <option>callout</option>
51795 option. A hints database called <quote>callout</quote> is used for the cache. Two
51796 different record types are used: one records the result of a callout check for
51797 a specific address, and the other records information that applies to the
51798 entire domain (for example, that it accepts the local part <emphasis>postmaster</emphasis>).
51799 </para>
51800 <para>
51801 When an original callout fails, a detailed SMTP error message is given about
51802 the failure. However, for subsequent failures use the cache data, this message
51803 is not available.
51804 </para>
51805 <para>
51806 The expiry times for negative and positive address cache records are
51807 independent, and can be set by the global options <option>callout_negative_expire</option>
51808 (default 2h) and <option>callout_positive_expire</option> (default 24h), respectively.
51809 </para>
51810 <para>
51811 If a host gives a negative response to an SMTP connection, or rejects any
51812 commands up to and including
51813 </para>
51814 <literallayout class="monospaced">
51815 MAIL FROM:&lt;&gt;
51816 </literallayout>
51817 <para>
51818 (but not including the MAIL command with a non-empty address),
51819 any callout attempt is bound to fail. Exim remembers such failures in a
51820 domain cache record, which it uses to fail callouts for the domain without
51821 making new connections, until the domain record times out. There are two
51822 separate expiry times for domain cache records:
51823 <option>callout_domain_negative_expire</option> (default 3h) and
51824 <option>callout_domain_positive_expire</option> (default 7d).
51825 </para>
51826 <para>
51827 Domain records expire when the negative expiry time is reached if callouts
51828 cannot be made for the domain, or if the postmaster check failed.
51829 Otherwise, they expire when the positive expiry time is reached. This
51830 ensures that, for example, a host that stops accepting <quote>random</quote> local parts
51831 will eventually be noticed.
51832 </para>
51833 <para>
51834 The callout caching mechanism is based on the domain of the address that is
51835 being tested. If the domain routes to several hosts, it is assumed that their
51836 behaviour will be the same.
51837 </para>
51838 </section>
51839 <section id="SECTsenaddver">
51840 <title>Sender address verification reporting</title>
51841 <para>
51842 <indexterm role="concept">
51843 <primary>verifying</primary>
51844 <secondary>suppressing error details</secondary>
51845 </indexterm>
51846 See section <xref linkend="SECTaddressverification"/> for a general discussion of
51847 verification. When sender verification fails in an ACL, the details of the
51848 failure are given as additional output lines before the 550 response to the
51849 relevant SMTP command (RCPT or DATA). For example, if sender callout is in use,
51850 you might see:
51851 </para>
51852 <literallayout class="monospaced">
51853 MAIL FROM:&lt;xyz@abc.example&gt;
51854 250 OK
51855 RCPT TO:&lt;pqr@def.example&gt;
51856 550-Verification failed for &lt;xyz@abc.example&gt;
51857 550-Called:   192.168.34.43
51858 550-Sent:     RCPT TO:&lt;xyz@abc.example&gt;
51859 550-Response: 550 Unknown local part xyz in &lt;xyz@abc.example&gt;
51860 550 Sender verification failed
51861 </literallayout>
51862 <para>
51863 If more than one RCPT command fails in the same way, the details are given
51864 only for the first of them. However, some administrators do not want to send
51865 out this much information. You can suppress the details by adding
51866 <literal>/no_details</literal> to the ACL statement that requests sender verification. For
51867 example:
51868 </para>
51869 <literallayout class="monospaced">
51870 verify = sender/no_details
51871 </literallayout>
51872 </section>
51873 <section id="SECTredirwhilveri">
51874 <title>Redirection while verifying</title>
51875 <para>
51876 <indexterm role="concept">
51877 <primary>verifying</primary>
51878 <secondary>redirection while</secondary>
51879 </indexterm>
51880 <indexterm role="concept">
51881 <primary>address redirection</primary>
51882 <secondary>while verifying</secondary>
51883 </indexterm>
51884 A dilemma arises when a local address is redirected by aliasing or forwarding
51885 during verification: should the generated addresses themselves be verified,
51886 or should the successful expansion of the original address be enough to verify
51887 it? By default, Exim takes the following pragmatic approach:
51888 </para>
51889 <itemizedlist>
51890 <listitem>
51891 <para>
51892 When an incoming address is redirected to just one child address, verification
51893 continues with the child address, and if that fails to verify, the original
51894 verification also fails.
51895 </para>
51896 </listitem>
51897 <listitem>
51898 <para>
51899 When an incoming address is redirected to more than one child address,
51900 verification does not continue. A success result is returned.
51901 </para>
51902 </listitem>
51903 </itemizedlist>
51904 <para>
51905 This seems the most reasonable behaviour for the common use of aliasing as a
51906 way of redirecting different local parts to the same mailbox. It means, for
51907 example, that a pair of alias entries of the form
51908 </para>
51909 <literallayout class="monospaced">
51910 A.Wol:   aw123
51911 aw123:   :fail: Gone away, no forwarding address
51912 </literallayout>
51913 <para>
51914 work as expected, with both local parts causing verification failure. When a
51915 redirection generates more than one address, the behaviour is more like a
51916 mailing list, where the existence of the alias itself is sufficient for
51917 verification to succeed.
51918 </para>
51919 <para>
51920 It is possible, however, to change the default behaviour so that all successful
51921 redirections count as successful verifications, however many new addresses are
51922 generated. This is specified by the <option>success_on_redirect</option> verification
51923 option. For example:
51924 </para>
51925 <literallayout class="monospaced">
51926 require verify = recipient/success_on_redirect/callout=10s
51927 </literallayout>
51928 <para>
51929 In this example, verification succeeds if a router generates a new address, and
51930 the callout does not occur, because no address was routed to a remote host.
51931 </para>
51932 <para>
51933 When verification is being tested via the <option>-bv</option> option, the treatment of
51934 redirections is as just described, unless the <option>-v</option> or any debugging option is
51935 also specified. In that case, full verification is done for every generated
51936 address and a report is output for each of them.
51937 </para>
51938 </section>
51939 <section id="SECTverifyCSA">
51940 <title>Client SMTP authorization (CSA)</title>
51941 <para>
51942 <indexterm role="concept">
51943 <primary>CSA</primary>
51944 <secondary>verifying</secondary>
51945 </indexterm>
51946 Client SMTP Authorization is a system that allows a site to advertise
51947 which machines are and are not permitted to send email. This is done by placing
51948 special SRV records in the DNS; these are looked up using the client&#x2019;s HELO
51949 domain. At the time of writing, CSA is still an Internet Draft. Client SMTP
51950 Authorization checks in Exim are performed by the ACL condition:
51951 </para>
51952 <literallayout class="monospaced">
51953 verify = csa
51954 </literallayout>
51955 <para>
51956 This fails if the client is not authorized. If there is a DNS problem, or if no
51957 valid CSA SRV record is found, or if the client is authorized, the condition
51958 succeeds. These three cases can be distinguished using the expansion variable
51959 <varname>$csa_status</varname>, which can take one of the values <quote>fail</quote>, <quote>defer</quote>,
51960 <quote>unknown</quote>, or <quote>ok</quote>. The condition does not itself defer because that would
51961 be likely to cause problems for legitimate email.
51962 </para>
51963 <para>
51964 The error messages produced by the CSA code include slightly more
51965 detail. If <varname>$csa_status</varname> is <quote>defer</quote>, this may be because of problems
51966 looking up the CSA SRV record, or problems looking up the CSA target
51967 address record. There are four reasons for <varname>$csa_status</varname> being <quote>fail</quote>:
51968 </para>
51969 <itemizedlist>
51970 <listitem>
51971 <para>
51972 The client&#x2019;s host name is explicitly not authorized.
51973 </para>
51974 </listitem>
51975 <listitem>
51976 <para>
51977 The client&#x2019;s IP address does not match any of the CSA target IP addresses.
51978 </para>
51979 </listitem>
51980 <listitem>
51981 <para>
51982 The client&#x2019;s host name is authorized but it has no valid target IP addresses
51983 (for example, the target&#x2019;s addresses are IPv6 and the client is using IPv4).
51984 </para>
51985 </listitem>
51986 <listitem>
51987 <para>
51988 The client&#x2019;s host name has no CSA SRV record but a parent domain has asserted
51989 that all subdomains must be explicitly authorized.
51990 </para>
51991 </listitem>
51992 </itemizedlist>
51993 <para>
51994 The <option>csa</option> verification condition can take an argument which is the domain to
51995 use for the DNS query. The default is:
51996 </para>
51997 <literallayout class="monospaced">
51998 verify = csa/$sender_helo_name
51999 </literallayout>
52000 <para>
52001 This implementation includes an extension to CSA. If the query domain
52002 is an address literal such as [192.0.2.95], or if it is a bare IP
52003 address, Exim searches for CSA SRV records in the reverse DNS as if
52004 the HELO domain was (for example) <emphasis>95.2.0.192.in-addr.arpa</emphasis>. Therefore it is
52005 meaningful to say:
52006 </para>
52007 <literallayout class="monospaced">
52008 verify = csa/$sender_host_address
52009 </literallayout>
52010 <para>
52011 In fact, this is the check that Exim performs if the client does not say HELO.
52012 This extension can be turned off by setting the main configuration option
52013 <option>dns_csa_use_reverse</option> to be false.
52014 </para>
52015 <para>
52016 If a CSA SRV record is not found for the domain itself, a search
52017 is performed through its parent domains for a record which might be
52018 making assertions about subdomains. The maximum depth of this search is limited
52019 using the main configuration option <option>dns_csa_search_limit</option>, which is 5 by
52020 default. Exim does not look for CSA SRV records in a top level domain, so the
52021 default settings handle HELO domains as long as seven
52022 (<emphasis>hostname.five.four.three.two.one.com</emphasis>). This encompasses the vast majority
52023 of legitimate HELO domains.
52024 </para>
52025 <para>
52026 The <emphasis>dnsdb</emphasis> lookup also has support for CSA. Although <emphasis>dnsdb</emphasis> also supports
52027 direct SRV lookups, this is not sufficient because of the extra parent domain
52028 search behaviour of CSA, and (as with PTR lookups) <emphasis>dnsdb</emphasis> also turns IP
52029 addresses into lookups in the reverse DNS space. The result of a successful
52030 lookup such as:
52031 </para>
52032 <literallayout class="monospaced">
52033 ${lookup dnsdb {csa=$sender_helo_name}}
52034 </literallayout>
52035 <para>
52036 has two space-separated fields: an authorization code and a target host name.
52037 The authorization code can be <quote>Y</quote> for yes, <quote>N</quote> for no, <quote>X</quote> for explicit
52038 authorization required but absent, or <quote>?</quote> for unknown.
52039 </para>
52040 </section>
52041 <section id="SECTverifyPRVS">
52042 <title>Bounce address tag validation</title>
52043 <para>
52044 <indexterm role="concept">
52045 <primary>BATV, verifying</primary>
52046 </indexterm>
52047 Bounce address tag validation (BATV) is a scheme whereby the envelope senders
52048 of outgoing messages have a cryptographic, timestamped <quote>tag</quote> added to them.
52049 Genuine incoming bounce messages should therefore always be addressed to
52050 recipients that have a valid tag. This scheme is a way of detecting unwanted
52051 bounce messages caused by sender address forgeries (often called <quote>collateral
52052 spam</quote>), because the recipients of such messages do not include valid tags.
52053 </para>
52054 <para>
52055 There are two expansion items to help with the implementation of the BATV
52056 <quote>prvs</quote> (private signature) scheme in an Exim configuration. This scheme signs
52057 the original envelope sender address by using a simple key to add a hash of the
52058 address and some time-based randomizing information. The <option>prvs</option> expansion
52059 item creates a signed address, and the <option>prvscheck</option> expansion item checks one.
52060 The syntax of these expansion items is described in section
52061 <xref linkend="SECTexpansionitems"/>.
52062 </para>
52063 <para>
52064 As an example, suppose the secret per-address keys are stored in an MySQL
52065 database. A query to look up the key for an address could be defined as a macro
52066 like this:
52067 </para>
52068 <literallayout class="monospaced">
52069 PRVSCHECK_SQL = ${lookup mysql{SELECT secret FROM batv_prvs \
52070                 WHERE sender='${quote_mysql:$prvscheck_address}'\
52071                 }{$value}}
52072 </literallayout>
52073 <para>
52074 Suppose also that the senders who make use of BATV are defined by an address
52075 list called <option>batv_senders</option>. Then, in the ACL for RCPT commands, you could
52076 use this:
52077 </para>
52078 <literallayout class="monospaced">
52079 # Bounces: drop unsigned addresses for BATV senders
52080 deny message = This address does not send an unsigned reverse path
52081      senders = :
52082      recipients = +batv_senders
52083
52084 # Bounces: In case of prvs-signed address, check signature.
52085 deny message = Invalid reverse path signature.
52086      senders = :
52087      condition  = ${prvscheck {$local_part@$domain}\
52088                   {PRVSCHECK_SQL}{1}}
52089      !condition = $prvscheck_result
52090 </literallayout>
52091 <para>
52092 The first statement rejects recipients for bounce messages that are addressed
52093 to plain BATV sender addresses, because it is known that BATV senders do not
52094 send out messages with plain sender addresses. The second statement rejects
52095 recipients that are prvs-signed, but with invalid signatures (either because
52096 the key is wrong, or the signature has timed out).
52097 </para>
52098 <para>
52099 A non-prvs-signed address is not rejected by the second statement, because the
52100 <option>prvscheck</option> expansion yields an empty string if its first argument is not a
52101 prvs-signed address, thus causing the <option>condition</option> condition to be false. If
52102 the first argument is a syntactically valid prvs-signed address, the yield is
52103 the third string (in this case <quote>1</quote>), whether or not the cryptographic and
52104 timeout checks succeed. The <varname>$prvscheck_result</varname> variable contains the result
52105 of the checks (empty for failure, <quote>1</quote> for success).
52106 </para>
52107 <para>
52108 There is one more issue you must consider when implementing prvs-signing:
52109 you have to ensure that the routers accept prvs-signed addresses and
52110 deliver them correctly. The easiest way to handle this is to use a <command>redirect</command>
52111 router to remove the signature with a configuration along these lines:
52112 </para>
52113 <literallayout class="monospaced">
52114 batv_redirect:
52115   driver = redirect
52116   data = ${prvscheck {$local_part@$domain}{PRVSCHECK_SQL}}
52117 </literallayout>
52118 <para>
52119 This works because, if the third argument of <option>prvscheck</option> is empty, the result
52120 of the expansion of a prvs-signed address is the decoded value of the original
52121 address. This router should probably be the first of your routers that handles
52122 local addresses.
52123 </para>
52124 <para>
52125 To create BATV-signed addresses in the first place, a transport of this form
52126 can be used:
52127 </para>
52128 <literallayout class="monospaced">
52129 external_smtp_batv:
52130   driver = smtp
52131   return_path = ${prvs {$return_path} \
52132                        {${lookup mysql{SELECT \
52133                        secret FROM batv_prvs WHERE \
52134                        sender='${quote_mysql:$sender_address}'} \
52135                        {$value}fail}}}
52136 </literallayout>
52137 <para>
52138 If no key can be found for the existing return path, no signing takes place.
52139 </para>
52140 </section>
52141 <section id="SECTrelaycontrol">
52142 <title>Using an ACL to control relaying</title>
52143 <para>
52144 <indexterm role="concept">
52145 <primary>access control lists (ACLs)</primary>
52146 <secondary>relay control</secondary>
52147 </indexterm>
52148 <indexterm role="concept">
52149 <primary>relaying</primary>
52150 <secondary>control by ACL</secondary>
52151 </indexterm>
52152 <indexterm role="concept">
52153 <primary>policy control</primary>
52154 <secondary>relay control</secondary>
52155 </indexterm>
52156 An MTA is said to <emphasis>relay</emphasis> a message if it receives it from some host and
52157 delivers it directly to another host as a result of a remote address contained
52158 within it. Redirecting a local address via an alias or forward file and then
52159 passing the message on to another host is not relaying,
52160 <indexterm role="concept">
52161 <primary><quote>percent hack</quote></primary>
52162 </indexterm>
52163 but a redirection as a result of the <quote>percent hack</quote> is.
52164 </para>
52165 <para>
52166 Two kinds of relaying exist, which are termed <quote>incoming</quote> and <quote>outgoing</quote>.
52167 A host which is acting as a gateway or an MX backup is concerned with incoming
52168 relaying from arbitrary hosts to a specific set of domains. On the other hand,
52169 a host which is acting as a smart host for a number of clients is concerned
52170 with outgoing relaying from those clients to the Internet at large. Often the
52171 same host is fulfilling both functions,
52172 but in principle these two kinds of relaying are entirely independent. What is
52173 not wanted is the transmission of mail from arbitrary remote hosts through your
52174 system to arbitrary domains.
52175 </para>
52176 <para>
52177 You can implement relay control by means of suitable statements in the ACL that
52178 runs for each RCPT command. For convenience, it is often easiest to use
52179 Exim&#x2019;s named list facility to define the domains and hosts involved. For
52180 example, suppose you want to do the following:
52181 </para>
52182 <itemizedlist>
52183 <listitem>
52184 <para>
52185 Deliver a number of domains to mailboxes on the local host (or process them
52186 locally in some other way). Let&#x2019;s say these are <emphasis>my.dom1.example</emphasis> and
52187 <emphasis>my.dom2.example</emphasis>.
52188 </para>
52189 </listitem>
52190 <listitem>
52191 <para>
52192 Relay mail for a number of other domains for which you are the secondary MX.
52193 These might be <emphasis>friend1.example</emphasis> and <emphasis>friend2.example</emphasis>.
52194 </para>
52195 </listitem>
52196 <listitem>
52197 <para>
52198 Relay mail from the hosts on your local LAN, to whatever domains are involved.
52199 Suppose your LAN is 192.168.45.0/24.
52200 </para>
52201 </listitem>
52202 </itemizedlist>
52203 <para>
52204 In the main part of the configuration, you put the following definitions:
52205 </para>
52206 <literallayout class="monospaced">
52207 domainlist local_domains = my.dom1.example : my.dom2.example
52208 domainlist relay_domains = friend1.example : friend2.example
52209 hostlist   relay_hosts   = 192.168.45.0/24
52210 </literallayout>
52211 <para>
52212 Now you can use these definitions in the ACL that is run for every RCPT
52213 command:
52214 </para>
52215 <literallayout class="monospaced">
52216 acl_check_rcpt:
52217   accept domains = +local_domains : +relay_domains
52218   accept hosts   = +relay_hosts
52219 </literallayout>
52220 <para>
52221 The first statement accepts any RCPT command that contains an address in
52222 the local or relay domains. For any other domain, control passes to the second
52223 statement, which accepts the command only if it comes from one of the relay
52224 hosts. In practice, you will probably want to make your ACL more sophisticated
52225 than this, for example, by including sender and recipient verification. The
52226 default configuration includes a more comprehensive example, which is described
52227 in chapter <xref linkend="CHAPdefconfil"/>.
52228 </para>
52229 </section>
52230 <section id="SECTcheralcon">
52231 <title>Checking a relay configuration</title>
52232 <para>
52233 <indexterm role="concept">
52234 <primary>relaying</primary>
52235 <secondary>checking control of</secondary>
52236 </indexterm>
52237 You can check the relay characteristics of your configuration in the same way
52238 that you can test any ACL behaviour for an incoming SMTP connection, by using
52239 the <option>-bh</option> option to run a fake SMTP session with which you interact.
52240 </para>
52241 <para>
52242 For specifically testing for unwanted relaying, the host
52243 <emphasis>relay-test.mail-abuse.org</emphasis> provides a useful service. If you telnet to this
52244 host from the host on which Exim is running, using the normal telnet port, you
52245 will see a normal telnet connection message and then quite a long delay. Be
52246 patient. The remote host is making an SMTP connection back to your host, and
52247 trying a number of common probes to test for open relay vulnerability. The
52248 results of the tests will eventually appear on your terminal.
52249 <indexterm role="concept" startref="IIDacl" class="endofrange"/>
52250 </para>
52251 </section>
52252 </chapter>
52253
52254 <chapter id="CHAPexiscan">
52255 <title>Content scanning at ACL time</title>
52256 <para>
52257 <indexterm role="concept" id="IIDcosca" class="startofrange">
52258 <primary>content scanning</primary>
52259 <secondary>at ACL time</secondary>
52260 </indexterm>
52261 The extension of Exim to include content scanning at ACL time, formerly known
52262 as <quote>exiscan</quote>, was originally implemented as a patch by Tom Kistner. The code
52263 was integrated into the main source for Exim release 4.50, and Tom continues to
52264 maintain it. Most of the wording of this chapter is taken from Tom&#x2019;s
52265 specification.
52266 </para>
52267 <para>
52268 It is also possible to scan the content of messages at other times. The
52269 <function>local_scan()</function> function (see chapter <xref linkend="CHAPlocalscan"/>) allows for content
52270 scanning after all the ACLs have run. A transport filter can be used to scan
52271 messages at delivery time (see the <option>transport_filter</option> option, described in
52272 chapter <xref linkend="CHAPtransportgeneric"/>).
52273 </para>
52274 <para>
52275 If you want to include the ACL-time content-scanning features when you compile
52276 Exim, you need to arrange for WITH_CONTENT_SCAN to be defined in your
52277 <filename>Local/Makefile</filename>. When you do that, the Exim binary is built with:
52278 </para>
52279 <itemizedlist>
52280 <listitem>
52281 <para>
52282 Two additional ACLs (<option>acl_smtp_mime</option> and <option>acl_not_smtp_mime</option>) that are run
52283 for all MIME parts for SMTP and non-SMTP messages, respectively.
52284 </para>
52285 </listitem>
52286 <listitem>
52287 <para>
52288 Additional ACL conditions and modifiers: <option>decode</option>, <option>malware</option>,
52289 <option>mime_regex</option>, <option>regex</option>, and <option>spam</option>. These can be used in the ACL that is
52290 run at the end of message reception (the <option>acl_smtp_data</option> ACL).
52291 </para>
52292 </listitem>
52293 <listitem>
52294 <para>
52295 An additional control feature (<quote>no_mbox_unspool</quote>) that saves spooled copies
52296 of messages, or parts of messages, for debugging purposes.
52297 </para>
52298 </listitem>
52299 <listitem>
52300 <para>
52301 Additional expansion variables that are set in the new ACL and by the new
52302 conditions.
52303 </para>
52304 </listitem>
52305 <listitem>
52306 <para>
52307 Two new main configuration options: <option>av_scanner</option> and <option>spamd_address</option>.
52308 </para>
52309 </listitem>
52310 </itemizedlist>
52311 <para>
52312 There is another content-scanning configuration option for <filename>Local/Makefile</filename>,
52313 called WITH_OLD_DEMIME. If this is set, the old, deprecated <option>demime</option> ACL
52314 condition is compiled, in addition to all the other content-scanning features.
52315 </para>
52316 <para>
52317 Content-scanning is continually evolving, and new features are still being
52318 added. While such features are still unstable and liable to incompatible
52319 changes, they are made available in Exim by setting options whose names begin
52320 EXPERIMENTAL_ in <filename>Local/Makefile</filename>. Such features are not documented in
52321 this manual. You can find out about them by reading the file called
52322 <filename>doc/experimental.txt</filename>.
52323 </para>
52324 <para>
52325 All the content-scanning facilities work on a MBOX copy of the message that is
52326 temporarily created in a file called:
52327 </para>
52328 <literallayout>
52329 &lt;<emphasis>spool_directory</emphasis>&gt;<literal>/scan/</literal>&lt;<emphasis>message_id</emphasis>&gt;/&lt;<emphasis>message_id</emphasis>&gt;<literal>.eml</literal>
52330 </literallayout>
52331 <para>
52332 The <filename>.eml</filename> extension is a friendly hint to virus scanners that they can
52333 expect an MBOX-like structure inside that file. The file is created when the
52334 first content scanning facility is called. Subsequent calls to content
52335 scanning conditions open the same file again. The directory is recursively
52336 removed when the <option>acl_smtp_data</option> ACL has finished running, unless
52337 </para>
52338 <literallayout class="monospaced">
52339 control = no_mbox_unspool
52340 </literallayout>
52341 <para>
52342 has been encountered. When the MIME ACL decodes files, they are put into the
52343 same directory by default.
52344 </para>
52345 <section id="SECTscanvirus">
52346 <title>Scanning for viruses</title>
52347 <para>
52348 <indexterm role="concept">
52349 <primary>virus scanning</primary>
52350 </indexterm>
52351 <indexterm role="concept">
52352 <primary>content scanning</primary>
52353 <secondary>for viruses</secondary>
52354 </indexterm>
52355 <indexterm role="concept">
52356 <primary>content scanning</primary>
52357 <secondary>the <option>malware</option> condition</secondary>
52358 </indexterm>
52359 The <option>malware</option> ACL condition lets you connect virus scanner software to Exim.
52360 It supports a <quote>generic</quote> interface to scanners called via the shell, and
52361 specialized interfaces for <quote>daemon</quote> type virus scanners, which are resident
52362 in memory and thus are much faster.
52363 </para>
52364 <para>
52365 <indexterm role="option">
52366 <primary><option>av_scanner</option></primary>
52367 </indexterm>
52368 You can set the <option>av_scanner</option> option in first part of the Exim configuration
52369 file to specify which scanner to use, together with any additional options that
52370 are needed. The basic syntax is as follows:
52371 </para>
52372 <literallayout>
52373 <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>
52374 </literallayout>
52375 <para>
52376 If you do not set <option>av_scanner</option>, it defaults to
52377 </para>
52378 <literallayout class="monospaced">
52379 av_scanner = sophie:/var/run/sophie
52380 </literallayout>
52381 <para>
52382 If the value of <option>av_scanner</option> starts with a dollar character, it is expanded
52383 before use. The following scanner types are supported in this release:
52384 </para>
52385 <variablelist>
52386 <varlistentry>
52387 <term><option>aveserver</option></term>
52388 <listitem>
52389 <para>
52390 <indexterm role="concept">
52391 <primary>virus scanners</primary>
52392 <secondary>Kaspersky</secondary>
52393 </indexterm>
52394 This is the scanner daemon of Kaspersky Version 5. You can get a trial version
52395 at <emphasis role="bold"><ulink url="http://www.kaspersky.com">http://www.kaspersky.com</ulink></emphasis>. This scanner type takes one option,
52396 which is the path to the daemon&#x2019;s UNIX socket. The default is shown in this
52397 example:
52398 </para>
52399 <literallayout class="monospaced">
52400 av_scanner = aveserver:/var/run/aveserver
52401 </literallayout>
52402 </listitem></varlistentry>
52403 <varlistentry>
52404 <term><option>clamd</option></term>
52405 <listitem>
52406 <para>
52407 <indexterm role="concept">
52408 <primary>virus scanners</primary>
52409 <secondary>clamd</secondary>
52410 </indexterm>
52411 This daemon-type scanner is GPL and free. You can get it at
52412 <emphasis role="bold"><ulink url="http://www.clamav.net/">http://www.clamav.net/</ulink></emphasis>. Some older versions of clamd do not seem to
52413 unpack MIME containers, so it used to be recommended to unpack MIME attachments
52414 in the MIME ACL. This no longer believed to be necessary. One option is
52415 required: either the path and name of a UNIX socket file, or a hostname or IP
52416 number, and a port, separated by space, as in the second of these examples:
52417 </para>
52418 <literallayout class="monospaced">
52419 av_scanner = clamd:/opt/clamd/socket
52420 av_scanner = clamd:192.0.2.3 1234
52421 av_scanner = clamd:192.0.2.3 1234:local
52422 </literallayout>
52423 <para>
52424 If the value of av_scanner points to a UNIX socket file or contains the local
52425 keyword, then the ClamAV interface will pass a filename containing the data
52426 to be scanned, which will should normally result in less I/O happening and be
52427 more efficient.  Normally in the TCP case, the data is streamed to ClamAV as
52428 Exim does not assume that there is a common filesystem with the remote host.
52429 There is an option WITH_OLD_CLAMAV_STREAM in <filename>src/EDITME</filename> available, should
52430 you be running a version of ClamAV prior to 0.95.
52431 If the option is unset, the default is <filename>/tmp/clamd</filename>. Thanks to David Saez for
52432 contributing the code for this scanner.
52433 </para>
52434 </listitem></varlistentry>
52435 <varlistentry>
52436 <term><option>cmdline</option></term>
52437 <listitem>
52438 <para>
52439 <indexterm role="concept">
52440 <primary>virus scanners</primary>
52441 <secondary>command line interface</secondary>
52442 </indexterm>
52443 This is the keyword for the generic command line scanner interface. It can be
52444 used to attach virus scanners that are invoked from the shell. This scanner
52445 type takes 3 mandatory options:
52446 </para>
52447 <orderedlist numeration="arabic">
52448 <listitem>
52449 <para>
52450 The full path and name of the scanner binary, with all command line options,
52451 and a placeholder (<literal>%s</literal>) for the directory to scan.
52452 </para>
52453 </listitem>
52454 <listitem>
52455 <para>
52456 A regular expression to match against the STDOUT and STDERR output of the
52457 virus scanner. If the expression matches, a virus was found. You must make
52458 absolutely sure that this expression matches on <quote>virus found</quote>. This is called
52459 the <quote>trigger</quote> expression.
52460 </para>
52461 </listitem>
52462 <listitem>
52463 <para>
52464 Another regular expression, containing exactly one pair of parentheses, to
52465 match the name of the virus found in the scanners output. This is called the
52466 <quote>name</quote> expression.
52467 </para>
52468 </listitem>
52469 </orderedlist>
52470 <para>
52471 For example, Sophos Sweep reports a virus on a line like this:
52472 </para>
52473 <literallayout class="monospaced">
52474 Virus 'W32/Magistr-B' found in file ./those.bat
52475 </literallayout>
52476 <para>
52477 For the trigger expression, we can match the phrase <quote>found in file</quote>. For the
52478 name expression, we want to extract the W32/Magistr-B string, so we can match
52479 for the single quotes left and right of it. Altogether, this makes the
52480 configuration setting:
52481 </para>
52482 <literallayout class="monospaced">
52483 av_scanner = cmdline:\
52484              /path/to/sweep -ss -all -rec -archive %s:\
52485              found in file:'(.+)'
52486 </literallayout>
52487 </listitem></varlistentry>
52488 <varlistentry>
52489 <term><option>drweb</option></term>
52490 <listitem>
52491 <para>
52492 <indexterm role="concept">
52493 <primary>virus scanners</primary>
52494 <secondary>DrWeb</secondary>
52495 </indexterm>
52496 The DrWeb daemon scanner (<emphasis role="bold"><ulink url="http://www.sald.com/">http://www.sald.com/</ulink></emphasis>) interface takes one
52497 argument, either a full path to a UNIX socket, or an IP address and port
52498 separated by white space, as in these examples:
52499 </para>
52500 <literallayout class="monospaced">
52501 av_scanner = drweb:/var/run/drwebd.sock
52502 av_scanner = drweb:192.168.2.20 31337
52503 </literallayout>
52504 <para>
52505 If you omit the argument, the default path <filename>/usr/local/drweb/run/drwebd.sock</filename>
52506 is used. Thanks to Alex Miller for contributing the code for this scanner.
52507 </para>
52508 </listitem></varlistentry>
52509 <varlistentry>
52510 <term><option>fsecure</option></term>
52511 <listitem>
52512 <para>
52513 <indexterm role="concept">
52514 <primary>virus scanners</primary>
52515 <secondary>F-Secure</secondary>
52516 </indexterm>
52517 The F-Secure daemon scanner (<emphasis role="bold"><ulink url="http://www.f-secure.com">http://www.f-secure.com</ulink></emphasis>) takes one
52518 argument which is the path to a UNIX socket. For example:
52519 </para>
52520 <literallayout class="monospaced">
52521 av_scanner = fsecure:/path/to/.fsav
52522 </literallayout>
52523 <para>
52524 If no argument is given, the default is <filename>/var/run/.fsav</filename>. Thanks to Johan
52525 Thelmen for contributing the code for this scanner.
52526 </para>
52527 </listitem></varlistentry>
52528 <varlistentry>
52529 <term><option>kavdaemon</option></term>
52530 <listitem>
52531 <para>
52532 <indexterm role="concept">
52533 <primary>virus scanners</primary>
52534 <secondary>Kaspersky</secondary>
52535 </indexterm>
52536 This is the scanner daemon of Kaspersky Version 4. This version of the
52537 Kaspersky scanner is outdated. Please upgrade (see <option>aveserver</option> above). This
52538 scanner type takes one option, which is the path to the daemon&#x2019;s UNIX socket.
52539 For example:
52540 </para>
52541 <literallayout class="monospaced">
52542 av_scanner = kavdaemon:/opt/AVP/AvpCtl
52543 </literallayout>
52544 <para>
52545 The default path is <filename>/var/run/AvpCtl</filename>.
52546 </para>
52547 </listitem></varlistentry>
52548 <varlistentry>
52549 <term><option>mksd</option></term>
52550 <listitem>
52551 <para>
52552 <indexterm role="concept">
52553 <primary>virus scanners</primary>
52554 <secondary>mksd</secondary>
52555 </indexterm>
52556 This is a daemon type scanner that is aimed mainly at Polish users, though some
52557 parts of documentation are now available in English. You can get it at
52558 <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
52559 the maximum number of processes used simultaneously to scan the attachments,
52560 provided that the demime facility is employed and also provided that mksd has
52561 been run with at least the same number of child processes. For example:
52562 </para>
52563 <literallayout class="monospaced">
52564 av_scanner = mksd:2
52565 </literallayout>
52566 <para>
52567 You can safely omit this option (the default value is 1).
52568 </para>
52569 </listitem></varlistentry>
52570 <varlistentry>
52571 <term><option>sophie</option></term>
52572 <listitem>
52573 <para>
52574 <indexterm role="concept">
52575 <primary>virus scanners</primary>
52576 <secondary>Sophos and Sophie</secondary>
52577 </indexterm>
52578 Sophie is a daemon that uses Sophos&#x2019; <option>libsavi</option> library to scan for viruses.
52579 You can get Sophie at <emphasis role="bold"><ulink url="http://www.clanfield.info/sophie/">http://www.clanfield.info/sophie/</ulink></emphasis>. The only option
52580 for this scanner type is the path to the UNIX socket that Sophie uses for
52581 client communication. For example:
52582 </para>
52583 <literallayout class="monospaced">
52584 av_scanner = sophie:/tmp/sophie
52585 </literallayout>
52586 <para>
52587 The default path is <filename>/var/run/sophie</filename>, so if you are using this, you can omit
52588 the option.
52589 </para>
52590 </listitem></varlistentry>
52591 </variablelist>
52592 <para>
52593 When <option>av_scanner</option> is correctly set, you can use the <option>malware</option> condition in
52594 the DATA ACL. <emphasis role="bold">Note</emphasis>: You cannot use the <option>malware</option> condition in the MIME
52595 ACL.
52596 </para>
52597 <para>
52598 The <option>av_scanner</option> option is expanded each time <option>malware</option> is called. This
52599 makes it possible to use different scanners. See further below for an example.
52600 The <option>malware</option> condition caches its results, so when you use it multiple times
52601 for the same message, the actual scanning process is only carried out once.
52602 However, using expandable items in <option>av_scanner</option> disables this caching, in
52603 which case each use of the <option>malware</option> condition causes a new scan of the
52604 message.
52605 </para>
52606 <para>
52607 The <option>malware</option> condition takes a right-hand argument that is expanded before
52608 use. It can then be one of
52609 </para>
52610 <itemizedlist>
52611 <listitem>
52612 <para>
52613 <quote>true</quote>, <quote>*</quote>, or <quote>1</quote>, in which case the message is scanned for viruses.
52614 The condition succeeds if a virus was found, and fail otherwise. This is the
52615 recommended usage.
52616 </para>
52617 </listitem>
52618 <listitem>
52619 <para>
52620 <quote>false</quote> or <quote>0</quote> or an empty string, in which case no scanning is done and
52621 the condition fails immediately.
52622 </para>
52623 </listitem>
52624 <listitem>
52625 <para>
52626 A regular expression, in which case the message is scanned for viruses. The
52627 condition succeeds if a virus is found and its name matches the regular
52628 expression. This allows you to take special actions on certain types of virus.
52629 </para>
52630 </listitem>
52631 </itemizedlist>
52632 <para>
52633 You can append <literal>/defer_ok</literal> to the <option>malware</option> condition to accept messages
52634 even if there is a problem with the virus scanner. Otherwise, such a problem
52635 causes the ACL to defer.
52636 </para>
52637 <para>
52638 <indexterm role="variable">
52639 <primary><varname>$malware_name</varname></primary>
52640 </indexterm>
52641 When a virus is found, the condition sets up an expansion variable called
52642 <varname>$malware_name</varname> that contains the name of the virus. You can use it in a
52643 <option>message</option> modifier that specifies the error returned to the sender, and/or in
52644 logging data.
52645 </para>
52646 <para>
52647 If your virus scanner cannot unpack MIME and TNEF containers itself, you should
52648 use the <option>demime</option> condition (see section <xref linkend="SECTdemimecond"/>) before the
52649 <option>malware</option> condition.
52650 </para>
52651 <para revisionflag="changed">
52652 Beware the interaction of Exim&#x2019;s <option>message_size_limit</option> with any size limits
52653 imposed by your anti-virus scanner.
52654 </para>
52655 <para>
52656 Here is a very simple scanning example:
52657 </para>
52658 <literallayout class="monospaced">
52659 deny message = This message contains malware ($malware_name)
52660      demime = *
52661      malware = *
52662 </literallayout>
52663 <para>
52664 The next example accepts messages when there is a problem with the scanner:
52665 </para>
52666 <literallayout class="monospaced">
52667 deny message = This message contains malware ($malware_name)
52668      demime = *
52669      malware = */defer_ok
52670 </literallayout>
52671 <para>
52672 The next example shows how to use an ACL variable to scan with both sophie and
52673 aveserver. It assumes you have set:
52674 </para>
52675 <literallayout class="monospaced">
52676 av_scanner = $acl_m0
52677 </literallayout>
52678 <para>
52679 in the main Exim configuration.
52680 </para>
52681 <literallayout class="monospaced">
52682 deny message = This message contains malware ($malware_name)
52683      set acl_m0 = sophie
52684      malware = *
52685
52686 deny message = This message contains malware ($malware_name)
52687      set acl_m0 = aveserver
52688      malware = *
52689 </literallayout>
52690 </section>
52691 <section id="SECTscanspamass">
52692 <title>Scanning with SpamAssassin</title>
52693 <para>
52694 <indexterm role="concept">
52695 <primary>content scanning</primary>
52696 <secondary>for spam</secondary>
52697 </indexterm>
52698 <indexterm role="concept">
52699 <primary>spam scanning</primary>
52700 </indexterm>
52701 <indexterm role="concept">
52702 <primary>SpamAssassin</primary>
52703 </indexterm>
52704 The <option>spam</option> ACL condition calls SpamAssassin&#x2019;s <option>spamd</option> daemon to get a spam
52705 score and a report for the message. You can get SpamAssassin at
52706 <emphasis role="bold"><ulink url="http://www.spamassassin.org">http://www.spamassassin.org</ulink></emphasis>, or, if you have a working Perl
52707 installation, you can use CPAN by running:
52708 </para>
52709 <literallayout class="monospaced">
52710 perl -MCPAN -e 'install Mail::SpamAssassin'
52711 </literallayout>
52712 <para>
52713 SpamAssassin has its own set of configuration files. Please review its
52714 documentation to see how you can tweak it. The default installation should work
52715 nicely, however.
52716 </para>
52717 <para>
52718 <indexterm role="option">
52719 <primary><option>spamd_address</option></primary>
52720 </indexterm>
52721 After having installed and configured SpamAssassin, start the <option>spamd</option> daemon.
52722 By default, it listens on 127.0.0.1, TCP port 783. If you use another host or
52723 port for <option>spamd</option>, you must set the <option>spamd_address</option> option in the global
52724 part of the Exim configuration as follows (example):
52725 </para>
52726 <literallayout class="monospaced">
52727 spamd_address = 192.168.99.45 387
52728 </literallayout>
52729 <para>
52730 You do not need to set this option if you use the default. As of version 2.60,
52731 <option>spamd</option> also supports communication over UNIX sockets. If you want to use
52732 these, supply <option>spamd_address</option> with an absolute file name instead of a
52733 address/port pair:
52734 </para>
52735 <literallayout class="monospaced">
52736 spamd_address = /var/run/spamd_socket
52737 </literallayout>
52738 <para>
52739 You can have multiple <option>spamd</option> servers to improve scalability. These can
52740 reside on other hardware reachable over the network. To specify multiple
52741 <option>spamd</option> servers, put multiple address/port pairs in the <option>spamd_address</option>
52742 option, separated with colons:
52743 </para>
52744 <literallayout class="monospaced">
52745 spamd_address = 192.168.2.10 783 : \
52746                 192.168.2.11 783 : \
52747                 192.168.2.12 783
52748 </literallayout>
52749 <para>
52750 Up to 32 <option>spamd</option> servers are supported. The servers are queried in a random
52751 fashion. When a server fails to respond to the connection attempt, all other
52752 servers are tried until one succeeds. If no server responds, the <option>spam</option>
52753 condition defers.
52754 </para>
52755 <para>
52756 <emphasis role="bold">Warning</emphasis>: It is not possible to use the UNIX socket connection method with
52757 multiple <option>spamd</option> servers.
52758 </para>
52759 <para>
52760 The <option>spamd_address</option> variable is expanded before use if it starts with
52761 a dollar sign. In this case, the expansion may return a string that is
52762 used as the list so that multiple spamd servers can be the result of an
52763 expansion.
52764 </para>
52765 </section>
52766 <section id="SECID206">
52767 <title>Calling SpamAssassin from an Exim ACL</title>
52768 <para>
52769 Here is a simple example of the use of the <option>spam</option> condition in a DATA ACL:
52770 </para>
52771 <literallayout class="monospaced">
52772 deny message = This message was classified as SPAM
52773      spam = joe
52774 </literallayout>
52775 <para>
52776 The right-hand side of the <option>spam</option> condition specifies a name. This is
52777 relevant if you have set up multiple SpamAssassin profiles. If you do not want
52778 to scan using a specific profile, but rather use the SpamAssassin system-wide
52779 default profile, you can scan for an unknown name, or simply use <quote>nobody</quote>.
52780 However, you must put something on the right-hand side.
52781 </para>
52782 <para>
52783 The name allows you to use per-domain or per-user antispam profiles in
52784 principle, but this is not straightforward in practice, because a message may
52785 have multiple recipients, not necessarily all in the same domain. Because the
52786 <option>spam</option> condition has to be called from a DATA ACL in order to be able to
52787 read the contents of the message, the variables <varname>$local_part</varname> and <varname>$domain</varname>
52788 are not set.
52789 </para>
52790 <para>
52791 The right-hand side of the <option>spam</option> condition is expanded before being used, so
52792 you can put lookups or conditions there. When the right-hand side evaluates to
52793 <quote>0</quote> or <quote>false</quote>, no scanning is done and the condition fails immediately.
52794 </para>
52795 <para>
52796 Scanning with SpamAssassin uses a lot of resources. If you scan every message,
52797 large ones may cause significant performance degradation. As most spam messages
52798 are quite small, it is recommended that you do not scan the big ones. For
52799 example:
52800 </para>
52801 <literallayout class="monospaced">
52802 deny message = This message was classified as SPAM
52803      condition = ${if &lt; {$message_size}{10K}}
52804      spam = nobody
52805 </literallayout>
52806 <para>
52807 The <option>spam</option> condition returns true if the threshold specified in the user&#x2019;s
52808 SpamAssassin profile has been matched or exceeded. If you want to use the
52809 <option>spam</option> condition for its side effects (see the variables below), you can make
52810 it always return <quote>true</quote> by appending <literal>:true</literal> to the username.
52811 </para>
52812 <para revisionflag="changed">
52813 <indexterm role="concept">
52814 <primary>spam scanning</primary>
52815 <secondary>returned variables</secondary>
52816 </indexterm>
52817 When the <option>spam</option> condition is run, it sets up a number of expansion
52818 variables. These variables are saved with the received message, thus they are
52819 available for use at delivery time.
52820 </para>
52821 <variablelist>
52822 <varlistentry>
52823 <term><varname>$spam_score</varname></term>
52824 <listitem>
52825 <para>
52826 The spam score of the message, for example <quote>3.4</quote> or <quote>30.5</quote>. This is useful
52827 for inclusion in log or reject messages.
52828 </para>
52829 </listitem></varlistentry>
52830 <varlistentry>
52831 <term><varname>$spam_score_int</varname></term>
52832 <listitem>
52833 <para>
52834 The spam score of the message, multiplied by ten, as an integer value. For
52835 example <quote>34</quote> or <quote>305</quote>. It may appear to disagree with <varname>$spam_score</varname>
52836 because <varname>$spam_score</varname> is rounded and <varname>$spam_score_int</varname> is truncated.
52837 The integer value is useful for numeric comparisons in conditions.
52838 </para>
52839 </listitem></varlistentry>
52840 <varlistentry>
52841 <term><varname>$spam_bar</varname></term>
52842 <listitem>
52843 <para>
52844 A string consisting of a number of <quote>+</quote> or <quote>-</quote> characters, representing the
52845 integer part of the spam score value. A spam score of 4.4 would have a
52846 <varname>$spam_bar</varname> value of <quote>++++</quote>. This is useful for inclusion in warning
52847 headers, since MUAs can match on such strings.
52848 </para>
52849 </listitem></varlistentry>
52850 <varlistentry>
52851 <term><varname>$spam_report</varname></term>
52852 <listitem>
52853 <para>
52854 A multiline text table, containing the full SpamAssassin report for the
52855 message. Useful for inclusion in headers or reject messages.
52856 </para>
52857 </listitem></varlistentry>
52858 </variablelist>
52859 <para>
52860 The <option>spam</option> condition caches its results unless expansion in
52861 spamd_address was used. If you call it again with the same user name, it
52862 does not scan again, but rather returns the same values as before.
52863 </para>
52864 <para>
52865 The <option>spam</option> condition returns DEFER if there is any error while running
52866 the message through SpamAssassin or if the expansion of spamd_address
52867 failed. If you want to treat DEFER as FAIL (to pass on to the next ACL
52868 statement block), append <literal>/defer_ok</literal> to the right-hand side of the
52869 spam condition, like this:
52870 </para>
52871 <literallayout class="monospaced">
52872 deny message = This message was classified as SPAM
52873      spam    = joe/defer_ok
52874 </literallayout>
52875 <para>
52876 This causes messages to be accepted even if there is a problem with <option>spamd</option>.
52877 </para>
52878 <para>
52879 Here is a longer, commented example of the use of the <option>spam</option>
52880 condition:
52881 </para>
52882 <literallayout class="monospaced">
52883 # put headers in all messages (no matter if spam or not)
52884 warn  spam = nobody:true
52885       add_header = X-Spam-Score: $spam_score ($spam_bar)
52886       add_header = X-Spam-Report: $spam_report
52887
52888 # add second subject line with *SPAM* marker when message
52889 # is over threshold
52890 warn  spam = nobody
52891       add_header = Subject: *SPAM* $h_Subject:
52892
52893 # reject spam at high scores (&gt; 12)
52894 deny  message = This message scored $spam_score spam points.
52895       spam = nobody:true
52896       condition = ${if &gt;{$spam_score_int}{120}{1}{0}}
52897 </literallayout>
52898 </section>
52899 <section id="SECTscanmimepart">
52900 <title>Scanning MIME parts</title>
52901 <para>
52902 <indexterm role="concept">
52903 <primary>content scanning</primary>
52904 <secondary>MIME parts</secondary>
52905 </indexterm>
52906 <indexterm role="concept">
52907 <primary>MIME content scanning</primary>
52908 </indexterm>
52909 <indexterm role="option">
52910 <primary><option>acl_smtp_mime</option></primary>
52911 </indexterm>
52912 <indexterm role="option">
52913 <primary><option>acl_not_smtp_mime</option></primary>
52914 </indexterm>
52915 The <option>acl_smtp_mime</option> global option specifies an ACL that is called once for
52916 each MIME part of an SMTP message, including multipart types, in the sequence
52917 of their position in the message. Similarly, the <option>acl_not_smtp_mime</option> option
52918 specifies an ACL that is used for the MIME parts of non-SMTP messages. These
52919 options may both refer to the same ACL if you want the same processing in both
52920 cases.
52921 </para>
52922 <para>
52923 These ACLs are called (possibly many times) just before the <option>acl_smtp_data</option>
52924 ACL in the case of an SMTP message, or just before the <option>acl_not_smtp</option> ACL in
52925 the case of a non-SMTP message. However, a MIME ACL is called only if the
52926 message contains a <emphasis>Content-Type:</emphasis> header line. When a call to a MIME
52927 ACL does not yield <quote>accept</quote>, ACL processing is aborted and the appropriate
52928 result code is sent to the client. In the case of an SMTP message, the
52929 <option>acl_smtp_data</option> ACL is not called when this happens.
52930 </para>
52931 <para>
52932 You cannot use the <option>malware</option> or <option>spam</option> conditions in a MIME ACL; these can
52933 only be used in the DATA or non-SMTP ACLs. However, you can use the <option>regex</option>
52934 condition to match against the raw MIME part. You can also use the
52935 <option>mime_regex</option> condition to match against the decoded MIME part (see section
52936 <xref linkend="SECTscanregex"/>).
52937 </para>
52938 <para>
52939 At the start of a MIME ACL, a number of variables are set from the header
52940 information for the relevant MIME part. These are described below. The contents
52941 of the MIME part are not by default decoded into a disk file except for MIME
52942 parts whose content-type is <quote>message/rfc822</quote>. If you want to decode a MIME
52943 part into a disk file, you can use the <option>decode</option> condition. The general
52944 syntax is:
52945 </para>
52946 <literallayout>
52947 <literal>decode = [/</literal>&lt;<emphasis>path</emphasis>&gt;<literal>/]</literal>&lt;<emphasis>filename</emphasis>&gt;
52948 </literallayout>
52949 <para>
52950 The right hand side is expanded before use. After expansion,
52951 the value can be:
52952 </para>
52953 <orderedlist numeration="arabic">
52954 <listitem>
52955 <para>
52956 <quote>0</quote> or <quote>false</quote>, in which case no decoding is done.
52957 </para>
52958 </listitem>
52959 <listitem>
52960 <para>
52961 The string <quote>default</quote>. In that case, the file is put in the temporary
52962 <quote>default</quote> directory &lt;<emphasis>spool_directory</emphasis>&gt;<filename>/scan/</filename>&lt;<emphasis>message_id</emphasis>&gt;<filename>/</filename> with
52963 a sequential file name consisting of the message id and a sequence number. The
52964 full path and name is available in <varname>$mime_decoded_filename</varname> after decoding.
52965 </para>
52966 </listitem>
52967 <listitem>
52968 <para>
52969 A full path name starting with a slash. If the full name is an existing
52970 directory, it is used as a replacement for the default directory. The filename
52971 is then sequentially assigned. If the path does not exist, it is used as
52972 the full path and file name.
52973 </para>
52974 </listitem>
52975 <listitem>
52976 <para>
52977 If the string does not start with a slash, it is used as the
52978 filename, and the default path is then used.
52979 </para>
52980 </listitem>
52981 </orderedlist>
52982 <para>
52983 The <option>decode</option> condition normally succeeds. It is only false for syntax
52984 errors or unusual circumstances such as memory shortages. You can easily decode
52985 a file with its original, proposed filename using
52986 </para>
52987 <literallayout class="monospaced">
52988 decode = $mime_filename
52989 </literallayout>
52990 <para>
52991 However, you should keep in mind that <varname>$mime_filename</varname> might contain
52992 anything. If you place files outside of the default path, they are not
52993 automatically unlinked.
52994 </para>
52995 <para>
52996 For RFC822 attachments (these are messages attached to messages, with a
52997 content-type of <quote>message/rfc822</quote>), the ACL is called again in the same manner
52998 as for the primary message, only that the <varname>$mime_is_rfc822</varname> expansion
52999 variable is set (see below). Attached messages are always decoded to disk
53000 before being checked, and the files are unlinked once the check is done.
53001 </para>
53002 <para>
53003 The MIME ACL supports the <option>regex</option> and <option>mime_regex</option> conditions. These can be
53004 used to match regular expressions against raw and decoded MIME parts,
53005 respectively. They are described in section <xref linkend="SECTscanregex"/>.
53006 </para>
53007 <para>
53008 <indexterm role="concept">
53009 <primary>MIME content scanning</primary>
53010 <secondary>returned variables</secondary>
53011 </indexterm>
53012 The following list describes all expansion variables that are
53013 available in the MIME ACL:
53014 </para>
53015 <variablelist>
53016 <varlistentry>
53017 <term><varname>$mime_boundary</varname></term>
53018 <listitem>
53019 <para>
53020 If the current part is a multipart (see <varname>$mime_is_multipart</varname>) below, it should
53021 have a boundary string, which is stored in this variable. If the current part
53022 has no boundary parameter in the <emphasis>Content-Type:</emphasis> header, this variable
53023 contains the empty string.
53024 </para>
53025 </listitem></varlistentry>
53026 <varlistentry>
53027 <term><varname>$mime_charset</varname></term>
53028 <listitem>
53029 <para>
53030 This variable contains the character set identifier, if one was found in the
53031 <emphasis>Content-Type:</emphasis> header. Examples for charset identifiers are:
53032 </para>
53033 <literallayout class="monospaced">
53034 us-ascii
53035 gb2312 (Chinese)
53036 iso-8859-1
53037 </literallayout>
53038 <para>
53039 Please note that this value is not normalized, so you should do matches
53040 case-insensitively.
53041 </para>
53042 </listitem></varlistentry>
53043 <varlistentry>
53044 <term><varname>$mime_content_description</varname></term>
53045 <listitem>
53046 <para>
53047 This variable contains the normalized content of the <emphasis>Content-Description:</emphasis>
53048 header. It can contain a human-readable description of the parts content. Some
53049 implementations repeat the filename for attachments here, but they are usually
53050 only used for display purposes.
53051 </para>
53052 </listitem></varlistentry>
53053 <varlistentry>
53054 <term><varname>$mime_content_disposition</varname></term>
53055 <listitem>
53056 <para>
53057 This variable contains the normalized content of the <emphasis>Content-Disposition:</emphasis>
53058 header. You can expect strings like <quote>attachment</quote> or <quote>inline</quote> here.
53059 </para>
53060 </listitem></varlistentry>
53061 <varlistentry>
53062 <term><varname>$mime_content_id</varname></term>
53063 <listitem>
53064 <para>
53065 This variable contains the normalized content of the <emphasis>Content-ID:</emphasis> header.
53066 This is a unique ID that can be used to reference a part from another part.
53067 </para>
53068 </listitem></varlistentry>
53069 <varlistentry>
53070 <term><varname>$mime_content_size</varname></term>
53071 <listitem>
53072 <para>
53073 This variable is set only after the <option>decode</option> modifier (see above) has been
53074 successfully run. It contains the size of the decoded part in kilobytes. The
53075 size is always rounded up to full kilobytes, so only a completely empty part
53076 has a <varname>$mime_content_size</varname> of zero.
53077 </para>
53078 </listitem></varlistentry>
53079 <varlistentry>
53080 <term><varname>$mime_content_transfer_encoding</varname></term>
53081 <listitem>
53082 <para>
53083 This variable contains the normalized content of the
53084 <emphasis>Content-transfer-encoding:</emphasis> header. This is a symbolic name for an encoding
53085 type. Typical values are <quote>base64</quote> and <quote>quoted-printable</quote>.
53086 </para>
53087 </listitem></varlistentry>
53088 <varlistentry>
53089 <term><varname>$mime_content_type</varname></term>
53090 <listitem>
53091 <para>
53092 If the MIME part has a <emphasis>Content-Type:</emphasis> header, this variable contains its
53093 value, lowercased, and without any options (like <quote>name</quote> or <quote>charset</quote>). Here
53094 are some examples of popular MIME types, as they may appear in this variable:
53095 </para>
53096 <literallayout class="monospaced">
53097 text/plain
53098 text/html
53099 application/octet-stream
53100 image/jpeg
53101 audio/midi
53102 </literallayout>
53103 <para>
53104 If the MIME part has no <emphasis>Content-Type:</emphasis> header, this variable contains the
53105 empty string.
53106 </para>
53107 </listitem></varlistentry>
53108 <varlistentry>
53109 <term><varname>$mime_decoded_filename</varname></term>
53110 <listitem>
53111 <para>
53112 This variable is set only after the <option>decode</option> modifier (see above) has been
53113 successfully run. It contains the full path and file name of the file
53114 containing the decoded data.
53115 </para>
53116 </listitem></varlistentry>
53117 </variablelist>
53118 <para>
53119 <indexterm role="concept">
53120 <primary>RFC 2047</primary>
53121 </indexterm>
53122 </para>
53123 <variablelist>
53124 <varlistentry>
53125 <term><varname>$mime_filename</varname></term>
53126 <listitem>
53127 <para>
53128 This is perhaps the most important of the MIME variables. It contains a
53129 proposed filename for an attachment, if one was found in either the
53130 <emphasis>Content-Type:</emphasis> or <emphasis>Content-Disposition:</emphasis> headers. The filename will be
53131 RFC2047 decoded, but no additional sanity checks are done. If no filename was
53132 found, this variable contains the empty string.
53133 </para>
53134 </listitem></varlistentry>
53135 <varlistentry>
53136 <term><varname>$mime_is_coverletter</varname></term>
53137 <listitem>
53138 <para>
53139 This variable attempts to differentiate the <quote>cover letter</quote> of an e-mail from
53140 attached data. It can be used to clamp down on flashy or unnecessarily encoded
53141 content in the cover letter, while not restricting attachments at all.
53142 </para>
53143 <para>
53144 The variable contains 1 (true) for a MIME part believed to be part of the
53145 cover letter, and 0 (false) for an attachment. At present, the algorithm is as
53146 follows:
53147 </para>
53148 <orderedlist numeration="arabic">
53149 <listitem>
53150 <para>
53151 The outermost MIME part of a message is always a cover letter.
53152 </para>
53153 </listitem>
53154 <listitem>
53155 <para>
53156 If a multipart/alternative or multipart/related MIME part is a cover letter,
53157 so are all MIME subparts within that multipart.
53158 </para>
53159 </listitem>
53160 <listitem>
53161 <para>
53162 If any other multipart is a cover letter, the first subpart is a cover letter,
53163 and the rest are attachments.
53164 </para>
53165 </listitem>
53166 <listitem>
53167 <para>
53168 All parts contained within an attachment multipart are attachments.
53169 </para>
53170 </listitem>
53171 </orderedlist>
53172 <para>
53173 As an example, the following will ban <quote>HTML mail</quote> (including that sent with
53174 alternative plain text), while allowing HTML files to be attached. HTML
53175 coverletter mail attached to non-HMTL coverletter mail will also be allowed:
53176 </para>
53177 <literallayout class="monospaced">
53178 deny message = HTML mail is not accepted here
53179 !condition = $mime_is_rfc822
53180 condition = $mime_is_coverletter
53181 condition = ${if eq{$mime_content_type}{text/html}{1}{0}}
53182 </literallayout>
53183 </listitem></varlistentry>
53184 <varlistentry>
53185 <term><varname>$mime_is_multipart</varname></term>
53186 <listitem>
53187 <para>
53188 This variable has the value 1 (true) when the current part has the main type
53189 <quote>multipart</quote>, for example <quote>multipart/alternative</quote> or <quote>multipart/mixed</quote>.
53190 Since multipart entities only serve as containers for other parts, you may not
53191 want to carry out specific actions on them.
53192 </para>
53193 </listitem></varlistentry>
53194 <varlistentry>
53195 <term><varname>$mime_is_rfc822</varname></term>
53196 <listitem>
53197 <para>
53198 This variable has the value 1 (true) if the current part is not a part of the
53199 checked message itself, but part of an attached message. Attached message
53200 decoding is fully recursive.
53201 </para>
53202 </listitem></varlistentry>
53203 <varlistentry>
53204 <term><varname>$mime_part_count</varname></term>
53205 <listitem>
53206 <para>
53207 This variable is a counter that is raised for each processed MIME part. It
53208 starts at zero for the very first part (which is usually a multipart). The
53209 counter is per-message, so it is reset when processing RFC822 attachments (see
53210 <varname>$mime_is_rfc822</varname>). The counter stays set after <option>acl_smtp_mime</option> is
53211 complete, so you can use it in the DATA ACL to determine the number of MIME
53212 parts of a message. For non-MIME messages, this variable contains the value -1.
53213 </para>
53214 </listitem></varlistentry>
53215 </variablelist>
53216 </section>
53217 <section id="SECTscanregex">
53218 <title>Scanning with regular expressions</title>
53219 <para>
53220 <indexterm role="concept">
53221 <primary>content scanning</primary>
53222 <secondary>with regular expressions</secondary>
53223 </indexterm>
53224 <indexterm role="concept">
53225 <primary>regular expressions</primary>
53226 <secondary>content scanning with</secondary>
53227 </indexterm>
53228 You can specify your own custom regular expression matches on the full body of
53229 the message, or on individual MIME parts.
53230 </para>
53231 <para>
53232 The <option>regex</option> condition takes one or more regular expressions as arguments and
53233 matches them against the full message (when called in the DATA ACL) or a raw
53234 MIME part (when called in the MIME ACL). The <option>regex</option> condition matches
53235 linewise, with a maximum line length of 32K characters. That means you cannot
53236 have multiline matches with the <option>regex</option> condition.
53237 </para>
53238 <para>
53239 The <option>mime_regex</option> condition can be called only in the MIME ACL. It matches up
53240 to 32K of decoded content (the whole content at once, not linewise). If the
53241 part has not been decoded with the <option>decode</option> modifier earlier in the ACL, it
53242 is decoded automatically when <option>mime_regex</option> is executed (using default path
53243 and filename values). If the decoded data is larger than  32K, only the first
53244 32K characters are checked.
53245 </para>
53246 <para>
53247 The regular expressions are passed as a colon-separated list. To include a
53248 literal colon, you must double it. Since the whole right-hand side string is
53249 expanded before being used, you must also escape dollar signs and backslashes
53250 with more backslashes, or use the <literal>\N</literal> facility to disable expansion.
53251 Here is a simple example that contains two regular expressions:
53252 </para>
53253 <literallayout class="monospaced">
53254 deny message = contains blacklisted regex ($regex_match_string)
53255      regex = [Mm]ortgage : URGENT BUSINESS PROPOSAL
53256 </literallayout>
53257 <para>
53258 The conditions returns true if any one of the regular expressions matches. The
53259 <varname>$regex_match_string</varname> expansion variable is then set up and contains the
53260 matching regular expression.
53261 </para>
53262 <para>
53263 <emphasis role="bold">Warning</emphasis>: With large messages, these conditions can be fairly
53264 CPU-intensive.
53265 </para>
53266 </section>
53267 <section id="SECTdemimecond">
53268 <title>The demime condition</title>
53269 <para>
53270 <indexterm role="concept">
53271 <primary>content scanning</primary>
53272 <secondary>MIME checking</secondary>
53273 </indexterm>
53274 <indexterm role="concept">
53275 <primary>MIME content scanning</primary>
53276 </indexterm>
53277 The <option>demime</option> ACL condition provides MIME unpacking, sanity checking and file
53278 extension blocking. It is usable only in the DATA and non-SMTP ACLs. The
53279 <option>demime</option> condition uses a simpler interface to MIME decoding than the MIME
53280 ACL functionality, but provides no additional facilities. Please note that this
53281 condition is deprecated and kept only for backward compatibility. You must set
53282 the WITH_OLD_DEMIME option in <filename>Local/Makefile</filename> at build time to be able to
53283 use the <option>demime</option> condition.
53284 </para>
53285 <para>
53286 The <option>demime</option> condition unpacks MIME containers in the message. It detects
53287 errors in MIME containers and can match file extensions found in the message
53288 against a list. Using this facility produces files containing the unpacked MIME
53289 parts of the message in the temporary scan directory. If you do antivirus
53290 scanning, it is recommended that you use the <option>demime</option> condition before the
53291 antivirus (<option>malware</option>) condition.
53292 </para>
53293 <para>
53294 On the right-hand side of the <option>demime</option> condition you can pass a
53295 colon-separated list of file extensions that it should match against. For
53296 example:
53297 </para>
53298 <literallayout class="monospaced">
53299 deny message = Found blacklisted file attachment
53300      demime  = vbs:com:bat:pif:prf:lnk
53301 </literallayout>
53302 <para>
53303 If one of the file extensions is found, the condition is true, otherwise it is
53304 false. If there is a temporary error while demimeing (for example, <quote>disk
53305 full</quote>), the condition defers, and the message is temporarily rejected (unless
53306 the condition is on a <option>warn</option> verb).
53307 </para>
53308 <para>
53309 The right-hand side is expanded before being treated as a list, so you can have
53310 conditions and lookups there. If it expands to an empty string, <quote>false</quote>, or
53311 zero (<quote>0</quote>), no demimeing is done and the condition is false.
53312 </para>
53313 <para>
53314 The <option>demime</option> condition set the following variables:
53315 </para>
53316 <variablelist>
53317 <varlistentry>
53318 <term><varname>$demime_errorlevel</varname></term>
53319 <listitem>
53320 <para>
53321 <indexterm role="variable">
53322 <primary><varname>$demime_errorlevel</varname></primary>
53323 </indexterm>
53324 When an error is detected in a MIME container, this variable contains the
53325 severity of the error, as an integer number. The higher the value, the more
53326 severe the error (the current maximum value is 3). If this variable is unset or
53327 zero, no error occurred.
53328 </para>
53329 </listitem></varlistentry>
53330 <varlistentry>
53331 <term><varname>$demime_reason</varname></term>
53332 <listitem>
53333 <para>
53334 <indexterm role="variable">
53335 <primary><varname>$demime_reason</varname></primary>
53336 </indexterm>
53337 When <varname>$demime_errorlevel</varname> is greater than zero, this variable contains a
53338 human-readable text string describing the MIME error that occurred.
53339 </para>
53340 </listitem></varlistentry>
53341 </variablelist>
53342 <variablelist>
53343 <varlistentry>
53344 <term><varname>$found_extension</varname></term>
53345 <listitem>
53346 <para>
53347 <indexterm role="variable">
53348 <primary><varname>$found_extension</varname></primary>
53349 </indexterm>
53350 When the <option>demime</option> condition is true, this variable contains the file
53351 extension it found.
53352 </para>
53353 </listitem></varlistentry>
53354 </variablelist>
53355 <para>
53356 Both <varname>$demime_errorlevel</varname> and <varname>$demime_reason</varname> are set by the first call of
53357 the <option>demime</option> condition, and are not changed on subsequent calls.
53358 </para>
53359 <para>
53360 If you do not want to check for file extensions, but rather use the <option>demime</option>
53361 condition for unpacking or error checking purposes, pass <quote>*</quote> as the
53362 right-hand side value. Here is a more elaborate example of how to use this
53363 facility:
53364 </para>
53365 <literallayout class="monospaced">
53366 # Reject messages with serious MIME container errors
53367 deny  message = Found MIME error ($demime_reason).
53368       demime = *
53369       condition = ${if &gt;{$demime_errorlevel}{2}{1}{0}}
53370
53371 # Reject known virus spreading file extensions.
53372 # Accepting these is pretty much braindead.
53373 deny  message = contains $found_extension file (blacklisted).
53374       demime  = com:vbs:bat:pif:scr
53375
53376 # Freeze .exe and .doc files. Postmaster can
53377 # examine them and eventually thaw them.
53378 deny  log_message = Another $found_extension file.
53379       demime = exe:doc
53380       control = freeze
53381 </literallayout>
53382 <para>
53383 <indexterm role="concept" startref="IIDcosca" class="endofrange"/>
53384 </para>
53385 </section>
53386 </chapter>
53387
53388 <chapter id="CHAPlocalscan">
53389 <title>Adding a local scan function to Exim</title>
53390 <titleabbrev>Local scan function</titleabbrev>
53391 <para>
53392 <indexterm role="concept" id="IIDlosca" class="startofrange">
53393 <primary><function>local_scan()</function> function</primary>
53394 <secondary>description of</secondary>
53395 </indexterm>
53396 <indexterm role="concept">
53397 <primary>customizing</primary>
53398 <secondary>input scan using C function</secondary>
53399 </indexterm>
53400 <indexterm role="concept">
53401 <primary>policy control</primary>
53402 <secondary>by local scan function</secondary>
53403 </indexterm>
53404 In these days of email worms, viruses, and ever-increasing spam, some sites
53405 want to apply a lot of checking to messages before accepting them.
53406 </para>
53407 <para>
53408 The content scanning extension (chapter <xref linkend="CHAPexiscan"/>) has facilities for
53409 passing messages to external virus and spam scanning software. You can also do
53410 a certain amount in Exim itself through string expansions and the <option>condition</option>
53411 condition in the ACL that runs after the SMTP DATA command or the ACL for
53412 non-SMTP messages (see chapter <xref linkend="CHAPACL"/>), but this has its limitations.
53413 </para>
53414 <para>
53415 To allow for further customization to a site&#x2019;s own requirements, there is the
53416 possibility of linking Exim with a private message scanning function, written
53417 in C. If you want to run code that is written in something other than C, you
53418 can of course use a little C stub to call it.
53419 </para>
53420 <para>
53421 The local scan function is run once for every incoming message, at the point
53422 when Exim is just about to accept the message.
53423 It can therefore be used to control non-SMTP messages from local processes as
53424 well as messages arriving via SMTP.
53425 </para>
53426 <para>
53427 Exim applies a timeout to calls of the local scan function, and there is an
53428 option called <option>local_scan_timeout</option> for setting it. The default is 5 minutes.
53429 Zero means <quote>no timeout</quote>.
53430 Exim also sets up signal handlers for SIGSEGV, SIGILL, SIGFPE, and SIGBUS
53431 before calling the local scan function, so that the most common types of crash
53432 are caught. If the timeout is exceeded or one of those signals is caught, the
53433 incoming message is rejected with a temporary error if it is an SMTP message.
53434 For a non-SMTP message, the message is dropped and Exim ends with a non-zero
53435 code. The incident is logged on the main and reject logs.
53436 </para>
53437 <section id="SECID207">
53438 <title>Building Exim to use a local scan function</title>
53439 <para>
53440 <indexterm role="concept">
53441 <primary><function>local_scan()</function> function</primary>
53442 <secondary>building Exim to use</secondary>
53443 </indexterm>
53444 To make use of the local scan function feature, you must tell Exim where your
53445 function is before building Exim, by setting LOCAL_SCAN_SOURCE in your
53446 <filename>Local/Makefile</filename>. A recommended place to put it is in the <filename>Local</filename>
53447 directory, so you might set
53448 </para>
53449 <literallayout class="monospaced">
53450 LOCAL_SCAN_SOURCE=Local/local_scan.c
53451 </literallayout>
53452 <para>
53453 for example. The function must be called <function>local_scan()</function>. It is called by
53454 Exim after it has received a message, when the success return code is about to
53455 be sent. This is after all the ACLs have been run. The return code from your
53456 function controls whether the message is actually accepted or not. There is a
53457 commented template function (that just accepts the message) in the file
53458 _src/local_scan.c_.
53459 </para>
53460 <para>
53461 If you want to make use of Exim&#x2019;s run time configuration file to set options
53462 for your <function>local_scan()</function> function, you must also set
53463 </para>
53464 <literallayout class="monospaced">
53465 LOCAL_SCAN_HAS_OPTIONS=yes
53466 </literallayout>
53467 <para>
53468 in <filename>Local/Makefile</filename> (see section <xref linkend="SECTconoptloc"/> below).
53469 </para>
53470 </section>
53471 <section id="SECTapiforloc">
53472 <title>API for local_scan()</title>
53473 <para>
53474 <indexterm role="concept">
53475 <primary><function>local_scan()</function> function</primary>
53476 <secondary>API description</secondary>
53477 </indexterm>
53478 You must include this line near the start of your code:
53479 </para>
53480 <literallayout class="monospaced">
53481 #include "local_scan.h"
53482 </literallayout>
53483 <para>
53484 This header file defines a number of variables and other values, and the
53485 prototype for the function itself. Exim is coded to use unsigned char values
53486 almost exclusively, and one of the things this header defines is a shorthand
53487 for <literal>unsigned char</literal> called <literal>uschar</literal>.
53488 It also contains the following macro definitions, to simplify casting character
53489 strings and pointers to character strings:
53490 </para>
53491 <literallayout class="monospaced">
53492 #define CS   (char *)
53493 #define CCS  (const char *)
53494 #define CSS  (char **)
53495 #define US   (unsigned char *)
53496 #define CUS  (const unsigned char *)
53497 #define USS  (unsigned char **)
53498 </literallayout>
53499 <para>
53500 The function prototype for <function>local_scan()</function> is:
53501 </para>
53502 <literallayout class="monospaced">
53503 extern int local_scan(int fd, uschar **return_text);
53504 </literallayout>
53505 <para>
53506 The arguments are as follows:
53507 </para>
53508 <itemizedlist>
53509 <listitem>
53510 <para>
53511 <option>fd</option> is a file descriptor for the file that contains the body of the message
53512 (the -D file). The file is open for reading and writing, but updating it is not
53513 recommended. <emphasis role="bold">Warning</emphasis>: You must <emphasis>not</emphasis> close this file descriptor.
53514 </para>
53515 <para>
53516 The descriptor is positioned at character 19 of the file, which is the first
53517 character of the body itself, because the first 19 characters are the message
53518 id followed by <literal>-D</literal> and a newline. If you rewind the file, you should use the
53519 macro SPOOL_DATA_START_OFFSET to reset to the start of the data, just in
53520 case this changes in some future version.
53521 </para>
53522 </listitem>
53523 <listitem>
53524 <para>
53525 <option>return_text</option> is an address which you can use to return a pointer to a text
53526 string at the end of the function. The value it points to on entry is NULL.
53527 </para>
53528 </listitem>
53529 </itemizedlist>
53530 <para>
53531 The function must return an <option>int</option> value which is one of the following macros:
53532 </para>
53533 <variablelist>
53534 <varlistentry>
53535 <term><literal>LOCAL_SCAN_ACCEPT</literal></term>
53536 <listitem>
53537 <para>
53538 <indexterm role="variable">
53539 <primary><varname>$local_scan_data</varname></primary>
53540 </indexterm>
53541 The message is accepted. If you pass back a string of text, it is saved with
53542 the message, and made available in the variable <varname>$local_scan_data</varname>. No
53543 newlines are permitted (if there are any, they are turned into spaces) and the
53544 maximum length of text is 1000 characters.
53545 </para>
53546 </listitem></varlistentry>
53547 <varlistentry>
53548 <term><literal>LOCAL_SCAN_ACCEPT_FREEZE</literal></term>
53549 <listitem>
53550 <para>
53551 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
53552 queued without immediate delivery, and is frozen.
53553 </para>
53554 </listitem></varlistentry>
53555 <varlistentry>
53556 <term><literal>LOCAL_SCAN_ACCEPT_QUEUE</literal></term>
53557 <listitem>
53558 <para>
53559 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
53560 queued without immediate delivery.
53561 </para>
53562 </listitem></varlistentry>
53563 <varlistentry>
53564 <term><literal>LOCAL_SCAN_REJECT</literal></term>
53565 <listitem>
53566 <para>
53567 The message is rejected; the returned text is used as an error message which is
53568 passed back to the sender and which is also logged. Newlines are permitted &ndash;
53569 they cause a multiline response for SMTP rejections, but are converted to
53570 <literal>\n</literal> in log lines. If no message is given, <quote>Administrative prohibition</quote> is
53571 used.
53572 </para>
53573 </listitem></varlistentry>
53574 <varlistentry>
53575 <term><literal>LOCAL_SCAN_TEMPREJECT</literal></term>
53576 <listitem>
53577 <para>
53578 The message is temporarily rejected; the returned text is used as an error
53579 message as for LOCAL_SCAN_REJECT. If no message is given, <quote>Temporary local
53580 problem</quote> is used.
53581 </para>
53582 </listitem></varlistentry>
53583 <varlistentry>
53584 <term><literal>LOCAL_SCAN_REJECT_NOLOGHDR</literal></term>
53585 <listitem>
53586 <para>
53587 This behaves as LOCAL_SCAN_REJECT, except that the header of the rejected
53588 message is not written to the reject log. It has the effect of unsetting the
53589 <option>rejected_header</option> log selector for just this rejection. If
53590 <option>rejected_header</option> is already unset (see the discussion of the
53591 <option>log_selection</option> option in section <xref linkend="SECTlogselector"/>), this code is the
53592 same as LOCAL_SCAN_REJECT.
53593 </para>
53594 </listitem></varlistentry>
53595 <varlistentry>
53596 <term><literal>LOCAL_SCAN_TEMPREJECT_NOLOGHDR</literal></term>
53597 <listitem>
53598 <para>
53599 This code is a variation of LOCAL_SCAN_TEMPREJECT in the same way that
53600 LOCAL_SCAN_REJECT_NOLOGHDR is a variation of LOCAL_SCAN_REJECT.
53601 </para>
53602 </listitem></varlistentry>
53603 </variablelist>
53604 <para>
53605 If the message is not being received by interactive SMTP, rejections are
53606 reported by writing to <option>stderr</option> or by sending an email, as configured by the
53607 <option>-oe</option> command line options.
53608 </para>
53609 </section>
53610 <section id="SECTconoptloc">
53611 <title>Configuration options for local_scan()</title>
53612 <para>
53613 <indexterm role="concept">
53614 <primary><function>local_scan()</function> function</primary>
53615 <secondary>configuration options</secondary>
53616 </indexterm>
53617 It is possible to have option settings in the main configuration file
53618 that set values in static variables in the <function>local_scan()</function> module. If you
53619 want to do this, you must have the line
53620 </para>
53621 <literallayout class="monospaced">
53622 LOCAL_SCAN_HAS_OPTIONS=yes
53623 </literallayout>
53624 <para>
53625 in your <filename>Local/Makefile</filename> when you build Exim. (This line is in
53626 <filename>OS/Makefile-Default</filename>, commented out). Then, in the <function>local_scan()</function> source
53627 file, you must define static variables to hold the option values, and a table
53628 to define them.
53629 </para>
53630 <para>
53631 The table must be a vector called <option>local_scan_options</option>, of type
53632 <literal>optionlist</literal>. Each entry is a triplet, consisting of a name, an option type,
53633 and a pointer to the variable that holds the value. The entries must appear in
53634 alphabetical order. Following <option>local_scan_options</option> you must also define a
53635 variable called <option>local_scan_options_count</option> that contains the number of
53636 entries in the table. Here is a short example, showing two kinds of option:
53637 </para>
53638 <literallayout class="monospaced">
53639 static int my_integer_option = 42;
53640 static uschar *my_string_option = US"a default string";
53641
53642 optionlist local_scan_options[] = {
53643   { "my_integer", opt_int,       &amp;my_integer_option },
53644   { "my_string",  opt_stringptr, &amp;my_string_option }
53645 };
53646
53647 int local_scan_options_count =
53648   sizeof(local_scan_options)/sizeof(optionlist);
53649 </literallayout>
53650 <para>
53651 The values of the variables can now be changed from Exim&#x2019;s runtime
53652 configuration file by including a local scan section as in this example:
53653 </para>
53654 <literallayout class="monospaced">
53655 begin local_scan
53656 my_integer = 99
53657 my_string = some string of text...
53658 </literallayout>
53659 <para>
53660 The available types of option data are as follows:
53661 </para>
53662 <variablelist>
53663 <varlistentry>
53664 <term><emphasis role="bold">opt_bool</emphasis></term>
53665 <listitem>
53666 <para>
53667 This specifies a boolean (true/false) option. The address should point to a
53668 variable of type <literal>BOOL</literal>, which will be set to TRUE or FALSE, which are macros
53669 that are defined as <quote>1</quote> and <quote>0</quote>, respectively. If you want to detect
53670 whether such a variable has been set at all, you can initialize it to
53671 TRUE_UNSET. (BOOL variables are integers underneath, so can hold more than two
53672 values.)
53673 </para>
53674 </listitem></varlistentry>
53675 <varlistentry>
53676 <term><emphasis role="bold">opt_fixed</emphasis></term>
53677 <listitem>
53678 <para>
53679 This specifies a fixed point number, such as is used for load averages.
53680 The address should point to a variable of type <literal>int</literal>. The value is stored
53681 multiplied by 1000, so, for example, 1.4142 is truncated and stored as 1414.
53682 </para>
53683 </listitem></varlistentry>
53684 <varlistentry>
53685 <term><emphasis role="bold">opt_int</emphasis></term>
53686 <listitem>
53687 <para>
53688 This specifies an integer; the address should point to a variable of type
53689 <literal>int</literal>. The value may be specified in any of the integer formats accepted by
53690 Exim.
53691 </para>
53692 </listitem></varlistentry>
53693 <varlistentry>
53694 <term><emphasis role="bold">opt_mkint</emphasis></term>
53695 <listitem>
53696 <para>
53697 This is the same as <option>opt_int</option>, except that when such a value is output in a
53698 <option>-bP</option> listing, if it is an exact number of kilobytes or megabytes, it is
53699 printed with the suffix K or M.
53700 </para>
53701 </listitem></varlistentry>
53702 <varlistentry>
53703 <term><emphasis role="bold">opt_octint</emphasis></term>
53704 <listitem>
53705 <para>
53706 This also specifies an integer, but the value is always interpreted as an
53707 octal integer, whether or not it starts with the digit zero, and it is
53708 always output in octal.
53709 </para>
53710 </listitem></varlistentry>
53711 <varlistentry>
53712 <term><emphasis role="bold">opt_stringptr</emphasis></term>
53713 <listitem>
53714 <para>
53715 This specifies a string value; the address must be a pointer to a
53716 variable that points to a string (for example, of type <literal>uschar *</literal>).
53717 </para>
53718 </listitem></varlistentry>
53719 <varlistentry>
53720 <term><emphasis role="bold">opt_time</emphasis></term>
53721 <listitem>
53722 <para>
53723 This specifies a time interval value. The address must point to a variable of
53724 type <literal>int</literal>. The value that is placed there is a number of seconds.
53725 </para>
53726 </listitem></varlistentry>
53727 </variablelist>
53728 <para>
53729 If the <option>-bP</option> command line option is followed by <literal>local_scan</literal>, Exim prints
53730 out the values of all the <function>local_scan()</function> options.
53731 </para>
53732 </section>
53733 <section id="SECID208">
53734 <title>Available Exim variables</title>
53735 <para>
53736 <indexterm role="concept">
53737 <primary><function>local_scan()</function> function</primary>
53738 <secondary>available Exim variables</secondary>
53739 </indexterm>
53740 The header <filename>local_scan.h</filename> gives you access to a number of C variables. These
53741 are the only ones that are guaranteed to be maintained from release to release.
53742 Note, however, that you can obtain the value of any Exim expansion variable,
53743 including <varname>$recipients</varname>, by calling <emphasis>expand_string()</emphasis>. The exported
53744 C variables are as follows:
53745 </para>
53746 <variablelist>
53747 <varlistentry>
53748 <term><emphasis role="bold">int&nbsp;body_linecount</emphasis></term>
53749 <listitem>
53750 <para>
53751 This variable contains the number of lines in the message&#x2019;s body.
53752 </para>
53753 </listitem></varlistentry>
53754 <varlistentry>
53755 <term><emphasis role="bold">int&nbsp;body_zerocount</emphasis></term>
53756 <listitem>
53757 <para>
53758 This variable contains the number of binary zero bytes in the message&#x2019;s body.
53759 </para>
53760 </listitem></varlistentry>
53761 <varlistentry>
53762 <term><emphasis role="bold">unsigned&nbsp;int&nbsp;debug_selector</emphasis></term>
53763 <listitem>
53764 <para>
53765 This variable is set to zero when no debugging is taking place. Otherwise, it
53766 is a bitmap of debugging selectors. Two bits are identified for use in
53767 <function>local_scan()</function>; they are defined as macros:
53768 </para>
53769 <itemizedlist>
53770 <listitem>
53771 <para>
53772 The <literal>D_v</literal> bit is set when <option>-v</option> was present on the command line. This is a
53773 testing option that is not privileged &ndash; any caller may set it. All the
53774 other selector bits can be set only by admin users.
53775 </para>
53776 </listitem>
53777 <listitem>
53778 <para>
53779 The <literal>D_local_scan</literal> bit is provided for use by <function>local_scan()</function>; it is set
53780 by the <literal>+local_scan</literal> debug selector. It is not included in the default set
53781 of debugging bits.
53782 </para>
53783 </listitem>
53784 </itemizedlist>
53785 <para>
53786 Thus, to write to the debugging output only when <literal>+local_scan</literal> has been
53787 selected, you should use code like this:
53788 </para>
53789 <literallayout class="monospaced">
53790 if ((debug_selector &amp; D_local_scan) != 0)
53791   debug_printf("xxx", ...);
53792 </literallayout>
53793 </listitem></varlistentry>
53794 <varlistentry>
53795 <term><emphasis role="bold">uschar&nbsp;*expand_string_message</emphasis></term>
53796 <listitem>
53797 <para>
53798 After a failing call to <emphasis>expand_string()</emphasis> (returned value NULL), the
53799 variable <option>expand_string_message</option> contains the error message, zero-terminated.
53800 </para>
53801 </listitem></varlistentry>
53802 <varlistentry>
53803 <term><emphasis role="bold">header_line&nbsp;*header_list</emphasis></term>
53804 <listitem>
53805 <para>
53806 A pointer to a chain of header lines. The <option>header_line</option> structure is
53807 discussed below.
53808 </para>
53809 </listitem></varlistentry>
53810 <varlistentry>
53811 <term><emphasis role="bold">header_line&nbsp;*header_last</emphasis></term>
53812 <listitem>
53813 <para>
53814 A pointer to the last of the header lines.
53815 </para>
53816 </listitem></varlistentry>
53817 <varlistentry>
53818 <term><emphasis role="bold">uschar&nbsp;*headers_charset</emphasis></term>
53819 <listitem>
53820 <para>
53821 The value of the <option>headers_charset</option> configuration option.
53822 </para>
53823 </listitem></varlistentry>
53824 <varlistentry>
53825 <term><emphasis role="bold">BOOL&nbsp;host_checking</emphasis></term>
53826 <listitem>
53827 <para>
53828 This variable is TRUE during a host checking session that is initiated by the
53829 <option>-bh</option> command line option.
53830 </para>
53831 </listitem></varlistentry>
53832 <varlistentry>
53833 <term><emphasis role="bold">uschar&nbsp;*interface_address</emphasis></term>
53834 <listitem>
53835 <para>
53836 The IP address of the interface that received the message, as a string. This
53837 is NULL for locally submitted messages.
53838 </para>
53839 </listitem></varlistentry>
53840 <varlistentry>
53841 <term><emphasis role="bold">int&nbsp;interface_port</emphasis></term>
53842 <listitem>
53843 <para>
53844 The port on which this message was received. When testing with the <option>-bh</option>
53845 command line option, the value of this variable is -1 unless a port has been
53846 specified via the <option>-oMi</option> option.
53847 </para>
53848 </listitem></varlistentry>
53849 <varlistentry>
53850 <term><emphasis role="bold">uschar&nbsp;*message_id</emphasis></term>
53851 <listitem>
53852 <para>
53853 This variable contains Exim&#x2019;s message id for the incoming message (the value of
53854 <varname>$message_exim_id</varname>) as a zero-terminated string.
53855 </para>
53856 </listitem></varlistentry>
53857 <varlistentry>
53858 <term><emphasis role="bold">uschar&nbsp;*received_protocol</emphasis></term>
53859 <listitem>
53860 <para>
53861 The name of the protocol by which the message was received.
53862 </para>
53863 </listitem></varlistentry>
53864 <varlistentry>
53865 <term><emphasis role="bold">int&nbsp;recipients_count</emphasis></term>
53866 <listitem>
53867 <para>
53868 The number of accepted recipients.
53869 </para>
53870 </listitem></varlistentry>
53871 <varlistentry>
53872 <term><emphasis role="bold">recipient_item&nbsp;*recipients_list</emphasis></term>
53873 <listitem>
53874 <para>
53875 <indexterm role="concept">
53876 <primary>recipient</primary>
53877 <secondary>adding in local scan</secondary>
53878 </indexterm>
53879 <indexterm role="concept">
53880 <primary>recipient</primary>
53881 <secondary>removing in local scan</secondary>
53882 </indexterm>
53883 The list of accepted recipients, held in a vector of length
53884 <option>recipients_count</option>. The <option>recipient_item</option> structure is discussed below. You
53885 can add additional recipients by calling <emphasis>receive_add_recipient()</emphasis> (see
53886 below). You can delete recipients by removing them from the vector and
53887 adjusting the value in <option>recipients_count</option>. In particular, by setting
53888 <option>recipients_count</option> to zero you remove all recipients. If you then return the
53889 value <literal>LOCAL_SCAN_ACCEPT</literal>, the message is accepted, but immediately
53890 blackholed. To replace the recipients, you can set <option>recipients_count</option> to zero
53891 and then call <emphasis>receive_add_recipient()</emphasis> as often as needed.
53892 </para>
53893 </listitem></varlistentry>
53894 <varlistentry>
53895 <term><emphasis role="bold">uschar&nbsp;*sender_address</emphasis></term>
53896 <listitem>
53897 <para>
53898 The envelope sender address. For bounce messages this is the empty string.
53899 </para>
53900 </listitem></varlistentry>
53901 <varlistentry>
53902 <term><emphasis role="bold">uschar&nbsp;*sender_host_address</emphasis></term>
53903 <listitem>
53904 <para>
53905 The IP address of the sending host, as a string. This is NULL for
53906 locally-submitted messages.
53907 </para>
53908 </listitem></varlistentry>
53909 <varlistentry>
53910 <term><emphasis role="bold">uschar&nbsp;*sender_host_authenticated</emphasis></term>
53911 <listitem>
53912 <para>
53913 The name of the authentication mechanism that was used, or NULL if the message
53914 was not received over an authenticated SMTP connection.
53915 </para>
53916 </listitem></varlistentry>
53917 <varlistentry>
53918 <term><emphasis role="bold">uschar&nbsp;*sender_host_name</emphasis></term>
53919 <listitem>
53920 <para>
53921 The name of the sending host, if known.
53922 </para>
53923 </listitem></varlistentry>
53924 <varlistentry>
53925 <term><emphasis role="bold">int&nbsp;sender_host_port</emphasis></term>
53926 <listitem>
53927 <para>
53928 The port on the sending host.
53929 </para>
53930 </listitem></varlistentry>
53931 <varlistentry>
53932 <term><emphasis role="bold">BOOL&nbsp;smtp_input</emphasis></term>
53933 <listitem>
53934 <para>
53935 This variable is TRUE for all SMTP input, including BSMTP.
53936 </para>
53937 </listitem></varlistentry>
53938 <varlistentry>
53939 <term><emphasis role="bold">BOOL&nbsp;smtp_batched_input</emphasis></term>
53940 <listitem>
53941 <para>
53942 This variable is TRUE for BSMTP input.
53943 </para>
53944 </listitem></varlistentry>
53945 <varlistentry>
53946 <term><emphasis role="bold">int&nbsp;store_pool</emphasis></term>
53947 <listitem>
53948 <para>
53949 The contents of this variable control which pool of memory is used for new
53950 requests. See section <xref linkend="SECTmemhanloc"/> for details.
53951 </para>
53952 </listitem></varlistentry>
53953 </variablelist>
53954 </section>
53955 <section id="SECID209">
53956 <title>Structure of header lines</title>
53957 <para>
53958 The <option>header_line</option> structure contains the members listed below.
53959 You can add additional header lines by calling the <emphasis>header_add()</emphasis> function
53960 (see below). You can cause header lines to be ignored (deleted) by setting
53961 their type to *.
53962 </para>
53963 <variablelist>
53964 <varlistentry>
53965 <term><emphasis role="bold">struct&nbsp;header_line&nbsp;*next</emphasis></term>
53966 <listitem>
53967 <para>
53968 A pointer to the next header line, or NULL for the last line.
53969 </para>
53970 </listitem></varlistentry>
53971 <varlistentry>
53972 <term><emphasis role="bold">int&nbsp;type</emphasis></term>
53973 <listitem>
53974 <para>
53975 A code identifying certain headers that Exim recognizes. The codes are printing
53976 characters, and are documented in chapter <xref linkend="CHAPspool"/> of this manual.
53977 Notice in particular that any header line whose type is * is not transmitted
53978 with the message. This flagging is used for header lines that have been
53979 rewritten, or are to be removed (for example, <emphasis>Envelope-sender:</emphasis> header
53980 lines.) Effectively, * means <quote>deleted</quote>.
53981 </para>
53982 </listitem></varlistentry>
53983 <varlistentry>
53984 <term><emphasis role="bold">int&nbsp;slen</emphasis></term>
53985 <listitem>
53986 <para>
53987 The number of characters in the header line, including the terminating and any
53988 internal newlines.
53989 </para>
53990 </listitem></varlistentry>
53991 <varlistentry>
53992 <term><emphasis role="bold">uschar&nbsp;*text</emphasis></term>
53993 <listitem>
53994 <para>
53995 A pointer to the text of the header. It always ends with a newline, followed by
53996 a zero byte. Internal newlines are preserved.
53997 </para>
53998 </listitem></varlistentry>
53999 </variablelist>
54000 </section>
54001 <section id="SECID210">
54002 <title>Structure of recipient items</title>
54003 <para>
54004 The <option>recipient_item</option> structure contains these members:
54005 </para>
54006 <variablelist>
54007 <varlistentry>
54008 <term><emphasis role="bold">uschar&nbsp;*address</emphasis></term>
54009 <listitem>
54010 <para>
54011 This is a pointer to the recipient address as it was received.
54012 </para>
54013 </listitem></varlistentry>
54014 <varlistentry>
54015 <term><emphasis role="bold">int&nbsp;pno</emphasis></term>
54016 <listitem>
54017 <para>
54018 This is used in later Exim processing when top level addresses are created by
54019 the <option>one_time</option> option. It is not relevant at the time <function>local_scan()</function> is run
54020 and must always contain -1 at this stage.
54021 </para>
54022 </listitem></varlistentry>
54023 <varlistentry>
54024 <term><emphasis role="bold">uschar&nbsp;*errors_to</emphasis></term>
54025 <listitem>
54026 <para>
54027 If this value is not NULL, bounce messages caused by failing to deliver to the
54028 recipient are sent to the address it contains. In other words, it overrides the
54029 envelope sender for this one recipient. (Compare the <option>errors_to</option> generic
54030 router option.) If a <function>local_scan()</function> function sets an <option>errors_to</option> field to
54031 an unqualified address, Exim qualifies it using the domain from
54032 <option>qualify_recipient</option>. When <function>local_scan()</function> is called, the <option>errors_to</option> field
54033 is NULL for all recipients.
54034 </para>
54035 </listitem></varlistentry>
54036 </variablelist>
54037 </section>
54038 <section id="SECID211">
54039 <title>Available Exim functions</title>
54040 <para>
54041 <indexterm role="concept">
54042 <primary><function>local_scan()</function> function</primary>
54043 <secondary>available Exim functions</secondary>
54044 </indexterm>
54045 The header <filename>local_scan.h</filename> gives you access to a number of Exim functions.
54046 These are the only ones that are guaranteed to be maintained from release to
54047 release:
54048 </para>
54049 <variablelist>
54050 <varlistentry>
54051 <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>
54052 <listitem>
54053 <para>
54054 This function creates a child process that runs the command specified by
54055 <option>argv</option>. The environment for the process is specified by <option>envp</option>, which can
54056 be NULL if no environment variables are to be passed. A new umask is supplied
54057 for the process in <option>newumask</option>.
54058 </para>
54059 <para>
54060 Pipes to the standard input and output of the new process are set up
54061 and returned to the caller via the <option>infdptr</option> and <option>outfdptr</option> arguments. The
54062 standard error is cloned to the standard output. If there are any file
54063 descriptors <quote>in the way</quote> in the new process, they are closed. If the final
54064 argument is TRUE, the new process is made into a process group leader.
54065 </para>
54066 <para>
54067 The function returns the pid of the new process, or -1 if things go wrong.
54068 </para>
54069 </listitem></varlistentry>
54070 <varlistentry>
54071 <term><emphasis role="bold">int&nbsp;child_close(pid_t&nbsp;pid,&nbsp;int&nbsp;timeout)</emphasis></term>
54072 <listitem>
54073 <para>
54074 This function waits for a child process to terminate, or for a timeout (in
54075 seconds) to expire. A timeout value of zero means wait as long as it takes. The
54076 return value is as follows:
54077 </para>
54078 <itemizedlist>
54079 <listitem>
54080 <para>
54081 &gt;= 0
54082 </para>
54083 <para>
54084 The process terminated by a normal exit and the value is the process
54085 ending status.
54086 </para>
54087 </listitem>
54088 <listitem>
54089 <para>
54090 &lt; 0 and &gt; &ndash;256
54091 </para>
54092 <para>
54093 The process was terminated by a signal and the value is the negation of the
54094 signal number.
54095 </para>
54096 </listitem>
54097 <listitem>
54098 <para>
54099 &ndash;256
54100 </para>
54101 <para>
54102 The process timed out.
54103 </para>
54104 </listitem>
54105 <listitem>
54106 <para>
54107 &ndash;257
54108 </para>
54109 <para>
54110 The was some other error in wait(); <option>errno</option> is still set.
54111 </para>
54112 </listitem>
54113 </itemizedlist>
54114 </listitem></varlistentry>
54115 <varlistentry>
54116 <term><emphasis role="bold">pid_t&nbsp;child_open_exim(int&nbsp;*fd)</emphasis></term>
54117 <listitem>
54118 <para>
54119 This function provide you with a means of submitting a new message to
54120 Exim. (Of course, you can also call <filename>/usr/sbin/sendmail</filename> yourself if you
54121 want, but this packages it all up for you.) The function creates a pipe,
54122 forks a subprocess that is running
54123 </para>
54124 <literallayout class="monospaced">
54125 exim -t -oem -oi -f &lt;&gt;
54126 </literallayout>
54127 <para>
54128 and returns to you (via the <literal>int *</literal> argument) a file descriptor for the pipe
54129 that is connected to the standard input. The yield of the function is the PID
54130 of the subprocess. You can then write a message to the file descriptor, with
54131 recipients in <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>, and/or <emphasis>Bcc:</emphasis> header lines.
54132 </para>
54133 <para>
54134 When you have finished, call <emphasis>child_close()</emphasis> to wait for the process to
54135 finish and to collect its ending status. A timeout value of zero is usually
54136 fine in this circumstance. Unless you have made a mistake with the recipient
54137 addresses, you should get a return code of zero.
54138 </para>
54139 </listitem></varlistentry>
54140 <varlistentry>
54141 <term><emphasis role="bold">pid_t&nbsp;child_open_exim2(int&nbsp;*fd,&nbsp;uschar&nbsp;*sender,&nbsp;uschar&nbsp;*sender_authentication)</emphasis></term>
54142 <listitem>
54143 <para>
54144 This function is a more sophisticated version of <emphasis>child_open()</emphasis>. The command
54145 that it runs is:
54146 </para>
54147 <literallayout>
54148 <literal>exim -t -oem -oi -f </literal><emphasis>sender</emphasis><literal> -oMas </literal><emphasis>sender_authentication</emphasis>
54149 </literallayout>
54150 <para>
54151 The third argument may be NULL, in which case the <option>-oMas</option> option is omitted.
54152 </para>
54153 </listitem></varlistentry>
54154 <varlistentry>
54155 <term><emphasis role="bold">void&nbsp;debug_printf(char&nbsp;*,&nbsp;...)</emphasis></term>
54156 <listitem>
54157 <para>
54158 This is Exim&#x2019;s debugging function, with arguments as for <emphasis>(printf()</emphasis>. The
54159 output is written to the standard error stream. If no debugging is selected,
54160 calls to <emphasis>debug_printf()</emphasis> have no effect. Normally, you should make calls
54161 conditional on the <literal>local_scan</literal> debug selector by coding like this:
54162 </para>
54163 <literallayout class="monospaced">
54164 if ((debug_selector &amp; D_local_scan) != 0)
54165   debug_printf("xxx", ...);
54166 </literallayout>
54167 </listitem></varlistentry>
54168 <varlistentry>
54169 <term><emphasis role="bold">uschar&nbsp;*expand_string(uschar&nbsp;*string)</emphasis></term>
54170 <listitem>
54171 <para>
54172 This is an interface to Exim&#x2019;s string expansion code. The return value is the
54173 expanded string, or NULL if there was an expansion failure.
54174 The C variable <option>expand_string_message</option> contains an error message after an
54175 expansion failure. If expansion does not change the string, the return value is
54176 the pointer to the input string. Otherwise, the return value points to a new
54177 block of memory that was obtained by a call to <emphasis>store_get()</emphasis>. See section
54178 <xref linkend="SECTmemhanloc"/> below for a discussion of memory handling.
54179 </para>
54180 </listitem></varlistentry>
54181 <varlistentry>
54182 <term><emphasis role="bold">void&nbsp;header_add(int&nbsp;type,&nbsp;char&nbsp;*format,&nbsp;...)</emphasis></term>
54183 <listitem>
54184 <para>
54185 This function allows you to an add additional header line at the end of the
54186 existing ones. The first argument is the type, and should normally be a space
54187 character. The second argument is a format string and any number of
54188 substitution arguments as for <function>sprintf()</function>. You may include internal newlines
54189 if you want, and you must ensure that the string ends with a newline.
54190 </para>
54191 </listitem></varlistentry>
54192 <varlistentry>
54193 <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>
54194 <listitem>
54195 <para>
54196 This function adds a new header line at a specified point in the header
54197 chain. The header itself is specified as for <emphasis>header_add()</emphasis>.
54198 </para>
54199 <para>
54200 If <option>name</option> is NULL, the new header is added at the end of the chain if
54201 <option>after</option> is true, or at the start if <option>after</option> is false. If <option>name</option> is not
54202 NULL, the header lines are searched for the first non-deleted header that
54203 matches the name. If one is found, the new header is added before it if
54204 <option>after</option> is false. If <option>after</option> is true, the new header is added after the
54205 found header and any adjacent subsequent ones with the same name (even if
54206 marked <quote>deleted</quote>). If no matching non-deleted header is found, the <option>topnot</option>
54207 option controls where the header is added. If it is true, addition is at the
54208 top; otherwise at the bottom. Thus, to add a header after all the <emphasis>Received:</emphasis>
54209 headers, or at the top if there are no <emphasis>Received:</emphasis> headers, you could use
54210 </para>
54211 <literallayout class="monospaced">
54212 header_add_at_position(TRUE, US"Received", TRUE,
54213   ' ', "X-xxx: ...");
54214 </literallayout>
54215 <para>
54216 Normally, there is always at least one non-deleted <emphasis>Received:</emphasis> header, but
54217 there may not be if <option>received_header_text</option> expands to an empty string.
54218 </para>
54219 </listitem></varlistentry>
54220 <varlistentry>
54221 <term><emphasis role="bold">void&nbsp;header_remove(int&nbsp;occurrence,&nbsp;uschar&nbsp;*name)</emphasis></term>
54222 <listitem>
54223 <para>
54224 This function removes header lines. If <option>occurrence</option> is zero or negative, all
54225 occurrences of the header are removed. If occurrence is greater than zero, that
54226 particular instance of the header is removed. If no header(s) can be found that
54227 match the specification, the function does nothing.
54228 </para>
54229 </listitem></varlistentry>
54230 <varlistentry>
54231 <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>
54232 <listitem>
54233 <para>
54234 This function tests whether the given header has the given name. It is not just
54235 a string comparison, because white space is permitted between the name and the
54236 colon. If the <option>notdel</option> argument is true, a false return is forced for all
54237 <quote>deleted</quote> headers; otherwise they are not treated specially. For example:
54238 </para>
54239 <literallayout class="monospaced">
54240 if (header_testname(h, US"X-Spam", 6, TRUE)) ...
54241 </literallayout>
54242 </listitem></varlistentry>
54243 <varlistentry>
54244 <term><emphasis role="bold">uschar&nbsp;*lss_b64encode(uschar&nbsp;*cleartext,&nbsp;int&nbsp;length)</emphasis></term>
54245 <listitem>
54246 <para>
54247 <indexterm role="concept">
54248 <primary>base64 encoding</primary>
54249 <secondary>functions for <function>local_scan()</function> use</secondary>
54250 </indexterm>
54251 This function base64-encodes a string, which is passed by address and length.
54252 The text may contain bytes of any value, including zero. The result is passed
54253 back in dynamic memory that is obtained by calling <emphasis>store_get()</emphasis>. It is
54254 zero-terminated.
54255 </para>
54256 </listitem></varlistentry>
54257 <varlistentry>
54258 <term><emphasis role="bold">int&nbsp;lss_b64decode(uschar&nbsp;*codetext,&nbsp;uschar&nbsp;**cleartext)</emphasis></term>
54259 <listitem>
54260 <para>
54261 This function decodes a base64-encoded string. Its arguments are a
54262 zero-terminated base64-encoded string and the address of a variable that is set
54263 to point to the result, which is in dynamic memory. The length of the decoded
54264 string is the yield of the function. If the input is invalid base64 data, the
54265 yield is -1. A zero byte is added to the end of the output string to make it
54266 easy to interpret as a C string (assuming it contains no zeros of its own). The
54267 added zero byte is not included in the returned count.
54268 </para>
54269 </listitem></varlistentry>
54270 <varlistentry>
54271 <term><emphasis role="bold">int&nbsp;lss_match_domain(uschar&nbsp;*domain,&nbsp;uschar&nbsp;*list)</emphasis></term>
54272 <listitem>
54273 <para>
54274 This function checks for a match in a domain list. Domains are always
54275 matched caselessly. The return value is one of the following:
54276 </para>
54277 <literallayout>
54278 <literal>OK     </literal> match succeeded
54279 <literal>FAIL   </literal> match failed
54280 <literal>DEFER  </literal> match deferred
54281 </literallayout>
54282 <para>
54283 DEFER is usually caused by some kind of lookup defer, such as the
54284 inability to contact a database.
54285 </para>
54286 </listitem></varlistentry>
54287 <varlistentry>
54288 <term><emphasis role="bold">int&nbsp;lss_match_local_part(uschar&nbsp;*localpart,&nbsp;uschar&nbsp;*list,&nbsp;BOOL&nbsp;caseless)</emphasis></term>
54289 <listitem>
54290 <para>
54291 This function checks for a match in a local part list. The third argument
54292 controls case-sensitivity. The return values are as for
54293 <emphasis>lss_match_domain()</emphasis>.
54294 </para>
54295 </listitem></varlistentry>
54296 <varlistentry>
54297 <term><emphasis role="bold">int&nbsp;lss_match_address(uschar&nbsp;*address,&nbsp;uschar&nbsp;*list,&nbsp;BOOL&nbsp;caseless)</emphasis></term>
54298 <listitem>
54299 <para>
54300 This function checks for a match in an address list. The third argument
54301 controls the case-sensitivity of the local part match. The domain is always
54302 matched caselessly. The return values are as for <emphasis>lss_match_domain()</emphasis>.
54303 </para>
54304 </listitem></varlistentry>
54305 <varlistentry>
54306 <term><emphasis role="bold">int&nbsp;lss_match_host(uschar&nbsp;*host_name,&nbsp;uschar&nbsp;*host_address,&nbsp;uschar&nbsp;*list)</emphasis></term>
54307 <listitem>
54308 <para>
54309 This function checks for a match in a host list. The most common usage is
54310 expected to be
54311 </para>
54312 <literallayout class="monospaced">
54313 lss_match_host(sender_host_name, sender_host_address, ...)
54314 </literallayout>
54315 <para>
54316 <indexterm role="variable">
54317 <primary><varname>$sender_host_address</varname></primary>
54318 </indexterm>
54319 An empty address field matches an empty item in the host list. If the host name
54320 is NULL, the name corresponding to <varname>$sender_host_address</varname> is automatically
54321 looked up if a host name is required to match an item in the list. The return
54322 values are as for <emphasis>lss_match_domain()</emphasis>, but in addition, <emphasis>lss_match_host()</emphasis>
54323 returns ERROR in the case when it had to look up a host name, but the lookup
54324 failed.
54325 </para>
54326 </listitem></varlistentry>
54327 <varlistentry>
54328 <term><emphasis role="bold">void&nbsp;log_write(unsigned&nbsp;int&nbsp;selector,&nbsp;int&nbsp;which,&nbsp;char&nbsp;*format,&nbsp;...)</emphasis></term>
54329 <listitem>
54330 <para>
54331 This function writes to Exim&#x2019;s log files. The first argument should be zero (it
54332 is concerned with <option>log_selector</option>). The second argument can be <literal>LOG_MAIN</literal> or
54333 <literal>LOG_REJECT</literal> or <literal>LOG_PANIC</literal> or the inclusive <quote>or</quote> of any combination of
54334 them. It specifies to which log or logs the message is written. The remaining
54335 arguments are a format and relevant insertion arguments. The string should not
54336 contain any newlines, not even at the end.
54337 </para>
54338 </listitem></varlistentry>
54339 <varlistentry>
54340 <term><emphasis role="bold">void&nbsp;receive_add_recipient(uschar&nbsp;*address,&nbsp;int&nbsp;pno)</emphasis></term>
54341 <listitem>
54342 <para>
54343 This function adds an additional recipient to the message. The first argument
54344 is the recipient address. If it is unqualified (has no domain), it is qualified
54345 with the <option>qualify_recipient</option> domain. The second argument must always be -1.
54346 </para>
54347 <para>
54348 This function does not allow you to specify a private <option>errors_to</option> address (as
54349 described with the structure of <option>recipient_item</option> above), because it pre-dates
54350 the addition of that field to the structure. However, it is easy to add such a
54351 value afterwards. For example:
54352 </para>
54353 <literallayout class="monospaced">
54354  receive_add_recipient(US"monitor@mydom.example", -1);
54355  recipients_list[recipients_count-1].errors_to =
54356    US"postmaster@mydom.example";
54357 </literallayout>
54358 </listitem></varlistentry>
54359 <varlistentry>
54360 <term><emphasis role="bold">BOOL&nbsp;receive_remove_recipient(uschar&nbsp;*recipient)</emphasis></term>
54361 <listitem>
54362 <para>
54363 This is a convenience function to remove a named recipient from the list of
54364 recipients. It returns true if a recipient was removed, and false if no
54365 matching recipient could be found. The argument must be a complete email
54366 address.
54367 </para>
54368 </listitem></varlistentry>
54369 </variablelist>
54370 <para>
54371 <indexterm role="concept">
54372 <primary>RFC 2047</primary>
54373 </indexterm>
54374 </para>
54375 <variablelist>
54376 <varlistentry>
54377 <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>
54378 <listitem>
54379 <para>
54380 This function decodes strings that are encoded according to RFC 2047. Typically
54381 these are the contents of header lines. First, each <quote>encoded word</quote> is decoded
54382 from the Q or B encoding into a byte-string. Then, if provided with the name of
54383 a charset encoding, and if the <function>iconv()</function> function is available, an attempt is
54384 made  to translate the result to the named character set. If this fails, the
54385 binary string is returned with an error message.
54386 </para>
54387 <para>
54388 The first argument is the string to be decoded. If <option>lencheck</option> is TRUE, the
54389 maximum MIME word length is enforced. The third argument is the target
54390 encoding, or NULL if no translation is wanted.
54391 </para>
54392 <para>
54393 <indexterm role="concept">
54394 <primary>binary zero</primary>
54395 <secondary>in RFC 2047 decoding</secondary>
54396 </indexterm>
54397 <indexterm role="concept">
54398 <primary>RFC 2047</primary>
54399 <secondary>binary zero in</secondary>
54400 </indexterm>
54401 If a binary zero is encountered in the decoded string, it is replaced by the
54402 contents of the <option>zeroval</option> argument. For use with Exim headers, the value must
54403 not be 0 because header lines are handled as zero-terminated strings.
54404 </para>
54405 <para>
54406 The function returns the result of processing the string, zero-terminated; if
54407 <option>lenptr</option> is not NULL, the length of the result is set in the variable to
54408 which it points. When <option>zeroval</option> is 0, <option>lenptr</option> should not be NULL.
54409 </para>
54410 <para>
54411 If an error is encountered, the function returns NULL and uses the <option>error</option>
54412 argument to return an error message. The variable pointed to by <option>error</option> is
54413 set to NULL if there is no error; it may be set non-NULL even when the function
54414 returns a non-NULL value if decoding was successful, but there was a problem
54415 with translation.
54416 </para>
54417 </listitem></varlistentry>
54418 <varlistentry>
54419 <term><emphasis role="bold">int&nbsp;smtp_fflush(void)</emphasis></term>
54420 <listitem>
54421 <para>
54422 This function is used in conjunction with <emphasis>smtp_printf()</emphasis>, as described
54423 below.
54424 </para>
54425 </listitem></varlistentry>
54426 <varlistentry>
54427 <term><emphasis role="bold">void&nbsp;smtp_printf(char&nbsp;*,&nbsp;...)</emphasis></term>
54428 <listitem>
54429 <para>
54430 The arguments of this function are like <function>printf()</function>; it writes to the SMTP
54431 output stream. You should use this function only when there is an SMTP output
54432 stream, that is, when the incoming message is being received via interactive
54433 SMTP. This is the case when <option>smtp_input</option> is TRUE and <option>smtp_batched_input</option>
54434 is FALSE. If you want to test for an incoming message from another host (as
54435 opposed to a local process that used the <option>-bs</option> command line option), you can
54436 test the value of <option>sender_host_address</option>, which is non-NULL when a remote host
54437 is involved.
54438 </para>
54439 <para>
54440 If an SMTP TLS connection is established, <emphasis>smtp_printf()</emphasis> uses the TLS
54441 output function, so it can be used for all forms of SMTP connection.
54442 </para>
54443 <para>
54444 Strings that are written by <emphasis>smtp_printf()</emphasis> from within <function>local_scan()</function>
54445 must start with an appropriate response code: 550 if you are going to return
54446 LOCAL_SCAN_REJECT, 451 if you are going to return
54447 LOCAL_SCAN_TEMPREJECT, and 250 otherwise. Because you are writing the
54448 initial lines of a multi-line response, the code must be followed by a hyphen
54449 to indicate that the line is not the final response line. You must also ensure
54450 that the lines you write terminate with CRLF. For example:
54451 </para>
54452 <literallayout class="monospaced">
54453 smtp_printf("550-this is some extra info\r\n");
54454 return LOCAL_SCAN_REJECT;
54455 </literallayout>
54456 <para>
54457 Note that you can also create multi-line responses by including newlines in
54458 the data returned via the <option>return_text</option> argument. The added value of using
54459 <emphasis>smtp_printf()</emphasis> is that, for instance, you could introduce delays between
54460 multiple output lines.
54461 </para>
54462 <para>
54463 The <emphasis>smtp_printf()</emphasis> function does not return any error indication, because it
54464 does not automatically flush pending output, and therefore does not test
54465 the state of the stream. (In the main code of Exim, flushing and error
54466 detection is done when Exim is ready for the next SMTP input command.) If
54467 you want to flush the output and check for an error (for example, the
54468 dropping of a TCP/IP connection), you can call <emphasis>smtp_fflush()</emphasis>, which has no
54469 arguments. It flushes the output stream, and returns a non-zero value if there
54470 is an error.
54471 </para>
54472 </listitem></varlistentry>
54473 <varlistentry>
54474 <term><emphasis role="bold">void&nbsp;*store_get(int)</emphasis></term>
54475 <listitem>
54476 <para>
54477 This function accesses Exim&#x2019;s internal store (memory) manager. It gets a new
54478 chunk of memory whose size is given by the argument. Exim bombs out if it ever
54479 runs out of memory. See the next section for a discussion of memory handling.
54480 </para>
54481 </listitem></varlistentry>
54482 <varlistentry>
54483 <term><emphasis role="bold">void&nbsp;*store_get_perm(int)</emphasis></term>
54484 <listitem>
54485 <para>
54486 This function is like <emphasis>store_get()</emphasis>, but it always gets memory from the
54487 permanent pool. See the next section for a discussion of memory handling.
54488 </para>
54489 </listitem></varlistentry>
54490 <varlistentry>
54491 <term><emphasis role="bold">uschar&nbsp;*string_copy(uschar&nbsp;*string)</emphasis></term>
54492 <listitem>
54493 <para>
54494 See below.
54495 </para>
54496 </listitem></varlistentry>
54497 <varlistentry>
54498 <term><emphasis role="bold">uschar&nbsp;*string_copyn(uschar&nbsp;*string,&nbsp;int&nbsp;length)</emphasis></term>
54499 <listitem>
54500 <para>
54501 See below.
54502 </para>
54503 </listitem></varlistentry>
54504 <varlistentry>
54505 <term><emphasis role="bold">uschar&nbsp;*string_sprintf(char&nbsp;*format,&nbsp;...)</emphasis></term>
54506 <listitem>
54507 <para>
54508 These three functions create strings using Exim&#x2019;s dynamic memory facilities.
54509 The first makes a copy of an entire string. The second copies up to a maximum
54510 number of characters, indicated by the second argument. The third uses a format
54511 and insertion arguments to create a new string. In each case, the result is a
54512 pointer to a new string in the current memory pool. See the next section for
54513 more discussion.
54514 </para>
54515 </listitem></varlistentry>
54516 </variablelist>
54517 </section>
54518 <section id="SECTmemhanloc">
54519 <title>More about Exim&#x2019;s memory handling</title>
54520 <para>
54521 <indexterm role="concept">
54522 <primary><function>local_scan()</function> function</primary>
54523 <secondary>memory handling</secondary>
54524 </indexterm>
54525 No function is provided for freeing memory, because that is never needed.
54526 The dynamic memory that Exim uses when receiving a message is automatically
54527 recycled if another message is received by the same process (this applies only
54528 to incoming SMTP connections &ndash; other input methods can supply only one
54529 message at a time). After receiving the last message, a reception process
54530 terminates.
54531 </para>
54532 <para>
54533 Because it is recycled, the normal dynamic memory cannot be used for holding
54534 data that must be preserved over a number of incoming messages on the same SMTP
54535 connection. However, Exim in fact uses two pools of dynamic memory; the second
54536 one is not recycled, and can be used for this purpose.
54537 </para>
54538 <para>
54539 If you want to allocate memory that remains available for subsequent messages
54540 in the same SMTP connection, you should set
54541 </para>
54542 <literallayout class="monospaced">
54543 store_pool = POOL_PERM
54544 </literallayout>
54545 <para>
54546 before calling the function that does the allocation. There is no need to
54547 restore the value if you do not need to; however, if you do want to revert to
54548 the normal pool, you can either restore the previous value of <option>store_pool</option> or
54549 set it explicitly to POOL_MAIN.
54550 </para>
54551 <para>
54552 The pool setting applies to all functions that get dynamic memory, including
54553 <emphasis>expand_string()</emphasis>, <emphasis>store_get()</emphasis>, and the <emphasis>string_xxx()</emphasis> functions.
54554 There is also a convenience function called <emphasis>store_get_perm()</emphasis> that gets a
54555 block of memory from the permanent pool while preserving the value of
54556 <option>store_pool</option>.
54557 <indexterm role="concept" startref="IIDlosca" class="endofrange"/>
54558 </para>
54559 </section>
54560 </chapter>
54561
54562 <chapter id="CHAPsystemfilter">
54563 <title>System-wide message filtering</title>
54564 <para>
54565 <indexterm role="concept" id="IIDsysfil1" class="startofrange">
54566 <primary>filter</primary>
54567 <secondary>system filter</secondary>
54568 </indexterm>
54569 <indexterm role="concept" id="IIDsysfil2" class="startofrange">
54570 <primary>filtering all mail</primary>
54571 </indexterm>
54572 <indexterm role="concept" id="IIDsysfil3" class="startofrange">
54573 <primary>system filter</primary>
54574 </indexterm>
54575 The previous chapters (on ACLs and the local scan function) describe checks
54576 that can be applied to messages before they are accepted by a host. There is
54577 also a mechanism for checking messages once they have been received, but before
54578 they are delivered. This is called the <emphasis>system filter</emphasis>.
54579 </para>
54580 <para>
54581 The system filter operates in a similar manner to users&#x2019; filter files, but it
54582 is run just once per message (however many recipients the message has).
54583 It should not normally be used as a substitute for routing, because <option>deliver</option>
54584 commands in a system router provide new envelope recipient addresses.
54585 The system filter must be an Exim filter. It cannot be a Sieve filter.
54586 </para>
54587 <para>
54588 The system filter is run at the start of a delivery attempt, before any routing
54589 is done. If a message fails to be completely delivered at the first attempt,
54590 the system filter is run again at the start of every retry.
54591 If you want your filter to do something only once per message, you can make use
54592 of the <option>first_delivery</option> condition in an <option>if</option> command in the filter to
54593 prevent it happening on retries.
54594 </para>
54595 <para>
54596 <indexterm role="variable">
54597 <primary><varname>$domain</varname></primary>
54598 </indexterm>
54599 <indexterm role="variable">
54600 <primary><varname>$local_part</varname></primary>
54601 </indexterm>
54602 <emphasis role="bold">Warning</emphasis>: Because the system filter runs just once, variables that are
54603 specific to individual recipient addresses, such as <varname>$local_part</varname> and
54604 <varname>$domain</varname>, are not set, and the <quote>personal</quote> condition is not meaningful. If
54605 you want to run a centrally-specified filter for each recipient address
54606 independently, you can do so by setting up a suitable <command>redirect</command> router, as
54607 described in section <xref linkend="SECTperaddfil"/> below.
54608 </para>
54609 <section id="SECID212">
54610 <title>Specifying a system filter</title>
54611 <para>
54612 <indexterm role="concept">
54613 <primary>uid (user id)</primary>
54614 <secondary>system filter</secondary>
54615 </indexterm>
54616 <indexterm role="concept">
54617 <primary>gid (group id)</primary>
54618 <secondary>system filter</secondary>
54619 </indexterm>
54620 The name of the file that contains the system filter must be specified by
54621 setting <option>system_filter</option>. If you want the filter to run under a uid and gid
54622 other than root, you must also set <option>system_filter_user</option> and
54623 <option>system_filter_group</option> as appropriate. For example:
54624 </para>
54625 <literallayout class="monospaced">
54626 system_filter = /etc/mail/exim.filter
54627 system_filter_user = exim
54628 </literallayout>
54629 <para>
54630 If a system filter generates any deliveries directly to files or pipes (via the
54631 <option>save</option> or <option>pipe</option> commands), transports to handle these deliveries must be
54632 specified by setting <option>system_filter_file_transport</option> and
54633 <option>system_filter_pipe_transport</option>, respectively. Similarly,
54634 <option>system_filter_reply_transport</option> must be set to handle any messages generated
54635 by the <option>reply</option> command.
54636 </para>
54637 </section>
54638 <section id="SECID213">
54639 <title>Testing a system filter</title>
54640 <para>
54641 You can run simple tests of a system filter in the same way as for a user
54642 filter, but you should use <option>-bF</option> rather than <option>-bf</option>, so that features that
54643 are permitted only in system filters are recognized.
54644 </para>
54645 <para>
54646 If you want to test the combined effect of a system filter and a user filter,
54647 you can use both <option>-bF</option> and <option>-bf</option> on the same command line.
54648 </para>
54649 </section>
54650 <section id="SECID214">
54651 <title>Contents of a system filter</title>
54652 <para>
54653 The language used to specify system filters is the same as for users&#x2019; filter
54654 files. It is described in the separate end-user document <emphasis>Exim&#x2019;s interface to
54655 mail filtering</emphasis>. However, there are some additional features that are
54656 available only in system filters; these are described in subsequent sections.
54657 If they are encountered in a user&#x2019;s filter file or when testing with <option>-bf</option>,
54658 they cause errors.
54659 </para>
54660 <para>
54661 <indexterm role="concept">
54662 <primary>frozen messages</primary>
54663 <secondary>manual thaw; testing in filter</secondary>
54664 </indexterm>
54665 There are two special conditions which, though available in users&#x2019; filter
54666 files, are designed for use in system filters. The condition <option>first_delivery</option>
54667 is true only for the first attempt at delivering a message, and
54668 <option>manually_thawed</option> is true only if the message has been frozen, and
54669 subsequently thawed by an admin user. An explicit forced delivery counts as a
54670 manual thaw, but thawing as a result of the <option>auto_thaw</option> setting does not.
54671 </para>
54672 <para>
54673 <emphasis role="bold">Warning</emphasis>: If a system filter uses the <option>first_delivery</option> condition to
54674 specify an <quote>unseen</quote> (non-significant) delivery, and that delivery does not
54675 succeed, it will not be tried again.
54676 If you want Exim to retry an unseen delivery until it succeeds, you should
54677 arrange to set it up every time the filter runs.
54678 </para>
54679 <para>
54680 When a system filter finishes running, the values of the variables <varname>$n0</varname> &ndash;
54681 <varname>$n9</varname> are copied into <varname>$sn0</varname> &ndash; <varname>$sn9</varname> and are thereby made available to
54682 users&#x2019; filter files. Thus a system filter can, for example, set up <quote>scores</quote>
54683 to which users&#x2019; filter files can refer.
54684 </para>
54685 </section>
54686 <section id="SECID215">
54687 <title>Additional variable for system filters</title>
54688 <para>
54689 <indexterm role="variable">
54690 <primary><varname>$recipients</varname></primary>
54691 </indexterm>
54692 The expansion variable <varname>$recipients</varname>, containing a list of all the recipients
54693 of the message (separated by commas and white space), is available in system
54694 filters. It is not available in users&#x2019; filters for privacy reasons.
54695 </para>
54696 </section>
54697 <section id="SECID216">
54698 <title>Defer, freeze, and fail commands for system filters</title>
54699 <para>
54700 <indexterm role="concept">
54701 <primary>freezing messages</primary>
54702 </indexterm>
54703 <indexterm role="concept">
54704 <primary>message</primary>
54705 <secondary>freezing</secondary>
54706 </indexterm>
54707 <indexterm role="concept">
54708 <primary>message</primary>
54709 <secondary>forced failure</secondary>
54710 </indexterm>
54711 <indexterm role="concept">
54712 <primary><option>fail</option></primary>
54713 <secondary>in system filter</secondary>
54714 </indexterm>
54715 <indexterm role="concept">
54716 <primary><option>freeze</option> in system filter</primary>
54717 </indexterm>
54718 <indexterm role="concept">
54719 <primary><option>defer</option> in system filter</primary>
54720 </indexterm>
54721 There are three extra commands (<option>defer</option>, <option>freeze</option> and <option>fail</option>) which are
54722 always available in system filters, but are not normally enabled in users&#x2019;
54723 filters. (See the <option>allow_defer</option>, <option>allow_freeze</option> and <option>allow_fail</option> options
54724 for the <command>redirect</command> router.) These commands can optionally be followed by the
54725 word <option>text</option> and a string containing an error message, for example:
54726 </para>
54727 <literallayout class="monospaced">
54728 fail text "this message looks like spam to me"
54729 </literallayout>
54730 <para>
54731 The keyword <option>text</option> is optional if the next character is a double quote.
54732 </para>
54733 <para>
54734 The <option>defer</option> command defers delivery of the original recipients of the
54735 message. The <option>fail</option> command causes all the original recipients to be failed,
54736 and a bounce message to be created. The <option>freeze</option> command suspends all
54737 delivery attempts for the original recipients. In all cases, any new deliveries
54738 that are specified by the filter are attempted as normal after the filter has
54739 run.
54740 </para>
54741 <para>
54742 The <option>freeze</option> command is ignored if the message has been manually unfrozen and
54743 not manually frozen since. This means that automatic freezing by a system
54744 filter can be used as a way of checking out suspicious messages. If a message
54745 is found to be all right, manually unfreezing it allows it to be delivered.
54746 </para>
54747 <para>
54748 <indexterm role="concept">
54749 <primary>log</primary>
54750 <secondary><option>fail</option> command log line</secondary>
54751 </indexterm>
54752 <indexterm role="concept">
54753 <primary><option>fail</option></primary>
54754 <secondary>log line; reducing</secondary>
54755 </indexterm>
54756 The text given with a fail command is used as part of the bounce message as
54757 well as being written to the log. If the message is quite long, this can fill
54758 up a lot of log space when such failures are common. To reduce the size of the
54759 log message, Exim interprets the text in a special way if it starts with the
54760 two characters <literal>&lt;&lt;</literal> and contains <literal>&gt;&gt;</literal> later. The text between these two
54761 strings is written to the log, and the rest of the text is used in the bounce
54762 message. For example:
54763 </para>
54764 <literallayout class="monospaced">
54765 fail "&lt;&lt;filter test 1&gt;&gt;Your message is rejected \
54766      because it contains attachments that we are \
54767      not prepared to receive."
54768 </literallayout>
54769 <para>
54770 <indexterm role="concept">
54771 <primary>loop</primary>
54772 <secondary>caused by <option>fail</option></secondary>
54773 </indexterm>
54774 Take great care with the <option>fail</option> command when basing the decision to fail on
54775 the contents of the message, because the bounce message will of course include
54776 the contents of the original message and will therefore trigger the <option>fail</option>
54777 command again (causing a mail loop) unless steps are taken to prevent this.
54778 Testing the <option>error_message</option> condition is one way to prevent this. You could
54779 use, for example
54780 </para>
54781 <literallayout class="monospaced">
54782 if $message_body contains "this is spam" and not error_message
54783 then fail text "spam is not wanted here" endif
54784 </literallayout>
54785 <para>
54786 though of course that might let through unwanted bounce messages. The
54787 alternative is clever checking of the body and/or headers to detect bounces
54788 generated by the filter.
54789 </para>
54790 <para>
54791 The interpretation of a system filter file ceases after a
54792 <option>defer</option>,
54793 <option>freeze</option>, or <option>fail</option> command is obeyed. However, any deliveries that were
54794 set up earlier in the filter file are honoured, so you can use a sequence such
54795 as
54796 </para>
54797 <literallayout class="monospaced">
54798 mail ...
54799 freeze
54800 </literallayout>
54801 <para>
54802 to send a specified message when the system filter is freezing (or deferring or
54803 failing) a message. The normal deliveries for the message do not, of course,
54804 take place.
54805 </para>
54806 </section>
54807 <section id="SECTaddremheasys">
54808 <title>Adding and removing headers in a system filter</title>
54809 <para>
54810 <indexterm role="concept">
54811 <primary>header lines</primary>
54812 <secondary>adding; in system filter</secondary>
54813 </indexterm>
54814 <indexterm role="concept">
54815 <primary>header lines</primary>
54816 <secondary>removing; in system filter</secondary>
54817 </indexterm>
54818 <indexterm role="concept">
54819 <primary>filter</primary>
54820 <secondary>header lines; adding/removing</secondary>
54821 </indexterm>
54822 Two filter commands that are available only in system filters are:
54823 </para>
54824 <literallayout class="monospaced">
54825 headers add &lt;string&gt;
54826 headers remove &lt;string&gt;
54827 </literallayout>
54828 <para>
54829 The argument for the <option>headers add</option> is a string that is expanded and then
54830 added to the end of the message&#x2019;s headers. It is the responsibility of the
54831 filter maintainer to make sure it conforms to RFC 2822 syntax. Leading white
54832 space is ignored, and if the string is otherwise empty, or if the expansion is
54833 forced to fail, the command has no effect.
54834 </para>
54835 <para>
54836 You can use <quote>\n</quote> within the string, followed by white space, to specify
54837 continued header lines. More than one header may be added in one command by
54838 including <quote>\n</quote> within the string without any following white space. For
54839 example:
54840 </para>
54841 <literallayout class="monospaced">
54842 headers add "X-header-1: ....\n  \
54843              continuation of X-header-1 ...\n\
54844              X-header-2: ...."
54845 </literallayout>
54846 <para>
54847 Note that the header line continuation white space after the first newline must
54848 be placed before the backslash that continues the input string, because white
54849 space after input continuations is ignored.
54850 </para>
54851 <para>
54852 The argument for <option>headers remove</option> is a colon-separated list of header names.
54853 This command applies only to those headers that are stored with the message;
54854 those that are added at delivery time (such as <emphasis>Envelope-To:</emphasis> and
54855 <emphasis>Return-Path:</emphasis>) cannot be removed by this means. If there is more than one
54856 header with the same name, they are all removed.
54857 </para>
54858 <para>
54859 The <option>headers</option> command in a system filter makes an immediate change to the set
54860 of header lines that was received with the message (with possible additions
54861 from ACL processing). Subsequent commands in the system filter operate on the
54862 modified set, which also forms the basis for subsequent message delivery.
54863 Unless further modified during routing or transporting, this set of headers is
54864 used for all recipients of the message.
54865 </para>
54866 <para>
54867 During routing and transporting, the variables that refer to the contents of
54868 header lines refer only to those lines that are in this set. Thus, header lines
54869 that are added by a system filter are visible to users&#x2019; filter files and to all
54870 routers and transports. This contrasts with the manipulation of header lines by
54871 routers and transports, which is not immediate, but which instead is saved up
54872 until the message is actually being written (see section
54873 <xref linkend="SECTheadersaddrem"/>).
54874 </para>
54875 <para>
54876 If the message is not delivered at the first attempt, header lines that were
54877 added by the system filter are stored with the message, and so are still
54878 present at the next delivery attempt. Header lines that were removed are still
54879 present, but marked <quote>deleted</quote> so that they are not transported with the
54880 message. For this reason, it is usual to make the <option>headers</option> command
54881 conditional on <option>first_delivery</option> so that the set of header lines is not
54882 modified more than once.
54883 </para>
54884 <para>
54885 Because header modification in a system filter acts immediately, you have to
54886 use an indirect approach if you want to modify the contents of a header line.
54887 For example:
54888 </para>
54889 <literallayout class="monospaced">
54890 headers add "Old-Subject: $h_subject:"
54891 headers remove "Subject"
54892 headers add "Subject: new subject (was: $h_old-subject:)"
54893 headers remove "Old-Subject"
54894 </literallayout>
54895 </section>
54896 <section id="SECID217">
54897 <title>Setting an errors address in a system filter</title>
54898 <para>
54899 <indexterm role="concept">
54900 <primary>envelope sender</primary>
54901 </indexterm>
54902 In a system filter, if a <option>deliver</option> command is followed by
54903 </para>
54904 <literallayout class="monospaced">
54905 errors_to &lt;some address&gt;
54906 </literallayout>
54907 <para>
54908 in order to change the envelope sender (and hence the error reporting) for that
54909 delivery, any address may be specified. (In a user filter, only the current
54910 user&#x2019;s address can be set.) For example, if some mail is being monitored, you
54911 might use
54912 </para>
54913 <literallayout class="monospaced">
54914 unseen deliver monitor@spying.example errors_to root@local.example
54915 </literallayout>
54916 <para>
54917 to take a copy which would not be sent back to the normal error reporting
54918 address if its delivery failed.
54919 </para>
54920 </section>
54921 <section id="SECTperaddfil">
54922 <title>Per-address filtering</title>
54923 <para>
54924 <indexterm role="variable">
54925 <primary><varname>$domain</varname></primary>
54926 </indexterm>
54927 <indexterm role="variable">
54928 <primary><varname>$local_part</varname></primary>
54929 </indexterm>
54930 In contrast to the system filter, which is run just once per message for each
54931 delivery attempt, it is also possible to set up a system-wide filtering
54932 operation that runs once for each recipient address. In this case, variables
54933 such as <varname>$local_part</varname> and <varname>$domain</varname> can be used, and indeed, the choice of
54934 filter file could be made dependent on them. This is an example of a router
54935 which implements such a filter:
54936 </para>
54937 <literallayout class="monospaced">
54938 central_filter:
54939   check_local_user
54940   driver = redirect
54941   domains = +local_domains
54942   file = /central/filters/$local_part
54943   no_verify
54944   allow_filter
54945   allow_freeze
54946 </literallayout>
54947 <para>
54948 The filter is run in a separate process under its own uid. Therefore, either
54949 <option>check_local_user</option> must be set (as above), in which case the filter is run as
54950 the local user, or the <option>user</option> option must be used to specify which user to
54951 use. If both are set, <option>user</option> overrides.
54952 </para>
54953 <para>
54954 Care should be taken to ensure that none of the commands in the filter file
54955 specify a significant delivery if the message is to go on to be delivered to
54956 its intended recipient. The router will not then claim to have dealt with the
54957 address, so it will be passed on to subsequent routers to be delivered in the
54958 normal way.
54959 <indexterm role="concept" startref="IIDsysfil1" class="endofrange"/>
54960 <indexterm role="concept" startref="IIDsysfil2" class="endofrange"/>
54961 <indexterm role="concept" startref="IIDsysfil3" class="endofrange"/>
54962 </para>
54963 </section>
54964 </chapter>
54965
54966 <chapter id="CHAPmsgproc">
54967 <title>Message processing</title>
54968 <para>
54969 <indexterm role="concept" id="IIDmesproc" class="startofrange">
54970 <primary>message</primary>
54971 <secondary>general processing</secondary>
54972 </indexterm>
54973 Exim performs various transformations on the sender and recipient addresses of
54974 all messages that it handles, and also on the messages&#x2019; header lines. Some of
54975 these are optional and configurable, while others always take place. All of
54976 this processing, except rewriting as a result of routing, and the addition or
54977 removal of header lines while delivering, happens when a message is received,
54978 before it is placed on Exim&#x2019;s queue.
54979 </para>
54980 <para>
54981 Some of the automatic processing takes place by default only for
54982 <quote>locally-originated</quote> messages. This adjective is used to describe messages
54983 that are not received over TCP/IP, but instead are passed to an Exim process on
54984 its standard input. This includes the interactive <quote>local SMTP</quote> case that is
54985 set up by the <option>-bs</option> command line option.
54986 </para>
54987 <para>
54988 <emphasis role="bold">Note</emphasis>: Messages received over TCP/IP on the loopback interface (127.0.0.1
54989 or ::1) are not considered to be locally-originated. Exim does not treat the
54990 loopback interface specially in any way.
54991 </para>
54992 <para>
54993 If you want the loopback interface to be treated specially, you must ensure
54994 that there are appropriate entries in your ACLs.
54995 </para>
54996 <section id="SECTsubmodnon">
54997 <title>Submission mode for non-local messages</title>
54998 <para>
54999 <indexterm role="concept">
55000 <primary>message</primary>
55001 <secondary>submission</secondary>
55002 </indexterm>
55003 <indexterm role="concept">
55004 <primary>submission mode</primary>
55005 </indexterm>
55006 Processing that happens automatically for locally-originated messages (unless
55007 <option>suppress_local_fixups</option> is set) can also be requested for messages that are
55008 received over TCP/IP. The term <quote>submission mode</quote> is used to describe this
55009 state. Submission mode is set by the modifier
55010 </para>
55011 <literallayout class="monospaced">
55012 control = submission
55013 </literallayout>
55014 <para>
55015 in a MAIL, RCPT, or pre-data ACL for an incoming message (see sections
55016 <xref linkend="SECTACLmodi"/> and <xref linkend="SECTcontrols"/>). This makes Exim treat the message as
55017 a local submission, and is normally used when the source of the message is
55018 known to be an MUA running on a client host (as opposed to an MTA). For
55019 example, to set submission mode for messages originating on the IPv4 loopback
55020 interface, you could include the following in the MAIL ACL:
55021 </para>
55022 <literallayout class="monospaced">
55023 warn  hosts = 127.0.0.1
55024       control = submission
55025 </literallayout>
55026 <para>
55027 <indexterm role="concept">
55028 <primary><option>sender_retain</option> submission option</primary>
55029 </indexterm>
55030 There are some options that can be used when setting submission mode. A slash
55031 is used to separate options. For example:
55032 </para>
55033 <literallayout class="monospaced">
55034 control = submission/sender_retain
55035 </literallayout>
55036 <para>
55037 Specifying <option>sender_retain</option> has the effect of setting <option>local_sender_retain</option>
55038 true and <option>local_from_check</option> false for the current incoming message. The first
55039 of these allows an existing <emphasis>Sender:</emphasis> header in the message to remain, and
55040 the second suppresses the check to ensure that <emphasis>From:</emphasis> matches the
55041 authenticated sender. With this setting, Exim still fixes up messages by adding
55042 <emphasis>Date:</emphasis> and <emphasis>Message-ID:</emphasis> header lines if they are missing, but makes no
55043 attempt to check sender authenticity in header lines.
55044 </para>
55045 <para>
55046 When <option>sender_retain</option> is not set, a submission mode setting may specify a
55047 domain to be used when generating a <emphasis>From:</emphasis> or <emphasis>Sender:</emphasis> header line. For
55048 example:
55049 </para>
55050 <literallayout class="monospaced">
55051 control = submission/domain=some.domain
55052 </literallayout>
55053 <para>
55054 The domain may be empty. How this value is used is described in sections
55055 <xref linkend="SECTthefrohea"/> and <xref linkend="SECTthesenhea"/>. There is also a <option>name</option> option
55056 that allows you to specify the user&#x2019;s full name for inclusion in a created
55057 <emphasis>Sender:</emphasis> or <emphasis>From:</emphasis> header line. For example:
55058 </para>
55059 <literallayout class="monospaced">
55060 accept authenticated = *
55061        control = submission/domain=wonderland.example/\
55062                             name=${lookup {$authenticated_id} \
55063                                    lsearch {/etc/exim/namelist}}
55064 </literallayout>
55065 <para>
55066 Because the name may contain any characters, including slashes, the <option>name</option>
55067 option must be given last. The remainder of the string is used as the name. For
55068 the example above, if <filename>/etc/exim/namelist</filename> contains:
55069 </para>
55070 <literallayout class="monospaced">
55071 bigegg:  Humpty Dumpty
55072 </literallayout>
55073 <para>
55074 then when the sender has authenticated as <emphasis>bigegg</emphasis>, the generated <emphasis>Sender:</emphasis>
55075 line would be:
55076 </para>
55077 <literallayout class="monospaced">
55078 Sender: Humpty Dumpty &lt;bigegg@wonderland.example&gt;
55079 </literallayout>
55080 <para>
55081 <indexterm role="concept">
55082 <primary>return path</primary>
55083 <secondary>in submission mode</secondary>
55084 </indexterm>
55085 By default, submission mode forces the return path to the same address as is
55086 used to create the <emphasis>Sender:</emphasis> header. However, if <option>sender_retain</option> is
55087 specified, the return path is also left unchanged.
55088 </para>
55089 <para>
55090 <emphasis role="bold">Note</emphasis>: The changes caused by submission mode take effect after the predata
55091 ACL. This means that any sender checks performed before the fix-ups use the
55092 untrusted sender address specified by the user, not the trusted sender address
55093 specified by submission mode. Although this might be slightly unexpected, it
55094 does mean that you can configure ACL checks to spot that a user is trying to
55095 spoof another&#x2019;s address.
55096 </para>
55097 </section>
55098 <section id="SECTlineendings">
55099 <title>Line endings</title>
55100 <para>
55101 <indexterm role="concept">
55102 <primary>line endings</primary>
55103 </indexterm>
55104 <indexterm role="concept">
55105 <primary>carriage return</primary>
55106 </indexterm>
55107 <indexterm role="concept">
55108 <primary>linefeed</primary>
55109 </indexterm>
55110 RFC 2821 specifies that CRLF (two characters: carriage-return, followed by
55111 linefeed) is the line ending for messages transmitted over the Internet using
55112 SMTP over TCP/IP. However, within individual operating systems, different
55113 conventions are used. For example, Unix-like systems use just LF, but others
55114 use CRLF or just CR.
55115 </para>
55116 <para>
55117 Exim was designed for Unix-like systems, and internally, it stores messages
55118 using the system&#x2019;s convention of a single LF as a line terminator. When
55119 receiving a message, all line endings are translated to this standard format.
55120 Originally, it was thought that programs that passed messages directly to an
55121 MTA within an operating system would use that system&#x2019;s convention. Experience
55122 has shown that this is not the case; for example, there are Unix applications
55123 that use CRLF in this circumstance. For this reason, and for compatibility with
55124 other MTAs, the way Exim handles line endings for all messages is now as
55125 follows:
55126 </para>
55127 <itemizedlist>
55128 <listitem>
55129 <para>
55130 LF not preceded by CR is treated as a line ending.
55131 </para>
55132 </listitem>
55133 <listitem>
55134 <para>
55135 CR is treated as a line ending; if it is immediately followed by LF, the LF
55136 is ignored.
55137 </para>
55138 </listitem>
55139 <listitem>
55140 <para>
55141 The sequence <quote>CR, dot, CR</quote> does not terminate an incoming SMTP message,
55142 nor a local message in the state where a line containing only a dot is a
55143 terminator.
55144 </para>
55145 </listitem>
55146 <listitem>
55147 <para>
55148 If a bare CR is encountered within a header line, an extra space is added after
55149 the line terminator so as not to end the header line. The reasoning behind this
55150 is that bare CRs in header lines are most likely either to be mistakes, or
55151 people trying to play silly games.
55152 </para>
55153 </listitem>
55154 <listitem>
55155 <para>
55156 If the first header line received in a message ends with CRLF, a subsequent
55157 bare LF in a header line is treated in the same way as a bare CR in a header
55158 line.
55159 </para>
55160 </listitem>
55161 </itemizedlist>
55162 </section>
55163 <section id="SECID218">
55164 <title>Unqualified addresses</title>
55165 <para>
55166 <indexterm role="concept">
55167 <primary>unqualified addresses</primary>
55168 </indexterm>
55169 <indexterm role="concept">
55170 <primary>address</primary>
55171 <secondary>qualification</secondary>
55172 </indexterm>
55173 By default, Exim expects every envelope address it receives from an external
55174 host to be fully qualified. Unqualified addresses cause negative responses to
55175 SMTP commands. However, because SMTP is used as a means of transporting
55176 messages from MUAs running on personal workstations, there is sometimes a
55177 requirement to accept unqualified addresses from specific hosts or IP networks.
55178 </para>
55179 <para>
55180 Exim has two options that separately control which hosts may send unqualified
55181 sender or recipient addresses in SMTP commands, namely
55182 <option>sender_unqualified_hosts</option> and <option>recipient_unqualified_hosts</option>. In both
55183 cases, if an unqualified address is accepted, it is qualified by adding the
55184 value of <option>qualify_domain</option> or <option>qualify_recipient</option>, as appropriate.
55185 </para>
55186 <para>
55187 <indexterm role="option">
55188 <primary><option>qualify_domain</option></primary>
55189 </indexterm>
55190 <indexterm role="option">
55191 <primary><option>qualify_recipient</option></primary>
55192 </indexterm>
55193 Unqualified addresses in header lines are automatically qualified for messages
55194 that are locally originated, unless the <option>-bnq</option> option is given on the command
55195 line. For messages received over SMTP, unqualified addresses in header lines
55196 are qualified only if unqualified addresses are permitted in SMTP commands. In
55197 other words, such qualification is also controlled by
55198 <option>sender_unqualified_hosts</option> and <option>recipient_unqualified_hosts</option>,
55199 </para>
55200 </section>
55201 <section id="SECID219">
55202 <title>The UUCP From line</title>
55203 <para>
55204 <indexterm role="concept">
55205 <primary><quote>From</quote> line</primary>
55206 </indexterm>
55207 <indexterm role="concept">
55208 <primary>UUCP</primary>
55209 <secondary><quote>From</quote> line</secondary>
55210 </indexterm>
55211 <indexterm role="concept">
55212 <primary>sender</primary>
55213 <secondary>address</secondary>
55214 </indexterm>
55215 <indexterm role="option">
55216 <primary><option>uucp_from_pattern</option></primary>
55217 </indexterm>
55218 <indexterm role="option">
55219 <primary><option>uucp_from_sender</option></primary>
55220 </indexterm>
55221 <indexterm role="concept">
55222 <primary>envelope sender</primary>
55223 </indexterm>
55224 <indexterm role="concept">
55225 <primary>Sendmail compatibility</primary>
55226 <secondary><quote>From</quote> line</secondary>
55227 </indexterm>
55228 Messages that have come from UUCP (and some other applications) often begin
55229 with a line containing the envelope sender and a timestamp, following the word
55230 <quote>From</quote>. Examples of two common formats are:
55231 </para>
55232 <literallayout class="monospaced">
55233 From a.oakley@berlin.mus Fri Jan  5 12:35 GMT 1996
55234 From f.butler@berlin.mus Fri, 7 Jan 97 14:00:00 GMT
55235 </literallayout>
55236 <para>
55237 This line precedes the RFC 2822 header lines. For compatibility with Sendmail,
55238 Exim recognizes such lines at the start of messages that are submitted to it
55239 via the command line (that is, on the standard input). It does not recognize
55240 such lines in incoming SMTP messages, unless the sending host matches
55241 <option>ignore_fromline_hosts</option> or the <option>-bs</option> option was used for a local message
55242 and <option>ignore_fromline_local</option> is set. The recognition is controlled by a
55243 regular expression that is defined by the <option>uucp_from_pattern</option> option, whose
55244 default value matches the two common cases shown above and puts the address
55245 that follows <quote>From</quote> into <varname>$1</varname>.
55246 </para>
55247 <para>
55248 <indexterm role="concept">
55249 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
55250 <secondary>in <quote>From </quote> line handling</secondary>
55251 </indexterm>
55252 When the caller of Exim for a non-SMTP message that contains a <quote>From</quote> line is
55253 a trusted user, the message&#x2019;s sender address is constructed by expanding the
55254 contents of <option>uucp_sender_address</option>, whose default value is <quote>$1</quote>. This is
55255 then parsed as an RFC 2822 address. If there is no domain, the local part is
55256 qualified with <option>qualify_domain</option> unless it is the empty string. However, if
55257 the command line <option>-f</option> option is used, it overrides the <quote>From</quote> line.
55258 </para>
55259 <para>
55260 If the caller of Exim is not trusted, the <quote>From</quote> line is recognized, but the
55261 sender address is not changed. This is also the case for incoming SMTP messages
55262 that are permitted to contain <quote>From</quote> lines.
55263 </para>
55264 <para>
55265 Only one <quote>From</quote> line is recognized. If there is more than one, the second is
55266 treated as a data line that starts the body of the message, as it is not valid
55267 as a header line. This also happens if a <quote>From</quote> line is present in an
55268 incoming SMTP message from a source that is not permitted to send them.
55269 </para>
55270 </section>
55271 <section id="SECID220">
55272 <title>Resent- header lines</title>
55273 <para>
55274 <indexterm role="concept">
55275 <primary><option>Resent-</option> header lines</primary>
55276 </indexterm>
55277 RFC 2822 makes provision for sets of header lines starting with the string
55278 <literal>Resent-</literal> to be added to a message when it is resent by the original
55279 recipient to somebody else. These headers are <emphasis>Resent-Date:</emphasis>,
55280 <emphasis>Resent-From:</emphasis>, <emphasis>Resent-Sender:</emphasis>, <emphasis>Resent-To:</emphasis>, <emphasis>Resent-Cc:</emphasis>,
55281 <emphasis>Resent-Bcc:</emphasis> and <emphasis>Resent-Message-ID:</emphasis>. The RFC says:
55282 </para>
55283 <blockquote>
55284 <para>
55285 <emphasis>Resent fields are strictly informational. They MUST NOT be used in the normal
55286 processing of replies or other such automatic actions on messages.</emphasis>
55287 </para>
55288 </blockquote>
55289 <para>
55290 This leaves things a bit vague as far as other processing actions such as
55291 address rewriting are concerned. Exim treats <option>Resent-</option> header lines as
55292 follows:
55293 </para>
55294 <itemizedlist>
55295 <listitem>
55296 <para>
55297 A <emphasis>Resent-From:</emphasis> line that just contains the login id of the submitting user
55298 is automatically rewritten in the same way as <emphasis>From:</emphasis> (see below).
55299 </para>
55300 </listitem>
55301 <listitem>
55302 <para>
55303 If there&#x2019;s a rewriting rule for a particular header line, it is also applied to
55304 <option>Resent-</option> header lines of the same type. For example, a rule that rewrites
55305 <emphasis>From:</emphasis> also rewrites <emphasis>Resent-From:</emphasis>.
55306 </para>
55307 </listitem>
55308 <listitem>
55309 <para>
55310 For local messages, if <emphasis>Sender:</emphasis> is removed on input, <emphasis>Resent-Sender:</emphasis> is
55311 also removed.
55312 </para>
55313 </listitem>
55314 <listitem>
55315 <para>
55316 For a locally-submitted message,
55317 if there are any <option>Resent-</option> header lines but no <emphasis>Resent-Date:</emphasis>,
55318 <emphasis>Resent-From:</emphasis>, or <emphasis>Resent-Message-Id:</emphasis>, they are added as necessary. It is
55319 the contents of <emphasis>Resent-Message-Id:</emphasis> (rather than <emphasis>Message-Id:</emphasis>) which are
55320 included in log lines in this case.
55321 </para>
55322 </listitem>
55323 <listitem>
55324 <para>
55325 The logic for adding <emphasis>Sender:</emphasis> is duplicated for <emphasis>Resent-Sender:</emphasis> when any
55326 <option>Resent-</option> header lines are present.
55327 </para>
55328 </listitem>
55329 </itemizedlist>
55330 </section>
55331 <section id="SECID221">
55332 <title>The Auto-Submitted: header line</title>
55333 <para>
55334 Whenever Exim generates an autoreply, a bounce, or a delay warning message, it
55335 includes the header line:
55336 </para>
55337 <literallayout class="monospaced">
55338 Auto-Submitted: auto-replied
55339 </literallayout>
55340 </section>
55341 <section id="SECID222">
55342 <title>The Bcc: header line</title>
55343 <para>
55344 <indexterm role="concept">
55345 <primary><emphasis>Bcc:</emphasis> header line</primary>
55346 </indexterm>
55347 If Exim is called with the <option>-t</option> option, to take recipient addresses from a
55348 message&#x2019;s header, it removes any <emphasis>Bcc:</emphasis> header line that may exist (after
55349 extracting its addresses). If <option>-t</option> is not present on the command line, any
55350 existing <emphasis>Bcc:</emphasis> is not removed.
55351 </para>
55352 </section>
55353 <section id="SECID223">
55354 <title>The Date: header line</title>
55355 <para>
55356 <indexterm role="concept">
55357 <primary><emphasis>Date:</emphasis> header line</primary>
55358 </indexterm>
55359 If a locally-generated or submission-mode message has no <emphasis>Date:</emphasis> header line,
55360 Exim adds one, using the current date and time, unless the
55361 <option>suppress_local_fixups</option> control has been specified.
55362 </para>
55363 </section>
55364 <section id="SECID224">
55365 <title>The Delivery-date: header line</title>
55366 <para>
55367 <indexterm role="concept">
55368 <primary><emphasis>Delivery-date:</emphasis> header line</primary>
55369 </indexterm>
55370 <indexterm role="option">
55371 <primary><option>delivery_date_remove</option></primary>
55372 </indexterm>
55373 <emphasis>Delivery-date:</emphasis> header lines are not part of the standard RFC 2822 header
55374 set. Exim can be configured to add them to the final delivery of messages. (See
55375 the generic <option>delivery_date_add</option> transport option.) They should not be present
55376 in messages in transit. If the <option>delivery_date_remove</option> configuration option is
55377 set (the default), Exim removes <emphasis>Delivery-date:</emphasis> header lines from incoming
55378 messages.
55379 </para>
55380 </section>
55381 <section id="SECID225">
55382 <title>The Envelope-to: header line</title>
55383 <para>
55384 <indexterm role="concept">
55385 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
55386 </indexterm>
55387 <indexterm role="option">
55388 <primary><option>envelope_to_remove</option></primary>
55389 </indexterm>
55390 <emphasis>Envelope-to:</emphasis> header lines are not part of the standard RFC 2822 header set.
55391 Exim can be configured to add them to the final delivery of messages. (See the
55392 generic <option>envelope_to_add</option> transport option.) They should not be present in
55393 messages in transit. If the <option>envelope_to_remove</option> configuration option is set
55394 (the default), Exim removes <emphasis>Envelope-to:</emphasis> header lines from incoming
55395 messages.
55396 </para>
55397 </section>
55398 <section id="SECTthefrohea">
55399 <title>The From: header line</title>
55400 <para>
55401 <indexterm role="concept">
55402 <primary><emphasis>From:</emphasis> header line</primary>
55403 </indexterm>
55404 <indexterm role="concept">
55405 <primary>Sendmail compatibility</primary>
55406 <secondary><quote>From</quote> line</secondary>
55407 </indexterm>
55408 <indexterm role="concept">
55409 <primary>message</primary>
55410 <secondary>submission</secondary>
55411 </indexterm>
55412 <indexterm role="concept">
55413 <primary>submission mode</primary>
55414 </indexterm>
55415 If a submission-mode message does not contain a <emphasis>From:</emphasis> header line, Exim
55416 adds one if either of the following conditions is true:
55417 </para>
55418 <itemizedlist>
55419 <listitem>
55420 <para>
55421 The envelope sender address is not empty (that is, this is not a bounce
55422 message). The added header line copies the envelope sender address.
55423 </para>
55424 </listitem>
55425 <listitem>
55426 <para>
55427 <indexterm role="variable">
55428 <primary><varname>$authenticated_id</varname></primary>
55429 </indexterm>
55430 The SMTP session is authenticated and <varname>$authenticated_id</varname> is not empty.
55431 </para>
55432 <orderedlist numeration="arabic">
55433 <listitem>
55434 <para>
55435 <indexterm role="variable">
55436 <primary><varname>$qualify_domain</varname></primary>
55437 </indexterm>
55438 If no domain is specified by the submission control, the local part is
55439 <varname>$authenticated_id</varname> and the domain is <varname>$qualify_domain</varname>.
55440 </para>
55441 </listitem>
55442 <listitem>
55443 <para>
55444 If a non-empty domain is specified by the submission control, the local
55445 part is <varname>$authenticated_id</varname>, and the domain is the specified domain.
55446 </para>
55447 </listitem>
55448 <listitem>
55449 <para>
55450 If an empty domain is specified by the submission control,
55451 <varname>$authenticated_id</varname> is assumed to be the complete address.
55452 </para>
55453 </listitem>
55454 </orderedlist>
55455 </listitem>
55456 </itemizedlist>
55457 <para>
55458 A non-empty envelope sender takes precedence.
55459 </para>
55460 <para>
55461 If a locally-generated incoming message does not contain a <emphasis>From:</emphasis> header
55462 line, and the <option>suppress_local_fixups</option> control is not set, Exim adds one
55463 containing the sender&#x2019;s address. The calling user&#x2019;s login name and full name
55464 are used to construct the address, as described in section <xref linkend="SECTconstr"/>.
55465 They are obtained from the password data by calling <function>getpwuid()</function> (but see the
55466 <option>unknown_login</option> configuration option). The address is qualified with
55467 <option>qualify_domain</option>.
55468 </para>
55469 <para>
55470 For compatibility with Sendmail, if an incoming, non-SMTP message has a
55471 <emphasis>From:</emphasis> header line containing just the unqualified login name of the calling
55472 user, this is replaced by an address containing the user&#x2019;s login name and full
55473 name as described in section <xref linkend="SECTconstr"/>.
55474 </para>
55475 </section>
55476 <section id="SECID226">
55477 <title>The Message-ID: header line</title>
55478 <para>
55479 <indexterm role="concept">
55480 <primary><emphasis>Message-ID:</emphasis> header line</primary>
55481 </indexterm>
55482 <indexterm role="concept">
55483 <primary>message</primary>
55484 <secondary>submission</secondary>
55485 </indexterm>
55486 <indexterm role="option">
55487 <primary><option>message_id_header_text</option></primary>
55488 </indexterm>
55489 If a locally-generated or submission-mode incoming message does not contain a
55490 <emphasis>Message-ID:</emphasis> or <emphasis>Resent-Message-ID:</emphasis> header line, and the
55491 <option>suppress_local_fixups</option> control is not set, Exim adds a suitable header line
55492 to the message. If there are any <emphasis>Resent-:</emphasis> headers in the message, it
55493 creates <emphasis>Resent-Message-ID:</emphasis>. The id is constructed from Exim&#x2019;s internal
55494 message id, preceded by the letter E to ensure it starts with a letter, and
55495 followed by @ and the primary host name. Additional information can be included
55496 in this header line by setting the <option>message_id_header_text</option> and/or
55497 <option>message_id_header_domain</option> options.
55498 </para>
55499 </section>
55500 <section id="SECID227">
55501 <title>The Received: header line</title>
55502 <para>
55503 <indexterm role="concept">
55504 <primary><emphasis>Received:</emphasis> header line</primary>
55505 </indexterm>
55506 A <emphasis>Received:</emphasis> header line is added at the start of every message. The
55507 contents are defined by the <option>received_header_text</option> configuration option, and
55508 Exim automatically adds a semicolon and a timestamp to the configured string.
55509 </para>
55510 <para>
55511 The <emphasis>Received:</emphasis> header is generated as soon as the message&#x2019;s header lines
55512 have been received. At this stage, the timestamp in the <emphasis>Received:</emphasis> header
55513 line is the time that the message started to be received. This is the value
55514 that is seen by the DATA ACL and by the <function>local_scan()</function> function.
55515 </para>
55516 <para>
55517 Once a message is accepted, the timestamp in the <emphasis>Received:</emphasis> header line is
55518 changed to the time of acceptance, which is (apart from a small delay while the
55519 -H spool file is written) the earliest time at which delivery could start.
55520 </para>
55521 </section>
55522 <section id="SECID228">
55523 <title>The References: header line</title>
55524 <para>
55525 <indexterm role="concept">
55526 <primary><emphasis>References:</emphasis> header line</primary>
55527 </indexterm>
55528 Messages created by the <command>autoreply</command> transport include a <emphasis>References:</emphasis>
55529 header line. This is constructed according to the rules that are described in
55530 section 3.64 of RFC 2822 (which states that replies should contain such a
55531 header line), and section 3.14 of RFC 3834 (which states that automatic
55532 responses are not different in this respect). However, because some mail
55533 processing software does not cope well with very long header lines, no more
55534 than 12 message IDs are copied from the <emphasis>References:</emphasis> header line in the
55535 incoming message. If there are more than 12, the first one and then the final
55536 11 are copied, before adding the message ID of the incoming message.
55537 </para>
55538 </section>
55539 <section id="SECID229">
55540 <title>The Return-path: header line</title>
55541 <para>
55542 <indexterm role="concept">
55543 <primary><emphasis>Return-path:</emphasis> header line</primary>
55544 </indexterm>
55545 <indexterm role="option">
55546 <primary><option>return_path_remove</option></primary>
55547 </indexterm>
55548 <emphasis>Return-path:</emphasis> header lines are defined as something an MTA may insert when
55549 it does the final delivery of messages. (See the generic <option>return_path_add</option>
55550 transport option.) Therefore, they should not be present in messages in
55551 transit. If the <option>return_path_remove</option> configuration option is set (the
55552 default), Exim removes <emphasis>Return-path:</emphasis> header lines from incoming messages.
55553 </para>
55554 </section>
55555 <section id="SECTthesenhea">
55556 <title>The Sender: header line</title>
55557 <para>
55558 <indexterm role="concept">
55559 <primary><emphasis>Sender:</emphasis> header line</primary>
55560 </indexterm>
55561 <indexterm role="concept">
55562 <primary>message</primary>
55563 <secondary>submission</secondary>
55564 </indexterm>
55565 For a locally-originated message from an untrusted user, Exim may remove an
55566 existing <emphasis>Sender:</emphasis> header line, and it may add a new one. You can modify
55567 these actions by setting the <option>local_sender_retain</option> option true, the
55568 <option>local_from_check</option> option false, or by using the <option>suppress_local_fixups</option>
55569 control setting.
55570 </para>
55571 <para>
55572 When a local message is received from an untrusted user and
55573 <option>local_from_check</option> is true (the default), and the <option>suppress_local_fixups</option>
55574 control has not been set, a check is made to see if the address given in the
55575 <emphasis>From:</emphasis> header line is the correct (local) sender of the message. The address
55576 that is expected has the login name as the local part and the value of
55577 <option>qualify_domain</option> as the domain. Prefixes and suffixes for the local part can
55578 be permitted by setting <option>local_from_prefix</option> and <option>local_from_suffix</option>
55579 appropriately. If <emphasis>From:</emphasis> does not contain the correct sender, a <emphasis>Sender:</emphasis>
55580 line is added to the message.
55581 </para>
55582 <para>
55583 If you set <option>local_from_check</option> false, this checking does not occur. However,
55584 the removal of an existing <emphasis>Sender:</emphasis> line still happens, unless you also set
55585 <option>local_sender_retain</option> to be true. It is not possible to set both of these
55586 options true at the same time.
55587 </para>
55588 <para>
55589 <indexterm role="concept">
55590 <primary>submission mode</primary>
55591 </indexterm>
55592 By default, no processing of <emphasis>Sender:</emphasis> header lines is done for messages
55593 received over TCP/IP or for messages submitted by trusted users. However, when
55594 a message is received over TCP/IP in submission mode, and <option>sender_retain</option> is
55595 not specified on the submission control, the following processing takes place:
55596 </para>
55597 <para>
55598 <indexterm role="variable">
55599 <primary><varname>$authenticated_id</varname></primary>
55600 </indexterm>
55601 First, any existing <emphasis>Sender:</emphasis> lines are removed. Then, if the SMTP session is
55602 authenticated, and <varname>$authenticated_id</varname> is not empty, a sender address is
55603 created as follows:
55604 </para>
55605 <itemizedlist>
55606 <listitem>
55607 <para>
55608 <indexterm role="variable">
55609 <primary><varname>$qualify_domain</varname></primary>
55610 </indexterm>
55611 If no domain is specified by the submission control, the local part is
55612 <varname>$authenticated_id</varname> and the domain is <varname>$qualify_domain</varname>.
55613 </para>
55614 </listitem>
55615 <listitem>
55616 <para>
55617 If a non-empty domain is specified by the submission control, the local part
55618 is <varname>$authenticated_id</varname>, and the domain is the specified domain.
55619 </para>
55620 </listitem>
55621 <listitem>
55622 <para>
55623 If an empty domain is specified by the submission control,
55624 <varname>$authenticated_id</varname> is assumed to be the complete address.
55625 </para>
55626 </listitem>
55627 </itemizedlist>
55628 <para>
55629 This address is compared with the address in the <emphasis>From:</emphasis> header line. If they
55630 are different, a <emphasis>Sender:</emphasis> header line containing the created address is
55631 added. Prefixes and suffixes for the local part in <emphasis>From:</emphasis> can be permitted
55632 by setting <option>local_from_prefix</option> and <option>local_from_suffix</option> appropriately.
55633 </para>
55634 <para>
55635 <indexterm role="concept">
55636 <primary>return path</primary>
55637 <secondary>created from <emphasis>Sender:</emphasis></secondary>
55638 </indexterm>
55639 <emphasis role="bold">Note</emphasis>: Whenever a <emphasis>Sender:</emphasis> header line is created, the return path for
55640 the message (the envelope sender address) is changed to be the same address,
55641 except in the case of submission mode when <option>sender_retain</option> is specified.
55642 </para>
55643 </section>
55644 <section id="SECTheadersaddrem">
55645 <title>Adding and removing header lines in routers and transports</title>
55646 <para>
55647 <indexterm role="concept">
55648 <primary>header lines</primary>
55649 <secondary>adding; in router or transport</secondary>
55650 </indexterm>
55651 <indexterm role="concept">
55652 <primary>header lines</primary>
55653 <secondary>removing; in router or transport</secondary>
55654 </indexterm>
55655 When a message is delivered, the addition and removal of header lines can be
55656 specified in a system filter, or on any of the routers and transports that
55657 process the message. Section <xref linkend="SECTaddremheasys"/> contains details about
55658 modifying headers in a system filter. Header lines can also be added in an ACL
55659 as a message is received (see section <xref linkend="SECTaddheadacl"/>).
55660 </para>
55661 <para>
55662 In contrast to what happens in a system filter, header modifications that are
55663 specified on routers and transports apply only to the particular recipient
55664 addresses that are being processed by those routers and transports. These
55665 changes do not actually take place until a copy of the message is being
55666 transported. Therefore, they do not affect the basic set of header lines, and
55667 they do not affect the values of the variables that refer to header lines.
55668 </para>
55669 <para>
55670 <emphasis role="bold">Note</emphasis>: In particular, this means that any expansions in the configuration of
55671 the transport cannot refer to the modified header lines, because such
55672 expansions all occur before the message is actually transported.
55673 </para>
55674 <para>
55675 For both routers and transports, the result of expanding a <option>headers_add</option>
55676 option must be in the form of one or more RFC 2822 header lines, separated by
55677 newlines (coded as <quote>\n</quote>). For example:
55678 </para>
55679 <literallayout class="monospaced">
55680 headers_add = X-added-header: added by $primary_hostname\n\
55681               X-added-second: another added header line
55682 </literallayout>
55683 <para>
55684 Exim does not check the syntax of these added header lines.
55685 </para>
55686 <para>
55687 The result of expanding <option>headers_remove</option> must consist of a colon-separated
55688 list of header names. This is confusing, because header names themselves are
55689 often terminated by colons. In this case, the colons are the list separators,
55690 not part of the names. For example:
55691 </para>
55692 <literallayout class="monospaced">
55693 headers_remove = return-receipt-to:acknowledge-to
55694 </literallayout>
55695 <para>
55696 When <option>headers_add</option> or <option>headers_remove</option> is specified on a router, its value
55697 is expanded at routing time, and then associated with all addresses that are
55698 accepted by that router, and also with any new addresses that it generates. If
55699 an address passes through several routers as a result of aliasing or
55700 forwarding, the changes are cumulative.
55701 </para>
55702 <para>
55703 <indexterm role="option">
55704 <primary><option>unseen</option></primary>
55705 </indexterm>
55706 However, this does not apply to multiple routers that result from the use of
55707 the <option>unseen</option> option. Any header modifications that were specified by the
55708 <quote>unseen</quote> router or its predecessors apply only to the <quote>unseen</quote> delivery.
55709 </para>
55710 <para>
55711 Addresses that end up with different <option>headers_add</option> or <option>headers_remove</option>
55712 settings cannot be delivered together in a batch, so a transport is always
55713 dealing with a set of addresses that have the same header-processing
55714 requirements.
55715 </para>
55716 <para>
55717 The transport starts by writing the original set of header lines that arrived
55718 with the message, possibly modified by the system filter. As it writes out
55719 these lines, it consults the list of header names that were attached to the
55720 recipient address(es) by <option>headers_remove</option> options in routers, and it also
55721 consults the transport&#x2019;s own <option>headers_remove</option> option. Header lines whose
55722 names are on either of these lists are not written out. If there are multiple
55723 instances of any listed header, they are all skipped.
55724 </para>
55725 <para>
55726 After the remaining original header lines have been written, new header
55727 lines that were specified by routers&#x2019; <option>headers_add</option> options are written, in
55728 the order in which they were attached to the address. These are followed by any
55729 header lines specified by the transport&#x2019;s <option>headers_add</option> option.
55730 </para>
55731 <para>
55732 This way of handling header line modifications in routers and transports has
55733 the following consequences:
55734 </para>
55735 <itemizedlist>
55736 <listitem>
55737 <para>
55738 The original set of header lines, possibly modified by the system filter,
55739 remains <quote>visible</quote>, in the sense that the <varname>$header_</varname><emphasis>xxx</emphasis> variables refer
55740 to it, at all times.
55741 </para>
55742 </listitem>
55743 <listitem>
55744 <para>
55745 Header lines that are added by a router&#x2019;s
55746 <option>headers_add</option> option are not accessible by means of the <varname>$header_</varname><emphasis>xxx</emphasis>
55747 expansion syntax in subsequent routers or the transport.
55748 </para>
55749 </listitem>
55750 <listitem>
55751 <para>
55752 Conversely, header lines that are specified for removal by <option>headers_remove</option>
55753 in a router remain visible to subsequent routers and the transport.
55754 </para>
55755 </listitem>
55756 <listitem>
55757 <para>
55758 Headers added to an address by <option>headers_add</option> in a router cannot be removed by
55759 a later router or by a transport.
55760 </para>
55761 </listitem>
55762 <listitem>
55763 <para>
55764 An added header can refer to the contents of an original header that is to be
55765 removed, even it has the same name as the added header. For example:
55766 </para>
55767 <literallayout class="monospaced">
55768 headers_remove = subject
55769 headers_add = Subject: new subject (was: $h_subject:)
55770 </literallayout>
55771 </listitem>
55772 </itemizedlist>
55773 <para>
55774 <emphasis role="bold">Warning</emphasis>: The <option>headers_add</option> and <option>headers_remove</option> options cannot be used
55775 for a <command>redirect</command> router that has the <option>one_time</option> option set.
55776 </para>
55777 </section>
55778 <section id="SECTconstr">
55779 <title>Constructed addresses</title>
55780 <para>
55781 <indexterm role="concept">
55782 <primary>address</primary>
55783 <secondary>constructed</secondary>
55784 </indexterm>
55785 <indexterm role="concept">
55786 <primary>constructed address</primary>
55787 </indexterm>
55788 When Exim constructs a sender address for a locally-generated message, it uses
55789 the form
55790 </para>
55791 <literallayout>
55792 &lt;<emphasis>user name</emphasis>&gt;&nbsp;&nbsp;&lt;<emphasis>login</emphasis><literal>@</literal><emphasis>qualify_domain</emphasis>&gt;
55793 </literallayout>
55794 <para>
55795 For example:
55796 </para>
55797 <literallayout class="monospaced">
55798 Zaphod Beeblebrox &lt;zaphod@end.univ.example&gt;
55799 </literallayout>
55800 <para>
55801 The user name is obtained from the <option>-F</option> command line option if set, or
55802 otherwise by looking up the calling user by <function>getpwuid()</function> and extracting the
55803 <quote>gecos</quote> field from the password entry. If the <quote>gecos</quote> field contains an
55804 ampersand character, this is replaced by the login name with the first letter
55805 upper cased, as is conventional in a number of operating systems. See the
55806 <option>gecos_name</option> option for a way to tailor the handling of the <quote>gecos</quote> field.
55807 The <option>unknown_username</option> option can be used to specify user names in cases when
55808 there is no password file entry.
55809 </para>
55810 <para>
55811 <indexterm role="concept">
55812 <primary>RFC 2047</primary>
55813 </indexterm>
55814 In all cases, the user name is made to conform to RFC 2822 by quoting all or
55815 parts of it if necessary. In addition, if it contains any non-printing
55816 characters, it is encoded as described in RFC 2047, which defines a way of
55817 including non-ASCII characters in header lines. The value of the
55818 <option>headers_charset</option> option specifies the name of the encoding that is used (the
55819 characters are assumed to be in this encoding). The setting of
55820 <option>print_topbitchars</option> controls whether characters with the top bit set (that
55821 is, with codes greater than 127) count as printing characters or not.
55822 </para>
55823 </section>
55824 <section id="SECID230">
55825 <title>Case of local parts</title>
55826 <para>
55827 <indexterm role="concept">
55828 <primary>case of local parts</primary>
55829 </indexterm>
55830 <indexterm role="concept">
55831 <primary>local part</primary>
55832 <secondary>case of</secondary>
55833 </indexterm>
55834 RFC 2822 states that the case of letters in the local parts of addresses cannot
55835 be assumed to be non-significant. Exim preserves the case of local parts of
55836 addresses, but by default it uses a lower-cased form when it is routing,
55837 because on most Unix systems, usernames are in lower case and case-insensitive
55838 routing is required. However, any particular router can be made to use the
55839 original case for local parts by setting the <option>caseful_local_part</option> generic
55840 router option.
55841 </para>
55842 <para>
55843 <indexterm role="concept">
55844 <primary>mixed-case login names</primary>
55845 </indexterm>
55846 If you must have mixed-case user names on your system, the best way to proceed,
55847 assuming you want case-independent handling of incoming email, is to set up
55848 your first router to convert incoming local parts in your domains to the
55849 correct case by means of a file lookup. For example:
55850 </para>
55851 <literallayout class="monospaced">
55852 correct_case:
55853   driver = redirect
55854   domains = +local_domains
55855   data = ${lookup{$local_part}cdb\
55856               {/etc/usercased.cdb}{$value}fail}\
55857               @$domain
55858 </literallayout>
55859 <para>
55860 For this router, the local part is forced to lower case by the default action
55861 (<option>caseful_local_part</option> is not set). The lower-cased local part is used to look
55862 up a new local part in the correct case. If you then set <option>caseful_local_part</option>
55863 on any subsequent routers which process your domains, they will operate on
55864 local parts with the correct case in a case-sensitive manner.
55865 </para>
55866 </section>
55867 <section id="SECID231">
55868 <title>Dots in local parts</title>
55869 <para>
55870 <indexterm role="concept">
55871 <primary>dot</primary>
55872 <secondary>in local part</secondary>
55873 </indexterm>
55874 <indexterm role="concept">
55875 <primary>local part</primary>
55876 <secondary>dots in</secondary>
55877 </indexterm>
55878 RFC 2822 forbids empty components in local parts. That is, an unquoted local
55879 part may not begin or end with a dot, nor have two consecutive dots in the
55880 middle. However, it seems that many MTAs do not enforce this, so Exim permits
55881 empty components for compatibility.
55882 </para>
55883 </section>
55884 <section id="SECID232">
55885 <title>Rewriting addresses</title>
55886 <para>
55887 <indexterm role="concept">
55888 <primary>rewriting</primary>
55889 <secondary>addresses</secondary>
55890 </indexterm>
55891 Rewriting of sender and recipient addresses, and addresses in headers, can
55892 happen automatically, or as the result of configuration options, as described
55893 in chapter <xref linkend="CHAPrewrite"/>. The headers that may be affected by this are
55894 <emphasis>Bcc:</emphasis>, <emphasis>Cc:</emphasis>, <emphasis>From:</emphasis>, <emphasis>Reply-To:</emphasis>, <emphasis>Sender:</emphasis>, and <emphasis>To:</emphasis>.
55895 </para>
55896 <para>
55897 Automatic rewriting includes qualification, as mentioned above. The other case
55898 in which it can happen is when an incomplete non-local domain is given. The
55899 routing process may cause this to be expanded into the full domain name. For
55900 example, a header such as
55901 </para>
55902 <literallayout class="monospaced">
55903 To: hare@teaparty
55904 </literallayout>
55905 <para>
55906 might get rewritten as
55907 </para>
55908 <literallayout class="monospaced">
55909 To: hare@teaparty.wonderland.fict.example
55910 </literallayout>
55911 <para>
55912 Rewriting as a result of routing is the one kind of message processing that
55913 does not happen at input time, as it cannot be done until the address has
55914 been routed.
55915 </para>
55916 <para>
55917 Strictly, one should not do <emphasis>any</emphasis> deliveries of a message until all its
55918 addresses have been routed, in case any of the headers get changed as a
55919 result of routing. However, doing this in practice would hold up many
55920 deliveries for unreasonable amounts of time, just because one address could not
55921 immediately be routed. Exim therefore does not delay other deliveries when
55922 routing of one or more addresses is deferred.
55923 <indexterm role="concept" startref="IIDmesproc" class="endofrange"/>
55924 </para>
55925 </section>
55926 </chapter>
55927
55928 <chapter id="CHAPSMTP">
55929 <title>SMTP processing</title>
55930 <para>
55931 <indexterm role="concept" id="IIDsmtpproc1" class="startofrange">
55932 <primary>SMTP</primary>
55933 <secondary>processing details</secondary>
55934 </indexterm>
55935 <indexterm role="concept" id="IIDsmtpproc2" class="startofrange">
55936 <primary>LMTP</primary>
55937 <secondary>processing details</secondary>
55938 </indexterm>
55939 Exim supports a number of different ways of using the SMTP protocol, and its
55940 LMTP variant, which is an interactive protocol for transferring messages into a
55941 closed mail store application. This chapter contains details of how SMTP is
55942 processed. For incoming mail, the following are available:
55943 </para>
55944 <itemizedlist>
55945 <listitem>
55946 <para>
55947 SMTP over TCP/IP (Exim daemon or <emphasis>inetd</emphasis>);
55948 </para>
55949 </listitem>
55950 <listitem>
55951 <para>
55952 SMTP over the standard input and output (the <option>-bs</option> option);
55953 </para>
55954 </listitem>
55955 <listitem>
55956 <para>
55957 Batched SMTP on the standard input (the <option>-bS</option> option).
55958 </para>
55959 </listitem>
55960 </itemizedlist>
55961 <para>
55962 For mail delivery, the following are available:
55963 </para>
55964 <itemizedlist>
55965 <listitem>
55966 <para>
55967 SMTP over TCP/IP (the <command>smtp</command> transport);
55968 </para>
55969 </listitem>
55970 <listitem>
55971 <para>
55972 LMTP over TCP/IP (the <command>smtp</command> transport with the <option>protocol</option> option set to
55973 <quote>lmtp</quote>);
55974 </para>
55975 </listitem>
55976 <listitem>
55977 <para>
55978 LMTP over a pipe to a process running in the local host (the <command>lmtp</command>
55979 transport);
55980 </para>
55981 </listitem>
55982 <listitem>
55983 <para>
55984 Batched SMTP to a file or pipe (the <command>appendfile</command> and <command>pipe</command> transports with
55985 the <option>use_bsmtp</option> option set).
55986 </para>
55987 </listitem>
55988 </itemizedlist>
55989 <para>
55990 <emphasis>Batched SMTP</emphasis> is the name for a process in which batches of messages are
55991 stored in or read from files (or pipes), in a format in which SMTP commands are
55992 used to contain the envelope information.
55993 </para>
55994 <section id="SECToutSMTPTCP">
55995 <title>Outgoing SMTP and LMTP over TCP/IP</title>
55996 <para>
55997 <indexterm role="concept">
55998 <primary>SMTP</primary>
55999 <secondary>outgoing over TCP/IP</secondary>
56000 </indexterm>
56001 <indexterm role="concept">
56002 <primary>outgoing SMTP over TCP/IP</primary>
56003 </indexterm>
56004 <indexterm role="concept">
56005 <primary>LMTP</primary>
56006 <secondary>over TCP/IP</secondary>
56007 </indexterm>
56008 <indexterm role="concept">
56009 <primary>outgoing LMTP over TCP/IP</primary>
56010 </indexterm>
56011 <indexterm role="concept">
56012 <primary>EHLO</primary>
56013 </indexterm>
56014 <indexterm role="concept">
56015 <primary>HELO</primary>
56016 </indexterm>
56017 <indexterm role="concept">
56018 <primary>SIZE option on MAIL command</primary>
56019 </indexterm>
56020 Outgoing SMTP and LMTP over TCP/IP is implemented by the <command>smtp</command> transport.
56021 The <option>protocol</option> option selects which protocol is to be used, but the actual
56022 processing is the same in both cases.
56023 </para>
56024 <para>
56025 If, in response to its EHLO command, Exim is told that the SIZE
56026 parameter is supported, it adds SIZE=&lt;<emphasis>n</emphasis>&gt; to each subsequent MAIL
56027 command. The value of &lt;<emphasis>n</emphasis>&gt; is the message size plus the value of the
56028 <option>size_addition</option> option (default 1024) to allow for additions to the message
56029 such as per-transport header lines, or changes made in a
56030 <indexterm role="concept">
56031 <primary>transport</primary>
56032 <secondary>filter</secondary>
56033 </indexterm>
56034 <indexterm role="concept">
56035 <primary>filter</primary>
56036 <secondary>transport filter</secondary>
56037 </indexterm>
56038 transport filter. If <option>size_addition</option> is set negative, the use of SIZE is
56039 suppressed.
56040 </para>
56041 <para>
56042 If the remote server advertises support for PIPELINING, Exim uses the
56043 pipelining extension to SMTP (RFC 2197) to reduce the number of TCP/IP packets
56044 required for the transaction.
56045 </para>
56046 <para>
56047 If the remote server advertises support for the STARTTLS command, and Exim
56048 was built to support TLS encryption, it tries to start a TLS session unless the
56049 server matches <option>hosts_avoid_tls</option>. See chapter <xref linkend="CHAPTLS"/> for more details.
56050 </para>
56051 <para>
56052 If the remote server advertises support for the AUTH command, Exim scans
56053 the authenticators configuration for any suitable client settings, as described
56054 in chapter <xref linkend="CHAPSMTPAUTH"/>.
56055 </para>
56056 <para>
56057 <indexterm role="concept">
56058 <primary>carriage return</primary>
56059 </indexterm>
56060 <indexterm role="concept">
56061 <primary>linefeed</primary>
56062 </indexterm>
56063 Responses from the remote host are supposed to be terminated by CR followed by
56064 LF. However, there are known to be hosts that do not send CR characters, so in
56065 order to be able to interwork with such hosts, Exim treats LF on its own as a
56066 line terminator.
56067 </para>
56068 <para>
56069 If a message contains a number of different addresses, all those with the same
56070 characteristics (for example, the same envelope sender) that resolve to the
56071 same set of hosts, in the same order, are sent in a single SMTP transaction,
56072 even if they are for different domains, unless there are more than the setting
56073 of the <option>max_rcpt</option>s option in the <command>smtp</command> transport allows, in which case
56074 they are split into groups containing no more than <option>max_rcpt</option>s addresses
56075 each. If <option>remote_max_parallel</option> is greater than one, such groups may be sent
56076 in parallel sessions. The order of hosts with identical MX values is not
56077 significant when checking whether addresses can be batched in this way.
56078 </para>
56079 <para>
56080 When the <command>smtp</command> transport suffers a temporary failure that is not
56081 message-related, Exim updates its transport-specific database, which contains
56082 records indexed by host name that remember which messages are waiting for each
56083 particular host. It also updates the retry database with new retry times.
56084 </para>
56085 <para>
56086 <indexterm role="concept">
56087 <primary>hints database</primary>
56088 <secondary>retry keys</secondary>
56089 </indexterm>
56090 Exim&#x2019;s retry hints are based on host name plus IP address, so if one address of
56091 a multi-homed host is broken, it will soon be skipped most of the time.
56092 See the next section for more detail about error handling.
56093 </para>
56094 <para>
56095 <indexterm role="concept">
56096 <primary>SMTP</primary>
56097 <secondary>passed connection</secondary>
56098 </indexterm>
56099 <indexterm role="concept">
56100 <primary>SMTP</primary>
56101 <secondary>batching over TCP/IP</secondary>
56102 </indexterm>
56103 When a message is successfully delivered over a TCP/IP SMTP connection, Exim
56104 looks in the hints database for the transport to see if there are any queued
56105 messages waiting for the host to which it is connected. If it finds one, it
56106 creates a new Exim process using the <option>-MC</option> option (which can only be used by
56107 a process running as root or the Exim user) and passes the TCP/IP socket to it
56108 so that it can deliver another message using the same socket. The new process
56109 does only those deliveries that are routed to the connected host, and may in
56110 turn pass the socket on to a third process, and so on.
56111 </para>
56112 <para>
56113 The <option>connection_max_messages</option> option of the <command>smtp</command> transport can be used to
56114 limit the number of messages sent down a single TCP/IP connection.
56115 </para>
56116 <para>
56117 <indexterm role="concept">
56118 <primary>asterisk</primary>
56119 <secondary>after IP address</secondary>
56120 </indexterm>
56121 The second and subsequent messages delivered down an existing connection are
56122 identified in the main log by the addition of an asterisk after the closing
56123 square bracket of the IP address.
56124 </para>
56125 </section>
56126 <section id="SECToutSMTPerr">
56127 <title>Errors in outgoing SMTP</title>
56128 <para>
56129 <indexterm role="concept">
56130 <primary>error</primary>
56131 <secondary>in outgoing SMTP</secondary>
56132 </indexterm>
56133 <indexterm role="concept">
56134 <primary>SMTP</primary>
56135 <secondary>errors in outgoing</secondary>
56136 </indexterm>
56137 <indexterm role="concept">
56138 <primary>host</primary>
56139 <secondary>error</secondary>
56140 </indexterm>
56141 Three different kinds of error are recognized for outgoing SMTP: host errors,
56142 message errors, and recipient errors.
56143 </para>
56144 <variablelist>
56145 <varlistentry>
56146 <term><emphasis role="bold">Host errors</emphasis></term>
56147 <listitem>
56148 <para>
56149 A host error is not associated with a particular message or with a
56150 particular recipient of a message. The host errors are:
56151 </para>
56152 <itemizedlist>
56153 <listitem>
56154 <para>
56155 Connection refused or timed out,
56156 </para>
56157 </listitem>
56158 <listitem>
56159 <para>
56160 Any error response code on connection,
56161 </para>
56162 </listitem>
56163 <listitem>
56164 <para>
56165 Any error response code to EHLO or HELO,
56166 </para>
56167 </listitem>
56168 <listitem>
56169 <para>
56170 Loss of connection at any time, except after <quote>.</quote>,
56171 </para>
56172 </listitem>
56173 <listitem>
56174 <para>
56175 I/O errors at any time,
56176 </para>
56177 </listitem>
56178 <listitem>
56179 <para>
56180 Timeouts during the session, other than in response to MAIL, RCPT or
56181 the <quote>.</quote> at the end of the data.
56182 </para>
56183 </listitem>
56184 </itemizedlist>
56185 <para>
56186 For a host error, a permanent error response on connection, or in response to
56187 EHLO, causes all addresses routed to the host to be failed. Any other host
56188 error causes all addresses to be deferred, and retry data to be created for the
56189 host. It is not tried again, for any message, until its retry time arrives. If
56190 the current set of addresses are not all delivered in this run (to some
56191 alternative host), the message is added to the list of those waiting for this
56192 host, so if it is still undelivered when a subsequent successful delivery is
56193 made to the host, it will be sent down the same SMTP connection.
56194 </para>
56195 </listitem></varlistentry>
56196 <varlistentry>
56197 <term><emphasis role="bold">Message errors</emphasis></term>
56198 <listitem>
56199 <para>
56200 <indexterm role="concept">
56201 <primary>message</primary>
56202 <secondary>error</secondary>
56203 </indexterm>
56204 A message error is associated with a particular message when sent to a
56205 particular host, but not with a particular recipient of the message. The
56206 message errors are:
56207 </para>
56208 <itemizedlist>
56209 <listitem>
56210 <para>
56211 Any error response code to MAIL, DATA, or the <quote>.</quote> that terminates
56212 the data,
56213 </para>
56214 </listitem>
56215 <listitem>
56216 <para>
56217 Timeout after MAIL,
56218 </para>
56219 </listitem>
56220 <listitem>
56221 <para>
56222 Timeout or loss of connection after the <quote>.</quote> that terminates the data. A
56223 timeout after the DATA command itself is treated as a host error, as is loss of
56224 connection at any other time.
56225 </para>
56226 </listitem>
56227 </itemizedlist>
56228 <para>
56229 For a message error, a permanent error response (5<emphasis>xx</emphasis>) causes all addresses
56230 to be failed, and a delivery error report to be returned to the sender. A
56231 temporary error response (4<emphasis>xx</emphasis>), or one of the timeouts, causes all
56232 addresses to be deferred. Retry data is not created for the host, but instead,
56233 a retry record for the combination of host plus message id is created. The
56234 message is not added to the list of those waiting for this host. This ensures
56235 that the failing message will not be sent to this host again until the retry
56236 time arrives. However, other messages that are routed to the host are not
56237 affected, so if it is some property of the message that is causing the error,
56238 it will not stop the delivery of other mail.
56239 </para>
56240 <para>
56241 If the remote host specified support for the SIZE parameter in its response
56242 to EHLO, Exim adds SIZE=<emphasis>nnn</emphasis> to the MAIL command, so an
56243 over-large message will cause a message error because the error arrives as a
56244 response to MAIL.
56245 </para>
56246 </listitem></varlistentry>
56247 <varlistentry>
56248 <term><emphasis role="bold">Recipient errors</emphasis></term>
56249 <listitem>
56250 <para>
56251 <indexterm role="concept">
56252 <primary>recipient</primary>
56253 <secondary>error</secondary>
56254 </indexterm>
56255 A recipient error is associated with a particular recipient of a message. The
56256 recipient errors are:
56257 </para>
56258 <itemizedlist>
56259 <listitem>
56260 <para>
56261 Any error response to RCPT,
56262 </para>
56263 </listitem>
56264 <listitem>
56265 <para>
56266 Timeout after RCPT.
56267 </para>
56268 </listitem>
56269 </itemizedlist>
56270 <para>
56271 For a recipient error, a permanent error response (5<emphasis>xx</emphasis>) causes the
56272 recipient address to be failed, and a bounce message to be returned to the
56273 sender. A temporary error response (4<emphasis>xx</emphasis>) or a timeout causes the failing
56274 address to be deferred, and routing retry data to be created for it. This is
56275 used to delay processing of the address in subsequent queue runs, until its
56276 routing retry time arrives. This applies to all messages, but because it
56277 operates only in queue runs, one attempt will be made to deliver a new message
56278 to the failing address before the delay starts to operate. This ensures that,
56279 if the failure is really related to the message rather than the recipient
56280 (<quote>message too big for this recipient</quote> is a possible example), other messages
56281 have a chance of getting delivered. If a delivery to the address does succeed,
56282 the retry information gets cleared, so all stuck messages get tried again, and
56283 the retry clock is reset.
56284 </para>
56285 <para>
56286 The message is not added to the list of those waiting for this host. Use of the
56287 host for other messages is unaffected, and except in the case of a timeout,
56288 other recipients are processed independently, and may be successfully delivered
56289 in the current SMTP session. After a timeout it is of course impossible to
56290 proceed with the session, so all addresses get deferred. However, those other
56291 than the one that failed do not suffer any subsequent retry delays. Therefore,
56292 if one recipient is causing trouble, the others have a chance of getting
56293 through when a subsequent delivery attempt occurs before the failing
56294 recipient&#x2019;s retry time.
56295 </para>
56296 </listitem></varlistentry>
56297 </variablelist>
56298 <para>
56299 In all cases, if there are other hosts (or IP addresses) available for the
56300 current set of addresses (for example, from multiple MX records), they are
56301 tried in this run for any undelivered addresses, subject of course to their
56302 own retry data. In other words, recipient error retry data does not take effect
56303 until the next delivery attempt.
56304 </para>
56305 <para>
56306 Some hosts have been observed to give temporary error responses to every
56307 MAIL command at certain times (<quote>insufficient space</quote> has been seen). It
56308 would be nice if such circumstances could be recognized, and defer data for the
56309 host itself created, but this is not possible within the current Exim design.
56310 What actually happens is that retry data for every (host, message) combination
56311 is created.
56312 </para>
56313 <para>
56314 The reason that timeouts after MAIL and RCPT are treated specially is that
56315 these can sometimes arise as a result of the remote host&#x2019;s verification
56316 procedures. Exim makes this assumption, and treats them as if a temporary error
56317 response had been received. A timeout after <quote>.</quote> is treated specially because
56318 it is known that some broken implementations fail to recognize the end of the
56319 message if the last character of the last line is a binary zero. Thus, it is
56320 helpful to treat this case as a message error.
56321 </para>
56322 <para>
56323 Timeouts at other times are treated as host errors, assuming a problem with the
56324 host, or the connection to it. If a timeout after MAIL, RCPT,
56325 or <quote>.</quote> is really a connection problem, the assumption is that at the next try
56326 the timeout is likely to occur at some other point in the dialogue, causing it
56327 then to be treated as a host error.
56328 </para>
56329 <para>
56330 There is experimental evidence that some MTAs drop the connection after the
56331 terminating <quote>.</quote> if they do not like the contents of the message for some
56332 reason, in contravention of the RFC, which indicates that a 5<emphasis>xx</emphasis> response
56333 should be given. That is why Exim treats this case as a message rather than a
56334 host error, in order not to delay other messages to the same host.
56335 </para>
56336 </section>
56337 <section id="SECID233">
56338 <title>Incoming SMTP messages over TCP/IP</title>
56339 <para>
56340 <indexterm role="concept">
56341 <primary>SMTP</primary>
56342 <secondary>incoming over TCP/IP</secondary>
56343 </indexterm>
56344 <indexterm role="concept">
56345 <primary>incoming SMTP over TCP/IP</primary>
56346 </indexterm>
56347 <indexterm role="concept">
56348 <primary>inetd</primary>
56349 </indexterm>
56350 <indexterm role="concept">
56351 <primary>daemon</primary>
56352 </indexterm>
56353 Incoming SMTP messages can be accepted in one of two ways: by running a
56354 listening daemon, or by using <emphasis>inetd</emphasis>. In the latter case, the entry in
56355 <filename>/etc/inetd.conf</filename> should be like this:
56356 </para>
56357 <literallayout class="monospaced">
56358 smtp stream tcp nowait exim /opt/exim/bin/exim in.exim -bs
56359 </literallayout>
56360 <para>
56361 Exim distinguishes between this case and the case of a locally running user
56362 agent using the <option>-bs</option> option by checking whether or not the standard input is
56363 a socket. When it is, either the port must be privileged (less than 1024), or
56364 the caller must be root or the Exim user. If any other user passes a socket
56365 with an unprivileged port number, Exim prints a message on the standard error
56366 stream and exits with an error code.
56367 </para>
56368 <para>
56369 By default, Exim does not make a log entry when a remote host connects or
56370 disconnects (either via the daemon or <emphasis>inetd</emphasis>), unless the disconnection is
56371 unexpected. It can be made to write such log entries by setting the
56372 <option>smtp_connection</option> log selector.
56373 </para>
56374 <para>
56375 <indexterm role="concept">
56376 <primary>carriage return</primary>
56377 </indexterm>
56378 <indexterm role="concept">
56379 <primary>linefeed</primary>
56380 </indexterm>
56381 Commands from the remote host are supposed to be terminated by CR followed by
56382 LF. However, there are known to be hosts that do not send CR characters. In
56383 order to be able to interwork with such hosts, Exim treats LF on its own as a
56384 line terminator.
56385 Furthermore, because common code is used for receiving messages from all
56386 sources, a CR on its own is also interpreted as a line terminator. However, the
56387 sequence <quote>CR, dot, CR</quote> does not terminate incoming SMTP data.
56388 </para>
56389 <para>
56390 <indexterm role="concept">
56391 <primary>EHLO</primary>
56392 <secondary>invalid data</secondary>
56393 </indexterm>
56394 <indexterm role="concept">
56395 <primary>HELO</primary>
56396 <secondary>invalid data</secondary>
56397 </indexterm>
56398 One area that sometimes gives rise to problems concerns the EHLO or
56399 HELO commands. Some clients send syntactically invalid versions of these
56400 commands, which Exim rejects by default. (This is nothing to do with verifying
56401 the data that is sent, so <option>helo_verify_hosts</option> is not relevant.) You can tell
56402 Exim not to apply a syntax check by setting <option>helo_accept_junk_hosts</option> to
56403 match the broken hosts that send invalid commands.
56404 </para>
56405 <para>
56406 <indexterm role="concept">
56407 <primary>SIZE option on MAIL command</primary>
56408 </indexterm>
56409 <indexterm role="concept">
56410 <primary>MAIL</primary>
56411 <secondary>SIZE option</secondary>
56412 </indexterm>
56413 The amount of disk space available is checked whenever SIZE is received on
56414 a MAIL command, independently of whether <option>message_size_limit</option> or
56415 <option>check_spool_space</option> is configured, unless <option>smtp_check_spool_space</option> is set
56416 false. A temporary error is given if there is not enough space. If
56417 <option>check_spool_space</option> is set, the check is for that amount of space plus the
56418 value given with SIZE, that is, it checks that the addition of the incoming
56419 message will not reduce the space below the threshold.
56420 </para>
56421 <para>
56422 When a message is successfully received, Exim includes the local message id in
56423 its response to the final <quote>.</quote> that terminates the data. If the remote host
56424 logs this text it can help with tracing what has happened to a message.
56425 </para>
56426 <para>
56427 The Exim daemon can limit the number of simultaneous incoming connections it is
56428 prepared to handle (see the <option>smtp_accept_max</option> option). It can also limit the
56429 number of simultaneous incoming connections from a single remote host (see the
56430 <option>smtp_accept_max_per_host</option> option). Additional connection attempts are
56431 rejected using the SMTP temporary error code 421.
56432 </para>
56433 <para>
56434 The Exim daemon does not rely on the SIGCHLD signal to detect when a
56435 subprocess has finished, as this can get lost at busy times. Instead, it looks
56436 for completed subprocesses every time it wakes up. Provided there are other
56437 things happening (new incoming calls, starts of queue runs), completed
56438 processes will be noticed and tidied away. On very quiet systems you may
56439 sometimes see a <quote>defunct</quote> Exim process hanging about. This is not a problem;
56440 it will be noticed when the daemon next wakes up.
56441 </para>
56442 <para>
56443 When running as a daemon, Exim can reserve some SMTP slots for specific hosts,
56444 and can also be set up to reject SMTP calls from non-reserved hosts at times of
56445 high system load &ndash; for details see the <option>smtp_accept_reserve</option>,
56446 <option>smtp_load_reserve</option>, and <option>smtp_reserve_hosts</option> options. The load check
56447 applies in both the daemon and <emphasis>inetd</emphasis> cases.
56448 </para>
56449 <para>
56450 Exim normally starts a delivery process for each message received, though this
56451 can be varied by means of the <option>-odq</option> command line option and the
56452 <option>queue_only</option>, <option>queue_only_file</option>, and <option>queue_only_load</option> options. The
56453 number of simultaneously running delivery processes started in this way from
56454 SMTP input can be limited by the <option>smtp_accept_queue</option> and
56455 <option>smtp_accept_queue_per_connection</option> options. When either limit is reached,
56456 subsequently received messages are just put on the input queue without starting
56457 a delivery process.
56458 </para>
56459 <para>
56460 The controls that involve counts of incoming SMTP calls (<option>smtp_accept_max</option>,
56461 <option>smtp_accept_queue</option>, <option>smtp_accept_reserve</option>) are not available when Exim is
56462 started up from the <emphasis>inetd</emphasis> daemon, because in that case each connection is
56463 handled by an entirely independent Exim process. Control by load average is,
56464 however, available with <emphasis>inetd</emphasis>.
56465 </para>
56466 <para>
56467 Exim can be configured to verify addresses in incoming SMTP commands as they
56468 are received. See chapter <xref linkend="CHAPACL"/> for details. It can also be configured
56469 to rewrite addresses at this time &ndash; before any syntax checking is done. See
56470 section <xref linkend="SECTrewriteS"/>.
56471 </para>
56472 <para>
56473 Exim can also be configured to limit the rate at which a client host submits
56474 MAIL and RCPT commands in a single SMTP session. See the
56475 <option>smtp_ratelimit_hosts</option> option.
56476 </para>
56477 </section>
56478 <section id="SECID234">
56479 <title>Unrecognized SMTP commands</title>
56480 <para>
56481 <indexterm role="concept">
56482 <primary>SMTP</primary>
56483 <secondary>unrecognized commands</secondary>
56484 </indexterm>
56485 If Exim receives more than <option>smtp_max_unknown_commands</option> unrecognized SMTP
56486 commands during a single SMTP connection, it drops the connection after sending
56487 the error response to the last command. The default value for
56488 <option>smtp_max_unknown_commands</option> is 3. This is a defence against some kinds of
56489 abuse that subvert web servers into making connections to SMTP ports; in these
56490 circumstances, a number of non-SMTP lines are sent first.
56491 </para>
56492 </section>
56493 <section id="SECID235">
56494 <title>Syntax and protocol errors in SMTP commands</title>
56495 <para>
56496 <indexterm role="concept">
56497 <primary>SMTP</primary>
56498 <secondary>syntax errors</secondary>
56499 </indexterm>
56500 <indexterm role="concept">
56501 <primary>SMTP</primary>
56502 <secondary>protocol errors</secondary>
56503 </indexterm>
56504 A syntax error is detected if an SMTP command is recognized, but there is
56505 something syntactically wrong with its data, for example, a malformed email
56506 address in a RCPT command. Protocol errors include invalid command
56507 sequencing such as RCPT before MAIL. If Exim receives more than
56508 <option>smtp_max_synprot_errors</option> such commands during a single SMTP connection, it
56509 drops the connection after sending the error response to the last command. The
56510 default value for <option>smtp_max_synprot_errors</option> is 3. This is a defence against
56511 broken clients that loop sending bad commands (yes, it has been seen).
56512 </para>
56513 </section>
56514 <section id="SECID236">
56515 <title>Use of non-mail SMTP commands</title>
56516 <para>
56517 <indexterm role="concept">
56518 <primary>SMTP</primary>
56519 <secondary>non-mail commands</secondary>
56520 </indexterm>
56521 The <quote>non-mail</quote> SMTP commands are those other than MAIL, RCPT, and
56522 DATA. Exim counts such commands, and drops the connection if there are too
56523 many of them in a single SMTP session. This action catches some
56524 denial-of-service attempts and things like repeated failing AUTHs, or a mad
56525 client looping sending EHLO. The global option <option>smtp_accept_max_nonmail</option>
56526 defines what <quote>too many</quote> means. Its default value is 10.
56527 </para>
56528 <para>
56529 When a new message is expected, one occurrence of RSET is not counted. This
56530 allows a client to send one RSET between messages (this is not necessary,
56531 but some clients do it). Exim also allows one uncounted occurrence of HELO
56532 or EHLO, and one occurrence of STARTTLS between messages. After
56533 starting up a TLS session, another EHLO is expected, and so it too is not
56534 counted.
56535 </para>
56536 <para>
56537 The first occurrence of AUTH in a connection, or immediately following
56538 STARTTLS is also not counted. Otherwise, all commands other than MAIL,
56539 RCPT, DATA, and QUIT are counted.
56540 </para>
56541 <para>
56542 You can control which hosts are subject to the limit set by
56543 <option>smtp_accept_max_nonmail</option> by setting
56544 <option>smtp_accept_max_nonmail_hosts</option>. The default value is <literal>*</literal>, which makes
56545 the limit apply to all hosts. This option means that you can exclude any
56546 specific badly-behaved hosts that you have to live with.
56547 </para>
56548 </section>
56549 <section id="SECID237">
56550 <title>The VRFY and EXPN commands</title>
56551 <para>
56552 When Exim receives a VRFY or EXPN command on a TCP/IP connection, it
56553 runs the ACL specified by <option>acl_smtp_vrfy</option> or <option>acl_smtp_expn</option> (as
56554 appropriate) in order to decide whether the command should be accepted or not.
56555 If no ACL is defined, the command is rejected.
56556 </para>
56557 <para>
56558 <indexterm role="concept">
56559 <primary>VRFY</primary>
56560 <secondary>processing</secondary>
56561 </indexterm>
56562 When VRFY is accepted, it runs exactly the same code as when Exim is
56563 called with the <option>-bv</option> option.
56564 </para>
56565 <para>
56566 <indexterm role="concept">
56567 <primary>EXPN</primary>
56568 <secondary>processing</secondary>
56569 </indexterm>
56570 When EXPN is accepted, a single-level expansion of the address is done.
56571 EXPN is treated as an <quote>address test</quote> (similar to the <option>-bt</option> option) rather
56572 than a verification (the <option>-bv</option> option). If an unqualified local part is given
56573 as the argument to EXPN, it is qualified with <option>qualify_domain</option>. Rejections
56574 of VRFY and EXPN commands are logged on the main and reject logs, and
56575 VRFY verification failures are logged on the main log for consistency with
56576 RCPT failures.
56577 </para>
56578 </section>
56579 <section id="SECTETRN">
56580 <title>The ETRN command</title>
56581 <para>
56582 <indexterm role="concept">
56583 <primary>ETRN</primary>
56584 <secondary>processing</secondary>
56585 </indexterm>
56586 RFC 1985 describes an SMTP command called ETRN that is designed to
56587 overcome the security problems of the TURN command (which has fallen into
56588 disuse). When Exim receives an ETRN command on a TCP/IP connection, it runs
56589 the ACL specified by <option>acl_smtp_etrn</option> in order to decide whether the command
56590 should be accepted or not. If no ACL is defined, the command is rejected.
56591 </para>
56592 <para>
56593 The ETRN command is concerned with <quote>releasing</quote> messages that are awaiting
56594 delivery to certain hosts. As Exim does not organize its message queue by host,
56595 the only form of ETRN that is supported by default is the one where the
56596 text starts with the <quote>#</quote> prefix, in which case the remainder of the text is
56597 specific to the SMTP server. A valid ETRN command causes a run of Exim with
56598 the <option>-R</option> option to happen, with the remainder of the ETRN text as its
56599 argument. For example,
56600 </para>
56601 <literallayout class="monospaced">
56602 ETRN #brigadoon
56603 </literallayout>
56604 <para>
56605 runs the command
56606 </para>
56607 <literallayout class="monospaced">
56608 exim -R brigadoon
56609 </literallayout>
56610 <para>
56611 which causes a delivery attempt on all messages with undelivered addresses
56612 containing the text <quote>brigadoon</quote>. When <option>smtp_etrn_serialize</option> is set (the
56613 default), Exim prevents the simultaneous execution of more than one queue run
56614 for the same argument string as a result of an ETRN command. This stops
56615 a misbehaving client from starting more than one queue runner at once.
56616 </para>
56617 <para>
56618 <indexterm role="concept">
56619 <primary>hints database</primary>
56620 <secondary>ETRN serialization</secondary>
56621 </indexterm>
56622 Exim implements the serialization by means of a hints database in which a
56623 record is written whenever a process is started by ETRN, and deleted when
56624 the process completes. However, Exim does not keep the SMTP session waiting for
56625 the ETRN process to complete. Once ETRN is accepted, the client is sent
56626 a <quote>success</quote> return code. Obviously there is scope for hints records to get
56627 left lying around if there is a system or program crash. To guard against this,
56628 Exim ignores any records that are more than six hours old.
56629 </para>
56630 <para>
56631 <indexterm role="option">
56632 <primary><option>smtp_etrn_command</option></primary>
56633 </indexterm>
56634 For more control over what ETRN does, the <option>smtp_etrn_command</option> option can
56635 used. This specifies a command that is run whenever ETRN is received,
56636 whatever the form of its argument. For
56637 example:
56638 </para>
56639 <literallayout class="monospaced">
56640 smtp_etrn_command = /etc/etrn_command $domain \
56641                     $sender_host_address
56642 </literallayout>
56643 <para>
56644 <indexterm role="variable">
56645 <primary><varname>$domain</varname></primary>
56646 </indexterm>
56647 The string is split up into arguments which are independently expanded. The
56648 expansion variable <varname>$domain</varname> is set to the argument of the ETRN command,
56649 and no syntax checking is done on the contents of this argument. Exim does not
56650 wait for the command to complete, so its status code is not checked. Exim runs
56651 under its own uid and gid when receiving incoming SMTP, so it is not possible
56652 for it to change them before running the command.
56653 </para>
56654 </section>
56655 <section id="SECID238">
56656 <title>Incoming local SMTP</title>
56657 <para>
56658 <indexterm role="concept">
56659 <primary>SMTP</primary>
56660 <secondary>local incoming</secondary>
56661 </indexterm>
56662 Some user agents use SMTP to pass messages to their local MTA using the
56663 standard input and output, as opposed to passing the envelope on the command
56664 line and writing the message to the standard input. This is supported by the
56665 <option>-bs</option> option. This form of SMTP is handled in the same way as incoming
56666 messages over TCP/IP (including the use of ACLs), except that the envelope
56667 sender given in a MAIL command is ignored unless the caller is trusted. In
56668 an ACL you can detect this form of SMTP input by testing for an empty host
56669 identification. It is common to have this as the first line in the ACL that
56670 runs for RCPT commands:
56671 </para>
56672 <literallayout class="monospaced">
56673 accept hosts = :
56674 </literallayout>
56675 <para>
56676 This accepts SMTP messages from local processes without doing any other tests.
56677 </para>
56678 </section>
56679 <section id="SECTbatchSMTP">
56680 <title>Outgoing batched SMTP</title>
56681 <para>
56682 <indexterm role="concept">
56683 <primary>SMTP</primary>
56684 <secondary>batched outgoing</secondary>
56685 </indexterm>
56686 <indexterm role="concept">
56687 <primary>batched SMTP output</primary>
56688 </indexterm>
56689 Both the <command>appendfile</command> and <command>pipe</command> transports can be used for handling
56690 batched SMTP. Each has an option called <option>use_bsmtp</option> which causes messages to
56691 be output in BSMTP format. No SMTP responses are possible for this form of
56692 delivery. All it is doing is using SMTP commands as a way of transmitting the
56693 envelope along with the message.
56694 </para>
56695 <para>
56696 The message is written to the file or pipe preceded by the SMTP commands
56697 MAIL and RCPT, and followed by a line containing a single dot. Lines in
56698 the message that start with a dot have an extra dot added. The SMTP command
56699 HELO is not normally used. If it is required, the <option>message_prefix</option> option
56700 can be used to specify it.
56701 </para>
56702 <para>
56703 Because <command>appendfile</command> and <command>pipe</command> are both local transports, they accept only
56704 one recipient address at a time by default. However, you can arrange for them
56705 to handle several addresses at once by setting the <option>batch_max</option> option. When
56706 this is done for BSMTP, messages may contain multiple RCPT commands. See
56707 chapter <xref linkend="CHAPbatching"/> for more details.
56708 </para>
56709 <para>
56710 <indexterm role="variable">
56711 <primary><varname>$host</varname></primary>
56712 </indexterm>
56713 When one or more addresses are routed to a BSMTP transport by a router that
56714 sets up a host list, the name of the first host on the list is available to the
56715 transport in the variable <varname>$host</varname>. Here is an example of such a transport and
56716 router:
56717 </para>
56718 <literallayout class="monospaced">
56719 begin routers
56720 route_append:
56721   driver = manualroute
56722   transport = smtp_appendfile
56723   route_list = domain.example  batch.host.example
56724
56725 begin transports
56726 smtp_appendfile:
56727   driver = appendfile
56728   directory = /var/bsmtp/$host
56729   batch_max = 1000
56730   use_bsmtp
56731   user = exim
56732 </literallayout>
56733 <para>
56734 This causes messages addressed to <emphasis>domain.example</emphasis> to be written in BSMTP
56735 format to <filename>/var/bsmtp/batch.host.example</filename>, with only a single copy of each
56736 message (unless there are more than 1000 recipients).
56737 </para>
56738 </section>
56739 <section id="SECTincomingbatchedSMTP">
56740 <title>Incoming batched SMTP</title>
56741 <para>
56742 <indexterm role="concept">
56743 <primary>SMTP</primary>
56744 <secondary>batched incoming</secondary>
56745 </indexterm>
56746 <indexterm role="concept">
56747 <primary>batched SMTP input</primary>
56748 </indexterm>
56749 The <option>-bS</option> command line option causes Exim to accept one or more messages by
56750 reading SMTP on the standard input, but to generate no responses. If the caller
56751 is trusted, the senders in the MAIL commands are believed; otherwise the
56752 sender is always the caller of Exim. Unqualified senders and receivers are not
56753 rejected (there seems little point) but instead just get qualified. HELO
56754 and EHLO act as RSET; VRFY, EXPN, ETRN and  HELP, act
56755 as NOOP; QUIT quits.
56756 </para>
56757 <para>
56758 Minimal policy checking is done for BSMTP input. Only the non-SMTP
56759 ACL is run in the same way as for non-SMTP local input.
56760 </para>
56761 <para>
56762 If an error is detected while reading a message, including a missing <quote>.</quote> at
56763 the end, Exim gives up immediately. It writes details of the error to the
56764 standard output in a stylized way that the calling program should be able to
56765 make some use of automatically, for example:
56766 </para>
56767 <literallayout class="monospaced">
56768 554 Unexpected end of file
56769 Transaction started in line 10
56770 Error detected in line 14
56771 </literallayout>
56772 <para>
56773 It writes a more verbose version, for human consumption, to the standard error
56774 file, for example:
56775 </para>
56776 <literallayout class="monospaced">
56777 An error was detected while processing a file of BSMTP input.
56778 The error message was:
56779
56780 501 '&gt;' missing at end of address
56781
56782 The SMTP transaction started in line 10.
56783 The error was detected in line 12.
56784 The SMTP command at fault was:
56785
56786 rcpt to:&lt;malformed@in.com.plete
56787
56788 1 previous message was successfully processed.
56789 The rest of the batch was abandoned.
56790 </literallayout>
56791 <para>
56792 The return code from Exim is zero only if there were no errors. It is 1 if some
56793 messages were accepted before an error was detected, and 2 if no messages were
56794 accepted.
56795 <indexterm role="concept" startref="IIDsmtpproc1" class="endofrange"/>
56796 <indexterm role="concept" startref="IIDsmtpproc2" class="endofrange"/>
56797 </para>
56798 </section>
56799 </chapter>
56800
56801 <chapter id="CHAPemsgcust">
56802 <title>Customizing bounce and warning messages</title>
56803 <titleabbrev>Customizing messages</titleabbrev>
56804 <para>
56805 When a message fails to be delivered, or remains on the queue for more than a
56806 configured amount of time, Exim sends a message to the original sender, or
56807 to an alternative configured address. The text of these messages is built into
56808 the code of Exim, but it is possible to change it, either by adding a single
56809 string, or by replacing each of the paragraphs by text supplied in a file.
56810 </para>
56811 <para>
56812 The <emphasis>From:</emphasis> and <emphasis>To:</emphasis> header lines are automatically generated; you can
56813 cause a <emphasis>Reply-To:</emphasis> line to be added by setting the <option>errors_reply_to</option>
56814 option. Exim also adds the line
56815 </para>
56816 <literallayout class="monospaced">
56817 Auto-Submitted: auto-generated
56818 </literallayout>
56819 <para>
56820 to all warning and bounce messages,
56821 </para>
56822 <section id="SECID239">
56823 <title>Customizing bounce messages</title>
56824 <para>
56825 <indexterm role="concept">
56826 <primary>customizing</primary>
56827 <secondary>bounce message</secondary>
56828 </indexterm>
56829 <indexterm role="concept">
56830 <primary>bounce message</primary>
56831 <secondary>customizing</secondary>
56832 </indexterm>
56833 If <option>bounce_message_text</option> is set, its contents are included in the default
56834 message immediately after <quote>This message was created automatically by mail
56835 delivery software.</quote> The string is not expanded. It is not used if
56836 <option>bounce_message_file</option> is set.
56837 </para>
56838 <para>
56839 When <option>bounce_message_file</option> is set, it must point to a template file for
56840 constructing error messages. The file consists of a series of text items,
56841 separated by lines consisting of exactly four asterisks. If the file cannot be
56842 opened, default text is used and a message is written to the main and panic
56843 logs. If any text item in the file is empty, default text is used for that
56844 item.
56845 </para>
56846 <para>
56847 <indexterm role="variable">
56848 <primary><varname>$bounce_recipient</varname></primary>
56849 </indexterm>
56850 <indexterm role="variable">
56851 <primary><varname>$bounce_return_size_limit</varname></primary>
56852 </indexterm>
56853 Each item of text that is read from the file is expanded, and there are two
56854 expansion variables which can be of use here: <varname>$bounce_recipient</varname> is set to
56855 the recipient of an error message while it is being created, and
56856 <varname>$bounce_return_size_limit</varname> contains the value of the <option>return_size_limit</option>
56857 option, rounded to a whole number.
56858 </para>
56859 <para>
56860 The items must appear in the file in the following order:
56861 </para>
56862 <itemizedlist>
56863 <listitem>
56864 <para>
56865 The first item is included in the headers, and should include at least a
56866 <emphasis>Subject:</emphasis> header. Exim does not check the syntax of these headers.
56867 </para>
56868 </listitem>
56869 <listitem>
56870 <para>
56871 The second item forms the start of the error message. After it, Exim lists the
56872 failing addresses with their error messages.
56873 </para>
56874 </listitem>
56875 <listitem>
56876 <para>
56877 The third item is used to introduce any text from pipe transports that is to be
56878 returned to the sender. It is omitted if there is no such text.
56879 </para>
56880 </listitem>
56881 <listitem>
56882 <para>
56883 The fourth item is used to introduce the copy of the message that is returned
56884 as part of the error report.
56885 </para>
56886 </listitem>
56887 <listitem>
56888 <para>
56889 The fifth item is added after the fourth one if the returned message is
56890 truncated because it is bigger than <option>return_size_limit</option>.
56891 </para>
56892 </listitem>
56893 <listitem>
56894 <para>
56895 The sixth item is added after the copy of the original message.
56896 </para>
56897 </listitem>
56898 </itemizedlist>
56899 <para>
56900 The default state (<option>bounce_message_file</option> unset) is equivalent to the
56901 following file, in which the sixth item is empty. The <emphasis>Subject:</emphasis> and some
56902 other lines have been split in order to fit them on the page:
56903 </para>
56904 <literallayout class="monospaced">
56905 Subject: Mail delivery failed
56906   ${if eq{$sender_address}{$bounce_recipient}
56907   {: returning message to sender}}
56908 ****
56909 This message was created automatically by mail delivery software.
56910
56911 A message ${if eq{$sender_address}{$bounce_recipient}
56912   {that you sent }{sent by
56913
56914 &lt;$sender_address&gt;
56915
56916 }}could not be delivered to all of its recipients.
56917 This is a permanent error. The following address(es) failed:
56918 ****
56919 The following text was generated during the delivery attempt(s):
56920 ****
56921 ------ This is a copy of the message, including all the headers.
56922   ------
56923 ****
56924 ------ The body of the message is $message_size characters long;
56925   only the first
56926 ------ $bounce_return_size_limit or so are included here.
56927 ****
56928 </literallayout>
56929 </section>
56930 <section id="SECTcustwarn">
56931 <title>Customizing warning messages</title>
56932 <para>
56933 <indexterm role="concept">
56934 <primary>customizing</primary>
56935 <secondary>warning message</secondary>
56936 </indexterm>
56937 <indexterm role="concept">
56938 <primary>warning of delay</primary>
56939 <secondary>customizing the message</secondary>
56940 </indexterm>
56941 The option <option>warn_message_file</option> can be pointed at a template file for use when
56942 warnings about message delays are created. In this case there are only three
56943 text sections:
56944 </para>
56945 <itemizedlist>
56946 <listitem>
56947 <para>
56948 The first item is included in the headers, and should include at least a
56949 <emphasis>Subject:</emphasis> header. Exim does not check the syntax of these headers.
56950 </para>
56951 </listitem>
56952 <listitem>
56953 <para>
56954 The second item forms the start of the warning message. After it, Exim lists
56955 the delayed addresses.
56956 </para>
56957 </listitem>
56958 <listitem>
56959 <para>
56960 The third item then ends the message.
56961 </para>
56962 </listitem>
56963 </itemizedlist>
56964 <para>
56965 The default state is equivalent to the following file, except that some lines
56966 have been split here, in order to fit them on the page:
56967 </para>
56968 <literallayout class="monospaced">
56969 Subject: Warning: message $message_exim_id delayed
56970   $warn_message_delay
56971 ****
56972 This message was created automatically by mail delivery software.
56973
56974 A message ${if eq{$sender_address}{$warn_message_recipients}
56975 {that you sent }{sent by
56976
56977 &lt;$sender_address&gt;
56978
56979 }}has not been delivered to all of its recipients after
56980 more than $warn_message_delay on the queue on $primary_hostname.
56981
56982 The message identifier is:     $message_exim_id
56983 The subject of the message is: $h_subject
56984 The date of the message is:    $h_date
56985
56986 The following address(es) have not yet been delivered:
56987 ****
56988 No action is required on your part. Delivery attempts will
56989 continue for some time, and this warning may be repeated at
56990 intervals if the message remains undelivered. Eventually the
56991 mail delivery software will give up, and when that happens,
56992 the message will be returned to you.
56993 </literallayout>
56994 <para>
56995 <indexterm role="variable">
56996 <primary><varname>$warn_message_delay</varname></primary>
56997 </indexterm>
56998 <indexterm role="variable">
56999 <primary><varname>$warn_message_recipients</varname></primary>
57000 </indexterm>
57001 However, in the default state the subject and date lines are omitted if no
57002 appropriate headers exist. During the expansion of this file,
57003 <varname>$warn_message_delay</varname> is set to the delay time in one of the forms <quote>&lt;<emphasis>n</emphasis>&gt;
57004 minutes</quote> or <quote>&lt;<emphasis>n</emphasis>&gt; hours</quote>, and <varname>$warn_message_recipients</varname> contains a list
57005 of recipients for the warning message. There may be more than one if there are
57006 multiple addresses with different <option>errors_to</option> settings on the routers that
57007 handled them.
57008 </para>
57009 </section>
57010 </chapter>
57011
57012 <chapter id="CHAPcomconreq">
57013 <title>Some common configuration settings</title>
57014 <para>
57015 This chapter discusses some configuration settings that seem to be fairly
57016 common. More examples and discussion can be found in the Exim book.
57017 </para>
57018 <section id="SECID240">
57019 <title>Sending mail to a smart host</title>
57020 <para>
57021 <indexterm role="concept">
57022 <primary>smart host</primary>
57023 <secondary>example router</secondary>
57024 </indexterm>
57025 If you want to send all mail for non-local domains to a <quote>smart host</quote>, you
57026 should replace the default <command>dnslookup</command> router with a router which does the
57027 routing explicitly:
57028 </para>
57029 <literallayout class="monospaced">
57030 send_to_smart_host:
57031   driver = manualroute
57032   route_list = !+local_domains smart.host.name
57033   transport = remote_smtp
57034 </literallayout>
57035 <para>
57036 You can use the smart host&#x2019;s IP address instead of the name if you wish.
57037 If you are using Exim only to submit messages to a smart host, and not for
57038 receiving incoming messages, you can arrange for it to do the submission
57039 synchronously by setting the <option>mua_wrapper</option> option (see chapter
57040 <xref linkend="CHAPnonqueueing"/>).
57041 </para>
57042 </section>
57043 <section id="SECTmailinglists">
57044 <title>Using Exim to handle mailing lists</title>
57045 <para>
57046 <indexterm role="concept">
57047 <primary>mailing lists</primary>
57048 </indexterm>
57049 Exim can be used to run simple mailing lists, but for large and/or complicated
57050 requirements, the use of additional specialized mailing list software such as
57051 Majordomo or Mailman is recommended.
57052 </para>
57053 <para>
57054 The <command>redirect</command> router can be used to handle mailing lists where each list
57055 is maintained in a separate file, which can therefore be managed by an
57056 independent manager. The <option>domains</option> router option can be used to run these
57057 lists in a separate domain from normal mail. For example:
57058 </para>
57059 <literallayout class="monospaced">
57060 lists:
57061   driver = redirect
57062   domains = lists.example
57063   file = /usr/lists/$local_part
57064   forbid_pipe
57065   forbid_file
57066   errors_to = $local_part-request@lists.example
57067   no_more
57068 </literallayout>
57069 <para>
57070 This router is skipped for domains other than <emphasis>lists.example</emphasis>. For addresses
57071 in that domain, it looks for a file that matches the local part. If there is no
57072 such file, the router declines, but because <option>no_more</option> is set, no subsequent
57073 routers are tried, and so the whole delivery fails.
57074 </para>
57075 <para>
57076 The <option>forbid_pipe</option> and <option>forbid_file</option> options prevent a local part from being
57077 expanded into a file name or a pipe delivery, which is usually inappropriate in
57078 a mailing list.
57079 </para>
57080 <para>
57081 <indexterm role="option">
57082 <primary><option>errors_to</option></primary>
57083 </indexterm>
57084 The <option>errors_to</option> option specifies that any delivery errors caused by addresses
57085 taken from a mailing list are to be sent to the given address rather than the
57086 original sender of the message. However, before acting on this, Exim verifies
57087 the error address, and ignores it if verification fails.
57088 </para>
57089 <para>
57090 For example, using the configuration above, mail sent to
57091 <emphasis>dicts@lists.example</emphasis> is passed on to those addresses contained in
57092 <filename>/usr/lists/dicts</filename>, with error reports directed to
57093 <emphasis>dicts-request@lists.example</emphasis>, provided that this address can be verified.
57094 There could be a file called <filename>/usr/lists/dicts-request</filename> containing
57095 the address(es) of this particular list&#x2019;s manager(s), but other approaches,
57096 such as setting up an earlier router (possibly using the <option>local_part_prefix</option>
57097 or <option>local_part_suffix</option> options) to handle addresses of the form
57098 <option>owner-</option><emphasis>xxx</emphasis> or <option>xxx-</option><emphasis>request</emphasis>, are also possible.
57099 </para>
57100 </section>
57101 <section id="SECID241">
57102 <title>Syntax errors in mailing lists</title>
57103 <para>
57104 <indexterm role="concept">
57105 <primary>mailing lists</primary>
57106 <secondary>syntax errors in</secondary>
57107 </indexterm>
57108 If an entry in redirection data contains a syntax error, Exim normally defers
57109 delivery of the original address. That means that a syntax error in a mailing
57110 list holds up all deliveries to the list. This may not be appropriate when a
57111 list is being maintained automatically from data supplied by users, and the
57112 addresses are not rigorously checked.
57113 </para>
57114 <para>
57115 If the <option>skip_syntax_errors</option> option is set, the <command>redirect</command> router just skips
57116 entries that fail to parse, noting the incident in the log. If in addition
57117 <option>syntax_errors_to</option> is set to a verifiable address, a message is sent to it
57118 whenever a broken address is skipped. It is usually appropriate to set
57119 <option>syntax_errors_to</option> to the same address as <option>errors_to</option>.
57120 </para>
57121 </section>
57122 <section id="SECID242">
57123 <title>Re-expansion of mailing lists</title>
57124 <para>
57125 <indexterm role="concept">
57126 <primary>mailing lists</primary>
57127 <secondary>re-expansion of</secondary>
57128 </indexterm>
57129 Exim remembers every individual address to which a message has been delivered,
57130 in order to avoid duplication, but it normally stores only the original
57131 recipient addresses with a message. If all the deliveries to a mailing list
57132 cannot be done at the first attempt, the mailing list is re-expanded when the
57133 delivery is next tried. This means that alterations to the list are taken into
57134 account at each delivery attempt, so addresses that have been added to
57135 the list since the message arrived will therefore receive a copy of the
57136 message, even though it pre-dates their subscription.
57137 </para>
57138 <para>
57139 If this behaviour is felt to be undesirable, the <option>one_time</option> option can be set
57140 on the <command>redirect</command> router. If this is done, any addresses generated by the
57141 router that fail to deliver at the first attempt are added to the message as
57142 <quote>top level</quote> addresses, and the parent address that generated them is marked
57143 <quote>delivered</quote>. Thus, expansion of the mailing list does not happen again at the
57144 subsequent delivery attempts. The disadvantage of this is that if any of the
57145 failing addresses are incorrect, correcting them in the file has no effect on
57146 pre-existing messages.
57147 </para>
57148 <para>
57149 The original top-level address is remembered with each of the generated
57150 addresses, and is output in any log messages. However, any intermediate parent
57151 addresses are not recorded. This makes a difference to the log only if the
57152 <option>all_parents</option> selector is set, but for mailing lists there is normally only
57153 one level of expansion anyway.
57154 </para>
57155 </section>
57156 <section id="SECID243">
57157 <title>Closed mailing lists</title>
57158 <para>
57159 <indexterm role="concept">
57160 <primary>mailing lists</primary>
57161 <secondary>closed</secondary>
57162 </indexterm>
57163 The examples so far have assumed open mailing lists, to which anybody may
57164 send mail. It is also possible to set up closed lists, where mail is accepted
57165 from specified senders only. This is done by making use of the generic
57166 <option>senders</option> option to restrict the router that handles the list.
57167 </para>
57168 <para>
57169 The following example uses the same file as a list of recipients and as a list
57170 of permitted senders. It requires three routers:
57171 </para>
57172 <literallayout class="monospaced">
57173 lists_request:
57174   driver = redirect
57175   domains = lists.example
57176   local_part_suffix = -request
57177   file = /usr/lists/$local_part$local_part_suffix
57178   no_more
57179
57180 lists_post:
57181   driver = redirect
57182   domains = lists.example
57183   senders = ${if exists {/usr/lists/$local_part}\
57184              {lsearch;/usr/lists/$local_part}{*}}
57185   file = /usr/lists/$local_part
57186   forbid_pipe
57187   forbid_file
57188   errors_to = $local_part-request@lists.example
57189   no_more
57190
57191 lists_closed:
57192   driver = redirect
57193   domains = lists.example
57194   allow_fail
57195   data = :fail: $local_part@lists.example is a closed mailing list
57196 </literallayout>
57197 <para>
57198 All three routers have the same <option>domains</option> setting, so for any other domains,
57199 they are all skipped. The first router runs only if the local part ends in
57200 <option>-request</option>. It handles messages to the list manager(s) by means of an open
57201 mailing list.
57202 </para>
57203 <para>
57204 The second router runs only if the <option>senders</option> precondition is satisfied. It
57205 checks for the existence of a list that corresponds to the local part, and then
57206 checks that the sender is on the list by means of a linear search. It is
57207 necessary to check for the existence of the file before trying to search it,
57208 because otherwise Exim thinks there is a configuration error. If the file does
57209 not exist, the expansion of <option>senders</option> is *, which matches all senders. This
57210 means that the router runs, but because there is no list, declines, and
57211 <option>no_more</option> ensures that no further routers are run. The address fails with an
57212 <quote>unrouteable address</quote> error.
57213 </para>
57214 <para>
57215 The third router runs only if the second router is skipped, which happens when
57216 a mailing list exists, but the sender is not on it. This router forcibly fails
57217 the address, giving a suitable error message.
57218 </para>
57219 </section>
57220 <section id="SECTverp">
57221 <title>Variable Envelope Return Paths (VERP)</title>
57222 <para>
57223 <indexterm role="concept">
57224 <primary>VERP</primary>
57225 </indexterm>
57226 <indexterm role="concept">
57227 <primary>Variable Envelope Return Paths</primary>
57228 </indexterm>
57229 <indexterm role="concept">
57230 <primary>envelope sender</primary>
57231 </indexterm>
57232 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;
57233 are a way of helping mailing list administrators discover which subscription
57234 address is the cause of a particular delivery failure. The idea is to encode
57235 the original recipient address in the outgoing envelope sender address, so that
57236 if the message is forwarded by another host and then subsequently bounces, the
57237 original recipient can be extracted from the recipient address of the bounce.
57238 </para>
57239 <para>
57240 <indexterm role="option">
57241 <primary><option>errors_to</option></primary>
57242 </indexterm>
57243 <indexterm role="option">
57244 <primary><option>return_path</option></primary>
57245 </indexterm>
57246 Envelope sender addresses can be modified by Exim using two different
57247 facilities: the <option>errors_to</option> option on a router (as shown in previous mailing
57248 list examples), or the <option>return_path</option> option on a transport. The second of
57249 these is effective only if the message is successfully delivered to another
57250 host; it is not used for errors detected on the local host (see the description
57251 of <option>return_path</option> in chapter <xref linkend="CHAPtransportgeneric"/>). Here is an example
57252 of the use of <option>return_path</option> to implement VERP on an <command>smtp</command> transport:
57253 </para>
57254 <literallayout class="monospaced">
57255 verp_smtp:
57256   driver = smtp
57257   max_rcpt = 1
57258   return_path = \
57259     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
57260       {$1-request+$local_part=$domain@your.dom.example}fail}
57261 </literallayout>
57262 <para>
57263 This has the effect of rewriting the return path (envelope sender) on outgoing
57264 SMTP messages, if the local part of the original return path ends in
57265 <quote>-request</quote>, and the domain is <emphasis>your.dom.example</emphasis>. The rewriting inserts the
57266 local part and domain of the recipient into the return path. Suppose, for
57267 example, that a message whose return path has been set to
57268 <emphasis>somelist-request@your.dom.example</emphasis> is sent to
57269 <emphasis>subscriber@other.dom.example</emphasis>. In the transport, the return path is
57270 rewritten as
57271 </para>
57272 <literallayout class="monospaced">
57273 somelist-request+subscriber=other.dom.example@your.dom.example
57274 </literallayout>
57275 <para>
57276 <indexterm role="variable">
57277 <primary><varname>$local_part</varname></primary>
57278 </indexterm>
57279 For this to work, you must tell Exim to send multiple copies of messages that
57280 have more than one recipient, so that each copy has just one recipient. This is
57281 achieved by setting <option>max_rcpt</option> to 1. Without this, a single copy of a message
57282 might be sent to several different recipients in the same domain, in which case
57283 <varname>$local_part</varname> is not available in the transport, because it is not unique.
57284 </para>
57285 <para>
57286 Unless your host is doing nothing but mailing list deliveries, you should
57287 probably use a separate transport for the VERP deliveries, so as not to use
57288 extra resources in making one-per-recipient copies for other deliveries. This
57289 can easily be done by expanding the <option>transport</option> option in the router:
57290 </para>
57291 <literallayout class="monospaced">
57292 dnslookup:
57293   driver = dnslookup
57294   domains = ! +local_domains
57295   transport = \
57296     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
57297       {verp_smtp}{remote_smtp}}
57298   no_more
57299 </literallayout>
57300 <para>
57301 If you want to change the return path using <option>errors_to</option> in a router instead
57302 of using <option>return_path</option> in the transport, you need to set <option>errors_to</option> on all
57303 routers that handle mailing list addresses. This will ensure that all delivery
57304 errors, including those detected on the local host, are sent to the VERP
57305 address.
57306 </para>
57307 <para>
57308 On a host that does no local deliveries and has no manual routing, only the
57309 <command>dnslookup</command> router needs to be changed. A special transport is not needed for
57310 SMTP deliveries. Every mailing list recipient has its own return path value,
57311 and so Exim must hand them to the transport one at a time. Here is an example
57312 of a <command>dnslookup</command> router that implements VERP:
57313 </para>
57314 <literallayout class="monospaced">
57315 verp_dnslookup:
57316   driver = dnslookup
57317   domains = ! +local_domains
57318   transport = remote_smtp
57319   errors_to = \
57320     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}}
57321      {$1-request+$local_part=$domain@your.dom.example}fail}
57322   no_more
57323 </literallayout>
57324 <para>
57325 Before you start sending out messages with VERPed return paths, you must also
57326 configure Exim to accept the bounce messages that come back to those paths.
57327 Typically this is done by setting a <option>local_part_suffix</option> option for a
57328 router, and using this to route the messages to wherever you want to handle
57329 them.
57330 </para>
57331 <para>
57332 The overhead incurred in using VERP depends very much on the size of the
57333 message, the number of recipient addresses that resolve to the same remote
57334 host, and the speed of the connection over which the message is being sent. If
57335 a lot of addresses resolve to the same host and the connection is slow, sending
57336 a separate copy of the message for each address may take substantially longer
57337 than sending a single copy with many recipients (for which VERP cannot be
57338 used).
57339 </para>
57340 </section>
57341 <section id="SECTvirtualdomains">
57342 <title>Virtual domains</title>
57343 <para>
57344 <indexterm role="concept">
57345 <primary>virtual domains</primary>
57346 </indexterm>
57347 <indexterm role="concept">
57348 <primary>domain</primary>
57349 <secondary>virtual</secondary>
57350 </indexterm>
57351 The phrase <emphasis>virtual domain</emphasis> is unfortunately used with two rather different
57352 meanings:
57353 </para>
57354 <itemizedlist>
57355 <listitem>
57356 <para>
57357 A domain for which there are no real mailboxes; all valid local parts are
57358 aliases for other email addresses. Common examples are organizational
57359 top-level domains and <quote>vanity</quote> domains.
57360 </para>
57361 </listitem>
57362 <listitem>
57363 <para>
57364 One of a number of independent domains that are all handled by the same host,
57365 with mailboxes on that host, but where the mailbox owners do not necessarily
57366 have login accounts on that host.
57367 </para>
57368 </listitem>
57369 </itemizedlist>
57370 <para>
57371 The first usage is probably more common, and does seem more <quote>virtual</quote> than
57372 the second. This kind of domain can be handled in Exim with a straightforward
57373 aliasing router. One approach is to create a separate alias file for each
57374 virtual domain. Exim can test for the existence of the alias file to determine
57375 whether the domain exists. The <command>dsearch</command> lookup type is useful here, leading
57376 to a router of this form:
57377 </para>
57378 <literallayout class="monospaced">
57379 virtual:
57380   driver = redirect
57381   domains = dsearch;/etc/mail/virtual
57382   data = ${lookup{$local_part}lsearch{/etc/mail/virtual/$domain}}
57383   no_more
57384 </literallayout>
57385 <para>
57386 The <option>domains</option> option specifies that the router is to be skipped, unless there
57387 is a file in the <filename>/etc/mail/virtual</filename> directory whose name is the same as the
57388 domain that is being processed. When the router runs, it looks up the local
57389 part in the file to find a new address (or list of addresses). The <option>no_more</option>
57390 setting ensures that if the lookup fails (leading to <option>data</option> being an empty
57391 string), Exim gives up on the address without trying any subsequent routers.
57392 </para>
57393 <para>
57394 This one router can handle all the virtual domains because the alias file names
57395 follow a fixed pattern. Permissions can be arranged so that appropriate people
57396 can edit the different alias files. A successful aliasing operation results in
57397 a new envelope recipient address, which is then routed from scratch.
57398 </para>
57399 <para>
57400 The other kind of <quote>virtual</quote> domain can also be handled in a straightforward
57401 way. One approach is to create a file for each domain containing a list of
57402 valid local parts, and use it in a router like this:
57403 </para>
57404 <literallayout class="monospaced">
57405 my_domains:
57406   driver = accept
57407   domains = dsearch;/etc/mail/domains
57408   local_parts = lsearch;/etc/mail/domains/$domain
57409   transport = my_mailboxes
57410 </literallayout>
57411 <para>
57412 The address is accepted if there is a file for the domain, and the local part
57413 can be found in the file. The <option>domains</option> option is used to check for the
57414 file&#x2019;s existence because <option>domains</option> is tested before the <option>local_parts</option>
57415 option (see section <xref linkend="SECTrouprecon"/>). You cannot use <option>require_files</option>,
57416 because that option is tested after <option>local_parts</option>. The transport is as
57417 follows:
57418 </para>
57419 <literallayout class="monospaced">
57420 my_mailboxes:
57421   driver = appendfile
57422   file = /var/mail/$domain/$local_part
57423   user = mail
57424 </literallayout>
57425 <para>
57426 This uses a directory of mailboxes for each domain. The <option>user</option> setting is
57427 required, to specify which uid is to be used for writing to the mailboxes.
57428 </para>
57429 <para>
57430 The configuration shown here is just one example of how you might support this
57431 requirement. There are many other ways this kind of configuration can be set
57432 up, for example, by using a database instead of separate files to hold all the
57433 information about the domains.
57434 </para>
57435 </section>
57436 <section id="SECTmulbox">
57437 <title>Multiple user mailboxes</title>
57438 <para>
57439 <indexterm role="concept">
57440 <primary>multiple mailboxes</primary>
57441 </indexterm>
57442 <indexterm role="concept">
57443 <primary>mailbox</primary>
57444 <secondary>multiple</secondary>
57445 </indexterm>
57446 <indexterm role="concept">
57447 <primary>local part</primary>
57448 <secondary>prefix</secondary>
57449 </indexterm>
57450 <indexterm role="concept">
57451 <primary>local part</primary>
57452 <secondary>suffix</secondary>
57453 </indexterm>
57454 Heavy email users often want to operate with multiple mailboxes, into which
57455 incoming mail is automatically sorted. A popular way of handling this is to
57456 allow users to use multiple sender addresses, so that replies can easily be
57457 identified. Users are permitted to add prefixes or suffixes to their local
57458 parts for this purpose. The wildcard facility of the generic router options
57459 <option>local_part_prefix</option> and <option>local_part_suffix</option> can be used for this. For
57460 example, consider this router:
57461 </para>
57462 <literallayout class="monospaced">
57463 userforward:
57464   driver = redirect
57465   check_local_user
57466   file = $home/.forward
57467   local_part_suffix = -*
57468   local_part_suffix_optional
57469   allow_filter
57470 </literallayout>
57471 <para>
57472 <indexterm role="variable">
57473 <primary><varname>$local_part_suffix</varname></primary>
57474 </indexterm>
57475 It runs a user&#x2019;s <filename>.forward</filename> file for all local parts of the form
57476 <emphasis>username-*</emphasis>. Within the filter file the user can distinguish different
57477 cases by testing the variable <varname>$local_part_suffix</varname>. For example:
57478 </para>
57479 <literallayout class="monospaced">
57480 if $local_part_suffix contains -special then
57481 save /home/$local_part/Mail/special
57482 endif
57483 </literallayout>
57484 <para>
57485 If the filter file does not exist, or does not deal with such addresses, they
57486 fall through to subsequent routers, and, assuming no subsequent use of the
57487 <option>local_part_suffix</option> option is made, they presumably fail. Thus, users have
57488 control over which suffixes are valid.
57489 </para>
57490 <para>
57491 Alternatively, a suffix can be used to trigger the use of a different
57492 <filename>.forward</filename> file &ndash; which is the way a similar facility is implemented in
57493 another MTA:
57494 </para>
57495 <literallayout class="monospaced">
57496 userforward:
57497   driver = redirect
57498   check_local_user
57499   file = $home/.forward$local_part_suffix
57500   local_part_suffix = -*
57501   local_part_suffix_optional
57502   allow_filter
57503 </literallayout>
57504 <para>
57505 If there is no suffix, <filename>.forward</filename> is used; if the suffix is <emphasis>-special</emphasis>, for
57506 example, <filename>.forward-special</filename> is used. Once again, if the appropriate file
57507 does not exist, or does not deal with the address, it is passed on to
57508 subsequent routers, which could, if required, look for an unqualified
57509 <filename>.forward</filename> file to use as a default.
57510 </para>
57511 </section>
57512 <section id="SECID244">
57513 <title>Simplified vacation processing</title>
57514 <para>
57515 <indexterm role="concept">
57516 <primary>vacation processing</primary>
57517 </indexterm>
57518 The traditional way of running the <emphasis>vacation</emphasis> program is for a user to set up
57519 a pipe command in a <filename>.forward</filename> file
57520 (see section <xref linkend="SECTspecitredli"/> for syntax details).
57521 This is prone to error by inexperienced users. There are two features of Exim
57522 that can be used to make this process simpler for users:
57523 </para>
57524 <itemizedlist>
57525 <listitem>
57526 <para>
57527 A local part prefix such as <quote>vacation-</quote> can be specified on a router which
57528 can cause the message to be delivered directly to the <emphasis>vacation</emphasis> program, or
57529 alternatively can use Exim&#x2019;s <command>autoreply</command> transport. The contents of a user&#x2019;s
57530 <filename>.forward</filename> file are then much simpler. For example:
57531 </para>
57532 <literallayout class="monospaced">
57533 spqr, vacation-spqr
57534 </literallayout>
57535 </listitem>
57536 <listitem>
57537 <para>
57538 The <option>require_files</option> generic router option can be used to trigger a
57539 vacation delivery by checking for the existence of a certain file in the
57540 user&#x2019;s home directory. The <option>unseen</option> generic option should also be used, to
57541 ensure that the original delivery also proceeds. In this case, all the user has
57542 to do is to create a file called, say, <filename>.vacation</filename>, containing a vacation
57543 message.
57544 </para>
57545 </listitem>
57546 </itemizedlist>
57547 <para>
57548 Another advantage of both these methods is that they both work even when the
57549 use of arbitrary pipes by users is locked out.
57550 </para>
57551 </section>
57552 <section id="SECID245">
57553 <title>Taking copies of mail</title>
57554 <para>
57555 <indexterm role="concept">
57556 <primary>message</primary>
57557 <secondary>copying every</secondary>
57558 </indexterm>
57559 Some installations have policies that require archive copies of all messages to
57560 be made. A single copy of each message can easily be taken by an appropriate
57561 command in a system filter, which could, for example, use a different file for
57562 each day&#x2019;s messages.
57563 </para>
57564 <para>
57565 There is also a shadow transport mechanism that can be used to take copies of
57566 messages that are successfully delivered by local transports, one copy per
57567 delivery. This could be used, <emphasis>inter alia</emphasis>, to implement automatic
57568 notification of delivery by sites that insist on doing such things.
57569 </para>
57570 </section>
57571 <section id="SECID246">
57572 <title>Intermittently connected hosts</title>
57573 <para>
57574 <indexterm role="concept">
57575 <primary>intermittently connected hosts</primary>
57576 </indexterm>
57577 It has become quite common (because it is cheaper) for hosts to connect to the
57578 Internet periodically rather than remain connected all the time. The normal
57579 arrangement is that mail for such hosts accumulates on a system that is
57580 permanently connected.
57581 </para>
57582 <para>
57583 Exim was designed for use on permanently connected hosts, and so it is not
57584 particularly well-suited to use in an intermittently connected environment.
57585 Nevertheless there are some features that can be used.
57586 </para>
57587 </section>
57588 <section id="SECID247">
57589 <title>Exim on the upstream server host</title>
57590 <para>
57591 It is tempting to arrange for incoming mail for the intermittently connected
57592 host to remain on Exim&#x2019;s queue until the client connects. However, this
57593 approach does not scale very well. Two different kinds of waiting message are
57594 being mixed up in the same queue &ndash; those that cannot be delivered because of
57595 some temporary problem, and those that are waiting for their destination host
57596 to connect. This makes it hard to manage the queue, as well as wasting
57597 resources, because each queue runner scans the entire queue.
57598 </para>
57599 <para>
57600 A better approach is to separate off those messages that are waiting for an
57601 intermittently connected host. This can be done by delivering these messages
57602 into local files in batch SMTP, <quote>mailstore</quote>, or other envelope-preserving
57603 format, from where they are transmitted by other software when their
57604 destination connects. This makes it easy to collect all the mail for one host
57605 in a single directory, and to apply local timeout rules on a per-message basis
57606 if required.
57607 </para>
57608 <para>
57609 On a very small scale, leaving the mail on Exim&#x2019;s queue can be made to work. If
57610 you are doing this, you should configure Exim with a long retry period for the
57611 intermittent host. For example:
57612 </para>
57613 <literallayout class="monospaced">
57614 cheshire.wonderland.fict.example    *   F,5d,24h
57615 </literallayout>
57616 <para>
57617 This stops a lot of failed delivery attempts from occurring, but Exim remembers
57618 which messages it has queued up for that host. Once the intermittent host comes
57619 online, forcing delivery of one message (either by using the <option>-M</option> or <option>-R</option>
57620 options, or by using the ETRN SMTP command (see section <xref linkend="SECTETRN"/>)
57621 causes all the queued up messages to be delivered, often down a single SMTP
57622 connection. While the host remains connected, any new messages get delivered
57623 immediately.
57624 </para>
57625 <para>
57626 If the connecting hosts do not have fixed IP addresses, that is, if a host is
57627 issued with a different IP address each time it connects, Exim&#x2019;s retry
57628 mechanisms on the holding host get confused, because the IP address is normally
57629 used as part of the key string for holding retry information. This can be
57630 avoided by unsetting <option>retry_include_ip_address</option> on the <command>smtp</command> transport.
57631 Since this has disadvantages for permanently connected hosts, it is best to
57632 arrange a separate transport for the intermittently connected ones.
57633 </para>
57634 </section>
57635 <section id="SECID248">
57636 <title>Exim on the intermittently connected client host</title>
57637 <para>
57638 The value of <option>smtp_accept_queue_per_connection</option> should probably be
57639 increased, or even set to zero (that is, disabled) on the intermittently
57640 connected host, so that all incoming messages down a single connection get
57641 delivered immediately.
57642 </para>
57643 <para>
57644 <indexterm role="concept">
57645 <primary>SMTP</primary>
57646 <secondary>passed connection</secondary>
57647 </indexterm>
57648 <indexterm role="concept">
57649 <primary>SMTP</primary>
57650 <secondary>multiple deliveries</secondary>
57651 </indexterm>
57652 <indexterm role="concept">
57653 <primary>multiple SMTP deliveries</primary>
57654 </indexterm>
57655 Mail waiting to be sent from an intermittently connected host will probably
57656 not have been routed, because without a connection DNS lookups are not
57657 possible. This means that if a normal queue run is done at connection time,
57658 each message is likely to be sent in a separate SMTP session. This can be
57659 avoided by starting the queue run with a command line option beginning with
57660 <option>-qq</option> instead of <option>-q</option>. In this case, the queue is scanned twice. In the
57661 first pass, routing is done but no deliveries take place. The second pass is a
57662 normal queue run; since all the messages have been previously routed, those
57663 destined for the same host are likely to get sent as multiple deliveries in a
57664 single SMTP connection.
57665 </para>
57666 </section>
57667 </chapter>
57668
57669 <chapter id="CHAPnonqueueing">
57670 <title>Using Exim as a non-queueing client</title>
57671 <titleabbrev>Exim as a non-queueing client</titleabbrev>
57672 <para>
57673 <indexterm role="concept">
57674 <primary>client, non-queueing</primary>
57675 </indexterm>
57676 <indexterm role="concept">
57677 <primary>smart host</primary>
57678 <secondary>suppressing queueing</secondary>
57679 </indexterm>
57680 On a personal computer, it is a common requirement for all
57681 email to be sent to a <quote>smart host</quote>. There are plenty of MUAs that can be
57682 configured to operate that way, for all the popular operating systems.
57683 However, there are some MUAs for Unix-like systems that cannot be so
57684 configured: they submit messages using the command line interface of
57685 <filename>/usr/sbin/sendmail</filename>. Furthermore, utility programs such as <emphasis>cron</emphasis> submit
57686 messages this way.
57687 </para>
57688 <para>
57689 If the personal computer runs continuously, there is no problem, because it can
57690 run a conventional MTA that handles delivery to the smart host, and deal with
57691 any delays via its queueing mechanism. However, if the computer does not run
57692 continuously or runs different operating systems at different times, queueing
57693 email is not desirable.
57694 </para>
57695 <para>
57696 There is therefore a requirement for something that can provide the
57697 <filename>/usr/sbin/sendmail</filename> interface but deliver messages to a smart host without
57698 any queueing or retrying facilities. Furthermore, the delivery to the smart
57699 host should be synchronous, so that if it fails, the sending MUA is immediately
57700 informed. In other words, we want something that extends an MUA that submits
57701 to a local MTA via the command line so that it behaves like one that submits
57702 to a remote smart host using TCP/SMTP.
57703 </para>
57704 <para>
57705 There are a number of applications (for example, there is one called <emphasis>ssmtp</emphasis>)
57706 that do this job. However, people have found them to be lacking in various
57707 ways. For instance, you might want to allow aliasing and forwarding to be done
57708 before sending a message to the smart host.
57709 </para>
57710 <para>
57711 Exim already had the necessary infrastructure for doing this job. Just a few
57712 tweaks were needed to make it behave as required, though it is somewhat of an
57713 overkill to use a fully-featured MTA for this purpose.
57714 </para>
57715 <para>
57716 <indexterm role="option">
57717 <primary><option>mua_wrapper</option></primary>
57718 </indexterm>
57719 There is a Boolean global option called <option>mua_wrapper</option>, defaulting false.
57720 Setting <option>mua_wrapper</option> true causes Exim to run in a special mode where it
57721 assumes that it is being used to <quote>wrap</quote> a command-line MUA in the manner
57722 just described. As well as setting <option>mua_wrapper</option>, you also need to provide a
57723 compatible router and transport configuration. Typically there will be just one
57724 router and one transport, sending everything to a smart host.
57725 </para>
57726 <para>
57727 When run in MUA wrapping mode, the behaviour of Exim changes in the
57728 following ways:
57729 </para>
57730 <itemizedlist>
57731 <listitem>
57732 <para>
57733 A daemon cannot be run, nor will Exim accept incoming messages from <emphasis>inetd</emphasis>.
57734 In other words, the only way to submit messages is via the command line.
57735 </para>
57736 </listitem>
57737 <listitem>
57738 <para>
57739 Each message is synchronously delivered as soon as it is received (<option>-odi</option> is
57740 assumed). All queueing options (<option>queue_only</option>, <option>queue_smtp_domains</option>,
57741 <option>control</option> in an ACL, etc.) are quietly ignored. The Exim reception process
57742 does not finish until the delivery attempt is complete. If the delivery is
57743 successful, a zero return code is given.
57744 </para>
57745 </listitem>
57746 <listitem>
57747 <para>
57748 Address redirection is permitted, but the final routing for all addresses must
57749 be to the same remote transport, and to the same list of hosts. Furthermore,
57750 the return address (envelope sender) must be the same for all recipients, as
57751 must any added or deleted header lines. In other words, it must be possible to
57752 deliver the message in a single SMTP transaction, however many recipients there
57753 are.
57754 </para>
57755 </listitem>
57756 <listitem>
57757 <para>
57758 If these conditions are not met, or if routing any address results in a
57759 failure or defer status, or if Exim is unable to deliver all the recipients
57760 successfully to one of the smart hosts, delivery of the entire message fails.
57761 </para>
57762 </listitem>
57763 <listitem>
57764 <para>
57765 Because no queueing is allowed, all failures are treated as permanent; there
57766 is no distinction between 4<emphasis>xx</emphasis> and 5<emphasis>xx</emphasis> SMTP response codes from the
57767 smart host. Furthermore, because only a single yes/no response can be given to
57768 the caller, it is not possible to deliver to some recipients and not others. If
57769 there is an error (temporary or permanent) for any recipient, all are failed.
57770 </para>
57771 </listitem>
57772 <listitem>
57773 <para>
57774 If more than one smart host is listed, Exim will try another host after a
57775 connection failure or a timeout, in the normal way. However, if this kind of
57776 failure happens for all the hosts, the delivery fails.
57777 </para>
57778 </listitem>
57779 <listitem>
57780 <para>
57781 When delivery fails, an error message is written to the standard error stream
57782 (as well as to Exim&#x2019;s log), and Exim exits to the caller with a return code
57783 value 1. The message is expunged from Exim&#x2019;s spool files. No bounce messages
57784 are ever generated.
57785 </para>
57786 </listitem>
57787 <listitem>
57788 <para>
57789 No retry data is maintained, and any retry rules are ignored.
57790 </para>
57791 </listitem>
57792 <listitem>
57793 <para>
57794 A number of Exim options are overridden: <option>deliver_drop_privilege</option> is forced
57795 true, <option>max_rcpt</option> in the <command>smtp</command> transport is forced to <quote>unlimited</quote>,
57796 <option>remote_max_parallel</option> is forced to one, and fallback hosts are ignored.
57797 </para>
57798 </listitem>
57799 </itemizedlist>
57800 <para>
57801 The overall effect is that Exim makes a single synchronous attempt to deliver
57802 the message, failing if there is any kind of problem. Because no local
57803 deliveries are done and no daemon can be run, Exim does not need root
57804 privilege. It should be possible to run it setuid to <emphasis>exim</emphasis> instead of setuid
57805 to <emphasis>root</emphasis>. See section <xref linkend="SECTrunexiwitpri"/> for a general discussion about
57806 the advantages and disadvantages of running without root privilege.
57807 </para>
57808 </chapter>
57809
57810 <chapter id="CHAPlog">
57811 <title>Log files</title>
57812 <para>
57813 <indexterm role="concept" id="IIDloggen" class="startofrange">
57814 <primary>log</primary>
57815 <secondary>general description</secondary>
57816 </indexterm>
57817 <indexterm role="concept">
57818 <primary>log</primary>
57819 <secondary>types of</secondary>
57820 </indexterm>
57821 Exim writes three different logs, referred to as the main log, the reject log,
57822 and the panic log:
57823 </para>
57824 <itemizedlist>
57825 <listitem>
57826 <para>
57827 <indexterm role="concept">
57828 <primary>main log</primary>
57829 </indexterm>
57830 The main log records the arrival of each message and each delivery in a single
57831 line in each case. The format is as compact as possible, in an attempt to keep
57832 down the size of log files. Two-character flag sequences make it easy to pick
57833 out these lines. A number of other events are recorded in the main log. Some of
57834 them are optional, in which case the <option>log_selector</option> option controls whether
57835 they are included or not. A Perl script called <emphasis>eximstats</emphasis>, which does simple
57836 analysis of main log files, is provided in the Exim distribution (see section
57837 <xref linkend="SECTmailstat"/>).
57838 </para>
57839 </listitem>
57840 <listitem>
57841 <para>
57842 <indexterm role="concept">
57843 <primary>reject log</primary>
57844 </indexterm>
57845 The reject log records information from messages that are rejected as a result
57846 of a configuration option (that is, for policy reasons).
57847 The first line of each rejection is a copy of the line that is also written to
57848 the main log. Then, if the message&#x2019;s header has been read at the time the log
57849 is written, its contents are written to this log. Only the original header
57850 lines are available; header lines added by ACLs are not logged. You can use the
57851 reject log to check that your policy controls are working correctly; on a busy
57852 host this may be easier than scanning the main log for rejection messages. You
57853 can suppress the writing of the reject log by setting <option>write_rejectlog</option>
57854 false.
57855 </para>
57856 </listitem>
57857 <listitem>
57858 <para>
57859 <indexterm role="concept">
57860 <primary>panic log</primary>
57861 </indexterm>
57862 <indexterm role="concept">
57863 <primary>system log</primary>
57864 </indexterm>
57865 When certain serious errors occur, Exim writes entries to its panic log. If the
57866 error is sufficiently disastrous, Exim bombs out afterwards. Panic log entries
57867 are usually written to the main log as well, but can get lost amid the mass of
57868 other entries. The panic log should be empty under normal circumstances. It is
57869 therefore a good idea to check it (or to have a <emphasis>cron</emphasis> script check it)
57870 regularly, in order to become aware of any problems. When Exim cannot open its
57871 panic log, it tries as a last resort to write to the system log (syslog). This
57872 is opened with LOG_PID+LOG_CONS and the facility code of LOG_MAIL. The
57873 message itself is written at priority LOG_CRIT.
57874 </para>
57875 </listitem>
57876 </itemizedlist>
57877 <para>
57878 Every log line starts with a timestamp, in the format shown in the following
57879 example. Note that many of the examples shown in this chapter are line-wrapped.
57880 In the log file, this would be all on one line:
57881 </para>
57882 <literallayout class="monospaced">
57883 2001-09-16 16:09:47 SMTP connection from [127.0.0.1] closed
57884   by QUIT
57885 </literallayout>
57886 <para>
57887 By default, the timestamps are in the local timezone. There are two
57888 ways of changing this:
57889 </para>
57890 <itemizedlist>
57891 <listitem>
57892 <para>
57893 You can set the <option>timezone</option> option to a different time zone; in particular, if
57894 you set
57895 </para>
57896 <literallayout class="monospaced">
57897 timezone = UTC
57898 </literallayout>
57899 <para>
57900 the timestamps will be in UTC (aka GMT).
57901 </para>
57902 </listitem>
57903 <listitem>
57904 <para>
57905 If you set <option>log_timezone</option> true, the time zone is added to the timestamp, for
57906 example:
57907 </para>
57908 <literallayout class="monospaced">
57909 2003-04-25 11:17:07 +0100 Start queue run: pid=12762
57910 </literallayout>
57911 </listitem>
57912 </itemizedlist>
57913 <para>
57914 <indexterm role="concept">
57915 <primary>log</primary>
57916 <secondary>process ids in</secondary>
57917 </indexterm>
57918 <indexterm role="concept">
57919 <primary>pid (process id)</primary>
57920 <secondary>in log lines</secondary>
57921 </indexterm>
57922 Exim does not include its process id in log lines by default, but you can
57923 request that it does so by specifying the <literal>pid</literal> log selector (see section
57924 <xref linkend="SECTlogselector"/>). When this is set, the process id is output, in square
57925 brackets, immediately after the time and date.
57926 </para>
57927 <section id="SECTwhelogwri">
57928 <title>Where the logs are written</title>
57929 <para>
57930 <indexterm role="concept">
57931 <primary>log</primary>
57932 <secondary>destination</secondary>
57933 </indexterm>
57934 <indexterm role="concept">
57935 <primary>log</primary>
57936 <secondary>to file</secondary>
57937 </indexterm>
57938 <indexterm role="concept">
57939 <primary>log</primary>
57940 <secondary>to syslog</secondary>
57941 </indexterm>
57942 <indexterm role="concept">
57943 <primary>syslog</primary>
57944 </indexterm>
57945 The logs may be written to local files, or to syslog, or both. However, it
57946 should be noted that many syslog implementations use UDP as a transport, and
57947 are therefore unreliable in the sense that messages are not guaranteed to
57948 arrive at the loghost, nor is the ordering of messages necessarily maintained.
57949 It has also been reported that on large log files (tens of megabytes) you may
57950 need to tweak syslog to prevent it syncing the file with each write &ndash; on
57951 Linux this has been seen to make syslog take 90% plus of CPU time.
57952 </para>
57953 <para>
57954 The destination for Exim&#x2019;s logs is configured by setting LOG_FILE_PATH in
57955 <filename>Local/Makefile</filename> or by setting <option>log_file_path</option> in the run time
57956 configuration. This latter string is expanded, so it can contain, for example,
57957 references to the host name:
57958 </para>
57959 <literallayout class="monospaced">
57960 log_file_path = /var/log/$primary_hostname/exim_%slog
57961 </literallayout>
57962 <para>
57963 It is generally advisable, however, to set the string in <filename>Local/Makefile</filename>
57964 rather than at run time, because then the setting is available right from the
57965 start of Exim&#x2019;s execution. Otherwise, if there&#x2019;s something it wants to log
57966 before it has read the configuration file (for example, an error in the
57967 configuration file) it will not use the path you want, and may not be able to
57968 log at all.
57969 </para>
57970 <para>
57971 The value of LOG_FILE_PATH or <option>log_file_path</option> is a colon-separated
57972 list, currently limited to at most two items. This is one option where the
57973 facility for changing a list separator may not be used. The list must always be
57974 colon-separated. If an item in the list is <quote>syslog</quote> then syslog is used;
57975 otherwise the item must either be an absolute path, containing <literal>%s</literal> at the
57976 point where <quote>main</quote>, <quote>reject</quote>, or <quote>panic</quote> is to be inserted, or be empty,
57977 implying the use of a default path.
57978 </para>
57979 <para>
57980 When Exim encounters an empty item in the list, it searches the list defined by
57981 LOG_FILE_PATH, and uses the first item it finds that is neither empty nor
57982 <quote>syslog</quote>. This means that an empty item in <option>log_file_path</option> can be used to
57983 mean <quote>use the path specified at build time</quote>. It no such item exists, log
57984 files are written in the <filename>log</filename> subdirectory of the spool directory. This is
57985 equivalent to the setting:
57986 </para>
57987 <literallayout class="monospaced">
57988 log_file_path = $spool_directory/log/%slog
57989 </literallayout>
57990 <para>
57991 If you do not specify anything at build time or run time, that is where the
57992 logs are written.
57993 </para>
57994 <para>
57995 A log file path may also contain <literal>%D</literal> if datestamped log file names are in
57996 use &ndash; see section <xref linkend="SECTdatlogfil"/> below.
57997 </para>
57998 <para>
57999 Here are some examples of possible settings:
58000 </para>
58001 <literallayout>
58002 <literal>LOG_FILE_PATH=syslog                    </literal> syslog only
58003 <literal>LOG_FILE_PATH=:syslog                   </literal> syslog and default path
58004 <literal>LOG_FILE_PATH=syslog : /usr/log/exim_%s </literal> syslog and specified path
58005 <literal>LOG_FILE_PATH=/usr/log/exim_%s          </literal> specified path only
58006 </literallayout>
58007 <para>
58008 If there are more than two paths in the list, the first is used and a panic
58009 error is logged.
58010 </para>
58011 </section>
58012 <section id="SECID285">
58013 <title>Logging to local files that are periodically <quote>cycled</quote></title>
58014 <para>
58015 <indexterm role="concept">
58016 <primary>log</primary>
58017 <secondary>cycling local files</secondary>
58018 </indexterm>
58019 <indexterm role="concept">
58020 <primary>cycling logs</primary>
58021 </indexterm>
58022 <indexterm role="concept">
58023 <primary><emphasis>exicyclog</emphasis></primary>
58024 </indexterm>
58025 <indexterm role="concept">
58026 <primary>log</primary>
58027 <secondary>local files; writing to</secondary>
58028 </indexterm>
58029 Some operating systems provide centralized and standardized methods for cycling
58030 log files. For those that do not, a utility script called <emphasis>exicyclog</emphasis> is
58031 provided (see section <xref linkend="SECTcyclogfil"/>). This renames and compresses the
58032 main and reject logs each time it is called. The maximum number of old logs to
58033 keep can be set. It is suggested this script is run as a daily <emphasis>cron</emphasis> job.
58034 </para>
58035 <para>
58036 An Exim delivery process opens the main log when it first needs to write to it,
58037 and it keeps the file open in case subsequent entries are required &ndash; for
58038 example, if a number of different deliveries are being done for the same
58039 message. However, remote SMTP deliveries can take a long time, and this means
58040 that the file may be kept open long after it is renamed if <emphasis>exicyclog</emphasis> or
58041 something similar is being used to rename log files on a regular basis. To
58042 ensure that a switch of log files is noticed as soon as possible, Exim calls
58043 <function>stat()</function> on the main log&#x2019;s name before reusing an open file, and if the file
58044 does not exist, or its inode has changed, the old file is closed and Exim
58045 tries to open the main log from scratch. Thus, an old log file may remain open
58046 for quite some time, but no Exim processes should write to it once it has been
58047 renamed.
58048 </para>
58049 </section>
58050 <section id="SECTdatlogfil">
58051 <title>Datestamped log files</title>
58052 <para>
58053 <indexterm role="concept">
58054 <primary>log</primary>
58055 <secondary>datestamped files</secondary>
58056 </indexterm>
58057 Instead of cycling the main and reject log files by renaming them
58058 periodically, some sites like to use files whose names contain a datestamp,
58059 for example, <filename>mainlog-20031225</filename>. The datestamp is in the form <filename>yyyymmdd</filename>.
58060 Exim has support for this way of working. It is enabled by setting the
58061 <option>log_file_path</option> option to a path that includes <literal>%D</literal> at the point where the
58062 datestamp is required. For example:
58063 </para>
58064 <literallayout class="monospaced">
58065 log_file_path = /var/spool/exim/log/%slog-%D
58066 log_file_path = /var/log/exim-%s-%D.log
58067 log_file_path = /var/spool/exim/log/%D-%slog
58068 </literallayout>
58069 <para>
58070 As before, <literal>%s</literal> is replaced by <quote>main</quote> or <quote>reject</quote>; the following are
58071 examples of names generated by the above examples:
58072 </para>
58073 <literallayout class="monospaced">
58074 /var/spool/exim/log/mainlog-20021225
58075 /var/log/exim-reject-20021225.log
58076 /var/spool/exim/log/20021225-mainlog
58077 </literallayout>
58078 <para>
58079 When this form of log file is specified, Exim automatically switches to new
58080 files at midnight. It does not make any attempt to compress old logs; you
58081 will need to write your own script if you require this. You should not
58082 run <emphasis>exicyclog</emphasis> with this form of logging.
58083 </para>
58084 <para>
58085 The location of the panic log is also determined by <option>log_file_path</option>, but it
58086 is not datestamped, because rotation of the panic log does not make sense.
58087 When generating the name of the panic log, <literal>%D</literal> is removed from the string.
58088 In addition, if it immediately follows a slash, a following non-alphanumeric
58089 character is removed; otherwise a preceding non-alphanumeric character is
58090 removed. Thus, the three examples above would give these panic log names:
58091 </para>
58092 <literallayout class="monospaced">
58093 /var/spool/exim/log/paniclog
58094 /var/log/exim-panic.log
58095 /var/spool/exim/log/paniclog
58096 </literallayout>
58097 </section>
58098 <section id="SECID249">
58099 <title>Logging to syslog</title>
58100 <para>
58101 <indexterm role="concept">
58102 <primary>log</primary>
58103 <secondary>syslog; writing to</secondary>
58104 </indexterm>
58105 The use of syslog does not change what Exim logs or the format of its messages,
58106 except in one respect. If <option>syslog_timestamp</option> is set false, the timestamps on
58107 Exim&#x2019;s log lines are omitted when these lines are sent to syslog. Apart from
58108 that, the same strings are written to syslog as to log files. The syslog
58109 <quote>facility</quote> is set to LOG_MAIL, and the program name to <quote>exim</quote>
58110 by default, but you can change these by setting the <option>syslog_facility</option> and
58111 <option>syslog_processname</option> options, respectively. If Exim was compiled with
58112 SYSLOG_LOG_PID set in <filename>Local/Makefile</filename> (this is the default in
58113 <filename>src/EDITME</filename>), then, on systems that permit it (all except ULTRIX), the
58114 LOG_PID flag is set so that the <function>syslog()</function> call adds the pid as well as
58115 the time and host name to each line.
58116 The three log streams are mapped onto syslog priorities as follows:
58117 </para>
58118 <itemizedlist>
58119 <listitem>
58120 <para>
58121 <emphasis>mainlog</emphasis> is mapped to LOG_INFO
58122 </para>
58123 </listitem>
58124 <listitem>
58125 <para>
58126 <emphasis>rejectlog</emphasis> is mapped to LOG_NOTICE
58127 </para>
58128 </listitem>
58129 <listitem>
58130 <para>
58131 <emphasis>paniclog</emphasis> is mapped to LOG_ALERT
58132 </para>
58133 </listitem>
58134 </itemizedlist>
58135 <para>
58136 Many log lines are written to both <emphasis>mainlog</emphasis> and <emphasis>rejectlog</emphasis>, and some are
58137 written to both <emphasis>mainlog</emphasis> and <emphasis>paniclog</emphasis>, so there will be duplicates if
58138 these are routed by syslog to the same place. You can suppress this duplication
58139 by setting <option>syslog_duplication</option> false.
58140 </para>
58141 <para>
58142 Exim&#x2019;s log lines can sometimes be very long, and some of its <emphasis>rejectlog</emphasis>
58143 entries contain multiple lines when headers are included. To cope with both
58144 these cases, entries written to syslog are split into separate <function>syslog()</function>
58145 calls at each internal newline, and also after a maximum of
58146 870 data characters. (This allows for a total syslog line length of 1024, when
58147 additions such as timestamps are added.) If you are running a syslog
58148 replacement that can handle lines longer than the 1024 characters allowed by
58149 RFC 3164, you should set
58150 </para>
58151 <literallayout class="monospaced">
58152 SYSLOG_LONG_LINES=yes
58153 </literallayout>
58154 <para>
58155 in <filename>Local/Makefile</filename> before building Exim. That stops Exim from splitting long
58156 lines, but it still splits at internal newlines in <emphasis>reject</emphasis> log entries.
58157 </para>
58158 <para>
58159 To make it easy to re-assemble split lines later, each component of a split
58160 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;]
58161 where &lt;<emphasis>n</emphasis>&gt; is the component number and &lt;<emphasis>m</emphasis>&gt; is the total number of
58162 components in the entry. The / delimiter is used when the line was split
58163 because it was too long; if it was split because of an internal newline, the \
58164 delimiter is used. For example, supposing the length limit to be 50 instead of
58165 870, the following would be the result of a typical rejection message to
58166 <emphasis>mainlog</emphasis> (LOG_INFO), each line in addition being preceded by the time, host
58167 name, and pid as added by syslog:
58168 </para>
58169 <literallayout class="monospaced">
58170 [1/5] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from
58171 [2/5]  [127.0.0.1] (ph10): syntax error in 'From' header
58172 [3/5]  when scanning for sender: missing or malformed lo
58173 [4/5] cal part in "&lt;&gt;" (envelope sender is &lt;ph10@cam.exa
58174 [5/5] mple&gt;)
58175 </literallayout>
58176 <para>
58177 The same error might cause the following lines to be written to <quote>rejectlog</quote>
58178 (LOG_NOTICE):
58179 </para>
58180 <literallayout class="monospaced">
58181 [1/18] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected fro
58182 [2/18] m [127.0.0.1] (ph10): syntax error in 'From' head
58183 [3/18] er when scanning for sender: missing or malformed
58184 [4/18]  local part in "&lt;&gt;" (envelope sender is &lt;ph10@cam
58185 [5\18] .example&gt;)
58186 [6\18] Recipients: ph10@some.domain.cam.example
58187 [7\18] P Received: from [127.0.0.1] (ident=ph10)
58188 [8\18]        by xxxxx.cam.example with smtp (Exim 4.00)
58189 [9\18]        id 16RdAL-0006pc-00
58190 [10/18]        for ph10@cam.example; Mon, 16 Sep 2002 16:
58191 [11\18] 09:43 +0100
58192 [12\18] F From: &lt;&gt;
58193 [13\18]   Subject: this is a test header
58194 [18\18]   X-something: this is another header
58195 [15/18] I Message-Id: &lt;E16RdAL-0006pc-00@xxxxx.cam.examp
58196 [16\18] le&gt;
58197 [17\18] B Bcc:
58198 [18/18]   Date: Mon, 16 Sep 2002 16:09:43 +0100
58199 </literallayout>
58200 <para>
58201 Log lines that are neither too long nor contain newlines are written to syslog
58202 without modification.
58203 </para>
58204 <para>
58205 If only syslog is being used, the Exim monitor is unable to provide a log tail
58206 display, unless syslog is routing <emphasis>mainlog</emphasis> to a file on the local host and
58207 the environment variable EXIMON_LOG_FILE_PATH is set to tell the monitor
58208 where it is.
58209 </para>
58210 </section>
58211 <section id="SECID250">
58212 <title>Log line flags</title>
58213 <para>
58214 One line is written to the main log for each message received, and for each
58215 successful, unsuccessful, and delayed delivery. These lines can readily be
58216 picked out by the distinctive two-character flags that immediately follow the
58217 timestamp. The flags are:
58218 </para>
58219 <literallayout>
58220 <literal>&lt;=</literal>     message arrival
58221 <literal>=&gt;</literal>     normal message delivery
58222 <literal>-&gt;</literal>     additional address in same delivery
58223 <literal>*&gt;</literal>     delivery suppressed by <option>-N</option>
58224 <literal>**</literal>     delivery failed; address bounced
58225 <literal>==</literal>     delivery deferred; temporary problem
58226 </literallayout>
58227 </section>
58228 <section id="SECID251">
58229 <title>Logging message reception</title>
58230 <para>
58231 <indexterm role="concept">
58232 <primary>log</primary>
58233 <secondary>reception line</secondary>
58234 </indexterm>
58235 The format of the single-line entry in the main log that is written for every
58236 message received is shown in the basic example below, which is split over
58237 several lines in order to fit it on the page:
58238 </para>
58239 <literallayout class="monospaced">
58240 2002-10-31 08:57:53 16ZCW1-0005MB-00 &lt;= kryten@dwarf.fict.example
58241   H=mailer.fict.example [192.168.123.123] U=exim
58242   P=smtp S=5678 id=&lt;incoming message id&gt;
58243 </literallayout>
58244 <para>
58245 The address immediately following <quote>&lt;=</quote> is the envelope sender address. A
58246 bounce message is shown with the sender address <quote>&lt;&gt;</quote>, and if it is locally
58247 generated, this is followed by an item of the form
58248 </para>
58249 <literallayout class="monospaced">
58250 R=&lt;message id&gt;
58251 </literallayout>
58252 <para>
58253 which is a reference to the message that caused the bounce to be sent.
58254 </para>
58255 <para>
58256 <indexterm role="concept">
58257 <primary>HELO</primary>
58258 </indexterm>
58259 <indexterm role="concept">
58260 <primary>EHLO</primary>
58261 </indexterm>
58262 For messages from other hosts, the H and U fields identify the remote host and
58263 record the RFC 1413 identity of the user that sent the message, if one was
58264 received. The number given in square brackets is the IP address of the sending
58265 host. If there is a single, unparenthesized  host name in the H field, as
58266 above, it has been verified to correspond to the IP address (see the
58267 <option>host_lookup</option> option). If the name is in parentheses, it was the name quoted
58268 by the remote host in the SMTP HELO or EHLO command, and has not been
58269 verified. If verification yields a different name to that given for HELO or
58270 EHLO, the verified name appears first, followed by the HELO or EHLO
58271 name in parentheses.
58272 </para>
58273 <para>
58274 Misconfigured hosts (and mail forgers) sometimes put an IP address, with or
58275 without brackets, in the HELO or EHLO command, leading to entries in
58276 the log containing text like these examples:
58277 </para>
58278 <literallayout class="monospaced">
58279 H=(10.21.32.43) [192.168.8.34]
58280 H=([10.21.32.43]) [192.168.8.34]
58281 </literallayout>
58282 <para>
58283 This can be confusing. Only the final address in square brackets can be relied
58284 on.
58285 </para>
58286 <para>
58287 For locally generated messages (that is, messages not received over TCP/IP),
58288 the H field is omitted, and the U field contains the login name of the caller
58289 of Exim.
58290 </para>
58291 <para>
58292 <indexterm role="concept">
58293 <primary>authentication</primary>
58294 <secondary>logging</secondary>
58295 </indexterm>
58296 <indexterm role="concept">
58297 <primary>AUTH</primary>
58298 <secondary>logging</secondary>
58299 </indexterm>
58300 For all messages, the P field specifies the protocol used to receive the
58301 message. This is the value that is stored in <varname>$received_protocol</varname>. In the case
58302 of incoming SMTP messages, the value indicates whether or not any SMTP
58303 extensions (ESMTP), encryption, or authentication were used. If the SMTP
58304 session was encrypted, there is an additional X field that records the cipher
58305 suite that was used.
58306 </para>
58307 <para>
58308 The protocol is set to <quote>esmtpsa</quote> or <quote>esmtpa</quote> for messages received from
58309 hosts that have authenticated themselves using the SMTP AUTH command. The first
58310 value is used when the SMTP connection was encrypted (<quote>secure</quote>). In this case
58311 there is an additional item A= followed by the name of the authenticator that
58312 was used. If an authenticated identification was set up by the authenticator&#x2019;s
58313 <option>server_set_id</option> option, this is logged too, separated by a colon from the
58314 authenticator name.
58315 </para>
58316 <para>
58317 <indexterm role="concept">
58318 <primary>size</primary>
58319 <secondary>of message</secondary>
58320 </indexterm>
58321 The id field records the existing message id, if present. The size of the
58322 received message is given by the S field. When the message is delivered,
58323 headers may be removed or added, so that the size of delivered copies of the
58324 message may not correspond with this value (and indeed may be different to each
58325 other).
58326 </para>
58327 <para>
58328 The <option>log_selector</option> option can be used to request the logging of additional
58329 data when a message is received. See section <xref linkend="SECTlogselector"/> below.
58330 </para>
58331 </section>
58332 <section id="SECID252">
58333 <title>Logging deliveries</title>
58334 <para>
58335 <indexterm role="concept">
58336 <primary>log</primary>
58337 <secondary>delivery line</secondary>
58338 </indexterm>
58339 The format of the single-line entry in the main log that is written for every
58340 delivery is shown in one of the examples below, for local and remote
58341 deliveries, respectively. Each example has been split into two lines in order
58342 to fit it on the page:
58343 </para>
58344 <literallayout class="monospaced">
58345 2002-10-31 08:59:13 16ZCW1-0005MB-00 =&gt; marv
58346   &lt;marv@hitch.fict.example&gt; R=localuser T=local_delivery
58347 2002-10-31 09:00:10 16ZCW1-0005MB-00 =&gt;
58348   monk@holistic.fict.example R=dnslookup T=remote_smtp
58349   H=holistic.fict.example [192.168.234.234]
58350 </literallayout>
58351 <para>
58352 For ordinary local deliveries, the original address is given in angle brackets
58353 after the final delivery address, which might be a pipe or a file. If
58354 intermediate address(es) exist between the original and the final address, the
58355 last of these is given in parentheses after the final address. The R and T
58356 fields record the router and transport that were used to process the address.
58357 </para>
58358 <para>
58359 If a shadow transport was run after a successful local delivery, the log line
58360 for the successful delivery has an item added on the end, of the form
58361 </para>
58362 <literallayout>
58363 <literal>ST=&lt;</literal><emphasis>shadow transport name</emphasis><literal>&gt;</literal>
58364 </literallayout>
58365 <para>
58366 If the shadow transport did not succeed, the error message is put in
58367 parentheses afterwards.
58368 </para>
58369 <para>
58370 <indexterm role="concept">
58371 <primary>asterisk</primary>
58372 <secondary>after IP address</secondary>
58373 </indexterm>
58374 When more than one address is included in a single delivery (for example, two
58375 SMTP RCPT commands in one transaction) the second and subsequent addresses are
58376 flagged with <literal>-&gt;</literal> instead of <literal>=&gt;</literal>. When two or more messages are delivered
58377 down a single SMTP connection, an asterisk follows the IP address in the log
58378 lines for the second and subsequent messages.
58379 </para>
58380 <para>
58381 The generation of a reply message by a filter file gets logged as a
58382 <quote>delivery</quote> to the addressee, preceded by <quote>&gt;</quote>.
58383 </para>
58384 <para>
58385 The <option>log_selector</option> option can be used to request the logging of additional
58386 data when a message is delivered. See section <xref linkend="SECTlogselector"/> below.
58387 </para>
58388 </section>
58389 <section id="SECID253">
58390 <title>Discarded deliveries</title>
58391 <para>
58392 <indexterm role="concept">
58393 <primary>discarded messages</primary>
58394 </indexterm>
58395 <indexterm role="concept">
58396 <primary>message</primary>
58397 <secondary>discarded</secondary>
58398 </indexterm>
58399 <indexterm role="concept">
58400 <primary>delivery</primary>
58401 <secondary>discarded; logging</secondary>
58402 </indexterm>
58403 When a message is discarded as a result of the command <quote>seen finish</quote> being
58404 obeyed in a filter file which generates no deliveries, a log entry of the form
58405 </para>
58406 <literallayout class="monospaced">
58407 2002-12-10 00:50:49 16auJc-0001UB-00 =&gt; discarded
58408   &lt;low.club@bridge.example&gt; R=userforward
58409 </literallayout>
58410 <para>
58411 is written, to record why no deliveries are logged. When a message is discarded
58412 because it is aliased to <quote>:blackhole:</quote> the log line is like this:
58413 </para>
58414 <literallayout class="monospaced">
58415 1999-03-02 09:44:33 10HmaX-0005vi-00 =&gt; :blackhole:
58416   &lt;hole@nowhere.example&gt; R=blackhole_router
58417 </literallayout>
58418 </section>
58419 <section id="SECID254">
58420 <title>Deferred deliveries</title>
58421 <para>
58422 When a delivery is deferred, a line of the following form is logged:
58423 </para>
58424 <literallayout class="monospaced">
58425 2002-12-19 16:20:23 16aiQz-0002Q5-00 == marvin@endrest.example
58426   R=dnslookup T=smtp defer (146): Connection refused
58427 </literallayout>
58428 <para>
58429 In the case of remote deliveries, the error is the one that was given for the
58430 last IP address that was tried. Details of individual SMTP failures are also
58431 written to the log, so the above line would be preceded by something like
58432 </para>
58433 <literallayout class="monospaced">
58434 2002-12-19 16:20:23 16aiQz-0002Q5-00 Failed to connect to
58435   mail1.endrest.example [192.168.239.239]: Connection refused
58436 </literallayout>
58437 <para>
58438 When a deferred address is skipped because its retry time has not been reached,
58439 a message is written to the log, but this can be suppressed by setting an
58440 appropriate value in <option>log_selector</option>.
58441 </para>
58442 </section>
58443 <section id="SECID255">
58444 <title>Delivery failures</title>
58445 <para>
58446 <indexterm role="concept">
58447 <primary>delivery</primary>
58448 <secondary>failure; logging</secondary>
58449 </indexterm>
58450 If a delivery fails because an address cannot be routed, a line of the
58451 following form is logged:
58452 </para>
58453 <literallayout class="monospaced">
58454 1995-12-19 16:20:23 0tRiQz-0002Q5-00 ** jim@trek99.example
58455   &lt;jim@trek99.example&gt;: unknown mail domain
58456 </literallayout>
58457 <para>
58458 If a delivery fails at transport time, the router and transport are shown, and
58459 the response from the remote host is included, as in this example:
58460 </para>
58461 <literallayout class="monospaced">
58462 2002-07-11 07:14:17 17SXDU-000189-00 ** ace400@pb.example
58463   R=dnslookup T=remote_smtp: SMTP error from remote mailer
58464   after pipelined RCPT TO:&lt;ace400@pb.example&gt;: host
58465   pbmail3.py.example [192.168.63.111]: 553 5.3.0
58466   &lt;ace400@pb.example&gt;...Addressee unknown
58467 </literallayout>
58468 <para>
58469 The word <quote>pipelined</quote> indicates that the SMTP PIPELINING extension was being
58470 used. See <option>hosts_avoid_esmtp</option> in the <command>smtp</command> transport for a way of
58471 disabling PIPELINING. The log lines for all forms of delivery failure are
58472 flagged with <literal>**</literal>.
58473 </para>
58474 </section>
58475 <section id="SECID256">
58476 <title>Fake deliveries</title>
58477 <para>
58478 <indexterm role="concept">
58479 <primary>delivery</primary>
58480 <secondary>fake; logging</secondary>
58481 </indexterm>
58482 If a delivery does not actually take place because the <option>-N</option> option has been
58483 used to suppress it, a normal delivery line is written to the log, except that
58484 <quote>=&gt;</quote> is replaced by <quote>*&gt;</quote>.
58485 </para>
58486 </section>
58487 <section id="SECID257">
58488 <title>Completion</title>
58489 <para>
58490 A line of the form
58491 </para>
58492 <literallayout class="monospaced">
58493 2002-10-31 09:00:11 16ZCW1-0005MB-00 Completed
58494 </literallayout>
58495 <para>
58496 is written to the main log when a message is about to be removed from the spool
58497 at the end of its processing.
58498 </para>
58499 </section>
58500 <section id="SECID258">
58501 <title>Summary of Fields in Log Lines</title>
58502 <para>
58503 <indexterm role="concept">
58504 <primary>log</primary>
58505 <secondary>summary of fields</secondary>
58506 </indexterm>
58507 A summary of the field identifiers that are used in log lines is shown in
58508 the following table:
58509 </para>
58510 <literallayout>
58511 <literal>A   </literal>        authenticator name (and optional id)
58512 <literal>C   </literal>        SMTP confirmation on delivery
58513 <literal>    </literal>        command list for <quote>no mail in SMTP session</quote>
58514 <literal>CV  </literal>        certificate verification status
58515 <literal>D   </literal>        duration of <quote>no mail in SMTP session</quote>
58516 <literal>DN  </literal>        distinguished name from peer certificate
58517 <literal>DT  </literal>        on <literal>=&gt;</literal> lines: time taken for a delivery
58518 <literal>F   </literal>        sender address (on delivery lines)
58519 <literal>H   </literal>        host name and IP address
58520 <literal>I   </literal>        local interface used
58521 <literal>id  </literal>        message id for incoming message
58522 <literal>P   </literal>        on <literal>&lt;=</literal> lines: protocol used
58523 <literal>    </literal>        on <literal>=&gt;</literal> and <literal>**</literal> lines: return path
58524 <literal>QT  </literal>        on <literal>=&gt;</literal> lines: time spent on queue so far
58525 <literal>    </literal>        on <quote>Completed</quote> lines: time spent on queue
58526 <literal>R   </literal>        on <literal>&lt;=</literal> lines: reference for local bounce
58527 <literal>    </literal>        on <literal>=&gt;</literal>  <literal>**</literal> and <literal>==</literal> lines: router name
58528 <literal>S   </literal>        size of message
58529 <literal>ST  </literal>        shadow transport name
58530 <literal>T   </literal>        on <literal>&lt;=</literal> lines: message subject (topic)
58531 <literal>    </literal>        on <literal>=&gt;</literal> <literal>**</literal> and <literal>==</literal> lines: transport name
58532 <literal>U   </literal>        local user or RFC 1413 identity
58533 <literal>X   </literal>        TLS cipher suite
58534 </literallayout>
58535 </section>
58536 <section id="SECID259">
58537 <title>Other log entries</title>
58538 <para>
58539 Various other types of log entry are written from time to time. Most should be
58540 self-explanatory. Among the more common are:
58541 </para>
58542 <itemizedlist>
58543 <listitem>
58544 <para>
58545 <indexterm role="concept">
58546 <primary>retry</primary>
58547 <secondary>time not reached</secondary>
58548 </indexterm>
58549 <emphasis>retry time not reached</emphasis>&nbsp;&nbsp;An address previously suffered a temporary error
58550 during routing or local delivery, and the time to retry has not yet arrived.
58551 This message is not written to an individual message log file unless it happens
58552 during the first delivery attempt.
58553 </para>
58554 </listitem>
58555 <listitem>
58556 <para>
58557 <emphasis>retry time not reached for any host</emphasis>&nbsp;&nbsp;An address previously suffered
58558 temporary errors during remote delivery, and the retry time has not yet arrived
58559 for any of the hosts to which it is routed.
58560 </para>
58561 </listitem>
58562 <listitem>
58563 <para>
58564 <indexterm role="concept">
58565 <primary>spool directory</primary>
58566 <secondary>file locked</secondary>
58567 </indexterm>
58568 <emphasis>spool file locked</emphasis>&nbsp;&nbsp;An attempt to deliver a message cannot proceed because
58569 some other Exim process is already working on the message. This can be quite
58570 common if queue running processes are started at frequent intervals. The
58571 <emphasis>exiwhat</emphasis> utility script can be used to find out what Exim processes are
58572 doing.
58573 </para>
58574 </listitem>
58575 <listitem>
58576 <para>
58577 <indexterm role="concept">
58578 <primary>error</primary>
58579 <secondary>ignored</secondary>
58580 </indexterm>
58581 <emphasis>error ignored</emphasis>&nbsp;&nbsp;There are several circumstances that give rise to this
58582 message:
58583 </para>
58584 <orderedlist numeration="arabic">
58585 <listitem>
58586 <para>
58587 Exim failed to deliver a bounce message whose age was greater than
58588 <option>ignore_bounce_errors_after</option>. The bounce was discarded.
58589 </para>
58590 </listitem>
58591 <listitem>
58592 <para>
58593 A filter file set up a delivery using the <quote>noerror</quote> option, and the delivery
58594 failed. The delivery was discarded.
58595 </para>
58596 </listitem>
58597 <listitem>
58598 <para>
58599 A delivery set up by a router configured with
58600 </para>
58601 <literallayout class="monospaced">
58602     errors_to = &lt;&gt;
58603 </literallayout>
58604 <para>
58605 failed. The delivery was discarded.
58606 </para>
58607 </listitem>
58608 </orderedlist>
58609 </listitem>
58610 </itemizedlist>
58611 </section>
58612 <section id="SECTlogselector">
58613 <title>Reducing or increasing what is logged</title>
58614 <para>
58615 <indexterm role="concept">
58616 <primary>log</primary>
58617 <secondary>selectors</secondary>
58618 </indexterm>
58619 By setting the <option>log_selector</option> global option, you can disable some of Exim&#x2019;s
58620 default logging, or you can request additional logging. The value of
58621 <option>log_selector</option> is made up of names preceded by plus or minus characters. For
58622 example:
58623 </para>
58624 <literallayout class="monospaced">
58625 log_selector = +arguments -retry_defer
58626 </literallayout>
58627 <para>
58628 The list of optional log items is in the following table, with the default
58629 selection marked by asterisks:
58630 </para>
58631 <literallayout>
58632 <literal>*acl_warn_skipped           </literal>  skipped <option>warn</option> statement in ACL
58633 <literal> address_rewrite            </literal>  address rewriting
58634 <literal> all_parents                </literal>  all parents in =&gt; lines
58635 <literal> arguments                  </literal>  command line arguments
58636 <literal>*connection_reject          </literal>  connection rejections
58637 <literal>*delay_delivery             </literal>  immediate delivery delayed
58638 <literal> deliver_time               </literal>  time taken to perform delivery
58639 <literal> delivery_size              </literal>  add <literal>S=</literal><emphasis>nnn</emphasis> to =&gt; lines
58640 <literal>*dnslist_defer              </literal>  defers of DNS list (aka RBL) lookups
58641 <literal>*etrn                       </literal>  ETRN commands
58642 <literal>*host_lookup_failed         </literal>  as it says
58643 <literal> ident_timeout              </literal>  timeout for ident connection
58644 <literal> incoming_interface         </literal>  incoming interface on &lt;= lines
58645 <literal> incoming_port              </literal>  incoming port on &lt;= lines
58646 <literal>*lost_incoming_connection   </literal>  as it says (includes timeouts)
58647 <literal> outgoing_port              </literal>  add remote port to =&gt; lines
58648 <literal>*queue_run                  </literal>  start and end queue runs
58649 <literal> queue_time                 </literal>  time on queue for one recipient
58650 <literal> queue_time_overall         </literal>  time on queue for whole message
58651 <literal> pid                        </literal>  Exim process id
58652 <literal> received_recipients        </literal>  recipients on &lt;= lines
58653 <literal> received_sender            </literal>  sender on &lt;= lines
58654 <literal>*rejected_header            </literal>  header contents on reject log
58655 <literal>*retry_defer                </literal>  <quote>retry time not reached</quote>
58656 <literal> return_path_on_delivery    </literal>  put return path on =&gt; and ** lines
58657 <literal> sender_on_delivery         </literal>  add sender to =&gt; lines
58658 <literal>*sender_verify_fail         </literal>  sender verification failures
58659 <literal>*size_reject                </literal>  rejection because too big
58660 <literal>*skip_delivery              </literal>  delivery skipped in a queue run
58661 <literal> smtp_confirmation          </literal>  SMTP confirmation on =&gt; lines
58662 <literal> smtp_connection            </literal>  SMTP connections
58663 <literal> smtp_incomplete_transaction</literal>  incomplete SMTP transactions
58664 <literal> smtp_no_mail               </literal>  session with no MAIL commands
58665 <literal> smtp_protocol_error        </literal>  SMTP protocol errors
58666 <literal> smtp_syntax_error          </literal>  SMTP syntax errors
58667 <literal> subject                    </literal>  contents of <emphasis>Subject:</emphasis> on &lt;= lines
58668 <literal> tls_certificate_verified   </literal>  certificate verification status
58669 <literal>*tls_cipher                 </literal>  TLS cipher suite on &lt;= and =&gt; lines
58670 <literal> tls_peerdn                 </literal>  TLS peer DN on &lt;= and =&gt; lines
58671 <literal> unknown_in_list            </literal>  DNS lookup failed in list match
58672
58673 <literal> all                        </literal>  all of the above
58674 </literallayout>
58675 <para>
58676 More details on each of these items follows:
58677 </para>
58678 <itemizedlist>
58679 <listitem>
58680 <para>
58681 <indexterm role="concept">
58682 <primary><option>warn</option> ACL verb</primary>
58683 <secondary>log when skipping</secondary>
58684 </indexterm>
58685 <option>acl_warn_skipped</option>: When an ACL <option>warn</option> statement is skipped because one of
58686 its conditions cannot be evaluated, a log line to this effect is written if
58687 this log selector is set.
58688 </para>
58689 </listitem>
58690 <listitem>
58691 <para>
58692 <indexterm role="concept">
58693 <primary>log</primary>
58694 <secondary>rewriting</secondary>
58695 </indexterm>
58696 <indexterm role="concept">
58697 <primary>rewriting</primary>
58698 <secondary>logging</secondary>
58699 </indexterm>
58700 <option>address_rewrite</option>: This applies both to global rewrites and per-transport
58701 rewrites, but not to rewrites in filters run as an unprivileged user (because
58702 such users cannot access the log).
58703 </para>
58704 </listitem>
58705 <listitem>
58706 <para>
58707 <indexterm role="concept">
58708 <primary>log</primary>
58709 <secondary>full parentage</secondary>
58710 </indexterm>
58711 <option>all_parents</option>: Normally only the original and final addresses are logged on
58712 delivery lines; with this selector, intermediate parents are given in
58713 parentheses between them.
58714 </para>
58715 </listitem>
58716 <listitem>
58717 <para>
58718 <indexterm role="concept">
58719 <primary>log</primary>
58720 <secondary>Exim arguments</secondary>
58721 </indexterm>
58722 <indexterm role="concept">
58723 <primary>Exim arguments, logging</primary>
58724 </indexterm>
58725 <option>arguments</option>: This causes Exim to write the arguments with which it was called
58726 to the main log, preceded by the current working directory. This is a debugging
58727 feature, added to make it easier to find out how certain MUAs call
58728 <filename>/usr/sbin/sendmail</filename>. The logging does not happen if Exim has given up root
58729 privilege because it was called with the <option>-C</option> or <option>-D</option> options. Arguments
58730 that are empty or that contain white space are quoted. Non-printing characters
58731 are shown as escape sequences. This facility cannot log unrecognized arguments,
58732 because the arguments are checked before the configuration file is read. The
58733 only way to log such cases is to interpose a script such as <filename>util/logargs.sh</filename>
58734 between the caller and Exim.
58735 </para>
58736 </listitem>
58737 <listitem>
58738 <para>
58739 <indexterm role="concept">
58740 <primary>log</primary>
58741 <secondary>connection rejections</secondary>
58742 </indexterm>
58743 <option>connection_reject</option>: A log entry is written whenever an incoming SMTP
58744 connection is rejected, for whatever reason.
58745 </para>
58746 </listitem>
58747 <listitem>
58748 <para>
58749 <indexterm role="concept">
58750 <primary>log</primary>
58751 <secondary>delayed delivery</secondary>
58752 </indexterm>
58753 <indexterm role="concept">
58754 <primary>delayed delivery, logging</primary>
58755 </indexterm>
58756 <option>delay_delivery</option>: A log entry is written whenever a delivery process is not
58757 started for an incoming message because the load is too high or too many
58758 messages were received on one connection. Logging does not occur if no delivery
58759 process is started because <option>queue_only</option> is set or <option>-odq</option> was used.
58760 </para>
58761 </listitem>
58762 <listitem>
58763 <para>
58764 <indexterm role="concept">
58765 <primary>log</primary>
58766 <secondary>delivery duration</secondary>
58767 </indexterm>
58768 <option>deliver_time</option>: For each delivery, the amount of real time it has taken to
58769 perform the actual delivery is logged as DT=&lt;<emphasis>time</emphasis>&gt;, for example, <literal>DT=1s</literal>.
58770 </para>
58771 </listitem>
58772 <listitem>
58773 <para>
58774 <indexterm role="concept">
58775 <primary>log</primary>
58776 <secondary>message size on delivery</secondary>
58777 </indexterm>
58778 <indexterm role="concept">
58779 <primary>size</primary>
58780 <secondary>of message</secondary>
58781 </indexterm>
58782 <option>delivery_size</option>: For each delivery, the size of message delivered is added to
58783 the <quote>=&gt;</quote> line, tagged with S=.
58784 </para>
58785 </listitem>
58786 <listitem>
58787 <para>
58788 <indexterm role="concept">
58789 <primary>log</primary>
58790 <secondary>dnslist defer</secondary>
58791 </indexterm>
58792 <indexterm role="concept">
58793 <primary>DNS list</primary>
58794 <secondary>logging defer</secondary>
58795 </indexterm>
58796 <indexterm role="concept">
58797 <primary>black list (DNS)</primary>
58798 </indexterm>
58799 <option>dnslist_defer</option>: A log entry is written if an attempt to look up a host in a
58800 DNS black list suffers a temporary error.
58801 </para>
58802 </listitem>
58803 <listitem>
58804 <para>
58805 <indexterm role="concept">
58806 <primary>log</primary>
58807 <secondary>ETRN commands</secondary>
58808 </indexterm>
58809 <indexterm role="concept">
58810 <primary>ETRN</primary>
58811 <secondary>logging</secondary>
58812 </indexterm>
58813 <option>etrn</option>: Every valid ETRN command that is received is logged, before the ACL
58814 is run to determine whether or not it is actually accepted. An invalid ETRN
58815 command, or one received within a message transaction is not logged by this
58816 selector (see <option>smtp_syntax_error</option> and <option>smtp_protocol_error</option>).
58817 </para>
58818 </listitem>
58819 <listitem>
58820 <para>
58821 <indexterm role="concept">
58822 <primary>log</primary>
58823 <secondary>host lookup failure</secondary>
58824 </indexterm>
58825 <option>host_lookup_failed</option>: When a lookup of a host&#x2019;s IP addresses fails to find
58826 any addresses, or when a lookup of an IP address fails to find a host name, a
58827 log line is written. This logging does not apply to direct DNS lookups when
58828 routing email addresses, but it does apply to <quote>byname</quote> lookups.
58829 </para>
58830 </listitem>
58831 <listitem>
58832 <para>
58833 <indexterm role="concept">
58834 <primary>log</primary>
58835 <secondary>ident timeout</secondary>
58836 </indexterm>
58837 <indexterm role="concept">
58838 <primary>RFC 1413</primary>
58839 <secondary>logging timeout</secondary>
58840 </indexterm>
58841 <option>ident_timeout</option>: A log line is written whenever an attempt to connect to a
58842 client&#x2019;s ident port times out.
58843 </para>
58844 </listitem>
58845 <listitem>
58846 <para>
58847 <indexterm role="concept">
58848 <primary>log</primary>
58849 <secondary>incoming interface</secondary>
58850 </indexterm>
58851 <indexterm role="concept">
58852 <primary>interface</primary>
58853 <secondary>logging</secondary>
58854 </indexterm>
58855 <option>incoming_interface</option>: The interface on which a message was received is added
58856 to the <quote>&lt;=</quote> line as an IP address in square brackets, tagged by I= and
58857 followed by a colon and the port number. The local interface and port are also
58858 added to other SMTP log lines, for example <quote>SMTP connection from</quote>, and to
58859 rejection lines.
58860 </para>
58861 </listitem>
58862 <listitem>
58863 <para>
58864 <indexterm role="concept">
58865 <primary>log</primary>
58866 <secondary>incoming remote port</secondary>
58867 </indexterm>
58868 <indexterm role="concept">
58869 <primary>port</primary>
58870 <secondary>logging remote</secondary>
58871 </indexterm>
58872 <indexterm role="concept">
58873 <primary>TCP/IP</primary>
58874 <secondary>logging incoming remote port</secondary>
58875 </indexterm>
58876 <indexterm role="variable">
58877 <primary><varname>$sender_fullhost</varname></primary>
58878 </indexterm>
58879 <indexterm role="variable">
58880 <primary><varname>$sender_rcvhost</varname></primary>
58881 </indexterm>
58882 <option>incoming_port</option>: The remote port number from which a message was received is
58883 added to log entries and <emphasis>Received:</emphasis> header lines, following the IP address
58884 in square brackets, and separated from it by a colon. This is implemented by
58885 changing the value that is put in the <varname>$sender_fullhost</varname> and
58886 <varname>$sender_rcvhost</varname> variables. Recording the remote port number has become more
58887 important with the widening use of NAT (see RFC 2505).
58888 </para>
58889 </listitem>
58890 <listitem>
58891 <para>
58892 <indexterm role="concept">
58893 <primary>log</primary>
58894 <secondary>dropped connection</secondary>
58895 </indexterm>
58896 <option>lost_incoming_connection</option>: A log line is written when an incoming SMTP
58897 connection is unexpectedly dropped.
58898 </para>
58899 </listitem>
58900 <listitem>
58901 <para>
58902 <indexterm role="concept">
58903 <primary>log</primary>
58904 <secondary>outgoing remote port</secondary>
58905 </indexterm>
58906 <indexterm role="concept">
58907 <primary>port</primary>
58908 <secondary>logging outgoint remote</secondary>
58909 </indexterm>
58910 <indexterm role="concept">
58911 <primary>TCP/IP</primary>
58912 <secondary>logging ougtoing remote port</secondary>
58913 </indexterm>
58914 <option>outgoing_port</option>: The remote port number is added to delivery log lines (those
58915 containing =&gt; tags) following the IP address. This option is not included in
58916 the default setting, because for most ordinary configurations, the remote port
58917 number is always 25 (the SMTP port).
58918 </para>
58919 </listitem>
58920 <listitem>
58921 <para>
58922 <indexterm role="concept">
58923 <primary>log</primary>
58924 <secondary>process ids in</secondary>
58925 </indexterm>
58926 <indexterm role="concept">
58927 <primary>pid (process id)</primary>
58928 <secondary>in log lines</secondary>
58929 </indexterm>
58930 <option>pid</option>: The current process id is added to every log line, in square brackets,
58931 immediately after the time and date.
58932 </para>
58933 </listitem>
58934 <listitem>
58935 <para>
58936 <indexterm role="concept">
58937 <primary>log</primary>
58938 <secondary>queue run</secondary>
58939 </indexterm>
58940 <indexterm role="concept">
58941 <primary>queue runner</primary>
58942 <secondary>logging</secondary>
58943 </indexterm>
58944 <option>queue_run</option>: The start and end of every queue run are logged.
58945 </para>
58946 </listitem>
58947 <listitem>
58948 <para>
58949 <indexterm role="concept">
58950 <primary>log</primary>
58951 <secondary>queue time</secondary>
58952 </indexterm>
58953 <option>queue_time</option>: The amount of time the message has been in the queue on the
58954 local host is logged as QT=&lt;<emphasis>time</emphasis>&gt; on delivery (<literal>=&gt;</literal>) lines, for example,
58955 <literal>QT=3m45s</literal>. The clock starts when Exim starts to receive the message, so it
58956 includes reception time as well as the delivery time for the current address.
58957 This means that it may be longer than the difference between the arrival and
58958 delivery log line times, because the arrival log line is not written until the
58959 message has been successfully received.
58960 </para>
58961 </listitem>
58962 <listitem>
58963 <para>
58964 <option>queue_time_overall</option>: The amount of time the message has been in the queue on
58965 the local host is logged as QT=&lt;<emphasis>time</emphasis>&gt; on <quote>Completed</quote> lines, for
58966 example, <literal>QT=3m45s</literal>. The clock starts when Exim starts to receive the
58967 message, so it includes reception time as well as the total delivery time.
58968 </para>
58969 </listitem>
58970 <listitem>
58971 <para>
58972 <indexterm role="concept">
58973 <primary>log</primary>
58974 <secondary>recipients</secondary>
58975 </indexterm>
58976 <option>received_recipients</option>: The recipients of a message are listed in the main log
58977 as soon as the message is received. The list appears at the end of the log line
58978 that is written when a message is received, preceded by the word <quote>for</quote>. The
58979 addresses are listed after they have been qualified, but before any rewriting
58980 has taken place.
58981 Recipients that were discarded by an ACL for MAIL or RCPT do not appear
58982 in the list.
58983 </para>
58984 </listitem>
58985 <listitem>
58986 <para>
58987 <indexterm role="concept">
58988 <primary>log</primary>
58989 <secondary>sender reception</secondary>
58990 </indexterm>
58991 <option>received_sender</option>: The unrewritten original sender of a message is added to
58992 the end of the log line that records the message&#x2019;s arrival, after the word
58993 <quote>from</quote> (before the recipients if <option>received_recipients</option> is also set).
58994 </para>
58995 </listitem>
58996 <listitem>
58997 <para>
58998 <indexterm role="concept">
58999 <primary>log</primary>
59000 <secondary>header lines for rejection</secondary>
59001 </indexterm>
59002 <option>rejected_header</option>: If a message&#x2019;s header has been received at the time a
59003 rejection is written to the reject log, the complete header is added to the
59004 log. Header logging can be turned off individually for messages that are
59005 rejected by the <function>local_scan()</function> function (see section <xref linkend="SECTapiforloc"/>).
59006 </para>
59007 </listitem>
59008 <listitem>
59009 <para>
59010 <indexterm role="concept">
59011 <primary>log</primary>
59012 <secondary>retry defer</secondary>
59013 </indexterm>
59014 <option>retry_defer</option>: A log line is written if a delivery is deferred because a
59015 retry time has not yet been reached. However, this <quote>retry time not reached</quote>
59016 message is always omitted from individual message logs after the first delivery
59017 attempt.
59018 </para>
59019 </listitem>
59020 <listitem>
59021 <para>
59022 <indexterm role="concept">
59023 <primary>log</primary>
59024 <secondary>return path</secondary>
59025 </indexterm>
59026 <option>return_path_on_delivery</option>: The return path that is being transmitted with
59027 the message is included in delivery and bounce lines, using the tag P=.
59028 This is omitted if no delivery actually happens, for example, if routing fails,
59029 or if delivery is to <filename>/dev/null</filename> or to <literal>:blackhole:</literal>.
59030 </para>
59031 </listitem>
59032 <listitem>
59033 <para>
59034 <indexterm role="concept">
59035 <primary>log</primary>
59036 <secondary>sender on delivery</secondary>
59037 </indexterm>
59038 <option>sender_on_delivery</option>: The message&#x2019;s sender address is added to every delivery
59039 and bounce line, tagged by F= (for <quote>from</quote>).
59040 This is the original sender that was received with the message; it is not
59041 necessarily the same as the outgoing return path.
59042 </para>
59043 </listitem>
59044 <listitem>
59045 <para>
59046 <indexterm role="concept">
59047 <primary>log</primary>
59048 <secondary>sender verify failure</secondary>
59049 </indexterm>
59050 <option>sender_verify_fail</option>: If this selector is unset, the separate log line that
59051 gives details of a sender verification failure is not written. Log lines for
59052 the rejection of SMTP commands contain just <quote>sender verify failed</quote>, so some
59053 detail is lost.
59054 </para>
59055 </listitem>
59056 <listitem>
59057 <para>
59058 <indexterm role="concept">
59059 <primary>log</primary>
59060 <secondary>size rejection</secondary>
59061 </indexterm>
59062 <option>size_reject</option>: A log line is written whenever a message is rejected because
59063 it is too big.
59064 </para>
59065 </listitem>
59066 <listitem>
59067 <para>
59068 <indexterm role="concept">
59069 <primary>log</primary>
59070 <secondary>frozen messages; skipped</secondary>
59071 </indexterm>
59072 <indexterm role="concept">
59073 <primary>frozen messages</primary>
59074 <secondary>logging skipping</secondary>
59075 </indexterm>
59076 <option>skip_delivery</option>: A log line is written whenever a message is skipped during a
59077 queue run because it is frozen or because another process is already delivering
59078 it.
59079 <indexterm role="concept">
59080 <primary><quote>spool file is locked</quote></primary>
59081 </indexterm>
59082 The message that is written is <quote>spool file is locked</quote>.
59083 </para>
59084 </listitem>
59085 <listitem>
59086 <para>
59087 <indexterm role="concept">
59088 <primary>log</primary>
59089 <secondary>smtp confirmation</secondary>
59090 </indexterm>
59091 <indexterm role="concept">
59092 <primary>SMTP</primary>
59093 <secondary>logging confirmation</secondary>
59094 </indexterm>
59095 <option>smtp_confirmation</option>: The response to the final <quote>.</quote> in the SMTP dialogue for
59096 outgoing messages is added to delivery log lines in the form <literal>C=</literal>&lt;<emphasis>text</emphasis>&gt;.
59097 A number of MTAs (including Exim) return an identifying string in this
59098 response.
59099 </para>
59100 </listitem>
59101 <listitem>
59102 <para>
59103 <indexterm role="concept">
59104 <primary>log</primary>
59105 <secondary>SMTP connections</secondary>
59106 </indexterm>
59107 <indexterm role="concept">
59108 <primary>SMTP</primary>
59109 <secondary>logging connections</secondary>
59110 </indexterm>
59111 <option>smtp_connection</option>: A log line is written whenever an SMTP connection is
59112 established or closed, unless the connection is from a host that matches
59113 <option>hosts_connection_nolog</option>. (In contrast, <option>lost_incoming_connection</option> applies
59114 only when the closure is unexpected.) This applies to connections from local
59115 processes that use <option>-bs</option> as well as to TCP/IP connections. If a connection is
59116 dropped in the middle of a message, a log line is always written, whether or
59117 not this selector is set, but otherwise nothing is written at the start and end
59118 of connections unless this selector is enabled.
59119 </para>
59120 <para>
59121 For TCP/IP connections to an Exim daemon, the current number of connections is
59122 included in the log message for each new connection, but note that the count is
59123 reset if the daemon is restarted.
59124 Also, because connections are closed (and the closure is logged) in
59125 subprocesses, the count may not include connections that have been closed but
59126 whose termination the daemon has not yet noticed. Thus, while it is possible to
59127 match up the opening and closing of connections in the log, the value of the
59128 logged counts may not be entirely accurate.
59129 </para>
59130 </listitem>
59131 <listitem>
59132 <para>
59133 <indexterm role="concept">
59134 <primary>log</primary>
59135 <secondary>SMTP transaction; incomplete</secondary>
59136 </indexterm>
59137 <indexterm role="concept">
59138 <primary>SMTP</primary>
59139 <secondary>logging incomplete transactions</secondary>
59140 </indexterm>
59141 <option>smtp_incomplete_transaction</option>: When a mail transaction is aborted by
59142 RSET, QUIT, loss of connection, or otherwise, the incident is logged,
59143 and the message sender plus any accepted recipients are included in the log
59144 line. This can provide evidence of dictionary attacks.
59145 </para>
59146 </listitem>
59147 <listitem>
59148 <para>
59149 <indexterm role="concept">
59150 <primary>log</primary>
59151 <secondary>non-MAIL SMTP sessions</secondary>
59152 </indexterm>
59153 <indexterm role="concept">
59154 <primary>MAIL</primary>
59155 <secondary>logging session without</secondary>
59156 </indexterm>
59157 <option>smtp_no_mail</option>: A line is written to the main log whenever an accepted SMTP
59158 connection terminates without having issued a MAIL command. This includes both
59159 the case when the connection is dropped, and the case when QUIT is used. It
59160 does not include cases where the connection is rejected right at the start (by
59161 an ACL, or because there are too many connections, or whatever). These cases
59162 already have their own log lines.
59163 </para>
59164 <para>
59165 The log line that is written contains the identity of the client in the usual
59166 way, followed by D= and a time, which records the duration of the connection.
59167 If the connection was authenticated, this fact is logged exactly as it is for
59168 an incoming message, with an A= item. If the connection was encrypted, CV=,
59169 DN=, and X= items may appear as they do for an incoming message, controlled by
59170 the same logging options.
59171 </para>
59172 <para>
59173 Finally, if any SMTP commands were issued during the connection, a C= item
59174 is added to the line, listing the commands that were used. For example,
59175 </para>
59176 <literallayout class="monospaced">
59177 C=EHLO,QUIT
59178 </literallayout>
59179 <para>
59180 shows that the client issued QUIT straight after EHLO. If there were fewer
59181 than 20 commands, they are all listed. If there were more than 20 commands,
59182 the last 20 are listed, preceded by <quote>...</quote>. However, with the default
59183 setting of 10 for <option>smtp_accep_max_nonmail</option>, the connection will in any case
59184 have been aborted before 20 non-mail commands are processed.
59185 </para>
59186 </listitem>
59187 <listitem>
59188 <para>
59189 <indexterm role="concept">
59190 <primary>log</primary>
59191 <secondary>SMTP protocol error</secondary>
59192 </indexterm>
59193 <indexterm role="concept">
59194 <primary>SMTP</primary>
59195 <secondary>logging protocol error</secondary>
59196 </indexterm>
59197 <option>smtp_protocol_error</option>: A log line is written for every SMTP protocol error
59198 encountered. Exim does not have perfect detection of all protocol errors
59199 because of transmission delays and the use of pipelining. If PIPELINING has
59200 been advertised to a client, an Exim server assumes that the client will use
59201 it, and therefore it does not count <quote>expected</quote> errors (for example, RCPT
59202 received after rejecting MAIL) as protocol errors.
59203 </para>
59204 </listitem>
59205 <listitem>
59206 <para>
59207 <indexterm role="concept">
59208 <primary>SMTP</primary>
59209 <secondary>logging syntax errors</secondary>
59210 </indexterm>
59211 <indexterm role="concept">
59212 <primary>SMTP</primary>
59213 <secondary>syntax errors; logging</secondary>
59214 </indexterm>
59215 <indexterm role="concept">
59216 <primary>SMTP</primary>
59217 <secondary>unknown command; logging</secondary>
59218 </indexterm>
59219 <indexterm role="concept">
59220 <primary>log</primary>
59221 <secondary>unknown SMTP command</secondary>
59222 </indexterm>
59223 <indexterm role="concept">
59224 <primary>log</primary>
59225 <secondary>SMTP syntax error</secondary>
59226 </indexterm>
59227 <option>smtp_syntax_error</option>: A log line is written for every SMTP syntax error
59228 encountered. An unrecognized command is treated as a syntax error. For an
59229 external connection, the host identity is given; for an internal connection
59230 using <option>-bs</option> the sender identification (normally the calling user) is given.
59231 </para>
59232 </listitem>
59233 <listitem>
59234 <para>
59235 <indexterm role="concept">
59236 <primary>log</primary>
59237 <secondary>subject</secondary>
59238 </indexterm>
59239 <indexterm role="concept">
59240 <primary>subject, logging</primary>
59241 </indexterm>
59242 <option>subject</option>: The subject of the message is added to the arrival log line,
59243 preceded by <quote>T=</quote> (T for <quote>topic</quote>, since S is already used for <quote>size</quote>).
59244 Any MIME <quote>words</quote> in the subject are decoded. The <option>print_topbitchars</option> option
59245 specifies whether characters with values greater than 127 should be logged
59246 unchanged, or whether they should be rendered as escape sequences.
59247 </para>
59248 </listitem>
59249 <listitem>
59250 <para>
59251 <indexterm role="concept">
59252 <primary>log</primary>
59253 <secondary>certificate verification</secondary>
59254 </indexterm>
59255 <option>tls_certificate_verified</option>: An extra item is added to &lt;= and =&gt; log lines
59256 when TLS is in use. The item is <literal>CV=yes</literal> if the peer&#x2019;s certificate was
59257 verified, and <literal>CV=no</literal> if not.
59258 </para>
59259 </listitem>
59260 <listitem>
59261 <para>
59262 <indexterm role="concept">
59263 <primary>log</primary>
59264 <secondary>TLS cipher</secondary>
59265 </indexterm>
59266 <indexterm role="concept">
59267 <primary>TLS</primary>
59268 <secondary>logging cipher</secondary>
59269 </indexterm>
59270 <option>tls_cipher</option>: When a message is sent or received over an encrypted
59271 connection, the cipher suite used is added to the log line, preceded by X=.
59272 </para>
59273 </listitem>
59274 <listitem>
59275 <para>
59276 <indexterm role="concept">
59277 <primary>log</primary>
59278 <secondary>TLS peer DN</secondary>
59279 </indexterm>
59280 <indexterm role="concept">
59281 <primary>TLS</primary>
59282 <secondary>logging peer DN</secondary>
59283 </indexterm>
59284 <option>tls_peerdn</option>: When a message is sent or received over an encrypted
59285 connection, and a certificate is supplied by the remote host, the peer DN is
59286 added to the log line, preceded by DN=.
59287 </para>
59288 </listitem>
59289 <listitem>
59290 <para>
59291 <indexterm role="concept">
59292 <primary>log</primary>
59293 <secondary>DNS failure in list</secondary>
59294 </indexterm>
59295 <option>unknown_in_list</option>: This setting causes a log entry to be written when the
59296 result of a list match is failure because a DNS lookup failed.
59297 </para>
59298 </listitem>
59299 </itemizedlist>
59300 </section>
59301 <section id="SECID260">
59302 <title>Message log</title>
59303 <para>
59304 <indexterm role="concept">
59305 <primary>message</primary>
59306 <secondary>log file for</secondary>
59307 </indexterm>
59308 <indexterm role="concept">
59309 <primary>log</primary>
59310 <secondary>message log; description of</secondary>
59311 </indexterm>
59312 <indexterm role="concept">
59313 <primary><filename>msglog</filename> directory</primary>
59314 </indexterm>
59315 <indexterm role="option">
59316 <primary><option>preserve_message_logs</option></primary>
59317 </indexterm>
59318 In addition to the general log files, Exim writes a log file for each message
59319 that it handles. The names of these per-message logs are the message ids, and
59320 they are kept in the <filename>msglog</filename> sub-directory of the spool directory. Each
59321 message log contains copies of the log lines that apply to the message. This
59322 makes it easier to inspect the status of an individual message without having
59323 to search the main log. A message log is deleted when processing of the message
59324 is complete, unless <option>preserve_message_logs</option> is set, but this should be used
59325 only with great care because they can fill up your disk very quickly.
59326 </para>
59327 <para>
59328 On a heavily loaded system, it may be desirable to disable the use of
59329 per-message logs, in order to reduce disk I/O. This can be done by setting the
59330 <option>message_logs</option> option false.
59331 <indexterm role="concept" startref="IIDloggen" class="endofrange"/>
59332 </para>
59333 </section>
59334 </chapter>
59335
59336 <chapter id="CHAPutils">
59337 <title>Exim utilities</title>
59338 <para>
59339 <indexterm role="concept" id="IIDutils" class="startofrange">
59340 <primary>utilities</primary>
59341 </indexterm>
59342 A number of utility scripts and programs are supplied with Exim and are
59343 described in this chapter. There is also the Exim Monitor, which is covered in
59344 the next chapter. The utilities described here are:
59345 </para>
59346 <informaltable frame="none">
59347 <tgroup cols="3" colsep="0" rowsep="0">
59348 <colspec colwidth="7*" align="left"/>
59349 <colspec colwidth="15*" align="left"/>
59350 <colspec colwidth="40*" align="left"/>
59351 <tbody>
59352 <row>
59353 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTfinoutwha"/></entry>
59354 <entry><emphasis>exiwhat</emphasis></entry>
59355 <entry>list what Exim processes are doing</entry>
59356 </row>
59357 <row>
59358 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTgreptheque"/></entry>
59359 <entry><emphasis>exiqgrep</emphasis></entry>
59360 <entry>grep the queue</entry>
59361 </row>
59362 <row>
59363 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTsumtheque"/></entry>
59364 <entry><emphasis>exiqsumm</emphasis></entry>
59365 <entry>summarize the queue</entry>
59366 </row>
59367 <row>
59368 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTextspeinf"/></entry>
59369 <entry><emphasis>exigrep</emphasis></entry>
59370 <entry>search the main log</entry>
59371 </row>
59372 <row>
59373 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTexipick"/></entry>
59374 <entry><emphasis>exipick</emphasis></entry>
59375 <entry>select messages on various criteria</entry>
59376 </row>
59377 <row>
59378 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTcyclogfil"/></entry>
59379 <entry><emphasis>exicyclog</emphasis></entry>
59380 <entry>cycle (rotate) log files</entry>
59381 </row>
59382 <row>
59383 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTmailstat"/></entry>
59384 <entry><emphasis>eximstats</emphasis></entry>
59385 <entry>extract statistics from the log</entry>
59386 </row>
59387 <row>
59388 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTcheckaccess"/></entry>
59389 <entry><emphasis>exim_checkaccess</emphasis></entry>
59390 <entry>check address acceptance from given IP</entry>
59391 </row>
59392 <row>
59393 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTdbmbuild"/></entry>
59394 <entry><emphasis>exim_dbmbuild</emphasis></entry>
59395 <entry>build a DBM file</entry>
59396 </row>
59397 <row>
59398 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTfinindret"/></entry>
59399 <entry><emphasis>exinext</emphasis></entry>
59400 <entry>extract retry information</entry>
59401 </row>
59402 <row>
59403 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECThindatmai"/></entry>
59404 <entry><emphasis>exim_dumpdb</emphasis></entry>
59405 <entry>dump a hints database</entry>
59406 </row>
59407 <row>
59408 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECThindatmai"/></entry>
59409 <entry><emphasis>exim_tidydb</emphasis></entry>
59410 <entry>clean up a hints database</entry>
59411 </row>
59412 <row>
59413 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECThindatmai"/></entry>
59414 <entry><emphasis>exim_fixdb</emphasis></entry>
59415 <entry>patch a hints database</entry>
59416 </row>
59417 <row>
59418 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTmailboxmaint"/></entry>
59419 <entry><emphasis>exim_lock</emphasis></entry>
59420 <entry>lock a mailbox file</entry>
59421 </row>
59422 </tbody>
59423 </tgroup>
59424 </informaltable>
59425 <para>
59426 Another utility that might be of use to sites with many MTAs is Tom Kistner&#x2019;s
59427 <emphasis>exilog</emphasis>. It provides log visualizations across multiple Exim servers. See
59428 <emphasis role="bold"><ulink url="http://duncanthrax.net/exilog/">http://duncanthrax.net/exilog/</ulink></emphasis> for details.
59429 </para>
59430 <section id="SECTfinoutwha">
59431 <title>Finding out what Exim processes are doing (exiwhat)</title>
59432 <para>
59433 <indexterm role="concept">
59434 <primary><emphasis>exiwhat</emphasis></primary>
59435 </indexterm>
59436 <indexterm role="concept">
59437 <primary>process, querying</primary>
59438 </indexterm>
59439 <indexterm role="concept">
59440 <primary>SIGUSR1</primary>
59441 </indexterm>
59442 On operating systems that can restart a system call after receiving a signal
59443 (most modern OS), an Exim process responds to the SIGUSR1 signal by writing
59444 a line describing what it is doing to the file <filename>exim-process.info</filename> in the
59445 Exim spool directory. The <emphasis>exiwhat</emphasis> script sends the signal to all Exim
59446 processes it can find, having first emptied the file. It then waits for one
59447 second to allow the Exim processes to react before displaying the results. In
59448 order to run <emphasis>exiwhat</emphasis> successfully you have to have sufficient privilege to
59449 send the signal to the Exim processes, so it is normally run as root.
59450 </para>
59451 <para>
59452 <emphasis role="bold">Warning</emphasis>: This is not an efficient process. It is intended for occasional
59453 use by system administrators. It is not sensible, for example, to set up a
59454 script that sends SIGUSR1 signals to Exim processes at short intervals.
59455 </para>
59456 <para>
59457 Unfortunately, the <emphasis>ps</emphasis> command that <emphasis>exiwhat</emphasis> uses to find Exim processes
59458 varies in different operating systems. Not only are different options used,
59459 but the format of the output is different. For this reason, there are some
59460 system configuration options that configure exactly how <emphasis>exiwhat</emphasis> works. If
59461 it doesn&#x2019;t seem to be working for you, check the following compile-time
59462 options:
59463 </para>
59464 <literallayout>
59465 <literal>EXIWHAT_PS_CMD    </literal> the command for running <emphasis>ps</emphasis>
59466 <literal>EXIWHAT_PS_ARG    </literal> the argument for <emphasis>ps</emphasis>
59467 <literal>EXIWHAT_EGREP_ARG </literal> the argument for <emphasis>egrep</emphasis> to select from <emphasis>ps</emphasis> output
59468 <literal>EXIWHAT_KILL_ARG  </literal> the argument for the <emphasis>kill</emphasis> command
59469 </literallayout>
59470 <para>
59471 An example of typical output from <emphasis>exiwhat</emphasis> is
59472 </para>
59473 <literallayout class="monospaced">
59474 164 daemon: -q1h, listening on port 25
59475 10483 running queue: waiting for 0tAycK-0002ij-00 (10492)
59476 10492 delivering 0tAycK-0002ij-00 to mail.ref.example
59477   [10.19.42.42] (editor@ref.example)
59478 10592 handling incoming call from [192.168.243.242]
59479 10628 accepting a local non-SMTP message
59480 </literallayout>
59481 <para>
59482 The first number in the output line is the process number. The third line has
59483 been split here, in order to fit it on the page.
59484 </para>
59485 </section>
59486 <section id="SECTgreptheque">
59487 <title>Selective queue listing (exiqgrep)</title>
59488 <para>
59489 <indexterm role="concept">
59490 <primary><emphasis>exiqgrep</emphasis></primary>
59491 </indexterm>
59492 <indexterm role="concept">
59493 <primary>queue</primary>
59494 <secondary>grepping</secondary>
59495 </indexterm>
59496 This utility is a Perl script contributed by Matt Hubbard. It runs
59497 </para>
59498 <literallayout class="monospaced">
59499 exim -bpu
59500 </literallayout>
59501 <para>
59502 to obtain a queue listing with undelivered recipients only, and then greps the
59503 output to select messages that match given criteria. The following selection
59504 options are available:
59505 </para>
59506 <variablelist>
59507 <varlistentry>
59508 <term><emphasis role="bold">-f</emphasis>&nbsp;&lt;<emphasis>regex</emphasis>&gt;</term>
59509 <listitem>
59510 <para>
59511 Match the sender address. The field that is tested is enclosed in angle
59512 brackets, so you can test for bounce messages with
59513 </para>
59514 <literallayout class="monospaced">
59515 exiqgrep -f '^&lt;&gt;$'
59516 </literallayout>
59517 </listitem></varlistentry>
59518 <varlistentry>
59519 <term><emphasis role="bold">-r</emphasis>&nbsp;&lt;<emphasis>regex</emphasis>&gt;</term>
59520 <listitem>
59521 <para>
59522 Match a recipient address. The field that is tested is not enclosed in angle
59523 brackets.
59524 </para>
59525 </listitem></varlistentry>
59526 <varlistentry>
59527 <term><emphasis role="bold">-s</emphasis>&nbsp;&lt;<emphasis>regex</emphasis>&gt;</term>
59528 <listitem>
59529 <para>
59530 Match against the size field.
59531 </para>
59532 </listitem></varlistentry>
59533 <varlistentry>
59534 <term><emphasis role="bold">-y</emphasis>&nbsp;&lt;<emphasis>seconds</emphasis>&gt;</term>
59535 <listitem>
59536 <para>
59537 Match messages that are younger than the given time.
59538 </para>
59539 </listitem></varlistentry>
59540 <varlistentry>
59541 <term><emphasis role="bold">-o</emphasis>&nbsp;&lt;<emphasis>seconds</emphasis>&gt;</term>
59542 <listitem>
59543 <para>
59544 Match messages that are older than the given time.
59545 </para>
59546 </listitem></varlistentry>
59547 <varlistentry>
59548 <term><emphasis role="bold">-z</emphasis></term>
59549 <listitem>
59550 <para>
59551 Match only frozen messages.
59552 </para>
59553 </listitem></varlistentry>
59554 <varlistentry>
59555 <term><emphasis role="bold">-x</emphasis></term>
59556 <listitem>
59557 <para>
59558 Match only non-frozen messages.
59559 </para>
59560 </listitem></varlistentry>
59561 </variablelist>
59562 <para>
59563 The following options control the format of the output:
59564 </para>
59565 <variablelist>
59566 <varlistentry>
59567 <term><emphasis role="bold">-c</emphasis></term>
59568 <listitem>
59569 <para>
59570 Display only the count of matching messages.
59571 </para>
59572 </listitem></varlistentry>
59573 <varlistentry>
59574 <term><emphasis role="bold">-l</emphasis></term>
59575 <listitem>
59576 <para>
59577 Long format &ndash; display the full message information as output by Exim. This is
59578 the default.
59579 </para>
59580 </listitem></varlistentry>
59581 <varlistentry>
59582 <term><emphasis role="bold">-i</emphasis></term>
59583 <listitem>
59584 <para>
59585 Display message ids only.
59586 </para>
59587 </listitem></varlistentry>
59588 <varlistentry>
59589 <term><emphasis role="bold">-b</emphasis></term>
59590 <listitem>
59591 <para>
59592 Brief format &ndash; one line per message.
59593 </para>
59594 </listitem></varlistentry>
59595 <varlistentry>
59596 <term><emphasis role="bold">-R</emphasis></term>
59597 <listitem>
59598 <para>
59599 Display messages in reverse order.
59600 </para>
59601 </listitem></varlistentry>
59602 </variablelist>
59603 <para>
59604 There is one more option, <option>-h</option>, which outputs a list of options.
59605 </para>
59606 </section>
59607 <section id="SECTsumtheque">
59608 <title>Summarizing the queue (exiqsumm)</title>
59609 <para>
59610 <indexterm role="concept">
59611 <primary><emphasis>exiqsumm</emphasis></primary>
59612 </indexterm>
59613 <indexterm role="concept">
59614 <primary>queue</primary>
59615 <secondary>summary</secondary>
59616 </indexterm>
59617 The <emphasis>exiqsumm</emphasis> utility is a Perl script which reads the output of <literal>exim
59618 -bp</literal> and produces a summary of the messages on the queue. Thus, you use it by
59619 running a command such as
59620 </para>
59621 <literallayout class="monospaced">
59622 exim -bp | exiqsumm
59623 </literallayout>
59624 <para>
59625 The output consists of one line for each domain that has messages waiting for
59626 it, as in the following example:
59627 </para>
59628 <literallayout class="monospaced">
59629 3   2322   74m   66m  msn.com.example
59630 </literallayout>
59631 <para>
59632 Each line lists the number of pending deliveries for a domain, their total
59633 volume, and the length of time that the oldest and the newest messages have
59634 been waiting. Note that the number of pending deliveries is greater than the
59635 number of messages when messages have more than one recipient.
59636 </para>
59637 <para>
59638 A summary line is output at the end. By default the output is sorted on the
59639 domain name, but <emphasis>exiqsumm</emphasis> has the options <option>-a</option> and <option>-c</option>, which cause
59640 the output to be sorted by oldest message and by count of messages,
59641 respectively. There are also three options that split the messages for each
59642 domain into two or more subcounts: <option>-b</option> separates bounce messages, <option>-f</option>
59643 separates frozen messages, and <option>-s</option> separates messages according to their
59644 sender.
59645 </para>
59646 <para>
59647 The output of <emphasis>exim -bp</emphasis> contains the original addresses in the message, so
59648 this also applies to the output from <emphasis>exiqsumm</emphasis>. No domains from addresses
59649 generated by aliasing or forwarding are included (unless the <option>one_time</option>
59650 option of the <command>redirect</command> router has been used to convert them into <quote>top
59651 level</quote> addresses).
59652 </para>
59653 </section>
59654 <section id="SECTextspeinf">
59655 <title>Extracting specific information from the log (exigrep)</title>
59656 <para>
59657 <indexterm role="concept">
59658 <primary><emphasis>exigrep</emphasis></primary>
59659 </indexterm>
59660 <indexterm role="concept">
59661 <primary>log</primary>
59662 <secondary>extracts; grepping for</secondary>
59663 </indexterm>
59664 The <emphasis>exigrep</emphasis> utility is a Perl script that searches one or more main log
59665 files for entries that match a given pattern. When it finds a match, it
59666 extracts all the log entries for the relevant message, not just those that
59667 match the pattern. Thus, <emphasis>exigrep</emphasis> can extract complete log entries for a
59668 given message, or all mail for a given user, or for a given host, for example.
59669 The input files can be in Exim log format or syslog format.
59670 If a matching log line is not associated with a specific message, it is
59671 included in <emphasis>exigrep</emphasis>&#x2019;s output without any additional lines. The usage is:
59672 </para>
59673 <literallayout>
59674 <literal>exigrep [-t&lt;</literal><emphasis>n</emphasis><literal>&gt;] [-I] [-l] [-v] &lt;</literal><emphasis>pattern</emphasis><literal>&gt; [&lt;</literal><emphasis>log file</emphasis><literal>&gt;] ...</literal>
59675 </literallayout>
59676 <para>
59677 If no log file names are given on the command line, the standard input is read.
59678 </para>
59679 <para>
59680 The <option>-t</option> argument specifies a number of seconds. It adds an additional
59681 condition for message selection. Messages that are complete are shown only if
59682 they spent more than &lt;<emphasis>n</emphasis>&gt; seconds on the queue.
59683 </para>
59684 <para>
59685 By default, <emphasis>exigrep</emphasis> does case-insensitive matching. The <option>-I</option> option
59686 makes it case-sensitive. This may give a performance improvement when searching
59687 large log files. Without <option>-I</option>, the Perl pattern matches use Perl&#x2019;s <literal>/i</literal>
59688 option; with <option>-I</option> they do not. In both cases it is possible to change the
59689 case sensitivity within the pattern by using <literal>(?i)</literal> or <literal>(?-i)</literal>.
59690 </para>
59691 <para>
59692 The <option>-l</option> option means <quote>literal</quote>, that is, treat all characters in the
59693 pattern as standing for themselves. Otherwise the pattern must be a Perl
59694 regular expression.
59695 </para>
59696 <para>
59697 The <option>-v</option> option inverts the matching condition. That is, a line is selected
59698 if it does <emphasis>not</emphasis> match the pattern.
59699 </para>
59700 <para>
59701 If the location of a <emphasis>zcat</emphasis> command is known from the definition of
59702 ZCAT_COMMAND in <filename>Local/Makefile</filename>, <emphasis>exigrep</emphasis> automatically passes any file
59703 whose name ends in COMPRESS_SUFFIX through <emphasis>zcat</emphasis> as it searches it.
59704 </para>
59705 </section>
59706 <section id="SECTexipick">
59707 <title>Selecting messages by various criteria (exipick)</title>
59708 <para>
59709 <indexterm role="concept">
59710 <primary><emphasis>exipick</emphasis></primary>
59711 </indexterm>
59712 John Jetmore&#x2019;s <emphasis>exipick</emphasis> utility is included in the Exim distribution. It
59713 lists messages from the queue according to a variety of criteria. For details
59714 of <emphasis>exipick</emphasis>&#x2019;s facilities, visit the web page at
59715 <emphasis role="bold"><ulink url="http://www.exim.org/eximwiki/ToolExipickManPage">http://www.exim.org/eximwiki/ToolExipickManPage</ulink></emphasis> or run <emphasis>exipick</emphasis> with
59716 the <option>--help</option> option.
59717 </para>
59718 </section>
59719 <section id="SECTcyclogfil">
59720 <title>Cycling log files (exicyclog)</title>
59721 <para>
59722 <indexterm role="concept">
59723 <primary>log</primary>
59724 <secondary>cycling local files</secondary>
59725 </indexterm>
59726 <indexterm role="concept">
59727 <primary>cycling logs</primary>
59728 </indexterm>
59729 <indexterm role="concept">
59730 <primary><emphasis>exicyclog</emphasis></primary>
59731 </indexterm>
59732 The <emphasis>exicyclog</emphasis> script can be used to cycle (rotate) <emphasis>mainlog</emphasis> and
59733 <emphasis>rejectlog</emphasis> files. This is not necessary if only syslog is being used, or if
59734 you are using log files with datestamps in their names (see section
59735 <xref linkend="SECTdatlogfil"/>). Some operating systems have their own standard mechanisms
59736 for log cycling, and these can be used instead of <emphasis>exicyclog</emphasis> if preferred.
59737 There are two command line options for <emphasis>exicyclog</emphasis>:
59738 </para>
59739 <itemizedlist>
59740 <listitem>
59741 <para>
59742 <option>-k</option> &lt;<emphasis>count</emphasis>&gt; specifies the number of log files to keep, overriding the
59743 default that is set when Exim is built. The default default is 10.
59744 </para>
59745 </listitem>
59746 <listitem>
59747 <para>
59748 <option>-l</option> &lt;<emphasis>path</emphasis>&gt; specifies the log file path, in the same format as Exim&#x2019;s
59749 <option>log_file_path</option> option (for example, <literal>/var/log/exim_%slog</literal>), again
59750 overriding the script&#x2019;s default, which is to find the setting from Exim&#x2019;s
59751 configuration.
59752 </para>
59753 </listitem>
59754 </itemizedlist>
59755 <para>
59756 Each time <emphasis>exicyclog</emphasis> is run the file names get <quote>shuffled down</quote> by one. If
59757 the main log file name is <filename>mainlog</filename> (the default) then when <emphasis>exicyclog</emphasis> is
59758 run <filename>mainlog</filename> becomes <filename>mainlog.01</filename>, the previous <filename>mainlog.01</filename> becomes
59759 <filename>mainlog.02</filename> and so on, up to the limit that is set in the script or by the
59760 <option>-k</option> option. Log files whose numbers exceed the limit are discarded. Reject
59761 logs are handled similarly.
59762 </para>
59763 <para>
59764 If the limit is greater than 99, the script uses 3-digit numbers such as
59765 <filename>mainlog.001</filename>, <filename>mainlog.002</filename>, etc. If you change from a number less than 99
59766 to one that is greater, or <emphasis>vice versa</emphasis>, you will have to fix the names of
59767 any existing log files.
59768 </para>
59769 <para>
59770 If no <filename>mainlog</filename> file exists, the script does nothing. Files that <quote>drop off</quote>
59771 the end are deleted. All files with numbers greater than 01 are compressed,
59772 using a compression command which is configured by the COMPRESS_COMMAND
59773 setting in <filename>Local/Makefile</filename>. It is usual to run <emphasis>exicyclog</emphasis> daily from a
59774 root <option>crontab</option> entry of the form
59775 </para>
59776 <literallayout class="monospaced">
59777 1 0 * * * su exim -c /usr/exim/bin/exicyclog
59778 </literallayout>
59779 <para>
59780 assuming you have used the name <quote>exim</quote> for the Exim user. You can run
59781 <emphasis>exicyclog</emphasis> as root if you wish, but there is no need.
59782 </para>
59783 </section>
59784 <section id="SECTmailstat">
59785 <title>Mail statistics (eximstats)</title>
59786 <para>
59787 <indexterm role="concept">
59788 <primary>statistics</primary>
59789 </indexterm>
59790 <indexterm role="concept">
59791 <primary><emphasis>eximstats</emphasis></primary>
59792 </indexterm>
59793 A Perl script called <emphasis>eximstats</emphasis> is provided for extracting statistical
59794 information from log files. The output is either plain text, or HTML.
59795 Exim log files are also supported by the <emphasis>Lire</emphasis> system produced by the
59796 LogReport Foundation <emphasis role="bold"><ulink url="http://www.logreport.org">http://www.logreport.org</ulink></emphasis>.
59797 </para>
59798 <para>
59799 The <emphasis>eximstats</emphasis> script has been hacked about quite a bit over time. The
59800 latest version is the result of some extensive revision by Steve Campbell. A
59801 lot of information is given by default, but there are options for suppressing
59802 various parts of it. Following any options, the arguments to the script are a
59803 list of files, which should be main log files. For example:
59804 </para>
59805 <literallayout class="monospaced">
59806 eximstats -nr /var/spool/exim/log/mainlog.01
59807 </literallayout>
59808 <para>
59809 By default, <emphasis>eximstats</emphasis> extracts information about the number and volume of
59810 messages received from or delivered to various hosts. The information is sorted
59811 both by message count and by volume, and the top fifty hosts in each category
59812 are listed on the standard output. Similar information, based on email
59813 addresses or domains instead of hosts can be requested by means of various
59814 options. For messages delivered and received locally, similar statistics are
59815 also produced per user.
59816 </para>
59817 <para>
59818 The output also includes total counts and statistics about delivery errors, and
59819 histograms showing the number of messages received and deliveries made in each
59820 hour of the day. A delivery with more than one address in its envelope (for
59821 example, an SMTP transaction with more than one RCPT command) is counted
59822 as a single delivery by <emphasis>eximstats</emphasis>.
59823 </para>
59824 <para>
59825 Though normally more deliveries than receipts are reported (as messages may
59826 have multiple recipients), it is possible for <emphasis>eximstats</emphasis> to report more
59827 messages received than delivered, even though the queue is empty at the start
59828 and end of the period in question. If an incoming message contains no valid
59829 recipients, no deliveries are recorded for it. A bounce message is handled as
59830 an entirely separate message.
59831 </para>
59832 <para>
59833 <emphasis>eximstats</emphasis> always outputs a grand total summary giving the volume and number
59834 of messages received and deliveries made, and the number of hosts involved in
59835 each case. It also outputs the number of messages that were delayed (that is,
59836 not completely delivered at the first attempt), and the number that had at
59837 least one address that failed.
59838 </para>
59839 <para>
59840 The remainder of the output is in sections that can be independently disabled
59841 or modified by various options. It consists of a summary of deliveries by
59842 transport, histograms of messages received and delivered per time interval
59843 (default per hour), information about the time messages spent on the queue,
59844 a list of relayed messages, lists of the top fifty sending hosts, local
59845 senders, destination hosts, and destination local users by count and by volume,
59846 and a list of delivery errors that occurred.
59847 </para>
59848 <para>
59849 The relay information lists messages that were actually relayed, that is, they
59850 came from a remote host and were directly delivered to some other remote host,
59851 without being processed (for example, for aliasing or forwarding) locally.
59852 </para>
59853 <para>
59854 There are quite a few options for <emphasis>eximstats</emphasis> to control exactly what it
59855 outputs. These are documented in the Perl script itself, and can be extracted
59856 by running the command <command>perldoc</command> on the script. For example:
59857 </para>
59858 <literallayout class="monospaced">
59859 perldoc /usr/exim/bin/eximstats
59860 </literallayout>
59861 </section>
59862 <section id="SECTcheckaccess">
59863 <title>Checking access policy (exim_checkaccess)</title>
59864 <para>
59865 <indexterm role="concept">
59866 <primary><emphasis>exim_checkaccess</emphasis></primary>
59867 </indexterm>
59868 <indexterm role="concept">
59869 <primary>policy control</primary>
59870 <secondary>checking access</secondary>
59871 </indexterm>
59872 <indexterm role="concept">
59873 <primary>checking access</primary>
59874 </indexterm>
59875 The <option>-bh</option> command line argument allows you to run a fake SMTP session with
59876 debugging output, in order to check what Exim is doing when it is applying
59877 policy controls to incoming SMTP mail. However, not everybody is sufficiently
59878 familiar with the SMTP protocol to be able to make full use of <option>-bh</option>, and
59879 sometimes you just want to answer the question <quote>Does this address have
59880 access?</quote> without bothering with any further details.
59881 </para>
59882 <para>
59883 The <emphasis>exim_checkaccess</emphasis> utility is a <quote>packaged</quote> version of <option>-bh</option>. It takes
59884 two arguments, an IP address and an email address:
59885 </para>
59886 <literallayout class="monospaced">
59887 exim_checkaccess 10.9.8.7 A.User@a.domain.example
59888 </literallayout>
59889 <para>
59890 The utility runs a call to Exim with the <option>-bh</option> option, to test whether the
59891 given email address would be accepted in a RCPT command in a TCP/IP
59892 connection from the host with the given IP address. The output of the utility
59893 is either the word <quote>accepted</quote>, or the SMTP error response, for example:
59894 </para>
59895 <literallayout class="monospaced">
59896 Rejected:
59897 550 Relay not permitted
59898 </literallayout>
59899 <para>
59900 When running this test, the utility uses <literal>&lt;&gt;</literal> as the envelope sender address
59901 for the MAIL command, but you can change this by providing additional
59902 options. These are passed directly to the Exim command. For example, to specify
59903 that the test is to be run with the sender address <emphasis>himself@there.example</emphasis>
59904 you can use:
59905 </para>
59906 <literallayout class="monospaced">
59907 exim_checkaccess 10.9.8.7 A.User@a.domain.example \
59908                  -f himself@there.example
59909 </literallayout>
59910 <para>
59911 Note that these additional Exim command line items must be given after the two
59912 mandatory arguments.
59913 </para>
59914 <para>
59915 Because the <option>exim_checkaccess</option> uses <option>-bh</option>, it does not perform callouts
59916 while running its checks. You can run checks that include callouts by using
59917 <option>-bhc</option>, but this is not yet available in a <quote>packaged</quote> form.
59918 </para>
59919 </section>
59920 <section id="SECTdbmbuild">
59921 <title>Making DBM files (exim_dbmbuild)</title>
59922 <para>
59923 <indexterm role="concept">
59924 <primary>DBM</primary>
59925 <secondary>building dbm files</secondary>
59926 </indexterm>
59927 <indexterm role="concept">
59928 <primary>building DBM files</primary>
59929 </indexterm>
59930 <indexterm role="concept">
59931 <primary><emphasis>exim_dbmbuild</emphasis></primary>
59932 </indexterm>
59933 <indexterm role="concept">
59934 <primary>lower casing</primary>
59935 </indexterm>
59936 <indexterm role="concept">
59937 <primary>binary zero</primary>
59938 <secondary>in lookup key</secondary>
59939 </indexterm>
59940 The <emphasis>exim_dbmbuild</emphasis> program reads an input file containing keys and data in
59941 the format used by the <command>lsearch</command> lookup (see section
59942 <xref linkend="SECTsinglekeylookups"/>). It writes a DBM file using the lower-cased alias
59943 names as keys and the remainder of the information as data. The lower-casing
59944 can be prevented by calling the program with the <option>-nolc</option> option.
59945 </para>
59946 <para>
59947 A terminating zero is included as part of the key string. This is expected by
59948 the <command>dbm</command> lookup type. However, if the option <option>-nozero</option> is given,
59949 <emphasis>exim_dbmbuild</emphasis> creates files without terminating zeroes in either the key
59950 strings or the data strings. The <command>dbmnz</command> lookup type can be used with such
59951 files.
59952 </para>
59953 <para>
59954 The program requires two arguments: the name of the input file (which can be a
59955 single hyphen to indicate the standard input), and the name of the output file.
59956 It creates the output under a temporary name, and then renames it if all went
59957 well.
59958 </para>
59959 <para>
59960 <indexterm role="concept">
59961 <primary>USE_DB</primary>
59962 </indexterm>
59963 If the native DB interface is in use (USE_DB is set in a compile-time
59964 configuration file &ndash; this is common in free versions of Unix) the two file
59965 names must be different, because in this mode the Berkeley DB functions create
59966 a single output file using exactly the name given. For example,
59967 </para>
59968 <literallayout class="monospaced">
59969 exim_dbmbuild /etc/aliases /etc/aliases.db
59970 </literallayout>
59971 <para>
59972 reads the system alias file and creates a DBM version of it in
59973 <filename>/etc/aliases.db</filename>.
59974 </para>
59975 <para>
59976 In systems that use the <emphasis>ndbm</emphasis> routines (mostly proprietary versions of
59977 Unix), two files are used, with the suffixes <filename>.dir</filename> and <filename>.pag</filename>. In this
59978 environment, the suffixes are added to the second argument of
59979 <emphasis>exim_dbmbuild</emphasis>, so it can be the same as the first. This is also the case
59980 when the Berkeley functions are used in compatibility mode (though this is not
59981 recommended), because in that case it adds a <filename>.db</filename> suffix to the file name.
59982 </para>
59983 <para>
59984 If a duplicate key is encountered, the program outputs a warning, and when it
59985 finishes, its return code is 1 rather than zero, unless the <option>-noduperr</option>
59986 option is used. By default, only the first of a set of duplicates is used &ndash;
59987 this makes it compatible with <command>lsearch</command> lookups. There is an option
59988 <option>-lastdup</option> which causes it to use the data for the last duplicate instead.
59989 There is also an option <option>-nowarn</option>, which stops it listing duplicate keys to
59990 <option>stderr</option>. For other errors, where it doesn&#x2019;t actually make a new file, the
59991 return code is 2.
59992 </para>
59993 </section>
59994 <section id="SECTfinindret">
59995 <title>Finding individual retry times (exinext)</title>
59996 <para>
59997 <indexterm role="concept">
59998 <primary>retry</primary>
59999 <secondary>times</secondary>
60000 </indexterm>
60001 <indexterm role="concept">
60002 <primary><emphasis>exinext</emphasis></primary>
60003 </indexterm>
60004 A utility called <emphasis>exinext</emphasis> (mostly a Perl script) provides the ability to
60005 fish specific information out of the retry database. Given a mail domain (or a
60006 complete address), it looks up the hosts for that domain, and outputs any retry
60007 information for the hosts or for the domain. At present, the retry information
60008 is obtained by running <emphasis>exim_dumpdb</emphasis> (see below) and post-processing the
60009 output. For example:
60010 </para>
60011 <literallayout class="monospaced">
60012 $ exinext piglet@milne.fict.example
60013 kanga.milne.example:192.168.8.1 error 146: Connection refused
60014   first failed: 21-Feb-1996 14:57:34
60015   last tried:   21-Feb-1996 14:57:34
60016   next try at:  21-Feb-1996 15:02:34
60017 roo.milne.example:192.168.8.3 error 146: Connection refused
60018   first failed: 20-Jan-1996 13:12:08
60019   last tried:   21-Feb-1996 11:42:03
60020   next try at:  21-Feb-1996 19:42:03
60021   past final cutoff time
60022 </literallayout>
60023 <para>
60024 You can also give <emphasis>exinext</emphasis> a local part, without a domain, and it
60025 will give any retry information for that local part in your default domain.
60026 A message id can be used to obtain retry information pertaining to a specific
60027 message. This exists only when an attempt to deliver a message to a remote host
60028 suffers a message-specific error (see section <xref linkend="SECToutSMTPerr"/>).
60029 <emphasis>exinext</emphasis> is not particularly efficient, but then it is not expected to be
60030 run very often.
60031 </para>
60032 <para>
60033 The <emphasis>exinext</emphasis> utility calls Exim to find out information such as the location
60034 of the spool directory. The utility has <option>-C</option> and <option>-D</option> options, which are
60035 passed on to the <emphasis>exim</emphasis> commands. The first specifies an alternate Exim
60036 configuration file, and the second sets macros for use within the configuration
60037 file. These features are mainly to help in testing, but might also be useful in
60038 environments where more than one configuration file is in use.
60039 </para>
60040 </section>
60041 <section id="SECThindatmai">
60042 <title>Hints database maintenance</title>
60043 <para>
60044 <indexterm role="concept">
60045 <primary>hints database</primary>
60046 <secondary>maintenance</secondary>
60047 </indexterm>
60048 <indexterm role="concept">
60049 <primary>maintaining Exim&#x2019;s hints database</primary>
60050 </indexterm>
60051 Three utility programs are provided for maintaining the DBM files that Exim
60052 uses to contain its delivery hint information. Each program requires two
60053 arguments. The first specifies the name of Exim&#x2019;s spool directory, and the
60054 second is the name of the database it is to operate on. These are as follows:
60055 </para>
60056 <itemizedlist>
60057 <listitem>
60058 <para>
60059 <emphasis>retry</emphasis>: the database of retry information
60060 </para>
60061 </listitem>
60062 <listitem>
60063 <para>
60064 <emphasis>wait-</emphasis>&lt;<emphasis>transport name</emphasis>&gt;: databases of information about messages waiting
60065 for remote hosts
60066 </para>
60067 </listitem>
60068 <listitem>
60069 <para>
60070 <emphasis>callout</emphasis>: the callout cache
60071 </para>
60072 </listitem>
60073 <listitem>
60074 <para>
60075 <emphasis>ratelimit</emphasis>: the data for implementing the ratelimit ACL condition
60076 </para>
60077 </listitem>
60078 <listitem>
60079 <para>
60080 <emphasis>misc</emphasis>: other hints data
60081 </para>
60082 </listitem>
60083 </itemizedlist>
60084 <para>
60085 The <emphasis>misc</emphasis> database is used for
60086 </para>
60087 <itemizedlist>
60088 <listitem>
60089 <para>
60090 Serializing ETRN runs (when <option>smtp_etrn_serialize</option> is set)
60091 </para>
60092 </listitem>
60093 <listitem>
60094 <para>
60095 Serializing delivery to a specific host (when <option>serialize_hosts</option> is set in an
60096 <command>smtp</command> transport)
60097 </para>
60098 </listitem>
60099 </itemizedlist>
60100 </section>
60101 <section id="SECID261">
60102 <title>exim_dumpdb</title>
60103 <para>
60104 <indexterm role="concept">
60105 <primary><emphasis>exim_dumpdb</emphasis></primary>
60106 </indexterm>
60107 The entire contents of a database are written to the standard output by the
60108 <emphasis>exim_dumpdb</emphasis> program, which has no options or arguments other than the
60109 spool and database names. For example, to dump the retry database:
60110 </para>
60111 <literallayout class="monospaced">
60112 exim_dumpdb /var/spool/exim retry
60113 </literallayout>
60114 <para>
60115 Two lines of output are produced for each entry:
60116 </para>
60117 <literallayout class="monospaced">
60118 T:mail.ref.example:192.168.242.242 146 77 Connection refused
60119 31-Oct-1995 12:00:12 02-Nov-1995 12:21:39 02-Nov-1995 20:21:39 *
60120 </literallayout>
60121 <para>
60122 The first item on the first line is the key of the record. It starts with one
60123 of the letters R, or T, depending on whether it refers to a routing or
60124 transport retry. For a local delivery, the next part is the local address; for
60125 a remote delivery it is the name of the remote host, followed by its failing IP
60126 address (unless <option>retry_include_ip_address</option> is set false on the <command>smtp</command>
60127 transport). If the remote port is not the standard one (port 25), it is added
60128 to the IP address. Then there follows an error code, an additional error code,
60129 and a textual description of the error.
60130 </para>
60131 <para>
60132 The three times on the second line are the time of first failure, the time of
60133 the last delivery attempt, and the computed time for the next attempt. The line
60134 ends with an asterisk if the cutoff time for the last retry rule has been
60135 exceeded.
60136 </para>
60137 <para>
60138 Each output line from <emphasis>exim_dumpdb</emphasis> for the <emphasis>wait-xxx</emphasis> databases
60139 consists of a host name followed by a list of ids for messages that are or were
60140 waiting to be delivered to that host. If there are a very large number for any
60141 one host, continuation records, with a sequence number added to the host name,
60142 may be seen. The data in these records is often out of date, because a message
60143 may be routed to several alternative hosts, and Exim makes no effort to keep
60144 cross-references.
60145 </para>
60146 </section>
60147 <section id="SECID262">
60148 <title>exim_tidydb</title>
60149 <para>
60150 <indexterm role="concept">
60151 <primary><emphasis>exim_tidydb</emphasis></primary>
60152 </indexterm>
60153 The <emphasis>exim_tidydb</emphasis> utility program is used to tidy up the contents of a hints
60154 database. If run with no options, it removes all records that are more than 30
60155 days old. The age is calculated from the date and time that the record was last
60156 updated. Note that, in the case of the retry database, it is <emphasis>not</emphasis> the time
60157 since the first delivery failure. Information about a host that has been down
60158 for more than 30 days will remain in the database, provided that the record is
60159 updated sufficiently often.
60160 </para>
60161 <para>
60162 The cutoff date can be altered by means of the <option>-t</option> option, which must be
60163 followed by a time. For example, to remove all records older than a week from
60164 the retry database:
60165 </para>
60166 <literallayout class="monospaced">
60167 exim_tidydb -t 7d /var/spool/exim retry
60168 </literallayout>
60169 <para>
60170 Both the <emphasis>wait-xxx</emphasis> and <emphasis>retry</emphasis> databases contain items that involve
60171 message ids. In the former these appear as data in records keyed by host &ndash;
60172 they were messages that were waiting for that host &ndash; and in the latter they
60173 are the keys for retry information for messages that have suffered certain
60174 types of error. When <emphasis>exim_tidydb</emphasis> is run, a check is made to ensure that
60175 message ids in database records are those of messages that are still on the
60176 queue. Message ids for messages that no longer exist are removed from
60177 <emphasis>wait-xxx</emphasis> records, and if this leaves any records empty, they are deleted.
60178 For the <emphasis>retry</emphasis> database, records whose keys are non-existent message ids are
60179 removed. The <emphasis>exim_tidydb</emphasis> utility outputs comments on the standard output
60180 whenever it removes information from the database.
60181 </para>
60182 <para>
60183 Certain records are automatically removed by Exim when they are no longer
60184 needed, but others are not. For example, if all the MX hosts for a domain are
60185 down, a retry record is created for each one. If the primary MX host comes back
60186 first, its record is removed when Exim successfully delivers to it, but the
60187 records for the others remain because Exim has not tried to use those hosts.
60188 </para>
60189 <para>
60190 It is important, therefore, to run <emphasis>exim_tidydb</emphasis> periodically on all the
60191 hints databases. You should do this at a quiet time of day, because it requires
60192 a database to be locked (and therefore inaccessible to Exim) while it does its
60193 work. Removing records from a DBM file does not normally make the file smaller,
60194 but all the common DBM libraries are able to re-use the space that is released.
60195 After an initial phase of increasing in size, the databases normally reach a
60196 point at which they no longer get any bigger, as long as they are regularly
60197 tidied.
60198 </para>
60199 <para>
60200 <emphasis role="bold">Warning</emphasis>: If you never run <emphasis>exim_tidydb</emphasis>, the space used by the hints
60201 databases is likely to keep on increasing.
60202 </para>
60203 </section>
60204 <section id="SECID263">
60205 <title>exim_fixdb</title>
60206 <para>
60207 <indexterm role="concept">
60208 <primary><emphasis>exim_fixdb</emphasis></primary>
60209 </indexterm>
60210 The <emphasis>exim_fixdb</emphasis> program is a utility for interactively modifying databases.
60211 Its main use is for testing Exim, but it might also be occasionally useful for
60212 getting round problems in a live system. It has no options, and its interface
60213 is somewhat crude. On entry, it prompts for input with a right angle-bracket. A
60214 key of a database record can then be entered, and the data for that record is
60215 displayed.
60216 </para>
60217 <para>
60218 If <quote>d</quote> is typed at the next prompt, the entire record is deleted. For all
60219 except the <emphasis>retry</emphasis> database, that is the only operation that can be carried
60220 out. For the <emphasis>retry</emphasis> database, each field is output preceded by a number, and
60221 data for individual fields can be changed by typing the field number followed
60222 by new data, for example:
60223 </para>
60224 <literallayout class="monospaced">
60225 &gt; 4 951102:1000
60226 </literallayout>
60227 <para>
60228 resets the time of the next delivery attempt. Time values are given as a
60229 sequence of digit pairs for year, month, day, hour, and minute. Colons can be
60230 used as optional separators.
60231 </para>
60232 </section>
60233 <section id="SECTmailboxmaint">
60234 <title>Mailbox maintenance (exim_lock)</title>
60235 <para>
60236 <indexterm role="concept">
60237 <primary>mailbox</primary>
60238 <secondary>maintenance</secondary>
60239 </indexterm>
60240 <indexterm role="concept">
60241 <primary><emphasis>exim_lock</emphasis></primary>
60242 </indexterm>
60243 <indexterm role="concept">
60244 <primary>locking mailboxes</primary>
60245 </indexterm>
60246 The <emphasis>exim_lock</emphasis> utility locks a mailbox file using the same algorithm as
60247 Exim. For a discussion of locking issues, see section <xref linkend="SECTopappend"/>.
60248 <emphasis>Exim_lock</emphasis> can be used to prevent any modification of a mailbox by Exim or
60249 a user agent while investigating a problem. The utility requires the name of
60250 the file as its first argument. If the locking is successful, the second
60251 argument is run as a command (using C&#x2019;s <function>system()</function> function); if there is no
60252 second argument, the value of the SHELL environment variable is used; if this
60253 is unset or empty, <filename>/bin/sh</filename> is run. When the command finishes, the mailbox
60254 is unlocked and the utility ends. The following options are available:
60255 </para>
60256 <variablelist>
60257 <varlistentry>
60258 <term><option>-fcntl</option></term>
60259 <listitem>
60260 <para>
60261 Use <function>fcntl()</function> locking on the open mailbox.
60262 </para>
60263 </listitem></varlistentry>
60264 <varlistentry>
60265 <term><option>-flock</option></term>
60266 <listitem>
60267 <para>
60268 Use <function>flock()</function> locking on the open mailbox, provided the operating system
60269 supports it.
60270 </para>
60271 </listitem></varlistentry>
60272 <varlistentry>
60273 <term><option>-interval</option></term>
60274 <listitem>
60275 <para>
60276 This must be followed by a number, which is a number of seconds; it sets the
60277 interval to sleep between retries (default 3).
60278 </para>
60279 </listitem></varlistentry>
60280 <varlistentry>
60281 <term><option>-lockfile</option></term>
60282 <listitem>
60283 <para>
60284 Create a lock file before opening the mailbox.
60285 </para>
60286 </listitem></varlistentry>
60287 <varlistentry>
60288 <term><option>-mbx</option></term>
60289 <listitem>
60290 <para>
60291 Lock the mailbox using MBX rules.
60292 </para>
60293 </listitem></varlistentry>
60294 <varlistentry>
60295 <term><option>-q</option></term>
60296 <listitem>
60297 <para>
60298 Suppress verification output.
60299 </para>
60300 </listitem></varlistentry>
60301 <varlistentry>
60302 <term><option>-retries</option></term>
60303 <listitem>
60304 <para>
60305 This must be followed by a number; it sets the number of times to try to get
60306 the lock (default 10).
60307 </para>
60308 </listitem></varlistentry>
60309 <varlistentry>
60310 <term><option>-restore_time</option></term>
60311 <listitem>
60312 <para>
60313 This option causes <option>exim_lock</option> to restore the modified and read times to the
60314 locked file before exiting. This allows you to access a locked mailbox (for
60315 example, to take a backup copy) without disturbing the times that the user
60316 subsequently sees.
60317 </para>
60318 </listitem></varlistentry>
60319 <varlistentry>
60320 <term><option>-timeout</option></term>
60321 <listitem>
60322 <para>
60323 This must be followed by a number, which is a number of seconds; it sets a
60324 timeout to be used with a blocking <function>fcntl()</function> lock. If it is not set (the
60325 default), a non-blocking call is used.
60326 </para>
60327 </listitem></varlistentry>
60328 <varlistentry>
60329 <term><option>-v</option></term>
60330 <listitem>
60331 <para>
60332 Generate verbose output.
60333 </para>
60334 </listitem></varlistentry>
60335 </variablelist>
60336 <para>
60337 If none of <option>-fcntl</option>, <option>-flock</option>, <option>-lockfile</option> or <option>-mbx</option> are given, the
60338 default is to create a lock file and also to use <function>fcntl()</function> locking on the
60339 mailbox, which is the same as Exim&#x2019;s default. The use of <option>-flock</option> or
60340 <option>-fcntl</option> requires that the file be writeable; the use of <option>-lockfile</option>
60341 requires that the directory containing the file be writeable. Locking by lock
60342 file does not last for ever; Exim assumes that a lock file is expired if it is
60343 more than 30 minutes old.
60344 </para>
60345 <para>
60346 The <option>-mbx</option> option can be used with either or both of <option>-fcntl</option> or
60347 <option>-flock</option>. It assumes <option>-fcntl</option> by default. MBX locking causes a shared lock
60348 to be taken out on the open mailbox, and an exclusive lock on the file
60349 <filename>/tmp/.n.m</filename> where <emphasis>n</emphasis> and <emphasis>m</emphasis> are the device number and inode
60350 number of the mailbox file. When the locking is released, if an exclusive lock
60351 can be obtained for the mailbox, the file in <filename>/tmp</filename> is deleted.
60352 </para>
60353 <para>
60354 The default output contains verification of the locking that takes place. The
60355 <option>-v</option> option causes some additional information to be given. The <option>-q</option> option
60356 suppresses all output except error messages.
60357 </para>
60358 <para>
60359 A command such as
60360 </para>
60361 <literallayout class="monospaced">
60362 exim_lock /var/spool/mail/spqr
60363 </literallayout>
60364 <para>
60365 runs an interactive shell while the file is locked, whereas
60366 </para>
60367 <literallayout>
60368 <literal>exim_lock -q /var/spool/mail/spqr &lt;&lt;End</literal>
60369 &lt;<emphasis>some commands</emphasis>&gt;
60370 <literal>End</literal>
60371 </literallayout>
60372 <para>
60373 runs a specific non-interactive sequence of commands while the file is locked,
60374 suppressing all verification output. A single command can be run by a command
60375 such as
60376 </para>
60377 <literallayout class="monospaced">
60378 exim_lock -q /var/spool/mail/spqr \
60379   "cp /var/spool/mail/spqr /some/where"
60380 </literallayout>
60381 <para>
60382 Note that if a command is supplied, it must be entirely contained within the
60383 second argument &ndash; hence the quotes.
60384 <indexterm role="concept" startref="IIDutils" class="endofrange"/>
60385 </para>
60386 </section>
60387 </chapter>
60388
60389 <chapter id="CHAPeximon">
60390 <title>The Exim monitor</title>
60391 <para>
60392 <indexterm role="concept" id="IIDeximon" class="startofrange">
60393 <primary>Exim monitor</primary>
60394 <secondary>description</secondary>
60395 </indexterm>
60396 <indexterm role="concept">
60397 <primary>X-windows</primary>
60398 </indexterm>
60399 <indexterm role="concept">
60400 <primary><emphasis>eximon</emphasis></primary>
60401 </indexterm>
60402 <indexterm role="concept">
60403 <primary>Local/eximon.conf</primary>
60404 </indexterm>
60405 <indexterm role="concept">
60406 <primary><filename>exim_monitor/EDITME</filename></primary>
60407 </indexterm>
60408 The Exim monitor is an application which displays in an X window information
60409 about the state of Exim&#x2019;s queue and what Exim is doing. An admin user can
60410 perform certain operations on messages from this GUI interface; however all
60411 such facilities are also available from the command line, and indeed, the
60412 monitor itself makes use of the command line to perform any actions requested.
60413 </para>
60414 <section id="SECID264">
60415 <title>Running the monitor</title>
60416 <para>
60417 The monitor is started by running the script called <emphasis>eximon</emphasis>. This is a shell
60418 script that sets up a number of environment variables, and then runs the
60419 binary called <filename>eximon.bin</filename>. The default appearance of the monitor window can
60420 be changed by editing the <filename>Local/eximon.conf</filename> file created by editing
60421 <filename>exim_monitor/EDITME</filename>. Comments in that file describe what the various
60422 parameters are for.
60423 </para>
60424 <para>
60425 The parameters that get built into the <emphasis>eximon</emphasis> script can be overridden for
60426 a particular invocation by setting up environment variables of the same names,
60427 preceded by <literal>EXIMON_</literal>. For example, a shell command such as
60428 </para>
60429 <literallayout class="monospaced">
60430 EXIMON_LOG_DEPTH=400 eximon
60431 </literallayout>
60432 <para>
60433 (in a Bourne-compatible shell) runs <emphasis>eximon</emphasis> with an overriding setting of
60434 the LOG_DEPTH parameter. If EXIMON_LOG_FILE_PATH is set in the environment, it
60435 overrides the Exim log file configuration. This makes it possible to have
60436 <emphasis>eximon</emphasis> tailing log data that is written to syslog, provided that MAIL.INFO
60437 syslog messages are routed to a file on the local host.
60438 </para>
60439 <para>
60440 X resources can be used to change the appearance of the window in the normal
60441 way. For example, a resource setting of the form
60442 </para>
60443 <literallayout class="monospaced">
60444 Eximon*background: gray94
60445 </literallayout>
60446 <para>
60447 changes the colour of the background to light grey rather than white. The
60448 stripcharts are drawn with both the data lines and the reference lines in
60449 black. This means that the reference lines are not visible when on top of the
60450 data. However, their colour can be changed by setting a resource called
60451 <quote>highlight</quote> (an odd name, but that&#x2019;s what the Athena stripchart widget uses).
60452 For example, if your X server is running Unix, you could set up lighter
60453 reference lines in the stripcharts by obeying
60454 </para>
60455 <literallayout class="monospaced">
60456 xrdb -merge &lt;&lt;End
60457 Eximon*highlight: gray
60458 End
60459 </literallayout>
60460 <para>
60461 <indexterm role="concept">
60462 <primary>admin user</primary>
60463 </indexterm>
60464 In order to see the contents of messages on the queue, and to operate on them,
60465 <emphasis>eximon</emphasis> must either be run as root or by an admin user.
60466 </para>
60467 <para>
60468 The monitor&#x2019;s window is divided into three parts. The first contains one or
60469 more stripcharts and two action buttons, the second contains a <quote>tail</quote> of the
60470 main log file, and the third is a display of the queue of messages awaiting
60471 delivery, with two more action buttons. The following sections describe these
60472 different parts of the display.
60473 </para>
60474 </section>
60475 <section id="SECID265">
60476 <title>The stripcharts</title>
60477 <para>
60478 <indexterm role="concept">
60479 <primary>stripchart</primary>
60480 </indexterm>
60481 The first stripchart is always a count of messages on the queue. Its name can
60482 be configured by setting QUEUE_STRIPCHART_NAME in the
60483 <filename>Local/eximon.conf</filename> file. The remaining stripcharts are defined in the
60484 configuration script by regular expression matches on log file entries, making
60485 it possible to display, for example, counts of messages delivered to certain
60486 hosts or using certain transports. The supplied defaults display counts of
60487 received and delivered messages, and of local and SMTP deliveries. The default
60488 period between stripchart updates is one minute; this can be adjusted by a
60489 parameter in the <filename>Local/eximon.conf</filename> file.
60490 </para>
60491 <para>
60492 The stripchart displays rescale themselves automatically as the value they are
60493 displaying changes. There are always 10 horizontal lines in each chart; the
60494 title string indicates the value of each division when it is greater than one.
60495 For example, <quote>x2</quote> means that each division represents a value of 2.
60496 </para>
60497 <para>
60498 It is also possible to have a stripchart which shows the percentage fullness of
60499 a particular disk partition, which is useful when local deliveries are confined
60500 to a single partition.
60501 </para>
60502 <para>
60503 <indexterm role="concept">
60504 <primary><option>statvfs</option> function</primary>
60505 </indexterm>
60506 This relies on the availability of the <function>statvfs()</function> function or equivalent in
60507 the operating system. Most, but not all versions of Unix that support Exim have
60508 this. For this particular stripchart, the top of the chart always represents
60509 100%, and the scale is given as <quote>x10%</quote>. This chart is configured by setting
60510 SIZE_STRIPCHART and (optionally) SIZE_STRIPCHART_NAME in the
60511 <filename>Local/eximon.conf</filename> file.
60512 </para>
60513 </section>
60514 <section id="SECID266">
60515 <title>Main action buttons</title>
60516 <para>
60517 <indexterm role="concept">
60518 <primary>size</primary>
60519 <secondary>of monitor window</secondary>
60520 </indexterm>
60521 <indexterm role="concept">
60522 <primary>Exim monitor</primary>
60523 <secondary>window size</secondary>
60524 </indexterm>
60525 <indexterm role="concept">
60526 <primary>window size</primary>
60527 </indexterm>
60528 Below the stripcharts there is an action button for quitting the monitor. Next
60529 to this is another button marked <quote>Size</quote>. They are placed here so that
60530 shrinking the window to its default minimum size leaves just the queue count
60531 stripchart and these two buttons visible. Pressing the <quote>Size</quote> button causes
60532 the window to expand to its maximum size, unless it is already at the maximum,
60533 in which case it is reduced to its minimum.
60534 </para>
60535 <para>
60536 When expanding to the maximum, if the window cannot be fully seen where it
60537 currently is, it is moved back to where it was the last time it was at full
60538 size. When it is expanding from its minimum size, the old position is
60539 remembered, and next time it is reduced to the minimum it is moved back there.
60540 </para>
60541 <para>
60542 The idea is that you can keep a reduced window just showing one or two
60543 stripcharts at a convenient place on your screen, easily expand it to show
60544 the full window when required, and just as easily put it back to what it was.
60545 The idea is copied from what the <emphasis>twm</emphasis> window manager does for its
60546 <emphasis>f.fullzoom</emphasis> action. The minimum size of the window can be changed by setting
60547 the MIN_HEIGHT and MIN_WIDTH values in <filename>Local/eximon.conf</filename>.
60548 </para>
60549 <para>
60550 Normally, the monitor starts up with the window at its full size, but it can be
60551 built so that it starts up with the window at its smallest size, by setting
60552 START_SMALL=yes in <filename>Local/eximon.conf</filename>.
60553 </para>
60554 </section>
60555 <section id="SECID267">
60556 <title>The log display</title>
60557 <para>
60558 <indexterm role="concept">
60559 <primary>log</primary>
60560 <secondary>tail of; in monitor</secondary>
60561 </indexterm>
60562 The second section of the window is an area in which a display of the tail of
60563 the main log is maintained.
60564 To save space on the screen, the timestamp on each log line is shortened by
60565 removing the date and, if <option>log_timezone</option> is set, the timezone.
60566 The log tail is not available when the only destination for logging data is
60567 syslog, unless the syslog lines are routed to a local file whose name is passed
60568 to <emphasis>eximon</emphasis> via the EXIMON_LOG_FILE_PATH environment variable.
60569 </para>
60570 <para>
60571 The log sub-window has a scroll bar at its lefthand side which can be used to
60572 move back to look at earlier text, and the up and down arrow keys also have a
60573 scrolling effect. The amount of log that is kept depends on the setting of
60574 LOG_BUFFER in <filename>Local/eximon.conf</filename>, which specifies the amount of memory
60575 to use. When this is full, the earlier 50% of data is discarded &ndash; this is
60576 much more efficient than throwing it away line by line. The sub-window also has
60577 a horizontal scroll bar for accessing the ends of long log lines. This is the
60578 only means of horizontal scrolling; the right and left arrow keys are not
60579 available. Text can be cut from this part of the window using the mouse in the
60580 normal way. The size of this subwindow is controlled by parameters in the
60581 configuration file <filename>Local/eximon.conf</filename>.
60582 </para>
60583 <para>
60584 Searches of the text in the log window can be carried out by means of the ^R
60585 and ^S keystrokes, which default to a reverse and a forward search,
60586 respectively. The search covers only the text that is displayed in the window.
60587 It cannot go further back up the log.
60588 </para>
60589 <para>
60590 The point from which the search starts is indicated by a caret marker. This is
60591 normally at the end of the text in the window, but can be positioned explicitly
60592 by pointing and clicking with the left mouse button, and is moved automatically
60593 by a successful search. If new text arrives in the window when it is scrolled
60594 back, the caret remains where it is, but if the window is not scrolled back,
60595 the caret is moved to the end of the new text.
60596 </para>
60597 <para>
60598 Pressing ^R or ^S pops up a window into which the search text can be typed.
60599 There are buttons for selecting forward or reverse searching, for carrying out
60600 the search, and for cancelling. If the <quote>Search</quote> button is pressed, the search
60601 happens and the window remains so that further searches can be done. If the
60602 <quote>Return</quote> key is pressed, a single search is done and the window is closed. If
60603 ^C is typed the search is cancelled.
60604 </para>
60605 <para>
60606 The searching facility is implemented using the facilities of the Athena text
60607 widget. By default this pops up a window containing both <quote>search</quote> and
60608 <quote>replace</quote> options. In order to suppress the unwanted <quote>replace</quote> portion for
60609 eximon, a modified version of the <option>TextPop</option> widget is distributed with Exim.
60610 However, the linkers in BSDI and HP-UX seem unable to handle an externally
60611 provided version of <option>TextPop</option> when the remaining parts of the text widget
60612 come from the standard libraries. The compile-time option EXIMON_TEXTPOP can be
60613 unset to cut out the modified <option>TextPop</option>, making it possible to build Eximon
60614 on these systems, at the expense of having unwanted items in the search popup
60615 window.
60616 </para>
60617 </section>
60618 <section id="SECID268">
60619 <title>The queue display</title>
60620 <para>
60621 <indexterm role="concept">
60622 <primary>queue</primary>
60623 <secondary>display in monitor</secondary>
60624 </indexterm>
60625 The bottom section of the monitor window contains a list of all messages that
60626 are on the queue, which includes those currently being received or delivered,
60627 as well as those awaiting delivery. The size of this subwindow is controlled by
60628 parameters in the configuration file <filename>Local/eximon.conf</filename>, and the frequency
60629 at which it is updated is controlled by another parameter in the same file &ndash;
60630 the default is 5 minutes, since queue scans can be quite expensive. However,
60631 there is an <quote>Update</quote> action button just above the display which can be used
60632 to force an update of the queue display at any time.
60633 </para>
60634 <para>
60635 When a host is down for some time, a lot of pending mail can build up for it,
60636 and this can make it hard to deal with other messages on the queue. To help
60637 with this situation there is a button next to <quote>Update</quote> called <quote>Hide</quote>. If
60638 pressed, a dialogue box called <quote>Hide addresses ending with</quote> is put up. If you
60639 type anything in here and press <quote>Return</quote>, the text is added to a chain of
60640 such texts, and if every undelivered address in a message matches at least one
60641 of the texts, the message is not displayed.
60642 </para>
60643 <para>
60644 If there is an address that does not match any of the texts, all the addresses
60645 are displayed as normal. The matching happens on the ends of addresses so, for
60646 example, <emphasis>cam.ac.uk</emphasis> specifies all addresses in Cambridge, while
60647 <emphasis>xxx@foo.com.example</emphasis> specifies just one specific address. When any hiding
60648 has been set up, a button called <quote>Unhide</quote> is displayed. If pressed, it
60649 cancels all hiding. Also, to ensure that hidden messages do not get forgotten,
60650 a hide request is automatically cancelled after one hour.
60651 </para>
60652 <para>
60653 While the dialogue box is displayed, you can&#x2019;t press any buttons or do anything
60654 else to the monitor window. For this reason, if you want to cut text from the
60655 queue display to use in the dialogue box, you have to do the cutting before
60656 pressing the <quote>Hide</quote> button.
60657 </para>
60658 <para>
60659 The queue display contains, for each unhidden queued message, the length of
60660 time it has been on the queue, the size of the message, the message id, the
60661 message sender, and the first undelivered recipient, all on one line. If it is
60662 a bounce message, the sender is shown as <quote>&lt;&gt;</quote>. If there is more than one
60663 recipient to which the message has not yet been delivered, subsequent ones are
60664 listed on additional lines, up to a maximum configured number, following which
60665 an ellipsis is displayed. Recipients that have already received the message are
60666 not shown.
60667 </para>
60668 <para>
60669 <indexterm role="concept">
60670 <primary>frozen messages</primary>
60671 <secondary>display</secondary>
60672 </indexterm>
60673 If a message is frozen, an asterisk is displayed at the left-hand side.
60674 </para>
60675 <para>
60676 The queue display has a vertical scroll bar, and can also be scrolled by means
60677 of the arrow keys. Text can be cut from it using the mouse in the normal way.
60678 The text searching facilities, as described above for the log window, are also
60679 available, but the caret is always moved to the end of the text when the queue
60680 display is updated.
60681 </para>
60682 </section>
60683 <section id="SECID269">
60684 <title>The queue menu</title>
60685 <para>
60686 <indexterm role="concept">
60687 <primary>queue</primary>
60688 <secondary>menu in monitor</secondary>
60689 </indexterm>
60690 If the <option>shift</option> key is held down and the left button is clicked when the mouse
60691 pointer is over the text for any message, an action menu pops up, and the first
60692 line of the queue display for the message is highlighted. This does not affect
60693 any selected text.
60694 </para>
60695 <para>
60696 If you want to use some other event for popping up the menu, you can set the
60697 MENU_EVENT parameter in <filename>Local/eximon.conf</filename> to change the default, or
60698 set EXIMON_MENU_EVENT in the environment before starting the monitor. The
60699 value set in this parameter is a standard X event description. For example, to
60700 run eximon using <option>ctrl</option> rather than <option>shift</option> you could use
60701 </para>
60702 <literallayout class="monospaced">
60703 EXIMON_MENU_EVENT='Ctrl&lt;Btn1Down&gt;' eximon
60704 </literallayout>
60705 <para>
60706 The title of the menu is the message id, and it contains entries which act as
60707 follows:
60708 </para>
60709 <itemizedlist>
60710 <listitem>
60711 <para>
60712 <emphasis>message log</emphasis>: The contents of the message log for the message are displayed
60713 in a new text window.
60714 </para>
60715 </listitem>
60716 <listitem>
60717 <para>
60718 <emphasis>headers</emphasis>: Information from the spool file that contains the envelope
60719 information and headers is displayed in a new text window. See chapter
60720 <xref linkend="CHAPspool"/> for a description of the format of spool files.
60721 </para>
60722 </listitem>
60723 <listitem>
60724 <para>
60725 <emphasis>body</emphasis>: The contents of the spool file containing the body of the message are
60726 displayed in a new text window. There is a default limit of 20,000 bytes to the
60727 amount of data displayed. This can be changed by setting the BODY_MAX
60728 option at compile time, or the EXIMON_BODY_MAX option at run time.
60729 </para>
60730 </listitem>
60731 <listitem>
60732 <para>
60733 <emphasis>deliver message</emphasis>: A call to Exim is made using the <option>-M</option> option to request
60734 delivery of the message. This causes an automatic thaw if the message is
60735 frozen. The <option>-v</option> option is also set, and the output from Exim is displayed in
60736 a new text window. The delivery is run in a separate process, to avoid holding
60737 up the monitor while the delivery proceeds.
60738 </para>
60739 </listitem>
60740 <listitem>
60741 <para>
60742 <emphasis>freeze message</emphasis>: A call to Exim is made using the <option>-Mf</option> option to request
60743 that the message be frozen.
60744 </para>
60745 </listitem>
60746 <listitem>
60747 <para>
60748 <indexterm role="concept">
60749 <primary>thawing messages</primary>
60750 </indexterm>
60751 <indexterm role="concept">
60752 <primary>unfreezing messages</primary>
60753 </indexterm>
60754 <indexterm role="concept">
60755 <primary>frozen messages</primary>
60756 <secondary>thawing</secondary>
60757 </indexterm>
60758 <emphasis>thaw message</emphasis>: A call to Exim is made using the <option>-Mt</option> option to request
60759 that the message be thawed.
60760 </para>
60761 </listitem>
60762 <listitem>
60763 <para>
60764 <indexterm role="concept">
60765 <primary>delivery</primary>
60766 <secondary>forcing failure</secondary>
60767 </indexterm>
60768 <emphasis>give up on msg</emphasis>: A call to Exim is made using the <option>-Mg</option> option to request
60769 that Exim gives up trying to deliver the message. A bounce message is generated
60770 for any remaining undelivered addresses.
60771 </para>
60772 </listitem>
60773 <listitem>
60774 <para>
60775 <emphasis>remove message</emphasis>: A call to Exim is made using the <option>-Mrm</option> option to request
60776 that the message be deleted from the system without generating a bounce
60777 message.
60778 </para>
60779 </listitem>
60780 <listitem>
60781 <para>
60782 <emphasis>add recipient</emphasis>: A dialog box is displayed into which a recipient address can
60783 be typed. If the address is not qualified and the QUALIFY_DOMAIN parameter
60784 is set in <filename>Local/eximon.conf</filename>, the address is qualified with that domain.
60785 Otherwise it must be entered as a fully qualified address. Pressing RETURN
60786 causes a call to Exim to be made using the <option>-Mar</option> option to request that an
60787 additional recipient be added to the message, unless the entry box is empty, in
60788 which case no action is taken.
60789 </para>
60790 </listitem>
60791 <listitem>
60792 <para>
60793 <emphasis>mark delivered</emphasis>: A dialog box is displayed into which a recipient address
60794 can be typed. If the address is not qualified and the QUALIFY_DOMAIN parameter
60795 is set in <filename>Local/eximon.conf</filename>, the address is qualified with that domain.
60796 Otherwise it must be entered as a fully qualified address. Pressing RETURN
60797 causes a call to Exim to be made using the <option>-Mmd</option> option to mark the given
60798 recipient address as already delivered, unless the entry box is empty, in which
60799 case no action is taken.
60800 </para>
60801 </listitem>
60802 <listitem>
60803 <para>
60804 <emphasis>mark all delivered</emphasis>: A call to Exim is made using the <option>-Mmad</option> option to
60805 mark all recipient addresses as already delivered.
60806 </para>
60807 </listitem>
60808 <listitem>
60809 <para>
60810 <emphasis>edit sender</emphasis>: A dialog box is displayed initialized with the current
60811 sender&#x2019;s address. Pressing RETURN causes a call to Exim to be made using the
60812 <option>-Mes</option> option to replace the sender address, unless the entry box is empty,
60813 in which case no action is taken. If you want to set an empty sender (as in
60814 bounce messages), you must specify it as <quote>&lt;&gt;</quote>. Otherwise, if the address is
60815 not qualified and the QUALIFY_DOMAIN parameter is set in <filename>Local/eximon.conf</filename>,
60816 the address is qualified with that domain.
60817 </para>
60818 </listitem>
60819 </itemizedlist>
60820 <para>
60821 When a delivery is forced, a window showing the <option>-v</option> output is displayed. In
60822 other cases when a call to Exim is made, if there is any output from Exim (in
60823 particular, if the command fails) a window containing the command and the
60824 output is displayed. Otherwise, the results of the action are normally apparent
60825 from the log and queue displays. However, if you set ACTION_OUTPUT=yes in
60826 <filename>Local/eximon.conf</filename>, a window showing the Exim command is always opened, even
60827 if no output is generated.
60828 </para>
60829 <para>
60830 The queue display is automatically updated for actions such as freezing and
60831 thawing, unless ACTION_QUEUE_UPDATE=no has been set in
60832 <filename>Local/eximon.conf</filename>. In this case the <quote>Update</quote> button has to be used to
60833 force an update of the display after one of these actions.
60834 </para>
60835 <para>
60836 In any text window that is displayed as result of a menu action, the normal
60837 cut-and-paste facility is available, and searching can be carried out using ^R
60838 and ^S, as described above for the log tail window.
60839 <indexterm role="concept" startref="IIDeximon" class="endofrange"/>
60840 </para>
60841 </section>
60842 </chapter>
60843
60844 <chapter id="CHAPsecurity">
60845 <title>Security considerations</title>
60846 <para>
60847 <indexterm role="concept" id="IIDsecurcon" class="startofrange">
60848 <primary>security</primary>
60849 <secondary>discussion of</secondary>
60850 </indexterm>
60851 This chapter discusses a number of issues concerned with security, some of
60852 which are also covered in other parts of this manual.
60853 </para>
60854 <para>
60855 For reasons that this author does not understand, some people have promoted
60856 Exim as a <quote>particularly secure</quote> mailer. Perhaps it is because of the
60857 existence of this chapter in the documentation. However, the intent of the
60858 chapter is simply to describe the way Exim works in relation to certain
60859 security concerns, not to make any specific claims about the effectiveness of
60860 its security as compared with other MTAs.
60861 </para>
60862 <para>
60863 What follows is a description of the way Exim is supposed to be. Best efforts
60864 have been made to try to ensure that the code agrees with the theory, but an
60865 absence of bugs can never be guaranteed. Any that are reported will get fixed
60866 as soon as possible.
60867 </para>
60868 <section id="SECID286">
60869 <title>Building a more <quote>hardened</quote> Exim</title>
60870 <para>
60871 <indexterm role="concept">
60872 <primary>security</primary>
60873 <secondary>build-time features</secondary>
60874 </indexterm>
60875 There are a number of build-time options that can be set in <filename>Local/Makefile</filename>
60876 to create Exim binaries that are <quote>harder</quote> to attack, in particular by a rogue
60877 Exim administrator who does not have the root password, or by someone who has
60878 penetrated the Exim (but not the root) account. These options are as follows:
60879 </para>
60880 <itemizedlist>
60881 <listitem>
60882 <para>
60883 ALT_CONFIG_PREFIX can be set to a string that is required to match the
60884 start of any file names used with the <option>-C</option> option. When it is set, these file
60885 names are also not allowed to contain the sequence <quote>/../</quote>. (However, if the
60886 value of the <option>-C</option> option is identical to the value of CONFIGURE_FILE in
60887 <filename>Local/Makefile</filename>, Exim ignores <option>-C</option> and proceeds as usual.) There is no
60888 default setting for <option>ALT_CONFIG_PREFIX</option>.
60889 </para>
60890 <para>
60891 If the permitted configuration files are confined to a directory to
60892 which only root has access, this guards against someone who has broken
60893 into the Exim account from running a privileged Exim with an arbitrary
60894 configuration file, and using it to break into other accounts.
60895 </para>
60896 </listitem>
60897 <listitem>
60898 <para revisionflag="changed">
60899 If a non-trusted configuration file (i.e. not the default configuration file
60900 or one which is trusted by virtue of being listed in the TRUSTED_CONFIG_LIST
60901 file) is specified with <option>-C</option>, or if macros are given with <option>-D</option> (but see
60902 the next item), then root privilege is retained only if the caller of Exim is
60903 root. This locks out the possibility of testing a configuration using <option>-C</option>
60904 right through message reception and delivery, even if the caller is root. The
60905 reception works, but by that time, Exim is running as the Exim user, so when
60906 it re-execs to regain privilege for the delivery, the use of <option>-C</option> causes
60907 privilege to be lost. However, root can test reception and delivery using two
60908 separate commands.
60909 </para>
60910 </listitem>
60911 <listitem>
60912 <para>
60913 The WHITELIST_D_MACROS build option declares some macros to be safe to override
60914 with <option>-D</option> if the real uid is one of root, the Exim run-time user or the
60915 CONFIGURE_OWNER, if defined.  The potential impact of this option is limited by
60916 requiring the run-time value supplied to <option>-D</option> to match a regex that errs on
60917 the restrictive side.  Requiring build-time selection of safe macros is onerous
60918 but this option is intended solely as a transition mechanism to permit
60919 previously-working configurations to continue to work after release 4.73.
60920 </para>
60921 </listitem>
60922 <listitem>
60923 <para>
60924 If DISABLE_D_OPTION is defined, the use of the <option>-D</option> command line option
60925 is disabled.
60926 </para>
60927 </listitem>
60928 <listitem>
60929 <para>
60930 FIXED_NEVER_USERS can be set to a colon-separated list of users that are
60931 never to be used for any deliveries. This is like the <option>never_users</option> runtime
60932 option, but it cannot be overridden; the runtime option adds additional users
60933 to the list. The default setting is <quote>root</quote>; this prevents a non-root user who
60934 is permitted to modify the runtime file from using Exim as a way to get root.
60935 </para>
60936 </listitem>
60937 </itemizedlist>
60938 </section>
60939 <section id="SECID270">
60940 <title>Root privilege</title>
60941 <para>
60942 <indexterm role="concept">
60943 <primary>setuid</primary>
60944 </indexterm>
60945 <indexterm role="concept">
60946 <primary>root privilege</primary>
60947 </indexterm>
60948 The Exim binary is normally setuid to root, which means that it gains root
60949 privilege (runs as root) when it starts execution. In some special cases (for
60950 example, when the daemon is not in use and there are no local deliveries), it
60951 may be possible to run Exim setuid to some user other than root. This is
60952 discussed in the next section. However, in most installations, root privilege
60953 is required for two things:
60954 </para>
60955 <itemizedlist>
60956 <listitem>
60957 <para>
60958 To set up a socket connected to the standard SMTP port (25) when initialising
60959 the listening daemon. If Exim is run from <emphasis>inetd</emphasis>, this privileged action is
60960 not required.
60961 </para>
60962 </listitem>
60963 <listitem>
60964 <para>
60965 To be able to change uid and gid in order to read users&#x2019; <filename>.forward</filename> files and
60966 perform local deliveries as the receiving user or as specified in the
60967 configuration.
60968 </para>
60969 </listitem>
60970 </itemizedlist>
60971 <para>
60972 It is not necessary to be root to do any of the other things Exim does, such as
60973 receiving messages and delivering them externally over SMTP, and it is
60974 obviously more secure if Exim does not run as root except when necessary.
60975 For this reason, a user and group for Exim to use must be defined in
60976 <filename>Local/Makefile</filename>. These are known as <quote>the Exim user</quote> and <quote>the Exim
60977 group</quote>. Their values can be changed by the run time configuration, though this
60978 is not recommended. Often a user called <emphasis>exim</emphasis> is used, but some sites use
60979 <emphasis>mail</emphasis> or another user name altogether.
60980 </para>
60981 <para>
60982 Exim uses <function>setuid()</function> whenever it gives up root privilege. This is a permanent
60983 abdication; the process cannot regain root afterwards. Prior to release 4.00,
60984 <function>seteuid()</function> was used in some circumstances, but this is no longer the case.
60985 </para>
60986 <para>
60987 After a new Exim process has interpreted its command line options, it changes
60988 uid and gid in the following cases:
60989 </para>
60990 <itemizedlist>
60991 <listitem>
60992 <para>
60993 <indexterm role="option">
60994 <primary><option>-C</option></primary>
60995 </indexterm>
60996 <indexterm role="option">
60997 <primary><option>-D</option></primary>
60998 </indexterm>
60999 If the <option>-C</option> option is used to specify an alternate configuration file, or if
61000 the <option>-D</option> option is used to define macro values for the configuration, and the
61001 calling process is not running as root, the uid and gid are changed to those of
61002 the calling process.
61003 However, if DISABLE_D_OPTION is defined in <filename>Local/Makefile</filename>, the <option>-D</option>
61004 option may not be used at all.
61005 If WHITELIST_D_MACROS is defined in <filename>Local/Makefile</filename>, then some macro values
61006 can be supplied if the calling process is running as root, the Exim run-time
61007 user or CONFIGURE_OWNER, if defined.
61008 </para>
61009 </listitem>
61010 <listitem>
61011 <para>
61012 <indexterm role="option">
61013 <primary><option>-be</option></primary>
61014 </indexterm>
61015 <indexterm role="option">
61016 <primary><option>-bf</option></primary>
61017 </indexterm>
61018 <indexterm role="option">
61019 <primary><option>-bF</option></primary>
61020 </indexterm>
61021 If the expansion test option (<option>-be</option>) or one of the filter testing options
61022 (<option>-bf</option> or <option>-bF</option>) are used, the uid and gid are changed to those of the
61023 calling process.
61024 </para>
61025 </listitem>
61026 <listitem>
61027 <para>
61028 If the process is not a daemon process or a queue runner process or a delivery
61029 process or a process for testing address routing (started with <option>-bt</option>), the
61030 uid and gid are changed to the Exim user and group. This means that Exim always
61031 runs under its own uid and gid when receiving messages. This also applies when
61032 testing address verification
61033 <indexterm role="option">
61034 <primary><option>-bv</option></primary>
61035 </indexterm>
61036 <indexterm role="option">
61037 <primary><option>-bh</option></primary>
61038 </indexterm>
61039 (the <option>-bv</option> option) and testing incoming message policy controls (the <option>-bh</option>
61040 option).
61041 </para>
61042 </listitem>
61043 <listitem>
61044 <para>
61045 For a daemon, queue runner, delivery, or address testing process, the uid
61046 remains as root at this stage, but the gid is changed to the Exim group.
61047 </para>
61048 </listitem>
61049 </itemizedlist>
61050 <para>
61051 The processes that initially retain root privilege behave as follows:
61052 </para>
61053 <itemizedlist>
61054 <listitem>
61055 <para>
61056 A daemon process changes the gid to the Exim group and the uid to the Exim
61057 user after setting up one or more listening sockets. The <function>initgroups()</function>
61058 function is called, so that if the Exim user is in any additional groups, they
61059 will be used during message reception.
61060 </para>
61061 </listitem>
61062 <listitem>
61063 <para>
61064 A queue runner process retains root privilege throughout its execution. Its
61065 job is to fork a controlled sequence of delivery processes.
61066 </para>
61067 </listitem>
61068 <listitem>
61069 <para>
61070 A delivery process retains root privilege throughout most of its execution,
61071 but any actual deliveries (that is, the transports themselves) are run in
61072 subprocesses which always change to a non-root uid and gid. For local
61073 deliveries this is typically the uid and gid of the owner of the mailbox; for
61074 remote deliveries, the Exim uid and gid are used. Once all the delivery
61075 subprocesses have been run, a delivery process changes to the Exim uid and gid
61076 while doing post-delivery tidying up such as updating the retry database and
61077 generating bounce and warning messages.
61078 </para>
61079 <para>
61080 While the recipient addresses in a message are being routed, the delivery
61081 process runs as root. However, if a user&#x2019;s filter file has to be processed,
61082 this is done in a subprocess that runs under the individual user&#x2019;s uid and
61083 gid. A system filter is run as root unless <option>system_filter_user</option> is set.
61084 </para>
61085 </listitem>
61086 <listitem>
61087 <para>
61088 A process that is testing addresses (the <option>-bt</option> option) runs as root so that
61089 the routing is done in the same environment as a message delivery.
61090 </para>
61091 </listitem>
61092 </itemizedlist>
61093 </section>
61094 <section id="SECTrunexiwitpri">
61095 <title>Running Exim without privilege</title>
61096 <para>
61097 <indexterm role="concept">
61098 <primary>privilege, running without</primary>
61099 </indexterm>
61100 <indexterm role="concept">
61101 <primary>unprivileged running</primary>
61102 </indexterm>
61103 <indexterm role="concept">
61104 <primary>root privilege</primary>
61105 <secondary>running without</secondary>
61106 </indexterm>
61107 Some installations like to run Exim in an unprivileged state for more of its
61108 operation, for added security. Support for this mode of operation is provided
61109 by the global option <option>deliver_drop_privilege</option>. When this is set, the uid and
61110 gid are changed to the Exim user and group at the start of a delivery process
61111 (and also queue runner and address testing processes). This means that address
61112 routing is no longer run as root, and the deliveries themselves cannot change
61113 to any other uid.
61114 </para>
61115 <para>
61116 <indexterm role="concept">
61117 <primary>SIGHUP</primary>
61118 </indexterm>
61119 <indexterm role="concept">
61120 <primary>daemon</primary>
61121 <secondary>restarting</secondary>
61122 </indexterm>
61123 Leaving the binary setuid to root, but setting <option>deliver_drop_privilege</option> means
61124 that the daemon can still be started in the usual way, and it can respond
61125 correctly to SIGHUP because the re-invocation regains root privilege.
61126 </para>
61127 <para>
61128 An alternative approach is to make Exim setuid to the Exim user and also setgid
61129 to the Exim group. If you do this, the daemon must be started from a root
61130 process. (Calling Exim from a root process makes it behave in the way it does
61131 when it is setuid root.) However, the daemon cannot restart itself after a
61132 SIGHUP signal because it cannot regain privilege.
61133 </para>
61134 <para>
61135 It is still useful to set <option>deliver_drop_privilege</option> in this case, because it
61136 stops Exim from trying to re-invoke itself to do a delivery after a message has
61137 been received. Such a re-invocation is a waste of resources because it has no
61138 effect.
61139 </para>
61140 <para>
61141 If restarting the daemon is not an issue (for example, if <option>mua_wrapper</option> is
61142 set, or <emphasis>inetd</emphasis> is being used instead of a daemon), having the binary setuid
61143 to the Exim user seems a clean approach, but there is one complication:
61144 </para>
61145 <para>
61146 In this style of operation, Exim is running with the real uid and gid set to
61147 those of the calling process, and the effective uid/gid set to Exim&#x2019;s values.
61148 Ideally, any association with the calling process&#x2019; uid/gid should be dropped,
61149 that is, the real uid/gid should be reset to the effective values so as to
61150 discard any privileges that the caller may have. While some operating systems
61151 have a function that permits this action for a non-root effective uid, quite a
61152 number of them do not. Because of this lack of standardization, Exim does not
61153 address this problem at this time.
61154 </para>
61155 <para>
61156 For this reason, the recommended approach for <quote>mostly unprivileged</quote> running
61157 is to keep the Exim binary setuid to root, and to set
61158 <option>deliver_drop_privilege</option>. This also has the advantage of allowing a daemon to
61159 be used in the most straightforward way.
61160 </para>
61161 <para>
61162 If you configure Exim not to run delivery processes as root, there are a
61163 number of restrictions on what you can do:
61164 </para>
61165 <itemizedlist>
61166 <listitem>
61167 <para>
61168 You can deliver only as the Exim user/group. You should  explicitly use the
61169 <option>user</option> and <option>group</option> options to override routers or local transports that
61170 normally deliver as the recipient. This makes sure that configurations that
61171 work in this mode function the same way in normal mode. Any implicit or
61172 explicit specification of another user causes an error.
61173 </para>
61174 </listitem>
61175 <listitem>
61176 <para>
61177 Use of <filename>.forward</filename> files is severely restricted, such that it is usually
61178 not worthwhile to include them in the configuration.
61179 </para>
61180 </listitem>
61181 <listitem>
61182 <para>
61183 Users who wish to use <filename>.forward</filename> would have to make their home directory and
61184 the file itself accessible to the Exim user. Pipe and append-to-file entries,
61185 and their equivalents in Exim filters, cannot be used. While they could be
61186 enabled in the Exim user&#x2019;s name, that would be insecure and not very useful.
61187 </para>
61188 </listitem>
61189 <listitem>
61190 <para>
61191 Unless the local user mailboxes are all owned by the Exim user (possible in
61192 some POP3 or IMAP-only environments):
61193 </para>
61194 <orderedlist numeration="arabic">
61195 <listitem>
61196 <para>
61197 They must be owned by the Exim group and be writeable by that group. This
61198 implies you must set <option>mode</option> in the appendfile configuration, as well as the
61199 mode of the mailbox files themselves.
61200 </para>
61201 </listitem>
61202 <listitem>
61203 <para>
61204 You must set <option>no_check_owner</option>, since most or all of the files will not be
61205 owned by the Exim user.
61206 </para>
61207 </listitem>
61208 <listitem>
61209 <para>
61210 You must set <option>file_must_exist</option>, because Exim cannot set the owner correctly
61211 on a newly created mailbox when unprivileged. This also implies that new
61212 mailboxes need to be created manually.
61213 </para>
61214 </listitem>
61215 </orderedlist>
61216 </listitem>
61217 </itemizedlist>
61218 <para>
61219 These restrictions severely restrict what can be done in local deliveries.
61220 However, there are no restrictions on remote deliveries. If you are running a
61221 gateway host that does no local deliveries, setting <option>deliver_drop_privilege</option>
61222 gives more security at essentially no cost.
61223 </para>
61224 <para>
61225 If you are using the <option>mua_wrapper</option> facility (see chapter
61226 <xref linkend="CHAPnonqueueing"/>), <option>deliver_drop_privilege</option> is forced to be true.
61227 </para>
61228 </section>
61229 <section id="SECID271">
61230 <title>Delivering to local files</title>
61231 <para>
61232 Full details of the checks applied by <command>appendfile</command> before it writes to a file
61233 are given in chapter <xref linkend="CHAPappendfile"/>.
61234 </para>
61235 </section>
61236 <section id="SECID272">
61237 <title>IPv4 source routing</title>
61238 <para>
61239 <indexterm role="concept">
61240 <primary>source routing</primary>
61241 <secondary>in IP packets</secondary>
61242 </indexterm>
61243 <indexterm role="concept">
61244 <primary>IP source routing</primary>
61245 </indexterm>
61246 Many operating systems suppress IP source-routed packets in the kernel, but
61247 some cannot be made to do this, so Exim does its own check. It logs incoming
61248 IPv4 source-routed TCP calls, and then drops them. Things are all different in
61249 IPv6. No special checking is currently done.
61250 </para>
61251 </section>
61252 <section id="SECID273">
61253 <title>The VRFY, EXPN, and ETRN commands in SMTP</title>
61254 <para>
61255 Support for these SMTP commands is disabled by default. If required, they can
61256 be enabled by defining suitable ACLs.
61257 </para>
61258 </section>
61259 <section id="SECID274">
61260 <title>Privileged users</title>
61261 <para>
61262 <indexterm role="concept">
61263 <primary>trusted users</primary>
61264 </indexterm>
61265 <indexterm role="concept">
61266 <primary>admin user</primary>
61267 </indexterm>
61268 <indexterm role="concept">
61269 <primary>privileged user</primary>
61270 </indexterm>
61271 <indexterm role="concept">
61272 <primary>user</primary>
61273 <secondary>trusted</secondary>
61274 </indexterm>
61275 <indexterm role="concept">
61276 <primary>user</primary>
61277 <secondary>admin</secondary>
61278 </indexterm>
61279 Exim recognizes two sets of users with special privileges. Trusted users are
61280 able to submit new messages to Exim locally, but supply their own sender
61281 addresses and information about a sending host. For other users submitting
61282 local messages, Exim sets up the sender address from the uid, and doesn&#x2019;t
61283 permit a remote host to be specified.
61284 </para>
61285 <para>
61286 <indexterm role="option">
61287 <primary><option>-f</option></primary>
61288 </indexterm>
61289 However, an untrusted user is permitted to use the <option>-f</option> command line option
61290 in the special form <option>-f &lt;&gt;</option> to indicate that a delivery failure for the
61291 message should not cause an error report. This affects the message&#x2019;s envelope,
61292 but it does not affect the <emphasis>Sender:</emphasis> header. Untrusted users may also be
61293 permitted to use specific forms of address with the <option>-f</option> option by setting
61294 the <option>untrusted_set_sender</option> option.
61295 </para>
61296 <para>
61297 Trusted users are used to run processes that receive mail messages from some
61298 other mail domain and pass them on to Exim for delivery either locally, or over
61299 the Internet. Exim trusts a caller that is running as root, as the Exim user,
61300 as any user listed in the <option>trusted_users</option> configuration option, or under any
61301 group listed in the <option>trusted_groups</option> option.
61302 </para>
61303 <para>
61304 Admin users are permitted to do things to the messages on Exim&#x2019;s queue. They
61305 can freeze or thaw messages, cause them to be returned to their senders, remove
61306 them entirely, or modify them in various ways. In addition, admin users can run
61307 the Exim monitor and see all the information it is capable of providing, which
61308 includes the contents of files on the spool.
61309 </para>
61310 <para>
61311 <indexterm role="option">
61312 <primary><option>-M</option></primary>
61313 </indexterm>
61314 <indexterm role="option">
61315 <primary><option>-q</option></primary>
61316 </indexterm>
61317 By default, the use of the <option>-M</option> and <option>-q</option> options to cause Exim to attempt
61318 delivery of messages on its queue is restricted to admin users. This
61319 restriction can be relaxed by setting the <option>no_prod_requires_admin</option> option.
61320 Similarly, the use of <option>-bp</option> (and its variants) to list the contents of the
61321 queue is also restricted to admin users. This restriction can be relaxed by
61322 setting <option>no_queue_list_requires_admin</option>.
61323 </para>
61324 <para>
61325 Exim recognizes an admin user if the calling process is running as root or as
61326 the Exim user or if any of the groups associated with the calling process is
61327 the Exim group. It is not necessary actually to be running under the Exim
61328 group. However, if admin users who are not root or the Exim user are to access
61329 the contents of files on the spool via the Exim monitor (which runs
61330 unprivileged), Exim must be built to allow group read access to its spool
61331 files.
61332 </para>
61333 </section>
61334 <section id="SECID275">
61335 <title>Spool files</title>
61336 <para>
61337 <indexterm role="concept">
61338 <primary>spool directory</primary>
61339 <secondary>files</secondary>
61340 </indexterm>
61341 Exim&#x2019;s spool directory and everything it contains is owned by the Exim user and
61342 set to the Exim group. The mode for spool files is defined in the
61343 <filename>Local/Makefile</filename> configuration file, and defaults to 0640. This means that
61344 any user who is a member of the Exim group can access these files.
61345 </para>
61346 </section>
61347 <section id="SECID276">
61348 <title>Use of argv[0]</title>
61349 <para>
61350 Exim examines the last component of <option>argv[0]</option>, and if it matches one of a set
61351 of specific strings, Exim assumes certain options. For example, calling Exim
61352 with the last component of <option>argv[0]</option> set to <quote>rsmtp</quote> is exactly equivalent
61353 to calling it with the option <option>-bS</option>. There are no security implications in
61354 this.
61355 </para>
61356 </section>
61357 <section id="SECID277">
61358 <title>Use of %f formatting</title>
61359 <para>
61360 The only use made of <quote>%f</quote> by Exim is in formatting load average values. These
61361 are actually stored in integer variables as 1000 times the load average.
61362 Consequently, their range is limited and so therefore is the length of the
61363 converted output.
61364 </para>
61365 </section>
61366 <section id="SECID278">
61367 <title>Embedded Exim path</title>
61368 <para>
61369 Exim uses its own path name, which is embedded in the code, only when it needs
61370 to re-exec in order to regain root privilege. Therefore, it is not root when it
61371 does so. If some bug allowed the path to get overwritten, it would lead to an
61372 arbitrary program&#x2019;s being run as exim, not as root.
61373 </para>
61374 </section>
61375 <section id="SECID279">
61376 <title>Use of sprintf()</title>
61377 <para>
61378 <indexterm role="concept">
61379 <primary><function>sprintf()</function></primary>
61380 </indexterm>
61381 A large number of occurrences of <quote>sprintf</quote> in the code are actually calls to
61382 <emphasis>string_sprintf()</emphasis>, a function that returns the result in malloc&#x2019;d store.
61383 The intermediate formatting is done into a large fixed buffer by a function
61384 that runs through the format string itself, and checks the length of each
61385 conversion before performing it, thus preventing buffer overruns.
61386 </para>
61387 <para>
61388 The remaining uses of <function>sprintf()</function> happen in controlled circumstances where
61389 the output buffer is known to be sufficiently long to contain the converted
61390 string.
61391 </para>
61392 </section>
61393 <section id="SECID280">
61394 <title>Use of debug_printf() and log_write()</title>
61395 <para>
61396 Arbitrary strings are passed to both these functions, but they do their
61397 formatting by calling the function <emphasis>string_vformat()</emphasis>, which runs through
61398 the format string itself, and checks the length of each conversion.
61399 </para>
61400 </section>
61401 <section id="SECID281">
61402 <title>Use of strcat() and strcpy()</title>
61403 <para>
61404 These are used only in cases where the output buffer is known to be large
61405 enough to hold the result.
61406 <indexterm role="concept" startref="IIDsecurcon" class="endofrange"/>
61407 </para>
61408 </section>
61409 </chapter>
61410
61411 <chapter id="CHAPspool">
61412 <title>Format of spool files</title>
61413 <para>
61414 <indexterm role="concept" id="IIDforspo1" class="startofrange">
61415 <primary>format</primary>
61416 <secondary>spool files</secondary>
61417 </indexterm>
61418 <indexterm role="concept" id="IIDforspo2" class="startofrange">
61419 <primary>spool directory</primary>
61420 <secondary>format of files</secondary>
61421 </indexterm>
61422 <indexterm role="concept" id="IIDforspo3" class="startofrange">
61423 <primary>spool files</primary>
61424 <secondary>format of</secondary>
61425 </indexterm>
61426 <indexterm role="concept">
61427 <primary>spool files</primary>
61428 <secondary>editing</secondary>
61429 </indexterm>
61430 A message on Exim&#x2019;s queue consists of two files, whose names are the message id
61431 followed by -D and -H, respectively. The data portion of the message is kept in
61432 the -D file on its own. The message&#x2019;s envelope, status, and headers are all
61433 kept in the -H file, whose format is described in this chapter. Each of these
61434 two files contains the final component of its own name as its first line. This
61435 is insurance against disk crashes where the directory is lost but the files
61436 themselves are recoverable.
61437 </para>
61438 <para>
61439 Some people are tempted into editing -D files in order to modify messages. You
61440 need to be extremely careful if you do this; it is not recommended and you are
61441 on your own if you do it. Here are some of the pitfalls:
61442 </para>
61443 <itemizedlist>
61444 <listitem>
61445 <para>
61446 You must ensure that Exim does not try to deliver the message while you are
61447 fiddling with it. The safest way is to take out a write lock on the -D file,
61448 which is what Exim itself does, using <function>fcntl()</function>. If you update the file in
61449 place, the lock will be retained. If you write a new file and rename it, the
61450 lock will be lost at the instant of rename.
61451 </para>
61452 </listitem>
61453 <listitem>
61454 <para>
61455 <indexterm role="variable">
61456 <primary><varname>$body_linecount</varname></primary>
61457 </indexterm>
61458 If you change the number of lines in the file, the value of
61459 <varname>$body_linecount</varname>, which is stored in the -H file, will be incorrect. At
61460 present, this value is not used by Exim, but there is no guarantee that this
61461 will always be the case.
61462 </para>
61463 </listitem>
61464 <listitem>
61465 <para>
61466 If the message is in MIME format, you must take care not to break it.
61467 </para>
61468 </listitem>
61469 <listitem>
61470 <para>
61471 If the message is cryptographically signed, any change will invalidate the
61472 signature.
61473 </para>
61474 </listitem>
61475 </itemizedlist>
61476 <para>
61477 All in all, modifying -D files is fraught with danger.
61478 </para>
61479 <para>
61480 Files whose names end with -J may also be seen in the <filename>input</filename> directory (or
61481 its subdirectories when <option>split_spool_directory</option> is set). These are journal
61482 files, used to record addresses to which the message has been delivered during
61483 the course of a delivery attempt. If there are still undelivered recipients at
61484 the end, the -H file is updated, and the -J file is deleted. If, however, there
61485 is some kind of crash (for example, a power outage) before this happens, the -J
61486 file remains in existence. When Exim next processes the message, it notices the
61487 -J file and uses it to update the -H file before starting the next delivery
61488 attempt.
61489 </para>
61490 <section id="SECID282">
61491 <title>Format of the -H file</title>
61492 <para>
61493 <indexterm role="concept">
61494 <primary>uid (user id)</primary>
61495 <secondary>in spool file</secondary>
61496 </indexterm>
61497 <indexterm role="concept">
61498 <primary>gid (group id)</primary>
61499 <secondary>in spool file</secondary>
61500 </indexterm>
61501 The second line of the -H file contains the login name for the uid of the
61502 process that called Exim to read the message, followed by the numerical uid and
61503 gid. For a locally generated message, this is normally the user who sent the
61504 message. For a message received over TCP/IP via the daemon, it is
61505 normally the Exim user.
61506 </para>
61507 <para>
61508 The third line of the file contains the address of the message&#x2019;s sender as
61509 transmitted in the envelope, contained in angle brackets. The sender address is
61510 empty for bounce messages. For incoming SMTP mail, the sender address is given
61511 in the MAIL command. For locally generated mail, the sender address is
61512 created by Exim from the login name of the current user and the configured
61513 <option>qualify_domain</option>. However, this can be overridden by the <option>-f</option> option or a
61514 leading <quote>From&nbsp;</quote> line if the caller is trusted, or if the supplied address is
61515 <quote>&lt;&gt;</quote> or an address that matches <option>untrusted_set_senders</option>.
61516 </para>
61517 <para>
61518 The fourth line contains two numbers. The first is the time that the message
61519 was received, in the conventional Unix form &ndash; the number of seconds since the
61520 start of the epoch. The second number is a count of the number of messages
61521 warning of delayed delivery that have been sent to the sender.
61522 </para>
61523 <para>
61524 There follow a number of lines starting with a hyphen. These can appear in any
61525 order, and are omitted when not relevant:
61526 </para>
61527 <variablelist>
61528 <varlistentry>
61529 <term><option>-acl</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;&nbsp;&lt;<emphasis>length</emphasis>&gt;</term>
61530 <listitem>
61531 <para>
61532 This item is obsolete, and is not generated from Exim release 4.61 onwards;
61533 <option>-aclc</option> and <option>-aclm</option> are used instead. However, <option>-acl</option> is still
61534 recognized, to provide backward compatibility. In the old format, a line of
61535 this form is present for every ACL variable that is not empty. The number
61536 identifies the variable; the <option>acl_c</option><emphasis role="bold">x</emphasis> variables are numbered 0&ndash;9 and
61537 the <option>acl_m</option><emphasis role="bold">x</emphasis> variables are numbered 10&ndash;19. The length is the length of
61538 the data string for the variable. The string itself starts at the beginning of
61539 the next line, and is followed by a newline character. It may contain internal
61540 newlines.
61541 </para>
61542 </listitem></varlistentry>
61543 <varlistentry>
61544 <term><option>-aclc</option>&nbsp;&lt;<emphasis>rest-of-name</emphasis>&gt;&nbsp;&lt;<emphasis>length</emphasis>&gt;</term>
61545 <listitem>
61546 <para>
61547 A line of this form is present for every ACL connection variable that is
61548 defined. Note that there is a space between <option>-aclc</option> and the rest of the name.
61549 The length is the length of the data string for the variable. The string itself
61550 starts at the beginning of the next line, and is followed by a newline
61551 character. It may contain internal newlines.
61552 </para>
61553 </listitem></varlistentry>
61554 <varlistentry>
61555 <term><option>-aclm</option>&nbsp;&lt;<emphasis>rest-of-name</emphasis>&gt;&nbsp;&lt;<emphasis>length</emphasis>&gt;</term>
61556 <listitem>
61557 <para>
61558 A line of this form is present for every ACL message variable that is defined.
61559 Note that there is a space between <option>-aclm</option> and the rest of the name. The
61560 length is the length of the data string for the variable. The string itself
61561 starts at the beginning of the next line, and is followed by a newline
61562 character. It may contain internal newlines.
61563 </para>
61564 </listitem></varlistentry>
61565 <varlistentry>
61566 <term><option>-active_hostname</option>&nbsp;&lt;<emphasis>hostname</emphasis>&gt;</term>
61567 <listitem>
61568 <para>
61569 This is present if, when the message was received over SMTP, the value of
61570 <varname>$smtp_active_hostname</varname> was different to the value of <varname>$primary_hostname</varname>.
61571 </para>
61572 </listitem></varlistentry>
61573 <varlistentry>
61574 <term><option>-allow_unqualified_recipient</option></term>
61575 <listitem>
61576 <para>
61577 This is present if unqualified recipient addresses are permitted in header
61578 lines (to stop such addresses from being qualified if rewriting occurs at
61579 transport time). Local messages that were input using <option>-bnq</option> and remote
61580 messages from hosts that match <option>recipient_unqualified_hosts</option> set this flag.
61581 </para>
61582 </listitem></varlistentry>
61583 <varlistentry>
61584 <term><option>-allow_unqualified_sender</option></term>
61585 <listitem>
61586 <para>
61587 This is present if unqualified sender addresses are permitted in header lines
61588 (to stop such addresses from being qualified if rewriting occurs at transport
61589 time). Local messages that were input using <option>-bnq</option> and remote messages from
61590 hosts that match <option>sender_unqualified_hosts</option> set this flag.
61591 </para>
61592 </listitem></varlistentry>
61593 <varlistentry>
61594 <term><option>-auth_id</option>&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
61595 <listitem>
61596 <para>
61597 The id information for a message received on an authenticated SMTP connection
61598 &ndash; the value of the <varname>$authenticated_id</varname> variable.
61599 </para>
61600 </listitem></varlistentry>
61601 <varlistentry>
61602 <term><option>-auth_sender</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;</term>
61603 <listitem>
61604 <para>
61605 The address of an authenticated sender &ndash; the value of the
61606 <varname>$authenticated_sender</varname> variable.
61607 </para>
61608 </listitem></varlistentry>
61609 <varlistentry>
61610 <term><option>-body_linecount</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;</term>
61611 <listitem>
61612 <para>
61613 This records the number of lines in the body of the message, and is always
61614 present.
61615 </para>
61616 </listitem></varlistentry>
61617 <varlistentry>
61618 <term><option>-body_zerocount</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;</term>
61619 <listitem>
61620 <para>
61621 This records the number of binary zero bytes in the body of the message, and is
61622 present if the number is greater than zero.
61623 </para>
61624 </listitem></varlistentry>
61625 <varlistentry>
61626 <term><option>-deliver_firsttime</option></term>
61627 <listitem>
61628 <para>
61629 This is written when a new message is first added to the spool. When the spool
61630 file is updated after a deferral, it is omitted.
61631 </para>
61632 </listitem></varlistentry>
61633 <varlistentry>
61634 <term><option>-frozen</option>&nbsp;&lt;<emphasis>time</emphasis>&gt;</term>
61635 <listitem>
61636 <para>
61637 <indexterm role="concept">
61638 <primary>frozen messages</primary>
61639 <secondary>spool data</secondary>
61640 </indexterm>
61641 The message is frozen, and the freezing happened at &lt;<emphasis>time</emphasis>&gt;.
61642 </para>
61643 </listitem></varlistentry>
61644 <varlistentry>
61645 <term><option>-helo_name</option>&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
61646 <listitem>
61647 <para>
61648 This records the host name as specified by a remote host in a HELO or EHLO
61649 command.
61650 </para>
61651 </listitem></varlistentry>
61652 <varlistentry>
61653 <term><option>-host_address</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;.&lt;<emphasis>port</emphasis>&gt;</term>
61654 <listitem>
61655 <para>
61656 This records the IP address of the host from which the message was received and
61657 the remote port number that was used. It is omitted for locally generated
61658 messages.
61659 </para>
61660 </listitem></varlistentry>
61661 <varlistentry>
61662 <term><option>-host_auth</option>&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
61663 <listitem>
61664 <para>
61665 If the message was received on an authenticated SMTP connection, this records
61666 the name of the authenticator &ndash; the value of the
61667 <varname>$sender_host_authenticated</varname> variable.
61668 </para>
61669 </listitem></varlistentry>
61670 <varlistentry>
61671 <term><option>-host_lookup_failed</option></term>
61672 <listitem>
61673 <para>
61674 This is present if an attempt to look up the sending host&#x2019;s name from its IP
61675 address failed. It corresponds to the <varname>$host_lookup_failed</varname> variable.
61676 </para>
61677 </listitem></varlistentry>
61678 <varlistentry>
61679 <term><option>-host_name</option>&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
61680 <listitem>
61681 <para>
61682 <indexterm role="concept">
61683 <primary>reverse DNS lookup</primary>
61684 </indexterm>
61685 <indexterm role="concept">
61686 <primary>DNS</primary>
61687 <secondary>reverse lookup</secondary>
61688 </indexterm>
61689 This records the name of the remote host from which the message was received,
61690 if the host name was looked up from the IP address when the message was being
61691 received. It is not present if no reverse lookup was done.
61692 </para>
61693 </listitem></varlistentry>
61694 <varlistentry>
61695 <term><option>-ident</option>&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
61696 <listitem>
61697 <para>
61698 For locally submitted messages, this records the login of the originating user,
61699 unless it was a trusted user and the <option>-oMt</option> option was used to specify an
61700 ident value. For messages received over TCP/IP, this records the ident string
61701 supplied by the remote host, if any.
61702 </para>
61703 </listitem></varlistentry>
61704 <varlistentry>
61705 <term><option>-interface_address</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;.&lt;<emphasis>port</emphasis>&gt;</term>
61706 <listitem>
61707 <para>
61708 This records the IP address of the local interface and the port number through
61709 which a message was received from a remote host. It is omitted for locally
61710 generated messages.
61711 </para>
61712 </listitem></varlistentry>
61713 <varlistentry>
61714 <term><option>-local</option></term>
61715 <listitem>
61716 <para>
61717 The message is from a local sender.
61718 </para>
61719 </listitem></varlistentry>
61720 <varlistentry>
61721 <term><option>-localerror</option></term>
61722 <listitem>
61723 <para>
61724 The message is a locally-generated bounce message.
61725 </para>
61726 </listitem></varlistentry>
61727 <varlistentry>
61728 <term><option>-local_scan</option>&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
61729 <listitem>
61730 <para>
61731 This records the data string that was returned by the <function>local_scan()</function> function
61732 when the message was received &ndash; the value of the <varname>$local_scan_data</varname>
61733 variable. It is omitted if no data was returned.
61734 </para>
61735 </listitem></varlistentry>
61736 <varlistentry>
61737 <term><option>-manual_thaw</option></term>
61738 <listitem>
61739 <para>
61740 The message was frozen but has been thawed manually, that is, by an explicit
61741 Exim command rather than via the auto-thaw process.
61742 </para>
61743 </listitem></varlistentry>
61744 <varlistentry>
61745 <term><option>-N</option></term>
61746 <listitem>
61747 <para>
61748 A testing delivery process was started using the <option>-N</option> option to suppress any
61749 actual deliveries, but delivery was deferred. At any further delivery attempts,
61750 <option>-N</option> is assumed.
61751 </para>
61752 </listitem></varlistentry>
61753 <varlistentry>
61754 <term><option>-received_protocol</option></term>
61755 <listitem>
61756 <para>
61757 This records the value of the <varname>$received_protocol</varname> variable, which contains
61758 the name of the protocol by which the message was received.
61759 </para>
61760 </listitem></varlistentry>
61761 <varlistentry>
61762 <term><option>-sender_set_untrusted</option></term>
61763 <listitem>
61764 <para>
61765 The envelope sender of this message was set by an untrusted local caller (used
61766 to ensure that the caller is displayed in queue listings).
61767 </para>
61768 </listitem></varlistentry>
61769 <varlistentry>
61770 <term><option>-spam_score_int</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;</term>
61771 <listitem>
61772 <para>
61773 If a message was scanned by SpamAssassin, this is present. It records the value
61774 of <varname>$spam_score_int</varname>.
61775 </para>
61776 </listitem></varlistentry>
61777 <varlistentry>
61778 <term><option>-tls_certificate_verified</option></term>
61779 <listitem>
61780 <para>
61781 A TLS certificate was received from the client that sent this message, and the
61782 certificate was verified by the server.
61783 </para>
61784 </listitem></varlistentry>
61785 <varlistentry>
61786 <term><option>-tls_cipher</option>&nbsp;&lt;<emphasis>cipher name</emphasis>&gt;</term>
61787 <listitem>
61788 <para>
61789 When the message was received over an encrypted connection, this records the
61790 name of the cipher suite that was used.
61791 </para>
61792 </listitem></varlistentry>
61793 <varlistentry>
61794 <term><option>-tls_peerdn</option>&nbsp;&lt;<emphasis>peer DN</emphasis>&gt;</term>
61795 <listitem>
61796 <para>
61797 When the message was received over an encrypted connection, and a certificate
61798 was received from the client, this records the Distinguished Name from that
61799 certificate.
61800 </para>
61801 </listitem></varlistentry>
61802 </variablelist>
61803 <para>
61804 Following the options there is a list of those addresses to which the message
61805 is not to be delivered. This set of addresses is initialized from the command
61806 line when the <option>-t</option> option is used and <option>extract_addresses_remove_arguments</option>
61807 is set; otherwise it starts out empty. Whenever a successful delivery is made,
61808 the address is added to this set. The addresses are kept internally as a
61809 balanced binary tree, and it is a representation of that tree which is written
61810 to the spool file. If an address is expanded via an alias or forward file, the
61811 original address is added to the tree when deliveries to all its child
61812 addresses are complete.
61813 </para>
61814 <para>
61815 If the tree is empty, there is a single line in the spool file containing just
61816 the text <quote>XX</quote>. Otherwise, each line consists of two letters, which are either
61817 Y or N, followed by an address. The address is the value for the node of the
61818 tree, and the letters indicate whether the node has a left branch and/or a
61819 right branch attached to it, respectively. If branches exist, they immediately
61820 follow. Here is an example of a three-node tree:
61821 </para>
61822 <literallayout class="monospaced">
61823 YY darcy@austen.fict.example
61824 NN alice@wonderland.fict.example
61825 NN editor@thesaurus.ref.example
61826 </literallayout>
61827 <para>
61828 After the non-recipients tree, there is a list of the message&#x2019;s recipients.
61829 This is a simple list, preceded by a count. It includes all the original
61830 recipients of the message, including those to whom the message has already been
61831 delivered. In the simplest case, the list contains one address per line. For
61832 example:
61833 </para>
61834 <literallayout class="monospaced">
61835 4
61836 editor@thesaurus.ref.example
61837 darcy@austen.fict.example
61838 rdo@foundation
61839 alice@wonderland.fict.example
61840 </literallayout>
61841 <para>
61842 However, when a child address has been added to the top-level addresses as a
61843 result of the use of the <option>one_time</option> option on a <command>redirect</command> router, each
61844 line is of the following form:
61845 </para>
61846 <literallayout>
61847 &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;
61848 </literallayout>
61849 <para>
61850 The 01 flag bit indicates the presence of the three other fields that follow
61851 the top-level address. Other bits may be used in future to support additional
61852 fields. The &lt;<emphasis>parent number</emphasis>&gt; is the offset in the recipients list of the
61853 original parent of the <quote>one time</quote> address. The first two fields are the
61854 envelope sender that is associated with this address and its length. If the
61855 length is zero, there is no special envelope sender (there are then two space
61856 characters in the line). A non-empty field can arise from a <command>redirect</command> router
61857 that has an <option>errors_to</option> setting.
61858 </para>
61859 <para>
61860 A blank line separates the envelope and status information from the headers
61861 which follow. A header may occupy several lines of the file, and to save effort
61862 when reading it in, each header is preceded by a number and an identifying
61863 character. The number is the number of characters in the header, including any
61864 embedded newlines and the terminating newline. The character is one of the
61865 following:
61866 </para>
61867 <informaltable frame="none">
61868 <tgroup cols="2" colsep="0" rowsep="0">
61869 <colspec colwidth="50pt" align="left"/>
61870 <colspec colwidth="254pt" align="left"/>
61871 <tbody>
61872 <row>
61873 <entry>&lt;<emphasis>blank</emphasis>&gt;</entry>
61874 <entry>header in which Exim has no special interest</entry>
61875 </row>
61876 <row>
61877 <entry><literal>B</literal></entry>
61878 <entry><emphasis>Bcc:</emphasis> header</entry>
61879 </row>
61880 <row>
61881 <entry><literal>C</literal></entry>
61882 <entry><emphasis>Cc:</emphasis> header</entry>
61883 </row>
61884 <row>
61885 <entry><literal>F</literal></entry>
61886 <entry><emphasis>From:</emphasis> header</entry>
61887 </row>
61888 <row>
61889 <entry><literal>I</literal></entry>
61890 <entry><emphasis>Message-id:</emphasis> header</entry>
61891 </row>
61892 <row>
61893 <entry><literal>P</literal></entry>
61894 <entry><emphasis>Received:</emphasis> header &ndash; P for <quote>postmark</quote></entry>
61895 </row>
61896 <row>
61897 <entry><literal>R</literal></entry>
61898 <entry><emphasis>Reply-To:</emphasis> header</entry>
61899 </row>
61900 <row>
61901 <entry><literal>S</literal></entry>
61902 <entry><emphasis>Sender:</emphasis> header</entry>
61903 </row>
61904 <row>
61905 <entry><literal>T</literal></entry>
61906 <entry><emphasis>To:</emphasis> header</entry>
61907 </row>
61908 <row>
61909 <entry><literal>*</literal></entry>
61910 <entry>replaced or deleted header</entry>
61911 </row>
61912 </tbody>
61913 </tgroup>
61914 </informaltable>
61915 <para>
61916 Deleted or replaced (rewritten) headers remain in the spool file for debugging
61917 purposes. They are not transmitted when the message is delivered. Here is a
61918 typical set of headers:
61919 </para>
61920 <literallayout class="monospaced">
61921 111P Received: by hobbit.fict.example with local (Exim 4.00)
61922 id 14y9EI-00026G-00; Fri, 11 May 2001 10:28:59 +0100
61923 049  Message-Id: &lt;E14y9EI-00026G-00@hobbit.fict.example&gt;
61924 038* X-rewrote-sender: bb@hobbit.fict.example
61925 042* From: Bilbo Baggins &lt;bb@hobbit.fict.example&gt;
61926 049F From: Bilbo Baggins &lt;B.Baggins@hobbit.fict.example&gt;
61927 099* To: alice@wonderland.fict.example, rdo@foundation,
61928 darcy@austen.fict.example, editor@thesaurus.ref.example
61929 104T To: alice@wonderland.fict.example, rdo@foundation.example,
61930 darcy@austen.fict.example, editor@thesaurus.ref.example
61931 038  Date: Fri, 11 May 2001 10:28:59 +0100
61932 </literallayout>
61933 <para>
61934 The asterisked headers indicate that the envelope sender, <emphasis>From:</emphasis> header, and
61935 <emphasis>To:</emphasis> header have been rewritten, the last one because routing expanded the
61936 unqualified domain <emphasis>foundation</emphasis>.
61937 <indexterm role="concept" startref="IIDforspo1" class="endofrange"/>
61938 <indexterm role="concept" startref="IIDforspo2" class="endofrange"/>
61939 <indexterm role="concept" startref="IIDforspo3" class="endofrange"/>
61940 </para>
61941 </section>
61942 </chapter>
61943
61944 <chapter id="CHID12">
61945 <title>Support for DKIM (DomainKeys Identified Mail) - RFC4871</title>
61946 <titleabbrev>DKIM Support</titleabbrev>
61947 <para>
61948 <indexterm role="concept">
61949 <primary>DKIM</primary>
61950 </indexterm>
61951 </para>
61952 <para>
61953 Since version 4.70, DKIM support is compiled into Exim by default. It can be
61954 disabled by setting DISABLE_DKIM=yes in Local/Makefile.
61955 </para>
61956 <para>
61957 Exim&#x2019;s DKIM implementation allows to
61958 </para>
61959 <orderedlist numeration="arabic">
61960 <listitem>
61961 <para>
61962 Sign outgoing messages: This function is implemented in the SMTP transport.
61963 It can co-exist with all other Exim features, including transport filters.
61964 </para>
61965 </listitem>
61966 <listitem>
61967 <para>
61968 Verify signatures in incoming messages: This is implemented by an additional
61969 ACL (acl_smtp_dkim), which can be called several times per message, with
61970 different signature contexts.
61971 </para>
61972 </listitem>
61973 </orderedlist>
61974 <para>
61975 In typical Exim style, the verification implementation does not include any
61976 default "policy". Instead it enables you to build your own policy using
61977 Exim&#x2019;s standard controls.
61978 </para>
61979 <para>
61980 Please note that verification of DKIM signatures in incoming mail is turned
61981 on by default for logging purposes. For each signature in incoming email,
61982 exim will log a line displaying the most important signature details, and the
61983 signature status. Here is an example:
61984 </para>
61985 <literallayout class="monospaced">
61986 2009-09-09 10:22:28 1MlIRf-0003LU-U3 DKIM: d=facebookmail.com s=q1-2009b c=relaxed/relaxed a=rsa-sha1 i=@facebookmail.com t=1252484542 [verification succeeded]
61987 </literallayout>
61988 <para>
61989 You might want to turn off DKIM verification processing entirely for internal
61990 or relay mail sources. To do that, set the <option>dkim_disable_verify</option> ACL
61991 control modifier. This should typically be done in the RCPT ACL, at points
61992 where you accept mail from relay sources (internal hosts or authenticated
61993 senders).
61994 </para>
61995 <section id="SECID513">
61996 <title>Signing outgoing messages</title>
61997 <para>
61998 <indexterm role="concept">
61999 <primary>DKIM</primary>
62000 <secondary>signing</secondary>
62001 </indexterm>
62002 </para>
62003 <para>
62004 Signing is implemented by setting private options on the SMTP transport.
62005 These options take (expandable) strings as arguments.
62006 </para>
62007 <para>
62008 <indexterm role="option">
62009 <primary><option>dkim_domain</option></primary>
62010 </indexterm>
62011 </para>
62012 <informaltable frame="all">
62013 <tgroup cols="4" colsep="0" rowsep="0">
62014 <colspec colwidth="8*" align="left"/>
62015 <colspec colwidth="6*" align="center"/>
62016 <colspec colwidth="6*" align="center"/>
62017 <colspec colwidth="6*" align="right"/>
62018 <tbody>
62019 <row>
62020 <entry><option>dkim_domain</option></entry>
62021 <entry>Use: <emphasis>smtp</emphasis></entry>
62022 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
62023 <entry>Default: <emphasis>unset</emphasis></entry>
62024 </row>
62025 </tbody>
62026 </tgroup>
62027 </informaltable>
62028 <para>
62029 MANDATORY:
62030 The domain you want to sign with. The result of this expanded
62031 option is put into the <option>$dkim_domain</option> expansion variable.
62032 </para>
62033 <para>
62034 <indexterm role="option">
62035 <primary><option>dkim_selector</option></primary>
62036 </indexterm>
62037 </para>
62038 <informaltable frame="all">
62039 <tgroup cols="4" colsep="0" rowsep="0">
62040 <colspec colwidth="8*" align="left"/>
62041 <colspec colwidth="6*" align="center"/>
62042 <colspec colwidth="6*" align="center"/>
62043 <colspec colwidth="6*" align="right"/>
62044 <tbody>
62045 <row>
62046 <entry><option>dkim_selector</option></entry>
62047 <entry>Use: <emphasis>smtp</emphasis></entry>
62048 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
62049 <entry>Default: <emphasis>unset</emphasis></entry>
62050 </row>
62051 </tbody>
62052 </tgroup>
62053 </informaltable>
62054 <para>
62055 MANDATORY:
62056 This sets the key selector string. You can use the <option>$dkim_domain</option> expansion
62057 variable to look up a matching selector. The result is put in the expansion
62058 variable <option>$dkim_selector</option> which should be used in the <option>dkim_private_key</option>
62059 option along with <option>$dkim_domain</option>.
62060 </para>
62061 <para>
62062 <indexterm role="option">
62063 <primary><option>dkim_private_key</option></primary>
62064 </indexterm>
62065 </para>
62066 <informaltable frame="all">
62067 <tgroup cols="4" colsep="0" rowsep="0">
62068 <colspec colwidth="8*" align="left"/>
62069 <colspec colwidth="6*" align="center"/>
62070 <colspec colwidth="6*" align="center"/>
62071 <colspec colwidth="6*" align="right"/>
62072 <tbody>
62073 <row>
62074 <entry><option>dkim_private_key</option></entry>
62075 <entry>Use: <emphasis>smtp</emphasis></entry>
62076 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
62077 <entry>Default: <emphasis>unset</emphasis></entry>
62078 </row>
62079 </tbody>
62080 </tgroup>
62081 </informaltable>
62082 <para>
62083 MANDATORY:
62084 This sets the private key to use. You can use the <option>$dkim_domain</option> and
62085 <option>$dkim_selector</option> expansion variables to determine the private key to use.
62086 The result can either
62087 </para>
62088 <itemizedlist>
62089 <listitem>
62090 <para>
62091 be a valid RSA private key in ASCII armor, including line breaks.
62092 </para>
62093 </listitem>
62094 <listitem>
62095 <para>
62096 start with a slash, in which case it is treated as a file that contains
62097 the private key.
62098 </para>
62099 </listitem>
62100 <listitem>
62101 <para>
62102 be "0", "false" or the empty string, in which case the message will not
62103 be signed. This case will not result in an error, even if <option>dkim_strict</option>
62104 is set.
62105 </para>
62106 </listitem>
62107 </itemizedlist>
62108 <para>
62109 <indexterm role="option">
62110 <primary><option>dkim_canon</option></primary>
62111 </indexterm>
62112 </para>
62113 <informaltable frame="all">
62114 <tgroup cols="4" colsep="0" rowsep="0">
62115 <colspec colwidth="8*" align="left"/>
62116 <colspec colwidth="6*" align="center"/>
62117 <colspec colwidth="6*" align="center"/>
62118 <colspec colwidth="6*" align="right"/>
62119 <tbody>
62120 <row>
62121 <entry><option>dkim_canon</option></entry>
62122 <entry>Use: <emphasis>smtp</emphasis></entry>
62123 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
62124 <entry>Default: <emphasis>unset</emphasis></entry>
62125 </row>
62126 </tbody>
62127 </tgroup>
62128 </informaltable>
62129 <para>
62130 OPTIONAL:
62131 This option sets the canonicalization method used when signing a message.
62132 The DKIM RFC currently supports two methods: "simple" and "relaxed".
62133 The option defaults to "relaxed" when unset. Note: the current implementation
62134 only supports using the same canonicalization method for both headers and body.
62135 </para>
62136 <para>
62137 <indexterm role="option">
62138 <primary><option>dkim_strict</option></primary>
62139 </indexterm>
62140 </para>
62141 <informaltable frame="all">
62142 <tgroup cols="4" colsep="0" rowsep="0">
62143 <colspec colwidth="8*" align="left"/>
62144 <colspec colwidth="6*" align="center"/>
62145 <colspec colwidth="6*" align="center"/>
62146 <colspec colwidth="6*" align="right"/>
62147 <tbody>
62148 <row>
62149 <entry><option>dkim_strict</option></entry>
62150 <entry>Use: <emphasis>smtp</emphasis></entry>
62151 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
62152 <entry>Default: <emphasis>unset</emphasis></entry>
62153 </row>
62154 </tbody>
62155 </tgroup>
62156 </informaltable>
62157 <para>
62158 OPTIONAL:
62159 This  option  defines  how  Exim  behaves  when  signing a message that
62160 should be signed fails for some reason.  When the expansion evaluates to
62161 either "1" or "true", Exim will defer. Otherwise Exim will send the message
62162 unsigned. You can use the <option>$dkim_domain</option> and <option>$dkim_selector</option> expansion
62163 variables here.
62164 </para>
62165 <para>
62166 <indexterm role="option">
62167 <primary><option>dkim_sign_headers</option></primary>
62168 </indexterm>
62169 </para>
62170 <informaltable frame="all">
62171 <tgroup cols="4" colsep="0" rowsep="0">
62172 <colspec colwidth="8*" align="left"/>
62173 <colspec colwidth="6*" align="center"/>
62174 <colspec colwidth="6*" align="center"/>
62175 <colspec colwidth="6*" align="right"/>
62176 <tbody>
62177 <row>
62178 <entry><option>dkim_sign_headers</option></entry>
62179 <entry>Use: <emphasis>smtp</emphasis></entry>
62180 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
62181 <entry>Default: <emphasis>unset</emphasis></entry>
62182 </row>
62183 </tbody>
62184 </tgroup>
62185 </informaltable>
62186 <para>
62187 OPTIONAL:
62188 When set, this option must expand to (or be specified as) a colon-separated
62189 list of header names. Headers with these names will be included in the message
62190 signature. When unspecified, the header names recommended in RFC4871 will be
62191 used.
62192 </para>
62193 </section>
62194 <section id="SECID514">
62195 <title>Verifying DKIM signatures in incoming mail</title>
62196 <para>
62197 <indexterm role="concept">
62198 <primary>DKIM</primary>
62199 <secondary>verification</secondary>
62200 </indexterm>
62201 </para>
62202 <para>
62203 Verification of DKIM signatures in incoming email is implemented via the
62204 <option>acl_smtp_dkim</option> ACL. By default, this ACL is called once for each
62205 syntactically(!) correct signature in the incoming message.
62206 </para>
62207 <para>
62208 To evaluate the signature in the ACL a large number of expansion variables
62209 containing the signature status and its details are set up during the
62210 runtime of the ACL.
62211 </para>
62212 <para>
62213 Calling the ACL only for existing signatures is not sufficient to build
62214 more advanced policies. For that reason, the global option
62215 <option>dkim_verify_signers</option>, and a global expansion variable
62216 <option>$dkim_signers</option> exist.
62217 </para>
62218 <para>
62219 The global option <option>dkim_verify_signers</option> can be set to a colon-separated
62220 list of DKIM domains or identities for which the ACL <option>acl_smtp_dkim</option> is
62221 called. It is expanded when the message has been received. At this point,
62222 the expansion variable <option>$dkim_signers</option> already contains a colon-separated
62223 list of signer domains and identities for the message. When
62224 <option>dkim_verify_signers</option> is not specified in the main configuration,
62225 it defaults as:
62226 </para>
62227 <literallayout class="monospaced">
62228 dkim_verify_signers = $dkim_signers
62229 </literallayout>
62230 <para>
62231 This leads to the default behaviour of calling <option>acl_smtp_dkim</option> for each
62232 DKIM signature in the message. Current DKIM verifiers may want to explicitly
62233 call the ACL for known domains or identities. This would be achieved as follows:
62234 </para>
62235 <literallayout class="monospaced">
62236 dkim_verify_signers = paypal.com:ebay.com:$dkim_signers
62237 </literallayout>
62238 <para>
62239 This would result in <option>acl_smtp_dkim</option> always being called for "paypal.com"
62240 and "ebay.com", plus all domains and identities that have signatures in the message.
62241 You can also be more creative in constructing your policy. For example:
62242 </para>
62243 <literallayout class="monospaced">
62244 dkim_verify_signers = $sender_address_domain:$dkim_signers
62245 </literallayout>
62246 <para>
62247 If a domain or identity is listed several times in the (expanded) value of
62248 <option>dkim_verify_signers</option>, the ACL is only called once for that domain or identity.
62249 </para>
62250 <para>
62251 Inside the <option>acl_smtp_dkim</option>, the following expansion variables are
62252 available (from most to least important):
62253 </para>
62254 <variablelist>
62255 <varlistentry>
62256 <term><option>$dkim_cur_signer</option></term>
62257 <listitem>
62258 <para>
62259 The signer that is being evaluated in this ACL run. This can be a domain or
62260 an identity. This is one of the list items from the expanded main option
62261 <option>dkim_verify_signers</option> (see above).
62262 </para>
62263 </listitem></varlistentry>
62264 <varlistentry>
62265 <term><option>$dkim_verify_status</option></term>
62266 <listitem>
62267 <para>
62268 A string describing the general status of the signature. One of
62269 </para>
62270 <itemizedlist>
62271 <listitem>
62272 <para>
62273 <option>none</option>: There is no signature in the message for the current domain or
62274 identity (as reflected by <option>$dkim_cur_signer</option>).
62275 </para>
62276 </listitem>
62277 <listitem>
62278 <para>
62279 <option>invalid</option>: The signature could not be verified due to a processing error.
62280 More detail is available in <option>$dkim_verify_reason</option>.
62281 </para>
62282 </listitem>
62283 <listitem>
62284 <para>
62285 <option>fail</option>: Verification of the signature failed.  More detail is
62286 available in <option>$dkim_verify_reason</option>.
62287 </para>
62288 </listitem>
62289 <listitem>
62290 <para>
62291 <option>pass</option>: The signature passed verification. It is valid.
62292 </para>
62293 </listitem>
62294 </itemizedlist>
62295 </listitem></varlistentry>
62296 <varlistentry>
62297 <term><option>$dkim_verify_reason</option></term>
62298 <listitem>
62299 <para>
62300 A string giving a litte bit more detail when <option>$dkim_verify_status</option> is either
62301 "fail" or "invalid". One of
62302 </para>
62303 <itemizedlist>
62304 <listitem>
62305 <para>
62306 <option>pubkey_unavailable</option> (when <option>$dkim_verify_status</option>="invalid"): The public
62307 key for the domain could not be retrieved. This may be a temporary problem.
62308 </para>
62309 </listitem>
62310 <listitem>
62311 <para>
62312 <option>pubkey_syntax</option> (when <option>$dkim_verify_status</option>="invalid"): The public key
62313 record for the domain is syntactically invalid.
62314 </para>
62315 </listitem>
62316 <listitem>
62317 <para>
62318 <option>bodyhash_mismatch</option> (when <option>$dkim_verify_status</option>="fail"): The calculated
62319 body hash does not match the one specified in the signature header. This
62320 means that the message body was modified in transit.
62321 </para>
62322 </listitem>
62323 <listitem>
62324 <para>
62325 <option>signature_incorrect</option> (when <option>$dkim_verify_status</option>="fail"): The signature
62326 could not be verified. This may mean that headers were modified,
62327 re-written or otherwise changed in a way which is incompatible with
62328 DKIM verification. It may of course also mean that the signature is forged.
62329 </para>
62330 </listitem>
62331 </itemizedlist>
62332 </listitem></varlistentry>
62333 <varlistentry>
62334 <term><option>$dkim_domain</option></term>
62335 <listitem>
62336 <para>
62337 The signing domain. IMPORTANT: This variable is only populated if there is
62338 an actual signature in the message for the current domain or identity (as
62339 reflected by <option>$dkim_cur_signer</option>).
62340 </para>
62341 </listitem></varlistentry>
62342 <varlistentry>
62343 <term><option>$dkim_identity</option></term>
62344 <listitem>
62345 <para>
62346 The signing identity, if present. IMPORTANT: This variable is only populated
62347 if there is an actual signature in the message for the current domain or
62348 identity (as reflected by <option>$dkim_cur_signer</option>).
62349 </para>
62350 </listitem></varlistentry>
62351 <varlistentry>
62352 <term><option>$dkim_selector</option></term>
62353 <listitem>
62354 <para>
62355 The key record selector string.
62356 </para>
62357 </listitem></varlistentry>
62358 <varlistentry>
62359 <term><option>$dkim_algo</option></term>
62360 <listitem>
62361 <para>
62362 The algorithm used. One of &#x2019;rsa-sha1&#x2019; or &#x2019;rsa-sha256&#x2019;.
62363 </para>
62364 </listitem></varlistentry>
62365 <varlistentry>
62366 <term><option>$dkim_canon_body</option></term>
62367 <listitem>
62368 <para>
62369 The body canonicalization method. One of &#x2019;relaxed&#x2019; or &#x2019;simple&#x2019;.
62370 </para>
62371 </listitem></varlistentry>
62372 <varlistentry>
62373 <term><option>dkim_canon_headers</option></term>
62374 <listitem>
62375 <para>
62376 The header canonicalization method. One of &#x2019;relaxed&#x2019; or &#x2019;simple&#x2019;.
62377 </para>
62378 </listitem></varlistentry>
62379 <varlistentry>
62380 <term><option>$dkim_copiedheaders</option></term>
62381 <listitem>
62382 <para>
62383 A transcript of headers and their values which are included in the signature
62384 (copied from the &#x2019;z=&#x2019; tag of the signature).
62385 </para>
62386 </listitem></varlistentry>
62387 <varlistentry>
62388 <term><option>$dkim_bodylength</option></term>
62389 <listitem>
62390 <para>
62391 The number of signed body bytes. If zero ("0"), the body is unsigned. If no
62392 limit was set by the signer, "9999999999999" is returned. This makes sure
62393 that this variable always expands to an integer value.
62394 </para>
62395 </listitem></varlistentry>
62396 <varlistentry>
62397 <term><option>$dkim_created</option></term>
62398 <listitem>
62399 <para>
62400 UNIX timestamp reflecting the date and time when the signature was created.
62401 When this was not specified by the signer, "0" is returned.
62402 </para>
62403 </listitem></varlistentry>
62404 <varlistentry>
62405 <term><option>$dkim_expires</option></term>
62406 <listitem>
62407 <para>
62408 UNIX timestamp reflecting the date and time when the signer wants the
62409 signature to be treated as "expired". When this was not specified by the
62410 signer, "9999999999999" is returned. This makes it possible to do useful
62411 integer size comparisons against this value.
62412 </para>
62413 </listitem></varlistentry>
62414 <varlistentry>
62415 <term><option>$dkim_headernames</option></term>
62416 <listitem>
62417 <para>
62418 A colon-separated list of names of headers included in the signature.
62419 </para>
62420 </listitem></varlistentry>
62421 <varlistentry>
62422 <term><option>$dkim_key_testing</option></term>
62423 <listitem>
62424 <para>
62425 "1" if the key record has the "testing" flag set, "0" if not.
62426 </para>
62427 </listitem></varlistentry>
62428 <varlistentry>
62429 <term><option>$dkim_key_nosubdomaining</option></term>
62430 <listitem>
62431 <para>
62432 "1" if the key record forbids subdomaining, "0" otherwise.
62433 </para>
62434 </listitem></varlistentry>
62435 <varlistentry>
62436 <term><option>$dkim_key_srvtype</option></term>
62437 <listitem>
62438 <para>
62439 Service type (tag s=) from the key record. Defaults to "*" if not specified
62440 in the key record.
62441 </para>
62442 </listitem></varlistentry>
62443 <varlistentry>
62444 <term><option>$dkim_key_granularity</option></term>
62445 <listitem>
62446 <para>
62447 Key granularity (tag g=) from the key record. Defaults to "*" if not specified
62448 in the key record.
62449 </para>
62450 </listitem></varlistentry>
62451 <varlistentry>
62452 <term><option>$dkim_key_notes</option></term>
62453 <listitem>
62454 <para>
62455 Notes from the key record (tag n=).
62456 </para>
62457 </listitem></varlistentry>
62458 </variablelist>
62459 <para>
62460 In addition, two ACL conditions are provided:
62461 </para>
62462 <variablelist>
62463 <varlistentry>
62464 <term><option>dkim_signers</option></term>
62465 <listitem>
62466 <para>
62467 ACL condition that checks a colon-separated list of domains or identities
62468 for a match against the domain or identity that the ACL is currently verifying
62469 (reflected by <option>$dkim_cur_signer</option>). This is typically used to restrict an ACL
62470 verb to a group of domains or identities. For example:
62471 </para>
62472 <literallayout class="monospaced">
62473 # Warn when message apparently from GMail has no signature at all
62474 warn log_message = GMail sender without DKIM signature
62475      sender_domains = gmail.com
62476      dkim_signers = gmail.com
62477      dkim_status = none
62478 </literallayout>
62479 </listitem></varlistentry>
62480 <varlistentry>
62481 <term><option>dkim_status</option></term>
62482 <listitem>
62483 <para>
62484 ACL condition that checks a colon-separated list of possible DKIM verification
62485 results agains the actual result of verification. This is typically used
62486 to restrict an ACL verb to a list of verification outcomes, like:
62487 </para>
62488 <literallayout class="monospaced">
62489 deny message = Message from Paypal with invalid or missing signature
62490      sender_domains = paypal.com:paypal.de
62491      dkim_signers = paypal.com:paypal.de
62492      dkim_status = none:invalid:fail
62493 </literallayout>
62494 <para>
62495 The possible status keywords are: &#x2019;none&#x2019;,&#x2019;invalid&#x2019;,&#x2019;fail&#x2019; and &#x2019;pass&#x2019;. Please
62496 see the documentation of the <option>$dkim_verify_status</option> expansion variable above
62497 for more information of what they mean.
62498 </para>
62499 </listitem></varlistentry>
62500 </variablelist>
62501 </section>
62502 </chapter>
62503
62504 <chapter id="CHID13">
62505 <title>Adding new drivers or lookup types</title>
62506 <titleabbrev>Adding drivers or lookups</titleabbrev>
62507 <para>
62508 <indexterm role="concept">
62509 <primary>adding drivers</primary>
62510 </indexterm>
62511 <indexterm role="concept">
62512 <primary>new drivers, adding</primary>
62513 </indexterm>
62514 <indexterm role="concept">
62515 <primary>drivers</primary>
62516 <secondary>adding new</secondary>
62517 </indexterm>
62518 The following actions have to be taken in order to add a new router, transport,
62519 authenticator, or lookup type to Exim:
62520 </para>
62521 <orderedlist numeration="arabic">
62522 <listitem>
62523 <para>
62524 Choose a name for the driver or lookup type that does not conflict with any
62525 existing name; I will use <quote>newdriver</quote> in what follows.
62526 </para>
62527 </listitem>
62528 <listitem>
62529 <para>
62530 Add to <filename>src/EDITME</filename> the line:
62531 </para>
62532 <literallayout>
62533 &lt;<emphasis>type</emphasis>&gt;<literal>_NEWDRIVER=yes</literal>
62534 </literallayout>
62535 <para>
62536 where &lt;<emphasis>type</emphasis>&gt; is ROUTER, TRANSPORT, AUTH, or LOOKUP. If the
62537 code is not to be included in the binary by default, comment this line out. You
62538 should also add any relevant comments about the driver or lookup type.
62539 </para>
62540 </listitem>
62541 <listitem>
62542 <para>
62543 Add to <filename>src/config.h.defaults</filename> the line:
62544 </para>
62545 <literallayout class="monospaced">
62546 #define &lt;type&gt;_NEWDRIVER
62547 </literallayout>
62548 </listitem>
62549 <listitem>
62550 <para>
62551 Edit <filename>src/drtables.c</filename>, adding conditional code to pull in the private header
62552 and create a table entry as is done for all the other drivers and lookup types.
62553 </para>
62554 </listitem>
62555 <listitem>
62556 <para>
62557 Edit <filename>Makefile</filename> in the appropriate sub-directory (<filename>src/routers</filename>,
62558 <filename>src/transports</filename>, <filename>src/auths</filename>, or <filename>src/lookups</filename>); add a line for the new
62559 driver or lookup type and add it to the definition of OBJ.
62560 </para>
62561 </listitem>
62562 <listitem>
62563 <para>
62564 Create <filename>newdriver.h</filename> and <filename>newdriver.c</filename> in the appropriate sub-directory of
62565 <filename>src</filename>.
62566 </para>
62567 </listitem>
62568 <listitem>
62569 <para>
62570 Edit <filename>scripts/MakeLinks</filename> and add commands to link the <filename>.h</filename> and <filename>.c</filename> files
62571 as for other drivers and lookups.
62572 </para>
62573 </listitem>
62574 </orderedlist>
62575 <para>
62576 Then all you need to do is write the code! A good way to start is to make a
62577 proforma by copying an existing module of the same type, globally changing all
62578 occurrences of the name, and cutting out most of the code. Note that any
62579 options you create must be listed in alphabetical order, because the tables are
62580 searched using a binary chop procedure.
62581 </para>
62582 <para>
62583 There is a <filename>README</filename> file in each of the sub-directories of <filename>src</filename> describing
62584 the interface that is expected.
62585 </para>
62586 <?sdop
62587   format="newpage"
62588   foot_right_recto="&chaptertitle;"
62589   foot_right_verso="&chaptertitle;"
62590 ?>
62591 </chapter>
62592
62593 <index role="option">
62594 <title>Options index</title>
62595 </index>
62596
62597 <index role="variable">
62598 <title>Variables index</title>
62599 </index>
62600
62601 <index role="concept">
62602 <title>Concept index</title>
62603 </index>
62604
62605 </book>