4b5c3fa8df65ea2edada240400c01e681dc7ad87
[exim-website.git] / docbook / 4.93 / 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>
16 08 Dez 2019
17 </date>
18 <author><firstname>Exim</firstname><surname>Maintainers</surname></author>
19 <authorinitials>EM</authorinitials>
20 <revhistory><revision>
21 <revnumber>4.93</revnumber>
22 <date>08 Dez 2019</date>
23   <authorinitials>EM</authorinitials>
24 </revision></revhistory>
25 <copyright><year>
26 2018, 2019
27            </year><holder>University of Cambridge</holder></copyright>
28 </bookinfo>
29 <chapter id="CHID1">
30 <title>Introduction</title>
31
32 <indexterm role="variable">
33   <primary>$1, $2, etc.</primary>
34   <see><emphasis>numerical variables</emphasis></see>
35 </indexterm>
36 <indexterm role="concept">
37   <primary>address</primary>
38   <secondary>rewriting</secondary>
39   <see><emphasis>rewriting</emphasis></see>
40 </indexterm>
41 <indexterm role="concept">
42   <primary>Bounce Address Tag Validation</primary>
43   <see><emphasis>BATV</emphasis></see>
44 </indexterm>
45 <indexterm role="concept">
46   <primary>Client SMTP Authorization</primary>
47   <see><emphasis>CSA</emphasis></see>
48 </indexterm>
49 <indexterm role="concept">
50   <primary>CR character</primary>
51   <see><emphasis>carriage return</emphasis></see>
52 </indexterm>
53 <indexterm role="concept">
54   <primary>CRL</primary>
55   <see><emphasis>certificate revocation list</emphasis></see>
56 </indexterm>
57 <indexterm role="concept">
58   <primary>delivery</primary>
59   <secondary>failure report</secondary>
60   <see><emphasis>bounce message</emphasis></see>
61 </indexterm>
62 <indexterm role="concept">
63   <primary>dialup</primary>
64   <see><emphasis>intermittently connected hosts</emphasis></see>
65 </indexterm>
66 <indexterm role="concept">
67   <primary>exiscan</primary>
68   <see><emphasis>content scanning</emphasis></see>
69 </indexterm>
70 <indexterm role="concept">
71   <primary>failover</primary>
72   <see><emphasis>fallback</emphasis></see>
73 </indexterm>
74 <indexterm role="concept">
75   <primary>fallover</primary>
76   <see><emphasis>fallback</emphasis></see>
77 </indexterm>
78 <indexterm role="concept">
79   <primary>filter</primary>
80   <secondary>Sieve</secondary>
81   <see><emphasis>Sieve filter</emphasis></see>
82 </indexterm>
83 <indexterm role="concept">
84   <primary>ident</primary>
85   <see><emphasis>RFC 1413</emphasis></see>
86 </indexterm>
87 <indexterm role="concept">
88   <primary>LF character</primary>
89   <see><emphasis>linefeed</emphasis></see>
90 </indexterm>
91 <indexterm role="concept">
92   <primary>maximum</primary>
93   <seealso><emphasis>limit</emphasis></seealso>
94 </indexterm>
95 <indexterm role="concept">
96   <primary>monitor</primary>
97   <see><emphasis>Exim monitor</emphasis></see>
98 </indexterm>
99 <indexterm role="concept">
100   <primary>no_<emphasis>xxx</emphasis></primary>
101   <see>entry for xxx</see>
102 </indexterm>
103 <indexterm role="concept">
104   <primary>NUL</primary>
105   <see><emphasis>binary zero</emphasis></see>
106 </indexterm>
107 <indexterm role="concept">
108   <primary>passwd file</primary>
109   <see><emphasis>/etc/passwd</emphasis></see>
110 </indexterm>
111 <indexterm role="concept">
112   <primary>process id</primary>
113   <see><emphasis>pid</emphasis></see>
114 </indexterm>
115 <indexterm role="concept">
116   <primary>RBL</primary>
117   <see><emphasis>DNS list</emphasis></see>
118 </indexterm>
119 <indexterm role="concept">
120   <primary>redirection</primary>
121   <see><emphasis>address redirection</emphasis></see>
122 </indexterm>
123 <indexterm role="concept">
124   <primary>return path</primary>
125   <seealso><emphasis>envelope sender</emphasis></seealso>
126 </indexterm>
127 <indexterm role="concept">
128   <primary>scanning</primary>
129   <see><emphasis>content scanning</emphasis></see>
130 </indexterm>
131 <indexterm role="concept">
132   <primary>SSL</primary>
133   <see><emphasis>TLS</emphasis></see>
134 </indexterm>
135 <indexterm role="concept">
136   <primary>string</primary>
137   <secondary>expansion</secondary>
138   <see><emphasis>expansion</emphasis></see>
139 </indexterm>
140 <indexterm role="concept">
141   <primary>top bit</primary>
142   <see><emphasis>8-bit characters</emphasis></see>
143 </indexterm>
144 <indexterm role="concept">
145   <primary>variables</primary>
146   <see><emphasis>expansion, variables</emphasis></see>
147 </indexterm>
148 <indexterm role="concept">
149   <primary>zero, binary</primary>
150   <see><emphasis>binary zero</emphasis></see>
151 </indexterm>
152
153 <para>
154 Exim is a mail transfer agent (MTA) for hosts that are running Unix or
155 Unix-like operating systems. It was designed on the assumption that it would be
156 run on hosts that are permanently connected to the Internet. However, it can be
157 used on intermittently connected hosts with suitable configuration adjustments.
158 </para>
159 <para>
160 Configuration files currently exist for the following operating systems: AIX,
161 BSD/OS (aka BSDI), Darwin (Mac OS X), DGUX, Dragonfly, FreeBSD, GNU/Hurd,
162 GNU/Linux, HI-OSF (Hitachi), HI-UX, HP-UX, IRIX, MIPS RISCOS, NetBSD, OpenBSD,
163 OpenUNIX, QNX, SCO, SCO SVR4.2 (aka UNIX-SV), Solaris (aka SunOS5), SunOS4,
164 Tru64-Unix (formerly Digital UNIX, formerly DEC-OSF1), Ultrix, and UnixWare.
165 Some of these operating systems are no longer current and cannot easily be
166 tested, so the configuration files may no longer work in practice.
167 </para>
168 <para>
169 There are also configuration files for compiling Exim in the Cygwin environment
170 that can be installed on systems running Windows. However, this document does
171 not contain any information about running Exim in the Cygwin environment.
172 </para>
173 <para>
174 The terms and conditions for the use and distribution of Exim are contained in
175 the file <filename>NOTICE</filename>. Exim is distributed under the terms of the GNU General
176 Public Licence, a copy of which may be found in the file <filename>LICENCE</filename>.
177 </para>
178 <para>
179 The use, supply, or promotion of Exim for the purpose of sending bulk,
180 unsolicited electronic mail is incompatible with the basic aims of Exim,
181 which revolve around the free provision of a service that enhances the quality
182 of personal communications. The author of Exim regards indiscriminate
183 mass-mailing as an antisocial, irresponsible abuse of the Internet.
184 </para>
185 <para>
186 Exim owes a great deal to Smail 3 and its author, Ron Karr. Without the
187 experience of running and working on the Smail 3 code, I could never have
188 contemplated starting to write a new MTA. Many of the ideas and user interfaces
189 were originally taken from Smail 3, though the actual code of Exim is entirely
190 new, and has developed far beyond the initial concept.
191 </para>
192 <para>
193 Many people, both in Cambridge and around the world, have contributed to the
194 development and the testing of Exim, and to porting it to various operating
195 systems. I am grateful to them all. The distribution now contains a file called
196 <filename>ACKNOWLEDGMENTS</filename>, in which I have started recording the names of
197 contributors.
198 </para>
199 <section id="SECID1">
200 <title>Exim documentation</title>
201 <para revisionflag="changed">
202 <indexterm role="concept">
203 <primary>documentation</primary>
204 </indexterm>
205 This edition of the Exim specification applies to version 4.93 of Exim.
206 Substantive changes from the 4.92 edition are marked in some
207 renditions of this document; this paragraph is so marked if the rendition is
208 capable of showing a change indicator.
209 </para>
210 <para>
211 This document is very much a reference manual; it is not a tutorial. The reader
212 is expected to have some familiarity with the SMTP mail transfer protocol and
213 with general Unix system administration. Although there are some discussions
214 and examples in places, the information is mostly organized in a way that makes
215 it easy to look up, rather than in a natural order for sequential reading.
216 Furthermore, this manual aims to cover every aspect of Exim in detail, including
217 a number of rarely-used, special-purpose features that are unlikely to be of
218 very wide interest.
219 </para>
220 <para>
221 <indexterm role="concept">
222 <primary>books about Exim</primary>
223 </indexterm>
224 An <quote>easier</quote> discussion of Exim which provides more in-depth explanatory,
225 introductory, and tutorial material can be found in a book entitled <emphasis>The Exim
226 SMTP Mail Server</emphasis> (second edition, 2007), published by UIT Cambridge
227 (<emphasis role="bold"><ulink url="https://www.uit.co.uk/exim-book/">https://www.uit.co.uk/exim-book/</ulink></emphasis>).
228 </para>
229 <para>
230 The book also contains a chapter that gives a general introduction to SMTP and
231 Internet mail. Inevitably, however, the book is unlikely to be fully up-to-date
232 with the latest release of Exim. (Note that the earlier book about Exim,
233 published by O&#x2019;Reilly, covers Exim 3, and many things have changed in Exim 4.)
234 </para>
235 <para>
236 <indexterm role="concept">
237 <primary>Debian</primary>
238 <secondary>information sources</secondary>
239 </indexterm>
240 If you are using a Debian distribution of Exim, you will find information about
241 Debian-specific features in the file
242 <filename>/usr/share/doc/exim4-base/README.Debian</filename>.
243 The command <command>man update-exim.conf</command> is another source of Debian-specific
244 information.
245 </para>
246 <para>
247 <indexterm role="concept">
248 <primary><filename>doc/NewStuff</filename></primary>
249 </indexterm>
250 <indexterm role="concept">
251 <primary><filename>doc/ChangeLog</filename></primary>
252 </indexterm>
253 <indexterm role="concept">
254 <primary>change log</primary>
255 </indexterm>
256 As Exim develops, there may be features in newer versions that have not
257 yet made it into this document, which is updated only when the most significant
258 digit of the fractional part of the version number changes. Specifications of
259 new features that are not yet in this manual are placed in the file
260 <filename>doc/NewStuff</filename> in the Exim distribution.
261 </para>
262 <para>
263 Some features may be classified as <quote>experimental</quote>. These may change
264 incompatibly while they are developing, or even be withdrawn. For this reason,
265 they are not documented in this manual. Information about experimental features
266 can be found in the file <filename>doc/experimental.txt</filename>.
267 </para>
268 <para>
269 All changes to Exim (whether new features, bug fixes, or other kinds of
270 change) are noted briefly in the file called <filename>doc/ChangeLog</filename>.
271 </para>
272 <para>
273 <indexterm role="concept">
274 <primary><filename>doc/spec.txt</filename></primary>
275 </indexterm>
276 This specification itself is available as an ASCII file in <filename>doc/spec.txt</filename> so
277 that it can easily be searched with a text editor. Other files in the <filename>doc</filename>
278 directory are:
279 </para>
280 <informaltable frame="none">
281 <tgroup cols="2" colsep="0" rowsep="0">
282 <colspec colwidth="100pt" align="left"/>
283 <colspec colwidth="254pt" align="left"/>
284 <tbody>
285 <row>
286 <entry><filename>OptionLists.txt</filename></entry>
287 <entry>list of all options in alphabetical order</entry>
288 </row>
289 <row>
290 <entry><filename>dbm.discuss.txt</filename></entry>
291 <entry>discussion about DBM libraries</entry>
292 </row>
293 <row>
294 <entry><filename>exim.8</filename></entry>
295 <entry>a man page of Exim&#x2019;s command line options</entry>
296 </row>
297 <row>
298 <entry><filename>experimental.txt</filename></entry>
299 <entry>documentation of experimental features</entry>
300 </row>
301 <row>
302 <entry><filename>filter.txt</filename></entry>
303 <entry>specification of the filter language</entry>
304 </row>
305 <row>
306 <entry><filename>Exim3.upgrade</filename></entry>
307 <entry>upgrade notes from release 2 to release 3</entry>
308 </row>
309 <row>
310 <entry><filename>Exim4.upgrade</filename></entry>
311 <entry>upgrade notes from release 3 to release 4</entry>
312 </row>
313 <row>
314 <entry><filename>openssl.txt</filename></entry>
315 <entry>installing a current OpenSSL release</entry>
316 </row>
317 </tbody>
318 </tgroup>
319 </informaltable>
320 <para>
321 The main specification and the specification of the filtering language are also
322 available in other formats (HTML, PostScript, PDF, and Texinfo). Section
323 <xref linkend="SECTavail"/> below tells you how to get hold of these.
324 </para>
325 </section>
326 <section id="SECID2">
327 <title>FTP site and websites</title>
328 <para>
329 <indexterm role="concept">
330 <primary>website</primary>
331 </indexterm>
332 <indexterm role="concept">
333 <primary>FTP site</primary>
334 </indexterm>
335 The primary site for Exim source distributions is the <option>exim.org</option> FTP site,
336 available over HTTPS, HTTP and FTP.  These services, and the <option>exim.org</option>
337 website, are hosted at the University of Cambridge.
338 </para>
339 <para>
340 <indexterm role="concept">
341 <primary>wiki</primary>
342 </indexterm>
343 <indexterm role="concept">
344 <primary>FAQ</primary>
345 </indexterm>
346 As well as Exim distribution tar files, the Exim website contains a number of
347 differently formatted versions of the documentation. A recent addition to the
348 online information is the Exim wiki (<emphasis role="bold"><ulink url="https://wiki.exim.org">https://wiki.exim.org</ulink></emphasis>),
349 which contains what used to be a separate FAQ, as well as various other
350 examples, tips, and know-how that have been contributed by Exim users.
351 The wiki site should always redirect to the correct place, which is currently
352 provided by GitHub, and is open to editing by anyone with a GitHub account.
353 </para>
354 <para>
355 <indexterm role="concept">
356 <primary>Bugzilla</primary>
357 </indexterm>
358 An Exim Bugzilla exists at <emphasis role="bold"><ulink url="https://bugs.exim.org">https://bugs.exim.org</ulink></emphasis>. You can use
359 this to report bugs, and also to add items to the wish list. Please search
360 first to check that you are not duplicating a previous entry.
361 Please do not ask for configuration help in the bug-tracker.
362 </para>
363 </section>
364 <section id="SECID3">
365 <title>Mailing lists</title>
366 <para>
367 <indexterm role="concept">
368 <primary>mailing lists</primary>
369 <secondary>for Exim users</secondary>
370 </indexterm>
371 The following Exim mailing lists exist:
372 </para>
373 <informaltable frame="none">
374 <tgroup cols="2" colsep="0" rowsep="0">
375 <colspec colwidth="140pt" align="left"/>
376 <colspec colwidth="254pt" align="left"/>
377 <tbody>
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-users@exim.org</emphasis></entry>
384 <entry>General discussion list</entry>
385 </row>
386 <row>
387 <entry><emphasis>exim-dev@exim.org</emphasis></entry>
388 <entry>Discussion of bugs, enhancements, etc.</entry>
389 </row>
390 <row>
391 <entry><emphasis>exim-cvs@exim.org</emphasis></entry>
392 <entry>Automated commit messages from the VCS</entry>
393 </row>
394 </tbody>
395 </tgroup>
396 </informaltable>
397 <para>
398 You can subscribe to these lists, change your existing subscriptions, and view
399 or search the archives via the mailing lists link on the Exim home page.
400 <indexterm role="concept">
401 <primary>Debian</primary>
402 <secondary>mailing list for</secondary>
403 </indexterm>
404 If you are using a Debian distribution of Exim, you may wish to subscribe to
405 the Debian-specific mailing list <emphasis>pkg-exim4-users@lists.alioth.debian.org</emphasis>
406 via this web page:
407 </para>
408 <literallayout>
409 <emphasis role="bold"><ulink url="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-exim4-users">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-exim4-users</ulink></emphasis>
410 </literallayout>
411 <para>
412 Please ask Debian-specific questions on that list and not on the general Exim
413 lists.
414 </para>
415 </section>
416 <section id="SECID5">
417 <title>Bug reports</title>
418 <para>
419 <indexterm role="concept">
420 <primary>bug reports</primary>
421 </indexterm>
422 <indexterm role="concept">
423 <primary>reporting bugs</primary>
424 </indexterm>
425 Reports of obvious bugs can be emailed to <emphasis>bugs@exim.org</emphasis> or reported
426 via the Bugzilla (<emphasis role="bold"><ulink url="https://bugs.exim.org">https://bugs.exim.org</ulink></emphasis>). However, if you are unsure
427 whether some behaviour is a bug or not, the best thing to do is to post a
428 message to the <emphasis>exim-dev</emphasis> mailing list and have it discussed.
429 </para>
430 </section>
431 <section id="SECTavail">
432 <title>Where to find the Exim distribution</title>
433 <para>
434 <indexterm role="concept">
435 <primary>FTP site</primary>
436 </indexterm>
437 <indexterm role="concept">
438 <primary>HTTPS download site</primary>
439 </indexterm>
440 <indexterm role="concept">
441 <primary>distribution</primary>
442 <secondary>FTP site</secondary>
443 </indexterm>
444 <indexterm role="concept">
445 <primary>distribution</primary>
446 <secondary>https site</secondary>
447 </indexterm>
448 The master distribution site for the Exim distribution is
449 </para>
450 <literallayout>
451 <emphasis role="bold"><ulink url="https://downloads.exim.org/">https://downloads.exim.org/</ulink></emphasis>
452 </literallayout>
453 <para>
454 The service is available over HTTPS, HTTP and FTP.
455 We encourage people to migrate to HTTPS.
456 </para>
457 <para>
458 The content served at <emphasis role="bold"><ulink url="https://downloads.exim.org/">https://downloads.exim.org/</ulink></emphasis> is identical to the
459 content served at <emphasis role="bold"><ulink url="https://ftp.exim.org/pub/exim">https://ftp.exim.org/pub/exim</ulink></emphasis> and
460 <emphasis role="bold"><ulink url="ftp://ftp.exim.org/pub/exim">ftp://ftp.exim.org/pub/exim</ulink></emphasis>.
461 </para>
462 <para>
463 If accessing via a hostname containing <emphasis>ftp</emphasis>, then the file references that
464 follow are relative to the <filename>exim</filename> directories at these sites.
465 If accessing via the hostname <emphasis>downloads</emphasis> then the subdirectories described
466 here are top-level directories.
467 </para>
468 <para>
469 There are now quite a number of independent mirror sites around
470 the world. Those that I know about are listed in the file called <filename>Mirrors</filename>.
471 </para>
472 <para>
473 Within the top exim directory there are subdirectories called <filename>exim3</filename> (for
474 previous Exim 3 distributions), <filename>exim4</filename> (for the latest Exim 4
475 distributions), and <filename>Testing</filename> for testing versions. In the <filename>exim4</filename>
476 subdirectory, the current release can always be found in files called
477 </para>
478 <literallayout>
479 <filename>exim-n.nn.tar.xz</filename>
480 <filename>exim-n.nn.tar.gz</filename>
481 <filename>exim-n.nn.tar.bz2</filename>
482 </literallayout>
483 <para>
484 where <emphasis>n.nn</emphasis> is the highest such version number in the directory. The three
485 files contain identical data; the only difference is the type of compression.
486 The <filename>.xz</filename> file is usually the smallest, while the <filename>.gz</filename> file is the
487 most portable to old systems.
488 </para>
489 <para>
490 <indexterm role="concept">
491 <primary>distribution</primary>
492 <secondary>signing details</secondary>
493 </indexterm>
494 <indexterm role="concept">
495 <primary>distribution</primary>
496 <secondary>public key</secondary>
497 </indexterm>
498 <indexterm role="concept">
499 <primary>public key for signed distribution</primary>
500 </indexterm>
501 The distributions will be PGP signed by an individual key of the Release
502 Coordinator.  This key will have a uid containing an email address in the
503 <emphasis>exim.org</emphasis> domain and will have signatures from other people, including
504 other Exim maintainers.  We expect that the key will be in the "strong set" of
505 PGP keys.  There should be a trust path to that key from the Exim Maintainer&#x2019;s
506 PGP keys, a version of which can be found in the release directory in the file
507 <filename>Exim-Maintainers-Keyring.asc</filename>.  All keys used will be available in public keyserver pools,
508 such as <emphasis>pool.sks-keyservers.net</emphasis>.
509 </para>
510 <para>
511 At the time of the last update, releases were being made by Jeremy Harris and signed
512 with key <emphasis>0xBCE58C8CE41F32DF</emphasis>.  Other recent keys used for signing are those
513 of Heiko Schlittermann, <emphasis>0x26101B62F69376CE</emphasis>,
514 and of Phil Pennock, <emphasis>0x4D1E900E14C1CC04</emphasis>.
515 </para>
516 <para>
517 The signatures for the tar bundles are in:
518 </para>
519 <literallayout>
520 <filename>exim-n.nn.tar.xz.asc</filename>
521 <filename>exim-n.nn.tar.gz.asc</filename>
522 <filename>exim-n.nn.tar.bz2.asc</filename>
523 </literallayout>
524 <para>
525 For each released version, the log of changes is made available in a
526 separate file in the directory <filename>ChangeLogs</filename> so that it is possible to
527 find out what has changed without having to download the entire distribution.
528 </para>
529 <para>
530 <indexterm role="concept">
531 <primary>documentation</primary>
532 <secondary>available formats</secondary>
533 </indexterm>
534 The main distribution contains ASCII versions of this specification and other
535 documentation; other formats of the documents are available in separate files
536 inside the <filename>exim4</filename> directory of the FTP site:
537 </para>
538 <literallayout>
539 <filename>exim-html-n.nn.tar.gz</filename>
540 <filename>exim-pdf-n.nn.tar.gz</filename>
541 <filename>exim-postscript-n.nn.tar.gz</filename>
542 <filename>exim-texinfo-n.nn.tar.gz</filename>
543 </literallayout>
544 <para>
545 These tar files contain only the <filename>doc</filename> directory, not the complete
546 distribution, and are also available in <filename>.bz2</filename> and <filename>.xz</filename> forms.
547 </para>
548 </section>
549 <section id="SECID6">
550 <title>Limitations</title>
551 <itemizedlist>
552 <listitem>
553 <para>
554 <indexterm role="concept">
555 <primary>limitations of Exim</primary>
556 </indexterm>
557 <indexterm role="concept">
558 <primary>bang paths</primary>
559 <secondary>not handled by Exim</secondary>
560 </indexterm>
561 Exim is designed for use as an Internet MTA, and therefore handles addresses in
562 RFC 2822 domain format only. It cannot handle UUCP <quote>bang paths</quote>, though
563 simple two-component bang paths can be converted by a straightforward rewriting
564 configuration. This restriction does not prevent Exim from being interfaced to
565 UUCP as a transport mechanism, provided that domain addresses are used.
566 </para>
567 </listitem>
568 <listitem>
569 <para>
570 <indexterm role="concept">
571 <primary>domainless addresses</primary>
572 </indexterm>
573 <indexterm role="concept">
574 <primary>address</primary>
575 <secondary>without domain</secondary>
576 </indexterm>
577 Exim insists that every address it handles has a domain attached. For incoming
578 local messages, domainless addresses are automatically qualified with a
579 configured domain value. Configuration options specify from which remote
580 systems unqualified addresses are acceptable. These are then qualified on
581 arrival.
582 </para>
583 </listitem>
584 <listitem>
585 <para>
586 <indexterm role="concept">
587 <primary>transport</primary>
588 <secondary>external</secondary>
589 </indexterm>
590 <indexterm role="concept">
591 <primary>external transports</primary>
592 </indexterm>
593 The only external transport mechanisms that are currently implemented are SMTP
594 and LMTP over a TCP/IP network (including support for IPv6). However, a pipe
595 transport is available, and there are facilities for writing messages to files
596 and pipes, optionally in <emphasis>batched SMTP</emphasis> format; these facilities can be used
597 to send messages to other transport mechanisms such as UUCP, provided they can
598 handle domain-style addresses. Batched SMTP input is also catered for.
599 </para>
600 </listitem>
601 <listitem>
602 <para>
603 Exim is not designed for storing mail for dial-in hosts. When the volumes of
604 such mail are large, it is better to get the messages <quote>delivered</quote> into files
605 (that is, off Exim&#x2019;s queue) and subsequently passed on to the dial-in hosts by
606 other means.
607 </para>
608 </listitem>
609 <listitem>
610 <para>
611 Although Exim does have basic facilities for scanning incoming messages, these
612 are not comprehensive enough to do full virus or spam scanning. Such operations
613 are best carried out using additional specialized software packages. If you
614 compile Exim with the content-scanning extension, straightforward interfaces to
615 a number of common scanners are provided.
616 </para>
617 </listitem>
618 </itemizedlist>
619 </section>
620 <section id="SECID7">
621 <title>Runtime configuration</title>
622 <para>
623 Exim&#x2019;s runtime configuration is held in a single text file that is divided
624 into a number of sections. The entries in this file consist of keywords and
625 values, in the style of Smail 3 configuration files. A default configuration
626 file which is suitable for simple online installations is provided in the
627 distribution, and is described in chapter <xref linkend="CHAPdefconfil"/> below.
628 </para>
629 </section>
630 <section id="SECID8">
631 <title>Calling interface</title>
632 <para>
633 <indexterm role="concept">
634 <primary>Sendmail compatibility</primary>
635 <secondary>command line interface</secondary>
636 </indexterm>
637 Like many MTAs, Exim has adopted the Sendmail command line interface so that it
638 can be a straight replacement for <filename>/usr/lib/sendmail</filename> or
639 <filename>/usr/sbin/sendmail</filename> when sending mail, but you do not need to know anything
640 about Sendmail in order to run Exim. For actions other than sending messages,
641 Sendmail-compatible options also exist, but those that produce output (for
642 example, <option>-bp</option>, which lists the messages in the queue) do so in Exim&#x2019;s own
643 format. There are also some additional options that are compatible with Smail
644 3, and some further options that are new to Exim. Chapter <xref linkend="CHAPcommandline"/>
645 documents all Exim&#x2019;s command line options. This information is automatically
646 made into the man page that forms part of the Exim distribution.
647 </para>
648 <para>
649 Control of messages in the queue can be done via certain privileged command
650 line options. There is also an optional monitor program called <emphasis>eximon</emphasis>,
651 which displays current information in an X window, and which contains a menu
652 interface to Exim&#x2019;s command line administration options.
653 </para>
654 </section>
655 <section id="SECID9">
656 <title>Terminology</title>
657 <para>
658 <indexterm role="concept">
659 <primary>terminology definitions</primary>
660 </indexterm>
661 <indexterm role="concept">
662 <primary>body of message</primary>
663 <secondary>definition of</secondary>
664 </indexterm>
665 The <emphasis>body</emphasis> of a message is the actual data that the sender wants to transmit.
666 It is the last part of a message and is separated from the <emphasis>header</emphasis> (see
667 below) by a blank line.
668 </para>
669 <para>
670 <indexterm role="concept">
671 <primary>bounce message</primary>
672 <secondary>definition of</secondary>
673 </indexterm>
674 When a message cannot be delivered, it is normally returned to the sender in a
675 delivery failure message or a <quote>non-delivery report</quote> (NDR). The term
676 <emphasis>bounce</emphasis> is commonly used for this action, and the error reports are often
677 called <emphasis>bounce messages</emphasis>. This is a convenient shorthand for <quote>delivery
678 failure error report</quote>. Such messages have an empty sender address in the
679 message&#x2019;s <emphasis>envelope</emphasis> (see below) to ensure that they cannot themselves give
680 rise to further bounce messages.
681 </para>
682 <para>
683 The term <emphasis>default</emphasis> appears frequently in this manual. It is used to qualify a
684 value which is used in the absence of any setting in the configuration. It may
685 also qualify an action which is taken unless a configuration setting specifies
686 otherwise.
687 </para>
688 <para>
689 The term <emphasis>defer</emphasis> is used when the delivery of a message to a specific
690 destination cannot immediately take place for some reason (a remote host may be
691 down, or a user&#x2019;s local mailbox may be full). Such deliveries are <emphasis>deferred</emphasis>
692 until a later time.
693 </para>
694 <para>
695 The word <emphasis>domain</emphasis> is sometimes used to mean all but the first component of a
696 host&#x2019;s name. It is <emphasis>not</emphasis> used in that sense here, where it normally refers to
697 the part of an email address following the @ sign.
698 </para>
699 <para>
700 <indexterm role="concept">
701 <primary>envelope, definition of</primary>
702 </indexterm>
703 <indexterm role="concept">
704 <primary>sender</primary>
705 <secondary>definition of</secondary>
706 </indexterm>
707 A message in transit has an associated <emphasis>envelope</emphasis>, as well as a header and a
708 body. The envelope contains a sender address (to which bounce messages should
709 be delivered), and any number of recipient addresses. References to the
710 sender or the recipients of a message usually mean the addresses in the
711 envelope. An MTA uses these addresses for delivery, and for returning bounce
712 messages, not the addresses that appear in the header lines.
713 </para>
714 <para>
715 <indexterm role="concept">
716 <primary>message</primary>
717 <secondary>header, definition of</secondary>
718 </indexterm>
719 <indexterm role="concept">
720 <primary>header section</primary>
721 <secondary>definition of</secondary>
722 </indexterm>
723 The <emphasis>header</emphasis> of a message is the first part of a message&#x2019;s text, consisting
724 of a number of lines, each of which has a name such as <emphasis>From:</emphasis>, <emphasis>To:</emphasis>,
725 <emphasis>Subject:</emphasis>, etc. Long header lines can be split over several text lines by
726 indenting the continuations. The header is separated from the body by a blank
727 line.
728 </para>
729 <para>
730 <indexterm role="concept">
731 <primary>local part</primary>
732 <secondary>definition of</secondary>
733 </indexterm>
734 <indexterm role="concept">
735 <primary>domain</primary>
736 <secondary>definition of</secondary>
737 </indexterm>
738 The term <emphasis>local part</emphasis>, which is taken from RFC 2822, is used to refer to the
739 part of an email address that precedes the @ sign. The part that follows the
740 @ sign is called the <emphasis>domain</emphasis> or <emphasis>mail domain</emphasis>.
741 </para>
742 <para>
743 <indexterm role="concept">
744 <primary>local delivery</primary>
745 <secondary>definition of</secondary>
746 </indexterm>
747 <indexterm role="concept">
748 <primary>remote delivery, definition of</primary>
749 </indexterm>
750 The terms <emphasis>local delivery</emphasis> and <emphasis>remote delivery</emphasis> are used to distinguish
751 delivery to a file or a pipe on the local host from delivery by SMTP over
752 TCP/IP to another host. As far as Exim is concerned, all hosts other than the
753 host it is running on are <emphasis>remote</emphasis>.
754 </para>
755 <para>
756 <indexterm role="concept">
757 <primary>return path</primary>
758 <secondary>definition of</secondary>
759 </indexterm>
760 <emphasis>Return path</emphasis> is another name that is used for the sender address in a
761 message&#x2019;s envelope.
762 </para>
763 <para>
764 <indexterm role="concept">
765 <primary>queue</primary>
766 <secondary>definition of</secondary>
767 </indexterm>
768 The term <emphasis>queue</emphasis> is used to refer to the set of messages awaiting delivery
769 because this term is in widespread use in the context of MTAs. However, in
770 Exim&#x2019;s case, the reality is more like a pool than a queue, because there is
771 normally no ordering of waiting messages.
772 </para>
773 <para>
774 <indexterm role="concept">
775 <primary>queue runner</primary>
776 <secondary>definition of</secondary>
777 </indexterm>
778 The term <emphasis>queue runner</emphasis> is used to describe a process that scans the queue
779 and attempts to deliver those messages whose retry times have come. This term
780 is used by other MTAs and also relates to the command <option>runq</option>, but in Exim
781 the waiting messages are normally processed in an unpredictable order.
782 </para>
783 <para>
784 <indexterm role="concept">
785 <primary>spool directory</primary>
786 <secondary>definition of</secondary>
787 </indexterm>
788 The term <emphasis>spool directory</emphasis> is used for a directory in which Exim keeps the
789 messages in its queue &ndash; that is, those that it is in the process of
790 delivering. This should not be confused with the directory in which local
791 mailboxes are stored, which is called a <quote>spool directory</quote> by some people. In
792 the Exim documentation, <quote>spool</quote> is always used in the first sense.
793 </para>
794 </section>
795 </chapter>
796
797 <chapter id="CHID2">
798 <title>Incorporated code</title>
799 <para>
800 <indexterm role="concept">
801 <primary>incorporated code</primary>
802 </indexterm>
803 <indexterm role="concept">
804 <primary>regular expressions</primary>
805 <secondary>library</secondary>
806 </indexterm>
807 <indexterm role="concept">
808 <primary>PCRE</primary>
809 </indexterm>
810 <indexterm role="concept">
811 <primary>OpenDMARC</primary>
812 </indexterm>
813 A number of pieces of external code are included in the Exim distribution.
814 </para>
815 <itemizedlist>
816 <listitem>
817 <para>
818 Regular expressions are supported in the main Exim program and in the
819 Exim monitor using the freely-distributable PCRE library, copyright
820 &copy; University of Cambridge. The source to PCRE is no longer shipped with
821 Exim, so you will need to use the version of PCRE shipped with your system,
822 or obtain and install the full version of the library from
823 <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>.
824 </para>
825 </listitem>
826 <listitem>
827 <para>
828 <indexterm role="concept">
829 <primary>cdb</primary>
830 <secondary>acknowledgment</secondary>
831 </indexterm>
832 Support for the cdb (Constant DataBase) lookup method is provided by code
833 contributed by Nigel Metheringham of (at the time he contributed it) Planet
834 Online Ltd. The implementation is completely contained within the code of Exim.
835 It does not link against an external cdb library. The code contains the
836 following statements:
837 </para>
838 <blockquote>
839 <para>
840 Copyright &copy; 1998 Nigel Metheringham, Planet Online Ltd
841 </para>
842 <para>
843 This program is free software; you can redistribute it and/or modify it under
844 the terms of the GNU General Public License as published by the Free Software
845 Foundation; either version 2 of the License, or (at your option) any later
846 version.
847 This code implements Dan Bernstein&#x2019;s Constant DataBase (cdb) spec. Information,
848 the spec and sample code for cdb can be obtained from
849 <emphasis role="bold"><ulink url="https://cr.yp.to/cdb.html">https://cr.yp.to/cdb.html</ulink></emphasis>. This implementation borrows
850 some code from Dan Bernstein&#x2019;s implementation (which has no license
851 restrictions applied to it).
852 </para>
853 </blockquote>
854 </listitem>
855 <listitem>
856 <para>
857 <indexterm role="concept">
858 <primary>SPA authentication</primary>
859 </indexterm>
860 <indexterm role="concept">
861 <primary>Samba project</primary>
862 </indexterm>
863 <indexterm role="concept">
864 <primary>Microsoft Secure Password Authentication</primary>
865 </indexterm>
866 Client support for Microsoft&#x2019;s <emphasis>Secure Password Authentication</emphasis> is provided
867 by code contributed by Marc Prud&#x2019;hommeaux. Server support was contributed by
868 Tom Kistner. This includes code taken from the Samba project, which is released
869 under the Gnu GPL.
870 </para>
871 </listitem>
872 <listitem>
873 <para>
874 <indexterm role="concept">
875 <primary>Cyrus</primary>
876 </indexterm>
877 <indexterm role="concept">
878 <primary><emphasis>pwcheck</emphasis> daemon</primary>
879 </indexterm>
880 <indexterm role="concept">
881 <primary><emphasis>pwauthd</emphasis> daemon</primary>
882 </indexterm>
883 Support for calling the Cyrus <emphasis>pwcheck</emphasis> and <emphasis>saslauthd</emphasis> daemons is provided
884 by code taken from the Cyrus-SASL library and adapted by Alexander S.
885 Sabourenkov. The permission notice appears below, in accordance with the
886 conditions expressed therein.
887 </para>
888 <blockquote>
889 <para>
890 Copyright &copy; 2001 Carnegie Mellon University.  All rights reserved.
891 </para>
892 <para>
893 Redistribution and use in source and binary forms, with or without
894 modification, are permitted provided that the following conditions
895 are met:
896 </para>
897 <orderedlist numeration="arabic">
898 <listitem>
899 <para>
900 Redistributions of source code must retain the above copyright
901 notice, this list of conditions and the following disclaimer.
902 </para>
903 </listitem>
904 <listitem>
905 <para>
906 Redistributions in binary form must reproduce the above copyright
907 notice, this list of conditions and the following disclaimer in
908 the documentation and/or other materials provided with the
909 distribution.
910 </para>
911 </listitem>
912 <listitem>
913 <para>
914 The name <quote>Carnegie Mellon University</quote> must not be used to
915 endorse or promote products derived from this software without
916 prior written permission. For permission or any other legal
917 details, please contact
918 </para>
919 <literallayout>
920               Office of Technology Transfer
921               Carnegie Mellon University
922               5000 Forbes Avenue
923               Pittsburgh, PA  15213-3890
924               (412) 268-4387, fax: (412) 268-7395
925               tech-transfer@andrew.cmu.edu
926 </literallayout>
927 </listitem>
928 <listitem>
929 <para>
930 Redistributions of any form whatsoever must retain the following
931 acknowledgment:
932 </para>
933 <para>
934 <quote>This product includes software developed by Computing Services
935 at Carnegie Mellon University (<emphasis role="bold"><ulink url="https://www.cmu.edu/computing/">https://www.cmu.edu/computing/</ulink></emphasis>.</quote>
936 </para>
937 <para>
938 CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
939 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
940 AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
941 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
942 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
943 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
944 OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
945 </para>
946 </listitem>
947 </orderedlist>
948 </blockquote>
949 </listitem>
950 <listitem>
951 <para>
952 <indexterm role="concept">
953 <primary>Exim monitor</primary>
954 <secondary>acknowledgment</secondary>
955 </indexterm>
956 <indexterm role="concept">
957 <primary>X-windows</primary>
958 </indexterm>
959 <indexterm role="concept">
960 <primary>Athena</primary>
961 </indexterm>
962 The Exim Monitor program, which is an X-Window application, includes
963 modified versions of the Athena StripChart and TextPop widgets.
964 This code is copyright by DEC and MIT, and their permission notice appears
965 below, in accordance with the conditions expressed therein.
966 </para>
967 <blockquote>
968 <para>
969 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
970 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
971 </para>
972 <para>
973 All Rights Reserved
974 </para>
975 <para>
976 Permission to use, copy, modify, and distribute this software and its
977 documentation for any purpose and without fee is hereby granted,
978 provided that the above copyright notice appear in all copies and that
979 both that copyright notice and this permission notice appear in
980 supporting documentation, and that the names of Digital or MIT not be
981 used in advertising or publicity pertaining to distribution of the
982 software without specific, written prior permission.
983 </para>
984 <para>
985 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
986 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
987 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
988 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
989 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
990 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
991 SOFTWARE.
992 </para>
993 </blockquote>
994 </listitem>
995 <listitem>
996 <para>
997 <indexterm role="concept">
998 <primary>opendmarc</primary>
999 <secondary>acknowledgment</secondary>
1000 </indexterm>
1001 The DMARC implementation uses the OpenDMARC library which is Copyrighted by
1002 The Trusted Domain Project. Portions of Exim source which use OpenDMARC
1003 derived code are indicated in the respective source files. The full OpenDMARC
1004 license is provided in the LICENSE.opendmarc file contained in the distributed
1005 source code.
1006 </para>
1007 </listitem>
1008 <listitem>
1009 <para>
1010 Many people have contributed code fragments, some large, some small, that were
1011 not covered by any specific license requirements. It is assumed that the
1012 contributors are happy to see their code incorporated into Exim under the GPL.
1013 </para>
1014 </listitem>
1015 </itemizedlist>
1016 </chapter>
1017
1018 <chapter id="CHID11">
1019 <title>How Exim receives and delivers mail</title>
1020 <titleabbrev>Receiving and delivering mail</titleabbrev>
1021 <section id="SECID10">
1022 <title>Overall philosophy</title>
1023 <para>
1024 <indexterm role="concept">
1025 <primary>design philosophy</primary>
1026 </indexterm>
1027 Exim is designed to work efficiently on systems that are permanently connected
1028 to the Internet and are handling a general mix of mail. In such circumstances,
1029 most messages can be delivered immediately. Consequently, Exim does not
1030 maintain independent queues of messages for specific domains or hosts, though
1031 it does try to send several messages in a single SMTP connection after a host
1032 has been down, and it also maintains per-host retry information.
1033 </para>
1034 </section>
1035 <section id="SECID11">
1036 <title>Policy control</title>
1037 <para>
1038 <indexterm role="concept">
1039 <primary>policy control</primary>
1040 <secondary>overview</secondary>
1041 </indexterm>
1042 Policy controls are now an important feature of MTAs that are connected to the
1043 Internet. Perhaps their most important job is to stop MTAs from being abused as
1044 <quote>open relays</quote> by misguided individuals who send out vast amounts of
1045 unsolicited junk and want to disguise its source. Exim provides flexible
1046 facilities for specifying policy controls on incoming mail:
1047 </para>
1048 <itemizedlist>
1049 <listitem>
1050 <para>
1051 <indexterm role="concept">
1052 <primary>access control lists (ACLs)</primary>
1053 <secondary>introduction</secondary>
1054 </indexterm>
1055 Exim 4 (unlike previous versions of Exim) implements policy controls on
1056 incoming mail by means of <emphasis>Access Control Lists</emphasis> (ACLs). Each list is a
1057 series of statements that may either grant or deny access. ACLs can be used at
1058 several places in the SMTP dialogue while receiving a message from a remote
1059 host. However, the most common places are after each RCPT command, and at the
1060 very end of the message. The sysadmin can specify conditions for accepting or
1061 rejecting individual recipients or the entire message, respectively, at these
1062 two points (see chapter <xref linkend="CHAPACL"/>). Denial of access results in an SMTP
1063 error code.
1064 </para>
1065 </listitem>
1066 <listitem>
1067 <para>
1068 An ACL is also available for locally generated, non-SMTP messages. In this
1069 case, the only available actions are to accept or deny the entire message.
1070 </para>
1071 </listitem>
1072 <listitem>
1073 <para>
1074 When Exim is compiled with the content-scanning extension, facilities are
1075 provided in the ACL mechanism for passing the message to external virus and/or
1076 spam scanning software. The result of such a scan is passed back to the ACL,
1077 which can then use it to decide what to do with the message.
1078 </para>
1079 </listitem>
1080 <listitem>
1081 <para>
1082 When a message has been received, either from a remote host or from the local
1083 host, but before the final acknowledgment has been sent, a locally supplied C
1084 function called <function>local_scan()</function> can be run to inspect the message and decide
1085 whether to accept it or not (see chapter <xref linkend="CHAPlocalscan"/>). If the message
1086 is accepted, the list of recipients can be modified by the function.
1087 </para>
1088 </listitem>
1089 <listitem>
1090 <para>
1091 Using the <function>local_scan()</function> mechanism is another way of calling external scanner
1092 software. The <option>SA-Exim</option> add-on package works this way. It does not require
1093 Exim to be compiled with the content-scanning extension.
1094 </para>
1095 </listitem>
1096 <listitem>
1097 <para>
1098 After a message has been accepted, a further checking mechanism is available in
1099 the form of the <emphasis>system filter</emphasis> (see chapter <xref linkend="CHAPsystemfilter"/>). This
1100 runs at the start of every delivery process.
1101 </para>
1102 </listitem>
1103 </itemizedlist>
1104 </section>
1105 <section id="SECID12">
1106 <title>User filters</title>
1107 <para>
1108 <indexterm role="concept">
1109 <primary>filter</primary>
1110 <secondary>introduction</secondary>
1111 </indexterm>
1112 <indexterm role="concept">
1113 <primary>Sieve filter</primary>
1114 </indexterm>
1115 In a conventional Exim configuration, users are able to run private filters by
1116 setting up appropriate <filename>.forward</filename> files in their home directories. See
1117 chapter <xref linkend="CHAPredirect"/> (about the <command>redirect</command> router) for the
1118 configuration needed to support this, and the separate document entitled
1119 <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis> for user details. Two different kinds
1120 of filtering are available:
1121 </para>
1122 <itemizedlist>
1123 <listitem>
1124 <para>
1125 Sieve filters are written in the standard filtering language that is defined
1126 by RFC 3028.
1127 </para>
1128 </listitem>
1129 <listitem>
1130 <para>
1131 Exim filters are written in a syntax that is unique to Exim, but which is more
1132 powerful than Sieve, which it pre-dates.
1133 </para>
1134 </listitem>
1135 </itemizedlist>
1136 <para>
1137 User filters are run as part of the routing process, described below.
1138 </para>
1139 </section>
1140 <section id="SECTmessiden">
1141 <title>Message identification</title>
1142 <para>
1143 <indexterm role="concept">
1144 <primary>message ids</primary>
1145 <secondary>details of format</secondary>
1146 </indexterm>
1147 <indexterm role="concept">
1148 <primary>format</primary>
1149 <secondary>of message id</secondary>
1150 </indexterm>
1151 <indexterm role="concept">
1152 <primary>id of message</primary>
1153 </indexterm>
1154 <indexterm role="concept">
1155 <primary>base62</primary>
1156 </indexterm>
1157 <indexterm role="concept">
1158 <primary>base36</primary>
1159 </indexterm>
1160 <indexterm role="concept">
1161 <primary>Darwin</primary>
1162 </indexterm>
1163 <indexterm role="concept">
1164 <primary>Cygwin</primary>
1165 </indexterm>
1166 Every message handled by Exim is given a <emphasis>message id</emphasis> which is sixteen
1167 characters long. It is divided into three parts, separated by hyphens, for
1168 example <literal>16VDhn-0001bo-D3</literal>. Each part is a sequence of letters and digits,
1169 normally encoding numbers in base 62. However, in the Darwin operating
1170 system (Mac OS X) and when Exim is compiled to run under Cygwin, base 36
1171 (avoiding the use of lower case letters) is used instead, because the message
1172 id is used to construct filenames, and the names of files in those systems are
1173 not always case-sensitive.
1174 </para>
1175 <para>
1176 <indexterm role="concept">
1177 <primary>pid (process id)</primary>
1178 <secondary>re-use of</secondary>
1179 </indexterm>
1180 The detail of the contents of the message id have changed as Exim has evolved.
1181 Earlier versions relied on the operating system not re-using a process id (pid)
1182 within one second. On modern operating systems, this assumption can no longer
1183 be made, so the algorithm had to be changed. To retain backward compatibility,
1184 the format of the message id was retained, which is why the following rules are
1185 somewhat eccentric:
1186 </para>
1187 <itemizedlist>
1188 <listitem>
1189 <para>
1190 The first six characters of the message id are the time at which the message
1191 started to be received, to a granularity of one second. That is, this field
1192 contains the number of seconds since the start of the epoch (the normal Unix
1193 way of representing the date and time of day).
1194 </para>
1195 </listitem>
1196 <listitem>
1197 <para>
1198 After the first hyphen, the next six characters are the id of the process that
1199 received the message.
1200 </para>
1201 </listitem>
1202 <listitem>
1203 <para>
1204 There are two different possibilities for the final two characters:
1205 </para>
1206 <orderedlist numeration="arabic">
1207 <listitem>
1208 <para>
1209 <indexterm role="option">
1210 <primary><option>localhost_number</option></primary>
1211 </indexterm>
1212 If <option>localhost_number</option> is not set, this value is the fractional part of the
1213 time of reception, normally in units of 1/2000 of a second, but for systems
1214 that must use base 36 instead of base 62 (because of case-insensitive file
1215 systems), the units are 1/1000 of a second.
1216 </para>
1217 </listitem>
1218 <listitem>
1219 <para>
1220 If <option>localhost_number</option> is set, it is multiplied by 200 (100) and added to
1221 the fractional part of the time, which in this case is in units of 1/200
1222 (1/100) of a second.
1223 </para>
1224 </listitem>
1225 </orderedlist>
1226 </listitem>
1227 </itemizedlist>
1228 <para>
1229 After a message has been received, Exim waits for the clock to tick at the
1230 appropriate resolution before proceeding, so that if another message is
1231 received by the same process, or by another process with the same (re-used)
1232 pid, it is guaranteed that the time will be different. In most cases, the clock
1233 will already have ticked while the message was being received.
1234 </para>
1235 </section>
1236 <section id="SECID13">
1237 <title>Receiving mail</title>
1238 <para>
1239 <indexterm role="concept">
1240 <primary>receiving mail</primary>
1241 </indexterm>
1242 <indexterm role="concept">
1243 <primary>message</primary>
1244 <secondary>reception</secondary>
1245 </indexterm>
1246 The only way Exim can receive mail from another host is using SMTP over
1247 TCP/IP, in which case the sender and recipient addresses are transferred using
1248 SMTP commands. However, from a locally running process (such as a user&#x2019;s MUA),
1249 there are several possibilities:
1250 </para>
1251 <itemizedlist>
1252 <listitem>
1253 <para>
1254 If the process runs Exim with the <option>-bm</option> option, the message is read
1255 non-interactively (usually via a pipe), with the recipients taken from the
1256 command line, or from the body of the message if <option>-t</option> is also used.
1257 </para>
1258 </listitem>
1259 <listitem>
1260 <para>
1261 If the process runs Exim with the <option>-bS</option> option, the message is also read
1262 non-interactively, but in this case the recipients are listed at the start of
1263 the message in a series of SMTP RCPT commands, terminated by a DATA
1264 command. This is called <quote>batch SMTP</quote> format,
1265 but it isn&#x2019;t really SMTP. The SMTP commands are just another way of passing
1266 envelope addresses in a non-interactive submission.
1267 </para>
1268 </listitem>
1269 <listitem>
1270 <para>
1271 If the process runs Exim with the <option>-bs</option> option, the message is read
1272 interactively, using the SMTP protocol. A two-way pipe is normally used for
1273 passing data between the local process and the Exim process.
1274 This is <quote>real</quote> SMTP and is handled in the same way as SMTP over TCP/IP. For
1275 example, the ACLs for SMTP commands are used for this form of submission.
1276 </para>
1277 </listitem>
1278 <listitem>
1279 <para>
1280 A local process may also make a TCP/IP call to the host&#x2019;s loopback address
1281 (127.0.0.1) or any other of its IP addresses. When receiving messages, Exim
1282 does not treat the loopback address specially. It treats all such connections
1283 in the same way as connections from other hosts.
1284 </para>
1285 </listitem>
1286 </itemizedlist>
1287 <para>
1288 <indexterm role="concept">
1289 <primary>message sender, constructed by Exim</primary>
1290 </indexterm>
1291 <indexterm role="concept">
1292 <primary>sender</primary>
1293 <secondary>constructed by Exim</secondary>
1294 </indexterm>
1295 In the three cases that do not involve TCP/IP, the sender address is
1296 constructed from the login name of the user that called Exim and a default
1297 qualification domain (which can be set by the <option>qualify_domain</option> configuration
1298 option). For local or batch SMTP, a sender address that is passed using the
1299 SMTP MAIL command is ignored. However, the system administrator may allow
1300 certain users (<quote>trusted users</quote>) to specify a different sender addresses
1301 unconditionally, or all users to specify certain forms of different sender
1302 address. The <option>-f</option> option or the SMTP MAIL command is used to specify these
1303 different addresses. See section <xref linkend="SECTtrustedadmin"/> for details of trusted
1304 users, and the <option>untrusted_set_sender</option> option for a way of allowing untrusted
1305 users to change sender addresses.
1306 </para>
1307 <para>
1308 Messages received by either of the non-interactive mechanisms are subject to
1309 checking by the non-SMTP ACL if one is defined. Messages received using SMTP
1310 (either over TCP/IP or interacting with a local process) can be checked by a
1311 number of ACLs that operate at different times during the SMTP session. Either
1312 individual recipients or the entire message can be rejected if local policy
1313 requirements are not met. The <function>local_scan()</function> function (see chapter
1314 <xref linkend="CHAPlocalscan"/>) is run for all incoming messages.
1315 </para>
1316 <para>
1317 Exim can be configured not to start a delivery process when a message is
1318 received; this can be unconditional, or depend on the number of incoming SMTP
1319 connections or the system load. In these situations, new messages wait on the
1320 queue until a queue runner process picks them up. However, in standard
1321 configurations under normal conditions, delivery is started as soon as a
1322 message is received.
1323 </para>
1324 </section>
1325 <section id="SECID14">
1326 <title>Handling an incoming message</title>
1327 <para>
1328 <indexterm role="concept">
1329 <primary>spool directory</primary>
1330 <secondary>files that hold a message</secondary>
1331 </indexterm>
1332 <indexterm role="concept">
1333 <primary>file</primary>
1334 <secondary>how a message is held</secondary>
1335 </indexterm>
1336 When Exim accepts a message, it writes two files in its spool directory. The
1337 first contains the envelope information, the current status of the message, and
1338 the header lines, and the second contains the body of the message. The names of
1339 the two spool files consist of the message id, followed by <literal>-H</literal> for the
1340 file containing the envelope and header, and <literal>-D</literal> for the data file.
1341 </para>
1342 <para>
1343 <indexterm role="concept">
1344 <primary>spool directory</primary>
1345 <secondary><filename>input</filename> sub-directory</secondary>
1346 </indexterm>
1347 By default, all these message files are held in a single directory called
1348 <filename>input</filename> inside the general Exim spool directory. Some operating systems do
1349 not perform very well if the number of files in a directory gets large; to
1350 improve performance in such cases, the <option>split_spool_directory</option> option can be
1351 used. This causes Exim to split up the input files into 62 sub-directories
1352 whose names are single letters or digits. When this is done, the queue is
1353 processed one sub-directory at a time instead of all at once, which can improve
1354 overall performance even when there are not enough files in each directory to
1355 affect file system performance.
1356 </para>
1357 <para>
1358 The envelope information consists of the address of the message&#x2019;s sender and
1359 the addresses of the recipients. This information is entirely separate from
1360 any addresses contained in the header lines. The status of the message includes
1361 a list of recipients who have already received the message. The format of the
1362 first spool file is described in chapter <xref linkend="CHAPspool"/>.
1363 </para>
1364 <para>
1365 <indexterm role="concept">
1366 <primary>rewriting</primary>
1367 <secondary>addresses</secondary>
1368 </indexterm>
1369 Address rewriting that is specified in the rewrite section of the configuration
1370 (see chapter <xref linkend="CHAPrewrite"/>) is done once and for all on incoming addresses,
1371 both in the header lines and the envelope, at the time the message is accepted.
1372 If during the course of delivery additional addresses are generated (for
1373 example, via aliasing), these new addresses are rewritten as soon as they are
1374 generated. At the time a message is actually delivered (transported) further
1375 rewriting can take place; because this is a transport option, it can be
1376 different for different forms of delivery. It is also possible to specify the
1377 addition or removal of certain header lines at the time the message is
1378 delivered (see chapters <xref linkend="CHAProutergeneric"/> and
1379 <xref linkend="CHAPtransportgeneric"/>).
1380 </para>
1381 </section>
1382 <section id="SECID15">
1383 <title>Life of a message</title>
1384 <para>
1385 <indexterm role="concept">
1386 <primary>message</primary>
1387 <secondary>life of</secondary>
1388 </indexterm>
1389 <indexterm role="concept">
1390 <primary>message</primary>
1391 <secondary>frozen</secondary>
1392 </indexterm>
1393 A message remains in the spool directory until it is completely delivered to
1394 its recipients or to an error address, or until it is deleted by an
1395 administrator or by the user who originally created it. In cases when delivery
1396 cannot proceed &ndash; for example when a message can neither be delivered to its
1397 recipients nor returned to its sender, the message is marked <quote>frozen</quote> on the
1398 spool, and no more deliveries are attempted.
1399 </para>
1400 <para>
1401 <indexterm role="concept">
1402 <primary>frozen messages</primary>
1403 <secondary>thawing</secondary>
1404 </indexterm>
1405 <indexterm role="concept">
1406 <primary>message</primary>
1407 <secondary>thawing frozen</secondary>
1408 </indexterm>
1409 An administrator can <quote>thaw</quote> such messages when the problem has been
1410 corrected, and can also freeze individual messages by hand if necessary. In
1411 addition, an administrator can force a delivery error, causing a bounce message
1412 to be sent.
1413 </para>
1414 <para>
1415 <indexterm role="option">
1416 <primary><option>timeout_frozen_after</option></primary>
1417 </indexterm>
1418 <indexterm role="option">
1419 <primary><option>ignore_bounce_errors_after</option></primary>
1420 </indexterm>
1421 There are options called <option>ignore_bounce_errors_after</option> and
1422 <option>timeout_frozen_after</option>, which discard frozen messages after a certain time.
1423 The first applies only to frozen bounces, the second to all frozen messages.
1424 </para>
1425 <para>
1426 <indexterm role="concept">
1427 <primary>message</primary>
1428 <secondary>log file for</secondary>
1429 </indexterm>
1430 <indexterm role="concept">
1431 <primary>log</primary>
1432 <secondary>file for each message</secondary>
1433 </indexterm>
1434 While Exim is working on a message, it writes information about each delivery
1435 attempt to its main log file. This includes successful, unsuccessful, and
1436 delayed deliveries for each recipient (see chapter <xref linkend="CHAPlog"/>). The log
1437 lines are also written to a separate <emphasis>message log</emphasis> file for each message.
1438 These logs are solely for the benefit of the administrator and are normally
1439 deleted along with the spool files when processing of a message is complete.
1440 The use of individual message logs can be disabled by setting
1441 <option>no_message_logs</option>; this might give an improvement in performance on very busy
1442 systems.
1443 </para>
1444 <para>
1445 <indexterm role="concept">
1446 <primary>journal file</primary>
1447 </indexterm>
1448 <indexterm role="concept">
1449 <primary>file</primary>
1450 <secondary>journal</secondary>
1451 </indexterm>
1452 All the information Exim itself needs to set up a delivery is kept in the first
1453 spool file, along with the header lines. When a successful delivery occurs, the
1454 address is immediately written at the end of a journal file, whose name is the
1455 message id followed by <literal>-J</literal>. At the end of a delivery run, if there are some
1456 addresses left to be tried again later, the first spool file (the <literal>-H</literal> file)
1457 is updated to indicate which these are, and the journal file is then deleted.
1458 Updating the spool file is done by writing a new file and renaming it, to
1459 minimize the possibility of data loss.
1460 </para>
1461 <para>
1462 Should the system or Exim crash after a successful delivery but before
1463 the spool file has been updated, the journal is left lying around. The next
1464 time Exim attempts to deliver the message, it reads the journal file and
1465 updates the spool file before proceeding. This minimizes the chances of double
1466 deliveries caused by crashes.
1467 </para>
1468 </section>
1469 <section id="SECTprocaddress">
1470 <title>Processing an address for delivery</title>
1471 <para>
1472 <indexterm role="concept">
1473 <primary>drivers</primary>
1474 <secondary>definition of</secondary>
1475 </indexterm>
1476 <indexterm role="concept">
1477 <primary>router</primary>
1478 <secondary>definition of</secondary>
1479 </indexterm>
1480 <indexterm role="concept">
1481 <primary>transport</primary>
1482 <secondary>definition of</secondary>
1483 </indexterm>
1484 The main delivery processing elements of Exim are called <emphasis>routers</emphasis> and
1485 <emphasis>transports</emphasis>, and collectively these are known as <emphasis>drivers</emphasis>. Code for a
1486 number of them is provided in the source distribution, and compile-time options
1487 specify which ones are included in the binary. Runtime options specify which
1488 ones are actually used for delivering messages.
1489 </para>
1490 <para>
1491 <indexterm role="concept">
1492 <primary>drivers</primary>
1493 <secondary>instance definition</secondary>
1494 </indexterm>
1495 Each driver that is specified in the runtime configuration is an <emphasis>instance</emphasis>
1496 of that particular driver type. Multiple instances are allowed; for example,
1497 you can set up several different <command>smtp</command> transports, each with different
1498 option values that might specify different ports or different timeouts. Each
1499 instance has its own identifying name. In what follows we will normally use the
1500 instance name when discussing one particular instance (that is, one specific
1501 configuration of the driver), and the generic driver name when discussing
1502 the driver&#x2019;s features in general.
1503 </para>
1504 <para>
1505 A <emphasis>router</emphasis> is a driver that operates on an address, either determining how
1506 its delivery should happen, by assigning it to a specific transport, or
1507 converting the address into one or more new addresses (for example, via an
1508 alias file). A router may also explicitly choose to fail an address, causing it
1509 to be bounced.
1510 </para>
1511 <para>
1512 A <emphasis>transport</emphasis> is a driver that transmits a copy of the message from Exim&#x2019;s
1513 spool to some destination. There are two kinds of transport: for a <emphasis>local</emphasis>
1514 transport, the destination is a file or a pipe on the local host, whereas for a
1515 <emphasis>remote</emphasis> transport the destination is some other host. A message is passed
1516 to a specific transport as a result of successful routing. If a message has
1517 several recipients, it may be passed to a number of different transports.
1518 </para>
1519 <para>
1520 <indexterm role="concept">
1521 <primary>preconditions</primary>
1522 <secondary>definition of</secondary>
1523 </indexterm>
1524 An address is processed by passing it to each configured router instance in
1525 turn, subject to certain preconditions, until a router accepts the address or
1526 specifies that it should be bounced. We will describe this process in more
1527 detail shortly. First, as a simple example, we consider how each recipient
1528 address in a message is processed in a small configuration of three routers.
1529 </para>
1530 <para>
1531 To make this a more concrete example, it is described in terms of some actual
1532 routers, but remember, this is only an example. You can configure Exim&#x2019;s
1533 routers in many different ways, and there may be any number of routers in a
1534 configuration.
1535 </para>
1536 <para>
1537 The first router that is specified in a configuration is often one that handles
1538 addresses in domains that are not recognized specifically by the local host.
1539 Typically these are addresses for arbitrary domains on the Internet. A precondition
1540 is set up which looks for the special domains known to the host (for example,
1541 its own domain name), and the router is run for addresses that do <emphasis>not</emphasis>
1542 match. Typically, this is a router that looks up domains in the DNS in order to
1543 find the hosts to which this address routes. If it succeeds, the address is
1544 assigned to a suitable SMTP transport; if it does not succeed, the router is
1545 configured to fail the address.
1546 </para>
1547 <para>
1548 The second router is reached only when the domain is recognized as one that
1549 <quote>belongs</quote> to the local host. This router does redirection &ndash; also known as
1550 aliasing and forwarding. When it generates one or more new addresses from the
1551 original, each of them is routed independently from the start. Otherwise, the
1552 router may cause an address to fail, or it may simply decline to handle the
1553 address, in which case the address is passed to the next router.
1554 </para>
1555 <para>
1556 The final router in many configurations is one that checks to see if the
1557 address belongs to a local mailbox. The precondition may involve a check to
1558 see if the local part is the name of a login account, or it may look up the
1559 local part in a file or a database. If its preconditions are not met, or if
1560 the router declines, we have reached the end of the routers. When this happens,
1561 the address is bounced.
1562 </para>
1563 </section>
1564 <section id="SECID16">
1565 <title>Processing an address for verification</title>
1566 <para>
1567 <indexterm role="concept">
1568 <primary>router</primary>
1569 <secondary>for verification</secondary>
1570 </indexterm>
1571 <indexterm role="concept">
1572 <primary>verifying address</primary>
1573 <secondary>overview</secondary>
1574 </indexterm>
1575 As well as being used to decide how to deliver to an address, Exim&#x2019;s routers
1576 are also used for <emphasis>address verification</emphasis>. Verification can be requested as
1577 one of the checks to be performed in an ACL for incoming messages, on both
1578 sender and recipient addresses, and it can be tested using the <option>-bv</option> and
1579 <option>-bvs</option> command line options.
1580 </para>
1581 <para>
1582 When an address is being verified, the routers are run in <quote>verify mode</quote>. This
1583 does not affect the way the routers work, but it is a state that can be
1584 detected. By this means, a router can be skipped or made to behave differently
1585 when verifying. A common example is a configuration in which the first router
1586 sends all messages to a message-scanning program unless they have been
1587 previously scanned. Thus, the first router accepts all addresses without any
1588 checking, making it useless for verifying. Normally, the <option>no_verify</option> option
1589 would be set for such a router, causing it to be skipped in verify mode.
1590 </para>
1591 </section>
1592 <section id="SECTrunindrou">
1593 <title>Running an individual router</title>
1594 <para>
1595 <indexterm role="concept">
1596 <primary>router</primary>
1597 <secondary>running details</secondary>
1598 </indexterm>
1599 <indexterm role="concept">
1600 <primary>preconditions</primary>
1601 <secondary>checking</secondary>
1602 </indexterm>
1603 <indexterm role="concept">
1604 <primary>router</primary>
1605 <secondary>result of running</secondary>
1606 </indexterm>
1607 As explained in the example above, a number of preconditions are checked before
1608 running a router. If any are not met, the router is skipped, and the address is
1609 passed to the next router. When all the preconditions on a router <emphasis>are</emphasis> met,
1610 the router is run. What happens next depends on the outcome, which is one of
1611 the following:
1612 </para>
1613 <itemizedlist>
1614 <listitem>
1615 <para>
1616 <emphasis>accept</emphasis>: The router accepts the address, and either assigns it to a
1617 transport or generates one or more <quote>child</quote> addresses. Processing the
1618 original address ceases
1619 <indexterm role="option">
1620 <primary><option>unseen</option></primary>
1621 </indexterm>
1622 unless the <option>unseen</option> option is set on the router. This option
1623 can be used to set up multiple deliveries with different routing (for example,
1624 for keeping archive copies of messages). When <option>unseen</option> is set, the address is
1625 passed to the next router. Normally, however, an <emphasis>accept</emphasis> return marks the
1626 end of routing.
1627 </para>
1628 <para>
1629 Any child addresses generated by the router are processed independently,
1630 starting with the first router by default. It is possible to change this by
1631 setting the <option>redirect_router</option> option to specify which router to start at for
1632 child addresses. Unlike <option>pass_router</option> (see below) the router specified by
1633 <option>redirect_router</option> may be anywhere in the router configuration.
1634 </para>
1635 </listitem>
1636 <listitem>
1637 <para>
1638 <emphasis>pass</emphasis>: The router recognizes the address, but cannot handle it itself. It
1639 requests that the address be passed to another router. By default, the address
1640 is passed to the next router, but this can be changed by setting the
1641 <option>pass_router</option> option. However, (unlike <option>redirect_router</option>) the named router
1642 must be below the current router (to avoid loops).
1643 </para>
1644 </listitem>
1645 <listitem>
1646 <para>
1647 <emphasis>decline</emphasis>: The router declines to accept the address because it does not
1648 recognize it at all. By default, the address is passed to the next router, but
1649 this can be prevented by setting the <option>no_more</option> option. When <option>no_more</option> is
1650 set, all the remaining routers are skipped. In effect, <option>no_more</option> converts
1651 <emphasis>decline</emphasis> into <emphasis>fail</emphasis>.
1652 </para>
1653 </listitem>
1654 <listitem>
1655 <para>
1656 <emphasis>fail</emphasis>: The router determines that the address should fail, and queues it for
1657 the generation of a bounce message. There is no further processing of the
1658 original address unless <option>unseen</option> is set on the router.
1659 </para>
1660 </listitem>
1661 <listitem>
1662 <para>
1663 <emphasis>defer</emphasis>: The router cannot handle the address at the present time. (A
1664 database may be offline, or a DNS lookup may have timed out.) No further
1665 processing of the address happens in this delivery attempt. It is tried again
1666 next time the message is considered for delivery.
1667 </para>
1668 </listitem>
1669 <listitem>
1670 <para>
1671 <emphasis>error</emphasis>: There is some error in the router (for example, a syntax error in
1672 its configuration). The action is as for defer.
1673 </para>
1674 </listitem>
1675 </itemizedlist>
1676 <para>
1677 If an address reaches the end of the routers without having been accepted by
1678 any of them, it is bounced as unrouteable. The default error message in this
1679 situation is <quote>unrouteable address</quote>, but you can set your own message by
1680 making use of the <option>cannot_route_message</option> option. This can be set for any
1681 router; the value from the last router that <quote>saw</quote> the address is used.
1682 </para>
1683 <para>
1684 Sometimes while routing you want to fail a delivery when some conditions are
1685 met but others are not, instead of passing the address on for further routing.
1686 You can do this by having a second router that explicitly fails the delivery
1687 when the relevant conditions are met. The <command>redirect</command> router has a <quote>fail</quote>
1688 facility for this purpose.
1689 </para>
1690 </section>
1691 <section id="SECID17">
1692 <title>Duplicate addresses</title>
1693 <para>
1694 <indexterm role="concept">
1695 <primary>case of local parts</primary>
1696 </indexterm>
1697 <indexterm role="concept">
1698 <primary>address duplicate, discarding</primary>
1699 </indexterm>
1700 <indexterm role="concept">
1701 <primary>duplicate addresses</primary>
1702 </indexterm>
1703 Once routing is complete, Exim scans the addresses that are assigned to local
1704 and remote transports and discards any duplicates that it finds. During this
1705 check, local parts are treated case-sensitively. This happens only when
1706 actually delivering a message; when testing routers with <option>-bt</option>, all the
1707 routed addresses are shown.
1708 </para>
1709 </section>
1710 <section id="SECTrouprecon">
1711 <title>Router preconditions</title>
1712 <para>
1713 <indexterm role="concept">
1714 <primary>router</primary>
1715 <secondary>preconditions, order of processing</secondary>
1716 </indexterm>
1717 <indexterm role="concept">
1718 <primary>preconditions</primary>
1719 <secondary>order of processing</secondary>
1720 </indexterm>
1721 The preconditions that are tested for each router are listed below, in the
1722 order in which they are tested. The individual configuration options are
1723 described in more detail in chapter <xref linkend="CHAProutergeneric"/>.
1724 </para>
1725 <itemizedlist>
1726 <listitem>
1727 <para>
1728 <indexterm role="concept">
1729 <primary>affix</primary>
1730 <secondary>router precondition</secondary>
1731 </indexterm>
1732 The <option>local_part_prefix</option> and <option>local_part_suffix</option> options can specify that
1733 the local parts handled by the router may or must have certain prefixes and/or
1734 suffixes. If a mandatory affix (prefix or suffix) is not present, the router is
1735 skipped. These conditions are tested first. When an affix is present, it is
1736 removed from the local part before further processing, including the evaluation
1737 of any other conditions.
1738 </para>
1739 </listitem>
1740 <listitem>
1741 <para>
1742 Routers can be designated for use only when not verifying an address, that is,
1743 only when routing it for delivery (or testing its delivery routing). If the
1744 <option>verify</option> option is set false, the router is skipped when Exim is verifying an
1745 address.
1746 Setting the <option>verify</option> option actually sets two options, <option>verify_sender</option> and
1747 <option>verify_recipient</option>, which independently control the use of the router for
1748 sender and recipient verification. You can set these options directly if
1749 you want a router to be used for only one type of verification.
1750 Note that cutthrough delivery is classed as a recipient verification for this purpose.
1751 </para>
1752 </listitem>
1753 <listitem>
1754 <para>
1755 If the <option>address_test</option> option is set false, the router is skipped when Exim is
1756 run with the <option>-bt</option> option to test an address routing. This can be helpful
1757 when the first router sends all new messages to a scanner of some sort; it
1758 makes it possible to use <option>-bt</option> to test subsequent delivery routing without
1759 having to simulate the effect of the scanner.
1760 </para>
1761 </listitem>
1762 <listitem>
1763 <para>
1764 Routers can be designated for use only when verifying an address, as
1765 opposed to routing it for delivery. The <option>verify_only</option> option controls this.
1766 Again, cutthrough delivery counts as a verification.
1767 </para>
1768 </listitem>
1769 <listitem>
1770 <para>
1771 Individual routers can be explicitly skipped when running the routers to
1772 check an address given in the SMTP EXPN command (see the <option>expn</option> option).
1773 </para>
1774 </listitem>
1775 <listitem>
1776 <para>
1777 If the <option>domains</option> option is set, the domain of the address must be in the set
1778 of domains that it defines.
1779 </para>
1780 </listitem>
1781 <listitem>
1782 <para>
1783 <indexterm role="variable">
1784 <primary><varname>$local_part_prefix</varname></primary>
1785 </indexterm>
1786 <indexterm role="variable">
1787 <primary><varname>$local_part</varname></primary>
1788 </indexterm>
1789 <indexterm role="variable">
1790 <primary><varname>$local_part_suffix</varname></primary>
1791 </indexterm>
1792 <indexterm role="concept">
1793 <primary>affix</primary>
1794 <secondary>router precondition</secondary>
1795 </indexterm>
1796 If the <option>local_parts</option> option is set, the local part of the address must be in
1797 the set of local parts that it defines. If <option>local_part_prefix</option> or
1798 <option>local_part_suffix</option> is in use, the prefix or suffix is removed from the local
1799 part before this check. If you want to do precondition tests on local parts
1800 that include affixes, you can do so by using a <option>condition</option> option (see below)
1801 that uses the variables <varname>$local_part</varname>, <varname>$local_part_prefix</varname>, and
1802 <varname>$local_part_suffix</varname> as necessary.
1803 </para>
1804 </listitem>
1805 <listitem>
1806 <para>
1807 <indexterm role="variable">
1808 <primary><varname>$local_user_uid</varname></primary>
1809 </indexterm>
1810 <indexterm role="variable">
1811 <primary><varname>$local_user_gid</varname></primary>
1812 </indexterm>
1813 <indexterm role="variable">
1814 <primary><varname>$home</varname></primary>
1815 </indexterm>
1816 If the <option>check_local_user</option> option is set, the local part must be the name of
1817 an account on the local host. If this check succeeds, the uid and gid of the
1818 local user are placed in <varname>$local_user_uid</varname> and <varname>$local_user_gid</varname> and the
1819 user&#x2019;s home directory is placed in <varname>$home</varname>; these values can be used in the
1820 remaining preconditions.
1821 </para>
1822 </listitem>
1823 <listitem>
1824 <para>
1825 If the <option>router_home_directory</option> option is set, it is expanded at this point,
1826 because it overrides the value of <varname>$home</varname>. If this expansion were left till
1827 later, the value of <varname>$home</varname> as set by <option>check_local_user</option> would be used in
1828 subsequent tests. Having two different values of <varname>$home</varname> in the same router
1829 could lead to confusion.
1830 </para>
1831 </listitem>
1832 <listitem>
1833 <para>
1834 If the <option>senders</option> option is set, the envelope sender address must be in the
1835 set of addresses that it defines.
1836 </para>
1837 </listitem>
1838 <listitem>
1839 <para>
1840 If the <option>require_files</option> option is set, the existence or non-existence of
1841 specified files is tested.
1842 </para>
1843 </listitem>
1844 <listitem>
1845 <para>
1846 <indexterm role="concept">
1847 <primary>customizing</primary>
1848 <secondary>precondition</secondary>
1849 </indexterm>
1850 If the <option>condition</option> option is set, it is evaluated and tested. This option
1851 uses an expanded string to allow you to set up your own custom preconditions.
1852 Expanded strings are described in chapter <xref linkend="CHAPexpand"/>.
1853 </para>
1854 </listitem>
1855 </itemizedlist>
1856 <para>
1857 Note that <option>require_files</option> comes near the end of the list, so you cannot use
1858 it to check for the existence of a file in which to lookup up a domain, local
1859 part, or sender. However, as these options are all expanded, you can use the
1860 <option>exists</option> expansion condition to make such tests within each condition. The
1861 <option>require_files</option> option is intended for checking files that the router may be
1862 going to use internally, or which are needed by a specific transport (for
1863 example, <filename>.procmailrc</filename>).
1864 </para>
1865 </section>
1866 <section id="SECID18">
1867 <title>Delivery in detail</title>
1868 <para>
1869 <indexterm role="concept">
1870 <primary>delivery</primary>
1871 <secondary>in detail</secondary>
1872 </indexterm>
1873 When a message is to be delivered, the sequence of events is as follows:
1874 </para>
1875 <itemizedlist>
1876 <listitem>
1877 <para>
1878 If a system-wide filter file is specified, the message is passed to it. The
1879 filter may add recipients to the message, replace the recipients, discard the
1880 message, cause a new message to be generated, or cause the message delivery to
1881 fail. The format of the system filter file is the same as for Exim user filter
1882 files, described in the separate document entitled <emphasis>Exim&#x2019;s interfaces to mail
1883 filtering</emphasis>.
1884 <indexterm role="concept">
1885 <primary>Sieve filter</primary>
1886 <secondary>not available for system filter</secondary>
1887 </indexterm>
1888 (<emphasis role="bold">Note</emphasis>: Sieve cannot be used for system filter files.)
1889 </para>
1890 <para>
1891 Some additional features are available in system filters &ndash; see chapter
1892 <xref linkend="CHAPsystemfilter"/> for details. Note that a message is passed to the system
1893 filter only once per delivery attempt, however many recipients it has. However,
1894 if there are several delivery attempts because one or more addresses could not
1895 be immediately delivered, the system filter is run each time. The filter
1896 condition <option>first_delivery</option> can be used to detect the first run of the system
1897 filter.
1898 </para>
1899 </listitem>
1900 <listitem>
1901 <para>
1902 Each recipient address is offered to each configured router, in turn, subject to
1903 its preconditions, until one is able to handle it. If no router can handle the
1904 address, that is, if they all decline, the address is failed. Because routers
1905 can be targeted at particular domains, several locally handled domains can be
1906 processed entirely independently of each other.
1907 </para>
1908 </listitem>
1909 <listitem>
1910 <para>
1911 <indexterm role="concept">
1912 <primary>routing</primary>
1913 <secondary>loops in</secondary>
1914 </indexterm>
1915 <indexterm role="concept">
1916 <primary>loop</primary>
1917 <secondary>while routing</secondary>
1918 </indexterm>
1919 A router that accepts an address may assign it to a local or a remote
1920 transport. However, the transport is not run at this time. Instead, the address
1921 is placed on a list for the particular transport, which will be run later.
1922 Alternatively, the router may generate one or more new addresses (typically
1923 from alias, forward, or filter files). New addresses are fed back into this
1924 process from the top, but in order to avoid loops, a router ignores any address
1925 which has an identically-named ancestor that was processed by itself.
1926 </para>
1927 </listitem>
1928 <listitem>
1929 <para>
1930 When all the routing has been done, addresses that have been successfully
1931 handled are passed to their assigned transports. When local transports are
1932 doing real local deliveries, they handle only one address at a time, but if a
1933 local transport is being used as a pseudo-remote transport (for example, to
1934 collect batched SMTP messages for transmission by some other means) multiple
1935 addresses can be handled. Remote transports can always handle more than one
1936 address at a time, but can be configured not to do so, or to restrict multiple
1937 addresses to the same domain.
1938 </para>
1939 </listitem>
1940 <listitem>
1941 <para>
1942 Each local delivery to a file or a pipe runs in a separate process under a
1943 non-privileged uid, and these deliveries are run one at a time. Remote
1944 deliveries also run in separate processes, normally under a uid that is private
1945 to Exim (<quote>the Exim user</quote>), but in this case, several remote deliveries can be
1946 run in parallel. The maximum number of simultaneous remote deliveries for any
1947 one message is set by the <option>remote_max_parallel</option> option.
1948 The order in which deliveries are done is not defined, except that all local
1949 deliveries happen before any remote deliveries.
1950 </para>
1951 </listitem>
1952 <listitem>
1953 <para>
1954 <indexterm role="concept">
1955 <primary>queue runner</primary>
1956 </indexterm>
1957 When it encounters a local delivery during a queue run, Exim checks its retry
1958 database to see if there has been a previous temporary delivery failure for the
1959 address before running the local transport. If there was a previous failure,
1960 Exim does not attempt a new delivery until the retry time for the address is
1961 reached. However, this happens only for delivery attempts that are part of a
1962 queue run. Local deliveries are always attempted when delivery immediately
1963 follows message reception, even if retry times are set for them. This makes for
1964 better behaviour if one particular message is causing problems (for example,
1965 causing quota overflow, or provoking an error in a filter file).
1966 </para>
1967 </listitem>
1968 <listitem>
1969 <para>
1970 <indexterm role="concept">
1971 <primary>delivery</primary>
1972 <secondary>retry in remote transports</secondary>
1973 </indexterm>
1974 Remote transports do their own retry handling, since an address may be
1975 deliverable to one of a number of hosts, each of which may have a different
1976 retry time. If there have been previous temporary failures and no host has
1977 reached its retry time, no delivery is attempted, whether in a queue run or
1978 not. See chapter <xref linkend="CHAPretry"/> for details of retry strategies.
1979 </para>
1980 </listitem>
1981 <listitem>
1982 <para>
1983 If there were any permanent errors, a bounce message is returned to an
1984 appropriate address (the sender in the common case), with details of the error
1985 for each failing address. Exim can be configured to send copies of bounce
1986 messages to other addresses.
1987 </para>
1988 </listitem>
1989 <listitem>
1990 <para>
1991 <indexterm role="concept">
1992 <primary>delivery</primary>
1993 <secondary>deferral</secondary>
1994 </indexterm>
1995 If one or more addresses suffered a temporary failure, the message is left on
1996 the queue, to be tried again later. Delivery of these addresses is said to be
1997 <emphasis>deferred</emphasis>.
1998 </para>
1999 </listitem>
2000 <listitem>
2001 <para>
2002 When all the recipient addresses have either been delivered or bounced,
2003 handling of the message is complete. The spool files and message log are
2004 deleted, though the message log can optionally be preserved if required.
2005 </para>
2006 </listitem>
2007 </itemizedlist>
2008 </section>
2009 <section id="SECID19">
2010 <title>Retry mechanism</title>
2011 <para>
2012 <indexterm role="concept">
2013 <primary>delivery</primary>
2014 <secondary>retry mechanism</secondary>
2015 </indexterm>
2016 <indexterm role="concept">
2017 <primary>retry</primary>
2018 <secondary>description of mechanism</secondary>
2019 </indexterm>
2020 <indexterm role="concept">
2021 <primary>queue runner</primary>
2022 </indexterm>
2023 Exim&#x2019;s mechanism for retrying messages that fail to get delivered at the first
2024 attempt is the queue runner process. You must either run an Exim daemon that
2025 uses the <option>-q</option> option with a time interval to start queue runners at regular
2026 intervals or use some other means (such as <emphasis>cron</emphasis>) to start them. If you do
2027 not arrange for queue runners to be run, messages that fail temporarily at the
2028 first attempt will remain in your queue forever. A queue runner process works
2029 its way through the queue, one message at a time, trying each delivery that has
2030 passed its retry time.
2031 You can run several queue runners at once.
2032 </para>
2033 <para>
2034 Exim uses a set of configured rules to determine when next to retry the failing
2035 address (see chapter <xref linkend="CHAPretry"/>). These rules also specify when Exim
2036 should give up trying to deliver to the address, at which point it generates a
2037 bounce message. If no retry rules are set for a particular host, address, and
2038 error combination, no retries are attempted, and temporary errors are treated
2039 as permanent.
2040 </para>
2041 </section>
2042 <section id="SECID20">
2043 <title>Temporary delivery failure</title>
2044 <para>
2045 <indexterm role="concept">
2046 <primary>delivery</primary>
2047 <secondary>temporary failure</secondary>
2048 </indexterm>
2049 There are many reasons why a message may not be immediately deliverable to a
2050 particular address. Failure to connect to a remote machine (because it, or the
2051 connection to it, is down) is one of the most common. Temporary failures may be
2052 detected during routing as well as during the transport stage of delivery.
2053 Local deliveries may be delayed if NFS files are unavailable, or if a mailbox
2054 is on a file system where the user is over quota. Exim can be configured to
2055 impose its own quotas on local mailboxes; where system quotas are set they will
2056 also apply.
2057 </para>
2058 <para>
2059 If a host is unreachable for a period of time, a number of messages may be
2060 waiting for it by the time it recovers, and sending them in a single SMTP
2061 connection is clearly beneficial. Whenever a delivery to a remote host is
2062 deferred,
2063 <indexterm role="concept">
2064 <primary>hints database</primary>
2065 <secondary>deferred deliveries</secondary>
2066 </indexterm>
2067 Exim makes a note in its hints database, and whenever a successful
2068 SMTP delivery has happened, it looks to see if any other messages are waiting
2069 for the same host. If any are found, they are sent over the same SMTP
2070 connection, subject to a configuration limit as to the maximum number in any
2071 one connection.
2072 </para>
2073 </section>
2074 <section id="SECID21">
2075 <title>Permanent delivery failure</title>
2076 <para>
2077 <indexterm role="concept">
2078 <primary>delivery</primary>
2079 <secondary>permanent failure</secondary>
2080 </indexterm>
2081 <indexterm role="concept">
2082 <primary>bounce message</primary>
2083 <secondary>when generated</secondary>
2084 </indexterm>
2085 When a message cannot be delivered to some or all of its intended recipients, a
2086 bounce message is generated. Temporary delivery failures turn into permanent
2087 errors when their timeout expires. All the addresses that fail in a given
2088 delivery attempt are listed in a single message. If the original message has
2089 many recipients, it is possible for some addresses to fail in one delivery
2090 attempt and others to fail subsequently, giving rise to more than one bounce
2091 message. The wording of bounce messages can be customized by the administrator.
2092 See chapter <xref linkend="CHAPemsgcust"/> for details.
2093 </para>
2094 <para>
2095 <indexterm role="concept">
2096 <primary><emphasis>X-Failed-Recipients:</emphasis> header line</primary>
2097 </indexterm>
2098 Bounce messages contain an <emphasis>X-Failed-Recipients:</emphasis> header line that lists the
2099 failed addresses, for the benefit of programs that try to analyse such messages
2100 automatically.
2101 </para>
2102 <para>
2103 <indexterm role="concept">
2104 <primary>bounce message</primary>
2105 <secondary>recipient of</secondary>
2106 </indexterm>
2107 A bounce message is normally sent to the sender of the original message, as
2108 obtained from the message&#x2019;s envelope. For incoming SMTP messages, this is the
2109 address given in the MAIL command. However, when an address is expanded via a
2110 forward or alias file, an alternative address can be specified for delivery
2111 failures of the generated addresses. For a mailing list expansion (see section
2112 <xref linkend="SECTmailinglists"/>) it is common to direct bounce messages to the manager
2113 of the list.
2114 </para>
2115 </section>
2116 <section id="SECID22">
2117 <title>Failures to deliver bounce messages</title>
2118 <para>
2119 <indexterm role="concept">
2120 <primary>bounce message</primary>
2121 <secondary>failure to deliver</secondary>
2122 </indexterm>
2123 If a bounce message (either locally generated or received from a remote host)
2124 itself suffers a permanent delivery failure, the message is left in the queue,
2125 but it is frozen, awaiting the attention of an administrator. There are options
2126 that can be used to make Exim discard such failed messages, or to keep them
2127 for only a short time (see <option>timeout_frozen_after</option> and
2128 <option>ignore_bounce_errors_after</option>).
2129 </para>
2130 </section>
2131 </chapter>
2132
2133 <chapter id="CHID3">
2134 <title>Building and installing Exim</title>
2135 <para>
2136 <indexterm role="concept" id="IIDbuex" class="startofrange">
2137 <primary>building Exim</primary>
2138 </indexterm>
2139 </para>
2140 <section id="SECID23">
2141 <title>Unpacking</title>
2142 <para>
2143 Exim is distributed as a gzipped or bzipped tar file which, when unpacked,
2144 creates a directory with the name of the current release (for example,
2145 <filename>exim-4.93</filename>) into which the following files are placed:
2146 </para>
2147 <informaltable frame="none">
2148 <tgroup cols="2" colsep="0" rowsep="0">
2149 <colspec colwidth="140pt" align="left"/>
2150 <colspec colwidth="254pt" align="left"/>
2151 <tbody>
2152 <row>
2153 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>ACKNOWLEDGMENTS</filename></entry>
2154 <entry>contains some acknowledgments</entry>
2155 </row>
2156 <row>
2157 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>CHANGES</filename></entry>
2158 <entry>contains a reference to where changes are documented</entry>
2159 </row>
2160 <row>
2161 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>LICENCE</filename></entry>
2162 <entry>the GNU General Public Licence</entry>
2163 </row>
2164 <row>
2165 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>Makefile</filename></entry>
2166 <entry>top-level make file</entry>
2167 </row>
2168 <row>
2169 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>NOTICE</filename></entry>
2170 <entry>conditions for the use of Exim</entry>
2171 </row>
2172 <row>
2173 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>README</filename></entry>
2174 <entry>list of files, directories and simple build instructions</entry>
2175 </row>
2176 </tbody>
2177 </tgroup>
2178 </informaltable>
2179 <para>
2180 Other files whose names begin with <filename>README</filename> may also be present. The
2181 following subdirectories are created:
2182 </para>
2183 <informaltable frame="none">
2184 <tgroup cols="2" colsep="0" rowsep="0">
2185 <colspec colwidth="140pt" align="left"/>
2186 <colspec colwidth="254pt" align="left"/>
2187 <tbody>
2188 <row>
2189 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>Local</filename></entry>
2190 <entry>an empty directory for local configuration files</entry>
2191 </row>
2192 <row>
2193 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>OS</filename></entry>
2194 <entry>OS-specific files</entry>
2195 </row>
2196 <row>
2197 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>doc</filename></entry>
2198 <entry>documentation files</entry>
2199 </row>
2200 <row>
2201 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>exim_monitor</filename></entry>
2202 <entry>source files for the Exim monitor</entry>
2203 </row>
2204 <row>
2205 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>scripts</filename></entry>
2206 <entry>scripts used in the build process</entry>
2207 </row>
2208 <row>
2209 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>src</filename></entry>
2210 <entry>remaining source files</entry>
2211 </row>
2212 <row>
2213 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>util</filename></entry>
2214 <entry>independent utilities</entry>
2215 </row>
2216 </tbody>
2217 </tgroup>
2218 </informaltable>
2219 <para>
2220 The main utility programs are contained in the <filename>src</filename> directory and are built
2221 with the Exim binary. The <filename>util</filename> directory contains a few optional scripts
2222 that may be useful to some sites.
2223 </para>
2224 </section>
2225 <section id="SECID24">
2226 <title>Multiple machine architectures and operating systems</title>
2227 <para>
2228 <indexterm role="concept">
2229 <primary>building Exim</primary>
2230 <secondary>multiple OS/architectures</secondary>
2231 </indexterm>
2232 The building process for Exim is arranged to make it easy to build binaries for
2233 a number of different architectures and operating systems from the same set of
2234 source files. Compilation does not take place in the <filename>src</filename> directory.
2235 Instead, a <emphasis>build directory</emphasis> is created for each architecture and operating
2236 system.
2237 <indexterm role="concept">
2238 <primary>symbolic link</primary>
2239 <secondary>to build directory</secondary>
2240 </indexterm>
2241 Symbolic links to the sources are installed in this directory, which is where
2242 the actual building takes place. In most cases, Exim can discover the machine
2243 architecture and operating system for itself, but the defaults can be
2244 overridden if necessary.
2245 <indexterm role="concept">
2246 <primary>compiler</primary>
2247 <secondary>requirements</secondary>
2248 </indexterm>
2249 <indexterm role="concept">
2250 <primary>compiler</primary>
2251 <secondary>version</secondary>
2252 </indexterm>
2253 A C99-capable compiler will be required for the build.
2254 </para>
2255 </section>
2256 <section id="SECTpcre">
2257 <title>PCRE library</title>
2258 <para>
2259 <indexterm role="concept">
2260 <primary>PCRE library</primary>
2261 </indexterm>
2262 Exim no longer has an embedded PCRE library as the vast majority of
2263 modern systems include PCRE as a system library, although you may need to
2264 install the PCRE package or the PCRE development package for your operating
2265 system. If your system has a normal PCRE installation the Exim build
2266 process will need no further configuration. If the library or the
2267 headers are in an unusual location you will need to either set the PCRE_LIBS
2268 and INCLUDE directives appropriately,
2269 or set PCRE_CONFIG=yes to use the installed <command>pcre-config</command> command.
2270 If your operating system has no
2271 PCRE support then you will need to obtain and build the current PCRE
2272 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>.
2273 More information on PCRE is available at <emphasis role="bold"><ulink url="https://www.pcre.org/">https://www.pcre.org/</ulink></emphasis>.
2274 </para>
2275 </section>
2276 <section id="SECTdb">
2277 <title>DBM libraries</title>
2278 <para>
2279 <indexterm role="concept">
2280 <primary>DBM libraries</primary>
2281 <secondary>discussion of</secondary>
2282 </indexterm>
2283 <indexterm role="concept">
2284 <primary>hints database</primary>
2285 <secondary>DBM files used for</secondary>
2286 </indexterm>
2287 Even if you do not use any DBM files in your configuration, Exim still needs a
2288 DBM library in order to operate, because it uses indexed files for its hints
2289 databases. Unfortunately, there are a number of DBM libraries in existence, and
2290 different operating systems often have different ones installed.
2291 </para>
2292 <para>
2293 <indexterm role="concept">
2294 <primary>Solaris</primary>
2295 <secondary>DBM library for</secondary>
2296 </indexterm>
2297 <indexterm role="concept">
2298 <primary>IRIX, DBM library for</primary>
2299 </indexterm>
2300 <indexterm role="concept">
2301 <primary>BSD, DBM library for</primary>
2302 </indexterm>
2303 <indexterm role="concept">
2304 <primary>Linux, DBM library for</primary>
2305 </indexterm>
2306 If you are using Solaris, IRIX, one of the modern BSD systems, or a modern
2307 Linux distribution, the DBM configuration should happen automatically, and you
2308 may be able to ignore this section. Otherwise, you may have to learn more than
2309 you would like about DBM libraries from what follows.
2310 </para>
2311 <para>
2312 <indexterm role="concept">
2313 <primary><emphasis>ndbm</emphasis> DBM library</primary>
2314 </indexterm>
2315 Licensed versions of Unix normally contain a library of DBM functions operating
2316 via the <emphasis>ndbm</emphasis> interface, and this is what Exim expects by default. Free
2317 versions of Unix seem to vary in what they contain as standard. In particular,
2318 some early versions of Linux have no default DBM library, and different
2319 distributors have chosen to bundle different libraries with their packaged
2320 versions. However, the more recent releases seem to have standardized on the
2321 Berkeley DB library.
2322 </para>
2323 <para>
2324 Different DBM libraries have different conventions for naming the files they
2325 use. When a program opens a file called <filename>dbmfile</filename>, there are several
2326 possibilities:
2327 </para>
2328 <orderedlist numeration="arabic">
2329 <listitem>
2330 <para>
2331 A traditional <emphasis>ndbm</emphasis> implementation, such as that supplied as part of
2332 Solaris, operates on two files called <filename>dbmfile.dir</filename> and <filename>dbmfile.pag</filename>.
2333 </para>
2334 </listitem>
2335 <listitem>
2336 <para>
2337 <indexterm role="concept">
2338 <primary><emphasis>gdbm</emphasis> DBM library</primary>
2339 </indexterm>
2340 The GNU library, <emphasis>gdbm</emphasis>, operates on a single file. If used via its <emphasis>ndbm</emphasis>
2341 compatibility interface it makes two different hard links to it with names
2342 <filename>dbmfile.dir</filename> and <filename>dbmfile.pag</filename>, but if used via its native interface, the
2343 filename is used unmodified.
2344 </para>
2345 </listitem>
2346 <listitem>
2347 <para>
2348 <indexterm role="concept">
2349 <primary>Berkeley DB library</primary>
2350 </indexterm>
2351 The Berkeley DB package, if called via its <emphasis>ndbm</emphasis> compatibility interface,
2352 operates on a single file called <filename>dbmfile.db</filename>, but otherwise looks to the
2353 programmer exactly the same as the traditional <emphasis>ndbm</emphasis> implementation.
2354 </para>
2355 </listitem>
2356 <listitem>
2357 <para>
2358 If the Berkeley package is used in its native mode, it operates on a single
2359 file called <filename>dbmfile</filename>; the programmer&#x2019;s interface is somewhat different to
2360 the traditional <emphasis>ndbm</emphasis> interface.
2361 </para>
2362 </listitem>
2363 <listitem>
2364 <para>
2365 To complicate things further, there are several very different versions of the
2366 Berkeley DB package. Version 1.85 was stable for a very long time, releases
2367 2.<emphasis>x</emphasis> and 3.<emphasis>x</emphasis> were current for a while, but the latest versions when Exim last revamped support were numbered 4.<emphasis>x</emphasis>.
2368 Maintenance of some of the earlier releases has ceased. All versions of
2369 Berkeley DB could be obtained from
2370 <emphasis role="bold"><ulink url="http://www.sleepycat.com/">http://www.sleepycat.com/</ulink></emphasis>, which is now a redirect to their new owner&#x2019;s
2371 page with far newer versions listed.
2372 It is probably wise to plan to move your storage configurations away from
2373 Berkeley DB format, as today there are smaller and simpler alternatives more
2374 suited to Exim&#x2019;s usage model.
2375 </para>
2376 </listitem>
2377 <listitem>
2378 <para>
2379 <indexterm role="concept">
2380 <primary><emphasis>tdb</emphasis> DBM library</primary>
2381 </indexterm>
2382 Yet another DBM library, called <emphasis>tdb</emphasis>, is available from
2383 <emphasis role="bold"><ulink url="https://sourceforge.net/projects/tdb/files/">https://sourceforge.net/projects/tdb/files/</ulink></emphasis>. It has its own interface, and also
2384 operates on a single file.
2385 </para>
2386 </listitem>
2387 </orderedlist>
2388 <para>
2389 <indexterm role="concept">
2390 <primary>USE_DB</primary>
2391 </indexterm>
2392 <indexterm role="concept">
2393 <primary>DBM libraries</primary>
2394 <secondary>configuration for building</secondary>
2395 </indexterm>
2396 Exim and its utilities can be compiled to use any of these interfaces. In order
2397 to use any version of the Berkeley DB package in native mode, you must set
2398 USE_DB in an appropriate configuration file (typically
2399 <filename>Local/Makefile</filename>). For example:
2400 </para>
2401 <literallayout class="monospaced">
2402 USE_DB=yes
2403 </literallayout>
2404 <para>
2405 Similarly, for gdbm you set USE_GDBM, and for tdb you set USE_TDB. An
2406 error is diagnosed if you set more than one of these.
2407 </para>
2408 <para>
2409 At the lowest level, the build-time configuration sets none of these options,
2410 thereby assuming an interface of type (1). However, some operating system
2411 configuration files (for example, those for the BSD operating systems and
2412 Linux) assume type (4) by setting USE_DB as their default, and the
2413 configuration files for Cygwin set USE_GDBM. Anything you set in
2414 <filename>Local/Makefile</filename>, however, overrides these system defaults.
2415 </para>
2416 <para>
2417 As well as setting USE_DB, USE_GDBM, or USE_TDB, it may also be
2418 necessary to set DBMLIB, to cause inclusion of the appropriate library, as
2419 in one of these lines:
2420 </para>
2421 <literallayout class="monospaced">
2422 DBMLIB = -ldb
2423 DBMLIB = -ltdb
2424 </literallayout>
2425 <para>
2426 Settings like that will work if the DBM library is installed in the standard
2427 place. Sometimes it is not, and the library&#x2019;s header file may also not be in
2428 the default path. You may need to set INCLUDE to specify where the header
2429 file is, and to specify the path to the library more fully in DBMLIB, as in
2430 this example:
2431 </para>
2432 <literallayout class="monospaced">
2433 INCLUDE=-I/usr/local/include/db-4.1
2434 DBMLIB=/usr/local/lib/db-4.1/libdb.a
2435 </literallayout>
2436 <para>
2437 There is further detailed discussion about the various DBM libraries in the
2438 file <filename>doc/dbm.discuss.txt</filename> in the Exim distribution.
2439 </para>
2440 </section>
2441 <section id="SECID25">
2442 <title>Pre-building configuration</title>
2443 <para>
2444 <indexterm role="concept">
2445 <primary>building Exim</primary>
2446 <secondary>pre-building configuration</secondary>
2447 </indexterm>
2448 <indexterm role="concept">
2449 <primary>configuration for building Exim</primary>
2450 </indexterm>
2451 <indexterm role="concept">
2452 <primary><filename>Local/Makefile</filename></primary>
2453 </indexterm>
2454 <indexterm role="concept">
2455 <primary><filename>src/EDITME</filename></primary>
2456 </indexterm>
2457 Before building Exim, a local configuration file that specifies options
2458 independent of any operating system has to be created with the name
2459 <filename>Local/Makefile</filename>. A template for this file is supplied as the file
2460 <filename>src/EDITME</filename>, and it contains full descriptions of all the option settings
2461 therein. These descriptions are therefore not repeated here. If you are
2462 building Exim for the first time, the simplest thing to do is to copy
2463 <filename>src/EDITME</filename> to <filename>Local/Makefile</filename>, then read it and edit it appropriately.
2464 </para>
2465 <para>
2466 There are three settings that you must supply, because Exim will not build
2467 without them. They are the location of the runtime configuration file
2468 (CONFIGURE_FILE), the directory in which Exim binaries will be installed
2469 (BIN_DIRECTORY), and the identity of the Exim user (EXIM_USER and
2470 maybe EXIM_GROUP as well). The value of CONFIGURE_FILE can in fact be
2471 a colon-separated list of filenames; Exim uses the first of them that exists.
2472 </para>
2473 <para>
2474 There are a few other parameters that can be specified either at build time or
2475 at runtime, to enable the same binary to be used on a number of different
2476 machines. However, if the locations of Exim&#x2019;s spool directory and log file
2477 directory (if not within the spool directory) are fixed, it is recommended that
2478 you specify them in <filename>Local/Makefile</filename> instead of at runtime, so that errors
2479 detected early in Exim&#x2019;s execution (such as a malformed configuration file) can
2480 be logged.
2481 </para>
2482 <para>
2483 <indexterm role="concept">
2484 <primary>content scanning</primary>
2485 <secondary>specifying at build time</secondary>
2486 </indexterm>
2487 Exim&#x2019;s interfaces for calling virus and spam scanning software directly from
2488 access control lists are not compiled by default. If you want to include these
2489 facilities, you need to set
2490 </para>
2491 <literallayout class="monospaced">
2492 WITH_CONTENT_SCAN=yes
2493 </literallayout>
2494 <para>
2495 in your <filename>Local/Makefile</filename>. For details of the facilities themselves, see
2496 chapter <xref linkend="CHAPexiscan"/>.
2497 </para>
2498 <para>
2499 <indexterm role="concept">
2500 <primary><filename>Local/eximon.conf</filename></primary>
2501 </indexterm>
2502 <indexterm role="concept">
2503 <primary><filename>exim_monitor/EDITME</filename></primary>
2504 </indexterm>
2505 If you are going to build the Exim monitor, a similar configuration process is
2506 required. The file <filename>exim_monitor/EDITME</filename> must be edited appropriately for
2507 your installation and saved under the name <filename>Local/eximon.conf</filename>. If you are
2508 happy with the default settings described in <filename>exim_monitor/EDITME</filename>,
2509 <filename>Local/eximon.conf</filename> can be empty, but it must exist.
2510 </para>
2511 <para>
2512 This is all the configuration that is needed in straightforward cases for known
2513 operating systems. However, the building process is set up so that it is easy
2514 to override options that are set by default or by operating-system-specific
2515 configuration files, for example, to change the C compiler, which
2516 defaults to <option>gcc</option>. See section <xref linkend="SECToverride"/> below for details of how to
2517 do this.
2518 </para>
2519 </section>
2520 <section id="SECID26">
2521 <title>Support for iconv()</title>
2522 <para>
2523 <indexterm role="concept">
2524 <primary><function>iconv()</function> support</primary>
2525 </indexterm>
2526 <indexterm role="concept">
2527 <primary>RFC 2047</primary>
2528 </indexterm>
2529 The contents of header lines in messages may be encoded according to the rules
2530 described RFC 2047. This makes it possible to transmit characters that are not
2531 in the ASCII character set, and to label them as being in a particular
2532 character set. When Exim is inspecting header lines by means of the <option>$h_</option>
2533 mechanism, it decodes them, and translates them into a specified character set
2534 (default is set at build time). The translation is possible only if the operating system
2535 supports the <function>iconv()</function> function.
2536 </para>
2537 <para>
2538 However, some of the operating systems that supply <function>iconv()</function> do not support
2539 very many conversions. The GNU <option>libiconv</option> library (available from
2540 <emphasis role="bold"><ulink url="https://www.gnu.org/software/libiconv/">https://www.gnu.org/software/libiconv/</ulink></emphasis>) can be installed on such
2541 systems to remedy this deficiency, as well as on systems that do not supply
2542 <function>iconv()</function> at all. After installing <option>libiconv</option>, you should add
2543 </para>
2544 <literallayout class="monospaced">
2545 HAVE_ICONV=yes
2546 </literallayout>
2547 <para>
2548 to your <filename>Local/Makefile</filename> and rebuild Exim.
2549 </para>
2550 </section>
2551 <section id="SECTinctlsssl">
2552 <title>Including TLS/SSL encryption support</title>
2553 <para>
2554 <indexterm role="concept">
2555 <primary>TLS</primary>
2556 <secondary>including support for TLS</secondary>
2557 </indexterm>
2558 <indexterm role="concept">
2559 <primary>encryption</primary>
2560 <secondary>including support for</secondary>
2561 </indexterm>
2562 <indexterm role="concept">
2563 <primary>OpenSSL</primary>
2564 <secondary>building Exim with</secondary>
2565 </indexterm>
2566 <indexterm role="concept">
2567 <primary>GnuTLS</primary>
2568 <secondary>building Exim with</secondary>
2569 </indexterm>
2570 Exim is usually built to support encrypted SMTP connections, using the STARTTLS
2571 command as per RFC 2487. It can also support clients that expect to
2572 start a TLS session immediately on connection to a non-standard port (see the
2573 <option>tls_on_connect_ports</option> runtime option and the <option>-tls-on-connect</option> command
2574 line option).
2575 </para>
2576 <para>
2577 If you want to build Exim with TLS support, you must first install either the
2578 OpenSSL or GnuTLS library. There is no cryptographic code in Exim itself for
2579 implementing SSL.
2580 </para>
2581 <para revisionflag="changed">
2582 If you do not want TLS support you should set
2583 </para>
2584 <literallayout class="monospaced" revisionflag="changed">
2585 DISABLE_TLS=yes
2586 </literallayout>
2587 <para revisionflag="changed">
2588 in <filename>Local/Makefile</filename>.
2589 </para>
2590 <para revisionflag="changed">
2591 If OpenSSL is installed, you should set
2592 </para>
2593 <literallayout class="monospaced" revisionflag="changed">
2594 USE_OPENSL=yes
2595 TLS_LIBS=-lssl -lcrypto
2596 </literallayout>
2597 <para revisionflag="changed">
2598 in <filename>Local/Makefile</filename>. You may also need to specify the locations of the
2599 OpenSSL library and include files. For example:
2600 </para>
2601 <literallayout class="monospaced" revisionflag="changed">
2602 USE_OPENSSL=yes
2603 TLS_LIBS=-L/usr/local/openssl/lib -lssl -lcrypto
2604 TLS_INCLUDE=-I/usr/local/openssl/include/
2605 </literallayout>
2606 <para revisionflag="changed">
2607 <indexterm role="concept">
2608 <primary>pkg-config</primary>
2609 <secondary>OpenSSL</secondary>
2610 </indexterm>
2611 If you have <emphasis>pkg-config</emphasis> available, then instead you can just use:
2612 </para>
2613 <literallayout class="monospaced" revisionflag="changed">
2614 USE_OPENSSL=yes
2615 USE_OPENSSL_PC=openssl
2616 </literallayout>
2617 <para>
2618 <indexterm role="concept">
2619 <primary>USE_GNUTLS</primary>
2620 </indexterm>
2621 If GnuTLS is installed, you should set
2622 </para>
2623 <literallayout class="monospaced">
2624 USE_GNUTLS=yes
2625 TLS_LIBS=-lgnutls -ltasn1 -lgcrypt
2626 </literallayout>
2627 <para>
2628 in <filename>Local/Makefile</filename>, and again you may need to specify the locations of the
2629 library and include files. For example:
2630 </para>
2631 <literallayout class="monospaced">
2632 USE_GNUTLS=yes
2633 TLS_LIBS=-L/usr/gnu/lib -lgnutls -ltasn1 -lgcrypt
2634 TLS_INCLUDE=-I/usr/gnu/include
2635 </literallayout>
2636 <para>
2637 <indexterm role="concept">
2638 <primary>pkg-config</primary>
2639 <secondary>GnuTLS</secondary>
2640 </indexterm>
2641 If you have <emphasis>pkg-config</emphasis> available, then instead you can just use:
2642 </para>
2643 <literallayout class="monospaced">
2644 USE_GNUTLS=yes
2645 USE_GNUTLS_PC=gnutls
2646 </literallayout>
2647 <para>
2648 You do not need to set TLS_INCLUDE if the relevant directory is already
2649 specified in INCLUDE. Details of how to configure Exim to make use of TLS are
2650 given in chapter <xref linkend="CHAPTLS"/>.
2651 </para>
2652 </section>
2653 <section id="SECID27">
2654 <title>Use of tcpwrappers</title>
2655 <para>
2656 <indexterm role="concept">
2657 <primary>tcpwrappers, building Exim to support</primary>
2658 </indexterm>
2659 <indexterm role="concept">
2660 <primary>USE_TCP_WRAPPERS</primary>
2661 </indexterm>
2662 <indexterm role="concept">
2663 <primary>TCP_WRAPPERS_DAEMON_NAME</primary>
2664 </indexterm>
2665 <indexterm role="concept">
2666 <primary>tcp_wrappers_daemon_name</primary>
2667 </indexterm>
2668 Exim can be linked with the <emphasis>tcpwrappers</emphasis> library in order to check incoming
2669 SMTP calls using the <emphasis>tcpwrappers</emphasis> control files. This may be a convenient
2670 alternative to Exim&#x2019;s own checking facilities for installations that are
2671 already making use of <emphasis>tcpwrappers</emphasis> for other purposes. To do this, you
2672 should set USE_TCP_WRAPPERS in <filename>Local/Makefile</filename>, arrange for the file
2673 <filename>tcpd.h</filename> to be available at compile time, and also ensure that the library
2674 <filename>libwrap.a</filename> is available at link time, typically by including <option>-lwrap</option> in
2675 EXTRALIBS_EXIM. For example, if <emphasis>tcpwrappers</emphasis> is installed in <filename>/usr/local</filename>,
2676 you might have
2677 </para>
2678 <literallayout class="monospaced">
2679 USE_TCP_WRAPPERS=yes
2680 CFLAGS=-O -I/usr/local/include
2681 EXTRALIBS_EXIM=-L/usr/local/lib -lwrap
2682 </literallayout>
2683 <para>
2684 in <filename>Local/Makefile</filename>. The daemon name to use in the <emphasis>tcpwrappers</emphasis> control
2685 files is <quote>exim</quote>. For example, the line
2686 </para>
2687 <literallayout class="monospaced">
2688 exim : LOCAL  192.168.1.  .friendly.domain.example
2689 </literallayout>
2690 <para>
2691 in your <filename>/etc/hosts.allow</filename> file allows connections from the local host, from
2692 the subnet 192.168.1.0/24, and from all hosts in <emphasis>friendly.domain.example</emphasis>.
2693 All other connections are denied. The daemon name used by <emphasis>tcpwrappers</emphasis>
2694 can be changed at build time by setting TCP_WRAPPERS_DAEMON_NAME in
2695 <filename>Local/Makefile</filename>, or by setting tcp_wrappers_daemon_name in the
2696 configure file. Consult the <emphasis>tcpwrappers</emphasis> documentation for
2697 further details.
2698 </para>
2699 </section>
2700 <section id="SECID28">
2701 <title>Including support for IPv6</title>
2702 <para>
2703 <indexterm role="concept">
2704 <primary>IPv6</primary>
2705 <secondary>including support for</secondary>
2706 </indexterm>
2707 Exim contains code for use on systems that have IPv6 support. Setting
2708 <literal>HAVE_IPV6=YES</literal> in <filename>Local/Makefile</filename> causes the IPv6 code to be included;
2709 it may also be necessary to set IPV6_INCLUDE and IPV6_LIBS on systems
2710 where the IPv6 support is not fully integrated into the normal include and
2711 library files.
2712 </para>
2713 <para>
2714 Two different types of DNS record for handling IPv6 addresses have been
2715 defined. AAAA records (analogous to A records for IPv4) are in use, and are
2716 currently seen as the mainstream. Another record type called A6 was proposed
2717 as better than AAAA because it had more flexibility. However, it was felt to be
2718 over-complex, and its status was reduced to <quote>experimental</quote>.
2719 Exim used to
2720 have a compile option for including A6 record support but this has now been
2721 withdrawn.
2722 </para>
2723 </section>
2724 <section id="SECTdynamicmodules">
2725 <title>Dynamically loaded lookup module support</title>
2726 <para>
2727 <indexterm role="concept">
2728 <primary>lookup modules</primary>
2729 </indexterm>
2730 <indexterm role="concept">
2731 <primary>dynamic modules</primary>
2732 </indexterm>
2733 <indexterm role="concept">
2734 <primary>.so building</primary>
2735 </indexterm>
2736 On some platforms, Exim supports not compiling all lookup types directly into
2737 the main binary, instead putting some into external modules which can be loaded
2738 on demand.
2739 This permits packagers to build Exim with support for lookups with extensive
2740 library dependencies without requiring all users to install all of those
2741 dependencies.
2742 Most, but not all, lookup types can be built this way.
2743 </para>
2744 <para>
2745 Set <literal>LOOKUP_MODULE_DIR</literal> to the directory into which the modules will be
2746 installed; Exim will only load modules from that directory, as a security
2747 measure.  You will need to set <literal>CFLAGS_DYNAMIC</literal> if not already defined
2748 for your OS; see <filename>OS/Makefile-Linux</filename> for an example.
2749 Some other requirements for adjusting <literal>EXTRALIBS</literal> may also be necessary,
2750 see <filename>src/EDITME</filename> for details.
2751 </para>
2752 <para>
2753 Then, for each module to be loaded dynamically, define the relevant
2754 <literal>LOOKUP_</literal>&lt;<emphasis>lookup_type</emphasis>&gt; flags to have the value "2" instead of "yes".
2755 For example, this will build in lsearch but load sqlite and mysql support
2756 on demand:
2757 </para>
2758 <literallayout class="monospaced">
2759 LOOKUP_LSEARCH=yes
2760 LOOKUP_SQLITE=2
2761 LOOKUP_MYSQL=2
2762 </literallayout>
2763 </section>
2764 <section id="SECID29">
2765 <title>The building process</title>
2766 <para>
2767 <indexterm role="concept">
2768 <primary>build directory</primary>
2769 </indexterm>
2770 Once <filename>Local/Makefile</filename> (and <filename>Local/eximon.conf</filename>, if required) have been
2771 created, run <emphasis>make</emphasis> at the top level. It determines the architecture and
2772 operating system types, and creates a build directory if one does not exist.
2773 For example, on a Sun system running Solaris 8, the directory
2774 <filename>build-SunOS5-5.8-sparc</filename> is created.
2775 <indexterm role="concept">
2776 <primary>symbolic link</primary>
2777 <secondary>to source files</secondary>
2778 </indexterm>
2779 Symbolic links to relevant source files are installed in the build directory.
2780 </para>
2781 <para>
2782 If this is the first time <emphasis>make</emphasis> has been run, it calls a script that builds
2783 a make file inside the build directory, using the configuration files from the
2784 <filename>Local</filename> directory. The new make file is then passed to another instance of
2785 <emphasis>make</emphasis>. This does the real work, building a number of utility scripts, and
2786 then compiling and linking the binaries for the Exim monitor (if configured), a
2787 number of utility programs, and finally Exim itself. The command <literal>make
2788 makefile</literal> can be used to force a rebuild of the make file in the build
2789 directory, should this ever be necessary.
2790 </para>
2791 <para>
2792 If you have problems building Exim, check for any comments there may be in the
2793 <filename>README</filename> file concerning your operating system, and also take a look at the
2794 FAQ, where some common problems are covered.
2795 </para>
2796 </section>
2797 <section id="SECID283">
2798 <title>Output from <quote>make</quote></title>
2799 <para>
2800 The output produced by the <emphasis>make</emphasis> process for compile lines is often very
2801 unreadable, because these lines can be very long. For this reason, the normal
2802 output is suppressed by default, and instead output similar to that which
2803 appears when compiling the 2.6 Linux kernel is generated: just a short line for
2804 each module that is being compiled or linked. However, it is still possible to
2805 get the full output, by calling <emphasis>make</emphasis> like this:
2806 </para>
2807 <literallayout class="monospaced">
2808 FULLECHO='' make -e
2809 </literallayout>
2810 <para>
2811 The value of FULLECHO defaults to <quote>@</quote>, the flag character that suppresses
2812 command reflection in <emphasis>make</emphasis>. When you ask for the full output, it is
2813 given in addition to the short output.
2814 </para>
2815 </section>
2816 <section id="SECToverride">
2817 <title>Overriding build-time options for Exim</title>
2818 <para>
2819 <indexterm role="concept">
2820 <primary>build-time options, overriding</primary>
2821 </indexterm>
2822 The main make file that is created at the beginning of the building process
2823 consists of the concatenation of a number of files which set configuration
2824 values, followed by a fixed set of <emphasis>make</emphasis> instructions. If a value is set
2825 more than once, the last setting overrides any previous ones. This provides a
2826 convenient way of overriding defaults. The files that are concatenated are, in
2827 order:
2828 </para>
2829 <literallayout>
2830 <filename>OS/Makefile-Default</filename>
2831 <filename>OS/Makefile-</filename>&lt;<emphasis>ostype</emphasis>&gt;
2832 <filename>Local/Makefile</filename>
2833 <filename>Local/Makefile-</filename>&lt;<emphasis>ostype</emphasis>&gt;
2834 <filename>Local/Makefile-</filename>&lt;<emphasis>archtype</emphasis>&gt;
2835 <filename>Local/Makefile-</filename>&lt;<emphasis>ostype</emphasis>&gt;-&lt;<emphasis>archtype</emphasis>&gt;
2836 <filename>OS/Makefile-Base</filename>
2837 </literallayout>
2838 <para>
2839 <indexterm role="concept">
2840 <primary><filename>Local/Makefile</filename></primary>
2841 </indexterm>
2842 <indexterm role="concept">
2843 <primary>building Exim</primary>
2844 <secondary>operating system type</secondary>
2845 </indexterm>
2846 <indexterm role="concept">
2847 <primary>building Exim</primary>
2848 <secondary>architecture type</secondary>
2849 </indexterm>
2850 where &lt;<emphasis>ostype</emphasis>&gt; is the operating system type and &lt;<emphasis>archtype</emphasis>&gt; is the
2851 architecture type. <filename>Local/Makefile</filename> is required to exist, and the building
2852 process fails if it is absent. The other three <filename>Local</filename> files are optional,
2853 and are often not needed.
2854 </para>
2855 <para>
2856 The values used for &lt;<emphasis>ostype</emphasis>&gt; and &lt;<emphasis>archtype</emphasis>&gt; are obtained from scripts
2857 called <filename>scripts/os-type</filename> and <filename>scripts/arch-type</filename> respectively. If either of
2858 the environment variables EXIM_OSTYPE or EXIM_ARCHTYPE is set, their
2859 values are used, thereby providing a means of forcing particular settings.
2860 Otherwise, the scripts try to get values from the <option>uname</option> command. If this
2861 fails, the shell variables OSTYPE and ARCHTYPE are inspected. A number
2862 of <emphasis>ad hoc</emphasis> transformations are then applied, to produce the standard names
2863 that Exim expects. You can run these scripts directly from the shell in order
2864 to find out what values are being used on your system.
2865 </para>
2866 <para>
2867 <filename>OS/Makefile-Default</filename> contains comments about the variables that are set
2868 therein. Some (but not all) are mentioned below. If there is something that
2869 needs changing, review the contents of this file and the contents of the make
2870 file for your operating system (<filename>OS/Makefile-&lt;ostype&gt;</filename>) to see what the
2871 default values are.
2872 </para>
2873 <para>
2874 <indexterm role="concept">
2875 <primary>building Exim</primary>
2876 <secondary>overriding default settings</secondary>
2877 </indexterm>
2878 If you need to change any of the values that are set in <filename>OS/Makefile-Default</filename>
2879 or in <filename>OS/Makefile-&lt;ostype&gt;</filename>, or to add any new definitions, you do not
2880 need to change the original files. Instead, you should make the changes by
2881 putting the new values in an appropriate <filename>Local</filename> file. For example,
2882 <indexterm role="concept">
2883 <primary>Tru64-Unix build-time settings</primary>
2884 </indexterm>
2885 when building Exim in many releases of the Tru64-Unix (formerly Digital UNIX,
2886 formerly DEC-OSF1) operating system, it is necessary to specify that the C
2887 compiler is called <emphasis>cc</emphasis> rather than <emphasis>gcc</emphasis>. Also, the compiler must be
2888 called with the option <option>-std1</option>, to make it recognize some of the features of
2889 Standard C that Exim uses. (Most other compilers recognize Standard C by
2890 default.) To do this, you should create a file called <filename>Local/Makefile-OSF1</filename>
2891 containing the lines
2892 </para>
2893 <literallayout class="monospaced">
2894 CC=cc
2895 CFLAGS=-std1
2896 </literallayout>
2897 <para>
2898 If you are compiling for just one operating system, it may be easier to put
2899 these lines directly into <filename>Local/Makefile</filename>.
2900 </para>
2901 <para>
2902 Keeping all your local configuration settings separate from the distributed
2903 files makes it easy to transfer them to new versions of Exim simply by copying
2904 the contents of the <filename>Local</filename> directory.
2905 </para>
2906 <para>
2907 <indexterm role="concept">
2908 <primary>NIS lookup type</primary>
2909 <secondary>including support for</secondary>
2910 </indexterm>
2911 <indexterm role="concept">
2912 <primary>NIS+ lookup type</primary>
2913 <secondary>including support for</secondary>
2914 </indexterm>
2915 <indexterm role="concept">
2916 <primary>LDAP</primary>
2917 <secondary>including support for</secondary>
2918 </indexterm>
2919 <indexterm role="concept">
2920 <primary>lookup</primary>
2921 <secondary>inclusion in binary</secondary>
2922 </indexterm>
2923 Exim contains support for doing LDAP, NIS, NIS+, and other kinds of file
2924 lookup, but not all systems have these components installed, so the default is
2925 not to include the relevant code in the binary. All the different kinds of file
2926 and database lookup that Exim supports are implemented as separate code modules
2927 which are included only if the relevant compile-time options are set. In the
2928 case of LDAP, NIS, and NIS+, the settings for <filename>Local/Makefile</filename> are:
2929 </para>
2930 <literallayout class="monospaced">
2931 LOOKUP_LDAP=yes
2932 LOOKUP_NIS=yes
2933 LOOKUP_NISPLUS=yes
2934 </literallayout>
2935 <para>
2936 and similar settings apply to the other lookup types. They are all listed in
2937 <filename>src/EDITME</filename>. In many cases the relevant include files and interface
2938 libraries need to be installed before compiling Exim.
2939 <indexterm role="concept">
2940 <primary>cdb</primary>
2941 <secondary>including support for</secondary>
2942 </indexterm>
2943 However, there are some optional lookup types (such as cdb) for which
2944 the code is entirely contained within Exim, and no external include
2945 files or libraries are required. When a lookup type is not included in the
2946 binary, attempts to configure Exim to use it cause runtime configuration
2947 errors.
2948 </para>
2949 <para>
2950 <indexterm role="concept">
2951 <primary>pkg-config</primary>
2952 <secondary>lookups</secondary>
2953 </indexterm>
2954 <indexterm role="concept">
2955 <primary>pkg-config</primary>
2956 <secondary>authenticators</secondary>
2957 </indexterm>
2958 Many systems now use a tool called <emphasis>pkg-config</emphasis> to encapsulate information
2959 about how to compile against a library; Exim has some initial support for
2960 being able to use pkg-config for lookups and authenticators.  For any given
2961 makefile variable which starts <literal>LOOKUP_</literal> or <literal>AUTH_</literal>, you can add a new
2962 variable with the <literal>_PC</literal> suffix in the name and assign as the value the
2963 name of the package to be queried.  The results of querying via the
2964 <emphasis>pkg-config</emphasis> command will be added to the appropriate Makefile variables
2965 with <literal>+=</literal> directives, so your version of <emphasis>make</emphasis> will need to support that
2966 syntax.  For instance:
2967 </para>
2968 <literallayout class="monospaced">
2969 LOOKUP_SQLITE=yes
2970 LOOKUP_SQLITE_PC=sqlite3
2971 AUTH_GSASL=yes
2972 AUTH_GSASL_PC=libgsasl
2973 AUTH_HEIMDAL_GSSAPI=yes
2974 AUTH_HEIMDAL_GSSAPI_PC=heimdal-gssapi
2975 </literallayout>
2976 <para>
2977 <indexterm role="concept">
2978 <primary>Perl</primary>
2979 <secondary>including support for</secondary>
2980 </indexterm>
2981 Exim can be linked with an embedded Perl interpreter, allowing Perl
2982 subroutines to be called during string expansion. To enable this facility,
2983 </para>
2984 <literallayout class="monospaced">
2985 EXIM_PERL=perl.o
2986 </literallayout>
2987 <para>
2988 must be defined in <filename>Local/Makefile</filename>. Details of this facility are given in
2989 chapter <xref linkend="CHAPperl"/>.
2990 </para>
2991 <para>
2992 <indexterm role="concept">
2993 <primary>X11 libraries, location of</primary>
2994 </indexterm>
2995 The location of the X11 libraries is something that varies a lot between
2996 operating systems, and there may be different versions of X11 to cope
2997 with. Exim itself makes no use of X11, but if you are compiling the Exim
2998 monitor, the X11 libraries must be available.
2999 The following three variables are set in <filename>OS/Makefile-Default</filename>:
3000 </para>
3001 <literallayout class="monospaced">
3002 X11=/usr/X11R6
3003 XINCLUDE=-I$(X11)/include
3004 XLFLAGS=-L$(X11)/lib
3005 </literallayout>
3006 <para>
3007 These are overridden in some of the operating-system configuration files. For
3008 example, in <filename>OS/Makefile-SunOS5</filename> there is
3009 </para>
3010 <literallayout class="monospaced">
3011 X11=/usr/openwin
3012 XINCLUDE=-I$(X11)/include
3013 XLFLAGS=-L$(X11)/lib -R$(X11)/lib
3014 </literallayout>
3015 <para>
3016 If you need to override the default setting for your operating system, place a
3017 definition of all three of these variables into your
3018 <filename>Local/Makefile-&lt;ostype&gt;</filename> file.
3019 </para>
3020 <para>
3021 <indexterm role="concept">
3022 <primary>EXTRALIBS</primary>
3023 </indexterm>
3024 If you need to add any extra libraries to the link steps, these can be put in a
3025 variable called EXTRALIBS, which appears in all the link commands, but by
3026 default is not defined. In contrast, EXTRALIBS_EXIM is used only on the
3027 command for linking the main Exim binary, and not for any associated utilities.
3028 </para>
3029 <para>
3030 <indexterm role="concept">
3031 <primary>DBM libraries</primary>
3032 <secondary>configuration for building</secondary>
3033 </indexterm>
3034 There is also DBMLIB, which appears in the link commands for binaries that
3035 use DBM functions (see also section <xref linkend="SECTdb"/>). Finally, there is
3036 EXTRALIBS_EXIMON, which appears only in the link step for the Exim monitor
3037 binary, and which can be used, for example, to include additional X11
3038 libraries.
3039 </para>
3040 <para>
3041 <indexterm role="concept">
3042 <primary>configuration file</primary>
3043 <secondary>editing</secondary>
3044 </indexterm>
3045 The make file copes with rebuilding Exim correctly if any of the configuration
3046 files are edited. However, if an optional configuration file is deleted, it is
3047 necessary to touch the associated non-optional file (that is,
3048 <filename>Local/Makefile</filename> or <filename>Local/eximon.conf</filename>) before rebuilding.
3049 </para>
3050 </section>
3051 <section id="SECID30">
3052 <title>OS-specific header files</title>
3053 <para>
3054 <indexterm role="concept">
3055 <primary><filename>os.h</filename></primary>
3056 </indexterm>
3057 <indexterm role="concept">
3058 <primary>building Exim</primary>
3059 <secondary>OS-specific C header files</secondary>
3060 </indexterm>
3061 The <filename>OS</filename> directory contains a number of files with names of the form
3062 <filename>os.h-&lt;ostype&gt;</filename>. These are system-specific C header files that should not
3063 normally need to be changed. There is a list of macro settings that are
3064 recognized in the file <filename>OS/os.configuring</filename>, which should be consulted if you
3065 are porting Exim to a new operating system.
3066 </para>
3067 </section>
3068 <section id="SECID31">
3069 <title>Overriding build-time options for the monitor</title>
3070 <para>
3071 <indexterm role="concept">
3072 <primary>building Eximon</primary>
3073 </indexterm>
3074 A similar process is used for overriding things when building the Exim monitor,
3075 where the files that are involved are
3076 </para>
3077 <literallayout>
3078 <filename>OS/eximon.conf-Default</filename>
3079 <filename>OS/eximon.conf-</filename>&lt;<emphasis>ostype</emphasis>&gt;
3080 <filename>Local/eximon.conf</filename>
3081 <filename>Local/eximon.conf-</filename>&lt;<emphasis>ostype</emphasis>&gt;
3082 <filename>Local/eximon.conf-</filename>&lt;<emphasis>archtype</emphasis>&gt;
3083 <filename>Local/eximon.conf-</filename>&lt;<emphasis>ostype</emphasis>&gt;-&lt;<emphasis>archtype</emphasis>&gt;
3084 </literallayout>
3085 <para>
3086 <indexterm role="concept">
3087 <primary><filename>Local/eximon.conf</filename></primary>
3088 </indexterm>
3089 As with Exim itself, the final three files need not exist, and in this case the
3090 <filename>OS/eximon.conf-&lt;ostype&gt;</filename> file is also optional. The default values in
3091 <filename>OS/eximon.conf-Default</filename> can be overridden dynamically by setting environment
3092 variables of the same name, preceded by EXIMON_. For example, setting
3093 EXIMON_LOG_DEPTH in the environment overrides the value of
3094 LOG_DEPTH at runtime.
3095 <indexterm role="concept" startref="IIDbuex" class="endofrange"/>
3096 </para>
3097 </section>
3098 <section id="SECID32">
3099 <title>Installing Exim binaries and scripts</title>
3100 <para>
3101 <indexterm role="concept">
3102 <primary>installing Exim</primary>
3103 </indexterm>
3104 <indexterm role="concept">
3105 <primary>BIN_DIRECTORY</primary>
3106 </indexterm>
3107 The command <literal>make install</literal> runs the <command>exim_install</command> script with no
3108 arguments. The script copies binaries and utility scripts into the directory
3109 whose name is specified by the BIN_DIRECTORY setting in <filename>Local/Makefile</filename>.
3110 <indexterm role="concept">
3111 <primary>setuid</primary>
3112 <secondary>installing Exim with</secondary>
3113 </indexterm>
3114 The install script copies files only if they are newer than the files they are
3115 going to replace. The Exim binary is required to be owned by root and have the
3116 <emphasis>setuid</emphasis> bit set, for normal configurations. Therefore, you must run <literal>make
3117 install</literal> as root so that it can set up the Exim binary in this way. However, in
3118 some special situations (for example, if a host is doing no local deliveries)
3119 it may be possible to run Exim without making the binary setuid root (see
3120 chapter <xref linkend="CHAPsecurity"/> for details).
3121 </para>
3122 <para>
3123 <indexterm role="concept">
3124 <primary>CONFIGURE_FILE</primary>
3125 </indexterm>
3126 Exim&#x2019;s runtime configuration file is named by the CONFIGURE_FILE setting
3127 in <filename>Local/Makefile</filename>. If this names a single file, and the file does not
3128 exist, the default configuration file <filename>src/configure.default</filename> is copied there
3129 by the installation script. If a runtime configuration file already exists, it
3130 is left alone. If CONFIGURE_FILE is a colon-separated list, naming several
3131 alternative files, no default is installed.
3132 </para>
3133 <para>
3134 <indexterm role="concept">
3135 <primary>system aliases file</primary>
3136 </indexterm>
3137 <indexterm role="concept">
3138 <primary><filename>/etc/aliases</filename></primary>
3139 </indexterm>
3140 One change is made to the default configuration file when it is installed: the
3141 default configuration contains a router that references a system aliases file.
3142 The path to this file is set to the value specified by
3143 SYSTEM_ALIASES_FILE in <filename>Local/Makefile</filename> (<filename>/etc/aliases</filename> by default).
3144 If the system aliases file does not exist, the installation script creates it,
3145 and outputs a comment to the user.
3146 </para>
3147 <para>
3148 The created file contains no aliases, but it does contain comments about the
3149 aliases a site should normally have. Mail aliases have traditionally been
3150 kept in <filename>/etc/aliases</filename>. However, some operating systems are now using
3151 <filename>/etc/mail/aliases</filename>. You should check if yours is one of these, and change
3152 Exim&#x2019;s configuration if necessary.
3153 </para>
3154 <para>
3155 The default configuration uses the local host&#x2019;s name as the only local domain,
3156 and is set up to do local deliveries into the shared directory <filename>/var/mail</filename>,
3157 running as the local user. System aliases and <filename>.forward</filename> files in users&#x2019; home
3158 directories are supported, but no NIS or NIS+ support is configured. Domains
3159 other than the name of the local host are routed using the DNS, with delivery
3160 over SMTP.
3161 </para>
3162 <para>
3163 It is possible to install Exim for special purposes (such as building a binary
3164 distribution) in a private part of the file system. You can do this by a
3165 command such as
3166 </para>
3167 <literallayout class="monospaced">
3168 make DESTDIR=/some/directory/ install
3169 </literallayout>
3170 <para>
3171 This has the effect of pre-pending the specified directory to all the file
3172 paths, except the name of the system aliases file that appears in the default
3173 configuration. (If a default alias file is created, its name <emphasis>is</emphasis> modified.)
3174 For backwards compatibility, ROOT is used if DESTDIR is not set,
3175 but this usage is deprecated.
3176 </para>
3177 <para>
3178 <indexterm role="concept">
3179 <primary>installing Exim</primary>
3180 <secondary>what is not installed</secondary>
3181 </indexterm>
3182 Running <emphasis>make install</emphasis> does not copy the Exim 4 conversion script
3183 <emphasis>convert4r4</emphasis>. You will probably run this only once if you are
3184 upgrading from Exim 3. None of the documentation files in the <filename>doc</filename>
3185 directory are copied, except for the info files when you have set
3186 INFO_DIRECTORY, as described in section <xref linkend="SECTinsinfdoc"/> below.
3187 </para>
3188 <para>
3189 For the utility programs, old versions are renamed by adding the suffix <filename>.O</filename>
3190 to their names. The Exim binary itself, however, is handled differently. It is
3191 installed under a name that includes the version number and the compile number,
3192 for example, <filename>exim-4.93-1</filename>. The script then arranges for a symbolic link
3193 called <filename>exim</filename> to point to the binary. If you are updating a previous version
3194 of Exim, the script takes care to ensure that the name <filename>exim</filename> is never absent
3195 from the directory (as seen by other processes).
3196 </para>
3197 <para>
3198 <indexterm role="concept">
3199 <primary>installing Exim</primary>
3200 <secondary>testing the script</secondary>
3201 </indexterm>
3202 If you want to see what the <emphasis>make install</emphasis> will do before running it for
3203 real, you can pass the <option>-n</option> option to the installation script by this
3204 command:
3205 </para>
3206 <literallayout class="monospaced">
3207 make INSTALL_ARG=-n install
3208 </literallayout>
3209 <para>
3210 The contents of the variable INSTALL_ARG are passed to the installation
3211 script. You do not need to be root to run this test. Alternatively, you can run
3212 the installation script directly, but this must be from within the build
3213 directory. For example, from the top-level Exim directory you could use this
3214 command:
3215 </para>
3216 <literallayout class="monospaced">
3217 (cd build-SunOS5-5.5.1-sparc; ../scripts/exim_install -n)
3218 </literallayout>
3219 <para>
3220 <indexterm role="concept">
3221 <primary>installing Exim</primary>
3222 <secondary>install script options</secondary>
3223 </indexterm>
3224 There are two other options that can be supplied to the installation script.
3225 </para>
3226 <itemizedlist>
3227 <listitem>
3228 <para>
3229 <option>-no_chown</option> bypasses the call to change the owner of the installed binary
3230 to root, and the call to make it a setuid binary.
3231 </para>
3232 </listitem>
3233 <listitem>
3234 <para>
3235 <option>-no_symlink</option> bypasses the setting up of the symbolic link <filename>exim</filename> to the
3236 installed binary.
3237 </para>
3238 </listitem>
3239 </itemizedlist>
3240 <para>
3241 INSTALL_ARG can be used to pass these options to the script. For example:
3242 </para>
3243 <literallayout class="monospaced">
3244 make INSTALL_ARG=-no_symlink install
3245 </literallayout>
3246 <para>
3247 The installation script can also be given arguments specifying which files are
3248 to be copied. For example, to install just the Exim binary, and nothing else,
3249 without creating the symbolic link, you could use:
3250 </para>
3251 <literallayout class="monospaced">
3252 make INSTALL_ARG='-no_symlink exim' install
3253 </literallayout>
3254 </section>
3255 <section id="SECTinsinfdoc">
3256 <title>Installing info documentation</title>
3257 <para>
3258 <indexterm role="concept">
3259 <primary>installing Exim</primary>
3260 <secondary><emphasis>info</emphasis> documentation</secondary>
3261 </indexterm>
3262 Not all systems use the GNU <emphasis>info</emphasis> system for documentation, and for this
3263 reason, the Texinfo source of Exim&#x2019;s documentation is not included in the main
3264 distribution. Instead it is available separately from the FTP site (see section
3265 <xref linkend="SECTavail"/>).
3266 </para>
3267 <para>
3268 If you have defined INFO_DIRECTORY in <filename>Local/Makefile</filename> and the Texinfo
3269 source of the documentation is found in the source tree, running <literal>make
3270 install</literal> automatically builds the info files and installs them.
3271 </para>
3272 </section>
3273 <section id="SECID33">
3274 <title>Setting up the spool directory</title>
3275 <para>
3276 <indexterm role="concept">
3277 <primary>spool directory</primary>
3278 <secondary>creating</secondary>
3279 </indexterm>
3280 When it starts up, Exim tries to create its spool directory if it does not
3281 exist. The Exim uid and gid are used for the owner and group of the spool
3282 directory. Sub-directories are automatically created in the spool directory as
3283 necessary.
3284 </para>
3285 </section>
3286 <section id="SECID34">
3287 <title>Testing</title>
3288 <para>
3289 <indexterm role="concept">
3290 <primary>testing</primary>
3291 <secondary>installation</secondary>
3292 </indexterm>
3293 Having installed Exim, you can check that the runtime configuration file is
3294 syntactically valid by running the following command, which assumes that the
3295 Exim binary directory is within your PATH environment variable:
3296 </para>
3297 <literallayout class="monospaced">
3298 exim -bV
3299 </literallayout>
3300 <para>
3301 If there are any errors in the configuration file, Exim outputs error messages.
3302 Otherwise it outputs the version number and build date,
3303 the DBM library that is being used, and information about which drivers and
3304 other optional code modules are included in the binary.
3305 Some simple routing tests can be done by using the address testing option. For
3306 example,
3307 </para>
3308 <literallayout>
3309 <literal>exim -bt</literal> &lt;<emphasis>local username</emphasis>&gt;
3310 </literallayout>
3311 <para>
3312 should verify that it recognizes a local mailbox, and
3313 </para>
3314 <literallayout>
3315 <literal>exim -bt</literal> &lt;<emphasis>remote address</emphasis>&gt;
3316 </literallayout>
3317 <para>
3318 a remote one. Then try getting it to deliver mail, both locally and remotely.
3319 This can be done by passing messages directly to Exim, without going through a
3320 user agent. For example:
3321 </para>
3322 <literallayout class="monospaced">
3323 exim -v postmaster@your.domain.example
3324 From: user@your.domain.example
3325 To: postmaster@your.domain.example
3326 Subject: Testing Exim
3327
3328 This is a test message.
3329 ^D
3330 </literallayout>
3331 <para>
3332 The <option>-v</option> option causes Exim to output some verification of what it is doing.
3333 In this case you should see copies of three log lines, one for the message&#x2019;s
3334 arrival, one for its delivery, and one containing <quote>Completed</quote>.
3335 </para>
3336 <para>
3337 <indexterm role="concept">
3338 <primary>delivery</primary>
3339 <secondary>problems with</secondary>
3340 </indexterm>
3341 If you encounter problems, look at Exim&#x2019;s log files (<emphasis>mainlog</emphasis> and
3342 <emphasis>paniclog</emphasis>) to see if there is any relevant information there. Another source
3343 of information is running Exim with debugging turned on, by specifying the
3344 <option>-d</option> option. If a message is stuck on Exim&#x2019;s spool, you can force a delivery
3345 with debugging turned on by a command of the form
3346 </para>
3347 <literallayout>
3348 <literal>exim -d -M</literal> &lt;<emphasis>exim-message-id</emphasis>&gt;
3349 </literallayout>
3350 <para>
3351 You must be root or an <quote>admin user</quote> in order to do this. The <option>-d</option> option
3352 produces rather a lot of output, but you can cut this down to specific areas.
3353 For example, if you use <option>-d-all+route</option> only the debugging information
3354 relevant to routing is included. (See the <option>-d</option> option in chapter
3355 <xref linkend="CHAPcommandline"/> for more details.)
3356 </para>
3357 <para>
3358 <indexterm role="concept">
3359 <primary><quote>sticky</quote> bit</primary>
3360 </indexterm>
3361 <indexterm role="concept">
3362 <primary>lock files</primary>
3363 </indexterm>
3364 One specific problem that has shown up on some sites is the inability to do
3365 local deliveries into a shared mailbox directory, because it does not have the
3366 <quote>sticky bit</quote> set on it. By default, Exim tries to create a lock file before
3367 writing to a mailbox file, and if it cannot create the lock file, the delivery
3368 is deferred. You can get round this either by setting the <quote>sticky bit</quote> on the
3369 directory, or by setting a specific group for local deliveries and allowing
3370 that group to create files in the directory (see the comments above the
3371 <command>local_delivery</command> transport in the default configuration file). Another
3372 approach is to configure Exim not to use lock files, but just to rely on
3373 <function>fcntl()</function> locking instead. However, you should do this only if all user
3374 agents also use <function>fcntl()</function> locking. For further discussion of locking issues,
3375 see chapter <xref linkend="CHAPappendfile"/>.
3376 </para>
3377 <para>
3378 One thing that cannot be tested on a system that is already running an MTA is
3379 the receipt of incoming SMTP mail on the standard SMTP port. However, the
3380 <option>-oX</option> option can be used to run an Exim daemon that listens on some other
3381 port, or <emphasis>inetd</emphasis> can be used to do this. The <option>-bh</option> option and the
3382 <emphasis>exim_checkaccess</emphasis> utility can be used to check out policy controls on
3383 incoming SMTP mail.
3384 </para>
3385 <para>
3386 Testing a new version on a system that is already running Exim can most easily
3387 be done by building a binary with a different CONFIGURE_FILE setting. From
3388 within the runtime configuration, all other file and directory names
3389 that Exim uses can be altered, in order to keep it entirely clear of the
3390 production version.
3391 </para>
3392 </section>
3393 <section id="SECID35">
3394 <title>Replacing another MTA with Exim</title>
3395 <para>
3396 <indexterm role="concept">
3397 <primary>replacing another MTA</primary>
3398 </indexterm>
3399 Building and installing Exim for the first time does not of itself put it in
3400 general use. The name by which the system&#x2019;s MTA is called by mail user agents
3401 is either <filename>/usr/sbin/sendmail</filename>, or <filename>/usr/lib/sendmail</filename> (depending on the
3402 operating system), and it is necessary to make this name point to the <emphasis>exim</emphasis>
3403 binary in order to get the user agents to pass messages to Exim. This is
3404 normally done by renaming any existing file and making <filename>/usr/sbin/sendmail</filename>
3405 or <filename>/usr/lib/sendmail</filename>
3406 <indexterm role="concept">
3407 <primary>symbolic link</primary>
3408 <secondary>to <emphasis>exim</emphasis> binary</secondary>
3409 </indexterm>
3410 a symbolic link to the <emphasis>exim</emphasis> binary. It is a good idea to remove any setuid
3411 privilege and executable status from the old MTA. It is then necessary to stop
3412 and restart the mailer daemon, if one is running.
3413 </para>
3414 <para>
3415 <indexterm role="concept">
3416 <primary>FreeBSD, MTA indirection</primary>
3417 </indexterm>
3418 <indexterm role="concept">
3419 <primary><filename>/etc/mail/mailer.conf</filename></primary>
3420 </indexterm>
3421 Some operating systems have introduced alternative ways of switching MTAs. For
3422 example, if you are running FreeBSD, you need to edit the file
3423 <filename>/etc/mail/mailer.conf</filename> instead of setting up a symbolic link as just
3424 described. A typical example of the contents of this file for running Exim is
3425 as follows:
3426 </para>
3427 <literallayout class="monospaced">
3428 sendmail            /usr/exim/bin/exim
3429 send-mail           /usr/exim/bin/exim
3430 mailq               /usr/exim/bin/exim -bp
3431 newaliases          /usr/bin/true
3432 </literallayout>
3433 <para>
3434 Once you have set up the symbolic link, or edited <filename>/etc/mail/mailer.conf</filename>,
3435 your Exim installation is <quote>live</quote>. Check it by sending a message from your
3436 favourite user agent.
3437 </para>
3438 <para>
3439 You should consider what to tell your users about the change of MTA. Exim may
3440 have different capabilities to what was previously running, and there are
3441 various operational differences such as the text of messages produced by
3442 command line options and in bounce messages. If you allow your users to make
3443 use of Exim&#x2019;s filtering capabilities, you should make the document entitled
3444 <emphasis>Exim&#x2019;s interface to mail filtering</emphasis> available to them.
3445 </para>
3446 </section>
3447 <section id="SECID36">
3448 <title>Upgrading Exim</title>
3449 <para>
3450 <indexterm role="concept">
3451 <primary>upgrading Exim</primary>
3452 </indexterm>
3453 If you are already running Exim on your host, building and installing a new
3454 version automatically makes it available to MUAs, or any other programs that
3455 call the MTA directly. However, if you are running an Exim daemon, you do need
3456 <indexterm role="concept">
3457 <primary>restart</primary>
3458 <secondary>on HUP signal</secondary>
3459 </indexterm>
3460 <indexterm role="concept">
3461 <primary>signal</primary>
3462 <secondary>HUP, to restart</secondary>
3463 </indexterm>
3464 to send it a HUP signal, to make it re-execute itself, and thereby pick up the
3465 new binary. You do not need to stop processing mail in order to install a new
3466 version of Exim. The install script does not modify an existing runtime
3467 configuration file.
3468 </para>
3469 </section>
3470 <section id="SECID37">
3471 <title>Stopping the Exim daemon on Solaris</title>
3472 <para>
3473 <indexterm role="concept">
3474 <primary>Solaris</primary>
3475 <secondary>stopping Exim on</secondary>
3476 </indexterm>
3477 The standard command for stopping the mailer daemon on Solaris is
3478 </para>
3479 <literallayout class="monospaced">
3480 /etc/init.d/sendmail stop
3481 </literallayout>
3482 <para>
3483 If <filename>/usr/lib/sendmail</filename> has been turned into a symbolic link, this script
3484 fails to stop Exim because it uses the command <emphasis>ps -e</emphasis> and greps the output
3485 for the text <quote>sendmail</quote>; this is not present because the actual program name
3486 (that is, <quote>exim</quote>) is given by the <emphasis>ps</emphasis> command with these options. A
3487 solution is to replace the line that finds the process id with something like
3488 </para>
3489 <literallayout class="monospaced">
3490 pid=`cat /var/spool/exim/exim-daemon.pid`
3491 </literallayout>
3492 <para>
3493 to obtain the daemon&#x2019;s pid directly from the file that Exim saves it in.
3494 </para>
3495 <para>
3496 Note, however, that stopping the daemon does not <quote>stop Exim</quote>. Messages can
3497 still be received from local processes, and if automatic delivery is configured
3498 (the normal case), deliveries will still occur.
3499 </para>
3500 </section>
3501 </chapter>
3502
3503 <chapter id="CHAPcommandline">
3504 <title>The Exim command line</title>
3505 <para>
3506 <indexterm role="concept" id="IIDclo1" class="startofrange">
3507 <primary>command line</primary>
3508 <secondary>options</secondary>
3509 </indexterm>
3510 <indexterm role="concept" id="IIDclo2" class="startofrange">
3511 <primary>options</primary>
3512 <secondary>command line</secondary>
3513 </indexterm>
3514 Exim&#x2019;s command line takes the standard Unix form of a sequence of options,
3515 each starting with a hyphen character, followed by a number of arguments. The
3516 options are compatible with the main options of Sendmail, and there are also
3517 some additional options, some of which are compatible with Smail 3. Certain
3518 combinations of options do not make sense, and provoke an error if used.
3519 The form of the arguments depends on which options are set.
3520 </para>
3521 <section id="SECID38">
3522 <title>Setting options by program name</title>
3523 <para>
3524 <indexterm role="concept">
3525 <primary><emphasis>mailq</emphasis></primary>
3526 </indexterm>
3527 If Exim is called under the name <emphasis>mailq</emphasis>, it behaves as if the option <option>-bp</option>
3528 were present before any other options.
3529 The <option>-bp</option> option requests a listing of the contents of the mail queue on the
3530 standard output.
3531 This feature is for compatibility with some systems that contain a command of
3532 that name in one of the standard libraries, symbolically linked to
3533 <filename>/usr/sbin/sendmail</filename> or <filename>/usr/lib/sendmail</filename>.
3534 </para>
3535 <para>
3536 <indexterm role="concept">
3537 <primary><emphasis>rsmtp</emphasis></primary>
3538 </indexterm>
3539 If Exim is called under the name <emphasis>rsmtp</emphasis> it behaves as if the option <option>-bS</option>
3540 were present before any other options, for compatibility with Smail. The
3541 <option>-bS</option> option is used for reading in a number of messages in batched SMTP
3542 format.
3543 </para>
3544 <para>
3545 <indexterm role="concept">
3546 <primary><emphasis>rmail</emphasis></primary>
3547 </indexterm>
3548 If Exim is called under the name <emphasis>rmail</emphasis> it behaves as if the <option>-i</option> and
3549 <option>-oee</option> options were present before any other options, for compatibility with
3550 Smail. The name <emphasis>rmail</emphasis> is used as an interface by some UUCP systems.
3551 </para>
3552 <para>
3553 <indexterm role="concept">
3554 <primary><emphasis>runq</emphasis></primary>
3555 </indexterm>
3556 <indexterm role="concept">
3557 <primary>queue runner</primary>
3558 </indexterm>
3559 If Exim is called under the name <emphasis>runq</emphasis> it behaves as if the option <option>-q</option>
3560 were present before any other options, for compatibility with Smail. The <option>-q</option>
3561 option causes a single queue runner process to be started.
3562 </para>
3563 <para>
3564 <indexterm role="concept">
3565 <primary><emphasis>newaliases</emphasis></primary>
3566 </indexterm>
3567 <indexterm role="concept">
3568 <primary>alias file</primary>
3569 <secondary>building</secondary>
3570 </indexterm>
3571 <indexterm role="concept">
3572 <primary>Sendmail compatibility</primary>
3573 <secondary>calling Exim as <emphasis>newaliases</emphasis></secondary>
3574 </indexterm>
3575 If Exim is called under the name <emphasis>newaliases</emphasis> it behaves as if the option
3576 <option>-bi</option> were present before any other options, for compatibility with Sendmail.
3577 This option is used for rebuilding Sendmail&#x2019;s alias file. Exim does not have
3578 the concept of a single alias file, but can be configured to run a given
3579 command if called with the <option>-bi</option> option.
3580 </para>
3581 </section>
3582 <section id="SECTtrustedadmin">
3583 <title>Trusted and admin users</title>
3584 <para>
3585 Some Exim options are available only to <emphasis>trusted users</emphasis> and others are
3586 available only to <emphasis>admin users</emphasis>. In the description below, the phrases <quote>Exim
3587 user</quote> and <quote>Exim group</quote> mean the user and group defined by EXIM_USER and
3588 EXIM_GROUP in <filename>Local/Makefile</filename> or set by the <option>exim_user</option> and
3589 <option>exim_group</option> options. These do not necessarily have to use the name <quote>exim</quote>.
3590 </para>
3591 <itemizedlist>
3592 <listitem>
3593 <para>
3594 <indexterm role="concept">
3595 <primary>trusted users</primary>
3596 <secondary>definition of</secondary>
3597 </indexterm>
3598 <indexterm role="concept">
3599 <primary>user</primary>
3600 <secondary>trusted definition of</secondary>
3601 </indexterm>
3602 The trusted users are root, the Exim user, any user listed in the
3603 <option>trusted_users</option> configuration option, and any user whose current group or any
3604 supplementary group is one of those listed in the <option>trusted_groups</option>
3605 configuration option. Note that the Exim group is not automatically trusted.
3606 </para>
3607 <para>
3608 <indexterm role="concept">
3609 <primary><quote>From</quote> line</primary>
3610 </indexterm>
3611 <indexterm role="concept">
3612 <primary>envelope from</primary>
3613 </indexterm>
3614 <indexterm role="concept">
3615 <primary>envelope sender</primary>
3616 </indexterm>
3617 Trusted users are always permitted to use the <option>-f</option> option or a leading
3618 <quote>From&nbsp;</quote> line to specify the envelope sender of a message that is passed to
3619 Exim through the local interface (see the <option>-bm</option> and <option>-f</option> options below).
3620 See the <option>untrusted_set_sender</option> option for a way of permitting non-trusted
3621 users to set envelope senders.
3622 </para>
3623 <para>
3624 <indexterm role="concept">
3625 <primary><emphasis>From:</emphasis> header line</primary>
3626 </indexterm>
3627 <indexterm role="concept">
3628 <primary><emphasis>Sender:</emphasis> header line</primary>
3629 </indexterm>
3630 <indexterm role="concept">
3631 <primary>header lines</primary>
3632 <secondary>From:</secondary>
3633 </indexterm>
3634 <indexterm role="concept">
3635 <primary>header lines</primary>
3636 <secondary>Sender:</secondary>
3637 </indexterm>
3638 For a trusted user, there is never any check on the contents of the <emphasis>From:</emphasis>
3639 header line, and a <emphasis>Sender:</emphasis> line is never added. Furthermore, any existing
3640 <emphasis>Sender:</emphasis> line in incoming local (non-TCP/IP) messages is not removed.
3641 </para>
3642 <para>
3643 Trusted users may also specify a host name, host address, interface address,
3644 protocol name, ident value, and authentication data when submitting a message
3645 locally. Thus, they are able to insert messages into Exim&#x2019;s queue locally that
3646 have the characteristics of messages received from a remote host. Untrusted
3647 users may in some circumstances use <option>-f</option>, but can never set the other values
3648 that are available to trusted users.
3649 </para>
3650 </listitem>
3651 <listitem>
3652 <para>
3653 <indexterm role="concept">
3654 <primary>user</primary>
3655 <secondary>admin definition of</secondary>
3656 </indexterm>
3657 <indexterm role="concept">
3658 <primary>admin user</primary>
3659 <secondary>definition of</secondary>
3660 </indexterm>
3661 The admin users are root, the Exim user, and any user that is a member of the
3662 Exim group or of any group listed in the <option>admin_groups</option> configuration option.
3663 The current group does not have to be one of these groups.
3664 </para>
3665 <para>
3666 Admin users are permitted to list the queue, and to carry out certain
3667 operations on messages, for example, to force delivery failures. It is also
3668 necessary to be an admin user in order to see the full information provided by
3669 the Exim monitor, and full debugging output.
3670 </para>
3671 <para>
3672 By default, the use of the <option>-M</option>, <option>-q</option>, <option>-R</option>, and <option>-S</option> options to cause
3673 Exim to attempt delivery of messages on its queue is restricted to admin users.
3674 However, this restriction can be relaxed by setting the <option>prod_requires_admin</option>
3675 option false (that is, specifying <option>no_prod_requires_admin</option>).
3676 </para>
3677 <para>
3678 Similarly, the use of the <option>-bp</option> option to list all the messages in the queue
3679 is restricted to admin users unless <option>queue_list_requires_admin</option> is set
3680 false.
3681 </para>
3682 </listitem>
3683 </itemizedlist>
3684 <para>
3685 <emphasis role="bold">Warning</emphasis>: If you configure your system so that admin users are able to
3686 edit Exim&#x2019;s configuration file, you are giving those users an easy way of
3687 getting root. There is further discussion of this issue at the start of chapter
3688 <xref linkend="CHAPconf"/>.
3689 </para>
3690 </section>
3691 <section id="SECID39">
3692 <title>Command line options</title>
3693 <para>
3694 Exim&#x2019;s command line options are described in alphabetical order below. If none
3695 of the options that specifies a specific action (such as starting the daemon or
3696 a queue runner, or testing an address, or receiving a message in a specific
3697 format, or listing the queue) are present, and there is at least one argument
3698 on the command line, <option>-bm</option> (accept a local message on the standard input,
3699 with the arguments specifying the recipients) is assumed. Otherwise, Exim
3700 outputs a brief message about itself and exits.
3701 </para>
3702 <!-- === Start of command line options === -->
3703 <variablelist>
3704 <varlistentry>
3705 <term><option>--</option></term>
3706 <listitem>
3707 <para>
3708 <indexterm role="option">
3709 <primary>--</primary>
3710 </indexterm>
3711 <indexterm role="concept">
3712 <primary>options</primary>
3713 <secondary>command line; terminating</secondary>
3714 </indexterm>
3715 This is a pseudo-option whose only purpose is to terminate the options and
3716 therefore to cause subsequent command line items to be treated as arguments
3717 rather than options, even if they begin with hyphens.
3718 </para>
3719 </listitem></varlistentry>
3720 <varlistentry>
3721 <term><option>--help</option></term>
3722 <listitem>
3723 <para>
3724 <indexterm role="option">
3725 <primary><option>--help</option></primary>
3726 </indexterm>
3727 This option causes Exim to output a few sentences stating what it is.
3728 The same output is generated if the Exim binary is called with no options and
3729 no arguments.
3730 </para>
3731 </listitem></varlistentry>
3732 <varlistentry>
3733 <term><option>--version</option></term>
3734 <listitem>
3735 <para>
3736 <indexterm role="option">
3737 <primary><option>--version</option></primary>
3738 </indexterm>
3739 This option is an alias for <option>-bV</option> and causes version information to be
3740 displayed.
3741 </para>
3742 </listitem></varlistentry>
3743 <varlistentry>
3744 <term><option>-Ac</option></term>
3745 <term><option>-Am</option></term>
3746 <listitem>
3747 <para>
3748 <indexterm role="option">
3749 <primary><option>-Ac</option></primary>
3750 </indexterm>
3751 <indexterm role="option">
3752 <primary><option>-Am</option></primary>
3753 </indexterm>
3754 These options are used by Sendmail for selecting configuration files and are
3755 ignored by Exim.
3756 </para>
3757 </listitem></varlistentry>
3758 <varlistentry>
3759 <term><option>-B</option>&lt;<emphasis>type</emphasis>&gt;</term>
3760 <listitem>
3761 <para>
3762 <indexterm role="option">
3763 <primary><option>-B</option></primary>
3764 </indexterm>
3765 <indexterm role="concept">
3766 <primary>8-bit characters</primary>
3767 </indexterm>
3768 <indexterm role="concept">
3769 <primary>Sendmail compatibility</primary>
3770 <secondary>8-bit characters</secondary>
3771 </indexterm>
3772 This is a Sendmail option for selecting 7 or 8 bit processing. Exim is 8-bit
3773 clean; it ignores this option.
3774 </para>
3775 </listitem></varlistentry>
3776 <varlistentry>
3777 <term><option>-bd</option></term>
3778 <listitem>
3779 <para>
3780 <indexterm role="option">
3781 <primary><option>-bd</option></primary>
3782 </indexterm>
3783 <indexterm role="concept">
3784 <primary>daemon</primary>
3785 </indexterm>
3786 <indexterm role="concept">
3787 <primary>SMTP</primary>
3788 <secondary>listener</secondary>
3789 </indexterm>
3790 <indexterm role="concept">
3791 <primary>queue runner</primary>
3792 </indexterm>
3793 This option runs Exim as a daemon, awaiting incoming SMTP connections. Usually
3794 the <option>-bd</option> option is combined with the <option>-q</option>&lt;<emphasis>time</emphasis>&gt; option, to specify
3795 that the daemon should also initiate periodic queue runs.
3796 </para>
3797 <para>
3798 The <option>-bd</option> option can be used only by an admin user. If either of the <option>-d</option>
3799 (debugging) or <option>-v</option> (verifying) options are set, the daemon does not
3800 disconnect from the controlling terminal. When running this way, it can be
3801 stopped by pressing ctrl-C.
3802 </para>
3803 <para>
3804 By default, Exim listens for incoming connections to the standard SMTP port on
3805 all the host&#x2019;s running interfaces. However, it is possible to listen on other
3806 ports, on multiple ports, and only on specific interfaces. Chapter
3807 <xref linkend="CHAPinterfaces"/> contains a description of the options that control this.
3808 </para>
3809 <para>
3810 When a listening daemon
3811 <indexterm role="concept">
3812 <primary>daemon</primary>
3813 <secondary>process id (pid)</secondary>
3814 </indexterm>
3815 <indexterm role="concept">
3816 <primary>pid (process id)</primary>
3817 <secondary>of daemon</secondary>
3818 </indexterm>
3819 is started without the use of <option>-oX</option> (that is, without overriding the normal
3820 configuration), it writes its process id to a file called <filename>exim-daemon.pid</filename>
3821 in Exim&#x2019;s spool directory. This location can be overridden by setting
3822 PID_FILE_PATH in <filename>Local/Makefile</filename>. The file is written while Exim is still
3823 running as root.
3824 </para>
3825 <para>
3826 When <option>-oX</option> is used on the command line to start a listening daemon, the
3827 process id is not written to the normal pid file path. However, <option>-oP</option> can be
3828 used to specify a path on the command line if a pid file is required.
3829 </para>
3830 <para>
3831 The SIGHUP signal
3832 <indexterm role="concept">
3833 <primary>SIGHUP</primary>
3834 </indexterm>
3835 <indexterm role="concept">
3836 <primary>restart</primary>
3837 <secondary>on HUP signal</secondary>
3838 </indexterm>
3839 <indexterm role="concept">
3840 <primary>signal</primary>
3841 <secondary>HUP, to restart</secondary>
3842 </indexterm>
3843 <indexterm role="concept">
3844 <primary>daemon</primary>
3845 <secondary>restarting</secondary>
3846 </indexterm>
3847 <indexterm role="concept">
3848 <primary>signal</primary>
3849 <secondary>to reload configuration</secondary>
3850 </indexterm>
3851 <indexterm role="concept">
3852 <primary>daemon</primary>
3853 <secondary>reload configuration</secondary>
3854 </indexterm>
3855 <indexterm role="concept">
3856 <primary>reload</primary>
3857 <secondary>configuration</secondary>
3858 </indexterm>
3859 can be used to cause the daemon to re-execute itself. This should be done
3860 whenever Exim&#x2019;s configuration file, or any file that is incorporated into it by
3861 means of the <option>.include</option> facility, is changed, and also whenever a new version
3862 of Exim is installed. It is not necessary to do this when other files that are
3863 referenced from the configuration (for example, alias files) are changed,
3864 because these are reread each time they are used.
3865 </para>
3866 </listitem></varlistentry>
3867 <varlistentry>
3868 <term><option>-bdf</option></term>
3869 <listitem>
3870 <para>
3871 <indexterm role="option">
3872 <primary><option>-bdf</option></primary>
3873 </indexterm>
3874 This option has the same effect as <option>-bd</option> except that it never disconnects
3875 from the controlling terminal, even when no debugging is specified.
3876 </para>
3877 </listitem></varlistentry>
3878 <varlistentry>
3879 <term><option>-be</option></term>
3880 <listitem>
3881 <para>
3882 <indexterm role="option">
3883 <primary><option>-be</option></primary>
3884 </indexterm>
3885 <indexterm role="concept">
3886 <primary>testing</primary>
3887 <secondary>string expansion</secondary>
3888 </indexterm>
3889 <indexterm role="concept">
3890 <primary>expansion</primary>
3891 <secondary>testing</secondary>
3892 </indexterm>
3893 Run Exim in expansion testing mode. Exim discards its root privilege, to
3894 prevent ordinary users from using this mode to read otherwise inaccessible
3895 files. If no arguments are given, Exim runs interactively, prompting for lines
3896 of data. Otherwise, it processes each argument in turn.
3897 </para>
3898 <para>
3899 If Exim was built with USE_READLINE=yes in <filename>Local/Makefile</filename>, it tries
3900 to load the <option>libreadline</option> library dynamically whenever the <option>-be</option> option is
3901 used without command line arguments. If successful, it uses the <function>readline()</function>
3902 function, which provides extensive line-editing facilities, for reading the
3903 test data. A line history is supported.
3904 </para>
3905 <para>
3906 Long expansion expressions can be split over several lines by using backslash
3907 continuations. As in Exim&#x2019;s runtime configuration, white space at the start of
3908 continuation lines is ignored. Each argument or data line is passed through the
3909 string expansion mechanism, and the result is output. Variable values from the
3910 configuration file (for example, <varname>$qualify_domain</varname>) are available, but no
3911 message-specific values (such as <varname>$message_exim_id</varname>) are set, because no message
3912 is being processed (but see <option>-bem</option> and <option>-Mset</option>).
3913 </para>
3914 <para>
3915 <emphasis role="bold">Note</emphasis>: If you use this mechanism to test lookups, and you change the data
3916 files or databases you are using, you must exit and restart Exim before trying
3917 the same lookup again. Otherwise, because each Exim process caches the results
3918 of lookups, you will just get the same result as before.
3919 </para>
3920 <para>
3921 Macro processing is done on lines before string-expansion: new macros can be
3922 defined and macros will be expanded.
3923 Because macros in the config file are often used for secrets, those are only
3924 available to admin users.
3925 </para>
3926 </listitem></varlistentry>
3927 <varlistentry>
3928 <term><option>-bem</option>&nbsp;&lt;<emphasis>filename</emphasis>&gt;</term>
3929 <listitem>
3930 <para>
3931 <indexterm role="option">
3932 <primary><option>-bem</option></primary>
3933 </indexterm>
3934 <indexterm role="concept">
3935 <primary>testing</primary>
3936 <secondary>string expansion</secondary>
3937 </indexterm>
3938 <indexterm role="concept">
3939 <primary>expansion</primary>
3940 <secondary>testing</secondary>
3941 </indexterm>
3942 This option operates like <option>-be</option> except that it must be followed by the name
3943 of a file. For example:
3944 </para>
3945 <literallayout class="monospaced">
3946 exim -bem /tmp/testmessage
3947 </literallayout>
3948 <para>
3949 The file is read as a message (as if receiving a locally-submitted non-SMTP
3950 message) before any of the test expansions are done. Thus, message-specific
3951 variables such as <varname>$message_size</varname> and <varname>$header_from:</varname> are available. However,
3952 no <emphasis>Received:</emphasis> header is added to the message. If the <option>-t</option> option is set,
3953 recipients are read from the headers in the normal way, and are shown in the
3954 <varname>$recipients</varname> variable. Note that recipients cannot be given on the command
3955 line, because further arguments are taken as strings to expand (just like
3956 <option>-be</option>).
3957 </para>
3958 </listitem></varlistentry>
3959 <varlistentry>
3960 <term><option>-bF</option>&nbsp;&lt;<emphasis>filename</emphasis>&gt;</term>
3961 <listitem>
3962 <para>
3963 <indexterm role="option">
3964 <primary><option>-bF</option></primary>
3965 </indexterm>
3966 <indexterm role="concept">
3967 <primary>system filter</primary>
3968 <secondary>testing</secondary>
3969 </indexterm>
3970 <indexterm role="concept">
3971 <primary>testing</primary>
3972 <secondary>system filter</secondary>
3973 </indexterm>
3974 This option is the same as <option>-bf</option> except that it assumes that the filter being
3975 tested is a system filter. The additional commands that are available only in
3976 system filters are recognized.
3977 </para>
3978 </listitem></varlistentry>
3979 <varlistentry>
3980 <term><option>-bf</option>&nbsp;&lt;<emphasis>filename</emphasis>&gt;</term>
3981 <listitem>
3982 <para>
3983 <indexterm role="option">
3984 <primary><option>-bf</option></primary>
3985 </indexterm>
3986 <indexterm role="concept">
3987 <primary>filter</primary>
3988 <secondary>testing</secondary>
3989 </indexterm>
3990 <indexterm role="concept">
3991 <primary>testing</primary>
3992 <secondary>filter file</secondary>
3993 </indexterm>
3994 <indexterm role="concept">
3995 <primary>forward file</primary>
3996 <secondary>testing</secondary>
3997 </indexterm>
3998 <indexterm role="concept">
3999 <primary>testing</primary>
4000 <secondary>forward file</secondary>
4001 </indexterm>
4002 <indexterm role="concept">
4003 <primary>Sieve filter</primary>
4004 <secondary>testing</secondary>
4005 </indexterm>
4006 This option runs Exim in user filter testing mode; the file is the filter file
4007 to be tested, and a test message must be supplied on the standard input. If
4008 there are no message-dependent tests in the filter, an empty file can be
4009 supplied.
4010 </para>
4011 <para>
4012 If you want to test a system filter file, use <option>-bF</option> instead of <option>-bf</option>. You
4013 can use both <option>-bF</option> and <option>-bf</option> on the same command, in order to test a system
4014 filter and a user filter in the same run. For example:
4015 </para>
4016 <literallayout class="monospaced">
4017 exim -bF /system/filter -bf /user/filter &lt;/test/message
4018 </literallayout>
4019 <para>
4020 This is helpful when the system filter adds header lines or sets filter
4021 variables that are used by the user filter.
4022 </para>
4023 <para>
4024 If the test filter file does not begin with one of the special lines
4025 </para>
4026 <literallayout class="monospaced">
4027 # Exim filter
4028 # Sieve filter
4029 </literallayout>
4030 <para>
4031 it is taken to be a normal <filename>.forward</filename> file, and is tested for validity under
4032 that interpretation. See sections <xref linkend="SECTitenonfilred"/> to
4033 <xref linkend="SECTspecitredli"/> for a description of the possible contents of non-filter
4034 redirection lists.
4035 </para>
4036 <para>
4037 The result of an Exim command that uses <option>-bf</option>, provided no errors are
4038 detected, is a list of the actions that Exim would try to take if presented
4039 with the message for real. More details of filter testing are given in the
4040 separate document entitled <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis>.
4041 </para>
4042 <para>
4043 When testing a filter file,
4044 <indexterm role="concept">
4045 <primary><quote>From</quote> line</primary>
4046 </indexterm>
4047 <indexterm role="concept">
4048 <primary>envelope from</primary>
4049 </indexterm>
4050 <indexterm role="concept">
4051 <primary>envelope sender</primary>
4052 </indexterm>
4053 <indexterm role="option">
4054 <primary><option>-f</option></primary>
4055 <secondary>for filter testing</secondary>
4056 </indexterm>
4057 the envelope sender can be set by the <option>-f</option> option,
4058 or by a <quote>From&nbsp;</quote> line at the start of the test message. Various parameters
4059 that would normally be taken from the envelope recipient address of the message
4060 can be set by means of additional command line options (see the next four
4061 options).
4062 </para>
4063 </listitem></varlistentry>
4064 <varlistentry>
4065 <term><option>-bfd</option>&nbsp;&lt;<emphasis>domain</emphasis>&gt;</term>
4066 <listitem>
4067 <para>
4068 <indexterm role="option">
4069 <primary><option>-bfd</option></primary>
4070 </indexterm>
4071 <indexterm role="variable">
4072 <primary><varname>$qualify_domain</varname></primary>
4073 </indexterm>
4074 This sets the domain of the recipient address when a filter file is being
4075 tested by means of the <option>-bf</option> option. The default is the value of
4076 <varname>$qualify_domain</varname>.
4077 </para>
4078 </listitem></varlistentry>
4079 <varlistentry>
4080 <term><option>-bfl</option>&nbsp;&lt;<emphasis>local&nbsp;part</emphasis>&gt;</term>
4081 <listitem>
4082 <para>
4083 <indexterm role="option">
4084 <primary><option>-bfl</option></primary>
4085 </indexterm>
4086 This sets the local part of the recipient address when a filter file is being
4087 tested by means of the <option>-bf</option> option. The default is the username of the
4088 process that calls Exim. A local part should be specified with any prefix or
4089 suffix stripped, because that is how it appears to the filter when a message is
4090 actually being delivered.
4091 </para>
4092 </listitem></varlistentry>
4093 <varlistentry>
4094 <term><option>-bfp</option>&nbsp;&lt;<emphasis>prefix</emphasis>&gt;</term>
4095 <listitem>
4096 <para>
4097 <indexterm role="option">
4098 <primary><option>-bfp</option></primary>
4099 </indexterm>
4100 <indexterm role="concept">
4101 <primary>affix</primary>
4102 <secondary>filter testing</secondary>
4103 </indexterm>
4104 This sets the prefix of the local part of the recipient address when a filter
4105 file is being tested by means of the <option>-bf</option> option. The default is an empty
4106 prefix.
4107 </para>
4108 </listitem></varlistentry>
4109 <varlistentry>
4110 <term><option>-bfs</option>&nbsp;&lt;<emphasis>suffix</emphasis>&gt;</term>
4111 <listitem>
4112 <para>
4113 <indexterm role="option">
4114 <primary><option>-bfs</option></primary>
4115 </indexterm>
4116 <indexterm role="concept">
4117 <primary>affix</primary>
4118 <secondary>filter testing</secondary>
4119 </indexterm>
4120 This sets the suffix of the local part of the recipient address when a filter
4121 file is being tested by means of the <option>-bf</option> option. The default is an empty
4122 suffix.
4123 </para>
4124 </listitem></varlistentry>
4125 <varlistentry>
4126 <term><option>-bh</option>&nbsp;&lt;<emphasis>IP&nbsp;address</emphasis>&gt;</term>
4127 <listitem>
4128 <para>
4129 <indexterm role="option">
4130 <primary><option>-bh</option></primary>
4131 </indexterm>
4132 <indexterm role="concept">
4133 <primary>testing</primary>
4134 <secondary>incoming SMTP</secondary>
4135 </indexterm>
4136 <indexterm role="concept">
4137 <primary>SMTP</primary>
4138 <secondary>testing incoming</secondary>
4139 </indexterm>
4140 <indexterm role="concept">
4141 <primary>testing</primary>
4142 <secondary>relay control</secondary>
4143 </indexterm>
4144 <indexterm role="concept">
4145 <primary>relaying</primary>
4146 <secondary>testing configuration</secondary>
4147 </indexterm>
4148 <indexterm role="concept">
4149 <primary>policy control</primary>
4150 <secondary>testing</secondary>
4151 </indexterm>
4152 <indexterm role="concept">
4153 <primary>debugging</primary>
4154 <secondary><option>-bh</option> option</secondary>
4155 </indexterm>
4156 This option runs a fake SMTP session as if from the given IP address, using the
4157 standard input and output. The IP address may include a port number at the end,
4158 after a full stop. For example:
4159 </para>
4160 <literallayout class="monospaced">
4161 exim -bh 10.9.8.7.1234
4162 exim -bh fe80::a00:20ff:fe86:a061.5678
4163 </literallayout>
4164 <para>
4165 When an IPv6 address is given, it is converted into canonical form. In the case
4166 of the second example above, the value of <varname>$sender_host_address</varname> after
4167 conversion to the canonical form is
4168 <literal>fe80:0000:0000:0a00:20ff:fe86:a061.5678</literal>.
4169 </para>
4170 <para>
4171 Comments as to what is going on are written to the standard error file. These
4172 include lines beginning with <quote>LOG</quote> for anything that would have been logged.
4173 This facility is provided for testing configuration options for incoming
4174 messages, to make sure they implement the required policy. For example, you can
4175 test your relay controls using <option>-bh</option>.
4176 </para>
4177 <para>
4178 <emphasis role="bold">Warning 1</emphasis>:
4179 <indexterm role="concept">
4180 <primary>RFC 1413</primary>
4181 </indexterm>
4182 You can test features of the configuration that rely on ident (RFC 1413)
4183 information by using the <option>-oMt</option> option. However, Exim cannot actually perform
4184 an ident callout when testing using <option>-bh</option> because there is no incoming SMTP
4185 connection.
4186 </para>
4187 <para>
4188 <emphasis role="bold">Warning 2</emphasis>: Address verification callouts (see section <xref linkend="SECTcallver"/>)
4189 are also skipped when testing using <option>-bh</option>. If you want these callouts to
4190 occur, use <option>-bhc</option> instead.
4191 </para>
4192 <para>
4193 Messages supplied during the testing session are discarded, and nothing is
4194 written to any of the real log files. There may be pauses when DNS (and other)
4195 lookups are taking place, and of course these may time out. The <option>-oMi</option> option
4196 can be used to specify a specific IP interface and port if this is important,
4197 and <option>-oMaa</option> and <option>-oMai</option> can be used to set parameters as if the SMTP
4198 session were authenticated.
4199 </para>
4200 <para>
4201 The <emphasis>exim_checkaccess</emphasis> utility is a <quote>packaged</quote> version of <option>-bh</option> whose
4202 output just states whether a given recipient address from a given host is
4203 acceptable or not. See section <xref linkend="SECTcheckaccess"/>.
4204 </para>
4205 <para>
4206 Features such as authentication and encryption, where the client input is not
4207 plain text, cannot easily be tested with <option>-bh</option>. Instead, you should use a
4208 specialized SMTP test program such as
4209 <emphasis role="bold"><ulink url="https://www.jetmore.org/john/code/swaks/">swaks</ulink></emphasis>.
4210 </para>
4211 </listitem></varlistentry>
4212 <varlistentry>
4213 <term><option>-bhc</option>&nbsp;&lt;<emphasis>IP&nbsp;address</emphasis>&gt;</term>
4214 <listitem>
4215 <para>
4216 <indexterm role="option">
4217 <primary><option>-bhc</option></primary>
4218 </indexterm>
4219 This option operates in the same way as <option>-bh</option>, except that address
4220 verification callouts are performed if required. This includes consulting and
4221 updating the callout cache database.
4222 </para>
4223 </listitem></varlistentry>
4224 <varlistentry>
4225 <term><option>-bi</option></term>
4226 <listitem>
4227 <para>
4228 <indexterm role="option">
4229 <primary><option>-bi</option></primary>
4230 </indexterm>
4231 <indexterm role="concept">
4232 <primary>alias file</primary>
4233 <secondary>building</secondary>
4234 </indexterm>
4235 <indexterm role="concept">
4236 <primary>building alias file</primary>
4237 </indexterm>
4238 <indexterm role="concept">
4239 <primary>Sendmail compatibility</primary>
4240 <secondary><option>-bi</option> option</secondary>
4241 </indexterm>
4242 Sendmail interprets the <option>-bi</option> option as a request to rebuild its alias file.
4243 Exim does not have the concept of a single alias file, and so it cannot mimic
4244 this behaviour. However, calls to <filename>/usr/lib/sendmail</filename> with the <option>-bi</option> option
4245 tend to appear in various scripts such as NIS make files, so the option must be
4246 recognized.
4247 </para>
4248 <para>
4249 If <option>-bi</option> is encountered, the command specified by the <option>bi_command</option>
4250 configuration option is run, under the uid and gid of the caller of Exim. If
4251 the <option>-oA</option> option is used, its value is passed to the command as an argument.
4252 The command set by <option>bi_command</option> may not contain arguments. The command can
4253 use the <emphasis>exim_dbmbuild</emphasis> utility, or some other means, to rebuild alias files
4254 if this is required. If the <option>bi_command</option> option is not set, calling Exim with
4255 <option>-bi</option> is a no-op.
4256 </para>
4257 </listitem></varlistentry>
4258 <varlistentry>
4259 <term><option>-bI:help</option></term>
4260 <listitem>
4261 <para>
4262 <indexterm role="option">
4263 <primary><option>-bI:help</option></primary>
4264 </indexterm>
4265 <indexterm role="concept">
4266 <primary>querying exim information</primary>
4267 </indexterm>
4268 We shall provide various options starting <literal>-bI:</literal> for querying Exim for
4269 information.  The output of many of these will be intended for machine
4270 consumption.  This one is not.  The <option>-bI:help</option> option asks Exim for a
4271 synopsis of supported options beginning <literal>-bI:</literal>.  Use of any of these
4272 options shall cause Exim to exit after producing the requested output.
4273 </para>
4274 </listitem></varlistentry>
4275 <varlistentry>
4276 <term><option>-bI:dscp</option></term>
4277 <listitem>
4278 <para>
4279 <indexterm role="option">
4280 <primary><option>-bI:dscp</option></primary>
4281 </indexterm>
4282 <indexterm role="concept">
4283 <primary>DSCP</primary>
4284 <secondary>values</secondary>
4285 </indexterm>
4286 This option causes Exim to emit an alphabetically sorted list of all
4287 recognised DSCP names.
4288 </para>
4289 </listitem></varlistentry>
4290 <varlistentry>
4291 <term><option>-bI:sieve</option></term>
4292 <listitem>
4293 <para>
4294 <indexterm role="option">
4295 <primary><option>-bI:sieve</option></primary>
4296 </indexterm>
4297 <indexterm role="concept">
4298 <primary>Sieve filter</primary>
4299 <secondary>capabilities</secondary>
4300 </indexterm>
4301 This option causes Exim to emit an alphabetically sorted list of all supported
4302 Sieve protocol extensions on stdout, one per line.  This is anticipated to be
4303 useful for ManageSieve (RFC 5804) implementations, in providing that protocol&#x2019;s
4304 <literal>SIEVE</literal> capability response line.  As the precise list may depend upon
4305 compile-time build options, which this option will adapt to, this is the only
4306 way to guarantee a correct response.
4307 </para>
4308 </listitem></varlistentry>
4309 <varlistentry>
4310 <term><option>-bm</option></term>
4311 <listitem>
4312 <para>
4313 <indexterm role="option">
4314 <primary><option>-bm</option></primary>
4315 </indexterm>
4316 <indexterm role="concept">
4317 <primary>local message reception</primary>
4318 </indexterm>
4319 This option runs an Exim receiving process that accepts an incoming,
4320 locally-generated message on the standard input. The recipients are given as the
4321 command arguments (except when <option>-t</option> is also present &ndash; see below). Each
4322 argument can be a comma-separated list of RFC 2822 addresses. This is the
4323 default option for selecting the overall action of an Exim call; it is assumed
4324 if no other conflicting option is present.
4325 </para>
4326 <para>
4327 If any addresses in the message are unqualified (have no domain), they are
4328 qualified by the values of the <option>qualify_domain</option> or <option>qualify_recipient</option>
4329 options, as appropriate. The <option>-bnq</option> option (see below) provides a way of
4330 suppressing this for special cases.
4331 </para>
4332 <para>
4333 Policy checks on the contents of local messages can be enforced by means of
4334 the non-SMTP ACL. See chapter <xref linkend="CHAPACL"/> for details.
4335 </para>
4336 <para>
4337 <indexterm role="concept">
4338 <primary>return code</primary>
4339 <secondary>for <option>-bm</option></secondary>
4340 </indexterm>
4341 The return code is zero if the message is successfully accepted. Otherwise, the
4342 action is controlled by the <option>-oe</option><emphasis>x</emphasis> option setting &ndash; see below.
4343 </para>
4344 <para>
4345 The format
4346 <indexterm role="concept">
4347 <primary>message</primary>
4348 <secondary>format</secondary>
4349 </indexterm>
4350 <indexterm role="concept">
4351 <primary>format</primary>
4352 <secondary>message</secondary>
4353 </indexterm>
4354 <indexterm role="concept">
4355 <primary><quote>From</quote> line</primary>
4356 </indexterm>
4357 <indexterm role="concept">
4358 <primary>UUCP</primary>
4359 <secondary><quote>From</quote> line</secondary>
4360 </indexterm>
4361 <indexterm role="concept">
4362 <primary>Sendmail compatibility</primary>
4363 <secondary><quote>From</quote> line</secondary>
4364 </indexterm>
4365 of the message must be as defined in RFC 2822, except that, for
4366 compatibility with Sendmail and Smail, a line in one of the forms
4367 </para>
4368 <literallayout class="monospaced">
4369 From sender Fri Jan  5 12:55 GMT 1997
4370 From sender Fri, 5 Jan 97 12:55:01
4371 </literallayout>
4372 <para>
4373 (with the weekday optional, and possibly with additional text after the date)
4374 is permitted to appear at the start of the message. There appears to be no
4375 authoritative specification of the format of this line. Exim recognizes it by
4376 matching against the regular expression defined by the <option>uucp_from_pattern</option>
4377 option, which can be changed if necessary.
4378 </para>
4379 <para>
4380 <indexterm role="option">
4381 <primary><option>-f</option></primary>
4382 <secondary>overriding <quote>From</quote> line</secondary>
4383 </indexterm>
4384 The specified sender is treated as if it were given as the argument to the
4385 <option>-f</option> option, but if a <option>-f</option> option is also present, its argument is used in
4386 preference to the address taken from the message. The caller of Exim must be a
4387 trusted user for the sender of a message to be set in this way.
4388 </para>
4389 </listitem></varlistentry>
4390 <varlistentry>
4391 <term><option>-bmalware</option>&nbsp;&lt;<emphasis>filename</emphasis>&gt;</term>
4392 <listitem>
4393 <para>
4394 <indexterm role="option">
4395 <primary><option>-bmalware</option></primary>
4396 </indexterm>
4397 <indexterm role="concept">
4398 <primary>testing</primary>
4399 <secondary>,</secondary>
4400 </indexterm>
4401 <indexterm role="concept">
4402 <primary>malware scan test</primary>
4403 </indexterm>
4404 This debugging option causes Exim to scan the given file or directory
4405 (depending on the used scanner interface),
4406 using the malware scanning framework.  The option of <option>av_scanner</option> influences
4407 this option, so if <option>av_scanner</option>&#x2019;s value is dependent upon an expansion then
4408 the expansion should have defaults which apply to this invocation.  ACLs are
4409 not invoked, so if <option>av_scanner</option> references an ACL variable then that variable
4410 will never be populated and <option>-bmalware</option> will fail.
4411 </para>
4412 <para>
4413 Exim will have changed working directory before resolving the filename, so
4414 using fully qualified pathnames is advisable.  Exim will be running as the Exim
4415 user when it tries to open the file, rather than as the invoking user.
4416 This option requires admin privileges.
4417 </para>
4418 <para>
4419 The <option>-bmalware</option> option will not be extended to be more generally useful,
4420 there are better tools for file-scanning.  This option exists to help
4421 administrators verify their Exim and AV scanner configuration.
4422 </para>
4423 </listitem></varlistentry>
4424 <varlistentry>
4425 <term><option>-bnq</option></term>
4426 <listitem>
4427 <para>
4428 <indexterm role="option">
4429 <primary><option>-bnq</option></primary>
4430 </indexterm>
4431 <indexterm role="concept">
4432 <primary>address qualification, suppressing</primary>
4433 </indexterm>
4434 By default, Exim automatically qualifies unqualified addresses (those
4435 without domains) that appear in messages that are submitted locally (that
4436 is, not over TCP/IP). This qualification applies both to addresses in
4437 envelopes, and addresses in header lines. Sender addresses are qualified using
4438 <option>qualify_domain</option>, and recipient addresses using <option>qualify_recipient</option> (which
4439 defaults to the value of <option>qualify_domain</option>).
4440 </para>
4441 <para>
4442 Sometimes, qualification is not wanted. For example, if <option>-bS</option> (batch SMTP) is
4443 being used to re-submit messages that originally came from remote hosts after
4444 content scanning, you probably do not want to qualify unqualified addresses in
4445 header lines. (Such lines will be present only if you have not enabled a header
4446 syntax check in the appropriate ACL.)
4447 </para>
4448 <para>
4449 The <option>-bnq</option> option suppresses all qualification of unqualified addresses in
4450 messages that originate on the local host. When this is used, unqualified
4451 addresses in the envelope provoke errors (causing message rejection) and
4452 unqualified addresses in header lines are left alone.
4453 </para>
4454 </listitem></varlistentry>
4455 <varlistentry>
4456 <term><option>-bP</option></term>
4457 <listitem>
4458 <para>
4459 <indexterm role="option">
4460 <primary><option>-bP</option></primary>
4461 </indexterm>
4462 <indexterm role="concept">
4463 <primary>configuration options</primary>
4464 <secondary>extracting</secondary>
4465 </indexterm>
4466 <indexterm role="concept">
4467 <primary>options</primary>
4468 <secondary>configuration &ndash; extracting</secondary>
4469 </indexterm>
4470 If this option is given with no arguments, it causes the values of all Exim&#x2019;s
4471 main configuration options to be written to the standard output. The values
4472 of one or more specific options can be requested by giving their names as
4473 arguments, for example:
4474 </para>
4475 <literallayout class="monospaced">
4476 exim -bP qualify_domain hold_domains
4477 </literallayout>
4478 <para>
4479 <indexterm role="concept">
4480 <primary>hiding configuration option values</primary>
4481 </indexterm>
4482 <indexterm role="concept">
4483 <primary>configuration options</primary>
4484 <secondary>hiding value of</secondary>
4485 </indexterm>
4486 <indexterm role="concept">
4487 <primary>options</primary>
4488 <secondary>hiding value of</secondary>
4489 </indexterm>
4490 However, any option setting that is preceded by the word <quote>hide</quote> in the
4491 configuration file is not shown in full, except to an admin user. For other
4492 users, the output is as in this example:
4493 </para>
4494 <literallayout class="monospaced">
4495 mysql_servers = &lt;value not displayable&gt;
4496 </literallayout>
4497 <para>
4498 If <option>config</option> is given as an argument, the config is
4499 output, as it was parsed, any include file resolved, any comment removed.
4500 </para>
4501 <para>
4502 If <option>config_file</option> is given as an argument, the name of the runtime
4503 configuration file is output. (<option>configure_file</option> works too, for
4504 backward compatibility.)
4505 If a list of configuration files was supplied, the value that is output here
4506 is the name of the file that was actually used.
4507 </para>
4508 <para>
4509 <indexterm role="concept">
4510 <primary>options</primary>
4511 <secondary>hiding name of</secondary>
4512 </indexterm>
4513 If the <option>-n</option> flag is given, then for most modes of <option>-bP</option> operation the
4514 name will not be output.
4515 </para>
4516 <para>
4517 <indexterm role="concept">
4518 <primary>daemon</primary>
4519 <secondary>process id (pid)</secondary>
4520 </indexterm>
4521 <indexterm role="concept">
4522 <primary>pid (process id)</primary>
4523 <secondary>of daemon</secondary>
4524 </indexterm>
4525 If <option>log_file_path</option> or <option>pid_file_path</option> are given, the names of the
4526 directories where log files and daemon pid files are written are output,
4527 respectively. If these values are unset, log files are written in a
4528 sub-directory of the spool directory called <option>log</option>, and the pid file is
4529 written directly into the spool directory.
4530 </para>
4531 <para>
4532 If <option>-bP</option> is followed by a name preceded by <literal>+</literal>, for example,
4533 </para>
4534 <literallayout class="monospaced">
4535 exim -bP +local_domains
4536 </literallayout>
4537 <para>
4538 it searches for a matching named list of any type (domain, host, address, or
4539 local part) and outputs what it finds.
4540 </para>
4541 <para>
4542 <indexterm role="concept">
4543 <primary>options</primary>
4544 <secondary>router &ndash; extracting</secondary>
4545 </indexterm>
4546 <indexterm role="concept">
4547 <primary>options</primary>
4548 <secondary>transport &ndash; extracting</secondary>
4549 </indexterm>
4550 <indexterm role="concept">
4551 <primary>options</primary>
4552 <secondary>authenticator &ndash; extracting</secondary>
4553 </indexterm>
4554 If one of the words <option>router</option>, <option>transport</option>, or <option>authenticator</option> is given,
4555 followed by the name of an appropriate driver instance, the option settings for
4556 that driver are output. For example:
4557 </para>
4558 <literallayout class="monospaced">
4559 exim -bP transport local_delivery
4560 </literallayout>
4561 <para>
4562 The generic driver options are output first, followed by the driver&#x2019;s private
4563 options. A list of the names of drivers of a particular type can be obtained by
4564 using one of the words <option>router_list</option>, <option>transport_list</option>, or
4565 <option>authenticator_list</option>, and a complete list of all drivers with their option
4566 settings can be obtained by using <option>routers</option>, <option>transports</option>, or
4567 <option>authenticators</option>.
4568 </para>
4569 <para>
4570 <indexterm role="concept">
4571 <primary>environment</primary>
4572 </indexterm>
4573 If <option>environment</option> is given as an argument, the set of environment
4574 variables is output, line by line. Using the <option>-n</option> flag suppresses the value of the
4575 variables.
4576 </para>
4577 <para>
4578 <indexterm role="concept">
4579 <primary>options</primary>
4580 <secondary>macro &ndash; extracting</secondary>
4581 </indexterm>
4582 If invoked by an admin user, then <option>macro</option>, <option>macro_list</option> and <option>macros</option>
4583 are available, similarly to the drivers.  Because macros are sometimes used
4584 for storing passwords, this option is restricted.
4585 The output format is one item per line.
4586 For the "-bP macro &lt;name&gt;" form, if no such macro is found
4587 the exit status will be nonzero.
4588 </para>
4589 </listitem></varlistentry>
4590 <varlistentry>
4591 <term><option>-bp</option></term>
4592 <listitem>
4593 <para>
4594 <indexterm role="option">
4595 <primary><option>-bp</option></primary>
4596 </indexterm>
4597 <indexterm role="concept">
4598 <primary>queue</primary>
4599 <secondary>listing messages in</secondary>
4600 </indexterm>
4601 <indexterm role="concept">
4602 <primary>listing</primary>
4603 <secondary>messages in the queue</secondary>
4604 </indexterm>
4605 This option requests a listing of the contents of the mail queue on the
4606 standard output. If the <option>-bp</option> option is followed by a list of message ids,
4607 just those messages are listed. By default, this option can be used only by an
4608 admin user. However, the <option>queue_list_requires_admin</option> option can be set false
4609 to allow any user to see the queue.
4610 </para>
4611 <para>
4612 Each message in the queue is displayed as in the following example:
4613 </para>
4614 <literallayout class="monospaced">
4615 25m  2.9K 0t5C6f-0000c8-00 &lt;alice@wonderland.fict.example&gt;
4616           red.king@looking-glass.fict.example
4617           &lt;other addresses&gt;
4618 </literallayout>
4619 <para>
4620 <indexterm role="concept">
4621 <primary>message</primary>
4622 <secondary>size in queue listing</secondary>
4623 </indexterm>
4624 <indexterm role="concept">
4625 <primary>size</primary>
4626 <secondary>of message</secondary>
4627 </indexterm>
4628 The first line contains the length of time the message has been in the queue
4629 (in this case 25 minutes), the size of the message (2.9K), the unique local
4630 identifier for the message, and the message sender, as contained in the
4631 envelope. For bounce messages, the sender address is empty, and appears as
4632 <quote>&lt;&gt;</quote>. If the message was submitted locally by an untrusted user who overrode
4633 the default sender address, the user&#x2019;s login name is shown in parentheses
4634 before the sender address.
4635 </para>
4636 <para>
4637 <indexterm role="concept">
4638 <primary>frozen messages</primary>
4639 <secondary>in queue listing</secondary>
4640 </indexterm>
4641 If the message is frozen (attempts to deliver it are suspended) then the text
4642 <quote>*** frozen ***</quote> is displayed at the end of this line.
4643 </para>
4644 <para>
4645 The recipients of the message (taken from the envelope, not the headers) are
4646 displayed on subsequent lines. Those addresses to which the message has already
4647 been delivered are marked with the letter D. If an original address gets
4648 expanded into several addresses via an alias or forward file, the original is
4649 displayed with a D only when deliveries for all of its child addresses are
4650 complete.
4651 </para>
4652 </listitem></varlistentry>
4653 <varlistentry>
4654 <term><option>-bpa</option></term>
4655 <listitem>
4656 <para>
4657 <indexterm role="option">
4658 <primary><option>-bpa</option></primary>
4659 </indexterm>
4660 This option operates like <option>-bp</option>, but in addition it shows delivered addresses
4661 that were generated from the original top level address(es) in each message by
4662 alias or forwarding operations. These addresses are flagged with <quote>+D</quote> instead
4663 of just <quote>D</quote>.
4664 </para>
4665 </listitem></varlistentry>
4666 <varlistentry>
4667 <term><option>-bpc</option></term>
4668 <listitem>
4669 <para>
4670 <indexterm role="option">
4671 <primary><option>-bpc</option></primary>
4672 </indexterm>
4673 <indexterm role="concept">
4674 <primary>queue</primary>
4675 <secondary>count of messages on</secondary>
4676 </indexterm>
4677 This option counts the number of messages in the queue, and writes the total
4678 to the standard output. It is restricted to admin users, unless
4679 <option>queue_list_requires_admin</option> is set false.
4680 </para>
4681 </listitem></varlistentry>
4682 <varlistentry>
4683 <term><option>-bpr</option></term>
4684 <listitem>
4685 <para>
4686 <indexterm role="option">
4687 <primary><option>-bpr</option></primary>
4688 </indexterm>
4689 This option operates like <option>-bp</option>, but the output is not sorted into
4690 chronological order of message arrival. This can speed it up when there are
4691 lots of messages in the queue, and is particularly useful if the output is
4692 going to be post-processed in a way that doesn&#x2019;t need the sorting.
4693 </para>
4694 </listitem></varlistentry>
4695 <varlistentry>
4696 <term><option>-bpra</option></term>
4697 <listitem>
4698 <para>
4699 <indexterm role="option">
4700 <primary><option>-bpra</option></primary>
4701 </indexterm>
4702 This option is a combination of <option>-bpr</option> and <option>-bpa</option>.
4703 </para>
4704 </listitem></varlistentry>
4705 <varlistentry>
4706 <term><option>-bpru</option></term>
4707 <listitem>
4708 <para>
4709 <indexterm role="option">
4710 <primary><option>-bpru</option></primary>
4711 </indexterm>
4712 This option is a combination of <option>-bpr</option> and <option>-bpu</option>.
4713 </para>
4714 </listitem></varlistentry>
4715 <varlistentry>
4716 <term><option>-bpu</option></term>
4717 <listitem>
4718 <para>
4719 <indexterm role="option">
4720 <primary><option>-bpu</option></primary>
4721 </indexterm>
4722 This option operates like <option>-bp</option> but shows only undelivered top-level
4723 addresses for each message displayed. Addresses generated by aliasing or
4724 forwarding are not shown, unless the message was deferred after processing by a
4725 router with the <option>one_time</option> option set.
4726 </para>
4727 </listitem></varlistentry>
4728 <varlistentry>
4729 <term><option>-brt</option></term>
4730 <listitem>
4731 <para>
4732 <indexterm role="option">
4733 <primary><option>-brt</option></primary>
4734 </indexterm>
4735 <indexterm role="concept">
4736 <primary>testing</primary>
4737 <secondary>retry configuration</secondary>
4738 </indexterm>
4739 <indexterm role="concept">
4740 <primary>retry</primary>
4741 <secondary>configuration testing</secondary>
4742 </indexterm>
4743 This option is for testing retry rules, and it must be followed by up to three
4744 arguments. It causes Exim to look for a retry rule that matches the values
4745 and to write it to the standard output. For example:
4746 </para>
4747 <literallayout class="monospaced">
4748 exim -brt bach.comp.mus.example
4749 Retry rule: *.comp.mus.example  F,2h,15m; F,4d,30m;
4750 </literallayout>
4751 <para>
4752 See chapter <xref linkend="CHAPretry"/> for a description of Exim&#x2019;s retry rules. The first
4753 argument, which is required, can be a complete address in the form
4754 <emphasis>local_part@domain</emphasis>, or it can be just a domain name. If the second argument
4755 contains a dot, it is interpreted as an optional second domain name; if no
4756 retry rule is found for the first argument, the second is tried. This ties in
4757 with Exim&#x2019;s behaviour when looking for retry rules for remote hosts &ndash; if no
4758 rule is found that matches the host, one that matches the mail domain is
4759 sought. Finally, an argument that is the name of a specific delivery error, as
4760 used in setting up retry rules, can be given. For example:
4761 </para>
4762 <literallayout class="monospaced">
4763 exim -brt haydn.comp.mus.example quota_3d
4764 Retry rule: *@haydn.comp.mus.example quota_3d  F,1h,15m
4765 </literallayout>
4766 </listitem></varlistentry>
4767 <varlistentry>
4768 <term><option>-brw</option></term>
4769 <listitem>
4770 <para>
4771 <indexterm role="option">
4772 <primary><option>-brw</option></primary>
4773 </indexterm>
4774 <indexterm role="concept">
4775 <primary>testing</primary>
4776 <secondary>rewriting</secondary>
4777 </indexterm>
4778 <indexterm role="concept">
4779 <primary>rewriting</primary>
4780 <secondary>testing</secondary>
4781 </indexterm>
4782 This option is for testing address rewriting rules, and it must be followed by
4783 a single argument, consisting of either a local part without a domain, or a
4784 complete address with a fully qualified domain. Exim outputs how this address
4785 would be rewritten for each possible place it might appear. See chapter
4786 <xref linkend="CHAPrewrite"/> for further details.
4787 </para>
4788 </listitem></varlistentry>
4789 <varlistentry>
4790 <term><option>-bS</option></term>
4791 <listitem>
4792 <para>
4793 <indexterm role="option">
4794 <primary><option>-bS</option></primary>
4795 </indexterm>
4796 <indexterm role="concept">
4797 <primary>SMTP</primary>
4798 <secondary>batched incoming</secondary>
4799 </indexterm>
4800 <indexterm role="concept">
4801 <primary>batched SMTP input</primary>
4802 </indexterm>
4803 This option is used for batched SMTP input, which is an alternative interface
4804 for non-interactive local message submission. A number of messages can be
4805 submitted in a single run. However, despite its name, this is not really SMTP
4806 input. Exim reads each message&#x2019;s envelope from SMTP commands on the standard
4807 input, but generates no responses. If the caller is trusted, or
4808 <option>untrusted_set_sender</option> is set, the senders in the SMTP MAIL commands are
4809 believed; otherwise the sender is always the caller of Exim.
4810 </para>
4811 <para>
4812 The message itself is read from the standard input, in SMTP format (leading
4813 dots doubled), terminated by a line containing just a single dot. An error is
4814 provoked if the terminating dot is missing. A further message may then follow.
4815 </para>
4816 <para>
4817 As for other local message submissions, the contents of incoming batch SMTP
4818 messages can be checked using the non-SMTP ACL (see chapter <xref linkend="CHAPACL"/>).
4819 Unqualified addresses are automatically qualified using <option>qualify_domain</option> and
4820 <option>qualify_recipient</option>, as appropriate, unless the <option>-bnq</option> option is used.
4821 </para>
4822 <para>
4823 Some other SMTP commands are recognized in the input. HELO and EHLO act
4824 as RSET; VRFY, EXPN, ETRN, and HELP act as NOOP;
4825 QUIT quits, ignoring the rest of the standard input.
4826 </para>
4827 <para>
4828 <indexterm role="concept">
4829 <primary>return code</primary>
4830 <secondary>for <option>-bS</option></secondary>
4831 </indexterm>
4832 If any error is encountered, reports are written to the standard output and
4833 error streams, and Exim gives up immediately. The return code is 0 if no error
4834 was detected; it is 1 if one or more messages were accepted before the error
4835 was detected; otherwise it is 2.
4836 </para>
4837 <para>
4838 More details of input using batched SMTP are given in section
4839 <xref linkend="SECTincomingbatchedSMTP"/>.
4840 </para>
4841 </listitem></varlistentry>
4842 <varlistentry>
4843 <term><option>-bs</option></term>
4844 <listitem>
4845 <para>
4846 <indexterm role="option">
4847 <primary><option>-bs</option></primary>
4848 </indexterm>
4849 <indexterm role="concept">
4850 <primary>SMTP</primary>
4851 <secondary>local input</secondary>
4852 </indexterm>
4853 <indexterm role="concept">
4854 <primary>local SMTP input</primary>
4855 </indexterm>
4856 This option causes Exim to accept one or more messages by reading SMTP commands
4857 on the standard input, and producing SMTP replies on the standard output. SMTP
4858 policy controls, as defined in ACLs (see chapter <xref linkend="CHAPACL"/>) are applied.
4859 Some user agents use this interface as a way of passing locally-generated
4860 messages to the MTA.
4861 </para>
4862 <para>
4863 In
4864 <indexterm role="concept">
4865 <primary>sender</primary>
4866 <secondary>source of</secondary>
4867 </indexterm>
4868 this usage, if the caller of Exim is trusted, or <option>untrusted_set_sender</option> is
4869 set, the senders of messages are taken from the SMTP MAIL commands.
4870 Otherwise the content of these commands is ignored and the sender is set up as
4871 the calling user. Unqualified addresses are automatically qualified using
4872 <option>qualify_domain</option> and <option>qualify_recipient</option>, as appropriate, unless the
4873 <option>-bnq</option> option is used.
4874 </para>
4875 <para>
4876 <indexterm role="concept">
4877 <primary>inetd</primary>
4878 </indexterm>
4879 The
4880 <option>-bs</option> option is also used to run Exim from <emphasis>inetd</emphasis>, as an alternative to
4881 using a listening daemon. Exim can distinguish the two cases by checking
4882 whether the standard input is a TCP/IP socket. When Exim is called from
4883 <emphasis>inetd</emphasis>, the source of the mail is assumed to be remote, and the comments
4884 above concerning senders and qualification do not apply. In this situation,
4885 Exim behaves in exactly the same way as it does when receiving a message via
4886 the listening daemon.
4887 </para>
4888 </listitem></varlistentry>
4889 <varlistentry>
4890 <term><option>-bt</option></term>
4891 <listitem>
4892 <para>
4893 <indexterm role="option">
4894 <primary><option>-bt</option></primary>
4895 </indexterm>
4896 <indexterm role="concept">
4897 <primary>testing</primary>
4898 <secondary>addresses</secondary>
4899 </indexterm>
4900 <indexterm role="concept">
4901 <primary>address</primary>
4902 <secondary>testing</secondary>
4903 </indexterm>
4904 This option runs Exim in address testing mode, in which each argument is taken
4905 as a recipient address to be tested for deliverability. The results are
4906 written to the standard output. If a test fails, and the caller is not an admin
4907 user, no details of the failure are output, because these might contain
4908 sensitive information such as usernames and passwords for database lookups.
4909 </para>
4910 <para>
4911 If no arguments are given, Exim runs in an interactive manner, prompting with a
4912 right angle bracket for addresses to be tested.
4913 </para>
4914 <para>
4915 Unlike the <option>-be</option> test option, you cannot arrange for Exim to use the
4916 <function>readline()</function> function, because it is running as <emphasis>root</emphasis> and there are
4917 security issues.
4918 </para>
4919 <para>
4920 Each address is handled as if it were the recipient address of a message
4921 (compare the <option>-bv</option> option). It is passed to the routers and the result is
4922 written to the standard output. However, any router that has
4923 <option>no_address_test</option> set is bypassed. This can make <option>-bt</option> easier to use for
4924 genuine routing tests if your first router passes everything to a scanner
4925 program.
4926 </para>
4927 <para>
4928 <indexterm role="concept">
4929 <primary>return code</primary>
4930 <secondary>for <option>-bt</option></secondary>
4931 </indexterm>
4932 The return code is 2 if any address failed outright; it is 1 if no address
4933 failed outright but at least one could not be resolved for some reason. Return
4934 code 0 is given only when all addresses succeed.
4935 </para>
4936 <para>
4937 <indexterm role="concept">
4938 <primary>duplicate addresses</primary>
4939 </indexterm>
4940 <emphasis role="bold">Note</emphasis>: When actually delivering a message, Exim removes duplicate recipient
4941 addresses after routing is complete, so that only one delivery takes place.
4942 This does not happen when testing with <option>-bt</option>; the full results of routing are
4943 always shown.
4944 </para>
4945 <para>
4946 <emphasis role="bold">Warning</emphasis>: <option>-bt</option> can only do relatively simple testing. If any of the
4947 routers in the configuration makes any tests on the sender address of a
4948 message,
4949 <indexterm role="option">
4950 <primary><option>-f</option></primary>
4951 <secondary>for address testing</secondary>
4952 </indexterm>
4953 you can use the <option>-f</option> option to set an appropriate sender when running
4954 <option>-bt</option> tests. Without it, the sender is assumed to be the calling user at the
4955 default qualifying domain. However, if you have set up (for example) routers
4956 whose behaviour depends on the contents of an incoming message, you cannot test
4957 those conditions using <option>-bt</option>. The <option>-N</option> option provides a possible way of
4958 doing such tests.
4959 </para>
4960 </listitem></varlistentry>
4961 <varlistentry>
4962 <term><option>-bV</option></term>
4963 <listitem>
4964 <para>
4965 <indexterm role="option">
4966 <primary><option>-bV</option></primary>
4967 </indexterm>
4968 <indexterm role="concept">
4969 <primary>version number of Exim</primary>
4970 </indexterm>
4971 This option causes Exim to write the current version number, compilation
4972 number, and compilation date of the <emphasis>exim</emphasis> binary to the standard output.
4973 It also lists the DBM library that is being used, the optional modules (such as
4974 specific lookup types), the drivers that are included in the binary, and the
4975 name of the runtime configuration file that is in use.
4976 </para>
4977 <para>
4978 As part of its operation, <option>-bV</option> causes Exim to read and syntax check its
4979 configuration file. However, this is a static check only. It cannot check
4980 values that are to be expanded. For example, although a misspelt ACL verb is
4981 detected, an error in the verb&#x2019;s arguments is not. You cannot rely on <option>-bV</option>
4982 alone to discover (for example) all the typos in the configuration; some
4983 realistic testing is needed. The <option>-bh</option> and <option>-N</option> options provide more
4984 dynamic testing facilities.
4985 </para>
4986 </listitem></varlistentry>
4987 <varlistentry>
4988 <term><option>-bv</option></term>
4989 <listitem>
4990 <para>
4991 <indexterm role="option">
4992 <primary><option>-bv</option></primary>
4993 </indexterm>
4994 <indexterm role="concept">
4995 <primary>verifying address</primary>
4996 <secondary>using <option>-bv</option></secondary>
4997 </indexterm>
4998 <indexterm role="concept">
4999 <primary>address</primary>
5000 <secondary>verification</secondary>
5001 </indexterm>
5002 This option runs Exim in address verification mode, in which each argument is
5003 taken as a recipient address to be verified by the routers. (This does
5004 not involve any verification callouts). During normal operation, verification
5005 happens mostly as a consequence processing a <option>verify</option> condition in an ACL
5006 (see chapter <xref linkend="CHAPACL"/>). If you want to test an entire ACL, possibly
5007 including callouts, see the <option>-bh</option> and <option>-bhc</option> options.
5008 </para>
5009 <para>
5010 If verification fails, and the caller is not an admin user, no details of the
5011 failure are output, because these might contain sensitive information such as
5012 usernames and passwords for database lookups.
5013 </para>
5014 <para>
5015 If no arguments are given, Exim runs in an interactive manner, prompting with a
5016 right angle bracket for addresses to be verified.
5017 </para>
5018 <para>
5019 Unlike the <option>-be</option> test option, you cannot arrange for Exim to use the
5020 <function>readline()</function> function, because it is running as <emphasis>exim</emphasis> and there are
5021 security issues.
5022 </para>
5023 <para>
5024 Verification differs from address testing (the <option>-bt</option> option) in that routers
5025 that have <option>no_verify</option> set are skipped, and if the address is accepted by a
5026 router that has <option>fail_verify</option> set, verification fails. The address is
5027 verified as a recipient if <option>-bv</option> is used; to test verification for a sender
5028 address, <option>-bvs</option> should be used.
5029 </para>
5030 <para>
5031 If the <option>-v</option> option is not set, the output consists of a single line for each
5032 address, stating whether it was verified or not, and giving a reason in the
5033 latter case. Without <option>-v</option>, generating more than one address by redirection
5034 causes verification to end successfully, without considering the generated
5035 addresses. However, if just one address is generated, processing continues,
5036 and the generated address must verify successfully for the overall verification
5037 to succeed.
5038 </para>
5039 <para>
5040 When <option>-v</option> is set, more details are given of how the address has been handled,
5041 and in the case of address redirection, all the generated addresses are also
5042 considered. Verification may succeed for some and fail for others.
5043 </para>
5044 <para>
5045 The
5046 <indexterm role="concept">
5047 <primary>return code</primary>
5048 <secondary>for <option>-bv</option></secondary>
5049 </indexterm>
5050 return code is 2 if any address failed outright; it is 1 if no address
5051 failed outright but at least one could not be resolved for some reason. Return
5052 code 0 is given only when all addresses succeed.
5053 </para>
5054 <para>
5055 If any of the routers in the configuration makes any tests on the sender
5056 address of a message, you should use the <option>-f</option> option to set an appropriate
5057 sender when running <option>-bv</option> tests. Without it, the sender is assumed to be the
5058 calling user at the default qualifying domain.
5059 </para>
5060 </listitem></varlistentry>
5061 <varlistentry>
5062 <term><option>-bvs</option></term>
5063 <listitem>
5064 <para>
5065 <indexterm role="option">
5066 <primary><option>-bvs</option></primary>
5067 </indexterm>
5068 This option acts like <option>-bv</option>, but verifies the address as a sender rather
5069 than a recipient address. This affects any rewriting and qualification that
5070 might happen.
5071 </para>
5072 </listitem></varlistentry>
5073 <varlistentry>
5074 <term><option>-bw</option></term>
5075 <listitem>
5076 <para>
5077 <indexterm role="option">
5078 <primary><option>-bw</option></primary>
5079 </indexterm>
5080 <indexterm role="concept">
5081 <primary>daemon</primary>
5082 </indexterm>
5083 <indexterm role="concept">
5084 <primary>inetd</primary>
5085 </indexterm>
5086 <indexterm role="concept">
5087 <primary>inetd</primary>
5088 <secondary>wait mode</secondary>
5089 </indexterm>
5090 This option runs Exim as a daemon, awaiting incoming SMTP connections,
5091 similarly to the <option>-bd</option> option.  All port specifications on the command-line
5092 and in the configuration file are ignored.  Queue-running may not be specified.
5093 </para>
5094 <para>
5095 In this mode, Exim expects to be passed a socket as fd 0 (stdin) which is
5096 listening for connections.  This permits the system to start up and have
5097 inetd (or equivalent) listen on the SMTP ports, starting an Exim daemon for
5098 each port only when the first connection is received.
5099 </para>
5100 <para>
5101 If the option is given as <option>-bw</option>&lt;<emphasis>time</emphasis>&gt; then the time is a timeout, after
5102 which the daemon will exit, which should cause inetd to listen once more.
5103 </para>
5104 </listitem></varlistentry>
5105 <varlistentry>
5106 <term><option>-C</option>&nbsp;&lt;<emphasis>filelist</emphasis>&gt;</term>
5107 <listitem>
5108 <para>
5109 <indexterm role="option">
5110 <primary><option>-C</option></primary>
5111 </indexterm>
5112 <indexterm role="concept">
5113 <primary>configuration file</primary>
5114 <secondary>alternate</secondary>
5115 </indexterm>
5116 <indexterm role="concept">
5117 <primary>CONFIGURE_FILE</primary>
5118 </indexterm>
5119 <indexterm role="concept">
5120 <primary>alternate configuration file</primary>
5121 </indexterm>
5122 This option causes Exim to find the runtime configuration file from the given
5123 list instead of from the list specified by the CONFIGURE_FILE
5124 compile-time setting. Usually, the list will consist of just a single filename,
5125 but it can be a colon-separated list of names. In this case, the first
5126 file that exists is used. Failure to open an existing file stops Exim from
5127 proceeding any further along the list, and an error is generated.
5128 </para>
5129 <para>
5130 When this option is used by a caller other than root, and the list is different
5131 from the compiled-in list, Exim gives up its root privilege immediately, and
5132 runs with the real and effective uid and gid set to those of the caller.
5133 However, if a TRUSTED_CONFIG_LIST file is defined in <filename>Local/Makefile</filename>, that
5134 file contains a list of full pathnames, one per line, for configuration files
5135 which are trusted. Root privilege is retained for any configuration file so
5136 listed, as long as the caller is the Exim user (or the user specified in the
5137 CONFIGURE_OWNER option, if any), and as long as the configuration file is
5138 not writeable by inappropriate users or groups.
5139 </para>
5140 <para>
5141 Leaving TRUSTED_CONFIG_LIST unset precludes the possibility of testing a
5142 configuration using <option>-C</option> right through message reception and delivery,
5143 even if the caller is root. The reception works, but by that time, Exim is
5144 running as the Exim user, so when it re-executes to regain privilege for the
5145 delivery, the use of <option>-C</option> causes privilege to be lost. However, root can
5146 test reception and delivery using two separate commands (one to put a message
5147 in the queue, using <option>-odq</option>, and another to do the delivery, using <option>-M</option>).
5148 </para>
5149 <para>
5150 If ALT_CONFIG_PREFIX is defined <filename>in Local/Makefile</filename>, it specifies a
5151 prefix string with which any file named in a <option>-C</option> command line option
5152 must start. In addition, the filename must not contain the sequence <literal>/../</literal>.
5153 However, if the value of the <option>-C</option> option is identical to the value of
5154 CONFIGURE_FILE in <filename>Local/Makefile</filename>, Exim ignores <option>-C</option> and proceeds as
5155 usual. There is no default setting for ALT_CONFIG_PREFIX; when it is
5156 unset, any filename can be used with <option>-C</option>.
5157 </para>
5158 <para>
5159 ALT_CONFIG_PREFIX can be used to confine alternative configuration files
5160 to a directory to which only root has access. This prevents someone who has
5161 broken into the Exim account from running a privileged Exim with an arbitrary
5162 configuration file.
5163 </para>
5164 <para>
5165 The <option>-C</option> facility is useful for ensuring that configuration files are
5166 syntactically correct, but cannot be used for test deliveries, unless the
5167 caller is privileged, or unless it is an exotic configuration that does not
5168 require privilege. No check is made on the owner or group of the files
5169 specified by this option.
5170 </para>
5171 </listitem></varlistentry>
5172 <varlistentry>
5173 <term><option>-D</option>&lt;<emphasis>macro</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt;</term>
5174 <listitem>
5175 <para>
5176 <indexterm role="option">
5177 <primary><option>-D</option></primary>
5178 </indexterm>
5179 <indexterm role="concept">
5180 <primary>macro</primary>
5181 <secondary>setting on command line</secondary>
5182 </indexterm>
5183 This option can be used to override macro definitions in the configuration file
5184 (see section <xref linkend="SECTmacrodefs"/>). However, like <option>-C</option>, if it is used by an
5185 unprivileged caller, it causes Exim to give up its root privilege.
5186 If DISABLE_D_OPTION is defined in <filename>Local/Makefile</filename>, the use of <option>-D</option> is
5187 completely disabled, and its use causes an immediate error exit.
5188 </para>
5189 <para>
5190 If WHITELIST_D_MACROS is defined in <filename>Local/Makefile</filename> then it should be a
5191 colon-separated list of macros which are considered safe and, if <option>-D</option> only
5192 supplies macros from this list, and the values are acceptable, then Exim will
5193 not give up root privilege if the caller is root, the Exim run-time user, or
5194 the CONFIGURE_OWNER, if set.  This is a transition mechanism and is expected
5195 to be removed in the future.  Acceptable values for the macros satisfy the
5196 regexp: <literal>^[A-Za-z0-9_/.-]*$</literal>
5197 </para>
5198 <para>
5199 The entire option (including equals sign if present) must all be within one
5200 command line item. <option>-D</option> can be used to set the value of a macro to the empty
5201 string, in which case the equals sign is optional. These two commands are
5202 synonymous:
5203 </para>
5204 <literallayout class="monospaced">
5205 exim -DABC  ...
5206 exim -DABC= ...
5207 </literallayout>
5208 <para>
5209 To include spaces in a macro definition item, quotes must be used. If you use
5210 quotes, spaces are permitted around the macro name and the equals sign. For
5211 example:
5212 </para>
5213 <literallayout class="monospaced">
5214 exim '-D ABC = something' ...
5215 </literallayout>
5216 <para>
5217 <option>-D</option> may be repeated up to 10 times on a command line.
5218 Only macro names up to 22 letters long can be set.
5219 </para>
5220 </listitem></varlistentry>
5221 <varlistentry>
5222 <term><option>-d</option>&lt;<emphasis>debug&nbsp;options</emphasis>&gt;</term>
5223 <listitem>
5224 <para>
5225 <indexterm role="option">
5226 <primary><option>-d</option></primary>
5227 </indexterm>
5228 <indexterm role="concept">
5229 <primary>debugging</primary>
5230 <secondary>list of selectors</secondary>
5231 </indexterm>
5232 <indexterm role="concept">
5233 <primary>debugging</primary>
5234 <secondary><option>-d</option> option</secondary>
5235 </indexterm>
5236 This option causes debugging information to be written to the standard
5237 error stream. It is restricted to admin users because debugging output may show
5238 database queries that contain password information. Also, the details of users&#x2019;
5239 filter files should be protected. If a non-admin user uses <option>-d</option>, Exim
5240 writes an error message to the standard error stream and exits with a non-zero
5241 return code.
5242 </para>
5243 <para>
5244 When <option>-d</option> is used, <option>-v</option> is assumed. If <option>-d</option> is given on its own, a lot of
5245 standard debugging data is output. This can be reduced, or increased to include
5246 some more rarely needed information, by directly following <option>-d</option> with a string
5247 made up of names preceded by plus or minus characters. These add or remove sets
5248 of debugging data, respectively. For example, <option>-d+filter</option> adds filter
5249 debugging, whereas <option>-d-all+filter</option> selects only filter debugging. Note that
5250 no spaces are allowed in the debug setting. The available debugging categories
5251 are:
5252 </para>
5253 <literallayout>
5254 <literal>acl            </literal> ACL interpretation
5255 <literal>auth           </literal> authenticators
5256 <literal>deliver        </literal> general delivery logic
5257 <literal>dns            </literal> DNS lookups (see also resolver)
5258 <literal>dnsbl          </literal> DNS black list (aka RBL) code
5259 <literal>exec           </literal> arguments for <function>execv()</function> calls
5260 <literal>expand         </literal> detailed debugging for string expansions
5261 <literal>filter         </literal> filter handling
5262 <literal>hints_lookup   </literal> hints data lookups
5263 <literal>host_lookup    </literal> all types of name-to-IP address handling
5264 <literal>ident          </literal> ident lookup
5265 <literal>interface      </literal> lists of local interfaces
5266 <literal>lists          </literal> matching things in lists
5267 <literal>load           </literal> system load checks
5268 <literal>local_scan     </literal> can be used by <function>local_scan()</function> (see chapter <xref linkend="CHAPlocalscan"/>)
5269 <literal>lookup         </literal> general lookup code and all lookups
5270 <literal>memory         </literal> memory handling
5271 <literal>noutf8         </literal> modifier: avoid UTF-8 line-drawing
5272 <literal>pid            </literal> modifier: add pid to debug output lines
5273 <literal>process_info   </literal> setting info for the process log
5274 <literal>queue_run      </literal> queue runs
5275 <literal>receive        </literal> general message reception logic
5276 <literal>resolver       </literal> turn on the DNS resolver&#x2019;s debugging output
5277 <literal>retry          </literal> retry handling
5278 <literal>rewrite        </literal> address rewriting
5279 <literal>route          </literal> address routing
5280 <literal>timestamp      </literal> modifier: add timestamp to debug output lines
5281 <literal>tls            </literal> TLS logic
5282 <literal>transport      </literal> transports
5283 <literal>uid            </literal> changes of uid/gid and looking up uid/gid
5284 <literal>verify         </literal> address verification logic
5285 <literal>all            </literal> almost all of the above (see below), and also <option>-v</option>
5286 </literallayout>
5287 <para>
5288 The <literal>all</literal> option excludes <literal>memory</literal> when used as <literal>+all</literal>, but includes it
5289 for <literal>-all</literal>. The reason for this is that <literal>+all</literal> is something that people
5290 tend to use when generating debug output for Exim maintainers. If <literal>+memory</literal>
5291 is included, an awful lot of output that is very rarely of interest is
5292 generated, so it now has to be explicitly requested. However, <literal>-all</literal> does
5293 turn everything off.
5294 </para>
5295 <para>
5296 <indexterm role="concept">
5297 <primary>resolver, debugging output</primary>
5298 </indexterm>
5299 <indexterm role="concept">
5300 <primary>DNS resolver, debugging output</primary>
5301 </indexterm>
5302 The <literal>resolver</literal> option produces output only if the DNS resolver was compiled
5303 with DEBUG enabled. This is not the case in some operating systems. Also,
5304 unfortunately, debugging output from the DNS resolver is written to stdout
5305 rather than stderr.
5306 </para>
5307 <para>
5308 The default (<option>-d</option> with no argument) omits <literal>expand</literal>, <literal>filter</literal>,
5309 <literal>interface</literal>, <literal>load</literal>, <literal>memory</literal>, <literal>pid</literal>, <literal>resolver</literal>, and <literal>timestamp</literal>.
5310 However, the <literal>pid</literal> selector is forced when debugging is turned on for a
5311 daemon, which then passes it on to any re-executed Exims. Exim also
5312 automatically adds the pid to debug lines when several remote deliveries are
5313 run in parallel.
5314 </para>
5315 <para>
5316 The <literal>timestamp</literal> selector causes the current time to be inserted at the start
5317 of all debug output lines. This can be useful when trying to track down delays
5318 in processing.
5319 </para>
5320 <para>
5321 <indexterm role="concept">
5322 <primary>debugging</primary>
5323 <secondary>UTF-8 in</secondary>
5324 </indexterm>
5325 <indexterm role="concept">
5326 <primary>UTF-8</primary>
5327 <secondary>in debug output</secondary>
5328 </indexterm>
5329 The <literal>noutf8</literal> selector disables the use of
5330 UTF-8 line-drawing characters to group related information.
5331 When disabled. ascii-art is used instead.
5332 Using the <literal>+all</literal> option does not set this modifier,
5333 </para>
5334 <para>
5335 If the <option>debug_print</option> option is set in any driver, it produces output whenever
5336 any debugging is selected, or if <option>-v</option> is used.
5337 </para>
5338 </listitem></varlistentry>
5339 <varlistentry>
5340 <term><option>-dd</option>&lt;<emphasis>debug&nbsp;options</emphasis>&gt;</term>
5341 <listitem>
5342 <para>
5343 <indexterm role="option">
5344 <primary><option>-dd</option></primary>
5345 </indexterm>
5346 This option behaves exactly like <option>-d</option> except when used on a command that
5347 starts a daemon process. In that case, debugging is turned off for the
5348 subprocesses that the daemon creates. Thus, it is useful for monitoring the
5349 behaviour of the daemon without creating as much output as full debugging does.
5350 </para>
5351 </listitem></varlistentry>
5352 <varlistentry>
5353 <term><option>-dropcr</option></term>
5354 <listitem>
5355 <para>
5356 <indexterm role="option">
5357 <primary><option>-dropcr</option></primary>
5358 </indexterm>
5359 This is an obsolete option that is now a no-op. It used to affect the way Exim
5360 handled CR and LF characters in incoming messages. What happens now is
5361 described in section <xref linkend="SECTlineendings"/>.
5362 </para>
5363 </listitem></varlistentry>
5364 <varlistentry>
5365 <term><option>-E</option></term>
5366 <listitem>
5367 <para>
5368 <indexterm role="option">
5369 <primary><option>-E</option></primary>
5370 </indexterm>
5371 <indexterm role="concept">
5372 <primary>bounce message</primary>
5373 <secondary>generating</secondary>
5374 </indexterm>
5375 This option specifies that an incoming message is a locally-generated delivery
5376 failure report. It is used internally by Exim when handling delivery failures
5377 and is not intended for external use. Its only effect is to stop Exim
5378 generating certain messages to the postmaster, as otherwise message cascades
5379 could occur in some situations. As part of the same option, a message id may
5380 follow the characters <option>-E</option>. If it does, the log entry for the receipt of the
5381 new message contains the id, following <quote>R=</quote>, as a cross-reference.
5382 </para>
5383 </listitem></varlistentry>
5384 <varlistentry>
5385 <term><option>-e</option><emphasis>x</emphasis></term>
5386 <listitem>
5387 <para>
5388 <indexterm role="option">
5389 <primary><option>-e</option><emphasis>x</emphasis></primary>
5390 </indexterm>
5391 There are a number of Sendmail options starting with <option>-oe</option> which seem to be
5392 called by various programs without the leading <option>o</option> in the option. For
5393 example, the <option>vacation</option> program uses <option>-eq</option>. Exim treats all options of the
5394 form <option>-e</option><emphasis>x</emphasis> as synonymous with the corresponding <option>-oe</option><emphasis>x</emphasis> options.
5395 </para>
5396 </listitem></varlistentry>
5397 <varlistentry>
5398 <term><option>-F</option>&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
5399 <listitem>
5400 <para>
5401 <indexterm role="option">
5402 <primary><option>-F</option></primary>
5403 </indexterm>
5404 <indexterm role="concept">
5405 <primary>sender</primary>
5406 <secondary>name</secondary>
5407 </indexterm>
5408 <indexterm role="concept">
5409 <primary>name</primary>
5410 <secondary>of sender</secondary>
5411 </indexterm>
5412 This option sets the sender&#x2019;s full name for use when a locally-generated
5413 message is being accepted. In the absence of this option, the user&#x2019;s <emphasis>gecos</emphasis>
5414 entry from the password data is used. As users are generally permitted to alter
5415 their <emphasis>gecos</emphasis> entries, no security considerations are involved. White space
5416 between <option>-F</option> and the &lt;<emphasis>string</emphasis>&gt; is optional.
5417 </para>
5418 </listitem></varlistentry>
5419 <varlistentry>
5420 <term><option>-f</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;</term>
5421 <listitem>
5422 <para>
5423 <indexterm role="option">
5424 <primary><option>-f</option></primary>
5425 </indexterm>
5426 <indexterm role="concept">
5427 <primary>sender</primary>
5428 <secondary>address</secondary>
5429 </indexterm>
5430 <indexterm role="concept">
5431 <primary>address</primary>
5432 <secondary>sender</secondary>
5433 </indexterm>
5434 <indexterm role="concept">
5435 <primary>trusted users</primary>
5436 </indexterm>
5437 <indexterm role="concept">
5438 <primary>envelope from</primary>
5439 </indexterm>
5440 <indexterm role="concept">
5441 <primary>envelope sender</primary>
5442 </indexterm>
5443 <indexterm role="concept">
5444 <primary>user</primary>
5445 <secondary>trusted</secondary>
5446 </indexterm>
5447 This option sets the address of the envelope sender of a locally-generated
5448 message (also known as the return path). The option can normally be used only
5449 by a trusted user, but <option>untrusted_set_sender</option> can be set to allow untrusted
5450 users to use it.
5451 </para>
5452 <para>
5453 Processes running as root or the Exim user are always trusted. Other
5454 trusted users are defined by the <option>trusted_users</option> or <option>trusted_groups</option>
5455 options. In the absence of <option>-f</option>, or if the caller is not trusted, the sender
5456 of a local message is set to the caller&#x2019;s login name at the default qualify
5457 domain.
5458 </para>
5459 <para>
5460 There is one exception to the restriction on the use of <option>-f</option>: an empty sender
5461 can be specified by any user, trusted or not, to create a message that can
5462 never provoke a bounce. An empty sender can be specified either as an empty
5463 string, or as a pair of angle brackets with nothing between them, as in these
5464 examples of shell commands:
5465 </para>
5466 <literallayout class="monospaced">
5467 exim -f '&lt;&gt;' user@domain
5468 exim -f "" user@domain
5469 </literallayout>
5470 <para>
5471 In addition, the use of <option>-f</option> is not restricted when testing a filter file
5472 with <option>-bf</option> or when testing or verifying addresses using the <option>-bt</option> or
5473 <option>-bv</option> options.
5474 </para>
5475 <para>
5476 Allowing untrusted users to change the sender address does not of itself make
5477 it possible to send anonymous mail. Exim still checks that the <emphasis>From:</emphasis> header
5478 refers to the local user, and if it does not, it adds a <emphasis>Sender:</emphasis> header,
5479 though this can be overridden by setting <option>no_local_from_check</option>.
5480 </para>
5481 <para>
5482 White
5483 <indexterm role="concept">
5484 <primary><quote>From</quote> line</primary>
5485 </indexterm>
5486 space between <option>-f</option> and the &lt;<emphasis>address</emphasis>&gt; is optional (that is, they can be
5487 given as two arguments or one combined argument). The sender of a
5488 locally-generated message can also be set (when permitted) by an initial
5489 <quote>From&nbsp;</quote> line in the message &ndash; see the description of <option>-bm</option> above &ndash; but
5490 if <option>-f</option> is also present, it overrides <quote>From&nbsp;</quote>.
5491 </para>
5492 </listitem></varlistentry>
5493 <varlistentry>
5494 <term><option>-G</option></term>
5495 <listitem>
5496 <para>
5497 <indexterm role="option">
5498 <primary><option>-G</option></primary>
5499 </indexterm>
5500 <indexterm role="concept">
5501 <primary>submission fixups, suppressing (command-line)</primary>
5502 </indexterm>
5503 This option is equivalent to an ACL applying:
5504 </para>
5505 <literallayout class="monospaced">
5506 control = suppress_local_fixups
5507 </literallayout>
5508 <para>
5509 for every message received.  Note that Sendmail will complain about such
5510 bad formatting, where Exim silently just does not fix it up.  This may change
5511 in future.
5512 </para>
5513 <para>
5514 As this affects audit information, the caller must be a trusted user to use
5515 this option.
5516 </para>
5517 </listitem></varlistentry>
5518 <varlistentry>
5519 <term><option>-h</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;</term>
5520 <listitem>
5521 <para>
5522 <indexterm role="option">
5523 <primary><option>-h</option></primary>
5524 </indexterm>
5525 <indexterm role="concept">
5526 <primary>Sendmail compatibility</primary>
5527 <secondary><option>-h</option> option ignored</secondary>
5528 </indexterm>
5529 This option is accepted for compatibility with Sendmail, but has no effect. (In
5530 Sendmail it overrides the <quote>hop count</quote> obtained by counting <emphasis>Received:</emphasis>
5531 headers.)
5532 </para>
5533 </listitem></varlistentry>
5534 <varlistentry>
5535 <term><option>-i</option></term>
5536 <listitem>
5537 <para>
5538 <indexterm role="option">
5539 <primary><option>-i</option></primary>
5540 </indexterm>
5541 <indexterm role="concept">
5542 <primary>Solaris</primary>
5543 <secondary><emphasis>mail</emphasis> command</secondary>
5544 </indexterm>
5545 <indexterm role="concept">
5546 <primary>dot</primary>
5547 <secondary>in incoming non-SMTP message</secondary>
5548 </indexterm>
5549 This option, which has the same effect as <option>-oi</option>, specifies that a dot on a
5550 line by itself should not terminate an incoming, non-SMTP message. I can find
5551 no documentation for this option in Solaris 2.4 Sendmail, but the <emphasis>mailx</emphasis>
5552 command in Solaris 2.4 uses it. See also <option>-ti</option>.
5553 </para>
5554 </listitem></varlistentry>
5555 <varlistentry>
5556 <term><option>-L</option>&nbsp;&lt;<emphasis>tag</emphasis>&gt;</term>
5557 <listitem>
5558 <para>
5559 <indexterm role="option">
5560 <primary><option>-L</option></primary>
5561 </indexterm>
5562 <indexterm role="concept">
5563 <primary>syslog</primary>
5564 <secondary>process name; set with flag</secondary>
5565 </indexterm>
5566 This option is equivalent to setting <option>syslog_processname</option> in the config
5567 file and setting <option>log_file_path</option> to <literal>syslog</literal>.
5568 Its use is restricted to administrators.  The configuration file has to be
5569 read and parsed, to determine access rights, before this is set and takes
5570 effect, so early configuration file errors will not honour this flag.
5571 </para>
5572 <para>
5573 The tag should not be longer than 32 characters.
5574 </para>
5575 </listitem></varlistentry>
5576 <varlistentry>
5577 <term><option>-M</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5578 <listitem>
5579 <para>
5580 <indexterm role="option">
5581 <primary><option>-M</option></primary>
5582 </indexterm>
5583 <indexterm role="concept">
5584 <primary>forcing delivery</primary>
5585 </indexterm>
5586 <indexterm role="concept">
5587 <primary>delivery</primary>
5588 <secondary>forcing attempt</secondary>
5589 </indexterm>
5590 <indexterm role="concept">
5591 <primary>frozen messages</primary>
5592 <secondary>forcing delivery</secondary>
5593 </indexterm>
5594 This option requests Exim to run a delivery attempt on each message in turn. If
5595 any of the messages are frozen, they are automatically thawed before the
5596 delivery attempt. The settings of <option>queue_domains</option>, <option>queue_smtp_domains</option>,
5597 and <option>hold_domains</option> are ignored.
5598 </para>
5599 <para>
5600 Retry
5601 <indexterm role="concept">
5602 <primary>hints database</primary>
5603 <secondary>overriding retry hints</secondary>
5604 </indexterm>
5605 hints for any of the addresses are overridden &ndash; Exim tries to deliver even if
5606 the normal retry time has not yet been reached. This option requires the caller
5607 to be an admin user. However, there is an option called <option>prod_requires_admin</option>
5608 which can be set false to relax this restriction (and also the same requirement
5609 for the <option>-q</option>, <option>-R</option>, and <option>-S</option> options).
5610 </para>
5611 <para>
5612 The deliveries happen synchronously, that is, the original Exim process does
5613 not terminate until all the delivery attempts have finished. No output is
5614 produced unless there is a serious error. If you want to see what is happening,
5615 use the <option>-v</option> option as well, or inspect Exim&#x2019;s main log.
5616 </para>
5617 </listitem></varlistentry>
5618 <varlistentry>
5619 <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>
5620 <listitem>
5621 <para>
5622 <indexterm role="option">
5623 <primary><option>-Mar</option></primary>
5624 </indexterm>
5625 <indexterm role="concept">
5626 <primary>message</primary>
5627 <secondary>adding recipients</secondary>
5628 </indexterm>
5629 <indexterm role="concept">
5630 <primary>recipient</primary>
5631 <secondary>adding</secondary>
5632 </indexterm>
5633 This option requests Exim to add the addresses to the list of recipients of the
5634 message (<quote>ar</quote> for <quote>add recipients</quote>). The first argument must be a message
5635 id, and the remaining ones must be email addresses. However, if the message is
5636 active (in the middle of a delivery attempt), it is not altered. This option
5637 can be used only by an admin user.
5638 </para>
5639 </listitem></varlistentry>
5640 <varlistentry>
5641 <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>
5642 <listitem>
5643 <para>
5644 <indexterm role="option">
5645 <primary><option>-MC</option></primary>
5646 </indexterm>
5647 <indexterm role="concept">
5648 <primary>SMTP</primary>
5649 <secondary>passed connection</secondary>
5650 </indexterm>
5651 <indexterm role="concept">
5652 <primary>SMTP</primary>
5653 <secondary>multiple deliveries</secondary>
5654 </indexterm>
5655 <indexterm role="concept">
5656 <primary>multiple SMTP deliveries</primary>
5657 </indexterm>
5658 This option is not intended for use by external callers. It is used internally
5659 by Exim to invoke another instance of itself to deliver a waiting message using
5660 an existing SMTP connection, which is passed as the standard input. Details are
5661 given in chapter <xref linkend="CHAPSMTP"/>. This must be the final option, and the caller
5662 must be root or the Exim user in order to use it.
5663 </para>
5664 </listitem></varlistentry>
5665 <varlistentry>
5666 <term><option>-MCA</option></term>
5667 <listitem>
5668 <para>
5669 <indexterm role="option">
5670 <primary><option>-MCA</option></primary>
5671 </indexterm>
5672 This option is not intended for use by external callers. It is used internally
5673 by Exim in conjunction with the <option>-MC</option> option. It signifies that the
5674 connection to the remote host has been authenticated.
5675 </para>
5676 </listitem></varlistentry>
5677 <varlistentry>
5678 <term><option>-MCD</option></term>
5679 <listitem>
5680 <para>
5681 <indexterm role="option">
5682 <primary><option>-MCD</option></primary>
5683 </indexterm>
5684 This option is not intended for use by external callers. It is used internally
5685 by Exim in conjunction with the <option>-MC</option> option. It signifies that the
5686 remote host supports the ESMTP <filename>DSN</filename> extension.
5687 </para>
5688 </listitem></varlistentry>
5689 <varlistentry>
5690 <term><option>-MCG</option>&nbsp;&lt;<emphasis>queue&nbsp;name</emphasis>&gt;</term>
5691 <listitem>
5692 <para>
5693 <indexterm role="option">
5694 <primary><option>-MCG</option></primary>
5695 </indexterm>
5696 This option is not intended for use by external callers. It is used internally
5697 by Exim in conjunction with the <option>-MC</option> option. It signifies that an
5698 alternate queue is used, named by the following argument.
5699 </para>
5700 </listitem></varlistentry>
5701 <varlistentry>
5702 <term><option>-MCK</option></term>
5703 <listitem>
5704 <para>
5705 <indexterm role="option">
5706 <primary><option>-MCK</option></primary>
5707 </indexterm>
5708 This option is not intended for use by external callers. It is used internally
5709 by Exim in conjunction with the <option>-MC</option> option. It signifies that a
5710 remote host supports the ESMTP <filename>CHUNKING</filename> extension.
5711 </para>
5712 </listitem></varlistentry>
5713 <varlistentry>
5714 <term><option>-MCP</option></term>
5715 <listitem>
5716 <para>
5717 <indexterm role="option">
5718 <primary><option>-MCP</option></primary>
5719 </indexterm>
5720 This option is not intended for use by external callers. It is used internally
5721 by Exim in conjunction with the <option>-MC</option> option. It signifies that the server to
5722 which Exim is connected supports pipelining.
5723 </para>
5724 </listitem></varlistentry>
5725 <varlistentry>
5726 <term><option>-MCQ</option>&nbsp;&lt;<emphasis>process&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>pipe&nbsp;fd</emphasis>&gt;</term>
5727 <listitem>
5728 <para>
5729 <indexterm role="option">
5730 <primary><option>-MCQ</option></primary>
5731 </indexterm>
5732 This option is not intended for use by external callers. It is used internally
5733 by Exim in conjunction with the <option>-MC</option> option when the original delivery was
5734 started by a queue runner. It passes on the process id of the queue runner,
5735 together with the file descriptor number of an open pipe. Closure of the pipe
5736 signals the final completion of the sequence of processes that are passing
5737 messages through the same SMTP connection.
5738 </para>
5739 </listitem></varlistentry>
5740 <varlistentry>
5741 <term><option>-MCS</option></term>
5742 <listitem>
5743 <para>
5744 <indexterm role="option">
5745 <primary><option>-MCS</option></primary>
5746 </indexterm>
5747 This option is not intended for use by external callers. It is used internally
5748 by Exim in conjunction with the <option>-MC</option> option, and passes on the fact that the
5749 SMTP SIZE option should be used on messages delivered down the existing
5750 connection.
5751 </para>
5752 </listitem></varlistentry>
5753 <varlistentry>
5754 <term><option>-MCT</option></term>
5755 <listitem>
5756 <para>
5757 <indexterm role="option">
5758 <primary><option>-MCT</option></primary>
5759 </indexterm>
5760 This option is not intended for use by external callers. It is used internally
5761 by Exim in conjunction with the <option>-MC</option> option, and passes on the fact that the
5762 host to which Exim is connected supports TLS encryption.
5763 </para>
5764 </listitem></varlistentry>
5765 <varlistentry>
5766 <term><option>-MCt</option>&nbsp;&lt;<emphasis>IP&nbsp;address</emphasis>&gt;&nbsp;&lt;<emphasis>port</emphasis>&gt;&nbsp;&lt;<emphasis>cipher</emphasis>&gt;</term>
5767 <listitem>
5768 <para>
5769 <indexterm role="option">
5770 <primary><option>-MCt</option></primary>
5771 </indexterm>
5772 This option is not intended for use by external callers. It is used internally
5773 by Exim in conjunction with the <option>-MC</option> option, and passes on the fact that the
5774 connection is being proxied by a parent process for handling TLS encryption.
5775 The arguments give the local address and port being proxied, and the TLS cipher.
5776 </para>
5777 </listitem></varlistentry>
5778 <varlistentry>
5779 <term><option>-Mc</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5780 <listitem>
5781 <para>
5782 <indexterm role="option">
5783 <primary><option>-Mc</option></primary>
5784 </indexterm>
5785 <indexterm role="concept">
5786 <primary>hints database</primary>
5787 <secondary>not overridden by <option>-Mc</option></secondary>
5788 </indexterm>
5789 <indexterm role="concept">
5790 <primary>delivery</primary>
5791 <secondary>manually started &ndash; not forced</secondary>
5792 </indexterm>
5793 This option requests Exim to run a delivery attempt on each message, in turn,
5794 but unlike the <option>-M</option> option, it does check for retry hints, and respects any
5795 that are found. This option is not very useful to external callers. It is
5796 provided mainly for internal use by Exim when it needs to re-invoke itself in
5797 order to regain root privilege for a delivery (see chapter <xref linkend="CHAPsecurity"/>).
5798 However, <option>-Mc</option> can be useful when testing, in order to run a delivery that
5799 respects retry times and other options such as <option>hold_domains</option> that are
5800 overridden when <option>-M</option> is used. Such a delivery does not count as a queue run.
5801 If you want to run a specific delivery as if in a queue run, you should use
5802 <option>-q</option> with a message id argument. A distinction between queue run deliveries
5803 and other deliveries is made in one or two places.
5804 </para>
5805 </listitem></varlistentry>
5806 <varlistentry>
5807 <term><option>-Mes</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>address</emphasis>&gt;</term>
5808 <listitem>
5809 <para>
5810 <indexterm role="option">
5811 <primary><option>-Mes</option></primary>
5812 </indexterm>
5813 <indexterm role="concept">
5814 <primary>message</primary>
5815 <secondary>changing sender</secondary>
5816 </indexterm>
5817 <indexterm role="concept">
5818 <primary>sender</primary>
5819 <secondary>changing</secondary>
5820 </indexterm>
5821 This option requests Exim to change the sender address in the message to the
5822 given address, which must be a fully qualified address or <quote>&lt;&gt;</quote> (<quote>es</quote> for
5823 <quote>edit sender</quote>). There must be exactly two arguments. The first argument must
5824 be a message id, and the second one an email address. However, if the message
5825 is active (in the middle of a delivery attempt), its status is not altered.
5826 This option can be used only by an admin user.
5827 </para>
5828 </listitem></varlistentry>
5829 <varlistentry>
5830 <term><option>-Mf</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5831 <listitem>
5832 <para>
5833 <indexterm role="option">
5834 <primary><option>-Mf</option></primary>
5835 </indexterm>
5836 <indexterm role="concept">
5837 <primary>freezing messages</primary>
5838 </indexterm>
5839 <indexterm role="concept">
5840 <primary>message</primary>
5841 <secondary>manually freezing</secondary>
5842 </indexterm>
5843 This option requests Exim to mark each listed message as <quote>frozen</quote>. This
5844 prevents any delivery attempts taking place until the message is <quote>thawed</quote>,
5845 either manually or as a result of the <option>auto_thaw</option> configuration option.
5846 However, if any of the messages are active (in the middle of a delivery
5847 attempt), their status is not altered. This option can be used only by an admin
5848 user.
5849 </para>
5850 </listitem></varlistentry>
5851 <varlistentry>
5852 <term><option>-Mg</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5853 <listitem>
5854 <para>
5855 <indexterm role="option">
5856 <primary><option>-Mg</option></primary>
5857 </indexterm>
5858 <indexterm role="concept">
5859 <primary>giving up on messages</primary>
5860 </indexterm>
5861 <indexterm role="concept">
5862 <primary>message</primary>
5863 <secondary>abandoning delivery attempts</secondary>
5864 </indexterm>
5865 <indexterm role="concept">
5866 <primary>delivery</primary>
5867 <secondary>abandoning further attempts</secondary>
5868 </indexterm>
5869 This option requests Exim to give up trying to deliver the listed messages,
5870 including any that are frozen. However, if any of the messages are active,
5871 their status is not altered. For non-bounce messages, a delivery error message
5872 is sent to the sender, containing the text <quote>cancelled by administrator</quote>.
5873 Bounce messages are just discarded. This option can be used only by an admin
5874 user.
5875 </para>
5876 </listitem></varlistentry>
5877 <varlistentry revisionflag="changed">
5878 <term><option>-MG</option>&nbsp;&lt;<emphasis>queue&nbsp;name</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5879 <listitem>
5880 <para revisionflag="changed">
5881 <indexterm role="option">
5882 <primary><option>-MG</option></primary>
5883 </indexterm>
5884 <indexterm role="concept">
5885 <primary>queue</primary>
5886 <secondary>named</secondary>
5887 </indexterm>
5888 <indexterm role="concept">
5889 <primary>named queues</primary>
5890 </indexterm>
5891 <indexterm role="concept">
5892 <primary>queue</primary>
5893 <secondary>moving messages</secondary>
5894 </indexterm>
5895 This option requests that each listed message be moved from its current
5896 queue to the given named queue.
5897 The destination queue name argument is required, but can be an empty
5898 string to define the default queue.
5899 If the messages are not currently located in the default queue,
5900 a <option>-qG&lt;name&gt;</option> option will be required to define the source queue.
5901 </para>
5902 </listitem></varlistentry>
5903 <varlistentry>
5904 <term><option>-Mmad</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5905 <listitem>
5906 <para>
5907 <indexterm role="option">
5908 <primary><option>-Mmad</option></primary>
5909 </indexterm>
5910 <indexterm role="concept">
5911 <primary>delivery</primary>
5912 <secondary>cancelling all</secondary>
5913 </indexterm>
5914 This option requests Exim to mark all the recipient addresses in the messages
5915 as already delivered (<quote>mad</quote> for <quote>mark all delivered</quote>). However, if any
5916 message is active (in the middle of a delivery attempt), its status is not
5917 altered. This option can be used only by an admin user.
5918 </para>
5919 </listitem></varlistentry>
5920 <varlistentry>
5921 <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>
5922 <listitem>
5923 <para>
5924 <indexterm role="option">
5925 <primary><option>-Mmd</option></primary>
5926 </indexterm>
5927 <indexterm role="concept">
5928 <primary>delivery</primary>
5929 <secondary>cancelling by address</secondary>
5930 </indexterm>
5931 <indexterm role="concept">
5932 <primary>recipient</primary>
5933 <secondary>removing</secondary>
5934 </indexterm>
5935 <indexterm role="concept">
5936 <primary>removing recipients</primary>
5937 </indexterm>
5938 This option requests Exim to mark the given addresses as already delivered
5939 (<quote>md</quote> for <quote>mark delivered</quote>). The first argument must be a message id, and
5940 the remaining ones must be email addresses. These are matched to recipient
5941 addresses in the message in a case-sensitive manner. If the message is active
5942 (in the middle of a delivery attempt), its status is not altered. This option
5943 can be used only by an admin user.
5944 </para>
5945 </listitem></varlistentry>
5946 <varlistentry>
5947 <term><option>-Mrm</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5948 <listitem>
5949 <para>
5950 <indexterm role="option">
5951 <primary><option>-Mrm</option></primary>
5952 </indexterm>
5953 <indexterm role="concept">
5954 <primary>removing messages</primary>
5955 </indexterm>
5956 <indexterm role="concept">
5957 <primary>abandoning mail</primary>
5958 </indexterm>
5959 <indexterm role="concept">
5960 <primary>message</primary>
5961 <secondary>manually discarding</secondary>
5962 </indexterm>
5963 This option requests Exim to remove the given messages from the queue. No
5964 bounce messages are sent; each message is simply forgotten. However, if any of
5965 the messages are active, their status is not altered. This option can be used
5966 only by an admin user or by the user who originally caused the message to be
5967 placed in the queue.
5968 </para>
5969 </listitem></varlistentry>
5970 <varlistentry>
5971 <term><option>-Mset</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
5972 <listitem>
5973 <para>
5974 <indexterm role="option">
5975 <primary><option>-Mset</option></primary>
5976 </indexterm>
5977 <indexterm role="concept">
5978 <primary>testing</primary>
5979 <secondary>string expansion</secondary>
5980 </indexterm>
5981 <indexterm role="concept">
5982 <primary>expansion</primary>
5983 <secondary>testing</secondary>
5984 </indexterm>
5985 This option is useful only in conjunction with <option>-be</option> (that is, when testing
5986 string expansions). Exim loads the given message from its spool before doing
5987 the test expansions, thus setting message-specific variables such as
5988 <varname>$message_size</varname> and the header variables. The <varname>$recipients</varname> variable is made
5989 available. This feature is provided to make it easier to test expansions that
5990 make use of these variables. However, this option can be used only by an admin
5991 user. See also <option>-bem</option>.
5992 </para>
5993 </listitem></varlistentry>
5994 <varlistentry>
5995 <term><option>-Mt</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5996 <listitem>
5997 <para>
5998 <indexterm role="option">
5999 <primary><option>-Mt</option></primary>
6000 </indexterm>
6001 <indexterm role="concept">
6002 <primary>thawing messages</primary>
6003 </indexterm>
6004 <indexterm role="concept">
6005 <primary>unfreezing messages</primary>
6006 </indexterm>
6007 <indexterm role="concept">
6008 <primary>frozen messages</primary>
6009 <secondary>thawing</secondary>
6010 </indexterm>
6011 <indexterm role="concept">
6012 <primary>message</primary>
6013 <secondary>thawing frozen</secondary>
6014 </indexterm>
6015 This option requests Exim to <quote>thaw</quote> any of the listed messages that are
6016 <quote>frozen</quote>, so that delivery attempts can resume. However, if any of the
6017 messages are active, their status is not altered. This option can be used only
6018 by an admin user.
6019 </para>
6020 </listitem></varlistentry>
6021 <varlistentry>
6022 <term><option>-Mvb</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
6023 <listitem>
6024 <para>
6025 <indexterm role="option">
6026 <primary><option>-Mvb</option></primary>
6027 </indexterm>
6028 <indexterm role="concept">
6029 <primary>listing</primary>
6030 <secondary>message body</secondary>
6031 </indexterm>
6032 <indexterm role="concept">
6033 <primary>message</primary>
6034 <secondary>listing body of</secondary>
6035 </indexterm>
6036 This option causes the contents of the message body (-D) spool file to be
6037 written to the standard output. This option can be used only by an admin user.
6038 </para>
6039 </listitem></varlistentry>
6040 <varlistentry>
6041 <term><option>-Mvc</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
6042 <listitem>
6043 <para>
6044 <indexterm role="option">
6045 <primary><option>-Mvc</option></primary>
6046 </indexterm>
6047 <indexterm role="concept">
6048 <primary>message</primary>
6049 <secondary>listing in RFC 2822 format</secondary>
6050 </indexterm>
6051 <indexterm role="concept">
6052 <primary>listing</primary>
6053 <secondary>message in RFC 2822 format</secondary>
6054 </indexterm>
6055 This option causes a copy of the complete message (header lines plus body) to
6056 be written to the standard output in RFC 2822 format. This option can be used
6057 only by an admin user.
6058 </para>
6059 </listitem></varlistentry>
6060 <varlistentry>
6061 <term><option>-Mvh</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
6062 <listitem>
6063 <para>
6064 <indexterm role="option">
6065 <primary><option>-Mvh</option></primary>
6066 </indexterm>
6067 <indexterm role="concept">
6068 <primary>listing</primary>
6069 <secondary>message headers</secondary>
6070 </indexterm>
6071 <indexterm role="concept">
6072 <primary>header lines</primary>
6073 <secondary>listing</secondary>
6074 </indexterm>
6075 <indexterm role="concept">
6076 <primary>message</primary>
6077 <secondary>listing header lines</secondary>
6078 </indexterm>
6079 This option causes the contents of the message headers (-H) spool file to be
6080 written to the standard output. This option can be used only by an admin user.
6081 </para>
6082 </listitem></varlistentry>
6083 <varlistentry>
6084 <term><option>-Mvl</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
6085 <listitem>
6086 <para>
6087 <indexterm role="option">
6088 <primary><option>-Mvl</option></primary>
6089 </indexterm>
6090 <indexterm role="concept">
6091 <primary>listing</primary>
6092 <secondary>message log</secondary>
6093 </indexterm>
6094 <indexterm role="concept">
6095 <primary>message</primary>
6096 <secondary>listing message log</secondary>
6097 </indexterm>
6098 This option causes the contents of the message log spool file to be written to
6099 the standard output. This option can be used only by an admin user.
6100 </para>
6101 </listitem></varlistentry>
6102 <varlistentry>
6103 <term><option>-m</option></term>
6104 <listitem>
6105 <para>
6106 <indexterm role="option">
6107 <primary><option>-m</option></primary>
6108 </indexterm>
6109 This is apparently a synonym for <option>-om</option> that is accepted by Sendmail, so Exim
6110 treats it that way too.
6111 </para>
6112 </listitem></varlistentry>
6113 <varlistentry>
6114 <term><option>-N</option></term>
6115 <listitem>
6116 <para>
6117 <indexterm role="option">
6118 <primary><option>-N</option></primary>
6119 </indexterm>
6120 <indexterm role="concept">
6121 <primary>debugging</primary>
6122 <secondary><option>-N</option> option</secondary>
6123 </indexterm>
6124 <indexterm role="concept">
6125 <primary>debugging</primary>
6126 <secondary>suppressing delivery</secondary>
6127 </indexterm>
6128 This is a debugging option that inhibits delivery of a message at the transport
6129 level. It implies <option>-v</option>. Exim goes through many of the motions of delivery &ndash;
6130 it just doesn&#x2019;t actually transport the message, but instead behaves as if it
6131 had successfully done so. However, it does not make any updates to the retry
6132 database, and the log entries for deliveries are flagged with <quote>*&gt;</quote> rather
6133 than <quote>=&gt;</quote>.
6134 </para>
6135 <para>
6136 Because <option>-N</option> discards any message to which it applies, only root or the Exim
6137 user are allowed to use it with <option>-bd</option>, <option>-q</option>, <option>-R</option> or <option>-M</option>. In other
6138 words, an ordinary user can use it only when supplying an incoming message to
6139 which it will apply. Although transportation never fails when <option>-N</option> is set, an
6140 address may be deferred because of a configuration problem on a transport, or a
6141 routing problem. Once <option>-N</option> has been used for a delivery attempt, it sticks to
6142 the message, and applies to any subsequent delivery attempts that may happen
6143 for that message.
6144 </para>
6145 </listitem></varlistentry>
6146 <varlistentry>
6147 <term><option>-n</option></term>
6148 <listitem>
6149 <para>
6150 <indexterm role="option">
6151 <primary><option>-n</option></primary>
6152 </indexterm>
6153 This option is interpreted by Sendmail to mean <quote>no aliasing</quote>.
6154 For normal modes of operation, it is ignored by Exim.
6155 When combined with <option>-bP</option> it makes the output more terse (suppresses
6156 option names, environment values and config pretty printing).
6157 </para>
6158 </listitem></varlistentry>
6159 <varlistentry>
6160 <term><option>-O</option>&nbsp;&lt;<emphasis>data</emphasis>&gt;</term>
6161 <listitem>
6162 <para>
6163 <indexterm role="option">
6164 <primary><option>-O</option></primary>
6165 </indexterm>
6166 This option is interpreted by Sendmail to mean <literal>set option</literal>. It is ignored by
6167 Exim.
6168 </para>
6169 </listitem></varlistentry>
6170 <varlistentry>
6171 <term><option>-oA</option>&nbsp;&lt;<emphasis>file&nbsp;name</emphasis>&gt;</term>
6172 <listitem>
6173 <para>
6174 <indexterm role="option">
6175 <primary><option>-oA</option></primary>
6176 </indexterm>
6177 <indexterm role="concept">
6178 <primary>Sendmail compatibility</primary>
6179 <secondary><option>-oA</option> option</secondary>
6180 </indexterm>
6181 This option is used by Sendmail in conjunction with <option>-bi</option> to specify an
6182 alternative alias filename. Exim handles <option>-bi</option> differently; see the
6183 description above.
6184 </para>
6185 </listitem></varlistentry>
6186 <varlistentry>
6187 <term><option>-oB</option>&nbsp;&lt;<emphasis>n</emphasis>&gt;</term>
6188 <listitem>
6189 <para>
6190 <indexterm role="option">
6191 <primary><option>-oB</option></primary>
6192 </indexterm>
6193 <indexterm role="concept">
6194 <primary>SMTP</primary>
6195 <secondary>passed connection</secondary>
6196 </indexterm>
6197 <indexterm role="concept">
6198 <primary>SMTP</primary>
6199 <secondary>multiple deliveries</secondary>
6200 </indexterm>
6201 <indexterm role="concept">
6202 <primary>multiple SMTP deliveries</primary>
6203 </indexterm>
6204 This is a debugging option which limits the maximum number of messages that can
6205 be delivered down one SMTP connection, overriding the value set in any <command>smtp</command>
6206 transport. If &lt;<emphasis>n</emphasis>&gt; is omitted, the limit is set to 1.
6207 </para>
6208 </listitem></varlistentry>
6209 <varlistentry>
6210 <term><option>-odb</option></term>
6211 <listitem>
6212 <para>
6213 <indexterm role="option">
6214 <primary><option>-odb</option></primary>
6215 </indexterm>
6216 <indexterm role="concept">
6217 <primary>background delivery</primary>
6218 </indexterm>
6219 <indexterm role="concept">
6220 <primary>delivery</primary>
6221 <secondary>in the background</secondary>
6222 </indexterm>
6223 This option applies to all modes in which Exim accepts incoming messages,
6224 including the listening daemon. It requests <quote>background</quote> delivery of such
6225 messages, which means that the accepting process automatically starts a
6226 delivery process for each message received, but does not wait for the delivery
6227 processes to finish.
6228 </para>
6229 <para>
6230 When all the messages have been received, the reception process exits,
6231 leaving the delivery processes to finish in their own time. The standard output
6232 and error streams are closed at the start of each delivery process.
6233 This is the default action if none of the <option>-od</option> options are present.
6234 </para>
6235 <para>
6236 If one of the queueing options in the configuration file
6237 (<option>queue_only</option> or <option>queue_only_file</option>, for example) is in effect, <option>-odb</option>
6238 overrides it if <option>queue_only_override</option> is set true, which is the default
6239 setting. If <option>queue_only_override</option> is set false, <option>-odb</option> has no effect.
6240 </para>
6241 </listitem></varlistentry>
6242 <varlistentry>
6243 <term><option>-odf</option></term>
6244 <listitem>
6245 <para>
6246 <indexterm role="option">
6247 <primary><option>-odf</option></primary>
6248 </indexterm>
6249 <indexterm role="concept">
6250 <primary>foreground delivery</primary>
6251 </indexterm>
6252 <indexterm role="concept">
6253 <primary>delivery</primary>
6254 <secondary>in the foreground</secondary>
6255 </indexterm>
6256 This option requests <quote>foreground</quote> (synchronous) delivery when Exim has
6257 accepted a locally-generated message. (For the daemon it is exactly the same as
6258 <option>-odb</option>.) A delivery process is automatically started to deliver the message,
6259 and Exim waits for it to complete before proceeding.
6260 </para>
6261 <para>
6262 The original Exim reception process does not finish until the delivery
6263 process for the final message has ended. The standard error stream is left open
6264 during deliveries.
6265 </para>
6266 <para>
6267 However, like <option>-odb</option>, this option has no effect if <option>queue_only_override</option> is
6268 false and one of the queueing options in the configuration file is in effect.
6269 </para>
6270 <para>
6271 If there is a temporary delivery error during foreground delivery, the
6272 message is left in the queue for later delivery, and the original reception
6273 process exits. See chapter <xref linkend="CHAPnonqueueing"/> for a way of setting up a
6274 restricted configuration that never queues messages.
6275 </para>
6276 </listitem></varlistentry>
6277 <varlistentry>
6278 <term><option>-odi</option></term>
6279 <listitem>
6280 <para>
6281 <indexterm role="option">
6282 <primary><option>-odi</option></primary>
6283 </indexterm>
6284 This option is synonymous with <option>-odf</option>. It is provided for compatibility with
6285 Sendmail.
6286 </para>
6287 </listitem></varlistentry>
6288 <varlistentry>
6289 <term><option>-odq</option></term>
6290 <listitem>
6291 <para>
6292 <indexterm role="option">
6293 <primary><option>-odq</option></primary>
6294 </indexterm>
6295 <indexterm role="concept">
6296 <primary>non-immediate delivery</primary>
6297 </indexterm>
6298 <indexterm role="concept">
6299 <primary>delivery</primary>
6300 <secondary>suppressing immediate</secondary>
6301 </indexterm>
6302 <indexterm role="concept">
6303 <primary>queueing incoming messages</primary>
6304 </indexterm>
6305 This option applies to all modes in which Exim accepts incoming messages,
6306 including the listening daemon. It specifies that the accepting process should
6307 not automatically start a delivery process for each message received. Messages
6308 are placed in the queue, and remain there until a subsequent queue runner
6309 process encounters them. There are several configuration options (such as
6310 <option>queue_only</option>) that can be used to queue incoming messages under certain
6311 conditions. This option overrides all of them and also <option>-odqs</option>. It always
6312 forces queueing.
6313 </para>
6314 </listitem></varlistentry>
6315 <varlistentry>
6316 <term><option>-odqs</option></term>
6317 <listitem>
6318 <para>
6319 <indexterm role="option">
6320 <primary><option>-odqs</option></primary>
6321 </indexterm>
6322 <indexterm role="concept">
6323 <primary>SMTP</primary>
6324 <secondary>delaying delivery</secondary>
6325 </indexterm>
6326 This option is a hybrid between <option>-odb</option>/<option>-odi</option> and <option>-odq</option>.
6327 However, like <option>-odb</option> and <option>-odi</option>, this option has no effect if
6328 <option>queue_only_override</option> is false and one of the queueing options in the
6329 configuration file is in effect.
6330 </para>
6331 <para>
6332 When <option>-odqs</option> does operate, a delivery process is started for each incoming
6333 message, in the background by default, but in the foreground if <option>-odi</option> is
6334 also present. The recipient addresses are routed, and local deliveries are done
6335 in the normal way. However, if any SMTP deliveries are required, they are not
6336 done at this time, so the message remains in the queue until a subsequent queue
6337 runner process encounters it. Because routing was done, Exim knows which
6338 messages are waiting for which hosts, and so a number of messages for the same
6339 host can be sent in a single SMTP connection. The <option>queue_smtp_domains</option>
6340 configuration option has the same effect for specific domains. See also the
6341 <option>-qq</option> option.
6342 </para>
6343 </listitem></varlistentry>
6344 <varlistentry>
6345 <term><option>-oee</option></term>
6346 <listitem>
6347 <para>
6348 <indexterm role="option">
6349 <primary><option>-oee</option></primary>
6350 </indexterm>
6351 <indexterm role="concept">
6352 <primary>error</primary>
6353 <secondary>reporting</secondary>
6354 </indexterm>
6355 If an error is detected while a non-SMTP message is being received (for
6356 example, a malformed address), the error is reported to the sender in a mail
6357 message.
6358 </para>
6359 <para>
6360 <indexterm role="concept">
6361 <primary>return code</primary>
6362 <secondary>for <option>-oee</option></secondary>
6363 </indexterm>
6364 Provided
6365 this error message is successfully sent, the Exim receiving process
6366 exits with a return code of zero. If not, the return code is 2 if the problem
6367 is that the original message has no recipients, or 1 for any other error.
6368 This is the default <option>-oe</option><emphasis>x</emphasis> option if Exim is called as <emphasis>rmail</emphasis>.
6369 </para>
6370 </listitem></varlistentry>
6371 <varlistentry>
6372 <term><option>-oem</option></term>
6373 <listitem>
6374 <para>
6375 <indexterm role="option">
6376 <primary><option>-oem</option></primary>
6377 </indexterm>
6378 <indexterm role="concept">
6379 <primary>error</primary>
6380 <secondary>reporting</secondary>
6381 </indexterm>
6382 <indexterm role="concept">
6383 <primary>return code</primary>
6384 <secondary>for <option>-oem</option></secondary>
6385 </indexterm>
6386 This is the same as <option>-oee</option>, except that Exim always exits with a non-zero
6387 return code, whether or not the error message was successfully sent.
6388 This is the default <option>-oe</option><emphasis>x</emphasis> option, unless Exim is called as <emphasis>rmail</emphasis>.
6389 </para>
6390 </listitem></varlistentry>
6391 <varlistentry>
6392 <term><option>-oep</option></term>
6393 <listitem>
6394 <para>
6395 <indexterm role="option">
6396 <primary><option>-oep</option></primary>
6397 </indexterm>
6398 <indexterm role="concept">
6399 <primary>error</primary>
6400 <secondary>reporting</secondary>
6401 </indexterm>
6402 If an error is detected while a non-SMTP message is being received, the
6403 error is reported by writing a message to the standard error file (stderr).
6404 <indexterm role="concept">
6405 <primary>return code</primary>
6406 <secondary>for <option>-oep</option></secondary>
6407 </indexterm>
6408 The return code is 1 for all errors.
6409 </para>
6410 </listitem></varlistentry>
6411 <varlistentry>
6412 <term><option>-oeq</option></term>
6413 <listitem>
6414 <para>
6415 <indexterm role="option">
6416 <primary><option>-oeq</option></primary>
6417 </indexterm>
6418 <indexterm role="concept">
6419 <primary>error</primary>
6420 <secondary>reporting</secondary>
6421 </indexterm>
6422 This option is supported for compatibility with Sendmail, but has the same
6423 effect as <option>-oep</option>.
6424 </para>
6425 </listitem></varlistentry>
6426 <varlistentry>
6427 <term><option>-oew</option></term>
6428 <listitem>
6429 <para>
6430 <indexterm role="option">
6431 <primary><option>-oew</option></primary>
6432 </indexterm>
6433 <indexterm role="concept">
6434 <primary>error</primary>
6435 <secondary>reporting</secondary>
6436 </indexterm>
6437 This option is supported for compatibility with Sendmail, but has the same
6438 effect as <option>-oem</option>.
6439 </para>
6440 </listitem></varlistentry>
6441 <varlistentry>
6442 <term><option>-oi</option></term>
6443 <listitem>
6444 <para>
6445 <indexterm role="option">
6446 <primary><option>-oi</option></primary>
6447 </indexterm>
6448 <indexterm role="concept">
6449 <primary>dot</primary>
6450 <secondary>in incoming non-SMTP message</secondary>
6451 </indexterm>
6452 This option, which has the same effect as <option>-i</option>, specifies that a dot on a
6453 line by itself should not terminate an incoming, non-SMTP message. Otherwise, a
6454 single dot does terminate, though Exim does no special processing for other
6455 lines that start with a dot. This option is set by default if Exim is called as
6456 <emphasis>rmail</emphasis>. See also <option>-ti</option>.
6457 </para>
6458 </listitem></varlistentry>
6459 <varlistentry>
6460 <term><option>-oitrue</option></term>
6461 <listitem>
6462 <para>
6463 <indexterm role="option">
6464 <primary><option>-oitrue</option></primary>
6465 </indexterm>
6466 This option is treated as synonymous with <option>-oi</option>.
6467 </para>
6468 </listitem></varlistentry>
6469 <varlistentry>
6470 <term><option>-oMa</option>&nbsp;&lt;<emphasis>host&nbsp;address</emphasis>&gt;</term>
6471 <listitem>
6472 <para>
6473 <indexterm role="option">
6474 <primary><option>-oMa</option></primary>
6475 </indexterm>
6476 <indexterm role="concept">
6477 <primary>sender</primary>
6478 <secondary>host address, specifying for local message</secondary>
6479 </indexterm>
6480 A number of options starting with <option>-oM</option> can be used to set values associated
6481 with remote hosts on locally-submitted messages (that is, messages not received
6482 over TCP/IP). These options can be used by any caller in conjunction with the
6483 <option>-bh</option>, <option>-be</option>, <option>-bf</option>, <option>-bF</option>, <option>-bt</option>, or <option>-bv</option> testing options. In
6484 other circumstances, they are ignored unless the caller is trusted.
6485 </para>
6486 <para>
6487 The <option>-oMa</option> option sets the sender host address. This may include a port
6488 number at the end, after a full stop (period). For example:
6489 </para>
6490 <literallayout class="monospaced">
6491 exim -bs -oMa 10.9.8.7.1234
6492 </literallayout>
6493 <para>
6494 An alternative syntax is to enclose the IP address in square brackets,
6495 followed by a colon and the port number:
6496 </para>
6497 <literallayout class="monospaced">
6498 exim -bs -oMa [10.9.8.7]:1234
6499 </literallayout>
6500 <para>
6501 The IP address is placed in the <varname>$sender_host_address</varname> variable, and the
6502 port, if present, in <varname>$sender_host_port</varname>. If both <option>-oMa</option> and <option>-bh</option>
6503 are present on the command line, the sender host IP address is taken from
6504 whichever one is last.
6505 </para>
6506 </listitem></varlistentry>
6507 <varlistentry>
6508 <term><option>-oMaa</option>&nbsp;&lt;<emphasis>name</emphasis>&gt;</term>
6509 <listitem>
6510 <para>
6511 <indexterm role="option">
6512 <primary><option>-oMaa</option></primary>
6513 </indexterm>
6514 <indexterm role="concept">
6515 <primary>authentication</primary>
6516 <secondary>name, specifying for local message</secondary>
6517 </indexterm>
6518 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMaa</option>
6519 option sets the value of <varname>$sender_host_authenticated</varname> (the authenticator
6520 name). See chapter <xref linkend="CHAPSMTPAUTH"/> for a discussion of SMTP authentication.
6521 This option can be used with <option>-bh</option> and <option>-bs</option> to set up an
6522 authenticated SMTP session without actually using the SMTP AUTH command.
6523 </para>
6524 </listitem></varlistentry>
6525 <varlistentry>
6526 <term><option>-oMai</option>&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
6527 <listitem>
6528 <para>
6529 <indexterm role="option">
6530 <primary><option>-oMai</option></primary>
6531 </indexterm>
6532 <indexterm role="concept">
6533 <primary>authentication</primary>
6534 <secondary>id, specifying for local message</secondary>
6535 </indexterm>
6536 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMai</option>
6537 option sets the value of <varname>$authenticated_id</varname> (the id that was authenticated).
6538 This overrides the default value (the caller&#x2019;s login id, except with <option>-bh</option>,
6539 where there is no default) for messages from local sources. See chapter
6540 <xref linkend="CHAPSMTPAUTH"/> for a discussion of authenticated ids.
6541 </para>
6542 </listitem></varlistentry>
6543 <varlistentry>
6544 <term><option>-oMas</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;</term>
6545 <listitem>
6546 <para>
6547 <indexterm role="option">
6548 <primary><option>-oMas</option></primary>
6549 </indexterm>
6550 <indexterm role="concept">
6551 <primary>authentication</primary>
6552 <secondary>sender, specifying for local message</secondary>
6553 </indexterm>
6554 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMas</option>
6555 option sets the authenticated sender value in <varname>$authenticated_sender</varname>. It
6556 overrides the sender address that is created from the caller&#x2019;s login id for
6557 messages from local sources, except when <option>-bh</option> is used, when there is no
6558 default. For both <option>-bh</option> and <option>-bs</option>, an authenticated sender that is
6559 specified on a MAIL command overrides this value. See chapter
6560 <xref linkend="CHAPSMTPAUTH"/> for a discussion of authenticated senders.
6561 </para>
6562 </listitem></varlistentry>
6563 <varlistentry>
6564 <term><option>-oMi</option>&nbsp;&lt;<emphasis>interface&nbsp;address</emphasis>&gt;</term>
6565 <listitem>
6566 <para>
6567 <indexterm role="option">
6568 <primary><option>-oMi</option></primary>
6569 </indexterm>
6570 <indexterm role="concept">
6571 <primary>interface</primary>
6572 <secondary>address, specifying for local message</secondary>
6573 </indexterm>
6574 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMi</option>
6575 option sets the IP interface address value. A port number may be included,
6576 using the same syntax as for <option>-oMa</option>. The interface address is placed in
6577 <varname>$received_ip_address</varname> and the port number, if present, in <varname>$received_port</varname>.
6578 </para>
6579 </listitem></varlistentry>
6580 <varlistentry>
6581 <term><option>-oMm</option>&nbsp;&lt;<emphasis>message&nbsp;reference</emphasis>&gt;</term>
6582 <listitem>
6583 <para>
6584 <indexterm role="option">
6585 <primary><option>-oMm</option></primary>
6586 </indexterm>
6587 <indexterm role="concept">
6588 <primary>message reference</primary>
6589 <secondary>message reference, specifying for local message</secondary>
6590 </indexterm>
6591 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMm</option>
6592 option sets the message reference, e.g. message-id, and is logged during
6593 delivery. This is useful when some kind of audit trail is required to tie
6594 messages together. The format of the message reference is checked and will
6595 abort if the format is invalid. The option will only be accepted if exim is
6596 running in trusted mode, not as any regular user.
6597 </para>
6598 <para>
6599 The best example of a message reference is when Exim sends a bounce message.
6600 The message reference is the message-id of the original message for which Exim
6601 is sending the bounce.
6602 </para>
6603 </listitem></varlistentry>
6604 <varlistentry>
6605 <term><option>-oMr</option>&nbsp;&lt;<emphasis>protocol&nbsp;name</emphasis>&gt;</term>
6606 <listitem>
6607 <para>
6608 <indexterm role="option">
6609 <primary><option>-oMr</option></primary>
6610 </indexterm>
6611 <indexterm role="concept">
6612 <primary>protocol, specifying for local message</primary>
6613 </indexterm>
6614 <indexterm role="variable">
6615 <primary><varname>$received_protocol</varname></primary>
6616 </indexterm>
6617 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMr</option>
6618 option sets the received protocol value that is stored in
6619 <varname>$received_protocol</varname>. However, it does not apply (and is ignored) when <option>-bh</option>
6620 or <option>-bs</option> is used. For <option>-bh</option>, the protocol is forced to one of the standard
6621 SMTP protocol names (see the description of <varname>$received_protocol</varname> in section
6622 <xref linkend="SECTexpvar"/>). For <option>-bs</option>, the protocol is always <quote>local-</quote> followed by
6623 one of those same names. For <option>-bS</option> (batched SMTP) however, the protocol can
6624 be set by <option>-oMr</option>. Repeated use of this option is not supported.
6625 </para>
6626 </listitem></varlistentry>
6627 <varlistentry>
6628 <term><option>-oMs</option>&nbsp;&lt;<emphasis>host&nbsp;name</emphasis>&gt;</term>
6629 <listitem>
6630 <para>
6631 <indexterm role="option">
6632 <primary><option>-oMs</option></primary>
6633 </indexterm>
6634 <indexterm role="concept">
6635 <primary>sender</primary>
6636 <secondary>host name, specifying for local message</secondary>
6637 </indexterm>
6638 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMs</option>
6639 option sets the sender host name in <varname>$sender_host_name</varname>. When this option is
6640 present, Exim does not attempt to look up a host name from an IP address; it
6641 uses the name it is given.
6642 </para>
6643 </listitem></varlistentry>
6644 <varlistentry>
6645 <term><option>-oMt</option>&nbsp;&lt;<emphasis>ident&nbsp;string</emphasis>&gt;</term>
6646 <listitem>
6647 <para>
6648 <indexterm role="option">
6649 <primary><option>-oMt</option></primary>
6650 </indexterm>
6651 <indexterm role="concept">
6652 <primary>sender</primary>
6653 <secondary>ident string, specifying for local message</secondary>
6654 </indexterm>
6655 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMt</option>
6656 option sets the sender ident value in <varname>$sender_ident</varname>. The default setting for
6657 local callers is the login id of the calling process, except when <option>-bh</option> is
6658 used, when there is no default.
6659 </para>
6660 </listitem></varlistentry>
6661 <varlistentry>
6662 <term><option>-om</option></term>
6663 <listitem>
6664 <para>
6665 <indexterm role="option">
6666 <primary><option>-om</option></primary>
6667 </indexterm>
6668 <indexterm role="concept">
6669 <primary>Sendmail compatibility</primary>
6670 <secondary><option>-om</option> option ignored</secondary>
6671 </indexterm>
6672 In Sendmail, this option means <quote>me too</quote>, indicating that the sender of a
6673 message should receive a copy of the message if the sender appears in an alias
6674 expansion. Exim always does this, so the option does nothing.
6675 </para>
6676 </listitem></varlistentry>
6677 <varlistentry>
6678 <term><option>-oo</option></term>
6679 <listitem>
6680 <para>
6681 <indexterm role="option">
6682 <primary><option>-oo</option></primary>
6683 </indexterm>
6684 <indexterm role="concept">
6685 <primary>Sendmail compatibility</primary>
6686 <secondary><option>-oo</option> option ignored</secondary>
6687 </indexterm>
6688 This option is ignored. In Sendmail it specifies <quote>old style headers</quote>,
6689 whatever that means.
6690 </para>
6691 </listitem></varlistentry>
6692 <varlistentry>
6693 <term><option>-oP</option>&nbsp;&lt;<emphasis>path</emphasis>&gt;</term>
6694 <listitem>
6695 <para>
6696 <indexterm role="option">
6697 <primary><option>-oP</option></primary>
6698 </indexterm>
6699 <indexterm role="concept">
6700 <primary>pid (process id)</primary>
6701 <secondary>of daemon</secondary>
6702 </indexterm>
6703 <indexterm role="concept">
6704 <primary>daemon</primary>
6705 <secondary>process id (pid)</secondary>
6706 </indexterm>
6707 This option is useful only in conjunction with <option>-bd</option> or <option>-q</option> with a time
6708 value. The option specifies the file to which the process id of the daemon is
6709 written. When <option>-oX</option> is used with <option>-bd</option>, or when <option>-q</option> with a time is used
6710 without <option>-bd</option>, this is the only way of causing Exim to write a pid file,
6711 because in those cases, the normal pid file is not used.
6712 </para>
6713 </listitem></varlistentry>
6714 <varlistentry>
6715 <term><option>-or</option>&nbsp;&lt;<emphasis>time</emphasis>&gt;</term>
6716 <listitem>
6717 <para>
6718 <indexterm role="option">
6719 <primary><option>-or</option></primary>
6720 </indexterm>
6721 <indexterm role="concept">
6722 <primary>timeout</primary>
6723 <secondary>for non-SMTP input</secondary>
6724 </indexterm>
6725 This option sets a timeout value for incoming non-SMTP messages. If it is not
6726 set, Exim will wait forever for the standard input. The value can also be set
6727 by the <option>receive_timeout</option> option. The format used for specifying times is
6728 described in section <xref linkend="SECTtimeformat"/>.
6729 </para>
6730 </listitem></varlistentry>
6731 <varlistentry>
6732 <term><option>-os</option>&nbsp;&lt;<emphasis>time</emphasis>&gt;</term>
6733 <listitem>
6734 <para>
6735 <indexterm role="option">
6736 <primary><option>-os</option></primary>
6737 </indexterm>
6738 <indexterm role="concept">
6739 <primary>timeout</primary>
6740 <secondary>for SMTP input</secondary>
6741 </indexterm>
6742 <indexterm role="concept">
6743 <primary>SMTP</primary>
6744 <secondary>input timeout</secondary>
6745 </indexterm>
6746 This option sets a timeout value for incoming SMTP messages. The timeout
6747 applies to each SMTP command and block of data. The value can also be set by
6748 the <option>smtp_receive_timeout</option> option; it defaults to 5 minutes. The format used
6749 for specifying times is described in section <xref linkend="SECTtimeformat"/>.
6750 </para>
6751 </listitem></varlistentry>
6752 <varlistentry>
6753 <term><option>-ov</option></term>
6754 <listitem>
6755 <para>
6756 <indexterm role="option">
6757 <primary><option>-ov</option></primary>
6758 </indexterm>
6759 This option has exactly the same effect as <option>-v</option>.
6760 </para>
6761 </listitem></varlistentry>
6762 <varlistentry>
6763 <term><option>-oX</option>&nbsp;&lt;<emphasis>number&nbsp;or&nbsp;string</emphasis>&gt;</term>
6764 <listitem>
6765 <para>
6766 <indexterm role="option">
6767 <primary><option>-oX</option></primary>
6768 </indexterm>
6769 <indexterm role="concept">
6770 <primary>TCP/IP</primary>
6771 <secondary>setting listening ports</secondary>
6772 </indexterm>
6773 <indexterm role="concept">
6774 <primary>TCP/IP</primary>
6775 <secondary>setting listening interfaces</secondary>
6776 </indexterm>
6777 <indexterm role="concept">
6778 <primary>port</primary>
6779 <secondary>receiving TCP/IP</secondary>
6780 </indexterm>
6781 This option is relevant only when the <option>-bd</option> (start listening daemon) option
6782 is also given. It controls which ports and interfaces the daemon uses. Details
6783 of the syntax, and how it interacts with configuration file options, are given
6784 in chapter <xref linkend="CHAPinterfaces"/>. When <option>-oX</option> is used to start a daemon, no pid
6785 file is written unless <option>-oP</option> is also present to specify a pid filename.
6786 </para>
6787 </listitem></varlistentry>
6788 <varlistentry>
6789 <term><option>-pd</option></term>
6790 <listitem>
6791 <para>
6792 <indexterm role="option">
6793 <primary><option>-pd</option></primary>
6794 </indexterm>
6795 <indexterm role="concept">
6796 <primary>Perl</primary>
6797 <secondary>starting the interpreter</secondary>
6798 </indexterm>
6799 This option applies when an embedded Perl interpreter is linked with Exim (see
6800 chapter <xref linkend="CHAPperl"/>). It overrides the setting of the <option>perl_at_start</option>
6801 option, forcing the starting of the interpreter to be delayed until it is
6802 needed.
6803 </para>
6804 </listitem></varlistentry>
6805 <varlistentry>
6806 <term><option>-ps</option></term>
6807 <listitem>
6808 <para>
6809 <indexterm role="option">
6810 <primary><option>-ps</option></primary>
6811 </indexterm>
6812 <indexterm role="concept">
6813 <primary>Perl</primary>
6814 <secondary>starting the interpreter</secondary>
6815 </indexterm>
6816 This option applies when an embedded Perl interpreter is linked with Exim (see
6817 chapter <xref linkend="CHAPperl"/>). It overrides the setting of the <option>perl_at_start</option>
6818 option, forcing the starting of the interpreter to occur as soon as Exim is
6819 started.
6820 </para>
6821 </listitem></varlistentry>
6822 <varlistentry>
6823 <term><option>-p</option>&lt;<emphasis>rval</emphasis>&gt;:&lt;<emphasis>sval</emphasis>&gt;</term>
6824 <listitem>
6825 <para>
6826 <indexterm role="option">
6827 <primary><option>-p</option></primary>
6828 </indexterm>
6829 For compatibility with Sendmail, this option is equivalent to
6830 </para>
6831 <literallayout>
6832 <literal>-oMr</literal> &lt;<emphasis>rval</emphasis>&gt; <literal>-oMs</literal> &lt;<emphasis>sval</emphasis>&gt;
6833 </literallayout>
6834 <para>
6835 It sets the incoming protocol and host name (for trusted callers). The
6836 host name and its colon can be omitted when only the protocol is to be set.
6837 Note the Exim already has two private options, <option>-pd</option> and <option>-ps</option>, that refer
6838 to embedded Perl. It is therefore impossible to set a protocol value of <literal>d</literal>
6839 or <literal>s</literal> using this option (but that does not seem a real limitation).
6840 Repeated use of this option is not supported.
6841 </para>
6842 </listitem></varlistentry>
6843 <varlistentry>
6844 <term><option>-q</option></term>
6845 <listitem>
6846 <para>
6847 <indexterm role="option">
6848 <primary><option>-q</option></primary>
6849 </indexterm>
6850 <indexterm role="concept">
6851 <primary>queue runner</primary>
6852 <secondary>starting manually</secondary>
6853 </indexterm>
6854 This option is normally restricted to admin users. However, there is a
6855 configuration option called <option>prod_requires_admin</option> which can be set false to
6856 relax this restriction (and also the same requirement for the <option>-M</option>, <option>-R</option>,
6857 and <option>-S</option> options).
6858 </para>
6859 <para>
6860 <indexterm role="concept">
6861 <primary>queue runner</primary>
6862 <secondary>description of operation</secondary>
6863 </indexterm>
6864 If other commandline options do not specify an action,
6865 the <option>-q</option> option starts one queue runner process. This scans the queue of
6866 waiting messages, and runs a delivery process for each one in turn. It waits
6867 for each delivery process to finish before starting the next one. A delivery
6868 process may not actually do any deliveries if the retry times for the addresses
6869 have not been reached. Use <option>-qf</option> (see below) if you want to override this.
6870 </para>
6871 <para>
6872 If
6873 <indexterm role="concept">
6874 <primary>SMTP</primary>
6875 <secondary>passed connection</secondary>
6876 </indexterm>
6877 <indexterm role="concept">
6878 <primary>SMTP</primary>
6879 <secondary>multiple deliveries</secondary>
6880 </indexterm>
6881 <indexterm role="concept">
6882 <primary>multiple SMTP deliveries</primary>
6883 </indexterm>
6884 the delivery process spawns other processes to deliver other messages down
6885 passed SMTP connections, the queue runner waits for these to finish before
6886 proceeding.
6887 </para>
6888 <para>
6889 When all the queued messages have been considered, the original queue runner
6890 process terminates. In other words, a single pass is made over the waiting
6891 mail, one message at a time. Use <option>-q</option> with a time (see below) if you want
6892 this to be repeated periodically.
6893 </para>
6894 <para>
6895 Exim processes the waiting messages in an unpredictable order. It isn&#x2019;t very
6896 random, but it is likely to be different each time, which is all that matters.
6897 If one particular message screws up a remote MTA, other messages to the same
6898 MTA have a chance of getting through if they get tried first.
6899 </para>
6900 <para>
6901 It is possible to cause the messages to be processed in lexical message id
6902 order, which is essentially the order in which they arrived, by setting the
6903 <option>queue_run_in_order</option> option, but this is not recommended for normal use.
6904 </para>
6905 </listitem></varlistentry>
6906 <varlistentry>
6907 <term><option>-q</option>&lt;<emphasis>qflags</emphasis>&gt;</term>
6908 <listitem>
6909 <para>
6910 The <option>-q</option> option may be followed by one or more flag letters that change its
6911 behaviour. They are all optional, but if more than one is present, they must
6912 appear in the correct order. Each flag is described in a separate item below.
6913 </para>
6914 </listitem></varlistentry>
6915 <varlistentry>
6916 <term><option>-qq...</option></term>
6917 <listitem>
6918 <para>
6919 <indexterm role="option">
6920 <primary><option>-qq</option></primary>
6921 </indexterm>
6922 <indexterm role="concept">
6923 <primary>queue</primary>
6924 <secondary>double scanning</secondary>
6925 </indexterm>
6926 <indexterm role="concept">
6927 <primary>queue</primary>
6928 <secondary>routing</secondary>
6929 </indexterm>
6930 <indexterm role="concept">
6931 <primary>routing</primary>
6932 <secondary>whole queue before delivery</secondary>
6933 </indexterm>
6934 An option starting with <option>-qq</option> requests a two-stage queue run. In the first
6935 stage, the queue is scanned as if the <option>queue_smtp_domains</option> option matched
6936 every domain. Addresses are routed, local deliveries happen, but no remote
6937 transports are run.
6938 </para>
6939 <para>
6940 <indexterm role="concept">
6941 <primary>hints database</primary>
6942 <secondary>remembering routing</secondary>
6943 </indexterm>
6944 The hints database that remembers which messages are waiting for specific hosts
6945 is updated, as if delivery to those hosts had been deferred. After this is
6946 complete, a second, normal queue scan happens, with routing and delivery taking
6947 place as normal. Messages that are routed to the same host should mostly be
6948 delivered down a single SMTP
6949 <indexterm role="concept">
6950 <primary>SMTP</primary>
6951 <secondary>passed connection</secondary>
6952 </indexterm>
6953 <indexterm role="concept">
6954 <primary>SMTP</primary>
6955 <secondary>multiple deliveries</secondary>
6956 </indexterm>
6957 <indexterm role="concept">
6958 <primary>multiple SMTP deliveries</primary>
6959 </indexterm>
6960 connection because of the hints that were set up during the first queue scan.
6961 This option may be useful for hosts that are connected to the Internet
6962 intermittently.
6963 </para>
6964 </listitem></varlistentry>
6965 <varlistentry>
6966 <term><option>-q[q]i...</option></term>
6967 <listitem>
6968 <para>
6969 <indexterm role="option">
6970 <primary><option>-qi</option></primary>
6971 </indexterm>
6972 <indexterm role="concept">
6973 <primary>queue</primary>
6974 <secondary>initial delivery</secondary>
6975 </indexterm>
6976 If the <emphasis>i</emphasis> flag is present, the queue runner runs delivery processes only for
6977 those messages that haven&#x2019;t previously been tried. (<emphasis>i</emphasis> stands for <quote>initial
6978 delivery</quote>.) This can be helpful if you are putting messages in the queue using
6979 <option>-odq</option> and want a queue runner just to process the new messages.
6980 </para>
6981 </listitem></varlistentry>
6982 <varlistentry>
6983 <term><option>-q[q][i]f...</option></term>
6984 <listitem>
6985 <para>
6986 <indexterm role="option">
6987 <primary><option>-qf</option></primary>
6988 </indexterm>
6989 <indexterm role="concept">
6990 <primary>queue</primary>
6991 <secondary>forcing delivery</secondary>
6992 </indexterm>
6993 <indexterm role="concept">
6994 <primary>delivery</primary>
6995 <secondary>forcing in queue run</secondary>
6996 </indexterm>
6997 If one <emphasis>f</emphasis> flag is present, a delivery attempt is forced for each non-frozen
6998 message, whereas without <emphasis>f</emphasis> only those non-frozen addresses that have passed
6999 their retry times are tried.
7000 </para>
7001 </listitem></varlistentry>
7002 <varlistentry>
7003 <term><option>-q[q][i]ff...</option></term>
7004 <listitem>
7005 <para>
7006 <indexterm role="option">
7007 <primary><option>-qff</option></primary>
7008 </indexterm>
7009 <indexterm role="concept">
7010 <primary>frozen messages</primary>
7011 <secondary>forcing delivery</secondary>
7012 </indexterm>
7013 If <emphasis>ff</emphasis> is present, a delivery attempt is forced for every message, whether
7014 frozen or not.
7015 </para>
7016 </listitem></varlistentry>
7017 <varlistentry>
7018 <term><option>-q[q][i][f[f]]l</option></term>
7019 <listitem>
7020 <para>
7021 <indexterm role="option">
7022 <primary><option>-ql</option></primary>
7023 </indexterm>
7024 <indexterm role="concept">
7025 <primary>queue</primary>
7026 <secondary>local deliveries only</secondary>
7027 </indexterm>
7028 The <emphasis>l</emphasis> (the letter <quote>ell</quote>) flag specifies that only local deliveries are to
7029 be done. If a message requires any remote deliveries, it remains in the queue
7030 for later delivery.
7031 </para>
7032 </listitem></varlistentry>
7033 <varlistentry>
7034 <term><option>-q[q][i][f[f]][l][G&lt;name&gt;[/&lt;time&gt;]]]</option></term>
7035 <listitem>
7036 <para>
7037 <indexterm role="option">
7038 <primary><option>-qG</option></primary>
7039 </indexterm>
7040 <indexterm role="concept">
7041 <primary>queue</primary>
7042 <secondary>named</secondary>
7043 </indexterm>
7044 <indexterm role="concept">
7045 <primary>named queues</primary>
7046 </indexterm>
7047 <indexterm role="concept">
7048 <primary>queue</primary>
7049 <secondary>delivering specific messages</secondary>
7050 </indexterm>
7051 If the <emphasis>G</emphasis> flag and a name is present, the queue runner operates on the
7052 queue with the given name rather than the default queue.
7053 The name should not contain a <emphasis>/</emphasis> character.
7054 For a periodic queue run (see below)
7055 append to the name a slash and a time value.
7056 </para>
7057 <para>
7058 If other commandline options specify an action, a <emphasis>-qG&lt;name&gt;</emphasis> option
7059 will specify a queue to operate on.
7060 For example:
7061 </para>
7062 <literallayout class="monospaced">
7063 exim -bp -qGquarantine
7064 mailq -qGquarantine
7065 exim -qGoffpeak -Rf @special.domain.example
7066 </literallayout>
7067 </listitem></varlistentry>
7068 <varlistentry>
7069 <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>
7070 <listitem>
7071 <para>
7072 When scanning the queue, Exim can be made to skip over messages whose ids are
7073 lexically less than a given value by following the <option>-q</option> option with a
7074 starting message id. For example:
7075 </para>
7076 <literallayout class="monospaced">
7077 exim -q 0t5C6f-0000c8-00
7078 </literallayout>
7079 <para>
7080 Messages that arrived earlier than <literal>0t5C6f-0000c8-00</literal> are not inspected. If a
7081 second message id is given, messages whose ids are lexically greater than it
7082 are also skipped. If the same id is given twice, for example,
7083 </para>
7084 <literallayout class="monospaced">
7085 exim -q 0t5C6f-0000c8-00 0t5C6f-0000c8-00
7086 </literallayout>
7087 <para>
7088 just one delivery process is started, for that message. This differs from
7089 <option>-M</option> in that retry data is respected, and it also differs from <option>-Mc</option> in
7090 that it counts as a delivery from a queue run. Note that the selection
7091 mechanism does not affect the order in which the messages are scanned. There
7092 are also other ways of selecting specific sets of messages for delivery in a
7093 queue run &ndash; see <option>-R</option> and <option>-S</option>.
7094 </para>
7095 </listitem></varlistentry>
7096 <varlistentry>
7097 <term><option>-q</option>&lt;<emphasis>qflags</emphasis>&gt;&lt;<emphasis>time</emphasis>&gt;</term>
7098 <listitem>
7099 <para>
7100 <indexterm role="concept">
7101 <primary>queue runner</primary>
7102 <secondary>starting periodically</secondary>
7103 </indexterm>
7104 <indexterm role="concept">
7105 <primary>periodic queue running</primary>
7106 </indexterm>
7107 When a time value is present, the <option>-q</option> option causes Exim to run as a daemon,
7108 starting a queue runner process at intervals specified by the given time value
7109 (whose format is described in section <xref linkend="SECTtimeformat"/>). This form of the
7110 <option>-q</option> option is commonly combined with the <option>-bd</option> option, in which case a
7111 single daemon process handles both functions. A common way of starting up a
7112 combined daemon at system boot time is to use a command such as
7113 </para>
7114 <literallayout class="monospaced">
7115 /usr/exim/bin/exim -bd -q30m
7116 </literallayout>
7117 <para>
7118 Such a daemon listens for incoming SMTP calls, and also starts a queue runner
7119 process every 30 minutes.
7120 </para>
7121 <para>
7122 When a daemon is started by <option>-q</option> with a time value, but without <option>-bd</option>, no
7123 pid file is written unless one is explicitly requested by the <option>-oP</option> option.
7124 </para>
7125 </listitem></varlistentry>
7126 <varlistentry>
7127 <term><option>-qR</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
7128 <listitem>
7129 <para>
7130 <indexterm role="option">
7131 <primary><option>-qR</option></primary>
7132 </indexterm>
7133 This option is synonymous with <option>-R</option>. It is provided for Sendmail
7134 compatibility.
7135 </para>
7136 </listitem></varlistentry>
7137 <varlistentry>
7138 <term><option>-qS</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
7139 <listitem>
7140 <para>
7141 <indexterm role="option">
7142 <primary><option>-qS</option></primary>
7143 </indexterm>
7144 This option is synonymous with <option>-S</option>.
7145 </para>
7146 </listitem></varlistentry>
7147 <varlistentry>
7148 <term><option>-R</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
7149 <listitem>
7150 <para>
7151 <indexterm role="option">
7152 <primary><option>-R</option></primary>
7153 </indexterm>
7154 <indexterm role="concept">
7155 <primary>queue runner</primary>
7156 <secondary>for specific recipients</secondary>
7157 </indexterm>
7158 <indexterm role="concept">
7159 <primary>delivery</primary>
7160 <secondary>to given domain</secondary>
7161 </indexterm>
7162 <indexterm role="concept">
7163 <primary>domain</primary>
7164 <secondary>delivery to</secondary>
7165 </indexterm>
7166 The &lt;<emphasis>rsflags</emphasis>&gt; may be empty, in which case the white space before the string
7167 is optional, unless the string is <emphasis>f</emphasis>, <emphasis>ff</emphasis>, <emphasis>r</emphasis>, <emphasis>rf</emphasis>, or <emphasis>rff</emphasis>,
7168 which are the possible values for &lt;<emphasis>rsflags</emphasis>&gt;. White space is required if
7169 &lt;<emphasis>rsflags</emphasis>&gt; is not empty.
7170 </para>
7171 <para>
7172 This option is similar to <option>-q</option> with no time value, that is, it causes Exim to
7173 perform a single queue run, except that, when scanning the messages on the
7174 queue, Exim processes only those that have at least one undelivered recipient
7175 address containing the given string, which is checked in a case-independent
7176 way. If the &lt;<emphasis>rsflags</emphasis>&gt; start with <emphasis>r</emphasis>, &lt;<emphasis>string</emphasis>&gt; is interpreted as a
7177 regular expression; otherwise it is a literal string.
7178 </para>
7179 <para>
7180 If you want to do periodic queue runs for messages with specific recipients,
7181 you can combine <option>-R</option> with <option>-q</option> and a time value. For example:
7182 </para>
7183 <literallayout class="monospaced">
7184 exim -q25m -R @special.domain.example
7185 </literallayout>
7186 <para>
7187 This example does a queue run for messages with recipients in the given domain
7188 every 25 minutes. Any additional flags that are specified with <option>-q</option> are
7189 applied to each queue run.
7190 </para>
7191 <para>
7192 Once a message is selected for delivery by this mechanism, all its addresses
7193 are processed. For the first selected message, Exim overrides any retry
7194 information and forces a delivery attempt for each undelivered address. This
7195 means that if delivery of any address in the first message is successful, any
7196 existing retry information is deleted, and so delivery attempts for that
7197 address in subsequently selected messages (which are processed without forcing)
7198 will run. However, if delivery of any address does not succeed, the retry
7199 information is updated, and in subsequently selected messages, the failing
7200 address will be skipped.
7201 </para>
7202 <para>
7203 <indexterm role="concept">
7204 <primary>frozen messages</primary>
7205 <secondary>forcing delivery</secondary>
7206 </indexterm>
7207 If the &lt;<emphasis>rsflags</emphasis>&gt; contain <emphasis>f</emphasis> or <emphasis>ff</emphasis>, the delivery forcing applies to
7208 all selected messages, not just the first; frozen messages are included when
7209 <emphasis>ff</emphasis> is present.
7210 </para>
7211 <para>
7212 The <option>-R</option> option makes it straightforward to initiate delivery of all messages
7213 to a given domain after a host has been down for some time. When the SMTP
7214 command ETRN is accepted by its ACL (see chapter <xref linkend="CHAPACL"/>), its default
7215 effect is to run Exim with the <option>-R</option> option, but it can be configured to run
7216 an arbitrary command instead.
7217 </para>
7218 </listitem></varlistentry>
7219 <varlistentry>
7220 <term><option>-r</option></term>
7221 <listitem>
7222 <para>
7223 <indexterm role="option">
7224 <primary><option>-r</option></primary>
7225 </indexterm>
7226 This is a documented (for Sendmail) obsolete alternative name for <option>-f</option>.
7227 </para>
7228 </listitem></varlistentry>
7229 <varlistentry>
7230 <term><option>-S</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
7231 <listitem>
7232 <para>
7233 <indexterm role="option">
7234 <primary><option>-S</option></primary>
7235 </indexterm>
7236 <indexterm role="concept">
7237 <primary>delivery</primary>
7238 <secondary>from given sender</secondary>
7239 </indexterm>
7240 <indexterm role="concept">
7241 <primary>queue runner</primary>
7242 <secondary>for specific senders</secondary>
7243 </indexterm>
7244 This option acts like <option>-R</option> except that it checks the string against each
7245 message&#x2019;s sender instead of against the recipients. If <option>-R</option> is also set, both
7246 conditions must be met for a message to be selected. If either of the options
7247 has <emphasis>f</emphasis> or <emphasis>ff</emphasis> in its flags, the associated action is taken.
7248 </para>
7249 </listitem></varlistentry>
7250 <varlistentry>
7251 <term><option>-Tqt</option>&nbsp;&lt;<emphasis>times</emphasis>&gt;</term>
7252 <listitem>
7253 <para>
7254 <indexterm role="option">
7255 <primary><option>-Tqt</option></primary>
7256 </indexterm>
7257 This is an option that is exclusively for use by the Exim testing suite. It is not
7258 recognized when Exim is run normally. It allows for the setting up of explicit
7259 <quote>queue times</quote> so that various warning/retry features can be tested.
7260 </para>
7261 </listitem></varlistentry>
7262 <varlistentry>
7263 <term><option>-t</option></term>
7264 <listitem>
7265 <para>
7266 <indexterm role="option">
7267 <primary><option>-t</option></primary>
7268 </indexterm>
7269 <indexterm role="concept">
7270 <primary>recipient</primary>
7271 <secondary>extracting from header lines</secondary>
7272 </indexterm>
7273 <indexterm role="concept">
7274 <primary><emphasis>Bcc:</emphasis> header line</primary>
7275 </indexterm>
7276 <indexterm role="concept">
7277 <primary><emphasis>Cc:</emphasis> header line</primary>
7278 </indexterm>
7279 <indexterm role="concept">
7280 <primary><emphasis>To:</emphasis> header line</primary>
7281 </indexterm>
7282 When Exim is receiving a locally-generated, non-SMTP message on its standard
7283 input, the <option>-t</option> option causes the recipients of the message to be obtained
7284 from the <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>, and <emphasis>Bcc:</emphasis> header lines in the message instead of
7285 from the command arguments. The addresses are extracted before any rewriting
7286 takes place and the <emphasis>Bcc:</emphasis> header line, if present, is then removed.
7287 </para>
7288 <para>
7289 <indexterm role="concept">
7290 <primary>Sendmail compatibility</primary>
7291 <secondary><option>-t</option> option</secondary>
7292 </indexterm>
7293 If the command has any arguments, they specify addresses to which the message
7294 is <emphasis>not</emphasis> to be delivered. That is, the argument addresses are removed from
7295 the recipients list obtained from the headers. This is compatible with Smail 3
7296 and in accordance with the documented behaviour of several versions of
7297 Sendmail, as described in man pages on a number of operating systems (e.g.
7298 Solaris 8, IRIX 6.5, HP-UX 11). However, some versions of Sendmail <emphasis>add</emphasis>
7299 argument addresses to those obtained from the headers, and the O&#x2019;Reilly
7300 Sendmail book documents it that way. Exim can be made to add argument addresses
7301 instead of subtracting them by setting the option
7302 <option>extract_addresses_remove_arguments</option> false.
7303 </para>
7304 <para>
7305 <indexterm role="concept">
7306 <primary><option>Resent-</option> header lines</primary>
7307 <secondary>with <option>-t</option></secondary>
7308 </indexterm>
7309 If there are any <option>Resent-</option> header lines in the message, Exim extracts
7310 recipients from all <emphasis>Resent-To:</emphasis>, <emphasis>Resent-Cc:</emphasis>, and <emphasis>Resent-Bcc:</emphasis> header
7311 lines instead of from <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>, and <emphasis>Bcc:</emphasis>. This is for compatibility
7312 with Sendmail and other MTAs. (Prior to release 4.20, Exim gave an error if
7313 <option>-t</option> was used in conjunction with <option>Resent-</option> header lines.)
7314 </para>
7315 <para>
7316 RFC 2822 talks about different sets of <option>Resent-</option> header lines (for when a
7317 message is resent several times). The RFC also specifies that they should be
7318 added at the front of the message, and separated by <emphasis>Received:</emphasis> lines. It is
7319 not at all clear how <option>-t</option> should operate in the present of multiple sets,
7320 nor indeed exactly what constitutes a <quote>set</quote>.
7321 In practice, it seems that MUAs do not follow the RFC. The <option>Resent-</option> lines
7322 are often added at the end of the header, and if a message is resent more than
7323 once, it is common for the original set of <option>Resent-</option> headers to be renamed as
7324 <option>X-Resent-</option> when a new set is added. This removes any possible ambiguity.
7325 </para>
7326 </listitem></varlistentry>
7327 <varlistentry>
7328 <term><option>-ti</option></term>
7329 <listitem>
7330 <para>
7331 <indexterm role="option">
7332 <primary><option>-ti</option></primary>
7333 </indexterm>
7334 This option is exactly equivalent to <option>-t</option> <option>-i</option>. It is provided for
7335 compatibility with Sendmail.
7336 </para>
7337 </listitem></varlistentry>
7338 <varlistentry>
7339 <term><option>-tls-on-connect</option></term>
7340 <listitem>
7341 <para>
7342 <indexterm role="option">
7343 <primary><option>-tls-on-connect</option></primary>
7344 </indexterm>
7345 <indexterm role="concept">
7346 <primary>TLS</primary>
7347 <secondary>use without STARTTLS</secondary>
7348 </indexterm>
7349 <indexterm role="concept">
7350 <primary>TLS</primary>
7351 <secondary>automatic start</secondary>
7352 </indexterm>
7353 This option is available when Exim is compiled with TLS support. It forces all
7354 incoming SMTP connections to behave as if the incoming port is listed in the
7355 <option>tls_on_connect_ports</option> option. See section <xref linkend="SECTsupobssmt"/> and chapter
7356 <xref linkend="CHAPTLS"/> for further details.
7357 </para>
7358 </listitem></varlistentry>
7359 <varlistentry>
7360 <term><option>-U</option></term>
7361 <listitem>
7362 <para>
7363 <indexterm role="option">
7364 <primary><option>-U</option></primary>
7365 </indexterm>
7366 <indexterm role="concept">
7367 <primary>Sendmail compatibility</primary>
7368 <secondary><option>-U</option> option ignored</secondary>
7369 </indexterm>
7370 Sendmail uses this option for <quote>initial message submission</quote>, and its
7371 documentation states that in future releases, it may complain about
7372 syntactically invalid messages rather than fixing them when this flag is not
7373 set. Exim ignores this option.
7374 </para>
7375 </listitem></varlistentry>
7376 <varlistentry>
7377 <term><option>-v</option></term>
7378 <listitem>
7379 <para>
7380 <indexterm role="option">
7381 <primary><option>-v</option></primary>
7382 </indexterm>
7383 This option causes Exim to write information to the standard error stream,
7384 describing what it is doing. In particular, it shows the log lines for
7385 receiving and delivering a message, and if an SMTP connection is made, the SMTP
7386 dialogue is shown. Some of the log lines shown may not actually be written to
7387 the log if the setting of <option>log_selector</option> discards them. Any relevant
7388 selectors are shown with each log line. If none are shown, the logging is
7389 unconditional.
7390 </para>
7391 </listitem></varlistentry>
7392 <varlistentry>
7393 <term><option>-x</option></term>
7394 <listitem>
7395 <para>
7396 <indexterm role="option">
7397 <primary><option>-x</option></primary>
7398 </indexterm>
7399 AIX uses <option>-x</option> for a private purpose (<quote>mail from a local mail program has
7400 National Language Support extended characters in the body of the mail item</quote>).
7401 It sets <option>-x</option> when calling the MTA from its <option>mail</option> command. Exim ignores
7402 this option.
7403 </para>
7404 </listitem></varlistentry>
7405 <varlistentry>
7406 <term><option>-X</option>&nbsp;&lt;<emphasis>logfile</emphasis>&gt;</term>
7407 <listitem>
7408 <para>
7409 <indexterm role="option">
7410 <primary><option>-X</option></primary>
7411 </indexterm>
7412 This option is interpreted by Sendmail to cause debug information to be sent
7413 to the named file.  It is ignored by Exim.
7414 </para>
7415 </listitem></varlistentry>
7416 <varlistentry>
7417 <term><option>-z</option>&nbsp;&lt;<emphasis>log-line</emphasis>&gt;</term>
7418 <listitem>
7419 <para>
7420 <indexterm role="option">
7421 <primary><option>-z</option></primary>
7422 </indexterm>
7423 This option writes its argument to Exim&#x2019;s logfile.
7424 Use is restricted to administrators; the intent is for operational notes.
7425 Quotes should be used to maintain a multi-word item as a single argument,
7426 under most shells.
7427 </para>
7428 </listitem></varlistentry>
7429 </variablelist>
7430 <para>
7431 <indexterm role="concept" startref="IIDclo1" class="endofrange"/>
7432 <indexterm role="concept" startref="IIDclo2" class="endofrange"/>
7433 </para>
7434 <!-- === End of command line options === -->
7435 </section>
7436 </chapter>
7437
7438 <chapter id="CHAPconf">
7439 <title>The Exim runtime configuration file</title>
7440 <titleabbrev>The runtime configuration file</titleabbrev>
7441 <para>
7442 <indexterm role="concept">
7443 <primary>runtime configuration</primary>
7444 </indexterm>
7445 <indexterm role="concept">
7446 <primary>configuration file</primary>
7447 <secondary>general description</secondary>
7448 </indexterm>
7449 <indexterm role="concept">
7450 <primary>CONFIGURE_FILE</primary>
7451 </indexterm>
7452 <indexterm role="concept">
7453 <primary>configuration file</primary>
7454 <secondary>errors in</secondary>
7455 </indexterm>
7456 <indexterm role="concept">
7457 <primary>error</primary>
7458 <secondary>in configuration file</secondary>
7459 </indexterm>
7460 <indexterm role="concept">
7461 <primary>return code</primary>
7462 <secondary>for bad configuration</secondary>
7463 </indexterm>
7464 Exim uses a single runtime configuration file that is read whenever an Exim
7465 binary is executed. Note that in normal operation, this happens frequently,
7466 because Exim is designed to operate in a distributed manner, without central
7467 control.
7468 </para>
7469 <para>
7470 If a syntax error is detected while reading the configuration file, Exim
7471 writes a message on the standard error, and exits with a non-zero return code.
7472 The message is also written to the panic log. <emphasis role="bold">Note</emphasis>: Only simple syntax
7473 errors can be detected at this time. The values of any expanded options are
7474 not checked until the expansion happens, even when the expansion does not
7475 actually alter the string.
7476 </para>
7477 <para>
7478 The name of the configuration file is compiled into the binary for security
7479 reasons, and is specified by the CONFIGURE_FILE compilation option. In
7480 most configurations, this specifies a single file. However, it is permitted to
7481 give a colon-separated list of filenames, in which case Exim uses the first
7482 existing file in the list.
7483 </para>
7484 <para>
7485 <indexterm role="concept">
7486 <primary>EXIM_USER</primary>
7487 </indexterm>
7488 <indexterm role="concept">
7489 <primary>EXIM_GROUP</primary>
7490 </indexterm>
7491 <indexterm role="concept">
7492 <primary>CONFIGURE_OWNER</primary>
7493 </indexterm>
7494 <indexterm role="concept">
7495 <primary>CONFIGURE_GROUP</primary>
7496 </indexterm>
7497 <indexterm role="concept">
7498 <primary>configuration file</primary>
7499 <secondary>ownership</secondary>
7500 </indexterm>
7501 <indexterm role="concept">
7502 <primary>ownership</primary>
7503 <secondary>configuration file</secondary>
7504 </indexterm>
7505 The runtime configuration file must be owned by root or by the user that is
7506 specified at compile time by the CONFIGURE_OWNER option (if set). The
7507 configuration file must not be world-writeable, or group-writeable unless its
7508 group is the root group or the one specified at compile time by the
7509 CONFIGURE_GROUP option.
7510 </para>
7511 <para>
7512 <emphasis role="bold">Warning</emphasis>: In a conventional configuration, where the Exim binary is setuid
7513 to root, anybody who is able to edit the runtime configuration file has an
7514 easy way to run commands as root. If you specify a user or group in the
7515 CONFIGURE_OWNER or CONFIGURE_GROUP options, then that user and/or any users
7516 who are members of that group will trivially be able to obtain root privileges.
7517 </para>
7518 <para>
7519 Up to Exim version 4.72, the runtime configuration file was also permitted to
7520 be writeable by the Exim user and/or group. That has been changed in Exim 4.73
7521 since it offered a simple privilege escalation for any attacker who managed to
7522 compromise the Exim user account.
7523 </para>
7524 <para>
7525 A default configuration file, which will work correctly in simple situations,
7526 is provided in the file <filename>src/configure.default</filename>. If CONFIGURE_FILE
7527 defines just one filename, the installation process copies the default
7528 configuration to a new file of that name if it did not previously exist. If
7529 CONFIGURE_FILE is a list, no default is automatically installed. Chapter
7530 <xref linkend="CHAPdefconfil"/> is a <quote>walk-through</quote> discussion of the default
7531 configuration.
7532 </para>
7533 <section id="SECID40">
7534 <title>Using a different configuration file</title>
7535 <para>
7536 <indexterm role="concept">
7537 <primary>configuration file</primary>
7538 <secondary>alternate</secondary>
7539 </indexterm>
7540 A one-off alternate configuration can be specified by the <option>-C</option> command line
7541 option, which may specify a single file or a list of files. However, when
7542 <option>-C</option> is used, Exim gives up its root privilege, unless called by root (or
7543 unless the argument for <option>-C</option> is identical to the built-in value from
7544 CONFIGURE_FILE), or is listed in the TRUSTED_CONFIG_LIST file and the caller
7545 is the Exim user or the user specified in the CONFIGURE_OWNER setting. <option>-C</option>
7546 is useful mainly for checking the syntax of configuration files before
7547 installing them. No owner or group checks are done on a configuration file
7548 specified by <option>-C</option>, if root privilege has been dropped.
7549 </para>
7550 <para>
7551 Even the Exim user is not trusted to specify an arbitrary configuration file
7552 with the <option>-C</option> option to be used with root privileges, unless that file is
7553 listed in the TRUSTED_CONFIG_LIST file. This locks out the possibility of
7554 testing a configuration using <option>-C</option> right through message reception and
7555 delivery, even if the caller is root. The reception works, but by that time,
7556 Exim is running as the Exim user, so when it re-execs to regain privilege for
7557 the delivery, the use of <option>-C</option> causes privilege to be lost. However, root
7558 can test reception and delivery using two separate commands (one to put a
7559 message in the queue, using <option>-odq</option>, and another to do the delivery, using
7560 <option>-M</option>).
7561 </para>
7562 <para>
7563 If ALT_CONFIG_PREFIX is defined <filename>in Local/Makefile</filename>, it specifies a
7564 prefix string with which any file named in a <option>-C</option> command line option must
7565 start. In addition, the filename must not contain the sequence <quote><literal>/../</literal></quote>.
7566 There is no default setting for ALT_CONFIG_PREFIX; when it is unset, any
7567 filename can be used with <option>-C</option>.
7568 </para>
7569 <para>
7570 One-off changes to a configuration can be specified by the <option>-D</option> command line
7571 option, which defines and overrides values for macros used inside the
7572 configuration file. However, like <option>-C</option>, the use of this option by a
7573 non-privileged user causes Exim to discard its root privilege.
7574 If DISABLE_D_OPTION is defined in <filename>Local/Makefile</filename>, the use of <option>-D</option> is
7575 completely disabled, and its use causes an immediate error exit.
7576 </para>
7577 <para>
7578 The WHITELIST_D_MACROS option in <filename>Local/Makefile</filename> permits the binary builder
7579 to declare certain macro names trusted, such that root privilege will not
7580 necessarily be discarded.
7581 WHITELIST_D_MACROS defines a colon-separated list of macros which are
7582 considered safe and, if <option>-D</option> only supplies macros from this list, and the
7583 values are acceptable, then Exim will not give up root privilege if the caller
7584 is root, the Exim run-time user, or the CONFIGURE_OWNER, if set.  This is a
7585 transition mechanism and is expected to be removed in the future.  Acceptable
7586 values for the macros satisfy the regexp: <literal>^[A-Za-z0-9_/.-]*$</literal>
7587 </para>
7588 <para>
7589 Some sites may wish to use the same Exim binary on different machines that
7590 share a file system, but to use different configuration files on each machine.
7591 If CONFIGURE_FILE_USE_NODE is defined in <filename>Local/Makefile</filename>, Exim first
7592 looks for a file whose name is the configuration filename followed by a dot
7593 and the machine&#x2019;s node name, as obtained from the <function>uname()</function> function. If this
7594 file does not exist, the standard name is tried. This processing occurs for
7595 each filename in the list given by CONFIGURE_FILE or <option>-C</option>.
7596 </para>
7597 <para>
7598 In some esoteric situations different versions of Exim may be run under
7599 different effective uids and the CONFIGURE_FILE_USE_EUID is defined to
7600 help with this. See the comments in <filename>src/EDITME</filename> for details.
7601 </para>
7602 </section>
7603 <section id="SECTconffilfor">
7604 <title>Configuration file format</title>
7605 <para>
7606 <indexterm role="concept">
7607 <primary>configuration file</primary>
7608 <secondary>format of</secondary>
7609 </indexterm>
7610 <indexterm role="concept">
7611 <primary>format</primary>
7612 <secondary>configuration file</secondary>
7613 </indexterm>
7614 Exim&#x2019;s configuration file is divided into a number of different parts. General
7615 option settings must always appear at the start of the file. The other parts
7616 are all optional, and may appear in any order. Each part other than the first
7617 is introduced by the word <quote>begin</quote> followed by at least one literal
7618 space, and the name of the part. The optional parts are:
7619 </para>
7620 <itemizedlist>
7621 <listitem>
7622 <para>
7623 <emphasis>ACL</emphasis>: Access control lists for controlling incoming SMTP mail (see chapter
7624 <xref linkend="CHAPACL"/>).
7625 </para>
7626 </listitem>
7627 <listitem>
7628 <para>
7629 <indexterm role="concept">
7630 <primary>AUTH</primary>
7631 <secondary>configuration</secondary>
7632 </indexterm>
7633 <emphasis>authenticators</emphasis>: Configuration settings for the authenticator drivers. These
7634 are concerned with the SMTP AUTH command (see chapter <xref linkend="CHAPSMTPAUTH"/>).
7635 </para>
7636 </listitem>
7637 <listitem>
7638 <para>
7639 <emphasis>routers</emphasis>: Configuration settings for the router drivers. Routers process
7640 addresses and determine how the message is to be delivered (see chapters
7641 <xref linkend="CHAProutergeneric"/>&ndash;<xref linkend="CHAPredirect"/>).
7642 </para>
7643 </listitem>
7644 <listitem>
7645 <para>
7646 <emphasis>transports</emphasis>: Configuration settings for the transport drivers. Transports
7647 define mechanisms for copying messages to destinations (see chapters
7648 <xref linkend="CHAPtransportgeneric"/>&ndash;<xref linkend="CHAPsmtptrans"/>).
7649 </para>
7650 </listitem>
7651 <listitem>
7652 <para>
7653 <emphasis>retry</emphasis>: Retry rules, for use when a message cannot be delivered immediately.
7654 If there is no retry section, or if it is empty (that is, no retry rules are
7655 defined), Exim will not retry deliveries. In this situation, temporary errors
7656 are treated the same as permanent errors. Retry rules are discussed in chapter
7657 <xref linkend="CHAPretry"/>.
7658 </para>
7659 </listitem>
7660 <listitem>
7661 <para>
7662 <emphasis>rewrite</emphasis>: Global address rewriting rules, for use when a message arrives and
7663 when new addresses are generated during delivery. Rewriting is discussed in
7664 chapter <xref linkend="CHAPrewrite"/>.
7665 </para>
7666 </listitem>
7667 <listitem>
7668 <para>
7669 <emphasis>local_scan</emphasis>: Private options for the <function>local_scan()</function> function. If you
7670 want to use this feature, you must set
7671 </para>
7672 <literallayout class="monospaced">
7673 LOCAL_SCAN_HAS_OPTIONS=yes
7674 </literallayout>
7675 <para>
7676 in <filename>Local/Makefile</filename> before building Exim. Details of the <function>local_scan()</function>
7677 facility are given in chapter <xref linkend="CHAPlocalscan"/>.
7678 </para>
7679 </listitem>
7680 </itemizedlist>
7681 <para>
7682 <indexterm role="concept">
7683 <primary>configuration file</primary>
7684 <secondary>leading white space in</secondary>
7685 </indexterm>
7686 <indexterm role="concept">
7687 <primary>configuration file</primary>
7688 <secondary>trailing white space in</secondary>
7689 </indexterm>
7690 <indexterm role="concept">
7691 <primary>white space</primary>
7692 <secondary>in configuration file</secondary>
7693 </indexterm>
7694 Leading and trailing white space in configuration lines is always ignored.
7695 </para>
7696 <para>
7697 Blank lines in the file, and lines starting with a # character (ignoring
7698 leading white space) are treated as comments and are ignored. <emphasis role="bold">Note</emphasis>: A
7699 # character other than at the beginning of a line is not treated specially,
7700 and does not introduce a comment.
7701 </para>
7702 <para>
7703 Any non-comment line can be continued by ending it with a backslash. Note that
7704 the general rule for white space means that trailing white space after the
7705 backslash and leading white space at the start of continuation
7706 lines is ignored. Comment lines beginning with # (but not empty lines) may
7707 appear in the middle of a sequence of continuation lines.
7708 </para>
7709 <para>
7710 A convenient way to create a configuration file is to start from the
7711 default, which is supplied in <filename>src/configure.default</filename>, and add, delete, or
7712 change settings as required.
7713 </para>
7714 <para>
7715 The ACLs, retry rules, and rewriting rules have their own syntax which is
7716 described in chapters <xref linkend="CHAPACL"/>, <xref linkend="CHAPretry"/>, and <xref linkend="CHAPrewrite"/>,
7717 respectively. The other parts of the configuration file have some syntactic
7718 items in common, and these are described below, from section <xref linkend="SECTcos"/>
7719 onwards. Before that, the inclusion, macro, and conditional facilities are
7720 described.
7721 </para>
7722 </section>
7723 <section id="SECID41">
7724 <title>File inclusions in the configuration file</title>
7725 <para>
7726 <indexterm role="concept">
7727 <primary>inclusions in configuration file</primary>
7728 </indexterm>
7729 <indexterm role="concept">
7730 <primary>configuration file</primary>
7731 <secondary>including other files</secondary>
7732 </indexterm>
7733 <indexterm role="concept">
7734 <primary><literal>.include</literal> in configuration file</primary>
7735 </indexterm>
7736 <indexterm role="concept">
7737 <primary><literal>.include_if_exists</literal> in configuration file</primary>
7738 </indexterm>
7739 You can include other files inside Exim&#x2019;s runtime configuration file by
7740 using this syntax:
7741 </para>
7742 <literallayout>
7743 <literal>.include</literal> &lt;<emphasis>filename</emphasis>&gt;
7744 <literal>.include_if_exists</literal> &lt;<emphasis>filename</emphasis>&gt;
7745 </literallayout>
7746 <para>
7747 on a line by itself. Double quotes round the filename are optional. If you use
7748 the first form, a configuration error occurs if the file does not exist; the
7749 second form does nothing for non-existent files.
7750 The first form allows a relative name. It is resolved relative to
7751 the directory of the including file. For the second form an absolute filename
7752 is required.
7753 </para>
7754 <para>
7755 Includes may be nested to any depth, but remember that Exim reads its
7756 configuration file often, so it is a good idea to keep them to a minimum.
7757 If you change the contents of an included file, you must HUP the daemon,
7758 because an included file is read only when the configuration itself is read.
7759 </para>
7760 <para>
7761 The processing of inclusions happens early, at a physical line level, so, like
7762 comment lines, an inclusion can be used in the middle of an option setting,
7763 for example:
7764 </para>
7765 <literallayout class="monospaced">
7766 hosts_lookup = a.b.c \
7767                .include /some/file
7768 </literallayout>
7769 <para>
7770 Include processing happens after macro processing (see below). Its effect is to
7771 process the lines of the included file as if they occurred inline where the
7772 inclusion appears.
7773 </para>
7774 </section>
7775 <section id="SECTmacrodefs">
7776 <title>Macros in the configuration file</title>
7777 <para>
7778 <indexterm role="concept">
7779 <primary>macro</primary>
7780 <secondary>description of</secondary>
7781 </indexterm>
7782 <indexterm role="concept">
7783 <primary>configuration file</primary>
7784 <secondary>macros</secondary>
7785 </indexterm>
7786 If a line in the main part of the configuration (that is, before the first
7787 <quote>begin</quote> line) begins with an upper case letter, it is taken as a macro
7788 definition, and must be of the form
7789 </para>
7790 <literallayout>
7791 &lt;<emphasis>name</emphasis>&gt; = &lt;<emphasis>rest of line</emphasis>&gt;
7792 </literallayout>
7793 <para>
7794 The name must consist of letters, digits, and underscores, and need not all be
7795 in upper case, though that is recommended. The rest of the line, including any
7796 continuations, is the replacement text, and has leading and trailing white
7797 space removed. Quotes are not removed. The replacement text can never end with
7798 a backslash character, but this doesn&#x2019;t seem to be a serious limitation.
7799 </para>
7800 <para>
7801 Macros may also be defined between router, transport, authenticator, or ACL
7802 definitions. They may not, however, be defined within an individual driver or
7803 ACL, or in the <option>local_scan</option>, retry, or rewrite sections of the configuration.
7804 </para>
7805 </section>
7806 <section id="SECID42">
7807 <title>Macro substitution</title>
7808 <para>
7809 Once a macro is defined, all subsequent lines in the file (and any included
7810 files) are scanned for the macro name; if there are several macros, the line is
7811 scanned for each, in turn, in the order in which the macros are defined. The
7812 replacement text is not re-scanned for the current macro, though it is scanned
7813 for subsequently defined macros. For this reason, a macro name may not contain
7814 the name of a previously defined macro as a substring. You could, for example,
7815 define
7816 </para>
7817 <literallayout>
7818 <literal>ABCD_XYZ = </literal>&lt;<emphasis>something</emphasis>&gt;
7819 <literal>ABCD = </literal>&lt;<emphasis>something else</emphasis>&gt;
7820 </literallayout>
7821 <para>
7822 but putting the definitions in the opposite order would provoke a configuration
7823 error. Macro expansion is applied to individual physical lines from the file,
7824 before checking for line continuation or file inclusion (see above). If a line
7825 consists solely of a macro name, and the expansion of the macro is empty, the
7826 line is ignored. A macro at the start of a line may turn the line into a
7827 comment line or a <literal>.include</literal> line.
7828 </para>
7829 </section>
7830 <section id="SECID43">
7831 <title>Redefining macros</title>
7832 <para>
7833 Once defined, the value of a macro can be redefined later in the configuration
7834 (or in an included file). Redefinition is specified by using <emphasis>==</emphasis> instead of
7835 <emphasis>=</emphasis>. For example:
7836 </para>
7837 <literallayout class="monospaced">
7838 MAC =  initial value
7839 ...
7840 MAC == updated value
7841 </literallayout>
7842 <para>
7843 Redefinition does not alter the order in which the macros are applied to the
7844 subsequent lines of the configuration file. It is still the same order in which
7845 the macros were originally defined. All that changes is the macro&#x2019;s value.
7846 Redefinition makes it possible to accumulate values. For example:
7847 </para>
7848 <literallayout class="monospaced">
7849 MAC =  initial value
7850 ...
7851 MAC == MAC and something added
7852 </literallayout>
7853 <para>
7854 This can be helpful in situations where the configuration file is built
7855 from a number of other files.
7856 </para>
7857 </section>
7858 <section id="SECID44">
7859 <title>Overriding macro values</title>
7860 <para>
7861 The values set for macros in the configuration file can be overridden by the
7862 <option>-D</option> command line option, but Exim gives up its root privilege when <option>-D</option> is
7863 used, unless called by root or the Exim user. A definition on the command line
7864 using the <option>-D</option> option causes all definitions and redefinitions within the
7865 file to be ignored.
7866 </para>
7867 </section>
7868 <section id="SECID45">
7869 <title>Example of macro usage</title>
7870 <para>
7871 As an example of macro usage, consider a configuration where aliases are looked
7872 up in a MySQL database. It helps to keep the file less cluttered if long
7873 strings such as SQL statements are defined separately as macros, for example:
7874 </para>
7875 <literallayout class="monospaced">
7876 ALIAS_QUERY = select mailbox from user where \
7877               login='${quote_mysql:$local_part}';
7878 </literallayout>
7879 <para>
7880 This can then be used in a <command>redirect</command> router setting like this:
7881 </para>
7882 <literallayout class="monospaced">
7883 data = ${lookup mysql{ALIAS_QUERY}}
7884 </literallayout>
7885 <para>
7886 In earlier versions of Exim macros were sometimes used for domain, host, or
7887 address lists. In Exim 4 these are handled better by named lists &ndash; see
7888 section <xref linkend="SECTnamedlists"/>.
7889 </para>
7890 </section>
7891 <section id="SECTbuiltinmacros">
7892 <title>Builtin macros</title>
7893 <para>
7894 Exim defines some macros depending on facilities available, which may
7895 differ due to build-time definitions and from one release to another.
7896 All of these macros start with an underscore.
7897 They can be used to conditionally include parts of a configuration
7898 (see below).
7899 </para>
7900 <para>
7901 The following classes of macros are defined:
7902 </para>
7903 <literallayout>
7904 <literal> _HAVE_*                    </literal>  build-time defines
7905 <literal> _DRIVER_ROUTER_*           </literal>  router drivers
7906 <literal> _DRIVER_TRANSPORT_*        </literal>  transport drivers
7907 <literal> _DRIVER_AUTHENTICATOR_*    </literal>  authenticator drivers
7908 <literal> _LOG_*                     </literal>  log_selector values
7909 <literal> _OPT_MAIN_*                </literal>  main config options
7910 <literal> _OPT_ROUTERS_*             </literal>  generic router options
7911 <literal> _OPT_TRANSPORTS_*          </literal>  generic transport options
7912 <literal> _OPT_AUTHENTICATORS_*      </literal>  generic authenticator options
7913 <literal> _OPT_ROUTER_*_*            </literal>  private router options
7914 <literal> _OPT_TRANSPORT_*_*         </literal>  private transport options
7915 <literal> _OPT_AUTHENTICATOR_*_*     </literal>  private authenticator options
7916 </literallayout>
7917 <para>
7918 Use an <quote>exim -bP macros</quote> command to get the list of macros.
7919 </para>
7920 </section>
7921 <section id="SECID46">
7922 <title>Conditional skips in the configuration file</title>
7923 <para>
7924 <indexterm role="concept">
7925 <primary>configuration file</primary>
7926 <secondary>conditional skips</secondary>
7927 </indexterm>
7928 <indexterm role="concept">
7929 <primary><literal>.ifdef</literal></primary>
7930 </indexterm>
7931 You can use the directives <literal>.ifdef</literal>, <literal>.ifndef</literal>, <literal>.elifdef</literal>,
7932 <literal>.elifndef</literal>, <literal>.else</literal>, and <literal>.endif</literal> to dynamically include or exclude
7933 portions of the configuration file. The processing happens whenever the file is
7934 read (that is, when an Exim binary starts to run).
7935 </para>
7936 <para>
7937 The implementation is very simple. Instances of the first four directives must
7938 be followed by text that includes the names of one or macros. The condition
7939 that is tested is whether or not any macro substitution has taken place in the
7940 line. Thus:
7941 </para>
7942 <literallayout class="monospaced">
7943 .ifdef AAA
7944 message_size_limit = 50M
7945 .else
7946 message_size_limit = 100M
7947 .endif
7948 </literallayout>
7949 <para>
7950 sets a message size limit of 50M if the macro <literal>AAA</literal> is defined
7951 (or <literal>A</literal> or <literal>AA</literal>), and 100M
7952 otherwise. If there is more than one macro named on the line, the condition
7953 is true if any of them are defined. That is, it is an <quote>or</quote> condition. To
7954 obtain an <quote>and</quote> condition, you need to use nested <literal>.ifdef</literal>s.
7955 </para>
7956 <para>
7957 Although you can use a macro expansion to generate one of these directives,
7958 it is not very useful, because the condition <quote>there was a macro substitution
7959 in this line</quote> will always be true.
7960 </para>
7961 <para>
7962 Text following <literal>.else</literal> and <literal>.endif</literal> is ignored, and can be used as comment
7963 to clarify complicated nestings.
7964 </para>
7965 </section>
7966 <section id="SECTcos">
7967 <title>Common option syntax</title>
7968 <para>
7969 <indexterm role="concept">
7970 <primary>common option syntax</primary>
7971 </indexterm>
7972 <indexterm role="concept">
7973 <primary>syntax of common options</primary>
7974 </indexterm>
7975 <indexterm role="concept">
7976 <primary>configuration file</primary>
7977 <secondary>common option syntax</secondary>
7978 </indexterm>
7979 For the main set of options, driver options, and <function>local_scan()</function> options,
7980 each setting is on a line by itself, and starts with a name consisting of
7981 lower-case letters and underscores. Many options require a data value, and in
7982 these cases the name must be followed by an equals sign (with optional white
7983 space) and then the value. For example:
7984 </para>
7985 <literallayout class="monospaced">
7986 qualify_domain = mydomain.example.com
7987 </literallayout>
7988 <para>
7989 <indexterm role="concept">
7990 <primary>hiding configuration option values</primary>
7991 </indexterm>
7992 <indexterm role="concept">
7993 <primary>configuration options</primary>
7994 <secondary>hiding value of</secondary>
7995 </indexterm>
7996 <indexterm role="concept">
7997 <primary>options</primary>
7998 <secondary>hiding value of</secondary>
7999 </indexterm>
8000 Some option settings may contain sensitive data, for example, passwords for
8001 accessing databases. To stop non-admin users from using the <option>-bP</option> command
8002 line option to read these values, you can precede the option settings with the
8003 word <quote>hide</quote>. For example:
8004 </para>
8005 <literallayout class="monospaced">
8006 hide mysql_servers = localhost/users/admin/secret-password
8007 </literallayout>
8008 <para>
8009 For non-admin users, such options are displayed like this:
8010 </para>
8011 <literallayout class="monospaced">
8012 mysql_servers = &lt;value not displayable&gt;
8013 </literallayout>
8014 <para>
8015 If <quote>hide</quote> is used on a driver option, it hides the value of that option on
8016 all instances of the same driver.
8017 </para>
8018 <para>
8019 The following sections describe the syntax used for the different data types
8020 that are found in option settings.
8021 </para>
8022 </section>
8023 <section id="SECID47">
8024 <title>Boolean options</title>
8025 <para>
8026 <indexterm role="concept">
8027 <primary>format</primary>
8028 <secondary>boolean</secondary>
8029 </indexterm>
8030 <indexterm role="concept">
8031 <primary>boolean configuration values</primary>
8032 </indexterm>
8033 <indexterm role="option">
8034 <primary><option>no_</option><emphasis>xxx</emphasis></primary>
8035 </indexterm>
8036 <indexterm role="option">
8037 <primary><option>not_</option><emphasis>xxx</emphasis></primary>
8038 </indexterm>
8039 Options whose type is given as boolean are on/off switches. There are two
8040 different ways of specifying such options: with and without a data value. If
8041 the option name is specified on its own without data, the switch is turned on;
8042 if it is preceded by <quote>no_</quote> or <quote>not_</quote> the switch is turned off. However,
8043 boolean options may be followed by an equals sign and one of the words
8044 <quote>true</quote>, <quote>false</quote>, <quote>yes</quote>, or <quote>no</quote>, as an alternative syntax. For example,
8045 the following two settings have exactly the same effect:
8046 </para>
8047 <literallayout class="monospaced">
8048 queue_only
8049 queue_only = true
8050 </literallayout>
8051 <para>
8052 The following two lines also have the same (opposite) effect:
8053 </para>
8054 <literallayout class="monospaced">
8055 no_queue_only
8056 queue_only = false
8057 </literallayout>
8058 <para>
8059 You can use whichever syntax you prefer.
8060 </para>
8061 </section>
8062 <section id="SECID48">
8063 <title>Integer values</title>
8064 <para>
8065 <indexterm role="concept">
8066 <primary>integer configuration values</primary>
8067 </indexterm>
8068 <indexterm role="concept">
8069 <primary>format</primary>
8070 <secondary>integer</secondary>
8071 </indexterm>
8072 If an option&#x2019;s type is given as <quote>integer</quote>, the value can be given in decimal,
8073 hexadecimal, or octal. If it starts with a digit greater than zero, a decimal
8074 number is assumed. Otherwise, it is treated as an octal number unless it starts
8075 with the characters <quote>0x</quote>, in which case the remainder is interpreted as a
8076 hexadecimal number.
8077 </para>
8078 <para>
8079 If an integer value is followed by the letter K, it is multiplied by 1024; if
8080 it is followed by the letter M, it is multiplied by 1024x1024;
8081 if by the letter G, 1024x1024x1024.
8082 When the values
8083 of integer option settings are output, values which are an exact multiple of
8084 1024 or 1024x1024 are sometimes, but not always, printed using the letters K
8085 and M. The printing style is independent of the actual input format that was
8086 used.
8087 </para>
8088 </section>
8089 <section id="SECID49">
8090 <title>Octal integer values</title>
8091 <para>
8092 <indexterm role="concept">
8093 <primary>integer format</primary>
8094 </indexterm>
8095 <indexterm role="concept">
8096 <primary>format</primary>
8097 <secondary>octal integer</secondary>
8098 </indexterm>
8099 If an option&#x2019;s type is given as <quote>octal integer</quote>, its value is always
8100 interpreted as an octal number, whether or not it starts with the digit zero.
8101 Such options are always output in octal.
8102 </para>
8103 </section>
8104 <section id="SECID50">
8105 <title>Fixed point numbers</title>
8106 <para>
8107 <indexterm role="concept">
8108 <primary>fixed point configuration values</primary>
8109 </indexterm>
8110 <indexterm role="concept">
8111 <primary>format</primary>
8112 <secondary>fixed point</secondary>
8113 </indexterm>
8114 If an option&#x2019;s type is given as <quote>fixed-point</quote>, its value must be a decimal
8115 integer, optionally followed by a decimal point and up to three further digits.
8116 </para>
8117 </section>
8118 <section id="SECTtimeformat">
8119 <title>Time intervals</title>
8120 <para>
8121 <indexterm role="concept">
8122 <primary>time interval</primary>
8123 <secondary>specifying in configuration</secondary>
8124 </indexterm>
8125 <indexterm role="concept">
8126 <primary>format</primary>
8127 <secondary>time interval</secondary>
8128 </indexterm>
8129 A time interval is specified as a sequence of numbers, each followed by one of
8130 the following letters, with no intervening white space:
8131 </para>
8132 <informaltable frame="none">
8133 <tgroup cols="2" colsep="0" rowsep="0">
8134 <colspec colwidth="30pt" align="left"/>
8135 <colspec colwidth="254pt" align="left"/>
8136 <tbody>
8137 <row>
8138 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>s</option></entry>
8139 <entry>seconds</entry>
8140 </row>
8141 <row>
8142 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>m</option></entry>
8143 <entry>minutes</entry>
8144 </row>
8145 <row>
8146 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>h</option></entry>
8147 <entry>hours</entry>
8148 </row>
8149 <row>
8150 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>d</option></entry>
8151 <entry>days</entry>
8152 </row>
8153 <row>
8154 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>w</option></entry>
8155 <entry>weeks</entry>
8156 </row>
8157 </tbody>
8158 </tgroup>
8159 </informaltable>
8160 <para>
8161 For example, <quote>3h50m</quote> specifies 3 hours and 50 minutes. The values of time
8162 intervals are output in the same format. Exim does not restrict the values; it
8163 is perfectly acceptable, for example, to specify <quote>90m</quote> instead of <quote>1h30m</quote>.
8164 </para>
8165 </section>
8166 <section id="SECTstrings">
8167 <title>String values</title>
8168 <para>
8169 <indexterm role="concept">
8170 <primary>string</primary>
8171 <secondary>format of configuration values</secondary>
8172 </indexterm>
8173 <indexterm role="concept">
8174 <primary>format</primary>
8175 <secondary>string</secondary>
8176 </indexterm>
8177 If an option&#x2019;s type is specified as <quote>string</quote>, the value can be specified with
8178 or without double-quotes. If it does not start with a double-quote, the value
8179 consists of the remainder of the line plus any continuation lines, starting at
8180 the first character after any leading white space, with trailing white space
8181 removed, and with no interpretation of the characters in the string. Because
8182 Exim removes comment lines (those beginning with #) at an early stage, they can
8183 appear in the middle of a multi-line string. The following two settings are
8184 therefore equivalent:
8185 </para>
8186 <literallayout class="monospaced">
8187 trusted_users = uucp:mail
8188 trusted_users = uucp:\
8189                 # This comment line is ignored
8190                 mail
8191 </literallayout>
8192 <para>
8193 <indexterm role="concept">
8194 <primary>string</primary>
8195 <secondary>quoted</secondary>
8196 </indexterm>
8197 <indexterm role="concept">
8198 <primary>escape characters in quoted strings</primary>
8199 </indexterm>
8200 If a string does start with a double-quote, it must end with a closing
8201 double-quote, and any backslash characters other than those used for line
8202 continuation are interpreted as escape characters, as follows:
8203 </para>
8204 <informaltable frame="none">
8205 <tgroup cols="2" colsep="0" rowsep="0">
8206 <colspec colwidth="100pt" align="left"/>
8207 <colspec colwidth="254pt" align="left"/>
8208 <tbody>
8209 <row>
8210 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\\</literal></entry>
8211 <entry>single backslash</entry>
8212 </row>
8213 <row>
8214 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\n</literal></entry>
8215 <entry>newline</entry>
8216 </row>
8217 <row>
8218 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\r</literal></entry>
8219 <entry>carriage return</entry>
8220 </row>
8221 <row>
8222 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\t</literal></entry>
8223 <entry>tab</entry>
8224 </row>
8225 <row>
8226 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\</literal>&lt;<emphasis>octal digits</emphasis>&gt;</entry>
8227 <entry>up to 3 octal digits specify one character</entry>
8228 </row>
8229 <row>
8230 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\x</literal>&lt;<emphasis>hex digits</emphasis>&gt;</entry>
8231 <entry>up to 2 hexadecimal digits specify one character</entry>
8232 </row>
8233 </tbody>
8234 </tgroup>
8235 </informaltable>
8236 <para>
8237 If a backslash is followed by some other character, including a double-quote
8238 character, that character replaces the pair.
8239 </para>
8240 <para>
8241 Quoting is necessary only if you want to make use of the backslash escapes to
8242 insert special characters, or if you need to specify a value with leading or
8243 trailing spaces. These cases are rare, so quoting is almost never needed in
8244 current versions of Exim. In versions of Exim before 3.14, quoting was required
8245 in order to continue lines, so you may come across older configuration files
8246 and examples that apparently quote unnecessarily.
8247 </para>
8248 </section>
8249 <section id="SECID51">
8250 <title>Expanded strings</title>
8251 <para>
8252 <indexterm role="concept">
8253 <primary>expansion</primary>
8254 <secondary>definition of</secondary>
8255 </indexterm>
8256 Some strings in the configuration file are subjected to <emphasis>string expansion</emphasis>,
8257 by which means various parts of the string may be changed according to the
8258 circumstances (see chapter <xref linkend="CHAPexpand"/>). The input syntax for such strings
8259 is as just described; in particular, the handling of backslashes in quoted
8260 strings is done as part of the input process, before expansion takes place.
8261 However, backslash is also an escape character for the expander, so any
8262 backslashes that are required for that reason must be doubled if they are
8263 within a quoted configuration string.
8264 </para>
8265 </section>
8266 <section id="SECID52">
8267 <title>User and group names</title>
8268 <para>
8269 <indexterm role="concept">
8270 <primary>user name</primary>
8271 <secondary>format of</secondary>
8272 </indexterm>
8273 <indexterm role="concept">
8274 <primary>format</primary>
8275 <secondary>user name</secondary>
8276 </indexterm>
8277 <indexterm role="concept">
8278 <primary>groups</primary>
8279 <secondary>name format</secondary>
8280 </indexterm>
8281 <indexterm role="concept">
8282 <primary>format</primary>
8283 <secondary>group name</secondary>
8284 </indexterm>
8285 User and group names are specified as strings, using the syntax described
8286 above, but the strings are interpreted specially. A user or group name must
8287 either consist entirely of digits, or be a name that can be looked up using the
8288 <function>getpwnam()</function> or <function>getgrnam()</function> function, as appropriate.
8289 </para>
8290 </section>
8291 <section id="SECTlistconstruct">
8292 <title>List construction</title>
8293 <para>
8294 <indexterm role="concept">
8295 <primary>list</primary>
8296 <secondary>syntax of in configuration</secondary>
8297 </indexterm>
8298 <indexterm role="concept">
8299 <primary>format</primary>
8300 <secondary>list item in configuration</secondary>
8301 </indexterm>
8302 <indexterm role="concept">
8303 <primary>string</primary>
8304 <secondary>list, definition of</secondary>
8305 </indexterm>
8306 The data for some configuration options is a list of items, with colon as the
8307 default separator. Many of these options are shown with type <quote>string list</quote> in
8308 the descriptions later in this document. Others are listed as <quote>domain list</quote>,
8309 <quote>host list</quote>, <quote>address list</quote>, or <quote>local part list</quote>. Syntactically, they
8310 are all the same; however, those other than <quote>string list</quote> are subject to
8311 particular kinds of interpretation, as described in chapter
8312 <xref linkend="CHAPdomhosaddlists"/>.
8313 </para>
8314 <para>
8315 In all these cases, the entire list is treated as a single string as far as the
8316 input syntax is concerned. The <option>trusted_users</option> setting in section
8317 <xref linkend="SECTstrings"/> above is an example. If a colon is actually needed in an item
8318 in a list, it must be entered as two colons. Leading and trailing white space
8319 on each item in a list is ignored. This makes it possible to include items that
8320 start with a colon, and in particular, certain forms of IPv6 address. For
8321 example, the list
8322 </para>
8323 <literallayout class="monospaced">
8324 local_interfaces = 127.0.0.1 : ::::1
8325 </literallayout>
8326 <para>
8327 contains two IP addresses, the IPv4 address 127.0.0.1 and the IPv6 address ::1.
8328 </para>
8329 <para>
8330 <emphasis role="bold">Note</emphasis>: Although leading and trailing white space is ignored in individual
8331 list items, it is not ignored when parsing the list. The space after the first
8332 colon in the example above is necessary. If it were not there, the list would
8333 be interpreted as the two items 127.0.0.1:: and 1.
8334 </para>
8335 </section>
8336 <section id="SECTlistsepchange">
8337 <title>Changing list separators</title>
8338 <para>
8339 <indexterm role="concept">
8340 <primary>list separator</primary>
8341 <secondary>changing</secondary>
8342 </indexterm>
8343 <indexterm role="concept">
8344 <primary>IPv6</primary>
8345 <secondary>addresses in lists</secondary>
8346 </indexterm>
8347 Doubling colons in IPv6 addresses is an unwelcome chore, so a mechanism was
8348 introduced to allow the separator character to be changed. If a list begins
8349 with a left angle bracket, followed by any punctuation character, that
8350 character is used instead of colon as the list separator. For example, the list
8351 above can be rewritten to use a semicolon separator like this:
8352 </para>
8353 <literallayout class="monospaced">
8354 local_interfaces = &lt;; 127.0.0.1 ; ::1
8355 </literallayout>
8356 <para>
8357 This facility applies to all lists, with the exception of the list in
8358 <option>log_file_path</option>. It is recommended that the use of non-colon separators be
8359 confined to circumstances where they really are needed.
8360 </para>
8361 <para>
8362 <indexterm role="concept">
8363 <primary>list separator</primary>
8364 <secondary>newline as</secondary>
8365 </indexterm>
8366 <indexterm role="concept">
8367 <primary>newline</primary>
8368 <secondary>as list separator</secondary>
8369 </indexterm>
8370 It is also possible to use newline and other control characters (those with
8371 code values less than 32, plus DEL) as separators in lists. Such separators
8372 must be provided literally at the time the list is processed. For options that
8373 are string-expanded, you can write the separator using a normal escape
8374 sequence. This will be processed by the expander before the string is
8375 interpreted as a list. For example, if a newline-separated list of domains is
8376 generated by a lookup, you can process it directly by a line such as this:
8377 </para>
8378 <literallayout class="monospaced">
8379 domains = &lt;\n ${lookup mysql{.....}}
8380 </literallayout>
8381 <para>
8382 This avoids having to change the list separator in such data. You are unlikely
8383 to want to use a control character as a separator in an option that is not
8384 expanded, because the value is literal text. However, it can be done by giving
8385 the value in quotes. For example:
8386 </para>
8387 <literallayout class="monospaced">
8388 local_interfaces = "&lt;\n 127.0.0.1 \n ::1"
8389 </literallayout>
8390 <para>
8391 Unlike printing character separators, which can be included in list items by
8392 doubling, it is not possible to include a control character as data when it is
8393 set as the separator. Two such characters in succession are interpreted as
8394 enclosing an empty list item.
8395 </para>
8396 </section>
8397 <section id="SECTempitelis">
8398 <title>Empty items in lists</title>
8399 <para>
8400 <indexterm role="concept">
8401 <primary>list</primary>
8402 <secondary>empty item in</secondary>
8403 </indexterm>
8404 An empty item at the end of a list is always ignored. In other words, trailing
8405 separator characters are ignored. Thus, the list in
8406 </para>
8407 <literallayout class="monospaced">
8408 senders = user@domain :
8409 </literallayout>
8410 <para>
8411 contains only a single item. If you want to include an empty string as one item
8412 in a list, it must not be the last item. For example, this list contains three
8413 items, the second of which is empty:
8414 </para>
8415 <literallayout class="monospaced">
8416 senders = user1@domain : : user2@domain
8417 </literallayout>
8418 <para>
8419 <emphasis role="bold">Note</emphasis>: There must be white space between the two colons, as otherwise they
8420 are interpreted as representing a single colon data character (and the list
8421 would then contain just one item). If you want to specify a list that contains
8422 just one, empty item, you can do it as in this example:
8423 </para>
8424 <literallayout class="monospaced">
8425 senders = :
8426 </literallayout>
8427 <para>
8428 In this case, the first item is empty, and the second is discarded because it
8429 is at the end of the list.
8430 </para>
8431 </section>
8432 <section id="SECTfordricon">
8433 <title>Format of driver configurations</title>
8434 <para>
8435 <indexterm role="concept">
8436 <primary>drivers</primary>
8437 <secondary>configuration format</secondary>
8438 </indexterm>
8439 There are separate parts in the configuration for defining routers, transports,
8440 and authenticators. In each part, you are defining a number of driver
8441 instances, each with its own set of options. Each driver instance is defined by
8442 a sequence of lines like this:
8443 </para>
8444 <literallayout>
8445 &lt;<emphasis>instance name</emphasis>&gt;:
8446   &lt;<emphasis>option</emphasis>&gt;
8447   ...
8448   &lt;<emphasis>option</emphasis>&gt;
8449 </literallayout>
8450 <para>
8451 In the following example, the instance name is <command>localuser</command>, and it is
8452 followed by three options settings:
8453 </para>
8454 <literallayout class="monospaced">
8455 localuser:
8456   driver = accept
8457   check_local_user
8458   transport = local_delivery
8459 </literallayout>
8460 <para>
8461 For each driver instance, you specify which Exim code module it uses &ndash; by the
8462 setting of the <option>driver</option> option &ndash; and (optionally) some configuration
8463 settings. For example, in the case of transports, if you want a transport to
8464 deliver with SMTP you would use the <command>smtp</command> driver; if you want to deliver to
8465 a local file you would use the <command>appendfile</command> driver. Each of the drivers is
8466 described in detail in its own separate chapter later in this manual.
8467 </para>
8468 <para>
8469 You can have several routers, transports, or authenticators that are based on
8470 the same underlying driver (each must have a different instance name).
8471 </para>
8472 <para>
8473 The order in which routers are defined is important, because addresses are
8474 passed to individual routers one by one, in order. The order in which
8475 transports are defined does not matter at all. The order in which
8476 authenticators are defined is used only when Exim, as a client, is searching
8477 them to find one that matches an authentication mechanism offered by the
8478 server.
8479 </para>
8480 <para>
8481 <indexterm role="concept">
8482 <primary>generic options</primary>
8483 </indexterm>
8484 <indexterm role="concept">
8485 <primary>options</primary>
8486 <secondary>generic &ndash; definition of</secondary>
8487 </indexterm>
8488 Within a driver instance definition, there are two kinds of option: <emphasis>generic</emphasis>
8489 and <emphasis>private</emphasis>. The generic options are those that apply to all drivers of the
8490 same type (that is, all routers, all transports or all authenticators). The
8491 <option>driver</option> option is a generic option that must appear in every definition.
8492 <indexterm role="concept">
8493 <primary>private options</primary>
8494 </indexterm>
8495 The private options are special for each driver, and none need appear, because
8496 they all have default values.
8497 </para>
8498 <para>
8499 The options may appear in any order, except that the <option>driver</option> option must
8500 precede any private options, since these depend on the particular driver. For
8501 this reason, it is recommended that <option>driver</option> always be the first option.
8502 </para>
8503 <para>
8504 Driver instance names, which are used for reference in log entries and
8505 elsewhere, can be any sequence of letters, digits, and underscores (starting
8506 with a letter) and must be unique among drivers of the same type. A router and
8507 a transport (for example) can each have the same name, but no two router
8508 instances can have the same name. The name of a driver instance should not be
8509 confused with the name of the underlying driver module. For example, the
8510 configuration lines:
8511 </para>
8512 <literallayout class="monospaced">
8513 remote_smtp:
8514   driver = smtp
8515 </literallayout>
8516 <para>
8517 create an instance of the <command>smtp</command> transport driver whose name is
8518 <command>remote_smtp</command>. The same driver code can be used more than once, with
8519 different instance names and different option settings each time. A second
8520 instance of the <command>smtp</command> transport, with different options, might be defined
8521 thus:
8522 </para>
8523 <literallayout class="monospaced">
8524 special_smtp:
8525   driver = smtp
8526   port = 1234
8527   command_timeout = 10s
8528 </literallayout>
8529 <para>
8530 The names <command>remote_smtp</command> and <command>special_smtp</command> would be used to reference
8531 these transport instances from routers, and these names would appear in log
8532 lines.
8533 </para>
8534 <para>
8535 Comment lines may be present in the middle of driver specifications. The full
8536 list of option settings for any particular driver instance, including all the
8537 defaulted values, can be extracted by making use of the <option>-bP</option> command line
8538 option.
8539 </para>
8540 </section>
8541 </chapter>
8542
8543 <chapter id="CHAPdefconfil">
8544 <title>The default configuration file</title>
8545 <para>
8546 <indexterm role="concept" id="IIDconfiwal" class="startofrange">
8547 <primary>configuration file</primary>
8548 <secondary>default <quote>walk through</quote></secondary>
8549 </indexterm>
8550 <indexterm role="concept">
8551 <primary>default</primary>
8552 <secondary>configuration file <quote>walk through</quote></secondary>
8553 </indexterm>
8554 The default configuration file supplied with Exim as <filename>src/configure.default</filename>
8555 is sufficient for a host with simple mail requirements. As an introduction to
8556 the way Exim is configured, this chapter <quote>walks through</quote> the default
8557 configuration, giving brief explanations of the settings. Detailed descriptions
8558 of the options are given in subsequent chapters. The default configuration file
8559 itself contains extensive comments about ways you might want to modify the
8560 initial settings. However, note that there are many options that are not
8561 mentioned at all in the default configuration.
8562 </para>
8563 <section id="SECTdefconfmacros">
8564 <title>Macros</title>
8565 <para>
8566 All macros should be defined before any options.
8567 </para>
8568 <para>
8569 One macro is specified, but commented out, in the default configuration:
8570 </para>
8571 <literallayout class="monospaced">
8572 # ROUTER_SMARTHOST=MAIL.HOSTNAME.FOR.CENTRAL.SERVER.EXAMPLE
8573 </literallayout>
8574 <para>
8575 If all off-site mail is expected to be delivered to a "smarthost", then set the
8576 hostname here and uncomment the macro.  This will affect which router is used
8577 later on.  If this is left commented out, then Exim will perform direct-to-MX
8578 deliveries using a <command>dnslookup</command> router.
8579 </para>
8580 <para>
8581 In addition to macros defined here, Exim includes a number of built-in macros
8582 to enable configuration to be guarded by a binary built with support for a
8583 given feature.  See section <xref linkend="SECTbuiltinmacros"/> for more details.
8584 </para>
8585 </section>
8586 <section id="SECTdefconfmain">
8587 <title>Main configuration settings</title>
8588 <para>
8589 The main (global) configuration option settings section must always come first
8590 in the file, after the macros.
8591 The first thing you&#x2019;ll see in the file, after some initial comments, is the line
8592 </para>
8593 <literallayout class="monospaced">
8594 # primary_hostname =
8595 </literallayout>
8596 <para>
8597 This is a commented-out setting of the <option>primary_hostname</option> option. Exim needs
8598 to know the official, fully qualified name of your host, and this is where you
8599 can specify it. However, in most cases you do not need to set this option. When
8600 it is unset, Exim uses the <function>uname()</function> system function to obtain the host name.
8601 </para>
8602 <para>
8603 The first three non-comment configuration lines are as follows:
8604 </para>
8605 <literallayout class="monospaced">
8606 domainlist local_domains    = @
8607 domainlist relay_to_domains =
8608 hostlist   relay_from_hosts = 127.0.0.1
8609 </literallayout>
8610 <para>
8611 These are not, in fact, option settings. They are definitions of two named
8612 domain lists and one named host list. Exim allows you to give names to lists of
8613 domains, hosts, and email addresses, in order to make it easier to manage the
8614 configuration file (see section <xref linkend="SECTnamedlists"/>).
8615 </para>
8616 <para>
8617 The first line defines a domain list called <emphasis>local_domains</emphasis>; this is used
8618 later in the configuration to identify domains that are to be delivered
8619 on the local host.
8620 </para>
8621 <para>
8622 <indexterm role="concept">
8623 <primary>@ in a domain list</primary>
8624 </indexterm>
8625 There is just one item in this list, the string <quote>@</quote>. This is a special form
8626 of entry which means <quote>the name of the local host</quote>. Thus, if the local host is
8627 called <emphasis>a.host.example</emphasis>, mail to <emphasis>any.user@a.host.example</emphasis> is expected to
8628 be delivered locally. Because the local host&#x2019;s name is referenced indirectly,
8629 the same configuration file can be used on different hosts.
8630 </para>
8631 <para>
8632 The second line defines a domain list called <emphasis>relay_to_domains</emphasis>, but the
8633 list itself is empty. Later in the configuration we will come to the part that
8634 controls mail relaying through the local host; it allows relaying to any
8635 domains in this list. By default, therefore, no relaying on the basis of a mail
8636 domain is permitted.
8637 </para>
8638 <para>
8639 The third line defines a host list called <emphasis>relay_from_hosts</emphasis>. This list is
8640 used later in the configuration to permit relaying from any host or IP address
8641 that matches the list. The default contains just the IP address of the IPv4
8642 loopback interface, which means that processes on the local host are able to
8643 submit mail for relaying by sending it over TCP/IP to that interface. No other
8644 hosts are permitted to submit messages for relaying.
8645 </para>
8646 <para>
8647 Just to be sure there&#x2019;s no misunderstanding: at this point in the configuration
8648 we aren&#x2019;t actually setting up any controls. We are just defining some domains
8649 and hosts that will be used in the controls that are specified later.
8650 </para>
8651 <para>
8652 The next two configuration lines are genuine option settings:
8653 </para>
8654 <literallayout class="monospaced">
8655 acl_smtp_rcpt = acl_check_rcpt
8656 acl_smtp_data = acl_check_data
8657 </literallayout>
8658 <para>
8659 These options specify <emphasis>Access Control Lists</emphasis> (ACLs) that are to be used
8660 during an incoming SMTP session for every recipient of a message (every RCPT
8661 command), and after the contents of the message have been received,
8662 respectively. The names of the lists are <emphasis>acl_check_rcpt</emphasis> and
8663 <emphasis>acl_check_data</emphasis>, and we will come to their definitions below, in the ACL
8664 section of the configuration. The RCPT ACL controls which recipients are
8665 accepted for an incoming message &ndash; if a configuration does not provide an ACL
8666 to check recipients, no SMTP mail can be accepted. The DATA ACL allows the
8667 contents of a message to be checked.
8668 </para>
8669 <para>
8670 Two commented-out option settings are next:
8671 </para>
8672 <literallayout class="monospaced">
8673 # av_scanner = clamd:/tmp/clamd
8674 # spamd_address = 127.0.0.1 783
8675 </literallayout>
8676 <para>
8677 These are example settings that can be used when Exim is compiled with the
8678 content-scanning extension. The first specifies the interface to the virus
8679 scanner, and the second specifies the interface to SpamAssassin. Further
8680 details are given in chapter <xref linkend="CHAPexiscan"/>.
8681 </para>
8682 <para>
8683 Three more commented-out option settings follow:
8684 </para>
8685 <literallayout class="monospaced">
8686 # tls_advertise_hosts = *
8687 # tls_certificate = /etc/ssl/exim.crt
8688 # tls_privatekey = /etc/ssl/exim.pem
8689 </literallayout>
8690 <para>
8691 These are example settings that can be used when Exim is compiled with
8692 support for TLS (aka SSL) as described in section <xref linkend="SECTinctlsssl"/>. The
8693 first one specifies the list of clients that are allowed to use TLS when
8694 connecting to this server; in this case, the wildcard means all clients. The
8695 other options specify where Exim should find its TLS certificate and private
8696 key, which together prove the server&#x2019;s identity to any clients that connect.
8697 More details are given in chapter <xref linkend="CHAPTLS"/>.
8698 </para>
8699 <para>
8700 Another two commented-out option settings follow:
8701 </para>
8702 <literallayout class="monospaced">
8703 # daemon_smtp_ports = 25 : 465 : 587
8704 # tls_on_connect_ports = 465
8705 </literallayout>
8706 <para>
8707 <indexterm role="concept">
8708 <primary>port</primary>
8709 <secondary>465 and 587</secondary>
8710 </indexterm>
8711 <indexterm role="concept">
8712 <primary>port</primary>
8713 <secondary>for message submission</secondary>
8714 </indexterm>
8715 <indexterm role="concept">
8716 <primary>message</primary>
8717 <secondary>submission, ports for</secondary>
8718 </indexterm>
8719 <indexterm role="concept">
8720 <primary>submissions protocol</primary>
8721 </indexterm>
8722 <indexterm role="concept">
8723 <primary>smtps protocol</primary>
8724 </indexterm>
8725 <indexterm role="concept">
8726 <primary>ssmtp protocol</primary>
8727 </indexterm>
8728 <indexterm role="concept">
8729 <primary>SMTP</primary>
8730 <secondary>submissions protocol</secondary>
8731 </indexterm>
8732 <indexterm role="concept">
8733 <primary>SMTP</primary>
8734 <secondary>ssmtp protocol</secondary>
8735 </indexterm>
8736 <indexterm role="concept">
8737 <primary>SMTP</primary>
8738 <secondary>smtps protocol</secondary>
8739 </indexterm>
8740 These options provide better support for roaming users who wish to use this
8741 server for message submission. They are not much use unless you have turned on
8742 TLS (as described in the previous paragraph) and authentication (about which
8743 more in section <xref linkend="SECTdefconfauth"/>).
8744 Mail submission from mail clients (MUAs) should be separate from inbound mail
8745 to your domain (MX delivery) for various good reasons (eg, ability to impose
8746 much saner TLS protocol and ciphersuite requirements without unintended
8747 consequences).
8748 RFC 6409 (previously 4409) specifies use of port 587 for SMTP Submission,
8749 which uses STARTTLS, so this is the <quote>submission</quote> port.
8750 RFC 8314 specifies use of port 465 as the <quote>submissions</quote> protocol,
8751 which should be used in preference to 587.
8752 You should also consider deploying SRV records to help clients find
8753 these ports.
8754 Older names for <quote>submissions</quote> are <quote>smtps</quote> and <quote>ssmtp</quote>.
8755 </para>
8756 <para>
8757 Two more commented-out options settings follow:
8758 </para>
8759 <literallayout class="monospaced">
8760 # qualify_domain =
8761 # qualify_recipient =
8762 </literallayout>
8763 <para>
8764 The first of these specifies a domain that Exim uses when it constructs a
8765 complete email address from a local login name. This is often needed when Exim
8766 receives a message from a local process. If you do not set <option>qualify_domain</option>,
8767 the value of <option>primary_hostname</option> is used. If you set both of these options,
8768 you can have different qualification domains for sender and recipient
8769 addresses. If you set only the first one, its value is used in both cases.
8770 </para>
8771 <para>
8772 <indexterm role="concept">
8773 <primary>domain literal</primary>
8774 <secondary>recognizing format</secondary>
8775 </indexterm>
8776 The following line must be uncommented if you want Exim to recognize
8777 addresses of the form <emphasis>user@[10.11.12.13]</emphasis> that is, with a <quote>domain literal</quote>
8778 (an IP address within square brackets) instead of a named domain.
8779 </para>
8780 <literallayout class="monospaced">
8781 # allow_domain_literals
8782 </literallayout>
8783 <para>
8784 The RFCs still require this form, but many people think that in the modern
8785 Internet it makes little sense to permit mail to be sent to specific hosts by
8786 quoting their IP addresses. This ancient format has been used by people who
8787 try to abuse hosts by using them for unwanted relaying. However, some
8788 people believe there are circumstances (for example, messages addressed to
8789 <emphasis>postmaster</emphasis>) where domain literals are still useful.
8790 </para>
8791 <para>
8792 The next configuration line is a kind of trigger guard:
8793 </para>
8794 <literallayout class="monospaced">
8795 never_users = root
8796 </literallayout>
8797 <para>
8798 It specifies that no delivery must ever be run as the root user. The normal
8799 convention is to set up <emphasis>root</emphasis> as an alias for the system administrator. This
8800 setting is a guard against slips in the configuration.
8801 The list of users specified by <option>never_users</option> is not, however, the complete
8802 list; the build-time configuration in <filename>Local/Makefile</filename> has an option called
8803 FIXED_NEVER_USERS specifying a list that cannot be overridden. The
8804 contents of <option>never_users</option> are added to this list. By default
8805 FIXED_NEVER_USERS also specifies root.
8806 </para>
8807 <para>
8808 When a remote host connects to Exim in order to send mail, the only information
8809 Exim has about the host&#x2019;s identity is its IP address. The next configuration
8810 line,
8811 </para>
8812 <literallayout class="monospaced">
8813 host_lookup = *
8814 </literallayout>
8815 <para>
8816 specifies that Exim should do a reverse DNS lookup on all incoming connections,
8817 in order to get a host name. This improves the quality of the logging
8818 information, but if you feel it is too expensive, you can remove it entirely,
8819 or restrict the lookup to hosts on <quote>nearby</quote> networks.
8820 Note that it is not always possible to find a host name from an IP address,
8821 because not all DNS reverse zones are maintained, and sometimes DNS servers are
8822 unreachable.
8823 </para>
8824 <para>
8825 The next two lines are concerned with <emphasis>ident</emphasis> callbacks, as defined by RFC
8826 1413 (hence their names):
8827 </para>
8828 <literallayout class="monospaced">
8829 rfc1413_hosts = *
8830 rfc1413_query_timeout = 0s
8831 </literallayout>
8832 <para>
8833 These settings cause Exim to avoid ident callbacks for all incoming SMTP calls.
8834 Few hosts offer RFC1413 service these days; calls have to be
8835 terminated by a timeout and this needlessly delays the startup
8836 of an incoming SMTP connection.
8837 If you have hosts for which you trust RFC1413 and need this
8838 information, you can change this.
8839 </para>
8840 <para>
8841 This line enables an efficiency SMTP option.  It is negotiated by clients
8842 and not expected to cause problems but can be disabled if needed.
8843 </para>
8844 <literallayout class="monospaced">
8845 prdr_enable = true
8846 </literallayout>
8847 <para>
8848 When Exim receives messages over SMTP connections, it expects all addresses to
8849 be fully qualified with a domain, as required by the SMTP definition. However,
8850 if you are running a server to which simple clients submit messages, you may
8851 find that they send unqualified addresses. The two commented-out options:
8852 </para>
8853 <literallayout class="monospaced">
8854 # sender_unqualified_hosts =
8855 # recipient_unqualified_hosts =
8856 </literallayout>
8857 <para>
8858 show how you can specify hosts that are permitted to send unqualified sender
8859 and recipient addresses, respectively.
8860 </para>
8861 <para>
8862 The <option>log_selector</option> option is used to increase the detail of logging
8863 over the default:
8864 </para>
8865 <literallayout class="monospaced">
8866 log_selector = +smtp_protocol_error +smtp_syntax_error \
8867                +tls_certificate_verified
8868 </literallayout>
8869 <para>
8870 The <option>percent_hack_domains</option> option is also commented out:
8871 </para>
8872 <literallayout class="monospaced">
8873 # percent_hack_domains =
8874 </literallayout>
8875 <para>
8876 It provides a list of domains for which the <quote>percent hack</quote> is to operate.
8877 This is an almost obsolete form of explicit email routing. If you do not know
8878 anything about it, you can safely ignore this topic.
8879 </para>
8880 <para>
8881 The next two settings in the main part of the default configuration are
8882 concerned with messages that have been <quote>frozen</quote> on Exim&#x2019;s queue. When a
8883 message is frozen, Exim no longer continues to try to deliver it. Freezing
8884 occurs when a bounce message encounters a permanent failure because the sender
8885 address of the original message that caused the bounce is invalid, so the
8886 bounce cannot be delivered. This is probably the most common case, but there
8887 are also other conditions that cause freezing, and frozen messages are not
8888 always bounce messages.
8889 </para>
8890 <literallayout class="monospaced">
8891 ignore_bounce_errors_after = 2d
8892 timeout_frozen_after = 7d
8893 </literallayout>
8894 <para>
8895 The first of these options specifies that failing bounce messages are to be
8896 discarded after 2 days in the queue. The second specifies that any frozen
8897 message (whether a bounce message or not) is to be timed out (and discarded)
8898 after a week. In this configuration, the first setting ensures that no failing
8899 bounce message ever lasts a week.
8900 </para>
8901 <para>
8902 Exim queues it&#x2019;s messages in a spool directory. If you expect to have
8903 large queues, you may consider using this option. It splits the spool
8904 directory into subdirectories to avoid file system degradation from
8905 many files in a single directory, resulting in better performance.
8906 Manual manipulation of queued messages becomes more complex (though fortunately
8907 not often needed).
8908 </para>
8909 <literallayout class="monospaced">
8910 # split_spool_directory = true
8911 </literallayout>
8912 <para>
8913 In an ideal world everybody follows the standards. For non-ASCII
8914 messages RFC 2047 is a standard, allowing a maximum line length of 76
8915 characters. Exim adheres that standard and won&#x2019;t process messages which
8916 violate this standard. (Even ${rfc2047:...} expansions will fail.)
8917 In particular, the Exim maintainers have had multiple reports of
8918 problems from Russian administrators of issues until they disable this
8919 check, because of some popular, yet buggy, mail composition software.
8920 </para>
8921 <literallayout class="monospaced">
8922 # check_rfc2047_length = false
8923 </literallayout>
8924 <para>
8925 If you need to be strictly RFC compliant you may wish to disable the
8926 8BITMIME advertisement. Use this, if you exchange mails with systems
8927 that are not 8-bit clean.
8928 </para>
8929 <literallayout class="monospaced">
8930 # accept_8bitmime = false
8931 </literallayout>
8932 <para>
8933 Libraries you use may depend on specific environment settings.  This
8934 imposes a security risk (e.g. PATH). There are two lists:
8935 <option>keep_environment</option> for the variables to import as they are, and
8936 <option>add_environment</option> for variables we want to set to a fixed value.
8937 Note that TZ is handled separately, by the $%timezone%$ runtime
8938 option and by the TIMEZONE_DEFAULT buildtime option.
8939 </para>
8940 <literallayout class="monospaced">
8941 # keep_environment = ^LDAP
8942 # add_environment = PATH=/usr/bin::/bin
8943 </literallayout>
8944 </section>
8945 <section id="SECID54">
8946 <title>ACL configuration</title>
8947 <para>
8948 <indexterm role="concept">
8949 <primary>default</primary>
8950 <secondary>ACLs</secondary>
8951 </indexterm>
8952 <indexterm role="concept">
8953 <primary>access control lists (ACLs)</primary>
8954 <secondary>default configuration</secondary>
8955 </indexterm>
8956 In the default configuration, the ACL section follows the main configuration.
8957 It starts with the line
8958 </para>
8959 <literallayout class="monospaced">
8960 begin acl
8961 </literallayout>
8962 <para>
8963 and it contains the definitions of two ACLs, called <emphasis>acl_check_rcpt</emphasis> and
8964 <emphasis>acl_check_data</emphasis>, that were referenced in the settings of <option>acl_smtp_rcpt</option>
8965 and <option>acl_smtp_data</option> above.
8966 </para>
8967 <para>
8968 <indexterm role="concept">
8969 <primary>RCPT</primary>
8970 <secondary>ACL for</secondary>
8971 </indexterm>
8972 The first ACL is used for every RCPT command in an incoming SMTP message. Each
8973 RCPT command specifies one of the message&#x2019;s recipients. The ACL statements
8974 are considered in order, until the recipient address is either accepted or
8975 rejected. The RCPT command is then accepted or rejected, according to the
8976 result of the ACL processing.
8977 </para>
8978 <literallayout class="monospaced">
8979 acl_check_rcpt:
8980 </literallayout>
8981 <para>
8982 This line, consisting of a name terminated by a colon, marks the start of the
8983 ACL, and names it.
8984 </para>
8985 <literallayout class="monospaced">
8986 accept  hosts = :
8987 </literallayout>
8988 <para>
8989 This ACL statement accepts the recipient if the sending host matches the list.
8990 But what does that strange list mean? It doesn&#x2019;t actually contain any host
8991 names or IP addresses. The presence of the colon puts an empty item in the
8992 list; Exim matches this only if the incoming message did not come from a remote
8993 host, because in that case, the remote hostname is empty. The colon is
8994 important. Without it, the list itself is empty, and can never match anything.
8995 </para>
8996 <para>
8997 What this statement is doing is to accept unconditionally all recipients in
8998 messages that are submitted by SMTP from local processes using the standard
8999 input and output (that is, not using TCP/IP). A number of MUAs operate in this
9000 manner.
9001 </para>
9002 <literallayout class="monospaced">
9003 deny    message       = Restricted characters in address
9004         domains       = +local_domains
9005         local_parts   = ^[.] : ^.*[@%!/|]
9006
9007 deny    message       = Restricted characters in address
9008         domains       = !+local_domains
9009         local_parts   = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
9010 </literallayout>
9011 <para>
9012 These statements are concerned with local parts that contain any of the
9013 characters <quote>@</quote>, <quote>%</quote>, <quote>!</quote>, <quote>/</quote>, <quote>|</quote>, or dots in unusual places.
9014 Although these characters are entirely legal in local parts (in the case of
9015 <quote>@</quote> and leading dots, only if correctly quoted), they do not commonly occur
9016 in Internet mail addresses.
9017 </para>
9018 <para>
9019 The first three have in the past been associated with explicitly routed
9020 addresses (percent is still sometimes used &ndash; see the <option>percent_hack_domains</option>
9021 option). Addresses containing these characters are regularly tried by spammers
9022 in an attempt to bypass relaying restrictions, and also by open relay testing
9023 programs. Unless you really need them it is safest to reject these characters
9024 at this early stage. This configuration is heavy-handed in rejecting these
9025 characters for all messages it accepts from remote hosts. This is a deliberate
9026 policy of being as safe as possible.
9027 </para>
9028 <para>
9029 The first rule above is stricter, and is applied to messages that are addressed
9030 to one of the local domains handled by this host. This is implemented by the
9031 first condition, which restricts it to domains that are listed in the
9032 <emphasis>local_domains</emphasis> domain list. The <quote>+</quote> character is used to indicate a
9033 reference to a named list. In this configuration, there is just one domain in
9034 <emphasis>local_domains</emphasis>, but in general there may be many.
9035 </para>
9036 <para>
9037 The second condition on the first statement uses two regular expressions to
9038 block local parts that begin with a dot or contain <quote>@</quote>, <quote>%</quote>, <quote>!</quote>, <quote>/</quote>,
9039 or <quote>|</quote>. If you have local accounts that include these characters, you will
9040 have to modify this rule.
9041 </para>
9042 <para>
9043 Empty components (two dots in a row) are not valid in RFC 2822, but Exim
9044 allows them because they have been encountered in practice. (Consider the
9045 common convention of local parts constructed as
9046 <quote><emphasis>first-initial.second-initial.family-name</emphasis></quote> when applied to someone like
9047 the author of Exim, who has no second initial.) However, a local part starting
9048 with a dot or containing <quote>/../</quote> can cause trouble if it is used as part of a
9049 filename (for example, for a mailing list). This is also true for local parts
9050 that contain slashes. A pipe symbol can also be troublesome if the local part
9051 is incorporated unthinkingly into a shell command line.
9052 </para>
9053 <para>
9054 The second rule above applies to all other domains, and is less strict. This
9055 allows your own users to send outgoing messages to sites that use slashes
9056 and vertical bars in their local parts. It blocks local parts that begin
9057 with a dot, slash, or vertical bar, but allows these characters within the
9058 local part. However, the sequence <quote>/../</quote> is barred. The use of <quote>@</quote>, <quote>%</quote>,
9059 and <quote>!</quote> is blocked, as before. The motivation here is to prevent your users
9060 (or your users&#x2019; viruses) from mounting certain kinds of attack on remote sites.
9061 </para>
9062 <literallayout class="monospaced">
9063 accept  local_parts   = postmaster
9064         domains       = +local_domains
9065 </literallayout>
9066 <para>
9067 This statement, which has two conditions, accepts an incoming address if the
9068 local part is <emphasis>postmaster</emphasis> and the domain is one of those listed in the
9069 <emphasis>local_domains</emphasis> domain list. The <quote>+</quote> character is used to indicate a
9070 reference to a named list. In this configuration, there is just one domain in
9071 <emphasis>local_domains</emphasis>, but in general there may be many.
9072 </para>
9073 <para>
9074 The presence of this statement means that mail to postmaster is never blocked
9075 by any of the subsequent tests. This can be helpful while sorting out problems
9076 in cases where the subsequent tests are incorrectly denying access.
9077 </para>
9078 <literallayout class="monospaced">
9079 require verify        = sender
9080 </literallayout>
9081 <para>
9082 This statement requires the sender address to be verified before any subsequent
9083 ACL statement can be used. If verification fails, the incoming recipient
9084 address is refused. Verification consists of trying to route the address, to
9085 see if a bounce message could be delivered to it. In the case of remote
9086 addresses, basic verification checks only the domain, but <emphasis>callouts</emphasis> can be
9087 used for more verification if required. Section <xref linkend="SECTaddressverification"/>
9088 discusses the details of address verification.
9089 </para>
9090 <literallayout class="monospaced">
9091 accept  hosts         = +relay_from_hosts
9092         control       = submission
9093 </literallayout>
9094 <para>
9095 This statement accepts the address if the message is coming from one of the
9096 hosts that are defined as being allowed to relay through this host. Recipient
9097 verification is omitted here, because in many cases the clients are dumb MUAs
9098 that do not cope well with SMTP error responses. For the same reason, the
9099 second line specifies <quote>submission mode</quote> for messages that are accepted. This
9100 is described in detail in section <xref linkend="SECTsubmodnon"/>; it causes Exim to fix
9101 messages that are deficient in some way, for example, because they lack a
9102 <emphasis>Date:</emphasis> header line. If you are actually relaying out from MTAs, you should
9103 probably add recipient verification here, and disable submission mode.
9104 </para>
9105 <literallayout class="monospaced">
9106 accept  authenticated = *
9107         control       = submission
9108 </literallayout>
9109 <para>
9110 This statement accepts the address if the client host has authenticated itself.
9111 Submission mode is again specified, on the grounds that such messages are most
9112 likely to come from MUAs. The default configuration does not define any
9113 authenticators, though it does include some nearly complete commented-out
9114 examples described in <xref linkend="SECTdefconfauth"/>. This means that no client can in
9115 fact authenticate until you complete the authenticator definitions.
9116 </para>
9117 <literallayout class="monospaced">
9118 require message = relay not permitted
9119         domains = +local_domains : +relay_to_domains
9120 </literallayout>
9121 <para>
9122 This statement rejects the address if its domain is neither a local domain nor
9123 one of the domains for which this host is a relay.
9124 </para>
9125 <literallayout class="monospaced">
9126 require verify = recipient
9127 </literallayout>
9128 <para>
9129 This statement requires the recipient address to be verified; if verification
9130 fails, the address is rejected.
9131 </para>
9132 <literallayout class="monospaced">
9133 # deny    message     = rejected because $sender_host_address \
9134 #                       is in a black list at $dnslist_domain\n\
9135 #                       $dnslist_text
9136 #         dnslists    = black.list.example
9137 #
9138 # warn    dnslists    = black.list.example
9139 #         add_header  = X-Warning: $sender_host_address is in \
9140 #                       a black list at $dnslist_domain
9141 #         log_message = found in $dnslist_domain
9142 </literallayout>
9143 <para>
9144 These commented-out lines are examples of how you could configure Exim to check
9145 sending hosts against a DNS black list. The first statement rejects messages
9146 from blacklisted hosts, whereas the second just inserts a warning header
9147 line.
9148 </para>
9149 <literallayout class="monospaced">
9150 # require verify = csa
9151 </literallayout>
9152 <para>
9153 This commented-out line is an example of how you could turn on client SMTP
9154 authorization (CSA) checking. Such checks do DNS lookups for special SRV
9155 records.
9156 </para>
9157 <literallayout class="monospaced">
9158 accept
9159 </literallayout>
9160 <para>
9161 The final statement in the first ACL unconditionally accepts any recipient
9162 address that has successfully passed all the previous tests.
9163 </para>
9164 <literallayout class="monospaced">
9165 acl_check_data:
9166 </literallayout>
9167 <para>
9168 This line marks the start of the second ACL, and names it. Most of the contents
9169 of this ACL are commented out:
9170 </para>
9171 <literallayout class="monospaced">
9172 # deny    malware   = *
9173 #         message   = This message contains a virus \
9174 #                     ($malware_name).
9175 </literallayout>
9176 <para>
9177 These lines are examples of how to arrange for messages to be scanned for
9178 viruses when Exim has been compiled with the content-scanning extension, and a
9179 suitable virus scanner is installed. If the message is found to contain a
9180 virus, it is rejected with the given custom error message.
9181 </para>
9182 <literallayout class="monospaced">
9183 # warn    spam      = nobody
9184 #         message   = X-Spam_score: $spam_score\n\
9185 #                     X-Spam_score_int: $spam_score_int\n\
9186 #                     X-Spam_bar: $spam_bar\n\
9187 #                     X-Spam_report: $spam_report
9188 </literallayout>
9189 <para>
9190 These lines are an example of how to arrange for messages to be scanned by
9191 SpamAssassin when Exim has been compiled with the content-scanning extension,
9192 and SpamAssassin has been installed. The SpamAssassin check is run with
9193 <literal>nobody</literal> as its user parameter, and the results are added to the message as a
9194 series of extra header line. In this case, the message is not rejected,
9195 whatever the spam score.
9196 </para>
9197 <literallayout class="monospaced">
9198 accept
9199 </literallayout>
9200 <para>
9201 This final line in the DATA ACL accepts the message unconditionally.
9202 </para>
9203 </section>
9204 <section id="SECID55">
9205 <title>Router configuration</title>
9206 <para>
9207 <indexterm role="concept">
9208 <primary>default</primary>
9209 <secondary>routers</secondary>
9210 </indexterm>
9211 <indexterm role="concept">
9212 <primary>routers</primary>
9213 <secondary>default</secondary>
9214 </indexterm>
9215 The router configuration comes next in the default configuration, introduced
9216 by the line
9217 </para>
9218 <literallayout class="monospaced">
9219 begin routers
9220 </literallayout>
9221 <para>
9222 Routers are the modules in Exim that make decisions about where to send
9223 messages. An address is passed to each router, in turn, until it is either
9224 accepted, or failed. This means that the order in which you define the routers
9225 matters. Each router is fully described in its own chapter later in this
9226 manual. Here we give only brief overviews.
9227 </para>
9228 <literallayout class="monospaced">
9229 # domain_literal:
9230 #   driver = ipliteral
9231 #   domains = !+local_domains
9232 #   transport = remote_smtp
9233 </literallayout>
9234 <para>
9235 <indexterm role="concept">
9236 <primary>domain literal</primary>
9237 <secondary>default router</secondary>
9238 </indexterm>
9239 This router is commented out because the majority of sites do not want to
9240 support domain literal addresses (those of the form <emphasis>user@[10.9.8.7]</emphasis>). If
9241 you uncomment this router, you also need to uncomment the setting of
9242 <option>allow_domain_literals</option> in the main part of the configuration.
9243 </para>
9244 <para>
9245 Which router is used next depends upon whether or not the ROUTER_SMARTHOST
9246 macro has been defined, per
9247 </para>
9248 <literallayout class="monospaced">
9249 .ifdef ROUTER_SMARTHOST
9250 smarthost:
9251 #...
9252 .else
9253 dnslookup:
9254 #...
9255 .endif
9256 </literallayout>
9257 <para>
9258 If ROUTER_SMARTHOST has been defined, either at the top of the file or on the
9259 command-line, then we route all non-local mail to that smarthost; otherwise, we&#x2019;ll
9260 perform DNS lookups for direct-to-MX lookup.  Any mail which is to a local domain will
9261 skip these routers because of the <option>domains</option> option.
9262 </para>
9263 <literallayout class="monospaced">
9264 smarthost:
9265   driver = manualroute
9266   domains = ! +local_domains
9267   transport = smarthost_smtp
9268   route_data = ROUTER_SMARTHOST
9269   ignore_target_hosts = &lt;; 0.0.0.0 ; 127.0.0.0/8 ; ::1
9270   no_more
9271 </literallayout>
9272 <para>
9273 This router only handles mail which is not to any local domains; this is
9274 specified by the line
9275 </para>
9276 <literallayout class="monospaced">
9277 domains = ! +local_domains
9278 </literallayout>
9279 <para>
9280 The <option>domains</option> option lists the domains to which this router applies, but the
9281 exclamation mark is a negation sign, so the router is used only for domains
9282 that are not in the domain list called <emphasis>local_domains</emphasis> (which was defined at
9283 the start of the configuration). The plus sign before <emphasis>local_domains</emphasis>
9284 indicates that it is referring to a named list. Addresses in other domains are
9285 passed on to the following routers.
9286 </para>
9287 <para>
9288 The name of the router driver is <command>manualroute</command> because we are manually
9289 specifying how mail should be routed onwards, instead of using DNS MX.
9290 While the name of this router instance is arbitrary, the <option>driver</option> option must
9291 be one of the driver modules that is in the Exim binary.
9292 </para>
9293 <para>
9294 With no pre-conditions other than <option>domains</option>, all mail for non-local domains
9295 will be handled by this router, and the <option>no_more</option> setting will ensure that no
9296 other routers will be used for messages matching the pre-conditions.  See
9297 <xref linkend="SECTrouprecon"/> for more on how the pre-conditions apply.  For messages which
9298 are handled by this router, we provide a hostname to deliver to in <option>route_data</option>
9299 and the macro supplies the value; the address is then queued for the
9300 <command>smarthost_smtp</command> transport.
9301 </para>
9302 <literallayout class="monospaced">
9303 dnslookup:
9304   driver = dnslookup
9305   domains = ! +local_domains
9306   transport = remote_smtp
9307   ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
9308   no_more
9309 </literallayout>
9310 <para>
9311 The <option>domains</option> option behaves as per smarthost, above.
9312 </para>
9313 <para>
9314 The name of the router driver is <command>dnslookup</command>,
9315 and is specified by the <option>driver</option> option. Do not be confused by the fact that
9316 the name of this router instance is the same as the name of the driver. The
9317 instance name is arbitrary, but the name set in the <option>driver</option> option must be
9318 one of the driver modules that is in the Exim binary.
9319 </para>
9320 <para>
9321 The <command>dnslookup</command> router routes addresses by looking up their domains in the
9322 DNS in order to obtain a list of hosts to which the address is routed. If the
9323 router succeeds, the address is queued for the <command>remote_smtp</command> transport, as
9324 specified by the <option>transport</option> option. If the router does not find the domain
9325 in the DNS, no further routers are tried because of the <option>no_more</option> setting, so
9326 the address fails and is bounced.
9327 </para>
9328 <para>
9329 The <option>ignore_target_hosts</option> option specifies a list of IP addresses that are to
9330 be entirely ignored. This option is present because a number of cases have been
9331 encountered where MX records in the DNS point to host names
9332 whose IP addresses are 0.0.0.0 or are in the 127 subnet (typically 127.0.0.1).
9333 Completely ignoring these IP addresses causes Exim to fail to route the
9334 email address, so it bounces. Otherwise, Exim would log a routing problem, and
9335 continue to try to deliver the message periodically until the address timed
9336 out.
9337 </para>
9338 <literallayout class="monospaced">
9339 system_aliases:
9340   driver = redirect
9341   allow_fail
9342   allow_defer
9343   data = ${lookup{$local_part}lsearch{/etc/aliases}}
9344 # user = exim
9345   file_transport = address_file
9346   pipe_transport = address_pipe
9347 </literallayout>
9348 <para>
9349 Control reaches this and subsequent routers only for addresses in the local
9350 domains. This router checks to see whether the local part is defined as an
9351 alias in the <filename>/etc/aliases</filename> file, and if so, redirects it according to the
9352 data that it looks up from that file. If no data is found for the local part,
9353 the value of the <option>data</option> option is empty, causing the address to be passed to
9354 the next router.
9355 </para>
9356 <para>
9357 <filename>/etc/aliases</filename> is a conventional name for the system aliases file that is
9358 often used. That is why it is referenced by from the default configuration
9359 file. However, you can change this by setting SYSTEM_ALIASES_FILE in
9360 <filename>Local/Makefile</filename> before building Exim.
9361 </para>
9362 <literallayout class="monospaced">
9363 userforward:
9364   driver = redirect
9365   check_local_user
9366 # local_part_suffix = +* : -*
9367 # local_part_suffix_optional
9368   file = $home/.forward
9369 # allow_filter
9370   no_verify
9371   no_expn
9372   check_ancestor
9373   file_transport = address_file
9374   pipe_transport = address_pipe
9375   reply_transport = address_reply
9376 </literallayout>
9377 <para>
9378 This is the most complicated router in the default configuration. It is another
9379 redirection router, but this time it is looking for forwarding data set up by
9380 individual users. The <option>check_local_user</option> setting specifies a check that the
9381 local part of the address is the login name of a local user. If it is not, the
9382 router is skipped. The two commented options that follow <option>check_local_user</option>,
9383 namely:
9384 </para>
9385 <literallayout class="monospaced">
9386 # local_part_suffix = +* : -*
9387 # local_part_suffix_optional
9388 </literallayout>
9389 <para>
9390 <indexterm role="variable">
9391 <primary><varname>$local_part_suffix</varname></primary>
9392 </indexterm>
9393 show how you can specify the recognition of local part suffixes. If the first
9394 is uncommented, a suffix beginning with either a plus or a minus sign, followed
9395 by any sequence of characters, is removed from the local part and placed in the
9396 variable <varname>$local_part_suffix</varname>. The second suffix option specifies that the
9397 presence of a suffix in the local part is optional. When a suffix is present,
9398 the check for a local login uses the local part with the suffix removed.
9399 </para>
9400 <para>
9401 When a local user account is found, the file called <filename>.forward</filename> in the user&#x2019;s
9402 home directory is consulted. If it does not exist, or is empty, the router
9403 declines. Otherwise, the contents of <filename>.forward</filename> are interpreted as
9404 redirection data (see chapter <xref linkend="CHAPredirect"/> for more details).
9405 </para>
9406 <para>
9407 <indexterm role="concept">
9408 <primary>Sieve filter</primary>
9409 <secondary>enabling in default router</secondary>
9410 </indexterm>
9411 Traditional <filename>.forward</filename> files contain just a list of addresses, pipes, or
9412 files. Exim supports this by default. However, if <option>allow_filter</option> is set (it
9413 is commented out by default), the contents of the file are interpreted as a set
9414 of Exim or Sieve filtering instructions, provided the file begins with <quote>#Exim
9415 filter</quote> or <quote>#Sieve filter</quote>, respectively. User filtering is discussed in the
9416 separate document entitled <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis>.
9417 </para>
9418 <para>
9419 The <option>no_verify</option> and <option>no_expn</option> options mean that this router is skipped when
9420 verifying addresses, or when running as a consequence of an SMTP EXPN command.
9421 There are two reasons for doing this:
9422 </para>
9423 <orderedlist numeration="arabic">
9424 <listitem>
9425 <para>
9426 Whether or not a local user has a <filename>.forward</filename> file is not really relevant when
9427 checking an address for validity; it makes sense not to waste resources doing
9428 unnecessary work.
9429 </para>
9430 </listitem>
9431 <listitem>
9432 <para>
9433 More importantly, when Exim is verifying addresses or handling an EXPN
9434 command during an SMTP session, it is running as the Exim user, not as root.
9435 The group is the Exim group, and no additional groups are set up.
9436 It may therefore not be possible for Exim to read users&#x2019; <filename>.forward</filename> files at
9437 this time.
9438 </para>
9439 </listitem>
9440 </orderedlist>
9441 <para>
9442 The setting of <option>check_ancestor</option> prevents the router from generating a new
9443 address that is the same as any previous address that was redirected. (This
9444 works round a problem concerning a bad interaction between aliasing and
9445 forwarding &ndash; see section <xref linkend="SECTredlocmai"/>).
9446 </para>
9447 <para>
9448 The final three option settings specify the transports that are to be used when
9449 forwarding generates a direct delivery to a file, or to a pipe, or sets up an
9450 auto-reply, respectively. For example, if a <filename>.forward</filename> file contains
9451 </para>
9452 <literallayout class="monospaced">
9453 a.nother@elsewhere.example, /home/spqr/archive
9454 </literallayout>
9455 <para>
9456 the delivery to <filename>/home/spqr/archive</filename> is done by running the <option>address_file</option>
9457 transport.
9458 </para>
9459 <literallayout class="monospaced">
9460 localuser:
9461   driver = accept
9462   check_local_user
9463 # local_part_suffix = +* : -*
9464 # local_part_suffix_optional
9465   transport = local_delivery
9466 </literallayout>
9467 <para>
9468 The final router sets up delivery into local mailboxes, provided that the local
9469 part is the name of a local login, by accepting the address and assigning it to
9470 the <command>local_delivery</command> transport. Otherwise, we have reached the end of the
9471 routers, so the address is bounced. The commented suffix settings fulfil the
9472 same purpose as they do for the <command>userforward</command> router.
9473 </para>
9474 </section>
9475 <section id="SECID56">
9476 <title>Transport configuration</title>
9477 <para>
9478 <indexterm role="concept">
9479 <primary>default</primary>
9480 <secondary>transports</secondary>
9481 </indexterm>
9482 <indexterm role="concept">
9483 <primary>transports</primary>
9484 <secondary>default</secondary>
9485 </indexterm>
9486 Transports define mechanisms for actually delivering messages. They operate
9487 only when referenced from routers, so the order in which they are defined does
9488 not matter. The transports section of the configuration starts with
9489 </para>
9490 <literallayout class="monospaced">
9491 begin transports
9492 </literallayout>
9493 <para>
9494 Two remote transports and four local transports are defined.
9495 </para>
9496 <literallayout class="monospaced">
9497 remote_smtp:
9498   driver = smtp
9499   message_size_limit = ${if &gt; {$max_received_linelength}{998} {1}{0}}
9500 .ifdef _HAVE_PRDR
9501   hosts_try_prdr = *
9502 .endif
9503 </literallayout>
9504 <para>
9505 This transport is used for delivering messages over SMTP connections.
9506 The list of remote hosts comes from the router.
9507 The <option>message_size_limit</option> usage is a hack to avoid sending on messages
9508 with over-long lines.
9509 </para>
9510 <para>
9511 The <option>hosts_try_prdr</option> option enables an efficiency SMTP option.  It is
9512 negotiated between client and server and not expected to cause problems
9513 but can be disabled if needed.  The built-in macro _HAVE_PRDR guards the
9514 use of the <option>hosts_try_prdr</option> configuration option.
9515 </para>
9516 <para>
9517 The other remote transport is used when delivering to a specific smarthost
9518 with whom there must be some kind of existing relationship, instead of the
9519 usual federated system.
9520 </para>
9521 <literallayout class="monospaced">
9522 smarthost_smtp:
9523   driver = smtp
9524   message_size_limit = ${if &gt; {$max_received_linelength}{998} {1}{0}}
9525   multi_domain
9526   #
9527 .ifdef _HAVE_TLS
9528   # Comment out any of these which you have to, then file a Support
9529   # request with your smarthost provider to get things fixed:
9530   hosts_require_tls = *
9531   tls_verify_hosts = *
9532   # As long as tls_verify_hosts is enabled, this won't matter, but if you
9533   # have to comment it out then this will at least log whether you succeed
9534   # or not:
9535   tls_try_verify_hosts = *
9536   #
9537   # The SNI name should match the name which we'll expect to verify;
9538   # many mail systems don't use SNI and this doesn't matter, but if it does,
9539   # we need to send a name which the remote site will recognize.
9540   # This _should_ be the name which the smarthost operators specified as
9541   # the hostname for sending your mail to.
9542   tls_sni = ROUTER_SMARTHOST
9543   #
9544 .ifdef _HAVE_OPENSSL
9545   tls_require_ciphers = HIGH:!aNULL:@STRENGTH
9546 .endif
9547 .ifdef _HAVE_GNUTLS
9548   tls_require_ciphers = SECURE192:-VERS-SSL3.0:-VERS-TLS1.0:-VERS-TLS1.1
9549 .endif
9550 .endif
9551 .ifdef _HAVE_PRDR
9552   hosts_try_prdr = *
9553 .endif
9554 </literallayout>
9555 <para>
9556 After the same <option>message_size_limit</option> hack, we then specify that this Transport
9557 can handle messages to multiple domains in one run.  The assumption here is
9558 that you&#x2019;re routing all non-local mail to the same place and that place is
9559 happy to take all messages from you as quickly as possible.
9560 All other options depend upon built-in macros; if Exim was built without TLS support
9561 then no other options are defined.
9562 If TLS is available, then we configure "stronger than default" TLS ciphersuites
9563 and versions using the <option>tls_require_ciphers</option> option, where the value to be
9564 used depends upon the library providing TLS.
9565 Beyond that, the options adopt the stance that you should have TLS support available
9566 from your smarthost on today&#x2019;s Internet, so we turn on requiring TLS for the
9567 mail to be delivered, and requiring that the certificate be valid, and match
9568 the expected hostname.  The <option>tls_sni</option> option can be used by service providers
9569 to select an appropriate certificate to present to you and here we re-use the
9570 ROUTER_SMARTHOST macro, because that is unaffected by CNAMEs present in DNS.
9571 You want to specify the hostname which you&#x2019;ll expect to validate for, and that
9572 should not be subject to insecure tampering via DNS results.
9573 </para>
9574 <para>
9575 For the <option>hosts_try_prdr</option> option see the previous transport.
9576 </para>
9577 <para>
9578 All other options are defaulted.
9579 </para>
9580 <literallayout class="monospaced">
9581 local_delivery:
9582   driver = appendfile
9583   file = /var/mail/$local_part
9584   delivery_date_add
9585   envelope_to_add
9586   return_path_add
9587 # group = mail
9588 # mode = 0660
9589 </literallayout>
9590 <para>
9591 This <command>appendfile</command> transport is used for local delivery to user mailboxes in
9592 traditional BSD mailbox format. By default it runs under the uid and gid of the
9593 local user, which requires the sticky bit to be set on the <filename>/var/mail</filename>
9594 directory. Some systems use the alternative approach of running mail deliveries
9595 under a particular group instead of using the sticky bit. The commented options
9596 show how this can be done.
9597 </para>
9598 <para>
9599 Exim adds three headers to the message as it delivers it: <emphasis>Delivery-date:</emphasis>,
9600 <emphasis>Envelope-to:</emphasis> and <emphasis>Return-path:</emphasis>. This action is requested by the three
9601 similarly-named options above.
9602 </para>
9603 <literallayout class="monospaced">
9604 address_pipe:
9605   driver = pipe
9606   return_output
9607 </literallayout>
9608 <para>
9609 This transport is used for handling deliveries to pipes that are generated by
9610 redirection (aliasing or users&#x2019; <filename>.forward</filename> files). The <option>return_output</option>
9611 option specifies that any output on stdout or stderr generated by the pipe is to
9612 be returned to the sender.
9613 </para>
9614 <literallayout class="monospaced">
9615 address_file:
9616   driver = appendfile
9617   delivery_date_add
9618   envelope_to_add
9619   return_path_add
9620 </literallayout>
9621 <para>
9622 This transport is used for handling deliveries to files that are generated by
9623 redirection. The name of the file is not specified in this instance of
9624 <command>appendfile</command>, because it comes from the <command>redirect</command> router.
9625 </para>
9626 <literallayout class="monospaced">
9627 address_reply:
9628   driver = autoreply
9629 </literallayout>
9630 <para>
9631 This transport is used for handling automatic replies generated by users&#x2019;
9632 filter files.
9633 </para>
9634 </section>
9635 <section id="SECID57">
9636 <title>Default retry rule</title>
9637 <para>
9638 <indexterm role="concept">
9639 <primary>retry</primary>
9640 <secondary>default rule</secondary>
9641 </indexterm>
9642 <indexterm role="concept">
9643 <primary>default</primary>
9644 <secondary>retry rule</secondary>
9645 </indexterm>
9646 The retry section of the configuration file contains rules which affect the way
9647 Exim retries deliveries that cannot be completed at the first attempt. It is
9648 introduced by the line
9649 </para>
9650 <literallayout class="monospaced">
9651 begin retry
9652 </literallayout>
9653 <para>
9654 In the default configuration, there is just one rule, which applies to all
9655 errors:
9656 </para>
9657 <literallayout class="monospaced">
9658 *   *   F,2h,15m; G,16h,1h,1.5; F,4d,6h
9659 </literallayout>
9660 <para>
9661 This causes any temporarily failing address to be retried every 15 minutes for
9662 2 hours, then at intervals starting at one hour and increasing by a factor of
9663 1.5 until 16 hours have passed, then every 6 hours up to 4 days. If an address
9664 is not delivered after 4 days of temporary failure, it is bounced. The time is
9665 measured from first failure, not from the time the message was received.
9666 </para>
9667 <para>
9668 If the retry section is removed from the configuration, or is empty (that is,
9669 if no retry rules are defined), Exim will not retry deliveries. This turns
9670 temporary errors into permanent errors.
9671 </para>
9672 </section>
9673 <section id="SECID58">
9674 <title>Rewriting configuration</title>
9675 <para>
9676 The rewriting section of the configuration, introduced by
9677 </para>
9678 <literallayout class="monospaced">
9679 begin rewrite
9680 </literallayout>
9681 <para>
9682 contains rules for rewriting addresses in messages as they arrive. There are no
9683 rewriting rules in the default configuration file.
9684 </para>
9685 </section>
9686 <section id="SECTdefconfauth">
9687 <title>Authenticators configuration</title>
9688 <para>
9689 <indexterm role="concept">
9690 <primary>AUTH</primary>
9691 <secondary>configuration</secondary>
9692 </indexterm>
9693 The authenticators section of the configuration, introduced by
9694 </para>
9695 <literallayout class="monospaced">
9696 begin authenticators
9697 </literallayout>
9698 <para>
9699 defines mechanisms for the use of the SMTP AUTH command. The default
9700 configuration file contains two commented-out example authenticators
9701 which support plaintext username/password authentication using the
9702 standard PLAIN mechanism and the traditional but non-standard LOGIN
9703 mechanism, with Exim acting as the server. PLAIN and LOGIN are enough
9704 to support most MUA software.
9705 </para>
9706 <para>
9707 The example PLAIN authenticator looks like this:
9708 </para>
9709 <literallayout class="monospaced">
9710 #PLAIN:
9711 #  driver                  = plaintext
9712 #  server_set_id           = $auth2
9713 #  server_prompts          = :
9714 #  server_condition        = Authentication is not yet configured
9715 #  server_advertise_condition = ${if def:tls_in_cipher }
9716 </literallayout>
9717 <para>
9718 And the example LOGIN authenticator looks like this:
9719 </para>
9720 <literallayout class="monospaced">
9721 #LOGIN:
9722 #  driver                  = plaintext
9723 #  server_set_id           = $auth1
9724 #  server_prompts          = &lt;| Username: | Password:
9725 #  server_condition        = Authentication is not yet configured
9726 #  server_advertise_condition = ${if def:tls_in_cipher }
9727 </literallayout>
9728 <para>
9729 The <option>server_set_id</option> option makes Exim remember the authenticated username
9730 in <varname>$authenticated_id</varname>, which can be used later in ACLs or routers. The
9731 <option>server_prompts</option> option configures the <command>plaintext</command> authenticator so
9732 that it implements the details of the specific authentication mechanism,
9733 i.e. PLAIN or LOGIN. The <option>server_advertise_condition</option> setting controls
9734 when Exim offers authentication to clients; in the examples, this is only
9735 when TLS or SSL has been started, so to enable the authenticators you also
9736 need to add support for TLS as described in section <xref linkend="SECTdefconfmain"/>.
9737 </para>
9738 <para>
9739 The <option>server_condition</option> setting defines how to verify that the username and
9740 password are correct. In the examples it just produces an error message.
9741 To make the authenticators work, you can use a string expansion
9742 expression like one of the examples in chapter <xref linkend="CHAPplaintext"/>.
9743 </para>
9744 <para>
9745 Beware that the sequence of the parameters to PLAIN and LOGIN differ; the
9746 usercode and password are in different positions.
9747 Chapter <xref linkend="CHAPplaintext"/> covers both.
9748 </para>
9749 <para>
9750 <indexterm role="concept" startref="IIDconfiwal" class="endofrange"/>
9751 </para>
9752 </section>
9753 </chapter>
9754
9755 <chapter id="CHAPregexp">
9756 <title>Regular expressions</title>
9757 <para>
9758 <indexterm role="concept">
9759 <primary>regular expressions</primary>
9760 <secondary>library</secondary>
9761 </indexterm>
9762 <indexterm role="concept">
9763 <primary>PCRE</primary>
9764 </indexterm>
9765 Exim supports the use of regular expressions in many of its options. It
9766 uses the PCRE regular expression library; this provides regular expression
9767 matching that is compatible with Perl 5. The syntax and semantics of
9768 regular expressions is discussed in
9769 online Perl manpages, in
9770 many Perl reference books, and also in
9771 Jeffrey Friedl&#x2019;s <emphasis>Mastering Regular Expressions</emphasis>, which is published by
9772 O&#x2019;Reilly (see <emphasis role="bold"><ulink url="http://www.oreilly.com/catalog/regex2/">http://www.oreilly.com/catalog/regex2/</ulink></emphasis>).
9773 </para>
9774 <para>
9775 The documentation for the syntax and semantics of the regular expressions that
9776 are supported by PCRE is included in the PCRE distribution, and no further
9777 description is included here. The PCRE functions are called from Exim using
9778 the default option settings (that is, with no PCRE options set), except that
9779 the PCRE_CASELESS option is set when the matching is required to be
9780 case-insensitive.
9781 </para>
9782 <para>
9783 In most cases, when a regular expression is required in an Exim configuration,
9784 it has to start with a circumflex, in order to distinguish it from plain text
9785 or an <quote>ends with</quote> wildcard. In this example of a configuration setting, the
9786 second item in the colon-separated list is a regular expression.
9787 </para>
9788 <literallayout class="monospaced">
9789 domains = a.b.c : ^\\d{3} : *.y.z : ...
9790 </literallayout>
9791 <para>
9792 The doubling of the backslash is required because of string expansion that
9793 precedes interpretation &ndash; see section <xref linkend="SECTlittext"/> for more discussion
9794 of this issue, and a way of avoiding the need for doubling backslashes. The
9795 regular expression that is eventually used in this example contains just one
9796 backslash. The circumflex is included in the regular expression, and has the
9797 normal effect of <quote>anchoring</quote> it to the start of the string that is being
9798 matched.
9799 </para>
9800 <para>
9801 There are, however, two cases where a circumflex is not required for the
9802 recognition of a regular expression: these are the <option>match</option> condition in a
9803 string expansion, and the <option>matches</option> condition in an Exim filter file. In
9804 these cases, the relevant string is always treated as a regular expression; if
9805 it does not start with a circumflex, the expression is not anchored, and can
9806 match anywhere in the subject string.
9807 </para>
9808 <para>
9809 In all cases, if you want a regular expression to match at the end of a string,
9810 you must code the $ metacharacter to indicate this. For example:
9811 </para>
9812 <literallayout class="monospaced">
9813 domains = ^\\d{3}\\.example
9814 </literallayout>
9815 <para>
9816 matches the domain <emphasis>123.example</emphasis>, but it also matches <emphasis>123.example.com</emphasis>.
9817 You need to use:
9818 </para>
9819 <literallayout class="monospaced">
9820 domains = ^\\d{3}\\.example\$
9821 </literallayout>
9822 <para>
9823 if you want <emphasis>example</emphasis> to be the top-level domain. The backslash before the
9824 $ is needed because string expansion also interprets dollar characters.
9825 </para>
9826 </chapter>
9827
9828 <chapter id="CHAPfdlookup">
9829 <title>File and database lookups</title>
9830 <para>
9831 <indexterm role="concept" id="IIDfidalo1" class="startofrange">
9832 <primary>file</primary>
9833 <secondary>lookups</secondary>
9834 </indexterm>
9835 <indexterm role="concept" id="IIDfidalo2" class="startofrange">
9836 <primary>database</primary>
9837 <secondary>lookups</secondary>
9838 </indexterm>
9839 <indexterm role="concept">
9840 <primary>lookup</primary>
9841 <secondary>description of</secondary>
9842 </indexterm>
9843 Exim can be configured to look up data in files or databases as it processes
9844 messages. Two different kinds of syntax are used:
9845 </para>
9846 <orderedlist numeration="arabic">
9847 <listitem>
9848 <para>
9849 A string that is to be expanded may contain explicit lookup requests. These
9850 cause parts of the string to be replaced by data that is obtained from the
9851 lookup. Lookups of this type are conditional expansion items. Different results
9852 can be defined for the cases of lookup success and failure. See chapter
9853 <xref linkend="CHAPexpand"/>, where string expansions are described in detail.
9854 The key for the lookup is specified as part of the string expansion.
9855 </para>
9856 </listitem>
9857 <listitem>
9858 <para>
9859 Lists of domains, hosts, and email addresses can contain lookup requests as a
9860 way of avoiding excessively long linear lists. In this case, the data that is
9861 returned by the lookup is often (but not always) discarded; whether the lookup
9862 succeeds or fails is what really counts. These kinds of list are described in
9863 chapter <xref linkend="CHAPdomhosaddlists"/>.
9864 The key for the lookup is given by the context in which the list is expanded.
9865 </para>
9866 </listitem>
9867 </orderedlist>
9868 <para>
9869 String expansions, lists, and lookups interact with each other in such a way
9870 that there is no order in which to describe any one of them that does not
9871 involve references to the others. Each of these three chapters makes more sense
9872 if you have read the other two first. If you are reading this for the first
9873 time, be aware that some of it will make a lot more sense after you have read
9874 chapters <xref linkend="CHAPdomhosaddlists"/> and <xref linkend="CHAPexpand"/>.
9875 </para>
9876 <section id="SECID60">
9877 <title>Examples of different lookup syntax</title>
9878 <para>
9879 It is easy to confuse the two different kinds of lookup, especially as the
9880 lists that may contain the second kind are always expanded before being
9881 processed as lists. Therefore, they may also contain lookups of the first kind.
9882 Be careful to distinguish between the following two examples:
9883 </para>
9884 <literallayout class="monospaced">
9885 domains = ${lookup{$sender_host_address}lsearch{/some/file}}
9886 domains = lsearch;/some/file
9887 </literallayout>
9888 <para>
9889 The first uses a string expansion, the result of which must be a domain list.
9890 No strings have been specified for a successful or a failing lookup; the
9891 defaults in this case are the looked-up data and an empty string, respectively.
9892 The expansion takes place before the string is processed as a list, and the
9893 file that is searched could contain lines like this:
9894 </para>
9895 <literallayout class="monospaced">
9896 192.168.3.4: domain1:domain2:...
9897 192.168.1.9: domain3:domain4:...
9898 </literallayout>
9899 <para>
9900 When the lookup succeeds, the result of the expansion is a list of domains (and
9901 possibly other types of item that are allowed in domain lists).
9902 </para>
9903 <para>
9904 In the second example, the lookup is a single item in a domain list. It causes
9905 Exim to use a lookup to see if the domain that is being processed can be found
9906 in the file. The file could contains lines like this:
9907 </para>
9908 <literallayout class="monospaced">
9909 domain1:
9910 domain2:
9911 </literallayout>
9912 <para>
9913 Any data that follows the keys is not relevant when checking that the domain
9914 matches the list item.
9915 </para>
9916 <para>
9917 It is possible, though no doubt confusing, to use both kinds of lookup at once.
9918 Consider a file containing lines like this:
9919 </para>
9920 <literallayout class="monospaced">
9921 192.168.5.6: lsearch;/another/file
9922 </literallayout>
9923 <para>
9924 If the value of <varname>$sender_host_address</varname> is 192.168.5.6, expansion of the
9925 first <option>domains</option> setting above generates the second setting, which therefore
9926 causes a second lookup to occur.
9927 </para>
9928 <para>
9929 The rest of this chapter describes the different lookup types that are
9930 available. Any of them can be used in any part of the configuration where a
9931 lookup is permitted.
9932 </para>
9933 </section>
9934 <section id="SECID61">
9935 <title>Lookup types</title>
9936 <para>
9937 <indexterm role="concept">
9938 <primary>lookup</primary>
9939 <secondary>types of</secondary>
9940 </indexterm>
9941 <indexterm role="concept">
9942 <primary>single-key lookup</primary>
9943 <secondary>definition of</secondary>
9944 </indexterm>
9945 Two different types of data lookup are implemented:
9946 </para>
9947 <itemizedlist>
9948 <listitem>
9949 <para>
9950 The <emphasis>single-key</emphasis> type requires the specification of a file in which to look,
9951 and a single key to search for. The key must be a non-empty string for the
9952 lookup to succeed. The lookup type determines how the file is searched.
9953 </para>
9954 </listitem>
9955 <listitem>
9956 <para>
9957 <indexterm role="concept">
9958 <primary>query-style lookup</primary>
9959 <secondary>definition of</secondary>
9960 </indexterm>
9961 The <emphasis>query-style</emphasis> type accepts a generalized database query. No particular
9962 key value is assumed by Exim for query-style lookups. You can use whichever
9963 Exim variables you need to construct the database query.
9964 </para>
9965 </listitem>
9966 </itemizedlist>
9967 <para>
9968 The code for each lookup type is in a separate source file that is included in
9969 the binary of Exim only if the corresponding compile-time option is set. The
9970 default settings in <filename>src/EDITME</filename> are:
9971 </para>
9972 <literallayout class="monospaced">
9973 LOOKUP_DBM=yes
9974 LOOKUP_LSEARCH=yes
9975 </literallayout>
9976 <para>
9977 which means that only linear searching and DBM lookups are included by default.
9978 For some types of lookup (e.g. SQL databases), you need to install appropriate
9979 libraries and header files before building Exim.
9980 </para>
9981 </section>
9982 <section id="SECTsinglekeylookups">
9983 <title>Single-key lookup types</title>
9984 <para>
9985 <indexterm role="concept">
9986 <primary>lookup</primary>
9987 <secondary>single-key types</secondary>
9988 </indexterm>
9989 <indexterm role="concept">
9990 <primary>single-key lookup</primary>
9991 <secondary>list of types</secondary>
9992 </indexterm>
9993 The following single-key lookup types are implemented:
9994 </para>
9995 <itemizedlist>
9996 <listitem>
9997 <para>
9998 <indexterm role="concept">
9999 <primary>cdb</primary>
10000 <secondary>description of</secondary>
10001 </indexterm>
10002 <indexterm role="concept">
10003 <primary>lookup</primary>
10004 <secondary>cdb</secondary>
10005 </indexterm>
10006 <indexterm role="concept">
10007 <primary>binary zero</primary>
10008 <secondary>in lookup key</secondary>
10009 </indexterm>
10010 <command>cdb</command>: The given file is searched as a Constant DataBase file, using the key
10011 string without a terminating binary zero. The cdb format is designed for
10012 indexed files that are read frequently and never updated, except by total
10013 re-creation. As such, it is particularly suitable for large files containing
10014 aliases or other indexed data referenced by an MTA. Information about cdb and
10015 tools for building the files can be found in several places:
10016 </para>
10017 <literallayout>
10018 <emphasis role="bold"><ulink url="https://cr.yp.to/cdb.html">https://cr.yp.to/cdb.html</ulink></emphasis>
10019 <emphasis role="bold"><ulink url="https://www.corpit.ru/mjt/tinycdb.html">https://www.corpit.ru/mjt/tinycdb.html</ulink></emphasis>
10020 <emphasis role="bold"><ulink url="https://packages.debian.org/stable/utils/freecdb">https://packages.debian.org/stable/utils/freecdb</ulink></emphasis>
10021 <emphasis role="bold"><ulink url="https://github.com/philpennock/cdbtools">https://github.com/philpennock/cdbtools</ulink></emphasis> (in Go)
10022 </literallayout>
10023 <para>
10024 A cdb distribution is not needed in order to build Exim with cdb support,
10025 because the code for reading cdb files is included directly in Exim itself.
10026 However, no means of building or testing cdb files is provided with Exim, so
10027 you need to obtain a cdb distribution in order to do this.
10028 </para>
10029 </listitem>
10030 <listitem>
10031 <para>
10032 <indexterm role="concept">
10033 <primary>DBM</primary>
10034 <secondary>lookup type</secondary>
10035 </indexterm>
10036 <indexterm role="concept">
10037 <primary>lookup</primary>
10038 <secondary>dbm</secondary>
10039 </indexterm>
10040 <indexterm role="concept">
10041 <primary>binary zero</primary>
10042 <secondary>in lookup key</secondary>
10043 </indexterm>
10044 <command>dbm</command>: Calls to DBM library functions are used to extract data from the given
10045 DBM file by looking up the record with the given key. A terminating binary
10046 zero is included in the key that is passed to the DBM library. See section
10047 <xref linkend="SECTdb"/> for a discussion of DBM libraries.
10048 </para>
10049 <para>
10050 <indexterm role="concept">
10051 <primary>Berkeley DB library</primary>
10052 <secondary>file format</secondary>
10053 </indexterm>
10054 For all versions of Berkeley DB, Exim uses the DB_HASH style of database
10055 when building DBM files using the <option>exim_dbmbuild</option> utility. However, when
10056 using Berkeley DB versions 3 or 4, it opens existing databases for reading with
10057 the DB_UNKNOWN option. This enables it to handle any of the types of database
10058 that the library supports, and can be useful for accessing DBM files created by
10059 other applications. (For earlier DB versions, DB_HASH is always used.)
10060 </para>
10061 </listitem>
10062 <listitem>
10063 <para>
10064 <indexterm role="concept">
10065 <primary>lookup</primary>
10066 <secondary>dbmjz</secondary>
10067 </indexterm>
10068 <indexterm role="concept">
10069 <primary>lookup</primary>
10070 <secondary>dbm &ndash; embedded NULs</secondary>
10071 </indexterm>
10072 <indexterm role="concept">
10073 <primary>sasldb2</primary>
10074 </indexterm>
10075 <indexterm role="concept">
10076 <primary>dbmjz lookup type</primary>
10077 </indexterm>
10078 <command>dbmjz</command>: This is the same as <command>dbm</command>, except that the lookup key is
10079 interpreted as an Exim list; the elements of the list are joined together with
10080 ASCII NUL characters to form the lookup key.  An example usage would be to
10081 authenticate incoming SMTP calls using the passwords from Cyrus SASL&#x2019;s
10082 <filename>/etc/sasldb2</filename> file with the <command>gsasl</command> authenticator or Exim&#x2019;s own
10083 <command>cram_md5</command> authenticator.
10084 </para>
10085 </listitem>
10086 <listitem>
10087 <para>
10088 <indexterm role="concept">
10089 <primary>lookup</primary>
10090 <secondary>dbmnz</secondary>
10091 </indexterm>
10092 <indexterm role="concept">
10093 <primary>lookup</primary>
10094 <secondary>dbm &ndash; terminating zero</secondary>
10095 </indexterm>
10096 <indexterm role="concept">
10097 <primary>binary zero</primary>
10098 <secondary>in lookup key</secondary>
10099 </indexterm>
10100 <indexterm role="concept">
10101 <primary>Courier</primary>
10102 </indexterm>
10103 <indexterm role="concept">
10104 <primary><filename>/etc/userdbshadow.dat</filename></primary>
10105 </indexterm>
10106 <indexterm role="concept">
10107 <primary>dbmnz lookup type</primary>
10108 </indexterm>
10109 <command>dbmnz</command>: This is the same as <command>dbm</command>, except that a terminating binary zero
10110 is not included in the key that is passed to the DBM library. You may need this
10111 if you want to look up data in files that are created by or shared with some
10112 other application that does not use terminating zeros. For example, you need to
10113 use <command>dbmnz</command> rather than <command>dbm</command> if you want to authenticate incoming SMTP
10114 calls using the passwords from Courier&#x2019;s <filename>/etc/userdbshadow.dat</filename> file. Exim&#x2019;s
10115 utility program for creating DBM files (<emphasis>exim_dbmbuild</emphasis>) includes the zeros
10116 by default, but has an option to omit them (see section <xref linkend="SECTdbmbuild"/>).
10117 </para>
10118 </listitem>
10119 <listitem>
10120 <para>
10121 <indexterm role="concept">
10122 <primary>lookup</primary>
10123 <secondary>dsearch</secondary>
10124 </indexterm>
10125 <indexterm role="concept">
10126 <primary>dsearch lookup type</primary>
10127 </indexterm>
10128 <command>dsearch</command>: The given file must be a directory; this is searched for an entry
10129 whose name is the key by calling the <function>lstat()</function> function. The key may not
10130 contain any forward slash characters. If <function>lstat()</function> succeeds, the result of
10131 the lookup is the name of the entry, which may be a file, directory,
10132 symbolic link, or any other kind of directory entry. An example of how this
10133 lookup can be used to support virtual domains is given in section
10134 <xref linkend="SECTvirtualdomains"/>.
10135 </para>
10136 </listitem>
10137 <listitem>
10138 <para>
10139 <indexterm role="concept">
10140 <primary>lookup</primary>
10141 <secondary>iplsearch</secondary>
10142 </indexterm>
10143 <indexterm role="concept">
10144 <primary>iplsearch lookup type</primary>
10145 </indexterm>
10146 <command>iplsearch</command>: The given file is a text file containing keys and data. A key is
10147 terminated by a colon or white space or the end of the line. The keys in the
10148 file must be IP addresses, or IP addresses with CIDR masks. Keys that involve
10149 IPv6 addresses must be enclosed in quotes to prevent the first internal colon
10150 being interpreted as a key terminator. For example:
10151 </para>
10152 <literallayout class="monospaced">
10153 1.2.3.4:           data for 1.2.3.4
10154 192.168.0.0/16:    data for 192.168.0.0/16
10155 "abcd::cdab":      data for abcd::cdab
10156 "abcd:abcd::/32"   data for abcd:abcd::/32
10157 </literallayout>
10158 <para>
10159 The key for an <command>iplsearch</command> lookup must be an IP address (without a mask). The
10160 file is searched linearly, using the CIDR masks where present, until a matching
10161 key is found. The first key that matches is used; there is no attempt to find a
10162 <quote>best</quote> match. Apart from the way the keys are matched, the processing for
10163 <command>iplsearch</command> is the same as for <command>lsearch</command>.
10164 </para>
10165 <para>
10166 <emphasis role="bold">Warning 1</emphasis>: Unlike most other single-key lookup types, a file of data for
10167 <command>iplsearch</command> can <emphasis>not</emphasis> be turned into a DBM or cdb file, because those
10168 lookup types support only literal keys.
10169 </para>
10170 <para>
10171 <emphasis role="bold">Warning 2</emphasis>: In a host list, you must always use <command>net-iplsearch</command> so that
10172 the implicit key is the host&#x2019;s IP address rather than its name (see section
10173 <xref linkend="SECThoslispatsikey"/>).
10174 </para>
10175 <para revisionflag="changed">
10176 <emphasis role="bold">Warning 3</emphasis>: Do not use an IPv4-mapped IPv6 address for a key; use the
10177 IPv4, in dotted-quad form. (Exim converts IPv4-mapped IPv6 addresses to this
10178 notation before executing the lookup.)
10179 </para>
10180 </listitem>
10181 <listitem>
10182 <para revisionflag="changed">
10183 <indexterm role="concept">
10184 <primary>lookup</primary>
10185 <secondary>json</secondary>
10186 </indexterm>
10187 <indexterm role="concept">
10188 <primary>json</primary>
10189 <secondary>lookup type</secondary>
10190 </indexterm>
10191 <indexterm role="concept">
10192 <primary>JSON</primary>
10193 <secondary>expansions</secondary>
10194 </indexterm>
10195 <command>json</command>: The given file is a text file with a JSON structure.
10196 An element of the structure is extracted, defined by the search key.
10197 The key is a list of subelement selectors
10198 (colon-separated by default but changeable in the usual way)
10199 which are applied in turn to select smaller and smaller portions
10200 of the JSON structure.
10201 If a selector is numeric, it must apply to a JSON array; the (zero-based)
10202 nunbered array element is selected.
10203 Otherwise it must apply to a JSON object; the named element is selected.
10204 The final resulting element can be a simple JSON type or a JSON object
10205 or array; for the latter two a string-representation os the JSON
10206 is returned.
10207 For elements of type string, the returned value is de-quoted.
10208 </para>
10209 </listitem>
10210 <listitem>
10211 <para>
10212 <indexterm role="concept">
10213 <primary>linear search</primary>
10214 </indexterm>
10215 <indexterm role="concept">
10216 <primary>lookup</primary>
10217 <secondary>lsearch</secondary>
10218 </indexterm>
10219 <indexterm role="concept">
10220 <primary>lsearch lookup type</primary>
10221 </indexterm>
10222 <indexterm role="concept">
10223 <primary>case sensitivity</primary>
10224 <secondary>in lsearch lookup</secondary>
10225 </indexterm>
10226 <command>lsearch</command>: The given file is a text file that is searched linearly for a
10227 line beginning with the search key, terminated by a colon or white space or the
10228 end of the line. The search is case-insensitive; that is, upper and lower case
10229 letters are treated as the same. The first occurrence of the key that is found
10230 in the file is used.
10231 </para>
10232 <para>
10233 White space between the key and the colon is permitted. The remainder of the
10234 line, with leading and trailing white space removed, is the data. This can be
10235 continued onto subsequent lines by starting them with any amount of white
10236 space, but only a single space character is included in the data at such a
10237 junction. If the data begins with a colon, the key must be terminated by a
10238 colon, for example:
10239 </para>
10240 <literallayout class="monospaced">
10241 baduser:  :fail:
10242 </literallayout>
10243 <para>
10244 Empty lines and lines beginning with # are ignored, even if they occur in the
10245 middle of an item. This is the traditional textual format of alias files. Note
10246 that the keys in an <command>lsearch</command> file are literal strings. There is no
10247 wildcarding of any kind.
10248 </para>
10249 <para>
10250 <indexterm role="concept">
10251 <primary>lookup</primary>
10252 <secondary>lsearch &ndash; colons in keys</secondary>
10253 </indexterm>
10254 <indexterm role="concept">
10255 <primary>white space</primary>
10256 <secondary>in lsearch key</secondary>
10257 </indexterm>
10258 In most <command>lsearch</command> files, keys are not required to contain colons or #
10259 characters, or white space. However, if you need this feature, it is available.
10260 If a key begins with a doublequote character, it is terminated only by a
10261 matching quote (or end of line), and the normal escaping rules apply to its
10262 contents (see section <xref linkend="SECTstrings"/>). An optional colon is permitted after
10263 quoted keys (exactly as for unquoted keys). There is no special handling of
10264 quotes for the data part of an <command>lsearch</command> line.
10265 </para>
10266 </listitem>
10267 <listitem>
10268 <para>
10269 <indexterm role="concept">
10270 <primary>NIS lookup type</primary>
10271 </indexterm>
10272 <indexterm role="concept">
10273 <primary>lookup</primary>
10274 <secondary>NIS</secondary>
10275 </indexterm>
10276 <indexterm role="concept">
10277 <primary>binary zero</primary>
10278 <secondary>in lookup key</secondary>
10279 </indexterm>
10280 <command>nis</command>: The given file is the name of a NIS map, and a NIS lookup is done with
10281 the given key, without a terminating binary zero. There is a variant called
10282 <command>nis0</command> which does include the terminating binary zero in the key. This is
10283 reportedly needed for Sun-style alias files. Exim does not recognize NIS
10284 aliases; the full map names must be used.
10285 </para>
10286 </listitem>
10287 <listitem>
10288 <para>
10289 <indexterm role="concept">
10290 <primary>wildlsearch lookup type</primary>
10291 </indexterm>
10292 <indexterm role="concept">
10293 <primary>lookup</primary>
10294 <secondary>wildlsearch</secondary>
10295 </indexterm>
10296 <indexterm role="concept">
10297 <primary>nwildlsearch lookup type</primary>
10298 </indexterm>
10299 <indexterm role="concept">
10300 <primary>lookup</primary>
10301 <secondary>nwildlsearch</secondary>
10302 </indexterm>
10303 <command>wildlsearch</command> or <command>nwildlsearch</command>: These search a file linearly, like
10304 <command>lsearch</command>, but instead of being interpreted as a literal string, each key in
10305 the file may be wildcarded. The difference between these two lookup types is
10306 that for <command>wildlsearch</command>, each key in the file is string-expanded before being
10307 used, whereas for <command>nwildlsearch</command>, no expansion takes place.
10308 </para>
10309 <para>
10310 <indexterm role="concept">
10311 <primary>case sensitivity</primary>
10312 <secondary>in (n)wildlsearch lookup</secondary>
10313 </indexterm>
10314 Like <command>lsearch</command>, the testing is done case-insensitively. However, keys in the
10315 file that are regular expressions can be made case-sensitive by the use of
10316 <literal>(-i)</literal> within the pattern. The following forms of wildcard are recognized:
10317 </para>
10318 <orderedlist numeration="arabic">
10319 <listitem>
10320 <para>
10321 The string may begin with an asterisk to mean <quote>ends with</quote>. For example:
10322 </para>
10323 <literallayout class="monospaced">
10324     *.a.b.c       data for anything.a.b.c
10325     *fish         data for anythingfish
10326 </literallayout>
10327 </listitem>
10328 <listitem>
10329 <para>
10330 The string may begin with a circumflex to indicate a regular expression. For
10331 example, for <command>wildlsearch</command>:
10332 </para>
10333 <literallayout class="monospaced">
10334     ^\N\d+\.a\.b\N    data for &lt;digits&gt;.a.b
10335 </literallayout>
10336 <para>
10337 Note the use of <literal>\N</literal> to disable expansion of the contents of the regular
10338 expression. If you are using <command>nwildlsearch</command>, where the keys are not
10339 string-expanded, the equivalent entry is:
10340 </para>
10341 <literallayout class="monospaced">
10342     ^\d+\.a\.b        data for &lt;digits&gt;.a.b
10343 </literallayout>
10344 <para>
10345 The case-insensitive flag is set at the start of compiling the regular
10346 expression, but it can be turned off by using <literal>(-i)</literal> at an appropriate point.
10347 For example, to make the entire pattern case-sensitive:
10348 </para>
10349 <literallayout class="monospaced">
10350     ^(?-i)\d+\.a\.b        data for &lt;digits&gt;.a.b
10351 </literallayout>
10352 <para>
10353 If the regular expression contains white space or colon characters, you must
10354 either quote it (see <command>lsearch</command> above), or represent these characters in other
10355 ways. For example, <literal>\s</literal> can be used for white space and <literal>\x3A</literal> for a
10356 colon. This may be easier than quoting, because if you quote, you have to
10357 escape all the backslashes inside the quotes.
10358 </para>
10359 <para>
10360 <emphasis role="bold">Note</emphasis>: It is not possible to capture substrings in a regular expression
10361 match for later use, because the results of all lookups are cached. If a lookup
10362 is repeated, the result is taken from the cache, and no actual pattern matching
10363 takes place. The values of all the numeric variables are unset after a
10364 <command>(n)wildlsearch</command> match.
10365 </para>
10366 </listitem>
10367 <listitem>
10368 <para>
10369 Although I cannot see it being of much use, the general matching function that
10370 is used to implement <command>(n)wildlsearch</command> means that the string may begin with a
10371 lookup name terminated by a semicolon, and followed by lookup data. For
10372 example:
10373 </para>
10374 <literallayout class="monospaced">
10375     cdb;/some/file  data for keys that match the file
10376 </literallayout>
10377 <para>
10378 The data that is obtained from the nested lookup is discarded.
10379 </para>
10380 </listitem>
10381 </orderedlist>
10382 <para>
10383 Keys that do not match any of these patterns are interpreted literally. The
10384 continuation rules for the data are the same as for <command>lsearch</command>, and keys may
10385 be followed by optional colons.
10386 </para>
10387 <para>
10388 <emphasis role="bold">Warning</emphasis>: Unlike most other single-key lookup types, a file of data for
10389 <command>(n)wildlsearch</command> can <emphasis>not</emphasis> be turned into a DBM or cdb file, because those
10390 lookup types support only literal keys.
10391 </para>
10392 </listitem>
10393 <listitem>
10394 <para>
10395 <indexterm role="concept">
10396 <primary>lookup</primary>
10397 <secondary>spf</secondary>
10398 </indexterm>
10399 If Exim is built with SPF support, manual lookups can be done
10400 (as opposed to the standard ACL condition method.
10401 For details see section <xref linkend="SECSPF"/>.
10402 </para>
10403 </listitem>
10404 </itemizedlist>
10405 </section>
10406 <section id="SECTquerystylelookups">
10407 <title>Query-style lookup types</title>
10408 <para>
10409 <indexterm role="concept">
10410 <primary>lookup</primary>
10411 <secondary>query-style types</secondary>
10412 </indexterm>
10413 <indexterm role="concept">
10414 <primary>query-style lookup</primary>
10415 <secondary>list of types</secondary>
10416 </indexterm>
10417 The supported query-style lookup types are listed below. Further details about
10418 many of them are given in later sections.
10419 </para>
10420 <itemizedlist>
10421 <listitem>
10422 <para>
10423 <indexterm role="concept">
10424 <primary>DNS</primary>
10425 <secondary>as a lookup type</secondary>
10426 </indexterm>
10427 <indexterm role="concept">
10428 <primary>lookup</primary>
10429 <secondary>DNS</secondary>
10430 </indexterm>
10431 <command>dnsdb</command>: This does a DNS search for one or more records whose domain names
10432 are given in the supplied query. The resulting data is the contents of the
10433 records. See section <xref linkend="SECTdnsdb"/>.
10434 </para>
10435 </listitem>
10436 <listitem>
10437 <para>
10438 <indexterm role="concept">
10439 <primary>InterBase lookup type</primary>
10440 </indexterm>
10441 <indexterm role="concept">
10442 <primary>lookup</primary>
10443 <secondary>InterBase</secondary>
10444 </indexterm>
10445 <command>ibase</command>: This does a lookup in an InterBase database.
10446 </para>
10447 </listitem>
10448 <listitem>
10449 <para>
10450 <indexterm role="concept">
10451 <primary>LDAP</primary>
10452 <secondary>lookup type</secondary>
10453 </indexterm>
10454 <indexterm role="concept">
10455 <primary>lookup</primary>
10456 <secondary>LDAP</secondary>
10457 </indexterm>
10458 <command>ldap</command>: This does an LDAP lookup using a query in the form of a URL, and
10459 returns attributes from a single entry. There is a variant called <command>ldapm</command>
10460 that permits values from multiple entries to be returned. A third variant
10461 called <command>ldapdn</command> returns the Distinguished Name of a single entry instead of
10462 any attribute values. See section <xref linkend="SECTldap"/>.
10463 </para>
10464 </listitem>
10465 <listitem>
10466 <para>
10467 <indexterm role="concept">
10468 <primary>MySQL</primary>
10469 <secondary>lookup type</secondary>
10470 </indexterm>
10471 <indexterm role="concept">
10472 <primary>lookup</primary>
10473 <secondary>MySQL</secondary>
10474 </indexterm>
10475 <command>mysql</command>: The format of the query is an SQL statement that is passed to a
10476 MySQL database. See section <xref linkend="SECTsql"/>.
10477 </para>
10478 </listitem>
10479 <listitem>
10480 <para>
10481 <indexterm role="concept">
10482 <primary>NIS+ lookup type</primary>
10483 </indexterm>
10484 <indexterm role="concept">
10485 <primary>lookup</primary>
10486 <secondary>NIS+</secondary>
10487 </indexterm>
10488 <command>nisplus</command>: This does a NIS+ lookup using a query that can specify the name of
10489 the field to be returned. See section <xref linkend="SECTnisplus"/>.
10490 </para>
10491 </listitem>
10492 <listitem>
10493 <para>
10494 <indexterm role="concept">
10495 <primary>Oracle</primary>
10496 <secondary>lookup type</secondary>
10497 </indexterm>
10498 <indexterm role="concept">
10499 <primary>lookup</primary>
10500 <secondary>Oracle</secondary>
10501 </indexterm>
10502 <command>oracle</command>: The format of the query is an SQL statement that is passed to an
10503 Oracle database. See section <xref linkend="SECTsql"/>.
10504 </para>
10505 </listitem>
10506 <listitem>
10507 <para>
10508 <indexterm role="concept">
10509 <primary>lookup</primary>
10510 <secondary>passwd</secondary>
10511 </indexterm>
10512 <indexterm role="concept">
10513 <primary>passwd lookup type</primary>
10514 </indexterm>
10515 <indexterm role="concept">
10516 <primary><filename>/etc/passwd</filename></primary>
10517 </indexterm>
10518 <command>passwd</command> is a query-style lookup with queries that are just user names. The
10519 lookup calls <function>getpwnam()</function> to interrogate the system password data, and on
10520 success, the result string is the same as you would get from an <command>lsearch</command>
10521 lookup on a traditional <filename>/etc/passwd file</filename>, though with <literal>*</literal> for the
10522 password value. For example:
10523 </para>
10524 <literallayout class="monospaced">
10525 *:42:42:King Rat:/home/kr:/bin/bash
10526 </literallayout>
10527 </listitem>
10528 <listitem>
10529 <para>
10530 <indexterm role="concept">
10531 <primary>PostgreSQL lookup type</primary>
10532 </indexterm>
10533 <indexterm role="concept">
10534 <primary>lookup</primary>
10535 <secondary>PostgreSQL</secondary>
10536 </indexterm>
10537 <command>pgsql</command>: The format of the query is an SQL statement that is passed to a
10538 PostgreSQL database. See section <xref linkend="SECTsql"/>.
10539 </para>
10540 </listitem>
10541 <listitem>
10542 <para>
10543 <indexterm role="concept">
10544 <primary>Redis lookup type</primary>
10545 </indexterm>
10546 <indexterm role="concept">
10547 <primary>lookup</primary>
10548 <secondary>Redis</secondary>
10549 </indexterm>
10550 <command>redis</command>: The format of the query is either a simple get or simple set,
10551 passed to a Redis database. See section <xref linkend="SECTsql"/>.
10552 </para>
10553 </listitem>
10554 <listitem>
10555 <para>
10556 <indexterm role="concept">
10557 <primary>sqlite lookup type</primary>
10558 </indexterm>
10559 <indexterm role="concept">
10560 <primary>lookup</primary>
10561 <secondary>sqlite</secondary>
10562 </indexterm>
10563 <command>sqlite</command>: The format of the query is a filename followed by an SQL statement
10564 that is passed to an SQLite database. See section <xref linkend="SECTsqlite"/>.
10565 </para>
10566 </listitem>
10567 <listitem>
10568 <para>
10569 <command>testdb</command>: This is a lookup type that is used for testing Exim. It is
10570 not likely to be useful in normal operation.
10571 </para>
10572 </listitem>
10573 <listitem>
10574 <para>
10575 <indexterm role="concept">
10576 <primary>whoson lookup type</primary>
10577 </indexterm>
10578 <indexterm role="concept">
10579 <primary>lookup</primary>
10580 <secondary>whoson</secondary>
10581 </indexterm>
10582 <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
10583 allows a server to check whether a particular (dynamically allocated) IP
10584 address is currently allocated to a known (trusted) user and, optionally, to
10585 obtain the identity of the said user. For SMTP servers, <emphasis>Whoson</emphasis> was popular
10586 at one time for <quote>POP before SMTP</quote> authentication, but that approach has been
10587 superseded by SMTP authentication. In Exim, <emphasis>Whoson</emphasis> can be used to implement
10588 <quote>POP before SMTP</quote> checking using ACL statements such as
10589 </para>
10590 <literallayout class="monospaced">
10591 require condition = \
10592   ${lookup whoson {$sender_host_address}{yes}{no}}
10593 </literallayout>
10594 <para>
10595 The query consists of a single IP address. The value returned is the name of
10596 the authenticated user, which is stored in the variable <varname>$value</varname>. However, in
10597 this example, the data in <varname>$value</varname> is not used; the result of the lookup is
10598 one of the fixed strings <quote>yes</quote> or <quote>no</quote>.
10599 </para>
10600 </listitem>
10601 </itemizedlist>
10602 </section>
10603 <section id="SECID63">
10604 <title>Temporary errors in lookups</title>
10605 <para>
10606 <indexterm role="concept">
10607 <primary>lookup</primary>
10608 <secondary>temporary error in</secondary>
10609 </indexterm>
10610 Lookup functions can return temporary error codes if the lookup cannot be
10611 completed. For example, an SQL or LDAP database might be unavailable. For this
10612 reason, it is not advisable to use a lookup that might do this for critical
10613 options such as a list of local domains.
10614 </para>
10615 <para>
10616 When a lookup cannot be completed in a router or transport, delivery
10617 of the message (to the relevant address) is deferred, as for any other
10618 temporary error. In other circumstances Exim may assume the lookup has failed,
10619 or may give up altogether.
10620 </para>
10621 </section>
10622 <section id="SECTdefaultvaluelookups">
10623 <title>Default values in single-key lookups</title>
10624 <para>
10625 <indexterm role="concept">
10626 <primary>wildcard lookups</primary>
10627 </indexterm>
10628 <indexterm role="concept">
10629 <primary>lookup</primary>
10630 <secondary>default values</secondary>
10631 </indexterm>
10632 <indexterm role="concept">
10633 <primary>lookup</primary>
10634 <secondary>wildcard</secondary>
10635 </indexterm>
10636 <indexterm role="concept">
10637 <primary>lookup</primary>
10638 <secondary>* added to type</secondary>
10639 </indexterm>
10640 <indexterm role="concept">
10641 <primary>default</primary>
10642 <secondary>in single-key lookups</secondary>
10643 </indexterm>
10644 In this context, a <quote>default value</quote> is a value specified by the administrator
10645 that is to be used if a lookup fails.
10646 </para>
10647 <para>
10648 <emphasis role="bold">Note:</emphasis> This section applies only to single-key lookups. For query-style
10649 lookups, the facilities of the query language must be used. An attempt to
10650 specify a default for a query-style lookup provokes an error.
10651 </para>
10652 <para>
10653 If <quote>*</quote> is added to a single-key lookup type (for example, <option>lsearch*</option>)
10654 and the initial lookup fails, the key <quote>*</quote> is looked up in the file to
10655 provide a default value. See also the section on partial matching below.
10656 </para>
10657 <para>
10658 <indexterm role="concept">
10659 <primary>*@ with single-key lookup</primary>
10660 </indexterm>
10661 <indexterm role="concept">
10662 <primary>lookup</primary>
10663 <secondary>*@ added to type</secondary>
10664 </indexterm>
10665 <indexterm role="concept">
10666 <primary>alias file</primary>
10667 <secondary>per-domain default</secondary>
10668 </indexterm>
10669 Alternatively, if <quote>*@</quote> is added to a single-key lookup type (for example
10670 <option>dbm*@</option>) then, if the initial lookup fails and the key contains an @
10671 character, a second lookup is done with everything before the last @ replaced
10672 by *. This makes it possible to provide per-domain defaults in alias files
10673 that include the domains in the keys. If the second lookup fails (or doesn&#x2019;t
10674 take place because there is no @ in the key), <quote>*</quote> is looked up.
10675 For example, a <command>redirect</command> router might contain:
10676 </para>
10677 <literallayout class="monospaced">
10678 data = ${lookup{$local_part@$domain}lsearch*@{/etc/mix-aliases}}
10679 </literallayout>
10680 <para>
10681 Suppose the address that is being processed is <emphasis>jane@eyre.example</emphasis>. Exim
10682 looks up these keys, in this order:
10683 </para>
10684 <literallayout class="monospaced">
10685 jane@eyre.example
10686 *@eyre.example
10687 *
10688 </literallayout>
10689 <para>
10690 The data is taken from whichever key it finds first. <emphasis role="bold">Note</emphasis>: In an
10691 <command>lsearch</command> file, this does not mean the first of these keys in the file. A
10692 complete scan is done for each key, and only if it is not found at all does
10693 Exim move on to try the next key.
10694 </para>
10695 </section>
10696 <section id="SECTpartiallookup">
10697 <title>Partial matching in single-key lookups</title>
10698 <para>
10699 <indexterm role="concept">
10700 <primary>partial matching</primary>
10701 </indexterm>
10702 <indexterm role="concept">
10703 <primary>wildcard lookups</primary>
10704 </indexterm>
10705 <indexterm role="concept">
10706 <primary>lookup</primary>
10707 <secondary>partial matching</secondary>
10708 </indexterm>
10709 <indexterm role="concept">
10710 <primary>lookup</primary>
10711 <secondary>wildcard</secondary>
10712 </indexterm>
10713 <indexterm role="concept">
10714 <primary>asterisk</primary>
10715 <secondary>in search type</secondary>
10716 </indexterm>
10717 The normal operation of a single-key lookup is to search the file for an exact
10718 match with the given key. However, in a number of situations where domains are
10719 being looked up, it is useful to be able to do partial matching. In this case,
10720 information in the file that has a key starting with <quote>*.</quote> is matched by any
10721 domain that ends with the components that follow the full stop. For example, if
10722 a key in a DBM file is
10723 </para>
10724 <literallayout class="monospaced">
10725 *.dates.fict.example
10726 </literallayout>
10727 <para>
10728 then when partial matching is enabled this is matched by (amongst others)
10729 <emphasis>2001.dates.fict.example</emphasis> and <emphasis>1984.dates.fict.example</emphasis>. It is also matched
10730 by <emphasis>dates.fict.example</emphasis>, if that does not appear as a separate key in the
10731 file.
10732 </para>
10733 <para>
10734 <emphasis role="bold">Note</emphasis>: Partial matching is not available for query-style lookups. It is
10735 also not available for any lookup items in address lists (see section
10736 <xref linkend="SECTaddresslist"/>).
10737 </para>
10738 <para>
10739 Partial matching is implemented by doing a series of separate lookups using
10740 keys constructed by modifying the original subject key. This means that it can
10741 be used with any of the single-key lookup types, provided that
10742 partial matching keys
10743 beginning with a special prefix (default <quote>*.</quote>) are included in the data file.
10744 Keys in the file that do not begin with the prefix are matched only by
10745 unmodified subject keys when partial matching is in use.
10746 </para>
10747 <para>
10748 Partial matching is requested by adding the string <quote>partial-</quote> to the front of
10749 the name of a single-key lookup type, for example, <option>partial-dbm</option>. When this
10750 is done, the subject key is first looked up unmodified; if that fails, <quote>*.</quote>
10751 is added at the start of the subject key, and it is looked up again. If that
10752 fails, further lookups are tried with dot-separated components removed from the
10753 start of the subject key, one-by-one, and <quote>*.</quote> added on the front of what
10754 remains.
10755 </para>
10756 <para>
10757 A minimum number of two non-* components are required. This can be adjusted
10758 by including a number before the hyphen in the search type. For example,
10759 <option>partial3-lsearch</option> specifies a minimum of three non-* components in the
10760 modified keys. Omitting the number is equivalent to <quote>partial2-</quote>. If the
10761 subject key is <emphasis>2250.dates.fict.example</emphasis> then the following keys are looked
10762 up when the minimum number of non-* components is two:
10763 </para>
10764 <literallayout class="monospaced">
10765 2250.dates.fict.example
10766 *.2250.dates.fict.example
10767 *.dates.fict.example
10768 *.fict.example
10769 </literallayout>
10770 <para>
10771 As soon as one key in the sequence is successfully looked up, the lookup
10772 finishes.
10773 </para>
10774 <para>
10775 <indexterm role="concept">
10776 <primary>lookup</primary>
10777 <secondary>partial matching &ndash; changing prefix</secondary>
10778 </indexterm>
10779 <indexterm role="concept">
10780 <primary>prefix</primary>
10781 <secondary>for partial matching</secondary>
10782 </indexterm>
10783 The use of <quote>*.</quote> as the partial matching prefix is a default that can be
10784 changed. The motivation for this feature is to allow Exim to operate with file
10785 formats that are used by other MTAs. A different prefix can be supplied in
10786 parentheses instead of the hyphen after <quote>partial</quote>. For example:
10787 </para>
10788 <literallayout class="monospaced">
10789 domains = partial(.)lsearch;/some/file
10790 </literallayout>
10791 <para>
10792 In this example, if the domain is <emphasis>a.b.c</emphasis>, the sequence of lookups is
10793 <literal>a.b.c</literal>, <literal>.a.b.c</literal>, and <literal>.b.c</literal> (the default minimum of 2 non-wild
10794 components is unchanged). The prefix may consist of any punctuation characters
10795 other than a closing parenthesis. It may be empty, for example:
10796 </para>
10797 <literallayout class="monospaced">
10798 domains = partial1()cdb;/some/file
10799 </literallayout>
10800 <para>
10801 For this example, if the domain is <emphasis>a.b.c</emphasis>, the sequence of lookups is
10802 <literal>a.b.c</literal>, <literal>b.c</literal>, and <literal>c</literal>.
10803 </para>
10804 <para>
10805 If <quote>partial0</quote> is specified, what happens at the end (when the lookup with
10806 just one non-wild component has failed, and the original key is shortened right
10807 down to the null string) depends on the prefix:
10808 </para>
10809 <itemizedlist>
10810 <listitem>
10811 <para>
10812 If the prefix has zero length, the whole lookup fails.
10813 </para>
10814 </listitem>
10815 <listitem>
10816 <para>
10817 If the prefix has length 1, a lookup for just the prefix is done. For
10818 example, the final lookup for <quote>partial0(.)</quote> is for <literal>.</literal> alone.
10819 </para>
10820 </listitem>
10821 <listitem>
10822 <para>
10823 Otherwise, if the prefix ends in a dot, the dot is removed, and the
10824 remainder is looked up. With the default prefix, therefore, the final lookup is
10825 for <quote>*</quote> on its own.
10826 </para>
10827 </listitem>
10828 <listitem>
10829 <para>
10830 Otherwise, the whole prefix is looked up.
10831 </para>
10832 </listitem>
10833 </itemizedlist>
10834 <para>
10835 If the search type ends in <quote>*</quote> or <quote>*@</quote> (see section
10836 <xref linkend="SECTdefaultvaluelookups"/> above), the search for an ultimate default that
10837 this implies happens after all partial lookups have failed. If <quote>partial0</quote> is
10838 specified, adding <quote>*</quote> to the search type has no effect with the default
10839 prefix, because the <quote>*</quote> key is already included in the sequence of partial
10840 lookups. However, there might be a use for lookup types such as
10841 <quote>partial0(.)lsearch*</quote>.
10842 </para>
10843 <para>
10844 The use of <quote>*</quote> in lookup partial matching differs from its use as a wildcard
10845 in domain lists and the like. Partial matching works only in terms of
10846 dot-separated components; a key such as <literal>*fict.example</literal>
10847 in a database file is useless, because the asterisk in a partial matching
10848 subject key is always followed by a dot.
10849 </para>
10850 </section>
10851 <section id="SECID64">
10852 <title>Lookup caching</title>
10853 <para>
10854 <indexterm role="concept">
10855 <primary>lookup</primary>
10856 <secondary>caching</secondary>
10857 </indexterm>
10858 <indexterm role="concept">
10859 <primary>caching</primary>
10860 <secondary>lookup data</secondary>
10861 </indexterm>
10862 Exim caches all lookup results in order to avoid needless repetition of
10863 lookups. However, because (apart from the daemon) Exim operates as a collection
10864 of independent, short-lived processes, this caching applies only within a
10865 single Exim process. There is no inter-process lookup caching facility.
10866 </para>
10867 <para>
10868 For single-key lookups, Exim keeps the relevant files open in case there is
10869 another lookup that needs them. In some types of configuration this can lead to
10870 many files being kept open for messages with many recipients. To avoid hitting
10871 the operating system limit on the number of simultaneously open files, Exim
10872 closes the least recently used file when it needs to open more files than its
10873 own internal limit, which can be changed via the <option>lookup_open_max</option> option.
10874 </para>
10875 <para>
10876 The single-key lookup files are closed and the lookup caches are flushed at
10877 strategic points during delivery &ndash; for example, after all routing is
10878 complete.
10879 </para>
10880 </section>
10881 <section id="SECID65">
10882 <title>Quoting lookup data</title>
10883 <para>
10884 <indexterm role="concept">
10885 <primary>lookup</primary>
10886 <secondary>quoting</secondary>
10887 </indexterm>
10888 <indexterm role="concept">
10889 <primary>quoting</primary>
10890 <secondary>in lookups</secondary>
10891 </indexterm>
10892 When data from an incoming message is included in a query-style lookup, there
10893 is the possibility of special characters in the data messing up the syntax of
10894 the query. For example, a NIS+ query that contains
10895 </para>
10896 <literallayout class="monospaced">
10897 [name=$local_part]
10898 </literallayout>
10899 <para>
10900 will be broken if the local part happens to contain a closing square bracket.
10901 For NIS+, data can be enclosed in double quotes like this:
10902 </para>
10903 <literallayout class="monospaced">
10904 [name="$local_part"]
10905 </literallayout>
10906 <para>
10907 but this still leaves the problem of a double quote in the data. The rule for
10908 NIS+ is that double quotes must be doubled. Other lookup types have different
10909 rules, and to cope with the differing requirements, an expansion operator
10910 of the following form is provided:
10911 </para>
10912 <literallayout class="monospaced">
10913 ${quote_&lt;lookup-type&gt;:&lt;string&gt;}
10914 </literallayout>
10915 <para>
10916 For example, the safest way to write the NIS+ query is
10917 </para>
10918 <literallayout class="monospaced">
10919 [name="${quote_nisplus:$local_part}"]
10920 </literallayout>
10921 <para>
10922 See chapter <xref linkend="CHAPexpand"/> for full coverage of string expansions. The quote
10923 operator can be used for all lookup types, but has no effect for single-key
10924 lookups, since no quoting is ever needed in their key strings.
10925 </para>
10926 </section>
10927 <section id="SECTdnsdb">
10928 <title>More about dnsdb</title>
10929 <para>
10930 <indexterm role="concept">
10931 <primary>dnsdb lookup</primary>
10932 </indexterm>
10933 <indexterm role="concept">
10934 <primary>lookup</primary>
10935 <secondary>dnsdb</secondary>
10936 </indexterm>
10937 <indexterm role="concept">
10938 <primary>DNS</primary>
10939 <secondary>as a lookup type</secondary>
10940 </indexterm>
10941 The <command>dnsdb</command> lookup type uses the DNS as its database. A simple query consists
10942 of a record type and a domain name, separated by an equals sign. For example,
10943 an expansion string could contain:
10944 </para>
10945 <literallayout class="monospaced">
10946 ${lookup dnsdb{mx=a.b.example}{$value}fail}
10947 </literallayout>
10948 <para>
10949 If the lookup succeeds, the result is placed in <varname>$value</varname>, which in this case
10950 is used on its own as the result. If the lookup does not succeed, the
10951 <literal>fail</literal> keyword causes a <emphasis>forced expansion failure</emphasis> &ndash; see section
10952 <xref linkend="SECTforexpfai"/> for an explanation of what this means.
10953 </para>
10954 <para>
10955 The supported DNS record types are A, CNAME, MX, NS, PTR, SOA, SPF, SRV, TLSA
10956 and TXT, and, when Exim is compiled with IPv6 support, AAAA.
10957 If no type is given, TXT is assumed.
10958 </para>
10959 <para>
10960 For any record type, if multiple records are found, the data is returned as a
10961 concatenation, with newline as the default separator. The order, of course,
10962 depends on the DNS resolver. You can specify a different separator character
10963 between multiple records by putting a right angle-bracket followed immediately
10964 by the new separator at the start of the query. For example:
10965 </para>
10966 <literallayout class="monospaced">
10967 ${lookup dnsdb{&gt;: a=host1.example}}
10968 </literallayout>
10969 <para>
10970 It is permitted to specify a space as the separator character. Further
10971 white space is ignored.
10972 For lookup types that return multiple fields per record,
10973 an alternate field separator can be specified using a comma after the main
10974 separator character, followed immediately by the field separator.
10975 </para>
10976 <para>
10977 <indexterm role="concept">
10978 <primary>PTR record</primary>
10979 <secondary>in <command>dnsdb</command> lookup</secondary>
10980 </indexterm>
10981 When the type is PTR,
10982 the data can be an IP address, written as normal; inversion and the addition of
10983 <option>in-addr.arpa</option> or <option>ip6.arpa</option> happens automatically. For example:
10984 </para>
10985 <literallayout class="monospaced">
10986 ${lookup dnsdb{ptr=192.168.4.5}{$value}fail}
10987 </literallayout>
10988 <para>
10989 If the data for a PTR record is not a syntactically valid IP address, it is not
10990 altered and nothing is added.
10991 </para>
10992 <para>
10993 <indexterm role="concept">
10994 <primary>MX record</primary>
10995 <secondary>in <command>dnsdb</command> lookup</secondary>
10996 </indexterm>
10997 <indexterm role="concept">
10998 <primary>SRV record</primary>
10999 <secondary>in <command>dnsdb</command> lookup</secondary>
11000 </indexterm>
11001 For an MX lookup, both the preference value and the host name are returned for
11002 each record, separated by a space. For an SRV lookup, the priority, weight,
11003 port, and host name are returned for each record, separated by spaces.
11004 The field separator can be modified as above.
11005 </para>
11006 <para>
11007 <indexterm role="concept">
11008 <primary>TXT record</primary>
11009 <secondary>in <command>dnsdb</command> lookup</secondary>
11010 </indexterm>
11011 <indexterm role="concept">
11012 <primary>SPF record</primary>
11013 <secondary>in <command>dnsdb</command> lookup</secondary>
11014 </indexterm>
11015 For TXT records with multiple items of data, only the first item is returned,
11016 unless a field separator is specified.
11017 To concatenate items without a separator, use a semicolon instead.
11018 For SPF records the
11019 default behaviour is to concatenate multiple items without using a separator.
11020 </para>
11021 <literallayout class="monospaced">
11022 ${lookup dnsdb{&gt;\n,: txt=a.b.example}}
11023 ${lookup dnsdb{&gt;\n; txt=a.b.example}}
11024 ${lookup dnsdb{spf=example.org}}
11025 </literallayout>
11026 <para>
11027 It is permitted to specify a space as the separator character. Further
11028 white space is ignored.
11029 </para>
11030 <para>
11031 <indexterm role="concept">
11032 <primary>SOA record</primary>
11033 <secondary>in <command>dnsdb</command> lookup</secondary>
11034 </indexterm>
11035 For an SOA lookup, while no result is obtained the lookup is redone with
11036 successively more leading components dropped from the given domain.
11037 Only the primary-nameserver field is returned unless a field separator is
11038 specified.
11039 </para>
11040 <literallayout class="monospaced">
11041 ${lookup dnsdb{&gt;:,; soa=a.b.example.com}}
11042 </literallayout>
11043 </section>
11044 <section id="SECTdnsdb_mod">
11045 <title>Dnsdb lookup modifiers</title>
11046 <para>
11047 <indexterm role="concept">
11048 <primary>dnsdb modifiers</primary>
11049 </indexterm>
11050 <indexterm role="concept">
11051 <primary>modifiers</primary>
11052 <secondary>dnsdb</secondary>
11053 </indexterm>
11054 <indexterm role="concept">
11055 <primary>options</primary>
11056 <secondary>dnsdb</secondary>
11057 </indexterm>
11058 Modifiers for <command>dnsdb</command> lookups are given by optional keywords,
11059 each followed by a comma,
11060 that may appear before the record type.
11061 </para>
11062 <para>
11063 The <command>dnsdb</command> lookup fails only if all the DNS lookups fail. If there is a
11064 temporary DNS error for any of them, the behaviour is controlled by
11065 a defer-option modifier.
11066 The possible keywords are
11067 <quote>defer_strict</quote>, <quote>defer_never</quote>, and <quote>defer_lax</quote>.
11068 With <quote>strict</quote> behaviour, any temporary DNS error causes the
11069 whole lookup to defer. With <quote>never</quote> behaviour, a temporary DNS error is
11070 ignored, and the behaviour is as if the DNS lookup failed to find anything.
11071 With <quote>lax</quote> behaviour, all the queries are attempted, but a temporary DNS
11072 error causes the whole lookup to defer only if none of the other lookups
11073 succeed. The default is <quote>lax</quote>, so the following lookups are equivalent:
11074 </para>
11075 <literallayout class="monospaced">
11076 ${lookup dnsdb{defer_lax,a=one.host.com:two.host.com}}
11077 ${lookup dnsdb{a=one.host.com:two.host.com}}
11078 </literallayout>
11079 <para>
11080 Thus, in the default case, as long as at least one of the DNS lookups
11081 yields some data, the lookup succeeds.
11082 </para>
11083 <para>
11084 <indexterm role="concept">
11085 <primary>DNSSEC</primary>
11086 <secondary>dns lookup</secondary>
11087 </indexterm>
11088 Use of <command>DNSSEC</command> is controlled by a dnssec modifier.
11089 The possible keywords are
11090 <quote>dnssec_strict</quote>, <quote>dnssec_lax</quote>, and <quote>dnssec_never</quote>.
11091 With <quote>strict</quote> or <quote>lax</quote> DNSSEC information is requested
11092 with the lookup.
11093 With <quote>strict</quote> a response from the DNS resolver that
11094 is not labelled as authenticated data
11095 is treated as equivalent to a temporary DNS error.
11096 </para>
11097 <para revisionflag="changed">
11098 The default is <quote>lax</quote>.
11099 </para>
11100 <para>
11101 See also the <varname>$lookup_dnssec_authenticated</varname> variable.
11102 </para>
11103 <para>
11104 <indexterm role="concept">
11105 <primary>timeout</primary>
11106 <secondary>dns lookup</secondary>
11107 </indexterm>
11108 <indexterm role="concept">
11109 <primary>DNS</primary>
11110 <secondary>timeout</secondary>
11111 </indexterm>
11112 Timeout for the dnsdb lookup can be controlled by a retrans modifier.
11113 The form is <quote>retrans_VAL</quote> where VAL is an Exim time specification
11114 (e.g. <quote>5s</quote>).
11115 The default value is set by the main configuration option <option>dns_retrans</option>.
11116 </para>
11117 <para>
11118 Retries for the dnsdb lookup can be controlled by a retry modifier.
11119 The form if <quote>retry_VAL</quote> where VAL is an integer.
11120 The default count is set by the main configuration option <option>dns_retry</option>.
11121 </para>
11122 <para>
11123 <indexterm role="concept">
11124 <primary>caching</primary>
11125 <secondary>of dns lookup</secondary>
11126 </indexterm>
11127 <indexterm role="concept">
11128 <primary>TTL</primary>
11129 <secondary>of dns lookup</secondary>
11130 </indexterm>
11131 <indexterm role="concept">
11132 <primary>DNS</primary>
11133 <secondary>TTL</secondary>
11134 </indexterm>
11135 Dnsdb lookup results are cached within a single process (and its children).
11136 The cache entry lifetime is limited to the smallest time-to-live (TTL)
11137 value of the set of returned DNS records.
11138 </para>
11139 </section>
11140 <section id="SECID66">
11141 <title>Pseudo dnsdb record types</title>
11142 <para>
11143 <indexterm role="concept">
11144 <primary>MX record</primary>
11145 <secondary>in <command>dnsdb</command> lookup</secondary>
11146 </indexterm>
11147 By default, both the preference value and the host name are returned for
11148 each MX record, separated by a space. If you want only host names, you can use
11149 the pseudo-type MXH:
11150 </para>
11151 <literallayout class="monospaced">
11152 ${lookup dnsdb{mxh=a.b.example}}
11153 </literallayout>
11154 <para>
11155 In this case, the preference values are omitted, and just the host names are
11156 returned.
11157 </para>
11158 <para>
11159 <indexterm role="concept">
11160 <primary>name server for enclosing domain</primary>
11161 </indexterm>
11162 Another pseudo-type is ZNS (for <quote>zone NS</quote>). It performs a lookup for NS
11163 records on the given domain, but if none are found, it removes the first
11164 component of the domain name, and tries again. This process continues until NS
11165 records are found or there are no more components left (or there is a DNS
11166 error). In other words, it may return the name servers for a top-level domain,
11167 but it never returns the root name servers. If there are no NS records for the
11168 top-level domain, the lookup fails. Consider these examples:
11169 </para>
11170 <literallayout class="monospaced">
11171 ${lookup dnsdb{zns=xxx.quercite.com}}
11172 ${lookup dnsdb{zns=xxx.edu}}
11173 </literallayout>
11174 <para>
11175 Assuming that in each case there are no NS records for the full domain name,
11176 the first returns the name servers for <option>quercite.com</option>, and the second returns
11177 the name servers for <option>edu</option>.
11178 </para>
11179 <para>
11180 You should be careful about how you use this lookup because, unless the
11181 top-level domain does not exist, the lookup always returns some host names. The
11182 sort of use to which this might be put is for seeing if the name servers for a
11183 given domain are on a blacklist. You can probably assume that the name servers
11184 for the high-level domains such as <option>com</option> or <option>co.uk</option> are not going to be on
11185 such a list.
11186 </para>
11187 <para>
11188 <indexterm role="concept">
11189 <primary>CSA</primary>
11190 <secondary>in <command>dnsdb</command> lookup</secondary>
11191 </indexterm>
11192 A third pseudo-type is CSA (Client SMTP Authorization). This looks up SRV
11193 records according to the CSA rules, which are described in section
11194 <xref linkend="SECTverifyCSA"/>. Although <command>dnsdb</command> supports SRV lookups directly, this is
11195 not sufficient because of the extra parent domain search behaviour of CSA. The
11196 result of a successful lookup such as:
11197 </para>
11198 <literallayout class="monospaced">
11199 ${lookup dnsdb {csa=$sender_helo_name}}
11200 </literallayout>
11201 <para>
11202 has two space-separated fields: an authorization code and a target host name.
11203 The authorization code can be <quote>Y</quote> for yes, <quote>N</quote> for no, <quote>X</quote> for explicit
11204 authorization required but absent, or <quote>?</quote> for unknown.
11205 </para>
11206 <para>
11207 <indexterm role="concept">
11208 <primary>A+</primary>
11209 <secondary>in <command>dnsdb</command> lookup</secondary>
11210 </indexterm>
11211 The pseudo-type A+ performs an AAAA
11212 and then an A lookup.  All results are returned; defer processing
11213 (see below) is handled separately for each lookup.  Example:
11214 </para>
11215 <literallayout class="monospaced">
11216 ${lookup dnsdb {&gt;; a+=$sender_helo_name}}
11217 </literallayout>
11218 </section>
11219 <section id="SECID67">
11220 <title>Multiple dnsdb lookups</title>
11221 <para>
11222 In the previous sections, <command>dnsdb</command> lookups for a single domain are described.
11223 However, you can specify a list of domains or IP addresses in a single
11224 <command>dnsdb</command> lookup. The list is specified in the normal Exim way, with colon as
11225 the default separator, but with the ability to change this. For example:
11226 </para>
11227 <literallayout class="monospaced">
11228 ${lookup dnsdb{one.domain.com:two.domain.com}}
11229 ${lookup dnsdb{a=one.host.com:two.host.com}}
11230 ${lookup dnsdb{ptr = &lt;; 1.2.3.4 ; 4.5.6.8}}
11231 </literallayout>
11232 <para>
11233 In order to retain backwards compatibility, there is one special case: if
11234 the lookup type is PTR and no change of separator is specified, Exim looks
11235 to see if the rest of the string is precisely one IPv6 address. In this
11236 case, it does not treat it as a list.
11237 </para>
11238 <para>
11239 The data from each lookup is concatenated, with newline separators by default,
11240 in the same way that multiple DNS records for a single item are handled. A
11241 different separator can be specified, as described above.
11242 </para>
11243 </section>
11244 <section id="SECTldap">
11245 <title>More about LDAP</title>
11246 <para>
11247 <indexterm role="concept">
11248 <primary>LDAP</primary>
11249 <secondary>lookup, more about</secondary>
11250 </indexterm>
11251 <indexterm role="concept">
11252 <primary>lookup</primary>
11253 <secondary>LDAP</secondary>
11254 </indexterm>
11255 <indexterm role="concept">
11256 <primary>Solaris</primary>
11257 <secondary>LDAP</secondary>
11258 </indexterm>
11259 The original LDAP implementation came from the University of Michigan; this has
11260 become <quote>Open LDAP</quote>, and there are now two different releases. Another
11261 implementation comes from Netscape, and Solaris 7 and subsequent releases
11262 contain inbuilt LDAP support. Unfortunately, though these are all compatible at
11263 the lookup function level, their error handling is different. For this reason
11264 it is necessary to set a compile-time variable when building Exim with LDAP, to
11265 indicate which LDAP library is in use. One of the following should appear in
11266 your <filename>Local/Makefile</filename>:
11267 </para>
11268 <literallayout class="monospaced">
11269 LDAP_LIB_TYPE=UMICHIGAN
11270 LDAP_LIB_TYPE=OPENLDAP1
11271 LDAP_LIB_TYPE=OPENLDAP2
11272 LDAP_LIB_TYPE=NETSCAPE
11273 LDAP_LIB_TYPE=SOLARIS
11274 </literallayout>
11275 <para>
11276 If LDAP_LIB_TYPE is not set, Exim assumes <literal>OPENLDAP1</literal>, which has the
11277 same interface as the University of Michigan version.
11278 </para>
11279 <para>
11280 There are three LDAP lookup types in Exim. These behave slightly differently in
11281 the way they handle the results of a query:
11282 </para>
11283 <itemizedlist>
11284 <listitem>
11285 <para>
11286 <command>ldap</command> requires the result to contain just one entry; if there are more, it
11287 gives an error.
11288 </para>
11289 </listitem>
11290 <listitem>
11291 <para>
11292 <command>ldapdn</command> also requires the result to contain just one entry, but it is the
11293 Distinguished Name that is returned rather than any attribute values.
11294 </para>
11295 </listitem>
11296 <listitem>
11297 <para>
11298 <command>ldapm</command> permits the result to contain more than one entry; the attributes
11299 from all of them are returned.
11300 </para>
11301 </listitem>
11302 </itemizedlist>
11303 <para>
11304 For <command>ldap</command> and <command>ldapm</command>, if a query finds only entries with no attributes,
11305 Exim behaves as if the entry did not exist, and the lookup fails. The format of
11306 the data returned by a successful lookup is described in the next section.
11307 First we explain how LDAP queries are coded.
11308 </para>
11309 </section>
11310 <section id="SECTforldaque">
11311 <title>Format of LDAP queries</title>
11312 <para>
11313 <indexterm role="concept">
11314 <primary>LDAP</primary>
11315 <secondary>query format</secondary>
11316 </indexterm>
11317 An LDAP query takes the form of a URL as defined in RFC 2255. For example, in
11318 the configuration of a <command>redirect</command> router one might have this setting:
11319 </para>
11320 <literallayout class="monospaced">
11321 data = ${lookup ldap \
11322   {ldap:///cn=$local_part,o=University%20of%20Cambridge,\
11323   c=UK?mailbox?base?}}
11324 </literallayout>
11325 <para>
11326 <indexterm role="concept">
11327 <primary>LDAP</primary>
11328 <secondary>with TLS</secondary>
11329 </indexterm>
11330 The URL may begin with <literal>ldap</literal> or <literal>ldaps</literal> if your LDAP library supports
11331 secure (encrypted) LDAP connections. The second of these ensures that an
11332 encrypted TLS connection is used.
11333 </para>
11334 <para>
11335 With sufficiently modern LDAP libraries, Exim supports forcing TLS over regular
11336 LDAP connections, rather than the SSL-on-connect <literal>ldaps</literal>.
11337 See the <option>ldap_start_tls</option> option.
11338 </para>
11339 <para>
11340 Starting with Exim 4.83, the initialization of LDAP with TLS is more tightly
11341 controlled. Every part of the TLS configuration can be configured by settings in
11342 <filename>exim.conf</filename>. Depending on the version of the client libraries installed on
11343 your system, some of the initialization may have required setting options in
11344 <filename>/etc/ldap.conf</filename> or <filename>~/.ldaprc</filename> to get TLS working with self-signed
11345 certificates. This revealed a nuance where the current UID that exim was
11346 running as could affect which config files it read. With Exim 4.83, these
11347 methods become optional, only taking effect if not specifically set in
11348 <filename>exim.conf</filename>.
11349 </para>
11350 </section>
11351 <section id="SECID68">
11352 <title>LDAP quoting</title>
11353 <para>
11354 <indexterm role="concept">
11355 <primary>LDAP</primary>
11356 <secondary>quoting</secondary>
11357 </indexterm>
11358 Two levels of quoting are required in LDAP queries, the first for LDAP itself
11359 and the second because the LDAP query is represented as a URL. Furthermore,
11360 within an LDAP query, two different kinds of quoting are required. For this
11361 reason, there are two different LDAP-specific quoting operators.
11362 </para>
11363 <para>
11364 The <option>quote_ldap</option> operator is designed for use on strings that are part of
11365 filter specifications. Conceptually, it first does the following conversions on
11366 the string:
11367 </para>
11368 <literallayout class="monospaced">
11369 *   =&gt;   \2A
11370 (   =&gt;   \28
11371 )   =&gt;   \29
11372 \   =&gt;   \5C
11373 </literallayout>
11374 <para>
11375 in accordance with RFC 2254. The resulting string is then quoted according
11376 to the rules for URLs, that is, all non-alphanumeric characters except
11377 </para>
11378 <literallayout class="monospaced">
11379 ! $ ' - . _ ( ) * +
11380 </literallayout>
11381 <para>
11382 are converted to their hex values, preceded by a percent sign. For example:
11383 </para>
11384 <literallayout class="monospaced">
11385 ${quote_ldap: a(bc)*, a&lt;yz&gt;; }
11386 </literallayout>
11387 <para>
11388 yields
11389 </para>
11390 <literallayout class="monospaced">
11391 %20a%5C28bc%5C29%5C2A%2C%20a%3Cyz%3E%3B%20
11392 </literallayout>
11393 <para>
11394 Removing the URL quoting, this is (with a leading and a trailing space):
11395 </para>
11396 <literallayout class="monospaced">
11397 a\28bc\29\2A, a&lt;yz&gt;;
11398 </literallayout>
11399 <para>
11400 The <option>quote_ldap_dn</option> operator is designed for use on strings that are part of
11401 base DN specifications in queries. Conceptually, it first converts the string
11402 by inserting a backslash in front of any of the following characters:
11403 </para>
11404 <literallayout class="monospaced">
11405 , + " \ &lt; &gt; ;
11406 </literallayout>
11407 <para>
11408 It also inserts a backslash before any leading spaces or # characters, and
11409 before any trailing spaces. (These rules are in RFC 2253.) The resulting string
11410 is then quoted according to the rules for URLs. For example:
11411 </para>
11412 <literallayout class="monospaced">
11413 ${quote_ldap_dn: a(bc)*, a&lt;yz&gt;; }
11414 </literallayout>
11415 <para>
11416 yields
11417 </para>
11418 <literallayout class="monospaced">
11419 %5C%20a(bc)*%5C%2C%20a%5C%3Cyz%5C%3E%5C%3B%5C%20
11420 </literallayout>
11421 <para>
11422 Removing the URL quoting, this is (with a trailing space):
11423 </para>
11424 <literallayout class="monospaced">
11425 \ a(bc)*\, a\&lt;yz\&gt;\;\
11426 </literallayout>
11427 <para>
11428 There are some further comments about quoting in the section on LDAP
11429 authentication below.
11430 </para>
11431 </section>
11432 <section id="SECID69">
11433 <title>LDAP connections</title>
11434 <para>
11435 <indexterm role="concept">
11436 <primary>LDAP</primary>
11437 <secondary>connections</secondary>
11438 </indexterm>
11439 The connection to an LDAP server may either be over TCP/IP, or, when OpenLDAP
11440 is in use, via a Unix domain socket. The example given above does not specify
11441 an LDAP server. A server that is reached by TCP/IP can be specified in a query
11442 by starting it with
11443 </para>
11444 <literallayout class="monospaced">
11445 ldap://&lt;hostname&gt;:&lt;port&gt;/...
11446 </literallayout>
11447 <para>
11448 If the port (and preceding colon) are omitted, the standard LDAP port (389) is
11449 used. When no server is specified in a query, a list of default servers is
11450 taken from the <option>ldap_default_servers</option> configuration option. This supplies a
11451 colon-separated list of servers which are tried in turn until one successfully
11452 handles a query, or there is a serious error. Successful handling either
11453 returns the requested data, or indicates that it does not exist. Serious errors
11454 are syntactical, or multiple values when only a single value is expected.
11455 Errors which cause the next server to be tried are connection failures, bind
11456 failures, and timeouts.
11457 </para>
11458 <para>
11459 For each server name in the list, a port number can be given. The standard way
11460 of specifying a host and port is to use a colon separator (RFC 1738). Because
11461 <option>ldap_default_servers</option> is a colon-separated list, such colons have to be
11462 doubled. For example
11463 </para>
11464 <literallayout class="monospaced">
11465 ldap_default_servers = ldap1.example.com::145:ldap2.example.com
11466 </literallayout>
11467 <para>
11468 If <option>ldap_default_servers</option> is unset, a URL with no server name is passed
11469 to the LDAP library with no server name, and the library&#x2019;s default (normally
11470 the local host) is used.
11471 </para>
11472 <para>
11473 If you are using the OpenLDAP library, you can connect to an LDAP server using
11474 a Unix domain socket instead of a TCP/IP connection. This is specified by using
11475 <literal>ldapi</literal> instead of <literal>ldap</literal> in LDAP queries. What follows here applies only
11476 to OpenLDAP. If Exim is compiled with a different LDAP library, this feature is
11477 not available.
11478 </para>
11479 <para>
11480 For this type of connection, instead of a host name for the server, a pathname
11481 for the socket is required, and the port number is not relevant. The pathname
11482 can be specified either as an item in <option>ldap_default_servers</option>, or inline in
11483 the query. In the former case, you can have settings such as
11484 </para>
11485 <literallayout class="monospaced">
11486 ldap_default_servers = /tmp/ldap.sock : backup.ldap.your.domain
11487 </literallayout>
11488 <para>
11489 When the pathname is given in the query, you have to escape the slashes as
11490 <literal>%2F</literal> to fit in with the LDAP URL syntax. For example:
11491 </para>
11492 <literallayout class="monospaced">
11493 ${lookup ldap {ldapi://%2Ftmp%2Fldap.sock/o=...
11494 </literallayout>
11495 <para>
11496 When Exim processes an LDAP lookup and finds that the <quote>hostname</quote> is really
11497 a pathname, it uses the Unix domain socket code, even if the query actually
11498 specifies <literal>ldap</literal> or <literal>ldaps</literal>. In particular, no encryption is used for a
11499 socket connection. This behaviour means that you can use a setting of
11500 <option>ldap_default_servers</option> such as in the example above with traditional <literal>ldap</literal>
11501 or <literal>ldaps</literal> queries, and it will work. First, Exim tries a connection via
11502 the Unix domain socket; if that fails, it tries a TCP/IP connection to the
11503 backup host.
11504 </para>
11505 <para>
11506 If an explicit <literal>ldapi</literal> type is given in a query when a host name is
11507 specified, an error is diagnosed. However, if there are more items in
11508 <option>ldap_default_servers</option>, they are tried. In other words:
11509 </para>
11510 <itemizedlist>
11511 <listitem>
11512 <para>
11513 Using a pathname with <literal>ldap</literal> or <literal>ldaps</literal> forces the use of the Unix domain
11514 interface.
11515 </para>
11516 </listitem>
11517 <listitem>
11518 <para>
11519 Using <literal>ldapi</literal> with a host name causes an error.
11520 </para>
11521 </listitem>
11522 </itemizedlist>
11523 <para>
11524 Using <literal>ldapi</literal> with no host or path in the query, and no setting of
11525 <option>ldap_default_servers</option>, does whatever the library does by default.
11526 </para>
11527 </section>
11528 <section id="SECID70">
11529 <title>LDAP authentication and control information</title>
11530 <para>
11531 <indexterm role="concept">
11532 <primary>LDAP</primary>
11533 <secondary>authentication</secondary>
11534 </indexterm>
11535 The LDAP URL syntax provides no way of passing authentication and other control
11536 information to the server. To make this possible, the URL in an LDAP query may
11537 be preceded by any number of &lt;<emphasis>name</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt; settings, separated by
11538 spaces. If a value contains spaces it must be enclosed in double quotes, and
11539 when double quotes are used, backslash is interpreted in the usual way inside
11540 them. The following names are recognized:
11541 </para>
11542 <literallayout>
11543 <literal>DEREFERENCE</literal>  set the dereferencing parameter
11544 <literal>NETTIME    </literal>  set a timeout for a network operation
11545 <literal>USER       </literal>  set the DN, for authenticating the LDAP bind
11546 <literal>PASS       </literal>  set the password, likewise
11547 <literal>REFERRALS  </literal>  set the referrals parameter
11548 <literal>SERVERS    </literal>  set alternate server list for this query only
11549 <literal>SIZE       </literal>  set the limit for the number of entries returned
11550 <literal>TIME       </literal>  set the maximum waiting time for a query
11551 </literallayout>
11552 <para>
11553 The value of the DEREFERENCE parameter must be one of the words <quote>never</quote>,
11554 <quote>searching</quote>, <quote>finding</quote>, or <quote>always</quote>. The value of the REFERRALS parameter
11555 must be <quote>follow</quote> (the default) or <quote>nofollow</quote>. The latter stops the LDAP
11556 library from trying to follow referrals issued by the LDAP server.
11557 </para>
11558 <para>
11559 <indexterm role="concept">
11560 <primary>LDAP</primary>
11561 <secondary>timeout</secondary>
11562 </indexterm>
11563 <indexterm role="concept">
11564 <primary>timeout</primary>
11565 <secondary>LDAP lookup</secondary>
11566 </indexterm>
11567 The name CONNECT is an obsolete name for NETTIME, retained for
11568 backwards compatibility. This timeout (specified as a number of seconds) is
11569 enforced from the client end for operations that can be carried out over a
11570 network. Specifically, it applies to network connections and calls to the
11571 <emphasis>ldap_result()</emphasis> function. If the value is greater than zero, it is used if
11572 LDAP_OPT_NETWORK_TIMEOUT is defined in the LDAP headers (OpenLDAP), or
11573 if LDAP_X_OPT_CONNECT_TIMEOUT is defined in the LDAP headers (Netscape
11574 SDK 4.1). A value of zero forces an explicit setting of <quote>no timeout</quote> for
11575 Netscape SDK; for OpenLDAP no action is taken.
11576 </para>
11577 <para>
11578 The TIME parameter (also a number of seconds) is passed to the server to
11579 set a server-side limit on the time taken to complete a search.
11580 </para>
11581 <para>
11582 The SERVERS parameter allows you to specify an alternate list of ldap servers
11583 to use for an individual lookup.  The global <option>ldap_default_servers</option> option provides a
11584 default list of ldap servers, and a single lookup can specify a single ldap
11585 server to use.  But when you need to do a lookup with a list of servers that is
11586 different than the default list (maybe different order, maybe a completely
11587 different set of servers), the SERVERS parameter allows you to specify this
11588 alternate list (colon-separated).
11589 </para>
11590 <para>
11591 Here is an example of an LDAP query in an Exim lookup that uses some of these
11592 values. This is a single line, folded to fit on the page:
11593 </para>
11594 <literallayout class="monospaced">
11595 ${lookup ldap
11596   {user="cn=manager,o=University of Cambridge,c=UK" pass=secret
11597   ldap:///o=University%20of%20Cambridge,c=UK?sn?sub?(cn=foo)}
11598   {$value}fail}
11599 </literallayout>
11600 <para>
11601 The encoding of spaces as <literal>%20</literal> is a URL thing which should not be done for
11602 any of the auxiliary data. Exim configuration settings that include lookups
11603 which contain password information should be preceded by <quote>hide</quote> to prevent
11604 non-admin users from using the <option>-bP</option> option to see their values.
11605 </para>
11606 <para>
11607 The auxiliary data items may be given in any order. The default is no
11608 connection timeout (the system timeout is used), no user or password, no limit
11609 on the number of entries returned, and no time limit on queries.
11610 </para>
11611 <para>
11612 When a DN is quoted in the USER= setting for LDAP authentication, Exim
11613 removes any URL quoting that it may contain before passing it LDAP. Apparently
11614 some libraries do this for themselves, but some do not. Removing the URL
11615 quoting has two advantages:
11616 </para>
11617 <itemizedlist>
11618 <listitem>
11619 <para>
11620 It makes it possible to use the same <option>quote_ldap_dn</option> expansion for USER=
11621 DNs as with DNs inside actual queries.
11622 </para>
11623 </listitem>
11624 <listitem>
11625 <para>
11626 It permits spaces inside USER= DNs.
11627 </para>
11628 </listitem>
11629 </itemizedlist>
11630 <para>
11631 For example, a setting such as
11632 </para>
11633 <literallayout class="monospaced">
11634 USER=cn=${quote_ldap_dn:$1}
11635 </literallayout>
11636 <para>
11637 should work even if <varname>$1</varname> contains spaces.
11638 </para>
11639 <para>
11640 Expanded data for the PASS= value should be quoted using the <option>quote</option>
11641 expansion operator, rather than the LDAP quote operators. The only reason this
11642 field needs quoting is to ensure that it conforms to the Exim syntax, which
11643 does not allow unquoted spaces. For example:
11644 </para>
11645 <literallayout class="monospaced">
11646 PASS=${quote:$3}
11647 </literallayout>
11648 <para>
11649 The LDAP authentication mechanism can be used to check passwords as part of
11650 SMTP authentication. See the <option>ldapauth</option> expansion string condition in chapter
11651 <xref linkend="CHAPexpand"/>.
11652 </para>
11653 </section>
11654 <section id="SECID71">
11655 <title>Format of data returned by LDAP</title>
11656 <para>
11657 <indexterm role="concept">
11658 <primary>LDAP</primary>
11659 <secondary>returned data formats</secondary>
11660 </indexterm>
11661 The <command>ldapdn</command> lookup type returns the Distinguished Name from a single entry
11662 as a sequence of values, for example
11663 </para>
11664 <literallayout class="monospaced">
11665 cn=manager,o=University of Cambridge,c=UK
11666 </literallayout>
11667 <para>
11668 The <command>ldap</command> lookup type generates an error if more than one entry matches the
11669 search filter, whereas <command>ldapm</command> permits this case, and inserts a newline in
11670 the result between the data from different entries. It is possible for multiple
11671 values to be returned for both <command>ldap</command> and <command>ldapm</command>, but in the former case
11672 you know that whatever values are returned all came from a single entry in the
11673 directory.
11674 </para>
11675 <para>
11676 In the common case where you specify a single attribute in your LDAP query, the
11677 result is not quoted, and does not contain the attribute name. If the attribute
11678 has multiple values, they are separated by commas. Any comma that is
11679 part of an attribute&#x2019;s value is doubled.
11680 </para>
11681 <para>
11682 If you specify multiple attributes, the result contains space-separated, quoted
11683 strings, each preceded by the attribute name and an equals sign. Within the
11684 quotes, the quote character, backslash, and newline are escaped with
11685 backslashes, and commas are used to separate multiple values for the attribute.
11686 Any commas in attribute values are doubled
11687 (permitting treatment of the values as a comma-separated list).
11688 Apart from the escaping, the string within quotes takes the same form as the
11689 output when a single attribute is requested. Specifying no attributes is the
11690 same as specifying all of an entry&#x2019;s attributes.
11691 </para>
11692 <para>
11693 Here are some examples of the output format. The first line of each pair is an
11694 LDAP query, and the second is the data that is returned. The attribute called
11695 <option>attr1</option> has two values, one of them with an embedded comma, whereas
11696 <option>attr2</option> has only one value. Both attributes are derived from <option>attr</option>
11697 (they have SUP <option>attr</option> in their schema definitions).
11698 </para>
11699 <literallayout class="monospaced">
11700 ldap:///o=base?attr1?sub?(uid=fred)
11701 value1.1,value1,,2
11702
11703 ldap:///o=base?attr2?sub?(uid=fred)
11704 value two
11705
11706 ldap:///o=base?attr?sub?(uid=fred)
11707 value1.1,value1,,2,value two
11708
11709 ldap:///o=base?attr1,attr2?sub?(uid=fred)
11710 attr1="value1.1,value1,,2" attr2="value two"
11711
11712 ldap:///o=base??sub?(uid=fred)
11713 objectClass="top" attr1="value1.1,value1,,2" attr2="value two"
11714 </literallayout>
11715 <para>
11716 You can
11717 make use of Exim&#x2019;s <option>-be</option> option to run expansion tests and thereby check the
11718 results of LDAP lookups.
11719 The <option>extract</option> operator in string expansions can be used to pick out
11720 individual fields from data that consists of <emphasis>key</emphasis>=<emphasis>value</emphasis> pairs.
11721 The <option>listextract</option> operator should be used to pick out individual values
11722 of attributes, even when only a single value is expected.
11723 The doubling of embedded commas allows you to use the returned data as a
11724 comma separated list (using the "&lt;," syntax for changing the input list separator).
11725 </para>
11726 </section>
11727 <section id="SECTnisplus">
11728 <title>More about NIS+</title>
11729 <para>
11730 <indexterm role="concept">
11731 <primary>NIS+ lookup type</primary>
11732 </indexterm>
11733 <indexterm role="concept">
11734 <primary>lookup</primary>
11735 <secondary>NIS+</secondary>
11736 </indexterm>
11737 NIS+ queries consist of a NIS+ <emphasis>indexed name</emphasis> followed by an optional colon
11738 and field name. If this is given, the result of a successful query is the
11739 contents of the named field; otherwise the result consists of a concatenation
11740 of <emphasis>field-name=field-value</emphasis> pairs, separated by spaces. Empty values and
11741 values containing spaces are quoted. For example, the query
11742 </para>
11743 <literallayout class="monospaced">
11744 [name=mg1456],passwd.org_dir
11745 </literallayout>
11746 <para>
11747 might return the string
11748 </para>
11749 <literallayout class="monospaced">
11750 name=mg1456 passwd="" uid=999 gid=999 gcos="Martin Guerre"
11751 home=/home/mg1456 shell=/bin/bash shadow=""
11752 </literallayout>
11753 <para>
11754 (split over two lines here to fit on the page), whereas
11755 </para>
11756 <literallayout class="monospaced">
11757 [name=mg1456],passwd.org_dir:gcos
11758 </literallayout>
11759 <para>
11760 would just return
11761 </para>
11762 <literallayout class="monospaced">
11763 Martin Guerre
11764 </literallayout>
11765 <para>
11766 with no quotes. A NIS+ lookup fails if NIS+ returns more than one table entry
11767 for the given indexed key. The effect of the <option>quote_nisplus</option> expansion
11768 operator is to double any quote characters within the text.
11769 </para>
11770 </section>
11771 <section id="SECTsql">
11772 <title>SQL lookups</title>
11773 <para>
11774 <indexterm role="concept">
11775 <primary>SQL lookup types</primary>
11776 </indexterm>
11777 <indexterm role="concept">
11778 <primary>MySQL</primary>
11779 <secondary>lookup type</secondary>
11780 </indexterm>
11781 <indexterm role="concept">
11782 <primary>PostgreSQL lookup type</primary>
11783 </indexterm>
11784 <indexterm role="concept">
11785 <primary>lookup</primary>
11786 <secondary>MySQL</secondary>
11787 </indexterm>
11788 <indexterm role="concept">
11789 <primary>lookup</primary>
11790 <secondary>PostgreSQL</secondary>
11791 </indexterm>
11792 <indexterm role="concept">
11793 <primary>Oracle</primary>
11794 <secondary>lookup type</secondary>
11795 </indexterm>
11796 <indexterm role="concept">
11797 <primary>lookup</primary>
11798 <secondary>Oracle</secondary>
11799 </indexterm>
11800 <indexterm role="concept">
11801 <primary>InterBase lookup type</primary>
11802 </indexterm>
11803 <indexterm role="concept">
11804 <primary>lookup</primary>
11805 <secondary>InterBase</secondary>
11806 </indexterm>
11807 <indexterm role="concept">
11808 <primary>Redis lookup type</primary>
11809 </indexterm>
11810 <indexterm role="concept">
11811 <primary>lookup</primary>
11812 <secondary>Redis</secondary>
11813 </indexterm>
11814 Exim can support lookups in InterBase, MySQL, Oracle, PostgreSQL, Redis,
11815 and SQLite
11816 databases. Queries for these databases contain SQL statements, so an example
11817 might be
11818 </para>
11819 <literallayout class="monospaced">
11820 ${lookup mysql{select mailbox from users where id='userx'}\
11821   {$value}fail}
11822 </literallayout>
11823 <para>
11824 If the result of the query contains more than one field, the data for each
11825 field in the row is returned, preceded by its name, so the result of
11826 </para>
11827 <literallayout class="monospaced">
11828 ${lookup pgsql{select home,name from users where id='userx'}\
11829   {$value}}
11830 </literallayout>
11831 <para>
11832 might be
11833 </para>
11834 <literallayout class="monospaced">
11835 home=/home/userx name="Mister X"
11836 </literallayout>
11837 <para>
11838 Empty values and values containing spaces are double quoted, with embedded
11839 quotes escaped by a backslash. If the result of the query contains just one
11840 field, the value is passed back verbatim, without a field name, for example:
11841 </para>
11842 <literallayout class="monospaced">
11843 Mister X
11844 </literallayout>
11845 <para>
11846 If the result of the query yields more than one row, it is all concatenated,
11847 with a newline between the data for each row.
11848 </para>
11849 </section>
11850 <section id="SECID72">
11851 <title>More about MySQL, PostgreSQL, Oracle, InterBase, and Redis</title>
11852 <para>
11853 <indexterm role="concept">
11854 <primary>MySQL</primary>
11855 <secondary>lookup type</secondary>
11856 </indexterm>
11857 <indexterm role="concept">
11858 <primary>PostgreSQL lookup type</primary>
11859 </indexterm>
11860 <indexterm role="concept">
11861 <primary>lookup</primary>
11862 <secondary>MySQL</secondary>
11863 </indexterm>
11864 <indexterm role="concept">
11865 <primary>lookup</primary>
11866 <secondary>PostgreSQL</secondary>
11867 </indexterm>
11868 <indexterm role="concept">
11869 <primary>Oracle</primary>
11870 <secondary>lookup type</secondary>
11871 </indexterm>
11872 <indexterm role="concept">
11873 <primary>lookup</primary>
11874 <secondary>Oracle</secondary>
11875 </indexterm>
11876 <indexterm role="concept">
11877 <primary>InterBase lookup type</primary>
11878 </indexterm>
11879 <indexterm role="concept">
11880 <primary>lookup</primary>
11881 <secondary>InterBase</secondary>
11882 </indexterm>
11883 <indexterm role="concept">
11884 <primary>Redis lookup type</primary>
11885 </indexterm>
11886 <indexterm role="concept">
11887 <primary>lookup</primary>
11888 <secondary>Redis</secondary>
11889 </indexterm>
11890 If any MySQL, PostgreSQL, Oracle, InterBase or Redis lookups are used, the
11891 <option>mysql_servers</option>, <option>pgsql_servers</option>, <option>oracle_servers</option>, <option>ibase_servers</option>,
11892 or <option>redis_servers</option>
11893 option (as appropriate) must be set to a colon-separated list of server
11894 information.
11895 (For MySQL and PostgreSQL, the global option need not be set if all
11896 queries contain their own server information &ndash; see section
11897 <xref linkend="SECTspeserque"/>.)
11898 For all but Redis
11899 each item in the list is a slash-separated list of four
11900 items: host name, database name, user name, and password. In the case of
11901 Oracle, the host name field is used for the <quote>service name</quote>, and the database
11902 name field is not used and should be empty. For example:
11903 </para>
11904 <literallayout class="monospaced">
11905 hide oracle_servers = oracle.plc.example//userx/abcdwxyz
11906 </literallayout>
11907 <para>
11908 Because password data is sensitive, you should always precede the setting with
11909 <quote>hide</quote>, to prevent non-admin users from obtaining the setting via the <option>-bP</option>
11910 option. Here is an example where two MySQL servers are listed:
11911 </para>
11912 <literallayout class="monospaced">
11913 hide mysql_servers = localhost/users/root/secret:\
11914                      otherhost/users/root/othersecret
11915 </literallayout>
11916 <para>
11917 For MySQL and PostgreSQL, a host may be specified as &lt;<emphasis>name</emphasis>&gt;:&lt;<emphasis>port</emphasis>&gt; but
11918 because this is a colon-separated list, the colon has to be doubled. For each
11919 query, these parameter groups are tried in order until a connection is made and
11920 a query is successfully processed. The result of a query may be that no data is
11921 found, but that is still a successful query. In other words, the list of
11922 servers provides a backup facility, not a list of different places to look.
11923 </para>
11924 <para>
11925 For Redis the global option need not be specified if all queries contain their
11926 own server information &ndash; see section <xref linkend="SECTspeserque"/>.
11927 If specified, the option must be set to a colon-separated list of server
11928 information.
11929 Each item in the list is a slash-separated list of three items:
11930 host, database number, and password.
11931 </para>
11932 <orderedlist numeration="arabic">
11933 <listitem>
11934 <para>
11935 The host is required and may be either an IPv4 address and optional
11936 port number (separated by a colon, which needs doubling due to the
11937 higher-level list), or a Unix socket pathname enclosed in parentheses
11938 </para>
11939 </listitem>
11940 <listitem>
11941 <para>
11942 The database number is optional; if present that number is selected in the backend
11943 </para>
11944 </listitem>
11945 <listitem>
11946 <para>
11947 The password is optional; if present it is used to authenticate to the backend
11948 </para>
11949 </listitem>
11950 </orderedlist>
11951 <para>
11952 The <option>quote_mysql</option>, <option>quote_pgsql</option>, and <option>quote_oracle</option> expansion operators
11953 convert newline, tab, carriage return, and backspace to \n, \t, \r, and \b
11954 respectively, and the characters single-quote, double-quote, and backslash
11955 itself are escaped with backslashes.
11956 </para>
11957 <para>
11958 The <option>quote_redis</option> expansion operator
11959 escapes whitespace and backslash characters with a backslash.
11960 </para>
11961 </section>
11962 <section id="SECTspeserque">
11963 <title>Specifying the server in the query</title>
11964 <para>
11965 For MySQL, PostgreSQL and Redis lookups (but not currently for Oracle and InterBase),
11966 it is possible to specify a list of servers with an individual query. This is
11967 done by starting the query with
11968 </para>
11969 <literallayout>
11970 <literal>servers=</literal><emphasis>server1:server2:server3:...</emphasis><literal>;</literal>
11971 </literallayout>
11972 <para>
11973 Each item in the list may take one of two forms:
11974 </para>
11975 <orderedlist numeration="arabic">
11976 <listitem>
11977 <para>
11978 If it contains no slashes it is assumed to be just a host name. The appropriate
11979 global option (<option>mysql_servers</option> or <option>pgsql_servers</option>) is searched for a host
11980 of the same name, and the remaining parameters (database, user, password) are
11981 taken from there.
11982 </para>
11983 </listitem>
11984 <listitem>
11985 <para>
11986 If it contains any slashes, it is taken as a complete parameter set.
11987 </para>
11988 </listitem>
11989 </orderedlist>
11990 <para>
11991 The list of servers is used in exactly the same way as the global list.
11992 Once a connection to a server has happened and a query has been
11993 successfully executed, processing of the lookup ceases.
11994 </para>
11995 <para>
11996 This feature is intended for use in master/slave situations where updates
11997 are occurring and you want to update the master rather than a slave. If the
11998 master is in the list as a backup for reading, you might have a global setting
11999 like this:
12000 </para>
12001 <literallayout class="monospaced">
12002 mysql_servers = slave1/db/name/pw:\
12003                 slave2/db/name/pw:\
12004                 master/db/name/pw
12005 </literallayout>
12006 <para>
12007 In an updating lookup, you could then write:
12008 </para>
12009 <literallayout class="monospaced">
12010 ${lookup mysql{servers=master; UPDATE ...} }
12011 </literallayout>
12012 <para>
12013 That query would then be sent only to the master server. If, on the other hand,
12014 the master is not to be used for reading, and so is not present in the global
12015 option, you can still update it by a query of this form:
12016 </para>
12017 <literallayout class="monospaced">
12018 ${lookup pgsql{servers=master/db/name/pw; UPDATE ...} }
12019 </literallayout>
12020 </section>
12021 <section id="SECID73">
12022 <title>Special MySQL features</title>
12023 <para>
12024 For MySQL, an empty host name or the use of <quote>localhost</quote> in <option>mysql_servers</option>
12025 causes a connection to the server on the local host by means of a Unix domain
12026 socket. An alternate socket can be specified in parentheses.
12027 An option group name for MySQL option files can be specified in square brackets;
12028 the default value is <quote>exim</quote>.
12029 The full syntax of each item in <option>mysql_servers</option> is:
12030 </para>
12031 <literallayout>
12032 &lt;<emphasis>hostname</emphasis>&gt;::&lt;<emphasis>port</emphasis>&gt;(&lt;<emphasis>socket name</emphasis>&gt;)[&lt;<emphasis>option group</emphasis>&gt;]/&lt;<emphasis>database</emphasis>&gt;/&lt;<emphasis>user</emphasis>&gt;/&lt;<emphasis>password</emphasis>&gt;
12033 </literallayout>
12034 <para>
12035 Any of the four sub-parts of the first field can be omitted. For normal use on
12036 the local host it can be left blank or set to just <quote>localhost</quote>.
12037 </para>
12038 <para>
12039 No database need be supplied &ndash; but if it is absent here, it must be given in
12040 the queries.
12041 </para>
12042 <para>
12043 If a MySQL query is issued that does not request any data (an insert, update,
12044 or delete command), the result of the lookup is the number of rows affected.
12045 </para>
12046 <para>
12047 <emphasis role="bold">Warning</emphasis>: This can be misleading. If an update does not actually change
12048 anything (for example, setting a field to the value it already has), the result
12049 is zero because no rows are affected.
12050 </para>
12051 </section>
12052 <section id="SECID74">
12053 <title>Special PostgreSQL features</title>
12054 <para>
12055 PostgreSQL lookups can also use Unix domain socket connections to the database.
12056 This is usually faster and costs less CPU time than a TCP/IP connection.
12057 However it can be used only if the mail server runs on the same machine as the
12058 database server. A configuration line for PostgreSQL via Unix domain sockets
12059 looks like this:
12060 </para>
12061 <literallayout class="monospaced">
12062 hide pgsql_servers = (/tmp/.s.PGSQL.5432)/db/user/password : ...
12063 </literallayout>
12064 <para>
12065 In other words, instead of supplying a host name, a path to the socket is
12066 given. The path name is enclosed in parentheses so that its slashes aren&#x2019;t
12067 visually confused with the delimiters for the other server parameters.
12068 </para>
12069 <para>
12070 If a PostgreSQL query is issued that does not request any data (an insert,
12071 update, or delete command), the result of the lookup is the number of rows
12072 affected.
12073 </para>
12074 </section>
12075 <section id="SECTsqlite">
12076 <title>More about SQLite</title>
12077 <para>
12078 <indexterm role="concept">
12079 <primary>lookup</primary>
12080 <secondary>SQLite</secondary>
12081 </indexterm>
12082 <indexterm role="concept">
12083 <primary>sqlite lookup type</primary>
12084 </indexterm>
12085 SQLite is different to the other SQL lookups because a filename is required in
12086 addition to the SQL query. An SQLite database is a single file, and there is no
12087 daemon as in the other SQL databases. The interface to Exim requires the name
12088 of the file, as an absolute path, to be given at the start of the query. It is
12089 separated from the query by white space. This means that the path name cannot
12090 contain white space. Here is a lookup expansion example:
12091 </para>
12092 <literallayout class="monospaced">
12093 ${lookup sqlite {/some/thing/sqlitedb \
12094   select name from aliases where id='userx';}}
12095 </literallayout>
12096 <para>
12097 In a list, the syntax is similar. For example:
12098 </para>
12099 <literallayout class="monospaced">
12100 domainlist relay_to_domains = sqlite;/some/thing/sqlitedb \
12101    select * from relays where ip='$sender_host_address';
12102 </literallayout>
12103 <para>
12104 The only character affected by the <option>quote_sqlite</option> operator is a single
12105 quote, which it doubles.
12106 </para>
12107 <para>
12108 <indexterm role="concept">
12109 <primary>timeout</primary>
12110 <secondary>SQLite</secondary>
12111 </indexterm>
12112 <indexterm role="concept">
12113 <primary>sqlite</primary>
12114 <secondary>lookup timeout</secondary>
12115 </indexterm>
12116 The SQLite library handles multiple simultaneous accesses to the database
12117 internally. Multiple readers are permitted, but only one process can
12118 update at once. Attempts to access the database while it is being updated
12119 are rejected after a timeout period, during which the SQLite library
12120 waits for the lock to be released. In Exim, the default timeout is set
12121 to 5 seconds, but it can be changed by means of the <option>sqlite_lock_timeout</option>
12122 option.
12123 </para>
12124 </section>
12125 <section id="SECTredis">
12126 <title>More about Redis</title>
12127 <para>
12128 <indexterm role="concept">
12129 <primary>lookup</primary>
12130 <secondary>Redis</secondary>
12131 </indexterm>
12132 <indexterm role="concept">
12133 <primary>redis lookup type</primary>
12134 </indexterm>
12135 Redis is a non-SQL database. Commands are simple get and set.
12136 Examples:
12137 </para>
12138 <literallayout class="monospaced">
12139 ${lookup redis{set keyname ${quote_redis:objvalue plus}}}
12140 ${lookup redis{get keyname}}
12141 </literallayout>
12142 <para>
12143 As of release 4.91, "lightweight" support for Redis Cluster is available.
12144 Requires <option>redis_servers</option> list to contain all the servers in the cluster, all
12145 of which must be reachable from the running exim instance. If the cluster has
12146 master/slave replication, the list must contain all the master and slave
12147 servers.
12148 </para>
12149 <para>
12150 When the Redis Cluster returns a "MOVED" response to a query, Exim does not
12151 immediately follow the redirection but treats the response as a DEFER, moving on
12152 to the next server in the <option>redis_servers</option> list until the correct server is
12153 reached.
12154 </para>
12155 <para>
12156 <indexterm role="concept" startref="IIDfidalo1" class="endofrange"/>
12157 <indexterm role="concept" startref="IIDfidalo2" class="endofrange"/>
12158 </para>
12159 </section>
12160 </chapter>
12161
12162 <chapter id="CHAPdomhosaddlists">
12163 <title>Domain, host, address, and local part lists</title>
12164 <titleabbrev>Domain, host, and address lists</titleabbrev>
12165 <para>
12166 <indexterm role="concept" id="IIDdohoadli" class="startofrange">
12167 <primary>lists of domains; hosts; etc.</primary>
12168 </indexterm>
12169 A number of Exim configuration options contain lists of domains, hosts,
12170 email addresses, or local parts. For example, the <option>hold_domains</option> option
12171 contains a list of domains whose delivery is currently suspended. These lists
12172 are also used as data in ACL statements (see chapter <xref linkend="CHAPACL"/>), and as
12173 arguments to expansion conditions such as <option>match_domain</option>.
12174 </para>
12175 <para>
12176 Each item in one of these lists is a pattern to be matched against a domain,
12177 host, email address, or local part, respectively. In the sections below, the
12178 different types of pattern for each case are described, but first we cover some
12179 general facilities that apply to all four kinds of list.
12180 </para>
12181 <para>
12182 Note that other parts of Exim use a <emphasis>string list</emphasis> which does not
12183 support all the complexity available in
12184 domain, host, address and local part lists.
12185 </para>
12186 <section id="SECTlistexpand">
12187 <title>Expansion of lists</title>
12188 <para>
12189 <indexterm role="concept">
12190 <primary>expansion</primary>
12191 <secondary>of lists</secondary>
12192 </indexterm>
12193 Each list is expanded as a single string before it is used.
12194 </para>
12195 <para>
12196 <emphasis>Exception: the router headers_remove option, where list-item
12197 splitting is done before string-expansion.</emphasis>
12198 </para>
12199 <para>
12200 The result of
12201 expansion must be a list, possibly containing empty items, which is split up
12202 into separate items for matching. By default, colon is the separator character,
12203 but this can be varied if necessary. See sections <xref linkend="SECTlistconstruct"/> and
12204 <xref linkend="SECTempitelis"/> for details of the list syntax; the second of these
12205 discusses the way to specify empty list items.
12206 </para>
12207 <para>
12208 If the string expansion is forced to fail, Exim behaves as if the item it is
12209 testing (domain, host, address, or local part) is not in the list. Other
12210 expansion failures cause temporary errors.
12211 </para>
12212 <para>
12213 If an item in a list is a regular expression, backslashes, dollars and possibly
12214 other special characters in the expression must be protected against
12215 misinterpretation by the string expander. The easiest way to do this is to use
12216 the <literal>\N</literal> expansion feature to indicate that the contents of the regular
12217 expression should not be expanded. For example, in an ACL you might have:
12218 </para>
12219 <literallayout class="monospaced">
12220 deny senders = \N^\d{8}\w@.*\.baddomain\.example$\N : \
12221                ${lookup{$domain}lsearch{/badsenders/bydomain}}
12222 </literallayout>
12223 <para>
12224 The first item is a regular expression that is protected from expansion by
12225 <literal>\N</literal>, whereas the second uses the expansion to obtain a list of unwanted
12226 senders based on the receiving domain.
12227 </para>
12228 </section>
12229 <section id="SECID76">
12230 <title>Negated items in lists</title>
12231 <para>
12232 <indexterm role="concept">
12233 <primary>list</primary>
12234 <secondary>negation</secondary>
12235 </indexterm>
12236 <indexterm role="concept">
12237 <primary>negation</primary>
12238 <secondary>in lists</secondary>
12239 </indexterm>
12240 Items in a list may be positive or negative. Negative items are indicated by a
12241 leading exclamation mark, which may be followed by optional white space. A list
12242 defines a set of items (domains, etc). When Exim processes one of these lists,
12243 it is trying to find out whether a domain, host, address, or local part
12244 (respectively) is in the set that is defined by the list. It works like this:
12245 </para>
12246 <para>
12247 The list is scanned from left to right. If a positive item is matched, the
12248 subject that is being checked is in the set; if a negative item is matched, the
12249 subject is not in the set. If the end of the list is reached without the
12250 subject having matched any of the patterns, it is in the set if the last item
12251 was a negative one, but not if it was a positive one. For example, the list in
12252 </para>
12253 <literallayout class="monospaced">
12254 domainlist relay_to_domains = !a.b.c : *.b.c
12255 </literallayout>
12256 <para>
12257 matches any domain ending in <emphasis>.b.c</emphasis> except for <emphasis>a.b.c</emphasis>. Domains that match
12258 neither <emphasis>a.b.c</emphasis> nor <emphasis>*.b.c</emphasis> do not match, because the last item in the
12259 list is positive. However, if the setting were
12260 </para>
12261 <literallayout class="monospaced">
12262 domainlist relay_to_domains = !a.b.c
12263 </literallayout>
12264 <para>
12265 then all domains other than <emphasis>a.b.c</emphasis> would match because the last item in the
12266 list is negative. In other words, a list that ends with a negative item behaves
12267 as if it had an extra item <literal>:*</literal> on the end.
12268 </para>
12269 <para>
12270 Another way of thinking about positive and negative items in lists is to read
12271 the connector as <quote>or</quote> after a positive item and as <quote>and</quote> after a negative
12272 item.
12273 </para>
12274 </section>
12275 <section id="SECTfilnamlis">
12276 <title>File names in lists</title>
12277 <para>
12278 <indexterm role="concept">
12279 <primary>list</primary>
12280 <secondary>filename in</secondary>
12281 </indexterm>
12282 If an item in a domain, host, address, or local part list is an absolute
12283 filename (beginning with a slash character), each line of the file is read and
12284 processed as if it were an independent item in the list, except that further
12285 filenames are not allowed,
12286 and no expansion of the data from the file takes place.
12287 Empty lines in the file are ignored, and the file may also contain comment
12288 lines:
12289 </para>
12290 <itemizedlist>
12291 <listitem>
12292 <para>
12293 For domain and host lists, if a # character appears anywhere in a line of the
12294 file, it and all following characters are ignored.
12295 </para>
12296 </listitem>
12297 <listitem>
12298 <para>
12299 Because local parts may legitimately contain # characters, a comment in an
12300 address list or local part list file is recognized only if # is preceded by
12301 white space or the start of the line. For example:
12302 </para>
12303 <literallayout class="monospaced">
12304 not#comment@x.y.z   # but this is a comment
12305 </literallayout>
12306 </listitem>
12307 </itemizedlist>
12308 <para>
12309 Putting a filename in a list has the same effect as inserting each line of the
12310 file as an item in the list (blank lines and comments excepted). However, there
12311 is one important difference: the file is read each time the list is processed,
12312 so if its contents vary over time, Exim&#x2019;s behaviour changes.
12313 </para>
12314 <para>
12315 If a filename is preceded by an exclamation mark, the sense of any match
12316 within the file is inverted. For example, if
12317 </para>
12318 <literallayout class="monospaced">
12319 hold_domains = !/etc/nohold-domains
12320 </literallayout>
12321 <para>
12322 and the file contains the lines
12323 </para>
12324 <literallayout class="monospaced">
12325 !a.b.c
12326 *.b.c
12327 </literallayout>
12328 <para>
12329 then <emphasis>a.b.c</emphasis> is in the set of domains defined by <option>hold_domains</option>, whereas
12330 any domain matching <literal>*.b.c</literal> is not.
12331 </para>
12332 </section>
12333 <section id="SECID77">
12334 <title>An lsearch file is not an out-of-line list</title>
12335 <para>
12336 As will be described in the sections that follow, lookups can be used in lists
12337 to provide indexed methods of checking list membership. There has been some
12338 confusion about the way <command>lsearch</command> lookups work in lists. Because
12339 an <command>lsearch</command> file contains plain text and is scanned sequentially, it is
12340 sometimes thought that it is allowed to contain wild cards and other kinds of
12341 non-constant pattern. This is not the case. The keys in an <command>lsearch</command> file are
12342 always fixed strings, just as for any other single-key lookup type.
12343 </para>
12344 <para>
12345 If you want to use a file to contain wild-card patterns that form part of a
12346 list, just give the filename on its own, without a search type, as described
12347 in the previous section. You could also use the <command>wildlsearch</command> or
12348 <command>nwildlsearch</command>, but there is no advantage in doing this.
12349 </para>
12350 </section>
12351 <section id="SECTnamedlists">
12352 <title>Named lists</title>
12353 <para>
12354 <indexterm role="concept">
12355 <primary>named lists</primary>
12356 </indexterm>
12357 <indexterm role="concept">
12358 <primary>list</primary>
12359 <secondary>named</secondary>
12360 </indexterm>
12361 A list of domains, hosts, email addresses, or local parts can be given a name
12362 which is then used to refer to the list elsewhere in the configuration. This is
12363 particularly convenient if the same list is required in several different
12364 places. It also allows lists to be given meaningful names, which can improve
12365 the readability of the configuration. For example, it is conventional to define
12366 a domain list called <emphasis>local_domains</emphasis> for all the domains that are handled
12367 locally on a host, using a configuration line such as
12368 </para>
12369 <literallayout class="monospaced">
12370 domainlist local_domains = localhost:my.dom.example
12371 </literallayout>
12372 <para>
12373 Named lists are referenced by giving their name preceded by a plus sign, so,
12374 for example, a router that is intended to handle local domains would be
12375 configured with the line
12376 </para>
12377 <literallayout class="monospaced">
12378 domains = +local_domains
12379 </literallayout>
12380 <para>
12381 The first router in a configuration is often one that handles all domains
12382 except the local ones, using a configuration with a negated item like this:
12383 </para>
12384 <literallayout class="monospaced">
12385 dnslookup:
12386   driver = dnslookup
12387   domains = ! +local_domains
12388   transport = remote_smtp
12389   no_more
12390 </literallayout>
12391 <para>
12392 The four kinds of named list are created by configuration lines starting with
12393 the words <option>domainlist</option>, <option>hostlist</option>, <option>addresslist</option>, or <option>localpartlist</option>,
12394 respectively. Then there follows the name that you are defining, followed by an
12395 equals sign and the list itself. For example:
12396 </para>
12397 <literallayout class="monospaced">
12398 hostlist    relay_from_hosts = 192.168.23.0/24 : my.friend.example
12399 addresslist bad_senders = cdb;/etc/badsenders
12400 </literallayout>
12401 <para>
12402 A named list may refer to other named lists:
12403 </para>
12404 <literallayout class="monospaced">
12405 domainlist  dom1 = first.example : second.example
12406 domainlist  dom2 = +dom1 : third.example
12407 domainlist  dom3 = fourth.example : +dom2 : fifth.example
12408 </literallayout>
12409 <para>
12410 <emphasis role="bold">Warning</emphasis>: If the last item in a referenced list is a negative one, the
12411 effect may not be what you intended, because the negation does not propagate
12412 out to the higher level. For example, consider:
12413 </para>
12414 <literallayout class="monospaced">
12415 domainlist  dom1 = !a.b
12416 domainlist  dom2 = +dom1 : *.b
12417 </literallayout>
12418 <para>
12419 The second list specifies <quote>either in the <option>dom1</option> list or <emphasis>*.b</emphasis></quote>. The first
12420 list specifies just <quote>not <emphasis>a.b</emphasis></quote>, so the domain <emphasis>x.y</emphasis> matches it. That
12421 means it matches the second list as well. The effect is not the same as
12422 </para>
12423 <literallayout class="monospaced">
12424 domainlist  dom2 = !a.b : *.b
12425 </literallayout>
12426 <para>
12427 where <emphasis>x.y</emphasis> does not match. It&#x2019;s best to avoid negation altogether in
12428 referenced lists if you can.
12429 </para>
12430 <para>
12431 Named lists may have a performance advantage. When Exim is routing an
12432 address or checking an incoming message, it caches the result of tests on named
12433 lists. So, if you have a setting such as
12434 </para>
12435 <literallayout class="monospaced">
12436 domains = +local_domains
12437 </literallayout>
12438 <para>
12439 on several of your routers
12440 or in several ACL statements,
12441 the actual test is done only for the first one. However, the caching works only
12442 if there are no expansions within the list itself or any sublists that it
12443 references. In other words, caching happens only for lists that are known to be
12444 the same each time they are referenced.
12445 </para>
12446 <para>
12447 By default, there may be up to 16 named lists of each type. This limit can be
12448 extended by changing a compile-time variable. The use of domain and host lists
12449 is recommended for concepts such as local domains, relay domains, and relay
12450 hosts. The default configuration is set up like this.
12451 </para>
12452 </section>
12453 <section id="SECID78">
12454 <title>Named lists compared with macros</title>
12455 <para>
12456 <indexterm role="concept">
12457 <primary>list</primary>
12458 <secondary>named compared with macro</secondary>
12459 </indexterm>
12460 <indexterm role="concept">
12461 <primary>macro</primary>
12462 <secondary>compared with named list</secondary>
12463 </indexterm>
12464 At first sight, named lists might seem to be no different from macros in the
12465 configuration file. However, macros are just textual substitutions. If you
12466 write
12467 </para>
12468 <literallayout class="monospaced">
12469 ALIST = host1 : host2
12470 auth_advertise_hosts = !ALIST
12471 </literallayout>
12472 <para>
12473 it probably won&#x2019;t do what you want, because that is exactly the same as
12474 </para>
12475 <literallayout class="monospaced">
12476 auth_advertise_hosts = !host1 : host2
12477 </literallayout>
12478 <para>
12479 Notice that the second host name is not negated. However, if you use a host
12480 list, and write
12481 </para>
12482 <literallayout class="monospaced">
12483 hostlist alist = host1 : host2
12484 auth_advertise_hosts = ! +alist
12485 </literallayout>
12486 <para>
12487 the negation applies to the whole list, and so that is equivalent to
12488 </para>
12489 <literallayout class="monospaced">
12490 auth_advertise_hosts = !host1 : !host2
12491 </literallayout>
12492 </section>
12493 <section id="SECID79">
12494 <title>Named list caching</title>
12495 <para>
12496 <indexterm role="concept">
12497 <primary>list</primary>
12498 <secondary>caching of named</secondary>
12499 </indexterm>
12500 <indexterm role="concept">
12501 <primary>caching</primary>
12502 <secondary>named lists</secondary>
12503 </indexterm>
12504 While processing a message, Exim caches the result of checking a named list if
12505 it is sure that the list is the same each time. In practice, this means that
12506 the cache operates only if the list contains no $ characters, which guarantees
12507 that it will not change when it is expanded. Sometimes, however, you may have
12508 an expanded list that you know will be the same each time within a given
12509 message. For example:
12510 </para>
12511 <literallayout class="monospaced">
12512 domainlist special_domains = \
12513            ${lookup{$sender_host_address}cdb{/some/file}}
12514 </literallayout>
12515 <para>
12516 This provides a list of domains that depends only on the sending host&#x2019;s IP
12517 address. If this domain list is referenced a number of times (for example,
12518 in several ACL lines, or in several routers) the result of the check is not
12519 cached by default, because Exim does not know that it is going to be the
12520 same list each time.
12521 </para>
12522 <para>
12523 By appending <literal>_cache</literal> to <literal>domainlist</literal> you can tell Exim to go ahead and
12524 cache the result anyway. For example:
12525 </para>
12526 <literallayout class="monospaced">
12527 domainlist_cache special_domains = ${lookup{...
12528 </literallayout>
12529 <para>
12530 If you do this, you should be absolutely sure that caching is going to do
12531 the right thing in all cases. When in doubt, leave it out.
12532 </para>
12533 </section>
12534 <section id="SECTdomainlist">
12535 <title>Domain lists</title>
12536 <para>
12537 <indexterm role="concept">
12538 <primary>domain list</primary>
12539 <secondary>patterns for</secondary>
12540 </indexterm>
12541 <indexterm role="concept">
12542 <primary>list</primary>
12543 <secondary>domain list</secondary>
12544 </indexterm>
12545 Domain lists contain patterns that are to be matched against a mail domain.
12546 The following types of item may appear in domain lists:
12547 </para>
12548 <itemizedlist>
12549 <listitem>
12550 <para>
12551 <indexterm role="concept">
12552 <primary>primary host name</primary>
12553 </indexterm>
12554 <indexterm role="concept">
12555 <primary>host name</primary>
12556 <secondary>matched in domain list</secondary>
12557 </indexterm>
12558 <indexterm role="option">
12559 <primary><option>primary_hostname</option></primary>
12560 </indexterm>
12561 <indexterm role="concept">
12562 <primary>domain list</primary>
12563 <secondary>matching primary host name</secondary>
12564 </indexterm>
12565 <indexterm role="concept">
12566 <primary>@ in a domain list</primary>
12567 </indexterm>
12568 If a pattern consists of a single @ character, it matches the local host name,
12569 as set by the <option>primary_hostname</option> option (or defaulted). This makes it
12570 possible to use the same configuration file on several different hosts that
12571 differ only in their names.
12572 </para>
12573 </listitem>
12574 <listitem>
12575 <para>
12576 <indexterm role="concept">
12577 <primary>@[] in a domain list</primary>
12578 </indexterm>
12579 <indexterm role="concept">
12580 <primary>domain list</primary>
12581 <secondary>matching local IP interfaces</secondary>
12582 </indexterm>
12583 <indexterm role="concept">
12584 <primary>domain literal</primary>
12585 </indexterm>
12586 If a pattern consists of the string <literal>@[]</literal> it matches an IP address enclosed
12587 in square brackets (as in an email address that contains a domain literal), but
12588 only if that IP address is recognized as local for email routing purposes. The
12589 <option>local_interfaces</option> and <option>extra_local_interfaces</option> options can be used to
12590 control which of a host&#x2019;s several IP addresses are treated as local.
12591 In today&#x2019;s Internet, the use of domain literals is controversial.
12592 </para>
12593 </listitem>
12594 <listitem>
12595 <para>
12596 <indexterm role="concept">
12597 <primary>@mx_any</primary>
12598 </indexterm>
12599 <indexterm role="concept">
12600 <primary>@mx_primary</primary>
12601 </indexterm>
12602 <indexterm role="concept">
12603 <primary>@mx_secondary</primary>
12604 </indexterm>
12605 <indexterm role="concept">
12606 <primary>domain list</primary>
12607 <secondary>matching MX pointers to local host</secondary>
12608 </indexterm>
12609 If a pattern consists of the string <literal>@mx_any</literal> it matches any domain that
12610 has an MX record pointing to the local host or to any host that is listed in
12611 <indexterm role="option">
12612 <primary><option>hosts_treat_as_local</option></primary>
12613 </indexterm>
12614 <option>hosts_treat_as_local</option>. The items <literal>@mx_primary</literal> and <literal>@mx_secondary</literal>
12615 are similar, except that the first matches only when a primary MX target is the
12616 local host, and the second only when no primary MX target is the local host,
12617 but a secondary MX target is. <quote>Primary</quote> means an MX record with the lowest
12618 preference value &ndash; there may of course be more than one of them.
12619 </para>
12620 <para>
12621 The MX lookup that takes place when matching a pattern of this type is
12622 performed with the resolver options for widening names turned off. Thus, for
12623 example, a single-component domain will <emphasis>not</emphasis> be expanded by adding the
12624 resolver&#x2019;s default domain. See the <option>qualify_single</option> and <option>search_parents</option>
12625 options of the <command>dnslookup</command> router for a discussion of domain widening.
12626 </para>
12627 <para>
12628 Sometimes you may want to ignore certain IP addresses when using one of these
12629 patterns. You can specify this by following the pattern with <literal>/ignore=</literal>&lt;<emphasis>ip
12630 list</emphasis>&gt;, where &lt;<emphasis>ip list</emphasis>&gt; is a list of IP addresses. These addresses are
12631 ignored when processing the pattern (compare the <option>ignore_target_hosts</option> option
12632 on a router). For example:
12633 </para>
12634 <literallayout class="monospaced">
12635 domains = @mx_any/ignore=127.0.0.1
12636 </literallayout>
12637 <para>
12638 This example matches any domain that has an MX record pointing to one of
12639 the local host&#x2019;s IP addresses other than 127.0.0.1.
12640 </para>
12641 <para>
12642 The list of IP addresses is in fact processed by the same code that processes
12643 host lists, so it may contain CIDR-coded network specifications and it may also
12644 contain negative items.
12645 </para>
12646 <para>
12647 Because the list of IP addresses is a sublist within a domain list, you have to
12648 be careful about delimiters if there is more than one address. Like any other
12649 list, the default delimiter can be changed. Thus, you might have:
12650 </para>
12651 <literallayout class="monospaced">
12652 domains = @mx_any/ignore=&lt;;127.0.0.1;0.0.0.0 : \
12653           an.other.domain : ...
12654 </literallayout>
12655 <para>
12656 so that the sublist uses semicolons for delimiters. When IPv6 addresses are
12657 involved, it is easiest to change the delimiter for the main list as well:
12658 </para>
12659 <literallayout class="monospaced">
12660 domains = &lt;? @mx_any/ignore=&lt;;127.0.0.1;::1 ? \
12661           an.other.domain ? ...
12662 </literallayout>
12663 </listitem>
12664 <listitem>
12665 <para>
12666 <indexterm role="concept">
12667 <primary>asterisk</primary>
12668 <secondary>in domain list</secondary>
12669 </indexterm>
12670 <indexterm role="concept">
12671 <primary>domain list</primary>
12672 <secondary>asterisk in</secondary>
12673 </indexterm>
12674 <indexterm role="concept">
12675 <primary>domain list</primary>
12676 <secondary>matching <quote>ends with</quote></secondary>
12677 </indexterm>
12678 If a pattern starts with an asterisk, the remaining characters of the pattern
12679 are compared with the terminating characters of the domain. The use of <quote>*</quote> in
12680 domain lists differs from its use in partial matching lookups. In a domain
12681 list, the character following the asterisk need not be a dot, whereas partial
12682 matching works only in terms of dot-separated components. For example, a domain
12683 list item such as <literal>*key.ex</literal> matches <emphasis>donkey.ex</emphasis> as well as
12684 <emphasis>cipher.key.ex</emphasis>.
12685 </para>
12686 </listitem>
12687 <listitem>
12688 <para>
12689 <indexterm role="concept">
12690 <primary>regular expressions</primary>
12691 <secondary>in domain list</secondary>
12692 </indexterm>
12693 <indexterm role="concept">
12694 <primary>domain list</primary>
12695 <secondary>matching regular expression</secondary>
12696 </indexterm>
12697 If a pattern starts with a circumflex character, it is treated as a regular
12698 expression, and matched against the domain using a regular expression matching
12699 function. The circumflex is treated as part of the regular expression.
12700 Email domains are case-independent, so this regular expression match is by
12701 default case-independent, but you can make it case-dependent by starting it
12702 with <literal>(?-i)</literal>. References to descriptions of the syntax of regular expressions
12703 are given in chapter <xref linkend="CHAPregexp"/>.
12704 </para>
12705 <para>
12706 <emphasis role="bold">Warning</emphasis>: Because domain lists are expanded before being processed, you
12707 must escape any backslash and dollar characters in the regular expression, or
12708 use the special <literal>\N</literal> sequence (see chapter <xref linkend="CHAPexpand"/>) to specify that
12709 it is not to be expanded (unless you really do want to build a regular
12710 expression by expansion, of course).
12711 </para>
12712 </listitem>
12713 <listitem>
12714 <para>
12715 <indexterm role="concept">
12716 <primary>lookup</primary>
12717 <secondary>in domain list</secondary>
12718 </indexterm>
12719 <indexterm role="concept">
12720 <primary>domain list</primary>
12721 <secondary>matching by lookup</secondary>
12722 </indexterm>
12723 If a pattern starts with the name of a single-key lookup type followed by a
12724 semicolon (for example, <quote>dbm;</quote> or <quote>lsearch;</quote>), the remainder of the pattern
12725 must be a filename in a suitable format for the lookup type. For example, for
12726 <quote>cdb;</quote> it must be an absolute path:
12727 </para>
12728 <literallayout class="monospaced">
12729 domains = cdb;/etc/mail/local_domains.cdb
12730 </literallayout>
12731 <para>
12732 The appropriate type of lookup is done on the file using the domain name as the
12733 key. In most cases, the data that is looked up is not used; Exim is interested
12734 only in whether or not the key is present in the file. However, when a lookup
12735 is used for the <option>domains</option> option on a router
12736 or a <option>domains</option> condition in an ACL statement, the data is preserved in the
12737 <varname>$domain_data</varname> variable and can be referred to in other router options or
12738 other statements in the same ACL.
12739 </para>
12740 </listitem>
12741 <listitem>
12742 <para>
12743 Any of the single-key lookup type names may be preceded by
12744 <literal>partial</literal>&lt;<emphasis>n</emphasis>&gt;<literal>-</literal>, where the &lt;<emphasis>n</emphasis>&gt; is optional, for example,
12745 </para>
12746 <literallayout class="monospaced">
12747 domains = partial-dbm;/partial/domains
12748 </literallayout>
12749 <para>
12750 This causes partial matching logic to be invoked; a description of how this
12751 works is given in section <xref linkend="SECTpartiallookup"/>.
12752 </para>
12753 </listitem>
12754 <listitem>
12755 <para>
12756 <indexterm role="concept">
12757 <primary>asterisk</primary>
12758 <secondary>in lookup type</secondary>
12759 </indexterm>
12760 Any of the single-key lookup types may be followed by an asterisk. This causes
12761 a default lookup for a key consisting of a single asterisk to be done if the
12762 original lookup fails. This is not a useful feature when using a domain list to
12763 select particular domains (because any domain would match), but it might have
12764 value if the result of the lookup is being used via the <varname>$domain_data</varname>
12765 expansion variable.
12766 </para>
12767 </listitem>
12768 <listitem>
12769 <para>
12770 If the pattern starts with the name of a query-style lookup type followed by a
12771 semicolon (for example, <quote>nisplus;</quote> or <quote>ldap;</quote>), the remainder of the
12772 pattern must be an appropriate query for the lookup type, as described in
12773 chapter <xref linkend="CHAPfdlookup"/>. For example:
12774 </para>
12775 <literallayout class="monospaced">
12776 hold_domains = mysql;select domain from holdlist \
12777   where domain = '${quote_mysql:$domain}';
12778 </literallayout>
12779 <para>
12780 In most cases, the data that is looked up is not used (so for an SQL query, for
12781 example, it doesn&#x2019;t matter what field you select). Exim is interested only in
12782 whether or not the query succeeds. However, when a lookup is used for the
12783 <option>domains</option> option on a router, the data is preserved in the <varname>$domain_data</varname>
12784 variable and can be referred to in other options.
12785 </para>
12786 </listitem>
12787 <listitem>
12788 <para>
12789 <indexterm role="concept">
12790 <primary>domain list</primary>
12791 <secondary>matching literal domain name</secondary>
12792 </indexterm>
12793 If none of the above cases apply, a caseless textual comparison is made
12794 between the pattern and the domain.
12795 </para>
12796 </listitem>
12797 </itemizedlist>
12798 <para>
12799 Here is an example that uses several different kinds of pattern:
12800 </para>
12801 <literallayout class="monospaced">
12802 domainlist funny_domains = \
12803   @ : \
12804   lib.unseen.edu : \
12805   *.foundation.fict.example : \
12806   \N^[1-2]\d{3}\.fict\.example$\N : \
12807   partial-dbm;/opt/data/penguin/book : \
12808   nis;domains.byname : \
12809   nisplus;[name=$domain,status=local],domains.org_dir
12810 </literallayout>
12811 <para>
12812 There are obvious processing trade-offs among the various matching modes. Using
12813 an asterisk is faster than a regular expression, and listing a few names
12814 explicitly probably is too. The use of a file or database lookup is expensive,
12815 but may be the only option if hundreds of names are required. Because the
12816 patterns are tested in order, it makes sense to put the most commonly matched
12817 patterns earlier.
12818 </para>
12819 </section>
12820 <section id="SECThostlist">
12821 <title>Host lists</title>
12822 <para>
12823 <indexterm role="concept">
12824 <primary>host list</primary>
12825 <secondary>patterns in</secondary>
12826 </indexterm>
12827 <indexterm role="concept">
12828 <primary>list</primary>
12829 <secondary>host list</secondary>
12830 </indexterm>
12831 Host lists are used to control what remote hosts are allowed to do. For
12832 example, some hosts may be allowed to use the local host as a relay, and some
12833 may be permitted to use the SMTP ETRN command. Hosts can be identified in
12834 two different ways, by name or by IP address. In a host list, some types of
12835 pattern are matched to a host name, and some are matched to an IP address.
12836 You need to be particularly careful with this when single-key lookups are
12837 involved, to ensure that the right value is being used as the key.
12838 </para>
12839 </section>
12840 <section id="SECID80">
12841 <title>Special host list patterns</title>
12842 <para>
12843 <indexterm role="concept">
12844 <primary>empty item in hosts list</primary>
12845 </indexterm>
12846 <indexterm role="concept">
12847 <primary>host list</primary>
12848 <secondary>empty string in</secondary>
12849 </indexterm>
12850 If a host list item is the empty string, it matches only when no remote host is
12851 involved. This is the case when a message is being received from a local
12852 process using SMTP on the standard input, that is, when a TCP/IP connection is
12853 not used.
12854 </para>
12855 <para>
12856 <indexterm role="concept">
12857 <primary>asterisk</primary>
12858 <secondary>in host list</secondary>
12859 </indexterm>
12860 The special pattern <quote>*</quote> in a host list matches any host or no host. Neither
12861 the IP address nor the name is actually inspected.
12862 </para>
12863 </section>
12864 <section id="SECThoslispatip">
12865 <title>Host list patterns that match by IP address</title>
12866 <para>
12867 <indexterm role="concept">
12868 <primary>host list</primary>
12869 <secondary>matching IP addresses</secondary>
12870 </indexterm>
12871 If an IPv4 host calls an IPv6 host and the call is accepted on an IPv6 socket,
12872 the incoming address actually appears in the IPv6 host as
12873 <literal>::ffff:</literal>&lt;<emphasis>v4address</emphasis>&gt;. When such an address is tested against a host
12874 list, it is converted into a traditional IPv4 address first. (Not all operating
12875 systems accept IPv4 calls on IPv6 sockets, as there have been some security
12876 concerns.)
12877 </para>
12878 <para>
12879 The following types of pattern in a host list check the remote host by
12880 inspecting its IP address:
12881 </para>
12882 <itemizedlist>
12883 <listitem>
12884 <para>
12885 If the pattern is a plain domain name (not a regular expression, not starting
12886 with *, not a lookup of any kind), Exim calls the operating system function
12887 to find the associated IP address(es). Exim uses the newer
12888 <function>getipnodebyname()</function> function when available, otherwise <function>gethostbyname()</function>.
12889 This typically causes a forward DNS lookup of the name. The result is compared
12890 with the IP address of the subject host.
12891 </para>
12892 <para>
12893 If there is a temporary problem (such as a DNS timeout) with the host name
12894 lookup, a temporary error occurs. For example, if the list is being used in an
12895 ACL condition, the ACL gives a <quote>defer</quote> response, usually leading to a
12896 temporary SMTP error code. If no IP address can be found for the host name,
12897 what happens is described in section <xref linkend="SECTbehipnot"/> below.
12898 </para>
12899 </listitem>
12900 <listitem>
12901 <para>
12902 <indexterm role="concept">
12903 <primary>@ in a host list</primary>
12904 </indexterm>
12905 If the pattern is <quote>@</quote>, the primary host name is substituted and used as a
12906 domain name, as just described.
12907 </para>
12908 </listitem>
12909 <listitem>
12910 <para>
12911 If the pattern is an IP address, it is matched against the IP address of the
12912 subject host. IPv4 addresses are given in the normal <quote>dotted-quad</quote> notation.
12913 IPv6 addresses can be given in colon-separated format, but the colons have to
12914 be doubled so as not to be taken as item separators when the default list
12915 separator is used. IPv6 addresses are recognized even when Exim is compiled
12916 without IPv6 support. This means that if they appear in a host list on an
12917 IPv4-only host, Exim will not treat them as host names. They are just addresses
12918 that can never match a client host.
12919 </para>
12920 </listitem>
12921 <listitem>
12922 <para>
12923 <indexterm role="concept">
12924 <primary>@[] in a host list</primary>
12925 </indexterm>
12926 If the pattern is <quote>@[]</quote>, it matches the IP address of any IP interface on
12927 the local host. For example, if the local host is an IPv4 host with one
12928 interface address 10.45.23.56, these two ACL statements have the same effect:
12929 </para>
12930 <literallayout class="monospaced">
12931 accept hosts = 127.0.0.1 : 10.45.23.56
12932 accept hosts = @[]
12933 </literallayout>
12934 </listitem>
12935 <listitem>
12936 <para>
12937 <indexterm role="concept">
12938 <primary>CIDR notation</primary>
12939 </indexterm>
12940 If the pattern is an IP address followed by a slash and a mask length (for
12941 example 10.11.42.0/24), it is matched against the IP address of the subject
12942 host under the given mask. This allows, an entire network of hosts to be
12943 included (or excluded) by a single item. The mask uses CIDR notation; it
12944 specifies the number of address bits that must match, starting from the most
12945 significant end of the address.
12946 </para>
12947 <para>
12948 <emphasis role="bold">Note</emphasis>: The mask is <emphasis>not</emphasis> a count of addresses, nor is it the high number
12949 of a range of addresses. It is the number of bits in the network portion of the
12950 address. The above example specifies a 24-bit netmask, so it matches all 256
12951 addresses in the 10.11.42.0 network. An item such as
12952 </para>
12953 <literallayout class="monospaced">
12954 192.168.23.236/31
12955 </literallayout>
12956 <para>
12957 matches just two addresses, 192.168.23.236 and 192.168.23.237. A mask value of
12958 32 for an IPv4 address is the same as no mask at all; just a single address
12959 matches.
12960 </para>
12961 <para>
12962 Here is another example which shows an IPv4 and an IPv6 network:
12963 </para>
12964 <literallayout class="monospaced">
12965 recipient_unqualified_hosts = 192.168.0.0/16: \
12966                               3ffe::ffff::836f::::/48
12967 </literallayout>
12968 <para>
12969 The doubling of list separator characters applies only when these items
12970 appear inline in a host list. It is not required when indirecting via a file.
12971 For example:
12972 </para>
12973 <literallayout class="monospaced">
12974 recipient_unqualified_hosts = /opt/exim/unqualnets
12975 </literallayout>
12976 <para>
12977 could make use of a file containing
12978 </para>
12979 <literallayout class="monospaced">
12980 172.16.0.0/12
12981 3ffe:ffff:836f::/48
12982 </literallayout>
12983 <para>
12984 to have exactly the same effect as the previous example. When listing IPv6
12985 addresses inline, it is usually more convenient to use the facility for
12986 changing separator characters. This list contains the same two networks:
12987 </para>
12988 <literallayout class="monospaced">
12989 recipient_unqualified_hosts = &lt;; 172.16.0.0/12; \
12990                                  3ffe:ffff:836f::/48
12991 </literallayout>
12992 <para>
12993 The separator is changed to semicolon by the leading <quote>&lt;;</quote> at the start of the
12994 list.
12995 </para>
12996 </listitem>
12997 </itemizedlist>
12998 </section>
12999 <section id="SECThoslispatsikey">
13000 <title>Host list patterns for single-key lookups by host address</title>
13001 <para>
13002 <indexterm role="concept">
13003 <primary>host list</primary>
13004 <secondary>lookup of IP address</secondary>
13005 </indexterm>
13006 When a host is to be identified by a single-key lookup of its complete IP
13007 address, the pattern takes this form:
13008 </para>
13009 <literallayout>
13010 <literal>net-&lt;</literal><emphasis>single-key-search-type</emphasis><literal>&gt;;&lt;</literal><emphasis>search-data</emphasis><literal>&gt;</literal>
13011 </literallayout>
13012 <para>
13013 For example:
13014 </para>
13015 <literallayout class="monospaced">
13016 hosts_lookup = net-cdb;/hosts-by-ip.db
13017 </literallayout>
13018 <para>
13019 The text form of the IP address of the subject host is used as the lookup key.
13020 IPv6 addresses are converted to an unabbreviated form, using lower case
13021 letters, with dots as separators because colon is the key terminator in
13022 <command>lsearch</command> files. [Colons can in fact be used in keys in <command>lsearch</command> files by
13023 quoting the keys, but this is a facility that was added later.] The data
13024 returned by the lookup is not used.
13025 </para>
13026 <para>
13027 <indexterm role="concept">
13028 <primary>IP address</primary>
13029 <secondary>masking</secondary>
13030 </indexterm>
13031 <indexterm role="concept">
13032 <primary>host list</primary>
13033 <secondary>masked IP address</secondary>
13034 </indexterm>
13035 Single-key lookups can also be performed using masked IP addresses, using
13036 patterns of this form:
13037 </para>
13038 <literallayout>
13039 <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>
13040 </literallayout>
13041 <para>
13042 For example:
13043 </para>
13044 <literallayout class="monospaced">
13045 net24-dbm;/networks.db
13046 </literallayout>
13047 <para>
13048 The IP address of the subject host is masked using &lt;<emphasis>number</emphasis>&gt; as the mask
13049 length. A textual string is constructed from the masked value, followed by the
13050 mask, and this is used as the lookup key. For example, if the host&#x2019;s IP address
13051 is 192.168.34.6, the key that is looked up for the above example is
13052 <quote>192.168.34.0/24</quote>.
13053 </para>
13054 <para>
13055 When an IPv6 address is converted to a string, dots are normally used instead
13056 of colons, so that keys in <command>lsearch</command> files need not contain colons (which
13057 terminate <command>lsearch</command> keys). This was implemented some time before the ability
13058 to quote keys was made available in <command>lsearch</command> files. However, the more
13059 recently implemented <command>iplsearch</command> files do require colons in IPv6 keys
13060 (notated using the quoting facility) so as to distinguish them from IPv4 keys.
13061 For this reason, when the lookup type is <command>iplsearch</command>, IPv6 addresses are
13062 converted using colons and not dots.
13063 </para>
13064 <para revisionflag="changed">
13065 In all cases except IPv4-mapped IPv6, full, unabbreviated IPv6
13066 addresses are always used.
13067 The latter are converted to IPv4 addresses, in dotted-quad form.
13068 </para>
13069 <para>
13070 Ideally, it would be nice to tidy up this anomalous situation by changing to
13071 colons in all cases, given that quoting is now available for <command>lsearch</command>.
13072 However, this would be an incompatible change that might break some existing
13073 configurations.
13074 </para>
13075 <para>
13076 <emphasis role="bold">Warning</emphasis>: Specifying <option>net32-</option> (for an IPv4 address) or <option>net128-</option> (for an
13077 IPv6 address) is not the same as specifying just <option>net-</option> without a number. In
13078 the former case the key strings include the mask value, whereas in the latter
13079 case the IP address is used on its own.
13080 </para>
13081 </section>
13082 <section id="SECThoslispatnam">
13083 <title>Host list patterns that match by host name</title>
13084 <para>
13085 <indexterm role="concept">
13086 <primary>host</primary>
13087 <secondary>lookup failures</secondary>
13088 </indexterm>
13089 <indexterm role="concept">
13090 <primary>unknown host name</primary>
13091 </indexterm>
13092 <indexterm role="concept">
13093 <primary>host list</primary>
13094 <secondary>matching host name</secondary>
13095 </indexterm>
13096 There are several types of pattern that require Exim to know the name of the
13097 remote host. These are either wildcard patterns or lookups by name. (If a
13098 complete hostname is given without any wildcarding, it is used to find an IP
13099 address to match against, as described in section <xref linkend="SECThoslispatip"/>
13100 above.)
13101 </para>
13102 <para>
13103 If the remote host name is not already known when Exim encounters one of these
13104 patterns, it has to be found from the IP address.
13105 Although many sites on the Internet are conscientious about maintaining reverse
13106 DNS data for their hosts, there are also many that do not do this.
13107 Consequently, a name cannot always be found, and this may lead to unwanted
13108 effects. Take care when configuring host lists with wildcarded name patterns.
13109 Consider what will happen if a name cannot be found.
13110 </para>
13111 <para>
13112 Because of the problems of determining host names from IP addresses, matching
13113 against host names is not as common as matching against IP addresses.
13114 </para>
13115 <para>
13116 By default, in order to find a host name, Exim first does a reverse DNS lookup;
13117 if no name is found in the DNS, the system function (<function>gethostbyaddr()</function> or
13118 <function>getipnodebyaddr()</function> if available) is tried. The order in which these lookups
13119 are done can be changed by setting the <option>host_lookup_order</option> option. For
13120 security, once Exim has found one or more names, it looks up the IP addresses
13121 for these names and compares them with the IP address that it started with.
13122 Only those names whose IP addresses match are accepted. Any other names are
13123 discarded. If no names are left, Exim behaves as if the host name cannot be
13124 found. In the most common case there is only one name and one IP address.
13125 </para>
13126 <para>
13127 There are some options that control what happens if a host name cannot be
13128 found. These are described in section <xref linkend="SECTbehipnot"/> below.
13129 </para>
13130 <para>
13131 <indexterm role="concept">
13132 <primary>host</primary>
13133 <secondary>alias for</secondary>
13134 </indexterm>
13135 <indexterm role="concept">
13136 <primary>alias for host</primary>
13137 </indexterm>
13138 As a result of aliasing, hosts may have more than one name. When processing any
13139 of the following types of pattern, all the host&#x2019;s names are checked:
13140 </para>
13141 <itemizedlist>
13142 <listitem>
13143 <para>
13144 <indexterm role="concept">
13145 <primary>asterisk</primary>
13146 <secondary>in host list</secondary>
13147 </indexterm>
13148 If a pattern starts with <quote>*</quote> the remainder of the item must match the end of
13149 the host name. For example, <literal>*.b.c</literal> matches all hosts whose names end in
13150 <emphasis>.b.c</emphasis>. This special simple form is provided because this is a very common
13151 requirement. Other kinds of wildcarding require the use of a regular
13152 expression.
13153 </para>
13154 </listitem>
13155 <listitem>
13156 <para>
13157 <indexterm role="concept">
13158 <primary>regular expressions</primary>
13159 <secondary>in host list</secondary>
13160 </indexterm>
13161 <indexterm role="concept">
13162 <primary>host list</primary>
13163 <secondary>regular expression in</secondary>
13164 </indexterm>
13165 If the item starts with <quote>^</quote> it is taken to be a regular expression which is
13166 matched against the host name. Host names are case-independent, so this regular
13167 expression match is by default case-independent, but you can make it
13168 case-dependent by starting it with <literal>(?-i)</literal>. References to descriptions of the
13169 syntax of regular expressions are given in chapter <xref linkend="CHAPregexp"/>. For
13170 example,
13171 </para>
13172 <literallayout class="monospaced">
13173 ^(a|b)\.c\.d$
13174 </literallayout>
13175 <para>
13176 is a regular expression that matches either of the two hosts <emphasis>a.c.d</emphasis> or
13177 <emphasis>b.c.d</emphasis>. When a regular expression is used in a host list, you must take care
13178 that backslash and dollar characters are not misinterpreted as part of the
13179 string expansion. The simplest way to do this is to use <literal>\N</literal> to mark that
13180 part of the string as non-expandable. For example:
13181 </para>
13182 <literallayout class="monospaced">
13183 sender_unqualified_hosts = \N^(a|b)\.c\.d$\N : ....
13184 </literallayout>
13185 <para>
13186 <emphasis role="bold">Warning</emphasis>: If you want to match a complete host name, you must include the
13187 <literal>$</literal> terminating metacharacter in the regular expression, as in the above
13188 example. Without it, a match at the start of the host name is all that is
13189 required.
13190 </para>
13191 </listitem>
13192 </itemizedlist>
13193 </section>
13194 <section id="SECTbehipnot">
13195 <title>Behaviour when an IP address or name cannot be found</title>
13196 <para>
13197 <indexterm role="concept">
13198 <primary>host</primary>
13199 <secondary>lookup failures, permanent</secondary>
13200 </indexterm>
13201 While processing a host list, Exim may need to look up an IP address from a
13202 name (see section <xref linkend="SECThoslispatip"/>), or it may need to look up a host name
13203 from an IP address (see section <xref linkend="SECThoslispatnam"/>). In either case, the
13204 behaviour when it fails to find the information it is seeking is the same.
13205 </para>
13206 <para>
13207 <emphasis role="bold">Note</emphasis>: This section applies to permanent lookup failures. It does <emphasis>not</emphasis>
13208 apply to temporary DNS errors, whose handling is described in the next section.
13209 </para>
13210 <para>
13211 <indexterm role="concept">
13212 <primary><literal>+include_unknown</literal></primary>
13213 </indexterm>
13214 <indexterm role="concept">
13215 <primary><literal>+ignore_unknown</literal></primary>
13216 </indexterm>
13217 Exim parses a host list from left to right. If it encounters a permanent
13218 lookup failure in any item in the host list before it has found a match,
13219 Exim treats it as a failure and the default behavior is as if the host
13220 does not match the list. This may not always be what you want to happen.
13221 To change Exim&#x2019;s behaviour, the special items <literal>+include_unknown</literal> or
13222 <literal>+ignore_unknown</literal> may appear in the list (at top level &ndash; they are
13223 not recognized in an indirected file).
13224 </para>
13225 <itemizedlist>
13226 <listitem>
13227 <para>
13228 If any item that follows <literal>+include_unknown</literal> requires information that
13229 cannot found, Exim behaves as if the host does match the list. For example,
13230 </para>
13231 <literallayout class="monospaced">
13232 host_reject_connection = +include_unknown:*.enemy.ex
13233 </literallayout>
13234 <para>
13235 rejects connections from any host whose name matches <literal>*.enemy.ex</literal>, and also
13236 any hosts whose name it cannot find.
13237 </para>
13238 </listitem>
13239 <listitem>
13240 <para>
13241 If any item that follows <literal>+ignore_unknown</literal> requires information that cannot
13242 be found, Exim ignores that item and proceeds to the rest of the list. For
13243 example:
13244 </para>
13245 <literallayout class="monospaced">
13246 accept hosts = +ignore_unknown : friend.example : \
13247                192.168.4.5
13248 </literallayout>
13249 <para>
13250 accepts from any host whose name is <emphasis>friend.example</emphasis> and from 192.168.4.5,
13251 whether or not its host name can be found. Without <literal>+ignore_unknown</literal>, if no
13252 name can be found for 192.168.4.5, it is rejected.
13253 </para>
13254 </listitem>
13255 </itemizedlist>
13256 <para>
13257 Both <literal>+include_unknown</literal> and <literal>+ignore_unknown</literal> may appear in the same
13258 list. The effect of each one lasts until the next, or until the end of the
13259 list.
13260 </para>
13261 </section>
13262 <section id="SECTmixwilhos">
13263 <title>Mixing wildcarded host names and addresses in host lists</title>
13264 <para>
13265 <indexterm role="concept">
13266 <primary>host list</primary>
13267 <secondary>mixing names and addresses in</secondary>
13268 </indexterm>
13269 </para>
13270 <para>
13271 This section explains the host/ip processing logic with the same concepts
13272 as the previous section, but specifically addresses what happens when a
13273 wildcarded hostname is one of the items in the hostlist.
13274 </para>
13275 <itemizedlist>
13276 <listitem>
13277 <para>
13278 If you have name lookups or wildcarded host names and
13279 IP addresses in the same host list, you should normally put the IP
13280 addresses first. For example, in an ACL you could have:
13281 </para>
13282 <literallayout class="monospaced">
13283 accept hosts = 10.9.8.7 : *.friend.example
13284 </literallayout>
13285 <para>
13286 The reason you normally would order it this way lies in the
13287 left-to-right way that Exim processes lists.  It can test IP addresses
13288 without doing any DNS lookups, but when it reaches an item that requires
13289 a host name, it fails if it cannot find a host name to compare with the
13290 pattern. If the above list is given in the opposite order, the
13291 <option>accept</option> statement fails for a host whose name cannot be found, even
13292 if its IP address is 10.9.8.7.
13293 </para>
13294 </listitem>
13295 <listitem>
13296 <para>
13297 If you really do want to do the name check first, and still recognize the IP
13298 address, you can rewrite the ACL like this:
13299 </para>
13300 <literallayout class="monospaced">
13301 accept hosts = *.friend.example
13302 accept hosts = 10.9.8.7
13303 </literallayout>
13304 <para>
13305 If the first <option>accept</option> fails, Exim goes on to try the second one. See chapter
13306 <xref linkend="CHAPACL"/> for details of ACLs. Alternatively, you can use
13307 <literal>+ignore_unknown</literal>, which was discussed in depth in the first example in
13308 this section.
13309 </para>
13310 </listitem>
13311 </itemizedlist>
13312 </section>
13313 <section id="SECTtemdnserr">
13314 <title>Temporary DNS errors when looking up host information</title>
13315 <para>
13316 <indexterm role="concept">
13317 <primary>host</primary>
13318 <secondary>lookup failures, temporary</secondary>
13319 </indexterm>
13320 <indexterm role="concept">
13321 <primary><literal>+include_defer</literal></primary>
13322 </indexterm>
13323 <indexterm role="concept">
13324 <primary><literal>+ignore_defer</literal></primary>
13325 </indexterm>
13326 A temporary DNS lookup failure normally causes a defer action (except when
13327 <option>dns_again_means_nonexist</option> converts it into a permanent error). However,
13328 host lists can include <literal>+ignore_defer</literal> and <literal>+include_defer</literal>, analogous to
13329 <literal>+ignore_unknown</literal> and <literal>+include_unknown</literal>, as described in the previous
13330 section. These options should be used with care, probably only in non-critical
13331 host lists such as whitelists.
13332 </para>
13333 </section>
13334 <section id="SECThoslispatnamsk">
13335 <title>Host list patterns for single-key lookups by host name</title>
13336 <para>
13337 <indexterm role="concept">
13338 <primary>unknown host name</primary>
13339 </indexterm>
13340 <indexterm role="concept">
13341 <primary>host list</primary>
13342 <secondary>matching host name</secondary>
13343 </indexterm>
13344 If a pattern is of the form
13345 </para>
13346 <literallayout>
13347 &lt;<emphasis>single-key-search-type</emphasis>&gt;;&lt;<emphasis>search-data</emphasis>&gt;
13348 </literallayout>
13349 <para>
13350 for example
13351 </para>
13352 <literallayout class="monospaced">
13353 dbm;/host/accept/list
13354 </literallayout>
13355 <para>
13356 a single-key lookup is performed, using the host name as its key. If the
13357 lookup succeeds, the host matches the item. The actual data that is looked up
13358 is not used.
13359 </para>
13360 <para>
13361 <emphasis role="bold">Reminder</emphasis>: With this kind of pattern, you must have host <emphasis>names</emphasis> as
13362 keys in the file, not IP addresses. If you want to do lookups based on IP
13363 addresses, you must precede the search type with <quote>net-</quote> (see section
13364 <xref linkend="SECThoslispatsikey"/>). There is, however, no reason why you could not use
13365 two items in the same list, one doing an address lookup and one doing a name
13366 lookup, both using the same file.
13367 </para>
13368 </section>
13369 <section id="SECID81">
13370 <title>Host list patterns for query-style lookups</title>
13371 <para>
13372 If a pattern is of the form
13373 </para>
13374 <literallayout>
13375 &lt;<emphasis>query-style-search-type</emphasis>&gt;;&lt;<emphasis>query</emphasis>&gt;
13376 </literallayout>
13377 <para>
13378 the query is obeyed, and if it succeeds, the host matches the item. The actual
13379 data that is looked up is not used. The variables <varname>$sender_host_address</varname> and
13380 <varname>$sender_host_name</varname> can be used in the query. For example:
13381 </para>
13382 <literallayout class="monospaced">
13383 hosts_lookup = pgsql;\
13384   select ip from hostlist where ip='$sender_host_address'
13385 </literallayout>
13386 <para>
13387 The value of <varname>$sender_host_address</varname> for an IPv6 address contains colons. You
13388 can use the <option>sg</option> expansion item to change this if you need to. If you want to
13389 use masked IP addresses in database queries, you can use the <option>mask</option> expansion
13390 operator.
13391 </para>
13392 <para>
13393 If the query contains a reference to <varname>$sender_host_name</varname>, Exim automatically
13394 looks up the host name if it has not already done so. (See section
13395 <xref linkend="SECThoslispatnam"/> for comments on finding host names.)
13396 </para>
13397 <para>
13398 Historical note: prior to release 4.30, Exim would always attempt to find a
13399 host name before running the query, unless the search type was preceded by
13400 <literal>net-</literal>. This is no longer the case. For backwards compatibility, <literal>net-</literal> is
13401 still recognized for query-style lookups, but its presence or absence has no
13402 effect. (Of course, for single-key lookups, <literal>net-</literal> <emphasis>is</emphasis> important.
13403 See section <xref linkend="SECThoslispatsikey"/>.)
13404 </para>
13405 </section>
13406 <section id="SECTaddresslist">
13407 <title>Address lists</title>
13408 <para>
13409 <indexterm role="concept">
13410 <primary>list</primary>
13411 <secondary>address list</secondary>
13412 </indexterm>
13413 <indexterm role="concept">
13414 <primary>address list</primary>
13415 <secondary>empty item</secondary>
13416 </indexterm>
13417 <indexterm role="concept">
13418 <primary>address list</primary>
13419 <secondary>patterns</secondary>
13420 </indexterm>
13421 Address lists contain patterns that are matched against mail addresses. There
13422 is one special case to be considered: the sender address of a bounce message is
13423 always empty. You can test for this by providing an empty item in an address
13424 list. For example, you can set up a router to process bounce messages by
13425 using this option setting:
13426 </para>
13427 <literallayout class="monospaced">
13428 senders = :
13429 </literallayout>
13430 <para>
13431 The presence of the colon creates an empty item. If you do not provide any
13432 data, the list is empty and matches nothing. The empty sender can also be
13433 detected by a regular expression that matches an empty string,
13434 and by a query-style lookup that succeeds when <varname>$sender_address</varname> is empty.
13435 </para>
13436 <para>
13437 Non-empty items in an address list can be straightforward email addresses. For
13438 example:
13439 </para>
13440 <literallayout class="monospaced">
13441 senders = jbc@askone.example : hs@anacreon.example
13442 </literallayout>
13443 <para>
13444 A certain amount of wildcarding is permitted. If a pattern contains an @
13445 character, but is not a regular expression and does not begin with a
13446 semicolon-terminated lookup type (described below), the local part of the
13447 subject address is compared with the local part of the pattern, which may start
13448 with an asterisk. If the local parts match, the domain is checked in exactly
13449 the same way as for a pattern in a domain list. For example, the domain can be
13450 wildcarded, refer to a named list, or be a lookup:
13451 </para>
13452 <literallayout class="monospaced">
13453 deny senders = *@*.spamming.site:\
13454                *@+hostile_domains:\
13455                bozo@partial-lsearch;/list/of/dodgy/sites:\
13456                *@dbm;/bad/domains.db
13457 </literallayout>
13458 <para>
13459 <indexterm role="concept">
13460 <primary>local part</primary>
13461 <secondary>starting with !</secondary>
13462 </indexterm>
13463 <indexterm role="concept">
13464 <primary>address list</primary>
13465 <secondary>local part starting with !</secondary>
13466 </indexterm>
13467 If a local part that begins with an exclamation mark is required, it has to be
13468 specified using a regular expression, because otherwise the exclamation mark is
13469 treated as a sign of negation, as is standard in lists.
13470 </para>
13471 <para>
13472 If a non-empty pattern that is not a regular expression or a lookup does not
13473 contain an @ character, it is matched against the domain part of the subject
13474 address. The only two formats that are recognized this way are a literal
13475 domain, or a domain pattern that starts with *. In both these cases, the effect
13476 is the same as if <literal>*@</literal> preceded the pattern. For example:
13477 </para>
13478 <literallayout class="monospaced">
13479 deny senders = enemy.domain : *.enemy.domain
13480 </literallayout>
13481 <para>
13482 The following kinds of more complicated address list pattern can match any
13483 address, including the empty address that is characteristic of bounce message
13484 senders:
13485 </para>
13486 <itemizedlist>
13487 <listitem>
13488 <para>
13489 <indexterm role="concept">
13490 <primary>regular expressions</primary>
13491 <secondary>in address list</secondary>
13492 </indexterm>
13493 <indexterm role="concept">
13494 <primary>address list</primary>
13495 <secondary>regular expression in</secondary>
13496 </indexterm>
13497 If (after expansion) a pattern starts with <quote>^</quote>, a regular expression match is
13498 done against the complete address, with the pattern as the regular expression.
13499 You must take care that backslash and dollar characters are not misinterpreted
13500 as part of the string expansion. The simplest way to do this is to use <literal>\N</literal>
13501 to mark that part of the string as non-expandable. For example:
13502 </para>
13503 <literallayout class="monospaced">
13504 deny senders = \N^.*this.*@example\.com$\N : \
13505                \N^\d{8}.+@spamhaus.example$\N : ...
13506 </literallayout>
13507 <para>
13508 The <literal>\N</literal> sequences are removed by the expansion, so these items do indeed
13509 start with <quote>^</quote> by the time they are being interpreted as address patterns.
13510 </para>
13511 </listitem>
13512 <listitem>
13513 <para>
13514 <indexterm role="concept">
13515 <primary>address list</primary>
13516 <secondary>lookup for complete address</secondary>
13517 </indexterm>
13518 Complete addresses can be looked up by using a pattern that starts with a
13519 lookup type terminated by a semicolon, followed by the data for the lookup. For
13520 example:
13521 </para>
13522 <literallayout class="monospaced">
13523 deny senders = cdb;/etc/blocked.senders : \
13524   mysql;select address from blocked where \
13525   address='${quote_mysql:$sender_address}'
13526 </literallayout>
13527 <para>
13528 Both query-style and single-key lookup types can be used. For a single-key
13529 lookup type, Exim uses the complete address as the key. However, empty keys are
13530 not supported for single-key lookups, so a match against the empty address
13531 always fails. This restriction does not apply to query-style lookups.
13532 </para>
13533 <para>
13534 Partial matching for single-key lookups (section <xref linkend="SECTpartiallookup"/>)
13535 cannot be used, and is ignored if specified, with an entry being written to the
13536 panic log.
13537 <indexterm role="concept">
13538 <primary>*@ with single-key lookup</primary>
13539 </indexterm>
13540 However, you can configure lookup defaults, as described in section
13541 <xref linkend="SECTdefaultvaluelookups"/>, but this is useful only for the <quote>*@</quote> type of
13542 default. For example, with this lookup:
13543 </para>
13544 <literallayout class="monospaced">
13545 accept senders = lsearch*@;/some/file
13546 </literallayout>
13547 <para>
13548 the file could contains lines like this:
13549 </para>
13550 <literallayout class="monospaced">
13551 user1@domain1.example
13552 *@domain2.example
13553 </literallayout>
13554 <para>
13555 and for the sender address <emphasis>nimrod@jaeger.example</emphasis>, the sequence of keys
13556 that are tried is:
13557 </para>
13558 <literallayout class="monospaced">
13559 nimrod@jaeger.example
13560 *@jaeger.example
13561 *
13562 </literallayout>
13563 <para>
13564 <emphasis role="bold">Warning 1</emphasis>: Do not include a line keyed by <quote>*</quote> in the file, because that
13565 would mean that every address matches, thus rendering the test useless.
13566 </para>
13567 <para>
13568 <emphasis role="bold">Warning 2</emphasis>: Do not confuse these two kinds of item:
13569 </para>
13570 <literallayout class="monospaced">
13571 deny recipients = dbm*@;/some/file
13572 deny recipients = *@dbm;/some/file
13573 </literallayout>
13574 <para>
13575 The first does a whole address lookup, with defaulting, as just described,
13576 because it starts with a lookup type. The second matches the local part and
13577 domain independently, as described in a bullet point below.
13578 </para>
13579 </listitem>
13580 </itemizedlist>
13581 <para>
13582 The following kinds of address list pattern can match only non-empty addresses.
13583 If the subject address is empty, a match against any of these pattern types
13584 always fails.
13585 </para>
13586 <itemizedlist>
13587 <listitem>
13588 <para>
13589 <indexterm role="concept">
13590 <primary>@@ with single-key lookup</primary>
13591 </indexterm>
13592 <indexterm role="concept">
13593 <primary>address list</primary>
13594 <secondary>@@ lookup type</secondary>
13595 </indexterm>
13596 <indexterm role="concept">
13597 <primary>address list</primary>
13598 <secondary>split local part and domain</secondary>
13599 </indexterm>
13600 If a pattern starts with <quote>@@</quote> followed by a single-key lookup item
13601 (for example, <literal>@@lsearch;/some/file</literal>), the address that is being checked is
13602 split into a local part and a domain. The domain is looked up in the file. If
13603 it is not found, there is no match. If it is found, the data that is looked up
13604 from the file is treated as a colon-separated list of local part patterns, each
13605 of which is matched against the subject local part in turn.
13606 </para>
13607 <para>
13608 <indexterm role="concept">
13609 <primary>asterisk</primary>
13610 <secondary>in address list</secondary>
13611 </indexterm>
13612 The lookup may be a partial one, and/or one involving a search for a default
13613 keyed by <quote>*</quote> (see section <xref linkend="SECTdefaultvaluelookups"/>). The local part
13614 patterns that are looked up can be regular expressions or begin with <quote>*</quote>, or
13615 even be further lookups. They may also be independently negated. For example,
13616 with
13617 </para>
13618 <literallayout class="monospaced">
13619 deny senders = @@dbm;/etc/reject-by-domain
13620 </literallayout>
13621 <para>
13622 the data from which the DBM file is built could contain lines like
13623 </para>
13624 <literallayout class="monospaced">
13625 baddomain.com:  !postmaster : *
13626 </literallayout>
13627 <para>
13628 to reject all senders except <option>postmaster</option> from that domain.
13629 </para>
13630 <para>
13631 <indexterm role="concept">
13632 <primary>local part</primary>
13633 <secondary>starting with !</secondary>
13634 </indexterm>
13635 If a local part that actually begins with an exclamation mark is required, it
13636 has to be specified using a regular expression. In <command>lsearch</command> files, an entry
13637 may be split over several lines by indenting the second and subsequent lines,
13638 but the separating colon must still be included at line breaks. White space
13639 surrounding the colons is ignored. For example:
13640 </para>
13641 <literallayout class="monospaced">
13642 aol.com:  spammer1 : spammer2 : ^[0-9]+$ :
13643   spammer3 : spammer4
13644 </literallayout>
13645 <para>
13646 As in all colon-separated lists in Exim, a colon can be included in an item by
13647 doubling.
13648 </para>
13649 <para>
13650 If the last item in the list starts with a right angle-bracket, the remainder
13651 of the item is taken as a new key to look up in order to obtain a continuation
13652 list of local parts. The new key can be any sequence of characters. Thus one
13653 might have entries like
13654 </para>
13655 <literallayout class="monospaced">
13656 aol.com: spammer1 : spammer 2 : &gt;*
13657 xyz.com: spammer3 : &gt;*
13658 *:       ^\d{8}$
13659 </literallayout>
13660 <para>
13661 in a file that was searched with <option>@@dbm*</option>, to specify a match for 8-digit
13662 local parts for all domains, in addition to the specific local parts listed for
13663 each domain. Of course, using this feature costs another lookup each time a
13664 chain is followed, but the effort needed to maintain the data is reduced.
13665 </para>
13666 <para>
13667 <indexterm role="concept">
13668 <primary>loop</primary>
13669 <secondary>in lookups</secondary>
13670 </indexterm>
13671 It is possible to construct loops using this facility, and in order to catch
13672 them, the chains may be no more than fifty items long.
13673 </para>
13674 </listitem>
13675 <listitem>
13676 <para>
13677 The @@&lt;<emphasis>lookup</emphasis>&gt; style of item can also be used with a query-style
13678 lookup, but in this case, the chaining facility is not available. The lookup
13679 can only return a single list of local parts.
13680 </para>
13681 </listitem>
13682 </itemizedlist>
13683 <para>
13684 <emphasis role="bold">Warning</emphasis>: There is an important difference between the address list items
13685 in these two examples:
13686 </para>
13687 <literallayout class="monospaced">
13688 senders = +my_list
13689 senders = *@+my_list
13690 </literallayout>
13691 <para>
13692 In the first one, <literal>my_list</literal> is a named address list, whereas in the second
13693 example it is a named domain list.
13694 </para>
13695 </section>
13696 <section id="SECTcasletadd">
13697 <title>Case of letters in address lists</title>
13698 <para>
13699 <indexterm role="concept">
13700 <primary>case of local parts</primary>
13701 </indexterm>
13702 <indexterm role="concept">
13703 <primary>address list</primary>
13704 <secondary>case forcing</secondary>
13705 </indexterm>
13706 <indexterm role="concept">
13707 <primary>case forcing in address lists</primary>
13708 </indexterm>
13709 Domains in email addresses are always handled caselessly, but for local parts
13710 case may be significant on some systems (see <option>caseful_local_part</option> for how
13711 Exim deals with this when routing addresses). However, RFC 2505 (<emphasis>Anti-Spam
13712 Recommendations for SMTP MTAs</emphasis>) suggests that matching of addresses to
13713 blocking lists should be done in a case-independent manner. Since most address
13714 lists in Exim are used for this kind of control, Exim attempts to do this by
13715 default.
13716 </para>
13717 <para>
13718 The domain portion of an address is always lowercased before matching it to an
13719 address list. The local part is lowercased by default, and any string
13720 comparisons that take place are done caselessly. This means that the data in
13721 the address list itself, in files included as plain filenames, and in any file
13722 that is looked up using the <quote>@@</quote> mechanism, can be in any case. However, the
13723 keys in files that are looked up by a search type other than <command>lsearch</command> (which
13724 works caselessly) must be in lower case, because these lookups are not
13725 case-independent.
13726 </para>
13727 <para>
13728 <indexterm role="concept">
13729 <primary><literal>+caseful</literal></primary>
13730 </indexterm>
13731 To allow for the possibility of caseful address list matching, if an item in
13732 an address list is the string <quote>+caseful</quote>, the original case of the local
13733 part is restored for any comparisons that follow, and string comparisons are no
13734 longer case-independent. This does not affect the domain, which remains in
13735 lower case. However, although independent matches on the domain alone are still
13736 performed caselessly, regular expressions that match against an entire address
13737 become case-sensitive after <quote>+caseful</quote> has been seen.
13738 </para>
13739 </section>
13740 <section id="SECTlocparlis">
13741 <title>Local part lists</title>
13742 <para>
13743 <indexterm role="concept">
13744 <primary>list</primary>
13745 <secondary>local part list</secondary>
13746 </indexterm>
13747 <indexterm role="concept">
13748 <primary>local part</primary>
13749 <secondary>list</secondary>
13750 </indexterm>
13751 Case-sensitivity in local part lists is handled in the same way as for address
13752 lists, as just described. The <quote>+caseful</quote> item can be used if required. In a
13753 setting of the <option>local_parts</option> option in a router with <option>caseful_local_part</option>
13754 set false, the subject is lowercased and the matching is initially
13755 case-insensitive. In this case, <quote>+caseful</quote> will restore case-sensitive
13756 matching in the local part list, but not elsewhere in the router. If
13757 <option>caseful_local_part</option> is set true in a router, matching in the <option>local_parts</option>
13758 option is case-sensitive from the start.
13759 </para>
13760 <para>
13761 If a local part list is indirected to a file (see section <xref linkend="SECTfilnamlis"/>),
13762 comments are handled in the same way as address lists &ndash; they are recognized
13763 only if the # is preceded by white space or the start of the line.
13764 Otherwise, local part lists are matched in the same way as domain lists, except
13765 that the special items that refer to the local host (<literal>@</literal>, <literal>@[]</literal>,
13766 <literal>@mx_any</literal>, <literal>@mx_primary</literal>, and <literal>@mx_secondary</literal>) are not recognized.
13767 Refer to section <xref linkend="SECTdomainlist"/> for details of the other available item
13768 types.
13769 <indexterm role="concept" startref="IIDdohoadli" class="endofrange"/>
13770 </para>
13771 </section>
13772 </chapter>
13773
13774 <chapter id="CHAPexpand">
13775 <title>String expansions</title>
13776 <para>
13777 <indexterm role="concept" id="IIDstrexp" class="startofrange">
13778 <primary>expansion</primary>
13779 <secondary>of strings</secondary>
13780 </indexterm>
13781 Many strings in Exim&#x2019;s runtime configuration are expanded before use. Some of
13782 them are expanded every time they are used; others are expanded only once.
13783 </para>
13784 <para>
13785 When a string is being expanded it is copied verbatim from left to right except
13786 <indexterm role="concept">
13787 <primary>expansion</primary>
13788 <secondary>string concatenation</secondary>
13789 </indexterm>
13790 when a dollar or backslash character is encountered. A dollar specifies the
13791 start of a portion of the string that is interpreted and replaced as described
13792 below in section <xref linkend="SECTexpansionitems"/> onwards. Backslash is used as an
13793 escape character, as described in the following section.
13794 </para>
13795 <para>
13796 Whether a string is expanded depends upon the context.  Usually this is solely
13797 dependent upon the option for which a value is sought; in this documentation,
13798 options for which string expansion is performed are marked with &dagger; after
13799 the data type.  ACL rules always expand strings.  A couple of expansion
13800 conditions do not expand some of the brace-delimited branches, for security
13801 reasons,
13802 </para>
13803 <para revisionflag="changed">
13804 <indexterm role="concept">
13805 <primary>tainted data</primary>
13806 <secondary>expansion</secondary>
13807 </indexterm>
13808 <indexterm role="concept">
13809 <primary>expansion</primary>
13810 <secondary>tainted data</secondary>
13811 </indexterm>
13812 and expansion of data deriving from the sender (<quote>tainted data</quote>)
13813 is not permitted.
13814 </para>
13815 <section id="SECTlittext">
13816 <title>Literal text in expanded strings</title>
13817 <para>
13818 <indexterm role="concept">
13819 <primary>expansion</primary>
13820 <secondary>including literal text</secondary>
13821 </indexterm>
13822 An uninterpreted dollar can be included in an expanded string by putting a
13823 backslash in front of it. A backslash can be used to prevent any special
13824 character being treated specially in an expansion, including backslash itself.
13825 If the string appears in quotes in the configuration file, two backslashes are
13826 required because the quotes themselves cause interpretation of backslashes when
13827 the string is read in (see section <xref linkend="SECTstrings"/>).
13828 </para>
13829 <para>
13830 <indexterm role="concept">
13831 <primary>expansion</primary>
13832 <secondary>non-expandable substrings</secondary>
13833 </indexterm>
13834 A portion of the string can specified as non-expandable by placing it between
13835 two occurrences of <literal>\N</literal>. This is particularly useful for protecting regular
13836 expressions, which often contain backslashes and dollar signs. For example:
13837 </para>
13838 <literallayout class="monospaced">
13839 deny senders = \N^\d{8}[a-z]@some\.site\.example$\N
13840 </literallayout>
13841 <para>
13842 On encountering the first <literal>\N</literal>, the expander copies subsequent characters
13843 without interpretation until it reaches the next <literal>\N</literal> or the end of the
13844 string.
13845 </para>
13846 </section>
13847 <section id="SECID82">
13848 <title>Character escape sequences in expanded strings</title>
13849 <para>
13850 <indexterm role="concept">
13851 <primary>expansion</primary>
13852 <secondary>escape sequences</secondary>
13853 </indexterm>
13854 A backslash followed by one of the letters <quote>n</quote>, <quote>r</quote>, or <quote>t</quote> in an
13855 expanded string is recognized as an escape sequence for the character newline,
13856 carriage return, or tab, respectively. A backslash followed by up to three
13857 octal digits is recognized as an octal encoding for a single character, and a
13858 backslash followed by <quote>x</quote> and up to two hexadecimal digits is a hexadecimal
13859 encoding.
13860 </para>
13861 <para>
13862 These escape sequences are also recognized in quoted strings when they are read
13863 in. Their interpretation in expansions as well is useful for unquoted strings,
13864 and for other cases such as looked-up strings that are then expanded.
13865 </para>
13866 </section>
13867 <section id="SECID83">
13868 <title>Testing string expansions</title>
13869 <para>
13870 <indexterm role="concept">
13871 <primary>expansion</primary>
13872 <secondary>testing</secondary>
13873 </indexterm>
13874 <indexterm role="concept">
13875 <primary>testing</primary>
13876 <secondary>string expansion</secondary>
13877 </indexterm>
13878 <indexterm role="option">
13879 <primary><option>-be</option></primary>
13880 </indexterm>
13881 Many expansions can be tested by calling Exim with the <option>-be</option> option. This
13882 takes the command arguments, or lines from the standard input if there are no
13883 arguments, runs them through the string expansion code, and writes the results
13884 to the standard output. Variables based on configuration values are set up, but
13885 since no message is being processed, variables such as <varname>$local_part</varname> have no
13886 value. Nevertheless the <option>-be</option> option can be useful for checking out file and
13887 database lookups, and the use of expansion operators such as <option>sg</option>, <option>substr</option>
13888 and <option>nhash</option>.
13889 </para>
13890 <para>
13891 Exim gives up its root privilege when it is called with the <option>-be</option> option, and
13892 instead runs under the uid and gid it was called with, to prevent users from
13893 using <option>-be</option> for reading files to which they do not have access.
13894 </para>
13895 <para>
13896 <indexterm role="option">
13897 <primary><option>-bem</option></primary>
13898 </indexterm>
13899 If you want to test expansions that include variables whose values are taken
13900 from a message, there are two other options that can be used. The <option>-bem</option>
13901 option is like <option>-be</option> except that it is followed by a filename. The file is
13902 read as a message before doing the test expansions. For example:
13903 </para>
13904 <literallayout class="monospaced">
13905 exim -bem /tmp/test.message '$h_subject:'
13906 </literallayout>
13907 <para>
13908 The <option>-Mset</option> option is used in conjunction with <option>-be</option> and is followed by an
13909 Exim message identifier. For example:
13910 </para>
13911 <literallayout class="monospaced">
13912 exim -be -Mset 1GrA8W-0004WS-LQ '$recipients'
13913 </literallayout>
13914 <para>
13915 This loads the message from Exim&#x2019;s spool before doing the test expansions, and
13916 is therefore restricted to admin users.
13917 </para>
13918 </section>
13919 <section id="SECTforexpfai">
13920 <title>Forced expansion failure</title>
13921 <para>
13922 <indexterm role="concept">
13923 <primary>expansion</primary>
13924 <secondary>forced failure</secondary>
13925 </indexterm>
13926 A number of expansions that are described in the following section have
13927 alternative <quote>true</quote> and <quote>false</quote> substrings, enclosed in brace characters
13928 (which are sometimes called <quote>curly brackets</quote>). Which of the two strings is
13929 used depends on some condition that is evaluated as part of the expansion. If,
13930 instead of a <quote>false</quote> substring, the word <quote>fail</quote> is used (not in braces),
13931 the entire string expansion fails in a way that can be detected by the code
13932 that requested the expansion. This is called <quote>forced expansion failure</quote>, and
13933 its consequences depend on the circumstances. In some cases it is no different
13934 from any other expansion failure, but in others a different action may be
13935 taken. Such variations are mentioned in the documentation of the option that is
13936 being expanded.
13937 </para>
13938 </section>
13939 <section id="SECTexpansionitems">
13940 <title>Expansion items</title>
13941 <para>
13942 The following items are recognized in expanded strings. White space may be used
13943 between sub-items that are keywords or substrings enclosed in braces inside an
13944 outer set of braces, to improve readability. <emphasis role="bold">Warning</emphasis>: Within braces,
13945 white space is significant.
13946 </para>
13947 <variablelist>
13948 <varlistentry>
13949 <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>
13950 <listitem>
13951 <para>
13952 <indexterm role="concept">
13953 <primary>expansion</primary>
13954 <secondary>variables</secondary>
13955 </indexterm>
13956 Substitute the contents of the named variable, for example:
13957 </para>
13958 <literallayout class="monospaced">
13959 $local_part
13960 ${domain}
13961 </literallayout>
13962 <para>
13963 The second form can be used to separate the name from subsequent alphanumeric
13964 characters. This form (using braces) is available only for variables; it does
13965 <emphasis>not</emphasis> apply to message headers. The names of the variables are given in
13966 section <xref linkend="SECTexpvar"/> below. If the name of a non-existent variable is
13967 given, the expansion fails.
13968 </para>
13969 </listitem></varlistentry>
13970 <varlistentry>
13971 <term><emphasis role="bold">${</emphasis>&lt;<emphasis>op</emphasis>&gt;<emphasis role="bold">:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13972 <listitem>
13973 <para>
13974 <indexterm role="concept">
13975 <primary>expansion</primary>
13976 <secondary>operators</secondary>
13977 </indexterm>
13978 The string is first itself expanded, and then the operation specified by
13979 &lt;<emphasis>op</emphasis>&gt; is applied to it. For example:
13980 </para>
13981 <literallayout class="monospaced">
13982 ${lc:$local_part}
13983 </literallayout>
13984 <para>
13985 The string starts with the first character after the colon, which may be
13986 leading white space. A list of operators is given in section <xref linkend="SECTexpop"/>
13987 below. The operator notation is used for simple expansion items that have just
13988 one argument, because it reduces the number of braces and therefore makes the
13989 string easier to understand.
13990 </para>
13991 </listitem></varlistentry>
13992 <varlistentry>
13993 <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>
13994 <listitem>
13995 <para>
13996 This item inserts <quote>basic</quote> header lines. It is described with the <option>header</option>
13997 expansion item below.
13998 </para>
13999 </listitem></varlistentry>
14000 <varlistentry>
14001 <term><emphasis role="bold">${acl{</emphasis>&lt;<emphasis>name</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>arg</emphasis>&gt;<emphasis role="bold">}...}</emphasis></term>
14002 <listitem>
14003 <para>
14004 <indexterm role="concept">
14005 <primary>expansion</primary>
14006 <secondary>calling an acl</secondary>
14007 </indexterm>
14008 <indexterm role="concept">
14009 <primary><option>acl</option></primary>
14010 <secondary>call from expansion</secondary>
14011 </indexterm>
14012 The name and zero to nine argument strings are first expanded separately.  The expanded
14013 arguments are assigned to the variables <varname>$acl_arg1</varname> to <varname>$acl_arg9</varname> in order.
14014 Any unused are made empty.  The variable <varname>$acl_narg</varname> is set to the number of
14015 arguments.  The named ACL (see chapter <xref linkend="CHAPACL"/>) is called
14016 and may use the variables; if another acl expansion is used the values
14017 are restored after it returns.  If the ACL sets
14018 a value using a "message =" modifier and returns accept or deny, the value becomes
14019 the result of the expansion.
14020 If no message is set and the ACL returns accept or deny
14021 the expansion result is an empty string.
14022 If the ACL returns defer the result is a forced-fail.  Otherwise the expansion fails.
14023 </para>
14024 </listitem></varlistentry>
14025 <varlistentry>
14026 <term><emphasis role="bold">${authresults{</emphasis>&lt;<emphasis>authserv-id</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
14027 <listitem>
14028 <para>
14029 <indexterm role="concept">
14030 <primary>authentication</primary>
14031 <secondary>results header</secondary>
14032 </indexterm>
14033 <indexterm role="concept">
14034 <primary>headers</primary>
14035 <secondary>authentication-results:</secondary>
14036 </indexterm>
14037 <indexterm role="concept">
14038 <primary>authentication</primary>
14039 <secondary>expansion item</secondary>
14040 </indexterm>
14041 This item returns a string suitable for insertion as an
14042 <emphasis>Authentication-Results:</emphasis>
14043 header line.
14044 The given &lt;<emphasis>authserv-id</emphasis>&gt; is included in the result; typically this
14045 will be a domain name identifying the system performing the authentications.
14046 Methods that might be present in the result include:
14047 </para>
14048 <literallayout class="monospaced">
14049 none
14050 iprev
14051 auth
14052 spf
14053 dkim
14054 </literallayout>
14055 <para>
14056 Example use (as an ACL modifier):
14057 </para>
14058 <literallayout class="monospaced">
14059       add_header = :at_start:${authresults {$primary_hostname}}
14060 </literallayout>
14061 <para>
14062 This is safe even if no authentication results are available.
14063 </para>
14064 </listitem></varlistentry>
14065 <varlistentry>
14066 <term><emphasis role="bold">${certextract{</emphasis>&lt;<emphasis>field</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>certificate</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>
14067 <listitem>
14068 <para>
14069 <indexterm role="concept">
14070 <primary>expansion</primary>
14071 <secondary>extracting certificate fields</secondary>
14072 </indexterm>
14073 <indexterm role="concept">
14074 <primary><option>certextract</option></primary>
14075 <secondary>certificate fields</secondary>
14076 </indexterm>
14077 <indexterm role="concept">
14078 <primary>certificate</primary>
14079 <secondary>extracting fields</secondary>
14080 </indexterm>
14081 The &lt;<emphasis>certificate</emphasis>&gt; must be a variable of type certificate.
14082 The field name is expanded and used to retrieve the relevant field from
14083 the certificate.  Supported fields are:
14084 </para>
14085 <literallayout>
14086 <literal>version        </literal>
14087 <literal>serial_number  </literal>
14088 <literal>subject        </literal> RFC4514 DN
14089 <literal>issuer         </literal> RFC4514 DN
14090 <literal>notbefore      </literal> time
14091 <literal>notafter       </literal> time
14092 <literal>sig_algorithm  </literal>
14093 <literal>signature      </literal>
14094 <literal>subj_altname   </literal> tagged list
14095 <literal>ocsp_uri       </literal> list
14096 <literal>crl_uri        </literal> list
14097 </literallayout>
14098 <para>
14099 If the field is found,
14100 &lt;<emphasis>string2</emphasis>&gt; is expanded, and replaces the whole item;
14101 otherwise &lt;<emphasis>string3</emphasis>&gt; is used. During the expansion of &lt;<emphasis>string2</emphasis>&gt; the
14102 variable <varname>$value</varname> contains the value that has been extracted. Afterwards, it
14103 is restored to any previous value it might have had.
14104 </para>
14105 <para>
14106 If {&lt;<emphasis>string3</emphasis>&gt;} is omitted, the item is replaced by an empty string if the
14107 key is not found. If {&lt;<emphasis>string2</emphasis>&gt;} is also omitted, the value that was
14108 extracted is used.
14109 </para>
14110 <para>
14111 Some field names take optional modifiers, appended and separated by commas.
14112 </para>
14113 <para>
14114 The field selectors marked as "RFC4514" above
14115 output a Distinguished Name string which is
14116 not quite
14117 parseable by Exim as a comma-separated tagged list
14118 (the exceptions being elements containing commas).
14119 RDN elements of a single type may be selected by
14120 a modifier of the type label; if so the expansion
14121 result is a list (newline-separated by default).
14122 The separator may be changed by another modifier of
14123 a right angle-bracket followed immediately by the new separator.
14124 Recognised RDN type labels include "CN", "O", "OU" and "DC".
14125 </para>
14126 <para>
14127 The field selectors marked as "time" above
14128 take an optional modifier of "int"
14129 for which the result is the number of seconds since epoch.
14130 Otherwise the result is a human-readable string
14131 in the timezone selected by the main "timezone" option.
14132 </para>
14133 <para>
14134 The field selectors marked as "list" above return a list,
14135 newline-separated by default,
14136 (embedded separator characters in elements are doubled).
14137 The separator may be changed by a modifier of
14138 a right angle-bracket followed immediately by the new separator.
14139 </para>
14140 <para>
14141 The field selectors marked as "tagged" above
14142 prefix each list element with a type string and an equals sign.
14143 Elements of only one type may be selected by a modifier
14144 which is one of "dns", "uri" or "mail";
14145 if so the element tags are omitted.
14146 </para>
14147 <para>
14148 If not otherwise noted field values are presented in human-readable form.
14149 </para>
14150 </listitem></varlistentry>
14151 <varlistentry>
14152 <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>
14153 <listitem>
14154 <para>
14155 <indexterm role="concept">
14156 <primary><option>dlfunc</option></primary>
14157 </indexterm>
14158 This expansion dynamically loads and then calls a locally-written C function.
14159 This functionality is available only if Exim is compiled with
14160 </para>
14161 <literallayout class="monospaced">
14162 EXPAND_DLFUNC=yes
14163 </literallayout>
14164 <para>
14165 set in <filename>Local/Makefile</filename>. Once loaded, Exim remembers the dynamically loaded
14166 object so that it doesn&#x2019;t reload the same object file in the same Exim process
14167 (but of course Exim does start new processes frequently).
14168 </para>
14169 <para>
14170 There may be from zero to eight arguments to the function.
14171 </para>
14172 <para revisionflag="changed">
14173 When compiling
14174 a local function that is to be called in this way,
14175 first <filename>DLFUNC_IMPL</filename> should be defined,
14176 and second <filename>local_scan.h</filename> should be included.
14177 </para>
14178 <para>
14179 The Exim variables and functions that are defined by that API
14180 are also available for dynamically loaded functions. The function itself
14181 must have the following type:
14182 </para>
14183 <literallayout class="monospaced">
14184 int dlfunction(uschar **yield, int argc, uschar *argv[])
14185 </literallayout>
14186 <para>
14187 Where <literal>uschar</literal> is a typedef for <literal>unsigned char</literal> in <filename>local_scan.h</filename>. The
14188 function should return one of the following values:
14189 </para>
14190 <para>
14191 <literal>OK</literal>: Success. The string that is placed in the variable <emphasis>yield</emphasis> is put
14192 into the expanded string that is being built.
14193 </para>
14194 <para>
14195 <literal>FAIL</literal>: A non-forced expansion failure occurs, with the error message taken
14196 from <emphasis>yield</emphasis>, if it is set.
14197 </para>
14198 <para>
14199 <literal>FAIL_FORCED</literal>: A forced expansion failure occurs, with the error message
14200 taken from <emphasis>yield</emphasis> if it is set.
14201 </para>
14202 <para>
14203 <literal>ERROR</literal>: Same as <literal>FAIL</literal>, except that a panic log entry is written.
14204 </para>
14205 <para>
14206 When compiling a function that is to be used in this way with gcc,
14207 you need to add <option>-shared</option> to the gcc command. Also, in the Exim build-time
14208 configuration, you must add <option>-export-dynamic</option> to EXTRALIBS.
14209 </para>
14210 </listitem></varlistentry>
14211 <varlistentry>
14212 <term><emphasis role="bold">${env{</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></term>
14213 <listitem>
14214 <para>
14215 <indexterm role="concept">
14216 <primary>expansion</primary>
14217 <secondary>extracting value from environment</secondary>
14218 </indexterm>
14219 <indexterm role="concept">
14220 <primary>environment</primary>
14221 <secondary>values from</secondary>
14222 </indexterm>
14223 The key is first expanded separately, and leading and trailing white space
14224 removed.
14225 This is then searched for as a name in the environment.
14226 If a variable is found then its value is placed in <varname>$value</varname>
14227 and &lt;<emphasis>string1</emphasis>&gt; is expanded, otherwise &lt;<emphasis>string2</emphasis>&gt; is expanded.
14228 </para>
14229 <para>
14230 Instead of {&lt;<emphasis>string2</emphasis>&gt;} the word <quote>fail</quote> (not in curly brackets) can
14231 appear, for example:
14232 </para>
14233 <literallayout class="monospaced">
14234 ${env{USER}{$value} fail }
14235 </literallayout>
14236 <para>
14237 This forces an expansion failure (see section <xref linkend="SECTforexpfai"/>);
14238 {&lt;<emphasis>string1</emphasis>&gt;} must be present for <quote>fail</quote> to be recognized.
14239 </para>
14240 <para>
14241 If {&lt;<emphasis>string2</emphasis>&gt;} is omitted an empty string is substituted on
14242 search failure.
14243 If {&lt;<emphasis>string1</emphasis>&gt;} is omitted the search result is substituted on
14244 search success.
14245 </para>
14246 <para>
14247 The environment is adjusted by the <option>keep_environment</option> and
14248 <option>add_environment</option> main section options.
14249 </para>
14250 </listitem></varlistentry>
14251 <varlistentry>
14252 <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>
14253 <listitem>
14254 <para>
14255 <indexterm role="concept">
14256 <primary>expansion</primary>
14257 <secondary>extracting substrings by key</secondary>
14258 </indexterm>
14259 <indexterm role="concept">
14260 <primary><option>extract</option></primary>
14261 <secondary>substrings by key</secondary>
14262 </indexterm>
14263 The key and &lt;<emphasis>string1</emphasis>&gt; are first expanded separately. Leading and trailing
14264 white space is removed from the key (but not from any of the strings). The key
14265 must not be empty and must not consist entirely of digits.
14266 The expanded &lt;<emphasis>string1</emphasis>&gt; must be of the form:
14267 </para>
14268 <literallayout>
14269 &lt;<emphasis>key1</emphasis>&gt; = &lt;<emphasis>value1</emphasis>&gt;  &lt;<emphasis>key2</emphasis>&gt; = &lt;<emphasis>value2</emphasis>&gt; ...
14270 </literallayout>
14271 <para>
14272 <indexterm role="variable">
14273 <primary><varname>$value</varname></primary>
14274 </indexterm>
14275 where the equals signs and spaces (but not both) are optional. If any of the
14276 values contain white space, they must be enclosed in double quotes, and any
14277 values that are enclosed in double quotes are subject to escape processing as
14278 described in section <xref linkend="SECTstrings"/>. The expanded &lt;<emphasis>string1</emphasis>&gt; is searched
14279 for the value that corresponds to the key. The search is case-insensitive. If
14280 the key is found, &lt;<emphasis>string2</emphasis>&gt; is expanded, and replaces the whole item;
14281 otherwise &lt;<emphasis>string3</emphasis>&gt; is used. During the expansion of &lt;<emphasis>string2</emphasis>&gt; the
14282 variable <varname>$value</varname> contains the value that has been extracted. Afterwards, it
14283 is restored to any previous value it might have had.
14284 </para>
14285 <para>
14286 If {&lt;<emphasis>string3</emphasis>&gt;} is omitted, the item is replaced by an empty string if the
14287 key is not found. If {&lt;<emphasis>string2</emphasis>&gt;} is also omitted, the value that was
14288 extracted is used. Thus, for example, these two expansions are identical, and
14289 yield <quote>2001</quote>:
14290 </para>
14291 <literallayout class="monospaced">
14292 ${extract{gid}{uid=1984 gid=2001}}
14293 ${extract{gid}{uid=1984 gid=2001}{$value}}
14294 </literallayout>
14295 <para>
14296 Instead of {&lt;<emphasis>string3</emphasis>&gt;} the word <quote>fail</quote> (not in curly brackets) can
14297 appear, for example:
14298 </para>
14299 <literallayout class="monospaced">
14300 ${extract{Z}{A=... B=...}{$value} fail }
14301 </literallayout>
14302 <para>
14303 This forces an expansion failure (see section <xref linkend="SECTforexpfai"/>);
14304 {&lt;<emphasis>string2</emphasis>&gt;} must be present for <quote>fail</quote> to be recognized.
14305 </para>
14306 </listitem></varlistentry>
14307 <varlistentry>
14308 <term><emphasis role="bold">${extract json{</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>
14309 <term><emphasis role="bold">${extract jsons{</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>
14310 <listitem>
14311 <para>
14312 <indexterm role="concept">
14313 <primary>expansion</primary>
14314 <secondary>extracting from JSON object</secondary>
14315 </indexterm>
14316 <indexterm role="concept">
14317 <primary>JSON</primary>
14318 <secondary>expansions</secondary>
14319 </indexterm>
14320 The key and &lt;<emphasis>string1</emphasis>&gt; are first expanded separately. Leading and trailing
14321 white space is removed from the key (but not from any of the strings). The key
14322 must not be empty and must not consist entirely of digits.
14323 The expanded &lt;<emphasis>string1</emphasis>&gt; must be of the form:
14324 </para>
14325 <literallayout>
14326 { &lt;<emphasis>"key1"</emphasis>&gt; : &lt;<emphasis>value1</emphasis>&gt; ,  &lt;<emphasis>"key2"</emphasis>&gt; , &lt;<emphasis>value2</emphasis>&gt; ... }
14327 </literallayout>
14328 <para>
14329 <indexterm role="variable">
14330 <primary><varname>$value</varname></primary>
14331 </indexterm>
14332 The braces, commas and colons, and the quoting of the member name are required;
14333 the spaces are optional.
14334 Matching of the key against the member names is done case-sensitively.
14335 For the <quote>json</quote> variant,
14336 if a returned value is a JSON string, it retains its leading and
14337 trailing quotes.
14338 </para>
14339 <para revisionflag="changed">
14340 For the <quote>jsons</quote> variant, which is intended for use with JSON strings, the
14341 leading and trailing quotes are removed from the returned value.
14342 </para>
14343 <para>
14344 The results of matching are handled as above.
14345 </para>
14346 </listitem></varlistentry>
14347 <varlistentry>
14348 <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>
14349 <listitem>
14350 <para>
14351 <indexterm role="concept">
14352 <primary>expansion</primary>
14353 <secondary>extracting substrings by number</secondary>
14354 </indexterm>
14355 <indexterm role="concept">
14356 <primary><option>extract</option></primary>
14357 <secondary>substrings by number</secondary>
14358 </indexterm>
14359 The &lt;<emphasis>number</emphasis>&gt; argument must consist entirely of decimal digits,
14360 apart from leading and trailing white space, which is ignored.
14361 This is what distinguishes this form of <option>extract</option> from the previous kind. It
14362 behaves in the same way, except that, instead of extracting a named field, it
14363 extracts from &lt;<emphasis>string1</emphasis>&gt; the field whose number is given as the first
14364 argument. You can use <varname>$value</varname> in &lt;<emphasis>string2</emphasis>&gt; or <literal>fail</literal> instead of
14365 &lt;<emphasis>string3</emphasis>&gt; as before.
14366 </para>
14367 <para>
14368 The fields in the string are separated by any one of the characters in the
14369 separator string. These may include space or tab characters.
14370 The first field is numbered one. If the number is negative, the fields are
14371 counted from the end of the string, with the rightmost one numbered -1. If the
14372 number given is zero, the entire string is returned. If the modulus of the
14373 number is greater than the number of fields in the string, the result is the
14374 expansion of &lt;<emphasis>string3</emphasis>&gt;, or the empty string if &lt;<emphasis>string3</emphasis>&gt; is not
14375 provided. For example:
14376 </para>
14377 <literallayout class="monospaced">
14378 ${extract{2}{:}{x:42:99:&amp; Mailer::/bin/bash}}
14379 </literallayout>
14380 <para>
14381 yields <quote>42</quote>, and
14382 </para>
14383 <literallayout class="monospaced">
14384 ${extract{-4}{:}{x:42:99:&amp; Mailer::/bin/bash}}
14385 </literallayout>
14386 <para>
14387 yields <quote>99</quote>. Two successive separators mean that the field between them is
14388 empty (for example, the fifth field above).
14389 </para>
14390 </listitem></varlistentry>
14391 <varlistentry>
14392 <term><emphasis role="bold">${extract json {</emphasis>&lt;<emphasis>number</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>
14393 <term><emphasis role="bold">${extract jsons{</emphasis>&lt;<emphasis>number</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>
14394 <listitem>
14395 <para>
14396 <indexterm role="concept">
14397 <primary>expansion</primary>
14398 <secondary>extracting from JSON array</secondary>
14399 </indexterm>
14400 <indexterm role="concept">
14401 <primary>JSON</primary>
14402 <secondary>expansions</secondary>
14403 </indexterm>
14404 The &lt;<emphasis>number</emphasis>&gt; argument must consist entirely of decimal digits,
14405 apart from leading and trailing white space, which is ignored.
14406 </para>
14407 <para>
14408 Field selection and result handling is as above;
14409 there is no choice of field separator.
14410 For the <quote>json</quote> variant,
14411 if a returned value is a JSON string, it retains its leading and
14412 trailing quotes.
14413 </para>
14414 <para revisionflag="changed">
14415 For the <quote>jsons</quote> variant, which is intended for use with JSON strings, the
14416 leading and trailing quotes are removed from the returned value.
14417 </para>
14418 </listitem></varlistentry>
14419 <varlistentry>
14420 <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>
14421 <listitem>
14422 <para>
14423 <indexterm role="concept">
14424 <primary>list</primary>
14425 <secondary>selecting by condition</secondary>
14426 </indexterm>
14427 <indexterm role="concept">
14428 <primary>expansion</primary>
14429 <secondary>selecting from list by condition</secondary>
14430 </indexterm>
14431 <indexterm role="variable">
14432 <primary><varname>$item</varname></primary>
14433 </indexterm>
14434 After expansion, &lt;<emphasis>string</emphasis>&gt; is interpreted as a list, colon-separated by
14435 default, but the separator can be changed in the usual way (<xref linkend="SECTlistsepchange"/>).
14436 For each item
14437 in this list, its value is place in <varname>$item</varname>, and then the condition is
14438 evaluated. If the condition is true, <varname>$item</varname> is added to the output as an
14439 item in a new list; if the condition is false, the item is discarded. The
14440 separator used for the output list is the same as the one used for the
14441 input, but a separator setting is not included in the output. For example:
14442 </para>
14443 <literallayout class="monospaced">
14444 ${filter{a:b:c}{!eq{$item}{b}}}
14445 </literallayout>
14446 <para>
14447 yields <literal>a:c</literal>. At the end of the expansion, the value of <varname>$item</varname> is restored
14448 to what it was before. See also the <option>map</option> and <option>reduce</option> expansion items.
14449 </para>
14450 </listitem></varlistentry>
14451 <varlistentry>
14452 <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>
14453 <listitem>
14454 <para>
14455 <indexterm role="concept">
14456 <primary>hash function</primary>
14457 <secondary>textual</secondary>
14458 </indexterm>
14459 <indexterm role="concept">
14460 <primary>expansion</primary>
14461 <secondary>textual hash</secondary>
14462 </indexterm>
14463 This is a textual hashing function, and was the first to be implemented in
14464 early versions of Exim. In current releases, there are other hashing functions
14465 (numeric, MD5, and SHA-1), which are described below.
14466 </para>
14467 <para>
14468 The first two strings, after expansion, must be numbers. Call them &lt;<emphasis>m</emphasis>&gt; and
14469 &lt;<emphasis>n</emphasis>&gt;. If you are using fixed values for these numbers, that is, if
14470 &lt;<emphasis>string1</emphasis>&gt; and &lt;<emphasis>string2</emphasis>&gt; do not change when they are expanded, you can
14471 use the simpler operator notation that avoids some of the braces:
14472 </para>
14473 <literallayout class="monospaced">
14474 ${hash_&lt;n&gt;_&lt;m&gt;:&lt;string&gt;}
14475 </literallayout>
14476 <para>
14477 The second number is optional (in both notations). If &lt;<emphasis>n</emphasis>&gt; is greater than
14478 or equal to the length of the string, the expansion item returns the string.
14479 Otherwise it computes a new string of length &lt;<emphasis>n</emphasis>&gt; by applying a hashing
14480 function to the string. The new string consists of characters taken from the
14481 first &lt;<emphasis>m</emphasis>&gt; characters of the string
14482 </para>
14483 <literallayout class="monospaced">
14484 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQWRSTUVWXYZ0123456789
14485 </literallayout>
14486 <para>
14487 If &lt;<emphasis>m</emphasis>&gt; is not present the value 26 is used, so that only lower case
14488 letters appear. For example:
14489 </para>
14490 <literallayout>
14491 <literal>$hash{3}{monty}}           </literal>   yields  <literal>jmg</literal>
14492 <literal>$hash{5}{monty}}           </literal>   yields  <literal>monty</literal>
14493 <literal>$hash{4}{62}{monty python}}</literal>   yields  <literal>fbWx</literal>
14494 </literallayout>
14495 </listitem></varlistentry>
14496 <varlistentry>
14497 <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>
14498 <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>
14499 <term><emphasis role="bold">$lheader_</emphasis>&lt;<emphasis>header&nbsp;name</emphasis>&gt;<emphasis role="bold">:</emphasis>&nbsp;or&nbsp;<emphasis role="bold">$lh_</emphasis>&lt;<emphasis>header&nbsp;name</emphasis>&gt;<emphasis role="bold">:</emphasis></term>
14500 <listitem>
14501 <para>
14502        "<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>"
14503 <indexterm role="concept">
14504 <primary>expansion</primary>
14505 <secondary>header insertion</secondary>
14506 </indexterm>
14507 <indexterm role="variable">
14508 <primary><varname>$header_</varname></primary>
14509 </indexterm>
14510 <indexterm role="variable">
14511 <primary><varname>$bheader_</varname></primary>
14512 </indexterm>
14513 <indexterm role="variable">
14514 <primary><varname>$lheader_</varname></primary>
14515 </indexterm>
14516 <indexterm role="variable">
14517 <primary><varname>$rheader_</varname></primary>
14518 </indexterm>
14519 <indexterm role="concept">
14520 <primary>header lines</primary>
14521 <secondary>in expansion strings</secondary>
14522 </indexterm>
14523 <indexterm role="concept">
14524 <primary>header lines</primary>
14525 <secondary>character sets</secondary>
14526 </indexterm>
14527 <indexterm role="concept">
14528 <primary>header lines</primary>
14529 <secondary>decoding</secondary>
14530 </indexterm>
14531 Substitute the contents of the named message header line, for example
14532 </para>
14533 <literallayout class="monospaced">
14534 $header_reply-to:
14535 </literallayout>
14536 <para>
14537 The newline that terminates a header line is not included in the expansion, but
14538 internal newlines (caused by splitting the header line over several physical
14539 lines) may be present.
14540 </para>
14541 <para>
14542 The difference between the four pairs of expansions is in the way
14543 the data in the header line is interpreted.
14544 </para>
14545 <itemizedlist>
14546 <listitem>
14547 <para>
14548 <indexterm role="concept">
14549 <primary>white space</primary>
14550 <secondary>in header lines</secondary>
14551 </indexterm>
14552 <option>rheader</option> gives the original <quote>raw</quote> content of the header line, with no
14553 processing at all, and without the removal of leading and trailing white space.
14554 </para>
14555 </listitem>
14556 <listitem>
14557 <para>
14558 <indexterm role="concept">
14559 <primary>list</primary>
14560 <secondary>of header lines</secondary>
14561 </indexterm>
14562 <option>lheader</option> gives a colon-separated list, one element per header when there
14563 are multiple headers with a given name.
14564 Any embedded colon characters within an element are doubled, so normal Exim
14565 list-processing facilities can be used.
14566 The terminating newline of each element is removed; in other respects
14567 the content is <quote>raw</quote>.
14568 </para>
14569 </listitem>
14570 <listitem>
14571 <para>
14572 <indexterm role="concept">
14573 <primary>base64 encoding</primary>
14574 <secondary>in header lines</secondary>
14575 </indexterm>
14576 <option>bheader</option> removes leading and trailing white space, and then decodes base64
14577 or quoted-printable MIME <quote>words</quote> within the header text, but does no
14578 character set translation. If decoding of what looks superficially like a MIME
14579 <quote>word</quote> fails, the raw string is returned. If decoding
14580 <indexterm role="concept">
14581 <primary>binary zero</primary>
14582 <secondary>in header line</secondary>
14583 </indexterm>
14584 produces a binary zero character, it is replaced by a question mark &ndash; this is
14585 what Exim does for binary zeros that are actually received in header lines.
14586 </para>
14587 </listitem>
14588 <listitem>
14589 <para>
14590 <option>header</option> tries to translate the string as decoded by <option>bheader</option> to a
14591 standard character set. This is an attempt to produce the same string as would
14592 be displayed on a user&#x2019;s MUA. If translation fails, the <option>bheader</option> string is
14593 returned. Translation is attempted only on operating systems that support the
14594 <function>iconv()</function> function. This is indicated by the compile-time macro HAVE_ICONV in
14595 a system Makefile or in <filename>Local/Makefile</filename>.
14596 </para>
14597 </listitem>
14598 </itemizedlist>
14599 <para>
14600 In a filter file, the target character set for <option>header</option> can be specified by a
14601 command of the following form:
14602 </para>
14603 <literallayout class="monospaced">
14604 headers charset "UTF-8"
14605 </literallayout>
14606 <para>
14607 This command affects all references to <varname>$h_</varname> (or <varname>$header_</varname>) expansions in
14608 subsequently obeyed filter commands. In the absence of this command, the target
14609 character set in a filter is taken from the setting of the <option>headers_charset</option>
14610 option in the runtime configuration. The value of this option defaults to the
14611 value of HEADERS_CHARSET in <filename>Local/Makefile</filename>. The ultimate default is
14612 ISO-8859-1.
14613 </para>
14614 <para>
14615 Header names follow the syntax of RFC 2822, which states that they may contain
14616 any printing characters except space and colon. Consequently, curly brackets
14617 <emphasis>do not</emphasis> terminate header names, and should not be used to enclose them as
14618 if they were variables. Attempting to do so causes a syntax error.
14619 </para>
14620 <para>
14621 Only header lines that are common to all copies of a message are visible to
14622 this mechanism. These are the original header lines that are received with the
14623 message, and any that are added by an ACL statement or by a system
14624 filter. Header lines that are added to a particular copy of a message by a
14625 router or transport are not accessible.
14626 </para>
14627 <para>
14628 For incoming SMTP messages, no header lines are visible in
14629 ACLs that are obeyed before the data phase completes,
14630 because the header structure is not set up until the message is received.
14631 They are visible in DKIM, PRDR and DATA ACLs.
14632 Header lines that are added in a RCPT ACL (for example)
14633 are saved until the message&#x2019;s incoming header lines are available, at which
14634 point they are added.
14635 When any of the above ACLs ar
14636 running, however, header lines added by earlier ACLs are visible.
14637 </para>
14638 <para>
14639 Upper case and lower case letters are synonymous in header names. If the
14640 following character is white space, the terminating colon may be omitted, but
14641 this is not recommended, because you may then forget it when it is needed. When
14642 white space terminates the header name, this white space is included in the
14643 expanded string.  If the message does not contain the given header, the
14644 expansion item is replaced by an empty string. (See the <option>def</option> condition in
14645 section <xref linkend="SECTexpcond"/> for a means of testing for the existence of a
14646 header.)
14647 </para>
14648 <para>
14649 If there is more than one header with the same name, they are all concatenated
14650 to form the substitution string, up to a maximum length of 64K. Unless
14651 <option>rheader</option> is being used, leading and trailing white space is removed from
14652 each header before concatenation, and a completely empty header is ignored. A
14653 newline character is then inserted between non-empty headers, but there is no
14654 newline at the very end. For the <option>header</option> and <option>bheader</option> expansion, for
14655 those headers that contain lists of addresses, a comma is also inserted at the
14656 junctions between headers. This does not happen for the <option>rheader</option> expansion.
14657 </para>
14658 </listitem></varlistentry>
14659 <varlistentry>
14660 <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>
14661 <listitem>
14662 <para>
14663 <indexterm role="concept">
14664 <primary>expansion</primary>
14665 <secondary>hmac hashing</secondary>
14666 </indexterm>
14667 <indexterm role="concept">
14668 <primary><option>hmac</option></primary>
14669 </indexterm>
14670 This function uses cryptographic hashing (either MD5 or SHA-1) to convert a
14671 shared secret and some text into a message authentication code, as specified in
14672 RFC 2104. This differs from <literal>${md5:secret_text...}</literal> or
14673 <literal>${sha1:secret_text...}</literal> in that the hmac step adds a signature to the
14674 cryptographic hash, allowing for authentication that is not possible with MD5
14675 or SHA-1 alone. The hash name must expand to either <literal>md5</literal> or <literal>sha1</literal> at
14676 present. For example:
14677 </para>
14678 <literallayout class="monospaced">
14679 ${hmac{md5}{somesecret}{$primary_hostname $tod_log}}
14680 </literallayout>
14681 <para>
14682 For the hostname <emphasis>mail.example.com</emphasis> and time 2002-10-17 11:30:59, this
14683 produces:
14684 </para>
14685 <literallayout class="monospaced">
14686 dd97e3ba5d1a61b5006108f8c8252953
14687 </literallayout>
14688 <para>
14689 As an example of how this might be used, you might put in the main part of
14690 an Exim configuration:
14691 </para>
14692 <literallayout class="monospaced">
14693 SPAMSCAN_SECRET=cohgheeLei2thahw
14694 </literallayout>
14695 <para>
14696 In a router or a transport you could then have:
14697 </para>
14698 <literallayout class="monospaced">
14699 headers_add = \
14700   X-Spam-Scanned: ${primary_hostname} ${message_exim_id} \
14701   ${hmac{md5}{SPAMSCAN_SECRET}\
14702   {${primary_hostname},${message_exim_id},$h_message-id:}}
14703 </literallayout>
14704 <para>
14705 Then given a message, you can check where it was scanned by looking at the
14706 <emphasis>X-Spam-Scanned:</emphasis> header line. If you know the secret, you can check that
14707 this header line is authentic by recomputing the authentication code from the
14708 host name, message ID and the <emphasis>Message-id:</emphasis> header line. This can be done
14709 using Exim&#x2019;s <option>-be</option> option, or by other means, for example, by using the
14710 <emphasis>hmac_md5_hex()</emphasis> function in Perl.
14711 </para>
14712 </listitem></varlistentry>
14713 <varlistentry>
14714 <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>
14715 <listitem>
14716 <para>
14717 <indexterm role="concept">
14718 <primary>expansion</primary>
14719 <secondary>conditional</secondary>
14720 </indexterm>
14721 <indexterm role="concept">
14722 <primary><option>if</option>, expansion item</primary>
14723 </indexterm>
14724 If &lt;<emphasis>condition</emphasis>&gt; is true, &lt;<emphasis>string1</emphasis>&gt; is expanded and replaces the whole
14725 item; otherwise &lt;<emphasis>string2</emphasis>&gt; is used. The available conditions are described
14726 in section <xref linkend="SECTexpcond"/> below. For example:
14727 </para>
14728 <literallayout class="monospaced">
14729 ${if eq {$local_part}{postmaster} {yes}{no} }
14730 </literallayout>
14731 <para>
14732 The second string need not be present; if it is not and the condition is not
14733 true, the item is replaced with nothing. Alternatively, the word <quote>fail</quote> may
14734 be present instead of the second string (without any curly brackets). In this
14735 case, the expansion is forced to fail if the condition is not true (see section
14736 <xref linkend="SECTforexpfai"/>).
14737 </para>
14738 <para>
14739 If both strings are omitted, the result is the string <literal>true</literal> if the condition
14740 is true, and the empty string if the condition is false. This makes it less
14741 cumbersome to write custom ACL and router conditions. For example, instead of
14742 </para>
14743 <literallayout class="monospaced">
14744 condition = ${if &gt;{$acl_m4}{3}{true}{false}}
14745 </literallayout>
14746 <para>
14747 you can use
14748 </para>
14749 <literallayout class="monospaced">
14750 condition = ${if &gt;{$acl_m4}{3}}
14751 </literallayout>
14752 </listitem></varlistentry>
14753 <varlistentry>
14754 <term><emphasis role="bold">${imapfolder{</emphasis>&lt;<emphasis>foldername</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
14755 <listitem>
14756 <para>
14757 <indexterm role="concept">
14758 <primary>expansion</primary>
14759 <secondary>imap folder</secondary>
14760 </indexterm>
14761 <indexterm role="concept">
14762 <primary><option>imapfolder</option> expansion item</primary>
14763 </indexterm>
14764 This item converts a (possibly multilevel, or with non-ASCII characters)
14765 folder specification to a Maildir name for filesystem use.
14766 For information on internationalisation support see <xref linkend="SECTi18nMDA"/>.
14767 </para>
14768 </listitem></varlistentry>
14769 <varlistentry>
14770 <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>
14771 <listitem>
14772 <para>
14773 <indexterm role="concept">
14774 <primary>expansion</primary>
14775 <secondary>string truncation</secondary>
14776 </indexterm>
14777 <indexterm role="concept">
14778 <primary><option>length</option> expansion item</primary>
14779 </indexterm>
14780 The <option>length</option> item is used to extract the initial portion of a string. Both
14781 strings are expanded, and the first one must yield a number, &lt;<emphasis>n</emphasis>&gt;, say. If
14782 you are using a fixed value for the number, that is, if &lt;<emphasis>string1</emphasis>&gt; does not
14783 change when expanded, you can use the simpler operator notation that avoids
14784 some of the braces:
14785 </para>
14786 <literallayout class="monospaced">
14787 ${length_&lt;n&gt;:&lt;string&gt;}
14788 </literallayout>
14789 <para>
14790 The result of this item is either the first &lt;<emphasis>n</emphasis>&gt; bytes or the whole
14791 of &lt;<emphasis>string2</emphasis>&gt;, whichever is the shorter. Do not confuse <option>length</option> with
14792 <option>strlen</option>, which gives the length of a string.
14793 All measurement is done in bytes and is not UTF-8 aware.
14794 </para>
14795 </listitem></varlistentry>
14796 <varlistentry>
14797 <term><emphasis role="bold">${listextract{</emphasis>&lt;<emphasis>number</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>
14798 <listitem>
14799 <para>
14800 <indexterm role="concept">
14801 <primary>expansion</primary>
14802 <secondary>extracting list elements by number</secondary>
14803 </indexterm>
14804 <indexterm role="concept">
14805 <primary><option>listextract</option></primary>
14806 <secondary>extract list elements by number</secondary>
14807 </indexterm>
14808 <indexterm role="concept">
14809 <primary>list</primary>
14810 <secondary>extracting elements by number</secondary>
14811 </indexterm>
14812 The &lt;<emphasis>number</emphasis>&gt; argument must consist entirely of decimal digits,
14813 apart from an optional leading minus,
14814 and leading and trailing white space (which is ignored).
14815 </para>
14816 <para>
14817 After expansion, &lt;<emphasis>string1</emphasis>&gt; is interpreted as a list, colon-separated by
14818 default, but the separator can be changed in the usual way (<xref linkend="SECTlistsepchange"/>).
14819 </para>
14820 <para>
14821 The first field of the list is numbered one.
14822 If the number is negative, the fields are
14823 counted from the end of the list, with the rightmost one numbered -1.
14824 The numbered element of the list is extracted and placed in <varname>$value</varname>,
14825 then &lt;<emphasis>string2</emphasis>&gt; is expanded as the result.
14826 </para>
14827 <para>
14828 If the modulus of the
14829 number is zero or greater than the number of fields in the string,
14830 the result is the expansion of &lt;<emphasis>string3</emphasis>&gt;.
14831 </para>
14832 <para>
14833 For example:
14834 </para>
14835 <literallayout class="monospaced">
14836 ${listextract{2}{x:42:99}}
14837 </literallayout>
14838 <para>
14839 yields <quote>42</quote>, and
14840 </para>
14841 <literallayout class="monospaced">
14842 ${listextract{-3}{&lt;, x,42,99,&amp; Mailer,,/bin/bash}{result: $value}}
14843 </literallayout>
14844 <para>
14845 yields <quote>result: 42</quote>.
14846 </para>
14847 <para>
14848 If {&lt;<emphasis>string3</emphasis>&gt;} is omitted, an empty string is used for string3.
14849 If {&lt;<emphasis>string2</emphasis>&gt;} is also omitted, the value that was
14850 extracted is used.
14851 You can use <literal>fail</literal> instead of {&lt;<emphasis>string3</emphasis>&gt;} as in a string extract.
14852 </para>
14853 </listitem></varlistentry>
14854 <varlistentry>
14855 <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>
14856 <listitem>
14857 <para>
14858 This is the first of one of two different types of lookup item, which are both
14859 described in the next item.
14860 </para>
14861 </listitem></varlistentry>
14862 <varlistentry>
14863 <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>
14864 <listitem>
14865 <para>
14866 <indexterm role="concept">
14867 <primary>expansion</primary>
14868 <secondary>lookup in</secondary>
14869 </indexterm>
14870 <indexterm role="concept">
14871 <primary>file</primary>
14872 <secondary>lookups</secondary>
14873 </indexterm>
14874 <indexterm role="concept">
14875 <primary>lookup</primary>
14876 <secondary>in expanded string</secondary>
14877 </indexterm>
14878 The two forms of lookup item specify data lookups in files and databases, as
14879 discussed in chapter <xref linkend="CHAPfdlookup"/>. The first form is used for single-key
14880 lookups, and the second is used for query-style lookups. The &lt;<emphasis>key</emphasis>&gt;,
14881 &lt;<emphasis>file</emphasis>&gt;, and &lt;<emphasis>query</emphasis>&gt; strings are expanded before use.
14882 </para>
14883 <para>
14884 If there is any white space in a lookup item which is part of a filter command,
14885 a retry or rewrite rule, a routing rule for the <command>manualroute</command> router, or any
14886 other place where white space is significant, the lookup item must be enclosed
14887 in double quotes. The use of data lookups in users&#x2019; filter files may be locked
14888 out by the system administrator.
14889 </para>
14890 <para>
14891 <indexterm role="variable">
14892 <primary><varname>$value</varname></primary>
14893 </indexterm>
14894 If the lookup succeeds, &lt;<emphasis>string1</emphasis>&gt; is expanded and replaces the entire item.
14895 During its expansion, the variable <varname>$value</varname> contains the data returned by the
14896 lookup. Afterwards it reverts to the value it had previously (at the outer
14897 level it is empty). If the lookup fails, &lt;<emphasis>string2</emphasis>&gt; is expanded and replaces
14898 the entire item. If {&lt;<emphasis>string2</emphasis>&gt;} is omitted, the replacement is the empty
14899 string on failure. If &lt;<emphasis>string2</emphasis>&gt; is provided, it can itself be a nested
14900 lookup, thus providing a mechanism for looking up a default value when the
14901 original lookup fails.
14902 </para>
14903 <para>
14904 If a nested lookup is used as part of &lt;<emphasis>string1</emphasis>&gt;, <varname>$value</varname> contains the
14905 data for the outer lookup while the parameters of the second lookup are
14906 expanded, and also while &lt;<emphasis>string2</emphasis>&gt; of the second lookup is expanded, should
14907 the second lookup fail. Instead of {&lt;<emphasis>string2</emphasis>&gt;} the word <quote>fail</quote> can
14908 appear, and in this case, if the lookup fails, the entire expansion is forced
14909 to fail (see section <xref linkend="SECTforexpfai"/>). If both {&lt;<emphasis>string1</emphasis>&gt;} and
14910 {&lt;<emphasis>string2</emphasis>&gt;} are omitted, the result is the looked up value in the case of a
14911 successful lookup, and nothing in the case of failure.
14912 </para>
14913 <para>
14914 For single-key lookups, the string <quote>partial</quote> is permitted to precede the
14915 search type in order to do partial matching, and * or *@ may follow a search
14916 type to request default lookups if the key does not match (see sections
14917 <xref linkend="SECTdefaultvaluelookups"/> and <xref linkend="SECTpartiallookup"/> for details).
14918 </para>
14919 <para>
14920 <indexterm role="concept">
14921 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
14922 <secondary>in lookup expansion</secondary>
14923 </indexterm>
14924 If a partial search is used, the variables <varname>$1</varname> and <varname>$2</varname> contain the wild
14925 and non-wild parts of the key during the expansion of the replacement text.
14926 They return to their previous values at the end of the lookup item.
14927 </para>
14928 <para>
14929 This example looks up the postmaster alias in the conventional alias file:
14930 </para>
14931 <literallayout class="monospaced">
14932 ${lookup {postmaster} lsearch {/etc/aliases} {$value}}
14933 </literallayout>
14934 <para>
14935 This example uses NIS+ to look up the full name of the user corresponding to
14936 the local part of an address, forcing the expansion to fail if it is not found:
14937 </para>
14938 <literallayout class="monospaced">
14939 ${lookup nisplus {[name=$local_part],passwd.org_dir:gcos} \
14940   {$value}fail}
14941 </literallayout>
14942 </listitem></varlistentry>
14943 <varlistentry>
14944 <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>
14945 <listitem>
14946 <para>
14947 <indexterm role="concept">
14948 <primary>expansion</primary>
14949 <secondary>list creation</secondary>
14950 </indexterm>
14951 <indexterm role="variable">
14952 <primary><varname>$item</varname></primary>
14953 </indexterm>
14954 After expansion, &lt;<emphasis>string1</emphasis>&gt; is interpreted as a list, colon-separated by
14955 default, but the separator can be changed in the usual way (<xref linkend="SECTlistsepchange"/>).
14956 For each item
14957 in this list, its value is place in <varname>$item</varname>, and then &lt;<emphasis>string2</emphasis>&gt; is
14958 expanded and added to the output as an item in a new list. The separator used
14959 for the output list is the same as the one used for the input, but a separator
14960 setting is not included in the output. For example:
14961 </para>
14962 <literallayout class="monospaced">
14963 ${map{a:b:c}{[$item]}} ${map{&lt;- x-y-z}{($item)}}
14964 </literallayout>
14965 <para>
14966 expands to <literal>[a]:[b]:[c] (x)-(y)-(z)</literal>. At the end of the expansion, the
14967 value of <varname>$item</varname> is restored to what it was before. See also the <option>filter</option>
14968 and <option>reduce</option> expansion items.
14969 </para>
14970 </listitem></varlistentry>
14971 <varlistentry>
14972 <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>
14973 <listitem>
14974 <para>
14975 <indexterm role="concept">
14976 <primary>expansion</primary>
14977 <secondary>numeric hash</secondary>
14978 </indexterm>
14979 <indexterm role="concept">
14980 <primary>hash function</primary>
14981 <secondary>numeric</secondary>
14982 </indexterm>
14983 The three strings are expanded; the first two must yield numbers. Call them
14984 &lt;<emphasis>n</emphasis>&gt; and &lt;<emphasis>m</emphasis>&gt;. If you are using fixed values for these numbers, that is,
14985 if &lt;<emphasis>string1</emphasis>&gt; and &lt;<emphasis>string2</emphasis>&gt; do not change when they are expanded, you
14986 can use the simpler operator notation that avoids some of the braces:
14987 </para>
14988 <literallayout class="monospaced">
14989 ${nhash_&lt;n&gt;_&lt;m&gt;:&lt;string&gt;}
14990 </literallayout>
14991 <para>
14992 The second number is optional (in both notations). If there is only one number,
14993 the result is a number in the range 0&ndash;&lt;<emphasis>n</emphasis>&gt;-1. Otherwise, the string is
14994 processed by a div/mod hash function that returns two numbers, separated by a
14995 slash, in the ranges 0 to &lt;<emphasis>n</emphasis>&gt;-1 and 0 to &lt;<emphasis>m</emphasis>&gt;-1, respectively. For
14996 example,
14997 </para>
14998 <literallayout class="monospaced">
14999 ${nhash{8}{64}{supercalifragilisticexpialidocious}}
15000 </literallayout>
15001 <para>
15002 returns the string <quote>6/33</quote>.
15003 </para>
15004 </listitem></varlistentry>
15005 <varlistentry>
15006 <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>
15007 <listitem>
15008 <para>
15009 <indexterm role="concept">
15010 <primary>Perl</primary>
15011 <secondary>use in expanded string</secondary>
15012 </indexterm>
15013 <indexterm role="concept">
15014 <primary>expansion</primary>
15015 <secondary>calling Perl from</secondary>
15016 </indexterm>
15017 This item is available only if Exim has been built to include an embedded Perl
15018 interpreter. The subroutine name and the arguments are first separately
15019 expanded, and then the Perl subroutine is called with those arguments. No
15020 additional arguments need be given; the maximum number permitted, including the
15021 name of the subroutine, is nine.
15022 </para>
15023 <para>
15024 The return value of the subroutine is inserted into the expanded string, unless
15025 the return value is <option>undef</option>. In that case, the expansion fails in the same
15026 way as an explicit <quote>fail</quote> on a lookup item. The return value is a scalar.
15027 Whatever you return is evaluated in a scalar context. For example, if you
15028 return the name of a Perl vector, the return value is the size of the vector,
15029 not its contents.
15030 </para>
15031 <para>
15032 If the subroutine exits by calling Perl&#x2019;s <option>die</option> function, the expansion fails
15033 with the error message that was passed to <option>die</option>. More details of the embedded
15034 Perl facility are given in chapter <xref linkend="CHAPperl"/>.
15035 </para>
15036 <para>
15037 The <command>redirect</command> router has an option called <option>forbid_filter_perl</option> which locks
15038 out the use of this expansion item in filter files.
15039 </para>
15040 </listitem></varlistentry>
15041 <varlistentry>
15042 <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>
15043 <listitem>
15044 <para>
15045 <indexterm role="concept">
15046 <primary><option>prvs</option> expansion item</primary>
15047 </indexterm>
15048 The first argument is a complete email address and the second is secret
15049 keystring. The third argument, specifying a key number, is optional. If absent,
15050 it defaults to 0. The result of the expansion is a prvs-signed email address,
15051 to be typically used with the <option>return_path</option> option on an <command>smtp</command> transport
15052 as part of a bounce address tag validation (BATV) scheme. For more discussion
15053 and an example, see section <xref linkend="SECTverifyPRVS"/>.
15054 </para>
15055 </listitem></varlistentry>
15056 <varlistentry>
15057 <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>
15058 <listitem>
15059 <para>
15060 <indexterm role="concept">
15061 <primary><option>prvscheck</option> expansion item</primary>
15062 </indexterm>
15063 This expansion item is the complement of the <option>prvs</option> item. It is used for
15064 checking prvs-signed addresses. If the expansion of the first argument does not
15065 yield a syntactically valid prvs-signed address, the whole item expands to the
15066 empty string. When the first argument does expand to a syntactically valid
15067 prvs-signed address, the second argument is expanded, with the prvs-decoded
15068 version of the address and the key number extracted from the address in the
15069 variables <varname>$prvscheck_address</varname> and <varname>$prvscheck_keynum</varname>, respectively.
15070 </para>
15071 <para>
15072 These two variables can be used in the expansion of the second argument to
15073 retrieve the secret. The validity of the prvs-signed address is then checked
15074 against the secret. The result is stored in the variable <varname>$prvscheck_result</varname>,
15075 which is empty for failure or <quote>1</quote> for success.
15076 </para>
15077 <para>
15078 The third argument is optional; if it is missing, it defaults to an empty
15079 string. This argument is now expanded. If the result is an empty string, the
15080 result of the expansion is the decoded version of the address. This is the case
15081 whether or not the signature was valid. Otherwise, the result of the expansion
15082 is the expansion of the third argument.
15083 </para>
15084 <para>
15085 All three variables can be used in the expansion of the third argument.
15086 However, once the expansion is complete, only <varname>$prvscheck_result</varname> remains set.
15087 For more discussion and an example, see section <xref linkend="SECTverifyPRVS"/>.
15088 </para>
15089 </listitem></varlistentry>
15090 <varlistentry>
15091 <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>
15092 <listitem>
15093 <para>
15094 <indexterm role="concept">
15095 <primary>expansion</primary>
15096 <secondary>inserting an entire file</secondary>
15097 </indexterm>
15098 <indexterm role="concept">
15099 <primary>file</primary>
15100 <secondary>inserting into expansion</secondary>
15101 </indexterm>
15102 <indexterm role="concept">
15103 <primary><option>readfile</option> expansion item</primary>
15104 </indexterm>
15105 The filename and end-of-line string are first expanded separately. The file is
15106 then read, and its contents replace the entire item. All newline characters in
15107 the file are replaced by the end-of-line string if it is present. Otherwise,
15108 newlines are left in the string.
15109 String expansion is not applied to the contents of the file. If you want this,
15110 you must wrap the item in an <option>expand</option> operator. If the file cannot be read,
15111 the string expansion fails.
15112 </para>
15113 <para>
15114 The <command>redirect</command> router has an option called <option>forbid_filter_readfile</option> which
15115 locks out the use of this expansion item in filter files.
15116 </para>
15117 </listitem></varlistentry>
15118 <varlistentry>
15119 <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>options</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>
15120 <listitem>
15121 <para>
15122 <indexterm role="concept">
15123 <primary>expansion</primary>
15124 <secondary>inserting from a socket</secondary>
15125 </indexterm>
15126 <indexterm role="concept">
15127 <primary>socket, use of in expansion</primary>
15128 </indexterm>
15129 <indexterm role="concept">
15130 <primary><option>readsocket</option> expansion item</primary>
15131 </indexterm>
15132 This item inserts data from a Unix domain or TCP socket into the expanded
15133 string. The minimal way of using it uses just two arguments, as in these
15134 examples:
15135 </para>
15136 <literallayout class="monospaced">
15137 ${readsocket{/socket/name}{request string}}
15138 ${readsocket{inet:some.host:1234}{request string}}
15139 </literallayout>
15140 <para>
15141 For a Unix domain socket, the first substring must be the path to the socket.
15142 For an Internet socket, the first substring must contain <literal>inet:</literal> followed by
15143 a host name or IP address, followed by a colon and a port, which can be a
15144 number or the name of a TCP port in <filename>/etc/services</filename>. An IP address may
15145 optionally be enclosed in square brackets. This is best for IPv6 addresses. For
15146 example:
15147 </para>
15148 <literallayout class="monospaced">
15149 ${readsocket{inet:[::1]:1234}{request string}}
15150 </literallayout>
15151 <para>
15152 Only a single host name may be given, but if looking it up yields more than
15153 one IP address, they are each tried in turn until a connection is made. For
15154 both kinds of socket, Exim makes a connection, writes the request string
15155 unless it is an empty string; and no terminating NUL is ever sent)
15156 and reads from the socket until an end-of-file
15157 is read. A timeout of 5 seconds is applied. Additional, optional arguments
15158 extend what can be done. Firstly, you can vary the timeout. For example:
15159 </para>
15160 <literallayout class="monospaced">
15161 ${readsocket{/socket/name}{request string}{3s}}
15162 </literallayout>
15163 <para>
15164 The third argument is a list of options, of which the first element is the timeout
15165 and must be present if the argument is given.
15166 Further elements are options of form <emphasis>name=value</emphasis>.
15167 Two option types is currently recognised: shutdown and tls.
15168 The first defines whether (the default)
15169 or not a shutdown is done on the connection after sending the request.
15170 Example, to not do so (preferred, eg. by some webservers):
15171 </para>
15172 <literallayout class="monospaced">
15173 ${readsocket{/socket/name}{request string}{3s:shutdown=no}}
15174 </literallayout>
15175 <para>
15176 The second, tls, controls the use of TLS on the connection.  Example:
15177 </para>
15178 <literallayout class="monospaced">
15179 ${readsocket{/socket/name}{request string}{3s:tls=yes}}
15180 </literallayout>
15181 <para>
15182 The default is to not use TLS.
15183 If it is enabled, a shutdown as descripbed above is never done.
15184 </para>
15185 <para>
15186 A fourth argument allows you to change any newlines that are in the data
15187 that is read, in the same way as for <option>readfile</option> (see above). This example
15188 turns them into spaces:
15189 </para>
15190 <literallayout class="monospaced">
15191 ${readsocket{inet:127.0.0.1:3294}{request string}{3s}{ }}
15192 </literallayout>
15193 <para>
15194 As with all expansions, the substrings are expanded before the processing
15195 happens. Errors in these sub-expansions cause the expansion to fail. In
15196 addition, the following errors can occur:
15197 </para>
15198 <itemizedlist>
15199 <listitem>
15200 <para>
15201 Failure to create a socket file descriptor;
15202 </para>
15203 </listitem>
15204 <listitem>
15205 <para>
15206 Failure to connect the socket;
15207 </para>
15208 </listitem>
15209 <listitem>
15210 <para>
15211 Failure to write the request string;
15212 </para>
15213 </listitem>
15214 <listitem>
15215 <para>
15216 Timeout on reading from the socket.
15217 </para>
15218 </listitem>
15219 </itemizedlist>
15220 <para>
15221 By default, any of these errors causes the expansion to fail. However, if
15222 you supply a fifth substring, it is expanded and used when any of the above
15223 errors occurs. For example:
15224 </para>
15225 <literallayout class="monospaced">
15226 ${readsocket{/socket/name}{request string}{3s}{\n}\
15227   {socket failure}}
15228 </literallayout>
15229 <para>
15230 You can test for the existence of a Unix domain socket by wrapping this
15231 expansion in <literal>${if exists</literal>, but there is a race condition between that test
15232 and the actual opening of the socket, so it is safer to use the fifth argument
15233 if you want to be absolutely sure of avoiding an expansion error for a
15234 non-existent Unix domain socket, or a failure to connect to an Internet socket.
15235 </para>
15236 <para>
15237 The <command>redirect</command> router has an option called <option>forbid_filter_readsocket</option> which
15238 locks out the use of this expansion item in filter files.
15239 </para>
15240 </listitem></varlistentry>
15241 <varlistentry>
15242 <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>
15243 <listitem>
15244 <para>
15245 <indexterm role="concept">
15246 <primary>expansion</primary>
15247 <secondary>reducing a list to a scalar</secondary>
15248 </indexterm>
15249 <indexterm role="concept">
15250 <primary>list</primary>
15251 <secondary>reducing to a scalar</secondary>
15252 </indexterm>
15253 <indexterm role="variable">
15254 <primary><varname>$value</varname></primary>
15255 </indexterm>
15256 <indexterm role="variable">
15257 <primary><varname>$item</varname></primary>
15258 </indexterm>
15259 This operation reduces a list to a single, scalar string. After expansion,
15260 &lt;<emphasis>string1</emphasis>&gt; is interpreted as a list, colon-separated by default, but the
15261 separator can be changed in the usual way (<xref linkend="SECTlistsepchange"/>).
15262 Then &lt;<emphasis>string2</emphasis>&gt; is expanded and
15263 assigned to the <varname>$value</varname> variable. After this, each item in the &lt;<emphasis>string1</emphasis>&gt;
15264 list is assigned to <varname>$item</varname>, in turn, and &lt;<emphasis>string3</emphasis>&gt; is expanded for each of
15265 them. The result of that expansion is assigned to <varname>$value</varname> before the next
15266 iteration. When the end of the list is reached, the final value of <varname>$value</varname> is
15267 added to the expansion output. The <option>reduce</option> expansion item can be used in a
15268 number of ways. For example, to add up a list of numbers:
15269 </para>
15270 <literallayout class="monospaced">
15271 ${reduce {&lt;, 1,2,3}{0}{${eval:$value+$item}}}
15272 </literallayout>
15273 <para>
15274 The result of that expansion would be <literal>6</literal>. The maximum of a list of numbers
15275 can be found:
15276 </para>
15277 <literallayout class="monospaced">
15278 ${reduce {3:0:9:4:6}{0}{${if &gt;{$item}{$value}{$item}{$value}}}}
15279 </literallayout>
15280 <para>
15281 At the end of a <emphasis role="bold">reduce</emphasis> expansion, the values of <varname>$item</varname> and <varname>$value</varname> are
15282 restored to what they were before. See also the <option>filter</option> and <option>map</option>
15283 expansion items.
15284 </para>
15285 </listitem></varlistentry>
15286 <varlistentry>
15287 <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>
15288 <listitem>
15289 <para>
15290 This item inserts <quote>raw</quote> header lines. It is described with the <option>header</option>
15291 expansion item in section <xref linkend="SECTexpansionitems"/> above.
15292 </para>
15293 </listitem></varlistentry>
15294 <varlistentry>
15295 <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>
15296 <listitem>
15297 <para>
15298 <indexterm role="concept">
15299 <primary>expansion</primary>
15300 <secondary>running a command</secondary>
15301 </indexterm>
15302 <indexterm role="concept">
15303 <primary><option>run</option> expansion item</primary>
15304 </indexterm>
15305 The command and its arguments are first expanded as one string. The string is
15306 split apart into individual arguments by spaces, and then the command is run
15307 in a separate process, but under the same uid and gid.  As in other command
15308 executions from Exim, a shell is not used by default. If the command requires
15309 a shell, you must explicitly code it.
15310 </para>
15311 <para>
15312 Since the arguments are split by spaces, when there is a variable expansion
15313 which has an empty result, it will cause the situation that the argument will
15314 simply be omitted when the program is actually executed by Exim. If the
15315 script/program requires a specific number of arguments and the expanded
15316 variable could possibly result in this empty expansion, the variable must be
15317 quoted. This is more difficult if the expanded variable itself could result
15318 in a string containing quotes, because it would interfere with the quotes
15319 around the command arguments. A possible guard against this is to wrap the
15320 variable in the <option>sg</option> operator to change any quote marks to some other
15321 character.
15322 </para>
15323 <para>
15324 The standard input for the command exists, but is empty. The standard output
15325 and standard error are set to the same file descriptor.
15326 <indexterm role="concept">
15327 <primary>return code</primary>
15328 <secondary>from <option>run</option> expansion</secondary>
15329 </indexterm>
15330 <indexterm role="variable">
15331 <primary><varname>$value</varname></primary>
15332 </indexterm>
15333 If the command succeeds (gives a zero return code) &lt;<emphasis>string1</emphasis>&gt; is expanded
15334 and replaces the entire item; during this expansion, the standard output/error
15335 from the command is in the variable <varname>$value</varname>. If the command fails,
15336 &lt;<emphasis>string2</emphasis>&gt;, if present, is expanded and used. Once again, during the
15337 expansion, the standard output/error from the command is in the variable
15338 <varname>$value</varname>.
15339 </para>
15340 <para>
15341 If &lt;<emphasis>string2</emphasis>&gt; is absent, the result is empty. Alternatively, &lt;<emphasis>string2</emphasis>&gt;
15342 can be the word <quote>fail</quote> (not in braces) to force expansion failure if the
15343 command does not succeed. If both strings are omitted, the result is contents
15344 of the standard output/error on success, and nothing on failure.
15345 </para>
15346 <para>
15347 <indexterm role="variable">
15348 <primary><varname>$run_in_acl</varname></primary>
15349 </indexterm>
15350 The standard output/error of the command is put in the variable <varname>$value</varname>.
15351 In this ACL example, the output of a command is logged for the admin to
15352 troubleshoot:
15353 </para>
15354 <literallayout class="monospaced">
15355 warn  condition    = ${run{/usr/bin/id}{yes}{no}}
15356       log_message  = Output of id: $value
15357 </literallayout>
15358 <para>
15359 If the command requires shell idioms, such as the &gt; redirect operator, the
15360 shell must be invoked directly, such as with:
15361 </para>
15362 <literallayout class="monospaced">
15363 ${run{/bin/bash -c "/usr/bin/id &gt;/tmp/id"}{yes}{yes}}
15364 </literallayout>
15365 <para>
15366 <indexterm role="variable">
15367 <primary><varname>$runrc</varname></primary>
15368 </indexterm>
15369 The return code from the command is put in the variable <varname>$runrc</varname>, and this
15370 remains set afterwards, so in a filter file you can do things like this:
15371 </para>
15372 <literallayout class="monospaced">
15373 if "${run{x y z}{}}$runrc" is 1 then ...
15374   elif $runrc is 2 then ...
15375   ...
15376 endif
15377 </literallayout>
15378 <para>
15379 If execution of the command fails (for example, the command does not exist),
15380 the return code is 127 &ndash; the same code that shells use for non-existent
15381 commands.
15382 </para>
15383 <para>
15384 <emphasis role="bold">Warning</emphasis>: In a router or transport, you cannot assume the order in which
15385 option values are expanded, except for those preconditions whose order of
15386 testing is documented. Therefore, you cannot reliably expect to set <varname>$runrc</varname>
15387 by the expansion of one option, and use it in another.
15388 </para>
15389 <para>
15390 The <command>redirect</command> router has an option called <option>forbid_filter_run</option> which locks
15391 out the use of this expansion item in filter files.
15392 </para>
15393 </listitem></varlistentry>
15394 <varlistentry>
15395 <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>
15396 <listitem>
15397 <para>
15398 <indexterm role="concept">
15399 <primary>expansion</primary>
15400 <secondary>string substitution</secondary>
15401 </indexterm>
15402 <indexterm role="concept">
15403 <primary><option>sg</option> expansion item</primary>
15404 </indexterm>
15405 This item works like Perl&#x2019;s substitution operator (s) with the global (/g)
15406 option; hence its name. However, unlike the Perl equivalent, Exim does not
15407 modify the subject string; instead it returns the modified string for insertion
15408 into the overall expansion. The item takes three arguments: the subject string,
15409 a regular expression, and a substitution string. For example:
15410 </para>
15411 <literallayout class="monospaced">
15412 ${sg{abcdefabcdef}{abc}{xyz}}
15413 </literallayout>
15414 <para>
15415 yields <quote>xyzdefxyzdef</quote>. Because all three arguments are expanded before use,
15416 if any $, } or \ characters are required in the regular expression or in the
15417 substitution string, they have to be escaped. For example:
15418 </para>
15419 <literallayout class="monospaced">
15420 ${sg{abcdef}{^(...)(...)\$}{\$2\$1}}
15421 </literallayout>
15422 <para>
15423 yields <quote>defabc</quote>, and
15424 </para>
15425 <literallayout class="monospaced">
15426 ${sg{1=A 4=D 3=C}{\N(\d+)=\N}{K\$1=}}
15427 </literallayout>
15428 <para>
15429 yields <quote>K1=A K4=D K3=C</quote>. Note the use of <literal>\N</literal> to protect the contents of
15430 the regular expression from string expansion.
15431 </para>
15432 <para>
15433 The regular expression is compiled in 8-bit mode, working against bytes
15434 rather than any Unicode-aware character handling.
15435 </para>
15436 </listitem></varlistentry>
15437 <varlistentry>
15438 <term><emphasis role="bold">${sort{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>comparator</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>extractor</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
15439 <listitem>
15440 <para>
15441 <indexterm role="concept">
15442 <primary>sorting</primary>
15443 <secondary>a list</secondary>
15444 </indexterm>
15445 <indexterm role="concept">
15446 <primary>list</primary>
15447 <secondary>sorting</secondary>
15448 </indexterm>
15449 <indexterm role="concept">
15450 <primary>expansion</primary>
15451 <secondary>list sorting</secondary>
15452 </indexterm>
15453 After expansion, &lt;<emphasis>string</emphasis>&gt; is interpreted as a list, colon-separated by
15454 default, but the separator can be changed in the usual way (<xref linkend="SECTlistsepchange"/>).
15455 The &lt;<emphasis>comparator</emphasis>&gt; argument is interpreted as the operator
15456 of a two-argument expansion condition.
15457 The numeric operators plus ge, gt, le, lt (and ~i variants) are supported.
15458 The comparison should return true when applied to two values
15459 if the first value should sort before the second value.
15460 The &lt;<emphasis>extractor</emphasis>&gt; expansion is applied repeatedly to elements of the list,
15461 the element being placed in <varname>$item</varname>,
15462 to give values for comparison.
15463 </para>
15464 <para>
15465 The item result is a sorted list,
15466 with the original list separator,
15467 of the list elements (in full) of the original.
15468 </para>
15469 <para>
15470 Examples:
15471 </para>
15472 <literallayout class="monospaced">
15473 ${sort{3:2:1:4}{&lt;}{$item}}
15474 </literallayout>
15475 <para>
15476 sorts a list of numbers, and
15477 </para>
15478 <literallayout class="monospaced">
15479 ${sort {${lookup dnsdb{&gt;:,,mx=example.com}}} {&lt;} {${listextract{1}{&lt;,$item}}}}
15480 </literallayout>
15481 <para>
15482 will sort an MX lookup into priority order.
15483 </para>
15484 </listitem></varlistentry>
15485 <varlistentry>
15486 <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>
15487 <listitem>
15488 <para>
15489 <indexterm role="concept">
15490 <primary><option>substr</option> expansion item</primary>
15491 </indexterm>
15492 <indexterm role="concept">
15493 <primary>substring extraction</primary>
15494 </indexterm>
15495 <indexterm role="concept">
15496 <primary>expansion</primary>
15497 <secondary>substring extraction</secondary>
15498 </indexterm>
15499 The three strings are expanded; the first two must yield numbers. Call them
15500 &lt;<emphasis>n</emphasis>&gt; and &lt;<emphasis>m</emphasis>&gt;. If you are using fixed values for these numbers, that is,
15501 if &lt;<emphasis>string1</emphasis>&gt; and &lt;<emphasis>string2</emphasis>&gt; do not change when they are expanded, you
15502 can use the simpler operator notation that avoids some of the braces:
15503 </para>
15504 <literallayout class="monospaced">
15505 ${substr_&lt;n&gt;_&lt;m&gt;:&lt;string&gt;}
15506 </literallayout>
15507 <para>
15508 The second number is optional (in both notations).
15509 If it is absent in the simpler format, the preceding underscore must also be
15510 omitted.
15511 </para>
15512 <para>
15513 The <option>substr</option> item can be used to extract more general substrings than
15514 <option>length</option>. The first number, &lt;<emphasis>n</emphasis>&gt;, is a starting offset, and &lt;<emphasis>m</emphasis>&gt; is the
15515 length required. For example
15516 </para>
15517 <literallayout class="monospaced">
15518 ${substr{3}{2}{$local_part}}
15519 </literallayout>
15520 <para>
15521 If the starting offset is greater than the string length the result is the
15522 null string; if the length plus starting offset is greater than the string
15523 length, the result is the right-hand part of the string, starting from the
15524 given offset. The first byte (character) in the string has offset zero.
15525 </para>
15526 <para>
15527 The <option>substr</option> expansion item can take negative offset values to count
15528 from the right-hand end of its operand. The last byte (character) is offset -1,
15529 the second-last is offset -2, and so on. Thus, for example,
15530 </para>
15531 <literallayout class="monospaced">
15532 ${substr{-5}{2}{1234567}}
15533 </literallayout>
15534 <para>
15535 yields <quote>34</quote>. If the absolute value of a negative offset is greater than the
15536 length of the string, the substring starts at the beginning of the string, and
15537 the length is reduced by the amount of overshoot. Thus, for example,
15538 </para>
15539 <literallayout class="monospaced">
15540 ${substr{-5}{2}{12}}
15541 </literallayout>
15542 <para>
15543 yields an empty string, but
15544 </para>
15545 <literallayout class="monospaced">
15546 ${substr{-3}{2}{12}}
15547 </literallayout>
15548 <para>
15549 yields <quote>1</quote>.
15550 </para>
15551 <para>
15552 When the second number is omitted from <option>substr</option>, the remainder of the string
15553 is taken if the offset is positive. If it is negative, all bytes (characters) in the
15554 string preceding the offset point are taken. For example, an offset of -1 and
15555 no length, as in these semantically identical examples:
15556 </para>
15557 <literallayout class="monospaced">
15558 ${substr_-1:abcde}
15559 ${substr{-1}{abcde}}
15560 </literallayout>
15561 <para>
15562 yields all but the last character of the string, that is, <quote>abcd</quote>.
15563 </para>
15564 <para>
15565 All measurement is done in bytes and is not UTF-8 aware.
15566 </para>
15567 </listitem></varlistentry>
15568 <varlistentry>
15569 <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>
15570 <listitem>
15571 <para>
15572 <indexterm role="concept">
15573 <primary>expansion</primary>
15574 <secondary>character translation</secondary>
15575 </indexterm>
15576 <indexterm role="concept">
15577 <primary><option>tr</option> expansion item</primary>
15578 </indexterm>
15579 This item does single-character (in bytes) translation on its subject string. The second
15580 argument is a list of characters to be translated in the subject string. Each
15581 matching character is replaced by the corresponding character from the
15582 replacement list. For example
15583 </para>
15584 <literallayout class="monospaced">
15585 ${tr{abcdea}{ac}{13}}
15586 </literallayout>
15587 <para>
15588 yields <literal>1b3de1</literal>. If there are duplicates in the second character string, the
15589 last occurrence is used. If the third string is shorter than the second, its
15590 last character is replicated. However, if it is empty, no translation takes
15591 place.
15592 </para>
15593 <para>
15594 All character handling is done in bytes and is not UTF-8 aware.
15595 </para>
15596 </listitem></varlistentry>
15597 </variablelist>
15598 </section>
15599 <section id="SECTexpop">
15600 <title>Expansion operators</title>
15601 <para>
15602 <indexterm role="concept">
15603 <primary>expansion</primary>
15604 <secondary>operators</secondary>
15605 </indexterm>
15606 For expansion items that perform transformations on a single argument string,
15607 the <quote>operator</quote> notation is used because it is simpler and uses fewer braces.
15608 The substring is first expanded before the operation is applied to it. The
15609 following operations can be performed:
15610 </para>
15611 <variablelist>
15612 <varlistentry>
15613 <term><emphasis role="bold">${address:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15614 <listitem>
15615 <para>
15616 <indexterm role="concept">
15617 <primary>expansion</primary>
15618 <secondary>RFC 2822 address handling</secondary>
15619 </indexterm>
15620 <indexterm role="concept">
15621 <primary><option>address</option> expansion item</primary>
15622 </indexterm>
15623 The string is interpreted as an RFC 2822 address, as it might appear in a
15624 header line, and the effective address is extracted from it. If the string does
15625 not parse successfully, the result is empty.
15626 </para>
15627 <para>
15628 The parsing correctly handles SMTPUTF8 Unicode in the string.
15629 </para>
15630 </listitem></varlistentry>
15631 <varlistentry>
15632 <term><emphasis role="bold">${addresses:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15633 <listitem>
15634 <para>
15635 <indexterm role="concept">
15636 <primary>expansion</primary>
15637 <secondary>RFC 2822 address handling</secondary>
15638 </indexterm>
15639 <indexterm role="concept">
15640 <primary><option>addresses</option> expansion item</primary>
15641 </indexterm>
15642 The string (after expansion) is interpreted as a list of addresses in RFC
15643 2822 format, such as can be found in a <emphasis>To:</emphasis> or <emphasis>Cc:</emphasis> header line. The
15644 operative address (<emphasis>local-part@domain</emphasis>) is extracted from each item, and the
15645 result of the expansion is a colon-separated list, with appropriate
15646 doubling of colons should any happen to be present in the email addresses.
15647 Syntactically invalid RFC2822 address items are omitted from the output.
15648 </para>
15649 <para>
15650 It is possible to specify a character other than colon for the output
15651 separator by starting the string with &gt; followed by the new separator
15652 character. For example:
15653 </para>
15654 <literallayout class="monospaced">
15655 ${addresses:&gt;&amp; Chief &lt;ceo@up.stairs&gt;, sec@base.ment (dogsbody)}
15656 </literallayout>
15657 <para>
15658 expands to <literal>ceo@up.stairs&amp;sec@base.ment</literal>. The string is expanded
15659 first, so if the expanded string starts with &gt;, it may change the output
15660 separator unintentionally. This can be avoided by setting the output
15661 separator explicitly:
15662 </para>
15663 <literallayout class="monospaced">
15664 ${addresses:&gt;:$h_from:}
15665 </literallayout>
15666 <para>
15667 Compare the <option>address</option> (singular)
15668 expansion item, which extracts the working address from a single RFC2822
15669 address. See the <option>filter</option>, <option>map</option>, and <option>reduce</option> items for ways of
15670 processing lists.
15671 </para>
15672 <para>
15673 To clarify "list of addresses in RFC 2822 format" mentioned above, Exim follows
15674 a strict interpretation of header line formatting.  Exim parses the bare,
15675 unquoted portion of an email address and if it finds a comma, treats it as an
15676 email address separator. For the example header line:
15677 </para>
15678 <literallayout class="monospaced">
15679 From: =?iso-8859-2?Q?Last=2C_First?= &lt;user@example.com&gt;
15680 </literallayout>
15681 <para>
15682 The first example below demonstrates that Q-encoded email addresses are parsed
15683 properly if it is given the raw header (in this example, <literal>$rheader_from:</literal>).
15684 It does not see the comma because it&#x2019;s still encoded as "=2C".  The second
15685 example below is passed the contents of <literal>$header_from:</literal>, meaning it gets
15686 de-mimed. Exim sees the decoded "," so it treats it as <emphasis role="bold">two</emphasis> email addresses.
15687 The third example shows that the presence of a comma is skipped when it is
15688 quoted.  The fourth example shows SMTPUTF8 handling.
15689 </para>
15690 <literallayout class="monospaced">
15691 # exim -be '${addresses:From: \
15692 =?iso-8859-2?Q?Last=2C_First?= &lt;user@example.com&gt;}'
15693 user@example.com
15694 # exim -be '${addresses:From: Last, First &lt;user@example.com&gt;}'
15695 Last:user@example.com
15696 # exim -be '${addresses:From: "Last, First" &lt;user@example.com&gt;}'
15697 user@example.com
15698 # exim -be '${addresses:フィル &lt;フィリップ@example.jp&gt;}'
15699 フィリップ@example.jp
15700 </literallayout>
15701 </listitem></varlistentry>
15702 <varlistentry>
15703 <term><emphasis role="bold">${base32:</emphasis>&lt;<emphasis>digits</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15704 <listitem>
15705 <para>
15706 <indexterm role="concept">
15707 <primary><option>base32</option> expansion item</primary>
15708 </indexterm>
15709 <indexterm role="concept">
15710 <primary>expansion</primary>
15711 <secondary>conversion to base 32</secondary>
15712 </indexterm>
15713 The string must consist entirely of decimal digits. The number is converted to
15714 base 32 and output as a (empty, for zero) string of characters.
15715 Only lowercase letters are used.
15716 </para>
15717 </listitem></varlistentry>
15718 <varlistentry>
15719 <term><emphasis role="bold">${base32d:</emphasis>&lt;<emphasis>base-32&nbsp;digits</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15720 <listitem>
15721 <para>
15722 <indexterm role="concept">
15723 <primary><option>base32d</option> expansion item</primary>
15724 </indexterm>
15725 <indexterm role="concept">
15726 <primary>expansion</primary>
15727 <secondary>conversion to base 32</secondary>
15728 </indexterm>
15729 The string must consist entirely of base-32 digits.
15730 The number is converted to decimal and output as a string.
15731 </para>
15732 </listitem></varlistentry>
15733 <varlistentry>
15734 <term><emphasis role="bold">${base62:</emphasis>&lt;<emphasis>digits</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15735 <listitem>
15736 <para>
15737 <indexterm role="concept">
15738 <primary><option>base62</option> expansion item</primary>
15739 </indexterm>
15740 <indexterm role="concept">
15741 <primary>expansion</primary>
15742 <secondary>conversion to base 62</secondary>
15743 </indexterm>
15744 The string must consist entirely of decimal digits. The number is converted to
15745 base 62 and output as a string of six characters, including leading zeros. In
15746 the few operating environments where Exim uses base 36 instead of base 62 for
15747 its message identifiers (because those systems do not have case-sensitive
15748 filenames), base 36 is used by this operator, despite its name. <emphasis role="bold">Note</emphasis>: Just
15749 to be absolutely clear: this is <emphasis>not</emphasis> base64 encoding.
15750 </para>
15751 </listitem></varlistentry>
15752 <varlistentry>
15753 <term><emphasis role="bold">${base62d:</emphasis>&lt;<emphasis>base-62&nbsp;digits</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15754 <listitem>
15755 <para>
15756 <indexterm role="concept">
15757 <primary><option>base62d</option> expansion item</primary>
15758 </indexterm>
15759 <indexterm role="concept">
15760 <primary>expansion</primary>
15761 <secondary>conversion to base 62</secondary>
15762 </indexterm>
15763 The string must consist entirely of base-62 digits, or, in operating
15764 environments where Exim uses base 36 instead of base 62 for its message
15765 identifiers, base-36 digits. The number is converted to decimal and output as a
15766 string.
15767 </para>
15768 </listitem></varlistentry>
15769 <varlistentry>
15770 <term><emphasis role="bold">${base64:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15771 <listitem>
15772 <para>
15773 <indexterm role="concept">
15774 <primary>expansion</primary>
15775 <secondary>base64 encoding</secondary>
15776 </indexterm>
15777 <indexterm role="concept">
15778 <primary>base64 encoding</primary>
15779 <secondary>in string expansion</secondary>
15780 </indexterm>
15781 <indexterm role="concept">
15782 <primary><option>base64</option> expansion item</primary>
15783 </indexterm>
15784 <indexterm role="concept">
15785 <primary>certificate</primary>
15786 <secondary>base64 of DER</secondary>
15787 </indexterm>
15788 This operator converts a string into one that is base64 encoded.
15789 </para>
15790 <para>
15791 If the string is a single variable of type certificate,
15792 returns the base64 encoding of the DER form of the certificate.
15793 </para>
15794 </listitem></varlistentry>
15795 <varlistentry>
15796 <term><emphasis role="bold">${base64d:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15797 <listitem>
15798 <para>
15799 <indexterm role="concept">
15800 <primary>expansion</primary>
15801 <secondary>base64 decoding</secondary>
15802 </indexterm>
15803 <indexterm role="concept">
15804 <primary>base64 decoding</primary>
15805 <secondary>in string expansion</secondary>
15806 </indexterm>
15807 <indexterm role="concept">
15808 <primary><option>base64d</option> expansion item</primary>
15809 </indexterm>
15810 This operator converts a base64-encoded string into the un-coded form.
15811 </para>
15812 </listitem></varlistentry>
15813 <varlistentry>
15814 <term><emphasis role="bold">${domain:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15815 <listitem>
15816 <para>
15817 <indexterm role="concept">
15818 <primary>domain</primary>
15819 <secondary>extraction</secondary>
15820 </indexterm>
15821 <indexterm role="concept">
15822 <primary>expansion</primary>
15823 <secondary>domain extraction</secondary>
15824 </indexterm>
15825 The string is interpreted as an RFC 2822 address and the domain is extracted
15826 from it. If the string does not parse successfully, the result is empty.
15827 </para>
15828 </listitem></varlistentry>
15829 <varlistentry>
15830 <term><emphasis role="bold">${escape:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15831 <listitem>
15832 <para>
15833 <indexterm role="concept">
15834 <primary>expansion</primary>
15835 <secondary>escaping non-printing characters</secondary>
15836 </indexterm>
15837 <indexterm role="concept">
15838 <primary><option>escape</option> expansion item</primary>
15839 </indexterm>
15840 If the string contains any non-printing characters, they are converted to
15841 escape sequences starting with a backslash. Whether characters with the most
15842 significant bit set (so-called <quote>8-bit characters</quote>) count as printing or not
15843 is controlled by the <option>print_topbitchars</option> option.
15844 </para>
15845 </listitem></varlistentry>
15846 <varlistentry>
15847 <term><emphasis role="bold">${escape8bit:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15848 <listitem>
15849 <para>
15850 <indexterm role="concept">
15851 <primary>expansion</primary>
15852 <secondary>escaping 8-bit characters</secondary>
15853 </indexterm>
15854 <indexterm role="concept">
15855 <primary><option>escape8bit</option> expansion item</primary>
15856 </indexterm>
15857 If the string contains and characters with the most significant bit set,
15858 they are converted to escape sequences starting with a backslash.
15859 Backslashes and DEL characters are also converted.
15860 </para>
15861 </listitem></varlistentry>
15862 <varlistentry>
15863 <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>
15864 <listitem>
15865 <para>
15866 <indexterm role="concept">
15867 <primary>expansion</primary>
15868 <secondary>expression evaluation</secondary>
15869 </indexterm>
15870 <indexterm role="concept">
15871 <primary>expansion</primary>
15872 <secondary>arithmetic expression</secondary>
15873 </indexterm>
15874 <indexterm role="concept">
15875 <primary><option>eval</option> expansion item</primary>
15876 </indexterm>
15877 These items supports simple arithmetic and bitwise logical operations in
15878 expansion strings. The string (after expansion) must be a conventional
15879 arithmetic expression, but it is limited to basic arithmetic operators, bitwise
15880 logical operators, and parentheses. All operations are carried out using
15881 integer arithmetic. The operator priorities are as follows (the same as in the
15882 C programming language):
15883 </para>
15884 <informaltable frame="none">
15885 <tgroup cols="2" colsep="0" rowsep="0">
15886 <colspec colwidth="70pt" align="left"/>
15887 <colspec colwidth="300pt" align="left"/>
15888 <tbody>
15889 <row>
15890 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>highest:</emphasis></entry>
15891 <entry>not (~), negate (-)</entry>
15892 </row>
15893 <row>
15894 <entry>&nbsp;&nbsp;&nbsp;&nbsp;</entry>
15895 <entry>multiply (*), divide (/), remainder (%)</entry>
15896 </row>
15897 <row>
15898 <entry>&nbsp;&nbsp;&nbsp;&nbsp;</entry>
15899 <entry>plus (+), minus (-)</entry>
15900 </row>
15901 <row>
15902 <entry>&nbsp;&nbsp;&nbsp;&nbsp;</entry>
15903 <entry>shift-left (&lt;&lt;), shift-right (&gt;&gt;)</entry>
15904 </row>
15905 <row>
15906 <entry>&nbsp;&nbsp;&nbsp;&nbsp;</entry>
15907 <entry>and (&amp;)</entry>
15908 </row>
15909 <row>
15910 <entry>&nbsp;&nbsp;&nbsp;&nbsp;</entry>
15911 <entry>xor (^)</entry>
15912 </row>
15913 <row>
15914 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>lowest:</emphasis></entry>
15915 <entry>or (|)</entry>
15916 </row>
15917 </tbody>
15918 </tgroup>
15919 </informaltable>
15920 <para>
15921 Binary operators with the same priority are evaluated from left to right. White
15922 space is permitted before or after operators.
15923 </para>
15924 <para>
15925 For <option>eval</option>, numbers may be decimal, octal (starting with <quote>0</quote>) or
15926 hexadecimal (starting with <quote>0x</quote>). For <option>eval10</option>, all numbers are taken as
15927 decimal, even if they start with a leading zero; hexadecimal numbers are not
15928 permitted. This can be useful when processing numbers extracted from dates or
15929 times, which often do have leading zeros.
15930 </para>
15931 <para>
15932 A number may be followed by <quote>K</quote>, <quote>M</quote> or <quote>G</quote> to multiply it by 1024, 1024*1024
15933 or 1024*1024*1024,
15934 respectively. Negative numbers are supported. The result of the computation is
15935 a decimal representation of the answer (without <quote>K</quote>, <quote>M</quote> or <quote>G</quote>). For example:
15936 </para>
15937 <literallayout>
15938 <literal>${eval:1+1}            </literal>  yields 2
15939 <literal>${eval:1+2*3}          </literal>  yields 7
15940 <literal>${eval:(1+2)*3}        </literal>  yields 9
15941 <literal>${eval:2+42%5}         </literal>  yields 4
15942 <literal>${eval:0xc&amp;5}          </literal>  yields 4
15943 <literal>${eval:0xc|5}          </literal>  yields 13
15944 <literal>${eval:0xc^5}          </literal>  yields 9
15945 <literal>${eval:0xc&gt;&gt;1}         </literal>  yields 6
15946 <literal>${eval:0xc&lt;&lt;1}         </literal>  yields 24
15947 <literal>${eval:~255&amp;0x1234}    </literal>  yields 4608
15948 <literal>${eval:-(~255&amp;0x1234)} </literal>  yields -4608
15949 </literallayout>
15950 <para>
15951 As a more realistic example, in an ACL you might have
15952 </para>
15953 <literallayout class="monospaced">
15954 deny   message = Too many bad recipients
15955        condition =                    \
15956          ${if and {                   \
15957            {&gt;{$rcpt_count}{10}}       \
15958            {                          \
15959            &lt;                          \
15960              {$recipients_count}      \
15961              {${eval:$rcpt_count/2}}  \
15962            }                          \
15963          }{yes}{no}}
15964 </literallayout>
15965 <para>
15966 The condition is true if there have been more than 10 RCPT commands and
15967 fewer than half of them have resulted in a valid recipient.
15968 </para>
15969 </listitem></varlistentry>
15970 <varlistentry>
15971 <term><emphasis role="bold">${expand:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15972 <listitem>
15973 <para>
15974 <indexterm role="concept">
15975 <primary>expansion</primary>
15976 <secondary>re-expansion of substring</secondary>
15977 </indexterm>
15978 The <option>expand</option> operator causes a string to be expanded for a second time. For
15979 example,
15980 </para>
15981 <literallayout class="monospaced">
15982 ${expand:${lookup{$domain}dbm{/some/file}{$value}}}
15983 </literallayout>
15984 <para>
15985 first looks up a string in a file while expanding the operand for <option>expand</option>,
15986 and then re-expands what it has found.
15987 </para>
15988 </listitem></varlistentry>
15989 <varlistentry>
15990 <term><emphasis role="bold">${from_utf8:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15991 <listitem>
15992 <para>
15993 <indexterm role="concept">
15994 <primary>Unicode</primary>
15995 </indexterm>
15996 <indexterm role="concept">
15997 <primary>UTF-8</primary>
15998 <secondary>conversion from</secondary>
15999 </indexterm>
16000 <indexterm role="concept">
16001 <primary>expansion</primary>
16002 <secondary>UTF-8 conversion</secondary>
16003 </indexterm>
16004 <indexterm role="concept">
16005 <primary><option>from_utf8</option> expansion item</primary>
16006 </indexterm>
16007 The world is slowly moving towards Unicode, although there are no standards for
16008 email yet. However, other applications (including some databases) are starting
16009 to store data in Unicode, using UTF-8 encoding. This operator converts from a
16010 UTF-8 string to an ISO-8859-1 string. UTF-8 code values greater than 255 are
16011 converted to underscores. The input must be a valid UTF-8 string. If it is not,
16012 the result is an undefined sequence of bytes.
16013 </para>
16014 <para>
16015 Unicode code points with values less than 256 are compatible with ASCII and
16016 ISO-8859-1 (also known as Latin-1).
16017 For example, character 169 is the copyright symbol in both cases, though the
16018 way it is encoded is different. In UTF-8, more than one byte is needed for
16019 characters with code values greater than 127, whereas ISO-8859-1 is a
16020 single-byte encoding (but thereby limited to 256 characters). This makes
16021 translation from UTF-8 to ISO-8859-1 straightforward.
16022 </para>
16023 </listitem></varlistentry>
16024 <varlistentry>
16025 <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>
16026 <listitem>
16027 <para>
16028 <indexterm role="concept">
16029 <primary>hash function</primary>
16030 <secondary>textual</secondary>
16031 </indexterm>
16032 <indexterm role="concept">
16033 <primary>expansion</primary>
16034 <secondary>textual hash</secondary>
16035 </indexterm>
16036 The <option>hash</option> operator is a simpler interface to the hashing function that can
16037 be used when the two parameters are fixed numbers (as opposed to strings that
16038 change when expanded). The effect is the same as
16039 </para>
16040 <literallayout class="monospaced">
16041 ${hash{&lt;n&gt;}{&lt;m&gt;}{&lt;string&gt;}}
16042 </literallayout>
16043 <para>
16044 See the description of the general <option>hash</option> item above for details. The
16045 abbreviation <option>h</option> can be used when <option>hash</option> is used as an operator.
16046 </para>
16047 </listitem></varlistentry>
16048 <varlistentry>
16049 <term><emphasis role="bold">${hex2b64:</emphasis>&lt;<emphasis>hexstring</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16050 <listitem>
16051 <para>
16052 <indexterm role="concept">
16053 <primary>base64 encoding</primary>
16054 <secondary>conversion from hex</secondary>
16055 </indexterm>
16056 <indexterm role="concept">
16057 <primary>expansion</primary>
16058 <secondary>hex to base64</secondary>
16059 </indexterm>
16060 <indexterm role="concept">
16061 <primary><option>hex2b64</option> expansion item</primary>
16062 </indexterm>
16063 This operator converts a hex string into one that is base64 encoded. This can
16064 be useful for processing the output of the various hashing functions.
16065 </para>
16066 </listitem></varlistentry>
16067 <varlistentry>
16068 <term><emphasis role="bold">${hexquote:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16069 <listitem>
16070 <para>
16071 <indexterm role="concept">
16072 <primary>quoting</primary>
16073 <secondary>hex-encoded unprintable characters</secondary>
16074 </indexterm>
16075 <indexterm role="concept">
16076 <primary><option>hexquote</option> expansion item</primary>
16077 </indexterm>
16078 This operator converts non-printable characters in a string into a hex
16079 escape form. Byte values between 33 (!) and 126 (~) inclusive are left
16080 as is, and other byte values are converted to <literal>\xNN</literal>, for example, a
16081 byte value 127 is converted to <literal>\x7f</literal>.
16082 </para>
16083 </listitem></varlistentry>
16084 <varlistentry>
16085 <term><emphasis role="bold">${ipv6denorm:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16086 <listitem>
16087 <para>
16088 <indexterm role="concept">
16089 <primary><option>ipv6denorm</option> expansion item</primary>
16090 </indexterm>
16091 <indexterm role="concept">
16092 <primary>IP address</primary>
16093 <secondary>normalisation</secondary>
16094 </indexterm>
16095 This expands an IPv6 address to a full eight-element colon-separated set
16096 of hex digits including leading zeroes.
16097 A trailing ipv4-style dotted-decimal set is converted to hex.
16098 Pure IPv4 addresses are converted to IPv4-mapped IPv6.
16099 </para>
16100 </listitem></varlistentry>
16101 <varlistentry>
16102 <term><emphasis role="bold">${ipv6norm:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16103 <listitem>
16104 <para>
16105 <indexterm role="concept">
16106 <primary><option>ipv6norm</option> expansion item</primary>
16107 </indexterm>
16108 <indexterm role="concept">
16109 <primary>IP address</primary>
16110 <secondary>normalisation</secondary>
16111 </indexterm>
16112 <indexterm role="concept">
16113 <primary>IP address</primary>
16114 <secondary>canonical form</secondary>
16115 </indexterm>
16116 This converts an IPv6 address to canonical form.
16117 Leading zeroes of groups are omitted, and the longest
16118 set of zero-valued groups is replaced with a double colon.
16119 A trailing ipv4-style dotted-decimal set is converted to hex.
16120 Pure IPv4 addresses are converted to IPv4-mapped IPv6.
16121 </para>
16122 </listitem></varlistentry>
16123 <varlistentry>
16124 <term><emphasis role="bold">${lc:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16125 <listitem>
16126 <para>
16127 <indexterm role="concept">
16128 <primary>case forcing in strings</primary>
16129 </indexterm>
16130 <indexterm role="concept">
16131 <primary>string</primary>
16132 <secondary>case forcing</secondary>
16133 </indexterm>
16134 <indexterm role="concept">
16135 <primary>lower casing</primary>
16136 </indexterm>
16137 <indexterm role="concept">
16138 <primary>expansion</primary>
16139 <secondary>case forcing</secondary>
16140 </indexterm>
16141 <indexterm role="concept">
16142 <primary><option>lc</option> expansion item</primary>
16143 </indexterm>
16144 This forces the letters in the string into lower-case, for example:
16145 </para>
16146 <literallayout class="monospaced">
16147 ${lc:$local_part}
16148 </literallayout>
16149 <para>
16150 Case is defined per the system C locale.
16151 </para>
16152 </listitem></varlistentry>
16153 <varlistentry>
16154 <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>
16155 <listitem>
16156 <para>
16157 <indexterm role="concept">
16158 <primary>expansion</primary>
16159 <secondary>string truncation</secondary>
16160 </indexterm>
16161 <indexterm role="concept">
16162 <primary><option>length</option> expansion item</primary>
16163 </indexterm>
16164 The <option>length</option> operator is a simpler interface to the <option>length</option> function that
16165 can be used when the parameter is a fixed number (as opposed to a string that
16166 changes when expanded). The effect is the same as
16167 </para>
16168 <literallayout class="monospaced">
16169 ${length{&lt;number&gt;}{&lt;string&gt;}}
16170 </literallayout>
16171 <para>
16172 See the description of the general <option>length</option> item above for details. Note that
16173 <option>length</option> is not the same as <option>strlen</option>. The abbreviation <option>l</option> can be used
16174 when <option>length</option> is used as an operator.
16175 All measurement is done in bytes and is not UTF-8 aware.
16176 </para>
16177 </listitem></varlistentry>
16178 <varlistentry>
16179 <term><emphasis role="bold">${listcount:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16180 <listitem>
16181 <para>
16182 <indexterm role="concept">
16183 <primary>expansion</primary>
16184 <secondary>list item count</secondary>
16185 </indexterm>
16186 <indexterm role="concept">
16187 <primary>list</primary>
16188 <secondary>item count</secondary>
16189 </indexterm>
16190 <indexterm role="concept">
16191 <primary>list</primary>
16192 <secondary>count of items</secondary>
16193 </indexterm>
16194 <indexterm role="concept">
16195 <primary><option>listcount</option> expansion item</primary>
16196 </indexterm>
16197 The string is interpreted as a list and the number of items is returned.
16198 </para>
16199 </listitem></varlistentry>
16200 <varlistentry>
16201 <term><emphasis role="bold">${listnamed:</emphasis>&lt;<emphasis>name</emphasis>&gt;<emphasis role="bold">}</emphasis>&nbsp;and&nbsp;<emphasis role="bold">${listnamed_</emphasis>&lt;<emphasis>type</emphasis>&gt;<emphasis role="bold">:</emphasis>&lt;<emphasis>name</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16202 <listitem>
16203 <para>
16204 <indexterm role="concept">
16205 <primary>expansion</primary>
16206 <secondary>named list</secondary>
16207 </indexterm>
16208 <indexterm role="concept">
16209 <primary><option>listnamed</option> expansion item</primary>
16210 </indexterm>
16211 The name is interpreted as a named list and the content of the list is returned,
16212 expanding any referenced lists, re-quoting as needed for colon-separation.
16213 If the optional type is given it must be one of "a", "d", "h" or "l"
16214 and selects address-, domain-, host- or localpart- lists to search among respectively.
16215 Otherwise all types are searched in an undefined order and the first
16216 matching list is returned.
16217 </para>
16218 </listitem></varlistentry>
16219 <varlistentry>
16220 <term><emphasis role="bold">${local_part:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16221 <listitem>
16222 <para>
16223 <indexterm role="concept">
16224 <primary>expansion</primary>
16225 <secondary>local part extraction</secondary>
16226 </indexterm>
16227 <indexterm role="concept">
16228 <primary><option>local_part</option> expansion item</primary>
16229 </indexterm>
16230 The string is interpreted as an RFC 2822 address and the local part is
16231 extracted from it. If the string does not parse successfully, the result is
16232 empty.
16233 The parsing correctly handles SMTPUTF8 Unicode in the string.
16234 </para>
16235 </listitem></varlistentry>
16236 <varlistentry>
16237 <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>
16238 <listitem>
16239 <para>
16240 <indexterm role="concept">
16241 <primary>masked IP address</primary>
16242 </indexterm>
16243 <indexterm role="concept">
16244 <primary>IP address</primary>
16245 <secondary>masking</secondary>
16246 </indexterm>
16247 <indexterm role="concept">
16248 <primary>CIDR notation</primary>
16249 </indexterm>
16250 <indexterm role="concept">
16251 <primary>expansion</primary>
16252 <secondary>IP address masking</secondary>
16253 </indexterm>
16254 <indexterm role="concept">
16255 <primary><option>mask</option> expansion item</primary>
16256 </indexterm>
16257 If the form of the string to be operated on is not an IP address followed by a
16258 slash and an integer (that is, a network address in CIDR notation), the
16259 expansion fails. Otherwise, this operator converts the IP address to binary,
16260 masks off the least significant bits according to the bit count, and converts
16261 the result back to text, with mask appended. For example,
16262 </para>
16263 <literallayout class="monospaced">
16264 ${mask:10.111.131.206/28}
16265 </literallayout>
16266 <para>
16267 returns the string <quote>10.111.131.192/28</quote>. Since this operation is expected to
16268 be mostly used for looking up masked addresses in files, the result for an IPv6
16269 address uses dots to separate components instead of colons, because colon
16270 terminates a key string in lsearch files. So, for example,
16271 </para>
16272 <literallayout class="monospaced">
16273 ${mask:3ffe:ffff:836f:0a00:000a:0800:200a:c031/99}
16274 </literallayout>
16275 <para>
16276 returns the string
16277 </para>
16278 <literallayout class="monospaced">
16279 3ffe.ffff.836f.0a00.000a.0800.2000.0000/99
16280 </literallayout>
16281 <para>
16282 Letters in IPv6 addresses are always output in lower case.
16283 </para>
16284 </listitem></varlistentry>
16285 <varlistentry>
16286 <term><emphasis role="bold">${md5:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16287 <listitem>
16288 <para>
16289 <indexterm role="concept">
16290 <primary>MD5 hash</primary>
16291 </indexterm>
16292 <indexterm role="concept">
16293 <primary>expansion</primary>
16294 <secondary>MD5 hash</secondary>
16295 </indexterm>
16296 <indexterm role="concept">
16297 <primary>certificate</primary>
16298 <secondary>fingerprint</secondary>
16299 </indexterm>
16300 <indexterm role="concept">
16301 <primary><option>md5</option> expansion item</primary>
16302 </indexterm>
16303 The <option>md5</option> operator computes the MD5 hash value of the string, and returns it
16304 as a 32-digit hexadecimal number, in which any letters are in lower case.
16305 </para>
16306 <para>
16307 If the string is a single variable of type certificate,
16308 returns the MD5 hash fingerprint of the certificate.
16309 </para>
16310 </listitem></varlistentry>
16311 <varlistentry>
16312 <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>
16313 <listitem>
16314 <para>
16315 <indexterm role="concept">
16316 <primary>expansion</primary>
16317 <secondary>numeric hash</secondary>
16318 </indexterm>
16319 <indexterm role="concept">
16320 <primary>hash function</primary>
16321 <secondary>numeric</secondary>
16322 </indexterm>
16323 The <option>nhash</option> operator is a simpler interface to the numeric hashing function
16324 that can be used when the two parameters are fixed numbers (as opposed to
16325 strings that change when expanded). The effect is the same as
16326 </para>
16327 <literallayout class="monospaced">
16328 ${nhash{&lt;n&gt;}{&lt;m&gt;}{&lt;string&gt;}}
16329 </literallayout>
16330 <para>
16331 See the description of the general <option>nhash</option> item above for details.
16332 </para>
16333 </listitem></varlistentry>
16334 <varlistentry>
16335 <term><emphasis role="bold">${quote:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16336 <listitem>
16337 <para>
16338 <indexterm role="concept">
16339 <primary>quoting</primary>
16340 <secondary>in string expansions</secondary>
16341 </indexterm>
16342 <indexterm role="concept">
16343 <primary>expansion</primary>
16344 <secondary>quoting</secondary>
16345 </indexterm>
16346 <indexterm role="concept">
16347 <primary><option>quote</option> expansion item</primary>
16348 </indexterm>
16349 The <option>quote</option> operator puts its argument into double quotes if it
16350 is an empty string or
16351 contains anything other than letters, digits, underscores, dots, and hyphens.
16352 Any occurrences of double quotes and backslashes are escaped with a backslash.
16353 Newlines and carriage returns are converted to <literal>\n</literal> and <literal>\r</literal>,
16354 respectively For example,
16355 </para>
16356 <literallayout class="monospaced">
16357 ${quote:ab"*"cd}
16358 </literallayout>
16359 <para>
16360 becomes
16361 </para>
16362 <literallayout class="monospaced">
16363 "ab\"*\"cd"
16364 </literallayout>
16365 <para>
16366 The place where this is useful is when the argument is a substitution from a
16367 variable or a message header.
16368 </para>
16369 </listitem></varlistentry>
16370 <varlistentry>
16371 <term><emphasis role="bold">${quote_local_part:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16372 <listitem>
16373 <para>
16374 <indexterm role="concept">
16375 <primary><option>quote_local_part</option> expansion item</primary>
16376 </indexterm>
16377 This operator is like <option>quote</option>, except that it quotes the string only if
16378 required to do so by the rules of RFC 2822 for quoting local parts. For
16379 example, a plus sign would not cause quoting (but it would for <option>quote</option>).
16380 If you are creating a new email address from the contents of <varname>$local_part</varname>
16381 (or any other unknown data), you should always use this operator.
16382 </para>
16383 <para>
16384 This quoting determination is not SMTPUTF8-aware, thus quoting non-ASCII data
16385 will likely use the quoting form.
16386 Thus <emphasis>${quote_local_part:フィル}</emphasis> will always become <emphasis>"フィル"</emphasis>.
16387 </para>
16388 </listitem></varlistentry>
16389 <varlistentry>
16390 <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>
16391 <listitem>
16392 <para>
16393 <indexterm role="concept">
16394 <primary>quoting</primary>
16395 <secondary>lookup-specific</secondary>
16396 </indexterm>
16397 This operator applies lookup-specific quoting rules to the string. Each
16398 query-style lookup type has its own quoting rules which are described with
16399 the lookups in chapter <xref linkend="CHAPfdlookup"/>. For example,
16400 </para>
16401 <literallayout class="monospaced">
16402 ${quote_ldap:two * two}
16403 </literallayout>
16404 <para>
16405 returns
16406 </para>
16407 <literallayout class="monospaced">
16408 two%20%5C2A%20two
16409 </literallayout>
16410 <para>
16411 For single-key lookup types, no quoting is ever necessary and this operator
16412 yields an unchanged string.
16413 </para>
16414 </listitem></varlistentry>
16415 <varlistentry>
16416 <term><emphasis role="bold">${randint:</emphasis>&lt;<emphasis>n</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16417 <listitem>
16418 <para>
16419 <indexterm role="concept">
16420 <primary>random number</primary>
16421 </indexterm>
16422 This operator returns a somewhat random number which is less than the
16423 supplied number and is at least 0.  The quality of this randomness depends
16424 on how Exim was built; the values are not suitable for keying material.
16425 If Exim is linked against OpenSSL then RAND_pseudo_bytes() is used.
16426 If Exim is linked against GnuTLS then gnutls_rnd(GNUTLS_RND_NONCE) is used,
16427 for versions of GnuTLS with that function.
16428 Otherwise, the implementation may be arc4random(), random() seeded by
16429 srandomdev() or srandom(), or a custom implementation even weaker than
16430 random().
16431 </para>
16432 </listitem></varlistentry>
16433 <varlistentry>
16434 <term><emphasis role="bold">${reverse_ip:</emphasis>&lt;<emphasis>ipaddr</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16435 <listitem>
16436 <para>
16437 <indexterm role="concept">
16438 <primary>expansion</primary>
16439 <secondary>IP address</secondary>
16440 </indexterm>
16441 This operator reverses an IP address; for IPv4 addresses, the result is in
16442 dotted-quad decimal form, while for IPv6 addresses the result is in
16443 dotted-nibble hexadecimal form.  In both cases, this is the "natural" form
16444 for DNS.  For example,
16445 </para>
16446 <literallayout class="monospaced">
16447 ${reverse_ip:192.0.2.4}
16448 ${reverse_ip:2001:0db8:c42:9:1:abcd:192.0.2.127}
16449 </literallayout>
16450 <para>
16451 returns
16452 </para>
16453 <literallayout class="monospaced">
16454 4.2.0.192
16455 f.7.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
16456 </literallayout>
16457 </listitem></varlistentry>
16458 <varlistentry>
16459 <term><emphasis role="bold">${rfc2047:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16460 <listitem>
16461 <para>
16462 <indexterm role="concept">
16463 <primary>expansion</primary>
16464 <secondary>RFC 2047</secondary>
16465 </indexterm>
16466 <indexterm role="concept">
16467 <primary>RFC 2047</primary>
16468 <secondary>expansion operator</secondary>
16469 </indexterm>
16470 <indexterm role="concept">
16471 <primary><option>rfc2047</option> expansion item</primary>
16472 </indexterm>
16473 This operator encodes text according to the rules of RFC 2047. This is an
16474 encoding that is used in header lines to encode non-ASCII characters. It is
16475 assumed that the input string is in the encoding specified by the
16476 <option>headers_charset</option> option, which gets its default at build time. If the string
16477 contains only characters in the range 33&ndash;126, and no instances of the
16478 characters
16479 </para>
16480 <literallayout class="monospaced">
16481 ? = ( ) &lt; &gt; @ , ; : \ " . [ ] _
16482 </literallayout>
16483 <para>
16484 it is not modified. Otherwise, the result is the RFC 2047 encoding of the
16485 string, using as many <quote>encoded words</quote> as necessary to encode all the
16486 characters.
16487 </para>
16488 </listitem></varlistentry>
16489 <varlistentry>
16490 <term><emphasis role="bold">${rfc2047d:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16491 <listitem>
16492 <para>
16493 <indexterm role="concept">
16494 <primary>expansion</primary>
16495 <secondary>RFC 2047</secondary>
16496 </indexterm>
16497 <indexterm role="concept">
16498 <primary>RFC 2047</primary>
16499 <secondary>decoding</secondary>
16500 </indexterm>
16501 <indexterm role="concept">
16502 <primary><option>rfc2047d</option> expansion item</primary>
16503 </indexterm>
16504 This operator decodes strings that are encoded as per RFC 2047. Binary zero
16505 bytes are replaced by question marks. Characters are converted into the
16506 character set defined by <option>headers_charset</option>. Overlong RFC 2047 <quote>words</quote> are
16507 not recognized unless <option>check_rfc2047_length</option> is set false.
16508 </para>
16509 <para>
16510 <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
16511 access a header line, RFC 2047 decoding is done automatically. You do not need
16512 to use this operator as well.
16513 </para>
16514 </listitem></varlistentry>
16515 <varlistentry>
16516 <term><emphasis role="bold">${rxquote:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16517 <listitem>
16518 <para>
16519 <indexterm role="concept">
16520 <primary>quoting</primary>
16521 <secondary>in regular expressions</secondary>
16522 </indexterm>
16523 <indexterm role="concept">
16524 <primary>regular expressions</primary>
16525 <secondary>quoting</secondary>
16526 </indexterm>
16527 <indexterm role="concept">
16528 <primary><option>rxquote</option> expansion item</primary>
16529 </indexterm>
16530 The <option>rxquote</option> operator inserts a backslash before any non-alphanumeric
16531 characters in its argument. This is useful when substituting the values of
16532 variables or headers inside regular expressions.
16533 </para>
16534 </listitem></varlistentry>
16535 <varlistentry>
16536 <term><emphasis role="bold">${sha1:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16537 <listitem>
16538 <para>
16539 <indexterm role="concept">
16540 <primary>SHA-1 hash</primary>
16541 </indexterm>
16542 <indexterm role="concept">
16543 <primary>expansion</primary>
16544 <secondary>SHA-1 hashing</secondary>
16545 </indexterm>
16546 <indexterm role="concept">
16547 <primary>certificate</primary>
16548 <secondary>fingerprint</secondary>
16549 </indexterm>
16550 <indexterm role="concept">
16551 <primary><option>sha1</option> expansion item</primary>
16552 </indexterm>
16553 The <option>sha1</option> operator computes the SHA-1 hash value of the string, and returns
16554 it as a 40-digit hexadecimal number, in which any letters are in upper case.
16555 </para>
16556 <para>
16557 If the string is a single variable of type certificate,
16558 returns the SHA-1 hash fingerprint of the certificate.
16559 </para>
16560 </listitem></varlistentry>
16561 <varlistentry>
16562 <term><emphasis role="bold">${sha256:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16563 <term><emphasis role="bold">${sha2:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16564 <term><emphasis role="bold">${sha2_&lt;n&gt;:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16565 <listitem>
16566 <para>
16567 <indexterm role="concept">
16568 <primary>SHA-256 hash</primary>
16569 </indexterm>
16570 <indexterm role="concept">
16571 <primary>SHA-2 hash</primary>
16572 </indexterm>
16573 <indexterm role="concept">
16574 <primary>certificate</primary>
16575 <secondary>fingerprint</secondary>
16576 </indexterm>
16577 <indexterm role="concept">
16578 <primary>expansion</primary>
16579 <secondary>SHA-256 hashing</secondary>
16580 </indexterm>
16581 <indexterm role="concept">
16582 <primary><option>sha256</option> expansion item</primary>
16583 </indexterm>
16584 <indexterm role="concept">
16585 <primary><option>sha2</option> expansion item</primary>
16586 </indexterm>
16587 The <option>sha256</option> operator computes the SHA-256 hash value of the string
16588 and returns
16589 it as a 64-digit hexadecimal number, in which any letters are in upper case.
16590 </para>
16591 <para>
16592 If the string is a single variable of type certificate,
16593 returns the SHA-256 hash fingerprint of the certificate.
16594 </para>
16595 <para revisionflag="changed">
16596 The operator can also be spelled <option>sha2</option> and does the same as <option>sha256</option>
16597 (except for certificates, which are not supported).
16598 Finally, if an underbar
16599 and a number is appended it specifies the output length, selecting a
16600 member of the SHA-2 family of hash functions.
16601 Values of 256, 384 and 512 are accepted, with 256 being the default.
16602 </para>
16603 </listitem></varlistentry>
16604 <varlistentry>
16605 <term><emphasis role="bold">${sha3:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16606 <term><emphasis role="bold">${sha3_&lt;n&gt;:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16607 <listitem>
16608 <para>
16609 <indexterm role="concept">
16610 <primary>SHA3 hash</primary>
16611 </indexterm>
16612 <indexterm role="concept">
16613 <primary>expansion</primary>
16614 <secondary>SHA3 hashing</secondary>
16615 </indexterm>
16616 <indexterm role="concept">
16617 <primary><option>sha3</option> expansion item</primary>
16618 </indexterm>
16619 The <option>sha3</option> operator computes the SHA3-256 hash value of the string
16620 and returns
16621 it as a 64-digit hexadecimal number, in which any letters are in upper case.
16622 </para>
16623 <para>
16624 If a number is appended, separated by an underbar, it specifies
16625 the output length.  Values of 224, 256, 384 and 512 are accepted;
16626 with 256 being the default.
16627 </para>
16628 <para>
16629 The <option>sha3</option> expansion item is only supported if Exim has been
16630 compiled with GnuTLS 3.5.0 or later,
16631 or OpenSSL 1.1.1 or later.
16632 The macro "_CRYPTO_HASH_SHA3" will be defined if it is supported.
16633 </para>
16634 </listitem></varlistentry>
16635 <varlistentry>
16636 <term><emphasis role="bold">${stat:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16637 <listitem>
16638 <para>
16639 <indexterm role="concept">
16640 <primary>expansion</primary>
16641 <secondary>statting a file</secondary>
16642 </indexterm>
16643 <indexterm role="concept">
16644 <primary>file</primary>
16645 <secondary>extracting characteristics</secondary>
16646 </indexterm>
16647 <indexterm role="concept">
16648 <primary><option>stat</option> expansion item</primary>
16649 </indexterm>
16650 The string, after expansion, must be a file path. A call to the <function>stat()</function>
16651 function is made for this path. If <function>stat()</function> fails, an error occurs and the
16652 expansion fails. If it succeeds, the data from the stat replaces the item, as a
16653 series of &lt;<emphasis>name</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt; pairs, where the values are all numerical,
16654 except for the value of <quote>smode</quote>. The names are: <quote>mode</quote> (giving the mode as
16655 a 4-digit octal number), <quote>smode</quote> (giving the mode in symbolic format as a
16656 10-character string, as for the <emphasis>ls</emphasis> command), <quote>inode</quote>, <quote>device</quote>,
16657 <quote>links</quote>, <quote>uid</quote>, <quote>gid</quote>, <quote>size</quote>, <quote>atime</quote>, <quote>mtime</quote>, and <quote>ctime</quote>. You
16658 can extract individual fields using the <option>extract</option> expansion item.
16659 </para>
16660 <para>
16661 The use of the <option>stat</option> expansion in users&#x2019; filter files can be locked out by
16662 the system administrator. <emphasis role="bold">Warning</emphasis>: The file size may be incorrect on 32-bit
16663 systems for files larger than 2GB.
16664 </para>
16665 </listitem></varlistentry>
16666 <varlistentry>
16667 <term><emphasis role="bold">${str2b64:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16668 <listitem>
16669 <para>
16670 <indexterm role="concept">
16671 <primary><option>str2b64</option> expansion item</primary>
16672 </indexterm>
16673 Now deprecated, a synonym for the <option>base64</option> expansion operator.
16674 </para>
16675 </listitem></varlistentry>
16676 <varlistentry>
16677 <term><emphasis role="bold">${strlen:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16678 <listitem>
16679 <para>
16680 <indexterm role="concept">
16681 <primary>expansion</primary>
16682 <secondary>string length</secondary>
16683 </indexterm>
16684 <indexterm role="concept">
16685 <primary>string</primary>
16686 <secondary>length in expansion</secondary>
16687 </indexterm>
16688 <indexterm role="concept">
16689 <primary><option>strlen</option> expansion item</primary>
16690 </indexterm>
16691 The item is replace by the length of the expanded string, expressed as a
16692 decimal number. <emphasis role="bold">Note</emphasis>: Do not confuse <option>strlen</option> with <option>length</option>.
16693 All measurement is done in bytes and is not UTF-8 aware.
16694 </para>
16695 </listitem></varlistentry>
16696 <varlistentry>
16697 <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>
16698 <listitem>
16699 <para>
16700 <indexterm role="concept">
16701 <primary><option>substr</option> expansion item</primary>
16702 </indexterm>
16703 <indexterm role="concept">
16704 <primary>substring extraction</primary>
16705 </indexterm>
16706 <indexterm role="concept">
16707 <primary>expansion</primary>
16708 <secondary>substring expansion</secondary>
16709 </indexterm>
16710 The <option>substr</option> operator is a simpler interface to the <option>substr</option> function that
16711 can be used when the two parameters are fixed numbers (as opposed to strings
16712 that change when expanded). The effect is the same as
16713 </para>
16714 <literallayout class="monospaced">
16715 ${substr{&lt;start&gt;}{&lt;length&gt;}{&lt;string&gt;}}
16716 </literallayout>
16717 <para>
16718 See the description of the general <option>substr</option> item above for details. The
16719 abbreviation <option>s</option> can be used when <option>substr</option> is used as an operator.
16720 All measurement is done in bytes and is not UTF-8 aware.
16721 </para>
16722 </listitem></varlistentry>
16723 <varlistentry>
16724 <term><emphasis role="bold">${time_eval:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16725 <listitem>
16726 <para>
16727 <indexterm role="concept">
16728 <primary><option>time_eval</option> expansion item</primary>
16729 </indexterm>
16730 <indexterm role="concept">
16731 <primary>time interval</primary>
16732 <secondary>decoding</secondary>
16733 </indexterm>
16734 This item converts an Exim time interval such as <literal>2d4h5m</literal> into a number of
16735 seconds.
16736 </para>
16737 </listitem></varlistentry>
16738 <varlistentry>
16739 <term><emphasis role="bold">${time_interval:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16740 <listitem>
16741 <para>
16742 <indexterm role="concept">
16743 <primary><option>time_interval</option> expansion item</primary>
16744 </indexterm>
16745 <indexterm role="concept">
16746 <primary>time interval</primary>
16747 <secondary>formatting</secondary>
16748 </indexterm>
16749 The argument (after sub-expansion) must be a sequence of decimal digits that
16750 represents an interval of time as a number of seconds. It is converted into a
16751 number of larger units and output in Exim&#x2019;s normal time format, for example,
16752 <literal>1w3d4h2m6s</literal>.
16753 </para>
16754 </listitem></varlistentry>
16755 <varlistentry>
16756 <term><emphasis role="bold">${uc:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16757 <listitem>
16758 <para>
16759 <indexterm role="concept">
16760 <primary>case forcing in strings</primary>
16761 </indexterm>
16762 <indexterm role="concept">
16763 <primary>string</primary>
16764 <secondary>case forcing</secondary>
16765 </indexterm>
16766 <indexterm role="concept">
16767 <primary>upper casing</primary>
16768 </indexterm>
16769 <indexterm role="concept">
16770 <primary>expansion</primary>
16771 <secondary>case forcing</secondary>
16772 </indexterm>
16773 <indexterm role="concept">
16774 <primary><option>uc</option> expansion item</primary>
16775 </indexterm>
16776 This forces the letters in the string into upper-case.
16777 Case is defined per the system C locale.
16778 </para>
16779 </listitem></varlistentry>
16780 <varlistentry>
16781 <term><emphasis role="bold">${utf8clean:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16782 <listitem>
16783 <para>
16784 <indexterm role="concept">
16785 <primary>correction of invalid utf-8 sequences in strings</primary>
16786 </indexterm>
16787 <indexterm role="concept">
16788 <primary>utf-8</primary>
16789 <secondary>utf-8 sequences</secondary>
16790 </indexterm>
16791 <indexterm role="concept">
16792 <primary>incorrect utf-8</primary>
16793 </indexterm>
16794 <indexterm role="concept">
16795 <primary>expansion</primary>
16796 <secondary>utf-8 forcing</secondary>
16797 </indexterm>
16798 <indexterm role="concept">
16799 <primary><option>utf8clean</option> expansion item</primary>
16800 </indexterm>
16801 This replaces any invalid utf-8 sequence in the string by the character <literal>?</literal>.
16802 In versions of Exim before 4.92, this did not correctly do so for a truncated
16803 final codepoint&#x2019;s encoding, and the character would be silently dropped.
16804 If you must handle detection of this scenario across both sets of Exim behavior,
16805 the complexity will depend upon the task.
16806 For instance, to detect if the first character is multibyte and a 1-byte
16807 extraction can be successfully used as a path component (as is common for
16808 dividing up delivery folders), you might use:
16809 </para>
16810 <literallayout class="monospaced">
16811 condition = ${if inlist{${utf8clean:${length_1:$local_part}}}{:?}{yes}{no}}
16812 </literallayout>
16813 <para>
16814 (which will false-positive if the first character of the local part is a
16815 literal question mark).
16816 </para>
16817 </listitem></varlistentry>
16818 <varlistentry>
16819 <term><emphasis role="bold">${utf8_domain_to_alabel:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16820 <term><emphasis role="bold">${utf8_domain_from_alabel:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16821 <term><emphasis role="bold">${utf8_localpart_to_alabel:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16822 <term><emphasis role="bold">${utf8_localpart_from_alabel:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16823 <listitem>
16824 <para>
16825 <indexterm role="concept">
16826 <primary>expansion</primary>
16827 <secondary>UTF-8</secondary>
16828 </indexterm>
16829 <indexterm role="concept">
16830 <primary>UTF-8</primary>
16831 <secondary>expansion</secondary>
16832 </indexterm>
16833 <indexterm role="concept">
16834 <primary>EAI</primary>
16835 </indexterm>
16836 <indexterm role="concept">
16837 <primary>internationalisation</primary>
16838 </indexterm>
16839 <indexterm role="concept">
16840 <primary><option>utf8_domain_to_alabel</option> expansion item</primary>
16841 </indexterm>
16842 <indexterm role="concept">
16843 <primary><option>utf8_domain_from_alabel</option> expansion item</primary>
16844 </indexterm>
16845 <indexterm role="concept">
16846 <primary><option>utf8_localpart_to_alabel</option> expansion item</primary>
16847 </indexterm>
16848 <indexterm role="concept">
16849 <primary><option>utf8_localpart_from_alabel</option> expansion item</primary>
16850 </indexterm>
16851 These convert EAI mail name components between UTF-8 and a-label forms.
16852 For information on internationalisation support see <xref linkend="SECTi18nMTA"/>.
16853 </para>
16854 </listitem></varlistentry>
16855 </variablelist>
16856 </section>
16857 <section id="SECTexpcond">
16858 <title>Expansion conditions</title>
16859 <para>
16860 <indexterm role="concept" id="IIDexpcond" class="startofrange">
16861 <primary>expansion</primary>
16862 <secondary>conditions</secondary>
16863 </indexterm>
16864 The following conditions are available for testing by the <option>${if</option> construct
16865 while expanding strings:
16866 </para>
16867 <variablelist>
16868 <varlistentry>
16869 <term><emphasis role="bold">!</emphasis>&lt;<emphasis>condition</emphasis>&gt;</term>
16870 <listitem>
16871 <para>
16872 <indexterm role="concept">
16873 <primary>expansion</primary>
16874 <secondary>negating a condition</secondary>
16875 </indexterm>
16876 <indexterm role="concept">
16877 <primary>negation</primary>
16878 <secondary>in expansion condition</secondary>
16879 </indexterm>
16880 Preceding any condition with an exclamation mark negates the result of the
16881 condition.
16882 </para>
16883 </listitem></varlistentry>
16884 <varlistentry>
16885 <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>
16886 <listitem>
16887 <para>
16888 <indexterm role="concept">
16889 <primary>numeric comparison</primary>
16890 </indexterm>
16891 <indexterm role="concept">
16892 <primary>expansion</primary>
16893 <secondary>numeric comparison</secondary>
16894 </indexterm>
16895 There are a number of symbolic operators for doing numeric comparisons. They
16896 are:
16897 </para>
16898 <literallayout>
16899 <literal>=   </literal>   equal
16900 <literal>==  </literal>   equal
16901 <literal>&gt;   </literal>   greater
16902 <literal>&gt;=  </literal>   greater or equal
16903 <literal>&lt;   </literal>   less
16904 <literal>&lt;=  </literal>   less or equal
16905 </literallayout>
16906 <para>
16907 For example:
16908 </para>
16909 <literallayout class="monospaced">
16910 ${if &gt;{$message_size}{10M} ...
16911 </literallayout>
16912 <para>
16913 Note that the general negation operator provides for inequality testing. The
16914 two strings must take the form of optionally signed decimal integers,
16915 optionally followed by one of the letters <quote>K</quote>, <quote>M</quote> or <quote>G</quote> (in either upper or
16916 lower case), signifying multiplication by 1024, 1024*1024 or 1024*1024*1024, respectively.
16917 As a special case, the numerical value of an empty string is taken as
16918 zero.
16919 </para>
16920 <para>
16921 In all cases, a relative comparator OP is testing if &lt;<emphasis>string1</emphasis>&gt; OP
16922 &lt;<emphasis>string2</emphasis>&gt;; the above example is checking if <varname>$message_size</varname> is larger than
16923 10M, not if 10M is larger than <varname>$message_size</varname>.
16924 </para>
16925 </listitem></varlistentry>
16926 <varlistentry>
16927 <term><emphasis role="bold">acl&nbsp;{{</emphasis>&lt;<emphasis>name</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>arg1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>arg2</emphasis>&gt;<emphasis role="bold">}...}</emphasis></term>
16928 <listitem>
16929 <para>
16930 <indexterm role="concept">
16931 <primary>expansion</primary>
16932 <secondary>calling an acl</secondary>
16933 </indexterm>
16934 <indexterm role="concept">
16935 <primary><option>acl</option></primary>
16936 <secondary>expansion condition</secondary>
16937 </indexterm>
16938 The name and zero to nine argument strings are first expanded separately.  The expanded
16939 arguments are assigned to the variables <varname>$acl_arg1</varname> to <varname>$acl_arg9</varname> in order.
16940 Any unused are made empty.  The variable <varname>$acl_narg</varname> is set to the number of
16941 arguments.  The named ACL (see chapter <xref linkend="CHAPACL"/>) is called
16942 and may use the variables; if another acl expansion is used the values
16943 are restored after it returns.  If the ACL sets
16944 a value using a "message =" modifier the variable $value becomes
16945 the result of the expansion, otherwise it is empty.
16946 If the ACL returns accept the condition is true; if deny, false.
16947 If the ACL returns defer the result is a forced-fail.
16948 </para>
16949 </listitem></varlistentry>
16950 <varlistentry>
16951 <term><emphasis role="bold">bool&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16952 <listitem>
16953 <para>
16954 <indexterm role="concept">
16955 <primary>expansion</primary>
16956 <secondary>boolean parsing</secondary>
16957 </indexterm>
16958 <indexterm role="concept">
16959 <primary><option>bool</option> expansion condition</primary>
16960 </indexterm>
16961 This condition turns a string holding a true or false representation into
16962 a boolean state.  It parses <quote>true</quote>, <quote>false</quote>, <quote>yes</quote> and <quote>no</quote>
16963 (case-insensitively); also integer numbers map to true if non-zero,
16964 false if zero.
16965 An empty string is treated as false.
16966 Leading and trailing whitespace is ignored;
16967 thus a string consisting only of whitespace is false.
16968 All other string values will result in expansion failure.
16969 </para>
16970 <para>
16971 When combined with ACL variables, this expansion condition will let you
16972 make decisions in one place and act on those decisions in another place.
16973 For example:
16974 </para>
16975 <literallayout class="monospaced">
16976 ${if bool{$acl_m_privileged_sender} ...
16977 </literallayout>
16978 </listitem></varlistentry>
16979 <varlistentry>
16980 <term><emphasis role="bold">bool_lax&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
16981 <listitem>
16982 <para>
16983 <indexterm role="concept">
16984 <primary>expansion</primary>
16985 <secondary>boolean parsing</secondary>
16986 </indexterm>
16987 <indexterm role="concept">
16988 <primary><option>bool_lax</option> expansion condition</primary>
16989 </indexterm>
16990 Like <option>bool</option>, this condition turns a string into a boolean state.  But
16991 where <option>bool</option> accepts a strict set of strings, <option>bool_lax</option> uses the same
16992 loose definition that the Router <option>condition</option> option uses.  The empty string
16993 and the values <quote>false</quote>, <quote>no</quote> and <quote>0</quote> map to false, all others map to
16994 true.  Leading and trailing whitespace is ignored.
16995 </para>
16996 <para>
16997 Note that where <quote>bool{00}</quote> is false, <quote>bool_lax{00}</quote> is true.
16998 </para>
16999 </listitem></varlistentry>
17000 <varlistentry>
17001 <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>
17002 <listitem>
17003 <para>
17004 <indexterm role="concept">
17005 <primary>expansion</primary>
17006 <secondary>encrypted comparison</secondary>
17007 </indexterm>
17008 <indexterm role="concept">
17009 <primary>encrypted strings, comparing</primary>
17010 </indexterm>
17011 <indexterm role="concept">
17012 <primary><option>crypteq</option> expansion condition</primary>
17013 </indexterm>
17014 This condition is included in the Exim binary if it is built to support any
17015 authentication mechanisms (see chapter <xref linkend="CHAPSMTPAUTH"/>). Otherwise, it is
17016 necessary to define SUPPORT_CRYPTEQ in <filename>Local/Makefile</filename> to get <option>crypteq</option>
17017 included in the binary.
17018 </para>
17019 <para>
17020 The <option>crypteq</option> condition has two arguments. The first is encrypted and
17021 compared against the second, which is already encrypted. The second string may
17022 be in the LDAP form for storing encrypted strings, which starts with the
17023 encryption type in curly brackets, followed by the data. If the second string
17024 does not begin with <quote>{</quote> it is assumed to be encrypted with <function>crypt()</function> or
17025 <function>crypt16()</function> (see below), since such strings cannot begin with <quote>{</quote>.
17026 Typically this will be a field from a password file. An example of an encrypted
17027 string in LDAP form is:
17028 </para>
17029 <literallayout class="monospaced">
17030 {md5}CY9rzUYh03PK3k6DJie09g==
17031 </literallayout>
17032 <para>
17033 If such a string appears directly in an expansion, the curly brackets have to
17034 be quoted, because they are part of the expansion syntax. For example:
17035 </para>
17036 <literallayout class="monospaced">
17037 ${if crypteq {test}{\{md5\}CY9rzUYh03PK3k6DJie09g==}{yes}{no}}
17038 </literallayout>
17039 <para>
17040 The following encryption types (whose names are matched case-independently) are
17041 supported:
17042 </para>
17043 <itemizedlist>
17044 <listitem>
17045 <para>
17046 <indexterm role="concept">
17047 <primary>MD5 hash</primary>
17048 </indexterm>
17049 <indexterm role="concept">
17050 <primary>base64 encoding</primary>
17051 <secondary>in encrypted password</secondary>
17052 </indexterm>
17053 <option>{md5}</option> computes the MD5 digest of the first string, and expresses this as
17054 printable characters to compare with the remainder of the second string. If the
17055 length of the comparison string is 24, Exim assumes that it is base64 encoded
17056 (as in the above example). If the length is 32, Exim assumes that it is a
17057 hexadecimal encoding of the MD5 digest. If the length not 24 or 32, the
17058 comparison fails.
17059 </para>
17060 </listitem>
17061 <listitem>
17062 <para>
17063 <indexterm role="concept">
17064 <primary>SHA-1 hash</primary>
17065 </indexterm>
17066 <option>{sha1}</option> computes the SHA-1 digest of the first string, and expresses this as
17067 printable characters to compare with the remainder of the second string. If the
17068 length of the comparison string is 28, Exim assumes that it is base64 encoded.
17069 If the length is 40, Exim assumes that it is a hexadecimal encoding of the
17070 SHA-1 digest. If the length is not 28 or 40, the comparison fails.
17071 </para>
17072 </listitem>
17073 <listitem>
17074 <para>
17075 <indexterm role="concept">
17076 <primary><function>crypt()</function></primary>
17077 </indexterm>
17078 <option>{crypt}</option> calls the <function>crypt()</function> function, which traditionally used to use
17079 only the first eight characters of the password. However, in modern operating
17080 systems this is no longer true, and in many cases the entire password is used,
17081 whatever its length.
17082 </para>
17083 </listitem>
17084 <listitem>
17085 <para>
17086 <indexterm role="concept">
17087 <primary><function>crypt16()</function></primary>
17088 </indexterm>
17089 <option>{crypt16}</option> calls the <function>crypt16()</function> function, which was originally created to
17090 use up to 16 characters of the password in some operating systems. Again, in
17091 modern operating systems, more characters may be used.
17092 </para>
17093 </listitem>
17094 </itemizedlist>
17095 <para>
17096 Exim has its own version of <function>crypt16()</function>, which is just a double call to
17097 <function>crypt()</function>. For operating systems that have their own version, setting
17098 HAVE_CRYPT16 in <filename>Local/Makefile</filename> when building Exim causes it to use the
17099 operating system version instead of its own. This option is set by default in
17100 the OS-dependent <filename>Makefile</filename> for those operating systems that are known to
17101 support <function>crypt16()</function>.
17102 </para>
17103 <para>
17104 Some years after Exim&#x2019;s <function>crypt16()</function> was implemented, a user discovered that
17105 it was not using the same algorithm as some operating systems&#x2019; versions. It
17106 turns out that as well as <function>crypt16()</function> there is a function called
17107 <function>bigcrypt()</function> in some operating systems. This may or may not use the same
17108 algorithm, and both of them may be different to Exim&#x2019;s built-in <function>crypt16()</function>.
17109 </para>
17110 <para>
17111 However, since there is now a move away from the traditional <function>crypt()</function>
17112 functions towards using SHA1 and other algorithms, tidying up this area of
17113 Exim is seen as very low priority.
17114 </para>
17115 <para>
17116 If you do not put a encryption type (in curly brackets) in a <option>crypteq</option>
17117 comparison, the default is usually either <literal>{crypt}</literal> or <literal>{crypt16}</literal>, as
17118 determined by the setting of DEFAULT_CRYPT in <filename>Local/Makefile</filename>. The default
17119 default is <literal>{crypt}</literal>. Whatever the default, you can always use either
17120 function by specifying it explicitly in curly brackets.
17121 </para>
17122 </listitem></varlistentry>
17123 <varlistentry>
17124 <term><emphasis role="bold">def:</emphasis>&lt;<emphasis>variable&nbsp;name</emphasis>&gt;</term>
17125 <listitem>
17126 <para>
17127 <indexterm role="concept">
17128 <primary>expansion</primary>
17129 <secondary>checking for empty variable</secondary>
17130 </indexterm>
17131 <indexterm role="concept">
17132 <primary><option>def</option> expansion condition</primary>
17133 </indexterm>
17134 The <option>def</option> condition must be followed by the name of one of the expansion
17135 variables defined in section <xref linkend="SECTexpvar"/>. The condition is true if the
17136 variable does not contain the empty string. For example:
17137 </para>
17138 <literallayout class="monospaced">
17139 ${if def:sender_ident {from $sender_ident}}
17140 </literallayout>
17141 <para>
17142 Note that the variable name is given without a leading <option>$</option> character. If the
17143 variable does not exist, the expansion fails.
17144 </para>
17145 </listitem></varlistentry>
17146 <varlistentry>
17147 <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>
17148 <listitem>
17149 <para>
17150 <indexterm role="concept">
17151 <primary>expansion</primary>
17152 <secondary>checking header line existence</secondary>
17153 </indexterm>
17154 This condition is true if a message is being processed and the named header
17155 exists in the message. For example,
17156 </para>
17157 <literallayout class="monospaced">
17158 ${if def:header_reply-to:{$h_reply-to:}{$h_from:}}
17159 </literallayout>
17160 <para>
17161 <emphasis role="bold">Note</emphasis>: No <option>$</option> appears before <option>header_</option> or <option>h_</option> in the condition, and
17162 the header name must be terminated by a colon if white space does not follow.
17163 </para>
17164 </listitem></varlistentry>
17165 <varlistentry>
17166 <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>
17167 <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>
17168 <listitem>
17169 <para>
17170 <indexterm role="concept">
17171 <primary>string</primary>
17172 <secondary>comparison</secondary>
17173 </indexterm>
17174 <indexterm role="concept">
17175 <primary>expansion</primary>
17176 <secondary>string comparison</secondary>
17177 </indexterm>
17178 <indexterm role="concept">
17179 <primary><option>eq</option> expansion condition</primary>
17180 </indexterm>
17181 <indexterm role="concept">
17182 <primary><option>eqi</option> expansion condition</primary>
17183 </indexterm>
17184 The two substrings are first expanded. The condition is true if the two
17185 resulting strings are identical. For <option>eq</option> the comparison includes the case of
17186 letters, whereas for <option>eqi</option> the comparison is case-independent, where
17187 case is defined per the system C locale.
17188 </para>
17189 </listitem></varlistentry>
17190 <varlistentry>
17191 <term><emphasis role="bold">exists&nbsp;{</emphasis>&lt;<emphasis>file&nbsp;name</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
17192 <listitem>
17193 <para>
17194 <indexterm role="concept">
17195 <primary>expansion</primary>
17196 <secondary>file existence test</secondary>
17197 </indexterm>
17198 <indexterm role="concept">
17199 <primary>file</primary>
17200 <secondary>existence test</secondary>
17201 </indexterm>
17202 <indexterm role="concept">
17203 <primary><option>exists</option>, expansion condition</primary>
17204 </indexterm>
17205 The substring is first expanded and then interpreted as an absolute path. The
17206 condition is true if the named file (or directory) exists. The existence test
17207 is done by calling the <function>stat()</function> function. The use of the <option>exists</option> test in
17208 users&#x2019; filter files may be locked out by the system administrator.
17209 </para>
17210 </listitem></varlistentry>
17211 <varlistentry>
17212 <term><emphasis role="bold">first_delivery</emphasis></term>
17213 <listitem>
17214 <para>
17215 <indexterm role="concept">
17216 <primary>delivery</primary>
17217 <secondary>first</secondary>
17218 </indexterm>
17219 <indexterm role="concept">
17220 <primary>first delivery</primary>
17221 </indexterm>
17222 <indexterm role="concept">
17223 <primary>expansion</primary>
17224 <secondary>first delivery test</secondary>
17225 </indexterm>
17226 <indexterm role="concept">
17227 <primary><option>first_delivery</option> expansion condition</primary>
17228 </indexterm>
17229 This condition, which has no data, is true during a message&#x2019;s first delivery
17230 attempt. It is false during any subsequent delivery attempts.
17231 </para>
17232 </listitem></varlistentry>
17233 <varlistentry>
17234 <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>
17235 <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>
17236 <listitem>
17237 <para>
17238 <indexterm role="concept">
17239 <primary>list</primary>
17240 <secondary>iterative conditions</secondary>
17241 </indexterm>
17242 <indexterm role="concept">
17243 <primary>expansion</primary>
17244 <secondary><emphasis role="bold">forall</emphasis> condition</secondary>
17245 </indexterm>
17246 <indexterm role="concept">
17247 <primary>expansion</primary>
17248 <secondary><emphasis role="bold">forany</emphasis> condition</secondary>
17249 </indexterm>
17250 <indexterm role="variable">
17251 <primary><varname>$item</varname></primary>
17252 </indexterm>
17253 These conditions iterate over a list. The first argument is expanded to form
17254 the list. By default, the list separator is a colon, but it can be changed by
17255 the normal method (<xref linkend="SECTlistsepchange"/>).
17256 The second argument is interpreted as a condition that is to
17257 be applied to each item in the list in turn. During the interpretation of the
17258 condition, the current list item is placed in a variable called <varname>$item</varname>.
17259 </para>
17260 <itemizedlist>
17261 <listitem>
17262 <para>
17263 For <emphasis role="bold">forany</emphasis>, interpretation stops if the condition is true for any item, and
17264 the result of the whole condition is true. If the condition is false for all
17265 items in the list, the overall condition is false.
17266 </para>
17267 </listitem>
17268 <listitem>
17269 <para>
17270 For <emphasis role="bold">forall</emphasis>, interpretation stops if the condition is false for any item,
17271 and the result of the whole condition is false. If the condition is true for
17272 all items in the list, the overall condition is true.
17273 </para>
17274 </listitem>
17275 </itemizedlist>
17276 <para>
17277 Note that negation of <emphasis role="bold">forany</emphasis> means that the condition must be false for all
17278 items for the overall condition to succeed, and negation of <emphasis role="bold">forall</emphasis> means
17279 that the condition must be false for at least one item. In this example, the
17280 list separator is changed to a comma:
17281 </para>
17282 <literallayout class="monospaced">
17283 ${if forany{&lt;, $recipients}{match{$item}{^user3@}}{yes}{no}}
17284 </literallayout>
17285 <para>
17286 The value of <varname>$item</varname> is saved and restored while <option>forany</option> or <option>forall</option> is
17287 being processed, to enable these expansion items to be nested.
17288 </para>
17289 <para>
17290 To scan a named list, expand it with the <emphasis role="bold">listnamed</emphasis> operator.
17291 </para>
17292 </listitem></varlistentry>
17293 <varlistentry revisionflag="changed">
17294 <term><emphasis role="bold">forall_json{</emphasis>&lt;<emphasis>a JSON array</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>a condition</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
17295 <term><emphasis role="bold">forany_json{</emphasis>&lt;<emphasis>a JSON array</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>a condition</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
17296 <term><emphasis role="bold">forall_jsons{</emphasis>&lt;<emphasis>a JSON array</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>a condition</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
17297 <term><emphasis role="bold">forany_jsons{</emphasis>&lt;<emphasis>a JSON array</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>a condition</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
17298 <listitem>
17299 <para revisionflag="changed">
17300 <indexterm role="concept">
17301 <primary>JSON</primary>
17302 <secondary>iterative conditions</secondary>
17303 </indexterm>
17304 <indexterm role="concept">
17305 <primary>JSON</primary>
17306 <secondary>expansions</secondary>
17307 </indexterm>
17308 <indexterm role="concept">
17309 <primary>expansion</primary>
17310 <secondary><emphasis role="bold">forall_json</emphasis> condition</secondary>
17311 </indexterm>
17312 <indexterm role="concept">
17313 <primary>expansion</primary>
17314 <secondary><emphasis role="bold">forany_json</emphasis> condition</secondary>
17315 </indexterm>
17316 <indexterm role="concept">
17317 <primary>expansion</primary>
17318 <secondary><emphasis role="bold">forall_jsons</emphasis> condition</secondary>
17319 </indexterm>
17320 <indexterm role="concept">
17321 <primary>expansion</primary>
17322 <secondary><emphasis role="bold">forany_jsons</emphasis> condition</secondary>
17323 </indexterm>
17324 As for the above, except that the first argument must, after expansion,
17325 be a JSON array.
17326 The array separator is not changeable.
17327 For the <quote>jsons</quote> variants the elements are expected to be JSON strings
17328 and have their quotes removed before the evaluation of the condition.
17329 </para>
17330 </listitem></varlistentry>
17331 <varlistentry>
17332 <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>
17333 <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>
17334 <listitem>
17335 <para>
17336 <indexterm role="concept">
17337 <primary>string</primary>
17338 <secondary>comparison</secondary>
17339 </indexterm>
17340 <indexterm role="concept">
17341 <primary>expansion</primary>
17342 <secondary>string comparison</secondary>
17343 </indexterm>
17344 <indexterm role="concept">
17345 <primary><option>ge</option> expansion condition</primary>
17346 </indexterm>
17347 <indexterm role="concept">
17348 <primary><option>gei</option> expansion condition</primary>
17349 </indexterm>
17350 The two substrings are first expanded. The condition is true if the first
17351 string is lexically greater than or equal to the second string. For <option>ge</option> the
17352 comparison includes the case of letters, whereas for <option>gei</option> the comparison is
17353 case-independent.
17354 Case and collation order are defined per the system C locale.
17355 </para>
17356 </listitem></varlistentry>
17357 <varlistentry>
17358 <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>
17359 <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>
17360 <listitem>
17361 <para>
17362 <indexterm role="concept">
17363 <primary>string</primary>
17364 <secondary>comparison</secondary>
17365 </indexterm>
17366 <indexterm role="concept">
17367 <primary>expansion</primary>
17368 <secondary>string comparison</secondary>
17369 </indexterm>
17370 <indexterm role="concept">
17371 <primary><option>gt</option> expansion condition</primary>
17372 </indexterm>
17373 <indexterm role="concept">
17374 <primary><option>gti</option> expansion condition</primary>
17375 </indexterm>
17376 The two substrings are first expanded. The condition is true if the first
17377 string is lexically greater than the second string. For <option>gt</option> the comparison
17378 includes the case of letters, whereas for <option>gti</option> the comparison is
17379 case-independent.
17380 Case and collation order are defined per the system C locale.
17381 </para>
17382 </listitem></varlistentry>
17383 <varlistentry>
17384 <term><emphasis role="bold">inlist&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
17385 <term><emphasis role="bold">inlisti&nbsp;{</emphasis>&lt;<emphasis>string1</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>string2</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
17386 <listitem>
17387 <para>
17388 <indexterm role="concept">
17389 <primary>string</primary>
17390 <secondary>comparison</secondary>
17391 </indexterm>
17392 <indexterm role="concept">
17393 <primary>list</primary>
17394 <secondary>iterative conditions</secondary>
17395 </indexterm>
17396 Both strings are expanded; the second string is treated as a list of simple
17397 strings; if the first string is a member of the second, then the condition
17398 is true.
17399 For the case-independent <option>inlisti</option> condition, case is defined per the system C locale.
17400 </para>
17401 <para>
17402 These are simpler to use versions of the more powerful <emphasis role="bold">forany</emphasis> condition.
17403 Examples, and the <emphasis role="bold">forany</emphasis> equivalents:
17404 </para>
17405 <literallayout class="monospaced">
17406 ${if inlist{needle}{foo:needle:bar}}
17407   ${if forany{foo:needle:bar}{eq{$item}{needle}}}
17408 ${if inlisti{Needle}{fOo:NeeDLE:bAr}}
17409   ${if forany{fOo:NeeDLE:bAr}{eqi{$item}{Needle}}}
17410 </literallayout>
17411 </listitem></varlistentry>
17412 <varlistentry>
17413 <term><emphasis role="bold">isip&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
17414 <term><emphasis role="bold">isip4&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
17415 <term><emphasis role="bold">isip6&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
17416 <listitem>
17417 <para>
17418 <indexterm role="concept">
17419 <primary>IP address</primary>
17420 <secondary>testing string format</secondary>
17421 </indexterm>
17422 <indexterm role="concept">
17423 <primary>string</primary>
17424 <secondary>testing for IP address</secondary>
17425 </indexterm>
17426 <indexterm role="concept">
17427 <primary><option>isip</option> expansion condition</primary>
17428 </indexterm>
17429 <indexterm role="concept">
17430 <primary><option>isip4</option> expansion condition</primary>
17431 </indexterm>
17432 <indexterm role="concept">
17433 <primary><option>isip6</option> expansion condition</primary>
17434 </indexterm>
17435 The substring is first expanded, and then tested to see if it has the form of
17436 an IP address. Both IPv4 and IPv6 addresses are valid for <option>isip</option>, whereas
17437 <option>isip4</option> and <option>isip6</option> test specifically for IPv4 or IPv6 addresses.
17438 </para>
17439 <para>
17440 For an IPv4 address, the test is for four dot-separated components, each of
17441 which consists of from one to three digits. For an IPv6 address, up to eight
17442 colon-separated components are permitted, each containing from one to four
17443 hexadecimal digits. There may be fewer than eight components if an empty
17444 component (adjacent colons) is present. Only one empty component is permitted.
17445 </para>
17446 <para>
17447 <emphasis role="bold">Note</emphasis>: The checks used to be just on the form of the address; actual numerical
17448 values were not considered. Thus, for example, 999.999.999.999 passed the IPv4
17449 check.
17450 This is no longer the case.
17451 </para>
17452 <para>
17453 The main use of these tests is to distinguish between IP addresses and
17454 host names, or between IPv4 and IPv6 addresses. For example, you could use
17455 </para>
17456 <literallayout class="monospaced">
17457 ${if isip4{$sender_host_address}...
17458 </literallayout>
17459 <para>
17460 to test which IP version an incoming SMTP connection is using.
17461 </para>
17462 </listitem></varlistentry>
17463 <varlistentry>
17464 <term><emphasis role="bold">ldapauth&nbsp;{</emphasis>&lt;<emphasis>ldap&nbsp;query</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
17465 <listitem>
17466 <para>
17467 <indexterm role="concept">
17468 <primary>LDAP</primary>
17469 <secondary>use for authentication</secondary>
17470 </indexterm>
17471 <indexterm role="concept">
17472 <primary>expansion</primary>
17473 <secondary>LDAP authentication test</secondary>
17474 </indexterm>
17475 <indexterm role="concept">
17476 <primary><option>ldapauth</option> expansion condition</primary>
17477 </indexterm>
17478 This condition supports user authentication using LDAP. See section
17479 <xref linkend="SECTldap"/> for details of how to use LDAP in lookups and the syntax of
17480 queries. For this use, the query must contain a user name and password. The
17481 query itself is not used, and can be empty. The condition is true if the
17482 password is not empty, and the user name and password are accepted by the LDAP
17483 server. An empty password is rejected without calling LDAP because LDAP binds
17484 with an empty password are considered anonymous regardless of the username, and
17485 will succeed in most configurations. See chapter <xref linkend="CHAPSMTPAUTH"/> for details
17486 of SMTP authentication, and chapter <xref linkend="CHAPplaintext"/> for an example of how
17487 this can be used.
17488 </para>
17489 </listitem></varlistentry>
17490 <varlistentry>
17491 <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>
17492 <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>
17493 <listitem>
17494 <para>
17495 <indexterm role="concept">
17496 <primary>string</primary>
17497 <secondary>comparison</secondary>
17498 </indexterm>
17499 <indexterm role="concept">
17500 <primary>expansion</primary>
17501 <secondary>string comparison</secondary>
17502 </indexterm>
17503 <indexterm role="concept">
17504 <primary><option>le</option> expansion condition</primary>
17505 </indexterm>
17506 <indexterm role="concept">
17507 <primary><option>lei</option> expansion condition</primary>
17508 </indexterm>
17509 The two substrings are first expanded. The condition is true if the first
17510 string is lexically less than or equal to the second string. For <option>le</option> the
17511 comparison includes the case of letters, whereas for <option>lei</option> the comparison is
17512 case-independent.
17513 Case and collation order are defined per the system C locale.
17514 </para>
17515 </listitem></varlistentry>
17516 <varlistentry>
17517 <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>
17518 <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>
17519 <listitem>
17520 <para>
17521 <indexterm role="concept">
17522 <primary>string</primary>
17523 <secondary>comparison</secondary>
17524 </indexterm>
17525 <indexterm role="concept">
17526 <primary>expansion</primary>
17527 <secondary>string comparison</secondary>
17528 </indexterm>
17529 <indexterm role="concept">
17530 <primary><option>lt</option> expansion condition</primary>
17531 </indexterm>
17532 <indexterm role="concept">
17533 <primary><option>lti</option> expansion condition</primary>
17534 </indexterm>
17535 The two substrings are first expanded. The condition is true if the first
17536 string is lexically less than the second string. For <option>lt</option> the comparison
17537 includes the case of letters, whereas for <option>lti</option> the comparison is
17538 case-independent.
17539 Case and collation order are defined per the system C locale.
17540 </para>
17541 </listitem></varlistentry>
17542 <varlistentry>
17543 <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>
17544 <listitem>
17545 <para>
17546 <indexterm role="concept">
17547 <primary>expansion</primary>
17548 <secondary>regular expression comparison</secondary>
17549 </indexterm>
17550 <indexterm role="concept">
17551 <primary>regular expressions</primary>
17552 <secondary>match in expanded string</secondary>
17553 </indexterm>
17554 <indexterm role="concept">
17555 <primary><option>match</option> expansion condition</primary>
17556 </indexterm>
17557 The two substrings are first expanded. The second is then treated as a regular
17558 expression and applied to the first. Because of the pre-expansion, if the
17559 regular expression contains dollar, or backslash characters, they must be
17560 escaped. Care must also be taken if the regular expression contains braces
17561 (curly brackets). A closing brace must be escaped so that it is not taken as a
17562 premature termination of &lt;<emphasis>string2</emphasis>&gt;. The easiest approach is to use the
17563 <literal>\N</literal> feature to disable expansion of the regular expression.
17564 For example,
17565 </para>
17566 <literallayout class="monospaced">
17567 ${if match {$local_part}{\N^\d{3}\N} ...
17568 </literallayout>
17569 <para>
17570 If the whole expansion string is in double quotes, further escaping of
17571 backslashes is also required.
17572 </para>
17573 <para>
17574 The condition is true if the regular expression match succeeds.
17575 The regular expression is not required to begin with a circumflex
17576 metacharacter, but if there is no circumflex, the expression is not anchored,
17577 and it may match anywhere in the subject, not just at the start. If you want
17578 the pattern to match at the end of the subject, you must include the <literal>$</literal>
17579 metacharacter at an appropriate point.
17580 All character handling is done in bytes and is not UTF-8 aware,
17581 but we might change this in a future Exim release.
17582 </para>
17583 <para>
17584 <indexterm role="concept">
17585 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
17586 <secondary>in <option>if</option> expansion</secondary>
17587 </indexterm>
17588 At the start of an <option>if</option> expansion the values of the numeric variable
17589 substitutions <varname>$1</varname> etc. are remembered. Obeying a <option>match</option> condition that
17590 succeeds causes them to be reset to the substrings of that condition and they
17591 will have these values during the expansion of the success string. At the end
17592 of the <option>if</option> expansion, the previous values are restored. After testing a
17593 combination of conditions using <option>or</option>, the subsequent values of the numeric
17594 variables are those of the condition that succeeded.
17595 </para>
17596 </listitem></varlistentry>
17597 <varlistentry>
17598 <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>
17599 <listitem>
17600 <para>
17601 <indexterm role="concept">
17602 <primary><option>match_address</option> expansion condition</primary>
17603 </indexterm>
17604 See <emphasis role="bold">match_local_part</emphasis>.
17605 </para>
17606 </listitem></varlistentry>
17607 <varlistentry>
17608 <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>
17609 <listitem>
17610 <para>
17611 <indexterm role="concept">
17612 <primary><option>match_domain</option> expansion condition</primary>
17613 </indexterm>
17614 See <emphasis role="bold">match_local_part</emphasis>.
17615 </para>
17616 </listitem></varlistentry>
17617 <varlistentry>
17618 <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>
17619 <listitem>
17620 <para>
17621 <indexterm role="concept">
17622 <primary><option>match_ip</option> expansion condition</primary>
17623 </indexterm>
17624 This condition matches an IP address to a list of IP address patterns. It must
17625 be followed by two argument strings. The first (after expansion) must be an IP
17626 address or an empty string. The second (not expanded) is a restricted host
17627 list that can match only an IP address, not a host name. For example:
17628 </para>
17629 <literallayout class="monospaced">
17630 ${if match_ip{$sender_host_address}{1.2.3.4:5.6.7.8}{...}{...}}
17631 </literallayout>
17632 <para>
17633 The specific types of host list item that are permitted in the list are:
17634 </para>
17635 <itemizedlist>
17636 <listitem>
17637 <para>
17638 An IP address, optionally with a CIDR mask.
17639 </para>
17640 </listitem>
17641 <listitem>
17642 <para>
17643 A single asterisk, which matches any IP address.
17644 </para>
17645 </listitem>
17646 <listitem>
17647 <para>
17648 An empty item, which matches only if the IP address is empty. This could be
17649 useful for testing for a locally submitted message or one from specific hosts
17650 in a single test such as
17651 </para>
17652 <literallayout class="monospaced">
17653   ${if match_ip{$sender_host_address}{:4.3.2.1:...}{...}{...}}
17654 </literallayout>
17655 <para>
17656 where the first item in the list is the empty string.
17657 </para>
17658 </listitem>
17659 <listitem>
17660 <para>
17661 The item @[] matches any of the local host&#x2019;s interface addresses.
17662 </para>
17663 </listitem>
17664 <listitem>
17665 <para>
17666 Single-key lookups are assumed to be like <quote>net-</quote> style lookups in host lists,
17667 even if <literal>net-</literal> is not specified. There is never any attempt to turn the IP
17668 address into a host name. The most common type of linear search for
17669 <emphasis role="bold">match_ip</emphasis> is likely to be <emphasis role="bold">iplsearch</emphasis>, in which the file can contain CIDR
17670 masks. For example:
17671 </para>
17672 <literallayout class="monospaced">
17673   ${if match_ip{$sender_host_address}{iplsearch;/some/file}...
17674 </literallayout>
17675 <para>
17676 It is of course possible to use other kinds of lookup, and in such a case, you
17677 do need to specify the <literal>net-</literal> prefix if you want to specify a specific
17678 address mask, for example:
17679 </para>
17680 <literallayout class="monospaced">
17681   ${if match_ip{$sender_host_address}{net24-dbm;/some/file}...
17682 </literallayout>
17683 <para>
17684 However, unless you are combining a <option>match_ip</option> condition with others, it is
17685 just as easy to use the fact that a lookup is itself a condition, and write:
17686 </para>
17687 <literallayout class="monospaced">
17688   ${lookup{${mask:$sender_host_address/24}}dbm{/a/file}...
17689 </literallayout>
17690 </listitem>
17691 </itemizedlist>
17692 <para>
17693 Note that &lt;<emphasis>string2</emphasis>&gt; is not itself subject to string expansion, unless
17694 Exim was built with the EXPAND_LISTMATCH_RHS option.
17695 </para>
17696 <para>
17697 Consult section <xref linkend="SECThoslispatip"/> for further details of these patterns.
17698 </para>
17699 </listitem></varlistentry>
17700 <varlistentry>
17701 <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>
17702 <listitem>
17703 <para>
17704 <indexterm role="concept">
17705 <primary>domain list</primary>
17706 <secondary>in expansion condition</secondary>
17707 </indexterm>
17708 <indexterm role="concept">
17709 <primary>address list</primary>
17710 <secondary>in expansion condition</secondary>
17711 </indexterm>
17712 <indexterm role="concept">
17713 <primary>local part</primary>
17714 <secondary>list, in expansion condition</secondary>
17715 </indexterm>
17716 <indexterm role="concept">
17717 <primary><option>match_local_part</option> expansion condition</primary>
17718 </indexterm>
17719 This condition, together with <option>match_address</option> and <option>match_domain</option>, make it
17720 possible to test domain, address, and local part lists within expansions. Each
17721 condition requires two arguments: an item and a list to match. A trivial
17722 example is:
17723 </para>
17724 <literallayout class="monospaced">
17725 ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
17726 </literallayout>
17727 <para>
17728 In each case, the second argument may contain any of the allowable items for a
17729 list of the appropriate type. Also, because the second argument
17730 is a standard form of list, it is possible to refer to a named list.
17731 Thus, you can use conditions like this:
17732 </para>
17733 <literallayout class="monospaced">
17734 ${if match_domain{$domain}{+local_domains}{...
17735 </literallayout>
17736 <para>
17737 <indexterm role="concept">
17738 <primary><literal>+caseful</literal></primary>
17739 </indexterm>
17740 For address lists, the matching starts off caselessly, but the <literal>+caseful</literal>
17741 item can be used, as in all address lists, to cause subsequent items to
17742 have their local parts matched casefully. Domains are always matched
17743 caselessly.
17744 </para>
17745 <para>
17746 Note that &lt;<emphasis>string2</emphasis>&gt; is not itself subject to string expansion, unless
17747 Exim was built with the EXPAND_LISTMATCH_RHS option.
17748 </para>
17749 <para>
17750 <emphasis role="bold">Note</emphasis>: Host lists are <emphasis>not</emphasis> supported in this way. This is because
17751 hosts have two identities: a name and an IP address, and it is not clear
17752 how to specify cleanly how such a test would work. However, IP addresses can be
17753 matched using <option>match_ip</option>.
17754 </para>
17755 </listitem></varlistentry>
17756 <varlistentry>
17757 <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>
17758 <listitem>
17759 <para>
17760 <indexterm role="concept">
17761 <primary>PAM authentication</primary>
17762 </indexterm>
17763 <indexterm role="concept">
17764 <primary>AUTH</primary>
17765 <secondary>with PAM</secondary>
17766 </indexterm>
17767 <indexterm role="concept">
17768 <primary>Solaris</primary>
17769 <secondary>PAM support</secondary>
17770 </indexterm>
17771 <indexterm role="concept">
17772 <primary>expansion</primary>
17773 <secondary>PAM authentication test</secondary>
17774 </indexterm>
17775 <indexterm role="concept">
17776 <primary><option>pam</option> expansion condition</primary>
17777 </indexterm>
17778 <emphasis>Pluggable Authentication Modules</emphasis>
17779 (<emphasis role="bold"><ulink url="https://mirrors.edge.kernel.org/pub/linux/libs/pam/">https://mirrors.edge.kernel.org/pub/linux/libs/pam/</ulink></emphasis>) are a facility that is
17780 available in the latest releases of Solaris and in some GNU/Linux
17781 distributions. The Exim support, which is intended for use in conjunction with
17782 the SMTP AUTH command, is available only if Exim is compiled with
17783 </para>
17784 <literallayout class="monospaced">
17785 SUPPORT_PAM=yes
17786 </literallayout>
17787 <para>
17788 in <filename>Local/Makefile</filename>. You probably need to add <option>-lpam</option> to EXTRALIBS, and
17789 in some releases of GNU/Linux <option>-ldl</option> is also needed.
17790 </para>
17791 <para>
17792 The argument string is first expanded, and the result must be a
17793 colon-separated list of strings. Leading and trailing white space is ignored.
17794 The PAM module is initialized with the service name <quote>exim</quote> and the user name
17795 taken from the first item in the colon-separated data string (&lt;<emphasis>string1</emphasis>&gt;).
17796 The remaining items in the data string are passed over in response to requests
17797 from the authentication function. In the simple case there will only be one
17798 request, for a password, so the data consists of just two strings.
17799 </para>
17800 <para>
17801 There can be problems if any of the strings are permitted to contain colon
17802 characters. In the usual way, these have to be doubled to avoid being taken as
17803 separators. If the data is being inserted from a variable, the <option>sg</option> expansion
17804 item can be used to double any existing colons. For example, the configuration
17805 of a LOGIN authenticator might contain this setting:
17806 </para>
17807 <literallayout class="monospaced">
17808 server_condition = ${if pam{$auth1:${sg{$auth2}{:}{::}}}}
17809 </literallayout>
17810 <para>
17811 For a PLAIN authenticator you could use:
17812 </para>
17813 <literallayout class="monospaced">
17814 server_condition = ${if pam{$auth2:${sg{$auth3}{:}{::}}}}
17815 </literallayout>
17816 <para>
17817 In some operating systems, PAM authentication can be done only from a process
17818 running as root. Since Exim is running as the Exim user when receiving
17819 messages, this means that PAM cannot be used directly in those systems.
17820 </para>
17821 </listitem></varlistentry>
17822 <varlistentry>
17823 <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>
17824 <listitem>
17825 <para>
17826 <indexterm role="concept">
17827 <primary><emphasis>pwcheck</emphasis> daemon</primary>
17828 </indexterm>
17829 <indexterm role="concept">
17830 <primary>Cyrus</primary>
17831 </indexterm>
17832 <indexterm role="concept">
17833 <primary>expansion</primary>
17834 <secondary><emphasis>pwcheck</emphasis> authentication test</secondary>
17835 </indexterm>
17836 <indexterm role="concept">
17837 <primary><option>pwcheck</option> expansion condition</primary>
17838 </indexterm>
17839 This condition supports user authentication using the Cyrus <emphasis>pwcheck</emphasis> daemon.
17840 This is one way of making it possible for passwords to be checked by a process
17841 that is not running as root. <emphasis role="bold">Note</emphasis>: The use of <emphasis>pwcheck</emphasis> is now
17842 deprecated. Its replacement is <emphasis>saslauthd</emphasis> (see below).
17843 </para>
17844 <para>
17845 The pwcheck support is not included in Exim by default. You need to specify
17846 the location of the pwcheck daemon&#x2019;s socket in <filename>Local/Makefile</filename> before
17847 building Exim. For example:
17848 </para>
17849 <literallayout class="monospaced">
17850 CYRUS_PWCHECK_SOCKET=/var/pwcheck/pwcheck
17851 </literallayout>
17852 <para>
17853 You do not need to install the full Cyrus software suite in order to use
17854 the pwcheck daemon. You can compile and install just the daemon alone
17855 from the Cyrus SASL library. Ensure that <emphasis>exim</emphasis> is the only user that has
17856 access to the <filename>/var/pwcheck</filename> directory.
17857 </para>
17858 <para>
17859 The <option>pwcheck</option> condition takes one argument, which must be the user name and
17860 password, separated by a colon. For example, in a LOGIN authenticator
17861 configuration, you might have this:
17862 </para>
17863 <literallayout class="monospaced">
17864 server_condition = ${if pwcheck{$auth1:$auth2}}
17865 </literallayout>
17866 <para>
17867 Again, for a PLAIN authenticator configuration, this would be:
17868 </para>
17869 <literallayout class="monospaced">
17870 server_condition = ${if pwcheck{$auth2:$auth3}}
17871 </literallayout>
17872 </listitem></varlistentry>
17873 <varlistentry>
17874 <term><emphasis role="bold">queue_running</emphasis></term>
17875 <listitem>
17876 <para>
17877 <indexterm role="concept">
17878 <primary>queue runner</primary>
17879 <secondary>detecting when delivering from</secondary>
17880 </indexterm>
17881 <indexterm role="concept">
17882 <primary>expansion</primary>
17883 <secondary>queue runner test</secondary>
17884 </indexterm>
17885 <indexterm role="concept">
17886 <primary><option>queue_running</option> expansion condition</primary>
17887 </indexterm>
17888 This condition, which has no data, is true during delivery attempts that are
17889 initiated by queue runner processes, and false otherwise.
17890 </para>
17891 </listitem></varlistentry>
17892 <varlistentry>
17893 <term><emphasis role="bold">radius&nbsp;{</emphasis>&lt;<emphasis>authentication&nbsp;string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
17894 <listitem>
17895 <para>
17896 <indexterm role="concept">
17897 <primary>Radius</primary>
17898 </indexterm>
17899 <indexterm role="concept">
17900 <primary>expansion</primary>
17901 <secondary>Radius authentication</secondary>
17902 </indexterm>
17903 <indexterm role="concept">
17904 <primary><option>radius</option> expansion condition</primary>
17905 </indexterm>
17906 Radius authentication (RFC 2865) is supported in a similar way to PAM. You must
17907 set RADIUS_CONFIG_FILE in <filename>Local/Makefile</filename> to specify the location of
17908 the Radius client configuration file in order to build Exim with Radius
17909 support.
17910 </para>
17911 <para>
17912 With just that one setting, Exim expects to be linked with the <option>radiusclient</option>
17913 library, using the original API. If you are using release 0.4.0 or later of
17914 this library, you need to set
17915 </para>
17916 <literallayout class="monospaced">
17917 RADIUS_LIB_TYPE=RADIUSCLIENTNEW
17918 </literallayout>
17919 <para>
17920 in <filename>Local/Makefile</filename> when building Exim. You can also link Exim with the
17921 <option>libradius</option> library that comes with FreeBSD. To do this, set
17922 </para>
17923 <literallayout class="monospaced">
17924 RADIUS_LIB_TYPE=RADLIB
17925 </literallayout>
17926 <para>
17927 in <filename>Local/Makefile</filename>, in addition to setting RADIUS_CONFIGURE_FILE.
17928 You may also have to supply a suitable setting in EXTRALIBS so that the
17929 Radius library can be found when Exim is linked.
17930 </para>
17931 <para>
17932 The string specified by RADIUS_CONFIG_FILE is expanded and passed to the
17933 Radius client library, which calls the Radius server. The condition is true if
17934 the authentication is successful. For example:
17935 </para>
17936 <literallayout class="monospaced">
17937 server_condition = ${if radius{&lt;arguments&gt;}}
17938 </literallayout>
17939 </listitem></varlistentry>
17940 <varlistentry>
17941 <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>
17942 <listitem>
17943 <para>
17944 <indexterm role="concept">
17945 <primary><emphasis>saslauthd</emphasis> daemon</primary>
17946 </indexterm>
17947 <indexterm role="concept">
17948 <primary>Cyrus</primary>
17949 </indexterm>
17950 <indexterm role="concept">
17951 <primary>expansion</primary>
17952 <secondary><emphasis>saslauthd</emphasis> authentication test</secondary>
17953 </indexterm>
17954 <indexterm role="concept">
17955 <primary><option>saslauthd</option> expansion condition</primary>
17956 </indexterm>
17957 This condition supports user authentication using the Cyrus <emphasis>saslauthd</emphasis>
17958 daemon. This replaces the older <emphasis>pwcheck</emphasis> daemon, which is now deprecated.
17959 Using this daemon is one way of making it possible for passwords to be checked
17960 by a process that is not running as root.
17961 </para>
17962 <para>
17963 The saslauthd support is not included in Exim by default. You need to specify
17964 the location of the saslauthd daemon&#x2019;s socket in <filename>Local/Makefile</filename> before
17965 building Exim. For example:
17966 </para>
17967 <literallayout class="monospaced">
17968 CYRUS_SASLAUTHD_SOCKET=/var/state/saslauthd/mux
17969 </literallayout>
17970 <para>
17971 You do not need to install the full Cyrus software suite in order to use
17972 the saslauthd daemon. You can compile and install just the daemon alone
17973 from the Cyrus SASL library.
17974 </para>
17975 <para>
17976 Up to four arguments can be supplied to the <option>saslauthd</option> condition, but only
17977 two are mandatory. For example:
17978 </para>
17979 <literallayout class="monospaced">
17980 server_condition = ${if saslauthd{{$auth1}{$auth2}}}
17981 </literallayout>
17982 <para>
17983 The service and the realm are optional (which is why the arguments are enclosed
17984 in their own set of braces). For details of the meaning of the service and
17985 realm, and how to run the daemon, consult the Cyrus documentation.
17986 </para>
17987 </listitem></varlistentry>
17988 </variablelist>
17989 </section>
17990 <section id="SECID84">
17991 <title>Combining expansion conditions</title>
17992 <para>
17993 <indexterm role="concept">
17994 <primary>expansion</primary>
17995 <secondary>combining conditions</secondary>
17996 </indexterm>
17997 Several conditions can be tested at once by combining them using the <option>and</option>
17998 and <option>or</option> combination conditions. Note that <option>and</option> and <option>or</option> are complete
17999 conditions on their own, and precede their lists of sub-conditions. Each
18000 sub-condition must be enclosed in braces within the overall braces that contain
18001 the list. No repetition of <option>if</option> is used.
18002 </para>
18003 <variablelist>
18004 <varlistentry>
18005 <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>
18006 <listitem>
18007 <para>
18008 <indexterm role="concept">
18009 <primary><quote>or</quote> expansion condition</primary>
18010 </indexterm>
18011 <indexterm role="concept">
18012 <primary>expansion</primary>
18013 <secondary><quote>or</quote> of conditions</secondary>
18014 </indexterm>
18015 The sub-conditions are evaluated from left to right. The condition is true if
18016 any one of the sub-conditions is true.
18017 For example,
18018 </para>
18019 <literallayout class="monospaced">
18020 ${if or {{eq{$local_part}{spqr}}{eq{$domain}{testing.com}}}...
18021 </literallayout>
18022 <para>
18023 When a true sub-condition is found, the following ones are parsed but not
18024 evaluated. If there are several <quote>match</quote> sub-conditions the values of the
18025 numeric variables afterwards are taken from the first one that succeeds.
18026 </para>
18027 </listitem></varlistentry>
18028 <varlistentry>
18029 <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>
18030 <listitem>
18031 <para>
18032 <indexterm role="concept">
18033 <primary><quote>and</quote> expansion condition</primary>
18034 </indexterm>
18035 <indexterm role="concept">
18036 <primary>expansion</primary>
18037 <secondary><quote>and</quote> of conditions</secondary>
18038 </indexterm>
18039 The sub-conditions are evaluated from left to right. The condition is true if
18040 all of the sub-conditions are true. If there are several <quote>match</quote>
18041 sub-conditions, the values of the numeric variables afterwards are taken from
18042 the last one. When a false sub-condition is found, the following ones are
18043 parsed but not evaluated.
18044 </para>
18045 </listitem></varlistentry>
18046 </variablelist>
18047 <para>
18048 <indexterm role="concept" startref="IIDexpcond" class="endofrange"/>
18049 </para>
18050 </section>
18051 <section id="SECTexpvar">
18052 <title>Expansion variables</title>
18053 <para>
18054 <indexterm role="concept">
18055 <primary>expansion</primary>
18056 <secondary>variables, list of</secondary>
18057 </indexterm>
18058 This section contains an alphabetical list of all the expansion variables. Some
18059 of them are available only when Exim is compiled with specific options such as
18060 support for TLS or the content scanning extension.
18061 </para>
18062 <variablelist>
18063 <varlistentry>
18064 <term><varname>$0</varname>, <varname>$1</varname>, etc</term>
18065 <listitem>
18066 <para>
18067 <indexterm role="concept">
18068 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
18069 </indexterm>
18070 When a <option>match</option> expansion condition succeeds, these variables contain the
18071 captured substrings identified by the regular expression during subsequent
18072 processing of the success string of the containing <option>if</option> expansion item.
18073 In the expansion condition case
18074 they do not retain their values afterwards; in fact, their previous
18075 values are restored at the end of processing an <option>if</option> item. The numerical
18076 variables may also be set externally by some other matching process which
18077 precedes the expansion of the string. For example, the commands available in
18078 Exim filter files include an <option>if</option> command with its own regular expression
18079 matching condition.
18080 </para>
18081 </listitem></varlistentry>
18082 <varlistentry>
18083 <term><varname>$acl_arg1</varname>, <varname>$acl_arg2</varname>, etc</term>
18084 <listitem>
18085 <para>
18086 Within an acl condition, expansion condition or expansion item
18087 any arguments are copied to these variables,
18088 any unused variables being made empty.
18089 </para>
18090 </listitem></varlistentry>
18091 <varlistentry>
18092 <term><varname>$acl_c...</varname></term>
18093 <listitem>
18094 <para>
18095 Values can be placed in these variables by the <option>set</option> modifier in an ACL. They
18096 can be given any name that starts with <varname>$acl_c</varname> and is at least six characters
18097 long, but the sixth character must be either a digit or an underscore. For
18098 example: <varname>$acl_c5</varname>, <varname>$acl_c_mycount</varname>. The values of the <varname>$acl_c...</varname>
18099 variables persist throughout the lifetime of an SMTP connection. They can be
18100 used to pass information between ACLs and between different invocations of the
18101 same ACL. When a message is received, the values of these variables are saved
18102 with the message, and can be accessed by filters, routers, and transports
18103 during subsequent delivery.
18104 </para>
18105 </listitem></varlistentry>
18106 <varlistentry>
18107 <term><varname>$acl_m...</varname></term>
18108 <listitem>
18109 <para>
18110 These variables are like the <varname>$acl_c...</varname> variables, except that their values
18111 are reset after a message has been received. Thus, if several messages are
18112 received in one SMTP connection, <varname>$acl_m...</varname> values are not passed on from one
18113 message to the next, as <varname>$acl_c...</varname> values are. The <varname>$acl_m...</varname> variables are
18114 also reset by MAIL, RSET, EHLO, HELO, and after starting a TLS session. When a
18115 message is received, the values of these variables are saved with the message,
18116 and can be accessed by filters, routers, and transports during subsequent
18117 delivery.
18118 </para>
18119 </listitem></varlistentry>
18120 <varlistentry>
18121 <term><varname>$acl_narg</varname></term>
18122 <listitem>
18123 <para>
18124 Within an acl condition, expansion condition or expansion item
18125 this variable has the number of arguments.
18126 </para>
18127 </listitem></varlistentry>
18128 <varlistentry>
18129 <term><varname>$acl_verify_message</varname></term>
18130 <listitem>
18131 <para>
18132 <indexterm role="variable">
18133 <primary><varname>$acl_verify_message</varname></primary>
18134 </indexterm>
18135 After an address verification has failed, this variable contains the failure
18136 message. It retains its value for use in subsequent modifiers. The message can
18137 be preserved by coding like this:
18138 </para>
18139 <literallayout class="monospaced">
18140 warn !verify = sender
18141      set acl_m0 = $acl_verify_message
18142 </literallayout>
18143 <para>
18144 You can use <varname>$acl_verify_message</varname> during the expansion of the <option>message</option> or
18145 <option>log_message</option> modifiers, to include information about the verification
18146 failure.
18147 </para>
18148 </listitem></varlistentry>
18149 <varlistentry>
18150 <term><varname>$address_data</varname></term>
18151 <listitem>
18152 <para>
18153 <indexterm role="variable">
18154 <primary><varname>$address_data</varname></primary>
18155 </indexterm>
18156 This variable is set by means of the <option>address_data</option> option in routers. The
18157 value then remains with the address while it is processed by subsequent routers
18158 and eventually a transport. If the transport is handling multiple addresses,
18159 the value from the first address is used. See chapter <xref linkend="CHAProutergeneric"/>
18160 for more details. <emphasis role="bold">Note</emphasis>: The contents of <varname>$address_data</varname> are visible in
18161 user filter files.
18162 </para>
18163 <para>
18164 If <varname>$address_data</varname> is set when the routers are called from an ACL to verify
18165 a recipient address, the final value is still in the variable for subsequent
18166 conditions and modifiers of the ACL statement. If routing the address caused it
18167 to be redirected to just one address, the child address is also routed as part
18168 of the verification, and in this case the final value of <varname>$address_data</varname> is
18169 from the child&#x2019;s routing.
18170 </para>
18171 <para>
18172 If <varname>$address_data</varname> is set when the routers are called from an ACL to verify a
18173 sender address, the final value is also preserved, but this time in
18174 <varname>$sender_address_data</varname>, to distinguish it from data from a recipient
18175 address.
18176 </para>
18177 <para>
18178 In both cases (recipient and sender verification), the value does not persist
18179 after the end of the current ACL statement. If you want to preserve
18180 these values for longer, you can save them in ACL variables.
18181 </para>
18182 </listitem></varlistentry>
18183 <varlistentry>
18184 <term><varname>$address_file</varname></term>
18185 <listitem>
18186 <para>
18187 <indexterm role="variable">
18188 <primary><varname>$address_file</varname></primary>
18189 </indexterm>
18190 When, as a result of aliasing, forwarding, or filtering, a message is directed
18191 to a specific file, this variable holds the name of the file when the transport
18192 is running. At other times, the variable is empty. For example, using the
18193 default configuration, if user <option>r2d2</option> has a <filename>.forward</filename> file containing
18194 </para>
18195 <literallayout class="monospaced">
18196 /home/r2d2/savemail
18197 </literallayout>
18198 <para>
18199 then when the <command>address_file</command> transport is running, <varname>$address_file</varname>
18200 contains the text string <literal>/home/r2d2/savemail</literal>.
18201 <indexterm role="concept">
18202 <primary>Sieve filter</primary>
18203 <secondary>value of <varname>$address_file</varname></secondary>
18204 </indexterm>
18205 For Sieve filters, the value may be <quote>inbox</quote> or a relative folder name. It is
18206 then up to the transport configuration to generate an appropriate absolute path
18207 to the relevant file.
18208 </para>
18209 </listitem></varlistentry>
18210 <varlistentry>
18211 <term><varname>$address_pipe</varname></term>
18212 <listitem>
18213 <para>
18214 <indexterm role="variable">
18215 <primary><varname>$address_pipe</varname></primary>
18216 </indexterm>
18217 When, as a result of aliasing or forwarding, a message is directed to a pipe,
18218 this variable holds the pipe command when the transport is running.
18219 </para>
18220 </listitem></varlistentry>
18221 <varlistentry>
18222 <term><varname>$auth1</varname> &ndash; <varname>$auth3</varname></term>
18223 <listitem>
18224 <para>
18225 <indexterm role="variable">
18226 <primary><varname>$auth1</varname>, <varname>$auth2</varname>, etc</primary>
18227 </indexterm>
18228 These variables are used in SMTP authenticators (see chapters
18229 <xref linkend="CHAPplaintext"/>&ndash;<xref linkend="CHAPtlsauth"/>). Elsewhere, they are empty.
18230 </para>
18231 </listitem></varlistentry>
18232 <varlistentry>
18233 <term><varname>$authenticated_id</varname></term>
18234 <listitem>
18235 <para>
18236 <indexterm role="concept">
18237 <primary>authentication</primary>
18238 <secondary>id</secondary>
18239 </indexterm>
18240 <indexterm role="variable">
18241 <primary><varname>$authenticated_id</varname></primary>
18242 </indexterm>
18243 When a server successfully authenticates a client it may be configured to
18244 preserve some of the authentication information in the variable
18245 <varname>$authenticated_id</varname> (see chapter <xref linkend="CHAPSMTPAUTH"/>). For example, a
18246 user/password authenticator configuration might preserve the user name for use
18247 in the routers. Note that this is not the same information that is saved in
18248 <varname>$sender_host_authenticated</varname>.
18249 </para>
18250 <para>
18251 When a message is submitted locally (that is, not over a TCP connection)
18252 the value of <varname>$authenticated_id</varname> is normally the login name of the calling
18253 process. However, a trusted user can override this by means of the <option>-oMai</option>
18254 command line option.
18255 This second case also sets up information used by the
18256 <varname>$authresults</varname> expansion item.
18257 </para>
18258 </listitem></varlistentry>
18259 <varlistentry>
18260 <term><varname>$authenticated_fail_id</varname></term>
18261 <listitem>
18262 <para>
18263 <indexterm role="concept">
18264 <primary>authentication</primary>
18265 <secondary>fail</secondary>
18266 </indexterm>
18267 <indexterm role="variable">
18268 <primary><varname>$authenticated_fail_id</varname></primary>
18269 </indexterm>
18270 When an authentication attempt fails, the variable <varname>$authenticated_fail_id</varname>
18271 will contain the failed authentication id. If more than one authentication
18272 id is attempted, it will contain only the last one. The variable is
18273 available for processing in the ACL&#x2019;s, generally the quit or notquit ACL.
18274 A message to a local recipient could still be accepted without requiring
18275 authentication, which means this variable could also be visible in all of
18276 the ACL&#x2019;s as well.
18277 </para>
18278 </listitem></varlistentry>
18279 <varlistentry>
18280 <term><varname>$authenticated_sender</varname></term>
18281 <listitem>
18282 <para>
18283 <indexterm role="concept">
18284 <primary>sender</primary>
18285 <secondary>authenticated</secondary>
18286 </indexterm>
18287 <indexterm role="concept">
18288 <primary>authentication</primary>
18289 <secondary>sender</secondary>
18290 </indexterm>
18291 <indexterm role="concept">
18292 <primary>AUTH</primary>
18293 <secondary>on MAIL command</secondary>
18294 </indexterm>
18295 <indexterm role="variable">
18296 <primary><varname>$authenticated_sender</varname></primary>
18297 </indexterm>
18298 When acting as a server, Exim takes note of the AUTH= parameter on an incoming
18299 SMTP MAIL command if it believes the sender is sufficiently trusted, as
18300 described in section <xref linkend="SECTauthparamail"/>. Unless the data is the string
18301 <quote>&lt;&gt;</quote>, it is set as the authenticated sender of the message, and the value is
18302 available during delivery in the <varname>$authenticated_sender</varname> variable. If the
18303 sender is not trusted, Exim accepts the syntax of AUTH=, but ignores the data.
18304 </para>
18305 <para>
18306 <indexterm role="variable">
18307 <primary><varname>$qualify_domain</varname></primary>
18308 </indexterm>
18309 When a message is submitted locally (that is, not over a TCP connection), the
18310 value of <varname>$authenticated_sender</varname> is an address constructed from the login
18311 name of the calling process and <varname>$qualify_domain</varname>, except that a trusted user
18312 can override this by means of the <option>-oMas</option> command line option.
18313 </para>
18314 </listitem></varlistentry>
18315 <varlistentry>
18316 <term><varname>$authentication_failed</varname></term>
18317 <listitem>
18318 <para>
18319 <indexterm role="concept">
18320 <primary>authentication</primary>
18321 <secondary>failure</secondary>
18322 </indexterm>
18323 <indexterm role="variable">
18324 <primary><varname>$authentication_failed</varname></primary>
18325 </indexterm>
18326 This variable is set to <quote>1</quote> in an Exim server if a client issues an AUTH
18327 command that does not succeed. Otherwise it is set to <quote>0</quote>. This makes it
18328 possible to distinguish between <quote>did not try to authenticate</quote>
18329 (<varname>$sender_host_authenticated</varname> is empty and <varname>$authentication_failed</varname> is set to
18330 <quote>0</quote>) and <quote>tried to authenticate but failed</quote> (<varname>$sender_host_authenticated</varname>
18331 is empty and <varname>$authentication_failed</varname> is set to <quote>1</quote>). Failure includes any
18332 negative response to an AUTH command, including (for example) an attempt to use
18333 an undefined mechanism.
18334 </para>
18335 </listitem></varlistentry>
18336 <varlistentry>
18337 <term><varname>$av_failed</varname></term>
18338 <listitem>
18339 <para>
18340 <indexterm role="concept">
18341 <primary>content scanning</primary>
18342 <secondary>AV scanner failure</secondary>
18343 </indexterm>
18344 This variable is available when Exim is compiled with the content-scanning
18345 extension. It is set to <quote>0</quote> by default, but will be set to <quote>1</quote> if any
18346 problem occurs with the virus scanner (specified by <option>av_scanner</option>) during
18347 the ACL malware condition.
18348 </para>
18349 </listitem></varlistentry>
18350 <varlistentry>
18351 <term><varname>$body_linecount</varname></term>
18352 <listitem>
18353 <para>
18354 <indexterm role="concept">
18355 <primary>message body</primary>
18356 <secondary>line count</secondary>
18357 </indexterm>
18358 <indexterm role="concept">
18359 <primary>body of message</primary>
18360 <secondary>line count</secondary>
18361 </indexterm>
18362 <indexterm role="variable">
18363 <primary><varname>$body_linecount</varname></primary>
18364 </indexterm>
18365 When a message is being received or delivered, this variable contains the
18366 number of lines in the message&#x2019;s body. See also <varname>$message_linecount</varname>.
18367 </para>
18368 </listitem></varlistentry>
18369 <varlistentry>
18370 <term><varname>$body_zerocount</varname></term>
18371 <listitem>
18372 <para>
18373 <indexterm role="concept">
18374 <primary>message body</primary>
18375 <secondary>binary zero count</secondary>
18376 </indexterm>
18377 <indexterm role="concept">
18378 <primary>body of message</primary>
18379 <secondary>binary zero count</secondary>
18380 </indexterm>
18381 <indexterm role="concept">
18382 <primary>binary zero</primary>
18383 <secondary>in message body</secondary>
18384 </indexterm>
18385 <indexterm role="variable">
18386 <primary><varname>$body_zerocount</varname></primary>
18387 </indexterm>
18388 When a message is being received or delivered, this variable contains the
18389 number of binary zero bytes (ASCII NULs) in the message&#x2019;s body.
18390 </para>
18391 </listitem></varlistentry>
18392 <varlistentry>
18393 <term><varname>$bounce_recipient</varname></term>
18394 <listitem>
18395 <para>
18396 <indexterm role="variable">
18397 <primary><varname>$bounce_recipient</varname></primary>
18398 </indexterm>
18399 This is set to the recipient address of a bounce message while Exim is creating
18400 it. It is useful if a customized bounce message text file is in use (see
18401 chapter <xref linkend="CHAPemsgcust"/>).
18402 </para>
18403 </listitem></varlistentry>
18404 <varlistentry>
18405 <term><varname>$bounce_return_size_limit</varname></term>
18406 <listitem>
18407 <para>
18408 <indexterm role="variable">
18409 <primary><varname>$bounce_return_size_limit</varname></primary>
18410 </indexterm>
18411 This contains the value set in the <option>bounce_return_size_limit</option> option, rounded
18412 up to a multiple of 1000. It is useful when a customized error message text
18413 file is in use (see chapter <xref linkend="CHAPemsgcust"/>).
18414 </para>
18415 </listitem></varlistentry>
18416 <varlistentry>
18417 <term><varname>$caller_gid</varname></term>
18418 <listitem>
18419 <para>
18420 <indexterm role="concept">
18421 <primary>gid (group id)</primary>
18422 <secondary>caller</secondary>
18423 </indexterm>
18424 <indexterm role="variable">
18425 <primary><varname>$caller_gid</varname></primary>
18426 </indexterm>
18427 The real group id under which the process that called Exim was running. This is
18428 not the same as the group id of the originator of a message (see
18429 <varname>$originator_gid</varname>). If Exim re-execs itself, this variable in the new
18430 incarnation normally contains the Exim gid.
18431 </para>
18432 </listitem></varlistentry>
18433 <varlistentry>
18434 <term><varname>$caller_uid</varname></term>
18435 <listitem>
18436 <para>
18437 <indexterm role="concept">
18438 <primary>uid (user id)</primary>
18439 <secondary>caller</secondary>
18440 </indexterm>
18441 <indexterm role="variable">
18442 <primary><varname>$caller_uid</varname></primary>
18443 </indexterm>
18444 The real user id under which the process that called Exim was running. This is
18445 not the same as the user id of the originator of a message (see
18446 <varname>$originator_uid</varname>). If Exim re-execs itself, this variable in the new
18447 incarnation normally contains the Exim uid.
18448 </para>
18449 </listitem></varlistentry>
18450 <varlistentry>
18451 <term><varname>$callout_address</varname></term>
18452 <listitem>
18453 <para>
18454 <indexterm role="variable">
18455 <primary><varname>$callout_address</varname></primary>
18456 </indexterm>
18457 After a callout for verification, spamd or malware daemon service, the
18458 address that was connected to.
18459 </para>
18460 </listitem></varlistentry>
18461 <varlistentry>
18462 <term><varname>$compile_number</varname></term>
18463 <listitem>
18464 <para>
18465 <indexterm role="variable">
18466 <primary><varname>$compile_number</varname></primary>
18467 </indexterm>
18468 The building process for Exim keeps a count of the number
18469 of times it has been compiled. This serves to distinguish different
18470 compilations of the same version of Exim.
18471 </para>
18472 </listitem></varlistentry>
18473 <varlistentry>
18474 <term><varname>$config_dir</varname></term>
18475 <listitem>
18476 <para>
18477 <indexterm role="variable">
18478 <primary><varname>$config_dir</varname></primary>
18479 </indexterm>
18480 The directory name of the main configuration file. That is, the content of
18481 <varname>$config_file</varname> with the last component stripped. The value does not
18482 contain the trailing slash. If <varname>$config_file</varname> does not contain a slash,
18483 <varname>$config_dir</varname> is ".".
18484 </para>
18485 </listitem></varlistentry>
18486 <varlistentry>
18487 <term><varname>$config_file</varname></term>
18488 <listitem>
18489 <para>
18490 <indexterm role="variable">
18491 <primary><varname>$config_file</varname></primary>
18492 </indexterm>
18493 The name of the main configuration file Exim is using.
18494 </para>
18495 </listitem></varlistentry>
18496 <varlistentry revisionflag="changed">
18497 <term><varname>$dmarc_domain_policy</varname></term>
18498 <term><varname>$dmarc_status</varname></term>
18499 <term><varname>$dmarc_status_text</varname></term>
18500 <term><varname>$dmarc_used_domains</varname></term>
18501 <listitem>
18502 <para revisionflag="changed">
18503 Results of DMARC verification.
18504 For details see section <xref linkend="SECDMARC"/>.
18505 </para>
18506 </listitem></varlistentry>
18507 <varlistentry>
18508 <term><varname>$dkim_verify_status</varname></term>
18509 <listitem>
18510 <para>
18511 Results of DKIM verification.
18512 For details see section <xref linkend="SECDKIMVFY"/>.
18513 </para>
18514 </listitem></varlistentry>
18515 <varlistentry>
18516 <term><varname>$dkim_cur_signer</varname></term>
18517 <term><varname>$dkim_verify_reason</varname></term>
18518 <term><varname>$dkim_domain</varname></term>
18519 <term><varname>$dkim_identity</varname></term>
18520 <term><varname>$dkim_selector</varname></term>
18521 <term><varname>$dkim_algo</varname></term>
18522 <term><varname>$dkim_canon_body</varname></term>
18523 <term><varname>$dkim_canon_headers</varname></term>
18524 <term><varname>$dkim_copiedheaders</varname></term>
18525 <term><varname>$dkim_bodylength</varname></term>
18526 <term><varname>$dkim_created</varname></term>
18527 <term><varname>$dkim_expires</varname></term>
18528 <term><varname>$dkim_headernames</varname></term>
18529 <term><varname>$dkim_key_testing</varname></term>
18530 <term><varname>$dkim_key_nosubdomains</varname></term>
18531 <term><varname>$dkim_key_srvtype</varname></term>
18532 <term><varname>$dkim_key_granularity</varname></term>
18533 <term><varname>$dkim_key_notes</varname></term>
18534 <term><varname>$dkim_key_length</varname></term>
18535 <listitem>
18536 <para>
18537 These variables are only available within the DKIM ACL.
18538 For details see section <xref linkend="SECDKIMVFY"/>.
18539 </para>
18540 </listitem></varlistentry>
18541 <varlistentry>
18542 <term><varname>$dkim_signers</varname></term>
18543 <listitem>
18544 <para>
18545 <indexterm role="variable">
18546 <primary><varname>$dkim_signers</varname></primary>
18547 </indexterm>
18548 When a message has been received this variable contains
18549 a colon-separated list of signer domains and identities for the message.
18550 For details see section <xref linkend="SECDKIMVFY"/>.
18551 </para>
18552 </listitem></varlistentry>
18553 <varlistentry>
18554 <term><varname>$dnslist_domain</varname></term>
18555 <term><varname>$dnslist_matched</varname></term>
18556 <term><varname>$dnslist_text</varname></term>
18557 <term><varname>$dnslist_value</varname></term>
18558 <listitem>
18559 <para>
18560 <indexterm role="variable">
18561 <primary><varname>$dnslist_domain</varname></primary>
18562 </indexterm>
18563 <indexterm role="variable">
18564 <primary><varname>$dnslist_matched</varname></primary>
18565 </indexterm>
18566 <indexterm role="variable">
18567 <primary><varname>$dnslist_text</varname></primary>
18568 </indexterm>
18569 <indexterm role="variable">
18570 <primary><varname>$dnslist_value</varname></primary>
18571 </indexterm>
18572 <indexterm role="concept">
18573 <primary>black list (DNS)</primary>
18574 </indexterm>
18575 When a DNS (black) list lookup succeeds, these variables are set to contain
18576 the following data from the lookup: the list&#x2019;s domain name, the key that was
18577 looked up, the contents of any associated TXT record, and the value from the
18578 main A record. See section <xref linkend="SECID204"/> for more details.
18579 </para>
18580 </listitem></varlistentry>
18581 <varlistentry>
18582 <term><varname>$domain</varname></term>
18583 <listitem>
18584 <para>
18585 <indexterm role="variable">
18586 <primary><varname>$domain</varname></primary>
18587 </indexterm>
18588 When an address is being routed, or delivered on its own, this variable
18589 contains the domain. Uppercase letters in the domain are converted into lower
18590 case for <varname>$domain</varname>.
18591 </para>
18592 <para>
18593 Global address rewriting happens when a message is received, so the value of
18594 <varname>$domain</varname> during routing and delivery is the value after rewriting. <varname>$domain</varname>
18595 is set during user filtering, but not during system filtering, because a
18596 message may have many recipients and the system filter is called just once.
18597 </para>
18598 <para>
18599 When more than one address is being delivered at once (for example, several
18600 RCPT commands in one SMTP delivery), <varname>$domain</varname> is set only if they all
18601 have the same domain. Transports can be restricted to handling only one domain
18602 at a time if the value of <varname>$domain</varname> is required at transport time &ndash; this is
18603 the default for local transports. For further details of the environment in
18604 which local transports are run, see chapter <xref linkend="CHAPenvironment"/>.
18605 </para>
18606 <para>
18607 <indexterm role="option">
18608 <primary><option>delay_warning_condition</option></primary>
18609 </indexterm>
18610 At the end of a delivery, if all deferred addresses have the same domain, it is
18611 set in <varname>$domain</varname> during the expansion of <option>delay_warning_condition</option>.
18612 </para>
18613 <para>
18614 The <varname>$domain</varname> variable is also used in some other circumstances:
18615 </para>
18616 <itemizedlist>
18617 <listitem>
18618 <para>
18619 When an ACL is running for a RCPT command, <varname>$domain</varname> contains the domain of
18620 the recipient address. The domain of the <emphasis>sender</emphasis> address is in
18621 <varname>$sender_address_domain</varname> at both MAIL time and at RCPT time. <varname>$domain</varname> is not
18622 normally set during the running of the MAIL ACL. However, if the sender address
18623 is verified with a callout during the MAIL ACL, the sender domain is placed in
18624 <varname>$domain</varname> during the expansions of <option>hosts</option>, <option>interface</option>, and <option>port</option> in
18625 the <command>smtp</command> transport.
18626 </para>
18627 </listitem>
18628 <listitem>
18629 <para>
18630 When a rewrite item is being processed (see chapter <xref linkend="CHAPrewrite"/>),
18631 <varname>$domain</varname> contains the domain portion of the address that is being rewritten;
18632 it can be used in the expansion of the replacement address, for example, to
18633 rewrite domains by file lookup.
18634 </para>
18635 </listitem>
18636 <listitem>
18637 <para>
18638 With one important exception, whenever a domain list is being scanned,
18639 <varname>$domain</varname> contains the subject domain. <emphasis role="bold">Exception</emphasis>: When a domain list in
18640 a <option>sender_domains</option> condition in an ACL is being processed, the subject domain
18641 is in <varname>$sender_address_domain</varname> and not in <varname>$domain</varname>. It works this way so
18642 that, in a RCPT ACL, the sender domain list can be dependent on the
18643 recipient domain (which is what is in <varname>$domain</varname> at this time).
18644 </para>
18645 </listitem>
18646 <listitem>
18647 <para>
18648 <indexterm role="concept">
18649 <primary>ETRN</primary>
18650 <secondary>value of <varname>$domain</varname></secondary>
18651 </indexterm>
18652 <indexterm role="option">
18653 <primary><option>smtp_etrn_command</option></primary>
18654 </indexterm>
18655 When the <option>smtp_etrn_command</option> option is being expanded, <varname>$domain</varname> contains
18656 the complete argument of the ETRN command (see section <xref linkend="SECTETRN"/>).
18657 </para>
18658 </listitem>
18659 </itemizedlist>
18660 </listitem></varlistentry>
18661 <varlistentry>
18662 <term><varname>$domain_data</varname></term>
18663 <listitem>
18664 <para>
18665 <indexterm role="variable">
18666 <primary><varname>$domain_data</varname></primary>
18667 </indexterm>
18668 When the <option>domains</option> option on a router matches a domain by
18669 means of a lookup, the data read by the lookup is available during the running
18670 of the router as <varname>$domain_data</varname>. In addition, if the driver routes the
18671 address to a transport, the value is available in that transport. If the
18672 transport is handling multiple addresses, the value from the first address is
18673 used.
18674 </para>
18675 <para>
18676 <varname>$domain_data</varname> is also set when the <option>domains</option> condition in an ACL matches a
18677 domain by means of a lookup. The data read by the lookup is available during
18678 the rest of the ACL statement. In all other situations, this variable expands
18679 to nothing.
18680 </para>
18681 </listitem></varlistentry>
18682 <varlistentry>
18683 <term><varname>$exim_gid</varname></term>
18684 <listitem>
18685 <para>
18686 <indexterm role="variable">
18687 <primary><varname>$exim_gid</varname></primary>
18688 </indexterm>
18689 This variable contains the numerical value of the Exim group id.
18690 </para>
18691 </listitem></varlistentry>
18692 <varlistentry>
18693 <term><varname>$exim_path</varname></term>
18694 <listitem>
18695 <para>
18696 <indexterm role="variable">
18697 <primary><varname>$exim_path</varname></primary>
18698 </indexterm>
18699 This variable contains the path to the Exim binary.
18700 </para>
18701 </listitem></varlistentry>
18702 <varlistentry>
18703 <term><varname>$exim_uid</varname></term>
18704 <listitem>
18705 <para>
18706 <indexterm role="variable">
18707 <primary><varname>$exim_uid</varname></primary>
18708 </indexterm>
18709 This variable contains the numerical value of the Exim user id.
18710 </para>
18711 </listitem></varlistentry>
18712 <varlistentry>
18713 <term><varname>$exim_version</varname></term>
18714 <listitem>
18715 <para>
18716 <indexterm role="variable">
18717 <primary><varname>$exim_version</varname></primary>
18718 </indexterm>
18719 This variable contains the version string of the Exim build.
18720 The first character is a major version number, currently 4.
18721 Then after a dot, the next group of digits is a minor version number.
18722 There may be other characters following the minor version.
18723 This value may be overridden by the <option>exim_version</option> main config option.
18724 </para>
18725 </listitem></varlistentry>
18726 <varlistentry>
18727 <term><varname>$header_</varname>&lt;<emphasis>name</emphasis>&gt;</term>
18728 <listitem>
18729 <para>
18730 This is not strictly an expansion variable. It is expansion syntax for
18731 inserting the message header line with the given name. Note that the name must
18732 be terminated by colon or white space, because it may contain a wide variety of
18733 characters. Note also that braces must <emphasis>not</emphasis> be used.
18734 See the full description in section <xref linkend="SECTexpansionitems"/> above.
18735 </para>
18736 </listitem></varlistentry>
18737 <varlistentry>
18738 <term><varname>$headers_added</varname></term>
18739 <listitem>
18740 <para>
18741 <indexterm role="variable">
18742 <primary><varname>$headers_added</varname></primary>
18743 </indexterm>
18744 Within an ACL this variable contains the headers added so far by
18745 the ACL modifier add_header (section <xref linkend="SECTaddheadacl"/>).
18746 The headers are a newline-separated list.
18747 </para>
18748 </listitem></varlistentry>
18749 <varlistentry>
18750 <term><varname>$home</varname></term>
18751 <listitem>
18752 <para>
18753 <indexterm role="variable">
18754 <primary><varname>$home</varname></primary>
18755 </indexterm>
18756 When the <option>check_local_user</option> option is set for a router, the user&#x2019;s home
18757 directory is placed in <varname>$home</varname> when the check succeeds. In particular, this
18758 means it is set during the running of users&#x2019; filter files. A router may also
18759 explicitly set a home directory for use by a transport; this can be overridden
18760 by a setting on the transport itself.
18761 </para>
18762 <para>
18763 When running a filter test via the <option>-bf</option> option, <varname>$home</varname> is set to the value
18764 of the environment variable HOME, which is subject to the
18765 <option>keep_environment</option> and <option>add_environment</option> main config options.
18766 </para>
18767 </listitem></varlistentry>
18768 <varlistentry>
18769 <term><varname>$host</varname></term>
18770 <listitem>
18771 <para>
18772 <indexterm role="variable">
18773 <primary><varname>$host</varname></primary>
18774 </indexterm>
18775 If a router assigns an address to a transport (any transport), and passes a
18776 list of hosts with the address, the value of <varname>$host</varname> when the transport starts
18777 to run is the name of the first host on the list. Note that this applies both
18778 to local and remote transports.
18779 </para>
18780 <para>
18781 <indexterm role="concept">
18782 <primary>transport</primary>
18783 <secondary>filter</secondary>
18784 </indexterm>
18785 <indexterm role="concept">
18786 <primary>filter</primary>
18787 <secondary>transport filter</secondary>
18788 </indexterm>
18789 For the <command>smtp</command> transport, if there is more than one host, the value of
18790 <varname>$host</varname> changes as the transport works its way through the list. In
18791 particular, when the <command>smtp</command> transport is expanding its options for encryption
18792 using TLS, or for specifying a transport filter (see chapter
18793 <xref linkend="CHAPtransportgeneric"/>), <varname>$host</varname> contains the name of the host to which it
18794 is connected.
18795 </para>
18796 <para>
18797 When used in the client part of an authenticator configuration (see chapter
18798 <xref linkend="CHAPSMTPAUTH"/>), <varname>$host</varname> contains the name of the server to which the
18799 client is connected.
18800 </para>
18801 </listitem></varlistentry>
18802 <varlistentry>
18803 <term><varname>$host_address</varname></term>
18804 <listitem>
18805 <para>
18806 <indexterm role="variable">
18807 <primary><varname>$host_address</varname></primary>
18808 </indexterm>
18809 This variable is set to the remote host&#x2019;s IP address whenever <varname>$host</varname> is set
18810 for a remote connection. It is also set to the IP address that is being checked
18811 when the <option>ignore_target_hosts</option> option is being processed.
18812 </para>
18813 </listitem></varlistentry>
18814 <varlistentry>
18815 <term><varname>$host_data</varname></term>
18816 <listitem>
18817 <para>
18818 <indexterm role="variable">
18819 <primary><varname>$host_data</varname></primary>
18820 </indexterm>
18821 If a <option>hosts</option> condition in an ACL is satisfied by means of a lookup, the
18822 result of the lookup is made available in the <varname>$host_data</varname> variable. This
18823 allows you, for example, to do things like this:
18824 </para>
18825 <literallayout class="monospaced">
18826 deny  hosts = net-lsearch;/some/file
18827 message = $host_data
18828 </literallayout>
18829 </listitem></varlistentry>
18830 <varlistentry>
18831 <term><varname>$host_lookup_deferred</varname></term>
18832 <listitem>
18833 <para>
18834 <indexterm role="concept">
18835 <primary>host name</primary>
18836 <secondary>lookup, failure of</secondary>
18837 </indexterm>
18838 <indexterm role="variable">
18839 <primary><varname>$host_lookup_deferred</varname></primary>
18840 </indexterm>
18841 This variable normally contains <quote>0</quote>, as does <varname>$host_lookup_failed</varname>. When a
18842 message comes from a remote host and there is an attempt to look up the host&#x2019;s
18843 name from its IP address, and the attempt is not successful, one of these
18844 variables is set to <quote>1</quote>.
18845 </para>
18846 <itemizedlist>
18847 <listitem>
18848 <para>
18849 If the lookup receives a definite negative response (for example, a DNS lookup
18850 succeeded, but no records were found), <varname>$host_lookup_failed</varname> is set to <quote>1</quote>.
18851 </para>
18852 </listitem>
18853 <listitem>
18854 <para>
18855 If there is any kind of problem during the lookup, such that Exim cannot
18856 tell whether or not the host name is defined (for example, a timeout for a DNS
18857 lookup), <varname>$host_lookup_deferred</varname> is set to <quote>1</quote>.
18858 </para>
18859 </listitem>
18860 </itemizedlist>
18861 <para>
18862 Looking up a host&#x2019;s name from its IP address consists of more than just a
18863 single reverse lookup. Exim checks that a forward lookup of at least one of the
18864 names it receives from a reverse lookup yields the original IP address. If this
18865 is not the case, Exim does not accept the looked up name(s), and
18866 <varname>$host_lookup_failed</varname> is set to <quote>1</quote>. Thus, being able to find a name from an
18867 IP address (for example, the existence of a PTR record in the DNS) is not
18868 sufficient on its own for the success of a host name lookup. If the reverse
18869 lookup succeeds, but there is a lookup problem such as a timeout when checking
18870 the result, the name is not accepted, and <varname>$host_lookup_deferred</varname> is set to
18871 <quote>1</quote>. See also <varname>$sender_host_name</varname>.
18872 </para>
18873 <para>
18874 <indexterm role="concept">
18875 <primary>authentication</primary>
18876 <secondary>expansion item</secondary>
18877 </indexterm>
18878 Performing these checks sets up information used by the
18879 <option>authresults</option> expansion item.
18880 </para>
18881 </listitem></varlistentry>
18882 <varlistentry>
18883 <term><varname>$host_lookup_failed</varname></term>
18884 <listitem>
18885 <para>
18886 <indexterm role="variable">
18887 <primary><varname>$host_lookup_failed</varname></primary>
18888 </indexterm>
18889 See <varname>$host_lookup_deferred</varname>.
18890 </para>
18891 </listitem></varlistentry>
18892 <varlistentry>
18893 <term><varname>$host_port</varname></term>
18894 <listitem>
18895 <para>
18896 <indexterm role="variable">
18897 <primary><varname>$host_port</varname></primary>
18898 </indexterm>
18899 This variable is set to the remote host&#x2019;s TCP port whenever <varname>$host</varname> is set
18900 for an outbound connection.
18901 </para>
18902 </listitem></varlistentry>
18903 <varlistentry>
18904 <term><varname>$initial_cwd</varname></term>
18905 <listitem>
18906 <para>
18907 <indexterm role="variable">
18908 <primary><varname>$initial_cwd</varname></primary>
18909 </indexterm>
18910 This variable contains the full path name of the initial working
18911 directory of the current Exim process. This may differ from the current
18912 working directory, as Exim changes this to "/" during early startup, and
18913 to <varname>$spool_directory</varname> later.
18914 </para>
18915 </listitem></varlistentry>
18916 <varlistentry>
18917 <term><varname>$inode</varname></term>
18918 <listitem>
18919 <para>
18920 <indexterm role="variable">
18921 <primary><varname>$inode</varname></primary>
18922 </indexterm>
18923 The only time this variable is set is while expanding the <option>directory_file</option>
18924 option in the <command>appendfile</command> transport. The variable contains the inode number
18925 of the temporary file which is about to be renamed. It can be used to construct
18926 a unique name for the file.
18927 </para>
18928 </listitem></varlistentry>
18929 <varlistentry>
18930 <term><varname>$interface_address</varname></term>
18931 <listitem>
18932 <para>
18933 <indexterm role="variable">
18934 <primary><varname>$interface_address</varname></primary>
18935 </indexterm>
18936 This is an obsolete name for <varname>$received_ip_address</varname>.
18937 </para>
18938 </listitem></varlistentry>
18939 <varlistentry>
18940 <term><varname>$interface_port</varname></term>
18941 <listitem>
18942 <para>
18943 <indexterm role="variable">
18944 <primary><varname>$interface_port</varname></primary>
18945 </indexterm>
18946 This is an obsolete name for <varname>$received_port</varname>.
18947 </para>
18948 </listitem></varlistentry>
18949 <varlistentry>
18950 <term><varname>$item</varname></term>
18951 <listitem>
18952 <para>
18953 <indexterm role="variable">
18954 <primary><varname>$item</varname></primary>
18955 </indexterm>
18956 This variable is used during the expansion of <emphasis role="bold">forall</emphasis> and <emphasis role="bold">forany</emphasis>
18957 conditions (see section <xref linkend="SECTexpcond"/>), and <emphasis role="bold">filter</emphasis>, <emphasis role="bold">map</emphasis>, and
18958 <emphasis role="bold">reduce</emphasis> items (see section <xref linkend="SECTexpcond"/>). In other circumstances, it is
18959 empty.
18960 </para>
18961 </listitem></varlistentry>
18962 <varlistentry>
18963 <term><varname>$ldap_dn</varname></term>
18964 <listitem>
18965 <para>
18966 <indexterm role="variable">
18967 <primary><varname>$ldap_dn</varname></primary>
18968 </indexterm>
18969 This variable, which is available only when Exim is compiled with LDAP support,
18970 contains the DN from the last entry in the most recently successful LDAP
18971 lookup.
18972 </para>
18973 </listitem></varlistentry>
18974 <varlistentry>
18975 <term><varname>$load_average</varname></term>
18976 <listitem>
18977 <para>
18978 <indexterm role="variable">
18979 <primary><varname>$load_average</varname></primary>
18980 </indexterm>
18981 This variable contains the system load average, multiplied by 1000 so that it
18982 is an integer. For example, if the load average is 0.21, the value of the
18983 variable is 210. The value is recomputed every time the variable is referenced.
18984 </para>
18985 </listitem></varlistentry>
18986 <varlistentry>
18987 <term><varname>$local_part</varname></term>
18988 <listitem>
18989 <para>
18990 <indexterm role="variable">
18991 <primary><varname>$local_part</varname></primary>
18992 </indexterm>
18993 When an address is being routed, or delivered on its own, this
18994 variable contains the local part. When a number of addresses are being
18995 delivered together (for example, multiple RCPT commands in an SMTP
18996 session), <varname>$local_part</varname> is not set.
18997 </para>
18998 <para>
18999 Global address rewriting happens when a message is received, so the value of
19000 <varname>$local_part</varname> during routing and delivery is the value after rewriting.
19001 <varname>$local_part</varname> is set during user filtering, but not during system filtering,
19002 because a message may have many recipients and the system filter is called just
19003 once.
19004 </para>
19005 <para>
19006 <indexterm role="variable">
19007 <primary><varname>$local_part_prefix</varname></primary>
19008 </indexterm>
19009 <indexterm role="variable">
19010 <primary><varname>$local_part_suffix</varname></primary>
19011 </indexterm>
19012 <indexterm role="concept">
19013 <primary>affix</primary>
19014 <secondary>variables</secondary>
19015 </indexterm>
19016 If a local part prefix or suffix has been recognized, it is not included in the
19017 value of <varname>$local_part</varname> during routing and subsequent delivery. The values of
19018 any prefix or suffix are in <varname>$local_part_prefix</varname> and
19019 <varname>$local_part_suffix</varname>, respectively.
19020 </para>
19021 <para>
19022 When a message is being delivered to a file, pipe, or autoreply transport as a
19023 result of aliasing or forwarding, <varname>$local_part</varname> is set to the local part of
19024 the parent address, not to the filename or command (see <varname>$address_file</varname> and
19025 <varname>$address_pipe</varname>).
19026 </para>
19027 <para>
19028 When an ACL is running for a RCPT command, <varname>$local_part</varname> contains the
19029 local part of the recipient address.
19030 </para>
19031 <para>
19032 When a rewrite item is being processed (see chapter <xref linkend="CHAPrewrite"/>),
19033 <varname>$local_part</varname> contains the local part of the address that is being rewritten;
19034 it can be used in the expansion of the replacement address, for example.
19035 </para>
19036 <para>
19037 In all cases, all quoting is removed from the local part. For example, for both
19038 the addresses
19039 </para>
19040 <literallayout class="monospaced">
19041 "abc:xyz"@test.example
19042 abc\:xyz@test.example
19043 </literallayout>
19044 <para>
19045 the value of <varname>$local_part</varname> is
19046 </para>
19047 <literallayout class="monospaced">
19048 abc:xyz
19049 </literallayout>
19050 <para>
19051 If you use <varname>$local_part</varname> to create another address, you should always wrap it
19052 inside a quoting operator. For example, in a <command>redirect</command> router you could
19053 have:
19054 </para>
19055 <literallayout class="monospaced">
19056 data = ${quote_local_part:$local_part}@new.domain.example
19057 </literallayout>
19058 <para>
19059 <emphasis role="bold">Note</emphasis>: The value of <varname>$local_part</varname> is normally lower cased. If you want
19060 to process local parts in a case-dependent manner in a router, you can set the
19061 <option>caseful_local_part</option> option (see chapter <xref linkend="CHAProutergeneric"/>).
19062 </para>
19063 </listitem></varlistentry>
19064 <varlistentry>
19065 <term><varname>$local_part_data</varname></term>
19066 <listitem>
19067 <para>
19068 <indexterm role="variable">
19069 <primary><varname>$local_part_data</varname></primary>
19070 </indexterm>
19071 When the <option>local_parts</option> option on a router matches a local part by means of a
19072 lookup, the data read by the lookup is available during the running of the
19073 router as <varname>$local_part_data</varname>. In addition, if the driver routes the address
19074 to a transport, the value is available in that transport. If the transport is
19075 handling multiple addresses, the value from the first address is used.
19076 </para>
19077 <para>
19078 <varname>$local_part_data</varname> is also set when the <option>local_parts</option> condition in an ACL
19079 matches a local part by means of a lookup. The data read by the lookup is
19080 available during the rest of the ACL statement. In all other situations, this
19081 variable expands to nothing.
19082 </para>
19083 </listitem></varlistentry>
19084 <varlistentry>
19085 <term><varname>$local_part_prefix</varname></term>
19086 <listitem>
19087 <para>
19088 <indexterm role="variable">
19089 <primary><varname>$local_part_prefix</varname></primary>
19090 </indexterm>
19091 <indexterm role="concept">
19092 <primary>affix</primary>
19093 <secondary>variables</secondary>
19094 </indexterm>
19095 When an address is being routed or delivered, and a
19096 specific prefix for the local part was recognized, it is available in this
19097 variable, having been removed from <varname>$local_part</varname>.
19098 </para>
19099 </listitem></varlistentry>
19100 <varlistentry>
19101 <term><varname>$local_part_suffix</varname></term>
19102 <listitem>
19103 <para>
19104 <indexterm role="variable">
19105 <primary><varname>$local_part_suffix</varname></primary>
19106 </indexterm>
19107 When an address is being routed or delivered, and a
19108 specific suffix for the local part was recognized, it is available in this
19109 variable, having been removed from <varname>$local_part</varname>.
19110 </para>
19111 </listitem></varlistentry>
19112 <varlistentry>
19113 <term><varname>$local_scan_data</varname></term>
19114 <listitem>
19115 <para>
19116 <indexterm role="variable">
19117 <primary><varname>$local_scan_data</varname></primary>
19118 </indexterm>
19119 This variable contains the text returned by the <function>local_scan()</function> function when
19120 a message is received. See chapter <xref linkend="CHAPlocalscan"/> for more details.
19121 </para>
19122 </listitem></varlistentry>
19123 <varlistentry>
19124 <term><varname>$local_user_gid</varname></term>
19125 <listitem>
19126 <para>
19127 <indexterm role="variable">
19128 <primary><varname>$local_user_gid</varname></primary>
19129 </indexterm>
19130 See <varname>$local_user_uid</varname>.
19131 </para>
19132 </listitem></varlistentry>
19133 <varlistentry>
19134 <term><varname>$local_user_uid</varname></term>
19135 <listitem>
19136 <para>
19137 <indexterm role="variable">
19138 <primary><varname>$local_user_uid</varname></primary>
19139 </indexterm>
19140 This variable and <varname>$local_user_gid</varname> are set to the uid and gid after the
19141 <option>check_local_user</option> router precondition succeeds. This means that their values
19142 are available for the remaining preconditions (<option>senders</option>, <option>require_files</option>,
19143 and <option>condition</option>), for the <option>address_data</option> expansion, and for any
19144 router-specific expansions. At all other times, the values in these variables
19145 are <literal>(uid_t)(-1)</literal> and <literal>(gid_t)(-1)</literal>, respectively.
19146 </para>
19147 </listitem></varlistentry>
19148 <varlistentry>
19149 <term><varname>$localhost_number</varname></term>
19150 <listitem>
19151 <para>
19152 <indexterm role="variable">
19153 <primary><varname>$localhost_number</varname></primary>
19154 </indexterm>
19155 This contains the expanded value of the
19156 <option>localhost_number</option> option. The expansion happens after the main options have
19157 been read.
19158 </para>
19159 </listitem></varlistentry>
19160 <varlistentry>
19161 <term><varname>$log_inodes</varname></term>
19162 <listitem>
19163 <para>
19164 <indexterm role="variable">
19165 <primary><varname>$log_inodes</varname></primary>
19166 </indexterm>
19167 The number of free inodes in the disk partition where Exim&#x2019;s
19168 log files are being written. The value is recalculated whenever the variable is
19169 referenced. If the relevant file system does not have the concept of inodes,
19170 the value of is -1. See also the <option>check_log_inodes</option> option.
19171 </para>
19172 </listitem></varlistentry>
19173 <varlistentry>
19174 <term><varname>$log_space</varname></term>
19175 <listitem>
19176 <para>
19177 <indexterm role="variable">
19178 <primary><varname>$log_space</varname></primary>
19179 </indexterm>
19180 The amount of free space (as a number of kilobytes) in the disk
19181 partition where Exim&#x2019;s log files are being written. The value is recalculated
19182 whenever the variable is referenced. If the operating system does not have the
19183 ability to find the amount of free space (only true for experimental systems),
19184 the space value is -1. See also the <option>check_log_space</option> option.
19185 </para>
19186 </listitem></varlistentry>
19187 <varlistentry>
19188 <term><varname>$lookup_dnssec_authenticated</varname></term>
19189 <listitem>
19190 <para>
19191 <indexterm role="variable">
19192 <primary><varname>$lookup_dnssec_authenticated</varname></primary>
19193 </indexterm>
19194 This variable is set after a DNS lookup done by
19195 a dnsdb lookup expansion, dnslookup router or smtp transport.
19196 <indexterm role="concept">
19197 <primary>DNS</primary>
19198 <secondary>DNSSEC</secondary>
19199 </indexterm>
19200 It will be empty if <command>DNSSEC</command> was not requested,
19201 <quote>no</quote> if the result was not labelled as authenticated data
19202 and <quote>yes</quote> if it was.
19203 Results that are labelled as authoritative answer that match
19204 the <option>dns_trust_aa</option> configuration variable count also
19205 as authenticated data.
19206 </para>
19207 </listitem></varlistentry>
19208 <varlistentry>
19209 <term><varname>$mailstore_basename</varname></term>
19210 <listitem>
19211 <para>
19212 <indexterm role="variable">
19213 <primary><varname>$mailstore_basename</varname></primary>
19214 </indexterm>
19215 This variable is set only when doing deliveries in <quote>mailstore</quote> format in the
19216 <command>appendfile</command> transport. During the expansion of the <option>mailstore_prefix</option>,
19217 <option>mailstore_suffix</option>, <option>message_prefix</option>, and <option>message_suffix</option> options, it
19218 contains the basename of the files that are being written, that is, the name
19219 without the <quote>.tmp</quote>, <quote>.env</quote>, or <quote>.msg</quote> suffix. At all other times, this
19220 variable is empty.
19221 </para>
19222 </listitem></varlistentry>
19223 <varlistentry>
19224 <term><varname>$malware_name</varname></term>
19225 <listitem>
19226 <para>
19227 <indexterm role="variable">
19228 <primary><varname>$malware_name</varname></primary>
19229 </indexterm>
19230 This variable is available when Exim is compiled with the
19231 content-scanning extension. It is set to the name of the virus that was found
19232 when the ACL <option>malware</option> condition is true (see section <xref linkend="SECTscanvirus"/>).
19233 </para>
19234 </listitem></varlistentry>
19235 <varlistentry>
19236 <term><varname>$max_received_linelength</varname></term>
19237 <listitem>
19238 <para>
19239 <indexterm role="variable">
19240 <primary><varname>$max_received_linelength</varname></primary>
19241 </indexterm>
19242 <indexterm role="concept">
19243 <primary>maximum</primary>
19244 <secondary>line length</secondary>
19245 </indexterm>
19246 <indexterm role="concept">
19247 <primary>line length</primary>
19248 <secondary>maximum</secondary>
19249 </indexterm>
19250 This variable contains the number of bytes in the longest line that was
19251 received as part of the message, not counting the line termination
19252 character(s).
19253 It is not valid if the <option>spool_files_wireformat</option> option is used.
19254 </para>
19255 </listitem></varlistentry>
19256 <varlistentry>
19257 <term><varname>$message_age</varname></term>
19258 <listitem>
19259 <para>
19260 <indexterm role="concept">
19261 <primary>message</primary>
19262 <secondary>age of</secondary>
19263 </indexterm>
19264 <indexterm role="variable">
19265 <primary><varname>$message_age</varname></primary>
19266 </indexterm>
19267 This variable is set at the start of a delivery attempt to contain the number
19268 of seconds since the message was received. It does not change during a single
19269 delivery attempt.
19270 </para>
19271 </listitem></varlistentry>
19272 <varlistentry>
19273 <term><varname>$message_body</varname></term>
19274 <listitem>
19275 <para>
19276 <indexterm role="concept">
19277 <primary>body of message</primary>
19278 <secondary>expansion variable</secondary>
19279 </indexterm>
19280 <indexterm role="concept">
19281 <primary>message body</primary>
19282 <secondary>in expansion</secondary>
19283 </indexterm>
19284 <indexterm role="concept">
19285 <primary>binary zero</primary>
19286 <secondary>in message body</secondary>
19287 </indexterm>
19288 <indexterm role="variable">
19289 <primary><varname>$message_body</varname></primary>
19290 </indexterm>
19291 <indexterm role="option">
19292 <primary><option>message_body_visible</option></primary>
19293 </indexterm>
19294 This variable contains the initial portion of a message&#x2019;s body while it is
19295 being delivered, and is intended mainly for use in filter files. The maximum
19296 number of characters of the body that are put into the variable is set by the
19297 <option>message_body_visible</option> configuration option; the default is 500.
19298 </para>
19299 <para>
19300 <indexterm role="option">
19301 <primary><option>message_body_newlines</option></primary>
19302 </indexterm>
19303 By default, newlines are converted into spaces in <varname>$message_body</varname>, to make it
19304 easier to search for phrases that might be split over a line break. However,
19305 this can be disabled by setting <option>message_body_newlines</option> to be true. Binary
19306 zeros are always converted into spaces.
19307 </para>
19308 </listitem></varlistentry>
19309 <varlistentry>
19310 <term><varname>$message_body_end</varname></term>
19311 <listitem>
19312 <para>
19313 <indexterm role="concept">
19314 <primary>body of message</primary>
19315 <secondary>expansion variable</secondary>
19316 </indexterm>
19317 <indexterm role="concept">
19318 <primary>message body</primary>
19319 <secondary>in expansion</secondary>
19320 </indexterm>
19321 <indexterm role="variable">
19322 <primary><varname>$message_body_end</varname></primary>
19323 </indexterm>
19324 This variable contains the final portion of a message&#x2019;s
19325 body while it is being delivered. The format and maximum size are as for
19326 <varname>$message_body</varname>.
19327 </para>
19328 </listitem></varlistentry>
19329 <varlistentry>
19330 <term><varname>$message_body_size</varname></term>
19331 <listitem>
19332 <para>
19333 <indexterm role="concept">
19334 <primary>body of message</primary>
19335 <secondary>size</secondary>
19336 </indexterm>
19337 <indexterm role="concept">
19338 <primary>message body</primary>
19339 <secondary>size</secondary>
19340 </indexterm>
19341 <indexterm role="variable">
19342 <primary><varname>$message_body_size</varname></primary>
19343 </indexterm>
19344 When a message is being delivered, this variable contains the size of the body
19345 in bytes. The count starts from the character after the blank line that
19346 separates the body from the header. Newlines are included in the count. See
19347 also <varname>$message_size</varname>, <varname>$body_linecount</varname>, and <varname>$body_zerocount</varname>.
19348 </para>
19349 <para>
19350 If the spool file is wireformat
19351 (see the <option>spool_files_wireformat</option> main option)
19352 the CRLF line-terminators are included in the count.
19353 </para>
19354 </listitem></varlistentry>
19355 <varlistentry>
19356 <term><varname>$message_exim_id</varname></term>
19357 <listitem>
19358 <para>
19359 <indexterm role="variable">
19360 <primary><varname>$message_exim_id</varname></primary>
19361 </indexterm>
19362 When a message is being received or delivered, this variable contains the
19363 unique message id that is generated and used by Exim to identify the message.
19364 An id is not created for a message until after its header has been successfully
19365 received. <emphasis role="bold">Note</emphasis>: This is <emphasis>not</emphasis> the contents of the <emphasis>Message-ID:</emphasis> header
19366 line; it is the local id that Exim assigns to the message, for example:
19367 <literal>1BXTIK-0001yO-VA</literal>.
19368 </para>
19369 </listitem></varlistentry>
19370 <varlistentry>
19371 <term><varname>$message_headers</varname></term>
19372 <listitem>
19373 <para>
19374 <indexterm role="variable">
19375 <primary><varname>$message_headers</varname></primary>
19376 </indexterm>
19377 This variable contains a concatenation of all the header lines when a message
19378 is being processed, except for lines added by routers or transports. The header
19379 lines are separated by newline characters. Their contents are decoded in the
19380 same way as a header line that is inserted by <option>bheader</option>.
19381 </para>
19382 </listitem></varlistentry>
19383 <varlistentry>
19384 <term><varname>$message_headers_raw</varname></term>
19385 <listitem>
19386 <para>
19387 <indexterm role="variable">
19388 <primary><varname>$message_headers_raw</varname></primary>
19389 </indexterm>
19390 This variable is like <varname>$message_headers</varname> except that no processing of the
19391 contents of header lines is done.
19392 </para>
19393 </listitem></varlistentry>
19394 <varlistentry>
19395 <term><varname>$message_id</varname></term>
19396 <listitem>
19397 <para>
19398 This is an old name for <varname>$message_exim_id</varname>. It is now deprecated.
19399 </para>
19400 </listitem></varlistentry>
19401 <varlistentry>
19402 <term><varname>$message_linecount</varname></term>
19403 <listitem>
19404 <para>
19405 <indexterm role="variable">
19406 <primary><varname>$message_linecount</varname></primary>
19407 </indexterm>
19408 This variable contains the total number of lines in the header and body of the
19409 message. Compare <varname>$body_linecount</varname>, which is the count for the body only.
19410 During the DATA and content-scanning ACLs, <varname>$message_linecount</varname> contains the
19411 number of lines received. Before delivery happens (that is, before filters,
19412 routers, and transports run) the count is increased to include the
19413 <emphasis>Received:</emphasis> header line that Exim standardly adds, and also any other header
19414 lines that are added by ACLs. The blank line that separates the message header
19415 from the body is not counted.
19416 </para>
19417 <para>
19418 As with the special case of <varname>$message_size</varname>, during the expansion of the
19419 appendfile transport&#x2019;s maildir_tag option in maildir format, the value of
19420 <varname>$message_linecount</varname> is the precise size of the number of newlines in the
19421 file that has been written (minus one for the blank line between the
19422 header and the body).
19423 </para>
19424 <para>
19425 Here is an example of the use of this variable in a DATA ACL:
19426 </para>
19427 <literallayout class="monospaced">
19428 deny message   = Too many lines in message header
19429      condition = \
19430       ${if &lt;{250}{${eval:$message_linecount - $body_linecount}}}
19431 </literallayout>
19432 <para>
19433 In the MAIL and RCPT ACLs, the value is zero because at that stage the
19434 message has not yet been received.
19435 </para>
19436 <para>
19437 This variable is not valid if the <option>spool_files_wireformat</option> option is used.
19438 </para>
19439 </listitem></varlistentry>
19440 <varlistentry>
19441 <term><varname>$message_size</varname></term>
19442 <listitem>
19443 <para>
19444 <indexterm role="concept">
19445 <primary>size</primary>
19446 <secondary>of message</secondary>
19447 </indexterm>
19448 <indexterm role="concept">
19449 <primary>message</primary>
19450 <secondary>size</secondary>
19451 </indexterm>
19452 <indexterm role="variable">
19453 <primary><varname>$message_size</varname></primary>
19454 </indexterm>
19455 When a message is being processed, this variable contains its size in bytes. In
19456 most cases, the size includes those headers that were received with the
19457 message, but not those (such as <emphasis>Envelope-to:</emphasis>) that are added to individual
19458 deliveries as they are written. However, there is one special case: during the
19459 expansion of the <option>maildir_tag</option> option in the <command>appendfile</command> transport while
19460 doing a delivery in maildir format, the value of <varname>$message_size</varname> is the
19461 precise size of the file that has been written. See also
19462 <varname>$message_body_size</varname>, <varname>$body_linecount</varname>, and <varname>$body_zerocount</varname>.
19463 </para>
19464 <para>
19465 <indexterm role="concept">
19466 <primary>RCPT</primary>
19467 <secondary>value of <varname>$message_size</varname></secondary>
19468 </indexterm>
19469 While running a per message ACL (mail/rcpt/predata), <varname>$message_size</varname>
19470 contains the size supplied on the MAIL command, or -1 if no size was given. The
19471 value may not, of course, be truthful.
19472 </para>
19473 </listitem></varlistentry>
19474 <varlistentry>
19475 <term><varname>$mime_</varname><emphasis>xxx</emphasis></term>
19476 <listitem>
19477 <para>
19478 A number of variables whose names start with <varname>$mime</varname> are
19479 available when Exim is compiled with the content-scanning extension. For
19480 details, see section <xref linkend="SECTscanmimepart"/>.
19481 </para>
19482 </listitem></varlistentry>
19483 <varlistentry>
19484 <term><varname>$n0</varname> &ndash; <varname>$n9</varname></term>
19485 <listitem>
19486 <para>
19487 These variables are counters that can be incremented by means
19488 of the <option>add</option> command in filter files.
19489 </para>
19490 </listitem></varlistentry>
19491 <varlistentry>
19492 <term><varname>$original_domain</varname></term>
19493 <listitem>
19494 <para>
19495 <indexterm role="variable">
19496 <primary><varname>$domain</varname></primary>
19497 </indexterm>
19498 <indexterm role="variable">
19499 <primary><varname>$original_domain</varname></primary>
19500 </indexterm>
19501 When a top-level address is being processed for delivery, this contains the
19502 same value as <varname>$domain</varname>. However, if a <quote>child</quote> address (for example,
19503 generated by an alias, forward, or filter file) is being processed, this
19504 variable contains the domain of the original address (lower cased). This
19505 differs from <varname>$parent_domain</varname> only when there is more than one level of
19506 aliasing or forwarding. When more than one address is being delivered in a
19507 single transport run, <varname>$original_domain</varname> is not set.
19508 </para>
19509 <para>
19510 If a new address is created by means of a <option>deliver</option> command in a system
19511 filter, it is set up with an artificial <quote>parent</quote> address. This has the local
19512 part <emphasis>system-filter</emphasis> and the default qualify domain.
19513 </para>
19514 </listitem></varlistentry>
19515 <varlistentry>
19516 <term><varname>$original_local_part</varname></term>
19517 <listitem>
19518 <para>
19519 <indexterm role="variable">
19520 <primary><varname>$local_part</varname></primary>
19521 </indexterm>
19522 <indexterm role="variable">
19523 <primary><varname>$original_local_part</varname></primary>
19524 </indexterm>
19525 When a top-level address is being processed for delivery, this contains the
19526 same value as <varname>$local_part</varname>, unless a prefix or suffix was removed from the
19527 local part, because <varname>$original_local_part</varname> always contains the full local
19528 part. When a <quote>child</quote> address (for example, generated by an alias, forward, or
19529 filter file) is being processed, this variable contains the full local part of
19530 the original address.
19531 </para>
19532 <para>
19533 If the router that did the redirection processed the local part
19534 case-insensitively, the value in <varname>$original_local_part</varname> is in lower case.
19535 This variable differs from <varname>$parent_local_part</varname> only when there is more than
19536 one level of aliasing or forwarding. When more than one address is being
19537 delivered in a single transport run, <varname>$original_local_part</varname> is not set.
19538 </para>
19539 <para>
19540 If a new address is created by means of a <option>deliver</option> command in a system
19541 filter, it is set up with an artificial <quote>parent</quote> address. This has the local
19542 part <emphasis>system-filter</emphasis> and the default qualify domain.
19543 </para>
19544 </listitem></varlistentry>
19545 <varlistentry>
19546 <term><varname>$originator_gid</varname></term>
19547 <listitem>
19548 <para>
19549 <indexterm role="concept">
19550 <primary>gid (group id)</primary>
19551 <secondary>of originating user</secondary>
19552 </indexterm>
19553 <indexterm role="concept">
19554 <primary>sender</primary>
19555 <secondary>gid</secondary>
19556 </indexterm>
19557 <indexterm role="variable">
19558 <primary><varname>$caller_gid</varname></primary>
19559 </indexterm>
19560 <indexterm role="variable">
19561 <primary><varname>$originator_gid</varname></primary>
19562 </indexterm>
19563 This variable contains the value of <varname>$caller_gid</varname> that was set when the
19564 message was received. For messages received via the command line, this is the
19565 gid of the sending user. For messages received by SMTP over TCP/IP, this is
19566 normally the gid of the Exim user.
19567 </para>
19568 </listitem></varlistentry>
19569 <varlistentry>
19570 <term><varname>$originator_uid</varname></term>
19571 <listitem>
19572 <para>
19573 <indexterm role="concept">
19574 <primary>uid (user id)</primary>
19575 <secondary>of originating user</secondary>
19576 </indexterm>
19577 <indexterm role="concept">
19578 <primary>sender</primary>
19579 <secondary>uid</secondary>
19580 </indexterm>
19581 <indexterm role="variable">
19582 <primary><varname>$caller_uid</varname></primary>
19583 </indexterm>
19584 <indexterm role="variable">
19585 <primary><varname>$originator_uid</varname></primary>
19586 </indexterm>
19587 The value of <varname>$caller_uid</varname> that was set when the message was received. For
19588 messages received via the command line, this is the uid of the sending user.
19589 For messages received by SMTP over TCP/IP, this is normally the uid of the Exim
19590 user.
19591 </para>
19592 </listitem></varlistentry>
19593 <varlistentry>
19594 <term><varname>$parent_domain</varname></term>
19595 <listitem>
19596 <para>
19597 <indexterm role="variable">
19598 <primary><varname>$parent_domain</varname></primary>
19599 </indexterm>
19600 This variable is similar to <varname>$original_domain</varname> (see
19601 above), except that it refers to the immediately preceding parent address.
19602 </para>
19603 </listitem></varlistentry>
19604 <varlistentry>
19605 <term><varname>$parent_local_part</varname></term>
19606 <listitem>
19607 <para>
19608 <indexterm role="variable">
19609 <primary><varname>$parent_local_part</varname></primary>
19610 </indexterm>
19611 This variable is similar to <varname>$original_local_part</varname>
19612 (see above), except that it refers to the immediately preceding parent address.
19613 </para>
19614 </listitem></varlistentry>
19615 <varlistentry>
19616 <term><varname>$pid</varname></term>
19617 <listitem>
19618 <para>
19619 <indexterm role="concept">
19620 <primary>pid (process id)</primary>
19621 <secondary>of current process</secondary>
19622 </indexterm>
19623 <indexterm role="variable">
19624 <primary><varname>$pid</varname></primary>
19625 </indexterm>
19626 This variable contains the current process id.
19627 </para>
19628 </listitem></varlistentry>
19629 <varlistentry>
19630 <term><varname>$pipe_addresses</varname></term>
19631 <listitem>
19632 <para>
19633 <indexterm role="concept">
19634 <primary>filter</primary>
19635 <secondary>transport filter</secondary>
19636 </indexterm>
19637 <indexterm role="concept">
19638 <primary>transport</primary>
19639 <secondary>filter</secondary>
19640 </indexterm>
19641 <indexterm role="variable">
19642 <primary><varname>$pipe_addresses</varname></primary>
19643 </indexterm>
19644 This is not an expansion variable, but is mentioned here because the string
19645 <literal>$pipe_addresses</literal> is handled specially in the command specification for the
19646 <command>pipe</command> transport (chapter <xref linkend="CHAPpipetransport"/>) and in transport filters
19647 (described under <option>transport_filter</option> in chapter <xref linkend="CHAPtransportgeneric"/>).
19648 It cannot be used in general expansion strings, and provokes an <quote>unknown
19649 variable</quote> error if encountered.
19650 </para>
19651 </listitem></varlistentry>
19652 <varlistentry>
19653 <term><varname>$primary_hostname</varname></term>
19654 <listitem>
19655 <para>
19656 <indexterm role="variable">
19657 <primary><varname>$primary_hostname</varname></primary>
19658 </indexterm>
19659 This variable contains the value set by <option>primary_hostname</option> in the
19660 configuration file, or read by the <function>uname()</function> function. If <function>uname()</function> returns
19661 a single-component name, Exim calls <function>gethostbyname()</function> (or
19662 <function>getipnodebyname()</function> where available) in an attempt to acquire a fully
19663 qualified host name. See also <varname>$smtp_active_hostname</varname>.
19664 </para>
19665 </listitem></varlistentry>
19666 <varlistentry>
19667 <term><varname>$proxy_external_address</varname></term>
19668 <term><varname>$proxy_external_port</varname></term>
19669 <term><varname>$proxy_local_address</varname></term>
19670 <term><varname>$proxy_local_port</varname></term>
19671 <term><varname>$proxy_session</varname></term>
19672 <listitem>
19673 <para>
19674 These variables are only available when built with Proxy Protocol
19675 or SOCKS5 support.
19676 For details see chapter <xref linkend="SECTproxyInbound"/>.
19677 </para>
19678 </listitem></varlistentry>
19679 <varlistentry>
19680 <term><varname>$prdr_requested</varname></term>
19681 <listitem>
19682 <para>
19683 <indexterm role="concept">
19684 <primary>PRDR</primary>
19685 <secondary>variable for</secondary>
19686 </indexterm>
19687 This variable is set to <quote>yes</quote> if PRDR was requested by the client for the
19688 current message, otherwise <quote>no</quote>.
19689 </para>
19690 </listitem></varlistentry>
19691 <varlistentry>
19692 <term><varname>$prvscheck_address</varname></term>
19693 <listitem>
19694 <para>
19695 This variable is used in conjunction with the <option>prvscheck</option> expansion item,
19696 which is described in sections <xref linkend="SECTexpansionitems"/> and
19697 <xref linkend="SECTverifyPRVS"/>.
19698 </para>
19699 </listitem></varlistentry>
19700 <varlistentry>
19701 <term><varname>$prvscheck_keynum</varname></term>
19702 <listitem>
19703 <para>
19704 This variable is used in conjunction with the <option>prvscheck</option> expansion item,
19705 which is described in sections <xref linkend="SECTexpansionitems"/> and
19706 <xref linkend="SECTverifyPRVS"/>.
19707 </para>
19708 </listitem></varlistentry>
19709 <varlistentry>
19710 <term><varname>$prvscheck_result</varname></term>
19711 <listitem>
19712 <para>
19713 This variable is used in conjunction with the <option>prvscheck</option> expansion item,
19714 which is described in sections <xref linkend="SECTexpansionitems"/> and
19715 <xref linkend="SECTverifyPRVS"/>.
19716 </para>
19717 </listitem></varlistentry>
19718 <varlistentry>
19719 <term><varname>$qualify_domain</varname></term>
19720 <listitem>
19721 <para>
19722 <indexterm role="variable">
19723 <primary><varname>$qualify_domain</varname></primary>
19724 </indexterm>
19725 The value set for the <option>qualify_domain</option> option in the configuration file.
19726 </para>
19727 </listitem></varlistentry>
19728 <varlistentry>
19729 <term><varname>$qualify_recipient</varname></term>
19730 <listitem>
19731 <para>
19732 <indexterm role="variable">
19733 <primary><varname>$qualify_recipient</varname></primary>
19734 </indexterm>
19735 The value set for the <option>qualify_recipient</option> option in the configuration file,
19736 or if not set, the value of <varname>$qualify_domain</varname>.
19737 </para>
19738 </listitem></varlistentry>
19739 <varlistentry>
19740 <term><varname>$queue_name</varname></term>
19741 <listitem>
19742 <para>
19743 <indexterm role="variable">
19744 <primary><varname>$queue_name</varname></primary>
19745 </indexterm>
19746 <indexterm role="concept">
19747 <primary>named queues</primary>
19748 </indexterm>
19749 <indexterm role="concept">
19750 <primary>queues</primary>
19751 <secondary>named</secondary>
19752 </indexterm>
19753 The name of the spool queue in use; empty for the default queue.
19754 </para>
19755 </listitem></varlistentry>
19756 <varlistentry revisionflag="changed">
19757 <term><varname>$r_...</varname></term>
19758 <listitem>
19759 <para revisionflag="changed">
19760 <indexterm role="variable">
19761 <primary><varname>$r_...</varname></primary>
19762 </indexterm>
19763 <indexterm role="concept">
19764 <primary>router</primary>
19765 <secondary>variables</secondary>
19766 </indexterm>
19767 Values can be placed in these variables by the <option>set</option> option of a router.
19768 They can be given any name that starts with <varname>$r_</varname>.
19769 The values persist for the address being handled through subsequent routers
19770 and the eventual transport.
19771 </para>
19772 </listitem></varlistentry>
19773 <varlistentry>
19774 <term><varname>$rcpt_count</varname></term>
19775 <listitem>
19776 <para>
19777 <indexterm role="variable">
19778 <primary><varname>$rcpt_count</varname></primary>
19779 </indexterm>
19780 When a message is being received by SMTP, this variable contains the number of
19781 RCPT commands received for the current message. If this variable is used in a
19782 RCPT ACL, its value includes the current command.
19783 </para>
19784 </listitem></varlistentry>
19785 <varlistentry>
19786 <term><varname>$rcpt_defer_count</varname></term>
19787 <listitem>
19788 <para>
19789 <indexterm role="variable">
19790 <primary><varname>$rcpt_defer_count</varname></primary>
19791 </indexterm>
19792 <indexterm role="concept">
19793 <primary>4<emphasis>xx</emphasis> responses</primary>
19794 <secondary>count of</secondary>
19795 </indexterm>
19796 When a message is being received by SMTP, this variable contains the number of
19797 RCPT commands in the current message that have previously been rejected with a
19798 temporary (4<emphasis>xx</emphasis>) response.
19799 </para>
19800 </listitem></varlistentry>
19801 <varlistentry>
19802 <term><varname>$rcpt_fail_count</varname></term>
19803 <listitem>
19804 <para>
19805 <indexterm role="variable">
19806 <primary><varname>$rcpt_fail_count</varname></primary>
19807 </indexterm>
19808 When a message is being received by SMTP, this variable contains the number of
19809 RCPT commands in the current message that have previously been rejected with a
19810 permanent (5<emphasis>xx</emphasis>) response.
19811 </para>
19812 </listitem></varlistentry>
19813 <varlistentry>
19814 <term><varname>$received_count</varname></term>
19815 <listitem>
19816 <para>
19817 <indexterm role="variable">
19818 <primary><varname>$received_count</varname></primary>
19819 </indexterm>
19820 This variable contains the number of <emphasis>Received:</emphasis> header lines in the message,
19821 including the one added by Exim (so its value is always greater than zero). It
19822 is available in the DATA ACL, the non-SMTP ACL, and while routing and
19823 delivering.
19824 </para>
19825 </listitem></varlistentry>
19826 <varlistentry>
19827 <term><varname>$received_for</varname></term>
19828 <listitem>
19829 <para>
19830 <indexterm role="variable">
19831 <primary><varname>$received_for</varname></primary>
19832 </indexterm>
19833 If there is only a single recipient address in an incoming message, this
19834 variable contains that address when the <emphasis>Received:</emphasis> header line is being
19835 built. The value is copied after recipient rewriting has happened, but before
19836 the <function>local_scan()</function> function is run.
19837 </para>
19838 </listitem></varlistentry>
19839 <varlistentry>
19840 <term><varname>$received_ip_address</varname></term>
19841 <listitem>
19842 <para>
19843 <indexterm role="variable">
19844 <primary><varname>$received_ip_address</varname></primary>
19845 </indexterm>
19846 As soon as an Exim server starts processing an incoming TCP/IP connection, this
19847 variable is set to the address of the local IP interface, and <varname>$received_port</varname>
19848 is set to the local port number. (The remote IP address and port are in
19849 <varname>$sender_host_address</varname> and <varname>$sender_host_port</varname>.) When testing with <option>-bh</option>,
19850 the port value is -1 unless it has been set using the <option>-oMi</option> command line
19851 option.
19852 </para>
19853 <para>
19854 As well as being useful in ACLs (including the <quote>connect</quote> ACL), these variable
19855 could be used, for example, to make the filename for a TLS certificate depend
19856 on which interface and/or port is being used for the incoming connection. The
19857 values of <varname>$received_ip_address</varname> and <varname>$received_port</varname> are saved with any
19858 messages that are received, thus making these variables available at delivery
19859 time.
19860 For outbound connections see <varname>$sending_ip_address</varname>.
19861 </para>
19862 </listitem></varlistentry>
19863 <varlistentry>
19864 <term><varname>$received_port</varname></term>
19865 <listitem>
19866 <para>
19867 <indexterm role="variable">
19868 <primary><varname>$received_port</varname></primary>
19869 </indexterm>
19870 See <varname>$received_ip_address</varname>.
19871 </para>
19872 </listitem></varlistentry>
19873 <varlistentry>
19874 <term><varname>$received_protocol</varname></term>
19875 <listitem>
19876 <para>
19877 <indexterm role="variable">
19878 <primary><varname>$received_protocol</varname></primary>
19879 </indexterm>
19880 When a message is being processed, this variable contains the name of the
19881 protocol by which it was received. Most of the names used by Exim are defined
19882 by RFCs 821, 2821, and 3848. They start with <quote>smtp</quote> (the client used HELO) or
19883 <quote>esmtp</quote> (the client used EHLO). This can be followed by <quote>s</quote> for secure
19884 (encrypted) and/or <quote>a</quote> for authenticated. Thus, for example, if the protocol
19885 is set to <quote>esmtpsa</quote>, the message was received over an encrypted SMTP
19886 connection and the client was successfully authenticated.
19887 </para>
19888 <para>
19889 Exim uses the protocol name <quote>smtps</quote> for the case when encryption is
19890 automatically set up on connection without the use of STARTTLS (see
19891 <option>tls_on_connect_ports</option>), and the client uses HELO to initiate the
19892 encrypted SMTP session. The name <quote>smtps</quote> is also used for the rare situation
19893 where the client initially uses EHLO, sets up an encrypted connection using
19894 STARTTLS, and then uses HELO afterwards.
19895 </para>
19896 <para>
19897 The <option>-oMr</option> option provides a way of specifying a custom protocol name for
19898 messages that are injected locally by trusted callers. This is commonly used to
19899 identify messages that are being re-injected after some kind of scanning.
19900 </para>
19901 </listitem></varlistentry>
19902 <varlistentry>
19903 <term><varname>$received_time</varname></term>
19904 <listitem>
19905 <para>
19906 <indexterm role="variable">
19907 <primary><varname>$received_time</varname></primary>
19908 </indexterm>
19909 This variable contains the date and time when the current message was received,
19910 as a number of seconds since the start of the Unix epoch.
19911 </para>
19912 </listitem></varlistentry>
19913 <varlistentry>
19914 <term><varname>$recipient_data</varname></term>
19915 <listitem>
19916 <para>
19917 <indexterm role="variable">
19918 <primary><varname>$recipient_data</varname></primary>
19919 </indexterm>
19920 This variable is set after an indexing lookup success in an ACL <option>recipients</option>
19921 condition. It contains the data from the lookup, and the value remains set
19922 until the next <option>recipients</option> test. Thus, you can do things like this:
19923 </para>
19924 <literallayout>
19925 <literal>require recipients  = cdb*@;/some/file</literal>
19926 <literal>deny    </literal><emphasis>some further test involving</emphasis> <literal>$recipient_data</literal>
19927 </literallayout>
19928 <para>
19929 <emphasis role="bold">Warning</emphasis>: This variable is set only when a lookup is used as an indexing
19930 method in the address list, using the semicolon syntax as in the example above.
19931 The variable is not set for a lookup that is used as part of the string
19932 expansion that all such lists undergo before being interpreted.
19933 </para>
19934 </listitem></varlistentry>
19935 <varlistentry>
19936 <term><varname>$recipient_verify_failure</varname></term>
19937 <listitem>
19938 <para>
19939 <indexterm role="variable">
19940 <primary><varname>$recipient_verify_failure</varname></primary>
19941 </indexterm>
19942 In an ACL, when a recipient verification fails, this variable contains
19943 information about the failure. It is set to one of the following words:
19944 </para>
19945 <itemizedlist>
19946 <listitem>
19947 <para>
19948 <quote>qualify</quote>: The address was unqualified (no domain), and the message
19949 was neither local nor came from an exempted host.
19950 </para>
19951 </listitem>
19952 <listitem>
19953 <para>
19954 <quote>route</quote>: Routing failed.
19955 </para>
19956 </listitem>
19957 <listitem>
19958 <para>
19959 <quote>mail</quote>: Routing succeeded, and a callout was attempted; rejection occurred at
19960 or before the MAIL command (that is, on initial connection, HELO, or
19961 MAIL).
19962 </para>
19963 </listitem>
19964 <listitem>
19965 <para>
19966 <quote>recipient</quote>: The RCPT command in a callout was rejected.
19967 </para>
19968 </listitem>
19969 <listitem>
19970 <para>
19971 <quote>postmaster</quote>: The postmaster check in a callout was rejected.
19972 </para>
19973 </listitem>
19974 </itemizedlist>
19975 <para>
19976 The main use of this variable is expected to be to distinguish between
19977 rejections of MAIL and rejections of RCPT.
19978 </para>
19979 </listitem></varlistentry>
19980 <varlistentry>
19981 <term><varname>$recipients</varname></term>
19982 <listitem>
19983 <para>
19984 <indexterm role="variable">
19985 <primary><varname>$recipients</varname></primary>
19986 </indexterm>
19987 This variable contains a list of envelope recipients for a message. A comma and
19988 a space separate the addresses in the replacement text. However, the variable
19989 is not generally available, to prevent exposure of Bcc recipients in
19990 unprivileged users&#x2019; filter files. You can use <varname>$recipients</varname> only in these
19991 cases:
19992 </para>
19993 <orderedlist numeration="arabic">
19994 <listitem>
19995 <para>
19996 In a system filter file.
19997 </para>
19998 </listitem>
19999 <listitem>
20000 <para>
20001 In the ACLs associated with the DATA command and with non-SMTP messages, that
20002 is, the ACLs defined by <option>acl_smtp_predata</option>, <option>acl_smtp_data</option>,
20003 <option>acl_smtp_mime</option>, <option>acl_not_smtp_start</option>, <option>acl_not_smtp</option>, and
20004 <option>acl_not_smtp_mime</option>.
20005 </para>
20006 </listitem>
20007 <listitem>
20008 <para>
20009 From within a <function>local_scan()</function> function.
20010 </para>
20011 </listitem>
20012 </orderedlist>
20013 </listitem></varlistentry>
20014 <varlistentry>
20015 <term><varname>$recipients_count</varname></term>
20016 <listitem>
20017 <para>
20018 <indexterm role="variable">
20019 <primary><varname>$recipients_count</varname></primary>
20020 </indexterm>
20021 When a message is being processed, this variable contains the number of
20022 envelope recipients that came with the message. Duplicates are not excluded
20023 from the count. While a message is being received over SMTP, the number
20024 increases for each accepted recipient. It can be referenced in an ACL.
20025 </para>
20026 </listitem></varlistentry>
20027 <varlistentry>
20028 <term><varname>$regex_match_string</varname></term>
20029 <listitem>
20030 <para>
20031 <indexterm role="variable">
20032 <primary><varname>$regex_match_string</varname></primary>
20033 </indexterm>
20034 This variable is set to contain the matching regular expression after a
20035 <option>regex</option> ACL condition has matched (see section <xref linkend="SECTscanregex"/>).
20036 </para>
20037 </listitem></varlistentry>
20038 <varlistentry>
20039 <term><varname>$regex1</varname>, <varname>$regex2</varname>, etc</term>
20040 <listitem>
20041 <para>
20042 <indexterm role="concept">
20043 <primary>regex submatch variables (<varname>$1regex</varname> <varname>$2regex</varname> etc)</primary>
20044 </indexterm>
20045 When a <option>regex</option> or <option>mime_regex</option> ACL condition succeeds,
20046 these variables contain the
20047 captured substrings identified by the regular expression.
20048 </para>
20049 </listitem></varlistentry>
20050 <varlistentry>
20051 <term><varname>$reply_address</varname></term>
20052 <listitem>
20053 <para>
20054 <indexterm role="variable">
20055 <primary><varname>$reply_address</varname></primary>
20056 </indexterm>
20057 When a message is being processed, this variable contains the contents of the
20058 <emphasis>Reply-To:</emphasis> header line if one exists and it is not empty, or otherwise the
20059 contents of the <emphasis>From:</emphasis> header line. Apart from the removal of leading
20060 white space, the value is not processed in any way. In particular, no RFC 2047
20061 decoding or character code translation takes place.
20062 </para>
20063 </listitem></varlistentry>
20064 <varlistentry>
20065 <term><varname>$return_path</varname></term>
20066 <listitem>
20067 <para>
20068 <indexterm role="variable">
20069 <primary><varname>$return_path</varname></primary>
20070 </indexterm>
20071 When a message is being delivered, this variable contains the return path &ndash;
20072 the sender field that will be sent as part of the envelope. It is not enclosed
20073 in &lt;&gt; characters. At the start of routing an address, <varname>$return_path</varname> has the
20074 same value as <varname>$sender_address</varname>, but if, for example, an incoming message to a
20075 mailing list has been expanded by a router which specifies a different address
20076 for bounce messages, <varname>$return_path</varname> subsequently contains the new bounce
20077 address, whereas <varname>$sender_address</varname> always contains the original sender address
20078 that was received with the message. In other words, <varname>$sender_address</varname> contains
20079 the incoming envelope sender, and <varname>$return_path</varname> contains the outgoing
20080 envelope sender.
20081 </para>
20082 </listitem></varlistentry>
20083 <varlistentry>
20084 <term><varname>$return_size_limit</varname></term>
20085 <listitem>
20086 <para>
20087 <indexterm role="variable">
20088 <primary><varname>$return_size_limit</varname></primary>
20089 </indexterm>
20090 This is an obsolete name for <varname>$bounce_return_size_limit</varname>.
20091 </para>
20092 </listitem></varlistentry>
20093 <varlistentry>
20094 <term><varname>$router_name</varname></term>
20095 <listitem>
20096 <para>
20097 <indexterm role="concept">
20098 <primary>router</primary>
20099 <secondary>name</secondary>
20100 </indexterm>
20101 <indexterm role="concept">
20102 <primary>name</primary>
20103 <secondary>of router</secondary>
20104 </indexterm>
20105 <indexterm role="variable">
20106 <primary><varname>$router_name</varname></primary>
20107 </indexterm>
20108 During the running of a router this variable contains its name.
20109 </para>
20110 </listitem></varlistentry>
20111 <varlistentry>
20112 <term><varname>$runrc</varname></term>
20113 <listitem>
20114 <para>
20115 <indexterm role="concept">
20116 <primary>return code</primary>
20117 <secondary>from <option>run</option> expansion</secondary>
20118 </indexterm>
20119 <indexterm role="variable">
20120 <primary><varname>$runrc</varname></primary>
20121 </indexterm>
20122 This variable contains the return code from a command that is run by the
20123 <option>${run...}</option> expansion item. <emphasis role="bold">Warning</emphasis>: In a router or transport, you cannot
20124 assume the order in which option values are expanded, except for those
20125 preconditions whose order of testing is documented. Therefore, you cannot
20126 reliably expect to set <varname>$runrc</varname> by the expansion of one option, and use it in
20127 another.
20128 </para>
20129 </listitem></varlistentry>
20130 <varlistentry>
20131 <term><varname>$self_hostname</varname></term>
20132 <listitem>
20133 <para>
20134 <indexterm role="option">
20135 <primary><option>self</option></primary>
20136 <secondary>value of host name</secondary>
20137 </indexterm>
20138 <indexterm role="variable">
20139 <primary><varname>$self_hostname</varname></primary>
20140 </indexterm>
20141 When an address is routed to a supposedly remote host that turns out to be the
20142 local host, what happens is controlled by the <option>self</option> generic router option.
20143 One of its values causes the address to be passed to another router. When this
20144 happens, <varname>$self_hostname</varname> is set to the name of the local host that the
20145 original router encountered. In other circumstances its contents are null.
20146 </para>
20147 </listitem></varlistentry>
20148 <varlistentry>
20149 <term><varname>$sender_address</varname></term>
20150 <listitem>
20151 <para>
20152 <indexterm role="variable">
20153 <primary><varname>$sender_address</varname></primary>
20154 </indexterm>
20155 When a message is being processed, this variable contains the sender&#x2019;s address
20156 that was received in the message&#x2019;s envelope. The case of letters in the address
20157 is retained, in both the local part and the domain. For bounce messages, the
20158 value of this variable is the empty string. See also <varname>$return_path</varname>.
20159 </para>
20160 </listitem></varlistentry>
20161 <varlistentry>
20162 <term><varname>$sender_address_data</varname></term>
20163 <listitem>
20164 <para>
20165 <indexterm role="variable">
20166 <primary><varname>$address_data</varname></primary>
20167 </indexterm>
20168 <indexterm role="variable">
20169 <primary><varname>$sender_address_data</varname></primary>
20170 </indexterm>
20171 If <varname>$address_data</varname> is set when the routers are called from an ACL to verify a
20172 sender address, the final value is preserved in <varname>$sender_address_data</varname>, to
20173 distinguish it from data from a recipient address. The value does not persist
20174 after the end of the current ACL statement. If you want to preserve it for
20175 longer, you can save it in an ACL variable.
20176 </para>
20177 </listitem></varlistentry>
20178 <varlistentry>
20179 <term><varname>$sender_address_domain</varname></term>
20180 <listitem>
20181 <para>
20182 <indexterm role="variable">
20183 <primary><varname>$sender_address_domain</varname></primary>
20184 </indexterm>
20185 The domain portion of <varname>$sender_address</varname>.
20186 </para>
20187 </listitem></varlistentry>
20188 <varlistentry>
20189 <term><varname>$sender_address_local_part</varname></term>
20190 <listitem>
20191 <para>
20192 <indexterm role="variable">
20193 <primary><varname>$sender_address_local_part</varname></primary>
20194 </indexterm>
20195 The local part portion of <varname>$sender_address</varname>.
20196 </para>
20197 </listitem></varlistentry>
20198 <varlistentry>
20199 <term><varname>$sender_data</varname></term>
20200 <listitem>
20201 <para>
20202 <indexterm role="variable">
20203 <primary><varname>$sender_data</varname></primary>
20204 </indexterm>
20205 This variable is set after a lookup success in an ACL <option>senders</option> condition or
20206 in a router <option>senders</option> option. It contains the data from the lookup, and the
20207 value remains set until the next <option>senders</option> test. Thus, you can do things like
20208 this:
20209 </para>
20210 <literallayout>
20211 <literal>require senders      = cdb*@;/some/file</literal>
20212 <literal>deny    </literal><emphasis>some further test involving</emphasis> <literal>$sender_data</literal>
20213 </literallayout>
20214 <para>
20215 <emphasis role="bold">Warning</emphasis>: This variable is set only when a lookup is used as an indexing
20216 method in the address list, using the semicolon syntax as in the example above.
20217 The variable is not set for a lookup that is used as part of the string
20218 expansion that all such lists undergo before being interpreted.
20219 </para>
20220 </listitem></varlistentry>
20221 <varlistentry>
20222 <term><varname>$sender_fullhost</varname></term>
20223 <listitem>
20224 <para>
20225 <indexterm role="variable">
20226 <primary><varname>$sender_fullhost</varname></primary>
20227 </indexterm>
20228 When a message is received from a remote host, this variable contains the host
20229 name and IP address in a single string. It ends with the IP address in square
20230 brackets, followed by a colon and a port number if the logging of ports is
20231 enabled. The format of the rest of the string depends on whether the host
20232 issued a HELO or EHLO SMTP command, and whether the host name was verified by
20233 looking up its IP address. (Looking up the IP address can be forced by the
20234 <option>host_lookup</option> option, independent of verification.) A plain host name at the
20235 start of the string is a verified host name; if this is not present,
20236 verification either failed or was not requested. A host name in parentheses is
20237 the argument of a HELO or EHLO command. This is omitted if it is identical to
20238 the verified host name or to the host&#x2019;s IP address in square brackets.
20239 </para>
20240 </listitem></varlistentry>
20241 <varlistentry>
20242 <term><varname>$sender_helo_dnssec</varname></term>
20243 <listitem>
20244 <para>
20245 <indexterm role="variable">
20246 <primary><varname>$sender_helo_dnssec</varname></primary>
20247 </indexterm>
20248 This boolean variable is true if a successful HELO verification was
20249 <indexterm role="concept">
20250 <primary>DNS</primary>
20251 <secondary>DNSSEC</secondary>
20252 </indexterm>
20253 done using DNS information the resolver library stated was authenticated data.
20254 </para>
20255 </listitem></varlistentry>
20256 <varlistentry>
20257 <term><varname>$sender_helo_name</varname></term>
20258 <listitem>
20259 <para>
20260 <indexterm role="variable">
20261 <primary><varname>$sender_helo_name</varname></primary>
20262 </indexterm>
20263 When a message is received from a remote host that has issued a HELO or EHLO
20264 command, the argument of that command is placed in this variable. It is also
20265 set if HELO or EHLO is used when a message is received using SMTP locally via
20266 the <option>-bs</option> or <option>-bS</option> options.
20267 </para>
20268 </listitem></varlistentry>
20269 <varlistentry>
20270 <term><varname>$sender_host_address</varname></term>
20271 <listitem>
20272 <para>
20273 <indexterm role="variable">
20274 <primary><varname>$sender_host_address</varname></primary>
20275 </indexterm>
20276 When a message is received from a remote host using SMTP,
20277 this variable contains that
20278 host&#x2019;s IP address. For locally non-SMTP submitted messages, it is empty.
20279 </para>
20280 </listitem></varlistentry>
20281 <varlistentry>
20282 <term><varname>$sender_host_authenticated</varname></term>
20283 <listitem>
20284 <para>
20285 <indexterm role="variable">
20286 <primary><varname>$sender_host_authenticated</varname></primary>
20287 </indexterm>
20288 This variable contains the name (not the public name) of the authenticator
20289 driver that successfully authenticated the client from which the message was
20290 received. It is empty if there was no successful authentication. See also
20291 <varname>$authenticated_id</varname>.
20292 </para>
20293 </listitem></varlistentry>
20294 <varlistentry>
20295 <term><varname>$sender_host_dnssec</varname></term>
20296 <listitem>
20297 <para>
20298 <indexterm role="variable">
20299 <primary><varname>$sender_host_dnssec</varname></primary>
20300 </indexterm>
20301 If an attempt to populate <varname>$sender_host_name</varname> has been made
20302 (by reference, <option>hosts_lookup</option> or
20303 otherwise) then this boolean will have been set true if, and only if, the
20304 resolver library states that both
20305 the reverse and forward DNS were authenticated data.  At all
20306 other times, this variable is false.
20307 </para>
20308 <para>
20309 <indexterm role="concept">
20310 <primary>DNS</primary>
20311 <secondary>DNSSEC</secondary>
20312 </indexterm>
20313 It is likely that you will need to coerce DNSSEC support on in the resolver
20314 library, by setting:
20315 </para>
20316 <literallayout class="monospaced">
20317 dns_dnssec_ok = 1
20318 </literallayout>
20319 <para>
20320 Exim does not perform DNSSEC validation itself, instead leaving that to a
20321 validating resolver (e.g. unbound, or bind with suitable configuration).
20322 </para>
20323 <para>
20324 If you have changed <option>host_lookup_order</option> so that <literal>bydns</literal> is not the first
20325 mechanism in the list, then this variable will be false.
20326 </para>
20327 <para>
20328 This requires that your system resolver library support EDNS0 (and that
20329 DNSSEC flags exist in the system headers).  If the resolver silently drops
20330 all EDNS0 options, then this will have no effect.  OpenBSD&#x2019;s asr resolver
20331 is known to currently ignore EDNS0, documented in CAVEATS of asr_run(3).
20332 </para>
20333 </listitem></varlistentry>
20334 <varlistentry>
20335 <term><varname>$sender_host_name</varname></term>
20336 <listitem>
20337 <para>
20338 <indexterm role="variable">
20339 <primary><varname>$sender_host_name</varname></primary>
20340 </indexterm>
20341 When a message is received from a remote host, this variable contains the
20342 host&#x2019;s name as obtained by looking up its IP address. For messages received by
20343 other means, this variable is empty.
20344 </para>
20345 <para>
20346 <indexterm role="variable">
20347 <primary><varname>$host_lookup_failed</varname></primary>
20348 </indexterm>
20349 If the host name has not previously been looked up, a reference to
20350 <varname>$sender_host_name</varname> triggers a lookup (for messages from remote hosts).
20351 A looked up name is accepted only if it leads back to the original IP address
20352 via a forward lookup. If either the reverse or the forward lookup fails to find
20353 any data, or if the forward lookup does not yield the original IP address,
20354 <varname>$sender_host_name</varname> remains empty, and <varname>$host_lookup_failed</varname> is set to <quote>1</quote>.
20355 </para>
20356 <para>
20357 <indexterm role="variable">
20358 <primary><varname>$host_lookup_deferred</varname></primary>
20359 </indexterm>
20360 However, if either of the lookups cannot be completed (for example, there is a
20361 DNS timeout), <varname>$host_lookup_deferred</varname> is set to <quote>1</quote>, and
20362 <varname>$host_lookup_failed</varname> remains set to <quote>0</quote>.
20363 </para>
20364 <para>
20365 Once <varname>$host_lookup_failed</varname> is set to <quote>1</quote>, Exim does not try to look up the
20366 host name again if there is a subsequent reference to <varname>$sender_host_name</varname>
20367 in the same Exim process, but it does try again if <varname>$host_lookup_deferred</varname>
20368 is set to <quote>1</quote>.
20369 </para>
20370 <para>
20371 Exim does not automatically look up every calling host&#x2019;s name. If you want
20372 maximum efficiency, you should arrange your configuration so that it avoids
20373 these lookups altogether. The lookup happens only if one or more of the
20374 following are true:
20375 </para>
20376 <itemizedlist>
20377 <listitem>
20378 <para>
20379 A string containing <varname>$sender_host_name</varname> is expanded.
20380 </para>
20381 </listitem>
20382 <listitem>
20383 <para>
20384 The calling host matches the list in <option>host_lookup</option>. In the default
20385 configuration, this option is set to *, so it must be changed if lookups are
20386 to be avoided. (In the code, the default for <option>host_lookup</option> is unset.)
20387 </para>
20388 </listitem>
20389 <listitem>
20390 <para>
20391 Exim needs the host name in order to test an item in a host list. The items
20392 that require this are described in sections <xref linkend="SECThoslispatnam"/> and
20393 <xref linkend="SECThoslispatnamsk"/>.
20394 </para>
20395 </listitem>
20396 <listitem>
20397 <para>
20398 The calling host matches <option>helo_try_verify_hosts</option> or <option>helo_verify_hosts</option>.
20399 In this case, the host name is required to compare with the name quoted in any
20400 EHLO or HELO commands that the client issues.
20401 </para>
20402 </listitem>
20403 <listitem>
20404 <para>
20405 The remote host issues a EHLO or HELO command that quotes one of the
20406 domains in <option>helo_lookup_domains</option>. The default value of this option is
20407 </para>
20408 <literallayout class="monospaced">
20409   helo_lookup_domains = @ : @[]
20410 </literallayout>
20411 <para>
20412 which causes a lookup if a remote host (incorrectly) gives the server&#x2019;s name or
20413 IP address in an EHLO or HELO command.
20414 </para>
20415 </listitem>
20416 </itemizedlist>
20417 </listitem></varlistentry>
20418 <varlistentry>
20419 <term><varname>$sender_host_port</varname></term>
20420 <listitem>
20421 <para>
20422 <indexterm role="variable">
20423 <primary><varname>$sender_host_port</varname></primary>
20424 </indexterm>
20425 When a message is received from a remote host, this variable contains the port
20426 number that was used on the remote host.
20427 </para>
20428 </listitem></varlistentry>
20429 <varlistentry>
20430 <term><varname>$sender_ident</varname></term>
20431 <listitem>
20432 <para>
20433 <indexterm role="variable">
20434 <primary><varname>$sender_ident</varname></primary>
20435 </indexterm>
20436 When a message is received from a remote host, this variable contains the
20437 identification received in response to an RFC 1413 request. When a message has
20438 been received locally, this variable contains the login name of the user that
20439 called Exim.
20440 </para>
20441 </listitem></varlistentry>
20442 <varlistentry>
20443 <term><varname>$sender_rate_</varname><emphasis>xxx</emphasis></term>
20444 <listitem>
20445 <para>
20446 A number of variables whose names begin <varname>$sender_rate_</varname> are set as part of the
20447 <option>ratelimit</option> ACL condition. Details are given in section
20448 <xref linkend="SECTratelimiting"/>.
20449 </para>
20450 </listitem></varlistentry>
20451 <varlistentry>
20452 <term><varname>$sender_rcvhost</varname></term>
20453 <listitem>
20454 <para>
20455 <indexterm role="concept">
20456 <primary>DNS</primary>
20457 <secondary>reverse lookup</secondary>
20458 </indexterm>
20459 <indexterm role="concept">
20460 <primary>reverse DNS lookup</primary>
20461 </indexterm>
20462 <indexterm role="variable">
20463 <primary><varname>$sender_rcvhost</varname></primary>
20464 </indexterm>
20465 This is provided specifically for use in <emphasis>Received:</emphasis> headers. It starts with
20466 either the verified host name (as obtained from a reverse DNS lookup) or, if
20467 there is no verified host name, the IP address in square brackets. After that
20468 there may be text in parentheses. When the first item is a verified host name,
20469 the first thing in the parentheses is the IP address in square brackets,
20470 followed by a colon and a port number if port logging is enabled. When the
20471 first item is an IP address, the port is recorded as <quote>port=<emphasis>xxxx</emphasis></quote> inside
20472 the parentheses.
20473 </para>
20474 <para>
20475 There may also be items of the form <quote>helo=<emphasis>xxxx</emphasis></quote> if HELO or EHLO
20476 was used and its argument was not identical to the real host name or IP
20477 address, and <quote>ident=<emphasis>xxxx</emphasis></quote> if an RFC 1413 ident string is available. If
20478 all three items are present in the parentheses, a newline and tab are inserted
20479 into the string, to improve the formatting of the <emphasis>Received:</emphasis> header.
20480 </para>
20481 </listitem></varlistentry>
20482 <varlistentry>
20483 <term><varname>$sender_verify_failure</varname></term>
20484 <listitem>
20485 <para>
20486 <indexterm role="variable">
20487 <primary><varname>$sender_verify_failure</varname></primary>
20488 </indexterm>
20489 In an ACL, when a sender verification fails, this variable contains information
20490 about the failure. The details are the same as for
20491 <varname>$recipient_verify_failure</varname>.
20492 </para>
20493 </listitem></varlistentry>
20494 <varlistentry>
20495 <term><varname>$sending_ip_address</varname></term>
20496 <listitem>
20497 <para>
20498 <indexterm role="variable">
20499 <primary><varname>$sending_ip_address</varname></primary>
20500 </indexterm>
20501 This variable is set whenever an outgoing SMTP connection to another host has
20502 been set up. It contains the IP address of the local interface that is being
20503 used. This is useful if a host that has more than one IP address wants to take
20504 on different personalities depending on which one is being used. For incoming
20505 connections, see <varname>$received_ip_address</varname>.
20506 </para>
20507 </listitem></varlistentry>
20508 <varlistentry>
20509 <term><varname>$sending_port</varname></term>
20510 <listitem>
20511 <para>
20512 <indexterm role="variable">
20513 <primary><varname>$sending_port</varname></primary>
20514 </indexterm>
20515 This variable is set whenever an outgoing SMTP connection to another host has
20516 been set up. It contains the local port that is being used. For incoming
20517 connections, see <varname>$received_port</varname>.
20518 </para>
20519 </listitem></varlistentry>
20520 <varlistentry>
20521 <term><varname>$smtp_active_hostname</varname></term>
20522 <listitem>
20523 <para>
20524 <indexterm role="variable">
20525 <primary><varname>$smtp_active_hostname</varname></primary>
20526 </indexterm>
20527 During an incoming SMTP session, this variable contains the value of the active
20528 host name, as specified by the <option>smtp_active_hostname</option> option. The value of
20529 <varname>$smtp_active_hostname</varname> is saved with any message that is received, so its
20530 value can be consulted during routing and delivery.
20531 </para>
20532 </listitem></varlistentry>
20533 <varlistentry>
20534 <term><varname>$smtp_command</varname></term>
20535 <listitem>
20536 <para>
20537 <indexterm role="variable">
20538 <primary><varname>$smtp_command</varname></primary>
20539 </indexterm>
20540 During the processing of an incoming SMTP command, this variable contains the
20541 entire command. This makes it possible to distinguish between HELO and EHLO in
20542 the HELO ACL, and also to distinguish between commands such as these:
20543 </para>
20544 <literallayout class="monospaced">
20545 MAIL FROM:&lt;&gt;
20546 MAIL FROM: &lt;&gt;
20547 </literallayout>
20548 <para>
20549 For a MAIL command, extra parameters such as SIZE can be inspected. For a RCPT
20550 command, the address in <varname>$smtp_command</varname> is the original address before any
20551 rewriting, whereas the values in <varname>$local_part</varname> and <varname>$domain</varname> are taken from
20552 the address after SMTP-time rewriting.
20553 </para>
20554 </listitem></varlistentry>
20555 <varlistentry>
20556 <term><varname>$smtp_command_argument</varname></term>
20557 <listitem>
20558 <para>
20559 <indexterm role="concept">
20560 <primary>SMTP</primary>
20561 <secondary>command, argument for</secondary>
20562 </indexterm>
20563 <indexterm role="variable">
20564 <primary><varname>$smtp_command_argument</varname></primary>
20565 </indexterm>
20566 While an ACL is running to check an SMTP command, this variable contains the
20567 argument, that is, the text that follows the command name, with leading white
20568 space removed. Following the introduction of <varname>$smtp_command</varname>, this variable is
20569 somewhat redundant, but is retained for backwards compatibility.
20570 </para>
20571 </listitem></varlistentry>
20572 <varlistentry>
20573 <term><varname>$smtp_command_history</varname></term>
20574 <listitem>
20575 <para>
20576 <indexterm role="concept">
20577 <primary>SMTP</primary>
20578 <secondary>command history</secondary>
20579 </indexterm>
20580 <indexterm role="variable">
20581 <primary><varname>$smtp_command_history</varname></primary>
20582 </indexterm>
20583 A comma-separated list (with no whitespace) of the most-recent SMTP commands
20584 received, in time-order left to right.  Only a limited number of commands
20585 are remembered.
20586 </para>
20587 </listitem></varlistentry>
20588 <varlistentry>
20589 <term><varname>$smtp_count_at_connection_start</varname></term>
20590 <listitem>
20591 <para>
20592 <indexterm role="variable">
20593 <primary><varname>$smtp_count_at_connection_start</varname></primary>
20594 </indexterm>
20595 This variable is set greater than zero only in processes spawned by the Exim
20596 daemon for handling incoming SMTP connections. The name is deliberately long,
20597 in order to emphasize what the contents are. When the daemon accepts a new
20598 connection, it increments this variable. A copy of the variable is passed to
20599 the child process that handles the connection, but its value is fixed, and
20600 never changes. It is only an approximation of how many incoming connections
20601 there actually are, because many other connections may come and go while a
20602 single connection is being processed. When a child process terminates, the
20603 daemon decrements its copy of the variable.
20604 </para>
20605 </listitem></varlistentry>
20606 <varlistentry>
20607 <term><varname>$sn0</varname> &ndash; <varname>$sn9</varname></term>
20608 <listitem>
20609 <para>
20610 These variables are copies of the values of the <varname>$n0</varname> &ndash; <varname>$n9</varname> accumulators
20611 that were current at the end of the system filter file. This allows a system
20612 filter file to set values that can be tested in users&#x2019; filter files. For
20613 example, a system filter could set a value indicating how likely it is that a
20614 message is junk mail.
20615 </para>
20616 </listitem></varlistentry>
20617 <varlistentry>
20618 <term><varname>$spam_</varname><emphasis>xxx</emphasis></term>
20619 <listitem>
20620 <para>
20621 A number of variables whose names start with <varname>$spam</varname> are available when Exim
20622 is compiled with the content-scanning extension. For details, see section
20623 <xref linkend="SECTscanspamass"/>.
20624 </para>
20625 </listitem></varlistentry>
20626 <varlistentry>
20627 <term><varname>$spf_header_comment</varname></term>
20628 <term><varname>$spf_received</varname></term>
20629 <term><varname>$spf_result</varname></term>
20630 <term><varname>$spf_result_guessed</varname></term>
20631 <term><varname>$spf_smtp_comment</varname></term>
20632 <listitem>
20633 <para>
20634 These variables are only available if Exim is built with SPF support.
20635 For details see section <xref linkend="SECSPF"/>.
20636 </para>
20637 </listitem></varlistentry>
20638 <varlistentry>
20639 <term><varname>$spool_directory</varname></term>
20640 <listitem>
20641 <para>
20642 <indexterm role="variable">
20643 <primary><varname>$spool_directory</varname></primary>
20644 </indexterm>
20645 The name of Exim&#x2019;s spool directory.
20646 </para>
20647 </listitem></varlistentry>
20648 <varlistentry>
20649 <term><varname>$spool_inodes</varname></term>
20650 <listitem>
20651 <para>
20652 <indexterm role="variable">
20653 <primary><varname>$spool_inodes</varname></primary>
20654 </indexterm>
20655 The number of free inodes in the disk partition where Exim&#x2019;s spool files are
20656 being written. The value is recalculated whenever the variable is referenced.
20657 If the relevant file system does not have the concept of inodes, the value of
20658 is -1. See also the <option>check_spool_inodes</option> option.
20659 </para>
20660 </listitem></varlistentry>
20661 <varlistentry>
20662 <term><varname>$spool_space</varname></term>
20663 <listitem>
20664 <para>
20665 <indexterm role="variable">
20666 <primary><varname>$spool_space</varname></primary>
20667 </indexterm>
20668 The amount of free space (as a number of kilobytes) in the disk partition where
20669 Exim&#x2019;s spool files are being written. The value is recalculated whenever the
20670 variable is referenced. If the operating system does not have the ability to
20671 find the amount of free space (only true for experimental systems), the space
20672 value is -1. For example, to check in an ACL that there is at least 50
20673 megabytes free on the spool, you could write:
20674 </para>
20675 <literallayout class="monospaced">
20676 condition = ${if &gt; {$spool_space}{50000}}
20677 </literallayout>
20678 <para>
20679 See also the <option>check_spool_space</option> option.
20680 </para>
20681 </listitem></varlistentry>
20682 <varlistentry>
20683 <term><varname>$thisaddress</varname></term>
20684 <listitem>
20685 <para>
20686 <indexterm role="variable">
20687 <primary><varname>$thisaddress</varname></primary>
20688 </indexterm>
20689 This variable is set only during the processing of the <option>foranyaddress</option>
20690 command in a filter file. Its use is explained in the description of that
20691 command, which can be found in the separate document entitled <emphasis>Exim&#x2019;s
20692 interfaces to mail filtering</emphasis>.
20693 </para>
20694 </listitem></varlistentry>
20695 <varlistentry>
20696 <term><varname>$tls_in_bits</varname></term>
20697 <listitem>
20698 <para>
20699 <indexterm role="variable">
20700 <primary><varname>$tls_in_bits</varname></primary>
20701 </indexterm>
20702 Contains an approximation of the TLS cipher&#x2019;s bit-strength
20703 on the inbound connection; the meaning of
20704 this depends upon the TLS implementation used.
20705 If TLS has not been negotiated, the value will be 0.
20706 The value of this is automatically fed into the Cyrus SASL authenticator
20707 when acting as a server, to specify the "external SSF" (a SASL term).
20708 </para>
20709 <para>
20710 The deprecated <varname>$tls_bits</varname> variable refers to the inbound side
20711 except when used in the context of an outbound SMTP delivery, when it refers to
20712 the outbound.
20713 </para>
20714 </listitem></varlistentry>
20715 <varlistentry>
20716 <term><varname>$tls_out_bits</varname></term>
20717 <listitem>
20718 <para>
20719 <indexterm role="variable">
20720 <primary><varname>$tls_out_bits</varname></primary>
20721 </indexterm>
20722 Contains an approximation of the TLS cipher&#x2019;s bit-strength
20723 on an outbound SMTP connection; the meaning of
20724 this depends upon the TLS implementation used.
20725 If TLS has not been negotiated, the value will be 0.
20726 </para>
20727 </listitem></varlistentry>
20728 <varlistentry>
20729 <term><varname>$tls_in_ourcert</varname></term>
20730 <listitem>
20731 <para>
20732 <indexterm role="variable">
20733 <primary><varname>$tls_in_ourcert</varname></primary>
20734 </indexterm>
20735 <indexterm role="concept">
20736 <primary>certificate</primary>
20737 <secondary>variables</secondary>
20738 </indexterm>
20739 This variable refers to the certificate presented to the peer of an
20740 inbound connection when the message was received.
20741 It is only useful as the argument of a
20742 <option>certextract</option> expansion item, <option>md5</option>, <option>sha1</option> or <option>sha256</option> operator,
20743 or a <option>def</option> condition.
20744 </para>
20745 <para>
20746 <emphasis role="bold">Note</emphasis>: Under versions of OpenSSL preceding 1.1.1,
20747 when a list of more than one
20748 file is used for <option>tls_certificate</option>, this variable is not reliable.
20749 </para>
20750 <para revisionflag="changed">
20751 The macro "_TLS_BAD_MULTICERT_IN_OURCERT" will be defined for those versions.
20752 </para>
20753 </listitem></varlistentry>
20754 <varlistentry>
20755 <term><varname>$tls_in_peercert</varname></term>
20756 <listitem>
20757 <para>
20758 <indexterm role="variable">
20759 <primary><varname>$tls_in_peercert</varname></primary>
20760 </indexterm>
20761 This variable refers to the certificate presented by the peer of an
20762 inbound connection when the message was received.
20763 It is only useful as the argument of a
20764 <option>certextract</option> expansion item, <option>md5</option>, <option>sha1</option> or <option>sha256</option> operator,
20765 or a <option>def</option> condition.
20766 If certificate verification fails it may refer to a failing chain element
20767 which is not the leaf.
20768 </para>
20769 </listitem></varlistentry>
20770 <varlistentry>
20771 <term><varname>$tls_out_ourcert</varname></term>
20772 <listitem>
20773 <para>
20774 <indexterm role="variable">
20775 <primary><varname>$tls_out_ourcert</varname></primary>
20776 </indexterm>
20777 This variable refers to the certificate presented to the peer of an
20778 outbound connection.  It is only useful as the argument of a
20779 <option>certextract</option> expansion item, <option>md5</option>, <option>sha1</option> or <option>sha256</option> operator,
20780 or a <option>def</option> condition.
20781 </para>
20782 </listitem></varlistentry>
20783 <varlistentry>
20784 <term><varname>$tls_out_peercert</varname></term>
20785 <listitem>
20786 <para>
20787 <indexterm role="variable">
20788 <primary><varname>$tls_out_peercert</varname></primary>
20789 </indexterm>
20790 This variable refers to the certificate presented by the peer of an
20791 outbound connection.  It is only useful as the argument of a
20792 <option>certextract</option> expansion item, <option>md5</option>, <option>sha1</option> or <option>sha256</option> operator,
20793 or a <option>def</option> condition.
20794 If certificate verification fails it may refer to a failing chain element
20795 which is not the leaf.
20796 </para>
20797 </listitem></varlistentry>
20798 <varlistentry>
20799 <term><varname>$tls_in_certificate_verified</varname></term>
20800 <listitem>
20801 <para>
20802 <indexterm role="variable">
20803 <primary><varname>$tls_in_certificate_verified</varname></primary>
20804 </indexterm>
20805 This variable is set to <quote>1</quote> if a TLS certificate was verified when the
20806 message was received, and <quote>0</quote> otherwise.
20807 </para>
20808 <para>
20809 The deprecated <varname>$tls_certificate_verified</varname> variable refers to the inbound side
20810 except when used in the context of an outbound SMTP delivery, when it refers to
20811 the outbound.
20812 </para>
20813 </listitem></varlistentry>
20814 <varlistentry>
20815 <term><varname>$tls_out_certificate_verified</varname></term>
20816 <listitem>
20817 <para>
20818 <indexterm role="variable">
20819 <primary><varname>$tls_out_certificate_verified</varname></primary>
20820 </indexterm>
20821 This variable is set to <quote>1</quote> if a TLS certificate was verified when an
20822 outbound SMTP connection was made,
20823 and <quote>0</quote> otherwise.
20824 </para>
20825 </listitem></varlistentry>
20826 <varlistentry>
20827 <term><varname>$tls_in_cipher</varname></term>
20828 <listitem>
20829 <para>
20830 <indexterm role="variable">
20831 <primary><varname>$tls_in_cipher</varname></primary>
20832 </indexterm>
20833 <indexterm role="variable">
20834 <primary><varname>$tls_cipher</varname></primary>
20835 </indexterm>
20836 When a message is received from a remote host over an encrypted SMTP
20837 connection, this variable is set to the cipher suite that was negotiated, for
20838 example DES-CBC3-SHA. In other circumstances, in particular, for message
20839 received over unencrypted connections, the variable is empty. Testing
20840 <varname>$tls_in_cipher</varname> for emptiness is one way of distinguishing between encrypted and
20841 non-encrypted connections during ACL processing.
20842 </para>
20843 <para>
20844 The deprecated <varname>$tls_cipher</varname> variable is the same as <varname>$tls_in_cipher</varname> during message reception,
20845 but in the context of an outward SMTP delivery taking place via the <command>smtp</command> transport
20846 becomes the same as <varname>$tls_out_cipher</varname>.
20847 </para>
20848 </listitem></varlistentry>
20849 <varlistentry revisionflag="changed">
20850 <term><varname>$tls_in_cipher_std</varname></term>
20851 <listitem>
20852 <para revisionflag="changed">
20853 <indexterm role="variable">
20854 <primary><varname>$tls_in_cipher_std</varname></primary>
20855 </indexterm>
20856 As above, but returning the RFC standard name for the cipher suite.
20857 </para>
20858 </listitem></varlistentry>
20859 <varlistentry>
20860 <term><varname>$tls_out_cipher</varname></term>
20861 <listitem>
20862 <para>
20863 <indexterm role="variable">
20864 <primary><varname>$tls_out_cipher</varname></primary>
20865 </indexterm>
20866 This variable is
20867 cleared before any outgoing SMTP connection is made,
20868 and then set to the outgoing cipher suite if one is negotiated. See chapter
20869 <xref linkend="CHAPTLS"/> for details of TLS support and chapter <xref linkend="CHAPsmtptrans"/> for
20870 details of the <command>smtp</command> transport.
20871 </para>
20872 </listitem></varlistentry>
20873 <varlistentry revisionflag="changed">
20874 <term><varname>$tls_out_cipher_std</varname></term>
20875 <listitem>
20876 <para revisionflag="changed">
20877 <indexterm role="variable">
20878 <primary><varname>$tls_out_cipher_std</varname></primary>
20879 </indexterm>
20880 As above, but returning the RFC standard name for the cipher suite.
20881 </para>
20882 </listitem></varlistentry>
20883 <varlistentry>
20884 <term><varname>$tls_out_dane</varname></term>
20885 <listitem>
20886 <para>
20887 <indexterm role="variable">
20888 <primary><varname>$tls_out_dane</varname></primary>
20889 </indexterm>
20890 DANE active status.  See section <xref linkend="SECDANE"/>.
20891 </para>
20892 </listitem></varlistentry>
20893 <varlistentry>
20894 <term><varname>$tls_in_ocsp</varname></term>
20895 <listitem>
20896 <para>
20897 <indexterm role="variable">
20898 <primary><varname>$tls_in_ocsp</varname></primary>
20899 </indexterm>
20900 When a message is received from a remote client connection
20901 the result of any OCSP request from the client is encoded in this variable:
20902 </para>
20903 <literallayout class="monospaced">
20904 0 OCSP proof was not requested (default value)
20905 1 No response to request
20906 2 Response not verified
20907 3 Verification failed
20908 4 Verification succeeded
20909 </literallayout>
20910 </listitem></varlistentry>
20911 <varlistentry>
20912 <term><varname>$tls_out_ocsp</varname></term>
20913 <listitem>
20914 <para>
20915 <indexterm role="variable">
20916 <primary><varname>$tls_out_ocsp</varname></primary>
20917 </indexterm>
20918 When a message is sent to a remote host connection
20919 the result of any OCSP request made is encoded in this variable.
20920 See <varname>$tls_in_ocsp</varname> for values.
20921 </para>
20922 </listitem></varlistentry>
20923 <varlistentry>
20924 <term><varname>$tls_in_peerdn</varname></term>
20925 <listitem>
20926 <para>
20927 <indexterm role="variable">
20928 <primary><varname>$tls_in_peerdn</varname></primary>
20929 </indexterm>
20930 <indexterm role="variable">
20931 <primary><varname>$tls_peerdn</varname></primary>
20932 </indexterm>
20933 <indexterm role="concept">
20934 <primary>certificate</primary>
20935 <secondary>extracting fields</secondary>
20936 </indexterm>
20937 When a message is received from a remote host over an encrypted SMTP
20938 connection, and Exim is configured to request a certificate from the client,
20939 the value of the Distinguished Name of the certificate is made available in the
20940 <varname>$tls_in_peerdn</varname> during subsequent processing.
20941 If certificate verification fails it may refer to a failing chain element
20942 which is not the leaf.
20943 </para>
20944 <para>
20945 The deprecated <varname>$tls_peerdn</varname> variable refers to the inbound side
20946 except when used in the context of an outbound SMTP delivery, when it refers to
20947 the outbound.
20948 </para>
20949 </listitem></varlistentry>
20950 <varlistentry>
20951 <term><varname>$tls_out_peerdn</varname></term>
20952 <listitem>
20953 <para>
20954 <indexterm role="variable">
20955 <primary><varname>$tls_out_peerdn</varname></primary>
20956 </indexterm>
20957 When a message is being delivered to a remote host over an encrypted SMTP
20958 connection, and Exim is configured to request a certificate from the server,
20959 the value of the Distinguished Name of the certificate is made available in the
20960 <varname>$tls_out_peerdn</varname> during subsequent processing.
20961 If certificate verification fails it may refer to a failing chain element
20962 which is not the leaf.
20963 </para>
20964 </listitem></varlistentry>
20965 <varlistentry>
20966 <term><varname>$tls_in_sni</varname></term>
20967 <listitem>
20968 <para>
20969 <indexterm role="variable">
20970 <primary><varname>$tls_in_sni</varname></primary>
20971 </indexterm>
20972 <indexterm role="variable">
20973 <primary><varname>$tls_sni</varname></primary>
20974 </indexterm>
20975 <indexterm role="concept">
20976 <primary>TLS</primary>
20977 <secondary>Server Name Indication</secondary>
20978 </indexterm>
20979 When a TLS session is being established, if the client sends the Server
20980 Name Indication extension, the value will be placed in this variable.
20981 If the variable appears in <option>tls_certificate</option> then this option and
20982 some others, described in <xref linkend="SECTtlssni"/>,
20983 will be re-expanded early in the TLS session, to permit
20984 a different certificate to be presented (and optionally a different key to be
20985 used) to the client, based upon the value of the SNI extension.
20986 </para>
20987 <para>
20988 The deprecated <varname>$tls_sni</varname> variable refers to the inbound side
20989 except when used in the context of an outbound SMTP delivery, when it refers to
20990 the outbound.
20991 </para>
20992 </listitem></varlistentry>
20993 <varlistentry>
20994 <term><varname>$tls_out_sni</varname></term>
20995 <listitem>
20996 <para>
20997 <indexterm role="variable">
20998 <primary><varname>$tls_out_sni</varname></primary>
20999 </indexterm>
21000 <indexterm role="concept">
21001 <primary>TLS</primary>
21002 <secondary>Server Name Indication</secondary>
21003 </indexterm>
21004 During outbound
21005 SMTP deliveries, this variable reflects the value of the <option>tls_sni</option> option on
21006 the transport.
21007 </para>
21008 </listitem></varlistentry>
21009 <varlistentry>
21010 <term><varname>$tls_out_tlsa_usage</varname></term>
21011 <listitem>
21012 <para>
21013 <indexterm role="variable">
21014 <primary><varname>$tls_out_tlsa_usage</varname></primary>
21015 </indexterm>
21016 Bitfield of TLSA record types found.  See section <xref linkend="SECDANE"/>.
21017 </para>
21018 </listitem></varlistentry>
21019 <varlistentry revisionflag="changed">
21020 <term><varname>$tls_in_ver</varname></term>
21021 <listitem>
21022 <para revisionflag="changed">
21023 <indexterm role="variable">
21024 <primary><varname>$tls_in_ver</varname></primary>
21025 </indexterm>
21026 When a message is received from a remote host over an encrypted SMTP connection
21027 this variable is set to the protocol version, eg <emphasis>TLS1.2</emphasis>.
21028 </para>
21029 </listitem></varlistentry>
21030 <varlistentry revisionflag="changed">
21031 <term><varname>$tls_out_ver</varname></term>
21032 <listitem>
21033 <para revisionflag="changed">
21034 <indexterm role="variable">
21035 <primary><varname>$tls_out_ver</varname></primary>
21036 </indexterm>
21037 When a message is being delivered to a remote host over an encrypted SMTP connection
21038 this variable is set to the protocol version.
21039 </para>
21040 </listitem></varlistentry>
21041 <varlistentry>
21042 <term><varname>$tod_bsdinbox</varname></term>
21043 <listitem>
21044 <para>
21045 <indexterm role="variable">
21046 <primary><varname>$tod_bsdinbox</varname></primary>
21047 </indexterm>
21048 The time of day and the date, in the format required for BSD-style mailbox
21049 files, for example: Thu Oct 17 17:14:09 1995.
21050 </para>
21051 </listitem></varlistentry>
21052 <varlistentry>
21053 <term><varname>$tod_epoch</varname></term>
21054 <listitem>
21055 <para>
21056 <indexterm role="variable">
21057 <primary><varname>$tod_epoch</varname></primary>
21058 </indexterm>
21059 The time and date as a number of seconds since the start of the Unix epoch.
21060 </para>
21061 </listitem></varlistentry>
21062 <varlistentry>
21063 <term><varname>$tod_epoch_l</varname></term>
21064 <listitem>
21065 <para>
21066 <indexterm role="variable">
21067 <primary><varname>$tod_epoch_l</varname></primary>
21068 </indexterm>
21069 The time and date as a number of microseconds since the start of the Unix epoch.
21070 </para>
21071 </listitem></varlistentry>
21072 <varlistentry>
21073 <term><varname>$tod_full</varname></term>
21074 <listitem>
21075 <para>
21076 <indexterm role="variable">
21077 <primary><varname>$tod_full</varname></primary>
21078 </indexterm>
21079 A full version of the time and date, for example: Wed, 16 Oct 1995 09:51:40
21080 +0100. The timezone is always given as a numerical offset from UTC, with
21081 positive values used for timezones that are ahead (east) of UTC, and negative
21082 values for those that are behind (west).
21083 </para>
21084 </listitem></varlistentry>
21085 <varlistentry>
21086 <term><varname>$tod_log</varname></term>
21087 <listitem>
21088 <para>
21089 <indexterm role="variable">
21090 <primary><varname>$tod_log</varname></primary>
21091 </indexterm>
21092 The time and date in the format used for writing Exim&#x2019;s log files, for example:
21093 1995-10-12 15:32:29, but without a timezone.
21094 </para>
21095 </listitem></varlistentry>
21096 <varlistentry>
21097 <term><varname>$tod_logfile</varname></term>
21098 <listitem>
21099 <para>
21100 <indexterm role="variable">
21101 <primary><varname>$tod_logfile</varname></primary>
21102 </indexterm>
21103 This variable contains the date in the format yyyymmdd. This is the format that
21104 is used for datestamping log files when <option>log_file_path</option> contains the <literal>%D</literal>
21105 flag.
21106 </para>
21107 </listitem></varlistentry>
21108 <varlistentry>
21109 <term><varname>$tod_zone</varname></term>
21110 <listitem>
21111 <para>
21112 <indexterm role="variable">
21113 <primary><varname>$tod_zone</varname></primary>
21114 </indexterm>
21115 This variable contains the numerical value of the local timezone, for example:
21116 -0500.
21117 </para>
21118 </listitem></varlistentry>
21119 <varlistentry>
21120 <term><varname>$tod_zulu</varname></term>
21121 <listitem>
21122 <para>
21123 <indexterm role="variable">
21124 <primary><varname>$tod_zulu</varname></primary>
21125 </indexterm>
21126 This variable contains the UTC date and time in <quote>Zulu</quote> format, as specified
21127 by ISO 8601, for example: 20030221154023Z.
21128 </para>
21129 </listitem></varlistentry>
21130 <varlistentry>
21131 <term><varname>$transport_name</varname></term>
21132 <listitem>
21133 <para>
21134 <indexterm role="concept">
21135 <primary>transport</primary>
21136 <secondary>name</secondary>
21137 </indexterm>
21138 <indexterm role="concept">
21139 <primary>name</primary>
21140 <secondary>of transport</secondary>
21141 </indexterm>
21142 <indexterm role="variable">
21143 <primary><varname>$transport_name</varname></primary>
21144 </indexterm>
21145 During the running of a transport, this variable contains its name.
21146 </para>
21147 </listitem></varlistentry>
21148 <varlistentry>
21149 <term><varname>$value</varname></term>
21150 <listitem>
21151 <para>
21152 <indexterm role="variable">
21153 <primary><varname>$value</varname></primary>
21154 </indexterm>
21155 This variable contains the result of an expansion lookup, extraction operation,
21156 or external command, as described above. It is also used during a
21157 <emphasis role="bold">reduce</emphasis> expansion.
21158 </para>
21159 </listitem></varlistentry>
21160 <varlistentry>
21161 <term><varname>$verify_mode</varname></term>
21162 <listitem>
21163 <para>
21164 <indexterm role="variable">
21165 <primary><varname>$verify_mode</varname></primary>
21166 </indexterm>
21167 While a router or transport is being run in verify mode or for cutthrough delivery,
21168 contains "S" for sender-verification or "R" for recipient-verification.
21169 Otherwise, empty.
21170 </para>
21171 </listitem></varlistentry>
21172 <varlistentry>
21173 <term><varname>$version_number</varname></term>
21174 <listitem>
21175 <para>
21176 <indexterm role="variable">
21177 <primary><varname>$version_number</varname></primary>
21178 </indexterm>
21179 The version number of Exim. Same as <varname>$exim_version</varname>, may be overridden
21180 by the <option>exim_version</option> main config option.
21181 </para>
21182 </listitem></varlistentry>
21183 <varlistentry>
21184 <term><varname>$warn_message_delay</varname></term>
21185 <listitem>
21186 <para>
21187 <indexterm role="variable">
21188 <primary><varname>$warn_message_delay</varname></primary>
21189 </indexterm>
21190 This variable is set only during the creation of a message warning about a
21191 delivery delay. Details of its use are explained in section <xref linkend="SECTcustwarn"/>.
21192 </para>
21193 </listitem></varlistentry>
21194 <varlistentry>
21195 <term><varname>$warn_message_recipients</varname></term>
21196 <listitem>
21197 <para>
21198 <indexterm role="variable">
21199 <primary><varname>$warn_message_recipients</varname></primary>
21200 </indexterm>
21201 This variable is set only during the creation of a message warning about a
21202 delivery delay. Details of its use are explained in section <xref linkend="SECTcustwarn"/>.
21203 </para>
21204 </listitem></varlistentry>
21205 </variablelist>
21206 <para>
21207 <indexterm role="concept" startref="IIDstrexp" class="endofrange"/>
21208 </para>
21209 </section>
21210 </chapter>
21211
21212 <chapter id="CHAPperl">
21213 <title>Embedded Perl</title>
21214 <para>
21215 <indexterm role="concept" id="IIDperl" class="startofrange">
21216 <primary>Perl</primary>
21217 <secondary>calling from Exim</secondary>
21218 </indexterm>
21219 Exim can be built to include an embedded Perl interpreter. When this is done,
21220 Perl subroutines can be called as part of the string expansion process. To make
21221 use of the Perl support, you need version 5.004 or later of Perl installed on
21222 your system. To include the embedded interpreter in the Exim binary, include
21223 the line
21224 </para>
21225 <literallayout class="monospaced">
21226 EXIM_PERL = perl.o
21227 </literallayout>
21228 <para>
21229 in your <filename>Local/Makefile</filename> and then build Exim in the normal way.
21230 </para>
21231 <section id="SECID85">
21232 <title>Setting up so Perl can be used</title>
21233 <para>
21234 <indexterm role="option">
21235 <primary><option>perl_startup</option></primary>
21236 </indexterm>
21237 Access to Perl subroutines is via a global configuration option called
21238 <option>perl_startup</option> and an expansion string operator <option>${perl ...}</option>. If there is
21239 no <option>perl_startup</option> option in the Exim configuration file then no Perl
21240 interpreter is started and there is almost no overhead for Exim (since none of
21241 the Perl library will be paged in unless used). If there is a <option>perl_startup</option>
21242 option then the associated value is taken to be Perl code which is executed in
21243 a newly created Perl interpreter.
21244 </para>
21245 <para>
21246 The value of <option>perl_startup</option> is not expanded in the Exim sense, so you do not
21247 need backslashes before any characters to escape special meanings. The option
21248 should usually be something like
21249 </para>
21250 <literallayout class="monospaced">
21251 perl_startup = do '/etc/exim.pl'
21252 </literallayout>
21253 <para>
21254 where <filename>/etc/exim.pl</filename> is Perl code which defines any subroutines you want to
21255 use from Exim. Exim can be configured either to start up a Perl interpreter as
21256 soon as it is entered, or to wait until the first time it is needed. Starting
21257 the interpreter at the beginning ensures that it is done while Exim still has
21258 its setuid privilege, but can impose an unnecessary overhead if Perl is not in
21259 fact used in a particular run. Also, note that this does not mean that Exim is
21260 necessarily running as root when Perl is called at a later time. By default,
21261 the interpreter is started only when it is needed, but this can be changed in
21262 two ways:
21263 </para>
21264 <itemizedlist>
21265 <listitem>
21266 <para>
21267 <indexterm role="option">
21268 <primary><option>perl_at_start</option></primary>
21269 </indexterm>
21270 Setting <option>perl_at_start</option> (a boolean option) in the configuration requests
21271 a startup when Exim is entered.
21272 </para>
21273 </listitem>
21274 <listitem>
21275 <para>
21276 The command line option <option>-ps</option> also requests a startup when Exim is entered,
21277 overriding the setting of <option>perl_at_start</option>.
21278 </para>
21279 </listitem>
21280 </itemizedlist>
21281 <para>
21282 There is also a command line option <option>-pd</option> (for delay) which suppresses the
21283 initial startup, even if <option>perl_at_start</option> is set.
21284 </para>
21285 <itemizedlist>
21286 <listitem>
21287 <para>
21288 <indexterm role="option">
21289 <primary><option>perl_taintmode</option></primary>
21290 </indexterm>
21291 <indexterm role="concept">
21292 <primary>Perl</primary>
21293 <secondary>taintmode</secondary>
21294 </indexterm>
21295 To provide more security executing Perl code via the embedded Perl
21296 interpreter, the <option>perl_taintmode</option> option can be set. This enables the
21297 taint mode of the Perl interpreter. You are encouraged to set this
21298 option to a true value. To avoid breaking existing installations, it
21299 defaults to false.
21300 </para>
21301 </listitem>
21302 </itemizedlist>
21303 </section>
21304 <section id="SECID86">
21305 <title>Calling Perl subroutines</title>
21306 <para>
21307 When the configuration file includes a <option>perl_startup</option> option you can make use
21308 of the string expansion item to call the Perl subroutines that are defined
21309 by the <option>perl_startup</option> code. The operator is used in any of the following
21310 forms:
21311 </para>
21312 <literallayout class="monospaced">
21313 ${perl{foo}}
21314 ${perl{foo}{argument}}
21315 ${perl{foo}{argument1}{argument2} ... }
21316 </literallayout>
21317 <para>
21318 which calls the subroutine <option>foo</option> with the given arguments. A maximum of eight
21319 arguments may be passed. Passing more than this results in an expansion failure
21320 with an error message of the form
21321 </para>
21322 <literallayout class="monospaced">
21323 Too many arguments passed to Perl subroutine "foo" (max is 8)
21324 </literallayout>
21325 <para>
21326 The return value of the Perl subroutine is evaluated in a scalar context before
21327 it is passed back to Exim to be inserted into the expanded string. If the
21328 return value is <emphasis>undef</emphasis>, the expansion is forced to fail in the same way as
21329 an explicit <quote>fail</quote> on an <option>if</option> or <option>lookup</option> item. If the subroutine aborts
21330 by obeying Perl&#x2019;s <option>die</option> function, the expansion fails with the error message
21331 that was passed to <option>die</option>.
21332 </para>
21333 </section>
21334 <section id="SECID87">
21335 <title>Calling Exim functions from Perl</title>
21336 <para>
21337 Within any Perl code called from Exim, the function <emphasis>Exim::expand_string()</emphasis>
21338 is available to call back into Exim&#x2019;s string expansion function. For example,
21339 the Perl code
21340 </para>
21341 <literallayout class="monospaced">
21342 my $lp = Exim::expand_string('$local_part');
21343 </literallayout>
21344 <para>
21345 makes the current Exim <varname>$local_part</varname> available in the Perl variable <varname>$lp</varname>.
21346 Note those are single quotes and not double quotes to protect against
21347 <varname>$local_part</varname> being interpolated as a Perl variable.
21348 </para>
21349 <para>
21350 If the string expansion is forced to fail by a <quote>fail</quote> item, the result of
21351 <emphasis>Exim::expand_string()</emphasis> is <option>undef</option>. If there is a syntax error in the
21352 expansion string, the Perl call from the original expansion string fails with
21353 an appropriate error message, in the same way as if <option>die</option> were used.
21354 </para>
21355 <para>
21356 <indexterm role="concept">
21357 <primary>debugging</primary>
21358 <secondary>from embedded Perl</secondary>
21359 </indexterm>
21360 <indexterm role="concept">
21361 <primary>log</primary>
21362 <secondary>writing from embedded Perl</secondary>
21363 </indexterm>
21364 Two other Exim functions are available for use from within Perl code.
21365 <emphasis>Exim::debug_write()</emphasis> writes a string to the standard error stream if Exim&#x2019;s
21366 debugging is enabled. If you want a newline at the end, you must supply it.
21367 <emphasis>Exim::log_write()</emphasis> writes a string to Exim&#x2019;s main log, adding a leading
21368 timestamp. In this case, you should not supply a terminating newline.
21369 </para>
21370 </section>
21371 <section id="SECID88">
21372 <title>Use of standard output and error by Perl</title>
21373 <para>
21374 <indexterm role="concept">
21375 <primary>Perl</primary>
21376 <secondary>standard output and error</secondary>
21377 </indexterm>
21378 You should not write to the standard error or output streams from within your
21379 Perl code, as it is not defined how these are set up. In versions of Exim
21380 before 4.50, it is possible for the standard output or error to refer to the
21381 SMTP connection during message reception via the daemon. Writing to this stream
21382 is certain to cause chaos. From Exim 4.50 onwards, the standard output and
21383 error streams are connected to <filename>/dev/null</filename> in the daemon. The chaos is
21384 avoided, but the output is lost.
21385 </para>
21386 <para>
21387 <indexterm role="concept">
21388 <primary>Perl</primary>
21389 <secondary>use of <option>warn</option></secondary>
21390 </indexterm>
21391 The Perl <option>warn</option> statement writes to the standard error stream by default.
21392 Calls to <option>warn</option> may be embedded in Perl modules that you use, but over which
21393 you have no control. When Exim starts up the Perl interpreter, it arranges for
21394 output from the <option>warn</option> statement to be written to the Exim main log. You can
21395 change this by including appropriate Perl magic somewhere in your Perl code.
21396 For example, to discard <option>warn</option> output completely, you need this:
21397 </para>
21398 <literallayout class="monospaced">
21399 $SIG{__WARN__} = sub { };
21400 </literallayout>
21401 <para>
21402 Whenever a <option>warn</option> is obeyed, the anonymous subroutine is called. In this
21403 example, the code for the subroutine is empty, so it does nothing, but you can
21404 include any Perl code that you like. The text of the <option>warn</option> message is passed
21405 as the first subroutine argument.
21406 <indexterm role="concept" startref="IIDperl" class="endofrange"/>
21407 </para>
21408 </section>
21409 </chapter>
21410
21411 <chapter id="CHAPinterfaces">
21412 <title>Starting the daemon and the use of network interfaces</title>
21413 <titleabbrev>Starting the daemon</titleabbrev>
21414 <para>
21415 <indexterm role="concept">
21416 <primary>daemon</primary>
21417 <secondary>starting</secondary>
21418 </indexterm>
21419 <indexterm role="concept">
21420 <primary>interface</primary>
21421 <secondary>listening</secondary>
21422 </indexterm>
21423 <indexterm role="concept">
21424 <primary>network interface</primary>
21425 </indexterm>
21426 <indexterm role="concept">
21427 <primary>interface</primary>
21428 <secondary>network</secondary>
21429 </indexterm>
21430 <indexterm role="concept">
21431 <primary>IP address</primary>
21432 <secondary>for listening</secondary>
21433 </indexterm>
21434 <indexterm role="concept">
21435 <primary>daemon</primary>
21436 <secondary>listening IP addresses</secondary>
21437 </indexterm>
21438 <indexterm role="concept">
21439 <primary>TCP/IP</primary>
21440 <secondary>setting listening interfaces</secondary>
21441 </indexterm>
21442 <indexterm role="concept">
21443 <primary>TCP/IP</primary>
21444 <secondary>setting listening ports</secondary>
21445 </indexterm>
21446 A host that is connected to a TCP/IP network may have one or more physical
21447 hardware network interfaces. Each of these interfaces may be configured as one
21448 or more <quote>logical</quote> interfaces, which are the entities that a program actually
21449 works with. Each of these logical interfaces is associated with an IP address.
21450 In addition, TCP/IP software supports <quote>loopback</quote> interfaces (127.0.0.1 in
21451 IPv4 and ::1 in IPv6), which do not use any physical hardware. Exim requires
21452 knowledge about the host&#x2019;s interfaces for use in three different circumstances:
21453 </para>
21454 <orderedlist numeration="arabic">
21455 <listitem>
21456 <para>
21457 When a listening daemon is started, Exim needs to know which interfaces
21458 and ports to listen on.
21459 </para>
21460 </listitem>
21461 <listitem>
21462 <para>
21463 When Exim is routing an address, it needs to know which IP addresses
21464 are associated with local interfaces. This is required for the correct
21465 processing of MX lists by removing the local host and others with the
21466 same or higher priority values. Also, Exim needs to detect cases
21467 when an address is routed to an IP address that in fact belongs to the
21468 local host. Unless the <option>self</option> router option or the <option>allow_localhost</option>
21469 option of the smtp transport is set (as appropriate), this is treated
21470 as an error situation.
21471 </para>
21472 </listitem>
21473 <listitem>
21474 <para>
21475 When Exim connects to a remote host, it may need to know which interface to use
21476 for the outgoing connection.
21477 </para>
21478 </listitem>
21479 </orderedlist>
21480 <para>
21481 Exim&#x2019;s default behaviour is likely to be appropriate in the vast majority
21482 of cases. If your host has only one interface, and you want all its IP
21483 addresses to be treated in the same way, and you are using only the
21484 standard SMTP port, you should not need to take any special action. The
21485 rest of this chapter does not apply to you.
21486 </para>
21487 <para>
21488 In a more complicated situation you may want to listen only on certain
21489 interfaces, or on different ports, and for this reason there are a number of
21490 options that can be used to influence Exim&#x2019;s behaviour. The rest of this
21491 chapter describes how they operate.
21492 </para>
21493 <para>
21494 When a message is received over TCP/IP, the interface and port that were
21495 actually used are set in <varname>$received_ip_address</varname> and <varname>$received_port</varname>.
21496 </para>
21497 <section id="SECID89">
21498 <title>Starting a listening daemon</title>
21499 <para>
21500 When a listening daemon is started (by means of the <option>-bd</option> command line
21501 option), the interfaces and ports on which it listens are controlled by the
21502 following options:
21503 </para>
21504 <itemizedlist>
21505 <listitem>
21506 <para>
21507 <option>daemon_smtp_ports</option> contains a list of default ports
21508 or service names.
21509 (For backward compatibility, this option can also be specified in the singular.)
21510 </para>
21511 </listitem>
21512 <listitem>
21513 <para>
21514 <option>local_interfaces</option> contains list of interface IP addresses on which to
21515 listen. Each item may optionally also specify a port.
21516 </para>
21517 </listitem>
21518 </itemizedlist>
21519 <para>
21520 The default list separator in both cases is a colon, but this can be changed as
21521 described in section <xref linkend="SECTlistsepchange"/>. When IPv6 addresses are involved,
21522 it is usually best to change the separator to avoid having to double all the
21523 colons. For example:
21524 </para>
21525 <literallayout class="monospaced">
21526 local_interfaces = &lt;; 127.0.0.1 ; \
21527                       192.168.23.65 ; \
21528                       ::1 ; \
21529                       3ffe:ffff:836f::fe86:a061
21530 </literallayout>
21531 <para>
21532 There are two different formats for specifying a port along with an IP address
21533 in <option>local_interfaces</option>:
21534 </para>
21535 <orderedlist numeration="arabic">
21536 <listitem>
21537 <para>
21538 The port is added onto the address with a dot separator. For example, to listen
21539 on port 1234 on two different IP addresses:
21540 </para>
21541 <literallayout class="monospaced">
21542 local_interfaces = &lt;; 192.168.23.65.1234 ; \
21543                       3ffe:ffff:836f::fe86:a061.1234
21544 </literallayout>
21545 </listitem>
21546 <listitem>
21547 <para>
21548 The IP address is enclosed in square brackets, and the port is added
21549 with a colon separator, for example:
21550 </para>
21551 <literallayout class="monospaced">
21552 local_interfaces = &lt;; [192.168.23.65]:1234 ; \
21553                       [3ffe:ffff:836f::fe86:a061]:1234
21554 </literallayout>
21555 </listitem>
21556 </orderedlist>
21557 <para>
21558 When a port is not specified, the value of <option>daemon_smtp_ports</option> is used. The
21559 default setting contains just one port:
21560 </para>
21561 <literallayout class="monospaced">
21562 daemon_smtp_ports = smtp
21563 </literallayout>
21564 <para>
21565 If more than one port is listed, each interface that does not have its own port
21566 specified listens on all of them. Ports that are listed in
21567 <option>daemon_smtp_ports</option> can be identified either by name (defined in
21568 <filename>/etc/services</filename>) or by number. However, when ports are given with individual
21569 IP addresses in <option>local_interfaces</option>, only numbers (not names) can be used.
21570 </para>
21571 </section>
21572 <section id="SECID90">
21573 <title>Special IP listening addresses</title>
21574 <para>
21575 The addresses 0.0.0.0 and ::0 are treated specially. They are interpreted
21576 as <quote>all IPv4 interfaces</quote> and <quote>all IPv6 interfaces</quote>, respectively. In each
21577 case, Exim tells the TCP/IP stack to <quote>listen on all IPv<emphasis>x</emphasis> interfaces</quote>
21578 instead of setting up separate listening sockets for each interface. The
21579 default value of <option>local_interfaces</option> is
21580 </para>
21581 <literallayout class="monospaced">
21582 local_interfaces = 0.0.0.0
21583 </literallayout>
21584 <para>
21585 when Exim is built without IPv6 support; otherwise it is:
21586 </para>
21587 <literallayout class="monospaced">
21588 local_interfaces = &lt;; ::0 ; 0.0.0.0
21589 </literallayout>
21590 <para>
21591 Thus, by default, Exim listens on all available interfaces, on the SMTP port.
21592 </para>
21593 </section>
21594 <section id="SECID91">
21595 <title>Overriding local_interfaces and daemon_smtp_ports</title>
21596 <para>
21597 The <option>-oX</option> command line option can be used to override the values of
21598 <option>daemon_smtp_ports</option> and/or <option>local_interfaces</option> for a particular daemon
21599 instance. Another way of doing this would be to use macros and the <option>-D</option>
21600 option. However, <option>-oX</option> can be used by any admin user, whereas modification of
21601 the runtime configuration by <option>-D</option> is allowed only when the caller is root or
21602 exim.
21603 </para>
21604 <para>
21605 The value of <option>-oX</option> is a list of items. The default colon separator can be
21606 changed in the usual way (<xref linkend="SECTlistsepchange"/>) if required.
21607 If there are any items that do not
21608 contain dots or colons (that is, are not IP addresses), the value of
21609 <option>daemon_smtp_ports</option> is replaced by the list of those items. If there are any
21610 items that do contain dots or colons, the value of <option>local_interfaces</option> is
21611 replaced by those items. Thus, for example,
21612 </para>
21613 <literallayout class="monospaced">
21614 -oX 1225
21615 </literallayout>
21616 <para>
21617 overrides <option>daemon_smtp_ports</option>, but leaves <option>local_interfaces</option> unchanged,
21618 whereas
21619 </para>
21620 <literallayout class="monospaced">
21621 -oX 192.168.34.5.1125
21622 </literallayout>
21623 <para>
21624 overrides <option>local_interfaces</option>, leaving <option>daemon_smtp_ports</option> unchanged.
21625 (However, since <option>local_interfaces</option> now contains no items without ports, the
21626 value of <option>daemon_smtp_ports</option> is no longer relevant in this example.)
21627 </para>
21628 </section>
21629 <section id="SECTsupobssmt">
21630 <title>Support for the submissions (aka SSMTP or SMTPS) protocol</title>
21631 <para>
21632 <indexterm role="concept">
21633 <primary>submissions protocol</primary>
21634 </indexterm>
21635 <indexterm role="concept">
21636 <primary>ssmtp protocol</primary>
21637 </indexterm>
21638 <indexterm role="concept">
21639 <primary>smtps protocol</primary>
21640 </indexterm>
21641 <indexterm role="concept">
21642 <primary>SMTP</primary>
21643 <secondary>ssmtp protocol</secondary>
21644 </indexterm>
21645 <indexterm role="concept">
21646 <primary>SMTP</primary>
21647 <secondary>smtps protocol</secondary>
21648 </indexterm>
21649 Exim supports the use of TLS-on-connect, used by mail clients in the
21650 <quote>submissions</quote> protocol, historically also known as SMTPS or SSMTP.
21651 For some years, IETF Standards Track documents only blessed the
21652 STARTTLS-based Submission service (port 587) while common practice was to support
21653 the same feature set on port 465, but using TLS-on-connect.
21654 If your installation needs to provide service to mail clients
21655 (Mail User Agents, MUAs) then you should provide service on both the 587 and
21656 the 465 TCP ports.
21657 </para>
21658 <para>
21659 If the <option>tls_on_connect_ports</option> option is set to a list of port numbers or
21660 service names, connections to those ports must first establish TLS, before
21661 proceeding to the application layer use of the SMTP protocol.
21662 </para>
21663 <para>
21664 The common use of this option is expected to be
21665 </para>
21666 <literallayout class="monospaced">
21667 tls_on_connect_ports = 465
21668 </literallayout>
21669 <para>
21670 per RFC 8314.
21671 There is also a command line option <option>-tls-on-connect</option>, which forces all ports
21672 to behave in this way when a daemon is started.
21673 </para>
21674 <para>
21675 <emphasis role="bold">Warning</emphasis>: Setting <option>tls_on_connect_ports</option> does not of itself cause the
21676 daemon to listen on those ports. You must still specify them in
21677 <option>daemon_smtp_ports</option>, <option>local_interfaces</option>, or the <option>-oX</option> option. (This is
21678 because <option>tls_on_connect_ports</option> applies to <option>inetd</option> connections as well as to
21679 connections via the daemon.)
21680 </para>
21681 </section>
21682 <section id="SECID92">
21683 <title>IPv6 address scopes</title>
21684 <para>
21685 <indexterm role="concept">
21686 <primary>IPv6</primary>
21687 <secondary>address scopes</secondary>
21688 </indexterm>
21689 IPv6 addresses have <quote>scopes</quote>, and a host with multiple hardware interfaces
21690 can, in principle, have the same link-local IPv6 address on different
21691 interfaces. Thus, additional information is needed, over and above the IP
21692 address, to distinguish individual interfaces. A convention of using a
21693 percent sign followed by something (often the interface name) has been
21694 adopted in some cases, leading to addresses like this:
21695 </para>
21696 <literallayout class="monospaced">
21697 fe80::202:b3ff:fe03:45c1%eth0
21698 </literallayout>
21699 <para>
21700 To accommodate this usage, a percent sign followed by an arbitrary string is
21701 allowed at the end of an IPv6 address. By default, Exim calls <function>getaddrinfo()</function>
21702 to convert a textual IPv6 address for actual use. This function recognizes the
21703 percent convention in operating systems that support it, and it processes the
21704 address appropriately. Unfortunately, some older libraries have problems with
21705 <function>getaddrinfo()</function>. If
21706 </para>
21707 <literallayout class="monospaced">
21708 IPV6_USE_INET_PTON=yes
21709 </literallayout>
21710 <para>
21711 is set in <filename>Local/Makefile</filename> (or an OS-dependent Makefile) when Exim is built,
21712 Exim uses <emphasis>inet_pton()</emphasis> to convert a textual IPv6 address for actual use,
21713 instead of <function>getaddrinfo()</function>. (Before version 4.14, it always used this
21714 function.) Of course, this means that the additional functionality of
21715 <function>getaddrinfo()</function> &ndash; recognizing scoped addresses &ndash; is lost.
21716 </para>
21717 </section>
21718 <section id="SECID93">
21719 <title>Disabling IPv6</title>
21720 <para>
21721 <indexterm role="concept">
21722 <primary>IPv6</primary>
21723 <secondary>disabling</secondary>
21724 </indexterm>
21725 Sometimes it happens that an Exim binary that was compiled with IPv6 support is
21726 run on a host whose kernel does not support IPv6. The binary will fall back to
21727 using IPv4, but it may waste resources looking up AAAA records, and trying to
21728 connect to IPv6 addresses, causing delays to mail delivery. If you set the
21729 <indexterm role="option">
21730 <primary><option>disable_ipv6</option></primary>
21731 </indexterm>
21732 <option>disable_ipv6</option> option true, even if the Exim binary has IPv6 support, no IPv6
21733 activities take place. AAAA records are never looked up, and any IPv6 addresses
21734 that are listed in <option>local_interfaces</option>, data for the <command>manualroute</command> router,
21735 etc. are ignored. If IP literals are enabled, the <command>ipliteral</command> router declines
21736 to handle IPv6 literal addresses.
21737 </para>
21738 <para>
21739 On the other hand, when IPv6 is in use, there may be times when you want to
21740 disable it for certain hosts or domains. You can use the <option>dns_ipv4_lookup</option>
21741 option to globally suppress the lookup of AAAA records for specified domains,
21742 and you can use the <option>ignore_target_hosts</option> generic router option to ignore
21743 IPv6 addresses in an individual router.
21744 </para>
21745 </section>
21746 <section id="SECID94">
21747 <title>Examples of starting a listening daemon</title>
21748 <para>
21749 The default case in an IPv6 environment is
21750 </para>
21751 <literallayout class="monospaced">
21752 daemon_smtp_ports = smtp
21753 local_interfaces = &lt;; ::0 ; 0.0.0.0
21754 </literallayout>
21755 <para>
21756 This specifies listening on the smtp port on all IPv6 and IPv4 interfaces.
21757 Either one or two sockets may be used, depending on the characteristics of
21758 the TCP/IP stack. (This is complicated and messy; for more information,
21759 read the comments in the <filename>daemon.c</filename> source file.)
21760 </para>
21761 <para>
21762 To specify listening on ports 25 and 26 on all interfaces:
21763 </para>
21764 <literallayout class="monospaced">
21765 daemon_smtp_ports = 25 : 26
21766 </literallayout>
21767 <para>
21768 (leaving <option>local_interfaces</option> at the default setting) or, more explicitly:
21769 </para>
21770 <literallayout class="monospaced">
21771 local_interfaces = &lt;; ::0.25     ; ::0.26 \
21772                       0.0.0.0.25 ; 0.0.0.0.26
21773 </literallayout>
21774 <para>
21775 To listen on the default port on all IPv4 interfaces, and on port 26 on the
21776 IPv4 loopback address only:
21777 </para>
21778 <literallayout class="monospaced">
21779 local_interfaces = 0.0.0.0 : 127.0.0.1.26
21780 </literallayout>
21781 <para>
21782 To specify listening on the default port on specific interfaces only:
21783 </para>
21784 <literallayout class="monospaced">
21785 local_interfaces = 10.0.0.67 : 192.168.34.67
21786 </literallayout>
21787 <para>
21788 <emphasis role="bold">Warning</emphasis>: Such a setting excludes listening on the loopback interfaces.
21789 </para>
21790 </section>
21791 <section id="SECTreclocipadd">
21792 <title>Recognizing the local host</title>
21793 <para>
21794 The <option>local_interfaces</option> option is also used when Exim needs to determine
21795 whether or not an IP address refers to the local host. That is, the IP
21796 addresses of all the interfaces on which a daemon is listening are always
21797 treated as local.
21798 </para>
21799 <para>
21800 For this usage, port numbers in <option>local_interfaces</option> are ignored. If either of
21801 the items 0.0.0.0 or ::0 are encountered, Exim gets a complete list of
21802 available interfaces from the operating system, and extracts the relevant
21803 (that is, IPv4 or IPv6) addresses to use for checking.
21804 </para>
21805 <para>
21806 Some systems set up large numbers of virtual interfaces in order to provide
21807 many virtual web servers. In this situation, you may want to listen for
21808 email on only a few of the available interfaces, but nevertheless treat all
21809 interfaces as local when routing. You can do this by setting
21810 <option>extra_local_interfaces</option> to a list of IP addresses, possibly including the
21811 <quote>all</quote> wildcard values. These addresses are recognized as local, but are not
21812 used for listening. Consider this example:
21813 </para>
21814 <literallayout class="monospaced">
21815 local_interfaces = &lt;; 127.0.0.1 ; ::1 ; \
21816                       192.168.53.235 ; \
21817                       3ffe:2101:12:1:a00:20ff:fe86:a061
21818
21819 extra_local_interfaces = &lt;; ::0 ; 0.0.0.0
21820 </literallayout>
21821 <para>
21822 The daemon listens on the loopback interfaces and just one IPv4 and one IPv6
21823 address, but all available interface addresses are treated as local when
21824 Exim is routing.
21825 </para>
21826 <para>
21827 In some environments the local host name may be in an MX list, but with an IP
21828 address that is not assigned to any local interface. In other cases it may be
21829 desirable to treat other host names as if they referred to the local host. Both
21830 these cases can be handled by setting the <option>hosts_treat_as_local</option> option.
21831 This contains host names rather than IP addresses. When a host is referenced
21832 during routing, either via an MX record or directly, it is treated as the local
21833 host if its name matches <option>hosts_treat_as_local</option>, or if any of its IP
21834 addresses match <option>local_interfaces</option> or <option>extra_local_interfaces</option>.
21835 </para>
21836 </section>
21837 <section id="SECID95">
21838 <title>Delivering to a remote host</title>
21839 <para>
21840 Delivery to a remote host is handled by the smtp transport. By default, it
21841 allows the system&#x2019;s TCP/IP functions to choose which interface to use (if
21842 there is more than one) when connecting to a remote host. However, the
21843 <option>interface</option> option can be set to specify which interface is used. See the
21844 description of the smtp transport in chapter <xref linkend="CHAPsmtptrans"/> for more
21845 details.
21846 </para>
21847 </section>
21848 </chapter>
21849
21850 <chapter id="CHAPmainconfig">
21851 <title>Main configuration</title>
21852 <para>
21853 <indexterm role="concept" id="IIDconfima" class="startofrange">
21854 <primary>configuration file</primary>
21855 <secondary>main section</secondary>
21856 </indexterm>
21857 <indexterm role="concept" id="IIDmaiconf" class="startofrange">
21858 <primary>main configuration</primary>
21859 </indexterm>
21860 The first part of the runtime configuration file contains three types of item:
21861 </para>
21862 <itemizedlist>
21863 <listitem>
21864 <para>
21865 Macro definitions: These lines start with an upper case letter. See section
21866 <xref linkend="SECTmacrodefs"/> for details of macro processing.
21867 </para>
21868 </listitem>
21869 <listitem>
21870 <para>
21871 Named list definitions: These lines start with one of the words <quote>domainlist</quote>,
21872 <quote>hostlist</quote>, <quote>addresslist</quote>, or <quote>localpartlist</quote>. Their use is described in
21873 section <xref linkend="SECTnamedlists"/>.
21874 </para>
21875 </listitem>
21876 <listitem>
21877 <para>
21878 Main configuration settings: Each setting occupies one line of the file
21879 (with possible continuations). If any setting is preceded by the word
21880 <quote>hide</quote>, the <option>-bP</option> command line option displays its value to admin users
21881 only. See section <xref linkend="SECTcos"/> for a description of the syntax of these option
21882 settings.
21883 </para>
21884 </listitem>
21885 </itemizedlist>
21886 <para>
21887 This chapter specifies all the main configuration options, along with their
21888 types and default values. For ease of finding a particular option, they appear
21889 in alphabetical order in section <xref linkend="SECTalomo"/> below. However, because there
21890 are now so many options, they are first listed briefly in functional groups, as
21891 an aid to finding the name of the option you are looking for. Some options are
21892 listed in more than one group.
21893 </para>
21894 <section id="SECID96">
21895 <title>Miscellaneous</title>
21896 <informaltable frame="none">
21897 <tgroup cols="2" colsep="0" rowsep="0">
21898 <colspec colwidth="196pt" align="left"/>
21899 <colspec colwidth="254pt" align="left"/>
21900 <tbody>
21901 <row>
21902 <entry><option>bi_command</option></entry>
21903 <entry>to run for <option>-bi</option> command line option</entry>
21904 </row>
21905 <row>
21906 <entry><option>debug_store</option></entry>
21907 <entry>do extra internal checks</entry>
21908 </row>
21909 <row>
21910 <entry><option>disable_ipv6</option></entry>
21911 <entry>do no IPv6 processing</entry>
21912 </row>
21913 <row>
21914 <entry><option>keep_malformed</option></entry>
21915 <entry>for broken files &ndash; should not happen</entry>
21916 </row>
21917 <row>
21918 <entry><option>localhost_number</option></entry>
21919 <entry>for unique message ids in clusters</entry>
21920 </row>
21921 <row>
21922 <entry><option>message_body_newlines</option></entry>
21923 <entry>retain newlines in <varname>$message_body</varname></entry>
21924 </row>
21925 <row>
21926 <entry><option>message_body_visible</option></entry>
21927 <entry>how much to show in <varname>$message_body</varname></entry>
21928 </row>
21929 <row>
21930 <entry><option>mua_wrapper</option></entry>
21931 <entry>run in <quote>MUA wrapper</quote> mode</entry>
21932 </row>
21933 <row>
21934 <entry><option>print_topbitchars</option></entry>
21935 <entry>top-bit characters are printing</entry>
21936 </row>
21937 <row>
21938 <entry><option>spool_wireformat</option></entry>
21939 <entry>use wire-format spool data files when possible</entry>
21940 </row>
21941 <row>
21942 <entry><option>timezone</option></entry>
21943 <entry>force time zone</entry>
21944 </row>
21945 </tbody>
21946 </tgroup>
21947 </informaltable>
21948 </section>
21949 <section id="SECID97">
21950 <title>Exim parameters</title>
21951 <informaltable frame="none">
21952 <tgroup cols="2" colsep="0" rowsep="0">
21953 <colspec colwidth="196pt" align="left"/>
21954 <colspec colwidth="254pt" align="left"/>
21955 <tbody>
21956 <row>
21957 <entry><option>exim_group</option></entry>
21958 <entry>override compiled-in value</entry>
21959 </row>
21960 <row>
21961 <entry><option>exim_path</option></entry>
21962 <entry>override compiled-in value</entry>
21963 </row>
21964 <row>
21965 <entry><option>exim_user</option></entry>
21966 <entry>override compiled-in value</entry>
21967 </row>
21968 <row>
21969 <entry><option>primary_hostname</option></entry>
21970 <entry>default from <function>uname()</function></entry>
21971 </row>
21972 <row>
21973 <entry><option>split_spool_directory</option></entry>
21974 <entry>use multiple directories</entry>
21975 </row>
21976 <row>
21977 <entry><option>spool_directory</option></entry>
21978 <entry>override compiled-in value</entry>
21979 </row>
21980 </tbody>
21981 </tgroup>
21982 </informaltable>
21983 </section>
21984 <section id="SECID98">
21985 <title>Privilege controls</title>
21986 <informaltable frame="none">
21987 <tgroup cols="2" colsep="0" rowsep="0">
21988 <colspec colwidth="196pt" align="left"/>
21989 <colspec colwidth="254pt" align="left"/>
21990 <tbody>
21991 <row>
21992 <entry><option>admin_groups</option></entry>
21993 <entry>groups that are Exim admin users</entry>
21994 </row>
21995 <row>
21996 <entry><option>commandline_checks_require_admin</option></entry>
21997 <entry>require admin for various checks</entry>
21998 </row>
21999 <row>
22000 <entry><option>deliver_drop_privilege</option></entry>
22001 <entry>drop root for delivery processes</entry>
22002 </row>
22003 <row>
22004 <entry><option>local_from_check</option></entry>
22005 <entry>insert <emphasis>Sender:</emphasis> if necessary</entry>
22006 </row>
22007 <row>
22008 <entry><option>local_from_prefix</option></entry>
22009 <entry>for testing <emphasis>From:</emphasis> for local sender</entry>
22010 </row>
22011 <row>
22012 <entry><option>local_from_suffix</option></entry>
22013 <entry>for testing <emphasis>From:</emphasis> for local sender</entry>
22014 </row>
22015 <row>
22016 <entry><option>local_sender_retain</option></entry>
22017 <entry>keep <emphasis>Sender:</emphasis> from untrusted user</entry>
22018 </row>
22019 <row>
22020 <entry><option>never_users</option></entry>
22021 <entry>do not run deliveries as these</entry>
22022 </row>
22023 <row>
22024 <entry><option>prod_requires_admin</option></entry>
22025 <entry>forced delivery requires admin user</entry>
22026 </row>
22027 <row>
22028 <entry><option>queue_list_requires_admin</option></entry>
22029 <entry>queue listing requires admin user</entry>
22030 </row>
22031 <row>
22032 <entry><option>trusted_groups</option></entry>
22033 <entry>groups that are trusted</entry>
22034 </row>
22035 <row>
22036 <entry><option>trusted_users</option></entry>
22037 <entry>users that are trusted</entry>
22038 </row>
22039 </tbody>
22040 </tgroup>
22041 </informaltable>
22042 </section>
22043 <section id="SECID99">
22044 <title>Logging</title>
22045 <informaltable frame="none">
22046 <tgroup cols="2" colsep="0" rowsep="0">
22047 <colspec colwidth="196pt" align="left"/>
22048 <colspec colwidth="254pt" align="left"/>
22049 <tbody>
22050 <row>
22051 <entry><option>event_action</option></entry>
22052 <entry>custom logging</entry>
22053 </row>
22054 <row>
22055 <entry><option>hosts_connection_nolog</option></entry>
22056 <entry>exemption from connect logging</entry>
22057 </row>
22058 <row>
22059 <entry><option>log_file_path</option></entry>
22060 <entry>override compiled-in value</entry>
22061 </row>
22062 <row>
22063 <entry><option>log_selector</option></entry>
22064 <entry>set/unset optional logging</entry>
22065 </row>
22066 <row>
22067 <entry><option>log_timezone</option></entry>
22068 <entry>add timezone to log lines</entry>
22069 </row>
22070 <row>
22071 <entry><option>message_logs</option></entry>
22072 <entry>create per-message logs</entry>
22073 </row>
22074 <row>
22075 <entry><option>preserve_message_logs</option></entry>
22076 <entry>after message completion</entry>
22077 </row>
22078 <row>
22079 <entry><option>process_log_path</option></entry>
22080 <entry>for SIGUSR1 and <emphasis>exiwhat</emphasis></entry>
22081 </row>
22082 <row>
22083 <entry><option>slow_lookup_log</option></entry>
22084 <entry>control logging of slow DNS lookups</entry>
22085 </row>
22086 <row>
22087 <entry><option>syslog_duplication</option></entry>
22088 <entry>controls duplicate log lines on syslog</entry>
22089 </row>
22090 <row>
22091 <entry><option>syslog_facility</option></entry>
22092 <entry>set syslog <quote>facility</quote> field</entry>
22093 </row>
22094 <row>
22095 <entry><option>syslog_pid</option></entry>
22096 <entry>pid in syslog lines</entry>
22097 </row>
22098 <row>
22099 <entry><option>syslog_processname</option></entry>
22100 <entry>set syslog <quote>ident</quote> field</entry>
22101 </row>
22102 <row>
22103 <entry><option>syslog_timestamp</option></entry>
22104 <entry>timestamp syslog lines</entry>
22105 </row>
22106 <row>
22107 <entry><option>write_rejectlog</option></entry>
22108 <entry>control use of message log</entry>
22109 </row>
22110 </tbody>
22111 </tgroup>
22112 </informaltable>
22113 </section>
22114 <section id="SECID100">
22115 <title>Frozen messages</title>
22116 <informaltable frame="none">
22117 <tgroup cols="2" colsep="0" rowsep="0">
22118 <colspec colwidth="196pt" align="left"/>
22119 <colspec colwidth="254pt" align="left"/>
22120 <tbody>
22121 <row>
22122 <entry><option>auto_thaw</option></entry>
22123 <entry>sets time for retrying frozen messages</entry>
22124 </row>
22125 <row>
22126 <entry><option>freeze_tell</option></entry>
22127 <entry>send message when freezing</entry>
22128 </row>
22129 <row>
22130 <entry><option>move_frozen_messages</option></entry>
22131 <entry>to another directory</entry>
22132 </row>
22133 <row>
22134 <entry><option>timeout_frozen_after</option></entry>
22135 <entry>keep frozen messages only so long</entry>
22136 </row>
22137 </tbody>
22138 </tgroup>
22139 </informaltable>
22140 </section>
22141 <section id="SECID101">
22142 <title>Data lookups</title>
22143 <informaltable frame="none">
22144 <tgroup cols="2" colsep="0" rowsep="0">
22145 <colspec colwidth="196pt" align="left"/>
22146 <colspec colwidth="254pt" align="left"/>
22147 <tbody>
22148 <row>
22149 <entry><option>ibase_servers</option></entry>
22150 <entry>InterBase servers</entry>
22151 </row>
22152 <row>
22153 <entry><option>ldap_ca_cert_dir</option></entry>
22154 <entry>dir of CA certs to verify LDAP server&#x2019;s</entry>
22155 </row>
22156 <row>
22157 <entry><option>ldap_ca_cert_file</option></entry>
22158 <entry>file of CA certs to verify LDAP server&#x2019;s</entry>
22159 </row>
22160 <row>
22161 <entry><option>ldap_cert_file</option></entry>
22162 <entry>client cert file for LDAP</entry>
22163 </row>
22164 <row>
22165 <entry><option>ldap_cert_key</option></entry>
22166 <entry>client key file for LDAP</entry>
22167 </row>
22168 <row>
22169 <entry><option>ldap_cipher_suite</option></entry>
22170 <entry>TLS negotiation preference control</entry>
22171 </row>
22172 <row>
22173 <entry><option>ldap_default_servers</option></entry>
22174 <entry>used if no server in query</entry>
22175 </row>
22176 <row>
22177 <entry><option>ldap_require_cert</option></entry>
22178 <entry>action to take without LDAP server cert</entry>
22179 </row>
22180 <row>
22181 <entry><option>ldap_start_tls</option></entry>
22182 <entry>require TLS within LDAP</entry>
22183 </row>
22184 <row>
22185 <entry><option>ldap_version</option></entry>
22186 <entry>set protocol version</entry>
22187 </row>
22188 <row>
22189 <entry><option>lookup_open_max</option></entry>
22190 <entry>lookup files held open</entry>
22191 </row>
22192 <row>
22193 <entry><option>mysql_servers</option></entry>
22194 <entry>default MySQL servers</entry>
22195 </row>
22196 <row>
22197 <entry><option>oracle_servers</option></entry>
22198 <entry>Oracle servers</entry>
22199 </row>
22200 <row>
22201 <entry><option>pgsql_servers</option></entry>
22202 <entry>default PostgreSQL servers</entry>
22203 </row>
22204 <row>
22205 <entry><option>sqlite_lock_timeout</option></entry>
22206 <entry>as it says</entry>
22207 </row>
22208 </tbody>
22209 </tgroup>
22210 </informaltable>
22211 </section>
22212 <section id="SECID102">
22213 <title>Message ids</title>
22214 <informaltable frame="none">
22215 <tgroup cols="2" colsep="0" rowsep="0">
22216 <colspec colwidth="196pt" align="left"/>
22217 <colspec colwidth="254pt" align="left"/>
22218 <tbody>
22219 <row>
22220 <entry><option>message_id_header_domain</option></entry>
22221 <entry>used to build <emphasis>Message-ID:</emphasis> header</entry>
22222 </row>
22223 <row>
22224 <entry><option>message_id_header_text</option></entry>
22225 <entry>ditto</entry>
22226 </row>
22227 </tbody>
22228 </tgroup>
22229 </informaltable>
22230 </section>
22231 <section id="SECID103">
22232 <title>Embedded Perl Startup</title>
22233 <informaltable frame="none">
22234 <tgroup cols="2" colsep="0" rowsep="0">
22235 <colspec colwidth="196pt" align="left"/>
22236 <colspec colwidth="254pt" align="left"/>
22237 <tbody>
22238 <row>
22239 <entry><option>perl_at_start</option></entry>
22240 <entry>always start the interpreter</entry>
22241 </row>
22242 <row>
22243 <entry><option>perl_startup</option></entry>
22244 <entry>code to obey when starting Perl</entry>
22245 </row>
22246 <row>
22247 <entry><option>perl_taintmode</option></entry>
22248 <entry>enable taint mode in Perl</entry>
22249 </row>
22250 </tbody>
22251 </tgroup>
22252 </informaltable>
22253 </section>
22254 <section id="SECID104">
22255 <title>Daemon</title>
22256 <informaltable frame="none">
22257 <tgroup cols="2" colsep="0" rowsep="0">
22258 <colspec colwidth="196pt" align="left"/>
22259 <colspec colwidth="254pt" align="left"/>
22260 <tbody>
22261 <row>
22262 <entry><option>daemon_smtp_ports</option></entry>
22263 <entry>default ports</entry>
22264 </row>
22265 <row>
22266 <entry><option>daemon_startup_retries</option></entry>
22267 <entry>number of times to retry</entry>
22268 </row>
22269 <row>
22270 <entry><option>daemon_startup_sleep</option></entry>
22271 <entry>time to sleep between tries</entry>
22272 </row>
22273 <row>
22274 <entry><option>extra_local_interfaces</option></entry>
22275 <entry>not necessarily listened on</entry>
22276 </row>
22277 <row>
22278 <entry><option>local_interfaces</option></entry>
22279 <entry>on which to listen, with optional ports</entry>
22280 </row>
22281 <row>
22282 <entry><option>pid_file_path</option></entry>
22283 <entry>override compiled-in value</entry>
22284 </row>
22285 <row>
22286 <entry><option>queue_run_max</option></entry>
22287 <entry>maximum simultaneous queue runners</entry>
22288 </row>
22289 </tbody>
22290 </tgroup>
22291 </informaltable>
22292 </section>
22293 <section id="SECID105">
22294 <title>Resource control</title>
22295 <informaltable frame="none">
22296 <tgroup cols="2" colsep="0" rowsep="0">
22297 <colspec colwidth="196pt" align="left"/>
22298 <colspec colwidth="254pt" align="left"/>
22299 <tbody>
22300 <row>
22301 <entry><option>check_log_inodes</option></entry>
22302 <entry>before accepting a message</entry>
22303 </row>
22304 <row>
22305 <entry><option>check_log_space</option></entry>
22306 <entry>before accepting a message</entry>
22307 </row>
22308 <row>
22309 <entry><option>check_spool_inodes</option></entry>
22310 <entry>before accepting a message</entry>
22311 </row>
22312 <row>
22313 <entry><option>check_spool_space</option></entry>
22314 <entry>before accepting a message</entry>
22315 </row>
22316 <row>
22317 <entry><option>deliver_queue_load_max</option></entry>
22318 <entry>no queue deliveries if load high</entry>
22319 </row>
22320 <row>
22321 <entry><option>queue_only_load</option></entry>
22322 <entry>queue incoming if load high</entry>
22323 </row>
22324 <row>
22325 <entry><option>queue_only_load_latch</option></entry>
22326 <entry>don&#x2019;t re-evaluate load for each message</entry>
22327 </row>
22328 <row>
22329 <entry><option>queue_run_max</option></entry>
22330 <entry>maximum simultaneous queue runners</entry>
22331 </row>
22332 <row>
22333 <entry><option>remote_max_parallel</option></entry>
22334 <entry>parallel SMTP delivery per message</entry>
22335 </row>
22336 <row>
22337 <entry><option>smtp_accept_max</option></entry>
22338 <entry>simultaneous incoming connections</entry>
22339 </row>
22340 <row>
22341 <entry><option>smtp_accept_max_nonmail</option></entry>
22342 <entry>non-mail commands</entry>
22343 </row>
22344 <row>
22345 <entry><option>smtp_accept_max_nonmail_hosts</option></entry>
22346 <entry>hosts to which the limit applies</entry>
22347 </row>
22348 <row>
22349 <entry><option>smtp_accept_max_per_connection</option></entry>
22350 <entry>messages per connection</entry>
22351 </row>
22352 <row>
22353 <entry><option>smtp_accept_max_per_host</option></entry>
22354 <entry>connections from one host</entry>
22355 </row>
22356 <row>
22357 <entry><option>smtp_accept_queue</option></entry>
22358 <entry>queue mail if more connections</entry>
22359 </row>
22360 <row>
22361 <entry><option>smtp_accept_queue_per_connection</option></entry>
22362 <entry>queue if more messages per connection</entry>
22363 </row>
22364 <row>
22365 <entry><option>smtp_accept_reserve</option></entry>
22366 <entry>only reserve hosts if more connections</entry>
22367 </row>
22368 <row>
22369 <entry><option>smtp_check_spool_space</option></entry>
22370 <entry>from SIZE on MAIL command</entry>
22371 </row>
22372 <row>
22373 <entry><option>smtp_connect_backlog</option></entry>
22374 <entry>passed to TCP/IP stack</entry>
22375 </row>
22376 <row>
22377 <entry><option>smtp_load_reserve</option></entry>
22378 <entry>SMTP from reserved hosts if load high</entry>
22379 </row>
22380 <row>
22381 <entry><option>smtp_reserve_hosts</option></entry>
22382 <entry>these are the reserve hosts</entry>
22383 </row>
22384 </tbody>
22385 </tgroup>
22386 </informaltable>
22387 </section>
22388 <section id="SECID106">
22389 <title>Policy controls</title>
22390 <informaltable frame="none">
22391 <tgroup cols="2" colsep="0" rowsep="0">
22392 <colspec colwidth="196pt" align="left"/>
22393 <colspec colwidth="254pt" align="left"/>
22394 <tbody>
22395 <row>
22396 <entry><option>acl_not_smtp</option></entry>
22397 <entry>ACL for non-SMTP messages</entry>
22398 </row>
22399 <row>
22400 <entry><option>acl_not_smtp_mime</option></entry>
22401 <entry>ACL for non-SMTP MIME parts</entry>
22402 </row>
22403 <row>
22404 <entry><option>acl_not_smtp_start</option></entry>
22405 <entry>ACL for start of non-SMTP message</entry>
22406 </row>
22407 <row>
22408 <entry><option>acl_smtp_auth</option></entry>
22409 <entry>ACL for AUTH</entry>
22410 </row>
22411 <row>
22412 <entry><option>acl_smtp_connect</option></entry>
22413 <entry>ACL for connection</entry>
22414 </row>
22415 <row>
22416 <entry><option>acl_smtp_data</option></entry>
22417 <entry>ACL for DATA</entry>
22418 </row>
22419 <row>
22420 <entry><option>acl_smtp_data_prdr</option></entry>
22421 <entry>ACL for DATA, per-recipient</entry>
22422 </row>
22423 <row>
22424 <entry><option>acl_smtp_dkim</option></entry>
22425 <entry>ACL for DKIM verification</entry>
22426 </row>
22427 <row>
22428 <entry><option>acl_smtp_etrn</option></entry>
22429 <entry>ACL for ETRN</entry>
22430 </row>
22431 <row>
22432 <entry><option>acl_smtp_expn</option></entry>
22433 <entry>ACL for EXPN</entry>
22434 </row>
22435 <row>
22436 <entry><option>acl_smtp_helo</option></entry>
22437 <entry>ACL for EHLO or HELO</entry>
22438 </row>
22439 <row>
22440 <entry><option>acl_smtp_mail</option></entry>
22441 <entry>ACL for MAIL</entry>
22442 </row>
22443 <row>
22444 <entry><option>acl_smtp_mailauth</option></entry>
22445 <entry>ACL for AUTH on MAIL command</entry>
22446 </row>
22447 <row>
22448 <entry><option>acl_smtp_mime</option></entry>
22449 <entry>ACL for MIME parts</entry>
22450 </row>
22451 <row>
22452 <entry><option>acl_smtp_notquit</option></entry>
22453 <entry>ACL for non-QUIT terminations</entry>
22454 </row>
22455 <row>
22456 <entry><option>acl_smtp_predata</option></entry>
22457 <entry>ACL for start of data</entry>
22458 </row>
22459 <row>
22460 <entry><option>acl_smtp_quit</option></entry>
22461 <entry>ACL for QUIT</entry>
22462 </row>
22463 <row>
22464 <entry><option>acl_smtp_rcpt</option></entry>
22465 <entry>ACL for RCPT</entry>
22466 </row>
22467 <row>
22468 <entry><option>acl_smtp_starttls</option></entry>
22469 <entry>ACL for STARTTLS</entry>
22470 </row>
22471 <row>
22472 <entry><option>acl_smtp_vrfy</option></entry>
22473 <entry>ACL for VRFY</entry>
22474 </row>
22475 <row>
22476 <entry><option>av_scanner</option></entry>
22477 <entry>specify virus scanner</entry>
22478 </row>
22479 <row>
22480 <entry><option>check_rfc2047_length</option></entry>
22481 <entry>check length of RFC 2047 <quote>encoded words</quote></entry>
22482 </row>
22483 <row>
22484 <entry><option>dns_cname_loops</option></entry>
22485 <entry>follow CNAMEs returned by resolver</entry>
22486 </row>
22487 <row>
22488 <entry><option>dns_csa_search_limit</option></entry>
22489 <entry>control CSA parent search depth</entry>
22490 </row>
22491 <row>
22492 <entry><option>dns_csa_use_reverse</option></entry>
22493 <entry>en/disable CSA IP reverse search</entry>
22494 </row>
22495 <row>
22496 <entry><option>header_maxsize</option></entry>
22497 <entry>total size of message header</entry>
22498 </row>
22499 <row>
22500 <entry><option>header_line_maxsize</option></entry>
22501 <entry>individual header line limit</entry>
22502 </row>
22503 <row>
22504 <entry><option>helo_accept_junk_hosts</option></entry>
22505 <entry>allow syntactic junk from these hosts</entry>
22506 </row>
22507 <row>
22508 <entry><option>helo_allow_chars</option></entry>
22509 <entry>allow illegal chars in HELO names</entry>
22510 </row>
22511 <row>
22512 <entry><option>helo_lookup_domains</option></entry>
22513 <entry>lookup hostname for these HELO names</entry>
22514 </row>
22515 <row>
22516 <entry><option>helo_try_verify_hosts</option></entry>
22517 <entry>HELO soft-checked for these hosts</entry>
22518 </row>
22519 <row>
22520 <entry><option>helo_verify_hosts</option></entry>
22521 <entry>HELO hard-checked for these hosts</entry>
22522 </row>
22523 <row>
22524 <entry><option>host_lookup</option></entry>
22525 <entry>host name looked up for these hosts</entry>
22526 </row>
22527 <row>
22528 <entry><option>host_lookup_order</option></entry>
22529 <entry>order of DNS and local name lookups</entry>
22530 </row>
22531 <row>
22532 <entry><option>hosts_proxy</option></entry>
22533 <entry>use proxy protocol for these hosts</entry>
22534 </row>
22535 <row>
22536 <entry><option>host_reject_connection</option></entry>
22537 <entry>reject connection from these hosts</entry>
22538 </row>
22539 <row>
22540 <entry><option>hosts_treat_as_local</option></entry>
22541 <entry>useful in some cluster configurations</entry>
22542 </row>
22543 <row>
22544 <entry><option>local_scan_timeout</option></entry>
22545 <entry>timeout for <function>local_scan()</function></entry>
22546 </row>
22547 <row>
22548 <entry><option>message_size_limit</option></entry>
22549 <entry>for all messages</entry>
22550 </row>
22551 <row>
22552 <entry><option>percent_hack_domains</option></entry>
22553 <entry>recognize %-hack for these domains</entry>
22554 </row>
22555 <row>
22556 <entry><option>spamd_address</option></entry>
22557 <entry>set interface to SpamAssassin</entry>
22558 </row>
22559 <row>
22560 <entry><option>strict_acl_vars</option></entry>
22561 <entry>object to unset ACL variables</entry>
22562 </row>
22563 </tbody>
22564 </tgroup>
22565 </informaltable>
22566 </section>
22567 <section id="SECID107">
22568 <title>Callout cache</title>
22569 <informaltable frame="none">
22570 <tgroup cols="2" colsep="0" rowsep="0">
22571 <colspec colwidth="196pt" align="left"/>
22572 <colspec colwidth="254pt" align="left"/>
22573 <tbody>
22574 <row>
22575 <entry><option>callout_domain_negative_expire</option></entry>
22576 <entry>timeout for negative domain cache item</entry>
22577 </row>
22578 <row>
22579 <entry><option>callout_domain_positive_expire</option></entry>
22580 <entry>timeout for positive domain cache item</entry>
22581 </row>
22582 <row>
22583 <entry><option>callout_negative_expire</option></entry>
22584 <entry>timeout for negative address cache item</entry>
22585 </row>
22586 <row>
22587 <entry><option>callout_positive_expire</option></entry>
22588 <entry>timeout for positive address cache item</entry>
22589 </row>
22590 <row>
22591 <entry><option>callout_random_local_part</option></entry>
22592 <entry>string to use for <quote>random</quote> testing</entry>
22593 </row>
22594 </tbody>
22595 </tgroup>
22596 </informaltable>
22597 </section>
22598 <section id="SECID108">
22599 <title>TLS</title>
22600 <informaltable frame="none">
22601 <tgroup cols="2" colsep="0" rowsep="0">
22602 <colspec colwidth="196pt" align="left"/>
22603 <colspec colwidth="254pt" align="left"/>
22604 <tbody>
22605 <row>
22606 <entry><option>gnutls_compat_mode</option></entry>
22607 <entry>use GnuTLS compatibility mode</entry>
22608 </row>
22609 <row>
22610 <entry><option>gnutls_allow_auto_pkcs11</option></entry>
22611 <entry>allow GnuTLS to autoload PKCS11 modules</entry>
22612 </row>
22613 <row>
22614 <entry><option>openssl_options</option></entry>
22615 <entry>adjust OpenSSL compatibility options</entry>
22616 </row>
22617 <row>
22618 <entry><option>tls_advertise_hosts</option></entry>
22619 <entry>advertise TLS to these hosts</entry>
22620 </row>
22621 <row>
22622 <entry><option>tls_certificate</option></entry>
22623 <entry>location of server certificate</entry>
22624 </row>
22625 <row>
22626 <entry><option>tls_crl</option></entry>
22627 <entry>certificate revocation list</entry>
22628 </row>
22629 <row>
22630 <entry><option>tls_dh_max_bits</option></entry>
22631 <entry>clamp D-H bit count suggestion</entry>
22632 </row>
22633 <row>
22634 <entry><option>tls_dhparam</option></entry>
22635 <entry>DH parameters for server</entry>
22636 </row>
22637 <row>
22638 <entry><option>tls_eccurve</option></entry>
22639 <entry>EC curve selection for server</entry>
22640 </row>
22641 <row>
22642 <entry><option>tls_ocsp_file</option></entry>
22643 <entry>location of server certificate status proof</entry>
22644 </row>
22645 <row>
22646 <entry><option>tls_on_connect_ports</option></entry>
22647 <entry>specify SSMTP (SMTPS) ports</entry>
22648 </row>
22649 <row>
22650 <entry><option>tls_privatekey</option></entry>
22651 <entry>location of server private key</entry>
22652 </row>
22653 <row>
22654 <entry><option>tls_remember_esmtp</option></entry>
22655 <entry>don&#x2019;t reset after starting TLS</entry>
22656 </row>
22657 <row>
22658 <entry><option>tls_require_ciphers</option></entry>
22659 <entry>specify acceptable ciphers</entry>
22660 </row>
22661 <row>
22662 <entry><option>tls_try_verify_hosts</option></entry>
22663 <entry>try to verify client certificate</entry>
22664 </row>
22665 <row>
22666 <entry><option>tls_verify_certificates</option></entry>
22667 <entry>expected client certificates</entry>
22668 </row>
22669 <row>
22670 <entry><option>tls_verify_hosts</option></entry>
22671 <entry>insist on client certificate verify</entry>
22672 </row>
22673 </tbody>
22674 </tgroup>
22675 </informaltable>
22676 </section>
22677 <section id="SECID109">
22678 <title>Local user handling</title>
22679 <informaltable frame="none">
22680 <tgroup cols="2" colsep="0" rowsep="0">
22681 <colspec colwidth="196pt" align="left"/>
22682 <colspec colwidth="254pt" align="left"/>
22683 <tbody>
22684 <row>
22685 <entry><option>finduser_retries</option></entry>
22686 <entry>useful in NIS environments</entry>
22687 </row>
22688 <row>
22689 <entry><option>gecos_name</option></entry>
22690 <entry>used when creating <emphasis>Sender:</emphasis></entry>
22691 </row>
22692 <row>
22693 <entry><option>gecos_pattern</option></entry>
22694 <entry>ditto</entry>
22695 </row>
22696 <row>
22697 <entry><option>max_username_length</option></entry>
22698 <entry>for systems that truncate</entry>
22699 </row>
22700 <row>
22701 <entry><option>unknown_login</option></entry>
22702 <entry>used when no login name found</entry>
22703 </row>
22704 <row>
22705 <entry><option>unknown_username</option></entry>
22706 <entry>ditto</entry>
22707 </row>
22708 <row>
22709 <entry><option>uucp_from_pattern</option></entry>
22710 <entry>for recognizing <quote>From </quote> lines</entry>
22711 </row>
22712 <row>
22713 <entry><option>uucp_from_sender</option></entry>
22714 <entry>ditto</entry>
22715 </row>
22716 </tbody>
22717 </tgroup>
22718 </informaltable>
22719 </section>
22720 <section id="SECID110">
22721 <title>All incoming messages (SMTP and non-SMTP)</title>
22722 <informaltable frame="none">
22723 <tgroup cols="2" colsep="0" rowsep="0">
22724 <colspec colwidth="196pt" align="left"/>
22725 <colspec colwidth="254pt" align="left"/>
22726 <tbody>
22727 <row>
22728 <entry><option>header_maxsize</option></entry>
22729 <entry>total size of message header</entry>
22730 </row>
22731 <row>
22732 <entry><option>header_line_maxsize</option></entry>
22733 <entry>individual header line limit</entry>
22734 </row>
22735 <row>
22736 <entry><option>message_size_limit</option></entry>
22737 <entry>applies to all messages</entry>
22738 </row>
22739 <row>
22740 <entry><option>percent_hack_domains</option></entry>
22741 <entry>recognize %-hack for these domains</entry>
22742 </row>
22743 <row>
22744 <entry><option>received_header_text</option></entry>
22745 <entry>expanded to make <emphasis>Received:</emphasis></entry>
22746 </row>
22747 <row>
22748 <entry><option>received_headers_max</option></entry>
22749 <entry>for mail loop detection</entry>
22750 </row>
22751 <row>
22752 <entry><option>recipients_max</option></entry>
22753 <entry>limit per message</entry>
22754 </row>
22755 <row>
22756 <entry><option>recipients_max_reject</option></entry>
22757 <entry>permanently reject excess recipients</entry>
22758 </row>
22759 </tbody>
22760 </tgroup>
22761 </informaltable>
22762 </section>
22763 <section id="SECID111">
22764 <title>Non-SMTP incoming messages</title>
22765 <informaltable frame="none">
22766 <tgroup cols="2" colsep="0" rowsep="0">
22767 <colspec colwidth="196pt" align="left"/>
22768 <colspec colwidth="254pt" align="left"/>
22769 <tbody>
22770 <row>
22771 <entry><option>receive_timeout</option></entry>
22772 <entry>for non-SMTP messages</entry>
22773 </row>
22774 </tbody>
22775 </tgroup>
22776 </informaltable>
22777 </section>
22778 <section id="SECID112">
22779 <title>Incoming SMTP messages</title>
22780 <para>
22781 See also the <emphasis>Policy controls</emphasis> section above.
22782 </para>
22783 <informaltable frame="none">
22784 <tgroup cols="2" colsep="0" rowsep="0">
22785 <colspec colwidth="196pt" align="left"/>
22786 <colspec colwidth="254pt" align="left"/>
22787 <tbody>
22788 <row>
22789 <entry><option>dkim_verify_hashes</option></entry>
22790 <entry>DKIM hash methods accepted for signatures</entry>
22791 </row>
22792 <row>
22793 <entry><option>dkim_verify_keytypes</option></entry>
22794 <entry>DKIM key types accepted for signatures</entry>
22795 </row>
22796 <row>
22797 <entry><option>dkim_verify_signers</option></entry>
22798 <entry>DKIM domains for which DKIM ACL is run</entry>
22799 </row>
22800 <row>
22801 <entry><option>host_lookup</option></entry>
22802 <entry>host name looked up for these hosts</entry>
22803 </row>
22804 <row>
22805 <entry><option>host_lookup_order</option></entry>
22806 <entry>order of DNS and local name lookups</entry>
22807 </row>
22808 <row>
22809 <entry><option>recipient_unqualified_hosts</option></entry>
22810 <entry>may send unqualified recipients</entry>
22811 </row>
22812 <row>
22813 <entry><option>rfc1413_hosts</option></entry>
22814 <entry>make ident calls to these hosts</entry>
22815 </row>
22816 <row>
22817 <entry><option>rfc1413_query_timeout</option></entry>
22818 <entry>zero disables ident calls</entry>
22819 </row>
22820 <row>
22821 <entry><option>sender_unqualified_hosts</option></entry>
22822 <entry>may send unqualified senders</entry>
22823 </row>
22824 <row>
22825 <entry><option>smtp_accept_keepalive</option></entry>
22826 <entry>some TCP/IP magic</entry>
22827 </row>
22828 <row>
22829 <entry><option>smtp_accept_max</option></entry>
22830 <entry>simultaneous incoming connections</entry>
22831 </row>
22832 <row>
22833 <entry><option>smtp_accept_max_nonmail</option></entry>
22834 <entry>non-mail commands</entry>
22835 </row>
22836 <row>
22837 <entry><option>smtp_accept_max_nonmail_hosts</option></entry>
22838 <entry>hosts to which the limit applies</entry>
22839 </row>
22840 <row>
22841 <entry><option>smtp_accept_max_per_connection</option></entry>
22842 <entry>messages per connection</entry>
22843 </row>
22844 <row>
22845 <entry><option>smtp_accept_max_per_host</option></entry>
22846 <entry>connections from one host</entry>
22847 </row>
22848 <row>
22849 <entry><option>smtp_accept_queue</option></entry>
22850 <entry>queue mail if more connections</entry>
22851 </row>
22852 <row>
22853 <entry><option>smtp_accept_queue_per_connection</option></entry>
22854 <entry>queue if more messages per connection</entry>
22855 </row>
22856 <row>
22857 <entry><option>smtp_accept_reserve</option></entry>
22858 <entry>only reserve hosts if more connections</entry>
22859 </row>
22860 <row>
22861 <entry><option>smtp_active_hostname</option></entry>
22862 <entry>host name to use in messages</entry>
22863 </row>
22864 <row>
22865 <entry><option>smtp_banner</option></entry>
22866 <entry>text for welcome banner</entry>
22867 </row>
22868 <row>
22869 <entry><option>smtp_check_spool_space</option></entry>
22870 <entry>from SIZE on MAIL command</entry>
22871 </row>
22872 <row>
22873 <entry><option>smtp_connect_backlog</option></entry>
22874 <entry>passed to TCP/IP stack</entry>
22875 </row>
22876 <row>
22877 <entry><option>smtp_enforce_sync</option></entry>
22878 <entry>of SMTP command/responses</entry>
22879 </row>
22880 <row>
22881 <entry><option>smtp_etrn_command</option></entry>
22882 <entry>what to run for ETRN</entry>
22883 </row>
22884 <row>
22885 <entry><option>smtp_etrn_serialize</option></entry>
22886 <entry>only one at once</entry>
22887 </row>
22888 <row>
22889 <entry><option>smtp_load_reserve</option></entry>
22890 <entry>only reserve hosts if this load</entry>
22891 </row>
22892 <row>
22893 <entry><option>smtp_max_unknown_commands</option></entry>
22894 <entry>before dropping connection</entry>
22895 </row>
22896 <row>
22897 <entry><option>smtp_ratelimit_hosts</option></entry>
22898 <entry>apply ratelimiting to these hosts</entry>
22899 </row>
22900 <row>
22901 <entry><option>smtp_ratelimit_mail</option></entry>
22902 <entry>ratelimit for MAIL commands</entry>
22903 </row>
22904 <row>
22905 <entry><option>smtp_ratelimit_rcpt</option></entry>
22906 <entry>ratelimit for RCPT commands</entry>
22907 </row>
22908 <row>
22909 <entry><option>smtp_receive_timeout</option></entry>
22910 <entry>per command or data line</entry>
22911 </row>
22912 <row>
22913 <entry><option>smtp_reserve_hosts</option></entry>
22914 <entry>these are the reserve hosts</entry>
22915 </row>
22916 <row>
22917 <entry><option>smtp_return_error_details</option></entry>
22918 <entry>give detail on rejections</entry>
22919 </row>
22920 </tbody>
22921 </tgroup>
22922 </informaltable>
22923 </section>
22924 <section id="SECID113">
22925 <title>SMTP extensions</title>
22926 <informaltable frame="none">
22927 <tgroup cols="2" colsep="0" rowsep="0">
22928 <colspec colwidth="196pt" align="left"/>
22929 <colspec colwidth="254pt" align="left"/>
22930 <tbody>
22931 <row>
22932 <entry><option>accept_8bitmime</option></entry>
22933 <entry>advertise 8BITMIME</entry>
22934 </row>
22935 <row>
22936 <entry><option>auth_advertise_hosts</option></entry>
22937 <entry>advertise AUTH to these hosts</entry>
22938 </row>
22939 <row>
22940 <entry><option>chunking_advertise_hosts</option></entry>
22941 <entry>advertise CHUNKING to these hosts</entry>
22942 </row>
22943 <row>
22944 <entry><option>dsn_advertise_hosts</option></entry>
22945 <entry>advertise DSN extensions to these hosts</entry>
22946 </row>
22947 <row>
22948 <entry><option>ignore_fromline_hosts</option></entry>
22949 <entry>allow <quote>From </quote> from these hosts</entry>
22950 </row>
22951 <row>
22952 <entry><option>ignore_fromline_local</option></entry>
22953 <entry>allow <quote>From </quote> from local SMTP</entry>
22954 </row>
22955 <row>
22956 <entry><option>pipelining_advertise_hosts</option></entry>
22957 <entry>advertise pipelining to these hosts</entry>
22958 </row>
22959 <row>
22960 <entry><option>pipelining_connect_advertise_hosts</option></entry>
22961 <entry>advertise pipelining to these hosts</entry>
22962 </row>
22963 <row>
22964 <entry><option>prdr_enable</option></entry>
22965 <entry>advertise PRDR to all hosts</entry>
22966 </row>
22967 <row>
22968 <entry><option>smtputf8_advertise_hosts</option></entry>
22969 <entry>advertise SMTPUTF8 to these hosts</entry>
22970 </row>
22971 <row>
22972 <entry><option>tls_advertise_hosts</option></entry>
22973 <entry>advertise TLS to these hosts</entry>
22974 </row>
22975 </tbody>
22976 </tgroup>
22977 </informaltable>
22978 </section>
22979 <section id="SECID114">
22980 <title>Processing messages</title>
22981 <informaltable frame="none">
22982 <tgroup cols="2" colsep="0" rowsep="0">
22983 <colspec colwidth="196pt" align="left"/>
22984 <colspec colwidth="254pt" align="left"/>
22985 <tbody>
22986 <row>
22987 <entry><option>allow_domain_literals</option></entry>
22988 <entry>recognize domain literal syntax</entry>
22989 </row>
22990 <row>
22991 <entry><option>allow_mx_to_ip</option></entry>
22992 <entry>allow MX to point to IP address</entry>
22993 </row>
22994 <row>
22995 <entry><option>allow_utf8_domains</option></entry>
22996 <entry>in addresses</entry>
22997 </row>
22998 <row>
22999 <entry><option>check_rfc2047_length</option></entry>
23000 <entry>check length of RFC 2047 <quote>encoded words</quote></entry>
23001 </row>
23002 <row>
23003 <entry><option>delivery_date_remove</option></entry>
23004 <entry>from incoming messages</entry>
23005 </row>
23006 <row>
23007 <entry><option>envelope_to_remove</option></entry>
23008 <entry>from incoming messages</entry>
23009 </row>
23010 <row>
23011 <entry><option>extract_addresses_remove_arguments</option></entry>
23012 <entry>affects <option>-t</option> processing</entry>
23013 </row>
23014 <row>
23015 <entry><option>headers_charset</option></entry>
23016 <entry>default for translations</entry>
23017 </row>
23018 <row>
23019 <entry><option>qualify_domain</option></entry>
23020 <entry>default for senders</entry>
23021 </row>
23022 <row>
23023 <entry><option>qualify_recipient</option></entry>
23024 <entry>default for recipients</entry>
23025 </row>
23026 <row>
23027 <entry><option>return_path_remove</option></entry>
23028 <entry>from incoming messages</entry>
23029 </row>
23030 <row>
23031 <entry><option>strip_excess_angle_brackets</option></entry>
23032 <entry>in addresses</entry>
23033 </row>
23034 <row>
23035 <entry><option>strip_trailing_dot</option></entry>
23036 <entry>at end of addresses</entry>
23037 </row>
23038 <row>
23039 <entry><option>untrusted_set_sender</option></entry>
23040 <entry>untrusted can set envelope sender</entry>
23041 </row>
23042 </tbody>
23043 </tgroup>
23044 </informaltable>
23045 </section>
23046 <section id="SECID115">
23047 <title>System filter</title>
23048 <informaltable frame="none">
23049 <tgroup cols="2" colsep="0" rowsep="0">
23050 <colspec colwidth="196pt" align="left"/>
23051 <colspec colwidth="254pt" align="left"/>
23052 <tbody>
23053 <row>
23054 <entry><option>system_filter</option></entry>
23055 <entry>locate system filter</entry>
23056 </row>
23057 <row>
23058 <entry><option>system_filter_directory_transport</option></entry>
23059 <entry>transport for delivery to a directory</entry>
23060 </row>
23061 <row>
23062 <entry><option>system_filter_file_transport</option></entry>
23063 <entry>transport for delivery to a file</entry>
23064 </row>
23065 <row>
23066 <entry><option>system_filter_group</option></entry>
23067 <entry>group for filter running</entry>
23068 </row>
23069 <row>
23070 <entry><option>system_filter_pipe_transport</option></entry>
23071 <entry>transport for delivery to a pipe</entry>
23072 </row>
23073 <row>
23074 <entry><option>system_filter_reply_transport</option></entry>
23075 <entry>transport for autoreply delivery</entry>
23076 </row>
23077 <row>
23078 <entry><option>system_filter_user</option></entry>
23079 <entry>user for filter running</entry>
23080 </row>
23081 </tbody>
23082 </tgroup>
23083 </informaltable>
23084 </section>
23085 <section id="SECID116">
23086 <title>Routing and delivery</title>
23087 <informaltable frame="none">
23088 <tgroup cols="2" colsep="0" rowsep="0">
23089 <colspec colwidth="196pt" align="left"/>
23090 <colspec colwidth="254pt" align="left"/>
23091 <tbody>
23092 <row>
23093 <entry><option>disable_ipv6</option></entry>
23094 <entry>do no IPv6 processing</entry>
23095 </row>
23096 <row>
23097 <entry><option>dns_again_means_nonexist</option></entry>
23098 <entry>for broken domains</entry>
23099 </row>
23100 <row>
23101 <entry><option>dns_check_names_pattern</option></entry>
23102 <entry>pre-DNS syntax check</entry>
23103 </row>
23104 <row>
23105 <entry><option>dns_dnssec_ok</option></entry>
23106 <entry>parameter for resolver</entry>
23107 </row>
23108 <row>
23109 <entry><option>dns_ipv4_lookup</option></entry>
23110 <entry>only v4 lookup for these domains</entry>
23111 </row>
23112 <row>
23113 <entry><option>dns_retrans</option></entry>
23114 <entry>parameter for resolver</entry>
23115 </row>
23116 <row>
23117 <entry><option>dns_retry</option></entry>
23118 <entry>parameter for resolver</entry>
23119 </row>
23120 <row>
23121 <entry><option>dns_trust_aa</option></entry>
23122 <entry>DNS zones trusted as authentic</entry>
23123 </row>
23124 <row>
23125 <entry><option>dns_use_edns0</option></entry>
23126 <entry>parameter for resolver</entry>
23127 </row>
23128 <row>
23129 <entry><option>hold_domains</option></entry>
23130 <entry>hold delivery for these domains</entry>
23131 </row>
23132 <row>
23133 <entry><option>local_interfaces</option></entry>
23134 <entry>for routing checks</entry>
23135 </row>
23136 <row>
23137 <entry><option>queue_domains</option></entry>
23138 <entry>no immediate delivery for these</entry>
23139 </row>
23140 <row>
23141 <entry><option>queue_only</option></entry>
23142 <entry>no immediate delivery at all</entry>
23143 </row>
23144 <row>
23145 <entry><option>queue_only_file</option></entry>
23146 <entry>no immediate delivery if file exists</entry>
23147 </row>
23148 <row>
23149 <entry><option>queue_only_load</option></entry>
23150 <entry>no immediate delivery if load is high</entry>
23151 </row>
23152 <row>
23153 <entry><option>queue_only_load_latch</option></entry>
23154 <entry>don&#x2019;t re-evaluate load for each message</entry>
23155 </row>
23156 <row>
23157 <entry><option>queue_only_override</option></entry>
23158 <entry>allow command line to override</entry>
23159 </row>
23160 <row>
23161 <entry><option>queue_run_in_order</option></entry>
23162 <entry>order of arrival</entry>
23163 </row>
23164 <row>
23165 <entry><option>queue_run_max</option></entry>
23166 <entry>of simultaneous queue runners</entry>
23167 </row>
23168 <row>
23169 <entry><option>queue_smtp_domains</option></entry>
23170 <entry>no immediate SMTP delivery for these</entry>
23171 </row>
23172 <row>
23173 <entry><option>remote_max_parallel</option></entry>
23174 <entry>parallel SMTP delivery per message</entry>
23175 </row>
23176 <row>
23177 <entry><option>remote_sort_domains</option></entry>
23178 <entry>order of remote deliveries</entry>
23179 </row>
23180 <row>
23181 <entry><option>retry_data_expire</option></entry>
23182 <entry>timeout for retry data</entry>
23183 </row>
23184 <row>
23185 <entry><option>retry_interval_max</option></entry>
23186 <entry>safety net for retry rules</entry>
23187 </row>
23188 </tbody>
23189 </tgroup>
23190 </informaltable>
23191 </section>
23192 <section id="SECID117">
23193 <title>Bounce and warning messages</title>
23194 <informaltable frame="none">
23195 <tgroup cols="2" colsep="0" rowsep="0">
23196 <colspec colwidth="196pt" align="left"/>
23197 <colspec colwidth="254pt" align="left"/>
23198 <tbody>
23199 <row>
23200 <entry><option>bounce_message_file</option></entry>
23201 <entry>content of bounce</entry>
23202 </row>
23203 <row>
23204 <entry><option>bounce_message_text</option></entry>
23205 <entry>content of bounce</entry>
23206 </row>
23207 <row>
23208 <entry><option>bounce_return_body</option></entry>
23209 <entry>include body if returning message</entry>
23210 </row>
23211 <row>
23212 <entry><option>bounce_return_linesize_limit</option></entry>
23213 <entry>limit on returned message line length</entry>
23214 </row>
23215 <row>
23216 <entry><option>bounce_return_message</option></entry>
23217 <entry>include original message in bounce</entry>
23218 </row>
23219 <row>
23220 <entry><option>bounce_return_size_limit</option></entry>
23221 <entry>limit on returned message</entry>
23222 </row>
23223 <row>
23224 <entry><option>bounce_sender_authentication</option></entry>
23225 <entry>send authenticated sender with bounce</entry>
23226 </row>
23227 <row>
23228 <entry><option>dsn_from</option></entry>
23229 <entry>set <emphasis>From:</emphasis> contents in bounces</entry>
23230 </row>
23231 <row>
23232 <entry><option>errors_copy</option></entry>
23233 <entry>copy bounce messages</entry>
23234 </row>
23235 <row>
23236 <entry><option>errors_reply_to</option></entry>
23237 <entry><emphasis>Reply-to:</emphasis> in bounces</entry>
23238 </row>
23239 <row>
23240 <entry><option>delay_warning</option></entry>
23241 <entry>time schedule</entry>
23242 </row>
23243 <row>
23244 <entry><option>delay_warning_condition</option></entry>
23245 <entry>condition for warning messages</entry>
23246 </row>
23247 <row>
23248 <entry><option>ignore_bounce_errors_after</option></entry>
23249 <entry>discard undeliverable bounces</entry>
23250 </row>
23251 <row>
23252 <entry><option>smtp_return_error_details</option></entry>
23253 <entry>give detail on rejections</entry>
23254 </row>
23255 <row>
23256 <entry><option>warn_message_file</option></entry>
23257 <entry>content of warning message</entry>
23258 </row>
23259 </tbody>
23260 </tgroup>
23261 </informaltable>
23262 </section>
23263 <section id="SECTalomo">
23264 <title>Alphabetical list of main options</title>
23265 <para>
23266 Those options that undergo string expansion before use are marked with
23267 &dagger;.
23268 </para>
23269 <para>
23270 <indexterm role="option">
23271 <primary><option>accept_8bitmime</option></primary>
23272 </indexterm>
23273 </para>
23274 <informaltable frame="all">
23275 <tgroup cols="4" colsep="0" rowsep="0">
23276 <colspec colwidth="8*" align="left"/>
23277 <colspec colwidth="6*" align="center"/>
23278 <colspec colwidth="6*" align="center"/>
23279 <colspec colwidth="6*" align="right"/>
23280 <tbody>
23281 <row>
23282 <entry><option>accept_8bitmime</option></entry>
23283 <entry>Use: <emphasis>main</emphasis></entry>
23284 <entry>Type: <emphasis>boolean</emphasis></entry>
23285 <entry>Default: <emphasis>true</emphasis></entry>
23286 </row>
23287 </tbody>
23288 </tgroup>
23289 </informaltable>
23290 <para>
23291 <indexterm role="concept">
23292 <primary>8BITMIME</primary>
23293 </indexterm>
23294 <indexterm role="concept">
23295 <primary>8-bit characters</primary>
23296 </indexterm>
23297 <indexterm role="concept">
23298 <primary>log</primary>
23299 <secondary>selectors</secondary>
23300 </indexterm>
23301 <indexterm role="concept">
23302 <primary>log</primary>
23303 <secondary>8BITMIME</secondary>
23304 </indexterm>
23305 This option causes Exim to send 8BITMIME in its response to an SMTP
23306 EHLO command, and to accept the BODY= parameter on MAIL commands.
23307 However, though Exim is 8-bit clean, it is not a protocol converter, and it
23308 takes no steps to do anything special with messages received by this route.
23309 </para>
23310 <para>
23311 Historically Exim kept this option off by default, but the maintainers
23312 feel that in today&#x2019;s Internet, this causes more problems than it solves.
23313 It now defaults to true.
23314 A more detailed analysis of the issues is provided by Dan Bernstein:
23315 </para>
23316 <literallayout>
23317 <emphasis role="bold"><ulink url="https://cr.yp.to/smtp/8bitmime.html">https://cr.yp.to/smtp/8bitmime.html</ulink></emphasis>
23318 </literallayout>
23319 <para>
23320 To log received 8BITMIME status use
23321 </para>
23322 <literallayout class="monospaced">
23323 log_selector = +8bitmime
23324 </literallayout>
23325 <para>
23326 <indexterm role="option">
23327 <primary><option>acl_not_smtp</option></primary>
23328 </indexterm>
23329 </para>
23330 <informaltable frame="all">
23331 <tgroup cols="4" colsep="0" rowsep="0">
23332 <colspec colwidth="8*" align="left"/>
23333 <colspec colwidth="6*" align="center"/>
23334 <colspec colwidth="6*" align="center"/>
23335 <colspec colwidth="6*" align="right"/>
23336 <tbody>
23337 <row>
23338 <entry><option>acl_not_smtp</option></entry>
23339 <entry>Use: <emphasis>main</emphasis></entry>
23340 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23341 <entry>Default: <emphasis>unset</emphasis></entry>
23342 </row>
23343 </tbody>
23344 </tgroup>
23345 </informaltable>
23346 <para>
23347 <indexterm role="concept">
23348 <primary>access control lists (ACLs)</primary>
23349 <secondary>for non-SMTP messages</secondary>
23350 </indexterm>
23351 <indexterm role="concept">
23352 <primary>non-SMTP messages</primary>
23353 <secondary>ACLs for</secondary>
23354 </indexterm>
23355 This option defines the ACL that is run when a non-SMTP message has been
23356 read and is on the point of being accepted. See chapter <xref linkend="CHAPACL"/> for
23357 further details.
23358 </para>
23359 <para>
23360 <indexterm role="option">
23361 <primary><option>acl_not_smtp_mime</option></primary>
23362 </indexterm>
23363 </para>
23364 <informaltable frame="all">
23365 <tgroup cols="4" colsep="0" rowsep="0">
23366 <colspec colwidth="8*" align="left"/>
23367 <colspec colwidth="6*" align="center"/>
23368 <colspec colwidth="6*" align="center"/>
23369 <colspec colwidth="6*" align="right"/>
23370 <tbody>
23371 <row>
23372 <entry><option>acl_not_smtp_mime</option></entry>
23373 <entry>Use: <emphasis>main</emphasis></entry>
23374 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23375 <entry>Default: <emphasis>unset</emphasis></entry>
23376 </row>
23377 </tbody>
23378 </tgroup>
23379 </informaltable>
23380 <para>
23381 This option defines the ACL that is run for individual MIME parts of non-SMTP
23382 messages. It operates in exactly the same way as <option>acl_smtp_mime</option> operates for
23383 SMTP messages.
23384 </para>
23385 <para>
23386 <indexterm role="option">
23387 <primary><option>acl_not_smtp_start</option></primary>
23388 </indexterm>
23389 </para>
23390 <informaltable frame="all">
23391 <tgroup cols="4" colsep="0" rowsep="0">
23392 <colspec colwidth="8*" align="left"/>
23393 <colspec colwidth="6*" align="center"/>
23394 <colspec colwidth="6*" align="center"/>
23395 <colspec colwidth="6*" align="right"/>
23396 <tbody>
23397 <row>
23398 <entry><option>acl_not_smtp_start</option></entry>
23399 <entry>Use: <emphasis>main</emphasis></entry>
23400 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23401 <entry>Default: <emphasis>unset</emphasis></entry>
23402 </row>
23403 </tbody>
23404 </tgroup>
23405 </informaltable>
23406 <para>
23407 <indexterm role="concept">
23408 <primary>access control lists (ACLs)</primary>
23409 <secondary>at start of non-SMTP message</secondary>
23410 </indexterm>
23411 <indexterm role="concept">
23412 <primary>non-SMTP messages</primary>
23413 <secondary>ACLs for</secondary>
23414 </indexterm>
23415 This option defines the ACL that is run before Exim starts reading a
23416 non-SMTP message. See chapter <xref linkend="CHAPACL"/> for further details.
23417 </para>
23418 <para>
23419 <indexterm role="option">
23420 <primary><option>acl_smtp_auth</option></primary>
23421 </indexterm>
23422 </para>
23423 <informaltable frame="all">
23424 <tgroup cols="4" colsep="0" rowsep="0">
23425 <colspec colwidth="8*" align="left"/>
23426 <colspec colwidth="6*" align="center"/>
23427 <colspec colwidth="6*" align="center"/>
23428 <colspec colwidth="6*" align="right"/>
23429 <tbody>
23430 <row>
23431 <entry><option>acl_smtp_auth</option></entry>
23432 <entry>Use: <emphasis>main</emphasis></entry>
23433 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23434 <entry>Default: <emphasis>unset</emphasis></entry>
23435 </row>
23436 </tbody>
23437 </tgroup>
23438 </informaltable>
23439 <para>
23440 <indexterm role="concept">
23441 <primary>access control lists (ACLs)</primary>
23442 <secondary>setting up for SMTP commands</secondary>
23443 </indexterm>
23444 <indexterm role="concept">
23445 <primary>AUTH</primary>
23446 <secondary>ACL for</secondary>
23447 </indexterm>
23448 This option defines the ACL that is run when an SMTP AUTH command is
23449 received. See chapter <xref linkend="CHAPACL"/> for further details.
23450 </para>
23451 <para>
23452 <indexterm role="option">
23453 <primary><option>acl_smtp_connect</option></primary>
23454 </indexterm>
23455 </para>
23456 <informaltable frame="all">
23457 <tgroup cols="4" colsep="0" rowsep="0">
23458 <colspec colwidth="8*" align="left"/>
23459 <colspec colwidth="6*" align="center"/>
23460 <colspec colwidth="6*" align="center"/>
23461 <colspec colwidth="6*" align="right"/>
23462 <tbody>
23463 <row>
23464 <entry><option>acl_smtp_connect</option></entry>
23465 <entry>Use: <emphasis>main</emphasis></entry>
23466 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23467 <entry>Default: <emphasis>unset</emphasis></entry>
23468 </row>
23469 </tbody>
23470 </tgroup>
23471 </informaltable>
23472 <para>
23473 <indexterm role="concept">
23474 <primary>access control lists (ACLs)</primary>
23475 <secondary>on SMTP connection</secondary>
23476 </indexterm>
23477 This option defines the ACL that is run when an SMTP connection is received.
23478 See chapter <xref linkend="CHAPACL"/> for further details.
23479 </para>
23480 <para>
23481 <indexterm role="option">
23482 <primary><option>acl_smtp_data</option></primary>
23483 </indexterm>
23484 </para>
23485 <informaltable frame="all">
23486 <tgroup cols="4" colsep="0" rowsep="0">
23487 <colspec colwidth="8*" align="left"/>
23488 <colspec colwidth="6*" align="center"/>
23489 <colspec colwidth="6*" align="center"/>
23490 <colspec colwidth="6*" align="right"/>
23491 <tbody>
23492 <row>
23493 <entry><option>acl_smtp_data</option></entry>
23494 <entry>Use: <emphasis>main</emphasis></entry>
23495 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23496 <entry>Default: <emphasis>unset</emphasis></entry>
23497 </row>
23498 </tbody>
23499 </tgroup>
23500 </informaltable>
23501 <para>
23502 <indexterm role="concept">
23503 <primary>DATA</primary>
23504 <secondary>ACL for</secondary>
23505 </indexterm>
23506 This option defines the ACL that is run after an SMTP DATA command has been
23507 processed and the message itself has been received, but before the final
23508 acknowledgment is sent. See chapter <xref linkend="CHAPACL"/> for further details.
23509 </para>
23510 <para>
23511 <indexterm role="option">
23512 <primary><option>acl_smtp_data_prdr</option></primary>
23513 </indexterm>
23514 </para>
23515 <informaltable frame="all">
23516 <tgroup cols="4" colsep="0" rowsep="0">
23517 <colspec colwidth="8*" align="left"/>
23518 <colspec colwidth="6*" align="center"/>
23519 <colspec colwidth="6*" align="center"/>
23520 <colspec colwidth="6*" align="right"/>
23521 <tbody>
23522 <row>
23523 <entry><option>acl_smtp_data_prdr</option></entry>
23524 <entry>Use: <emphasis>main</emphasis></entry>
23525 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23526 <entry>Default: <emphasis>accept</emphasis></entry>
23527 </row>
23528 </tbody>
23529 </tgroup>
23530 </informaltable>
23531 <para>
23532 <indexterm role="concept">
23533 <primary>PRDR</primary>
23534 <secondary>ACL for</secondary>
23535 </indexterm>
23536 <indexterm role="concept">
23537 <primary>DATA</primary>
23538 <secondary>PRDR ACL for</secondary>
23539 </indexterm>
23540 <indexterm role="concept">
23541 <primary>access control lists (ACLs)</primary>
23542 <secondary>PRDR-related</secondary>
23543 </indexterm>
23544 <indexterm role="concept">
23545 <primary>access control lists (ACLs)</primary>
23546 <secondary>per-user data processing</secondary>
23547 </indexterm>
23548 This option defines the ACL that,
23549 if the PRDR feature has been negotiated,
23550 is run for each recipient after an SMTP DATA command has been
23551 processed and the message itself has been received, but before the
23552 acknowledgment is sent. See chapter <xref linkend="CHAPACL"/> for further details.
23553 </para>
23554 <para>
23555 <indexterm role="option">
23556 <primary><option>acl_smtp_dkim</option></primary>
23557 </indexterm>
23558 </para>
23559 <informaltable frame="all">
23560 <tgroup cols="4" colsep="0" rowsep="0">
23561 <colspec colwidth="8*" align="left"/>
23562 <colspec colwidth="6*" align="center"/>
23563 <colspec colwidth="6*" align="center"/>
23564 <colspec colwidth="6*" align="right"/>
23565 <tbody>
23566 <row>
23567 <entry><option>acl_smtp_dkim</option></entry>
23568 <entry>Use: <emphasis>main</emphasis></entry>
23569 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23570 <entry>Default: <emphasis>unset</emphasis></entry>
23571 </row>
23572 </tbody>
23573 </tgroup>
23574 </informaltable>
23575 <para>
23576 <indexterm role="concept">
23577 <primary>DKIM</primary>
23578 <secondary>ACL for</secondary>
23579 </indexterm>
23580 This option defines the ACL that is run for each DKIM signature
23581 (by default, or as specified in the dkim_verify_signers option)
23582 of a received message.
23583 See section <xref linkend="SECDKIMVFY"/> for further details.
23584 </para>
23585 <para>
23586 <indexterm role="option">
23587 <primary><option>acl_smtp_etrn</option></primary>
23588 </indexterm>
23589 </para>
23590 <informaltable frame="all">
23591 <tgroup cols="4" colsep="0" rowsep="0">
23592 <colspec colwidth="8*" align="left"/>
23593 <colspec colwidth="6*" align="center"/>
23594 <colspec colwidth="6*" align="center"/>
23595 <colspec colwidth="6*" align="right"/>
23596 <tbody>
23597 <row>
23598 <entry><option>acl_smtp_etrn</option></entry>
23599 <entry>Use: <emphasis>main</emphasis></entry>
23600 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23601 <entry>Default: <emphasis>unset</emphasis></entry>
23602 </row>
23603 </tbody>
23604 </tgroup>
23605 </informaltable>
23606 <para>
23607 <indexterm role="concept">
23608 <primary>ETRN</primary>
23609 <secondary>ACL for</secondary>
23610 </indexterm>
23611 This option defines the ACL that is run when an SMTP ETRN command is
23612 received. See chapter <xref linkend="CHAPACL"/> for further details.
23613 </para>
23614 <para>
23615 <indexterm role="option">
23616 <primary><option>acl_smtp_expn</option></primary>
23617 </indexterm>
23618 </para>
23619 <informaltable frame="all">
23620 <tgroup cols="4" colsep="0" rowsep="0">
23621 <colspec colwidth="8*" align="left"/>
23622 <colspec colwidth="6*" align="center"/>
23623 <colspec colwidth="6*" align="center"/>
23624 <colspec colwidth="6*" align="right"/>
23625 <tbody>
23626 <row>
23627 <entry><option>acl_smtp_expn</option></entry>
23628 <entry>Use: <emphasis>main</emphasis></entry>
23629 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23630 <entry>Default: <emphasis>unset</emphasis></entry>
23631 </row>
23632 </tbody>
23633 </tgroup>
23634 </informaltable>
23635 <para>
23636 <indexterm role="concept">
23637 <primary>EXPN</primary>
23638 <secondary>ACL for</secondary>
23639 </indexterm>
23640 This option defines the ACL that is run when an SMTP EXPN command is
23641 received. See chapter <xref linkend="CHAPACL"/> for further details.
23642 </para>
23643 <para>
23644 <indexterm role="option">
23645 <primary><option>acl_smtp_helo</option></primary>
23646 </indexterm>
23647 </para>
23648 <informaltable frame="all">
23649 <tgroup cols="4" colsep="0" rowsep="0">
23650 <colspec colwidth="8*" align="left"/>
23651 <colspec colwidth="6*" align="center"/>
23652 <colspec colwidth="6*" align="center"/>
23653 <colspec colwidth="6*" align="right"/>
23654 <tbody>
23655 <row>
23656 <entry><option>acl_smtp_helo</option></entry>
23657 <entry>Use: <emphasis>main</emphasis></entry>
23658 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23659 <entry>Default: <emphasis>unset</emphasis></entry>
23660 </row>
23661 </tbody>
23662 </tgroup>
23663 </informaltable>
23664 <para>
23665 <indexterm role="concept">
23666 <primary>EHLO</primary>
23667 <secondary>ACL for</secondary>
23668 </indexterm>
23669 <indexterm role="concept">
23670 <primary>HELO</primary>
23671 <secondary>ACL for</secondary>
23672 </indexterm>
23673 This option defines the ACL that is run when an SMTP EHLO or HELO
23674 command is received. See chapter <xref linkend="CHAPACL"/> for further details.
23675 </para>
23676 <para>
23677 <indexterm role="option">
23678 <primary><option>acl_smtp_mail</option></primary>
23679 </indexterm>
23680 </para>
23681 <informaltable frame="all">
23682 <tgroup cols="4" colsep="0" rowsep="0">
23683 <colspec colwidth="8*" align="left"/>
23684 <colspec colwidth="6*" align="center"/>
23685 <colspec colwidth="6*" align="center"/>
23686 <colspec colwidth="6*" align="right"/>
23687 <tbody>
23688 <row>
23689 <entry><option>acl_smtp_mail</option></entry>
23690 <entry>Use: <emphasis>main</emphasis></entry>
23691 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23692 <entry>Default: <emphasis>unset</emphasis></entry>
23693 </row>
23694 </tbody>
23695 </tgroup>
23696 </informaltable>
23697 <para>
23698 <indexterm role="concept">
23699 <primary>MAIL</primary>
23700 <secondary>ACL for</secondary>
23701 </indexterm>
23702 This option defines the ACL that is run when an SMTP MAIL command is
23703 received. See chapter <xref linkend="CHAPACL"/> for further details.
23704 </para>
23705 <para>
23706 <indexterm role="option">
23707 <primary><option>acl_smtp_mailauth</option></primary>
23708 </indexterm>
23709 </para>
23710 <informaltable frame="all">
23711 <tgroup cols="4" colsep="0" rowsep="0">
23712 <colspec colwidth="8*" align="left"/>
23713 <colspec colwidth="6*" align="center"/>
23714 <colspec colwidth="6*" align="center"/>
23715 <colspec colwidth="6*" align="right"/>
23716 <tbody>
23717 <row>
23718 <entry><option>acl_smtp_mailauth</option></entry>
23719 <entry>Use: <emphasis>main</emphasis></entry>
23720 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23721 <entry>Default: <emphasis>unset</emphasis></entry>
23722 </row>
23723 </tbody>
23724 </tgroup>
23725 </informaltable>
23726 <para>
23727 <indexterm role="concept">
23728 <primary>AUTH</primary>
23729 <secondary>on MAIL command</secondary>
23730 </indexterm>
23731 This option defines the ACL that is run when there is an AUTH parameter on
23732 a MAIL command. See chapter <xref linkend="CHAPACL"/> for details of ACLs, and chapter
23733 <xref linkend="CHAPSMTPAUTH"/> for details of authentication.
23734 </para>
23735 <para>
23736 <indexterm role="option">
23737 <primary><option>acl_smtp_mime</option></primary>
23738 </indexterm>
23739 </para>
23740 <informaltable frame="all">
23741 <tgroup cols="4" colsep="0" rowsep="0">
23742 <colspec colwidth="8*" align="left"/>
23743 <colspec colwidth="6*" align="center"/>
23744 <colspec colwidth="6*" align="center"/>
23745 <colspec colwidth="6*" align="right"/>
23746 <tbody>
23747 <row>
23748 <entry><option>acl_smtp_mime</option></entry>
23749 <entry>Use: <emphasis>main</emphasis></entry>
23750 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23751 <entry>Default: <emphasis>unset</emphasis></entry>
23752 </row>
23753 </tbody>
23754 </tgroup>
23755 </informaltable>
23756 <para>
23757 <indexterm role="concept">
23758 <primary>MIME content scanning</primary>
23759 <secondary>ACL for</secondary>
23760 </indexterm>
23761 This option is available when Exim is built with the content-scanning
23762 extension. It defines the ACL that is run for each MIME part in a message. See
23763 section <xref linkend="SECTscanmimepart"/> for details.
23764 </para>
23765 <para>
23766 <indexterm role="option">
23767 <primary><option>acl_smtp_notquit</option></primary>
23768 </indexterm>
23769 </para>
23770 <informaltable frame="all">
23771 <tgroup cols="4" colsep="0" rowsep="0">
23772 <colspec colwidth="8*" align="left"/>
23773 <colspec colwidth="6*" align="center"/>
23774 <colspec colwidth="6*" align="center"/>
23775 <colspec colwidth="6*" align="right"/>
23776 <tbody>
23777 <row>
23778 <entry><option>acl_smtp_notquit</option></entry>
23779 <entry>Use: <emphasis>main</emphasis></entry>
23780 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23781 <entry>Default: <emphasis>unset</emphasis></entry>
23782 </row>
23783 </tbody>
23784 </tgroup>
23785 </informaltable>
23786 <para>
23787 <indexterm role="concept">
23788 <primary>not-QUIT, ACL for</primary>
23789 </indexterm>
23790 This option defines the ACL that is run when an SMTP session
23791 ends without a QUIT command being received.
23792 See chapter <xref linkend="CHAPACL"/> for further details.
23793 </para>
23794 <para>
23795 <indexterm role="option">
23796 <primary><option>acl_smtp_predata</option></primary>
23797 </indexterm>
23798 </para>
23799 <informaltable frame="all">
23800 <tgroup cols="4" colsep="0" rowsep="0">
23801 <colspec colwidth="8*" align="left"/>
23802 <colspec colwidth="6*" align="center"/>
23803 <colspec colwidth="6*" align="center"/>
23804 <colspec colwidth="6*" align="right"/>
23805 <tbody>
23806 <row>
23807 <entry><option>acl_smtp_predata</option></entry>
23808 <entry>Use: <emphasis>main</emphasis></entry>
23809 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23810 <entry>Default: <emphasis>unset</emphasis></entry>
23811 </row>
23812 </tbody>
23813 </tgroup>
23814 </informaltable>
23815 <para>
23816 This option defines the ACL that is run when an SMTP DATA command is
23817 received, before the message itself is received. See chapter <xref linkend="CHAPACL"/> for
23818 further details.
23819 </para>
23820 <para>
23821 <indexterm role="option">
23822 <primary><option>acl_smtp_quit</option></primary>
23823 </indexterm>
23824 </para>
23825 <informaltable frame="all">
23826 <tgroup cols="4" colsep="0" rowsep="0">
23827 <colspec colwidth="8*" align="left"/>
23828 <colspec colwidth="6*" align="center"/>
23829 <colspec colwidth="6*" align="center"/>
23830 <colspec colwidth="6*" align="right"/>
23831 <tbody>
23832 <row>
23833 <entry><option>acl_smtp_quit</option></entry>
23834 <entry>Use: <emphasis>main</emphasis></entry>
23835 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23836 <entry>Default: <emphasis>unset</emphasis></entry>
23837 </row>
23838 </tbody>
23839 </tgroup>
23840 </informaltable>
23841 <para>
23842 <indexterm role="concept">
23843 <primary>QUIT, ACL for</primary>
23844 </indexterm>
23845 This option defines the ACL that is run when an SMTP QUIT command is
23846 received. See chapter <xref linkend="CHAPACL"/> for further details.
23847 </para>
23848 <para>
23849 <indexterm role="option">
23850 <primary><option>acl_smtp_rcpt</option></primary>
23851 </indexterm>
23852 </para>
23853 <informaltable frame="all">
23854 <tgroup cols="4" colsep="0" rowsep="0">
23855 <colspec colwidth="8*" align="left"/>
23856 <colspec colwidth="6*" align="center"/>
23857 <colspec colwidth="6*" align="center"/>
23858 <colspec colwidth="6*" align="right"/>
23859 <tbody>
23860 <row>
23861 <entry><option>acl_smtp_rcpt</option></entry>
23862 <entry>Use: <emphasis>main</emphasis></entry>
23863 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23864 <entry>Default: <emphasis>unset</emphasis></entry>
23865 </row>
23866 </tbody>
23867 </tgroup>
23868 </informaltable>
23869 <para>
23870 <indexterm role="concept">
23871 <primary>RCPT</primary>
23872 <secondary>ACL for</secondary>
23873 </indexterm>
23874 This option defines the ACL that is run when an SMTP RCPT command is
23875 received. See chapter <xref linkend="CHAPACL"/> for further details.
23876 </para>
23877 <para>
23878 <indexterm role="option">
23879 <primary><option>acl_smtp_starttls</option></primary>
23880 </indexterm>
23881 </para>
23882 <informaltable frame="all">
23883 <tgroup cols="4" colsep="0" rowsep="0">
23884 <colspec colwidth="8*" align="left"/>
23885 <colspec colwidth="6*" align="center"/>
23886 <colspec colwidth="6*" align="center"/>
23887 <colspec colwidth="6*" align="right"/>
23888 <tbody>
23889 <row>
23890 <entry><option>acl_smtp_starttls</option></entry>
23891 <entry>Use: <emphasis>main</emphasis></entry>
23892 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23893 <entry>Default: <emphasis>unset</emphasis></entry>
23894 </row>
23895 </tbody>
23896 </tgroup>
23897 </informaltable>
23898 <para>
23899 <indexterm role="concept">
23900 <primary>STARTTLS, ACL for</primary>
23901 </indexterm>
23902 This option defines the ACL that is run when an SMTP STARTTLS command is
23903 received. See chapter <xref linkend="CHAPACL"/> for further details.
23904 </para>
23905 <para>
23906 <indexterm role="option">
23907 <primary><option>acl_smtp_vrfy</option></primary>
23908 </indexterm>
23909 </para>
23910 <informaltable frame="all">
23911 <tgroup cols="4" colsep="0" rowsep="0">
23912 <colspec colwidth="8*" align="left"/>
23913 <colspec colwidth="6*" align="center"/>
23914 <colspec colwidth="6*" align="center"/>
23915 <colspec colwidth="6*" align="right"/>
23916 <tbody>
23917 <row>
23918 <entry><option>acl_smtp_vrfy</option></entry>
23919 <entry>Use: <emphasis>main</emphasis></entry>
23920 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
23921 <entry>Default: <emphasis>unset</emphasis></entry>
23922 </row>
23923 </tbody>
23924 </tgroup>
23925 </informaltable>
23926 <para>
23927 <indexterm role="concept">
23928 <primary>VRFY</primary>
23929 <secondary>ACL for</secondary>
23930 </indexterm>
23931 This option defines the ACL that is run when an SMTP VRFY command is
23932 received. See chapter <xref linkend="CHAPACL"/> for further details.
23933 </para>
23934 <para>
23935 <indexterm role="option">
23936 <primary><option>add_environment</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>add_environment</option></entry>
23948 <entry>Use: <emphasis>main</emphasis></entry>
23949 <entry>Type: <emphasis>string list</emphasis></entry>
23950 <entry>Default: <emphasis>empty</emphasis></entry>
23951 </row>
23952 </tbody>
23953 </tgroup>
23954 </informaltable>
23955 <para>
23956 <indexterm role="concept">
23957 <primary>environment</primary>
23958 <secondary>set values</secondary>
23959 </indexterm>
23960 This option adds individual environment variables that the
23961 currently linked libraries and programs in child processes may use.
23962 Each list element should be of the form <quote>name=value</quote>.
23963 </para>
23964 <para>
23965 See <xref linkend="SECTpipeenv"/> for the environment of <command>pipe</command> transports.
23966 </para>
23967 <para>
23968 <indexterm role="option">
23969 <primary><option>admin_groups</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>admin_groups</option></entry>
23981 <entry>Use: <emphasis>main</emphasis></entry>
23982 <entry>Type: <emphasis>string list</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>admin user</primary>
23991 </indexterm>
23992 This option is expanded just once, at the start of Exim&#x2019;s processing. If the
23993 current group or any of the supplementary groups of an Exim caller is in this
23994 colon-separated list, the caller has admin privileges. If all your system
23995 programmers are in a specific group, for example, you can give them all Exim
23996 admin privileges by putting that group in <option>admin_groups</option>. However, this does
23997 not permit them to read Exim&#x2019;s spool files (whose group owner is the Exim gid).
23998 To permit this, you have to add individuals to the Exim group.
23999 </para>
24000 <para>
24001 <indexterm role="option">
24002 <primary><option>allow_domain_literals</option></primary>
24003 </indexterm>
24004 </para>
24005 <informaltable frame="all">
24006 <tgroup cols="4" colsep="0" rowsep="0">
24007 <colspec colwidth="8*" align="left"/>
24008 <colspec colwidth="6*" align="center"/>
24009 <colspec colwidth="6*" align="center"/>
24010 <colspec colwidth="6*" align="right"/>
24011 <tbody>
24012 <row>
24013 <entry><option>allow_domain_literals</option></entry>
24014 <entry>Use: <emphasis>main</emphasis></entry>
24015 <entry>Type: <emphasis>boolean</emphasis></entry>
24016 <entry>Default: <emphasis>false</emphasis></entry>
24017 </row>
24018 </tbody>
24019 </tgroup>
24020 </informaltable>
24021 <para>
24022 <indexterm role="concept">
24023 <primary>domain literal</primary>
24024 </indexterm>
24025 If this option is set, the RFC 2822 domain literal format is permitted in
24026 email addresses. The option is not set by default, because the domain literal
24027 format is not normally required these days, and few people know about it. It
24028 has, however, been exploited by mail abusers.
24029 </para>
24030 <para>
24031 Unfortunately, it seems that some DNS black list maintainers are using this
24032 format to report black listing to postmasters. If you want to accept messages
24033 addressed to your hosts by IP address, you need to set
24034 <option>allow_domain_literals</option> true, and also to add <literal>@[]</literal> to the list of local
24035 domains (defined in the named domain list <option>local_domains</option> in the default
24036 configuration). This <quote>magic string</quote> matches the domain literal form of all
24037 the local host&#x2019;s IP addresses.
24038 </para>
24039 <para>
24040 <indexterm role="option">
24041 <primary><option>allow_mx_to_ip</option></primary>
24042 </indexterm>
24043 </para>
24044 <informaltable frame="all">
24045 <tgroup cols="4" colsep="0" rowsep="0">
24046 <colspec colwidth="8*" align="left"/>
24047 <colspec colwidth="6*" align="center"/>
24048 <colspec colwidth="6*" align="center"/>
24049 <colspec colwidth="6*" align="right"/>
24050 <tbody>
24051 <row>
24052 <entry><option>allow_mx_to_ip</option></entry>
24053 <entry>Use: <emphasis>main</emphasis></entry>
24054 <entry>Type: <emphasis>boolean</emphasis></entry>
24055 <entry>Default: <emphasis>false</emphasis></entry>
24056 </row>
24057 </tbody>
24058 </tgroup>
24059 </informaltable>
24060 <para>
24061 <indexterm role="concept">
24062 <primary>MX record</primary>
24063 <secondary>pointing to IP address</secondary>
24064 </indexterm>
24065 It appears that more and more DNS zone administrators are breaking the rules
24066 and putting domain names that look like IP addresses on the right hand side of
24067 MX records. Exim follows the rules and rejects this, giving an error message
24068 that explains the misconfiguration. However, some other MTAs support this
24069 practice, so to avoid <quote>Why can&#x2019;t Exim do this?</quote> complaints,
24070 <option>allow_mx_to_ip</option> exists, in order to enable this heinous activity. It is not
24071 recommended, except when you have no other choice.
24072 </para>
24073 <para>
24074 <indexterm role="option">
24075 <primary><option>allow_utf8_domains</option></primary>
24076 </indexterm>
24077 </para>
24078 <informaltable frame="all">
24079 <tgroup cols="4" colsep="0" rowsep="0">
24080 <colspec colwidth="8*" align="left"/>
24081 <colspec colwidth="6*" align="center"/>
24082 <colspec colwidth="6*" align="center"/>
24083 <colspec colwidth="6*" align="right"/>
24084 <tbody>
24085 <row>
24086 <entry><option>allow_utf8_domains</option></entry>
24087 <entry>Use: <emphasis>main</emphasis></entry>
24088 <entry>Type: <emphasis>boolean</emphasis></entry>
24089 <entry>Default: <emphasis>false</emphasis></entry>
24090 </row>
24091 </tbody>
24092 </tgroup>
24093 </informaltable>
24094 <para>
24095 <indexterm role="concept">
24096 <primary>domain</primary>
24097 <secondary>UTF-8 characters in</secondary>
24098 </indexterm>
24099 <indexterm role="concept">
24100 <primary>UTF-8</primary>
24101 <secondary>in domain name</secondary>
24102 </indexterm>
24103 Lots of discussion is going on about internationalized domain names. One
24104 camp is strongly in favour of just using UTF-8 characters, and it seems
24105 that at least two other MTAs permit this.
24106 This option allows Exim users to experiment if they wish.
24107 </para>
24108 <para>
24109 If it is set true, Exim&#x2019;s domain parsing function allows valid
24110 UTF-8 multicharacters to appear in domain name components, in addition to
24111 letters, digits, and hyphens.
24112 </para>
24113 <para revisionflag="changed">
24114 If Exim is built with internationalization support
24115 and the SMTPUTF8 ESMTP option is in use (see chapter <xref linkend="CHAPi18n"/>)
24116 this option can be left as default.
24117 </para>
24118 <para>
24119 Without that,
24120 if you want to look up such domain names in the DNS, you must also
24121 adjust the value of <option>dns_check_names_pattern</option> to match the extended form. A
24122 suitable setting is:
24123 </para>
24124 <literallayout class="monospaced">
24125 dns_check_names_pattern = (?i)^(?&gt;(?(1)\.|())[a-z0-9\xc0-\xff]\
24126   (?&gt;[-a-z0-9\x80-\xff]*[a-z0-9\x80-\xbf])?)+$
24127 </literallayout>
24128 <para>
24129 Alternatively, you can just disable this feature by setting
24130 </para>
24131 <literallayout class="monospaced">
24132 dns_check_names_pattern =
24133 </literallayout>
24134 <para>
24135 That is, set the option to an empty string so that no check is done.
24136 </para>
24137 <para>
24138 <indexterm role="option">
24139 <primary><option>auth_advertise_hosts</option></primary>
24140 </indexterm>
24141 </para>
24142 <informaltable frame="all">
24143 <tgroup cols="4" colsep="0" rowsep="0">
24144 <colspec colwidth="8*" align="left"/>
24145 <colspec colwidth="6*" align="center"/>
24146 <colspec colwidth="6*" align="center"/>
24147 <colspec colwidth="6*" align="right"/>
24148 <tbody>
24149 <row>
24150 <entry><option>auth_advertise_hosts</option></entry>
24151 <entry>Use: <emphasis>main</emphasis></entry>
24152 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
24153 <entry>Default: <emphasis>*</emphasis></entry>
24154 </row>
24155 </tbody>
24156 </tgroup>
24157 </informaltable>
24158 <para>
24159 <indexterm role="concept">
24160 <primary>authentication</primary>
24161 <secondary>advertising</secondary>
24162 </indexterm>
24163 <indexterm role="concept">
24164 <primary>AUTH</primary>
24165 <secondary>advertising</secondary>
24166 </indexterm>
24167 If any server authentication mechanisms are configured, Exim advertises them in
24168 response to an EHLO command only if the calling host matches this list.
24169 Otherwise, Exim does not advertise AUTH.
24170 Exim does not accept AUTH commands from clients to which it has not
24171 advertised the availability of AUTH. The advertising of individual
24172 authentication mechanisms can be controlled by the use of the
24173 <option>server_advertise_condition</option> generic authenticator option on the individual
24174 authenticators. See chapter <xref linkend="CHAPSMTPAUTH"/> for further details.
24175 </para>
24176 <para>
24177 Certain mail clients (for example, Netscape) require the user to provide a name
24178 and password for authentication if AUTH is advertised, even though it may
24179 not be needed (the host may accept messages from hosts on its local LAN without
24180 authentication, for example). The <option>auth_advertise_hosts</option> option can be used
24181 to make these clients more friendly by excluding them from the set of hosts to
24182 which Exim advertises AUTH.
24183 </para>
24184 <para>
24185 <indexterm role="concept">
24186 <primary>AUTH</primary>
24187 <secondary>advertising when encrypted</secondary>
24188 </indexterm>
24189 If you want to advertise the availability of AUTH only when the connection
24190 is encrypted using TLS, you can make use of the fact that the value of this
24191 option is expanded, with a setting like this:
24192 </para>
24193 <literallayout class="monospaced">
24194 auth_advertise_hosts = ${if eq{$tls_in_cipher}{}{}{*}}
24195 </literallayout>
24196 <para>
24197 <indexterm role="variable">
24198 <primary><varname>$tls_in_cipher</varname></primary>
24199 </indexterm>
24200 If <varname>$tls_in_cipher</varname> is empty, the session is not encrypted, and the result of
24201 the expansion is empty, thus matching no hosts. Otherwise, the result of the
24202 expansion is *, which matches all hosts.
24203 </para>
24204 <para>
24205 <indexterm role="option">
24206 <primary><option>auto_thaw</option></primary>
24207 </indexterm>
24208 </para>
24209 <informaltable frame="all">
24210 <tgroup cols="4" colsep="0" rowsep="0">
24211 <colspec colwidth="8*" align="left"/>
24212 <colspec colwidth="6*" align="center"/>
24213 <colspec colwidth="6*" align="center"/>
24214 <colspec colwidth="6*" align="right"/>
24215 <tbody>
24216 <row>
24217 <entry><option>auto_thaw</option></entry>
24218 <entry>Use: <emphasis>main</emphasis></entry>
24219 <entry>Type: <emphasis>time</emphasis></entry>
24220 <entry>Default: <emphasis>0s</emphasis></entry>
24221 </row>
24222 </tbody>
24223 </tgroup>
24224 </informaltable>
24225 <para>
24226 <indexterm role="concept">
24227 <primary>thawing messages</primary>
24228 </indexterm>
24229 <indexterm role="concept">
24230 <primary>unfreezing messages</primary>
24231 </indexterm>
24232 If this option is set to a time greater than zero, a queue runner will try a
24233 new delivery attempt on any frozen message, other than a bounce message, if
24234 this much time has passed since it was frozen. This may result in the message
24235 being re-frozen if nothing has changed since the last attempt. It is a way of
24236 saying <quote>keep on trying, even though there are big problems</quote>.
24237 </para>
24238 <para>
24239 <emphasis role="bold">Note</emphasis>: This is an old option, which predates <option>timeout_frozen_after</option> and
24240 <option>ignore_bounce_errors_after</option>. It is retained for compatibility, but it is not
24241 thought to be very useful any more, and its use should probably be avoided.
24242 </para>
24243 <para>
24244 <indexterm role="option">
24245 <primary><option>av_scanner</option></primary>
24246 </indexterm>
24247 </para>
24248 <informaltable frame="all">
24249 <tgroup cols="4" colsep="0" rowsep="0">
24250 <colspec colwidth="8*" align="left"/>
24251 <colspec colwidth="6*" align="center"/>
24252 <colspec colwidth="6*" align="center"/>
24253 <colspec colwidth="6*" align="right"/>
24254 <tbody>
24255 <row>
24256 <entry><option>av_scanner</option></entry>
24257 <entry>Use: <emphasis>main</emphasis></entry>
24258 <entry>Type: <emphasis>string</emphasis></entry>
24259 <entry>Default: <emphasis>see below</emphasis></entry>
24260 </row>
24261 </tbody>
24262 </tgroup>
24263 </informaltable>
24264 <para>
24265 This option is available if Exim is built with the content-scanning extension.
24266 It specifies which anti-virus scanner to use. The default value is:
24267 </para>
24268 <literallayout class="monospaced">
24269 sophie:/var/run/sophie
24270 </literallayout>
24271 <para>
24272 If the value of <option>av_scanner</option> starts with a dollar character, it is expanded
24273 before use. See section <xref linkend="SECTscanvirus"/> for further details.
24274 </para>
24275 <para>
24276 <indexterm role="option">
24277 <primary><option>bi_command</option></primary>
24278 </indexterm>
24279 </para>
24280 <informaltable frame="all">
24281 <tgroup cols="4" colsep="0" rowsep="0">
24282 <colspec colwidth="8*" align="left"/>
24283 <colspec colwidth="6*" align="center"/>
24284 <colspec colwidth="6*" align="center"/>
24285 <colspec colwidth="6*" align="right"/>
24286 <tbody>
24287 <row>
24288 <entry><option>bi_command</option></entry>
24289 <entry>Use: <emphasis>main</emphasis></entry>
24290 <entry>Type: <emphasis>string</emphasis></entry>
24291 <entry>Default: <emphasis>unset</emphasis></entry>
24292 </row>
24293 </tbody>
24294 </tgroup>
24295 </informaltable>
24296 <para>
24297 <indexterm role="option">
24298 <primary><option>-bi</option></primary>
24299 </indexterm>
24300 This option supplies the name of a command that is run when Exim is called with
24301 the <option>-bi</option> option (see chapter <xref linkend="CHAPcommandline"/>). The string value is
24302 just the command name, it is not a complete command line. If an argument is
24303 required, it must come from the <option>-oA</option> command line option.
24304 </para>
24305 <para>
24306 <indexterm role="option">
24307 <primary><option>bounce_message_file</option></primary>
24308 </indexterm>
24309 </para>
24310 <informaltable frame="all">
24311 <tgroup cols="4" colsep="0" rowsep="0">
24312 <colspec colwidth="8*" align="left"/>
24313 <colspec colwidth="6*" align="center"/>
24314 <colspec colwidth="6*" align="center"/>
24315 <colspec colwidth="6*" align="right"/>
24316 <tbody>
24317 <row>
24318 <entry><option>bounce_message_file</option></entry>
24319 <entry>Use: <emphasis>main</emphasis></entry>
24320 <entry>Type: <emphasis>string</emphasis></entry>
24321 <entry>Default: <emphasis>unset</emphasis></entry>
24322 </row>
24323 </tbody>
24324 </tgroup>
24325 </informaltable>
24326 <para>
24327 <indexterm role="concept">
24328 <primary>bounce message</primary>
24329 <secondary>customizing</secondary>
24330 </indexterm>
24331 <indexterm role="concept">
24332 <primary>customizing</primary>
24333 <secondary>bounce message</secondary>
24334 </indexterm>
24335 This option defines a template file containing paragraphs of text to be used
24336 for constructing bounce messages.  Details of the file&#x2019;s contents are given in
24337 chapter <xref linkend="CHAPemsgcust"/>. See also <option>warn_message_file</option>.
24338 </para>
24339 <para>
24340 <indexterm role="option">
24341 <primary><option>bounce_message_text</option></primary>
24342 </indexterm>
24343 </para>
24344 <informaltable frame="all">
24345 <tgroup cols="4" colsep="0" rowsep="0">
24346 <colspec colwidth="8*" align="left"/>
24347 <colspec colwidth="6*" align="center"/>
24348 <colspec colwidth="6*" align="center"/>
24349 <colspec colwidth="6*" align="right"/>
24350 <tbody>
24351 <row>
24352 <entry><option>bounce_message_text</option></entry>
24353 <entry>Use: <emphasis>main</emphasis></entry>
24354 <entry>Type: <emphasis>string</emphasis></entry>
24355 <entry>Default: <emphasis>unset</emphasis></entry>
24356 </row>
24357 </tbody>
24358 </tgroup>
24359 </informaltable>
24360 <para>
24361 When this option is set, its contents are included in the default bounce
24362 message immediately after <quote>This message was created automatically by mail
24363 delivery software.</quote> It is not used if <option>bounce_message_file</option> is set.
24364 </para>
24365 <para>
24366 <indexterm role="option">
24367 <primary><option>bounce_return_body</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>bounce_return_body</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>bounce message</primary>
24389 <secondary>including body</secondary>
24390 </indexterm>
24391 This option controls whether the body of an incoming message is included in a
24392 bounce message when <option>bounce_return_message</option> is true. The default setting
24393 causes the entire message, both header and body, to be returned (subject to the
24394 value of <option>bounce_return_size_limit</option>). If this option is false, only the
24395 message header is included. In the case of a non-SMTP message containing an
24396 error that is detected during reception, only those header lines preceding the
24397 point at which the error was detected are returned.
24398 <indexterm role="concept">
24399 <primary>bounce message</primary>
24400 <secondary>including original</secondary>
24401 </indexterm>
24402 </para>
24403 <para>
24404 <indexterm role="option">
24405 <primary><option>bounce_return_linesize_limit</option></primary>
24406 </indexterm>
24407 </para>
24408 <informaltable frame="all">
24409 <tgroup cols="4" colsep="0" rowsep="0">
24410 <colspec colwidth="8*" align="left"/>
24411 <colspec colwidth="6*" align="center"/>
24412 <colspec colwidth="6*" align="center"/>
24413 <colspec colwidth="6*" align="right"/>
24414 <tbody>
24415 <row>
24416 <entry><option>bounce_return_linesize_limit</option></entry>
24417 <entry>Use: <emphasis>main</emphasis></entry>
24418 <entry>Type: <emphasis>integer</emphasis></entry>
24419 <entry>Default: <emphasis>998</emphasis></entry>
24420 </row>
24421 </tbody>
24422 </tgroup>
24423 </informaltable>
24424 <para>
24425 <indexterm role="concept">
24426 <primary>size</primary>
24427 <secondary>of bounce lines, limit</secondary>
24428 </indexterm>
24429 <indexterm role="concept">
24430 <primary>bounce message</primary>
24431 <secondary>line length limit</secondary>
24432 </indexterm>
24433 <indexterm role="concept">
24434 <primary>limit</primary>
24435 <secondary>bounce message line length</secondary>
24436 </indexterm>
24437 This option sets a limit in bytes on the line length of messages
24438 that are returned to senders due to delivery problems,
24439 when <option>bounce_return_message</option> is true.
24440 The default value corresponds to RFC limits.
24441 If the message being returned has lines longer than this value it is
24442 treated as if the <option>bounce_return_size_limit</option> (below) restriction was exceeded.
24443 </para>
24444 <para>
24445 The option also applies to bounces returned when an error is detected
24446 during reception of a message.
24447 In this case lines from the original are truncated.
24448 </para>
24449 <para>
24450 The option does not apply to messages generated by an <command>autoreply</command> transport.
24451 </para>
24452 <para>
24453 <indexterm role="option">
24454 <primary><option>bounce_return_message</option></primary>
24455 </indexterm>
24456 </para>
24457 <informaltable frame="all">
24458 <tgroup cols="4" colsep="0" rowsep="0">
24459 <colspec colwidth="8*" align="left"/>
24460 <colspec colwidth="6*" align="center"/>
24461 <colspec colwidth="6*" align="center"/>
24462 <colspec colwidth="6*" align="right"/>
24463 <tbody>
24464 <row>
24465 <entry><option>bounce_return_message</option></entry>
24466 <entry>Use: <emphasis>main</emphasis></entry>
24467 <entry>Type: <emphasis>boolean</emphasis></entry>
24468 <entry>Default: <emphasis>true</emphasis></entry>
24469 </row>
24470 </tbody>
24471 </tgroup>
24472 </informaltable>
24473 <para>
24474 If this option is set false, none of the original message is included in
24475 bounce messages generated by Exim. See also <option>bounce_return_size_limit</option> and
24476 <option>bounce_return_body</option>.
24477 </para>
24478 <para>
24479 <indexterm role="option">
24480 <primary><option>bounce_return_size_limit</option></primary>
24481 </indexterm>
24482 </para>
24483 <informaltable frame="all">
24484 <tgroup cols="4" colsep="0" rowsep="0">
24485 <colspec colwidth="8*" align="left"/>
24486 <colspec colwidth="6*" align="center"/>
24487 <colspec colwidth="6*" align="center"/>
24488 <colspec colwidth="6*" align="right"/>
24489 <tbody>
24490 <row>
24491 <entry><option>bounce_return_size_limit</option></entry>
24492 <entry>Use: <emphasis>main</emphasis></entry>
24493 <entry>Type: <emphasis>integer</emphasis></entry>
24494 <entry>Default: <emphasis>100K</emphasis></entry>
24495 </row>
24496 </tbody>
24497 </tgroup>
24498 </informaltable>
24499 <para>
24500 <indexterm role="concept">
24501 <primary>size</primary>
24502 <secondary>of bounce, limit</secondary>
24503 </indexterm>
24504 <indexterm role="concept">
24505 <primary>bounce message</primary>
24506 <secondary>size limit</secondary>
24507 </indexterm>
24508 <indexterm role="concept">
24509 <primary>limit</primary>
24510 <secondary>bounce message size</secondary>
24511 </indexterm>
24512 This option sets a limit in bytes on the size of messages that are returned to
24513 senders as part of bounce messages when <option>bounce_return_message</option> is true. The
24514 limit should be less than the value of the global <option>message_size_limit</option> and of
24515 any <option>message_size_limit</option> settings on transports, to allow for the bounce text
24516 that Exim generates. If this option is set to zero there is no limit.
24517 </para>
24518 <para>
24519 When the body of any message that is to be included in a bounce message is
24520 greater than the limit, it is truncated, and a comment pointing this out is
24521 added at the top. The actual cutoff may be greater than the value given, owing
24522 to the use of buffering for transferring the message in chunks (typically 8K in
24523 size). The idea is to save bandwidth on those undeliverable 15-megabyte
24524 messages.
24525 </para>
24526 <para>
24527 <indexterm role="option">
24528 <primary><option>bounce_sender_authentication</option></primary>
24529 </indexterm>
24530 </para>
24531 <informaltable frame="all">
24532 <tgroup cols="4" colsep="0" rowsep="0">
24533 <colspec colwidth="8*" align="left"/>
24534 <colspec colwidth="6*" align="center"/>
24535 <colspec colwidth="6*" align="center"/>
24536 <colspec colwidth="6*" align="right"/>
24537 <tbody>
24538 <row>
24539 <entry><option>bounce_sender_authentication</option></entry>
24540 <entry>Use: <emphasis>main</emphasis></entry>
24541 <entry>Type: <emphasis>string</emphasis></entry>
24542 <entry>Default: <emphasis>unset</emphasis></entry>
24543 </row>
24544 </tbody>
24545 </tgroup>
24546 </informaltable>
24547 <para>
24548 <indexterm role="concept">
24549 <primary>bounce message</primary>
24550 <secondary>sender authentication</secondary>
24551 </indexterm>
24552 <indexterm role="concept">
24553 <primary>authentication</primary>
24554 <secondary>bounce message</secondary>
24555 </indexterm>
24556 <indexterm role="concept">
24557 <primary>AUTH</primary>
24558 <secondary>on bounce message</secondary>
24559 </indexterm>
24560 This option provides an authenticated sender address that is sent with any
24561 bounce messages generated by Exim that are sent over an authenticated SMTP
24562 connection. A typical setting might be:
24563 </para>
24564 <literallayout class="monospaced">
24565 bounce_sender_authentication = mailer-daemon@my.domain.example
24566 </literallayout>
24567 <para>
24568 which would cause bounce messages to be sent using the SMTP command:
24569 </para>
24570 <literallayout class="monospaced">
24571 MAIL FROM:&lt;&gt; AUTH=mailer-daemon@my.domain.example
24572 </literallayout>
24573 <para>
24574 The value of <option>bounce_sender_authentication</option> must always be a complete email
24575 address.
24576 </para>
24577 <para>
24578 <indexterm role="option">
24579 <primary><option>callout_domain_negative_expire</option></primary>
24580 </indexterm>
24581 </para>
24582 <informaltable frame="all">
24583 <tgroup cols="4" colsep="0" rowsep="0">
24584 <colspec colwidth="8*" align="left"/>
24585 <colspec colwidth="6*" align="center"/>
24586 <colspec colwidth="6*" align="center"/>
24587 <colspec colwidth="6*" align="right"/>
24588 <tbody>
24589 <row>
24590 <entry><option>callout_domain_negative_expire</option></entry>
24591 <entry>Use: <emphasis>main</emphasis></entry>
24592 <entry>Type: <emphasis>time</emphasis></entry>
24593 <entry>Default: <emphasis>3h</emphasis></entry>
24594 </row>
24595 </tbody>
24596 </tgroup>
24597 </informaltable>
24598 <para>
24599 <indexterm role="concept">
24600 <primary>caching</primary>
24601 <secondary>callout timeouts</secondary>
24602 </indexterm>
24603 <indexterm role="concept">
24604 <primary>callout</primary>
24605 <secondary>caching timeouts</secondary>
24606 </indexterm>
24607 This option specifies the expiry time for negative callout cache data for a
24608 domain. See section <xref linkend="SECTcallver"/> for details of callout verification, and
24609 section <xref linkend="SECTcallvercache"/> for details of the caching.
24610 </para>
24611 <para>
24612 <indexterm role="option">
24613 <primary><option>callout_domain_positive_expire</option></primary>
24614 </indexterm>
24615 </para>
24616 <informaltable frame="all">
24617 <tgroup cols="4" colsep="0" rowsep="0">
24618 <colspec colwidth="8*" align="left"/>
24619 <colspec colwidth="6*" align="center"/>
24620 <colspec colwidth="6*" align="center"/>
24621 <colspec colwidth="6*" align="right"/>
24622 <tbody>
24623 <row>
24624 <entry><option>callout_domain_positive_expire</option></entry>
24625 <entry>Use: <emphasis>main</emphasis></entry>
24626 <entry>Type: <emphasis>time</emphasis></entry>
24627 <entry>Default: <emphasis>7d</emphasis></entry>
24628 </row>
24629 </tbody>
24630 </tgroup>
24631 </informaltable>
24632 <para>
24633 This option specifies the expiry time for positive callout cache data for a
24634 domain. See section <xref linkend="SECTcallver"/> for details of callout verification, and
24635 section <xref linkend="SECTcallvercache"/> for details of the caching.
24636 </para>
24637 <para>
24638 <indexterm role="option">
24639 <primary><option>callout_negative_expire</option></primary>
24640 </indexterm>
24641 </para>
24642 <informaltable frame="all">
24643 <tgroup cols="4" colsep="0" rowsep="0">
24644 <colspec colwidth="8*" align="left"/>
24645 <colspec colwidth="6*" align="center"/>
24646 <colspec colwidth="6*" align="center"/>
24647 <colspec colwidth="6*" align="right"/>
24648 <tbody>
24649 <row>
24650 <entry><option>callout_negative_expire</option></entry>
24651 <entry>Use: <emphasis>main</emphasis></entry>
24652 <entry>Type: <emphasis>time</emphasis></entry>
24653 <entry>Default: <emphasis>2h</emphasis></entry>
24654 </row>
24655 </tbody>
24656 </tgroup>
24657 </informaltable>
24658 <para>
24659 This option specifies the expiry time for negative callout cache data for an
24660 address. See section <xref linkend="SECTcallver"/> for details of callout verification, and
24661 section <xref linkend="SECTcallvercache"/> for details of the caching.
24662 </para>
24663 <para>
24664 <indexterm role="option">
24665 <primary><option>callout_positive_expire</option></primary>
24666 </indexterm>
24667 </para>
24668 <informaltable frame="all">
24669 <tgroup cols="4" colsep="0" rowsep="0">
24670 <colspec colwidth="8*" align="left"/>
24671 <colspec colwidth="6*" align="center"/>
24672 <colspec colwidth="6*" align="center"/>
24673 <colspec colwidth="6*" align="right"/>
24674 <tbody>
24675 <row>
24676 <entry><option>callout_positive_expire</option></entry>
24677 <entry>Use: <emphasis>main</emphasis></entry>
24678 <entry>Type: <emphasis>time</emphasis></entry>
24679 <entry>Default: <emphasis>24h</emphasis></entry>
24680 </row>
24681 </tbody>
24682 </tgroup>
24683 </informaltable>
24684 <para>
24685 This option specifies the expiry time for positive callout cache data for an
24686 address. See section <xref linkend="SECTcallver"/> for details of callout verification, and
24687 section <xref linkend="SECTcallvercache"/> for details of the caching.
24688 </para>
24689 <para>
24690 <indexterm role="option">
24691 <primary><option>callout_random_local_part</option></primary>
24692 </indexterm>
24693 </para>
24694 <informaltable frame="all">
24695 <tgroup cols="4" colsep="0" rowsep="0">
24696 <colspec colwidth="8*" align="left"/>
24697 <colspec colwidth="6*" align="center"/>
24698 <colspec colwidth="6*" align="center"/>
24699 <colspec colwidth="6*" align="right"/>
24700 <tbody>
24701 <row>
24702 <entry><option>callout_random_local_part</option></entry>
24703 <entry>Use: <emphasis>main</emphasis></entry>
24704 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
24705 <entry>Default: <emphasis>see below</emphasis></entry>
24706 </row>
24707 </tbody>
24708 </tgroup>
24709 </informaltable>
24710 <para>
24711 This option defines the <quote>random</quote> local part that can be used as part of
24712 callout verification. The default value is
24713 </para>
24714 <literallayout class="monospaced">
24715 $primary_hostname-$tod_epoch-testing
24716 </literallayout>
24717 <para>
24718 See section <xref linkend="CALLaddparcall"/> for details of how this value is used.
24719 </para>
24720 <para>
24721 <indexterm role="option">
24722 <primary><option>check_log_inodes</option></primary>
24723 </indexterm>
24724 </para>
24725 <informaltable frame="all">
24726 <tgroup cols="4" colsep="0" rowsep="0">
24727 <colspec colwidth="8*" align="left"/>
24728 <colspec colwidth="6*" align="center"/>
24729 <colspec colwidth="6*" align="center"/>
24730 <colspec colwidth="6*" align="right"/>
24731 <tbody>
24732 <row>
24733 <entry><option>check_log_inodes</option></entry>
24734 <entry>Use: <emphasis>main</emphasis></entry>
24735 <entry>Type: <emphasis>integer</emphasis></entry>
24736 <entry>Default: <emphasis>100</emphasis></entry>
24737 </row>
24738 </tbody>
24739 </tgroup>
24740 </informaltable>
24741 <para>
24742 See <option>check_spool_space</option> below.
24743 </para>
24744 <para>
24745 <indexterm role="option">
24746 <primary><option>check_log_space</option></primary>
24747 </indexterm>
24748 </para>
24749 <informaltable frame="all">
24750 <tgroup cols="4" colsep="0" rowsep="0">
24751 <colspec colwidth="8*" align="left"/>
24752 <colspec colwidth="6*" align="center"/>
24753 <colspec colwidth="6*" align="center"/>
24754 <colspec colwidth="6*" align="right"/>
24755 <tbody>
24756 <row>
24757 <entry><option>check_log_space</option></entry>
24758 <entry>Use: <emphasis>main</emphasis></entry>
24759 <entry>Type: <emphasis>integer</emphasis></entry>
24760 <entry>Default: <emphasis>10M</emphasis></entry>
24761 </row>
24762 </tbody>
24763 </tgroup>
24764 </informaltable>
24765 <para>
24766 See <option>check_spool_space</option> below.
24767 </para>
24768 <para>
24769 <indexterm role="option">
24770 <primary><option>check_rfc2047_length</option></primary>
24771 </indexterm>
24772 <indexterm role="concept">
24773 <primary>RFC 2047</primary>
24774 <secondary>disabling length check</secondary>
24775 </indexterm>
24776 <indexterm role="option">
24777 <primary><option>check_rfc2047_length</option></primary>
24778 </indexterm>
24779 </para>
24780 <informaltable frame="all">
24781 <tgroup cols="4" colsep="0" rowsep="0">
24782 <colspec colwidth="8*" align="left"/>
24783 <colspec colwidth="6*" align="center"/>
24784 <colspec colwidth="6*" align="center"/>
24785 <colspec colwidth="6*" align="right"/>
24786 <tbody>
24787 <row>
24788 <entry><option>check_rfc2047_length</option></entry>
24789 <entry>Use: <emphasis>main</emphasis></entry>
24790 <entry>Type: <emphasis>boolean</emphasis></entry>
24791 <entry>Default: <emphasis>true</emphasis></entry>
24792 </row>
24793 </tbody>
24794 </tgroup>
24795 </informaltable>
24796 <para>
24797 RFC 2047 defines a way of encoding non-ASCII characters in headers using a
24798 system of <quote>encoded words</quote>. The RFC specifies a maximum length for an encoded
24799 word; strings to be encoded that exceed this length are supposed to use
24800 multiple encoded words. By default, Exim does not recognize encoded words that
24801 exceed the maximum length. However, it seems that some software, in violation
24802 of the RFC, generates overlong encoded words. If <option>check_rfc2047_length</option> is
24803 set false, Exim recognizes encoded words of any length.
24804 </para>
24805 <para>
24806 <indexterm role="option">
24807 <primary><option>check_spool_inodes</option></primary>
24808 </indexterm>
24809 </para>
24810 <informaltable frame="all">
24811 <tgroup cols="4" colsep="0" rowsep="0">
24812 <colspec colwidth="8*" align="left"/>
24813 <colspec colwidth="6*" align="center"/>
24814 <colspec colwidth="6*" align="center"/>
24815 <colspec colwidth="6*" align="right"/>
24816 <tbody>
24817 <row>
24818 <entry><option>check_spool_inodes</option></entry>
24819 <entry>Use: <emphasis>main</emphasis></entry>
24820 <entry>Type: <emphasis>integer</emphasis></entry>
24821 <entry>Default: <emphasis>100</emphasis></entry>
24822 </row>
24823 </tbody>
24824 </tgroup>
24825 </informaltable>
24826 <para>
24827 See <option>check_spool_space</option> below.
24828 </para>
24829 <para>
24830 <indexterm role="option">
24831 <primary><option>check_spool_space</option></primary>
24832 </indexterm>
24833 </para>
24834 <informaltable frame="all">
24835 <tgroup cols="4" colsep="0" rowsep="0">
24836 <colspec colwidth="8*" align="left"/>
24837 <colspec colwidth="6*" align="center"/>
24838 <colspec colwidth="6*" align="center"/>
24839 <colspec colwidth="6*" align="right"/>
24840 <tbody>
24841 <row>
24842 <entry><option>check_spool_space</option></entry>
24843 <entry>Use: <emphasis>main</emphasis></entry>
24844 <entry>Type: <emphasis>integer</emphasis></entry>
24845 <entry>Default: <emphasis>10M</emphasis></entry>
24846 </row>
24847 </tbody>
24848 </tgroup>
24849 </informaltable>
24850 <para>
24851 <indexterm role="concept">
24852 <primary>checking disk space</primary>
24853 </indexterm>
24854 <indexterm role="concept">
24855 <primary>disk space, checking</primary>
24856 </indexterm>
24857 <indexterm role="concept">
24858 <primary>spool directory</primary>
24859 <secondary>checking space</secondary>
24860 </indexterm>
24861 The four <option>check_...</option> options allow for checking of disk resources before a
24862 message is accepted.
24863 </para>
24864 <para>
24865 <indexterm role="variable">
24866 <primary><varname>$log_inodes</varname></primary>
24867 </indexterm>
24868 <indexterm role="variable">
24869 <primary><varname>$log_space</varname></primary>
24870 </indexterm>
24871 <indexterm role="variable">
24872 <primary><varname>$spool_inodes</varname></primary>
24873 </indexterm>
24874 <indexterm role="variable">
24875 <primary><varname>$spool_space</varname></primary>
24876 </indexterm>
24877 When any of these options are nonzero, they apply to all incoming messages. If you
24878 want to apply different checks to different kinds of message, you can do so by
24879 testing the variables <varname>$log_inodes</varname>, <varname>$log_space</varname>, <varname>$spool_inodes</varname>, and
24880 <varname>$spool_space</varname> in an ACL with appropriate additional conditions.
24881 </para>
24882 <para>
24883 <option>check_spool_space</option> and <option>check_spool_inodes</option> check the spool partition if
24884 either value is greater than zero, for example:
24885 </para>
24886 <literallayout class="monospaced">
24887 check_spool_space = 100M
24888 check_spool_inodes = 100
24889 </literallayout>
24890 <para>
24891 The spool partition is the one that contains the directory defined by
24892 SPOOL_DIRECTORY in <filename>Local/Makefile</filename>. It is used for holding messages in
24893 transit.
24894 </para>
24895 <para>
24896 <option>check_log_space</option> and <option>check_log_inodes</option>  check the partition in which log
24897 files are written if either is greater than zero. These should be set only if
24898 <option>log_file_path</option> and <option>spool_directory</option> refer to different partitions.
24899 </para>
24900 <para>
24901 If there is less space or fewer inodes than requested, Exim refuses to accept
24902 incoming mail. In the case of SMTP input this is done by giving a 452 temporary
24903 error response to the MAIL command. If ESMTP is in use and there was a
24904 SIZE parameter on the MAIL command, its value is added to the
24905 <option>check_spool_space</option> value, and the check is performed even if
24906 <option>check_spool_space</option> is zero, unless <option>no_smtp_check_spool_space</option> is set.
24907 </para>
24908 <para>
24909 The values for <option>check_spool_space</option> and <option>check_log_space</option> are held as a
24910 number of kilobytes (though specified in bytes).
24911 If a non-multiple of 1024 is specified, it is rounded up.
24912 </para>
24913 <para>
24914 For non-SMTP input and for batched SMTP input, the test is done at start-up; on
24915 failure a message is written to stderr and Exim exits with a non-zero code, as
24916 it obviously cannot send an error message of any kind.
24917 </para>
24918 <para>
24919 There is a slight performance penalty for these checks.
24920 Versions of Exim preceding 4.88 had these disabled by default;
24921 high-rate installations confident they will never run out of resources
24922 may wish to deliberately disable them.
24923 </para>
24924 <para>
24925 <indexterm role="option">
24926 <primary><option>chunking_advertise_hosts</option></primary>
24927 </indexterm>
24928 </para>
24929 <informaltable frame="all">
24930 <tgroup cols="4" colsep="0" rowsep="0">
24931 <colspec colwidth="8*" align="left"/>
24932 <colspec colwidth="6*" align="center"/>
24933 <colspec colwidth="6*" align="center"/>
24934 <colspec colwidth="6*" align="right"/>
24935 <tbody>
24936 <row>
24937 <entry><option>chunking_advertise_hosts</option></entry>
24938 <entry>Use: <emphasis>main</emphasis></entry>
24939 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
24940 <entry>Default: <emphasis>*</emphasis></entry>
24941 </row>
24942 </tbody>
24943 </tgroup>
24944 </informaltable>
24945 <para>
24946 <indexterm role="concept">
24947 <primary>CHUNKING</primary>
24948 <secondary>advertisement</secondary>
24949 </indexterm>
24950 <indexterm role="concept">
24951 <primary>RFC 3030</primary>
24952 <secondary>CHUNKING</secondary>
24953 </indexterm>
24954 The CHUNKING extension (RFC3030) will be advertised in the EHLO message to
24955 these hosts.
24956 Hosts may use the BDAT command as an alternate to DATA.
24957 </para>
24958 <para>
24959 <indexterm role="option">
24960 <primary><option>commandline_checks_require_admin</option></primary>
24961 </indexterm>
24962 </para>
24963 <informaltable frame="all">
24964 <tgroup cols="4" colsep="0" rowsep="0">
24965 <colspec colwidth="8*" align="left"/>
24966 <colspec colwidth="6*" align="center"/>
24967 <colspec colwidth="6*" align="center"/>
24968 <colspec colwidth="6*" align="right"/>
24969 <tbody>
24970 <row>
24971 <entry><option>commandline_checks_require_admin</option></entry>
24972 <entry>Use: <emphasis>main</emphasis></entry>
24973 <entry>Type: <emphasis>boolean</emphasis></entry>
24974 <entry>Default: <emphasis><literal>false</literal></emphasis></entry>
24975 </row>
24976 </tbody>
24977 </tgroup>
24978 </informaltable>
24979 <para>
24980 <indexterm role="concept">
24981 <primary>restricting access to features</primary>
24982 </indexterm>
24983 This option restricts various basic checking features to require an
24984 administrative user.
24985 This affects most of the <option>-b*</option> options, such as <option>-be</option>.
24986 </para>
24987 <para>
24988 <indexterm role="option">
24989 <primary><option>debug_store</option></primary>
24990 </indexterm>
24991 </para>
24992 <informaltable frame="all">
24993 <tgroup cols="4" colsep="0" rowsep="0">
24994 <colspec colwidth="8*" align="left"/>
24995 <colspec colwidth="6*" align="center"/>
24996 <colspec colwidth="6*" align="center"/>
24997 <colspec colwidth="6*" align="right"/>
24998 <tbody>
24999 <row>
25000 <entry><option>debug_store</option></entry>
25001 <entry>Use: <emphasis>main</emphasis></entry>
25002 <entry>Type: <emphasis>boolean</emphasis></entry>
25003 <entry>Default: <emphasis><literal>false</literal></emphasis></entry>
25004 </row>
25005 </tbody>
25006 </tgroup>
25007 </informaltable>
25008 <para>
25009 <indexterm role="concept">
25010 <primary>debugging</primary>
25011 <secondary>memory corruption</secondary>
25012 </indexterm>
25013 <indexterm role="concept">
25014 <primary>memory</primary>
25015 <secondary>debugging</secondary>
25016 </indexterm>
25017 This option, when true, enables extra checking in Exim&#x2019;s internal memory
25018 management.  For use when a memory corruption issue is being investigated,
25019 it should normally be left as default.
25020 </para>
25021 <para>
25022 <indexterm role="option">
25023 <primary><option>daemon_smtp_ports</option></primary>
25024 </indexterm>
25025 </para>
25026 <informaltable frame="all">
25027 <tgroup cols="4" colsep="0" rowsep="0">
25028 <colspec colwidth="8*" align="left"/>
25029 <colspec colwidth="6*" align="center"/>
25030 <colspec colwidth="6*" align="center"/>
25031 <colspec colwidth="6*" align="right"/>
25032 <tbody>
25033 <row>
25034 <entry><option>daemon_smtp_ports</option></entry>
25035 <entry>Use: <emphasis>main</emphasis></entry>
25036 <entry>Type: <emphasis>string</emphasis></entry>
25037 <entry>Default: <emphasis><literal>smtp</literal></emphasis></entry>
25038 </row>
25039 </tbody>
25040 </tgroup>
25041 </informaltable>
25042 <para>
25043 <indexterm role="concept">
25044 <primary>port</primary>
25045 <secondary>for daemon</secondary>
25046 </indexterm>
25047 <indexterm role="concept">
25048 <primary>TCP/IP</primary>
25049 <secondary>setting listening ports</secondary>
25050 </indexterm>
25051 This option specifies one or more default SMTP ports on which the Exim daemon
25052 listens. See chapter <xref linkend="CHAPinterfaces"/> for details of how it is used. For
25053 backward compatibility, <option>daemon_smtp_port</option> (singular) is a synonym.
25054 </para>
25055 <para>
25056 <indexterm role="option">
25057 <primary><option>daemon_startup_retries</option></primary>
25058 </indexterm>
25059 </para>
25060 <informaltable frame="all">
25061 <tgroup cols="4" colsep="0" rowsep="0">
25062 <colspec colwidth="8*" align="left"/>
25063 <colspec colwidth="6*" align="center"/>
25064 <colspec colwidth="6*" align="center"/>
25065 <colspec colwidth="6*" align="right"/>
25066 <tbody>
25067 <row>
25068 <entry><option>daemon_startup_retries</option></entry>
25069 <entry>Use: <emphasis>main</emphasis></entry>
25070 <entry>Type: <emphasis>integer</emphasis></entry>
25071 <entry>Default: <emphasis>9</emphasis></entry>
25072 </row>
25073 </tbody>
25074 </tgroup>
25075 </informaltable>
25076 <para>
25077 <indexterm role="concept">
25078 <primary>daemon startup, retrying</primary>
25079 </indexterm>
25080 This option, along with <option>daemon_startup_sleep</option>, controls the retrying done by
25081 the daemon at startup when it cannot immediately bind a listening socket
25082 (typically because the socket is already in use): <option>daemon_startup_retries</option>
25083 defines the number of retries after the first failure, and
25084 <option>daemon_startup_sleep</option> defines the length of time to wait between retries.
25085 </para>
25086 <para>
25087 <indexterm role="option">
25088 <primary><option>daemon_startup_sleep</option></primary>
25089 </indexterm>
25090 </para>
25091 <informaltable frame="all">
25092 <tgroup cols="4" colsep="0" rowsep="0">
25093 <colspec colwidth="8*" align="left"/>
25094 <colspec colwidth="6*" align="center"/>
25095 <colspec colwidth="6*" align="center"/>
25096 <colspec colwidth="6*" align="right"/>
25097 <tbody>
25098 <row>
25099 <entry><option>daemon_startup_sleep</option></entry>
25100 <entry>Use: <emphasis>main</emphasis></entry>
25101 <entry>Type: <emphasis>time</emphasis></entry>
25102 <entry>Default: <emphasis>30s</emphasis></entry>
25103 </row>
25104 </tbody>
25105 </tgroup>
25106 </informaltable>
25107 <para>
25108 See <option>daemon_startup_retries</option>.
25109 </para>
25110 <para>
25111 <indexterm role="option">
25112 <primary><option>delay_warning</option></primary>
25113 </indexterm>
25114 </para>
25115 <informaltable frame="all">
25116 <tgroup cols="4" colsep="0" rowsep="0">
25117 <colspec colwidth="8*" align="left"/>
25118 <colspec colwidth="6*" align="center"/>
25119 <colspec colwidth="6*" align="center"/>
25120 <colspec colwidth="6*" align="right"/>
25121 <tbody>
25122 <row>
25123 <entry><option>delay_warning</option></entry>
25124 <entry>Use: <emphasis>main</emphasis></entry>
25125 <entry>Type: <emphasis>time list</emphasis></entry>
25126 <entry>Default: <emphasis>24h</emphasis></entry>
25127 </row>
25128 </tbody>
25129 </tgroup>
25130 </informaltable>
25131 <para>
25132 <indexterm role="concept">
25133 <primary>warning of delay</primary>
25134 </indexterm>
25135 <indexterm role="concept">
25136 <primary>delay warning, specifying</primary>
25137 </indexterm>
25138 <indexterm role="concept">
25139 <primary>queue</primary>
25140 <secondary>delay warning</secondary>
25141 </indexterm>
25142 When a message is delayed, Exim sends a warning message to the sender at
25143 intervals specified by this option. The data is a colon-separated list of times
25144 after which to send warning messages. If the value of the option is an empty
25145 string or a zero time, no warnings are sent. Up to 10 times may be given. If a
25146 message has been in the queue for longer than the last time, the last interval
25147 between the times is used to compute subsequent warning times. For example,
25148 with
25149 </para>
25150 <literallayout class="monospaced">
25151 delay_warning = 4h:8h:24h
25152 </literallayout>
25153 <para>
25154 the first message is sent after 4 hours, the second after 8 hours, and
25155 the third one after 24 hours. After that, messages are sent every 16 hours,
25156 because that is the interval between the last two times on the list. If you set
25157 just one time, it specifies the repeat interval. For example, with:
25158 </para>
25159 <literallayout class="monospaced">
25160 delay_warning = 6h
25161 </literallayout>
25162 <para>
25163 messages are repeated every six hours. To stop warnings after a given time, set
25164 a very large time at the end of the list. For example:
25165 </para>
25166 <literallayout class="monospaced">
25167 delay_warning = 2h:12h:99d
25168 </literallayout>
25169 <para>
25170 Note that the option is only evaluated at the time a delivery attempt fails,
25171 which depends on retry and queue-runner configuration.
25172 Typically retries will be configured more frequently than warning messages.
25173 </para>
25174 <para>
25175 <indexterm role="option">
25176 <primary><option>delay_warning_condition</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>delay_warning_condition</option></entry>
25188 <entry>Use: <emphasis>main</emphasis></entry>
25189 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
25190 <entry>Default: <emphasis>see below</emphasis></entry>
25191 </row>
25192 </tbody>
25193 </tgroup>
25194 </informaltable>
25195 <para>
25196 <indexterm role="variable">
25197 <primary><varname>$domain</varname></primary>
25198 </indexterm>
25199 The string is expanded at the time a warning message might be sent. If all the
25200 deferred addresses have the same domain, it is set in <varname>$domain</varname> during the
25201 expansion. Otherwise <varname>$domain</varname> is empty. If the result of the expansion is a
25202 forced failure, an empty string, or a string matching any of <quote>0</quote>, <quote>no</quote> or
25203 <quote>false</quote> (the comparison being done caselessly) then the warning message is
25204 not sent. The default is:
25205 </para>
25206 <literallayout class="monospaced">
25207 delay_warning_condition = ${if or {\
25208   { !eq{$h_list-id:$h_list-post:$h_list-subscribe:}{} }\
25209   { match{$h_precedence:}{(?i)bulk|list|junk} }\
25210   { match{$h_auto-submitted:}{(?i)auto-generated|auto-replied} }\
25211   } {no}{yes}}
25212 </literallayout>
25213 <para>
25214 This suppresses the sending of warnings for messages that contain <emphasis>List-ID:</emphasis>,
25215 <emphasis>List-Post:</emphasis>, or <emphasis>List-Subscribe:</emphasis> headers, or have <quote>bulk</quote>, <quote>list</quote> or
25216 <quote>junk</quote> in a <emphasis>Precedence:</emphasis> header, or have <quote>auto-generated</quote> or
25217 <quote>auto-replied</quote> in an <emphasis>Auto-Submitted:</emphasis> header.
25218 </para>
25219 <para>
25220 <indexterm role="option">
25221 <primary><option>deliver_drop_privilege</option></primary>
25222 </indexterm>
25223 </para>
25224 <informaltable frame="all">
25225 <tgroup cols="4" colsep="0" rowsep="0">
25226 <colspec colwidth="8*" align="left"/>
25227 <colspec colwidth="6*" align="center"/>
25228 <colspec colwidth="6*" align="center"/>
25229 <colspec colwidth="6*" align="right"/>
25230 <tbody>
25231 <row>
25232 <entry><option>deliver_drop_privilege</option></entry>
25233 <entry>Use: <emphasis>main</emphasis></entry>
25234 <entry>Type: <emphasis>boolean</emphasis></entry>
25235 <entry>Default: <emphasis>false</emphasis></entry>
25236 </row>
25237 </tbody>
25238 </tgroup>
25239 </informaltable>
25240 <para>
25241 <indexterm role="concept">
25242 <primary>unprivileged delivery</primary>
25243 </indexterm>
25244 <indexterm role="concept">
25245 <primary>delivery</primary>
25246 <secondary>unprivileged</secondary>
25247 </indexterm>
25248 If this option is set true, Exim drops its root privilege at the start of a
25249 delivery process, and runs as the Exim user throughout. This severely restricts
25250 the kinds of local delivery that are possible, but is viable in certain types
25251 of configuration. There is a discussion about the use of root privilege in
25252 chapter <xref linkend="CHAPsecurity"/>.
25253 </para>
25254 <para>
25255 <indexterm role="option">
25256 <primary><option>deliver_queue_load_max</option></primary>
25257 </indexterm>
25258 </para>
25259 <informaltable frame="all">
25260 <tgroup cols="4" colsep="0" rowsep="0">
25261 <colspec colwidth="8*" align="left"/>
25262 <colspec colwidth="6*" align="center"/>
25263 <colspec colwidth="6*" align="center"/>
25264 <colspec colwidth="6*" align="right"/>
25265 <tbody>
25266 <row>
25267 <entry><option>deliver_queue_load_max</option></entry>
25268 <entry>Use: <emphasis>main</emphasis></entry>
25269 <entry>Type: <emphasis>fixed-point</emphasis></entry>
25270 <entry>Default: <emphasis>unset</emphasis></entry>
25271 </row>
25272 </tbody>
25273 </tgroup>
25274 </informaltable>
25275 <para>
25276 <indexterm role="concept">
25277 <primary>load average</primary>
25278 </indexterm>
25279 <indexterm role="concept">
25280 <primary>queue runner</primary>
25281 <secondary>abandoning</secondary>
25282 </indexterm>
25283 When this option is set, a queue run is abandoned if the system load average
25284 becomes greater than the value of the option. The option has no effect on
25285 ancient operating systems on which Exim cannot determine the load average.
25286 See also <option>queue_only_load</option> and <option>smtp_load_reserve</option>.
25287 </para>
25288 <para>
25289 <indexterm role="option">
25290 <primary><option>delivery_date_remove</option></primary>
25291 </indexterm>
25292 </para>
25293 <informaltable frame="all">
25294 <tgroup cols="4" colsep="0" rowsep="0">
25295 <colspec colwidth="8*" align="left"/>
25296 <colspec colwidth="6*" align="center"/>
25297 <colspec colwidth="6*" align="center"/>
25298 <colspec colwidth="6*" align="right"/>
25299 <tbody>
25300 <row>
25301 <entry><option>delivery_date_remove</option></entry>
25302 <entry>Use: <emphasis>main</emphasis></entry>
25303 <entry>Type: <emphasis>boolean</emphasis></entry>
25304 <entry>Default: <emphasis>true</emphasis></entry>
25305 </row>
25306 </tbody>
25307 </tgroup>
25308 </informaltable>
25309 <para>
25310 <indexterm role="concept">
25311 <primary><emphasis>Delivery-date:</emphasis> header line</primary>
25312 </indexterm>
25313 Exim&#x2019;s transports have an option for adding a <emphasis>Delivery-date:</emphasis> header to a
25314 message when it is delivered, in exactly the same way as <emphasis>Return-path:</emphasis> is
25315 handled. <emphasis>Delivery-date:</emphasis> records the actual time of delivery. Such headers
25316 should not be present in incoming messages, and this option causes them to be
25317 removed at the time the message is received, to avoid any problems that might
25318 occur when a delivered message is subsequently sent on to some other recipient.
25319 </para>
25320 <para>
25321 <indexterm role="option">
25322 <primary><option>disable_fsync</option></primary>
25323 </indexterm>
25324 </para>
25325 <informaltable frame="all">
25326 <tgroup cols="4" colsep="0" rowsep="0">
25327 <colspec colwidth="8*" align="left"/>
25328 <colspec colwidth="6*" align="center"/>
25329 <colspec colwidth="6*" align="center"/>
25330 <colspec colwidth="6*" align="right"/>
25331 <tbody>
25332 <row>
25333 <entry><option>disable_fsync</option></entry>
25334 <entry>Use: <emphasis>main</emphasis></entry>
25335 <entry>Type: <emphasis>boolean</emphasis></entry>
25336 <entry>Default: <emphasis>false</emphasis></entry>
25337 </row>
25338 </tbody>
25339 </tgroup>
25340 </informaltable>
25341 <para>
25342 <indexterm role="concept">
25343 <primary><function>fsync()</function>, disabling</primary>
25344 </indexterm>
25345 This option is available only if Exim was built with the compile-time option
25346 ENABLE_DISABLE_FSYNC. When this is not set, a reference to <option>disable_fsync</option> in
25347 a runtime configuration generates an <quote>unknown option</quote> error. You should not
25348 build Exim with ENABLE_DISABLE_FSYNC or set <option>disable_fsync</option> unless you
25349 really, really, really understand what you are doing. <emphasis>No pre-compiled
25350 distributions of Exim should ever make this option available.</emphasis>
25351 </para>
25352 <para>
25353 When <option>disable_fsync</option> is set true, Exim no longer calls <function>fsync()</function> to force
25354 updated files&#x2019; data to be written to disc before continuing. Unexpected events
25355 such as crashes and power outages may cause data to be lost or scrambled.
25356 Here be Dragons. <emphasis role="bold">Beware.</emphasis>
25357 </para>
25358 <para>
25359 <indexterm role="option">
25360 <primary><option>disable_ipv6</option></primary>
25361 </indexterm>
25362 </para>
25363 <informaltable frame="all">
25364 <tgroup cols="4" colsep="0" rowsep="0">
25365 <colspec colwidth="8*" align="left"/>
25366 <colspec colwidth="6*" align="center"/>
25367 <colspec colwidth="6*" align="center"/>
25368 <colspec colwidth="6*" align="right"/>
25369 <tbody>
25370 <row>
25371 <entry><option>disable_ipv6</option></entry>
25372 <entry>Use: <emphasis>main</emphasis></entry>
25373 <entry>Type: <emphasis>boolean</emphasis></entry>
25374 <entry>Default: <emphasis>false</emphasis></entry>
25375 </row>
25376 </tbody>
25377 </tgroup>
25378 </informaltable>
25379 <para>
25380 <indexterm role="concept">
25381 <primary>IPv6</primary>
25382 <secondary>disabling</secondary>
25383 </indexterm>
25384 If this option is set true, even if the Exim binary has IPv6 support, no IPv6
25385 activities take place. AAAA records are never looked up, and any IPv6 addresses
25386 that are listed in <option>local_interfaces</option>, data for the <option>manualroute</option> router,
25387 etc. are ignored. If IP literals are enabled, the <command>ipliteral</command> router declines
25388 to handle IPv6 literal addresses.
25389 </para>
25390 <para revisionflag="changed">
25391 <indexterm role="option">
25392 <primary><option>dkim_verify_hashes</option></primary>
25393 </indexterm>
25394 </para>
25395 <informaltable frame="all" revisionflag="changed">
25396 <tgroup cols="4" colsep="0" rowsep="0">
25397 <colspec colwidth="8*" align="left"/>
25398 <colspec colwidth="6*" align="center"/>
25399 <colspec colwidth="6*" align="center"/>
25400 <colspec colwidth="6*" align="right"/>
25401 <tbody>
25402 <row>
25403 <entry><option>dkim_verify_hashes</option></entry>
25404 <entry>Use: <emphasis>main</emphasis></entry>
25405 <entry>Type: <emphasis>string list</emphasis></entry>
25406 <entry>Default: <emphasis>sha256 : sha512 : sha1</emphasis></entry>
25407 </row>
25408 </tbody>
25409 </tgroup>
25410 </informaltable>
25411 <para revisionflag="changed">
25412 <indexterm role="concept">
25413 <primary>DKIM</primary>
25414 <secondary>selecting signature algorithms</secondary>
25415 </indexterm>
25416 This option gives a list of hash types which are acceptable in signatures,
25417 and an order of processing.
25418 Signatures with algorithms not in the list will be ignored.
25419 </para>
25420 <para revisionflag="changed">
25421 Note that the presence of sha1 violates RFC 8301.
25422 Signatures using the rsa-sha1 are however (as of writing) still common.
25423 The default inclusion of sha1 may be dropped in a future release.
25424 </para>
25425 <para revisionflag="changed">
25426 <indexterm role="option">
25427 <primary><option>dkim_verify_keytypes</option></primary>
25428 </indexterm>
25429 </para>
25430 <informaltable frame="all" revisionflag="changed">
25431 <tgroup cols="4" colsep="0" rowsep="0">
25432 <colspec colwidth="8*" align="left"/>
25433 <colspec colwidth="6*" align="center"/>
25434 <colspec colwidth="6*" align="center"/>
25435 <colspec colwidth="6*" align="right"/>
25436 <tbody>
25437 <row>
25438 <entry><option>dkim_verify_keytypes</option></entry>
25439 <entry>Use: <emphasis>main</emphasis></entry>
25440 <entry>Type: <emphasis>string list</emphasis></entry>
25441 <entry>Default: <emphasis>ed25519 : rsa</emphasis></entry>
25442 </row>
25443 </tbody>
25444 </tgroup>
25445 </informaltable>
25446 <para revisionflag="changed">
25447 This option gives a list of key types which are acceptable in signatures,
25448 and an order of processing.
25449 Signatures with algorithms not in the list will be ignored.
25450 </para>
25451 <para revisionflag="changed">
25452 <indexterm role="option">
25453 <primary><option>dkim_verify_minimal</option></primary>
25454 </indexterm>
25455 </para>
25456 <informaltable frame="all" revisionflag="changed">
25457 <tgroup cols="4" colsep="0" rowsep="0">
25458 <colspec colwidth="8*" align="left"/>
25459 <colspec colwidth="6*" align="center"/>
25460 <colspec colwidth="6*" align="center"/>
25461 <colspec colwidth="6*" align="right"/>
25462 <tbody>
25463 <row>
25464 <entry><option>dkim_verify_minimal</option></entry>
25465 <entry>Use: <emphasis>main</emphasis></entry>
25466 <entry>Type: <emphasis>boolean</emphasis></entry>
25467 <entry>Default: <emphasis>false</emphasis></entry>
25468 </row>
25469 </tbody>
25470 </tgroup>
25471 </informaltable>
25472 <para revisionflag="changed">
25473 If set to true, verification of signatures will terminate after the
25474 first success.
25475 </para>
25476 <para>
25477 <indexterm role="option">
25478 <primary><option>dkim_verify_signers</option></primary>
25479 </indexterm>
25480 </para>
25481 <informaltable frame="all">
25482 <tgroup cols="4" colsep="0" rowsep="0">
25483 <colspec colwidth="8*" align="left"/>
25484 <colspec colwidth="6*" align="center"/>
25485 <colspec colwidth="6*" align="center"/>
25486 <colspec colwidth="6*" align="right"/>
25487 <tbody>
25488 <row>
25489 <entry><option>dkim_verify_signers</option></entry>
25490 <entry>Use: <emphasis>main</emphasis></entry>
25491 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
25492 <entry>Default: <emphasis>$dkim_signers</emphasis></entry>
25493 </row>
25494 </tbody>
25495 </tgroup>
25496 </informaltable>
25497 <para>
25498 <indexterm role="concept">
25499 <primary>DKIM</primary>
25500 <secondary>controlling calls to the ACL</secondary>
25501 </indexterm>
25502 This option gives a list of DKIM domains for which the DKIM ACL is run.
25503 It is expanded after the message is received; by default it runs
25504 the ACL once for each signature in the message.
25505 See section <xref linkend="SECDKIMVFY"/>.
25506 </para>
25507 <para>
25508 <indexterm role="option">
25509 <primary><option>dns_again_means_nonexist</option></primary>
25510 </indexterm>
25511 </para>
25512 <informaltable frame="all">
25513 <tgroup cols="4" colsep="0" rowsep="0">
25514 <colspec colwidth="8*" align="left"/>
25515 <colspec colwidth="6*" align="center"/>
25516 <colspec colwidth="6*" align="center"/>
25517 <colspec colwidth="6*" align="right"/>
25518 <tbody>
25519 <row>
25520 <entry><option>dns_again_means_nonexist</option></entry>
25521 <entry>Use: <emphasis>main</emphasis></entry>
25522 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
25523 <entry>Default: <emphasis>unset</emphasis></entry>
25524 </row>
25525 </tbody>
25526 </tgroup>
25527 </informaltable>
25528 <para>
25529 <indexterm role="concept">
25530 <primary>DNS</primary>
25531 <secondary><quote>try again</quote> response; overriding</secondary>
25532 </indexterm>
25533 DNS lookups give a <quote>try again</quote> response for the DNS errors
25534 <quote>non-authoritative host not found</quote> and <quote>SERVERFAIL</quote>. This can cause Exim to
25535 keep trying to deliver a message, or to give repeated temporary errors to
25536 incoming mail. Sometimes the effect is caused by a badly set up name server and
25537 may persist for a long time. If a domain which exhibits this problem matches
25538 anything in <option>dns_again_means_nonexist</option>, it is treated as if it did not exist.
25539 This option should be used with care. You can make it apply to reverse lookups
25540 by a setting such as this:
25541 </para>
25542 <literallayout class="monospaced">
25543 dns_again_means_nonexist = *.in-addr.arpa
25544 </literallayout>
25545 <para>
25546 This option applies to all DNS lookups that Exim does. It also applies when the
25547 <function>gethostbyname()</function> or <function>getipnodebyname()</function> functions give temporary errors,
25548 since these are most likely to be caused by DNS lookup problems. The
25549 <command>dnslookup</command> router has some options of its own for controlling what happens
25550 when lookups for MX or SRV records give temporary errors. These more specific
25551 options are applied after this global option.
25552 </para>
25553 <para>
25554 <indexterm role="option">
25555 <primary><option>dns_check_names_pattern</option></primary>
25556 </indexterm>
25557 </para>
25558 <informaltable frame="all">
25559 <tgroup cols="4" colsep="0" rowsep="0">
25560 <colspec colwidth="8*" align="left"/>
25561 <colspec colwidth="6*" align="center"/>
25562 <colspec colwidth="6*" align="center"/>
25563 <colspec colwidth="6*" align="right"/>
25564 <tbody>
25565 <row>
25566 <entry><option>dns_check_names_pattern</option></entry>
25567 <entry>Use: <emphasis>main</emphasis></entry>
25568 <entry>Type: <emphasis>string</emphasis></entry>
25569 <entry>Default: <emphasis>see below</emphasis></entry>
25570 </row>
25571 </tbody>
25572 </tgroup>
25573 </informaltable>
25574 <para>
25575 <indexterm role="concept">
25576 <primary>DNS</primary>
25577 <secondary>pre-check of name syntax</secondary>
25578 </indexterm>
25579 When this option is set to a non-empty string, it causes Exim to check domain
25580 names for characters that are not allowed in host names before handing them to
25581 the DNS resolver, because some resolvers give temporary errors for names that
25582 contain unusual characters. If a domain name contains any unwanted characters,
25583 a <quote>not found</quote> result is forced, and the resolver is not called. The check is
25584 done by matching the domain name against a regular expression, which is the
25585 value of this option. The default pattern is
25586 </para>
25587 <literallayout class="monospaced">
25588 dns_check_names_pattern = \
25589   (?i)^(?&gt;(?(1)\.|())[^\W_](?&gt;[a-z0-9/-]*[^\W_])?)+$
25590 </literallayout>
25591 <para>
25592 which permits only letters, digits, slashes, and hyphens in components, but
25593 they must start and end with a letter or digit. Slashes are not, in fact,
25594 permitted in host names, but they are found in certain NS records (which can be
25595 accessed in Exim by using a <option>dnsdb</option> lookup). If you set
25596 <option>allow_utf8_domains</option>, you must modify this pattern, or set the option to an
25597 empty string.
25598 </para>
25599 <para>
25600 <indexterm role="option">
25601 <primary><option>dns_csa_search_limit</option></primary>
25602 </indexterm>
25603 </para>
25604 <informaltable frame="all">
25605 <tgroup cols="4" colsep="0" rowsep="0">
25606 <colspec colwidth="8*" align="left"/>
25607 <colspec colwidth="6*" align="center"/>
25608 <colspec colwidth="6*" align="center"/>
25609 <colspec colwidth="6*" align="right"/>
25610 <tbody>
25611 <row>
25612 <entry><option>dns_csa_search_limit</option></entry>
25613 <entry>Use: <emphasis>main</emphasis></entry>
25614 <entry>Type: <emphasis>integer</emphasis></entry>
25615 <entry>Default: <emphasis>5</emphasis></entry>
25616 </row>
25617 </tbody>
25618 </tgroup>
25619 </informaltable>
25620 <para>
25621 This option controls the depth of parental searching for CSA SRV records in the
25622 DNS, as described in more detail in section <xref linkend="SECTverifyCSA"/>.
25623 </para>
25624 <para>
25625 <indexterm role="option">
25626 <primary><option>dns_csa_use_reverse</option></primary>
25627 </indexterm>
25628 </para>
25629 <informaltable frame="all">
25630 <tgroup cols="4" colsep="0" rowsep="0">
25631 <colspec colwidth="8*" align="left"/>
25632 <colspec colwidth="6*" align="center"/>
25633 <colspec colwidth="6*" align="center"/>
25634 <colspec colwidth="6*" align="right"/>
25635 <tbody>
25636 <row>
25637 <entry><option>dns_csa_use_reverse</option></entry>
25638 <entry>Use: <emphasis>main</emphasis></entry>
25639 <entry>Type: <emphasis>boolean</emphasis></entry>
25640 <entry>Default: <emphasis>true</emphasis></entry>
25641 </row>
25642 </tbody>
25643 </tgroup>
25644 </informaltable>
25645 <para>
25646 This option controls whether or not an IP address, given as a CSA domain, is
25647 reversed and looked up in the reverse DNS, as described in more detail in
25648 section <xref linkend="SECTverifyCSA"/>.
25649 </para>
25650 <para>
25651 <indexterm role="option">
25652 <primary><option>dns_cname_loops</option></primary>
25653 </indexterm>
25654 </para>
25655 <informaltable frame="all">
25656 <tgroup cols="4" colsep="0" rowsep="0">
25657 <colspec colwidth="8*" align="left"/>
25658 <colspec colwidth="6*" align="center"/>
25659 <colspec colwidth="6*" align="center"/>
25660 <colspec colwidth="6*" align="right"/>
25661 <tbody>
25662 <row>
25663 <entry><option>dns_cname_loops</option></entry>
25664 <entry>Use: <emphasis>main</emphasis></entry>
25665 <entry>Type: <emphasis>integer</emphasis></entry>
25666 <entry>Default: <emphasis>1</emphasis></entry>
25667 </row>
25668 </tbody>
25669 </tgroup>
25670 </informaltable>
25671 <para>
25672 <indexterm role="concept">
25673 <primary>DNS</primary>
25674 <secondary>CNAME following</secondary>
25675 </indexterm>
25676 This option controls the following of CNAME chains, needed if the resolver does
25677 not do it internally.
25678 As of 2018 most should, and the default can be left.
25679 If you have an ancient one, a value of 10 is likely needed.
25680 </para>
25681 <para>
25682 The default value of one CNAME-follow is needed
25683 thanks to the observed return for an MX request,
25684 given no MX presence but a CNAME to an A, of the CNAME.
25685 </para>
25686 <para>
25687 <indexterm role="option">
25688 <primary><option>dns_dnssec_ok</option></primary>
25689 </indexterm>
25690 </para>
25691 <informaltable frame="all">
25692 <tgroup cols="4" colsep="0" rowsep="0">
25693 <colspec colwidth="8*" align="left"/>
25694 <colspec colwidth="6*" align="center"/>
25695 <colspec colwidth="6*" align="center"/>
25696 <colspec colwidth="6*" align="right"/>
25697 <tbody>
25698 <row>
25699 <entry><option>dns_dnssec_ok</option></entry>
25700 <entry>Use: <emphasis>main</emphasis></entry>
25701 <entry>Type: <emphasis>integer</emphasis></entry>
25702 <entry>Default: <emphasis>-1</emphasis></entry>
25703 </row>
25704 </tbody>
25705 </tgroup>
25706 </informaltable>
25707 <para>
25708 <indexterm role="concept">
25709 <primary>DNS</primary>
25710 <secondary>resolver options</secondary>
25711 </indexterm>
25712 <indexterm role="concept">
25713 <primary>DNS</primary>
25714 <secondary>DNSSEC</secondary>
25715 </indexterm>
25716 If this option is set to a non-negative number then Exim will initialise the
25717 DNS resolver library to either use or not use DNSSEC, overriding the system
25718 default. A value of 0 coerces DNSSEC off, a value of 1 coerces DNSSEC on.
25719 </para>
25720 <para>
25721 If the resolver library does not support DNSSEC then this option has no effect.
25722 </para>
25723 <para>
25724 <indexterm role="option">
25725 <primary><option>dns_ipv4_lookup</option></primary>
25726 </indexterm>
25727 </para>
25728 <informaltable frame="all">
25729 <tgroup cols="4" colsep="0" rowsep="0">
25730 <colspec colwidth="8*" align="left"/>
25731 <colspec colwidth="6*" align="center"/>
25732 <colspec colwidth="6*" align="center"/>
25733 <colspec colwidth="6*" align="right"/>
25734 <tbody>
25735 <row>
25736 <entry><option>dns_ipv4_lookup</option></entry>
25737 <entry>Use: <emphasis>main</emphasis></entry>
25738 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
25739 <entry>Default: <emphasis>unset</emphasis></entry>
25740 </row>
25741 </tbody>
25742 </tgroup>
25743 </informaltable>
25744 <para>
25745 <indexterm role="concept">
25746 <primary>IPv6</primary>
25747 <secondary>DNS lookup for AAAA records</secondary>
25748 </indexterm>
25749 <indexterm role="concept">
25750 <primary>DNS</primary>
25751 <secondary>IPv6 lookup for AAAA records</secondary>
25752 </indexterm>
25753 <indexterm role="concept">
25754 <primary>DNS</primary>
25755 <secondary>IPv6 disabling</secondary>
25756 </indexterm>
25757 When Exim is compiled with IPv6 support and <option>disable_ipv6</option> is not set, it
25758 looks for IPv6 address records (AAAA records) as well as IPv4 address records
25759 (A records) when trying to find IP addresses for hosts, unless the host&#x2019;s
25760 domain matches this list.
25761 </para>
25762 <para>
25763 This is a fudge to help with name servers that give big delays or otherwise do
25764 not work for the AAAA record type. In due course, when the world&#x2019;s name
25765 servers have all been upgraded, there should be no need for this option.
25766 </para>
25767 <para revisionflag="changed">
25768 Note that all lookups, including those done for verification, are affected;
25769 this will result in verify failure for IPv6 connections or ones using names
25770 only valid for IPv6 addresses.
25771 </para>
25772 <para>
25773 <indexterm role="option">
25774 <primary><option>dns_retrans</option></primary>
25775 </indexterm>
25776 </para>
25777 <informaltable frame="all">
25778 <tgroup cols="4" colsep="0" rowsep="0">
25779 <colspec colwidth="8*" align="left"/>
25780 <colspec colwidth="6*" align="center"/>
25781 <colspec colwidth="6*" align="center"/>
25782 <colspec colwidth="6*" align="right"/>
25783 <tbody>
25784 <row>
25785 <entry><option>dns_retrans</option></entry>
25786 <entry>Use: <emphasis>main</emphasis></entry>
25787 <entry>Type: <emphasis>time</emphasis></entry>
25788 <entry>Default: <emphasis>0s</emphasis></entry>
25789 </row>
25790 </tbody>
25791 </tgroup>
25792 </informaltable>
25793 <para>
25794 <indexterm role="concept">
25795 <primary>DNS</primary>
25796 <secondary>resolver options</secondary>
25797 </indexterm>
25798 <indexterm role="concept">
25799 <primary>timeout</primary>
25800 <secondary>dns lookup</secondary>
25801 </indexterm>
25802 <indexterm role="concept">
25803 <primary>DNS</primary>
25804 <secondary>timeout</secondary>
25805 </indexterm>
25806 The options <option>dns_retrans</option> and <option>dns_retry</option> can be used to set the
25807 retransmission and retry parameters for DNS lookups. Values of zero (the
25808 defaults) leave the system default settings unchanged. The first value is the
25809 time between retries, and the second is the number of retries. It isn&#x2019;t
25810 totally clear exactly how these settings affect the total time a DNS lookup may
25811 take. I haven&#x2019;t found any documentation about timeouts on DNS lookups; these
25812 parameter values are available in the external resolver interface structure,
25813 but nowhere does it seem to describe how they are used or what you might want
25814 to set in them.
25815 See also the <option>slow_lookup_log</option> option.
25816 </para>
25817 <para>
25818 <indexterm role="option">
25819 <primary><option>dns_retry</option></primary>
25820 </indexterm>
25821 </para>
25822 <informaltable frame="all">
25823 <tgroup cols="4" colsep="0" rowsep="0">
25824 <colspec colwidth="8*" align="left"/>
25825 <colspec colwidth="6*" align="center"/>
25826 <colspec colwidth="6*" align="center"/>
25827 <colspec colwidth="6*" align="right"/>
25828 <tbody>
25829 <row>
25830 <entry><option>dns_retry</option></entry>
25831 <entry>Use: <emphasis>main</emphasis></entry>
25832 <entry>Type: <emphasis>integer</emphasis></entry>
25833 <entry>Default: <emphasis>0</emphasis></entry>
25834 </row>
25835 </tbody>
25836 </tgroup>
25837 </informaltable>
25838 <para>
25839 See <option>dns_retrans</option> above.
25840 </para>
25841 <para>
25842 <indexterm role="option">
25843 <primary><option>dns_trust_aa</option></primary>
25844 </indexterm>
25845 </para>
25846 <informaltable frame="all">
25847 <tgroup cols="4" colsep="0" rowsep="0">
25848 <colspec colwidth="8*" align="left"/>
25849 <colspec colwidth="6*" align="center"/>
25850 <colspec colwidth="6*" align="center"/>
25851 <colspec colwidth="6*" align="right"/>
25852 <tbody>
25853 <row>
25854 <entry><option>dns_trust_aa</option></entry>
25855 <entry>Use: <emphasis>main</emphasis></entry>
25856 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
25857 <entry>Default: <emphasis>unset</emphasis></entry>
25858 </row>
25859 </tbody>
25860 </tgroup>
25861 </informaltable>
25862 <para>
25863 <indexterm role="concept">
25864 <primary>DNS</primary>
25865 <secondary>resolver options</secondary>
25866 </indexterm>
25867 <indexterm role="concept">
25868 <primary>DNS</primary>
25869 <secondary>DNSSEC</secondary>
25870 </indexterm>
25871 If this option is set then lookup results marked with the AA bit
25872 (Authoritative Answer) are trusted the same way as if they were
25873 DNSSEC-verified. The authority section&#x2019;s name of the answer must
25874 match with this expanded domain list.
25875 </para>
25876 <para>
25877 Use this option only if you talk directly to a resolver that is
25878 authoritative for some zones and does not set the AD (Authentic Data)
25879 bit in the answer. Some DNS servers may have an configuration option to
25880 mark the answers from their own zones as verified (they set the AD bit).
25881 Others do not have this option. It is considered as poor practice using
25882 a resolver that is an authoritative server for some zones.
25883 </para>
25884 <para>
25885 Use this option only if you really have to (e.g. if you want
25886 to use DANE for remote delivery to a server that is listed in the DNS
25887 zones that your resolver is authoritative for).
25888 </para>
25889 <para>
25890 If the DNS answer packet has the AA bit set and contains resource record
25891 in the answer section, the name of the first NS record appearing in the
25892 authority section is compared against the list. If the answer packet is
25893 authoritative but the answer section is empty, the name of the first SOA
25894 record in the authoritative section is used instead.
25895 </para>
25896 <para>
25897 <indexterm role="concept">
25898 <primary>DNS</primary>
25899 <secondary>resolver options</secondary>
25900 </indexterm>
25901 <indexterm role="option">
25902 <primary><option>dns_use_edns0</option></primary>
25903 </indexterm>
25904 </para>
25905 <informaltable frame="all">
25906 <tgroup cols="4" colsep="0" rowsep="0">
25907 <colspec colwidth="8*" align="left"/>
25908 <colspec colwidth="6*" align="center"/>
25909 <colspec colwidth="6*" align="center"/>
25910 <colspec colwidth="6*" align="right"/>
25911 <tbody>
25912 <row>
25913 <entry><option>dns_use_edns0</option></entry>
25914 <entry>Use: <emphasis>main</emphasis></entry>
25915 <entry>Type: <emphasis>integer</emphasis></entry>
25916 <entry>Default: <emphasis>-1</emphasis></entry>
25917 </row>
25918 </tbody>
25919 </tgroup>
25920 </informaltable>
25921 <para>
25922 <indexterm role="concept">
25923 <primary>DNS</primary>
25924 <secondary>resolver options</secondary>
25925 </indexterm>
25926 <indexterm role="concept">
25927 <primary>DNS</primary>
25928 <secondary>EDNS0</secondary>
25929 </indexterm>
25930 <indexterm role="concept">
25931 <primary>DNS</primary>
25932 <secondary>OpenBSD</secondary>
25933 </indexterm>
25934 If this option is set to a non-negative number then Exim will initialise the
25935 DNS resolver library to either use or not use EDNS0 extensions, overriding
25936 the system default. A value of 0 coerces EDNS0 off, a value of 1 coerces EDNS0
25937 on.
25938 </para>
25939 <para>
25940 If the resolver library does not support EDNS0 then this option has no effect.
25941 </para>
25942 <para>
25943 OpenBSD&#x2019;s asr resolver routines are known to ignore the EDNS0 option; this
25944 means that DNSSEC will not work with Exim on that platform either, unless Exim
25945 is linked against an alternative DNS client library.
25946 </para>
25947 <para>
25948 <indexterm role="option">
25949 <primary><option>drop_cr</option></primary>
25950 </indexterm>
25951 </para>
25952 <informaltable frame="all">
25953 <tgroup cols="4" colsep="0" rowsep="0">
25954 <colspec colwidth="8*" align="left"/>
25955 <colspec colwidth="6*" align="center"/>
25956 <colspec colwidth="6*" align="center"/>
25957 <colspec colwidth="6*" align="right"/>
25958 <tbody>
25959 <row>
25960 <entry><option>drop_cr</option></entry>
25961 <entry>Use: <emphasis>main</emphasis></entry>
25962 <entry>Type: <emphasis>boolean</emphasis></entry>
25963 <entry>Default: <emphasis>false</emphasis></entry>
25964 </row>
25965 </tbody>
25966 </tgroup>
25967 </informaltable>
25968 <para>
25969 This is an obsolete option that is now a no-op. It used to affect the way Exim
25970 handled CR and LF characters in incoming messages. What happens now is
25971 described in section <xref linkend="SECTlineendings"/>.
25972 </para>
25973 <para>
25974 <indexterm role="option">
25975 <primary><option>dsn_advertise_hosts</option></primary>
25976 </indexterm>
25977 </para>
25978 <informaltable frame="all">
25979 <tgroup cols="4" colsep="0" rowsep="0">
25980 <colspec colwidth="8*" align="left"/>
25981 <colspec colwidth="6*" align="center"/>
25982 <colspec colwidth="6*" align="center"/>
25983 <colspec colwidth="6*" align="right"/>
25984 <tbody>
25985 <row>
25986 <entry><option>dsn_advertise_hosts</option></entry>
25987 <entry>Use: <emphasis>main</emphasis></entry>
25988 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
25989 <entry>Default: <emphasis>unset</emphasis></entry>
25990 </row>
25991 </tbody>
25992 </tgroup>
25993 </informaltable>
25994 <para>
25995 <indexterm role="concept">
25996 <primary>bounce messages</primary>
25997 <secondary>success</secondary>
25998 </indexterm>
25999 <indexterm role="concept">
26000 <primary>DSN</primary>
26001 <secondary>success</secondary>
26002 </indexterm>
26003 <indexterm role="concept">
26004 <primary>Delivery Status Notification</primary>
26005 <secondary>success</secondary>
26006 </indexterm>
26007 DSN extensions (RFC3461) will be advertised in the EHLO message to,
26008 and accepted from, these hosts.
26009 Hosts may use the NOTIFY and ENVID options on RCPT TO commands,
26010 and RET and ORCPT options on MAIL FROM commands.
26011 A NOTIFY=SUCCESS option requests success-DSN messages.
26012 A NOTIFY= option with no argument requests that no delay or failure DSNs
26013 are sent.
26014 </para>
26015 <para>
26016 <indexterm role="option">
26017 <primary><option>dsn_from</option></primary>
26018 </indexterm>
26019 </para>
26020 <informaltable frame="all">
26021 <tgroup cols="4" colsep="0" rowsep="0">
26022 <colspec colwidth="8*" align="left"/>
26023 <colspec colwidth="6*" align="center"/>
26024 <colspec colwidth="6*" align="center"/>
26025 <colspec colwidth="6*" align="right"/>
26026 <tbody>
26027 <row>
26028 <entry><option>dsn_from</option></entry>
26029 <entry>Use: <emphasis>main</emphasis></entry>
26030 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26031 <entry>Default: <emphasis>see below</emphasis></entry>
26032 </row>
26033 </tbody>
26034 </tgroup>
26035 </informaltable>
26036 <para>
26037 <indexterm role="concept">
26038 <primary><emphasis>From:</emphasis> header line</primary>
26039 <secondary>in bounces</secondary>
26040 </indexterm>
26041 <indexterm role="concept">
26042 <primary>bounce messages</primary>
26043 <secondary><emphasis>From:</emphasis> line, specifying</secondary>
26044 </indexterm>
26045 This option can be used to vary the contents of <emphasis>From:</emphasis> header lines in
26046 bounces and other automatically generated messages (<quote>Delivery Status
26047 Notifications</quote> &ndash; hence the name of the option). The default setting is:
26048 </para>
26049 <literallayout class="monospaced">
26050 dsn_from = Mail Delivery System &lt;Mailer-Daemon@$qualify_domain&gt;
26051 </literallayout>
26052 <para>
26053 The value is expanded every time it is needed. If the expansion fails, a
26054 panic is logged, and the default value is used.
26055 </para>
26056 <para>
26057 <indexterm role="option">
26058 <primary><option>envelope_to_remove</option></primary>
26059 </indexterm>
26060 </para>
26061 <informaltable frame="all">
26062 <tgroup cols="4" colsep="0" rowsep="0">
26063 <colspec colwidth="8*" align="left"/>
26064 <colspec colwidth="6*" align="center"/>
26065 <colspec colwidth="6*" align="center"/>
26066 <colspec colwidth="6*" align="right"/>
26067 <tbody>
26068 <row>
26069 <entry><option>envelope_to_remove</option></entry>
26070 <entry>Use: <emphasis>main</emphasis></entry>
26071 <entry>Type: <emphasis>boolean</emphasis></entry>
26072 <entry>Default: <emphasis>true</emphasis></entry>
26073 </row>
26074 </tbody>
26075 </tgroup>
26076 </informaltable>
26077 <para>
26078 <indexterm role="concept">
26079 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
26080 </indexterm>
26081 Exim&#x2019;s transports have an option for adding an <emphasis>Envelope-to:</emphasis> header to a
26082 message when it is delivered, in exactly the same way as <emphasis>Return-path:</emphasis> is
26083 handled. <emphasis>Envelope-to:</emphasis> records the original recipient address from the
26084 message&#x2019;s envelope that caused the delivery to happen. Such headers should not
26085 be present in incoming messages, and this option causes them to be removed at
26086 the time the message is received, to avoid any problems that might occur when a
26087 delivered message is subsequently sent on to some other recipient.
26088 </para>
26089 <para>
26090 <indexterm role="option">
26091 <primary><option>errors_copy</option></primary>
26092 </indexterm>
26093 </para>
26094 <informaltable frame="all">
26095 <tgroup cols="4" colsep="0" rowsep="0">
26096 <colspec colwidth="8*" align="left"/>
26097 <colspec colwidth="6*" align="center"/>
26098 <colspec colwidth="6*" align="center"/>
26099 <colspec colwidth="6*" align="right"/>
26100 <tbody>
26101 <row>
26102 <entry><option>errors_copy</option></entry>
26103 <entry>Use: <emphasis>main</emphasis></entry>
26104 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
26105 <entry>Default: <emphasis>unset</emphasis></entry>
26106 </row>
26107 </tbody>
26108 </tgroup>
26109 </informaltable>
26110 <para>
26111 <indexterm role="concept">
26112 <primary>bounce message</primary>
26113 <secondary>copy to other address</secondary>
26114 </indexterm>
26115 <indexterm role="concept">
26116 <primary>copy of bounce message</primary>
26117 </indexterm>
26118 Setting this option causes Exim to send bcc copies of bounce messages that it
26119 generates to other addresses. <emphasis role="bold">Note</emphasis>: This does not apply to bounce messages
26120 coming from elsewhere. The value of the option is a colon-separated list of
26121 items. Each item consists of a pattern, terminated by white space, followed by
26122 a comma-separated list of email addresses. If a pattern contains spaces, it
26123 must be enclosed in double quotes.
26124 </para>
26125 <para>
26126 Each pattern is processed in the same way as a single item in an address list
26127 (see section <xref linkend="SECTaddresslist"/>). When a pattern matches the recipient of
26128 the bounce message, the message is copied to the addresses on the list. The
26129 items are scanned in order, and once a matching one is found, no further items
26130 are examined. For example:
26131 </para>
26132 <literallayout class="monospaced">
26133 errors_copy = spqr@mydomain   postmaster@mydomain.example :\
26134               rqps@mydomain   hostmaster@mydomain.example,\
26135                               postmaster@mydomain.example
26136 </literallayout>
26137 <para>
26138 <indexterm role="variable">
26139 <primary><varname>$domain</varname></primary>
26140 </indexterm>
26141 <indexterm role="variable">
26142 <primary><varname>$local_part</varname></primary>
26143 </indexterm>
26144 The address list is expanded before use. The expansion variables <varname>$local_part</varname>
26145 and <varname>$domain</varname> are set from the original recipient of the error message, and if
26146 there was any wildcard matching in the pattern, the expansion
26147 <indexterm role="concept">
26148 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
26149 <secondary>in <option>errors_copy</option></secondary>
26150 </indexterm>
26151 variables <varname>$0</varname>, <varname>$1</varname>, etc. are set in the normal way.
26152 </para>
26153 <para>
26154 <indexterm role="option">
26155 <primary><option>errors_reply_to</option></primary>
26156 </indexterm>
26157 </para>
26158 <informaltable frame="all">
26159 <tgroup cols="4" colsep="0" rowsep="0">
26160 <colspec colwidth="8*" align="left"/>
26161 <colspec colwidth="6*" align="center"/>
26162 <colspec colwidth="6*" align="center"/>
26163 <colspec colwidth="6*" align="right"/>
26164 <tbody>
26165 <row>
26166 <entry><option>errors_reply_to</option></entry>
26167 <entry>Use: <emphasis>main</emphasis></entry>
26168 <entry>Type: <emphasis>string</emphasis></entry>
26169 <entry>Default: <emphasis>unset</emphasis></entry>
26170 </row>
26171 </tbody>
26172 </tgroup>
26173 </informaltable>
26174 <para>
26175 <indexterm role="concept">
26176 <primary>bounce message</primary>
26177 <secondary><emphasis>Reply-to:</emphasis> in</secondary>
26178 </indexterm>
26179 By default, Exim&#x2019;s bounce and delivery warning messages contain the header line
26180 </para>
26181 <literallayout>
26182 <literal>From: Mail Delivery System &lt;Mailer-Daemon@</literal><emphasis>qualify-domain</emphasis><literal>&gt;</literal>
26183 </literallayout>
26184 <para>
26185 <indexterm role="option">
26186 <primary><option>quota_warn_message</option></primary>
26187 </indexterm>
26188 where <emphasis>qualify-domain</emphasis> is the value of the <option>qualify_domain</option> option.
26189 A warning message that is generated by the <option>quota_warn_message</option> option in an
26190 <command>appendfile</command> transport may contain its own <emphasis>From:</emphasis> header line that
26191 overrides the default.
26192 </para>
26193 <para>
26194 Experience shows that people reply to bounce messages. If the
26195 <option>errors_reply_to</option> option is set, a <emphasis>Reply-To:</emphasis> header is added to bounce
26196 and warning messages. For example:
26197 </para>
26198 <literallayout class="monospaced">
26199 errors_reply_to = postmaster@my.domain.example
26200 </literallayout>
26201 <para>
26202 The value of the option is not expanded. It must specify a valid RFC 2822
26203 address. However, if a warning message that is generated by the
26204 <option>quota_warn_message</option> option in an <command>appendfile</command> transport contain its
26205 own <emphasis>Reply-To:</emphasis> header line, the value of the <option>errors_reply_to</option> option is
26206 not used.
26207 </para>
26208 <para>
26209 <indexterm role="option">
26210 <primary><option>event_action</option></primary>
26211 </indexterm>
26212 </para>
26213 <informaltable frame="all">
26214 <tgroup cols="4" colsep="0" rowsep="0">
26215 <colspec colwidth="8*" align="left"/>
26216 <colspec colwidth="6*" align="center"/>
26217 <colspec colwidth="6*" align="center"/>
26218 <colspec colwidth="6*" align="right"/>
26219 <tbody>
26220 <row>
26221 <entry><option>event_action</option></entry>
26222 <entry>Use: <emphasis>main</emphasis></entry>
26223 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26224 <entry>Default: <emphasis>unset</emphasis></entry>
26225 </row>
26226 </tbody>
26227 </tgroup>
26228 </informaltable>
26229 <para>
26230 <indexterm role="concept">
26231 <primary>events</primary>
26232 </indexterm>
26233 This option declares a string to be expanded for Exim&#x2019;s events mechanism.
26234 For details see chapter <xref linkend="CHAPevents"/>.
26235 </para>
26236 <para>
26237 <indexterm role="option">
26238 <primary><option>exim_group</option></primary>
26239 </indexterm>
26240 </para>
26241 <informaltable frame="all">
26242 <tgroup cols="4" colsep="0" rowsep="0">
26243 <colspec colwidth="8*" align="left"/>
26244 <colspec colwidth="6*" align="center"/>
26245 <colspec colwidth="6*" align="center"/>
26246 <colspec colwidth="6*" align="right"/>
26247 <tbody>
26248 <row>
26249 <entry><option>exim_group</option></entry>
26250 <entry>Use: <emphasis>main</emphasis></entry>
26251 <entry>Type: <emphasis>string</emphasis></entry>
26252 <entry>Default: <emphasis>compile-time configured</emphasis></entry>
26253 </row>
26254 </tbody>
26255 </tgroup>
26256 </informaltable>
26257 <para>
26258 <indexterm role="concept">
26259 <primary>gid (group id)</primary>
26260 <secondary>Exim&#x2019;s own</secondary>
26261 </indexterm>
26262 <indexterm role="concept">
26263 <primary>Exim group</primary>
26264 </indexterm>
26265 This option changes the gid under which Exim runs when it gives up root
26266 privilege. The default value is compiled into the binary. The value of this
26267 option is used only when <option>exim_user</option> is also set. Unless it consists entirely
26268 of digits, the string is looked up using <function>getgrnam()</function>, and failure causes a
26269 configuration error. See chapter <xref linkend="CHAPsecurity"/> for a discussion of
26270 security issues.
26271 </para>
26272 <para>
26273 <indexterm role="option">
26274 <primary><option>exim_path</option></primary>
26275 </indexterm>
26276 </para>
26277 <informaltable frame="all">
26278 <tgroup cols="4" colsep="0" rowsep="0">
26279 <colspec colwidth="8*" align="left"/>
26280 <colspec colwidth="6*" align="center"/>
26281 <colspec colwidth="6*" align="center"/>
26282 <colspec colwidth="6*" align="right"/>
26283 <tbody>
26284 <row>
26285 <entry><option>exim_path</option></entry>
26286 <entry>Use: <emphasis>main</emphasis></entry>
26287 <entry>Type: <emphasis>string</emphasis></entry>
26288 <entry>Default: <emphasis>see below</emphasis></entry>
26289 </row>
26290 </tbody>
26291 </tgroup>
26292 </informaltable>
26293 <para>
26294 <indexterm role="concept">
26295 <primary>Exim binary, path name</primary>
26296 </indexterm>
26297 This option specifies the path name of the Exim binary, which is used when Exim
26298 needs to re-exec itself. The default is set up to point to the file <emphasis>exim</emphasis> in
26299 the directory configured at compile time by the BIN_DIRECTORY setting. It
26300 is necessary to change <option>exim_path</option> if, exceptionally, Exim is run from some
26301 other place.
26302 <emphasis role="bold">Warning</emphasis>: Do not use a macro to define the value of this option, because
26303 you will break those Exim utilities that scan the configuration file to find
26304 where the binary is. (They then use the <option>-bP</option> option to extract option
26305 settings such as the value of <option>spool_directory</option>.)
26306 </para>
26307 <para>
26308 <indexterm role="option">
26309 <primary><option>exim_user</option></primary>
26310 </indexterm>
26311 </para>
26312 <informaltable frame="all">
26313 <tgroup cols="4" colsep="0" rowsep="0">
26314 <colspec colwidth="8*" align="left"/>
26315 <colspec colwidth="6*" align="center"/>
26316 <colspec colwidth="6*" align="center"/>
26317 <colspec colwidth="6*" align="right"/>
26318 <tbody>
26319 <row>
26320 <entry><option>exim_user</option></entry>
26321 <entry>Use: <emphasis>main</emphasis></entry>
26322 <entry>Type: <emphasis>string</emphasis></entry>
26323 <entry>Default: <emphasis>compile-time configured</emphasis></entry>
26324 </row>
26325 </tbody>
26326 </tgroup>
26327 </informaltable>
26328 <para>
26329 <indexterm role="concept">
26330 <primary>uid (user id)</primary>
26331 <secondary>Exim&#x2019;s own</secondary>
26332 </indexterm>
26333 <indexterm role="concept">
26334 <primary>Exim user</primary>
26335 </indexterm>
26336 This option changes the uid under which Exim runs when it gives up root
26337 privilege. The default value is compiled into the binary. Ownership of the run
26338 time configuration file and the use of the <option>-C</option> and <option>-D</option> command line
26339 options is checked against the values in the binary, not what is set here.
26340 </para>
26341 <para>
26342 Unless it consists entirely of digits, the string is looked up using
26343 <function>getpwnam()</function>, and failure causes a configuration error. If <option>exim_group</option> is
26344 not also supplied, the gid is taken from the result of <function>getpwnam()</function> if it is
26345 used. See chapter <xref linkend="CHAPsecurity"/> for a discussion of security issues.
26346 </para>
26347 <para revisionflag="changed">
26348 <indexterm role="option">
26349 <primary><option>exim_version</option></primary>
26350 </indexterm>
26351 </para>
26352 <informaltable frame="all" revisionflag="changed">
26353 <tgroup cols="4" colsep="0" rowsep="0">
26354 <colspec colwidth="8*" align="left"/>
26355 <colspec colwidth="6*" align="center"/>
26356 <colspec colwidth="6*" align="center"/>
26357 <colspec colwidth="6*" align="right"/>
26358 <tbody>
26359 <row>
26360 <entry><option>exim_version</option></entry>
26361 <entry>Use: <emphasis>main</emphasis></entry>
26362 <entry>Type: <emphasis>string</emphasis></entry>
26363 <entry>Default: <emphasis>current version</emphasis></entry>
26364 </row>
26365 </tbody>
26366 </tgroup>
26367 </informaltable>
26368 <para revisionflag="changed">
26369 <indexterm role="concept">
26370 <primary>Exim version</primary>
26371 </indexterm>
26372 <indexterm role="concept">
26373 <primary>customizing</primary>
26374 <secondary>version number</secondary>
26375 </indexterm>
26376 <indexterm role="concept">
26377 <primary>version number of Exim</primary>
26378 <secondary>override</secondary>
26379 </indexterm>
26380 This option overrides the <varname>$version_number</varname>/<varname>$exim_version</varname> that Exim reports in
26381 various places.  Use with care; this may fool stupid security scanners.
26382 </para>
26383 <para>
26384 <indexterm role="option">
26385 <primary><option>extra_local_interfaces</option></primary>
26386 </indexterm>
26387 </para>
26388 <informaltable frame="all">
26389 <tgroup cols="4" colsep="0" rowsep="0">
26390 <colspec colwidth="8*" align="left"/>
26391 <colspec colwidth="6*" align="center"/>
26392 <colspec colwidth="6*" align="center"/>
26393 <colspec colwidth="6*" align="right"/>
26394 <tbody>
26395 <row>
26396 <entry><option>extra_local_interfaces</option></entry>
26397 <entry>Use: <emphasis>main</emphasis></entry>
26398 <entry>Type: <emphasis>string list</emphasis></entry>
26399 <entry>Default: <emphasis>unset</emphasis></entry>
26400 </row>
26401 </tbody>
26402 </tgroup>
26403 </informaltable>
26404 <para>
26405 This option defines network interfaces that are to be considered local when
26406 routing, but which are not used for listening by the daemon. See section
26407 <xref linkend="SECTreclocipadd"/> for details.
26408 </para>
26409 <para>
26410 <indexterm role="option">
26411 <primary><option>extract_addresses_remove_arguments</option></primary>
26412 </indexterm>
26413 </para>
26414 <informaltable frame="all">
26415 <tgroup cols="4" colsep="0" rowsep="0">
26416 <colspec colwidth="8*" align="left"/>
26417 <colspec colwidth="6*" align="center"/>
26418 <colspec colwidth="6*" align="center"/>
26419 <colspec colwidth="6*" align="right"/>
26420 <tbody>
26421 <row>
26422 <entry><option>extract_addresses_remove_arguments</option></entry>
26423 <entry>Use: <emphasis>main</emphasis></entry>
26424 <entry>Type: <emphasis>boolean</emphasis></entry>
26425 <entry>Default: <emphasis>true</emphasis></entry>
26426 </row>
26427 </tbody>
26428 </tgroup>
26429 </informaltable>
26430 <para>
26431 <indexterm role="option">
26432 <primary><option>-t</option></primary>
26433 </indexterm>
26434 <indexterm role="concept">
26435 <primary>command line</primary>
26436 <secondary>addresses with <option>-t</option></secondary>
26437 </indexterm>
26438 <indexterm role="concept">
26439 <primary>Sendmail compatibility</primary>
26440 <secondary><option>-t</option> option</secondary>
26441 </indexterm>
26442 According to some Sendmail documentation (Sun, IRIX, HP-UX), if any addresses
26443 are present on the command line when the <option>-t</option> option is used to build an
26444 envelope from a message&#x2019;s <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis> and <emphasis>Bcc:</emphasis> headers, the command
26445 line addresses are removed from the recipients list. This is also how Smail
26446 behaves. However, other Sendmail documentation (the O&#x2019;Reilly book) states that
26447 command line addresses are added to those obtained from the header lines. When
26448 <option>extract_addresses_remove_arguments</option> is true (the default), Exim subtracts
26449 argument headers. If it is set false, Exim adds rather than removes argument
26450 addresses.
26451 </para>
26452 <para>
26453 <indexterm role="option">
26454 <primary><option>finduser_retries</option></primary>
26455 </indexterm>
26456 </para>
26457 <informaltable frame="all">
26458 <tgroup cols="4" colsep="0" rowsep="0">
26459 <colspec colwidth="8*" align="left"/>
26460 <colspec colwidth="6*" align="center"/>
26461 <colspec colwidth="6*" align="center"/>
26462 <colspec colwidth="6*" align="right"/>
26463 <tbody>
26464 <row>
26465 <entry><option>finduser_retries</option></entry>
26466 <entry>Use: <emphasis>main</emphasis></entry>
26467 <entry>Type: <emphasis>integer</emphasis></entry>
26468 <entry>Default: <emphasis>0</emphasis></entry>
26469 </row>
26470 </tbody>
26471 </tgroup>
26472 </informaltable>
26473 <para>
26474 <indexterm role="concept">
26475 <primary>NIS, retrying user lookups</primary>
26476 </indexterm>
26477 On systems running NIS or other schemes in which user and group information is
26478 distributed from a remote system, there can be times when <function>getpwnam()</function> and
26479 related functions fail, even when given valid data, because things time out.
26480 Unfortunately these failures cannot be distinguished from genuine <quote>not found</quote>
26481 errors. If <option>finduser_retries</option> is set greater than zero, Exim will try that
26482 many extra times to find a user or a group, waiting for one second between
26483 retries.
26484 </para>
26485 <para>
26486 <indexterm role="concept">
26487 <primary><filename>/etc/passwd</filename></primary>
26488 <secondary>multiple reading of</secondary>
26489 </indexterm>
26490 You should not set this option greater than zero if your user information is in
26491 a traditional <filename>/etc/passwd</filename> file, because it will cause Exim needlessly to
26492 search the file multiple times for non-existent users, and also cause delay.
26493 </para>
26494 <para>
26495 <indexterm role="option">
26496 <primary><option>freeze_tell</option></primary>
26497 </indexterm>
26498 </para>
26499 <informaltable frame="all">
26500 <tgroup cols="4" colsep="0" rowsep="0">
26501 <colspec colwidth="8*" align="left"/>
26502 <colspec colwidth="6*" align="center"/>
26503 <colspec colwidth="6*" align="center"/>
26504 <colspec colwidth="6*" align="right"/>
26505 <tbody>
26506 <row>
26507 <entry><option>freeze_tell</option></entry>
26508 <entry>Use: <emphasis>main</emphasis></entry>
26509 <entry>Type: <emphasis>string list, comma separated</emphasis></entry>
26510 <entry>Default: <emphasis>unset</emphasis></entry>
26511 </row>
26512 </tbody>
26513 </tgroup>
26514 </informaltable>
26515 <para>
26516 <indexterm role="concept">
26517 <primary>freezing messages</primary>
26518 <secondary>sending a message when freezing</secondary>
26519 </indexterm>
26520 On encountering certain errors, or when configured to do so in a system filter,
26521 ACL, or special router, Exim freezes a message. This means that no further
26522 delivery attempts take place until an administrator thaws the message, or the
26523 <option>auto_thaw</option>, <option>ignore_bounce_errors_after</option>, or <option>timeout_frozen_after</option>
26524 feature cause it to be processed. If <option>freeze_tell</option> is set, Exim generates a
26525 warning message whenever it freezes something, unless the message it is
26526 freezing is a locally-generated bounce message. (Without this exception there
26527 is the possibility of looping.) The warning message is sent to the addresses
26528 supplied as the comma-separated value of this option. If several of the
26529 message&#x2019;s addresses cause freezing, only a single message is sent. If the
26530 freezing was automatic, the reason(s) for freezing can be found in the message
26531 log. If you configure freezing in a filter or ACL, you must arrange for any
26532 logging that you require.
26533 </para>
26534 <para>
26535 <indexterm role="option">
26536 <primary><option>gecos_name</option></primary>
26537 </indexterm>
26538 </para>
26539 <informaltable frame="all">
26540 <tgroup cols="4" colsep="0" rowsep="0">
26541 <colspec colwidth="8*" align="left"/>
26542 <colspec colwidth="6*" align="center"/>
26543 <colspec colwidth="6*" align="center"/>
26544 <colspec colwidth="6*" align="right"/>
26545 <tbody>
26546 <row>
26547 <entry><option>gecos_name</option></entry>
26548 <entry>Use: <emphasis>main</emphasis></entry>
26549 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26550 <entry>Default: <emphasis>unset</emphasis></entry>
26551 </row>
26552 </tbody>
26553 </tgroup>
26554 </informaltable>
26555 <para>
26556 <indexterm role="concept">
26557 <primary>HP-UX</primary>
26558 </indexterm>
26559 <indexterm role="concept">
26560 <primary><quote>gecos</quote> field, parsing</primary>
26561 </indexterm>
26562 Some operating systems, notably HP-UX, use the <quote>gecos</quote> field in the system
26563 password file to hold other information in addition to users&#x2019; real names. Exim
26564 looks up this field for use when it is creating <emphasis>Sender:</emphasis> or <emphasis>From:</emphasis>
26565 headers. If either <option>gecos_pattern</option> or <option>gecos_name</option> are unset, the contents
26566 of the field are used unchanged, except that, if an ampersand is encountered,
26567 it is replaced by the user&#x2019;s login name with the first character forced to
26568 upper case, since this is a convention that is observed on many systems.
26569 </para>
26570 <para>
26571 When these options are set, <option>gecos_pattern</option> is treated as a regular
26572 expression that is to be applied to the field (again with &amp; replaced by the
26573 login name), and if it matches, <option>gecos_name</option> is expanded and used as the
26574 user&#x2019;s name.
26575 </para>
26576 <para>
26577 <indexterm role="concept">
26578 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
26579 <secondary>in <option>gecos_name</option></secondary>
26580 </indexterm>
26581 Numeric variables such as <varname>$1</varname>, <varname>$2</varname>, etc. can be used in the expansion to
26582 pick up sub-fields that were matched by the pattern. In HP-UX, where the user&#x2019;s
26583 name terminates at the first comma, the following can be used:
26584 </para>
26585 <literallayout class="monospaced">
26586 gecos_pattern = ([^,]*)
26587 gecos_name = $1
26588 </literallayout>
26589 <para>
26590 <indexterm role="option">
26591 <primary><option>gecos_pattern</option></primary>
26592 </indexterm>
26593 </para>
26594 <informaltable frame="all">
26595 <tgroup cols="4" colsep="0" rowsep="0">
26596 <colspec colwidth="8*" align="left"/>
26597 <colspec colwidth="6*" align="center"/>
26598 <colspec colwidth="6*" align="center"/>
26599 <colspec colwidth="6*" align="right"/>
26600 <tbody>
26601 <row>
26602 <entry><option>gecos_pattern</option></entry>
26603 <entry>Use: <emphasis>main</emphasis></entry>
26604 <entry>Type: <emphasis>string</emphasis></entry>
26605 <entry>Default: <emphasis>unset</emphasis></entry>
26606 </row>
26607 </tbody>
26608 </tgroup>
26609 </informaltable>
26610 <para>
26611 See <option>gecos_name</option> above.
26612 </para>
26613 <para>
26614 <indexterm role="option">
26615 <primary><option>gnutls_compat_mode</option></primary>
26616 </indexterm>
26617 </para>
26618 <informaltable frame="all">
26619 <tgroup cols="4" colsep="0" rowsep="0">
26620 <colspec colwidth="8*" align="left"/>
26621 <colspec colwidth="6*" align="center"/>
26622 <colspec colwidth="6*" align="center"/>
26623 <colspec colwidth="6*" align="right"/>
26624 <tbody>
26625 <row>
26626 <entry><option>gnutls_compat_mode</option></entry>
26627 <entry>Use: <emphasis>main</emphasis></entry>
26628 <entry>Type: <emphasis>boolean</emphasis></entry>
26629 <entry>Default: <emphasis>unset</emphasis></entry>
26630 </row>
26631 </tbody>
26632 </tgroup>
26633 </informaltable>
26634 <para>
26635 This option controls whether GnuTLS is used in compatibility mode in an Exim
26636 server. This reduces security slightly, but improves interworking with older
26637 implementations of TLS.
26638 </para>
26639 <para>
26640 <indexterm role="option">
26641 <primary><option>gnutls_allow_auto_pkcs11</option></primary>
26642 </indexterm>
26643 </para>
26644 <informaltable frame="all">
26645 <tgroup cols="4" colsep="0" rowsep="0">
26646 <colspec colwidth="8*" align="left"/>
26647 <colspec colwidth="6*" align="center"/>
26648 <colspec colwidth="6*" align="center"/>
26649 <colspec colwidth="6*" align="right"/>
26650 <tbody>
26651 <row>
26652 <entry><option>gnutls_allow_auto_pkcs11</option></entry>
26653 <entry>Use: <emphasis>main</emphasis></entry>
26654 <entry>Type: <emphasis>boolean</emphasis></entry>
26655 <entry>Default: <emphasis>unset</emphasis></entry>
26656 </row>
26657 </tbody>
26658 </tgroup>
26659 </informaltable>
26660 <para>
26661 This option will let GnuTLS (2.12.0 or later) autoload PKCS11 modules with
26662 the p11-kit configuration files in <filename>/etc/pkcs11/modules/</filename>.
26663 </para>
26664 <para>
26665 See
26666 <emphasis role="bold"><ulink url="https://www.gnutls.org/manual/gnutls.html#Smart-cards-and-HSMs">https://www.gnutls.org/manual/gnutls.html#Smart-cards-and-HSMs</ulink></emphasis>
26667 for documentation.
26668 </para>
26669 <para>
26670 <indexterm role="option">
26671 <primary><option>headers_charset</option></primary>
26672 </indexterm>
26673 </para>
26674 <informaltable frame="all">
26675 <tgroup cols="4" colsep="0" rowsep="0">
26676 <colspec colwidth="8*" align="left"/>
26677 <colspec colwidth="6*" align="center"/>
26678 <colspec colwidth="6*" align="center"/>
26679 <colspec colwidth="6*" align="right"/>
26680 <tbody>
26681 <row>
26682 <entry><option>headers_charset</option></entry>
26683 <entry>Use: <emphasis>main</emphasis></entry>
26684 <entry>Type: <emphasis>string</emphasis></entry>
26685 <entry>Default: <emphasis>see below</emphasis></entry>
26686 </row>
26687 </tbody>
26688 </tgroup>
26689 </informaltable>
26690 <para>
26691 This option sets a default character set for translating from encoded MIME
26692 <quote>words</quote> in header lines, when referenced by an <varname>$h_xxx</varname> expansion item. The
26693 default is the value of HEADERS_CHARSET in <filename>Local/Makefile</filename>. The
26694 ultimate default is ISO-8859-1. For more details see the description of header
26695 insertions in section <xref linkend="SECTexpansionitems"/>.
26696 </para>
26697 <para>
26698 <indexterm role="option">
26699 <primary><option>header_maxsize</option></primary>
26700 </indexterm>
26701 </para>
26702 <informaltable frame="all">
26703 <tgroup cols="4" colsep="0" rowsep="0">
26704 <colspec colwidth="8*" align="left"/>
26705 <colspec colwidth="6*" align="center"/>
26706 <colspec colwidth="6*" align="center"/>
26707 <colspec colwidth="6*" align="right"/>
26708 <tbody>
26709 <row>
26710 <entry><option>header_maxsize</option></entry>
26711 <entry>Use: <emphasis>main</emphasis></entry>
26712 <entry>Type: <emphasis>integer</emphasis></entry>
26713 <entry>Default: <emphasis>see below</emphasis></entry>
26714 </row>
26715 </tbody>
26716 </tgroup>
26717 </informaltable>
26718 <para>
26719 <indexterm role="concept">
26720 <primary>header section</primary>
26721 <secondary>maximum size of</secondary>
26722 </indexterm>
26723 <indexterm role="concept">
26724 <primary>limit</primary>
26725 <secondary>size of message header section</secondary>
26726 </indexterm>
26727 This option controls the overall maximum size of a message&#x2019;s header
26728 section. The default is the value of HEADER_MAXSIZE in
26729 <filename>Local/Makefile</filename>; the default for that is 1M. Messages with larger header
26730 sections are rejected.
26731 </para>
26732 <para>
26733 <indexterm role="option">
26734 <primary><option>header_line_maxsize</option></primary>
26735 </indexterm>
26736 </para>
26737 <informaltable frame="all">
26738 <tgroup cols="4" colsep="0" rowsep="0">
26739 <colspec colwidth="8*" align="left"/>
26740 <colspec colwidth="6*" align="center"/>
26741 <colspec colwidth="6*" align="center"/>
26742 <colspec colwidth="6*" align="right"/>
26743 <tbody>
26744 <row>
26745 <entry><option>header_line_maxsize</option></entry>
26746 <entry>Use: <emphasis>main</emphasis></entry>
26747 <entry>Type: <emphasis>integer</emphasis></entry>
26748 <entry>Default: <emphasis>0</emphasis></entry>
26749 </row>
26750 </tbody>
26751 </tgroup>
26752 </informaltable>
26753 <para>
26754 <indexterm role="concept">
26755 <primary>header lines</primary>
26756 <secondary>maximum size of</secondary>
26757 </indexterm>
26758 <indexterm role="concept">
26759 <primary>limit</primary>
26760 <secondary>size of one header line</secondary>
26761 </indexterm>
26762 This option limits the length of any individual header line in a message, after
26763 all the continuations have been joined together. Messages with individual
26764 header lines that are longer than the limit are rejected. The default value of
26765 zero means <quote>no limit</quote>.
26766 </para>
26767 <para>
26768 <indexterm role="option">
26769 <primary><option>helo_accept_junk_hosts</option></primary>
26770 </indexterm>
26771 </para>
26772 <informaltable frame="all">
26773 <tgroup cols="4" colsep="0" rowsep="0">
26774 <colspec colwidth="8*" align="left"/>
26775 <colspec colwidth="6*" align="center"/>
26776 <colspec colwidth="6*" align="center"/>
26777 <colspec colwidth="6*" align="right"/>
26778 <tbody>
26779 <row>
26780 <entry><option>helo_accept_junk_hosts</option></entry>
26781 <entry>Use: <emphasis>main</emphasis></entry>
26782 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
26783 <entry>Default: <emphasis>unset</emphasis></entry>
26784 </row>
26785 </tbody>
26786 </tgroup>
26787 </informaltable>
26788 <para>
26789 <indexterm role="concept">
26790 <primary>HELO</primary>
26791 <secondary>accepting junk data</secondary>
26792 </indexterm>
26793 <indexterm role="concept">
26794 <primary>EHLO</primary>
26795 <secondary>accepting junk data</secondary>
26796 </indexterm>
26797 Exim checks the syntax of HELO and EHLO commands for incoming SMTP
26798 mail, and gives an error response for invalid data. Unfortunately, there are
26799 some SMTP clients that send syntactic junk. They can be accommodated by setting
26800 this option. Note that this is a syntax check only. See <option>helo_verify_hosts</option>
26801 if you want to do semantic checking.
26802 See also <option>helo_allow_chars</option> for a way of extending the permitted character
26803 set.
26804 </para>
26805 <para>
26806 <indexterm role="option">
26807 <primary><option>helo_allow_chars</option></primary>
26808 </indexterm>
26809 </para>
26810 <informaltable frame="all">
26811 <tgroup cols="4" colsep="0" rowsep="0">
26812 <colspec colwidth="8*" align="left"/>
26813 <colspec colwidth="6*" align="center"/>
26814 <colspec colwidth="6*" align="center"/>
26815 <colspec colwidth="6*" align="right"/>
26816 <tbody>
26817 <row>
26818 <entry><option>helo_allow_chars</option></entry>
26819 <entry>Use: <emphasis>main</emphasis></entry>
26820 <entry>Type: <emphasis>string</emphasis></entry>
26821 <entry>Default: <emphasis>unset</emphasis></entry>
26822 </row>
26823 </tbody>
26824 </tgroup>
26825 </informaltable>
26826 <para>
26827 <indexterm role="concept">
26828 <primary>HELO</primary>
26829 <secondary>underscores in</secondary>
26830 </indexterm>
26831 <indexterm role="concept">
26832 <primary>EHLO</primary>
26833 <secondary>underscores in</secondary>
26834 </indexterm>
26835 <indexterm role="concept">
26836 <primary>underscore in EHLO/HELO</primary>
26837 </indexterm>
26838 This option can be set to a string of rogue characters that are permitted in
26839 all EHLO and HELO names in addition to the standard letters, digits,
26840 hyphens, and dots. If you really must allow underscores, you can set
26841 </para>
26842 <literallayout class="monospaced">
26843 helo_allow_chars = _
26844 </literallayout>
26845 <para>
26846 Note that the value is one string, not a list.
26847 </para>
26848 <para>
26849 <indexterm role="option">
26850 <primary><option>helo_lookup_domains</option></primary>
26851 </indexterm>
26852 </para>
26853 <informaltable frame="all">
26854 <tgroup cols="4" colsep="0" rowsep="0">
26855 <colspec colwidth="8*" align="left"/>
26856 <colspec colwidth="6*" align="center"/>
26857 <colspec colwidth="6*" align="center"/>
26858 <colspec colwidth="6*" align="right"/>
26859 <tbody>
26860 <row>
26861 <entry><option>helo_lookup_domains</option></entry>
26862 <entry>Use: <emphasis>main</emphasis></entry>
26863 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
26864 <entry>Default: <emphasis><literal>@:@[]</literal></emphasis></entry>
26865 </row>
26866 </tbody>
26867 </tgroup>
26868 </informaltable>
26869 <para>
26870 <indexterm role="concept">
26871 <primary>HELO</primary>
26872 <secondary>forcing reverse lookup</secondary>
26873 </indexterm>
26874 <indexterm role="concept">
26875 <primary>EHLO</primary>
26876 <secondary>forcing reverse lookup</secondary>
26877 </indexterm>
26878 If the domain given by a client in a HELO or EHLO command matches this
26879 list, a reverse lookup is done in order to establish the host&#x2019;s true name. The
26880 default forces a lookup if the client host gives the server&#x2019;s name or any of
26881 its IP addresses (in brackets), something that broken clients have been seen to
26882 do.
26883 </para>
26884 <para>
26885 <indexterm role="option">
26886 <primary><option>helo_try_verify_hosts</option></primary>
26887 </indexterm>
26888 </para>
26889 <informaltable frame="all">
26890 <tgroup cols="4" colsep="0" rowsep="0">
26891 <colspec colwidth="8*" align="left"/>
26892 <colspec colwidth="6*" align="center"/>
26893 <colspec colwidth="6*" align="center"/>
26894 <colspec colwidth="6*" align="right"/>
26895 <tbody>
26896 <row>
26897 <entry><option>helo_try_verify_hosts</option></entry>
26898 <entry>Use: <emphasis>main</emphasis></entry>
26899 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
26900 <entry>Default: <emphasis>unset</emphasis></entry>
26901 </row>
26902 </tbody>
26903 </tgroup>
26904 </informaltable>
26905 <para>
26906 <indexterm role="concept">
26907 <primary>HELO verifying</primary>
26908 <secondary>optional</secondary>
26909 </indexterm>
26910 <indexterm role="concept">
26911 <primary>EHLO</primary>
26912 <secondary>verifying, optional</secondary>
26913 </indexterm>
26914 By default, Exim just checks the syntax of HELO and EHLO commands (see
26915 <option>helo_accept_junk_hosts</option> and <option>helo_allow_chars</option>). However, some sites like
26916 to do more extensive checking of the data supplied by these commands. The ACL
26917 condition <literal>verify = helo</literal> is provided to make this possible.
26918 Formerly, it was necessary also to set this option (<option>helo_try_verify_hosts</option>)
26919 to force the check to occur. From release 4.53 onwards, this is no longer
26920 necessary. If the check has not been done before <literal>verify = helo</literal> is
26921 encountered, it is done at that time. Consequently, this option is obsolete.
26922 Its specification is retained here for backwards compatibility.
26923 </para>
26924 <para>
26925 When an EHLO or HELO command is received, if the calling host matches
26926 <option>helo_try_verify_hosts</option>, Exim checks that the host name given in the HELO or
26927 EHLO command either:
26928 </para>
26929 <itemizedlist>
26930 <listitem>
26931 <para>
26932 is an IP literal matching the calling address of the host, or
26933 </para>
26934 </listitem>
26935 <listitem>
26936 <para>
26937 <indexterm role="concept">
26938 <primary>DNS</primary>
26939 <secondary>reverse lookup</secondary>
26940 </indexterm>
26941 <indexterm role="concept">
26942 <primary>reverse DNS lookup</primary>
26943 </indexterm>
26944 matches the host name that Exim obtains by doing a reverse lookup of the
26945 calling host address, or
26946 </para>
26947 </listitem>
26948 <listitem>
26949 <para>
26950 when looked up in DNS yields the calling host address.
26951 </para>
26952 </listitem>
26953 </itemizedlist>
26954 <para>
26955 However, the EHLO or HELO command is not rejected if any of the checks
26956 fail. Processing continues, but the result of the check is remembered, and can
26957 be detected later in an ACL by the <literal>verify = helo</literal> condition.
26958 </para>
26959 <para>
26960 If DNS was used for successful verification, the variable
26961 <indexterm role="concept">
26962 <primary>DNS</primary>
26963 <secondary>DNSSEC</secondary>
26964 </indexterm>
26965 <varname>$helo_verify_dnssec</varname> records the DNSSEC status of the lookups.
26966 </para>
26967 <para>
26968 <indexterm role="option">
26969 <primary><option>helo_verify_hosts</option></primary>
26970 </indexterm>
26971 </para>
26972 <informaltable frame="all">
26973 <tgroup cols="4" colsep="0" rowsep="0">
26974 <colspec colwidth="8*" align="left"/>
26975 <colspec colwidth="6*" align="center"/>
26976 <colspec colwidth="6*" align="center"/>
26977 <colspec colwidth="6*" align="right"/>
26978 <tbody>
26979 <row>
26980 <entry><option>helo_verify_hosts</option></entry>
26981 <entry>Use: <emphasis>main</emphasis></entry>
26982 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
26983 <entry>Default: <emphasis>unset</emphasis></entry>
26984 </row>
26985 </tbody>
26986 </tgroup>
26987 </informaltable>
26988 <para>
26989 <indexterm role="concept">
26990 <primary>HELO verifying</primary>
26991 <secondary>mandatory</secondary>
26992 </indexterm>
26993 <indexterm role="concept">
26994 <primary>EHLO</primary>
26995 <secondary>verifying, mandatory</secondary>
26996 </indexterm>
26997 Like <option>helo_try_verify_hosts</option>, this option is obsolete, and retained only for
26998 backwards compatibility. For hosts that match this option, Exim checks the host
26999 name given in the HELO or EHLO in the same way as for
27000 <option>helo_try_verify_hosts</option>. If the check fails, the HELO or EHLO command is
27001 rejected with a 550 error, and entries are written to the main and reject logs.
27002 If a MAIL command is received before EHLO or HELO, it is rejected with a 503
27003 error.
27004 </para>
27005 <para>
27006 <indexterm role="option">
27007 <primary><option>hold_domains</option></primary>
27008 </indexterm>
27009 </para>
27010 <informaltable frame="all">
27011 <tgroup cols="4" colsep="0" rowsep="0">
27012 <colspec colwidth="8*" align="left"/>
27013 <colspec colwidth="6*" align="center"/>
27014 <colspec colwidth="6*" align="center"/>
27015 <colspec colwidth="6*" align="right"/>
27016 <tbody>
27017 <row>
27018 <entry><option>hold_domains</option></entry>
27019 <entry>Use: <emphasis>main</emphasis></entry>
27020 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
27021 <entry>Default: <emphasis>unset</emphasis></entry>
27022 </row>
27023 </tbody>
27024 </tgroup>
27025 </informaltable>
27026 <para>
27027 <indexterm role="concept">
27028 <primary>domain</primary>
27029 <secondary>delaying delivery</secondary>
27030 </indexterm>
27031 <indexterm role="concept">
27032 <primary>delivery</primary>
27033 <secondary>delaying certain domains</secondary>
27034 </indexterm>
27035 This option allows mail for particular domains to be held in the queue
27036 manually. The option is overridden if a message delivery is forced with the
27037 <option>-M</option>, <option>-qf</option>, <option>-Rf</option> or <option>-Sf</option> options, and also while testing or
27038 verifying addresses using <option>-bt</option> or <option>-bv</option>. Otherwise, if a domain matches an
27039 item in <option>hold_domains</option>, no routing or delivery for that address is done, and
27040 it is deferred every time the message is looked at.
27041 </para>
27042 <para>
27043 This option is intended as a temporary operational measure for delaying the
27044 delivery of mail while some problem is being sorted out, or some new
27045 configuration tested. If you just want to delay the processing of some
27046 domains until a queue run occurs, you should use <option>queue_domains</option> or
27047 <option>queue_smtp_domains</option>, not <option>hold_domains</option>.
27048 </para>
27049 <para>
27050 A setting of <option>hold_domains</option> does not override Exim&#x2019;s code for removing
27051 messages from the queue if they have been there longer than the longest retry
27052 time in any retry rule. If you want to hold messages for longer than the normal
27053 retry times, insert a dummy retry rule with a long retry time.
27054 </para>
27055 <para>
27056 <indexterm role="option">
27057 <primary><option>host_lookup</option></primary>
27058 </indexterm>
27059 </para>
27060 <informaltable frame="all">
27061 <tgroup cols="4" colsep="0" rowsep="0">
27062 <colspec colwidth="8*" align="left"/>
27063 <colspec colwidth="6*" align="center"/>
27064 <colspec colwidth="6*" align="center"/>
27065 <colspec colwidth="6*" align="right"/>
27066 <tbody>
27067 <row>
27068 <entry><option>host_lookup</option></entry>
27069 <entry>Use: <emphasis>main</emphasis></entry>
27070 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
27071 <entry>Default: <emphasis>unset</emphasis></entry>
27072 </row>
27073 </tbody>
27074 </tgroup>
27075 </informaltable>
27076 <para>
27077 <indexterm role="concept">
27078 <primary>host name</primary>
27079 <secondary>lookup, forcing</secondary>
27080 </indexterm>
27081 Exim does not look up the name of a calling host from its IP address unless it
27082 is required to compare against some host list, or the host matches
27083 <option>helo_try_verify_hosts</option> or <option>helo_verify_hosts</option>, or the host matches this
27084 option (which normally contains IP addresses rather than host names). The
27085 default configuration file contains
27086 </para>
27087 <literallayout class="monospaced">
27088 host_lookup = *
27089 </literallayout>
27090 <para>
27091 which causes a lookup to happen for all hosts. If the expense of these lookups
27092 is felt to be too great, the setting can be changed or removed.
27093 </para>
27094 <para>
27095 After a successful reverse lookup, Exim does a forward lookup on the name it
27096 has obtained, to verify that it yields the IP address that it started with. If
27097 this check fails, Exim behaves as if the name lookup failed.
27098 </para>
27099 <para>
27100 <indexterm role="variable">
27101 <primary><varname>$host_lookup_failed</varname></primary>
27102 </indexterm>
27103 <indexterm role="variable">
27104 <primary><varname>$sender_host_name</varname></primary>
27105 </indexterm>
27106 After any kind of failure, the host name (in <varname>$sender_host_name</varname>) remains
27107 unset, and <varname>$host_lookup_failed</varname> is set to the string <quote>1</quote>. See also
27108 <option>dns_again_means_nonexist</option>, <option>helo_lookup_domains</option>, and
27109 <literal>verify = reverse_host_lookup</literal> in ACLs.
27110 </para>
27111 <para>
27112 <indexterm role="option">
27113 <primary><option>host_lookup_order</option></primary>
27114 </indexterm>
27115 </para>
27116 <informaltable frame="all">
27117 <tgroup cols="4" colsep="0" rowsep="0">
27118 <colspec colwidth="8*" align="left"/>
27119 <colspec colwidth="6*" align="center"/>
27120 <colspec colwidth="6*" align="center"/>
27121 <colspec colwidth="6*" align="right"/>
27122 <tbody>
27123 <row>
27124 <entry><option>host_lookup_order</option></entry>
27125 <entry>Use: <emphasis>main</emphasis></entry>
27126 <entry>Type: <emphasis>string list</emphasis></entry>
27127 <entry>Default: <emphasis><literal>bydns:byaddr</literal></emphasis></entry>
27128 </row>
27129 </tbody>
27130 </tgroup>
27131 </informaltable>
27132 <para>
27133 This option specifies the order of different lookup methods when Exim is trying
27134 to find a host name from an IP address. The default is to do a DNS lookup
27135 first, and then to try a local lookup (using <function>gethostbyaddr()</function> or equivalent)
27136 if that fails. You can change the order of these lookups, or omit one entirely,
27137 if you want.
27138 </para>
27139 <para>
27140 <emphasis role="bold">Warning</emphasis>: The <quote>byaddr</quote> method does not always yield aliases when there are
27141 multiple PTR records in the DNS and the IP address is not listed in
27142 <filename>/etc/hosts</filename>. Different operating systems give different results in this
27143 case. That is why the default tries a DNS lookup first.
27144 </para>
27145 <para>
27146 <indexterm role="option">
27147 <primary><option>host_reject_connection</option></primary>
27148 </indexterm>
27149 </para>
27150 <informaltable frame="all">
27151 <tgroup cols="4" colsep="0" rowsep="0">
27152 <colspec colwidth="8*" align="left"/>
27153 <colspec colwidth="6*" align="center"/>
27154 <colspec colwidth="6*" align="center"/>
27155 <colspec colwidth="6*" align="right"/>
27156 <tbody>
27157 <row>
27158 <entry><option>host_reject_connection</option></entry>
27159 <entry>Use: <emphasis>main</emphasis></entry>
27160 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
27161 <entry>Default: <emphasis>unset</emphasis></entry>
27162 </row>
27163 </tbody>
27164 </tgroup>
27165 </informaltable>
27166 <para>
27167 <indexterm role="concept">
27168 <primary>host</primary>
27169 <secondary>rejecting connections from</secondary>
27170 </indexterm>
27171 If this option is set, incoming SMTP calls from the hosts listed are rejected
27172 as soon as the connection is made.
27173 This option is obsolete, and retained only for backward compatibility, because
27174 nowadays the ACL specified by <option>acl_smtp_connect</option> can also reject incoming
27175 connections immediately.
27176 </para>
27177 <para>
27178 The ability to give an immediate rejection (either by this option or using an
27179 ACL) is provided for use in unusual cases. Many hosts will just try again,
27180 sometimes without much delay. Normally, it is better to use an ACL to reject
27181 incoming messages at a later stage, such as after RCPT commands. See
27182 chapter <xref linkend="CHAPACL"/>.
27183 </para>
27184 <para>
27185 <indexterm role="option">
27186 <primary><option>hosts_connection_nolog</option></primary>
27187 </indexterm>
27188 </para>
27189 <informaltable frame="all">
27190 <tgroup cols="4" colsep="0" rowsep="0">
27191 <colspec colwidth="8*" align="left"/>
27192 <colspec colwidth="6*" align="center"/>
27193 <colspec colwidth="6*" align="center"/>
27194 <colspec colwidth="6*" align="right"/>
27195 <tbody>
27196 <row>
27197 <entry><option>hosts_connection_nolog</option></entry>
27198 <entry>Use: <emphasis>main</emphasis></entry>
27199 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
27200 <entry>Default: <emphasis>unset</emphasis></entry>
27201 </row>
27202 </tbody>
27203 </tgroup>
27204 </informaltable>
27205 <para>
27206 <indexterm role="concept">
27207 <primary>host</primary>
27208 <secondary>not logging connections from</secondary>
27209 </indexterm>
27210 This option defines a list of hosts for which connection logging does not
27211 happen, even though the <option>smtp_connection</option> log selector is set. For example,
27212 you might want not to log SMTP connections from local processes, or from
27213 127.0.0.1, or from your local LAN. This option is consulted in the main loop of
27214 the daemon; you should therefore strive to restrict its value to a short inline
27215 list of IP addresses and networks. To disable logging SMTP connections from
27216 local processes, you must create a host list with an empty item. For example:
27217 </para>
27218 <literallayout class="monospaced">
27219 hosts_connection_nolog = :
27220 </literallayout>
27221 <para>
27222 If the <option>smtp_connection</option> log selector is not set, this option has no effect.
27223 </para>
27224 <para>
27225 <indexterm role="option">
27226 <primary><option>hosts_proxy</option></primary>
27227 </indexterm>
27228 </para>
27229 <informaltable frame="all">
27230 <tgroup cols="4" colsep="0" rowsep="0">
27231 <colspec colwidth="8*" align="left"/>
27232 <colspec colwidth="6*" align="center"/>
27233 <colspec colwidth="6*" align="center"/>
27234 <colspec colwidth="6*" align="right"/>
27235 <tbody>
27236 <row>
27237 <entry><option>hosts_proxy</option></entry>
27238 <entry>Use: <emphasis>main</emphasis></entry>
27239 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
27240 <entry>Default: <emphasis>unset</emphasis></entry>
27241 </row>
27242 </tbody>
27243 </tgroup>
27244 </informaltable>
27245 <para>
27246 <indexterm role="concept">
27247 <primary>proxy</primary>
27248 <secondary>proxy protocol</secondary>
27249 </indexterm>
27250 This option enables use of Proxy Protocol proxies for incoming
27251 connections.  For details see section <xref linkend="SECTproxyInbound"/>.
27252 </para>
27253 <para>
27254 <indexterm role="option">
27255 <primary><option>hosts_treat_as_local</option></primary>
27256 </indexterm>
27257 </para>
27258 <informaltable frame="all">
27259 <tgroup cols="4" colsep="0" rowsep="0">
27260 <colspec colwidth="8*" align="left"/>
27261 <colspec colwidth="6*" align="center"/>
27262 <colspec colwidth="6*" align="center"/>
27263 <colspec colwidth="6*" align="right"/>
27264 <tbody>
27265 <row>
27266 <entry><option>hosts_treat_as_local</option></entry>
27267 <entry>Use: <emphasis>main</emphasis></entry>
27268 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
27269 <entry>Default: <emphasis>unset</emphasis></entry>
27270 </row>
27271 </tbody>
27272 </tgroup>
27273 </informaltable>
27274 <para>
27275 <indexterm role="concept">
27276 <primary>local host</primary>
27277 <secondary>domains treated as</secondary>
27278 </indexterm>
27279 <indexterm role="concept">
27280 <primary>host</primary>
27281 <secondary>treated as local</secondary>
27282 </indexterm>
27283 If this option is set, any host names that match the domain list are treated as
27284 if they were the local host when Exim is scanning host lists obtained from MX
27285 records
27286 or other sources. Note that the value of this option is a domain list, not a
27287 host list, because it is always used to check host names, not IP addresses.
27288 </para>
27289 <para>
27290 This option also applies when Exim is matching the special items
27291 <literal>@mx_any</literal>, <literal>@mx_primary</literal>, and <literal>@mx_secondary</literal> in a domain list (see
27292 section <xref linkend="SECTdomainlist"/>), and when checking the <option>hosts</option> option in the
27293 <command>smtp</command> transport for the local host (see the <option>allow_localhost</option> option in
27294 that transport). See also <option>local_interfaces</option>, <option>extra_local_interfaces</option>, and
27295 chapter <xref linkend="CHAPinterfaces"/>, which contains a discussion about local network
27296 interfaces and recognizing the local host.
27297 </para>
27298 <para>
27299 <indexterm role="option">
27300 <primary><option>ibase_servers</option></primary>
27301 </indexterm>
27302 </para>
27303 <informaltable frame="all">
27304 <tgroup cols="4" colsep="0" rowsep="0">
27305 <colspec colwidth="8*" align="left"/>
27306 <colspec colwidth="6*" align="center"/>
27307 <colspec colwidth="6*" align="center"/>
27308 <colspec colwidth="6*" align="right"/>
27309 <tbody>
27310 <row>
27311 <entry><option>ibase_servers</option></entry>
27312 <entry>Use: <emphasis>main</emphasis></entry>
27313 <entry>Type: <emphasis>string list</emphasis></entry>
27314 <entry>Default: <emphasis>unset</emphasis></entry>
27315 </row>
27316 </tbody>
27317 </tgroup>
27318 </informaltable>
27319 <para>
27320 <indexterm role="concept">
27321 <primary>InterBase</primary>
27322 <secondary>server list</secondary>
27323 </indexterm>
27324 This option provides a list of InterBase servers and associated connection data,
27325 to be used in conjunction with <command>ibase</command> lookups (see section <xref linkend="SECID72"/>).
27326 The option is available only if Exim has been built with InterBase support.
27327 </para>
27328 <para>
27329 <indexterm role="option">
27330 <primary><option>ignore_bounce_errors_after</option></primary>
27331 </indexterm>
27332 </para>
27333 <informaltable frame="all">
27334 <tgroup cols="4" colsep="0" rowsep="0">
27335 <colspec colwidth="8*" align="left"/>
27336 <colspec colwidth="6*" align="center"/>
27337 <colspec colwidth="6*" align="center"/>
27338 <colspec colwidth="6*" align="right"/>
27339 <tbody>
27340 <row>
27341 <entry><option>ignore_bounce_errors_after</option></entry>
27342 <entry>Use: <emphasis>main</emphasis></entry>
27343 <entry>Type: <emphasis>time</emphasis></entry>
27344 <entry>Default: <emphasis>10w</emphasis></entry>
27345 </row>
27346 </tbody>
27347 </tgroup>
27348 </informaltable>
27349 <para>
27350 <indexterm role="concept">
27351 <primary>bounce message</primary>
27352 <secondary>discarding</secondary>
27353 </indexterm>
27354 <indexterm role="concept">
27355 <primary>discarding bounce message</primary>
27356 </indexterm>
27357 This option affects the processing of bounce messages that cannot be delivered,
27358 that is, those that suffer a permanent delivery failure. (Bounce messages that
27359 suffer temporary delivery failures are of course retried in the usual way.)
27360 </para>
27361 <para>
27362 After a permanent delivery failure, bounce messages are frozen,
27363 because there is no sender to whom they can be returned. When a frozen bounce
27364 message has been in the queue for more than the given time, it is unfrozen at
27365 the next queue run, and a further delivery is attempted. If delivery fails
27366 again, the bounce message is discarded. This makes it possible to keep failed
27367 bounce messages around for a shorter time than the normal maximum retry time
27368 for frozen messages. For example,
27369 </para>
27370 <literallayout class="monospaced">
27371 ignore_bounce_errors_after = 12h
27372 </literallayout>
27373 <para>
27374 retries failed bounce message deliveries after 12 hours, discarding any further
27375 failures. If the value of this option is set to a zero time period, bounce
27376 failures are discarded immediately. Setting a very long time (as in the default
27377 value) has the effect of disabling this option. For ways of automatically
27378 dealing with other kinds of frozen message, see <option>auto_thaw</option> and
27379 <option>timeout_frozen_after</option>.
27380 </para>
27381 <para>
27382 <indexterm role="option">
27383 <primary><option>ignore_fromline_hosts</option></primary>
27384 </indexterm>
27385 </para>
27386 <informaltable frame="all">
27387 <tgroup cols="4" colsep="0" rowsep="0">
27388 <colspec colwidth="8*" align="left"/>
27389 <colspec colwidth="6*" align="center"/>
27390 <colspec colwidth="6*" align="center"/>
27391 <colspec colwidth="6*" align="right"/>
27392 <tbody>
27393 <row>
27394 <entry><option>ignore_fromline_hosts</option></entry>
27395 <entry>Use: <emphasis>main</emphasis></entry>
27396 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
27397 <entry>Default: <emphasis>unset</emphasis></entry>
27398 </row>
27399 </tbody>
27400 </tgroup>
27401 </informaltable>
27402 <para>
27403 <indexterm role="concept">
27404 <primary><quote>From</quote> line</primary>
27405 </indexterm>
27406 <indexterm role="concept">
27407 <primary>UUCP</primary>
27408 <secondary><quote>From</quote> line</secondary>
27409 </indexterm>
27410 Some broken SMTP clients insist on sending a UUCP-like <quote>From&nbsp;</quote> line before
27411 the headers of a message. By default this is treated as the start of the
27412 message&#x2019;s body, which means that any following headers are not recognized as
27413 such. Exim can be made to ignore it by setting <option>ignore_fromline_hosts</option> to
27414 match those hosts that insist on sending it. If the sender is actually a local
27415 process rather than a remote host, and is using <option>-bs</option> to inject the messages,
27416 <option>ignore_fromline_local</option> must be set to achieve this effect.
27417 </para>
27418 <para>
27419 <indexterm role="option">
27420 <primary><option>ignore_fromline_local</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>ignore_fromline_local</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 See <option>ignore_fromline_hosts</option> above.
27441 </para>
27442 <para>
27443 <indexterm role="option">
27444 <primary><option>keep_environment</option></primary>
27445 </indexterm>
27446 </para>
27447 <informaltable frame="all">
27448 <tgroup cols="4" colsep="0" rowsep="0">
27449 <colspec colwidth="8*" align="left"/>
27450 <colspec colwidth="6*" align="center"/>
27451 <colspec colwidth="6*" align="center"/>
27452 <colspec colwidth="6*" align="right"/>
27453 <tbody>
27454 <row>
27455 <entry><option>keep_environment</option></entry>
27456 <entry>Use: <emphasis>main</emphasis></entry>
27457 <entry>Type: <emphasis>string list</emphasis></entry>
27458 <entry>Default: <emphasis>unset</emphasis></entry>
27459 </row>
27460 </tbody>
27461 </tgroup>
27462 </informaltable>
27463 <para>
27464 <indexterm role="concept">
27465 <primary>environment</primary>
27466 <secondary>values from</secondary>
27467 </indexterm>
27468 This option contains a string list of environment variables to keep.
27469 You have to trust these variables or you have to be sure that
27470 these variables do not impose any security risk. Keep in mind that
27471 during the startup phase Exim is running with an effective UID 0 in most
27472 installations. As the default value is an empty list, the default
27473 environment for using libraries, running embedded Perl code, or running
27474 external binaries is empty, and does not not even contain PATH or HOME.
27475 </para>
27476 <para>
27477 Actually the list is interpreted as a list of patterns
27478 (<xref linkend="SECTlistexpand"/>), except that it is not expanded first.
27479 </para>
27480 <para>
27481 WARNING: Macro substitution is still done first, so having a macro
27482 FOO and having FOO_HOME in your <option>keep_environment</option> option may have
27483 unexpected results. You may work around this using a regular expression
27484 that does not match the macro name: ^[F]OO_HOME$.
27485 </para>
27486 <para>
27487 Current versions of Exim issue a warning during startup if you do not mention
27488 <option>keep_environment</option> in your runtime configuration file and if your
27489 current environment is not empty. Future versions may not issue that warning
27490 anymore.
27491 </para>
27492 <para>
27493 See the <option>add_environment</option> main config option for a way to set
27494 environment variables to a fixed value.  The environment for <command>pipe</command>
27495 transports is handled separately, see section <xref linkend="SECTpipeenv"/> for
27496 details.
27497 </para>
27498 <para>
27499 <indexterm role="option">
27500 <primary><option>keep_malformed</option></primary>
27501 </indexterm>
27502 </para>
27503 <informaltable frame="all">
27504 <tgroup cols="4" colsep="0" rowsep="0">
27505 <colspec colwidth="8*" align="left"/>
27506 <colspec colwidth="6*" align="center"/>
27507 <colspec colwidth="6*" align="center"/>
27508 <colspec colwidth="6*" align="right"/>
27509 <tbody>
27510 <row>
27511 <entry><option>keep_malformed</option></entry>
27512 <entry>Use: <emphasis>main</emphasis></entry>
27513 <entry>Type: <emphasis>time</emphasis></entry>
27514 <entry>Default: <emphasis>4d</emphasis></entry>
27515 </row>
27516 </tbody>
27517 </tgroup>
27518 </informaltable>
27519 <para>
27520 This option specifies the length of time to keep messages whose spool files
27521 have been corrupted in some way. This should, of course, never happen. At the
27522 next attempt to deliver such a message, it gets removed. The incident is
27523 logged.
27524 </para>
27525 <para>
27526 <indexterm role="option">
27527 <primary><option>ldap_ca_cert_dir</option></primary>
27528 </indexterm>
27529 </para>
27530 <informaltable frame="all">
27531 <tgroup cols="4" colsep="0" rowsep="0">
27532 <colspec colwidth="8*" align="left"/>
27533 <colspec colwidth="6*" align="center"/>
27534 <colspec colwidth="6*" align="center"/>
27535 <colspec colwidth="6*" align="right"/>
27536 <tbody>
27537 <row>
27538 <entry><option>ldap_ca_cert_dir</option></entry>
27539 <entry>Use: <emphasis>main</emphasis></entry>
27540 <entry>Type: <emphasis>string</emphasis></entry>
27541 <entry>Default: <emphasis>unset</emphasis></entry>
27542 </row>
27543 </tbody>
27544 </tgroup>
27545 </informaltable>
27546 <para>
27547 <indexterm role="concept">
27548 <primary>LDAP</primary>
27549 <secondary>,</secondary>
27550 </indexterm>
27551 <indexterm role="concept">
27552 <primary>certificate</primary>
27553 <secondary>directory for LDAP</secondary>
27554 </indexterm>
27555 This option indicates which directory contains CA certificates for verifying
27556 a TLS certificate presented by an LDAP server.
27557 While Exim does not provide a default value, your SSL library may.
27558 Analogous to <option>tls_verify_certificates</option> but as a client-side option for LDAP
27559 and constrained to be a directory.
27560 </para>
27561 <para>
27562 <indexterm role="option">
27563 <primary><option>ldap_ca_cert_file</option></primary>
27564 </indexterm>
27565 </para>
27566 <informaltable frame="all">
27567 <tgroup cols="4" colsep="0" rowsep="0">
27568 <colspec colwidth="8*" align="left"/>
27569 <colspec colwidth="6*" align="center"/>
27570 <colspec colwidth="6*" align="center"/>
27571 <colspec colwidth="6*" align="right"/>
27572 <tbody>
27573 <row>
27574 <entry><option>ldap_ca_cert_file</option></entry>
27575 <entry>Use: <emphasis>main</emphasis></entry>
27576 <entry>Type: <emphasis>string</emphasis></entry>
27577 <entry>Default: <emphasis>unset</emphasis></entry>
27578 </row>
27579 </tbody>
27580 </tgroup>
27581 </informaltable>
27582 <para>
27583 <indexterm role="concept">
27584 <primary>LDAP</primary>
27585 <secondary>,</secondary>
27586 </indexterm>
27587 <indexterm role="concept">
27588 <primary>certificate</primary>
27589 <secondary>file for LDAP</secondary>
27590 </indexterm>
27591 This option indicates which file contains CA certificates for verifying
27592 a TLS certificate presented by an LDAP server.
27593 While Exim does not provide a default value, your SSL library may.
27594 Analogous to <option>tls_verify_certificates</option> but as a client-side option for LDAP
27595 and constrained to be a file.
27596 </para>
27597 <para>
27598 <indexterm role="option">
27599 <primary><option>ldap_cert_file</option></primary>
27600 </indexterm>
27601 </para>
27602 <informaltable frame="all">
27603 <tgroup cols="4" colsep="0" rowsep="0">
27604 <colspec colwidth="8*" align="left"/>
27605 <colspec colwidth="6*" align="center"/>
27606 <colspec colwidth="6*" align="center"/>
27607 <colspec colwidth="6*" align="right"/>
27608 <tbody>
27609 <row>
27610 <entry><option>ldap_cert_file</option></entry>
27611 <entry>Use: <emphasis>main</emphasis></entry>
27612 <entry>Type: <emphasis>string</emphasis></entry>
27613 <entry>Default: <emphasis>unset</emphasis></entry>
27614 </row>
27615 </tbody>
27616 </tgroup>
27617 </informaltable>
27618 <para>
27619 <indexterm role="concept">
27620 <primary>LDAP</primary>
27621 <secondary>TLS client certificate file</secondary>
27622 </indexterm>
27623 <indexterm role="concept">
27624 <primary>certificate</primary>
27625 <secondary>file for LDAP</secondary>
27626 </indexterm>
27627 This option indicates which file contains an TLS client certificate which
27628 Exim should present to the LDAP server during TLS negotiation.
27629 Should be used together with <option>ldap_cert_key</option>.
27630 </para>
27631 <para>
27632 <indexterm role="option">
27633 <primary><option>ldap_cert_key</option></primary>
27634 </indexterm>
27635 </para>
27636 <informaltable frame="all">
27637 <tgroup cols="4" colsep="0" rowsep="0">
27638 <colspec colwidth="8*" align="left"/>
27639 <colspec colwidth="6*" align="center"/>
27640 <colspec colwidth="6*" align="center"/>
27641 <colspec colwidth="6*" align="right"/>
27642 <tbody>
27643 <row>
27644 <entry><option>ldap_cert_key</option></entry>
27645 <entry>Use: <emphasis>main</emphasis></entry>
27646 <entry>Type: <emphasis>string</emphasis></entry>
27647 <entry>Default: <emphasis>unset</emphasis></entry>
27648 </row>
27649 </tbody>
27650 </tgroup>
27651 </informaltable>
27652 <para>
27653 <indexterm role="concept">
27654 <primary>LDAP</primary>
27655 <secondary>TLS client key file</secondary>
27656 </indexterm>
27657 <indexterm role="concept">
27658 <primary>certificate</primary>
27659 <secondary>key for LDAP</secondary>
27660 </indexterm>
27661 This option indicates which file contains the secret/private key to use
27662 to prove identity to the LDAP server during TLS negotiation.
27663 Should be used together with <option>ldap_cert_file</option>, which contains the
27664 identity to be proven.
27665 </para>
27666 <para>
27667 <indexterm role="option">
27668 <primary><option>ldap_cipher_suite</option></primary>
27669 </indexterm>
27670 </para>
27671 <informaltable frame="all">
27672 <tgroup cols="4" colsep="0" rowsep="0">
27673 <colspec colwidth="8*" align="left"/>
27674 <colspec colwidth="6*" align="center"/>
27675 <colspec colwidth="6*" align="center"/>
27676 <colspec colwidth="6*" align="right"/>
27677 <tbody>
27678 <row>
27679 <entry><option>ldap_cipher_suite</option></entry>
27680 <entry>Use: <emphasis>main</emphasis></entry>
27681 <entry>Type: <emphasis>string</emphasis></entry>
27682 <entry>Default: <emphasis>unset</emphasis></entry>
27683 </row>
27684 </tbody>
27685 </tgroup>
27686 </informaltable>
27687 <para>
27688 <indexterm role="concept">
27689 <primary>LDAP</primary>
27690 <secondary>TLS cipher suite</secondary>
27691 </indexterm>
27692 This controls the TLS cipher-suite negotiation during TLS negotiation with
27693 the LDAP server.  See <xref linkend="SECTreqciphssl"/> for more details of the format of
27694 cipher-suite options with OpenSSL (as used by LDAP client libraries).
27695 </para>
27696 <para>
27697 <indexterm role="option">
27698 <primary><option>ldap_default_servers</option></primary>
27699 </indexterm>
27700 </para>
27701 <informaltable frame="all">
27702 <tgroup cols="4" colsep="0" rowsep="0">
27703 <colspec colwidth="8*" align="left"/>
27704 <colspec colwidth="6*" align="center"/>
27705 <colspec colwidth="6*" align="center"/>
27706 <colspec colwidth="6*" align="right"/>
27707 <tbody>
27708 <row>
27709 <entry><option>ldap_default_servers</option></entry>
27710 <entry>Use: <emphasis>main</emphasis></entry>
27711 <entry>Type: <emphasis>string list</emphasis></entry>
27712 <entry>Default: <emphasis>unset</emphasis></entry>
27713 </row>
27714 </tbody>
27715 </tgroup>
27716 </informaltable>
27717 <para>
27718 <indexterm role="concept">
27719 <primary>LDAP</primary>
27720 <secondary>default servers</secondary>
27721 </indexterm>
27722 This option provides a list of LDAP servers which are tried in turn when an
27723 LDAP query does not contain a server. See section <xref linkend="SECTforldaque"/> for
27724 details of LDAP queries. This option is available only when Exim has been built
27725 with LDAP support.
27726 </para>
27727 <para>
27728 <indexterm role="option">
27729 <primary><option>ldap_require_cert</option></primary>
27730 </indexterm>
27731 </para>
27732 <informaltable frame="all">
27733 <tgroup cols="4" colsep="0" rowsep="0">
27734 <colspec colwidth="8*" align="left"/>
27735 <colspec colwidth="6*" align="center"/>
27736 <colspec colwidth="6*" align="center"/>
27737 <colspec colwidth="6*" align="right"/>
27738 <tbody>
27739 <row>
27740 <entry><option>ldap_require_cert</option></entry>
27741 <entry>Use: <emphasis>main</emphasis></entry>
27742 <entry>Type: <emphasis>string</emphasis></entry>
27743 <entry>Default: <emphasis>unset.</emphasis></entry>
27744 </row>
27745 </tbody>
27746 </tgroup>
27747 </informaltable>
27748 <para>
27749 <indexterm role="concept">
27750 <primary>LDAP</primary>
27751 <secondary>policy for LDAP server TLS cert presentation</secondary>
27752 </indexterm>
27753 This should be one of the values "hard", "demand", "allow", "try" or "never".
27754 A value other than one of these is interpreted as "never".
27755 See the entry "TLS_REQCERT" in your system man page for ldap.conf(5).
27756 Although Exim does not set a default, the LDAP library probably defaults
27757 to hard/demand.
27758 </para>
27759 <para>
27760 <indexterm role="option">
27761 <primary><option>ldap_start_tls</option></primary>
27762 </indexterm>
27763 </para>
27764 <informaltable frame="all">
27765 <tgroup cols="4" colsep="0" rowsep="0">
27766 <colspec colwidth="8*" align="left"/>
27767 <colspec colwidth="6*" align="center"/>
27768 <colspec colwidth="6*" align="center"/>
27769 <colspec colwidth="6*" align="right"/>
27770 <tbody>
27771 <row>
27772 <entry><option>ldap_start_tls</option></entry>
27773 <entry>Use: <emphasis>main</emphasis></entry>
27774 <entry>Type: <emphasis>boolean</emphasis></entry>
27775 <entry>Default: <emphasis>false</emphasis></entry>
27776 </row>
27777 </tbody>
27778 </tgroup>
27779 </informaltable>
27780 <para>
27781 <indexterm role="concept">
27782 <primary>LDAP</primary>
27783 <secondary>whether or not to negotiate TLS</secondary>
27784 </indexterm>
27785 If set, Exim will attempt to negotiate TLS with the LDAP server when
27786 connecting on a regular LDAP port.  This is the LDAP equivalent of SMTP&#x2019;s
27787 "STARTTLS".  This is distinct from using "ldaps", which is the LDAP form
27788 of SSL-on-connect.
27789 In the event of failure to negotiate TLS, the action taken is controlled
27790 by <option>ldap_require_cert</option>.
27791 This option is ignored for <literal>ldapi</literal> connections.
27792 </para>
27793 <para>
27794 <indexterm role="option">
27795 <primary><option>ldap_version</option></primary>
27796 </indexterm>
27797 </para>
27798 <informaltable frame="all">
27799 <tgroup cols="4" colsep="0" rowsep="0">
27800 <colspec colwidth="8*" align="left"/>
27801 <colspec colwidth="6*" align="center"/>
27802 <colspec colwidth="6*" align="center"/>
27803 <colspec colwidth="6*" align="right"/>
27804 <tbody>
27805 <row>
27806 <entry><option>ldap_version</option></entry>
27807 <entry>Use: <emphasis>main</emphasis></entry>
27808 <entry>Type: <emphasis>integer</emphasis></entry>
27809 <entry>Default: <emphasis>unset</emphasis></entry>
27810 </row>
27811 </tbody>
27812 </tgroup>
27813 </informaltable>
27814 <para>
27815 <indexterm role="concept">
27816 <primary>LDAP</primary>
27817 <secondary>protocol version, forcing</secondary>
27818 </indexterm>
27819 This option can be used to force Exim to set a specific protocol version for
27820 LDAP. If it option is unset, it is shown by the <option>-bP</option> command line option as
27821 -1. When this is the case, the default is 3 if LDAP_VERSION3 is defined in
27822 the LDAP headers; otherwise it is 2. This option is available only when Exim
27823 has been built with LDAP support.
27824 </para>
27825 <para>
27826 <indexterm role="option">
27827 <primary><option>local_from_check</option></primary>
27828 </indexterm>
27829 </para>
27830 <informaltable frame="all">
27831 <tgroup cols="4" colsep="0" rowsep="0">
27832 <colspec colwidth="8*" align="left"/>
27833 <colspec colwidth="6*" align="center"/>
27834 <colspec colwidth="6*" align="center"/>
27835 <colspec colwidth="6*" align="right"/>
27836 <tbody>
27837 <row>
27838 <entry><option>local_from_check</option></entry>
27839 <entry>Use: <emphasis>main</emphasis></entry>
27840 <entry>Type: <emphasis>boolean</emphasis></entry>
27841 <entry>Default: <emphasis>true</emphasis></entry>
27842 </row>
27843 </tbody>
27844 </tgroup>
27845 </informaltable>
27846 <para>
27847 <indexterm role="concept">
27848 <primary><emphasis>Sender:</emphasis> header line</primary>
27849 <secondary>disabling addition of</secondary>
27850 </indexterm>
27851 <indexterm role="concept">
27852 <primary><emphasis>From:</emphasis> header line</primary>
27853 <secondary>disabling checking of</secondary>
27854 </indexterm>
27855 When a message is submitted locally (that is, not over a TCP/IP connection) by
27856 an untrusted user, Exim removes any existing <emphasis>Sender:</emphasis> header line, and
27857 checks that the <emphasis>From:</emphasis> header line matches the login of the calling user and
27858 the domain specified by <option>qualify_domain</option>.
27859 </para>
27860 <para>
27861 <emphasis role="bold">Note</emphasis>: An unqualified address (no domain) in the <emphasis>From:</emphasis> header in a
27862 locally submitted message is automatically qualified by Exim, unless the
27863 <option>-bnq</option> command line option is used.
27864 </para>
27865 <para>
27866 You can use <option>local_from_prefix</option> and <option>local_from_suffix</option> to permit affixes
27867 on the local part. If the <emphasis>From:</emphasis> header line does not match, Exim adds a
27868 <emphasis>Sender:</emphasis> header with an address constructed from the calling user&#x2019;s login
27869 and the default qualify domain.
27870 </para>
27871 <para>
27872 If <option>local_from_check</option> is set false, the <emphasis>From:</emphasis> header check is disabled,
27873 and no <emphasis>Sender:</emphasis> header is ever added. If, in addition, you want to retain
27874 <emphasis>Sender:</emphasis> header lines supplied by untrusted users, you must also set
27875 <option>local_sender_retain</option> to be true.
27876 </para>
27877 <para>
27878 <indexterm role="concept">
27879 <primary>envelope from</primary>
27880 </indexterm>
27881 <indexterm role="concept">
27882 <primary>envelope sender</primary>
27883 </indexterm>
27884 These options affect only the header lines in the message. The envelope sender
27885 is still forced to be the login id at the qualify domain unless
27886 <option>untrusted_set_sender</option> permits the user to supply an envelope sender.
27887 </para>
27888 <para>
27889 For messages received over TCP/IP, an ACL can specify <quote>submission mode</quote> to
27890 request similar header line checking. See section <xref linkend="SECTthesenhea"/>, which
27891 has more details about <emphasis>Sender:</emphasis> processing.
27892 </para>
27893 <para>
27894 <indexterm role="option">
27895 <primary><option>local_from_prefix</option></primary>
27896 </indexterm>
27897 </para>
27898 <informaltable frame="all">
27899 <tgroup cols="4" colsep="0" rowsep="0">
27900 <colspec colwidth="8*" align="left"/>
27901 <colspec colwidth="6*" align="center"/>
27902 <colspec colwidth="6*" align="center"/>
27903 <colspec colwidth="6*" align="right"/>
27904 <tbody>
27905 <row>
27906 <entry><option>local_from_prefix</option></entry>
27907 <entry>Use: <emphasis>main</emphasis></entry>
27908 <entry>Type: <emphasis>string</emphasis></entry>
27909 <entry>Default: <emphasis>unset</emphasis></entry>
27910 </row>
27911 </tbody>
27912 </tgroup>
27913 </informaltable>
27914 <para>
27915 When Exim checks the <emphasis>From:</emphasis> header line of locally submitted messages for
27916 matching the login id (see <option>local_from_check</option> above), it can be configured to
27917 ignore certain prefixes and suffixes in the local part of the address. This is
27918 done by setting <option>local_from_prefix</option> and/or <option>local_from_suffix</option> to
27919 appropriate lists, in the same form as the <option>local_part_prefix</option> and
27920 <option>local_part_suffix</option> router options (see chapter <xref linkend="CHAProutergeneric"/>). For
27921 example, if
27922 </para>
27923 <literallayout class="monospaced">
27924 local_from_prefix = *-
27925 </literallayout>
27926 <para>
27927 is set, a <emphasis>From:</emphasis> line containing
27928 </para>
27929 <literallayout class="monospaced">
27930 From: anything-user@your.domain.example
27931 </literallayout>
27932 <para>
27933 will not cause a <emphasis>Sender:</emphasis> header to be added if <emphasis>user@your.domain.example</emphasis>
27934 matches the actual sender address that is constructed from the login name and
27935 qualify domain.
27936 </para>
27937 <para>
27938 <indexterm role="option">
27939 <primary><option>local_from_suffix</option></primary>
27940 </indexterm>
27941 </para>
27942 <informaltable frame="all">
27943 <tgroup cols="4" colsep="0" rowsep="0">
27944 <colspec colwidth="8*" align="left"/>
27945 <colspec colwidth="6*" align="center"/>
27946 <colspec colwidth="6*" align="center"/>
27947 <colspec colwidth="6*" align="right"/>
27948 <tbody>
27949 <row>
27950 <entry><option>local_from_suffix</option></entry>
27951 <entry>Use: <emphasis>main</emphasis></entry>
27952 <entry>Type: <emphasis>string</emphasis></entry>
27953 <entry>Default: <emphasis>unset</emphasis></entry>
27954 </row>
27955 </tbody>
27956 </tgroup>
27957 </informaltable>
27958 <para>
27959 See <option>local_from_prefix</option> above.
27960 </para>
27961 <para>
27962 <indexterm role="option">
27963 <primary><option>local_interfaces</option></primary>
27964 </indexterm>
27965 </para>
27966 <informaltable frame="all">
27967 <tgroup cols="4" colsep="0" rowsep="0">
27968 <colspec colwidth="8*" align="left"/>
27969 <colspec colwidth="6*" align="center"/>
27970 <colspec colwidth="6*" align="center"/>
27971 <colspec colwidth="6*" align="right"/>
27972 <tbody>
27973 <row>
27974 <entry><option>local_interfaces</option></entry>
27975 <entry>Use: <emphasis>main</emphasis></entry>
27976 <entry>Type: <emphasis>string list</emphasis></entry>
27977 <entry>Default: <emphasis>see below</emphasis></entry>
27978 </row>
27979 </tbody>
27980 </tgroup>
27981 </informaltable>
27982 <para>
27983 This option controls which network interfaces are used by the daemon for
27984 listening; they are also used to identify the local host when routing. Chapter
27985 <xref linkend="CHAPinterfaces"/> contains a full description of this option and the related
27986 options <option>daemon_smtp_ports</option>, <option>extra_local_interfaces</option>,
27987 <option>hosts_treat_as_local</option>, and <option>tls_on_connect_ports</option>. The default value for
27988 <option>local_interfaces</option> is
27989 </para>
27990 <literallayout class="monospaced">
27991 local_interfaces = 0.0.0.0
27992 </literallayout>
27993 <para>
27994 when Exim is built without IPv6 support; otherwise it is
27995 </para>
27996 <literallayout class="monospaced">
27997 local_interfaces = &lt;; ::0 ; 0.0.0.0
27998 </literallayout>
27999 <para>
28000 <indexterm role="option">
28001 <primary><option>local_scan_timeout</option></primary>
28002 </indexterm>
28003 </para>
28004 <informaltable frame="all">
28005 <tgroup cols="4" colsep="0" rowsep="0">
28006 <colspec colwidth="8*" align="left"/>
28007 <colspec colwidth="6*" align="center"/>
28008 <colspec colwidth="6*" align="center"/>
28009 <colspec colwidth="6*" align="right"/>
28010 <tbody>
28011 <row>
28012 <entry><option>local_scan_timeout</option></entry>
28013 <entry>Use: <emphasis>main</emphasis></entry>
28014 <entry>Type: <emphasis>time</emphasis></entry>
28015 <entry>Default: <emphasis>5m</emphasis></entry>
28016 </row>
28017 </tbody>
28018 </tgroup>
28019 </informaltable>
28020 <para>
28021 <indexterm role="concept">
28022 <primary>timeout</primary>
28023 <secondary>for <function>local_scan()</function> function</secondary>
28024 </indexterm>
28025 <indexterm role="concept">
28026 <primary><function>local_scan()</function> function</primary>
28027 <secondary>timeout</secondary>
28028 </indexterm>
28029 This timeout applies to the <function>local_scan()</function> function (see chapter
28030 <xref linkend="CHAPlocalscan"/>). Zero means <quote>no timeout</quote>. If the timeout is exceeded,
28031 the incoming message is rejected with a temporary error if it is an SMTP
28032 message. For a non-SMTP message, the message is dropped and Exim ends with a
28033 non-zero code. The incident is logged on the main and reject logs.
28034 </para>
28035 <para>
28036 <indexterm role="option">
28037 <primary><option>local_sender_retain</option></primary>
28038 </indexterm>
28039 </para>
28040 <informaltable frame="all">
28041 <tgroup cols="4" colsep="0" rowsep="0">
28042 <colspec colwidth="8*" align="left"/>
28043 <colspec colwidth="6*" align="center"/>
28044 <colspec colwidth="6*" align="center"/>
28045 <colspec colwidth="6*" align="right"/>
28046 <tbody>
28047 <row>
28048 <entry><option>local_sender_retain</option></entry>
28049 <entry>Use: <emphasis>main</emphasis></entry>
28050 <entry>Type: <emphasis>boolean</emphasis></entry>
28051 <entry>Default: <emphasis>false</emphasis></entry>
28052 </row>
28053 </tbody>
28054 </tgroup>
28055 </informaltable>
28056 <para>
28057 <indexterm role="concept">
28058 <primary><emphasis>Sender:</emphasis> header line</primary>
28059 <secondary>retaining from local submission</secondary>
28060 </indexterm>
28061 When a message is submitted locally (that is, not over a TCP/IP connection) by
28062 an untrusted user, Exim removes any existing <emphasis>Sender:</emphasis> header line. If you
28063 do not want this to happen, you must set <option>local_sender_retain</option>, and you must
28064 also set <option>local_from_check</option> to be false (Exim will complain if you do not).
28065 See also the ACL modifier <literal>control = suppress_local_fixups</literal>. Section
28066 <xref linkend="SECTthesenhea"/> has more details about <emphasis>Sender:</emphasis> processing.
28067 </para>
28068 <para>
28069 <indexterm role="option">
28070 <primary><option>localhost_number</option></primary>
28071 </indexterm>
28072 </para>
28073 <informaltable frame="all">
28074 <tgroup cols="4" colsep="0" rowsep="0">
28075 <colspec colwidth="8*" align="left"/>
28076 <colspec colwidth="6*" align="center"/>
28077 <colspec colwidth="6*" align="center"/>
28078 <colspec colwidth="6*" align="right"/>
28079 <tbody>
28080 <row>
28081 <entry><option>localhost_number</option></entry>
28082 <entry>Use: <emphasis>main</emphasis></entry>
28083 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28084 <entry>Default: <emphasis>unset</emphasis></entry>
28085 </row>
28086 </tbody>
28087 </tgroup>
28088 </informaltable>
28089 <para>
28090 <indexterm role="concept">
28091 <primary>host</primary>
28092 <secondary>locally unique number for</secondary>
28093 </indexterm>
28094 <indexterm role="concept">
28095 <primary>message ids</primary>
28096 <secondary>with multiple hosts</secondary>
28097 </indexterm>
28098 <indexterm role="variable">
28099 <primary><varname>$localhost_number</varname></primary>
28100 </indexterm>
28101 Exim&#x2019;s message ids are normally unique only within the local host. If
28102 uniqueness among a set of hosts is required, each host must set a different
28103 value for the <option>localhost_number</option> option. The string is expanded immediately
28104 after reading the configuration file (so that a number can be computed from the
28105 host name, for example) and the result of the expansion must be a number in the
28106 range 0&ndash;16 (or 0&ndash;10 on operating systems with case-insensitive file
28107 systems). This is available in subsequent string expansions via the variable
28108 <varname>$localhost_number</varname>. When <option>localhost_number is set</option>, the final two
28109 characters of the message id, instead of just being a fractional part of the
28110 time, are computed from the time and the local host number as described in
28111 section <xref linkend="SECTmessiden"/>.
28112 </para>
28113 <para>
28114 <indexterm role="option">
28115 <primary><option>log_file_path</option></primary>
28116 </indexterm>
28117 </para>
28118 <informaltable frame="all">
28119 <tgroup cols="4" colsep="0" rowsep="0">
28120 <colspec colwidth="8*" align="left"/>
28121 <colspec colwidth="6*" align="center"/>
28122 <colspec colwidth="6*" align="center"/>
28123 <colspec colwidth="6*" align="right"/>
28124 <tbody>
28125 <row>
28126 <entry><option>log_file_path</option></entry>
28127 <entry>Use: <emphasis>main</emphasis></entry>
28128 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
28129 <entry>Default: <emphasis>set at compile time</emphasis></entry>
28130 </row>
28131 </tbody>
28132 </tgroup>
28133 </informaltable>
28134 <para>
28135 <indexterm role="concept">
28136 <primary>log</primary>
28137 <secondary>file path for</secondary>
28138 </indexterm>
28139 This option sets the path which is used to determine the names of Exim&#x2019;s log
28140 files, or indicates that logging is to be to syslog, or both. It is expanded
28141 when Exim is entered, so it can, for example, contain a reference to the host
28142 name. If no specific path is set for the log files at compile or runtime,
28143 or if the option is unset at runtime (i.e.  <literal>log_file_path = </literal>)
28144 they are written in a sub-directory called <filename>log</filename> in Exim&#x2019;s spool directory.
28145 </para>
28146 <para revisionflag="changed">
28147 A path must start with a slash.
28148 To send to syslog, use the word <quote>syslog</quote>.
28149 </para>
28150 <para>
28151 Chapter <xref linkend="CHAPlog"/> contains further details about Exim&#x2019;s logging, and
28152 section <xref linkend="SECTwhelogwri"/> describes how the contents of <option>log_file_path</option> are
28153 used. If this string is fixed at your installation (contains no expansion
28154 variables) it is recommended that you do not set this option in the
28155 configuration file, but instead supply the path using LOG_FILE_PATH in
28156 <filename>Local/Makefile</filename> so that it is available to Exim for logging errors detected
28157 early on &ndash; in particular, failure to read the configuration file.
28158 </para>
28159 <para>
28160 <indexterm role="option">
28161 <primary><option>log_selector</option></primary>
28162 </indexterm>
28163 </para>
28164 <informaltable frame="all">
28165 <tgroup cols="4" colsep="0" rowsep="0">
28166 <colspec colwidth="8*" align="left"/>
28167 <colspec colwidth="6*" align="center"/>
28168 <colspec colwidth="6*" align="center"/>
28169 <colspec colwidth="6*" align="right"/>
28170 <tbody>
28171 <row>
28172 <entry><option>log_selector</option></entry>
28173 <entry>Use: <emphasis>main</emphasis></entry>
28174 <entry>Type: <emphasis>string</emphasis></entry>
28175 <entry>Default: <emphasis>unset</emphasis></entry>
28176 </row>
28177 </tbody>
28178 </tgroup>
28179 </informaltable>
28180 <para>
28181 <indexterm role="concept">
28182 <primary>log</primary>
28183 <secondary>selectors</secondary>
28184 </indexterm>
28185 This option can be used to reduce or increase the number of things that Exim
28186 writes to its log files. Its argument is made up of names preceded by plus or
28187 minus characters. For example:
28188 </para>
28189 <literallayout class="monospaced">
28190 log_selector = +arguments -retry_defer
28191 </literallayout>
28192 <para>
28193 A list of possible names and what they control is given in the chapter on
28194 logging, in section <xref linkend="SECTlogselector"/>.
28195 </para>
28196 <para>
28197 <indexterm role="option">
28198 <primary><option>log_timezone</option></primary>
28199 </indexterm>
28200 </para>
28201 <informaltable frame="all">
28202 <tgroup cols="4" colsep="0" rowsep="0">
28203 <colspec colwidth="8*" align="left"/>
28204 <colspec colwidth="6*" align="center"/>
28205 <colspec colwidth="6*" align="center"/>
28206 <colspec colwidth="6*" align="right"/>
28207 <tbody>
28208 <row>
28209 <entry><option>log_timezone</option></entry>
28210 <entry>Use: <emphasis>main</emphasis></entry>
28211 <entry>Type: <emphasis>boolean</emphasis></entry>
28212 <entry>Default: <emphasis>false</emphasis></entry>
28213 </row>
28214 </tbody>
28215 </tgroup>
28216 </informaltable>
28217 <para>
28218 <indexterm role="concept">
28219 <primary>log</primary>
28220 <secondary>timezone for entries</secondary>
28221 </indexterm>
28222 <indexterm role="variable">
28223 <primary><varname>$tod_log</varname></primary>
28224 </indexterm>
28225 <indexterm role="variable">
28226 <primary><varname>$tod_zone</varname></primary>
28227 </indexterm>
28228 By default, the timestamps on log lines are in local time without the
28229 timezone. This means that if your timezone changes twice a year, the timestamps
28230 in log lines are ambiguous for an hour when the clocks go back. One way of
28231 avoiding this problem is to set the timezone to UTC. An alternative is to set
28232 <option>log_timezone</option> true. This turns on the addition of the timezone offset to
28233 timestamps in log lines. Turning on this option can add quite a lot to the size
28234 of log files because each line is extended by 6 characters. Note that the
28235 <varname>$tod_log</varname> variable contains the log timestamp without the zone, but there is
28236 another variable called <varname>$tod_zone</varname> that contains just the timezone offset.
28237 </para>
28238 <para>
28239 <indexterm role="option">
28240 <primary><option>lookup_open_max</option></primary>
28241 </indexterm>
28242 </para>
28243 <informaltable frame="all">
28244 <tgroup cols="4" colsep="0" rowsep="0">
28245 <colspec colwidth="8*" align="left"/>
28246 <colspec colwidth="6*" align="center"/>
28247 <colspec colwidth="6*" align="center"/>
28248 <colspec colwidth="6*" align="right"/>
28249 <tbody>
28250 <row>
28251 <entry><option>lookup_open_max</option></entry>
28252 <entry>Use: <emphasis>main</emphasis></entry>
28253 <entry>Type: <emphasis>integer</emphasis></entry>
28254 <entry>Default: <emphasis>25</emphasis></entry>
28255 </row>
28256 </tbody>
28257 </tgroup>
28258 </informaltable>
28259 <para>
28260 <indexterm role="concept">
28261 <primary>too many open files</primary>
28262 </indexterm>
28263 <indexterm role="concept">
28264 <primary>open files, too many</primary>
28265 </indexterm>
28266 <indexterm role="concept">
28267 <primary>file</primary>
28268 <secondary>too many open</secondary>
28269 </indexterm>
28270 <indexterm role="concept">
28271 <primary>lookup</primary>
28272 <secondary>maximum open files</secondary>
28273 </indexterm>
28274 <indexterm role="concept">
28275 <primary>limit</primary>
28276 <secondary>open files for lookups</secondary>
28277 </indexterm>
28278 This option limits the number of simultaneously open files for single-key
28279 lookups that use regular files (that is, <command>lsearch</command>, <command>dbm</command>, and <command>cdb</command>).
28280 Exim normally keeps these files open during routing, because often the same
28281 file is required several times. If the limit is reached, Exim closes the least
28282 recently used file. Note that if you are using the <emphasis>ndbm</emphasis> library, it
28283 actually opens two files for each logical DBM database, though it still counts
28284 as one for the purposes of <option>lookup_open_max</option>. If you are getting <quote>too many
28285 open files</quote> errors with NDBM, you need to reduce the value of
28286 <option>lookup_open_max</option>.
28287 </para>
28288 <para>
28289 <indexterm role="option">
28290 <primary><option>max_username_length</option></primary>
28291 </indexterm>
28292 </para>
28293 <informaltable frame="all">
28294 <tgroup cols="4" colsep="0" rowsep="0">
28295 <colspec colwidth="8*" align="left"/>
28296 <colspec colwidth="6*" align="center"/>
28297 <colspec colwidth="6*" align="center"/>
28298 <colspec colwidth="6*" align="right"/>
28299 <tbody>
28300 <row>
28301 <entry><option>max_username_length</option></entry>
28302 <entry>Use: <emphasis>main</emphasis></entry>
28303 <entry>Type: <emphasis>integer</emphasis></entry>
28304 <entry>Default: <emphasis>0</emphasis></entry>
28305 </row>
28306 </tbody>
28307 </tgroup>
28308 </informaltable>
28309 <para>
28310 <indexterm role="concept">
28311 <primary>length of login name</primary>
28312 </indexterm>
28313 <indexterm role="concept">
28314 <primary>user name</primary>
28315 <secondary>maximum length</secondary>
28316 </indexterm>
28317 <indexterm role="concept">
28318 <primary>limit</primary>
28319 <secondary>user name length</secondary>
28320 </indexterm>
28321 Some operating systems are broken in that they truncate long arguments to
28322 <function>getpwnam()</function> to eight characters, instead of returning <quote>no such user</quote>. If
28323 this option is set greater than zero, any attempt to call <function>getpwnam()</function> with
28324 an argument that is longer behaves as if <function>getpwnam()</function> failed.
28325 </para>
28326 <para>
28327 <indexterm role="option">
28328 <primary><option>message_body_newlines</option></primary>
28329 </indexterm>
28330 </para>
28331 <informaltable frame="all">
28332 <tgroup cols="4" colsep="0" rowsep="0">
28333 <colspec colwidth="8*" align="left"/>
28334 <colspec colwidth="6*" align="center"/>
28335 <colspec colwidth="6*" align="center"/>
28336 <colspec colwidth="6*" align="right"/>
28337 <tbody>
28338 <row>
28339 <entry><option>message_body_newlines</option></entry>
28340 <entry>Use: <emphasis>main</emphasis></entry>
28341 <entry>Type: <emphasis>bool</emphasis></entry>
28342 <entry>Default: <emphasis>false</emphasis></entry>
28343 </row>
28344 </tbody>
28345 </tgroup>
28346 </informaltable>
28347 <para>
28348 <indexterm role="concept">
28349 <primary>message body</primary>
28350 <secondary>newlines in variables</secondary>
28351 </indexterm>
28352 <indexterm role="concept">
28353 <primary>newline</primary>
28354 <secondary>in message body variables</secondary>
28355 </indexterm>
28356 <indexterm role="variable">
28357 <primary><varname>$message_body</varname></primary>
28358 </indexterm>
28359 <indexterm role="variable">
28360 <primary><varname>$message_body_end</varname></primary>
28361 </indexterm>
28362 By default, newlines in the message body are replaced by spaces when setting
28363 the <varname>$message_body</varname> and <varname>$message_body_end</varname> expansion variables. If this
28364 option is set true, this no longer happens.
28365 </para>
28366 <para>
28367 <indexterm role="option">
28368 <primary><option>message_body_visible</option></primary>
28369 </indexterm>
28370 </para>
28371 <informaltable frame="all">
28372 <tgroup cols="4" colsep="0" rowsep="0">
28373 <colspec colwidth="8*" align="left"/>
28374 <colspec colwidth="6*" align="center"/>
28375 <colspec colwidth="6*" align="center"/>
28376 <colspec colwidth="6*" align="right"/>
28377 <tbody>
28378 <row>
28379 <entry><option>message_body_visible</option></entry>
28380 <entry>Use: <emphasis>main</emphasis></entry>
28381 <entry>Type: <emphasis>integer</emphasis></entry>
28382 <entry>Default: <emphasis>500</emphasis></entry>
28383 </row>
28384 </tbody>
28385 </tgroup>
28386 </informaltable>
28387 <para>
28388 <indexterm role="concept">
28389 <primary>body of message</primary>
28390 <secondary>visible size</secondary>
28391 </indexterm>
28392 <indexterm role="concept">
28393 <primary>message body</primary>
28394 <secondary>visible size</secondary>
28395 </indexterm>
28396 <indexterm role="variable">
28397 <primary><varname>$message_body</varname></primary>
28398 </indexterm>
28399 <indexterm role="variable">
28400 <primary><varname>$message_body_end</varname></primary>
28401 </indexterm>
28402 This option specifies how much of a message&#x2019;s body is to be included in the
28403 <varname>$message_body</varname> and <varname>$message_body_end</varname> expansion variables.
28404 </para>
28405 <para>
28406 <indexterm role="option">
28407 <primary><option>message_id_header_domain</option></primary>
28408 </indexterm>
28409 </para>
28410 <informaltable frame="all">
28411 <tgroup cols="4" colsep="0" rowsep="0">
28412 <colspec colwidth="8*" align="left"/>
28413 <colspec colwidth="6*" align="center"/>
28414 <colspec colwidth="6*" align="center"/>
28415 <colspec colwidth="6*" align="right"/>
28416 <tbody>
28417 <row>
28418 <entry><option>message_id_header_domain</option></entry>
28419 <entry>Use: <emphasis>main</emphasis></entry>
28420 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28421 <entry>Default: <emphasis>unset</emphasis></entry>
28422 </row>
28423 </tbody>
28424 </tgroup>
28425 </informaltable>
28426 <para>
28427 <indexterm role="concept">
28428 <primary><emphasis>Message-ID:</emphasis> header line</primary>
28429 </indexterm>
28430 If this option is set, the string is expanded and used as the right hand side
28431 (domain) of the <emphasis>Message-ID:</emphasis> header that Exim creates if a
28432 locally-originated incoming message does not have one. <quote>Locally-originated</quote>
28433 means <quote>not received over TCP/IP.</quote>
28434 Otherwise, the primary host name is used.
28435 Only letters, digits, dot and hyphen are accepted; any other characters are
28436 replaced by hyphens. If the expansion is forced to fail, or if the result is an
28437 empty string, the option is ignored.
28438 </para>
28439 <para>
28440 <indexterm role="option">
28441 <primary><option>message_id_header_text</option></primary>
28442 </indexterm>
28443 </para>
28444 <informaltable frame="all">
28445 <tgroup cols="4" colsep="0" rowsep="0">
28446 <colspec colwidth="8*" align="left"/>
28447 <colspec colwidth="6*" align="center"/>
28448 <colspec colwidth="6*" align="center"/>
28449 <colspec colwidth="6*" align="right"/>
28450 <tbody>
28451 <row>
28452 <entry><option>message_id_header_text</option></entry>
28453 <entry>Use: <emphasis>main</emphasis></entry>
28454 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28455 <entry>Default: <emphasis>unset</emphasis></entry>
28456 </row>
28457 </tbody>
28458 </tgroup>
28459 </informaltable>
28460 <para>
28461 If this variable is set, the string is expanded and used to augment the text of
28462 the <emphasis>Message-id:</emphasis> header that Exim creates if a locally-originated incoming
28463 message does not have one. The text of this header is required by RFC 2822 to
28464 take the form of an address. By default, Exim uses its internal message id as
28465 the local part, and the primary host name as the domain. If this option is set,
28466 it is expanded, and provided the expansion is not forced to fail, and does not
28467 yield an empty string, the result is inserted into the header immediately
28468 before the @, separated from the internal message id by a dot. Any characters
28469 that are illegal in an address are automatically converted into hyphens. This
28470 means that variables such as <varname>$tod_log</varname> can be used, because the spaces and
28471 colons will become hyphens.
28472 </para>
28473 <para>
28474 <indexterm role="option">
28475 <primary><option>message_logs</option></primary>
28476 </indexterm>
28477 </para>
28478 <informaltable frame="all">
28479 <tgroup cols="4" colsep="0" rowsep="0">
28480 <colspec colwidth="8*" align="left"/>
28481 <colspec colwidth="6*" align="center"/>
28482 <colspec colwidth="6*" align="center"/>
28483 <colspec colwidth="6*" align="right"/>
28484 <tbody>
28485 <row>
28486 <entry><option>message_logs</option></entry>
28487 <entry>Use: <emphasis>main</emphasis></entry>
28488 <entry>Type: <emphasis>boolean</emphasis></entry>
28489 <entry>Default: <emphasis>true</emphasis></entry>
28490 </row>
28491 </tbody>
28492 </tgroup>
28493 </informaltable>
28494 <para>
28495 <indexterm role="concept">
28496 <primary>message logs</primary>
28497 <secondary>disabling</secondary>
28498 </indexterm>
28499 <indexterm role="concept">
28500 <primary>log</primary>
28501 <secondary>message log; disabling</secondary>
28502 </indexterm>
28503 If this option is turned off, per-message log files are not created in the
28504 <filename>msglog</filename> spool sub-directory. This reduces the amount of disk I/O required by
28505 Exim, by reducing the number of files involved in handling a message from a
28506 minimum of four (header spool file, body spool file, delivery journal, and
28507 per-message log) to three. The other major I/O activity is Exim&#x2019;s main log,
28508 which is not affected by this option.
28509 </para>
28510 <para>
28511 <indexterm role="option">
28512 <primary><option>message_size_limit</option></primary>
28513 </indexterm>
28514 </para>
28515 <informaltable frame="all">
28516 <tgroup cols="4" colsep="0" rowsep="0">
28517 <colspec colwidth="8*" align="left"/>
28518 <colspec colwidth="6*" align="center"/>
28519 <colspec colwidth="6*" align="center"/>
28520 <colspec colwidth="6*" align="right"/>
28521 <tbody>
28522 <row>
28523 <entry><option>message_size_limit</option></entry>
28524 <entry>Use: <emphasis>main</emphasis></entry>
28525 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28526 <entry>Default: <emphasis>50M</emphasis></entry>
28527 </row>
28528 </tbody>
28529 </tgroup>
28530 </informaltable>
28531 <para>
28532 <indexterm role="concept">
28533 <primary>message</primary>
28534 <secondary>size limit</secondary>
28535 </indexterm>
28536 <indexterm role="concept">
28537 <primary>limit</primary>
28538 <secondary>message size</secondary>
28539 </indexterm>
28540 <indexterm role="concept">
28541 <primary>size</primary>
28542 <secondary>of message, limit</secondary>
28543 </indexterm>
28544 This option limits the maximum size of message that Exim will process. The
28545 value is expanded for each incoming connection so, for example, it can be made
28546 to depend on the IP address of the remote host for messages arriving via
28547 TCP/IP. After expansion, the value must be a sequence of decimal digits,
28548 optionally followed by K or M.
28549 </para>
28550 <para>
28551 <emphasis role="bold">Note</emphasis>: This limit cannot be made to depend on a message&#x2019;s sender or any
28552 other properties of an individual message, because it has to be advertised in
28553 the server&#x2019;s response to EHLO. String expansion failure causes a temporary
28554 error. A value of zero means no limit, but its use is not recommended. See also
28555 <option>bounce_return_size_limit</option>.
28556 </para>
28557 <para>
28558 Incoming SMTP messages are failed with a 552 error if the limit is
28559 exceeded; locally-generated messages either get a stderr message or a delivery
28560 failure message to the sender, depending on the <option>-oe</option> setting. Rejection of
28561 an oversized message is logged in both the main and the reject logs. See also
28562 the generic transport option <option>message_size_limit</option>, which limits the size of
28563 message that an individual transport can process.
28564 </para>
28565 <para>
28566 If you use a virus-scanner and set this option to to a value larger than the
28567 maximum size that your virus-scanner is configured to support, you may get
28568 failures triggered by large mails.  The right size to configure for the
28569 virus-scanner depends upon what data is passed and the options in use but it&#x2019;s
28570 probably safest to just set it to a little larger than this value.  E.g., with a
28571 default Exim message size of 50M and a default ClamAV StreamMaxLength of 10M,
28572 some problems may result.
28573 </para>
28574 <para>
28575 A value of 0 will disable size limit checking; Exim will still advertise the
28576 SIZE extension in an EHLO response, but without a limit, so as to permit
28577 SMTP clients to still indicate the message size along with the MAIL verb.
28578 </para>
28579 <para>
28580 <indexterm role="option">
28581 <primary><option>move_frozen_messages</option></primary>
28582 </indexterm>
28583 </para>
28584 <informaltable frame="all">
28585 <tgroup cols="4" colsep="0" rowsep="0">
28586 <colspec colwidth="8*" align="left"/>
28587 <colspec colwidth="6*" align="center"/>
28588 <colspec colwidth="6*" align="center"/>
28589 <colspec colwidth="6*" align="right"/>
28590 <tbody>
28591 <row>
28592 <entry><option>move_frozen_messages</option></entry>
28593 <entry>Use: <emphasis>main</emphasis></entry>
28594 <entry>Type: <emphasis>boolean</emphasis></entry>
28595 <entry>Default: <emphasis>false</emphasis></entry>
28596 </row>
28597 </tbody>
28598 </tgroup>
28599 </informaltable>
28600 <para>
28601 <indexterm role="concept">
28602 <primary>frozen messages</primary>
28603 <secondary>moving</secondary>
28604 </indexterm>
28605 This option, which is available only if Exim has been built with the setting
28606 </para>
28607 <literallayout class="monospaced">
28608 SUPPORT_MOVE_FROZEN_MESSAGES=yes
28609 </literallayout>
28610 <para>
28611 in <filename>Local/Makefile</filename>, causes frozen messages and their message logs to be
28612 moved from the <filename>input</filename> and <filename>msglog</filename> directories on the spool to <filename>Finput</filename>
28613 and <filename>Fmsglog</filename>, respectively. There is currently no support in Exim or the
28614 standard utilities for handling such moved messages, and they do not show up in
28615 lists generated by <option>-bp</option> or by the Exim monitor.
28616 </para>
28617 <para>
28618 <indexterm role="option">
28619 <primary><option>mua_wrapper</option></primary>
28620 </indexterm>
28621 </para>
28622 <informaltable frame="all">
28623 <tgroup cols="4" colsep="0" rowsep="0">
28624 <colspec colwidth="8*" align="left"/>
28625 <colspec colwidth="6*" align="center"/>
28626 <colspec colwidth="6*" align="center"/>
28627 <colspec colwidth="6*" align="right"/>
28628 <tbody>
28629 <row>
28630 <entry><option>mua_wrapper</option></entry>
28631 <entry>Use: <emphasis>main</emphasis></entry>
28632 <entry>Type: <emphasis>boolean</emphasis></entry>
28633 <entry>Default: <emphasis>false</emphasis></entry>
28634 </row>
28635 </tbody>
28636 </tgroup>
28637 </informaltable>
28638 <para>
28639 Setting this option true causes Exim to run in a very restrictive mode in which
28640 it passes messages synchronously to a smart host. Chapter <xref linkend="CHAPnonqueueing"/>
28641 contains a full description of this facility.
28642 </para>
28643 <para>
28644 <indexterm role="option">
28645 <primary><option>mysql_servers</option></primary>
28646 </indexterm>
28647 </para>
28648 <informaltable frame="all">
28649 <tgroup cols="4" colsep="0" rowsep="0">
28650 <colspec colwidth="8*" align="left"/>
28651 <colspec colwidth="6*" align="center"/>
28652 <colspec colwidth="6*" align="center"/>
28653 <colspec colwidth="6*" align="right"/>
28654 <tbody>
28655 <row>
28656 <entry><option>mysql_servers</option></entry>
28657 <entry>Use: <emphasis>main</emphasis></entry>
28658 <entry>Type: <emphasis>string list</emphasis></entry>
28659 <entry>Default: <emphasis>unset</emphasis></entry>
28660 </row>
28661 </tbody>
28662 </tgroup>
28663 </informaltable>
28664 <para>
28665 <indexterm role="concept">
28666 <primary>MySQL</primary>
28667 <secondary>server list</secondary>
28668 </indexterm>
28669 This option provides a list of MySQL servers and associated connection data, to
28670 be used in conjunction with <command>mysql</command> lookups (see section <xref linkend="SECID72"/>). The
28671 option is available only if Exim has been built with MySQL support.
28672 </para>
28673 <para>
28674 <indexterm role="option">
28675 <primary><option>never_users</option></primary>
28676 </indexterm>
28677 </para>
28678 <informaltable frame="all">
28679 <tgroup cols="4" colsep="0" rowsep="0">
28680 <colspec colwidth="8*" align="left"/>
28681 <colspec colwidth="6*" align="center"/>
28682 <colspec colwidth="6*" align="center"/>
28683 <colspec colwidth="6*" align="right"/>
28684 <tbody>
28685 <row>
28686 <entry><option>never_users</option></entry>
28687 <entry>Use: <emphasis>main</emphasis></entry>
28688 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
28689 <entry>Default: <emphasis>unset</emphasis></entry>
28690 </row>
28691 </tbody>
28692 </tgroup>
28693 </informaltable>
28694 <para>
28695 This option is expanded just once, at the start of Exim&#x2019;s processing. Local
28696 message deliveries are normally run in processes that are setuid to the
28697 recipient, and remote deliveries are normally run under Exim&#x2019;s own uid and gid.
28698 It is usually desirable to prevent any deliveries from running as root, as a
28699 safety precaution.
28700 </para>
28701 <para>
28702 When Exim is built, an option called FIXED_NEVER_USERS can be set to a
28703 list of users that must not be used for local deliveries. This list is fixed in
28704 the binary and cannot be overridden by the configuration file. By default, it
28705 contains just the single user name <quote>root</quote>. The <option>never_users</option> runtime option
28706 can be used to add more users to the fixed list.
28707 </para>
28708 <para>
28709 If a message is to be delivered as one of the users on the fixed list or the
28710 <option>never_users</option> list, an error occurs, and delivery is deferred. A common
28711 example is
28712 </para>
28713 <literallayout class="monospaced">
28714 never_users = root:daemon:bin
28715 </literallayout>
28716 <para>
28717 Including root is redundant if it is also on the fixed list, but it does no
28718 harm. This option overrides the <option>pipe_as_creator</option> option of the <command>pipe</command>
28719 transport driver.
28720 </para>
28721 <para>
28722 <indexterm role="option">
28723 <primary><option>openssl_options</option></primary>
28724 </indexterm>
28725 </para>
28726 <informaltable frame="all">
28727 <tgroup cols="4" colsep="0" rowsep="0">
28728 <colspec colwidth="8*" align="left"/>
28729 <colspec colwidth="6*" align="center"/>
28730 <colspec colwidth="6*" align="center"/>
28731 <colspec colwidth="6*" align="right"/>
28732 <tbody>
28733 <row>
28734 <entry><option>openssl_options</option></entry>
28735 <entry>Use: <emphasis>main</emphasis></entry>
28736 <entry>Type: <emphasis>string list</emphasis></entry>
28737 <entry>Default: <emphasis>+no_sslv2 +no_sslv3 +single_dh_use +no_ticket +no_renegotiation</emphasis></entry>
28738 </row>
28739 </tbody>
28740 </tgroup>
28741 </informaltable>
28742 <para>
28743 <indexterm role="concept">
28744 <primary>OpenSSL </primary>
28745 <secondary>compatibility</secondary>
28746 </indexterm>
28747 This option allows an administrator to adjust the SSL options applied
28748 by OpenSSL to connections.  It is given as a space-separated list of items,
28749 each one to be +added or -subtracted from the current value.
28750 </para>
28751 <para>
28752 This option is only available if Exim is built against OpenSSL.  The values
28753 available for this option vary according to the age of your OpenSSL install.
28754 The <quote>all</quote> value controls a subset of flags which are available, typically
28755 the bug workaround options.  The <emphasis>SSL_CTX_set_options</emphasis> man page will
28756 list the values known on your system and Exim should support all the
28757 <quote>bug workaround</quote> options and many of the <quote>modifying</quote> options.  The Exim
28758 names lose the leading <quote>SSL_OP_</quote> and are lower-cased.
28759 </para>
28760 <para>
28761 Note that adjusting the options can have severe impact upon the security of
28762 SSL as used by Exim.  It is possible to disable safety checks and shoot
28763 yourself in the foot in various unpleasant ways.  This option should not be
28764 adjusted lightly.  An unrecognised item will be detected at startup, by
28765 invoking Exim with the <option>-bV</option> flag.
28766 </para>
28767 <para>
28768 The option affects Exim operating both as a server and as a client.
28769 </para>
28770 <para>
28771 Historical note: prior to release 4.80, Exim defaulted this value to
28772 "+dont_insert_empty_fragments", which may still be needed for compatibility
28773 with some clients, but which lowers security by increasing exposure to
28774 some now infamous attacks.
28775 </para>
28776 <para>
28777 Examples:
28778 </para>
28779 <literallayout class="monospaced">
28780 # Make both old MS and old Eudora happy:
28781 openssl_options = -all +microsoft_big_sslv3_buffer \
28782                        +dont_insert_empty_fragments
28783
28784 # Disable older protocol versions:
28785 openssl_options = +no_sslv2 +no_sslv3
28786 </literallayout>
28787 <para>
28788 Possible options may include:
28789 </para>
28790 <itemizedlist>
28791 <listitem>
28792 <para>
28793 <literal>all</literal>
28794 </para>
28795 </listitem>
28796 <listitem>
28797 <para>
28798 <literal>allow_unsafe_legacy_renegotiation</literal>
28799 </para>
28800 </listitem>
28801 <listitem>
28802 <para>
28803 <literal>cipher_server_preference</literal>
28804 </para>
28805 </listitem>
28806 <listitem>
28807 <para>
28808 <literal>dont_insert_empty_fragments</literal>
28809 </para>
28810 </listitem>
28811 <listitem>
28812 <para>
28813 <literal>ephemeral_rsa</literal>
28814 </para>
28815 </listitem>
28816 <listitem>
28817 <para>
28818 <literal>legacy_server_connect</literal>
28819 </para>
28820 </listitem>
28821 <listitem>
28822 <para>
28823 <literal>microsoft_big_sslv3_buffer</literal>
28824 </para>
28825 </listitem>
28826 <listitem>
28827 <para>
28828 <literal>microsoft_sess_id_bug</literal>
28829 </para>
28830 </listitem>
28831 <listitem>
28832 <para>
28833 <literal>msie_sslv2_rsa_padding</literal>
28834 </para>
28835 </listitem>
28836 <listitem>
28837 <para>
28838 <literal>netscape_challenge_bug</literal>
28839 </para>
28840 </listitem>
28841 <listitem>
28842 <para>
28843 <literal>netscape_reuse_cipher_change_bug</literal>
28844 </para>
28845 </listitem>
28846 <listitem>
28847 <para>
28848 <literal>no_compression</literal>
28849 </para>
28850 </listitem>
28851 <listitem>
28852 <para>
28853 <literal>no_session_resumption_on_renegotiation</literal>
28854 </para>
28855 </listitem>
28856 <listitem>
28857 <para>
28858 <literal>no_sslv2</literal>
28859 </para>
28860 </listitem>
28861 <listitem>
28862 <para>
28863 <literal>no_sslv3</literal>
28864 </para>
28865 </listitem>
28866 <listitem>
28867 <para>
28868 <literal>no_ticket</literal>
28869 </para>
28870 </listitem>
28871 <listitem>
28872 <para>
28873 <literal>no_tlsv1</literal>
28874 </para>
28875 </listitem>
28876 <listitem>
28877 <para>
28878 <literal>no_tlsv1_1</literal>
28879 </para>
28880 </listitem>
28881 <listitem>
28882 <para>
28883 <literal>no_tlsv1_2</literal>
28884 </para>
28885 </listitem>
28886 <listitem>
28887 <para>
28888 <literal>safari_ecdhe_ecdsa_bug</literal>
28889 </para>
28890 </listitem>
28891 <listitem>
28892 <para>
28893 <literal>single_dh_use</literal>
28894 </para>
28895 </listitem>
28896 <listitem>
28897 <para>
28898 <literal>single_ecdh_use</literal>
28899 </para>
28900 </listitem>
28901 <listitem>
28902 <para>
28903 <literal>ssleay_080_client_dh_bug</literal>
28904 </para>
28905 </listitem>
28906 <listitem>
28907 <para>
28908 <literal>sslref2_reuse_cert_type_bug</literal>
28909 </para>
28910 </listitem>
28911 <listitem>
28912 <para>
28913 <literal>tls_block_padding_bug</literal>
28914 </para>
28915 </listitem>
28916 <listitem>
28917 <para>
28918 <literal>tls_d5_bug</literal>
28919 </para>
28920 </listitem>
28921 <listitem>
28922 <para>
28923 <literal>tls_rollback_bug</literal>
28924 </para>
28925 </listitem>
28926 </itemizedlist>
28927 <para>
28928 As an aside, the <literal>safari_ecdhe_ecdsa_bug</literal> item is a misnomer and affects
28929 all clients connecting using the MacOS SecureTransport TLS facility prior
28930 to MacOS 10.8.4, including email clients.  If you see old MacOS clients failing
28931 to negotiate TLS then this option value might help, provided that your OpenSSL
28932 release is new enough to contain this work-around.  This may be a situation
28933 where you have to upgrade OpenSSL to get buggy clients working.
28934 </para>
28935 <para>
28936 <indexterm role="option">
28937 <primary><option>oracle_servers</option></primary>
28938 </indexterm>
28939 </para>
28940 <informaltable frame="all">
28941 <tgroup cols="4" colsep="0" rowsep="0">
28942 <colspec colwidth="8*" align="left"/>
28943 <colspec colwidth="6*" align="center"/>
28944 <colspec colwidth="6*" align="center"/>
28945 <colspec colwidth="6*" align="right"/>
28946 <tbody>
28947 <row>
28948 <entry><option>oracle_servers</option></entry>
28949 <entry>Use: <emphasis>main</emphasis></entry>
28950 <entry>Type: <emphasis>string list</emphasis></entry>
28951 <entry>Default: <emphasis>unset</emphasis></entry>
28952 </row>
28953 </tbody>
28954 </tgroup>
28955 </informaltable>
28956 <para>
28957 <indexterm role="concept">
28958 <primary>Oracle</primary>
28959 <secondary>server list</secondary>
28960 </indexterm>
28961 This option provides a list of Oracle servers and associated connection data,
28962 to be used in conjunction with <command>oracle</command> lookups (see section <xref linkend="SECID72"/>).
28963 The option is available only if Exim has been built with Oracle support.
28964 </para>
28965 <para>
28966 <indexterm role="option">
28967 <primary><option>percent_hack_domains</option></primary>
28968 </indexterm>
28969 </para>
28970 <informaltable frame="all">
28971 <tgroup cols="4" colsep="0" rowsep="0">
28972 <colspec colwidth="8*" align="left"/>
28973 <colspec colwidth="6*" align="center"/>
28974 <colspec colwidth="6*" align="center"/>
28975 <colspec colwidth="6*" align="right"/>
28976 <tbody>
28977 <row>
28978 <entry><option>percent_hack_domains</option></entry>
28979 <entry>Use: <emphasis>main</emphasis></entry>
28980 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
28981 <entry>Default: <emphasis>unset</emphasis></entry>
28982 </row>
28983 </tbody>
28984 </tgroup>
28985 </informaltable>
28986 <para>
28987 <indexterm role="concept">
28988 <primary><quote>percent hack</quote></primary>
28989 </indexterm>
28990 <indexterm role="concept">
28991 <primary>source routing</primary>
28992 <secondary>in email address</secondary>
28993 </indexterm>
28994 <indexterm role="concept">
28995 <primary>address</primary>
28996 <secondary>source-routed</secondary>
28997 </indexterm>
28998 The <quote>percent hack</quote> is the convention whereby a local part containing a
28999 percent sign is re-interpreted as a new email address, with the percent
29000 replaced by @. This is sometimes called <quote>source routing</quote>, though that term is
29001 also applied to RFC 2822 addresses that begin with an @ character. If this
29002 option is set, Exim implements the percent facility for those domains listed,
29003 but no others. This happens before an incoming SMTP address is tested against
29004 an ACL.
29005 </para>
29006 <para>
29007 <emphasis role="bold">Warning</emphasis>: The <quote>percent hack</quote> has often been abused by people who are
29008 trying to get round relaying restrictions. For this reason, it is best avoided
29009 if at all possible. Unfortunately, a number of less security-conscious MTAs
29010 implement it unconditionally. If you are running Exim on a gateway host, and
29011 routing mail through to internal MTAs without processing the local parts, it is
29012 a good idea to reject recipient addresses with percent characters in their
29013 local parts. Exim&#x2019;s default configuration does this.
29014 </para>
29015 <para>
29016 <indexterm role="option">
29017 <primary><option>perl_at_start</option></primary>
29018 </indexterm>
29019 </para>
29020 <informaltable frame="all">
29021 <tgroup cols="4" colsep="0" rowsep="0">
29022 <colspec colwidth="8*" align="left"/>
29023 <colspec colwidth="6*" align="center"/>
29024 <colspec colwidth="6*" align="center"/>
29025 <colspec colwidth="6*" align="right"/>
29026 <tbody>
29027 <row>
29028 <entry><option>perl_at_start</option></entry>
29029 <entry>Use: <emphasis>main</emphasis></entry>
29030 <entry>Type: <emphasis>boolean</emphasis></entry>
29031 <entry>Default: <emphasis>false</emphasis></entry>
29032 </row>
29033 </tbody>
29034 </tgroup>
29035 </informaltable>
29036 <para>
29037 <indexterm role="concept">
29038 <primary>Perl</primary>
29039 </indexterm>
29040 This option is available only when Exim is built with an embedded Perl
29041 interpreter. See chapter <xref linkend="CHAPperl"/> for details of its use.
29042 </para>
29043 <para>
29044 <indexterm role="option">
29045 <primary><option>perl_startup</option></primary>
29046 </indexterm>
29047 </para>
29048 <informaltable frame="all">
29049 <tgroup cols="4" colsep="0" rowsep="0">
29050 <colspec colwidth="8*" align="left"/>
29051 <colspec colwidth="6*" align="center"/>
29052 <colspec colwidth="6*" align="center"/>
29053 <colspec colwidth="6*" align="right"/>
29054 <tbody>
29055 <row>
29056 <entry><option>perl_startup</option></entry>
29057 <entry>Use: <emphasis>main</emphasis></entry>
29058 <entry>Type: <emphasis>string</emphasis></entry>
29059 <entry>Default: <emphasis>unset</emphasis></entry>
29060 </row>
29061 </tbody>
29062 </tgroup>
29063 </informaltable>
29064 <para>
29065 <indexterm role="concept">
29066 <primary>Perl</primary>
29067 </indexterm>
29068 This option is available only when Exim is built with an embedded Perl
29069 interpreter. See chapter <xref linkend="CHAPperl"/> for details of its use.
29070 </para>
29071 <para>
29072 <indexterm role="option">
29073 <primary><option>perl_taintmode</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>perl_taintmode</option></entry>
29085 <entry>Use: <emphasis>main</emphasis></entry>
29086 <entry>Type: <emphasis>boolean</emphasis></entry>
29087 <entry>Default: <emphasis>false</emphasis></entry>
29088 </row>
29089 </tbody>
29090 </tgroup>
29091 </informaltable>
29092 <para>
29093 <indexterm role="concept">
29094 <primary>Perl</primary>
29095 </indexterm>
29096 This option enables the taint mode of the embedded Perl interpreter.
29097 </para>
29098 <para>
29099 <indexterm role="option">
29100 <primary><option>pgsql_servers</option></primary>
29101 </indexterm>
29102 </para>
29103 <informaltable frame="all">
29104 <tgroup cols="4" colsep="0" rowsep="0">
29105 <colspec colwidth="8*" align="left"/>
29106 <colspec colwidth="6*" align="center"/>
29107 <colspec colwidth="6*" align="center"/>
29108 <colspec colwidth="6*" align="right"/>
29109 <tbody>
29110 <row>
29111 <entry><option>pgsql_servers</option></entry>
29112 <entry>Use: <emphasis>main</emphasis></entry>
29113 <entry>Type: <emphasis>string list</emphasis></entry>
29114 <entry>Default: <emphasis>unset</emphasis></entry>
29115 </row>
29116 </tbody>
29117 </tgroup>
29118 </informaltable>
29119 <para>
29120 <indexterm role="concept">
29121 <primary>PostgreSQL lookup type</primary>
29122 <secondary>server list</secondary>
29123 </indexterm>
29124 This option provides a list of PostgreSQL servers and associated connection
29125 data, to be used in conjunction with <command>pgsql</command> lookups (see section
29126 <xref linkend="SECID72"/>). The option is available only if Exim has been built with
29127 PostgreSQL support.
29128 </para>
29129 <para>
29130 <indexterm role="option">
29131 <primary><option>pid_file_path</option></primary>
29132 </indexterm>
29133 </para>
29134 <informaltable frame="all">
29135 <tgroup cols="4" colsep="0" rowsep="0">
29136 <colspec colwidth="8*" align="left"/>
29137 <colspec colwidth="6*" align="center"/>
29138 <colspec colwidth="6*" align="center"/>
29139 <colspec colwidth="6*" align="right"/>
29140 <tbody>
29141 <row>
29142 <entry><option>pid_file_path</option></entry>
29143 <entry>Use: <emphasis>main</emphasis></entry>
29144 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29145 <entry>Default: <emphasis>set at compile time</emphasis></entry>
29146 </row>
29147 </tbody>
29148 </tgroup>
29149 </informaltable>
29150 <para>
29151 <indexterm role="concept">
29152 <primary>daemon</primary>
29153 <secondary>pid file path</secondary>
29154 </indexterm>
29155 <indexterm role="concept">
29156 <primary>pid file, path for</primary>
29157 </indexterm>
29158 This option sets the name of the file to which the Exim daemon writes its
29159 process id. The string is expanded, so it can contain, for example, references
29160 to the host name:
29161 </para>
29162 <literallayout class="monospaced">
29163 pid_file_path = /var/log/$primary_hostname/exim.pid
29164 </literallayout>
29165 <para>
29166 If no path is set, the pid is written to the file <filename>exim-daemon.pid</filename> in Exim&#x2019;s
29167 spool directory.
29168 The value set by the option can be overridden by the <option>-oP</option> command line
29169 option. A pid file is not written if a <quote>non-standard</quote> daemon is run by means
29170 of the <option>-oX</option> option, unless a path is explicitly supplied by <option>-oP</option>.
29171 </para>
29172 <para>
29173 <indexterm role="option">
29174 <primary><option>pipelining_advertise_hosts</option></primary>
29175 </indexterm>
29176 </para>
29177 <informaltable frame="all">
29178 <tgroup cols="4" colsep="0" rowsep="0">
29179 <colspec colwidth="8*" align="left"/>
29180 <colspec colwidth="6*" align="center"/>
29181 <colspec colwidth="6*" align="center"/>
29182 <colspec colwidth="6*" align="right"/>
29183 <tbody>
29184 <row>
29185 <entry><option>pipelining_advertise_hosts</option></entry>
29186 <entry>Use: <emphasis>main</emphasis></entry>
29187 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
29188 <entry>Default: <emphasis>*</emphasis></entry>
29189 </row>
29190 </tbody>
29191 </tgroup>
29192 </informaltable>
29193 <para>
29194 <indexterm role="concept">
29195 <primary>PIPELINING</primary>
29196 <secondary>suppressing advertising</secondary>
29197 </indexterm>
29198 This option can be used to suppress the advertisement of the SMTP
29199 PIPELINING extension to specific hosts. See also the <emphasis role="bold">no_pipelining</emphasis>
29200 control in section <xref linkend="SECTcontrols"/>. When PIPELINING is not advertised and
29201 <option>smtp_enforce_sync</option> is true, an Exim server enforces strict synchronization
29202 for each SMTP command and response. When PIPELINING is advertised, Exim assumes
29203 that clients will use it; <quote>out of order</quote> commands that are <quote>expected</quote> do
29204 not count as protocol errors (see <option>smtp_max_synprot_errors</option>).
29205 </para>
29206 <para revisionflag="changed">
29207 <indexterm role="option">
29208 <primary><option>pipelining_connect_advertise_hosts</option></primary>
29209 </indexterm>
29210 </para>
29211 <informaltable frame="all" revisionflag="changed">
29212 <tgroup cols="4" colsep="0" rowsep="0">
29213 <colspec colwidth="8*" align="left"/>
29214 <colspec colwidth="6*" align="center"/>
29215 <colspec colwidth="6*" align="center"/>
29216 <colspec colwidth="6*" align="right"/>
29217 <tbody>
29218 <row>
29219 <entry><option>pipelining_connect_advertise_hosts</option></entry>
29220 <entry>Use: <emphasis>main</emphasis></entry>
29221 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
29222 <entry>Default: <emphasis>*</emphasis></entry>
29223 </row>
29224 </tbody>
29225 </tgroup>
29226 </informaltable>
29227 <para revisionflag="changed">
29228 <indexterm role="concept">
29229 <primary>pipelining</primary>
29230 <secondary>early connection</secondary>
29231 </indexterm>
29232 <indexterm role="concept">
29233 <primary>pipelining</primary>
29234 <secondary>PIPE_CONNECT</secondary>
29235 </indexterm>
29236 If Exim is built with the SUPPORT_PIPE_CONNECT build option
29237 this option controls which hosts the facility is advertised to
29238 and from which pipeline early-connection (before MAIL) SMTP
29239 commands are acceptable.
29240 When used, the pipelining saves on roundtrip times.
29241 </para>
29242 <para revisionflag="changed">
29243 See also the <option>hosts_pipe_connect</option> smtp transport option.
29244 </para>
29245 <para revisionflag="changed">
29246 Currently the option name <quote>X_PIPE_CONNECT</quote> is used.
29247 </para>
29248 <para>
29249 <indexterm role="option">
29250 <primary><option>prdr_enable</option></primary>
29251 </indexterm>
29252 </para>
29253 <informaltable frame="all">
29254 <tgroup cols="4" colsep="0" rowsep="0">
29255 <colspec colwidth="8*" align="left"/>
29256 <colspec colwidth="6*" align="center"/>
29257 <colspec colwidth="6*" align="center"/>
29258 <colspec colwidth="6*" align="right"/>
29259 <tbody>
29260 <row>
29261 <entry><option>prdr_enable</option></entry>
29262 <entry>Use: <emphasis>main</emphasis></entry>
29263 <entry>Type: <emphasis>boolean</emphasis></entry>
29264 <entry>Default: <emphasis>false</emphasis></entry>
29265 </row>
29266 </tbody>
29267 </tgroup>
29268 </informaltable>
29269 <para>
29270 <indexterm role="concept">
29271 <primary>PRDR</primary>
29272 <secondary>enabling on server</secondary>
29273 </indexterm>
29274 This option can be used to enable the Per-Recipient Data Response extension
29275 to SMTP, defined by Eric Hall.
29276 If the option is set, PRDR is advertised by Exim when operating as a server.
29277 If the client requests PRDR, and more than one recipient, for a message
29278 an additional ACL is called for each recipient after the message content
29279 is received.  See section <xref linkend="SECTPRDRACL"/>.
29280 </para>
29281 <para>
29282 <indexterm role="option">
29283 <primary><option>preserve_message_logs</option></primary>
29284 </indexterm>
29285 </para>
29286 <informaltable frame="all">
29287 <tgroup cols="4" colsep="0" rowsep="0">
29288 <colspec colwidth="8*" align="left"/>
29289 <colspec colwidth="6*" align="center"/>
29290 <colspec colwidth="6*" align="center"/>
29291 <colspec colwidth="6*" align="right"/>
29292 <tbody>
29293 <row>
29294 <entry><option>preserve_message_logs</option></entry>
29295 <entry>Use: <emphasis>main</emphasis></entry>
29296 <entry>Type: <emphasis>boolean</emphasis></entry>
29297 <entry>Default: <emphasis>false</emphasis></entry>
29298 </row>
29299 </tbody>
29300 </tgroup>
29301 </informaltable>
29302 <para>
29303 <indexterm role="concept">
29304 <primary>message logs</primary>
29305 <secondary>preserving</secondary>
29306 </indexterm>
29307 If this option is set, message log files are not deleted when messages are
29308 completed. Instead, they are moved to a sub-directory of the spool directory
29309 called <filename>msglog.OLD</filename>, where they remain available for statistical or debugging
29310 purposes. This is a dangerous option to set on systems with any appreciable
29311 volume of mail. Use with care!
29312 </para>
29313 <para>
29314 <indexterm role="option">
29315 <primary><option>primary_hostname</option></primary>
29316 </indexterm>
29317 </para>
29318 <informaltable frame="all">
29319 <tgroup cols="4" colsep="0" rowsep="0">
29320 <colspec colwidth="8*" align="left"/>
29321 <colspec colwidth="6*" align="center"/>
29322 <colspec colwidth="6*" align="center"/>
29323 <colspec colwidth="6*" align="right"/>
29324 <tbody>
29325 <row>
29326 <entry><option>primary_hostname</option></entry>
29327 <entry>Use: <emphasis>main</emphasis></entry>
29328 <entry>Type: <emphasis>string</emphasis></entry>
29329 <entry>Default: <emphasis>see below</emphasis></entry>
29330 </row>
29331 </tbody>
29332 </tgroup>
29333 </informaltable>
29334 <para>
29335 <indexterm role="concept">
29336 <primary>name</primary>
29337 <secondary>of local host</secondary>
29338 </indexterm>
29339 <indexterm role="concept">
29340 <primary>host</primary>
29341 <secondary>name of local</secondary>
29342 </indexterm>
29343 <indexterm role="concept">
29344 <primary>local host</primary>
29345 <secondary>name of</secondary>
29346 </indexterm>
29347 <indexterm role="variable">
29348 <primary><varname>$primary_hostname</varname></primary>
29349 </indexterm>
29350 This specifies the name of the current host. It is used in the default EHLO or
29351 HELO command for outgoing SMTP messages (changeable via the <option>helo_data</option>
29352 option in the <command>smtp</command> transport), and as the default for <option>qualify_domain</option>.
29353 The value is also used by default in some SMTP response messages from an Exim
29354 server. This can be changed dynamically by setting <option>smtp_active_hostname</option>.
29355 </para>
29356 <para>
29357 If <option>primary_hostname</option> is not set, Exim calls <function>uname()</function> to find the host
29358 name. If this fails, Exim panics and dies. If the name returned by <function>uname()</function>
29359 contains only one component, Exim passes it to <function>gethostbyname()</function> (or
29360 <function>getipnodebyname()</function> when available) in order to obtain the fully qualified
29361 version. The variable <varname>$primary_hostname</varname> contains the host name, whether set
29362 explicitly by this option, or defaulted.
29363 </para>
29364 <para>
29365 <indexterm role="option">
29366 <primary><option>print_topbitchars</option></primary>
29367 </indexterm>
29368 </para>
29369 <informaltable frame="all">
29370 <tgroup cols="4" colsep="0" rowsep="0">
29371 <colspec colwidth="8*" align="left"/>
29372 <colspec colwidth="6*" align="center"/>
29373 <colspec colwidth="6*" align="center"/>
29374 <colspec colwidth="6*" align="right"/>
29375 <tbody>
29376 <row>
29377 <entry><option>print_topbitchars</option></entry>
29378 <entry>Use: <emphasis>main</emphasis></entry>
29379 <entry>Type: <emphasis>boolean</emphasis></entry>
29380 <entry>Default: <emphasis>false</emphasis></entry>
29381 </row>
29382 </tbody>
29383 </tgroup>
29384 </informaltable>
29385 <para>
29386 <indexterm role="concept">
29387 <primary>printing characters</primary>
29388 </indexterm>
29389 <indexterm role="concept">
29390 <primary>8-bit characters</primary>
29391 </indexterm>
29392 By default, Exim considers only those characters whose codes lie in the range
29393 32&ndash;126 to be printing characters. In a number of circumstances (for example,
29394 when writing log entries) non-printing characters are converted into escape
29395 sequences, primarily to avoid messing up the layout. If <option>print_topbitchars</option>
29396 is set, code values of 128 and above are also considered to be printing
29397 characters.
29398 </para>
29399 <para>
29400 This option also affects the header syntax checks performed by the
29401 <command>autoreply</command> transport, and whether Exim uses RFC 2047 encoding of
29402 the user&#x2019;s full name when constructing From: and Sender: addresses (as
29403 described in section <xref linkend="SECTconstr"/>). Setting this option can cause
29404 Exim to generate eight bit message headers that do not conform to the
29405 standards.
29406 </para>
29407 <para>
29408 <indexterm role="option">
29409 <primary><option>process_log_path</option></primary>
29410 </indexterm>
29411 </para>
29412 <informaltable frame="all">
29413 <tgroup cols="4" colsep="0" rowsep="0">
29414 <colspec colwidth="8*" align="left"/>
29415 <colspec colwidth="6*" align="center"/>
29416 <colspec colwidth="6*" align="center"/>
29417 <colspec colwidth="6*" align="right"/>
29418 <tbody>
29419 <row>
29420 <entry><option>process_log_path</option></entry>
29421 <entry>Use: <emphasis>main</emphasis></entry>
29422 <entry>Type: <emphasis>string</emphasis></entry>
29423 <entry>Default: <emphasis>unset</emphasis></entry>
29424 </row>
29425 </tbody>
29426 </tgroup>
29427 </informaltable>
29428 <para>
29429 <indexterm role="concept">
29430 <primary>process log path</primary>
29431 </indexterm>
29432 <indexterm role="concept">
29433 <primary>log</primary>
29434 <secondary>process log</secondary>
29435 </indexterm>
29436 <indexterm role="concept">
29437 <primary><emphasis>exiwhat</emphasis></primary>
29438 </indexterm>
29439 This option sets the name of the file to which an Exim process writes its
29440 <quote>process log</quote> when sent a USR1 signal. This is used by the <emphasis>exiwhat</emphasis>
29441 utility script. If this option is unset, the file called <filename>exim-process.info</filename>
29442 in Exim&#x2019;s spool directory is used. The ability to specify the name explicitly
29443 can be useful in environments where two different Exims are running, using
29444 different spool directories.
29445 </para>
29446 <para>
29447 <indexterm role="option">
29448 <primary><option>prod_requires_admin</option></primary>
29449 </indexterm>
29450 </para>
29451 <informaltable frame="all">
29452 <tgroup cols="4" colsep="0" rowsep="0">
29453 <colspec colwidth="8*" align="left"/>
29454 <colspec colwidth="6*" align="center"/>
29455 <colspec colwidth="6*" align="center"/>
29456 <colspec colwidth="6*" align="right"/>
29457 <tbody>
29458 <row>
29459 <entry><option>prod_requires_admin</option></entry>
29460 <entry>Use: <emphasis>main</emphasis></entry>
29461 <entry>Type: <emphasis>boolean</emphasis></entry>
29462 <entry>Default: <emphasis>true</emphasis></entry>
29463 </row>
29464 </tbody>
29465 </tgroup>
29466 </informaltable>
29467 <para>
29468 <indexterm role="concept">
29469 <primary>restricting access to features</primary>
29470 </indexterm>
29471 <indexterm role="option">
29472 <primary><option>-M</option></primary>
29473 </indexterm>
29474 <indexterm role="option">
29475 <primary><option>-R</option></primary>
29476 </indexterm>
29477 <indexterm role="option">
29478 <primary><option>-q</option></primary>
29479 </indexterm>
29480 The <option>-M</option>, <option>-R</option>, and <option>-q</option> command-line options require the caller to be an
29481 admin user unless <option>prod_requires_admin</option> is set false. See also
29482 <option>queue_list_requires_admin</option> and <option>commandline_checks_require_admin</option>.
29483 </para>
29484 <para>
29485 <indexterm role="option">
29486 <primary><option>qualify_domain</option></primary>
29487 </indexterm>
29488 </para>
29489 <informaltable frame="all">
29490 <tgroup cols="4" colsep="0" rowsep="0">
29491 <colspec colwidth="8*" align="left"/>
29492 <colspec colwidth="6*" align="center"/>
29493 <colspec colwidth="6*" align="center"/>
29494 <colspec colwidth="6*" align="right"/>
29495 <tbody>
29496 <row>
29497 <entry><option>qualify_domain</option></entry>
29498 <entry>Use: <emphasis>main</emphasis></entry>
29499 <entry>Type: <emphasis>string</emphasis></entry>
29500 <entry>Default: <emphasis>see below</emphasis></entry>
29501 </row>
29502 </tbody>
29503 </tgroup>
29504 </informaltable>
29505 <para>
29506 <indexterm role="concept">
29507 <primary>domain</primary>
29508 <secondary>for qualifying addresses</secondary>
29509 </indexterm>
29510 <indexterm role="concept">
29511 <primary>address</primary>
29512 <secondary>qualification</secondary>
29513 </indexterm>
29514 This option specifies the domain name that is added to any envelope sender
29515 addresses that do not have a domain qualification. It also applies to
29516 recipient addresses if <option>qualify_recipient</option> is not set. Unqualified addresses
29517 are accepted by default only for locally-generated messages. Qualification is
29518 also applied to addresses in header lines such as <emphasis>From:</emphasis> and <emphasis>To:</emphasis> for
29519 locally-generated messages, unless the <option>-bnq</option> command line option is used.
29520 </para>
29521 <para>
29522 Messages from external sources must always contain fully qualified addresses,
29523 unless the sending host matches <option>sender_unqualified_hosts</option> or
29524 <option>recipient_unqualified_hosts</option> (as appropriate), in which case incoming
29525 addresses are qualified with <option>qualify_domain</option> or <option>qualify_recipient</option> as
29526 necessary. Internally, Exim always works with fully qualified envelope
29527 addresses. If <option>qualify_domain</option> is not set, it defaults to the
29528 <option>primary_hostname</option> value.
29529 </para>
29530 <para>
29531 <indexterm role="option">
29532 <primary><option>qualify_recipient</option></primary>
29533 </indexterm>
29534 </para>
29535 <informaltable frame="all">
29536 <tgroup cols="4" colsep="0" rowsep="0">
29537 <colspec colwidth="8*" align="left"/>
29538 <colspec colwidth="6*" align="center"/>
29539 <colspec colwidth="6*" align="center"/>
29540 <colspec colwidth="6*" align="right"/>
29541 <tbody>
29542 <row>
29543 <entry><option>qualify_recipient</option></entry>
29544 <entry>Use: <emphasis>main</emphasis></entry>
29545 <entry>Type: <emphasis>string</emphasis></entry>
29546 <entry>Default: <emphasis>see below</emphasis></entry>
29547 </row>
29548 </tbody>
29549 </tgroup>
29550 </informaltable>
29551 <para>
29552 This option allows you to specify a different domain for qualifying recipient
29553 addresses to the one that is used for senders. See <option>qualify_domain</option> above.
29554 </para>
29555 <para>
29556 <indexterm role="option">
29557 <primary><option>queue_domains</option></primary>
29558 </indexterm>
29559 </para>
29560 <informaltable frame="all">
29561 <tgroup cols="4" colsep="0" rowsep="0">
29562 <colspec colwidth="8*" align="left"/>
29563 <colspec colwidth="6*" align="center"/>
29564 <colspec colwidth="6*" align="center"/>
29565 <colspec colwidth="6*" align="right"/>
29566 <tbody>
29567 <row>
29568 <entry><option>queue_domains</option></entry>
29569 <entry>Use: <emphasis>main</emphasis></entry>
29570 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
29571 <entry>Default: <emphasis>unset</emphasis></entry>
29572 </row>
29573 </tbody>
29574 </tgroup>
29575 </informaltable>
29576 <para>
29577 <indexterm role="concept">
29578 <primary>domain</primary>
29579 <secondary>specifying non-immediate delivery</secondary>
29580 </indexterm>
29581 <indexterm role="concept">
29582 <primary>queueing incoming messages</primary>
29583 </indexterm>
29584 <indexterm role="concept">
29585 <primary>message</primary>
29586 <secondary>queueing certain domains</secondary>
29587 </indexterm>
29588 This option lists domains for which immediate delivery is not required.
29589 A delivery process is started whenever a message is received, but only those
29590 domains that do not match are processed. All other deliveries wait until the
29591 next queue run. See also <option>hold_domains</option> and <option>queue_smtp_domains</option>.
29592 </para>
29593 <para>
29594 <indexterm role="option">
29595 <primary><option>queue_list_requires_admin</option></primary>
29596 </indexterm>
29597 </para>
29598 <informaltable frame="all">
29599 <tgroup cols="4" colsep="0" rowsep="0">
29600 <colspec colwidth="8*" align="left"/>
29601 <colspec colwidth="6*" align="center"/>
29602 <colspec colwidth="6*" align="center"/>
29603 <colspec colwidth="6*" align="right"/>
29604 <tbody>
29605 <row>
29606 <entry><option>queue_list_requires_admin</option></entry>
29607 <entry>Use: <emphasis>main</emphasis></entry>
29608 <entry>Type: <emphasis>boolean</emphasis></entry>
29609 <entry>Default: <emphasis>true</emphasis></entry>
29610 </row>
29611 </tbody>
29612 </tgroup>
29613 </informaltable>
29614 <para>
29615 <indexterm role="concept">
29616 <primary>restricting access to features</primary>
29617 </indexterm>
29618 <indexterm role="option">
29619 <primary><option>-bp</option></primary>
29620 </indexterm>
29621 The <option>-bp</option> command-line option, which lists the messages that are on the
29622 queue, requires the caller to be an admin user unless
29623 <option>queue_list_requires_admin</option> is set false.
29624 See also <option>prod_requires_admin</option> and <option>commandline_checks_require_admin</option>.
29625 </para>
29626 <para>
29627 <indexterm role="option">
29628 <primary><option>queue_only</option></primary>
29629 </indexterm>
29630 </para>
29631 <informaltable frame="all">
29632 <tgroup cols="4" colsep="0" rowsep="0">
29633 <colspec colwidth="8*" align="left"/>
29634 <colspec colwidth="6*" align="center"/>
29635 <colspec colwidth="6*" align="center"/>
29636 <colspec colwidth="6*" align="right"/>
29637 <tbody>
29638 <row>
29639 <entry><option>queue_only</option></entry>
29640 <entry>Use: <emphasis>main</emphasis></entry>
29641 <entry>Type: <emphasis>boolean</emphasis></entry>
29642 <entry>Default: <emphasis>false</emphasis></entry>
29643 </row>
29644 </tbody>
29645 </tgroup>
29646 </informaltable>
29647 <para>
29648 <indexterm role="concept">
29649 <primary>queueing incoming messages</primary>
29650 </indexterm>
29651 <indexterm role="concept">
29652 <primary>message</primary>
29653 <secondary>queueing unconditionally</secondary>
29654 </indexterm>
29655 If <option>queue_only</option> is set, a delivery process is not automatically started
29656 whenever a message is received. Instead, the message waits in the queue for the
29657 next queue run. Even if <option>queue_only</option> is false, incoming messages may not get
29658 delivered immediately when certain conditions (such as heavy load) occur.
29659 </para>
29660 <para>
29661 The <option>-odq</option> command line has the same effect as <option>queue_only</option>. The <option>-odb</option>
29662 and <option>-odi</option> command line options override <option>queue_only</option> unless
29663 <option>queue_only_override</option> is set false. See also <option>queue_only_file</option>,
29664 <option>queue_only_load</option>, and <option>smtp_accept_queue</option>.
29665 </para>
29666 <para>
29667 <indexterm role="option">
29668 <primary><option>queue_only_file</option></primary>
29669 </indexterm>
29670 </para>
29671 <informaltable frame="all">
29672 <tgroup cols="4" colsep="0" rowsep="0">
29673 <colspec colwidth="8*" align="left"/>
29674 <colspec colwidth="6*" align="center"/>
29675 <colspec colwidth="6*" align="center"/>
29676 <colspec colwidth="6*" align="right"/>
29677 <tbody>
29678 <row>
29679 <entry><option>queue_only_file</option></entry>
29680 <entry>Use: <emphasis>main</emphasis></entry>
29681 <entry>Type: <emphasis>string</emphasis></entry>
29682 <entry>Default: <emphasis>unset</emphasis></entry>
29683 </row>
29684 </tbody>
29685 </tgroup>
29686 </informaltable>
29687 <para>
29688 <indexterm role="concept">
29689 <primary>queueing incoming messages</primary>
29690 </indexterm>
29691 <indexterm role="concept">
29692 <primary>message</primary>
29693 <secondary>queueing by file existence</secondary>
29694 </indexterm>
29695 This option can be set to a colon-separated list of absolute path names, each
29696 one optionally preceded by <quote>smtp</quote>. When Exim is receiving a message,
29697 it tests for the existence of each listed path using a call to <function>stat()</function>. For
29698 each path that exists, the corresponding queueing option is set.
29699 For paths with no prefix, <option>queue_only</option> is set; for paths prefixed by
29700 <quote>smtp</quote>, <option>queue_smtp_domains</option> is set to match all domains. So, for example,
29701 </para>
29702 <literallayout class="monospaced">
29703 queue_only_file = smtp/some/file
29704 </literallayout>
29705 <para>
29706 causes Exim to behave as if <option>queue_smtp_domains</option> were set to <quote>*</quote> whenever
29707 <filename>/some/file</filename> exists.
29708 </para>
29709 <para>
29710 <indexterm role="option">
29711 <primary><option>queue_only_load</option></primary>
29712 </indexterm>
29713 </para>
29714 <informaltable frame="all">
29715 <tgroup cols="4" colsep="0" rowsep="0">
29716 <colspec colwidth="8*" align="left"/>
29717 <colspec colwidth="6*" align="center"/>
29718 <colspec colwidth="6*" align="center"/>
29719 <colspec colwidth="6*" align="right"/>
29720 <tbody>
29721 <row>
29722 <entry><option>queue_only_load</option></entry>
29723 <entry>Use: <emphasis>main</emphasis></entry>
29724 <entry>Type: <emphasis>fixed-point</emphasis></entry>
29725 <entry>Default: <emphasis>unset</emphasis></entry>
29726 </row>
29727 </tbody>
29728 </tgroup>
29729 </informaltable>
29730 <para>
29731 <indexterm role="concept">
29732 <primary>load average</primary>
29733 </indexterm>
29734 <indexterm role="concept">
29735 <primary>queueing incoming messages</primary>
29736 </indexterm>
29737 <indexterm role="concept">
29738 <primary>message</primary>
29739 <secondary>queueing by load</secondary>
29740 </indexterm>
29741 If the system load average is higher than this value, incoming messages from
29742 all sources are queued, and no automatic deliveries are started. If this
29743 happens during local or remote SMTP input, all subsequent messages received on
29744 the same SMTP connection are queued by default, whatever happens to the load in
29745 the meantime, but this can be changed by setting <option>queue_only_load_latch</option>
29746 false.
29747 </para>
29748 <para>
29749 Deliveries will subsequently be performed by queue runner processes. This
29750 option has no effect on ancient operating systems on which Exim cannot
29751 determine the load average. See also <option>deliver_queue_load_max</option> and
29752 <option>smtp_load_reserve</option>.
29753 </para>
29754 <para>
29755 <indexterm role="option">
29756 <primary><option>queue_only_load_latch</option></primary>
29757 </indexterm>
29758 </para>
29759 <informaltable frame="all">
29760 <tgroup cols="4" colsep="0" rowsep="0">
29761 <colspec colwidth="8*" align="left"/>
29762 <colspec colwidth="6*" align="center"/>
29763 <colspec colwidth="6*" align="center"/>
29764 <colspec colwidth="6*" align="right"/>
29765 <tbody>
29766 <row>
29767 <entry><option>queue_only_load_latch</option></entry>
29768 <entry>Use: <emphasis>main</emphasis></entry>
29769 <entry>Type: <emphasis>boolean</emphasis></entry>
29770 <entry>Default: <emphasis>true</emphasis></entry>
29771 </row>
29772 </tbody>
29773 </tgroup>
29774 </informaltable>
29775 <para>
29776 <indexterm role="concept">
29777 <primary>load average</primary>
29778 <secondary>re-evaluating per message</secondary>
29779 </indexterm>
29780 When this option is true (the default), once one message has been queued
29781 because the load average is higher than the value set by <option>queue_only_load</option>,
29782 all subsequent messages received on the same SMTP connection are also queued.
29783 This is a deliberate choice; even though the load average may fall below the
29784 threshold, it doesn&#x2019;t seem right to deliver later messages on the same
29785 connection when not delivering earlier ones. However, there are special
29786 circumstances such as very long-lived connections from scanning appliances
29787 where this is not the best strategy. In such cases, <option>queue_only_load_latch</option>
29788 should be set false. This causes the value of the load average to be
29789 re-evaluated for each message.
29790 </para>
29791 <para>
29792 <indexterm role="option">
29793 <primary><option>queue_only_override</option></primary>
29794 </indexterm>
29795 </para>
29796 <informaltable frame="all">
29797 <tgroup cols="4" colsep="0" rowsep="0">
29798 <colspec colwidth="8*" align="left"/>
29799 <colspec colwidth="6*" align="center"/>
29800 <colspec colwidth="6*" align="center"/>
29801 <colspec colwidth="6*" align="right"/>
29802 <tbody>
29803 <row>
29804 <entry><option>queue_only_override</option></entry>
29805 <entry>Use: <emphasis>main</emphasis></entry>
29806 <entry>Type: <emphasis>boolean</emphasis></entry>
29807 <entry>Default: <emphasis>true</emphasis></entry>
29808 </row>
29809 </tbody>
29810 </tgroup>
29811 </informaltable>
29812 <para>
29813 <indexterm role="concept">
29814 <primary>queueing incoming messages</primary>
29815 </indexterm>
29816 When this option is true, the <option>-od</option><emphasis>x</emphasis> command line options override the
29817 setting of <option>queue_only</option> or <option>queue_only_file</option> in the configuration file. If
29818 <option>queue_only_override</option> is set false, the <option>-od</option><emphasis>x</emphasis> options cannot be used
29819 to override; they are accepted, but ignored.
29820 </para>
29821 <para>
29822 <indexterm role="option">
29823 <primary><option>queue_run_in_order</option></primary>
29824 </indexterm>
29825 </para>
29826 <informaltable frame="all">
29827 <tgroup cols="4" colsep="0" rowsep="0">
29828 <colspec colwidth="8*" align="left"/>
29829 <colspec colwidth="6*" align="center"/>
29830 <colspec colwidth="6*" align="center"/>
29831 <colspec colwidth="6*" align="right"/>
29832 <tbody>
29833 <row>
29834 <entry><option>queue_run_in_order</option></entry>
29835 <entry>Use: <emphasis>main</emphasis></entry>
29836 <entry>Type: <emphasis>boolean</emphasis></entry>
29837 <entry>Default: <emphasis>false</emphasis></entry>
29838 </row>
29839 </tbody>
29840 </tgroup>
29841 </informaltable>
29842 <para>
29843 <indexterm role="concept">
29844 <primary>queue runner</primary>
29845 <secondary>processing messages in order</secondary>
29846 </indexterm>
29847 If this option is set, queue runs happen in order of message arrival instead of
29848 in an arbitrary order. For this to happen, a complete list of the entire queue
29849 must be set up before the deliveries start. When the queue is all held in a
29850 single directory (the default), a single list is created for both the ordered
29851 and the non-ordered cases. However, if <option>split_spool_directory</option> is set, a
29852 single list is not created when <option>queue_run_in_order</option> is false. In this case,
29853 the sub-directories are processed one at a time (in a random order), and this
29854 avoids setting up one huge list for the whole queue. Thus, setting
29855 <option>queue_run_in_order</option> with <option>split_spool_directory</option> may degrade performance
29856 when the queue is large, because of the extra work in setting up the single,
29857 large list. In most situations, <option>queue_run_in_order</option> should not be set.
29858 </para>
29859 <para>
29860 <indexterm role="option">
29861 <primary><option>queue_run_max</option></primary>
29862 </indexterm>
29863 </para>
29864 <informaltable frame="all">
29865 <tgroup cols="4" colsep="0" rowsep="0">
29866 <colspec colwidth="8*" align="left"/>
29867 <colspec colwidth="6*" align="center"/>
29868 <colspec colwidth="6*" align="center"/>
29869 <colspec colwidth="6*" align="right"/>
29870 <tbody>
29871 <row>
29872 <entry><option>queue_run_max</option></entry>
29873 <entry>Use: <emphasis>main</emphasis></entry>
29874 <entry>Type: <emphasis>integer</emphasis>&dagger;<emphasis></emphasis></entry>
29875 <entry>Default: <emphasis>5</emphasis></entry>
29876 </row>
29877 </tbody>
29878 </tgroup>
29879 </informaltable>
29880 <para>
29881 <indexterm role="concept">
29882 <primary>queue runner</primary>
29883 <secondary>maximum number of</secondary>
29884 </indexterm>
29885 This controls the maximum number of queue runner processes that an Exim daemon
29886 can run simultaneously. This does not mean that it starts them all at once,
29887 but rather that if the maximum number are still running when the time comes to
29888 start another one, it refrains from starting another one. This can happen with
29889 very large queues and/or very sluggish deliveries. This option does not,
29890 however, interlock with other processes, so additional queue runners can be
29891 started by other means, or by killing and restarting the daemon.
29892 </para>
29893 <para>
29894 Setting this option to zero does not suppress queue runs; rather, it disables
29895 the limit, allowing any number of simultaneous queue runner processes to be
29896 run. If you do not want queue runs to occur, omit the <option>-q</option><emphasis>xx</emphasis> setting on
29897 the daemon&#x2019;s command line.
29898 </para>
29899 <para>
29900 <indexterm role="concept">
29901 <primary>queues</primary>
29902 <secondary>named</secondary>
29903 </indexterm>
29904 <indexterm role="concept">
29905 <primary>named queues</primary>
29906 </indexterm>
29907 To set limits for different named queues use
29908 an expansion depending on the <varname>$queue_name</varname> variable.
29909 </para>
29910 <para>
29911 <indexterm role="option">
29912 <primary><option>queue_smtp_domains</option></primary>
29913 </indexterm>
29914 </para>
29915 <informaltable frame="all">
29916 <tgroup cols="4" colsep="0" rowsep="0">
29917 <colspec colwidth="8*" align="left"/>
29918 <colspec colwidth="6*" align="center"/>
29919 <colspec colwidth="6*" align="center"/>
29920 <colspec colwidth="6*" align="right"/>
29921 <tbody>
29922 <row>
29923 <entry><option>queue_smtp_domains</option></entry>
29924 <entry>Use: <emphasis>main</emphasis></entry>
29925 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
29926 <entry>Default: <emphasis>unset</emphasis></entry>
29927 </row>
29928 </tbody>
29929 </tgroup>
29930 </informaltable>
29931 <para>
29932 <indexterm role="concept">
29933 <primary>queueing incoming messages</primary>
29934 </indexterm>
29935 <indexterm role="concept">
29936 <primary>message</primary>
29937 <secondary>queueing remote deliveries</secondary>
29938 </indexterm>
29939 When this option is set, a delivery process is started whenever a message is
29940 received, routing is performed, and local deliveries take place.
29941 However, if any SMTP deliveries are required for domains that match
29942 <option>queue_smtp_domains</option>, they are not immediately delivered, but instead the
29943 message waits in the queue for the next queue run. Since routing of the message
29944 has taken place, Exim knows to which remote hosts it must be delivered, and so
29945 when the queue run happens, multiple messages for the same host are delivered
29946 over a single SMTP connection. The <option>-odqs</option> command line option causes all
29947 SMTP deliveries to be queued in this way, and is equivalent to setting
29948 <option>queue_smtp_domains</option> to <quote>*</quote>. See also <option>hold_domains</option> and
29949 <option>queue_domains</option>.
29950 </para>
29951 <para>
29952 <indexterm role="option">
29953 <primary><option>receive_timeout</option></primary>
29954 </indexterm>
29955 </para>
29956 <informaltable frame="all">
29957 <tgroup cols="4" colsep="0" rowsep="0">
29958 <colspec colwidth="8*" align="left"/>
29959 <colspec colwidth="6*" align="center"/>
29960 <colspec colwidth="6*" align="center"/>
29961 <colspec colwidth="6*" align="right"/>
29962 <tbody>
29963 <row>
29964 <entry><option>receive_timeout</option></entry>
29965 <entry>Use: <emphasis>main</emphasis></entry>
29966 <entry>Type: <emphasis>time</emphasis></entry>
29967 <entry>Default: <emphasis>0s</emphasis></entry>
29968 </row>
29969 </tbody>
29970 </tgroup>
29971 </informaltable>
29972 <para>
29973 <indexterm role="concept">
29974 <primary>timeout</primary>
29975 <secondary>for non-SMTP input</secondary>
29976 </indexterm>
29977 This option sets the timeout for accepting a non-SMTP message, that is, the
29978 maximum time that Exim waits when reading a message on the standard input. If
29979 the value is zero, it will wait forever. This setting is overridden by the
29980 <option>-or</option> command line option. The timeout for incoming SMTP messages is
29981 controlled by <option>smtp_receive_timeout</option>.
29982 </para>
29983 <para>
29984 <indexterm role="option">
29985 <primary><option>received_header_text</option></primary>
29986 </indexterm>
29987 </para>
29988 <informaltable frame="all">
29989 <tgroup cols="4" colsep="0" rowsep="0">
29990 <colspec colwidth="8*" align="left"/>
29991 <colspec colwidth="6*" align="center"/>
29992 <colspec colwidth="6*" align="center"/>
29993 <colspec colwidth="6*" align="right"/>
29994 <tbody>
29995 <row>
29996 <entry><option>received_header_text</option></entry>
29997 <entry>Use: <emphasis>main</emphasis></entry>
29998 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29999 <entry>Default: <emphasis>see below</emphasis></entry>
30000 </row>
30001 </tbody>
30002 </tgroup>
30003 </informaltable>
30004 <para>
30005 <indexterm role="concept">
30006 <primary>customizing</primary>
30007 <secondary><emphasis>Received:</emphasis> header</secondary>
30008 </indexterm>
30009 <indexterm role="concept">
30010 <primary><emphasis>Received:</emphasis> header line</primary>
30011 <secondary>customizing</secondary>
30012 </indexterm>
30013 This string defines the contents of the <emphasis>Received:</emphasis> message header that is
30014 added to each message, except for the timestamp, which is automatically added
30015 on at the end (preceded by a semicolon). The string is expanded each time it is
30016 used. If the expansion yields an empty string, no <emphasis>Received:</emphasis> header line is
30017 added to the message. Otherwise, the string should start with the text
30018 <quote>Received:</quote> and conform to the RFC 2822 specification for <emphasis>Received:</emphasis>
30019 header lines.
30020 </para>
30021 <para revisionflag="changed">
30022 The default setting is:
30023 </para>
30024 <literallayout class="monospaced" revisionflag="changed">
30025 received_header_text = Received: \
30026   ${if def:sender_rcvhost {from $sender_rcvhost\n\t}\
30027     {${if def:sender_ident \
30028       {from ${quote_local_part:$sender_ident} }}\
30029         ${if def:sender_helo_name {(helo=$sender_helo_name)\n\t}}}}\
30030   by $primary_hostname \
30031   ${if def:received_protocol {with $received_protocol }}\
30032   ${if def:tls_ver           { ($tls_ver)}}\
30033   ${if def:tls_in_cipher_std { tls $tls_in_cipher_std\n\t}}\
30034   (Exim $version_number)\n\t\
30035   ${if def:sender_address \
30036   {(envelope-from &lt;$sender_address&gt;)\n\t}}\
30037   id $message_exim_id\
30038   ${if def:received_for {\n\tfor $received_for}}
30039 </literallayout>
30040 <para>
30041 The reference to the TLS cipher is omitted when Exim is built without TLS
30042 support. The use of conditional expansions ensures that this works for both
30043 locally generated messages and messages received from remote hosts, giving
30044 header lines such as the following:
30045 </para>
30046 <literallayout class="monospaced">
30047 Received: from scrooge.carol.example ([192.168.12.25] ident=root)
30048 by marley.carol.example with esmtp (Exim 4.00)
30049 (envelope-from &lt;bob@carol.example&gt;)
30050 id 16IOWa-00019l-00
30051 for chas@dickens.example; Tue, 25 Dec 2001 14:43:44 +0000
30052 Received: by scrooge.carol.example with local (Exim 4.00)
30053 id 16IOWW-000083-00; Tue, 25 Dec 2001 14:43:41 +0000
30054 </literallayout>
30055 <para>
30056 Until the body of the message has been received, the timestamp is the time when
30057 the message started to be received. Once the body has arrived, and all policy
30058 checks have taken place, the timestamp is updated to the time at which the
30059 message was accepted.
30060 </para>
30061 <para>
30062 <indexterm role="option">
30063 <primary><option>received_headers_max</option></primary>
30064 </indexterm>
30065 </para>
30066 <informaltable frame="all">
30067 <tgroup cols="4" colsep="0" rowsep="0">
30068 <colspec colwidth="8*" align="left"/>
30069 <colspec colwidth="6*" align="center"/>
30070 <colspec colwidth="6*" align="center"/>
30071 <colspec colwidth="6*" align="right"/>
30072 <tbody>
30073 <row>
30074 <entry><option>received_headers_max</option></entry>
30075 <entry>Use: <emphasis>main</emphasis></entry>
30076 <entry>Type: <emphasis>integer</emphasis></entry>
30077 <entry>Default: <emphasis>30</emphasis></entry>
30078 </row>
30079 </tbody>
30080 </tgroup>
30081 </informaltable>
30082 <para>
30083 <indexterm role="concept">
30084 <primary>loop</primary>
30085 <secondary>prevention</secondary>
30086 </indexterm>
30087 <indexterm role="concept">
30088 <primary>mail loop prevention</primary>
30089 </indexterm>
30090 <indexterm role="concept">
30091 <primary><emphasis>Received:</emphasis> header line</primary>
30092 <secondary>counting</secondary>
30093 </indexterm>
30094 When a message is to be delivered, the number of <emphasis>Received:</emphasis> headers is
30095 counted, and if it is greater than this parameter, a mail loop is assumed to
30096 have occurred, the delivery is abandoned, and an error message is generated.
30097 This applies to both local and remote deliveries.
30098 </para>
30099 <para>
30100 <indexterm role="option">
30101 <primary><option>recipient_unqualified_hosts</option></primary>
30102 </indexterm>
30103 </para>
30104 <informaltable frame="all">
30105 <tgroup cols="4" colsep="0" rowsep="0">
30106 <colspec colwidth="8*" align="left"/>
30107 <colspec colwidth="6*" align="center"/>
30108 <colspec colwidth="6*" align="center"/>
30109 <colspec colwidth="6*" align="right"/>
30110 <tbody>
30111 <row>
30112 <entry><option>recipient_unqualified_hosts</option></entry>
30113 <entry>Use: <emphasis>main</emphasis></entry>
30114 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
30115 <entry>Default: <emphasis>unset</emphasis></entry>
30116 </row>
30117 </tbody>
30118 </tgroup>
30119 </informaltable>
30120 <para>
30121 <indexterm role="concept">
30122 <primary>unqualified addresses</primary>
30123 </indexterm>
30124 <indexterm role="concept">
30125 <primary>host</primary>
30126 <secondary>unqualified addresses from</secondary>
30127 </indexterm>
30128 This option lists those hosts from which Exim is prepared to accept unqualified
30129 recipient addresses in message envelopes. The addresses are made fully
30130 qualified by the addition of the <option>qualify_recipient</option> value. This option also
30131 affects message header lines. Exim does not reject unqualified recipient
30132 addresses in headers, but it qualifies them only if the message came from a
30133 host that matches <option>recipient_unqualified_hosts</option>,
30134 or if the message was submitted locally (not using TCP/IP), and the <option>-bnq</option>
30135 option was not set.
30136 </para>
30137 <para>
30138 <indexterm role="option">
30139 <primary><option>recipients_max</option></primary>
30140 </indexterm>
30141 </para>
30142 <informaltable frame="all">
30143 <tgroup cols="4" colsep="0" rowsep="0">
30144 <colspec colwidth="8*" align="left"/>
30145 <colspec colwidth="6*" align="center"/>
30146 <colspec colwidth="6*" align="center"/>
30147 <colspec colwidth="6*" align="right"/>
30148 <tbody>
30149 <row>
30150 <entry><option>recipients_max</option></entry>
30151 <entry>Use: <emphasis>main</emphasis></entry>
30152 <entry>Type: <emphasis>integer</emphasis></entry>
30153 <entry>Default: <emphasis>0</emphasis></entry>
30154 </row>
30155 </tbody>
30156 </tgroup>
30157 </informaltable>
30158 <para>
30159 <indexterm role="concept">
30160 <primary>limit</primary>
30161 <secondary>number of recipients</secondary>
30162 </indexterm>
30163 <indexterm role="concept">
30164 <primary>recipient</primary>
30165 <secondary>maximum number</secondary>
30166 </indexterm>
30167 If this option is set greater than zero, it specifies the maximum number of
30168 original recipients for any message. Additional recipients that are generated
30169 by aliasing or forwarding do not count. SMTP messages get a 452 response for
30170 all recipients over the limit; earlier recipients are delivered as normal.
30171 Non-SMTP messages with too many recipients are failed, and no deliveries are
30172 done.
30173 </para>
30174 <para>
30175 <indexterm role="concept">
30176 <primary>RCPT</primary>
30177 <secondary>maximum number of incoming</secondary>
30178 </indexterm>
30179 <emphasis role="bold">Note</emphasis>: The RFCs specify that an SMTP server should accept at least 100
30180 RCPT commands in a single message.
30181 </para>
30182 <para>
30183 <indexterm role="option">
30184 <primary><option>recipients_max_reject</option></primary>
30185 </indexterm>
30186 </para>
30187 <informaltable frame="all">
30188 <tgroup cols="4" colsep="0" rowsep="0">
30189 <colspec colwidth="8*" align="left"/>
30190 <colspec colwidth="6*" align="center"/>
30191 <colspec colwidth="6*" align="center"/>
30192 <colspec colwidth="6*" align="right"/>
30193 <tbody>
30194 <row>
30195 <entry><option>recipients_max_reject</option></entry>
30196 <entry>Use: <emphasis>main</emphasis></entry>
30197 <entry>Type: <emphasis>boolean</emphasis></entry>
30198 <entry>Default: <emphasis>false</emphasis></entry>
30199 </row>
30200 </tbody>
30201 </tgroup>
30202 </informaltable>
30203 <para>
30204 If this option is set true, Exim rejects SMTP messages containing too many
30205 recipients by giving 552 errors to the surplus RCPT commands, and a 554
30206 error to the eventual DATA command. Otherwise (the default) it gives a 452
30207 error to the surplus RCPT commands and accepts the message on behalf of the
30208 initial set of recipients. The remote server should then re-send the message
30209 for the remaining recipients at a later time.
30210 </para>
30211 <para>
30212 <indexterm role="option">
30213 <primary><option>remote_max_parallel</option></primary>
30214 </indexterm>
30215 </para>
30216 <informaltable frame="all">
30217 <tgroup cols="4" colsep="0" rowsep="0">
30218 <colspec colwidth="8*" align="left"/>
30219 <colspec colwidth="6*" align="center"/>
30220 <colspec colwidth="6*" align="center"/>
30221 <colspec colwidth="6*" align="right"/>
30222 <tbody>
30223 <row>
30224 <entry><option>remote_max_parallel</option></entry>
30225 <entry>Use: <emphasis>main</emphasis></entry>
30226 <entry>Type: <emphasis>integer</emphasis></entry>
30227 <entry>Default: <emphasis>2</emphasis></entry>
30228 </row>
30229 </tbody>
30230 </tgroup>
30231 </informaltable>
30232 <para>
30233 <indexterm role="concept">
30234 <primary>delivery</primary>
30235 <secondary>parallelism for remote</secondary>
30236 </indexterm>
30237 This option controls parallel delivery of one message to a number of remote
30238 hosts. If the value is less than 2, parallel delivery is disabled, and Exim
30239 does all the remote deliveries for a message one by one. Otherwise, if a single
30240 message has to be delivered to more than one remote host, or if several copies
30241 have to be sent to the same remote host, up to <option>remote_max_parallel</option>
30242 deliveries are done simultaneously. If more than <option>remote_max_parallel</option>
30243 deliveries are required, the maximum number of processes are started, and as
30244 each one finishes, another is begun. The order of starting processes is the
30245 same as if sequential delivery were being done, and can be controlled by the
30246 <option>remote_sort_domains</option> option. If parallel delivery takes place while running
30247 with debugging turned on, the debugging output from each delivery process is
30248 tagged with its process id.
30249 </para>
30250 <para>
30251 This option controls only the maximum number of parallel deliveries for one
30252 message in one Exim delivery process. Because Exim has no central queue
30253 manager, there is no way of controlling the total number of simultaneous
30254 deliveries if the configuration allows a delivery attempt as soon as a message
30255 is received.
30256 </para>
30257 <para>
30258 <indexterm role="concept">
30259 <primary>number of deliveries</primary>
30260 </indexterm>
30261 <indexterm role="concept">
30262 <primary>delivery</primary>
30263 <secondary>maximum number of</secondary>
30264 </indexterm>
30265 If you want to control the total number of deliveries on the system, you
30266 need to set the <option>queue_only</option> option. This ensures that all incoming messages
30267 are added to the queue without starting a delivery process. Then set up an Exim
30268 daemon to start queue runner processes at appropriate intervals (probably
30269 fairly often, for example, every minute), and limit the total number of queue
30270 runners by setting the <option>queue_run_max</option> parameter. Because each queue runner
30271 delivers only one message at a time, the maximum number of deliveries that can
30272 then take place at once is <option>queue_run_max</option> multiplied by
30273 <option>remote_max_parallel</option>.
30274 </para>
30275 <para>
30276 If it is purely remote deliveries you want to control, use
30277 <option>queue_smtp_domains</option> instead of <option>queue_only</option>. This has the added benefit of
30278 doing the SMTP routing before queueing, so that several messages for the same
30279 host will eventually get delivered down the same connection.
30280 </para>
30281 <para>
30282 <indexterm role="option">
30283 <primary><option>remote_sort_domains</option></primary>
30284 </indexterm>
30285 </para>
30286 <informaltable frame="all">
30287 <tgroup cols="4" colsep="0" rowsep="0">
30288 <colspec colwidth="8*" align="left"/>
30289 <colspec colwidth="6*" align="center"/>
30290 <colspec colwidth="6*" align="center"/>
30291 <colspec colwidth="6*" align="right"/>
30292 <tbody>
30293 <row>
30294 <entry><option>remote_sort_domains</option></entry>
30295 <entry>Use: <emphasis>main</emphasis></entry>
30296 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
30297 <entry>Default: <emphasis>unset</emphasis></entry>
30298 </row>
30299 </tbody>
30300 </tgroup>
30301 </informaltable>
30302 <para>
30303 <indexterm role="concept">
30304 <primary>sorting remote deliveries</primary>
30305 </indexterm>
30306 <indexterm role="concept">
30307 <primary>delivery</primary>
30308 <secondary>sorting remote</secondary>
30309 </indexterm>
30310 When there are a number of remote deliveries for a message, they are sorted by
30311 domain into the order given by this list. For example,
30312 </para>
30313 <literallayout class="monospaced">
30314 remote_sort_domains = *.cam.ac.uk:*.uk
30315 </literallayout>
30316 <para>
30317 would attempt to deliver to all addresses in the <emphasis>cam.ac.uk</emphasis> domain first,
30318 then to those in the <option>uk</option> domain, then to any others.
30319 </para>
30320 <para>
30321 <indexterm role="option">
30322 <primary><option>retry_data_expire</option></primary>
30323 </indexterm>
30324 </para>
30325 <informaltable frame="all">
30326 <tgroup cols="4" colsep="0" rowsep="0">
30327 <colspec colwidth="8*" align="left"/>
30328 <colspec colwidth="6*" align="center"/>
30329 <colspec colwidth="6*" align="center"/>
30330 <colspec colwidth="6*" align="right"/>
30331 <tbody>
30332 <row>
30333 <entry><option>retry_data_expire</option></entry>
30334 <entry>Use: <emphasis>main</emphasis></entry>
30335 <entry>Type: <emphasis>time</emphasis></entry>
30336 <entry>Default: <emphasis>7d</emphasis></entry>
30337 </row>
30338 </tbody>
30339 </tgroup>
30340 </informaltable>
30341 <para>
30342 <indexterm role="concept">
30343 <primary>hints database</primary>
30344 <secondary>data expiry</secondary>
30345 </indexterm>
30346 This option sets a <quote>use before</quote> time on retry information in Exim&#x2019;s hints
30347 database. Any older retry data is ignored. This means that, for example, once a
30348 host has not been tried for 7 days, Exim behaves as if it has no knowledge of
30349 past failures.
30350 </para>
30351 <para>
30352 <indexterm role="option">
30353 <primary><option>retry_interval_max</option></primary>
30354 </indexterm>
30355 </para>
30356 <informaltable frame="all">
30357 <tgroup cols="4" colsep="0" rowsep="0">
30358 <colspec colwidth="8*" align="left"/>
30359 <colspec colwidth="6*" align="center"/>
30360 <colspec colwidth="6*" align="center"/>
30361 <colspec colwidth="6*" align="right"/>
30362 <tbody>
30363 <row>
30364 <entry><option>retry_interval_max</option></entry>
30365 <entry>Use: <emphasis>main</emphasis></entry>
30366 <entry>Type: <emphasis>time</emphasis></entry>
30367 <entry>Default: <emphasis>24h</emphasis></entry>
30368 </row>
30369 </tbody>
30370 </tgroup>
30371 </informaltable>
30372 <para>
30373 <indexterm role="concept">
30374 <primary>retry</primary>
30375 <secondary>limit on interval</secondary>
30376 </indexterm>
30377 <indexterm role="concept">
30378 <primary>limit</primary>
30379 <secondary>on retry interval</secondary>
30380 </indexterm>
30381 Chapter <xref linkend="CHAPretry"/> describes Exim&#x2019;s mechanisms for controlling the
30382 intervals between delivery attempts for messages that cannot be delivered
30383 straight away. This option sets an overall limit to the length of time between
30384 retries. It cannot be set greater than 24 hours; any attempt to do so forces
30385 the default value.
30386 </para>
30387 <para>
30388 <indexterm role="option">
30389 <primary><option>return_path_remove</option></primary>
30390 </indexterm>
30391 </para>
30392 <informaltable frame="all">
30393 <tgroup cols="4" colsep="0" rowsep="0">
30394 <colspec colwidth="8*" align="left"/>
30395 <colspec colwidth="6*" align="center"/>
30396 <colspec colwidth="6*" align="center"/>
30397 <colspec colwidth="6*" align="right"/>
30398 <tbody>
30399 <row>
30400 <entry><option>return_path_remove</option></entry>
30401 <entry>Use: <emphasis>main</emphasis></entry>
30402 <entry>Type: <emphasis>boolean</emphasis></entry>
30403 <entry>Default: <emphasis>true</emphasis></entry>
30404 </row>
30405 </tbody>
30406 </tgroup>
30407 </informaltable>
30408 <para>
30409 <indexterm role="concept">
30410 <primary><emphasis>Return-path:</emphasis> header line</primary>
30411 <secondary>removing</secondary>
30412 </indexterm>
30413 RFC 2821, section 4.4, states that an SMTP server must insert a
30414 <emphasis>Return-path:</emphasis> header line into a message when it makes a <quote>final delivery</quote>.
30415 The <emphasis>Return-path:</emphasis> header preserves the sender address as received in the
30416 MAIL command. This description implies that this header should not be present
30417 in an incoming message. If <option>return_path_remove</option> is true, any existing
30418 <emphasis>Return-path:</emphasis> headers are removed from messages at the time they are
30419 received. Exim&#x2019;s transports have options for adding <emphasis>Return-path:</emphasis> headers at
30420 the time of delivery. They are normally used only for final local deliveries.
30421 </para>
30422 <para>
30423 <indexterm role="option">
30424 <primary><option>return_size_limit</option></primary>
30425 </indexterm>
30426 </para>
30427 <informaltable frame="all">
30428 <tgroup cols="4" colsep="0" rowsep="0">
30429 <colspec colwidth="8*" align="left"/>
30430 <colspec colwidth="6*" align="center"/>
30431 <colspec colwidth="6*" align="center"/>
30432 <colspec colwidth="6*" align="right"/>
30433 <tbody>
30434 <row>
30435 <entry><option>return_size_limit</option></entry>
30436 <entry>Use: <emphasis>main</emphasis></entry>
30437 <entry>Type: <emphasis>integer</emphasis></entry>
30438 <entry>Default: <emphasis>100K</emphasis></entry>
30439 </row>
30440 </tbody>
30441 </tgroup>
30442 </informaltable>
30443 <para>
30444 This option is an obsolete synonym for <option>bounce_return_size_limit</option>.
30445 </para>
30446 <para>
30447 <indexterm role="option">
30448 <primary><option>rfc1413_hosts</option></primary>
30449 </indexterm>
30450 </para>
30451 <informaltable frame="all">
30452 <tgroup cols="4" colsep="0" rowsep="0">
30453 <colspec colwidth="8*" align="left"/>
30454 <colspec colwidth="6*" align="center"/>
30455 <colspec colwidth="6*" align="center"/>
30456 <colspec colwidth="6*" align="right"/>
30457 <tbody>
30458 <row>
30459 <entry><option>rfc1413_hosts</option></entry>
30460 <entry>Use: <emphasis>main</emphasis></entry>
30461 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
30462 <entry>Default: <emphasis>@[]</emphasis></entry>
30463 </row>
30464 </tbody>
30465 </tgroup>
30466 </informaltable>
30467 <para>
30468 <indexterm role="concept">
30469 <primary>RFC 1413</primary>
30470 </indexterm>
30471 <indexterm role="concept">
30472 <primary>host</primary>
30473 <secondary>for RFC 1413 calls</secondary>
30474 </indexterm>
30475 RFC 1413 identification calls are made to any client host which matches
30476 an item in the list.
30477 The default value specifies just this host, being any local interface
30478 for the system.
30479 </para>
30480 <para>
30481 <indexterm role="option">
30482 <primary><option>rfc1413_query_timeout</option></primary>
30483 </indexterm>
30484 </para>
30485 <informaltable frame="all">
30486 <tgroup cols="4" colsep="0" rowsep="0">
30487 <colspec colwidth="8*" align="left"/>
30488 <colspec colwidth="6*" align="center"/>
30489 <colspec colwidth="6*" align="center"/>
30490 <colspec colwidth="6*" align="right"/>
30491 <tbody>
30492 <row>
30493 <entry><option>rfc1413_query_timeout</option></entry>
30494 <entry>Use: <emphasis>main</emphasis></entry>
30495 <entry>Type: <emphasis>time</emphasis></entry>
30496 <entry>Default: <emphasis>0s</emphasis></entry>
30497 </row>
30498 </tbody>
30499 </tgroup>
30500 </informaltable>
30501 <para>
30502 <indexterm role="concept">
30503 <primary>RFC 1413</primary>
30504 <secondary>query timeout</secondary>
30505 </indexterm>
30506 <indexterm role="concept">
30507 <primary>timeout</primary>
30508 <secondary>for RFC 1413 call</secondary>
30509 </indexterm>
30510 This sets the timeout on RFC 1413 identification calls. If it is set to zero,
30511 no RFC 1413 calls are ever made.
30512 </para>
30513 <para>
30514 <indexterm role="option">
30515 <primary><option>sender_unqualified_hosts</option></primary>
30516 </indexterm>
30517 </para>
30518 <informaltable frame="all">
30519 <tgroup cols="4" colsep="0" rowsep="0">
30520 <colspec colwidth="8*" align="left"/>
30521 <colspec colwidth="6*" align="center"/>
30522 <colspec colwidth="6*" align="center"/>
30523 <colspec colwidth="6*" align="right"/>
30524 <tbody>
30525 <row>
30526 <entry><option>sender_unqualified_hosts</option></entry>
30527 <entry>Use: <emphasis>main</emphasis></entry>
30528 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
30529 <entry>Default: <emphasis>unset</emphasis></entry>
30530 </row>
30531 </tbody>
30532 </tgroup>
30533 </informaltable>
30534 <para>
30535 <indexterm role="concept">
30536 <primary>unqualified addresses</primary>
30537 </indexterm>
30538 <indexterm role="concept">
30539 <primary>host</primary>
30540 <secondary>unqualified addresses from</secondary>
30541 </indexterm>
30542 This option lists those hosts from which Exim is prepared to accept unqualified
30543 sender addresses. The addresses are made fully qualified by the addition of
30544 <option>qualify_domain</option>. This option also affects message header lines. Exim does
30545 not reject unqualified addresses in headers that contain sender addresses, but
30546 it qualifies them only if the message came from a host that matches
30547 <option>sender_unqualified_hosts</option>, or if the message was submitted locally (not
30548 using TCP/IP), and the <option>-bnq</option> option was not set.
30549 </para>
30550 <para>
30551 <indexterm role="option">
30552 <primary><option>slow_lookup_log</option></primary>
30553 </indexterm>
30554 </para>
30555 <informaltable frame="all">
30556 <tgroup cols="4" colsep="0" rowsep="0">
30557 <colspec colwidth="8*" align="left"/>
30558 <colspec colwidth="6*" align="center"/>
30559 <colspec colwidth="6*" align="center"/>
30560 <colspec colwidth="6*" align="right"/>
30561 <tbody>
30562 <row>
30563 <entry><option>slow_lookup_log</option></entry>
30564 <entry>Use: <emphasis>main</emphasis></entry>
30565 <entry>Type: <emphasis>integer</emphasis></entry>
30566 <entry>Default: <emphasis>0</emphasis></entry>
30567 </row>
30568 </tbody>
30569 </tgroup>
30570 </informaltable>
30571 <para>
30572 <indexterm role="concept">
30573 <primary>logging</primary>
30574 <secondary>slow lookups</secondary>
30575 </indexterm>
30576 <indexterm role="concept">
30577 <primary>dns</primary>
30578 <secondary>logging slow lookups</secondary>
30579 </indexterm>
30580 This option controls logging of slow lookups.
30581 If the value is nonzero it is taken as a number of milliseconds
30582 and lookups taking longer than this are logged.
30583 Currently this applies only to DNS lookups.
30584 </para>
30585 <para>
30586 <indexterm role="option">
30587 <primary><option>smtp_accept_keepalive</option></primary>
30588 </indexterm>
30589 </para>
30590 <informaltable frame="all">
30591 <tgroup cols="4" colsep="0" rowsep="0">
30592 <colspec colwidth="8*" align="left"/>
30593 <colspec colwidth="6*" align="center"/>
30594 <colspec colwidth="6*" align="center"/>
30595 <colspec colwidth="6*" align="right"/>
30596 <tbody>
30597 <row>
30598 <entry><option>smtp_accept_keepalive</option></entry>
30599 <entry>Use: <emphasis>main</emphasis></entry>
30600 <entry>Type: <emphasis>boolean</emphasis></entry>
30601 <entry>Default: <emphasis>true</emphasis></entry>
30602 </row>
30603 </tbody>
30604 </tgroup>
30605 </informaltable>
30606 <para>
30607 <indexterm role="concept">
30608 <primary>keepalive</primary>
30609 <secondary>on incoming connection</secondary>
30610 </indexterm>
30611 This option controls the setting of the SO_KEEPALIVE option on incoming
30612 TCP/IP socket connections. When set, it causes the kernel to probe idle
30613 connections periodically, by sending packets with <quote>old</quote> sequence numbers. The
30614 other end of the connection should send an acknowledgment if the connection is
30615 still okay or a reset if the connection has been aborted. The reason for doing
30616 this is that it has the beneficial effect of freeing up certain types of
30617 connection that can get stuck when the remote host is disconnected without
30618 tidying up the TCP/IP call properly. The keepalive mechanism takes several
30619 hours to detect unreachable hosts.
30620 </para>
30621 <para>
30622 <indexterm role="option">
30623 <primary><option>smtp_accept_max</option></primary>
30624 </indexterm>
30625 </para>
30626 <informaltable frame="all">
30627 <tgroup cols="4" colsep="0" rowsep="0">
30628 <colspec colwidth="8*" align="left"/>
30629 <colspec colwidth="6*" align="center"/>
30630 <colspec colwidth="6*" align="center"/>
30631 <colspec colwidth="6*" align="right"/>
30632 <tbody>
30633 <row>
30634 <entry><option>smtp_accept_max</option></entry>
30635 <entry>Use: <emphasis>main</emphasis></entry>
30636 <entry>Type: <emphasis>integer</emphasis></entry>
30637 <entry>Default: <emphasis>20</emphasis></entry>
30638 </row>
30639 </tbody>
30640 </tgroup>
30641 </informaltable>
30642 <para>
30643 <indexterm role="concept">
30644 <primary>limit</primary>
30645 <secondary>incoming SMTP connections</secondary>
30646 </indexterm>
30647 <indexterm role="concept">
30648 <primary>SMTP</primary>
30649 <secondary>incoming connection count</secondary>
30650 </indexterm>
30651 <indexterm role="concept">
30652 <primary>inetd</primary>
30653 </indexterm>
30654 This option specifies the maximum number of simultaneous incoming SMTP calls
30655 that Exim will accept. It applies only to the listening daemon; there is no
30656 control (in Exim) when incoming SMTP is being handled by <emphasis>inetd</emphasis>. If the
30657 value is set to zero, no limit is applied. However, it is required to be
30658 non-zero if either <option>smtp_accept_max_per_host</option> or <option>smtp_accept_queue</option> is
30659 set. See also <option>smtp_accept_reserve</option> and <option>smtp_load_reserve</option>.
30660 </para>
30661 <para>
30662 A new SMTP connection is immediately rejected if the <option>smtp_accept_max</option> limit
30663 has been reached. If not, Exim first checks <option>smtp_accept_max_per_host</option>. If
30664 that limit has not been reached for the client host, <option>smtp_accept_reserve</option>
30665 and <option>smtp_load_reserve</option> are then checked before accepting the connection.
30666 </para>
30667 <para>
30668 <indexterm role="option">
30669 <primary><option>smtp_accept_max_nonmail</option></primary>
30670 </indexterm>
30671 </para>
30672 <informaltable frame="all">
30673 <tgroup cols="4" colsep="0" rowsep="0">
30674 <colspec colwidth="8*" align="left"/>
30675 <colspec colwidth="6*" align="center"/>
30676 <colspec colwidth="6*" align="center"/>
30677 <colspec colwidth="6*" align="right"/>
30678 <tbody>
30679 <row>
30680 <entry><option>smtp_accept_max_nonmail</option></entry>
30681 <entry>Use: <emphasis>main</emphasis></entry>
30682 <entry>Type: <emphasis>integer</emphasis></entry>
30683 <entry>Default: <emphasis>10</emphasis></entry>
30684 </row>
30685 </tbody>
30686 </tgroup>
30687 </informaltable>
30688 <para>
30689 <indexterm role="concept">
30690 <primary>limit</primary>
30691 <secondary>non-mail SMTP commands</secondary>
30692 </indexterm>
30693 <indexterm role="concept">
30694 <primary>SMTP</primary>
30695 <secondary>limiting non-mail commands</secondary>
30696 </indexterm>
30697 Exim counts the number of <quote>non-mail</quote> commands in an SMTP session, and drops
30698 the connection if there are too many. This option defines <quote>too many</quote>. The
30699 check catches some denial-of-service attacks, repeated failing AUTHs, or a mad
30700 client looping sending EHLO, for example. The check is applied only if the
30701 client host matches <option>smtp_accept_max_nonmail_hosts</option>.
30702 </para>
30703 <para>
30704 When a new message is expected, one occurrence of RSET is not counted. This
30705 allows a client to send one RSET between messages (this is not necessary,
30706 but some clients do it). Exim also allows one uncounted occurrence of HELO
30707 or EHLO, and one occurrence of STARTTLS between messages. After
30708 starting up a TLS session, another EHLO is expected, and so it too is not
30709 counted. The first occurrence of AUTH in a connection, or immediately
30710 following STARTTLS is not counted. Otherwise, all commands other than
30711 MAIL, RCPT, DATA, and QUIT are counted.
30712 </para>
30713 <para>
30714 <indexterm role="option">
30715 <primary><option>smtp_accept_max_nonmail_hosts</option></primary>
30716 </indexterm>
30717 </para>
30718 <informaltable frame="all">
30719 <tgroup cols="4" colsep="0" rowsep="0">
30720 <colspec colwidth="8*" align="left"/>
30721 <colspec colwidth="6*" align="center"/>
30722 <colspec colwidth="6*" align="center"/>
30723 <colspec colwidth="6*" align="right"/>
30724 <tbody>
30725 <row>
30726 <entry><option>smtp_accept_max_nonmail_hosts</option></entry>
30727 <entry>Use: <emphasis>main</emphasis></entry>
30728 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
30729 <entry>Default: <emphasis>*</emphasis></entry>
30730 </row>
30731 </tbody>
30732 </tgroup>
30733 </informaltable>
30734 <para>
30735 You can control which hosts are subject to the <option>smtp_accept_max_nonmail</option>
30736 check by setting this option. The default value makes it apply to all hosts. By
30737 changing the value, you can exclude any badly-behaved hosts that you have to
30738 live with.
30739 </para>
30740 <para>
30741 <indexterm role="option">
30742 <primary><option>smtp_accept_max_per_connection</option></primary>
30743 </indexterm>
30744 </para>
30745 <informaltable frame="all">
30746 <tgroup cols="4" colsep="0" rowsep="0">
30747 <colspec colwidth="8*" align="left"/>
30748 <colspec colwidth="6*" align="center"/>
30749 <colspec colwidth="6*" align="center"/>
30750 <colspec colwidth="6*" align="right"/>
30751 <tbody>
30752 <row>
30753 <entry><option>smtp_accept_max_per_connection</option></entry>
30754 <entry>Use: <emphasis>main</emphasis></entry>
30755 <entry>Type: <emphasis>integer</emphasis></entry>
30756 <entry>Default: <emphasis>1000</emphasis></entry>
30757 </row>
30758 </tbody>
30759 </tgroup>
30760 </informaltable>
30761 <para>
30762 <indexterm role="concept">
30763 <primary>SMTP</primary>
30764 <secondary>limiting incoming message count</secondary>
30765 </indexterm>
30766 <indexterm role="concept">
30767 <primary>limit</primary>
30768 <secondary>messages per SMTP connection</secondary>
30769 </indexterm>
30770 The value of this option limits the number of MAIL commands that Exim is
30771 prepared to accept over a single SMTP connection, whether or not each command
30772 results in the transfer of a message. After the limit is reached, a 421
30773 response is given to subsequent MAIL commands. This limit is a safety
30774 precaution against a client that goes mad (incidents of this type have been
30775 seen).
30776 </para>
30777 <para>
30778 <indexterm role="option">
30779 <primary><option>smtp_accept_max_per_host</option></primary>
30780 </indexterm>
30781 </para>
30782 <informaltable frame="all">
30783 <tgroup cols="4" colsep="0" rowsep="0">
30784 <colspec colwidth="8*" align="left"/>
30785 <colspec colwidth="6*" align="center"/>
30786 <colspec colwidth="6*" align="center"/>
30787 <colspec colwidth="6*" align="right"/>
30788 <tbody>
30789 <row>
30790 <entry><option>smtp_accept_max_per_host</option></entry>
30791 <entry>Use: <emphasis>main</emphasis></entry>
30792 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30793 <entry>Default: <emphasis>unset</emphasis></entry>
30794 </row>
30795 </tbody>
30796 </tgroup>
30797 </informaltable>
30798 <para>
30799 <indexterm role="concept">
30800 <primary>limit</primary>
30801 <secondary>SMTP connections from one host</secondary>
30802 </indexterm>
30803 <indexterm role="concept">
30804 <primary>host</primary>
30805 <secondary>limiting SMTP connections from</secondary>
30806 </indexterm>
30807 This option restricts the number of simultaneous IP connections from a single
30808 host (strictly, from a single IP address) to the Exim daemon. The option is
30809 expanded, to enable different limits to be applied to different hosts by
30810 reference to <varname>$sender_host_address</varname>. Once the limit is reached, additional
30811 connection attempts from the same host are rejected with error code 421. This
30812 is entirely independent of <option>smtp_accept_reserve</option>. The option&#x2019;s default value
30813 of zero imposes no limit. If this option is set greater than zero, it is
30814 required that <option>smtp_accept_max</option> be non-zero.
30815 </para>
30816 <para>
30817 <emphasis role="bold">Warning</emphasis>: When setting this option you should not use any expansion
30818 constructions that take an appreciable amount of time. The expansion and test
30819 happen in the main daemon loop, in order to reject additional connections
30820 without forking additional processes (otherwise a denial-of-service attack
30821 could cause a vast number or processes to be created). While the daemon is
30822 doing this processing, it cannot accept any other incoming connections.
30823 </para>
30824 <para>
30825 <indexterm role="option">
30826 <primary><option>smtp_accept_queue</option></primary>
30827 </indexterm>
30828 </para>
30829 <informaltable frame="all">
30830 <tgroup cols="4" colsep="0" rowsep="0">
30831 <colspec colwidth="8*" align="left"/>
30832 <colspec colwidth="6*" align="center"/>
30833 <colspec colwidth="6*" align="center"/>
30834 <colspec colwidth="6*" align="right"/>
30835 <tbody>
30836 <row>
30837 <entry><option>smtp_accept_queue</option></entry>
30838 <entry>Use: <emphasis>main</emphasis></entry>
30839 <entry>Type: <emphasis>integer</emphasis></entry>
30840 <entry>Default: <emphasis>0</emphasis></entry>
30841 </row>
30842 </tbody>
30843 </tgroup>
30844 </informaltable>
30845 <para>
30846 <indexterm role="concept">
30847 <primary>SMTP</primary>
30848 <secondary>incoming connection count</secondary>
30849 </indexterm>
30850 <indexterm role="concept">
30851 <primary>queueing incoming messages</primary>
30852 </indexterm>
30853 <indexterm role="concept">
30854 <primary>message</primary>
30855 <secondary>queueing by SMTP connection count</secondary>
30856 </indexterm>
30857 If the number of simultaneous incoming SMTP connections being handled via the
30858 listening daemon exceeds this value, messages received by SMTP are just placed
30859 in the queue; no delivery processes are started automatically. The count is
30860 fixed at the start of an SMTP connection. It cannot be updated in the
30861 subprocess that receives messages, and so the queueing or not queueing applies
30862 to all messages received in the same connection.
30863 </para>
30864 <para>
30865 A value of zero implies no limit, and clearly any non-zero value is useful only
30866 if it is less than the <option>smtp_accept_max</option> value (unless that is zero). See
30867 also <option>queue_only</option>, <option>queue_only_load</option>, <option>queue_smtp_domains</option>, and the
30868 various <option>-od</option><emphasis>x</emphasis> command line options.
30869 </para>
30870 <para>
30871 <indexterm role="option">
30872 <primary><option>smtp_accept_queue_per_connection</option></primary>
30873 </indexterm>
30874 </para>
30875 <informaltable frame="all">
30876 <tgroup cols="4" colsep="0" rowsep="0">
30877 <colspec colwidth="8*" align="left"/>
30878 <colspec colwidth="6*" align="center"/>
30879 <colspec colwidth="6*" align="center"/>
30880 <colspec colwidth="6*" align="right"/>
30881 <tbody>
30882 <row>
30883 <entry><option>smtp_accept_queue_per_connection</option></entry>
30884 <entry>Use: <emphasis>main</emphasis></entry>
30885 <entry>Type: <emphasis>integer</emphasis></entry>
30886 <entry>Default: <emphasis>10</emphasis></entry>
30887 </row>
30888 </tbody>
30889 </tgroup>
30890 </informaltable>
30891 <para>
30892 <indexterm role="concept">
30893 <primary>queueing incoming messages</primary>
30894 </indexterm>
30895 <indexterm role="concept">
30896 <primary>message</primary>
30897 <secondary>queueing by message count</secondary>
30898 </indexterm>
30899 This option limits the number of delivery processes that Exim starts
30900 automatically when receiving messages via SMTP, whether via the daemon or by
30901 the use of <option>-bs</option> or <option>-bS</option>. If the value of the option is greater than zero,
30902 and the number of messages received in a single SMTP session exceeds this
30903 number, subsequent messages are placed in the queue, but no delivery processes
30904 are started. This helps to limit the number of Exim processes when a server
30905 restarts after downtime and there is a lot of mail waiting for it on other
30906 systems. On large systems, the default should probably be increased, and on
30907 dial-in client systems it should probably be set to zero (that is, disabled).
30908 </para>
30909 <para>
30910 <indexterm role="option">
30911 <primary><option>smtp_accept_reserve</option></primary>
30912 </indexterm>
30913 </para>
30914 <informaltable frame="all">
30915 <tgroup cols="4" colsep="0" rowsep="0">
30916 <colspec colwidth="8*" align="left"/>
30917 <colspec colwidth="6*" align="center"/>
30918 <colspec colwidth="6*" align="center"/>
30919 <colspec colwidth="6*" align="right"/>
30920 <tbody>
30921 <row>
30922 <entry><option>smtp_accept_reserve</option></entry>
30923 <entry>Use: <emphasis>main</emphasis></entry>
30924 <entry>Type: <emphasis>integer</emphasis></entry>
30925 <entry>Default: <emphasis>0</emphasis></entry>
30926 </row>
30927 </tbody>
30928 </tgroup>
30929 </informaltable>
30930 <para>
30931 <indexterm role="concept">
30932 <primary>SMTP</primary>
30933 <secondary>incoming call count</secondary>
30934 </indexterm>
30935 <indexterm role="concept">
30936 <primary>host</primary>
30937 <secondary>reserved</secondary>
30938 </indexterm>
30939 When <option>smtp_accept_max</option> is set greater than zero, this option specifies a
30940 number of SMTP connections that are reserved for connections from the hosts
30941 that are specified in <option>smtp_reserve_hosts</option>. The value set in
30942 <option>smtp_accept_max</option> includes this reserve pool. The specified hosts are not
30943 restricted to this number of connections; the option specifies a minimum number
30944 of connection slots for them, not a maximum. It is a guarantee that this group
30945 of hosts can always get at least <option>smtp_accept_reserve</option> connections. However,
30946 the limit specified by <option>smtp_accept_max_per_host</option> is still applied to each
30947 individual host.
30948 </para>
30949 <para>
30950 For example, if <option>smtp_accept_max</option> is set to 50 and <option>smtp_accept_reserve</option> is
30951 set to 5, once there are 45 active connections (from any hosts), new
30952 connections are accepted only from hosts listed in <option>smtp_reserve_hosts</option>,
30953 provided the other criteria for acceptance are met.
30954 </para>
30955 <para>
30956 <indexterm role="option">
30957 <primary><option>smtp_active_hostname</option></primary>
30958 </indexterm>
30959 </para>
30960 <informaltable frame="all">
30961 <tgroup cols="4" colsep="0" rowsep="0">
30962 <colspec colwidth="8*" align="left"/>
30963 <colspec colwidth="6*" align="center"/>
30964 <colspec colwidth="6*" align="center"/>
30965 <colspec colwidth="6*" align="right"/>
30966 <tbody>
30967 <row>
30968 <entry><option>smtp_active_hostname</option></entry>
30969 <entry>Use: <emphasis>main</emphasis></entry>
30970 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30971 <entry>Default: <emphasis>unset</emphasis></entry>
30972 </row>
30973 </tbody>
30974 </tgroup>
30975 </informaltable>
30976 <para>
30977 <indexterm role="concept">
30978 <primary>host</primary>
30979 <secondary>name in SMTP responses</secondary>
30980 </indexterm>
30981 <indexterm role="concept">
30982 <primary>SMTP</primary>
30983 <secondary>host name in responses</secondary>
30984 </indexterm>
30985 <indexterm role="variable">
30986 <primary><varname>$primary_hostname</varname></primary>
30987 </indexterm>
30988 This option is provided for multi-homed servers that want to masquerade as
30989 several different hosts. At the start of an incoming SMTP connection, its value
30990 is expanded and used instead of the value of <varname>$primary_hostname</varname> in SMTP
30991 responses. For example, it is used as domain name in the response to an
30992 incoming HELO or EHLO command.
30993 </para>
30994 <para>
30995 <indexterm role="variable">
30996 <primary><varname>$smtp_active_hostname</varname></primary>
30997 </indexterm>
30998 The active hostname is placed in the <varname>$smtp_active_hostname</varname> variable, which
30999 is saved with any messages that are received. It is therefore available for use
31000 in routers and transports when the message is later delivered.
31001 </para>
31002 <para>
31003 If this option is unset, or if its expansion is forced to fail, or if the
31004 expansion results in an empty string, the value of <varname>$primary_hostname</varname> is
31005 used. Other expansion failures cause a message to be written to the main and
31006 panic logs, and the SMTP command receives a temporary error. Typically, the
31007 value of <option>smtp_active_hostname</option> depends on the incoming interface address.
31008 For example:
31009 </para>
31010 <literallayout class="monospaced">
31011 smtp_active_hostname = ${if eq{$received_ip_address}{10.0.0.1}\
31012   {cox.mydomain}{box.mydomain}}
31013 </literallayout>
31014 <para>
31015 Although <varname>$smtp_active_hostname</varname> is primarily concerned with incoming
31016 messages, it is also used as the default for HELO commands in callout
31017 verification if there is no remote transport from which to obtain a
31018 <option>helo_data</option> value.
31019 </para>
31020 <para>
31021 <indexterm role="option">
31022 <primary><option>smtp_banner</option></primary>
31023 </indexterm>
31024 </para>
31025 <informaltable frame="all">
31026 <tgroup cols="4" colsep="0" rowsep="0">
31027 <colspec colwidth="8*" align="left"/>
31028 <colspec colwidth="6*" align="center"/>
31029 <colspec colwidth="6*" align="center"/>
31030 <colspec colwidth="6*" align="right"/>
31031 <tbody>
31032 <row>
31033 <entry><option>smtp_banner</option></entry>
31034 <entry>Use: <emphasis>main</emphasis></entry>
31035 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
31036 <entry>Default: <emphasis>see below</emphasis></entry>
31037 </row>
31038 </tbody>
31039 </tgroup>
31040 </informaltable>
31041 <para>
31042 <indexterm role="concept">
31043 <primary>SMTP</primary>
31044 <secondary>welcome banner</secondary>
31045 </indexterm>
31046 <indexterm role="concept">
31047 <primary>banner for SMTP</primary>
31048 </indexterm>
31049 <indexterm role="concept">
31050 <primary>welcome banner for SMTP</primary>
31051 </indexterm>
31052 <indexterm role="concept">
31053 <primary>customizing</primary>
31054 <secondary>SMTP banner</secondary>
31055 </indexterm>
31056 This string, which is expanded every time it is used, is output as the initial
31057 positive response to an SMTP connection. The default setting is:
31058 </para>
31059 <literallayout class="monospaced">
31060 smtp_banner = $smtp_active_hostname ESMTP Exim \
31061   $version_number $tod_full
31062 </literallayout>
31063 <para>
31064 Failure to expand the string causes a panic error. If you want to create a
31065 multiline response to the initial SMTP connection, use <quote>\n</quote> in the string at
31066 appropriate points, but not at the end. Note that the 220 code is not included
31067 in this string. Exim adds it automatically (several times in the case of a
31068 multiline response).
31069 </para>
31070 <para>
31071 <indexterm role="option">
31072 <primary><option>smtp_check_spool_space</option></primary>
31073 </indexterm>
31074 </para>
31075 <informaltable frame="all">
31076 <tgroup cols="4" colsep="0" rowsep="0">
31077 <colspec colwidth="8*" align="left"/>
31078 <colspec colwidth="6*" align="center"/>
31079 <colspec colwidth="6*" align="center"/>
31080 <colspec colwidth="6*" align="right"/>
31081 <tbody>
31082 <row>
31083 <entry><option>smtp_check_spool_space</option></entry>
31084 <entry>Use: <emphasis>main</emphasis></entry>
31085 <entry>Type: <emphasis>boolean</emphasis></entry>
31086 <entry>Default: <emphasis>true</emphasis></entry>
31087 </row>
31088 </tbody>
31089 </tgroup>
31090 </informaltable>
31091 <para>
31092 <indexterm role="concept">
31093 <primary>checking disk space</primary>
31094 </indexterm>
31095 <indexterm role="concept">
31096 <primary>disk space, checking</primary>
31097 </indexterm>
31098 <indexterm role="concept">
31099 <primary>spool directory</primary>
31100 <secondary>checking space</secondary>
31101 </indexterm>
31102 When this option is set, if an incoming SMTP session encounters the SIZE
31103 option on a MAIL command, it checks that there is enough space in the
31104 spool directory&#x2019;s partition to accept a message of that size, while still
31105 leaving free the amount specified by <option>check_spool_space</option> (even if that value
31106 is zero). If there isn&#x2019;t enough space, a temporary error code is returned.
31107 </para>
31108 <para>
31109 <indexterm role="option">
31110 <primary><option>smtp_connect_backlog</option></primary>
31111 </indexterm>
31112 </para>
31113 <informaltable frame="all">
31114 <tgroup cols="4" colsep="0" rowsep="0">
31115 <colspec colwidth="8*" align="left"/>
31116 <colspec colwidth="6*" align="center"/>
31117 <colspec colwidth="6*" align="center"/>
31118 <colspec colwidth="6*" align="right"/>
31119 <tbody>
31120 <row>
31121 <entry><option>smtp_connect_backlog</option></entry>
31122 <entry>Use: <emphasis>main</emphasis></entry>
31123 <entry>Type: <emphasis>integer</emphasis></entry>
31124 <entry>Default: <emphasis>20</emphasis></entry>
31125 </row>
31126 </tbody>
31127 </tgroup>
31128 </informaltable>
31129 <para>
31130 <indexterm role="concept">
31131 <primary>connection backlog</primary>
31132 </indexterm>
31133 <indexterm role="concept">
31134 <primary>SMTP</primary>
31135 <secondary>connection backlog</secondary>
31136 </indexterm>
31137 <indexterm role="concept">
31138 <primary>backlog of connections</primary>
31139 </indexterm>
31140 This option specifies a maximum number of waiting SMTP connections. Exim passes
31141 this value to the TCP/IP system when it sets up its listener. Once this number
31142 of connections are waiting for the daemon&#x2019;s attention, subsequent connection
31143 attempts are refused at the TCP/IP level. At least, that is what the manuals
31144 say; in some circumstances such connection attempts have been observed to time
31145 out instead. For large systems it is probably a good idea to increase the
31146 value (to 50, say). It also gives some protection against denial-of-service
31147 attacks by SYN flooding.
31148 </para>
31149 <para>
31150 <indexterm role="option">
31151 <primary><option>smtp_enforce_sync</option></primary>
31152 </indexterm>
31153 </para>
31154 <informaltable frame="all">
31155 <tgroup cols="4" colsep="0" rowsep="0">
31156 <colspec colwidth="8*" align="left"/>
31157 <colspec colwidth="6*" align="center"/>
31158 <colspec colwidth="6*" align="center"/>
31159 <colspec colwidth="6*" align="right"/>
31160 <tbody>
31161 <row>
31162 <entry><option>smtp_enforce_sync</option></entry>
31163 <entry>Use: <emphasis>main</emphasis></entry>
31164 <entry>Type: <emphasis>boolean</emphasis></entry>
31165 <entry>Default: <emphasis>true</emphasis></entry>
31166 </row>
31167 </tbody>
31168 </tgroup>
31169 </informaltable>
31170 <para>
31171 <indexterm role="concept">
31172 <primary>SMTP</primary>
31173 <secondary>synchronization checking</secondary>
31174 </indexterm>
31175 <indexterm role="concept">
31176 <primary>synchronization checking in SMTP</primary>
31177 </indexterm>
31178 The SMTP protocol specification requires the client to wait for a response from
31179 the server at certain points in the dialogue. Without PIPELINING these
31180 synchronization points are after every command; with PIPELINING they are
31181 fewer, but they still exist.
31182 </para>
31183 <para>
31184 Some spamming sites send out a complete set of SMTP commands without waiting
31185 for any response. Exim protects against this by rejecting a message if the
31186 client has sent further input when it should not have. The error response <quote>554
31187 SMTP synchronization error</quote> is sent, and the connection is dropped. Testing
31188 for this error cannot be perfect because of transmission delays (unexpected
31189 input may be on its way but not yet received when Exim checks). However, it
31190 does detect many instances.
31191 </para>
31192 <para>
31193 The check can be globally disabled by setting <option>smtp_enforce_sync</option> false.
31194 If you want to disable the check selectively (for example, only for certain
31195 hosts), you can do so by an appropriate use of a <option>control</option> modifier in an ACL
31196 (see section <xref linkend="SECTcontrols"/>). See also <option>pipelining_advertise_hosts</option>.
31197 </para>
31198 <para>
31199 <indexterm role="option">
31200 <primary><option>smtp_etrn_command</option></primary>
31201 </indexterm>
31202 </para>
31203 <informaltable frame="all">
31204 <tgroup cols="4" colsep="0" rowsep="0">
31205 <colspec colwidth="8*" align="left"/>
31206 <colspec colwidth="6*" align="center"/>
31207 <colspec colwidth="6*" align="center"/>
31208 <colspec colwidth="6*" align="right"/>
31209 <tbody>
31210 <row>
31211 <entry><option>smtp_etrn_command</option></entry>
31212 <entry>Use: <emphasis>main</emphasis></entry>
31213 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
31214 <entry>Default: <emphasis>unset</emphasis></entry>
31215 </row>
31216 </tbody>
31217 </tgroup>
31218 </informaltable>
31219 <para>
31220 <indexterm role="concept">
31221 <primary>ETRN</primary>
31222 <secondary>command to be run</secondary>
31223 </indexterm>
31224 <indexterm role="variable">
31225 <primary><varname>$domain</varname></primary>
31226 </indexterm>
31227 If this option is set, the given command is run whenever an SMTP ETRN
31228 command is received from a host that is permitted to issue such commands (see
31229 chapter <xref linkend="CHAPACL"/>). The string is split up into separate arguments which
31230 are independently expanded. The expansion variable <varname>$domain</varname> is set to the
31231 argument of the ETRN command, and no syntax checking is done on it. For
31232 example:
31233 </para>
31234 <literallayout class="monospaced">
31235 smtp_etrn_command = /etc/etrn_command $domain \
31236                     $sender_host_address
31237 </literallayout>
31238 <para>
31239 A new process is created to run the command, but Exim does not wait for it to
31240 complete. Consequently, its status cannot be checked. If the command cannot be
31241 run, a line is written to the panic log, but the ETRN caller still receives
31242 a 250 success response. Exim is normally running under its own uid when
31243 receiving SMTP, so it is not possible for it to change the uid before running
31244 the command.
31245 </para>
31246 <para>
31247 <indexterm role="option">
31248 <primary><option>smtp_etrn_serialize</option></primary>
31249 </indexterm>
31250 </para>
31251 <informaltable frame="all">
31252 <tgroup cols="4" colsep="0" rowsep="0">
31253 <colspec colwidth="8*" align="left"/>
31254 <colspec colwidth="6*" align="center"/>
31255 <colspec colwidth="6*" align="center"/>
31256 <colspec colwidth="6*" align="right"/>
31257 <tbody>
31258 <row>
31259 <entry><option>smtp_etrn_serialize</option></entry>
31260 <entry>Use: <emphasis>main</emphasis></entry>
31261 <entry>Type: <emphasis>boolean</emphasis></entry>
31262 <entry>Default: <emphasis>true</emphasis></entry>
31263 </row>
31264 </tbody>
31265 </tgroup>
31266 </informaltable>
31267 <para>
31268 <indexterm role="concept">
31269 <primary>ETRN</primary>
31270 <secondary>serializing</secondary>
31271 </indexterm>
31272 When this option is set, it prevents the simultaneous execution of more than
31273 one identical command as a result of ETRN in an SMTP connection. See
31274 section <xref linkend="SECTETRN"/> for details.
31275 </para>
31276 <para>
31277 <indexterm role="option">
31278 <primary><option>smtp_load_reserve</option></primary>
31279 </indexterm>
31280 </para>
31281 <informaltable frame="all">
31282 <tgroup cols="4" colsep="0" rowsep="0">
31283 <colspec colwidth="8*" align="left"/>
31284 <colspec colwidth="6*" align="center"/>
31285 <colspec colwidth="6*" align="center"/>
31286 <colspec colwidth="6*" align="right"/>
31287 <tbody>
31288 <row>
31289 <entry><option>smtp_load_reserve</option></entry>
31290 <entry>Use: <emphasis>main</emphasis></entry>
31291 <entry>Type: <emphasis>fixed-point</emphasis></entry>
31292 <entry>Default: <emphasis>unset</emphasis></entry>
31293 </row>
31294 </tbody>
31295 </tgroup>
31296 </informaltable>
31297 <para>
31298 <indexterm role="concept">
31299 <primary>load average</primary>
31300 </indexterm>
31301 If the system load average ever gets higher than this, incoming SMTP calls are
31302 accepted only from those hosts that match an entry in <option>smtp_reserve_hosts</option>.
31303 If <option>smtp_reserve_hosts</option> is not set, no incoming SMTP calls are accepted when
31304 the load is over the limit. The option has no effect on ancient operating
31305 systems on which Exim cannot determine the load average. See also
31306 <option>deliver_queue_load_max</option> and <option>queue_only_load</option>.
31307 </para>
31308 <para>
31309 <indexterm role="option">
31310 <primary><option>smtp_max_synprot_errors</option></primary>
31311 </indexterm>
31312 </para>
31313 <informaltable frame="all">
31314 <tgroup cols="4" colsep="0" rowsep="0">
31315 <colspec colwidth="8*" align="left"/>
31316 <colspec colwidth="6*" align="center"/>
31317 <colspec colwidth="6*" align="center"/>
31318 <colspec colwidth="6*" align="right"/>
31319 <tbody>
31320 <row>
31321 <entry><option>smtp_max_synprot_errors</option></entry>
31322 <entry>Use: <emphasis>main</emphasis></entry>
31323 <entry>Type: <emphasis>integer</emphasis></entry>
31324 <entry>Default: <emphasis>3</emphasis></entry>
31325 </row>
31326 </tbody>
31327 </tgroup>
31328 </informaltable>
31329 <para>
31330 <indexterm role="concept">
31331 <primary>SMTP</primary>
31332 <secondary>limiting syntax and protocol errors</secondary>
31333 </indexterm>
31334 <indexterm role="concept">
31335 <primary>limit</primary>
31336 <secondary>SMTP syntax and protocol errors</secondary>
31337 </indexterm>
31338 Exim rejects SMTP commands that contain syntax or protocol errors. In
31339 particular, a syntactically invalid email address, as in this command:
31340 </para>
31341 <literallayout class="monospaced">
31342 RCPT TO:&lt;abc xyz@a.b.c&gt;
31343 </literallayout>
31344 <para>
31345 causes immediate rejection of the command, before any other tests are done.
31346 (The ACL cannot be run if there is no valid address to set up for it.) An
31347 example of a protocol error is receiving RCPT before MAIL. If there are
31348 too many syntax or protocol errors in one SMTP session, the connection is
31349 dropped. The limit is set by this option.
31350 </para>
31351 <para>
31352 <indexterm role="concept">
31353 <primary>PIPELINING</primary>
31354 <secondary>expected errors</secondary>
31355 </indexterm>
31356 When the PIPELINING extension to SMTP is in use, some protocol errors are
31357 <quote>expected</quote>, for instance, a RCPT command after a rejected MAIL command.
31358 Exim assumes that PIPELINING will be used if it advertises it (see
31359 <option>pipelining_advertise_hosts</option>), and in this situation, <quote>expected</quote> errors do
31360 not count towards the limit.
31361 </para>
31362 <para>
31363 <indexterm role="option">
31364 <primary><option>smtp_max_unknown_commands</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>smtp_max_unknown_commands</option></entry>
31376 <entry>Use: <emphasis>main</emphasis></entry>
31377 <entry>Type: <emphasis>integer</emphasis></entry>
31378 <entry>Default: <emphasis>3</emphasis></entry>
31379 </row>
31380 </tbody>
31381 </tgroup>
31382 </informaltable>
31383 <para>
31384 <indexterm role="concept">
31385 <primary>SMTP</primary>
31386 <secondary>limiting unknown commands</secondary>
31387 </indexterm>
31388 <indexterm role="concept">
31389 <primary>limit</primary>
31390 <secondary>unknown SMTP commands</secondary>
31391 </indexterm>
31392 If there are too many unrecognized commands in an incoming SMTP session, an
31393 Exim server drops the connection. This is a defence against some kinds of abuse
31394 that subvert web
31395 clients
31396 into making connections to SMTP ports; in these circumstances, a number of
31397 non-SMTP command lines are sent first.
31398 </para>
31399 <para>
31400 <indexterm role="option">
31401 <primary><option>smtp_ratelimit_hosts</option></primary>
31402 </indexterm>
31403 </para>
31404 <informaltable frame="all">
31405 <tgroup cols="4" colsep="0" rowsep="0">
31406 <colspec colwidth="8*" align="left"/>
31407 <colspec colwidth="6*" align="center"/>
31408 <colspec colwidth="6*" align="center"/>
31409 <colspec colwidth="6*" align="right"/>
31410 <tbody>
31411 <row>
31412 <entry><option>smtp_ratelimit_hosts</option></entry>
31413 <entry>Use: <emphasis>main</emphasis></entry>
31414 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
31415 <entry>Default: <emphasis>unset</emphasis></entry>
31416 </row>
31417 </tbody>
31418 </tgroup>
31419 </informaltable>
31420 <para>
31421 <indexterm role="concept">
31422 <primary>SMTP</primary>
31423 <secondary>rate limiting</secondary>
31424 </indexterm>
31425 <indexterm role="concept">
31426 <primary>limit</primary>
31427 <secondary>rate of message arrival</secondary>
31428 </indexterm>
31429 <indexterm role="concept">
31430 <primary>RCPT</primary>
31431 <secondary>rate limiting</secondary>
31432 </indexterm>
31433 Some sites find it helpful to be able to limit the rate at which certain hosts
31434 can send them messages, and the rate at which an individual message can specify
31435 recipients.
31436 </para>
31437 <para>
31438 Exim has two rate-limiting facilities. This section describes the older
31439 facility, which can limit rates within a single connection. The newer
31440 <option>ratelimit</option> ACL condition can limit rates across all connections. See section
31441 <xref linkend="SECTratelimiting"/> for details of the newer facility.
31442 </para>
31443 <para>
31444 When a host matches <option>smtp_ratelimit_hosts</option>, the values of
31445 <option>smtp_ratelimit_mail</option> and <option>smtp_ratelimit_rcpt</option> are used to control the
31446 rate of acceptance of MAIL and RCPT commands in a single SMTP session,
31447 respectively. Each option, if set, must contain a set of four comma-separated
31448 values:
31449 </para>
31450 <itemizedlist>
31451 <listitem>
31452 <para>
31453 A threshold, before which there is no rate limiting.
31454 </para>
31455 </listitem>
31456 <listitem>
31457 <para>
31458 An initial time delay. Unlike other times in Exim, numbers with decimal
31459 fractional parts are allowed here.
31460 </para>
31461 </listitem>
31462 <listitem>
31463 <para>
31464 A factor by which to increase the delay each time.
31465 </para>
31466 </listitem>
31467 <listitem>
31468 <para>
31469 A maximum value for the delay. This should normally be less than 5 minutes,
31470 because after that time, the client is liable to timeout the SMTP command.
31471 </para>
31472 </listitem>
31473 </itemizedlist>
31474 <para>
31475 For example, these settings have been used successfully at the site which
31476 first suggested this feature, for controlling mail from their customers:
31477 </para>
31478 <literallayout class="monospaced">
31479 smtp_ratelimit_mail = 2,0.5s,1.05,4m
31480 smtp_ratelimit_rcpt = 4,0.25s,1.015,4m
31481 </literallayout>
31482 <para>
31483 The first setting specifies delays that are applied to MAIL commands after
31484 two have been received over a single connection. The initial delay is 0.5
31485 seconds, increasing by a factor of 1.05 each time. The second setting applies
31486 delays to RCPT commands when more than four occur in a single message.
31487 </para>
31488 <para>
31489 <indexterm role="option">
31490 <primary><option>smtp_ratelimit_mail</option></primary>
31491 </indexterm>
31492 </para>
31493 <informaltable frame="all">
31494 <tgroup cols="4" colsep="0" rowsep="0">
31495 <colspec colwidth="8*" align="left"/>
31496 <colspec colwidth="6*" align="center"/>
31497 <colspec colwidth="6*" align="center"/>
31498 <colspec colwidth="6*" align="right"/>
31499 <tbody>
31500 <row>
31501 <entry><option>smtp_ratelimit_mail</option></entry>
31502 <entry>Use: <emphasis>main</emphasis></entry>
31503 <entry>Type: <emphasis>string</emphasis></entry>
31504 <entry>Default: <emphasis>unset</emphasis></entry>
31505 </row>
31506 </tbody>
31507 </tgroup>
31508 </informaltable>
31509 <para>
31510 See <option>smtp_ratelimit_hosts</option> above.
31511 </para>
31512 <para>
31513 <indexterm role="option">
31514 <primary><option>smtp_ratelimit_rcpt</option></primary>
31515 </indexterm>
31516 </para>
31517 <informaltable frame="all">
31518 <tgroup cols="4" colsep="0" rowsep="0">
31519 <colspec colwidth="8*" align="left"/>
31520 <colspec colwidth="6*" align="center"/>
31521 <colspec colwidth="6*" align="center"/>
31522 <colspec colwidth="6*" align="right"/>
31523 <tbody>
31524 <row>
31525 <entry><option>smtp_ratelimit_rcpt</option></entry>
31526 <entry>Use: <emphasis>main</emphasis></entry>
31527 <entry>Type: <emphasis>string</emphasis></entry>
31528 <entry>Default: <emphasis>unset</emphasis></entry>
31529 </row>
31530 </tbody>
31531 </tgroup>
31532 </informaltable>
31533 <para>
31534 See <option>smtp_ratelimit_hosts</option> above.
31535 </para>
31536 <para>
31537 <indexterm role="option">
31538 <primary><option>smtp_receive_timeout</option></primary>
31539 </indexterm>
31540 </para>
31541 <informaltable frame="all">
31542 <tgroup cols="4" colsep="0" rowsep="0">
31543 <colspec colwidth="8*" align="left"/>
31544 <colspec colwidth="6*" align="center"/>
31545 <colspec colwidth="6*" align="center"/>
31546 <colspec colwidth="6*" align="right"/>
31547 <tbody>
31548 <row>
31549 <entry><option>smtp_receive_timeout</option></entry>
31550 <entry>Use: <emphasis>main</emphasis></entry>
31551 <entry>Type: <emphasis>time</emphasis>&dagger;<emphasis></emphasis></entry>
31552 <entry>Default: <emphasis>5m</emphasis></entry>
31553 </row>
31554 </tbody>
31555 </tgroup>
31556 </informaltable>
31557 <para>
31558 <indexterm role="concept">
31559 <primary>timeout</primary>
31560 <secondary>for SMTP input</secondary>
31561 </indexterm>
31562 <indexterm role="concept">
31563 <primary>SMTP</primary>
31564 <secondary>input timeout</secondary>
31565 </indexterm>
31566 This sets a timeout value for SMTP reception. It applies to all forms of SMTP
31567 input, including batch SMTP. If a line of input (either an SMTP command or a
31568 data line) is not received within this time, the SMTP connection is dropped and
31569 the message is abandoned.
31570 A line is written to the log containing one of the following messages:
31571 </para>
31572 <literallayout class="monospaced">
31573 SMTP command timeout on connection from...
31574 SMTP data timeout on connection from...
31575 </literallayout>
31576 <para>
31577 The former means that Exim was expecting to read an SMTP command; the latter
31578 means that it was in the DATA phase, reading the contents of a message.
31579 </para>
31580 <para>
31581 If the first character of the option is a <quote>$</quote> the option is
31582 expanded before use and may depend on
31583 <varname>$sender_host_name</varname>, <varname>$sender_host_address</varname> and <varname>$sender_host_port</varname>.
31584 </para>
31585 <para>
31586 <indexterm role="option">
31587 <primary><option>-os</option></primary>
31588 </indexterm>
31589 The value set by this option can be overridden by the
31590 <option>-os</option> command-line option. A setting of zero time disables the timeout, but
31591 this should never be used for SMTP over TCP/IP. (It can be useful in some cases
31592 of local input using <option>-bs</option> or <option>-bS</option>.) For non-SMTP input, the reception
31593 timeout is controlled by <option>receive_timeout</option> and <option>-or</option>.
31594 </para>
31595 <para>
31596 <indexterm role="option">
31597 <primary><option>smtp_reserve_hosts</option></primary>
31598 </indexterm>
31599 </para>
31600 <informaltable frame="all">
31601 <tgroup cols="4" colsep="0" rowsep="0">
31602 <colspec colwidth="8*" align="left"/>
31603 <colspec colwidth="6*" align="center"/>
31604 <colspec colwidth="6*" align="center"/>
31605 <colspec colwidth="6*" align="right"/>
31606 <tbody>
31607 <row>
31608 <entry><option>smtp_reserve_hosts</option></entry>
31609 <entry>Use: <emphasis>main</emphasis></entry>
31610 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
31611 <entry>Default: <emphasis>unset</emphasis></entry>
31612 </row>
31613 </tbody>
31614 </tgroup>
31615 </informaltable>
31616 <para>
31617 This option defines hosts for which SMTP connections are reserved; see
31618 <option>smtp_accept_reserve</option> and <option>smtp_load_reserve</option> above.
31619 </para>
31620 <para>
31621 <indexterm role="option">
31622 <primary><option>smtp_return_error_details</option></primary>
31623 </indexterm>
31624 </para>
31625 <informaltable frame="all">
31626 <tgroup cols="4" colsep="0" rowsep="0">
31627 <colspec colwidth="8*" align="left"/>
31628 <colspec colwidth="6*" align="center"/>
31629 <colspec colwidth="6*" align="center"/>
31630 <colspec colwidth="6*" align="right"/>
31631 <tbody>
31632 <row>
31633 <entry><option>smtp_return_error_details</option></entry>
31634 <entry>Use: <emphasis>main</emphasis></entry>
31635 <entry>Type: <emphasis>boolean</emphasis></entry>
31636 <entry>Default: <emphasis>false</emphasis></entry>
31637 </row>
31638 </tbody>
31639 </tgroup>
31640 </informaltable>
31641 <para>
31642 <indexterm role="concept">
31643 <primary>SMTP</primary>
31644 <secondary>details policy failures</secondary>
31645 </indexterm>
31646 <indexterm role="concept">
31647 <primary>policy control</primary>
31648 <secondary>rejection, returning details</secondary>
31649 </indexterm>
31650 In the default state, Exim uses bland messages such as
31651 <quote>Administrative prohibition</quote> when it rejects SMTP commands for policy
31652 reasons. Many sysadmins like this because it gives away little information
31653 to spammers. However, some other sysadmins who are applying strict checking
31654 policies want to give out much fuller information about failures. Setting
31655 <option>smtp_return_error_details</option> true causes Exim to be more forthcoming. For
31656 example, instead of <quote>Administrative prohibition</quote>, it might give:
31657 </para>
31658 <literallayout class="monospaced">
31659 550-Rejected after DATA: '&gt;' missing at end of address:
31660 550 failing address in "From" header is: &lt;user@dom.ain
31661 </literallayout>
31662 <para>
31663 <indexterm role="option">
31664 <primary><option>smtputf8_advertise_hosts</option></primary>
31665 </indexterm>
31666 </para>
31667 <informaltable frame="all">
31668 <tgroup cols="4" colsep="0" rowsep="0">
31669 <colspec colwidth="8*" align="left"/>
31670 <colspec colwidth="6*" align="center"/>
31671 <colspec colwidth="6*" align="center"/>
31672 <colspec colwidth="6*" align="right"/>
31673 <tbody>
31674 <row>
31675 <entry><option>smtputf8_advertise_hosts</option></entry>
31676 <entry>Use: <emphasis>main</emphasis></entry>
31677 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
31678 <entry>Default: <emphasis>*</emphasis></entry>
31679 </row>
31680 </tbody>
31681 </tgroup>
31682 </informaltable>
31683 <para>
31684 <indexterm role="concept">
31685 <primary>SMTPUTF8</primary>
31686 <secondary>advertising</secondary>
31687 </indexterm>
31688 When Exim is built with support for internationalised mail names,
31689 the availability thereof is advertised in
31690 response to EHLO only to those client hosts that match this option. See
31691 chapter <xref linkend="CHAPi18n"/> for details of Exim&#x2019;s support for internationalisation.
31692 </para>
31693 <para>
31694 <indexterm role="option">
31695 <primary><option>spamd_address</option></primary>
31696 </indexterm>
31697 </para>
31698 <informaltable frame="all">
31699 <tgroup cols="4" colsep="0" rowsep="0">
31700 <colspec colwidth="8*" align="left"/>
31701 <colspec colwidth="6*" align="center"/>
31702 <colspec colwidth="6*" align="center"/>
31703 <colspec colwidth="6*" align="right"/>
31704 <tbody>
31705 <row>
31706 <entry><option>spamd_address</option></entry>
31707 <entry>Use: <emphasis>main</emphasis></entry>
31708 <entry>Type: <emphasis>string</emphasis></entry>
31709 <entry>Default: <emphasis>127.0.0.1 783</emphasis></entry>
31710 </row>
31711 </tbody>
31712 </tgroup>
31713 </informaltable>
31714 <para>
31715 This option is available when Exim is compiled with the content-scanning
31716 extension. It specifies how Exim connects to SpamAssassin&#x2019;s <option>spamd</option> daemon.
31717 See section <xref linkend="SECTscanspamass"/> for more details.
31718 </para>
31719 <para>
31720 <indexterm role="option">
31721 <primary><option>spf_guess</option></primary>
31722 </indexterm>
31723 </para>
31724 <informaltable frame="all">
31725 <tgroup cols="4" colsep="0" rowsep="0">
31726 <colspec colwidth="8*" align="left"/>
31727 <colspec colwidth="6*" align="center"/>
31728 <colspec colwidth="6*" align="center"/>
31729 <colspec colwidth="6*" align="right"/>
31730 <tbody>
31731 <row>
31732 <entry><option>spf_guess</option></entry>
31733 <entry>Use: <emphasis>main</emphasis></entry>
31734 <entry>Type: <emphasis>string</emphasis></entry>
31735 <entry>Default: <emphasis>v=spf1 a/24 mx/24 ptr ?all</emphasis></entry>
31736 </row>
31737 </tbody>
31738 </tgroup>
31739 </informaltable>
31740 <para>
31741 This option is available when Exim is compiled with SPF support.
31742 See section <xref linkend="SECSPF"/> for more details.
31743 </para>
31744 <para>
31745 <indexterm role="option">
31746 <primary><option>split_spool_directory</option></primary>
31747 </indexterm>
31748 </para>
31749 <informaltable frame="all">
31750 <tgroup cols="4" colsep="0" rowsep="0">
31751 <colspec colwidth="8*" align="left"/>
31752 <colspec colwidth="6*" align="center"/>
31753 <colspec colwidth="6*" align="center"/>
31754 <colspec colwidth="6*" align="right"/>
31755 <tbody>
31756 <row>
31757 <entry><option>split_spool_directory</option></entry>
31758 <entry>Use: <emphasis>main</emphasis></entry>
31759 <entry>Type: <emphasis>boolean</emphasis></entry>
31760 <entry>Default: <emphasis>false</emphasis></entry>
31761 </row>
31762 </tbody>
31763 </tgroup>
31764 </informaltable>
31765 <para>
31766 <indexterm role="concept">
31767 <primary>multiple spool directories</primary>
31768 </indexterm>
31769 <indexterm role="concept">
31770 <primary>spool directory</primary>
31771 <secondary>split</secondary>
31772 </indexterm>
31773 <indexterm role="concept">
31774 <primary>directories, multiple</primary>
31775 </indexterm>
31776 If this option is set, it causes Exim to split its input directory into 62
31777 subdirectories, each with a single alphanumeric character as its name. The
31778 sixth character of the message id is used to allocate messages to
31779 subdirectories; this is the least significant base-62 digit of the time of
31780 arrival of the message.
31781 </para>
31782 <para>
31783 Splitting up the spool in this way may provide better performance on systems
31784 where there are long mail queues, by reducing the number of files in any one
31785 directory. The msglog directory is also split up in a similar way to the input
31786 directory; however, if <option>preserve_message_logs</option> is set, all old msglog files
31787 are still placed in the single directory <filename>msglog.OLD</filename>.
31788 </para>
31789 <para>
31790 It is not necessary to take any special action for existing messages when
31791 changing <option>split_spool_directory</option>. Exim notices messages that are in the
31792 <quote>wrong</quote> place, and continues to process them. If the option is turned off
31793 after a period of being on, the subdirectories will eventually empty and be
31794 automatically deleted.
31795 </para>
31796 <para>
31797 When <option>split_spool_directory</option> is set, the behaviour of queue runner processes
31798 changes. Instead of creating a list of all messages in the queue, and then
31799 trying to deliver each one, in turn, it constructs a list of those in one
31800 sub-directory and tries to deliver them, before moving on to the next
31801 sub-directory. The sub-directories are processed in a random order. This
31802 spreads out the scanning of the input directories, and uses less memory. It is
31803 particularly beneficial when there are lots of messages in the queue. However,
31804 if <option>queue_run_in_order</option> is set, none of this new processing happens. The
31805 entire queue has to be scanned and sorted before any deliveries can start.
31806 </para>
31807 <para>
31808 <indexterm role="option">
31809 <primary><option>spool_directory</option></primary>
31810 </indexterm>
31811 </para>
31812 <informaltable frame="all">
31813 <tgroup cols="4" colsep="0" rowsep="0">
31814 <colspec colwidth="8*" align="left"/>
31815 <colspec colwidth="6*" align="center"/>
31816 <colspec colwidth="6*" align="center"/>
31817 <colspec colwidth="6*" align="right"/>
31818 <tbody>
31819 <row>
31820 <entry><option>spool_directory</option></entry>
31821 <entry>Use: <emphasis>main</emphasis></entry>
31822 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
31823 <entry>Default: <emphasis>set at compile time</emphasis></entry>
31824 </row>
31825 </tbody>
31826 </tgroup>
31827 </informaltable>
31828 <para>
31829 <indexterm role="concept">
31830 <primary>spool directory</primary>
31831 <secondary>path to</secondary>
31832 </indexterm>
31833 This defines the directory in which Exim keeps its spool, that is, the messages
31834 it is waiting to deliver. The default value is taken from the compile-time
31835 configuration setting, if there is one. If not, this option must be set. The
31836 string is expanded, so it can contain, for example, a reference to
31837 <varname>$primary_hostname</varname>.
31838 </para>
31839 <para>
31840 If the spool directory name is fixed on your installation, it is recommended
31841 that you set it at build time rather than from this option, particularly if the
31842 log files are being written to the spool directory (see <option>log_file_path</option>).
31843 Otherwise log files cannot be used for errors that are detected early on, such
31844 as failures in the configuration file.
31845 </para>
31846 <para>
31847 By using this option to override the compiled-in path, it is possible to run
31848 tests of Exim without using the standard spool.
31849 </para>
31850 <para>
31851 <indexterm role="option">
31852 <primary><option>spool_wireformat</option></primary>
31853 </indexterm>
31854 </para>
31855 <informaltable frame="all">
31856 <tgroup cols="4" colsep="0" rowsep="0">
31857 <colspec colwidth="8*" align="left"/>
31858 <colspec colwidth="6*" align="center"/>
31859 <colspec colwidth="6*" align="center"/>
31860 <colspec colwidth="6*" align="right"/>
31861 <tbody>
31862 <row>
31863 <entry><option>spool_wireformat</option></entry>
31864 <entry>Use: <emphasis>main</emphasis></entry>
31865 <entry>Type: <emphasis>boolean</emphasis></entry>
31866 <entry>Default: <emphasis>false</emphasis></entry>
31867 </row>
31868 </tbody>
31869 </tgroup>
31870 </informaltable>
31871 <para>
31872 <indexterm role="concept">
31873 <primary>spool directory</primary>
31874 <secondary>file formats</secondary>
31875 </indexterm>
31876 If this option is set, Exim may for some messages use an alternative format
31877 for data-files in the spool which matches the wire format.
31878 Doing this permits more efficient message reception and transmission.
31879 Currently it is only done for messages received using the ESMTP CHUNKING
31880 option.
31881 </para>
31882 <para>
31883 The following variables will not have useful values:
31884 </para>
31885 <literallayout class="monospaced">
31886 $max_received_linelength
31887 $body_linecount
31888 $body_zerocount
31889 </literallayout>
31890 <para>
31891 Users of the local_scan() API (see <xref linkend="CHAPlocalscan"/>),
31892 and any external programs which are passed a reference to a message data file
31893 (except via the <quote>regex</quote>, <quote>malware</quote> or <quote>spam</quote>) ACL conditions)
31894 will need to be aware of the different formats potentially available.
31895 </para>
31896 <para>
31897 Using any of the ACL conditions noted will negate the reception benefit
31898 (as a Unix-mbox-format file is constructed for them).
31899 The transmission benefit is maintained.
31900 </para>
31901 <para>
31902 <indexterm role="option">
31903 <primary><option>sqlite_lock_timeout</option></primary>
31904 </indexterm>
31905 </para>
31906 <informaltable frame="all">
31907 <tgroup cols="4" colsep="0" rowsep="0">
31908 <colspec colwidth="8*" align="left"/>
31909 <colspec colwidth="6*" align="center"/>
31910 <colspec colwidth="6*" align="center"/>
31911 <colspec colwidth="6*" align="right"/>
31912 <tbody>
31913 <row>
31914 <entry><option>sqlite_lock_timeout</option></entry>
31915 <entry>Use: <emphasis>main</emphasis></entry>
31916 <entry>Type: <emphasis>time</emphasis></entry>
31917 <entry>Default: <emphasis>5s</emphasis></entry>
31918 </row>
31919 </tbody>
31920 </tgroup>
31921 </informaltable>
31922 <para>
31923 <indexterm role="concept">
31924 <primary>sqlite lookup type</primary>
31925 <secondary>lock timeout</secondary>
31926 </indexterm>
31927 This option controls the timeout that the <command>sqlite</command> lookup uses when trying to
31928 access an SQLite database. See section <xref linkend="SECTsqlite"/> for more details.
31929 </para>
31930 <para>
31931 <indexterm role="option">
31932 <primary><option>strict_acl_vars</option></primary>
31933 </indexterm>
31934 </para>
31935 <informaltable frame="all">
31936 <tgroup cols="4" colsep="0" rowsep="0">
31937 <colspec colwidth="8*" align="left"/>
31938 <colspec colwidth="6*" align="center"/>
31939 <colspec colwidth="6*" align="center"/>
31940 <colspec colwidth="6*" align="right"/>
31941 <tbody>
31942 <row>
31943 <entry><option>strict_acl_vars</option></entry>
31944 <entry>Use: <emphasis>main</emphasis></entry>
31945 <entry>Type: <emphasis>boolean</emphasis></entry>
31946 <entry>Default: <emphasis>false</emphasis></entry>
31947 </row>
31948 </tbody>
31949 </tgroup>
31950 </informaltable>
31951 <para>
31952 <indexterm role="concept">
31953 <primary>access control lists (ACLs)</primary>
31954 <secondary>variables, handling unset</secondary>
31955 </indexterm>
31956 This option controls what happens if a syntactically valid but undefined ACL
31957 variable is referenced. If it is false (the default), an empty string
31958 is substituted; if it is true, an error is generated. See section
31959 <xref linkend="SECTaclvariables"/> for details of ACL variables.
31960 </para>
31961 <para>
31962 <indexterm role="option">
31963 <primary><option>strip_excess_angle_brackets</option></primary>
31964 </indexterm>
31965 </para>
31966 <informaltable frame="all">
31967 <tgroup cols="4" colsep="0" rowsep="0">
31968 <colspec colwidth="8*" align="left"/>
31969 <colspec colwidth="6*" align="center"/>
31970 <colspec colwidth="6*" align="center"/>
31971 <colspec colwidth="6*" align="right"/>
31972 <tbody>
31973 <row>
31974 <entry><option>strip_excess_angle_brackets</option></entry>
31975 <entry>Use: <emphasis>main</emphasis></entry>
31976 <entry>Type: <emphasis>boolean</emphasis></entry>
31977 <entry>Default: <emphasis>false</emphasis></entry>
31978 </row>
31979 </tbody>
31980 </tgroup>
31981 </informaltable>
31982 <para>
31983 <indexterm role="concept">
31984 <primary>angle brackets, excess</primary>
31985 </indexterm>
31986 If this option is set, redundant pairs of angle brackets round <quote>route-addr</quote>
31987 items in addresses are stripped. For example, <emphasis>&lt;&lt;xxx@a.b.c.d&gt;&gt;</emphasis> is
31988 treated as <emphasis>&lt;xxx@a.b.c.d&gt;</emphasis>. If this is in the envelope and the message is
31989 passed on to another MTA, the excess angle brackets are not passed on. If this
31990 option is not set, multiple pairs of angle brackets cause a syntax error.
31991 </para>
31992 <para>
31993 <indexterm role="option">
31994 <primary><option>strip_trailing_dot</option></primary>
31995 </indexterm>
31996 </para>
31997 <informaltable frame="all">
31998 <tgroup cols="4" colsep="0" rowsep="0">
31999 <colspec colwidth="8*" align="left"/>
32000 <colspec colwidth="6*" align="center"/>
32001 <colspec colwidth="6*" align="center"/>
32002 <colspec colwidth="6*" align="right"/>
32003 <tbody>
32004 <row>
32005 <entry><option>strip_trailing_dot</option></entry>
32006 <entry>Use: <emphasis>main</emphasis></entry>
32007 <entry>Type: <emphasis>boolean</emphasis></entry>
32008 <entry>Default: <emphasis>false</emphasis></entry>
32009 </row>
32010 </tbody>
32011 </tgroup>
32012 </informaltable>
32013 <para>
32014 <indexterm role="concept">
32015 <primary>trailing dot on domain</primary>
32016 </indexterm>
32017 <indexterm role="concept">
32018 <primary>dot</primary>
32019 <secondary>trailing on domain</secondary>
32020 </indexterm>
32021 If this option is set, a trailing dot at the end of a domain in an address is
32022 ignored. If this is in the envelope and the message is passed on to another
32023 MTA, the dot is not passed on. If this option is not set, a dot at the end of a
32024 domain causes a syntax error.
32025 However, addresses in header lines are checked only when an ACL requests header
32026 syntax checking.
32027 </para>
32028 <para>
32029 <indexterm role="option">
32030 <primary><option>syslog_duplication</option></primary>
32031 </indexterm>
32032 </para>
32033 <informaltable frame="all">
32034 <tgroup cols="4" colsep="0" rowsep="0">
32035 <colspec colwidth="8*" align="left"/>
32036 <colspec colwidth="6*" align="center"/>
32037 <colspec colwidth="6*" align="center"/>
32038 <colspec colwidth="6*" align="right"/>
32039 <tbody>
32040 <row>
32041 <entry><option>syslog_duplication</option></entry>
32042 <entry>Use: <emphasis>main</emphasis></entry>
32043 <entry>Type: <emphasis>boolean</emphasis></entry>
32044 <entry>Default: <emphasis>true</emphasis></entry>
32045 </row>
32046 </tbody>
32047 </tgroup>
32048 </informaltable>
32049 <para>
32050 <indexterm role="concept">
32051 <primary>syslog</primary>
32052 <secondary>duplicate log lines; suppressing</secondary>
32053 </indexterm>
32054 When Exim is logging to syslog, it writes the log lines for its three
32055 separate logs at different syslog priorities so that they can in principle
32056 be separated on the logging hosts. Some installations do not require this
32057 separation, and in those cases, the duplication of certain log lines is a
32058 nuisance. If <option>syslog_duplication</option> is set false, only one copy of any
32059 particular log line is written to syslog. For lines that normally go to
32060 both the main log and the reject log, the reject log version (possibly
32061 containing message header lines) is written, at LOG_NOTICE priority.
32062 Lines that normally go to both the main and the panic log are written at
32063 the LOG_ALERT priority.
32064 </para>
32065 <para>
32066 <indexterm role="option">
32067 <primary><option>syslog_facility</option></primary>
32068 </indexterm>
32069 </para>
32070 <informaltable frame="all">
32071 <tgroup cols="4" colsep="0" rowsep="0">
32072 <colspec colwidth="8*" align="left"/>
32073 <colspec colwidth="6*" align="center"/>
32074 <colspec colwidth="6*" align="center"/>
32075 <colspec colwidth="6*" align="right"/>
32076 <tbody>
32077 <row>
32078 <entry><option>syslog_facility</option></entry>
32079 <entry>Use: <emphasis>main</emphasis></entry>
32080 <entry>Type: <emphasis>string</emphasis></entry>
32081 <entry>Default: <emphasis>unset</emphasis></entry>
32082 </row>
32083 </tbody>
32084 </tgroup>
32085 </informaltable>
32086 <para>
32087 <indexterm role="concept">
32088 <primary>syslog</primary>
32089 <secondary>facility; setting</secondary>
32090 </indexterm>
32091 This option sets the syslog <quote>facility</quote> name, used when Exim is logging to
32092 syslog. The value must be one of the strings <quote>mail</quote>, <quote>user</quote>, <quote>news</quote>,
32093 <quote>uucp</quote>, <quote>daemon</quote>, or <quote>local<emphasis>x</emphasis></quote> where <emphasis>x</emphasis> is a digit between 0 and 7.
32094 If this option is unset, <quote>mail</quote> is used. See chapter <xref linkend="CHAPlog"/> for
32095 details of Exim&#x2019;s logging.
32096 </para>
32097 <para>
32098 <indexterm role="option">
32099 <primary><option>syslog_pid</option></primary>
32100 </indexterm>
32101 </para>
32102 <informaltable frame="all">
32103 <tgroup cols="4" colsep="0" rowsep="0">
32104 <colspec colwidth="8*" align="left"/>
32105 <colspec colwidth="6*" align="center"/>
32106 <colspec colwidth="6*" align="center"/>
32107 <colspec colwidth="6*" align="right"/>
32108 <tbody>
32109 <row>
32110 <entry><option>syslog_pid</option></entry>
32111 <entry>Use: <emphasis>main</emphasis></entry>
32112 <entry>Type: <emphasis>boolean</emphasis></entry>
32113 <entry>Default: <emphasis>true</emphasis></entry>
32114 </row>
32115 </tbody>
32116 </tgroup>
32117 </informaltable>
32118 <para>
32119 <indexterm role="concept">
32120 <primary>syslog</primary>
32121 <secondary>pid</secondary>
32122 </indexterm>
32123 If <option>syslog_pid</option> is set false, the PID on Exim&#x2019;s log lines are
32124 omitted when these lines are sent to syslog. (Syslog normally prefixes
32125 the log lines with the PID of the logging process automatically.) You need
32126 to enable the <literal>+pid</literal> log selector item, if you want Exim to write it&#x2019;s PID
32127 into the logs.) See chapter <xref linkend="CHAPlog"/> for details of Exim&#x2019;s logging.
32128 </para>
32129 <para>
32130 <indexterm role="option">
32131 <primary><option>syslog_processname</option></primary>
32132 </indexterm>
32133 </para>
32134 <informaltable frame="all">
32135 <tgroup cols="4" colsep="0" rowsep="0">
32136 <colspec colwidth="8*" align="left"/>
32137 <colspec colwidth="6*" align="center"/>
32138 <colspec colwidth="6*" align="center"/>
32139 <colspec colwidth="6*" align="right"/>
32140 <tbody>
32141 <row>
32142 <entry><option>syslog_processname</option></entry>
32143 <entry>Use: <emphasis>main</emphasis></entry>
32144 <entry>Type: <emphasis>string</emphasis></entry>
32145 <entry>Default: <emphasis><literal>exim</literal></emphasis></entry>
32146 </row>
32147 </tbody>
32148 </tgroup>
32149 </informaltable>
32150 <para>
32151 <indexterm role="concept">
32152 <primary>syslog</primary>
32153 <secondary>process name; setting</secondary>
32154 </indexterm>
32155 This option sets the syslog <quote>ident</quote> name, used when Exim is logging to
32156 syslog. The value must be no longer than 32 characters. See chapter
32157 <xref linkend="CHAPlog"/> for details of Exim&#x2019;s logging.
32158 </para>
32159 <para>
32160 <indexterm role="option">
32161 <primary><option>syslog_timestamp</option></primary>
32162 </indexterm>
32163 </para>
32164 <informaltable frame="all">
32165 <tgroup cols="4" colsep="0" rowsep="0">
32166 <colspec colwidth="8*" align="left"/>
32167 <colspec colwidth="6*" align="center"/>
32168 <colspec colwidth="6*" align="center"/>
32169 <colspec colwidth="6*" align="right"/>
32170 <tbody>
32171 <row>
32172 <entry><option>syslog_timestamp</option></entry>
32173 <entry>Use: <emphasis>main</emphasis></entry>
32174 <entry>Type: <emphasis>boolean</emphasis></entry>
32175 <entry>Default: <emphasis>true</emphasis></entry>
32176 </row>
32177 </tbody>
32178 </tgroup>
32179 </informaltable>
32180 <para>
32181 <indexterm role="concept">
32182 <primary>syslog</primary>
32183 <secondary>timestamps</secondary>
32184 </indexterm>
32185 If <option>syslog_timestamp</option> is set false, the timestamps on Exim&#x2019;s log lines are
32186 omitted when these lines are sent to syslog. See chapter <xref linkend="CHAPlog"/> for
32187 details of Exim&#x2019;s logging.
32188 </para>
32189 <para>
32190 <indexterm role="option">
32191 <primary><option>system_filter</option></primary>
32192 </indexterm>
32193 </para>
32194 <informaltable frame="all">
32195 <tgroup cols="4" colsep="0" rowsep="0">
32196 <colspec colwidth="8*" align="left"/>
32197 <colspec colwidth="6*" align="center"/>
32198 <colspec colwidth="6*" align="center"/>
32199 <colspec colwidth="6*" align="right"/>
32200 <tbody>
32201 <row>
32202 <entry><option>system_filter</option></entry>
32203 <entry>Use: <emphasis>main</emphasis></entry>
32204 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32205 <entry>Default: <emphasis>unset</emphasis></entry>
32206 </row>
32207 </tbody>
32208 </tgroup>
32209 </informaltable>
32210 <para>
32211 <indexterm role="concept">
32212 <primary>filter</primary>
32213 <secondary>system filter</secondary>
32214 </indexterm>
32215 <indexterm role="concept">
32216 <primary>system filter</primary>
32217 <secondary>specifying</secondary>
32218 </indexterm>
32219 <indexterm role="concept">
32220 <primary>Sieve filter</primary>
32221 <secondary>not available for system filter</secondary>
32222 </indexterm>
32223 This option specifies an Exim filter file that is applied to all messages at
32224 the start of each delivery attempt, before any routing is done. System filters
32225 must be Exim filters; they cannot be Sieve filters. If the system filter
32226 generates any deliveries to files or pipes, or any new mail messages, the
32227 appropriate <option>system_filter_..._transport</option> option(s) must be set, to define
32228 which transports are to be used. Details of this facility are given in chapter
32229 <xref linkend="CHAPsystemfilter"/>.
32230 A forced expansion failure results in no filter operation.
32231 </para>
32232 <para>
32233 <indexterm role="option">
32234 <primary><option>system_filter_directory_transport</option></primary>
32235 </indexterm>
32236 </para>
32237 <informaltable frame="all">
32238 <tgroup cols="4" colsep="0" rowsep="0">
32239 <colspec colwidth="8*" align="left"/>
32240 <colspec colwidth="6*" align="center"/>
32241 <colspec colwidth="6*" align="center"/>
32242 <colspec colwidth="6*" align="right"/>
32243 <tbody>
32244 <row>
32245 <entry><option>system_filter_directory_transport</option></entry>
32246 <entry>Use: <emphasis>main</emphasis></entry>
32247 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32248 <entry>Default: <emphasis>unset</emphasis></entry>
32249 </row>
32250 </tbody>
32251 </tgroup>
32252 </informaltable>
32253 <para>
32254 <indexterm role="variable">
32255 <primary><varname>$address_file</varname></primary>
32256 </indexterm>
32257 This sets the name of the transport driver that is to be used when the
32258 <option>save</option> command in a system message filter specifies a path ending in <quote>/</quote>,
32259 implying delivery of each message into a separate file in some directory.
32260 During the delivery, the variable <varname>$address_file</varname> contains the path name.
32261 </para>
32262 <para>
32263 <indexterm role="option">
32264 <primary><option>system_filter_file_transport</option></primary>
32265 </indexterm>
32266 </para>
32267 <informaltable frame="all">
32268 <tgroup cols="4" colsep="0" rowsep="0">
32269 <colspec colwidth="8*" align="left"/>
32270 <colspec colwidth="6*" align="center"/>
32271 <colspec colwidth="6*" align="center"/>
32272 <colspec colwidth="6*" align="right"/>
32273 <tbody>
32274 <row>
32275 <entry><option>system_filter_file_transport</option></entry>
32276 <entry>Use: <emphasis>main</emphasis></entry>
32277 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32278 <entry>Default: <emphasis>unset</emphasis></entry>
32279 </row>
32280 </tbody>
32281 </tgroup>
32282 </informaltable>
32283 <para>
32284 <indexterm role="concept">
32285 <primary>file</primary>
32286 <secondary>transport for system filter</secondary>
32287 </indexterm>
32288 This sets the name of the transport driver that is to be used when the <option>save</option>
32289 command in a system message filter specifies a path not ending in <quote>/</quote>. During
32290 the delivery, the variable <varname>$address_file</varname> contains the path name.
32291 </para>
32292 <para>
32293 <indexterm role="option">
32294 <primary><option>system_filter_group</option></primary>
32295 </indexterm>
32296 </para>
32297 <informaltable frame="all">
32298 <tgroup cols="4" colsep="0" rowsep="0">
32299 <colspec colwidth="8*" align="left"/>
32300 <colspec colwidth="6*" align="center"/>
32301 <colspec colwidth="6*" align="center"/>
32302 <colspec colwidth="6*" align="right"/>
32303 <tbody>
32304 <row>
32305 <entry><option>system_filter_group</option></entry>
32306 <entry>Use: <emphasis>main</emphasis></entry>
32307 <entry>Type: <emphasis>string</emphasis></entry>
32308 <entry>Default: <emphasis>unset</emphasis></entry>
32309 </row>
32310 </tbody>
32311 </tgroup>
32312 </informaltable>
32313 <para>
32314 <indexterm role="concept">
32315 <primary>gid (group id)</primary>
32316 <secondary>system filter</secondary>
32317 </indexterm>
32318 This option is used only when <option>system_filter_user</option> is also set. It sets the
32319 gid under which the system filter is run, overriding any gid that is associated
32320 with the user. The value may be numerical or symbolic.
32321 </para>
32322 <para>
32323 <indexterm role="option">
32324 <primary><option>system_filter_pipe_transport</option></primary>
32325 </indexterm>
32326 </para>
32327 <informaltable frame="all">
32328 <tgroup cols="4" colsep="0" rowsep="0">
32329 <colspec colwidth="8*" align="left"/>
32330 <colspec colwidth="6*" align="center"/>
32331 <colspec colwidth="6*" align="center"/>
32332 <colspec colwidth="6*" align="right"/>
32333 <tbody>
32334 <row>
32335 <entry><option>system_filter_pipe_transport</option></entry>
32336 <entry>Use: <emphasis>main</emphasis></entry>
32337 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32338 <entry>Default: <emphasis>unset</emphasis></entry>
32339 </row>
32340 </tbody>
32341 </tgroup>
32342 </informaltable>
32343 <para>
32344 <indexterm role="concept">
32345 <primary><command>pipe</command> transport</primary>
32346 <secondary>for system filter</secondary>
32347 </indexterm>
32348 <indexterm role="variable">
32349 <primary><varname>$address_pipe</varname></primary>
32350 </indexterm>
32351 This specifies the transport driver that is to be used when a <option>pipe</option> command
32352 is used in a system filter. During the delivery, the variable <varname>$address_pipe</varname>
32353 contains the pipe command.
32354 </para>
32355 <para>
32356 <indexterm role="option">
32357 <primary><option>system_filter_reply_transport</option></primary>
32358 </indexterm>
32359 </para>
32360 <informaltable frame="all">
32361 <tgroup cols="4" colsep="0" rowsep="0">
32362 <colspec colwidth="8*" align="left"/>
32363 <colspec colwidth="6*" align="center"/>
32364 <colspec colwidth="6*" align="center"/>
32365 <colspec colwidth="6*" align="right"/>
32366 <tbody>
32367 <row>
32368 <entry><option>system_filter_reply_transport</option></entry>
32369 <entry>Use: <emphasis>main</emphasis></entry>
32370 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32371 <entry>Default: <emphasis>unset</emphasis></entry>
32372 </row>
32373 </tbody>
32374 </tgroup>
32375 </informaltable>
32376 <para>
32377 <indexterm role="concept">
32378 <primary><command>autoreply</command> transport</primary>
32379 <secondary>for system filter</secondary>
32380 </indexterm>
32381 This specifies the transport driver that is to be used when a <option>mail</option> command
32382 is used in a system filter.
32383 </para>
32384 <para>
32385 <indexterm role="option">
32386 <primary><option>system_filter_user</option></primary>
32387 </indexterm>
32388 </para>
32389 <informaltable frame="all">
32390 <tgroup cols="4" colsep="0" rowsep="0">
32391 <colspec colwidth="8*" align="left"/>
32392 <colspec colwidth="6*" align="center"/>
32393 <colspec colwidth="6*" align="center"/>
32394 <colspec colwidth="6*" align="right"/>
32395 <tbody>
32396 <row>
32397 <entry><option>system_filter_user</option></entry>
32398 <entry>Use: <emphasis>main</emphasis></entry>
32399 <entry>Type: <emphasis>string</emphasis></entry>
32400 <entry>Default: <emphasis>unset</emphasis></entry>
32401 </row>
32402 </tbody>
32403 </tgroup>
32404 </informaltable>
32405 <para>
32406 <indexterm role="concept">
32407 <primary>uid (user id)</primary>
32408 <secondary>system filter</secondary>
32409 </indexterm>
32410 If this option is set to root, the system filter is run in the main Exim
32411 delivery process, as root.  Otherwise, the system filter runs in a separate
32412 process, as the given user, defaulting to the Exim run-time user.
32413 Unless the string consists entirely of digits, it
32414 is looked up in the password data. Failure to find the named user causes a
32415 configuration error. The gid is either taken from the password data, or
32416 specified by <option>system_filter_group</option>. When the uid is specified numerically,
32417 <option>system_filter_group</option> is required to be set.
32418 </para>
32419 <para>
32420 If the system filter generates any pipe, file, or reply deliveries, the uid
32421 under which the filter is run is used when transporting them, unless a
32422 transport option overrides.
32423 </para>
32424 <para>
32425 <indexterm role="option">
32426 <primary><option>tcp_nodelay</option></primary>
32427 </indexterm>
32428 </para>
32429 <informaltable frame="all">
32430 <tgroup cols="4" colsep="0" rowsep="0">
32431 <colspec colwidth="8*" align="left"/>
32432 <colspec colwidth="6*" align="center"/>
32433 <colspec colwidth="6*" align="center"/>
32434 <colspec colwidth="6*" align="right"/>
32435 <tbody>
32436 <row>
32437 <entry><option>tcp_nodelay</option></entry>
32438 <entry>Use: <emphasis>main</emphasis></entry>
32439 <entry>Type: <emphasis>boolean</emphasis></entry>
32440 <entry>Default: <emphasis>true</emphasis></entry>
32441 </row>
32442 </tbody>
32443 </tgroup>
32444 </informaltable>
32445 <para>
32446 <indexterm role="concept">
32447 <primary>daemon</primary>
32448 <secondary>TCP_NODELAY on sockets</secondary>
32449 </indexterm>
32450 <indexterm role="concept">
32451 <primary>Nagle algorithm</primary>
32452 </indexterm>
32453 <indexterm role="concept">
32454 <primary>TCP_NODELAY on listening sockets</primary>
32455 </indexterm>
32456 If this option is set false, it stops the Exim daemon setting the
32457 TCP_NODELAY option on its listening sockets. Setting TCP_NODELAY
32458 turns off the <quote>Nagle algorithm</quote>, which is a way of improving network
32459 performance in interactive (character-by-character) situations. Turning it off
32460 should improve Exim&#x2019;s performance a bit, so that is what happens by default.
32461 However, it appears that some broken clients cannot cope, and time out. Hence
32462 this option. It affects only those sockets that are set up for listening by the
32463 daemon. Sockets created by the smtp transport for delivering mail always set
32464 TCP_NODELAY.
32465 </para>
32466 <para>
32467 <indexterm role="option">
32468 <primary><option>timeout_frozen_after</option></primary>
32469 </indexterm>
32470 </para>
32471 <informaltable frame="all">
32472 <tgroup cols="4" colsep="0" rowsep="0">
32473 <colspec colwidth="8*" align="left"/>
32474 <colspec colwidth="6*" align="center"/>
32475 <colspec colwidth="6*" align="center"/>
32476 <colspec colwidth="6*" align="right"/>
32477 <tbody>
32478 <row>
32479 <entry><option>timeout_frozen_after</option></entry>
32480 <entry>Use: <emphasis>main</emphasis></entry>
32481 <entry>Type: <emphasis>time</emphasis></entry>
32482 <entry>Default: <emphasis>0s</emphasis></entry>
32483 </row>
32484 </tbody>
32485 </tgroup>
32486 </informaltable>
32487 <para>
32488 <indexterm role="concept">
32489 <primary>frozen messages</primary>
32490 <secondary>timing out</secondary>
32491 </indexterm>
32492 <indexterm role="concept">
32493 <primary>timeout</primary>
32494 <secondary>frozen messages</secondary>
32495 </indexterm>
32496 If <option>timeout_frozen_after</option> is set to a time greater than zero, a frozen
32497 message of any kind that has been in the queue for longer than the given time
32498 is automatically cancelled at the next queue run. If the frozen message is a
32499 bounce message, it is just discarded; otherwise, a bounce is sent to the
32500 sender, in a similar manner to cancellation by the <option>-Mg</option> command line option.
32501 If you want to timeout frozen bounce messages earlier than other kinds of
32502 frozen message, see <option>ignore_bounce_errors_after</option>.
32503 </para>
32504 <para>
32505 <emphasis role="bold">Note:</emphasis> the default value of zero means no timeouts; with this setting,
32506 frozen messages remain in the queue forever (except for any frozen bounce
32507 messages that are released by <option>ignore_bounce_errors_after</option>).
32508 </para>
32509 <para>
32510 <indexterm role="option">
32511 <primary><option>timezone</option></primary>
32512 </indexterm>
32513 </para>
32514 <informaltable frame="all">
32515 <tgroup cols="4" colsep="0" rowsep="0">
32516 <colspec colwidth="8*" align="left"/>
32517 <colspec colwidth="6*" align="center"/>
32518 <colspec colwidth="6*" align="center"/>
32519 <colspec colwidth="6*" align="right"/>
32520 <tbody>
32521 <row>
32522 <entry><option>timezone</option></entry>
32523 <entry>Use: <emphasis>main</emphasis></entry>
32524 <entry>Type: <emphasis>string</emphasis></entry>
32525 <entry>Default: <emphasis>unset</emphasis></entry>
32526 </row>
32527 </tbody>
32528 </tgroup>
32529 </informaltable>
32530 <para>
32531 <indexterm role="concept">
32532 <primary>timezone, setting</primary>
32533 </indexterm>
32534 <indexterm role="concept">
32535 <primary>environment</primary>
32536 <secondary>values from</secondary>
32537 </indexterm>
32538 The value of <option>timezone</option> is used to set the environment variable TZ while
32539 running Exim (if it is different on entry). This ensures that all timestamps
32540 created by Exim are in the required timezone. If you want all your timestamps
32541 to be in UTC (aka GMT) you should set
32542 </para>
32543 <literallayout class="monospaced">
32544 timezone = UTC
32545 </literallayout>
32546 <para>
32547 The default value is taken from TIMEZONE_DEFAULT in <filename>Local/Makefile</filename>,
32548 or, if that is not set, from the value of the TZ environment variable when Exim
32549 is built. If <option>timezone</option> is set to the empty string, either at build or run
32550 time, any existing TZ variable is removed from the environment when Exim
32551 runs. This is appropriate behaviour for obtaining wall-clock time on some, but
32552 unfortunately not all, operating systems.
32553 </para>
32554 <para>
32555 <indexterm role="option">
32556 <primary><option>tls_advertise_hosts</option></primary>
32557 </indexterm>
32558 </para>
32559 <informaltable frame="all">
32560 <tgroup cols="4" colsep="0" rowsep="0">
32561 <colspec colwidth="8*" align="left"/>
32562 <colspec colwidth="6*" align="center"/>
32563 <colspec colwidth="6*" align="center"/>
32564 <colspec colwidth="6*" align="right"/>
32565 <tbody>
32566 <row>
32567 <entry><option>tls_advertise_hosts</option></entry>
32568 <entry>Use: <emphasis>main</emphasis></entry>
32569 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
32570 <entry>Default: <emphasis>*</emphasis></entry>
32571 </row>
32572 </tbody>
32573 </tgroup>
32574 </informaltable>
32575 <para>
32576 <indexterm role="concept">
32577 <primary>TLS</primary>
32578 <secondary>advertising</secondary>
32579 </indexterm>
32580 <indexterm role="concept">
32581 <primary>encryption</primary>
32582 <secondary>on SMTP connection</secondary>
32583 </indexterm>
32584 <indexterm role="concept">
32585 <primary>SMTP</primary>
32586 <secondary>encrypted connection</secondary>
32587 </indexterm>
32588 When Exim is built with support for TLS encrypted connections, the availability
32589 of the STARTTLS command to set up an encrypted session is advertised in
32590 response to EHLO only to those client hosts that match this option. See
32591 chapter <xref linkend="CHAPTLS"/> for details of Exim&#x2019;s support for TLS.
32592 Note that the default value requires that a certificate be supplied
32593 using the <option>tls_certificate</option> option.  If TLS support for incoming connections
32594 is not required the <option>tls_advertise_hosts</option> option should be set empty.
32595 </para>
32596 <para>
32597 <indexterm role="option">
32598 <primary><option>unset</option></primary>
32599 </indexterm>
32600 </para>
32601 <informaltable frame="all">
32602 <tgroup cols="4" colsep="0" rowsep="0">
32603 <colspec colwidth="8*" align="left"/>
32604 <colspec colwidth="6*" align="center"/>
32605 <colspec colwidth="6*" align="center"/>
32606 <colspec colwidth="6*" align="right"/>
32607 <tbody>
32608 <row>
32609 <entry><option>tls_certificate</option></entry>
32610 <entry>Use: <emphasis>main</emphasis></entry>
32611 <entry>Type: <emphasis>string</emphasis></entry>
32612 <entry>Default: <emphasis>list</emphasis>&dagger;<emphasis></emphasis></entry>
32613 </row>
32614 </tbody>
32615 </tgroup>
32616 </informaltable>
32617 <para>
32618 <indexterm role="concept">
32619 <primary>TLS</primary>
32620 <secondary>server certificate; location of</secondary>
32621 </indexterm>
32622 <indexterm role="concept">
32623 <primary>certificate</primary>
32624 <secondary>server, location of</secondary>
32625 </indexterm>
32626 The value of this option is expanded, and must then be a list of absolute paths to
32627 files which contain the server&#x2019;s certificates (in PEM format).
32628 Commonly only one file is needed.
32629 The server&#x2019;s private key is also
32630 assumed to be in this file if <option>tls_privatekey</option> is unset. See chapter
32631 <xref linkend="CHAPTLS"/> for further details.
32632 </para>
32633 <para>
32634 <emphasis role="bold">Note</emphasis>: The certificates defined by this option are used only when Exim is
32635 receiving incoming messages as a server. If you want to supply certificates for
32636 use when sending messages as a client, you must set the <option>tls_certificate</option>
32637 option in the relevant <command>smtp</command> transport.
32638 </para>
32639 <para>
32640 <emphasis role="bold">Note</emphasis>: If you use filenames based on IP addresses, change the list
32641 separator in the usual way (<xref linkend="SECTlistsepchange"/>) to avoid confusion under IPv6.
32642 </para>
32643 <para>
32644 <emphasis role="bold">Note</emphasis>: Under versions of OpenSSL preceding 1.1.1,
32645 when a list of more than one
32646 file is used, the <varname>$tls_in_ourcert</varname> variable is unreliable.
32647 </para>
32648 <para revisionflag="changed">
32649 The macro "_TLS_BAD_MULTICERT_IN_OURCERT" will be defined for those versions.
32650 </para>
32651 <para>
32652 If the option contains <varname>$tls_out_sni</varname> and Exim is built against OpenSSL, then
32653 if the OpenSSL build supports TLS extensions and the TLS client sends the
32654 Server Name Indication extension, then this option and others documented in
32655 <xref linkend="SECTtlssni"/> will be re-expanded.
32656 </para>
32657 <para>
32658 If this option is unset or empty a fresh self-signed certificate will be
32659 generated for every connection.
32660 </para>
32661 <para>
32662 <indexterm role="option">
32663 <primary><option>tls_crl</option></primary>
32664 </indexterm>
32665 </para>
32666 <informaltable frame="all">
32667 <tgroup cols="4" colsep="0" rowsep="0">
32668 <colspec colwidth="8*" align="left"/>
32669 <colspec colwidth="6*" align="center"/>
32670 <colspec colwidth="6*" align="center"/>
32671 <colspec colwidth="6*" align="right"/>
32672 <tbody>
32673 <row>
32674 <entry><option>tls_crl</option></entry>
32675 <entry>Use: <emphasis>main</emphasis></entry>
32676 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32677 <entry>Default: <emphasis>unset</emphasis></entry>
32678 </row>
32679 </tbody>
32680 </tgroup>
32681 </informaltable>
32682 <para>
32683 <indexterm role="concept">
32684 <primary>TLS</primary>
32685 <secondary>server certificate revocation list</secondary>
32686 </indexterm>
32687 <indexterm role="concept">
32688 <primary>certificate</primary>
32689 <secondary>revocation list for server</secondary>
32690 </indexterm>
32691 This option specifies a certificate revocation list. The expanded value must
32692 be the name of a file that contains CRLs in PEM format.
32693 </para>
32694 <para>
32695 Under OpenSSL the option can specify a directory with CRL files.
32696 </para>
32697 <para>
32698 <emphasis role="bold">Note:</emphasis> Under OpenSSL the option must, if given, supply a CRL
32699 for each signing element of the certificate chain (i.e. all but the leaf).
32700 For the file variant this can be multiple PEM blocks in the one file.
32701 </para>
32702 <para>
32703 See <xref linkend="SECTtlssni"/> for discussion of when this option might be re-expanded.
32704 </para>
32705 <para>
32706 <indexterm role="option">
32707 <primary><option>tls_dh_max_bits</option></primary>
32708 </indexterm>
32709 </para>
32710 <informaltable frame="all">
32711 <tgroup cols="4" colsep="0" rowsep="0">
32712 <colspec colwidth="8*" align="left"/>
32713 <colspec colwidth="6*" align="center"/>
32714 <colspec colwidth="6*" align="center"/>
32715 <colspec colwidth="6*" align="right"/>
32716 <tbody>
32717 <row>
32718 <entry><option>tls_dh_max_bits</option></entry>
32719 <entry>Use: <emphasis>main</emphasis></entry>
32720 <entry>Type: <emphasis>integer</emphasis></entry>
32721 <entry>Default: <emphasis>2236</emphasis></entry>
32722 </row>
32723 </tbody>
32724 </tgroup>
32725 </informaltable>
32726 <para>
32727 <indexterm role="concept">
32728 <primary>TLS</primary>
32729 <secondary>D-H bit count</secondary>
32730 </indexterm>
32731 The number of bits used for Diffie-Hellman key-exchange may be suggested by
32732 the chosen TLS library.  That value might prove to be too high for
32733 interoperability.  This option provides a maximum clamp on the value
32734 suggested, trading off security for interoperability.
32735 </para>
32736 <para>
32737 The value must be at least 1024.
32738 </para>
32739 <para>
32740 The value 2236 was chosen because, at time of adding the option, it was the
32741 hard-coded maximum value supported by the NSS cryptographic library, as used
32742 by Thunderbird, while GnuTLS was suggesting 2432 bits as normal.
32743 </para>
32744 <para>
32745 If you prefer more security and are willing to break some clients, raise this
32746 number.
32747 </para>
32748 <para>
32749 Note that the value passed to GnuTLS for *generating* a new prime may be a
32750 little less than this figure, because GnuTLS is inexact and may produce a
32751 larger prime than requested.
32752 </para>
32753 <para>
32754 <indexterm role="option">
32755 <primary><option>tls_dhparam</option></primary>
32756 </indexterm>
32757 </para>
32758 <informaltable frame="all">
32759 <tgroup cols="4" colsep="0" rowsep="0">
32760 <colspec colwidth="8*" align="left"/>
32761 <colspec colwidth="6*" align="center"/>
32762 <colspec colwidth="6*" align="center"/>
32763 <colspec colwidth="6*" align="right"/>
32764 <tbody>
32765 <row>
32766 <entry><option>tls_dhparam</option></entry>
32767 <entry>Use: <emphasis>main</emphasis></entry>
32768 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32769 <entry>Default: <emphasis>unset</emphasis></entry>
32770 </row>
32771 </tbody>
32772 </tgroup>
32773 </informaltable>
32774 <para>
32775 <indexterm role="concept">
32776 <primary>TLS</primary>
32777 <secondary>D-H parameters for server</secondary>
32778 </indexterm>
32779 The value of this option is expanded and indicates the source of DH parameters
32780 to be used by Exim.
32781 </para>
32782 <para revisionflag="changed">
32783 This option is ignored for GnuTLS version 3.6.0 and later.
32784 The library manages parameter negotiation internally.
32785 </para>
32786 <para>
32787 <emphasis role="bold">Note: The Exim Maintainers strongly recommend,
32788 for other TLS library versions,
32789 using a filename with site-generated
32790 local DH parameters</emphasis>, which has been supported across all versions of Exim.  The
32791 other specific constants available are a fallback so that even when
32792 "unconfigured", Exim can offer Perfect Forward Secrecy in older ciphersuites in TLS.
32793 </para>
32794 <para>
32795 If <option>tls_dhparam</option> is a filename starting with a <literal>/</literal>,
32796 then it names a file from which DH
32797 parameters should be loaded.  If the file exists, it should hold a PEM-encoded
32798 PKCS#3 representation of the DH prime.  If the file does not exist, for
32799 OpenSSL it is an error.  For GnuTLS, Exim will attempt to create the file and
32800 fill it with a generated DH prime.  For OpenSSL, if the DH bit-count from
32801 loading the file is greater than <option>tls_dh_max_bits</option> then it will be ignored,
32802 and treated as though the <option>tls_dhparam</option> were set to "none".
32803 </para>
32804 <para>
32805 If this option expands to the string "none", then no DH parameters will be
32806 loaded by Exim.
32807 </para>
32808 <para>
32809 If this option expands to the string "historic" and Exim is using GnuTLS, then
32810 Exim will attempt to load a file from inside the spool directory.  If the file
32811 does not exist, Exim will attempt to create it.
32812 See section <xref linkend="SECTgnutlsparam"/> for further details.
32813 </para>
32814 <para>
32815 If Exim is using OpenSSL and this option is empty or unset, then Exim will load
32816 a default DH prime; the default is Exim-specific but lacks verifiable provenance.
32817 </para>
32818 <para>
32819 In older versions of Exim the default was the 2048 bit prime described in section
32820 2.2 of RFC 5114, "2048-bit MODP Group with 224-bit Prime Order Subgroup", which
32821 in IKE is assigned number 23.
32822 </para>
32823 <para>
32824 Otherwise, the option must expand to the name used by Exim for any of a number
32825 of DH primes specified in RFC 2409, RFC 3526, RFC 5114, RFC 7919, or from other
32826 sources.  As names, Exim uses a standard specified name, else "ike" followed by
32827 the number used by IKE, or "default" which corresponds to
32828 <literal>exim.dev.20160529.3</literal>.
32829 </para>
32830 <para>
32831 The available standard primes are:
32832 <literal>ffdhe2048</literal>, <literal>ffdhe3072</literal>, <literal>ffdhe4096</literal>, <literal>ffdhe6144</literal>, <literal>ffdhe8192</literal>,
32833 <literal>ike1</literal>, <literal>ike2</literal>, <literal>ike5</literal>,
32834 <literal>ike14</literal>, <literal>ike15</literal>, <literal>ike16</literal>, <literal>ike17</literal>, <literal>ike18</literal>,
32835 <literal>ike22</literal>, <literal>ike23</literal> and <literal>ike24</literal>.
32836 </para>
32837 <para>
32838 The available additional primes are:
32839 <literal>exim.dev.20160529.1</literal>, <literal>exim.dev.20160529.2</literal> and <literal>exim.dev.20160529.3</literal>.
32840 </para>
32841 <para>
32842 Some of these will be too small to be accepted by clients.
32843 Some may be too large to be accepted by clients.
32844 The open cryptographic community has suspicions about the integrity of some
32845 of the later IKE values, which led into RFC7919 providing new fixed constants
32846 (the "ffdhe" identifiers).
32847 </para>
32848 <para>
32849 At this point, all of the "ike" values should be considered obsolete;
32850 they&#x2019;re still in Exim to avoid breaking unusual configurations, but are
32851 candidates for removal the next time we have backwards-incompatible changes.
32852 </para>
32853 <para>
32854 The TLS protocol does not negotiate an acceptable size for this; clients tend
32855 to hard-drop connections if what is offered by the server is unacceptable,
32856 whether too large or too small, and there&#x2019;s no provision for the client to
32857 tell the server what these constraints are.  Thus, as a server operator, you
32858 need to make an educated guess as to what is most likely to work for your
32859 userbase.
32860 </para>
32861 <para>
32862 Some known size constraints suggest that a bit-size in the range 2048 to 2236
32863 is most likely to maximise interoperability.  The upper bound comes from
32864 applications using the Mozilla Network Security Services (NSS) library, which
32865 used to set its <literal>DH_MAX_P_BITS</literal> upper-bound to 2236.  This affects many
32866 mail user agents (MUAs). The lower bound comes from Debian installs of Exim4
32867 prior to the 4.80 release, as Debian used to patch Exim to raise the minimum
32868 acceptable bound from 1024 to 2048.
32869 </para>
32870 <para>
32871 <indexterm role="option">
32872 <primary><option>tls_eccurve</option></primary>
32873 </indexterm>
32874 </para>
32875 <informaltable frame="all">
32876 <tgroup cols="4" colsep="0" rowsep="0">
32877 <colspec colwidth="8*" align="left"/>
32878 <colspec colwidth="6*" align="center"/>
32879 <colspec colwidth="6*" align="center"/>
32880 <colspec colwidth="6*" align="right"/>
32881 <tbody>
32882 <row>
32883 <entry><option>tls_eccurve</option></entry>
32884 <entry>Use: <emphasis>main</emphasis></entry>
32885 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32886 <entry>Default: <emphasis><literal>auto</literal></emphasis></entry>
32887 </row>
32888 </tbody>
32889 </tgroup>
32890 </informaltable>
32891 <para>
32892 <indexterm role="concept">
32893 <primary>TLS</primary>
32894 <secondary>EC cryptography</secondary>
32895 </indexterm>
32896 This option selects a EC curve for use by Exim when used with OpenSSL.
32897 It has no effect when Exim is used with GnuTLS.
32898 </para>
32899 <para>
32900 After expansion it must contain a valid EC curve parameter, such as
32901 <literal>prime256v1</literal>, <literal>secp384r1</literal>, or <literal>P-512</literal>. Consult your OpenSSL manual
32902 for valid selections.
32903 </para>
32904 <para>
32905 For OpenSSL versions before (and not including) 1.0.2, the string
32906 <literal>auto</literal> selects <literal>prime256v1</literal>. For more recent OpenSSL versions
32907 <literal>auto</literal> tells the library to choose.
32908 </para>
32909 <para>
32910 If the option expands to an empty string, no EC curves will be enabled.
32911 </para>
32912 <para>
32913 <indexterm role="option">
32914 <primary><option>tls_ocsp_file</option></primary>
32915 </indexterm>
32916 </para>
32917 <informaltable frame="all">
32918 <tgroup cols="4" colsep="0" rowsep="0">
32919 <colspec colwidth="8*" align="left"/>
32920 <colspec colwidth="6*" align="center"/>
32921 <colspec colwidth="6*" align="center"/>
32922 <colspec colwidth="6*" align="right"/>
32923 <tbody>
32924 <row>
32925 <entry><option>tls_ocsp_file</option></entry>
32926 <entry>Use: <emphasis>main</emphasis></entry>
32927 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32928 <entry>Default: <emphasis>unset</emphasis></entry>
32929 </row>
32930 </tbody>
32931 </tgroup>
32932 </informaltable>
32933 <para>
32934 <indexterm role="concept">
32935 <primary>TLS</primary>
32936 <secondary>certificate status</secondary>
32937 </indexterm>
32938 <indexterm role="concept">
32939 <primary>TLS</primary>
32940 <secondary>OCSP proof file</secondary>
32941 </indexterm>
32942 This option
32943 must if set expand to the absolute path to a file which contains a current
32944 status proof for the server&#x2019;s certificate, as obtained from the
32945 Certificate Authority.
32946 </para>
32947 <para>
32948 Usable for GnuTLS 3.4.4 or 3.3.17 or OpenSSL 1.1.0 (or later).
32949 </para>
32950 <para revisionflag="changed">
32951 The macro "_HAVE_TLS_OCSP" will be defined for those versions.
32952 </para>
32953 <para revisionflag="changed">
32954 For OpenSSL 1.1.0 or later, and
32955 </para>
32956 <para>
32957 for GnuTLS 3.5.6 or later the expanded value of this option can be a list
32958 of files, to match a list given for the <option>tls_certificate</option> option.
32959 The ordering of the two lists must match.
32960 </para>
32961 <para revisionflag="changed">
32962 The macro "_HAVE_TLS_OCSP_LIST" will be defined for those versions.
32963 </para>
32964 <para revisionflag="changed">
32965 The file(s) should be in DER format,
32966 except for GnuTLS 3.6.3 or later
32967 or for OpenSSL,
32968 when an optional filetype prefix can be used.
32969 The prefix must be one of "DER" or "PEM", followed by
32970 a single space.  If one is used it sets the format for subsequent
32971 files in the list; the initial format is DER.
32972 If multiple proofs are wanted, for multiple chain elements
32973 (this only works under TLS1.3)
32974 they must be coded as a combined OCSP response.
32975 </para>
32976 <para revisionflag="changed">
32977 Although GnuTLS will accept PEM files with multiple separate
32978 PEM blobs (ie. separate OCSP responses), it sends them in the
32979 TLS Certificate record interleaved with the certificates of the chain;
32980 although a GnuTLS client is happy with that, an OpenSSL client is not.
32981 </para>
32982 <para>
32983 <indexterm role="option">
32984 <primary><option>tls_on_connect_ports</option></primary>
32985 </indexterm>
32986 </para>
32987 <informaltable frame="all">
32988 <tgroup cols="4" colsep="0" rowsep="0">
32989 <colspec colwidth="8*" align="left"/>
32990 <colspec colwidth="6*" align="center"/>
32991 <colspec colwidth="6*" align="center"/>
32992 <colspec colwidth="6*" align="right"/>
32993 <tbody>
32994 <row>
32995 <entry><option>tls_on_connect_ports</option></entry>
32996 <entry>Use: <emphasis>main</emphasis></entry>
32997 <entry>Type: <emphasis>string list</emphasis></entry>
32998 <entry>Default: <emphasis>unset</emphasis></entry>
32999 </row>
33000 </tbody>
33001 </tgroup>
33002 </informaltable>
33003 <para>
33004 <indexterm role="concept">
33005 <primary>SSMTP</primary>
33006 </indexterm>
33007 <indexterm role="concept">
33008 <primary>SMTPS</primary>
33009 </indexterm>
33010 This option specifies a list of incoming SSMTP (aka SMTPS) ports that should
33011 operate the SSMTP (SMTPS) protocol, where a TLS session is immediately
33012 set up without waiting for the client to issue a STARTTLS command. For
33013 further details, see section <xref linkend="SECTsupobssmt"/>.
33014 </para>
33015 <para>
33016 <indexterm role="option">
33017 <primary><option>unset</option></primary>
33018 </indexterm>
33019 </para>
33020 <informaltable frame="all">
33021 <tgroup cols="4" colsep="0" rowsep="0">
33022 <colspec colwidth="8*" align="left"/>
33023 <colspec colwidth="6*" align="center"/>
33024 <colspec colwidth="6*" align="center"/>
33025 <colspec colwidth="6*" align="right"/>
33026 <tbody>
33027 <row>
33028 <entry><option>tls_privatekey</option></entry>
33029 <entry>Use: <emphasis>main</emphasis></entry>
33030 <entry>Type: <emphasis>string</emphasis></entry>
33031 <entry>Default: <emphasis>list</emphasis>&dagger;<emphasis></emphasis></entry>
33032 </row>
33033 </tbody>
33034 </tgroup>
33035 </informaltable>
33036 <para>
33037 <indexterm role="concept">
33038 <primary>TLS</primary>
33039 <secondary>server private key; location of</secondary>
33040 </indexterm>
33041 The value of this option is expanded, and must then be a list of absolute paths to
33042 files which contains the server&#x2019;s private keys.
33043 If this option is unset, or if
33044 the expansion is forced to fail, or the result is an empty string, the private
33045 key is assumed to be in the same file as the server&#x2019;s certificates. See chapter
33046 <xref linkend="CHAPTLS"/> for further details.
33047 </para>
33048 <para>
33049 See <xref linkend="SECTtlssni"/> for discussion of when this option might be re-expanded.
33050 </para>
33051 <para>
33052 <indexterm role="option">
33053 <primary><option>tls_remember_esmtp</option></primary>
33054 </indexterm>
33055 </para>
33056 <informaltable frame="all">
33057 <tgroup cols="4" colsep="0" rowsep="0">
33058 <colspec colwidth="8*" align="left"/>
33059 <colspec colwidth="6*" align="center"/>
33060 <colspec colwidth="6*" align="center"/>
33061 <colspec colwidth="6*" align="right"/>
33062 <tbody>
33063 <row>
33064 <entry><option>tls_remember_esmtp</option></entry>
33065 <entry>Use: <emphasis>main</emphasis></entry>
33066 <entry>Type: <emphasis>boolean</emphasis></entry>
33067 <entry>Default: <emphasis>false</emphasis></entry>
33068 </row>
33069 </tbody>
33070 </tgroup>
33071 </informaltable>
33072 <para>
33073 <indexterm role="concept">
33074 <primary>TLS</primary>
33075 <secondary>esmtp state; remembering</secondary>
33076 </indexterm>
33077 <indexterm role="concept">
33078 <primary>TLS</primary>
33079 <secondary>broken clients</secondary>
33080 </indexterm>
33081 If this option is set true, Exim violates the RFCs by remembering that it is in
33082 <quote>esmtp</quote> state after successfully negotiating a TLS session. This provides
33083 support for broken clients that fail to send a new EHLO after starting a
33084 TLS session.
33085 </para>
33086 <para>
33087 <indexterm role="option">
33088 <primary><option>tls_require_ciphers</option></primary>
33089 </indexterm>
33090 </para>
33091 <informaltable frame="all">
33092 <tgroup cols="4" colsep="0" rowsep="0">
33093 <colspec colwidth="8*" align="left"/>
33094 <colspec colwidth="6*" align="center"/>
33095 <colspec colwidth="6*" align="center"/>
33096 <colspec colwidth="6*" align="right"/>
33097 <tbody>
33098 <row>
33099 <entry><option>tls_require_ciphers</option></entry>
33100 <entry>Use: <emphasis>main</emphasis></entry>
33101 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33102 <entry>Default: <emphasis>unset</emphasis></entry>
33103 </row>
33104 </tbody>
33105 </tgroup>
33106 </informaltable>
33107 <para>
33108 <indexterm role="concept">
33109 <primary>TLS</primary>
33110 <secondary>requiring specific ciphers</secondary>
33111 </indexterm>
33112 <indexterm role="concept">
33113 <primary>cipher</primary>
33114 <secondary>requiring specific</secondary>
33115 </indexterm>
33116 This option controls which ciphers can be used for incoming TLS connections.
33117 The <command>smtp</command> transport has an option of the same name for controlling outgoing
33118 connections. This option is expanded for each connection, so can be varied for
33119 different clients if required. The value of this option must be a list of
33120 permitted cipher suites. The OpenSSL and GnuTLS libraries handle cipher control
33121 in somewhat different ways. If GnuTLS is being used, the client controls the
33122 preference order of the available ciphers. Details are given in sections
33123 <xref linkend="SECTreqciphssl"/> and <xref linkend="SECTreqciphgnu"/>.
33124 </para>
33125 <para>
33126 <indexterm role="option">
33127 <primary><option>tls_try_verify_hosts</option></primary>
33128 </indexterm>
33129 </para>
33130 <informaltable frame="all">
33131 <tgroup cols="4" colsep="0" rowsep="0">
33132 <colspec colwidth="8*" align="left"/>
33133 <colspec colwidth="6*" align="center"/>
33134 <colspec colwidth="6*" align="center"/>
33135 <colspec colwidth="6*" align="right"/>
33136 <tbody>
33137 <row>
33138 <entry><option>tls_try_verify_hosts</option></entry>
33139 <entry>Use: <emphasis>main</emphasis></entry>
33140 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
33141 <entry>Default: <emphasis>unset</emphasis></entry>
33142 </row>
33143 </tbody>
33144 </tgroup>
33145 </informaltable>
33146 <para>
33147 <indexterm role="concept">
33148 <primary>TLS</primary>
33149 <secondary>client certificate verification</secondary>
33150 </indexterm>
33151 <indexterm role="concept">
33152 <primary>certificate</primary>
33153 <secondary>verification of client</secondary>
33154 </indexterm>
33155 See <option>tls_verify_hosts</option> below.
33156 </para>
33157 <para>
33158 <indexterm role="option">
33159 <primary><option>tls_verify_certificates</option></primary>
33160 </indexterm>
33161 </para>
33162 <informaltable frame="all">
33163 <tgroup cols="4" colsep="0" rowsep="0">
33164 <colspec colwidth="8*" align="left"/>
33165 <colspec colwidth="6*" align="center"/>
33166 <colspec colwidth="6*" align="center"/>
33167 <colspec colwidth="6*" align="right"/>
33168 <tbody>
33169 <row>
33170 <entry><option>tls_verify_certificates</option></entry>
33171 <entry>Use: <emphasis>main</emphasis></entry>
33172 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33173 <entry>Default: <emphasis>system</emphasis></entry>
33174 </row>
33175 </tbody>
33176 </tgroup>
33177 </informaltable>
33178 <para>
33179 <indexterm role="concept">
33180 <primary>TLS</primary>
33181 <secondary>client certificate verification</secondary>
33182 </indexterm>
33183 <indexterm role="concept">
33184 <primary>certificate</primary>
33185 <secondary>verification of client</secondary>
33186 </indexterm>
33187 The value of this option is expanded, and must then be either the
33188 word "system"
33189 or the absolute path to
33190 a file or directory containing permitted certificates for clients that
33191 match <option>tls_verify_hosts</option> or <option>tls_try_verify_hosts</option>.
33192 </para>
33193 <para>
33194 The "system" value for the option will use a
33195 system default location compiled into the SSL library.
33196 This is not available for GnuTLS versions preceding 3.0.20,
33197 and will be taken as empty; an explicit location
33198 must be specified.
33199 </para>
33200 <para>
33201 The use of a directory for the option value is not available for GnuTLS versions
33202 preceding 3.3.6 and a single file must be used.
33203 </para>
33204 <para>
33205 With OpenSSL the certificates specified
33206 explicitly
33207 either by file or directory
33208 are added to those given by the system default location.
33209 </para>
33210 <para>
33211 These certificates should be for the certificate authorities trusted, rather
33212 than the public cert of individual clients.  With both OpenSSL and GnuTLS, if
33213 the value is a file then the certificates are sent by Exim as a server to
33214 connecting clients, defining the list of accepted certificate authorities.
33215 Thus the values defined should be considered public data.  To avoid this,
33216 use the explicit directory version.
33217 </para>
33218 <para>
33219 See <xref linkend="SECTtlssni"/> for discussion of when this option might be re-expanded.
33220 </para>
33221 <para>
33222 A forced expansion failure or setting to an empty string is equivalent to
33223 being unset.
33224 </para>
33225 <para>
33226 <indexterm role="option">
33227 <primary><option>tls_verify_hosts</option></primary>
33228 </indexterm>
33229 </para>
33230 <informaltable frame="all">
33231 <tgroup cols="4" colsep="0" rowsep="0">
33232 <colspec colwidth="8*" align="left"/>
33233 <colspec colwidth="6*" align="center"/>
33234 <colspec colwidth="6*" align="center"/>
33235 <colspec colwidth="6*" align="right"/>
33236 <tbody>
33237 <row>
33238 <entry><option>tls_verify_hosts</option></entry>
33239 <entry>Use: <emphasis>main</emphasis></entry>
33240 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
33241 <entry>Default: <emphasis>unset</emphasis></entry>
33242 </row>
33243 </tbody>
33244 </tgroup>
33245 </informaltable>
33246 <para>
33247 <indexterm role="concept">
33248 <primary>TLS</primary>
33249 <secondary>client certificate verification</secondary>
33250 </indexterm>
33251 <indexterm role="concept">
33252 <primary>certificate</primary>
33253 <secondary>verification of client</secondary>
33254 </indexterm>
33255 This option, along with <option>tls_try_verify_hosts</option>, controls the checking of
33256 certificates from clients. The expected certificates are defined by
33257 <option>tls_verify_certificates</option>, which must be set. A configuration error occurs if
33258 either <option>tls_verify_hosts</option> or <option>tls_try_verify_hosts</option> is set and
33259 <option>tls_verify_certificates</option> is not set.
33260 </para>
33261 <para>
33262 Any client that matches <option>tls_verify_hosts</option> is constrained by
33263 <option>tls_verify_certificates</option>. When the client initiates a TLS session, it must
33264 present one of the listed certificates. If it does not, the connection is
33265 aborted. <emphasis role="bold">Warning</emphasis>: Including a host in <option>tls_verify_hosts</option> does not require
33266 the host to use TLS. It can still send SMTP commands through unencrypted
33267 connections. Forcing a client to use TLS has to be done separately using an
33268 ACL to reject inappropriate commands when the connection is not encrypted.
33269 </para>
33270 <para>
33271 A weaker form of checking is provided by <option>tls_try_verify_hosts</option>. If a client
33272 matches this option (but not <option>tls_verify_hosts</option>), Exim requests a
33273 certificate and checks it against <option>tls_verify_certificates</option>, but does not
33274 abort the connection if there is no certificate or if it does not match. This
33275 state can be detected in an ACL, which makes it possible to implement policies
33276 such as <quote>accept for relay only if a verified certificate has been received,
33277 but accept for local delivery if encrypted, even without a verified
33278 certificate</quote>.
33279 </para>
33280 <para>
33281 Client hosts that match neither of these lists are not asked to present
33282 certificates.
33283 </para>
33284 <para>
33285 <indexterm role="option">
33286 <primary><option>trusted_groups</option></primary>
33287 </indexterm>
33288 </para>
33289 <informaltable frame="all">
33290 <tgroup cols="4" colsep="0" rowsep="0">
33291 <colspec colwidth="8*" align="left"/>
33292 <colspec colwidth="6*" align="center"/>
33293 <colspec colwidth="6*" align="center"/>
33294 <colspec colwidth="6*" align="right"/>
33295 <tbody>
33296 <row>
33297 <entry><option>trusted_groups</option></entry>
33298 <entry>Use: <emphasis>main</emphasis></entry>
33299 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
33300 <entry>Default: <emphasis>unset</emphasis></entry>
33301 </row>
33302 </tbody>
33303 </tgroup>
33304 </informaltable>
33305 <para>
33306 <indexterm role="concept">
33307 <primary>trusted groups</primary>
33308 </indexterm>
33309 <indexterm role="concept">
33310 <primary>groups</primary>
33311 <secondary>trusted</secondary>
33312 </indexterm>
33313 This option is expanded just once, at the start of Exim&#x2019;s processing. If this
33314 option is set, any process that is running in one of the listed groups, or
33315 which has one of them as a supplementary group, is trusted. The groups can be
33316 specified numerically or by name. See section <xref linkend="SECTtrustedadmin"/> for
33317 details of what trusted callers are permitted to do. If neither
33318 <option>trusted_groups</option> nor <option>trusted_users</option> is set, only root and the Exim user
33319 are trusted.
33320 </para>
33321 <para>
33322 <indexterm role="option">
33323 <primary><option>trusted_users</option></primary>
33324 </indexterm>
33325 </para>
33326 <informaltable frame="all">
33327 <tgroup cols="4" colsep="0" rowsep="0">
33328 <colspec colwidth="8*" align="left"/>
33329 <colspec colwidth="6*" align="center"/>
33330 <colspec colwidth="6*" align="center"/>
33331 <colspec colwidth="6*" align="right"/>
33332 <tbody>
33333 <row>
33334 <entry><option>trusted_users</option></entry>
33335 <entry>Use: <emphasis>main</emphasis></entry>
33336 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
33337 <entry>Default: <emphasis>unset</emphasis></entry>
33338 </row>
33339 </tbody>
33340 </tgroup>
33341 </informaltable>
33342 <para>
33343 <indexterm role="concept">
33344 <primary>trusted users</primary>
33345 </indexterm>
33346 <indexterm role="concept">
33347 <primary>user</primary>
33348 <secondary>trusted</secondary>
33349 </indexterm>
33350 This option is expanded just once, at the start of Exim&#x2019;s processing. If this
33351 option is set, any process that is running as one of the listed users is
33352 trusted. The users can be specified numerically or by name. See section
33353 <xref linkend="SECTtrustedadmin"/> for details of what trusted callers are permitted to do.
33354 If neither <option>trusted_groups</option> nor <option>trusted_users</option> is set, only root and the
33355 Exim user are trusted.
33356 </para>
33357 <para>
33358 <indexterm role="option">
33359 <primary><option>unknown_login</option></primary>
33360 </indexterm>
33361 </para>
33362 <informaltable frame="all">
33363 <tgroup cols="4" colsep="0" rowsep="0">
33364 <colspec colwidth="8*" align="left"/>
33365 <colspec colwidth="6*" align="center"/>
33366 <colspec colwidth="6*" align="center"/>
33367 <colspec colwidth="6*" align="right"/>
33368 <tbody>
33369 <row>
33370 <entry><option>unknown_login</option></entry>
33371 <entry>Use: <emphasis>main</emphasis></entry>
33372 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33373 <entry>Default: <emphasis>unset</emphasis></entry>
33374 </row>
33375 </tbody>
33376 </tgroup>
33377 </informaltable>
33378 <para>
33379 <indexterm role="concept">
33380 <primary>uid (user id)</primary>
33381 <secondary>unknown caller</secondary>
33382 </indexterm>
33383 <indexterm role="variable">
33384 <primary><varname>$caller_uid</varname></primary>
33385 </indexterm>
33386 This is a specialized feature for use in unusual configurations. By default, if
33387 the uid of the caller of Exim cannot be looked up using <function>getpwuid()</function>, Exim
33388 gives up. The <option>unknown_login</option> option can be used to set a login name to be
33389 used in this circumstance. It is expanded, so values like <option>user$caller_uid</option>
33390 can be set. When <option>unknown_login</option> is used, the value of <option>unknown_username</option>
33391 is used for the user&#x2019;s real name (gecos field), unless this has been set by the
33392 <option>-F</option> option.
33393 </para>
33394 <para>
33395 <indexterm role="option">
33396 <primary><option>unknown_username</option></primary>
33397 </indexterm>
33398 </para>
33399 <informaltable frame="all">
33400 <tgroup cols="4" colsep="0" rowsep="0">
33401 <colspec colwidth="8*" align="left"/>
33402 <colspec colwidth="6*" align="center"/>
33403 <colspec colwidth="6*" align="center"/>
33404 <colspec colwidth="6*" align="right"/>
33405 <tbody>
33406 <row>
33407 <entry><option>unknown_username</option></entry>
33408 <entry>Use: <emphasis>main</emphasis></entry>
33409 <entry>Type: <emphasis>string</emphasis></entry>
33410 <entry>Default: <emphasis>unset</emphasis></entry>
33411 </row>
33412 </tbody>
33413 </tgroup>
33414 </informaltable>
33415 <para>
33416 See <option>unknown_login</option>.
33417 </para>
33418 <para>
33419 <indexterm role="option">
33420 <primary><option>untrusted_set_sender</option></primary>
33421 </indexterm>
33422 </para>
33423 <informaltable frame="all">
33424 <tgroup cols="4" colsep="0" rowsep="0">
33425 <colspec colwidth="8*" align="left"/>
33426 <colspec colwidth="6*" align="center"/>
33427 <colspec colwidth="6*" align="center"/>
33428 <colspec colwidth="6*" align="right"/>
33429 <tbody>
33430 <row>
33431 <entry><option>untrusted_set_sender</option></entry>
33432 <entry>Use: <emphasis>main</emphasis></entry>
33433 <entry>Type: <emphasis>address list</emphasis>&dagger;<emphasis></emphasis></entry>
33434 <entry>Default: <emphasis>unset</emphasis></entry>
33435 </row>
33436 </tbody>
33437 </tgroup>
33438 </informaltable>
33439 <para>
33440 <indexterm role="concept">
33441 <primary>trusted users</primary>
33442 </indexterm>
33443 <indexterm role="concept">
33444 <primary>sender</primary>
33445 <secondary>setting by untrusted user</secondary>
33446 </indexterm>
33447 <indexterm role="concept">
33448 <primary>untrusted user setting sender</primary>
33449 </indexterm>
33450 <indexterm role="concept">
33451 <primary>user</primary>
33452 <secondary>untrusted setting sender</secondary>
33453 </indexterm>
33454 <indexterm role="concept">
33455 <primary>envelope from</primary>
33456 </indexterm>
33457 <indexterm role="concept">
33458 <primary>envelope sender</primary>
33459 </indexterm>
33460 When an untrusted user submits a message to Exim using the standard input, Exim
33461 normally creates an envelope sender address from the user&#x2019;s login and the
33462 default qualification domain. Data from the <option>-f</option> option (for setting envelope
33463 senders on non-SMTP messages) or the SMTP MAIL command (if <option>-bs</option> or <option>-bS</option>
33464 is used) is ignored.
33465 </para>
33466 <para>
33467 However, untrusted users are permitted to set an empty envelope sender address,
33468 to declare that a message should never generate any bounces. For example:
33469 </para>
33470 <literallayout class="monospaced">
33471 exim -f '&lt;&gt;' user@domain.example
33472 </literallayout>
33473 <para>
33474 <indexterm role="variable">
33475 <primary><varname>$sender_ident</varname></primary>
33476 </indexterm>
33477 The <option>untrusted_set_sender</option> option allows you to permit untrusted users to set
33478 other envelope sender addresses in a controlled way. When it is set, untrusted
33479 users are allowed to set envelope sender addresses that match any of the
33480 patterns in the list. Like all address lists, the string is expanded. The
33481 identity of the user is in <varname>$sender_ident</varname>, so you can, for example, restrict
33482 users to setting senders that start with their login ids
33483 followed by a hyphen
33484 by a setting like this:
33485 </para>
33486 <literallayout class="monospaced">
33487 untrusted_set_sender = ^$sender_ident-
33488 </literallayout>
33489 <para>
33490 If you want to allow untrusted users to set envelope sender addresses without
33491 restriction, you can use
33492 </para>
33493 <literallayout class="monospaced">
33494 untrusted_set_sender = *
33495 </literallayout>
33496 <para>
33497 The <option>untrusted_set_sender</option> option applies to all forms of local input, but
33498 only to the setting of the envelope sender. It does not permit untrusted users
33499 to use the other options which trusted user can use to override message
33500 parameters. Furthermore, it does not stop Exim from removing an existing
33501 <emphasis>Sender:</emphasis> header in the message, or from adding a <emphasis>Sender:</emphasis> header if
33502 necessary. See <option>local_sender_retain</option> and <option>local_from_check</option> for ways of
33503 overriding these actions. The handling of the <emphasis>Sender:</emphasis> header is also
33504 described in section <xref linkend="SECTthesenhea"/>.
33505 </para>
33506 <para>
33507 The log line for a message&#x2019;s arrival shows the envelope sender following
33508 <quote>&lt;=</quote>. For local messages, the user&#x2019;s login always follows, after <quote>U=</quote>. In
33509 <option>-bp</option> displays, and in the Exim monitor, if an untrusted user sets an
33510 envelope sender address, the user&#x2019;s login is shown in parentheses after the
33511 sender address.
33512 </para>
33513 <para>
33514 <indexterm role="option">
33515 <primary><option>uucp_from_pattern</option></primary>
33516 </indexterm>
33517 </para>
33518 <informaltable frame="all">
33519 <tgroup cols="4" colsep="0" rowsep="0">
33520 <colspec colwidth="8*" align="left"/>
33521 <colspec colwidth="6*" align="center"/>
33522 <colspec colwidth="6*" align="center"/>
33523 <colspec colwidth="6*" align="right"/>
33524 <tbody>
33525 <row>
33526 <entry><option>uucp_from_pattern</option></entry>
33527 <entry>Use: <emphasis>main</emphasis></entry>
33528 <entry>Type: <emphasis>string</emphasis></entry>
33529 <entry>Default: <emphasis>see below</emphasis></entry>
33530 </row>
33531 </tbody>
33532 </tgroup>
33533 </informaltable>
33534 <para>
33535 <indexterm role="concept">
33536 <primary><quote>From</quote> line</primary>
33537 </indexterm>
33538 <indexterm role="concept">
33539 <primary>UUCP</primary>
33540 <secondary><quote>From</quote> line</secondary>
33541 </indexterm>
33542 Some applications that pass messages to an MTA via a command line interface use
33543 an initial line starting with <quote>From&nbsp;</quote> to pass the envelope sender. In
33544 particular, this is used by UUCP software. Exim recognizes such a line by means
33545 of a regular expression that is set in <option>uucp_from_pattern</option>. When the pattern
33546 matches, the sender address is constructed by expanding the contents of
33547 <option>uucp_from_sender</option>, provided that the caller of Exim is a trusted user. The
33548 default pattern recognizes lines in the following two forms:
33549 </para>
33550 <literallayout class="monospaced">
33551 From ph10 Fri Jan  5 12:35 GMT 1996
33552 From ph10 Fri, 7 Jan 97 14:00:00 GMT
33553 </literallayout>
33554 <para>
33555 The pattern can be seen by running
33556 </para>
33557 <literallayout class="monospaced">
33558 exim -bP uucp_from_pattern
33559 </literallayout>
33560 <para>
33561 It checks only up to the hours and minutes, and allows for a 2-digit or 4-digit
33562 year in the second case. The first word after <quote>From&nbsp;</quote> is matched in the
33563 regular expression by a parenthesized subpattern. The default value for
33564 <option>uucp_from_sender</option> is <quote>$1</quote>, which therefore just uses this first word
33565 (<quote>ph10</quote> in the example above) as the message&#x2019;s sender. See also
33566 <option>ignore_fromline_hosts</option>.
33567 </para>
33568 <para>
33569 <indexterm role="option">
33570 <primary><option>uucp_from_sender</option></primary>
33571 </indexterm>
33572 </para>
33573 <informaltable frame="all">
33574 <tgroup cols="4" colsep="0" rowsep="0">
33575 <colspec colwidth="8*" align="left"/>
33576 <colspec colwidth="6*" align="center"/>
33577 <colspec colwidth="6*" align="center"/>
33578 <colspec colwidth="6*" align="right"/>
33579 <tbody>
33580 <row>
33581 <entry><option>uucp_from_sender</option></entry>
33582 <entry>Use: <emphasis>main</emphasis></entry>
33583 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33584 <entry>Default: <emphasis><literal>$1</literal></emphasis></entry>
33585 </row>
33586 </tbody>
33587 </tgroup>
33588 </informaltable>
33589 <para>
33590 See <option>uucp_from_pattern</option> above.
33591 </para>
33592 <para>
33593 <indexterm role="option">
33594 <primary><option>warn_message_file</option></primary>
33595 </indexterm>
33596 </para>
33597 <informaltable frame="all">
33598 <tgroup cols="4" colsep="0" rowsep="0">
33599 <colspec colwidth="8*" align="left"/>
33600 <colspec colwidth="6*" align="center"/>
33601 <colspec colwidth="6*" align="center"/>
33602 <colspec colwidth="6*" align="right"/>
33603 <tbody>
33604 <row>
33605 <entry><option>warn_message_file</option></entry>
33606 <entry>Use: <emphasis>main</emphasis></entry>
33607 <entry>Type: <emphasis>string</emphasis></entry>
33608 <entry>Default: <emphasis>unset</emphasis></entry>
33609 </row>
33610 </tbody>
33611 </tgroup>
33612 </informaltable>
33613 <para>
33614 <indexterm role="concept">
33615 <primary>warning of delay</primary>
33616 <secondary>customizing the message</secondary>
33617 </indexterm>
33618 <indexterm role="concept">
33619 <primary>customizing</primary>
33620 <secondary>warning message</secondary>
33621 </indexterm>
33622 This option defines a template file containing paragraphs of text to be used
33623 for constructing the warning message which is sent by Exim when a message has
33624 been in the queue for a specified amount of time, as specified by
33625 <option>delay_warning</option>. Details of the file&#x2019;s contents are given in chapter
33626 <xref linkend="CHAPemsgcust"/>. See also <option>bounce_message_file</option>.
33627 </para>
33628 <para>
33629 <indexterm role="option">
33630 <primary><option>write_rejectlog</option></primary>
33631 </indexterm>
33632 </para>
33633 <informaltable frame="all">
33634 <tgroup cols="4" colsep="0" rowsep="0">
33635 <colspec colwidth="8*" align="left"/>
33636 <colspec colwidth="6*" align="center"/>
33637 <colspec colwidth="6*" align="center"/>
33638 <colspec colwidth="6*" align="right"/>
33639 <tbody>
33640 <row>
33641 <entry><option>write_rejectlog</option></entry>
33642 <entry>Use: <emphasis>main</emphasis></entry>
33643 <entry>Type: <emphasis>boolean</emphasis></entry>
33644 <entry>Default: <emphasis>true</emphasis></entry>
33645 </row>
33646 </tbody>
33647 </tgroup>
33648 </informaltable>
33649 <para>
33650 <indexterm role="concept">
33651 <primary>reject log</primary>
33652 <secondary>disabling</secondary>
33653 </indexterm>
33654 If this option is set false, Exim no longer writes anything to the reject log.
33655 See chapter <xref linkend="CHAPlog"/> for details of what Exim writes to its logs.
33656 <indexterm role="concept" startref="IIDconfima" class="endofrange"/>
33657 <indexterm role="concept" startref="IIDmaiconf" class="endofrange"/>
33658 </para>
33659 </section>
33660 </chapter>
33661
33662 <chapter id="CHAProutergeneric">
33663 <title>Generic options for routers</title>
33664 <para>
33665 <indexterm role="concept" id="IIDgenoprou1" class="startofrange">
33666 <primary>options</primary>
33667 <secondary>generic; for routers</secondary>
33668 </indexterm>
33669 <indexterm role="concept" id="IIDgenoprou2" class="startofrange">
33670 <primary>generic options</primary>
33671 <secondary>router</secondary>
33672 </indexterm>
33673 This chapter describes the generic options that apply to all routers.
33674 Those that are preconditions are marked with &Dagger; in the <quote>use</quote> field.
33675 </para>
33676 <para>
33677 For a general description of how a router operates, see sections
33678 <xref linkend="SECTrunindrou"/> and <xref linkend="SECTrouprecon"/>. The latter specifies the order in
33679 which the preconditions are tested. The order of expansion of the options that
33680 provide data for a transport is: <option>errors_to</option>, <option>headers_add</option>,
33681 <option>headers_remove</option>, <option>transport</option>.
33682 </para>
33683 <para>
33684 <indexterm role="option">
33685 <primary><option>address_data</option></primary>
33686 </indexterm>
33687 </para>
33688 <informaltable frame="all">
33689 <tgroup cols="4" colsep="0" rowsep="0">
33690 <colspec colwidth="8*" align="left"/>
33691 <colspec colwidth="6*" align="center"/>
33692 <colspec colwidth="6*" align="center"/>
33693 <colspec colwidth="6*" align="right"/>
33694 <tbody>
33695 <row>
33696 <entry><option>address_data</option></entry>
33697 <entry>Use: <emphasis>routers</emphasis></entry>
33698 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33699 <entry>Default: <emphasis>unset</emphasis></entry>
33700 </row>
33701 </tbody>
33702 </tgroup>
33703 </informaltable>
33704 <para>
33705 <indexterm role="concept">
33706 <primary>router</primary>
33707 <secondary>data attached to address</secondary>
33708 </indexterm>
33709 The string is expanded just before the router is run, that is, after all the
33710 precondition tests have succeeded. If the expansion is forced to fail, the
33711 router declines, the value of <option>address_data</option> remains unchanged, and the
33712 <option>more</option> option controls what happens next. Other expansion failures cause
33713 delivery of the address to be deferred.
33714 </para>
33715 <para>
33716 <indexterm role="variable">
33717 <primary><varname>$address_data</varname></primary>
33718 </indexterm>
33719 When the expansion succeeds, the value is retained with the address, and can be
33720 accessed using the variable <varname>$address_data</varname> in the current router, subsequent
33721 routers, and the eventual transport.
33722 </para>
33723 <para>
33724 <emphasis role="bold">Warning</emphasis>: If the current or any subsequent router is a <command>redirect</command> router
33725 that runs a user&#x2019;s filter file, the contents of <varname>$address_data</varname> are accessible
33726 in the filter. This is not normally a problem, because such data is usually
33727 either not confidential or it <quote>belongs</quote> to the current user, but if you do
33728 put confidential data into <varname>$address_data</varname> you need to remember this point.
33729 </para>
33730 <para>
33731 Even if the router declines or passes, the value of <varname>$address_data</varname> remains
33732 with the address, though it can be changed by another <option>address_data</option> setting
33733 on a subsequent router. If a router generates child addresses, the value of
33734 <varname>$address_data</varname> propagates to them. This also applies to the special kind of
33735 <quote>child</quote> that is generated by a router with the <option>unseen</option> option.
33736 </para>
33737 <para>
33738 The idea of <option>address_data</option> is that you can use it to look up a lot of data
33739 for the address once, and then pick out parts of the data later. For example,
33740 you could use a single LDAP lookup to return a string of the form
33741 </para>
33742 <literallayout class="monospaced">
33743 uid=1234 gid=5678 mailbox=/mail/xyz forward=/home/xyz/.forward
33744 </literallayout>
33745 <para>
33746 In the transport you could pick out the mailbox by a setting such as
33747 </para>
33748 <literallayout class="monospaced">
33749 file = ${extract{mailbox}{$address_data}}
33750 </literallayout>
33751 <para>
33752 This makes the configuration file less messy, and also reduces the number of
33753 lookups (though Exim does cache lookups).
33754 </para>
33755 <para revisionflag="changed">
33756 See also the <option>set</option> option below.
33757 </para>
33758 <para>
33759 <indexterm role="variable">
33760 <primary><varname>$sender_address_data</varname></primary>
33761 </indexterm>
33762 <indexterm role="variable">
33763 <primary><varname>$address_data</varname></primary>
33764 </indexterm>
33765 The <option>address_data</option> facility is also useful as a means of passing information
33766 from one router to another, and from a router to a transport. In addition, if
33767 <varname>$address_data</varname> is set by a router when verifying a recipient address from an
33768 ACL, it remains available for use in the rest of the ACL statement. After
33769 verifying a sender, the value is transferred to <varname>$sender_address_data</varname>.
33770 </para>
33771 <para>
33772 <indexterm role="option">
33773 <primary><option>address_test</option></primary>
33774 </indexterm>
33775 </para>
33776 <informaltable frame="all">
33777 <tgroup cols="4" colsep="0" rowsep="0">
33778 <colspec colwidth="8*" align="left"/>
33779 <colspec colwidth="6*" align="center"/>
33780 <colspec colwidth="6*" align="center"/>
33781 <colspec colwidth="6*" align="right"/>
33782 <tbody>
33783 <row>
33784 <entry><option>address_test</option></entry>
33785 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
33786 <entry>Type: <emphasis>boolean</emphasis></entry>
33787 <entry>Default: <emphasis>true</emphasis></entry>
33788 </row>
33789 </tbody>
33790 </tgroup>
33791 </informaltable>
33792 <para>
33793 <indexterm role="option">
33794 <primary><option>-bt</option></primary>
33795 </indexterm>
33796 <indexterm role="concept">
33797 <primary>router</primary>
33798 <secondary>skipping when address testing</secondary>
33799 </indexterm>
33800 If this option is set false, the router is skipped when routing is being tested
33801 by means of the <option>-bt</option> command line option. This can be a convenience when
33802 your first router sends messages to an external scanner, because it saves you
33803 having to set the <quote>already scanned</quote> indicator when testing real address
33804 routing.
33805 </para>
33806 <para>
33807 <indexterm role="option">
33808 <primary><option>cannot_route_message</option></primary>
33809 </indexterm>
33810 </para>
33811 <informaltable frame="all">
33812 <tgroup cols="4" colsep="0" rowsep="0">
33813 <colspec colwidth="8*" align="left"/>
33814 <colspec colwidth="6*" align="center"/>
33815 <colspec colwidth="6*" align="center"/>
33816 <colspec colwidth="6*" align="right"/>
33817 <tbody>
33818 <row>
33819 <entry><option>cannot_route_message</option></entry>
33820 <entry>Use: <emphasis>routers</emphasis></entry>
33821 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33822 <entry>Default: <emphasis>unset</emphasis></entry>
33823 </row>
33824 </tbody>
33825 </tgroup>
33826 </informaltable>
33827 <para>
33828 <indexterm role="concept">
33829 <primary>router</primary>
33830 <secondary>customizing <quote>cannot route</quote> message</secondary>
33831 </indexterm>
33832 <indexterm role="concept">
33833 <primary>customizing</primary>
33834 <secondary><quote>cannot route</quote> message</secondary>
33835 </indexterm>
33836 This option specifies a text message that is used when an address cannot be
33837 routed because Exim has run out of routers. The default message is
33838 <quote>Unrouteable address</quote>. This option is useful only on routers that have
33839 <option>more</option> set false, or on the very last router in a configuration, because the
33840 value that is used is taken from the last router that is considered. This
33841 includes a router that is skipped because its preconditions are not met, as
33842 well as a router that declines. For example, using the default configuration,
33843 you could put:
33844 </para>
33845 <literallayout class="monospaced">
33846 cannot_route_message = Remote domain not found in DNS
33847 </literallayout>
33848 <para>
33849 on the first router, which is a <command>dnslookup</command> router with <option>more</option> set false,
33850 and
33851 </para>
33852 <literallayout class="monospaced">
33853 cannot_route_message = Unknown local user
33854 </literallayout>
33855 <para>
33856 on the final router that checks for local users. If string expansion fails for
33857 this option, the default message is used. Unless the expansion failure was
33858 explicitly forced, a message about the failure is written to the main and panic
33859 logs, in addition to the normal message about the routing failure.
33860 </para>
33861 <para>
33862 <indexterm role="option">
33863 <primary><option>caseful_local_part</option></primary>
33864 </indexterm>
33865 </para>
33866 <informaltable frame="all">
33867 <tgroup cols="4" colsep="0" rowsep="0">
33868 <colspec colwidth="8*" align="left"/>
33869 <colspec colwidth="6*" align="center"/>
33870 <colspec colwidth="6*" align="center"/>
33871 <colspec colwidth="6*" align="right"/>
33872 <tbody>
33873 <row>
33874 <entry><option>caseful_local_part</option></entry>
33875 <entry>Use: <emphasis>routers</emphasis></entry>
33876 <entry>Type: <emphasis>boolean</emphasis></entry>
33877 <entry>Default: <emphasis>false</emphasis></entry>
33878 </row>
33879 </tbody>
33880 </tgroup>
33881 </informaltable>
33882 <para>
33883 <indexterm role="concept">
33884 <primary>case of local parts</primary>
33885 </indexterm>
33886 <indexterm role="concept">
33887 <primary>router</primary>
33888 <secondary>case of local parts</secondary>
33889 </indexterm>
33890 By default, routers handle the local parts of addresses in a case-insensitive
33891 manner, though the actual case is preserved for transmission with the message.
33892 If you want the case of letters to be significant in a router, you must set
33893 this option true. For individual router options that contain address or local
33894 part lists (for example, <option>local_parts</option>), case-sensitive matching can be
33895 turned on by <quote>+caseful</quote> as a list item. See section <xref linkend="SECTcasletadd"/> for
33896 more details.
33897 </para>
33898 <para>
33899 <indexterm role="variable">
33900 <primary><varname>$local_part</varname></primary>
33901 </indexterm>
33902 <indexterm role="variable">
33903 <primary><varname>$original_local_part</varname></primary>
33904 </indexterm>
33905 <indexterm role="variable">
33906 <primary><varname>$parent_local_part</varname></primary>
33907 </indexterm>
33908 The value of the <varname>$local_part</varname> variable is forced to lower case while a
33909 router is running unless <option>caseful_local_part</option> is set. When a router assigns
33910 an address to a transport, the value of <varname>$local_part</varname> when the transport runs
33911 is the same as it was in the router. Similarly, when a router generates child
33912 addresses by aliasing or forwarding, the values of <varname>$original_local_part</varname>
33913 and <varname>$parent_local_part</varname> are those that were used by the redirecting router.
33914 </para>
33915 <para>
33916 This option applies to the processing of an address by a router. When a
33917 recipient address is being processed in an ACL, there is a separate <option>control</option>
33918 modifier that can be used to specify case-sensitive processing within the ACL
33919 (see section <xref linkend="SECTcontrols"/>).
33920 </para>
33921 <para>
33922 <indexterm role="option">
33923 <primary><option>check_local_user</option></primary>
33924 </indexterm>
33925 </para>
33926 <informaltable frame="all">
33927 <tgroup cols="4" colsep="0" rowsep="0">
33928 <colspec colwidth="8*" align="left"/>
33929 <colspec colwidth="6*" align="center"/>
33930 <colspec colwidth="6*" align="center"/>
33931 <colspec colwidth="6*" align="right"/>
33932 <tbody>
33933 <row>
33934 <entry><option>check_local_user</option></entry>
33935 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
33936 <entry>Type: <emphasis>boolean</emphasis></entry>
33937 <entry>Default: <emphasis>false</emphasis></entry>
33938 </row>
33939 </tbody>
33940 </tgroup>
33941 </informaltable>
33942 <para>
33943 <indexterm role="concept">
33944 <primary>local user, checking in router</primary>
33945 </indexterm>
33946 <indexterm role="concept">
33947 <primary>router</primary>
33948 <secondary>checking for local user</secondary>
33949 </indexterm>
33950 <indexterm role="concept">
33951 <primary><filename>/etc/passwd</filename></primary>
33952 </indexterm>
33953 <indexterm role="variable">
33954 <primary><varname>$home</varname></primary>
33955 </indexterm>
33956 When this option is true, Exim checks that the local part of the recipient
33957 address (with affixes removed if relevant) is the name of an account on the
33958 local system. The check is done by calling the <function>getpwnam()</function> function rather
33959 than trying to read <filename>/etc/passwd</filename> directly. This means that other methods of
33960 holding password data (such as NIS) are supported. If the local part is a local
33961 user, <varname>$home</varname> is set from the password data, and can be tested in other
33962 preconditions that are evaluated after this one (the order of evaluation is
33963 given in section <xref linkend="SECTrouprecon"/>). However, the value of <varname>$home</varname> can be
33964 overridden by <option>router_home_directory</option>. If the local part is not a local user,
33965 the router is skipped.
33966 </para>
33967 <para>
33968 If you want to check that the local part is either the name of a local user
33969 or matches something else, you cannot combine <option>check_local_user</option> with a
33970 setting of <option>local_parts</option>, because that specifies the logical <emphasis>and</emphasis> of the
33971 two conditions. However, you can use a <command>passwd</command> lookup in a <option>local_parts</option>
33972 setting to achieve this. For example:
33973 </para>
33974 <literallayout class="monospaced">
33975 local_parts = passwd;$local_part : lsearch;/etc/other/users
33976 </literallayout>
33977 <para>
33978 Note, however, that the side effects of <option>check_local_user</option> (such as setting
33979 up a home directory) do not occur when a <command>passwd</command> lookup is used in a
33980 <option>local_parts</option> (or any other) precondition.
33981 </para>
33982 <para>
33983 <indexterm role="option">
33984 <primary><option>condition</option></primary>
33985 </indexterm>
33986 </para>
33987 <informaltable frame="all">
33988 <tgroup cols="4" colsep="0" rowsep="0">
33989 <colspec colwidth="8*" align="left"/>
33990 <colspec colwidth="6*" align="center"/>
33991 <colspec colwidth="6*" align="center"/>
33992 <colspec colwidth="6*" align="right"/>
33993 <tbody>
33994 <row>
33995 <entry><option>condition</option></entry>
33996 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
33997 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33998 <entry>Default: <emphasis>unset</emphasis></entry>
33999 </row>
34000 </tbody>
34001 </tgroup>
34002 </informaltable>
34003 <para>
34004 <indexterm role="concept">
34005 <primary>router</primary>
34006 <secondary>customized precondition</secondary>
34007 </indexterm>
34008 This option specifies a general precondition test that has to succeed for the
34009 router to be called. The <option>condition</option> option is the last precondition to be
34010 evaluated (see section <xref linkend="SECTrouprecon"/>). The string is expanded, and if the
34011 result is a forced failure, or an empty string, or one of the strings <quote>0</quote> or
34012 <quote>no</quote> or <quote>false</quote> (checked without regard to the case of the letters), the
34013 router is skipped, and the address is offered to the next one.
34014 </para>
34015 <para>
34016 If the result is any other value, the router is run (as this is the last
34017 precondition to be evaluated, all the other preconditions must be true).
34018 </para>
34019 <para>
34020 This option is unusual in that multiple <option>condition</option> options may be present.
34021 All <option>condition</option> options must succeed.
34022 </para>
34023 <para>
34024 The <option>condition</option> option provides a means of applying custom conditions to the
34025 running of routers. Note that in the case of a simple conditional expansion,
34026 the default expansion values are exactly what is wanted. For example:
34027 </para>
34028 <literallayout class="monospaced">
34029 condition = ${if &gt;{$message_age}{600}}
34030 </literallayout>
34031 <para>
34032 Because of the default behaviour of the string expansion, this is equivalent to
34033 </para>
34034 <literallayout class="monospaced">
34035 condition = ${if &gt;{$message_age}{600}{true}{}}
34036 </literallayout>
34037 <para>
34038 A multiple condition example, which succeeds:
34039 </para>
34040 <literallayout class="monospaced">
34041 condition = ${if &gt;{$message_age}{600}}
34042 condition = ${if !eq{${lc:$local_part}}{postmaster}}
34043 condition = foobar
34044 </literallayout>
34045 <para>
34046 If the expansion fails (other than forced failure) delivery is deferred. Some
34047 of the other precondition options are common special cases that could in fact
34048 be specified using <option>condition</option>.
34049 </para>
34050 <para>
34051 Historical note: We have <option>condition</option> on ACLs and on Routers.  Routers
34052 are far older, and use one set of semantics.  ACLs are newer and when
34053 they were created, the ACL <option>condition</option> process was given far stricter
34054 parse semantics.  The <option>bool{}</option> expansion condition uses the same rules as
34055 ACLs.  The <option>bool_lax{}</option> expansion condition uses the same rules as
34056 Routers.  More pointedly, the <option>bool_lax{}</option> was written to match the existing
34057 Router rules processing behavior.
34058 </para>
34059 <para>
34060 This is best illustrated in an example:
34061 </para>
34062 <literallayout class="monospaced">
34063 # If used in an ACL condition will fail with a syntax error, but
34064 # in a router condition any extra characters are treated as a string
34065
34066 $ exim -be '${if eq {${lc:GOOGLE.com}} {google.com}} {yes} {no}}'
34067 true {yes} {no}}
34068
34069 $ exim -be '${if eq {${lc:WHOIS.com}} {google.com}} {yes} {no}}'
34070  {yes} {no}}
34071 </literallayout>
34072 <para>
34073 In each example above, the <option>if</option> statement actually ends after
34074 <quote>{google.com}}</quote>.  Since no true or false braces were defined, the
34075 default <option>if</option> behavior is to return a boolean true or a null answer
34076 (which evaluates to false). The rest of the line is then treated as a
34077 string. So the first example resulted in the boolean answer <quote>true</quote>
34078 with the string <quote> {yes} {no}}</quote> appended to it. The second example
34079 resulted in the null output (indicating false) with the string
34080 <quote> {yes} {no}}</quote> appended to it.
34081 </para>
34082 <para>
34083 In fact you can put excess forward braces in too.  In the router
34084 <option>condition</option>, Exim&#x2019;s parser only looks for <quote>{</quote> symbols when they
34085 mean something, like after a <quote>$</quote> or when required as part of a
34086 conditional.  But otherwise <quote>{</quote> and <quote>}</quote> are treated as ordinary
34087 string characters.
34088 </para>
34089 <para>
34090 Thus, in a Router, the above expansion strings will both always evaluate
34091 true, as the result of expansion is a non-empty string which doesn&#x2019;t
34092 match an explicit false value.  This can be tricky to debug.  By
34093 contrast, in an ACL either of those strings will always result in an
34094 expansion error because the result doesn&#x2019;t look sufficiently boolean.
34095 </para>
34096 <para>
34097 <indexterm role="option">
34098 <primary><option>debug_print</option></primary>
34099 </indexterm>
34100 </para>
34101 <informaltable frame="all">
34102 <tgroup cols="4" colsep="0" rowsep="0">
34103 <colspec colwidth="8*" align="left"/>
34104 <colspec colwidth="6*" align="center"/>
34105 <colspec colwidth="6*" align="center"/>
34106 <colspec colwidth="6*" align="right"/>
34107 <tbody>
34108 <row>
34109 <entry><option>debug_print</option></entry>
34110 <entry>Use: <emphasis>routers</emphasis></entry>
34111 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34112 <entry>Default: <emphasis>unset</emphasis></entry>
34113 </row>
34114 </tbody>
34115 </tgroup>
34116 </informaltable>
34117 <para>
34118 <indexterm role="concept">
34119 <primary>testing</primary>
34120 <secondary>variables in drivers</secondary>
34121 </indexterm>
34122 If this option is set and debugging is enabled (see the <option>-d</option> command line
34123 option) or in address-testing mode (see the <option>-bt</option> command line option),
34124 the string is expanded and included in the debugging output.
34125 If expansion of the string fails, the error message is written to the debugging
34126 output, and Exim carries on processing.
34127 This option is provided to help with checking out the values of variables and
34128 so on when debugging router configurations. For example, if a <option>condition</option>
34129 option appears not to be working, <option>debug_print</option> can be used to output the
34130 variables it references. The output happens after checks for <option>domains</option>,
34131 <option>local_parts</option>, and <option>check_local_user</option> but before any other preconditions
34132 are tested. A newline is added to the text if it does not end with one.
34133 The variable <varname>$router_name</varname> contains the name of the router.
34134 </para>
34135 <para>
34136 <indexterm role="option">
34137 <primary><option>disable_logging</option></primary>
34138 </indexterm>
34139 </para>
34140 <informaltable frame="all">
34141 <tgroup cols="4" colsep="0" rowsep="0">
34142 <colspec colwidth="8*" align="left"/>
34143 <colspec colwidth="6*" align="center"/>
34144 <colspec colwidth="6*" align="center"/>
34145 <colspec colwidth="6*" align="right"/>
34146 <tbody>
34147 <row>
34148 <entry><option>disable_logging</option></entry>
34149 <entry>Use: <emphasis>routers</emphasis></entry>
34150 <entry>Type: <emphasis>boolean</emphasis></entry>
34151 <entry>Default: <emphasis>false</emphasis></entry>
34152 </row>
34153 </tbody>
34154 </tgroup>
34155 </informaltable>
34156 <para>
34157 If this option is set true, nothing is logged for any routing errors
34158 or for any deliveries caused by this router. You should not set this option
34159 unless you really, really know what you are doing. See also the generic
34160 transport option of the same name.
34161 </para>
34162 <para>
34163 <indexterm role="option">
34164 <primary><option>dnssec_request_domains</option></primary>
34165 </indexterm>
34166 </para>
34167 <informaltable frame="all">
34168 <tgroup cols="4" colsep="0" rowsep="0">
34169 <colspec colwidth="8*" align="left"/>
34170 <colspec colwidth="6*" align="center"/>
34171 <colspec colwidth="6*" align="center"/>
34172 <colspec colwidth="6*" align="right"/>
34173 <tbody>
34174 <row>
34175 <entry><option>dnssec_request_domains</option></entry>
34176 <entry>Use: <emphasis>routers</emphasis></entry>
34177 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
34178 <entry>Default: <emphasis>*</emphasis></entry>
34179 </row>
34180 </tbody>
34181 </tgroup>
34182 </informaltable>
34183 <para>
34184 <indexterm role="concept">
34185 <primary>MX record</primary>
34186 <secondary>security</secondary>
34187 </indexterm>
34188 <indexterm role="concept">
34189 <primary>DNSSEC</primary>
34190 <secondary>MX lookup</secondary>
34191 </indexterm>
34192 <indexterm role="concept">
34193 <primary>security</primary>
34194 <secondary>MX lookup</secondary>
34195 </indexterm>
34196 <indexterm role="concept">
34197 <primary>DNS</primary>
34198 <secondary>DNSSEC</secondary>
34199 </indexterm>
34200 DNS lookups for domains matching <option>dnssec_request_domains</option> will be done with
34201 the dnssec request bit set.
34202 This applies to all of the SRV, MX, AAAA, A lookup sequence.
34203 </para>
34204 <para>
34205 <indexterm role="option">
34206 <primary><option>dnssec_require_domains</option></primary>
34207 </indexterm>
34208 </para>
34209 <informaltable frame="all">
34210 <tgroup cols="4" colsep="0" rowsep="0">
34211 <colspec colwidth="8*" align="left"/>
34212 <colspec colwidth="6*" align="center"/>
34213 <colspec colwidth="6*" align="center"/>
34214 <colspec colwidth="6*" align="right"/>
34215 <tbody>
34216 <row>
34217 <entry><option>dnssec_require_domains</option></entry>
34218 <entry>Use: <emphasis>routers</emphasis></entry>
34219 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
34220 <entry>Default: <emphasis>unset</emphasis></entry>
34221 </row>
34222 </tbody>
34223 </tgroup>
34224 </informaltable>
34225 <para>
34226 <indexterm role="concept">
34227 <primary>MX record</primary>
34228 <secondary>security</secondary>
34229 </indexterm>
34230 <indexterm role="concept">
34231 <primary>DNSSEC</primary>
34232 <secondary>MX lookup</secondary>
34233 </indexterm>
34234 <indexterm role="concept">
34235 <primary>security</primary>
34236 <secondary>MX lookup</secondary>
34237 </indexterm>
34238 <indexterm role="concept">
34239 <primary>DNS</primary>
34240 <secondary>DNSSEC</secondary>
34241 </indexterm>
34242 DNS lookups for domains matching <option>dnssec_require_domains</option> will be done with
34243 the dnssec request bit set.  Any returns not having the Authenticated Data bit
34244 (AD bit) set will be ignored and logged as a host-lookup failure.
34245 This applies to all of the SRV, MX, AAAA, A lookup sequence.
34246 </para>
34247 <para>
34248 <indexterm role="option">
34249 <primary><option>domains</option></primary>
34250 </indexterm>
34251 </para>
34252 <informaltable frame="all">
34253 <tgroup cols="4" colsep="0" rowsep="0">
34254 <colspec colwidth="8*" align="left"/>
34255 <colspec colwidth="6*" align="center"/>
34256 <colspec colwidth="6*" align="center"/>
34257 <colspec colwidth="6*" align="right"/>
34258 <tbody>
34259 <row>
34260 <entry><option>domains</option></entry>
34261 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
34262 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
34263 <entry>Default: <emphasis>unset</emphasis></entry>
34264 </row>
34265 </tbody>
34266 </tgroup>
34267 </informaltable>
34268 <para>
34269 <indexterm role="concept">
34270 <primary>router</primary>
34271 <secondary>restricting to specific domains</secondary>
34272 </indexterm>
34273 <indexterm role="variable">
34274 <primary><varname>$domain_data</varname></primary>
34275 </indexterm>
34276 If this option is set, the router is skipped unless the current domain matches
34277 the list. If the match is achieved by means of a file lookup, the data that the
34278 lookup returned for the domain is placed in <varname>$domain_data</varname> for use in string
34279 expansions of the driver&#x2019;s private options. See section <xref linkend="SECTrouprecon"/> for
34280 a list of the order in which preconditions are evaluated.
34281 </para>
34282 <para>
34283 <indexterm role="option">
34284 <primary><option>driver</option></primary>
34285 </indexterm>
34286 </para>
34287 <informaltable frame="all">
34288 <tgroup cols="4" colsep="0" rowsep="0">
34289 <colspec colwidth="8*" align="left"/>
34290 <colspec colwidth="6*" align="center"/>
34291 <colspec colwidth="6*" align="center"/>
34292 <colspec colwidth="6*" align="right"/>
34293 <tbody>
34294 <row>
34295 <entry><option>driver</option></entry>
34296 <entry>Use: <emphasis>routers</emphasis></entry>
34297 <entry>Type: <emphasis>string</emphasis></entry>
34298 <entry>Default: <emphasis>unset</emphasis></entry>
34299 </row>
34300 </tbody>
34301 </tgroup>
34302 </informaltable>
34303 <para>
34304 This option must always be set. It specifies which of the available routers is
34305 to be used.
34306 </para>
34307 <para>
34308 <indexterm role="option">
34309 <primary><option>dsn_lasthop</option></primary>
34310 </indexterm>
34311 </para>
34312 <informaltable frame="all">
34313 <tgroup cols="4" colsep="0" rowsep="0">
34314 <colspec colwidth="8*" align="left"/>
34315 <colspec colwidth="6*" align="center"/>
34316 <colspec colwidth="6*" align="center"/>
34317 <colspec colwidth="6*" align="right"/>
34318 <tbody>
34319 <row>
34320 <entry><option>dsn_lasthop</option></entry>
34321 <entry>Use: <emphasis>routers</emphasis></entry>
34322 <entry>Type: <emphasis>boolean</emphasis></entry>
34323 <entry>Default: <emphasis>false</emphasis></entry>
34324 </row>
34325 </tbody>
34326 </tgroup>
34327 </informaltable>
34328 <para>
34329 <indexterm role="concept">
34330 <primary>DSN</primary>
34331 <secondary>success</secondary>
34332 </indexterm>
34333 <indexterm role="concept">
34334 <primary>Delivery Status Notification</primary>
34335 <secondary>success</secondary>
34336 </indexterm>
34337 If this option is set true, and extended DSN (RFC3461) processing is in effect,
34338 Exim will not pass on DSN requests to downstream DSN-aware hosts but will
34339 instead send a success DSN as if the next hop does not support DSN.
34340 Not effective on redirect routers.
34341 </para>
34342 <para>
34343 <indexterm role="option">
34344 <primary><option>errors_to</option></primary>
34345 </indexterm>
34346 </para>
34347 <informaltable frame="all">
34348 <tgroup cols="4" colsep="0" rowsep="0">
34349 <colspec colwidth="8*" align="left"/>
34350 <colspec colwidth="6*" align="center"/>
34351 <colspec colwidth="6*" align="center"/>
34352 <colspec colwidth="6*" align="right"/>
34353 <tbody>
34354 <row>
34355 <entry><option>errors_to</option></entry>
34356 <entry>Use: <emphasis>routers</emphasis></entry>
34357 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34358 <entry>Default: <emphasis>unset</emphasis></entry>
34359 </row>
34360 </tbody>
34361 </tgroup>
34362 </informaltable>
34363 <para>
34364 <indexterm role="concept">
34365 <primary>envelope from</primary>
34366 </indexterm>
34367 <indexterm role="concept">
34368 <primary>envelope sender</primary>
34369 </indexterm>
34370 <indexterm role="concept">
34371 <primary>router</primary>
34372 <secondary>changing address for errors</secondary>
34373 </indexterm>
34374 If a router successfully handles an address, it may assign the address to a
34375 transport for delivery or it may generate child addresses. In both cases, if
34376 there is a delivery problem during later processing, the resulting bounce
34377 message is sent to the address that results from expanding this string,
34378 provided that the address verifies successfully. The <option>errors_to</option> option is
34379 expanded before <option>headers_add</option>, <option>headers_remove</option>, and <option>transport</option>.
34380 </para>
34381 <para>
34382 The <option>errors_to</option> setting associated with an address can be overridden if it
34383 subsequently passes through other routers that have their own <option>errors_to</option>
34384 settings, or if the message is delivered by a transport with a <option>return_path</option>
34385 setting.
34386 </para>
34387 <para>
34388 If <option>errors_to</option> is unset, or the expansion is forced to fail, or the result of
34389 the expansion fails to verify, the errors address associated with the incoming
34390 address is used. At top level, this is the envelope sender. A non-forced
34391 expansion failure causes delivery to be deferred.
34392 </para>
34393 <para>
34394 If an address for which <option>errors_to</option> has been set ends up being delivered over
34395 SMTP, the envelope sender for that delivery is the <option>errors_to</option> value, so that
34396 any bounces that are generated by other MTAs on the delivery route are also
34397 sent there. You can set <option>errors_to</option> to the empty string by either of these
34398 settings:
34399 </para>
34400 <literallayout class="monospaced">
34401 errors_to =
34402 errors_to = ""
34403 </literallayout>
34404 <para>
34405 An expansion item that yields an empty string has the same effect. If you do
34406 this, a locally detected delivery error for addresses processed by this router
34407 no longer gives rise to a bounce message; the error is discarded. If the
34408 address is delivered to a remote host, the return path is set to <literal>&lt;&gt;</literal>, unless
34409 overridden by the <option>return_path</option> option on the transport.
34410 </para>
34411 <para>
34412 <indexterm role="variable">
34413 <primary><varname>$address_data</varname></primary>
34414 </indexterm>
34415 If for some reason you want to discard local errors, but use a non-empty
34416 MAIL command for remote delivery, you can preserve the original return
34417 path in <varname>$address_data</varname> in the router, and reinstate it in the transport by
34418 setting <option>return_path</option>.
34419 </para>
34420 <para>
34421 The most common use of <option>errors_to</option> is to direct mailing list bounces to the
34422 manager of the list, as described in section <xref linkend="SECTmailinglists"/>, or to
34423 implement VERP (Variable Envelope Return Paths) (see section <xref linkend="SECTverp"/>).
34424 </para>
34425 <para>
34426 <indexterm role="option">
34427 <primary><option>expn</option></primary>
34428 </indexterm>
34429 </para>
34430 <informaltable frame="all">
34431 <tgroup cols="4" colsep="0" rowsep="0">
34432 <colspec colwidth="8*" align="left"/>
34433 <colspec colwidth="6*" align="center"/>
34434 <colspec colwidth="6*" align="center"/>
34435 <colspec colwidth="6*" align="right"/>
34436 <tbody>
34437 <row>
34438 <entry><option>expn</option></entry>
34439 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
34440 <entry>Type: <emphasis>boolean</emphasis></entry>
34441 <entry>Default: <emphasis>true</emphasis></entry>
34442 </row>
34443 </tbody>
34444 </tgroup>
34445 </informaltable>
34446 <para>
34447 <indexterm role="concept">
34448 <primary>address</primary>
34449 <secondary>testing</secondary>
34450 </indexterm>
34451 <indexterm role="concept">
34452 <primary>testing</primary>
34453 <secondary>addresses</secondary>
34454 </indexterm>
34455 <indexterm role="concept">
34456 <primary>EXPN</primary>
34457 <secondary>router skipping</secondary>
34458 </indexterm>
34459 <indexterm role="concept">
34460 <primary>router</primary>
34461 <secondary>skipping for EXPN</secondary>
34462 </indexterm>
34463 If this option is turned off, the router is skipped when testing an address
34464 as a result of processing an SMTP EXPN command. You might, for example,
34465 want to turn it off on a router for users&#x2019; <filename>.forward</filename> files, while leaving it
34466 on for the system alias file.
34467 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
34468 are evaluated.
34469 </para>
34470 <para>
34471 The use of the SMTP EXPN command is controlled by an ACL (see chapter
34472 <xref linkend="CHAPACL"/>). When Exim is running an EXPN command, it is similar to testing
34473 an address with <option>-bt</option>. Compare VRFY, whose counterpart is <option>-bv</option>.
34474 </para>
34475 <para>
34476 <indexterm role="option">
34477 <primary><option>fail_verify</option></primary>
34478 </indexterm>
34479 </para>
34480 <informaltable frame="all">
34481 <tgroup cols="4" colsep="0" rowsep="0">
34482 <colspec colwidth="8*" align="left"/>
34483 <colspec colwidth="6*" align="center"/>
34484 <colspec colwidth="6*" align="center"/>
34485 <colspec colwidth="6*" align="right"/>
34486 <tbody>
34487 <row>
34488 <entry><option>fail_verify</option></entry>
34489 <entry>Use: <emphasis>routers</emphasis></entry>
34490 <entry>Type: <emphasis>boolean</emphasis></entry>
34491 <entry>Default: <emphasis>false</emphasis></entry>
34492 </row>
34493 </tbody>
34494 </tgroup>
34495 </informaltable>
34496 <para>
34497 <indexterm role="concept">
34498 <primary>router</primary>
34499 <secondary>forcing verification failure</secondary>
34500 </indexterm>
34501 Setting this option has the effect of setting both <option>fail_verify_sender</option> and
34502 <option>fail_verify_recipient</option> to the same value.
34503 </para>
34504 <para>
34505 <indexterm role="option">
34506 <primary><option>fail_verify_recipient</option></primary>
34507 </indexterm>
34508 </para>
34509 <informaltable frame="all">
34510 <tgroup cols="4" colsep="0" rowsep="0">
34511 <colspec colwidth="8*" align="left"/>
34512 <colspec colwidth="6*" align="center"/>
34513 <colspec colwidth="6*" align="center"/>
34514 <colspec colwidth="6*" align="right"/>
34515 <tbody>
34516 <row>
34517 <entry><option>fail_verify_recipient</option></entry>
34518 <entry>Use: <emphasis>routers</emphasis></entry>
34519 <entry>Type: <emphasis>boolean</emphasis></entry>
34520 <entry>Default: <emphasis>false</emphasis></entry>
34521 </row>
34522 </tbody>
34523 </tgroup>
34524 </informaltable>
34525 <para>
34526 If this option is true and an address is accepted by this router when
34527 verifying a recipient, verification fails.
34528 </para>
34529 <para>
34530 <indexterm role="option">
34531 <primary><option>fail_verify_sender</option></primary>
34532 </indexterm>
34533 </para>
34534 <informaltable frame="all">
34535 <tgroup cols="4" colsep="0" rowsep="0">
34536 <colspec colwidth="8*" align="left"/>
34537 <colspec colwidth="6*" align="center"/>
34538 <colspec colwidth="6*" align="center"/>
34539 <colspec colwidth="6*" align="right"/>
34540 <tbody>
34541 <row>
34542 <entry><option>fail_verify_sender</option></entry>
34543 <entry>Use: <emphasis>routers</emphasis></entry>
34544 <entry>Type: <emphasis>boolean</emphasis></entry>
34545 <entry>Default: <emphasis>false</emphasis></entry>
34546 </row>
34547 </tbody>
34548 </tgroup>
34549 </informaltable>
34550 <para>
34551 If this option is true and an address is accepted by this router when
34552 verifying a sender, verification fails.
34553 </para>
34554 <para>
34555 <indexterm role="option">
34556 <primary><option>fallback_hosts</option></primary>
34557 </indexterm>
34558 </para>
34559 <informaltable frame="all">
34560 <tgroup cols="4" colsep="0" rowsep="0">
34561 <colspec colwidth="8*" align="left"/>
34562 <colspec colwidth="6*" align="center"/>
34563 <colspec colwidth="6*" align="center"/>
34564 <colspec colwidth="6*" align="right"/>
34565 <tbody>
34566 <row>
34567 <entry><option>fallback_hosts</option></entry>
34568 <entry>Use: <emphasis>routers</emphasis></entry>
34569 <entry>Type: <emphasis>string list</emphasis></entry>
34570 <entry>Default: <emphasis>unset</emphasis></entry>
34571 </row>
34572 </tbody>
34573 </tgroup>
34574 </informaltable>
34575 <para>
34576 <indexterm role="concept">
34577 <primary>router</primary>
34578 <secondary>fallback hosts</secondary>
34579 </indexterm>
34580 <indexterm role="concept">
34581 <primary>fallback</primary>
34582 <secondary>hosts specified on router</secondary>
34583 </indexterm>
34584 String expansion is not applied to this option. The argument must be a
34585 colon-separated list of host names or IP addresses. The list separator can be
34586 changed (see section <xref linkend="SECTlistsepchange"/>), and a port can be specified with
34587 each name or address. In fact, the format of each item is exactly the same as
34588 defined for the list of hosts in a <command>manualroute</command> router (see section
34589 <xref linkend="SECTformatonehostitem"/>).
34590 </para>
34591 <para>
34592 If a router queues an address for a remote transport, this host list is
34593 associated with the address, and used instead of the transport&#x2019;s fallback host
34594 list. If <option>hosts_randomize</option> is set on the transport, the order of the list is
34595 randomized for each use. See the <option>fallback_hosts</option> option of the <command>smtp</command>
34596 transport for further details.
34597 </para>
34598 <para>
34599 <indexterm role="option">
34600 <primary><option>group</option></primary>
34601 </indexterm>
34602 </para>
34603 <informaltable frame="all">
34604 <tgroup cols="4" colsep="0" rowsep="0">
34605 <colspec colwidth="8*" align="left"/>
34606 <colspec colwidth="6*" align="center"/>
34607 <colspec colwidth="6*" align="center"/>
34608 <colspec colwidth="6*" align="right"/>
34609 <tbody>
34610 <row>
34611 <entry><option>group</option></entry>
34612 <entry>Use: <emphasis>routers</emphasis></entry>
34613 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34614 <entry>Default: <emphasis>see below</emphasis></entry>
34615 </row>
34616 </tbody>
34617 </tgroup>
34618 </informaltable>
34619 <para>
34620 <indexterm role="concept">
34621 <primary>gid (group id)</primary>
34622 <secondary>local delivery</secondary>
34623 </indexterm>
34624 <indexterm role="concept">
34625 <primary>local transports</primary>
34626 <secondary>uid and gid</secondary>
34627 </indexterm>
34628 <indexterm role="concept">
34629 <primary>transport</primary>
34630 <secondary>local</secondary>
34631 </indexterm>
34632 <indexterm role="concept">
34633 <primary>router</primary>
34634 <secondary>setting group</secondary>
34635 </indexterm>
34636 When a router queues an address for a transport, and the transport does not
34637 specify a group, the group given here is used when running the delivery
34638 process.
34639 The group may be specified numerically or by name. If expansion fails, the
34640 error is logged and delivery is deferred.
34641 The default is unset, unless <option>check_local_user</option> is set, when the default
34642 is taken from the password information. See also <option>initgroups</option> and <option>user</option>
34643 and the discussion in chapter <xref linkend="CHAPenvironment"/>.
34644 </para>
34645 <para>
34646 <indexterm role="option">
34647 <primary><option>headers_add</option></primary>
34648 </indexterm>
34649 </para>
34650 <informaltable frame="all">
34651 <tgroup cols="4" colsep="0" rowsep="0">
34652 <colspec colwidth="8*" align="left"/>
34653 <colspec colwidth="6*" align="center"/>
34654 <colspec colwidth="6*" align="center"/>
34655 <colspec colwidth="6*" align="right"/>
34656 <tbody>
34657 <row>
34658 <entry><option>headers_add</option></entry>
34659 <entry>Use: <emphasis>routers</emphasis></entry>
34660 <entry>Type: <emphasis>list</emphasis>&dagger;<emphasis></emphasis></entry>
34661 <entry>Default: <emphasis>unset</emphasis></entry>
34662 </row>
34663 </tbody>
34664 </tgroup>
34665 </informaltable>
34666 <para>
34667 <indexterm role="concept">
34668 <primary>header lines</primary>
34669 <secondary>adding</secondary>
34670 </indexterm>
34671 <indexterm role="concept">
34672 <primary>router</primary>
34673 <secondary>adding header lines</secondary>
34674 </indexterm>
34675 This option specifies a list of text headers,
34676 newline-separated (by default, changeable in the usual way <xref linkend="SECTlistsepchange"/>),
34677 that is associated with any addresses that are accepted by the router.
34678 Each item is separately expanded, at routing time.  However, this
34679 option has no effect when an address is just being verified. The way in which
34680 the text is used to add header lines at transport time is described in section
34681 <xref linkend="SECTheadersaddrem"/>. New header lines are not actually added until the
34682 message is in the process of being transported. This means that references to
34683 header lines in string expansions in the transport&#x2019;s configuration do not
34684 <quote>see</quote> the added header lines.
34685 </para>
34686 <para>
34687 The <option>headers_add</option> option is expanded after <option>errors_to</option>, but before
34688 <option>headers_remove</option> and <option>transport</option>. If an item is empty, or if
34689 an item expansion is forced to fail, the item has no effect. Other expansion
34690 failures are treated as configuration errors.
34691 </para>
34692 <para>
34693 Unlike most options, <option>headers_add</option> can be specified multiple times
34694 for a router; all listed headers are added.
34695 </para>
34696 <para>
34697 <emphasis role="bold">Warning 1</emphasis>: The <option>headers_add</option> option cannot be used for a <command>redirect</command>
34698 router that has the <option>one_time</option> option set.
34699 </para>
34700 <para>
34701 <indexterm role="concept">
34702 <primary>duplicate addresses</primary>
34703 </indexterm>
34704 <indexterm role="option">
34705 <primary><option>unseen</option></primary>
34706 </indexterm>
34707 <emphasis role="bold">Warning 2</emphasis>: If the <option>unseen</option> option is set on the router, all header
34708 additions are deleted when the address is passed on to subsequent routers.
34709 For a <option>redirect</option> router, if a generated address is the same as the incoming
34710 address, this can lead to duplicate addresses with different header
34711 modifications. Exim does not do duplicate deliveries (except, in certain
34712 circumstances, to pipes -- see section <xref linkend="SECTdupaddr"/>), but it is undefined
34713 which of the duplicates is discarded, so this ambiguous situation should be
34714 avoided. The <option>repeat_use</option> option of the <option>redirect</option> router may be of help.
34715 </para>
34716 <para>
34717 <indexterm role="option">
34718 <primary><option>headers_remove</option></primary>
34719 </indexterm>
34720 </para>
34721 <informaltable frame="all">
34722 <tgroup cols="4" colsep="0" rowsep="0">
34723 <colspec colwidth="8*" align="left"/>
34724 <colspec colwidth="6*" align="center"/>
34725 <colspec colwidth="6*" align="center"/>
34726 <colspec colwidth="6*" align="right"/>
34727 <tbody>
34728 <row>
34729 <entry><option>headers_remove</option></entry>
34730 <entry>Use: <emphasis>routers</emphasis></entry>
34731 <entry>Type: <emphasis>list</emphasis>&dagger;<emphasis></emphasis></entry>
34732 <entry>Default: <emphasis>unset</emphasis></entry>
34733 </row>
34734 </tbody>
34735 </tgroup>
34736 </informaltable>
34737 <para>
34738 <indexterm role="concept">
34739 <primary>header lines</primary>
34740 <secondary>removing</secondary>
34741 </indexterm>
34742 <indexterm role="concept">
34743 <primary>router</primary>
34744 <secondary>removing header lines</secondary>
34745 </indexterm>
34746 This option specifies a list of text headers,
34747 colon-separated (by default, changeable in the usual way <xref linkend="SECTlistsepchange"/>),
34748 that is associated with any addresses that are accepted by the router.
34749 Each item is separately expanded, at routing time.  However, this
34750 option has no effect when an address is just being verified. The way in which
34751 the text is used to remove header lines at transport time is described in
34752 section <xref linkend="SECTheadersaddrem"/>. Header lines are not actually removed until
34753 the message is in the process of being transported. This means that references
34754 to header lines in string expansions in the transport&#x2019;s configuration still
34755 <quote>see</quote> the original header lines.
34756 </para>
34757 <para>
34758 The <option>headers_remove</option> option is expanded after <option>errors_to</option> and
34759 <option>headers_add</option>, but before <option>transport</option>. If an item expansion is forced to fail,
34760 the item has no effect. Other expansion failures are treated as configuration
34761 errors.
34762 </para>
34763 <para>
34764 Unlike most options, <option>headers_remove</option> can be specified multiple times
34765 for a router; all listed headers are removed.
34766 </para>
34767 <para>
34768 <emphasis role="bold">Warning 1</emphasis>: The <option>headers_remove</option> option cannot be used for a <command>redirect</command>
34769 router that has the <option>one_time</option> option set.
34770 </para>
34771 <para>
34772 <emphasis role="bold">Warning 2</emphasis>: If the <option>unseen</option> option is set on the router, all header
34773 removal requests are deleted when the address is passed on to subsequent
34774 routers, and this can lead to problems with duplicates -- see the similar
34775 warning for <option>headers_add</option> above.
34776 </para>
34777 <para>
34778 <emphasis role="bold">Warning 3</emphasis>: Because of the separate expansion of the list items,
34779 items that contain a list separator must have it doubled.
34780 To avoid this, change the list separator (<xref linkend="SECTlistsepchange"/>).
34781 </para>
34782 <para>
34783 <indexterm role="option">
34784 <primary><option>ignore_target_hosts</option></primary>
34785 </indexterm>
34786 </para>
34787 <informaltable frame="all">
34788 <tgroup cols="4" colsep="0" rowsep="0">
34789 <colspec colwidth="8*" align="left"/>
34790 <colspec colwidth="6*" align="center"/>
34791 <colspec colwidth="6*" align="center"/>
34792 <colspec colwidth="6*" align="right"/>
34793 <tbody>
34794 <row>
34795 <entry><option>ignore_target_hosts</option></entry>
34796 <entry>Use: <emphasis>routers</emphasis></entry>
34797 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
34798 <entry>Default: <emphasis>unset</emphasis></entry>
34799 </row>
34800 </tbody>
34801 </tgroup>
34802 </informaltable>
34803 <para>
34804 <indexterm role="concept">
34805 <primary>IP address</primary>
34806 <secondary>discarding</secondary>
34807 </indexterm>
34808 <indexterm role="concept">
34809 <primary>router</primary>
34810 <secondary>discarding IP addresses</secondary>
34811 </indexterm>
34812 Although this option is a host list, it should normally contain IP address
34813 entries rather than names. If any host that is looked up by the router has an
34814 IP address that matches an item in this list, Exim behaves as if that IP
34815 address did not exist. This option allows you to cope with rogue DNS entries
34816 like
34817 </para>
34818 <literallayout class="monospaced">
34819 remote.domain.example.  A  127.0.0.1
34820 </literallayout>
34821 <para>
34822 by setting
34823 </para>
34824 <literallayout class="monospaced">
34825 ignore_target_hosts = 127.0.0.1
34826 </literallayout>
34827 <para>
34828 on the relevant router. If all the hosts found by a <command>dnslookup</command> router are
34829 discarded in this way, the router declines. In a conventional configuration, an
34830 attempt to mail to such a domain would normally provoke the <quote>unrouteable
34831 domain</quote> error, and an attempt to verify an address in the domain would fail.
34832 Similarly, if <option>ignore_target_hosts</option> is set on an <command>ipliteral</command> router, the
34833 router declines if presented with one of the listed addresses.
34834 </para>
34835 <para>
34836 You can use this option to disable the use of IPv4 or IPv6 for mail delivery by
34837 means of the first or the second of the following settings, respectively:
34838 </para>
34839 <literallayout class="monospaced">
34840 ignore_target_hosts = 0.0.0.0/0
34841 ignore_target_hosts = &lt;; 0::0/0
34842 </literallayout>
34843 <para>
34844 The pattern in the first line matches all IPv4 addresses, whereas the pattern
34845 in the second line matches all IPv6 addresses.
34846 </para>
34847 <para>
34848 This option may also be useful for ignoring link-local and site-local IPv6
34849 addresses. Because, like all host lists, the value of <option>ignore_target_hosts</option>
34850 is expanded before use as a list, it is possible to make it dependent on the
34851 domain that is being routed.
34852 </para>
34853 <para>
34854 <indexterm role="variable">
34855 <primary><varname>$host_address</varname></primary>
34856 </indexterm>
34857 During its expansion, <varname>$host_address</varname> is set to the IP address that is being
34858 checked.
34859 </para>
34860 <para>
34861 <indexterm role="option">
34862 <primary><option>initgroups</option></primary>
34863 </indexterm>
34864 </para>
34865 <informaltable frame="all">
34866 <tgroup cols="4" colsep="0" rowsep="0">
34867 <colspec colwidth="8*" align="left"/>
34868 <colspec colwidth="6*" align="center"/>
34869 <colspec colwidth="6*" align="center"/>
34870 <colspec colwidth="6*" align="right"/>
34871 <tbody>
34872 <row>
34873 <entry><option>initgroups</option></entry>
34874 <entry>Use: <emphasis>routers</emphasis></entry>
34875 <entry>Type: <emphasis>boolean</emphasis></entry>
34876 <entry>Default: <emphasis>false</emphasis></entry>
34877 </row>
34878 </tbody>
34879 </tgroup>
34880 </informaltable>
34881 <para>
34882 <indexterm role="concept">
34883 <primary>additional groups</primary>
34884 </indexterm>
34885 <indexterm role="concept">
34886 <primary>groups</primary>
34887 <secondary>additional</secondary>
34888 </indexterm>
34889 <indexterm role="concept">
34890 <primary>local transports</primary>
34891 <secondary>uid and gid</secondary>
34892 </indexterm>
34893 <indexterm role="concept">
34894 <primary>transport</primary>
34895 <secondary>local</secondary>
34896 </indexterm>
34897 If the router queues an address for a transport, and this option is true, and
34898 the uid supplied by the router is not overridden by the transport, the
34899 <function>initgroups()</function> function is called when running the transport to ensure that
34900 any additional groups associated with the uid are set up. See also <option>group</option>
34901 and <option>user</option> and the discussion in chapter <xref linkend="CHAPenvironment"/>.
34902 </para>
34903 <para>
34904 <indexterm role="option">
34905 <primary><option>local_part_prefix</option></primary>
34906 </indexterm>
34907 </para>
34908 <informaltable frame="all">
34909 <tgroup cols="4" colsep="0" rowsep="0">
34910 <colspec colwidth="8*" align="left"/>
34911 <colspec colwidth="6*" align="center"/>
34912 <colspec colwidth="6*" align="center"/>
34913 <colspec colwidth="6*" align="right"/>
34914 <tbody>
34915 <row>
34916 <entry><option>local_part_prefix</option></entry>
34917 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
34918 <entry>Type: <emphasis>string list</emphasis></entry>
34919 <entry>Default: <emphasis>unset</emphasis></entry>
34920 </row>
34921 </tbody>
34922 </tgroup>
34923 </informaltable>
34924 <para>
34925 <indexterm role="concept">
34926 <primary>affix</primary>
34927 <secondary>router precondition</secondary>
34928 </indexterm>
34929 <indexterm role="concept">
34930 <primary>router</primary>
34931 <secondary>prefix for local part</secondary>
34932 </indexterm>
34933 <indexterm role="concept">
34934 <primary>prefix</primary>
34935 <secondary>for local part, used in router</secondary>
34936 </indexterm>
34937 If this option is set, the router is skipped unless the local part starts with
34938 one of the given strings, or <option>local_part_prefix_optional</option> is true. See
34939 section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions are
34940 evaluated.
34941 </para>
34942 <para>
34943 The list is scanned from left to right, and the first prefix that matches is
34944 used. A limited form of wildcard is available; if the prefix begins with an
34945 asterisk, it matches the longest possible sequence of arbitrary characters at
34946 the start of the local part. An asterisk should therefore always be followed by
34947 some character that does not occur in normal local parts.
34948 <indexterm role="concept">
34949 <primary>multiple mailboxes</primary>
34950 </indexterm>
34951 <indexterm role="concept">
34952 <primary>mailbox</primary>
34953 <secondary>multiple</secondary>
34954 </indexterm>
34955 Wildcarding can be used to set up multiple user mailboxes, as described in
34956 section <xref linkend="SECTmulbox"/>.
34957 </para>
34958 <para>
34959 <indexterm role="variable">
34960 <primary><varname>$local_part</varname></primary>
34961 </indexterm>
34962 <indexterm role="variable">
34963 <primary><varname>$local_part_prefix</varname></primary>
34964 </indexterm>
34965 During the testing of the <option>local_parts</option> option, and while the router is
34966 running, the prefix is removed from the local part, and is available in the
34967 expansion variable <varname>$local_part_prefix</varname>. When a message is being delivered, if
34968 the router accepts the address, this remains true during subsequent delivery by
34969 a transport. In particular, the local part that is transmitted in the RCPT
34970 command for LMTP, SMTP, and BSMTP deliveries has the prefix removed by default.
34971 This behaviour can be overridden by setting <option>rcpt_include_affixes</option> true on
34972 the relevant transport.
34973 </para>
34974 <para>
34975 When an address is being verified, <option>local_part_prefix</option> affects only the
34976 behaviour of the router. If the callout feature of verification is in use, this
34977 means that the full address, including the prefix, will be used during the
34978 callout.
34979 </para>
34980 <para>
34981 The prefix facility is commonly used to handle local parts of the form
34982 <option>owner-something</option>. Another common use is to support local parts of the form
34983 <option>real-username</option> to bypass a user&#x2019;s <filename>.forward</filename> file &ndash; helpful when trying
34984 to tell a user their forwarding is broken &ndash; by placing a router like this one
34985 immediately before the router that handles <filename>.forward</filename> files:
34986 </para>
34987 <literallayout class="monospaced">
34988 real_localuser:
34989   driver = accept
34990   local_part_prefix = real-
34991   check_local_user
34992   transport = local_delivery
34993 </literallayout>
34994 <para>
34995 For security, it would probably be a good idea to restrict the use of this
34996 router to locally-generated messages, using a condition such as this:
34997 </para>
34998 <literallayout class="monospaced">
34999   condition = ${if match {$sender_host_address}\
35000                          {\N^(|127\.0\.0\.1)$\N}}
35001 </literallayout>
35002 <para>
35003 If both <option>local_part_prefix</option> and <option>local_part_suffix</option> are set for a router,
35004 both conditions must be met if not optional. Care must be taken if wildcards
35005 are used in both a prefix and a suffix on the same router. Different
35006 separator characters must be used to avoid ambiguity.
35007 </para>
35008 <para>
35009 <indexterm role="option">
35010 <primary><option>local_part_prefix_optional</option></primary>
35011 </indexterm>
35012 </para>
35013 <informaltable frame="all">
35014 <tgroup cols="4" colsep="0" rowsep="0">
35015 <colspec colwidth="8*" align="left"/>
35016 <colspec colwidth="6*" align="center"/>
35017 <colspec colwidth="6*" align="center"/>
35018 <colspec colwidth="6*" align="right"/>
35019 <tbody>
35020 <row>
35021 <entry><option>local_part_prefix_optional</option></entry>
35022 <entry>Use: <emphasis>routers</emphasis></entry>
35023 <entry>Type: <emphasis>boolean</emphasis></entry>
35024 <entry>Default: <emphasis>false</emphasis></entry>
35025 </row>
35026 </tbody>
35027 </tgroup>
35028 </informaltable>
35029 <para>
35030 See <option>local_part_prefix</option> above.
35031 </para>
35032 <para>
35033 <indexterm role="option">
35034 <primary><option>local_part_suffix</option></primary>
35035 </indexterm>
35036 </para>
35037 <informaltable frame="all">
35038 <tgroup cols="4" colsep="0" rowsep="0">
35039 <colspec colwidth="8*" align="left"/>
35040 <colspec colwidth="6*" align="center"/>
35041 <colspec colwidth="6*" align="center"/>
35042 <colspec colwidth="6*" align="right"/>
35043 <tbody>
35044 <row>
35045 <entry><option>local_part_suffix</option></entry>
35046 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
35047 <entry>Type: <emphasis>string list</emphasis></entry>
35048 <entry>Default: <emphasis>unset</emphasis></entry>
35049 </row>
35050 </tbody>
35051 </tgroup>
35052 </informaltable>
35053 <para>
35054 <indexterm role="concept">
35055 <primary>router</primary>
35056 <secondary>suffix for local part</secondary>
35057 </indexterm>
35058 <indexterm role="concept">
35059 <primary>suffix for local part</primary>
35060 <secondary>used in router</secondary>
35061 </indexterm>
35062 This option operates in the same way as <option>local_part_prefix</option>, except that the
35063 local part must end (rather than start) with the given string, the
35064 <option>local_part_suffix_optional</option> option determines whether the suffix is
35065 mandatory, and the wildcard * character, if present, must be the last
35066 character of the suffix. This option facility is commonly used to handle local
35067 parts of the form <option>something-request</option> and multiple user mailboxes of the form
35068 <option>username-foo</option>.
35069 </para>
35070 <para>
35071 <indexterm role="option">
35072 <primary><option>local_part_suffix_optional</option></primary>
35073 </indexterm>
35074 </para>
35075 <informaltable frame="all">
35076 <tgroup cols="4" colsep="0" rowsep="0">
35077 <colspec colwidth="8*" align="left"/>
35078 <colspec colwidth="6*" align="center"/>
35079 <colspec colwidth="6*" align="center"/>
35080 <colspec colwidth="6*" align="right"/>
35081 <tbody>
35082 <row>
35083 <entry><option>local_part_suffix_optional</option></entry>
35084 <entry>Use: <emphasis>routers</emphasis></entry>
35085 <entry>Type: <emphasis>boolean</emphasis></entry>
35086 <entry>Default: <emphasis>false</emphasis></entry>
35087 </row>
35088 </tbody>
35089 </tgroup>
35090 </informaltable>
35091 <para>
35092 See <option>local_part_suffix</option> above.
35093 </para>
35094 <para>
35095 <indexterm role="option">
35096 <primary><option>local_parts</option></primary>
35097 </indexterm>
35098 </para>
35099 <informaltable frame="all">
35100 <tgroup cols="4" colsep="0" rowsep="0">
35101 <colspec colwidth="8*" align="left"/>
35102 <colspec colwidth="6*" align="center"/>
35103 <colspec colwidth="6*" align="center"/>
35104 <colspec colwidth="6*" align="right"/>
35105 <tbody>
35106 <row>
35107 <entry><option>local_parts</option></entry>
35108 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
35109 <entry>Type: <emphasis>local part list</emphasis>&dagger;<emphasis></emphasis></entry>
35110 <entry>Default: <emphasis>unset</emphasis></entry>
35111 </row>
35112 </tbody>
35113 </tgroup>
35114 </informaltable>
35115 <para>
35116 <indexterm role="concept">
35117 <primary>router</primary>
35118 <secondary>restricting to specific local parts</secondary>
35119 </indexterm>
35120 <indexterm role="concept">
35121 <primary>local part</primary>
35122 <secondary>checking in router</secondary>
35123 </indexterm>
35124 The router is run only if the local part of the address matches the list.
35125 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
35126 are evaluated, and
35127 section <xref linkend="SECTlocparlis"/> for a discussion of local part lists. Because the
35128 string is expanded, it is possible to make it depend on the domain, for
35129 example:
35130 </para>
35131 <literallayout class="monospaced">
35132 local_parts = dbm;/usr/local/specials/$domain
35133 </literallayout>
35134 <para>
35135 <indexterm role="variable">
35136 <primary><varname>$local_part_data</varname></primary>
35137 </indexterm>
35138 If the match is achieved by a lookup, the data that the lookup returned
35139 for the local part is placed in the variable <varname>$local_part_data</varname> for use in
35140 expansions of the router&#x2019;s private options. You might use this option, for
35141 example, if you have a large number of local virtual domains, and you want to
35142 send all postmaster mail to the same place without having to set up an alias in
35143 each virtual domain:
35144 </para>
35145 <literallayout class="monospaced">
35146 postmaster:
35147   driver = redirect
35148   local_parts = postmaster
35149   data = postmaster@real.domain.example
35150 </literallayout>
35151 <para>
35152 <indexterm role="option">
35153 <primary><option>log_as_local</option></primary>
35154 </indexterm>
35155 </para>
35156 <informaltable frame="all">
35157 <tgroup cols="4" colsep="0" rowsep="0">
35158 <colspec colwidth="8*" align="left"/>
35159 <colspec colwidth="6*" align="center"/>
35160 <colspec colwidth="6*" align="center"/>
35161 <colspec colwidth="6*" align="right"/>
35162 <tbody>
35163 <row>
35164 <entry><option>log_as_local</option></entry>
35165 <entry>Use: <emphasis>routers</emphasis></entry>
35166 <entry>Type: <emphasis>boolean</emphasis></entry>
35167 <entry>Default: <emphasis>see below</emphasis></entry>
35168 </row>
35169 </tbody>
35170 </tgroup>
35171 </informaltable>
35172 <para>
35173 <indexterm role="concept">
35174 <primary>log</primary>
35175 <secondary>delivery line</secondary>
35176 </indexterm>
35177 <indexterm role="concept">
35178 <primary>delivery</primary>
35179 <secondary>log line format</secondary>
35180 </indexterm>
35181 Exim has two logging styles for delivery, the idea being to make local
35182 deliveries stand out more visibly from remote ones. In the <quote>local</quote> style, the
35183 recipient address is given just as the local part, without a domain. The use of
35184 this style is controlled by this option. It defaults to true for the <command>accept</command>
35185 router, and false for all the others. This option applies only when a
35186 router assigns an address to a transport. It has no effect on routers that
35187 redirect addresses.
35188 </para>
35189 <para>
35190 <indexterm role="option">
35191 <primary><option>more</option></primary>
35192 </indexterm>
35193 </para>
35194 <informaltable frame="all">
35195 <tgroup cols="4" colsep="0" rowsep="0">
35196 <colspec colwidth="8*" align="left"/>
35197 <colspec colwidth="6*" align="center"/>
35198 <colspec colwidth="6*" align="center"/>
35199 <colspec colwidth="6*" align="right"/>
35200 <tbody>
35201 <row>
35202 <entry><option>more</option></entry>
35203 <entry>Use: <emphasis>routers</emphasis></entry>
35204 <entry>Type: <emphasis>boolean</emphasis>&dagger;<emphasis></emphasis></entry>
35205 <entry>Default: <emphasis>true</emphasis></entry>
35206 </row>
35207 </tbody>
35208 </tgroup>
35209 </informaltable>
35210 <para>
35211 The result of string expansion for this option must be a valid boolean value,
35212 that is, one of the strings <quote>yes</quote>, <quote>no</quote>, <quote>true</quote>, or <quote>false</quote>. Any other
35213 result causes an error, and delivery is deferred. If the expansion is forced to
35214 fail, the default value for the option (true) is used. Other failures cause
35215 delivery to be deferred.
35216 </para>
35217 <para>
35218 If this option is set false, and the router declines to handle the address, no
35219 further routers are tried, routing fails, and the address is bounced.
35220 <indexterm role="option">
35221 <primary><option>self</option></primary>
35222 </indexterm>
35223 However, if the router explicitly passes an address to the following router by
35224 means of the setting
35225 </para>
35226 <literallayout class="monospaced">
35227 self = pass
35228 </literallayout>
35229 <para>
35230 or otherwise, the setting of <option>more</option> is ignored. Also, the setting of <option>more</option>
35231 does not affect the behaviour if one of the precondition tests fails. In that
35232 case, the address is always passed to the next router.
35233 </para>
35234 <para>
35235 Note that <option>address_data</option> is not considered to be a precondition. If its
35236 expansion is forced to fail, the router declines, and the value of <option>more</option>
35237 controls what happens next.
35238 </para>
35239 <para>
35240 <indexterm role="option">
35241 <primary><option>pass_on_timeout</option></primary>
35242 </indexterm>
35243 </para>
35244 <informaltable frame="all">
35245 <tgroup cols="4" colsep="0" rowsep="0">
35246 <colspec colwidth="8*" align="left"/>
35247 <colspec colwidth="6*" align="center"/>
35248 <colspec colwidth="6*" align="center"/>
35249 <colspec colwidth="6*" align="right"/>
35250 <tbody>
35251 <row>
35252 <entry><option>pass_on_timeout</option></entry>
35253 <entry>Use: <emphasis>routers</emphasis></entry>
35254 <entry>Type: <emphasis>boolean</emphasis></entry>
35255 <entry>Default: <emphasis>false</emphasis></entry>
35256 </row>
35257 </tbody>
35258 </tgroup>
35259 </informaltable>
35260 <para>
35261 <indexterm role="concept">
35262 <primary>timeout</primary>
35263 <secondary>of router</secondary>
35264 </indexterm>
35265 <indexterm role="concept">
35266 <primary>router</primary>
35267 <secondary>timeout</secondary>
35268 </indexterm>
35269 If a router times out during a host lookup, it normally causes deferral of the
35270 address. If <option>pass_on_timeout</option> is set, the address is passed on to the next
35271 router, overriding <option>no_more</option>. This may be helpful for systems that are
35272 intermittently connected to the Internet, or those that want to pass to a smart
35273 host any messages that cannot immediately be delivered.
35274 </para>
35275 <para>
35276 There are occasional other temporary errors that can occur while doing DNS
35277 lookups. They are treated in the same way as a timeout, and this option
35278 applies to all of them.
35279 </para>
35280 <para>
35281 <indexterm role="option">
35282 <primary><option>pass_router</option></primary>
35283 </indexterm>
35284 </para>
35285 <informaltable frame="all">
35286 <tgroup cols="4" colsep="0" rowsep="0">
35287 <colspec colwidth="8*" align="left"/>
35288 <colspec colwidth="6*" align="center"/>
35289 <colspec colwidth="6*" align="center"/>
35290 <colspec colwidth="6*" align="right"/>
35291 <tbody>
35292 <row>
35293 <entry><option>pass_router</option></entry>
35294 <entry>Use: <emphasis>routers</emphasis></entry>
35295 <entry>Type: <emphasis>string</emphasis></entry>
35296 <entry>Default: <emphasis>unset</emphasis></entry>
35297 </row>
35298 </tbody>
35299 </tgroup>
35300 </informaltable>
35301 <para>
35302 <indexterm role="concept">
35303 <primary>router</primary>
35304 <secondary>go to after <quote>pass</quote></secondary>
35305 </indexterm>
35306 Routers that recognize the generic <option>self</option> option (<command>dnslookup</command>,
35307 <command>ipliteral</command>, and <command>manualroute</command>) are able to return <quote>pass</quote>, forcing
35308 routing to continue, and overriding a false setting of <option>more</option>. When one of
35309 these routers returns <quote>pass</quote>, the address is normally handed on to the next
35310 router in sequence. This can be changed by setting <option>pass_router</option> to the name
35311 of another router. However (unlike <option>redirect_router</option>) the named router must
35312 be below the current router, to avoid loops. Note that this option applies only
35313 to the special case of <quote>pass</quote>. It does not apply when a router returns
35314 <quote>decline</quote> because it cannot handle an address.
35315 </para>
35316 <para>
35317 <indexterm role="option">
35318 <primary><option>redirect_router</option></primary>
35319 </indexterm>
35320 </para>
35321 <informaltable frame="all">
35322 <tgroup cols="4" colsep="0" rowsep="0">
35323 <colspec colwidth="8*" align="left"/>
35324 <colspec colwidth="6*" align="center"/>
35325 <colspec colwidth="6*" align="center"/>
35326 <colspec colwidth="6*" align="right"/>
35327 <tbody>
35328 <row>
35329 <entry><option>redirect_router</option></entry>
35330 <entry>Use: <emphasis>routers</emphasis></entry>
35331 <entry>Type: <emphasis>string</emphasis></entry>
35332 <entry>Default: <emphasis>unset</emphasis></entry>
35333 </row>
35334 </tbody>
35335 </tgroup>
35336 </informaltable>
35337 <para>
35338 <indexterm role="concept">
35339 <primary>router</primary>
35340 <secondary>start at after redirection</secondary>
35341 </indexterm>
35342 Sometimes an administrator knows that it is pointless to reprocess addresses
35343 generated from alias or forward files with the same router again. For
35344 example, if an alias file translates real names into login ids there is no
35345 point searching the alias file a second time, especially if it is a large file.
35346 </para>
35347 <para>
35348 The <option>redirect_router</option> option can be set to the name of any router instance.
35349 It causes the routing of any generated addresses to start at the named router
35350 instead of at the first router. This option has no effect if the router in
35351 which it is set does not generate new addresses.
35352 </para>
35353 <para>
35354 <indexterm role="option">
35355 <primary><option>require_files</option></primary>
35356 </indexterm>
35357 </para>
35358 <informaltable frame="all">
35359 <tgroup cols="4" colsep="0" rowsep="0">
35360 <colspec colwidth="8*" align="left"/>
35361 <colspec colwidth="6*" align="center"/>
35362 <colspec colwidth="6*" align="center"/>
35363 <colspec colwidth="6*" align="right"/>
35364 <tbody>
35365 <row>
35366 <entry><option>require_files</option></entry>
35367 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
35368 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
35369 <entry>Default: <emphasis>unset</emphasis></entry>
35370 </row>
35371 </tbody>
35372 </tgroup>
35373 </informaltable>
35374 <para>
35375 <indexterm role="concept">
35376 <primary>file</primary>
35377 <secondary>requiring for router</secondary>
35378 </indexterm>
35379 <indexterm role="concept">
35380 <primary>router</primary>
35381 <secondary>requiring file existence</secondary>
35382 </indexterm>
35383 This option provides a general mechanism for predicating the running of a
35384 router on the existence or non-existence of certain files or directories.
35385 Before running a router, as one of its precondition tests, Exim works its way
35386 through the <option>require_files</option> list, expanding each item separately.
35387 </para>
35388 <para>
35389 Because the list is split before expansion, any colons in expansion items must
35390 be doubled, or the facility for using a different list separator must be used
35391 (<xref linkend="SECTlistsepchange"/>).
35392 If any expansion is forced to fail, the item is ignored. Other expansion
35393 failures cause routing of the address to be deferred.
35394 </para>
35395 <para>
35396 If any expanded string is empty, it is ignored. Otherwise, except as described
35397 below, each string must be a fully qualified file path, optionally preceded by
35398 <quote>!</quote>. The paths are passed to the <function>stat()</function> function to test for the
35399 existence of the files or directories. The router is skipped if any paths not
35400 preceded by <quote>!</quote> do not exist, or if any paths preceded by <quote>!</quote> do exist.
35401 </para>
35402 <para>
35403 <indexterm role="concept">
35404 <primary>NFS</primary>
35405 </indexterm>
35406 If <function>stat()</function> cannot determine whether a file exists or not, delivery of
35407 the message is deferred. This can happen when NFS-mounted filesystems are
35408 unavailable.
35409 </para>
35410 <para>
35411 This option is checked after the <option>domains</option>, <option>local_parts</option>, and <option>senders</option>
35412 options, so you cannot use it to check for the existence of a file in which to
35413 look up a domain, local part, or sender. (See section <xref linkend="SECTrouprecon"/> for a
35414 full list of the order in which preconditions are evaluated.) However, as
35415 these options are all expanded, you can use the <option>exists</option> expansion condition
35416 to make such tests. The <option>require_files</option> option is intended for checking files
35417 that the router may be going to use internally, or which are needed by a
35418 transport (e.g., <filename>.procmailrc</filename>).
35419 </para>
35420 <para>
35421 During delivery, the <function>stat()</function> function is run as root, but there is a
35422 facility for some checking of the accessibility of a file by another user.
35423 This is not a proper permissions check, but just a <quote>rough</quote> check that
35424 operates as follows:
35425 </para>
35426 <para>
35427 If an item in a <option>require_files</option> list does not contain any forward slash
35428 characters, it is taken to be the user (and optional group, separated by a
35429 comma) to be checked for subsequent files in the list. If no group is specified
35430 but the user is specified symbolically, the gid associated with the uid is
35431 used. For example:
35432 </para>
35433 <literallayout class="monospaced">
35434 require_files = mail:/some/file
35435 require_files = $local_part:$home/.procmailrc
35436 </literallayout>
35437 <para>
35438 If a user or group name in a <option>require_files</option> list does not exist, the
35439 <option>require_files</option> condition fails.
35440 </para>
35441 <para>
35442 Exim performs the check by scanning along the components of the file path, and
35443 checking the access for the given uid and gid. It checks for <quote>x</quote> access on
35444 directories, and <quote>r</quote> access on the final file. Note that this means that file
35445 access control lists, if the operating system has them, are ignored.
35446 </para>
35447 <para>
35448 <emphasis role="bold">Warning 1</emphasis>: When the router is being run to verify addresses for an
35449 incoming SMTP message, Exim is not running as root, but under its own uid. This
35450 may affect the result of a <option>require_files</option> check. In particular, <function>stat()</function>
35451 may yield the error EACCES (<quote>Permission denied</quote>). This means that the Exim
35452 user is not permitted to read one of the directories on the file&#x2019;s path.
35453 </para>
35454 <para>
35455 <emphasis role="bold">Warning 2</emphasis>: Even when Exim is running as root while delivering a message,
35456 <function>stat()</function> can yield EACCES for a file in an NFS directory that is mounted
35457 without root access. In this case, if a check for access by a particular user
35458 is requested, Exim creates a subprocess that runs as that user, and tries the
35459 check again in that process.
35460 </para>
35461 <para>
35462 The default action for handling an unresolved EACCES is to consider it to
35463 be caused by a configuration error, and routing is deferred because the
35464 existence or non-existence of the file cannot be determined. However, in some
35465 circumstances it may be desirable to treat this condition as if the file did
35466 not exist. If the filename (or the exclamation mark that precedes the filename
35467 for non-existence) is preceded by a plus sign, the EACCES error is treated
35468 as if the file did not exist. For example:
35469 </para>
35470 <literallayout class="monospaced">
35471 require_files = +/some/file
35472 </literallayout>
35473 <para>
35474 If the router is not an essential part of verification (for example, it
35475 handles users&#x2019; <filename>.forward</filename> files), another solution is to set the <option>verify</option>
35476 option false so that the router is skipped when verifying.
35477 </para>
35478 <para>
35479 <indexterm role="option">
35480 <primary><option>retry_use_local_part</option></primary>
35481 </indexterm>
35482 </para>
35483 <informaltable frame="all">
35484 <tgroup cols="4" colsep="0" rowsep="0">
35485 <colspec colwidth="8*" align="left"/>
35486 <colspec colwidth="6*" align="center"/>
35487 <colspec colwidth="6*" align="center"/>
35488 <colspec colwidth="6*" align="right"/>
35489 <tbody>
35490 <row>
35491 <entry><option>retry_use_local_part</option></entry>
35492 <entry>Use: <emphasis>routers</emphasis></entry>
35493 <entry>Type: <emphasis>boolean</emphasis></entry>
35494 <entry>Default: <emphasis>see below</emphasis></entry>
35495 </row>
35496 </tbody>
35497 </tgroup>
35498 </informaltable>
35499 <para>
35500 <indexterm role="concept">
35501 <primary>hints database</primary>
35502 <secondary>retry keys</secondary>
35503 </indexterm>
35504 <indexterm role="concept">
35505 <primary>local part</primary>
35506 <secondary>in retry keys</secondary>
35507 </indexterm>
35508 When a delivery suffers a temporary routing failure, a retry record is created
35509 in Exim&#x2019;s hints database. For addresses whose routing depends only on the
35510 domain, the key for the retry record should not involve the local part, but for
35511 other addresses, both the domain and the local part should be included.
35512 Usually, remote routing is of the former kind, and local routing is of the
35513 latter kind.
35514 </para>
35515 <para>
35516 This option controls whether the local part is used to form the key for retry
35517 hints for addresses that suffer temporary errors while being handled by this
35518 </para>
35519 <para revisionflag="changed">
35520 router. The default value is true for any router that has any of
35521 <option>check_local_user</option>,
35522 <option>local_parts</option>,
35523 <option>condition</option>,
35524 <option>local_part_prefix</option>,
35525 <option>local_part_suffix</option>,
35526 <option>senders</option> or
35527 <option>require_files</option>
35528 </para>
35529 <para>
35530 set, and false otherwise. Note that this option does not apply to hints keys
35531 for transport delays; they are controlled by a generic transport option of the
35532 same name.
35533 </para>
35534 <para>
35535 Failing to set this option when it is needed
35536 (because a remote router handles only some of the local-parts for a domain)
35537 can result in incorrect error messages being generated.
35538 </para>
35539 <para>
35540 The setting of <option>retry_use_local_part</option> applies only to the router on which it
35541 appears. If the router generates child addresses, they are routed
35542 independently; this setting does not become attached to them.
35543 </para>
35544 <para>
35545 <indexterm role="option">
35546 <primary><option>router_home_directory</option></primary>
35547 </indexterm>
35548 </para>
35549 <informaltable frame="all">
35550 <tgroup cols="4" colsep="0" rowsep="0">
35551 <colspec colwidth="8*" align="left"/>
35552 <colspec colwidth="6*" align="center"/>
35553 <colspec colwidth="6*" align="center"/>
35554 <colspec colwidth="6*" align="right"/>
35555 <tbody>
35556 <row>
35557 <entry><option>router_home_directory</option></entry>
35558 <entry>Use: <emphasis>routers</emphasis></entry>
35559 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35560 <entry>Default: <emphasis>unset</emphasis></entry>
35561 </row>
35562 </tbody>
35563 </tgroup>
35564 </informaltable>
35565 <para>
35566 <indexterm role="concept">
35567 <primary>router</primary>
35568 <secondary>home directory for</secondary>
35569 </indexterm>
35570 <indexterm role="concept">
35571 <primary>home directory</primary>
35572 <secondary>for router</secondary>
35573 </indexterm>
35574 <indexterm role="variable">
35575 <primary><varname>$home</varname></primary>
35576 </indexterm>
35577 This option sets a home directory for use while the router is running. (Compare
35578 <option>transport_home_directory</option>, which sets a home directory for later
35579 transporting.) In particular, if used on a <command>redirect</command> router, this option
35580 sets a value for <varname>$home</varname> while a filter is running. The value is expanded;
35581 forced expansion failure causes the option to be ignored &ndash; other failures
35582 cause the router to defer.
35583 </para>
35584 <para>
35585 Expansion of <option>router_home_directory</option> happens immediately after the
35586 <option>check_local_user</option> test (if configured), before any further expansions take
35587 place.
35588 (See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
35589 are evaluated.)
35590 While the router is running, <option>router_home_directory</option> overrides the value of
35591 <varname>$home</varname> that came from <option>check_local_user</option>.
35592 </para>
35593 <para>
35594 When a router accepts an address and assigns it to a local transport (including
35595 the cases when a <command>redirect</command> router generates a pipe, file, or autoreply
35596 delivery), the home directory setting for the transport is taken from the first
35597 of these values that is set:
35598 </para>
35599 <itemizedlist>
35600 <listitem>
35601 <para>
35602 The <option>home_directory</option> option on the transport;
35603 </para>
35604 </listitem>
35605 <listitem>
35606 <para>
35607 The <option>transport_home_directory</option> option on the router;
35608 </para>
35609 </listitem>
35610 <listitem>
35611 <para>
35612 The password data if <option>check_local_user</option> is set on the router;
35613 </para>
35614 </listitem>
35615 <listitem>
35616 <para>
35617 The <option>router_home_directory</option> option on the router.
35618 </para>
35619 </listitem>
35620 </itemizedlist>
35621 <para>
35622 In other words, <option>router_home_directory</option> overrides the password data for the
35623 router, but not for the transport.
35624 </para>
35625 <para>
35626 <indexterm role="option">
35627 <primary><option>self</option></primary>
35628 </indexterm>
35629 </para>
35630 <informaltable frame="all">
35631 <tgroup cols="4" colsep="0" rowsep="0">
35632 <colspec colwidth="8*" align="left"/>
35633 <colspec colwidth="6*" align="center"/>
35634 <colspec colwidth="6*" align="center"/>
35635 <colspec colwidth="6*" align="right"/>
35636 <tbody>
35637 <row>
35638 <entry><option>self</option></entry>
35639 <entry>Use: <emphasis>routers</emphasis></entry>
35640 <entry>Type: <emphasis>string</emphasis></entry>
35641 <entry>Default: <emphasis>freeze</emphasis></entry>
35642 </row>
35643 </tbody>
35644 </tgroup>
35645 </informaltable>
35646 <para>
35647 <indexterm role="concept">
35648 <primary>MX record</primary>
35649 <secondary>pointing to local host</secondary>
35650 </indexterm>
35651 <indexterm role="concept">
35652 <primary>local host</primary>
35653 <secondary>MX pointing to</secondary>
35654 </indexterm>
35655 This option applies to those routers that use a recipient address to find a
35656 list of remote hosts. Currently, these are the <command>dnslookup</command>, <command>ipliteral</command>,
35657 and <command>manualroute</command> routers.
35658 Certain configurations of the <command>queryprogram</command> router can also specify a list
35659 of remote hosts.
35660 Usually such routers are configured to send the message to a remote host via an
35661 <command>smtp</command> transport. The <option>self</option> option specifies what happens when the first
35662 host on the list turns out to be the local host.
35663 The way in which Exim checks for the local host is described in section
35664 <xref linkend="SECTreclocipadd"/>.
35665 </para>
35666 <para>
35667 Normally this situation indicates either an error in Exim&#x2019;s configuration (for
35668 example, the router should be configured not to process this domain), or an
35669 error in the DNS (for example, the MX should not point to this host). For this
35670 reason, the default action is to log the incident, defer the address, and
35671 freeze the message. The following alternatives are provided for use in special
35672 cases:
35673 </para>
35674 <variablelist>
35675 <varlistentry>
35676 <term><option>defer</option></term>
35677 <listitem>
35678 <para>
35679 Delivery of the message is tried again later, but the message is not frozen.
35680 </para>
35681 </listitem></varlistentry>
35682 <varlistentry>
35683 <term><option>reroute</option>: &lt;<emphasis>domain</emphasis>&gt;</term>
35684 <listitem>
35685 <para>
35686 The domain is changed to the given domain, and the address is passed back to
35687 be reprocessed by the routers. No rewriting of headers takes place. This
35688 behaviour is essentially a redirection.
35689 </para>
35690 </listitem></varlistentry>
35691 <varlistentry>
35692 <term><option>reroute: rewrite:</option> &lt;<emphasis>domain</emphasis>&gt;</term>
35693 <listitem>
35694 <para>
35695 The domain is changed to the given domain, and the address is passed back to be
35696 reprocessed by the routers. Any headers that contain the original domain are
35697 rewritten.
35698 </para>
35699 </listitem></varlistentry>
35700 <varlistentry>
35701 <term><option>pass</option></term>
35702 <listitem>
35703 <para>
35704 <indexterm role="option">
35705 <primary><option>more</option></primary>
35706 </indexterm>
35707 <indexterm role="variable">
35708 <primary><varname>$self_hostname</varname></primary>
35709 </indexterm>
35710 The router passes the address to the next router, or to the router named in the
35711 <option>pass_router</option> option if it is set. This overrides <option>no_more</option>. During
35712 subsequent routing and delivery, the variable <varname>$self_hostname</varname> contains the
35713 name of the local host that the router encountered. This can be used to
35714 distinguish between different cases for hosts with multiple names. The
35715 combination
35716 </para>
35717 <literallayout class="monospaced">
35718 self = pass
35719 no_more
35720 </literallayout>
35721 <para>
35722 ensures that only those addresses that routed to the local host are passed on.
35723 Without <option>no_more</option>, addresses that were declined for other reasons would also
35724 be passed to the next router.
35725 </para>
35726 </listitem></varlistentry>
35727 <varlistentry>
35728 <term><option>fail</option></term>
35729 <listitem>
35730 <para>
35731 Delivery fails and an error report is generated.
35732 </para>
35733 </listitem></varlistentry>
35734 <varlistentry>
35735 <term><option>send</option></term>
35736 <listitem>
35737 <para>
35738 <indexterm role="concept">
35739 <primary>local host</primary>
35740 <secondary>sending to</secondary>
35741 </indexterm>
35742 The anomaly is ignored and the address is queued for the transport. This
35743 setting should be used with extreme caution. For an <command>smtp</command> transport, it
35744 makes sense only in cases where the program that is listening on the SMTP port
35745 is not this version of Exim. That is, it must be some other MTA, or Exim with a
35746 different configuration file that handles the domain in another way.
35747 </para>
35748 </listitem></varlistentry>
35749 </variablelist>
35750 <para>
35751 <indexterm role="option">
35752 <primary><option>senders</option></primary>
35753 </indexterm>
35754 </para>
35755 <informaltable frame="all">
35756 <tgroup cols="4" colsep="0" rowsep="0">
35757 <colspec colwidth="8*" align="left"/>
35758 <colspec colwidth="6*" align="center"/>
35759 <colspec colwidth="6*" align="center"/>
35760 <colspec colwidth="6*" align="right"/>
35761 <tbody>
35762 <row>
35763 <entry><option>senders</option></entry>
35764 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
35765 <entry>Type: <emphasis>address list</emphasis>&dagger;<emphasis></emphasis></entry>
35766 <entry>Default: <emphasis>unset</emphasis></entry>
35767 </row>
35768 </tbody>
35769 </tgroup>
35770 </informaltable>
35771 <para>
35772 <indexterm role="concept">
35773 <primary>router</primary>
35774 <secondary>checking senders</secondary>
35775 </indexterm>
35776 If this option is set, the router is skipped unless the message&#x2019;s sender
35777 address matches something on the list.
35778 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
35779 are evaluated.
35780 </para>
35781 <para>
35782 There are issues concerning verification when the running of routers is
35783 dependent on the sender. When Exim is verifying the address in an <option>errors_to</option>
35784 setting, it sets the sender to the null string. When using the <option>-bt</option> option
35785 to check a configuration file, it is necessary also to use the <option>-f</option> option to
35786 set an appropriate sender. For incoming mail, the sender is unset when
35787 verifying the sender, but is available when verifying any recipients. If the
35788 SMTP VRFY command is enabled, it must be used after MAIL if the sender address
35789 matters.
35790 </para>
35791 <para revisionflag="changed">
35792 <indexterm role="option">
35793 <primary><option>set</option></primary>
35794 </indexterm>
35795 </para>
35796 <informaltable frame="all" revisionflag="changed">
35797 <tgroup cols="4" colsep="0" rowsep="0">
35798 <colspec colwidth="8*" align="left"/>
35799 <colspec colwidth="6*" align="center"/>
35800 <colspec colwidth="6*" align="center"/>
35801 <colspec colwidth="6*" align="right"/>
35802 <tbody>
35803 <row>
35804 <entry><option>set</option></entry>
35805 <entry>Use: <emphasis>routers</emphasis></entry>
35806 <entry>Type: <emphasis>string list</emphasis></entry>
35807 <entry>Default: <emphasis>unset</emphasis></entry>
35808 </row>
35809 </tbody>
35810 </tgroup>
35811 </informaltable>
35812 <para revisionflag="changed">
35813 <indexterm role="concept">
35814 <primary>router</primary>
35815 <secondary>variables</secondary>
35816 </indexterm>
35817 This option may be used multiple times on a router;
35818 because of this the list aspect is mostly irrelevant.
35819 The list separator is a semicolon but can be changed in the
35820 usual way.
35821 </para>
35822 <para revisionflag="changed">
35823 Each list-element given must be of the form <quote>name = value</quote>
35824 and the names used must start with the string <quote>r_</quote>.
35825 Values containing a list-separator should have them doubled.
35826 When a router runs, the strings are evaluated in order,
35827 to create variables which are added to the set associated with
35828 the address.
35829 The variable is set with the expansion of the value.
35830 The variables can be used by the router options
35831 (not including any preconditions)
35832 and by the transport.
35833 Later definitions of a given named variable will override former ones.
35834 Variable use is via the usual <varname>$r_...</varname> syntax.
35835 </para>
35836 <para revisionflag="changed">
35837 This is similar to the <option>address_data</option> option, except that
35838 many independent variables can be used, with choice of naming.
35839 </para>
35840 <para>
35841 <indexterm role="option">
35842 <primary><option>translate_ip_address</option></primary>
35843 </indexterm>
35844 </para>
35845 <informaltable frame="all">
35846 <tgroup cols="4" colsep="0" rowsep="0">
35847 <colspec colwidth="8*" align="left"/>
35848 <colspec colwidth="6*" align="center"/>
35849 <colspec colwidth="6*" align="center"/>
35850 <colspec colwidth="6*" align="right"/>
35851 <tbody>
35852 <row>
35853 <entry><option>translate_ip_address</option></entry>
35854 <entry>Use: <emphasis>routers</emphasis></entry>
35855 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35856 <entry>Default: <emphasis>unset</emphasis></entry>
35857 </row>
35858 </tbody>
35859 </tgroup>
35860 </informaltable>
35861 <para>
35862 <indexterm role="concept">
35863 <primary>IP address</primary>
35864 <secondary>translating</secondary>
35865 </indexterm>
35866 <indexterm role="concept">
35867 <primary>packet radio</primary>
35868 </indexterm>
35869 <indexterm role="concept">
35870 <primary>router</primary>
35871 <secondary>IP address translation</secondary>
35872 </indexterm>
35873 There exist some rare networking situations (for example, packet radio) where
35874 it is helpful to be able to translate IP addresses generated by normal routing
35875 mechanisms into other IP addresses, thus performing a kind of manual IP
35876 routing. This should be done only if the normal IP routing of the TCP/IP stack
35877 is inadequate or broken. Because this is an extremely uncommon requirement, the
35878 code to support this option is not included in the Exim binary unless
35879 SUPPORT_TRANSLATE_IP_ADDRESS=yes is set in <filename>Local/Makefile</filename>.
35880 </para>
35881 <para>
35882 <indexterm role="variable">
35883 <primary><varname>$host_address</varname></primary>
35884 </indexterm>
35885 The <option>translate_ip_address</option> string is expanded for every IP address generated
35886 by the router, with the generated address set in <varname>$host_address</varname>. If the
35887 expansion is forced to fail, no action is taken.
35888 For any other expansion error, delivery of the message is deferred.
35889 If the result of the expansion is an IP address, that replaces the original
35890 address; otherwise the result is assumed to be a host name &ndash; this is looked
35891 up using <function>gethostbyname()</function> (or <function>getipnodebyname()</function> when available) to
35892 produce one or more replacement IP addresses. For example, to subvert all IP
35893 addresses in some specific networks, this could be added to a router:
35894 </para>
35895 <literallayout class="monospaced">
35896 translate_ip_address = \
35897   ${lookup{${mask:$host_address/26}}lsearch{/some/file}\
35898     {$value}fail}}
35899 </literallayout>
35900 <para>
35901 The file would contain lines like
35902 </para>
35903 <literallayout class="monospaced">
35904 10.2.3.128/26    some.host
35905 10.8.4.34/26     10.44.8.15
35906 </literallayout>
35907 <para>
35908 You should not make use of this facility unless you really understand what you
35909 are doing.
35910 </para>
35911 <para>
35912 <indexterm role="option">
35913 <primary><option>transport</option></primary>
35914 </indexterm>
35915 </para>
35916 <informaltable frame="all">
35917 <tgroup cols="4" colsep="0" rowsep="0">
35918 <colspec colwidth="8*" align="left"/>
35919 <colspec colwidth="6*" align="center"/>
35920 <colspec colwidth="6*" align="center"/>
35921 <colspec colwidth="6*" align="right"/>
35922 <tbody>
35923 <row>
35924 <entry><option>transport</option></entry>
35925 <entry>Use: <emphasis>routers</emphasis></entry>
35926 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35927 <entry>Default: <emphasis>unset</emphasis></entry>
35928 </row>
35929 </tbody>
35930 </tgroup>
35931 </informaltable>
35932 <para>
35933 This option specifies the transport to be used when a router accepts an address
35934 and sets it up for delivery. A transport is never needed if a router is used
35935 only for verification. The value of the option is expanded at routing time,
35936 after the expansion of <option>errors_to</option>, <option>headers_add</option>, and <option>headers_remove</option>,
35937 and result must be the name of one of the configured transports. If it is not,
35938 delivery is deferred.
35939 </para>
35940 <para>
35941 The <option>transport</option> option is not used by the <command>redirect</command> router, but it does
35942 have some private options that set up transports for pipe and file deliveries
35943 (see chapter <xref linkend="CHAPredirect"/>).
35944 </para>
35945 <para>
35946 <indexterm role="option">
35947 <primary><option>transport_current_directory</option></primary>
35948 </indexterm>
35949 </para>
35950 <informaltable frame="all">
35951 <tgroup cols="4" colsep="0" rowsep="0">
35952 <colspec colwidth="8*" align="left"/>
35953 <colspec colwidth="6*" align="center"/>
35954 <colspec colwidth="6*" align="center"/>
35955 <colspec colwidth="6*" align="right"/>
35956 <tbody>
35957 <row>
35958 <entry><option>transport_current_directory</option></entry>
35959 <entry>Use: <emphasis>routers</emphasis></entry>
35960 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35961 <entry>Default: <emphasis>unset</emphasis></entry>
35962 </row>
35963 </tbody>
35964 </tgroup>
35965 </informaltable>
35966 <para>
35967 <indexterm role="concept">
35968 <primary>current directory for local transport</primary>
35969 </indexterm>
35970 This option associates a current directory with any address that is routed
35971 to a local transport. This can happen either because a transport is
35972 explicitly configured for the router, or because it generates a delivery to a
35973 file or a pipe. During the delivery process (that is, at transport time), this
35974 option string is expanded and is set as the current directory, unless
35975 overridden by a setting on the transport.
35976 If the expansion fails for any reason, including forced failure, an error is
35977 logged, and delivery is deferred.
35978 See chapter <xref linkend="CHAPenvironment"/> for details of the local delivery
35979 environment.
35980 </para>
35981 <para>
35982 <indexterm role="option">
35983 <primary><option>transport_home_directory</option></primary>
35984 </indexterm>
35985 </para>
35986 <informaltable frame="all">
35987 <tgroup cols="4" colsep="0" rowsep="0">
35988 <colspec colwidth="8*" align="left"/>
35989 <colspec colwidth="6*" align="center"/>
35990 <colspec colwidth="6*" align="center"/>
35991 <colspec colwidth="6*" align="right"/>
35992 <tbody>
35993 <row>
35994 <entry><option>transport_home_directory</option></entry>
35995 <entry>Use: <emphasis>routers</emphasis></entry>
35996 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35997 <entry>Default: <emphasis>see below</emphasis></entry>
35998 </row>
35999 </tbody>
36000 </tgroup>
36001 </informaltable>
36002 <para>
36003 <indexterm role="concept">
36004 <primary>home directory</primary>
36005 <secondary>for local transport</secondary>
36006 </indexterm>
36007 This option associates a home directory with any address that is routed to a
36008 local transport. This can happen either because a transport is explicitly
36009 configured for the router, or because it generates a delivery to a file or a
36010 pipe. During the delivery process (that is, at transport time), the option
36011 string is expanded and is set as the home directory, unless overridden by a
36012 setting of <option>home_directory</option> on the transport.
36013 If the expansion fails for any reason, including forced failure, an error is
36014 logged, and delivery is deferred.
36015 </para>
36016 <para>
36017 If the transport does not specify a home directory, and
36018 <option>transport_home_directory</option> is not set for the router, the home directory for
36019 the transport is taken from the password data if <option>check_local_user</option> is set for
36020 the router. Otherwise it is taken from <option>router_home_directory</option> if that option
36021 is set; if not, no home directory is set for the transport.
36022 </para>
36023 <para>
36024 See chapter <xref linkend="CHAPenvironment"/> for further details of the local delivery
36025 environment.
36026 </para>
36027 <para>
36028 <indexterm role="option">
36029 <primary><option>unseen</option></primary>
36030 </indexterm>
36031 </para>
36032 <informaltable frame="all">
36033 <tgroup cols="4" colsep="0" rowsep="0">
36034 <colspec colwidth="8*" align="left"/>
36035 <colspec colwidth="6*" align="center"/>
36036 <colspec colwidth="6*" align="center"/>
36037 <colspec colwidth="6*" align="right"/>
36038 <tbody>
36039 <row>
36040 <entry><option>unseen</option></entry>
36041 <entry>Use: <emphasis>routers</emphasis></entry>
36042 <entry>Type: <emphasis>boolean</emphasis>&dagger;<emphasis></emphasis></entry>
36043 <entry>Default: <emphasis>false</emphasis></entry>
36044 </row>
36045 </tbody>
36046 </tgroup>
36047 </informaltable>
36048 <para>
36049 <indexterm role="concept">
36050 <primary>router</primary>
36051 <secondary>carrying on after success</secondary>
36052 </indexterm>
36053 The result of string expansion for this option must be a valid boolean value,
36054 that is, one of the strings <quote>yes</quote>, <quote>no</quote>, <quote>true</quote>, or <quote>false</quote>. Any other
36055 result causes an error, and delivery is deferred. If the expansion is forced to
36056 fail, the default value for the option (false) is used. Other failures cause
36057 delivery to be deferred.
36058 </para>
36059 <para>
36060 When this option is set true, routing does not cease if the router accepts the
36061 address. Instead, a copy of the incoming address is passed to the next router,
36062 overriding a false setting of <option>more</option>. There is little point in setting
36063 <option>more</option> false if <option>unseen</option> is always true, but it may be useful in cases when
36064 the value of <option>unseen</option> contains expansion items (and therefore, presumably, is
36065 sometimes true and sometimes false).
36066 </para>
36067 <para>
36068 <indexterm role="concept">
36069 <primary>copy of message (<option>unseen</option> option)</primary>
36070 </indexterm>
36071 Setting the <option>unseen</option> option has a similar effect to the <option>unseen</option> command
36072 qualifier in filter files. It can be used to cause copies of messages to be
36073 delivered to some other destination, while also carrying out a normal delivery.
36074 In effect, the current address is made into a <quote>parent</quote> that has two children
36075 &ndash; one that is delivered as specified by this router, and a clone that goes on
36076 to be routed further. For this reason, <option>unseen</option> may not be combined with the
36077 <option>one_time</option> option in a <command>redirect</command> router.
36078 </para>
36079 <para>
36080 <emphasis role="bold">Warning</emphasis>: Header lines added to the address (or specified for removal) by
36081 this router or by previous routers affect the <quote>unseen</quote> copy of the message
36082 only. The clone that continues to be processed by further routers starts with
36083 no added headers and none specified for removal. For a <option>redirect</option> router, if
36084 a generated address is the same as the incoming address, this can lead to
36085 duplicate addresses with different header modifications. Exim does not do
36086 duplicate deliveries (except, in certain circumstances, to pipes -- see section
36087 <xref linkend="SECTdupaddr"/>), but it is undefined which of the duplicates is discarded,
36088 so this ambiguous situation should be avoided. The <option>repeat_use</option> option of the
36089 <option>redirect</option> router may be of help.
36090 </para>
36091 <para>
36092 Unlike the handling of header modifications, any data that was set by the
36093 <option>address_data</option> option in the current or previous routers <emphasis>is</emphasis> passed on to
36094 subsequent routers.
36095 </para>
36096 <para>
36097 <indexterm role="option">
36098 <primary><option>user</option></primary>
36099 </indexterm>
36100 </para>
36101 <informaltable frame="all">
36102 <tgroup cols="4" colsep="0" rowsep="0">
36103 <colspec colwidth="8*" align="left"/>
36104 <colspec colwidth="6*" align="center"/>
36105 <colspec colwidth="6*" align="center"/>
36106 <colspec colwidth="6*" align="right"/>
36107 <tbody>
36108 <row>
36109 <entry><option>user</option></entry>
36110 <entry>Use: <emphasis>routers</emphasis></entry>
36111 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36112 <entry>Default: <emphasis>see below</emphasis></entry>
36113 </row>
36114 </tbody>
36115 </tgroup>
36116 </informaltable>
36117 <para>
36118 <indexterm role="concept">
36119 <primary>uid (user id)</primary>
36120 <secondary>local delivery</secondary>
36121 </indexterm>
36122 <indexterm role="concept">
36123 <primary>local transports</primary>
36124 <secondary>uid and gid</secondary>
36125 </indexterm>
36126 <indexterm role="concept">
36127 <primary>transport</primary>
36128 <secondary>local</secondary>
36129 </indexterm>
36130 <indexterm role="concept">
36131 <primary>router</primary>
36132 <secondary>user for filter processing</secondary>
36133 </indexterm>
36134 <indexterm role="concept">
36135 <primary>filter</primary>
36136 <secondary>user for processing</secondary>
36137 </indexterm>
36138 When a router queues an address for a transport, and the transport does not
36139 specify a user, the user given here is used when running the delivery process.
36140 The user may be specified numerically or by name. If expansion fails, the
36141 error is logged and delivery is deferred.
36142 This user is also used by the <command>redirect</command> router when running a filter file.
36143 The default is unset, except when <option>check_local_user</option> is set. In this case,
36144 the default is taken from the password information. If the user is specified as
36145 a name, and <option>group</option> is not set, the group associated with the user is used.
36146 See also <option>initgroups</option> and <option>group</option> and the discussion in chapter
36147 <xref linkend="CHAPenvironment"/>.
36148 </para>
36149 <para>
36150 <indexterm role="option">
36151 <primary><option>verify</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>verify</option></entry>
36163 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
36164 <entry>Type: <emphasis>boolean</emphasis></entry>
36165 <entry>Default: <emphasis>true</emphasis></entry>
36166 </row>
36167 </tbody>
36168 </tgroup>
36169 </informaltable>
36170 <para>
36171 Setting this option has the effect of setting <option>verify_sender</option> and
36172 <option>verify_recipient</option> to the same value.
36173 </para>
36174 <para>
36175 <indexterm role="option">
36176 <primary><option>verify_only</option></primary>
36177 </indexterm>
36178 </para>
36179 <informaltable frame="all">
36180 <tgroup cols="4" colsep="0" rowsep="0">
36181 <colspec colwidth="8*" align="left"/>
36182 <colspec colwidth="6*" align="center"/>
36183 <colspec colwidth="6*" align="center"/>
36184 <colspec colwidth="6*" align="right"/>
36185 <tbody>
36186 <row>
36187 <entry><option>verify_only</option></entry>
36188 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
36189 <entry>Type: <emphasis>boolean</emphasis></entry>
36190 <entry>Default: <emphasis>false</emphasis></entry>
36191 </row>
36192 </tbody>
36193 </tgroup>
36194 </informaltable>
36195 <para>
36196 <indexterm role="concept">
36197 <primary>EXPN</primary>
36198 <secondary>with <option>verify_only</option></secondary>
36199 </indexterm>
36200 <indexterm role="option">
36201 <primary><option>-bv</option></primary>
36202 </indexterm>
36203 <indexterm role="concept">
36204 <primary>router</primary>
36205 <secondary>used only when verifying</secondary>
36206 </indexterm>
36207 If this option is set, the router is used only when verifying an address,
36208 delivering in cutthrough mode or
36209 testing with the <option>-bv</option> option, not when actually doing a delivery, testing
36210 with the <option>-bt</option> option, or running the SMTP EXPN command. It can be further
36211 restricted to verifying only senders or recipients by means of
36212 <option>verify_sender</option> and <option>verify_recipient</option>.
36213 </para>
36214 <para>
36215 <emphasis role="bold">Warning</emphasis>: When the router is being run to verify addresses for an incoming
36216 SMTP message, Exim is not running as root, but under its own uid. If the router
36217 accesses any files, you need to make sure that they are accessible to the Exim
36218 user or group.
36219 </para>
36220 <para>
36221 <indexterm role="option">
36222 <primary><option>verify_recipient</option></primary>
36223 </indexterm>
36224 </para>
36225 <informaltable frame="all">
36226 <tgroup cols="4" colsep="0" rowsep="0">
36227 <colspec colwidth="8*" align="left"/>
36228 <colspec colwidth="6*" align="center"/>
36229 <colspec colwidth="6*" align="center"/>
36230 <colspec colwidth="6*" align="right"/>
36231 <tbody>
36232 <row>
36233 <entry><option>verify_recipient</option></entry>
36234 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
36235 <entry>Type: <emphasis>boolean</emphasis></entry>
36236 <entry>Default: <emphasis>true</emphasis></entry>
36237 </row>
36238 </tbody>
36239 </tgroup>
36240 </informaltable>
36241 <para>
36242 If this option is false, the router is skipped when verifying recipient
36243 addresses,
36244 delivering in cutthrough mode
36245 or testing recipient verification using <option>-bv</option>.
36246 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
36247 are evaluated.
36248 See also the <varname>$verify_mode</varname> variable.
36249 </para>
36250 <para>
36251 <indexterm role="option">
36252 <primary><option>verify_sender</option></primary>
36253 </indexterm>
36254 </para>
36255 <informaltable frame="all">
36256 <tgroup cols="4" colsep="0" rowsep="0">
36257 <colspec colwidth="8*" align="left"/>
36258 <colspec colwidth="6*" align="center"/>
36259 <colspec colwidth="6*" align="center"/>
36260 <colspec colwidth="6*" align="right"/>
36261 <tbody>
36262 <row>
36263 <entry><option>verify_sender</option></entry>
36264 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
36265 <entry>Type: <emphasis>boolean</emphasis></entry>
36266 <entry>Default: <emphasis>true</emphasis></entry>
36267 </row>
36268 </tbody>
36269 </tgroup>
36270 </informaltable>
36271 <para>
36272 If this option is false, the router is skipped when verifying sender addresses
36273 or testing sender verification using <option>-bvs</option>.
36274 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
36275 are evaluated.
36276 See also the <varname>$verify_mode</varname> variable.
36277 <indexterm role="concept" startref="IIDgenoprou1" class="endofrange"/>
36278 <indexterm role="concept" startref="IIDgenoprou2" class="endofrange"/>
36279 </para>
36280 </chapter>
36281
36282 <chapter id="CHID4">
36283 <title>The accept router</title>
36284 <para>
36285 <indexterm role="concept">
36286 <primary><command>accept</command> router</primary>
36287 </indexterm>
36288 <indexterm role="concept">
36289 <primary>routers</primary>
36290 <secondary><command>accept</command></secondary>
36291 </indexterm>
36292 The <command>accept</command> router has no private options of its own. Unless it is being
36293 used purely for verification (see <option>verify_only</option>) a transport is required to
36294 be defined by the generic <option>transport</option> option. If the preconditions that are
36295 specified by generic options are met, the router accepts the address and queues
36296 it for the given transport. The most common use of this router is for setting
36297 up deliveries to local mailboxes. For example:
36298 </para>
36299 <literallayout class="monospaced">
36300 localusers:
36301   driver = accept
36302   domains = mydomain.example
36303   check_local_user
36304   transport = local_delivery
36305 </literallayout>
36306 <para>
36307 The <option>domains</option> condition in this example checks the domain of the address, and
36308 <option>check_local_user</option> checks that the local part is the login of a local user.
36309 When both preconditions are met, the <command>accept</command> router runs, and queues the
36310 address for the <command>local_delivery</command> transport.
36311 </para>
36312 </chapter>
36313
36314 <chapter id="CHAPdnslookup">
36315 <title>The dnslookup router</title>
36316 <para>
36317 <indexterm role="concept" id="IIDdnsrou1" class="startofrange">
36318 <primary><command>dnslookup</command> router</primary>
36319 </indexterm>
36320 <indexterm role="concept" id="IIDdnsrou2" class="startofrange">
36321 <primary>routers</primary>
36322 <secondary><command>dnslookup</command></secondary>
36323 </indexterm>
36324 The <command>dnslookup</command> router looks up the hosts that handle mail for the
36325 recipient&#x2019;s domain in the DNS. A transport must always be set for this router,
36326 unless <option>verify_only</option> is set.
36327 </para>
36328 <para>
36329 If SRV support is configured (see <option>check_srv</option> below), Exim first searches for
36330 SRV records. If none are found, or if SRV support is not configured,
36331 MX records are looked up. If no MX records exist, address records are sought.
36332 However, <option>mx_domains</option> can be set to disable the direct use of address
36333 records.
36334 </para>
36335 <para>
36336 MX records of equal priority are sorted by Exim into a random order. Exim then
36337 looks for address records for the host names obtained from MX or SRV records.
36338 When a host has more than one IP address, they are sorted into a random order,
36339 except that IPv6 addresses are sorted before IPv4 addresses. If all the
36340 IP addresses found are discarded by a setting of the <option>ignore_target_hosts</option>
36341 generic option, the router declines.
36342 </para>
36343 <para>
36344 Unless they have the highest priority (lowest MX value), MX records that point
36345 to the local host, or to any host name that matches <option>hosts_treat_as_local</option>,
36346 are discarded, together with any other MX records of equal or lower priority.
36347 </para>
36348 <para>
36349 <indexterm role="concept">
36350 <primary>MX record</primary>
36351 <secondary>pointing to local host</secondary>
36352 </indexterm>
36353 <indexterm role="concept">
36354 <primary>local host</primary>
36355 <secondary>MX pointing to</secondary>
36356 </indexterm>
36357 <indexterm role="option">
36358 <primary><option>self</option></primary>
36359 <secondary>in <command>dnslookup</command> router</secondary>
36360 </indexterm>
36361 If the host pointed to by the highest priority MX record, or looked up as an
36362 address record, is the local host, or matches <option>hosts_treat_as_local</option>, what
36363 happens is controlled by the generic <option>self</option> option.
36364 </para>
36365 <section id="SECTprowitdnsloo">
36366 <title>Problems with DNS lookups</title>
36367 <para>
36368 There have been problems with DNS servers when SRV records are looked up.
36369 Some misbehaving servers return a DNS error or timeout when a non-existent
36370 SRV record is sought. Similar problems have in the past been reported for
36371 MX records. The global <option>dns_again_means_nonexist</option> option can help with this
36372 problem, but it is heavy-handed because it is a global option.
36373 </para>
36374 <para>
36375 For this reason, there are two options, <option>srv_fail_domains</option> and
36376 <option>mx_fail_domains</option>, that control what happens when a DNS lookup in a
36377 <command>dnslookup</command> router results in a DNS failure or a <quote>try again</quote> response. If
36378 an attempt to look up an SRV or MX record causes one of these results, and the
36379 domain matches the relevant list, Exim behaves as if the DNS had responded <quote>no
36380 such record</quote>. In the case of an SRV lookup, this means that the router
36381 proceeds to look for MX records; in the case of an MX lookup, it proceeds to
36382 look for A or AAAA records, unless the domain matches <option>mx_domains</option>, in which
36383 case routing fails.
36384 </para>
36385 </section>
36386 <section id="SECTdnslookupdecline">
36387 <title>Declining addresses by dnslookup</title>
36388 <para>
36389 <indexterm role="concept">
36390 <primary><command>dnslookup</command> router</primary>
36391 <secondary>declines</secondary>
36392 </indexterm>
36393 There are a few cases where a <command>dnslookup</command> router will decline to accept
36394 an address; if such a router is expected to handle "all remaining non-local
36395 domains", then it is important to set <option>no_more</option>.
36396 </para>
36397 <para>
36398 The router will defer rather than decline if the domain
36399 is found in the <option>fail_defer_domains</option> router option.
36400 </para>
36401 <para>
36402 Reasons for a <command>dnslookup</command> router to decline currently include:
36403 </para>
36404 <itemizedlist>
36405 <listitem>
36406 <para>
36407 The domain does not exist in DNS
36408 </para>
36409 </listitem>
36410 <listitem>
36411 <para>
36412 The domain exists but the MX record&#x2019;s host part is just "."; this is a common
36413 convention (borrowed from SRV) used to indicate that there is no such service
36414 for this domain and to not fall back to trying A/AAAA records.
36415 </para>
36416 </listitem>
36417 <listitem>
36418 <para>
36419 Ditto, but for SRV records, when <option>check_srv</option> is set on this router.
36420 </para>
36421 </listitem>
36422 <listitem>
36423 <para>
36424 MX record points to a non-existent host.
36425 </para>
36426 </listitem>
36427 <listitem>
36428 <para>
36429 MX record points to an IP address and the main section option
36430 <option>allow_mx_to_ip</option> is not set.
36431 </para>
36432 </listitem>
36433 <listitem>
36434 <para>
36435 MX records exist and point to valid hosts, but all hosts resolve only to
36436 addresses blocked by the <option>ignore_target_hosts</option> generic option on this router.
36437 </para>
36438 </listitem>
36439 <listitem>
36440 <para>
36441 The domain is not syntactically valid (see also <option>allow_utf8_domains</option> and
36442 <option>dns_check_names_pattern</option> for handling one variant of this)
36443 </para>
36444 </listitem>
36445 <listitem>
36446 <para>
36447 <option>check_secondary_mx</option> is set on this router but the local host can
36448 not be found in the MX records (see below)
36449 </para>
36450 </listitem>
36451 </itemizedlist>
36452 </section>
36453 <section id="SECID118">
36454 <title>Private options for dnslookup</title>
36455 <para>
36456 <indexterm role="concept">
36457 <primary>options</primary>
36458 <secondary><command>dnslookup</command> router</secondary>
36459 </indexterm>
36460 The private options for the <command>dnslookup</command> router are as follows:
36461 </para>
36462 <para>
36463 <indexterm role="option">
36464 <primary><option>check_secondary_mx</option></primary>
36465 </indexterm>
36466 </para>
36467 <informaltable frame="all">
36468 <tgroup cols="4" colsep="0" rowsep="0">
36469 <colspec colwidth="8*" align="left"/>
36470 <colspec colwidth="6*" align="center"/>
36471 <colspec colwidth="6*" align="center"/>
36472 <colspec colwidth="6*" align="right"/>
36473 <tbody>
36474 <row>
36475 <entry><option>check_secondary_mx</option></entry>
36476 <entry>Use: <emphasis>dnslookup</emphasis></entry>
36477 <entry>Type: <emphasis>boolean</emphasis></entry>
36478 <entry>Default: <emphasis>false</emphasis></entry>
36479 </row>
36480 </tbody>
36481 </tgroup>
36482 </informaltable>
36483 <para>
36484 <indexterm role="concept">
36485 <primary>MX record</primary>
36486 <secondary>checking for secondary</secondary>
36487 </indexterm>
36488 If this option is set, the router declines unless the local host is found in
36489 (and removed from) the list of hosts obtained by MX lookup. This can be used to
36490 process domains for which the local host is a secondary mail exchanger
36491 differently to other domains. The way in which Exim decides whether a host is
36492 the local host is described in section <xref linkend="SECTreclocipadd"/>.
36493 </para>
36494 <para>
36495 <indexterm role="option">
36496 <primary><option>check_srv</option></primary>
36497 </indexterm>
36498 </para>
36499 <informaltable frame="all">
36500 <tgroup cols="4" colsep="0" rowsep="0">
36501 <colspec colwidth="8*" align="left"/>
36502 <colspec colwidth="6*" align="center"/>
36503 <colspec colwidth="6*" align="center"/>
36504 <colspec colwidth="6*" align="right"/>
36505 <tbody>
36506 <row>
36507 <entry><option>check_srv</option></entry>
36508 <entry>Use: <emphasis>dnslookup</emphasis></entry>
36509 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36510 <entry>Default: <emphasis>unset</emphasis></entry>
36511 </row>
36512 </tbody>
36513 </tgroup>
36514 </informaltable>
36515 <para>
36516 <indexterm role="concept">
36517 <primary>SRV record</primary>
36518 <secondary>enabling use of</secondary>
36519 </indexterm>
36520 The <command>dnslookup</command> router supports the use of SRV records (see RFC 2782) in
36521 addition to MX and address records. The support is disabled by default. To
36522 enable SRV support, set the <option>check_srv</option> option to the name of the service
36523 required. For example,
36524 </para>
36525 <literallayout class="monospaced">
36526 check_srv = smtp
36527 </literallayout>
36528 <para>
36529 looks for SRV records that refer to the normal smtp service. The option is
36530 expanded, so the service name can vary from message to message or address
36531 to address. This might be helpful if SRV records are being used for a
36532 submission service. If the expansion is forced to fail, the <option>check_srv</option>
36533 option is ignored, and the router proceeds to look for MX records in the
36534 normal way.
36535 </para>
36536 <para>
36537 When the expansion succeeds, the router searches first for SRV records for
36538 the given service (it assumes TCP protocol). A single SRV record with a
36539 host name that consists of just a single dot indicates <quote>no such service for
36540 this domain</quote>; if this is encountered, the router declines. If other kinds of
36541 SRV record are found, they are used to construct a host list for delivery
36542 according to the rules of RFC 2782. MX records are not sought in this case.
36543 </para>
36544 <para>
36545 When no SRV records are found, MX records (and address records) are sought in
36546 the traditional way. In other words, SRV records take precedence over MX
36547 records, just as MX records take precedence over address records. Note that
36548 this behaviour is not sanctioned by RFC 2782, though a previous draft RFC
36549 defined it. It is apparently believed that MX records are sufficient for email
36550 and that SRV records should not be used for this purpose. However, SRV records
36551 have an additional <quote>weight</quote> feature which some people might find useful when
36552 trying to split an SMTP load between hosts of different power.
36553 </para>
36554 <para>
36555 See section <xref linkend="SECTprowitdnsloo"/> above for a discussion of Exim&#x2019;s behaviour
36556 when there is a DNS lookup error.
36557 </para>
36558 <para>
36559 <indexterm role="option">
36560 <primary><option>fail_defer_domains</option></primary>
36561 </indexterm>
36562 </para>
36563 <informaltable frame="all">
36564 <tgroup cols="4" colsep="0" rowsep="0">
36565 <colspec colwidth="8*" align="left"/>
36566 <colspec colwidth="6*" align="center"/>
36567 <colspec colwidth="6*" align="center"/>
36568 <colspec colwidth="6*" align="right"/>
36569 <tbody>
36570 <row>
36571 <entry><option>fail_defer_domains</option></entry>
36572 <entry>Use: <emphasis>dnslookup</emphasis></entry>
36573 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
36574 <entry>Default: <emphasis>unset</emphasis></entry>
36575 </row>
36576 </tbody>
36577 </tgroup>
36578 </informaltable>
36579 <para>
36580 <indexterm role="concept">
36581 <primary>MX record</primary>
36582 <secondary>not found</secondary>
36583 </indexterm>
36584 DNS lookups for domains matching <option>fail_defer_domains</option>
36585 which find no matching record will cause the router to defer
36586 rather than the default behaviour of decline.
36587 This maybe be useful for queueing messages for a newly created
36588 domain while the DNS configuration is not ready.
36589 However, it will result in any message with mistyped domains
36590 also being queued.
36591 </para>
36592 <para>
36593 <indexterm role="option">
36594 <primary><option>ipv4_only</option></primary>
36595 </indexterm>
36596 </para>
36597 <informaltable frame="all">
36598 <tgroup cols="4" colsep="0" rowsep="0">
36599 <colspec colwidth="8*" align="left"/>
36600 <colspec colwidth="6*" align="center"/>
36601 <colspec colwidth="6*" align="center"/>
36602 <colspec colwidth="6*" align="right"/>
36603 <tbody>
36604 <row>
36605 <entry><option>ipv4_only</option></entry>
36606 <entry>Use: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36607 <entry>Type: <emphasis>unset</emphasis></entry>
36608 <entry>Default: <emphasis></emphasis></entry>
36609 </row>
36610 </tbody>
36611 </tgroup>
36612 </informaltable>
36613 <para>
36614 <indexterm role="concept">
36615 <primary>IPv6</primary>
36616 <secondary>disabling</secondary>
36617 </indexterm>
36618 <indexterm role="concept">
36619 <primary>DNS</primary>
36620 <secondary>IPv6 disabling</secondary>
36621 </indexterm>
36622 The string is expanded, and if the result is anything but a forced failure,
36623 or an empty string, or one of the strings “0” or “no” or “false”
36624 (checked without regard to the case of the letters),
36625 only A records are used.
36626 </para>
36627 <para>
36628 <indexterm role="option">
36629 <primary><option>ipv4_prefer</option></primary>
36630 </indexterm>
36631 </para>
36632 <informaltable frame="all">
36633 <tgroup cols="4" colsep="0" rowsep="0">
36634 <colspec colwidth="8*" align="left"/>
36635 <colspec colwidth="6*" align="center"/>
36636 <colspec colwidth="6*" align="center"/>
36637 <colspec colwidth="6*" align="right"/>
36638 <tbody>
36639 <row>
36640 <entry><option>ipv4_prefer</option></entry>
36641 <entry>Use: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36642 <entry>Type: <emphasis>unset</emphasis></entry>
36643 <entry>Default: <emphasis></emphasis></entry>
36644 </row>
36645 </tbody>
36646 </tgroup>
36647 </informaltable>
36648 <para>
36649 <indexterm role="concept">
36650 <primary>IPv4</primary>
36651 <secondary>preference</secondary>
36652 </indexterm>
36653 <indexterm role="concept">
36654 <primary>DNS</primary>
36655 <secondary>IPv4 preference</secondary>
36656 </indexterm>
36657 The string is expanded, and if the result is anything but a forced failure,
36658 or an empty string, or one of the strings “0” or “no” or “false”
36659 (checked without regard to the case of the letters),
36660 A records are sorted before AAAA records (inverting the default).
36661 </para>
36662 <para>
36663 <indexterm role="option">
36664 <primary><option>mx_domains</option></primary>
36665 </indexterm>
36666 </para>
36667 <informaltable frame="all">
36668 <tgroup cols="4" colsep="0" rowsep="0">
36669 <colspec colwidth="8*" align="left"/>
36670 <colspec colwidth="6*" align="center"/>
36671 <colspec colwidth="6*" align="center"/>
36672 <colspec colwidth="6*" align="right"/>
36673 <tbody>
36674 <row>
36675 <entry><option>mx_domains</option></entry>
36676 <entry>Use: <emphasis>dnslookup</emphasis></entry>
36677 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
36678 <entry>Default: <emphasis>unset</emphasis></entry>
36679 </row>
36680 </tbody>
36681 </tgroup>
36682 </informaltable>
36683 <para>
36684 <indexterm role="concept">
36685 <primary>MX record</primary>
36686 <secondary>required to exist</secondary>
36687 </indexterm>
36688 <indexterm role="concept">
36689 <primary>SRV record</primary>
36690 <secondary>required to exist</secondary>
36691 </indexterm>
36692 A domain that matches <option>mx_domains</option> is required to have either an MX or an SRV
36693 record in order to be recognized. (The name of this option could be improved.)
36694 For example, if all the mail hosts in <emphasis>fict.example</emphasis> are known to have MX
36695 records, except for those in <emphasis>discworld.fict.example</emphasis>, you could use this
36696 setting:
36697 </para>
36698 <literallayout class="monospaced">
36699 mx_domains = ! *.discworld.fict.example : *.fict.example
36700 </literallayout>
36701 <para>
36702 This specifies that messages addressed to a domain that matches the list but
36703 has no MX record should be bounced immediately instead of being routed using
36704 the address record.
36705 </para>
36706 <para>
36707 <indexterm role="option">
36708 <primary><option>mx_fail_domains</option></primary>
36709 </indexterm>
36710 </para>
36711 <informaltable frame="all">
36712 <tgroup cols="4" colsep="0" rowsep="0">
36713 <colspec colwidth="8*" align="left"/>
36714 <colspec colwidth="6*" align="center"/>
36715 <colspec colwidth="6*" align="center"/>
36716 <colspec colwidth="6*" align="right"/>
36717 <tbody>
36718 <row>
36719 <entry><option>mx_fail_domains</option></entry>
36720 <entry>Use: <emphasis>dnslookup</emphasis></entry>
36721 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
36722 <entry>Default: <emphasis>unset</emphasis></entry>
36723 </row>
36724 </tbody>
36725 </tgroup>
36726 </informaltable>
36727 <para>
36728 If the DNS lookup for MX records for one of the domains in this list causes a
36729 DNS lookup error, Exim behaves as if no MX records were found. See section
36730 <xref linkend="SECTprowitdnsloo"/> for more discussion.
36731 </para>
36732 <para>
36733 <indexterm role="option">
36734 <primary><option>qualify_single</option></primary>
36735 </indexterm>
36736 </para>
36737 <informaltable frame="all">
36738 <tgroup cols="4" colsep="0" rowsep="0">
36739 <colspec colwidth="8*" align="left"/>
36740 <colspec colwidth="6*" align="center"/>
36741 <colspec colwidth="6*" align="center"/>
36742 <colspec colwidth="6*" align="right"/>
36743 <tbody>
36744 <row>
36745 <entry><option>qualify_single</option></entry>
36746 <entry>Use: <emphasis>dnslookup</emphasis></entry>
36747 <entry>Type: <emphasis>boolean</emphasis></entry>
36748 <entry>Default: <emphasis>true</emphasis></entry>
36749 </row>
36750 </tbody>
36751 </tgroup>
36752 </informaltable>
36753 <para>
36754 <indexterm role="concept">
36755 <primary>DNS</primary>
36756 <secondary>resolver options</secondary>
36757 </indexterm>
36758 <indexterm role="concept">
36759 <primary>DNS</primary>
36760 <secondary>qualifying single-component names</secondary>
36761 </indexterm>
36762 When this option is true, the resolver option RES_DEFNAMES is set for DNS
36763 lookups. Typically, but not standardly, this causes the resolver to qualify
36764 single-component names with the default domain. For example, on a machine
36765 called <emphasis>dictionary.ref.example</emphasis>, the domain <emphasis>thesaurus</emphasis> would be changed to
36766 <emphasis>thesaurus.ref.example</emphasis> inside the resolver. For details of what your
36767 resolver actually does, consult your man pages for <emphasis>resolver</emphasis> and
36768 <emphasis>resolv.conf</emphasis>.
36769 </para>
36770 <para>
36771 <indexterm role="option">
36772 <primary><option>rewrite_headers</option></primary>
36773 </indexterm>
36774 </para>
36775 <informaltable frame="all">
36776 <tgroup cols="4" colsep="0" rowsep="0">
36777 <colspec colwidth="8*" align="left"/>
36778 <colspec colwidth="6*" align="center"/>
36779 <colspec colwidth="6*" align="center"/>
36780 <colspec colwidth="6*" align="right"/>
36781 <tbody>
36782 <row>
36783 <entry><option>rewrite_headers</option></entry>
36784 <entry>Use: <emphasis>dnslookup</emphasis></entry>
36785 <entry>Type: <emphasis>boolean</emphasis></entry>
36786 <entry>Default: <emphasis>true</emphasis></entry>
36787 </row>
36788 </tbody>
36789 </tgroup>
36790 </informaltable>
36791 <para>
36792 <indexterm role="concept">
36793 <primary>rewriting</primary>
36794 <secondary>header lines</secondary>
36795 </indexterm>
36796 <indexterm role="concept">
36797 <primary>header lines</primary>
36798 <secondary>rewriting</secondary>
36799 </indexterm>
36800 If the domain name in the address that is being processed is not fully
36801 qualified, it may be expanded to its full form by a DNS lookup. For example, if
36802 an address is specified as <emphasis>dormouse@teaparty</emphasis>, the domain might be
36803 expanded to <emphasis>teaparty.wonderland.fict.example</emphasis>. Domain expansion can also
36804 occur as a result of setting the <option>widen_domains</option> option. If
36805 <option>rewrite_headers</option> is true, all occurrences of the abbreviated domain name in
36806 any <emphasis>Bcc:</emphasis>, <emphasis>Cc:</emphasis>, <emphasis>From:</emphasis>, <emphasis>Reply-to:</emphasis>, <emphasis>Sender:</emphasis>, and <emphasis>To:</emphasis>
36807 header lines of the message are rewritten with the full domain name.
36808 </para>
36809 <para>
36810 This option should be turned off only when it is known that no message is
36811 ever going to be sent outside an environment where the abbreviation makes
36812 sense.
36813 </para>
36814 <para>
36815 When an MX record is looked up in the DNS and matches a wildcard record, name
36816 servers normally return a record containing the name that has been looked up,
36817 making it impossible to detect whether a wildcard was present or not. However,
36818 some name servers have recently been seen to return the wildcard entry. If the
36819 name returned by a DNS lookup begins with an asterisk, it is not used for
36820 header rewriting.
36821 </para>
36822 <para>
36823 <indexterm role="option">
36824 <primary><option>same_domain_copy_routing</option></primary>
36825 </indexterm>
36826 </para>
36827 <informaltable frame="all">
36828 <tgroup cols="4" colsep="0" rowsep="0">
36829 <colspec colwidth="8*" align="left"/>
36830 <colspec colwidth="6*" align="center"/>
36831 <colspec colwidth="6*" align="center"/>
36832 <colspec colwidth="6*" align="right"/>
36833 <tbody>
36834 <row>
36835 <entry><option>same_domain_copy_routing</option></entry>
36836 <entry>Use: <emphasis>dnslookup</emphasis></entry>
36837 <entry>Type: <emphasis>boolean</emphasis></entry>
36838 <entry>Default: <emphasis>false</emphasis></entry>
36839 </row>
36840 </tbody>
36841 </tgroup>
36842 </informaltable>
36843 <para>
36844 <indexterm role="concept">
36845 <primary>address</primary>
36846 <secondary>copying routing</secondary>
36847 </indexterm>
36848 Addresses with the same domain are normally routed by the <command>dnslookup</command> router
36849 to the same list of hosts. However, this cannot be presumed, because the router
36850 options and preconditions may refer to the local part of the address. By
36851 default, therefore, Exim routes each address in a message independently. DNS
36852 servers run caches, so repeated DNS lookups are not normally expensive, and in
36853 any case, personal messages rarely have more than a few recipients.
36854 </para>
36855 <para>
36856 If you are running mailing lists with large numbers of subscribers at the same
36857 domain, and you are using a <command>dnslookup</command> router which is independent of the
36858 local part, you can set <option>same_domain_copy_routing</option> to bypass repeated DNS
36859 lookups for identical domains in one message. In this case, when <command>dnslookup</command>
36860 routes an address to a remote transport, any other unrouted addresses in the
36861 message that have the same domain are automatically given the same routing
36862 without processing them independently,
36863 provided the following conditions are met:
36864 </para>
36865 <itemizedlist>
36866 <listitem>
36867 <para>
36868 No router that processed the address specified <option>headers_add</option> or
36869 <option>headers_remove</option>.
36870 </para>
36871 </listitem>
36872 <listitem>
36873 <para>
36874 The router did not change the address in any way, for example, by <quote>widening</quote>
36875 the domain.
36876 </para>
36877 </listitem>
36878 </itemizedlist>
36879 <para>
36880 <indexterm role="option">
36881 <primary><option>search_parents</option></primary>
36882 </indexterm>
36883 </para>
36884 <informaltable frame="all">
36885 <tgroup cols="4" colsep="0" rowsep="0">
36886 <colspec colwidth="8*" align="left"/>
36887 <colspec colwidth="6*" align="center"/>
36888 <colspec colwidth="6*" align="center"/>
36889 <colspec colwidth="6*" align="right"/>
36890 <tbody>
36891 <row>
36892 <entry><option>search_parents</option></entry>
36893 <entry>Use: <emphasis>dnslookup</emphasis></entry>
36894 <entry>Type: <emphasis>boolean</emphasis></entry>
36895 <entry>Default: <emphasis>false</emphasis></entry>
36896 </row>
36897 </tbody>
36898 </tgroup>
36899 </informaltable>
36900 <para>
36901 <indexterm role="concept">
36902 <primary>DNS</primary>
36903 <secondary>resolver options</secondary>
36904 </indexterm>
36905 When this option is true, the resolver option RES_DNSRCH is set for DNS
36906 lookups. This is different from the <option>qualify_single</option> option in that it
36907 applies to domains containing dots. Typically, but not standardly, it causes
36908 the resolver to search for the name in the current domain and in parent
36909 domains. For example, on a machine in the <emphasis>fict.example</emphasis> domain, if looking
36910 up <emphasis>teaparty.wonderland</emphasis> failed, the resolver would try
36911 <emphasis>teaparty.wonderland.fict.example</emphasis>. For details of what your resolver
36912 actually does, consult your man pages for <emphasis>resolver</emphasis> and <emphasis>resolv.conf</emphasis>.
36913 </para>
36914 <para>
36915 Setting this option true can cause problems in domains that have a wildcard MX
36916 record, because any domain that does not have its own MX record matches the
36917 local wildcard.
36918 </para>
36919 <para>
36920 <indexterm role="option">
36921 <primary><option>srv_fail_domains</option></primary>
36922 </indexterm>
36923 </para>
36924 <informaltable frame="all">
36925 <tgroup cols="4" colsep="0" rowsep="0">
36926 <colspec colwidth="8*" align="left"/>
36927 <colspec colwidth="6*" align="center"/>
36928 <colspec colwidth="6*" align="center"/>
36929 <colspec colwidth="6*" align="right"/>
36930 <tbody>
36931 <row>
36932 <entry><option>srv_fail_domains</option></entry>
36933 <entry>Use: <emphasis>dnslookup</emphasis></entry>
36934 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
36935 <entry>Default: <emphasis>unset</emphasis></entry>
36936 </row>
36937 </tbody>
36938 </tgroup>
36939 </informaltable>
36940 <para>
36941 If the DNS lookup for SRV records for one of the domains in this list causes a
36942 DNS lookup error, Exim behaves as if no SRV records were found. See section
36943 <xref linkend="SECTprowitdnsloo"/> for more discussion.
36944 </para>
36945 <para>
36946 <indexterm role="option">
36947 <primary><option>widen_domains</option></primary>
36948 </indexterm>
36949 </para>
36950 <informaltable frame="all">
36951 <tgroup cols="4" colsep="0" rowsep="0">
36952 <colspec colwidth="8*" align="left"/>
36953 <colspec colwidth="6*" align="center"/>
36954 <colspec colwidth="6*" align="center"/>
36955 <colspec colwidth="6*" align="right"/>
36956 <tbody>
36957 <row>
36958 <entry><option>widen_domains</option></entry>
36959 <entry>Use: <emphasis>dnslookup</emphasis></entry>
36960 <entry>Type: <emphasis>string list</emphasis></entry>
36961 <entry>Default: <emphasis>unset</emphasis></entry>
36962 </row>
36963 </tbody>
36964 </tgroup>
36965 </informaltable>
36966 <para>
36967 <indexterm role="concept">
36968 <primary>domain</primary>
36969 <secondary>partial; widening</secondary>
36970 </indexterm>
36971 If a DNS lookup fails and this option is set, each of its strings in turn is
36972 added onto the end of the domain, and the lookup is tried again. For example,
36973 if
36974 </para>
36975 <literallayout class="monospaced">
36976 widen_domains = fict.example:ref.example
36977 </literallayout>
36978 <para>
36979 is set and a lookup of <emphasis>klingon.dictionary</emphasis> fails,
36980 <emphasis>klingon.dictionary.fict.example</emphasis> is looked up, and if this fails,
36981 <emphasis>klingon.dictionary.ref.example</emphasis> is tried. Note that the <option>qualify_single</option>
36982 and <option>search_parents</option> options can cause some widening to be undertaken inside
36983 the DNS resolver. <option>widen_domains</option> is not applied to sender addresses
36984 when verifying, unless <option>rewrite_headers</option> is false (not the default).
36985 </para>
36986 </section>
36987 <section id="SECID119">
36988 <title>Effect of qualify_single and search_parents</title>
36989 <para>
36990 When a domain from an envelope recipient is changed by the resolver as a result
36991 of the <option>qualify_single</option> or <option>search_parents</option> options, Exim rewrites the
36992 corresponding address in the message&#x2019;s header lines unless <option>rewrite_headers</option>
36993 is set false. Exim then re-routes the address, using the full domain.
36994 </para>
36995 <para>
36996 These two options affect only the DNS lookup that takes place inside the router
36997 for the domain of the address that is being routed. They do not affect lookups
36998 such as that implied by
36999 </para>
37000 <literallayout class="monospaced">
37001 domains = @mx_any
37002 </literallayout>
37003 <para>
37004 that may happen while processing a router precondition before the router is
37005 entered. No widening ever takes place for these lookups.
37006 <indexterm role="concept" startref="IIDdnsrou1" class="endofrange"/>
37007 <indexterm role="concept" startref="IIDdnsrou2" class="endofrange"/>
37008 </para>
37009 </section>
37010 </chapter>
37011
37012 <chapter id="CHID5">
37013 <title>The ipliteral router</title>
37014 <para>
37015 <indexterm role="concept">
37016 <primary><command>ipliteral</command> router</primary>
37017 </indexterm>
37018 <indexterm role="concept">
37019 <primary>domain literal</primary>
37020 <secondary>routing</secondary>
37021 </indexterm>
37022 <indexterm role="concept">
37023 <primary>routers</primary>
37024 <secondary><command>ipliteral</command></secondary>
37025 </indexterm>
37026 This router has no private options. Unless it is being used purely for
37027 verification (see <option>verify_only</option>) a transport is required to be defined by the
37028 generic <option>transport</option> option. The router accepts the address if its domain part
37029 takes the form of an RFC 2822 domain literal. For example, the <command>ipliteral</command>
37030 router handles the address
37031 </para>
37032 <literallayout class="monospaced">
37033 root@[192.168.1.1]
37034 </literallayout>
37035 <para>
37036 by setting up delivery to the host with that IP address. IPv4 domain literals
37037 consist of an IPv4 address enclosed in square brackets. IPv6 domain literals
37038 are similar, but the address is preceded by <literal>ipv6:</literal>. For example:
37039 </para>
37040 <literallayout class="monospaced">
37041 postmaster@[ipv6:fe80::a00:20ff:fe86:a061.5678]
37042 </literallayout>
37043 <para>
37044 Exim allows <literal>ipv4:</literal> before IPv4 addresses, for consistency, and on the
37045 grounds that sooner or later somebody will try it.
37046 </para>
37047 <para>
37048 <indexterm role="option">
37049 <primary><option>self</option></primary>
37050 <secondary>in <command>ipliteral</command> router</secondary>
37051 </indexterm>
37052 If the IP address matches something in <option>ignore_target_hosts</option>, the router
37053 declines. If an IP literal turns out to refer to the local host, the generic
37054 <option>self</option> option determines what happens.
37055 </para>
37056 <para>
37057 The RFCs require support for domain literals; however, their use is
37058 controversial in today&#x2019;s Internet. If you want to use this router, you must
37059 also set the main configuration option <option>allow_domain_literals</option>. Otherwise,
37060 Exim will not recognize the domain literal syntax in addresses.
37061 </para>
37062 </chapter>
37063
37064 <chapter id="CHID6">
37065 <title>The iplookup router</title>
37066 <para>
37067 <indexterm role="concept">
37068 <primary><command>iplookup</command> router</primary>
37069 </indexterm>
37070 <indexterm role="concept">
37071 <primary>routers</primary>
37072 <secondary><command>iplookup</command></secondary>
37073 </indexterm>
37074 The <command>iplookup</command> router was written to fulfil a specific requirement in
37075 Cambridge University (which in fact no longer exists). For this reason, it is
37076 not included in the binary of Exim by default. If you want to include it, you
37077 must set
37078 </para>
37079 <literallayout class="monospaced">
37080 ROUTER_IPLOOKUP=yes
37081 </literallayout>
37082 <para>
37083 in your <filename>Local/Makefile</filename> configuration file.
37084 </para>
37085 <para>
37086 The <command>iplookup</command> router routes an address by sending it over a TCP or UDP
37087 connection to one or more specific hosts. The host can then return the same or
37088 a different address &ndash; in effect rewriting the recipient address in the
37089 message&#x2019;s envelope. The new address is then passed on to subsequent routers. If
37090 this process fails, the address can be passed on to other routers, or delivery
37091 can be deferred. Since <command>iplookup</command> is just a rewriting router, a transport
37092 must not be specified for it.
37093 </para>
37094 <para>
37095 <indexterm role="concept">
37096 <primary>options</primary>
37097 <secondary><command>iplookup</command> router</secondary>
37098 </indexterm>
37099 <indexterm role="option">
37100 <primary><option>hosts</option></primary>
37101 </indexterm>
37102 </para>
37103 <informaltable frame="all">
37104 <tgroup cols="4" colsep="0" rowsep="0">
37105 <colspec colwidth="8*" align="left"/>
37106 <colspec colwidth="6*" align="center"/>
37107 <colspec colwidth="6*" align="center"/>
37108 <colspec colwidth="6*" align="right"/>
37109 <tbody>
37110 <row>
37111 <entry><option>hosts</option></entry>
37112 <entry>Use: <emphasis>iplookup</emphasis></entry>
37113 <entry>Type: <emphasis>string</emphasis></entry>
37114 <entry>Default: <emphasis>unset</emphasis></entry>
37115 </row>
37116 </tbody>
37117 </tgroup>
37118 </informaltable>
37119 <para>
37120 This option must be supplied. Its value is a colon-separated list of host
37121 names. The hosts are looked up using <function>gethostbyname()</function>
37122 (or <function>getipnodebyname()</function> when available)
37123 and are tried in order until one responds to the query. If none respond, what
37124 happens is controlled by <option>optional</option>.
37125 </para>
37126 <para>
37127 <indexterm role="option">
37128 <primary><option>optional</option></primary>
37129 </indexterm>
37130 </para>
37131 <informaltable frame="all">
37132 <tgroup cols="4" colsep="0" rowsep="0">
37133 <colspec colwidth="8*" align="left"/>
37134 <colspec colwidth="6*" align="center"/>
37135 <colspec colwidth="6*" align="center"/>
37136 <colspec colwidth="6*" align="right"/>
37137 <tbody>
37138 <row>
37139 <entry><option>optional</option></entry>
37140 <entry>Use: <emphasis>iplookup</emphasis></entry>
37141 <entry>Type: <emphasis>boolean</emphasis></entry>
37142 <entry>Default: <emphasis>false</emphasis></entry>
37143 </row>
37144 </tbody>
37145 </tgroup>
37146 </informaltable>
37147 <para>
37148 If <option>optional</option> is true, if no response is obtained from any host, the address
37149 is passed to the next router, overriding <option>no_more</option>. If <option>optional</option> is false,
37150 delivery to the address is deferred.
37151 </para>
37152 <para>
37153 <indexterm role="option">
37154 <primary><option>port</option></primary>
37155 </indexterm>
37156 </para>
37157 <informaltable frame="all">
37158 <tgroup cols="4" colsep="0" rowsep="0">
37159 <colspec colwidth="8*" align="left"/>
37160 <colspec colwidth="6*" align="center"/>
37161 <colspec colwidth="6*" align="center"/>
37162 <colspec colwidth="6*" align="right"/>
37163 <tbody>
37164 <row>
37165 <entry><option>port</option></entry>
37166 <entry>Use: <emphasis>iplookup</emphasis></entry>
37167 <entry>Type: <emphasis>integer</emphasis></entry>
37168 <entry>Default: <emphasis>0</emphasis></entry>
37169 </row>
37170 </tbody>
37171 </tgroup>
37172 </informaltable>
37173 <para>
37174 <indexterm role="concept">
37175 <primary>port</primary>
37176 <secondary><command>iplookup</command> router</secondary>
37177 </indexterm>
37178 This option must be supplied. It specifies the port number for the TCP or UDP
37179 call.
37180 </para>
37181 <para>
37182 <indexterm role="option">
37183 <primary><option>protocol</option></primary>
37184 </indexterm>
37185 </para>
37186 <informaltable frame="all">
37187 <tgroup cols="4" colsep="0" rowsep="0">
37188 <colspec colwidth="8*" align="left"/>
37189 <colspec colwidth="6*" align="center"/>
37190 <colspec colwidth="6*" align="center"/>
37191 <colspec colwidth="6*" align="right"/>
37192 <tbody>
37193 <row>
37194 <entry><option>protocol</option></entry>
37195 <entry>Use: <emphasis>iplookup</emphasis></entry>
37196 <entry>Type: <emphasis>string</emphasis></entry>
37197 <entry>Default: <emphasis>udp</emphasis></entry>
37198 </row>
37199 </tbody>
37200 </tgroup>
37201 </informaltable>
37202 <para>
37203 This option can be set to <quote>udp</quote> or <quote>tcp</quote> to specify which of the two
37204 protocols is to be used.
37205 </para>
37206 <para>
37207 <indexterm role="option">
37208 <primary><option>query</option></primary>
37209 </indexterm>
37210 </para>
37211 <informaltable frame="all">
37212 <tgroup cols="4" colsep="0" rowsep="0">
37213 <colspec colwidth="8*" align="left"/>
37214 <colspec colwidth="6*" align="center"/>
37215 <colspec colwidth="6*" align="center"/>
37216 <colspec colwidth="6*" align="right"/>
37217 <tbody>
37218 <row>
37219 <entry><option>query</option></entry>
37220 <entry>Use: <emphasis>iplookup</emphasis></entry>
37221 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37222 <entry>Default: <emphasis>see below</emphasis></entry>
37223 </row>
37224 </tbody>
37225 </tgroup>
37226 </informaltable>
37227 <para>
37228 This defines the content of the query that is sent to the remote hosts. The
37229 default value is:
37230 </para>
37231 <literallayout class="monospaced">
37232 $local_part@$domain $local_part@$domain
37233 </literallayout>
37234 <para>
37235 The repetition serves as a way of checking that a response is to the correct
37236 query in the default case (see <option>response_pattern</option> below).
37237 </para>
37238 <para>
37239 <indexterm role="option">
37240 <primary><option>reroute</option></primary>
37241 </indexterm>
37242 </para>
37243 <informaltable frame="all">
37244 <tgroup cols="4" colsep="0" rowsep="0">
37245 <colspec colwidth="8*" align="left"/>
37246 <colspec colwidth="6*" align="center"/>
37247 <colspec colwidth="6*" align="center"/>
37248 <colspec colwidth="6*" align="right"/>
37249 <tbody>
37250 <row>
37251 <entry><option>reroute</option></entry>
37252 <entry>Use: <emphasis>iplookup</emphasis></entry>
37253 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37254 <entry>Default: <emphasis>unset</emphasis></entry>
37255 </row>
37256 </tbody>
37257 </tgroup>
37258 </informaltable>
37259 <para>
37260 If this option is not set, the rerouted address is precisely the byte string
37261 returned by the remote host, up to the first white space, if any. If set, the
37262 string is expanded to form the rerouted address. It can include parts matched
37263 in the response by <option>response_pattern</option> by means of numeric variables such as
37264 <varname>$1</varname>, <varname>$2</varname>, etc. The variable <varname>$0</varname> refers to the entire input string,
37265 whether or not a pattern is in use. In all cases, the rerouted address must end
37266 up in the form <emphasis>local_part@domain</emphasis>.
37267 </para>
37268 <para>
37269 <indexterm role="option">
37270 <primary><option>response_pattern</option></primary>
37271 </indexterm>
37272 </para>
37273 <informaltable frame="all">
37274 <tgroup cols="4" colsep="0" rowsep="0">
37275 <colspec colwidth="8*" align="left"/>
37276 <colspec colwidth="6*" align="center"/>
37277 <colspec colwidth="6*" align="center"/>
37278 <colspec colwidth="6*" align="right"/>
37279 <tbody>
37280 <row>
37281 <entry><option>response_pattern</option></entry>
37282 <entry>Use: <emphasis>iplookup</emphasis></entry>
37283 <entry>Type: <emphasis>string</emphasis></entry>
37284 <entry>Default: <emphasis>unset</emphasis></entry>
37285 </row>
37286 </tbody>
37287 </tgroup>
37288 </informaltable>
37289 <para>
37290 This option can be set to a regular expression that is applied to the string
37291 returned from the remote host. If the pattern does not match the response, the
37292 router declines. If <option>response_pattern</option> is not set, no checking of the
37293 response is done, unless the query was defaulted, in which case there is a
37294 check that the text returned after the first white space is the original
37295 address. This checks that the answer that has been received is in response to
37296 the correct question. For example, if the response is just a new domain, the
37297 following could be used:
37298 </para>
37299 <literallayout class="monospaced">
37300 response_pattern = ^([^@]+)$
37301 reroute = $local_part@$1
37302 </literallayout>
37303 <para>
37304 <indexterm role="option">
37305 <primary><option>timeout</option></primary>
37306 </indexterm>
37307 </para>
37308 <informaltable frame="all">
37309 <tgroup cols="4" colsep="0" rowsep="0">
37310 <colspec colwidth="8*" align="left"/>
37311 <colspec colwidth="6*" align="center"/>
37312 <colspec colwidth="6*" align="center"/>
37313 <colspec colwidth="6*" align="right"/>
37314 <tbody>
37315 <row>
37316 <entry><option>timeout</option></entry>
37317 <entry>Use: <emphasis>iplookup</emphasis></entry>
37318 <entry>Type: <emphasis>time</emphasis></entry>
37319 <entry>Default: <emphasis>5s</emphasis></entry>
37320 </row>
37321 </tbody>
37322 </tgroup>
37323 </informaltable>
37324 <para>
37325 This specifies the amount of time to wait for a response from the remote
37326 machine. The same timeout is used for the <function>connect()</function> function for a TCP
37327 call. It does not apply to UDP.
37328 </para>
37329 </chapter>
37330
37331 <chapter id="CHID7">
37332 <title>The manualroute router</title>
37333 <para>
37334 <indexterm role="concept" id="IIDmanrou1" class="startofrange">
37335 <primary><command>manualroute</command> router</primary>
37336 </indexterm>
37337 <indexterm role="concept" id="IIDmanrou2" class="startofrange">
37338 <primary>routers</primary>
37339 <secondary><command>manualroute</command></secondary>
37340 </indexterm>
37341 <indexterm role="concept">
37342 <primary>domain</primary>
37343 <secondary>manually routing</secondary>
37344 </indexterm>
37345 The <command>manualroute</command> router is so-called because it provides a way of manually
37346 routing an address according to its domain. It is mainly used when you want to
37347 route addresses to remote hosts according to your own rules, bypassing the
37348 normal DNS routing that looks up MX records. However, <command>manualroute</command> can also
37349 route to local transports, a facility that may be useful if you want to save
37350 messages for dial-in hosts in local files.
37351 </para>
37352 <para>
37353 The <command>manualroute</command> router compares a list of domain patterns with the domain
37354 it is trying to route. If there is no match, the router declines. Each pattern
37355 has associated with it a list of hosts and some other optional data, which may
37356 include a transport. The combination of a pattern and its data is called a
37357 <quote>routing rule</quote>. For patterns that do not have an associated transport, the
37358 generic <option>transport</option> option must specify a transport, unless the router is
37359 being used purely for verification (see <option>verify_only</option>).
37360 </para>
37361 <para>
37362 <indexterm role="variable">
37363 <primary><varname>$host</varname></primary>
37364 </indexterm>
37365 In the case of verification, matching the domain pattern is sufficient for the
37366 router to accept the address. When actually routing an address for delivery,
37367 an address that matches a domain pattern is queued for the associated
37368 transport. If the transport is not a local one, a host list must be associated
37369 with the pattern; IP addresses are looked up for the hosts, and these are
37370 passed to the transport along with the mail address. For local transports, a
37371 host list is optional. If it is present, it is passed in <varname>$host</varname> as a single
37372 text string.
37373 </para>
37374 <para>
37375 The list of routing rules can be provided as an inline string in
37376 <option>route_list</option>, or the data can be obtained by looking up the domain in a file
37377 or database by setting <option>route_data</option>. Only one of these settings may appear in
37378 any one instance of <command>manualroute</command>. The format of routing rules is described
37379 below, following the list of private options.
37380 </para>
37381 <section id="SECTprioptman">
37382 <title>Private options for manualroute</title>
37383 <para>
37384 <indexterm role="concept">
37385 <primary>options</primary>
37386 <secondary><command>manualroute</command> router</secondary>
37387 </indexterm>
37388 The private options for the <command>manualroute</command> router are as follows:
37389 </para>
37390 <para>
37391 <indexterm role="option">
37392 <primary><option>host_all_ignored</option></primary>
37393 </indexterm>
37394 </para>
37395 <informaltable frame="all">
37396 <tgroup cols="4" colsep="0" rowsep="0">
37397 <colspec colwidth="8*" align="left"/>
37398 <colspec colwidth="6*" align="center"/>
37399 <colspec colwidth="6*" align="center"/>
37400 <colspec colwidth="6*" align="right"/>
37401 <tbody>
37402 <row>
37403 <entry><option>host_all_ignored</option></entry>
37404 <entry>Use: <emphasis>manualroute</emphasis></entry>
37405 <entry>Type: <emphasis>string</emphasis></entry>
37406 <entry>Default: <emphasis>defer</emphasis></entry>
37407 </row>
37408 </tbody>
37409 </tgroup>
37410 </informaltable>
37411 <para>
37412 See <option>host_find_failed</option>.
37413 </para>
37414 <para>
37415 <indexterm role="option">
37416 <primary><option>host_find_failed</option></primary>
37417 </indexterm>
37418 </para>
37419 <informaltable frame="all">
37420 <tgroup cols="4" colsep="0" rowsep="0">
37421 <colspec colwidth="8*" align="left"/>
37422 <colspec colwidth="6*" align="center"/>
37423 <colspec colwidth="6*" align="center"/>
37424 <colspec colwidth="6*" align="right"/>
37425 <tbody>
37426 <row>
37427 <entry><option>host_find_failed</option></entry>
37428 <entry>Use: <emphasis>manualroute</emphasis></entry>
37429 <entry>Type: <emphasis>string</emphasis></entry>
37430 <entry>Default: <emphasis>freeze</emphasis></entry>
37431 </row>
37432 </tbody>
37433 </tgroup>
37434 </informaltable>
37435 <para>
37436 This option controls what happens when <command>manualroute</command> tries to find an IP
37437 address for a host, and the host does not exist. The option can be set to one
37438 of the following values:
37439 </para>
37440 <literallayout class="monospaced">
37441 decline
37442 defer
37443 fail
37444 freeze
37445 ignore
37446 pass
37447 </literallayout>
37448 <para>
37449 The default (<quote>freeze</quote>) assumes that this state is a serious configuration
37450 error. The difference between <quote>pass</quote> and <quote>decline</quote> is that the former
37451 forces the address to be passed to the next router (or the router defined by
37452 <option>pass_router</option>),
37453 <indexterm role="option">
37454 <primary><option>more</option></primary>
37455 </indexterm>
37456 overriding <option>no_more</option>, whereas the latter passes the address to the next
37457 router only if <option>more</option> is true.
37458 </para>
37459 <para>
37460 The value <quote>ignore</quote> causes Exim to completely ignore a host whose IP address
37461 cannot be found. If all the hosts in the list are ignored, the behaviour is
37462 controlled by the <option>host_all_ignored</option> option. This takes the same values
37463 as <option>host_find_failed</option>, except that it cannot be set to <quote>ignore</quote>.
37464 </para>
37465 <para>
37466 The <option>host_find_failed</option> option applies only to a definite <quote>does not exist</quote>
37467 state; if a host lookup gets a temporary error, delivery is deferred unless the
37468 generic <option>pass_on_timeout</option> option is set.
37469 </para>
37470 <para>
37471 <indexterm role="option">
37472 <primary><option>hosts_randomize</option></primary>
37473 </indexterm>
37474 </para>
37475 <informaltable frame="all">
37476 <tgroup cols="4" colsep="0" rowsep="0">
37477 <colspec colwidth="8*" align="left"/>
37478 <colspec colwidth="6*" align="center"/>
37479 <colspec colwidth="6*" align="center"/>
37480 <colspec colwidth="6*" align="right"/>
37481 <tbody>
37482 <row>
37483 <entry><option>hosts_randomize</option></entry>
37484 <entry>Use: <emphasis>manualroute</emphasis></entry>
37485 <entry>Type: <emphasis>boolean</emphasis></entry>
37486 <entry>Default: <emphasis>false</emphasis></entry>
37487 </row>
37488 </tbody>
37489 </tgroup>
37490 </informaltable>
37491 <para>
37492 <indexterm role="concept">
37493 <primary>randomized host list</primary>
37494 </indexterm>
37495 <indexterm role="concept">
37496 <primary>host</primary>
37497 <secondary>list of; randomized</secondary>
37498 </indexterm>
37499 If this option is set, the order of the items in a host list in a routing rule
37500 is randomized each time the list is used, unless an option in the routing rule
37501 overrides (see below). Randomizing the order of a host list can be used to do
37502 crude load sharing. However, if more than one mail address is routed by the
37503 same router to the same host list, the host lists are considered to be the same
37504 (even though they may be randomized into different orders) for the purpose of
37505 deciding whether to batch the deliveries into a single SMTP transaction.
37506 </para>
37507 <para>
37508 When <option>hosts_randomize</option> is true, a host list may be split
37509 into groups whose order is separately randomized. This makes it possible to
37510 set up MX-like behaviour. The boundaries between groups are indicated by an
37511 item that is just <literal>+</literal> in the host list. For example:
37512 </para>
37513 <literallayout class="monospaced">
37514 route_list = * host1:host2:host3:+:host4:host5
37515 </literallayout>
37516 <para>
37517 The order of the first three hosts and the order of the last two hosts is
37518 randomized for each use, but the first three always end up before the last two.
37519 If <option>hosts_randomize</option> is not set, a <literal>+</literal> item in the list is ignored. If a
37520 randomized host list is passed to an <command>smtp</command> transport that also has
37521 <option>hosts_randomize set</option>, the list is not re-randomized.
37522 </para>
37523 <para>
37524 <indexterm role="option">
37525 <primary><option>route_data</option></primary>
37526 </indexterm>
37527 </para>
37528 <informaltable frame="all">
37529 <tgroup cols="4" colsep="0" rowsep="0">
37530 <colspec colwidth="8*" align="left"/>
37531 <colspec colwidth="6*" align="center"/>
37532 <colspec colwidth="6*" align="center"/>
37533 <colspec colwidth="6*" align="right"/>
37534 <tbody>
37535 <row>
37536 <entry><option>route_data</option></entry>
37537 <entry>Use: <emphasis>manualroute</emphasis></entry>
37538 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37539 <entry>Default: <emphasis>unset</emphasis></entry>
37540 </row>
37541 </tbody>
37542 </tgroup>
37543 </informaltable>
37544 <para>
37545 If this option is set, it must expand to yield the data part of a routing rule.
37546 Typically, the expansion string includes a lookup based on the domain. For
37547 example:
37548 </para>
37549 <literallayout class="monospaced">
37550 route_data = ${lookup{$domain}dbm{/etc/routes}}
37551 </literallayout>
37552 <para>
37553 If the expansion is forced to fail, or the result is an empty string, the
37554 router declines. Other kinds of expansion failure cause delivery to be
37555 deferred.
37556 </para>
37557 <para>
37558 <indexterm role="option">
37559 <primary><option>route_list</option></primary>
37560 </indexterm>
37561 </para>
37562 <informaltable frame="all">
37563 <tgroup cols="4" colsep="0" rowsep="0">
37564 <colspec colwidth="8*" align="left"/>
37565 <colspec colwidth="6*" align="center"/>
37566 <colspec colwidth="6*" align="center"/>
37567 <colspec colwidth="6*" align="right"/>
37568 <tbody>
37569 <row>
37570 <entry><option>route_list</option></entry>
37571 <entry>Use: <emphasis>manualroute</emphasis></entry>
37572 <entry>Type: <emphasis>string list</emphasis></entry>
37573 <entry>Default: <emphasis>unset</emphasis></entry>
37574 </row>
37575 </tbody>
37576 </tgroup>
37577 </informaltable>
37578 <para>
37579 This string is a list of routing rules, in the form defined below. Note that,
37580 unlike most string lists, the items are separated by semicolons. This is so
37581 that they may contain colon-separated host lists.
37582 </para>
37583 <para>
37584 <indexterm role="option">
37585 <primary><option>same_domain_copy_routing</option></primary>
37586 </indexterm>
37587 </para>
37588 <informaltable frame="all">
37589 <tgroup cols="4" colsep="0" rowsep="0">
37590 <colspec colwidth="8*" align="left"/>
37591 <colspec colwidth="6*" align="center"/>
37592 <colspec colwidth="6*" align="center"/>
37593 <colspec colwidth="6*" align="right"/>
37594 <tbody>
37595 <row>
37596 <entry><option>same_domain_copy_routing</option></entry>
37597 <entry>Use: <emphasis>manualroute</emphasis></entry>
37598 <entry>Type: <emphasis>boolean</emphasis></entry>
37599 <entry>Default: <emphasis>false</emphasis></entry>
37600 </row>
37601 </tbody>
37602 </tgroup>
37603 </informaltable>
37604 <para>
37605 <indexterm role="concept">
37606 <primary>address</primary>
37607 <secondary>copying routing</secondary>
37608 </indexterm>
37609 Addresses with the same domain are normally routed by the <command>manualroute</command>
37610 router to the same list of hosts. However, this cannot be presumed, because the
37611 router options and preconditions may refer to the local part of the address. By
37612 default, therefore, Exim routes each address in a message independently. DNS
37613 servers run caches, so repeated DNS lookups are not normally expensive, and in
37614 any case, personal messages rarely have more than a few recipients.
37615 </para>
37616 <para>
37617 If you are running mailing lists with large numbers of subscribers at the same
37618 domain, and you are using a <command>manualroute</command> router which is independent of the
37619 local part, you can set <option>same_domain_copy_routing</option> to bypass repeated DNS
37620 lookups for identical domains in one message. In this case, when
37621 <command>manualroute</command> routes an address to a remote transport, any other unrouted
37622 addresses in the message that have the same domain are automatically given the
37623 same routing without processing them independently. However, this is only done
37624 if <option>headers_add</option> and <option>headers_remove</option> are unset.
37625 </para>
37626 </section>
37627 <section id="SECID120">
37628 <title>Routing rules in route_list</title>
37629 <para>
37630 The value of <option>route_list</option> is a string consisting of a sequence of routing
37631 rules, separated by semicolons. If a semicolon is needed in a rule, it can be
37632 entered as two semicolons. Alternatively, the list separator can be changed as
37633 described (for colon-separated lists) in section <xref linkend="SECTlistconstruct"/>.
37634 Empty rules are ignored. The format of each rule is
37635 </para>
37636 <literallayout>
37637 &lt;<emphasis>domain pattern</emphasis>&gt;  &lt;<emphasis>list of hosts</emphasis>&gt;  &lt;<emphasis>options</emphasis>&gt;
37638 </literallayout>
37639 <para>
37640 The following example contains two rules, each with a simple domain pattern and
37641 no options:
37642 </para>
37643 <literallayout class="monospaced">
37644 route_list = \
37645   dict.ref.example  mail-1.ref.example:mail-2.ref.example ; \
37646   thes.ref.example  mail-3.ref.example:mail-4.ref.example
37647 </literallayout>
37648 <para>
37649 The three parts of a rule are separated by white space. The pattern and the
37650 list of hosts can be enclosed in quotes if necessary, and if they are, the
37651 usual quoting rules apply. Each rule in a <option>route_list</option> must start with a
37652 single domain pattern, which is the only mandatory item in the rule. The
37653 pattern is in the same format as one item in a domain list (see section
37654 <xref linkend="SECTdomainlist"/>),
37655 except that it may not be the name of an interpolated file.
37656 That is, it may be wildcarded, or a regular expression, or a file or database
37657 lookup (with semicolons doubled, because of the use of semicolon as a separator
37658 in a <option>route_list</option>).
37659 </para>
37660 <para>
37661 The rules in <option>route_list</option> are searched in order until one of the patterns
37662 matches the domain that is being routed. The list of hosts and then options are
37663 then used as described below. If there is no match, the router declines. When
37664 <option>route_list</option> is set, <option>route_data</option> must not be set.
37665 </para>
37666 </section>
37667 <section id="SECID121">
37668 <title>Routing rules in route_data</title>
37669 <para>
37670 The use of <option>route_list</option> is convenient when there are only a small number of
37671 routing rules. For larger numbers, it is easier to use a file or database to
37672 hold the routing information, and use the <option>route_data</option> option instead.
37673 The value of <option>route_data</option> is a list of hosts, followed by (optional) options.
37674 Most commonly, <option>route_data</option> is set as a string that contains an
37675 expansion lookup. For example, suppose we place two routing rules in a file
37676 like this:
37677 </para>
37678 <literallayout class="monospaced">
37679 dict.ref.example:  mail-1.ref.example:mail-2.ref.example
37680 thes.ref.example:  mail-3.ref.example:mail-4.ref.example
37681 </literallayout>
37682 <para>
37683 This data can be accessed by setting
37684 </para>
37685 <literallayout class="monospaced">
37686 route_data = ${lookup{$domain}lsearch{/the/file/name}}
37687 </literallayout>
37688 <para>
37689 Failure of the lookup results in an empty string, causing the router to
37690 decline. However, you do not have to use a lookup in <option>route_data</option>. The only
37691 requirement is that the result of expanding the string is a list of hosts,
37692 possibly followed by options, separated by white space. The list of hosts must
37693 be enclosed in quotes if it contains white space.
37694 </para>
37695 </section>
37696 <section id="SECID122">
37697 <title>Format of the list of hosts</title>
37698 <para>
37699 A list of hosts, whether obtained via <option>route_data</option> or <option>route_list</option>, is
37700 always separately expanded before use. If the expansion fails, the router
37701 declines. The result of the expansion must be a colon-separated list of names
37702 and/or IP addresses, optionally also including ports.
37703 If the list is written with spaces, it must be protected with quotes.
37704 The format of each item
37705 in the list is described in the next section. The list separator can be changed
37706 as described in section <xref linkend="SECTlistsepchange"/>.
37707 </para>
37708 <para>
37709 If the list of hosts was obtained from a <option>route_list</option> item, the following
37710 variables are set during its expansion:
37711 </para>
37712 <itemizedlist>
37713 <listitem>
37714 <para>
37715 <indexterm role="concept">
37716 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname>  etc)</primary>
37717 <secondary>in <command>manualroute</command> router</secondary>
37718 </indexterm>
37719 If the domain was matched against a regular expression, the numeric variables
37720 <varname>$1</varname>, <varname>$2</varname>, etc. may be set. For example:
37721 </para>
37722 <literallayout class="monospaced">
37723 route_list = ^domain(\d+)   host-$1.text.example
37724 </literallayout>
37725 </listitem>
37726 <listitem>
37727 <para>
37728 <varname>$0</varname> is always set to the entire domain.
37729 </para>
37730 </listitem>
37731 <listitem>
37732 <para>
37733 <varname>$1</varname> is also set when partial matching is done in a file lookup.
37734 </para>
37735 </listitem>
37736 <listitem>
37737 <para>
37738 <indexterm role="variable">
37739 <primary><varname>$value</varname></primary>
37740 </indexterm>
37741 If the pattern that matched the domain was a lookup item, the data that was
37742 looked up is available in the expansion variable <varname>$value</varname>. For example:
37743 </para>
37744 <literallayout class="monospaced">
37745 route_list = lsearch;;/some/file.routes  $value
37746 </literallayout>
37747 </listitem>
37748 </itemizedlist>
37749 <para>
37750 Note the doubling of the semicolon in the pattern that is necessary because
37751 semicolon is the default route list separator.
37752 </para>
37753 </section>
37754 <section id="SECTformatonehostitem">
37755 <title>Format of one host item</title>
37756 <para>
37757 Each item in the list of hosts is either a host name or an IP address,
37758 optionally with an attached port number. When no port is given, an IP address
37759 is not enclosed in brackets. When a port is specified, it overrides the port
37760 specification on the transport. The port is separated from the name or address
37761 by a colon. This leads to some complications:
37762 </para>
37763 <itemizedlist>
37764 <listitem>
37765 <para>
37766 Because colon is the default separator for the list of hosts, either
37767 the colon that specifies a port must be doubled, or the list separator must
37768 be changed. The following two examples have the same effect:
37769 </para>
37770 <literallayout class="monospaced">
37771 route_list = * "host1.tld::1225 : host2.tld::1226"
37772 route_list = * "&lt;+ host1.tld:1225 + host2.tld:1226"
37773 </literallayout>
37774 </listitem>
37775 <listitem>
37776 <para>
37777 When IPv6 addresses are involved, it gets worse, because they contain
37778 colons of their own. To make this case easier, it is permitted to
37779 enclose an IP address (either v4 or v6) in square brackets if a port
37780 number follows. For example:
37781 </para>
37782 <literallayout class="monospaced">
37783 route_list = * "&lt;/ [10.1.1.1]:1225 / [::1]:1226"
37784 </literallayout>
37785 </listitem>
37786 </itemizedlist>
37787 </section>
37788 <section id="SECThostshowused">
37789 <title>How the list of hosts is used</title>
37790 <para>
37791 When an address is routed to an <command>smtp</command> transport by <command>manualroute</command>, each of
37792 the hosts is tried, in the order specified, when carrying out the SMTP
37793 delivery. However, the order can be changed by setting the <option>hosts_randomize</option>
37794 option, either on the router (see section <xref linkend="SECTprioptman"/> above), or on the
37795 transport.
37796 </para>
37797 <para>
37798 Hosts may be listed by name or by IP address. An unadorned name in the list of
37799 hosts is interpreted as a host name. A name that is followed by <literal>/MX</literal> is
37800 interpreted as an indirection to a sublist of hosts obtained by looking up MX
37801 records in the DNS. For example:
37802 </para>
37803 <literallayout class="monospaced">
37804 route_list = *  x.y.z:p.q.r/MX:e.f.g
37805 </literallayout>
37806 <para>
37807 If this feature is used with a port specifier, the port must come last. For
37808 example:
37809 </para>
37810 <literallayout class="monospaced">
37811 route_list = *  dom1.tld/mx::1225
37812 </literallayout>
37813 <para>
37814 If the <option>hosts_randomize</option> option is set, the order of the items in the list is
37815 randomized before any lookups are done. Exim then scans the list; for any name
37816 that is not followed by <literal>/MX</literal> it looks up an IP address. If this turns out to
37817 be an interface on the local host and the item is not the first in the list,
37818 Exim discards it and any subsequent items. If it is the first item, what
37819 happens is controlled by the
37820 <indexterm role="option">
37821 <primary><option>self</option></primary>
37822 <secondary>in <command>manualroute</command> router</secondary>
37823 </indexterm>
37824 <option>self</option> option of the router.
37825 </para>
37826 <para>
37827 A name on the list that is followed by <literal>/MX</literal> is replaced with the list of
37828 hosts obtained by looking up MX records for the name. This is always a DNS
37829 lookup; the <option>bydns</option> and <option>byname</option> options (see section <xref linkend="SECThowoptused"/>
37830 below) are not relevant here. The order of these hosts is determined by the
37831 preference values in the MX records, according to the usual rules. Because
37832 randomizing happens before the MX lookup, it does not affect the order that is
37833 defined by MX preferences.
37834 </para>
37835 <para>
37836 If the local host is present in the sublist obtained from MX records, but is
37837 not the most preferred host in that list, it and any equally or less
37838 preferred hosts are removed before the sublist is inserted into the main list.
37839 </para>
37840 <para>
37841 If the local host is the most preferred host in the MX list, what happens
37842 depends on where in the original list of hosts the <literal>/MX</literal> item appears. If it
37843 is not the first item (that is, there are previous hosts in the main list),
37844 Exim discards this name and any subsequent items in the main list.
37845 </para>
37846 <para>
37847 If the MX item is first in the list of hosts, and the local host is the
37848 most preferred host, what happens is controlled by the <option>self</option> option of the
37849 router.
37850 </para>
37851 <para>
37852 DNS failures when lookup up the MX records are treated in the same way as DNS
37853 failures when looking up IP addresses: <option>pass_on_timeout</option> and
37854 <option>host_find_failed</option> are used when relevant.
37855 </para>
37856 <para>
37857 The generic <option>ignore_target_hosts</option> option applies to all hosts in the list,
37858 whether obtained from an MX lookup or not.
37859 </para>
37860 </section>
37861 <section id="SECThowoptused">
37862 <title>How the options are used</title>
37863 <para>
37864 The options are a sequence of words, space-separated.
37865 One of the words can be the name of a transport; this overrides the
37866 <option>transport</option> option on the router for this particular routing rule only. The
37867 other words (if present) control randomization of the list of hosts on a
37868 per-rule basis, and how the IP addresses of the hosts are to be found when
37869 routing to a remote transport. These options are as follows:
37870 </para>
37871 <itemizedlist>
37872 <listitem>
37873 <para>
37874 <option>randomize</option>: randomize the order of the hosts in this list, overriding the
37875 setting of <option>hosts_randomize</option> for this routing rule only.
37876 </para>
37877 </listitem>
37878 <listitem>
37879 <para>
37880 <option>no_randomize</option>: do not randomize the order of the hosts in this list,
37881 overriding the setting of <option>hosts_randomize</option> for this routing rule only.
37882 </para>
37883 </listitem>
37884 <listitem>
37885 <para>
37886 <option>byname</option>: use <function>getipnodebyname()</function> (<function>gethostbyname()</function> on older systems) to
37887 find IP addresses. This function may ultimately cause a DNS lookup, but it may
37888 also look in <filename>/etc/hosts</filename> or other sources of information.
37889 </para>
37890 </listitem>
37891 <listitem>
37892 <para>
37893 <option>bydns</option>: look up address records for the hosts directly in the DNS; fail if
37894 no address records are found. If there is a temporary DNS error (such as a
37895 timeout), delivery is deferred.
37896 </para>
37897 </listitem>
37898 <listitem>
37899 <para>
37900 <option>ipv4_only</option>: in direct DNS lookups, look up only A records.
37901 </para>
37902 </listitem>
37903 <listitem>
37904 <para>
37905 <option>ipv4_prefer</option>: in direct DNS lookups, sort A records before AAAA records.
37906 </para>
37907 </listitem>
37908 </itemizedlist>
37909 <para>
37910 For example:
37911 </para>
37912 <literallayout class="monospaced">
37913 route_list = domain1  host1:host2:host3  randomize bydns;\
37914              domain2  host4:host5
37915 </literallayout>
37916 <para>
37917 If neither <option>byname</option> nor <option>bydns</option> is given, Exim behaves as follows: First, a
37918 DNS lookup is done. If this yields anything other than HOST_NOT_FOUND, that
37919 result is used. Otherwise, Exim goes on to try a call to <function>getipnodebyname()</function>
37920 or <function>gethostbyname()</function>, and the result of the lookup is the result of that
37921 call.
37922 </para>
37923 <para>
37924 <emphasis role="bold">Warning</emphasis>: It has been discovered that on some systems, if a DNS lookup
37925 called via <function>getipnodebyname()</function> times out, HOST_NOT_FOUND is returned
37926 instead of TRY_AGAIN. That is why the default action is to try a DNS
37927 lookup first. Only if that gives a definite <quote>no such host</quote> is the local
37928 function called.
37929 </para>
37930 <para>
37931 <emphasis role="bold">Compatibility</emphasis>: From Exim 4.85 until fixed for 4.90, there was an
37932 inadvertent constraint that a transport name as an option had to be the last
37933 option specified.
37934 </para>
37935 <para>
37936 If no IP address for a host can be found, what happens is controlled by the
37937 <option>host_find_failed</option> option.
37938 </para>
37939 <para>
37940 <indexterm role="variable">
37941 <primary><varname>$host</varname></primary>
37942 </indexterm>
37943 When an address is routed to a local transport, IP addresses are not looked up.
37944 The host list is passed to the transport in the <varname>$host</varname> variable.
37945 </para>
37946 </section>
37947 <section id="SECID123">
37948 <title>Manualroute examples</title>
37949 <para>
37950 In some of the examples that follow, the presence of the <option>remote_smtp</option>
37951 transport, as defined in the default configuration file, is assumed:
37952 </para>
37953 <itemizedlist>
37954 <listitem>
37955 <para>
37956 <indexterm role="concept">
37957 <primary>smart host</primary>
37958 <secondary>example router</secondary>
37959 </indexterm>
37960 The <command>manualroute</command> router can be used to forward all external mail to a
37961 <emphasis>smart host</emphasis>. If you have set up, in the main part of the configuration, a
37962 named domain list that contains your local domains, for example:
37963 </para>
37964 <literallayout class="monospaced">
37965 domainlist local_domains = my.domain.example
37966 </literallayout>
37967 <para>
37968 You can arrange for all other domains to be routed to a smart host by making
37969 your first router something like this:
37970 </para>
37971 <literallayout class="monospaced">
37972 smart_route:
37973   driver = manualroute
37974   domains = !+local_domains
37975   transport = remote_smtp
37976   route_list = * smarthost.ref.example
37977 </literallayout>
37978 <para>
37979 This causes all non-local addresses to be sent to the single host
37980 <emphasis>smarthost.ref.example</emphasis>. If a colon-separated list of smart hosts is given,
37981 they are tried in order
37982 (but you can use <option>hosts_randomize</option> to vary the order each time).
37983 Another way of configuring the same thing is this:
37984 </para>
37985 <literallayout class="monospaced">
37986 smart_route:
37987   driver = manualroute
37988   transport = remote_smtp
37989   route_list = !+local_domains  smarthost.ref.example
37990 </literallayout>
37991 <para>
37992 There is no difference in behaviour between these two routers as they stand.
37993 However, they behave differently if <option>no_more</option> is added to them. In the first
37994 example, the router is skipped if the domain does not match the <option>domains</option>
37995 precondition; the following router is always tried. If the router runs, it
37996 always matches the domain and so can never decline. Therefore, <option>no_more</option>
37997 would have no effect. In the second case, the router is never skipped; it
37998 always runs. However, if it doesn&#x2019;t match the domain, it declines. In this case
37999 <option>no_more</option> would prevent subsequent routers from running.
38000 </para>
38001 </listitem>
38002 <listitem>
38003 <para>
38004 <indexterm role="concept">
38005 <primary>mail hub example</primary>
38006 </indexterm>
38007 A <emphasis>mail hub</emphasis> is a host which receives mail for a number of domains via MX
38008 records in the DNS and delivers it via its own private routing mechanism. Often
38009 the final destinations are behind a firewall, with the mail hub being the one
38010 machine that can connect to machines both inside and outside the firewall. The
38011 <command>manualroute</command> router is usually used on a mail hub to route incoming messages
38012 to the correct hosts. For a small number of domains, the routing can be inline,
38013 using the <option>route_list</option> option, but for a larger number a file or database
38014 lookup is easier to manage.
38015 </para>
38016 <para>
38017 If the domain names are in fact the names of the machines to which the mail is
38018 to be sent by the mail hub, the configuration can be quite simple. For
38019 example:
38020 </para>
38021 <literallayout class="monospaced">
38022 hub_route:
38023   driver = manualroute
38024   transport = remote_smtp
38025   route_list = *.rhodes.tvs.example  $domain
38026 </literallayout>
38027 <para>
38028 This configuration routes domains that match <literal>*.rhodes.tvs.example</literal> to hosts
38029 whose names are the same as the mail domains. A similar approach can be taken
38030 if the host name can be obtained from the domain name by a string manipulation
38031 that the expansion facilities can handle. Otherwise, a lookup based on the
38032 domain can be used to find the host:
38033 </para>
38034 <literallayout class="monospaced">
38035 through_firewall:
38036   driver = manualroute
38037   transport = remote_smtp
38038   route_data = ${lookup {$domain} cdb {/internal/host/routes}}
38039 </literallayout>
38040 <para>
38041 The result of the lookup must be the name or IP address of the host (or
38042 hosts) to which the address is to be routed. If the lookup fails, the route
38043 data is empty, causing the router to decline. The address then passes to the
38044 next router.
38045 </para>
38046 </listitem>
38047 <listitem>
38048 <para>
38049 <indexterm role="concept">
38050 <primary>batched SMTP output example</primary>
38051 </indexterm>
38052 <indexterm role="concept">
38053 <primary>SMTP</primary>
38054 <secondary>batched outgoing; example</secondary>
38055 </indexterm>
38056 You can use <command>manualroute</command> to deliver messages to pipes or files in batched
38057 SMTP format for onward transportation by some other means. This is one way of
38058 storing mail for a dial-up host when it is not connected. The route list entry
38059 can be as simple as a single domain name in a configuration like this:
38060 </para>
38061 <literallayout class="monospaced">
38062 save_in_file:
38063   driver = manualroute
38064   transport = batchsmtp_appendfile
38065   route_list = saved.domain.example
38066 </literallayout>
38067 <para>
38068 though often a pattern is used to pick up more than one domain. If there are
38069 several domains or groups of domains with different transport requirements,
38070 different transports can be listed in the routing information:
38071 </para>
38072 <literallayout class="monospaced">
38073 save_in_file:
38074   driver = manualroute
38075   route_list = \
38076     *.saved.domain1.example  $domain  batch_appendfile; \
38077     *.saved.domain2.example  \
38078       ${lookup{$domain}dbm{/domain2/hosts}{$value}fail} \
38079       batch_pipe
38080 </literallayout>
38081 <para>
38082 <indexterm role="variable">
38083 <primary><varname>$domain</varname></primary>
38084 </indexterm>
38085 <indexterm role="variable">
38086 <primary><varname>$host</varname></primary>
38087 </indexterm>
38088 The first of these just passes the domain in the <varname>$host</varname> variable, which
38089 doesn&#x2019;t achieve much (since it is also in <varname>$domain</varname>), but the second does a
38090 file lookup to find a value to pass, causing the router to decline to handle
38091 the address if the lookup fails.
38092 </para>
38093 </listitem>
38094 <listitem>
38095 <para>
38096 <indexterm role="concept">
38097 <primary>UUCP</primary>
38098 <secondary>example of router for</secondary>
38099 </indexterm>
38100 Routing mail directly to UUCP software is a specific case of the use of
38101 <command>manualroute</command> in a gateway to another mail environment. This is an example of
38102 one way it can be done:
38103 </para>
38104 <literallayout class="monospaced">
38105 # Transport
38106 uucp:
38107   driver = pipe
38108   user = nobody
38109   command = /usr/local/bin/uux -r - \
38110     ${substr_-5:$host}!rmail ${local_part}
38111   return_fail_output = true
38112
38113 # Router
38114 uucphost:
38115   transport = uucp
38116   driver = manualroute
38117   route_data = \
38118     ${lookup{$domain}lsearch{/usr/local/exim/uucphosts}}
38119 </literallayout>
38120 <para>
38121 The file <filename>/usr/local/exim/uucphosts</filename> contains entries like
38122 </para>
38123 <literallayout class="monospaced">
38124 darksite.ethereal.example:           darksite.UUCP
38125 </literallayout>
38126 <para>
38127 It can be set up more simply without adding and removing <quote>.UUCP</quote> but this way
38128 makes clear the distinction between the domain name
38129 <emphasis>darksite.ethereal.example</emphasis> and the UUCP host name <emphasis>darksite</emphasis>.
38130 </para>
38131 </listitem>
38132 </itemizedlist>
38133 <para>
38134 <indexterm role="concept" startref="IIDmanrou1" class="endofrange"/>
38135 <indexterm role="concept" startref="IIDmanrou2" class="endofrange"/>
38136 </para>
38137 </section>
38138 </chapter>
38139
38140 <chapter id="CHAPdriverlast">
38141 <title>The queryprogram router</title>
38142 <para>
38143 <indexterm role="concept" id="IIDquerou1" class="startofrange">
38144 <primary><command>queryprogram</command> router</primary>
38145 </indexterm>
38146 <indexterm role="concept" id="IIDquerou2" class="startofrange">
38147 <primary>routers</primary>
38148 <secondary><command>queryprogram</command></secondary>
38149 </indexterm>
38150 <indexterm role="concept">
38151 <primary>routing</primary>
38152 <secondary>by external program</secondary>
38153 </indexterm>
38154 The <command>queryprogram</command> router routes an address by running an external command
38155 and acting on its output. This is an expensive way to route, and is intended
38156 mainly for use in lightly-loaded systems, or for performing experiments.
38157 However, if it is possible to use the precondition options (<option>domains</option>,
38158 <option>local_parts</option>, etc) to skip this router for most addresses, it could sensibly
38159 be used in special cases, even on a busy host. There are the following private
38160 options:
38161 <indexterm role="concept">
38162 <primary>options</primary>
38163 <secondary><command>queryprogram</command> router</secondary>
38164 </indexterm>
38165 </para>
38166 <para>
38167 <indexterm role="option">
38168 <primary><option>command</option></primary>
38169 </indexterm>
38170 </para>
38171 <informaltable frame="all">
38172 <tgroup cols="4" colsep="0" rowsep="0">
38173 <colspec colwidth="8*" align="left"/>
38174 <colspec colwidth="6*" align="center"/>
38175 <colspec colwidth="6*" align="center"/>
38176 <colspec colwidth="6*" align="right"/>
38177 <tbody>
38178 <row>
38179 <entry><option>command</option></entry>
38180 <entry>Use: <emphasis>queryprogram</emphasis></entry>
38181 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38182 <entry>Default: <emphasis>unset</emphasis></entry>
38183 </row>
38184 </tbody>
38185 </tgroup>
38186 </informaltable>
38187 <para>
38188 This option must be set. It specifies the command that is to be run. The
38189 command is split up into a command name and arguments, and then each is
38190 expanded separately (exactly as for a <command>pipe</command> transport, described in chapter
38191 <xref linkend="CHAPpipetransport"/>).
38192 </para>
38193 <para>
38194 <indexterm role="option">
38195 <primary><option>command_group</option></primary>
38196 </indexterm>
38197 </para>
38198 <informaltable frame="all">
38199 <tgroup cols="4" colsep="0" rowsep="0">
38200 <colspec colwidth="8*" align="left"/>
38201 <colspec colwidth="6*" align="center"/>
38202 <colspec colwidth="6*" align="center"/>
38203 <colspec colwidth="6*" align="right"/>
38204 <tbody>
38205 <row>
38206 <entry><option>command_group</option></entry>
38207 <entry>Use: <emphasis>queryprogram</emphasis></entry>
38208 <entry>Type: <emphasis>string</emphasis></entry>
38209 <entry>Default: <emphasis>unset</emphasis></entry>
38210 </row>
38211 </tbody>
38212 </tgroup>
38213 </informaltable>
38214 <para>
38215 <indexterm role="concept">
38216 <primary>gid (group id)</primary>
38217 <secondary>in <command>queryprogram</command> router</secondary>
38218 </indexterm>
38219 This option specifies a gid to be set when running the command while routing an
38220 address for deliver. It must be set if <option>command_user</option> specifies a numerical
38221 uid. If it begins with a digit, it is interpreted as the numerical value of the
38222 gid. Otherwise it is looked up using <function>getgrnam()</function>.
38223 </para>
38224 <para>
38225 <indexterm role="option">
38226 <primary><option>command_user</option></primary>
38227 </indexterm>
38228 </para>
38229 <informaltable frame="all">
38230 <tgroup cols="4" colsep="0" rowsep="0">
38231 <colspec colwidth="8*" align="left"/>
38232 <colspec colwidth="6*" align="center"/>
38233 <colspec colwidth="6*" align="center"/>
38234 <colspec colwidth="6*" align="right"/>
38235 <tbody>
38236 <row>
38237 <entry><option>command_user</option></entry>
38238 <entry>Use: <emphasis>queryprogram</emphasis></entry>
38239 <entry>Type: <emphasis>string</emphasis></entry>
38240 <entry>Default: <emphasis>unset</emphasis></entry>
38241 </row>
38242 </tbody>
38243 </tgroup>
38244 </informaltable>
38245 <para>
38246 <indexterm role="concept">
38247 <primary>uid (user id)</primary>
38248 <secondary>for <command>queryprogram</command></secondary>
38249 </indexterm>
38250 This option must be set. It specifies the uid which is set when running the
38251 command while routing an address for delivery. If the value begins with a digit,
38252 it is interpreted as the numerical value of the uid. Otherwise, it is looked up
38253 using <function>getpwnam()</function> to obtain a value for the uid and, if <option>command_group</option> is
38254 not set, a value for the gid also.
38255 </para>
38256 <para>
38257 <emphasis role="bold">Warning:</emphasis> Changing uid and gid is possible only when Exim is running as
38258 root, which it does during a normal delivery in a conventional configuration.
38259 However, when an address is being verified during message reception, Exim is
38260 usually running as the Exim user, not as root. If the <command>queryprogram</command> router
38261 is called from a non-root process, Exim cannot change uid or gid before running
38262 the command. In this circumstance the command runs under the current uid and
38263 gid.
38264 </para>
38265 <para>
38266 <indexterm role="option">
38267 <primary><option>current_directory</option></primary>
38268 </indexterm>
38269 </para>
38270 <informaltable frame="all">
38271 <tgroup cols="4" colsep="0" rowsep="0">
38272 <colspec colwidth="8*" align="left"/>
38273 <colspec colwidth="6*" align="center"/>
38274 <colspec colwidth="6*" align="center"/>
38275 <colspec colwidth="6*" align="right"/>
38276 <tbody>
38277 <row>
38278 <entry><option>current_directory</option></entry>
38279 <entry>Use: <emphasis>queryprogram</emphasis></entry>
38280 <entry>Type: <emphasis>string</emphasis></entry>
38281 <entry>Default: <emphasis>/</emphasis></entry>
38282 </row>
38283 </tbody>
38284 </tgroup>
38285 </informaltable>
38286 <para>
38287 This option specifies an absolute path which is made the current directory
38288 before running the command.
38289 </para>
38290 <para>
38291 <indexterm role="option">
38292 <primary><option>timeout</option></primary>
38293 </indexterm>
38294 </para>
38295 <informaltable frame="all">
38296 <tgroup cols="4" colsep="0" rowsep="0">
38297 <colspec colwidth="8*" align="left"/>
38298 <colspec colwidth="6*" align="center"/>
38299 <colspec colwidth="6*" align="center"/>
38300 <colspec colwidth="6*" align="right"/>
38301 <tbody>
38302 <row>
38303 <entry><option>timeout</option></entry>
38304 <entry>Use: <emphasis>queryprogram</emphasis></entry>
38305 <entry>Type: <emphasis>time</emphasis></entry>
38306 <entry>Default: <emphasis>1h</emphasis></entry>
38307 </row>
38308 </tbody>
38309 </tgroup>
38310 </informaltable>
38311 <para>
38312 If the command does not complete within the timeout period, its process group
38313 is killed and the message is frozen. A value of zero time specifies no
38314 timeout.
38315 </para>
38316 <para>
38317 The standard output of the command is connected to a pipe, which is read when
38318 the command terminates. It should consist of a single line of output,
38319 containing up to five fields, separated by white space. The maximum length of
38320 the line is 1023 characters. Longer lines are silently truncated. The first
38321 field is one of the following words (case-insensitive):
38322 </para>
38323 <itemizedlist>
38324 <listitem>
38325 <para>
38326 <emphasis>Accept</emphasis>: routing succeeded; the remaining fields specify what to do (see
38327 below).
38328 </para>
38329 </listitem>
38330 <listitem>
38331 <para>
38332 <emphasis>Decline</emphasis>: the router declines; pass the address to the next router, unless
38333 <option>no_more</option> is set.
38334 </para>
38335 </listitem>
38336 <listitem>
38337 <para>
38338 <emphasis>Fail</emphasis>: routing failed; do not pass the address to any more routers. Any
38339 subsequent text on the line is an error message. If the router is run as part
38340 of address verification during an incoming SMTP message, the message is
38341 included in the SMTP response.
38342 </para>
38343 </listitem>
38344 <listitem>
38345 <para>
38346 <emphasis>Defer</emphasis>: routing could not be completed at this time; try again later. Any
38347 subsequent text on the line is an error message which is logged. It is not
38348 included in any SMTP response.
38349 </para>
38350 </listitem>
38351 <listitem>
38352 <para>
38353 <emphasis>Freeze</emphasis>: the same as <emphasis>defer</emphasis>, except that the message is frozen.
38354 </para>
38355 </listitem>
38356 <listitem>
38357 <para>
38358 <emphasis>Pass</emphasis>: pass the address to the next router (or the router specified by
38359 <option>pass_router</option>), overriding <option>no_more</option>.
38360 </para>
38361 </listitem>
38362 <listitem>
38363 <para>
38364 <emphasis>Redirect</emphasis>: the message is redirected. The remainder of the line is a list of
38365 new addresses, which are routed independently, starting with the first router,
38366 or the router specified by <option>redirect_router</option>, if set.
38367 </para>
38368 </listitem>
38369 </itemizedlist>
38370 <para>
38371 When the first word is <emphasis>accept</emphasis>, the remainder of the line consists of a
38372 number of keyed data values, as follows (split into two lines here, to fit on
38373 the page):
38374 </para>
38375 <literallayout class="monospaced">
38376 ACCEPT TRANSPORT=&lt;transport&gt; HOSTS=&lt;list of hosts&gt;
38377 LOOKUP=byname|bydns DATA=&lt;text&gt;
38378 </literallayout>
38379 <para>
38380 The data items can be given in any order, and all are optional. If no transport
38381 is included, the transport specified by the generic <option>transport</option> option is
38382 used. The list of hosts and the lookup type are needed only if the transport is
38383 an <command>smtp</command> transport that does not itself supply a list of hosts.
38384 </para>
38385 <para>
38386 The format of the list of hosts is the same as for the <command>manualroute</command> router.
38387 As well as host names and IP addresses with optional port numbers, as described
38388 in section <xref linkend="SECTformatonehostitem"/>, it may contain names followed by
38389 <literal>/MX</literal> to specify sublists of hosts that are obtained by looking up MX records
38390 (see section <xref linkend="SECThostshowused"/>).
38391 </para>
38392 <para>
38393 If the lookup type is not specified, Exim behaves as follows when trying to
38394 find an IP address for each host: First, a DNS lookup is done. If this yields
38395 anything other than HOST_NOT_FOUND, that result is used. Otherwise, Exim
38396 goes on to try a call to <function>getipnodebyname()</function> or <function>gethostbyname()</function>, and the
38397 result of the lookup is the result of that call.
38398 </para>
38399 <para>
38400 <indexterm role="variable">
38401 <primary><varname>$address_data</varname></primary>
38402 </indexterm>
38403 If the DATA field is set, its value is placed in the <varname>$address_data</varname>
38404 variable. For example, this return line
38405 </para>
38406 <literallayout class="monospaced">
38407 accept hosts=x1.y.example:x2.y.example data="rule1"
38408 </literallayout>
38409 <para>
38410 routes the address to the default transport, passing a list of two hosts. When
38411 the transport runs, the string <quote>rule1</quote> is in <varname>$address_data</varname>.
38412 <indexterm role="concept" startref="IIDquerou1" class="endofrange"/>
38413 <indexterm role="concept" startref="IIDquerou2" class="endofrange"/>
38414 </para>
38415 </chapter>
38416
38417 <chapter id="CHAPredirect">
38418 <title>The redirect router</title>
38419 <para>
38420 <indexterm role="concept" id="IIDredrou1" class="startofrange">
38421 <primary><command>redirect</command> router</primary>
38422 </indexterm>
38423 <indexterm role="concept" id="IIDredrou2" class="startofrange">
38424 <primary>routers</primary>
38425 <secondary><command>redirect</command></secondary>
38426 </indexterm>
38427 <indexterm role="concept">
38428 <primary>alias file</primary>
38429 <secondary>in a <command>redirect</command> router</secondary>
38430 </indexterm>
38431 <indexterm role="concept">
38432 <primary>address redirection</primary>
38433 <secondary><command>redirect</command> router</secondary>
38434 </indexterm>
38435 The <command>redirect</command> router handles several kinds of address redirection. Its most
38436 common uses are for resolving local part aliases from a central alias file
38437 (usually called <filename>/etc/aliases</filename>) and for handling users&#x2019; personal <filename>.forward</filename>
38438 files, but it has many other potential uses. The incoming address can be
38439 redirected in several different ways:
38440 </para>
38441 <itemizedlist>
38442 <listitem>
38443 <para>
38444 It can be replaced by one or more new addresses which are themselves routed
38445 independently.
38446 </para>
38447 </listitem>
38448 <listitem>
38449 <para>
38450 It can be routed to be delivered to a given file or directory.
38451 </para>
38452 </listitem>
38453 <listitem>
38454 <para>
38455 It can be routed to be delivered to a specified pipe command.
38456 </para>
38457 </listitem>
38458 <listitem>
38459 <para>
38460 It can cause an automatic reply to be generated.
38461 </para>
38462 </listitem>
38463 <listitem>
38464 <para>
38465 It can be forced to fail, optionally with a custom error message.
38466 </para>
38467 </listitem>
38468 <listitem>
38469 <para>
38470 It can be temporarily deferred, optionally with a custom message.
38471 </para>
38472 </listitem>
38473 <listitem>
38474 <para>
38475 It can be discarded.
38476 </para>
38477 </listitem>
38478 </itemizedlist>
38479 <para>
38480 The generic <option>transport</option> option must not be set for <command>redirect</command> routers.
38481 However, there are some private options which define transports for delivery to
38482 files and pipes, and for generating autoreplies. See the <option>file_transport</option>,
38483 <option>pipe_transport</option> and <option>reply_transport</option> descriptions below.
38484 </para>
38485 <para>
38486 If success DSNs have been requested
38487 <indexterm role="concept">
38488 <primary>DSN</primary>
38489 <secondary>success</secondary>
38490 </indexterm>
38491 <indexterm role="concept">
38492 <primary>Delivery Status Notification</primary>
38493 <secondary>success</secondary>
38494 </indexterm>
38495 redirection triggers one and the DSN options are not passed any further.
38496 </para>
38497 <section id="SECID124">
38498 <title>Redirection data</title>
38499 <para>
38500 The router operates by interpreting a text string which it obtains either by
38501 expanding the contents of the <option>data</option> option, or by reading the entire
38502 contents of a file whose name is given in the <option>file</option> option. These two
38503 options are mutually exclusive. The first is commonly used for handling system
38504 aliases, in a configuration like this:
38505 </para>
38506 <literallayout class="monospaced">
38507 system_aliases:
38508   driver = redirect
38509   data = ${lookup{$local_part}lsearch{/etc/aliases}}
38510 </literallayout>
38511 <para>
38512 If the lookup fails, the expanded string in this example is empty. When the
38513 expansion of <option>data</option> results in an empty string, the router declines. A forced
38514 expansion failure also causes the router to decline; other expansion failures
38515 cause delivery to be deferred.
38516 </para>
38517 <para>
38518 A configuration using <option>file</option> is commonly used for handling users&#x2019;
38519 <filename>.forward</filename> files, like this:
38520 </para>
38521 <literallayout class="monospaced">
38522 userforward:
38523   driver = redirect
38524   check_local_user
38525   file = $home/.forward
38526   no_verify
38527 </literallayout>
38528 <para>
38529 If the file does not exist, or causes no action to be taken (for example, it is
38530 empty or consists only of comments), the router declines. <emphasis role="bold">Warning</emphasis>: This
38531 is not the case when the file contains syntactically valid items that happen to
38532 yield empty addresses, for example, items containing only RFC 2822 address
38533 comments.
38534 </para>
38535 </section>
38536 <section id="SECID125">
38537 <title>Forward files and address verification</title>
38538 <para>
38539 <indexterm role="concept">
38540 <primary>address redirection</primary>
38541 <secondary>while verifying</secondary>
38542 </indexterm>
38543 It is usual to set <option>no_verify</option> on <command>redirect</command> routers which handle users&#x2019;
38544 <filename>.forward</filename> files, as in the example above. There are two reasons for this:
38545 </para>
38546 <itemizedlist>
38547 <listitem>
38548 <para>
38549 When Exim is receiving an incoming SMTP message from a remote host, it is
38550 running under the Exim uid, not as root. Exim is unable to change uid to read
38551 the file as the user, and it may not be able to read it as the Exim user. So in
38552 practice the router may not be able to operate.
38553 </para>
38554 </listitem>
38555 <listitem>
38556 <para>
38557 However, even when the router can operate, the existence of a <filename>.forward</filename> file
38558 is unimportant when verifying an address. What should be checked is whether the
38559 local part is a valid user name or not. Cutting out the redirection processing
38560 saves some resources.
38561 </para>
38562 </listitem>
38563 </itemizedlist>
38564 </section>
38565 <section id="SECID126">
38566 <title>Interpreting redirection data</title>
38567 <para>
38568 <indexterm role="concept">
38569 <primary>Sieve filter</primary>
38570 <secondary>specifying in redirection data</secondary>
38571 </indexterm>
38572 <indexterm role="concept">
38573 <primary>filter</primary>
38574 <secondary>specifying in redirection data</secondary>
38575 </indexterm>
38576 The contents of the data string, whether obtained from <option>data</option> or <option>file</option>,
38577 can be interpreted in two different ways:
38578 </para>
38579 <itemizedlist>
38580 <listitem>
38581 <para>
38582 If the <option>allow_filter</option> option is set true, and the data begins with the text
38583 <quote>#Exim filter</quote> or <quote>#Sieve filter</quote>, it is interpreted as a list of
38584 <emphasis>filtering</emphasis> instructions in the form of an Exim or Sieve filter file,
38585 respectively. Details of the syntax and semantics of filter files are described
38586 in a separate document entitled <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis>; this
38587 document is intended for use by end users.
38588 </para>
38589 </listitem>
38590 <listitem>
38591 <para>
38592 Otherwise, the data must be a comma-separated list of redirection items, as
38593 described in the next section.
38594 </para>
38595 </listitem>
38596 </itemizedlist>
38597 <para>
38598 When a message is redirected to a file (a <quote>mail folder</quote>), the filename given
38599 in a non-filter redirection list must always be an absolute path. A filter may
38600 generate a relative path &ndash; how this is handled depends on the transport&#x2019;s
38601 configuration. See section <xref linkend="SECTfildiropt"/> for a discussion of this issue
38602 for the <command>appendfile</command> transport.
38603 </para>
38604 </section>
38605 <section id="SECTitenonfilred">
38606 <title>Items in a non-filter redirection list</title>
38607 <para>
38608 <indexterm role="concept">
38609 <primary>address redirection</primary>
38610 <secondary>non-filter list items</secondary>
38611 </indexterm>
38612 When the redirection data is not an Exim or Sieve filter, for example, if it
38613 comes from a conventional alias or forward file, it consists of a list of
38614 addresses, filenames, pipe commands, or certain special items (see section
38615 <xref linkend="SECTspecitredli"/> below). The special items can be individually enabled or
38616 disabled by means of options whose names begin with <option>allow_</option> or <option>forbid_</option>,
38617 depending on their default values. The items in the list are separated by
38618 commas or newlines.
38619 If a comma is required in an item, the entire item must be enclosed in double
38620 quotes.
38621 </para>
38622 <para>
38623 Lines starting with a # character are comments, and are ignored, and # may
38624 also appear following a comma, in which case everything between the # and the
38625 next newline character is ignored.
38626 </para>
38627 <para>
38628 If an item is entirely enclosed in double quotes, these are removed. Otherwise
38629 double quotes are retained because some forms of mail address require their use
38630 (but never to enclose the entire address). In the following description,
38631 <quote>item</quote> refers to what remains after any surrounding double quotes have been
38632 removed.
38633 </para>
38634 <para>
38635 <indexterm role="variable">
38636 <primary><varname>$local_part</varname></primary>
38637 </indexterm>
38638 <emphasis role="bold">Warning</emphasis>: If you use an Exim expansion to construct a redirection address,
38639 and the expansion contains a reference to <varname>$local_part</varname>, you should make use
38640 of the <option>quote_local_part</option> expansion operator, in case the local part contains
38641 special characters. For example, to redirect all mail for the domain
38642 <emphasis>obsolete.example</emphasis>, retaining the existing local part, you could use this
38643 setting:
38644 </para>
38645 <literallayout class="monospaced">
38646 data = ${quote_local_part:$local_part}@newdomain.example
38647 </literallayout>
38648 </section>
38649 <section id="SECTredlocmai">
38650 <title>Redirecting to a local mailbox</title>
38651 <para>
38652 <indexterm role="concept">
38653 <primary>routing</primary>
38654 <secondary>loops in</secondary>
38655 </indexterm>
38656 <indexterm role="concept">
38657 <primary>loop</primary>
38658 <secondary>while routing, avoidance of</secondary>
38659 </indexterm>
38660 <indexterm role="concept">
38661 <primary>address redirection</primary>
38662 <secondary>to local mailbox</secondary>
38663 </indexterm>
38664 A redirection item may safely be the same as the address currently under
38665 consideration. This does not cause a routing loop, because a router is
38666 automatically skipped if any ancestor of the address that is being processed
38667 is the same as the current address and was processed by the current router.
38668 Such an address is therefore passed to the following routers, so it is handled
38669 as if there were no redirection. When making this loop-avoidance test, the
38670 complete local part, including any prefix or suffix, is used.
38671 </para>
38672 <para>
38673 <indexterm role="concept">
38674 <primary>address redirection</primary>
38675 <secondary>local part without domain</secondary>
38676 </indexterm>
38677 Specifying the same local part without a domain is a common usage in personal
38678 filter files when the user wants to have messages delivered to the local
38679 mailbox and also forwarded elsewhere. For example, the user whose login is
38680 <emphasis>cleo</emphasis> might have a <filename>.forward</filename> file containing this:
38681 </para>
38682 <literallayout class="monospaced">
38683 cleo, cleopatra@egypt.example
38684 </literallayout>
38685 <para>
38686 <indexterm role="concept">
38687 <primary>backslash in alias file</primary>
38688 </indexterm>
38689 <indexterm role="concept">
38690 <primary>alias file</primary>
38691 <secondary>backslash in</secondary>
38692 </indexterm>
38693 For compatibility with other MTAs, such unqualified local parts may be
38694 preceded by <quote>\</quote>, but this is not a requirement for loop prevention. However,
38695 it does make a difference if more than one domain is being handled
38696 synonymously.
38697 </para>
38698 <para>
38699 If an item begins with <quote>\</quote> and the rest of the item parses as a valid RFC
38700 2822 address that does not include a domain, the item is qualified using the
38701 domain of the incoming address. In the absence of a leading <quote>\</quote>, unqualified
38702 addresses are qualified using the value in <option>qualify_recipient</option>, but you can
38703 force the incoming domain to be used by setting <option>qualify_preserve_domain</option>.
38704 </para>
38705 <para>
38706 Care must be taken if there are alias names for local users.
38707 Consider an MTA handling a single local domain where the system alias file
38708 contains:
38709 </para>
38710 <literallayout class="monospaced">
38711 Sam.Reman: spqr
38712 </literallayout>
38713 <para>
38714 Now suppose that Sam (whose login id is <emphasis>spqr</emphasis>) wants to save copies of
38715 messages in the local mailbox, and also forward copies elsewhere. He creates
38716 this forward file:
38717 </para>
38718 <literallayout class="monospaced">
38719 Sam.Reman, spqr@reme.elsewhere.example
38720 </literallayout>
38721 <para>
38722 With these settings, an incoming message addressed to <emphasis>Sam.Reman</emphasis> fails. The
38723 <command>redirect</command> router for system aliases does not process <emphasis>Sam.Reman</emphasis> the
38724 second time round, because it has previously routed it,
38725 and the following routers presumably cannot handle the alias. The forward file
38726 should really contain
38727 </para>
38728 <literallayout class="monospaced">
38729 spqr, spqr@reme.elsewhere.example
38730 </literallayout>
38731 <para>
38732 but because this is such a common error, the <option>check_ancestor</option> option (see
38733 below) exists to provide a way to get round it. This is normally set on a
38734 <command>redirect</command> router that is handling users&#x2019; <filename>.forward</filename> files.
38735 </para>
38736 </section>
38737 <section id="SECTspecitredli">
38738 <title>Special items in redirection lists</title>
38739 <para>
38740 In addition to addresses, the following types of item may appear in redirection
38741 lists (that is, in non-filter redirection data):
38742 </para>
38743 <itemizedlist>
38744 <listitem>
38745 <para>
38746 <indexterm role="concept">
38747 <primary>pipe</primary>
38748 <secondary>in redirection list</secondary>
38749 </indexterm>
38750 <indexterm role="concept">
38751 <primary>address redirection</primary>
38752 <secondary>to pipe</secondary>
38753 </indexterm>
38754 An item is treated as a pipe command if it begins with <quote>|</quote> and does not parse
38755 as a valid RFC 2822 address that includes a domain. A transport for running the
38756 command must be specified by the <option>pipe_transport</option> option.
38757 Normally, either the router or the transport specifies a user and a group under
38758 which to run the delivery. The default is to use the Exim user and group.
38759 </para>
38760 <para>
38761 Single or double quotes can be used for enclosing the individual arguments of
38762 the pipe command; no interpretation of escapes is done for single quotes. If
38763 the command contains a comma character, it is necessary to put the whole item
38764 in double quotes, for example:
38765 </para>
38766 <literallayout class="monospaced">
38767 "|/some/command ready,steady,go"
38768 </literallayout>
38769 <para>
38770 since items in redirection lists are terminated by commas. Do not, however,
38771 quote just the command. An item such as
38772 </para>
38773 <literallayout class="monospaced">
38774 |"/some/command ready,steady,go"
38775 </literallayout>
38776 <para>
38777 is interpreted as a pipe with a rather strange command name, and no arguments.
38778 </para>
38779 <para>
38780 Note that the above example assumes that the text comes from a lookup source
38781 of some sort, so that the quotes are part of the data.  If composing a
38782 redirect router with a <option>data</option> option directly specifying this command, the
38783 quotes will be used by the configuration parser to define the extent of one
38784 string, but will not be passed down into the redirect router itself.  There
38785 are two main approaches to get around this: escape quotes to be part of the
38786 data itself, or avoid using this mechanism and instead create a custom
38787 transport with the <option>command</option> option set and reference that transport from
38788 an <option>accept</option> router.
38789 </para>
38790 </listitem>
38791 <listitem>
38792 <para>
38793 <indexterm role="concept">
38794 <primary>file</primary>
38795 <secondary>in redirection list</secondary>
38796 </indexterm>
38797 <indexterm role="concept">
38798 <primary>address redirection</primary>
38799 <secondary>to file</secondary>
38800 </indexterm>
38801 An item is interpreted as a path name if it begins with <quote>/</quote> and does not
38802 parse as a valid RFC 2822 address that includes a domain. For example,
38803 </para>
38804 <literallayout class="monospaced">
38805 /home/world/minbari
38806 </literallayout>
38807 <para>
38808 is treated as a filename, but
38809 </para>
38810 <literallayout class="monospaced">
38811 /s=molari/o=babylon/@x400gate.way
38812 </literallayout>
38813 <para>
38814 is treated as an address. For a filename, a transport must be specified using
38815 the <option>file_transport</option> option. However, if the generated path name ends with a
38816 forward slash character, it is interpreted as a directory name rather than a
38817 filename, and <option>directory_transport</option> is used instead.
38818 </para>
38819 <para>
38820 Normally, either the router or the transport specifies a user and a group under
38821 which to run the delivery. The default is to use the Exim user and group.
38822 </para>
38823 <para>
38824 <indexterm role="concept">
38825 <primary><filename>/dev/null</filename></primary>
38826 </indexterm>
38827 However, if a redirection item is the path <filename>/dev/null</filename>, delivery to it is
38828 bypassed at a high level, and the log entry shows <quote>**bypassed**</quote>
38829 instead of a transport name. In this case the user and group are not used.
38830 </para>
38831 </listitem>
38832 <listitem>
38833 <para>
38834 <indexterm role="concept">
38835 <primary>included address list</primary>
38836 </indexterm>
38837 <indexterm role="concept">
38838 <primary>address redirection</primary>
38839 <secondary>included external list</secondary>
38840 </indexterm>
38841 If an item is of the form
38842 </para>
38843 <literallayout class="monospaced">
38844 :include:&lt;path name&gt;
38845 </literallayout>
38846 <para>
38847 a list of further items is taken from the given file and included at that
38848 point. <emphasis role="bold">Note</emphasis>: Such a file can not be a filter file; it is just an
38849 out-of-line addition to the list. The items in the included list are separated
38850 by commas or newlines and are not subject to expansion. If this is the first
38851 item in an alias list in an <command>lsearch</command> file, a colon must be used to terminate
38852 the alias name. This example is incorrect:
38853 </para>
38854 <literallayout class="monospaced">
38855 list1    :include:/opt/lists/list1
38856 </literallayout>
38857 <para>
38858 It must be given as
38859 </para>
38860 <literallayout class="monospaced">
38861 list1:   :include:/opt/lists/list1
38862 </literallayout>
38863 </listitem>
38864 <listitem>
38865 <para>
38866 <indexterm role="concept">
38867 <primary>address redirection</primary>
38868 <secondary>to black hole</secondary>
38869 </indexterm>
38870 <indexterm role="concept">
38871 <primary>delivery</primary>
38872 <secondary>discard</secondary>
38873 </indexterm>
38874 <indexterm role="concept">
38875 <primary>delivery</primary>
38876 <secondary>blackhole</secondary>
38877 </indexterm>
38878 <indexterm role="concept">
38879 <primary>black hole</primary>
38880 </indexterm>
38881 <indexterm role="concept">
38882 <primary>abandoning mail</primary>
38883 </indexterm>
38884 Sometimes you want to throw away mail to a particular local part.  Making the
38885 <option>data</option> option expand to an empty string does not work, because that causes
38886 the router to decline. Instead, the alias item
38887 </para>
38888 <literallayout class="monospaced">
38889 :blackhole:
38890 </literallayout>
38891 <para>
38892 can be used. It does what its name implies. No delivery is
38893 done, and no error message is generated. This has the same effect as specifying
38894 <filename>/dev/null</filename> as a destination, but it can be independently disabled.
38895 </para>
38896 <para>
38897 <emphasis role="bold">Warning</emphasis>: If <emphasis>:blackhole:</emphasis> appears anywhere in a redirection list, no
38898 delivery is done for the original local part, even if other redirection items
38899 are present. If you are generating a multi-item list (for example, by reading a
38900 database) and need the ability to provide a no-op item, you must use
38901 <filename>/dev/null</filename>.
38902 </para>
38903 </listitem>
38904 <listitem>
38905 <para>
38906 <indexterm role="concept">
38907 <primary>delivery</primary>
38908 <secondary>forcing failure</secondary>
38909 </indexterm>
38910 <indexterm role="concept">
38911 <primary>delivery</primary>
38912 <secondary>forcing deferral</secondary>
38913 </indexterm>
38914 <indexterm role="concept">
38915 <primary>failing delivery</primary>
38916 <secondary>forcing</secondary>
38917 </indexterm>
38918 <indexterm role="concept">
38919 <primary>deferred delivery, forcing</primary>
38920 </indexterm>
38921 <indexterm role="concept">
38922 <primary>customizing</primary>
38923 <secondary>failure message</secondary>
38924 </indexterm>
38925 An attempt to deliver a particular address can be deferred or forced to fail by
38926 redirection items of the form
38927 </para>
38928 <literallayout class="monospaced">
38929 :defer:
38930 :fail:
38931 </literallayout>
38932 <para>
38933 respectively. When a redirection list contains such an item, it applies
38934 to the entire redirection; any other items in the list are ignored. Any
38935 text following <emphasis>:fail:</emphasis> or <emphasis>:defer:</emphasis> is placed in the error text
38936 associated with the failure. For example, an alias file might contain:
38937 </para>
38938 <literallayout class="monospaced">
38939 X.Employee:  :fail: Gone away, no forwarding address
38940 </literallayout>
38941 <para>
38942 In the case of an address that is being verified from an ACL or as the subject
38943 of a
38944 <indexterm role="concept">
38945 <primary>VRFY</primary>
38946 <secondary>error text, display of</secondary>
38947 </indexterm>
38948 VRFY command, the text is included in the SMTP error response by
38949 default.
38950 <indexterm role="concept">
38951 <primary>EXPN</primary>
38952 <secondary>error text, display of</secondary>
38953 </indexterm>
38954 The text is not included in the response to an EXPN command. In non-SMTP cases
38955 the text is included in the error message that Exim generates.
38956 </para>
38957 <para>
38958 <indexterm role="concept">
38959 <primary>SMTP</primary>
38960 <secondary>error codes</secondary>
38961 </indexterm>
38962 By default, Exim sends a 451 SMTP code for a <emphasis>:defer:</emphasis>, and 550 for
38963 <emphasis>:fail:</emphasis>. However, if the message starts with three digits followed by a
38964 space, optionally followed by an extended code of the form <emphasis>n.n.n</emphasis>, also
38965 followed by a space, and the very first digit is the same as the default error
38966 code, the code from the message is used instead. If the very first digit is
38967 incorrect, a panic error is logged, and the default code is used. You can
38968 suppress the use of the supplied code in a redirect router by setting the
38969 <option>forbid_smtp_code</option> option true. In this case, any SMTP code is quietly
38970 ignored.
38971 </para>
38972 <para>
38973 <indexterm role="variable">
38974 <primary><varname>$acl_verify_message</varname></primary>
38975 </indexterm>
38976 In an ACL, an explicitly provided message overrides the default, but the
38977 default message is available in the variable <varname>$acl_verify_message</varname> and can
38978 therefore be included in a custom message if this is desired.
38979 </para>
38980 <para>
38981 Normally the error text is the rest of the redirection list &ndash; a comma does
38982 not terminate it &ndash; but a newline does act as a terminator. Newlines are not
38983 normally present in alias expansions. In <command>lsearch</command> lookups they are removed
38984 as part of the continuation process, but they may exist in other kinds of
38985 lookup and in <emphasis>:include:</emphasis> files.
38986 </para>
38987 <para>
38988 During routing for message delivery (as opposed to verification), a redirection
38989 containing <emphasis>:fail:</emphasis> causes an immediate failure of the incoming address,
38990 whereas <emphasis>:defer:</emphasis> causes the message to remain in the queue so that a
38991 subsequent delivery attempt can happen at a later time. If an address is
38992 deferred for too long, it will ultimately fail, because the normal retry
38993 rules still apply.
38994 </para>
38995 </listitem>
38996 <listitem>
38997 <para>
38998 <indexterm role="concept">
38999 <primary>alias file</primary>
39000 <secondary>exception to default</secondary>
39001 </indexterm>
39002 Sometimes it is useful to use a single-key search type with a default (see
39003 chapter <xref linkend="CHAPfdlookup"/>) to look up aliases. However, there may be a need
39004 for exceptions to the default. These can be handled by aliasing them to
39005 <emphasis>:unknown:</emphasis>. This differs from <emphasis>:fail:</emphasis> in that it causes the <command>redirect</command>
39006 router to decline, whereas <emphasis>:fail:</emphasis> forces routing to fail. A lookup which
39007 results in an empty redirection list has the same effect.
39008 </para>
39009 </listitem>
39010 </itemizedlist>
39011 </section>
39012 <section id="SECTdupaddr">
39013 <title>Duplicate addresses</title>
39014 <para>
39015 <indexterm role="concept">
39016 <primary>duplicate addresses</primary>
39017 </indexterm>
39018 <indexterm role="concept">
39019 <primary>address duplicate, discarding</primary>
39020 </indexterm>
39021 <indexterm role="concept">
39022 <primary>pipe</primary>
39023 <secondary>duplicated</secondary>
39024 </indexterm>
39025 Exim removes duplicate addresses from the list to which it is delivering, so as
39026 to deliver just one copy to each address. This does not apply to deliveries
39027 routed to pipes by different immediate parent addresses, but an indirect
39028 aliasing scheme of the type
39029 </para>
39030 <literallayout class="monospaced">
39031 pipe:       |/some/command $local_part
39032 localpart1: pipe
39033 localpart2: pipe
39034 </literallayout>
39035 <para>
39036 does not work with a message that is addressed to both local parts, because
39037 when the second is aliased to the intermediate local part <quote>pipe</quote> it gets
39038 discarded as being the same as a previously handled address. However, a scheme
39039 such as
39040 </para>
39041 <literallayout class="monospaced">
39042 localpart1: |/some/command $local_part
39043 localpart2: |/some/command $local_part
39044 </literallayout>
39045 <para>
39046 does result in two different pipe deliveries, because the immediate parents of
39047 the pipes are distinct.
39048 </para>
39049 </section>
39050 <section id="SECID128">
39051 <title>Repeated redirection expansion</title>
39052 <para>
39053 <indexterm role="concept">
39054 <primary>repeated redirection expansion</primary>
39055 </indexterm>
39056 <indexterm role="concept">
39057 <primary>address redirection</primary>
39058 <secondary>repeated for each delivery attempt</secondary>
39059 </indexterm>
39060 When a message cannot be delivered to all of its recipients immediately,
39061 leading to two or more delivery attempts, redirection expansion is carried out
39062 afresh each time for those addresses whose children were not all previously
39063 delivered. If redirection is being used as a mailing list, this can lead to new
39064 members of the list receiving copies of old messages. The <option>one_time</option> option
39065 can be used to avoid this.
39066 </para>
39067 </section>
39068 <section id="SECID129">
39069 <title>Errors in redirection lists</title>
39070 <para>
39071 <indexterm role="concept">
39072 <primary>address redirection</primary>
39073 <secondary>errors</secondary>
39074 </indexterm>
39075 If <option>skip_syntax_errors</option> is set, a malformed address that causes a parsing
39076 error is skipped, and an entry is written to the main log. This may be useful
39077 for mailing lists that are automatically managed. Otherwise, if an error is
39078 detected while generating the list of new addresses, the original address is
39079 deferred. See also <option>syntax_errors_to</option>.
39080 </para>
39081 </section>
39082 <section id="SECID130">
39083 <title>Private options for the redirect router</title>
39084 <para>
39085 <indexterm role="concept">
39086 <primary>options</primary>
39087 <secondary><command>redirect</command> router</secondary>
39088 </indexterm>
39089 The private options for the <command>redirect</command> router are as follows:
39090 </para>
39091 <para>
39092 <indexterm role="option">
39093 <primary><option>allow_defer</option></primary>
39094 </indexterm>
39095 </para>
39096 <informaltable frame="all">
39097 <tgroup cols="4" colsep="0" rowsep="0">
39098 <colspec colwidth="8*" align="left"/>
39099 <colspec colwidth="6*" align="center"/>
39100 <colspec colwidth="6*" align="center"/>
39101 <colspec colwidth="6*" align="right"/>
39102 <tbody>
39103 <row>
39104 <entry><option>allow_defer</option></entry>
39105 <entry>Use: <emphasis>redirect</emphasis></entry>
39106 <entry>Type: <emphasis>boolean</emphasis></entry>
39107 <entry>Default: <emphasis>false</emphasis></entry>
39108 </row>
39109 </tbody>
39110 </tgroup>
39111 </informaltable>
39112 <para>
39113 Setting this option allows the use of <emphasis>:defer:</emphasis> in non-filter redirection
39114 data, or the <option>defer</option> command in an Exim filter file.
39115 </para>
39116 <para>
39117 <indexterm role="option">
39118 <primary><option>allow_fail</option></primary>
39119 </indexterm>
39120 </para>
39121 <informaltable frame="all">
39122 <tgroup cols="4" colsep="0" rowsep="0">
39123 <colspec colwidth="8*" align="left"/>
39124 <colspec colwidth="6*" align="center"/>
39125 <colspec colwidth="6*" align="center"/>
39126 <colspec colwidth="6*" align="right"/>
39127 <tbody>
39128 <row>
39129 <entry><option>allow_fail</option></entry>
39130 <entry>Use: <emphasis>redirect</emphasis></entry>
39131 <entry>Type: <emphasis>boolean</emphasis></entry>
39132 <entry>Default: <emphasis>false</emphasis></entry>
39133 </row>
39134 </tbody>
39135 </tgroup>
39136 </informaltable>
39137 <para>
39138 <indexterm role="concept">
39139 <primary>failing delivery</primary>
39140 <secondary>from filter</secondary>
39141 </indexterm>
39142 If this option is true, the <emphasis>:fail:</emphasis> item can be used in a redirection list,
39143 and the <option>fail</option> command may be used in an Exim filter file.
39144 </para>
39145 <para>
39146 <indexterm role="option">
39147 <primary><option>allow_filter</option></primary>
39148 </indexterm>
39149 </para>
39150 <informaltable frame="all">
39151 <tgroup cols="4" colsep="0" rowsep="0">
39152 <colspec colwidth="8*" align="left"/>
39153 <colspec colwidth="6*" align="center"/>
39154 <colspec colwidth="6*" align="center"/>
39155 <colspec colwidth="6*" align="right"/>
39156 <tbody>
39157 <row>
39158 <entry><option>allow_filter</option></entry>
39159 <entry>Use: <emphasis>redirect</emphasis></entry>
39160 <entry>Type: <emphasis>boolean</emphasis></entry>
39161 <entry>Default: <emphasis>false</emphasis></entry>
39162 </row>
39163 </tbody>
39164 </tgroup>
39165 </informaltable>
39166 <para>
39167 <indexterm role="concept">
39168 <primary>filter</primary>
39169 <secondary>enabling use of</secondary>
39170 </indexterm>
39171 <indexterm role="concept">
39172 <primary>Sieve filter</primary>
39173 <secondary>enabling use of</secondary>
39174 </indexterm>
39175 Setting this option allows Exim to interpret redirection data that starts with
39176 <quote>#Exim filter</quote> or <quote>#Sieve filter</quote> as a set of filtering instructions. There
39177 are some features of Exim filter files that some administrators may wish to
39178 lock out; see the <option>forbid_filter_</option><emphasis>xxx</emphasis> options below.
39179 </para>
39180 <para>
39181 It is also possible to lock out Exim filters or Sieve filters while allowing
39182 the other type; see <option>forbid_exim_filter</option> and <option>forbid_sieve_filter</option>.
39183 </para>
39184 <para>
39185 The filter is run using the uid and gid set by the generic <option>user</option> and
39186 <option>group</option> options. These take their defaults from the password data if
39187 <option>check_local_user</option> is set, so in the normal case of users&#x2019; personal filter
39188 files, the filter is run as the relevant user. When <option>allow_filter</option> is set
39189 true, Exim insists that either <option>check_local_user</option> or <option>user</option> is set.
39190 </para>
39191 <para>
39192 <indexterm role="option">
39193 <primary><option>allow_freeze</option></primary>
39194 </indexterm>
39195 </para>
39196 <informaltable frame="all">
39197 <tgroup cols="4" colsep="0" rowsep="0">
39198 <colspec colwidth="8*" align="left"/>
39199 <colspec colwidth="6*" align="center"/>
39200 <colspec colwidth="6*" align="center"/>
39201 <colspec colwidth="6*" align="right"/>
39202 <tbody>
39203 <row>
39204 <entry><option>allow_freeze</option></entry>
39205 <entry>Use: <emphasis>redirect</emphasis></entry>
39206 <entry>Type: <emphasis>boolean</emphasis></entry>
39207 <entry>Default: <emphasis>false</emphasis></entry>
39208 </row>
39209 </tbody>
39210 </tgroup>
39211 </informaltable>
39212 <para>
39213 <indexterm role="concept">
39214 <primary>freezing messages</primary>
39215 <secondary>allowing in filter</secondary>
39216 </indexterm>
39217 Setting this option allows the use of the <option>freeze</option> command in an Exim filter.
39218 This command is more normally encountered in system filters, and is disabled by
39219 default for redirection filters because it isn&#x2019;t something you usually want to
39220 let ordinary users do.
39221 </para>
39222 <para>
39223 <indexterm role="option">
39224 <primary><option>check_ancestor</option></primary>
39225 </indexterm>
39226 </para>
39227 <informaltable frame="all">
39228 <tgroup cols="4" colsep="0" rowsep="0">
39229 <colspec colwidth="8*" align="left"/>
39230 <colspec colwidth="6*" align="center"/>
39231 <colspec colwidth="6*" align="center"/>
39232 <colspec colwidth="6*" align="right"/>
39233 <tbody>
39234 <row>
39235 <entry><option>check_ancestor</option></entry>
39236 <entry>Use: <emphasis>redirect</emphasis></entry>
39237 <entry>Type: <emphasis>boolean</emphasis></entry>
39238 <entry>Default: <emphasis>false</emphasis></entry>
39239 </row>
39240 </tbody>
39241 </tgroup>
39242 </informaltable>
39243 <para>
39244 This option is concerned with handling generated addresses that are the same
39245 as some address in the list of redirection ancestors of the current address.
39246 Although it is turned off by default in the code, it is set in the default
39247 configuration file for handling users&#x2019; <filename>.forward</filename> files. It is recommended
39248 for this use of the <command>redirect</command> router.
39249 </para>
39250 <para>
39251 When <option>check_ancestor</option> is set, if a generated address (including the domain)
39252 is the same as any ancestor of the current address, it is replaced by a copy of
39253 the current address. This helps in the case where local part A is aliased to B,
39254 and B has a <filename>.forward</filename> file pointing back to A. For example, within a single
39255 domain, the local part <quote>Joe.Bloggs</quote> is aliased to <quote>jb</quote> and
39256 <filename>&nbsp;jb/.forward</filename> contains:
39257 </para>
39258 <literallayout class="monospaced">
39259 \Joe.Bloggs, &lt;other item(s)&gt;
39260 </literallayout>
39261 <para>
39262 Without the <option>check_ancestor</option> setting, either local part (<quote>jb</quote> or
39263 <quote>joe.bloggs</quote>) gets processed once by each router and so ends up as it was
39264 originally. If <quote>jb</quote> is the real mailbox name, mail to <quote>jb</quote> gets delivered
39265 (having been turned into <quote>joe.bloggs</quote> by the <filename>.forward</filename> file and back to
39266 <quote>jb</quote> by the alias), but mail to <quote>joe.bloggs</quote> fails. Setting
39267 <option>check_ancestor</option> on the <command>redirect</command> router that handles the <filename>.forward</filename>
39268 file prevents it from turning <quote>jb</quote> back into <quote>joe.bloggs</quote> when that was the
39269 original address. See also the <option>repeat_use</option> option below.
39270 </para>
39271 <para>
39272 <indexterm role="option">
39273 <primary><option>check_group</option></primary>
39274 </indexterm>
39275 </para>
39276 <informaltable frame="all">
39277 <tgroup cols="4" colsep="0" rowsep="0">
39278 <colspec colwidth="8*" align="left"/>
39279 <colspec colwidth="6*" align="center"/>
39280 <colspec colwidth="6*" align="center"/>
39281 <colspec colwidth="6*" align="right"/>
39282 <tbody>
39283 <row>
39284 <entry><option>check_group</option></entry>
39285 <entry>Use: <emphasis>redirect</emphasis></entry>
39286 <entry>Type: <emphasis>boolean</emphasis></entry>
39287 <entry>Default: <emphasis>see below</emphasis></entry>
39288 </row>
39289 </tbody>
39290 </tgroup>
39291 </informaltable>
39292 <para>
39293 When the <option>file</option> option is used, the group owner of the file is checked only
39294 when this option is set. The permitted groups are those listed in the
39295 <option>owngroups</option> option, together with the user&#x2019;s default group if
39296 <option>check_local_user</option> is set. If the file has the wrong group, routing is
39297 deferred. The default setting for this option is true if <option>check_local_user</option>
39298 is set and the <option>modemask</option> option permits the group write bit, or if the
39299 <option>owngroups</option> option is set. Otherwise it is false, and no group check occurs.
39300 </para>
39301 <para>
39302 <indexterm role="option">
39303 <primary><option>check_owner</option></primary>
39304 </indexterm>
39305 </para>
39306 <informaltable frame="all">
39307 <tgroup cols="4" colsep="0" rowsep="0">
39308 <colspec colwidth="8*" align="left"/>
39309 <colspec colwidth="6*" align="center"/>
39310 <colspec colwidth="6*" align="center"/>
39311 <colspec colwidth="6*" align="right"/>
39312 <tbody>
39313 <row>
39314 <entry><option>check_owner</option></entry>
39315 <entry>Use: <emphasis>redirect</emphasis></entry>
39316 <entry>Type: <emphasis>boolean</emphasis></entry>
39317 <entry>Default: <emphasis>see below</emphasis></entry>
39318 </row>
39319 </tbody>
39320 </tgroup>
39321 </informaltable>
39322 <para>
39323 When the <option>file</option> option is used, the owner of the file is checked only when
39324 this option is set. If <option>check_local_user</option> is set, the local user is
39325 permitted; otherwise the owner must be one of those listed in the <option>owners</option>
39326 option. The default value for this option is true if <option>check_local_user</option> or
39327 <option>owners</option> is set. Otherwise the default is false, and no owner check occurs.
39328 </para>
39329 <para>
39330 <indexterm role="option">
39331 <primary><option>data</option></primary>
39332 </indexterm>
39333 </para>
39334 <informaltable frame="all">
39335 <tgroup cols="4" colsep="0" rowsep="0">
39336 <colspec colwidth="8*" align="left"/>
39337 <colspec colwidth="6*" align="center"/>
39338 <colspec colwidth="6*" align="center"/>
39339 <colspec colwidth="6*" align="right"/>
39340 <tbody>
39341 <row>
39342 <entry><option>data</option></entry>
39343 <entry>Use: <emphasis>redirect</emphasis></entry>
39344 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39345 <entry>Default: <emphasis>unset</emphasis></entry>
39346 </row>
39347 </tbody>
39348 </tgroup>
39349 </informaltable>
39350 <para>
39351 This option is mutually exclusive with <option>file</option>. One or other of them must be
39352 set, but not both. The contents of <option>data</option> are expanded, and then used as the
39353 list of forwarding items, or as a set of filtering instructions. If the
39354 expansion is forced to fail, or the result is an empty string or a string that
39355 has no effect (consists entirely of comments), the router declines.
39356 </para>
39357 <para>
39358 When filtering instructions are used, the string must begin with <quote>#Exim
39359 filter</quote>, and all comments in the string, including this initial one, must be
39360 terminated with newline characters. For example:
39361 </para>
39362 <literallayout class="monospaced">
39363 data = #Exim filter\n\
39364        if $h_to: contains Exim then save $home/mail/exim endif
39365 </literallayout>
39366 <para>
39367 If you are reading the data from a database where newlines cannot be included,
39368 you can use the <varname>${sg}</varname> expansion item to turn the escape string of your
39369 choice into a newline.
39370 </para>
39371 <para>
39372 <indexterm role="option">
39373 <primary><option>directory_transport</option></primary>
39374 </indexterm>
39375 </para>
39376 <informaltable frame="all">
39377 <tgroup cols="4" colsep="0" rowsep="0">
39378 <colspec colwidth="8*" align="left"/>
39379 <colspec colwidth="6*" align="center"/>
39380 <colspec colwidth="6*" align="center"/>
39381 <colspec colwidth="6*" align="right"/>
39382 <tbody>
39383 <row>
39384 <entry><option>directory_transport</option></entry>
39385 <entry>Use: <emphasis>redirect</emphasis></entry>
39386 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39387 <entry>Default: <emphasis>unset</emphasis></entry>
39388 </row>
39389 </tbody>
39390 </tgroup>
39391 </informaltable>
39392 <para>
39393 A <command>redirect</command> router sets up a direct delivery to a directory when a path name
39394 ending with a slash is specified as a new <quote>address</quote>. The transport used is
39395 specified by this option, which, after expansion, must be the name of a
39396 configured transport. This should normally be an <command>appendfile</command> transport.
39397 </para>
39398 <para>
39399 <indexterm role="option">
39400 <primary><option>file</option></primary>
39401 </indexterm>
39402 </para>
39403 <informaltable frame="all">
39404 <tgroup cols="4" colsep="0" rowsep="0">
39405 <colspec colwidth="8*" align="left"/>
39406 <colspec colwidth="6*" align="center"/>
39407 <colspec colwidth="6*" align="center"/>
39408 <colspec colwidth="6*" align="right"/>
39409 <tbody>
39410 <row>
39411 <entry><option>file</option></entry>
39412 <entry>Use: <emphasis>redirect</emphasis></entry>
39413 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39414 <entry>Default: <emphasis>unset</emphasis></entry>
39415 </row>
39416 </tbody>
39417 </tgroup>
39418 </informaltable>
39419 <para>
39420 This option specifies the name of a file that contains the redirection data. It
39421 is mutually exclusive with the <option>data</option> option. The string is expanded before
39422 use; if the expansion is forced to fail, the router declines. Other expansion
39423 failures cause delivery to be deferred. The result of a successful expansion
39424 must be an absolute path. The entire file is read and used as the redirection
39425 data. If the data is an empty string or a string that has no effect (consists
39426 entirely of comments), the router declines.
39427 </para>
39428 <para>
39429 <indexterm role="concept">
39430 <primary>NFS</primary>
39431 <secondary>checking for file existence</secondary>
39432 </indexterm>
39433 If the attempt to open the file fails with a <quote>does not exist</quote> error, Exim
39434 runs a check on the containing directory,
39435 unless <option>ignore_enotdir</option> is true (see below).
39436 If the directory does not appear to exist, delivery is deferred. This can
39437 happen when users&#x2019; <filename>.forward</filename> files are in NFS-mounted directories, and there
39438 is a mount problem. If the containing directory does exist, but the file does
39439 not, the router declines.
39440 </para>
39441 <para>
39442 <indexterm role="option">
39443 <primary><option>file_transport</option></primary>
39444 </indexterm>
39445 </para>
39446 <informaltable frame="all">
39447 <tgroup cols="4" colsep="0" rowsep="0">
39448 <colspec colwidth="8*" align="left"/>
39449 <colspec colwidth="6*" align="center"/>
39450 <colspec colwidth="6*" align="center"/>
39451 <colspec colwidth="6*" align="right"/>
39452 <tbody>
39453 <row>
39454 <entry><option>file_transport</option></entry>
39455 <entry>Use: <emphasis>redirect</emphasis></entry>
39456 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39457 <entry>Default: <emphasis>unset</emphasis></entry>
39458 </row>
39459 </tbody>
39460 </tgroup>
39461 </informaltable>
39462 <para>
39463 <indexterm role="variable">
39464 <primary><varname>$address_file</varname></primary>
39465 </indexterm>
39466 A <command>redirect</command> router sets up a direct delivery to a file when a path name not
39467 ending in a slash is specified as a new <quote>address</quote>. The transport used is
39468 specified by this option, which, after expansion, must be the name of a
39469 configured transport. This should normally be an <command>appendfile</command> transport. When
39470 it is running, the filename is in <varname>$address_file</varname>.
39471 </para>
39472 <para>
39473 <indexterm role="option">
39474 <primary><option>filter_prepend_home</option></primary>
39475 </indexterm>
39476 </para>
39477 <informaltable frame="all">
39478 <tgroup cols="4" colsep="0" rowsep="0">
39479 <colspec colwidth="8*" align="left"/>
39480 <colspec colwidth="6*" align="center"/>
39481 <colspec colwidth="6*" align="center"/>
39482 <colspec colwidth="6*" align="right"/>
39483 <tbody>
39484 <row>
39485 <entry><option>filter_prepend_home</option></entry>
39486 <entry>Use: <emphasis>redirect</emphasis></entry>
39487 <entry>Type: <emphasis>boolean</emphasis></entry>
39488 <entry>Default: <emphasis>true</emphasis></entry>
39489 </row>
39490 </tbody>
39491 </tgroup>
39492 </informaltable>
39493 <para>
39494 When this option is true, if a <command>save</command> command in an Exim filter specifies a
39495 relative path, and <varname>$home</varname> is defined, it is automatically prepended to the
39496 relative path. If this option is set false, this action does not happen. The
39497 relative path is then passed to the transport unmodified.
39498 </para>
39499 <para>
39500 <indexterm role="option">
39501 <primary><option>forbid_blackhole</option></primary>
39502 </indexterm>
39503 </para>
39504 <informaltable frame="all">
39505 <tgroup cols="4" colsep="0" rowsep="0">
39506 <colspec colwidth="8*" align="left"/>
39507 <colspec colwidth="6*" align="center"/>
39508 <colspec colwidth="6*" align="center"/>
39509 <colspec colwidth="6*" align="right"/>
39510 <tbody>
39511 <row>
39512 <entry><option>forbid_blackhole</option></entry>
39513 <entry>Use: <emphasis>redirect</emphasis></entry>
39514 <entry>Type: <emphasis>boolean</emphasis></entry>
39515 <entry>Default: <emphasis>false</emphasis></entry>
39516 </row>
39517 </tbody>
39518 </tgroup>
39519 </informaltable>
39520 <para>
39521 <indexterm role="concept">
39522 <primary>restricting access to features</primary>
39523 </indexterm>
39524 <indexterm role="concept">
39525 <primary>filter</primary>
39526 <secondary>locking out certain features</secondary>
39527 </indexterm>
39528 If this option is true, the <emphasis>:blackhole:</emphasis> item may not appear in a
39529 redirection list.
39530 </para>
39531 <para>
39532 <indexterm role="option">
39533 <primary><option>forbid_exim_filter</option></primary>
39534 </indexterm>
39535 </para>
39536 <informaltable frame="all">
39537 <tgroup cols="4" colsep="0" rowsep="0">
39538 <colspec colwidth="8*" align="left"/>
39539 <colspec colwidth="6*" align="center"/>
39540 <colspec colwidth="6*" align="center"/>
39541 <colspec colwidth="6*" align="right"/>
39542 <tbody>
39543 <row>
39544 <entry><option>forbid_exim_filter</option></entry>
39545 <entry>Use: <emphasis>redirect</emphasis></entry>
39546 <entry>Type: <emphasis>boolean</emphasis></entry>
39547 <entry>Default: <emphasis>false</emphasis></entry>
39548 </row>
39549 </tbody>
39550 </tgroup>
39551 </informaltable>
39552 <para>
39553 <indexterm role="concept">
39554 <primary>restricting access to features</primary>
39555 </indexterm>
39556 <indexterm role="concept">
39557 <primary>filter</primary>
39558 <secondary>locking out certain features</secondary>
39559 </indexterm>
39560 If this option is set true, only Sieve filters are permitted when
39561 <option>allow_filter</option> is true.
39562 </para>
39563 <para>
39564 <indexterm role="option">
39565 <primary><option>forbid_file</option></primary>
39566 </indexterm>
39567 </para>
39568 <informaltable frame="all">
39569 <tgroup cols="4" colsep="0" rowsep="0">
39570 <colspec colwidth="8*" align="left"/>
39571 <colspec colwidth="6*" align="center"/>
39572 <colspec colwidth="6*" align="center"/>
39573 <colspec colwidth="6*" align="right"/>
39574 <tbody>
39575 <row>
39576 <entry><option>forbid_file</option></entry>
39577 <entry>Use: <emphasis>redirect</emphasis></entry>
39578 <entry>Type: <emphasis>boolean</emphasis></entry>
39579 <entry>Default: <emphasis>false</emphasis></entry>
39580 </row>
39581 </tbody>
39582 </tgroup>
39583 </informaltable>
39584 <para>
39585 <indexterm role="concept">
39586 <primary>restricting access to features</primary>
39587 </indexterm>
39588 <indexterm role="concept">
39589 <primary>delivery</primary>
39590 <secondary>to file; forbidding</secondary>
39591 </indexterm>
39592 <indexterm role="concept">
39593 <primary>filter</primary>
39594 <secondary>locking out certain features</secondary>
39595 </indexterm>
39596 <indexterm role="concept">
39597 <primary>Sieve filter</primary>
39598 <secondary>forbidding delivery to a file</secondary>
39599 </indexterm>
39600 <indexterm role="concept">
39601 <primary>Sieve filter</primary>
39602 <secondary><quote>keep</quote> facility; disabling</secondary>
39603 </indexterm>
39604 If this option is true, this router may not generate a new address that
39605 specifies delivery to a local file or directory, either from a filter or from a
39606 conventional forward file. This option is forced to be true if <option>one_time</option> is
39607 set. It applies to Sieve filters as well as to Exim filters, but if true, it
39608 locks out the Sieve&#x2019;s <quote>keep</quote> facility.
39609 </para>
39610 <para>
39611 <indexterm role="option">
39612 <primary><option>forbid_filter_dlfunc</option></primary>
39613 </indexterm>
39614 </para>
39615 <informaltable frame="all">
39616 <tgroup cols="4" colsep="0" rowsep="0">
39617 <colspec colwidth="8*" align="left"/>
39618 <colspec colwidth="6*" align="center"/>
39619 <colspec colwidth="6*" align="center"/>
39620 <colspec colwidth="6*" align="right"/>
39621 <tbody>
39622 <row>
39623 <entry><option>forbid_filter_dlfunc</option></entry>
39624 <entry>Use: <emphasis>redirect</emphasis></entry>
39625 <entry>Type: <emphasis>boolean</emphasis></entry>
39626 <entry>Default: <emphasis>false</emphasis></entry>
39627 </row>
39628 </tbody>
39629 </tgroup>
39630 </informaltable>
39631 <para>
39632 <indexterm role="concept">
39633 <primary>restricting access to features</primary>
39634 </indexterm>
39635 <indexterm role="concept">
39636 <primary>filter</primary>
39637 <secondary>locking out certain features</secondary>
39638 </indexterm>
39639 If this option is true, string expansions in Exim filters are not allowed to
39640 make use of the <option>dlfunc</option> expansion facility to run dynamically loaded
39641 functions.
39642 </para>
39643 <para>
39644 <indexterm role="option">
39645 <primary><option>forbid_filter_existstest</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>forbid_filter_existstest</option></entry>
39657 <entry>Use: <emphasis>redirect</emphasis></entry>
39658 <entry>Type: <emphasis>boolean</emphasis></entry>
39659 <entry>Default: <emphasis>false</emphasis></entry>
39660 </row>
39661 </tbody>
39662 </tgroup>
39663 </informaltable>
39664 <para>
39665 <indexterm role="concept">
39666 <primary>restricting access to features</primary>
39667 </indexterm>
39668 <indexterm role="concept">
39669 <primary>filter</primary>
39670 <secondary>locking out certain features</secondary>
39671 </indexterm>
39672 <indexterm role="concept">
39673 <primary>expansion</primary>
39674 <secondary>statting a file</secondary>
39675 </indexterm>
39676 If this option is true, string expansions in Exim filters are not allowed to
39677 make use of the <option>exists</option> condition or the <option>stat</option> expansion item.
39678 </para>
39679 <para>
39680 <indexterm role="option">
39681 <primary><option>forbid_filter_logwrite</option></primary>
39682 </indexterm>
39683 </para>
39684 <informaltable frame="all">
39685 <tgroup cols="4" colsep="0" rowsep="0">
39686 <colspec colwidth="8*" align="left"/>
39687 <colspec colwidth="6*" align="center"/>
39688 <colspec colwidth="6*" align="center"/>
39689 <colspec colwidth="6*" align="right"/>
39690 <tbody>
39691 <row>
39692 <entry><option>forbid_filter_logwrite</option></entry>
39693 <entry>Use: <emphasis>redirect</emphasis></entry>
39694 <entry>Type: <emphasis>boolean</emphasis></entry>
39695 <entry>Default: <emphasis>false</emphasis></entry>
39696 </row>
39697 </tbody>
39698 </tgroup>
39699 </informaltable>
39700 <para>
39701 <indexterm role="concept">
39702 <primary>restricting access to features</primary>
39703 </indexterm>
39704 <indexterm role="concept">
39705 <primary>filter</primary>
39706 <secondary>locking out certain features</secondary>
39707 </indexterm>
39708 If this option is true, use of the logging facility in Exim filters is not
39709 permitted. Logging is in any case available only if the filter is being run
39710 under some unprivileged uid (which is normally the case for ordinary users&#x2019;
39711 <filename>.forward</filename> files).
39712 </para>
39713 <para>
39714 <indexterm role="option">
39715 <primary><option>forbid_filter_lookup</option></primary>
39716 </indexterm>
39717 </para>
39718 <informaltable frame="all">
39719 <tgroup cols="4" colsep="0" rowsep="0">
39720 <colspec colwidth="8*" align="left"/>
39721 <colspec colwidth="6*" align="center"/>
39722 <colspec colwidth="6*" align="center"/>
39723 <colspec colwidth="6*" align="right"/>
39724 <tbody>
39725 <row>
39726 <entry><option>forbid_filter_lookup</option></entry>
39727 <entry>Use: <emphasis>redirect</emphasis></entry>
39728 <entry>Type: <emphasis>boolean</emphasis></entry>
39729 <entry>Default: <emphasis>false</emphasis></entry>
39730 </row>
39731 </tbody>
39732 </tgroup>
39733 </informaltable>
39734 <para>
39735 <indexterm role="concept">
39736 <primary>restricting access to features</primary>
39737 </indexterm>
39738 <indexterm role="concept">
39739 <primary>filter</primary>
39740 <secondary>locking out certain features</secondary>
39741 </indexterm>
39742 If this option is true, string expansions in Exim filter files are not allowed
39743 to make use of <option>lookup</option> items.
39744 </para>
39745 <para>
39746 <indexterm role="option">
39747 <primary><option>forbid_filter_perl</option></primary>
39748 </indexterm>
39749 </para>
39750 <informaltable frame="all">
39751 <tgroup cols="4" colsep="0" rowsep="0">
39752 <colspec colwidth="8*" align="left"/>
39753 <colspec colwidth="6*" align="center"/>
39754 <colspec colwidth="6*" align="center"/>
39755 <colspec colwidth="6*" align="right"/>
39756 <tbody>
39757 <row>
39758 <entry><option>forbid_filter_perl</option></entry>
39759 <entry>Use: <emphasis>redirect</emphasis></entry>
39760 <entry>Type: <emphasis>boolean</emphasis></entry>
39761 <entry>Default: <emphasis>false</emphasis></entry>
39762 </row>
39763 </tbody>
39764 </tgroup>
39765 </informaltable>
39766 <para>
39767 <indexterm role="concept">
39768 <primary>restricting access to features</primary>
39769 </indexterm>
39770 <indexterm role="concept">
39771 <primary>filter</primary>
39772 <secondary>locking out certain features</secondary>
39773 </indexterm>
39774 This option has an effect only if Exim is built with embedded Perl support. If
39775 it is true, string expansions in Exim filter files are not allowed to make use
39776 of the embedded Perl support.
39777 </para>
39778 <para>
39779 <indexterm role="option">
39780 <primary><option>forbid_filter_readfile</option></primary>
39781 </indexterm>
39782 </para>
39783 <informaltable frame="all">
39784 <tgroup cols="4" colsep="0" rowsep="0">
39785 <colspec colwidth="8*" align="left"/>
39786 <colspec colwidth="6*" align="center"/>
39787 <colspec colwidth="6*" align="center"/>
39788 <colspec colwidth="6*" align="right"/>
39789 <tbody>
39790 <row>
39791 <entry><option>forbid_filter_readfile</option></entry>
39792 <entry>Use: <emphasis>redirect</emphasis></entry>
39793 <entry>Type: <emphasis>boolean</emphasis></entry>
39794 <entry>Default: <emphasis>false</emphasis></entry>
39795 </row>
39796 </tbody>
39797 </tgroup>
39798 </informaltable>
39799 <para>
39800 <indexterm role="concept">
39801 <primary>restricting access to features</primary>
39802 </indexterm>
39803 <indexterm role="concept">
39804 <primary>filter</primary>
39805 <secondary>locking out certain features</secondary>
39806 </indexterm>
39807 If this option is true, string expansions in Exim filter files are not allowed
39808 to make use of <option>readfile</option> items.
39809 </para>
39810 <para>
39811 <indexterm role="option">
39812 <primary><option>forbid_filter_readsocket</option></primary>
39813 </indexterm>
39814 </para>
39815 <informaltable frame="all">
39816 <tgroup cols="4" colsep="0" rowsep="0">
39817 <colspec colwidth="8*" align="left"/>
39818 <colspec colwidth="6*" align="center"/>
39819 <colspec colwidth="6*" align="center"/>
39820 <colspec colwidth="6*" align="right"/>
39821 <tbody>
39822 <row>
39823 <entry><option>forbid_filter_readsocket</option></entry>
39824 <entry>Use: <emphasis>redirect</emphasis></entry>
39825 <entry>Type: <emphasis>boolean</emphasis></entry>
39826 <entry>Default: <emphasis>false</emphasis></entry>
39827 </row>
39828 </tbody>
39829 </tgroup>
39830 </informaltable>
39831 <para>
39832 <indexterm role="concept">
39833 <primary>restricting access to features</primary>
39834 </indexterm>
39835 <indexterm role="concept">
39836 <primary>filter</primary>
39837 <secondary>locking out certain features</secondary>
39838 </indexterm>
39839 If this option is true, string expansions in Exim filter files are not allowed
39840 to make use of <option>readsocket</option> items.
39841 </para>
39842 <para>
39843 <indexterm role="option">
39844 <primary><option>forbid_filter_reply</option></primary>
39845 </indexterm>
39846 </para>
39847 <informaltable frame="all">
39848 <tgroup cols="4" colsep="0" rowsep="0">
39849 <colspec colwidth="8*" align="left"/>
39850 <colspec colwidth="6*" align="center"/>
39851 <colspec colwidth="6*" align="center"/>
39852 <colspec colwidth="6*" align="right"/>
39853 <tbody>
39854 <row>
39855 <entry><option>forbid_filter_reply</option></entry>
39856 <entry>Use: <emphasis>redirect</emphasis></entry>
39857 <entry>Type: <emphasis>boolean</emphasis></entry>
39858 <entry>Default: <emphasis>false</emphasis></entry>
39859 </row>
39860 </tbody>
39861 </tgroup>
39862 </informaltable>
39863 <para>
39864 <indexterm role="concept">
39865 <primary>restricting access to features</primary>
39866 </indexterm>
39867 <indexterm role="concept">
39868 <primary>filter</primary>
39869 <secondary>locking out certain features</secondary>
39870 </indexterm>
39871 If this option is true, this router may not generate an automatic reply
39872 message. Automatic replies can be generated only from Exim or Sieve filter
39873 files, not from traditional forward files. This option is forced to be true if
39874 <option>one_time</option> is set.
39875 </para>
39876 <para>
39877 <indexterm role="option">
39878 <primary><option>forbid_filter_run</option></primary>
39879 </indexterm>
39880 </para>
39881 <informaltable frame="all">
39882 <tgroup cols="4" colsep="0" rowsep="0">
39883 <colspec colwidth="8*" align="left"/>
39884 <colspec colwidth="6*" align="center"/>
39885 <colspec colwidth="6*" align="center"/>
39886 <colspec colwidth="6*" align="right"/>
39887 <tbody>
39888 <row>
39889 <entry><option>forbid_filter_run</option></entry>
39890 <entry>Use: <emphasis>redirect</emphasis></entry>
39891 <entry>Type: <emphasis>boolean</emphasis></entry>
39892 <entry>Default: <emphasis>false</emphasis></entry>
39893 </row>
39894 </tbody>
39895 </tgroup>
39896 </informaltable>
39897 <para>
39898 <indexterm role="concept">
39899 <primary>restricting access to features</primary>
39900 </indexterm>
39901 <indexterm role="concept">
39902 <primary>filter</primary>
39903 <secondary>locking out certain features</secondary>
39904 </indexterm>
39905 If this option is true, string expansions in Exim filter files are not allowed
39906 to make use of <option>run</option> items.
39907 </para>
39908 <para>
39909 <indexterm role="option">
39910 <primary><option>forbid_include</option></primary>
39911 </indexterm>
39912 </para>
39913 <informaltable frame="all">
39914 <tgroup cols="4" colsep="0" rowsep="0">
39915 <colspec colwidth="8*" align="left"/>
39916 <colspec colwidth="6*" align="center"/>
39917 <colspec colwidth="6*" align="center"/>
39918 <colspec colwidth="6*" align="right"/>
39919 <tbody>
39920 <row>
39921 <entry><option>forbid_include</option></entry>
39922 <entry>Use: <emphasis>redirect</emphasis></entry>
39923 <entry>Type: <emphasis>boolean</emphasis></entry>
39924 <entry>Default: <emphasis>false</emphasis></entry>
39925 </row>
39926 </tbody>
39927 </tgroup>
39928 </informaltable>
39929 <para>
39930 <indexterm role="concept">
39931 <primary>restricting access to features</primary>
39932 </indexterm>
39933 <indexterm role="concept">
39934 <primary>filter</primary>
39935 <secondary>locking out certain features</secondary>
39936 </indexterm>
39937 If this option is true, items of the form
39938 </para>
39939 <literallayout class="monospaced">
39940 :include:&lt;path name&gt;
39941 </literallayout>
39942 <para>
39943 are not permitted in non-filter redirection lists.
39944 </para>
39945 <para>
39946 <indexterm role="option">
39947 <primary><option>forbid_pipe</option></primary>
39948 </indexterm>
39949 </para>
39950 <informaltable frame="all">
39951 <tgroup cols="4" colsep="0" rowsep="0">
39952 <colspec colwidth="8*" align="left"/>
39953 <colspec colwidth="6*" align="center"/>
39954 <colspec colwidth="6*" align="center"/>
39955 <colspec colwidth="6*" align="right"/>
39956 <tbody>
39957 <row>
39958 <entry><option>forbid_pipe</option></entry>
39959 <entry>Use: <emphasis>redirect</emphasis></entry>
39960 <entry>Type: <emphasis>boolean</emphasis></entry>
39961 <entry>Default: <emphasis>false</emphasis></entry>
39962 </row>
39963 </tbody>
39964 </tgroup>
39965 </informaltable>
39966 <para>
39967 <indexterm role="concept">
39968 <primary>restricting access to features</primary>
39969 </indexterm>
39970 <indexterm role="concept">
39971 <primary>filter</primary>
39972 <secondary>locking out certain features</secondary>
39973 </indexterm>
39974 <indexterm role="concept">
39975 <primary>delivery</primary>
39976 <secondary>to pipe; forbidding</secondary>
39977 </indexterm>
39978 If this option is true, this router may not generate a new address which
39979 specifies delivery to a pipe, either from an Exim filter or from a conventional
39980 forward file. This option is forced to be true if <option>one_time</option> is set.
39981 </para>
39982 <para>
39983 <indexterm role="option">
39984 <primary><option>forbid_sieve_filter</option></primary>
39985 </indexterm>
39986 </para>
39987 <informaltable frame="all">
39988 <tgroup cols="4" colsep="0" rowsep="0">
39989 <colspec colwidth="8*" align="left"/>
39990 <colspec colwidth="6*" align="center"/>
39991 <colspec colwidth="6*" align="center"/>
39992 <colspec colwidth="6*" align="right"/>
39993 <tbody>
39994 <row>
39995 <entry><option>forbid_sieve_filter</option></entry>
39996 <entry>Use: <emphasis>redirect</emphasis></entry>
39997 <entry>Type: <emphasis>boolean</emphasis></entry>
39998 <entry>Default: <emphasis>false</emphasis></entry>
39999 </row>
40000 </tbody>
40001 </tgroup>
40002 </informaltable>
40003 <para>
40004 <indexterm role="concept">
40005 <primary>restricting access to features</primary>
40006 </indexterm>
40007 <indexterm role="concept">
40008 <primary>filter</primary>
40009 <secondary>locking out certain features</secondary>
40010 </indexterm>
40011 If this option is set true, only Exim filters are permitted when
40012 <option>allow_filter</option> is true.
40013 </para>
40014 <para>
40015 <indexterm role="concept">
40016 <primary>SMTP</primary>
40017 <secondary>error codes</secondary>
40018 </indexterm>
40019 <indexterm role="option">
40020 <primary><option>forbid_smtp_code</option></primary>
40021 </indexterm>
40022 </para>
40023 <informaltable frame="all">
40024 <tgroup cols="4" colsep="0" rowsep="0">
40025 <colspec colwidth="8*" align="left"/>
40026 <colspec colwidth="6*" align="center"/>
40027 <colspec colwidth="6*" align="center"/>
40028 <colspec colwidth="6*" align="right"/>
40029 <tbody>
40030 <row>
40031 <entry><option>forbid_smtp_code</option></entry>
40032 <entry>Use: <emphasis>redirect</emphasis></entry>
40033 <entry>Type: <emphasis>boolean</emphasis></entry>
40034 <entry>Default: <emphasis>false</emphasis></entry>
40035 </row>
40036 </tbody>
40037 </tgroup>
40038 </informaltable>
40039 <para>
40040 If this option is set true, any SMTP error codes that are present at the start
40041 of messages specified for <literal>:defer:</literal> or <literal>:fail:</literal> are quietly ignored, and
40042 the default codes (451 and 550, respectively) are always used.
40043 </para>
40044 <para>
40045 <indexterm role="option">
40046 <primary><option>hide_child_in_errmsg</option></primary>
40047 </indexterm>
40048 </para>
40049 <informaltable frame="all">
40050 <tgroup cols="4" colsep="0" rowsep="0">
40051 <colspec colwidth="8*" align="left"/>
40052 <colspec colwidth="6*" align="center"/>
40053 <colspec colwidth="6*" align="center"/>
40054 <colspec colwidth="6*" align="right"/>
40055 <tbody>
40056 <row>
40057 <entry><option>hide_child_in_errmsg</option></entry>
40058 <entry>Use: <emphasis>redirect</emphasis></entry>
40059 <entry>Type: <emphasis>boolean</emphasis></entry>
40060 <entry>Default: <emphasis>false</emphasis></entry>
40061 </row>
40062 </tbody>
40063 </tgroup>
40064 </informaltable>
40065 <para>
40066 <indexterm role="concept">
40067 <primary>bounce message</primary>
40068 <secondary>redirection details; suppressing</secondary>
40069 </indexterm>
40070 If this option is true, it prevents Exim from quoting a child address if it
40071 generates a bounce or delay message for it. Instead it says <quote>an address
40072 generated from &lt;<emphasis>the top level address</emphasis>&gt;</quote>. Of course, this applies only to
40073 bounces generated locally. If a message is forwarded to another host, <emphasis>its</emphasis>
40074 bounce may well quote the generated address.
40075 </para>
40076 <para>
40077 <indexterm role="option">
40078 <primary><option>ignore_eacces</option></primary>
40079 </indexterm>
40080 </para>
40081 <informaltable frame="all">
40082 <tgroup cols="4" colsep="0" rowsep="0">
40083 <colspec colwidth="8*" align="left"/>
40084 <colspec colwidth="6*" align="center"/>
40085 <colspec colwidth="6*" align="center"/>
40086 <colspec colwidth="6*" align="right"/>
40087 <tbody>
40088 <row>
40089 <entry><option>ignore_eacces</option></entry>
40090 <entry>Use: <emphasis>redirect</emphasis></entry>
40091 <entry>Type: <emphasis>boolean</emphasis></entry>
40092 <entry>Default: <emphasis>false</emphasis></entry>
40093 </row>
40094 </tbody>
40095 </tgroup>
40096 </informaltable>
40097 <para>
40098 <indexterm role="concept">
40099 <primary>EACCES</primary>
40100 </indexterm>
40101 If this option is set and an attempt to open a redirection file yields the
40102 EACCES error (permission denied), the <command>redirect</command> router behaves as if the
40103 file did not exist.
40104 </para>
40105 <para>
40106 <indexterm role="option">
40107 <primary><option>ignore_enotdir</option></primary>
40108 </indexterm>
40109 </para>
40110 <informaltable frame="all">
40111 <tgroup cols="4" colsep="0" rowsep="0">
40112 <colspec colwidth="8*" align="left"/>
40113 <colspec colwidth="6*" align="center"/>
40114 <colspec colwidth="6*" align="center"/>
40115 <colspec colwidth="6*" align="right"/>
40116 <tbody>
40117 <row>
40118 <entry><option>ignore_enotdir</option></entry>
40119 <entry>Use: <emphasis>redirect</emphasis></entry>
40120 <entry>Type: <emphasis>boolean</emphasis></entry>
40121 <entry>Default: <emphasis>false</emphasis></entry>
40122 </row>
40123 </tbody>
40124 </tgroup>
40125 </informaltable>
40126 <para>
40127 <indexterm role="concept">
40128 <primary>ENOTDIR</primary>
40129 </indexterm>
40130 If this option is set and an attempt to open a redirection file yields the
40131 ENOTDIR error (something on the path is not a directory), the <command>redirect</command>
40132 router behaves as if the file did not exist.
40133 </para>
40134 <para>
40135 Setting <option>ignore_enotdir</option> has another effect as well: When a <command>redirect</command>
40136 router that has the <option>file</option> option set discovers that the file does not exist
40137 (the ENOENT error), it tries to <function>stat()</function> the parent directory, as a check
40138 against unmounted NFS directories. If the parent can not be statted, delivery
40139 is deferred. However, it seems wrong to do this check when <option>ignore_enotdir</option>
40140 is set, because that option tells Exim to ignore <quote>something on the path is not
40141 a directory</quote> (the ENOTDIR error). This is a confusing area, because it seems
40142 that some operating systems give ENOENT where others give ENOTDIR.
40143 </para>
40144 <para>
40145 <indexterm role="option">
40146 <primary><option>include_directory</option></primary>
40147 </indexterm>
40148 </para>
40149 <informaltable frame="all">
40150 <tgroup cols="4" colsep="0" rowsep="0">
40151 <colspec colwidth="8*" align="left"/>
40152 <colspec colwidth="6*" align="center"/>
40153 <colspec colwidth="6*" align="center"/>
40154 <colspec colwidth="6*" align="right"/>
40155 <tbody>
40156 <row>
40157 <entry><option>include_directory</option></entry>
40158 <entry>Use: <emphasis>redirect</emphasis></entry>
40159 <entry>Type: <emphasis>string</emphasis></entry>
40160 <entry>Default: <emphasis>unset</emphasis></entry>
40161 </row>
40162 </tbody>
40163 </tgroup>
40164 </informaltable>
40165 <para>
40166 If this option is set, the path names of any <emphasis>:include:</emphasis> items in a
40167 redirection list must start with this directory.
40168 </para>
40169 <para>
40170 <indexterm role="option">
40171 <primary><option>modemask</option></primary>
40172 </indexterm>
40173 </para>
40174 <informaltable frame="all">
40175 <tgroup cols="4" colsep="0" rowsep="0">
40176 <colspec colwidth="8*" align="left"/>
40177 <colspec colwidth="6*" align="center"/>
40178 <colspec colwidth="6*" align="center"/>
40179 <colspec colwidth="6*" align="right"/>
40180 <tbody>
40181 <row>
40182 <entry><option>modemask</option></entry>
40183 <entry>Use: <emphasis>redirect</emphasis></entry>
40184 <entry>Type: <emphasis>octal integer</emphasis></entry>
40185 <entry>Default: <emphasis>022</emphasis></entry>
40186 </row>
40187 </tbody>
40188 </tgroup>
40189 </informaltable>
40190 <para>
40191 This specifies mode bits which must not be set for a file specified by the
40192 <option>file</option> option. If any of the forbidden bits are set, delivery is deferred.
40193 </para>
40194 <para>
40195 <indexterm role="option">
40196 <primary><option>one_time</option></primary>
40197 </indexterm>
40198 </para>
40199 <informaltable frame="all">
40200 <tgroup cols="4" colsep="0" rowsep="0">
40201 <colspec colwidth="8*" align="left"/>
40202 <colspec colwidth="6*" align="center"/>
40203 <colspec colwidth="6*" align="center"/>
40204 <colspec colwidth="6*" align="right"/>
40205 <tbody>
40206 <row>
40207 <entry><option>one_time</option></entry>
40208 <entry>Use: <emphasis>redirect</emphasis></entry>
40209 <entry>Type: <emphasis>boolean</emphasis></entry>
40210 <entry>Default: <emphasis>false</emphasis></entry>
40211 </row>
40212 </tbody>
40213 </tgroup>
40214 </informaltable>
40215 <para>
40216 <indexterm role="concept">
40217 <primary>one-time aliasing/forwarding expansion</primary>
40218 </indexterm>
40219 <indexterm role="concept">
40220 <primary>alias file</primary>
40221 <secondary>one-time expansion</secondary>
40222 </indexterm>
40223 <indexterm role="concept">
40224 <primary>forward file</primary>
40225 <secondary>one-time expansion</secondary>
40226 </indexterm>
40227 <indexterm role="concept">
40228 <primary>mailing lists</primary>
40229 <secondary>one-time expansion</secondary>
40230 </indexterm>
40231 <indexterm role="concept">
40232 <primary>address redirection</primary>
40233 <secondary>one-time expansion</secondary>
40234 </indexterm>
40235 Sometimes the fact that Exim re-evaluates aliases and reprocesses redirection
40236 files each time it tries to deliver a message causes a problem when one or more
40237 of the generated addresses fails be delivered at the first attempt. The problem
40238 is not one of duplicate delivery &ndash; Exim is clever enough to handle that &ndash;
40239 but of what happens when the redirection list changes during the time that the
40240 message is on Exim&#x2019;s queue. This is particularly true in the case of mailing
40241 lists, where new subscribers might receive copies of messages that were posted
40242 before they subscribed.
40243 </para>
40244 <para>
40245 If <option>one_time</option> is set and any addresses generated by the router fail to
40246 deliver at the first attempt, the failing addresses are added to the message as
40247 <quote>top level</quote> addresses, and the parent address that generated them is marked
40248 <quote>delivered</quote>. Thus, redirection does not happen again at the next delivery
40249 attempt.
40250 </para>
40251 <para>
40252 <emphasis role="bold">Warning 1</emphasis>: Any header line addition or removal that is specified by this
40253 router would be lost if delivery did not succeed at the first attempt. For this
40254 reason, the <option>headers_add</option> and <option>headers_remove</option> generic options are not
40255 permitted when <option>one_time</option> is set.
40256 </para>
40257 <para>
40258 <emphasis role="bold">Warning 2</emphasis>: To ensure that the router generates only addresses (as opposed
40259 to pipe or file deliveries or auto-replies) <option>forbid_file</option>, <option>forbid_pipe</option>,
40260 and <option>forbid_filter_reply</option> are forced to be true when <option>one_time</option> is set.
40261 </para>
40262 <para>
40263 <emphasis role="bold">Warning 3</emphasis>: The <option>unseen</option> generic router option may not be set with
40264 <option>one_time</option>.
40265 </para>
40266 <para>
40267 The original top-level address is remembered with each of the generated
40268 addresses, and is output in any log messages. However, any intermediate parent
40269 addresses are not recorded. This makes a difference to the log only if
40270 <option>all_parents</option> log selector is set. It is expected that <option>one_time</option> will
40271 typically be used for mailing lists, where there is normally just one level of
40272 expansion.
40273 </para>
40274 <para>
40275 <indexterm role="option">
40276 <primary><option>owners</option></primary>
40277 </indexterm>
40278 </para>
40279 <informaltable frame="all">
40280 <tgroup cols="4" colsep="0" rowsep="0">
40281 <colspec colwidth="8*" align="left"/>
40282 <colspec colwidth="6*" align="center"/>
40283 <colspec colwidth="6*" align="center"/>
40284 <colspec colwidth="6*" align="right"/>
40285 <tbody>
40286 <row>
40287 <entry><option>owners</option></entry>
40288 <entry>Use: <emphasis>redirect</emphasis></entry>
40289 <entry>Type: <emphasis>string list</emphasis></entry>
40290 <entry>Default: <emphasis>unset</emphasis></entry>
40291 </row>
40292 </tbody>
40293 </tgroup>
40294 </informaltable>
40295 <para>
40296 <indexterm role="concept">
40297 <primary>ownership</primary>
40298 <secondary>alias file</secondary>
40299 </indexterm>
40300 <indexterm role="concept">
40301 <primary>ownership</primary>
40302 <secondary>forward file</secondary>
40303 </indexterm>
40304 <indexterm role="concept">
40305 <primary>alias file</primary>
40306 <secondary>ownership</secondary>
40307 </indexterm>
40308 <indexterm role="concept">
40309 <primary>forward file</primary>
40310 <secondary>ownership</secondary>
40311 </indexterm>
40312 This specifies a list of permitted owners for the file specified by <option>file</option>.
40313 This list is in addition to the local user when <option>check_local_user</option> is set.
40314 See <option>check_owner</option> above.
40315 </para>
40316 <para>
40317 <indexterm role="option">
40318 <primary><option>owngroups</option></primary>
40319 </indexterm>
40320 </para>
40321 <informaltable frame="all">
40322 <tgroup cols="4" colsep="0" rowsep="0">
40323 <colspec colwidth="8*" align="left"/>
40324 <colspec colwidth="6*" align="center"/>
40325 <colspec colwidth="6*" align="center"/>
40326 <colspec colwidth="6*" align="right"/>
40327 <tbody>
40328 <row>
40329 <entry><option>owngroups</option></entry>
40330 <entry>Use: <emphasis>redirect</emphasis></entry>
40331 <entry>Type: <emphasis>string list</emphasis></entry>
40332 <entry>Default: <emphasis>unset</emphasis></entry>
40333 </row>
40334 </tbody>
40335 </tgroup>
40336 </informaltable>
40337 <para>
40338 This specifies a list of permitted groups for the file specified by <option>file</option>.
40339 The list is in addition to the local user&#x2019;s primary group when
40340 <option>check_local_user</option> is set. See <option>check_group</option> above.
40341 </para>
40342 <para>
40343 <indexterm role="option">
40344 <primary><option>pipe_transport</option></primary>
40345 </indexterm>
40346 </para>
40347 <informaltable frame="all">
40348 <tgroup cols="4" colsep="0" rowsep="0">
40349 <colspec colwidth="8*" align="left"/>
40350 <colspec colwidth="6*" align="center"/>
40351 <colspec colwidth="6*" align="center"/>
40352 <colspec colwidth="6*" align="right"/>
40353 <tbody>
40354 <row>
40355 <entry><option>pipe_transport</option></entry>
40356 <entry>Use: <emphasis>redirect</emphasis></entry>
40357 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40358 <entry>Default: <emphasis>unset</emphasis></entry>
40359 </row>
40360 </tbody>
40361 </tgroup>
40362 </informaltable>
40363 <para>
40364 <indexterm role="variable">
40365 <primary><varname>$address_pipe</varname></primary>
40366 </indexterm>
40367 A <command>redirect</command> router sets up a direct delivery to a pipe when a string
40368 starting with a vertical bar character is specified as a new <quote>address</quote>. The
40369 transport used is specified by this option, which, after expansion, must be the
40370 name of a configured transport. This should normally be a <command>pipe</command> transport.
40371 When the transport is run, the pipe command is in <varname>$address_pipe</varname>.
40372 </para>
40373 <para>
40374 <indexterm role="option">
40375 <primary><option>qualify_domain</option></primary>
40376 </indexterm>
40377 </para>
40378 <informaltable frame="all">
40379 <tgroup cols="4" colsep="0" rowsep="0">
40380 <colspec colwidth="8*" align="left"/>
40381 <colspec colwidth="6*" align="center"/>
40382 <colspec colwidth="6*" align="center"/>
40383 <colspec colwidth="6*" align="right"/>
40384 <tbody>
40385 <row>
40386 <entry><option>qualify_domain</option></entry>
40387 <entry>Use: <emphasis>redirect</emphasis></entry>
40388 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40389 <entry>Default: <emphasis>unset</emphasis></entry>
40390 </row>
40391 </tbody>
40392 </tgroup>
40393 </informaltable>
40394 <para>
40395 <indexterm role="variable">
40396 <primary><varname>$qualify_recipient</varname></primary>
40397 </indexterm>
40398 If this option is set, and an unqualified address (one without a domain) is
40399 generated, and that address would normally be qualified by the global setting
40400 in <option>qualify_recipient</option>, it is instead qualified with the domain specified by
40401 expanding this string. If the expansion fails, the router declines. If you want
40402 to revert to the default, you can have the expansion generate
40403 <varname>$qualify_recipient</varname>.
40404 </para>
40405 <para>
40406 This option applies to all unqualified addresses generated by Exim filters,
40407 but for traditional <filename>.forward</filename> files, it applies only to addresses that are
40408 not preceded by a backslash. Sieve filters cannot generate unqualified
40409 addresses.
40410 </para>
40411 <para>
40412 <indexterm role="option">
40413 <primary><option>qualify_preserve_domain</option></primary>
40414 </indexterm>
40415 </para>
40416 <informaltable frame="all">
40417 <tgroup cols="4" colsep="0" rowsep="0">
40418 <colspec colwidth="8*" align="left"/>
40419 <colspec colwidth="6*" align="center"/>
40420 <colspec colwidth="6*" align="center"/>
40421 <colspec colwidth="6*" align="right"/>
40422 <tbody>
40423 <row>
40424 <entry><option>qualify_preserve_domain</option></entry>
40425 <entry>Use: <emphasis>redirect</emphasis></entry>
40426 <entry>Type: <emphasis>boolean</emphasis></entry>
40427 <entry>Default: <emphasis>false</emphasis></entry>
40428 </row>
40429 </tbody>
40430 </tgroup>
40431 </informaltable>
40432 <para>
40433 <indexterm role="concept">
40434 <primary>domain</primary>
40435 <secondary>in redirection; preserving</secondary>
40436 </indexterm>
40437 <indexterm role="concept">
40438 <primary>preserving domain in redirection</primary>
40439 </indexterm>
40440 <indexterm role="concept">
40441 <primary>address redirection</primary>
40442 <secondary>domain; preserving</secondary>
40443 </indexterm>
40444 If this option is set, the router&#x2019;s local <option>qualify_domain</option> option must not be
40445 set (a configuration error occurs if it is). If an unqualified address (one
40446 without a domain) is generated, it is qualified with the domain of the parent
40447 address (the immediately preceding ancestor) instead of the global
40448 <option>qualify_recipient</option> value. In the case of a traditional <filename>.forward</filename> file,
40449 this applies whether or not the address is preceded by a backslash.
40450 </para>
40451 <para>
40452 <indexterm role="option">
40453 <primary><option>repeat_use</option></primary>
40454 </indexterm>
40455 </para>
40456 <informaltable frame="all">
40457 <tgroup cols="4" colsep="0" rowsep="0">
40458 <colspec colwidth="8*" align="left"/>
40459 <colspec colwidth="6*" align="center"/>
40460 <colspec colwidth="6*" align="center"/>
40461 <colspec colwidth="6*" align="right"/>
40462 <tbody>
40463 <row>
40464 <entry><option>repeat_use</option></entry>
40465 <entry>Use: <emphasis>redirect</emphasis></entry>
40466 <entry>Type: <emphasis>boolean</emphasis></entry>
40467 <entry>Default: <emphasis>true</emphasis></entry>
40468 </row>
40469 </tbody>
40470 </tgroup>
40471 </informaltable>
40472 <para>
40473 If this option is set false, the router is skipped for a child address that has
40474 any ancestor that was routed by this router. This test happens before any of
40475 the other preconditions are tested. Exim&#x2019;s default anti-looping rules skip
40476 only when the ancestor is the same as the current address. See also
40477 <option>check_ancestor</option> above and the generic <option>redirect_router</option> option.
40478 </para>
40479 <para>
40480 <indexterm role="option">
40481 <primary><option>reply_transport</option></primary>
40482 </indexterm>
40483 </para>
40484 <informaltable frame="all">
40485 <tgroup cols="4" colsep="0" rowsep="0">
40486 <colspec colwidth="8*" align="left"/>
40487 <colspec colwidth="6*" align="center"/>
40488 <colspec colwidth="6*" align="center"/>
40489 <colspec colwidth="6*" align="right"/>
40490 <tbody>
40491 <row>
40492 <entry><option>reply_transport</option></entry>
40493 <entry>Use: <emphasis>redirect</emphasis></entry>
40494 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40495 <entry>Default: <emphasis>unset</emphasis></entry>
40496 </row>
40497 </tbody>
40498 </tgroup>
40499 </informaltable>
40500 <para>
40501 A <command>redirect</command> router sets up an automatic reply when a <option>mail</option> or
40502 <option>vacation</option> command is used in a filter file. The transport used is specified
40503 by this option, which, after expansion, must be the name of a configured
40504 transport. This should normally be an <command>autoreply</command> transport. Other transports
40505 are unlikely to do anything sensible or useful.
40506 </para>
40507 <para>
40508 <indexterm role="option">
40509 <primary><option>rewrite</option></primary>
40510 </indexterm>
40511 </para>
40512 <informaltable frame="all">
40513 <tgroup cols="4" colsep="0" rowsep="0">
40514 <colspec colwidth="8*" align="left"/>
40515 <colspec colwidth="6*" align="center"/>
40516 <colspec colwidth="6*" align="center"/>
40517 <colspec colwidth="6*" align="right"/>
40518 <tbody>
40519 <row>
40520 <entry><option>rewrite</option></entry>
40521 <entry>Use: <emphasis>redirect</emphasis></entry>
40522 <entry>Type: <emphasis>boolean</emphasis></entry>
40523 <entry>Default: <emphasis>true</emphasis></entry>
40524 </row>
40525 </tbody>
40526 </tgroup>
40527 </informaltable>
40528 <para>
40529 <indexterm role="concept">
40530 <primary>address redirection</primary>
40531 <secondary>disabling rewriting</secondary>
40532 </indexterm>
40533 If this option is set false, addresses generated by the router are not
40534 subject to address rewriting. Otherwise, they are treated like new addresses
40535 and are rewritten according to the global rewriting rules.
40536 </para>
40537 <para>
40538 <indexterm role="option">
40539 <primary><option>sieve_subaddress</option></primary>
40540 </indexterm>
40541 </para>
40542 <informaltable frame="all">
40543 <tgroup cols="4" colsep="0" rowsep="0">
40544 <colspec colwidth="8*" align="left"/>
40545 <colspec colwidth="6*" align="center"/>
40546 <colspec colwidth="6*" align="center"/>
40547 <colspec colwidth="6*" align="right"/>
40548 <tbody>
40549 <row>
40550 <entry><option>sieve_subaddress</option></entry>
40551 <entry>Use: <emphasis>redirect</emphasis></entry>
40552 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40553 <entry>Default: <emphasis>unset</emphasis></entry>
40554 </row>
40555 </tbody>
40556 </tgroup>
40557 </informaltable>
40558 <para>
40559 The value of this option is passed to a Sieve filter to specify the
40560 :subaddress part of an address.
40561 </para>
40562 <para>
40563 <indexterm role="option">
40564 <primary><option>sieve_useraddress</option></primary>
40565 </indexterm>
40566 </para>
40567 <informaltable frame="all">
40568 <tgroup cols="4" colsep="0" rowsep="0">
40569 <colspec colwidth="8*" align="left"/>
40570 <colspec colwidth="6*" align="center"/>
40571 <colspec colwidth="6*" align="center"/>
40572 <colspec colwidth="6*" align="right"/>
40573 <tbody>
40574 <row>
40575 <entry><option>sieve_useraddress</option></entry>
40576 <entry>Use: <emphasis>redirect</emphasis></entry>
40577 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40578 <entry>Default: <emphasis>unset</emphasis></entry>
40579 </row>
40580 </tbody>
40581 </tgroup>
40582 </informaltable>
40583 <para>
40584 The value of this option is passed to a Sieve filter to specify the :user part
40585 of an address. However, if it is unset, the entire original local part
40586 (including any prefix or suffix) is used for :user.
40587 </para>
40588 <para>
40589 <indexterm role="option">
40590 <primary><option>sieve_vacation_directory</option></primary>
40591 </indexterm>
40592 </para>
40593 <informaltable frame="all">
40594 <tgroup cols="4" colsep="0" rowsep="0">
40595 <colspec colwidth="8*" align="left"/>
40596 <colspec colwidth="6*" align="center"/>
40597 <colspec colwidth="6*" align="center"/>
40598 <colspec colwidth="6*" align="right"/>
40599 <tbody>
40600 <row>
40601 <entry><option>sieve_vacation_directory</option></entry>
40602 <entry>Use: <emphasis>redirect</emphasis></entry>
40603 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40604 <entry>Default: <emphasis>unset</emphasis></entry>
40605 </row>
40606 </tbody>
40607 </tgroup>
40608 </informaltable>
40609 <para>
40610 <indexterm role="concept">
40611 <primary>Sieve filter</primary>
40612 <secondary>vacation directory</secondary>
40613 </indexterm>
40614 To enable the <quote>vacation</quote> extension for Sieve filters, you must set
40615 <option>sieve_vacation_directory</option> to the directory where vacation databases are held
40616 (do not put anything else in that directory), and ensure that the
40617 <option>reply_transport</option> option refers to an <command>autoreply</command> transport. Each user
40618 needs their own directory; Exim will create it if necessary.
40619 </para>
40620 <para>
40621 <indexterm role="option">
40622 <primary><option>skip_syntax_errors</option></primary>
40623 </indexterm>
40624 </para>
40625 <informaltable frame="all">
40626 <tgroup cols="4" colsep="0" rowsep="0">
40627 <colspec colwidth="8*" align="left"/>
40628 <colspec colwidth="6*" align="center"/>
40629 <colspec colwidth="6*" align="center"/>
40630 <colspec colwidth="6*" align="right"/>
40631 <tbody>
40632 <row>
40633 <entry><option>skip_syntax_errors</option></entry>
40634 <entry>Use: <emphasis>redirect</emphasis></entry>
40635 <entry>Type: <emphasis>boolean</emphasis></entry>
40636 <entry>Default: <emphasis>false</emphasis></entry>
40637 </row>
40638 </tbody>
40639 </tgroup>
40640 </informaltable>
40641 <para>
40642 <indexterm role="concept">
40643 <primary>forward file</primary>
40644 <secondary>broken</secondary>
40645 </indexterm>
40646 <indexterm role="concept">
40647 <primary>address redirection</primary>
40648 <secondary>broken files</secondary>
40649 </indexterm>
40650 <indexterm role="concept">
40651 <primary>alias file</primary>
40652 <secondary>broken</secondary>
40653 </indexterm>
40654 <indexterm role="concept">
40655 <primary>broken alias or forward files</primary>
40656 </indexterm>
40657 <indexterm role="concept">
40658 <primary>ignoring faulty addresses</primary>
40659 </indexterm>
40660 <indexterm role="concept">
40661 <primary>skipping faulty addresses</primary>
40662 </indexterm>
40663 <indexterm role="concept">
40664 <primary>error</primary>
40665 <secondary>skipping bad syntax</secondary>
40666 </indexterm>
40667 If <option>skip_syntax_errors</option> is set, syntactically malformed addresses in
40668 non-filter redirection data are skipped, and each failing address is logged. If
40669 <option>syntax_errors_to</option> is set, a message is sent to the address it defines,
40670 giving details of the failures. If <option>syntax_errors_text</option> is set, its contents
40671 are expanded and placed at the head of the error message generated by
40672 <option>syntax_errors_to</option>. Usually it is appropriate to set <option>syntax_errors_to</option> to
40673 be the same address as the generic <option>errors_to</option> option. The
40674 <option>skip_syntax_errors</option> option is often used when handling mailing lists.
40675 </para>
40676 <para>
40677 If all the addresses in a redirection list are skipped because of syntax
40678 errors, the router declines to handle the original address, and it is passed to
40679 the following routers.
40680 </para>
40681 <para>
40682 If <option>skip_syntax_errors</option> is set when an Exim filter is interpreted, any syntax
40683 error in the filter causes filtering to be abandoned without any action being
40684 taken. The incident is logged, and the router declines to handle the address,
40685 so it is passed to the following routers.
40686 </para>
40687 <para>
40688 <indexterm role="concept">
40689 <primary>Sieve filter</primary>
40690 <secondary>syntax errors in</secondary>
40691 </indexterm>
40692 Syntax errors in a Sieve filter file cause the <quote>keep</quote> action to occur. This
40693 action is specified by RFC 3028. The values of <option>skip_syntax_errors</option>,
40694 <option>syntax_errors_to</option>, and <option>syntax_errors_text</option> are not used.
40695 </para>
40696 <para>
40697 <option>skip_syntax_errors</option> can be used to specify that errors in users&#x2019; forward
40698 lists or filter files should not prevent delivery. The <option>syntax_errors_to</option>
40699 option, used with an address that does not get redirected, can be used to
40700 notify users of these errors, by means of a router like this:
40701 </para>
40702 <literallayout class="monospaced">
40703 userforward:
40704   driver = redirect
40705   allow_filter
40706   check_local_user
40707   file = $home/.forward
40708   file_transport = address_file
40709   pipe_transport = address_pipe
40710   reply_transport = address_reply
40711   no_verify
40712   skip_syntax_errors
40713   syntax_errors_to = real-$local_part@$domain
40714   syntax_errors_text = \
40715    This is an automatically generated message. An error has\n\
40716    been found in your .forward file. Details of the error are\n\
40717    reported below. While this error persists, you will receive\n\
40718    a copy of this message for every message that is addressed\n\
40719    to you. If your .forward file is a filter file, or if it is\n\
40720    a non-filter file containing no valid forwarding addresses,\n\
40721    a copy of each incoming message will be put in your normal\n\
40722    mailbox. If a non-filter file contains at least one valid\n\
40723    forwarding address, forwarding to the valid addresses will\n\
40724    happen, and those will be the only deliveries that occur.
40725 </literallayout>
40726 <para>
40727 You also need a router to ensure that local addresses that are prefixed by
40728 <literal>real-</literal> are recognized, but not forwarded or filtered. For example, you could
40729 put this immediately before the <command>userforward</command> router:
40730 </para>
40731 <literallayout class="monospaced">
40732 real_localuser:
40733   driver = accept
40734   check_local_user
40735   local_part_prefix = real-
40736   transport = local_delivery
40737 </literallayout>
40738 <para>
40739 For security, it would probably be a good idea to restrict the use of this
40740 router to locally-generated messages, using a condition such as this:
40741 </para>
40742 <literallayout class="monospaced">
40743   condition = ${if match {$sender_host_address}\
40744                          {\N^(|127\.0\.0\.1)$\N}}
40745 </literallayout>
40746 <para>
40747 <indexterm role="option">
40748 <primary><option>syntax_errors_text</option></primary>
40749 </indexterm>
40750 </para>
40751 <informaltable frame="all">
40752 <tgroup cols="4" colsep="0" rowsep="0">
40753 <colspec colwidth="8*" align="left"/>
40754 <colspec colwidth="6*" align="center"/>
40755 <colspec colwidth="6*" align="center"/>
40756 <colspec colwidth="6*" align="right"/>
40757 <tbody>
40758 <row>
40759 <entry><option>syntax_errors_text</option></entry>
40760 <entry>Use: <emphasis>redirect</emphasis></entry>
40761 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40762 <entry>Default: <emphasis>unset</emphasis></entry>
40763 </row>
40764 </tbody>
40765 </tgroup>
40766 </informaltable>
40767 <para>
40768 See <option>skip_syntax_errors</option> above.
40769 </para>
40770 <para>
40771 <indexterm role="option">
40772 <primary><option>syntax_errors_to</option></primary>
40773 </indexterm>
40774 </para>
40775 <informaltable frame="all">
40776 <tgroup cols="4" colsep="0" rowsep="0">
40777 <colspec colwidth="8*" align="left"/>
40778 <colspec colwidth="6*" align="center"/>
40779 <colspec colwidth="6*" align="center"/>
40780 <colspec colwidth="6*" align="right"/>
40781 <tbody>
40782 <row>
40783 <entry><option>syntax_errors_to</option></entry>
40784 <entry>Use: <emphasis>redirect</emphasis></entry>
40785 <entry>Type: <emphasis>string</emphasis></entry>
40786 <entry>Default: <emphasis>unset</emphasis></entry>
40787 </row>
40788 </tbody>
40789 </tgroup>
40790 </informaltable>
40791 <para>
40792 See <option>skip_syntax_errors</option> above.
40793 <indexterm role="concept" startref="IIDredrou1" class="endofrange"/>
40794 <indexterm role="concept" startref="IIDredrou2" class="endofrange"/>
40795 </para>
40796 </section>
40797 </chapter>
40798
40799 <chapter id="CHAPenvironment">
40800 <title>Environment for running local transports</title>
40801 <titleabbrev>Environment for local transports</titleabbrev>
40802 <para>
40803 <indexterm role="concept" id="IIDenvlotra1" class="startofrange">
40804 <primary>local transports</primary>
40805 <secondary>environment for</secondary>
40806 </indexterm>
40807 <indexterm role="concept" id="IIDenvlotra2" class="startofrange">
40808 <primary>environment</primary>
40809 <secondary>local transports</secondary>
40810 </indexterm>
40811 <indexterm role="concept" id="IIDenvlotra3" class="startofrange">
40812 <primary>transport</primary>
40813 <secondary>local; environment for</secondary>
40814 </indexterm>
40815 Local transports handle deliveries to files and pipes. (The <command>autoreply</command>
40816 transport can be thought of as similar to a pipe.) Exim always runs transports
40817 in subprocesses, under specified uids and gids. Typical deliveries to local
40818 mailboxes run under the uid and gid of the local user.
40819 </para>
40820 <para>
40821 Exim also sets a specific current directory while running the transport; for
40822 some transports a home directory setting is also relevant. The <command>pipe</command>
40823 transport is the only one that sets up environment variables; see section
40824 <xref linkend="SECTpipeenv"/> for details.
40825 </para>
40826 <para>
40827 The values used for the uid, gid, and the directories may come from several
40828 different places. In many cases, the router that handles the address associates
40829 settings with that address as a result of its <option>check_local_user</option>, <option>group</option>,
40830 or <option>user</option> options. However, values may also be given in the transport&#x2019;s own
40831 configuration, and these override anything that comes from the router.
40832 </para>
40833 <section id="SECID131">
40834 <title>Concurrent deliveries</title>
40835 <para>
40836 <indexterm role="concept">
40837 <primary>concurrent deliveries</primary>
40838 </indexterm>
40839 <indexterm role="concept">
40840 <primary>simultaneous deliveries</primary>
40841 </indexterm>
40842 If two different messages for the same local recipient arrive more or less
40843 simultaneously, the two delivery processes are likely to run concurrently. When
40844 the <command>appendfile</command> transport is used to write to a file, Exim applies locking
40845 rules to stop concurrent processes from writing to the same file at the same
40846 time.
40847 </para>
40848 <para>
40849 However, when you use a <command>pipe</command> transport, it is up to you to arrange any
40850 locking that is needed. Here is a silly example:
40851 </para>
40852 <literallayout class="monospaced">
40853 my_transport:
40854   driver = pipe
40855   command = /bin/sh -c 'cat &gt;&gt;/some/file'
40856 </literallayout>
40857 <para>
40858 This is supposed to write the message at the end of the file. However, if two
40859 messages arrive at the same time, the file will be scrambled. You can use the
40860 <option>exim_lock</option> utility program (see section <xref linkend="SECTmailboxmaint"/>) to lock a
40861 file using the same algorithm that Exim itself uses.
40862 </para>
40863 </section>
40864 <section id="SECTenvuidgid">
40865 <title>Uids and gids</title>
40866 <para>
40867 <indexterm role="concept">
40868 <primary>local transports</primary>
40869 <secondary>uid and gid</secondary>
40870 </indexterm>
40871 <indexterm role="concept">
40872 <primary>transport</primary>
40873 <secondary>local; uid and gid</secondary>
40874 </indexterm>
40875 All transports have the options <option>group</option> and <option>user</option>. If <option>group</option> is set, it
40876 overrides any group that the router set in the address, even if <option>user</option> is not
40877 set for the transport. This makes it possible, for example, to run local mail
40878 delivery under the uid of the recipient (set by the router), but in a special
40879 group (set by the transport). For example:
40880 </para>
40881 <literallayout class="monospaced">
40882 # Routers ...
40883 # User/group are set by check_local_user in this router
40884 local_users:
40885   driver = accept
40886   check_local_user
40887   transport = group_delivery
40888
40889 # Transports ...
40890 # This transport overrides the group
40891 group_delivery:
40892   driver = appendfile
40893   file = /var/spool/mail/$local_part
40894   group = mail
40895 </literallayout>
40896 <para>
40897 If <option>user</option> is set for a transport, its value overrides what is set in the
40898 address by the router. If <option>user</option> is non-numeric and <option>group</option> is not set, the
40899 gid associated with the user is used. If <option>user</option> is numeric, <option>group</option> must be
40900 set.
40901 </para>
40902 <para>
40903 <indexterm role="option">
40904 <primary><option>initgroups</option></primary>
40905 </indexterm>
40906 When the uid is taken from the transport&#x2019;s configuration, the <function>initgroups()</function>
40907 function is called for the groups associated with that uid if the
40908 <option>initgroups</option> option is set for the transport. When the uid is not specified
40909 by the transport, but is associated with the address by a router, the option
40910 for calling <function>initgroups()</function> is taken from the router configuration.
40911 </para>
40912 <para>
40913 <indexterm role="concept">
40914 <primary><command>pipe</command> transport</primary>
40915 <secondary>uid for</secondary>
40916 </indexterm>
40917 The <command>pipe</command> transport contains the special option <option>pipe_as_creator</option>. If this
40918 is set and <option>user</option> is not set, the uid of the process that called Exim to
40919 receive the message is used, and if <option>group</option> is not set, the corresponding
40920 original gid is also used.
40921 </para>
40922 <para>
40923 This is the detailed preference order for obtaining a gid; the first of the
40924 following that is set is used:
40925 </para>
40926 <itemizedlist>
40927 <listitem>
40928 <para>
40929 A <option>group</option> setting of the transport;
40930 </para>
40931 </listitem>
40932 <listitem>
40933 <para>
40934 A <option>group</option> setting of the router;
40935 </para>
40936 </listitem>
40937 <listitem>
40938 <para>
40939 A gid associated with a user setting of the router, either as a result of
40940 <option>check_local_user</option> or an explicit non-numeric <option>user</option> setting;
40941 </para>
40942 </listitem>
40943 <listitem>
40944 <para>
40945 The group associated with a non-numeric <option>user</option> setting of the transport;
40946 </para>
40947 </listitem>
40948 <listitem>
40949 <para>
40950 In a <command>pipe</command> transport, the creator&#x2019;s gid if <option>deliver_as_creator</option> is set and
40951 the uid is the creator&#x2019;s uid;
40952 </para>
40953 </listitem>
40954 <listitem>
40955 <para>
40956 The Exim gid if the Exim uid is being used as a default.
40957 </para>
40958 </listitem>
40959 </itemizedlist>
40960 <para>
40961 If, for example, the user is specified numerically on the router and there are
40962 no group settings, no gid is available. In this situation, an error occurs.
40963 This is different for the uid, for which there always is an ultimate default.
40964 The first of the following that is set is used:
40965 </para>
40966 <itemizedlist>
40967 <listitem>
40968 <para>
40969 A <option>user</option> setting of the transport;
40970 </para>
40971 </listitem>
40972 <listitem>
40973 <para>
40974 In a <command>pipe</command> transport, the creator&#x2019;s uid if <option>deliver_as_creator</option> is set;
40975 </para>
40976 </listitem>
40977 <listitem>
40978 <para>
40979 A <option>user</option> setting of the router;
40980 </para>
40981 </listitem>
40982 <listitem>
40983 <para>
40984 A <option>check_local_user</option> setting of the router;
40985 </para>
40986 </listitem>
40987 <listitem>
40988 <para>
40989 The Exim uid.
40990 </para>
40991 </listitem>
40992 </itemizedlist>
40993 <para>
40994 Of course, an error will still occur if the uid that is chosen is on the
40995 <option>never_users</option> list.
40996 </para>
40997 </section>
40998 <section id="SECID132">
40999 <title>Current and home directories</title>
41000 <para>
41001 <indexterm role="concept">
41002 <primary>current directory for local transport</primary>
41003 </indexterm>
41004 <indexterm role="concept">
41005 <primary>home directory</primary>
41006 <secondary>for local transport</secondary>
41007 </indexterm>
41008 <indexterm role="concept">
41009 <primary>transport</primary>
41010 <secondary>local; home directory for</secondary>
41011 </indexterm>
41012 <indexterm role="concept">
41013 <primary>transport</primary>
41014 <secondary>local; current directory for</secondary>
41015 </indexterm>
41016 Routers may set current and home directories for local transports by means of
41017 the <option>transport_current_directory</option> and <option>transport_home_directory</option> options.
41018 However, if the transport&#x2019;s <option>current_directory</option> or <option>home_directory</option> options
41019 are set, they override the router&#x2019;s values. In detail, the home directory
41020 for a local transport is taken from the first of these values that is set:
41021 </para>
41022 <itemizedlist>
41023 <listitem>
41024 <para>
41025 The <option>home_directory</option> option on the transport;
41026 </para>
41027 </listitem>
41028 <listitem>
41029 <para>
41030 The <option>transport_home_directory</option> option on the router;
41031 </para>
41032 </listitem>
41033 <listitem>
41034 <para>
41035 The password data if <option>check_local_user</option> is set on the router;
41036 </para>
41037 </listitem>
41038 <listitem>
41039 <para>
41040 The <option>router_home_directory</option> option on the router.
41041 </para>
41042 </listitem>
41043 </itemizedlist>
41044 <para>
41045 The current directory is taken from the first of these values that is set:
41046 </para>
41047 <itemizedlist>
41048 <listitem>
41049 <para>
41050 The <option>current_directory</option> option on the transport;
41051 </para>
41052 </listitem>
41053 <listitem>
41054 <para>
41055 The <option>transport_current_directory</option> option on the router.
41056 </para>
41057 </listitem>
41058 </itemizedlist>
41059 <para>
41060 If neither the router nor the transport sets a current directory, Exim uses the
41061 value of the home directory, if it is set. Otherwise it sets the current
41062 directory to <filename>/</filename> before running a local transport.
41063 </para>
41064 </section>
41065 <section id="SECID133">
41066 <title>Expansion variables derived from the address</title>
41067 <para>
41068 <indexterm role="variable">
41069 <primary><varname>$domain</varname></primary>
41070 </indexterm>
41071 <indexterm role="variable">
41072 <primary><varname>$local_part</varname></primary>
41073 </indexterm>
41074 <indexterm role="variable">
41075 <primary><varname>$original_domain</varname></primary>
41076 </indexterm>
41077 Normally a local delivery is handling a single address, and in that case the
41078 variables such as <varname>$domain</varname> and <varname>$local_part</varname> are set during local
41079 deliveries. However, in some circumstances more than one address may be handled
41080 at once (for example, while writing batch SMTP for onward transmission by some
41081 other means). In this case, the variables associated with the local part are
41082 never set, <varname>$domain</varname> is set only if all the addresses have the same domain,
41083 and <varname>$original_domain</varname> is never set.
41084 <indexterm role="concept" startref="IIDenvlotra1" class="endofrange"/>
41085 <indexterm role="concept" startref="IIDenvlotra2" class="endofrange"/>
41086 <indexterm role="concept" startref="IIDenvlotra3" class="endofrange"/>
41087 </para>
41088 </section>
41089 </chapter>
41090
41091 <chapter id="CHAPtransportgeneric">
41092 <title>Generic options for transports</title>
41093 <para>
41094 <indexterm role="concept" id="IIDgenoptra1" class="startofrange">
41095 <primary>generic options</primary>
41096 <secondary>transport</secondary>
41097 </indexterm>
41098 <indexterm role="concept" id="IIDgenoptra2" class="startofrange">
41099 <primary>options</primary>
41100 <secondary>generic; for transports</secondary>
41101 </indexterm>
41102 <indexterm role="concept" id="IIDgenoptra3" class="startofrange">
41103 <primary>transport</primary>
41104 <secondary>generic options for</secondary>
41105 </indexterm>
41106 The following generic options apply to all transports:
41107 </para>
41108 <para>
41109 <indexterm role="option">
41110 <primary><option>body_only</option></primary>
41111 </indexterm>
41112 </para>
41113 <informaltable frame="all">
41114 <tgroup cols="4" colsep="0" rowsep="0">
41115 <colspec colwidth="8*" align="left"/>
41116 <colspec colwidth="6*" align="center"/>
41117 <colspec colwidth="6*" align="center"/>
41118 <colspec colwidth="6*" align="right"/>
41119 <tbody>
41120 <row>
41121 <entry><option>body_only</option></entry>
41122 <entry>Use: <emphasis>transports</emphasis></entry>
41123 <entry>Type: <emphasis>boolean</emphasis></entry>
41124 <entry>Default: <emphasis>false</emphasis></entry>
41125 </row>
41126 </tbody>
41127 </tgroup>
41128 </informaltable>
41129 <para>
41130 <indexterm role="concept">
41131 <primary>transport</primary>
41132 <secondary>body only</secondary>
41133 </indexterm>
41134 <indexterm role="concept">
41135 <primary>message</primary>
41136 <secondary>transporting body only</secondary>
41137 </indexterm>
41138 <indexterm role="concept">
41139 <primary>body of message</primary>
41140 <secondary>transporting</secondary>
41141 </indexterm>
41142 If this option is set, the message&#x2019;s headers are not transported. It is
41143 mutually exclusive with <option>headers_only</option>. If it is used with the <command>appendfile</command>
41144 or <command>pipe</command> transports, the settings of <option>message_prefix</option> and
41145 <option>message_suffix</option> should be checked, because this option does not
41146 automatically suppress them.
41147 </para>
41148 <para>
41149 <indexterm role="option">
41150 <primary><option>current_directory</option></primary>
41151 </indexterm>
41152 </para>
41153 <informaltable frame="all">
41154 <tgroup cols="4" colsep="0" rowsep="0">
41155 <colspec colwidth="8*" align="left"/>
41156 <colspec colwidth="6*" align="center"/>
41157 <colspec colwidth="6*" align="center"/>
41158 <colspec colwidth="6*" align="right"/>
41159 <tbody>
41160 <row>
41161 <entry><option>current_directory</option></entry>
41162 <entry>Use: <emphasis>transports</emphasis></entry>
41163 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
41164 <entry>Default: <emphasis>unset</emphasis></entry>
41165 </row>
41166 </tbody>
41167 </tgroup>
41168 </informaltable>
41169 <para>
41170 <indexterm role="concept">
41171 <primary>transport</primary>
41172 <secondary>current directory for</secondary>
41173 </indexterm>
41174 This specifies the current directory that is to be set while running the
41175 transport, overriding any value that may have been set by the router.
41176 If the expansion fails for any reason, including forced failure, an error is
41177 logged, and delivery is deferred.
41178 </para>
41179 <para>
41180 <indexterm role="option">
41181 <primary><option>disable_logging</option></primary>
41182 </indexterm>
41183 </para>
41184 <informaltable frame="all">
41185 <tgroup cols="4" colsep="0" rowsep="0">
41186 <colspec colwidth="8*" align="left"/>
41187 <colspec colwidth="6*" align="center"/>
41188 <colspec colwidth="6*" align="center"/>
41189 <colspec colwidth="6*" align="right"/>
41190 <tbody>
41191 <row>
41192 <entry><option>disable_logging</option></entry>
41193 <entry>Use: <emphasis>transports</emphasis></entry>
41194 <entry>Type: <emphasis>boolean</emphasis></entry>
41195 <entry>Default: <emphasis>false</emphasis></entry>
41196 </row>
41197 </tbody>
41198 </tgroup>
41199 </informaltable>
41200 <para>
41201 If this option is set true, nothing is logged for any
41202 deliveries by the transport or for any
41203 transport errors. You should not set this option unless you really, really know
41204 what you are doing.
41205 </para>
41206 <para>
41207 <indexterm role="option">
41208 <primary><option>debug_print</option></primary>
41209 </indexterm>
41210 </para>
41211 <informaltable frame="all">
41212 <tgroup cols="4" colsep="0" rowsep="0">
41213 <colspec colwidth="8*" align="left"/>
41214 <colspec colwidth="6*" align="center"/>
41215 <colspec colwidth="6*" align="center"/>
41216 <colspec colwidth="6*" align="right"/>
41217 <tbody>
41218 <row>
41219 <entry><option>debug_print</option></entry>
41220 <entry>Use: <emphasis>transports</emphasis></entry>
41221 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
41222 <entry>Default: <emphasis>unset</emphasis></entry>
41223 </row>
41224 </tbody>
41225 </tgroup>
41226 </informaltable>
41227 <para>
41228 <indexterm role="concept">
41229 <primary>testing</primary>
41230 <secondary>variables in drivers</secondary>
41231 </indexterm>
41232 If this option is set and debugging is enabled (see the <option>-d</option> command line
41233 option), the string is expanded and included in the debugging output when the
41234 transport is run.
41235 If expansion of the string fails, the error message is written to the debugging
41236 output, and Exim carries on processing.
41237 This facility is provided to help with checking out the values of variables and
41238 so on when debugging driver configurations. For example, if a <option>headers_add</option>
41239 option is not working properly, <option>debug_print</option> could be used to output the
41240 variables it references. A newline is added to the text if it does not end with
41241 one.
41242 The variables <varname>$transport_name</varname> and <varname>$router_name</varname> contain the name of the
41243 transport and the router that called it.
41244 </para>
41245 <para>
41246 <indexterm role="option">
41247 <primary><option>delivery_date_add</option></primary>
41248 </indexterm>
41249 </para>
41250 <informaltable frame="all">
41251 <tgroup cols="4" colsep="0" rowsep="0">
41252 <colspec colwidth="8*" align="left"/>
41253 <colspec colwidth="6*" align="center"/>
41254 <colspec colwidth="6*" align="center"/>
41255 <colspec colwidth="6*" align="right"/>
41256 <tbody>
41257 <row>
41258 <entry><option>delivery_date_add</option></entry>
41259 <entry>Use: <emphasis>transports</emphasis></entry>
41260 <entry>Type: <emphasis>boolean</emphasis></entry>
41261 <entry>Default: <emphasis>false</emphasis></entry>
41262 </row>
41263 </tbody>
41264 </tgroup>
41265 </informaltable>
41266 <para>
41267 <indexterm role="concept">
41268 <primary><emphasis>Delivery-date:</emphasis> header line</primary>
41269 </indexterm>
41270 If this option is true, a <emphasis>Delivery-date:</emphasis> header is added to the message.
41271 This gives the actual time the delivery was made. As this is not a standard
41272 header, Exim has a configuration option (<option>delivery_date_remove</option>) which
41273 requests its removal from incoming messages, so that delivered messages can
41274 safely be resent to other recipients.
41275 </para>
41276 <para>
41277 <indexterm role="option">
41278 <primary><option>driver</option></primary>
41279 </indexterm>
41280 </para>
41281 <informaltable frame="all">
41282 <tgroup cols="4" colsep="0" rowsep="0">
41283 <colspec colwidth="8*" align="left"/>
41284 <colspec colwidth="6*" align="center"/>
41285 <colspec colwidth="6*" align="center"/>
41286 <colspec colwidth="6*" align="right"/>
41287 <tbody>
41288 <row>
41289 <entry><option>driver</option></entry>
41290 <entry>Use: <emphasis>transports</emphasis></entry>
41291 <entry>Type: <emphasis>string</emphasis></entry>
41292 <entry>Default: <emphasis>unset</emphasis></entry>
41293 </row>
41294 </tbody>
41295 </tgroup>
41296 </informaltable>
41297 <para>
41298 This specifies which of the available transport drivers is to be used.
41299 There is no default, and this option must be set for every transport.
41300 </para>
41301 <para>
41302 <indexterm role="option">
41303 <primary><option>envelope_to_add</option></primary>
41304 </indexterm>
41305 </para>
41306 <informaltable frame="all">
41307 <tgroup cols="4" colsep="0" rowsep="0">
41308 <colspec colwidth="8*" align="left"/>
41309 <colspec colwidth="6*" align="center"/>
41310 <colspec colwidth="6*" align="center"/>
41311 <colspec colwidth="6*" align="right"/>
41312 <tbody>
41313 <row>
41314 <entry><option>envelope_to_add</option></entry>
41315 <entry>Use: <emphasis>transports</emphasis></entry>
41316 <entry>Type: <emphasis>boolean</emphasis></entry>
41317 <entry>Default: <emphasis>false</emphasis></entry>
41318 </row>
41319 </tbody>
41320 </tgroup>
41321 </informaltable>
41322 <para>
41323 <indexterm role="concept">
41324 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
41325 </indexterm>
41326 If this option is true, an <emphasis>Envelope-to:</emphasis> header is added to the message.
41327 This gives the original address(es) in the incoming envelope that caused this
41328 delivery to happen. More than one address may be present if the transport is
41329 configured to handle several addresses at once, or if more than one original
41330 address was redirected to the same final address. As this is not a standard
41331 header, Exim has a configuration option (<option>envelope_to_remove</option>) which requests
41332 its removal from incoming messages, so that delivered messages can safely be
41333 resent to other recipients.
41334 </para>
41335 <para>
41336 <indexterm role="option">
41337 <primary><option>event_action</option></primary>
41338 </indexterm>
41339 </para>
41340 <informaltable frame="all">
41341 <tgroup cols="4" colsep="0" rowsep="0">
41342 <colspec colwidth="8*" align="left"/>
41343 <colspec colwidth="6*" align="center"/>
41344 <colspec colwidth="6*" align="center"/>
41345 <colspec colwidth="6*" align="right"/>
41346 <tbody>
41347 <row>
41348 <entry><option>event_action</option></entry>
41349 <entry>Use: <emphasis>transports</emphasis></entry>
41350 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
41351 <entry>Default: <emphasis>unset</emphasis></entry>
41352 </row>
41353 </tbody>
41354 </tgroup>
41355 </informaltable>
41356 <para>
41357 <indexterm role="concept">
41358 <primary>events</primary>
41359 </indexterm>
41360 This option declares a string to be expanded for Exim&#x2019;s events mechanism.
41361 For details see chapter <xref linkend="CHAPevents"/>.
41362 </para>
41363 <para>
41364 <indexterm role="option">
41365 <primary><option>group</option></primary>
41366 </indexterm>
41367 </para>
41368 <informaltable frame="all">
41369 <tgroup cols="4" colsep="0" rowsep="0">
41370 <colspec colwidth="8*" align="left"/>
41371 <colspec colwidth="6*" align="center"/>
41372 <colspec colwidth="6*" align="center"/>
41373 <colspec colwidth="6*" align="right"/>
41374 <tbody>
41375 <row>
41376 <entry><option>group</option></entry>
41377 <entry>Use: <emphasis>transports</emphasis></entry>
41378 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
41379 <entry>Default: <emphasis>Exim group</emphasis></entry>
41380 </row>
41381 </tbody>
41382 </tgroup>
41383 </informaltable>
41384 <para>
41385 <indexterm role="concept">
41386 <primary>transport</primary>
41387 <secondary>group; specifying</secondary>
41388 </indexterm>
41389 This option specifies a gid for running the transport process, overriding any
41390 value that the router supplies, and also overriding any value associated with
41391 <option>user</option> (see below).
41392 </para>
41393 <para>
41394 <indexterm role="option">
41395 <primary><option>headers_add</option></primary>
41396 </indexterm>
41397 </para>
41398 <informaltable frame="all">
41399 <tgroup cols="4" colsep="0" rowsep="0">
41400 <colspec colwidth="8*" align="left"/>
41401 <colspec colwidth="6*" align="center"/>
41402 <colspec colwidth="6*" align="center"/>
41403 <colspec colwidth="6*" align="right"/>
41404 <tbody>
41405 <row>
41406 <entry><option>headers_add</option></entry>
41407 <entry>Use: <emphasis>transports</emphasis></entry>
41408 <entry>Type: <emphasis>list</emphasis>&dagger;<emphasis></emphasis></entry>
41409 <entry>Default: <emphasis>unset</emphasis></entry>
41410 </row>
41411 </tbody>
41412 </tgroup>
41413 </informaltable>
41414 <para>
41415 <indexterm role="concept">
41416 <primary>header lines</primary>
41417 <secondary>adding in transport</secondary>
41418 </indexterm>
41419 <indexterm role="concept">
41420 <primary>transport</primary>
41421 <secondary>header lines; adding</secondary>
41422 </indexterm>
41423 This option specifies a list of text headers,
41424 newline-separated (by default, changeable in the usual way <xref linkend="SECTlistsepchange"/>),
41425 which are (separately) expanded and added to the header
41426 portion of a message as it is transported, as described in section
41427 <xref linkend="SECTheadersaddrem"/>. Additional header lines can also be specified by
41428 routers. If the result of the expansion is an empty string, or if the expansion
41429 is forced to fail, no action is taken. Other expansion failures are treated as
41430 errors and cause the delivery to be deferred.
41431 </para>
41432 <para>
41433 Unlike most options, <option>headers_add</option> can be specified multiple times
41434 for a transport; all listed headers are added.
41435 </para>
41436 <para>
41437 <indexterm role="option">
41438 <primary><option>headers_only</option></primary>
41439 </indexterm>
41440 </para>
41441 <informaltable frame="all">
41442 <tgroup cols="4" colsep="0" rowsep="0">
41443 <colspec colwidth="8*" align="left"/>
41444 <colspec colwidth="6*" align="center"/>
41445 <colspec colwidth="6*" align="center"/>
41446 <colspec colwidth="6*" align="right"/>
41447 <tbody>
41448 <row>
41449 <entry><option>headers_only</option></entry>
41450 <entry>Use: <emphasis>transports</emphasis></entry>
41451 <entry>Type: <emphasis>boolean</emphasis></entry>
41452 <entry>Default: <emphasis>false</emphasis></entry>
41453 </row>
41454 </tbody>
41455 </tgroup>
41456 </informaltable>
41457 <para>
41458 <indexterm role="concept">
41459 <primary>transport</primary>
41460 <secondary>header lines only</secondary>
41461 </indexterm>
41462 <indexterm role="concept">
41463 <primary>message</primary>
41464 <secondary>transporting headers only</secondary>
41465 </indexterm>
41466 <indexterm role="concept">
41467 <primary>header lines</primary>
41468 <secondary>transporting</secondary>
41469 </indexterm>
41470 If this option is set, the message&#x2019;s body is not transported. It is mutually
41471 exclusive with <option>body_only</option>. If it is used with the <command>appendfile</command> or <command>pipe</command>
41472 transports, the settings of <option>message_prefix</option> and <option>message_suffix</option> should be
41473 checked, since this option does not automatically suppress them.
41474 </para>
41475 <para>
41476 <indexterm role="option">
41477 <primary><option>headers_remove</option></primary>
41478 </indexterm>
41479 </para>
41480 <informaltable frame="all">
41481 <tgroup cols="4" colsep="0" rowsep="0">
41482 <colspec colwidth="8*" align="left"/>
41483 <colspec colwidth="6*" align="center"/>
41484 <colspec colwidth="6*" align="center"/>
41485 <colspec colwidth="6*" align="right"/>
41486 <tbody>
41487 <row>
41488 <entry><option>headers_remove</option></entry>
41489 <entry>Use: <emphasis>transports</emphasis></entry>
41490 <entry>Type: <emphasis>list</emphasis>&dagger;<emphasis></emphasis></entry>
41491 <entry>Default: <emphasis>unset</emphasis></entry>
41492 </row>
41493 </tbody>
41494 </tgroup>
41495 </informaltable>
41496 <para>
41497 <indexterm role="concept">
41498 <primary>header lines</primary>
41499 <secondary>removing</secondary>
41500 </indexterm>
41501 <indexterm role="concept">
41502 <primary>transport</primary>
41503 <secondary>header lines; removing</secondary>
41504 </indexterm>
41505 This option specifies a list of header names,
41506 colon-separated (by default, changeable in the usual way <xref linkend="SECTlistsepchange"/>);
41507 these headers are omitted from the message as it is transported, as described
41508 in section <xref linkend="SECTheadersaddrem"/>. Header removal can also be specified by
41509 routers.
41510 Each list item is separately expanded.
41511 If the result of the expansion is an empty string, or if the expansion
41512 is forced to fail, no action is taken. Other expansion failures are treated as
41513 errors and cause the delivery to be deferred.
41514 </para>
41515 <para>
41516 Unlike most options, <option>headers_remove</option> can be specified multiple times
41517 for a transport; all listed headers are removed.
41518 </para>
41519 <para>
41520 <emphasis role="bold">Warning</emphasis>: Because of the separate expansion of the list items,
41521 items that contain a list separator must have it doubled.
41522 To avoid this, change the list separator (<xref linkend="SECTlistsepchange"/>).
41523 </para>
41524 <para>
41525 <indexterm role="option">
41526 <primary><option>headers_rewrite</option></primary>
41527 </indexterm>
41528 </para>
41529 <informaltable frame="all">
41530 <tgroup cols="4" colsep="0" rowsep="0">
41531 <colspec colwidth="8*" align="left"/>
41532 <colspec colwidth="6*" align="center"/>
41533 <colspec colwidth="6*" align="center"/>
41534 <colspec colwidth="6*" align="right"/>
41535 <tbody>
41536 <row>
41537 <entry><option>headers_rewrite</option></entry>
41538 <entry>Use: <emphasis>transports</emphasis></entry>
41539 <entry>Type: <emphasis>string</emphasis></entry>
41540 <entry>Default: <emphasis>unset</emphasis></entry>
41541 </row>
41542 </tbody>
41543 </tgroup>
41544 </informaltable>
41545 <para>
41546 <indexterm role="concept">
41547 <primary>transport</primary>
41548 <secondary>header lines; rewriting</secondary>
41549 </indexterm>
41550 <indexterm role="concept">
41551 <primary>rewriting</primary>
41552 <secondary>at transport time</secondary>
41553 </indexterm>
41554 This option allows addresses in header lines to be rewritten at transport time,
41555 that is, as the message is being copied to its destination. The contents of the
41556 option are a colon-separated list of rewriting rules. Each rule is in exactly
41557 the same form as one of the general rewriting rules that are applied when a
41558 message is received. These are described in chapter <xref linkend="CHAPrewrite"/>. For
41559 example,
41560 </para>
41561 <literallayout class="monospaced">
41562 headers_rewrite = a@b c@d f : \
41563                   x@y w@z
41564 </literallayout>
41565 <para>
41566 changes <emphasis>a@b</emphasis> into <emphasis>c@d</emphasis> in <emphasis>From:</emphasis> header lines, and <emphasis>x@y</emphasis> into
41567 <emphasis>w@z</emphasis> in all address-bearing header lines. The rules are applied to the
41568 header lines just before they are written out at transport time, so they affect
41569 only those copies of the message that pass through the transport. However, only
41570 the message&#x2019;s original header lines, and any that were added by a system
41571 filter, are rewritten. If a router or transport adds header lines, they are not
41572 affected by this option. These rewriting rules are <emphasis>not</emphasis> applied to the
41573 envelope. You can change the return path using <option>return_path</option>, but you cannot
41574 change envelope recipients at this time.
41575 </para>
41576 <para>
41577 <indexterm role="option">
41578 <primary><option>home_directory</option></primary>
41579 </indexterm>
41580 </para>
41581 <informaltable frame="all">
41582 <tgroup cols="4" colsep="0" rowsep="0">
41583 <colspec colwidth="8*" align="left"/>
41584 <colspec colwidth="6*" align="center"/>
41585 <colspec colwidth="6*" align="center"/>
41586 <colspec colwidth="6*" align="right"/>
41587 <tbody>
41588 <row>
41589 <entry><option>home_directory</option></entry>
41590 <entry>Use: <emphasis>transports</emphasis></entry>
41591 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
41592 <entry>Default: <emphasis>unset</emphasis></entry>
41593 </row>
41594 </tbody>
41595 </tgroup>
41596 </informaltable>
41597 <para>
41598 <indexterm role="concept">
41599 <primary>transport</primary>
41600 <secondary>home directory for</secondary>
41601 </indexterm>
41602 <indexterm role="variable">
41603 <primary><varname>$home</varname></primary>
41604 </indexterm>
41605 This option specifies a home directory setting for a local transport,
41606 overriding any value that may be set by the router. The home directory is
41607 placed in <varname>$home</varname> while expanding the transport&#x2019;s private options. It is also
41608 used as the current directory if no current directory is set by the
41609 <option>current_directory</option> option on the transport or the
41610 <option>transport_current_directory</option> option on the router. If the expansion fails
41611 for any reason, including forced failure, an error is logged, and delivery is
41612 deferred.
41613 </para>
41614 <para>
41615 <indexterm role="option">
41616 <primary><option>initgroups</option></primary>
41617 </indexterm>
41618 </para>
41619 <informaltable frame="all">
41620 <tgroup cols="4" colsep="0" rowsep="0">
41621 <colspec colwidth="8*" align="left"/>
41622 <colspec colwidth="6*" align="center"/>
41623 <colspec colwidth="6*" align="center"/>
41624 <colspec colwidth="6*" align="right"/>
41625 <tbody>
41626 <row>
41627 <entry><option>initgroups</option></entry>
41628 <entry>Use: <emphasis>transports</emphasis></entry>
41629 <entry>Type: <emphasis>boolean</emphasis></entry>
41630 <entry>Default: <emphasis>false</emphasis></entry>
41631 </row>
41632 </tbody>
41633 </tgroup>
41634 </informaltable>
41635 <para>
41636 <indexterm role="concept">
41637 <primary>additional groups</primary>
41638 </indexterm>
41639 <indexterm role="concept">
41640 <primary>groups</primary>
41641 <secondary>additional</secondary>
41642 </indexterm>
41643 <indexterm role="concept">
41644 <primary>transport</primary>
41645 <secondary>group; additional</secondary>
41646 </indexterm>
41647 If this option is true and the uid for the delivery process is provided by the
41648 transport, the <function>initgroups()</function> function is called when running the transport
41649 to ensure that any additional groups associated with the uid are set up.
41650 </para>
41651 <para>
41652 <indexterm role="option">
41653 <primary><option>max_parallel</option></primary>
41654 </indexterm>
41655 </para>
41656 <informaltable frame="all">
41657 <tgroup cols="4" colsep="0" rowsep="0">
41658 <colspec colwidth="8*" align="left"/>
41659 <colspec colwidth="6*" align="center"/>
41660 <colspec colwidth="6*" align="center"/>
41661 <colspec colwidth="6*" align="right"/>
41662 <tbody>
41663 <row>
41664 <entry><option>max_parallel</option></entry>
41665 <entry>Use: <emphasis>transports</emphasis></entry>
41666 <entry>Type: <emphasis>integer</emphasis>&dagger;<emphasis></emphasis></entry>
41667 <entry>Default: <emphasis>unset</emphasis></entry>
41668 </row>
41669 </tbody>
41670 </tgroup>
41671 </informaltable>
41672 <para>
41673 <indexterm role="concept">
41674 <primary>limit</primary>
41675 <secondary>transport parallelism</secondary>
41676 </indexterm>
41677 <indexterm role="concept">
41678 <primary>transport</primary>
41679 <secondary>parallel processes</secondary>
41680 </indexterm>
41681 <indexterm role="concept">
41682 <primary>transport</primary>
41683 <secondary>concurrency limit</secondary>
41684 </indexterm>
41685 <indexterm role="concept">
41686 <primary>delivery</primary>
41687 <secondary>parallelism for transport</secondary>
41688 </indexterm>
41689 If this option is set and expands to an integer greater than zero
41690 it limits the number of concurrent runs of the transport.
41691 The control does not apply to shadow transports.
41692 </para>
41693 <para>
41694 <indexterm role="concept">
41695 <primary>hints database</primary>
41696 <secondary>transport concurrency control</secondary>
41697 </indexterm>
41698 Exim implements this control by means of a hints database in which a record is
41699 incremented whenever a transport process is being created. The record
41700 is decremented and possibly removed when the process terminates.
41701 Obviously there is scope for
41702 records to get left lying around if there is a system or program crash. To
41703 guard against this, Exim ignores any records that are more than six hours old.
41704 </para>
41705 <para>
41706 If you use this option, you should also arrange to delete the
41707 relevant hints database whenever your system reboots. The names of the files
41708 start with <filename>misc</filename> and they are kept in the <filename>spool/db</filename> directory. There
41709 may be one or two files, depending on the type of DBM in use. The same files
41710 are used for ETRN and smtp transport serialization.
41711 </para>
41712 <para>
41713 <indexterm role="option">
41714 <primary><option>message_size_limit</option></primary>
41715 </indexterm>
41716 </para>
41717 <informaltable frame="all">
41718 <tgroup cols="4" colsep="0" rowsep="0">
41719 <colspec colwidth="8*" align="left"/>
41720 <colspec colwidth="6*" align="center"/>
41721 <colspec colwidth="6*" align="center"/>
41722 <colspec colwidth="6*" align="right"/>
41723 <tbody>
41724 <row>
41725 <entry><option>message_size_limit</option></entry>
41726 <entry>Use: <emphasis>transports</emphasis></entry>
41727 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
41728 <entry>Default: <emphasis>0</emphasis></entry>
41729 </row>
41730 </tbody>
41731 </tgroup>
41732 </informaltable>
41733 <para>
41734 <indexterm role="concept">
41735 <primary>limit</primary>
41736 <secondary>message size per transport</secondary>
41737 </indexterm>
41738 <indexterm role="concept">
41739 <primary>size</primary>
41740 <secondary>of message, limit</secondary>
41741 </indexterm>
41742 <indexterm role="concept">
41743 <primary>transport</primary>
41744 <secondary>message size; limiting</secondary>
41745 </indexterm>
41746 This option controls the size of messages passed through the transport. It is
41747 expanded before use; the result of the expansion must be a sequence of decimal
41748 digits, optionally followed by K or M. If the expansion fails for any reason,
41749 including forced failure, or if the result is not of the required form,
41750 delivery is deferred. If the value is greater than zero and the size of a
41751 message exceeds this limit, the address is failed. If there is any chance that
41752 the resulting bounce message could be routed to the same transport, you should
41753 ensure that <option>return_size_limit</option> is less than the transport&#x2019;s
41754 <option>message_size_limit</option>, as otherwise the bounce message will fail to get
41755 delivered.
41756 </para>
41757 <para>
41758 <indexterm role="option">
41759 <primary><option>rcpt_include_affixes</option></primary>
41760 </indexterm>
41761 </para>
41762 <informaltable frame="all">
41763 <tgroup cols="4" colsep="0" rowsep="0">
41764 <colspec colwidth="8*" align="left"/>
41765 <colspec colwidth="6*" align="center"/>
41766 <colspec colwidth="6*" align="center"/>
41767 <colspec colwidth="6*" align="right"/>
41768 <tbody>
41769 <row>
41770 <entry><option>rcpt_include_affixes</option></entry>
41771 <entry>Use: <emphasis>transports</emphasis></entry>
41772 <entry>Type: <emphasis>boolean</emphasis></entry>
41773 <entry>Default: <emphasis>false</emphasis></entry>
41774 </row>
41775 </tbody>
41776 </tgroup>
41777 </informaltable>
41778 <para>
41779 <indexterm role="concept">
41780 <primary>prefix</primary>
41781 <secondary>for local part, including in envelope</secondary>
41782 </indexterm>
41783 <indexterm role="concept">
41784 <primary>suffix for local part</primary>
41785 <secondary>including in envelope</secondary>
41786 </indexterm>
41787 <indexterm role="concept">
41788 <primary>local part</primary>
41789 <secondary>prefix</secondary>
41790 </indexterm>
41791 <indexterm role="concept">
41792 <primary>local part</primary>
41793 <secondary>suffix</secondary>
41794 </indexterm>
41795 When this option is false (the default), and an address that has had any
41796 affixes (prefixes or suffixes) removed from the local part is delivered by any
41797 form of SMTP or LMTP, the affixes are not included. For example, if a router
41798 that contains
41799 </para>
41800 <literallayout class="monospaced">
41801 local_part_prefix = *-
41802 </literallayout>
41803 <para>
41804 routes the address <emphasis>abc-xyz@some.domain</emphasis> to an SMTP transport, the envelope
41805 is delivered with
41806 </para>
41807 <literallayout class="monospaced">
41808 RCPT TO:&lt;xyz@some.domain&gt;
41809 </literallayout>
41810 <para>
41811 This is also the case when an ACL-time callout is being used to verify a
41812 recipient address. However, if <option>rcpt_include_affixes</option> is set true, the
41813 whole local part is included in the RCPT command. This option applies to BSMTP
41814 deliveries by the <command>appendfile</command> and <command>pipe</command> transports as well as to the
41815 <command>lmtp</command> and <command>smtp</command> transports.
41816 </para>
41817 <para>
41818 <indexterm role="option">
41819 <primary><option>retry_use_local_part</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>retry_use_local_part</option></entry>
41831 <entry>Use: <emphasis>transports</emphasis></entry>
41832 <entry>Type: <emphasis>boolean</emphasis></entry>
41833 <entry>Default: <emphasis>see below</emphasis></entry>
41834 </row>
41835 </tbody>
41836 </tgroup>
41837 </informaltable>
41838 <para>
41839 <indexterm role="concept">
41840 <primary>hints database</primary>
41841 <secondary>retry keys</secondary>
41842 </indexterm>
41843 When a delivery suffers a temporary failure, a retry record is created
41844 in Exim&#x2019;s hints database. For remote deliveries, the key for the retry record
41845 is based on the name and/or IP address of the failing remote host. For local
41846 deliveries, the key is normally the entire address, including both the local
41847 part and the domain. This is suitable for most common cases of local delivery
41848 temporary failure &ndash; for example, exceeding a mailbox quota should delay only
41849 deliveries to that mailbox, not to the whole domain.
41850 </para>
41851 <para>
41852 However, in some special cases you may want to treat a temporary local delivery
41853 as a failure associated with the domain, and not with a particular local part.
41854 (For example, if you are storing all mail for some domain in files.) You can do
41855 this by setting <option>retry_use_local_part</option> false.
41856 </para>
41857 <para>
41858 For all the local transports, its default value is true. For remote transports,
41859 the default value is false for tidiness, but changing the value has no effect
41860 on a remote transport in the current implementation.
41861 </para>
41862 <para>
41863 <indexterm role="option">
41864 <primary><option>return_path</option></primary>
41865 </indexterm>
41866 </para>
41867 <informaltable frame="all">
41868 <tgroup cols="4" colsep="0" rowsep="0">
41869 <colspec colwidth="8*" align="left"/>
41870 <colspec colwidth="6*" align="center"/>
41871 <colspec colwidth="6*" align="center"/>
41872 <colspec colwidth="6*" align="right"/>
41873 <tbody>
41874 <row>
41875 <entry><option>return_path</option></entry>
41876 <entry>Use: <emphasis>transports</emphasis></entry>
41877 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
41878 <entry>Default: <emphasis>unset</emphasis></entry>
41879 </row>
41880 </tbody>
41881 </tgroup>
41882 </informaltable>
41883 <para>
41884 <indexterm role="concept">
41885 <primary>envelope sender</primary>
41886 </indexterm>
41887 <indexterm role="concept">
41888 <primary>envelope from</primary>
41889 </indexterm>
41890 <indexterm role="concept">
41891 <primary>transport</primary>
41892 <secondary>return path; changing</secondary>
41893 </indexterm>
41894 <indexterm role="concept">
41895 <primary>return path</primary>
41896 <secondary>changing in transport</secondary>
41897 </indexterm>
41898 If this option is set, the string is expanded at transport time and replaces
41899 the existing return path (envelope sender) value in the copy of the message
41900 that is being delivered. An empty return path is permitted. This feature is
41901 designed for remote deliveries, where the value of this option is used in the
41902 SMTP MAIL command. If you set <option>return_path</option> for a local transport, the
41903 only effect is to change the address that is placed in the <emphasis>Return-path:</emphasis>
41904 header line, if one is added to the message (see the next option).
41905 </para>
41906 <para>
41907 <emphasis role="bold">Note:</emphasis> A changed return path is not logged unless you add
41908 <option>return_path_on_delivery</option> to the log selector.
41909 </para>
41910 <para>
41911 <indexterm role="variable">
41912 <primary><varname>$return_path</varname></primary>
41913 </indexterm>
41914 The expansion can refer to the existing value via <varname>$return_path</varname>. This is
41915 either the message&#x2019;s envelope sender, or an address set by the
41916 <option>errors_to</option> option on a router. If the expansion is forced to fail, no
41917 replacement occurs; if it fails for another reason, delivery is deferred. This
41918 option can be used to support VERP (Variable Envelope Return Paths) &ndash; see
41919 section <xref linkend="SECTverp"/>.
41920 </para>
41921 <para>
41922 <emphasis role="bold">Note</emphasis>: If a delivery error is detected locally, including the case when a
41923 remote server rejects a message at SMTP time, the bounce message is not sent to
41924 the value of this option. It is sent to the previously set errors address.
41925 This defaults to the incoming sender address, but can be changed by setting
41926 <option>errors_to</option> in a router.
41927 </para>
41928 <para>
41929 <indexterm role="option">
41930 <primary><option>return_path_add</option></primary>
41931 </indexterm>
41932 </para>
41933 <informaltable frame="all">
41934 <tgroup cols="4" colsep="0" rowsep="0">
41935 <colspec colwidth="8*" align="left"/>
41936 <colspec colwidth="6*" align="center"/>
41937 <colspec colwidth="6*" align="center"/>
41938 <colspec colwidth="6*" align="right"/>
41939 <tbody>
41940 <row>
41941 <entry><option>return_path_add</option></entry>
41942 <entry>Use: <emphasis>transports</emphasis></entry>
41943 <entry>Type: <emphasis>boolean</emphasis></entry>
41944 <entry>Default: <emphasis>false</emphasis></entry>
41945 </row>
41946 </tbody>
41947 </tgroup>
41948 </informaltable>
41949 <para>
41950 <indexterm role="concept">
41951 <primary><emphasis>Return-path:</emphasis> header line</primary>
41952 </indexterm>
41953 If this option is true, a <emphasis>Return-path:</emphasis> header is added to the message.
41954 Although the return path is normally available in the prefix line of BSD
41955 mailboxes, this is commonly not displayed by MUAs, and so the user does not
41956 have easy access to it.
41957 </para>
41958 <para>
41959 RFC 2821 states that the <emphasis>Return-path:</emphasis> header is added to a message <quote>when
41960 the delivery SMTP server makes the final delivery</quote>. This implies that this
41961 header should not be present in incoming messages. Exim has a configuration
41962 option, <option>return_path_remove</option>, which requests removal of this header from
41963 incoming messages, so that delivered messages can safely be resent to other
41964 recipients.
41965 </para>
41966 <para>
41967 <indexterm role="option">
41968 <primary><option>shadow_condition</option></primary>
41969 </indexterm>
41970 </para>
41971 <informaltable frame="all">
41972 <tgroup cols="4" colsep="0" rowsep="0">
41973 <colspec colwidth="8*" align="left"/>
41974 <colspec colwidth="6*" align="center"/>
41975 <colspec colwidth="6*" align="center"/>
41976 <colspec colwidth="6*" align="right"/>
41977 <tbody>
41978 <row>
41979 <entry><option>shadow_condition</option></entry>
41980 <entry>Use: <emphasis>transports</emphasis></entry>
41981 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
41982 <entry>Default: <emphasis>unset</emphasis></entry>
41983 </row>
41984 </tbody>
41985 </tgroup>
41986 </informaltable>
41987 <para>
41988 See <option>shadow_transport</option> below.
41989 </para>
41990 <para>
41991 <indexterm role="option">
41992 <primary><option>shadow_transport</option></primary>
41993 </indexterm>
41994 </para>
41995 <informaltable frame="all">
41996 <tgroup cols="4" colsep="0" rowsep="0">
41997 <colspec colwidth="8*" align="left"/>
41998 <colspec colwidth="6*" align="center"/>
41999 <colspec colwidth="6*" align="center"/>
42000 <colspec colwidth="6*" align="right"/>
42001 <tbody>
42002 <row>
42003 <entry><option>shadow_transport</option></entry>
42004 <entry>Use: <emphasis>transports</emphasis></entry>
42005 <entry>Type: <emphasis>string</emphasis></entry>
42006 <entry>Default: <emphasis>unset</emphasis></entry>
42007 </row>
42008 </tbody>
42009 </tgroup>
42010 </informaltable>
42011 <para>
42012 <indexterm role="concept">
42013 <primary>shadow transport</primary>
42014 </indexterm>
42015 <indexterm role="concept">
42016 <primary>transport</primary>
42017 <secondary>shadow</secondary>
42018 </indexterm>
42019 A local transport may set the <option>shadow_transport</option> option to the name of
42020 another local transport. Shadow remote transports are not supported.
42021 </para>
42022 <para>
42023 Whenever a delivery to the main transport succeeds, and either
42024 <option>shadow_condition</option> is unset, or its expansion does not result in the empty
42025 string or one of the strings <quote>0</quote> or <quote>no</quote> or <quote>false</quote>, the message is also
42026 passed to the shadow transport, with the same delivery address or addresses. If
42027 expansion fails, no action is taken except that non-forced expansion failures
42028 cause a log line to be written.
42029 </para>
42030 <para>
42031 The result of the shadow transport is discarded and does not affect the
42032 subsequent processing of the message. Only a single level of shadowing is
42033 provided; the <option>shadow_transport</option> option is ignored on any transport when it
42034 is running as a shadow. Options concerned with output from pipes are also
42035 ignored. The log line for the successful delivery has an item added on the end,
42036 of the form
42037 </para>
42038 <literallayout class="monospaced">
42039 ST=&lt;shadow transport name&gt;
42040 </literallayout>
42041 <para>
42042 If the shadow transport did not succeed, the error message is put in
42043 parentheses afterwards. Shadow transports can be used for a number of different
42044 purposes, including keeping more detailed log information than Exim normally
42045 provides, and implementing automatic acknowledgment policies based on message
42046 headers that some sites insist on.
42047 </para>
42048 <para>
42049 <indexterm role="option">
42050 <primary><option>transport_filter</option></primary>
42051 </indexterm>
42052 </para>
42053 <informaltable frame="all">
42054 <tgroup cols="4" colsep="0" rowsep="0">
42055 <colspec colwidth="8*" align="left"/>
42056 <colspec colwidth="6*" align="center"/>
42057 <colspec colwidth="6*" align="center"/>
42058 <colspec colwidth="6*" align="right"/>
42059 <tbody>
42060 <row>
42061 <entry><option>transport_filter</option></entry>
42062 <entry>Use: <emphasis>transports</emphasis></entry>
42063 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
42064 <entry>Default: <emphasis>unset</emphasis></entry>
42065 </row>
42066 </tbody>
42067 </tgroup>
42068 </informaltable>
42069 <para>
42070 <indexterm role="concept">
42071 <primary>transport</primary>
42072 <secondary>filter</secondary>
42073 </indexterm>
42074 <indexterm role="concept">
42075 <primary>filter</primary>
42076 <secondary>transport filter</secondary>
42077 </indexterm>
42078 This option sets up a filtering (in the Unix shell sense) process for messages
42079 at transport time. It should not be confused with mail filtering as set up by
42080 individual users or via a system filter.
42081 If unset, or expanding to an empty string, no filtering is done.
42082 </para>
42083 <para>
42084 When the message is about to be written out, the command specified by
42085 <option>transport_filter</option> is started up in a separate, parallel process, and
42086 the entire message, including the header lines, is passed to it on its standard
42087 input (this in fact is done from a third process, to avoid deadlock). The
42088 command must be specified as an absolute path.
42089 </para>
42090 <para>
42091 The lines of the message that are written to the transport filter are
42092 terminated by newline (<quote>\n</quote>). The message is passed to the filter before any
42093 SMTP-specific processing, such as turning <quote>\n</quote> into <quote>\r\n</quote> and escaping
42094 lines beginning with a dot, and also before any processing implied by the
42095 settings of <option>check_string</option> and <option>escape_string</option> in the <command>appendfile</command> or
42096 <command>pipe</command> transports.
42097 </para>
42098 <para>
42099 The standard error for the filter process is set to the same destination as its
42100 standard output; this is read and written to the message&#x2019;s ultimate
42101 destination. The process that writes the message to the filter, the
42102 filter itself, and the original process that reads the result and delivers it
42103 are all run in parallel, like a shell pipeline.
42104 </para>
42105 <para>
42106 The filter can perform any transformations it likes, but of course should take
42107 care not to break RFC 2822 syntax. Exim does not check the result, except to
42108 test for a final newline when SMTP is in use. All messages transmitted over
42109 SMTP must end with a newline, so Exim supplies one if it is missing.
42110 </para>
42111 <para>
42112 <indexterm role="concept">
42113 <primary>content scanning</primary>
42114 <secondary>per user</secondary>
42115 </indexterm>
42116 A transport filter can be used to provide content-scanning on a per-user basis
42117 at delivery time if the only required effect of the scan is to modify the
42118 message. For example, a content scan could insert a new header line containing
42119 a spam score. This could be interpreted by a filter in the user&#x2019;s MUA. It is
42120 not possible to discard a message at this stage.
42121 </para>
42122 <para>
42123 <indexterm role="concept">
42124 <primary>SMTP</primary>
42125 <secondary>SIZE</secondary>
42126 </indexterm>
42127 A problem might arise if the filter increases the size of a message that is
42128 being sent down an SMTP connection. If the receiving SMTP server has indicated
42129 support for the SIZE parameter, Exim will have sent the size of the message
42130 at the start of the SMTP session. If what is actually sent is substantially
42131 more, the server might reject the message. This can be worked round by setting
42132 the <option>size_addition</option> option on the <command>smtp</command> transport, either to allow for
42133 additions to the message, or to disable the use of SIZE altogether.
42134 </para>
42135 <para>
42136 <indexterm role="variable">
42137 <primary><varname>$pipe_addresses</varname></primary>
42138 </indexterm>
42139 The value of the <option>transport_filter</option> option is the command string for starting
42140 the filter, which is run directly from Exim, not under a shell. The string is
42141 parsed by Exim in the same way as a command string for the <command>pipe</command> transport:
42142 Exim breaks it up into arguments and then expands each argument separately (see
42143 section <xref linkend="SECThowcommandrun"/>). Any kind of expansion failure causes delivery
42144 to be deferred. The special argument <varname>$pipe_addresses</varname> is replaced by a number
42145 of arguments, one for each address that applies to this delivery. (This isn&#x2019;t
42146 an ideal name for this feature here, but as it was already implemented for the
42147 <command>pipe</command> transport, it seemed sensible not to change it.)
42148 </para>
42149 <para>
42150 <indexterm role="variable">
42151 <primary><varname>$host</varname></primary>
42152 </indexterm>
42153 <indexterm role="variable">
42154 <primary><varname>$host_address</varname></primary>
42155 </indexterm>
42156 The expansion variables <varname>$host</varname> and <varname>$host_address</varname> are available when the
42157 transport is a remote one. They contain the name and IP address of the host to
42158 which the message is being sent. For example:
42159 </para>
42160 <literallayout class="monospaced">
42161 transport_filter = /some/directory/transport-filter.pl \
42162   $host $host_address $sender_address $pipe_addresses
42163 </literallayout>
42164 <para>
42165 Two problems arise if you want to use more complicated expansion items to
42166 generate transport filter commands, both of which due to the fact that the
42167 command is split up <emphasis>before</emphasis> expansion.
42168 </para>
42169 <itemizedlist>
42170 <listitem>
42171 <para>
42172 If an expansion item contains white space, you must quote it, so that it is all
42173 part of the same command item. If the entire option setting is one such
42174 expansion item, you have to take care what kind of quoting you use. For
42175 example:
42176 </para>
42177 <literallayout class="monospaced">
42178 transport_filter = '/bin/cmd${if eq{$host}{a.b.c}{1}{2}}'
42179 </literallayout>
42180 <para>
42181 This runs the command <command>/bin/cmd1</command> if the host name is <emphasis>a.b.c</emphasis>, and
42182 <command>/bin/cmd2</command> otherwise. If double quotes had been used, they would have been
42183 stripped by Exim when it read the option&#x2019;s value. When the value is used, if
42184 the single quotes were missing, the line would be split into two items,
42185 <literal>/bin/cmd${if</literal> and <literal>eq{$host}{a.b.c}{1}{2}</literal>, and an error would occur when
42186 Exim tried to expand the first one.
42187 </para>
42188 </listitem>
42189 <listitem>
42190 <para>
42191 Except for the special case of <varname>$pipe_addresses</varname> that is mentioned above, an
42192 expansion cannot generate multiple arguments, or a command name followed by
42193 arguments. Consider this example:
42194 </para>
42195 <literallayout class="monospaced">
42196 transport_filter = ${lookup{$host}lsearch{/a/file}\
42197                     {$value}{/bin/cat}}
42198 </literallayout>
42199 <para>
42200 The result of the lookup is interpreted as the name of the command, even
42201 if it contains white space. The simplest way round this is to use a shell:
42202 </para>
42203 <literallayout class="monospaced">
42204 transport_filter = /bin/sh -c ${lookup{$host}lsearch{/a/file}\
42205                                {$value}{/bin/cat}}
42206 </literallayout>
42207 </listitem>
42208 </itemizedlist>
42209 <para>
42210 The filter process is run under the same uid and gid as the normal delivery.
42211 For remote deliveries this is the Exim uid/gid by default. The command should
42212 normally yield a zero return code. Transport filters are not supposed to fail.
42213 A non-zero code is taken to mean that the transport filter encountered some
42214 serious problem. Delivery of the message is deferred; the message remains on
42215 the queue and is tried again later. It is not possible to cause a message to be
42216 bounced from a transport filter.
42217 </para>
42218 <para>
42219 If a transport filter is set on an autoreply transport, the original message is
42220 passed through the filter as it is being copied into the newly generated
42221 message, which happens if the <option>return_message</option> option is set.
42222 </para>
42223 <para>
42224 <indexterm role="option">
42225 <primary><option>transport_filter_timeout</option></primary>
42226 </indexterm>
42227 </para>
42228 <informaltable frame="all">
42229 <tgroup cols="4" colsep="0" rowsep="0">
42230 <colspec colwidth="8*" align="left"/>
42231 <colspec colwidth="6*" align="center"/>
42232 <colspec colwidth="6*" align="center"/>
42233 <colspec colwidth="6*" align="right"/>
42234 <tbody>
42235 <row>
42236 <entry><option>transport_filter_timeout</option></entry>
42237 <entry>Use: <emphasis>transports</emphasis></entry>
42238 <entry>Type: <emphasis>time</emphasis></entry>
42239 <entry>Default: <emphasis>5m</emphasis></entry>
42240 </row>
42241 </tbody>
42242 </tgroup>
42243 </informaltable>
42244 <para>
42245 <indexterm role="concept">
42246 <primary>transport</primary>
42247 <secondary>filter, timeout</secondary>
42248 </indexterm>
42249 When Exim is reading the output of a transport filter, it applies a timeout
42250 that can be set by this option. Exceeding the timeout is normally treated as a
42251 temporary delivery failure. However, if a transport filter is used with a
42252 <command>pipe</command> transport, a timeout in the transport filter is treated in the same
42253 way as a timeout in the pipe command itself. By default, a timeout is a hard
42254 error, but if the <command>pipe</command> transport&#x2019;s <option>timeout_defer</option> option is set true, it
42255 becomes a temporary error.
42256 </para>
42257 <para>
42258 <indexterm role="option">
42259 <primary><option>user</option></primary>
42260 </indexterm>
42261 </para>
42262 <informaltable frame="all">
42263 <tgroup cols="4" colsep="0" rowsep="0">
42264 <colspec colwidth="8*" align="left"/>
42265 <colspec colwidth="6*" align="center"/>
42266 <colspec colwidth="6*" align="center"/>
42267 <colspec colwidth="6*" align="right"/>
42268 <tbody>
42269 <row>
42270 <entry><option>user</option></entry>
42271 <entry>Use: <emphasis>transports</emphasis></entry>
42272 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
42273 <entry>Default: <emphasis>Exim user</emphasis></entry>
42274 </row>
42275 </tbody>
42276 </tgroup>
42277 </informaltable>
42278 <para>
42279 <indexterm role="concept">
42280 <primary>uid (user id)</primary>
42281 <secondary>local delivery</secondary>
42282 </indexterm>
42283 <indexterm role="concept">
42284 <primary>transport</primary>
42285 <secondary>user, specifying</secondary>
42286 </indexterm>
42287 This option specifies the user under whose uid the delivery process is to be
42288 run, overriding any uid that may have been set by the router. If the user is
42289 given as a name, the uid is looked up from the password data, and the
42290 associated group is taken as the value of the gid to be used if the <option>group</option>
42291 option is not set.
42292 </para>
42293 <para>
42294 For deliveries that use local transports, a user and group are normally
42295 specified explicitly or implicitly (for example, as a result of
42296 <option>check_local_user</option>) by the router or transport.
42297 </para>
42298 <para>
42299 <indexterm role="concept">
42300 <primary>hints database</primary>
42301 <secondary>access by remote transport</secondary>
42302 </indexterm>
42303 For remote transports, you should leave this option unset unless you really are
42304 sure you know what you are doing. When a remote transport is running, it needs
42305 to be able to access Exim&#x2019;s hints databases, because each host may have its own
42306 retry data.
42307 <indexterm role="concept" startref="IIDgenoptra1" class="endofrange"/>
42308 <indexterm role="concept" startref="IIDgenoptra2" class="endofrange"/>
42309 <indexterm role="concept" startref="IIDgenoptra3" class="endofrange"/>
42310 </para>
42311 </chapter>
42312
42313 <chapter id="CHAPbatching">
42314 <title>Address batching in local transports</title>
42315 <titleabbrev>Address batching</titleabbrev>
42316 <para>
42317 <indexterm role="concept">
42318 <primary>transport</primary>
42319 <secondary>local; address batching in</secondary>
42320 </indexterm>
42321 The only remote transport (<command>smtp</command>) is normally configured to handle more than
42322 one address at a time, so that when several addresses are routed to the same
42323 remote host, just one copy of the message is sent. Local transports, however,
42324 normally handle one address at a time. That is, a separate instance of the
42325 transport is run for each address that is routed to the transport. A separate
42326 copy of the message is delivered each time.
42327 </para>
42328 <para>
42329 <indexterm role="concept">
42330 <primary>batched local delivery</primary>
42331 </indexterm>
42332 <indexterm role="option">
42333 <primary><option>batch_max</option></primary>
42334 </indexterm>
42335 <indexterm role="option">
42336 <primary><option>batch_id</option></primary>
42337 </indexterm>
42338 In special cases, it may be desirable to handle several addresses at once in a
42339 local transport, for example:
42340 </para>
42341 <itemizedlist>
42342 <listitem>
42343 <para>
42344 In an <command>appendfile</command> transport, when storing messages in files for later
42345 delivery by some other means, a single copy of the message with multiple
42346 recipients saves space.
42347 </para>
42348 </listitem>
42349 <listitem>
42350 <para>
42351 In an <command>lmtp</command> transport, when delivering over <quote>local SMTP</quote> to some process,
42352 a single copy saves time, and is the normal way LMTP is expected to work.
42353 </para>
42354 </listitem>
42355 <listitem>
42356 <para>
42357 In a <command>pipe</command> transport, when passing the message
42358 to a scanner program or
42359 to some other delivery mechanism such as UUCP, multiple recipients may be
42360 acceptable.
42361 </para>
42362 </listitem>
42363 </itemizedlist>
42364 <para>
42365 These three local transports all have the same options for controlling multiple
42366 (<quote>batched</quote>) deliveries, namely <option>batch_max</option> and <option>batch_id</option>. To save
42367 repeating the information for each transport, these options are described here.
42368 </para>
42369 <para>
42370 The <option>batch_max</option> option specifies the maximum number of addresses that can be
42371 delivered together in a single run of the transport. Its default value is one
42372 (no batching). When more than one address is routed to a transport that has a
42373 <option>batch_max</option> value greater than one, the addresses are delivered in a batch
42374 (that is, in a single run of the transport with multiple recipients), subject
42375 to certain conditions:
42376 </para>
42377 <itemizedlist>
42378 <listitem>
42379 <para>
42380 <indexterm role="variable">
42381 <primary><varname>$local_part</varname></primary>
42382 </indexterm>
42383 If any of the transport&#x2019;s options contain a reference to <varname>$local_part</varname>, no
42384 batching is possible.
42385 </para>
42386 </listitem>
42387 <listitem>
42388 <para>
42389 <indexterm role="variable">
42390 <primary><varname>$domain</varname></primary>
42391 </indexterm>
42392 If any of the transport&#x2019;s options contain a reference to <varname>$domain</varname>, only
42393 addresses with the same domain are batched.
42394 </para>
42395 </listitem>
42396 <listitem>
42397 <para>
42398 <indexterm role="concept">
42399 <primary>customizing</primary>
42400 <secondary>batching condition</secondary>
42401 </indexterm>
42402 If <option>batch_id</option> is set, it is expanded for each address, and only those
42403 addresses with the same expanded value are batched. This allows you to specify
42404 customized batching conditions. Failure of the expansion for any reason,
42405 including forced failure, disables batching, but it does not stop the delivery
42406 from taking place.
42407 </para>
42408 </listitem>
42409 <listitem>
42410 <para>
42411 Batched addresses must also have the same errors address (where to send
42412 delivery errors), the same header additions and removals, the same user and
42413 group for the transport, and if a host list is present, the first host must
42414 be the same.
42415 </para>
42416 </listitem>
42417 </itemizedlist>
42418 <para>
42419 In the case of the <command>appendfile</command> and <command>pipe</command> transports, batching applies
42420 both when the file or pipe command is specified in the transport, and when it
42421 is specified by a <command>redirect</command> router, but all the batched addresses must of
42422 course be routed to the same file or pipe command. These two transports have an
42423 option called <option>use_bsmtp</option>, which causes them to deliver the message in
42424 <quote>batched SMTP</quote> format, with the envelope represented as SMTP commands. The
42425 <option>check_string</option> and <option>escape_string</option> options are forced to the values
42426 </para>
42427 <literallayout class="monospaced">
42428 check_string = "."
42429 escape_string = ".."
42430 </literallayout>
42431 <para>
42432 when batched SMTP is in use. A full description of the batch SMTP mechanism is
42433 given in section <xref linkend="SECTbatchSMTP"/>. The <command>lmtp</command> transport does not have a
42434 <option>use_bsmtp</option> option, because it always delivers using the SMTP protocol.
42435 </para>
42436 <para>
42437 <indexterm role="concept">
42438 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
42439 </indexterm>
42440 If the generic <option>envelope_to_add</option> option is set for a batching transport, the
42441 <emphasis>Envelope-to:</emphasis> header that is added to the message contains all the addresses
42442 that are being processed together. If you are using a batching <command>appendfile</command>
42443 transport without <option>use_bsmtp</option>, the only way to preserve the recipient
42444 addresses is to set the <option>envelope_to_add</option> option.
42445 </para>
42446 <para>
42447 <indexterm role="concept">
42448 <primary><command>pipe</command> transport</primary>
42449 <secondary>with multiple addresses</secondary>
42450 </indexterm>
42451 <indexterm role="variable">
42452 <primary><varname>$pipe_addresses</varname></primary>
42453 </indexterm>
42454 If you are using a <command>pipe</command> transport without BSMTP, and setting the
42455 transport&#x2019;s <option>command</option> option, you can include <varname>$pipe_addresses</varname> as part of
42456 the command. This is not a true variable; it is a bit of magic that causes each
42457 of the recipient addresses to be inserted into the command as a separate
42458 argument. This provides a way of accessing all the addresses that are being
42459 delivered in the batch. <emphasis role="bold">Note:</emphasis> This is not possible for pipe commands that
42460 are specified by a <command>redirect</command> router.
42461 </para>
42462 </chapter>
42463
42464 <chapter id="CHAPappendfile">
42465 <title>The appendfile transport</title>
42466 <para>
42467 <indexterm role="concept" id="IIDapptra1" class="startofrange">
42468 <primary><command>appendfile</command> transport</primary>
42469 </indexterm>
42470 <indexterm role="concept" id="IIDapptra2" class="startofrange">
42471 <primary>transports</primary>
42472 <secondary><command>appendfile</command></secondary>
42473 </indexterm>
42474 <indexterm role="concept">
42475 <primary>directory creation</primary>
42476 </indexterm>
42477 <indexterm role="concept">
42478 <primary>creating directories</primary>
42479 </indexterm>
42480 The <command>appendfile</command> transport delivers a message by appending it to an existing
42481 file, or by creating an entirely new file in a specified directory. Single
42482 files to which messages are appended can be in the traditional Unix mailbox
42483 format, or optionally in the MBX format supported by the Pine MUA and
42484 University of Washington IMAP daemon, <emphasis>inter alia</emphasis>. When each message is
42485 being delivered as a separate file, <quote>maildir</quote> format can optionally be used
42486 to give added protection against failures that happen part-way through the
42487 delivery. A third form of separate-file delivery known as <quote>mailstore</quote> is also
42488 supported. For all file formats, Exim attempts to create as many levels of
42489 directory as necessary, provided that <option>create_directory</option> is set.
42490 </para>
42491 <para>
42492 The code for the optional formats is not included in the Exim binary by
42493 default. It is necessary to set SUPPORT_MBX, SUPPORT_MAILDIR and/or
42494 SUPPORT_MAILSTORE in <filename>Local/Makefile</filename> to have the appropriate code
42495 included.
42496 </para>
42497 <para>
42498 <indexterm role="concept">
42499 <primary>quota</primary>
42500 <secondary>system</secondary>
42501 </indexterm>
42502 Exim recognizes system quota errors, and generates an appropriate message. Exim
42503 also supports its own quota control within the transport, for use when the
42504 system facility is unavailable or cannot be used for some reason.
42505 </para>
42506 <para>
42507 If there is an error while appending to a file (for example, quota exceeded or
42508 partition filled), Exim attempts to reset the file&#x2019;s length and last
42509 modification time back to what they were before. If there is an error while
42510 creating an entirely new file, the new file is removed.
42511 </para>
42512 <para>
42513 Before appending to a file, a number of security checks are made, and the
42514 file is locked. A detailed description is given below, after the list of
42515 private options.
42516 </para>
42517 <para>
42518 The <command>appendfile</command> transport is most commonly used for local deliveries to
42519 users&#x2019; mailboxes. However, it can also be used as a pseudo-remote transport for
42520 putting messages into files for remote delivery by some means other than Exim.
42521 <quote>Batch SMTP</quote> format is often used in this case (see the <option>use_bsmtp</option>
42522 option).
42523 </para>
42524 <section id="SECTfildiropt">
42525 <title>The file and directory options</title>
42526 <para>
42527 The <option>file</option> option specifies a single file, to which the message is appended;
42528 the <option>directory</option> option specifies a directory, in which a new file containing
42529 the message is created. Only one of these two options can be set, and for
42530 normal deliveries to mailboxes, one of them <emphasis>must</emphasis> be set.
42531 </para>
42532 <para>
42533 <indexterm role="variable">
42534 <primary><varname>$address_file</varname></primary>
42535 </indexterm>
42536 <indexterm role="variable">
42537 <primary><varname>$local_part</varname></primary>
42538 </indexterm>
42539 However, <command>appendfile</command> is also used for delivering messages to files or
42540 directories whose names (or parts of names) are obtained from alias,
42541 forwarding, or filtering operations (for example, a <option>save</option> command in a
42542 user&#x2019;s Exim filter). When such a transport is running, <varname>$local_part</varname> contains
42543 the local part that was aliased or forwarded, and <varname>$address_file</varname> contains the
42544 name (or partial name) of the file or directory generated by the redirection
42545 operation. There are two cases:
42546 </para>
42547 <itemizedlist>
42548 <listitem>
42549 <para>
42550 If neither <option>file</option> nor <option>directory</option> is set, the redirection operation
42551 must specify an absolute path (one that begins with <literal>/</literal>). This is the most
42552 common case when users with local accounts use filtering to sort mail into
42553 different folders. See for example, the <command>address_file</command> transport in the
42554 default configuration. If the path ends with a slash, it is assumed to be the
42555 name of a directory. A delivery to a directory can also be forced by setting
42556 <option>maildir_format</option> or <option>mailstore_format</option>.
42557 </para>
42558 </listitem>
42559 <listitem>
42560 <para>
42561 If <option>file</option> or <option>directory</option> is set for a delivery from a redirection, it is
42562 used to determine the file or directory name for the delivery. Normally, the
42563 contents of <varname>$address_file</varname> are used in some way in the string expansion.
42564 </para>
42565 </listitem>
42566 </itemizedlist>
42567 <para>
42568 <indexterm role="concept">
42569 <primary>Sieve filter</primary>
42570 <secondary>configuring <command>appendfile</command></secondary>
42571 </indexterm>
42572 <indexterm role="concept">
42573 <primary>Sieve filter</primary>
42574 <secondary>relative mailbox path handling</secondary>
42575 </indexterm>
42576 As an example of the second case, consider an environment where users do not
42577 have home directories. They may be permitted to use Exim filter commands of the
42578 form:
42579 </para>
42580 <literallayout class="monospaced">
42581 save folder23
42582 </literallayout>
42583 <para>
42584 or Sieve filter commands of the form:
42585 </para>
42586 <literallayout class="monospaced">
42587 require "fileinto";
42588 fileinto "folder23";
42589 </literallayout>
42590 <para>
42591 In this situation, the expansion of <option>file</option> or <option>directory</option> in the transport
42592 must transform the relative path into an appropriate absolute filename. In the
42593 case of Sieve filters, the name <emphasis>inbox</emphasis> must be handled. It is the name that
42594 is used as a result of a <quote>keep</quote> action in the filter. This example shows one
42595 way of handling this requirement:
42596 </para>
42597 <literallayout class="monospaced">
42598 file = ${if eq{$address_file}{inbox} \
42599             {/var/mail/$local_part} \
42600             {${if eq{${substr_0_1:$address_file}}{/} \
42601                   {$address_file} \
42602                   {$home/mail/$address_file} \
42603             }} \
42604        }
42605 </literallayout>
42606 <para>
42607 With this setting of <option>file</option>, <emphasis>inbox</emphasis> refers to the standard mailbox
42608 location, absolute paths are used without change, and other folders are in the
42609 <filename>mail</filename> directory within the home directory.
42610 </para>
42611 <para>
42612 <emphasis role="bold">Note 1</emphasis>: While processing an Exim filter, a relative path such as
42613 <filename>folder23</filename> is turned into an absolute path if a home directory is known to
42614 the router. In particular, this is the case if <option>check_local_user</option> is set. If
42615 you want to prevent this happening at routing time, you can set
42616 <option>router_home_directory</option> empty. This forces the router to pass the relative
42617 path to the transport.
42618 </para>
42619 <para>
42620 <emphasis role="bold">Note 2</emphasis>: An absolute path in <varname>$address_file</varname> is not treated specially;
42621 the <option>file</option> or <option>directory</option> option is still used if it is set.
42622 </para>
42623 </section>
42624 <section id="SECID134">
42625 <title>Private options for appendfile</title>
42626 <para>
42627 <indexterm role="concept">
42628 <primary>options</primary>
42629 <secondary><command>appendfile</command> transport</secondary>
42630 </indexterm>
42631 </para>
42632 <para>
42633 <indexterm role="option">
42634 <primary><option>allow_fifo</option></primary>
42635 </indexterm>
42636 </para>
42637 <informaltable frame="all">
42638 <tgroup cols="4" colsep="0" rowsep="0">
42639 <colspec colwidth="8*" align="left"/>
42640 <colspec colwidth="6*" align="center"/>
42641 <colspec colwidth="6*" align="center"/>
42642 <colspec colwidth="6*" align="right"/>
42643 <tbody>
42644 <row>
42645 <entry><option>allow_fifo</option></entry>
42646 <entry>Use: <emphasis>appendfile</emphasis></entry>
42647 <entry>Type: <emphasis>boolean</emphasis></entry>
42648 <entry>Default: <emphasis>false</emphasis></entry>
42649 </row>
42650 </tbody>
42651 </tgroup>
42652 </informaltable>
42653 <para>
42654 <indexterm role="concept">
42655 <primary>fifo (named pipe)</primary>
42656 </indexterm>
42657 <indexterm role="concept">
42658 <primary>named pipe (fifo)</primary>
42659 </indexterm>
42660 <indexterm role="concept">
42661 <primary>pipe</primary>
42662 <secondary>named (fifo)</secondary>
42663 </indexterm>
42664 Setting this option permits delivery to named pipes (FIFOs) as well as to
42665 regular files. If no process is reading the named pipe at delivery time, the
42666 delivery is deferred.
42667 </para>
42668 <para>
42669 <indexterm role="option">
42670 <primary><option>allow_symlink</option></primary>
42671 </indexterm>
42672 </para>
42673 <informaltable frame="all">
42674 <tgroup cols="4" colsep="0" rowsep="0">
42675 <colspec colwidth="8*" align="left"/>
42676 <colspec colwidth="6*" align="center"/>
42677 <colspec colwidth="6*" align="center"/>
42678 <colspec colwidth="6*" align="right"/>
42679 <tbody>
42680 <row>
42681 <entry><option>allow_symlink</option></entry>
42682 <entry>Use: <emphasis>appendfile</emphasis></entry>
42683 <entry>Type: <emphasis>boolean</emphasis></entry>
42684 <entry>Default: <emphasis>false</emphasis></entry>
42685 </row>
42686 </tbody>
42687 </tgroup>
42688 </informaltable>
42689 <para>
42690 <indexterm role="concept">
42691 <primary>symbolic link</primary>
42692 <secondary>to mailbox</secondary>
42693 </indexterm>
42694 <indexterm role="concept">
42695 <primary>mailbox</primary>
42696 <secondary>symbolic link</secondary>
42697 </indexterm>
42698 By default, <command>appendfile</command> will not deliver if the path name for the file is
42699 that of a symbolic link. Setting this option relaxes that constraint, but there
42700 are security issues involved in the use of symbolic links. Be sure you know
42701 what you are doing if you set this. Details of exactly what this option affects
42702 are included in the discussion which follows this list of options.
42703 </para>
42704 <para>
42705 <indexterm role="option">
42706 <primary><option>batch_id</option></primary>
42707 </indexterm>
42708 </para>
42709 <informaltable frame="all">
42710 <tgroup cols="4" colsep="0" rowsep="0">
42711 <colspec colwidth="8*" align="left"/>
42712 <colspec colwidth="6*" align="center"/>
42713 <colspec colwidth="6*" align="center"/>
42714 <colspec colwidth="6*" align="right"/>
42715 <tbody>
42716 <row>
42717 <entry><option>batch_id</option></entry>
42718 <entry>Use: <emphasis>appendfile</emphasis></entry>
42719 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
42720 <entry>Default: <emphasis>unset</emphasis></entry>
42721 </row>
42722 </tbody>
42723 </tgroup>
42724 </informaltable>
42725 <para>
42726 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
42727 However, batching is automatically disabled for <command>appendfile</command> deliveries that
42728 happen as a result of forwarding or aliasing or other redirection directly to a
42729 file.
42730 </para>
42731 <para>
42732 <indexterm role="option">
42733 <primary><option>batch_max</option></primary>
42734 </indexterm>
42735 </para>
42736 <informaltable frame="all">
42737 <tgroup cols="4" colsep="0" rowsep="0">
42738 <colspec colwidth="8*" align="left"/>
42739 <colspec colwidth="6*" align="center"/>
42740 <colspec colwidth="6*" align="center"/>
42741 <colspec colwidth="6*" align="right"/>
42742 <tbody>
42743 <row>
42744 <entry><option>batch_max</option></entry>
42745 <entry>Use: <emphasis>appendfile</emphasis></entry>
42746 <entry>Type: <emphasis>integer</emphasis></entry>
42747 <entry>Default: <emphasis>1</emphasis></entry>
42748 </row>
42749 </tbody>
42750 </tgroup>
42751 </informaltable>
42752 <para>
42753 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
42754 </para>
42755 <para>
42756 <indexterm role="option">
42757 <primary><option>check_group</option></primary>
42758 </indexterm>
42759 </para>
42760 <informaltable frame="all">
42761 <tgroup cols="4" colsep="0" rowsep="0">
42762 <colspec colwidth="8*" align="left"/>
42763 <colspec colwidth="6*" align="center"/>
42764 <colspec colwidth="6*" align="center"/>
42765 <colspec colwidth="6*" align="right"/>
42766 <tbody>
42767 <row>
42768 <entry><option>check_group</option></entry>
42769 <entry>Use: <emphasis>appendfile</emphasis></entry>
42770 <entry>Type: <emphasis>boolean</emphasis></entry>
42771 <entry>Default: <emphasis>false</emphasis></entry>
42772 </row>
42773 </tbody>
42774 </tgroup>
42775 </informaltable>
42776 <para>
42777 When this option is set, the group owner of the file defined by the <option>file</option>
42778 option is checked to see that it is the same as the group under which the
42779 delivery process is running. The default setting is false because the default
42780 file mode is 0600, which means that the group is irrelevant.
42781 </para>
42782 <para>
42783 <indexterm role="option">
42784 <primary><option>check_owner</option></primary>
42785 </indexterm>
42786 </para>
42787 <informaltable frame="all">
42788 <tgroup cols="4" colsep="0" rowsep="0">
42789 <colspec colwidth="8*" align="left"/>
42790 <colspec colwidth="6*" align="center"/>
42791 <colspec colwidth="6*" align="center"/>
42792 <colspec colwidth="6*" align="right"/>
42793 <tbody>
42794 <row>
42795 <entry><option>check_owner</option></entry>
42796 <entry>Use: <emphasis>appendfile</emphasis></entry>
42797 <entry>Type: <emphasis>boolean</emphasis></entry>
42798 <entry>Default: <emphasis>true</emphasis></entry>
42799 </row>
42800 </tbody>
42801 </tgroup>
42802 </informaltable>
42803 <para>
42804 When this option is set, the owner of the file defined by the <option>file</option> option
42805 is checked to ensure that it is the same as the user under which the delivery
42806 process is running.
42807 </para>
42808 <para>
42809 <indexterm role="option">
42810 <primary><option>check_string</option></primary>
42811 </indexterm>
42812 </para>
42813 <informaltable frame="all">
42814 <tgroup cols="4" colsep="0" rowsep="0">
42815 <colspec colwidth="8*" align="left"/>
42816 <colspec colwidth="6*" align="center"/>
42817 <colspec colwidth="6*" align="center"/>
42818 <colspec colwidth="6*" align="right"/>
42819 <tbody>
42820 <row>
42821 <entry><option>check_string</option></entry>
42822 <entry>Use: <emphasis>appendfile</emphasis></entry>
42823 <entry>Type: <emphasis>string</emphasis></entry>
42824 <entry>Default: <emphasis>see below</emphasis></entry>
42825 </row>
42826 </tbody>
42827 </tgroup>
42828 </informaltable>
42829 <para>
42830 <indexterm role="concept">
42831 <primary><quote>From</quote> line</primary>
42832 </indexterm>
42833 As <command>appendfile</command> writes the message, the start of each line is tested for
42834 matching <option>check_string</option>, and if it does, the initial matching characters are
42835 replaced by the contents of <option>escape_string</option>. The value of <option>check_string</option> is
42836 a literal string, not a regular expression, and the case of any letters it
42837 contains is significant.
42838 </para>
42839 <para>
42840 If <option>use_bsmtp</option> is set the values of <option>check_string</option> and <option>escape_string</option>
42841 are forced to <quote>.</quote> and <quote>..</quote> respectively, and any settings in the
42842 configuration are ignored. Otherwise, they default to <quote>From&nbsp;</quote> and
42843 <quote>&gt;From&nbsp;</quote> when the <option>file</option> option is set, and unset when any of the
42844 <option>directory</option>, <option>maildir</option>, or <option>mailstore</option> options are set.
42845 </para>
42846 <para>
42847 The default settings, along with <option>message_prefix</option> and <option>message_suffix</option>, are
42848 suitable for traditional <quote>BSD</quote> mailboxes, where a line beginning with
42849 <quote>From&nbsp;</quote> indicates the start of a new message. All four options need changing
42850 if another format is used. For example, to deliver to mailboxes in MMDF format:
42851 <indexterm role="concept">
42852 <primary>MMDF format mailbox</primary>
42853 </indexterm>
42854 <indexterm role="concept">
42855 <primary>mailbox</primary>
42856 <secondary>MMDF format</secondary>
42857 </indexterm>
42858 </para>
42859 <literallayout class="monospaced">
42860 check_string = "\1\1\1\1\n"
42861 escape_string = "\1\1\1\1 \n"
42862 message_prefix = "\1\1\1\1\n"
42863 message_suffix = "\1\1\1\1\n"
42864 </literallayout>
42865 <para>
42866 <indexterm role="option">
42867 <primary><option>create_directory</option></primary>
42868 </indexterm>
42869 </para>
42870 <informaltable frame="all">
42871 <tgroup cols="4" colsep="0" rowsep="0">
42872 <colspec colwidth="8*" align="left"/>
42873 <colspec colwidth="6*" align="center"/>
42874 <colspec colwidth="6*" align="center"/>
42875 <colspec colwidth="6*" align="right"/>
42876 <tbody>
42877 <row>
42878 <entry><option>create_directory</option></entry>
42879 <entry>Use: <emphasis>appendfile</emphasis></entry>
42880 <entry>Type: <emphasis>boolean</emphasis></entry>
42881 <entry>Default: <emphasis>true</emphasis></entry>
42882 </row>
42883 </tbody>
42884 </tgroup>
42885 </informaltable>
42886 <para>
42887 <indexterm role="concept">
42888 <primary>directory creation</primary>
42889 </indexterm>
42890 When this option is true, Exim attempts to create any missing superior
42891 directories for the file that it is about to write. A created directory&#x2019;s mode
42892 is given by the <option>directory_mode</option> option.
42893 </para>
42894 <para>
42895 The group ownership of a newly created directory is highly dependent on the
42896 operating system (and possibly the file system) that is being used. For
42897 example, in Solaris, if the parent directory has the setgid bit set, its group
42898 is propagated to the child; if not, the currently set group is used. However,
42899 in FreeBSD, the parent&#x2019;s group is always used.
42900 </para>
42901 <para>
42902 <indexterm role="option">
42903 <primary><option>create_file</option></primary>
42904 </indexterm>
42905 </para>
42906 <informaltable frame="all">
42907 <tgroup cols="4" colsep="0" rowsep="0">
42908 <colspec colwidth="8*" align="left"/>
42909 <colspec colwidth="6*" align="center"/>
42910 <colspec colwidth="6*" align="center"/>
42911 <colspec colwidth="6*" align="right"/>
42912 <tbody>
42913 <row>
42914 <entry><option>create_file</option></entry>
42915 <entry>Use: <emphasis>appendfile</emphasis></entry>
42916 <entry>Type: <emphasis>string</emphasis></entry>
42917 <entry>Default: <emphasis>anywhere</emphasis></entry>
42918 </row>
42919 </tbody>
42920 </tgroup>
42921 </informaltable>
42922 <para>
42923 This option constrains the location of files and directories that are created
42924 by this transport. It applies to files defined by the <option>file</option> option and
42925 directories defined by the <option>directory</option> option. In the case of maildir
42926 delivery, it applies to the top level directory, not the maildir directories
42927 beneath.
42928 </para>
42929 <para>
42930 The option must be set to one of the words <quote>anywhere</quote>, <quote>inhome</quote>, or
42931 <quote>belowhome</quote>. In the second and third cases, a home directory must have been
42932 set for the transport. This option is not useful when an explicit filename is
42933 given for normal mailbox deliveries. It is intended for the case when filenames
42934 are generated from users&#x2019; <filename>.forward</filename> files. These are usually handled
42935 by an <command>appendfile</command> transport called <option>address_file</option>. See also
42936 <option>file_must_exist</option>.
42937 </para>
42938 <para>
42939 <indexterm role="option">
42940 <primary><option>directory</option></primary>
42941 </indexterm>
42942 </para>
42943 <informaltable frame="all">
42944 <tgroup cols="4" colsep="0" rowsep="0">
42945 <colspec colwidth="8*" align="left"/>
42946 <colspec colwidth="6*" align="center"/>
42947 <colspec colwidth="6*" align="center"/>
42948 <colspec colwidth="6*" align="right"/>
42949 <tbody>
42950 <row>
42951 <entry><option>directory</option></entry>
42952 <entry>Use: <emphasis>appendfile</emphasis></entry>
42953 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
42954 <entry>Default: <emphasis>unset</emphasis></entry>
42955 </row>
42956 </tbody>
42957 </tgroup>
42958 </informaltable>
42959 <para>
42960 This option is mutually exclusive with the <option>file</option> option, but one of <option>file</option>
42961 or <option>directory</option> must be set, unless the delivery is the direct result of a
42962 redirection (see section <xref linkend="SECTfildiropt"/>).
42963 </para>
42964 <para>
42965 When <option>directory</option> is set, the string is expanded, and the message is delivered
42966 into a new file or files in or below the given directory, instead of being
42967 appended to a single mailbox file. A number of different formats are provided
42968 (see <option>maildir_format</option> and <option>mailstore_format</option>), and see section
42969 <xref linkend="SECTopdir"/> for further details of this form of delivery.
42970 </para>
42971 <para>
42972 <indexterm role="option">
42973 <primary><option>directory_file</option></primary>
42974 </indexterm>
42975 </para>
42976 <informaltable frame="all">
42977 <tgroup cols="4" colsep="0" rowsep="0">
42978 <colspec colwidth="8*" align="left"/>
42979 <colspec colwidth="6*" align="center"/>
42980 <colspec colwidth="6*" align="center"/>
42981 <colspec colwidth="6*" align="right"/>
42982 <tbody>
42983 <row>
42984 <entry><option>directory_file</option></entry>
42985 <entry>Use: <emphasis>appendfile</emphasis></entry>
42986 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
42987 <entry>Default: <emphasis>see below</emphasis></entry>
42988 </row>
42989 </tbody>
42990 </tgroup>
42991 </informaltable>
42992 <para>
42993 <indexterm role="concept">
42994 <primary>base62</primary>
42995 </indexterm>
42996 <indexterm role="variable">
42997 <primary><varname>$inode</varname></primary>
42998 </indexterm>
42999 When <option>directory</option> is set, but neither <option>maildir_format</option> nor
43000 <option>mailstore_format</option> is set, <command>appendfile</command> delivers each message into a file
43001 whose name is obtained by expanding this string. The default value is:
43002 </para>
43003 <literallayout class="monospaced">
43004 q${base62:$tod_epoch}-$inode
43005 </literallayout>
43006 <para>
43007 This generates a unique name from the current time, in base 62 form, and the
43008 inode of the file. The variable <varname>$inode</varname> is available only when expanding this
43009 option.
43010 </para>
43011 <para>
43012 <indexterm role="option">
43013 <primary><option>directory_mode</option></primary>
43014 </indexterm>
43015 </para>
43016 <informaltable frame="all">
43017 <tgroup cols="4" colsep="0" rowsep="0">
43018 <colspec colwidth="8*" align="left"/>
43019 <colspec colwidth="6*" align="center"/>
43020 <colspec colwidth="6*" align="center"/>
43021 <colspec colwidth="6*" align="right"/>
43022 <tbody>
43023 <row>
43024 <entry><option>directory_mode</option></entry>
43025 <entry>Use: <emphasis>appendfile</emphasis></entry>
43026 <entry>Type: <emphasis>octal integer</emphasis></entry>
43027 <entry>Default: <emphasis>0700</emphasis></entry>
43028 </row>
43029 </tbody>
43030 </tgroup>
43031 </informaltable>
43032 <para>
43033 If <command>appendfile</command> creates any directories as a result of the
43034 <option>create_directory</option> option, their mode is specified by this option.
43035 </para>
43036 <para>
43037 <indexterm role="option">
43038 <primary><option>escape_string</option></primary>
43039 </indexterm>
43040 </para>
43041 <informaltable frame="all">
43042 <tgroup cols="4" colsep="0" rowsep="0">
43043 <colspec colwidth="8*" align="left"/>
43044 <colspec colwidth="6*" align="center"/>
43045 <colspec colwidth="6*" align="center"/>
43046 <colspec colwidth="6*" align="right"/>
43047 <tbody>
43048 <row>
43049 <entry><option>escape_string</option></entry>
43050 <entry>Use: <emphasis>appendfile</emphasis></entry>
43051 <entry>Type: <emphasis>string</emphasis></entry>
43052 <entry>Default: <emphasis>see description</emphasis></entry>
43053 </row>
43054 </tbody>
43055 </tgroup>
43056 </informaltable>
43057 <para>
43058 See <option>check_string</option> above.
43059 </para>
43060 <para>
43061 <indexterm role="option">
43062 <primary><option>file</option></primary>
43063 </indexterm>
43064 </para>
43065 <informaltable frame="all">
43066 <tgroup cols="4" colsep="0" rowsep="0">
43067 <colspec colwidth="8*" align="left"/>
43068 <colspec colwidth="6*" align="center"/>
43069 <colspec colwidth="6*" align="center"/>
43070 <colspec colwidth="6*" align="right"/>
43071 <tbody>
43072 <row>
43073 <entry><option>file</option></entry>
43074 <entry>Use: <emphasis>appendfile</emphasis></entry>
43075 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43076 <entry>Default: <emphasis>unset</emphasis></entry>
43077 </row>
43078 </tbody>
43079 </tgroup>
43080 </informaltable>
43081 <para>
43082 This option is mutually exclusive with the <option>directory</option> option, but one of
43083 <option>file</option> or <option>directory</option> must be set, unless the delivery is the direct result
43084 of a redirection (see section <xref linkend="SECTfildiropt"/>). The <option>file</option> option
43085 specifies a single file, to which the message is appended. One or more of
43086 <option>use_fcntl_lock</option>, <option>use_flock_lock</option>, or <option>use_lockfile</option> must be set with
43087 <option>file</option>.
43088 </para>
43089 <para>
43090 <indexterm role="concept">
43091 <primary>NFS</primary>
43092 <secondary>lock file</secondary>
43093 </indexterm>
43094 <indexterm role="concept">
43095 <primary>locking files</primary>
43096 </indexterm>
43097 <indexterm role="concept">
43098 <primary>lock files</primary>
43099 </indexterm>
43100 If you are using more than one host to deliver over NFS into the same
43101 mailboxes, you should always use lock files.
43102 </para>
43103 <para>
43104 The string value is expanded for each delivery, and must yield an absolute
43105 path. The most common settings of this option are variations on one of these
43106 examples:
43107 </para>
43108 <literallayout class="monospaced">
43109 file = /var/spool/mail/$local_part
43110 file = /home/$local_part/inbox
43111 file = $home/inbox
43112 </literallayout>
43113 <para>
43114 <indexterm role="concept">
43115 <primary><quote>sticky</quote> bit</primary>
43116 </indexterm>
43117 In the first example, all deliveries are done into the same directory. If Exim
43118 is configured to use lock files (see <option>use_lockfile</option> below) it must be able to
43119 create a file in the directory, so the <quote>sticky</quote> bit must be turned on for
43120 deliveries to be possible, or alternatively the <option>group</option> option can be used to
43121 run the delivery under a group id which has write access to the directory.
43122 </para>
43123 <para>
43124 <indexterm role="option">
43125 <primary><option>file_format</option></primary>
43126 </indexterm>
43127 </para>
43128 <informaltable frame="all">
43129 <tgroup cols="4" colsep="0" rowsep="0">
43130 <colspec colwidth="8*" align="left"/>
43131 <colspec colwidth="6*" align="center"/>
43132 <colspec colwidth="6*" align="center"/>
43133 <colspec colwidth="6*" align="right"/>
43134 <tbody>
43135 <row>
43136 <entry><option>file_format</option></entry>
43137 <entry>Use: <emphasis>appendfile</emphasis></entry>
43138 <entry>Type: <emphasis>string</emphasis></entry>
43139 <entry>Default: <emphasis>unset</emphasis></entry>
43140 </row>
43141 </tbody>
43142 </tgroup>
43143 </informaltable>
43144 <para>
43145 <indexterm role="concept">
43146 <primary>file</primary>
43147 <secondary>mailbox; checking existing format</secondary>
43148 </indexterm>
43149 This option requests the transport to check the format of an existing file
43150 before adding to it. The check consists of matching a specific string at the
43151 start of the file. The value of the option consists of an even number of
43152 colon-separated strings. The first of each pair is the test string, and the
43153 second is the name of a transport. If the transport associated with a matched
43154 string is not the current transport, control is passed over to the other
43155 transport. For example, suppose the standard <command>local_delivery</command> transport has
43156 this added to it:
43157 </para>
43158 <literallayout class="monospaced">
43159 file_format = "From       : local_delivery :\
43160                \1\1\1\1\n : local_mmdf_delivery"
43161 </literallayout>
43162 <para>
43163 Mailboxes that begin with <quote>From</quote> are still handled by this transport, but if
43164 a mailbox begins with four binary ones followed by a newline, control is passed
43165 to a transport called <option>local_mmdf_delivery</option>, which presumably is configured
43166 to do the delivery in MMDF format. If a mailbox does not exist or is empty, it
43167 is assumed to match the current transport. If the start of a mailbox doesn&#x2019;t
43168 match any string, or if the transport named for a given string is not defined,
43169 delivery is deferred.
43170 </para>
43171 <para>
43172 <indexterm role="option">
43173 <primary><option>file_must_exist</option></primary>
43174 </indexterm>
43175 </para>
43176 <informaltable frame="all">
43177 <tgroup cols="4" colsep="0" rowsep="0">
43178 <colspec colwidth="8*" align="left"/>
43179 <colspec colwidth="6*" align="center"/>
43180 <colspec colwidth="6*" align="center"/>
43181 <colspec colwidth="6*" align="right"/>
43182 <tbody>
43183 <row>
43184 <entry><option>file_must_exist</option></entry>
43185 <entry>Use: <emphasis>appendfile</emphasis></entry>
43186 <entry>Type: <emphasis>boolean</emphasis></entry>
43187 <entry>Default: <emphasis>false</emphasis></entry>
43188 </row>
43189 </tbody>
43190 </tgroup>
43191 </informaltable>
43192 <para>
43193 If this option is true, the file specified by the <option>file</option> option must exist.
43194 A temporary error occurs if it does not, causing delivery to be deferred.
43195 If this option is false, the file is created if it does not exist.
43196 </para>
43197 <para>
43198 <indexterm role="option">
43199 <primary><option>lock_fcntl_timeout</option></primary>
43200 </indexterm>
43201 </para>
43202 <informaltable frame="all">
43203 <tgroup cols="4" colsep="0" rowsep="0">
43204 <colspec colwidth="8*" align="left"/>
43205 <colspec colwidth="6*" align="center"/>
43206 <colspec colwidth="6*" align="center"/>
43207 <colspec colwidth="6*" align="right"/>
43208 <tbody>
43209 <row>
43210 <entry><option>lock_fcntl_timeout</option></entry>
43211 <entry>Use: <emphasis>appendfile</emphasis></entry>
43212 <entry>Type: <emphasis>time</emphasis></entry>
43213 <entry>Default: <emphasis>0s</emphasis></entry>
43214 </row>
43215 </tbody>
43216 </tgroup>
43217 </informaltable>
43218 <para>
43219 <indexterm role="concept">
43220 <primary>timeout</primary>
43221 <secondary>mailbox locking</secondary>
43222 </indexterm>
43223 <indexterm role="concept">
43224 <primary>mailbox</primary>
43225 <secondary>locking, blocking and non-blocking</secondary>
43226 </indexterm>
43227 <indexterm role="concept">
43228 <primary>locking files</primary>
43229 </indexterm>
43230 By default, the <command>appendfile</command> transport uses non-blocking calls to <function>fcntl()</function>
43231 when locking an open mailbox file. If the call fails, the delivery process
43232 sleeps for <option>lock_interval</option> and tries again, up to <option>lock_retries</option> times.
43233 Non-blocking calls are used so that the file is not kept open during the wait
43234 for the lock; the reason for this is to make it as safe as possible for
43235 deliveries over NFS in the case when processes might be accessing an NFS
43236 mailbox without using a lock file. This should not be done, but
43237 misunderstandings and hence misconfigurations are not unknown.
43238 </para>
43239 <para>
43240 On a busy system, however, the performance of a non-blocking lock approach is
43241 not as good as using a blocking lock with a timeout. In this case, the waiting
43242 is done inside the system call, and Exim&#x2019;s delivery process acquires the lock
43243 and can proceed as soon as the previous lock holder releases it.
43244 </para>
43245 <para>
43246 If <option>lock_fcntl_timeout</option> is set to a non-zero time, blocking locks, with that
43247 timeout, are used. There may still be some retrying: the maximum number of
43248 retries is
43249 </para>
43250 <literallayout class="monospaced">
43251 (lock_retries * lock_interval) / lock_fcntl_timeout
43252 </literallayout>
43253 <para>
43254 rounded up to the next whole number. In other words, the total time during
43255 which <command>appendfile</command> is trying to get a lock is roughly the same, unless
43256 <option>lock_fcntl_timeout</option> is set very large.
43257 </para>
43258 <para>
43259 You should consider setting this option if you are getting a lot of delayed
43260 local deliveries because of errors of the form
43261 </para>
43262 <literallayout class="monospaced">
43263 failed to lock mailbox /some/file (fcntl)
43264 </literallayout>
43265 <para>
43266 <indexterm role="option">
43267 <primary><option>lock_flock_timeout</option></primary>
43268 </indexterm>
43269 </para>
43270 <informaltable frame="all">
43271 <tgroup cols="4" colsep="0" rowsep="0">
43272 <colspec colwidth="8*" align="left"/>
43273 <colspec colwidth="6*" align="center"/>
43274 <colspec colwidth="6*" align="center"/>
43275 <colspec colwidth="6*" align="right"/>
43276 <tbody>
43277 <row>
43278 <entry><option>lock_flock_timeout</option></entry>
43279 <entry>Use: <emphasis>appendfile</emphasis></entry>
43280 <entry>Type: <emphasis>time</emphasis></entry>
43281 <entry>Default: <emphasis>0s</emphasis></entry>
43282 </row>
43283 </tbody>
43284 </tgroup>
43285 </informaltable>
43286 <para>
43287 This timeout applies to file locking when using <function>flock()</function> (see
43288 <option>use_flock</option>); the timeout operates in a similar manner to
43289 <option>lock_fcntl_timeout</option>.
43290 </para>
43291 <para>
43292 <indexterm role="option">
43293 <primary><option>lock_interval</option></primary>
43294 </indexterm>
43295 </para>
43296 <informaltable frame="all">
43297 <tgroup cols="4" colsep="0" rowsep="0">
43298 <colspec colwidth="8*" align="left"/>
43299 <colspec colwidth="6*" align="center"/>
43300 <colspec colwidth="6*" align="center"/>
43301 <colspec colwidth="6*" align="right"/>
43302 <tbody>
43303 <row>
43304 <entry><option>lock_interval</option></entry>
43305 <entry>Use: <emphasis>appendfile</emphasis></entry>
43306 <entry>Type: <emphasis>time</emphasis></entry>
43307 <entry>Default: <emphasis>3s</emphasis></entry>
43308 </row>
43309 </tbody>
43310 </tgroup>
43311 </informaltable>
43312 <para>
43313 This specifies the time to wait between attempts to lock the file. See below
43314 for details of locking.
43315 </para>
43316 <para>
43317 <indexterm role="option">
43318 <primary><option>lock_retries</option></primary>
43319 </indexterm>
43320 </para>
43321 <informaltable frame="all">
43322 <tgroup cols="4" colsep="0" rowsep="0">
43323 <colspec colwidth="8*" align="left"/>
43324 <colspec colwidth="6*" align="center"/>
43325 <colspec colwidth="6*" align="center"/>
43326 <colspec colwidth="6*" align="right"/>
43327 <tbody>
43328 <row>
43329 <entry><option>lock_retries</option></entry>
43330 <entry>Use: <emphasis>appendfile</emphasis></entry>
43331 <entry>Type: <emphasis>integer</emphasis></entry>
43332 <entry>Default: <emphasis>10</emphasis></entry>
43333 </row>
43334 </tbody>
43335 </tgroup>
43336 </informaltable>
43337 <para>
43338 This specifies the maximum number of attempts to lock the file. A value of zero
43339 is treated as 1. See below for details of locking.
43340 </para>
43341 <para>
43342 <indexterm role="option">
43343 <primary><option>lockfile_mode</option></primary>
43344 </indexterm>
43345 </para>
43346 <informaltable frame="all">
43347 <tgroup cols="4" colsep="0" rowsep="0">
43348 <colspec colwidth="8*" align="left"/>
43349 <colspec colwidth="6*" align="center"/>
43350 <colspec colwidth="6*" align="center"/>
43351 <colspec colwidth="6*" align="right"/>
43352 <tbody>
43353 <row>
43354 <entry><option>lockfile_mode</option></entry>
43355 <entry>Use: <emphasis>appendfile</emphasis></entry>
43356 <entry>Type: <emphasis>octal integer</emphasis></entry>
43357 <entry>Default: <emphasis>0600</emphasis></entry>
43358 </row>
43359 </tbody>
43360 </tgroup>
43361 </informaltable>
43362 <para>
43363 This specifies the mode of the created lock file, when a lock file is being
43364 used (see <option>use_lockfile</option> and <option>use_mbx_lock</option>).
43365 </para>
43366 <para>
43367 <indexterm role="option">
43368 <primary><option>lockfile_timeout</option></primary>
43369 </indexterm>
43370 </para>
43371 <informaltable frame="all">
43372 <tgroup cols="4" colsep="0" rowsep="0">
43373 <colspec colwidth="8*" align="left"/>
43374 <colspec colwidth="6*" align="center"/>
43375 <colspec colwidth="6*" align="center"/>
43376 <colspec colwidth="6*" align="right"/>
43377 <tbody>
43378 <row>
43379 <entry><option>lockfile_timeout</option></entry>
43380 <entry>Use: <emphasis>appendfile</emphasis></entry>
43381 <entry>Type: <emphasis>time</emphasis></entry>
43382 <entry>Default: <emphasis>30m</emphasis></entry>
43383 </row>
43384 </tbody>
43385 </tgroup>
43386 </informaltable>
43387 <para>
43388 <indexterm role="concept">
43389 <primary>timeout</primary>
43390 <secondary>mailbox locking</secondary>
43391 </indexterm>
43392 When a lock file is being used (see <option>use_lockfile</option>), if a lock file already
43393 exists and is older than this value, it is assumed to have been left behind by
43394 accident, and Exim attempts to remove it.
43395 </para>
43396 <para>
43397 <indexterm role="option">
43398 <primary><option>mailbox_filecount</option></primary>
43399 </indexterm>
43400 </para>
43401 <informaltable frame="all">
43402 <tgroup cols="4" colsep="0" rowsep="0">
43403 <colspec colwidth="8*" align="left"/>
43404 <colspec colwidth="6*" align="center"/>
43405 <colspec colwidth="6*" align="center"/>
43406 <colspec colwidth="6*" align="right"/>
43407 <tbody>
43408 <row>
43409 <entry><option>mailbox_filecount</option></entry>
43410 <entry>Use: <emphasis>appendfile</emphasis></entry>
43411 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43412 <entry>Default: <emphasis>unset</emphasis></entry>
43413 </row>
43414 </tbody>
43415 </tgroup>
43416 </informaltable>
43417 <para>
43418 <indexterm role="concept">
43419 <primary>mailbox</primary>
43420 <secondary>specifying size of</secondary>
43421 </indexterm>
43422 <indexterm role="concept">
43423 <primary>size</primary>
43424 <secondary>of mailbox</secondary>
43425 </indexterm>
43426 If this option is set, it is expanded, and the result is taken as the current
43427 number of files in the mailbox. It must be a decimal number, optionally
43428 followed by K or M. This provides a way of obtaining this information from an
43429 external source that maintains the data.
43430 </para>
43431 <para>
43432 <indexterm role="option">
43433 <primary><option>mailbox_size</option></primary>
43434 </indexterm>
43435 </para>
43436 <informaltable frame="all">
43437 <tgroup cols="4" colsep="0" rowsep="0">
43438 <colspec colwidth="8*" align="left"/>
43439 <colspec colwidth="6*" align="center"/>
43440 <colspec colwidth="6*" align="center"/>
43441 <colspec colwidth="6*" align="right"/>
43442 <tbody>
43443 <row>
43444 <entry><option>mailbox_size</option></entry>
43445 <entry>Use: <emphasis>appendfile</emphasis></entry>
43446 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43447 <entry>Default: <emphasis>unset</emphasis></entry>
43448 </row>
43449 </tbody>
43450 </tgroup>
43451 </informaltable>
43452 <para>
43453 <indexterm role="concept">
43454 <primary>mailbox</primary>
43455 <secondary>specifying size of</secondary>
43456 </indexterm>
43457 <indexterm role="concept">
43458 <primary>size</primary>
43459 <secondary>of mailbox</secondary>
43460 </indexterm>
43461 If this option is set, it is expanded, and the result is taken as the current
43462 size the mailbox. It must be a decimal number, optionally followed by K or M.
43463 This provides a way of obtaining this information from an external source that
43464 maintains the data. This is likely to be helpful for maildir deliveries where
43465 it is computationally expensive to compute the size of a mailbox.
43466 </para>
43467 <para>
43468 <indexterm role="option">
43469 <primary><option>maildir_format</option></primary>
43470 </indexterm>
43471 </para>
43472 <informaltable frame="all">
43473 <tgroup cols="4" colsep="0" rowsep="0">
43474 <colspec colwidth="8*" align="left"/>
43475 <colspec colwidth="6*" align="center"/>
43476 <colspec colwidth="6*" align="center"/>
43477 <colspec colwidth="6*" align="right"/>
43478 <tbody>
43479 <row>
43480 <entry><option>maildir_format</option></entry>
43481 <entry>Use: <emphasis>appendfile</emphasis></entry>
43482 <entry>Type: <emphasis>boolean</emphasis></entry>
43483 <entry>Default: <emphasis>false</emphasis></entry>
43484 </row>
43485 </tbody>
43486 </tgroup>
43487 </informaltable>
43488 <para>
43489 <indexterm role="concept">
43490 <primary>maildir format</primary>
43491 <secondary>specifying</secondary>
43492 </indexterm>
43493 If this option is set with the <option>directory</option> option, the delivery is into a new
43494 file, in the <quote>maildir</quote> format that is used by other mail software. When the
43495 transport is activated directly from a <command>redirect</command> router (for example, the
43496 <command>address_file</command> transport in the default configuration), setting
43497 <option>maildir_format</option> causes the path received from the router to be treated as a
43498 directory, whether or not it ends with <literal>/</literal>. This option is available only if
43499 SUPPORT_MAILDIR is present in <filename>Local/Makefile</filename>. See section
43500 <xref linkend="SECTmaildirdelivery"/> below for further details.
43501 </para>
43502 <para>
43503 <indexterm role="option">
43504 <primary><option>maildir_quota_directory_regex</option></primary>
43505 </indexterm>
43506 </para>
43507 <informaltable frame="all">
43508 <tgroup cols="4" colsep="0" rowsep="0">
43509 <colspec colwidth="8*" align="left"/>
43510 <colspec colwidth="6*" align="center"/>
43511 <colspec colwidth="6*" align="center"/>
43512 <colspec colwidth="6*" align="right"/>
43513 <tbody>
43514 <row>
43515 <entry><option>maildir_quota_directory_regex</option></entry>
43516 <entry>Use: <emphasis>appendfile</emphasis></entry>
43517 <entry>Type: <emphasis>string</emphasis></entry>
43518 <entry>Default: <emphasis>See below</emphasis></entry>
43519 </row>
43520 </tbody>
43521 </tgroup>
43522 </informaltable>
43523 <para>
43524 <indexterm role="concept">
43525 <primary>maildir format</primary>
43526 <secondary>quota; directories included in</secondary>
43527 </indexterm>
43528 <indexterm role="concept">
43529 <primary>quota</primary>
43530 <secondary>maildir; directories included in</secondary>
43531 </indexterm>
43532 This option is relevant only when <option>maildir_use_size_file</option> is set. It defines
43533 a regular expression for specifying directories, relative to the quota
43534 directory (see <option>quota_directory</option>), that should be included in the quota
43535 calculation. The default value is:
43536 </para>
43537 <literallayout class="monospaced">
43538 maildir_quota_directory_regex = ^(?:cur|new|\..*)$
43539 </literallayout>
43540 <para>
43541 This includes the <filename>cur</filename> and <filename>new</filename> directories, and any maildir++ folders
43542 (directories whose names begin with a dot). If you want to exclude the
43543 <filename>Trash</filename>
43544 folder from the count (as some sites do), you need to change this setting to
43545 </para>
43546 <literallayout class="monospaced">
43547 maildir_quota_directory_regex = ^(?:cur|new|\.(?!Trash).*)$
43548 </literallayout>
43549 <para>
43550 This uses a negative lookahead in the regular expression to exclude the
43551 directory whose name is <filename>.Trash</filename>. When a directory is excluded from quota
43552 calculations, quota processing is bypassed for any messages that are delivered
43553 directly into that directory.
43554 </para>
43555 <para>
43556 <indexterm role="option">
43557 <primary><option>maildir_retries</option></primary>
43558 </indexterm>
43559 </para>
43560 <informaltable frame="all">
43561 <tgroup cols="4" colsep="0" rowsep="0">
43562 <colspec colwidth="8*" align="left"/>
43563 <colspec colwidth="6*" align="center"/>
43564 <colspec colwidth="6*" align="center"/>
43565 <colspec colwidth="6*" align="right"/>
43566 <tbody>
43567 <row>
43568 <entry><option>maildir_retries</option></entry>
43569 <entry>Use: <emphasis>appendfile</emphasis></entry>
43570 <entry>Type: <emphasis>integer</emphasis></entry>
43571 <entry>Default: <emphasis>10</emphasis></entry>
43572 </row>
43573 </tbody>
43574 </tgroup>
43575 </informaltable>
43576 <para>
43577 This option specifies the number of times to retry when writing a file in
43578 <quote>maildir</quote> format. See section <xref linkend="SECTmaildirdelivery"/> below.
43579 </para>
43580 <para>
43581 <indexterm role="option">
43582 <primary><option>maildir_tag</option></primary>
43583 </indexterm>
43584 </para>
43585 <informaltable frame="all">
43586 <tgroup cols="4" colsep="0" rowsep="0">
43587 <colspec colwidth="8*" align="left"/>
43588 <colspec colwidth="6*" align="center"/>
43589 <colspec colwidth="6*" align="center"/>
43590 <colspec colwidth="6*" align="right"/>
43591 <tbody>
43592 <row>
43593 <entry><option>maildir_tag</option></entry>
43594 <entry>Use: <emphasis>appendfile</emphasis></entry>
43595 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43596 <entry>Default: <emphasis>unset</emphasis></entry>
43597 </row>
43598 </tbody>
43599 </tgroup>
43600 </informaltable>
43601 <para>
43602 This option applies only to deliveries in maildir format, and is described in
43603 section <xref linkend="SECTmaildirdelivery"/> below.
43604 </para>
43605 <para>
43606 <indexterm role="option">
43607 <primary><option>maildir_use_size_file</option></primary>
43608 </indexterm>
43609 </para>
43610 <informaltable frame="all">
43611 <tgroup cols="4" colsep="0" rowsep="0">
43612 <colspec colwidth="8*" align="left"/>
43613 <colspec colwidth="6*" align="center"/>
43614 <colspec colwidth="6*" align="center"/>
43615 <colspec colwidth="6*" align="right"/>
43616 <tbody>
43617 <row>
43618 <entry><option>maildir_use_size_file</option></entry>
43619 <entry>Use: <emphasis>appendfile</emphasis>&dagger;<emphasis></emphasis></entry>
43620 <entry>Type: <emphasis>boolean</emphasis></entry>
43621 <entry>Default: <emphasis>false</emphasis></entry>
43622 </row>
43623 </tbody>
43624 </tgroup>
43625 </informaltable>
43626 <para>
43627 <indexterm role="concept">
43628 <primary>maildir format</primary>
43629 <secondary><filename>maildirsize</filename> file</secondary>
43630 </indexterm>
43631 The result of string expansion for this option must be a valid boolean value.
43632 If it is true, it enables support for <filename>maildirsize</filename> files. Exim
43633 creates a <filename>maildirsize</filename> file in a maildir if one does not exist, taking the
43634 quota from the <option>quota</option> option of the transport. If <option>quota</option> is unset, the
43635 value is zero. See <option>maildir_quota_directory_regex</option> above and section
43636 <xref linkend="SECTmaildirdelivery"/> below for further details.
43637 </para>
43638 <para>
43639 <indexterm role="option">
43640 <primary><option>maildirfolder_create_regex</option></primary>
43641 </indexterm>
43642 </para>
43643 <informaltable frame="all">
43644 <tgroup cols="4" colsep="0" rowsep="0">
43645 <colspec colwidth="8*" align="left"/>
43646 <colspec colwidth="6*" align="center"/>
43647 <colspec colwidth="6*" align="center"/>
43648 <colspec colwidth="6*" align="right"/>
43649 <tbody>
43650 <row>
43651 <entry><option>maildirfolder_create_regex</option></entry>
43652 <entry>Use: <emphasis>appendfile</emphasis></entry>
43653 <entry>Type: <emphasis>string</emphasis></entry>
43654 <entry>Default: <emphasis>unset</emphasis></entry>
43655 </row>
43656 </tbody>
43657 </tgroup>
43658 </informaltable>
43659 <para>
43660 <indexterm role="concept">
43661 <primary>maildir format</primary>
43662 <secondary><filename>maildirfolder</filename> file</secondary>
43663 </indexterm>
43664 <indexterm role="concept">
43665 <primary><filename>maildirfolder</filename>, creating</primary>
43666 </indexterm>
43667 The value of this option is a regular expression. If it is unset, it has no
43668 effect. Otherwise, before a maildir delivery takes place, the pattern is
43669 matched against the name of the maildir directory, that is, the directory
43670 containing the <filename>new</filename> and <filename>tmp</filename> subdirectories that will be used for the
43671 delivery. If there is a match, Exim checks for the existence of a file called
43672 <filename>maildirfolder</filename> in the directory, and creates it if it does not exist.
43673 See section <xref linkend="SECTmaildirdelivery"/> for more details.
43674 </para>
43675 <para>
43676 <indexterm role="option">
43677 <primary><option>mailstore_format</option></primary>
43678 </indexterm>
43679 </para>
43680 <informaltable frame="all">
43681 <tgroup cols="4" colsep="0" rowsep="0">
43682 <colspec colwidth="8*" align="left"/>
43683 <colspec colwidth="6*" align="center"/>
43684 <colspec colwidth="6*" align="center"/>
43685 <colspec colwidth="6*" align="right"/>
43686 <tbody>
43687 <row>
43688 <entry><option>mailstore_format</option></entry>
43689 <entry>Use: <emphasis>appendfile</emphasis></entry>
43690 <entry>Type: <emphasis>boolean</emphasis></entry>
43691 <entry>Default: <emphasis>false</emphasis></entry>
43692 </row>
43693 </tbody>
43694 </tgroup>
43695 </informaltable>
43696 <para>
43697 <indexterm role="concept">
43698 <primary>mailstore format</primary>
43699 <secondary>specifying</secondary>
43700 </indexterm>
43701 If this option is set with the <option>directory</option> option, the delivery is into two
43702 new files in  <quote>mailstore</quote> format. The option is available only if
43703 SUPPORT_MAILSTORE is present in <filename>Local/Makefile</filename>. See section <xref linkend="SECTopdir"/>
43704 below for further details.
43705 </para>
43706 <para>
43707 <indexterm role="option">
43708 <primary><option>mailstore_prefix</option></primary>
43709 </indexterm>
43710 </para>
43711 <informaltable frame="all">
43712 <tgroup cols="4" colsep="0" rowsep="0">
43713 <colspec colwidth="8*" align="left"/>
43714 <colspec colwidth="6*" align="center"/>
43715 <colspec colwidth="6*" align="center"/>
43716 <colspec colwidth="6*" align="right"/>
43717 <tbody>
43718 <row>
43719 <entry><option>mailstore_prefix</option></entry>
43720 <entry>Use: <emphasis>appendfile</emphasis></entry>
43721 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43722 <entry>Default: <emphasis>unset</emphasis></entry>
43723 </row>
43724 </tbody>
43725 </tgroup>
43726 </informaltable>
43727 <para>
43728 This option applies only to deliveries in mailstore format, and is described in
43729 section <xref linkend="SECTopdir"/> below.
43730 </para>
43731 <para>
43732 <indexterm role="option">
43733 <primary><option>mailstore_suffix</option></primary>
43734 </indexterm>
43735 </para>
43736 <informaltable frame="all">
43737 <tgroup cols="4" colsep="0" rowsep="0">
43738 <colspec colwidth="8*" align="left"/>
43739 <colspec colwidth="6*" align="center"/>
43740 <colspec colwidth="6*" align="center"/>
43741 <colspec colwidth="6*" align="right"/>
43742 <tbody>
43743 <row>
43744 <entry><option>mailstore_suffix</option></entry>
43745 <entry>Use: <emphasis>appendfile</emphasis></entry>
43746 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43747 <entry>Default: <emphasis>unset</emphasis></entry>
43748 </row>
43749 </tbody>
43750 </tgroup>
43751 </informaltable>
43752 <para>
43753 This option applies only to deliveries in mailstore format, and is described in
43754 section <xref linkend="SECTopdir"/> below.
43755 </para>
43756 <para>
43757 <indexterm role="option">
43758 <primary><option>mbx_format</option></primary>
43759 </indexterm>
43760 </para>
43761 <informaltable frame="all">
43762 <tgroup cols="4" colsep="0" rowsep="0">
43763 <colspec colwidth="8*" align="left"/>
43764 <colspec colwidth="6*" align="center"/>
43765 <colspec colwidth="6*" align="center"/>
43766 <colspec colwidth="6*" align="right"/>
43767 <tbody>
43768 <row>
43769 <entry><option>mbx_format</option></entry>
43770 <entry>Use: <emphasis>appendfile</emphasis></entry>
43771 <entry>Type: <emphasis>boolean</emphasis></entry>
43772 <entry>Default: <emphasis>false</emphasis></entry>
43773 </row>
43774 </tbody>
43775 </tgroup>
43776 </informaltable>
43777 <para>
43778 <indexterm role="concept">
43779 <primary>locking files</primary>
43780 </indexterm>
43781 <indexterm role="concept">
43782 <primary>file</primary>
43783 <secondary>locking</secondary>
43784 </indexterm>
43785 <indexterm role="concept">
43786 <primary>file</primary>
43787 <secondary>MBX format</secondary>
43788 </indexterm>
43789 <indexterm role="concept">
43790 <primary>MBX format, specifying</primary>
43791 </indexterm>
43792 This option is available only if Exim has been compiled with SUPPORT_MBX
43793 set in <filename>Local/Makefile</filename>. If <option>mbx_format</option> is set with the <option>file</option> option,
43794 the message is appended to the mailbox file in MBX format instead of
43795 traditional Unix format. This format is supported by Pine4 and its associated
43796 IMAP and POP daemons, by means of the <emphasis>c-client</emphasis> library that they all use.
43797 </para>
43798 <para>
43799 <emphasis role="bold">Note</emphasis>: The <option>message_prefix</option> and <option>message_suffix</option> options are not
43800 automatically changed by the use of <option>mbx_format</option>. They should normally be set
43801 empty when using MBX format, so this option almost always appears in this
43802 combination:
43803 </para>
43804 <literallayout class="monospaced">
43805 mbx_format = true
43806 message_prefix =
43807 message_suffix =
43808 </literallayout>
43809 <para>
43810 If none of the locking options are mentioned in the configuration,
43811 <option>use_mbx_lock</option> is assumed and the other locking options default to false. It
43812 is possible to specify the other kinds of locking with <option>mbx_format</option>, but
43813 <option>use_fcntl_lock</option> and <option>use_mbx_lock</option> are mutually exclusive. MBX locking
43814 interworks with <emphasis>c-client</emphasis>, providing for shared access to the mailbox. It
43815 should not be used if any program that does not use this form of locking is
43816 going to access the mailbox, nor should it be used if the mailbox file is NFS
43817 mounted, because it works only when the mailbox is accessed from a single host.
43818 </para>
43819 <para>
43820 If you set <option>use_fcntl_lock</option> with an MBX-format mailbox, you cannot use
43821 the standard version of <emphasis>c-client</emphasis>, because as long as it has a mailbox open
43822 (this means for the whole of a Pine or IMAP session), Exim will not be able to
43823 append messages to it.
43824 </para>
43825 <para>
43826 <indexterm role="option">
43827 <primary><option>message_prefix</option></primary>
43828 </indexterm>
43829 </para>
43830 <informaltable frame="all">
43831 <tgroup cols="4" colsep="0" rowsep="0">
43832 <colspec colwidth="8*" align="left"/>
43833 <colspec colwidth="6*" align="center"/>
43834 <colspec colwidth="6*" align="center"/>
43835 <colspec colwidth="6*" align="right"/>
43836 <tbody>
43837 <row>
43838 <entry><option>message_prefix</option></entry>
43839 <entry>Use: <emphasis>appendfile</emphasis></entry>
43840 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43841 <entry>Default: <emphasis>see below</emphasis></entry>
43842 </row>
43843 </tbody>
43844 </tgroup>
43845 </informaltable>
43846 <para>
43847 <indexterm role="concept">
43848 <primary><quote>From</quote> line</primary>
43849 </indexterm>
43850 The string specified here is expanded and output at the start of every message.
43851 The default is unset unless <option>file</option> is specified and <option>use_bsmtp</option> is not set,
43852 in which case it is:
43853 </para>
43854 <literallayout class="monospaced">
43855 message_prefix = "From ${if def:return_path{$return_path}\
43856   {MAILER-DAEMON}} $tod_bsdinbox\n"
43857 </literallayout>
43858 <para>
43859 <emphasis role="bold">Note:</emphasis> If you set <option>use_crlf</option> true, you must change any occurrences of
43860 <literal>\n</literal> to <literal>\r\n</literal> in <option>message_prefix</option>.
43861 </para>
43862 <para>
43863 <indexterm role="option">
43864 <primary><option>message_suffix</option></primary>
43865 </indexterm>
43866 </para>
43867 <informaltable frame="all">
43868 <tgroup cols="4" colsep="0" rowsep="0">
43869 <colspec colwidth="8*" align="left"/>
43870 <colspec colwidth="6*" align="center"/>
43871 <colspec colwidth="6*" align="center"/>
43872 <colspec colwidth="6*" align="right"/>
43873 <tbody>
43874 <row>
43875 <entry><option>message_suffix</option></entry>
43876 <entry>Use: <emphasis>appendfile</emphasis></entry>
43877 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43878 <entry>Default: <emphasis>see below</emphasis></entry>
43879 </row>
43880 </tbody>
43881 </tgroup>
43882 </informaltable>
43883 <para>
43884 The string specified here is expanded and output at the end of every message.
43885 The default is unset unless <option>file</option> is specified and <option>use_bsmtp</option> is not set,
43886 in which case it is a single newline character. The suffix can be suppressed by
43887 setting
43888 </para>
43889 <literallayout class="monospaced">
43890 message_suffix =
43891 </literallayout>
43892 <para>
43893 <emphasis role="bold">Note:</emphasis> If you set <option>use_crlf</option> true, you must change any occurrences of
43894 <literal>\n</literal> to <literal>\r\n</literal> in <option>message_suffix</option>.
43895 </para>
43896 <para>
43897 <indexterm role="option">
43898 <primary><option>mode</option></primary>
43899 </indexterm>
43900 </para>
43901 <informaltable frame="all">
43902 <tgroup cols="4" colsep="0" rowsep="0">
43903 <colspec colwidth="8*" align="left"/>
43904 <colspec colwidth="6*" align="center"/>
43905 <colspec colwidth="6*" align="center"/>
43906 <colspec colwidth="6*" align="right"/>
43907 <tbody>
43908 <row>
43909 <entry><option>mode</option></entry>
43910 <entry>Use: <emphasis>appendfile</emphasis></entry>
43911 <entry>Type: <emphasis>octal integer</emphasis></entry>
43912 <entry>Default: <emphasis>0600</emphasis></entry>
43913 </row>
43914 </tbody>
43915 </tgroup>
43916 </informaltable>
43917 <para>
43918 If the output file is created, it is given this mode. If it already exists and
43919 has wider permissions, they are reduced to this mode. If it has narrower
43920 permissions, an error occurs unless <option>mode_fail_narrower</option> is false. However,
43921 if the delivery is the result of a <option>save</option> command in a filter file specifying
43922 a particular mode, the mode of the output file is always forced to take that
43923 value, and this option is ignored.
43924 </para>
43925 <para>
43926 <indexterm role="option">
43927 <primary><option>mode_fail_narrower</option></primary>
43928 </indexterm>
43929 </para>
43930 <informaltable frame="all">
43931 <tgroup cols="4" colsep="0" rowsep="0">
43932 <colspec colwidth="8*" align="left"/>
43933 <colspec colwidth="6*" align="center"/>
43934 <colspec colwidth="6*" align="center"/>
43935 <colspec colwidth="6*" align="right"/>
43936 <tbody>
43937 <row>
43938 <entry><option>mode_fail_narrower</option></entry>
43939 <entry>Use: <emphasis>appendfile</emphasis></entry>
43940 <entry>Type: <emphasis>boolean</emphasis></entry>
43941 <entry>Default: <emphasis>true</emphasis></entry>
43942 </row>
43943 </tbody>
43944 </tgroup>
43945 </informaltable>
43946 <para>
43947 This option applies in the case when an existing mailbox file has a narrower
43948 mode than that specified by the <option>mode</option> option. If <option>mode_fail_narrower</option> is
43949 true, the delivery is deferred (<quote>mailbox has the wrong mode</quote>); otherwise Exim
43950 continues with the delivery attempt, using the existing mode of the file.
43951 </para>
43952 <para>
43953 <indexterm role="option">
43954 <primary><option>notify_comsat</option></primary>
43955 </indexterm>
43956 </para>
43957 <informaltable frame="all">
43958 <tgroup cols="4" colsep="0" rowsep="0">
43959 <colspec colwidth="8*" align="left"/>
43960 <colspec colwidth="6*" align="center"/>
43961 <colspec colwidth="6*" align="center"/>
43962 <colspec colwidth="6*" align="right"/>
43963 <tbody>
43964 <row>
43965 <entry><option>notify_comsat</option></entry>
43966 <entry>Use: <emphasis>appendfile</emphasis></entry>
43967 <entry>Type: <emphasis>boolean</emphasis></entry>
43968 <entry>Default: <emphasis>false</emphasis></entry>
43969 </row>
43970 </tbody>
43971 </tgroup>
43972 </informaltable>
43973 <para>
43974 If this option is true, the <emphasis>comsat</emphasis> daemon is notified after every
43975 successful delivery to a user mailbox. This is the daemon that notifies logged
43976 on users about incoming mail.
43977 </para>
43978 <para>
43979 <indexterm role="option">
43980 <primary><option>quota</option></primary>
43981 </indexterm>
43982 </para>
43983 <informaltable frame="all">
43984 <tgroup cols="4" colsep="0" rowsep="0">
43985 <colspec colwidth="8*" align="left"/>
43986 <colspec colwidth="6*" align="center"/>
43987 <colspec colwidth="6*" align="center"/>
43988 <colspec colwidth="6*" align="right"/>
43989 <tbody>
43990 <row>
43991 <entry><option>quota</option></entry>
43992 <entry>Use: <emphasis>appendfile</emphasis></entry>
43993 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43994 <entry>Default: <emphasis>unset</emphasis></entry>
43995 </row>
43996 </tbody>
43997 </tgroup>
43998 </informaltable>
43999 <para>
44000 <indexterm role="concept">
44001 <primary>quota</primary>
44002 <secondary>imposed by Exim</secondary>
44003 </indexterm>
44004 This option imposes a limit on the size of the file to which Exim is appending,
44005 or to the total space used in the directory tree when the <option>directory</option> option
44006 is set. In the latter case, computation of the space used is expensive, because
44007 all the files in the directory (and any sub-directories) have to be
44008 individually inspected and their sizes summed. (See <option>quota_size_regex</option> and
44009 <option>maildir_use_size_file</option> for ways to avoid this in environments where users
44010 have no shell access to their mailboxes).
44011 </para>
44012 <para>
44013 As there is no interlock against two simultaneous deliveries into a
44014 multi-file mailbox, it is possible for the quota to be overrun in this case.
44015 For single-file mailboxes, of course, an interlock is a necessity.
44016 </para>
44017 <para>
44018 A file&#x2019;s size is taken as its <emphasis>used</emphasis> value. Because of blocking effects, this
44019 may be a lot less than the actual amount of disk space allocated to the file.
44020 If the sizes of a number of files are being added up, the rounding effect can
44021 become quite noticeable, especially on systems that have large block sizes.
44022 Nevertheless, it seems best to stick to the <emphasis>used</emphasis> figure, because this is
44023 the obvious value which users understand most easily.
44024 </para>
44025 <para>
44026 The value of the option is expanded, and must then be a numerical value
44027 (decimal point allowed), optionally followed by one of the letters K, M, or G,
44028 for kilobytes, megabytes, or gigabytes, optionally followed by a slash
44029 and further option modifiers. If Exim is running on a system with
44030 large file support (Linux and FreeBSD have this), mailboxes larger than 2G can
44031 be handled.
44032 </para>
44033 <para>
44034 The option modifier <option>no_check</option> can be used to force delivery even if the over
44035 quota condition is met. The quota gets updated as usual.
44036 </para>
44037 <para>
44038 <emphasis role="bold">Note</emphasis>: A value of zero is interpreted as <quote>no quota</quote>.
44039 </para>
44040 <para>
44041 The expansion happens while Exim is running as root, before it changes uid for
44042 the delivery. This means that files that are inaccessible to the end user can
44043 be used to hold quota values that are looked up in the expansion. When delivery
44044 fails because this quota is exceeded, the handling of the error is as for
44045 system quota failures.
44046 </para>
44047 <para>
44048 By default, Exim&#x2019;s quota checking mimics system quotas, and restricts the
44049 mailbox to the specified maximum size, though the value is not accurate to the
44050 last byte, owing to separator lines and additional headers that may get added
44051 during message delivery. When a mailbox is nearly full, large messages may get
44052 refused even though small ones are accepted, because the size of the current
44053 message is added to the quota when the check is made. This behaviour can be
44054 changed by setting <option>quota_is_inclusive</option> false. When this is done, the check
44055 for exceeding the quota does not include the current message. Thus, deliveries
44056 continue until the quota has been exceeded; thereafter, no further messages are
44057 delivered. See also <option>quota_warn_threshold</option>.
44058 </para>
44059 <para>
44060 <indexterm role="option">
44061 <primary><option>quota_directory</option></primary>
44062 </indexterm>
44063 </para>
44064 <informaltable frame="all">
44065 <tgroup cols="4" colsep="0" rowsep="0">
44066 <colspec colwidth="8*" align="left"/>
44067 <colspec colwidth="6*" align="center"/>
44068 <colspec colwidth="6*" align="center"/>
44069 <colspec colwidth="6*" align="right"/>
44070 <tbody>
44071 <row>
44072 <entry><option>quota_directory</option></entry>
44073 <entry>Use: <emphasis>appendfile</emphasis></entry>
44074 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
44075 <entry>Default: <emphasis>unset</emphasis></entry>
44076 </row>
44077 </tbody>
44078 </tgroup>
44079 </informaltable>
44080 <para>
44081 This option defines the directory to check for quota purposes when delivering
44082 into individual files. The default is the delivery directory, or, if a file
44083 called <filename>maildirfolder</filename> exists in a maildir directory, the parent of the
44084 delivery directory.
44085 </para>
44086 <para>
44087 <indexterm role="option">
44088 <primary><option>quota_filecount</option></primary>
44089 </indexterm>
44090 </para>
44091 <informaltable frame="all">
44092 <tgroup cols="4" colsep="0" rowsep="0">
44093 <colspec colwidth="8*" align="left"/>
44094 <colspec colwidth="6*" align="center"/>
44095 <colspec colwidth="6*" align="center"/>
44096 <colspec colwidth="6*" align="right"/>
44097 <tbody>
44098 <row>
44099 <entry><option>quota_filecount</option></entry>
44100 <entry>Use: <emphasis>appendfile</emphasis></entry>
44101 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
44102 <entry>Default: <emphasis>0</emphasis></entry>
44103 </row>
44104 </tbody>
44105 </tgroup>
44106 </informaltable>
44107 <para>
44108 This option applies when the <option>directory</option> option is set. It limits the total
44109 number of files in the directory (compare the inode limit in system quotas). It
44110 can only be used if <option>quota</option> is also set. The value is expanded; an expansion
44111 failure causes delivery to be deferred. A value of zero is interpreted as
44112 <quote>no quota</quote>.
44113 </para>
44114 <para>
44115 The option modifier <option>no_check</option> can be used to force delivery even if the over
44116 quota condition is met. The quota gets updated as usual.
44117 </para>
44118 <para>
44119 <indexterm role="option">
44120 <primary><option>quota_is_inclusive</option></primary>
44121 </indexterm>
44122 </para>
44123 <informaltable frame="all">
44124 <tgroup cols="4" colsep="0" rowsep="0">
44125 <colspec colwidth="8*" align="left"/>
44126 <colspec colwidth="6*" align="center"/>
44127 <colspec colwidth="6*" align="center"/>
44128 <colspec colwidth="6*" align="right"/>
44129 <tbody>
44130 <row>
44131 <entry><option>quota_is_inclusive</option></entry>
44132 <entry>Use: <emphasis>appendfile</emphasis></entry>
44133 <entry>Type: <emphasis>boolean</emphasis></entry>
44134 <entry>Default: <emphasis>true</emphasis></entry>
44135 </row>
44136 </tbody>
44137 </tgroup>
44138 </informaltable>
44139 <para>
44140 See <option>quota</option> above.
44141 </para>
44142 <para>
44143 <indexterm role="option">
44144 <primary><option>quota_size_regex</option></primary>
44145 </indexterm>
44146 </para>
44147 <informaltable frame="all">
44148 <tgroup cols="4" colsep="0" rowsep="0">
44149 <colspec colwidth="8*" align="left"/>
44150 <colspec colwidth="6*" align="center"/>
44151 <colspec colwidth="6*" align="center"/>
44152 <colspec colwidth="6*" align="right"/>
44153 <tbody>
44154 <row>
44155 <entry><option>quota_size_regex</option></entry>
44156 <entry>Use: <emphasis>appendfile</emphasis></entry>
44157 <entry>Type: <emphasis>string</emphasis></entry>
44158 <entry>Default: <emphasis>unset</emphasis></entry>
44159 </row>
44160 </tbody>
44161 </tgroup>
44162 </informaltable>
44163 <para>
44164 This option applies when one of the delivery modes that writes a separate file
44165 for each message is being used. When Exim wants to find the size of one of
44166 these files in order to test the quota, it first checks <option>quota_size_regex</option>.
44167 If this is set to a regular expression that matches the filename, and it
44168 captures one string, that string is interpreted as a representation of the
44169 file&#x2019;s size. The value of <option>quota_size_regex</option> is not expanded.
44170 </para>
44171 <para>
44172 This feature is useful only when users have no shell access to their mailboxes
44173 &ndash; otherwise they could defeat the quota simply by renaming the files. This
44174 facility can be used with maildir deliveries, by setting <option>maildir_tag</option> to add
44175 the file length to the filename. For example:
44176 </para>
44177 <literallayout class="monospaced">
44178 maildir_tag = ,S=$message_size
44179 quota_size_regex = ,S=(\d+)
44180 </literallayout>
44181 <para>
44182 An alternative to <varname>$message_size</varname> is <varname>$message_linecount</varname>, which contains the
44183 number of lines in the message.
44184 </para>
44185 <para>
44186 The regular expression should not assume that the length is at the end of the
44187 filename (even though <option>maildir_tag</option> puts it there) because maildir MUAs
44188 sometimes add other information onto the ends of message filenames.
44189 </para>
44190 <para>
44191 Section <xref linkend="SECID136"/> contains further information.
44192 </para>
44193 <para revisionflag="changed">
44194 This option should not be used when other message-handling software
44195 may duplicate messages by making hardlinks to the files.  When that is done Exim
44196 will count the message size once for each filename, in contrast with the actual
44197 disk usage.  When the option is not set, calculating total usage requires
44198 a system-call per file to get the size; the number of links is then available also
44199 as is used to adjust the effective size.
44200 </para>
44201 <para>
44202 <indexterm role="option">
44203 <primary><option>quota_warn_message</option></primary>
44204 </indexterm>
44205 </para>
44206 <informaltable frame="all">
44207 <tgroup cols="4" colsep="0" rowsep="0">
44208 <colspec colwidth="8*" align="left"/>
44209 <colspec colwidth="6*" align="center"/>
44210 <colspec colwidth="6*" align="center"/>
44211 <colspec colwidth="6*" align="right"/>
44212 <tbody>
44213 <row>
44214 <entry><option>quota_warn_message</option></entry>
44215 <entry>Use: <emphasis>appendfile</emphasis></entry>
44216 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
44217 <entry>Default: <emphasis>see below</emphasis></entry>
44218 </row>
44219 </tbody>
44220 </tgroup>
44221 </informaltable>
44222 <para>
44223 See below for the use of this option. If it is not set when
44224 <option>quota_warn_threshold</option> is set, it defaults to
44225 </para>
44226 <literallayout class="monospaced">
44227 quota_warn_message = "\
44228   To: $local_part@$domain\n\
44229   Subject: Your mailbox\n\n\
44230   This message is automatically created \
44231   by mail delivery software.\n\n\
44232   The size of your mailbox has exceeded \
44233   a warning threshold that is\n\
44234   set by the system administrator.\n"
44235 </literallayout>
44236 <para>
44237 <indexterm role="option">
44238 <primary><option>quota_warn_threshold</option></primary>
44239 </indexterm>
44240 </para>
44241 <informaltable frame="all">
44242 <tgroup cols="4" colsep="0" rowsep="0">
44243 <colspec colwidth="8*" align="left"/>
44244 <colspec colwidth="6*" align="center"/>
44245 <colspec colwidth="6*" align="center"/>
44246 <colspec colwidth="6*" align="right"/>
44247 <tbody>
44248 <row>
44249 <entry><option>quota_warn_threshold</option></entry>
44250 <entry>Use: <emphasis>appendfile</emphasis></entry>
44251 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
44252 <entry>Default: <emphasis>0</emphasis></entry>
44253 </row>
44254 </tbody>
44255 </tgroup>
44256 </informaltable>
44257 <para>
44258 <indexterm role="concept">
44259 <primary>quota</primary>
44260 <secondary>warning threshold</secondary>
44261 </indexterm>
44262 <indexterm role="concept">
44263 <primary>mailbox</primary>
44264 <secondary>size warning</secondary>
44265 </indexterm>
44266 <indexterm role="concept">
44267 <primary>size</primary>
44268 <secondary>of mailbox</secondary>
44269 </indexterm>
44270 This option is expanded in the same way as <option>quota</option> (see above). If the
44271 resulting value is greater than zero, and delivery of the message causes the
44272 size of the file or total space in the directory tree to cross the given
44273 threshold, a warning message is sent. If <option>quota</option> is also set, the threshold
44274 may be specified as a percentage of it by following the value with a percent
44275 sign. For example:
44276 </para>
44277 <literallayout class="monospaced">
44278 quota = 10M
44279 quota_warn_threshold = 75%
44280 </literallayout>
44281 <para>
44282 If <option>quota</option> is not set, a setting of <option>quota_warn_threshold</option> that ends with a
44283 percent sign is ignored.
44284 </para>
44285 <para>
44286 The warning message itself is specified by the <option>quota_warn_message</option> option,
44287 and it must start with a <emphasis>To:</emphasis> header line containing the recipient(s) of the
44288 warning message. These do not necessarily have to include the recipient(s) of
44289 the original message. A <emphasis>Subject:</emphasis> line should also normally be supplied. You
44290 can include any other header lines that you want. If you do not include a
44291 <emphasis>From:</emphasis> line, the default is:
44292 </para>
44293 <literallayout class="monospaced">
44294 From: Mail Delivery System &lt;mailer-daemon@$qualify_domain_sender&gt;
44295 </literallayout>
44296 <para>
44297 <indexterm role="option">
44298 <primary><option>errors_reply_to</option></primary>
44299 </indexterm>
44300 If you supply a <emphasis>Reply-To:</emphasis> line, it overrides the global <option>errors_reply_to</option>
44301 option.
44302 </para>
44303 <para>
44304 The <option>quota</option> option does not have to be set in order to use this option; they
44305 are independent of one another except when the threshold is specified as a
44306 percentage.
44307 </para>
44308 <para>
44309 <indexterm role="option">
44310 <primary><option>use_bsmtp</option></primary>
44311 </indexterm>
44312 </para>
44313 <informaltable frame="all">
44314 <tgroup cols="4" colsep="0" rowsep="0">
44315 <colspec colwidth="8*" align="left"/>
44316 <colspec colwidth="6*" align="center"/>
44317 <colspec colwidth="6*" align="center"/>
44318 <colspec colwidth="6*" align="right"/>
44319 <tbody>
44320 <row>
44321 <entry><option>use_bsmtp</option></entry>
44322 <entry>Use: <emphasis>appendfile</emphasis></entry>
44323 <entry>Type: <emphasis>boolean</emphasis></entry>
44324 <entry>Default: <emphasis>false</emphasis></entry>
44325 </row>
44326 </tbody>
44327 </tgroup>
44328 </informaltable>
44329 <para>
44330 <indexterm role="concept">
44331 <primary>envelope from</primary>
44332 </indexterm>
44333 <indexterm role="concept">
44334 <primary>envelope sender</primary>
44335 </indexterm>
44336 If this option is set true, <command>appendfile</command> writes messages in <quote>batch SMTP</quote>
44337 format, with the envelope sender and recipient(s) included as SMTP commands. If
44338 you want to include a leading HELO command with such messages, you can do
44339 so by setting the <option>message_prefix</option> option. See section <xref linkend="SECTbatchSMTP"/>
44340 for details of batch SMTP.
44341 </para>
44342 <para>
44343 <indexterm role="option">
44344 <primary><option>use_crlf</option></primary>
44345 </indexterm>
44346 </para>
44347 <informaltable frame="all">
44348 <tgroup cols="4" colsep="0" rowsep="0">
44349 <colspec colwidth="8*" align="left"/>
44350 <colspec colwidth="6*" align="center"/>
44351 <colspec colwidth="6*" align="center"/>
44352 <colspec colwidth="6*" align="right"/>
44353 <tbody>
44354 <row>
44355 <entry><option>use_crlf</option></entry>
44356 <entry>Use: <emphasis>appendfile</emphasis></entry>
44357 <entry>Type: <emphasis>boolean</emphasis></entry>
44358 <entry>Default: <emphasis>false</emphasis></entry>
44359 </row>
44360 </tbody>
44361 </tgroup>
44362 </informaltable>
44363 <para>
44364 <indexterm role="concept">
44365 <primary>carriage return</primary>
44366 </indexterm>
44367 <indexterm role="concept">
44368 <primary>linefeed</primary>
44369 </indexterm>
44370 This option causes lines to be terminated with the two-character CRLF sequence
44371 (carriage return, linefeed) instead of just a linefeed character. In the case
44372 of batched SMTP, the byte sequence written to the file is then an exact image
44373 of what would be sent down a real SMTP connection.
44374 </para>
44375 <para>
44376 <emphasis role="bold">Note:</emphasis> The contents of the <option>message_prefix</option> and <option>message_suffix</option> options
44377 (which are used to supply the traditional <quote>From&nbsp;</quote> and blank line separators
44378 in Berkeley-style mailboxes) are written verbatim, so must contain their own
44379 carriage return characters if these are needed. In cases where these options
44380 have non-empty defaults, the values end with a single linefeed, so they must be
44381 changed to end with <literal>\r\n</literal> if <option>use_crlf</option> is set.
44382 </para>
44383 <para>
44384 <indexterm role="option">
44385 <primary><option>use_fcntl_lock</option></primary>
44386 </indexterm>
44387 </para>
44388 <informaltable frame="all">
44389 <tgroup cols="4" colsep="0" rowsep="0">
44390 <colspec colwidth="8*" align="left"/>
44391 <colspec colwidth="6*" align="center"/>
44392 <colspec colwidth="6*" align="center"/>
44393 <colspec colwidth="6*" align="right"/>
44394 <tbody>
44395 <row>
44396 <entry><option>use_fcntl_lock</option></entry>
44397 <entry>Use: <emphasis>appendfile</emphasis></entry>
44398 <entry>Type: <emphasis>boolean</emphasis></entry>
44399 <entry>Default: <emphasis>see below</emphasis></entry>
44400 </row>
44401 </tbody>
44402 </tgroup>
44403 </informaltable>
44404 <para>
44405 This option controls the use of the <function>fcntl()</function> function to lock a file for
44406 exclusive use when a message is being appended. It is set by default unless
44407 <option>use_flock_lock</option> is set. Otherwise, it should be turned off only if you know
44408 that all your MUAs use lock file locking. When both <option>use_fcntl_lock</option> and
44409 <option>use_flock_lock</option> are unset, <option>use_lockfile</option> must be set.
44410 </para>
44411 <para>
44412 <indexterm role="option">
44413 <primary><option>use_flock_lock</option></primary>
44414 </indexterm>
44415 </para>
44416 <informaltable frame="all">
44417 <tgroup cols="4" colsep="0" rowsep="0">
44418 <colspec colwidth="8*" align="left"/>
44419 <colspec colwidth="6*" align="center"/>
44420 <colspec colwidth="6*" align="center"/>
44421 <colspec colwidth="6*" align="right"/>
44422 <tbody>
44423 <row>
44424 <entry><option>use_flock_lock</option></entry>
44425 <entry>Use: <emphasis>appendfile</emphasis></entry>
44426 <entry>Type: <emphasis>boolean</emphasis></entry>
44427 <entry>Default: <emphasis>false</emphasis></entry>
44428 </row>
44429 </tbody>
44430 </tgroup>
44431 </informaltable>
44432 <para>
44433 This option is provided to support the use of <function>flock()</function> for file locking, for
44434 the few situations where it is needed. Most modern operating systems support
44435 <function>fcntl()</function> and <function>lockf()</function> locking, and these two functions interwork with
44436 each other. Exim uses <function>fcntl()</function> locking by default.
44437 </para>
44438 <para>
44439 This option is required only if you are using an operating system where
44440 <function>flock()</function> is used by programs that access mailboxes (typically MUAs), and
44441 where <function>flock()</function> does not correctly interwork with <function>fcntl()</function>. You can use
44442 both <function>fcntl()</function> and <function>flock()</function> locking simultaneously if you want.
44443 </para>
44444 <para>
44445 <indexterm role="concept">
44446 <primary>Solaris</primary>
44447 <secondary><function>flock()</function> support</secondary>
44448 </indexterm>
44449 Not all operating systems provide <function>flock()</function>. Some versions of Solaris do not
44450 have it (and some, I think, provide a not quite right version built on top of
44451 <function>lockf()</function>). If the OS does not have <function>flock()</function>, Exim will be built without
44452 the ability to use it, and any attempt to do so will cause a configuration
44453 error.
44454 </para>
44455 <para>
44456 <emphasis role="bold">Warning</emphasis>: <function>flock()</function> locks do not work on NFS files (unless <function>flock()</function>
44457 is just being mapped onto <function>fcntl()</function> by the OS).
44458 </para>
44459 <para>
44460 <indexterm role="option">
44461 <primary><option>use_lockfile</option></primary>
44462 </indexterm>
44463 </para>
44464 <informaltable frame="all">
44465 <tgroup cols="4" colsep="0" rowsep="0">
44466 <colspec colwidth="8*" align="left"/>
44467 <colspec colwidth="6*" align="center"/>
44468 <colspec colwidth="6*" align="center"/>
44469 <colspec colwidth="6*" align="right"/>
44470 <tbody>
44471 <row>
44472 <entry><option>use_lockfile</option></entry>
44473 <entry>Use: <emphasis>appendfile</emphasis></entry>
44474 <entry>Type: <emphasis>boolean</emphasis></entry>
44475 <entry>Default: <emphasis>see below</emphasis></entry>
44476 </row>
44477 </tbody>
44478 </tgroup>
44479 </informaltable>
44480 <para>
44481 If this option is turned off, Exim does not attempt to create a lock file when
44482 appending to a mailbox file. In this situation, the only locking is by
44483 <function>fcntl()</function>. You should only turn <option>use_lockfile</option> off if you are absolutely
44484 sure that every MUA that is ever going to look at your users&#x2019; mailboxes uses
44485 <function>fcntl()</function> rather than a lock file, and even then only when you are not
44486 delivering over NFS from more than one host.
44487 </para>
44488 <para>
44489 <indexterm role="concept">
44490 <primary>NFS</primary>
44491 <secondary>lock file</secondary>
44492 </indexterm>
44493 In order to append to an NFS file safely from more than one host, it is
44494 necessary to take out a lock <emphasis>before</emphasis> opening the file, and the lock file
44495 achieves this. Otherwise, even with <function>fcntl()</function> locking, there is a risk of
44496 file corruption.
44497 </para>
44498 <para>
44499 The <option>use_lockfile</option> option is set by default unless <option>use_mbx_lock</option> is set.
44500 It is not possible to turn both <option>use_lockfile</option> and <option>use_fcntl_lock</option> off,
44501 except when <option>mbx_format</option> is set.
44502 </para>
44503 <para>
44504 <indexterm role="option">
44505 <primary><option>use_mbx_lock</option></primary>
44506 </indexterm>
44507 </para>
44508 <informaltable frame="all">
44509 <tgroup cols="4" colsep="0" rowsep="0">
44510 <colspec colwidth="8*" align="left"/>
44511 <colspec colwidth="6*" align="center"/>
44512 <colspec colwidth="6*" align="center"/>
44513 <colspec colwidth="6*" align="right"/>
44514 <tbody>
44515 <row>
44516 <entry><option>use_mbx_lock</option></entry>
44517 <entry>Use: <emphasis>appendfile</emphasis></entry>
44518 <entry>Type: <emphasis>boolean</emphasis></entry>
44519 <entry>Default: <emphasis>see below</emphasis></entry>
44520 </row>
44521 </tbody>
44522 </tgroup>
44523 </informaltable>
44524 <para>
44525 This option is available only if Exim has been compiled with SUPPORT_MBX
44526 set in <filename>Local/Makefile</filename>. Setting the option specifies that special MBX
44527 locking rules be used. It is set by default if <option>mbx_format</option> is set and none
44528 of the locking options are mentioned in the configuration. The locking rules
44529 are the same as are used by the <emphasis>c-client</emphasis> library that underlies Pine and
44530 the IMAP4 and POP daemons that come with it (see the discussion below). The
44531 rules allow for shared access to the mailbox. However, this kind of locking
44532 does not work when the mailbox is NFS mounted.
44533 </para>
44534 <para>
44535 You can set <option>use_mbx_lock</option> with either (or both) of <option>use_fcntl_lock</option> and
44536 <option>use_flock_lock</option> to control what kind of locking is used in implementing the
44537 MBX locking rules. The default is to use <function>fcntl()</function> if <option>use_mbx_lock</option> is set
44538 without <option>use_fcntl_lock</option> or <option>use_flock_lock</option>.
44539 </para>
44540 </section>
44541 <section id="SECTopappend">
44542 <title>Operational details for appending</title>
44543 <para>
44544 <indexterm role="concept">
44545 <primary>appending to a file</primary>
44546 </indexterm>
44547 <indexterm role="concept">
44548 <primary>file</primary>
44549 <secondary>appending</secondary>
44550 </indexterm>
44551 Before appending to a file, the following preparations are made:
44552 </para>
44553 <itemizedlist>
44554 <listitem>
44555 <para>
44556 If the name of the file is <filename>/dev/null</filename>, no action is taken, and a success
44557 return is given.
44558 </para>
44559 </listitem>
44560 <listitem>
44561 <para>
44562 <indexterm role="concept">
44563 <primary>directory creation</primary>
44564 </indexterm>
44565 If any directories on the file&#x2019;s path are missing, Exim creates them if the
44566 <option>create_directory</option> option is set. A created directory&#x2019;s mode is given by the
44567 <option>directory_mode</option> option.
44568 </para>
44569 </listitem>
44570 <listitem>
44571 <para>
44572 If <option>file_format</option> is set, the format of an existing file is checked. If this
44573 indicates that a different transport should be used, control is passed to that
44574 transport.
44575 </para>
44576 </listitem>
44577 <listitem>
44578 <para>
44579 <indexterm role="concept">
44580 <primary>file</primary>
44581 <secondary>locking</secondary>
44582 </indexterm>
44583 <indexterm role="concept">
44584 <primary>locking files</primary>
44585 </indexterm>
44586 <indexterm role="concept">
44587 <primary>NFS</primary>
44588 <secondary>lock file</secondary>
44589 </indexterm>
44590 If <option>use_lockfile</option> is set, a lock file is built in a way that will work
44591 reliably over NFS, as follows:
44592 </para>
44593 <orderedlist numeration="arabic">
44594 <listitem>
44595 <para>
44596 Create a <quote>hitching post</quote> file whose name is that of the lock file with the
44597 current time, primary host name, and process id added, by opening for writing
44598 as a new file. If this fails with an access error, delivery is deferred.
44599 </para>
44600 </listitem>
44601 <listitem>
44602 <para>
44603 Close the hitching post file, and hard link it to the lock filename.
44604 </para>
44605 </listitem>
44606 <listitem>
44607 <para>
44608 If the call to <function>link()</function> succeeds, creation of the lock file has succeeded.
44609 Unlink the hitching post name.
44610 </para>
44611 </listitem>
44612 <listitem>
44613 <para>
44614 Otherwise, use <function>stat()</function> to get information about the hitching post file, and
44615 then unlink hitching post name. If the number of links is exactly two, creation
44616 of the lock file succeeded but something (for example, an NFS server crash and
44617 restart) caused this fact not to be communicated to the <function>link()</function> call.
44618 </para>
44619 </listitem>
44620 <listitem>
44621 <para>
44622 If creation of the lock file failed, wait for <option>lock_interval</option> and try again,
44623 up to <option>lock_retries</option> times. However, since any program that writes to a
44624 mailbox should complete its task very quickly, it is reasonable to time out old
44625 lock files that are normally the result of user agent and system crashes. If an
44626 existing lock file is older than <option>lockfile_timeout</option> Exim attempts to unlink
44627 it before trying again.
44628 </para>
44629 </listitem>
44630 </orderedlist>
44631 </listitem>
44632 <listitem>
44633 <para>
44634 A call is made to <function>lstat()</function> to discover whether the main file exists, and if
44635 so, what its characteristics are. If <function>lstat()</function> fails for any reason other
44636 than non-existence, delivery is deferred.
44637 </para>
44638 </listitem>
44639 <listitem>
44640 <para>
44641 <indexterm role="concept">
44642 <primary>symbolic link</primary>
44643 <secondary>to mailbox</secondary>
44644 </indexterm>
44645 <indexterm role="concept">
44646 <primary>mailbox</primary>
44647 <secondary>symbolic link</secondary>
44648 </indexterm>
44649 If the file does exist and is a symbolic link, delivery is deferred, unless the
44650 <option>allow_symlink</option> option is set, in which case the ownership of the link is
44651 checked, and then <function>stat()</function> is called to find out about the real file, which
44652 is then subjected to the checks below. The check on the top-level link
44653 ownership prevents one user creating a link for another&#x2019;s mailbox in a sticky
44654 directory, though allowing symbolic links in this case is definitely not a good
44655 idea. If there is a chain of symbolic links, the intermediate ones are not
44656 checked.
44657 </para>
44658 </listitem>
44659 <listitem>
44660 <para>
44661 If the file already exists but is not a regular file, or if the file&#x2019;s owner
44662 and group (if the group is being checked &ndash; see <option>check_group</option> above) are
44663 different from the user and group under which the delivery is running,
44664 delivery is deferred.
44665 </para>
44666 </listitem>
44667 <listitem>
44668 <para>
44669 If the file&#x2019;s permissions are more generous than specified, they are reduced.
44670 If they are insufficient, delivery is deferred, unless <option>mode_fail_narrower</option>
44671 is set false, in which case the delivery is tried using the existing
44672 permissions.
44673 </para>
44674 </listitem>
44675 <listitem>
44676 <para>
44677 The file&#x2019;s inode number is saved, and the file is then opened for appending.
44678 If this fails because the file has vanished, <command>appendfile</command> behaves as if it
44679 hadn&#x2019;t existed (see below). For any other failures, delivery is deferred.
44680 </para>
44681 </listitem>
44682 <listitem>
44683 <para>
44684 If the file is opened successfully, check that the inode number hasn&#x2019;t
44685 changed, that it is still a regular file, and that the owner and permissions
44686 have not changed. If anything is wrong, defer delivery and freeze the message.
44687 </para>
44688 </listitem>
44689 <listitem>
44690 <para>
44691 If the file did not exist originally, defer delivery if the <option>file_must_exist</option>
44692 option is set. Otherwise, check that the file is being created in a permitted
44693 directory if the <option>create_file</option> option is set (deferring on failure), and then
44694 open for writing as a new file, with the O_EXCL and O_CREAT options,
44695 except when dealing with a symbolic link (the <option>allow_symlink</option> option must be
44696 set). In this case, which can happen if the link points to a non-existent file,
44697 the file is opened for writing using O_CREAT but not O_EXCL, because
44698 that prevents link following.
44699 </para>
44700 </listitem>
44701 <listitem>
44702 <para>
44703 <indexterm role="concept">
44704 <primary>loop</primary>
44705 <secondary>while file testing</secondary>
44706 </indexterm>
44707 If opening fails because the file exists, obey the tests given above for
44708 existing files. However, to avoid looping in a situation where the file is
44709 being continuously created and destroyed, the exists/not-exists loop is broken
44710 after 10 repetitions, and the message is then frozen.
44711 </para>
44712 </listitem>
44713 <listitem>
44714 <para>
44715 If opening fails with any other error, defer delivery.
44716 </para>
44717 </listitem>
44718 <listitem>
44719 <para>
44720 <indexterm role="concept">
44721 <primary>file</primary>
44722 <secondary>locking</secondary>
44723 </indexterm>
44724 <indexterm role="concept">
44725 <primary>locking files</primary>
44726 </indexterm>
44727 Once the file is open, unless both <option>use_fcntl_lock</option> and <option>use_flock_lock</option>
44728 are false, it is locked using <function>fcntl()</function> or <function>flock()</function> or both. If
44729 <option>use_mbx_lock</option> is false, an exclusive lock is requested in each case.
44730 However, if <option>use_mbx_lock</option> is true, Exim takes out a shared lock on the open
44731 file, and an exclusive lock on the file whose name is
44732 </para>
44733 <literallayout class="monospaced">
44734 /tmp/.&lt;device-number&gt;.&lt;inode-number&gt;
44735 </literallayout>
44736 <para>
44737 using the device and inode numbers of the open mailbox file, in accordance with
44738 the MBX locking rules. This file is created with a mode that is specified by
44739 the <option>lockfile_mode</option> option.
44740 </para>
44741 <para>
44742 If Exim fails to lock the file, there are two possible courses of action,
44743 depending on the value of the locking timeout. This is obtained from
44744 <option>lock_fcntl_timeout</option> or <option>lock_flock_timeout</option>, as appropriate.
44745 </para>
44746 <para>
44747 If the timeout value is zero, the file is closed, Exim waits for
44748 <option>lock_interval</option>, and then goes back and re-opens the file as above and tries
44749 to lock it again. This happens up to <option>lock_retries</option> times, after which the
44750 delivery is deferred.
44751 </para>
44752 <para>
44753 If the timeout has a value greater than zero, blocking calls to <function>fcntl()</function> or
44754 <function>flock()</function> are used (with the given timeout), so there has already been some
44755 waiting involved by the time locking fails. Nevertheless, Exim does not give up
44756 immediately. It retries up to
44757 </para>
44758 <literallayout class="monospaced">
44759 (lock_retries * lock_interval) / &lt;timeout&gt;
44760 </literallayout>
44761 <para>
44762 times (rounded up).
44763 </para>
44764 </listitem>
44765 </itemizedlist>
44766 <para>
44767 At the end of delivery, Exim closes the file (which releases the <function>fcntl()</function>
44768 and/or <function>flock()</function> locks) and then deletes the lock file if one was created.
44769 </para>
44770 </section>
44771 <section id="SECTopdir">
44772 <title>Operational details for delivery to a new file</title>
44773 <para>
44774 <indexterm role="concept">
44775 <primary>delivery</primary>
44776 <secondary>to single file</secondary>
44777 </indexterm>
44778 <indexterm role="concept">
44779 <primary><quote>From</quote> line</primary>
44780 </indexterm>
44781 When the <option>directory</option> option is set instead of <option>file</option>, each message is
44782 delivered into a newly-created file or set of files. When <command>appendfile</command> is
44783 activated directly from a <command>redirect</command> router, neither <option>file</option> nor
44784 <option>directory</option> is normally set, because the path for delivery is supplied by the
44785 router. (See for example, the <command>address_file</command> transport in the default
44786 configuration.) In this case, delivery is to a new file if either the path name
44787 ends in <literal>/</literal>, or the <option>maildir_format</option> or <option>mailstore_format</option> option is set.
44788 </para>
44789 <para>
44790 No locking is required while writing the message to a new file, so the various
44791 locking options of the transport are ignored. The <quote>From</quote> line that by default
44792 separates messages in a single file is not normally needed, nor is the escaping
44793 of message lines that start with <quote>From</quote>, and there is no need to ensure a
44794 newline at the end of each message. Consequently, the default values for
44795 <option>check_string</option>, <option>message_prefix</option>, and <option>message_suffix</option> are all unset when
44796 any of <option>directory</option>, <option>maildir_format</option>, or <option>mailstore_format</option> is set.
44797 </para>
44798 <para>
44799 If Exim is required to check a <option>quota</option> setting, it adds up the sizes of all
44800 the files in the delivery directory by default. However, you can specify a
44801 different directory by setting <option>quota_directory</option>. Also, for maildir
44802 deliveries (see below) the <filename>maildirfolder</filename> convention is honoured.
44803 </para>
44804 <para>
44805 <indexterm role="concept">
44806 <primary>maildir format</primary>
44807 </indexterm>
44808 <indexterm role="concept">
44809 <primary>mailstore format</primary>
44810 </indexterm>
44811 There are three different ways in which delivery to individual files can be
44812 done, controlled by the settings of the <option>maildir_format</option> and
44813 <option>mailstore_format</option> options. Note that code to support maildir or mailstore
44814 formats is not included in the binary unless SUPPORT_MAILDIR or
44815 SUPPORT_MAILSTORE, respectively, is set in <filename>Local/Makefile</filename>.
44816 </para>
44817 <para>
44818 <indexterm role="concept">
44819 <primary>directory creation</primary>
44820 </indexterm>
44821 In all three cases an attempt is made to create the directory and any necessary
44822 sub-directories if they do not exist, provided that the <option>create_directory</option>
44823 option is set (the default). The location of a created directory can be
44824 constrained by setting <option>create_file</option>. A created directory&#x2019;s mode is given by
44825 the <option>directory_mode</option> option. If creation fails, or if the
44826 <option>create_directory</option> option is not set when creation is required, delivery is
44827 deferred.
44828 </para>
44829 </section>
44830 <section id="SECTmaildirdelivery">
44831 <title>Maildir delivery</title>
44832 <para>
44833 <indexterm role="concept">
44834 <primary>maildir format</primary>
44835 <secondary>description of</secondary>
44836 </indexterm>
44837 If the <option>maildir_format</option> option is true, Exim delivers each message by writing
44838 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
44839 directory that is defined by the <option>directory</option> option (the <quote>delivery
44840 directory</quote>). If the delivery is successful, the file is renamed into the
44841 <filename>new</filename> subdirectory.
44842 </para>
44843 <para>
44844 In the filename, &lt;<emphasis>stime</emphasis>&gt; is the current time of day in seconds, and
44845 &lt;<emphasis>mtime</emphasis>&gt; is the microsecond fraction of the time. After a maildir delivery,
44846 Exim checks that the time-of-day clock has moved on by at least one microsecond
44847 before terminating the delivery process. This guarantees uniqueness for the
44848 filename. However, as a precaution, Exim calls <function>stat()</function> for the file before
44849 opening it. If any response other than ENOENT (does not exist) is given,
44850 Exim waits 2 seconds and tries again, up to <option>maildir_retries</option> times.
44851 </para>
44852 <para>
44853 Before Exim carries out a maildir delivery, it ensures that subdirectories
44854 called <filename>new</filename>, <filename>cur</filename>, and <filename>tmp</filename> exist in the delivery directory. If they
44855 do not exist, Exim tries to create them and any superior directories in their
44856 path, subject to the <option>create_directory</option> and <option>create_file</option> options. If the
44857 <option>maildirfolder_create_regex</option> option is set, and the regular expression it
44858 contains matches the delivery directory, Exim also ensures that a file called
44859 <filename>maildirfolder</filename> exists in the delivery directory. If a missing directory or
44860 <filename>maildirfolder</filename> file cannot be created, delivery is deferred.
44861 </para>
44862 <para>
44863 These features make it possible to use Exim to create all the necessary files
44864 and directories in a maildir mailbox, including subdirectories for maildir++
44865 folders. Consider this example:
44866 </para>
44867 <literallayout class="monospaced">
44868 maildir_format = true
44869 directory = /var/mail/$local_part\
44870            ${if eq{$local_part_suffix}{}{}\
44871            {/.${substr_1:$local_part_suffix}}}
44872 maildirfolder_create_regex = /\.[^/]+$
44873 </literallayout>
44874 <para>
44875 If <varname>$local_part_suffix</varname> is empty (there was no suffix for the local part),
44876 delivery is into a toplevel maildir with a name like <filename>/var/mail/pimbo</filename> (for
44877 the user called <emphasis>pimbo</emphasis>). The pattern in <option>maildirfolder_create_regex</option> does
44878 not match this name, so Exim will not look for or create the file
44879 <filename>/var/mail/pimbo/maildirfolder</filename>, though it will create
44880 <filename>/var/mail/pimbo/{cur,new,tmp}</filename> if necessary.
44881 </para>
44882 <para>
44883 However, if <varname>$local_part_suffix</varname> contains <literal>-eximusers</literal> (for example),
44884 delivery is into the maildir++ folder <filename>/var/mail/pimbo/.eximusers</filename>, which
44885 does match <option>maildirfolder_create_regex</option>. In this case, Exim will create
44886 <filename>/var/mail/pimbo/.eximusers/maildirfolder</filename> as well as the three maildir
44887 directories <filename>/var/mail/pimbo/.eximusers/{cur,new,tmp}</filename>.
44888 </para>
44889 <para>
44890 <emphasis role="bold">Warning:</emphasis> Take care when setting <option>maildirfolder_create_regex</option> that it does
44891 not inadvertently match the toplevel maildir directory, because a
44892 <filename>maildirfolder</filename> file at top level would completely break quota calculations.
44893 </para>
44894 <para>
44895 <indexterm role="concept">
44896 <primary>quota</primary>
44897 <secondary>in maildir delivery</secondary>
44898 </indexterm>
44899 <indexterm role="concept">
44900 <primary>maildir++</primary>
44901 </indexterm>
44902 If Exim is required to check a <option>quota</option> setting before a maildir delivery, and
44903 <option>quota_directory</option> is not set, it looks for a file called <filename>maildirfolder</filename> in
44904 the maildir directory (alongside <filename>new</filename>, <filename>cur</filename>, <filename>tmp</filename>). If this exists,
44905 Exim assumes the directory is a maildir++ folder directory, which is one level
44906 down from the user&#x2019;s top level mailbox directory. This causes it to start at
44907 the parent directory instead of the current directory when calculating the
44908 amount of space used.
44909 </para>
44910 <para>
44911 One problem with delivering into a multi-file mailbox is that it is
44912 computationally expensive to compute the size of the mailbox for quota
44913 checking. Various approaches have been taken to reduce the amount of work
44914 needed. The next two sections describe two of them. A third alternative is to
44915 use some external process for maintaining the size data, and use the expansion
44916 of the <option>mailbox_size</option> option as a way of importing it into Exim.
44917 </para>
44918 </section>
44919 <section id="SECID135">
44920 <title>Using tags to record message sizes</title>
44921 <para>
44922 If <option>maildir_tag</option> is set, the string is expanded for each delivery.
44923 When the maildir file is renamed into the <filename>new</filename> sub-directory, the
44924 tag is added to its name. However, if adding the tag takes the length of the
44925 name to the point where the test <function>stat()</function> call fails with ENAMETOOLONG,
44926 the tag is dropped and the maildir file is created with no tag.
44927 </para>
44928 <para>
44929 <indexterm role="variable">
44930 <primary><varname>$message_size</varname></primary>
44931 </indexterm>
44932 Tags can be used to encode the size of files in their names; see
44933 <option>quota_size_regex</option> above for an example. The expansion of <option>maildir_tag</option>
44934 happens after the message has been written. The value of the <varname>$message_size</varname>
44935 variable is set to the number of bytes actually written. If the expansion is
44936 forced to fail, the tag is ignored, but a non-forced failure causes delivery to
44937 be deferred. The expanded tag may contain any printing characters except <quote>/</quote>.
44938 Non-printing characters in the string are ignored; if the resulting string is
44939 empty, it is ignored. If it starts with an alphanumeric character, a leading
44940 colon is inserted; this default has not proven to be the path that popular
44941 maildir implementations have chosen (but changing it in Exim would break
44942 backwards compatibility).
44943 </para>
44944 <para>
44945 For one common implementation, you might set:
44946 </para>
44947 <literallayout class="monospaced">
44948 maildir_tag = ,S=${message_size}
44949 </literallayout>
44950 <para>
44951 but you should check the documentation of the other software to be sure.
44952 </para>
44953 <para>
44954 It is advisable to also set <option>quota_size_regex</option> when setting <option>maildir_tag</option>
44955 as this allows Exim to extract the size from your tag, instead of having to
44956 <function>stat()</function> each message file.
44957 </para>
44958 </section>
44959 <section id="SECID136">
44960 <title>Using a maildirsize file</title>
44961 <para>
44962 <indexterm role="concept">
44963 <primary>quota</primary>
44964 <secondary>in maildir delivery</secondary>
44965 </indexterm>
44966 <indexterm role="concept">
44967 <primary>maildir format</primary>
44968 <secondary><filename>maildirsize</filename> file</secondary>
44969 </indexterm>
44970 If <option>maildir_use_size_file</option> is true, Exim implements the maildir++ rules for
44971 storing quota and message size information in a file called <filename>maildirsize</filename>
44972 within the toplevel maildir directory. If this file does not exist, Exim
44973 creates it, setting the quota from the <option>quota</option> option of the transport. If
44974 the maildir directory itself does not exist, it is created before any attempt
44975 to write a <filename>maildirsize</filename> file.
44976 </para>
44977 <para>
44978 The <filename>maildirsize</filename> file is used to hold information about the sizes of
44979 messages in the maildir, thus speeding up quota calculations. The quota value
44980 in the file is just a cache; if the quota is changed in the transport, the new
44981 value overrides the cached value when the next message is delivered. The cache
44982 is maintained for the benefit of other programs that access the maildir and
44983 need to know the quota.
44984 </para>
44985 <para>
44986 If the <option>quota</option> option in the transport is unset or zero, the <filename>maildirsize</filename>
44987 file is maintained (with a zero quota setting), but no quota is imposed.
44988 </para>
44989 <para>
44990 A regular expression is available for controlling which directories in the
44991 maildir participate in quota calculations when a <filename>maildirsizefile</filename> is in use.
44992 See the description of the <option>maildir_quota_directory_regex</option> option above for
44993 details.
44994 </para>
44995 </section>
44996 <section id="SECID137">
44997 <title>Mailstore delivery</title>
44998 <para>
44999 <indexterm role="concept">
45000 <primary>mailstore format</primary>
45001 <secondary>description of</secondary>
45002 </indexterm>
45003 If the <option>mailstore_format</option> option is true, each message is written as two
45004 files in the given directory. A unique base name is constructed from the
45005 message id and the current delivery process, and the files that are written use
45006 this base name plus the suffixes <filename>.env</filename> and <filename>.msg</filename>. The <filename>.env</filename> file
45007 contains the message&#x2019;s envelope, and the <filename>.msg</filename> file contains the message
45008 itself. The base name is placed in the variable <varname>$mailstore_basename</varname>.
45009 </para>
45010 <para>
45011 During delivery, the envelope is first written to a file with the suffix
45012 <filename>.tmp</filename>. The <filename>.msg</filename> file is then written, and when it is complete, the
45013 <filename>.tmp</filename> file is renamed as the <filename>.env</filename> file. Programs that access messages in
45014 mailstore format should wait for the presence of both a <filename>.msg</filename> and a <filename>.env</filename>
45015 file before accessing either of them. An alternative approach is to wait for
45016 the absence of a <filename>.tmp</filename> file.
45017 </para>
45018 <para>
45019 The envelope file starts with any text defined by the <option>mailstore_prefix</option>
45020 option, expanded and terminated by a newline if there isn&#x2019;t one. Then follows
45021 the sender address on one line, then all the recipient addresses, one per line.
45022 There can be more than one recipient only if the <option>batch_max</option> option is set
45023 greater than one. Finally, <option>mailstore_suffix</option> is expanded and the result
45024 appended to the file, followed by a newline if it does not end with one.
45025 </para>
45026 <para>
45027 If expansion of <option>mailstore_prefix</option> or <option>mailstore_suffix</option> ends with a forced
45028 failure, it is ignored. Other expansion errors are treated as serious
45029 configuration errors, and delivery is deferred. The variable
45030 <varname>$mailstore_basename</varname> is available for use during these expansions.
45031 </para>
45032 </section>
45033 <section id="SECID138">
45034 <title>Non-special new file delivery</title>
45035 <para>
45036 If neither <option>maildir_format</option> nor <option>mailstore_format</option> is set, a single new
45037 file is created directly in the named directory. For example, when delivering
45038 messages into files in batched SMTP format for later delivery to some host (see
45039 section <xref linkend="SECTbatchSMTP"/>), a setting such as
45040 </para>
45041 <literallayout class="monospaced">
45042 directory = /var/bsmtp/$host
45043 </literallayout>
45044 <para>
45045 might be used. A message is written to a file with a temporary name, which is
45046 then renamed when the delivery is complete. The final name is obtained by
45047 expanding the contents of the <option>directory_file</option> option.
45048 <indexterm role="concept" startref="IIDapptra1" class="endofrange"/>
45049 <indexterm role="concept" startref="IIDapptra2" class="endofrange"/>
45050 </para>
45051 </section>
45052 </chapter>
45053
45054 <chapter id="CHID8">
45055 <title>The autoreply transport</title>
45056 <para>
45057 <indexterm role="concept" id="IIDauttra1" class="startofrange">
45058 <primary>transports</primary>
45059 <secondary><command>autoreply</command></secondary>
45060 </indexterm>
45061 <indexterm role="concept" id="IIDauttra2" class="startofrange">
45062 <primary><command>autoreply</command> transport</primary>
45063 </indexterm>
45064 The <command>autoreply</command> transport is not a true transport in that it does not cause
45065 the message to be transmitted. Instead, it generates a new mail message as an
45066 automatic reply to the incoming message. <emphasis>References:</emphasis> and
45067 <emphasis>Auto-Submitted:</emphasis> header lines are included. These are constructed according
45068 to the rules in RFCs 2822 and 3834, respectively.
45069 </para>
45070 <para>
45071 If the router that passes the message to this transport does not have the
45072 <option>unseen</option> option set, the original message (for the current recipient) is not
45073 delivered anywhere. However, when the <option>unseen</option> option is set on the router
45074 that passes the message to this transport, routing of the address continues, so
45075 another router can set up a normal message delivery.
45076 </para>
45077 <para>
45078 The <command>autoreply</command> transport is usually run as the result of mail filtering, a
45079 <quote>vacation</quote> message being the standard example. However, it can also be run
45080 directly from a router like any other transport. To reduce the possibility of
45081 message cascades, messages created by the <command>autoreply</command> transport always have
45082 empty envelope sender addresses, like bounce messages.
45083 </para>
45084 <para>
45085 The parameters of the message to be sent can be specified in the configuration
45086 by options described below. However, these are used only when the address
45087 passed to the transport does not contain its own reply information. When the
45088 transport is run as a consequence of a
45089 <option>mail</option>
45090 or <option>vacation</option> command in a filter file, the parameters of the message are
45091 supplied by the filter, and passed with the address. The transport&#x2019;s options
45092 that define the message are then ignored (so they are not usually set in this
45093 case). The message is specified entirely by the filter or by the transport; it
45094 is never built from a mixture of options. However, the <option>file_optional</option>,
45095 <option>mode</option>, and <option>return_message</option> options apply in all cases.
45096 </para>
45097 <para>
45098 <command>Autoreply</command> is implemented as a local transport. When used as a result of a
45099 command in a user&#x2019;s filter file, <command>autoreply</command> normally runs under the uid and
45100 gid of the user, and with appropriate current and home directories (see chapter
45101 <xref linkend="CHAPenvironment"/>).
45102 </para>
45103 <para>
45104 There is a subtle difference between routing a message to a <command>pipe</command> transport
45105 that generates some text to be returned to the sender, and routing it to an
45106 <command>autoreply</command> transport. This difference is noticeable only if more than one
45107 address from the same message is so handled. In the case of a pipe, the
45108 separate outputs from the different addresses are gathered up and returned to
45109 the sender in a single message, whereas if <command>autoreply</command> is used, a separate
45110 message is generated for each address that is passed to it.
45111 </para>
45112 <para>
45113 Non-printing characters are not permitted in the header lines generated for the
45114 message that <command>autoreply</command> creates, with the exception of newlines that are
45115 immediately followed by white space. If any non-printing characters are found,
45116 the transport defers.
45117 Whether characters with the top bit set count as printing characters or not is
45118 controlled by the <option>print_topbitchars</option> global option.
45119 </para>
45120 <para>
45121 If any of the generic options for manipulating headers (for example,
45122 <option>headers_add</option>) are set on an <command>autoreply</command> transport, they apply to the copy
45123 of the original message that is included in the generated message when
45124 <option>return_message</option> is set. They do not apply to the generated message itself.
45125 </para>
45126 <para>
45127 <indexterm role="variable">
45128 <primary><varname>$sender_address</varname></primary>
45129 </indexterm>
45130 If the <command>autoreply</command> transport receives return code 2 from Exim when it submits
45131 the message, indicating that there were no recipients, it does not treat this
45132 as an error. This means that autoreplies sent to <varname>$sender_address</varname> when this
45133 is empty (because the incoming message is a bounce message) do not cause
45134 problems. They are just discarded.
45135 </para>
45136 <section id="SECID139">
45137 <title>Private options for autoreply</title>
45138 <para>
45139 <indexterm role="concept">
45140 <primary>options</primary>
45141 <secondary><command>autoreply</command> transport</secondary>
45142 </indexterm>
45143 </para>
45144 <para>
45145 <indexterm role="option">
45146 <primary><option>bcc</option></primary>
45147 </indexterm>
45148 </para>
45149 <informaltable frame="all">
45150 <tgroup cols="4" colsep="0" rowsep="0">
45151 <colspec colwidth="8*" align="left"/>
45152 <colspec colwidth="6*" align="center"/>
45153 <colspec colwidth="6*" align="center"/>
45154 <colspec colwidth="6*" align="right"/>
45155 <tbody>
45156 <row>
45157 <entry><option>bcc</option></entry>
45158 <entry>Use: <emphasis>autoreply</emphasis></entry>
45159 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45160 <entry>Default: <emphasis>unset</emphasis></entry>
45161 </row>
45162 </tbody>
45163 </tgroup>
45164 </informaltable>
45165 <para>
45166 This specifies the addresses that are to receive <quote>blind carbon copies</quote> of the
45167 message when the message is specified by the transport.
45168 </para>
45169 <para>
45170 <indexterm role="option">
45171 <primary><option>cc</option></primary>
45172 </indexterm>
45173 </para>
45174 <informaltable frame="all">
45175 <tgroup cols="4" colsep="0" rowsep="0">
45176 <colspec colwidth="8*" align="left"/>
45177 <colspec colwidth="6*" align="center"/>
45178 <colspec colwidth="6*" align="center"/>
45179 <colspec colwidth="6*" align="right"/>
45180 <tbody>
45181 <row>
45182 <entry><option>cc</option></entry>
45183 <entry>Use: <emphasis>autoreply</emphasis></entry>
45184 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45185 <entry>Default: <emphasis>unset</emphasis></entry>
45186 </row>
45187 </tbody>
45188 </tgroup>
45189 </informaltable>
45190 <para>
45191 This specifies recipients of the message and the contents of the <emphasis>Cc:</emphasis> header
45192 when the message is specified by the transport.
45193 </para>
45194 <para>
45195 <indexterm role="option">
45196 <primary><option>file</option></primary>
45197 </indexterm>
45198 </para>
45199 <informaltable frame="all">
45200 <tgroup cols="4" colsep="0" rowsep="0">
45201 <colspec colwidth="8*" align="left"/>
45202 <colspec colwidth="6*" align="center"/>
45203 <colspec colwidth="6*" align="center"/>
45204 <colspec colwidth="6*" align="right"/>
45205 <tbody>
45206 <row>
45207 <entry><option>file</option></entry>
45208 <entry>Use: <emphasis>autoreply</emphasis></entry>
45209 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45210 <entry>Default: <emphasis>unset</emphasis></entry>
45211 </row>
45212 </tbody>
45213 </tgroup>
45214 </informaltable>
45215 <para>
45216 The contents of the file are sent as the body of the message when the message
45217 is specified by the transport. If both <option>file</option> and <option>text</option> are set, the text
45218 string comes first.
45219 </para>
45220 <para>
45221 <indexterm role="option">
45222 <primary><option>file_expand</option></primary>
45223 </indexterm>
45224 </para>
45225 <informaltable frame="all">
45226 <tgroup cols="4" colsep="0" rowsep="0">
45227 <colspec colwidth="8*" align="left"/>
45228 <colspec colwidth="6*" align="center"/>
45229 <colspec colwidth="6*" align="center"/>
45230 <colspec colwidth="6*" align="right"/>
45231 <tbody>
45232 <row>
45233 <entry><option>file_expand</option></entry>
45234 <entry>Use: <emphasis>autoreply</emphasis></entry>
45235 <entry>Type: <emphasis>boolean</emphasis></entry>
45236 <entry>Default: <emphasis>false</emphasis></entry>
45237 </row>
45238 </tbody>
45239 </tgroup>
45240 </informaltable>
45241 <para>
45242 If this is set, the contents of the file named by the <option>file</option> option are
45243 subjected to string expansion as they are added to the message.
45244 </para>
45245 <para>
45246 <indexterm role="option">
45247 <primary><option>file_optional</option></primary>
45248 </indexterm>
45249 </para>
45250 <informaltable frame="all">
45251 <tgroup cols="4" colsep="0" rowsep="0">
45252 <colspec colwidth="8*" align="left"/>
45253 <colspec colwidth="6*" align="center"/>
45254 <colspec colwidth="6*" align="center"/>
45255 <colspec colwidth="6*" align="right"/>
45256 <tbody>
45257 <row>
45258 <entry><option>file_optional</option></entry>
45259 <entry>Use: <emphasis>autoreply</emphasis></entry>
45260 <entry>Type: <emphasis>boolean</emphasis></entry>
45261 <entry>Default: <emphasis>false</emphasis></entry>
45262 </row>
45263 </tbody>
45264 </tgroup>
45265 </informaltable>
45266 <para>
45267 If this option is true, no error is generated if the file named by the <option>file</option>
45268 option or passed with the address does not exist or cannot be read.
45269 </para>
45270 <para>
45271 <indexterm role="option">
45272 <primary><option>from</option></primary>
45273 </indexterm>
45274 </para>
45275 <informaltable frame="all">
45276 <tgroup cols="4" colsep="0" rowsep="0">
45277 <colspec colwidth="8*" align="left"/>
45278 <colspec colwidth="6*" align="center"/>
45279 <colspec colwidth="6*" align="center"/>
45280 <colspec colwidth="6*" align="right"/>
45281 <tbody>
45282 <row>
45283 <entry><option>from</option></entry>
45284 <entry>Use: <emphasis>autoreply</emphasis></entry>
45285 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45286 <entry>Default: <emphasis>unset</emphasis></entry>
45287 </row>
45288 </tbody>
45289 </tgroup>
45290 </informaltable>
45291 <para>
45292 This specifies the contents of the <emphasis>From:</emphasis> header when the message is
45293 specified by the transport.
45294 </para>
45295 <para>
45296 <indexterm role="option">
45297 <primary><option>headers</option></primary>
45298 </indexterm>
45299 </para>
45300 <informaltable frame="all">
45301 <tgroup cols="4" colsep="0" rowsep="0">
45302 <colspec colwidth="8*" align="left"/>
45303 <colspec colwidth="6*" align="center"/>
45304 <colspec colwidth="6*" align="center"/>
45305 <colspec colwidth="6*" align="right"/>
45306 <tbody>
45307 <row>
45308 <entry><option>headers</option></entry>
45309 <entry>Use: <emphasis>autoreply</emphasis></entry>
45310 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45311 <entry>Default: <emphasis>unset</emphasis></entry>
45312 </row>
45313 </tbody>
45314 </tgroup>
45315 </informaltable>
45316 <para>
45317 This specifies additional RFC 2822 headers that are to be added to the message
45318 when the message is specified by the transport. Several can be given by using
45319 <quote>\n</quote> to separate them. There is no check on the format.
45320 </para>
45321 <para>
45322 <indexterm role="option">
45323 <primary><option>log</option></primary>
45324 </indexterm>
45325 </para>
45326 <informaltable frame="all">
45327 <tgroup cols="4" colsep="0" rowsep="0">
45328 <colspec colwidth="8*" align="left"/>
45329 <colspec colwidth="6*" align="center"/>
45330 <colspec colwidth="6*" align="center"/>
45331 <colspec colwidth="6*" align="right"/>
45332 <tbody>
45333 <row>
45334 <entry><option>log</option></entry>
45335 <entry>Use: <emphasis>autoreply</emphasis></entry>
45336 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45337 <entry>Default: <emphasis>unset</emphasis></entry>
45338 </row>
45339 </tbody>
45340 </tgroup>
45341 </informaltable>
45342 <para>
45343 This option names a file in which a record of every message sent is logged when
45344 the message is specified by the transport.
45345 </para>
45346 <para>
45347 <indexterm role="option">
45348 <primary><option>mode</option></primary>
45349 </indexterm>
45350 </para>
45351 <informaltable frame="all">
45352 <tgroup cols="4" colsep="0" rowsep="0">
45353 <colspec colwidth="8*" align="left"/>
45354 <colspec colwidth="6*" align="center"/>
45355 <colspec colwidth="6*" align="center"/>
45356 <colspec colwidth="6*" align="right"/>
45357 <tbody>
45358 <row>
45359 <entry><option>mode</option></entry>
45360 <entry>Use: <emphasis>autoreply</emphasis></entry>
45361 <entry>Type: <emphasis>octal integer</emphasis></entry>
45362 <entry>Default: <emphasis>0600</emphasis></entry>
45363 </row>
45364 </tbody>
45365 </tgroup>
45366 </informaltable>
45367 <para>
45368 If either the log file or the <quote>once</quote> file has to be created, this mode is
45369 used.
45370 </para>
45371 <para>
45372 <indexterm role="option">
45373 <primary><option>never_mail</option></primary>
45374 </indexterm>
45375 </para>
45376 <informaltable frame="all">
45377 <tgroup cols="4" colsep="0" rowsep="0">
45378 <colspec colwidth="8*" align="left"/>
45379 <colspec colwidth="6*" align="center"/>
45380 <colspec colwidth="6*" align="center"/>
45381 <colspec colwidth="6*" align="right"/>
45382 <tbody>
45383 <row>
45384 <entry><option>never_mail</option></entry>
45385 <entry>Use: <emphasis>autoreply</emphasis></entry>
45386 <entry>Type: <emphasis>address list</emphasis>&dagger;<emphasis></emphasis></entry>
45387 <entry>Default: <emphasis>unset</emphasis></entry>
45388 </row>
45389 </tbody>
45390 </tgroup>
45391 </informaltable>
45392 <para>
45393 If any run of the transport creates a message with a recipient that matches any
45394 item in the list, that recipient is quietly discarded. If all recipients are
45395 discarded, no message is created. This applies both when the recipients are
45396 generated by a filter and when they are specified in the transport.
45397 </para>
45398 <para>
45399 <indexterm role="option">
45400 <primary><option>once</option></primary>
45401 </indexterm>
45402 </para>
45403 <informaltable frame="all">
45404 <tgroup cols="4" colsep="0" rowsep="0">
45405 <colspec colwidth="8*" align="left"/>
45406 <colspec colwidth="6*" align="center"/>
45407 <colspec colwidth="6*" align="center"/>
45408 <colspec colwidth="6*" align="right"/>
45409 <tbody>
45410 <row>
45411 <entry><option>once</option></entry>
45412 <entry>Use: <emphasis>autoreply</emphasis></entry>
45413 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45414 <entry>Default: <emphasis>unset</emphasis></entry>
45415 </row>
45416 </tbody>
45417 </tgroup>
45418 </informaltable>
45419 <para>
45420 This option names a file or DBM database in which a record of each <emphasis>To:</emphasis>
45421 recipient is kept when the message is specified by the transport. <emphasis role="bold">Note</emphasis>:
45422 This does not apply to <emphasis>Cc:</emphasis> or <emphasis>Bcc:</emphasis> recipients.
45423 </para>
45424 <para>
45425 If <option>once</option> is unset, or is set to an empty string, the message is always sent.
45426 By default, if <option>once</option> is set to a non-empty filename, the message
45427 is not sent if a potential recipient is already listed in the database.
45428 However, if the <option>once_repeat</option> option specifies a time greater than zero, the
45429 message is sent if that much time has elapsed since a message was last sent to
45430 this recipient. A setting of zero time for <option>once_repeat</option> (the default)
45431 prevents a message from being sent a second time &ndash; in this case, zero means
45432 infinity.
45433 </para>
45434 <para>
45435 If <option>once_file_size</option> is zero, a DBM database is used to remember recipients,
45436 and it is allowed to grow as large as necessary. If <option>once_file_size</option> is set
45437 greater than zero, it changes the way Exim implements the <option>once</option> option.
45438 Instead of using a DBM file to record every recipient it sends to, it uses a
45439 regular file, whose size will never get larger than the given value.
45440 </para>
45441 <para>
45442 In the file, Exim keeps a linear list of recipient addresses and the times at
45443 which they were sent messages. If the file is full when a new address needs to
45444 be added, the oldest address is dropped. If <option>once_repeat</option> is not set, this
45445 means that a given recipient may receive multiple messages, but at
45446 unpredictable intervals that depend on the rate of turnover of addresses in the
45447 file. If <option>once_repeat</option> is set, it specifies a maximum time between repeats.
45448 </para>
45449 <para>
45450 <indexterm role="option">
45451 <primary><option>once_file_size</option></primary>
45452 </indexterm>
45453 </para>
45454 <informaltable frame="all">
45455 <tgroup cols="4" colsep="0" rowsep="0">
45456 <colspec colwidth="8*" align="left"/>
45457 <colspec colwidth="6*" align="center"/>
45458 <colspec colwidth="6*" align="center"/>
45459 <colspec colwidth="6*" align="right"/>
45460 <tbody>
45461 <row>
45462 <entry><option>once_file_size</option></entry>
45463 <entry>Use: <emphasis>autoreply</emphasis></entry>
45464 <entry>Type: <emphasis>integer</emphasis></entry>
45465 <entry>Default: <emphasis>0</emphasis></entry>
45466 </row>
45467 </tbody>
45468 </tgroup>
45469 </informaltable>
45470 <para>
45471 See <option>once</option> above.
45472 </para>
45473 <para>
45474 <indexterm role="option">
45475 <primary><option>once_repeat</option></primary>
45476 </indexterm>
45477 </para>
45478 <informaltable frame="all">
45479 <tgroup cols="4" colsep="0" rowsep="0">
45480 <colspec colwidth="8*" align="left"/>
45481 <colspec colwidth="6*" align="center"/>
45482 <colspec colwidth="6*" align="center"/>
45483 <colspec colwidth="6*" align="right"/>
45484 <tbody>
45485 <row>
45486 <entry><option>once_repeat</option></entry>
45487 <entry>Use: <emphasis>autoreply</emphasis></entry>
45488 <entry>Type: <emphasis>time</emphasis>&dagger;<emphasis></emphasis></entry>
45489 <entry>Default: <emphasis>0s</emphasis></entry>
45490 </row>
45491 </tbody>
45492 </tgroup>
45493 </informaltable>
45494 <para>
45495 See <option>once</option> above.
45496 After expansion, the value of this option must be a valid time value.
45497 </para>
45498 <para>
45499 <indexterm role="option">
45500 <primary><option>reply_to</option></primary>
45501 </indexterm>
45502 </para>
45503 <informaltable frame="all">
45504 <tgroup cols="4" colsep="0" rowsep="0">
45505 <colspec colwidth="8*" align="left"/>
45506 <colspec colwidth="6*" align="center"/>
45507 <colspec colwidth="6*" align="center"/>
45508 <colspec colwidth="6*" align="right"/>
45509 <tbody>
45510 <row>
45511 <entry><option>reply_to</option></entry>
45512 <entry>Use: <emphasis>autoreply</emphasis></entry>
45513 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45514 <entry>Default: <emphasis>unset</emphasis></entry>
45515 </row>
45516 </tbody>
45517 </tgroup>
45518 </informaltable>
45519 <para>
45520 This specifies the contents of the <emphasis>Reply-To:</emphasis> header when the message is
45521 specified by the transport.
45522 </para>
45523 <para>
45524 <indexterm role="option">
45525 <primary><option>return_message</option></primary>
45526 </indexterm>
45527 </para>
45528 <informaltable frame="all">
45529 <tgroup cols="4" colsep="0" rowsep="0">
45530 <colspec colwidth="8*" align="left"/>
45531 <colspec colwidth="6*" align="center"/>
45532 <colspec colwidth="6*" align="center"/>
45533 <colspec colwidth="6*" align="right"/>
45534 <tbody>
45535 <row>
45536 <entry><option>return_message</option></entry>
45537 <entry>Use: <emphasis>autoreply</emphasis></entry>
45538 <entry>Type: <emphasis>boolean</emphasis></entry>
45539 <entry>Default: <emphasis>false</emphasis></entry>
45540 </row>
45541 </tbody>
45542 </tgroup>
45543 </informaltable>
45544 <para>
45545 If this is set, a copy of the original message is returned with the new
45546 message, subject to the maximum size set in the <option>return_size_limit</option> global
45547 configuration option.
45548 </para>
45549 <para>
45550 <indexterm role="option">
45551 <primary><option>subject</option></primary>
45552 </indexterm>
45553 </para>
45554 <informaltable frame="all">
45555 <tgroup cols="4" colsep="0" rowsep="0">
45556 <colspec colwidth="8*" align="left"/>
45557 <colspec colwidth="6*" align="center"/>
45558 <colspec colwidth="6*" align="center"/>
45559 <colspec colwidth="6*" align="right"/>
45560 <tbody>
45561 <row>
45562 <entry><option>subject</option></entry>
45563 <entry>Use: <emphasis>autoreply</emphasis></entry>
45564 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45565 <entry>Default: <emphasis>unset</emphasis></entry>
45566 </row>
45567 </tbody>
45568 </tgroup>
45569 </informaltable>
45570 <para>
45571 This specifies the contents of the <emphasis>Subject:</emphasis> header when the message is
45572 specified by the transport. It is tempting to quote the original subject in
45573 automatic responses. For example:
45574 </para>
45575 <literallayout class="monospaced">
45576 subject = Re: $h_subject:
45577 </literallayout>
45578 <para>
45579 There is a danger in doing this, however. It may allow a third party to
45580 subscribe your users to an opt-in mailing list, provided that the list accepts
45581 bounce messages as subscription confirmations. Well-managed lists require a
45582 non-bounce message to confirm a subscription, so the danger is relatively
45583 small.
45584 </para>
45585 <para>
45586 <indexterm role="option">
45587 <primary><option>text</option></primary>
45588 </indexterm>
45589 </para>
45590 <informaltable frame="all">
45591 <tgroup cols="4" colsep="0" rowsep="0">
45592 <colspec colwidth="8*" align="left"/>
45593 <colspec colwidth="6*" align="center"/>
45594 <colspec colwidth="6*" align="center"/>
45595 <colspec colwidth="6*" align="right"/>
45596 <tbody>
45597 <row>
45598 <entry><option>text</option></entry>
45599 <entry>Use: <emphasis>autoreply</emphasis></entry>
45600 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45601 <entry>Default: <emphasis>unset</emphasis></entry>
45602 </row>
45603 </tbody>
45604 </tgroup>
45605 </informaltable>
45606 <para>
45607 This specifies a single string to be used as the body of the message when the
45608 message is specified by the transport. If both <option>text</option> and <option>file</option> are set,
45609 the text comes first.
45610 </para>
45611 <para>
45612 <indexterm role="option">
45613 <primary><option>to</option></primary>
45614 </indexterm>
45615 </para>
45616 <informaltable frame="all">
45617 <tgroup cols="4" colsep="0" rowsep="0">
45618 <colspec colwidth="8*" align="left"/>
45619 <colspec colwidth="6*" align="center"/>
45620 <colspec colwidth="6*" align="center"/>
45621 <colspec colwidth="6*" align="right"/>
45622 <tbody>
45623 <row>
45624 <entry><option>to</option></entry>
45625 <entry>Use: <emphasis>autoreply</emphasis></entry>
45626 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45627 <entry>Default: <emphasis>unset</emphasis></entry>
45628 </row>
45629 </tbody>
45630 </tgroup>
45631 </informaltable>
45632 <para>
45633 This specifies recipients of the message and the contents of the <emphasis>To:</emphasis> header
45634 when the message is specified by the transport.
45635 <indexterm role="concept" startref="IIDauttra1" class="endofrange"/>
45636 <indexterm role="concept" startref="IIDauttra2" class="endofrange"/>
45637 </para>
45638 </section>
45639 </chapter>
45640
45641 <chapter id="CHAPLMTP">
45642 <title>The lmtp transport</title>
45643 <para>
45644 <indexterm role="concept">
45645 <primary>transports</primary>
45646 <secondary><command>lmtp</command></secondary>
45647 </indexterm>
45648 <indexterm role="concept">
45649 <primary><command>lmtp</command> transport</primary>
45650 </indexterm>
45651 <indexterm role="concept">
45652 <primary>LMTP</primary>
45653 <secondary>over a pipe</secondary>
45654 </indexterm>
45655 <indexterm role="concept">
45656 <primary>LMTP</primary>
45657 <secondary>over a socket</secondary>
45658 </indexterm>
45659 The <command>lmtp</command> transport runs the LMTP protocol (RFC 2033) over a pipe to a
45660 specified command
45661 or by interacting with a Unix domain socket.
45662 This transport is something of a cross between the <command>pipe</command> and <command>smtp</command>
45663 transports. Exim also has support for using LMTP over TCP/IP; this is
45664 implemented as an option for the <command>smtp</command> transport. Because LMTP is expected
45665 to be of minority interest, the default build-time configure in <filename>src/EDITME</filename>
45666 has it commented out. You need to ensure that
45667 </para>
45668 <literallayout class="monospaced">
45669 TRANSPORT_LMTP=yes
45670 </literallayout>
45671 <para>
45672 <indexterm role="concept">
45673 <primary>options</primary>
45674 <secondary><command>lmtp</command> transport</secondary>
45675 </indexterm>
45676 is present in your <filename>Local/Makefile</filename> in order to have the <command>lmtp</command> transport
45677 included in the Exim binary. The private options of the <command>lmtp</command> transport are
45678 as follows:
45679 </para>
45680 <para>
45681 <indexterm role="option">
45682 <primary><option>batch_id</option></primary>
45683 </indexterm>
45684 </para>
45685 <informaltable frame="all">
45686 <tgroup cols="4" colsep="0" rowsep="0">
45687 <colspec colwidth="8*" align="left"/>
45688 <colspec colwidth="6*" align="center"/>
45689 <colspec colwidth="6*" align="center"/>
45690 <colspec colwidth="6*" align="right"/>
45691 <tbody>
45692 <row>
45693 <entry><option>batch_id</option></entry>
45694 <entry>Use: <emphasis>lmtp</emphasis></entry>
45695 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45696 <entry>Default: <emphasis>unset</emphasis></entry>
45697 </row>
45698 </tbody>
45699 </tgroup>
45700 </informaltable>
45701 <para>
45702 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
45703 </para>
45704 <para>
45705 <indexterm role="option">
45706 <primary><option>batch_max</option></primary>
45707 </indexterm>
45708 </para>
45709 <informaltable frame="all">
45710 <tgroup cols="4" colsep="0" rowsep="0">
45711 <colspec colwidth="8*" align="left"/>
45712 <colspec colwidth="6*" align="center"/>
45713 <colspec colwidth="6*" align="center"/>
45714 <colspec colwidth="6*" align="right"/>
45715 <tbody>
45716 <row>
45717 <entry><option>batch_max</option></entry>
45718 <entry>Use: <emphasis>lmtp</emphasis></entry>
45719 <entry>Type: <emphasis>integer</emphasis></entry>
45720 <entry>Default: <emphasis>1</emphasis></entry>
45721 </row>
45722 </tbody>
45723 </tgroup>
45724 </informaltable>
45725 <para>
45726 This limits the number of addresses that can be handled in a single delivery.
45727 Most LMTP servers can handle several addresses at once, so it is normally a
45728 good idea to increase this value. See the description of local delivery
45729 batching in chapter <xref linkend="CHAPbatching"/>.
45730 </para>
45731 <para>
45732 <indexterm role="option">
45733 <primary><option>command</option></primary>
45734 </indexterm>
45735 </para>
45736 <informaltable frame="all">
45737 <tgroup cols="4" colsep="0" rowsep="0">
45738 <colspec colwidth="8*" align="left"/>
45739 <colspec colwidth="6*" align="center"/>
45740 <colspec colwidth="6*" align="center"/>
45741 <colspec colwidth="6*" align="right"/>
45742 <tbody>
45743 <row>
45744 <entry><option>command</option></entry>
45745 <entry>Use: <emphasis>lmtp</emphasis></entry>
45746 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45747 <entry>Default: <emphasis>unset</emphasis></entry>
45748 </row>
45749 </tbody>
45750 </tgroup>
45751 </informaltable>
45752 <para>
45753 This option must be set if <option>socket</option> is not set. The string is a command which
45754 is run in a separate process. It is split up into a command name and list of
45755 arguments, each of which is separately expanded (so expansion cannot change the
45756 number of arguments). The command is run directly, not via a shell. The message
45757 is passed to the new process using the standard input and output to operate the
45758 LMTP protocol.
45759 </para>
45760 <para>
45761 <indexterm role="option">
45762 <primary><option>ignore_quota</option></primary>
45763 </indexterm>
45764 </para>
45765 <informaltable frame="all">
45766 <tgroup cols="4" colsep="0" rowsep="0">
45767 <colspec colwidth="8*" align="left"/>
45768 <colspec colwidth="6*" align="center"/>
45769 <colspec colwidth="6*" align="center"/>
45770 <colspec colwidth="6*" align="right"/>
45771 <tbody>
45772 <row>
45773 <entry><option>ignore_quota</option></entry>
45774 <entry>Use: <emphasis>lmtp</emphasis></entry>
45775 <entry>Type: <emphasis>boolean</emphasis></entry>
45776 <entry>Default: <emphasis>false</emphasis></entry>
45777 </row>
45778 </tbody>
45779 </tgroup>
45780 </informaltable>
45781 <para>
45782 <indexterm role="concept">
45783 <primary>LMTP</primary>
45784 <secondary>ignoring quota errors</secondary>
45785 </indexterm>
45786 If this option is set true, the string <literal>IGNOREQUOTA</literal> is added to RCPT
45787 commands, provided that the LMTP server has advertised support for IGNOREQUOTA
45788 in its response to the LHLO command.
45789 </para>
45790 <para>
45791 <indexterm role="option">
45792 <primary><option>socket</option></primary>
45793 </indexterm>
45794 </para>
45795 <informaltable frame="all">
45796 <tgroup cols="4" colsep="0" rowsep="0">
45797 <colspec colwidth="8*" align="left"/>
45798 <colspec colwidth="6*" align="center"/>
45799 <colspec colwidth="6*" align="center"/>
45800 <colspec colwidth="6*" align="right"/>
45801 <tbody>
45802 <row>
45803 <entry><option>socket</option></entry>
45804 <entry>Use: <emphasis>lmtp</emphasis></entry>
45805 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45806 <entry>Default: <emphasis>unset</emphasis></entry>
45807 </row>
45808 </tbody>
45809 </tgroup>
45810 </informaltable>
45811 <para>
45812 This option must be set if <option>command</option> is not set. The result of expansion must
45813 be the name of a Unix domain socket. The transport connects to the socket and
45814 delivers the message to it using the LMTP protocol.
45815 </para>
45816 <para>
45817 <indexterm role="option">
45818 <primary><option>timeout</option></primary>
45819 </indexterm>
45820 </para>
45821 <informaltable frame="all">
45822 <tgroup cols="4" colsep="0" rowsep="0">
45823 <colspec colwidth="8*" align="left"/>
45824 <colspec colwidth="6*" align="center"/>
45825 <colspec colwidth="6*" align="center"/>
45826 <colspec colwidth="6*" align="right"/>
45827 <tbody>
45828 <row>
45829 <entry><option>timeout</option></entry>
45830 <entry>Use: <emphasis>lmtp</emphasis></entry>
45831 <entry>Type: <emphasis>time</emphasis></entry>
45832 <entry>Default: <emphasis>5m</emphasis></entry>
45833 </row>
45834 </tbody>
45835 </tgroup>
45836 </informaltable>
45837 <para>
45838 The transport is aborted if the created process or Unix domain socket does not
45839 respond to LMTP commands or message input within this timeout. Delivery
45840 is deferred, and will be tried again later. Here is an example of a typical
45841 LMTP transport:
45842 </para>
45843 <literallayout class="monospaced">
45844 lmtp:
45845   driver = lmtp
45846   command = /some/local/lmtp/delivery/program
45847   batch_max = 20
45848   user = exim
45849 </literallayout>
45850 <para>
45851 This delivers up to 20 addresses at a time, in a mixture of domains if
45852 necessary, running as the user <emphasis>exim</emphasis>.
45853 </para>
45854 </chapter>
45855
45856 <chapter id="CHAPpipetransport">
45857 <title>The pipe transport</title>
45858 <para>
45859 <indexterm role="concept" id="IIDpiptra1" class="startofrange">
45860 <primary>transports</primary>
45861 <secondary><command>pipe</command></secondary>
45862 </indexterm>
45863 <indexterm role="concept" id="IIDpiptra2" class="startofrange">
45864 <primary><command>pipe</command> transport</primary>
45865 </indexterm>
45866 The <command>pipe</command> transport is used to deliver messages via a pipe to a command
45867 running in another process. One example is the use of <command>pipe</command> as a
45868 pseudo-remote transport for passing messages to some other delivery mechanism
45869 (such as UUCP). Another is the use by individual users to automatically process
45870 their incoming messages. The <command>pipe</command> transport can be used in one of the
45871 following ways:
45872 </para>
45873 <itemizedlist>
45874 <listitem>
45875 <para>
45876 <indexterm role="variable">
45877 <primary><varname>$local_part</varname></primary>
45878 </indexterm>
45879 A router routes one address to a transport in the normal way, and the
45880 transport is configured as a <command>pipe</command> transport. In this case, <varname>$local_part</varname>
45881 contains the local part of the address (as usual), and the command that is run
45882 is specified by the <option>command</option> option on the transport.
45883 </para>
45884 </listitem>
45885 <listitem>
45886 <para>
45887 <indexterm role="variable">
45888 <primary><varname>$pipe_addresses</varname></primary>
45889 </indexterm>
45890 If the <option>batch_max</option> option is set greater than 1 (the default is 1), the
45891 transport can handle more than one address in a single run. In this case, when
45892 more than one address is routed to the transport, <varname>$local_part</varname> is not set
45893 (because it is not unique). However, the pseudo-variable <varname>$pipe_addresses</varname>
45894 (described in section <xref linkend="SECThowcommandrun"/> below) contains all the addresses
45895 that are routed to the transport.
45896 </para>
45897 </listitem>
45898 <listitem>
45899 <para>
45900 <indexterm role="variable">
45901 <primary><varname>$address_pipe</varname></primary>
45902 </indexterm>
45903 A router redirects an address directly to a pipe command (for example, from an
45904 alias or forward file). In this case, <varname>$address_pipe</varname> contains the text of the
45905 pipe command, and the <option>command</option> option on the transport is ignored unless
45906 <option>force_command</option> is set. If only one address is being transported
45907 (<option>batch_max</option> is not greater than one, or only one address was redirected to
45908 this pipe command), <varname>$local_part</varname> contains the local part that was redirected.
45909 </para>
45910 </listitem>
45911 </itemizedlist>
45912 <para>
45913 The <command>pipe</command> transport is a non-interactive delivery method. Exim can also
45914 deliver messages over pipes using the LMTP interactive protocol. This is
45915 implemented by the <command>lmtp</command> transport.
45916 </para>
45917 <para>
45918 In the case when <command>pipe</command> is run as a consequence of an entry in a local user&#x2019;s
45919 <filename>.forward</filename> file, the command runs under the uid and gid of that user. In
45920 other cases, the uid and gid have to be specified explicitly, either on the
45921 transport or on the router that handles the address. Current and <quote>home</quote>
45922 directories are also controllable. See chapter <xref linkend="CHAPenvironment"/> for
45923 details of the local delivery environment and chapter <xref linkend="CHAPbatching"/>
45924 for a discussion of local delivery batching.
45925 </para>
45926 <section id="SECID140">
45927 <title>Concurrent delivery</title>
45928 <para>
45929 If two messages arrive at almost the same time, and both are routed to a pipe
45930 delivery, the two pipe transports may be run concurrently. You must ensure that
45931 any pipe commands you set up are robust against this happening. If the commands
45932 write to a file, the <option>exim_lock</option> utility might be of use.
45933 Alternatively the <option>max_parallel</option> option could be used with a value
45934 of "1" to enforce serialization.
45935 </para>
45936 </section>
45937 <section id="SECID141">
45938 <title>Returned status and data</title>
45939 <para>
45940 <indexterm role="concept">
45941 <primary><command>pipe</command> transport</primary>
45942 <secondary>returned data</secondary>
45943 </indexterm>
45944 If the command exits with a non-zero return code, the delivery is deemed to
45945 have failed, unless either the <option>ignore_status</option> option is set (in which case
45946 the return code is treated as zero), or the return code is one of those listed
45947 in the <option>temp_errors</option> option, which are interpreted as meaning <quote>try again
45948 later</quote>. In this case, delivery is deferred. Details of a permanent failure are
45949 logged, but are not included in the bounce message, which merely contains
45950 <quote>local delivery failed</quote>.
45951 </para>
45952 <para>
45953 If the command exits on a signal and the <option>freeze_signal</option> option is set then
45954 the message will be frozen in the queue. If that option is not set, a bounce
45955 will be sent as normal.
45956 </para>
45957 <para>
45958 If the return code is greater than 128 and the command being run is a shell
45959 script, it normally means that the script was terminated by a signal whose
45960 value is the return code minus 128. The <option>freeze_signal</option> option does not
45961 apply in this case.
45962 </para>
45963 <para>
45964 If Exim is unable to run the command (that is, if <function>execve()</function> fails), the
45965 return code is set to 127. This is the value that a shell returns if it is
45966 asked to run a non-existent command. The wording for the log line suggests that
45967 a non-existent command may be the problem.
45968 </para>
45969 <para>
45970 The <option>return_output</option> option can affect the result of a pipe delivery. If it is
45971 set and the command produces any output on its standard output or standard
45972 error streams, the command is considered to have failed, even if it gave a zero
45973 return code or if <option>ignore_status</option> is set. The output from the command is
45974 included as part of the bounce message. The <option>return_fail_output</option> option is
45975 similar, except that output is returned only when the command exits with a
45976 failure return code, that is, a value other than zero or a code that matches
45977 <option>temp_errors</option>.
45978 </para>
45979 </section>
45980 <section id="SECThowcommandrun">
45981 <title>How the command is run</title>
45982 <para>
45983 <indexterm role="concept">
45984 <primary><command>pipe</command> transport</primary>
45985 <secondary>path for command</secondary>
45986 </indexterm>
45987 The command line is (by default) broken down into a command name and arguments
45988 by the <command>pipe</command> transport itself. The <option>allow_commands</option> and
45989 <option>restrict_to_path</option> options can be used to restrict the commands that may be
45990 run.
45991 </para>
45992 <para>
45993 <indexterm role="concept">
45994 <primary>quoting</primary>
45995 <secondary>in pipe command</secondary>
45996 </indexterm>
45997 Unquoted arguments are delimited by white space. If an argument appears in
45998 double quotes, backslash is interpreted as an escape character in the usual
45999 way. If an argument appears in single quotes, no escaping is done.
46000 </para>
46001 <para>
46002 String expansion is applied to the command line except when it comes from a
46003 traditional <filename>.forward</filename> file (commands from a filter file are expanded). The
46004 expansion is applied to each argument in turn rather than to the whole line.
46005 For this reason, any string expansion item that contains white space must be
46006 quoted so as to be contained within a single argument. A setting such as
46007 </para>
46008 <literallayout class="monospaced">
46009 command = /some/path ${if eq{$local_part}{postmaster}{xx}{yy}}
46010 </literallayout>
46011 <para>
46012 will not work, because the expansion item gets split between several
46013 arguments. You have to write
46014 </para>
46015 <literallayout class="monospaced">
46016 command = /some/path "${if eq{$local_part}{postmaster}{xx}{yy}}"
46017 </literallayout>
46018 <para>
46019 to ensure that it is all in one argument. The expansion is done in this way,
46020 argument by argument, so that the number of arguments cannot be changed as a
46021 result of expansion, and quotes or backslashes in inserted variables do not
46022 interact with external quoting. However, this leads to problems if you want to
46023 generate multiple arguments (or the command name plus arguments) from a single
46024 expansion. In this situation, the simplest solution is to use a shell. For
46025 example:
46026 </para>
46027 <literallayout class="monospaced">
46028 command = /bin/sh -c ${lookup{$local_part}lsearch{/some/file}}
46029 </literallayout>
46030 <para>
46031 <indexterm role="concept">
46032 <primary>transport</primary>
46033 <secondary>filter</secondary>
46034 </indexterm>
46035 <indexterm role="concept">
46036 <primary>filter</primary>
46037 <secondary>transport filter</secondary>
46038 </indexterm>
46039 <indexterm role="variable">
46040 <primary><varname>$pipe_addresses</varname></primary>
46041 </indexterm>
46042 Special handling takes place when an argument consists of precisely the text
46043 <literal>$pipe_addresses</literal> (no quotes).
46044 This is not a general expansion variable; the only
46045 place this string is recognized is when it appears as an argument for a pipe or
46046 transport filter command. It causes each address that is being handled to be
46047 inserted in the argument list at that point <emphasis>as a separate argument</emphasis>. This
46048 avoids any problems with spaces or shell metacharacters, and is of use when a
46049 <command>pipe</command> transport is handling groups of addresses in a batch.
46050 </para>
46051 <para>
46052 If <option>force_command</option> is enabled on the transport, special handling takes place
46053 for an argument that consists of precisely the text <literal>$address_pipe</literal>.  It
46054 is handled similarly to <varname>$pipe_addresses</varname> above.  It is expanded and each
46055 argument is inserted in the argument list at that point
46056 <emphasis>as a separate argument</emphasis>.  The <literal>$address_pipe</literal> item does not need to be
46057 the only item in the argument; in fact, if it were then <option>force_command</option>
46058 should behave as a no-op.  Rather, it should be used to adjust the command
46059 run while preserving the argument vector separation.
46060 </para>
46061 <para>
46062 After splitting up into arguments and expansion, the resulting command is run
46063 in a subprocess directly from the transport, <emphasis>not</emphasis> under a shell. The
46064 message that is being delivered is supplied on the standard input, and the
46065 standard output and standard error are both connected to a single pipe that is
46066 read by Exim. The <option>max_output</option> option controls how much output the command
46067 may produce, and the <option>return_output</option> and <option>return_fail_output</option> options
46068 control what is done with it.
46069 </para>
46070 <para>
46071 Not running the command under a shell (by default) lessens the security risks
46072 in cases when a command from a user&#x2019;s filter file is built out of data that was
46073 taken from an incoming message. If a shell is required, it can of course be
46074 explicitly specified as the command to be run. However, there are circumstances
46075 where existing commands (for example, in <filename>.forward</filename> files) expect to be run
46076 under a shell and cannot easily be modified. To allow for these cases, there is
46077 an option called <option>use_shell</option>, which changes the way the <command>pipe</command> transport
46078 works. Instead of breaking up the command line as just described, it expands it
46079 as a single string and passes the result to <filename>/bin/sh</filename>. The
46080 <option>restrict_to_path</option> option and the <varname>$pipe_addresses</varname> facility cannot be used
46081 with <option>use_shell</option>, and the whole mechanism is inherently less secure.
46082 </para>
46083 </section>
46084 <section id="SECTpipeenv">
46085 <title>Environment variables</title>
46086 <para>
46087 <indexterm role="concept">
46088 <primary><command>pipe</command> transport</primary>
46089 <secondary>environment for command</secondary>
46090 </indexterm>
46091 <indexterm role="concept">
46092 <primary>environment</primary>
46093 <secondary><command>pipe</command> transport</secondary>
46094 </indexterm>
46095 The environment variables listed below are set up when the command is invoked.
46096 This list is a compromise for maximum compatibility with other MTAs. Note that
46097 the <option>environment</option> option can be used to add additional variables to this
46098 environment. The environment for the <command>pipe</command> transport is not subject
46099 to the <option>add_environment</option> and <option>keep_environment</option> main config options.
46100 </para>
46101 <literallayout>
46102 <literal>DOMAIN            </literal>   the domain of the address
46103 <literal>HOME              </literal>   the home directory, if set
46104 <literal>HOST              </literal>   the host name when called from a router (see below)
46105 <literal>LOCAL_PART        </literal>   see below
46106 <literal>LOCAL_PART_PREFIX </literal>   see below
46107 <literal>LOCAL_PART_SUFFIX </literal>   see below
46108 <literal>LOGNAME           </literal>   see below
46109 <literal>MESSAGE_ID        </literal>   Exim&#x2019;s local ID for the message
46110 <literal>PATH              </literal>   as specified by the <option>path</option> option below
46111 <literal>QUALIFY_DOMAIN    </literal>   the sender qualification domain
46112 <literal>RECIPIENT         </literal>   the complete recipient address
46113 <literal>SENDER            </literal>   the sender of the message (empty if a bounce)
46114 <literal>SHELL             </literal>   <literal>/bin/sh</literal>
46115 <literal>TZ                </literal>   the value of the <option>timezone</option> option, if set
46116 <literal>USER              </literal>   see below
46117 </literallayout>
46118 <para>
46119 When a <command>pipe</command> transport is called directly from (for example) an <command>accept</command>
46120 router, LOCAL_PART is set to the local part of the address. When it is
46121 called as a result of a forward or alias expansion, LOCAL_PART is set to
46122 the local part of the address that was expanded. In both cases, any affixes are
46123 removed from the local part, and made available in LOCAL_PART_PREFIX and
46124 LOCAL_PART_SUFFIX, respectively. LOGNAME and USER are set to the
46125 same value as LOCAL_PART for compatibility with other MTAs.
46126 </para>
46127 <para>
46128 <indexterm role="concept">
46129 <primary>HOST</primary>
46130 </indexterm>
46131 HOST is set only when a <command>pipe</command> transport is called from a router that
46132 associates hosts with an address, typically when using <command>pipe</command> as a
46133 pseudo-remote transport. HOST is set to the first host name specified by
46134 the router.
46135 </para>
46136 <para>
46137 <indexterm role="concept">
46138 <primary>HOME</primary>
46139 </indexterm>
46140 If the transport&#x2019;s generic <option>home_directory</option> option is set, its value is used
46141 for the HOME environment variable. Otherwise, a home directory may be set
46142 by the router&#x2019;s <option>transport_home_directory</option> option, which defaults to the
46143 user&#x2019;s home directory if <option>check_local_user</option> is set.
46144 </para>
46145 </section>
46146 <section id="SECID142">
46147 <title>Private options for pipe</title>
46148 <para>
46149 <indexterm role="concept">
46150 <primary>options</primary>
46151 <secondary><command>pipe</command> transport</secondary>
46152 </indexterm>
46153 </para>
46154 <para>
46155 <indexterm role="option">
46156 <primary><option>allow_commands</option></primary>
46157 </indexterm>
46158 </para>
46159 <informaltable frame="all">
46160 <tgroup cols="4" colsep="0" rowsep="0">
46161 <colspec colwidth="8*" align="left"/>
46162 <colspec colwidth="6*" align="center"/>
46163 <colspec colwidth="6*" align="center"/>
46164 <colspec colwidth="6*" align="right"/>
46165 <tbody>
46166 <row>
46167 <entry><option>allow_commands</option></entry>
46168 <entry>Use: <emphasis>pipe</emphasis></entry>
46169 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
46170 <entry>Default: <emphasis>unset</emphasis></entry>
46171 </row>
46172 </tbody>
46173 </tgroup>
46174 </informaltable>
46175 <para>
46176 <indexterm role="concept">
46177 <primary><command>pipe</command> transport</primary>
46178 <secondary>permitted commands</secondary>
46179 </indexterm>
46180 The string is expanded, and is then interpreted as a colon-separated list of
46181 permitted commands. If <option>restrict_to_path</option> is not set, the only commands
46182 permitted are those in the <option>allow_commands</option> list. They need not be absolute
46183 paths; the <option>path</option> option is still used for relative paths. If
46184 <option>restrict_to_path</option> is set with <option>allow_commands</option>, the command must either be
46185 in the <option>allow_commands</option> list, or a name without any slashes that is found on
46186 the path. In other words, if neither <option>allow_commands</option> nor
46187 <option>restrict_to_path</option> is set, there is no restriction on the command, but
46188 otherwise only commands that are permitted by one or the other are allowed. For
46189 example, if
46190 </para>
46191 <literallayout class="monospaced">
46192 allow_commands = /usr/bin/vacation
46193 </literallayout>
46194 <para>
46195 and <option>restrict_to_path</option> is not set, the only permitted command is
46196 <filename>/usr/bin/vacation</filename>. The <option>allow_commands</option> option may not be set if
46197 <option>use_shell</option> is set.
46198 </para>
46199 <para>
46200 <indexterm role="option">
46201 <primary><option>batch_id</option></primary>
46202 </indexterm>
46203 </para>
46204 <informaltable frame="all">
46205 <tgroup cols="4" colsep="0" rowsep="0">
46206 <colspec colwidth="8*" align="left"/>
46207 <colspec colwidth="6*" align="center"/>
46208 <colspec colwidth="6*" align="center"/>
46209 <colspec colwidth="6*" align="right"/>
46210 <tbody>
46211 <row>
46212 <entry><option>batch_id</option></entry>
46213 <entry>Use: <emphasis>pipe</emphasis></entry>
46214 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46215 <entry>Default: <emphasis>unset</emphasis></entry>
46216 </row>
46217 </tbody>
46218 </tgroup>
46219 </informaltable>
46220 <para>
46221 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
46222 </para>
46223 <para>
46224 <indexterm role="option">
46225 <primary><option>batch_max</option></primary>
46226 </indexterm>
46227 </para>
46228 <informaltable frame="all">
46229 <tgroup cols="4" colsep="0" rowsep="0">
46230 <colspec colwidth="8*" align="left"/>
46231 <colspec colwidth="6*" align="center"/>
46232 <colspec colwidth="6*" align="center"/>
46233 <colspec colwidth="6*" align="right"/>
46234 <tbody>
46235 <row>
46236 <entry><option>batch_max</option></entry>
46237 <entry>Use: <emphasis>pipe</emphasis></entry>
46238 <entry>Type: <emphasis>integer</emphasis></entry>
46239 <entry>Default: <emphasis>1</emphasis></entry>
46240 </row>
46241 </tbody>
46242 </tgroup>
46243 </informaltable>
46244 <para>
46245 This limits the number of addresses that can be handled in a single delivery.
46246 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
46247 </para>
46248 <para>
46249 <indexterm role="option">
46250 <primary><option>check_string</option></primary>
46251 </indexterm>
46252 </para>
46253 <informaltable frame="all">
46254 <tgroup cols="4" colsep="0" rowsep="0">
46255 <colspec colwidth="8*" align="left"/>
46256 <colspec colwidth="6*" align="center"/>
46257 <colspec colwidth="6*" align="center"/>
46258 <colspec colwidth="6*" align="right"/>
46259 <tbody>
46260 <row>
46261 <entry><option>check_string</option></entry>
46262 <entry>Use: <emphasis>pipe</emphasis></entry>
46263 <entry>Type: <emphasis>string</emphasis></entry>
46264 <entry>Default: <emphasis>unset</emphasis></entry>
46265 </row>
46266 </tbody>
46267 </tgroup>
46268 </informaltable>
46269 <para>
46270 As <command>pipe</command> writes the message, the start of each line is tested for matching
46271 <option>check_string</option>, and if it does, the initial matching characters are replaced
46272 by the contents of <option>escape_string</option>, provided both are set. The value of
46273 <option>check_string</option> is a literal string, not a regular expression, and the case of
46274 any letters it contains is significant. When <option>use_bsmtp</option> is set, the contents
46275 of <option>check_string</option> and <option>escape_string</option> are forced to values that implement
46276 the SMTP escaping protocol. Any settings made in the configuration file are
46277 ignored.
46278 </para>
46279 <para>
46280 <indexterm role="option">
46281 <primary><option>command</option></primary>
46282 </indexterm>
46283 </para>
46284 <informaltable frame="all">
46285 <tgroup cols="4" colsep="0" rowsep="0">
46286 <colspec colwidth="8*" align="left"/>
46287 <colspec colwidth="6*" align="center"/>
46288 <colspec colwidth="6*" align="center"/>
46289 <colspec colwidth="6*" align="right"/>
46290 <tbody>
46291 <row>
46292 <entry><option>command</option></entry>
46293 <entry>Use: <emphasis>pipe</emphasis></entry>
46294 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46295 <entry>Default: <emphasis>unset</emphasis></entry>
46296 </row>
46297 </tbody>
46298 </tgroup>
46299 </informaltable>
46300 <para>
46301 This option need not be set when <command>pipe</command> is being used to deliver to pipes
46302 obtained directly from address redirections. In other cases, the option must be
46303 set, to provide a command to be run. It need not yield an absolute path (see
46304 the <option>path</option> option below). The command is split up into separate arguments by
46305 Exim, and each argument is separately expanded, as described in section
46306 <xref linkend="SECThowcommandrun"/> above.
46307 </para>
46308 <para>
46309 <indexterm role="option">
46310 <primary><option>environment</option></primary>
46311 </indexterm>
46312 </para>
46313 <informaltable frame="all">
46314 <tgroup cols="4" colsep="0" rowsep="0">
46315 <colspec colwidth="8*" align="left"/>
46316 <colspec colwidth="6*" align="center"/>
46317 <colspec colwidth="6*" align="center"/>
46318 <colspec colwidth="6*" align="right"/>
46319 <tbody>
46320 <row>
46321 <entry><option>environment</option></entry>
46322 <entry>Use: <emphasis>pipe</emphasis></entry>
46323 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46324 <entry>Default: <emphasis>unset</emphasis></entry>
46325 </row>
46326 </tbody>
46327 </tgroup>
46328 </informaltable>
46329 <para>
46330 <indexterm role="concept">
46331 <primary><command>pipe</command> transport</primary>
46332 <secondary>environment for command</secondary>
46333 </indexterm>
46334 <indexterm role="concept">
46335 <primary>environment</primary>
46336 <secondary><command>pipe</command> transport</secondary>
46337 </indexterm>
46338 This option is used to add additional variables to the environment in which the
46339 command runs (see section <xref linkend="SECTpipeenv"/> for the default list). Its value is
46340 a string which is expanded, and then interpreted as a colon-separated list of
46341 environment settings of the form &lt;<emphasis>name</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt;.
46342 </para>
46343 <para>
46344 <indexterm role="option">
46345 <primary><option>escape_string</option></primary>
46346 </indexterm>
46347 </para>
46348 <informaltable frame="all">
46349 <tgroup cols="4" colsep="0" rowsep="0">
46350 <colspec colwidth="8*" align="left"/>
46351 <colspec colwidth="6*" align="center"/>
46352 <colspec colwidth="6*" align="center"/>
46353 <colspec colwidth="6*" align="right"/>
46354 <tbody>
46355 <row>
46356 <entry><option>escape_string</option></entry>
46357 <entry>Use: <emphasis>pipe</emphasis></entry>
46358 <entry>Type: <emphasis>string</emphasis></entry>
46359 <entry>Default: <emphasis>unset</emphasis></entry>
46360 </row>
46361 </tbody>
46362 </tgroup>
46363 </informaltable>
46364 <para>
46365 See <option>check_string</option> above.
46366 </para>
46367 <para>
46368 <indexterm role="option">
46369 <primary><option>freeze_exec_fail</option></primary>
46370 </indexterm>
46371 </para>
46372 <informaltable frame="all">
46373 <tgroup cols="4" colsep="0" rowsep="0">
46374 <colspec colwidth="8*" align="left"/>
46375 <colspec colwidth="6*" align="center"/>
46376 <colspec colwidth="6*" align="center"/>
46377 <colspec colwidth="6*" align="right"/>
46378 <tbody>
46379 <row>
46380 <entry><option>freeze_exec_fail</option></entry>
46381 <entry>Use: <emphasis>pipe</emphasis></entry>
46382 <entry>Type: <emphasis>boolean</emphasis></entry>
46383 <entry>Default: <emphasis>false</emphasis></entry>
46384 </row>
46385 </tbody>
46386 </tgroup>
46387 </informaltable>
46388 <para>
46389 <indexterm role="concept">
46390 <primary>exec failure</primary>
46391 </indexterm>
46392 <indexterm role="concept">
46393 <primary>failure of exec</primary>
46394 </indexterm>
46395 <indexterm role="concept">
46396 <primary><command>pipe</command> transport</primary>
46397 <secondary>failure of exec</secondary>
46398 </indexterm>
46399 Failure to exec the command in a pipe transport is by default treated like
46400 any other failure while running the command. However, if <option>freeze_exec_fail</option>
46401 is set, failure to exec is treated specially, and causes the message to be
46402 frozen, whatever the setting of <option>ignore_status</option>.
46403 </para>
46404 <para>
46405 <indexterm role="option">
46406 <primary><option>freeze_signal</option></primary>
46407 </indexterm>
46408 </para>
46409 <informaltable frame="all">
46410 <tgroup cols="4" colsep="0" rowsep="0">
46411 <colspec colwidth="8*" align="left"/>
46412 <colspec colwidth="6*" align="center"/>
46413 <colspec colwidth="6*" align="center"/>
46414 <colspec colwidth="6*" align="right"/>
46415 <tbody>
46416 <row>
46417 <entry><option>freeze_signal</option></entry>
46418 <entry>Use: <emphasis>pipe</emphasis></entry>
46419 <entry>Type: <emphasis>boolean</emphasis></entry>
46420 <entry>Default: <emphasis>false</emphasis></entry>
46421 </row>
46422 </tbody>
46423 </tgroup>
46424 </informaltable>
46425 <para>
46426 <indexterm role="concept">
46427 <primary>signal exit</primary>
46428 </indexterm>
46429 <indexterm role="concept">
46430 <primary><command>pipe</command> transport</primary>
46431 <secondary>,</secondary>
46432 </indexterm>
46433 Normally if the process run by a command in a pipe transport exits on a signal,
46434 a bounce message is sent. If <option>freeze_signal</option> is set, the message will be
46435 frozen in Exim&#x2019;s queue instead.
46436 </para>
46437 <para>
46438 <indexterm role="option">
46439 <primary><option>force_command</option></primary>
46440 </indexterm>
46441 </para>
46442 <informaltable frame="all">
46443 <tgroup cols="4" colsep="0" rowsep="0">
46444 <colspec colwidth="8*" align="left"/>
46445 <colspec colwidth="6*" align="center"/>
46446 <colspec colwidth="6*" align="center"/>
46447 <colspec colwidth="6*" align="right"/>
46448 <tbody>
46449 <row>
46450 <entry><option>force_command</option></entry>
46451 <entry>Use: <emphasis>pipe</emphasis></entry>
46452 <entry>Type: <emphasis>boolean</emphasis></entry>
46453 <entry>Default: <emphasis>false</emphasis></entry>
46454 </row>
46455 </tbody>
46456 </tgroup>
46457 </informaltable>
46458 <para>
46459 <indexterm role="concept">
46460 <primary>force command</primary>
46461 </indexterm>
46462 <indexterm role="concept">
46463 <primary><command>pipe</command> transport</primary>
46464 <secondary>,</secondary>
46465 </indexterm>
46466 Normally when a router redirects an address directly to a pipe command
46467 the <option>command</option> option on the transport is ignored.  If <option>force_command</option>
46468 is set, the <option>command</option> option will used. This is especially
46469 useful for forcing a wrapper or additional argument to be added to the
46470 command. For example:
46471 </para>
46472 <literallayout class="monospaced">
46473 command = /usr/bin/remote_exec myhost -- $address_pipe
46474 force_command
46475 </literallayout>
46476 <para>
46477 Note that <varname>$address_pipe</varname> is handled specially in <option>command</option> when
46478 <option>force_command</option> is set, expanding out to the original argument vector as
46479 separate items, similarly to a Unix shell <literal>"$@"</literal> construct.
46480 </para>
46481 <para>
46482 <indexterm role="option">
46483 <primary><option>ignore_status</option></primary>
46484 </indexterm>
46485 </para>
46486 <informaltable frame="all">
46487 <tgroup cols="4" colsep="0" rowsep="0">
46488 <colspec colwidth="8*" align="left"/>
46489 <colspec colwidth="6*" align="center"/>
46490 <colspec colwidth="6*" align="center"/>
46491 <colspec colwidth="6*" align="right"/>
46492 <tbody>
46493 <row>
46494 <entry><option>ignore_status</option></entry>
46495 <entry>Use: <emphasis>pipe</emphasis></entry>
46496 <entry>Type: <emphasis>boolean</emphasis></entry>
46497 <entry>Default: <emphasis>false</emphasis></entry>
46498 </row>
46499 </tbody>
46500 </tgroup>
46501 </informaltable>
46502 <para>
46503 If this option is true, the status returned by the subprocess that is set up to
46504 run the command is ignored, and Exim behaves as if zero had been returned.
46505 Otherwise, a non-zero status or termination by signal causes an error return
46506 from the transport unless the status value is one of those listed in
46507 <option>temp_errors</option>; these cause the delivery to be deferred and tried again later.
46508 </para>
46509 <para>
46510 <emphasis role="bold">Note</emphasis>: This option does not apply to timeouts, which do not return a status.
46511 See the <option>timeout_defer</option> option for how timeouts are handled.
46512 </para>
46513 <para>
46514 <indexterm role="option">
46515 <primary><option>log_defer_output</option></primary>
46516 </indexterm>
46517 </para>
46518 <informaltable frame="all">
46519 <tgroup cols="4" colsep="0" rowsep="0">
46520 <colspec colwidth="8*" align="left"/>
46521 <colspec colwidth="6*" align="center"/>
46522 <colspec colwidth="6*" align="center"/>
46523 <colspec colwidth="6*" align="right"/>
46524 <tbody>
46525 <row>
46526 <entry><option>log_defer_output</option></entry>
46527 <entry>Use: <emphasis>pipe</emphasis></entry>
46528 <entry>Type: <emphasis>boolean</emphasis></entry>
46529 <entry>Default: <emphasis>false</emphasis></entry>
46530 </row>
46531 </tbody>
46532 </tgroup>
46533 </informaltable>
46534 <para>
46535 <indexterm role="concept">
46536 <primary><command>pipe</command> transport</primary>
46537 <secondary>logging output</secondary>
46538 </indexterm>
46539 If this option is set, and the status returned by the command is
46540 one of the codes listed in <option>temp_errors</option> (that is, delivery was deferred),
46541 and any output was produced on stdout or stderr, the first line of it is
46542 written to the main log.
46543 </para>
46544 <para>
46545 <indexterm role="option">
46546 <primary><option>log_fail_output</option></primary>
46547 </indexterm>
46548 </para>
46549 <informaltable frame="all">
46550 <tgroup cols="4" colsep="0" rowsep="0">
46551 <colspec colwidth="8*" align="left"/>
46552 <colspec colwidth="6*" align="center"/>
46553 <colspec colwidth="6*" align="center"/>
46554 <colspec colwidth="6*" align="right"/>
46555 <tbody>
46556 <row>
46557 <entry><option>log_fail_output</option></entry>
46558 <entry>Use: <emphasis>pipe</emphasis></entry>
46559 <entry>Type: <emphasis>boolean</emphasis></entry>
46560 <entry>Default: <emphasis>false</emphasis></entry>
46561 </row>
46562 </tbody>
46563 </tgroup>
46564 </informaltable>
46565 <para>
46566 If this option is set, and the command returns any output on stdout or
46567 stderr, and also ends with a return code that is neither zero nor one of
46568 the return codes listed in <option>temp_errors</option> (that is, the delivery
46569 failed), the first line of output is written to the main log. This
46570 option and <option>log_output</option> are mutually exclusive.  Only one of them may
46571 be set.
46572 </para>
46573 <para>
46574 <indexterm role="option">
46575 <primary><option>log_output</option></primary>
46576 </indexterm>
46577 </para>
46578 <informaltable frame="all">
46579 <tgroup cols="4" colsep="0" rowsep="0">
46580 <colspec colwidth="8*" align="left"/>
46581 <colspec colwidth="6*" align="center"/>
46582 <colspec colwidth="6*" align="center"/>
46583 <colspec colwidth="6*" align="right"/>
46584 <tbody>
46585 <row>
46586 <entry><option>log_output</option></entry>
46587 <entry>Use: <emphasis>pipe</emphasis></entry>
46588 <entry>Type: <emphasis>boolean</emphasis></entry>
46589 <entry>Default: <emphasis>false</emphasis></entry>
46590 </row>
46591 </tbody>
46592 </tgroup>
46593 </informaltable>
46594 <para>
46595 If this option is set and the command returns any output on stdout or
46596 stderr, the first line of output is written to the main log, whatever
46597 the return code. This option and <option>log_fail_output</option> are mutually
46598 exclusive. Only one of them may be set.
46599 </para>
46600 <para>
46601 <indexterm role="option">
46602 <primary><option>max_output</option></primary>
46603 </indexterm>
46604 </para>
46605 <informaltable frame="all">
46606 <tgroup cols="4" colsep="0" rowsep="0">
46607 <colspec colwidth="8*" align="left"/>
46608 <colspec colwidth="6*" align="center"/>
46609 <colspec colwidth="6*" align="center"/>
46610 <colspec colwidth="6*" align="right"/>
46611 <tbody>
46612 <row>
46613 <entry><option>max_output</option></entry>
46614 <entry>Use: <emphasis>pipe</emphasis></entry>
46615 <entry>Type: <emphasis>integer</emphasis></entry>
46616 <entry>Default: <emphasis>20K</emphasis></entry>
46617 </row>
46618 </tbody>
46619 </tgroup>
46620 </informaltable>
46621 <para>
46622 This specifies the maximum amount of output that the command may produce on its
46623 standard output and standard error file combined. If the limit is exceeded, the
46624 process running the command is killed. This is intended as a safety measure to
46625 catch runaway processes. The limit is applied independently of the settings of
46626 the options that control what is done with such output (for example,
46627 <option>return_output</option>). Because of buffering effects, the amount of output may
46628 exceed the limit by a small amount before Exim notices.
46629 </para>
46630 <para>
46631 <indexterm role="option">
46632 <primary><option>message_prefix</option></primary>
46633 </indexterm>
46634 </para>
46635 <informaltable frame="all">
46636 <tgroup cols="4" colsep="0" rowsep="0">
46637 <colspec colwidth="8*" align="left"/>
46638 <colspec colwidth="6*" align="center"/>
46639 <colspec colwidth="6*" align="center"/>
46640 <colspec colwidth="6*" align="right"/>
46641 <tbody>
46642 <row>
46643 <entry><option>message_prefix</option></entry>
46644 <entry>Use: <emphasis>pipe</emphasis></entry>
46645 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46646 <entry>Default: <emphasis>see below</emphasis></entry>
46647 </row>
46648 </tbody>
46649 </tgroup>
46650 </informaltable>
46651 <para>
46652 The string specified here is expanded and output at the start of every message.
46653 The default is unset if <option>use_bsmtp</option> is set. Otherwise it is
46654 </para>
46655 <literallayout class="monospaced">
46656 message_prefix = \
46657   From ${if def:return_path{$return_path}{MAILER-DAEMON}}\
46658   ${tod_bsdinbox}\n
46659 </literallayout>
46660 <para>
46661 <indexterm role="concept">
46662 <primary>Cyrus</primary>
46663 </indexterm>
46664 <indexterm role="concept">
46665 <primary><option>tmail</option></primary>
46666 </indexterm>
46667 <indexterm role="concept">
46668 <primary><quote>From</quote> line</primary>
46669 </indexterm>
46670 This is required by the commonly used <filename>/usr/bin/vacation</filename> program.
46671 However, it must <emphasis>not</emphasis> be present if delivery is to the Cyrus IMAP server,
46672 or to the <option>tmail</option> local delivery agent. The prefix can be suppressed by
46673 setting
46674 </para>
46675 <literallayout class="monospaced">
46676 message_prefix =
46677 </literallayout>
46678 <para>
46679 <emphasis role="bold">Note:</emphasis> If you set <option>use_crlf</option> true, you must change any occurrences of
46680 <literal>\n</literal> to <literal>\r\n</literal> in <option>message_prefix</option>.
46681 </para>
46682 <para>
46683 <indexterm role="option">
46684 <primary><option>message_suffix</option></primary>
46685 </indexterm>
46686 </para>
46687 <informaltable frame="all">
46688 <tgroup cols="4" colsep="0" rowsep="0">
46689 <colspec colwidth="8*" align="left"/>
46690 <colspec colwidth="6*" align="center"/>
46691 <colspec colwidth="6*" align="center"/>
46692 <colspec colwidth="6*" align="right"/>
46693 <tbody>
46694 <row>
46695 <entry><option>message_suffix</option></entry>
46696 <entry>Use: <emphasis>pipe</emphasis></entry>
46697 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46698 <entry>Default: <emphasis>see below</emphasis></entry>
46699 </row>
46700 </tbody>
46701 </tgroup>
46702 </informaltable>
46703 <para>
46704 The string specified here is expanded and output at the end of every message.
46705 The default is unset if <option>use_bsmtp</option> is set. Otherwise it is a single newline.
46706 The suffix can be suppressed by setting
46707 </para>
46708 <literallayout class="monospaced">
46709 message_suffix =
46710 </literallayout>
46711 <para>
46712 <emphasis role="bold">Note:</emphasis> If you set <option>use_crlf</option> true, you must change any occurrences of
46713 <literal>\n</literal> to <literal>\r\n</literal> in <option>message_suffix</option>.
46714 </para>
46715 <para>
46716 <indexterm role="option">
46717 <primary><option>path</option></primary>
46718 </indexterm>
46719 </para>
46720 <informaltable frame="all">
46721 <tgroup cols="4" colsep="0" rowsep="0">
46722 <colspec colwidth="8*" align="left"/>
46723 <colspec colwidth="6*" align="center"/>
46724 <colspec colwidth="6*" align="center"/>
46725 <colspec colwidth="6*" align="right"/>
46726 <tbody>
46727 <row>
46728 <entry><option>path</option></entry>
46729 <entry>Use: <emphasis>pipe</emphasis></entry>
46730 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46731 <entry>Default: <emphasis>/bin:/usr/bin</emphasis></entry>
46732 </row>
46733 </tbody>
46734 </tgroup>
46735 </informaltable>
46736 <para>
46737 This option is expanded and
46738 specifies the string that is set up in the PATH environment
46739 variable of the subprocess.
46740 If the <option>command</option> option does not yield an absolute path name, the command is
46741 sought in the PATH directories, in the usual way. <emphasis role="bold">Warning</emphasis>: This does not
46742 apply to a command specified as a transport filter.
46743 </para>
46744 <para>
46745 <indexterm role="option">
46746 <primary><option>permit_coredump</option></primary>
46747 </indexterm>
46748 </para>
46749 <informaltable frame="all">
46750 <tgroup cols="4" colsep="0" rowsep="0">
46751 <colspec colwidth="8*" align="left"/>
46752 <colspec colwidth="6*" align="center"/>
46753 <colspec colwidth="6*" align="center"/>
46754 <colspec colwidth="6*" align="right"/>
46755 <tbody>
46756 <row>
46757 <entry><option>permit_coredump</option></entry>
46758 <entry>Use: <emphasis>pipe</emphasis></entry>
46759 <entry>Type: <emphasis>boolean</emphasis></entry>
46760 <entry>Default: <emphasis>false</emphasis></entry>
46761 </row>
46762 </tbody>
46763 </tgroup>
46764 </informaltable>
46765 <para>
46766 Normally Exim inhibits core-dumps during delivery.  If you have a need to get
46767 a core-dump of a pipe command, enable this command.  This enables core-dumps
46768 during delivery and affects both the Exim binary and the pipe command run.
46769 It is recommended that this option remain off unless and until you have a need
46770 for it and that this only be enabled when needed, as the risk of excessive
46771 resource consumption can be quite high.  Note also that Exim is typically
46772 installed as a setuid binary and most operating systems will inhibit coredumps
46773 of these by default, so further OS-specific action may be required.
46774 </para>
46775 <para>
46776 <indexterm role="option">
46777 <primary><option>pipe_as_creator</option></primary>
46778 </indexterm>
46779 </para>
46780 <informaltable frame="all">
46781 <tgroup cols="4" colsep="0" rowsep="0">
46782 <colspec colwidth="8*" align="left"/>
46783 <colspec colwidth="6*" align="center"/>
46784 <colspec colwidth="6*" align="center"/>
46785 <colspec colwidth="6*" align="right"/>
46786 <tbody>
46787 <row>
46788 <entry><option>pipe_as_creator</option></entry>
46789 <entry>Use: <emphasis>pipe</emphasis></entry>
46790 <entry>Type: <emphasis>boolean</emphasis></entry>
46791 <entry>Default: <emphasis>false</emphasis></entry>
46792 </row>
46793 </tbody>
46794 </tgroup>
46795 </informaltable>
46796 <para>
46797 <indexterm role="concept">
46798 <primary>uid (user id)</primary>
46799 <secondary>local delivery</secondary>
46800 </indexterm>
46801 If the generic <option>user</option> option is not set and this option is true, the delivery
46802 process is run under the uid that was in force when Exim was originally called
46803 to accept the message. If the group id is not otherwise set (via the generic
46804 <option>group</option> option), the gid that was in force when Exim was originally called to
46805 accept the message is used.
46806 </para>
46807 <para>
46808 <indexterm role="option">
46809 <primary><option>restrict_to_path</option></primary>
46810 </indexterm>
46811 </para>
46812 <informaltable frame="all">
46813 <tgroup cols="4" colsep="0" rowsep="0">
46814 <colspec colwidth="8*" align="left"/>
46815 <colspec colwidth="6*" align="center"/>
46816 <colspec colwidth="6*" align="center"/>
46817 <colspec colwidth="6*" align="right"/>
46818 <tbody>
46819 <row>
46820 <entry><option>restrict_to_path</option></entry>
46821 <entry>Use: <emphasis>pipe</emphasis></entry>
46822 <entry>Type: <emphasis>boolean</emphasis></entry>
46823 <entry>Default: <emphasis>false</emphasis></entry>
46824 </row>
46825 </tbody>
46826 </tgroup>
46827 </informaltable>
46828 <para>
46829 When this option is set, any command name not listed in <option>allow_commands</option> must
46830 contain no slashes. The command is searched for only in the directories listed
46831 in the <option>path</option> option. This option is intended for use in the case when a pipe
46832 command has been generated from a user&#x2019;s <filename>.forward</filename> file. This is usually
46833 handled by a <command>pipe</command> transport called <option>address_pipe</option>.
46834 </para>
46835 <para>
46836 <indexterm role="option">
46837 <primary><option>return_fail_output</option></primary>
46838 </indexterm>
46839 </para>
46840 <informaltable frame="all">
46841 <tgroup cols="4" colsep="0" rowsep="0">
46842 <colspec colwidth="8*" align="left"/>
46843 <colspec colwidth="6*" align="center"/>
46844 <colspec colwidth="6*" align="center"/>
46845 <colspec colwidth="6*" align="right"/>
46846 <tbody>
46847 <row>
46848 <entry><option>return_fail_output</option></entry>
46849 <entry>Use: <emphasis>pipe</emphasis></entry>
46850 <entry>Type: <emphasis>boolean</emphasis></entry>
46851 <entry>Default: <emphasis>false</emphasis></entry>
46852 </row>
46853 </tbody>
46854 </tgroup>
46855 </informaltable>
46856 <para>
46857 If this option is true, and the command produced any output and ended with a
46858 return code other than zero or one of the codes listed in <option>temp_errors</option> (that
46859 is, the delivery failed), the output is returned in the bounce message.
46860 However, if the message has a null sender (that is, it is itself a bounce
46861 message), output from the command is discarded. This option and
46862 <option>return_output</option> are mutually exclusive. Only one of them may be set.
46863 </para>
46864 <para>
46865 <indexterm role="option">
46866 <primary><option>return_output</option></primary>
46867 </indexterm>
46868 </para>
46869 <informaltable frame="all">
46870 <tgroup cols="4" colsep="0" rowsep="0">
46871 <colspec colwidth="8*" align="left"/>
46872 <colspec colwidth="6*" align="center"/>
46873 <colspec colwidth="6*" align="center"/>
46874 <colspec colwidth="6*" align="right"/>
46875 <tbody>
46876 <row>
46877 <entry><option>return_output</option></entry>
46878 <entry>Use: <emphasis>pipe</emphasis></entry>
46879 <entry>Type: <emphasis>boolean</emphasis></entry>
46880 <entry>Default: <emphasis>false</emphasis></entry>
46881 </row>
46882 </tbody>
46883 </tgroup>
46884 </informaltable>
46885 <para>
46886 If this option is true, and the command produced any output, the delivery is
46887 deemed to have failed whatever the return code from the command, and the output
46888 is returned in the bounce message. Otherwise, the output is just discarded.
46889 However, if the message has a null sender (that is, it is a bounce message),
46890 output from the command is always discarded, whatever the setting of this
46891 option. This option and <option>return_fail_output</option> are mutually exclusive. Only one
46892 of them may be set.
46893 </para>
46894 <para>
46895 <indexterm role="option">
46896 <primary><option>temp_errors</option></primary>
46897 </indexterm>
46898 </para>
46899 <informaltable frame="all">
46900 <tgroup cols="4" colsep="0" rowsep="0">
46901 <colspec colwidth="8*" align="left"/>
46902 <colspec colwidth="6*" align="center"/>
46903 <colspec colwidth="6*" align="center"/>
46904 <colspec colwidth="6*" align="right"/>
46905 <tbody>
46906 <row>
46907 <entry><option>temp_errors</option></entry>
46908 <entry>Use: <emphasis>pipe</emphasis></entry>
46909 <entry>Type: <emphasis>string list</emphasis></entry>
46910 <entry>Default: <emphasis>see below</emphasis></entry>
46911 </row>
46912 </tbody>
46913 </tgroup>
46914 </informaltable>
46915 <para>
46916 <indexterm role="concept">
46917 <primary><command>pipe</command> transport</primary>
46918 <secondary>temporary failure</secondary>
46919 </indexterm>
46920 This option contains either a colon-separated list of numbers, or a single
46921 asterisk. If <option>ignore_status</option> is false
46922 and <option>return_output</option> is not set,
46923 and the command exits with a non-zero return code, the failure is treated as
46924 temporary and the delivery is deferred if the return code matches one of the
46925 numbers, or if the setting is a single asterisk. Otherwise, non-zero return
46926 codes are treated as permanent errors. The default setting contains the codes
46927 defined by EX_TEMPFAIL and EX_CANTCREAT in <filename>sysexits.h</filename>. If Exim is
46928 compiled on a system that does not define these macros, it assumes values of 75
46929 and 73, respectively.
46930 </para>
46931 <para>
46932 <indexterm role="option">
46933 <primary><option>timeout</option></primary>
46934 </indexterm>
46935 </para>
46936 <informaltable frame="all">
46937 <tgroup cols="4" colsep="0" rowsep="0">
46938 <colspec colwidth="8*" align="left"/>
46939 <colspec colwidth="6*" align="center"/>
46940 <colspec colwidth="6*" align="center"/>
46941 <colspec colwidth="6*" align="right"/>
46942 <tbody>
46943 <row>
46944 <entry><option>timeout</option></entry>
46945 <entry>Use: <emphasis>pipe</emphasis></entry>
46946 <entry>Type: <emphasis>time</emphasis></entry>
46947 <entry>Default: <emphasis>1h</emphasis></entry>
46948 </row>
46949 </tbody>
46950 </tgroup>
46951 </informaltable>
46952 <para>
46953 If the command fails to complete within this time, it is killed. This normally
46954 causes the delivery to fail (but see <option>timeout_defer</option>). A zero time interval
46955 specifies no timeout. In order to ensure that any subprocesses created by the
46956 command are also killed, Exim makes the initial process a process group leader,
46957 and kills the whole process group on a timeout. However, this can be defeated
46958 if one of the processes starts a new process group.
46959 </para>
46960 <para>
46961 <indexterm role="option">
46962 <primary><option>timeout_defer</option></primary>
46963 </indexterm>
46964 </para>
46965 <informaltable frame="all">
46966 <tgroup cols="4" colsep="0" rowsep="0">
46967 <colspec colwidth="8*" align="left"/>
46968 <colspec colwidth="6*" align="center"/>
46969 <colspec colwidth="6*" align="center"/>
46970 <colspec colwidth="6*" align="right"/>
46971 <tbody>
46972 <row>
46973 <entry><option>timeout_defer</option></entry>
46974 <entry>Use: <emphasis>pipe</emphasis></entry>
46975 <entry>Type: <emphasis>boolean</emphasis></entry>
46976 <entry>Default: <emphasis>false</emphasis></entry>
46977 </row>
46978 </tbody>
46979 </tgroup>
46980 </informaltable>
46981 <para>
46982 A timeout in a <command>pipe</command> transport, either in the command that the transport
46983 runs, or in a transport filter that is associated with it, is by default
46984 treated as a hard error, and the delivery fails. However, if <option>timeout_defer</option>
46985 is set true, both kinds of timeout become temporary errors, causing the
46986 delivery to be deferred.
46987 </para>
46988 <para>
46989 <indexterm role="option">
46990 <primary><option>umask</option></primary>
46991 </indexterm>
46992 </para>
46993 <informaltable frame="all">
46994 <tgroup cols="4" colsep="0" rowsep="0">
46995 <colspec colwidth="8*" align="left"/>
46996 <colspec colwidth="6*" align="center"/>
46997 <colspec colwidth="6*" align="center"/>
46998 <colspec colwidth="6*" align="right"/>
46999 <tbody>
47000 <row>
47001 <entry><option>umask</option></entry>
47002 <entry>Use: <emphasis>pipe</emphasis></entry>
47003 <entry>Type: <emphasis>octal integer</emphasis></entry>
47004 <entry>Default: <emphasis>022</emphasis></entry>
47005 </row>
47006 </tbody>
47007 </tgroup>
47008 </informaltable>
47009 <para>
47010 This specifies the umask setting for the subprocess that runs the command.
47011 </para>
47012 <para>
47013 <indexterm role="option">
47014 <primary><option>use_bsmtp</option></primary>
47015 </indexterm>
47016 </para>
47017 <informaltable frame="all">
47018 <tgroup cols="4" colsep="0" rowsep="0">
47019 <colspec colwidth="8*" align="left"/>
47020 <colspec colwidth="6*" align="center"/>
47021 <colspec colwidth="6*" align="center"/>
47022 <colspec colwidth="6*" align="right"/>
47023 <tbody>
47024 <row>
47025 <entry><option>use_bsmtp</option></entry>
47026 <entry>Use: <emphasis>pipe</emphasis></entry>
47027 <entry>Type: <emphasis>boolean</emphasis></entry>
47028 <entry>Default: <emphasis>false</emphasis></entry>
47029 </row>
47030 </tbody>
47031 </tgroup>
47032 </informaltable>
47033 <para>
47034 <indexterm role="concept">
47035 <primary>envelope sender</primary>
47036 </indexterm>
47037 If this option is set true, the <command>pipe</command> transport writes messages in <quote>batch
47038 SMTP</quote> format, with the envelope sender and recipient(s) included as SMTP
47039 commands. If you want to include a leading HELO command with such messages,
47040 you can do so by setting the <option>message_prefix</option> option. See section
47041 <xref linkend="SECTbatchSMTP"/> for details of batch SMTP.
47042 </para>
47043 <para>
47044 <indexterm role="option">
47045 <primary><option>use_classresources</option></primary>
47046 </indexterm>
47047 </para>
47048 <informaltable frame="all">
47049 <tgroup cols="4" colsep="0" rowsep="0">
47050 <colspec colwidth="8*" align="left"/>
47051 <colspec colwidth="6*" align="center"/>
47052 <colspec colwidth="6*" align="center"/>
47053 <colspec colwidth="6*" align="right"/>
47054 <tbody>
47055 <row>
47056 <entry><option>use_classresources</option></entry>
47057 <entry>Use: <emphasis>pipe</emphasis></entry>
47058 <entry>Type: <emphasis>boolean</emphasis></entry>
47059 <entry>Default: <emphasis>false</emphasis></entry>
47060 </row>
47061 </tbody>
47062 </tgroup>
47063 </informaltable>
47064 <para>
47065 <indexterm role="concept">
47066 <primary>class resources (BSD)</primary>
47067 </indexterm>
47068 This option is available only when Exim is running on FreeBSD, NetBSD, or
47069 BSD/OS. If it is set true, the <function>setclassresources()</function> function is used to set
47070 resource limits when a <command>pipe</command> transport is run to perform a delivery. The
47071 limits for the uid under which the pipe is to run are obtained from the login
47072 class database.
47073 </para>
47074 <para>
47075 <indexterm role="option">
47076 <primary><option>use_crlf</option></primary>
47077 </indexterm>
47078 </para>
47079 <informaltable frame="all">
47080 <tgroup cols="4" colsep="0" rowsep="0">
47081 <colspec colwidth="8*" align="left"/>
47082 <colspec colwidth="6*" align="center"/>
47083 <colspec colwidth="6*" align="center"/>
47084 <colspec colwidth="6*" align="right"/>
47085 <tbody>
47086 <row>
47087 <entry><option>use_crlf</option></entry>
47088 <entry>Use: <emphasis>pipe</emphasis></entry>
47089 <entry>Type: <emphasis>boolean</emphasis></entry>
47090 <entry>Default: <emphasis>false</emphasis></entry>
47091 </row>
47092 </tbody>
47093 </tgroup>
47094 </informaltable>
47095 <para>
47096 <indexterm role="concept">
47097 <primary>carriage return</primary>
47098 </indexterm>
47099 <indexterm role="concept">
47100 <primary>linefeed</primary>
47101 </indexterm>
47102 This option causes lines to be terminated with the two-character CRLF sequence
47103 (carriage return, linefeed) instead of just a linefeed character. In the case
47104 of batched SMTP, the byte sequence written to the pipe is then an exact image
47105 of what would be sent down a real SMTP connection.
47106 </para>
47107 <para>
47108 The contents of the <option>message_prefix</option> and <option>message_suffix</option> options are
47109 written verbatim, so must contain their own carriage return characters if these
47110 are needed. When <option>use_bsmtp</option> is not set, the default values for both
47111 <option>message_prefix</option> and <option>message_suffix</option> end with a single linefeed, so their
47112 values must be changed to end with <literal>\r\n</literal> if <option>use_crlf</option> is set.
47113 </para>
47114 <para>
47115 <indexterm role="option">
47116 <primary><option>use_shell</option></primary>
47117 </indexterm>
47118 </para>
47119 <informaltable frame="all">
47120 <tgroup cols="4" colsep="0" rowsep="0">
47121 <colspec colwidth="8*" align="left"/>
47122 <colspec colwidth="6*" align="center"/>
47123 <colspec colwidth="6*" align="center"/>
47124 <colspec colwidth="6*" align="right"/>
47125 <tbody>
47126 <row>
47127 <entry><option>use_shell</option></entry>
47128 <entry>Use: <emphasis>pipe</emphasis></entry>
47129 <entry>Type: <emphasis>boolean</emphasis></entry>
47130 <entry>Default: <emphasis>false</emphasis></entry>
47131 </row>
47132 </tbody>
47133 </tgroup>
47134 </informaltable>
47135 <para>
47136 <indexterm role="variable">
47137 <primary><varname>$pipe_addresses</varname></primary>
47138 </indexterm>
47139 If this option is set, it causes the command to be passed to <filename>/bin/sh</filename>
47140 instead of being run directly from the transport, as described in section
47141 <xref linkend="SECThowcommandrun"/>. This is less secure, but is needed in some situations
47142 where the command is expected to be run under a shell and cannot easily be
47143 modified. The <option>allow_commands</option> and <option>restrict_to_path</option> options, and the
47144 <literal>$pipe_addresses</literal> facility are incompatible with <option>use_shell</option>. The
47145 command is expanded as a single string, and handed to <filename>/bin/sh</filename> as data for
47146 its <option>-c</option> option.
47147 </para>
47148 </section>
47149 <section id="SECID143">
47150 <title>Using an external local delivery agent</title>
47151 <para>
47152 <indexterm role="concept">
47153 <primary>local delivery</primary>
47154 <secondary>using an external agent</secondary>
47155 </indexterm>
47156 <indexterm role="concept">
47157 <primary><emphasis>procmail</emphasis></primary>
47158 </indexterm>
47159 <indexterm role="concept">
47160 <primary>external local delivery</primary>
47161 </indexterm>
47162 <indexterm role="concept">
47163 <primary>delivery</primary>
47164 <secondary><emphasis>procmail</emphasis></secondary>
47165 </indexterm>
47166 <indexterm role="concept">
47167 <primary>delivery</primary>
47168 <secondary>by external agent</secondary>
47169 </indexterm>
47170 The <command>pipe</command> transport can be used to pass all messages that require local
47171 delivery to a separate local delivery agent such as <option>procmail</option>. When doing
47172 this, care must be taken to ensure that the pipe is run under an appropriate
47173 uid and gid. In some configurations one wants this to be a uid that is trusted
47174 by the delivery agent to supply the correct sender of the message. It may be
47175 necessary to recompile or reconfigure the delivery agent so that it trusts an
47176 appropriate user. The following is an example transport and router
47177 configuration for <option>procmail</option>:
47178 </para>
47179 <literallayout class="monospaced">
47180 # transport
47181 procmail_pipe:
47182   driver = pipe
47183   command = /usr/local/bin/procmail -d $local_part
47184   return_path_add
47185   delivery_date_add
47186   envelope_to_add
47187   check_string = "From "
47188   escape_string = "&gt;From "
47189   umask = 077
47190   user = $local_part
47191   group = mail
47192
47193 # router
47194 procmail:
47195   driver = accept
47196   check_local_user
47197   transport = procmail_pipe
47198 </literallayout>
47199 <para>
47200 In this example, the pipe is run as the local user, but with the group set to
47201 <emphasis>mail</emphasis>. An alternative is to run the pipe as a specific user such as <emphasis>mail</emphasis>
47202 or <emphasis>exim</emphasis>, but in this case you must arrange for <option>procmail</option> to trust that
47203 user to supply a correct sender address. If you do not specify either a
47204 <option>group</option> or a <option>user</option> option, the pipe command is run as the local user. The
47205 home directory is the user&#x2019;s home directory by default.
47206 </para>
47207 <para>
47208 <emphasis role="bold">Note</emphasis>: The command that the pipe transport runs does <emphasis>not</emphasis> begin with
47209 </para>
47210 <literallayout class="monospaced">
47211 IFS=" "
47212 </literallayout>
47213 <para>
47214 as shown in some <option>procmail</option> documentation, because Exim does not by default
47215 use a shell to run pipe commands.
47216 </para>
47217 <para>
47218 <indexterm role="concept">
47219 <primary>Cyrus</primary>
47220 </indexterm>
47221 The next example shows a transport and a router for a system where local
47222 deliveries are handled by the Cyrus IMAP server.
47223 </para>
47224 <literallayout class="monospaced">
47225 # transport
47226 local_delivery_cyrus:
47227   driver = pipe
47228   command = /usr/cyrus/bin/deliver \
47229             -m ${substr_1:$local_part_suffix} -- $local_part
47230   user = cyrus
47231   group = mail
47232   return_output
47233   log_output
47234   message_prefix =
47235   message_suffix =
47236
47237 # router
47238 local_user_cyrus:
47239   driver = accept
47240   check_local_user
47241   local_part_suffix = .*
47242   transport = local_delivery_cyrus
47243 </literallayout>
47244 <para>
47245 Note the unsetting of <option>message_prefix</option> and <option>message_suffix</option>, and the use of
47246 <option>return_output</option> to cause any text written by Cyrus to be returned to the
47247 sender.
47248 <indexterm role="concept" startref="IIDpiptra1" class="endofrange"/>
47249 <indexterm role="concept" startref="IIDpiptra2" class="endofrange"/>
47250 </para>
47251 </section>
47252 </chapter>
47253
47254 <chapter id="CHAPsmtptrans">
47255 <title>The smtp transport</title>
47256 <para>
47257 <indexterm role="concept" id="IIDsmttra1" class="startofrange">
47258 <primary>transports</primary>
47259 <secondary><command>smtp</command></secondary>
47260 </indexterm>
47261 <indexterm role="concept" id="IIDsmttra2" class="startofrange">
47262 <primary><command>smtp</command> transport</primary>
47263 </indexterm>
47264 The <command>smtp</command> transport delivers messages over TCP/IP connections using the SMTP
47265 or LMTP protocol. The list of hosts to try can either be taken from the address
47266 that is being processed (having been set up by the router), or specified
47267 explicitly for the transport. Timeout and retry processing (see chapter
47268 <xref linkend="CHAPretry"/>) is applied to each IP address independently.
47269 </para>
47270 <section id="SECID144">
47271 <title>Multiple messages on a single connection</title>
47272 <para>
47273 The sending of multiple messages over a single TCP/IP connection can arise in
47274 two ways:
47275 </para>
47276 <itemizedlist>
47277 <listitem>
47278 <para>
47279 If a message contains more than <option>max_rcpt</option> (see below) addresses that are
47280 routed to the same host, more than one copy of the message has to be sent to
47281 that host. In this situation, multiple copies may be sent in a single run of
47282 the <command>smtp</command> transport over a single TCP/IP connection. (What Exim actually
47283 does when it has too many addresses to send in one message also depends on the
47284 value of the global <option>remote_max_parallel</option> option. Details are given in
47285 section <xref linkend="SECToutSMTPTCP"/>.)
47286 </para>
47287 </listitem>
47288 <listitem>
47289 <para>
47290 <indexterm role="concept">
47291 <primary>hints database</primary>
47292 <secondary>remembering routing</secondary>
47293 </indexterm>
47294 When a message has been successfully delivered over a TCP/IP connection, Exim
47295 looks in its hints database to see if there are any other messages awaiting a
47296 connection to the same host. If there are, a new delivery process is started
47297 for one of them, and the current TCP/IP connection is passed on to it. The new
47298 process may in turn send multiple copies and possibly create yet another
47299 process.
47300 </para>
47301 </listitem>
47302 </itemizedlist>
47303 <para>
47304 For each copy sent over the same TCP/IP connection, a sequence counter is
47305 incremented, and if it ever gets to the value of <option>connection_max_messages</option>,
47306 no further messages are sent over that connection.
47307 </para>
47308 </section>
47309 <section id="SECID145">
47310 <title>Use of the $host and $host_address variables</title>
47311 <para>
47312 <indexterm role="variable">
47313 <primary><varname>$host</varname></primary>
47314 </indexterm>
47315 <indexterm role="variable">
47316 <primary><varname>$host_address</varname></primary>
47317 </indexterm>
47318 At the start of a run of the <command>smtp</command> transport, the values of <varname>$host</varname> and
47319 <varname>$host_address</varname> are the name and IP address of the first host on the host list
47320 passed by the router. However, when the transport is about to connect to a
47321 specific host, and while it is connected to that host, <varname>$host</varname> and
47322 <varname>$host_address</varname> are set to the values for that host. These are the values
47323 that are in force when the <option>helo_data</option>, <option>hosts_try_auth</option>, <option>interface</option>,
47324 <option>serialize_hosts</option>, and the various TLS options are expanded.
47325 </para>
47326 </section>
47327 <section id="usecippeer">
47328 <title>Use of $tls_cipher and $tls_peerdn</title>
47329 <para>
47330 <indexterm role="variable">
47331 <primary><varname>$tls_bits</varname></primary>
47332 </indexterm>
47333 <indexterm role="variable">
47334 <primary><varname>$tls_cipher</varname></primary>
47335 </indexterm>
47336 <indexterm role="variable">
47337 <primary><varname>$tls_peerdn</varname></primary>
47338 </indexterm>
47339 <indexterm role="variable">
47340 <primary><varname>$tls_sni</varname></primary>
47341 </indexterm>
47342 At the start of a run of the <command>smtp</command> transport, the values of <varname>$tls_bits</varname>,
47343 <varname>$tls_cipher</varname>, <varname>$tls_peerdn</varname> and <varname>$tls_sni</varname>
47344 are the values that were set when the message was received.
47345 These are the values that are used for options that are expanded before any
47346 SMTP connections are made. Just before each connection is made, these four
47347 variables are emptied. If TLS is subsequently started, they are set to the
47348 appropriate values for the outgoing connection, and these are the values that
47349 are in force when any authenticators are run and when the
47350 <option>authenticated_sender</option> option is expanded.
47351 </para>
47352 <para>
47353 These variables are deprecated in favour of <varname>$tls_in_cipher</varname> et. al.
47354 and will be removed in a future release.
47355 </para>
47356 </section>
47357 <section id="SECID146">
47358 <title>Private options for smtp</title>
47359 <para>
47360 <indexterm role="concept">
47361 <primary>options</primary>
47362 <secondary><command>smtp</command> transport</secondary>
47363 </indexterm>
47364 The private options of the <command>smtp</command> transport are as follows:
47365 </para>
47366 <para>
47367 <indexterm role="option">
47368 <primary><option>address_retry_include_sender</option></primary>
47369 </indexterm>
47370 </para>
47371 <informaltable frame="all">
47372 <tgroup cols="4" colsep="0" rowsep="0">
47373 <colspec colwidth="8*" align="left"/>
47374 <colspec colwidth="6*" align="center"/>
47375 <colspec colwidth="6*" align="center"/>
47376 <colspec colwidth="6*" align="right"/>
47377 <tbody>
47378 <row>
47379 <entry><option>address_retry_include_sender</option></entry>
47380 <entry>Use: <emphasis>smtp</emphasis></entry>
47381 <entry>Type: <emphasis>boolean</emphasis></entry>
47382 <entry>Default: <emphasis>true</emphasis></entry>
47383 </row>
47384 </tbody>
47385 </tgroup>
47386 </informaltable>
47387 <para>
47388 <indexterm role="concept">
47389 <primary>4<emphasis>xx</emphasis> responses</primary>
47390 <secondary>retrying after</secondary>
47391 </indexterm>
47392 When an address is delayed because of a 4<emphasis>xx</emphasis> response to a RCPT command, it
47393 is the combination of sender and recipient that is delayed in subsequent queue
47394 runs until the retry time is reached. You can delay the recipient without
47395 reference to the sender (which is what earlier versions of Exim did), by
47396 setting <option>address_retry_include_sender</option> false. However, this can lead to
47397 problems with servers that regularly issue 4<emphasis>xx</emphasis> responses to RCPT commands.
47398 </para>
47399 <para>
47400 <indexterm role="option">
47401 <primary><option>allow_localhost</option></primary>
47402 </indexterm>
47403 </para>
47404 <informaltable frame="all">
47405 <tgroup cols="4" colsep="0" rowsep="0">
47406 <colspec colwidth="8*" align="left"/>
47407 <colspec colwidth="6*" align="center"/>
47408 <colspec colwidth="6*" align="center"/>
47409 <colspec colwidth="6*" align="right"/>
47410 <tbody>
47411 <row>
47412 <entry><option>allow_localhost</option></entry>
47413 <entry>Use: <emphasis>smtp</emphasis></entry>
47414 <entry>Type: <emphasis>boolean</emphasis></entry>
47415 <entry>Default: <emphasis>false</emphasis></entry>
47416 </row>
47417 </tbody>
47418 </tgroup>
47419 </informaltable>
47420 <para>
47421 <indexterm role="concept">
47422 <primary>local host</primary>
47423 <secondary>sending to</secondary>
47424 </indexterm>
47425 <indexterm role="concept">
47426 <primary>fallback</primary>
47427 <secondary>hosts specified on transport</secondary>
47428 </indexterm>
47429 When a host specified in <option>hosts</option> or <option>fallback_hosts</option> (see below) turns out
47430 to be the local host, or is listed in <option>hosts_treat_as_local</option>, delivery is
47431 deferred by default. However, if <option>allow_localhost</option> is set, Exim goes on to do
47432 the delivery anyway. This should be used only in special cases when the
47433 configuration ensures that no looping will result (for example, a differently
47434 configured Exim is listening on the port to which the message is sent).
47435 </para>
47436 <para>
47437 <indexterm role="option">
47438 <primary><option>authenticated_sender</option></primary>
47439 </indexterm>
47440 </para>
47441 <informaltable frame="all">
47442 <tgroup cols="4" colsep="0" rowsep="0">
47443 <colspec colwidth="8*" align="left"/>
47444 <colspec colwidth="6*" align="center"/>
47445 <colspec colwidth="6*" align="center"/>
47446 <colspec colwidth="6*" align="right"/>
47447 <tbody>
47448 <row>
47449 <entry><option>authenticated_sender</option></entry>
47450 <entry>Use: <emphasis>smtp</emphasis></entry>
47451 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
47452 <entry>Default: <emphasis>unset</emphasis></entry>
47453 </row>
47454 </tbody>
47455 </tgroup>
47456 </informaltable>
47457 <para>
47458 <indexterm role="concept">
47459 <primary>Cyrus</primary>
47460 </indexterm>
47461 When Exim has authenticated as a client, or if <option>authenticated_sender_force</option>
47462 is true, this option sets a value for the AUTH= item on outgoing MAIL commands,
47463 overriding any existing authenticated sender value. If the string expansion is
47464 forced to fail, the option is ignored. Other expansion failures cause delivery
47465 to be deferred. If the result of expansion is an empty string, that is also
47466 ignored.
47467 </para>
47468 <para>
47469 The expansion happens after the outgoing connection has been made and TLS
47470 started, if required. This means that the <varname>$host</varname>, <varname>$host_address</varname>,
47471 <varname>$tls_out_cipher</varname>, and <varname>$tls_out_peerdn</varname> variables are set according to the
47472 particular connection.
47473 </para>
47474 <para>
47475 If the SMTP session is not authenticated, the expansion of
47476 <option>authenticated_sender</option> still happens (and can cause the delivery to be
47477 deferred if it fails), but no AUTH= item is added to MAIL commands
47478 unless <option>authenticated_sender_force</option> is true.
47479 </para>
47480 <para>
47481 This option allows you to use the <command>smtp</command> transport in LMTP mode to
47482 deliver mail to Cyrus IMAP and provide the proper local part as the
47483 <quote>authenticated sender</quote>, via a setting such as:
47484 </para>
47485 <literallayout class="monospaced">
47486 authenticated_sender = $local_part
47487 </literallayout>
47488 <para>
47489 This removes the need for IMAP subfolders to be assigned special ACLs to
47490 allow direct delivery to those subfolders.
47491 </para>
47492 <para>
47493 Because of expected uses such as that just described for Cyrus (when no
47494 domain is involved), there is no checking on the syntax of the provided
47495 value.
47496 </para>
47497 <para>
47498 <indexterm role="option">
47499 <primary><option>authenticated_sender_force</option></primary>
47500 </indexterm>
47501 </para>
47502 <informaltable frame="all">
47503 <tgroup cols="4" colsep="0" rowsep="0">
47504 <colspec colwidth="8*" align="left"/>
47505 <colspec colwidth="6*" align="center"/>
47506 <colspec colwidth="6*" align="center"/>
47507 <colspec colwidth="6*" align="right"/>
47508 <tbody>
47509 <row>
47510 <entry><option>authenticated_sender_force</option></entry>
47511 <entry>Use: <emphasis>smtp</emphasis></entry>
47512 <entry>Type: <emphasis>boolean</emphasis></entry>
47513 <entry>Default: <emphasis>false</emphasis></entry>
47514 </row>
47515 </tbody>
47516 </tgroup>
47517 </informaltable>
47518 <para>
47519 If this option is set true, the <option>authenticated_sender</option> option&#x2019;s value
47520 is used for the AUTH= item on outgoing MAIL commands, even if Exim has not
47521 authenticated as a client.
47522 </para>
47523 <para>
47524 <indexterm role="option">
47525 <primary><option>command_timeout</option></primary>
47526 </indexterm>
47527 </para>
47528 <informaltable frame="all">
47529 <tgroup cols="4" colsep="0" rowsep="0">
47530 <colspec colwidth="8*" align="left"/>
47531 <colspec colwidth="6*" align="center"/>
47532 <colspec colwidth="6*" align="center"/>
47533 <colspec colwidth="6*" align="right"/>
47534 <tbody>
47535 <row>
47536 <entry><option>command_timeout</option></entry>
47537 <entry>Use: <emphasis>smtp</emphasis></entry>
47538 <entry>Type: <emphasis>time</emphasis></entry>
47539 <entry>Default: <emphasis>5m</emphasis></entry>
47540 </row>
47541 </tbody>
47542 </tgroup>
47543 </informaltable>
47544 <para>
47545 This sets a timeout for receiving a response to an SMTP command that has been
47546 sent out. It is also used when waiting for the initial banner line from the
47547 remote host. Its value must not be zero.
47548 </para>
47549 <para>
47550 <indexterm role="option">
47551 <primary><option>connect_timeout</option></primary>
47552 </indexterm>
47553 </para>
47554 <informaltable frame="all">
47555 <tgroup cols="4" colsep="0" rowsep="0">
47556 <colspec colwidth="8*" align="left"/>
47557 <colspec colwidth="6*" align="center"/>
47558 <colspec colwidth="6*" align="center"/>
47559 <colspec colwidth="6*" align="right"/>
47560 <tbody>
47561 <row>
47562 <entry><option>connect_timeout</option></entry>
47563 <entry>Use: <emphasis>smtp</emphasis></entry>
47564 <entry>Type: <emphasis>time</emphasis></entry>
47565 <entry>Default: <emphasis>5m</emphasis></entry>
47566 </row>
47567 </tbody>
47568 </tgroup>
47569 </informaltable>
47570 <para>
47571 This sets a timeout for the <function>connect()</function> function, which sets up a TCP/IP call
47572 to a remote host. A setting of zero allows the system timeout (typically
47573 several minutes) to act. To have any effect, the value of this option must be
47574 less than the system timeout. However, it has been observed that on some
47575 systems there is no system timeout, which is why the default value for this
47576 option is 5 minutes, a value recommended by RFC 1123.
47577 </para>
47578 <para>
47579 <indexterm role="option">
47580 <primary><option>connection_max_messages</option></primary>
47581 </indexterm>
47582 </para>
47583 <informaltable frame="all">
47584 <tgroup cols="4" colsep="0" rowsep="0">
47585 <colspec colwidth="8*" align="left"/>
47586 <colspec colwidth="6*" align="center"/>
47587 <colspec colwidth="6*" align="center"/>
47588 <colspec colwidth="6*" align="right"/>
47589 <tbody>
47590 <row>
47591 <entry><option>connection_max_messages</option></entry>
47592 <entry>Use: <emphasis>smtp</emphasis></entry>
47593 <entry>Type: <emphasis>integer</emphasis></entry>
47594 <entry>Default: <emphasis>500</emphasis></entry>
47595 </row>
47596 </tbody>
47597 </tgroup>
47598 </informaltable>
47599 <para>
47600 <indexterm role="concept">
47601 <primary>SMTP</primary>
47602 <secondary>passed connection</secondary>
47603 </indexterm>
47604 <indexterm role="concept">
47605 <primary>SMTP</primary>
47606 <secondary>multiple deliveries</secondary>
47607 </indexterm>
47608 <indexterm role="concept">
47609 <primary>multiple SMTP deliveries</primary>
47610 </indexterm>
47611 This controls the maximum number of separate message deliveries that are sent
47612 over a single TCP/IP connection. If the value is zero, there is no limit.
47613 For testing purposes, this value can be overridden by the <option>-oB</option> command line
47614 option.
47615 </para>
47616 <para>
47617 <indexterm role="option">
47618 <primary><option>dane_require_tls_ciphers</option></primary>
47619 </indexterm>
47620 </para>
47621 <informaltable frame="all">
47622 <tgroup cols="4" colsep="0" rowsep="0">
47623 <colspec colwidth="8*" align="left"/>
47624 <colspec colwidth="6*" align="center"/>
47625 <colspec colwidth="6*" align="center"/>
47626 <colspec colwidth="6*" align="right"/>
47627 <tbody>
47628 <row>
47629 <entry><option>dane_require_tls_ciphers</option></entry>
47630 <entry>Use: <emphasis>smtp</emphasis></entry>
47631 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
47632 <entry>Default: <emphasis>unset</emphasis></entry>
47633 </row>
47634 </tbody>
47635 </tgroup>
47636 </informaltable>
47637 <para>
47638 <indexterm role="concept">
47639 <primary>TLS</primary>
47640 <secondary>requiring specific ciphers for DANE</secondary>
47641 </indexterm>
47642 <indexterm role="concept">
47643 <primary>cipher</primary>
47644 <secondary>requiring specific</secondary>
47645 </indexterm>
47646 <indexterm role="concept">
47647 <primary>DANE</primary>
47648 <secondary>TLS ciphers</secondary>
47649 </indexterm>
47650 This option may be used to override <option>tls_require_ciphers</option> for connections
47651 where DANE has been determined to be in effect.
47652 If not set, then <option>tls_require_ciphers</option> will be used.
47653 Normal SMTP delivery is not able to make strong demands of TLS cipher
47654 configuration, because delivery will fall back to plaintext.  Once DANE has
47655 been determined to be in effect, there is no plaintext fallback and making the
47656 TLS cipherlist configuration stronger will increase security, rather than
47657 counter-intuitively decreasing it.
47658 If the option expands to be empty or is forced to fail, then it will
47659 be treated as unset and <option>tls_require_ciphers</option> will be used instead.
47660 </para>
47661 <para>
47662 <indexterm role="option">
47663 <primary><option>data_timeout</option></primary>
47664 </indexterm>
47665 </para>
47666 <informaltable frame="all">
47667 <tgroup cols="4" colsep="0" rowsep="0">
47668 <colspec colwidth="8*" align="left"/>
47669 <colspec colwidth="6*" align="center"/>
47670 <colspec colwidth="6*" align="center"/>
47671 <colspec colwidth="6*" align="right"/>
47672 <tbody>
47673 <row>
47674 <entry><option>data_timeout</option></entry>
47675 <entry>Use: <emphasis>smtp</emphasis></entry>
47676 <entry>Type: <emphasis>time</emphasis></entry>
47677 <entry>Default: <emphasis>5m</emphasis></entry>
47678 </row>
47679 </tbody>
47680 </tgroup>
47681 </informaltable>
47682 <para>
47683 This sets a timeout for the transmission of each block in the data portion of
47684 the message. As a result, the overall timeout for a message depends on the size
47685 of the message. Its value must not be zero. See also <option>final_timeout</option>.
47686 </para>
47687 <para>
47688 <indexterm role="option">
47689 <primary><option>dkim_canon</option></primary>
47690 </indexterm>
47691 </para>
47692 <informaltable frame="all">
47693 <tgroup cols="4" colsep="0" rowsep="0">
47694 <colspec colwidth="8*" align="left"/>
47695 <colspec colwidth="6*" align="center"/>
47696 <colspec colwidth="6*" align="center"/>
47697 <colspec colwidth="6*" align="right"/>
47698 <tbody>
47699 <row>
47700 <entry><option>dkim_canon</option></entry>
47701 <entry>Use: <emphasis>smtp</emphasis></entry>
47702 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
47703 <entry>Default: <emphasis>unset</emphasis></entry>
47704 </row>
47705 </tbody>
47706 </tgroup>
47707 </informaltable>
47708 <para>
47709 DKIM signing option.  For details see section <xref linkend="SECDKIMSIGN"/>.
47710 <indexterm role="option">
47711 <primary><option>unset</option></primary>
47712 </indexterm>
47713 </para>
47714 <informaltable frame="all">
47715 <tgroup cols="4" colsep="0" rowsep="0">
47716 <colspec colwidth="8*" align="left"/>
47717 <colspec colwidth="6*" align="center"/>
47718 <colspec colwidth="6*" align="center"/>
47719 <colspec colwidth="6*" align="right"/>
47720 <tbody>
47721 <row>
47722 <entry><option>dkim_domain</option></entry>
47723 <entry>Use: <emphasis>smtp</emphasis></entry>
47724 <entry>Type: <emphasis>string</emphasis></entry>
47725 <entry>Default: <emphasis>list</emphasis>&dagger;<emphasis></emphasis></entry>
47726 </row>
47727 </tbody>
47728 </tgroup>
47729 </informaltable>
47730 <para>
47731 DKIM signing option.  For details see section <xref linkend="SECDKIMSIGN"/>.
47732 <indexterm role="option">
47733 <primary><option>dkim_hash</option></primary>
47734 </indexterm>
47735 </para>
47736 <informaltable frame="all">
47737 <tgroup cols="4" colsep="0" rowsep="0">
47738 <colspec colwidth="8*" align="left"/>
47739 <colspec colwidth="6*" align="center"/>
47740 <colspec colwidth="6*" align="center"/>
47741 <colspec colwidth="6*" align="right"/>
47742 <tbody>
47743 <row>
47744 <entry><option>dkim_hash</option></entry>
47745 <entry>Use: <emphasis>smtp</emphasis></entry>
47746 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
47747 <entry>Default: <emphasis>sha256</emphasis></entry>
47748 </row>
47749 </tbody>
47750 </tgroup>
47751 </informaltable>
47752 <para>
47753 DKIM signing option.  For details see section <xref linkend="SECDKIMSIGN"/>.
47754 <indexterm role="option">
47755 <primary><option>dkim_identity</option></primary>
47756 </indexterm>
47757 </para>
47758 <informaltable frame="all">
47759 <tgroup cols="4" colsep="0" rowsep="0">
47760 <colspec colwidth="8*" align="left"/>
47761 <colspec colwidth="6*" align="center"/>
47762 <colspec colwidth="6*" align="center"/>
47763 <colspec colwidth="6*" align="right"/>
47764 <tbody>
47765 <row>
47766 <entry><option>dkim_identity</option></entry>
47767 <entry>Use: <emphasis>smtp</emphasis></entry>
47768 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
47769 <entry>Default: <emphasis>unset</emphasis></entry>
47770 </row>
47771 </tbody>
47772 </tgroup>
47773 </informaltable>
47774 <para>
47775 DKIM signing option.  For details see section <xref linkend="SECDKIMSIGN"/>.
47776 <indexterm role="option">
47777 <primary><option>dkim_private_key</option></primary>
47778 </indexterm>
47779 </para>
47780 <informaltable frame="all">
47781 <tgroup cols="4" colsep="0" rowsep="0">
47782 <colspec colwidth="8*" align="left"/>
47783 <colspec colwidth="6*" align="center"/>
47784 <colspec colwidth="6*" align="center"/>
47785 <colspec colwidth="6*" align="right"/>
47786 <tbody>
47787 <row>
47788 <entry><option>dkim_private_key</option></entry>
47789 <entry>Use: <emphasis>smtp</emphasis></entry>
47790 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
47791 <entry>Default: <emphasis>unset</emphasis></entry>
47792 </row>
47793 </tbody>
47794 </tgroup>
47795 </informaltable>
47796 <para>
47797 DKIM signing option.  For details see section <xref linkend="SECDKIMSIGN"/>.
47798 <indexterm role="option">
47799 <primary><option>dkim_selector</option></primary>
47800 </indexterm>
47801 </para>
47802 <informaltable frame="all">
47803 <tgroup cols="4" colsep="0" rowsep="0">
47804 <colspec colwidth="8*" align="left"/>
47805 <colspec colwidth="6*" align="center"/>
47806 <colspec colwidth="6*" align="center"/>
47807 <colspec colwidth="6*" align="right"/>
47808 <tbody>
47809 <row>
47810 <entry><option>dkim_selector</option></entry>
47811 <entry>Use: <emphasis>smtp</emphasis></entry>
47812 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
47813 <entry>Default: <emphasis>unset</emphasis></entry>
47814 </row>
47815 </tbody>
47816 </tgroup>
47817 </informaltable>
47818 <para>
47819 DKIM signing option.  For details see section <xref linkend="SECDKIMSIGN"/>.
47820 <indexterm role="option">
47821 <primary><option>dkim_strict</option></primary>
47822 </indexterm>
47823 </para>
47824 <informaltable frame="all">
47825 <tgroup cols="4" colsep="0" rowsep="0">
47826 <colspec colwidth="8*" align="left"/>
47827 <colspec colwidth="6*" align="center"/>
47828 <colspec colwidth="6*" align="center"/>
47829 <colspec colwidth="6*" align="right"/>
47830 <tbody>
47831 <row>
47832 <entry><option>dkim_strict</option></entry>
47833 <entry>Use: <emphasis>smtp</emphasis></entry>
47834 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
47835 <entry>Default: <emphasis>unset</emphasis></entry>
47836 </row>
47837 </tbody>
47838 </tgroup>
47839 </informaltable>
47840 <para>
47841 DKIM signing option.  For details see section <xref linkend="SECDKIMSIGN"/>.
47842 <indexterm role="option">
47843 <primary><option>dkim_sign_headers</option></primary>
47844 </indexterm>
47845 </para>
47846 <informaltable frame="all">
47847 <tgroup cols="4" colsep="0" rowsep="0">
47848 <colspec colwidth="8*" align="left"/>
47849 <colspec colwidth="6*" align="center"/>
47850 <colspec colwidth="6*" align="center"/>
47851 <colspec colwidth="6*" align="right"/>
47852 <tbody>
47853 <row>
47854 <entry><option>dkim_sign_headers</option></entry>
47855 <entry>Use: <emphasis>smtp</emphasis></entry>
47856 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
47857 <entry>Default: <emphasis>per RFC</emphasis></entry>
47858 </row>
47859 </tbody>
47860 </tgroup>
47861 </informaltable>
47862 <para>
47863 DKIM signing option.  For details see section <xref linkend="SECDKIMSIGN"/>.
47864 <indexterm role="option">
47865 <primary><option>dkim_timestamps</option></primary>
47866 </indexterm>
47867 </para>
47868 <informaltable frame="all">
47869 <tgroup cols="4" colsep="0" rowsep="0">
47870 <colspec colwidth="8*" align="left"/>
47871 <colspec colwidth="6*" align="center"/>
47872 <colspec colwidth="6*" align="center"/>
47873 <colspec colwidth="6*" align="right"/>
47874 <tbody>
47875 <row>
47876 <entry><option>dkim_timestamps</option></entry>
47877 <entry>Use: <emphasis>smtp</emphasis></entry>
47878 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
47879 <entry>Default: <emphasis>unset</emphasis></entry>
47880 </row>
47881 </tbody>
47882 </tgroup>
47883 </informaltable>
47884 <para>
47885 DKIM signing option.  For details see section <xref linkend="SECDKIMSIGN"/>.
47886 </para>
47887 <para>
47888 <indexterm role="option">
47889 <primary><option>delay_after_cutoff</option></primary>
47890 </indexterm>
47891 </para>
47892 <informaltable frame="all">
47893 <tgroup cols="4" colsep="0" rowsep="0">
47894 <colspec colwidth="8*" align="left"/>
47895 <colspec colwidth="6*" align="center"/>
47896 <colspec colwidth="6*" align="center"/>
47897 <colspec colwidth="6*" align="right"/>
47898 <tbody>
47899 <row>
47900 <entry><option>delay_after_cutoff</option></entry>
47901 <entry>Use: <emphasis>smtp</emphasis></entry>
47902 <entry>Type: <emphasis>boolean</emphasis></entry>
47903 <entry>Default: <emphasis>true</emphasis></entry>
47904 </row>
47905 </tbody>
47906 </tgroup>
47907 </informaltable>
47908 <para>
47909 <indexterm role="concept">
47910 <primary>final cutoff</primary>
47911 <secondary>retries, controlling</secondary>
47912 </indexterm>
47913 <indexterm role="concept">
47914 <primary>retry</primary>
47915 <secondary>final cutoff</secondary>
47916 </indexterm>
47917 This option controls what happens when all remote IP addresses for a given
47918 domain have been inaccessible for so long that they have passed their retry
47919 cutoff times.
47920 </para>
47921 <para>
47922 In the default state, if the next retry time has not been reached for any of
47923 them, the address is bounced without trying any deliveries. In other words,
47924 Exim delays retrying an IP address after the final cutoff time until a new
47925 retry time is reached, and can therefore bounce an address without ever trying
47926 a delivery, when machines have been down for a long time. Some people are
47927 unhappy at this prospect, so...
47928 </para>
47929 <para>
47930 If <option>delay_after_cutoff</option> is set false, Exim behaves differently. If all IP
47931 addresses are past their final cutoff time, Exim tries to deliver to those
47932 IP addresses that have not been tried since the message arrived. If there are
47933 none, of if they all fail, the address is bounced. In other words, it does not
47934 delay when a new message arrives, but immediately tries those expired IP
47935 addresses that haven&#x2019;t been tried since the message arrived. If there is a
47936 continuous stream of messages for the dead hosts, unsetting
47937 <option>delay_after_cutoff</option> means that there will be many more attempts to deliver
47938 to them.
47939 </para>
47940 <para>
47941 <indexterm role="option">
47942 <primary><option>dns_qualify_single</option></primary>
47943 </indexterm>
47944 </para>
47945 <informaltable frame="all">
47946 <tgroup cols="4" colsep="0" rowsep="0">
47947 <colspec colwidth="8*" align="left"/>
47948 <colspec colwidth="6*" align="center"/>
47949 <colspec colwidth="6*" align="center"/>
47950 <colspec colwidth="6*" align="right"/>
47951 <tbody>
47952 <row>
47953 <entry><option>dns_qualify_single</option></entry>
47954 <entry>Use: <emphasis>smtp</emphasis></entry>
47955 <entry>Type: <emphasis>boolean</emphasis></entry>
47956 <entry>Default: <emphasis>true</emphasis></entry>
47957 </row>
47958 </tbody>
47959 </tgroup>
47960 </informaltable>
47961 <para>
47962 If the <option>hosts</option> or <option>fallback_hosts</option> option is being used,
47963 and the <option>gethostbyname</option> option is false,
47964 the RES_DEFNAMES resolver option is set. See the <option>qualify_single</option> option
47965 in chapter <xref linkend="CHAPdnslookup"/> for more details.
47966 </para>
47967 <para>
47968 <indexterm role="option">
47969 <primary><option>dns_search_parents</option></primary>
47970 </indexterm>
47971 </para>
47972 <informaltable frame="all">
47973 <tgroup cols="4" colsep="0" rowsep="0">
47974 <colspec colwidth="8*" align="left"/>
47975 <colspec colwidth="6*" align="center"/>
47976 <colspec colwidth="6*" align="center"/>
47977 <colspec colwidth="6*" align="right"/>
47978 <tbody>
47979 <row>
47980 <entry><option>dns_search_parents</option></entry>
47981 <entry>Use: <emphasis>smtp</emphasis></entry>
47982 <entry>Type: <emphasis>boolean</emphasis></entry>
47983 <entry>Default: <emphasis>false</emphasis></entry>
47984 </row>
47985 </tbody>
47986 </tgroup>
47987 </informaltable>
47988 <para>
47989 If the <option>hosts</option> or <option>fallback_hosts</option> option is being used, and the
47990 <option>gethostbyname</option> option is false, the RES_DNSRCH resolver option is set.
47991 See the <option>search_parents</option> option in chapter <xref linkend="CHAPdnslookup"/> for more
47992 details.
47993 </para>
47994 <para>
47995 <indexterm role="option">
47996 <primary><option>dnssec_request_domains</option></primary>
47997 </indexterm>
47998 </para>
47999 <informaltable frame="all">
48000 <tgroup cols="4" colsep="0" rowsep="0">
48001 <colspec colwidth="8*" align="left"/>
48002 <colspec colwidth="6*" align="center"/>
48003 <colspec colwidth="6*" align="center"/>
48004 <colspec colwidth="6*" align="right"/>
48005 <tbody>
48006 <row>
48007 <entry><option>dnssec_request_domains</option></entry>
48008 <entry>Use: <emphasis>smtp</emphasis></entry>
48009 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
48010 <entry>Default: <emphasis>*</emphasis></entry>
48011 </row>
48012 </tbody>
48013 </tgroup>
48014 </informaltable>
48015 <para>
48016 <indexterm role="concept">
48017 <primary>MX record</primary>
48018 <secondary>security</secondary>
48019 </indexterm>
48020 <indexterm role="concept">
48021 <primary>DNSSEC</primary>
48022 <secondary>MX lookup</secondary>
48023 </indexterm>
48024 <indexterm role="concept">
48025 <primary>security</primary>
48026 <secondary>MX lookup</secondary>
48027 </indexterm>
48028 <indexterm role="concept">
48029 <primary>DNS</primary>
48030 <secondary>DNSSEC</secondary>
48031 </indexterm>
48032 DNS lookups for domains matching <option>dnssec_request_domains</option> will be done with
48033 the dnssec request bit set. Setting this transport option is only useful if the
48034 transport overrides or sets the host names. See the <option>dnssec_request_domains</option>
48035 router option.
48036 </para>
48037 <para>
48038 <indexterm role="option">
48039 <primary><option>dnssec_require_domains</option></primary>
48040 </indexterm>
48041 </para>
48042 <informaltable frame="all">
48043 <tgroup cols="4" colsep="0" rowsep="0">
48044 <colspec colwidth="8*" align="left"/>
48045 <colspec colwidth="6*" align="center"/>
48046 <colspec colwidth="6*" align="center"/>
48047 <colspec colwidth="6*" align="right"/>
48048 <tbody>
48049 <row>
48050 <entry><option>dnssec_require_domains</option></entry>
48051 <entry>Use: <emphasis>smtp</emphasis></entry>
48052 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
48053 <entry>Default: <emphasis>unset</emphasis></entry>
48054 </row>
48055 </tbody>
48056 </tgroup>
48057 </informaltable>
48058 <para>
48059 <indexterm role="concept">
48060 <primary>MX record</primary>
48061 <secondary>security</secondary>
48062 </indexterm>
48063 <indexterm role="concept">
48064 <primary>DNSSEC</primary>
48065 <secondary>MX lookup</secondary>
48066 </indexterm>
48067 <indexterm role="concept">
48068 <primary>security</primary>
48069 <secondary>MX lookup</secondary>
48070 </indexterm>
48071 <indexterm role="concept">
48072 <primary>DNS</primary>
48073 <secondary>DNSSEC</secondary>
48074 </indexterm>
48075 DNS lookups for domains matching <option>dnssec_require_domains</option> will be done with
48076 the dnssec request bit set.  Setting this transport option is only
48077 useful if the transport overrides or sets the host names. See the
48078 <option>dnssec_require_domains</option> router option.
48079 </para>
48080 <para>
48081 <indexterm role="option">
48082 <primary><option>dscp</option></primary>
48083 </indexterm>
48084 </para>
48085 <informaltable frame="all">
48086 <tgroup cols="4" colsep="0" rowsep="0">
48087 <colspec colwidth="8*" align="left"/>
48088 <colspec colwidth="6*" align="center"/>
48089 <colspec colwidth="6*" align="center"/>
48090 <colspec colwidth="6*" align="right"/>
48091 <tbody>
48092 <row>
48093 <entry><option>dscp</option></entry>
48094 <entry>Use: <emphasis>smtp</emphasis></entry>
48095 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
48096 <entry>Default: <emphasis>unset</emphasis></entry>
48097 </row>
48098 </tbody>
48099 </tgroup>
48100 </informaltable>
48101 <para>
48102 <indexterm role="concept">
48103 <primary>DCSP</primary>
48104 <secondary>outbound</secondary>
48105 </indexterm>
48106 This option causes the DSCP value associated with a socket to be set to one
48107 of a number of fixed strings or to numeric value.
48108 The <option>-bI:dscp</option> option may be used to ask Exim which names it knows of.
48109 Common values include <literal>throughput</literal>, <literal>mincost</literal>, and on newer systems
48110 <literal>ef</literal>, <literal>af41</literal>, etc.  Numeric values may be in the range 0 to 0x3F.
48111 </para>
48112 <para>
48113 The outbound packets from Exim will be marked with this value in the header
48114 (for IPv4, the TOS field; for IPv6, the TCLASS field); there is no guarantee
48115 that these values will have any effect, not be stripped by networking
48116 equipment, or do much of anything without cooperation with your Network
48117 Engineer and those of all network operators between the source and destination.
48118 </para>
48119 <para>
48120 <indexterm role="option">
48121 <primary><option>fallback_hosts</option></primary>
48122 </indexterm>
48123 </para>
48124 <informaltable frame="all">
48125 <tgroup cols="4" colsep="0" rowsep="0">
48126 <colspec colwidth="8*" align="left"/>
48127 <colspec colwidth="6*" align="center"/>
48128 <colspec colwidth="6*" align="center"/>
48129 <colspec colwidth="6*" align="right"/>
48130 <tbody>
48131 <row>
48132 <entry><option>fallback_hosts</option></entry>
48133 <entry>Use: <emphasis>smtp</emphasis></entry>
48134 <entry>Type: <emphasis>string list</emphasis></entry>
48135 <entry>Default: <emphasis>unset</emphasis></entry>
48136 </row>
48137 </tbody>
48138 </tgroup>
48139 </informaltable>
48140 <para>
48141 <indexterm role="concept">
48142 <primary>fallback</primary>
48143 <secondary>hosts specified on transport</secondary>
48144 </indexterm>
48145 String expansion is not applied to this option. The argument must be a
48146 colon-separated list of host names or IP addresses, optionally also including
48147 port numbers, though the separator can be changed, as described in section
48148 <xref linkend="SECTlistconstruct"/>. Each individual item in the list is the same as an
48149 item in a <option>route_list</option> setting for the <command>manualroute</command> router, as described
48150 in section <xref linkend="SECTformatonehostitem"/>.
48151 </para>
48152 <para>
48153 Fallback hosts can also be specified on routers, which associate them with the
48154 addresses they process. As for the <option>hosts</option> option without <option>hosts_override</option>,
48155 <option>fallback_hosts</option> specified on the transport is used only if the address does
48156 not have its own associated fallback host list. Unlike <option>hosts</option>, a setting of
48157 <option>fallback_hosts</option> on an address is not overridden by <option>hosts_override</option>.
48158 However, <option>hosts_randomize</option> does apply to fallback host lists.
48159 </para>
48160 <para>
48161 If Exim is unable to deliver to any of the hosts for a particular address, and
48162 the errors are not permanent rejections, the address is put on a separate
48163 transport queue with its host list replaced by the fallback hosts, unless the
48164 address was routed via MX records and the current host was in the original MX
48165 list. In that situation, the fallback host list is not used.
48166 </para>
48167 <para>
48168 Once normal deliveries are complete, the fallback queue is delivered by
48169 re-running the same transports with the new host lists. If several failing
48170 addresses have the same fallback hosts (and <option>max_rcpt</option> permits it), a single
48171 copy of the message is sent.
48172 </para>
48173 <para>
48174 The resolution of the host names on the fallback list is controlled by the
48175 <option>gethostbyname</option> option, as for the <option>hosts</option> option. Fallback hosts apply
48176 both to cases when the host list comes with the address and when it is taken
48177 from <option>hosts</option>. This option provides a <quote>use a smart host only if delivery
48178 fails</quote> facility.
48179 </para>
48180 <para>
48181 <indexterm role="option">
48182 <primary><option>final_timeout</option></primary>
48183 </indexterm>
48184 </para>
48185 <informaltable frame="all">
48186 <tgroup cols="4" colsep="0" rowsep="0">
48187 <colspec colwidth="8*" align="left"/>
48188 <colspec colwidth="6*" align="center"/>
48189 <colspec colwidth="6*" align="center"/>
48190 <colspec colwidth="6*" align="right"/>
48191 <tbody>
48192 <row>
48193 <entry><option>final_timeout</option></entry>
48194 <entry>Use: <emphasis>smtp</emphasis></entry>
48195 <entry>Type: <emphasis>time</emphasis></entry>
48196 <entry>Default: <emphasis>10m</emphasis></entry>
48197 </row>
48198 </tbody>
48199 </tgroup>
48200 </informaltable>
48201 <para>
48202 This is the timeout that applies while waiting for the response to the final
48203 line containing just <quote>.</quote> that terminates a message. Its value must not be
48204 zero.
48205 </para>
48206 <para>
48207 <indexterm role="option">
48208 <primary><option>gethostbyname</option></primary>
48209 </indexterm>
48210 </para>
48211 <informaltable frame="all">
48212 <tgroup cols="4" colsep="0" rowsep="0">
48213 <colspec colwidth="8*" align="left"/>
48214 <colspec colwidth="6*" align="center"/>
48215 <colspec colwidth="6*" align="center"/>
48216 <colspec colwidth="6*" align="right"/>
48217 <tbody>
48218 <row>
48219 <entry><option>gethostbyname</option></entry>
48220 <entry>Use: <emphasis>smtp</emphasis></entry>
48221 <entry>Type: <emphasis>boolean</emphasis></entry>
48222 <entry>Default: <emphasis>false</emphasis></entry>
48223 </row>
48224 </tbody>
48225 </tgroup>
48226 </informaltable>
48227 <para>
48228 If this option is true when the <option>hosts</option> and/or <option>fallback_hosts</option> options are
48229 being used, names are looked up using <function>gethostbyname()</function>
48230 (or <function>getipnodebyname()</function> when available)
48231 instead of using the DNS. Of course, that function may in fact use the DNS, but
48232 it may also consult other sources of information such as <filename>/etc/hosts</filename>.
48233 </para>
48234 <para>
48235 <indexterm role="option">
48236 <primary><option>gnutls_compat_mode</option></primary>
48237 </indexterm>
48238 </para>
48239 <informaltable frame="all">
48240 <tgroup cols="4" colsep="0" rowsep="0">
48241 <colspec colwidth="8*" align="left"/>
48242 <colspec colwidth="6*" align="center"/>
48243 <colspec colwidth="6*" align="center"/>
48244 <colspec colwidth="6*" align="right"/>
48245 <tbody>
48246 <row>
48247 <entry><option>gnutls_compat_mode</option></entry>
48248 <entry>Use: <emphasis>smtp</emphasis></entry>
48249 <entry>Type: <emphasis>boolean</emphasis></entry>
48250 <entry>Default: <emphasis>unset</emphasis></entry>
48251 </row>
48252 </tbody>
48253 </tgroup>
48254 </informaltable>
48255 <para>
48256 This option controls whether GnuTLS is used in compatibility mode in an Exim
48257 server. This reduces security slightly, but improves interworking with older
48258 implementations of TLS.
48259 </para>
48260 <para>
48261 <indexterm role="option">
48262 <primary><option>helo_data</option></primary>
48263 </indexterm>
48264 </para>
48265 <informaltable frame="all">
48266 <tgroup cols="4" colsep="0" rowsep="0">
48267 <colspec colwidth="8*" align="left"/>
48268 <colspec colwidth="6*" align="center"/>
48269 <colspec colwidth="6*" align="center"/>
48270 <colspec colwidth="6*" align="right"/>
48271 <tbody>
48272 <row>
48273 <entry><option>helo_data</option></entry>
48274 <entry>Use: <emphasis>smtp</emphasis></entry>
48275 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
48276 <entry>Default: <emphasis>see below</emphasis></entry>
48277 </row>
48278 </tbody>
48279 </tgroup>
48280 </informaltable>
48281 <para>
48282 <indexterm role="concept">
48283 <primary>HELO</primary>
48284 <secondary>argument, setting</secondary>
48285 </indexterm>
48286 <indexterm role="concept">
48287 <primary>EHLO</primary>
48288 <secondary>argument, setting</secondary>
48289 </indexterm>
48290 <indexterm role="concept">
48291 <primary>LHLO argument setting</primary>
48292 </indexterm>
48293 The value of this option is expanded after a connection to a another host has
48294 been set up. The result is used as the argument for the EHLO, HELO, or LHLO
48295 command that starts the outgoing SMTP or LMTP session. The default value of the
48296 option is:
48297 </para>
48298 <literallayout class="monospaced">
48299 $primary_hostname
48300 </literallayout>
48301 <para>
48302 During the expansion, the variables <varname>$host</varname> and <varname>$host_address</varname> are set to
48303 the identity of the remote host, and the variables <varname>$sending_ip_address</varname> and
48304 <varname>$sending_port</varname> are set to the local IP address and port number that are being
48305 used. These variables can be used to generate different values for different
48306 servers or different local IP addresses. For example, if you want the string
48307 that is used for <option>helo_data</option> to be obtained by a DNS lookup of the outgoing
48308 interface address, you could use this:
48309 </para>
48310 <literallayout class="monospaced">
48311 helo_data = ${lookup dnsdb{ptr=$sending_ip_address}{$value}\
48312   {$primary_hostname}}
48313 </literallayout>
48314 <para>
48315 The use of <option>helo_data</option> applies both to sending messages and when doing
48316 callouts.
48317 </para>
48318 <para>
48319 <indexterm role="option">
48320 <primary><option>hosts</option></primary>
48321 </indexterm>
48322 </para>
48323 <informaltable frame="all">
48324 <tgroup cols="4" colsep="0" rowsep="0">
48325 <colspec colwidth="8*" align="left"/>
48326 <colspec colwidth="6*" align="center"/>
48327 <colspec colwidth="6*" align="center"/>
48328 <colspec colwidth="6*" align="right"/>
48329 <tbody>
48330 <row>
48331 <entry><option>hosts</option></entry>
48332 <entry>Use: <emphasis>smtp</emphasis></entry>
48333 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
48334 <entry>Default: <emphasis>unset</emphasis></entry>
48335 </row>
48336 </tbody>
48337 </tgroup>
48338 </informaltable>
48339 <para>
48340 Hosts are associated with an address by a router such as <command>dnslookup</command>, which
48341 finds the hosts by looking up the address domain in the DNS, or by
48342 <command>manualroute</command>, which has lists of hosts in its configuration. However,
48343 email addresses can be passed to the <command>smtp</command> transport by any router, and not
48344 all of them can provide an associated list of hosts.
48345 </para>
48346 <para>
48347 The <option>hosts</option> option specifies a list of hosts to be used if the address being
48348 processed does not have any hosts associated with it. The hosts specified by
48349 <option>hosts</option> are also used, whether or not the address has its own hosts, if
48350 <option>hosts_override</option> is set.
48351 </para>
48352 <para>
48353 The string is first expanded, before being interpreted as a colon-separated
48354 list of host names or IP addresses, possibly including port numbers. The
48355 separator may be changed to something other than colon, as described in section
48356 <xref linkend="SECTlistconstruct"/>. Each individual item in the list is the same as an
48357 item in a <option>route_list</option> setting for the <command>manualroute</command> router, as described
48358 in section <xref linkend="SECTformatonehostitem"/>. However, note that the <literal>/MX</literal> facility
48359 of the <command>manualroute</command> router is not available here.
48360 </para>
48361 <para>
48362 If the expansion fails, delivery is deferred. Unless the failure was caused by
48363 the inability to complete a lookup, the error is logged to the panic log as
48364 well as the main log. Host names are looked up either by searching directly for
48365 address records in the DNS or by calling <function>gethostbyname()</function> (or
48366 <function>getipnodebyname()</function> when available), depending on the setting of the
48367 <option>gethostbyname</option> option. When Exim is compiled with IPv6 support, if a host
48368 that is looked up in the DNS has both IPv4 and IPv6 addresses, both types of
48369 address are used.
48370 </para>
48371 <para>
48372 During delivery, the hosts are tried in order, subject to their retry status,
48373 unless <option>hosts_randomize</option> is set.
48374 </para>
48375 <para>
48376 <indexterm role="option">
48377 <primary><option>hosts_avoid_esmtp</option></primary>
48378 </indexterm>
48379 </para>
48380 <informaltable frame="all">
48381 <tgroup cols="4" colsep="0" rowsep="0">
48382 <colspec colwidth="8*" align="left"/>
48383 <colspec colwidth="6*" align="center"/>
48384 <colspec colwidth="6*" align="center"/>
48385 <colspec colwidth="6*" align="right"/>
48386 <tbody>
48387 <row>
48388 <entry><option>hosts_avoid_esmtp</option></entry>
48389 <entry>Use: <emphasis>smtp</emphasis></entry>
48390 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
48391 <entry>Default: <emphasis>unset</emphasis></entry>
48392 </row>
48393 </tbody>
48394 </tgroup>
48395 </informaltable>
48396 <para>
48397 <indexterm role="concept">
48398 <primary>ESMTP, avoiding use of</primary>
48399 </indexterm>
48400 <indexterm role="concept">
48401 <primary>HELO</primary>
48402 <secondary>forcing use of</secondary>
48403 </indexterm>
48404 <indexterm role="concept">
48405 <primary>EHLO</primary>
48406 <secondary>avoiding use of</secondary>
48407 </indexterm>
48408 <indexterm role="concept">
48409 <primary>PIPELINING</primary>
48410 <secondary>avoiding the use of</secondary>
48411 </indexterm>
48412 This option is for use with broken hosts that announce ESMTP facilities (for
48413 example, PIPELINING) and then fail to implement them properly. When a host
48414 matches <option>hosts_avoid_esmtp</option>, Exim sends HELO rather than EHLO at the
48415 start of the SMTP session. This means that it cannot use any of the ESMTP
48416 facilities such as AUTH, PIPELINING, SIZE, and STARTTLS.
48417 </para>
48418 <para>
48419 <indexterm role="option">
48420 <primary><option>hosts_avoid_pipelining</option></primary>
48421 </indexterm>
48422 </para>
48423 <informaltable frame="all">
48424 <tgroup cols="4" colsep="0" rowsep="0">
48425 <colspec colwidth="8*" align="left"/>
48426 <colspec colwidth="6*" align="center"/>
48427 <colspec colwidth="6*" align="center"/>
48428 <colspec colwidth="6*" align="right"/>
48429 <tbody>
48430 <row>
48431 <entry><option>hosts_avoid_pipelining</option></entry>
48432 <entry>Use: <emphasis>smtp</emphasis></entry>
48433 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
48434 <entry>Default: <emphasis>unset</emphasis></entry>
48435 </row>
48436 </tbody>
48437 </tgroup>
48438 </informaltable>
48439 <para>
48440 <indexterm role="concept">
48441 <primary>PIPELINING</primary>
48442 <secondary>avoiding the use of</secondary>
48443 </indexterm>
48444 Exim will not use the SMTP PIPELINING extension when delivering to any host
48445 that matches this list, even if the server host advertises PIPELINING support.
48446 </para>
48447 <para revisionflag="changed">
48448 <indexterm role="option">
48449 <primary><option>hosts_pipe_connect</option></primary>
48450 </indexterm>
48451 </para>
48452 <informaltable frame="all" revisionflag="changed">
48453 <tgroup cols="4" colsep="0" rowsep="0">
48454 <colspec colwidth="8*" align="left"/>
48455 <colspec colwidth="6*" align="center"/>
48456 <colspec colwidth="6*" align="center"/>
48457 <colspec colwidth="6*" align="right"/>
48458 <tbody>
48459 <row>
48460 <entry><option>hosts_pipe_connect</option></entry>
48461 <entry>Use: <emphasis>smtp</emphasis></entry>
48462 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
48463 <entry>Default: <emphasis>unset</emphasis></entry>
48464 </row>
48465 </tbody>
48466 </tgroup>
48467 </informaltable>
48468 <para revisionflag="changed">
48469 <indexterm role="concept">
48470 <primary>pipelining</primary>
48471 <secondary>early connection</secondary>
48472 </indexterm>
48473 <indexterm role="concept">
48474 <primary>pipelining</primary>
48475 <secondary>PIPE_CONNECT</secondary>
48476 </indexterm>
48477 If Exim is built with the SUPPORT_PIPE_CONNECT build option
48478 this option controls which to hosts the facility watched for
48479 and recorded, and used for subsequent connections.
48480 </para>
48481 <para revisionflag="changed">
48482 The retry hints database is used for the record,
48483 and records are subject to the <option>retry_data_expire</option> option.
48484 When used, the pipelining saves on roundtrip times.
48485 It also turns SMTP into a client-first protocol
48486 so combines well with TCP Fast Open.
48487 </para>
48488 <para revisionflag="changed">
48489 See also the <option>pipelining_connect_advertise_hosts</option> main option.
48490 </para>
48491 <para revisionflag="changed">
48492 Note:
48493 When the facility is used, the transport <option>helo_data</option> option
48494 will be expanded before the <varname>$sending_ip_address</varname> variable
48495 is filled in.
48496 A check is made for the use of that variable, without the
48497 presence of a <quote>def:</quote> test on it, but suitably complex coding
48498 can avoid the check and produce unexpected results.
48499 You have been warned.
48500 </para>
48501 <para>
48502 <indexterm role="option">
48503 <primary><option>hosts_avoid_tls</option></primary>
48504 </indexterm>
48505 </para>
48506 <informaltable frame="all">
48507 <tgroup cols="4" colsep="0" rowsep="0">
48508 <colspec colwidth="8*" align="left"/>
48509 <colspec colwidth="6*" align="center"/>
48510 <colspec colwidth="6*" align="center"/>
48511 <colspec colwidth="6*" align="right"/>
48512 <tbody>
48513 <row>
48514 <entry><option>hosts_avoid_tls</option></entry>
48515 <entry>Use: <emphasis>smtp</emphasis></entry>
48516 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
48517 <entry>Default: <emphasis>unset</emphasis></entry>
48518 </row>
48519 </tbody>
48520 </tgroup>
48521 </informaltable>
48522 <para>
48523 <indexterm role="concept">
48524 <primary>TLS</primary>
48525 <secondary>avoiding for certain hosts</secondary>
48526 </indexterm>
48527 Exim will not try to start a TLS session when delivering to any host that
48528 matches this list. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
48529 </para>
48530 <para>
48531 <indexterm role="option">
48532 <primary><option>hosts_verify_avoid_tls</option></primary>
48533 </indexterm>
48534 </para>
48535 <informaltable frame="all">
48536 <tgroup cols="4" colsep="0" rowsep="0">
48537 <colspec colwidth="8*" align="left"/>
48538 <colspec colwidth="6*" align="center"/>
48539 <colspec colwidth="6*" align="center"/>
48540 <colspec colwidth="6*" align="right"/>
48541 <tbody>
48542 <row>
48543 <entry><option>hosts_verify_avoid_tls</option></entry>
48544 <entry>Use: <emphasis>smtp</emphasis></entry>
48545 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
48546 <entry>Default: <emphasis>unset</emphasis></entry>
48547 </row>
48548 </tbody>
48549 </tgroup>
48550 </informaltable>
48551 <para>
48552 <indexterm role="concept">
48553 <primary>TLS</primary>
48554 <secondary>avoiding for certain hosts</secondary>
48555 </indexterm>
48556 Exim will not try to start a TLS session for a verify callout,
48557 or when delivering in cutthrough mode,
48558 to any host that matches this list.
48559 </para>
48560 <para>
48561 <indexterm role="option">
48562 <primary><option>hosts_max_try</option></primary>
48563 </indexterm>
48564 </para>
48565 <informaltable frame="all">
48566 <tgroup cols="4" colsep="0" rowsep="0">
48567 <colspec colwidth="8*" align="left"/>
48568 <colspec colwidth="6*" align="center"/>
48569 <colspec colwidth="6*" align="center"/>
48570 <colspec colwidth="6*" align="right"/>
48571 <tbody>
48572 <row>
48573 <entry><option>hosts_max_try</option></entry>
48574 <entry>Use: <emphasis>smtp</emphasis></entry>
48575 <entry>Type: <emphasis>integer</emphasis></entry>
48576 <entry>Default: <emphasis>5</emphasis></entry>
48577 </row>
48578 </tbody>
48579 </tgroup>
48580 </informaltable>
48581 <para>
48582 <indexterm role="concept">
48583 <primary>host</primary>
48584 <secondary>maximum number to try</secondary>
48585 </indexterm>
48586 <indexterm role="concept">
48587 <primary>limit</primary>
48588 <secondary>number of hosts tried</secondary>
48589 </indexterm>
48590 <indexterm role="concept">
48591 <primary>limit</primary>
48592 <secondary>number of MX tried</secondary>
48593 </indexterm>
48594 <indexterm role="concept">
48595 <primary>MX record</primary>
48596 <secondary>maximum tried</secondary>
48597 </indexterm>
48598 This option limits the number of IP addresses that are tried for any one
48599 delivery in cases where there are temporary delivery errors. Section
48600 <xref linkend="SECTvalhosmax"/> describes in detail how the value of this option is used.
48601 </para>
48602 <para>
48603 <indexterm role="option">
48604 <primary><option>hosts_max_try_hardlimit</option></primary>
48605 </indexterm>
48606 </para>
48607 <informaltable frame="all">
48608 <tgroup cols="4" colsep="0" rowsep="0">
48609 <colspec colwidth="8*" align="left"/>
48610 <colspec colwidth="6*" align="center"/>
48611 <colspec colwidth="6*" align="center"/>
48612 <colspec colwidth="6*" align="right"/>
48613 <tbody>
48614 <row>
48615 <entry><option>hosts_max_try_hardlimit</option></entry>
48616 <entry>Use: <emphasis>smtp</emphasis></entry>
48617 <entry>Type: <emphasis>integer</emphasis></entry>
48618 <entry>Default: <emphasis>50</emphasis></entry>
48619 </row>
48620 </tbody>
48621 </tgroup>
48622 </informaltable>
48623 <para>
48624 This is an additional check on the maximum number of IP addresses that Exim
48625 tries for any one delivery. Section <xref linkend="SECTvalhosmax"/> describes its use and
48626 why it exists.
48627 </para>
48628 <para>
48629 <indexterm role="option">
48630 <primary><option>hosts_nopass_tls</option></primary>
48631 </indexterm>
48632 </para>
48633 <informaltable frame="all">
48634 <tgroup cols="4" colsep="0" rowsep="0">
48635 <colspec colwidth="8*" align="left"/>
48636 <colspec colwidth="6*" align="center"/>
48637 <colspec colwidth="6*" align="center"/>
48638 <colspec colwidth="6*" align="right"/>
48639 <tbody>
48640 <row>
48641 <entry><option>hosts_nopass_tls</option></entry>
48642 <entry>Use: <emphasis>smtp</emphasis></entry>
48643 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
48644 <entry>Default: <emphasis>unset</emphasis></entry>
48645 </row>
48646 </tbody>
48647 </tgroup>
48648 </informaltable>
48649 <para>
48650 <indexterm role="concept">
48651 <primary>TLS</primary>
48652 <secondary>passing connection</secondary>
48653 </indexterm>
48654 <indexterm role="concept">
48655 <primary>multiple SMTP deliveries</primary>
48656 </indexterm>
48657 <indexterm role="concept">
48658 <primary>TLS</primary>
48659 <secondary>multiple message deliveries</secondary>
48660 </indexterm>
48661 For any host that matches this list, a connection on which a TLS session has
48662 been started will not be passed to a new delivery process for sending another
48663 message on the same connection. See section <xref linkend="SECTmulmessam"/> for an
48664 explanation of when this might be needed.
48665 </para>
48666 <para revisionflag="changed">
48667 <indexterm role="option">
48668 <primary><option>hosts_noproxy_tls</option></primary>
48669 </indexterm>
48670 </para>
48671 <informaltable frame="all" revisionflag="changed">
48672 <tgroup cols="4" colsep="0" rowsep="0">
48673 <colspec colwidth="8*" align="left"/>
48674 <colspec colwidth="6*" align="center"/>
48675 <colspec colwidth="6*" align="center"/>
48676 <colspec colwidth="6*" align="right"/>
48677 <tbody>
48678 <row>
48679 <entry><option>hosts_noproxy_tls</option></entry>
48680 <entry>Use: <emphasis>smtp</emphasis></entry>
48681 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
48682 <entry>Default: <emphasis>unset</emphasis></entry>
48683 </row>
48684 </tbody>
48685 </tgroup>
48686 </informaltable>
48687 <para revisionflag="changed">
48688 <indexterm role="concept">
48689 <primary>TLS</primary>
48690 <secondary>passing connection</secondary>
48691 </indexterm>
48692 <indexterm role="concept">
48693 <primary>multiple SMTP deliveries</primary>
48694 </indexterm>
48695 <indexterm role="concept">
48696 <primary>TLS</primary>
48697 <secondary>multiple message deliveries</secondary>
48698 </indexterm>
48699 For any host that matches this list, a TLS session which has
48700 been started will not be passed to a new delivery process for sending another
48701 message on the same session.
48702 </para>
48703 <para>
48704 The traditional implementation closes down TLS and re-starts it in the new
48705 process, on the same open TCP connection, for each successive message
48706 sent.  If permitted by this option a pipe to to the new process is set up
48707 instead, and the original process maintains the TLS connection and proxies
48708 the SMTP connection from and to the new process and any subsequents.
48709 The new process has no access to TLS information, so cannot include it in
48710 logging.
48711 </para>
48712 <para>
48713 <indexterm role="option">
48714 <primary><option>hosts_override</option></primary>
48715 </indexterm>
48716 </para>
48717 <informaltable frame="all">
48718 <tgroup cols="4" colsep="0" rowsep="0">
48719 <colspec colwidth="8*" align="left"/>
48720 <colspec colwidth="6*" align="center"/>
48721 <colspec colwidth="6*" align="center"/>
48722 <colspec colwidth="6*" align="right"/>
48723 <tbody>
48724 <row>
48725 <entry><option>hosts_override</option></entry>
48726 <entry>Use: <emphasis>smtp</emphasis></entry>
48727 <entry>Type: <emphasis>boolean</emphasis></entry>
48728 <entry>Default: <emphasis>false</emphasis></entry>
48729 </row>
48730 </tbody>
48731 </tgroup>
48732 </informaltable>
48733 <para>
48734 If this option is set and the <option>hosts</option> option is also set, any hosts that are
48735 attached to the address are ignored, and instead the hosts specified by the
48736 <option>hosts</option> option are always used. This option does not apply to
48737 <option>fallback_hosts</option>.
48738 </para>
48739 <para>
48740 <indexterm role="option">
48741 <primary><option>hosts_randomize</option></primary>
48742 </indexterm>
48743 </para>
48744 <informaltable frame="all">
48745 <tgroup cols="4" colsep="0" rowsep="0">
48746 <colspec colwidth="8*" align="left"/>
48747 <colspec colwidth="6*" align="center"/>
48748 <colspec colwidth="6*" align="center"/>
48749 <colspec colwidth="6*" align="right"/>
48750 <tbody>
48751 <row>
48752 <entry><option>hosts_randomize</option></entry>
48753 <entry>Use: <emphasis>smtp</emphasis></entry>
48754 <entry>Type: <emphasis>boolean</emphasis></entry>
48755 <entry>Default: <emphasis>false</emphasis></entry>
48756 </row>
48757 </tbody>
48758 </tgroup>
48759 </informaltable>
48760 <para>
48761 <indexterm role="concept">
48762 <primary>randomized host list</primary>
48763 </indexterm>
48764 <indexterm role="concept">
48765 <primary>host</primary>
48766 <secondary>list of; randomized</secondary>
48767 </indexterm>
48768 <indexterm role="concept">
48769 <primary>fallback</primary>
48770 <secondary>randomized hosts</secondary>
48771 </indexterm>
48772 If this option is set, and either the list of hosts is taken from the
48773 <option>hosts</option> or the <option>fallback_hosts</option> option, or the hosts supplied by the router
48774 were not obtained from MX records (this includes fallback hosts from the
48775 router), and were not randomized by the router, the order of trying the hosts
48776 is randomized each time the transport runs. Randomizing the order of a host
48777 list can be used to do crude load sharing.
48778 </para>
48779 <para>
48780 When <option>hosts_randomize</option> is true, a host list may be split into groups whose
48781 order is separately randomized. This makes it possible to set up MX-like
48782 behaviour. The boundaries between groups are indicated by an item that is just
48783 <literal>+</literal> in the host list. For example:
48784 </para>
48785 <literallayout class="monospaced">
48786 hosts = host1:host2:host3:+:host4:host5
48787 </literallayout>
48788 <para>
48789 The order of the first three hosts and the order of the last two hosts is
48790 randomized for each use, but the first three always end up before the last two.
48791 If <option>hosts_randomize</option> is not set, a <literal>+</literal> item in the list is ignored.
48792 </para>
48793 <para>
48794 <indexterm role="option">
48795 <primary><option>hosts_require_auth</option></primary>
48796 </indexterm>
48797 </para>
48798 <informaltable frame="all">
48799 <tgroup cols="4" colsep="0" rowsep="0">
48800 <colspec colwidth="8*" align="left"/>
48801 <colspec colwidth="6*" align="center"/>
48802 <colspec colwidth="6*" align="center"/>
48803 <colspec colwidth="6*" align="right"/>
48804 <tbody>
48805 <row>
48806 <entry><option>hosts_require_auth</option></entry>
48807 <entry>Use: <emphasis>smtp</emphasis></entry>
48808 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
48809 <entry>Default: <emphasis>unset</emphasis></entry>
48810 </row>
48811 </tbody>
48812 </tgroup>
48813 </informaltable>
48814 <para>
48815 <indexterm role="concept">
48816 <primary>authentication</primary>
48817 <secondary>required by client</secondary>
48818 </indexterm>
48819 This option provides a list of servers for which authentication must succeed
48820 before Exim will try to transfer a message. If authentication fails for
48821 servers which are not in this list, Exim tries to send unauthenticated. If
48822 authentication fails for one of these servers, delivery is deferred. This
48823 temporary error is detectable in the retry rules, so it can be turned into a
48824 hard failure if required. See also <option>hosts_try_auth</option>, and chapter
48825 <xref linkend="CHAPSMTPAUTH"/> for details of authentication.
48826 </para>
48827 <para>
48828 <indexterm role="option">
48829 <primary><option>hosts_request_ocsp</option></primary>
48830 </indexterm>
48831 </para>
48832 <informaltable frame="all">
48833 <tgroup cols="4" colsep="0" rowsep="0">
48834 <colspec colwidth="8*" align="left"/>
48835 <colspec colwidth="6*" align="center"/>
48836 <colspec colwidth="6*" align="center"/>
48837 <colspec colwidth="6*" align="right"/>
48838 <tbody>
48839 <row>
48840 <entry><option>hosts_request_ocsp</option></entry>
48841 <entry>Use: <emphasis>smtp</emphasis></entry>
48842 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
48843 <entry>Default: <emphasis>*</emphasis></entry>
48844 </row>
48845 </tbody>
48846 </tgroup>
48847 </informaltable>
48848 <para>
48849 <indexterm role="concept">
48850 <primary>TLS</primary>
48851 <secondary>requiring for certain servers</secondary>
48852 </indexterm>
48853 Exim will request a Certificate Status on a
48854 TLS session for any host that matches this list.
48855 <option>tls_verify_certificates</option> should also be set for the transport.
48856 </para>
48857 <para>
48858 <indexterm role="option">
48859 <primary><option>hosts_require_dane</option></primary>
48860 </indexterm>
48861 </para>
48862 <informaltable frame="all">
48863 <tgroup cols="4" colsep="0" rowsep="0">
48864 <colspec colwidth="8*" align="left"/>
48865 <colspec colwidth="6*" align="center"/>
48866 <colspec colwidth="6*" align="center"/>
48867 <colspec colwidth="6*" align="right"/>
48868 <tbody>
48869 <row>
48870 <entry><option>hosts_require_dane</option></entry>
48871 <entry>Use: <emphasis>smtp</emphasis></entry>
48872 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
48873 <entry>Default: <emphasis>unset</emphasis></entry>
48874 </row>
48875 </tbody>
48876 </tgroup>
48877 </informaltable>
48878 <para>
48879 <indexterm role="concept">
48880 <primary>DANE</primary>
48881 <secondary>transport options</secondary>
48882 </indexterm>
48883 <indexterm role="concept">
48884 <primary>DANE</primary>
48885 <secondary>requiring for certain servers</secondary>
48886 </indexterm>
48887 If built with DANE support, Exim  will require that a DNSSEC-validated
48888 TLSA record is present for any host matching the list,
48889 and that a DANE-verified TLS connection is made. See
48890 the <option>dnssec_request_domains</option> router and transport options.
48891 There will be no fallback to in-clear communication.
48892 See section <xref linkend="SECDANE"/>.
48893 </para>
48894 <para>
48895 <indexterm role="option">
48896 <primary><option>hosts_require_ocsp</option></primary>
48897 </indexterm>
48898 </para>
48899 <informaltable frame="all">
48900 <tgroup cols="4" colsep="0" rowsep="0">
48901 <colspec colwidth="8*" align="left"/>
48902 <colspec colwidth="6*" align="center"/>
48903 <colspec colwidth="6*" align="center"/>
48904 <colspec colwidth="6*" align="right"/>
48905 <tbody>
48906 <row>
48907 <entry><option>hosts_require_ocsp</option></entry>
48908 <entry>Use: <emphasis>smtp</emphasis></entry>
48909 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
48910 <entry>Default: <emphasis>unset</emphasis></entry>
48911 </row>
48912 </tbody>
48913 </tgroup>
48914 </informaltable>
48915 <para>
48916 <indexterm role="concept">
48917 <primary>TLS</primary>
48918 <secondary>requiring for certain servers</secondary>
48919 </indexterm>
48920 Exim will request, and check for a valid Certificate Status being given, on a
48921 TLS session for any host that matches this list.
48922 <option>tls_verify_certificates</option> should also be set for the transport.
48923 </para>
48924 <para>
48925 <indexterm role="option">
48926 <primary><option>hosts_require_tls</option></primary>
48927 </indexterm>
48928 </para>
48929 <informaltable frame="all">
48930 <tgroup cols="4" colsep="0" rowsep="0">
48931 <colspec colwidth="8*" align="left"/>
48932 <colspec colwidth="6*" align="center"/>
48933 <colspec colwidth="6*" align="center"/>
48934 <colspec colwidth="6*" align="right"/>
48935 <tbody>
48936 <row>
48937 <entry><option>hosts_require_tls</option></entry>
48938 <entry>Use: <emphasis>smtp</emphasis></entry>
48939 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
48940 <entry>Default: <emphasis>unset</emphasis></entry>
48941 </row>
48942 </tbody>
48943 </tgroup>
48944 </informaltable>
48945 <para>
48946 <indexterm role="concept">
48947 <primary>TLS</primary>
48948 <secondary>requiring for certain servers</secondary>
48949 </indexterm>
48950 Exim will insist on using a TLS session when delivering to any host that
48951 matches this list. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
48952 <emphasis role="bold">Note</emphasis>: This option affects outgoing mail only. To insist on TLS for
48953 incoming messages, use an appropriate ACL.
48954 </para>
48955 <para>
48956 <indexterm role="option">
48957 <primary><option>hosts_try_auth</option></primary>
48958 </indexterm>
48959 </para>
48960 <informaltable frame="all">
48961 <tgroup cols="4" colsep="0" rowsep="0">
48962 <colspec colwidth="8*" align="left"/>
48963 <colspec colwidth="6*" align="center"/>
48964 <colspec colwidth="6*" align="center"/>
48965 <colspec colwidth="6*" align="right"/>
48966 <tbody>
48967 <row>
48968 <entry><option>hosts_try_auth</option></entry>
48969 <entry>Use: <emphasis>smtp</emphasis></entry>
48970 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
48971 <entry>Default: <emphasis>unset</emphasis></entry>
48972 </row>
48973 </tbody>
48974 </tgroup>
48975 </informaltable>
48976 <para>
48977 <indexterm role="concept">
48978 <primary>authentication</primary>
48979 <secondary>optional in client</secondary>
48980 </indexterm>
48981 This option provides a list of servers to which, provided they announce
48982 authentication support, Exim will attempt to authenticate as a client when it
48983 connects. If authentication fails, Exim will try to transfer the message
48984 unauthenticated. See also <option>hosts_require_auth</option>, and chapter
48985 <xref linkend="CHAPSMTPAUTH"/> for details of authentication.
48986 </para>
48987 <para>
48988 <indexterm role="option">
48989 <primary><option>hosts_try_chunking</option></primary>
48990 </indexterm>
48991 </para>
48992 <informaltable frame="all">
48993 <tgroup cols="4" colsep="0" rowsep="0">
48994 <colspec colwidth="8*" align="left"/>
48995 <colspec colwidth="6*" align="center"/>
48996 <colspec colwidth="6*" align="center"/>
48997 <colspec colwidth="6*" align="right"/>
48998 <tbody>
48999 <row>
49000 <entry><option>hosts_try_chunking</option></entry>
49001 <entry>Use: <emphasis>smtp</emphasis></entry>
49002 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
49003 <entry>Default: <emphasis>*</emphasis></entry>
49004 </row>
49005 </tbody>
49006 </tgroup>
49007 </informaltable>
49008 <para>
49009 <indexterm role="concept">
49010 <primary>CHUNKING</primary>
49011 <secondary>enabling, in client</secondary>
49012 </indexterm>
49013 <indexterm role="concept">
49014 <primary>BDAT</primary>
49015 <secondary>SMTP command</secondary>
49016 </indexterm>
49017 <indexterm role="concept">
49018 <primary>RFC 3030</primary>
49019 <secondary>CHUNKING</secondary>
49020 </indexterm>
49021 This option provides a list of servers to which, provided they announce
49022 CHUNKING support, Exim will attempt to use BDAT commands rather than DATA.
49023 BDAT will not be used in conjunction with a transport filter.
49024 </para>
49025 <para>
49026 <indexterm role="option">
49027 <primary><option>hosts_try_dane</option></primary>
49028 </indexterm>
49029 </para>
49030 <informaltable frame="all">
49031 <tgroup cols="4" colsep="0" rowsep="0">
49032 <colspec colwidth="8*" align="left"/>
49033 <colspec colwidth="6*" align="center"/>
49034 <colspec colwidth="6*" align="center"/>
49035 <colspec colwidth="6*" align="right"/>
49036 <tbody>
49037 <row>
49038 <entry><option>hosts_try_dane</option></entry>
49039 <entry>Use: <emphasis>smtp</emphasis></entry>
49040 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
49041 <entry>Default: <emphasis>*</emphasis></entry>
49042 </row>
49043 </tbody>
49044 </tgroup>
49045 </informaltable>
49046 <para>
49047 <indexterm role="concept">
49048 <primary>DANE</primary>
49049 <secondary>transport options</secondary>
49050 </indexterm>
49051 <indexterm role="concept">
49052 <primary>DANE</primary>
49053 <secondary>attempting for certain servers</secondary>
49054 </indexterm>
49055 If built with DANE support, Exim  will require that a DNSSEC-validated
49056 TLSA record is present for any host matching the list,
49057 and that a DANE-verified TLS connection is made. See
49058 the <option>dnssec_request_domains</option> router and transport options.
49059 There will be no fallback to in-clear communication.
49060 See section <xref linkend="SECDANE"/>.
49061 </para>
49062 <para>
49063 <indexterm role="option">
49064 <primary><option>hosts_try_fastopen</option></primary>
49065 </indexterm>
49066 </para>
49067 <informaltable frame="all">
49068 <tgroup cols="4" colsep="0" rowsep="0">
49069 <colspec colwidth="8*" align="left"/>
49070 <colspec colwidth="6*" align="center"/>
49071 <colspec colwidth="6*" align="center"/>
49072 <colspec colwidth="6*" align="right"/>
49073 <tbody>
49074 <row>
49075 <entry><option>hosts_try_fastopen</option></entry>
49076 <entry>Use: <emphasis>smtp</emphasis></entry>
49077 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
49078 <entry>Default: <emphasis>*</emphasis></entry>
49079 </row>
49080 </tbody>
49081 </tgroup>
49082 </informaltable>
49083 <para>
49084 <indexterm role="concept">
49085 <primary>fast open, TCP</primary>
49086 <secondary>enabling, in client</secondary>
49087 </indexterm>
49088 <indexterm role="concept">
49089 <primary>TCP Fast Open</primary>
49090 <secondary>enabling, in client</secondary>
49091 </indexterm>
49092 <indexterm role="concept">
49093 <primary>RFC 7413</primary>
49094 <secondary>TCP Fast Open</secondary>
49095 </indexterm>
49096 This option provides a list of servers to which, provided
49097 the facility is supported by this system, Exim will attempt to
49098 perform a TCP Fast Open.
49099 No data is sent on the SYN segment but, if the remote server also
49100 supports the facility, it can send its SMTP banner immediately after
49101 the SYN,ACK segment.  This can save up to one round-trip time.
49102 </para>
49103 <para>
49104 The facility is only active for previously-contacted servers,
49105 as the initiator must present a cookie in the SYN segment.
49106 </para>
49107 <para>
49108 On (at least some) current Linux distributions the facility must be enabled
49109 in the kernel by the sysadmin before the support is usable.
49110 There is no option for control of the server side; if the system supports
49111 it it is always enabled.  Note that lengthy operations in the connect ACL,
49112 such as DNSBL lookups, will still delay the emission of the SMTP banner.
49113 </para>
49114 <para>
49115 <indexterm role="option">
49116 <primary><option>hosts_try_prdr</option></primary>
49117 </indexterm>
49118 </para>
49119 <informaltable frame="all">
49120 <tgroup cols="4" colsep="0" rowsep="0">
49121 <colspec colwidth="8*" align="left"/>
49122 <colspec colwidth="6*" align="center"/>
49123 <colspec colwidth="6*" align="center"/>
49124 <colspec colwidth="6*" align="right"/>
49125 <tbody>
49126 <row>
49127 <entry><option>hosts_try_prdr</option></entry>
49128 <entry>Use: <emphasis>smtp</emphasis></entry>
49129 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
49130 <entry>Default: <emphasis>*</emphasis></entry>
49131 </row>
49132 </tbody>
49133 </tgroup>
49134 </informaltable>
49135 <para>
49136 <indexterm role="concept">
49137 <primary>PRDR</primary>
49138 <secondary>enabling, optional in client</secondary>
49139 </indexterm>
49140 This option provides a list of servers to which, provided they announce
49141 PRDR support, Exim will attempt to negotiate PRDR
49142 for multi-recipient messages.
49143 The option can usually be left as default.
49144 </para>
49145 <para>
49146 <indexterm role="option">
49147 <primary><option>interface</option></primary>
49148 </indexterm>
49149 </para>
49150 <informaltable frame="all">
49151 <tgroup cols="4" colsep="0" rowsep="0">
49152 <colspec colwidth="8*" align="left"/>
49153 <colspec colwidth="6*" align="center"/>
49154 <colspec colwidth="6*" align="center"/>
49155 <colspec colwidth="6*" align="right"/>
49156 <tbody>
49157 <row>
49158 <entry><option>interface</option></entry>
49159 <entry>Use: <emphasis>smtp</emphasis></entry>
49160 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
49161 <entry>Default: <emphasis>unset</emphasis></entry>
49162 </row>
49163 </tbody>
49164 </tgroup>
49165 </informaltable>
49166 <para>
49167 <indexterm role="concept">
49168 <primary>bind IP address</primary>
49169 </indexterm>
49170 <indexterm role="concept">
49171 <primary>IP address</primary>
49172 <secondary>binding</secondary>
49173 </indexterm>
49174 <indexterm role="variable">
49175 <primary><varname>$host</varname></primary>
49176 </indexterm>
49177 <indexterm role="variable">
49178 <primary><varname>$host_address</varname></primary>
49179 </indexterm>
49180 This option specifies which interface to bind to when making an outgoing SMTP
49181 call. The value is an IP address, not an interface name such as
49182 <literal>eth0</literal>. Do not confuse this with the interface address that was used when a
49183 message was received, which is in <varname>$received_ip_address</varname>, formerly known as
49184 <varname>$interface_address</varname>. The name was changed to minimize confusion with the
49185 outgoing interface address. There is no variable that contains an outgoing
49186 interface address because, unless it is set by this option, its value is
49187 unknown.
49188 </para>
49189 <para>
49190 During the expansion of the <option>interface</option> option the variables <varname>$host</varname> and
49191 <varname>$host_address</varname> refer to the host to which a connection is about to be made
49192 during the expansion of the string. Forced expansion failure, or an empty
49193 string result causes the option to be ignored. Otherwise, after expansion, the
49194 string must be a list of IP addresses, colon-separated by default, but the
49195 separator can be changed in the usual way (<xref linkend="SECTlistsepchange"/>).
49196 For example:
49197 </para>
49198 <literallayout class="monospaced">
49199 interface = &lt;; 192.168.123.123 ; 3ffe:ffff:836f::fe86:a061
49200 </literallayout>
49201 <para>
49202 The first interface of the correct type (IPv4 or IPv6) is used for the outgoing
49203 connection. If none of them are the correct type, the option is ignored. If
49204 <option>interface</option> is not set, or is ignored, the system&#x2019;s IP functions choose which
49205 interface to use if the host has more than one.
49206 </para>
49207 <para>
49208 <indexterm role="option">
49209 <primary><option>keepalive</option></primary>
49210 </indexterm>
49211 </para>
49212 <informaltable frame="all">
49213 <tgroup cols="4" colsep="0" rowsep="0">
49214 <colspec colwidth="8*" align="left"/>
49215 <colspec colwidth="6*" align="center"/>
49216 <colspec colwidth="6*" align="center"/>
49217 <colspec colwidth="6*" align="right"/>
49218 <tbody>
49219 <row>
49220 <entry><option>keepalive</option></entry>
49221 <entry>Use: <emphasis>smtp</emphasis></entry>
49222 <entry>Type: <emphasis>boolean</emphasis></entry>
49223 <entry>Default: <emphasis>true</emphasis></entry>
49224 </row>
49225 </tbody>
49226 </tgroup>
49227 </informaltable>
49228 <para>
49229 <indexterm role="concept">
49230 <primary>keepalive</primary>
49231 <secondary>on outgoing connection</secondary>
49232 </indexterm>
49233 This option controls the setting of SO_KEEPALIVE on outgoing TCP/IP socket
49234 connections. When set, it causes the kernel to probe idle connections
49235 periodically, by sending packets with <quote>old</quote> sequence numbers. The other end
49236 of the connection should send a acknowledgment if the connection is still okay
49237 or a reset if the connection has been aborted. The reason for doing this is
49238 that it has the beneficial effect of freeing up certain types of connection
49239 that can get stuck when the remote host is disconnected without tidying up the
49240 TCP/IP call properly. The keepalive mechanism takes several hours to detect
49241 unreachable hosts.
49242 </para>
49243 <para>
49244 <indexterm role="option">
49245 <primary><option>lmtp_ignore_quota</option></primary>
49246 </indexterm>
49247 </para>
49248 <informaltable frame="all">
49249 <tgroup cols="4" colsep="0" rowsep="0">
49250 <colspec colwidth="8*" align="left"/>
49251 <colspec colwidth="6*" align="center"/>
49252 <colspec colwidth="6*" align="center"/>
49253 <colspec colwidth="6*" align="right"/>
49254 <tbody>
49255 <row>
49256 <entry><option>lmtp_ignore_quota</option></entry>
49257 <entry>Use: <emphasis>smtp</emphasis></entry>
49258 <entry>Type: <emphasis>boolean</emphasis></entry>
49259 <entry>Default: <emphasis>false</emphasis></entry>
49260 </row>
49261 </tbody>
49262 </tgroup>
49263 </informaltable>
49264 <para>
49265 <indexterm role="concept">
49266 <primary>LMTP</primary>
49267 <secondary>ignoring quota errors</secondary>
49268 </indexterm>
49269 If this option is set true when the <option>protocol</option> option is set to <quote>lmtp</quote>, the
49270 string <literal>IGNOREQUOTA</literal> is added to RCPT commands, provided that the LMTP server
49271 has advertised support for IGNOREQUOTA in its response to the LHLO command.
49272 </para>
49273 <para>
49274 <indexterm role="option">
49275 <primary><option>max_rcpt</option></primary>
49276 </indexterm>
49277 </para>
49278 <informaltable frame="all">
49279 <tgroup cols="4" colsep="0" rowsep="0">
49280 <colspec colwidth="8*" align="left"/>
49281 <colspec colwidth="6*" align="center"/>
49282 <colspec colwidth="6*" align="center"/>
49283 <colspec colwidth="6*" align="right"/>
49284 <tbody>
49285 <row>
49286 <entry><option>max_rcpt</option></entry>
49287 <entry>Use: <emphasis>smtp</emphasis></entry>
49288 <entry>Type: <emphasis>integer</emphasis></entry>
49289 <entry>Default: <emphasis>100</emphasis></entry>
49290 </row>
49291 </tbody>
49292 </tgroup>
49293 </informaltable>
49294 <para>
49295 <indexterm role="concept">
49296 <primary>RCPT</primary>
49297 <secondary>maximum number of outgoing</secondary>
49298 </indexterm>
49299 This option limits the number of RCPT commands that are sent in a single
49300 SMTP message transaction. Each set of addresses is treated independently, and
49301 so can cause parallel connections to the same host if <option>remote_max_parallel</option>
49302 permits this.
49303 </para>
49304 <para>
49305 <indexterm role="option">
49306 <primary><option>multi_domain</option></primary>
49307 </indexterm>
49308 </para>
49309 <informaltable frame="all">
49310 <tgroup cols="4" colsep="0" rowsep="0">
49311 <colspec colwidth="8*" align="left"/>
49312 <colspec colwidth="6*" align="center"/>
49313 <colspec colwidth="6*" align="center"/>
49314 <colspec colwidth="6*" align="right"/>
49315 <tbody>
49316 <row>
49317 <entry><option>multi_domain</option></entry>
49318 <entry>Use: <emphasis>smtp</emphasis></entry>
49319 <entry>Type: <emphasis>boolean</emphasis>&dagger;<emphasis></emphasis></entry>
49320 <entry>Default: <emphasis>true</emphasis></entry>
49321 </row>
49322 </tbody>
49323 </tgroup>
49324 </informaltable>
49325 <para>
49326 <indexterm role="variable">
49327 <primary><varname>$domain</varname></primary>
49328 </indexterm>
49329 When this option is set, the <command>smtp</command> transport can handle a number of
49330 addresses containing a mixture of different domains provided they all resolve
49331 to the same list of hosts. Turning the option off restricts the transport to
49332 handling only one domain at a time. This is useful if you want to use
49333 <varname>$domain</varname> in an expansion for the transport, because it is set only when there
49334 is a single domain involved in a remote delivery.
49335 </para>
49336 <para>
49337 It is expanded per-address and can depend on any of
49338 <varname>$address_data</varname>, <varname>$domain_data</varname>, <varname>$local_part_data</varname>,
49339 <varname>$host</varname>, <varname>$host_address</varname> and <varname>$host_port</varname>.
49340 </para>
49341 <para>
49342 <indexterm role="option">
49343 <primary><option>port</option></primary>
49344 </indexterm>
49345 </para>
49346 <informaltable frame="all">
49347 <tgroup cols="4" colsep="0" rowsep="0">
49348 <colspec colwidth="8*" align="left"/>
49349 <colspec colwidth="6*" align="center"/>
49350 <colspec colwidth="6*" align="center"/>
49351 <colspec colwidth="6*" align="right"/>
49352 <tbody>
49353 <row>
49354 <entry><option>port</option></entry>
49355 <entry>Use: <emphasis>smtp</emphasis></entry>
49356 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
49357 <entry>Default: <emphasis>see below</emphasis></entry>
49358 </row>
49359 </tbody>
49360 </tgroup>
49361 </informaltable>
49362 <para>
49363 <indexterm role="concept">
49364 <primary>port</primary>
49365 <secondary>sending TCP/IP</secondary>
49366 </indexterm>
49367 <indexterm role="concept">
49368 <primary>TCP/IP</primary>
49369 <secondary>setting outgoing port</secondary>
49370 </indexterm>
49371 This option specifies the TCP/IP port on the server to which Exim connects.
49372 <emphasis role="bold">Note:</emphasis> Do not confuse this with the port that was used when a message was
49373 received, which is in <varname>$received_port</varname>, formerly known as <varname>$interface_port</varname>.
49374 The name was changed to minimize confusion with the outgoing port. There is no
49375 variable that contains an outgoing port.
49376 </para>
49377 <para>
49378 If the value of this option begins with a digit it is taken as a port number;
49379 otherwise it is looked up using <function>getservbyname()</function>. The default value is
49380 normally <quote>smtp</quote>,
49381 but if <option>protocol</option> is set to <quote>lmtp</quote> the default is <quote>lmtp</quote>
49382 and if <option>protocol</option> is set to <quote>smtps</quote> the default is <quote>smtps</quote>.
49383 If the expansion fails, or if a port number cannot be found, delivery
49384 is deferred.
49385 </para>
49386 <para>
49387 Note that at least one Linux distribution has been seen failing
49388 to put <quote>smtps</quote> in its <quote>/etc/services</quote> file, resulting is such deferrals.
49389 </para>
49390 <para>
49391 <indexterm role="option">
49392 <primary><option>protocol</option></primary>
49393 </indexterm>
49394 </para>
49395 <informaltable frame="all">
49396 <tgroup cols="4" colsep="0" rowsep="0">
49397 <colspec colwidth="8*" align="left"/>
49398 <colspec colwidth="6*" align="center"/>
49399 <colspec colwidth="6*" align="center"/>
49400 <colspec colwidth="6*" align="right"/>
49401 <tbody>
49402 <row>
49403 <entry><option>protocol</option></entry>
49404 <entry>Use: <emphasis>smtp</emphasis></entry>
49405 <entry>Type: <emphasis>string</emphasis></entry>
49406 <entry>Default: <emphasis>smtp</emphasis></entry>
49407 </row>
49408 </tbody>
49409 </tgroup>
49410 </informaltable>
49411 <para>
49412 <indexterm role="concept">
49413 <primary>LMTP</primary>
49414 <secondary>over TCP/IP</secondary>
49415 </indexterm>
49416 <indexterm role="concept">
49417 <primary>ssmtp protocol</primary>
49418 <secondary>outbound</secondary>
49419 </indexterm>
49420 <indexterm role="concept">
49421 <primary>TLS</primary>
49422 <secondary>SSL-on-connect outbound</secondary>
49423 </indexterm>
49424 <indexterm role="variable">
49425 <primary><varname>$port</varname></primary>
49426 </indexterm>
49427 If this option is set to <quote>lmtp</quote> instead of <quote>smtp</quote>, the default value for
49428 the <option>port</option> option changes to <quote>lmtp</quote>, and the transport operates the LMTP
49429 protocol (RFC 2033) instead of SMTP. This protocol is sometimes used for local
49430 deliveries into closed message stores. Exim also has support for running LMTP
49431 over a pipe to a local process &ndash; see chapter <xref linkend="CHAPLMTP"/>.
49432 </para>
49433 <para>
49434 If this option is set to <quote>smtps</quote>, the default value for the <option>port</option> option
49435 changes to <quote>smtps</quote>, and the transport initiates TLS immediately after
49436 connecting, as an outbound SSL-on-connect, instead of using STARTTLS to upgrade.
49437 The Internet standards bodies used to strongly discourage use of this mode,
49438 but as of RFC 8314 it is perferred over STARTTLS for message submission
49439 (as distinct from MTA-MTA communication).
49440 </para>
49441 <para>
49442 <indexterm role="option">
49443 <primary><option>retry_include_ip_address</option></primary>
49444 </indexterm>
49445 </para>
49446 <informaltable frame="all">
49447 <tgroup cols="4" colsep="0" rowsep="0">
49448 <colspec colwidth="8*" align="left"/>
49449 <colspec colwidth="6*" align="center"/>
49450 <colspec colwidth="6*" align="center"/>
49451 <colspec colwidth="6*" align="right"/>
49452 <tbody>
49453 <row>
49454 <entry><option>retry_include_ip_address</option></entry>
49455 <entry>Use: <emphasis>smtp</emphasis></entry>
49456 <entry>Type: <emphasis>boolean</emphasis>&dagger;<emphasis></emphasis></entry>
49457 <entry>Default: <emphasis>true</emphasis></entry>
49458 </row>
49459 </tbody>
49460 </tgroup>
49461 </informaltable>
49462 <para>
49463 Exim normally includes both the host name and the IP address in the key it
49464 constructs for indexing retry data after a temporary delivery failure. This
49465 means that when one of several IP addresses for a host is failing, it gets
49466 tried periodically (controlled by the retry rules), but use of the other IP
49467 addresses is not affected.
49468 </para>
49469 <para>
49470 However, in some dialup environments hosts are assigned a different IP address
49471 each time they connect. In this situation the use of the IP address as part of
49472 the retry key leads to undesirable behaviour. Setting this option false causes
49473 Exim to use only the host name.
49474 Since it is expanded it can be made to depend on the host or domain.
49475 </para>
49476 <para>
49477 <indexterm role="option">
49478 <primary><option>serialize_hosts</option></primary>
49479 </indexterm>
49480 </para>
49481 <informaltable frame="all">
49482 <tgroup cols="4" colsep="0" rowsep="0">
49483 <colspec colwidth="8*" align="left"/>
49484 <colspec colwidth="6*" align="center"/>
49485 <colspec colwidth="6*" align="center"/>
49486 <colspec colwidth="6*" align="right"/>
49487 <tbody>
49488 <row>
49489 <entry><option>serialize_hosts</option></entry>
49490 <entry>Use: <emphasis>smtp</emphasis></entry>
49491 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
49492 <entry>Default: <emphasis>unset</emphasis></entry>
49493 </row>
49494 </tbody>
49495 </tgroup>
49496 </informaltable>
49497 <para>
49498 <indexterm role="concept">
49499 <primary>serializing connections</primary>
49500 </indexterm>
49501 <indexterm role="concept">
49502 <primary>host</primary>
49503 <secondary>serializing connections</secondary>
49504 </indexterm>
49505 Because Exim operates in a distributed manner, if several messages for the same
49506 host arrive at around the same time, more than one simultaneous connection to
49507 the remote host can occur. This is not usually a problem except when there is a
49508 slow link between the hosts. In that situation it may be helpful to restrict
49509 Exim to one connection at a time. This can be done by setting
49510 <option>serialize_hosts</option> to match the relevant hosts.
49511 </para>
49512 <para>
49513 <indexterm role="concept">
49514 <primary>hints database</primary>
49515 <secondary>serializing deliveries to a host</secondary>
49516 </indexterm>
49517 Exim implements serialization by means of a hints database in which a record is
49518 written whenever a process connects to one of the restricted hosts. The record
49519 is deleted when the connection is completed. Obviously there is scope for
49520 records to get left lying around if there is a system or program crash. To
49521 guard against this, Exim ignores any records that are more than six hours old.
49522 </para>
49523 <para>
49524 If you set up this kind of serialization, you should also arrange to delete the
49525 relevant hints database whenever your system reboots. The names of the files
49526 start with <filename>misc</filename> and they are kept in the <filename>spool/db</filename> directory. There
49527 may be one or two files, depending on the type of DBM in use. The same files
49528 are used for ETRN serialization.
49529 </para>
49530 <para>
49531 See also the <option>max_parallel</option> generic transport option.
49532 </para>
49533 <para>
49534 <indexterm role="option">
49535 <primary><option>size_addition</option></primary>
49536 </indexterm>
49537 </para>
49538 <informaltable frame="all">
49539 <tgroup cols="4" colsep="0" rowsep="0">
49540 <colspec colwidth="8*" align="left"/>
49541 <colspec colwidth="6*" align="center"/>
49542 <colspec colwidth="6*" align="center"/>
49543 <colspec colwidth="6*" align="right"/>
49544 <tbody>
49545 <row>
49546 <entry><option>size_addition</option></entry>
49547 <entry>Use: <emphasis>smtp</emphasis></entry>
49548 <entry>Type: <emphasis>integer</emphasis></entry>
49549 <entry>Default: <emphasis>1024</emphasis></entry>
49550 </row>
49551 </tbody>
49552 </tgroup>
49553 </informaltable>
49554 <para>
49555 <indexterm role="concept">
49556 <primary>SMTP</primary>
49557 <secondary>SIZE</secondary>
49558 </indexterm>
49559 <indexterm role="concept">
49560 <primary>message</primary>
49561 <secondary>size issue for transport filter</secondary>
49562 </indexterm>
49563 <indexterm role="concept">
49564 <primary>size</primary>
49565 <secondary>of message</secondary>
49566 </indexterm>
49567 <indexterm role="concept">
49568 <primary>transport</primary>
49569 <secondary>filter</secondary>
49570 </indexterm>
49571 <indexterm role="concept">
49572 <primary>filter</primary>
49573 <secondary>transport filter</secondary>
49574 </indexterm>
49575 If a remote SMTP server indicates that it supports the SIZE option of the
49576 MAIL command, Exim uses this to pass over the message size at the start of
49577 an SMTP transaction. It adds the value of <option>size_addition</option> to the value it
49578 sends, to allow for headers and other text that may be added during delivery by
49579 configuration options or in a transport filter. It may be necessary to increase
49580 this if a lot of text is added to messages.
49581 </para>
49582 <para>
49583 Alternatively, if the value of <option>size_addition</option> is set negative, it disables
49584 the use of the SIZE option altogether.
49585 </para>
49586 <para>
49587 <indexterm role="option">
49588 <primary><option>socks_proxy</option></primary>
49589 </indexterm>
49590 </para>
49591 <informaltable frame="all">
49592 <tgroup cols="4" colsep="0" rowsep="0">
49593 <colspec colwidth="8*" align="left"/>
49594 <colspec colwidth="6*" align="center"/>
49595 <colspec colwidth="6*" align="center"/>
49596 <colspec colwidth="6*" align="right"/>
49597 <tbody>
49598 <row>
49599 <entry><option>socks_proxy</option></entry>
49600 <entry>Use: <emphasis>smtp</emphasis></entry>
49601 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
49602 <entry>Default: <emphasis>unset</emphasis></entry>
49603 </row>
49604 </tbody>
49605 </tgroup>
49606 </informaltable>
49607 <para>
49608 <indexterm role="concept">
49609 <primary>proxy</primary>
49610 <secondary>SOCKS</secondary>
49611 </indexterm>
49612 This option enables use of SOCKS proxies for connections made by the
49613 transport.  For details see section <xref linkend="SECTproxySOCKS"/>.
49614 </para>
49615 <para>
49616 <indexterm role="option">
49617 <primary><option>tls_certificate</option></primary>
49618 </indexterm>
49619 </para>
49620 <informaltable frame="all">
49621 <tgroup cols="4" colsep="0" rowsep="0">
49622 <colspec colwidth="8*" align="left"/>
49623 <colspec colwidth="6*" align="center"/>
49624 <colspec colwidth="6*" align="center"/>
49625 <colspec colwidth="6*" align="right"/>
49626 <tbody>
49627 <row>
49628 <entry><option>tls_certificate</option></entry>
49629 <entry>Use: <emphasis>smtp</emphasis></entry>
49630 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
49631 <entry>Default: <emphasis>unset</emphasis></entry>
49632 </row>
49633 </tbody>
49634 </tgroup>
49635 </informaltable>
49636 <para>
49637 <indexterm role="concept">
49638 <primary>TLS</primary>
49639 <secondary>client certificate, location of</secondary>
49640 </indexterm>
49641 <indexterm role="concept">
49642 <primary>certificate</primary>
49643 <secondary>client, location of</secondary>
49644 </indexterm>
49645 <indexterm role="variable">
49646 <primary><varname>$host</varname></primary>
49647 </indexterm>
49648 <indexterm role="variable">
49649 <primary><varname>$host_address</varname></primary>
49650 </indexterm>
49651 The value of this option must be the absolute path to a file which contains the
49652 client&#x2019;s certificate, for possible use when sending a message over an encrypted
49653 connection. The values of <varname>$host</varname> and <varname>$host_address</varname> are set to the name and
49654 address of the server during the expansion. See chapter <xref linkend="CHAPTLS"/> for
49655 details of TLS.
49656 </para>
49657 <para>
49658 <emphasis role="bold">Note</emphasis>: This option must be set if you want Exim to be able to use a TLS
49659 certificate when sending messages as a client. The global option of the same
49660 name specifies the certificate for Exim as a server; it is not automatically
49661 assumed that the same certificate should be used when Exim is operating as a
49662 client.
49663 </para>
49664 <para>
49665 <indexterm role="option">
49666 <primary><option>tls_crl</option></primary>
49667 </indexterm>
49668 </para>
49669 <informaltable frame="all">
49670 <tgroup cols="4" colsep="0" rowsep="0">
49671 <colspec colwidth="8*" align="left"/>
49672 <colspec colwidth="6*" align="center"/>
49673 <colspec colwidth="6*" align="center"/>
49674 <colspec colwidth="6*" align="right"/>
49675 <tbody>
49676 <row>
49677 <entry><option>tls_crl</option></entry>
49678 <entry>Use: <emphasis>smtp</emphasis></entry>
49679 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
49680 <entry>Default: <emphasis>unset</emphasis></entry>
49681 </row>
49682 </tbody>
49683 </tgroup>
49684 </informaltable>
49685 <para>
49686 <indexterm role="concept">
49687 <primary>TLS</primary>
49688 <secondary>client certificate revocation list</secondary>
49689 </indexterm>
49690 <indexterm role="concept">
49691 <primary>certificate</primary>
49692 <secondary>revocation list for client</secondary>
49693 </indexterm>
49694 This option specifies a certificate revocation list. The expanded value must
49695 be the name of a file that contains a CRL in PEM format.
49696 </para>
49697 <para>
49698 <indexterm role="option">
49699 <primary><option>tls_dh_min_bits</option></primary>
49700 </indexterm>
49701 </para>
49702 <informaltable frame="all">
49703 <tgroup cols="4" colsep="0" rowsep="0">
49704 <colspec colwidth="8*" align="left"/>
49705 <colspec colwidth="6*" align="center"/>
49706 <colspec colwidth="6*" align="center"/>
49707 <colspec colwidth="6*" align="right"/>
49708 <tbody>
49709 <row>
49710 <entry><option>tls_dh_min_bits</option></entry>
49711 <entry>Use: <emphasis>smtp</emphasis></entry>
49712 <entry>Type: <emphasis>integer</emphasis></entry>
49713 <entry>Default: <emphasis>1024</emphasis></entry>
49714 </row>
49715 </tbody>
49716 </tgroup>
49717 </informaltable>
49718 <para>
49719 <indexterm role="concept">
49720 <primary>TLS</primary>
49721 <secondary>Diffie-Hellman minimum acceptable size</secondary>
49722 </indexterm>
49723 When establishing a TLS session, if a ciphersuite which uses Diffie-Hellman
49724 key agreement is negotiated, the server will provide a large prime number
49725 for use.  This option establishes the minimum acceptable size of that number.
49726 If the parameter offered by the server is too small, then the TLS handshake
49727 will fail.
49728 </para>
49729 <para>
49730 Only supported when using GnuTLS.
49731 </para>
49732 <para>
49733 <indexterm role="option">
49734 <primary><option>tls_privatekey</option></primary>
49735 </indexterm>
49736 </para>
49737 <informaltable frame="all">
49738 <tgroup cols="4" colsep="0" rowsep="0">
49739 <colspec colwidth="8*" align="left"/>
49740 <colspec colwidth="6*" align="center"/>
49741 <colspec colwidth="6*" align="center"/>
49742 <colspec colwidth="6*" align="right"/>
49743 <tbody>
49744 <row>
49745 <entry><option>tls_privatekey</option></entry>
49746 <entry>Use: <emphasis>smtp</emphasis></entry>
49747 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
49748 <entry>Default: <emphasis>unset</emphasis></entry>
49749 </row>
49750 </tbody>
49751 </tgroup>
49752 </informaltable>
49753 <para>
49754 <indexterm role="concept">
49755 <primary>TLS</primary>
49756 <secondary>client private key, location of</secondary>
49757 </indexterm>
49758 <indexterm role="variable">
49759 <primary><varname>$host</varname></primary>
49760 </indexterm>
49761 <indexterm role="variable">
49762 <primary><varname>$host_address</varname></primary>
49763 </indexterm>
49764 The value of this option must be the absolute path to a file which contains the
49765 client&#x2019;s private key. This is used when sending a message over an encrypted
49766 connection using a client certificate. The values of <varname>$host</varname> and
49767 <varname>$host_address</varname> are set to the name and address of the server during the
49768 expansion. If this option is unset, or the expansion is forced to fail, or the
49769 result is an empty string, the private key is assumed to be in the same file as
49770 the certificate. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
49771 </para>
49772 <para>
49773 <indexterm role="option">
49774 <primary><option>tls_require_ciphers</option></primary>
49775 </indexterm>
49776 </para>
49777 <informaltable frame="all">
49778 <tgroup cols="4" colsep="0" rowsep="0">
49779 <colspec colwidth="8*" align="left"/>
49780 <colspec colwidth="6*" align="center"/>
49781 <colspec colwidth="6*" align="center"/>
49782 <colspec colwidth="6*" align="right"/>
49783 <tbody>
49784 <row>
49785 <entry><option>tls_require_ciphers</option></entry>
49786 <entry>Use: <emphasis>smtp</emphasis></entry>
49787 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
49788 <entry>Default: <emphasis>unset</emphasis></entry>
49789 </row>
49790 </tbody>
49791 </tgroup>
49792 </informaltable>
49793 <para>
49794 <indexterm role="concept">
49795 <primary>TLS</primary>
49796 <secondary>requiring specific ciphers</secondary>
49797 </indexterm>
49798 <indexterm role="concept">
49799 <primary>cipher</primary>
49800 <secondary>requiring specific</secondary>
49801 </indexterm>
49802 <indexterm role="variable">
49803 <primary><varname>$host</varname></primary>
49804 </indexterm>
49805 <indexterm role="variable">
49806 <primary><varname>$host_address</varname></primary>
49807 </indexterm>
49808 The value of this option must be a list of permitted cipher suites, for use
49809 when setting up an outgoing encrypted connection. (There is a global option of
49810 the same name for controlling incoming connections.) The values of <varname>$host</varname> and
49811 <varname>$host_address</varname> are set to the name and address of the server during the
49812 expansion. See chapter <xref linkend="CHAPTLS"/> for details of TLS; note that this option
49813 is used in different ways by OpenSSL and GnuTLS (see sections
49814 <xref linkend="SECTreqciphssl"/> and <xref linkend="SECTreqciphgnu"/>). For GnuTLS, the order of the
49815 ciphers is a preference order.
49816 </para>
49817 <para>
49818 <indexterm role="option">
49819 <primary><option>tls_sni</option></primary>
49820 </indexterm>
49821 </para>
49822 <informaltable frame="all">
49823 <tgroup cols="4" colsep="0" rowsep="0">
49824 <colspec colwidth="8*" align="left"/>
49825 <colspec colwidth="6*" align="center"/>
49826 <colspec colwidth="6*" align="center"/>
49827 <colspec colwidth="6*" align="right"/>
49828 <tbody>
49829 <row>
49830 <entry><option>tls_sni</option></entry>
49831 <entry>Use: <emphasis>smtp</emphasis></entry>
49832 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
49833 <entry>Default: <emphasis>unset</emphasis></entry>
49834 </row>
49835 </tbody>
49836 </tgroup>
49837 </informaltable>
49838 <para>
49839 <indexterm role="concept">
49840 <primary>TLS</primary>
49841 <secondary>Server Name Indication</secondary>
49842 </indexterm>
49843 <indexterm role="variable">
49844 <primary><varname>$tls_sni</varname></primary>
49845 </indexterm>
49846 If this option is set then it sets the $tls_out_sni variable and causes any
49847 TLS session to pass this value as the Server Name Indication extension to
49848 the remote side, which can be used by the remote side to select an appropriate
49849 certificate and private key for the session.
49850 </para>
49851 <para>
49852 See <xref linkend="SECTtlssni"/> for more information.
49853 </para>
49854 <para>
49855 Note that for OpenSSL, this feature requires a build of OpenSSL that supports
49856 TLS extensions.
49857 </para>
49858 <para>
49859 <indexterm role="option">
49860 <primary><option>tls_tempfail_tryclear</option></primary>
49861 </indexterm>
49862 </para>
49863 <informaltable frame="all">
49864 <tgroup cols="4" colsep="0" rowsep="0">
49865 <colspec colwidth="8*" align="left"/>
49866 <colspec colwidth="6*" align="center"/>
49867 <colspec colwidth="6*" align="center"/>
49868 <colspec colwidth="6*" align="right"/>
49869 <tbody>
49870 <row>
49871 <entry><option>tls_tempfail_tryclear</option></entry>
49872 <entry>Use: <emphasis>smtp</emphasis></entry>
49873 <entry>Type: <emphasis>boolean</emphasis></entry>
49874 <entry>Default: <emphasis>true</emphasis></entry>
49875 </row>
49876 </tbody>
49877 </tgroup>
49878 </informaltable>
49879 <para>
49880 <indexterm role="concept">
49881 <primary>4<emphasis>xx</emphasis> responses</primary>
49882 <secondary>to STARTTLS</secondary>
49883 </indexterm>
49884 When the server host is not in <option>hosts_require_tls</option>, and there is a problem in
49885 setting up a TLS session, this option determines whether or not Exim should try
49886 to deliver the message unencrypted. If it is set false, delivery to the
49887 current host is deferred; if there are other hosts, they are tried. If this
49888 option is set true, Exim attempts to deliver unencrypted after a 4<emphasis>xx</emphasis>
49889 response to STARTTLS. Also, if STARTTLS is accepted, but the subsequent
49890 TLS negotiation fails, Exim closes the current connection (because it is in an
49891 unknown state), opens a new one to the same host, and then tries the delivery
49892 in clear.
49893 </para>
49894 <para>
49895 <indexterm role="option">
49896 <primary><option>tls_try_verify_hosts</option></primary>
49897 </indexterm>
49898 </para>
49899 <informaltable frame="all">
49900 <tgroup cols="4" colsep="0" rowsep="0">
49901 <colspec colwidth="8*" align="left"/>
49902 <colspec colwidth="6*" align="center"/>
49903 <colspec colwidth="6*" align="center"/>
49904 <colspec colwidth="6*" align="right"/>
49905 <tbody>
49906 <row>
49907 <entry><option>tls_try_verify_hosts</option></entry>
49908 <entry>Use: <emphasis>smtp</emphasis></entry>
49909 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
49910 <entry>Default: <emphasis>*</emphasis></entry>
49911 </row>
49912 </tbody>
49913 </tgroup>
49914 </informaltable>
49915 <para>
49916 <indexterm role="concept">
49917 <primary>TLS</primary>
49918 <secondary>server certificate verification</secondary>
49919 </indexterm>
49920 <indexterm role="concept">
49921 <primary>certificate</primary>
49922 <secondary>verification of server</secondary>
49923 </indexterm>
49924 This option gives a list of hosts for which, on encrypted connections,
49925 certificate verification will be tried but need not succeed.
49926 The <option>tls_verify_certificates</option> option must also be set.
49927 Note that unless the host is in this list
49928 TLS connections will be denied to hosts using self-signed certificates
49929 when <option>tls_verify_certificates</option> is matched.
49930 The <varname>$tls_out_certificate_verified</varname> variable is set when
49931 certificate verification succeeds.
49932 </para>
49933 <para>
49934 <indexterm role="option">
49935 <primary><option>tls_verify_cert_hostnames</option></primary>
49936 </indexterm>
49937 </para>
49938 <informaltable frame="all">
49939 <tgroup cols="4" colsep="0" rowsep="0">
49940 <colspec colwidth="8*" align="left"/>
49941 <colspec colwidth="6*" align="center"/>
49942 <colspec colwidth="6*" align="center"/>
49943 <colspec colwidth="6*" align="right"/>
49944 <tbody>
49945 <row>
49946 <entry><option>tls_verify_cert_hostnames</option></entry>
49947 <entry>Use: <emphasis>smtp</emphasis></entry>
49948 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
49949 <entry>Default: <emphasis>*</emphasis></entry>
49950 </row>
49951 </tbody>
49952 </tgroup>
49953 </informaltable>
49954 <para>
49955 <indexterm role="concept">
49956 <primary>TLS</primary>
49957 <secondary>server certificate hostname verification</secondary>
49958 </indexterm>
49959 <indexterm role="concept">
49960 <primary>certificate</primary>
49961 <secondary>verification of server</secondary>
49962 </indexterm>
49963 This option give a list of hosts for which,
49964 while verifying the server certificate,
49965 checks will be included on the host name
49966 (note that this will generally be the result of a DNS MX lookup)
49967 versus Subject and Subject-Alternate-Name fields.  Wildcard names are permitted
49968 limited to being the initial component of a 3-or-more component FQDN.
49969 </para>
49970 <para>
49971 There is no equivalent checking on client certificates.
49972 </para>
49973 <para>
49974 <indexterm role="option">
49975 <primary><option>tls_verify_certificates</option></primary>
49976 </indexterm>
49977 </para>
49978 <informaltable frame="all">
49979 <tgroup cols="4" colsep="0" rowsep="0">
49980 <colspec colwidth="8*" align="left"/>
49981 <colspec colwidth="6*" align="center"/>
49982 <colspec colwidth="6*" align="center"/>
49983 <colspec colwidth="6*" align="right"/>
49984 <tbody>
49985 <row>
49986 <entry><option>tls_verify_certificates</option></entry>
49987 <entry>Use: <emphasis>smtp</emphasis></entry>
49988 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
49989 <entry>Default: <emphasis>system</emphasis></entry>
49990 </row>
49991 </tbody>
49992 </tgroup>
49993 </informaltable>
49994 <para>
49995 <indexterm role="concept">
49996 <primary>TLS</primary>
49997 <secondary>server certificate verification</secondary>
49998 </indexterm>
49999 <indexterm role="concept">
50000 <primary>certificate</primary>
50001 <secondary>verification of server</secondary>
50002 </indexterm>
50003 <indexterm role="variable">
50004 <primary><varname>$host</varname></primary>
50005 </indexterm>
50006 <indexterm role="variable">
50007 <primary><varname>$host_address</varname></primary>
50008 </indexterm>
50009 The value of this option must be either the
50010 word "system"
50011 or the absolute path to
50012 a file or directory containing permitted certificates for servers,
50013 for use when setting up an encrypted connection.
50014 </para>
50015 <para>
50016 The "system" value for the option will use a location compiled into the SSL library.
50017 This is not available for GnuTLS versions preceding 3.0.20; a value of "system"
50018 is taken as empty and an explicit location
50019 must be specified.
50020 </para>
50021 <para>
50022 The use of a directory for the option value is not available for GnuTLS versions
50023 preceding 3.3.6 and a single file must be used.
50024 </para>
50025 <para>
50026 With OpenSSL the certificates specified
50027 explicitly
50028 either by file or directory
50029 are added to those given by the system default location.
50030 </para>
50031 <para>
50032 The values of <varname>$host</varname> and
50033 <varname>$host_address</varname> are set to the name and address of the server during the
50034 expansion of this option. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
50035 </para>
50036 <para>
50037 For back-compatibility,
50038 if neither tls_verify_hosts nor tls_try_verify_hosts are set
50039 (a single-colon empty list counts as being set)
50040 and certificate verification fails the TLS connection is closed.
50041 </para>
50042 <para>
50043 <indexterm role="option">
50044 <primary><option>tls_verify_hosts</option></primary>
50045 </indexterm>
50046 </para>
50047 <informaltable frame="all">
50048 <tgroup cols="4" colsep="0" rowsep="0">
50049 <colspec colwidth="8*" align="left"/>
50050 <colspec colwidth="6*" align="center"/>
50051 <colspec colwidth="6*" align="center"/>
50052 <colspec colwidth="6*" align="right"/>
50053 <tbody>
50054 <row>
50055 <entry><option>tls_verify_hosts</option></entry>
50056 <entry>Use: <emphasis>smtp</emphasis></entry>
50057 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
50058 <entry>Default: <emphasis>unset</emphasis></entry>
50059 </row>
50060 </tbody>
50061 </tgroup>
50062 </informaltable>
50063 <para>
50064 <indexterm role="concept">
50065 <primary>TLS</primary>
50066 <secondary>server certificate verification</secondary>
50067 </indexterm>
50068 <indexterm role="concept">
50069 <primary>certificate</primary>
50070 <secondary>verification of server</secondary>
50071 </indexterm>
50072 This option gives a list of hosts for which, on encrypted connections,
50073 certificate verification must succeed.
50074 The <option>tls_verify_certificates</option> option must also be set.
50075 If both this option and <option>tls_try_verify_hosts</option> are unset
50076 operation is as if this option selected all hosts.
50077 </para>
50078 <para>
50079 <indexterm role="option">
50080 <primary><option>utf8_downconvert</option></primary>
50081 </indexterm>
50082 </para>
50083 <informaltable frame="all">
50084 <tgroup cols="4" colsep="0" rowsep="0">
50085 <colspec colwidth="8*" align="left"/>
50086 <colspec colwidth="6*" align="center"/>
50087 <colspec colwidth="6*" align="center"/>
50088 <colspec colwidth="6*" align="right"/>
50089 <tbody>
50090 <row>
50091 <entry><option>utf8_downconvert</option></entry>
50092 <entry>Use: <emphasis>smtp</emphasis></entry>
50093 <entry>Type: <emphasis>integer!!</emphasis></entry>
50094 <entry>Default: <emphasis>unset</emphasis></entry>
50095 </row>
50096 </tbody>
50097 </tgroup>
50098 </informaltable>
50099 <para>
50100 <indexterm role="concept">
50101 <primary>utf8</primary>
50102 <secondary>address downconversion</secondary>
50103 </indexterm>
50104 <indexterm role="concept">
50105 <primary>i18n</primary>
50106 <secondary>utf8 address downconversion</secondary>
50107 </indexterm>
50108 If built with internationalization support,
50109 this option controls conversion of UTF-8 in message addresses
50110 to a-label form.
50111 For details see section <xref linkend="SECTi18nMTA"/>.
50112 </para>
50113 </section>
50114 <section id="SECTvalhosmax">
50115 <title>How the limits for the number of hosts to try are used</title>
50116 <para>
50117 <indexterm role="concept">
50118 <primary>host</primary>
50119 <secondary>maximum number to try</secondary>
50120 </indexterm>
50121 <indexterm role="concept">
50122 <primary>limit</primary>
50123 <secondary>hosts; maximum number tried</secondary>
50124 </indexterm>
50125 There are two options that are concerned with the number of hosts that are
50126 tried when an SMTP delivery takes place. They are <option>hosts_max_try</option> and
50127 <option>hosts_max_try_hardlimit</option>.
50128 </para>
50129 <para>
50130 The <option>hosts_max_try</option> option limits the number of hosts that are tried
50131 for a single delivery. However, despite the term <quote>host</quote> in its name, the
50132 option actually applies to each IP address independently. In other words, a
50133 multihomed host is treated as several independent hosts, just as it is for
50134 retrying.
50135 </para>
50136 <para>
50137 Many of the larger ISPs have multiple MX records which often point to
50138 multihomed hosts. As a result, a list of a dozen or more IP addresses may be
50139 created as a result of routing one of these domains.
50140 </para>
50141 <para>
50142 Trying every single IP address on such a long list does not seem sensible; if
50143 several at the top of the list fail, it is reasonable to assume there is some
50144 problem that is likely to affect all of them. Roughly speaking, the value of
50145 <option>hosts_max_try</option> is the maximum number that are tried before deferring the
50146 delivery. However, the logic cannot be quite that simple.
50147 </para>
50148 <para>
50149 Firstly, IP addresses that are skipped because their retry times have not
50150 arrived do not count, and in addition, addresses that are past their retry
50151 limits are also not counted, even when they are tried. This means that when
50152 some IP addresses are past their retry limits, more than the value of
50153 <option>hosts_max_retry</option> may be tried. The reason for this behaviour is to ensure
50154 that all IP addresses are considered before timing out an email address (but
50155 see below for an exception).
50156 </para>
50157 <para>
50158 Secondly, when the <option>hosts_max_try</option> limit is reached, Exim looks down the host
50159 list to see if there is a subsequent host with a different (higher valued) MX.
50160 If there is, that host is considered next, and the current IP address is used
50161 but not counted. This behaviour helps in the case of a domain with a retry rule
50162 that hardly ever delays any hosts, as is now explained:
50163 </para>
50164 <para>
50165 Consider the case of a long list of hosts with one MX value, and a few with a
50166 higher MX value. If <option>hosts_max_try</option> is small (the default is 5) only a few
50167 hosts at the top of the list are tried at first. With the default retry rule,
50168 which specifies increasing retry times, the higher MX hosts are eventually
50169 tried when those at the top of the list are skipped because they have not
50170 reached their retry times.
50171 </para>
50172 <para>
50173 However, it is common practice to put a fixed short retry time on domains for
50174 large ISPs, on the grounds that their servers are rarely down for very long.
50175 Unfortunately, these are exactly the domains that tend to resolve to long lists
50176 of hosts. The short retry time means that the lowest MX hosts are tried every
50177 time. The attempts may be in a different order because of random sorting, but
50178 without the special MX check, the higher MX hosts would never be tried until
50179 all the lower MX hosts had timed out (which might be several days), because
50180 there are always some lower MX hosts that have reached their retry times. With
50181 the special check, Exim considers at least one IP address from each MX value at
50182 every delivery attempt, even if the <option>hosts_max_try</option> limit has already been
50183 reached.
50184 </para>
50185 <para>
50186 The above logic means that <option>hosts_max_try</option> is not a hard limit, and in
50187 particular, Exim normally eventually tries all the IP addresses before timing
50188 out an email address. When <option>hosts_max_try</option> was implemented, this seemed a
50189 reasonable thing to do. Recently, however, some lunatic DNS configurations have
50190 been set up with hundreds of IP addresses for some domains. It can
50191 take a very long time indeed for an address to time out in these cases.
50192 </para>
50193 <para>
50194 The <option>hosts_max_try_hardlimit</option> option was added to help with this problem.
50195 Exim never tries more than this number of IP addresses; if it hits this limit
50196 and they are all timed out, the email address is bounced, even though not all
50197 possible IP addresses have been tried.
50198 <indexterm role="concept" startref="IIDsmttra1" class="endofrange"/>
50199 <indexterm role="concept" startref="IIDsmttra2" class="endofrange"/>
50200 </para>
50201 </section>
50202 </chapter>
50203
50204 <chapter id="CHAPrewrite">
50205 <title>Address rewriting</title>
50206 <para>
50207 <indexterm role="concept" id="IIDaddrew" class="startofrange">
50208 <primary>rewriting</primary>
50209 <secondary>addresses</secondary>
50210 </indexterm>
50211 There are some circumstances in which Exim automatically rewrites domains in
50212 addresses. The two most common are when an address is given without a domain
50213 (referred to as an <quote>unqualified address</quote>) or when an address contains an
50214 abbreviated domain that is expanded by DNS lookup.
50215 </para>
50216 <para>
50217 Unqualified envelope addresses are accepted only for locally submitted
50218 messages, or for messages that are received from hosts matching
50219 <option>sender_unqualified_hosts</option> or <option>recipient_unqualified_hosts</option>, as
50220 appropriate. Unqualified addresses in header lines are qualified if they are in
50221 locally submitted messages, or messages from hosts that are permitted to send
50222 unqualified envelope addresses. Otherwise, unqualified addresses in header
50223 lines are neither qualified nor rewritten.
50224 </para>
50225 <para>
50226 One situation in which Exim does <emphasis>not</emphasis> automatically rewrite a domain is
50227 when it is the name of a CNAME record in the DNS. The older RFCs suggest that
50228 such a domain should be rewritten using the <quote>canonical</quote> name, and some MTAs
50229 do this. The new RFCs do not contain this suggestion.
50230 </para>
50231 <section id="SECID147">
50232 <title>Explicitly configured address rewriting</title>
50233 <para>
50234 This chapter describes the rewriting rules that can be used in the
50235 main rewrite section of the configuration file, and also in the generic
50236 <option>headers_rewrite</option> option that can be set on any transport.
50237 </para>
50238 <para>
50239 Some people believe that configured address rewriting is a Mortal Sin.
50240 Others believe that life is not possible without it. Exim provides the
50241 facility; you do not have to use it.
50242 </para>
50243 <para>
50244 The main rewriting rules that appear in the <quote>rewrite</quote> section of the
50245 configuration file are applied to addresses in incoming messages, both envelope
50246 addresses and addresses in header lines. Each rule specifies the types of
50247 address to which it applies.
50248 </para>
50249 <para>
50250 Whether or not addresses in header lines are rewritten depends on the origin of
50251 the headers and the type of rewriting. Global rewriting, that is, rewriting
50252 rules from the rewrite section of the configuration file, is applied only to
50253 those headers that were received with the message. Header lines that are added
50254 by ACLs or by a system filter or by individual routers or transports (which
50255 are specific to individual recipient addresses) are not rewritten by the global
50256 rules.
50257 </para>
50258 <para>
50259 Rewriting at transport time, by means of the <option>headers_rewrite</option> option,
50260 applies all headers except those added by routers and transports. That is, as
50261 well as the headers that were received with the message, it also applies to
50262 headers that were added by an ACL or a system filter.
50263 </para>
50264 <para>
50265 In general, rewriting addresses from your own system or domain has some
50266 legitimacy. Rewriting other addresses should be done only with great care and
50267 in special circumstances. The author of Exim believes that rewriting should be
50268 used sparingly, and mainly for <quote>regularizing</quote> addresses in your own domains.
50269 Although it can sometimes be used as a routing tool, this is very strongly
50270 discouraged.
50271 </para>
50272 <para>
50273 There are two commonly encountered circumstances where rewriting is used, as
50274 illustrated by these examples:
50275 </para>
50276 <itemizedlist>
50277 <listitem>
50278 <para>
50279 The company whose domain is <emphasis>hitch.fict.example</emphasis> has a number of hosts that
50280 exchange mail with each other behind a firewall, but there is only a single
50281 gateway to the outer world. The gateway rewrites <emphasis>*.hitch.fict.example</emphasis> as
50282 <emphasis>hitch.fict.example</emphasis> when sending mail off-site.
50283 </para>
50284 </listitem>
50285 <listitem>
50286 <para>
50287 A host rewrites the local parts of its own users so that, for example,
50288 <emphasis>fp42@hitch.fict.example</emphasis> becomes <emphasis>Ford.Prefect@hitch.fict.example</emphasis>.
50289 </para>
50290 </listitem>
50291 </itemizedlist>
50292 </section>
50293 <section id="SECID148">
50294 <title>When does rewriting happen?</title>
50295 <para>
50296 <indexterm role="concept">
50297 <primary>rewriting</primary>
50298 <secondary>timing of</secondary>
50299 </indexterm>
50300 <indexterm role="concept">
50301 <primary>access control lists (ACLs)</primary>
50302 <secondary>rewriting addresses in</secondary>
50303 </indexterm>
50304 Configured address rewriting can take place at several different stages of a
50305 message&#x2019;s processing.
50306 </para>
50307 <para>
50308 <indexterm role="variable">
50309 <primary><varname>$sender_address</varname></primary>
50310 </indexterm>
50311 At the start of an ACL for MAIL, the sender address may have been rewritten
50312 by a special SMTP-time rewrite rule (see section <xref linkend="SECTrewriteS"/>), but no
50313 ordinary rewrite rules have yet been applied. If, however, the sender address
50314 is verified in the ACL, it is rewritten before verification, and remains
50315 rewritten thereafter. The subsequent value of <varname>$sender_address</varname> is the
50316 rewritten address. This also applies if sender verification happens in a
50317 RCPT ACL. Otherwise, when the sender address is not verified, it is
50318 rewritten as soon as a message&#x2019;s header lines have been received.
50319 </para>
50320 <para>
50321 <indexterm role="variable">
50322 <primary><varname>$domain</varname></primary>
50323 </indexterm>
50324 <indexterm role="variable">
50325 <primary><varname>$local_part</varname></primary>
50326 </indexterm>
50327 Similarly, at the start of an ACL for RCPT, the current recipient&#x2019;s address
50328 may have been rewritten by a special SMTP-time rewrite rule, but no ordinary
50329 rewrite rules have yet been applied to it. However, the behaviour is different
50330 from the sender address when a recipient is verified. The address is rewritten
50331 for the verification, but the rewriting is not remembered at this stage. The
50332 value of <varname>$local_part</varname> and <varname>$domain</varname> after verification are always the same
50333 as they were before (that is, they contain the unrewritten &ndash; except for
50334 SMTP-time rewriting &ndash; address).
50335 </para>
50336 <para>
50337 As soon as a message&#x2019;s header lines have been received, all the envelope
50338 recipient addresses are permanently rewritten, and rewriting is also applied to
50339 the addresses in the header lines (if configured). This happens before adding
50340 any header lines that were specified in MAIL or RCPT ACLs, and
50341 <indexterm role="concept">
50342 <primary><function>local_scan()</function> function</primary>
50343 <secondary>address rewriting; timing of</secondary>
50344 </indexterm>
50345 before the DATA ACL and <function>local_scan()</function> functions are run.
50346 </para>
50347 <para>
50348 When an address is being routed, either for delivery or for verification,
50349 rewriting is applied immediately to child addresses that are generated by
50350 redirection, unless <option>no_rewrite</option> is set on the router.
50351 </para>
50352 <para>
50353 <indexterm role="concept">
50354 <primary>envelope from</primary>
50355 </indexterm>
50356 <indexterm role="concept">
50357 <primary>envelope sender</primary>
50358 <secondary>rewriting at transport time</secondary>
50359 </indexterm>
50360 <indexterm role="concept">
50361 <primary>rewriting</primary>
50362 <secondary>at transport time</secondary>
50363 </indexterm>
50364 <indexterm role="concept">
50365 <primary>header lines</primary>
50366 <secondary>rewriting at transport time</secondary>
50367 </indexterm>
50368 At transport time, additional rewriting of addresses in header lines can be
50369 specified by setting the generic <option>headers_rewrite</option> option on a transport.
50370 This option contains rules that are identical in form to those in the rewrite
50371 section of the configuration file. They are applied to the original message
50372 header lines and any that were added by ACLs or a system filter. They are not
50373 applied to header lines that are added by routers or the transport.
50374 </para>
50375 <para>
50376 The outgoing envelope sender can be rewritten by means of the <option>return_path</option>
50377 transport option. However, it is not possible to rewrite envelope recipients at
50378 transport time.
50379 </para>
50380 </section>
50381 <section id="SECID149">
50382 <title>Testing the rewriting rules that apply on input</title>
50383 <para>
50384 <indexterm role="concept">
50385 <primary>rewriting</primary>
50386 <secondary>testing</secondary>
50387 </indexterm>
50388 <indexterm role="concept">
50389 <primary>testing</primary>
50390 <secondary>rewriting</secondary>
50391 </indexterm>
50392 Exim&#x2019;s input rewriting configuration appears in a part of the runtime
50393 configuration file headed by <quote>begin rewrite</quote>. It can be tested by the
50394 <option>-brw</option> command line option. This takes an address (which can be a full RFC
50395 2822 address) as its argument. The output is a list of how the address would be
50396 transformed by the rewriting rules for each of the different places it might
50397 appear in an incoming message, that is, for each different header and for the
50398 envelope sender and recipient fields. For example,
50399 </para>
50400 <literallayout class="monospaced">
50401 exim -brw ph10@exim.workshop.example
50402 </literallayout>
50403 <para>
50404 might produce the output
50405 </para>
50406 <literallayout class="monospaced">
50407 sender: Philip.Hazel@exim.workshop.example
50408 from: Philip.Hazel@exim.workshop.example
50409 to: ph10@exim.workshop.example
50410 cc: ph10@exim.workshop.example
50411 bcc: ph10@exim.workshop.example
50412 reply-to: Philip.Hazel@exim.workshop.example
50413 env-from: Philip.Hazel@exim.workshop.example
50414 env-to: ph10@exim.workshop.example
50415 </literallayout>
50416 <para>
50417 which shows that rewriting has been set up for that address when used in any of
50418 the source fields, but not when it appears as a recipient address. At the
50419 present time, there is no equivalent way of testing rewriting rules that are
50420 set for a particular transport.
50421 </para>
50422 </section>
50423 <section id="SECID150">
50424 <title>Rewriting rules</title>
50425 <para>
50426 <indexterm role="concept">
50427 <primary>rewriting</primary>
50428 <secondary>rules</secondary>
50429 </indexterm>
50430 The rewrite section of the configuration file consists of lines of rewriting
50431 rules in the form
50432 </para>
50433 <literallayout>
50434 &lt;<emphasis>source pattern</emphasis>&gt;  &lt;<emphasis>replacement</emphasis>&gt;  &lt;<emphasis>flags</emphasis>&gt;
50435 </literallayout>
50436 <para>
50437 Rewriting rules that are specified for the <option>headers_rewrite</option> generic
50438 transport option are given as a colon-separated list. Each item in the list
50439 takes the same form as a line in the main rewriting configuration (except that
50440 any colons must be doubled, of course).
50441 </para>
50442 <para>
50443 The formats of source patterns and replacement strings are described below.
50444 Each is terminated by white space, unless enclosed in double quotes, in which
50445 case normal quoting conventions apply inside the quotes. The flags are single
50446 characters which may appear in any order. Spaces and tabs between them are
50447 ignored.
50448 </para>
50449 <para>
50450 For each address that could potentially be rewritten, the rules are scanned in
50451 order, and replacements for the address from earlier rules can themselves be
50452 replaced by later rules (but see the <quote>q</quote> and <quote>R</quote> flags).
50453 </para>
50454 <para>
50455 The order in which addresses are rewritten is undefined, may change between
50456 releases, and must not be relied on, with one exception: when a message is
50457 received, the envelope sender is always rewritten first, before any header
50458 lines are rewritten. For example, the replacement string for a rewrite of an
50459 address in <emphasis>To:</emphasis> must not assume that the message&#x2019;s address in <emphasis>From:</emphasis> has
50460 (or has not) already been rewritten. However, a rewrite of <emphasis>From:</emphasis> may assume
50461 that the envelope sender has already been rewritten.
50462 </para>
50463 <para>
50464 <indexterm role="variable">
50465 <primary><varname>$domain</varname></primary>
50466 </indexterm>
50467 <indexterm role="variable">
50468 <primary><varname>$local_part</varname></primary>
50469 </indexterm>
50470 The variables <varname>$local_part</varname> and <varname>$domain</varname> can be used in the replacement
50471 string to refer to the address that is being rewritten. Note that lookup-driven
50472 rewriting can be done by a rule of the form
50473 </para>
50474 <literallayout class="monospaced">
50475 *@*   ${lookup ...
50476 </literallayout>
50477 <para>
50478 where the lookup key uses <varname>$1</varname> and <varname>$2</varname> or <varname>$local_part</varname> and <varname>$domain</varname> to
50479 refer to the address that is being rewritten.
50480 </para>
50481 </section>
50482 <section id="SECID151">
50483 <title>Rewriting patterns</title>
50484 <para>
50485 <indexterm role="concept">
50486 <primary>rewriting</primary>
50487 <secondary>patterns</secondary>
50488 </indexterm>
50489 <indexterm role="concept">
50490 <primary>address list</primary>
50491 <secondary>in a rewriting pattern</secondary>
50492 </indexterm>
50493 The source pattern in a rewriting rule is any item which may appear in an
50494 address list (see section <xref linkend="SECTaddresslist"/>). It is in fact processed as a
50495 single-item address list, which means that it is expanded before being tested
50496 against the address. As always, if you use a regular expression as a pattern,
50497 you must take care to escape dollar and backslash characters, or use the <literal>\N</literal>
50498 facility to suppress string expansion within the regular expression.
50499 </para>
50500 <para>
50501 Domains in patterns should be given in lower case. Local parts in patterns are
50502 case-sensitive. If you want to do case-insensitive matching of local parts, you
50503 can use a regular expression that starts with <literal>^(?i)</literal>.
50504 </para>
50505 <para>
50506 <indexterm role="concept">
50507 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
50508 <secondary>in rewriting rules</secondary>
50509 </indexterm>
50510 After matching, the numerical variables <varname>$1</varname>, <varname>$2</varname>, etc. may be set,
50511 depending on the type of match which occurred. These can be used in the
50512 replacement string to insert portions of the incoming address. <varname>$0</varname> always
50513 refers to the complete incoming address. When a regular expression is used, the
50514 numerical variables are set from its capturing subexpressions. For other types
50515 of pattern they are set as follows:
50516 </para>
50517 <itemizedlist>
50518 <listitem>
50519 <para>
50520 If a local part or domain starts with an asterisk, the numerical variables
50521 refer to the character strings matched by asterisks, with <varname>$1</varname> associated with
50522 the first asterisk, and <varname>$2</varname> with the second, if present. For example, if the
50523 pattern
50524 </para>
50525 <literallayout class="monospaced">
50526 *queen@*.fict.example
50527 </literallayout>
50528 <para>
50529 is matched against the address <emphasis>hearts-queen@wonderland.fict.example</emphasis> then
50530 </para>
50531 <literallayout class="monospaced">
50532 $0 = hearts-queen@wonderland.fict.example
50533 $1 = hearts-
50534 $2 = wonderland
50535 </literallayout>
50536 <para>
50537 Note that if the local part does not start with an asterisk, but the domain
50538 does, it is <varname>$1</varname> that contains the wild part of the domain.
50539 </para>
50540 </listitem>
50541 <listitem>
50542 <para>
50543 If the domain part of the pattern is a partial lookup, the wild and fixed parts
50544 of the domain are placed in the next available numerical variables. Suppose,
50545 for example, that the address <emphasis>foo@bar.baz.example</emphasis> is processed by a
50546 rewriting rule of the form
50547 </para>
50548 <literallayout>
50549 <literal>*@partial-dbm;/some/dbm/file</literal>    &lt;<emphasis>replacement string</emphasis>&gt;
50550 </literallayout>
50551 <para>
50552 and the key in the file that matches the domain is <literal>*.baz.example</literal>. Then
50553 </para>
50554 <literallayout class="monospaced">
50555 $1 = foo
50556 $2 = bar
50557 $3 = baz.example
50558 </literallayout>
50559 <para>
50560 If the address <emphasis>foo@baz.example</emphasis> is looked up, this matches the same
50561 wildcard file entry, and in this case <varname>$2</varname> is set to the empty string, but
50562 <varname>$3</varname> is still set to <emphasis>baz.example</emphasis>. If a non-wild key is matched in a
50563 partial lookup, <varname>$2</varname> is again set to the empty string and <varname>$3</varname> is set to the
50564 whole domain. For non-partial domain lookups, no numerical variables are set.
50565 </para>
50566 </listitem>
50567 </itemizedlist>
50568 </section>
50569 <section id="SECID152">
50570 <title>Rewriting replacements</title>
50571 <para>
50572 <indexterm role="concept">
50573 <primary>rewriting</primary>
50574 <secondary>replacements</secondary>
50575 </indexterm>
50576 If the replacement string for a rule is a single asterisk, addresses that
50577 match the pattern and the flags are <emphasis>not</emphasis> rewritten, and no subsequent
50578 rewriting rules are scanned. For example,
50579 </para>
50580 <literallayout class="monospaced">
50581 hatta@lookingglass.fict.example  *  f
50582 </literallayout>
50583 <para>
50584 specifies that <emphasis>hatta@lookingglass.fict.example</emphasis> is never to be rewritten in
50585 <emphasis>From:</emphasis> headers.
50586 </para>
50587 <para>
50588 <indexterm role="variable">
50589 <primary><varname>$domain</varname></primary>
50590 </indexterm>
50591 <indexterm role="variable">
50592 <primary><varname>$local_part</varname></primary>
50593 </indexterm>
50594 If the replacement string is not a single asterisk, it is expanded, and must
50595 yield a fully qualified address. Within the expansion, the variables
50596 <varname>$local_part</varname> and <varname>$domain</varname> refer to the address that is being rewritten.
50597 Any letters they contain retain their original case &ndash; they are not lower
50598 cased. The numerical variables are set up according to the type of pattern that
50599 matched the address, as described above. If the expansion is forced to fail by
50600 the presence of <quote>fail</quote> in a conditional or lookup item, rewriting by the
50601 current rule is abandoned, but subsequent rules may take effect. Any other
50602 expansion failure causes the entire rewriting operation to be abandoned, and an
50603 entry written to the panic log.
50604 </para>
50605 </section>
50606 <section id="SECID153">
50607 <title>Rewriting flags</title>
50608 <para>
50609 There are three different kinds of flag that may appear on rewriting rules:
50610 </para>
50611 <itemizedlist>
50612 <listitem>
50613 <para>
50614 Flags that specify which headers and envelope addresses to rewrite: E, F, T, b,
50615 c, f, h, r, s, t.
50616 </para>
50617 </listitem>
50618 <listitem>
50619 <para>
50620 A flag that specifies rewriting at SMTP time: S.
50621 </para>
50622 </listitem>
50623 <listitem>
50624 <para>
50625 Flags that control the rewriting process: Q, q, R, w.
50626 </para>
50627 </listitem>
50628 </itemizedlist>
50629 <para>
50630 For rules that are part of the <option>headers_rewrite</option> generic transport option,
50631 E, F, T, and S are not permitted.
50632 </para>
50633 </section>
50634 <section id="SECID154">
50635 <title>Flags specifying which headers and envelope addresses to rewrite</title>
50636 <para>
50637 <indexterm role="concept">
50638 <primary>rewriting</primary>
50639 <secondary>flags</secondary>
50640 </indexterm>
50641 If none of the following flag letters, nor the <quote>S</quote> flag (see section
50642 <xref linkend="SECTrewriteS"/>) are present, a main rewriting rule applies to all headers
50643 and to both the sender and recipient fields of the envelope, whereas a
50644 transport-time rewriting rule just applies to all headers. Otherwise, the
50645 rewriting rule is skipped unless the relevant addresses are being processed.
50646 </para>
50647 <literallayout>
50648 <literal>E</literal>       rewrite all envelope fields
50649 <literal>F</literal>       rewrite the envelope From field
50650 <literal>T</literal>       rewrite the envelope To field
50651 <literal>b</literal>       rewrite the <emphasis>Bcc:</emphasis> header
50652 <literal>c</literal>       rewrite the <emphasis>Cc:</emphasis> header
50653 <literal>f</literal>       rewrite the <emphasis>From:</emphasis> header
50654 <literal>h</literal>       rewrite all headers
50655 <literal>r</literal>       rewrite the <emphasis>Reply-To:</emphasis> header
50656 <literal>s</literal>       rewrite the <emphasis>Sender:</emphasis> header
50657 <literal>t</literal>       rewrite the <emphasis>To:</emphasis> header
50658 </literallayout>
50659 <para>
50660 "All headers" means all of the headers listed above that can be selected
50661 individually, plus their <emphasis>Resent-</emphasis> versions. It does not include
50662 other headers such as <emphasis>Subject:</emphasis> etc.
50663 </para>
50664 <para>
50665 You should be particularly careful about rewriting <emphasis>Sender:</emphasis> headers, and
50666 restrict this to special known cases in your own domains.
50667 </para>
50668 </section>
50669 <section id="SECTrewriteS">
50670 <title>The SMTP-time rewriting flag</title>
50671 <para>
50672 <indexterm role="concept">
50673 <primary>SMTP</primary>
50674 <secondary>rewriting malformed addresses</secondary>
50675 </indexterm>
50676 <indexterm role="concept">
50677 <primary>RCPT</primary>
50678 <secondary>rewriting argument of</secondary>
50679 </indexterm>
50680 <indexterm role="concept">
50681 <primary>MAIL</primary>
50682 <secondary>rewriting argument of</secondary>
50683 </indexterm>
50684 The rewrite flag <quote>S</quote> specifies a rewrite of incoming envelope addresses at
50685 SMTP time, as soon as an address is received in a MAIL or RCPT command, and
50686 before any other processing; even before syntax checking. The pattern is
50687 required to be a regular expression, and it is matched against the whole of the
50688 data for the command, including any surrounding angle brackets.
50689 </para>
50690 <para>
50691 <indexterm role="variable">
50692 <primary><varname>$domain</varname></primary>
50693 </indexterm>
50694 <indexterm role="variable">
50695 <primary><varname>$local_part</varname></primary>
50696 </indexterm>
50697 This form of rewrite rule allows for the handling of addresses that are not
50698 compliant with RFCs 2821 and 2822 (for example, <quote>bang paths</quote> in batched SMTP
50699 input). Because the input is not required to be a syntactically valid address,
50700 the variables <varname>$local_part</varname> and <varname>$domain</varname> are not available during the
50701 expansion of the replacement string. The result of rewriting replaces the
50702 original address in the MAIL or RCPT command.
50703 </para>
50704 </section>
50705 <section id="SECID155">
50706 <title>Flags controlling the rewriting process</title>
50707 <para>
50708 There are four flags which control the way the rewriting process works. These
50709 take effect only when a rule is invoked, that is, when the address is of the
50710 correct type (matches the flags) and matches the pattern:
50711 </para>
50712 <itemizedlist>
50713 <listitem>
50714 <para>
50715 If the <quote>Q</quote> flag is set on a rule, the rewritten address is permitted to be an
50716 unqualified local part. It is qualified with <option>qualify_recipient</option>. In the
50717 absence of <quote>Q</quote> the rewritten address must always include a domain.
50718 </para>
50719 </listitem>
50720 <listitem>
50721 <para>
50722 If the <quote>q</quote> flag is set on a rule, no further rewriting rules are considered,
50723 even if no rewriting actually takes place because of a <quote>fail</quote> in the
50724 expansion. The <quote>q</quote> flag is not effective if the address is of the wrong type
50725 (does not match the flags) or does not match the pattern.
50726 </para>
50727 </listitem>
50728 <listitem>
50729 <para>
50730 The <quote>R</quote> flag causes a successful rewriting rule to be re-applied to the new
50731 address, up to ten times. It can be combined with the <quote>q</quote> flag, to stop
50732 rewriting once it fails to match (after at least one successful rewrite).
50733 </para>
50734 </listitem>
50735 <listitem>
50736 <para>
50737 <indexterm role="concept">
50738 <primary>rewriting</primary>
50739 <secondary>whole addresses</secondary>
50740 </indexterm>
50741 When an address in a header is rewritten, the rewriting normally applies only
50742 to the working part of the address, with any comments and RFC 2822 <quote>phrase</quote>
50743 left unchanged. For example, rewriting might change
50744 </para>
50745 <literallayout class="monospaced">
50746 From: Ford Prefect &lt;fp42@restaurant.hitch.fict.example&gt;
50747 </literallayout>
50748 <para>
50749 into
50750 </para>
50751 <literallayout class="monospaced">
50752 From: Ford Prefect &lt;prefectf@hitch.fict.example&gt;
50753 </literallayout>
50754 <para>
50755 <indexterm role="concept">
50756 <primary>RFC 2047</primary>
50757 </indexterm>
50758 Sometimes there is a need to replace the whole address item, and this can be
50759 done by adding the flag letter <quote>w</quote> to a rule. If this is set on a rule that
50760 causes an address in a header line to be rewritten, the entire address is
50761 replaced, not just the working part. The replacement must be a complete RFC
50762 2822 address, including the angle brackets if necessary. If text outside angle
50763 brackets contains a character whose value is greater than 126 or less than 32
50764 (except for tab), the text is encoded according to RFC 2047. The character set
50765 is taken from <option>headers_charset</option>, which gets its default at build time.
50766 </para>
50767 <para>
50768 When the <quote>w</quote> flag is set on a rule that causes an envelope address to be
50769 rewritten, all but the working part of the replacement address is discarded.
50770 </para>
50771 </listitem>
50772 </itemizedlist>
50773 </section>
50774 <section id="SECID156">
50775 <title>Rewriting examples</title>
50776 <para>
50777 Here is an example of the two common rewriting paradigms:
50778 </para>
50779 <literallayout class="monospaced">
50780 *@*.hitch.fict.example  $1@hitch.fict.example
50781 *@hitch.fict.example    ${lookup{$1}dbm{/etc/realnames}\
50782                      {$value}fail}@hitch.fict.example bctfrF
50783 </literallayout>
50784 <para>
50785 Note the use of <quote>fail</quote> in the lookup expansion in the second rule, forcing
50786 the string expansion to fail if the lookup does not succeed. In this context it
50787 has the effect of leaving the original address unchanged, but Exim goes on to
50788 consider subsequent rewriting rules, if any, because the <quote>q</quote> flag is not
50789 present in that rule. An alternative to <quote>fail</quote> would be to supply <varname>$1</varname>
50790 explicitly, which would cause the rewritten address to be the same as before,
50791 at the cost of a small bit of processing. Not supplying either of these is an
50792 error, since the rewritten address would then contain no local part.
50793 </para>
50794 <para>
50795 The first example above replaces the domain with a superior, more general
50796 domain. This may not be desirable for certain local parts. If the rule
50797 </para>
50798 <literallayout class="monospaced">
50799 root@*.hitch.fict.example  *
50800 </literallayout>
50801 <para>
50802 were inserted before the first rule, rewriting would be suppressed for the
50803 local part <emphasis>root</emphasis> at any domain ending in <emphasis>hitch.fict.example</emphasis>.
50804 </para>
50805 <para>
50806 Rewriting can be made conditional on a number of tests, by making use of
50807 <varname>${if</varname> in the expansion item. For example, to apply a rewriting rule only to
50808 messages that originate outside the local host:
50809 </para>
50810 <literallayout class="monospaced">
50811 *@*.hitch.fict.example  "${if !eq {$sender_host_address}{}\
50812                          {$1@hitch.fict.example}fail}"
50813 </literallayout>
50814 <para>
50815 The replacement string is quoted in this example because it contains white
50816 space.
50817 </para>
50818 <para>
50819 <indexterm role="concept">
50820 <primary>rewriting</primary>
50821 <secondary>bang paths</secondary>
50822 </indexterm>
50823 <indexterm role="concept">
50824 <primary>bang paths</primary>
50825 <secondary>rewriting</secondary>
50826 </indexterm>
50827 Exim does not handle addresses in the form of <quote>bang paths</quote>. If it sees such
50828 an address it treats it as an unqualified local part which it qualifies with
50829 the local qualification domain (if the source of the message is local or if the
50830 remote host is permitted to send unqualified addresses). Rewriting can
50831 sometimes be used to handle simple bang paths with a fixed number of
50832 components. For example, the rule
50833 </para>
50834 <literallayout class="monospaced">
50835 \N^([^!]+)!(.*)@your.domain.example$\N   $2@$1
50836 </literallayout>
50837 <para>
50838 rewrites a two-component bang path <emphasis>host.name!user</emphasis> as the domain address
50839 <emphasis>user@host.name</emphasis>. However, there is a security implication in using this as
50840 a global rewriting rule for envelope addresses. It can provide a backdoor
50841 method for using your system as a relay, because the incoming addresses appear
50842 to be local. If the bang path addresses are received via SMTP, it is safer to
50843 use the <quote>S</quote> flag to rewrite them as they are received, so that relay checking
50844 can be done on the rewritten addresses.
50845 <indexterm role="concept" startref="IIDaddrew" class="endofrange"/>
50846 </para>
50847 </section>
50848 </chapter>
50849
50850 <chapter id="CHAPretry">
50851 <title>Retry configuration</title>
50852 <para>
50853 <indexterm role="concept" id="IIDretconf1" class="startofrange">
50854 <primary>retry</primary>
50855 <secondary>configuration, description of</secondary>
50856 </indexterm>
50857 <indexterm role="concept" id="IIDregconf2" class="startofrange">
50858 <primary>configuration file</primary>
50859 <secondary>retry section</secondary>
50860 </indexterm>
50861 The <quote>retry</quote> section of the runtime configuration file contains a list of
50862 retry rules that control how often Exim tries to deliver messages that cannot
50863 be delivered at the first attempt. If there are no retry rules (the section is
50864 empty or not present), there are no retries. In this situation, temporary
50865 errors are treated as permanent. The default configuration contains a single,
50866 general-purpose retry rule (see section <xref linkend="SECID57"/>). The <option>-brt</option> command
50867 line option can be used to test which retry rule will be used for a given
50868 address, domain and error.
50869 </para>
50870 <para>
50871 The most common cause of retries is temporary failure to deliver to a remote
50872 host because the host is down, or inaccessible because of a network problem.
50873 Exim&#x2019;s retry processing in this case is applied on a per-host (strictly, per IP
50874 address) basis, not on a per-message basis. Thus, if one message has recently
50875 been delayed, delivery of a new message to the same host is not immediately
50876 tried, but waits for the host&#x2019;s retry time to arrive. If the <option>retry_defer</option>
50877 log selector is set, the message
50878 <indexterm role="concept">
50879 <primary>retry</primary>
50880 <secondary>time not reached</secondary>
50881 </indexterm>
50882 <quote>retry time not reached</quote> is written to the main log whenever a delivery is
50883 skipped for this reason. Section <xref linkend="SECToutSMTPerr"/> contains more details of
50884 the handling of errors during remote deliveries.
50885 </para>
50886 <para>
50887 Retry processing applies to routing as well as to delivering, except as covered
50888 in the next paragraph. The retry rules do not distinguish between these
50889 actions. It is not possible, for example, to specify different behaviour for
50890 failures to route the domain <emphasis>snark.fict.example</emphasis> and failures to deliver to
50891 the host <emphasis>snark.fict.example</emphasis>. I didn&#x2019;t think anyone would ever need this
50892 added complication, so did not implement it. However, although they share the
50893 same retry rule, the actual retry times for routing and transporting a given
50894 domain are maintained independently.
50895 </para>
50896 <para>
50897 When a delivery is not part of a queue run (typically an immediate delivery on
50898 receipt of a message), the routers are always run, and local deliveries are
50899 always attempted, even if retry times are set for them. This makes for better
50900 behaviour if one particular message is causing problems (for example, causing
50901 quota overflow, or provoking an error in a filter file). If such a delivery
50902 suffers a temporary failure, the retry data is updated as normal, and
50903 subsequent delivery attempts from queue runs occur only when the retry time for
50904 the local address is reached.
50905 </para>
50906 <section id="SECID157">
50907 <title>Changing retry rules</title>
50908 <para>
50909 If you change the retry rules in your configuration, you should consider
50910 whether or not to delete the retry data that is stored in Exim&#x2019;s spool area in
50911 files with names like <filename>db/retry</filename>. Deleting any of Exim&#x2019;s hints files is
50912 always safe; that is why they are called <quote>hints</quote>.
50913 </para>
50914 <para>
50915 The hints retry data contains suggested retry times based on the previous
50916 rules. In the case of a long-running problem with a remote host, it might
50917 record the fact that the host has timed out. If your new rules increase the
50918 timeout time for such a host, you should definitely remove the old retry data
50919 and let Exim recreate it, based on the new rules. Otherwise Exim might bounce
50920 messages that it should now be retaining.
50921 </para>
50922 </section>
50923 <section id="SECID158">
50924 <title>Format of retry rules</title>
50925 <para>
50926 <indexterm role="concept">
50927 <primary>retry</primary>
50928 <secondary>rules</secondary>
50929 </indexterm>
50930 Each retry rule occupies one line and consists of three or four parts,
50931 separated by white space: a pattern, an error name, an optional list of sender
50932 addresses, and a list of retry parameters. The pattern and sender lists must be
50933 enclosed in double quotes if they contain white space. The rules are searched
50934 in order until one is found where the pattern, error name, and sender list (if
50935 present) match the failing host or address, the error that occurred, and the
50936 message&#x2019;s sender, respectively.
50937 </para>
50938 <para>
50939 The pattern is any single item that may appear in an address list (see section
50940 <xref linkend="SECTaddresslist"/>). It is in fact processed as a one-item address list,
50941 which means that it is expanded before being tested against the address that
50942 has been delayed. A negated address list item is permitted. Address
50943 list processing treats a plain domain name as if it were preceded by <quote>*@</quote>,
50944 which makes it possible for many retry rules to start with just a domain. For
50945 example,
50946 </para>
50947 <literallayout class="monospaced">
50948 lookingglass.fict.example        *  F,24h,30m;
50949 </literallayout>
50950 <para>
50951 provides a rule for any address in the <emphasis>lookingglass.fict.example</emphasis> domain,
50952 whereas
50953 </para>
50954 <literallayout class="monospaced">
50955 alice@lookingglass.fict.example  *  F,24h,30m;
50956 </literallayout>
50957 <para>
50958 applies only to temporary failures involving the local part <option>alice</option>.
50959 In practice, almost all rules start with a domain name pattern without a local
50960 part.
50961 </para>
50962 <para>
50963 <indexterm role="concept">
50964 <primary>regular expressions</primary>
50965 <secondary>in retry rules</secondary>
50966 </indexterm>
50967 <emphasis role="bold">Warning</emphasis>: If you use a regular expression in a retry rule pattern, it
50968 must match a complete address, not just a domain, because that is how regular
50969 expressions work in address lists.
50970 </para>
50971 <literallayout>
50972 <literal>^\Nxyz\d+\.abc\.example$\N        *  G,1h,10m,2</literal>     <option>Wrong</option>
50973 <literal>^\N[^@]+@xyz\d+\.abc\.example$\N  *  G,1h,10m,2</literal>     <option>Right</option>
50974 </literallayout>
50975 </section>
50976 <section id="SECID159">
50977 <title>Choosing which retry rule to use for address errors</title>
50978 <para>
50979 When Exim is looking for a retry rule after a routing attempt has failed (for
50980 example, after a DNS timeout), each line in the retry configuration is tested
50981 against the complete address only if <option>retry_use_local_part</option> is set for the
50982 router. Otherwise, only the domain is used, except when matching against a
50983 regular expression, when the local part of the address is replaced with <quote>*</quote>.
50984 A domain on its own can match a domain pattern, or a pattern that starts with
50985 <quote>*@</quote>. By default, <option>retry_use_local_part</option> is true for routers where
50986 <option>check_local_user</option> is true, and false for other routers.
50987 </para>
50988 <para>
50989 Similarly, when Exim is looking for a retry rule after a local delivery has
50990 failed (for example, after a mailbox full error), each line in the retry
50991 configuration is tested against the complete address only if
50992 <option>retry_use_local_part</option> is set for the transport (it defaults true for all
50993 local transports).
50994 </para>
50995 <para>
50996 <indexterm role="concept">
50997 <primary>4<emphasis>xx</emphasis> responses</primary>
50998 <secondary>retry rules for</secondary>
50999 </indexterm>
51000 However, when Exim is looking for a retry rule after a remote delivery attempt
51001 suffers an address error (a 4<emphasis>xx</emphasis> SMTP response for a recipient address), the
51002 whole address is always used as the key when searching the retry rules. The
51003 rule that is found is used to create a retry time for the combination of the
51004 failing address and the message&#x2019;s sender. It is the combination of sender and
51005 recipient that is delayed in subsequent queue runs until its retry time is
51006 reached. You can delay the recipient without regard to the sender by setting
51007 <option>address_retry_include_sender</option> false in the <command>smtp</command> transport but this can
51008 lead to problems with servers that regularly issue 4<emphasis>xx</emphasis> responses to RCPT
51009 commands.
51010 </para>
51011 </section>
51012 <section id="SECID160">
51013 <title>Choosing which retry rule to use for host and message errors</title>
51014 <para>
51015 For a temporary error that is not related to an individual address (for
51016 example, a connection timeout), each line in the retry configuration is checked
51017 twice. First, the name of the remote host is used as a domain name (preceded by
51018 <quote>*@</quote> when matching a regular expression). If this does not match the line,
51019 the domain from the email address is tried in a similar fashion. For example,
51020 suppose the MX records for <emphasis>a.b.c.example</emphasis> are
51021 </para>
51022 <literallayout class="monospaced">
51023 a.b.c.example  MX  5  x.y.z.example
51024                MX  6  p.q.r.example
51025                MX  7  m.n.o.example
51026 </literallayout>
51027 <para>
51028 and the retry rules are
51029 </para>
51030 <literallayout class="monospaced">
51031 p.q.r.example    *      F,24h,30m;
51032 a.b.c.example    *      F,4d,45m;
51033 </literallayout>
51034 <para>
51035 and a delivery to the host <emphasis>x.y.z.example</emphasis> suffers a connection failure. The
51036 first rule matches neither the host nor the domain, so Exim looks at the second
51037 rule. This does not match the host, but it does match the domain, so it is used
51038 to calculate the retry time for the host <emphasis>x.y.z.example</emphasis>. Meanwhile, Exim
51039 tries to deliver to <emphasis>p.q.r.example</emphasis>. If this also suffers a host error, the
51040 first retry rule is used, because it matches the host.
51041 </para>
51042 <para>
51043 In other words, temporary failures to deliver to host <emphasis>p.q.r.example</emphasis> use the
51044 first rule to determine retry times, but for all the other hosts for the domain
51045 <emphasis>a.b.c.example</emphasis>, the second rule is used. The second rule is also used if
51046 routing to <emphasis>a.b.c.example</emphasis> suffers a temporary failure.
51047 </para>
51048 <para>
51049 <emphasis role="bold">Note</emphasis>: The host name is used when matching the patterns, not its IP address.
51050 However, if a message is routed directly to an IP address without the use of a
51051 host name, for example, if a <command>manualroute</command> router contains a setting such as:
51052 </para>
51053 <literallayout class="monospaced">
51054 route_list = *.a.example  192.168.34.23
51055 </literallayout>
51056 <para>
51057 then the <quote>host name</quote> that is used when searching for a retry rule is the
51058 textual form of the IP address.
51059 </para>
51060 </section>
51061 <section id="SECID161">
51062 <title>Retry rules for specific errors</title>
51063 <para>
51064 <indexterm role="concept">
51065 <primary>retry</primary>
51066 <secondary>specific errors; specifying</secondary>
51067 </indexterm>
51068 The second field in a retry rule is the name of a particular error, or an
51069 asterisk, which matches any error. The errors that can be tested for are:
51070 </para>
51071 <variablelist>
51072 <varlistentry>
51073 <term><option>auth_failed</option></term>
51074 <listitem>
51075 <para>
51076 Authentication failed when trying to send to a host in the
51077 <option>hosts_require_auth</option> list in an <command>smtp</command> transport.
51078 </para>
51079 </listitem></varlistentry>
51080 <varlistentry>
51081 <term><option>data_4xx</option></term>
51082 <listitem>
51083 <para>
51084 A 4<emphasis>xx</emphasis> error was received for an outgoing DATA command, either immediately
51085 after the command, or after sending the message&#x2019;s data.
51086 </para>
51087 </listitem></varlistentry>
51088 <varlistentry>
51089 <term><option>mail_4xx</option></term>
51090 <listitem>
51091 <para>
51092 A 4<emphasis>xx</emphasis> error was received for an outgoing MAIL command.
51093 </para>
51094 </listitem></varlistentry>
51095 <varlistentry>
51096 <term><option>rcpt_4xx</option></term>
51097 <listitem>
51098 <para>
51099 A 4<emphasis>xx</emphasis> error was received for an outgoing RCPT command.
51100 </para>
51101 </listitem></varlistentry>
51102 </variablelist>
51103 <para>
51104 For the three 4<emphasis>xx</emphasis> errors, either the first or both of the x&#x2019;s can be given
51105 as specific digits, for example: <literal>mail_45x</literal> or <literal>rcpt_436</literal>. For example, to
51106 recognize 452 errors given to RCPT commands for addresses in a certain domain,
51107 and have retries every ten minutes with a one-hour timeout, you could set up a
51108 retry rule of this form:
51109 </para>
51110 <literallayout class="monospaced">
51111 the.domain.name  rcpt_452   F,1h,10m
51112 </literallayout>
51113 <para>
51114 These errors apply to both outgoing SMTP (the <command>smtp</command> transport) and outgoing
51115 LMTP (either the <command>lmtp</command> transport, or the <command>smtp</command> transport in LMTP mode).
51116 </para>
51117 <variablelist>
51118 <varlistentry>
51119 <term><option>lost_connection</option></term>
51120 <listitem>
51121 <para>
51122 A server unexpectedly closed the SMTP connection. There may, of course,
51123 legitimate reasons for this (host died, network died), but if it repeats a lot
51124 for the same host, it indicates something odd.
51125 </para>
51126 </listitem></varlistentry>
51127 <varlistentry>
51128 <term><option>lookup</option></term>
51129 <listitem>
51130 <para>
51131 A DNS lookup for a host failed.
51132 Note that a <option>dnslookup</option> router will need to have matched
51133 its <option>fail_defer_domains</option> option for this retry type to be usable.
51134 Also note that a <option>manualroute</option> router will probably need
51135 its <option>host_find_failed</option> option set to <option>defer</option>.
51136 </para>
51137 </listitem></varlistentry>
51138 <varlistentry>
51139 <term><option>refused_MX</option></term>
51140 <listitem>
51141 <para>
51142 A connection to a host obtained from an MX record was refused.
51143 </para>
51144 </listitem></varlistentry>
51145 <varlistentry>
51146 <term><option>refused_A</option></term>
51147 <listitem>
51148 <para>
51149 A connection to a host not obtained from an MX record was refused.
51150 </para>
51151 </listitem></varlistentry>
51152 <varlistentry>
51153 <term><option>refused</option></term>
51154 <listitem>
51155 <para>
51156 A connection was refused.
51157 </para>
51158 </listitem></varlistentry>
51159 <varlistentry>
51160 <term><option>timeout_connect_MX</option></term>
51161 <listitem>
51162 <para>
51163 A connection attempt to a host obtained from an MX record timed out.
51164 </para>
51165 </listitem></varlistentry>
51166 <varlistentry>
51167 <term><option>timeout_connect_A</option></term>
51168 <listitem>
51169 <para>
51170 A connection attempt to a host not obtained from an MX record timed out.
51171 </para>
51172 </listitem></varlistentry>
51173 <varlistentry>
51174 <term><option>timeout_connect</option></term>
51175 <listitem>
51176 <para>
51177 A connection attempt timed out.
51178 </para>
51179 </listitem></varlistentry>
51180 <varlistentry>
51181 <term><option>timeout_MX</option></term>
51182 <listitem>
51183 <para>
51184 There was a timeout while connecting or during an SMTP session with a host
51185 obtained from an MX record.
51186 </para>
51187 </listitem></varlistentry>
51188 <varlistentry>
51189 <term><option>timeout_A</option></term>
51190 <listitem>
51191 <para>
51192 There was a timeout while connecting or during an SMTP session with a host not
51193 obtained from an MX record.
51194 </para>
51195 </listitem></varlistentry>
51196 <varlistentry>
51197 <term><option>timeout</option></term>
51198 <listitem>
51199 <para>
51200 There was a timeout while connecting or during an SMTP session.
51201 </para>
51202 </listitem></varlistentry>
51203 <varlistentry>
51204 <term><option>tls_required</option></term>
51205 <listitem>
51206 <para>
51207 The server was required to use TLS (it matched <option>hosts_require_tls</option> in the
51208 <command>smtp</command> transport), but either did not offer TLS, or it responded with 4<emphasis>xx</emphasis>
51209 to STARTTLS, or there was a problem setting up the TLS connection.
51210 </para>
51211 </listitem></varlistentry>
51212 <varlistentry>
51213 <term><option>quota</option></term>
51214 <listitem>
51215 <para>
51216 A mailbox quota was exceeded in a local delivery by the <command>appendfile</command>
51217 transport.
51218 </para>
51219 </listitem></varlistentry>
51220 <varlistentry>
51221 <term><option>quota_</option>&lt;<emphasis>time</emphasis>&gt;</term>
51222 <listitem>
51223 <para>
51224 <indexterm role="concept">
51225 <primary>quota</primary>
51226 <secondary>error testing in retry rule</secondary>
51227 </indexterm>
51228 <indexterm role="concept">
51229 <primary>retry</primary>
51230 <secondary>quota error testing</secondary>
51231 </indexterm>
51232 A mailbox quota was exceeded in a local delivery by the <command>appendfile</command>
51233 transport, and the mailbox has not been accessed for &lt;<emphasis>time</emphasis>&gt;. For example,
51234 <emphasis>quota_4d</emphasis> applies to a quota error when the mailbox has not been accessed
51235 for four days.
51236 </para>
51237 </listitem></varlistentry>
51238 </variablelist>
51239 <para>
51240 <indexterm role="concept">
51241 <primary>mailbox</primary>
51242 <secondary>time of last read</secondary>
51243 </indexterm>
51244 The idea of <option>quota_</option>&lt;<emphasis>time</emphasis>&gt; is to make it possible to have shorter
51245 timeouts when the mailbox is full and is not being read by its owner. Ideally,
51246 it should be based on the last time that the user accessed the mailbox.
51247 However, it is not always possible to determine this. Exim uses the following
51248 heuristic rules:
51249 </para>
51250 <itemizedlist>
51251 <listitem>
51252 <para>
51253 If the mailbox is a single file, the time of last access (the <quote>atime</quote>) is
51254 used. As no new messages are being delivered (because the mailbox is over
51255 quota), Exim does not access the file, so this is the time of last user access.
51256 </para>
51257 </listitem>
51258 <listitem>
51259 <para>
51260 <indexterm role="concept">
51261 <primary>maildir format</primary>
51262 <secondary>time of last read</secondary>
51263 </indexterm>
51264 For a maildir delivery, the time of last modification of the <filename>new</filename>
51265 subdirectory is used. As the mailbox is over quota, no new files are created in
51266 the <filename>new</filename> subdirectory, because no new messages are being delivered. Any
51267 change to the <filename>new</filename> subdirectory is therefore assumed to be the result of an
51268 MUA moving a new message to the <filename>cur</filename> directory when it is first read. The
51269 time that is used is therefore the last time that the user read a new message.
51270 </para>
51271 </listitem>
51272 <listitem>
51273 <para>
51274 For other kinds of multi-file mailbox, the time of last access cannot be
51275 obtained, so a retry rule that uses this type of error field is never matched.
51276 </para>
51277 </listitem>
51278 </itemizedlist>
51279 <para>
51280 The quota errors apply both to system-enforced quotas and to Exim&#x2019;s own quota
51281 mechanism in the <command>appendfile</command> transport. The <emphasis>quota</emphasis> error also applies
51282 when a local delivery is deferred because a partition is full (the ENOSPC
51283 error).
51284 </para>
51285 </section>
51286 <section id="SECID162">
51287 <title>Retry rules for specified senders</title>
51288 <para>
51289 <indexterm role="concept">
51290 <primary>retry</primary>
51291 <secondary>rules; sender-specific</secondary>
51292 </indexterm>
51293 You can specify retry rules that apply only when the failing message has a
51294 specific sender. In particular, this can be used to define retry rules that
51295 apply only to bounce messages. The third item in a retry rule can be of this
51296 form:
51297 </para>
51298 <literallayout>
51299 <literal>senders=</literal>&lt;<emphasis>address list</emphasis>&gt;
51300 </literallayout>
51301 <para>
51302 The retry timings themselves are then the fourth item. For example:
51303 </para>
51304 <literallayout class="monospaced">
51305 *   rcpt_4xx   senders=:   F,1h,30m
51306 </literallayout>
51307 <para>
51308 matches recipient 4<emphasis>xx</emphasis> errors for bounce messages sent to any address at any
51309 host. If the address list contains white space, it must be enclosed in quotes.
51310 For example:
51311 </para>
51312 <literallayout class="monospaced">
51313 a.domain  rcpt_452  senders="xb.dom : yc.dom"  G,8h,10m,1.5
51314 </literallayout>
51315 <para>
51316 <emphasis role="bold">Warning</emphasis>: This facility can be unhelpful if it is used for host errors
51317 (which do not depend on the recipient). The reason is that the sender is used
51318 only to match the retry rule. Once the rule has been found for a host error,
51319 its contents are used to set a retry time for the host, and this will apply to
51320 all messages, not just those with specific senders.
51321 </para>
51322 <para>
51323 When testing retry rules using <option>-brt</option>, you can supply a sender using the
51324 <option>-f</option> command line option, like this:
51325 </para>
51326 <literallayout class="monospaced">
51327 exim -f "" -brt user@dom.ain
51328 </literallayout>
51329 <para>
51330 If you do not set <option>-f</option> with <option>-brt</option>, a retry rule that contains a senders
51331 list is never matched.
51332 </para>
51333 </section>
51334 <section id="SECID163">
51335 <title>Retry parameters</title>
51336 <para>
51337 <indexterm role="concept">
51338 <primary>retry</primary>
51339 <secondary>parameters in rules</secondary>
51340 </indexterm>
51341 The third (or fourth, if a senders list is present) field in a retry rule is a
51342 sequence of retry parameter sets, separated by semicolons. Each set consists of
51343 </para>
51344 <literallayout>
51345 &lt;<emphasis>letter</emphasis>&gt;,&lt;<emphasis>cutoff time</emphasis>&gt;,&lt;<emphasis>arguments</emphasis>&gt;
51346 </literallayout>
51347 <para>
51348 The letter identifies the algorithm for computing a new retry time; the cutoff
51349 time is the time beyond which this algorithm no longer applies, and the
51350 arguments vary the algorithm&#x2019;s action. The cutoff time is measured from the
51351 time that the first failure for the domain (combined with the local part if
51352 relevant) was detected, not from the time the message was received.
51353 </para>
51354 <para>
51355 <indexterm role="concept">
51356 <primary>retry</primary>
51357 <secondary>algorithms</secondary>
51358 </indexterm>
51359 <indexterm role="concept">
51360 <primary>retry</primary>
51361 <secondary>fixed intervals</secondary>
51362 </indexterm>
51363 <indexterm role="concept">
51364 <primary>retry</primary>
51365 <secondary>increasing intervals</secondary>
51366 </indexterm>
51367 <indexterm role="concept">
51368 <primary>retry</primary>
51369 <secondary>random intervals</secondary>
51370 </indexterm>
51371 The available algorithms are:
51372 </para>
51373 <itemizedlist>
51374 <listitem>
51375 <para>
51376 <emphasis>F</emphasis>: retry at fixed intervals. There is a single time parameter specifying
51377 the interval.
51378 </para>
51379 </listitem>
51380 <listitem>
51381 <para>
51382 <emphasis>G</emphasis>: retry at geometrically increasing intervals. The first argument
51383 specifies a starting value for the interval, and the second a multiplier, which
51384 is used to increase the size of the interval at each retry.
51385 </para>
51386 </listitem>
51387 <listitem>
51388 <para>
51389 <emphasis>H</emphasis>: retry at randomized intervals. The arguments are as for <emphasis>G</emphasis>. For each
51390 retry, the previous interval is multiplied by the factor in order to get a
51391 maximum for the next interval. The minimum interval is the first argument of
51392 the parameter, and an actual interval is chosen randomly between them. Such a
51393 rule has been found to be helpful in cluster configurations when all the
51394 members of the cluster restart at once, and may therefore synchronize their
51395 queue processing times.
51396 </para>
51397 </listitem>
51398 </itemizedlist>
51399 <para>
51400 When computing the next retry time, the algorithm definitions are scanned in
51401 order until one whose cutoff time has not yet passed is reached. This is then
51402 used to compute a new retry time that is later than the current time. In the
51403 case of fixed interval retries, this simply means adding the interval to the
51404 current time. For geometrically increasing intervals, retry intervals are
51405 computed from the rule&#x2019;s parameters until one that is greater than the previous
51406 interval is found. The main configuration variable
51407 <indexterm role="concept">
51408 <primary>limit</primary>
51409 <secondary>retry interval</secondary>
51410 </indexterm>
51411 <indexterm role="concept">
51412 <primary>retry</primary>
51413 <secondary>interval, maximum</secondary>
51414 </indexterm>
51415 <indexterm role="option">
51416 <primary><option>retry_interval_max</option></primary>
51417 </indexterm>
51418 <option>retry_interval_max</option> limits the maximum interval between retries. It
51419 cannot be set greater than <literal>24h</literal>, which is its default value.
51420 </para>
51421 <para>
51422 A single remote domain may have a number of hosts associated with it, and each
51423 host may have more than one IP address. Retry algorithms are selected on the
51424 basis of the domain name, but are applied to each IP address independently. If,
51425 for example, a host has two IP addresses and one is unusable, Exim will
51426 generate retry times for it and will not try to use it until its next retry
51427 time comes. Thus the good IP address is likely to be tried first most of the
51428 time.
51429 </para>
51430 <para>
51431 <indexterm role="concept">
51432 <primary>hints database</primary>
51433 <secondary>use for retrying</secondary>
51434 </indexterm>
51435 Retry times are hints rather than promises. Exim does not make any attempt to
51436 run deliveries exactly at the computed times. Instead, a queue runner process
51437 starts delivery processes for delayed messages periodically, and these attempt
51438 new deliveries only for those addresses that have passed their next retry time.
51439 If a new message arrives for a deferred address, an immediate delivery attempt
51440 occurs only if the address has passed its retry time. In the absence of new
51441 messages, the minimum time between retries is the interval between queue runner
51442 processes. There is not much point in setting retry times of five minutes if
51443 your queue runners happen only once an hour, unless there are a significant
51444 number of incoming messages (which might be the case on a system that is
51445 sending everything to a smart host, for example).
51446 </para>
51447 <para>
51448 The data in the retry hints database can be inspected by using the
51449 <emphasis>exim_dumpdb</emphasis> or <emphasis>exim_fixdb</emphasis> utility programs (see chapter
51450 <xref linkend="CHAPutils"/>). The latter utility can also be used to change the data. The
51451 <emphasis>exinext</emphasis> utility script can be used to find out what the next retry times
51452 are for the hosts associated with a particular mail domain, and also for local
51453 deliveries that have been deferred.
51454 </para>
51455 </section>
51456 <section id="SECID164">
51457 <title>Retry rule examples</title>
51458 <para>
51459 Here are some example retry rules:
51460 </para>
51461 <literallayout class="monospaced">
51462 alice@wonderland.fict.example quota_5d  F,7d,3h
51463 wonderland.fict.example       quota_5d
51464 wonderland.fict.example       *         F,1h,15m; G,2d,1h,2;
51465 lookingglass.fict.example     *         F,24h,30m;
51466 *                 refused_A   F,2h,20m;
51467 *                 *           F,2h,15m; G,16h,1h,1.5; F,5d,8h
51468 </literallayout>
51469 <para>
51470 The first rule sets up special handling for mail to
51471 <emphasis>alice@wonderland.fict.example</emphasis> when there is an over-quota error and the
51472 mailbox has not been read for at least 5 days. Retries continue every three
51473 hours for 7 days. The second rule handles over-quota errors for all other local
51474 parts at <emphasis>wonderland.fict.example</emphasis>; the absence of a local part has the same
51475 effect as supplying <quote>*@</quote>. As no retry algorithms are supplied, messages that
51476 fail are bounced immediately if the mailbox has not been read for at least 5
51477 days.
51478 </para>
51479 <para>
51480 The third rule handles all other errors at <emphasis>wonderland.fict.example</emphasis>; retries
51481 happen every 15 minutes for an hour, then with geometrically increasing
51482 intervals until two days have passed since a delivery first failed. After the
51483 first hour there is a delay of one hour, then two hours, then four hours, and
51484 so on (this is a rather extreme example).
51485 </para>
51486 <para>
51487 The fourth rule controls retries for the domain <emphasis>lookingglass.fict.example</emphasis>.
51488 They happen every 30 minutes for 24 hours only. The remaining two rules handle
51489 all other domains, with special action for connection refusal from hosts that
51490 were not obtained from an MX record.
51491 </para>
51492 <para>
51493 The final rule in a retry configuration should always have asterisks in the
51494 first two fields so as to provide a general catch-all for any addresses that do
51495 not have their own special handling. This example tries every 15 minutes for 2
51496 hours, then with intervals starting at one hour and increasing by a factor of
51497 1.5 up to 16 hours, then every 8 hours up to 5 days.
51498 </para>
51499 </section>
51500 <section id="SECID165">
51501 <title>Timeout of retry data</title>
51502 <para>
51503 <indexterm role="concept">
51504 <primary>timeout</primary>
51505 <secondary>of retry data</secondary>
51506 </indexterm>
51507 <indexterm role="option">
51508 <primary><option>retry_data_expire</option></primary>
51509 </indexterm>
51510 <indexterm role="concept">
51511 <primary>hints database</primary>
51512 <secondary>data expiry</secondary>
51513 </indexterm>
51514 <indexterm role="concept">
51515 <primary>retry</primary>
51516 <secondary>timeout of data</secondary>
51517 </indexterm>
51518 Exim timestamps the data that it writes to its retry hints database. When it
51519 consults the data during a delivery it ignores any that is older than the value
51520 set in <option>retry_data_expire</option> (default 7 days). If, for example, a host hasn&#x2019;t
51521 been tried for 7 days, Exim will try to deliver to it immediately a message
51522 arrives, and if that fails, it will calculate a retry time as if it were
51523 failing for the first time.
51524 </para>
51525 <para>
51526 This improves the behaviour for messages routed to rarely-used hosts such as MX
51527 backups. If such a host was down at one time, and happens to be down again when
51528 Exim tries a month later, using the old retry data would imply that it had been
51529 down all the time, which is not a justified assumption.
51530 </para>
51531 <para>
51532 If a host really is permanently dead, this behaviour causes a burst of retries
51533 every now and again, but only if messages routed to it are rare. If there is a
51534 message at least once every 7 days the retry data never expires.
51535 </para>
51536 </section>
51537 <section id="SECID166">
51538 <title>Long-term failures</title>
51539 <para>
51540 <indexterm role="concept">
51541 <primary>delivery failure, long-term</primary>
51542 </indexterm>
51543 <indexterm role="concept">
51544 <primary>retry</primary>
51545 <secondary>after long-term failure</secondary>
51546 </indexterm>
51547 Special processing happens when an email address has been failing for so long
51548 that the cutoff time for the last algorithm is reached. For example, using the
51549 default retry rule:
51550 </para>
51551 <literallayout class="monospaced">
51552 * * F,2h,15m; G,16h,1h,1.5; F,4d,6h
51553 </literallayout>
51554 <para>
51555 the cutoff time is four days. Reaching the retry cutoff is independent of how
51556 long any specific message has been failing; it is the length of continuous
51557 failure for the recipient address that counts.
51558 </para>
51559 <para>
51560 When the cutoff time is reached for a local delivery, or for all the IP
51561 addresses associated with a remote delivery, a subsequent delivery failure
51562 causes Exim to give up on the address, and a bounce message is generated.
51563 In order to cater for new messages that use the failing address, a next retry
51564 time is still computed from the final algorithm, and is used as follows:
51565 </para>
51566 <para>
51567 For local deliveries, one delivery attempt is always made for any subsequent
51568 messages. If this delivery fails, the address fails immediately. The
51569 post-cutoff retry time is not used.
51570 </para>
51571 <para>
51572 <indexterm role="concept">
51573 <primary>final cutoff</primary>
51574 <secondary>retries, controlling</secondary>
51575 </indexterm>
51576 <indexterm role="concept">
51577 <primary>retry</primary>
51578 <secondary>final cutoff</secondary>
51579 </indexterm>
51580 If the delivery is remote, there are two possibilities, controlled by the
51581 <indexterm role="option">
51582 <primary><option>delay_after_cutoff</option></primary>
51583 </indexterm>
51584 <option>delay_after_cutoff</option> option of the <command>smtp</command> transport. The option is true by
51585 default. Until the post-cutoff retry time for one of the IP addresses,
51586 as set by the <option>retry_data_expire</option> option, is
51587 reached, the failing email address is bounced immediately, without a delivery
51588 attempt taking place. After that time, one new delivery attempt is made to
51589 those IP addresses that are past their retry times, and if that still fails,
51590 the address is bounced and new retry times are computed.
51591 </para>
51592 <para>
51593 In other words, when all the hosts for a given email address have been failing
51594 for a long time, Exim bounces rather then defers until one of the hosts&#x2019; retry
51595 times is reached. Then it tries once, and bounces if that attempt fails. This
51596 behaviour ensures that few resources are wasted in repeatedly trying to deliver
51597 to a broken destination, but if the host does recover, Exim will eventually
51598 notice.
51599 </para>
51600 <para>
51601 If <option>delay_after_cutoff</option> is set false, Exim behaves differently. If all IP
51602 addresses are past their final cutoff time, Exim tries to deliver to those IP
51603 addresses that have not been tried since the message arrived. If there are
51604 no suitable IP addresses, or if they all fail, the address is bounced. In other
51605 words, it does not delay when a new message arrives, but tries the expired
51606 addresses immediately, unless they have been tried since the message arrived.
51607 If there is a continuous stream of messages for the failing domains, setting
51608 <option>delay_after_cutoff</option> false means that there will be many more attempts to
51609 deliver to permanently failing IP addresses than when <option>delay_after_cutoff</option> is
51610 true.
51611 </para>
51612 </section>
51613 <section id="SECID167">
51614 <title>Deliveries that work intermittently</title>
51615 <para>
51616 <indexterm role="concept">
51617 <primary>retry</primary>
51618 <secondary>intermittently working deliveries</secondary>
51619 </indexterm>
51620 Some additional logic is needed to cope with cases where a host is
51621 intermittently available, or when a message has some attribute that prevents
51622 its delivery when others to the same address get through. In this situation,
51623 because some messages are successfully delivered, the <quote>retry clock</quote> for the
51624 host or address keeps getting reset by the successful deliveries, and so
51625 failing messages remain in the queue for ever because the cutoff time is never
51626 reached.
51627 </para>
51628 <para>
51629 Two exceptional actions are applied to prevent this happening. The first
51630 applies to errors that are related to a message rather than a remote host.
51631 Section <xref linkend="SECToutSMTPerr"/> has a discussion of the different kinds of error;
51632 examples of message-related errors are 4<emphasis>xx</emphasis> responses to MAIL or DATA
51633 commands, and quota failures. For this type of error, if a message&#x2019;s arrival
51634 time is earlier than the <quote>first failed</quote> time for the error, the earlier time
51635 is used when scanning the retry rules to decide when to try next and when to
51636 time out the address.
51637 </para>
51638 <para>
51639 The exceptional second action applies in all cases. If a message has been on
51640 the queue for longer than the cutoff time of any applicable retry rule for a
51641 given address, a delivery is attempted for that address, even if it is not yet
51642 time, and if this delivery fails, the address is timed out. A new retry time is
51643 not computed in this case, so that other messages for the same address are
51644 considered immediately.
51645 <indexterm role="concept" startref="IIDretconf1" class="endofrange"/>
51646 <indexterm role="concept" startref="IIDregconf2" class="endofrange"/>
51647 </para>
51648 </section>
51649 </chapter>
51650
51651 <chapter id="CHAPSMTPAUTH">
51652 <title>SMTP authentication</title>
51653 <para>
51654 <indexterm role="concept" id="IIDauthconf1" class="startofrange">
51655 <primary>SMTP</primary>
51656 <secondary>authentication configuration</secondary>
51657 </indexterm>
51658 <indexterm role="concept" id="IIDauthconf2" class="startofrange">
51659 <primary>authentication</primary>
51660 </indexterm>
51661 The <quote>authenticators</quote> section of Exim&#x2019;s runtime configuration is concerned
51662 with SMTP authentication. This facility is an extension to the SMTP protocol,
51663 described in RFC 2554, which allows a client SMTP host to authenticate itself
51664 to a server. This is a common way for a server to recognize clients that are
51665 permitted to use it as a relay. SMTP authentication is not of relevance to the
51666 transfer of mail between servers that have no managerial connection with each
51667 other.
51668 </para>
51669 <para>
51670 <indexterm role="concept">
51671 <primary>AUTH</primary>
51672 <secondary>description of</secondary>
51673 </indexterm>
51674 Very briefly, the way SMTP authentication works is as follows:
51675 </para>
51676 <itemizedlist>
51677 <listitem>
51678 <para>
51679 The server advertises a number of authentication <emphasis>mechanisms</emphasis> in response to
51680 the client&#x2019;s EHLO command.
51681 </para>
51682 </listitem>
51683 <listitem>
51684 <para>
51685 The client issues an AUTH command, naming a specific mechanism. The command
51686 may, optionally, contain some authentication data.
51687 </para>
51688 </listitem>
51689 <listitem>
51690 <para>
51691 The server may issue one or more <emphasis>challenges</emphasis>, to which the client must send
51692 appropriate responses. In simple authentication mechanisms, the challenges are
51693 just prompts for user names and passwords. The server does not have to issue
51694 any challenges &ndash; in some mechanisms the relevant data may all be transmitted
51695 with the AUTH command.
51696 </para>
51697 </listitem>
51698 <listitem>
51699 <para>
51700 The server either accepts or denies authentication.
51701 </para>
51702 </listitem>
51703 <listitem>
51704 <para>
51705 If authentication succeeds, the client may optionally make use of the AUTH
51706 option on the MAIL command to pass an authenticated sender in subsequent
51707 mail transactions. Authentication lasts for the remainder of the SMTP
51708 connection.
51709 </para>
51710 </listitem>
51711 <listitem>
51712 <para>
51713 If authentication fails, the client may give up, or it may try a different
51714 authentication mechanism, or it may try transferring mail over the
51715 unauthenticated connection.
51716 </para>
51717 </listitem>
51718 </itemizedlist>
51719 <para>
51720 If you are setting up a client, and want to know which authentication
51721 mechanisms the server supports, you can use Telnet to connect to port 25 (the
51722 SMTP port) on the server, and issue an EHLO command. The response to this
51723 includes the list of supported mechanisms. For example:
51724 </para>
51725 <literallayout>
51726 <literal>$ </literal><emphasis role="bold"><literal>telnet server.example 25</literal></emphasis>
51727 <literal>Trying 192.168.34.25...</literal>
51728 <literal>Connected to server.example.</literal>
51729 <literal>Escape character is &#x0027;^]&#x0027;.</literal>
51730 <literal>220 server.example ESMTP Exim 4.20 ...</literal>
51731 <emphasis role="bold"><literal>ehlo client.example</literal></emphasis>
51732 <literal>250-server.example Hello client.example [10.8.4.5]</literal>
51733 <literal>250-SIZE 52428800</literal>
51734 <literal>250-PIPELINING</literal>
51735 <literal>250-AUTH PLAIN</literal>
51736 <literal>250 HELP</literal>
51737 </literallayout>
51738 <para>
51739 The second-last line of this example output shows that the server supports
51740 authentication using the PLAIN mechanism. In Exim, the different authentication
51741 mechanisms are configured by specifying <emphasis>authenticator</emphasis> drivers. Like the
51742 routers and transports, which authenticators are included in the binary is
51743 controlled by build-time definitions. The following are currently available,
51744 included by setting
51745 </para>
51746 <literallayout class="monospaced">
51747 AUTH_CRAM_MD5=yes
51748 AUTH_CYRUS_SASL=yes
51749 AUTH_DOVECOT=yes
51750 AUTH_EXTERNAL=yes
51751 AUTH_GSASL=yes
51752 AUTH_HEIMDAL_GSSAPI=yes
51753 AUTH_PLAINTEXT=yes
51754 AUTH_SPA=yes
51755 AUTH_TLS=yes
51756 </literallayout>
51757 <para>
51758 in <filename>Local/Makefile</filename>, respectively. The first of these supports the CRAM-MD5
51759 authentication mechanism (RFC 2195), and the second provides an interface to
51760 the Cyrus SASL authentication library.
51761 The third is an interface to Dovecot&#x2019;s authentication system, delegating the
51762 work via a socket interface.
51763 </para>
51764 <para revisionflag="changed">
51765 The fourth provides for negotiation of authentication done via non-SMTP means,
51766 as defined by RFC 4422 Appendix A.
51767 </para>
51768 <para>
51769 The fifth provides an interface to the GNU SASL authentication library, which
51770 provides mechanisms but typically not data sources.
51771 The sixth provides direct access to Heimdal GSSAPI, geared for Kerberos, but
51772 supporting setting a server keytab.
51773 The seventh can be configured to support
51774 the PLAIN authentication mechanism (RFC 2595) or the LOGIN mechanism, which is
51775 not formally documented, but used by several MUAs.
51776 The eighth authenticator
51777 supports Microsoft&#x2019;s <emphasis>Secure Password Authentication</emphasis> mechanism.
51778 The last is an Exim authenticator but not an SMTP one;
51779 instead it can use information from a TLS negotiation.
51780 </para>
51781 <para>
51782 The authenticators are configured using the same syntax as other drivers (see
51783 section <xref linkend="SECTfordricon"/>). If no authenticators are required, no
51784 authentication section need be present in the configuration file. Each
51785 authenticator can in principle have both server and client functions. When Exim
51786 is receiving SMTP mail, it is acting as a server; when it is sending out
51787 messages over SMTP, it is acting as a client. Authenticator configuration
51788 options are provided for use in both these circumstances.
51789 </para>
51790 <para>
51791 To make it clear which options apply to which situation, the prefixes
51792 <option>server_</option> and <option>client_</option> are used on option names that are specific to
51793 either the server or the client function, respectively. Server and client
51794 functions are disabled if none of their options are set. If an authenticator is
51795 to be used for both server and client functions, a single definition, using
51796 both sets of options, is required. For example:
51797 </para>
51798 <literallayout class="monospaced">
51799 cram:
51800   driver = cram_md5
51801   public_name = CRAM-MD5
51802   server_secret = ${if eq{$auth1}{ph10}{secret1}fail}
51803   client_name = ph10
51804   client_secret = secret2
51805 </literallayout>
51806 <para>
51807 The <option>server_</option> option is used when Exim is acting as a server, and the
51808 <option>client_</option> options when it is acting as a client.
51809 </para>
51810 <para>
51811 Descriptions of the individual authenticators are given in subsequent chapters.
51812 The remainder of this chapter covers the generic options for the
51813 authenticators, followed by general discussion of the way authentication works
51814 in Exim.
51815 </para>
51816 <para>
51817 <emphasis role="bold">Beware:</emphasis> the meaning of <varname>$auth1</varname>, <varname>$auth2</varname>, ... varies on a per-driver and
51818 per-mechanism basis.  Please read carefully to determine which variables hold
51819 account labels such as usercodes and which hold passwords or other
51820 authenticating data.
51821 </para>
51822 <para>
51823 Note that some mechanisms support two different identifiers for accounts: the
51824 <emphasis>authentication id</emphasis> and the <emphasis>authorization id</emphasis>.  The contractions <emphasis>authn</emphasis>
51825 and <emphasis>authz</emphasis> are commonly encountered.  The American spelling is standard here.
51826 Conceptually, authentication data such as passwords are tied to the identifier
51827 used to authenticate; servers may have rules to permit one user to act as a
51828 second user, so that after login the session is treated as though that second
51829 user had logged in.  That second user is the <emphasis>authorization id</emphasis>.  A robust
51830 configuration might confirm that the <emphasis>authz</emphasis> field is empty or matches the
51831 <emphasis>authn</emphasis> field.  Often this is just ignored.  The <emphasis>authn</emphasis> can be considered
51832 as verified data, the <emphasis>authz</emphasis> as an unverified request which the server might
51833 choose to honour.
51834 </para>
51835 <para>
51836 A <emphasis>realm</emphasis> is a text string, typically a domain name, presented by a server
51837 to a client to help it select an account and credentials to use.  In some
51838 mechanisms, the client and server provably agree on the realm, but clients
51839 typically can not treat the realm as secure data to be blindly trusted.
51840 </para>
51841 <section id="SECID168">
51842 <title>Generic options for authenticators</title>
51843 <para>
51844 <indexterm role="concept">
51845 <primary>authentication</primary>
51846 <secondary>generic options</secondary>
51847 </indexterm>
51848 <indexterm role="concept">
51849 <primary>options</primary>
51850 <secondary>generic; for authenticators</secondary>
51851 </indexterm>
51852 </para>
51853 <para>
51854 <indexterm role="option">
51855 <primary><option>client_condition</option></primary>
51856 </indexterm>
51857 </para>
51858 <informaltable frame="all">
51859 <tgroup cols="4" colsep="0" rowsep="0">
51860 <colspec colwidth="8*" align="left"/>
51861 <colspec colwidth="6*" align="center"/>
51862 <colspec colwidth="6*" align="center"/>
51863 <colspec colwidth="6*" align="right"/>
51864 <tbody>
51865 <row>
51866 <entry><option>client_condition</option></entry>
51867 <entry>Use: <emphasis>authenticators</emphasis></entry>
51868 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
51869 <entry>Default: <emphasis>unset</emphasis></entry>
51870 </row>
51871 </tbody>
51872 </tgroup>
51873 </informaltable>
51874 <para>
51875 When Exim is authenticating as a client, it skips any authenticator whose
51876 <option>client_condition</option> expansion yields <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>. This can be
51877 used, for example, to skip plain text authenticators when the connection is not
51878 encrypted by a setting such as:
51879 </para>
51880 <literallayout class="monospaced">
51881 client_condition = ${if !eq{$tls_out_cipher}{}}
51882 </literallayout>
51883 <para>
51884 <indexterm role="option">
51885 <primary><option>client_set_id</option></primary>
51886 </indexterm>
51887 </para>
51888 <informaltable frame="all">
51889 <tgroup cols="4" colsep="0" rowsep="0">
51890 <colspec colwidth="8*" align="left"/>
51891 <colspec colwidth="6*" align="center"/>
51892 <colspec colwidth="6*" align="center"/>
51893 <colspec colwidth="6*" align="right"/>
51894 <tbody>
51895 <row>
51896 <entry><option>client_set_id</option></entry>
51897 <entry>Use: <emphasis>authenticators</emphasis></entry>
51898 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
51899 <entry>Default: <emphasis>unset</emphasis></entry>
51900 </row>
51901 </tbody>
51902 </tgroup>
51903 </informaltable>
51904 <para>
51905 When client authentication succeeds, this condition is expanded; the
51906 result is used in the log lines for outbound messages.
51907 Typically it will be the user name used for authentication.
51908 </para>
51909 <para>
51910 <indexterm role="option">
51911 <primary><option>driver</option></primary>
51912 </indexterm>
51913 </para>
51914 <informaltable frame="all">
51915 <tgroup cols="4" colsep="0" rowsep="0">
51916 <colspec colwidth="8*" align="left"/>
51917 <colspec colwidth="6*" align="center"/>
51918 <colspec colwidth="6*" align="center"/>
51919 <colspec colwidth="6*" align="right"/>
51920 <tbody>
51921 <row>
51922 <entry><option>driver</option></entry>
51923 <entry>Use: <emphasis>authenticators</emphasis></entry>
51924 <entry>Type: <emphasis>string</emphasis></entry>
51925 <entry>Default: <emphasis>unset</emphasis></entry>
51926 </row>
51927 </tbody>
51928 </tgroup>
51929 </informaltable>
51930 <para>
51931 This option must always be set. It specifies which of the available
51932 authenticators is to be used.
51933 </para>
51934 <para>
51935 <indexterm role="option">
51936 <primary><option>public_name</option></primary>
51937 </indexterm>
51938 </para>
51939 <informaltable frame="all">
51940 <tgroup cols="4" colsep="0" rowsep="0">
51941 <colspec colwidth="8*" align="left"/>
51942 <colspec colwidth="6*" align="center"/>
51943 <colspec colwidth="6*" align="center"/>
51944 <colspec colwidth="6*" align="right"/>
51945 <tbody>
51946 <row>
51947 <entry><option>public_name</option></entry>
51948 <entry>Use: <emphasis>authenticators</emphasis></entry>
51949 <entry>Type: <emphasis>string</emphasis></entry>
51950 <entry>Default: <emphasis>unset</emphasis></entry>
51951 </row>
51952 </tbody>
51953 </tgroup>
51954 </informaltable>
51955 <para>
51956 This option specifies the name of the authentication mechanism that the driver
51957 implements, and by which it is known to the outside world. These names should
51958 contain only upper case letters, digits, underscores, and hyphens (RFC 2222),
51959 but Exim in fact matches them caselessly. If <option>public_name</option> is not set, it
51960 defaults to the driver&#x2019;s instance name.
51961 </para>
51962 <para>
51963 <indexterm role="option">
51964 <primary><option>server_advertise_condition</option></primary>
51965 </indexterm>
51966 </para>
51967 <informaltable frame="all">
51968 <tgroup cols="4" colsep="0" rowsep="0">
51969 <colspec colwidth="8*" align="left"/>
51970 <colspec colwidth="6*" align="center"/>
51971 <colspec colwidth="6*" align="center"/>
51972 <colspec colwidth="6*" align="right"/>
51973 <tbody>
51974 <row>
51975 <entry><option>server_advertise_condition</option></entry>
51976 <entry>Use: <emphasis>authenticators</emphasis></entry>
51977 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
51978 <entry>Default: <emphasis>unset</emphasis></entry>
51979 </row>
51980 </tbody>
51981 </tgroup>
51982 </informaltable>
51983 <para>
51984 When a server is about to advertise an authentication mechanism, the condition
51985 is expanded. If it yields the empty string, <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, the
51986 mechanism is not advertised.
51987 If the expansion fails, the mechanism is not advertised. If the failure was not
51988 forced, and was not caused by a lookup defer, the incident is logged.
51989 See section <xref linkend="SECTauthexiser"/> below for further discussion.
51990 </para>
51991 <para>
51992 <indexterm role="option">
51993 <primary><option>server_condition</option></primary>
51994 </indexterm>
51995 </para>
51996 <informaltable frame="all">
51997 <tgroup cols="4" colsep="0" rowsep="0">
51998 <colspec colwidth="8*" align="left"/>
51999 <colspec colwidth="6*" align="center"/>
52000 <colspec colwidth="6*" align="center"/>
52001 <colspec colwidth="6*" align="right"/>
52002 <tbody>
52003 <row>
52004 <entry><option>server_condition</option></entry>
52005 <entry>Use: <emphasis>authenticators</emphasis></entry>
52006 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
52007 <entry>Default: <emphasis>unset</emphasis></entry>
52008 </row>
52009 </tbody>
52010 </tgroup>
52011 </informaltable>
52012 <para>
52013 This option must be set for a <option>plaintext</option> server authenticator, where it
52014 is used directly to control authentication. See section <xref linkend="SECTplainserver"/>
52015 for details.
52016 </para>
52017 <para>
52018 For the <command>gsasl</command> authenticator, this option is required for various
52019 mechanisms; see chapter <xref linkend="CHAPgsasl"/> for details.
52020 </para>
52021 <para>
52022 For the other authenticators, <option>server_condition</option> can be used as an additional
52023 authentication or authorization mechanism that is applied after the other
52024 authenticator conditions succeed. If it is set, it is expanded when the
52025 authenticator would otherwise return a success code. If the expansion is forced
52026 to fail, authentication fails. Any other expansion failure causes a temporary
52027 error code to be returned. If the result of a successful expansion is an empty
52028 string, <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, authentication fails. If the result of the
52029 expansion is <quote>1</quote>, <quote>yes</quote>, or <quote>true</quote>, authentication succeeds. For any
52030 other result, a temporary error code is returned, with the expanded string as
52031 the error text.
52032 </para>
52033 <para>
52034 <indexterm role="option">
52035 <primary><option>server_debug_print</option></primary>
52036 </indexterm>
52037 </para>
52038 <informaltable frame="all">
52039 <tgroup cols="4" colsep="0" rowsep="0">
52040 <colspec colwidth="8*" align="left"/>
52041 <colspec colwidth="6*" align="center"/>
52042 <colspec colwidth="6*" align="center"/>
52043 <colspec colwidth="6*" align="right"/>
52044 <tbody>
52045 <row>
52046 <entry><option>server_debug_print</option></entry>
52047 <entry>Use: <emphasis>authenticators</emphasis></entry>
52048 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
52049 <entry>Default: <emphasis>unset</emphasis></entry>
52050 </row>
52051 </tbody>
52052 </tgroup>
52053 </informaltable>
52054 <para>
52055 If this option is set and authentication debugging is enabled (see the <option>-d</option>
52056 command line option), the string is expanded and included in the debugging
52057 output when the authenticator is run as a server. This can help with checking
52058 out the values of variables.
52059 If expansion of the string fails, the error message is written to the debugging
52060 output, and Exim carries on processing.
52061 </para>
52062 <para>
52063 <indexterm role="option">
52064 <primary><option>server_set_id</option></primary>
52065 </indexterm>
52066 </para>
52067 <informaltable frame="all">
52068 <tgroup cols="4" colsep="0" rowsep="0">
52069 <colspec colwidth="8*" align="left"/>
52070 <colspec colwidth="6*" align="center"/>
52071 <colspec colwidth="6*" align="center"/>
52072 <colspec colwidth="6*" align="right"/>
52073 <tbody>
52074 <row>
52075 <entry><option>server_set_id</option></entry>
52076 <entry>Use: <emphasis>authenticators</emphasis></entry>
52077 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
52078 <entry>Default: <emphasis>unset</emphasis></entry>
52079 </row>
52080 </tbody>
52081 </tgroup>
52082 </informaltable>
52083 <para>
52084 <indexterm role="variable">
52085 <primary><varname>$authenticated_id</varname></primary>
52086 </indexterm>
52087 <indexterm role="variable">
52088 <primary><varname>$authenticated_fail_id</varname></primary>
52089 </indexterm>
52090 When an Exim server successfully authenticates a client, this string is
52091 expanded using data from the authentication, and preserved for any incoming
52092 messages in the variable <varname>$authenticated_id</varname>. It is also included in the log
52093 lines for incoming messages. For example, a user/password authenticator
52094 configuration might preserve the user name that was used to authenticate, and
52095 refer to it subsequently during delivery of the message.
52096 On a failing authentication the expansion result is instead saved in
52097 the <varname>$authenticated_fail_id</varname> variable.
52098 If expansion fails, the option is ignored.
52099 </para>
52100 <para>
52101 <indexterm role="option">
52102 <primary><option>server_mail_auth_condition</option></primary>
52103 </indexterm>
52104 </para>
52105 <informaltable frame="all">
52106 <tgroup cols="4" colsep="0" rowsep="0">
52107 <colspec colwidth="8*" align="left"/>
52108 <colspec colwidth="6*" align="center"/>
52109 <colspec colwidth="6*" align="center"/>
52110 <colspec colwidth="6*" align="right"/>
52111 <tbody>
52112 <row>
52113 <entry><option>server_mail_auth_condition</option></entry>
52114 <entry>Use: <emphasis>authenticators</emphasis></entry>
52115 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
52116 <entry>Default: <emphasis>unset</emphasis></entry>
52117 </row>
52118 </tbody>
52119 </tgroup>
52120 </informaltable>
52121 <para>
52122 This option allows a server to discard authenticated sender addresses supplied
52123 as part of MAIL commands in SMTP connections that are authenticated by the
52124 driver on which <option>server_mail_auth_condition</option> is set. The option is not used
52125 as part of the authentication process; instead its (unexpanded) value is
52126 remembered for later use.
52127 How it is used is described in the following section.
52128 </para>
52129 </section>
52130 <section id="SECTauthparamail">
52131 <title>The AUTH parameter on MAIL commands</title>
52132 <para>
52133 <indexterm role="concept">
52134 <primary>authentication</primary>
52135 <secondary>sender; authenticated</secondary>
52136 </indexterm>
52137 <indexterm role="concept">
52138 <primary>AUTH</primary>
52139 <secondary>on MAIL command</secondary>
52140 </indexterm>
52141 When a client supplied an AUTH= item on a MAIL command, Exim applies
52142 the following checks before accepting it as the authenticated sender of the
52143 message:
52144 </para>
52145 <itemizedlist>
52146 <listitem>
52147 <para>
52148 If the connection is not using extended SMTP (that is, HELO was used rather
52149 than EHLO), the use of AUTH= is a syntax error.
52150 </para>
52151 </listitem>
52152 <listitem>
52153 <para>
52154 If the value of the AUTH= parameter is <quote>&lt;&gt;</quote>, it is ignored.
52155 </para>
52156 </listitem>
52157 <listitem>
52158 <para>
52159 <indexterm role="variable">
52160 <primary><varname>$authenticated_sender</varname></primary>
52161 </indexterm>
52162 If <option>acl_smtp_mailauth</option> is defined, the ACL it specifies is run. While it is
52163 running, the value of <varname>$authenticated_sender</varname> is set to the value obtained
52164 from the AUTH= parameter. If the ACL does not yield <quote>accept</quote>, the value of
52165 <varname>$authenticated_sender</varname> is deleted. The <option>acl_smtp_mailauth</option> ACL may not
52166 return <quote>drop</quote> or <quote>discard</quote>. If it defers, a temporary error code (451) is
52167 given for the MAIL command.
52168 </para>
52169 </listitem>
52170 <listitem>
52171 <para>
52172 If <option>acl_smtp_mailauth</option> is not defined, the value of the AUTH= parameter
52173 is accepted and placed in <varname>$authenticated_sender</varname> only if the client has
52174 authenticated.
52175 </para>
52176 </listitem>
52177 <listitem>
52178 <para>
52179 If the AUTH= value was accepted by either of the two previous rules, and
52180 the client has authenticated, and the authenticator has a setting for the
52181 <option>server_mail_auth_condition</option>, the condition is checked at this point. The
52182 valued that was saved from the authenticator is expanded. If the expansion
52183 fails, or yields an empty string, <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, the value of
52184 <varname>$authenticated_sender</varname> is deleted. If the expansion yields any other value,
52185 the value of <varname>$authenticated_sender</varname> is retained and passed on with the
52186 message.
52187 </para>
52188 </listitem>
52189 </itemizedlist>
52190 <para>
52191 When <varname>$authenticated_sender</varname> is set for a message, it is passed on to other
52192 hosts to which Exim authenticates as a client. Do not confuse this value with
52193 <varname>$authenticated_id</varname>, which is a string obtained from the authentication
52194 process, and which is not usually a complete email address.
52195 </para>
52196 <para>
52197 <indexterm role="variable">
52198 <primary><varname>$sender_address</varname></primary>
52199 </indexterm>
52200 Whenever an AUTH= value is ignored, the incident is logged. The ACL for
52201 MAIL, if defined, is run after AUTH= is accepted or ignored. It can
52202 therefore make use of <varname>$authenticated_sender</varname>. The converse is not true: the
52203 value of <varname>$sender_address</varname> is not yet set up when the <option>acl_smtp_mailauth</option>
52204 ACL is run.
52205 </para>
52206 </section>
52207 <section id="SECTauthexiser">
52208 <title>Authentication on an Exim server</title>
52209 <para>
52210 <indexterm role="concept">
52211 <primary>authentication</primary>
52212 <secondary>on an Exim server</secondary>
52213 </indexterm>
52214 When Exim receives an EHLO command, it advertises the public names of those
52215 authenticators that are configured as servers, subject to the following
52216 conditions:
52217 </para>
52218 <itemizedlist>
52219 <listitem>
52220 <para>
52221 The client host must match <option>auth_advertise_hosts</option> (default *).
52222 </para>
52223 </listitem>
52224 <listitem>
52225 <para>
52226 It the <option>server_advertise_condition</option> option is set, its expansion must not
52227 yield the empty string, <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>.
52228 </para>
52229 </listitem>
52230 </itemizedlist>
52231 <para>
52232 The order in which the authenticators are defined controls the order in which
52233 the mechanisms are advertised.
52234 </para>
52235 <para>
52236 Some mail clients (for example, some versions of Netscape) require the user to
52237 provide a name and password for authentication whenever AUTH is advertised,
52238 even though authentication may not in fact be needed (for example, Exim may be
52239 set up to allow unconditional relaying from the client by an IP address check).
52240 You can make such clients more friendly by not advertising AUTH to them.
52241 For example, if clients on the 10.9.8.0/24 network are permitted (by the ACL
52242 that runs for RCPT) to relay without authentication, you should set
52243 </para>
52244 <literallayout class="monospaced">
52245 auth_advertise_hosts = ! 10.9.8.0/24
52246 </literallayout>
52247 <para>
52248 so that no authentication mechanisms are advertised to them.
52249 </para>
52250 <para>
52251 The <option>server_advertise_condition</option> controls the advertisement of individual
52252 authentication mechanisms. For example, it can be used to restrict the
52253 advertisement of a particular mechanism to encrypted connections, by a setting
52254 such as:
52255 </para>
52256 <literallayout class="monospaced">
52257 server_advertise_condition = ${if eq{$tls_in_cipher}{}{no}{yes}}
52258 </literallayout>
52259 <para>
52260 <indexterm role="variable">
52261 <primary><varname>$tls_in_cipher</varname></primary>
52262 </indexterm>
52263 If the session is encrypted, <varname>$tls_in_cipher</varname> is not empty, and so the expansion
52264 yields <quote>yes</quote>, which allows the advertisement to happen.
52265 </para>
52266 <para>
52267 When an Exim server receives an AUTH command from a client, it rejects it
52268 immediately if AUTH was not advertised in response to an earlier EHLO
52269 command. This is the case if
52270 </para>
52271 <itemizedlist>
52272 <listitem>
52273 <para>
52274 The client host does not match <option>auth_advertise_hosts</option>; or
52275 </para>
52276 </listitem>
52277 <listitem>
52278 <para>
52279 No authenticators are configured with server options; or
52280 </para>
52281 </listitem>
52282 <listitem>
52283 <para>
52284 Expansion of <option>server_advertise_condition</option> blocked the advertising of all the
52285 server authenticators.
52286 </para>
52287 </listitem>
52288 </itemizedlist>
52289 <para>
52290 Otherwise, Exim runs the ACL specified by <option>acl_smtp_auth</option> in order
52291 to decide whether to accept the command. If <option>acl_smtp_auth</option> is not set,
52292 AUTH is accepted from any client host.
52293 </para>
52294 <para>
52295 If AUTH is not rejected by the ACL, Exim searches its configuration for a
52296 server authentication mechanism that was advertised in response to EHLO and
52297 that matches the one named in the AUTH command. If it finds one, it runs
52298 the appropriate authentication protocol, and authentication either succeeds or
52299 fails. If there is no matching advertised mechanism, the AUTH command is
52300 rejected with a 504 error.
52301 </para>
52302 <para>
52303 <indexterm role="variable">
52304 <primary><varname>$received_protocol</varname></primary>
52305 </indexterm>
52306 <indexterm role="variable">
52307 <primary><varname>$sender_host_authenticated</varname></primary>
52308 </indexterm>
52309 When a message is received from an authenticated host, the value of
52310 <varname>$received_protocol</varname> is set to <quote>esmtpa</quote> or <quote>esmtpsa</quote> instead of <quote>esmtp</quote>
52311 or <quote>esmtps</quote>, and <varname>$sender_host_authenticated</varname> contains the name (not the
52312 public name) of the authenticator driver that successfully authenticated the
52313 client from which the message was received. This variable is empty if there was
52314 no successful authentication.
52315 </para>
52316 <para>
52317 <indexterm role="concept">
52318 <primary>authentication</primary>
52319 <secondary>expansion item</secondary>
52320 </indexterm>
52321 Successful authentication sets up information used by the
52322 <option>authresults</option> expansion item.
52323 </para>
52324 </section>
52325 <section id="SECID169">
52326 <title>Testing server authentication</title>
52327 <para>
52328 <indexterm role="concept">
52329 <primary>authentication</primary>
52330 <secondary>testing a server</secondary>
52331 </indexterm>
52332 <indexterm role="concept">
52333 <primary>AUTH</primary>
52334 <secondary>testing a server</secondary>
52335 </indexterm>
52336 <indexterm role="concept">
52337 <primary>base64 encoding</primary>
52338 <secondary>creating authentication test data</secondary>
52339 </indexterm>
52340 Exim&#x2019;s <option>-bh</option> option can be useful for testing server authentication
52341 configurations. The data for the AUTH command has to be sent using base64
52342 encoding. A quick way to produce such data for testing is the following Perl
52343 script:
52344 </para>
52345 <literallayout class="monospaced">
52346 use MIME::Base64;
52347 printf ("%s", encode_base64(eval "\"$ARGV[0]\""));
52348 </literallayout>
52349 <para>
52350 <indexterm role="concept">
52351 <primary>binary zero</primary>
52352 <secondary>in authentication data</secondary>
52353 </indexterm>
52354 This interprets its argument as a Perl string, and then encodes it. The
52355 interpretation as a Perl string allows binary zeros, which are required for
52356 some kinds of authentication, to be included in the data. For example, a
52357 command line to run this script on such data might be
52358 </para>
52359 <literallayout class="monospaced">
52360 encode '\0user\0password'
52361 </literallayout>
52362 <para>
52363 Note the use of single quotes to prevent the shell interpreting the
52364 backslashes, so that they can be interpreted by Perl to specify characters
52365 whose code value is zero.
52366 </para>
52367 <para>
52368 <emphasis role="bold">Warning 1</emphasis>: If either of the user or password strings starts with an octal
52369 digit, you must use three zeros instead of one after the leading backslash. If
52370 you do not, the octal digit that starts your string will be incorrectly
52371 interpreted as part of the code for the first character.
52372 </para>
52373 <para>
52374 <emphasis role="bold">Warning 2</emphasis>: If there are characters in the strings that Perl interprets
52375 specially, you must use a Perl escape to prevent them being misinterpreted. For
52376 example, a command such as
52377 </para>
52378 <literallayout class="monospaced">
52379 encode '\0user@domain.com\0pas$$word'
52380 </literallayout>
52381 <para>
52382 gives an incorrect answer because of the unescaped <quote>@</quote> and <quote>$</quote> characters.
52383 </para>
52384 <para>
52385 If you have the <option>mimencode</option> command installed, another way to do produce
52386 base64-encoded strings is to run the command
52387 </para>
52388 <literallayout class="monospaced">
52389 echo -e -n `\0user\0password' | mimencode
52390 </literallayout>
52391 <para>
52392 The <option>-e</option> option of <option>echo</option> enables the interpretation of backslash escapes
52393 in the argument, and the <option>-n</option> option specifies no newline at the end of its
52394 output. However, not all versions of <option>echo</option> recognize these options, so you
52395 should check your version before relying on this suggestion.
52396 </para>
52397 </section>
52398 <section id="SECID170">
52399 <title>Authentication by an Exim client</title>
52400 <para>
52401 <indexterm role="concept">
52402 <primary>authentication</primary>
52403 <secondary>on an Exim client</secondary>
52404 </indexterm>
52405 The <command>smtp</command> transport has two options called <option>hosts_require_auth</option> and
52406 <option>hosts_try_auth</option>. When the <command>smtp</command> transport connects to a server that
52407 announces support for authentication, and the host matches an entry in either
52408 of these options, Exim (as a client) tries to authenticate as follows:
52409 </para>
52410 <itemizedlist>
52411 <listitem>
52412 <para>
52413 For each authenticator that is configured as a client, in the order in which
52414 they are defined in the configuration, it searches the authentication
52415 mechanisms announced by the server for one whose name matches the public name
52416 of the authenticator.
52417 </para>
52418 </listitem>
52419 <listitem>
52420 <para>
52421 <indexterm role="variable">
52422 <primary><varname>$host</varname></primary>
52423 </indexterm>
52424 <indexterm role="variable">
52425 <primary><varname>$host_address</varname></primary>
52426 </indexterm>
52427 When it finds one that matches, it runs the authenticator&#x2019;s client code. The
52428 variables <varname>$host</varname> and <varname>$host_address</varname> are available for any string expansions
52429 that the client might do. They are set to the server&#x2019;s name and IP address. If
52430 any expansion is forced to fail, the authentication attempt is abandoned, and
52431 Exim moves on to the next authenticator. Otherwise an expansion failure causes
52432 delivery to be deferred.
52433 </para>
52434 </listitem>
52435 <listitem>
52436 <para>
52437 If the result of the authentication attempt is a temporary error or a timeout,
52438 Exim abandons trying to send the message to the host for the moment. It will
52439 try again later. If there are any backup hosts available, they are tried in the
52440 usual way.
52441 </para>
52442 </listitem>
52443 <listitem>
52444 <para>
52445 If the response to authentication is a permanent error (5<emphasis>xx</emphasis> code), Exim
52446 carries on searching the list of authenticators and tries another one if
52447 possible. If all authentication attempts give permanent errors, or if there are
52448 no attempts because no mechanisms match (or option expansions force failure),
52449 what happens depends on whether the host matches <option>hosts_require_auth</option> or
52450 <option>hosts_try_auth</option>. In the first case, a temporary error is generated, and
52451 delivery is deferred. The error can be detected in the retry rules, and thereby
52452 turned into a permanent error if you wish. In the second case, Exim tries to
52453 deliver the message unauthenticated.
52454 </para>
52455 </listitem>
52456 </itemizedlist>
52457 <para>
52458 Note that the hostlist test for whether to do authentication can be
52459 confused if name-IP lookups change between the time the peer is decided
52460 upon and the time that the transport runs.  For example, with a manualroute
52461 router given a host name, and with DNS "round-robin" used by that name: if
52462 the local resolver cache times out between the router and the transport
52463 running, the transport may get an IP for the name for its authentication
52464 check which does not match the connection peer IP.
52465 No authentication will then be done, despite the names being identical.
52466 </para>
52467 <para>
52468 For such cases use a separate transport which always authenticates.
52469 </para>
52470 <para>
52471 <indexterm role="concept">
52472 <primary>AUTH</primary>
52473 <secondary>on MAIL command</secondary>
52474 </indexterm>
52475 When Exim has authenticated itself to a remote server, it adds the AUTH
52476 parameter to the MAIL commands it sends, if it has an authenticated sender for
52477 the message. If the message came from a remote host, the authenticated sender
52478 is the one that was receiving on an incoming MAIL command, provided that the
52479 incoming connection was authenticated and the <option>server_mail_auth</option> condition
52480 allowed the authenticated sender to be retained. If a local process calls Exim
52481 to send a message, the sender address that is built from the login name and
52482 <option>qualify_domain</option> is treated as authenticated. However, if the
52483 <option>authenticated_sender</option> option is set on the <command>smtp</command> transport, it overrides
52484 the authenticated sender that was received with the message.
52485 <indexterm role="concept" startref="IIDauthconf1" class="endofrange"/>
52486 <indexterm role="concept" startref="IIDauthconf2" class="endofrange"/>
52487 </para>
52488 </section>
52489 </chapter>
52490
52491 <chapter id="CHAPplaintext">
52492 <title>The plaintext authenticator</title>
52493 <para>
52494 <indexterm role="concept" id="IIDplaiauth1" class="startofrange">
52495 <primary><command>plaintext</command> authenticator</primary>
52496 </indexterm>
52497 <indexterm role="concept" id="IIDplaiauth2" class="startofrange">
52498 <primary>authenticators</primary>
52499 <secondary><command>plaintext</command></secondary>
52500 </indexterm>
52501 The <command>plaintext</command> authenticator can be configured to support the PLAIN and
52502 LOGIN authentication mechanisms, both of which transfer authentication data as
52503 plain (unencrypted) text (though base64 encoded). The use of plain text is a
52504 security risk; you are strongly advised to insist on the use of SMTP encryption
52505 (see chapter <xref linkend="CHAPTLS"/>) if you use the PLAIN or LOGIN mechanisms. If you do
52506 use unencrypted plain text, you should not use the same passwords for SMTP
52507 connections as you do for login accounts.
52508 </para>
52509 <section id="SECTplain_TLS" revisionflag="changed">
52510 <title>Avoiding cleartext use</title>
52511 <para revisionflag="changed">
52512 The following generic option settings will disable <command>plaintext</command> authenticators when
52513 TLS is not being used:
52514 </para>
52515 <literallayout class="monospaced" revisionflag="changed">
52516   server_advertise_condition = ${if def:tls_in_cipher }
52517   client_condition =           ${if def:tls_out_cipher}
52518 </literallayout>
52519 <para revisionflag="changed">
52520 <emphasis role="bold">Note</emphasis>: a plaintext SMTP AUTH done inside TLS is not vulnerable to casual snooping,
52521 but is still vulnerable to a Man In The Middle attack unless certificates
52522 (including their names) have been properly verified.
52523 </para>
52524 </section>
52525 <section id="SECID171">
52526 <title>Plaintext server options</title>
52527 <para>
52528 <indexterm role="concept">
52529 <primary>options</primary>
52530 <secondary><command>plaintext</command> authenticator (server)</secondary>
52531 </indexterm>
52532 When configured as a server, <command>plaintext</command> uses the following options:
52533 </para>
52534 <para>
52535 <indexterm role="option">
52536 <primary><option>server_condition</option></primary>
52537 </indexterm>
52538 </para>
52539 <informaltable frame="all">
52540 <tgroup cols="4" colsep="0" rowsep="0">
52541 <colspec colwidth="8*" align="left"/>
52542 <colspec colwidth="6*" align="center"/>
52543 <colspec colwidth="6*" align="center"/>
52544 <colspec colwidth="6*" align="right"/>
52545 <tbody>
52546 <row>
52547 <entry><option>server_condition</option></entry>
52548 <entry>Use: <emphasis>authenticators</emphasis></entry>
52549 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
52550 <entry>Default: <emphasis>unset</emphasis></entry>
52551 </row>
52552 </tbody>
52553 </tgroup>
52554 </informaltable>
52555 <para>
52556 This is actually a global authentication option, but it must be set in order to
52557 configure the <command>plaintext</command> driver as a server. Its use is described below.
52558 </para>
52559 <para>
52560 <indexterm role="option">
52561 <primary><option>server_prompts</option></primary>
52562 </indexterm>
52563 </para>
52564 <informaltable frame="all">
52565 <tgroup cols="4" colsep="0" rowsep="0">
52566 <colspec colwidth="8*" align="left"/>
52567 <colspec colwidth="6*" align="center"/>
52568 <colspec colwidth="6*" align="center"/>
52569 <colspec colwidth="6*" align="right"/>
52570 <tbody>
52571 <row>
52572 <entry><option>server_prompts</option></entry>
52573 <entry>Use: <emphasis>plaintext</emphasis></entry>
52574 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
52575 <entry>Default: <emphasis>unset</emphasis></entry>
52576 </row>
52577 </tbody>
52578 </tgroup>
52579 </informaltable>
52580 <para>
52581 The contents of this option, after expansion, must be a colon-separated list of
52582 prompt strings. If expansion fails, a temporary authentication rejection is
52583 given.
52584 </para>
52585 </section>
52586 <section id="SECTplainserver">
52587 <title>Using plaintext in a server</title>
52588 <para>
52589 <indexterm role="concept">
52590 <primary>AUTH</primary>
52591 <secondary>in <command>plaintext</command> authenticator</secondary>
52592 </indexterm>
52593 <indexterm role="concept">
52594 <primary>binary zero</primary>
52595 <secondary>in <command>plaintext</command> authenticator</secondary>
52596 </indexterm>
52597 <indexterm role="concept">
52598 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
52599 <secondary>in <command>plaintext</command> authenticator</secondary>
52600 </indexterm>
52601 <indexterm role="variable">
52602 <primary><varname>$auth1</varname>, <varname>$auth2</varname>, etc</primary>
52603 </indexterm>
52604 <indexterm role="concept">
52605 <primary>base64 encoding</primary>
52606 <secondary>in <command>plaintext</command> authenticator</secondary>
52607 </indexterm>
52608 </para>
52609 <para>
52610 When running as a server, <command>plaintext</command> performs the authentication test by
52611 expanding a string. The data sent by the client with the AUTH command, or in
52612 response to subsequent prompts, is base64 encoded, and so may contain any byte
52613 values when decoded. If any data is supplied with the command, it is treated as
52614 a list of strings, separated by NULs (binary zeros), the first three of which
52615 are placed in the expansion variables <varname>$auth1</varname>, <varname>$auth2</varname>, and <varname>$auth3</varname>
52616 (neither LOGIN nor PLAIN uses more than three strings).
52617 </para>
52618 <para>
52619 For compatibility with previous releases of Exim, the values are also placed in
52620 the expansion variables <varname>$1</varname>, <varname>$2</varname>, and <varname>$3</varname>. However, the use of these
52621 variables for this purpose is now deprecated, as it can lead to confusion in
52622 string expansions that also use them for other things.
52623 </para>
52624 <para>
52625 If there are more strings in <option>server_prompts</option> than the number of strings
52626 supplied with the AUTH command, the remaining prompts are used to obtain more
52627 data. Each response from the client may be a list of NUL-separated strings.
52628 </para>
52629 <para>
52630 <indexterm role="variable">
52631 <primary><varname>$authenticated_id</varname></primary>
52632 </indexterm>
52633 Once a sufficient number of data strings have been received,
52634 <option>server_condition</option> is expanded. If the expansion is forced to fail,
52635 authentication fails. Any other expansion failure causes a temporary error code
52636 to be returned. If the result of a successful expansion is an empty string,
52637 <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, authentication fails. If the result of the
52638 expansion is <quote>1</quote>, <quote>yes</quote>, or <quote>true</quote>, authentication succeeds and the
52639 generic <option>server_set_id</option> option is expanded and saved in <varname>$authenticated_id</varname>.
52640 For any other result, a temporary error code is returned, with the expanded
52641 string as the error text.
52642 </para>
52643 <para>
52644 <emphasis role="bold">Warning</emphasis>: If you use a lookup in the expansion to find the user&#x2019;s
52645 password, be sure to make the authentication fail if the user is unknown.
52646 There are good and bad examples at the end of the next section.
52647 </para>
52648 </section>
52649 <section id="SECID172">
52650 <title>The PLAIN authentication mechanism</title>
52651 <para>
52652 <indexterm role="concept">
52653 <primary>PLAIN authentication mechanism</primary>
52654 </indexterm>
52655 <indexterm role="concept">
52656 <primary>authentication</primary>
52657 <secondary>PLAIN mechanism</secondary>
52658 </indexterm>
52659 <indexterm role="concept">
52660 <primary>binary zero</primary>
52661 <secondary>in <command>plaintext</command> authenticator</secondary>
52662 </indexterm>
52663 The PLAIN authentication mechanism (RFC 2595) specifies that three strings be
52664 sent as one item of data (that is, one combined string containing two NUL
52665 separators). The data is sent either as part of the AUTH command, or
52666 subsequently in response to an empty prompt from the server.
52667 </para>
52668 <para>
52669 The second and third strings are a user name and a corresponding password.
52670 Using a single fixed user name and password as an example, this could be
52671 configured as follows:
52672 </para>
52673 <literallayout class="monospaced">
52674 fixed_plain:
52675   driver = plaintext
52676   public_name = PLAIN
52677   server_prompts = :
52678   server_condition = \
52679     ${if and {{eq{$auth2}{username}}{eq{$auth3}{mysecret}}}}
52680   server_set_id = $auth2
52681 </literallayout>
52682 <para>
52683 Note that the default result strings from <option>if</option> (<quote>true</quote> or an empty string)
52684 are exactly what we want here, so they need not be specified. Obviously, if the
52685 password contains expansion-significant characters such as dollar, backslash,
52686 or closing brace, they have to be escaped.
52687 </para>
52688 <para>
52689 The <option>server_prompts</option> setting specifies a single, empty prompt (empty items at
52690 the end of a string list are ignored). If all the data comes as part of the
52691 AUTH command, as is commonly the case, the prompt is not used. This
52692 authenticator is advertised in the response to EHLO as
52693 </para>
52694 <literallayout class="monospaced">
52695 250-AUTH PLAIN
52696 </literallayout>
52697 <para>
52698 and a client host can authenticate itself by sending the command
52699 </para>
52700 <literallayout class="monospaced">
52701 AUTH PLAIN AHVzZXJuYW1lAG15c2VjcmV0
52702 </literallayout>
52703 <para>
52704 As this contains three strings (more than the number of prompts), no further
52705 data is required from the client. Alternatively, the client may just send
52706 </para>
52707 <literallayout class="monospaced">
52708 AUTH PLAIN
52709 </literallayout>
52710 <para>
52711 to initiate authentication, in which case the server replies with an empty
52712 prompt. The client must respond with the combined data string.
52713 </para>
52714 <para>
52715 The data string is base64 encoded, as required by the RFC. This example,
52716 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;
52717 represents a zero byte. This is split up into three strings, the first of which
52718 is empty. The <option>server_condition</option> option in the authenticator checks that the
52719 second two are <literal>username</literal> and <literal>mysecret</literal> respectively.
52720 </para>
52721 <para>
52722 Having just one fixed user name and password, as in this example, is not very
52723 realistic, though for a small organization with only a handful of
52724 authenticating clients it could make sense.
52725 </para>
52726 <para>
52727 A more sophisticated instance of this authenticator could use the user name in
52728 <varname>$auth2</varname> to look up a password in a file or database, and maybe do an encrypted
52729 comparison (see <option>crypteq</option> in chapter <xref linkend="CHAPexpand"/>). Here is a example of
52730 this approach, where the passwords are looked up in a DBM file. <emphasis role="bold">Warning</emphasis>:
52731 This is an incorrect example:
52732 </para>
52733 <literallayout class="monospaced">
52734 server_condition = \
52735   ${if eq{$auth3}{${lookup{$auth2}dbm{/etc/authpwd}}}}
52736 </literallayout>
52737 <para>
52738 The expansion uses the user name (<varname>$auth2</varname>) as the key to look up a password,
52739 which it then compares to the supplied password (<varname>$auth3</varname>). Why is this example
52740 incorrect? It works fine for existing users, but consider what happens if a
52741 non-existent user name is given. The lookup fails, but as no success/failure
52742 strings are given for the lookup, it yields an empty string. Thus, to defeat
52743 the authentication, all a client has to do is to supply a non-existent user
52744 name and an empty password. The correct way of writing this test is:
52745 </para>
52746 <literallayout class="monospaced">
52747 server_condition = ${lookup{$auth2}dbm{/etc/authpwd}\
52748   {${if eq{$value}{$auth3}}} {false}}
52749 </literallayout>
52750 <para>
52751 In this case, if the lookup succeeds, the result is checked; if the lookup
52752 fails, <quote>false</quote> is returned and authentication fails. If <option>crypteq</option> is being
52753 used instead of <option>eq</option>, the first example is in fact safe, because <option>crypteq</option>
52754 always fails if its second argument is empty. However, the second way of
52755 writing the test makes the logic clearer.
52756 </para>
52757 </section>
52758 <section id="SECID173">
52759 <title>The LOGIN authentication mechanism</title>
52760 <para>
52761 <indexterm role="concept">
52762 <primary>LOGIN authentication mechanism</primary>
52763 </indexterm>
52764 <indexterm role="concept">
52765 <primary>authentication</primary>
52766 <secondary>LOGIN mechanism</secondary>
52767 </indexterm>
52768 The LOGIN authentication mechanism is not documented in any RFC, but is in use
52769 in a number of programs. No data is sent with the AUTH command. Instead, a
52770 user name and password are supplied separately, in response to prompts. The
52771 plaintext authenticator can be configured to support this as in this example:
52772 </para>
52773 <literallayout class="monospaced">
52774 fixed_login:
52775   driver = plaintext
52776   public_name = LOGIN
52777   server_prompts = User Name : Password
52778   server_condition = \
52779     ${if and {{eq{$auth1}{username}}{eq{$auth2}{mysecret}}}}
52780   server_set_id = $auth1
52781 </literallayout>
52782 <para>
52783 Because of the way plaintext operates, this authenticator accepts data supplied
52784 with the AUTH command (in contravention of the specification of LOGIN), but
52785 if the client does not supply it (as is the case for LOGIN clients), the prompt
52786 strings are used to obtain two data items.
52787 </para>
52788 <para>
52789 Some clients are very particular about the precise text of the prompts. For
52790 example, Outlook Express is reported to recognize only <quote>Username:</quote> and
52791 <quote>Password:</quote>. Here is an example of a LOGIN authenticator that uses those
52792 strings. It uses the <option>ldapauth</option> expansion condition to check the user
52793 name and password by binding to an LDAP server:
52794 </para>
52795 <literallayout class="monospaced">
52796 login:
52797   driver = plaintext
52798   public_name = LOGIN
52799   server_prompts = Username:: : Password::
52800   server_condition = ${if and{{ \
52801     !eq{}{$auth1} }{ \
52802     ldapauth{\
52803       user="uid=${quote_ldap_dn:$auth1},ou=people,o=example.org" \
52804       pass=${quote:$auth2} \
52805       ldap://ldap.example.org/} }} }
52806   server_set_id = uid=$auth1,ou=people,o=example.org
52807 </literallayout>
52808 <para>
52809 We have to check that the username is not empty before using it, because LDAP
52810 does not permit empty DN components. We must also use the <option>quote_ldap_dn</option>
52811 operator to correctly quote the DN for authentication. However, the basic
52812 <option>quote</option> operator, rather than any of the LDAP quoting operators, is the
52813 correct one to use for the password, because quoting is needed only to make
52814 the password conform to the Exim syntax. At the LDAP level, the password is an
52815 uninterpreted string.
52816 </para>
52817 </section>
52818 <section id="SECID174">
52819 <title>Support for different kinds of authentication</title>
52820 <para>
52821 A number of string expansion features are provided for the purpose of
52822 interfacing to different ways of user authentication. These include checking
52823 traditionally encrypted passwords from <filename>/etc/passwd</filename> (or equivalent), PAM,
52824 Radius, <option>ldapauth</option>, <emphasis>pwcheck</emphasis>, and <emphasis>saslauthd</emphasis>. For details see section
52825 <xref linkend="SECTexpcond"/>.
52826 </para>
52827 </section>
52828 <section id="SECID175">
52829 <title>Using plaintext in a client</title>
52830 <para>
52831 <indexterm role="concept">
52832 <primary>options</primary>
52833 <secondary><command>plaintext</command> authenticator (client)</secondary>
52834 </indexterm>
52835 The <command>plaintext</command> authenticator has two client options:
52836 </para>
52837 <para>
52838 <indexterm role="option">
52839 <primary><option>client_ignore_invalid_base64</option></primary>
52840 </indexterm>
52841 </para>
52842 <informaltable frame="all">
52843 <tgroup cols="4" colsep="0" rowsep="0">
52844 <colspec colwidth="8*" align="left"/>
52845 <colspec colwidth="6*" align="center"/>
52846 <colspec colwidth="6*" align="center"/>
52847 <colspec colwidth="6*" align="right"/>
52848 <tbody>
52849 <row>
52850 <entry><option>client_ignore_invalid_base64</option></entry>
52851 <entry>Use: <emphasis>plaintext</emphasis></entry>
52852 <entry>Type: <emphasis>boolean</emphasis></entry>
52853 <entry>Default: <emphasis>false</emphasis></entry>
52854 </row>
52855 </tbody>
52856 </tgroup>
52857 </informaltable>
52858 <para>
52859 If the client receives a server prompt that is not a valid base64 string,
52860 authentication is abandoned by default. However, if this option is set true,
52861 the error in the challenge is ignored and the client sends the response as
52862 usual.
52863 </para>
52864 <para>
52865 <indexterm role="option">
52866 <primary><option>client_send</option></primary>
52867 </indexterm>
52868 </para>
52869 <informaltable frame="all">
52870 <tgroup cols="4" colsep="0" rowsep="0">
52871 <colspec colwidth="8*" align="left"/>
52872 <colspec colwidth="6*" align="center"/>
52873 <colspec colwidth="6*" align="center"/>
52874 <colspec colwidth="6*" align="right"/>
52875 <tbody>
52876 <row>
52877 <entry><option>client_send</option></entry>
52878 <entry>Use: <emphasis>plaintext</emphasis></entry>
52879 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
52880 <entry>Default: <emphasis>unset</emphasis></entry>
52881 </row>
52882 </tbody>
52883 </tgroup>
52884 </informaltable>
52885 <para>
52886 The string is a colon-separated list of authentication data strings. Each
52887 string is independently expanded before being sent to the server. The first
52888 string is sent with the AUTH command; any more strings are sent in response
52889 to prompts from the server. Before each string is expanded, the value of the
52890 most recent prompt is placed in the next <varname>$auth</varname>&lt;<emphasis>n</emphasis>&gt; variable, starting
52891 with <varname>$auth1</varname> for the first prompt. Up to three prompts are stored in this
52892 way. Thus, the prompt that is received in response to sending the first string
52893 (with the AUTH command) can be used in the expansion of the second string, and
52894 so on. If an invalid base64 string is received when
52895 <option>client_ignore_invalid_base64</option> is set, an empty string is put in the
52896 <varname>$auth</varname>&lt;<emphasis>n</emphasis>&gt; variable.
52897 </para>
52898 <para>
52899 <emphasis role="bold">Note</emphasis>: You cannot use expansion to create multiple strings, because
52900 splitting takes priority and happens first.
52901 </para>
52902 <para>
52903 Because the PLAIN authentication mechanism requires NUL (binary zero) bytes in
52904 the data, further processing is applied to each string before it is sent. If
52905 there are any single circumflex characters in the string, they are converted to
52906 NULs. Should an actual circumflex be required as data, it must be doubled in
52907 the string.
52908 </para>
52909 <para>
52910 This is an example of a client configuration that implements the PLAIN
52911 authentication mechanism with a fixed user name and password:
52912 </para>
52913 <literallayout class="monospaced">
52914 fixed_plain:
52915   driver = plaintext
52916   public_name = PLAIN
52917   client_send = ^username^mysecret
52918 </literallayout>
52919 <para>
52920 The lack of colons means that the entire text is sent with the AUTH
52921 command, with the circumflex characters converted to NULs. A similar example
52922 that uses the LOGIN mechanism is:
52923 </para>
52924 <literallayout class="monospaced">
52925 fixed_login:
52926   driver = plaintext
52927   public_name = LOGIN
52928   client_send = : username : mysecret
52929 </literallayout>
52930 <para>
52931 The initial colon means that the first string is empty, so no data is sent with
52932 the AUTH command itself. The remaining strings are sent in response to
52933 prompts.
52934 <indexterm role="concept" startref="IIDplaiauth1" class="endofrange"/>
52935 <indexterm role="concept" startref="IIDplaiauth2" class="endofrange"/>
52936 </para>
52937 </section>
52938 </chapter>
52939
52940 <chapter id="CHID9">
52941 <title>The cram_md5 authenticator</title>
52942 <para>
52943 <indexterm role="concept" id="IIDcramauth1" class="startofrange">
52944 <primary><command>cram_md5</command> authenticator</primary>
52945 </indexterm>
52946 <indexterm role="concept" id="IIDcramauth2" class="startofrange">
52947 <primary>authenticators</primary>
52948 <secondary><command>cram_md5</command></secondary>
52949 </indexterm>
52950 <indexterm role="concept">
52951 <primary>CRAM-MD5 authentication mechanism</primary>
52952 </indexterm>
52953 <indexterm role="concept">
52954 <primary>authentication</primary>
52955 <secondary>CRAM-MD5 mechanism</secondary>
52956 </indexterm>
52957 The CRAM-MD5 authentication mechanism is described in RFC 2195. The server
52958 sends a challenge string to the client, and the response consists of a user
52959 name and the CRAM-MD5 digest of the challenge string combined with a secret
52960 string (password) which is known to both server and client. Thus, the secret
52961 is not sent over the network as plain text, which makes this authenticator more
52962 secure than <command>plaintext</command>. However, the downside is that the secret has to be
52963 available in plain text at either end.
52964 </para>
52965 <section id="SECID176">
52966 <title>Using cram_md5 as a server</title>
52967 <para>
52968 <indexterm role="concept">
52969 <primary>options</primary>
52970 <secondary><command>cram_md5</command> authenticator (server)</secondary>
52971 </indexterm>
52972 This authenticator has one server option, which must be set to configure the
52973 authenticator as a server:
52974 </para>
52975 <para>
52976 <indexterm role="option">
52977 <primary><option>server_secret</option></primary>
52978 </indexterm>
52979 </para>
52980 <informaltable frame="all">
52981 <tgroup cols="4" colsep="0" rowsep="0">
52982 <colspec colwidth="8*" align="left"/>
52983 <colspec colwidth="6*" align="center"/>
52984 <colspec colwidth="6*" align="center"/>
52985 <colspec colwidth="6*" align="right"/>
52986 <tbody>
52987 <row>
52988 <entry><option>server_secret</option></entry>
52989 <entry>Use: <emphasis>cram_md5</emphasis></entry>
52990 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
52991 <entry>Default: <emphasis>unset</emphasis></entry>
52992 </row>
52993 </tbody>
52994 </tgroup>
52995 </informaltable>
52996 <para>
52997 <indexterm role="concept">
52998 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
52999 <secondary>in <command>cram_md5</command> authenticator</secondary>
53000 </indexterm>
53001 When the server receives the client&#x2019;s response, the user name is placed in
53002 the expansion variable <varname>$auth1</varname>, and <option>server_secret</option> is expanded to
53003 obtain the password for that user. The server then computes the CRAM-MD5 digest
53004 that the client should have sent, and checks that it received the correct
53005 string. If the expansion of <option>server_secret</option> is forced to fail, authentication
53006 fails. If the expansion fails for some other reason, a temporary error code is
53007 returned to the client.
53008 </para>
53009 <para>
53010 For compatibility with previous releases of Exim, the user name is also placed
53011 in <varname>$1</varname>. However, the use of this variables for this purpose is now
53012 deprecated, as it can lead to confusion in string expansions that also use
53013 numeric variables for other things.
53014 </para>
53015 <para>
53016 For example, the following authenticator checks that the user name given by the
53017 client is <quote>ph10</quote>, and if so, uses <quote>secret</quote> as the password. For any other
53018 user name, authentication fails.
53019 </para>
53020 <literallayout class="monospaced">
53021 fixed_cram:
53022   driver = cram_md5
53023   public_name = CRAM-MD5
53024   server_secret = ${if eq{$auth1}{ph10}{secret}fail}
53025   server_set_id = $auth1
53026 </literallayout>
53027 <para>
53028 <indexterm role="variable">
53029 <primary><varname>$authenticated_id</varname></primary>
53030 </indexterm>
53031 If authentication succeeds, the setting of <option>server_set_id</option> preserves the user
53032 name in <varname>$authenticated_id</varname>. A more typical configuration might look up the
53033 secret string in a file, using the user name as the key. For example:
53034 </para>
53035 <literallayout class="monospaced">
53036 lookup_cram:
53037   driver = cram_md5
53038   public_name = CRAM-MD5
53039   server_secret = ${lookup{$auth1}lsearch{/etc/authpwd}\
53040                   {$value}fail}
53041   server_set_id = $auth1
53042 </literallayout>
53043 <para>
53044 Note that this expansion explicitly forces failure if the lookup fails
53045 because <varname>$auth1</varname> contains an unknown user name.
53046 </para>
53047 <para>
53048 As another example, if you wish to re-use a Cyrus SASL sasldb2 file without
53049 using the relevant libraries, you need to know the realm to specify in the
53050 lookup and then ask for the <quote>userPassword</quote> attribute for that user in that
53051 realm, with:
53052 </para>
53053 <literallayout class="monospaced">
53054 cyrusless_crammd5:
53055   driver = cram_md5
53056   public_name = CRAM-MD5
53057   server_secret = ${lookup{$auth1:mail.example.org:userPassword}\
53058                   dbmjz{/etc/sasldb2}{$value}fail}
53059   server_set_id = $auth1
53060 </literallayout>
53061 </section>
53062 <section id="SECID177">
53063 <title>Using cram_md5 as a client</title>
53064 <para>
53065 <indexterm role="concept">
53066 <primary>options</primary>
53067 <secondary><command>cram_md5</command> authenticator (client)</secondary>
53068 </indexterm>
53069 When used as a client, the <command>cram_md5</command> authenticator has two options:
53070 </para>
53071 <para>
53072 <indexterm role="option">
53073 <primary><option>client_name</option></primary>
53074 </indexterm>
53075 </para>
53076 <informaltable frame="all">
53077 <tgroup cols="4" colsep="0" rowsep="0">
53078 <colspec colwidth="8*" align="left"/>
53079 <colspec colwidth="6*" align="center"/>
53080 <colspec colwidth="6*" align="center"/>
53081 <colspec colwidth="6*" align="right"/>
53082 <tbody>
53083 <row>
53084 <entry><option>client_name</option></entry>
53085 <entry>Use: <emphasis>cram_md5</emphasis></entry>
53086 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
53087 <entry>Default: <emphasis>the primary host name</emphasis></entry>
53088 </row>
53089 </tbody>
53090 </tgroup>
53091 </informaltable>
53092 <para>
53093 This string is expanded, and the result used as the user name data when
53094 computing the response to the server&#x2019;s challenge.
53095 </para>
53096 <para>
53097 <indexterm role="option">
53098 <primary><option>client_secret</option></primary>
53099 </indexterm>
53100 </para>
53101 <informaltable frame="all">
53102 <tgroup cols="4" colsep="0" rowsep="0">
53103 <colspec colwidth="8*" align="left"/>
53104 <colspec colwidth="6*" align="center"/>
53105 <colspec colwidth="6*" align="center"/>
53106 <colspec colwidth="6*" align="right"/>
53107 <tbody>
53108 <row>
53109 <entry><option>client_secret</option></entry>
53110 <entry>Use: <emphasis>cram_md5</emphasis></entry>
53111 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
53112 <entry>Default: <emphasis>unset</emphasis></entry>
53113 </row>
53114 </tbody>
53115 </tgroup>
53116 </informaltable>
53117 <para>
53118 This option must be set for the authenticator to work as a client. Its value is
53119 expanded and the result used as the secret string when computing the response.
53120 </para>
53121 <para>
53122 <indexterm role="variable">
53123 <primary><varname>$host</varname></primary>
53124 </indexterm>
53125 <indexterm role="variable">
53126 <primary><varname>$host_address</varname></primary>
53127 </indexterm>
53128 Different user names and secrets can be used for different servers by referring
53129 to <varname>$host</varname> or <varname>$host_address</varname> in the options. Forced failure of either
53130 expansion string is treated as an indication that this authenticator is not
53131 prepared to handle this case. Exim moves on to the next configured client
53132 authenticator. Any other expansion failure causes Exim to give up trying to
53133 send the message to the current server.
53134 </para>
53135 <para>
53136 A simple example configuration of a <command>cram_md5</command> authenticator, using fixed
53137 strings, is:
53138 </para>
53139 <literallayout class="monospaced">
53140 fixed_cram:
53141   driver = cram_md5
53142   public_name = CRAM-MD5
53143   client_name = ph10
53144   client_secret = secret
53145 </literallayout>
53146 <para>
53147 <indexterm role="concept" startref="IIDcramauth1" class="endofrange"/>
53148 <indexterm role="concept" startref="IIDcramauth2" class="endofrange"/>
53149 </para>
53150 </section>
53151 </chapter>
53152
53153 <chapter id="CHID10">
53154 <title>The cyrus_sasl authenticator</title>
53155 <para>
53156 <indexterm role="concept" id="IIDcyrauth1" class="startofrange">
53157 <primary><command>cyrus_sasl</command> authenticator</primary>
53158 </indexterm>
53159 <indexterm role="concept" id="IIDcyrauth2" class="startofrange">
53160 <primary>authenticators</primary>
53161 <secondary><command>cyrus_sasl</command></secondary>
53162 </indexterm>
53163 <indexterm role="concept">
53164 <primary>Cyrus</primary>
53165 <secondary>SASL library</secondary>
53166 </indexterm>
53167 <indexterm role="concept">
53168 <primary>Kerberos</primary>
53169 </indexterm>
53170 The code for this authenticator was provided by Matthew Byng-Maddick while
53171 at A L Digital Ltd.
53172 </para>
53173 <para>
53174 The <command>cyrus_sasl</command> authenticator provides server support for the Cyrus SASL
53175 library implementation of the RFC 2222 (<quote>Simple Authentication and Security
53176 Layer</quote>). This library supports a number of authentication mechanisms,
53177 including PLAIN and LOGIN, but also several others that Exim does not support
53178 directly. In particular, there is support for Kerberos authentication.
53179 </para>
53180 <para>
53181 The <command>cyrus_sasl</command> authenticator provides a gatewaying mechanism directly to
53182 the Cyrus interface, so if your Cyrus library can do, for example, CRAM-MD5,
53183 then so can the <command>cyrus_sasl</command> authenticator. By default it uses the public
53184 name of the driver to determine which mechanism to support.
53185 </para>
53186 <para>
53187 Where access to some kind of secret file is required, for example, in GSSAPI
53188 or CRAM-MD5, it is worth noting that the authenticator runs as the Exim
53189 user, and that the Cyrus SASL library has no way of escalating privileges
53190 by default. You may also find you need to set environment variables,
53191 depending on the driver you are using.
53192 </para>
53193 <para>
53194 The application name provided by Exim is <quote>exim</quote>, so various SASL options may
53195 be set in <filename>exim.conf</filename> in your SASL directory. If you are using GSSAPI for
53196 Kerberos, note that because of limitations in the GSSAPI interface,
53197 changing the server keytab might need to be communicated down to the Kerberos
53198 layer independently. The mechanism for doing so is dependent upon the Kerberos
53199 implementation.
53200 </para>
53201 <para>
53202 For example, for older releases of Heimdal, the environment variable KRB5_KTNAME
53203 may be set to point to an alternative keytab file. Exim will pass this
53204 variable through from its own inherited environment when started as root or the
53205 Exim user. The keytab file needs to be readable by the Exim user.
53206 With newer releases of Heimdal, a setuid Exim may cause Heimdal to discard the
53207 environment variable.  In practice, for those releases, the Cyrus authenticator
53208 is not a suitable interface for GSSAPI (Kerberos) support.  Instead, consider
53209 the <command>heimdal_gssapi</command> authenticator, described in chapter <xref linkend="CHAPheimdalgss"/>
53210 </para>
53211 <section id="SECID178">
53212 <title>Using cyrus_sasl as a server</title>
53213 <para>
53214 The <command>cyrus_sasl</command> authenticator has four private options. It puts the username
53215 (on a successful authentication) into <varname>$auth1</varname>. For compatibility with
53216 previous releases of Exim, the username is also placed in <varname>$1</varname>. However, the
53217 use of this variable for this purpose is now deprecated, as it can lead to
53218 confusion in string expansions that also use numeric variables for other
53219 things.
53220 </para>
53221 <para>
53222 <indexterm role="option">
53223 <primary><option>server_hostname</option></primary>
53224 </indexterm>
53225 </para>
53226 <informaltable frame="all">
53227 <tgroup cols="4" colsep="0" rowsep="0">
53228 <colspec colwidth="8*" align="left"/>
53229 <colspec colwidth="6*" align="center"/>
53230 <colspec colwidth="6*" align="center"/>
53231 <colspec colwidth="6*" align="right"/>
53232 <tbody>
53233 <row>
53234 <entry><option>server_hostname</option></entry>
53235 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
53236 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
53237 <entry>Default: <emphasis>see below</emphasis></entry>
53238 </row>
53239 </tbody>
53240 </tgroup>
53241 </informaltable>
53242 <para>
53243 This option selects the hostname that is used when communicating with the
53244 library. The default value is <literal>$primary_hostname</literal>. It is up to the underlying
53245 SASL plug-in what it does with this data.
53246 </para>
53247 <para>
53248 <indexterm role="option">
53249 <primary><option>server_mech</option></primary>
53250 </indexterm>
53251 </para>
53252 <informaltable frame="all">
53253 <tgroup cols="4" colsep="0" rowsep="0">
53254 <colspec colwidth="8*" align="left"/>
53255 <colspec colwidth="6*" align="center"/>
53256 <colspec colwidth="6*" align="center"/>
53257 <colspec colwidth="6*" align="right"/>
53258 <tbody>
53259 <row>
53260 <entry><option>server_mech</option></entry>
53261 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
53262 <entry>Type: <emphasis>string</emphasis></entry>
53263 <entry>Default: <emphasis>see below</emphasis></entry>
53264 </row>
53265 </tbody>
53266 </tgroup>
53267 </informaltable>
53268 <para>
53269 This option selects the authentication mechanism this driver should use. The
53270 default is the value of the generic <option>public_name</option> option. This option allows
53271 you to use a different underlying mechanism from the advertised name. For
53272 example:
53273 </para>
53274 <literallayout class="monospaced">
53275 sasl:
53276   driver = cyrus_sasl
53277   public_name = X-ANYTHING
53278   server_mech = CRAM-MD5
53279   server_set_id = $auth1
53280 </literallayout>
53281 <para>
53282 <indexterm role="option">
53283 <primary><option>server_realm</option></primary>
53284 </indexterm>
53285 </para>
53286 <informaltable frame="all">
53287 <tgroup cols="4" colsep="0" rowsep="0">
53288 <colspec colwidth="8*" align="left"/>
53289 <colspec colwidth="6*" align="center"/>
53290 <colspec colwidth="6*" align="center"/>
53291 <colspec colwidth="6*" align="right"/>
53292 <tbody>
53293 <row>
53294 <entry><option>server_realm</option></entry>
53295 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
53296 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
53297 <entry>Default: <emphasis>unset</emphasis></entry>
53298 </row>
53299 </tbody>
53300 </tgroup>
53301 </informaltable>
53302 <para>
53303 This specifies the SASL realm that the server claims to be in.
53304 </para>
53305 <para>
53306 <indexterm role="option">
53307 <primary><option>server_service</option></primary>
53308 </indexterm>
53309 </para>
53310 <informaltable frame="all">
53311 <tgroup cols="4" colsep="0" rowsep="0">
53312 <colspec colwidth="8*" align="left"/>
53313 <colspec colwidth="6*" align="center"/>
53314 <colspec colwidth="6*" align="center"/>
53315 <colspec colwidth="6*" align="right"/>
53316 <tbody>
53317 <row>
53318 <entry><option>server_service</option></entry>
53319 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
53320 <entry>Type: <emphasis>string</emphasis></entry>
53321 <entry>Default: <emphasis><literal>smtp</literal></emphasis></entry>
53322 </row>
53323 </tbody>
53324 </tgroup>
53325 </informaltable>
53326 <para>
53327 This is the SASL service that the server claims to implement.
53328 </para>
53329 <para>
53330 For straightforward cases, you do not need to set any of the authenticator&#x2019;s
53331 private options. All you need to do is to specify an appropriate mechanism as
53332 the public name. Thus, if you have a SASL library that supports CRAM-MD5 and
53333 PLAIN, you could have two authenticators as follows:
53334 </para>
53335 <literallayout class="monospaced">
53336 sasl_cram_md5:
53337   driver = cyrus_sasl
53338   public_name = CRAM-MD5
53339   server_set_id = $auth1
53340
53341 sasl_plain:
53342   driver = cyrus_sasl
53343   public_name = PLAIN
53344   server_set_id = $auth2
53345 </literallayout>
53346 <para>
53347 Cyrus SASL does implement the LOGIN authentication method, even though it is
53348 not a standard method. It is disabled by default in the source distribution,
53349 but it is present in many binary distributions.
53350 <indexterm role="concept" startref="IIDcyrauth1" class="endofrange"/>
53351 <indexterm role="concept" startref="IIDcyrauth2" class="endofrange"/>
53352 </para>
53353 </section>
53354 </chapter>
53355
53356 <chapter id="CHAPdovecot">
53357 <title>The dovecot authenticator</title>
53358 <para>
53359 <indexterm role="concept" id="IIDdcotauth1" class="startofrange">
53360 <primary><command>dovecot</command> authenticator</primary>
53361 </indexterm>
53362 <indexterm role="concept" id="IIDdcotauth2" class="startofrange">
53363 <primary>authenticators</primary>
53364 <secondary><command>dovecot</command></secondary>
53365 </indexterm>
53366 This authenticator is an interface to the authentication facility of the
53367 Dovecot POP/IMAP server, which can support a number of authentication methods.
53368 Note that Dovecot must be configured to use auth-client not auth-userdb.
53369 If you are using Dovecot to authenticate POP/IMAP clients, it might be helpful
53370 to use the same mechanisms for SMTP authentication. This is a server
53371 authenticator only. There is only one option:
53372 </para>
53373 <para>
53374 <indexterm role="option">
53375 <primary><option>server_socket</option></primary>
53376 </indexterm>
53377 </para>
53378 <informaltable frame="all">
53379 <tgroup cols="4" colsep="0" rowsep="0">
53380 <colspec colwidth="8*" align="left"/>
53381 <colspec colwidth="6*" align="center"/>
53382 <colspec colwidth="6*" align="center"/>
53383 <colspec colwidth="6*" align="right"/>
53384 <tbody>
53385 <row>
53386 <entry><option>server_socket</option></entry>
53387 <entry>Use: <emphasis>dovecot</emphasis></entry>
53388 <entry>Type: <emphasis>string</emphasis></entry>
53389 <entry>Default: <emphasis>unset</emphasis></entry>
53390 </row>
53391 </tbody>
53392 </tgroup>
53393 </informaltable>
53394 <para>
53395 This option must specify the UNIX socket that is the interface to Dovecot
53396 authentication. The <option>public_name</option> option must specify an authentication
53397 mechanism that Dovecot is configured to support. You can have several
53398 authenticators for different mechanisms. For example:
53399 </para>
53400 <literallayout class="monospaced">
53401 dovecot_plain:
53402   driver = dovecot
53403   public_name = PLAIN
53404   server_socket = /var/run/dovecot/auth-client
53405   server_set_id = $auth1
53406
53407 dovecot_ntlm:
53408   driver = dovecot
53409   public_name = NTLM
53410   server_socket = /var/run/dovecot/auth-client
53411   server_set_id = $auth1
53412 </literallayout>
53413 <para>
53414 If the SMTP connection is encrypted, or if <varname>$sender_host_address</varname> is equal to
53415 <varname>$received_ip_address</varname> (that is, the connection is local), the <quote>secured</quote>
53416 option is passed in the Dovecot authentication command. If, for a TLS
53417 connection, a client certificate has been verified, the <quote>valid-client-cert</quote>
53418 option is passed. When authentication succeeds, the identity of the user
53419 who authenticated is placed in <varname>$auth1</varname>.
53420 <indexterm role="concept" startref="IIDdcotauth1" class="endofrange"/>
53421 <indexterm role="concept" startref="IIDdcotauth2" class="endofrange"/>
53422 </para>
53423 </chapter>
53424
53425 <chapter id="CHAPgsasl">
53426 <title>The gsasl authenticator</title>
53427 <para>
53428 <indexterm role="concept" id="IIDgsaslauth1" class="startofrange">
53429 <primary><command>gsasl</command> authenticator</primary>
53430 </indexterm>
53431 <indexterm role="concept" id="IIDgsaslauth2" class="startofrange">
53432 <primary>authenticators</primary>
53433 <secondary><command>gsasl</command></secondary>
53434 </indexterm>
53435 <indexterm role="concept">
53436 <primary>authentication</primary>
53437 <secondary>GNU SASL</secondary>
53438 </indexterm>
53439 <indexterm role="concept">
53440 <primary>authentication</primary>
53441 <secondary>SASL</secondary>
53442 </indexterm>
53443 <indexterm role="concept">
53444 <primary>authentication</primary>
53445 <secondary>EXTERNAL</secondary>
53446 </indexterm>
53447 <indexterm role="concept">
53448 <primary>authentication</primary>
53449 <secondary>ANONYMOUS</secondary>
53450 </indexterm>
53451 <indexterm role="concept">
53452 <primary>authentication</primary>
53453 <secondary>PLAIN</secondary>
53454 </indexterm>
53455 <indexterm role="concept">
53456 <primary>authentication</primary>
53457 <secondary>LOGIN</secondary>
53458 </indexterm>
53459 <indexterm role="concept">
53460 <primary>authentication</primary>
53461 <secondary>DIGEST-MD5</secondary>
53462 </indexterm>
53463 <indexterm role="concept">
53464 <primary>authentication</primary>
53465 <secondary>CRAM-MD5</secondary>
53466 </indexterm>
53467 <indexterm role="concept">
53468 <primary>authentication</primary>
53469 <secondary>SCRAM-SHA-1</secondary>
53470 </indexterm>
53471 The <command>gsasl</command> authenticator provides server integration for the GNU SASL
53472 library and the mechanisms it provides.  This is new as of the 4.80 release
53473 and there are a few areas where the library does not let Exim smoothly
53474 scale to handle future authentication mechanisms, so no guarantee can be
53475 made that any particular new authentication mechanism will be supported
53476 without code changes in Exim.
53477 </para>
53478 <para>
53479 Exim&#x2019;s <command>gsasl</command> authenticator does not have client-side support at this
53480 time; only the server-side support is implemented.  Patches welcome.
53481 </para>
53482 <para>
53483 <indexterm role="option">
53484 <primary><option>server_channelbinding</option></primary>
53485 </indexterm>
53486 </para>
53487 <informaltable frame="all">
53488 <tgroup cols="4" colsep="0" rowsep="0">
53489 <colspec colwidth="8*" align="left"/>
53490 <colspec colwidth="6*" align="center"/>
53491 <colspec colwidth="6*" align="center"/>
53492 <colspec colwidth="6*" align="right"/>
53493 <tbody>
53494 <row>
53495 <entry><option>server_channelbinding</option></entry>
53496 <entry>Use: <emphasis>gsasl</emphasis></entry>
53497 <entry>Type: <emphasis>boolean</emphasis></entry>
53498 <entry>Default: <emphasis>false</emphasis></entry>
53499 </row>
53500 </tbody>
53501 </tgroup>
53502 </informaltable>
53503 <para>
53504 Do not set this true without consulting a cryptographic engineer.
53505 </para>
53506 <para>
53507 Some authentication mechanisms are able to use external context at both ends
53508 of the session to bind the authentication to that context, and fail the
53509 authentication process if that context differs.  Specifically, some TLS
53510 ciphersuites can provide identifying information about the cryptographic
53511 context.
53512 </para>
53513 <para>
53514 This should have meant that certificate identity and verification becomes a
53515 non-issue, as a man-in-the-middle attack will cause the correct client and
53516 server to see different identifiers and authentication will fail.
53517 </para>
53518 <para>
53519 This is currently only supported when using the GnuTLS library.  This is
53520 only usable by mechanisms which support "channel binding"; at time of
53521 writing, that&#x2019;s the SCRAM family.
53522 </para>
53523 <para>
53524 This defaults off to ensure smooth upgrade across Exim releases, in case
53525 this option causes some clients to start failing.  Some future release
53526 of Exim might have switched the default to be true.
53527 </para>
53528 <para>
53529 However, Channel Binding in TLS has proven to be broken in current versions.
53530 Do not plan to rely upon this feature for security, ever, without consulting
53531 with a subject matter expert (a cryptographic engineer).
53532 </para>
53533 <para>
53534 <indexterm role="option">
53535 <primary><option>server_hostname</option></primary>
53536 </indexterm>
53537 </para>
53538 <informaltable frame="all">
53539 <tgroup cols="4" colsep="0" rowsep="0">
53540 <colspec colwidth="8*" align="left"/>
53541 <colspec colwidth="6*" align="center"/>
53542 <colspec colwidth="6*" align="center"/>
53543 <colspec colwidth="6*" align="right"/>
53544 <tbody>
53545 <row>
53546 <entry><option>server_hostname</option></entry>
53547 <entry>Use: <emphasis>gsasl</emphasis></entry>
53548 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
53549 <entry>Default: <emphasis>see below</emphasis></entry>
53550 </row>
53551 </tbody>
53552 </tgroup>
53553 </informaltable>
53554 <para>
53555 This option selects the hostname that is used when communicating with the
53556 library. The default value is <literal>$primary_hostname</literal>.
53557 Some mechanisms will use this data.
53558 </para>
53559 <para>
53560 <indexterm role="option">
53561 <primary><option>server_mech</option></primary>
53562 </indexterm>
53563 </para>
53564 <informaltable frame="all">
53565 <tgroup cols="4" colsep="0" rowsep="0">
53566 <colspec colwidth="8*" align="left"/>
53567 <colspec colwidth="6*" align="center"/>
53568 <colspec colwidth="6*" align="center"/>
53569 <colspec colwidth="6*" align="right"/>
53570 <tbody>
53571 <row>
53572 <entry><option>server_mech</option></entry>
53573 <entry>Use: <emphasis>gsasl</emphasis></entry>
53574 <entry>Type: <emphasis>string</emphasis></entry>
53575 <entry>Default: <emphasis>see below</emphasis></entry>
53576 </row>
53577 </tbody>
53578 </tgroup>
53579 </informaltable>
53580 <para>
53581 This option selects the authentication mechanism this driver should use. The
53582 default is the value of the generic <option>public_name</option> option. This option allows
53583 you to use a different underlying mechanism from the advertised name. For
53584 example:
53585 </para>
53586 <literallayout class="monospaced">
53587 sasl:
53588   driver = gsasl
53589   public_name = X-ANYTHING
53590   server_mech = CRAM-MD5
53591   server_set_id = $auth1
53592 </literallayout>
53593 <para>
53594 <indexterm role="option">
53595 <primary><option>server_password</option></primary>
53596 </indexterm>
53597 </para>
53598 <informaltable frame="all">
53599 <tgroup cols="4" colsep="0" rowsep="0">
53600 <colspec colwidth="8*" align="left"/>
53601 <colspec colwidth="6*" align="center"/>
53602 <colspec colwidth="6*" align="center"/>
53603 <colspec colwidth="6*" align="right"/>
53604 <tbody>
53605 <row>
53606 <entry><option>server_password</option></entry>
53607 <entry>Use: <emphasis>gsasl</emphasis></entry>
53608 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
53609 <entry>Default: <emphasis>unset</emphasis></entry>
53610 </row>
53611 </tbody>
53612 </tgroup>
53613 </informaltable>
53614 <para>
53615 Various mechanisms need access to the cleartext password on the server, so
53616 that proof-of-possession can be demonstrated on the wire, without sending
53617 the password itself.
53618 </para>
53619 <para>
53620 The data available for lookup varies per mechanism.
53621 In all cases, <varname>$auth1</varname> is set to the <emphasis>authentication id</emphasis>.
53622 The <varname>$auth2</varname> variable will always be the <emphasis>authorization id</emphasis> (<emphasis>authz</emphasis>)
53623 if available, else the empty string.
53624 The <varname>$auth3</varname> variable will always be the <emphasis>realm</emphasis> if available,
53625 else the empty string.
53626 </para>
53627 <para>
53628 A forced failure will cause authentication to defer.
53629 </para>
53630 <para>
53631 If using this option, it may make sense to set the <option>server_condition</option>
53632 option to be simply "true".
53633 </para>
53634 <para>
53635 <indexterm role="option">
53636 <primary><option>server_realm</option></primary>
53637 </indexterm>
53638 </para>
53639 <informaltable frame="all">
53640 <tgroup cols="4" colsep="0" rowsep="0">
53641 <colspec colwidth="8*" align="left"/>
53642 <colspec colwidth="6*" align="center"/>
53643 <colspec colwidth="6*" align="center"/>
53644 <colspec colwidth="6*" align="right"/>
53645 <tbody>
53646 <row>
53647 <entry><option>server_realm</option></entry>
53648 <entry>Use: <emphasis>gsasl</emphasis></entry>
53649 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
53650 <entry>Default: <emphasis>unset</emphasis></entry>
53651 </row>
53652 </tbody>
53653 </tgroup>
53654 </informaltable>
53655 <para>
53656 This specifies the SASL realm that the server claims to be in.
53657 Some mechanisms will use this data.
53658 </para>
53659 <para>
53660 <indexterm role="option">
53661 <primary><option>server_scram_iter</option></primary>
53662 </indexterm>
53663 </para>
53664 <informaltable frame="all">
53665 <tgroup cols="4" colsep="0" rowsep="0">
53666 <colspec colwidth="8*" align="left"/>
53667 <colspec colwidth="6*" align="center"/>
53668 <colspec colwidth="6*" align="center"/>
53669 <colspec colwidth="6*" align="right"/>
53670 <tbody>
53671 <row>
53672 <entry><option>server_scram_iter</option></entry>
53673 <entry>Use: <emphasis>gsasl</emphasis></entry>
53674 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
53675 <entry>Default: <emphasis>unset</emphasis></entry>
53676 </row>
53677 </tbody>
53678 </tgroup>
53679 </informaltable>
53680 <para>
53681 This option provides data for the SCRAM family of mechanisms.
53682 <varname>$auth1</varname> is not available at evaluation time.
53683 (This may change, as we receive feedback on use)
53684 </para>
53685 <para>
53686 <indexterm role="option">
53687 <primary><option>server_scram_salt</option></primary>
53688 </indexterm>
53689 </para>
53690 <informaltable frame="all">
53691 <tgroup cols="4" colsep="0" rowsep="0">
53692 <colspec colwidth="8*" align="left"/>
53693 <colspec colwidth="6*" align="center"/>
53694 <colspec colwidth="6*" align="center"/>
53695 <colspec colwidth="6*" align="right"/>
53696 <tbody>
53697 <row>
53698 <entry><option>server_scram_salt</option></entry>
53699 <entry>Use: <emphasis>gsasl</emphasis></entry>
53700 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
53701 <entry>Default: <emphasis>unset</emphasis></entry>
53702 </row>
53703 </tbody>
53704 </tgroup>
53705 </informaltable>
53706 <para>
53707 This option provides data for the SCRAM family of mechanisms.
53708 <varname>$auth1</varname> is not available at evaluation time.
53709 (This may change, as we receive feedback on use)
53710 </para>
53711 <para>
53712 <indexterm role="option">
53713 <primary><option>server_service</option></primary>
53714 </indexterm>
53715 </para>
53716 <informaltable frame="all">
53717 <tgroup cols="4" colsep="0" rowsep="0">
53718 <colspec colwidth="8*" align="left"/>
53719 <colspec colwidth="6*" align="center"/>
53720 <colspec colwidth="6*" align="center"/>
53721 <colspec colwidth="6*" align="right"/>
53722 <tbody>
53723 <row>
53724 <entry><option>server_service</option></entry>
53725 <entry>Use: <emphasis>gsasl</emphasis></entry>
53726 <entry>Type: <emphasis>string</emphasis></entry>
53727 <entry>Default: <emphasis><literal>smtp</literal></emphasis></entry>
53728 </row>
53729 </tbody>
53730 </tgroup>
53731 </informaltable>
53732 <para>
53733 This is the SASL service that the server claims to implement.
53734 Some mechanisms will use this data.
53735 </para>
53736 <section id="SECTgsaslauthvar">
53737 <title><command>gsasl</command> auth variables</title>
53738 <para>
53739 <indexterm role="variable">
53740 <primary><varname>$auth1</varname>, <varname>$auth2</varname>, etc</primary>
53741 </indexterm>
53742 These may be set when evaluating specific options, as detailed above.
53743 They will also be set when evaluating <option>server_condition</option>.
53744 </para>
53745 <para>
53746 Unless otherwise stated below, the <command>gsasl</command> integration will use the following
53747 meanings for these variables:
53748 </para>
53749 <itemizedlist>
53750 <listitem>
53751 <para>
53752 <indexterm role="variable">
53753 <primary><varname>$auth1</varname></primary>
53754 </indexterm>
53755 <varname>$auth1</varname>: the <emphasis>authentication id</emphasis>
53756 </para>
53757 </listitem>
53758 <listitem>
53759 <para>
53760 <indexterm role="variable">
53761 <primary><varname>$auth2</varname></primary>
53762 </indexterm>
53763 <varname>$auth2</varname>: the <emphasis>authorization id</emphasis>
53764 </para>
53765 </listitem>
53766 <listitem>
53767 <para>
53768 <indexterm role="variable">
53769 <primary><varname>$auth3</varname></primary>
53770 </indexterm>
53771 <varname>$auth3</varname>: the <emphasis>realm</emphasis>
53772 </para>
53773 </listitem>
53774 </itemizedlist>
53775 <para>
53776 On a per-mechanism basis:
53777 </para>
53778 <itemizedlist>
53779 <listitem>
53780 <para>
53781 <indexterm role="concept">
53782 <primary>authentication</primary>
53783 <secondary>EXTERNAL</secondary>
53784 </indexterm>
53785 EXTERNAL: only <varname>$auth1</varname> is set, to the possibly empty <emphasis>authorization id</emphasis>;
53786 the <option>server_condition</option> option must be present.
53787 </para>
53788 </listitem>
53789 <listitem>
53790 <para>
53791 <indexterm role="concept">
53792 <primary>authentication</primary>
53793 <secondary>ANONYMOUS</secondary>
53794 </indexterm>
53795 ANONYMOUS: only <varname>$auth1</varname> is set, to the possibly empty <emphasis>anonymous token</emphasis>;
53796 the <option>server_condition</option> option must be present.
53797 </para>
53798 </listitem>
53799 <listitem>
53800 <para>
53801 <indexterm role="concept">
53802 <primary>authentication</primary>
53803 <secondary>GSSAPI</secondary>
53804 </indexterm>
53805 GSSAPI: <varname>$auth1</varname> will be set to the <emphasis>GSSAPI Display Name</emphasis>;
53806 <varname>$auth2</varname> will be set to the <emphasis>authorization id</emphasis>,
53807 the <option>server_condition</option> option must be present.
53808 </para>
53809 </listitem>
53810 </itemizedlist>
53811 <para>
53812 An <emphasis>anonymous token</emphasis> is something passed along as an unauthenticated
53813 identifier; this is analogous to FTP anonymous authentication passing an
53814 email address, or software-identifier@, as the "password".
53815 </para>
53816 <para>
53817 An example showing the password having the realm specified in the callback
53818 and demonstrating a Cyrus SASL to GSASL migration approach is:
53819 </para>
53820 <literallayout class="monospaced">
53821 gsasl_cyrusless_crammd5:
53822   driver = gsasl
53823   public_name = CRAM-MD5
53824   server_realm = imap.example.org
53825   server_password = ${lookup{$auth1:$auth3:userPassword}\
53826                     dbmjz{/etc/sasldb2}{$value}fail}
53827   server_set_id = ${quote:$auth1}
53828   server_condition = yes
53829 </literallayout>
53830 </section>
53831 </chapter>
53832
53833 <chapter id="CHAPheimdalgss">
53834 <title>The heimdal_gssapi authenticator</title>
53835 <para>
53836 <indexterm role="concept" id="IIDheimdalgssauth1" class="startofrange">
53837 <primary><command>heimdal_gssapi</command> authenticator</primary>
53838 </indexterm>
53839 <indexterm role="concept" id="IIDheimdalgssauth2" class="startofrange">
53840 <primary>authenticators</primary>
53841 <secondary><command>heimdal_gssapi</command></secondary>
53842 </indexterm>
53843 <indexterm role="concept">
53844 <primary>authentication</primary>
53845 <secondary>GSSAPI</secondary>
53846 </indexterm>
53847 <indexterm role="concept">
53848 <primary>authentication</primary>
53849 <secondary>Kerberos</secondary>
53850 </indexterm>
53851 The <command>heimdal_gssapi</command> authenticator provides server integration for the
53852 Heimdal GSSAPI/Kerberos library, permitting Exim to set a keytab pathname
53853 reliably.
53854 </para>
53855 <para>
53856 <indexterm role="option">
53857 <primary><option>server_hostname</option></primary>
53858 </indexterm>
53859 </para>
53860 <informaltable frame="all">
53861 <tgroup cols="4" colsep="0" rowsep="0">
53862 <colspec colwidth="8*" align="left"/>
53863 <colspec colwidth="6*" align="center"/>
53864 <colspec colwidth="6*" align="center"/>
53865 <colspec colwidth="6*" align="right"/>
53866 <tbody>
53867 <row>
53868 <entry><option>server_hostname</option></entry>
53869 <entry>Use: <emphasis>heimdal_gssapi</emphasis></entry>
53870 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
53871 <entry>Default: <emphasis>see below</emphasis></entry>
53872 </row>
53873 </tbody>
53874 </tgroup>
53875 </informaltable>
53876 <para>
53877 This option selects the hostname that is used, with <option>server_service</option>,
53878 for constructing the GSS server name, as a <emphasis>GSS_C_NT_HOSTBASED_SERVICE</emphasis>
53879 identifier.  The default value is <literal>$primary_hostname</literal>.
53880 </para>
53881 <para>
53882 <indexterm role="option">
53883 <primary><option>server_keytab</option></primary>
53884 </indexterm>
53885 </para>
53886 <informaltable frame="all">
53887 <tgroup cols="4" colsep="0" rowsep="0">
53888 <colspec colwidth="8*" align="left"/>
53889 <colspec colwidth="6*" align="center"/>
53890 <colspec colwidth="6*" align="center"/>
53891 <colspec colwidth="6*" align="right"/>
53892 <tbody>
53893 <row>
53894 <entry><option>server_keytab</option></entry>
53895 <entry>Use: <emphasis>heimdal_gssapi</emphasis></entry>
53896 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
53897 <entry>Default: <emphasis>unset</emphasis></entry>
53898 </row>
53899 </tbody>
53900 </tgroup>
53901 </informaltable>
53902 <para>
53903 If set, then Heimdal will not use the system default keytab (typically
53904 <filename>/etc/krb5.keytab</filename>) but instead the pathname given in this option.
53905 The value should be a pathname, with no <quote>file:</quote> prefix.
53906 </para>
53907 <para>
53908 <indexterm role="option">
53909 <primary><option>server_service</option></primary>
53910 </indexterm>
53911 </para>
53912 <informaltable frame="all">
53913 <tgroup cols="4" colsep="0" rowsep="0">
53914 <colspec colwidth="8*" align="left"/>
53915 <colspec colwidth="6*" align="center"/>
53916 <colspec colwidth="6*" align="center"/>
53917 <colspec colwidth="6*" align="right"/>
53918 <tbody>
53919 <row>
53920 <entry><option>server_service</option></entry>
53921 <entry>Use: <emphasis>heimdal_gssapi</emphasis></entry>
53922 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
53923 <entry>Default: <emphasis>smtp</emphasis></entry>
53924 </row>
53925 </tbody>
53926 </tgroup>
53927 </informaltable>
53928 <para>
53929 This option specifies the service identifier used, in conjunction with
53930 <option>server_hostname</option>, for building the identifier for finding credentials
53931 from the keytab.
53932 </para>
53933 <section id="SECTheimdalgssauthvar">
53934 <title><command>heimdal_gssapi</command> auth variables</title>
53935 <para>
53936 Beware that these variables will typically include a realm, thus will appear
53937 to be roughly like an email address already.  The <emphasis>authzid</emphasis> in <varname>$auth2</varname> is
53938 not verified, so a malicious client can set it to anything.
53939 </para>
53940 <para>
53941 The <varname>$auth1</varname> field should be safely trustable as a value from the Key
53942 Distribution Center.  Note that these are not quite email addresses.
53943 Each identifier is for a role, and so the left-hand-side may include a
53944 role suffix.  For instance, <quote>joe/admin@EXAMPLE.ORG</quote>.
53945 </para>
53946 <para>
53947 <indexterm role="variable">
53948 <primary><varname>$auth1</varname>, <varname>$auth2</varname>, etc</primary>
53949 </indexterm>
53950 </para>
53951 <itemizedlist>
53952 <listitem>
53953 <para>
53954 <indexterm role="variable">
53955 <primary><varname>$auth1</varname></primary>
53956 </indexterm>
53957 <varname>$auth1</varname>: the <emphasis>authentication id</emphasis>, set to the GSS Display Name.
53958 </para>
53959 </listitem>
53960 <listitem>
53961 <para>
53962 <indexterm role="variable">
53963 <primary><varname>$auth2</varname></primary>
53964 </indexterm>
53965 <varname>$auth2</varname>: the <emphasis>authorization id</emphasis>, sent within SASL encapsulation after
53966 authentication.  If that was empty, this will also be set to the
53967 GSS Display Name.
53968 </para>
53969 </listitem>
53970 </itemizedlist>
53971 </section>
53972 </chapter>
53973
53974 <chapter id="CHAPspa">
53975 <title>The spa authenticator</title>
53976 <para>
53977 <indexterm role="concept" id="IIDspaauth1" class="startofrange">
53978 <primary><command>spa</command> authenticator</primary>
53979 </indexterm>
53980 <indexterm role="concept" id="IIDspaauth2" class="startofrange">
53981 <primary>authenticators</primary>
53982 <secondary><command>spa</command></secondary>
53983 </indexterm>
53984 <indexterm role="concept">
53985 <primary>authentication</primary>
53986 <secondary>Microsoft Secure Password</secondary>
53987 </indexterm>
53988 <indexterm role="concept">
53989 <primary>authentication</primary>
53990 <secondary>NTLM</secondary>
53991 </indexterm>
53992 <indexterm role="concept">
53993 <primary>Microsoft Secure Password Authentication</primary>
53994 </indexterm>
53995 <indexterm role="concept">
53996 <primary>NTLM authentication</primary>
53997 </indexterm>
53998 The <command>spa</command> authenticator provides client support for Microsoft&#x2019;s <emphasis>Secure
53999 Password Authentication</emphasis> mechanism,
54000 which is also sometimes known as NTLM (NT LanMan). The code for client side of
54001 this authenticator was contributed by Marc Prud&#x2019;hommeaux, and much of it is
54002 taken from the Samba project (<emphasis role="bold"><ulink url="https://www.samba.org/">https://www.samba.org/</ulink></emphasis>). The code for the
54003 server side was subsequently contributed by Tom Kistner. The mechanism works as
54004 follows:
54005 </para>
54006 <itemizedlist>
54007 <listitem>
54008 <para>
54009 After the AUTH command has been accepted, the client sends an SPA
54010 authentication request based on the user name and optional domain.
54011 </para>
54012 </listitem>
54013 <listitem>
54014 <para>
54015 The server sends back a challenge.
54016 </para>
54017 </listitem>
54018 <listitem>
54019 <para>
54020 The client builds a challenge response which makes use of the user&#x2019;s password
54021 and sends it to the server, which then accepts or rejects it.
54022 </para>
54023 </listitem>
54024 </itemizedlist>
54025 <para>
54026 Encryption is used to protect the password in transit.
54027 </para>
54028 <section id="SECID179">
54029 <title>Using spa as a server</title>
54030 <para>
54031 <indexterm role="concept">
54032 <primary>options</primary>
54033 <secondary><command>spa</command> authenticator (server)</secondary>
54034 </indexterm>
54035 The <command>spa</command> authenticator has just one server option:
54036 </para>
54037 <para>
54038 <indexterm role="option">
54039 <primary><option>server_password</option></primary>
54040 </indexterm>
54041 </para>
54042 <informaltable frame="all">
54043 <tgroup cols="4" colsep="0" rowsep="0">
54044 <colspec colwidth="8*" align="left"/>
54045 <colspec colwidth="6*" align="center"/>
54046 <colspec colwidth="6*" align="center"/>
54047 <colspec colwidth="6*" align="right"/>
54048 <tbody>
54049 <row>
54050 <entry><option>server_password</option></entry>
54051 <entry>Use: <emphasis>spa</emphasis></entry>
54052 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
54053 <entry>Default: <emphasis>unset</emphasis></entry>
54054 </row>
54055 </tbody>
54056 </tgroup>
54057 </informaltable>
54058 <para>
54059 <indexterm role="concept">
54060 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
54061 <secondary>in <command>spa</command> authenticator</secondary>
54062 </indexterm>
54063 This option is expanded, and the result must be the cleartext password for the
54064 authenticating user, whose name is at this point in <varname>$auth1</varname>. For
54065 compatibility with previous releases of Exim, the user name is also placed in
54066 <varname>$1</varname>. However, the use of this variable for this purpose is now deprecated, as
54067 it can lead to confusion in string expansions that also use numeric variables
54068 for other things. For example:
54069 </para>
54070 <literallayout class="monospaced">
54071 spa:
54072   driver = spa
54073   public_name = NTLM
54074   server_password = \
54075     ${lookup{$auth1}lsearch{/etc/exim/spa_clearpass}{$value}fail}
54076 </literallayout>
54077 <para>
54078 If the expansion is forced to fail, authentication fails. Any other expansion
54079 failure causes a temporary error code to be returned.
54080 </para>
54081 </section>
54082 <section id="SECID180">
54083 <title>Using spa as a client</title>
54084 <para>
54085 <indexterm role="concept">
54086 <primary>options</primary>
54087 <secondary><command>spa</command> authenticator (client)</secondary>
54088 </indexterm>
54089 The <command>spa</command> authenticator has the following client options:
54090 </para>
54091 <para>
54092 <indexterm role="option">
54093 <primary><option>client_domain</option></primary>
54094 </indexterm>
54095 </para>
54096 <informaltable frame="all">
54097 <tgroup cols="4" colsep="0" rowsep="0">
54098 <colspec colwidth="8*" align="left"/>
54099 <colspec colwidth="6*" align="center"/>
54100 <colspec colwidth="6*" align="center"/>
54101 <colspec colwidth="6*" align="right"/>
54102 <tbody>
54103 <row>
54104 <entry><option>client_domain</option></entry>
54105 <entry>Use: <emphasis>spa</emphasis></entry>
54106 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
54107 <entry>Default: <emphasis>unset</emphasis></entry>
54108 </row>
54109 </tbody>
54110 </tgroup>
54111 </informaltable>
54112 <para>
54113 This option specifies an optional domain for the authentication.
54114 </para>
54115 <para>
54116 <indexterm role="option">
54117 <primary><option>client_password</option></primary>
54118 </indexterm>
54119 </para>
54120 <informaltable frame="all">
54121 <tgroup cols="4" colsep="0" rowsep="0">
54122 <colspec colwidth="8*" align="left"/>
54123 <colspec colwidth="6*" align="center"/>
54124 <colspec colwidth="6*" align="center"/>
54125 <colspec colwidth="6*" align="right"/>
54126 <tbody>
54127 <row>
54128 <entry><option>client_password</option></entry>
54129 <entry>Use: <emphasis>spa</emphasis></entry>
54130 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
54131 <entry>Default: <emphasis>unset</emphasis></entry>
54132 </row>
54133 </tbody>
54134 </tgroup>
54135 </informaltable>
54136 <para>
54137 This option specifies the user&#x2019;s password, and must be set.
54138 </para>
54139 <para>
54140 <indexterm role="option">
54141 <primary><option>client_username</option></primary>
54142 </indexterm>
54143 </para>
54144 <informaltable frame="all">
54145 <tgroup cols="4" colsep="0" rowsep="0">
54146 <colspec colwidth="8*" align="left"/>
54147 <colspec colwidth="6*" align="center"/>
54148 <colspec colwidth="6*" align="center"/>
54149 <colspec colwidth="6*" align="right"/>
54150 <tbody>
54151 <row>
54152 <entry><option>client_username</option></entry>
54153 <entry>Use: <emphasis>spa</emphasis></entry>
54154 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
54155 <entry>Default: <emphasis>unset</emphasis></entry>
54156 </row>
54157 </tbody>
54158 </tgroup>
54159 </informaltable>
54160 <para>
54161 This option specifies the user name, and must be set. Here is an example of a
54162 configuration of this authenticator for use with the mail servers at
54163 <emphasis>msn.com</emphasis>:
54164 </para>
54165 <literallayout class="monospaced">
54166 msn:
54167   driver = spa
54168   public_name = MSN
54169   client_username = msn/msn_username
54170   client_password = msn_plaintext_password
54171   client_domain = DOMAIN_OR_UNSET
54172 </literallayout>
54173 <para>
54174 <indexterm role="concept" startref="IIDspaauth1" class="endofrange"/>
54175 <indexterm role="concept" startref="IIDspaauth2" class="endofrange"/>
54176 </para>
54177 </section>
54178 </chapter>
54179
54180 <chapter id="CHAPexternauth" revisionflag="changed">
54181 <title>The external authenticator</title>
54182 <para revisionflag="changed">
54183 <indexterm role="concept" id="IIDexternauth1" class="startofrange">
54184 <primary><command>external</command> authenticator</primary>
54185 </indexterm>
54186 <indexterm role="concept" id="IIDexternauth2" class="startofrange">
54187 <primary>authenticators</primary>
54188 <secondary><command>external</command></secondary>
54189 </indexterm>
54190 <indexterm role="concept">
54191 <primary>authentication</primary>
54192 <secondary>Client Certificate</secondary>
54193 </indexterm>
54194 <indexterm role="concept">
54195 <primary>authentication</primary>
54196 <secondary>X509</secondary>
54197 </indexterm>
54198 <indexterm role="concept">
54199 <primary>Certificate-based authentication</primary>
54200 </indexterm>
54201 The <command>external</command> authenticator provides support for
54202 authentication based on non-SMTP information.
54203 The specification is in RFC 4422 Appendix A
54204 (<emphasis role="bold"><ulink url="https://tools.ietf.org/html/rfc4422">https://tools.ietf.org/html/rfc4422</ulink></emphasis>).
54205 It is only a transport and negotiation mechanism;
54206 the process of authentication is entirely controlled
54207 by the server configuration.
54208 </para>
54209 <para revisionflag="changed">
54210 The client presents an identity in-clear.
54211 It is probably wise for a server to only advertise,
54212 and for clients to only attempt,
54213 this authentication method on a secure (eg. under TLS) connection.
54214 </para>
54215 <para revisionflag="changed">
54216 One possible use, compatible with the
54217 K-9 Mail Andoid client (<emphasis role="bold"><ulink url="https://k9mail.github.io/">https://k9mail.github.io/</ulink></emphasis>),
54218 is for using X509 client certificates.
54219 </para>
54220 <para revisionflag="changed">
54221 It thus overlaps in function with the TLS authenticator
54222 (see <xref linkend="CHAPtlsauth"/>)
54223 but is a full SMTP SASL authenticator
54224 rather than being implicit for TLS-connection carried
54225 client certificates only.
54226 </para>
54227 <para revisionflag="changed">
54228 The examples and discussion in this chapter assume that
54229 client-certificate authentication is being done.
54230 </para>
54231 <para revisionflag="changed">
54232 The client must present a certificate,
54233 for which it must have been requested via the
54234 <option>tls_verify_hosts</option> or <option>tls_try_verify_hosts</option> main options
54235 (see <xref linkend="CHAPTLS"/>).
54236 For authentication to be effective the certificate should be
54237 verifiable against a trust-anchor certificate known to the server.
54238 </para>
54239 <section id="SECTexternsoptions" revisionflag="changed">
54240 <title>External options</title>
54241 <para revisionflag="changed">
54242 <indexterm role="concept">
54243 <primary>options</primary>
54244 <secondary><command>external</command> authenticator (server)</secondary>
54245 </indexterm>
54246 The <command>external</command> authenticator has two server options:
54247 </para>
54248 <para revisionflag="changed">
54249 <indexterm role="option">
54250 <primary><option>server_param2</option></primary>
54251 </indexterm>
54252 </para>
54253 <informaltable frame="all" revisionflag="changed">
54254 <tgroup cols="4" colsep="0" rowsep="0">
54255 <colspec colwidth="8*" align="left"/>
54256 <colspec colwidth="6*" align="center"/>
54257 <colspec colwidth="6*" align="center"/>
54258 <colspec colwidth="6*" align="right"/>
54259 <tbody>
54260 <row>
54261 <entry><option>server_param2</option></entry>
54262 <entry>Use: <emphasis>external</emphasis></entry>
54263 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
54264 <entry>Default: <emphasis>unset</emphasis></entry>
54265 </row>
54266 </tbody>
54267 </tgroup>
54268 </informaltable>
54269 <para revisionflag="changed">
54270 <indexterm role="option">
54271 <primary><option>server_param3</option></primary>
54272 </indexterm>
54273 </para>
54274 <informaltable frame="all" revisionflag="changed">
54275 <tgroup cols="4" colsep="0" rowsep="0">
54276 <colspec colwidth="8*" align="left"/>
54277 <colspec colwidth="6*" align="center"/>
54278 <colspec colwidth="6*" align="center"/>
54279 <colspec colwidth="6*" align="right"/>
54280 <tbody>
54281 <row>
54282 <entry><option>server_param3</option></entry>
54283 <entry>Use: <emphasis>external</emphasis></entry>
54284 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
54285 <entry>Default: <emphasis>unset</emphasis></entry>
54286 </row>
54287 </tbody>
54288 </tgroup>
54289 </informaltable>
54290 <para revisionflag="changed">
54291 <indexterm role="concept">
54292 <primary>variables (<varname>$auth1</varname> <varname>$auth2</varname> etc)</primary>
54293 <secondary>in <command>external</command> authenticator</secondary>
54294 </indexterm>
54295 These options are expanded before the <option>server_condition</option> option
54296 and the result are placed in <varname>$auth2</varname> and <varname>$auth3</varname> resectively.
54297 If the expansion is forced to fail, authentication fails. Any other expansion
54298 failure causes a temporary error code to be returned.
54299 </para>
54300 <para revisionflag="changed">
54301 They can be used to clarify the coding of a complex <option>server_condition</option>.
54302 </para>
54303 </section>
54304 <section id="SECTexternserver" revisionflag="changed">
54305 <title>Using external in a server</title>
54306 <para revisionflag="changed">
54307 <indexterm role="concept">
54308 <primary>AUTH</primary>
54309 <secondary>in <command>external</command> authenticator</secondary>
54310 </indexterm>
54311 <indexterm role="concept">
54312 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
54313 <secondary>in <command>external</command> authenticator</secondary>
54314 </indexterm>
54315 <indexterm role="variable">
54316 <primary><varname>$auth1</varname>, <varname>$auth2</varname>, etc</primary>
54317 </indexterm>
54318 <indexterm role="concept">
54319 <primary>base64 encoding</primary>
54320 <secondary>in <command>external</command> authenticator</secondary>
54321 </indexterm>
54322 </para>
54323 <para revisionflag="changed">
54324 When running as a server, <command>external</command> performs the authentication test by
54325 expanding a string. The data sent by the client with the AUTH command, or in
54326 response to subsequent prompts, is base64 encoded, and so may contain any byte
54327 values when decoded. The decoded value is treated as
54328 an identity for authentication and
54329 placed in the expansion variable <varname>$auth1</varname>.
54330 </para>
54331 <para revisionflag="changed">
54332 For compatibility with previous releases of Exim, the value is also placed in
54333 the expansion variable <varname>$1</varname>. However, the use of this
54334 variable for this purpose is now deprecated, as it can lead to confusion in
54335 string expansions that also use them for other things.
54336 </para>
54337 <para revisionflag="changed">
54338 <indexterm role="variable">
54339 <primary><varname>$authenticated_id</varname></primary>
54340 </indexterm>
54341 Once an identity has been received,
54342 <option>server_condition</option> is expanded. If the expansion is forced to fail,
54343 authentication fails. Any other expansion failure causes a temporary error code
54344 to be returned. If the result of a successful expansion is an empty string,
54345 <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, authentication fails. If the result of the
54346 expansion is <quote>1</quote>, <quote>yes</quote>, or <quote>true</quote>, authentication succeeds and the
54347 generic <option>server_set_id</option> option is expanded and saved in <varname>$authenticated_id</varname>.
54348 For any other result, a temporary error code is returned, with the expanded
54349 string as the error text.
54350 </para>
54351 <para revisionflag="changed">
54352 Example:
54353 </para>
54354 <literallayout class="monospaced" revisionflag="changed">
54355 ext_ccert_san_mail:
54356   driver =            external
54357   public_name =       EXTERNAL
54358
54359   server_advertise_condition = $tls_in_certificate_verified
54360   server_param2 =     ${certextract {subj_altname,mail,&gt;:} \
54361                                     {$tls_in_peercert}}
54362   server_condition =  ${if forany {$auth2} \
54363                             {eq {$item}{$auth1}}}
54364   server_set_id =     $auth1
54365 </literallayout>
54366 <para revisionflag="changed">
54367 This accepts a client certificate that is verifiable against any
54368 of your configured trust-anchors
54369 (which usually means the full set of public CAs)
54370 and which has a mail-SAN matching the claimed identity sent by the client.
54371 </para>
54372 <para revisionflag="changed">
54373 <emphasis role="bold">Note</emphasis>: up to TLS1.2, the client cert is on the wire in-clear, including the SAN.
54374 The account name is therefore guessable by an opponent.
54375 TLS 1.3 protects both server and client certificates, and is not vulnerable
54376 in this way.
54377 </para>
54378 </section>
54379 <section id="SECTexternclient" revisionflag="changed">
54380 <title>Using external in a client</title>
54381 <para revisionflag="changed">
54382 <indexterm role="concept">
54383 <primary>options</primary>
54384 <secondary><command>external</command> authenticator (client)</secondary>
54385 </indexterm>
54386 The <command>external</command> authenticator has one client option:
54387 </para>
54388 <para revisionflag="changed">
54389 <indexterm role="option">
54390 <primary><option>client_send</option></primary>
54391 </indexterm>
54392 </para>
54393 <informaltable frame="all" revisionflag="changed">
54394 <tgroup cols="4" colsep="0" rowsep="0">
54395 <colspec colwidth="8*" align="left"/>
54396 <colspec colwidth="6*" align="center"/>
54397 <colspec colwidth="6*" align="center"/>
54398 <colspec colwidth="6*" align="right"/>
54399 <tbody>
54400 <row>
54401 <entry><option>client_send</option></entry>
54402 <entry>Use: <emphasis>external</emphasis></entry>
54403 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
54404 <entry>Default: <emphasis>unset</emphasis></entry>
54405 </row>
54406 </tbody>
54407 </tgroup>
54408 </informaltable>
54409 <para revisionflag="changed">
54410 This option is expanded and sent with the AUTH command as the
54411 identity being asserted.
54412 </para>
54413 <para revisionflag="changed">
54414 Example:
54415 </para>
54416 <literallayout class="monospaced" revisionflag="changed">
54417 ext_ccert:
54418   driver =      external
54419   public_name = EXTERNAL
54420
54421   client_condition = ${if !eq{$tls_out_cipher}{}}
54422   client_send = myaccount@smarthost.example.net
54423 </literallayout>
54424 <para revisionflag="changed">
54425 <indexterm role="concept" startref="IIDexternauth1" class="endofrange"/>
54426 <indexterm role="concept" startref="IIDexternauth2" class="endofrange"/>
54427 </para>
54428 </section>
54429 </chapter>
54430
54431 <chapter id="CHAPtlsauth">
54432 <title>The tls authenticator</title>
54433 <para>
54434 <indexterm role="concept" id="IIDtlsauth1" class="startofrange">
54435 <primary><command>tls</command> authenticator</primary>
54436 </indexterm>
54437 <indexterm role="concept" id="IIDtlsauth2" class="startofrange">
54438 <primary>authenticators</primary>
54439 <secondary><command>tls</command></secondary>
54440 </indexterm>
54441 <indexterm role="concept">
54442 <primary>authentication</primary>
54443 <secondary>Client Certificate</secondary>
54444 </indexterm>
54445 <indexterm role="concept">
54446 <primary>authentication</primary>
54447 <secondary>X509</secondary>
54448 </indexterm>
54449 <indexterm role="concept">
54450 <primary>Certificate-based authentication</primary>
54451 </indexterm>
54452 The <command>tls</command> authenticator provides server support for
54453 authentication based on client certificates.
54454 </para>
54455 <para>
54456 It is not an SMTP authentication mechanism and is not
54457 advertised by the server as part of the SMTP EHLO response.
54458 It is an Exim authenticator in the sense that it affects
54459 the protocol element of the log line, can be tested for
54460 by the <option>authenticated</option> ACL condition, and can set
54461 the <varname>$authenticated_id</varname> variable.
54462 </para>
54463 <para>
54464 The client must present a verifiable certificate,
54465 for which it must have been requested via the
54466 <option>tls_verify_hosts</option> or <option>tls_try_verify_hosts</option> main options
54467 (see <xref linkend="CHAPTLS"/>).
54468 </para>
54469 <para>
54470 If an authenticator of this type is configured it is
54471 run before any SMTP-level communication is done,
54472 and can authenticate the connection.
54473 If it does, SMTP authentication is not offered.
54474 </para>
54475 <para>
54476 A maximum of one authenticator of this type may be present.
54477 </para>
54478 <para>
54479 <indexterm role="concept">
54480 <primary>options</primary>
54481 <secondary><command>tls</command> authenticator (server)</secondary>
54482 </indexterm>
54483 The <command>tls</command> authenticator has three server options:
54484 </para>
54485 <para>
54486 <indexterm role="option">
54487 <primary><option>server_param1</option></primary>
54488 </indexterm>
54489 </para>
54490 <informaltable frame="all">
54491 <tgroup cols="4" colsep="0" rowsep="0">
54492 <colspec colwidth="8*" align="left"/>
54493 <colspec colwidth="6*" align="center"/>
54494 <colspec colwidth="6*" align="center"/>
54495 <colspec colwidth="6*" align="right"/>
54496 <tbody>
54497 <row>
54498 <entry><option>server_param1</option></entry>
54499 <entry>Use: <emphasis>tls</emphasis></entry>
54500 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
54501 <entry>Default: <emphasis>unset</emphasis></entry>
54502 </row>
54503 </tbody>
54504 </tgroup>
54505 </informaltable>
54506 <para>
54507 <indexterm role="concept">
54508 <primary>variables (<varname>$auth1</varname> <varname>$auth2</varname> etc)</primary>
54509 <secondary>in <command>tls</command> authenticator</secondary>
54510 </indexterm>
54511 This option is expanded after the TLS negotiation and
54512 the result is placed in <varname>$auth1</varname>.
54513 If the expansion is forced to fail, authentication fails. Any other expansion
54514 failure causes a temporary error code to be returned.
54515 </para>
54516 <para>
54517 <indexterm role="option">
54518 <primary><option>server_param2</option></primary>
54519 </indexterm>
54520 </para>
54521 <informaltable frame="all">
54522 <tgroup cols="4" colsep="0" rowsep="0">
54523 <colspec colwidth="8*" align="left"/>
54524 <colspec colwidth="6*" align="center"/>
54525 <colspec colwidth="6*" align="center"/>
54526 <colspec colwidth="6*" align="right"/>
54527 <tbody>
54528 <row>
54529 <entry><option>server_param2</option></entry>
54530 <entry>Use: <emphasis>tls</emphasis></entry>
54531 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
54532 <entry>Default: <emphasis>unset</emphasis></entry>
54533 </row>
54534 </tbody>
54535 </tgroup>
54536 </informaltable>
54537 <para>
54538 <indexterm role="option">
54539 <primary><option>server_param3</option></primary>
54540 </indexterm>
54541 </para>
54542 <informaltable frame="all">
54543 <tgroup cols="4" colsep="0" rowsep="0">
54544 <colspec colwidth="8*" align="left"/>
54545 <colspec colwidth="6*" align="center"/>
54546 <colspec colwidth="6*" align="center"/>
54547 <colspec colwidth="6*" align="right"/>
54548 <tbody>
54549 <row>
54550 <entry><option>server_param3</option></entry>
54551 <entry>Use: <emphasis>tls</emphasis></entry>
54552 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
54553 <entry>Default: <emphasis>unset</emphasis></entry>
54554 </row>
54555 </tbody>
54556 </tgroup>
54557 </informaltable>
54558 <para>
54559 As above, for <varname>$auth2</varname> and <varname>$auth3</varname>.
54560 </para>
54561 <para>
54562 <option>server_param1</option> may also be spelled <option>server_param</option>.
54563 </para>
54564 <para>
54565 Example:
54566 </para>
54567 <literallayout class="monospaced">
54568 tls:
54569   driver = tls
54570   server_param1 =     ${certextract {subj_altname,mail,&gt;:} \
54571                                     {$tls_in_peercert}}
54572   server_condition =  ${if and { {eq{$tls_in_certificate_verified}{1}} \
54573                                  {forany {$auth1} \
54574                             {!= {0} \
54575                                 {${lookup ldap{ldap:///\
54576                          mailname=${quote_ldap_dn:${lc:$item}},\
54577                          ou=users,LDAP_DC?mailid} {$value}{0} \
54578                        }    }  } }}}
54579   server_set_id =     ${if = {1}{${listcount:$auth1}} {$auth1}{}}
54580 </literallayout>
54581 <para>
54582 This accepts a client certificate that is verifiable against any
54583 of your configured trust-anchors
54584 (which usually means the full set of public CAs)
54585 and which has a SAN with a good account name.
54586 </para>
54587 <para>
54588 Note that, up to TLS1.2, the client cert is on the wire in-clear, including the SAN,
54589 The account name is therefore guessable by an opponent.
54590 TLS 1.3 protects both server and client certificates, and is not vulnerable
54591 in this way.
54592 Likewise, a traditional plaintext SMTP AUTH done inside TLS is not.
54593 </para>
54594 <para>
54595 <indexterm role="concept" startref="IIDtlsauth1" class="endofrange"/>
54596 <indexterm role="concept" startref="IIDtlsauth2" class="endofrange"/>
54597 </para>
54598 <para>
54599 Note that because authentication is traditionally an SMTP operation,
54600 the <option>authenticated</option> ACL condition cannot be used in
54601 a connect- or helo-ACL.
54602 </para>
54603 </chapter>
54604
54605 <chapter id="CHAPTLS">
54606 <title>Encrypted SMTP connections using TLS/SSL</title>
54607 <titleabbrev>Encrypted SMTP connections</titleabbrev>
54608 <para>
54609 <indexterm role="concept" id="IIDencsmtp1" class="startofrange">
54610 <primary>encryption</primary>
54611 <secondary>on SMTP connection</secondary>
54612 </indexterm>
54613 <indexterm role="concept" id="IIDencsmtp2" class="startofrange">
54614 <primary>SMTP</primary>
54615 <secondary>encryption</secondary>
54616 </indexterm>
54617 <indexterm role="concept">
54618 <primary>TLS</primary>
54619 <secondary>on SMTP connection</secondary>
54620 </indexterm>
54621 <indexterm role="concept">
54622 <primary>OpenSSL</primary>
54623 </indexterm>
54624 <indexterm role="concept">
54625 <primary>GnuTLS</primary>
54626 </indexterm>
54627 Support for TLS (Transport Layer Security), formerly known as SSL (Secure
54628 Sockets Layer), is implemented by making use of the OpenSSL library or the
54629 GnuTLS library (Exim requires GnuTLS release 1.0 or later). There is no
54630 cryptographic code in the Exim distribution itself for implementing TLS. In
54631 order to use this feature you must install OpenSSL or GnuTLS, and then build a
54632 version of Exim that includes TLS support (see section <xref linkend="SECTinctlsssl"/>).
54633 You also need to understand the basic concepts of encryption at a managerial
54634 level, and in particular, the way that public keys, private keys, and
54635 certificates are used.
54636 </para>
54637 <para>
54638 RFC 3207 defines how SMTP connections can make use of encryption. Once a
54639 connection is established, the client issues a STARTTLS command. If the
54640 server accepts this, the client and the server negotiate an encryption
54641 mechanism. If the negotiation succeeds, the data that subsequently passes
54642 between them is encrypted.
54643 </para>
54644 <para>
54645 Exim&#x2019;s ACLs can detect whether the current SMTP session is encrypted or not,
54646 and if so, what cipher suite is in use, whether the client supplied a
54647 certificate, and whether or not that certificate was verified. This makes it
54648 possible for an Exim server to deny or accept certain commands based on the
54649 encryption state.
54650 </para>
54651 <para>
54652 <emphasis role="bold">Warning</emphasis>: Certain types of firewall and certain anti-virus products can
54653 disrupt TLS connections. You need to turn off SMTP scanning for these products
54654 in order to get TLS to work.
54655 </para>
54656 <section id="SECID284">
54657 <title>Support for the <quote>submissions</quote> (aka <quote>ssmtp</quote> and <quote>smtps</quote>) protocol</title>
54658 <para>
54659 <indexterm role="concept">
54660 <primary>submissions protocol</primary>
54661 </indexterm>
54662 <indexterm role="concept">
54663 <primary>ssmtp protocol</primary>
54664 </indexterm>
54665 <indexterm role="concept">
54666 <primary>smtps protocol</primary>
54667 </indexterm>
54668 <indexterm role="concept">
54669 <primary>SMTP</primary>
54670 <secondary>submissions protocol</secondary>
54671 </indexterm>
54672 <indexterm role="concept">
54673 <primary>SMTP</primary>
54674 <secondary>ssmtp protocol</secondary>
54675 </indexterm>
54676 <indexterm role="concept">
54677 <primary>SMTP</primary>
54678 <secondary>smtps protocol</secondary>
54679 </indexterm>
54680 The history of port numbers for TLS in SMTP is a little messy and has been
54681 contentious.  As of RFC 8314, the common practice of using the historically
54682 allocated port 465 for "email submission but with TLS immediately upon connect
54683 instead of using STARTTLS" is officially blessed by the IETF, and recommended
54684 by them in preference to STARTTLS.
54685 </para>
54686 <para>
54687 The name originally assigned to the port was <quote>ssmtp</quote> or <quote>smtps</quote>, but as
54688 clarity emerged over the dual roles of SMTP, for MX delivery and Email
54689 Submission, nomenclature has shifted.  The modern name is now <quote>submissions</quote>.
54690 </para>
54691 <para>
54692 This approach was, for a while, officially abandoned when encrypted SMTP was
54693 standardized, but many clients kept using it, even as the TCP port number was
54694 reassigned for other use.
54695 Thus you may encounter guidance claiming that you shouldn&#x2019;t enable use of
54696 this port.
54697 In practice, a number of mail-clients have only ever supported submissions,
54698 not submission with STARTTLS upgrade.
54699 Ideally, offer both submission (587) and submissions (465) service.
54700 </para>
54701 <para>
54702 Exim supports TLS-on-connect by means of the <option>tls_on_connect_ports</option>
54703 global option. Its value must be a list of port numbers;
54704 the most common use is expected to be:
54705 </para>
54706 <literallayout class="monospaced">
54707 tls_on_connect_ports = 465
54708 </literallayout>
54709 <para>
54710 The port numbers specified by this option apply to all SMTP connections, both
54711 via the daemon and via <emphasis>inetd</emphasis>. You still need to specify all the ports that
54712 the daemon uses (by setting <option>daemon_smtp_ports</option> or <option>local_interfaces</option> or
54713 the <option>-oX</option> command line option) because <option>tls_on_connect_ports</option> does not add
54714 an extra port &ndash; rather, it specifies different behaviour on a port that is
54715 defined elsewhere.
54716 </para>
54717 <para>
54718 There is also a <option>-tls-on-connect</option> command line option. This overrides
54719 <option>tls_on_connect_ports</option>; it forces the TLS-only behaviour for all ports.
54720 </para>
54721 </section>
54722 <section id="SECTopenvsgnu">
54723 <title>OpenSSL vs GnuTLS</title>
54724 <para>
54725 <indexterm role="concept">
54726 <primary>TLS</primary>
54727 <secondary>OpenSSL <emphasis>vs</emphasis> GnuTLS</secondary>
54728 </indexterm>
54729 TLS is supported in Exim using either the OpenSSL or GnuTLS library.
54730 </para>
54731 <para revisionflag="changed">
54732 To build Exim to use OpenSSL you need to set
54733 </para>
54734 <literallayout class="monospaced" revisionflag="changed">
54735 USE_OPENSSL=yes
54736 </literallayout>
54737 <para revisionflag="changed">
54738 in Local/Makefile.
54739 </para>
54740 <para>
54741 To build Exim to use GnuTLS, you need to set
54742 </para>
54743 <literallayout class="monospaced">
54744 USE_GNUTLS=yes
54745 </literallayout>
54746 <para>
54747 in Local/Makefile.
54748 </para>
54749 <para>
54750 You must also set TLS_LIBS and TLS_INCLUDE appropriately, so that the
54751 include files and libraries for GnuTLS can be found.
54752 </para>
54753 <para>
54754 There are some differences in usage when using GnuTLS instead of OpenSSL:
54755 </para>
54756 <itemizedlist>
54757 <listitem>
54758 <para>
54759 The <option>tls_verify_certificates</option> option
54760 cannot be the path of a directory
54761 for GnuTLS versions before 3.3.6
54762 (for later versions, or OpenSSL, it can be either).
54763 </para>
54764 </listitem>
54765 <listitem>
54766 <para>
54767 The default value for <option>tls_dhparam</option> differs for historical reasons.
54768 </para>
54769 </listitem>
54770 <listitem>
54771 <para>
54772 <indexterm role="variable">
54773 <primary><varname>$tls_in_peerdn</varname></primary>
54774 </indexterm>
54775 <indexterm role="variable">
54776 <primary><varname>$tls_out_peerdn</varname></primary>
54777 </indexterm>
54778 Distinguished Name (DN) strings reported by the OpenSSL library use a slash for
54779 separating fields; GnuTLS uses commas, in accordance with RFC 2253. This
54780 affects the value of the <varname>$tls_in_peerdn</varname> and <varname>$tls_out_peerdn</varname> variables.
54781 </para>
54782 </listitem>
54783 <listitem>
54784 <para>
54785 OpenSSL identifies cipher suites using hyphens as separators, for example:
54786 DES-CBC3-SHA. GnuTLS historically used underscores, for example:
54787 RSA_ARCFOUR_SHA. What is more, OpenSSL complains if underscores are present
54788 in a cipher list. To make life simpler, Exim changes underscores to hyphens
54789 for OpenSSL and passes the string unchanged to GnuTLS (expecting the library
54790 to handle its own older variants) when processing lists of cipher suites in the
54791 <option>tls_require_ciphers</option> options (the global option and the <command>smtp</command> transport
54792 option).
54793 </para>
54794 </listitem>
54795 <listitem>
54796 <para>
54797 The <option>tls_require_ciphers</option> options operate differently, as described in the
54798 sections <xref linkend="SECTreqciphssl"/> and <xref linkend="SECTreqciphgnu"/>.
54799 </para>
54800 </listitem>
54801 <listitem>
54802 <para>
54803 The <option>tls_dh_min_bits</option> SMTP transport option is only honoured by GnuTLS.
54804 When using OpenSSL, this option is ignored.
54805 (If an API is found to let OpenSSL be configured in this way,
54806 let the Exim Maintainers know and we&#x2019;ll likely use it).
54807 </para>
54808 </listitem>
54809 <listitem>
54810 <para>
54811 With GnuTLS, if an explicit list is used for the <option>tls_privatekey</option> main option
54812 main option, it must be ordered to match the <option>tls_certificate</option> list.
54813 </para>
54814 </listitem>
54815 <listitem>
54816 <para>
54817 Some other recently added features may only be available in one or the other.
54818 This should be documented with the feature.  If the documentation does not
54819 explicitly state that the feature is infeasible in the other TLS
54820 implementation, then patches are welcome.
54821 </para>
54822 </listitem>
54823 </itemizedlist>
54824 </section>
54825 <section id="SECTgnutlsparam">
54826 <title>GnuTLS parameter computation</title>
54827 <para>
54828 This section only applies if <option>tls_dhparam</option> is set to <literal>historic</literal> or to
54829 an explicit path; if the latter, then the text about generation still applies,
54830 but not the chosen filename.
54831 By default, as of Exim 4.80 a hard-coded D-H prime is used.
54832 See the documentation of <option>tls_dhparam</option> for more information.
54833 </para>
54834 <para>
54835 GnuTLS uses D-H parameters that may take a substantial amount of time
54836 to compute. It is unreasonable to re-compute them for every TLS session.
54837 Therefore, Exim keeps this data in a file in its spool directory, called
54838 <filename>gnutls-params-NNNN</filename> for some value of NNNN, corresponding to the number
54839 of bits requested.
54840 The file is owned by the Exim user and is readable only by
54841 its owner. Every Exim process that start up GnuTLS reads the D-H
54842 parameters from this file. If the file does not exist, the first Exim process
54843 that needs it computes the data and writes it to a temporary file which is
54844 renamed once it is complete. It does not matter if several Exim processes do
54845 this simultaneously (apart from wasting a few resources). Once a file is in
54846 place, new Exim processes immediately start using it.
54847 </para>
54848 <para>
54849 For maximum security, the parameters that are stored in this file should be
54850 recalculated periodically, the frequency depending on your paranoia level.
54851 If you are avoiding using the fixed D-H primes published in RFCs, then you
54852 are concerned about some advanced attacks and will wish to do this; if you do
54853 not regenerate then you might as well stick to the standard primes.
54854 </para>
54855 <para>
54856 Arranging this is easy in principle; just delete the file when you want new
54857 values to be computed. However, there may be a problem. The calculation of new
54858 parameters needs random numbers, and these are obtained from <filename>/dev/random</filename>.
54859 If the system is not very active, <filename>/dev/random</filename> may delay returning data
54860 until enough randomness (entropy) is available. This may cause Exim to hang for
54861 a substantial amount of time, causing timeouts on incoming connections.
54862 </para>
54863 <para>
54864 The solution is to generate the parameters externally to Exim. They are stored
54865 in <filename>gnutls-params-N</filename> in PEM format, which means that they can be
54866 generated externally using the <command>certtool</command> command that is part of GnuTLS.
54867 </para>
54868 <para>
54869 To replace the parameters with new ones, instead of deleting the file
54870 and letting Exim re-create it, you can generate new parameters using
54871 <command>certtool</command> and, when this has been done, replace Exim&#x2019;s cache file by
54872 renaming. The relevant commands are something like this:
54873 </para>
54874 <literallayout class="monospaced">
54875 # ls
54876 [ look for file; assume gnutls-params-2236 is the most recent ]
54877 # rm -f new-params
54878 # touch new-params
54879 # chown exim:exim new-params
54880 # chmod 0600 new-params
54881 # certtool --generate-dh-params --bits 2236 &gt;&gt;new-params
54882 # openssl dhparam -noout -text -in new-params | head
54883 [ check the first line, make sure it's not more than 2236;
54884   if it is, then go back to the start ("rm") and repeat
54885   until the size generated is at most the size requested ]
54886 # chmod 0400 new-params
54887 # mv new-params gnutls-params-2236
54888 </literallayout>
54889 <para>
54890 If Exim never has to generate the parameters itself, the possibility of
54891 stalling is removed.
54892 </para>
54893 <para>
54894 The filename changed in Exim 4.80, to gain the -bits suffix.  The value which
54895 Exim will choose depends upon the version of GnuTLS in use.  For older GnuTLS,
54896 the value remains hard-coded in Exim as 1024.  As of GnuTLS 2.12.x, there is
54897 a way for Exim to ask for the "normal" number of bits for D-H public-key usage,
54898 and Exim does so.  This attempt to remove Exim from TLS policy decisions
54899 failed, as GnuTLS 2.12 returns a value higher than the current hard-coded limit
54900 of the NSS library.  Thus Exim gains the <option>tls_dh_max_bits</option> global option,
54901 which applies to all D-H usage, client or server.  If the value returned by
54902 GnuTLS is greater than <option>tls_dh_max_bits</option> then the value will be clamped down
54903 to <option>tls_dh_max_bits</option>.  The default value has been set at the current NSS
54904 limit, which is still much higher than Exim historically used.
54905 </para>
54906 <para>
54907 The filename and bits used will change as the GnuTLS maintainers change the
54908 value for their parameter <literal>GNUTLS_SEC_PARAM_NORMAL</literal>, as clamped by
54909 <option>tls_dh_max_bits</option>.  At the time of writing (mid 2012), GnuTLS 2.12 recommends
54910 2432 bits, while NSS is limited to 2236 bits.
54911 </para>
54912 <para>
54913 In fact, the requested value will be *lower* than <option>tls_dh_max_bits</option>, to
54914 increase the chance of the generated prime actually being within acceptable
54915 bounds, as GnuTLS has been observed to overshoot.  Note the check step in the
54916 procedure above.  There is no sane procedure available to Exim to double-check
54917 the size of the generated prime, so it might still be too large.
54918 </para>
54919 </section>
54920 <section id="SECTreqciphssl">
54921 <title>Requiring specific ciphers in OpenSSL</title>
54922 <para>
54923 <indexterm role="concept">
54924 <primary>TLS</primary>
54925 <secondary>requiring specific ciphers (OpenSSL)</secondary>
54926 </indexterm>
54927 <indexterm role="option">
54928 <primary><option>tls_require_ciphers</option></primary>
54929 <secondary>OpenSSL</secondary>
54930 </indexterm>
54931 There is a function in the OpenSSL library that can be passed a list of cipher
54932 suites before the cipher negotiation takes place. This specifies which ciphers
54933 are acceptable for TLS versions prior to 1.3.
54934 The list is colon separated and may contain names like
54935 DES-CBC3-SHA. Exim passes the expanded value of <option>tls_require_ciphers</option>
54936 directly to this function call.
54937 Many systems will install the OpenSSL manual-pages, so you may have
54938 <emphasis>ciphers(1)</emphasis> available to you.
54939 The following quotation from the OpenSSL
54940 documentation specifies what forms of item are allowed in the cipher string:
54941 </para>
54942 <itemizedlist>
54943 <listitem>
54944 <para>
54945 It can consist of a single cipher suite such as RC4-SHA.
54946 </para>
54947 </listitem>
54948 <listitem>
54949 <para>
54950 It can represent a list of cipher suites containing a certain algorithm,
54951 or cipher suites of a certain type. For example SHA1 represents all
54952 ciphers suites using the digest algorithm SHA1 and SSLv3 represents all
54953 SSL v3 algorithms.
54954 </para>
54955 </listitem>
54956 <listitem>
54957 <para>
54958 Lists of cipher suites can be combined in a single cipher string using
54959 the + character. This is used as a logical and operation. For example
54960 SHA1+DES represents all cipher suites containing the SHA1 and the DES
54961 algorithms.
54962 </para>
54963 </listitem>
54964 </itemizedlist>
54965 <para>
54966 Each cipher string can be optionally preceded by one of the characters <literal>!</literal>,
54967 <literal>-</literal> or <literal>+</literal>.
54968 </para>
54969 <itemizedlist>
54970 <listitem>
54971 <para>
54972 If <literal>!</literal> is used, the ciphers are permanently deleted from the list. The
54973 ciphers deleted can never reappear in the list even if they are explicitly
54974 stated.
54975 </para>
54976 </listitem>
54977 <listitem>
54978 <para>
54979 If <literal>-</literal> is used, the ciphers are deleted from the list, but some or all
54980 of the ciphers can be added again by later options.
54981 </para>
54982 </listitem>
54983 <listitem>
54984 <para>
54985 If <literal>+</literal> is used, the ciphers are moved to the end of the list. This
54986 option does not add any new ciphers; it just moves matching existing ones.
54987 </para>
54988 </listitem>
54989 </itemizedlist>
54990 <para>
54991 If none of these characters is present, the string is interpreted as
54992 a list of ciphers to be appended to the current preference list. If the list
54993 includes any ciphers already present they will be ignored: that is, they will
54994 not be moved to the end of the list.
54995 </para>
54996 <para>
54997 The OpenSSL <emphasis>ciphers(1)</emphasis> command may be used to test the results of a given
54998 string:
54999 </para>
55000 <literallayout class="monospaced">
55001 # note single-quotes to get ! past any shell history expansion
55002 $ openssl ciphers 'HIGH:!MD5:!SHA1'
55003 </literallayout>
55004 <para>
55005 This example will let the library defaults be permitted on the MX port, where
55006 there&#x2019;s probably no identity verification anyway, but ups the ante on the
55007 submission ports where the administrator might have some influence on the
55008 choice of clients used:
55009 </para>
55010 <literallayout class="monospaced">
55011 # OpenSSL variant; see man ciphers(1)
55012 tls_require_ciphers = ${if =={$received_port}{25}\
55013                            {DEFAULT}\
55014                            {HIGH:!MD5:!SHA1}}
55015 </literallayout>
55016 <para>
55017 This example will prefer ECDSA-authenticated ciphers over RSA ones:
55018 </para>
55019 <literallayout class="monospaced">
55020 tls_require_ciphers = ECDSA:RSA:!COMPLEMENTOFDEFAULT
55021 </literallayout>
55022 <para>
55023 For TLS version 1.3 the control available is less fine-grained
55024 and Exim does not provide access to it at present.
55025 The value of the <option>tls_require_ciphers</option> option is ignored when
55026 TLS version 1.3 is negotiated.
55027 </para>
55028 <para>
55029 As of writing the library default cipher suite list for TLSv1.3 is
55030 </para>
55031 <literallayout class="monospaced">
55032 TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256
55033 </literallayout>
55034 </section>
55035 <section id="SECTreqciphgnu">
55036 <title>Requiring specific ciphers or other parameters in GnuTLS</title>
55037 <para>
55038 <indexterm role="concept">
55039 <primary>GnuTLS</primary>
55040 <secondary>specifying parameters for</secondary>
55041 </indexterm>
55042 <indexterm role="concept">
55043 <primary>TLS</primary>
55044 <secondary>specifying ciphers (GnuTLS)</secondary>
55045 </indexterm>
55046 <indexterm role="concept">
55047 <primary>TLS</primary>
55048 <secondary>specifying key exchange methods (GnuTLS)</secondary>
55049 </indexterm>
55050 <indexterm role="concept">
55051 <primary>TLS</primary>
55052 <secondary>specifying MAC algorithms (GnuTLS)</secondary>
55053 </indexterm>
55054 <indexterm role="concept">
55055 <primary>TLS</primary>
55056 <secondary>specifying protocols (GnuTLS)</secondary>
55057 </indexterm>
55058 <indexterm role="concept">
55059 <primary>TLS</primary>
55060 <secondary>specifying priority string (GnuTLS)</secondary>
55061 </indexterm>
55062 <indexterm role="option">
55063 <primary><option>tls_require_ciphers</option></primary>
55064 <secondary>GnuTLS</secondary>
55065 </indexterm>
55066 The GnuTLS library allows the caller to provide a "priority string", documented
55067 as part of the <function>gnutls_priority_init</function> function.  This is very similar to the
55068 ciphersuite specification in OpenSSL.
55069 </para>
55070 <para>
55071 The <option>tls_require_ciphers</option> option is treated as the GnuTLS priority string
55072 and controls both protocols and ciphers.
55073 </para>
55074 <para>
55075 The <option>tls_require_ciphers</option> option is available both as an global option,
55076 controlling how Exim behaves as a server, and also as an option of the
55077 <command>smtp</command> transport, controlling how Exim behaves as a client.  In both cases
55078 the value is string expanded.  The resulting string is not an Exim list and
55079 the string is given to the GnuTLS library, so that Exim does not need to be
55080 aware of future feature enhancements of GnuTLS.
55081 </para>
55082 <para>
55083 Documentation of the strings accepted may be found in the GnuTLS manual, under
55084 "Priority strings".  This is online as
55085 <emphasis role="bold"><ulink url="https://www.gnutls.org/manual/html_node/Priority-Strings.html">https://www.gnutls.org/manual/html_node/Priority-Strings.html</ulink></emphasis>,
55086 but beware that this relates to GnuTLS 3, which may be newer than the version
55087 installed on your system.  If you are using GnuTLS 3,
55088 then the example code
55089 <emphasis role="bold"><ulink url="https://www.gnutls.org/manual/gnutls.html#Listing-the-ciphersuites-in-a-priority-string">https://www.gnutls.org/manual/gnutls.html#Listing-the-ciphersuites-in-a-priority-string</ulink></emphasis>
55090 on that site can be used to test a given string.
55091 </para>
55092 <para>
55093 For example:
55094 </para>
55095 <literallayout class="monospaced">
55096 # Disable older versions of protocols
55097 tls_require_ciphers = NORMAL:%LATEST_RECORD_VERSION:-VERS-SSL3.0
55098 </literallayout>
55099 <para>
55100 Prior to Exim 4.80, an older API of GnuTLS was used, and Exim supported three
55101 additional options, "<option>gnutls_require_kx</option>", "<option>gnutls_require_mac</option>" and
55102 "<option>gnutls_require_protocols</option>".  <option>tls_require_ciphers</option> was an Exim list.
55103 </para>
55104 <para>
55105 This example will let the library defaults be permitted on the MX port, where
55106 there&#x2019;s probably no identity verification anyway, and lowers security further
55107 by increasing compatibility; but this ups the ante on the submission ports
55108 where the administrator might have some influence on the choice of clients
55109 used:
55110 </para>
55111 <literallayout class="monospaced">
55112 # GnuTLS variant
55113 tls_require_ciphers = ${if =={$received_port}{25}\
55114                            {NORMAL:%COMPAT}\
55115                            {SECURE128}}
55116 </literallayout>
55117 </section>
55118 <section id="SECID182">
55119 <title>Configuring an Exim server to use TLS</title>
55120 <para>
55121 <indexterm role="concept">
55122 <primary>TLS</primary>
55123 <secondary>configuring an Exim server</secondary>
55124 </indexterm>
55125 When Exim has been built with TLS support, it advertises the availability of
55126 the STARTTLS command to client hosts that match <option>tls_advertise_hosts</option>,
55127 but not to any others. The default value of this option is *, which means
55128 that STARTTLS is always advertised.  Set it to blank to never advertise;
55129 this is reasonable for systems that want to use TLS only as a client.
55130 </para>
55131 <para>
55132 If STARTTLS is to be used you
55133 need to set some other options in order to make TLS available.
55134 </para>
55135 <para>
55136 If a client issues a STARTTLS command and there is some configuration
55137 problem in the server, the command is rejected with a 454 error. If the client
55138 persists in trying to issue SMTP commands, all except QUIT are rejected
55139 with the error
55140 </para>
55141 <literallayout class="monospaced">
55142 554 Security failure
55143 </literallayout>
55144 <para>
55145 If a STARTTLS command is issued within an existing TLS session, it is
55146 rejected with a 554 error code.
55147 </para>
55148 <para>
55149 To enable TLS operations on a server, the <option>tls_advertise_hosts</option> option
55150 must be set to match some hosts. The default is * which matches all hosts.
55151 </para>
55152 <para>
55153 If this is all you do, TLS encryption will be enabled but not authentication -
55154 meaning that the peer has no assurance it is actually you he is talking to.
55155 You gain protection from a passive sniffer listening on the wire but not
55156 from someone able to intercept the communication.
55157 </para>
55158 <para>
55159 Further protection requires some further configuration at the server end.
55160 </para>
55161 <para>
55162 To make TLS work you need to set, in the server,
55163 </para>
55164 <literallayout class="monospaced">
55165 tls_certificate = /some/file/name
55166 tls_privatekey = /some/file/name
55167 </literallayout>
55168 <para>
55169 These options are, in fact, expanded strings, so you can make them depend on
55170 the identity of the client that is connected if you wish. The first file
55171 contains the server&#x2019;s X509 certificate, and the second contains the private key
55172 that goes with it. These files need to be
55173 PEM format and readable by the Exim user, and must
55174 always be given as full path names.
55175 The key must not be password-protected.
55176 They can be the same file if both the
55177 certificate and the key are contained within it. If <option>tls_privatekey</option> is not
55178 set, or if its expansion is forced to fail or results in an empty string, this
55179 is assumed to be the case. The certificate file may also contain intermediate
55180 certificates that need to be sent to the client to enable it to authenticate
55181 the server&#x2019;s certificate.
55182 </para>
55183 <para>
55184 For dual-stack (eg. RSA and ECDSA) configurations, these options can be
55185 colon-separated lists of file paths.  Ciphers using given authentication
55186 algorithms require the presence of a suitable certificate to supply the
55187 public-key.  The server selects among the certificates to present to the
55188 client depending on the selected cipher, hence the priority ordering for
55189 ciphers will affect which certificate is used.
55190 </para>
55191 <para>
55192 If you do not understand about certificates and keys, please try to find a
55193 source of this background information, which is not Exim-specific. (There are a
55194 few comments below in section <xref linkend="SECTcerandall"/>.)
55195 </para>
55196 <para>
55197 <emphasis role="bold">Note</emphasis>: These options do not apply when Exim is operating as a client &ndash;
55198 they apply only in the case of a server. If you need to use a certificate in an
55199 Exim client, you must set the options of the same names in an <command>smtp</command>
55200 transport.
55201 </para>
55202 <para>
55203 With just these options, an Exim server will be able to use TLS. It does not
55204 require the client to have a certificate (but see below for how to insist on
55205 this). There is one other option that may be needed in other situations. If
55206 </para>
55207 <literallayout class="monospaced">
55208 tls_dhparam = /some/file/name
55209 </literallayout>
55210 <para>
55211 is set, the SSL library is initialized for the use of Diffie-Hellman ciphers
55212 with the parameters contained in the file.
55213 Set this to <literal>none</literal> to disable use of DH entirely, by making no prime
55214 available:
55215 </para>
55216 <literallayout class="monospaced">
55217 tls_dhparam = none
55218 </literallayout>
55219 <para>
55220 This may also be set to a string identifying a standard prime to be used for
55221 DH; if it is set to <literal>default</literal> or, for OpenSSL, is unset, then the prime
55222 used is <literal>ike23</literal>.  There are a few standard primes available, see the
55223 documentation for <option>tls_dhparam</option> for the complete list.
55224 </para>
55225 <para>
55226 See the command
55227 </para>
55228 <literallayout class="monospaced">
55229 openssl dhparam
55230 </literallayout>
55231 <para>
55232 for a way of generating file data.
55233 </para>
55234 <para>
55235 The strings supplied for these three options are expanded every time a client
55236 host connects. It is therefore possible to use different certificates and keys
55237 for different hosts, if you so wish, by making use of the client&#x2019;s IP address
55238 in <varname>$sender_host_address</varname> to control the expansion. If a string expansion is
55239 forced to fail, Exim behaves as if the option is not set.
55240 </para>
55241 <para>
55242 <indexterm role="concept">
55243 <primary>cipher</primary>
55244 <secondary>logging</secondary>
55245 </indexterm>
55246 <indexterm role="concept">
55247 <primary>log</primary>
55248 <secondary>TLS cipher</secondary>
55249 </indexterm>
55250 <indexterm role="variable">
55251 <primary><varname>$tls_in_cipher</varname></primary>
55252 </indexterm>
55253 The variable <varname>$tls_in_cipher</varname> is set to the cipher suite that was negotiated for
55254 an incoming TLS connection. It is included in the <emphasis>Received:</emphasis> header of an
55255 incoming message (by default &ndash; you can, of course, change this), and it is
55256 also included in the log line that records a message&#x2019;s arrival, keyed by
55257 <quote>X=</quote>, unless the <option>tls_cipher</option> log selector is turned off. The <option>encrypted</option>
55258 condition can be used to test for specific cipher suites in ACLs.
55259 </para>
55260 <para>
55261 Once TLS has been established, the ACLs that run for subsequent SMTP commands
55262 can check the name of the cipher suite and vary their actions accordingly. The
55263 cipher suite names vary, depending on which TLS library is being used. For
55264 example, OpenSSL uses the name DES-CBC3-SHA for the cipher suite which in other
55265 contexts is known as TLS_RSA_WITH_3DES_EDE_CBC_SHA. Check the OpenSSL or GnuTLS
55266 documentation for more details.
55267 </para>
55268 <para>
55269 For outgoing SMTP deliveries, <varname>$tls_out_cipher</varname> is used and logged
55270 (again depending on the <option>tls_cipher</option> log selector).
55271 </para>
55272 </section>
55273 <section id="SECID183">
55274 <title>Requesting and verifying client certificates</title>
55275 <para>
55276 <indexterm role="concept">
55277 <primary>certificate</primary>
55278 <secondary>verification of client</secondary>
55279 </indexterm>
55280 <indexterm role="concept">
55281 <primary>TLS</primary>
55282 <secondary>client certificate verification</secondary>
55283 </indexterm>
55284 If you want an Exim server to request a certificate when negotiating a TLS
55285 session with a client, you must set either <option>tls_verify_hosts</option> or
55286 <option>tls_try_verify_hosts</option>. You can, of course, set either of them to * to
55287 apply to all TLS connections. For any host that matches one of these options,
55288 Exim requests a certificate as part of the setup of the TLS session. The
55289 contents of the certificate are verified by comparing it with a list of
55290 expected trust-anchors or certificates.
55291 These may be the system default set (depending on library version),
55292 an explicit file or,
55293 depending on library version, a directory, identified by
55294 <option>tls_verify_certificates</option>.
55295 </para>
55296 <para>
55297 A file can contain multiple certificates, concatenated end to end. If a
55298 directory is used
55299 (OpenSSL only),
55300 each certificate must be in a separate file, with a name (or a symbolic link)
55301 of the form &lt;<emphasis>hash</emphasis>&gt;.0, where &lt;<emphasis>hash</emphasis>&gt; is a hash value constructed from the
55302 certificate. You can compute the relevant hash by running the command
55303 </para>
55304 <literallayout class="monospaced">
55305 openssl x509 -hash -noout -in /cert/file
55306 </literallayout>
55307 <para>
55308 where <filename>/cert/file</filename> contains a single certificate.
55309 </para>
55310 <para>
55311 There is no checking of names of the client against the certificate
55312 Subject Name or Subject Alternate Names.
55313 </para>
55314 <para>
55315 The difference between <option>tls_verify_hosts</option> and <option>tls_try_verify_hosts</option> is
55316 what happens if the client does not supply a certificate, or if the certificate
55317 does not match any of the certificates in the collection named by
55318 <option>tls_verify_certificates</option>. If the client matches <option>tls_verify_hosts</option>, the
55319 attempt to set up a TLS session is aborted, and the incoming connection is
55320 dropped. If the client matches <option>tls_try_verify_hosts</option>, the (encrypted) SMTP
55321 session continues. ACLs that run for subsequent SMTP commands can detect the
55322 fact that no certificate was verified, and vary their actions accordingly. For
55323 example, you can insist on a certificate before accepting a message for
55324 relaying, but not when the message is destined for local delivery.
55325 </para>
55326 <para>
55327 <indexterm role="variable">
55328 <primary><varname>$tls_in_peerdn</varname></primary>
55329 </indexterm>
55330 When a client supplies a certificate (whether it verifies or not), the value of
55331 the Distinguished Name of the certificate is made available in the variable
55332 <varname>$tls_in_peerdn</varname> during subsequent processing of the message.
55333 </para>
55334 <para>
55335 <indexterm role="concept">
55336 <primary>log</primary>
55337 <secondary>distinguished name</secondary>
55338 </indexterm>
55339 Because it is often a long text string, it is not included in the log line or
55340 <emphasis>Received:</emphasis> header by default. You can arrange for it to be logged, keyed by
55341 <quote>DN=</quote>, by setting the <option>tls_peerdn</option> log selector, and you can use
55342 <option>received_header_text</option> to change the <emphasis>Received:</emphasis> header. When no
55343 certificate is supplied, <varname>$tls_in_peerdn</varname> is empty.
55344 </para>
55345 </section>
55346 <section id="SECID184">
55347 <title>Revoked certificates</title>
55348 <para>
55349 <indexterm role="concept">
55350 <primary>TLS</primary>
55351 <secondary>revoked certificates</secondary>
55352 </indexterm>
55353 <indexterm role="concept">
55354 <primary>revocation list</primary>
55355 </indexterm>
55356 <indexterm role="concept">
55357 <primary>certificate</primary>
55358 <secondary>revocation list</secondary>
55359 </indexterm>
55360 <indexterm role="concept">
55361 <primary>OCSP</primary>
55362 <secondary>stapling</secondary>
55363 </indexterm>
55364 Certificate issuing authorities issue Certificate Revocation Lists (CRLs) when
55365 certificates are revoked. If you have such a list, you can pass it to an Exim
55366 server using the global option called <option>tls_crl</option> and to an Exim client using
55367 an identically named option for the <command>smtp</command> transport. In each case, the value
55368 of the option is expanded and must then be the name of a file that contains a
55369 CRL in PEM format.
55370 The downside is that clients have to periodically re-download a potentially huge
55371 file from every certificate authority they know of.
55372 </para>
55373 <para>
55374 The way with most moving parts at query time is Online Certificate
55375 Status Protocol (OCSP), where the client verifies the certificate
55376 against an OCSP server run by the CA.  This lets the CA track all
55377 usage of the certs.  It requires running software with access to the
55378 private key of the CA, to sign the responses to the OCSP queries.  OCSP
55379 is based on HTTP and can be proxied accordingly.
55380 </para>
55381 <para>
55382 The only widespread OCSP server implementation (known to this writer)
55383 comes as part of OpenSSL and aborts on an invalid request, such as
55384 connecting to the port and then disconnecting.  This requires
55385 re-entering the passphrase each time some random client does this.
55386 </para>
55387 <para>
55388 The third way is OCSP Stapling; in this, the server using a certificate
55389 issued by the CA periodically requests an OCSP proof of validity from
55390 the OCSP server, then serves it up inline as part of the TLS
55391 negotiation.   This approach adds no extra round trips, does not let the
55392 CA track users, scales well with number of certs issued by the CA and is
55393 resilient to temporary OCSP server failures, as long as the server
55394 starts retrying to fetch an OCSP proof some time before its current
55395 proof expires.  The downside is that it requires server support.
55396 </para>
55397 <para>
55398 Unless Exim is built with the support disabled,
55399 or with GnuTLS earlier than version 3.3.16 / 3.4.8
55400 support for OCSP stapling is included.
55401 </para>
55402 <para>
55403 There is a global option called <option>tls_ocsp_file</option>.
55404 The file specified therein is expected to be in DER format, and contain
55405 an OCSP proof.  Exim will serve it as part of the TLS handshake.  This
55406 option will be re-expanded for SNI, if the <option>tls_certificate</option> option
55407 contains <literal>tls_in_sni</literal>, as per other TLS options.
55408 </para>
55409 <para>
55410 Exim does not at this time implement any support for fetching a new OCSP
55411 proof.  The burden is on the administrator to handle this, outside of
55412 Exim.  The file specified should be replaced atomically, so that the
55413 contents are always valid.  Exim will expand the <option>tls_ocsp_file</option> option
55414 on each connection, so a new file will be handled transparently on the
55415 next connection.
55416 </para>
55417 <para>
55418 When built with OpenSSL Exim will check for a valid next update timestamp
55419 in the OCSP proof; if not present, or if the proof has expired, it will be
55420 ignored.
55421 </para>
55422 <para>
55423 For the client to be able to verify the stapled OCSP the server must
55424 also supply, in its stapled information, any intermediate
55425 certificates for the chain leading to the OCSP proof from the signer
55426 of the server certificate.  There may be zero or one such. These
55427 intermediate certificates should be added to the server OCSP stapling
55428 file named by <option>tls_ocsp_file</option>.
55429 </para>
55430 <para>
55431 Note that the proof only covers the terminal server certificate,
55432 not any of the chain from CA to it.
55433 </para>
55434 <para>
55435 There is no current way to staple a proof for a client certificate.
55436 </para>
55437 <literallayout class="monospaced">
55438   A helper script "ocsp_fetch.pl" for fetching a proof from a CA
55439   OCSP server is supplied.  The server URL may be included in the
55440   server certificate, if the CA is helpful.
55441
55442   One failure mode seen was the OCSP Signer cert expiring before the end
55443   of validity of the OCSP proof. The checking done by Exim/OpenSSL
55444   noted this as invalid overall, but the re-fetch script did not.
55445 </literallayout>
55446 </section>
55447 <section id="SECTclientTLS">
55448 <title>Configuring an Exim client to use TLS</title>
55449 <para>
55450 <indexterm role="concept">
55451 <primary>cipher</primary>
55452 <secondary>logging</secondary>
55453 </indexterm>
55454 <indexterm role="concept">
55455 <primary>log</primary>
55456 <secondary>TLS cipher</secondary>
55457 </indexterm>
55458 <indexterm role="concept">
55459 <primary>log</primary>
55460 <secondary>distinguished name</secondary>
55461 </indexterm>
55462 <indexterm role="concept">
55463 <primary>TLS</primary>
55464 <secondary>configuring an Exim client</secondary>
55465 </indexterm>
55466 The <option>tls_cipher</option> and <option>tls_peerdn</option> log selectors apply to outgoing SMTP
55467 deliveries as well as to incoming, the latter one causing logging of the
55468 server certificate&#x2019;s DN. The remaining client configuration for TLS is all
55469 within the <command>smtp</command> transport.
55470 </para>
55471 <para>
55472 It is not necessary to set any options to have TLS work in the <command>smtp</command>
55473 transport. If Exim is built with TLS support, and TLS is advertised by a
55474 server, the <command>smtp</command> transport always tries to start a TLS session. However,
55475 this can be prevented by setting <option>hosts_avoid_tls</option> (an option of the
55476 transport) to a list of server hosts for which TLS should not be used.
55477 </para>
55478 <para>
55479 If you do not want Exim to attempt to send messages unencrypted when an attempt
55480 to set up an encrypted connection fails in any way, you can set
55481 <option>hosts_require_tls</option> to a list of hosts for which encryption is mandatory. For
55482 those hosts, delivery is always deferred if an encrypted connection cannot be
55483 set up. If there are any other hosts for the address, they are tried in the
55484 usual way.
55485 </para>
55486 <para>
55487 When the server host is not in <option>hosts_require_tls</option>, Exim may try to deliver
55488 the message unencrypted. It always does this if the response to STARTTLS is
55489 a 5<emphasis>xx</emphasis> code. For a temporary error code, or for a failure to negotiate a TLS
55490 session after a success response code, what happens is controlled by the
55491 <option>tls_tempfail_tryclear</option> option of the <command>smtp</command> transport. If it is false,
55492 delivery to this host is deferred, and other hosts (if available) are tried. If
55493 it is true, Exim attempts to deliver unencrypted after a 4<emphasis>xx</emphasis> response to
55494 STARTTLS, and if STARTTLS is accepted, but the subsequent TLS
55495 negotiation fails, Exim closes the current connection (because it is in an
55496 unknown state), opens a new one to the same host, and then tries the delivery
55497 unencrypted.
55498 </para>
55499 <para>
55500 The <option>tls_certificate</option> and <option>tls_privatekey</option> options of the <command>smtp</command>
55501 transport provide the client with a certificate, which is passed to the server
55502 if it requests it. If the server is Exim, it will request a certificate only if
55503 <option>tls_verify_hosts</option> or <option>tls_try_verify_hosts</option> matches the client.
55504 </para>
55505 <para revisionflag="changed">
55506 <emphasis role="bold">Note</emphasis>: Do not use a certificate which has the OCSP-must-staple extension,
55507 for client use (they are usable for server use).
55508 As the TLS protocol has no means for the client to staple before TLS 1.3 it will result
55509 in failed connections.
55510 </para>
55511 <para>
55512 If the <option>tls_verify_certificates</option> option is set on the <command>smtp</command> transport, it
55513 specifies a collection of expected server certificates.
55514 These may be
55515 the system default set (depending on library version),
55516 a file,
55517 or (depending on library version) a directory.
55518 The client verifies the server&#x2019;s certificate
55519 against this collection, taking into account any revoked certificates that are
55520 in the list defined by <option>tls_crl</option>.
55521 Failure to verify fails the TLS connection unless either of the
55522 <option>tls_verify_hosts</option> or <option>tls_try_verify_hosts</option> options are set.
55523 </para>
55524 <para>
55525 The <option>tls_verify_hosts</option> and <option>tls_try_verify_hosts</option> options restrict
55526 certificate verification to the listed servers.  Verification either must
55527 or need not succeed respectively.
55528 </para>
55529 <para>
55530 The <option>tls_verify_cert_hostnames</option> option lists hosts for which additional
55531 checks are made: that the host name (the one in the DNS A record)
55532 is valid for the certificate.
55533 The option defaults to always checking.
55534 </para>
55535 <para>
55536 The <command>smtp</command> transport has two OCSP-related options:
55537 <option>hosts_require_ocsp</option>; a host-list for which a Certificate Status
55538 is requested and required for the connection to proceed.  The default
55539 value is empty.
55540 <option>hosts_request_ocsp</option>; a host-list for which (additionally)
55541 a Certificate Status is requested (but not necessarily verified).  The default
55542 value is "*" meaning that requests are made unless configured
55543 otherwise.
55544 </para>
55545 <para>
55546 The host(s) should also be in <option>hosts_require_tls</option>, and
55547 <option>tls_verify_certificates</option> configured for the transport,
55548 for OCSP to be relevant.
55549 </para>
55550 <para>
55551 If
55552 <option>tls_require_ciphers</option> is set on the <command>smtp</command> transport, it must contain a
55553 list of permitted cipher suites. If either of these checks fails, delivery to
55554 the current host is abandoned, and the <command>smtp</command> transport tries to deliver to
55555 alternative hosts, if any.
55556 </para>
55557 <para>
55558  <emphasis role="bold">Note</emphasis>:
55559 These options must be set in the <command>smtp</command> transport for Exim to use TLS when it
55560 is operating as a client. Exim does not assume that a server certificate (set
55561 by the global options of the same name) should also be used when operating as a
55562 client.
55563 </para>
55564 <para>
55565 <indexterm role="variable">
55566 <primary><varname>$host</varname></primary>
55567 </indexterm>
55568 <indexterm role="variable">
55569 <primary><varname>$host_address</varname></primary>
55570 </indexterm>
55571 All the TLS options in the <command>smtp</command> transport are expanded before use, with
55572 <varname>$host</varname> and <varname>$host_address</varname> containing the name and address of the server to
55573 which the client is connected. Forced failure of an expansion causes Exim to
55574 behave as if the relevant option were unset.
55575 </para>
55576 <para>
55577 <indexterm role="variable">
55578 <primary><varname>$tls_out_bits</varname></primary>
55579 </indexterm>
55580 <indexterm role="variable">
55581 <primary><varname>$tls_out_cipher</varname></primary>
55582 </indexterm>
55583 <indexterm role="variable">
55584 <primary><varname>$tls_out_peerdn</varname></primary>
55585 </indexterm>
55586 <indexterm role="variable">
55587 <primary><varname>$tls_out_sni</varname></primary>
55588 </indexterm>
55589 Before an SMTP connection is established, the
55590 <varname>$tls_out_bits</varname>, <varname>$tls_out_cipher</varname>, <varname>$tls_out_peerdn</varname> and <varname>$tls_out_sni</varname>
55591 variables are emptied. (Until the first connection, they contain the values
55592 that were set when the message was received.) If STARTTLS is subsequently
55593 successfully obeyed, these variables are set to the relevant values for the
55594 outgoing connection.
55595 </para>
55596 </section>
55597 <section id="SECTtlssni">
55598 <title>Use of TLS Server Name Indication</title>
55599 <para>
55600 <indexterm role="concept">
55601 <primary>TLS</primary>
55602 <secondary>Server Name Indication</secondary>
55603 </indexterm>
55604 <indexterm role="variable">
55605 <primary><varname>$tls_in_sni</varname></primary>
55606 </indexterm>
55607 <indexterm role="option">
55608 <primary><option>tls_in_sni</option></primary>
55609 </indexterm>
55610 With TLS1.0 or above, there is an extension mechanism by which extra
55611 information can be included at various points in the protocol.  One of these
55612 extensions, documented in RFC 6066 (and before that RFC 4366) is
55613 <quote>Server Name Indication</quote>, commonly <quote>SNI</quote>.  This extension is sent by the
55614 client in the initial handshake, so that the server can examine the servername
55615 within and possibly choose to use different certificates and keys (and more)
55616 for this session.
55617 </para>
55618 <para>
55619 This is analogous to HTTP&#x2019;s <quote>Host:</quote> header, and is the main mechanism by
55620 which HTTPS-enabled web-sites can be virtual-hosted, many sites to one IP
55621 address.
55622 </para>
55623 <para>
55624 With SMTP to MX, there are the same problems here as in choosing the identity
55625 against which to validate a certificate: you can&#x2019;t rely on insecure DNS to
55626 provide the identity which you then cryptographically verify.  So this will
55627 be of limited use in that environment.
55628 </para>
55629 <para>
55630 With SMTP to Submission, there is a well-defined hostname which clients are
55631 connecting to and can validate certificates against.  Thus clients <emphasis role="bold">can</emphasis>
55632 choose to include this information in the TLS negotiation.  If this becomes
55633 wide-spread, then hosters can choose to present different certificates to
55634 different clients.  Or even negotiate different cipher suites.
55635 </para>
55636 <para>
55637 The <option>tls_sni</option> option on an SMTP transport is an expanded string; the result,
55638 if not empty, will be sent on a TLS session as part of the handshake.  There&#x2019;s
55639 nothing more to it.  Choosing a sensible value not derived insecurely is the
55640 only point of caution.  The <varname>$tls_out_sni</varname> variable will be set to this string
55641 for the lifetime of the client connection (including during authentication).
55642 </para>
55643 <para>
55644 Except during SMTP client sessions, if <varname>$tls_in_sni</varname> is set then it is a string
55645 received from a client.
55646 It can be logged with the <option>log_selector</option> item <literal>+tls_sni</literal>.
55647 </para>
55648 <para>
55649 If the string <literal>tls_in_sni</literal> appears in the main section&#x2019;s <option>tls_certificate</option>
55650 option (prior to expansion) then the following options will be re-expanded
55651 during TLS session handshake, to permit alternative values to be chosen:
55652 </para>
55653 <itemizedlist>
55654 <listitem>
55655 <para>
55656 <option>tls_certificate</option>
55657 </para>
55658 </listitem>
55659 <listitem>
55660 <para>
55661 <option>tls_crl</option>
55662 </para>
55663 </listitem>
55664 <listitem>
55665 <para>
55666 <option>tls_privatekey</option>
55667 </para>
55668 </listitem>
55669 <listitem>
55670 <para>
55671 <option>tls_verify_certificates</option>
55672 </para>
55673 </listitem>
55674 <listitem>
55675 <para>
55676 <option>tls_ocsp_file</option>
55677 </para>
55678 </listitem>
55679 </itemizedlist>
55680 <para>
55681 Great care should be taken to deal with matters of case, various injection
55682 attacks in the string (<literal>../</literal> or SQL), and ensuring that a valid filename
55683 can always be referenced; it is important to remember that <varname>$tls_in_sni</varname> is
55684 arbitrary unverified data provided prior to authentication.
55685 Further, the initial certificate is loaded before SNI has arrived, so
55686 an expansion for <option>tls_certificate</option> must have a default which is used
55687 when <varname>$tls_in_sni</varname> is empty.
55688 </para>
55689 <para>
55690 The Exim developers are proceeding cautiously and so far no other TLS options
55691 are re-expanded.
55692 </para>
55693 <para>
55694 When Exim is built against OpenSSL, OpenSSL must have been built with support
55695 for TLS Extensions.  This holds true for OpenSSL 1.0.0+ and 0.9.8+ with
55696 enable-tlsext in EXTRACONFIGURE.  If you invoke <command>openssl s_client -h</command> and
55697 see <literal>-servername</literal> in the output, then OpenSSL has support.
55698 </para>
55699 <para>
55700 When Exim is built against GnuTLS, SNI support is available as of GnuTLS
55701 0.5.10.  (Its presence predates the current API which Exim uses, so if Exim
55702 built, then you have SNI support).
55703 </para>
55704 </section>
55705 <section id="SECTmulmessam">
55706 <title>Multiple messages on the same encrypted TCP/IP connection</title>
55707 <para>
55708 <indexterm role="concept">
55709 <primary>multiple SMTP deliveries with TLS</primary>
55710 </indexterm>
55711 <indexterm role="concept">
55712 <primary>TLS</primary>
55713 <secondary>multiple message deliveries</secondary>
55714 </indexterm>
55715 Exim sends multiple messages down the same TCP/IP connection by starting up
55716 an entirely new delivery process for each message, passing the socket from
55717 one process to the next. This implementation does not fit well with the use
55718 of TLS, because there is quite a lot of state information associated with a TLS
55719 connection, not just a socket identification. Passing all the state information
55720 to a new process is not feasible. Consequently, for sending using TLS Exim
55721 starts an additional proxy process for handling the encryption, piping the
55722 unencrypted data stream from and to the delivery processes.
55723 </para>
55724 <para>
55725 An older mode of operation can be enabled on a per-host basis by the
55726 <option>hosts_noproxy_tls</option> option on the <command>smtp</command> transport.  If the host matches
55727 this list the proxy process described above is not used; instead Exim
55728 shuts down an existing TLS session being run by the delivery process
55729 before passing the socket to a new process. The new process may then
55730 try to start a new TLS session, and if successful, may try to re-authenticate
55731 if AUTH is in use, before sending the next message.
55732 </para>
55733 <para>
55734 The RFC is not clear as to whether or not an SMTP session continues in clear
55735 after TLS has been shut down, or whether TLS may be restarted again later, as
55736 just described. However, if the server is Exim, this shutdown and
55737 reinitialization works. It is not known which (if any) other servers operate
55738 successfully if the client closes a TLS session and continues with unencrypted
55739 SMTP, but there are certainly some that do not work. For such servers, Exim
55740 should not pass the socket to another process, because the failure of the
55741 subsequent attempt to use it would cause Exim to record a temporary host error,
55742 and delay other deliveries to that host.
55743 </para>
55744 <para>
55745 To test for this case, Exim sends an EHLO command to the server after
55746 closing down the TLS session. If this fails in any way, the connection is
55747 closed instead of being passed to a new delivery process, but no retry
55748 information is recorded.
55749 </para>
55750 <para>
55751 There is also a manual override; you can set <option>hosts_nopass_tls</option> on the
55752 <command>smtp</command> transport to match those hosts for which Exim should not pass
55753 connections to new processes if TLS has been used.
55754 </para>
55755 </section>
55756 <section id="SECTcerandall">
55757 <title>Certificates and all that</title>
55758 <para>
55759 <indexterm role="concept">
55760 <primary>certificate</primary>
55761 <secondary>references to discussion</secondary>
55762 </indexterm>
55763 In order to understand fully how TLS works, you need to know about
55764 certificates, certificate signing, and certificate authorities.
55765 This is a large topic and an introductory guide is unsuitable for the Exim
55766 reference manual, so instead we provide pointers to existing documentation.
55767 </para>
55768 <para>
55769 The Apache web-server was for a long time the canonical guide, so their
55770 documentation is a good place to start; their SSL module&#x2019;s Introduction
55771 document is currently at
55772 </para>
55773 <literallayout>
55774 <emphasis role="bold"><ulink url="https://httpd.apache.org/docs/current/ssl/ssl_intro.html">https://httpd.apache.org/docs/current/ssl/ssl_intro.html</ulink></emphasis>
55775 </literallayout>
55776 <para>
55777 and their FAQ is at
55778 </para>
55779 <literallayout>
55780 <emphasis role="bold"><ulink url="https://httpd.apache.org/docs/current/ssl/ssl_faq.html">https://httpd.apache.org/docs/current/ssl/ssl_faq.html</ulink></emphasis>
55781 </literallayout>
55782 <para>
55783 Eric Rescorla&#x2019;s book, <emphasis>SSL and TLS</emphasis>, published by Addison-Wesley (ISBN
55784 0-201-61598-3) in 2001, contains both introductory and more in-depth
55785 descriptions.
55786 More recently Ivan Ristić&#x2019;s book <emphasis>Bulletproof SSL and TLS</emphasis>,
55787 published by Feisty Duck (ISBN 978-1907117046) in 2013 is good.
55788 Ivan is the author of the popular TLS testing tools at
55789 <emphasis role="bold"><ulink url="https://www.ssllabs.com/">https://www.ssllabs.com/</ulink></emphasis>.
55790 </para>
55791 </section>
55792 <section id="SECID186">
55793 <title>Certificate chains</title>
55794 <para>
55795 The file named by <option>tls_certificate</option> may contain more than one
55796 certificate. This is useful in the case where the certificate that is being
55797 sent is validated by an intermediate certificate which the other end does
55798 not have. Multiple certificates must be in the correct order in the file.
55799 First the host&#x2019;s certificate itself, then the first intermediate
55800 certificate to validate the issuer of the host certificate, then the next
55801 intermediate certificate to validate the issuer of the first intermediate
55802 certificate, and so on, until finally (optionally) the root certificate.
55803 The root certificate must already be trusted by the recipient for
55804 validation to succeed, of course, but if it&#x2019;s not preinstalled, sending the
55805 root certificate along with the rest makes it available for the user to
55806 install if the receiving end is a client MUA that can interact with a user.
55807 </para>
55808 <para>
55809 Note that certificates using MD5 are unlikely to work on today&#x2019;s Internet;
55810 even if your libraries allow loading them for use in Exim when acting as a
55811 server, increasingly clients will not accept such certificates.  The error
55812 diagnostics in such a case can be frustratingly vague.
55813 </para>
55814 </section>
55815 <section id="SECID187">
55816 <title>Self-signed certificates</title>
55817 <para>
55818 <indexterm role="concept">
55819 <primary>certificate</primary>
55820 <secondary>self-signed</secondary>
55821 </indexterm>
55822 You can create a self-signed certificate using the <emphasis>req</emphasis> command provided
55823 with OpenSSL, like this:
55824 </para>
55825 <literallayout class="monospaced">
55826 openssl req -x509 -newkey rsa:1024 -keyout file1 -out file2 \
55827             -days 9999 -nodes
55828 </literallayout>
55829 <para>
55830 <filename>file1</filename> and <filename>file2</filename> can be the same file; the key and the certificate are
55831 delimited and so can be identified independently. The <option>-days</option> option
55832 specifies a period for which the certificate is valid. The <option>-nodes</option> option is
55833 important: if you do not set it, the key is encrypted with a passphrase
55834 that you are prompted for, and any use that is made of the key causes more
55835 prompting for the passphrase. This is not helpful if you are going to use
55836 this certificate and key in an MTA, where prompting is not possible.
55837 </para>
55838 <para>
55839 NB: we are now past the point where 9999 days takes us past the 32-bit Unix
55840 epoch.  If your system uses unsigned time_t (most do) and is 32-bit, then
55841 the above command might produce a date in the past.  Think carefully about
55842 the lifetime of the systems you&#x2019;re deploying, and either reduce the duration
55843 of the certificate or reconsider your platform deployment.  (At time of
55844 writing, reducing the duration is the most likely choice, but the inexorable
55845 progression of time takes us steadily towards an era where this will not
55846 be a sensible resolution).
55847 </para>
55848 <para>
55849 A self-signed certificate made in this way is sufficient for testing, and
55850 may be adequate for all your requirements if you are mainly interested in
55851 encrypting transfers, and not in secure identification.
55852 </para>
55853 <para>
55854 However, many clients require that the certificate presented by the server be a
55855 user (also called <quote>leaf</quote> or <quote>site</quote>) certificate, and not a self-signed
55856 certificate. In this situation, the self-signed certificate described above
55857 must be installed on the client host as a trusted root <emphasis>certification
55858 authority</emphasis> (CA), and the certificate used by Exim must be a user certificate
55859 signed with that self-signed certificate.
55860 </para>
55861 <para>
55862 For information on creating self-signed CA certificates and using them to sign
55863 user certificates, see the <emphasis>General implementation overview</emphasis> chapter of the
55864 Open-source PKI book, available online at
55865 <emphasis role="bold"><ulink url="https://sourceforge.net/projects/ospkibook/">https://sourceforge.net/projects/ospkibook/</ulink></emphasis>.
55866 <indexterm role="concept" startref="IIDencsmtp1" class="endofrange"/>
55867 <indexterm role="concept" startref="IIDencsmtp2" class="endofrange"/>
55868 </para>
55869 </section>
55870 <section id="SECDANE">
55871 <title>DANE</title>
55872 <para>
55873 <indexterm role="concept">
55874 <primary>DANE</primary>
55875 </indexterm>
55876 DNS-based Authentication of Named Entities, as applied to SMTP over TLS, provides assurance to a client that
55877 it is actually talking to the server it wants to rather than some attacker operating a Man In The Middle (MITM)
55878 operation.  The latter can terminate the TLS connection you make, and make another one to the server (so both
55879 you and the server still think you have an encrypted connection) and, if one of the "well known" set of
55880 Certificate Authorities has been suborned - something which *has* been seen already (2014), a verifiable
55881 certificate (if you&#x2019;re using normal root CAs, eg. the Mozilla set, as your trust anchors).
55882 </para>
55883 <para>
55884 What DANE does is replace the CAs with the DNS as the trust anchor.  The assurance is limited to a) the possibility
55885 that the DNS has been suborned, b) mistakes made by the admins of the target server.   The attack surface presented
55886 by (a) is thought to be smaller than that of the set of root CAs.
55887 </para>
55888 <para>
55889 It also allows the server to declare (implicitly) that connections to it should use TLS.  An MITM could simply
55890 fail to pass on a server&#x2019;s STARTTLS.
55891 </para>
55892 <para>
55893 DANE scales better than having to maintain (and side-channel communicate) copies of server certificates
55894 for every possible target server.  It also scales (slightly) better than having to maintain on an SMTP
55895 client a copy of the standard CAs bundle.  It also means not having to pay a CA for certificates.
55896 </para>
55897 <para>
55898 DANE requires a server operator to do three things: 1) run DNSSEC.  This provides assurance to clients
55899 that DNS lookups they do for the server have not been tampered with.  The domain MX record applying
55900 to this server, its A record, its TLSA record and any associated CNAME records must all be covered by
55901 DNSSEC.
55902 2) add TLSA DNS records.  These say what the server certificate for a TLS connection should be.
55903 3) offer a server certificate, or certificate chain, in TLS connections which is is anchored by one of the TLSA records.
55904 </para>
55905 <para>
55906 There are no changes to Exim specific to server-side operation of DANE.
55907 Support for client-side operation of DANE can be included at compile time by defining SUPPORT_DANE=yes
55908 in <filename>Local/Makefile</filename>.
55909 If it has been included, the macro "_HAVE_DANE" will be defined.
55910 </para>
55911 <para>
55912 A TLSA record consist of 4 fields, the "Certificate Usage", the
55913 "Selector", the "Matching type", and the "Certificate Association Data".
55914 For a detailed description of the TLSA record see
55915 <emphasis role="bold"><ulink url="https://tools.ietf.org/html/rfc7671#page-5">RFC 7671</ulink></emphasis>.
55916 </para>
55917 <para>
55918 The TLSA record for the server may have "Certificate Usage" (1st) field of DANE-TA(2) or DANE-EE(3).
55919 These are the "Trust Anchor" and "End Entity" variants.
55920 The latter specifies the End Entity directly, i.e. the certificate involved is that of the server
55921 (and if only DANE-EE is used then it should be the sole one transmitted during the TLS handshake);
55922 this is appropriate for a single system, using a self-signed certificate.
55923 DANE-TA usage is effectively declaring a specific CA to be used; this might be a private CA or a public,
55924 well-known one.
55925 A private CA at simplest is just a self-signed certificate (with certain
55926 attributes) which is used to sign server certificates, but running one securely
55927 does require careful arrangement.
55928 With DANE-TA, as implemented in Exim and commonly in other MTAs,
55929 the server TLS handshake must transmit the entire certificate chain from CA to server-certificate.
55930 DANE-TA is commonly used for several services and/or servers, each having a TLSA query-domain CNAME record,
55931 all of which point to a single TLSA record.
55932 DANE-TA and DANE-EE can both be used together.
55933 </para>
55934 <para>
55935 Our recommendation is to use DANE with a certificate from a public CA,
55936 because this enables a variety of strategies for remote clients to verify
55937 your certificate.
55938 You can then publish information both via DANE and another technology,
55939 "MTA-STS", described below.
55940 </para>
55941 <para>
55942 When you use DANE-TA to publish trust anchor information, you ask entities
55943 outside your administrative control to trust the Certificate Authority for
55944 connections to you.
55945 If using a private CA then you should expect others to still apply the
55946 technical criteria they&#x2019;d use for a public CA to your certificates.
55947 In particular, you should probably try to follow current best practices for CA
55948 operation around hash algorithms and key sizes.
55949 Do not expect other organizations to lower their security expectations just
55950 because a particular profile might be reasonable for your own internal use.
55951 </para>
55952 <para>
55953 When this text was last updated, this in practice means to avoid use of SHA-1
55954 and MD5; if using RSA to use key sizes of at least 2048 bits (and no larger
55955 than 4096, for interoperability); to use keyUsage fields correctly; to use
55956 random serial numbers.
55957 The list of requirements is subject to change as best practices evolve.
55958 If you&#x2019;re not already using a private CA, or it doesn&#x2019;t meet these
55959 requirements, then we encourage you to avoid all these issues and use a public
55960 CA such as <emphasis role="bold"><ulink url="https://letsencrypt.org/">Let&#x2019;s Encrypt</ulink></emphasis> instead.
55961 </para>
55962 <para>
55963 The TLSA record should have a "Selector" (2nd) field of SPKI(1) and
55964 a "Matching Type" (3rd) field of SHA2-512(2).
55965 </para>
55966 <para>
55967 For the "Certificate Authority Data" (4th) field, commands like
55968 </para>
55969 <literallayout class="monospaced">
55970   openssl x509 -pubkey -noout &lt;certificate.pem \
55971   | openssl rsa -outform der -pubin 2&gt;/dev/null \
55972   | openssl sha512 \
55973   | awk '{print $2}'
55974 </literallayout>
55975 <para>
55976 are workable to create a hash of the certificate&#x2019;s public key.
55977 </para>
55978 <para>
55979 An example TLSA record for DANE-EE(3), SPKI(1), and SHA-512 (2) looks like
55980 </para>
55981 <literallayout class="monospaced">
55982   _25._tcp.mail.example.com. TLSA 3 1 2 8BA8A336E...
55983 </literallayout>
55984 <para>
55985 At the time of writing, <emphasis role="bold"><ulink url="https://www.huque.com/bin/gen_tlsa">https://www.huque.com/bin/gen_tlsa</ulink></emphasis>
55986 is useful for quickly generating TLSA records.
55987 </para>
55988 <para>
55989 For use with the DANE-TA model, server certificates must have a correct name (SubjectName or SubjectAltName).
55990 </para>
55991 <para>
55992 The Certificate issued by the CA published in the DANE-TA model should be
55993 issued using a strong hash algorithm.
55994 Exim, and importantly various other MTAs sending to you, will not
55995 re-enable hash algorithms which have been disabled by default in TLS
55996 libraries.
55997 This means no MD5 and no SHA-1.  SHA2-256 is the minimum for reliable
55998 interoperability (and probably the maximum too, in 2018).
55999 </para>
56000 <para>
56001 The use of OCSP-stapling should be considered, allowing for fast revocation of certificates (which would otherwise
56002 be limited by the DNS TTL on the TLSA records).  However, this is likely to only be usable with DANE-TA.  NOTE: the
56003 default of requesting OCSP for all hosts is modified iff DANE is in use, to:
56004 </para>
56005 <literallayout class="monospaced">
56006   hosts_request_ocsp = ${if or { {= {0}{$tls_out_tlsa_usage}} \
56007                                  {= {4}{$tls_out_tlsa_usage}} } \
56008                          {*}{}}
56009 </literallayout>
56010 <para>
56011 The (new) variable <varname>$tls_out_tlsa_usage</varname> is a bitfield with numbered bits set for TLSA record usage codes.
56012 The zero above means DANE was not in use, the four means that only DANE-TA usage TLSA records were
56013 found. If the definition of <option>hosts_request_ocsp</option> includes the
56014 string "tls_out_tlsa_usage", they are re-expanded in time to
56015 control the OCSP request.
56016 </para>
56017 <para>
56018 This modification of hosts_request_ocsp is only done if it has the default value of "*".  Admins who change it, and
56019 those who use <option>hosts_require_ocsp</option>, should consider the interaction with DANE in their OCSP settings.
56020 </para>
56021 <para>
56022 For client-side DANE there are three new smtp transport options, <option>hosts_try_dane</option>, <option>hosts_require_dane</option>
56023 and <option>dane_require_tls_ciphers</option>.
56024 The <quote>require</quote> variant will result in failure if the target host is not
56025 DNSSEC-secured. To get DNSSEC-secured hostname resolution, use
56026 the <option>dnssec_request_domains</option> router or transport option.
56027 </para>
56028 <para>
56029 DANE will only be usable if the target host has DNSSEC-secured MX, A and TLSA records.
56030 </para>
56031 <para>
56032 A TLSA lookup will be done if either of the above options match and the host-lookup succeeded using dnssec.
56033 If a TLSA lookup is done and succeeds, a DANE-verified TLS connection
56034 will be required for the host.  If it does not, the host will not
56035 be used; there is no fallback to non-DANE or non-TLS.
56036 </para>
56037 <para>
56038 If DANE is requested and usable, then the TLS cipher list configuration
56039 prefers to use the option <option>dane_require_tls_ciphers</option> and falls
56040 back to <option>tls_require_ciphers</option> only if that is unset.
56041 This lets you configure "decent crypto" for DANE and "better than nothing
56042 crypto" as the default.  Note though that while GnuTLS lets the string control
56043 which versions of TLS/SSL will be negotiated, OpenSSL does not and you&#x2019;re
56044 limited to ciphersuite constraints.
56045 </para>
56046 <para>
56047 If DANE is requested and useable (see above) the following transport options are ignored:
56048 </para>
56049 <literallayout class="monospaced">
56050   hosts_require_tls
56051   tls_verify_hosts
56052   tls_try_verify_hosts
56053   tls_verify_certificates
56054   tls_crl
56055   tls_verify_cert_hostnames
56056 </literallayout>
56057 <para>
56058 If DANE is not usable, whether requested or not, and CA-anchored
56059 verification evaluation is wanted, the above variables should be set appropriately.
56060 </para>
56061 <para>
56062 The router and transport option <option>dnssec_request_domains</option> must not be
56063 set to <quote>never</quote>, and <option>dnssec_require_domains</option> is ignored.
56064 </para>
56065 <para>
56066 If verification was successful using DANE then the "CV" item in the delivery log line will show as "CV=dane".
56067 </para>
56068 <para>
56069 There is a new variable <varname>$tls_out_dane</varname> which will have "yes" if
56070 verification succeeded using DANE and "no" otherwise (only useful
56071 in combination with events; see <xref linkend="CHAPevents"/>),
56072 and a new variable <varname>$tls_out_tlsa_usage</varname> (detailed above).
56073 </para>
56074 <para>
56075 <indexterm role="concept">
56076 <primary>DANE</primary>
56077 <secondary>reporting</secondary>
56078 </indexterm>
56079 An event (see <xref linkend="CHAPevents"/>) of type "dane:fail" will be raised on failures
56080 to achieve DANE-verified connection, if one was either requested and offered, or
56081 required.  This is intended to support TLS-reporting as defined in
56082 <emphasis role="bold"><ulink url="https://tools.ietf.org/html/draft-ietf-uta-smtp-tlsrpt-17">https://tools.ietf.org/html/draft-ietf-uta-smtp-tlsrpt-17</ulink></emphasis>.
56083 The <varname>$event_data</varname> will be one of the Result Types defined in
56084 Section 4.3 of that document.
56085 </para>
56086 <para>
56087 Under GnuTLS, DANE is only supported from version 3.0.0 onwards.
56088 </para>
56089 <para>
56090 DANE is specified in published RFCs and decouples certificate authority trust
56091 selection from a "race to the bottom" of "you must trust everything for mail
56092 to get through".  There is an alternative technology called MTA-STS, which
56093 instead publishes MX trust anchor information on an HTTPS website.  At the
56094 time this text was last updated, MTA-STS was still a draft, not yet an RFC.
56095 Exim has no support for MTA-STS as a client, but Exim mail server operators
56096 can choose to publish information describing their TLS configuration using
56097 MTA-STS to let those clients who do use that protocol derive trust
56098 information.
56099 </para>
56100 <para>
56101 The MTA-STS design requires a certificate from a public Certificate Authority
56102 which is recognized by clients sending to you.
56103 That selection of which CAs are trusted by others is outside your control.
56104 </para>
56105 <para>
56106 The most interoperable course of action is probably to use
56107 <emphasis role="bold"><ulink url="https://letsencrypt.org/">Let&#x2019;s Encrypt</ulink></emphasis>, with automated certificate
56108 renewal; to publish the anchor information in DNSSEC-secured DNS via TLSA
56109 records for DANE clients (such as Exim and Postfix) and to publish anchor
56110 information for MTA-STS as well.  This is what is done for the <emphasis>exim.org</emphasis>
56111 domain itself (with caveats around occasionally broken MTA-STS because of
56112 incompatible specification changes prior to reaching RFC status).
56113 </para>
56114 </section>
56115 </chapter>
56116
56117 <chapter id="CHAPACL">
56118 <title>Access control lists</title>
56119 <para>
56120 <indexterm role="concept" id="IIDacl" class="startofrange">
56121 <primary>access control lists (ACLs)</primary>
56122 <secondary>description</secondary>
56123 </indexterm>
56124 <indexterm role="concept">
56125 <primary>control of incoming mail</primary>
56126 </indexterm>
56127 <indexterm role="concept">
56128 <primary>message</primary>
56129 <secondary>controlling incoming</secondary>
56130 </indexterm>
56131 <indexterm role="concept">
56132 <primary>policy control</primary>
56133 <secondary>access control lists</secondary>
56134 </indexterm>
56135 Access Control Lists (ACLs) are defined in a separate section of the runtime
56136 configuration file, headed by <quote>begin acl</quote>. Each ACL definition starts with a
56137 name, terminated by a colon. Here is a complete ACL section that contains just
56138 one very small ACL:
56139 </para>
56140 <literallayout class="monospaced">
56141 begin acl
56142 small_acl:
56143   accept   hosts = one.host.only
56144 </literallayout>
56145 <para>
56146 You can have as many lists as you like in the ACL section, and the order in
56147 which they appear does not matter. The lists are self-terminating.
56148 </para>
56149 <para>
56150 The majority of ACLs are used to control Exim&#x2019;s behaviour when it receives
56151 certain SMTP commands. This applies both to incoming TCP/IP connections, and
56152 when a local process submits a message using SMTP by specifying the <option>-bs</option>
56153 option. The most common use is for controlling which recipients are accepted
56154 in incoming messages. In addition, you can define an ACL that is used to check
56155 local non-SMTP messages. The default configuration file contains an example of
56156 a realistic ACL for checking RCPT commands. This is discussed in chapter
56157 <xref linkend="CHAPdefconfil"/>.
56158 </para>
56159 <section id="SECID188">
56160 <title>Testing ACLs</title>
56161 <para>
56162 The <option>-bh</option> command line option provides a way of testing your ACL
56163 configuration locally by running a fake SMTP session with which you interact.
56164 </para>
56165 </section>
56166 <section id="SECID189">
56167 <title>Specifying when ACLs are used</title>
56168 <para>
56169 <indexterm role="concept">
56170 <primary>access control lists (ACLs)</primary>
56171 <secondary>options for specifying</secondary>
56172 </indexterm>
56173 In order to cause an ACL to be used, you have to name it in one of the relevant
56174 options in the main part of the configuration. These options are:
56175 <indexterm role="concept">
56176 <primary>AUTH</primary>
56177 <secondary>ACL for</secondary>
56178 </indexterm>
56179 <indexterm role="concept">
56180 <primary>DATA</primary>
56181 <secondary>ACLs for</secondary>
56182 </indexterm>
56183 <indexterm role="concept">
56184 <primary>ETRN</primary>
56185 <secondary>ACL for</secondary>
56186 </indexterm>
56187 <indexterm role="concept">
56188 <primary>EXPN</primary>
56189 <secondary>ACL for</secondary>
56190 </indexterm>
56191 <indexterm role="concept">
56192 <primary>HELO</primary>
56193 <secondary>ACL for</secondary>
56194 </indexterm>
56195 <indexterm role="concept">
56196 <primary>EHLO</primary>
56197 <secondary>ACL for</secondary>
56198 </indexterm>
56199 <indexterm role="concept">
56200 <primary>DKIM</primary>
56201 <secondary>ACL for</secondary>
56202 </indexterm>
56203 <indexterm role="concept">
56204 <primary>MAIL</primary>
56205 <secondary>ACL for</secondary>
56206 </indexterm>
56207 <indexterm role="concept">
56208 <primary>QUIT, ACL for</primary>
56209 </indexterm>
56210 <indexterm role="concept">
56211 <primary>RCPT</primary>
56212 <secondary>ACL for</secondary>
56213 </indexterm>
56214 <indexterm role="concept">
56215 <primary>STARTTLS, ACL for</primary>
56216 </indexterm>
56217 <indexterm role="concept">
56218 <primary>VRFY</primary>
56219 <secondary>ACL for</secondary>
56220 </indexterm>
56221 <indexterm role="concept">
56222 <primary>SMTP</primary>
56223 <secondary>connection, ACL for</secondary>
56224 </indexterm>
56225 <indexterm role="concept">
56226 <primary>non-SMTP messages</primary>
56227 <secondary>ACLs for</secondary>
56228 </indexterm>
56229 <indexterm role="concept">
56230 <primary>MIME content scanning</primary>
56231 <secondary>ACL for</secondary>
56232 </indexterm>
56233 <indexterm role="concept">
56234 <primary>PRDR</primary>
56235 <secondary>ACL for</secondary>
56236 </indexterm>
56237 </para>
56238 <informaltable frame="none">
56239 <tgroup cols="2" colsep="0" rowsep="0">
56240 <colspec colwidth="140pt" align="left"/>
56241 <colspec colwidth="254pt" align="left"/>
56242 <tbody>
56243 <row>
56244 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_not_smtp</option></entry>
56245 <entry>ACL for non-SMTP messages</entry>
56246 </row>
56247 <row>
56248 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_not_smtp_mime</option></entry>
56249 <entry>ACL for non-SMTP MIME parts</entry>
56250 </row>
56251 <row>
56252 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_not_smtp_start</option></entry>
56253 <entry>ACL at start of non-SMTP message</entry>
56254 </row>
56255 <row>
56256 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_auth</option></entry>
56257 <entry>ACL for AUTH</entry>
56258 </row>
56259 <row>
56260 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_connect</option></entry>
56261 <entry>ACL for start of SMTP connection</entry>
56262 </row>
56263 <row>
56264 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_data</option></entry>
56265 <entry>ACL after DATA is complete</entry>
56266 </row>
56267 <row>
56268 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_data_prdr</option></entry>
56269 <entry>ACL for each recipient, after DATA is complete</entry>
56270 </row>
56271 <row>
56272 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_dkim</option></entry>
56273 <entry>ACL for each DKIM signer</entry>
56274 </row>
56275 <row>
56276 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_etrn</option></entry>
56277 <entry>ACL for ETRN</entry>
56278 </row>
56279 <row>
56280 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_expn</option></entry>
56281 <entry>ACL for EXPN</entry>
56282 </row>
56283 <row>
56284 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_helo</option></entry>
56285 <entry>ACL for HELO or EHLO</entry>
56286 </row>
56287 <row>
56288 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_mail</option></entry>
56289 <entry>ACL for MAIL</entry>
56290 </row>
56291 <row>
56292 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_mailauth</option></entry>
56293 <entry>ACL for the AUTH parameter of MAIL</entry>
56294 </row>
56295 <row>
56296 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_mime</option></entry>
56297 <entry>ACL for content-scanning MIME parts</entry>
56298 </row>
56299 <row>
56300 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_notquit</option></entry>
56301 <entry>ACL for non-QUIT terminations</entry>
56302 </row>
56303 <row>
56304 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_predata</option></entry>
56305 <entry>ACL at start of DATA command</entry>
56306 </row>
56307 <row>
56308 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_quit</option></entry>
56309 <entry>ACL for QUIT</entry>
56310 </row>
56311 <row>
56312 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_rcpt</option></entry>
56313 <entry>ACL for RCPT</entry>
56314 </row>
56315 <row>
56316 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_starttls</option></entry>
56317 <entry>ACL for STARTTLS</entry>
56318 </row>
56319 <row>
56320 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_vrfy</option></entry>
56321 <entry>ACL for VRFY</entry>
56322 </row>
56323 </tbody>
56324 </tgroup>
56325 </informaltable>
56326 <para>
56327 For example, if you set
56328 </para>
56329 <literallayout class="monospaced">
56330 acl_smtp_rcpt = small_acl
56331 </literallayout>
56332 <para>
56333 the little ACL defined above is used whenever Exim receives a RCPT command
56334 in an SMTP dialogue. The majority of policy tests on incoming messages can be
56335 done when RCPT commands arrive. A rejection of RCPT should cause the
56336 sending MTA to give up on the recipient address contained in the RCPT
56337 command, whereas rejection at other times may cause the client MTA to keep on
56338 trying to deliver the message. It is therefore recommended that you do as much
56339 testing as possible at RCPT time.
56340 </para>
56341 </section>
56342 <section id="SECID190">
56343 <title>The non-SMTP ACLs</title>
56344 <para>
56345 <indexterm role="concept">
56346 <primary>non-SMTP messages</primary>
56347 <secondary>ACLs for</secondary>
56348 </indexterm>
56349 The non-SMTP ACLs apply to all non-interactive incoming messages, that is, they
56350 apply to batched SMTP as well as to non-SMTP messages. (Batched SMTP is not
56351 really SMTP.) Many of the ACL conditions (for example, host tests, and tests on
56352 the state of the SMTP connection such as encryption and authentication) are not
56353 relevant and are forbidden in these ACLs. However, the sender and recipients
56354 are known, so the <option>senders</option> and <option>sender_domains</option> conditions and the
56355 <varname>$sender_address</varname> and <varname>$recipients</varname> variables can be used. Variables such as
56356 <varname>$authenticated_sender</varname> are also available. You can specify added header lines
56357 in any of these ACLs.
56358 </para>
56359 <para>
56360 The <option>acl_not_smtp_start</option> ACL is run right at the start of receiving a
56361 non-SMTP message, before any of the message has been read. (This is the
56362 analogue of the <option>acl_smtp_predata</option> ACL for SMTP input.) In the case of
56363 batched SMTP input, it runs after the DATA command has been reached. The
56364 result of this ACL is ignored; it cannot be used to reject a message. If you
56365 really need to, you could set a value in an ACL variable here and reject based
56366 on that in the <option>acl_not_smtp</option> ACL. However, this ACL can be used to set
56367 controls, and in particular, it can be used to set
56368 </para>
56369 <literallayout class="monospaced">
56370 control = suppress_local_fixups
56371 </literallayout>
56372 <para>
56373 This cannot be used in the other non-SMTP ACLs because by the time they are
56374 run, it is too late.
56375 </para>
56376 <para>
56377 The <option>acl_not_smtp_mime</option> ACL is available only when Exim is compiled with the
56378 content-scanning extension. For details, see chapter <xref linkend="CHAPexiscan"/>.
56379 </para>
56380 <para>
56381 The <option>acl_not_smtp</option> ACL is run just before the <function>local_scan()</function> function. Any
56382 kind of rejection is treated as permanent, because there is no way of sending a
56383 temporary error for these kinds of message.
56384 </para>
56385 </section>
56386 <section id="SECID191">
56387 <title>The SMTP connect ACL</title>
56388 <para>
56389 <indexterm role="concept">
56390 <primary>SMTP</primary>
56391 <secondary>connection, ACL for</secondary>
56392 </indexterm>
56393 <indexterm role="option">
56394 <primary><option>smtp_banner</option></primary>
56395 </indexterm>
56396 The ACL test specified by <option>acl_smtp_connect</option> happens at the start of an SMTP
56397 session, after the test specified by <option>host_reject_connection</option> (which is now
56398 an anomaly) and any TCP Wrappers testing (if configured). If the connection is
56399 accepted by an <option>accept</option> verb that has a <option>message</option> modifier, the contents of
56400 the message override the banner message that is otherwise specified by the
56401 <option>smtp_banner</option> option.
56402 </para>
56403 </section>
56404 <section id="SECID192">
56405 <title>The EHLO/HELO ACL</title>
56406 <para>
56407 <indexterm role="concept">
56408 <primary>EHLO</primary>
56409 <secondary>ACL for</secondary>
56410 </indexterm>
56411 <indexterm role="concept">
56412 <primary>HELO</primary>
56413 <secondary>ACL for</secondary>
56414 </indexterm>
56415 The ACL test specified by <option>acl_smtp_helo</option> happens when the client issues an
56416 EHLO or HELO command, after the tests specified by <option>helo_accept_junk_hosts</option>,
56417 <option>helo_allow_chars</option>, <option>helo_verify_hosts</option>, and <option>helo_try_verify_hosts</option>.
56418 Note that a client may issue more than one EHLO or HELO command in an SMTP
56419 session, and indeed is required to issue a new EHLO or HELO after successfully
56420 setting up encryption following a STARTTLS command.
56421 </para>
56422 <para>
56423 Note also that a deny neither forces the client to go away nor means that
56424 mail will be refused on the connection.  Consider checking for
56425 <varname>$sender_helo_name</varname> being defined in a MAIL or RCPT ACL to do that.
56426 </para>
56427 <para>
56428 If the command is accepted by an <option>accept</option> verb that has a <option>message</option>
56429 modifier, the message may not contain more than one line (it will be truncated
56430 at the first newline and a panic logged if it does). Such a message cannot
56431 affect the EHLO options that are listed on the second and subsequent lines of
56432 an EHLO response.
56433 </para>
56434 </section>
56435 <section id="SECID193">
56436 <title>The DATA ACLs</title>
56437 <para>
56438 <indexterm role="concept">
56439 <primary>DATA</primary>
56440 <secondary>ACLs for</secondary>
56441 </indexterm>
56442 Two ACLs are associated with the DATA command, because it is two-stage
56443 command, with two responses being sent to the client.
56444 When the DATA command is received, the ACL defined by <option>acl_smtp_predata</option>
56445 is obeyed. This gives you control after all the RCPT commands, but before
56446 the message itself is received. It offers the opportunity to give a negative
56447 response to the DATA command before the data is transmitted. Header lines
56448 added by MAIL or RCPT ACLs are not visible at this time, but any that
56449 are defined here are visible when the <option>acl_smtp_data</option> ACL is run.
56450 </para>
56451 <para>
56452 You cannot test the contents of the message, for example, to verify addresses
56453 in the headers, at RCPT time or when the DATA command is received. Such
56454 tests have to appear in the ACL that is run after the message itself has been
56455 received, before the final response to the DATA command is sent. This is
56456 the ACL specified by <option>acl_smtp_data</option>, which is the second ACL that is
56457 associated with the DATA command.
56458 </para>
56459 <para>
56460 <indexterm role="concept">
56461 <primary>CHUNKING</primary>
56462 <secondary>BDAT command</secondary>
56463 </indexterm>
56464 <indexterm role="concept">
56465 <primary>BDAT</primary>
56466 <secondary>SMTP command</secondary>
56467 </indexterm>
56468 <indexterm role="concept">
56469 <primary>RFC 3030</primary>
56470 <secondary>CHUNKING</secondary>
56471 </indexterm>
56472 If CHUNKING was advertised and a BDAT command sequence is received,
56473 the <option>acl_smtp_predata</option> ACL is not run.
56474 The <option>acl_smtp_data</option> is run after the last BDAT command and all of
56475 the data specified is received.
56476 </para>
56477 <para>
56478 For both of these ACLs, it is not possible to reject individual recipients. An
56479 error response rejects the entire message. Unfortunately, it is known that some
56480 MTAs do not treat hard (5<emphasis>xx</emphasis>) responses to the DATA command (either
56481 before or after the data) correctly &ndash; they keep the message on their queues
56482 and try again later, but that is their problem, though it does waste some of
56483 your resources.
56484 </para>
56485 <para>
56486 The <option>acl_smtp_data</option> ACL is run after
56487 the <option>acl_smtp_data_prdr</option>,
56488 the <option>acl_smtp_dkim</option>
56489 and the <option>acl_smtp_mime</option> ACLs.
56490 </para>
56491 </section>
56492 <section id="SECTDKIMACL">
56493 <title>The SMTP DKIM ACL</title>
56494 <para>
56495 The <option>acl_smtp_dkim</option> ACL is available only when Exim is compiled with DKIM support
56496 enabled (which is the default).
56497 </para>
56498 <para>
56499 The ACL test specified by <option>acl_smtp_dkim</option> happens after a message has been
56500 received, and is executed for each DKIM signature found in a message.  If not
56501 otherwise specified, the default action is to accept.
56502 </para>
56503 <para>
56504 This ACL is evaluated before <option>acl_smtp_mime</option> and <option>acl_smtp_data</option>.
56505 </para>
56506 <para>
56507 For details on the operation of DKIM, see section <xref linkend="SECDKIM"/>.
56508 </para>
56509 </section>
56510 <section id="SECID194">
56511 <title>The SMTP MIME ACL</title>
56512 <para>
56513 The <option>acl_smtp_mime</option> option is available only when Exim is compiled with the
56514 content-scanning extension. For details, see chapter <xref linkend="CHAPexiscan"/>.
56515 </para>
56516 <para>
56517 This ACL is evaluated after <option>acl_smtp_dkim</option> but before <option>acl_smtp_data</option>.
56518 </para>
56519 </section>
56520 <section id="SECTPRDRACL">
56521 <title>The SMTP PRDR ACL</title>
56522 <para>
56523 <indexterm role="concept">
56524 <primary>PRDR</primary>
56525 <secondary>ACL for</secondary>
56526 </indexterm>
56527 <indexterm role="option">
56528 <primary><option>prdr_enable</option></primary>
56529 </indexterm>
56530 The <option>acl_smtp_data_prdr</option> ACL is available only when Exim is compiled
56531 with PRDR support enabled (which is the default).
56532 It becomes active only when the PRDR feature is negotiated between
56533 client and server for a message, and more than one recipient
56534 has been accepted.
56535 </para>
56536 <para>
56537 The ACL test specified by <option>acl_smtp_data_prdr</option> happens after a message
56538 has been received, and is executed once for each recipient of the message
56539 with <varname>$local_part</varname> and <varname>$domain</varname> valid.
56540 The test may accept, defer or deny for individual recipients.
56541 The <option>acl_smtp_data</option> will still be called after this ACL and
56542 can reject the message overall, even if this ACL has accepted it
56543 for some or all recipients.
56544 </para>
56545 <para>
56546 PRDR may be used to support per-user content filtering.  Without it
56547 one must defer any recipient after the first that has a different
56548 content-filter configuration.  With PRDR, the RCPT-time check
56549 <indexterm role="concept">
56550 <primary>PRDR</primary>
56551 <secondary>variable for</secondary>
56552 </indexterm>
56553 for this can be disabled when the variable <varname>$prdr_requested</varname>
56554 is <quote>yes</quote>.
56555 Any required difference in behaviour of the main DATA-time
56556 ACL should however depend on the PRDR-time ACL having run, as Exim
56557 will avoid doing so in some situations (e.g. single-recipient mails).
56558 </para>
56559 <para>
56560 See also the <option>prdr_enable</option> global option
56561 and the <option>hosts_try_prdr</option> smtp transport option.
56562 </para>
56563 <para>
56564 This ACL is evaluated after <option>acl_smtp_dkim</option> but before <option>acl_smtp_data</option>.
56565 If the ACL is not defined, processing completes as if
56566 the feature was not requested by the client.
56567 </para>
56568 </section>
56569 <section id="SECTQUITACL">
56570 <title>The QUIT ACL</title>
56571 <para>
56572 <indexterm role="concept">
56573 <primary>QUIT, ACL for</primary>
56574 </indexterm>
56575 The ACL for the SMTP QUIT command is anomalous, in that the outcome of the ACL
56576 does not affect the response code to QUIT, which is always 221. Thus, the ACL
56577 does not in fact control any access.
56578 For this reason, it may only accept
56579 or warn as its final result.
56580 </para>
56581 <para>
56582 This ACL can be used for tasks such as custom logging at the end of an SMTP
56583 session. For example, you can use ACL variables in other ACLs to count
56584 messages, recipients, etc., and log the totals at QUIT time using one or
56585 more <option>logwrite</option> modifiers on a <option>warn</option> verb.
56586 </para>
56587 <para>
56588 <emphasis role="bold">Warning</emphasis>: Only the <varname>$acl_c</varname><emphasis>x</emphasis> variables can be used for this, because
56589 the <varname>$acl_m</varname><emphasis>x</emphasis> variables are reset at the end of each incoming message.
56590 </para>
56591 <para>
56592 You do not need to have a final <option>accept</option>, but if you do, you can use a
56593 <option>message</option> modifier to specify custom text that is sent as part of the 221
56594 response to QUIT.
56595 </para>
56596 <para>
56597 This ACL is run only for a <quote>normal</quote> QUIT. For certain kinds of disastrous
56598 failure (for example, failure to open a log file, or when Exim is bombing out
56599 because it has detected an unrecoverable error), all SMTP commands from the
56600 client are given temporary error responses until QUIT is received or the
56601 connection is closed. In these special cases, the QUIT ACL does not run.
56602 </para>
56603 </section>
56604 <section id="SECTNOTQUITACL">
56605 <title>The not-QUIT ACL</title>
56606 <para>
56607 <indexterm role="variable">
56608 <primary><varname>$acl_smtp_notquit</varname></primary>
56609 </indexterm>
56610 The not-QUIT ACL, specified by <option>acl_smtp_notquit</option>, is run in most cases when
56611 an SMTP session ends without sending QUIT. However, when Exim itself is in bad
56612 trouble, such as being unable to write to its log files, this ACL is not run,
56613 because it might try to do things (such as write to log files) that make the
56614 situation even worse.
56615 </para>
56616 <para>
56617 Like the QUIT ACL, this ACL is provided to make it possible to do customized
56618 logging or to gather statistics, and its outcome is ignored. The <option>delay</option>
56619 modifier is forbidden in this ACL, and the only permitted verbs are <option>accept</option>
56620 and <option>warn</option>.
56621 </para>
56622 <para>
56623 <indexterm role="variable">
56624 <primary><varname>$smtp_notquit_reason</varname></primary>
56625 </indexterm>
56626 When the not-QUIT ACL is running, the variable <varname>$smtp_notquit_reason</varname> is set
56627 to a string that indicates the reason for the termination of the SMTP
56628 connection. The possible values are:
56629 </para>
56630 <informaltable frame="none">
56631 <tgroup cols="2" colsep="0" rowsep="0">
56632 <colspec colwidth="196pt" align="left"/>
56633 <colspec colwidth="254pt" align="left"/>
56634 <tbody>
56635 <row>
56636 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>acl-drop</literal></entry>
56637 <entry>Another ACL issued a <option>drop</option> command</entry>
56638 </row>
56639 <row>
56640 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>bad-commands</literal></entry>
56641 <entry>Too many unknown or non-mail commands</entry>
56642 </row>
56643 <row>
56644 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>command-timeout</literal></entry>
56645 <entry>Timeout while reading SMTP commands</entry>
56646 </row>
56647 <row>
56648 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>connection-lost</literal></entry>
56649 <entry>The SMTP connection has been lost</entry>
56650 </row>
56651 <row>
56652 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>data-timeout</literal></entry>
56653 <entry>Timeout while reading message data</entry>
56654 </row>
56655 <row>
56656 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>local-scan-error</literal></entry>
56657 <entry>The <function>local_scan()</function> function crashed</entry>
56658 </row>
56659 <row>
56660 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>local-scan-timeout</literal></entry>
56661 <entry>The <function>local_scan()</function> function timed out</entry>
56662 </row>
56663 <row>
56664 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>signal-exit</literal></entry>
56665 <entry>SIGTERM or SIGINT</entry>
56666 </row>
56667 <row>
56668 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>synchronization-error</literal></entry>
56669 <entry>SMTP synchronization error</entry>
56670 </row>
56671 <row>
56672 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>tls-failed</literal></entry>
56673 <entry>TLS failed to start</entry>
56674 </row>
56675 </tbody>
56676 </tgroup>
56677 </informaltable>
56678 <para>
56679 In most cases when an SMTP connection is closed without having received QUIT,
56680 Exim sends an SMTP response message before actually closing the connection.
56681 With the exception of the <literal>acl-drop</literal> case, the default message can be
56682 overridden by the <option>message</option> modifier in the not-QUIT ACL. In the case of a
56683 <option>drop</option> verb in another ACL, it is the message from the other ACL that is
56684 used.
56685 </para>
56686 </section>
56687 <section id="SECID195">
56688 <title>Finding an ACL to use</title>
56689 <para>
56690 <indexterm role="concept">
56691 <primary>access control lists (ACLs)</primary>
56692 <secondary>finding which to use</secondary>
56693 </indexterm>
56694 The value of an <option>acl_smtp_</option><emphasis>xxx</emphasis> option is expanded before use, so
56695 you can use different ACLs in different circumstances. For example,
56696 </para>
56697 <literallayout class="monospaced">
56698 acl_smtp_rcpt = ${if ={25}{$interface_port} \
56699                      {acl_check_rcpt} {acl_check_rcpt_submit} }
56700 </literallayout>
56701 <para>
56702 In the default configuration file there are some example settings for
56703 providing an RFC 4409 message <quote>submission</quote> service on port 587 and
56704 an RFC 8314 <quote>submissions</quote> service on port 465. You can use a string
56705 expansion like this to choose an ACL for MUAs on these ports which is
56706 more appropriate for this purpose than the default ACL on port 25.
56707 </para>
56708 <para>
56709 The expanded string does not have to be the name of an ACL in the
56710 configuration file; there are other possibilities. Having expanded the
56711 string, Exim searches for an ACL as follows:
56712 </para>
56713 <itemizedlist>
56714 <listitem>
56715 <para>
56716 If the string begins with a slash, Exim uses it as a filename, and reads its
56717 contents as an ACL. The lines are processed in the same way as lines in the
56718 Exim configuration file. In particular, continuation lines are supported, blank
56719 lines are ignored, as are lines whose first non-whitespace character is <quote>#</quote>.
56720 If the file does not exist or cannot be read, an error occurs (typically
56721 causing a temporary failure of whatever caused the ACL to be run). For example:
56722 </para>
56723 <literallayout class="monospaced">
56724 acl_smtp_data = /etc/acls/\
56725   ${lookup{$sender_host_address}lsearch\
56726   {/etc/acllist}{$value}{default}}
56727 </literallayout>
56728 <para>
56729 This looks up an ACL file to use on the basis of the host&#x2019;s IP address, falling
56730 back to a default if the lookup fails. If an ACL is successfully read from a
56731 file, it is retained in memory for the duration of the Exim process, so that it
56732 can be re-used without having to re-read the file.
56733 </para>
56734 </listitem>
56735 <listitem>
56736 <para>
56737 If the string does not start with a slash, and does not contain any spaces,
56738 Exim searches the ACL section of the configuration for an ACL whose name
56739 matches the string.
56740 </para>
56741 </listitem>
56742 <listitem>
56743 <para>
56744 If no named ACL is found, or if the string contains spaces, Exim parses
56745 the string as an inline ACL. This can save typing in cases where you just
56746 want to have something like
56747 </para>
56748 <literallayout class="monospaced">
56749 acl_smtp_vrfy = accept
56750 </literallayout>
56751 <para>
56752 in order to allow free use of the VRFY command. Such a string may contain
56753 newlines; it is processed in the same way as an ACL that is read from a file.
56754 </para>
56755 </listitem>
56756 </itemizedlist>
56757 </section>
56758 <section id="SECID196">
56759 <title>ACL return codes</title>
56760 <para>
56761 <indexterm role="concept">
56762 <primary>access control lists (ACLs)</primary>
56763 <secondary>return codes</secondary>
56764 </indexterm>
56765 Except for the QUIT ACL, which does not affect the SMTP return code (see
56766 section <xref linkend="SECTQUITACL"/> above), the result of running an ACL is either
56767 <quote>accept</quote> or <quote>deny</quote>, or, if some test cannot be completed (for example, if a
56768 database is down), <quote>defer</quote>. These results cause 2<emphasis>xx</emphasis>, 5<emphasis>xx</emphasis>, and 4<emphasis>xx</emphasis>
56769 return codes, respectively, to be used in the SMTP dialogue. A fourth return,
56770 <quote>error</quote>, occurs when there is an error such as invalid syntax in the ACL.
56771 This also causes a 4<emphasis>xx</emphasis> return code.
56772 </para>
56773 <para>
56774 For the non-SMTP ACL, <quote>defer</quote> and <quote>error</quote> are treated in the same way as
56775 <quote>deny</quote>, because there is no mechanism for passing temporary errors to the
56776 submitters of non-SMTP messages.
56777 </para>
56778 <para>
56779 ACLs that are relevant to message reception may also return <quote>discard</quote>. This
56780 has the effect of <quote>accept</quote>, but causes either the entire message or an
56781 individual recipient address to be discarded. In other words, it is a
56782 blackholing facility. Use it with care.
56783 </para>
56784 <para>
56785 If the ACL for MAIL returns <quote>discard</quote>, all recipients are discarded, and no
56786 ACL is run for subsequent RCPT commands. The effect of <quote>discard</quote> in a
56787 RCPT ACL is to discard just the one recipient address. If there are no
56788 recipients left when the message&#x2019;s data is received, the DATA ACL is not
56789 run. A <quote>discard</quote> return from the DATA or the non-SMTP ACL discards all the
56790 remaining recipients. The <quote>discard</quote> return is not permitted for the
56791 <option>acl_smtp_predata</option> ACL.
56792 </para>
56793 <para>
56794 If the ACL for VRFY returns <quote>accept</quote>, a recipient verify (without callout)
56795 is done on the address and the result determines the SMTP response.
56796 </para>
56797 <para>
56798 <indexterm role="concept">
56799 <primary><function>local_scan()</function> function</primary>
56800 <secondary>when all recipients discarded</secondary>
56801 </indexterm>
56802 The <function>local_scan()</function> function is always run, even if there are no remaining
56803 recipients; it may create new recipients.
56804 </para>
56805 </section>
56806 <section id="SECID197">
56807 <title>Unset ACL options</title>
56808 <para>
56809 <indexterm role="concept">
56810 <primary>access control lists (ACLs)</primary>
56811 <secondary>unset options</secondary>
56812 </indexterm>
56813 The default actions when any of the <option>acl_</option><emphasis>xxx</emphasis> options are unset are not
56814 all the same. <emphasis role="bold">Note</emphasis>: These defaults apply only when the relevant ACL is
56815 not defined at all. For any defined ACL, the default action when control
56816 reaches the end of the ACL statements is <quote>deny</quote>.
56817 </para>
56818 <para>
56819 For <option>acl_smtp_quit</option> and <option>acl_not_smtp_start</option> there is no default because
56820 these two are ACLs that are used only for their side effects. They cannot be
56821 used to accept or reject anything.
56822 </para>
56823 <para>
56824 For <option>acl_not_smtp</option>, <option>acl_smtp_auth</option>, <option>acl_smtp_connect</option>,
56825 <option>acl_smtp_data</option>, <option>acl_smtp_helo</option>, <option>acl_smtp_mail</option>, <option>acl_smtp_mailauth</option>,
56826 <option>acl_smtp_mime</option>, <option>acl_smtp_predata</option>, and <option>acl_smtp_starttls</option>, the action
56827 when the ACL is not defined is <quote>accept</quote>.
56828 </para>
56829 <para>
56830 For the others (<option>acl_smtp_etrn</option>, <option>acl_smtp_expn</option>, <option>acl_smtp_rcpt</option>, and
56831 <option>acl_smtp_vrfy</option>), the action when the ACL is not defined is <quote>deny</quote>.
56832 This means that <option>acl_smtp_rcpt</option> must be defined in order to receive any
56833 messages over an SMTP connection. For an example, see the ACL in the default
56834 configuration file.
56835 </para>
56836 </section>
56837 <section id="SECID198">
56838 <title>Data for message ACLs</title>
56839 <para>
56840 <indexterm role="concept">
56841 <primary>access control lists (ACLs)</primary>
56842 <secondary>data for message ACL</secondary>
56843 </indexterm>
56844 <indexterm role="variable">
56845 <primary><varname>$domain</varname></primary>
56846 </indexterm>
56847 <indexterm role="variable">
56848 <primary><varname>$local_part</varname></primary>
56849 </indexterm>
56850 <indexterm role="variable">
56851 <primary><varname>$sender_address</varname></primary>
56852 </indexterm>
56853 <indexterm role="variable">
56854 <primary><varname>$sender_host_address</varname></primary>
56855 </indexterm>
56856 <indexterm role="variable">
56857 <primary><varname>$smtp_command</varname></primary>
56858 </indexterm>
56859 When a MAIL or RCPT ACL, or either of the DATA ACLs, is running, the variables
56860 that contain information about the host and the message&#x2019;s sender (for example,
56861 <varname>$sender_host_address</varname> and <varname>$sender_address</varname>) are set, and can be used in ACL
56862 statements. In the case of RCPT (but not MAIL or DATA), <varname>$domain</varname> and
56863 <varname>$local_part</varname> are set from the argument address. The entire SMTP command
56864 is available in <varname>$smtp_command</varname>.
56865 </para>
56866 <para>
56867 When an ACL for the AUTH parameter of MAIL is running, the variables that
56868 contain information about the host are set, but <varname>$sender_address</varname> is not yet
56869 set. Section <xref linkend="SECTauthparamail"/> contains a discussion of this parameter and
56870 how it is used.
56871 </para>
56872 <para>
56873 <indexterm role="variable">
56874 <primary><varname>$message_size</varname></primary>
56875 </indexterm>
56876 The <varname>$message_size</varname> variable is set to the value of the SIZE parameter on
56877 the MAIL command at MAIL, RCPT and pre-data time, or to -1 if
56878 that parameter is not given. The value is updated to the true message size by
56879 the time the final DATA ACL is run (after the message data has been
56880 received).
56881 </para>
56882 <para>
56883 <indexterm role="variable">
56884 <primary><varname>$rcpt_count</varname></primary>
56885 </indexterm>
56886 <indexterm role="variable">
56887 <primary><varname>$recipients_count</varname></primary>
56888 </indexterm>
56889 The <varname>$rcpt_count</varname> variable increases by one for each RCPT command received.
56890 The <varname>$recipients_count</varname> variable increases by one each time a RCPT command is
56891 accepted, so while an ACL for RCPT is being processed, it contains the number
56892 of previously accepted recipients. At DATA time (for both the DATA ACLs),
56893 <varname>$rcpt_count</varname> contains the total number of RCPT commands, and
56894 <varname>$recipients_count</varname> contains the total number of accepted recipients.
56895 </para>
56896 </section>
56897 <section id="SECTdatfornon">
56898 <title>Data for non-message ACLs</title>
56899 <para>
56900 <indexterm role="concept">
56901 <primary>access control lists (ACLs)</primary>
56902 <secondary>data for non-message ACL</secondary>
56903 </indexterm>
56904 <indexterm role="variable">
56905 <primary><varname>$smtp_command_argument</varname></primary>
56906 </indexterm>
56907 <indexterm role="variable">
56908 <primary><varname>$smtp_command</varname></primary>
56909 </indexterm>
56910 When an ACL is being run for AUTH, EHLO, ETRN, EXPN, HELO, STARTTLS, or VRFY,
56911 the remainder of the SMTP command line is placed in <varname>$smtp_command_argument</varname>,
56912 and the entire SMTP command is available in <varname>$smtp_command</varname>.
56913 These variables can be tested using a <option>condition</option> condition. For example,
56914 here is an ACL for use with AUTH, which insists that either the session is
56915 encrypted, or the CRAM-MD5 authentication method is used. In other words, it
56916 does not permit authentication methods that use cleartext passwords on
56917 unencrypted connections.
56918 </para>
56919 <literallayout class="monospaced">
56920 acl_check_auth:
56921   accept encrypted = *
56922   accept condition = ${if eq{${uc:$smtp_command_argument}}\
56923                      {CRAM-MD5}}
56924   deny   message   = TLS encryption or CRAM-MD5 required
56925 </literallayout>
56926 <para>
56927 (Another way of applying this restriction is to arrange for the authenticators
56928 that use cleartext passwords not to be advertised when the connection is not
56929 encrypted. You can use the generic <option>server_advertise_condition</option> authenticator
56930 option to do this.)
56931 </para>
56932 </section>
56933 <section id="SECID199">
56934 <title>Format of an ACL</title>
56935 <para>
56936 <indexterm role="concept">
56937 <primary>access control lists (ACLs)</primary>
56938 <secondary>format of</secondary>
56939 </indexterm>
56940 <indexterm role="concept">
56941 <primary>access control lists (ACLs)</primary>
56942 <secondary>verbs, definition of</secondary>
56943 </indexterm>
56944 An individual ACL consists of a number of statements. Each statement starts
56945 with a verb, optionally followed by a number of conditions and <quote>modifiers</quote>.
56946 Modifiers can change the way the verb operates, define error and log messages,
56947 set variables, insert delays, and vary the processing of accepted messages.
56948 </para>
56949 <para>
56950 If all the conditions are met, the verb is obeyed. The same condition may be
56951 used (with different arguments) more than once in the same statement. This
56952 provides a means of specifying an <quote>and</quote> conjunction between conditions. For
56953 example:
56954 </para>
56955 <literallayout class="monospaced">
56956 deny  dnslists = list1.example
56957       dnslists = list2.example
56958 </literallayout>
56959 <para>
56960 If there are no conditions, the verb is always obeyed. Exim stops evaluating
56961 the conditions and modifiers when it reaches a condition that fails. What
56962 happens then depends on the verb (and in one case, on a special modifier). Not
56963 all the conditions make sense at every testing point. For example, you cannot
56964 test a sender address in the ACL that is run for a VRFY command.
56965 </para>
56966 </section>
56967 <section id="SECID200">
56968 <title>ACL verbs</title>
56969 <para>
56970 The ACL verbs are as follows:
56971 </para>
56972 <itemizedlist>
56973 <listitem>
56974 <para>
56975 <indexterm role="concept">
56976 <primary><option>accept</option> ACL verb</primary>
56977 </indexterm>
56978 <option>accept</option>: If all the conditions are met, the ACL returns <quote>accept</quote>. If any
56979 of the conditions are not met, what happens depends on whether <option>endpass</option>
56980 appears among the conditions (for syntax see below). If the failing condition
56981 is before <option>endpass</option>, control is passed to the next ACL statement; if it is
56982 after <option>endpass</option>, the ACL returns <quote>deny</quote>. Consider this statement, used to
56983 check a RCPT command:
56984 </para>
56985 <literallayout class="monospaced">
56986 accept domains = +local_domains
56987        endpass
56988        verify = recipient
56989 </literallayout>
56990 <para>
56991 If the recipient domain does not match the <option>domains</option> condition, control
56992 passes to the next statement. If it does match, the recipient is verified, and
56993 the command is accepted if verification succeeds. However, if verification
56994 fails, the ACL yields <quote>deny</quote>, because the failing condition is after
56995 <option>endpass</option>.
56996 </para>
56997 <para>
56998 The <option>endpass</option> feature has turned out to be confusing to many people, so its
56999 use is not recommended nowadays. It is always possible to rewrite an ACL so
57000 that <option>endpass</option> is not needed, and it is no longer used in the default
57001 configuration.
57002 </para>
57003 <para>
57004 <indexterm role="concept">
57005 <primary><option>message</option> ACL modifier</primary>
57006 <secondary>with <option>accept</option></secondary>
57007 </indexterm>
57008 If a <option>message</option> modifier appears on an <option>accept</option> statement, its action
57009 depends on whether or not <option>endpass</option> is present. In the absence of <option>endpass</option>
57010 (when an <option>accept</option> verb either accepts or passes control to the next
57011 statement), <option>message</option> can be used to vary the message that is sent when an
57012 SMTP command is accepted. For example, in a RCPT ACL you could have:
57013 </para>
57014 <literallayout>
57015 <literal>accept  </literal>&lt;<emphasis>some conditions</emphasis>&gt;
57016 <literal>        message = OK, I will allow you through today</literal>
57017 </literallayout>
57018 <para>
57019 You can specify an SMTP response code, optionally followed by an <quote>extended
57020 response code</quote> at the start of the message, but the first digit must be the
57021 same as would be sent by default, which is 2 for an <option>accept</option> verb.
57022 </para>
57023 <para>
57024 If <option>endpass</option> is present in an <option>accept</option> statement, <option>message</option> specifies
57025 an error message that is used when access is denied. This behaviour is retained
57026 for backward compatibility, but current <quote>best practice</quote> is to avoid the use
57027 of <option>endpass</option>.
57028 </para>
57029 </listitem>
57030 <listitem>
57031 <para>
57032 <indexterm role="concept">
57033 <primary><option>defer</option> ACL verb</primary>
57034 </indexterm>
57035 <option>defer</option>: If all the conditions are true, the ACL returns <quote>defer</quote> which, in
57036 an SMTP session, causes a 4<emphasis>xx</emphasis> response to be given. For a non-SMTP ACL,
57037 <option>defer</option> is the same as <option>deny</option>, because there is no way of sending a
57038 temporary error. For a RCPT command, <option>defer</option> is much the same as using a
57039 <command>redirect</command> router and <literal>:defer:</literal> while verifying, but the <option>defer</option> verb can
57040 be used in any ACL, and even for a recipient it might be a simpler approach.
57041 </para>
57042 </listitem>
57043 <listitem>
57044 <para>
57045 <indexterm role="concept">
57046 <primary><option>deny</option> ACL verb</primary>
57047 </indexterm>
57048 <option>deny</option>: If all the conditions are met, the ACL returns <quote>deny</quote>. If any of
57049 the conditions are not met, control is passed to the next ACL statement. For
57050 example,
57051 </para>
57052 <literallayout class="monospaced">
57053 deny dnslists = blackholes.mail-abuse.org
57054 </literallayout>
57055 <para>
57056 rejects commands from hosts that are on a DNS black list.
57057 </para>
57058 </listitem>
57059 <listitem>
57060 <para>
57061 <indexterm role="concept">
57062 <primary><option>discard</option> ACL verb</primary>
57063 </indexterm>
57064 <option>discard</option>: This verb behaves like <option>accept</option>, except that it returns
57065 <quote>discard</quote> from the ACL instead of <quote>accept</quote>. It is permitted only on ACLs
57066 that are concerned with receiving messages. When all the conditions are true,
57067 the sending entity receives a <quote>success</quote> response. However, <option>discard</option> causes
57068 recipients to be discarded. If it is used in an ACL for RCPT, just the one
57069 recipient is discarded; if used for MAIL, DATA or in the non-SMTP ACL, all the
57070 message&#x2019;s recipients are discarded. Recipients that are discarded before DATA
57071 do not appear in the log line when the <option>received_recipients</option> log selector is set.
57072 </para>
57073 <para>
57074 If the <option>log_message</option> modifier is set when <option>discard</option> operates,
57075 its contents are added to the line that is automatically written to the log.
57076 The <option>message</option> modifier operates exactly as it does for <option>accept</option>.
57077 </para>
57078 </listitem>
57079 <listitem>
57080 <para>
57081 <indexterm role="concept">
57082 <primary><option>drop</option> ACL verb</primary>
57083 </indexterm>
57084 <option>drop</option>: This verb behaves like <option>deny</option>, except that an SMTP connection is
57085 forcibly closed after the 5<emphasis>xx</emphasis> error message has been sent. For example:
57086 </para>
57087 <literallayout class="monospaced">
57088 drop   message   = I don't take more than 20 RCPTs
57089        condition = ${if &gt; {$rcpt_count}{20}}
57090 </literallayout>
57091 <para>
57092 There is no difference between <option>deny</option> and <option>drop</option> for the connect-time ACL.
57093 The connection is always dropped after sending a 550 response.
57094 </para>
57095 </listitem>
57096 <listitem>
57097 <para>
57098 <indexterm role="concept">
57099 <primary><option>require</option> ACL verb</primary>
57100 </indexterm>
57101 <option>require</option>: If all the conditions are met, control is passed to the next ACL
57102 statement. If any of the conditions are not met, the ACL returns <quote>deny</quote>. For
57103 example, when checking a RCPT command,
57104 </para>
57105 <literallayout class="monospaced">
57106 require message = Sender did not verify
57107         verify  = sender
57108 </literallayout>
57109 <para>
57110 passes control to subsequent statements only if the message&#x2019;s sender can be
57111 verified. Otherwise, it rejects the command. Note the positioning of the
57112 <option>message</option> modifier, before the <option>verify</option> condition. The reason for this is
57113 discussed in section <xref linkend="SECTcondmodproc"/>.
57114 </para>
57115 </listitem>
57116 <listitem>
57117 <para>
57118 <indexterm role="concept">
57119 <primary><option>warn</option> ACL verb</primary>
57120 </indexterm>
57121 <option>warn</option>: If all the conditions are true, a line specified by the
57122 <option>log_message</option> modifier is written to Exim&#x2019;s main log. Control always passes
57123 to the next ACL statement. If any condition is false, the log line is not
57124 written. If an identical log line is requested several times in the same
57125 message, only one copy is actually written to the log. If you want to force
57126 duplicates to be written, use the <option>logwrite</option> modifier instead.
57127 </para>
57128 <para>
57129 If <option>log_message</option> is not present, a <option>warn</option> verb just checks its conditions
57130 and obeys any <quote>immediate</quote> modifiers (such as <option>control</option>, <option>set</option>,
57131 <option>logwrite</option>, <option>add_header</option>, and <option>remove_header</option>) that appear before the
57132 first failing condition. There is more about adding header lines in section
57133 <xref linkend="SECTaddheadacl"/>.
57134 </para>
57135 <para>
57136 If any condition on a <option>warn</option> statement cannot be completed (that is, there is
57137 some sort of defer), the log line specified by <option>log_message</option> is not written.
57138 This does not include the case of a forced failure from a lookup, which
57139 is considered to be a successful completion. After a defer, no further
57140 conditions or modifiers in the <option>warn</option> statement are processed. The incident
57141 is logged, and the ACL continues to be processed, from the next statement
57142 onwards.
57143 </para>
57144 <para>
57145 <indexterm role="variable">
57146 <primary><varname>$acl_verify_message</varname></primary>
57147 </indexterm>
57148 When one of the <option>warn</option> conditions is an address verification that fails, the
57149 text of the verification failure message is in <varname>$acl_verify_message</varname>. If you
57150 want this logged, you must set it up explicitly. For example:
57151 </para>
57152 <literallayout class="monospaced">
57153 warn   !verify = sender
57154        log_message = sender verify failed: $acl_verify_message
57155 </literallayout>
57156 </listitem>
57157 </itemizedlist>
57158 <para>
57159 At the end of each ACL there is an implicit unconditional <option>deny</option>.
57160 </para>
57161 <para>
57162 As you can see from the examples above, the conditions and modifiers are
57163 written one to a line, with the first one on the same line as the verb, and
57164 subsequent ones on following lines. If you have a very long condition, you can
57165 continue it onto several physical lines by the usual backslash continuation
57166 mechanism. It is conventional to align the conditions vertically.
57167 </para>
57168 </section>
57169 <section id="SECTaclvariables">
57170 <title>ACL variables</title>
57171 <para>
57172 <indexterm role="concept">
57173 <primary>access control lists (ACLs)</primary>
57174 <secondary>variables</secondary>
57175 </indexterm>
57176 There are some special variables that can be set during ACL processing. They
57177 can be used to pass information between different ACLs, different invocations
57178 of the same ACL in the same SMTP connection, and between ACLs and the routers,
57179 transports, and filters that are used to deliver a message. The names of these
57180 variables must begin with <varname>$acl_c</varname> or <varname>$acl_m</varname>, followed either by a digit or
57181 an underscore, but the remainder of the name can be any sequence of
57182 alphanumeric characters and underscores that you choose. There is no limit on
57183 the number of ACL variables. The two sets act as follows:
57184 </para>
57185 <itemizedlist>
57186 <listitem>
57187 <para>
57188 The values of those variables whose names begin with <varname>$acl_c</varname> persist
57189 throughout an SMTP connection. They are never reset. Thus, a value that is set
57190 while receiving one message is still available when receiving the next message
57191 on the same SMTP connection.
57192 </para>
57193 </listitem>
57194 <listitem>
57195 <para>
57196 The values of those variables whose names begin with <varname>$acl_m</varname> persist only
57197 while a message is being received. They are reset afterwards. They are also
57198 reset by MAIL, RSET, EHLO, HELO, and after starting up a TLS session.
57199 </para>
57200 </listitem>
57201 </itemizedlist>
57202 <para>
57203 When a message is accepted, the current values of all the ACL variables are
57204 preserved with the message and are subsequently made available at delivery
57205 time. The ACL variables are set by a modifier called <option>set</option>. For example:
57206 </para>
57207 <literallayout class="monospaced">
57208 accept hosts = whatever
57209        set acl_m4 = some value
57210 accept authenticated = *
57211        set acl_c_auth = yes
57212 </literallayout>
57213 <para>
57214 <emphasis role="bold">Note</emphasis>: A leading dollar sign is not used when naming a variable that is to
57215 be set. If you want to set a variable without taking any action, you can use a
57216 <option>warn</option> verb without any other modifiers or conditions.
57217 </para>
57218 <para>
57219 <indexterm role="option">
57220 <primary><option>strict_acl_vars</option></primary>
57221 </indexterm>
57222 What happens if a syntactically valid but undefined ACL variable is
57223 referenced depends on the setting of the <option>strict_acl_vars</option> option. If it is
57224 false (the default), an empty string is substituted; if it is true, an
57225 error is generated.
57226 </para>
57227 <para>
57228 Versions of Exim before 4.64 have a limited set of numbered variables, but
57229 their names are compatible, so there is no problem with upgrading.
57230 </para>
57231 </section>
57232 <section id="SECTcondmodproc">
57233 <title>Condition and modifier processing</title>
57234 <para>
57235 <indexterm role="concept">
57236 <primary>access control lists (ACLs)</primary>
57237 <secondary>conditions; processing</secondary>
57238 </indexterm>
57239 <indexterm role="concept">
57240 <primary>access control lists (ACLs)</primary>
57241 <secondary>modifiers; processing</secondary>
57242 </indexterm>
57243 An exclamation mark preceding a condition negates its result. For example:
57244 </para>
57245 <literallayout class="monospaced">
57246 deny   domains = *.dom.example
57247       !verify  = recipient
57248 </literallayout>
57249 <para>
57250 causes the ACL to return <quote>deny</quote> if the recipient domain ends in
57251 <emphasis>dom.example</emphasis> and the recipient address cannot be verified. Sometimes
57252 negation can be used on the right-hand side of a condition. For example, these
57253 two statements are equivalent:
57254 </para>
57255 <literallayout class="monospaced">
57256 deny  hosts = !192.168.3.4
57257 deny !hosts =  192.168.3.4
57258 </literallayout>
57259 <para>
57260 However, for many conditions (<option>verify</option> being a good example), only left-hand
57261 side negation of the whole condition is possible.
57262 </para>
57263 <para>
57264 The arguments of conditions and modifiers are expanded. A forced failure
57265 of an expansion causes a condition to be ignored, that is, it behaves as if the
57266 condition is true. Consider these two statements:
57267 </para>
57268 <literallayout class="monospaced">
57269 accept  senders = ${lookup{$host_name}lsearch\
57270                   {/some/file}{$value}fail}
57271 accept  senders = ${lookup{$host_name}lsearch\
57272                   {/some/file}{$value}{}}
57273 </literallayout>
57274 <para>
57275 Each attempts to look up a list of acceptable senders. If the lookup succeeds,
57276 the returned list is searched, but if the lookup fails the behaviour is
57277 different in the two cases. The <option>fail</option> in the first statement causes the
57278 condition to be ignored, leaving no further conditions. The <option>accept</option> verb
57279 therefore succeeds. The second statement, however, generates an empty list when
57280 the lookup fails. No sender can match an empty list, so the condition fails,
57281 and therefore the <option>accept</option> also fails.
57282 </para>
57283 <para>
57284 ACL modifiers appear mixed in with conditions in ACL statements. Some of them
57285 specify actions that are taken as the conditions for a statement are checked;
57286 others specify text for messages that are used when access is denied or a
57287 warning is generated. The <option>control</option> modifier affects the way an incoming
57288 message is handled.
57289 </para>
57290 <para>
57291 The positioning of the modifiers in an ACL statement is important, because the
57292 processing of a verb ceases as soon as its outcome is known. Only those
57293 modifiers that have already been encountered will take effect. For example,
57294 consider this use of the <option>message</option> modifier:
57295 </para>
57296 <literallayout class="monospaced">
57297 require message = Can't verify sender
57298         verify  = sender
57299         message = Can't verify recipient
57300         verify  = recipient
57301         message = This message cannot be used
57302 </literallayout>
57303 <para>
57304 If sender verification fails, Exim knows that the result of the statement is
57305 <quote>deny</quote>, so it goes no further. The first <option>message</option> modifier has been seen,
57306 so its text is used as the error message. If sender verification succeeds, but
57307 recipient verification fails, the second message is used. If recipient
57308 verification succeeds, the third message becomes <quote>current</quote>, but is never used
57309 because there are no more conditions to cause failure.
57310 </para>
57311 <para>
57312 For the <option>deny</option> verb, on the other hand, it is always the last <option>message</option>
57313 modifier that is used, because all the conditions must be true for rejection to
57314 happen. Specifying more than one <option>message</option> modifier does not make sense, and
57315 the message can even be specified after all the conditions. For example:
57316 </para>
57317 <literallayout class="monospaced">
57318 deny   hosts = ...
57319       !senders = *@my.domain.example
57320        message = Invalid sender from client host
57321 </literallayout>
57322 <para>
57323 The <quote>deny</quote> result does not happen until the end of the statement is reached,
57324 by which time Exim has set up the message.
57325 </para>
57326 </section>
57327 <section id="SECTACLmodi">
57328 <title>ACL modifiers</title>
57329 <para>
57330 <indexterm role="concept">
57331 <primary>access control lists (ACLs)</primary>
57332 <secondary>modifiers; list of</secondary>
57333 </indexterm>
57334 The ACL modifiers are as follows:
57335 </para>
57336 <variablelist>
57337 <varlistentry>
57338 <term><emphasis role="bold">add_header</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
57339 <listitem>
57340 <para>
57341 This modifier specifies one or more header lines that are to be added to an
57342 incoming message, assuming, of course, that the message is ultimately
57343 accepted. For details, see section <xref linkend="SECTaddheadacl"/>.
57344 </para>
57345 </listitem></varlistentry>
57346 <varlistentry>
57347 <term><emphasis role="bold">continue</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
57348 <listitem>
57349 <para>
57350 <indexterm role="concept">
57351 <primary><option>continue</option> ACL modifier</primary>
57352 </indexterm>
57353 <indexterm role="concept">
57354 <primary>database</primary>
57355 <secondary>updating in ACL</secondary>
57356 </indexterm>
57357 This modifier does nothing of itself, and processing of the ACL always
57358 continues with the next condition or modifier. The value of <option>continue</option> is in
57359 the side effects of expanding its argument. Typically this could be used to
57360 update a database. It is really just a syntactic tidiness, to avoid having to
57361 write rather ugly lines like this:
57362 </para>
57363 <literallayout>
57364 <literal>condition = ${if eq{0}{</literal>&lt;<emphasis>some expansion</emphasis>&gt;<literal>}{true}{true}}</literal>
57365 </literallayout>
57366 <para>
57367 Instead, all you need is
57368 </para>
57369 <literallayout>
57370 <literal>continue = </literal>&lt;<emphasis>some expansion</emphasis>&gt;
57371 </literallayout>
57372 </listitem></varlistentry>
57373 <varlistentry>
57374 <term><emphasis role="bold">control</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
57375 <listitem>
57376 <para>
57377 <indexterm role="concept">
57378 <primary><option>control</option> ACL modifier</primary>
57379 </indexterm>
57380 This modifier affects the subsequent processing of the SMTP connection or of an
57381 incoming message that is accepted. The effect of the first type of control
57382 lasts for the duration of the connection, whereas the effect of the second type
57383 lasts only until the current message has been received. The message-specific
57384 controls always apply to the whole message, not to individual recipients,
57385 even if the <option>control</option> modifier appears in a RCPT ACL.
57386 </para>
57387 <para>
57388 As there are now quite a few controls that can be applied, they are described
57389 separately in section <xref linkend="SECTcontrols"/>. The <option>control</option> modifier can be used
57390 in several different ways. For example:
57391 </para>
57392 <itemizedlist>
57393 <listitem>
57394 <para>
57395 It can be at the end of an <option>accept</option> statement:
57396 </para>
57397 <literallayout class="monospaced">
57398     accept  ...some conditions
57399             control = queue_only
57400 </literallayout>
57401 <para>
57402 In this case, the control is applied when this statement yields <quote>accept</quote>, in
57403 other words, when the conditions are all true.
57404 </para>
57405 </listitem>
57406 <listitem>
57407 <para>
57408 It can be in the middle of an <option>accept</option> statement:
57409 </para>
57410 <literallayout class="monospaced">
57411     accept  ...some conditions...
57412             control = queue_only
57413             ...some more conditions...
57414 </literallayout>
57415 <para>
57416 If the first set of conditions are true, the control is applied, even if the
57417 statement does not accept because one of the second set of conditions is false.
57418 In this case, some subsequent statement must yield <quote>accept</quote> for the control
57419 to be relevant.
57420 </para>
57421 </listitem>
57422 <listitem>
57423 <para>
57424 It can be used with <option>warn</option> to apply the control, leaving the
57425 decision about accepting or denying to a subsequent verb. For
57426 example:
57427 </para>
57428 <literallayout class="monospaced">
57429     warn    ...some conditions...
57430             control = freeze
57431     accept  ...
57432 </literallayout>
57433 <para>
57434 This example of <option>warn</option> does not contain <option>message</option>, <option>log_message</option>, or
57435 <option>logwrite</option>, so it does not add anything to the message and does not write a
57436 log entry.
57437 </para>
57438 </listitem>
57439 <listitem>
57440 <para>
57441 If you want to apply a control unconditionally, you can use it with a
57442 <option>require</option> verb. For example:
57443 </para>
57444 <literallayout class="monospaced">
57445     require  control = no_multiline_responses
57446 </literallayout>
57447 </listitem>
57448 </itemizedlist>
57449 </listitem></varlistentry>
57450 <varlistentry>
57451 <term><emphasis role="bold">delay</emphasis>&nbsp;=&nbsp;&lt;<emphasis>time</emphasis>&gt;</term>
57452 <listitem>
57453 <para>
57454 <indexterm role="concept">
57455 <primary><option>delay</option> ACL modifier</primary>
57456 </indexterm>
57457 <indexterm role="option">
57458 <primary><option>-bh</option></primary>
57459 </indexterm>
57460 This modifier may appear in any ACL except notquit. It causes Exim to wait for
57461 the time interval before proceeding. However, when testing Exim using the
57462 <option>-bh</option> option, the delay is not actually imposed (an appropriate message is
57463 output instead). The time is given in the usual Exim notation, and the delay
57464 happens as soon as the modifier is processed. In an SMTP session, pending
57465 output is flushed before the delay is imposed.
57466 </para>
57467 <para>
57468 Like <option>control</option>, <option>delay</option> can be used with <option>accept</option> or <option>deny</option>, for
57469 example:
57470 </para>
57471 <literallayout class="monospaced">
57472 deny    ...some conditions...
57473         delay = 30s
57474 </literallayout>
57475 <para>
57476 The delay happens if all the conditions are true, before the statement returns
57477 <quote>deny</quote>. Compare this with:
57478 </para>
57479 <literallayout class="monospaced">
57480 deny    delay = 30s
57481         ...some conditions...
57482 </literallayout>
57483 <para>
57484 which waits for 30s before processing the conditions. The <option>delay</option> modifier
57485 can also be used with <option>warn</option> and together with <option>control</option>:
57486 </para>
57487 <literallayout class="monospaced">
57488 warn    ...some conditions...
57489         delay = 2m
57490         control = freeze
57491 accept  ...
57492 </literallayout>
57493 <para>
57494 If <option>delay</option> is encountered when the SMTP PIPELINING extension is in use,
57495 responses to several commands are no longer buffered and sent in one packet (as
57496 they would normally be) because all output is flushed before imposing the
57497 delay. This optimization is disabled so that a number of small delays do not
57498 appear to the client as one large aggregated delay that might provoke an
57499 unwanted timeout. You can, however, disable output flushing for <option>delay</option> by
57500 using a <option>control</option> modifier to set <option>no_delay_flush</option>.
57501 </para>
57502 </listitem></varlistentry>
57503 <varlistentry>
57504 <term><emphasis role="bold">endpass</emphasis></term>
57505 <listitem>
57506 <para>
57507 <indexterm role="concept">
57508 <primary><option>endpass</option> ACL modifier</primary>
57509 </indexterm>
57510 This modifier, which has no argument, is recognized only in <option>accept</option> and
57511 <option>discard</option> statements. It marks the boundary between the conditions whose
57512 failure causes control to pass to the next statement, and the conditions whose
57513 failure causes the ACL to return <quote>deny</quote>. This concept has proved to be
57514 confusing to some people, so the use of <option>endpass</option> is no longer recommended as
57515 <quote>best practice</quote>. See the description of <option>accept</option> above for more details.
57516 </para>
57517 </listitem></varlistentry>
57518 <varlistentry>
57519 <term><emphasis role="bold">log_message</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
57520 <listitem>
57521 <para>
57522 <indexterm role="concept">
57523 <primary><option>log_message</option> ACL modifier</primary>
57524 </indexterm>
57525 This modifier sets up a message that is used as part of the log message if the
57526 ACL denies access or a <option>warn</option> statement&#x2019;s conditions are true. For example:
57527 </para>
57528 <literallayout class="monospaced">
57529 require log_message = wrong cipher suite $tls_in_cipher
57530         encrypted   = DES-CBC3-SHA
57531 </literallayout>
57532 <para>
57533 <option>log_message</option> is also used when recipients are discarded by <option>discard</option>. For
57534 example:
57535 </para>
57536 <literallayout>
57537 <literal>discard </literal>&lt;<emphasis>some conditions</emphasis>&gt;
57538 <literal>        log_message = Discarded $local_part@$domain because...</literal>
57539 </literallayout>
57540 <para>
57541 When access is denied, <option>log_message</option> adds to any underlying error message
57542 that may exist because of a condition failure. For example, while verifying a
57543 recipient address, a <emphasis>:fail:</emphasis> redirection might have already set up a
57544 message.
57545 </para>
57546 <para>
57547 The message may be defined before the conditions to which it applies, because
57548 the string expansion does not happen until Exim decides that access is to be
57549 denied. This means that any variables that are set by the condition are
57550 available for inclusion in the message. For example, the <varname>$dnslist_</varname>&lt;<emphasis>xxx</emphasis>&gt;
57551 variables are set after a DNS black list lookup succeeds. If the expansion of
57552 <option>log_message</option> fails, or if the result is an empty string, the modifier is
57553 ignored.
57554 </para>
57555 <para>
57556 <indexterm role="variable">
57557 <primary><varname>$acl_verify_message</varname></primary>
57558 </indexterm>
57559 If you want to use a <option>warn</option> statement to log the result of an address
57560 verification, you can use <varname>$acl_verify_message</varname> to include the verification
57561 error message.
57562 </para>
57563 <para>
57564 If <option>log_message</option> is used with a <option>warn</option> statement, <quote>Warning:</quote> is added to
57565 the start of the logged message. If the same warning log message is requested
57566 more than once while receiving  a single email message, only one copy is
57567 actually logged. If you want to log multiple copies, use <option>logwrite</option> instead
57568 of <option>log_message</option>. In the absence of <option>log_message</option> and <option>logwrite</option>, nothing
57569 is logged for a successful <option>warn</option> statement.
57570 </para>
57571 <para>
57572 If <option>log_message</option> is not present and there is no underlying error message (for
57573 example, from the failure of address verification), but <option>message</option> is present,
57574 the <option>message</option> text is used for logging rejections. However, if any text for
57575 logging contains newlines, only the first line is logged. In the absence of
57576 both <option>log_message</option> and <option>message</option>, a default built-in message is used for
57577 logging rejections.
57578 </para>
57579 </listitem></varlistentry>
57580 <varlistentry>
57581 <term><emphasis role="bold">log_reject_target</emphasis>&nbsp;=&nbsp;&lt;<emphasis>log name list</emphasis>&gt;</term>
57582 <listitem>
57583 <para>
57584 <indexterm role="concept">
57585 <primary><option>log_reject_target</option> ACL modifier</primary>
57586 </indexterm>
57587 <indexterm role="concept">
57588 <primary>logging in ACL</primary>
57589 <secondary>specifying which log</secondary>
57590 </indexterm>
57591 This modifier makes it possible to specify which logs are used for messages
57592 about ACL rejections. Its argument is a colon-separated list of words that can
57593 be <quote>main</quote>, <quote>reject</quote>, or <quote>panic</quote>. The default is <literal>main:reject</literal>. The list
57594 may be empty, in which case a rejection is not logged at all. For example, this
57595 ACL fragment writes no logging information when access is denied:
57596 </para>
57597 <literallayout>
57598 <literal>deny </literal>&lt;<emphasis>some conditions</emphasis>&gt;
57599 <literal>     log_reject_target =</literal>
57600 </literallayout>
57601 <para>
57602 This modifier can be used in SMTP and non-SMTP ACLs. It applies to both
57603 permanent and temporary rejections. Its effect lasts for the rest of the
57604 current ACL.
57605 </para>
57606 </listitem></varlistentry>
57607 <varlistentry>
57608 <term><emphasis role="bold">logwrite</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
57609 <listitem>
57610 <para>
57611 <indexterm role="concept">
57612 <primary><option>logwrite</option> ACL modifier</primary>
57613 </indexterm>
57614 <indexterm role="concept">
57615 <primary>logging in ACL</primary>
57616 <secondary>immediate</secondary>
57617 </indexterm>
57618 This modifier writes a message to a log file as soon as it is encountered when
57619 processing an ACL. (Compare <option>log_message</option>, which, except in the case of
57620 <option>warn</option> and <option>discard</option>, is used only if the ACL statement denies
57621 access.) The <option>logwrite</option> modifier can be used to log special incidents in
57622 ACLs. For example:
57623 </para>
57624 <literallayout>
57625 <literal>accept </literal>&lt;<emphasis>some special conditions</emphasis>&gt;
57626 <literal>       control  = freeze</literal>
57627 <literal>       logwrite = froze message because ...</literal>
57628 </literallayout>
57629 <para>
57630 By default, the message is written to the main log. However, it may begin
57631 with a colon, followed by a comma-separated list of log names, and then
57632 another colon, to specify exactly which logs are to be written. For
57633 example:
57634 </para>
57635 <literallayout class="monospaced">
57636 logwrite = :main,reject: text for main and reject logs
57637 logwrite = :panic: text for panic log only
57638 </literallayout>
57639 </listitem></varlistentry>
57640 <varlistentry>
57641 <term><emphasis role="bold">message</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
57642 <listitem>
57643 <para>
57644 <indexterm role="concept">
57645 <primary><option>message</option> ACL modifier</primary>
57646 </indexterm>
57647 This modifier sets up a text string that is expanded and used as a response
57648 message when an ACL statement terminates the ACL with an <quote>accept</quote>, <quote>deny</quote>,
57649 or <quote>defer</quote> response. (In the case of the <option>accept</option> and <option>discard</option> verbs,
57650 there is some complication if <option>endpass</option> is involved; see the description of
57651 <option>accept</option> for details.)
57652 </para>
57653 <para>
57654 The expansion of the message happens at the time Exim decides that the ACL is
57655 to end, not at the time it processes <option>message</option>. If the expansion fails, or
57656 generates an empty string, the modifier is ignored. Here is an example where
57657 <option>message</option> must be specified first, because the ACL ends with a rejection if
57658 the <option>hosts</option> condition fails:
57659 </para>
57660 <literallayout class="monospaced">
57661 require  message = Host not recognized
57662          hosts = 10.0.0.0/8
57663 </literallayout>
57664 <para>
57665 (Once a condition has failed, no further conditions or modifiers are
57666 processed.)
57667 </para>
57668 <para>
57669 <indexterm role="concept">
57670 <primary>SMTP</primary>
57671 <secondary>error codes</secondary>
57672 </indexterm>
57673 <indexterm role="option">
57674 <primary><option>smtp_banner</option></primary>
57675 </indexterm>
57676 For ACLs that are triggered by SMTP commands, the message is returned as part
57677 of the SMTP response. The use of <option>message</option> with <option>accept</option> (or <option>discard</option>)
57678 is meaningful only for SMTP, as no message is returned when a non-SMTP message
57679 is accepted. In the case of the connect ACL, accepting with a message modifier
57680 overrides the value of <option>smtp_banner</option>. For the EHLO/HELO ACL, a customized
57681 accept message may not contain more than one line (otherwise it will be
57682 truncated at the first newline and a panic logged), and it cannot affect the
57683 EHLO options.
57684 </para>
57685 <para>
57686 When SMTP is involved, the message may begin with an overriding response code,
57687 consisting of three digits optionally followed by an <quote>extended response code</quote>
57688 of the form <emphasis>n.n.n</emphasis>, each code being followed by a space. For example:
57689 </para>
57690 <literallayout class="monospaced">
57691 deny  message = 599 1.2.3 Host not welcome
57692       hosts = 192.168.34.0/24
57693 </literallayout>
57694 <para>
57695 The first digit of the supplied response code must be the same as would be sent
57696 by default. A panic occurs if it is not. Exim uses a 550 code when it denies
57697 access, but for the predata ACL, note that the default success code is 354, not
57698 2<emphasis>xx</emphasis>.
57699 </para>
57700 <para>
57701 Notwithstanding the previous paragraph, for the QUIT ACL, unlike the others,
57702 the message modifier cannot override the 221 response code.
57703 </para>
57704 <para>
57705 The text in a <option>message</option> modifier is literal; any quotes are taken as
57706 literals, but because the string is expanded, backslash escapes are processed
57707 anyway. If the message contains newlines, this gives rise to a multi-line SMTP
57708 response.
57709 </para>
57710 <para>
57711 <indexterm role="variable">
57712 <primary><varname>$acl_verify_message</varname></primary>
57713 </indexterm>
57714 For ACLs that are called by an <option>acl =</option> ACL condition, the message is
57715 stored in <varname>$acl_verify_message</varname>, from which the calling ACL may use it.
57716 </para>
57717 <para>
57718 If <option>message</option> is used on a statement that verifies an address, the message
57719 specified overrides any message that is generated by the verification process.
57720 However, the original message is available in the variable
57721 <varname>$acl_verify_message</varname>, so you can incorporate it into your message if you
57722 wish. In particular, if you want the text from <option>:fail:</option> items in <command>redirect</command>
57723 routers to be passed back as part of the SMTP response, you should either not
57724 use a <option>message</option> modifier, or make use of <varname>$acl_verify_message</varname>.
57725 </para>
57726 <para>
57727 For compatibility with previous releases of Exim, a <option>message</option> modifier that
57728 is used with a <option>warn</option> verb behaves in a similar way to the <option>add_header</option>
57729 modifier, but this usage is now deprecated. However, <option>message</option> acts only when
57730 all the conditions are true, wherever it appears in an ACL command, whereas
57731 <option>add_header</option> acts as soon as it is encountered. If <option>message</option> is used with
57732 <option>warn</option> in an ACL that is not concerned with receiving a message, it has no
57733 effect.
57734 </para>
57735 </listitem></varlistentry>
57736 <varlistentry>
57737 <term><emphasis role="bold">queue</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
57738 <listitem>
57739 <para>
57740 <indexterm role="concept">
57741 <primary><option>queue</option> ACL modifier</primary>
57742 </indexterm>
57743 <indexterm role="concept">
57744 <primary>named queues</primary>
57745 <secondary>selecting in ACL</secondary>
57746 </indexterm>
57747 This modifier specifies the use of a named queue for spool files
57748 for the message.
57749 It can only be used before the message is received (i.e. not in
57750 the DATA ACL).
57751 This could be used, for example, for known high-volume burst sources
57752 of traffic, or for quarantine of messages.
57753 Separate queue-runner processes will be needed for named queues.
57754 If the text after expansion is empty, the default queue is used.
57755 </para>
57756 </listitem></varlistentry>
57757 <varlistentry>
57758 <term><emphasis role="bold">remove_header</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
57759 <listitem>
57760 <para>
57761 This modifier specifies one or more header names in a colon-separated list
57762  that are to be removed from an incoming message, assuming, of course, that
57763 the message is ultimately accepted. For details, see section <xref linkend="SECTremoveheadacl"/>.
57764 </para>
57765 </listitem></varlistentry>
57766 <varlistentry>
57767 <term><emphasis role="bold">set</emphasis>&nbsp;&lt;<emphasis>acl_name</emphasis>&gt;&nbsp;=&nbsp;&lt;<emphasis>value</emphasis>&gt;</term>
57768 <listitem>
57769 <para>
57770 <indexterm role="concept">
57771 <primary><option>set</option> ACL modifier</primary>
57772 </indexterm>
57773 This modifier puts a value into one of the ACL variables (see section
57774 <xref linkend="SECTaclvariables"/>).
57775 </para>
57776 </listitem></varlistentry>
57777 <varlistentry>
57778 <term><emphasis role="bold">udpsend</emphasis>&nbsp;=&nbsp;&lt;<emphasis>parameters</emphasis>&gt;</term>
57779 <listitem>
57780 <para>
57781 <indexterm role="concept">
57782 <primary>UDP communications</primary>
57783 </indexterm>
57784 This modifier sends a UDP packet, for purposes such as statistics
57785 collection or behaviour monitoring. The parameters are expanded, and
57786 the result of the expansion must be a colon-separated list consisting
57787 of a destination server, port number, and the packet contents. The
57788 server can be specified as a host name or IPv4 or IPv6 address. The
57789 separator can be changed with the usual angle bracket syntax. For
57790 example, you might want to collect information on which hosts connect
57791 when:
57792 </para>
57793 <literallayout class="monospaced">
57794 udpsend = &lt;; 2001:dB8::dead:beef ; 1234 ;\
57795              $tod_zulu $sender_host_address
57796 </literallayout>
57797 </listitem></varlistentry>
57798 </variablelist>
57799 </section>
57800 <section id="SECTcontrols">
57801 <title>Use of the control modifier</title>
57802 <para>
57803 <indexterm role="concept">
57804 <primary><option>control</option> ACL modifier</primary>
57805 </indexterm>
57806 The <option>control</option> modifier supports the following settings:
57807 </para>
57808 <variablelist>
57809 <varlistentry>
57810 <term><emphasis role="bold">control&nbsp;=&nbsp;allow_auth_unadvertised</emphasis></term>
57811 <listitem>
57812 <para>
57813 This modifier allows a client host to use the SMTP AUTH command even when it
57814 has not been advertised in response to EHLO. Furthermore, because there are
57815 apparently some really broken clients that do this, Exim will accept AUTH after
57816 HELO (rather than EHLO) when this control is set. It should be used only if you
57817 really need it, and you should limit its use to those broken clients that do
57818 not work without it. For example:
57819 </para>
57820 <literallayout class="monospaced">
57821 warn hosts   = 192.168.34.25
57822      control = allow_auth_unadvertised
57823 </literallayout>
57824 <para>
57825 Normally, when an Exim server receives an AUTH command, it checks the name of
57826 the authentication mechanism that is given in the command to ensure that it
57827 matches an advertised mechanism. When this control is set, the check that a
57828 mechanism has been advertised is bypassed. Any configured mechanism can be used
57829 by the client. This control is permitted only in the connection and HELO ACLs.
57830 </para>
57831 </listitem></varlistentry>
57832 <varlistentry>
57833 <term><emphasis role="bold">control&nbsp;=&nbsp;caseful_local_part</emphasis></term>
57834 <term><emphasis role="bold">control&nbsp;=&nbsp;caselower_local_part</emphasis></term>
57835 <listitem>
57836 <para>
57837 <indexterm role="concept">
57838 <primary>access control lists (ACLs)</primary>
57839 <secondary>case of local part in</secondary>
57840 </indexterm>
57841 <indexterm role="concept">
57842 <primary>case of local parts</primary>
57843 </indexterm>
57844 <indexterm role="variable">
57845 <primary><varname>$local_part</varname></primary>
57846 </indexterm>
57847 These two controls are permitted only in the ACL specified by <option>acl_smtp_rcpt</option>
57848 (that is, during RCPT processing). By default, the contents of <varname>$local_part</varname>
57849 are lower cased before ACL processing. If <quote>caseful_local_part</quote> is specified,
57850 any uppercase letters in the original local part are restored in <varname>$local_part</varname>
57851 for the rest of the ACL, or until a control that sets <quote>caselower_local_part</quote>
57852 is encountered.
57853 </para>
57854 <para>
57855 These controls affect only the current recipient. Moreover, they apply only to
57856 local part handling that takes place directly in the ACL (for example, as a key
57857 in lookups). If a test to verify the recipient is obeyed, the case-related
57858 handling of the local part during the verification is controlled by the router
57859 configuration (see the <option>caseful_local_part</option> generic router option).
57860 </para>
57861 <para>
57862 This facility could be used, for example, to add a spam score to local parts
57863 containing upper case letters. For example, using <varname>$acl_m4</varname> to accumulate the
57864 spam score:
57865 </para>
57866 <literallayout class="monospaced">
57867 warn  control = caseful_local_part
57868       set acl_m4 = ${eval:\
57869                      $acl_m4 + \
57870                      ${if match{$local_part}{[A-Z]}{1}{0}}\
57871                     }
57872       control = caselower_local_part
57873 </literallayout>
57874 <para>
57875 Notice that we put back the lower cased version afterwards, assuming that
57876 is what is wanted for subsequent tests.
57877 </para>
57878 </listitem></varlistentry>
57879 <varlistentry>
57880 <term><emphasis role="bold">control&nbsp;=&nbsp;cutthrough_delivery/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
57881 <listitem>
57882 <para>
57883 <indexterm role="concept">
57884 <primary>access control lists (ACLs)</primary>
57885 <secondary>cutthrough routing</secondary>
57886 </indexterm>
57887 <indexterm role="concept">
57888 <primary>cutthrough</primary>
57889 <secondary>requesting</secondary>
57890 </indexterm>
57891 This option requests delivery be attempted while the item is being received.
57892 </para>
57893 <para>
57894 The option is usable in the RCPT ACL.
57895 If enabled for a message received via smtp and routed to an smtp transport,
57896 and only one transport, interface, destination host and port combination
57897 is used for all recipients of the message,
57898 then the delivery connection is made while the receiving connection is open
57899 and data is copied from one to the other.
57900 </para>
57901 <para>
57902 An attempt to set this option for any recipient but the first
57903 for a mail will be quietly ignored.
57904 If a recipient-verify callout
57905 (with use_sender)
57906 connection is subsequently
57907 requested in the same ACL it is held open and used for
57908 any subsequent recipients and the data,
57909 otherwise one is made after the initial RCPT ACL completes.
57910 </para>
57911 <para>
57912 Note that routers are used in verify mode,
57913 and cannot depend on content of received headers.
57914 Note also that headers cannot be
57915 modified by any of the post-data ACLs (DATA, MIME and DKIM).
57916 Headers may be modified by routers (subject to the above) and transports.
57917 The <emphasis>Received-By:</emphasis> header is generated as soon as the body reception starts,
57918 rather than the traditional time after the full message is received;
57919 this will affect the timestamp.
57920 </para>
57921 <para>
57922 All the usual ACLs are called; if one results in the message being
57923 rejected, all effort spent in delivery (including the costs on
57924 the ultimate destination) will be wasted.
57925 Note that in the case of data-time ACLs this includes the entire
57926 message body.
57927 </para>
57928 <para>
57929 Cutthrough delivery is not supported via transport-filters or when DKIM signing
57930 of outgoing messages is done, because it sends data to the ultimate destination
57931 before the entire message has been received from the source.
57932 It is not supported for messages received with the SMTP PRDR
57933 or CHUNKING
57934 options in use.
57935 </para>
57936 <para>
57937 Should the ultimate destination system positively accept or reject the mail,
57938 a corresponding indication is given to the source system and nothing is queued.
57939 If the item is successfully delivered in cutthrough mode
57940 the delivery log lines are tagged with "&gt;&gt;" rather than "=&gt;" and appear
57941 before the acceptance "&lt;=" line.
57942 </para>
57943 <para>
57944 If there is a temporary error the item is queued for later delivery in the
57945 usual fashion.
57946 This behaviour can be adjusted by appending the option <emphasis role="bold">defer=</emphasis>&lt;<emphasis>value</emphasis>&gt;
57947 to the control; the default value is <quote>spool</quote> and the alternate value
57948 <quote>pass</quote> copies an SMTP defer response from the target back to the initiator
57949 and does not queue the message.
57950 Note that this is independent of any recipient verify conditions in the ACL.
57951 </para>
57952 <para>
57953 Delivery in this mode avoids the generation of a bounce mail to a
57954 (possibly faked)
57955 sender when the destination system is doing content-scan based rejection.
57956 </para>
57957 </listitem></varlistentry>
57958 <varlistentry>
57959 <term><emphasis role="bold">control&nbsp;=&nbsp;debug/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
57960 <listitem>
57961 <para>
57962 <indexterm role="concept">
57963 <primary>access control lists (ACLs)</primary>
57964 <secondary>enabling debug logging</secondary>
57965 </indexterm>
57966 <indexterm role="concept">
57967 <primary>debugging</primary>
57968 <secondary>enabling from an ACL</secondary>
57969 </indexterm>
57970 This control turns on debug logging, almost as though Exim had been invoked
57971 with <literal>-d</literal>, with the output going to a new logfile in the usual logs directory,
57972 by default called <emphasis>debuglog</emphasis>.
57973 The filename can be adjusted with the <emphasis>tag</emphasis> option, which
57974 may access any variables already defined.  The logging may be adjusted with
57975 the <emphasis>opts</emphasis> option, which takes the same values as the <literal>-d</literal> command-line
57976 option.
57977 Logging started this way may be stopped, and the file removed,
57978 with the <emphasis>kill</emphasis> option.
57979 Some examples (which depend on variables that don&#x2019;t exist in all
57980 contexts):
57981 </para>
57982 <literallayout class="monospaced">
57983       control = debug
57984       control = debug/tag=.$sender_host_address
57985       control = debug/opts=+expand+acl
57986       control = debug/tag=.$message_exim_id/opts=+expand
57987       control = debug/kill
57988 </literallayout>
57989 </listitem></varlistentry>
57990 <varlistentry>
57991 <term><emphasis role="bold">control&nbsp;=&nbsp;dkim_disable_verify</emphasis></term>
57992 <listitem>
57993 <para>
57994 <indexterm role="concept">
57995 <primary>disable DKIM verify</primary>
57996 </indexterm>
57997 <indexterm role="concept">
57998 <primary>DKIM</primary>
57999 <secondary>disable verify</secondary>
58000 </indexterm>
58001 This control turns off DKIM verification processing entirely.  For details on
58002 the operation and configuration of DKIM, see section <xref linkend="SECDKIM"/>.
58003 </para>
58004 </listitem></varlistentry>
58005 <varlistentry>
58006 <term><emphasis role="bold">control&nbsp;=&nbsp;dscp/</emphasis>&lt;<emphasis>value</emphasis>&gt;</term>
58007 <listitem>
58008 <para>
58009 <indexterm role="concept">
58010 <primary>access control lists (ACLs)</primary>
58011 <secondary>setting DSCP value</secondary>
58012 </indexterm>
58013 <indexterm role="concept">
58014 <primary>DSCP</primary>
58015 <secondary>inbound</secondary>
58016 </indexterm>
58017 This option causes the DSCP value associated with the socket for the inbound
58018 connection to be adjusted to a given value, given as one of a number of fixed
58019 strings or to numeric value.
58020 The <option>-bI:dscp</option> option may be used to ask Exim which names it knows of.
58021 Common values include <literal>throughput</literal>, <literal>mincost</literal>, and on newer systems
58022 <literal>ef</literal>, <literal>af41</literal>, etc.  Numeric values may be in the range 0 to 0x3F.
58023 </para>
58024 <para>
58025 The outbound packets from Exim will be marked with this value in the header
58026 (for IPv4, the TOS field; for IPv6, the TCLASS field); there is no guarantee
58027 that these values will have any effect, not be stripped by networking
58028 equipment, or do much of anything without cooperation with your Network
58029 Engineer and those of all network operators between the source and destination.
58030 </para>
58031 </listitem></varlistentry>
58032 <varlistentry>
58033 <term><emphasis role="bold">control&nbsp;=&nbsp;enforce_sync</emphasis></term>
58034 <term><emphasis role="bold">control&nbsp;=&nbsp;no_enforce_sync</emphasis></term>
58035 <listitem>
58036 <para>
58037 <indexterm role="concept">
58038 <primary>SMTP</primary>
58039 <secondary>synchronization checking</secondary>
58040 </indexterm>
58041 <indexterm role="concept">
58042 <primary>synchronization checking in SMTP</primary>
58043 </indexterm>
58044 These controls make it possible to be selective about when SMTP synchronization
58045 is enforced. The global option <option>smtp_enforce_sync</option> specifies the initial
58046 state of the switch (it is true by default). See the description of this option
58047 in chapter <xref linkend="CHAPmainconfig"/> for details of SMTP synchronization checking.
58048 </para>
58049 <para>
58050 The effect of these two controls lasts for the remainder of the SMTP
58051 connection. They can appear in any ACL except the one for the non-SMTP
58052 messages. The most straightforward place to put them is in the ACL defined by
58053 <option>acl_smtp_connect</option>, which is run at the start of an incoming SMTP connection,
58054 before the first synchronization check. The expected use is to turn off the
58055 synchronization checks for badly-behaved hosts that you nevertheless need to
58056 work with.
58057 </para>
58058 </listitem></varlistentry>
58059 <varlistentry>
58060 <term><emphasis role="bold">control&nbsp;=&nbsp;fakedefer/</emphasis>&lt;<emphasis>message</emphasis>&gt;</term>
58061 <listitem>
58062 <para>
58063 <indexterm role="concept">
58064 <primary>fake defer</primary>
58065 </indexterm>
58066 <indexterm role="concept">
58067 <primary>defer, fake</primary>
58068 </indexterm>
58069 This control works in exactly the same way as <option>fakereject</option> (described below)
58070 except that it causes an SMTP 450 response after the message data instead of a
58071 550 response. You must take care when using <option>fakedefer</option> because it causes the
58072 messages to be duplicated when the sender retries. Therefore, you should not
58073 use <option>fakedefer</option> if the message is to be delivered normally.
58074 </para>
58075 </listitem></varlistentry>
58076 <varlistentry>
58077 <term><emphasis role="bold">control&nbsp;=&nbsp;fakereject/</emphasis>&lt;<emphasis>message</emphasis>&gt;</term>
58078 <listitem>
58079 <para>
58080 <indexterm role="concept">
58081 <primary>fake rejection</primary>
58082 </indexterm>
58083 <indexterm role="concept">
58084 <primary>rejection, fake</primary>
58085 </indexterm>
58086 This control is permitted only for the MAIL, RCPT, and DATA ACLs, in other
58087 words, only when an SMTP message is being received. If Exim accepts the
58088 message, instead the final 250 response, a 550 rejection message is sent.
58089 However, Exim proceeds to deliver the message as normal. The control applies
58090 only to the current message, not to any subsequent ones that may be received in
58091 the same SMTP connection.
58092 </para>
58093 <para>
58094 The text for the 550 response is taken from the <option>control</option> modifier. If no
58095 message is supplied, the following is used:
58096 </para>
58097 <literallayout class="monospaced">
58098 550-Your message has been rejected but is being
58099 550-kept for evaluation.
58100 550-If it was a legitimate message, it may still be
58101 550 delivered to the target recipient(s).
58102 </literallayout>
58103 <para>
58104 This facility should be used with extreme caution.
58105 </para>
58106 </listitem></varlistentry>
58107 <varlistentry>
58108 <term><emphasis role="bold">control&nbsp;=&nbsp;freeze</emphasis></term>
58109 <listitem>
58110 <para>
58111 <indexterm role="concept">
58112 <primary>frozen messages</primary>
58113 <secondary>forcing in ACL</secondary>
58114 </indexterm>
58115 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs, in
58116 other words, only when a message is being received. If the message is accepted,
58117 it is placed on Exim&#x2019;s queue and frozen. The control applies only to the
58118 current message, not to any subsequent ones that may be received in the same
58119 SMTP connection.
58120 </para>
58121 <para>
58122 This modifier can optionally be followed by <literal>/no_tell</literal>. If the global option
58123 <option>freeze_tell</option> is set, it is ignored for the current message (that is, nobody
58124 is told about the freezing), provided all the <emphasis role="bold">control=freeze</emphasis> modifiers that
58125 are obeyed for the current message have the <literal>/no_tell</literal> option.
58126 </para>
58127 </listitem></varlistentry>
58128 <varlistentry>
58129 <term><emphasis role="bold">control&nbsp;=&nbsp;no_delay_flush</emphasis></term>
58130 <listitem>
58131 <para>
58132 <indexterm role="concept">
58133 <primary>SMTP</primary>
58134 <secondary>output flushing, disabling for delay</secondary>
58135 </indexterm>
58136 Exim normally flushes SMTP output before implementing a delay in an ACL, to
58137 avoid unexpected timeouts in clients when the SMTP PIPELINING extension is in
58138 use. This control, as long as it is encountered before the <option>delay</option> modifier,
58139 disables such output flushing.
58140 </para>
58141 </listitem></varlistentry>
58142 <varlistentry>
58143 <term><emphasis role="bold">control&nbsp;=&nbsp;no_callout_flush</emphasis></term>
58144 <listitem>
58145 <para>
58146 <indexterm role="concept">
58147 <primary>SMTP</primary>
58148 <secondary>output flushing, disabling for callout</secondary>
58149 </indexterm>
58150 Exim normally flushes SMTP output before performing a callout in an ACL, to
58151 avoid unexpected timeouts in clients when the SMTP PIPELINING extension is in
58152 use. This control, as long as it is encountered before the <option>verify</option> condition
58153 that causes the callout, disables such output flushing.
58154 </para>
58155 </listitem></varlistentry>
58156 <varlistentry>
58157 <term><emphasis role="bold">control&nbsp;=&nbsp;no_mbox_unspool</emphasis></term>
58158 <listitem>
58159 <para>
58160 This control is available when Exim is compiled with the content scanning
58161 extension. Content scanning may require a copy of the current message, or parts
58162 of it, to be written in <quote>mbox format</quote> to a spool file, for passing to a virus
58163 or spam scanner. Normally, such copies are deleted when they are no longer
58164 needed. If this control is set, the copies are not deleted. The control applies
58165 only to the current message, not to any subsequent ones that may be received in
58166 the same SMTP connection. It is provided for debugging purposes and is unlikely
58167 to be useful in production.
58168 </para>
58169 </listitem></varlistentry>
58170 <varlistentry>
58171 <term><emphasis role="bold">control&nbsp;=&nbsp;no_multiline_responses</emphasis></term>
58172 <listitem>
58173 <para>
58174 <indexterm role="concept">
58175 <primary>multiline responses, suppressing</primary>
58176 </indexterm>
58177 This control is permitted for any ACL except the one for non-SMTP messages.
58178 It seems that there are broken clients in use that cannot handle multiline
58179 SMTP responses, despite the fact that RFC 821 defined them over 20 years ago.
58180 </para>
58181 <para>
58182 If this control is set, multiline SMTP responses from ACL rejections are
58183 suppressed. One way of doing this would have been to put out these responses as
58184 one long line. However, RFC 2821 specifies a maximum of 512 bytes per response
58185 (<quote>use multiline responses for more</quote> it says &ndash; ha!), and some of the
58186 responses might get close to that. So this facility, which is after all only a
58187 sop to broken clients, is implemented by doing two very easy things:
58188 </para>
58189 <itemizedlist>
58190 <listitem>
58191 <para>
58192 Extra information that is normally output as part of a rejection caused by
58193 sender verification failure is omitted. Only the final line (typically <quote>sender
58194 verification failed</quote>) is sent.
58195 </para>
58196 </listitem>
58197 <listitem>
58198 <para>
58199 If a <option>message</option> modifier supplies a multiline response, only the first
58200 line is output.
58201 </para>
58202 </listitem>
58203 </itemizedlist>
58204 <para>
58205 The setting of the switch can, of course, be made conditional on the
58206 calling host. Its effect lasts until the end of the SMTP connection.
58207 </para>
58208 </listitem></varlistentry>
58209 <varlistentry>
58210 <term><emphasis role="bold">control&nbsp;=&nbsp;no_pipelining</emphasis></term>
58211 <listitem>
58212 <para>
58213 <indexterm role="concept">
58214 <primary>PIPELINING</primary>
58215 <secondary>suppressing advertising</secondary>
58216 </indexterm>
58217 This control turns off the advertising of the PIPELINING extension to SMTP in
58218 the current session. To be useful, it must be obeyed before Exim sends its
58219 response to an EHLO command. Therefore, it should normally appear in an ACL
58220 controlled by <option>acl_smtp_connect</option> or <option>acl_smtp_helo</option>. See also
58221 <option>pipelining_advertise_hosts</option>.
58222 </para>
58223 </listitem></varlistentry>
58224 <varlistentry>
58225 <term><emphasis role="bold">control&nbsp;=&nbsp;queue_only</emphasis></term>
58226 <listitem>
58227 <para>
58228 <indexterm role="option">
58229 <primary><option>queue_only</option></primary>
58230 </indexterm>
58231 <indexterm role="concept">
58232 <primary>queueing incoming messages</primary>
58233 </indexterm>
58234 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs, in
58235 other words, only when a message is being received. If the message is accepted,
58236 it is placed on Exim&#x2019;s queue and left there for delivery by a subsequent queue
58237 runner. No immediate delivery process is started. In other words, it has the
58238 effect as the <option>queue_only</option> global option. However, the control applies only
58239 to the current message, not to any subsequent ones that may be received in the
58240 same SMTP connection.
58241 </para>
58242 </listitem></varlistentry>
58243 <varlistentry>
58244 <term><emphasis role="bold">control&nbsp;=&nbsp;submission/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
58245 <listitem>
58246 <para>
58247 <indexterm role="concept">
58248 <primary>message</primary>
58249 <secondary>submission</secondary>
58250 </indexterm>
58251 <indexterm role="concept">
58252 <primary>submission mode</primary>
58253 </indexterm>
58254 This control is permitted only for the MAIL, RCPT, and start of data ACLs (the
58255 latter is the one defined by <option>acl_smtp_predata</option>). Setting it tells Exim that
58256 the current message is a submission from a local MUA. In this case, Exim
58257 operates in <quote>submission mode</quote>, and applies certain fixups to the message if
58258 necessary. For example, it adds a <emphasis>Date:</emphasis> header line if one is not present.
58259 This control is not permitted in the <option>acl_smtp_data</option> ACL, because that is too
58260 late (the message has already been created).
58261 </para>
58262 <para>
58263 Chapter <xref linkend="CHAPmsgproc"/> describes the processing that Exim applies to
58264 messages. Section <xref linkend="SECTsubmodnon"/> covers the processing that happens in
58265 submission mode; the available options for this control are described there.
58266 The control applies only to the current message, not to any subsequent ones
58267 that may be received in the same SMTP connection.
58268 </para>
58269 </listitem></varlistentry>
58270 <varlistentry>
58271 <term><emphasis role="bold">control&nbsp;=&nbsp;suppress_local_fixups</emphasis></term>
58272 <listitem>
58273 <para>
58274 <indexterm role="concept">
58275 <primary>submission fixups, suppressing</primary>
58276 </indexterm>
58277 This control applies to locally submitted (non TCP/IP) messages, and is the
58278 complement of <literal>control = submission</literal>. It disables the fixups that are
58279 normally applied to locally-submitted messages. Specifically:
58280 </para>
58281 <itemizedlist>
58282 <listitem>
58283 <para>
58284 Any <emphasis>Sender:</emphasis> header line is left alone (in this respect, it is a
58285 dynamic version of <option>local_sender_retain</option>).
58286 </para>
58287 </listitem>
58288 <listitem>
58289 <para>
58290 No <emphasis>Message-ID:</emphasis>, <emphasis>From:</emphasis>, or <emphasis>Date:</emphasis> header lines are added.
58291 </para>
58292 </listitem>
58293 <listitem>
58294 <para>
58295 There is no check that <emphasis>From:</emphasis> corresponds to the actual sender.
58296 </para>
58297 </listitem>
58298 </itemizedlist>
58299 <para>
58300 This control may be useful when a remotely-originated message is accepted,
58301 passed to some scanning program, and then re-submitted for delivery. It can be
58302 used only in the <option>acl_smtp_mail</option>, <option>acl_smtp_rcpt</option>, <option>acl_smtp_predata</option>,
58303 and <option>acl_not_smtp_start</option> ACLs, because it has to be set before the message&#x2019;s
58304 data is read.
58305 </para>
58306 <para>
58307 <emphasis role="bold">Note:</emphasis> This control applies only to the current message, not to any others
58308 that are being submitted at the same time using <option>-bs</option> or <option>-bS</option>.
58309 </para>
58310 </listitem></varlistentry>
58311 <varlistentry>
58312 <term><emphasis role="bold">control&nbsp;=&nbsp;utf8_downconvert</emphasis></term>
58313 <listitem>
58314 <para>
58315 This control enables conversion of UTF-8 in message addresses
58316 to a-label form.
58317 For details see section <xref linkend="SECTi18nMTA"/>.
58318 </para>
58319 </listitem></varlistentry>
58320 </variablelist>
58321 </section>
58322 <section id="SECTsummesfix">
58323 <title>Summary of message fixup control</title>
58324 <para>
58325 All four possibilities for message fixups can be specified:
58326 </para>
58327 <itemizedlist>
58328 <listitem>
58329 <para>
58330 Locally submitted, fixups applied: the default.
58331 </para>
58332 </listitem>
58333 <listitem>
58334 <para>
58335 Locally submitted, no fixups applied: use
58336 <literal>control = suppress_local_fixups</literal>.
58337 </para>
58338 </listitem>
58339 <listitem>
58340 <para>
58341 Remotely submitted, no fixups applied: the default.
58342 </para>
58343 </listitem>
58344 <listitem>
58345 <para>
58346 Remotely submitted, fixups applied: use <literal>control = submission</literal>.
58347 </para>
58348 </listitem>
58349 </itemizedlist>
58350 </section>
58351 <section id="SECTaddheadacl">
58352 <title>Adding header lines in ACLs</title>
58353 <para>
58354 <indexterm role="concept">
58355 <primary>header lines</primary>
58356 <secondary>adding in an ACL</secondary>
58357 </indexterm>
58358 <indexterm role="concept">
58359 <primary>header lines</primary>
58360 <secondary>position of added lines</secondary>
58361 </indexterm>
58362 <indexterm role="concept">
58363 <primary><option>add_header</option> ACL modifier</primary>
58364 </indexterm>
58365 The <option>add_header</option> modifier can be used to add one or more extra header lines
58366 to an incoming message, as in this example:
58367 </para>
58368 <literallayout class="monospaced">
58369 warn dnslists = sbl.spamhaus.org : \
58370                 dialup.mail-abuse.org
58371      add_header = X-blacklisted-at: $dnslist_domain
58372 </literallayout>
58373 <para>
58374 The <option>add_header</option> modifier is permitted in the MAIL, RCPT, PREDATA, DATA,
58375 MIME, DKIM, and non-SMTP ACLs (in other words, those that are concerned with
58376 receiving a message). The message must ultimately be accepted for
58377 <option>add_header</option> to have any significant effect. You can use <option>add_header</option> with
58378 any ACL verb, including <option>deny</option> (though this is potentially useful only in a
58379 RCPT ACL).
58380 </para>
58381 <para>
58382 Headers will not be added to the message if the modifier is used in
58383 DATA, MIME or DKIM ACLs for a message delivered by cutthrough routing.
58384 </para>
58385 <para>
58386 Leading and trailing newlines are removed from
58387 the data for the <option>add_header</option> modifier; if it then
58388 contains one or more newlines that
58389 are not followed by a space or a tab, it is assumed to contain multiple header
58390 lines. Each one is checked for valid syntax; <literal>X-ACL-Warn:</literal> is added to the
58391 front of any line that is not a valid header line.
58392 </para>
58393 <para>
58394 Added header lines are accumulated during the MAIL, RCPT, and predata ACLs.
58395 They are added to the message before processing the DATA and MIME ACLs.
58396 However, if an identical header line is requested more than once, only one copy
58397 is actually added to the message. Further header lines may be accumulated
58398 during the DATA and MIME ACLs, after which they are added to the message, again
58399 with duplicates suppressed. Thus, it is possible to add two identical header
58400 lines to an SMTP message, but only if one is added before DATA and one after.
58401 In the case of non-SMTP messages, new headers are accumulated during the
58402 non-SMTP ACLs, and are added to the message after all the ACLs have run. If a
58403 message is rejected after DATA or by the non-SMTP ACL, all added header lines
58404 are included in the entry that is written to the reject log.
58405 </para>
58406 <para>
58407 <indexterm role="concept">
58408 <primary>header lines</primary>
58409 <secondary>added; visibility of</secondary>
58410 </indexterm>
58411 Header lines are not visible in string expansions
58412 of message headers
58413 until they are added to the
58414 message. It follows that header lines defined in the MAIL, RCPT, and predata
58415 ACLs are not visible until the DATA ACL and MIME ACLs are run. Similarly,
58416 header lines that are added by the DATA or MIME ACLs are not visible in those
58417 ACLs. Because of this restriction, you cannot use header lines as a way of
58418 passing data between (for example) the MAIL and RCPT ACLs. If you want to do
58419 this, you can use ACL variables, as described in section
58420 <xref linkend="SECTaclvariables"/>.
58421 </para>
58422 <para>
58423 The list of headers yet to be added is given by the <option>$headers_added</option> variable.
58424 </para>
58425 <para>
58426 The <option>add_header</option> modifier acts immediately as it is encountered during the
58427 processing of an ACL. Notice the difference between these two cases:
58428 </para>
58429 <literallayout>
58430 <literal>accept add_header = ADDED: some text</literal>
58431 <literal>       </literal>&lt;<emphasis>some condition</emphasis>&gt;
58432
58433 <literal>accept </literal>&lt;<emphasis>some condition</emphasis>&gt;
58434 <literal>       add_header = ADDED: some text</literal>
58435 </literallayout>
58436 <para>
58437 In the first case, the header line is always added, whether or not the
58438 condition is true. In the second case, the header line is added only if the
58439 condition is true. Multiple occurrences of <option>add_header</option> may occur in the same
58440 ACL statement. All those that are encountered before a condition fails are
58441 honoured.
58442 </para>
58443 <para>
58444 <indexterm role="concept">
58445 <primary><option>warn</option> ACL verb</primary>
58446 </indexterm>
58447 For compatibility with previous versions of Exim, a <option>message</option> modifier for a
58448 <option>warn</option> verb acts in the same way as <option>add_header</option>, except that it takes
58449 effect only if all the conditions are true, even if it appears before some of
58450 them. Furthermore, only the last occurrence of <option>message</option> is honoured. This
58451 usage of <option>message</option> is now deprecated. If both <option>add_header</option> and <option>message</option>
58452 are present on a <option>warn</option> verb, both are processed according to their
58453 specifications.
58454 </para>
58455 <para>
58456 By default, new header lines are added to a message at the end of the existing
58457 header lines. However, you can specify that any particular header line should
58458 be added right at the start (before all the <emphasis>Received:</emphasis> lines), immediately
58459 after the first block of <emphasis>Received:</emphasis> lines, or immediately before any line
58460 that is not a <emphasis>Received:</emphasis> or <emphasis>Resent-something:</emphasis> header.
58461 </para>
58462 <para>
58463 This is done by specifying <quote>:at_start:</quote>, <quote>:after_received:</quote>, or
58464 <quote>:at_start_rfc:</quote> (or, for completeness, <quote>:at_end:</quote>) before the text of the
58465 header line, respectively. (Header text cannot start with a colon, as there has
58466 to be a header name first.) For example:
58467 </para>
58468 <literallayout class="monospaced">
58469 warn add_header = \
58470        :after_received:X-My-Header: something or other...
58471 </literallayout>
58472 <para>
58473 If more than one header line is supplied in a single <option>add_header</option> modifier,
58474 each one is treated independently and can therefore be placed differently. If
58475 you add more than one line at the start, or after the Received: block, they end
58476 up in reverse order.
58477 </para>
58478 <para>
58479 <emphasis role="bold">Warning</emphasis>: This facility currently applies only to header lines that are
58480 added in an ACL. It does NOT work for header lines that are added in a
58481 system filter or in a router or transport.
58482 </para>
58483 </section>
58484 <section id="SECTremoveheadacl">
58485 <title>Removing header lines in ACLs</title>
58486 <para>
58487 <indexterm role="concept">
58488 <primary>header lines</primary>
58489 <secondary>removing in an ACL</secondary>
58490 </indexterm>
58491 <indexterm role="concept">
58492 <primary>header lines</primary>
58493 <secondary>position of removed lines</secondary>
58494 </indexterm>
58495 <indexterm role="concept">
58496 <primary><option>remove_header</option> ACL modifier</primary>
58497 </indexterm>
58498 The <option>remove_header</option> modifier can be used to remove one or more header lines
58499 from an incoming message, as in this example:
58500 </para>
58501 <literallayout class="monospaced">
58502 warn   message        = Remove internal headers
58503        remove_header  = x-route-mail1 : x-route-mail2
58504 </literallayout>
58505 <para>
58506 The <option>remove_header</option> modifier is permitted in the MAIL, RCPT, PREDATA, DATA,
58507 MIME, DKIM, and non-SMTP ACLs (in other words, those that are concerned with
58508 receiving a message). The message must ultimately be accepted for
58509 <option>remove_header</option> to have any significant effect. You can use <option>remove_header</option>
58510 with any ACL verb, including <option>deny</option>, though this is really not useful for
58511 any verb that doesn&#x2019;t result in a delivered message.
58512 </para>
58513 <para>
58514 Headers will not be removed from the message if the modifier is used in
58515 DATA, MIME or DKIM ACLs for a message delivered by cutthrough routing.
58516 </para>
58517 <para>
58518 More than one header can be removed at the same time by using a colon separated
58519 list of header names. The header matching is case insensitive. Wildcards are
58520 not permitted, nor is list expansion performed, so you cannot use hostlists to
58521 create a list of headers, however both connection and message variable expansion
58522 are performed (<option>$acl_c_*</option> and <option>$acl_m_*</option>), illustrated in this example:
58523 </para>
58524 <literallayout class="monospaced">
58525 warn   hosts           = +internal_hosts
58526        set acl_c_ihdrs = x-route-mail1 : x-route-mail2
58527 warn   message         = Remove internal headers
58528        remove_header   = $acl_c_ihdrs
58529 </literallayout>
58530 <para>
58531 Header names for removal are accumulated during the MAIL, RCPT, and predata ACLs.
58532 Matching header lines are removed from the message before processing the DATA and MIME ACLs.
58533 If multiple header lines match, all are removed.
58534 There is no harm in attempting to remove the same header twice nor in removing
58535 a non-existent header. Further header lines to be removed may be accumulated
58536 during the DATA and MIME ACLs, after which they are removed from the message,
58537 if present. In the case of non-SMTP messages, headers to be removed are
58538 accumulated during the non-SMTP ACLs, and are removed from the message after
58539 all the ACLs have run. If a message is rejected after DATA or by the non-SMTP
58540 ACL, there really is no effect because there is no logging of what headers
58541 would have been removed.
58542 </para>
58543 <para>
58544 <indexterm role="concept">
58545 <primary>header lines</primary>
58546 <secondary>removed; visibility of</secondary>
58547 </indexterm>
58548 Header lines are not visible in string expansions until the DATA phase when it
58549 is received. Any header lines removed in the MAIL, RCPT, and predata ACLs are
58550 not visible in the DATA ACL and MIME ACLs. Similarly, header lines that are
58551 removed by the DATA or MIME ACLs are still visible in those ACLs. Because of
58552 this restriction, you cannot use header lines as a way of controlling data
58553 passed between (for example) the MAIL and RCPT ACLs. If you want to do this,
58554 you should instead use ACL variables, as described in section
58555 <xref linkend="SECTaclvariables"/>.
58556 </para>
58557 <para>
58558 The <option>remove_header</option> modifier acts immediately as it is encountered during the
58559 processing of an ACL. Notice the difference between these two cases:
58560 </para>
58561 <literallayout>
58562 <literal>accept remove_header = X-Internal</literal>
58563 <literal>       </literal>&lt;<emphasis>some condition</emphasis>&gt;
58564
58565 <literal>accept </literal>&lt;<emphasis>some condition</emphasis>&gt;
58566 <literal>       remove_header = X-Internal</literal>
58567 </literallayout>
58568 <para>
58569 In the first case, the header line is always removed, whether or not the
58570 condition is true. In the second case, the header line is removed only if the
58571 condition is true. Multiple occurrences of <option>remove_header</option> may occur in the
58572 same ACL statement. All those that are encountered before a condition fails
58573 are honoured.
58574 </para>
58575 <para>
58576 <emphasis role="bold">Warning</emphasis>: This facility currently applies only to header lines that are
58577 present during ACL processing. It does NOT remove header lines that are added
58578 in a system filter or in a router or transport.
58579 </para>
58580 </section>
58581 <section id="SECTaclconditions">
58582 <title>ACL conditions</title>
58583 <para>
58584 <indexterm role="concept">
58585 <primary>access control lists (ACLs)</primary>
58586 <secondary>conditions; list of</secondary>
58587 </indexterm>
58588 Some of the conditions listed in this section are available only when Exim is
58589 compiled with the content-scanning extension. They are included here briefly
58590 for completeness. More detailed descriptions can be found in the discussion on
58591 content scanning in chapter <xref linkend="CHAPexiscan"/>.
58592 </para>
58593 <para>
58594 Not all conditions are relevant in all circumstances. For example, testing
58595 senders and recipients does not make sense in an ACL that is being run as the
58596 result of the arrival of an ETRN command, and checks on message headers can be
58597 done only in the ACLs specified by <option>acl_smtp_data</option> and <option>acl_not_smtp</option>. You
58598 can use the same condition (with different parameters) more than once in the
58599 same ACL statement. This provides a way of specifying an <quote>and</quote> conjunction.
58600 The conditions are as follows:
58601 </para>
58602 <variablelist>
58603 <varlistentry>
58604 <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>
58605 <listitem>
58606 <para>
58607 <indexterm role="concept">
58608 <primary>access control lists (ACLs)</primary>
58609 <secondary>nested</secondary>
58610 </indexterm>
58611 <indexterm role="concept">
58612 <primary>access control lists (ACLs)</primary>
58613 <secondary>indirect</secondary>
58614 </indexterm>
58615 <indexterm role="concept">
58616 <primary>access control lists (ACLs)</primary>
58617 <secondary>arguments</secondary>
58618 </indexterm>
58619 <indexterm role="concept">
58620 <primary><option>acl</option> ACL condition</primary>
58621 </indexterm>
58622 The possible values of the argument are the same as for the
58623 <option>acl_smtp_</option><emphasis>xxx</emphasis> options. The named or inline ACL is run. If it returns
58624 <quote>accept</quote> the condition is true; if it returns <quote>deny</quote> the condition is
58625 false. If it returns <quote>defer</quote>, the current ACL returns <quote>defer</quote> unless the
58626 condition is on a <option>warn</option> verb. In that case, a <quote>defer</quote> return makes the
58627 condition false. This means that further processing of the <option>warn</option> verb
58628 ceases, but processing of the ACL continues.
58629 </para>
58630 <para>
58631 If the argument is a named ACL, up to nine space-separated optional values
58632 can be appended; they appear within the called ACL in $acl_arg1 to $acl_arg9,
58633 and $acl_narg is set to the count of values.
58634 Previous values of these variables are restored after the call returns.
58635 The name and values are expanded separately.
58636 Note that spaces in complex expansions which are used as arguments
58637 will act as argument separators.
58638 </para>
58639 <para>
58640 If the nested <option>acl</option> returns <quote>drop</quote> and the outer condition denies access,
58641 the connection is dropped. If it returns <quote>discard</quote>, the verb must be
58642 <option>accept</option> or <option>discard</option>, and the action is taken immediately &ndash; no further
58643 conditions are tested.
58644 </para>
58645 <para>
58646 ACLs may be nested up to 20 deep; the limit exists purely to catch runaway
58647 loops. This condition allows you to use different ACLs in different
58648 circumstances. For example, different ACLs can be used to handle RCPT commands
58649 for different local users or different local domains.
58650 </para>
58651 </listitem></varlistentry>
58652 <varlistentry>
58653 <term><emphasis role="bold">authenticated&nbsp;=&nbsp;</emphasis>&lt;<emphasis>string&nbsp;list</emphasis>&gt;</term>
58654 <listitem>
58655 <para>
58656 <indexterm role="concept">
58657 <primary><option>authenticated</option> ACL condition</primary>
58658 </indexterm>
58659 <indexterm role="concept">
58660 <primary>authentication</primary>
58661 <secondary>ACL checking</secondary>
58662 </indexterm>
58663 <indexterm role="concept">
58664 <primary>access control lists (ACLs)</primary>
58665 <secondary>testing for authentication</secondary>
58666 </indexterm>
58667 If the SMTP connection is not authenticated, the condition is false. Otherwise,
58668 the name of the authenticator is tested against the list. To test for
58669 authentication by any authenticator, you can set
58670 </para>
58671 <literallayout class="monospaced">
58672 authenticated = *
58673 </literallayout>
58674 </listitem></varlistentry>
58675 <varlistentry>
58676 <term><emphasis role="bold">condition&nbsp;=&nbsp;</emphasis>&lt;<emphasis>string</emphasis>&gt;</term>
58677 <listitem>
58678 <para>
58679 <indexterm role="concept">
58680 <primary><option>condition</option> ACL condition</primary>
58681 </indexterm>
58682 <indexterm role="concept">
58683 <primary>customizing</primary>
58684 <secondary>ACL condition</secondary>
58685 </indexterm>
58686 <indexterm role="concept">
58687 <primary>access control lists (ACLs)</primary>
58688 <secondary>customized test</secondary>
58689 </indexterm>
58690 <indexterm role="concept">
58691 <primary>access control lists (ACLs)</primary>
58692 <secondary>testing, customized</secondary>
58693 </indexterm>
58694 This feature allows you to make up custom conditions. If the result of
58695 expanding the string is an empty string, the number zero, or one of the strings
58696 <quote>no</quote> or <quote>false</quote>, the condition is false. If the result is any non-zero
58697 number, or one of the strings <quote>yes</quote> or <quote>true</quote>, the condition is true. For
58698 any other value, some error is assumed to have occurred, and the ACL returns
58699 <quote>defer</quote>. However, if the expansion is forced to fail, the condition is
58700 ignored. The effect is to treat it as true, whether it is positive or
58701 negative.
58702 </para>
58703 </listitem></varlistentry>
58704 <varlistentry>
58705 <term><emphasis role="bold">decode&nbsp;=&nbsp;</emphasis>&lt;<emphasis>location</emphasis>&gt;</term>
58706 <listitem>
58707 <para>
58708 <indexterm role="concept">
58709 <primary><option>decode</option> ACL condition</primary>
58710 </indexterm>
58711 This condition is available only when Exim is compiled with the
58712 content-scanning extension, and it is allowed only in the ACL defined by
58713 <option>acl_smtp_mime</option>. It causes the current MIME part to be decoded into a file.
58714 If all goes well, the condition is true. It is false only if there are
58715 problems such as a syntax error or a memory shortage. For more details, see
58716 chapter <xref linkend="CHAPexiscan"/>.
58717 </para>
58718 </listitem></varlistentry>
58719 <varlistentry>
58720 <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>
58721 <listitem>
58722 <para>
58723 <indexterm role="concept">
58724 <primary><option>dnslists</option> ACL condition</primary>
58725 </indexterm>
58726 <indexterm role="concept">
58727 <primary>DNS list</primary>
58728 <secondary>in ACL</secondary>
58729 </indexterm>
58730 <indexterm role="concept">
58731 <primary>black list (DNS)</primary>
58732 </indexterm>
58733 <indexterm role="concept">
58734 <primary>access control lists (ACLs)</primary>
58735 <secondary>testing a DNS list</secondary>
58736 </indexterm>
58737 This condition checks for entries in DNS black lists. These are also known as
58738 <quote>RBL lists</quote>, after the original Realtime Blackhole List, but note that the
58739 use of the lists at <emphasis>mail-abuse.org</emphasis> now carries a charge. There are too many
58740 different variants of this condition to describe briefly here. See sections
58741 <xref linkend="SECTmorednslists"/>&ndash;<xref linkend="SECTmorednslistslast"/> for details.
58742 </para>
58743 </listitem></varlistentry>
58744 <varlistentry>
58745 <term><emphasis role="bold">domains&nbsp;=&nbsp;</emphasis>&lt;<emphasis>domain&nbsp;list</emphasis>&gt;</term>
58746 <listitem>
58747 <para>
58748 <indexterm role="concept">
58749 <primary><option>domains</option> ACL condition</primary>
58750 </indexterm>
58751 <indexterm role="concept">
58752 <primary>domain</primary>
58753 <secondary>ACL checking</secondary>
58754 </indexterm>
58755 <indexterm role="concept">
58756 <primary>access control lists (ACLs)</primary>
58757 <secondary>testing a recipient domain</secondary>
58758 </indexterm>
58759 <indexterm role="variable">
58760 <primary><varname>$domain_data</varname></primary>
58761 </indexterm>
58762 This condition is relevant only after a RCPT command. It checks that the domain
58763 of the recipient address is in the domain list. If percent-hack processing is
58764 enabled, it is done before this test is done. If the check succeeds with a
58765 lookup, the result of the lookup is placed in <varname>$domain_data</varname> until the next
58766 <option>domains</option> test.
58767 </para>
58768 <para>
58769 <emphasis role="bold">Note carefully</emphasis> (because many people seem to fall foul of this): you cannot
58770 use <option>domains</option> in a DATA ACL.
58771 </para>
58772 </listitem></varlistentry>
58773 <varlistentry>
58774 <term><emphasis role="bold">encrypted&nbsp;=&nbsp;</emphasis>&lt;<emphasis>string&nbsp;list</emphasis>&gt;</term>
58775 <listitem>
58776 <para>
58777 <indexterm role="concept">
58778 <primary><option>encrypted</option> ACL condition</primary>
58779 </indexterm>
58780 <indexterm role="concept">
58781 <primary>encryption</primary>
58782 <secondary>checking in an ACL</secondary>
58783 </indexterm>
58784 <indexterm role="concept">
58785 <primary>access control lists (ACLs)</primary>
58786 <secondary>testing for encryption</secondary>
58787 </indexterm>
58788 If the SMTP connection is not encrypted, the condition is false. Otherwise, the
58789 name of the cipher suite in use is tested against the list. To test for
58790 encryption without testing for any specific cipher suite(s), set
58791 </para>
58792 <literallayout class="monospaced">
58793 encrypted = *
58794 </literallayout>
58795 </listitem></varlistentry>
58796 <varlistentry>
58797 <term><emphasis role="bold">hosts&nbsp;=&nbsp;</emphasis>&lt;<emphasis>host&nbsp;list</emphasis>&gt;</term>
58798 <listitem>
58799 <para>
58800 <indexterm role="concept">
58801 <primary><option>hosts</option> ACL condition</primary>
58802 </indexterm>
58803 <indexterm role="concept">
58804 <primary>host</primary>
58805 <secondary>ACL checking</secondary>
58806 </indexterm>
58807 <indexterm role="concept">
58808 <primary>access control lists (ACLs)</primary>
58809 <secondary>testing the client host</secondary>
58810 </indexterm>
58811 This condition tests that the calling host matches the host list. If you have
58812 name lookups or wildcarded host names and IP addresses in the same host list,
58813 you should normally put the IP addresses first. For example, you could have:
58814 </para>
58815 <literallayout class="monospaced">
58816 accept hosts = 10.9.8.7 : dbm;/etc/friendly/hosts
58817 </literallayout>
58818 <para>
58819 The lookup in this example uses the host name for its key. This is implied by
58820 the lookup type <quote>dbm</quote>. (For a host address lookup you would use <quote>net-dbm</quote>
58821 and it wouldn&#x2019;t matter which way round you had these two items.)
58822 </para>
58823 <para>
58824 The reason for the problem with host names lies in the left-to-right way that
58825 Exim processes lists. It can test IP addresses without doing any DNS lookups,
58826 but when it reaches an item that requires a host name, it fails if it cannot
58827 find a host name to compare with the pattern. If the above list is given in the
58828 opposite order, the <option>accept</option> statement fails for a host whose name cannot be
58829 found, even if its IP address is 10.9.8.7.
58830 </para>
58831 <para>
58832 If you really do want to do the name check first, and still recognize the IP
58833 address even if the name lookup fails, you can rewrite the ACL like this:
58834 </para>
58835 <literallayout class="monospaced">
58836 accept hosts = dbm;/etc/friendly/hosts
58837 accept hosts = 10.9.8.7
58838 </literallayout>
58839 <para>
58840 The default action on failing to find the host name is to assume that the host
58841 is not in the list, so the first <option>accept</option> statement fails. The second
58842 statement can then check the IP address.
58843 </para>
58844 <para>
58845 <indexterm role="variable">
58846 <primary><varname>$host_data</varname></primary>
58847 </indexterm>
58848 If a <option>hosts</option> condition is satisfied by means of a lookup, the result
58849 of the lookup is made available in the <varname>$host_data</varname> variable. This
58850 allows you, for example, to set up a statement like this:
58851 </para>
58852 <literallayout class="monospaced">
58853 deny  hosts = net-lsearch;/some/file
58854 message = $host_data
58855 </literallayout>
58856 <para>
58857 which gives a custom error message for each denied host.
58858 </para>
58859 </listitem></varlistentry>
58860 <varlistentry>
58861 <term><emphasis role="bold">local_parts&nbsp;=&nbsp;</emphasis>&lt;<emphasis>local&nbsp;part&nbsp;list</emphasis>&gt;</term>
58862 <listitem>
58863 <para>
58864 <indexterm role="concept">
58865 <primary><option>local_parts</option> ACL condition</primary>
58866 </indexterm>
58867 <indexterm role="concept">
58868 <primary>local part</primary>
58869 <secondary>ACL checking</secondary>
58870 </indexterm>
58871 <indexterm role="concept">
58872 <primary>access control lists (ACLs)</primary>
58873 <secondary>testing a local part</secondary>
58874 </indexterm>
58875 <indexterm role="variable">
58876 <primary><varname>$local_part_data</varname></primary>
58877 </indexterm>
58878 This condition is relevant only after a RCPT command. It checks that the local
58879 part of the recipient address is in the list. If percent-hack processing is
58880 enabled, it is done before this test. If the check succeeds with a lookup, the
58881 result of the lookup is placed in <varname>$local_part_data</varname>, which remains set until
58882 the next <option>local_parts</option> test.
58883 </para>
58884 </listitem></varlistentry>
58885 <varlistentry>
58886 <term><emphasis role="bold">malware&nbsp;=&nbsp;</emphasis>&lt;<emphasis>option</emphasis>&gt;</term>
58887 <listitem>
58888 <para>
58889 <indexterm role="concept">
58890 <primary><option>malware</option> ACL condition</primary>
58891 </indexterm>
58892 <indexterm role="concept">
58893 <primary>access control lists (ACLs)</primary>
58894 <secondary>virus scanning</secondary>
58895 </indexterm>
58896 <indexterm role="concept">
58897 <primary>access control lists (ACLs)</primary>
58898 <secondary>scanning for viruses</secondary>
58899 </indexterm>
58900 This condition is available only when Exim is compiled with the
58901 content-scanning extension
58902 and only after a DATA command.
58903 It causes the incoming message to be scanned for
58904 viruses. For details, see chapter <xref linkend="CHAPexiscan"/>.
58905 </para>
58906 </listitem></varlistentry>
58907 <varlistentry>
58908 <term><emphasis role="bold">mime_regex&nbsp;=&nbsp;</emphasis>&lt;<emphasis>list&nbsp;of&nbsp;regular&nbsp;expressions</emphasis>&gt;</term>
58909 <listitem>
58910 <para>
58911 <indexterm role="concept">
58912 <primary><option>mime_regex</option> ACL condition</primary>
58913 </indexterm>
58914 <indexterm role="concept">
58915 <primary>access control lists (ACLs)</primary>
58916 <secondary>testing by regex matching</secondary>
58917 </indexterm>
58918 This condition is available only when Exim is compiled with the
58919 content-scanning extension, and it is allowed only in the ACL defined by
58920 <option>acl_smtp_mime</option>. It causes the current MIME part to be scanned for a match
58921 with any of the regular expressions. For details, see chapter
58922 <xref linkend="CHAPexiscan"/>.
58923 </para>
58924 </listitem></varlistentry>
58925 <varlistentry>
58926 <term><emphasis role="bold">ratelimit&nbsp;=&nbsp;</emphasis>&lt;<emphasis>parameters</emphasis>&gt;</term>
58927 <listitem>
58928 <para>
58929 <indexterm role="concept">
58930 <primary>rate limiting</primary>
58931 </indexterm>
58932 This condition can be used to limit the rate at which a user or host submits
58933 messages. Details are given in section <xref linkend="SECTratelimiting"/>.
58934 </para>
58935 </listitem></varlistentry>
58936 <varlistentry>
58937 <term><emphasis role="bold">recipients&nbsp;=&nbsp;</emphasis>&lt;<emphasis>address&nbsp;list</emphasis>&gt;</term>
58938 <listitem>
58939 <para>
58940 <indexterm role="concept">
58941 <primary><option>recipients</option> ACL condition</primary>
58942 </indexterm>
58943 <indexterm role="concept">
58944 <primary>recipient</primary>
58945 <secondary>ACL checking</secondary>
58946 </indexterm>
58947 <indexterm role="concept">
58948 <primary>access control lists (ACLs)</primary>
58949 <secondary>testing a recipient</secondary>
58950 </indexterm>
58951 This condition is relevant only after a RCPT command. It checks the entire
58952 recipient address against a list of recipients.
58953 </para>
58954 </listitem></varlistentry>
58955 <varlistentry>
58956 <term><emphasis role="bold">regex&nbsp;=&nbsp;</emphasis>&lt;<emphasis>list&nbsp;of&nbsp;regular&nbsp;expressions</emphasis>&gt;</term>
58957 <listitem>
58958 <para>
58959 <indexterm role="concept">
58960 <primary><option>regex</option> ACL condition</primary>
58961 </indexterm>
58962 <indexterm role="concept">
58963 <primary>access control lists (ACLs)</primary>
58964 <secondary>testing by regex matching</secondary>
58965 </indexterm>
58966 This condition is available only when Exim is compiled with the
58967 content-scanning extension, and is available only in the DATA, MIME, and
58968 non-SMTP ACLs. It causes the incoming message to be scanned for a match with
58969 any of the regular expressions. For details, see chapter <xref linkend="CHAPexiscan"/>.
58970 </para>
58971 </listitem></varlistentry>
58972 <varlistentry>
58973 <term><emphasis role="bold">sender_domains&nbsp;=&nbsp;</emphasis>&lt;<emphasis>domain&nbsp;list</emphasis>&gt;</term>
58974 <listitem>
58975 <para>
58976 <indexterm role="concept">
58977 <primary><option>sender_domains</option> ACL condition</primary>
58978 </indexterm>
58979 <indexterm role="concept">
58980 <primary>sender</primary>
58981 <secondary>ACL checking</secondary>
58982 </indexterm>
58983 <indexterm role="concept">
58984 <primary>access control lists (ACLs)</primary>
58985 <secondary>testing a sender domain</secondary>
58986 </indexterm>
58987 <indexterm role="variable">
58988 <primary><varname>$domain</varname></primary>
58989 </indexterm>
58990 <indexterm role="variable">
58991 <primary><varname>$sender_address_domain</varname></primary>
58992 </indexterm>
58993 This condition tests the domain of the sender of the message against the given
58994 domain list. <emphasis role="bold">Note</emphasis>: The domain of the sender address is in
58995 <varname>$sender_address_domain</varname>. It is <emphasis>not</emphasis> put in <varname>$domain</varname> during the testing
58996 of this condition. This is an exception to the general rule for testing domain
58997 lists. It is done this way so that, if this condition is used in an ACL for a
58998 RCPT command, the recipient&#x2019;s domain (which is in <varname>$domain</varname>) can be used to
58999 influence the sender checking.
59000 </para>
59001 <para>
59002 <emphasis role="bold">Warning</emphasis>: It is a bad idea to use this condition on its own as a control on
59003 relaying, because sender addresses are easily, and commonly, forged.
59004 </para>
59005 </listitem></varlistentry>
59006 <varlistentry>
59007 <term><emphasis role="bold">senders&nbsp;=&nbsp;</emphasis>&lt;<emphasis>address&nbsp;list</emphasis>&gt;</term>
59008 <listitem>
59009 <para>
59010 <indexterm role="concept">
59011 <primary><option>senders</option> ACL condition</primary>
59012 </indexterm>
59013 <indexterm role="concept">
59014 <primary>sender</primary>
59015 <secondary>ACL checking</secondary>
59016 </indexterm>
59017 <indexterm role="concept">
59018 <primary>access control lists (ACLs)</primary>
59019 <secondary>testing a sender</secondary>
59020 </indexterm>
59021 This condition tests the sender of the message against the given list. To test
59022 for a bounce message, which has an empty sender, set
59023 </para>
59024 <literallayout class="monospaced">
59025 senders = :
59026 </literallayout>
59027 <para>
59028 <emphasis role="bold">Warning</emphasis>: It is a bad idea to use this condition on its own as a control on
59029 relaying, because sender addresses are easily, and commonly, forged.
59030 </para>
59031 </listitem></varlistentry>
59032 <varlistentry>
59033 <term><emphasis role="bold">spam&nbsp;=&nbsp;</emphasis>&lt;<emphasis>username</emphasis>&gt;</term>
59034 <listitem>
59035 <para>
59036 <indexterm role="concept">
59037 <primary><option>spam</option> ACL condition</primary>
59038 </indexterm>
59039 <indexterm role="concept">
59040 <primary>access control lists (ACLs)</primary>
59041 <secondary>scanning for spam</secondary>
59042 </indexterm>
59043 This condition is available only when Exim is compiled with the
59044 content-scanning extension. It causes the incoming message to be scanned by
59045 SpamAssassin. For details, see chapter <xref linkend="CHAPexiscan"/>.
59046 </para>
59047 </listitem></varlistentry>
59048 <varlistentry>
59049 <term><emphasis role="bold">verify&nbsp;=&nbsp;certificate</emphasis></term>
59050 <listitem>
59051 <para>
59052 <indexterm role="concept">
59053 <primary><option>verify</option> ACL condition</primary>
59054 </indexterm>
59055 <indexterm role="concept">
59056 <primary>TLS</primary>
59057 <secondary>client certificate verification</secondary>
59058 </indexterm>
59059 <indexterm role="concept">
59060 <primary>certificate</primary>
59061 <secondary>verification of client</secondary>
59062 </indexterm>
59063 <indexterm role="concept">
59064 <primary>access control lists (ACLs)</primary>
59065 <secondary>certificate verification</secondary>
59066 </indexterm>
59067 <indexterm role="concept">
59068 <primary>access control lists (ACLs)</primary>
59069 <secondary>testing a TLS certificate</secondary>
59070 </indexterm>
59071 This condition is true in an SMTP session if the session is encrypted, and a
59072 certificate was received from the client, and the certificate was verified. The
59073 server requests a certificate only if the client matches <option>tls_verify_hosts</option>
59074 or <option>tls_try_verify_hosts</option> (see chapter <xref linkend="CHAPTLS"/>).
59075 </para>
59076 </listitem></varlistentry>
59077 <varlistentry>
59078 <term><emphasis role="bold">verify&nbsp;=&nbsp;csa</emphasis></term>
59079 <listitem>
59080 <para>
59081 <indexterm role="concept">
59082 <primary>CSA verification</primary>
59083 </indexterm>
59084 This condition checks whether the sending host (the client) is authorized to
59085 send email. Details of how this works are given in section
59086 <xref linkend="SECTverifyCSA"/>.
59087 </para>
59088 </listitem></varlistentry>
59089 <varlistentry>
59090 <term><emphasis role="bold">verify&nbsp;=&nbsp;header_names_ascii</emphasis></term>
59091 <listitem>
59092 <para>
59093 <indexterm role="concept">
59094 <primary><option>verify</option> ACL condition</primary>
59095 </indexterm>
59096 <indexterm role="concept">
59097 <primary>access control lists (ACLs)</primary>
59098 <secondary>verifying header names only ASCII</secondary>
59099 </indexterm>
59100 <indexterm role="concept">
59101 <primary>header lines</primary>
59102 <secondary>verifying header names only ASCII</secondary>
59103 </indexterm>
59104 <indexterm role="concept">
59105 <primary>verifying</primary>
59106 <secondary>header names only ASCII</secondary>
59107 </indexterm>
59108 This condition is relevant only in an ACL that is run after a message has been
59109 received, that is, in an ACL specified by <option>acl_smtp_data</option> or
59110 <option>acl_not_smtp</option>.  It checks all header names (not the content) to make sure
59111 there are no non-ASCII characters, also excluding control characters.  The
59112 allowable characters are decimal ASCII values 33 through 126.
59113 </para>
59114 <para>
59115 Exim itself will handle headers with non-ASCII characters, but it can cause
59116 problems for downstream applications, so this option will allow their
59117 detection and rejection in the DATA ACL&#x2019;s.
59118 </para>
59119 </listitem></varlistentry>
59120 <varlistentry>
59121 <term><emphasis role="bold">verify&nbsp;=&nbsp;header_sender/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
59122 <listitem>
59123 <para>
59124 <indexterm role="concept">
59125 <primary><option>verify</option> ACL condition</primary>
59126 </indexterm>
59127 <indexterm role="concept">
59128 <primary>access control lists (ACLs)</primary>
59129 <secondary>verifying sender in the header</secondary>
59130 </indexterm>
59131 <indexterm role="concept">
59132 <primary>header lines</primary>
59133 <secondary>verifying the sender in</secondary>
59134 </indexterm>
59135 <indexterm role="concept">
59136 <primary>sender</primary>
59137 <secondary>verifying in header</secondary>
59138 </indexterm>
59139 <indexterm role="concept">
59140 <primary>verifying</primary>
59141 <secondary>sender in header</secondary>
59142 </indexterm>
59143 This condition is relevant only in an ACL that is run after a message has been
59144 received, that is, in an ACL specified by <option>acl_smtp_data</option> or
59145 <option>acl_not_smtp</option>. It checks that there is a verifiable address in at least one
59146 of the <emphasis>Sender:</emphasis>, <emphasis>Reply-To:</emphasis>, or <emphasis>From:</emphasis> header lines. Such an address
59147 is loosely thought of as a <quote>sender</quote> address (hence the name of the test).
59148 However, an address that appears in one of these headers need not be an address
59149 that accepts bounce messages; only sender addresses in envelopes are required
59150 to accept bounces. Therefore, if you use the callout option on this check, you
59151 might want to arrange for a non-empty address in the MAIL command.
59152 </para>
59153 <para>
59154 Details of address verification and the options are given later, starting at
59155 section <xref linkend="SECTaddressverification"/> (callouts are described in section
59156 <xref linkend="SECTcallver"/>). You can combine this condition with the <option>senders</option>
59157 condition to restrict it to bounce messages only:
59158 </para>
59159 <literallayout class="monospaced">
59160 deny    senders = :
59161         message = A valid sender header is required for bounces
59162        !verify  = header_sender
59163 </literallayout>
59164 </listitem></varlistentry>
59165 <varlistentry>
59166 <term><emphasis role="bold">verify&nbsp;=&nbsp;header_syntax</emphasis></term>
59167 <listitem>
59168 <para>
59169 <indexterm role="concept">
59170 <primary><option>verify</option> ACL condition</primary>
59171 </indexterm>
59172 <indexterm role="concept">
59173 <primary>access control lists (ACLs)</primary>
59174 <secondary>verifying header syntax</secondary>
59175 </indexterm>
59176 <indexterm role="concept">
59177 <primary>header lines</primary>
59178 <secondary>verifying syntax</secondary>
59179 </indexterm>
59180 <indexterm role="concept">
59181 <primary>verifying</primary>
59182 <secondary>header syntax</secondary>
59183 </indexterm>
59184 This condition is relevant only in an ACL that is run after a message has been
59185 received, that is, in an ACL specified by <option>acl_smtp_data</option> or
59186 <option>acl_not_smtp</option>. It checks the syntax of all header lines that can contain
59187 lists of addresses (<emphasis>Sender:</emphasis>, <emphasis>From:</emphasis>, <emphasis>Reply-To:</emphasis>, <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>,
59188 and <emphasis>Bcc:</emphasis>), returning true if there are no problems.
59189 Unqualified addresses (local parts without domains) are
59190 permitted only in locally generated messages and from hosts that match
59191 <option>sender_unqualified_hosts</option> or <option>recipient_unqualified_hosts</option>, as
59192 appropriate.
59193 </para>
59194 <para>
59195 Note that this condition is a syntax check only. However, a common spamming
59196 ploy used to be to send syntactically invalid headers such as
59197 </para>
59198 <literallayout class="monospaced">
59199 To: @
59200 </literallayout>
59201 <para>
59202 and this condition can be used to reject such messages, though they are not as
59203 common as they used to be.
59204 </para>
59205 </listitem></varlistentry>
59206 <varlistentry>
59207 <term><emphasis role="bold">verify&nbsp;=&nbsp;helo</emphasis></term>
59208 <listitem>
59209 <para>
59210 <indexterm role="concept">
59211 <primary><option>verify</option> ACL condition</primary>
59212 </indexterm>
59213 <indexterm role="concept">
59214 <primary>access control lists (ACLs)</primary>
59215 <secondary>verifying HELO/EHLO</secondary>
59216 </indexterm>
59217 <indexterm role="concept">
59218 <primary>HELO</primary>
59219 <secondary>verifying</secondary>
59220 </indexterm>
59221 <indexterm role="concept">
59222 <primary>EHLO</primary>
59223 <secondary>verifying</secondary>
59224 </indexterm>
59225 <indexterm role="concept">
59226 <primary>verifying</primary>
59227 <secondary>EHLO</secondary>
59228 </indexterm>
59229 <indexterm role="concept">
59230 <primary>verifying</primary>
59231 <secondary>HELO</secondary>
59232 </indexterm>
59233 This condition is true if a HELO or EHLO command has been received from the
59234 client host, and its contents have been verified. If there has been no previous
59235 attempt to verify the HELO/EHLO contents, it is carried out when this
59236 condition is encountered. See the description of the <option>helo_verify_hosts</option> and
59237 <option>helo_try_verify_hosts</option> options for details of how to request verification
59238 independently of this condition, and for detail of the verification.
59239 </para>
59240 <para>
59241 For SMTP input that does not come over TCP/IP (the <option>-bs</option> command line
59242 option), this condition is always true.
59243 </para>
59244 </listitem></varlistentry>
59245 <varlistentry>
59246 <term><emphasis role="bold">verify&nbsp;=&nbsp;not_blind/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
59247 <listitem>
59248 <para>
59249 <indexterm role="concept">
59250 <primary>verifying</primary>
59251 <secondary>not blind</secondary>
59252 </indexterm>
59253 <indexterm role="concept">
59254 <primary>bcc recipients, verifying none</primary>
59255 </indexterm>
59256 This condition checks that there are no blind (bcc) recipients in the message.
59257 Every envelope recipient must appear either in a <emphasis>To:</emphasis> header line or in a
59258 <emphasis>Cc:</emphasis> header line for this condition to be true. Local parts are checked
59259 case-sensitively; domains are checked case-insensitively. If <emphasis>Resent-To:</emphasis> or
59260 <emphasis>Resent-Cc:</emphasis> header lines exist, they are also checked. This condition can be
59261 used only in a DATA or non-SMTP ACL.
59262 </para>
59263 <para revisionflag="changed">
59264 There is one possible option, <literal>case_insensitive</literal>.  If this is present then
59265 local parts are checked case-insensitively.
59266 </para>
59267 <para>
59268 There are, of course, many legitimate messages that make use of blind (bcc)
59269 recipients. This check should not be used on its own for blocking messages.
59270 </para>
59271 </listitem></varlistentry>
59272 <varlistentry>
59273 <term><emphasis role="bold">verify&nbsp;=&nbsp;recipient/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
59274 <listitem>
59275 <para>
59276 <indexterm role="concept">
59277 <primary><option>verify</option> ACL condition</primary>
59278 </indexterm>
59279 <indexterm role="concept">
59280 <primary>access control lists (ACLs)</primary>
59281 <secondary>verifying recipient</secondary>
59282 </indexterm>
59283 <indexterm role="concept">
59284 <primary>recipient</primary>
59285 <secondary>verifying</secondary>
59286 </indexterm>
59287 <indexterm role="concept">
59288 <primary>verifying</primary>
59289 <secondary>recipient</secondary>
59290 </indexterm>
59291 <indexterm role="variable">
59292 <primary><varname>$address_data</varname></primary>
59293 </indexterm>
59294 This condition is relevant only after a RCPT command. It verifies the current
59295 recipient. Details of address verification are given later, starting at section
59296 <xref linkend="SECTaddressverification"/>. After a recipient has been verified, the value
59297 of <varname>$address_data</varname> is the last value that was set while routing the address.
59298 This applies even if the verification fails. When an address that is being
59299 verified is redirected to a single address, verification continues with the new
59300 address, and in that case, the subsequent value of <varname>$address_data</varname> is the
59301 value for the child address.
59302 </para>
59303 </listitem></varlistentry>
59304 <varlistentry>
59305 <term><emphasis role="bold">verify&nbsp;=&nbsp;reverse_host_lookup/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
59306 <listitem>
59307 <para>
59308 <indexterm role="concept">
59309 <primary><option>verify</option> ACL condition</primary>
59310 </indexterm>
59311 <indexterm role="concept">
59312 <primary>access control lists (ACLs)</primary>
59313 <secondary>verifying host reverse lookup</secondary>
59314 </indexterm>
59315 <indexterm role="concept">
59316 <primary>host</primary>
59317 <secondary>verifying reverse lookup</secondary>
59318 </indexterm>
59319 This condition ensures that a verified host name has been looked up from the IP
59320 address of the client host. (This may have happened already if the host name
59321 was needed for checking a host list, or if the host matched <option>host_lookup</option>.)
59322 Verification ensures that the host name obtained from a reverse DNS lookup, or
59323 one of its aliases, does, when it is itself looked up in the DNS, yield the
59324 original IP address.
59325 </para>
59326 <para>
59327 There is one possible option, <literal>defer_ok</literal>.  If this is present and a
59328 DNS operation returns a temporary error, the verify condition succeeds.
59329 </para>
59330 <para>
59331 If this condition is used for a locally generated message (that is, when there
59332 is no client host involved), it always succeeds.
59333 </para>
59334 </listitem></varlistentry>
59335 <varlistentry>
59336 <term><emphasis role="bold">verify&nbsp;=&nbsp;sender/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
59337 <listitem>
59338 <para>
59339 <indexterm role="concept">
59340 <primary><option>verify</option> ACL condition</primary>
59341 </indexterm>
59342 <indexterm role="concept">
59343 <primary>access control lists (ACLs)</primary>
59344 <secondary>verifying sender</secondary>
59345 </indexterm>
59346 <indexterm role="concept">
59347 <primary>sender</primary>
59348 <secondary>verifying</secondary>
59349 </indexterm>
59350 <indexterm role="concept">
59351 <primary>verifying</primary>
59352 <secondary>sender</secondary>
59353 </indexterm>
59354 This condition is relevant only after a MAIL or RCPT command, or after a
59355 message has been received (the <option>acl_smtp_data</option> or <option>acl_not_smtp</option> ACLs). If
59356 the message&#x2019;s sender is empty (that is, this is a bounce message), the
59357 condition is true. Otherwise, the sender address is verified.
59358 </para>
59359 <para>
59360 <indexterm role="variable">
59361 <primary><varname>$address_data</varname></primary>
59362 </indexterm>
59363 <indexterm role="variable">
59364 <primary><varname>$sender_address_data</varname></primary>
59365 </indexterm>
59366 If there is data in the <varname>$address_data</varname> variable at the end of routing, its
59367 value is placed in <varname>$sender_address_data</varname> at the end of verification. This
59368 value can be used in subsequent conditions and modifiers in the same ACL
59369 statement. It does not persist after the end of the current statement. If you
59370 want to preserve the value for longer, you can save it in an ACL variable.
59371 </para>
59372 <para>
59373 Details of verification are given later, starting at section
59374 <xref linkend="SECTaddressverification"/>. Exim caches the result of sender verification,
59375 to avoid doing it more than once per message.
59376 </para>
59377 </listitem></varlistentry>
59378 <varlistentry>
59379 <term><emphasis role="bold">verify&nbsp;=&nbsp;sender=</emphasis>&lt;<emphasis>address</emphasis>&gt;<emphasis role="bold">/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
59380 <listitem>
59381 <para>
59382 <indexterm role="concept">
59383 <primary><option>verify</option> ACL condition</primary>
59384 </indexterm>
59385 This is a variation of the previous option, in which a modified address is
59386 verified as a sender.
59387 </para>
59388 <para>
59389 Note that &#x2019;/&#x2019; is legal in local-parts; if the address may have such
59390 (eg. is generated from the received message)
59391 they must be protected from the options parsing by doubling:
59392 </para>
59393 <literallayout class="monospaced">
59394 verify = sender=${sg{${address:$h_sender:}}{/}{//}}
59395 </literallayout>
59396 </listitem></varlistentry>
59397 </variablelist>
59398 </section>
59399 <section id="SECTmorednslists">
59400 <title>Using DNS lists</title>
59401 <para>
59402 <indexterm role="concept">
59403 <primary>DNS list</primary>
59404 <secondary>in ACL</secondary>
59405 </indexterm>
59406 <indexterm role="concept">
59407 <primary>black list (DNS)</primary>
59408 </indexterm>
59409 <indexterm role="concept">
59410 <primary>access control lists (ACLs)</primary>
59411 <secondary>testing a DNS list</secondary>
59412 </indexterm>
59413 In its simplest form, the <option>dnslists</option> condition tests whether the calling host
59414 is on at least one of a number of DNS lists by looking up the inverted IP
59415 address in one or more DNS domains. (Note that DNS list domains are not mail
59416 domains, so the <literal>+</literal> syntax for named lists doesn&#x2019;t work - it is used for
59417 special options instead.) For example, if the calling host&#x2019;s IP
59418 address is 192.168.62.43, and the ACL statement is
59419 </para>
59420 <literallayout class="monospaced">
59421 deny dnslists = blackholes.mail-abuse.org : \
59422                 dialups.mail-abuse.org
59423 </literallayout>
59424 <para>
59425 the following records are looked up:
59426 </para>
59427 <literallayout class="monospaced">
59428 43.62.168.192.blackholes.mail-abuse.org
59429 43.62.168.192.dialups.mail-abuse.org
59430 </literallayout>
59431 <para>
59432 As soon as Exim finds an existing DNS record, processing of the list stops.
59433 Thus, multiple entries on the list provide an <quote>or</quote> conjunction. If you want
59434 to test that a host is on more than one list (an <quote>and</quote> conjunction), you can
59435 use two separate conditions:
59436 </para>
59437 <literallayout class="monospaced">
59438 deny dnslists = blackholes.mail-abuse.org
59439      dnslists = dialups.mail-abuse.org
59440 </literallayout>
59441 <para>
59442 If a DNS lookup times out or otherwise fails to give a decisive answer, Exim
59443 behaves as if the host does not match the list item, that is, as if the DNS
59444 record does not exist. If there are further items in the DNS list, they are
59445 processed.
59446 </para>
59447 <para>
59448 This is usually the required action when <option>dnslists</option> is used with <option>deny</option>
59449 (which is the most common usage), because it prevents a DNS failure from
59450 blocking mail. However, you can change this behaviour by putting one of the
59451 following special items in the list:
59452 </para>
59453 <literallayout>
59454 <literal>+include_unknown </literal>   behave as if the item is on the list
59455 <literal>+exclude_unknown </literal>   behave as if the item is not on the list (default)
59456 <literal>+defer_unknown   </literal>   give a temporary error
59457 </literallayout>
59458 <para>
59459 <indexterm role="concept">
59460 <primary><literal>+include_unknown</literal></primary>
59461 </indexterm>
59462 <indexterm role="concept">
59463 <primary><literal>+exclude_unknown</literal></primary>
59464 </indexterm>
59465 <indexterm role="concept">
59466 <primary><literal>+defer_unknown</literal></primary>
59467 </indexterm>
59468 Each of these applies to any subsequent items on the list. For example:
59469 </para>
59470 <literallayout class="monospaced">
59471 deny dnslists = +defer_unknown : foo.bar.example
59472 </literallayout>
59473 <para>
59474 Testing the list of domains stops as soon as a match is found. If you want to
59475 warn for one list and block for another, you can use two different statements:
59476 </para>
59477 <literallayout class="monospaced">
59478 deny  dnslists = blackholes.mail-abuse.org
59479 warn  message  = X-Warn: sending host is on dialups list
59480       dnslists = dialups.mail-abuse.org
59481 </literallayout>
59482 <para>
59483 <indexterm role="concept">
59484 <primary>caching</primary>
59485 <secondary>of dns lookup</secondary>
59486 </indexterm>
59487 <indexterm role="concept">
59488 <primary>DNS</primary>
59489 <secondary>TTL</secondary>
59490 </indexterm>
59491 DNS list lookups are cached by Exim for the duration of the SMTP session
59492 (but limited by the DNS return TTL value),
59493 so a lookup based on the IP address is done at most once for any incoming
59494 connection (assuming long-enough TTL).
59495 Exim does not share information between multiple incoming
59496 connections (but your local name server cache should be active).
59497 </para>
59498 <para>
59499 There are a number of DNS lists to choose from, some commercial, some free,
59500 or free for small deployments.  An overview can be found at
59501 <emphasis role="bold"><ulink url="https://en.wikipedia.org/wiki/Comparison_of_DNS_blacklists">https://en.wikipedia.org/wiki/Comparison_of_DNS_blacklists</ulink></emphasis>.
59502 </para>
59503 </section>
59504 <section id="SECID201">
59505 <title>Specifying the IP address for a DNS list lookup</title>
59506 <para>
59507 <indexterm role="concept">
59508 <primary>DNS list</primary>
59509 <secondary>keyed by explicit IP address</secondary>
59510 </indexterm>
59511 By default, the IP address that is used in a DNS list lookup is the IP address
59512 of the calling host. However, you can specify another IP address by listing it
59513 after the domain name, introduced by a slash. For example:
59514 </para>
59515 <literallayout class="monospaced">
59516 deny dnslists = black.list.tld/192.168.1.2
59517 </literallayout>
59518 <para>
59519 This feature is not very helpful with explicit IP addresses; it is intended for
59520 use with IP addresses that are looked up, for example, the IP addresses of the
59521 MX hosts or nameservers of an email sender address. For an example, see section
59522 <xref linkend="SECTmulkeyfor"/> below.
59523 </para>
59524 </section>
59525 <section id="SECID202">
59526 <title>DNS lists keyed on domain names</title>
59527 <para>
59528 <indexterm role="concept">
59529 <primary>DNS list</primary>
59530 <secondary>keyed by domain name</secondary>
59531 </indexterm>
59532 There are some lists that are keyed on domain names rather than inverted IP
59533 addresses (see, e.g., the <emphasis>domain based zones</emphasis> link at
59534 <emphasis role="bold"><ulink url="http://www.rfc-ignorant.org/">http://www.rfc-ignorant.org/</ulink></emphasis>). No reversing of components is used
59535 with these lists. You can change the name that is looked up in a DNS list by
59536 listing it after the domain name, introduced by a slash. For example,
59537 </para>
59538 <literallayout class="monospaced">
59539 deny  message  = Sender's domain is listed at $dnslist_domain
59540       dnslists = dsn.rfc-ignorant.org/$sender_address_domain
59541 </literallayout>
59542 <para>
59543 This particular example is useful only in ACLs that are obeyed after the
59544 RCPT or DATA commands, when a sender address is available. If (for
59545 example) the message&#x2019;s sender is <emphasis>user@tld.example</emphasis> the name that is looked
59546 up by this example is
59547 </para>
59548 <literallayout class="monospaced">
59549 tld.example.dsn.rfc-ignorant.org
59550 </literallayout>
59551 <para>
59552 A single <option>dnslists</option> condition can contain entries for both names and IP
59553 addresses. For example:
59554 </para>
59555 <literallayout class="monospaced">
59556 deny dnslists = sbl.spamhaus.org : \
59557                 dsn.rfc-ignorant.org/$sender_address_domain
59558 </literallayout>
59559 <para>
59560 The first item checks the sending host&#x2019;s IP address; the second checks a domain
59561 name. The whole condition is true if either of the DNS lookups succeeds.
59562 </para>
59563 </section>
59564 <section id="SECTmulkeyfor">
59565 <title>Multiple explicit keys for a DNS list</title>
59566 <para>
59567 <indexterm role="concept">
59568 <primary>DNS list</primary>
59569 <secondary>multiple keys for</secondary>
59570 </indexterm>
59571 The syntax described above for looking up explicitly-defined values (either
59572 names or IP addresses) in a DNS blacklist is a simplification. After the domain
59573 name for the DNS list, what follows the slash can in fact be a list of items.
59574 As with all lists in Exim, the default separator is a colon. However, because
59575 this is a sublist within the list of DNS blacklist domains, it is necessary
59576 either to double the separators like this:
59577 </para>
59578 <literallayout class="monospaced">
59579 dnslists = black.list.tld/name.1::name.2
59580 </literallayout>
59581 <para>
59582 or to change the separator character, like this:
59583 </para>
59584 <literallayout class="monospaced">
59585 dnslists = black.list.tld/&lt;;name.1;name.2
59586 </literallayout>
59587 <para>
59588 If an item in the list is an IP address, it is inverted before the DNS
59589 blacklist domain is appended. If it is not an IP address, no inversion
59590 occurs. Consider this condition:
59591 </para>
59592 <literallayout class="monospaced">
59593 dnslists = black.list.tld/&lt;;192.168.1.2;a.domain
59594 </literallayout>
59595 <para>
59596 The DNS lookups that occur are:
59597 </para>
59598 <literallayout class="monospaced">
59599 2.1.168.192.black.list.tld
59600 a.domain.black.list.tld
59601 </literallayout>
59602 <para>
59603 Once a DNS record has been found (that matches a specific IP return
59604 address, if specified &ndash; see section <xref linkend="SECTaddmatcon"/>), no further lookups
59605 are done. If there is a temporary DNS error, the rest of the sublist of domains
59606 or IP addresses is tried. A temporary error for the whole dnslists item occurs
59607 only if no other DNS lookup in this sublist succeeds. In other words, a
59608 successful lookup for any of the items in the sublist overrides a temporary
59609 error for a previous item.
59610 </para>
59611 <para>
59612 The ability to supply a list of items after the slash is in some sense just a
59613 syntactic convenience. These two examples have the same effect:
59614 </para>
59615 <literallayout class="monospaced">
59616 dnslists = black.list.tld/a.domain : black.list.tld/b.domain
59617 dnslists = black.list.tld/a.domain::b.domain
59618 </literallayout>
59619 <para>
59620 However, when the data for the list is obtained from a lookup, the second form
59621 is usually much more convenient. Consider this example:
59622 </para>
59623 <literallayout class="monospaced">
59624 deny message  = The mail servers for the domain \
59625                 $sender_address_domain \
59626                 are listed at $dnslist_domain ($dnslist_value); \
59627                 see $dnslist_text.
59628      dnslists = sbl.spamhaus.org/&lt;|${lookup dnsdb {&gt;|a=&lt;|\
59629                                    ${lookup dnsdb {&gt;|mxh=\
59630                                    $sender_address_domain} }} }
59631 </literallayout>
59632 <para>
59633 Note the use of <literal>&gt;|</literal> in the dnsdb lookup to specify the separator for
59634 multiple DNS records. The inner dnsdb lookup produces a list of MX hosts
59635 and the outer dnsdb lookup finds the IP addresses for these hosts. The result
59636 of expanding the condition might be something like this:
59637 </para>
59638 <literallayout class="monospaced">
59639 dnslists = sbl.spamhaus.org/&lt;|192.168.2.3|192.168.5.6|...
59640 </literallayout>
59641 <para>
59642 Thus, this example checks whether or not the IP addresses of the sender
59643 domain&#x2019;s mail servers are on the Spamhaus black list.
59644 </para>
59645 <para>
59646 The key that was used for a successful DNS list lookup is put into the variable
59647 <varname>$dnslist_matched</varname> (see section <xref linkend="SECID204"/>).
59648 </para>
59649 </section>
59650 <section id="SECID203">
59651 <title>Data returned by DNS lists</title>
59652 <para>
59653 <indexterm role="concept">
59654 <primary>DNS list</primary>
59655 <secondary>data returned from</secondary>
59656 </indexterm>
59657 DNS lists are constructed using address records in the DNS. The original RBL
59658 just used the address 127.0.0.1 on the right hand side of each record, but the
59659 RBL+ list and some other lists use a number of values with different meanings.
59660 The values used on the RBL+ list are:
59661 </para>
59662 <literallayout>
59663 127.1.0.1  RBL
59664 127.1.0.2  DUL
59665 127.1.0.3  DUL and RBL
59666 127.1.0.4  RSS
59667 127.1.0.5  RSS and RBL
59668 127.1.0.6  RSS and DUL
59669 127.1.0.7  RSS and DUL and RBL
59670 </literallayout>
59671 <para>
59672 Section <xref linkend="SECTaddmatcon"/> below describes how you can distinguish between
59673 different values. Some DNS lists may return more than one address record;
59674 see section <xref linkend="SECThanmuldnsrec"/> for details of how they are checked.
59675 </para>
59676 </section>
59677 <section id="SECID204">
59678 <title>Variables set from DNS lists</title>
59679 <para>
59680 <indexterm role="concept">
59681 <primary>expansion</primary>
59682 <secondary>variables, set from DNS list</secondary>
59683 </indexterm>
59684 <indexterm role="concept">
59685 <primary>DNS list</primary>
59686 <secondary>variables set from</secondary>
59687 </indexterm>
59688 <indexterm role="variable">
59689 <primary><varname>$dnslist_domain</varname></primary>
59690 </indexterm>
59691 <indexterm role="variable">
59692 <primary><varname>$dnslist_matched</varname></primary>
59693 </indexterm>
59694 <indexterm role="variable">
59695 <primary><varname>$dnslist_text</varname></primary>
59696 </indexterm>
59697 <indexterm role="variable">
59698 <primary><varname>$dnslist_value</varname></primary>
59699 </indexterm>
59700 When an entry is found in a DNS list, the variable <varname>$dnslist_domain</varname> contains
59701 the name of the overall domain that matched (for example,
59702 <literal>spamhaus.example</literal>), <varname>$dnslist_matched</varname> contains the key within that domain
59703 (for example, <literal>192.168.5.3</literal>), and <varname>$dnslist_value</varname> contains the data from
59704 the DNS record. When the key is an IP address, it is not reversed in
59705 <varname>$dnslist_matched</varname> (though it is, of course, in the actual lookup). In simple
59706 cases, for example:
59707 </para>
59708 <literallayout class="monospaced">
59709 deny dnslists = spamhaus.example
59710 </literallayout>
59711 <para>
59712 the key is also available in another variable (in this case,
59713 <varname>$sender_host_address</varname>). In more complicated cases, however, this is not true.
59714 For example, using a data lookup (as described in section <xref linkend="SECTmulkeyfor"/>)
59715 might generate a dnslists lookup like this:
59716 </para>
59717 <literallayout class="monospaced">
59718 deny dnslists = spamhaus.example/&lt;|192.168.1.2|192.168.6.7|...
59719 </literallayout>
59720 <para>
59721 If this condition succeeds, the value in <varname>$dnslist_matched</varname> might be
59722 <literal>192.168.6.7</literal> (for example).
59723 </para>
59724 <para>
59725 If more than one address record is returned by the DNS lookup, all the IP
59726 addresses are included in <varname>$dnslist_value</varname>, separated by commas and spaces.
59727 The variable <varname>$dnslist_text</varname> contains the contents of any associated TXT
59728 record. For lists such as RBL+ the TXT record for a merged entry is often not
59729 very meaningful. See section <xref linkend="SECTmordetinf"/> for a way of obtaining more
59730 information.
59731 </para>
59732 <para>
59733 You can use the DNS list variables in <option>message</option> or <option>log_message</option> modifiers
59734 &ndash; although these appear before the condition in the ACL, they are not
59735 expanded until after it has failed. For example:
59736 </para>
59737 <literallayout class="monospaced">
59738 deny    hosts = !+local_networks
59739         message = $sender_host_address is listed \
59740                   at $dnslist_domain
59741         dnslists = rbl-plus.mail-abuse.example
59742 </literallayout>
59743 </section>
59744 <section id="SECTaddmatcon">
59745 <title>Additional matching conditions for DNS lists</title>
59746 <para>
59747 <indexterm role="concept">
59748 <primary>DNS list</primary>
59749 <secondary>matching specific returned data</secondary>
59750 </indexterm>
59751 You can add an equals sign and an IP address after a <option>dnslists</option> domain name
59752 in order to restrict its action to DNS records with a matching right hand side.
59753 For example,
59754 </para>
59755 <literallayout class="monospaced">
59756 deny dnslists = rblplus.mail-abuse.org=127.0.0.2
59757 </literallayout>
59758 <para>
59759 rejects only those hosts that yield 127.0.0.2. Without this additional data,
59760 any address record is considered to be a match. For the moment, we assume
59761 that the DNS lookup returns just one record. Section <xref linkend="SECThanmuldnsrec"/>
59762 describes how multiple records are handled.
59763 </para>
59764 <para>
59765 More than one IP address may be given for checking, using a comma as a
59766 separator. These are alternatives &ndash; if any one of them matches, the
59767 <option>dnslists</option> condition is true. For example:
59768 </para>
59769 <literallayout class="monospaced">
59770 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
59771 </literallayout>
59772 <para>
59773 If you want to specify a constraining address list and also specify names or IP
59774 addresses to be looked up, the constraining address list must be specified
59775 first. For example:
59776 </para>
59777 <literallayout class="monospaced">
59778 deny dnslists = dsn.rfc-ignorant.org\
59779                 =127.0.0.2/$sender_address_domain
59780 </literallayout>
59781 <para>
59782 If the character <literal>&amp;</literal> is used instead of <literal>=</literal>, the comparison for each
59783 listed IP address is done by a bitwise <quote>and</quote> instead of by an equality test.
59784 In other words, the listed addresses are used as bit masks. The comparison is
59785 true if all the bits in the mask are present in the address that is being
59786 tested. For example:
59787 </para>
59788 <literallayout class="monospaced">
59789 dnslists = a.b.c&amp;0.0.0.3
59790 </literallayout>
59791 <para>
59792 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
59793 want to test whether one bit or another bit is present (as opposed to both
59794 being present), you must use multiple values. For example:
59795 </para>
59796 <literallayout class="monospaced">
59797 dnslists = a.b.c&amp;0.0.0.1,0.0.0.2
59798 </literallayout>
59799 <para>
59800 matches if the final component of the address is an odd number or two times
59801 an odd number.
59802 </para>
59803 </section>
59804 <section id="SECID205">
59805 <title>Negated DNS matching conditions</title>
59806 <para>
59807 You can supply a negative list of IP addresses as part of a <option>dnslists</option>
59808 condition. Whereas
59809 </para>
59810 <literallayout class="monospaced">
59811 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
59812 </literallayout>
59813 <para>
59814 means <quote>deny if the host is in the black list at the domain <emphasis>a.b.c</emphasis> and the
59815 IP address yielded by the list is either 127.0.0.2 or 127.0.0.3</quote>,
59816 </para>
59817 <literallayout class="monospaced">
59818 deny  dnslists = a.b.c!=127.0.0.2,127.0.0.3
59819 </literallayout>
59820 <para>
59821 means <quote>deny if the host is in the black list at the domain <emphasis>a.b.c</emphasis> and the
59822 IP address yielded by the list is not 127.0.0.2 and not 127.0.0.3</quote>. In other
59823 words, the result of the test is inverted if an exclamation mark appears before
59824 the <literal>=</literal> (or the <literal>&amp;</literal>) sign.
59825 </para>
59826 <para>
59827 <emphasis role="bold">Note</emphasis>: This kind of negation is not the same as negation in a domain,
59828 host, or address list (which is why the syntax is different).
59829 </para>
59830 <para>
59831 If you are using just one list, the negation syntax does not gain you much. The
59832 previous example is precisely equivalent to
59833 </para>
59834 <literallayout class="monospaced">
59835 deny  dnslists = a.b.c
59836      !dnslists = a.b.c=127.0.0.2,127.0.0.3
59837 </literallayout>
59838 <para>
59839 However, if you are using multiple lists, the negation syntax is clearer.
59840 Consider this example:
59841 </para>
59842 <literallayout class="monospaced">
59843 deny  dnslists = sbl.spamhaus.org : \
59844                  list.dsbl.org : \
59845                  dnsbl.njabl.org!=127.0.0.3 : \
59846                  relays.ordb.org
59847 </literallayout>
59848 <para>
59849 Using only positive lists, this would have to be:
59850 </para>
59851 <literallayout class="monospaced">
59852 deny  dnslists = sbl.spamhaus.org : \
59853                  list.dsbl.org
59854 deny  dnslists = dnsbl.njabl.org
59855      !dnslists = dnsbl.njabl.org=127.0.0.3
59856 deny  dnslists = relays.ordb.org
59857 </literallayout>
59858 <para>
59859 which is less clear, and harder to maintain.
59860 </para>
59861 </section>
59862 <section id="SECThanmuldnsrec">
59863 <title>Handling multiple DNS records from a DNS list</title>
59864 <para>
59865 A DNS lookup for a <option>dnslists</option> condition may return more than one DNS record,
59866 thereby providing more than one IP address. When an item in a <option>dnslists</option> list
59867 is followed by <literal>=</literal> or <literal>&amp;</literal> and a list of IP addresses, in order to restrict
59868 the match to specific results from the DNS lookup, there are two ways in which
59869 the checking can be handled. For example, consider the condition:
59870 </para>
59871 <literallayout class="monospaced">
59872 dnslists = a.b.c=127.0.0.1
59873 </literallayout>
59874 <para>
59875 What happens if the DNS lookup for the incoming IP address yields both
59876 127.0.0.1 and 127.0.0.2 by means of two separate DNS records? Is the
59877 condition true because at least one given value was found, or is it false
59878 because at least one of the found values was not listed? And how does this
59879 affect negated conditions? Both possibilities are provided for with the help of
59880 additional separators <literal>==</literal> and <literal>=&amp;</literal>.
59881 </para>
59882 <itemizedlist>
59883 <listitem>
59884 <para>
59885 If <literal>=</literal> or <literal>&amp;</literal> is used, the condition is true if any one of the looked up
59886 IP addresses matches one of the listed addresses. For the example above, the
59887 condition is true because 127.0.0.1 matches.
59888 </para>
59889 </listitem>
59890 <listitem>
59891 <para>
59892 If <literal>==</literal> or <literal>=&amp;</literal> is used, the condition is true only if every one of the
59893 looked up IP addresses matches one of the listed addresses. If the condition is
59894 changed to:
59895 </para>
59896 <literallayout class="monospaced">
59897 dnslists = a.b.c==127.0.0.1
59898 </literallayout>
59899 <para>
59900 and the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
59901 false because 127.0.0.2 is not listed. You would need to have:
59902 </para>
59903 <literallayout class="monospaced">
59904 dnslists = a.b.c==127.0.0.1,127.0.0.2
59905 </literallayout>
59906 <para>
59907 for the condition to be true.
59908 </para>
59909 </listitem>
59910 </itemizedlist>
59911 <para>
59912 When <literal>!</literal> is used to negate IP address matching, it inverts the result, giving
59913 the precise opposite of the behaviour above. Thus:
59914 </para>
59915 <itemizedlist>
59916 <listitem>
59917 <para>
59918 If <literal>!=</literal> or <literal>!&amp;</literal> is used, the condition is true if none of the looked up IP
59919 addresses matches one of the listed addresses. Consider:
59920 </para>
59921 <literallayout class="monospaced">
59922 dnslists = a.b.c!&amp;0.0.0.1
59923 </literallayout>
59924 <para>
59925 If the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
59926 false because 127.0.0.1 matches.
59927 </para>
59928 </listitem>
59929 <listitem>
59930 <para>
59931 If <literal>!==</literal> or <literal>!=&amp;</literal> is used, the condition is true if there is at least one
59932 looked up IP address that does not match. Consider:
59933 </para>
59934 <literallayout class="monospaced">
59935 dnslists = a.b.c!=&amp;0.0.0.1
59936 </literallayout>
59937 <para>
59938 If the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
59939 true, because 127.0.0.2 does not match. You would need to have:
59940 </para>
59941 <literallayout class="monospaced">
59942 dnslists = a.b.c!=&amp;0.0.0.1,0.0.0.2
59943 </literallayout>
59944 <para>
59945 for the condition to be false.
59946 </para>
59947 </listitem>
59948 </itemizedlist>
59949 <para>
59950 When the DNS lookup yields only a single IP address, there is no difference
59951 between <literal>=</literal> and <literal>==</literal> and between <literal>&amp;</literal> and <literal>=&amp;</literal>.
59952 </para>
59953 </section>
59954 <section id="SECTmordetinf">
59955 <title>Detailed information from merged DNS lists</title>
59956 <para>
59957 <indexterm role="concept">
59958 <primary>DNS list</primary>
59959 <secondary>information from merged</secondary>
59960 </indexterm>
59961 When the facility for restricting the matching IP values in a DNS list is used,
59962 the text from the TXT record that is set in <varname>$dnslist_text</varname> may not reflect
59963 the true reason for rejection. This happens when lists are merged and the IP
59964 address in the A record is used to distinguish them; unfortunately there is
59965 only one TXT record. One way round this is not to use merged lists, but that
59966 can be inefficient because it requires multiple DNS lookups where one would do
59967 in the vast majority of cases when the host of interest is not on any of the
59968 lists.
59969 </para>
59970 <para>
59971 A less inefficient way of solving this problem is available. If
59972 two domain names, comma-separated, are given, the second is used first to
59973 do an initial check, making use of any IP value restrictions that are set.
59974 If there is a match, the first domain is used, without any IP value
59975 restrictions, to get the TXT record. As a byproduct of this, there is also
59976 a check that the IP being tested is indeed on the first list. The first
59977 domain is the one that is put in <varname>$dnslist_domain</varname>. For example:
59978 </para>
59979 <literallayout class="monospaced">
59980 deny message  = \
59981          rejected because $sender_host_address is blacklisted \
59982          at $dnslist_domain\n$dnslist_text
59983        dnslists = \
59984          sbl.spamhaus.org,sbl-xbl.spamhaus.org=127.0.0.2 : \
59985          dul.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.10
59986 </literallayout>
59987 <para>
59988 For the first blacklist item, this starts by doing a lookup in
59989 <emphasis>sbl-xbl.spamhaus.org</emphasis> and testing for a 127.0.0.2 return. If there is a
59990 match, it then looks in <emphasis>sbl.spamhaus.org</emphasis>, without checking the return
59991 value, and as long as something is found, it looks for the corresponding TXT
59992 record. If there is no match in <emphasis>sbl-xbl.spamhaus.org</emphasis>, nothing more is done.
59993 The second blacklist item is processed similarly.
59994 </para>
59995 <para>
59996 If you are interested in more than one merged list, the same list must be
59997 given several times, but because the results of the DNS lookups are cached,
59998 the DNS calls themselves are not repeated. For example:
59999 </para>
60000 <literallayout class="monospaced">
60001 deny dnslists = \
60002          http.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.2 : \
60003          socks.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.3 : \
60004          misc.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.4 : \
60005          dul.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.10
60006 </literallayout>
60007 <para>
60008 In this case there is one lookup in <emphasis>dnsbl.sorbs.net</emphasis>, and if none of the IP
60009 values matches (or if no record is found), this is the only lookup that is
60010 done. Only if there is a match is one of the more specific lists consulted.
60011 </para>
60012 </section>
60013 <section id="SECTmorednslistslast">
60014 <title>DNS lists and IPv6</title>
60015 <para>
60016 <indexterm role="concept">
60017 <primary>IPv6</primary>
60018 <secondary>DNS black lists</secondary>
60019 </indexterm>
60020 <indexterm role="concept">
60021 <primary>DNS list</primary>
60022 <secondary>IPv6 usage</secondary>
60023 </indexterm>
60024 If Exim is asked to do a dnslist lookup for an IPv6 address, it inverts it
60025 nibble by nibble. For example, if the calling host&#x2019;s IP address is
60026 3ffe:ffff:836f:0a00:000a:0800:200a:c031, Exim might look up
60027 </para>
60028 <literallayout class="monospaced">
60029 1.3.0.c.a.0.0.2.0.0.8.0.a.0.0.0.0.0.a.0.f.6.3.8.
60030   f.f.f.f.e.f.f.3.blackholes.mail-abuse.org
60031 </literallayout>
60032 <para>
60033 (split over two lines here to fit on the page). Unfortunately, some of the DNS
60034 lists contain wildcard records, intended for IPv4, that interact badly with
60035 IPv6. For example, the DNS entry
60036 </para>
60037 <literallayout class="monospaced">
60038 *.3.some.list.example.    A    127.0.0.1
60039 </literallayout>
60040 <para>
60041 is probably intended to put the entire 3.0.0.0/8 IPv4 network on the list.
60042 Unfortunately, it also matches the entire 3::/4 IPv6 network.
60043 </para>
60044 <para>
60045 You can exclude IPv6 addresses from DNS lookups by making use of a suitable
60046 <option>condition</option> condition, as in this example:
60047 </para>
60048 <literallayout class="monospaced">
60049 deny   condition = ${if isip4{$sender_host_address}}
60050        dnslists  = some.list.example
60051 </literallayout>
60052 <para>
60053 If an explicit key is being used for a DNS lookup and it may be an IPv6
60054 address you should specify alternate list separators for both the outer
60055 (DNS list name) list and inner (lookup keys) list:
60056 </para>
60057 <literallayout class="monospaced">
60058        dnslists = &lt;; dnsbl.example.com/&lt;|$acl_m_addrslist
60059 </literallayout>
60060 </section>
60061 <section id="SECTratelimiting">
60062 <title>Rate limiting incoming messages</title>
60063 <para>
60064 <indexterm role="concept">
60065 <primary>rate limiting</primary>
60066 <secondary>client sending</secondary>
60067 </indexterm>
60068 <indexterm role="concept">
60069 <primary>limiting client sending rates</primary>
60070 </indexterm>
60071 <indexterm role="option">
60072 <primary><option>smtp_ratelimit_*</option></primary>
60073 </indexterm>
60074 The <option>ratelimit</option> ACL condition can be used to measure and control the rate at
60075 which clients can send email. This is more powerful than the
60076 <option>smtp_ratelimit_*</option> options, because those options control the rate of
60077 commands in a single SMTP session only, whereas the <option>ratelimit</option> condition
60078 works across all connections (concurrent and sequential) from the same client
60079 host. The syntax of the <option>ratelimit</option> condition is:
60080 </para>
60081 <literallayout>
60082 <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;
60083 </literallayout>
60084 <para>
60085 If the average client sending rate is less than <emphasis>m</emphasis> messages per time
60086 period <emphasis>p</emphasis> then the condition is false; otherwise it is true.
60087 </para>
60088 <para>
60089 As a side-effect, the <option>ratelimit</option> condition sets the expansion variable
60090 <varname>$sender_rate</varname> to the client&#x2019;s computed rate, <varname>$sender_rate_limit</varname> to the
60091 configured value of <emphasis>m</emphasis>, and <varname>$sender_rate_period</varname> to the configured value
60092 of <emphasis>p</emphasis>.
60093 </para>
60094 <para>
60095 The parameter <emphasis>p</emphasis> is the smoothing time constant, in the form of an Exim
60096 time interval, for example, <literal>8h</literal> for eight hours. A larger time constant
60097 means that it takes Exim longer to forget a client&#x2019;s past behaviour. The
60098 parameter <emphasis>m</emphasis> is the maximum number of messages that a client is permitted to
60099 send in each time interval. It also specifies the number of messages permitted
60100 in a fast burst. By increasing both <emphasis>m</emphasis> and <emphasis>p</emphasis> but keeping <emphasis>m/p</emphasis>
60101 constant, you can allow a client to send more messages in a burst without
60102 changing its long-term sending rate limit. Conversely, if <emphasis>m</emphasis> and <emphasis>p</emphasis> are
60103 both small, messages must be sent at an even rate.
60104 </para>
60105 <para>
60106 There is a script in <filename>util/ratelimit.pl</filename> which extracts sending rates from
60107 log files, to assist with choosing appropriate settings for <emphasis>m</emphasis> and <emphasis>p</emphasis>
60108 when deploying the <option>ratelimit</option> ACL condition. The script prints usage
60109 instructions when it is run with no arguments.
60110 </para>
60111 <para>
60112 The key is used to look up the data for calculating the client&#x2019;s average
60113 sending rate. This data is stored in Exim&#x2019;s spool directory, alongside the
60114 retry and other hints databases. The default key is <varname>$sender_host_address</varname>,
60115 which means Exim computes the sending rate of each client host IP address.
60116 By changing the key you can change how Exim identifies clients for the purpose
60117 of ratelimiting. For example, to limit the sending rate of each authenticated
60118 user, independent of the computer they are sending from, set the key to
60119 <varname>$authenticated_id</varname>. You must ensure that the lookup key is meaningful; for
60120 example, <varname>$authenticated_id</varname> is only meaningful if the client has
60121 authenticated (which you can check with the <option>authenticated</option> ACL condition).
60122 </para>
60123 <para>
60124 The lookup key does not have to identify clients: If you want to limit the
60125 rate at which a recipient receives messages, you can use the key
60126 <literal>$local_part@$domain</literal> with the <option>per_rcpt</option> option (see below) in a RCPT
60127 ACL.
60128 </para>
60129 <para>
60130 Each <option>ratelimit</option> condition can have up to four options. A <option>per_*</option> option
60131 specifies what Exim measures the rate of, for example, messages or recipients
60132 or bytes. You can adjust the measurement using the <option>unique=</option> and/or
60133 <option>count=</option> options. You can also control when Exim updates the recorded rate
60134 using a <option>strict</option>, <option>leaky</option>, or <option>readonly</option> option. The options are
60135 separated by a slash, like the other parameters. They may appear in any order.
60136 </para>
60137 <para>
60138 Internally, Exim appends the smoothing constant <emphasis>p</emphasis> onto the lookup key with
60139 any options that alter the meaning of the stored data. The limit <emphasis>m</emphasis> is not
60140 stored, so you can alter the configured maximum rate and Exim will still
60141 remember clients&#x2019; past behaviour. If you change the <option>per_*</option> mode or add or
60142 remove the <option>unique=</option> option, the lookup key changes so Exim will forget past
60143 behaviour. The lookup key is not affected by changes to the update mode and
60144 the <option>count=</option> option.
60145 </para>
60146 </section>
60147 <section id="ratoptmea">
60148 <title>Ratelimit options for what is being measured</title>
60149 <para>
60150 <indexterm role="concept">
60151 <primary>rate limiting</primary>
60152 <secondary>per_* options</secondary>
60153 </indexterm>
60154 The <option>per_conn</option> option limits the client&#x2019;s connection rate. It is not
60155 normally used in the <option>acl_not_smtp</option>, <option>acl_not_smtp_mime</option>, or
60156 <option>acl_not_smtp_start</option> ACLs.
60157 </para>
60158 <para>
60159 The <option>per_mail</option> option limits the client&#x2019;s rate of sending messages. This is
60160 the default if none of the <option>per_*</option> options is specified. It can be used in
60161 <option>acl_smtp_mail</option>, <option>acl_smtp_rcpt</option>, <option>acl_smtp_predata</option>, <option>acl_smtp_mime</option>,
60162 <option>acl_smtp_data</option>, or <option>acl_not_smtp</option>.
60163 </para>
60164 <para>
60165 The <option>per_byte</option> option limits the sender&#x2019;s email bandwidth. It can be used in
60166 the same ACLs as the <option>per_mail</option> option, though it is best to use this option
60167 in the <option>acl_smtp_mime</option>, <option>acl_smtp_data</option> or <option>acl_not_smtp</option> ACLs; if it is
60168 used in an earlier ACL, Exim relies on the SIZE parameter given by the client
60169 in its MAIL command, which may be inaccurate or completely missing. You can
60170 follow the limit <emphasis>m</emphasis> in the configuration with K, M, or G to specify limits
60171 in kilobytes, megabytes, or gigabytes, respectively.
60172 </para>
60173 <para>
60174 The <option>per_rcpt</option> option causes Exim to limit the rate at which recipients are
60175 accepted. It can be used in the <option>acl_smtp_rcpt</option>, <option>acl_smtp_predata</option>,
60176 <option>acl_smtp_mime</option>, <option>acl_smtp_data</option>, or <option>acl_smtp_rcpt</option> ACLs. In
60177 <option>acl_smtp_rcpt</option> the rate is updated one recipient at a time; in the other
60178 ACLs the rate is updated with the total (accepted) recipient count in one go. Note that
60179 in either case the rate limiting engine will see a message with many
60180 recipients as a large high-speed burst.
60181 </para>
60182 <para>
60183 The <option>per_addr</option> option is like the <option>per_rcpt</option> option, except it counts the
60184 number of different recipients that the client has sent messages to in the
60185 last time period. That is, if the client repeatedly sends messages to the same
60186 recipient, its measured rate is not increased. This option can only be used in
60187 <option>acl_smtp_rcpt</option>.
60188 </para>
60189 <para>
60190 The <option>per_cmd</option> option causes Exim to recompute the rate every time the
60191 condition is processed. This can be used to limit the rate of any SMTP
60192 command. If it is used in multiple ACLs it can limit the aggregate rate of
60193 multiple different commands.
60194 </para>
60195 <para>
60196 The <option>count=</option> option can be used to alter how much Exim adds to the client&#x2019;s
60197 measured rate. For example, the <option>per_byte</option> option is equivalent to
60198 <literal>per_mail/count=$message_size</literal>. If there is no <option>count=</option> option, Exim
60199 increases the measured rate by one (except for the <option>per_rcpt</option> option in ACLs
60200 other than <option>acl_smtp_rcpt</option>). The count does not have to be an integer.
60201 </para>
60202 <para>
60203 The <option>unique=</option> option is described in section <xref linkend="ratoptuniq"/> below.
60204 </para>
60205 </section>
60206 <section id="ratoptupd">
60207 <title>Ratelimit update modes</title>
60208 <para>
60209 <indexterm role="concept">
60210 <primary>rate limiting</primary>
60211 <secondary>reading data without updating</secondary>
60212 </indexterm>
60213 You can specify one of three options with the <option>ratelimit</option> condition to
60214 control when its database is updated. This section describes the <option>readonly</option>
60215 mode, and the next section describes the <option>strict</option> and <option>leaky</option> modes.
60216 </para>
60217 <para>
60218 If the <option>ratelimit</option> condition is used in <option>readonly</option> mode, Exim looks up a
60219 previously-computed rate to check against the limit.
60220 </para>
60221 <para>
60222 For example, you can test the client&#x2019;s sending rate and deny it access (when
60223 it is too fast) in the connect ACL. If the client passes this check then it
60224 can go on to send a message, in which case its recorded rate will be updated
60225 in the MAIL ACL. Subsequent connections from the same client will check this
60226 new rate.
60227 </para>
60228 <literallayout class="monospaced">
60229 acl_check_connect:
60230  deny ratelimit = 100 / 5m / readonly
60231     log_message = RATE CHECK: $sender_rate/$sender_rate_period \
60232                   (max $sender_rate_limit)
60233 # ...
60234 acl_check_mail:
60235  warn ratelimit = 100 / 5m / strict
60236     log_message = RATE UPDATE: $sender_rate/$sender_rate_period \
60237                   (max $sender_rate_limit)
60238 </literallayout>
60239 <para>
60240 If Exim encounters multiple <option>ratelimit</option> conditions with the same key when
60241 processing a message then it may increase the client&#x2019;s measured rate more than
60242 it should. For example, this will happen if you check the <option>per_rcpt</option> option
60243 in both <option>acl_smtp_rcpt</option> and <option>acl_smtp_data</option>. However it&#x2019;s OK to check the
60244 same <option>ratelimit</option> condition multiple times in the same ACL. You can avoid any
60245 multiple update problems by using the <option>readonly</option> option on later ratelimit
60246 checks.
60247 </para>
60248 <para>
60249 The <option>per_*</option> options described above do not make sense in some ACLs. If you
60250 use a <option>per_*</option> option in an ACL where it is not normally permitted then the
60251 update mode defaults to <option>readonly</option> and you cannot specify the <option>strict</option> or
60252 <option>leaky</option> modes. In other ACLs the default update mode is <option>leaky</option> (see the
60253 next section) so you must specify the <option>readonly</option> option explicitly.
60254 </para>
60255 </section>
60256 <section id="ratoptfast">
60257 <title>Ratelimit options for handling fast clients</title>
60258 <para>
60259 <indexterm role="concept">
60260 <primary>rate limiting</primary>
60261 <secondary>strict and leaky modes</secondary>
60262 </indexterm>
60263 If a client&#x2019;s average rate is greater than the maximum, the rate limiting
60264 engine can react in two possible ways, depending on the presence of the
60265 <option>strict</option> or <option>leaky</option> update modes. This is independent of the other
60266 counter-measures (such as rejecting the message) that may be specified by the
60267 rest of the ACL.
60268 </para>
60269 <para>
60270 The <option>leaky</option> (default) option means that the client&#x2019;s recorded rate is not
60271 updated if it is above the limit. The effect of this is that Exim measures the
60272 client&#x2019;s average rate of successfully sent email,
60273 up to the given limit.
60274 This is appropriate if the countermeasure when the condition is true
60275 consists of refusing the message, and
60276 is generally the better choice if you have clients that retry automatically.
60277 If the action when true is anything more complex then this option is
60278 likely not what is wanted.
60279 </para>
60280 <para>
60281 The <option>strict</option> option means that the client&#x2019;s recorded rate is always
60282 updated. The effect of this is that Exim measures the client&#x2019;s average rate
60283 of attempts to send email, which can be much higher than the maximum it is
60284 actually allowed. If the client is over the limit it may be subjected to
60285 counter-measures by the ACL. It must slow down and allow sufficient time to
60286 pass that its computed rate falls below the maximum before it can send email
60287 again. The time (the number of smoothing periods) it must wait and not
60288 attempt to send mail can be calculated with this formula:
60289 </para>
60290 <literallayout class="monospaced">
60291         ln(peakrate/maxrate)
60292 </literallayout>
60293 </section>
60294 <section id="ratoptuniq">
60295 <title>Limiting the rate of different events</title>
60296 <para>
60297 <indexterm role="concept">
60298 <primary>rate limiting</primary>
60299 <secondary>counting unique events</secondary>
60300 </indexterm>
60301 The <option>ratelimit</option> <option>unique=</option> option controls a mechanism for counting the
60302 rate of different events. For example, the <option>per_addr</option> option uses this
60303 mechanism to count the number of different recipients that the client has
60304 sent messages to in the last time period; it is equivalent to
60305 <literal>per_rcpt/unique=$local_part@$domain</literal>. You could use this feature to
60306 measure the rate that a client uses different sender addresses with the
60307 options <literal>per_mail/unique=$sender_address</literal>.
60308 </para>
60309 <para>
60310 For each <option>ratelimit</option> key Exim stores the set of <option>unique=</option> values that it
60311 has seen for that key. The whole set is thrown away when it is older than the
60312 rate smoothing period <emphasis>p</emphasis>, so each different event is counted at most once
60313 per period. In the <option>leaky</option> update mode, an event that causes the client to
60314 go over the limit is not added to the set, in the same way that the client&#x2019;s
60315 recorded rate is not updated in the same situation.
60316 </para>
60317 <para>
60318 When you combine the <option>unique=</option> and <option>readonly</option> options, the specific
60319 <option>unique=</option> value is ignored, and Exim just retrieves the client&#x2019;s stored
60320 rate.
60321 </para>
60322 <para>
60323 The <option>unique=</option> mechanism needs more space in the ratelimit database than the
60324 other <option>ratelimit</option> options in order to store the event set. The number of
60325 unique values is potentially as large as the rate limit, so the extra space
60326 required increases with larger limits.
60327 </para>
60328 <para>
60329 The uniqueification is not perfect: there is a small probability that Exim
60330 will think a new event has happened before. If the sender&#x2019;s rate is less than
60331 the limit, Exim should be more than 99.9% correct. However in <option>strict</option> mode
60332 the measured rate can go above the limit, in which case Exim may under-count
60333 events by a significant margin. Fortunately, if the rate is high enough (2.7
60334 times the limit) that the false positive rate goes above 9%, then Exim will
60335 throw away the over-full event set before the measured rate falls below the
60336 limit. Therefore the only harm should be that exceptionally high sending rates
60337 are logged incorrectly; any countermeasures you configure will be as effective
60338 as intended.
60339 </para>
60340 </section>
60341 <section id="useratlim">
60342 <title>Using rate limiting</title>
60343 <para>
60344 Exim&#x2019;s other ACL facilities are used to define what counter-measures are taken
60345 when the rate limit is exceeded. This might be anything from logging a warning
60346 (for example, while measuring existing sending rates in order to define
60347 policy), through time delays to slow down fast senders, up to rejecting the
60348 message. For example:
60349 </para>
60350 <literallayout class="monospaced">
60351 # Log all senders' rates
60352 warn ratelimit = 0 / 1h / strict
60353      log_message = Sender rate $sender_rate / $sender_rate_period
60354
60355 # Slow down fast senders; note the need to truncate $sender_rate
60356 # at the decimal point.
60357 warn ratelimit = 100 / 1h / per_rcpt / strict
60358      delay     = ${eval: ${sg{$sender_rate}{[.].*}{}} - \
60359                    $sender_rate_limit }s
60360
60361 # Keep authenticated users under control
60362 deny authenticated = *
60363      ratelimit = 100 / 1d / strict / $authenticated_id
60364
60365 # System-wide rate limit
60366 defer message = Sorry, too busy. Try again later.
60367      ratelimit = 10 / 1s / $primary_hostname
60368
60369 # Restrict incoming rate from each host, with a default
60370 # set using a macro and special cases looked up in a table.
60371 defer message = Sender rate exceeds $sender_rate_limit \
60372                messages per $sender_rate_period
60373      ratelimit = ${lookup {$sender_host_address} \
60374                    cdb {DB/ratelimits.cdb} \
60375                    {$value} {RATELIMIT} }
60376 </literallayout>
60377 <para>
60378 <emphasis role="bold">Warning</emphasis>: If you have a busy server with a lot of <option>ratelimit</option> tests,
60379 especially with the <option>per_rcpt</option> option, you may suffer from a performance
60380 bottleneck caused by locking on the ratelimit hints database. Apart from
60381 making your ACLs less complicated, you can reduce the problem by using a
60382 RAM disk for Exim&#x2019;s hints directory (usually <filename>/var/spool/exim/db/</filename>). However
60383 this means that Exim will lose its hints data after a reboot (including retry
60384 hints, the callout cache, and ratelimit data).
60385 </para>
60386 </section>
60387 <section id="SECTaddressverification">
60388 <title>Address verification</title>
60389 <para>
60390 <indexterm role="concept">
60391 <primary>verifying address</primary>
60392 <secondary>options for</secondary>
60393 </indexterm>
60394 <indexterm role="concept">
60395 <primary>policy control</primary>
60396 <secondary>address verification</secondary>
60397 </indexterm>
60398 Several of the <option>verify</option> conditions described in section
60399 <xref linkend="SECTaclconditions"/> cause addresses to be verified. Section
60400 <xref linkend="SECTsenaddver"/> discusses the reporting of sender verification failures.
60401 The verification conditions can be followed by options that modify the
60402 verification process. The options are separated from the keyword and from each
60403 other by slashes, and some of them contain parameters. For example:
60404 </para>
60405 <literallayout class="monospaced">
60406 verify = sender/callout
60407 verify = recipient/defer_ok/callout=10s,defer_ok
60408 </literallayout>
60409 <para>
60410 The first stage of address verification, which always happens, is to run the
60411 address through the routers, in <quote>verify mode</quote>. Routers can detect the
60412 difference between verification and routing for delivery, and their actions can
60413 be varied by a number of generic options such as <option>verify</option> and <option>verify_only</option>
60414 (see chapter <xref linkend="CHAProutergeneric"/>). If routing fails, verification fails.
60415 The available options are as follows:
60416 </para>
60417 <itemizedlist>
60418 <listitem>
60419 <para>
60420 If the <option>callout</option> option is specified, successful routing to one or more
60421 remote hosts is followed by a <quote>callout</quote> to those hosts as an additional
60422 check. Callouts and their sub-options are discussed in the next section.
60423 </para>
60424 </listitem>
60425 <listitem>
60426 <para>
60427 If there is a defer error while doing verification routing, the ACL
60428 normally returns <quote>defer</quote>. However, if you include <option>defer_ok</option> in the
60429 options, the condition is forced to be true instead. Note that this is a main
60430 verification option as well as a suboption for callouts.
60431 </para>
60432 </listitem>
60433 <listitem>
60434 <para>
60435 The <option>no_details</option> option is covered in section <xref linkend="SECTsenaddver"/>, which
60436 discusses the reporting of sender address verification failures.
60437 </para>
60438 </listitem>
60439 <listitem>
60440 <para>
60441 The <option>success_on_redirect</option> option causes verification always to succeed
60442 immediately after a successful redirection. By default, if a redirection
60443 generates just one address, that address is also verified. See further
60444 discussion in section <xref linkend="SECTredirwhilveri"/>.
60445 </para>
60446 </listitem>
60447 </itemizedlist>
60448 <para>
60449 <indexterm role="concept">
60450 <primary>verifying address</primary>
60451 <secondary>differentiating failures</secondary>
60452 </indexterm>
60453 <indexterm role="variable">
60454 <primary><varname>$recipient_verify_failure</varname></primary>
60455 </indexterm>
60456 <indexterm role="variable">
60457 <primary><varname>$sender_verify_failure</varname></primary>
60458 </indexterm>
60459 <indexterm role="variable">
60460 <primary><varname>$acl_verify_message</varname></primary>
60461 </indexterm>
60462 After an address verification failure, <varname>$acl_verify_message</varname> contains the
60463 error message that is associated with the failure. It can be preserved by
60464 coding like this:
60465 </para>
60466 <literallayout class="monospaced">
60467 warn  !verify = sender
60468        set acl_m0 = $acl_verify_message
60469 </literallayout>
60470 <para>
60471 If you are writing your own custom rejection message or log message when
60472 denying access, you can use this variable to include information about the
60473 verification failure.
60474 </para>
60475 <para>
60476 In addition, <varname>$sender_verify_failure</varname> or <varname>$recipient_verify_failure</varname> (as
60477 appropriate) contains one of the following words:
60478 </para>
60479 <itemizedlist>
60480 <listitem>
60481 <para>
60482 <option>qualify</option>: The address was unqualified (no domain), and the message
60483 was neither local nor came from an exempted host.
60484 </para>
60485 </listitem>
60486 <listitem>
60487 <para>
60488 <option>route</option>: Routing failed.
60489 </para>
60490 </listitem>
60491 <listitem>
60492 <para>
60493 <option>mail</option>: Routing succeeded, and a callout was attempted; rejection
60494 occurred at or before the MAIL command (that is, on initial
60495 connection, HELO, or MAIL).
60496 </para>
60497 </listitem>
60498 <listitem>
60499 <para>
60500 <option>recipient</option>: The RCPT command in a callout was rejected.
60501 </para>
60502 </listitem>
60503 <listitem>
60504 <para>
60505 <option>postmaster</option>: The postmaster check in a callout was rejected.
60506 </para>
60507 </listitem>
60508 </itemizedlist>
60509 <para>
60510 The main use of these variables is expected to be to distinguish between
60511 rejections of MAIL and rejections of RCPT in callouts.
60512 </para>
60513 <para>
60514 The above variables may also be set after a <emphasis role="bold">successful</emphasis>
60515 address verification to:
60516 </para>
60517 <itemizedlist>
60518 <listitem>
60519 <para>
60520 <option>random</option>: A random local-part callout succeeded
60521 </para>
60522 </listitem>
60523 </itemizedlist>
60524 </section>
60525 <section id="SECTcallver">
60526 <title>Callout verification</title>
60527 <para>
60528 <indexterm role="concept">
60529 <primary>verifying address</primary>
60530 <secondary>by callout</secondary>
60531 </indexterm>
60532 <indexterm role="concept">
60533 <primary>callout</primary>
60534 <secondary>verification</secondary>
60535 </indexterm>
60536 <indexterm role="concept">
60537 <primary>SMTP</primary>
60538 <secondary>callout verification</secondary>
60539 </indexterm>
60540 For non-local addresses, routing verifies the domain, but is unable to do any
60541 checking of the local part. There are situations where some means of verifying
60542 the local part is desirable. One way this can be done is to make an SMTP
60543 <emphasis>callback</emphasis> to a delivery host for the sender address or a <emphasis>callforward</emphasis> to
60544 a subsequent host for a recipient address, to see if the host accepts the
60545 address. We use the term <emphasis>callout</emphasis> to cover both cases. Note that for a
60546 sender address, the callback is not to the client host that is trying to
60547 deliver the message, but to one of the hosts that accepts incoming mail for the
60548 sender&#x2019;s domain.
60549 </para>
60550 <para>
60551 Exim does not do callouts by default. If you want them to happen, you must
60552 request them by setting appropriate options on the <option>verify</option> condition, as
60553 described below. This facility should be used with care, because it can add a
60554 lot of resource usage to the cost of verifying an address. However, Exim does
60555 cache the results of callouts, which helps to reduce the cost. Details of
60556 caching are in section <xref linkend="SECTcallvercache"/>.
60557 </para>
60558 <para>
60559 Recipient callouts are usually used only between hosts that are controlled by
60560 the same administration. For example, a corporate gateway host could use
60561 callouts to check for valid recipients on an internal mailserver. A successful
60562 callout does not guarantee that a real delivery to the address would succeed;
60563 on the other hand, a failing callout does guarantee that a delivery would fail.
60564 </para>
60565 <para>
60566 If the <option>callout</option> option is present on a condition that verifies an address, a
60567 second stage of verification occurs if the address is successfully routed to
60568 one or more remote hosts. The usual case is routing by a <command>dnslookup</command> or a
60569 <command>manualroute</command> router, where the router specifies the hosts. However, if a
60570 router that does not set up hosts routes to an <command>smtp</command> transport with a
60571 <option>hosts</option> setting, the transport&#x2019;s hosts are used. If an <command>smtp</command> transport has
60572 <option>hosts_override</option> set, its hosts are always used, whether or not the router
60573 supplies a host list.
60574 Callouts are only supported on <command>smtp</command> transports.
60575 </para>
60576 <para>
60577 The port that is used is taken from the transport, if it is specified and is a
60578 remote transport. (For routers that do verification only, no transport need be
60579 specified.) Otherwise, the default SMTP port is used. If a remote transport
60580 specifies an outgoing interface, this is used; otherwise the interface is not
60581 specified. Likewise, the text that is used for the HELO command is taken from
60582 the transport&#x2019;s <option>helo_data</option> option; if there is no transport, the value of
60583 <varname>$smtp_active_hostname</varname> is used.
60584 </para>
60585 <para>
60586 For a sender callout check, Exim makes SMTP connections to the remote hosts, to
60587 test whether a bounce message could be delivered to the sender address. The
60588 following SMTP commands are sent:
60589 </para>
60590 <literallayout>
60591 <literal>HELO </literal>&lt;<emphasis>local host name</emphasis>&gt;
60592 <literal>MAIL FROM:&lt;&gt;</literal>
60593 <literal>RCPT TO:</literal>&lt;<emphasis>the address to be tested</emphasis>&gt;
60594 <literal>QUIT</literal>
60595 </literallayout>
60596 <para>
60597 LHLO is used instead of HELO if the transport&#x2019;s <option>protocol</option> option is
60598 set to <quote>lmtp</quote>.
60599 </para>
60600 <para>
60601 The callout may use EHLO, AUTH and/or STARTTLS given appropriate option
60602 settings.
60603 </para>
60604 <para>
60605 A recipient callout check is similar. By default, it also uses an empty address
60606 for the sender. This default is chosen because most hosts do not make use of
60607 the sender address when verifying a recipient. Using the same address means
60608 that a single cache entry can be used for each recipient. Some sites, however,
60609 do make use of the sender address when verifying. These are catered for by the
60610 <option>use_sender</option> and <option>use_postmaster</option> options, described in the next section.
60611 </para>
60612 <para>
60613 If the response to the RCPT command is a 2<emphasis>xx</emphasis> code, the verification
60614 succeeds. If it is 5<emphasis>xx</emphasis>, the verification fails. For any other condition,
60615 Exim tries the next host, if any. If there is a problem with all the remote
60616 hosts, the ACL yields <quote>defer</quote>, unless the <option>defer_ok</option> parameter of the
60617 <option>callout</option> option is given, in which case the condition is forced to succeed.
60618 </para>
60619 <para>
60620 <indexterm role="concept">
60621 <primary>SMTP</primary>
60622 <secondary>output flushing, disabling for callout</secondary>
60623 </indexterm>
60624 A callout may take a little time. For this reason, Exim normally flushes SMTP
60625 output before performing a callout in an ACL, to avoid unexpected timeouts in
60626 clients when the SMTP PIPELINING extension is in use. The flushing can be
60627 disabled by using a <option>control</option> modifier to set <option>no_callout_flush</option>.
60628 </para>
60629 </section>
60630 <section id="CALLaddparcall">
60631 <title>Additional parameters for callouts</title>
60632 <para>
60633 <indexterm role="concept">
60634 <primary>callout</primary>
60635 <secondary>additional parameters for</secondary>
60636 </indexterm>
60637 The <option>callout</option> option can be followed by an equals sign and a number of
60638 optional parameters, separated by commas. For example:
60639 </para>
60640 <literallayout class="monospaced">
60641 verify = recipient/callout=10s,defer_ok
60642 </literallayout>
60643 <para>
60644 The old syntax, which had <option>callout_defer_ok</option> and <option>check_postmaster</option> as
60645 separate verify options, is retained for backwards compatibility, but is now
60646 deprecated. The additional parameters for <option>callout</option> are as follows:
60647 </para>
60648 <variablelist>
60649 <varlistentry>
60650 <term>&lt;<emphasis>a&nbsp;time&nbsp;interval</emphasis>&gt;</term>
60651 <listitem>
60652 <para>
60653 <indexterm role="concept">
60654 <primary>callout</primary>
60655 <secondary>timeout, specifying</secondary>
60656 </indexterm>
60657 This specifies the timeout that applies for the callout attempt to each host.
60658 For example:
60659 </para>
60660 <literallayout class="monospaced">
60661 verify = sender/callout=5s
60662 </literallayout>
60663 <para>
60664 The default is 30 seconds. The timeout is used for each response from the
60665 remote host. It is also used for the initial connection, unless overridden by
60666 the <option>connect</option> parameter.
60667 </para>
60668 </listitem></varlistentry>
60669 <varlistentry>
60670 <term><emphasis role="bold">connect&nbsp;=&nbsp;</emphasis>&lt;<emphasis>time&nbsp;interval</emphasis>&gt;</term>
60671 <listitem>
60672 <para>
60673 <indexterm role="concept">
60674 <primary>callout</primary>
60675 <secondary>connection timeout, specifying</secondary>
60676 </indexterm>
60677 This parameter makes it possible to set a different (usually smaller) timeout
60678 for making the SMTP connection. For example:
60679 </para>
60680 <literallayout class="monospaced">
60681 verify = sender/callout=5s,connect=1s
60682 </literallayout>
60683 <para>
60684 If not specified, this timeout defaults to the general timeout value.
60685 </para>
60686 </listitem></varlistentry>
60687 <varlistentry>
60688 <term><emphasis role="bold">defer_ok</emphasis></term>
60689 <listitem>
60690 <para>
60691 <indexterm role="concept">
60692 <primary>callout</primary>
60693 <secondary>defer, action on</secondary>
60694 </indexterm>
60695 When this parameter is present, failure to contact any host, or any other kind
60696 of temporary error, is treated as success by the ACL. However, the cache is not
60697 updated in this circumstance.
60698 </para>
60699 </listitem></varlistentry>
60700 <varlistentry>
60701 <term><emphasis role="bold">fullpostmaster</emphasis></term>
60702 <listitem>
60703 <para>
60704 <indexterm role="concept">
60705 <primary>callout</primary>
60706 <secondary>full postmaster check</secondary>
60707 </indexterm>
60708 This operates like the <option>postmaster</option> option (see below), but if the check for
60709 <emphasis>postmaster@domain</emphasis> fails, it tries just <emphasis>postmaster</emphasis>, without a domain, in
60710 accordance with the specification in RFC 2821. The RFC states that the
60711 unqualified address <emphasis>postmaster</emphasis> should be accepted.
60712 </para>
60713 </listitem></varlistentry>
60714 <varlistentry>
60715 <term><emphasis role="bold">mailfrom&nbsp;=&nbsp;</emphasis>&lt;<emphasis>email&nbsp;address</emphasis>&gt;</term>
60716 <listitem>
60717 <para>
60718 <indexterm role="concept">
60719 <primary>callout</primary>
60720 <secondary>sender when verifying header</secondary>
60721 </indexterm>
60722 When verifying addresses in header lines using the <option>header_sender</option>
60723 verification option, Exim behaves by default as if the addresses are envelope
60724 sender addresses from a message. Callout verification therefore tests to see
60725 whether a bounce message could be delivered, by using an empty address in the
60726 MAIL command. However, it is arguable that these addresses might never be used
60727 as envelope senders, and could therefore justifiably reject bounce messages
60728 (empty senders). The <option>mailfrom</option> callout parameter allows you to specify what
60729 address to use in the MAIL command. For example:
60730 </para>
60731 <literallayout class="monospaced">
60732 require  verify = header_sender/callout=mailfrom=abcd@x.y.z
60733 </literallayout>
60734 <para>
60735 This parameter is available only for the <option>header_sender</option> verification option.
60736 </para>
60737 </listitem></varlistentry>
60738 <varlistentry>
60739 <term><emphasis role="bold">maxwait&nbsp;=&nbsp;</emphasis>&lt;<emphasis>time&nbsp;interval</emphasis>&gt;</term>
60740 <listitem>
60741 <para>
60742 <indexterm role="concept">
60743 <primary>callout</primary>
60744 <secondary>overall timeout, specifying</secondary>
60745 </indexterm>
60746 This parameter sets an overall timeout for performing a callout verification.
60747 For example:
60748 </para>
60749 <literallayout class="monospaced">
60750 verify = sender/callout=5s,maxwait=30s
60751 </literallayout>
60752 <para>
60753 This timeout defaults to four times the callout timeout for individual SMTP
60754 commands. The overall timeout applies when there is more than one host that can
60755 be tried. The timeout is checked before trying the next host. This prevents
60756 very long delays if there are a large number of hosts and all are timing out
60757 (for example, when network connections are timing out).
60758 </para>
60759 </listitem></varlistentry>
60760 <varlistentry>
60761 <term><emphasis role="bold">no_cache</emphasis></term>
60762 <listitem>
60763 <para>
60764 <indexterm role="concept">
60765 <primary>callout</primary>
60766 <secondary>cache, suppressing</secondary>
60767 </indexterm>
60768 <indexterm role="concept">
60769 <primary>caching callout, suppressing</primary>
60770 </indexterm>
60771 When this parameter is given, the callout cache is neither read nor updated.
60772 </para>
60773 </listitem></varlistentry>
60774 <varlistentry>
60775 <term><emphasis role="bold">postmaster</emphasis></term>
60776 <listitem>
60777 <para>
60778 <indexterm role="concept">
60779 <primary>callout</primary>
60780 <secondary>postmaster; checking</secondary>
60781 </indexterm>
60782 When this parameter is set, a successful callout check is followed by a similar
60783 check for the local part <emphasis>postmaster</emphasis> at the same domain. If this address is
60784 rejected, the callout fails (but see <option>fullpostmaster</option> above). The result of
60785 the postmaster check is recorded in a cache record; if it is a failure, this is
60786 used to fail subsequent callouts for the domain without a connection being
60787 made, until the cache record expires.
60788 </para>
60789 </listitem></varlistentry>
60790 <varlistentry>
60791 <term><emphasis role="bold">postmaster_mailfrom&nbsp;=&nbsp;</emphasis>&lt;<emphasis>email&nbsp;address</emphasis>&gt;</term>
60792 <listitem>
60793 <para>
60794 The postmaster check uses an empty sender in the MAIL command by default.
60795 You can use this parameter to do a postmaster check using a different address.
60796 For example:
60797 </para>
60798 <literallayout class="monospaced">
60799 require  verify = sender/callout=postmaster_mailfrom=abc@x.y.z
60800 </literallayout>
60801 <para>
60802 If both <option>postmaster</option> and <option>postmaster_mailfrom</option> are present, the rightmost
60803 one overrides. The <option>postmaster</option> parameter is equivalent to this example:
60804 </para>
60805 <literallayout class="monospaced">
60806 require  verify = sender/callout=postmaster_mailfrom=
60807 </literallayout>
60808 <para>
60809 <emphasis role="bold">Warning</emphasis>: The caching arrangements for postmaster checking do not take
60810 account of the sender address. It is assumed that either the empty address or
60811 a fixed non-empty address will be used. All that Exim remembers is that the
60812 postmaster check for the domain succeeded or failed.
60813 </para>
60814 </listitem></varlistentry>
60815 <varlistentry>
60816 <term><emphasis role="bold">random</emphasis></term>
60817 <listitem>
60818 <para>
60819 <indexterm role="concept">
60820 <primary>callout</primary>
60821 <secondary><quote>random</quote> check</secondary>
60822 </indexterm>
60823 When this parameter is set, before doing the normal callout check, Exim does a
60824 check for a <quote>random</quote> local part at the same domain. The local part is not
60825 really random &ndash; it is defined by the expansion of the option
60826 <option>callout_random_local_part</option>, which defaults to
60827 </para>
60828 <literallayout class="monospaced">
60829 $primary_hostname-$tod_epoch-testing
60830 </literallayout>
60831 <para>
60832 The idea here is to try to determine whether the remote host accepts all local
60833 parts without checking. If it does, there is no point in doing callouts for
60834 specific local parts. If the <quote>random</quote> check succeeds, the result is saved in
60835 a cache record, and used to force the current and subsequent callout checks to
60836 succeed without a connection being made, until the cache record expires.
60837 </para>
60838 </listitem></varlistentry>
60839 <varlistentry>
60840 <term><emphasis role="bold">use_postmaster</emphasis></term>
60841 <listitem>
60842 <para>
60843 <indexterm role="concept">
60844 <primary>callout</primary>
60845 <secondary>sender for recipient check</secondary>
60846 </indexterm>
60847 This parameter applies to recipient callouts only. For example:
60848 </para>
60849 <literallayout class="monospaced">
60850 deny  !verify = recipient/callout=use_postmaster
60851 </literallayout>
60852 <para>
60853 <indexterm role="variable">
60854 <primary><varname>$qualify_domain</varname></primary>
60855 </indexterm>
60856 It causes a non-empty postmaster address to be used in the MAIL command when
60857 performing the callout for the recipient, and also for a <quote>random</quote> check if
60858 that is configured. The local part of the address is <literal>postmaster</literal> and the
60859 domain is the contents of <varname>$qualify_domain</varname>.
60860 </para>
60861 </listitem></varlistentry>
60862 <varlistentry>
60863 <term><emphasis role="bold">use_sender</emphasis></term>
60864 <listitem>
60865 <para>
60866 This option applies to recipient callouts only. For example:
60867 </para>
60868 <literallayout class="monospaced">
60869 require  verify = recipient/callout=use_sender
60870 </literallayout>
60871 <para>
60872 It causes the message&#x2019;s actual sender address to be used in the MAIL
60873 command when performing the callout, instead of an empty address. There is no
60874 need to use this option unless you know that the called hosts make use of the
60875 sender when checking recipients. If used indiscriminately, it reduces the
60876 usefulness of callout caching.
60877 </para>
60878 </listitem></varlistentry>
60879 <varlistentry>
60880 <term><emphasis role="bold">hold</emphasis></term>
60881 <listitem>
60882 <para>
60883 This option applies to recipient callouts only. For example:
60884 </para>
60885 <literallayout class="monospaced">
60886 require  verify = recipient/callout=use_sender,hold
60887 </literallayout>
60888 <para>
60889 It causes the connection to be held open and used for any further recipients
60890 and for eventual delivery (should that be done quickly).
60891 Doing this saves on TCP and SMTP startup costs, and TLS costs also
60892 when that is used for the connections.
60893 The advantage is only gained if there are no callout cache hits
60894 (which could be enforced by the no_cache option),
60895 if the use_sender option is used,
60896 if neither the random nor the use_postmaster option is used,
60897 and if no other callouts intervene.
60898 </para>
60899 </listitem></varlistentry>
60900 </variablelist>
60901 <para>
60902 If you use any of the parameters that set a non-empty sender for the MAIL
60903 command (<option>mailfrom</option>, <option>postmaster_mailfrom</option>, <option>use_postmaster</option>, or
60904 <option>use_sender</option>), you should think about possible loops. Recipient checking is
60905 usually done between two hosts that are under the same management, and the host
60906 that receives the callouts is not normally configured to do callouts itself.
60907 Therefore, it is normally safe to use <option>use_postmaster</option> or <option>use_sender</option> in
60908 these circumstances.
60909 </para>
60910 <para>
60911 However, if you use a non-empty sender address for a callout to an arbitrary
60912 host, there is the likelihood that the remote host will itself initiate a
60913 callout check back to your host. As it is checking what appears to be a message
60914 sender, it is likely to use an empty address in MAIL, thus avoiding a
60915 callout loop. However, to be on the safe side it would be best to set up your
60916 own ACLs so that they do not do sender verification checks when the recipient
60917 is the address you use for header sender or postmaster callout checking.
60918 </para>
60919 <para>
60920 Another issue to think about when using non-empty senders for callouts is
60921 caching. When you set <option>mailfrom</option> or <option>use_sender</option>, the cache record is keyed
60922 by the sender/recipient combination; thus, for any given recipient, many more
60923 actual callouts are performed than when an empty sender or postmaster is used.
60924 </para>
60925 </section>
60926 <section id="SECTcallvercache">
60927 <title>Callout caching</title>
60928 <para>
60929 <indexterm role="concept">
60930 <primary>hints database</primary>
60931 <secondary>callout cache</secondary>
60932 </indexterm>
60933 <indexterm role="concept">
60934 <primary>callout</primary>
60935 <secondary>cache, description of</secondary>
60936 </indexterm>
60937 <indexterm role="concept">
60938 <primary>caching</primary>
60939 <secondary>callout</secondary>
60940 </indexterm>
60941 Exim caches the results of callouts in order to reduce the amount of resources
60942 used, unless you specify the <option>no_cache</option> parameter with the <option>callout</option>
60943 option. A hints database called <quote>callout</quote> is used for the cache. Two
60944 different record types are used: one records the result of a callout check for
60945 a specific address, and the other records information that applies to the
60946 entire domain (for example, that it accepts the local part <emphasis>postmaster</emphasis>).
60947 </para>
60948 <para>
60949 When an original callout fails, a detailed SMTP error message is given about
60950 the failure. However, for subsequent failures use the cache data, this message
60951 is not available.
60952 </para>
60953 <para>
60954 The expiry times for negative and positive address cache records are
60955 independent, and can be set by the global options <option>callout_negative_expire</option>
60956 (default 2h) and <option>callout_positive_expire</option> (default 24h), respectively.
60957 </para>
60958 <para>
60959 If a host gives a negative response to an SMTP connection, or rejects any
60960 commands up to and including
60961 </para>
60962 <literallayout class="monospaced">
60963 MAIL FROM:&lt;&gt;
60964 </literallayout>
60965 <para>
60966 (but not including the MAIL command with a non-empty address),
60967 any callout attempt is bound to fail. Exim remembers such failures in a
60968 domain cache record, which it uses to fail callouts for the domain without
60969 making new connections, until the domain record times out. There are two
60970 separate expiry times for domain cache records:
60971 <option>callout_domain_negative_expire</option> (default 3h) and
60972 <option>callout_domain_positive_expire</option> (default 7d).
60973 </para>
60974 <para>
60975 Domain records expire when the negative expiry time is reached if callouts
60976 cannot be made for the domain, or if the postmaster check failed.
60977 Otherwise, they expire when the positive expiry time is reached. This
60978 ensures that, for example, a host that stops accepting <quote>random</quote> local parts
60979 will eventually be noticed.
60980 </para>
60981 <para>
60982 The callout caching mechanism is based on the domain of the address that is
60983 being tested. If the domain routes to several hosts, it is assumed that their
60984 behaviour will be the same.
60985 </para>
60986 </section>
60987 <section id="SECTsenaddver">
60988 <title>Sender address verification reporting</title>
60989 <para>
60990 <indexterm role="concept">
60991 <primary>verifying</primary>
60992 <secondary>suppressing error details</secondary>
60993 </indexterm>
60994 See section <xref linkend="SECTaddressverification"/> for a general discussion of
60995 verification. When sender verification fails in an ACL, the details of the
60996 failure are given as additional output lines before the 550 response to the
60997 relevant SMTP command (RCPT or DATA). For example, if sender callout is in use,
60998 you might see:
60999 </para>
61000 <literallayout class="monospaced">
61001 MAIL FROM:&lt;xyz@abc.example&gt;
61002 250 OK
61003 RCPT TO:&lt;pqr@def.example&gt;
61004 550-Verification failed for &lt;xyz@abc.example&gt;
61005 550-Called:   192.168.34.43
61006 550-Sent:     RCPT TO:&lt;xyz@abc.example&gt;
61007 550-Response: 550 Unknown local part xyz in &lt;xyz@abc.example&gt;
61008 550 Sender verification failed
61009 </literallayout>
61010 <para>
61011 If more than one RCPT command fails in the same way, the details are given
61012 only for the first of them. However, some administrators do not want to send
61013 out this much information. You can suppress the details by adding
61014 <literal>/no_details</literal> to the ACL statement that requests sender verification. For
61015 example:
61016 </para>
61017 <literallayout class="monospaced">
61018 verify = sender/no_details
61019 </literallayout>
61020 </section>
61021 <section id="SECTredirwhilveri">
61022 <title>Redirection while verifying</title>
61023 <para>
61024 <indexterm role="concept">
61025 <primary>verifying</primary>
61026 <secondary>redirection while</secondary>
61027 </indexterm>
61028 <indexterm role="concept">
61029 <primary>address redirection</primary>
61030 <secondary>while verifying</secondary>
61031 </indexterm>
61032 A dilemma arises when a local address is redirected by aliasing or forwarding
61033 during verification: should the generated addresses themselves be verified,
61034 or should the successful expansion of the original address be enough to verify
61035 it? By default, Exim takes the following pragmatic approach:
61036 </para>
61037 <itemizedlist>
61038 <listitem>
61039 <para>
61040 When an incoming address is redirected to just one child address, verification
61041 continues with the child address, and if that fails to verify, the original
61042 verification also fails.
61043 </para>
61044 </listitem>
61045 <listitem>
61046 <para>
61047 When an incoming address is redirected to more than one child address,
61048 verification does not continue. A success result is returned.
61049 </para>
61050 </listitem>
61051 </itemizedlist>
61052 <para>
61053 This seems the most reasonable behaviour for the common use of aliasing as a
61054 way of redirecting different local parts to the same mailbox. It means, for
61055 example, that a pair of alias entries of the form
61056 </para>
61057 <literallayout class="monospaced">
61058 A.Wol:   aw123
61059 aw123:   :fail: Gone away, no forwarding address
61060 </literallayout>
61061 <para>
61062 work as expected, with both local parts causing verification failure. When a
61063 redirection generates more than one address, the behaviour is more like a
61064 mailing list, where the existence of the alias itself is sufficient for
61065 verification to succeed.
61066 </para>
61067 <para>
61068 It is possible, however, to change the default behaviour so that all successful
61069 redirections count as successful verifications, however many new addresses are
61070 generated. This is specified by the <option>success_on_redirect</option> verification
61071 option. For example:
61072 </para>
61073 <literallayout class="monospaced">
61074 require verify = recipient/success_on_redirect/callout=10s
61075 </literallayout>
61076 <para>
61077 In this example, verification succeeds if a router generates a new address, and
61078 the callout does not occur, because no address was routed to a remote host.
61079 </para>
61080 <para>
61081 When verification is being tested via the <option>-bv</option> option, the treatment of
61082 redirections is as just described, unless the <option>-v</option> or any debugging option is
61083 also specified. In that case, full verification is done for every generated
61084 address and a report is output for each of them.
61085 </para>
61086 </section>
61087 <section id="SECTverifyCSA">
61088 <title>Client SMTP authorization (CSA)</title>
61089 <para>
61090 <indexterm role="concept">
61091 <primary>CSA</primary>
61092 <secondary>verifying</secondary>
61093 </indexterm>
61094 Client SMTP Authorization is a system that allows a site to advertise
61095 which machines are and are not permitted to send email. This is done by placing
61096 special SRV records in the DNS; these are looked up using the client&#x2019;s HELO
61097 domain. At the time of writing, CSA is still an Internet Draft. Client SMTP
61098 Authorization checks in Exim are performed by the ACL condition:
61099 </para>
61100 <literallayout class="monospaced">
61101 verify = csa
61102 </literallayout>
61103 <para>
61104 This fails if the client is not authorized. If there is a DNS problem, or if no
61105 valid CSA SRV record is found, or if the client is authorized, the condition
61106 succeeds. These three cases can be distinguished using the expansion variable
61107 <varname>$csa_status</varname>, which can take one of the values <quote>fail</quote>, <quote>defer</quote>,
61108 <quote>unknown</quote>, or <quote>ok</quote>. The condition does not itself defer because that would
61109 be likely to cause problems for legitimate email.
61110 </para>
61111 <para>
61112 The error messages produced by the CSA code include slightly more
61113 detail. If <varname>$csa_status</varname> is <quote>defer</quote>, this may be because of problems
61114 looking up the CSA SRV record, or problems looking up the CSA target
61115 address record. There are four reasons for <varname>$csa_status</varname> being <quote>fail</quote>:
61116 </para>
61117 <itemizedlist>
61118 <listitem>
61119 <para>
61120 The client&#x2019;s host name is explicitly not authorized.
61121 </para>
61122 </listitem>
61123 <listitem>
61124 <para>
61125 The client&#x2019;s IP address does not match any of the CSA target IP addresses.
61126 </para>
61127 </listitem>
61128 <listitem>
61129 <para>
61130 The client&#x2019;s host name is authorized but it has no valid target IP addresses
61131 (for example, the target&#x2019;s addresses are IPv6 and the client is using IPv4).
61132 </para>
61133 </listitem>
61134 <listitem>
61135 <para>
61136 The client&#x2019;s host name has no CSA SRV record but a parent domain has asserted
61137 that all subdomains must be explicitly authorized.
61138 </para>
61139 </listitem>
61140 </itemizedlist>
61141 <para>
61142 The <option>csa</option> verification condition can take an argument which is the domain to
61143 use for the DNS query. The default is:
61144 </para>
61145 <literallayout class="monospaced">
61146 verify = csa/$sender_helo_name
61147 </literallayout>
61148 <para>
61149 This implementation includes an extension to CSA. If the query domain
61150 is an address literal such as [192.0.2.95], or if it is a bare IP
61151 address, Exim searches for CSA SRV records in the reverse DNS as if
61152 the HELO domain was (for example) <emphasis>95.2.0.192.in-addr.arpa</emphasis>. Therefore it is
61153 meaningful to say:
61154 </para>
61155 <literallayout class="monospaced">
61156 verify = csa/$sender_host_address
61157 </literallayout>
61158 <para>
61159 In fact, this is the check that Exim performs if the client does not say HELO.
61160 This extension can be turned off by setting the main configuration option
61161 <option>dns_csa_use_reverse</option> to be false.
61162 </para>
61163 <para>
61164 If a CSA SRV record is not found for the domain itself, a search
61165 is performed through its parent domains for a record which might be
61166 making assertions about subdomains. The maximum depth of this search is limited
61167 using the main configuration option <option>dns_csa_search_limit</option>, which is 5 by
61168 default. Exim does not look for CSA SRV records in a top level domain, so the
61169 default settings handle HELO domains as long as seven
61170 (<emphasis>hostname.five.four.three.two.one.com</emphasis>). This encompasses the vast majority
61171 of legitimate HELO domains.
61172 </para>
61173 <para>
61174 The <emphasis>dnsdb</emphasis> lookup also has support for CSA. Although <emphasis>dnsdb</emphasis> also supports
61175 direct SRV lookups, this is not sufficient because of the extra parent domain
61176 search behaviour of CSA, and (as with PTR lookups) <emphasis>dnsdb</emphasis> also turns IP
61177 addresses into lookups in the reverse DNS space. The result of a successful
61178 lookup such as:
61179 </para>
61180 <literallayout class="monospaced">
61181 ${lookup dnsdb {csa=$sender_helo_name}}
61182 </literallayout>
61183 <para>
61184 has two space-separated fields: an authorization code and a target host name.
61185 The authorization code can be <quote>Y</quote> for yes, <quote>N</quote> for no, <quote>X</quote> for explicit
61186 authorization required but absent, or <quote>?</quote> for unknown.
61187 </para>
61188 </section>
61189 <section id="SECTverifyPRVS">
61190 <title>Bounce address tag validation</title>
61191 <para>
61192 <indexterm role="concept">
61193 <primary>BATV, verifying</primary>
61194 </indexterm>
61195 Bounce address tag validation (BATV) is a scheme whereby the envelope senders
61196 of outgoing messages have a cryptographic, timestamped <quote>tag</quote> added to them.
61197 Genuine incoming bounce messages should therefore always be addressed to
61198 recipients that have a valid tag. This scheme is a way of detecting unwanted
61199 bounce messages caused by sender address forgeries (often called <quote>collateral
61200 spam</quote>), because the recipients of such messages do not include valid tags.
61201 </para>
61202 <para>
61203 There are two expansion items to help with the implementation of the BATV
61204 <quote>prvs</quote> (private signature) scheme in an Exim configuration. This scheme signs
61205 the original envelope sender address by using a simple key to add a hash of the
61206 address and some time-based randomizing information. The <option>prvs</option> expansion
61207 item creates a signed address, and the <option>prvscheck</option> expansion item checks one.
61208 The syntax of these expansion items is described in section
61209 <xref linkend="SECTexpansionitems"/>.
61210 The validity period on signed addresses is seven days.
61211 </para>
61212 <para>
61213 As an example, suppose the secret per-address keys are stored in an MySQL
61214 database. A query to look up the key for an address could be defined as a macro
61215 like this:
61216 </para>
61217 <literallayout class="monospaced">
61218 PRVSCHECK_SQL = ${lookup mysql{SELECT secret FROM batv_prvs \
61219                 WHERE sender='${quote_mysql:$prvscheck_address}'\
61220                 }{$value}}
61221 </literallayout>
61222 <para>
61223 Suppose also that the senders who make use of BATV are defined by an address
61224 list called <option>batv_senders</option>. Then, in the ACL for RCPT commands, you could
61225 use this:
61226 </para>
61227 <literallayout class="monospaced">
61228 # Bounces: drop unsigned addresses for BATV senders
61229 deny message = This address does not send an unsigned reverse path
61230      senders = :
61231      recipients = +batv_senders
61232
61233 # Bounces: In case of prvs-signed address, check signature.
61234 deny message = Invalid reverse path signature.
61235      senders = :
61236      condition  = ${prvscheck {$local_part@$domain}\
61237                   {PRVSCHECK_SQL}{1}}
61238      !condition = $prvscheck_result
61239 </literallayout>
61240 <para>
61241 The first statement rejects recipients for bounce messages that are addressed
61242 to plain BATV sender addresses, because it is known that BATV senders do not
61243 send out messages with plain sender addresses. The second statement rejects
61244 recipients that are prvs-signed, but with invalid signatures (either because
61245 the key is wrong, or the signature has timed out).
61246 </para>
61247 <para>
61248 A non-prvs-signed address is not rejected by the second statement, because the
61249 <option>prvscheck</option> expansion yields an empty string if its first argument is not a
61250 prvs-signed address, thus causing the <option>condition</option> condition to be false. If
61251 the first argument is a syntactically valid prvs-signed address, the yield is
61252 the third string (in this case <quote>1</quote>), whether or not the cryptographic and
61253 timeout checks succeed. The <varname>$prvscheck_result</varname> variable contains the result
61254 of the checks (empty for failure, <quote>1</quote> for success).
61255 </para>
61256 <para>
61257 There is one more issue you must consider when implementing prvs-signing:
61258 you have to ensure that the routers accept prvs-signed addresses and
61259 deliver them correctly. The easiest way to handle this is to use a <command>redirect</command>
61260 router to remove the signature with a configuration along these lines:
61261 </para>
61262 <literallayout class="monospaced">
61263 batv_redirect:
61264   driver = redirect
61265   data = ${prvscheck {$local_part@$domain}{PRVSCHECK_SQL}}
61266 </literallayout>
61267 <para>
61268 This works because, if the third argument of <option>prvscheck</option> is empty, the result
61269 of the expansion of a prvs-signed address is the decoded value of the original
61270 address. This router should probably be the first of your routers that handles
61271 local addresses.
61272 </para>
61273 <para>
61274 To create BATV-signed addresses in the first place, a transport of this form
61275 can be used:
61276 </para>
61277 <literallayout class="monospaced">
61278 external_smtp_batv:
61279   driver = smtp
61280   return_path = ${prvs {$return_path} \
61281                        {${lookup mysql{SELECT \
61282                        secret FROM batv_prvs WHERE \
61283                        sender='${quote_mysql:$sender_address}'} \
61284                        {$value}fail}}}
61285 </literallayout>
61286 <para>
61287 If no key can be found for the existing return path, no signing takes place.
61288 </para>
61289 </section>
61290 <section id="SECTrelaycontrol">
61291 <title>Using an ACL to control relaying</title>
61292 <para>
61293 <indexterm role="concept">
61294 <primary>access control lists (ACLs)</primary>
61295 <secondary>relay control</secondary>
61296 </indexterm>
61297 <indexterm role="concept">
61298 <primary>relaying</primary>
61299 <secondary>control by ACL</secondary>
61300 </indexterm>
61301 <indexterm role="concept">
61302 <primary>policy control</primary>
61303 <secondary>relay control</secondary>
61304 </indexterm>
61305 An MTA is said to <emphasis>relay</emphasis> a message if it receives it from some host and
61306 delivers it directly to another host as a result of a remote address contained
61307 within it. Redirecting a local address via an alias or forward file and then
61308 passing the message on to another host is not relaying,
61309 <indexterm role="concept">
61310 <primary><quote>percent hack</quote></primary>
61311 </indexterm>
61312 but a redirection as a result of the <quote>percent hack</quote> is.
61313 </para>
61314 <para>
61315 Two kinds of relaying exist, which are termed <quote>incoming</quote> and <quote>outgoing</quote>.
61316 A host which is acting as a gateway or an MX backup is concerned with incoming
61317 relaying from arbitrary hosts to a specific set of domains. On the other hand,
61318 a host which is acting as a smart host for a number of clients is concerned
61319 with outgoing relaying from those clients to the Internet at large. Often the
61320 same host is fulfilling both functions,
61321 but in principle these two kinds of relaying are entirely independent. What is
61322 not wanted is the transmission of mail from arbitrary remote hosts through your
61323 system to arbitrary domains.
61324 </para>
61325 <para>
61326 You can implement relay control by means of suitable statements in the ACL that
61327 runs for each RCPT command. For convenience, it is often easiest to use
61328 Exim&#x2019;s named list facility to define the domains and hosts involved. For
61329 example, suppose you want to do the following:
61330 </para>
61331 <itemizedlist>
61332 <listitem>
61333 <para>
61334 Deliver a number of domains to mailboxes on the local host (or process them
61335 locally in some other way). Let&#x2019;s say these are <emphasis>my.dom1.example</emphasis> and
61336 <emphasis>my.dom2.example</emphasis>.
61337 </para>
61338 </listitem>
61339 <listitem>
61340 <para>
61341 Relay mail for a number of other domains for which you are the secondary MX.
61342 These might be <emphasis>friend1.example</emphasis> and <emphasis>friend2.example</emphasis>.
61343 </para>
61344 </listitem>
61345 <listitem>
61346 <para>
61347 Relay mail from the hosts on your local LAN, to whatever domains are involved.
61348 Suppose your LAN is 192.168.45.0/24.
61349 </para>
61350 </listitem>
61351 </itemizedlist>
61352 <para>
61353 In the main part of the configuration, you put the following definitions:
61354 </para>
61355 <literallayout class="monospaced">
61356 domainlist local_domains    = my.dom1.example : my.dom2.example
61357 domainlist relay_to_domains = friend1.example : friend2.example
61358 hostlist   relay_from_hosts = 192.168.45.0/24
61359 </literallayout>
61360 <para>
61361 Now you can use these definitions in the ACL that is run for every RCPT
61362 command:
61363 </para>
61364 <literallayout class="monospaced">
61365 acl_check_rcpt:
61366   accept domains = +local_domains : +relay_to_domains
61367   accept hosts   = +relay_from_hosts
61368 </literallayout>
61369 <para>
61370 The first statement accepts any RCPT command that contains an address in
61371 the local or relay domains. For any other domain, control passes to the second
61372 statement, which accepts the command only if it comes from one of the relay
61373 hosts. In practice, you will probably want to make your ACL more sophisticated
61374 than this, for example, by including sender and recipient verification. The
61375 default configuration includes a more comprehensive example, which is described
61376 in chapter <xref linkend="CHAPdefconfil"/>.
61377 </para>
61378 </section>
61379 <section id="SECTcheralcon">
61380 <title>Checking a relay configuration</title>
61381 <para>
61382 <indexterm role="concept">
61383 <primary>relaying</primary>
61384 <secondary>checking control of</secondary>
61385 </indexterm>
61386 You can check the relay characteristics of your configuration in the same way
61387 that you can test any ACL behaviour for an incoming SMTP connection, by using
61388 the <option>-bh</option> option to run a fake SMTP session with which you interact.
61389 <indexterm role="concept" startref="IIDacl" class="endofrange"/>
61390 </para>
61391 </section>
61392 </chapter>
61393
61394 <chapter id="CHAPexiscan">
61395 <title>Content scanning at ACL time</title>
61396 <para>
61397 <indexterm role="concept" id="IIDcosca" class="startofrange">
61398 <primary>content scanning</primary>
61399 <secondary>at ACL time</secondary>
61400 </indexterm>
61401 The extension of Exim to include content scanning at ACL time, formerly known
61402 as <quote>exiscan</quote>, was originally implemented as a patch by Tom Kistner. The code
61403 was integrated into the main source for Exim release 4.50, and Tom continues to
61404 maintain it. Most of the wording of this chapter is taken from Tom&#x2019;s
61405 specification.
61406 </para>
61407 <para>
61408 It is also possible to scan the content of messages at other times. The
61409 <function>local_scan()</function> function (see chapter <xref linkend="CHAPlocalscan"/>) allows for content
61410 scanning after all the ACLs have run. A transport filter can be used to scan
61411 messages at delivery time (see the <option>transport_filter</option> option, described in
61412 chapter <xref linkend="CHAPtransportgeneric"/>).
61413 </para>
61414 <para>
61415 If you want to include the ACL-time content-scanning features when you compile
61416 Exim, you need to arrange for WITH_CONTENT_SCAN to be defined in your
61417 <filename>Local/Makefile</filename>. When you do that, the Exim binary is built with:
61418 </para>
61419 <itemizedlist>
61420 <listitem>
61421 <para>
61422 Two additional ACLs (<option>acl_smtp_mime</option> and <option>acl_not_smtp_mime</option>) that are run
61423 for all MIME parts for SMTP and non-SMTP messages, respectively.
61424 </para>
61425 </listitem>
61426 <listitem>
61427 <para>
61428 Additional ACL conditions and modifiers: <option>decode</option>, <option>malware</option>,
61429 <option>mime_regex</option>, <option>regex</option>, and <option>spam</option>. These can be used in the ACL that is
61430 run at the end of message reception (the <option>acl_smtp_data</option> ACL).
61431 </para>
61432 </listitem>
61433 <listitem>
61434 <para>
61435 An additional control feature (<quote>no_mbox_unspool</quote>) that saves spooled copies
61436 of messages, or parts of messages, for debugging purposes.
61437 </para>
61438 </listitem>
61439 <listitem>
61440 <para>
61441 Additional expansion variables that are set in the new ACL and by the new
61442 conditions.
61443 </para>
61444 </listitem>
61445 <listitem>
61446 <para>
61447 Two new main configuration options: <option>av_scanner</option> and <option>spamd_address</option>.
61448 </para>
61449 </listitem>
61450 </itemizedlist>
61451 <para>
61452 Content-scanning is continually evolving, and new features are still being
61453 added. While such features are still unstable and liable to incompatible
61454 changes, they are made available in Exim by setting options whose names begin
61455 EXPERIMENTAL_ in <filename>Local/Makefile</filename>. Such features are not documented in
61456 this manual. You can find out about them by reading the file called
61457 <filename>doc/experimental.txt</filename>.
61458 </para>
61459 <para>
61460 All the content-scanning facilities work on a MBOX copy of the message that is
61461 temporarily created in a file called:
61462 </para>
61463 <literallayout>
61464 &lt;<emphasis>spool_directory</emphasis>&gt;<literal>/scan/</literal>&lt;<emphasis>message_id</emphasis>&gt;/&lt;<emphasis>message_id</emphasis>&gt;<literal>.eml</literal>
61465 </literallayout>
61466 <para>
61467 The <filename>.eml</filename> extension is a friendly hint to virus scanners that they can
61468 expect an MBOX-like structure inside that file. The file is created when the
61469 first content scanning facility is called. Subsequent calls to content
61470 scanning conditions open the same file again. The directory is recursively
61471 removed when the <option>acl_smtp_data</option> ACL has finished running, unless
61472 </para>
61473 <literallayout class="monospaced">
61474 control = no_mbox_unspool
61475 </literallayout>
61476 <para>
61477 has been encountered. When the MIME ACL decodes files, they are put into the
61478 same directory by default.
61479 </para>
61480 <section id="SECTscanvirus">
61481 <title>Scanning for viruses</title>
61482 <para>
61483 <indexterm role="concept">
61484 <primary>virus scanning</primary>
61485 </indexterm>
61486 <indexterm role="concept">
61487 <primary>content scanning</primary>
61488 <secondary>for viruses</secondary>
61489 </indexterm>
61490 <indexterm role="concept">
61491 <primary>content scanning</primary>
61492 <secondary>the <option>malware</option> condition</secondary>
61493 </indexterm>
61494 The <option>malware</option> ACL condition lets you connect virus scanner software to Exim.
61495 It supports a <quote>generic</quote> interface to scanners called via the shell, and
61496 specialized interfaces for <quote>daemon</quote> type virus scanners, which are resident
61497 in memory and thus are much faster.
61498 </para>
61499 <para revisionflag="changed">
61500 Since message data needs to have arrived,
61501 the condition may be only called in ACL defined by
61502 <option>acl_smtp_data</option>,
61503 <option>acl_smtp_data_prdr</option>,
61504 <option>acl_smtp_mime</option> or
61505 <option>acl_smtp_dkim</option>
61506 </para>
61507 <para>
61508 A timeout of 2 minutes is applied to a scanner call (by default);
61509 if it expires then a defer action is taken.
61510 </para>
61511 <para>
61512 <indexterm role="option">
61513 <primary><option>av_scanner</option></primary>
61514 </indexterm>
61515 You can set the <option>av_scanner</option> option in the main part of the configuration
61516 to specify which scanner to use, together with any additional options that
61517 are needed. The basic syntax is as follows:
61518 </para>
61519 <literallayout>
61520 <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>
61521 </literallayout>
61522 <para>
61523 If you do not set <option>av_scanner</option>, it defaults to
61524 </para>
61525 <literallayout class="monospaced">
61526 av_scanner = sophie:/var/run/sophie
61527 </literallayout>
61528 <para>
61529 If the value of <option>av_scanner</option> starts with a dollar character, it is expanded
61530 before use.
61531 The usual list-parsing of the content (see <xref linkend="SECTlistconstruct"/>) applies.
61532 The following scanner types are supported in this release,
61533 though individual ones can be included or not at build time:
61534 </para>
61535 <variablelist>
61536 <varlistentry>
61537 <term><option>avast</option></term>
61538 <listitem>
61539 <para>
61540 <indexterm role="concept">
61541 <primary>virus scanners</primary>
61542 <secondary>avast</secondary>
61543 </indexterm>
61544 This is the scanner daemon of Avast. It has been tested with Avast Core
61545 Security (currently at version 2.2.0).
61546 You can get a trial version at <emphasis role="bold"><ulink url="https://www.avast.com">https://www.avast.com</ulink></emphasis> or for Linux
61547 at <emphasis role="bold"><ulink url="https://www.avast.com/linux-server-antivirus">https://www.avast.com/linux-server-antivirus</ulink></emphasis>.
61548 This scanner type takes one option,
61549 which can be either a full path to a UNIX socket,
61550 or host and port specifiers separated by white space.
61551 The host may be a name or an IP address; the port is either a
61552 single number or a pair of numbers with a dash between.
61553 A list of options may follow. These options are interpreted on the
61554 Exim&#x2019;s side of the malware scanner, or are given on separate lines to
61555 the daemon as options before the main scan command.
61556 </para>
61557 <para>
61558 <indexterm role="concept">
61559 <primary><literal>pass_unscanned</literal></primary>
61560 <secondary>avast</secondary>
61561 </indexterm>
61562 If <literal>pass_unscanned</literal>
61563 is set, any files the Avast scanner can&#x2019;t scan (e.g.
61564 decompression bombs, or invalid archives) are considered clean. Use with
61565 care.
61566 </para>
61567 <para>
61568 For example:
61569 </para>
61570 <literallayout class="monospaced">
61571 av_scanner = avast:/var/run/avast/scan.sock:FLAGS -fullfiles:SENSITIVITY -pup
61572 av_scanner = avast:/var/run/avast/scan.sock:pass_unscanned:FLAGS -fullfiles:SENSITIVITY -pup
61573 av_scanner = avast:192.168.2.22 5036
61574 </literallayout>
61575 <para>
61576 If you omit the argument, the default path
61577 <filename>/var/run/avast/scan.sock</filename>
61578 is used.
61579 If you use a remote host,
61580 you need to make Exim&#x2019;s spool directory available to it,
61581 as the scanner is passed a file path, not file contents.
61582 For information about available commands and their options you may use
61583 </para>
61584 <literallayout class="monospaced">
61585 $ socat UNIX:/var/run/avast/scan.sock STDIO:
61586     FLAGS
61587     SENSITIVITY
61588     PACK
61589 </literallayout>
61590 <para>
61591 If the scanner returns a temporary failure (e.g. license issues, or
61592 permission problems), the message is deferred and a paniclog entry is
61593 written.  The usual <literal>defer_ok</literal> option is available.
61594 </para>
61595 </listitem></varlistentry>
61596 <varlistentry>
61597 <term><option>aveserver</option></term>
61598 <listitem>
61599 <para>
61600 <indexterm role="concept">
61601 <primary>virus scanners</primary>
61602 <secondary>Kaspersky</secondary>
61603 </indexterm>
61604 This is the scanner daemon of Kaspersky Version 5. You can get a trial version
61605 at <emphasis role="bold"><ulink url="https://www.kaspersky.com/">https://www.kaspersky.com/</ulink></emphasis>. This scanner type takes one option,
61606 which is the path to the daemon&#x2019;s UNIX socket. The default is shown in this
61607 example:
61608 </para>
61609 <literallayout class="monospaced">
61610 av_scanner = aveserver:/var/run/aveserver
61611 </literallayout>
61612 </listitem></varlistentry>
61613 <varlistentry>
61614 <term><option>clamd</option></term>
61615 <listitem>
61616 <para>
61617 <indexterm role="concept">
61618 <primary>virus scanners</primary>
61619 <secondary>clamd</secondary>
61620 </indexterm>
61621 This daemon-type scanner is GPL and free. You can get it at
61622 <emphasis role="bold"><ulink url="https://www.clamav.net/">https://www.clamav.net/</ulink></emphasis>. Some older versions of clamd do not seem to
61623 unpack MIME containers, so it used to be recommended to unpack MIME attachments
61624 in the MIME ACL. This is no longer believed to be necessary.
61625 </para>
61626 <para>
61627 The options are a list of server specifiers, which may be
61628 a UNIX socket specification,
61629 a TCP socket specification,
61630 or a (global) option.
61631 </para>
61632 <para>
61633 A socket specification consists of a space-separated list.
61634 For a Unix socket the first element is a full path for the socket,
61635 for a TCP socket the first element is the IP address
61636 and the second a port number,
61637 Any further elements are per-server (non-global) options.
61638 These per-server options are supported:
61639 </para>
61640 <literallayout class="monospaced">
61641 retry=&lt;timespec&gt;  Retry on connect fail
61642 </literallayout>
61643 <para>
61644 The <literal>retry</literal> option specifies a time after which a single retry for
61645 a failed connect is made.  The default is to not retry.
61646 </para>
61647 <para>
61648 If a Unix socket file is specified, only one server is supported.
61649 </para>
61650 <para>
61651 Examples:
61652 </para>
61653 <literallayout class="monospaced">
61654 av_scanner = clamd:/opt/clamd/socket
61655 av_scanner = clamd:192.0.2.3 1234
61656 av_scanner = clamd:192.0.2.3 1234:local
61657 av_scanner = clamd:192.0.2.3 1234 retry=10s
61658 av_scanner = clamd:192.0.2.3 1234 : 192.0.2.4 1234
61659 </literallayout>
61660 <para>
61661 If the value of av_scanner points to a UNIX socket file or contains the
61662 <literal>local</literal>
61663 option, then the ClamAV interface will pass a filename containing the data
61664 to be scanned, which should normally result in less I/O happening and be
61665 more efficient.  Normally in the TCP case, the data is streamed to ClamAV as
61666 Exim does not assume that there is a common filesystem with the remote host.
61667 </para>
61668 <para>
61669 The final example shows that multiple TCP targets can be specified.  Exim will
61670 randomly use one for each incoming email (i.e. it load balances them).  Note
61671 that only TCP targets may be used if specifying a list of scanners; a UNIX
61672 socket cannot be mixed in with TCP targets.  If one of the servers becomes
61673 unavailable, Exim will try the remaining one(s) until it finds one that works.
61674 When a clamd server becomes unreachable, Exim will log a message.  Exim does
61675 not keep track of scanner state between multiple messages, and the scanner
61676 selection is random, so the message will get logged in the mainlog for each
61677 email that the down scanner gets chosen first (message wrapped to be readable):
61678 </para>
61679 <literallayout class="monospaced">
61680 2013-10-09 14:30:39 1VTumd-0000Y8-BQ malware acl condition:
61681    clamd: connection to localhost, port 3310 failed
61682    (Connection refused)
61683 </literallayout>
61684 <para>
61685 If the option is unset, the default is <filename>/tmp/clamd</filename>. Thanks to David Saez for
61686 contributing the code for this scanner.
61687 </para>
61688 </listitem></varlistentry>
61689 <varlistentry>
61690 <term><option>cmdline</option></term>
61691 <listitem>
61692 <para>
61693 <indexterm role="concept">
61694 <primary>virus scanners</primary>
61695 <secondary>command line interface</secondary>
61696 </indexterm>
61697 This is the keyword for the generic command line scanner interface. It can be
61698 used to attach virus scanners that are invoked from the shell. This scanner
61699 type takes 3 mandatory options:
61700 </para>
61701 <orderedlist numeration="arabic">
61702 <listitem>
61703 <para>
61704 The full path and name of the scanner binary, with all command line options,
61705 and a placeholder (<literal>%s</literal>) for the directory to scan.
61706 </para>
61707 </listitem>
61708 <listitem>
61709 <para>
61710 A regular expression to match against the STDOUT and STDERR output of the
61711 virus scanner. If the expression matches, a virus was found. You must make
61712 absolutely sure that this expression matches on <quote>virus found</quote>. This is called
61713 the <quote>trigger</quote> expression.
61714 </para>
61715 </listitem>
61716 <listitem>
61717 <para>
61718 Another regular expression, containing exactly one pair of parentheses, to
61719 match the name of the virus found in the scanners output. This is called the
61720 <quote>name</quote> expression.
61721 </para>
61722 </listitem>
61723 </orderedlist>
61724 <para>
61725 For example, Sophos Sweep reports a virus on a line like this:
61726 </para>
61727 <literallayout class="monospaced">
61728 Virus 'W32/Magistr-B' found in file ./those.bat
61729 </literallayout>
61730 <para>
61731 For the trigger expression, we can match the phrase <quote>found in file</quote>. For the
61732 name expression, we want to extract the W32/Magistr-B string, so we can match
61733 for the single quotes left and right of it. Altogether, this makes the
61734 configuration setting:
61735 </para>
61736 <literallayout class="monospaced">
61737 av_scanner = cmdline:\
61738              /path/to/sweep -ss -all -rec -archive %s:\
61739              found in file:'(.+)'
61740 </literallayout>
61741 </listitem></varlistentry>
61742 <varlistentry>
61743 <term><option>drweb</option></term>
61744 <listitem>
61745 <para>
61746 <indexterm role="concept">
61747 <primary>virus scanners</primary>
61748 <secondary>DrWeb</secondary>
61749 </indexterm>
61750 The DrWeb daemon scanner (<emphasis role="bold"><ulink url="https://www.sald.ru/">https://www.sald.ru/</ulink></emphasis>) interface
61751 takes one option,
61752 either a full path to a UNIX socket,
61753 or host and port specifiers separated by white space.
61754 The host may be a name or an IP address; the port is either a
61755 single number or a pair of numbers with a dash between.
61756 For example:
61757 </para>
61758 <literallayout class="monospaced">
61759 av_scanner = drweb:/var/run/drwebd.sock
61760 av_scanner = drweb:192.168.2.20 31337
61761 </literallayout>
61762 <para>
61763 If you omit the argument, the default path <filename>/usr/local/drweb/run/drwebd.sock</filename>
61764 is used. Thanks to Alex Miller for contributing the code for this scanner.
61765 </para>
61766 </listitem></varlistentry>
61767 <varlistentry>
61768 <term><option>f-protd</option></term>
61769 <listitem>
61770 <para>
61771 <indexterm role="concept">
61772 <primary>virus scanners</primary>
61773 <secondary>f-protd</secondary>
61774 </indexterm>
61775 The f-protd scanner is accessed via HTTP over TCP.
61776 One argument is taken, being a space-separated hostname and port number
61777 (or port-range).
61778 For example:
61779 </para>
61780 <literallayout class="monospaced">
61781 av_scanner = f-protd:localhost 10200-10204
61782 </literallayout>
61783 <para>
61784 If you omit the argument, the default values shown above are used.
61785 </para>
61786 </listitem></varlistentry>
61787 <varlistentry>
61788 <term><option>f-prot6d</option></term>
61789 <listitem>
61790 <para>
61791 <indexterm role="concept">
61792 <primary>virus scanners</primary>
61793 <secondary>f-prot6d</secondary>
61794 </indexterm>
61795 The f-prot6d scanner is accessed using the FPSCAND protocol over TCP.
61796 One argument is taken, being a space-separated hostname and port number.
61797 For example:
61798 </para>
61799 <literallayout class="monospaced">
61800 av_scanner = f-prot6d:localhost 10200
61801 </literallayout>
61802 <para>
61803 If you omit the argument, the default values show above are used.
61804 </para>
61805 </listitem></varlistentry>
61806 <varlistentry>
61807 <term><option>fsecure</option></term>
61808 <listitem>
61809 <para>
61810 <indexterm role="concept">
61811 <primary>virus scanners</primary>
61812 <secondary>F-Secure</secondary>
61813 </indexterm>
61814 The F-Secure daemon scanner (<emphasis role="bold"><ulink url="https://www.f-secure.com/">https://www.f-secure.com/</ulink></emphasis>) takes one
61815 argument which is the path to a UNIX socket. For example:
61816 </para>
61817 <literallayout class="monospaced">
61818 av_scanner = fsecure:/path/to/.fsav
61819 </literallayout>
61820 <para>
61821 If no argument is given, the default is <filename>/var/run/.fsav</filename>. Thanks to Johan
61822 Thelmen for contributing the code for this scanner.
61823 </para>
61824 </listitem></varlistentry>
61825 <varlistentry>
61826 <term><option>kavdaemon</option></term>
61827 <listitem>
61828 <para>
61829 <indexterm role="concept">
61830 <primary>virus scanners</primary>
61831 <secondary>Kaspersky</secondary>
61832 </indexterm>
61833 This is the scanner daemon of Kaspersky Version 4. This version of the
61834 Kaspersky scanner is outdated. Please upgrade (see <option>aveserver</option> above). This
61835 scanner type takes one option, which is the path to the daemon&#x2019;s UNIX socket.
61836 For example:
61837 </para>
61838 <literallayout class="monospaced">
61839 av_scanner = kavdaemon:/opt/AVP/AvpCtl
61840 </literallayout>
61841 <para>
61842 The default path is <filename>/var/run/AvpCtl</filename>.
61843 </para>
61844 </listitem></varlistentry>
61845 <varlistentry>
61846 <term><option>mksd</option></term>
61847 <listitem>
61848 <para>
61849 <indexterm role="concept">
61850 <primary>virus scanners</primary>
61851 <secondary>mksd</secondary>
61852 </indexterm>
61853 This was a daemon type scanner that is aimed mainly at Polish users,
61854 though some documentation was available in English.
61855 The history can be shown at <emphasis role="bold"><ulink url="https://en.wikipedia.org/wiki/Mks_vir">https://en.wikipedia.org/wiki/Mks_vir</ulink></emphasis>
61856 and this appears to be a candidate for removal from Exim, unless
61857 we are informed of other virus scanners which use the same protocol
61858 to integrate.
61859 The only option for this scanner type is
61860 the maximum number of processes used simultaneously to scan the attachments,
61861 provided that mksd has
61862 been run with at least the same number of child processes. For example:
61863 </para>
61864 <literallayout class="monospaced">
61865 av_scanner = mksd:2
61866 </literallayout>
61867 <para>
61868 You can safely omit this option (the default value is 1).
61869 </para>
61870 </listitem></varlistentry>
61871 <varlistentry>
61872 <term><option>sock</option></term>
61873 <listitem>
61874 <para>
61875 <indexterm role="concept">
61876 <primary>virus scanners</primary>
61877 <secondary>simple socket-connected</secondary>
61878 </indexterm>
61879 This is a general-purpose way of talking to simple scanner daemons
61880 running on the local machine.
61881 There are four options:
61882 an address (which may be an IP address and port, or the path of a Unix socket),
61883 a commandline to send (may include a single %s which will be replaced with
61884 the path to the mail file to be scanned),
61885 an RE to trigger on from the returned data,
61886 and an RE to extract malware_name from the returned data.
61887 For example:
61888 </para>
61889 <literallayout class="monospaced">
61890 av_scanner = sock:127.0.0.1 6001:%s:(SPAM|VIRUS):(.*)$
61891 </literallayout>
61892 <para>
61893 Note that surrounding whitespace is stripped from each option, meaning
61894 there is no way to specify a trailing newline.
61895 The socket specifier and both regular-expressions are required.
61896 Default for the commandline is <filename>%s\n</filename> (note this does have a trailing newline);
61897 specify an empty element to get this.
61898 </para>
61899 </listitem></varlistentry>
61900 <varlistentry>
61901 <term><option>sophie</option></term>
61902 <listitem>
61903 <para>
61904 <indexterm role="concept">
61905 <primary>virus scanners</primary>
61906 <secondary>Sophos and Sophie</secondary>
61907 </indexterm>
61908 Sophie is a daemon that uses Sophos&#x2019; <option>libsavi</option> library to scan for viruses.
61909 You can get Sophie at <emphasis role="bold"><ulink url="http://sophie.sourceforge.net/">http://sophie.sourceforge.net/</ulink></emphasis>. The only option
61910 for this scanner type is the path to the UNIX socket that Sophie uses for
61911 client communication. For example:
61912 </para>
61913 <literallayout class="monospaced">
61914 av_scanner = sophie:/tmp/sophie
61915 </literallayout>
61916 <para>
61917 The default path is <filename>/var/run/sophie</filename>, so if you are using this, you can omit
61918 the option.
61919 </para>
61920 </listitem></varlistentry>
61921 </variablelist>
61922 <para>
61923 When <option>av_scanner</option> is correctly set, you can use the <option>malware</option> condition in
61924 the DATA ACL. <emphasis role="bold">Note</emphasis>: You cannot use the <option>malware</option> condition in the MIME
61925 ACL.
61926 </para>
61927 <para>
61928 The <option>av_scanner</option> option is expanded each time <option>malware</option> is called. This
61929 makes it possible to use different scanners. See further below for an example.
61930 The <option>malware</option> condition caches its results, so when you use it multiple times
61931 for the same message, the actual scanning process is only carried out once.
61932 However, using expandable items in <option>av_scanner</option> disables this caching, in
61933 which case each use of the <option>malware</option> condition causes a new scan of the
61934 message.
61935 </para>
61936 <para>
61937 The <option>malware</option> condition takes a right-hand argument that is expanded before
61938 use and taken as a list, slash-separated by default.
61939 The first element can then be one of
61940 </para>
61941 <itemizedlist>
61942 <listitem>
61943 <para>
61944 <quote>true</quote>, <quote>*</quote>, or <quote>1</quote>, in which case the message is scanned for viruses.
61945 The condition succeeds if a virus was found, and fail otherwise. This is the
61946 recommended usage.
61947 </para>
61948 </listitem>
61949 <listitem>
61950 <para>
61951 <quote>false</quote> or <quote>0</quote> or an empty string, in which case no scanning is done and
61952 the condition fails immediately.
61953 </para>
61954 </listitem>
61955 <listitem>
61956 <para>
61957 A regular expression, in which case the message is scanned for viruses. The
61958 condition succeeds if a virus is found and its name matches the regular
61959 expression. This allows you to take special actions on certain types of virus.
61960 Note that <quote>/</quote> characters in the RE must be doubled due to the list-processing,
61961 unless the separator is changed (in the usual way <xref linkend="SECTlistsepchange"/>).
61962 </para>
61963 </listitem>
61964 </itemizedlist>
61965 <para>
61966 You can append a <literal>defer_ok</literal> element to the <option>malware</option> argument list to accept
61967 messages even if there is a problem with the virus scanner.
61968 Otherwise, such a problem causes the ACL to defer.
61969 </para>
61970 <para>
61971 You can append a <literal>tmo=&lt;val&gt;</literal> element to the <option>malware</option> argument list to
61972 specify a non-default timeout.  The default is two minutes.
61973 For example:
61974 </para>
61975 <literallayout class="monospaced">
61976 malware = * / defer_ok / tmo=10s
61977 </literallayout>
61978 <para>
61979 A timeout causes the ACL to defer.
61980 </para>
61981 <para>
61982 <indexterm role="variable">
61983 <primary><varname>$callout_address</varname></primary>
61984 </indexterm>
61985 When a connection is made to the scanner the expansion variable <varname>$callout_address</varname>
61986 is set to record the actual address used.
61987 </para>
61988 <para>
61989 <indexterm role="variable">
61990 <primary><varname>$malware_name</varname></primary>
61991 </indexterm>
61992 When a virus is found, the condition sets up an expansion variable called
61993 <varname>$malware_name</varname> that contains the name of the virus. You can use it in a
61994 <option>message</option> modifier that specifies the error returned to the sender, and/or in
61995 logging data.
61996 </para>
61997 <para>
61998 Beware the interaction of Exim&#x2019;s <option>message_size_limit</option> with any size limits
61999 imposed by your anti-virus scanner.
62000 </para>
62001 <para>
62002 Here is a very simple scanning example:
62003 </para>
62004 <literallayout class="monospaced">
62005 deny message = This message contains malware ($malware_name)
62006      malware = *
62007 </literallayout>
62008 <para>
62009 The next example accepts messages when there is a problem with the scanner:
62010 </para>
62011 <literallayout class="monospaced">
62012 deny message = This message contains malware ($malware_name)
62013      malware = */defer_ok
62014 </literallayout>
62015 <para>
62016 The next example shows how to use an ACL variable to scan with both sophie and
62017 aveserver. It assumes you have set:
62018 </para>
62019 <literallayout class="monospaced">
62020 av_scanner = $acl_m0
62021 </literallayout>
62022 <para>
62023 in the main Exim configuration.
62024 </para>
62025 <literallayout class="monospaced">
62026 deny message = This message contains malware ($malware_name)
62027      set acl_m0 = sophie
62028      malware = *
62029
62030 deny message = This message contains malware ($malware_name)
62031      set acl_m0 = aveserver
62032      malware = *
62033 </literallayout>
62034 </section>
62035 <section id="SECTscanspamass">
62036 <title>Scanning with SpamAssassin and Rspamd</title>
62037 <para>
62038 <indexterm role="concept">
62039 <primary>content scanning</primary>
62040 <secondary>for spam</secondary>
62041 </indexterm>
62042 <indexterm role="concept">
62043 <primary>spam scanning</primary>
62044 </indexterm>
62045 <indexterm role="concept">
62046 <primary>SpamAssassin</primary>
62047 </indexterm>
62048 <indexterm role="concept">
62049 <primary>Rspamd</primary>
62050 </indexterm>
62051 The <option>spam</option> ACL condition calls SpamAssassin&#x2019;s <option>spamd</option> daemon to get a spam
62052 score and a report for the message.
62053 Support is also provided for Rspamd.
62054 </para>
62055 <para>
62056 For more information about installation and configuration of SpamAssassin or
62057 Rspamd refer to their respective websites at
62058 <emphasis role="bold"><ulink url="https://spamassassin.apache.org/">https://spamassassin.apache.org/</ulink></emphasis> and <emphasis role="bold"><ulink url="https://www.rspamd.com/">https://www.rspamd.com/</ulink></emphasis>
62059 </para>
62060 <para>
62061 SpamAssassin can be installed with CPAN by running:
62062 </para>
62063 <literallayout class="monospaced">
62064 perl -MCPAN -e 'install Mail::SpamAssassin'
62065 </literallayout>
62066 <para>
62067 SpamAssassin has its own set of configuration files. Please review its
62068 documentation to see how you can tweak it. The default installation should work
62069 nicely, however.
62070 </para>
62071 <para>
62072 <indexterm role="option">
62073 <primary><option>spamd_address</option></primary>
62074 </indexterm>
62075 By default, SpamAssassin listens on 127.0.0.1, TCP port 783 and if you
62076 intend to use an instance running on the local host you do not need to set
62077 <option>spamd_address</option>. If you intend to use another host or port for SpamAssassin,
62078 you must set the <option>spamd_address</option> option in the global part of the Exim
62079 configuration as follows (example):
62080 </para>
62081 <literallayout class="monospaced">
62082 spamd_address = 192.168.99.45 783
62083 </literallayout>
62084 <para>
62085 The SpamAssassin protocol relies on a TCP half-close from the client.
62086 If your SpamAssassin client side is running a Linux system with an
62087 iptables firewall, consider setting
62088 <option>net.netfilter.nf_conntrack_tcp_timeout_close_wait</option> to at least the
62089 timeout, Exim uses when waiting for a response from the SpamAssassin
62090 server (currently defaulting to 120s).  With a lower value the Linux
62091 connection tracking may consider your half-closed connection as dead too
62092 soon.
62093 </para>
62094 <para>
62095 To use Rspamd (which by default listens on all local addresses
62096 on TCP port 11333)
62097 you should add <option>variant=rspamd</option> after the address/port pair, for example:
62098 </para>
62099 <literallayout class="monospaced">
62100 spamd_address = 127.0.0.1 11333 variant=rspamd
62101 </literallayout>
62102 <para>
62103 As of version 2.60, <option>SpamAssassin</option> also supports communication over UNIX
62104 sockets. If you want to us these, supply <option>spamd_address</option> with an absolute
62105 filename instead of an address/port pair:
62106 </para>
62107 <literallayout class="monospaced">
62108 spamd_address = /var/run/spamd_socket
62109 </literallayout>
62110 <para>
62111 You can have multiple <option>spamd</option> servers to improve scalability. These can
62112 reside on other hardware reachable over the network. To specify multiple
62113 <option>spamd</option> servers, put multiple address/port pairs in the <option>spamd_address</option>
62114 option, separated with colons (the separator can be changed in the usual way <xref linkend="SECTlistsepchange"/>):
62115 </para>
62116 <literallayout class="monospaced">
62117 spamd_address = 192.168.2.10 783 : \
62118                 192.168.2.11 783 : \
62119                 192.168.2.12 783
62120 </literallayout>
62121 <para>
62122 Up to 32 <option>spamd</option> servers are supported.
62123 When a server fails to respond to the connection attempt, all other
62124 servers are tried until one succeeds. If no server responds, the <option>spam</option>
62125 condition defers.
62126 </para>
62127 <para>
62128 Unix and TCP socket specifications may be mixed in any order.
62129 Each element of the list is a list itself, space-separated by default
62130 and changeable in the usual way (<xref linkend="SECTlistsepchange"/>);
62131 take care to not double the separator.
62132 </para>
62133 <para>
62134 For TCP socket specifications a host name or IP (v4 or v6, but
62135 subject to list-separator quoting rules) address can be used,
62136 and the port can be one or a dash-separated pair.
62137 In the latter case, the range is tried in strict order.
62138 </para>
62139 <para>
62140 Elements after the first for Unix sockets, or second for TCP socket,
62141 are options.
62142 The supported options are:
62143 </para>
62144 <literallayout class="monospaced">
62145 pri=&lt;priority&gt;      Selection priority
62146 weight=&lt;value&gt;      Selection bias
62147 time=&lt;start&gt;-&lt;end&gt;  Use only between these times of day
62148 retry=&lt;timespec&gt;    Retry on connect fail
62149 tmo=&lt;timespec&gt;      Connection time limit
62150 variant=rspamd      Use Rspamd rather than SpamAssassin protocol
62151 </literallayout>
62152 <para>
62153 The <literal>pri</literal> option specifies a priority for the server within the list,
62154 higher values being tried first.
62155 The default priority is 1.
62156 </para>
62157 <para>
62158 The <literal>weight</literal> option specifies a selection bias.
62159 Within a priority set
62160 servers are queried in a random fashion, weighted by this value.
62161 The default value for selection bias is 1.
62162 </para>
62163 <para>
62164 Time specifications for the <literal>time</literal> option are &lt;hour&gt;.&lt;minute&gt;.&lt;second&gt;
62165 in the local time zone; each element being one or more digits.
62166 Either the seconds or both minutes and seconds, plus the leading <literal>.</literal>
62167 characters, may be omitted and will be taken as zero.
62168 </para>
62169 <para>
62170 Timeout specifications for the <literal>retry</literal> and <literal>tmo</literal> options
62171 are the usual Exim time interval standard, e.g. <literal>20s</literal> or <literal>1m</literal>.
62172 </para>
62173 <para>
62174 The <literal>tmo</literal> option specifies an overall timeout for communication.
62175 The default value is two minutes.
62176 </para>
62177 <para>
62178 The <literal>retry</literal> option specifies a time after which a single retry for
62179 a failed connect is made.
62180 The default is to not retry.
62181 </para>
62182 <para>
62183 The <option>spamd_address</option> variable is expanded before use if it starts with
62184 a dollar sign. In this case, the expansion may return a string that is
62185 used as the list so that multiple spamd servers can be the result of an
62186 expansion.
62187 </para>
62188 <para>
62189 <indexterm role="variable">
62190 <primary><varname>$callout_address</varname></primary>
62191 </indexterm>
62192 When a connection is made to the server the expansion variable <varname>$callout_address</varname>
62193 is set to record the actual address used.
62194 </para>
62195 </section>
62196 <section id="SECID206">
62197 <title>Calling SpamAssassin from an Exim ACL</title>
62198 <para>
62199 Here is a simple example of the use of the <option>spam</option> condition in a DATA ACL:
62200 </para>
62201 <literallayout class="monospaced">
62202 deny message = This message was classified as SPAM
62203      spam = joe
62204 </literallayout>
62205 <para>
62206 The right-hand side of the <option>spam</option> condition specifies a name. This is
62207 relevant if you have set up multiple SpamAssassin profiles. If you do not want
62208 to scan using a specific profile, but rather use the SpamAssassin system-wide
62209 default profile, you can scan for an unknown name, or simply use <quote>nobody</quote>.
62210 Rspamd does not use this setting. However, you must put something on the
62211 right-hand side.
62212 </para>
62213 <para>
62214 The name allows you to use per-domain or per-user antispam profiles in
62215 principle, but this is not straightforward in practice, because a message may
62216 have multiple recipients, not necessarily all in the same domain. Because the
62217 <option>spam</option> condition has to be called from a DATA-time ACL in order to be able to
62218 read the contents of the message, the variables <varname>$local_part</varname> and <varname>$domain</varname>
62219 are not set.
62220 Careful enforcement of single-recipient messages
62221 (e.g. by responding with defer in the recipient ACL for all recipients
62222 after the first),
62223 or the use of PRDR,
62224 <indexterm role="concept">
62225 <primary>PRDR</primary>
62226 <secondary>use for per-user SpamAssassin profiles</secondary>
62227 </indexterm>
62228 are needed to use this feature.
62229 </para>
62230 <para>
62231 The right-hand side of the <option>spam</option> condition is expanded before being used, so
62232 you can put lookups or conditions there. When the right-hand side evaluates to
62233 <quote>0</quote> or <quote>false</quote>, no scanning is done and the condition fails immediately.
62234 </para>
62235 <para>
62236 Scanning with SpamAssassin uses a lot of resources. If you scan every message,
62237 large ones may cause significant performance degradation. As most spam messages
62238 are quite small, it is recommended that you do not scan the big ones. For
62239 example:
62240 </para>
62241 <literallayout class="monospaced">
62242 deny message = This message was classified as SPAM
62243      condition = ${if &lt; {$message_size}{10K}}
62244      spam = nobody
62245 </literallayout>
62246 <para>
62247 The <option>spam</option> condition returns true if the threshold specified in the user&#x2019;s
62248 SpamAssassin profile has been matched or exceeded. If you want to use the
62249 <option>spam</option> condition for its side effects (see the variables below), you can make
62250 it always return <quote>true</quote> by appending <literal>:true</literal> to the username.
62251 </para>
62252 <para>
62253 <indexterm role="concept">
62254 <primary>spam scanning</primary>
62255 <secondary>returned variables</secondary>
62256 </indexterm>
62257 When the <option>spam</option> condition is run, it sets up a number of expansion
62258 variables.
62259 Except for <varname>$spam_report</varname>,
62260 these variables are saved with the received message so are
62261 available for use at delivery time.
62262 </para>
62263 <variablelist>
62264 <varlistentry>
62265 <term><varname>$spam_score</varname></term>
62266 <listitem>
62267 <para>
62268 The spam score of the message, for example, <quote>3.4</quote> or <quote>30.5</quote>. This is useful
62269 for inclusion in log or reject messages.
62270 </para>
62271 </listitem></varlistentry>
62272 <varlistentry>
62273 <term><varname>$spam_score_int</varname></term>
62274 <listitem>
62275 <para>
62276 The spam score of the message, multiplied by ten, as an integer value. For
62277 example <quote>34</quote> or <quote>305</quote>. It may appear to disagree with <varname>$spam_score</varname>
62278 because <varname>$spam_score</varname> is rounded and <varname>$spam_score_int</varname> is truncated.
62279 The integer value is useful for numeric comparisons in conditions.
62280 </para>
62281 </listitem></varlistentry>
62282 <varlistentry>
62283 <term><varname>$spam_bar</varname></term>
62284 <listitem>
62285 <para>
62286 A string consisting of a number of <quote>+</quote> or <quote>-</quote> characters, representing the
62287 integer part of the spam score value. A spam score of 4.4 would have a
62288 <varname>$spam_bar</varname> value of <quote>++++</quote>. This is useful for inclusion in warning
62289 headers, since MUAs can match on such strings. The maximum length of the
62290 spam bar is 50 characters.
62291 </para>
62292 </listitem></varlistentry>
62293 <varlistentry>
62294 <term><varname>$spam_report</varname></term>
62295 <listitem>
62296 <para>
62297 A multiline text table, containing the full SpamAssassin report for the
62298 message. Useful for inclusion in headers or reject messages.
62299 This variable is only usable in a DATA-time ACL.
62300 Beware that SpamAssassin may return non-ASCII characters, especially
62301 when running in country-specific locales, which are not legal
62302 unencoded in headers.
62303 </para>
62304 </listitem></varlistentry>
62305 <varlistentry>
62306 <term><varname>$spam_action</varname></term>
62307 <listitem>
62308 <para>
62309 For SpamAssassin either &#x2019;reject&#x2019; or &#x2019;no action&#x2019; depending on the
62310 spam score versus threshold.
62311 For Rspamd, the recommended action.
62312 </para>
62313 </listitem></varlistentry>
62314 </variablelist>
62315 <para>
62316 The <option>spam</option> condition caches its results unless expansion in
62317 spamd_address was used. If you call it again with the same user name, it
62318 does not scan again, but rather returns the same values as before.
62319 </para>
62320 <para>
62321 The <option>spam</option> condition returns DEFER if there is any error while running
62322 the message through SpamAssassin or if the expansion of spamd_address
62323 failed. If you want to treat DEFER as FAIL (to pass on to the next ACL
62324 statement block), append <literal>/defer_ok</literal> to the right-hand side of the
62325 spam condition, like this:
62326 </para>
62327 <literallayout class="monospaced">
62328 deny message = This message was classified as SPAM
62329      spam    = joe/defer_ok
62330 </literallayout>
62331 <para>
62332 This causes messages to be accepted even if there is a problem with <option>spamd</option>.
62333 </para>
62334 <para>
62335 Here is a longer, commented example of the use of the <option>spam</option>
62336 condition:
62337 </para>
62338 <literallayout class="monospaced">
62339 # put headers in all messages (no matter if spam or not)
62340 warn  spam = nobody:true
62341       add_header = X-Spam-Score: $spam_score ($spam_bar)
62342       add_header = X-Spam-Report: $spam_report
62343
62344 # add second subject line with *SPAM* marker when message
62345 # is over threshold
62346 warn  spam = nobody
62347       add_header = Subject: *SPAM* $h_Subject:
62348
62349 # reject spam at high scores (&gt; 12)
62350 deny  message = This message scored $spam_score spam points.
62351       spam = nobody:true
62352       condition = ${if &gt;{$spam_score_int}{120}{1}{0}}
62353 </literallayout>
62354 </section>
62355 <section id="SECTscanmimepart">
62356 <title>Scanning MIME parts</title>
62357 <para>
62358 <indexterm role="concept">
62359 <primary>content scanning</primary>
62360 <secondary>MIME parts</secondary>
62361 </indexterm>
62362 <indexterm role="concept">
62363 <primary>MIME content scanning</primary>
62364 </indexterm>
62365 <indexterm role="option">
62366 <primary><option>acl_smtp_mime</option></primary>
62367 </indexterm>
62368 <indexterm role="option">
62369 <primary><option>acl_not_smtp_mime</option></primary>
62370 </indexterm>
62371 The <option>acl_smtp_mime</option> global option specifies an ACL that is called once for
62372 each MIME part of an SMTP message, including multipart types, in the sequence
62373 of their position in the message. Similarly, the <option>acl_not_smtp_mime</option> option
62374 specifies an ACL that is used for the MIME parts of non-SMTP messages. These
62375 options may both refer to the same ACL if you want the same processing in both
62376 cases.
62377 </para>
62378 <para>
62379 These ACLs are called (possibly many times) just before the <option>acl_smtp_data</option>
62380 ACL in the case of an SMTP message, or just before the <option>acl_not_smtp</option> ACL in
62381 the case of a non-SMTP message. However, a MIME ACL is called only if the
62382 message contains a <emphasis>Content-Type:</emphasis> header line. When a call to a MIME
62383 ACL does not yield <quote>accept</quote>, ACL processing is aborted and the appropriate
62384 result code is sent to the client. In the case of an SMTP message, the
62385 <option>acl_smtp_data</option> ACL is not called when this happens.
62386 </para>
62387 <para>
62388 You cannot use the <option>malware</option> or <option>spam</option> conditions in a MIME ACL; these can
62389 only be used in the DATA or non-SMTP ACLs. However, you can use the <option>regex</option>
62390 condition to match against the raw MIME part. You can also use the
62391 <option>mime_regex</option> condition to match against the decoded MIME part (see section
62392 <xref linkend="SECTscanregex"/>).
62393 </para>
62394 <para>
62395 At the start of a MIME ACL, a number of variables are set from the header
62396 information for the relevant MIME part. These are described below. The contents
62397 of the MIME part are not by default decoded into a disk file except for MIME
62398 parts whose content-type is <quote>message/rfc822</quote>. If you want to decode a MIME
62399 part into a disk file, you can use the <option>decode</option> condition. The general
62400 syntax is:
62401 </para>
62402 <literallayout>
62403 <literal>decode = [/</literal>&lt;<emphasis>path</emphasis>&gt;<literal>/]</literal>&lt;<emphasis>filename</emphasis>&gt;
62404 </literallayout>
62405 <para>
62406 The right hand side is expanded before use. After expansion,
62407 the value can be:
62408 </para>
62409 <orderedlist numeration="arabic">
62410 <listitem>
62411 <para>
62412 <quote>0</quote> or <quote>false</quote>, in which case no decoding is done.
62413 </para>
62414 </listitem>
62415 <listitem>
62416 <para>
62417 The string <quote>default</quote>. In that case, the file is put in the temporary
62418 <quote>default</quote> directory &lt;<emphasis>spool_directory</emphasis>&gt;<filename>/scan/</filename>&lt;<emphasis>message_id</emphasis>&gt;<filename>/</filename> with
62419 a sequential filename consisting of the message id and a sequence number. The
62420 full path and name is available in <varname>$mime_decoded_filename</varname> after decoding.
62421 </para>
62422 </listitem>
62423 <listitem>
62424 <para>
62425 A full path name starting with a slash. If the full name is an existing
62426 directory, it is used as a replacement for the default directory. The filename
62427 is then sequentially assigned. If the path does not exist, it is used as
62428 the full path and filename.
62429 </para>
62430 </listitem>
62431 <listitem>
62432 <para>
62433 If the string does not start with a slash, it is used as the
62434 filename, and the default path is then used.
62435 </para>
62436 </listitem>
62437 </orderedlist>
62438 <para>
62439 The <option>decode</option> condition normally succeeds. It is only false for syntax
62440 errors or unusual circumstances such as memory shortages. You can easily decode
62441 a file with its original, proposed filename using
62442 </para>
62443 <literallayout class="monospaced">
62444 decode = $mime_filename
62445 </literallayout>
62446 <para>
62447 However, you should keep in mind that <varname>$mime_filename</varname> might contain
62448 anything. If you place files outside of the default path, they are not
62449 automatically unlinked.
62450 </para>
62451 <para>
62452 For RFC822 attachments (these are messages attached to messages, with a
62453 content-type of <quote>message/rfc822</quote>), the ACL is called again in the same manner
62454 as for the primary message, only that the <varname>$mime_is_rfc822</varname> expansion
62455 variable is set (see below). Attached messages are always decoded to disk
62456 before being checked, and the files are unlinked once the check is done.
62457 </para>
62458 <para>
62459 The MIME ACL supports the <option>regex</option> and <option>mime_regex</option> conditions. These can be
62460 used to match regular expressions against raw and decoded MIME parts,
62461 respectively. They are described in section <xref linkend="SECTscanregex"/>.
62462 </para>
62463 <para>
62464 <indexterm role="concept">
62465 <primary>MIME content scanning</primary>
62466 <secondary>returned variables</secondary>
62467 </indexterm>
62468 The following list describes all expansion variables that are
62469 available in the MIME ACL:
62470 </para>
62471 <variablelist>
62472 <varlistentry>
62473 <term><varname>$mime_boundary</varname></term>
62474 <listitem>
62475 <para>
62476 If the current part is a multipart (see <varname>$mime_is_multipart</varname>) below, it should
62477 have a boundary string, which is stored in this variable. If the current part
62478 has no boundary parameter in the <emphasis>Content-Type:</emphasis> header, this variable
62479 contains the empty string.
62480 </para>
62481 </listitem></varlistentry>
62482 <varlistentry>
62483 <term><varname>$mime_charset</varname></term>
62484 <listitem>
62485 <para>
62486 This variable contains the character set identifier, if one was found in the
62487 <emphasis>Content-Type:</emphasis> header. Examples for charset identifiers are:
62488 </para>
62489 <literallayout class="monospaced">
62490 us-ascii
62491 gb2312 (Chinese)
62492 iso-8859-1
62493 </literallayout>
62494 <para>
62495 Please note that this value is not normalized, so you should do matches
62496 case-insensitively.
62497 </para>
62498 </listitem></varlistentry>
62499 <varlistentry>
62500 <term><varname>$mime_content_description</varname></term>
62501 <listitem>
62502 <para>
62503 This variable contains the normalized content of the <emphasis>Content-Description:</emphasis>
62504 header. It can contain a human-readable description of the parts content. Some
62505 implementations repeat the filename for attachments here, but they are usually
62506 only used for display purposes.
62507 </para>
62508 </listitem></varlistentry>
62509 <varlistentry>
62510 <term><varname>$mime_content_disposition</varname></term>
62511 <listitem>
62512 <para>
62513 This variable contains the normalized content of the <emphasis>Content-Disposition:</emphasis>
62514 header. You can expect strings like <quote>attachment</quote> or <quote>inline</quote> here.
62515 </para>
62516 </listitem></varlistentry>
62517 <varlistentry>
62518 <term><varname>$mime_content_id</varname></term>
62519 <listitem>
62520 <para>
62521 This variable contains the normalized content of the <emphasis>Content-ID:</emphasis> header.
62522 This is a unique ID that can be used to reference a part from another part.
62523 </para>
62524 </listitem></varlistentry>
62525 <varlistentry>
62526 <term><varname>$mime_content_size</varname></term>
62527 <listitem>
62528 <para>
62529 This variable is set only after the <option>decode</option> modifier (see above) has been
62530 successfully run. It contains the size of the decoded part in kilobytes. The
62531 size is always rounded up to full kilobytes, so only a completely empty part
62532 has a <varname>$mime_content_size</varname> of zero.
62533 </para>
62534 </listitem></varlistentry>
62535 <varlistentry>
62536 <term><varname>$mime_content_transfer_encoding</varname></term>
62537 <listitem>
62538 <para>
62539 This variable contains the normalized content of the
62540 <emphasis>Content-transfer-encoding:</emphasis> header. This is a symbolic name for an encoding
62541 type. Typical values are <quote>base64</quote> and <quote>quoted-printable</quote>.
62542 </para>
62543 </listitem></varlistentry>
62544 <varlistentry>
62545 <term><varname>$mime_content_type</varname></term>
62546 <listitem>
62547 <para>
62548 If the MIME part has a <emphasis>Content-Type:</emphasis> header, this variable contains its
62549 value, lowercased, and without any options (like <quote>name</quote> or <quote>charset</quote>). Here
62550 are some examples of popular MIME types, as they may appear in this variable:
62551 </para>
62552 <literallayout class="monospaced">
62553 text/plain
62554 text/html
62555 application/octet-stream
62556 image/jpeg
62557 audio/midi
62558 </literallayout>
62559 <para>
62560 If the MIME part has no <emphasis>Content-Type:</emphasis> header, this variable contains the
62561 empty string.
62562 </para>
62563 </listitem></varlistentry>
62564 <varlistentry>
62565 <term><varname>$mime_decoded_filename</varname></term>
62566 <listitem>
62567 <para>
62568 This variable is set only after the <option>decode</option> modifier (see above) has been
62569 successfully run. It contains the full path and filename of the file
62570 containing the decoded data.
62571 </para>
62572 </listitem></varlistentry>
62573 </variablelist>
62574 <para>
62575 <indexterm role="concept">
62576 <primary>RFC 2047</primary>
62577 </indexterm>
62578 </para>
62579 <variablelist>
62580 <varlistentry>
62581 <term><varname>$mime_filename</varname></term>
62582 <listitem>
62583 <para>
62584 This is perhaps the most important of the MIME variables. It contains a
62585 proposed filename for an attachment, if one was found in either the
62586 <emphasis>Content-Type:</emphasis> or <emphasis>Content-Disposition:</emphasis> headers. The filename will be
62587 RFC2047
62588 or RFC2231
62589 decoded, but no additional sanity checks are done.
62590  If no filename was
62591 found, this variable contains the empty string.
62592 </para>
62593 </listitem></varlistentry>
62594 <varlistentry>
62595 <term><varname>$mime_is_coverletter</varname></term>
62596 <listitem>
62597 <para>
62598 This variable attempts to differentiate the <quote>cover letter</quote> of an e-mail from
62599 attached data. It can be used to clamp down on flashy or unnecessarily encoded
62600 content in the cover letter, while not restricting attachments at all.
62601 </para>
62602 <para>
62603 The variable contains 1 (true) for a MIME part believed to be part of the
62604 cover letter, and 0 (false) for an attachment. At present, the algorithm is as
62605 follows:
62606 </para>
62607 <orderedlist numeration="arabic">
62608 <listitem>
62609 <para>
62610 The outermost MIME part of a message is always a cover letter.
62611 </para>
62612 </listitem>
62613 <listitem>
62614 <para>
62615 If a multipart/alternative or multipart/related MIME part is a cover letter,
62616 so are all MIME subparts within that multipart.
62617 </para>
62618 </listitem>
62619 <listitem>
62620 <para>
62621 If any other multipart is a cover letter, the first subpart is a cover letter,
62622 and the rest are attachments.
62623 </para>
62624 </listitem>
62625 <listitem>
62626 <para>
62627 All parts contained within an attachment multipart are attachments.
62628 </para>
62629 </listitem>
62630 </orderedlist>
62631 <para>
62632 As an example, the following will ban <quote>HTML mail</quote> (including that sent with
62633 alternative plain text), while allowing HTML files to be attached. HTML
62634 coverletter mail attached to non-HTML coverletter mail will also be allowed:
62635 </para>
62636 <literallayout class="monospaced">
62637 deny message = HTML mail is not accepted here
62638 !condition = $mime_is_rfc822
62639 condition = $mime_is_coverletter
62640 condition = ${if eq{$mime_content_type}{text/html}{1}{0}}
62641 </literallayout>
62642 </listitem></varlistentry>
62643 <varlistentry>
62644 <term><varname>$mime_is_multipart</varname></term>
62645 <listitem>
62646 <para>
62647 This variable has the value 1 (true) when the current part has the main type
62648 <quote>multipart</quote>, for example, <quote>multipart/alternative</quote> or <quote>multipart/mixed</quote>.
62649 Since multipart entities only serve as containers for other parts, you may not
62650 want to carry out specific actions on them.
62651 </para>
62652 </listitem></varlistentry>
62653 <varlistentry>
62654 <term><varname>$mime_is_rfc822</varname></term>
62655 <listitem>
62656 <para>
62657 This variable has the value 1 (true) if the current part is not a part of the
62658 checked message itself, but part of an attached message. Attached message
62659 decoding is fully recursive.
62660 </para>
62661 </listitem></varlistentry>
62662 <varlistentry>
62663 <term><varname>$mime_part_count</varname></term>
62664 <listitem>
62665 <para>
62666 This variable is a counter that is raised for each processed MIME part. It
62667 starts at zero for the very first part (which is usually a multipart). The
62668 counter is per-message, so it is reset when processing RFC822 attachments (see
62669 <varname>$mime_is_rfc822</varname>). The counter stays set after <option>acl_smtp_mime</option> is
62670 complete, so you can use it in the DATA ACL to determine the number of MIME
62671 parts of a message. For non-MIME messages, this variable contains the value -1.
62672 </para>
62673 </listitem></varlistentry>
62674 </variablelist>
62675 </section>
62676 <section id="SECTscanregex">
62677 <title>Scanning with regular expressions</title>
62678 <para>
62679 <indexterm role="concept">
62680 <primary>content scanning</primary>
62681 <secondary>with regular expressions</secondary>
62682 </indexterm>
62683 <indexterm role="concept">
62684 <primary>regular expressions</primary>
62685 <secondary>content scanning with</secondary>
62686 </indexterm>
62687 You can specify your own custom regular expression matches on the full body of
62688 the message, or on individual MIME parts.
62689 </para>
62690 <para>
62691 The <option>regex</option> condition takes one or more regular expressions as arguments and
62692 matches them against the full message (when called in the DATA ACL) or a raw
62693 MIME part (when called in the MIME ACL). The <option>regex</option> condition matches
62694 linewise, with a maximum line length of 32K characters. That means you cannot
62695 have multiline matches with the <option>regex</option> condition.
62696 </para>
62697 <para>
62698 The <option>mime_regex</option> condition can be called only in the MIME ACL. It matches up
62699 to 32K of decoded content (the whole content at once, not linewise). If the
62700 part has not been decoded with the <option>decode</option> modifier earlier in the ACL, it
62701 is decoded automatically when <option>mime_regex</option> is executed (using default path
62702 and filename values). If the decoded data is larger than  32K, only the first
62703 32K characters are checked.
62704 </para>
62705 <para>
62706 The regular expressions are passed as a colon-separated list. To include a
62707 literal colon, you must double it. Since the whole right-hand side string is
62708 expanded before being used, you must also escape dollar signs and backslashes
62709 with more backslashes, or use the <literal>\N</literal> facility to disable expansion.
62710 Here is a simple example that contains two regular expressions:
62711 </para>
62712 <literallayout class="monospaced">
62713 deny message = contains blacklisted regex ($regex_match_string)
62714      regex = [Mm]ortgage : URGENT BUSINESS PROPOSAL
62715 </literallayout>
62716 <para>
62717 The conditions returns true if any one of the regular expressions matches. The
62718 <varname>$regex_match_string</varname> expansion variable is then set up and contains the
62719 matching regular expression.
62720 The expansion variables <varname>$regex1</varname> <varname>$regex2</varname> etc
62721 are set to any substrings captured by the regular expression.
62722 </para>
62723 <para>
62724 <emphasis role="bold">Warning</emphasis>: With large messages, these conditions can be fairly
62725 CPU-intensive.
62726 </para>
62727 <para>
62728 <indexterm role="concept" startref="IIDcosca" class="endofrange"/>
62729 </para>
62730 </section>
62731 </chapter>
62732
62733 <chapter id="CHAPlocalscan">
62734 <title>Adding a local scan function to Exim</title>
62735 <titleabbrev>Local scan function</titleabbrev>
62736 <para>
62737 <indexterm role="concept" id="IIDlosca" class="startofrange">
62738 <primary><function>local_scan()</function> function</primary>
62739 <secondary>description of</secondary>
62740 </indexterm>
62741 <indexterm role="concept">
62742 <primary>customizing</primary>
62743 <secondary>input scan using C function</secondary>
62744 </indexterm>
62745 <indexterm role="concept">
62746 <primary>policy control</primary>
62747 <secondary>by local scan function</secondary>
62748 </indexterm>
62749 In these days of email worms, viruses, and ever-increasing spam, some sites
62750 want to apply a lot of checking to messages before accepting them.
62751 </para>
62752 <para>
62753 The content scanning extension (chapter <xref linkend="CHAPexiscan"/>) has facilities for
62754 passing messages to external virus and spam scanning software. You can also do
62755 a certain amount in Exim itself through string expansions and the <option>condition</option>
62756 condition in the ACL that runs after the SMTP DATA command or the ACL for
62757 non-SMTP messages (see chapter <xref linkend="CHAPACL"/>), but this has its limitations.
62758 </para>
62759 <para>
62760 To allow for further customization to a site&#x2019;s own requirements, there is the
62761 possibility of linking Exim with a private message scanning function, written
62762 in C. If you want to run code that is written in something other than C, you
62763 can of course use a little C stub to call it.
62764 </para>
62765 <para>
62766 The local scan function is run once for every incoming message, at the point
62767 when Exim is just about to accept the message.
62768 It can therefore be used to control non-SMTP messages from local processes as
62769 well as messages arriving via SMTP.
62770 </para>
62771 <para>
62772 Exim applies a timeout to calls of the local scan function, and there is an
62773 option called <option>local_scan_timeout</option> for setting it. The default is 5 minutes.
62774 Zero means <quote>no timeout</quote>.
62775 Exim also sets up signal handlers for SIGSEGV, SIGILL, SIGFPE, and SIGBUS
62776 before calling the local scan function, so that the most common types of crash
62777 are caught. If the timeout is exceeded or one of those signals is caught, the
62778 incoming message is rejected with a temporary error if it is an SMTP message.
62779 For a non-SMTP message, the message is dropped and Exim ends with a non-zero
62780 code. The incident is logged on the main and reject logs.
62781 </para>
62782 <section id="SECID207">
62783 <title>Building Exim to use a local scan function</title>
62784 <para>
62785 <indexterm role="concept">
62786 <primary><function>local_scan()</function> function</primary>
62787 <secondary>building Exim to use</secondary>
62788 </indexterm>
62789 To make use of the local scan function feature, you must tell Exim where your
62790 function is before building Exim, by setting
62791 both HAVE_LOCAL_SCAN and
62792 LOCAL_SCAN_SOURCE in your
62793 <filename>Local/Makefile</filename>. A recommended place to put it is in the <filename>Local</filename>
62794 directory, so you might set
62795 </para>
62796 <literallayout class="monospaced">
62797 HAVE_LOCAL_SCAN=yes
62798 LOCAL_SCAN_SOURCE=Local/local_scan.c
62799 </literallayout>
62800 <para>
62801 for example. The function must be called <function>local_scan()</function>. It is called by
62802 Exim after it has received a message, when the success return code is about to
62803 be sent. This is after all the ACLs have been run. The return code from your
62804 function controls whether the message is actually accepted or not. There is a
62805 commented template function (that just accepts the message) in the file
62806 _src/local_scan.c_.
62807 </para>
62808 <para>
62809 If you want to make use of Exim&#x2019;s runtime configuration file to set options
62810 for your <function>local_scan()</function> function, you must also set
62811 </para>
62812 <literallayout class="monospaced">
62813 LOCAL_SCAN_HAS_OPTIONS=yes
62814 </literallayout>
62815 <para>
62816 in <filename>Local/Makefile</filename> (see section <xref linkend="SECTconoptloc"/> below).
62817 </para>
62818 </section>
62819 <section id="SECTapiforloc">
62820 <title>API for local_scan()</title>
62821 <para>
62822 <indexterm role="concept">
62823 <primary><function>local_scan()</function> function</primary>
62824 <secondary>API description</secondary>
62825 </indexterm>
62826 <indexterm role="concept">
62827 <primary><option>dlfunc</option></primary>
62828 <secondary>API description</secondary>
62829 </indexterm>
62830 You must include this line near the start of your code:
62831 </para>
62832 <literallayout class="monospaced">
62833 #include "local_scan.h"
62834 </literallayout>
62835 <para>
62836 This header file defines a number of variables and other values, and the
62837 prototype for the function itself. Exim is coded to use unsigned char values
62838 almost exclusively, and one of the things this header defines is a shorthand
62839 for <literal>unsigned char</literal> called <literal>uschar</literal>.
62840 It also contains the following macro definitions, to simplify casting character
62841 strings and pointers to character strings:
62842 </para>
62843 <literallayout class="monospaced">
62844 #define CS   (char *)
62845 #define CCS  (const char *)
62846 #define CSS  (char **)
62847 #define US   (unsigned char *)
62848 #define CUS  (const unsigned char *)
62849 #define USS  (unsigned char **)
62850 </literallayout>
62851 <para>
62852 The function prototype for <function>local_scan()</function> is:
62853 </para>
62854 <literallayout class="monospaced">
62855 extern int local_scan(int fd, uschar **return_text);
62856 </literallayout>
62857 <para>
62858 The arguments are as follows:
62859 </para>
62860 <itemizedlist>
62861 <listitem>
62862 <para>
62863 <option>fd</option> is a file descriptor for the file that contains the body of the message
62864 (the -D file). The file is open for reading and writing, but updating it is not
62865 recommended. <emphasis role="bold">Warning</emphasis>: You must <emphasis>not</emphasis> close this file descriptor.
62866 </para>
62867 <para>
62868 The descriptor is positioned at character 19 of the file, which is the first
62869 character of the body itself, because the first 19 characters are the message
62870 id followed by <literal>-D</literal> and a newline. If you rewind the file, you should use the
62871 macro SPOOL_DATA_START_OFFSET to reset to the start of the data, just in
62872 case this changes in some future version.
62873 </para>
62874 </listitem>
62875 <listitem>
62876 <para>
62877 <option>return_text</option> is an address which you can use to return a pointer to a text
62878 string at the end of the function. The value it points to on entry is NULL.
62879 </para>
62880 </listitem>
62881 </itemizedlist>
62882 <para>
62883 The function must return an <option>int</option> value which is one of the following macros:
62884 </para>
62885 <variablelist>
62886 <varlistentry>
62887 <term><literal>LOCAL_SCAN_ACCEPT</literal></term>
62888 <listitem>
62889 <para>
62890 <indexterm role="variable">
62891 <primary><varname>$local_scan_data</varname></primary>
62892 </indexterm>
62893 The message is accepted. If you pass back a string of text, it is saved with
62894 the message, and made available in the variable <varname>$local_scan_data</varname>. No
62895 newlines are permitted (if there are any, they are turned into spaces) and the
62896 maximum length of text is 1000 characters.
62897 </para>
62898 </listitem></varlistentry>
62899 <varlistentry>
62900 <term><literal>LOCAL_SCAN_ACCEPT_FREEZE</literal></term>
62901 <listitem>
62902 <para>
62903 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
62904 queued without immediate delivery, and is frozen.
62905 </para>
62906 </listitem></varlistentry>
62907 <varlistentry>
62908 <term><literal>LOCAL_SCAN_ACCEPT_QUEUE</literal></term>
62909 <listitem>
62910 <para>
62911 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
62912 queued without immediate delivery.
62913 </para>
62914 </listitem></varlistentry>
62915 <varlistentry>
62916 <term><literal>LOCAL_SCAN_REJECT</literal></term>
62917 <listitem>
62918 <para>
62919 The message is rejected; the returned text is used as an error message which is
62920 passed back to the sender and which is also logged. Newlines are permitted &ndash;
62921 they cause a multiline response for SMTP rejections, but are converted to
62922 <literal>\n</literal> in log lines. If no message is given, <quote>Administrative prohibition</quote> is
62923 used.
62924 </para>
62925 </listitem></varlistentry>
62926 <varlistentry>
62927 <term><literal>LOCAL_SCAN_TEMPREJECT</literal></term>
62928 <listitem>
62929 <para>
62930 The message is temporarily rejected; the returned text is used as an error
62931 message as for LOCAL_SCAN_REJECT. If no message is given, <quote>Temporary local
62932 problem</quote> is used.
62933 </para>
62934 </listitem></varlistentry>
62935 <varlistentry>
62936 <term><literal>LOCAL_SCAN_REJECT_NOLOGHDR</literal></term>
62937 <listitem>
62938 <para>
62939 This behaves as LOCAL_SCAN_REJECT, except that the header of the rejected
62940 message is not written to the reject log. It has the effect of unsetting the
62941 <option>rejected_header</option> log selector for just this rejection. If
62942 <option>rejected_header</option> is already unset (see the discussion of the
62943 <option>log_selection</option> option in section <xref linkend="SECTlogselector"/>), this code is the
62944 same as LOCAL_SCAN_REJECT.
62945 </para>
62946 </listitem></varlistentry>
62947 <varlistentry>
62948 <term><literal>LOCAL_SCAN_TEMPREJECT_NOLOGHDR</literal></term>
62949 <listitem>
62950 <para>
62951 This code is a variation of LOCAL_SCAN_TEMPREJECT in the same way that
62952 LOCAL_SCAN_REJECT_NOLOGHDR is a variation of LOCAL_SCAN_REJECT.
62953 </para>
62954 </listitem></varlistentry>
62955 </variablelist>
62956 <para>
62957 If the message is not being received by interactive SMTP, rejections are
62958 reported by writing to <option>stderr</option> or by sending an email, as configured by the
62959 <option>-oe</option> command line options.
62960 </para>
62961 </section>
62962 <section id="SECTconoptloc">
62963 <title>Configuration options for local_scan()</title>
62964 <para>
62965 <indexterm role="concept">
62966 <primary><function>local_scan()</function> function</primary>
62967 <secondary>configuration options</secondary>
62968 </indexterm>
62969 It is possible to have option settings in the main configuration file
62970 that set values in static variables in the <function>local_scan()</function> module. If you
62971 want to do this, you must have the line
62972 </para>
62973 <literallayout class="monospaced">
62974 LOCAL_SCAN_HAS_OPTIONS=yes
62975 </literallayout>
62976 <para>
62977 in your <filename>Local/Makefile</filename> when you build Exim. (This line is in
62978 <filename>OS/Makefile-Default</filename>, commented out). Then, in the <function>local_scan()</function> source
62979 file, you must define static variables to hold the option values, and a table
62980 to define them.
62981 </para>
62982 <para>
62983 The table must be a vector called <option>local_scan_options</option>, of type
62984 <literal>optionlist</literal>. Each entry is a triplet, consisting of a name, an option type,
62985 and a pointer to the variable that holds the value. The entries must appear in
62986 alphabetical order. Following <option>local_scan_options</option> you must also define a
62987 variable called <option>local_scan_options_count</option> that contains the number of
62988 entries in the table. Here is a short example, showing two kinds of option:
62989 </para>
62990 <literallayout class="monospaced">
62991 static int my_integer_option = 42;
62992 static uschar *my_string_option = US"a default string";
62993
62994 optionlist local_scan_options[] = {
62995   { "my_integer", opt_int,       &amp;my_integer_option },
62996   { "my_string",  opt_stringptr, &amp;my_string_option }
62997 };
62998
62999 int local_scan_options_count =
63000   sizeof(local_scan_options)/sizeof(optionlist);
63001 </literallayout>
63002 <para>
63003 The values of the variables can now be changed from Exim&#x2019;s runtime
63004 configuration file by including a local scan section as in this example:
63005 </para>
63006 <literallayout class="monospaced">
63007 begin local_scan
63008 my_integer = 99
63009 my_string = some string of text...
63010 </literallayout>
63011 <para>
63012 The available types of option data are as follows:
63013 </para>
63014 <variablelist>
63015 <varlistentry>
63016 <term><emphasis role="bold">opt_bool</emphasis></term>
63017 <listitem>
63018 <para>
63019 This specifies a boolean (true/false) option. The address should point to a
63020 variable of type <literal>BOOL</literal>, which will be set to TRUE or FALSE, which are macros
63021 that are defined as <quote>1</quote> and <quote>0</quote>, respectively. If you want to detect
63022 whether such a variable has been set at all, you can initialize it to
63023 TRUE_UNSET. (BOOL variables are integers underneath, so can hold more than two
63024 values.)
63025 </para>
63026 </listitem></varlistentry>
63027 <varlistentry>
63028 <term><emphasis role="bold">opt_fixed</emphasis></term>
63029 <listitem>
63030 <para>
63031 This specifies a fixed point number, such as is used for load averages.
63032 The address should point to a variable of type <literal>int</literal>. The value is stored
63033 multiplied by 1000, so, for example, 1.4142 is truncated and stored as 1414.
63034 </para>
63035 </listitem></varlistentry>
63036 <varlistentry>
63037 <term><emphasis role="bold">opt_int</emphasis></term>
63038 <listitem>
63039 <para>
63040 This specifies an integer; the address should point to a variable of type
63041 <literal>int</literal>. The value may be specified in any of the integer formats accepted by
63042 Exim.
63043 </para>
63044 </listitem></varlistentry>
63045 <varlistentry>
63046 <term><emphasis role="bold">opt_mkint</emphasis></term>
63047 <listitem>
63048 <para>
63049 This is the same as <option>opt_int</option>, except that when such a value is output in a
63050 <option>-bP</option> listing, if it is an exact number of kilobytes or megabytes, it is
63051 printed with the suffix K or M.
63052 </para>
63053 </listitem></varlistentry>
63054 <varlistentry>
63055 <term><emphasis role="bold">opt_octint</emphasis></term>
63056 <listitem>
63057 <para>
63058 This also specifies an integer, but the value is always interpreted as an
63059 octal integer, whether or not it starts with the digit zero, and it is
63060 always output in octal.
63061 </para>
63062 </listitem></varlistentry>
63063 <varlistentry>
63064 <term><emphasis role="bold">opt_stringptr</emphasis></term>
63065 <listitem>
63066 <para>
63067 This specifies a string value; the address must be a pointer to a
63068 variable that points to a string (for example, of type <literal>uschar *</literal>).
63069 </para>
63070 </listitem></varlistentry>
63071 <varlistentry>
63072 <term><emphasis role="bold">opt_time</emphasis></term>
63073 <listitem>
63074 <para>
63075 This specifies a time interval value. The address must point to a variable of
63076 type <literal>int</literal>. The value that is placed there is a number of seconds.
63077 </para>
63078 </listitem></varlistentry>
63079 </variablelist>
63080 <para>
63081 If the <option>-bP</option> command line option is followed by <literal>local_scan</literal>, Exim prints
63082 out the values of all the <function>local_scan()</function> options.
63083 </para>
63084 </section>
63085 <section id="SECID208">
63086 <title>Available Exim variables</title>
63087 <para>
63088 <indexterm role="concept">
63089 <primary><function>local_scan()</function> function</primary>
63090 <secondary>available Exim variables</secondary>
63091 </indexterm>
63092 The header <filename>local_scan.h</filename> gives you access to a number of C variables. These
63093 are the only ones that are guaranteed to be maintained from release to release.
63094 Note, however, that you can obtain the value of any Exim expansion variable,
63095 including <varname>$recipients</varname>, by calling <emphasis>expand_string()</emphasis>. The exported
63096 C variables are as follows:
63097 </para>
63098 <variablelist>
63099 <varlistentry>
63100 <term><emphasis role="bold">int&nbsp;body_linecount</emphasis></term>
63101 <listitem>
63102 <para>
63103 This variable contains the number of lines in the message&#x2019;s body.
63104 It is not valid if the <option>spool_files_wireformat</option> option is used.
63105 </para>
63106 </listitem></varlistentry>
63107 <varlistentry>
63108 <term><emphasis role="bold">int&nbsp;body_zerocount</emphasis></term>
63109 <listitem>
63110 <para>
63111 This variable contains the number of binary zero bytes in the message&#x2019;s body.
63112 It is not valid if the <option>spool_files_wireformat</option> option is used.
63113 </para>
63114 </listitem></varlistentry>
63115 <varlistentry>
63116 <term><emphasis role="bold">unsigned&nbsp;int&nbsp;debug_selector</emphasis></term>
63117 <listitem>
63118 <para>
63119 This variable is set to zero when no debugging is taking place. Otherwise, it
63120 is a bitmap of debugging selectors. Two bits are identified for use in
63121 <function>local_scan()</function>; they are defined as macros:
63122 </para>
63123 <itemizedlist>
63124 <listitem>
63125 <para>
63126 The <literal>D_v</literal> bit is set when <option>-v</option> was present on the command line. This is a
63127 testing option that is not privileged &ndash; any caller may set it. All the
63128 other selector bits can be set only by admin users.
63129 </para>
63130 </listitem>
63131 <listitem>
63132 <para>
63133 The <literal>D_local_scan</literal> bit is provided for use by <function>local_scan()</function>; it is set
63134 by the <literal>+local_scan</literal> debug selector. It is not included in the default set
63135 of debugging bits.
63136 </para>
63137 </listitem>
63138 </itemizedlist>
63139 <para>
63140 Thus, to write to the debugging output only when <literal>+local_scan</literal> has been
63141 selected, you should use code like this:
63142 </para>
63143 <literallayout class="monospaced">
63144 if ((debug_selector &amp; D_local_scan) != 0)
63145   debug_printf("xxx", ...);
63146 </literallayout>
63147 </listitem></varlistentry>
63148 <varlistentry>
63149 <term><emphasis role="bold">uschar&nbsp;*expand_string_message</emphasis></term>
63150 <listitem>
63151 <para>
63152 After a failing call to <emphasis>expand_string()</emphasis> (returned value NULL), the
63153 variable <option>expand_string_message</option> contains the error message, zero-terminated.
63154 </para>
63155 </listitem></varlistentry>
63156 <varlistentry>
63157 <term><emphasis role="bold">header_line&nbsp;*header_list</emphasis></term>
63158 <listitem>
63159 <para>
63160 A pointer to a chain of header lines. The <option>header_line</option> structure is
63161 discussed below.
63162 </para>
63163 </listitem></varlistentry>
63164 <varlistentry>
63165 <term><emphasis role="bold">header_line&nbsp;*header_last</emphasis></term>
63166 <listitem>
63167 <para>
63168 A pointer to the last of the header lines.
63169 </para>
63170 </listitem></varlistentry>
63171 <varlistentry>
63172 <term><emphasis role="bold">uschar&nbsp;*headers_charset</emphasis></term>
63173 <listitem>
63174 <para>
63175 The value of the <option>headers_charset</option> configuration option.
63176 </para>
63177 </listitem></varlistentry>
63178 <varlistentry>
63179 <term><emphasis role="bold">BOOL&nbsp;host_checking</emphasis></term>
63180 <listitem>
63181 <para>
63182 This variable is TRUE during a host checking session that is initiated by the
63183 <option>-bh</option> command line option.
63184 </para>
63185 </listitem></varlistentry>
63186 <varlistentry>
63187 <term><emphasis role="bold">uschar&nbsp;*interface_address</emphasis></term>
63188 <listitem>
63189 <para>
63190 The IP address of the interface that received the message, as a string. This
63191 is NULL for locally submitted messages.
63192 </para>
63193 </listitem></varlistentry>
63194 <varlistentry>
63195 <term><emphasis role="bold">int&nbsp;interface_port</emphasis></term>
63196 <listitem>
63197 <para>
63198 The port on which this message was received. When testing with the <option>-bh</option>
63199 command line option, the value of this variable is -1 unless a port has been
63200 specified via the <option>-oMi</option> option.
63201 </para>
63202 </listitem></varlistentry>
63203 <varlistentry>
63204 <term><emphasis role="bold">uschar&nbsp;*message_id</emphasis></term>
63205 <listitem>
63206 <para>
63207 This variable contains Exim&#x2019;s message id for the incoming message (the value of
63208 <varname>$message_exim_id</varname>) as a zero-terminated string.
63209 </para>
63210 </listitem></varlistentry>
63211 <varlistentry>
63212 <term><emphasis role="bold">uschar&nbsp;*received_protocol</emphasis></term>
63213 <listitem>
63214 <para>
63215 The name of the protocol by which the message was received.
63216 </para>
63217 </listitem></varlistentry>
63218 <varlistentry>
63219 <term><emphasis role="bold">int&nbsp;recipients_count</emphasis></term>
63220 <listitem>
63221 <para>
63222 The number of accepted recipients.
63223 </para>
63224 </listitem></varlistentry>
63225 <varlistentry>
63226 <term><emphasis role="bold">recipient_item&nbsp;*recipients_list</emphasis></term>
63227 <listitem>
63228 <para>
63229 <indexterm role="concept">
63230 <primary>recipient</primary>
63231 <secondary>adding in local scan</secondary>
63232 </indexterm>
63233 <indexterm role="concept">
63234 <primary>recipient</primary>
63235 <secondary>removing in local scan</secondary>
63236 </indexterm>
63237 The list of accepted recipients, held in a vector of length
63238 <option>recipients_count</option>. The <option>recipient_item</option> structure is discussed below. You
63239 can add additional recipients by calling <emphasis>receive_add_recipient()</emphasis> (see
63240 below). You can delete recipients by removing them from the vector and
63241 adjusting the value in <option>recipients_count</option>. In particular, by setting
63242 <option>recipients_count</option> to zero you remove all recipients. If you then return the
63243 value <literal>LOCAL_SCAN_ACCEPT</literal>, the message is accepted, but immediately
63244 blackholed. To replace the recipients, you can set <option>recipients_count</option> to zero
63245 and then call <emphasis>receive_add_recipient()</emphasis> as often as needed.
63246 </para>
63247 </listitem></varlistentry>
63248 <varlistentry>
63249 <term><emphasis role="bold">uschar&nbsp;*sender_address</emphasis></term>
63250 <listitem>
63251 <para>
63252 The envelope sender address. For bounce messages this is the empty string.
63253 </para>
63254 </listitem></varlistentry>
63255 <varlistentry>
63256 <term><emphasis role="bold">uschar&nbsp;*sender_host_address</emphasis></term>
63257 <listitem>
63258 <para>
63259 The IP address of the sending host, as a string. This is NULL for
63260 locally-submitted messages.
63261 </para>
63262 </listitem></varlistentry>
63263 <varlistentry>
63264 <term><emphasis role="bold">uschar&nbsp;*sender_host_authenticated</emphasis></term>
63265 <listitem>
63266 <para>
63267 The name of the authentication mechanism that was used, or NULL if the message
63268 was not received over an authenticated SMTP connection.
63269 </para>
63270 </listitem></varlistentry>
63271 <varlistentry>
63272 <term><emphasis role="bold">uschar&nbsp;*sender_host_name</emphasis></term>
63273 <listitem>
63274 <para>
63275 The name of the sending host, if known.
63276 </para>
63277 </listitem></varlistentry>
63278 <varlistentry>
63279 <term><emphasis role="bold">int&nbsp;sender_host_port</emphasis></term>
63280 <listitem>
63281 <para>
63282 The port on the sending host.
63283 </para>
63284 </listitem></varlistentry>
63285 <varlistentry>
63286 <term><emphasis role="bold">BOOL&nbsp;smtp_input</emphasis></term>
63287 <listitem>
63288 <para>
63289 This variable is TRUE for all SMTP input, including BSMTP.
63290 </para>
63291 </listitem></varlistentry>
63292 <varlistentry>
63293 <term><emphasis role="bold">BOOL&nbsp;smtp_batched_input</emphasis></term>
63294 <listitem>
63295 <para>
63296 This variable is TRUE for BSMTP input.
63297 </para>
63298 </listitem></varlistentry>
63299 <varlistentry>
63300 <term><emphasis role="bold">int&nbsp;store_pool</emphasis></term>
63301 <listitem>
63302 <para>
63303 The contents of this variable control which pool of memory is used for new
63304 requests. See section <xref linkend="SECTmemhanloc"/> for details.
63305 </para>
63306 </listitem></varlistentry>
63307 </variablelist>
63308 </section>
63309 <section id="SECID209">
63310 <title>Structure of header lines</title>
63311 <para>
63312 The <option>header_line</option> structure contains the members listed below.
63313 You can add additional header lines by calling the <emphasis>header_add()</emphasis> function
63314 (see below). You can cause header lines to be ignored (deleted) by setting
63315 their type to *.
63316 </para>
63317 <variablelist>
63318 <varlistentry>
63319 <term><emphasis role="bold">struct&nbsp;header_line&nbsp;*next</emphasis></term>
63320 <listitem>
63321 <para>
63322 A pointer to the next header line, or NULL for the last line.
63323 </para>
63324 </listitem></varlistentry>
63325 <varlistentry>
63326 <term><emphasis role="bold">int&nbsp;type</emphasis></term>
63327 <listitem>
63328 <para>
63329 A code identifying certain headers that Exim recognizes. The codes are printing
63330 characters, and are documented in chapter <xref linkend="CHAPspool"/> of this manual.
63331 Notice in particular that any header line whose type is * is not transmitted
63332 with the message. This flagging is used for header lines that have been
63333 rewritten, or are to be removed (for example, <emphasis>Envelope-sender:</emphasis> header
63334 lines.) Effectively, * means <quote>deleted</quote>.
63335 </para>
63336 </listitem></varlistentry>
63337 <varlistentry>
63338 <term><emphasis role="bold">int&nbsp;slen</emphasis></term>
63339 <listitem>
63340 <para>
63341 The number of characters in the header line, including the terminating and any
63342 internal newlines.
63343 </para>
63344 </listitem></varlistentry>
63345 <varlistentry>
63346 <term><emphasis role="bold">uschar&nbsp;*text</emphasis></term>
63347 <listitem>
63348 <para>
63349 A pointer to the text of the header. It always ends with a newline, followed by
63350 a zero byte. Internal newlines are preserved.
63351 </para>
63352 </listitem></varlistentry>
63353 </variablelist>
63354 </section>
63355 <section id="SECID210">
63356 <title>Structure of recipient items</title>
63357 <para>
63358 The <option>recipient_item</option> structure contains these members:
63359 </para>
63360 <variablelist>
63361 <varlistentry>
63362 <term><emphasis role="bold">uschar&nbsp;*address</emphasis></term>
63363 <listitem>
63364 <para>
63365 This is a pointer to the recipient address as it was received.
63366 </para>
63367 </listitem></varlistentry>
63368 <varlistentry>
63369 <term><emphasis role="bold">int&nbsp;pno</emphasis></term>
63370 <listitem>
63371 <para>
63372 This is used in later Exim processing when top level addresses are created by
63373 the <option>one_time</option> option. It is not relevant at the time <function>local_scan()</function> is run
63374 and must always contain -1 at this stage.
63375 </para>
63376 </listitem></varlistentry>
63377 <varlistentry>
63378 <term><emphasis role="bold">uschar&nbsp;*errors_to</emphasis></term>
63379 <listitem>
63380 <para>
63381 If this value is not NULL, bounce messages caused by failing to deliver to the
63382 recipient are sent to the address it contains. In other words, it overrides the
63383 envelope sender for this one recipient. (Compare the <option>errors_to</option> generic
63384 router option.) If a <function>local_scan()</function> function sets an <option>errors_to</option> field to
63385 an unqualified address, Exim qualifies it using the domain from
63386 <option>qualify_recipient</option>. When <function>local_scan()</function> is called, the <option>errors_to</option> field
63387 is NULL for all recipients.
63388 </para>
63389 </listitem></varlistentry>
63390 </variablelist>
63391 </section>
63392 <section id="SECID211">
63393 <title>Available Exim functions</title>
63394 <para>
63395 <indexterm role="concept">
63396 <primary><function>local_scan()</function> function</primary>
63397 <secondary>available Exim functions</secondary>
63398 </indexterm>
63399 The header <filename>local_scan.h</filename> gives you access to a number of Exim functions.
63400 These are the only ones that are guaranteed to be maintained from release to
63401 release:
63402 </para>
63403 <variablelist>
63404 <varlistentry>
63405 <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>
63406 <listitem>
63407 <para>
63408 This function creates a child process that runs the command specified by
63409 <option>argv</option>. The environment for the process is specified by <option>envp</option>, which can
63410 be NULL if no environment variables are to be passed. A new umask is supplied
63411 for the process in <option>newumask</option>.
63412 </para>
63413 <para>
63414 Pipes to the standard input and output of the new process are set up
63415 and returned to the caller via the <option>infdptr</option> and <option>outfdptr</option> arguments. The
63416 standard error is cloned to the standard output. If there are any file
63417 descriptors <quote>in the way</quote> in the new process, they are closed. If the final
63418 argument is TRUE, the new process is made into a process group leader.
63419 </para>
63420 <para>
63421 The function returns the pid of the new process, or -1 if things go wrong.
63422 </para>
63423 </listitem></varlistentry>
63424 <varlistentry>
63425 <term><emphasis role="bold">int&nbsp;child_close(pid_t&nbsp;pid,&nbsp;int&nbsp;timeout)</emphasis></term>
63426 <listitem>
63427 <para>
63428 This function waits for a child process to terminate, or for a timeout (in
63429 seconds) to expire. A timeout value of zero means wait as long as it takes. The
63430 return value is as follows:
63431 </para>
63432 <itemizedlist>
63433 <listitem>
63434 <para>
63435 &gt;= 0
63436 </para>
63437 <para>
63438 The process terminated by a normal exit and the value is the process
63439 ending status.
63440 </para>
63441 </listitem>
63442 <listitem>
63443 <para>
63444 &lt; 0 and &gt; &ndash;256
63445 </para>
63446 <para>
63447 The process was terminated by a signal and the value is the negation of the
63448 signal number.
63449 </para>
63450 </listitem>
63451 <listitem>
63452 <para>
63453 &ndash;256
63454 </para>
63455 <para>
63456 The process timed out.
63457 </para>
63458 </listitem>
63459 <listitem>
63460 <para>
63461 &ndash;257
63462 </para>
63463 <para>
63464 The was some other error in wait(); <option>errno</option> is still set.
63465 </para>
63466 </listitem>
63467 </itemizedlist>
63468 </listitem></varlistentry>
63469 <varlistentry>
63470 <term><emphasis role="bold">pid_t&nbsp;child_open_exim(int&nbsp;*fd)</emphasis></term>
63471 <listitem>
63472 <para>
63473 This function provide you with a means of submitting a new message to
63474 Exim. (Of course, you can also call <filename>/usr/sbin/sendmail</filename> yourself if you
63475 want, but this packages it all up for you.) The function creates a pipe,
63476 forks a subprocess that is running
63477 </para>
63478 <literallayout class="monospaced">
63479 exim -t -oem -oi -f &lt;&gt;
63480 </literallayout>
63481 <para>
63482 and returns to you (via the <literal>int *</literal> argument) a file descriptor for the pipe
63483 that is connected to the standard input. The yield of the function is the PID
63484 of the subprocess. You can then write a message to the file descriptor, with
63485 recipients in <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>, and/or <emphasis>Bcc:</emphasis> header lines.
63486 </para>
63487 <para>
63488 When you have finished, call <emphasis>child_close()</emphasis> to wait for the process to
63489 finish and to collect its ending status. A timeout value of zero is usually
63490 fine in this circumstance. Unless you have made a mistake with the recipient
63491 addresses, you should get a return code of zero.
63492 </para>
63493 </listitem></varlistentry>
63494 <varlistentry>
63495 <term><emphasis role="bold">pid_t&nbsp;child_open_exim2(int&nbsp;*fd,&nbsp;uschar&nbsp;*sender,&nbsp;uschar&nbsp;*sender_authentication)</emphasis></term>
63496 <listitem>
63497 <para>
63498 This function is a more sophisticated version of <emphasis>child_open()</emphasis>. The command
63499 that it runs is:
63500 </para>
63501 <literallayout>
63502 <literal>exim -t -oem -oi -f </literal><emphasis>sender</emphasis><literal> -oMas </literal><emphasis>sender_authentication</emphasis>
63503 </literallayout>
63504 <para>
63505 The third argument may be NULL, in which case the <option>-oMas</option> option is omitted.
63506 </para>
63507 </listitem></varlistentry>
63508 <varlistentry>
63509 <term><emphasis role="bold">void&nbsp;debug_printf(char&nbsp;*,&nbsp;...)</emphasis></term>
63510 <listitem>
63511 <para>
63512 This is Exim&#x2019;s debugging function, with arguments as for <emphasis>(printf()</emphasis>. The
63513 output is written to the standard error stream. If no debugging is selected,
63514 calls to <emphasis>debug_printf()</emphasis> have no effect. Normally, you should make calls
63515 conditional on the <literal>local_scan</literal> debug selector by coding like this:
63516 </para>
63517 <literallayout class="monospaced">
63518 if ((debug_selector &amp; D_local_scan) != 0)
63519   debug_printf("xxx", ...);
63520 </literallayout>
63521 </listitem></varlistentry>
63522 <varlistentry>
63523 <term><emphasis role="bold">uschar&nbsp;*expand_string(uschar&nbsp;*string)</emphasis></term>
63524 <listitem>
63525 <para>
63526 This is an interface to Exim&#x2019;s string expansion code. The return value is the
63527 expanded string, or NULL if there was an expansion failure.
63528 The C variable <option>expand_string_message</option> contains an error message after an
63529 expansion failure. If expansion does not change the string, the return value is
63530 the pointer to the input string. Otherwise, the return value points to a new
63531 block of memory that was obtained by a call to <emphasis>store_get()</emphasis>. See section
63532 <xref linkend="SECTmemhanloc"/> below for a discussion of memory handling.
63533 </para>
63534 </listitem></varlistentry>
63535 <varlistentry>
63536 <term><emphasis role="bold">void&nbsp;header_add(int&nbsp;type,&nbsp;char&nbsp;*format,&nbsp;...)</emphasis></term>
63537 <listitem>
63538 <para>
63539 This function allows you to an add additional header line at the end of the
63540 existing ones. The first argument is the type, and should normally be a space
63541 character. The second argument is a format string and any number of
63542 substitution arguments as for <function>sprintf()</function>. You may include internal newlines
63543 if you want, and you must ensure that the string ends with a newline.
63544 </para>
63545 </listitem></varlistentry>
63546 <varlistentry>
63547 <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>
63548 <listitem>
63549 <para>
63550 This function adds a new header line at a specified point in the header
63551 chain. The header itself is specified as for <emphasis>header_add()</emphasis>.
63552 </para>
63553 <para>
63554 If <option>name</option> is NULL, the new header is added at the end of the chain if
63555 <option>after</option> is true, or at the start if <option>after</option> is false. If <option>name</option> is not
63556 NULL, the header lines are searched for the first non-deleted header that
63557 matches the name. If one is found, the new header is added before it if
63558 <option>after</option> is false. If <option>after</option> is true, the new header is added after the
63559 found header and any adjacent subsequent ones with the same name (even if
63560 marked <quote>deleted</quote>). If no matching non-deleted header is found, the <option>topnot</option>
63561 option controls where the header is added. If it is true, addition is at the
63562 top; otherwise at the bottom. Thus, to add a header after all the <emphasis>Received:</emphasis>
63563 headers, or at the top if there are no <emphasis>Received:</emphasis> headers, you could use
63564 </para>
63565 <literallayout class="monospaced">
63566 header_add_at_position(TRUE, US"Received", TRUE,
63567   ' ', "X-xxx: ...");
63568 </literallayout>
63569 <para>
63570 Normally, there is always at least one non-deleted <emphasis>Received:</emphasis> header, but
63571 there may not be if <option>received_header_text</option> expands to an empty string.
63572 </para>
63573 </listitem></varlistentry>
63574 <varlistentry>
63575 <term><emphasis role="bold">void&nbsp;header_remove(int&nbsp;occurrence,&nbsp;uschar&nbsp;*name)</emphasis></term>
63576 <listitem>
63577 <para>
63578 This function removes header lines. If <option>occurrence</option> is zero or negative, all
63579 occurrences of the header are removed. If occurrence is greater than zero, that
63580 particular instance of the header is removed. If no header(s) can be found that
63581 match the specification, the function does nothing.
63582 </para>
63583 </listitem></varlistentry>
63584 <varlistentry>
63585 <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>
63586 <listitem>
63587 <para>
63588 This function tests whether the given header has the given name. It is not just
63589 a string comparison, because white space is permitted between the name and the
63590 colon. If the <option>notdel</option> argument is true, a false return is forced for all
63591 <quote>deleted</quote> headers; otherwise they are not treated specially. For example:
63592 </para>
63593 <literallayout class="monospaced">
63594 if (header_testname(h, US"X-Spam", 6, TRUE)) ...
63595 </literallayout>
63596 </listitem></varlistentry>
63597 <varlistentry>
63598 <term><emphasis role="bold">uschar&nbsp;*lss_b64encode(uschar&nbsp;*cleartext,&nbsp;int&nbsp;length)</emphasis></term>
63599 <listitem>
63600 <para>
63601 <indexterm role="concept">
63602 <primary>base64 encoding</primary>
63603 <secondary>functions for <function>local_scan()</function> use</secondary>
63604 </indexterm>
63605 This function base64-encodes a string, which is passed by address and length.
63606 The text may contain bytes of any value, including zero. The result is passed
63607 back in dynamic memory that is obtained by calling <emphasis>store_get()</emphasis>. It is
63608 zero-terminated.
63609 </para>
63610 </listitem></varlistentry>
63611 <varlistentry>
63612 <term><emphasis role="bold">int&nbsp;lss_b64decode(uschar&nbsp;*codetext,&nbsp;uschar&nbsp;**cleartext)</emphasis></term>
63613 <listitem>
63614 <para>
63615 This function decodes a base64-encoded string. Its arguments are a
63616 zero-terminated base64-encoded string and the address of a variable that is set
63617 to point to the result, which is in dynamic memory. The length of the decoded
63618 string is the yield of the function. If the input is invalid base64 data, the
63619 yield is -1. A zero byte is added to the end of the output string to make it
63620 easy to interpret as a C string (assuming it contains no zeros of its own). The
63621 added zero byte is not included in the returned count.
63622 </para>
63623 </listitem></varlistentry>
63624 <varlistentry>
63625 <term><emphasis role="bold">int&nbsp;lss_match_domain(uschar&nbsp;*domain,&nbsp;uschar&nbsp;*list)</emphasis></term>
63626 <listitem>
63627 <para>
63628 This function checks for a match in a domain list. Domains are always
63629 matched caselessly. The return value is one of the following:
63630 </para>
63631 <literallayout>
63632 <literal>OK     </literal> match succeeded
63633 <literal>FAIL   </literal> match failed
63634 <literal>DEFER  </literal> match deferred
63635 </literallayout>
63636 <para>
63637 DEFER is usually caused by some kind of lookup defer, such as the
63638 inability to contact a database.
63639 </para>
63640 </listitem></varlistentry>
63641 <varlistentry>
63642 <term><emphasis role="bold">int&nbsp;lss_match_local_part(uschar&nbsp;*localpart,&nbsp;uschar&nbsp;*list,&nbsp;BOOL&nbsp;caseless)</emphasis></term>
63643 <listitem>
63644 <para>
63645 This function checks for a match in a local part list. The third argument
63646 controls case-sensitivity. The return values are as for
63647 <emphasis>lss_match_domain()</emphasis>.
63648 </para>
63649 </listitem></varlistentry>
63650 <varlistentry>
63651 <term><emphasis role="bold">int&nbsp;lss_match_address(uschar&nbsp;*address,&nbsp;uschar&nbsp;*list,&nbsp;BOOL&nbsp;caseless)</emphasis></term>
63652 <listitem>
63653 <para>
63654 This function checks for a match in an address list. The third argument
63655 controls the case-sensitivity of the local part match. The domain is always
63656 matched caselessly. The return values are as for <emphasis>lss_match_domain()</emphasis>.
63657 </para>
63658 </listitem></varlistentry>
63659 <varlistentry>
63660 <term><emphasis role="bold">int&nbsp;lss_match_host(uschar&nbsp;*host_name,&nbsp;uschar&nbsp;*host_address,&nbsp;uschar&nbsp;*list)</emphasis></term>
63661 <listitem>
63662 <para>
63663 This function checks for a match in a host list. The most common usage is
63664 expected to be
63665 </para>
63666 <literallayout class="monospaced">
63667 lss_match_host(sender_host_name, sender_host_address, ...)
63668 </literallayout>
63669 <para>
63670 <indexterm role="variable">
63671 <primary><varname>$sender_host_address</varname></primary>
63672 </indexterm>
63673 An empty address field matches an empty item in the host list. If the host name
63674 is NULL, the name corresponding to <varname>$sender_host_address</varname> is automatically
63675 looked up if a host name is required to match an item in the list. The return
63676 values are as for <emphasis>lss_match_domain()</emphasis>, but in addition, <emphasis>lss_match_host()</emphasis>
63677 returns ERROR in the case when it had to look up a host name, but the lookup
63678 failed.
63679 </para>
63680 </listitem></varlistentry>
63681 <varlistentry>
63682 <term><emphasis role="bold">void&nbsp;log_write(unsigned&nbsp;int&nbsp;selector,&nbsp;int&nbsp;which,&nbsp;char&nbsp;*format,&nbsp;...)</emphasis></term>
63683 <listitem>
63684 <para>
63685 This function writes to Exim&#x2019;s log files. The first argument should be zero (it
63686 is concerned with <option>log_selector</option>). The second argument can be <literal>LOG_MAIN</literal> or
63687 <literal>LOG_REJECT</literal> or <literal>LOG_PANIC</literal> or the inclusive <quote>or</quote> of any combination of
63688 them. It specifies to which log or logs the message is written. The remaining
63689 arguments are a format and relevant insertion arguments. The string should not
63690 contain any newlines, not even at the end.
63691 </para>
63692 </listitem></varlistentry>
63693 <varlistentry>
63694 <term><emphasis role="bold">void&nbsp;receive_add_recipient(uschar&nbsp;*address,&nbsp;int&nbsp;pno)</emphasis></term>
63695 <listitem>
63696 <para>
63697 This function adds an additional recipient to the message. The first argument
63698 is the recipient address. If it is unqualified (has no domain), it is qualified
63699 with the <option>qualify_recipient</option> domain. The second argument must always be -1.
63700 </para>
63701 <para>
63702 This function does not allow you to specify a private <option>errors_to</option> address (as
63703 described with the structure of <option>recipient_item</option> above), because it pre-dates
63704 the addition of that field to the structure. However, it is easy to add such a
63705 value afterwards. For example:
63706 </para>
63707 <literallayout class="monospaced">
63708  receive_add_recipient(US"monitor@mydom.example", -1);
63709  recipients_list[recipients_count-1].errors_to =
63710    US"postmaster@mydom.example";
63711 </literallayout>
63712 </listitem></varlistentry>
63713 <varlistentry>
63714 <term><emphasis role="bold">BOOL&nbsp;receive_remove_recipient(uschar&nbsp;*recipient)</emphasis></term>
63715 <listitem>
63716 <para>
63717 This is a convenience function to remove a named recipient from the list of
63718 recipients. It returns true if a recipient was removed, and false if no
63719 matching recipient could be found. The argument must be a complete email
63720 address.
63721 </para>
63722 </listitem></varlistentry>
63723 </variablelist>
63724 <para>
63725 <indexterm role="concept">
63726 <primary>RFC 2047</primary>
63727 </indexterm>
63728 </para>
63729 <variablelist>
63730 <varlistentry>
63731 <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>
63732 <listitem>
63733 <para>
63734 This function decodes strings that are encoded according to RFC 2047. Typically
63735 these are the contents of header lines. First, each <quote>encoded word</quote> is decoded
63736 from the Q or B encoding into a byte-string. Then, if provided with the name of
63737 a charset encoding, and if the <function>iconv()</function> function is available, an attempt is
63738 made  to translate the result to the named character set. If this fails, the
63739 binary string is returned with an error message.
63740 </para>
63741 <para>
63742 The first argument is the string to be decoded. If <option>lencheck</option> is TRUE, the
63743 maximum MIME word length is enforced. The third argument is the target
63744 encoding, or NULL if no translation is wanted.
63745 </para>
63746 <para>
63747 <indexterm role="concept">
63748 <primary>binary zero</primary>
63749 <secondary>in RFC 2047 decoding</secondary>
63750 </indexterm>
63751 <indexterm role="concept">
63752 <primary>RFC 2047</primary>
63753 <secondary>binary zero in</secondary>
63754 </indexterm>
63755 If a binary zero is encountered in the decoded string, it is replaced by the
63756 contents of the <option>zeroval</option> argument. For use with Exim headers, the value must
63757 not be 0 because header lines are handled as zero-terminated strings.
63758 </para>
63759 <para>
63760 The function returns the result of processing the string, zero-terminated; if
63761 <option>lenptr</option> is not NULL, the length of the result is set in the variable to
63762 which it points. When <option>zeroval</option> is 0, <option>lenptr</option> should not be NULL.
63763 </para>
63764 <para>
63765 If an error is encountered, the function returns NULL and uses the <option>error</option>
63766 argument to return an error message. The variable pointed to by <option>error</option> is
63767 set to NULL if there is no error; it may be set non-NULL even when the function
63768 returns a non-NULL value if decoding was successful, but there was a problem
63769 with translation.
63770 </para>
63771 </listitem></varlistentry>
63772 <varlistentry>
63773 <term><emphasis role="bold">int&nbsp;smtp_fflush(void)</emphasis></term>
63774 <listitem>
63775 <para>
63776 This function is used in conjunction with <emphasis>smtp_printf()</emphasis>, as described
63777 below.
63778 </para>
63779 </listitem></varlistentry>
63780 <varlistentry revisionflag="changed">
63781 <term><emphasis role="bold">void&nbsp;smtp_printf(char&nbsp;*,BOOL,&nbsp;...)</emphasis></term>
63782 <listitem>
63783 <para revisionflag="changed">
63784 The arguments of this function are almost like <function>printf()</function>; it writes to the SMTP
63785 </para>
63786 <para>
63787 output stream. You should use this function only when there is an SMTP output
63788 stream, that is, when the incoming message is being received via interactive
63789 SMTP. This is the case when <option>smtp_input</option> is TRUE and <option>smtp_batched_input</option>
63790 is FALSE. If you want to test for an incoming message from another host (as
63791 opposed to a local process that used the <option>-bs</option> command line option), you can
63792 test the value of <option>sender_host_address</option>, which is non-NULL when a remote host
63793 is involved.
63794 </para>
63795 <para>
63796 If an SMTP TLS connection is established, <emphasis>smtp_printf()</emphasis> uses the TLS
63797 output function, so it can be used for all forms of SMTP connection.
63798 </para>
63799 <para revisionflag="changed">
63800 The second argument is used to request that the data be buffered
63801 (when TRUE) or flushed (along with any previously buffered, when FALSE).
63802 This is advisory only, but likely to save on system-calls and packets
63803 sent when a sequence of calls to the function are made.
63804 </para>
63805 <para revisionflag="changed">
63806 The argument was added in Exim version 4.90 - changing the API/ABI.
63807 Nobody noticed until 4.93 was imminent, at which point the
63808 ABI version number was incremented.
63809 </para>
63810 <para>
63811 Strings that are written by <emphasis>smtp_printf()</emphasis> from within <function>local_scan()</function>
63812 must start with an appropriate response code: 550 if you are going to return
63813 LOCAL_SCAN_REJECT, 451 if you are going to return
63814 LOCAL_SCAN_TEMPREJECT, and 250 otherwise. Because you are writing the
63815 initial lines of a multi-line response, the code must be followed by a hyphen
63816 to indicate that the line is not the final response line. You must also ensure
63817 that the lines you write terminate with CRLF. For example:
63818 </para>
63819 <literallayout class="monospaced">
63820 smtp_printf("550-this is some extra info\r\n");
63821 return LOCAL_SCAN_REJECT;
63822 </literallayout>
63823 <para>
63824 Note that you can also create multi-line responses by including newlines in
63825 the data returned via the <option>return_text</option> argument. The added value of using
63826 <emphasis>smtp_printf()</emphasis> is that, for instance, you could introduce delays between
63827 multiple output lines.
63828 </para>
63829 <para>
63830 The <emphasis>smtp_printf()</emphasis> function does not return any error indication, because it
63831 does not
63832 </para>
63833 <para revisionflag="changed">
63834 guarantee a flush of
63835 </para>
63836 <para>
63837 pending output, and therefore does not test
63838 the state of the stream. (In the main code of Exim, flushing and error
63839 detection is done when Exim is ready for the next SMTP input command.) If
63840 you want to flush the output and check for an error (for example, the
63841 dropping of a TCP/IP connection), you can call <emphasis>smtp_fflush()</emphasis>, which has no
63842 arguments. It flushes the output stream, and returns a non-zero value if there
63843 is an error.
63844 </para>
63845 </listitem></varlistentry>
63846 <varlistentry>
63847 <term><emphasis role="bold">void&nbsp;*store_get(int)</emphasis></term>
63848 <listitem>
63849 <para>
63850 This function accesses Exim&#x2019;s internal store (memory) manager. It gets a new
63851 chunk of memory whose size is given by the argument. Exim bombs out if it ever
63852 runs out of memory. See the next section for a discussion of memory handling.
63853 </para>
63854 </listitem></varlistentry>
63855 <varlistentry>
63856 <term><emphasis role="bold">void&nbsp;*store_get_perm(int)</emphasis></term>
63857 <listitem>
63858 <para>
63859 This function is like <emphasis>store_get()</emphasis>, but it always gets memory from the
63860 permanent pool. See the next section for a discussion of memory handling.
63861 </para>
63862 </listitem></varlistentry>
63863 <varlistentry>
63864 <term><emphasis role="bold">uschar&nbsp;*string_copy(uschar&nbsp;*string)</emphasis></term>
63865 <listitem>
63866 <para>
63867 See below.
63868 </para>
63869 </listitem></varlistentry>
63870 <varlistentry>
63871 <term><emphasis role="bold">uschar&nbsp;*string_copyn(uschar&nbsp;*string,&nbsp;int&nbsp;length)</emphasis></term>
63872 <listitem>
63873 <para>
63874 See below.
63875 </para>
63876 </listitem></varlistentry>
63877 <varlistentry>
63878 <term><emphasis role="bold">uschar&nbsp;*string_sprintf(char&nbsp;*format,&nbsp;...)</emphasis></term>
63879 <listitem>
63880 <para>
63881 These three functions create strings using Exim&#x2019;s dynamic memory facilities.
63882 The first makes a copy of an entire string. The second copies up to a maximum
63883 number of characters, indicated by the second argument. The third uses a format
63884 and insertion arguments to create a new string. In each case, the result is a
63885 pointer to a new string in the current memory pool. See the next section for
63886 more discussion.
63887 </para>
63888 </listitem></varlistentry>
63889 </variablelist>
63890 </section>
63891 <section id="SECTmemhanloc">
63892 <title>More about Exim&#x2019;s memory handling</title>
63893 <para>
63894 <indexterm role="concept">
63895 <primary><function>local_scan()</function> function</primary>
63896 <secondary>memory handling</secondary>
63897 </indexterm>
63898 No function is provided for freeing memory, because that is never needed.
63899 The dynamic memory that Exim uses when receiving a message is automatically
63900 recycled if another message is received by the same process (this applies only
63901 to incoming SMTP connections &ndash; other input methods can supply only one
63902 message at a time). After receiving the last message, a reception process
63903 terminates.
63904 </para>
63905 <para>
63906 Because it is recycled, the normal dynamic memory cannot be used for holding
63907 data that must be preserved over a number of incoming messages on the same SMTP
63908 connection. However, Exim in fact uses two pools of dynamic memory; the second
63909 one is not recycled, and can be used for this purpose.
63910 </para>
63911 <para>
63912 If you want to allocate memory that remains available for subsequent messages
63913 in the same SMTP connection, you should set
63914 </para>
63915 <literallayout class="monospaced">
63916 store_pool = POOL_PERM
63917 </literallayout>
63918 <para>
63919 before calling the function that does the allocation. There is no need to
63920 restore the value if you do not need to; however, if you do want to revert to
63921 the normal pool, you can either restore the previous value of <option>store_pool</option> or
63922 set it explicitly to POOL_MAIN.
63923 </para>
63924 <para>
63925 The pool setting applies to all functions that get dynamic memory, including
63926 <emphasis>expand_string()</emphasis>, <emphasis>store_get()</emphasis>, and the <emphasis>string_xxx()</emphasis> functions.
63927 There is also a convenience function called <emphasis>store_get_perm()</emphasis> that gets a
63928 block of memory from the permanent pool while preserving the value of
63929 <option>store_pool</option>.
63930 <indexterm role="concept" startref="IIDlosca" class="endofrange"/>
63931 </para>
63932 </section>
63933 </chapter>
63934
63935 <chapter id="CHAPsystemfilter">
63936 <title>System-wide message filtering</title>
63937 <para>
63938 <indexterm role="concept" id="IIDsysfil1" class="startofrange">
63939 <primary>filter</primary>
63940 <secondary>system filter</secondary>
63941 </indexterm>
63942 <indexterm role="concept" id="IIDsysfil2" class="startofrange">
63943 <primary>filtering all mail</primary>
63944 </indexterm>
63945 <indexterm role="concept" id="IIDsysfil3" class="startofrange">
63946 <primary>system filter</primary>
63947 </indexterm>
63948 The previous chapters (on ACLs and the local scan function) describe checks
63949 that can be applied to messages before they are accepted by a host. There is
63950 also a mechanism for checking messages once they have been received, but before
63951 they are delivered. This is called the <emphasis>system filter</emphasis>.
63952 </para>
63953 <para>
63954 The system filter operates in a similar manner to users&#x2019; filter files, but it
63955 is run just once per message (however many recipients the message has).
63956 It should not normally be used as a substitute for routing, because <option>deliver</option>
63957 commands in a system router provide new envelope recipient addresses.
63958 The system filter must be an Exim filter. It cannot be a Sieve filter.
63959 </para>
63960 <para>
63961 The system filter is run at the start of a delivery attempt, before any routing
63962 is done. If a message fails to be completely delivered at the first attempt,
63963 the system filter is run again at the start of every retry.
63964 If you want your filter to do something only once per message, you can make use
63965 of the <option>first_delivery</option> condition in an <option>if</option> command in the filter to
63966 prevent it happening on retries.
63967 </para>
63968 <para>
63969 <indexterm role="variable">
63970 <primary><varname>$domain</varname></primary>
63971 </indexterm>
63972 <indexterm role="variable">
63973 <primary><varname>$local_part</varname></primary>
63974 </indexterm>
63975 <emphasis role="bold">Warning</emphasis>: Because the system filter runs just once, variables that are
63976 specific to individual recipient addresses, such as <varname>$local_part</varname> and
63977 <varname>$domain</varname>, are not set, and the <quote>personal</quote> condition is not meaningful. If
63978 you want to run a centrally-specified filter for each recipient address
63979 independently, you can do so by setting up a suitable <command>redirect</command> router, as
63980 described in section <xref linkend="SECTperaddfil"/> below.
63981 </para>
63982 <section id="SECID212">
63983 <title>Specifying a system filter</title>
63984 <para>
63985 <indexterm role="concept">
63986 <primary>uid (user id)</primary>
63987 <secondary>system filter</secondary>
63988 </indexterm>
63989 <indexterm role="concept">
63990 <primary>gid (group id)</primary>
63991 <secondary>system filter</secondary>
63992 </indexterm>
63993 The name of the file that contains the system filter must be specified by
63994 setting <option>system_filter</option>. If you want the filter to run under a uid and gid
63995 other than root, you must also set <option>system_filter_user</option> and
63996 <option>system_filter_group</option> as appropriate. For example:
63997 </para>
63998 <literallayout class="monospaced">
63999 system_filter = /etc/mail/exim.filter
64000 system_filter_user = exim
64001 </literallayout>
64002 <para>
64003 If a system filter generates any deliveries directly to files or pipes (via the
64004 <option>save</option> or <option>pipe</option> commands), transports to handle these deliveries must be
64005 specified by setting <option>system_filter_file_transport</option> and
64006 <option>system_filter_pipe_transport</option>, respectively. Similarly,
64007 <option>system_filter_reply_transport</option> must be set to handle any messages generated
64008 by the <option>reply</option> command.
64009 </para>
64010 </section>
64011 <section id="SECID213">
64012 <title>Testing a system filter</title>
64013 <para>
64014 You can run simple tests of a system filter in the same way as for a user
64015 filter, but you should use <option>-bF</option> rather than <option>-bf</option>, so that features that
64016 are permitted only in system filters are recognized.
64017 </para>
64018 <para>
64019 If you want to test the combined effect of a system filter and a user filter,
64020 you can use both <option>-bF</option> and <option>-bf</option> on the same command line.
64021 </para>
64022 </section>
64023 <section id="SECID214">
64024 <title>Contents of a system filter</title>
64025 <para>
64026 The language used to specify system filters is the same as for users&#x2019; filter
64027 files. It is described in the separate end-user document <emphasis>Exim&#x2019;s interface to
64028 mail filtering</emphasis>. However, there are some additional features that are
64029 available only in system filters; these are described in subsequent sections.
64030 If they are encountered in a user&#x2019;s filter file or when testing with <option>-bf</option>,
64031 they cause errors.
64032 </para>
64033 <para>
64034 <indexterm role="concept">
64035 <primary>frozen messages</primary>
64036 <secondary>manual thaw; testing in filter</secondary>
64037 </indexterm>
64038 There are two special conditions which, though available in users&#x2019; filter
64039 files, are designed for use in system filters. The condition <option>first_delivery</option>
64040 is true only for the first attempt at delivering a message, and
64041 <option>manually_thawed</option> is true only if the message has been frozen, and
64042 subsequently thawed by an admin user. An explicit forced delivery counts as a
64043 manual thaw, but thawing as a result of the <option>auto_thaw</option> setting does not.
64044 </para>
64045 <para>
64046 <emphasis role="bold">Warning</emphasis>: If a system filter uses the <option>first_delivery</option> condition to
64047 specify an <quote>unseen</quote> (non-significant) delivery, and that delivery does not
64048 succeed, it will not be tried again.
64049 If you want Exim to retry an unseen delivery until it succeeds, you should
64050 arrange to set it up every time the filter runs.
64051 </para>
64052 <para>
64053 When a system filter finishes running, the values of the variables <varname>$n0</varname> &ndash;
64054 <varname>$n9</varname> are copied into <varname>$sn0</varname> &ndash; <varname>$sn9</varname> and are thereby made available to
64055 users&#x2019; filter files. Thus a system filter can, for example, set up <quote>scores</quote>
64056 to which users&#x2019; filter files can refer.
64057 </para>
64058 </section>
64059 <section id="SECID215">
64060 <title>Additional variable for system filters</title>
64061 <para>
64062 <indexterm role="variable">
64063 <primary><varname>$recipients</varname></primary>
64064 </indexterm>
64065 The expansion variable <varname>$recipients</varname>, containing a list of all the recipients
64066 of the message (separated by commas and white space), is available in system
64067 filters. It is not available in users&#x2019; filters for privacy reasons.
64068 </para>
64069 </section>
64070 <section id="SECID216">
64071 <title>Defer, freeze, and fail commands for system filters</title>
64072 <para>
64073 <indexterm role="concept">
64074 <primary>freezing messages</primary>
64075 </indexterm>
64076 <indexterm role="concept">
64077 <primary>message</primary>
64078 <secondary>freezing</secondary>
64079 </indexterm>
64080 <indexterm role="concept">
64081 <primary>message</primary>
64082 <secondary>forced failure</secondary>
64083 </indexterm>
64084 <indexterm role="concept">
64085 <primary><option>fail</option></primary>
64086 <secondary>in system filter</secondary>
64087 </indexterm>
64088 <indexterm role="concept">
64089 <primary><option>freeze</option> in system filter</primary>
64090 </indexterm>
64091 <indexterm role="concept">
64092 <primary><option>defer</option> in system filter</primary>
64093 </indexterm>
64094 There are three extra commands (<option>defer</option>, <option>freeze</option> and <option>fail</option>) which are
64095 always available in system filters, but are not normally enabled in users&#x2019;
64096 filters. (See the <option>allow_defer</option>, <option>allow_freeze</option> and <option>allow_fail</option> options
64097 for the <command>redirect</command> router.) These commands can optionally be followed by the
64098 word <option>text</option> and a string containing an error message, for example:
64099 </para>
64100 <literallayout class="monospaced">
64101 fail text "this message looks like spam to me"
64102 </literallayout>
64103 <para>
64104 The keyword <option>text</option> is optional if the next character is a double quote.
64105 </para>
64106 <para>
64107 The <option>defer</option> command defers delivery of the original recipients of the
64108 message. The <option>fail</option> command causes all the original recipients to be failed,
64109 and a bounce message to be created. The <option>freeze</option> command suspends all
64110 delivery attempts for the original recipients. In all cases, any new deliveries
64111 that are specified by the filter are attempted as normal after the filter has
64112 run.
64113 </para>
64114 <para>
64115 The <option>freeze</option> command is ignored if the message has been manually unfrozen and
64116 not manually frozen since. This means that automatic freezing by a system
64117 filter can be used as a way of checking out suspicious messages. If a message
64118 is found to be all right, manually unfreezing it allows it to be delivered.
64119 </para>
64120 <para>
64121 <indexterm role="concept">
64122 <primary>log</primary>
64123 <secondary><option>fail</option> command log line</secondary>
64124 </indexterm>
64125 <indexterm role="concept">
64126 <primary><option>fail</option></primary>
64127 <secondary>log line; reducing</secondary>
64128 </indexterm>
64129 The text given with a fail command is used as part of the bounce message as
64130 well as being written to the log. If the message is quite long, this can fill
64131 up a lot of log space when such failures are common. To reduce the size of the
64132 log message, Exim interprets the text in a special way if it starts with the
64133 two characters <literal>&lt;&lt;</literal> and contains <literal>&gt;&gt;</literal> later. The text between these two
64134 strings is written to the log, and the rest of the text is used in the bounce
64135 message. For example:
64136 </para>
64137 <literallayout class="monospaced">
64138 fail "&lt;&lt;filter test 1&gt;&gt;Your message is rejected \
64139      because it contains attachments that we are \
64140      not prepared to receive."
64141 </literallayout>
64142 <para>
64143 <indexterm role="concept">
64144 <primary>loop</primary>
64145 <secondary>caused by <option>fail</option></secondary>
64146 </indexterm>
64147 Take great care with the <option>fail</option> command when basing the decision to fail on
64148 the contents of the message, because the bounce message will of course include
64149 the contents of the original message and will therefore trigger the <option>fail</option>
64150 command again (causing a mail loop) unless steps are taken to prevent this.
64151 Testing the <option>error_message</option> condition is one way to prevent this. You could
64152 use, for example
64153 </para>
64154 <literallayout class="monospaced">
64155 if $message_body contains "this is spam" and not error_message
64156 then fail text "spam is not wanted here" endif
64157 </literallayout>
64158 <para>
64159 though of course that might let through unwanted bounce messages. The
64160 alternative is clever checking of the body and/or headers to detect bounces
64161 generated by the filter.
64162 </para>
64163 <para>
64164 The interpretation of a system filter file ceases after a
64165 <option>defer</option>,
64166 <option>freeze</option>, or <option>fail</option> command is obeyed. However, any deliveries that were
64167 set up earlier in the filter file are honoured, so you can use a sequence such
64168 as
64169 </para>
64170 <literallayout class="monospaced">
64171 mail ...
64172 freeze
64173 </literallayout>
64174 <para>
64175 to send a specified message when the system filter is freezing (or deferring or
64176 failing) a message. The normal deliveries for the message do not, of course,
64177 take place.
64178 </para>
64179 </section>
64180 <section id="SECTaddremheasys">
64181 <title>Adding and removing headers in a system filter</title>
64182 <para>
64183 <indexterm role="concept">
64184 <primary>header lines</primary>
64185 <secondary>adding; in system filter</secondary>
64186 </indexterm>
64187 <indexterm role="concept">
64188 <primary>header lines</primary>
64189 <secondary>removing; in system filter</secondary>
64190 </indexterm>
64191 <indexterm role="concept">
64192 <primary>filter</primary>
64193 <secondary>header lines; adding/removing</secondary>
64194 </indexterm>
64195 Two filter commands that are available only in system filters are:
64196 </para>
64197 <literallayout class="monospaced">
64198 headers add &lt;string&gt;
64199 headers remove &lt;string&gt;
64200 </literallayout>
64201 <para>
64202 The argument for the <option>headers add</option> is a string that is expanded and then
64203 added to the end of the message&#x2019;s headers. It is the responsibility of the
64204 filter maintainer to make sure it conforms to RFC 2822 syntax. Leading white
64205 space is ignored, and if the string is otherwise empty, or if the expansion is
64206 forced to fail, the command has no effect.
64207 </para>
64208 <para>
64209 You can use <quote>\n</quote> within the string, followed by white space, to specify
64210 continued header lines. More than one header may be added in one command by
64211 including <quote>\n</quote> within the string without any following white space. For
64212 example:
64213 </para>
64214 <literallayout class="monospaced">
64215 headers add "X-header-1: ....\n  \
64216              continuation of X-header-1 ...\n\
64217              X-header-2: ...."
64218 </literallayout>
64219 <para>
64220 Note that the header line continuation white space after the first newline must
64221 be placed before the backslash that continues the input string, because white
64222 space after input continuations is ignored.
64223 </para>
64224 <para>
64225 The argument for <option>headers remove</option> is a colon-separated list of header names.
64226 This command applies only to those headers that are stored with the message;
64227 those that are added at delivery time (such as <emphasis>Envelope-To:</emphasis> and
64228 <emphasis>Return-Path:</emphasis>) cannot be removed by this means. If there is more than one
64229 header with the same name, they are all removed.
64230 </para>
64231 <para>
64232 The <option>headers</option> command in a system filter makes an immediate change to the set
64233 of header lines that was received with the message (with possible additions
64234 from ACL processing). Subsequent commands in the system filter operate on the
64235 modified set, which also forms the basis for subsequent message delivery.
64236 Unless further modified during routing or transporting, this set of headers is
64237 used for all recipients of the message.
64238 </para>
64239 <para>
64240 During routing and transporting, the variables that refer to the contents of
64241 header lines refer only to those lines that are in this set. Thus, header lines
64242 that are added by a system filter are visible to users&#x2019; filter files and to all
64243 routers and transports. This contrasts with the manipulation of header lines by
64244 routers and transports, which is not immediate, but which instead is saved up
64245 until the message is actually being written (see section
64246 <xref linkend="SECTheadersaddrem"/>).
64247 </para>
64248 <para>
64249 If the message is not delivered at the first attempt, header lines that were
64250 added by the system filter are stored with the message, and so are still
64251 present at the next delivery attempt. Header lines that were removed are still
64252 present, but marked <quote>deleted</quote> so that they are not transported with the
64253 message. For this reason, it is usual to make the <option>headers</option> command
64254 conditional on <option>first_delivery</option> so that the set of header lines is not
64255 modified more than once.
64256 </para>
64257 <para>
64258 Because header modification in a system filter acts immediately, you have to
64259 use an indirect approach if you want to modify the contents of a header line.
64260 For example:
64261 </para>
64262 <literallayout class="monospaced">
64263 headers add "Old-Subject: $h_subject:"
64264 headers remove "Subject"
64265 headers add "Subject: new subject (was: $h_old-subject:)"
64266 headers remove "Old-Subject"
64267 </literallayout>
64268 </section>
64269 <section id="SECID217">
64270 <title>Setting an errors address in a system filter</title>
64271 <para>
64272 <indexterm role="concept">
64273 <primary>envelope from</primary>
64274 </indexterm>
64275 <indexterm role="concept">
64276 <primary>envelope sender</primary>
64277 </indexterm>
64278 In a system filter, if a <option>deliver</option> command is followed by
64279 </para>
64280 <literallayout class="monospaced">
64281 errors_to &lt;some address&gt;
64282 </literallayout>
64283 <para>
64284 in order to change the envelope sender (and hence the error reporting) for that
64285 delivery, any address may be specified. (In a user filter, only the current
64286 user&#x2019;s address can be set.) For example, if some mail is being monitored, you
64287 might use
64288 </para>
64289 <literallayout class="monospaced">
64290 unseen deliver monitor@spying.example errors_to root@local.example
64291 </literallayout>
64292 <para>
64293 to take a copy which would not be sent back to the normal error reporting
64294 address if its delivery failed.
64295 </para>
64296 </section>
64297 <section id="SECTperaddfil">
64298 <title>Per-address filtering</title>
64299 <para>
64300 <indexterm role="variable">
64301 <primary><varname>$domain</varname></primary>
64302 </indexterm>
64303 <indexterm role="variable">
64304 <primary><varname>$local_part</varname></primary>
64305 </indexterm>
64306 In contrast to the system filter, which is run just once per message for each
64307 delivery attempt, it is also possible to set up a system-wide filtering
64308 operation that runs once for each recipient address. In this case, variables
64309 such as <varname>$local_part</varname> and <varname>$domain</varname> can be used, and indeed, the choice of
64310 filter file could be made dependent on them. This is an example of a router
64311 which implements such a filter:
64312 </para>
64313 <literallayout class="monospaced">
64314 central_filter:
64315   check_local_user
64316   driver = redirect
64317   domains = +local_domains
64318   file = /central/filters/$local_part
64319   no_verify
64320   allow_filter
64321   allow_freeze
64322 </literallayout>
64323 <para>
64324 The filter is run in a separate process under its own uid. Therefore, either
64325 <option>check_local_user</option> must be set (as above), in which case the filter is run as
64326 the local user, or the <option>user</option> option must be used to specify which user to
64327 use. If both are set, <option>user</option> overrides.
64328 </para>
64329 <para>
64330 Care should be taken to ensure that none of the commands in the filter file
64331 specify a significant delivery if the message is to go on to be delivered to
64332 its intended recipient. The router will not then claim to have dealt with the
64333 address, so it will be passed on to subsequent routers to be delivered in the
64334 normal way.
64335 <indexterm role="concept" startref="IIDsysfil1" class="endofrange"/>
64336 <indexterm role="concept" startref="IIDsysfil2" class="endofrange"/>
64337 <indexterm role="concept" startref="IIDsysfil3" class="endofrange"/>
64338 </para>
64339 </section>
64340 </chapter>
64341
64342 <chapter id="CHAPmsgproc">
64343 <title>Message processing</title>
64344 <para>
64345 <indexterm role="concept" id="IIDmesproc" class="startofrange">
64346 <primary>message</primary>
64347 <secondary>general processing</secondary>
64348 </indexterm>
64349 Exim performs various transformations on the sender and recipient addresses of
64350 all messages that it handles, and also on the messages&#x2019; header lines. Some of
64351 these are optional and configurable, while others always take place. All of
64352 this processing, except rewriting as a result of routing, and the addition or
64353 removal of header lines while delivering, happens when a message is received,
64354 before it is placed on Exim&#x2019;s queue.
64355 </para>
64356 <para>
64357 Some of the automatic processing takes place by default only for
64358 <quote>locally-originated</quote> messages. This adjective is used to describe messages
64359 that are not received over TCP/IP, but instead are passed to an Exim process on
64360 its standard input. This includes the interactive <quote>local SMTP</quote> case that is
64361 set up by the <option>-bs</option> command line option.
64362 </para>
64363 <para>
64364 <emphasis role="bold">Note</emphasis>: Messages received over TCP/IP on the loopback interface (127.0.0.1
64365 or ::1) are not considered to be locally-originated. Exim does not treat the
64366 loopback interface specially in any way.
64367 </para>
64368 <para>
64369 If you want the loopback interface to be treated specially, you must ensure
64370 that there are appropriate entries in your ACLs.
64371 </para>
64372 <section id="SECTsubmodnon">
64373 <title>Submission mode for non-local messages</title>
64374 <para>
64375 <indexterm role="concept">
64376 <primary>message</primary>
64377 <secondary>submission</secondary>
64378 </indexterm>
64379 <indexterm role="concept">
64380 <primary>submission mode</primary>
64381 </indexterm>
64382 Processing that happens automatically for locally-originated messages (unless
64383 <option>suppress_local_fixups</option> is set) can also be requested for messages that are
64384 received over TCP/IP. The term <quote>submission mode</quote> is used to describe this
64385 state. Submission mode is set by the modifier
64386 </para>
64387 <literallayout class="monospaced">
64388 control = submission
64389 </literallayout>
64390 <para>
64391 in a MAIL, RCPT, or pre-data ACL for an incoming message (see sections
64392 <xref linkend="SECTACLmodi"/> and <xref linkend="SECTcontrols"/>). This makes Exim treat the message as
64393 a local submission, and is normally used when the source of the message is
64394 known to be an MUA running on a client host (as opposed to an MTA). For
64395 example, to set submission mode for messages originating on the IPv4 loopback
64396 interface, you could include the following in the MAIL ACL:
64397 </para>
64398 <literallayout class="monospaced">
64399 warn  hosts = 127.0.0.1
64400       control = submission
64401 </literallayout>
64402 <para>
64403 <indexterm role="concept">
64404 <primary><option>sender_retain</option> submission option</primary>
64405 </indexterm>
64406 There are some options that can be used when setting submission mode. A slash
64407 is used to separate options. For example:
64408 </para>
64409 <literallayout class="monospaced">
64410 control = submission/sender_retain
64411 </literallayout>
64412 <para>
64413 Specifying <option>sender_retain</option> has the effect of setting <option>local_sender_retain</option>
64414 true and <option>local_from_check</option> false for the current incoming message. The first
64415 of these allows an existing <emphasis>Sender:</emphasis> header in the message to remain, and
64416 the second suppresses the check to ensure that <emphasis>From:</emphasis> matches the
64417 authenticated sender. With this setting, Exim still fixes up messages by adding
64418 <emphasis>Date:</emphasis> and <emphasis>Message-ID:</emphasis> header lines if they are missing, but makes no
64419 attempt to check sender authenticity in header lines.
64420 </para>
64421 <para>
64422 When <option>sender_retain</option> is not set, a submission mode setting may specify a
64423 domain to be used when generating a <emphasis>From:</emphasis> or <emphasis>Sender:</emphasis> header line. For
64424 example:
64425 </para>
64426 <literallayout class="monospaced">
64427 control = submission/domain=some.domain
64428 </literallayout>
64429 <para>
64430 The domain may be empty. How this value is used is described in sections
64431 <xref linkend="SECTthefrohea"/> and <xref linkend="SECTthesenhea"/>. There is also a <option>name</option> option
64432 that allows you to specify the user&#x2019;s full name for inclusion in a created
64433 <emphasis>Sender:</emphasis> or <emphasis>From:</emphasis> header line. For example:
64434 </para>
64435 <literallayout class="monospaced">
64436 accept authenticated = *
64437        control = submission/domain=wonderland.example/\
64438                             name=${lookup {$authenticated_id} \
64439                                    lsearch {/etc/exim/namelist}}
64440 </literallayout>
64441 <para>
64442 Because the name may contain any characters, including slashes, the <option>name</option>
64443 option must be given last. The remainder of the string is used as the name. For
64444 the example above, if <filename>/etc/exim/namelist</filename> contains:
64445 </para>
64446 <literallayout class="monospaced">
64447 bigegg:  Humpty Dumpty
64448 </literallayout>
64449 <para>
64450 then when the sender has authenticated as <emphasis>bigegg</emphasis>, the generated <emphasis>Sender:</emphasis>
64451 line would be:
64452 </para>
64453 <literallayout class="monospaced">
64454 Sender: Humpty Dumpty &lt;bigegg@wonderland.example&gt;
64455 </literallayout>
64456 <para>
64457 <indexterm role="concept">
64458 <primary>return path</primary>
64459 <secondary>in submission mode</secondary>
64460 </indexterm>
64461 By default, submission mode forces the return path to the same address as is
64462 used to create the <emphasis>Sender:</emphasis> header. However, if <option>sender_retain</option> is
64463 specified, the return path is also left unchanged.
64464 </para>
64465 <para>
64466 <emphasis role="bold">Note</emphasis>: The changes caused by submission mode take effect after the predata
64467 ACL. This means that any sender checks performed before the fix-ups use the
64468 untrusted sender address specified by the user, not the trusted sender address
64469 specified by submission mode. Although this might be slightly unexpected, it
64470 does mean that you can configure ACL checks to spot that a user is trying to
64471 spoof another&#x2019;s address.
64472 </para>
64473 </section>
64474 <section id="SECTlineendings">
64475 <title>Line endings</title>
64476 <para>
64477 <indexterm role="concept">
64478 <primary>line endings</primary>
64479 </indexterm>
64480 <indexterm role="concept">
64481 <primary>carriage return</primary>
64482 </indexterm>
64483 <indexterm role="concept">
64484 <primary>linefeed</primary>
64485 </indexterm>
64486 RFC 2821 specifies that CRLF (two characters: carriage-return, followed by
64487 linefeed) is the line ending for messages transmitted over the Internet using
64488 SMTP over TCP/IP. However, within individual operating systems, different
64489 conventions are used. For example, Unix-like systems use just LF, but others
64490 use CRLF or just CR.
64491 </para>
64492 <para>
64493 Exim was designed for Unix-like systems, and internally, it stores messages
64494 using the system&#x2019;s convention of a single LF as a line terminator. When
64495 receiving a message, all line endings are translated to this standard format.
64496 Originally, it was thought that programs that passed messages directly to an
64497 MTA within an operating system would use that system&#x2019;s convention. Experience
64498 has shown that this is not the case; for example, there are Unix applications
64499 that use CRLF in this circumstance. For this reason, and for compatibility with
64500 other MTAs, the way Exim handles line endings for all messages is now as
64501 follows:
64502 </para>
64503 <itemizedlist>
64504 <listitem>
64505 <para>
64506 LF not preceded by CR is treated as a line ending.
64507 </para>
64508 </listitem>
64509 <listitem>
64510 <para>
64511 CR is treated as a line ending; if it is immediately followed by LF, the LF
64512 is ignored.
64513 </para>
64514 </listitem>
64515 <listitem>
64516 <para>
64517 The sequence <quote>CR, dot, CR</quote> does not terminate an incoming SMTP message,
64518 nor a local message in the state where a line containing only a dot is a
64519 terminator.
64520 </para>
64521 </listitem>
64522 <listitem>
64523 <para>
64524 If a bare CR is encountered within a header line, an extra space is added after
64525 the line terminator so as not to end the header line. The reasoning behind this
64526 is that bare CRs in header lines are most likely either to be mistakes, or
64527 people trying to play silly games.
64528 </para>
64529 </listitem>
64530 <listitem>
64531 <para>
64532 If the first header line received in a message ends with CRLF, a subsequent
64533 bare LF in a header line is treated in the same way as a bare CR in a header
64534 line.
64535 </para>
64536 </listitem>
64537 </itemizedlist>
64538 </section>
64539 <section id="SECID218">
64540 <title>Unqualified addresses</title>
64541 <para>
64542 <indexterm role="concept">
64543 <primary>unqualified addresses</primary>
64544 </indexterm>
64545 <indexterm role="concept">
64546 <primary>address</primary>
64547 <secondary>qualification</secondary>
64548 </indexterm>
64549 By default, Exim expects every envelope address it receives from an external
64550 host to be fully qualified. Unqualified addresses cause negative responses to
64551 SMTP commands. However, because SMTP is used as a means of transporting
64552 messages from MUAs running on personal workstations, there is sometimes a
64553 requirement to accept unqualified addresses from specific hosts or IP networks.
64554 </para>
64555 <para>
64556 Exim has two options that separately control which hosts may send unqualified
64557 sender or recipient addresses in SMTP commands, namely
64558 <option>sender_unqualified_hosts</option> and <option>recipient_unqualified_hosts</option>. In both
64559 cases, if an unqualified address is accepted, it is qualified by adding the
64560 value of <option>qualify_domain</option> or <option>qualify_recipient</option>, as appropriate.
64561 </para>
64562 <para>
64563 <indexterm role="option">
64564 <primary><option>qualify_domain</option></primary>
64565 </indexterm>
64566 <indexterm role="option">
64567 <primary><option>qualify_recipient</option></primary>
64568 </indexterm>
64569 Unqualified addresses in header lines are automatically qualified for messages
64570 that are locally originated, unless the <option>-bnq</option> option is given on the command
64571 line. For messages received over SMTP, unqualified addresses in header lines
64572 are qualified only if unqualified addresses are permitted in SMTP commands. In
64573 other words, such qualification is also controlled by
64574 <option>sender_unqualified_hosts</option> and <option>recipient_unqualified_hosts</option>,
64575 </para>
64576 </section>
64577 <section id="SECID219">
64578 <title>The UUCP From line</title>
64579 <para>
64580 <indexterm role="concept">
64581 <primary><quote>From</quote> line</primary>
64582 </indexterm>
64583 <indexterm role="concept">
64584 <primary>UUCP</primary>
64585 <secondary><quote>From</quote> line</secondary>
64586 </indexterm>
64587 <indexterm role="concept">
64588 <primary>sender</primary>
64589 <secondary>address</secondary>
64590 </indexterm>
64591 <indexterm role="option">
64592 <primary><option>uucp_from_pattern</option></primary>
64593 </indexterm>
64594 <indexterm role="option">
64595 <primary><option>uucp_from_sender</option></primary>
64596 </indexterm>
64597 <indexterm role="concept">
64598 <primary>envelope from</primary>
64599 </indexterm>
64600 <indexterm role="concept">
64601 <primary>envelope sender</primary>
64602 </indexterm>
64603 <indexterm role="concept">
64604 <primary>Sendmail compatibility</primary>
64605 <secondary><quote>From</quote> line</secondary>
64606 </indexterm>
64607 Messages that have come from UUCP (and some other applications) often begin
64608 with a line containing the envelope sender and a timestamp, following the word
64609 <quote>From</quote>. Examples of two common formats are:
64610 </para>
64611 <literallayout class="monospaced">
64612 From a.oakley@berlin.mus Fri Jan  5 12:35 GMT 1996
64613 From f.butler@berlin.mus Fri, 7 Jan 97 14:00:00 GMT
64614 </literallayout>
64615 <para>
64616 This line precedes the RFC 2822 header lines. For compatibility with Sendmail,
64617 Exim recognizes such lines at the start of messages that are submitted to it
64618 via the command line (that is, on the standard input). It does not recognize
64619 such lines in incoming SMTP messages, unless the sending host matches
64620 <option>ignore_fromline_hosts</option> or the <option>-bs</option> option was used for a local message
64621 and <option>ignore_fromline_local</option> is set. The recognition is controlled by a
64622 regular expression that is defined by the <option>uucp_from_pattern</option> option, whose
64623 default value matches the two common cases shown above and puts the address
64624 that follows <quote>From</quote> into <varname>$1</varname>.
64625 </para>
64626 <para>
64627 <indexterm role="concept">
64628 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
64629 <secondary>in <quote>From </quote> line handling</secondary>
64630 </indexterm>
64631 When the caller of Exim for a non-SMTP message that contains a <quote>From</quote> line is
64632 a trusted user, the message&#x2019;s sender address is constructed by expanding the
64633 contents of <option>uucp_sender_address</option>, whose default value is <quote>$1</quote>. This is
64634 then parsed as an RFC 2822 address. If there is no domain, the local part is
64635 qualified with <option>qualify_domain</option> unless it is the empty string. However, if
64636 the command line <option>-f</option> option is used, it overrides the <quote>From</quote> line.
64637 </para>
64638 <para>
64639 If the caller of Exim is not trusted, the <quote>From</quote> line is recognized, but the
64640 sender address is not changed. This is also the case for incoming SMTP messages
64641 that are permitted to contain <quote>From</quote> lines.
64642 </para>
64643 <para>
64644 Only one <quote>From</quote> line is recognized. If there is more than one, the second is
64645 treated as a data line that starts the body of the message, as it is not valid
64646 as a header line. This also happens if a <quote>From</quote> line is present in an
64647 incoming SMTP message from a source that is not permitted to send them.
64648 </para>
64649 </section>
64650 <section id="SECID220">
64651 <title>Resent- header lines</title>
64652 <para>
64653 <indexterm role="concept">
64654 <primary><option>Resent-</option> header lines</primary>
64655 </indexterm>
64656 <indexterm role="concept">
64657 <primary>header lines</primary>
64658 <secondary>Resent-</secondary>
64659 </indexterm>
64660 RFC 2822 makes provision for sets of header lines starting with the string
64661 <literal>Resent-</literal> to be added to a message when it is resent by the original
64662 recipient to somebody else. These headers are <emphasis>Resent-Date:</emphasis>,
64663 <emphasis>Resent-From:</emphasis>, <emphasis>Resent-Sender:</emphasis>, <emphasis>Resent-To:</emphasis>, <emphasis>Resent-Cc:</emphasis>,
64664 <emphasis>Resent-Bcc:</emphasis> and <emphasis>Resent-Message-ID:</emphasis>. The RFC says:
64665 </para>
64666 <blockquote>
64667 <para>
64668 <emphasis>Resent fields are strictly informational. They MUST NOT be used in the normal
64669 processing of replies or other such automatic actions on messages.</emphasis>
64670 </para>
64671 </blockquote>
64672 <para>
64673 This leaves things a bit vague as far as other processing actions such as
64674 address rewriting are concerned. Exim treats <option>Resent-</option> header lines as
64675 follows:
64676 </para>
64677 <itemizedlist>
64678 <listitem>
64679 <para>
64680 A <emphasis>Resent-From:</emphasis> line that just contains the login id of the submitting user
64681 is automatically rewritten in the same way as <emphasis>From:</emphasis> (see below).
64682 </para>
64683 </listitem>
64684 <listitem>
64685 <para>
64686 If there&#x2019;s a rewriting rule for a particular header line, it is also applied to
64687 <option>Resent-</option> header lines of the same type. For example, a rule that rewrites
64688 <emphasis>From:</emphasis> also rewrites <emphasis>Resent-From:</emphasis>.
64689 </para>
64690 </listitem>
64691 <listitem>
64692 <para>
64693 For local messages, if <emphasis>Sender:</emphasis> is removed on input, <emphasis>Resent-Sender:</emphasis> is
64694 also removed.
64695 </para>
64696 </listitem>
64697 <listitem>
64698 <para>
64699 For a locally-submitted message,
64700 if there are any <option>Resent-</option> header lines but no <emphasis>Resent-Date:</emphasis>,
64701 <emphasis>Resent-From:</emphasis>, or <emphasis>Resent-Message-Id:</emphasis>, they are added as necessary. It is
64702 the contents of <emphasis>Resent-Message-Id:</emphasis> (rather than <emphasis>Message-Id:</emphasis>) which are
64703 included in log lines in this case.
64704 </para>
64705 </listitem>
64706 <listitem>
64707 <para>
64708 The logic for adding <emphasis>Sender:</emphasis> is duplicated for <emphasis>Resent-Sender:</emphasis> when any
64709 <option>Resent-</option> header lines are present.
64710 </para>
64711 </listitem>
64712 </itemizedlist>
64713 </section>
64714 <section id="SECID221">
64715 <title>The Auto-Submitted: header line</title>
64716 <para>
64717 Whenever Exim generates an autoreply, a bounce, or a delay warning message, it
64718 includes the header line:
64719 </para>
64720 <literallayout class="monospaced">
64721 Auto-Submitted: auto-replied
64722 </literallayout>
64723 </section>
64724 <section id="SECID222">
64725 <title>The Bcc: header line</title>
64726 <para>
64727 <indexterm role="concept">
64728 <primary><emphasis>Bcc:</emphasis> header line</primary>
64729 </indexterm>
64730 If Exim is called with the <option>-t</option> option, to take recipient addresses from a
64731 message&#x2019;s header, it removes any <emphasis>Bcc:</emphasis> header line that may exist (after
64732 extracting its addresses). If <option>-t</option> is not present on the command line, any
64733 existing <emphasis>Bcc:</emphasis> is not removed.
64734 </para>
64735 </section>
64736 <section id="SECID223">
64737 <title>The Date: header line</title>
64738 <para>
64739 <indexterm role="concept">
64740 <primary><emphasis>Date:</emphasis> header line</primary>
64741 </indexterm>
64742 <indexterm role="concept">
64743 <primary>header lines</primary>
64744 <secondary>Date:</secondary>
64745 </indexterm>
64746 If a locally-generated or submission-mode message has no <emphasis>Date:</emphasis> header line,
64747 Exim adds one, using the current date and time, unless the
64748 <option>suppress_local_fixups</option> control has been specified.
64749 </para>
64750 </section>
64751 <section id="SECID224">
64752 <title>The Delivery-date: header line</title>
64753 <para>
64754 <indexterm role="concept">
64755 <primary><emphasis>Delivery-date:</emphasis> header line</primary>
64756 </indexterm>
64757 <indexterm role="option">
64758 <primary><option>delivery_date_remove</option></primary>
64759 </indexterm>
64760 <emphasis>Delivery-date:</emphasis> header lines are not part of the standard RFC 2822 header
64761 set. Exim can be configured to add them to the final delivery of messages. (See
64762 the generic <option>delivery_date_add</option> transport option.) They should not be present
64763 in messages in transit. If the <option>delivery_date_remove</option> configuration option is
64764 set (the default), Exim removes <emphasis>Delivery-date:</emphasis> header lines from incoming
64765 messages.
64766 </para>
64767 </section>
64768 <section id="SECID225">
64769 <title>The Envelope-to: header line</title>
64770 <para>
64771 <indexterm role="concept">
64772 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
64773 </indexterm>
64774 <indexterm role="concept">
64775 <primary>header lines</primary>
64776 <secondary>Envelope-to:</secondary>
64777 </indexterm>
64778 <indexterm role="option">
64779 <primary><option>envelope_to_remove</option></primary>
64780 </indexterm>
64781 <emphasis>Envelope-to:</emphasis> header lines are not part of the standard RFC 2822 header set.
64782 Exim can be configured to add them to the final delivery of messages. (See the
64783 generic <option>envelope_to_add</option> transport option.) They should not be present in
64784 messages in transit. If the <option>envelope_to_remove</option> configuration option is set
64785 (the default), Exim removes <emphasis>Envelope-to:</emphasis> header lines from incoming
64786 messages.
64787 </para>
64788 </section>
64789 <section id="SECTthefrohea">
64790 <title>The From: header line</title>
64791 <para>
64792 <indexterm role="concept">
64793 <primary><emphasis>From:</emphasis> header line</primary>
64794 </indexterm>
64795 <indexterm role="concept">
64796 <primary>header lines</primary>
64797 <secondary>From:</secondary>
64798 </indexterm>
64799 <indexterm role="concept">
64800 <primary>Sendmail compatibility</primary>
64801 <secondary><quote>From</quote> line</secondary>
64802 </indexterm>
64803 <indexterm role="concept">
64804 <primary>message</primary>
64805 <secondary>submission</secondary>
64806 </indexterm>
64807 <indexterm role="concept">
64808 <primary>submission mode</primary>
64809 </indexterm>
64810 If a submission-mode message does not contain a <emphasis>From:</emphasis> header line, Exim
64811 adds one if either of the following conditions is true:
64812 </para>
64813 <itemizedlist>
64814 <listitem>
64815 <para>
64816 The envelope sender address is not empty (that is, this is not a bounce
64817 message). The added header line copies the envelope sender address.
64818 </para>
64819 </listitem>
64820 <listitem>
64821 <para>
64822 <indexterm role="variable">
64823 <primary><varname>$authenticated_id</varname></primary>
64824 </indexterm>
64825 The SMTP session is authenticated and <varname>$authenticated_id</varname> is not empty.
64826 </para>
64827 <orderedlist numeration="arabic">
64828 <listitem>
64829 <para>
64830 <indexterm role="variable">
64831 <primary><varname>$qualify_domain</varname></primary>
64832 </indexterm>
64833 If no domain is specified by the submission control, the local part is
64834 <varname>$authenticated_id</varname> and the domain is <varname>$qualify_domain</varname>.
64835 </para>
64836 </listitem>
64837 <listitem>
64838 <para>
64839 If a non-empty domain is specified by the submission control, the local
64840 part is <varname>$authenticated_id</varname>, and the domain is the specified domain.
64841 </para>
64842 </listitem>
64843 <listitem>
64844 <para>
64845 If an empty domain is specified by the submission control,
64846 <varname>$authenticated_id</varname> is assumed to be the complete address.
64847 </para>
64848 </listitem>
64849 </orderedlist>
64850 </listitem>
64851 </itemizedlist>
64852 <para>
64853 A non-empty envelope sender takes precedence.
64854 </para>
64855 <para>
64856 If a locally-generated incoming message does not contain a <emphasis>From:</emphasis> header
64857 line, and the <option>suppress_local_fixups</option> control is not set, Exim adds one
64858 containing the sender&#x2019;s address. The calling user&#x2019;s login name and full name
64859 are used to construct the address, as described in section <xref linkend="SECTconstr"/>.
64860 They are obtained from the password data by calling <function>getpwuid()</function> (but see the
64861 <option>unknown_login</option> configuration option). The address is qualified with
64862 <option>qualify_domain</option>.
64863 </para>
64864 <para>
64865 For compatibility with Sendmail, if an incoming, non-SMTP message has a
64866 <emphasis>From:</emphasis> header line containing just the unqualified login name of the calling
64867 user, this is replaced by an address containing the user&#x2019;s login name and full
64868 name as described in section <xref linkend="SECTconstr"/>.
64869 </para>
64870 </section>
64871 <section id="SECID226">
64872 <title>The Message-ID: header line</title>
64873 <para>
64874 <indexterm role="concept">
64875 <primary><emphasis>Message-ID:</emphasis> header line</primary>
64876 </indexterm>
64877 <indexterm role="concept">
64878 <primary>header lines</primary>
64879 <secondary>Message-ID:</secondary>
64880 </indexterm>
64881 <indexterm role="concept">
64882 <primary>message</primary>
64883 <secondary>submission</secondary>
64884 </indexterm>
64885 <indexterm role="option">
64886 <primary><option>message_id_header_text</option></primary>
64887 </indexterm>
64888 If a locally-generated or submission-mode incoming message does not contain a
64889 <emphasis>Message-ID:</emphasis> or <emphasis>Resent-Message-ID:</emphasis> header line, and the
64890 <option>suppress_local_fixups</option> control is not set, Exim adds a suitable header line
64891 to the message. If there are any <emphasis>Resent-:</emphasis> headers in the message, it
64892 creates <emphasis>Resent-Message-ID:</emphasis>. The id is constructed from Exim&#x2019;s internal
64893 message id, preceded by the letter E to ensure it starts with a letter, and
64894 followed by @ and the primary host name. Additional information can be included
64895 in this header line by setting the <option>message_id_header_text</option> and/or
64896 <option>message_id_header_domain</option> options.
64897 </para>
64898 </section>
64899 <section id="SECID227">
64900 <title>The Received: header line</title>
64901 <para>
64902 <indexterm role="concept">
64903 <primary><emphasis>Received:</emphasis> header line</primary>
64904 </indexterm>
64905 <indexterm role="concept">
64906 <primary>header lines</primary>
64907 <secondary>Received:</secondary>
64908 </indexterm>
64909 A <emphasis>Received:</emphasis> header line is added at the start of every message. The
64910 contents are defined by the <option>received_header_text</option> configuration option, and
64911 Exim automatically adds a semicolon and a timestamp to the configured string.
64912 </para>
64913 <para>
64914 The <emphasis>Received:</emphasis> header is generated as soon as the message&#x2019;s header lines
64915 have been received. At this stage, the timestamp in the <emphasis>Received:</emphasis> header
64916 line is the time that the message started to be received. This is the value
64917 that is seen by the DATA ACL and by the <function>local_scan()</function> function.
64918 </para>
64919 <para>
64920 Once a message is accepted, the timestamp in the <emphasis>Received:</emphasis> header line is
64921 changed to the time of acceptance, which is (apart from a small delay while the
64922 -H spool file is written) the earliest time at which delivery could start.
64923 </para>
64924 </section>
64925 <section id="SECID228">
64926 <title>The References: header line</title>
64927 <para>
64928 <indexterm role="concept">
64929 <primary><emphasis>References:</emphasis> header line</primary>
64930 </indexterm>
64931 <indexterm role="concept">
64932 <primary>header lines</primary>
64933 <secondary>References:</secondary>
64934 </indexterm>
64935 Messages created by the <command>autoreply</command> transport include a <emphasis>References:</emphasis>
64936 header line. This is constructed according to the rules that are described in
64937 section 3.64 of RFC 2822 (which states that replies should contain such a
64938 header line), and section 3.14 of RFC 3834 (which states that automatic
64939 responses are not different in this respect). However, because some mail
64940 processing software does not cope well with very long header lines, no more
64941 than 12 message IDs are copied from the <emphasis>References:</emphasis> header line in the
64942 incoming message. If there are more than 12, the first one and then the final
64943 11 are copied, before adding the message ID of the incoming message.
64944 </para>
64945 </section>
64946 <section id="SECID229">
64947 <title>The Return-path: header line</title>
64948 <para>
64949 <indexterm role="concept">
64950 <primary><emphasis>Return-path:</emphasis> header line</primary>
64951 </indexterm>
64952 <indexterm role="concept">
64953 <primary>header lines</primary>
64954 <secondary>Return-path:</secondary>
64955 </indexterm>
64956 <indexterm role="option">
64957 <primary><option>return_path_remove</option></primary>
64958 </indexterm>
64959 <emphasis>Return-path:</emphasis> header lines are defined as something an MTA may insert when
64960 it does the final delivery of messages. (See the generic <option>return_path_add</option>
64961 transport option.) Therefore, they should not be present in messages in
64962 transit. If the <option>return_path_remove</option> configuration option is set (the
64963 default), Exim removes <emphasis>Return-path:</emphasis> header lines from incoming messages.
64964 </para>
64965 </section>
64966 <section id="SECTthesenhea">
64967 <title>The Sender: header line</title>
64968 <para>
64969 <indexterm role="concept">
64970 <primary><emphasis>Sender:</emphasis> header line</primary>
64971 </indexterm>
64972 <indexterm role="concept">
64973 <primary>message</primary>
64974 <secondary>submission</secondary>
64975 </indexterm>
64976 <indexterm role="concept">
64977 <primary>header lines</primary>
64978 <secondary>Sender:</secondary>
64979 </indexterm>
64980 For a locally-originated message from an untrusted user, Exim may remove an
64981 existing <emphasis>Sender:</emphasis> header line, and it may add a new one. You can modify
64982 these actions by setting the <option>local_sender_retain</option> option true, the
64983 <option>local_from_check</option> option false, or by using the <option>suppress_local_fixups</option>
64984 control setting.
64985 </para>
64986 <para>
64987 When a local message is received from an untrusted user and
64988 <option>local_from_check</option> is true (the default), and the <option>suppress_local_fixups</option>
64989 control has not been set, a check is made to see if the address given in the
64990 <emphasis>From:</emphasis> header line is the correct (local) sender of the message. The address
64991 that is expected has the login name as the local part and the value of
64992 <option>qualify_domain</option> as the domain. Prefixes and suffixes for the local part can
64993 be permitted by setting <option>local_from_prefix</option> and <option>local_from_suffix</option>
64994 appropriately. If <emphasis>From:</emphasis> does not contain the correct sender, a <emphasis>Sender:</emphasis>
64995 line is added to the message.
64996 </para>
64997 <para>
64998 If you set <option>local_from_check</option> false, this checking does not occur. However,
64999 the removal of an existing <emphasis>Sender:</emphasis> line still happens, unless you also set
65000 <option>local_sender_retain</option> to be true. It is not possible to set both of these
65001 options true at the same time.
65002 </para>
65003 <para>
65004 <indexterm role="concept">
65005 <primary>submission mode</primary>
65006 </indexterm>
65007 By default, no processing of <emphasis>Sender:</emphasis> header lines is done for messages
65008 received over TCP/IP or for messages submitted by trusted users. However, when
65009 a message is received over TCP/IP in submission mode, and <option>sender_retain</option> is
65010 not specified on the submission control, the following processing takes place:
65011 </para>
65012 <para>
65013 <indexterm role="variable">
65014 <primary><varname>$authenticated_id</varname></primary>
65015 </indexterm>
65016 First, any existing <emphasis>Sender:</emphasis> lines are removed. Then, if the SMTP session is
65017 authenticated, and <varname>$authenticated_id</varname> is not empty, a sender address is
65018 created as follows:
65019 </para>
65020 <itemizedlist>
65021 <listitem>
65022 <para>
65023 <indexterm role="variable">
65024 <primary><varname>$qualify_domain</varname></primary>
65025 </indexterm>
65026 If no domain is specified by the submission control, the local part is
65027 <varname>$authenticated_id</varname> and the domain is <varname>$qualify_domain</varname>.
65028 </para>
65029 </listitem>
65030 <listitem>
65031 <para>
65032 If a non-empty domain is specified by the submission control, the local part
65033 is <varname>$authenticated_id</varname>, and the domain is the specified domain.
65034 </para>
65035 </listitem>
65036 <listitem>
65037 <para>
65038 If an empty domain is specified by the submission control,
65039 <varname>$authenticated_id</varname> is assumed to be the complete address.
65040 </para>
65041 </listitem>
65042 </itemizedlist>
65043 <para>
65044 This address is compared with the address in the <emphasis>From:</emphasis> header line. If they
65045 are different, a <emphasis>Sender:</emphasis> header line containing the created address is
65046 added. Prefixes and suffixes for the local part in <emphasis>From:</emphasis> can be permitted
65047 by setting <option>local_from_prefix</option> and <option>local_from_suffix</option> appropriately.
65048 </para>
65049 <para>
65050 <indexterm role="concept">
65051 <primary>return path</primary>
65052 <secondary>created from <emphasis>Sender:</emphasis></secondary>
65053 </indexterm>
65054 <emphasis role="bold">Note</emphasis>: Whenever a <emphasis>Sender:</emphasis> header line is created, the return path for
65055 the message (the envelope sender address) is changed to be the same address,
65056 except in the case of submission mode when <option>sender_retain</option> is specified.
65057 </para>
65058 </section>
65059 <section id="SECTheadersaddrem">
65060 <title>Adding and removing header lines in routers and transports</title>
65061 <para>
65062 <indexterm role="concept">
65063 <primary>header lines</primary>
65064 <secondary>adding; in router or transport</secondary>
65065 </indexterm>
65066 <indexterm role="concept">
65067 <primary>header lines</primary>
65068 <secondary>removing; in router or transport</secondary>
65069 </indexterm>
65070 When a message is delivered, the addition and removal of header lines can be
65071 specified in a system filter, or on any of the routers and transports that
65072 process the message. Section <xref linkend="SECTaddremheasys"/> contains details about
65073 modifying headers in a system filter. Header lines can also be added in an ACL
65074 as a message is received (see section <xref linkend="SECTaddheadacl"/>).
65075 </para>
65076 <para>
65077 In contrast to what happens in a system filter, header modifications that are
65078 specified on routers and transports apply only to the particular recipient
65079 addresses that are being processed by those routers and transports. These
65080 changes do not actually take place until a copy of the message is being
65081 transported. Therefore, they do not affect the basic set of header lines, and
65082 they do not affect the values of the variables that refer to header lines.
65083 </para>
65084 <para>
65085 <emphasis role="bold">Note</emphasis>: In particular, this means that any expansions in the configuration of
65086 the transport cannot refer to the modified header lines, because such
65087 expansions all occur before the message is actually transported.
65088 </para>
65089 <para>
65090 For both routers and transports, the argument of a <option>headers_add</option>
65091 option must be in the form of one or more RFC 2822 header lines, separated by
65092 newlines (coded as <quote>\n</quote>). For example:
65093 </para>
65094 <literallayout class="monospaced">
65095 headers_add = X-added-header: added by $primary_hostname\n\
65096               X-added-second: another added header line
65097 </literallayout>
65098 <para>
65099 Exim does not check the syntax of these added header lines.
65100 </para>
65101 <para>
65102 Multiple <option>headers_add</option> options for a single router or transport can be
65103 specified; the values will append to a single list of header lines.
65104 Each header-line is separately expanded.
65105 </para>
65106 <para>
65107 The argument of a <option>headers_remove</option> option must consist of a colon-separated
65108 list of header names. This is confusing, because header names themselves are
65109 often terminated by colons. In this case, the colons are the list separators,
65110 not part of the names. For example:
65111 </para>
65112 <literallayout class="monospaced">
65113 headers_remove = return-receipt-to:acknowledge-to
65114 </literallayout>
65115 <para>
65116 Multiple <option>headers_remove</option> options for a single router or transport can be
65117 specified; the arguments will append to a single header-names list.
65118 Each item is separately expanded.
65119 Note that colons in complex expansions which are used to
65120 form all or part of a <option>headers_remove</option> list
65121 will act as list separators.
65122 </para>
65123 <para>
65124 When <option>headers_add</option> or <option>headers_remove</option> is specified on a router,
65125 items are expanded at routing time,
65126 and then associated with all addresses that are
65127 accepted by that router, and also with any new addresses that it generates. If
65128 an address passes through several routers as a result of aliasing or
65129 forwarding, the changes are cumulative.
65130 </para>
65131 <para>
65132 <indexterm role="option">
65133 <primary><option>unseen</option></primary>
65134 </indexterm>
65135 However, this does not apply to multiple routers that result from the use of
65136 the <option>unseen</option> option. Any header modifications that were specified by the
65137 <quote>unseen</quote> router or its predecessors apply only to the <quote>unseen</quote> delivery.
65138 </para>
65139 <para>
65140 Addresses that end up with different <option>headers_add</option> or <option>headers_remove</option>
65141 settings cannot be delivered together in a batch, so a transport is always
65142 dealing with a set of addresses that have the same header-processing
65143 requirements.
65144 </para>
65145 <para>
65146 The transport starts by writing the original set of header lines that arrived
65147 with the message, possibly modified by the system filter. As it writes out
65148 these lines, it consults the list of header names that were attached to the
65149 recipient address(es) by <option>headers_remove</option> options in routers, and it also
65150 consults the transport&#x2019;s own <option>headers_remove</option> option. Header lines whose
65151 names are on either of these lists are not written out. If there are multiple
65152 instances of any listed header, they are all skipped.
65153 </para>
65154 <para>
65155 After the remaining original header lines have been written, new header
65156 lines that were specified by routers&#x2019; <option>headers_add</option> options are written, in
65157 the order in which they were attached to the address. These are followed by any
65158 header lines specified by the transport&#x2019;s <option>headers_add</option> option.
65159 </para>
65160 <para>
65161 This way of handling header line modifications in routers and transports has
65162 the following consequences:
65163 </para>
65164 <itemizedlist>
65165 <listitem>
65166 <para>
65167 The original set of header lines, possibly modified by the system filter,
65168 remains <quote>visible</quote>, in the sense that the <varname>$header_</varname><emphasis>xxx</emphasis> variables refer
65169 to it, at all times.
65170 </para>
65171 </listitem>
65172 <listitem>
65173 <para>
65174 Header lines that are added by a router&#x2019;s
65175 <option>headers_add</option> option are not accessible by means of the <varname>$header_</varname><emphasis>xxx</emphasis>
65176 expansion syntax in subsequent routers or the transport.
65177 </para>
65178 </listitem>
65179 <listitem>
65180 <para>
65181 Conversely, header lines that are specified for removal by <option>headers_remove</option>
65182 in a router remain visible to subsequent routers and the transport.
65183 </para>
65184 </listitem>
65185 <listitem>
65186 <para>
65187 Headers added to an address by <option>headers_add</option> in a router cannot be removed by
65188 a later router or by a transport.
65189 </para>
65190 </listitem>
65191 <listitem>
65192 <para>
65193 An added header can refer to the contents of an original header that is to be
65194 removed, even it has the same name as the added header. For example:
65195 </para>
65196 <literallayout class="monospaced">
65197 headers_remove = subject
65198 headers_add = Subject: new subject (was: $h_subject:)
65199 </literallayout>
65200 </listitem>
65201 </itemizedlist>
65202 <para>
65203 <emphasis role="bold">Warning</emphasis>: The <option>headers_add</option> and <option>headers_remove</option> options cannot be used
65204 for a <command>redirect</command> router that has the <option>one_time</option> option set.
65205 </para>
65206 </section>
65207 <section id="SECTconstr">
65208 <title>Constructed addresses</title>
65209 <para>
65210 <indexterm role="concept">
65211 <primary>address</primary>
65212 <secondary>constructed</secondary>
65213 </indexterm>
65214 <indexterm role="concept">
65215 <primary>constructed address</primary>
65216 </indexterm>
65217 When Exim constructs a sender address for a locally-generated message, it uses
65218 the form
65219 </para>
65220 <literallayout>
65221 &lt;<emphasis>user name</emphasis>&gt;&nbsp;&nbsp;&lt;<emphasis>login</emphasis><literal>@</literal><emphasis>qualify_domain</emphasis>&gt;
65222 </literallayout>
65223 <para>
65224 For example:
65225 </para>
65226 <literallayout class="monospaced">
65227 Zaphod Beeblebrox &lt;zaphod@end.univ.example&gt;
65228 </literallayout>
65229 <para>
65230 The user name is obtained from the <option>-F</option> command line option if set, or
65231 otherwise by looking up the calling user by <function>getpwuid()</function> and extracting the
65232 <quote>gecos</quote> field from the password entry. If the <quote>gecos</quote> field contains an
65233 ampersand character, this is replaced by the login name with the first letter
65234 upper cased, as is conventional in a number of operating systems. See the
65235 <option>gecos_name</option> option for a way to tailor the handling of the <quote>gecos</quote> field.
65236 The <option>unknown_username</option> option can be used to specify user names in cases when
65237 there is no password file entry.
65238 </para>
65239 <para>
65240 <indexterm role="concept">
65241 <primary>RFC 2047</primary>
65242 </indexterm>
65243 In all cases, the user name is made to conform to RFC 2822 by quoting all or
65244 parts of it if necessary. In addition, if it contains any non-printing
65245 characters, it is encoded as described in RFC 2047, which defines a way of
65246 including non-ASCII characters in header lines. The value of the
65247 <option>headers_charset</option> option specifies the name of the encoding that is used (the
65248 characters are assumed to be in this encoding). The setting of
65249 <option>print_topbitchars</option> controls whether characters with the top bit set (that
65250 is, with codes greater than 127) count as printing characters or not.
65251 </para>
65252 </section>
65253 <section id="SECID230">
65254 <title>Case of local parts</title>
65255 <para>
65256 <indexterm role="concept">
65257 <primary>case of local parts</primary>
65258 </indexterm>
65259 <indexterm role="concept">
65260 <primary>local part</primary>
65261 <secondary>case of</secondary>
65262 </indexterm>
65263 RFC 2822 states that the case of letters in the local parts of addresses cannot
65264 be assumed to be non-significant. Exim preserves the case of local parts of
65265 addresses, but by default it uses a lower-cased form when it is routing,
65266 because on most Unix systems, usernames are in lower case and case-insensitive
65267 routing is required. However, any particular router can be made to use the
65268 original case for local parts by setting the <option>caseful_local_part</option> generic
65269 router option.
65270 </para>
65271 <para>
65272 <indexterm role="concept">
65273 <primary>mixed-case login names</primary>
65274 </indexterm>
65275 If you must have mixed-case user names on your system, the best way to proceed,
65276 assuming you want case-independent handling of incoming email, is to set up
65277 your first router to convert incoming local parts in your domains to the
65278 correct case by means of a file lookup. For example:
65279 </para>
65280 <literallayout class="monospaced">
65281 correct_case:
65282   driver = redirect
65283   domains = +local_domains
65284   data = ${lookup{$local_part}cdb\
65285               {/etc/usercased.cdb}{$value}fail}\
65286               @$domain
65287 </literallayout>
65288 <para>
65289 For this router, the local part is forced to lower case by the default action
65290 (<option>caseful_local_part</option> is not set). The lower-cased local part is used to look
65291 up a new local part in the correct case. If you then set <option>caseful_local_part</option>
65292 on any subsequent routers which process your domains, they will operate on
65293 local parts with the correct case in a case-sensitive manner.
65294 </para>
65295 </section>
65296 <section id="SECID231">
65297 <title>Dots in local parts</title>
65298 <para>
65299 <indexterm role="concept">
65300 <primary>dot</primary>
65301 <secondary>in local part</secondary>
65302 </indexterm>
65303 <indexterm role="concept">
65304 <primary>local part</primary>
65305 <secondary>dots in</secondary>
65306 </indexterm>
65307 RFC 2822 forbids empty components in local parts. That is, an unquoted local
65308 part may not begin or end with a dot, nor have two consecutive dots in the
65309 middle. However, it seems that many MTAs do not enforce this, so Exim permits
65310 empty components for compatibility.
65311 </para>
65312 </section>
65313 <section id="SECID232">
65314 <title>Rewriting addresses</title>
65315 <para>
65316 <indexterm role="concept">
65317 <primary>rewriting</primary>
65318 <secondary>addresses</secondary>
65319 </indexterm>
65320 Rewriting of sender and recipient addresses, and addresses in headers, can
65321 happen automatically, or as the result of configuration options, as described
65322 in chapter <xref linkend="CHAPrewrite"/>. The headers that may be affected by this are
65323 <emphasis>Bcc:</emphasis>, <emphasis>Cc:</emphasis>, <emphasis>From:</emphasis>, <emphasis>Reply-To:</emphasis>, <emphasis>Sender:</emphasis>, and <emphasis>To:</emphasis>.
65324 </para>
65325 <para>
65326 Automatic rewriting includes qualification, as mentioned above. The other case
65327 in which it can happen is when an incomplete non-local domain is given. The
65328 routing process may cause this to be expanded into the full domain name. For
65329 example, a header such as
65330 </para>
65331 <literallayout class="monospaced">
65332 To: hare@teaparty
65333 </literallayout>
65334 <para>
65335 might get rewritten as
65336 </para>
65337 <literallayout class="monospaced">
65338 To: hare@teaparty.wonderland.fict.example
65339 </literallayout>
65340 <para>
65341 Rewriting as a result of routing is the one kind of message processing that
65342 does not happen at input time, as it cannot be done until the address has
65343 been routed.
65344 </para>
65345 <para>
65346 Strictly, one should not do <emphasis>any</emphasis> deliveries of a message until all its
65347 addresses have been routed, in case any of the headers get changed as a
65348 result of routing. However, doing this in practice would hold up many
65349 deliveries for unreasonable amounts of time, just because one address could not
65350 immediately be routed. Exim therefore does not delay other deliveries when
65351 routing of one or more addresses is deferred.
65352 <indexterm role="concept" startref="IIDmesproc" class="endofrange"/>
65353 </para>
65354 </section>
65355 </chapter>
65356
65357 <chapter id="CHAPSMTP">
65358 <title>SMTP processing</title>
65359 <para>
65360 <indexterm role="concept" id="IIDsmtpproc1" class="startofrange">
65361 <primary>SMTP</primary>
65362 <secondary>processing details</secondary>
65363 </indexterm>
65364 <indexterm role="concept" id="IIDsmtpproc2" class="startofrange">
65365 <primary>LMTP</primary>
65366 <secondary>processing details</secondary>
65367 </indexterm>
65368 Exim supports a number of different ways of using the SMTP protocol, and its
65369 LMTP variant, which is an interactive protocol for transferring messages into a
65370 closed mail store application. This chapter contains details of how SMTP is
65371 processed. For incoming mail, the following are available:
65372 </para>
65373 <itemizedlist>
65374 <listitem>
65375 <para>
65376 SMTP over TCP/IP (Exim daemon or <emphasis>inetd</emphasis>);
65377 </para>
65378 </listitem>
65379 <listitem>
65380 <para>
65381 SMTP over the standard input and output (the <option>-bs</option> option);
65382 </para>
65383 </listitem>
65384 <listitem>
65385 <para>
65386 Batched SMTP on the standard input (the <option>-bS</option> option).
65387 </para>
65388 </listitem>
65389 </itemizedlist>
65390 <para>
65391 For mail delivery, the following are available:
65392 </para>
65393 <itemizedlist>
65394 <listitem>
65395 <para>
65396 SMTP over TCP/IP (the <command>smtp</command> transport);
65397 </para>
65398 </listitem>
65399 <listitem>
65400 <para>
65401 LMTP over TCP/IP (the <command>smtp</command> transport with the <option>protocol</option> option set to
65402 <quote>lmtp</quote>);
65403 </para>
65404 </listitem>
65405 <listitem>
65406 <para>
65407 LMTP over a pipe to a process running in the local host (the <command>lmtp</command>
65408 transport);
65409 </para>
65410 </listitem>
65411 <listitem>
65412 <para>
65413 Batched SMTP to a file or pipe (the <command>appendfile</command> and <command>pipe</command> transports with
65414 the <option>use_bsmtp</option> option set).
65415 </para>
65416 </listitem>
65417 </itemizedlist>
65418 <para>
65419 <emphasis>Batched SMTP</emphasis> is the name for a process in which batches of messages are
65420 stored in or read from files (or pipes), in a format in which SMTP commands are
65421 used to contain the envelope information.
65422 </para>
65423 <section id="SECToutSMTPTCP">
65424 <title>Outgoing SMTP and LMTP over TCP/IP</title>
65425 <para>
65426 <indexterm role="concept">
65427 <primary>SMTP</primary>
65428 <secondary>outgoing over TCP/IP</secondary>
65429 </indexterm>
65430 <indexterm role="concept">
65431 <primary>outgoing SMTP over TCP/IP</primary>
65432 </indexterm>
65433 <indexterm role="concept">
65434 <primary>LMTP</primary>
65435 <secondary>over TCP/IP</secondary>
65436 </indexterm>
65437 <indexterm role="concept">
65438 <primary>outgoing LMTP over TCP/IP</primary>
65439 </indexterm>
65440 <indexterm role="concept">
65441 <primary>EHLO</primary>
65442 </indexterm>
65443 <indexterm role="concept">
65444 <primary>HELO</primary>
65445 </indexterm>
65446 <indexterm role="concept">
65447 <primary>SIZE option on MAIL command</primary>
65448 </indexterm>
65449 Outgoing SMTP and LMTP over TCP/IP is implemented by the <command>smtp</command> transport.
65450 The <option>protocol</option> option selects which protocol is to be used, but the actual
65451 processing is the same in both cases.
65452 </para>
65453 <para>
65454 If, in response to its EHLO command, Exim is told that the SIZE
65455 parameter is supported, it adds SIZE=&lt;<emphasis>n</emphasis>&gt; to each subsequent MAIL
65456 command. The value of &lt;<emphasis>n</emphasis>&gt; is the message size plus the value of the
65457 <option>size_addition</option> option (default 1024) to allow for additions to the message
65458 such as per-transport header lines, or changes made in a
65459 <indexterm role="concept">
65460 <primary>transport</primary>
65461 <secondary>filter</secondary>
65462 </indexterm>
65463 <indexterm role="concept">
65464 <primary>filter</primary>
65465 <secondary>transport filter</secondary>
65466 </indexterm>
65467 transport filter. If <option>size_addition</option> is set negative, the use of SIZE is
65468 suppressed.
65469 </para>
65470 <para>
65471 If the remote server advertises support for PIPELINING, Exim uses the
65472 pipelining extension to SMTP (RFC 2197) to reduce the number of TCP/IP packets
65473 required for the transaction.
65474 </para>
65475 <para>
65476 If the remote server advertises support for the STARTTLS command, and Exim
65477 was built to support TLS encryption, it tries to start a TLS session unless the
65478 server matches <option>hosts_avoid_tls</option>. See chapter <xref linkend="CHAPTLS"/> for more details.
65479 Either a match in that or <option>hosts_verify_avoid_tls</option> apply when the transport
65480 is called for verification.
65481 </para>
65482 <para>
65483 If the remote server advertises support for the AUTH command, Exim scans
65484 the authenticators configuration for any suitable client settings, as described
65485 in chapter <xref linkend="CHAPSMTPAUTH"/>.
65486 </para>
65487 <para>
65488 <indexterm role="concept">
65489 <primary>carriage return</primary>
65490 </indexterm>
65491 <indexterm role="concept">
65492 <primary>linefeed</primary>
65493 </indexterm>
65494 Responses from the remote host are supposed to be terminated by CR followed by
65495 LF. However, there are known to be hosts that do not send CR characters, so in
65496 order to be able to interwork with such hosts, Exim treats LF on its own as a
65497 line terminator.
65498 </para>
65499 <para>
65500 If a message contains a number of different addresses, all those with the same
65501 characteristics (for example, the same envelope sender) that resolve to the
65502 same set of hosts, in the same order, are sent in a single SMTP transaction,
65503 even if they are for different domains, unless there are more than the setting
65504 of the <option>max_rcpt</option>s option in the <command>smtp</command> transport allows, in which case
65505 they are split into groups containing no more than <option>max_rcpt</option>s addresses
65506 each. If <option>remote_max_parallel</option> is greater than one, such groups may be sent
65507 in parallel sessions. The order of hosts with identical MX values is not
65508 significant when checking whether addresses can be batched in this way.
65509 </para>
65510 <para>
65511 When the <command>smtp</command> transport suffers a temporary failure that is not
65512 message-related, Exim updates its transport-specific database, which contains
65513 records indexed by host name that remember which messages are waiting for each
65514 particular host. It also updates the retry database with new retry times.
65515 </para>
65516 <para>
65517 <indexterm role="concept">
65518 <primary>hints database</primary>
65519 <secondary>retry keys</secondary>
65520 </indexterm>
65521 Exim&#x2019;s retry hints are based on host name plus IP address, so if one address of
65522 a multi-homed host is broken, it will soon be skipped most of the time.
65523 See the next section for more detail about error handling.
65524 </para>
65525 <para>
65526 <indexterm role="concept">
65527 <primary>SMTP</primary>
65528 <secondary>passed connection</secondary>
65529 </indexterm>
65530 <indexterm role="concept">
65531 <primary>SMTP</primary>
65532 <secondary>batching over TCP/IP</secondary>
65533 </indexterm>
65534 When a message is successfully delivered over a TCP/IP SMTP connection, Exim
65535 looks in the hints database for the transport to see if there are any queued
65536 messages waiting for the host to which it is connected. If it finds one, it
65537 creates a new Exim process using the <option>-MC</option> option (which can only be used by
65538 a process running as root or the Exim user) and passes the TCP/IP socket to it
65539 so that it can deliver another message using the same socket. The new process
65540 does only those deliveries that are routed to the connected host, and may in
65541 turn pass the socket on to a third process, and so on.
65542 </para>
65543 <para>
65544 The <option>connection_max_messages</option> option of the <command>smtp</command> transport can be used to
65545 limit the number of messages sent down a single TCP/IP connection.
65546 </para>
65547 <para>
65548 <indexterm role="concept">
65549 <primary>asterisk</primary>
65550 <secondary>after IP address</secondary>
65551 </indexterm>
65552 The second and subsequent messages delivered down an existing connection are
65553 identified in the main log by the addition of an asterisk after the closing
65554 square bracket of the IP address.
65555 </para>
65556 </section>
65557 <section id="SECToutSMTPerr">
65558 <title>Errors in outgoing SMTP</title>
65559 <para>
65560 <indexterm role="concept">
65561 <primary>error</primary>
65562 <secondary>in outgoing SMTP</secondary>
65563 </indexterm>
65564 <indexterm role="concept">
65565 <primary>SMTP</primary>
65566 <secondary>errors in outgoing</secondary>
65567 </indexterm>
65568 <indexterm role="concept">
65569 <primary>host</primary>
65570 <secondary>error</secondary>
65571 </indexterm>
65572 Three different kinds of error are recognized for outgoing SMTP: host errors,
65573 message errors, and recipient errors.
65574 </para>
65575 <variablelist>
65576 <varlistentry>
65577 <term><emphasis role="bold">Host errors</emphasis></term>
65578 <listitem>
65579 <para>
65580 A host error is not associated with a particular message or with a
65581 particular recipient of a message. The host errors are:
65582 </para>
65583 <itemizedlist>
65584 <listitem>
65585 <para>
65586 Connection refused or timed out,
65587 </para>
65588 </listitem>
65589 <listitem>
65590 <para>
65591 Any error response code on connection,
65592 </para>
65593 </listitem>
65594 <listitem>
65595 <para>
65596 Any error response code to EHLO or HELO,
65597 </para>
65598 </listitem>
65599 <listitem>
65600 <para>
65601 Loss of connection at any time, except after <quote>.</quote>,
65602 </para>
65603 </listitem>
65604 <listitem>
65605 <para>
65606 I/O errors at any time,
65607 </para>
65608 </listitem>
65609 <listitem>
65610 <para>
65611 Timeouts during the session, other than in response to MAIL, RCPT or
65612 the <quote>.</quote> at the end of the data.
65613 </para>
65614 </listitem>
65615 </itemizedlist>
65616 <para>
65617 For a host error, a permanent error response on connection, or in response to
65618 EHLO, causes all addresses routed to the host to be failed. Any other host
65619 error causes all addresses to be deferred, and retry data to be created for the
65620 host. It is not tried again, for any message, until its retry time arrives. If
65621 the current set of addresses are not all delivered in this run (to some
65622 alternative host), the message is added to the list of those waiting for this
65623 host, so if it is still undelivered when a subsequent successful delivery is
65624 made to the host, it will be sent down the same SMTP connection.
65625 </para>
65626 </listitem></varlistentry>
65627 <varlistentry>
65628 <term><emphasis role="bold">Message errors</emphasis></term>
65629 <listitem>
65630 <para>
65631 <indexterm role="concept">
65632 <primary>message</primary>
65633 <secondary>error</secondary>
65634 </indexterm>
65635 A message error is associated with a particular message when sent to a
65636 particular host, but not with a particular recipient of the message. The
65637 message errors are:
65638 </para>
65639 <itemizedlist>
65640 <listitem>
65641 <para>
65642 Any error response code to MAIL, DATA, or the <quote>.</quote> that terminates
65643 the data,
65644 </para>
65645 </listitem>
65646 <listitem>
65647 <para>
65648 Timeout after MAIL,
65649 </para>
65650 </listitem>
65651 <listitem>
65652 <para>
65653 Timeout or loss of connection after the <quote>.</quote> that terminates the data. A
65654 timeout after the DATA command itself is treated as a host error, as is loss of
65655 connection at any other time.
65656 </para>
65657 </listitem>
65658 </itemizedlist>
65659 <para>
65660 For a message error, a permanent error response (5<emphasis>xx</emphasis>) causes all addresses
65661 to be failed, and a delivery error report to be returned to the sender. A
65662 temporary error response (4<emphasis>xx</emphasis>), or one of the timeouts, causes all
65663 addresses to be deferred. Retry data is not created for the host, but instead,
65664 a retry record for the combination of host plus message id is created. The
65665 message is not added to the list of those waiting for this host. This ensures
65666 that the failing message will not be sent to this host again until the retry
65667 time arrives. However, other messages that are routed to the host are not
65668 affected, so if it is some property of the message that is causing the error,
65669 it will not stop the delivery of other mail.
65670 </para>
65671 <para>
65672 If the remote host specified support for the SIZE parameter in its response
65673 to EHLO, Exim adds SIZE=<emphasis>nnn</emphasis> to the MAIL command, so an
65674 over-large message will cause a message error because the error arrives as a
65675 response to MAIL.
65676 </para>
65677 </listitem></varlistentry>
65678 <varlistentry>
65679 <term><emphasis role="bold">Recipient errors</emphasis></term>
65680 <listitem>
65681 <para>
65682 <indexterm role="concept">
65683 <primary>recipient</primary>
65684 <secondary>error</secondary>
65685 </indexterm>
65686 A recipient error is associated with a particular recipient of a message. The
65687 recipient errors are:
65688 </para>
65689 <itemizedlist>
65690 <listitem>
65691 <para>
65692 Any error response to RCPT,
65693 </para>
65694 </listitem>
65695 <listitem>
65696 <para>
65697 Timeout after RCPT.
65698 </para>
65699 </listitem>
65700 </itemizedlist>
65701 <para>
65702 For a recipient error, a permanent error response (5<emphasis>xx</emphasis>) causes the
65703 recipient address to be failed, and a bounce message to be returned to the
65704 sender. A temporary error response (4<emphasis>xx</emphasis>) or a timeout causes the failing
65705 address to be deferred, and routing retry data to be created for it. This is
65706 used to delay processing of the address in subsequent queue runs, until its
65707 routing retry time arrives. This applies to all messages, but because it
65708 operates only in queue runs, one attempt will be made to deliver a new message
65709 to the failing address before the delay starts to operate. This ensures that,
65710 if the failure is really related to the message rather than the recipient
65711 (<quote>message too big for this recipient</quote> is a possible example), other messages
65712 have a chance of getting delivered. If a delivery to the address does succeed,
65713 the retry information gets cleared, so all stuck messages get tried again, and
65714 the retry clock is reset.
65715 </para>
65716 <para>
65717 The message is not added to the list of those waiting for this host. Use of the
65718 host for other messages is unaffected, and except in the case of a timeout,
65719 other recipients are processed independently, and may be successfully delivered
65720 in the current SMTP session. After a timeout it is of course impossible to
65721 proceed with the session, so all addresses get deferred. However, those other
65722 than the one that failed do not suffer any subsequent retry delays. Therefore,
65723 if one recipient is causing trouble, the others have a chance of getting
65724 through when a subsequent delivery attempt occurs before the failing
65725 recipient&#x2019;s retry time.
65726 </para>
65727 </listitem></varlistentry>
65728 </variablelist>
65729 <para>
65730 In all cases, if there are other hosts (or IP addresses) available for the
65731 current set of addresses (for example, from multiple MX records), they are
65732 tried in this run for any undelivered addresses, subject of course to their
65733 own retry data. In other words, recipient error retry data does not take effect
65734 until the next delivery attempt.
65735 </para>
65736 <para>
65737 Some hosts have been observed to give temporary error responses to every
65738 MAIL command at certain times (<quote>insufficient space</quote> has been seen). It
65739 would be nice if such circumstances could be recognized, and defer data for the
65740 host itself created, but this is not possible within the current Exim design.
65741 What actually happens is that retry data for every (host, message) combination
65742 is created.
65743 </para>
65744 <para>
65745 The reason that timeouts after MAIL and RCPT are treated specially is that
65746 these can sometimes arise as a result of the remote host&#x2019;s verification
65747 procedures. Exim makes this assumption, and treats them as if a temporary error
65748 response had been received. A timeout after <quote>.</quote> is treated specially because
65749 it is known that some broken implementations fail to recognize the end of the
65750 message if the last character of the last line is a binary zero. Thus, it is
65751 helpful to treat this case as a message error.
65752 </para>
65753 <para>
65754 Timeouts at other times are treated as host errors, assuming a problem with the
65755 host, or the connection to it. If a timeout after MAIL, RCPT,
65756 or <quote>.</quote> is really a connection problem, the assumption is that at the next try
65757 the timeout is likely to occur at some other point in the dialogue, causing it
65758 then to be treated as a host error.
65759 </para>
65760 <para>
65761 There is experimental evidence that some MTAs drop the connection after the
65762 terminating <quote>.</quote> if they do not like the contents of the message for some
65763 reason, in contravention of the RFC, which indicates that a 5<emphasis>xx</emphasis> response
65764 should be given. That is why Exim treats this case as a message rather than a
65765 host error, in order not to delay other messages to the same host.
65766 </para>
65767 </section>
65768 <section id="SECID233">
65769 <title>Incoming SMTP messages over TCP/IP</title>
65770 <para>
65771 <indexterm role="concept">
65772 <primary>SMTP</primary>
65773 <secondary>incoming over TCP/IP</secondary>
65774 </indexterm>
65775 <indexterm role="concept">
65776 <primary>incoming SMTP over TCP/IP</primary>
65777 </indexterm>
65778 <indexterm role="concept">
65779 <primary>inetd</primary>
65780 </indexterm>
65781 <indexterm role="concept">
65782 <primary>daemon</primary>
65783 </indexterm>
65784 Incoming SMTP messages can be accepted in one of two ways: by running a
65785 listening daemon, or by using <emphasis>inetd</emphasis>. In the latter case, the entry in
65786 <filename>/etc/inetd.conf</filename> should be like this:
65787 </para>
65788 <literallayout class="monospaced">
65789 smtp stream tcp nowait exim /opt/exim/bin/exim in.exim -bs
65790 </literallayout>
65791 <para>
65792 Exim distinguishes between this case and the case of a locally running user
65793 agent using the <option>-bs</option> option by checking whether or not the standard input is
65794 a socket. When it is, either the port must be privileged (less than 1024), or
65795 the caller must be root or the Exim user. If any other user passes a socket
65796 with an unprivileged port number, Exim prints a message on the standard error
65797 stream and exits with an error code.
65798 </para>
65799 <para>
65800 By default, Exim does not make a log entry when a remote host connects or
65801 disconnects (either via the daemon or <emphasis>inetd</emphasis>), unless the disconnection is
65802 unexpected. It can be made to write such log entries by setting the
65803 <option>smtp_connection</option> log selector.
65804 </para>
65805 <para>
65806 <indexterm role="concept">
65807 <primary>carriage return</primary>
65808 </indexterm>
65809 <indexterm role="concept">
65810 <primary>linefeed</primary>
65811 </indexterm>
65812 Commands from the remote host are supposed to be terminated by CR followed by
65813 LF. However, there are known to be hosts that do not send CR characters. In
65814 order to be able to interwork with such hosts, Exim treats LF on its own as a
65815 line terminator.
65816 Furthermore, because common code is used for receiving messages from all
65817 sources, a CR on its own is also interpreted as a line terminator. However, the
65818 sequence <quote>CR, dot, CR</quote> does not terminate incoming SMTP data.
65819 </para>
65820 <para>
65821 <indexterm role="concept">
65822 <primary>EHLO</primary>
65823 <secondary>invalid data</secondary>
65824 </indexterm>
65825 <indexterm role="concept">
65826 <primary>HELO</primary>
65827 <secondary>invalid data</secondary>
65828 </indexterm>
65829 One area that sometimes gives rise to problems concerns the EHLO or
65830 HELO commands. Some clients send syntactically invalid versions of these
65831 commands, which Exim rejects by default. (This is nothing to do with verifying
65832 the data that is sent, so <option>helo_verify_hosts</option> is not relevant.) You can tell
65833 Exim not to apply a syntax check by setting <option>helo_accept_junk_hosts</option> to
65834 match the broken hosts that send invalid commands.
65835 </para>
65836 <para>
65837 <indexterm role="concept">
65838 <primary>SIZE option on MAIL command</primary>
65839 </indexterm>
65840 <indexterm role="concept">
65841 <primary>MAIL</primary>
65842 <secondary>SIZE option</secondary>
65843 </indexterm>
65844 The amount of disk space available is checked whenever SIZE is received on
65845 a MAIL command, independently of whether <option>message_size_limit</option> or
65846 <option>check_spool_space</option> is configured, unless <option>smtp_check_spool_space</option> is set
65847 false. A temporary error is given if there is not enough space. If
65848 <option>check_spool_space</option> is set, the check is for that amount of space plus the
65849 value given with SIZE, that is, it checks that the addition of the incoming
65850 message will not reduce the space below the threshold.
65851 </para>
65852 <para>
65853 When a message is successfully received, Exim includes the local message id in
65854 its response to the final <quote>.</quote> that terminates the data. If the remote host
65855 logs this text it can help with tracing what has happened to a message.
65856 </para>
65857 <para>
65858 The Exim daemon can limit the number of simultaneous incoming connections it is
65859 prepared to handle (see the <option>smtp_accept_max</option> option). It can also limit the
65860 number of simultaneous incoming connections from a single remote host (see the
65861 <option>smtp_accept_max_per_host</option> option). Additional connection attempts are
65862 rejected using the SMTP temporary error code 421.
65863 </para>
65864 <para>
65865 The Exim daemon does not rely on the SIGCHLD signal to detect when a
65866 subprocess has finished, as this can get lost at busy times. Instead, it looks
65867 for completed subprocesses every time it wakes up. Provided there are other
65868 things happening (new incoming calls, starts of queue runs), completed
65869 processes will be noticed and tidied away. On very quiet systems you may
65870 sometimes see a <quote>defunct</quote> Exim process hanging about. This is not a problem;
65871 it will be noticed when the daemon next wakes up.
65872 </para>
65873 <para>
65874 When running as a daemon, Exim can reserve some SMTP slots for specific hosts,
65875 and can also be set up to reject SMTP calls from non-reserved hosts at times of
65876 high system load &ndash; for details see the <option>smtp_accept_reserve</option>,
65877 <option>smtp_load_reserve</option>, and <option>smtp_reserve_hosts</option> options. The load check
65878 applies in both the daemon and <emphasis>inetd</emphasis> cases.
65879 </para>
65880 <para>
65881 Exim normally starts a delivery process for each message received, though this
65882 can be varied by means of the <option>-odq</option> command line option and the
65883 <option>queue_only</option>, <option>queue_only_file</option>, and <option>queue_only_load</option> options. The
65884 number of simultaneously running delivery processes started in this way from
65885 SMTP input can be limited by the <option>smtp_accept_queue</option> and
65886 <option>smtp_accept_queue_per_connection</option> options. When either limit is reached,
65887 subsequently received messages are just put on the input queue without starting
65888 a delivery process.
65889 </para>
65890 <para>
65891 The controls that involve counts of incoming SMTP calls (<option>smtp_accept_max</option>,
65892 <option>smtp_accept_queue</option>, <option>smtp_accept_reserve</option>) are not available when Exim is
65893 started up from the <emphasis>inetd</emphasis> daemon, because in that case each connection is
65894 handled by an entirely independent Exim process. Control by load average is,
65895 however, available with <emphasis>inetd</emphasis>.
65896 </para>
65897 <para>
65898 Exim can be configured to verify addresses in incoming SMTP commands as they
65899 are received. See chapter <xref linkend="CHAPACL"/> for details. It can also be configured
65900 to rewrite addresses at this time &ndash; before any syntax checking is done. See
65901 section <xref linkend="SECTrewriteS"/>.
65902 </para>
65903 <para>
65904 Exim can also be configured to limit the rate at which a client host submits
65905 MAIL and RCPT commands in a single SMTP session. See the
65906 <option>smtp_ratelimit_hosts</option> option.
65907 </para>
65908 </section>
65909 <section id="SECID234">
65910 <title>Unrecognized SMTP commands</title>
65911 <para>
65912 <indexterm role="concept">
65913 <primary>SMTP</primary>
65914 <secondary>unrecognized commands</secondary>
65915 </indexterm>
65916 If Exim receives more than <option>smtp_max_unknown_commands</option> unrecognized SMTP
65917 commands during a single SMTP connection, it drops the connection after sending
65918 the error response to the last command. The default value for
65919 <option>smtp_max_unknown_commands</option> is 3. This is a defence against some kinds of
65920 abuse that subvert web servers into making connections to SMTP ports; in these
65921 circumstances, a number of non-SMTP lines are sent first.
65922 </para>
65923 </section>
65924 <section id="SECID235">
65925 <title>Syntax and protocol errors in SMTP commands</title>
65926 <para>
65927 <indexterm role="concept">
65928 <primary>SMTP</primary>
65929 <secondary>syntax errors</secondary>
65930 </indexterm>
65931 <indexterm role="concept">
65932 <primary>SMTP</primary>
65933 <secondary>protocol errors</secondary>
65934 </indexterm>
65935 A syntax error is detected if an SMTP command is recognized, but there is
65936 something syntactically wrong with its data, for example, a malformed email
65937 address in a RCPT command. Protocol errors include invalid command
65938 sequencing such as RCPT before MAIL. If Exim receives more than
65939 <option>smtp_max_synprot_errors</option> such commands during a single SMTP connection, it
65940 drops the connection after sending the error response to the last command. The
65941 default value for <option>smtp_max_synprot_errors</option> is 3. This is a defence against
65942 broken clients that loop sending bad commands (yes, it has been seen).
65943 </para>
65944 </section>
65945 <section id="SECID236">
65946 <title>Use of non-mail SMTP commands</title>
65947 <para>
65948 <indexterm role="concept">
65949 <primary>SMTP</primary>
65950 <secondary>non-mail commands</secondary>
65951 </indexterm>
65952 The <quote>non-mail</quote> SMTP commands are those other than MAIL, RCPT, and
65953 DATA. Exim counts such commands, and drops the connection if there are too
65954 many of them in a single SMTP session. This action catches some
65955 denial-of-service attempts and things like repeated failing AUTHs, or a mad
65956 client looping sending EHLO. The global option <option>smtp_accept_max_nonmail</option>
65957 defines what <quote>too many</quote> means. Its default value is 10.
65958 </para>
65959 <para>
65960 When a new message is expected, one occurrence of RSET is not counted. This
65961 allows a client to send one RSET between messages (this is not necessary,
65962 but some clients do it). Exim also allows one uncounted occurrence of HELO
65963 or EHLO, and one occurrence of STARTTLS between messages. After
65964 starting up a TLS session, another EHLO is expected, and so it too is not
65965 counted.
65966 </para>
65967 <para>
65968 The first occurrence of AUTH in a connection, or immediately following
65969 STARTTLS is also not counted. Otherwise, all commands other than MAIL,
65970 RCPT, DATA, and QUIT are counted.
65971 </para>
65972 <para>
65973 You can control which hosts are subject to the limit set by
65974 <option>smtp_accept_max_nonmail</option> by setting
65975 <option>smtp_accept_max_nonmail_hosts</option>. The default value is <literal>*</literal>, which makes
65976 the limit apply to all hosts. This option means that you can exclude any
65977 specific badly-behaved hosts that you have to live with.
65978 </para>
65979 </section>
65980 <section id="SECID237">
65981 <title>The VRFY and EXPN commands</title>
65982 <para>
65983 When Exim receives a VRFY or EXPN command on a TCP/IP connection, it
65984 runs the ACL specified by <option>acl_smtp_vrfy</option> or <option>acl_smtp_expn</option> (as
65985 appropriate) in order to decide whether the command should be accepted or not.
65986 </para>
65987 <para>
65988 <indexterm role="concept">
65989 <primary>VRFY</primary>
65990 <secondary>processing</secondary>
65991 </indexterm>
65992 When no ACL is defined for VRFY, or if it rejects without
65993 setting an explicit response code, the command is accepted
65994 (with a 252 SMTP response code)
65995 in order to support awkward clients that do a VRFY before every RCPT.
65996 When VRFY is accepted, it runs exactly the same code as when Exim is
65997 called with the <option>-bv</option> option, and returns 250/451/550
65998 SMTP response codes.
65999 </para>
66000 <para>
66001 <indexterm role="concept">
66002 <primary>EXPN</primary>
66003 <secondary>processing</secondary>
66004 </indexterm>
66005 If no ACL for EXPN is defined, the command is rejected.
66006 When EXPN is accepted, a single-level expansion of the address is done.
66007 EXPN is treated as an <quote>address test</quote> (similar to the <option>-bt</option> option) rather
66008 than a verification (the <option>-bv</option> option). If an unqualified local part is given
66009 as the argument to EXPN, it is qualified with <option>qualify_domain</option>. Rejections
66010 of VRFY and EXPN commands are logged on the main and reject logs, and
66011 VRFY verification failures are logged on the main log for consistency with
66012 RCPT failures.
66013 </para>
66014 </section>
66015 <section id="SECTETRN">
66016 <title>The ETRN command</title>
66017 <para>
66018 <indexterm role="concept">
66019 <primary>ETRN</primary>
66020 <secondary>processing</secondary>
66021 </indexterm>
66022 RFC 1985 describes an SMTP command called ETRN that is designed to
66023 overcome the security problems of the TURN command (which has fallen into
66024 disuse). When Exim receives an ETRN command on a TCP/IP connection, it runs
66025 the ACL specified by <option>acl_smtp_etrn</option> in order to decide whether the command
66026 should be accepted or not. If no ACL is defined, the command is rejected.
66027 </para>
66028 <para>
66029 The ETRN command is concerned with <quote>releasing</quote> messages that are awaiting
66030 delivery to certain hosts. As Exim does not organize its message queue by host,
66031 the only form of ETRN that is supported by default is the one where the
66032 text starts with the <quote>#</quote> prefix, in which case the remainder of the text is
66033 specific to the SMTP server. A valid ETRN command causes a run of Exim with
66034 the <option>-R</option> option to happen, with the remainder of the ETRN text as its
66035 argument. For example,
66036 </para>
66037 <literallayout class="monospaced">
66038 ETRN #brigadoon
66039 </literallayout>
66040 <para>
66041 runs the command
66042 </para>
66043 <literallayout class="monospaced">
66044 exim -R brigadoon
66045 </literallayout>
66046 <para>
66047 which causes a delivery attempt on all messages with undelivered addresses
66048 containing the text <quote>brigadoon</quote>. When <option>smtp_etrn_serialize</option> is set (the
66049 default), Exim prevents the simultaneous execution of more than one queue run
66050 for the same argument string as a result of an ETRN command. This stops
66051 a misbehaving client from starting more than one queue runner at once.
66052 </para>
66053 <para>
66054 <indexterm role="concept">
66055 <primary>hints database</primary>
66056 <secondary>ETRN serialization</secondary>
66057 </indexterm>
66058 Exim implements the serialization by means of a hints database in which a
66059 record is written whenever a process is started by ETRN, and deleted when
66060 the process completes. However, Exim does not keep the SMTP session waiting for
66061 the ETRN process to complete. Once ETRN is accepted, the client is sent
66062 a <quote>success</quote> return code. Obviously there is scope for hints records to get
66063 left lying around if there is a system or program crash. To guard against this,
66064 Exim ignores any records that are more than six hours old.
66065 </para>
66066 <para>
66067 <indexterm role="option">
66068 <primary><option>smtp_etrn_command</option></primary>
66069 </indexterm>
66070 For more control over what ETRN does, the <option>smtp_etrn_command</option> option can
66071 used. This specifies a command that is run whenever ETRN is received,
66072 whatever the form of its argument. For
66073 example:
66074 </para>
66075 <literallayout class="monospaced">
66076 smtp_etrn_command = /etc/etrn_command $domain \
66077                     $sender_host_address
66078 </literallayout>
66079 <para>
66080 <indexterm role="variable">
66081 <primary><varname>$domain</varname></primary>
66082 </indexterm>
66083 The string is split up into arguments which are independently expanded. The
66084 expansion variable <varname>$domain</varname> is set to the argument of the ETRN command,
66085 and no syntax checking is done on the contents of this argument. Exim does not
66086 wait for the command to complete, so its status code is not checked. Exim runs
66087 under its own uid and gid when receiving incoming SMTP, so it is not possible
66088 for it to change them before running the command.
66089 </para>
66090 </section>
66091 <section id="SECID238">
66092 <title>Incoming local SMTP</title>
66093 <para>
66094 <indexterm role="concept">
66095 <primary>SMTP</primary>
66096 <secondary>local incoming</secondary>
66097 </indexterm>
66098 Some user agents use SMTP to pass messages to their local MTA using the
66099 standard input and output, as opposed to passing the envelope on the command
66100 line and writing the message to the standard input. This is supported by the
66101 <option>-bs</option> option. This form of SMTP is handled in the same way as incoming
66102 messages over TCP/IP (including the use of ACLs), except that the envelope
66103 sender given in a MAIL command is ignored unless the caller is trusted. In
66104 an ACL you can detect this form of SMTP input by testing for an empty host
66105 identification. It is common to have this as the first line in the ACL that
66106 runs for RCPT commands:
66107 </para>
66108 <literallayout class="monospaced">
66109 accept hosts = :
66110 </literallayout>
66111 <para>
66112 This accepts SMTP messages from local processes without doing any other tests.
66113 </para>
66114 </section>
66115 <section id="SECTbatchSMTP">
66116 <title>Outgoing batched SMTP</title>
66117 <para>
66118 <indexterm role="concept">
66119 <primary>SMTP</primary>
66120 <secondary>batched outgoing</secondary>
66121 </indexterm>
66122 <indexterm role="concept">
66123 <primary>batched SMTP output</primary>
66124 </indexterm>
66125 Both the <command>appendfile</command> and <command>pipe</command> transports can be used for handling
66126 batched SMTP. Each has an option called <option>use_bsmtp</option> which causes messages to
66127 be output in BSMTP format. No SMTP responses are possible for this form of
66128 delivery. All it is doing is using SMTP commands as a way of transmitting the
66129 envelope along with the message.
66130 </para>
66131 <para>
66132 The message is written to the file or pipe preceded by the SMTP commands
66133 MAIL and RCPT, and followed by a line containing a single dot. Lines in
66134 the message that start with a dot have an extra dot added. The SMTP command
66135 HELO is not normally used. If it is required, the <option>message_prefix</option> option
66136 can be used to specify it.
66137 </para>
66138 <para>
66139 Because <command>appendfile</command> and <command>pipe</command> are both local transports, they accept only
66140 one recipient address at a time by default. However, you can arrange for them
66141 to handle several addresses at once by setting the <option>batch_max</option> option. When
66142 this is done for BSMTP, messages may contain multiple RCPT commands. See
66143 chapter <xref linkend="CHAPbatching"/> for more details.
66144 </para>
66145 <para>
66146 <indexterm role="variable">
66147 <primary><varname>$host</varname></primary>
66148 </indexterm>
66149 When one or more addresses are routed to a BSMTP transport by a router that
66150 sets up a host list, the name of the first host on the list is available to the
66151 transport in the variable <varname>$host</varname>. Here is an example of such a transport and
66152 router:
66153 </para>
66154 <literallayout class="monospaced">
66155 begin routers
66156 route_append:
66157   driver = manualroute
66158   transport = smtp_appendfile
66159   route_list = domain.example  batch.host.example
66160
66161 begin transports
66162 smtp_appendfile:
66163   driver = appendfile
66164   directory = /var/bsmtp/$host
66165   batch_max = 1000
66166   use_bsmtp
66167   user = exim
66168 </literallayout>
66169 <para>
66170 This causes messages addressed to <emphasis>domain.example</emphasis> to be written in BSMTP
66171 format to <filename>/var/bsmtp/batch.host.example</filename>, with only a single copy of each
66172 message (unless there are more than 1000 recipients).
66173 </para>
66174 </section>
66175 <section id="SECTincomingbatchedSMTP">
66176 <title>Incoming batched SMTP</title>
66177 <para>
66178 <indexterm role="concept">
66179 <primary>SMTP</primary>
66180 <secondary>batched incoming</secondary>
66181 </indexterm>
66182 <indexterm role="concept">
66183 <primary>batched SMTP input</primary>
66184 </indexterm>
66185 The <option>-bS</option> command line option causes Exim to accept one or more messages by
66186 reading SMTP on the standard input, but to generate no responses. If the caller
66187 is trusted, the senders in the MAIL commands are believed; otherwise the
66188 sender is always the caller of Exim. Unqualified senders and receivers are not
66189 rejected (there seems little point) but instead just get qualified. HELO
66190 and EHLO act as RSET; VRFY, EXPN, ETRN and  HELP, act
66191 as NOOP; QUIT quits.
66192 </para>
66193 <para>
66194 Minimal policy checking is done for BSMTP input. Only the non-SMTP
66195 ACL is run in the same way as for non-SMTP local input.
66196 </para>
66197 <para>
66198 If an error is detected while reading a message, including a missing <quote>.</quote> at
66199 the end, Exim gives up immediately. It writes details of the error to the
66200 standard output in a stylized way that the calling program should be able to
66201 make some use of automatically, for example:
66202 </para>
66203 <literallayout class="monospaced">
66204 554 Unexpected end of file
66205 Transaction started in line 10
66206 Error detected in line 14
66207 </literallayout>
66208 <para>
66209 It writes a more verbose version, for human consumption, to the standard error
66210 file, for example:
66211 </para>
66212 <literallayout class="monospaced">
66213 An error was detected while processing a file of BSMTP input.
66214 The error message was:
66215
66216 501 '&gt;' missing at end of address
66217
66218 The SMTP transaction started in line 10.
66219 The error was detected in line 12.
66220 The SMTP command at fault was:
66221
66222 rcpt to:&lt;malformed@in.com.plete
66223
66224 1 previous message was successfully processed.
66225 The rest of the batch was abandoned.
66226 </literallayout>
66227 <para>
66228 The return code from Exim is zero only if there were no errors. It is 1 if some
66229 messages were accepted before an error was detected, and 2 if no messages were
66230 accepted.
66231 <indexterm role="concept" startref="IIDsmtpproc1" class="endofrange"/>
66232 <indexterm role="concept" startref="IIDsmtpproc2" class="endofrange"/>
66233 </para>
66234 </section>
66235 </chapter>
66236
66237 <chapter id="CHAPemsgcust">
66238 <title>Customizing bounce and warning messages</title>
66239 <titleabbrev>Customizing messages</titleabbrev>
66240 <para>
66241 When a message fails to be delivered, or remains in the queue for more than a
66242 configured amount of time, Exim sends a message to the original sender, or
66243 to an alternative configured address. The text of these messages is built into
66244 the code of Exim, but it is possible to change it, either by adding a single
66245 string, or by replacing each of the paragraphs by text supplied in a file.
66246 </para>
66247 <para>
66248 The <emphasis>From:</emphasis> and <emphasis>To:</emphasis> header lines are automatically generated; you can
66249 cause a <emphasis>Reply-To:</emphasis> line to be added by setting the <option>errors_reply_to</option>
66250 option. Exim also adds the line
66251 </para>
66252 <literallayout class="monospaced">
66253 Auto-Submitted: auto-generated
66254 </literallayout>
66255 <para>
66256 to all warning and bounce messages,
66257 </para>
66258 <section id="SECID239">
66259 <title>Customizing bounce messages</title>
66260 <para>
66261 <indexterm role="concept">
66262 <primary>customizing</primary>
66263 <secondary>bounce message</secondary>
66264 </indexterm>
66265 <indexterm role="concept">
66266 <primary>bounce message</primary>
66267 <secondary>customizing</secondary>
66268 </indexterm>
66269 If <option>bounce_message_text</option> is set, its contents are included in the default
66270 message immediately after <quote>This message was created automatically by mail
66271 delivery software.</quote> The string is not expanded. It is not used if
66272 <option>bounce_message_file</option> is set.
66273 </para>
66274 <para>
66275 When <option>bounce_message_file</option> is set, it must point to a template file for
66276 constructing error messages. The file consists of a series of text items,
66277 separated by lines consisting of exactly four asterisks. If the file cannot be
66278 opened, default text is used and a message is written to the main and panic
66279 logs. If any text item in the file is empty, default text is used for that
66280 item.
66281 </para>
66282 <para>
66283 <indexterm role="variable">
66284 <primary><varname>$bounce_recipient</varname></primary>
66285 </indexterm>
66286 <indexterm role="variable">
66287 <primary><varname>$bounce_return_size_limit</varname></primary>
66288 </indexterm>
66289 Each item of text that is read from the file is expanded, and there are two
66290 expansion variables which can be of use here: <varname>$bounce_recipient</varname> is set to
66291 the recipient of an error message while it is being created, and
66292 <varname>$bounce_return_size_limit</varname> contains the value of the <option>return_size_limit</option>
66293 option, rounded to a whole number.
66294 </para>
66295 <para>
66296 The items must appear in the file in the following order:
66297 </para>
66298 <itemizedlist>
66299 <listitem>
66300 <para>
66301 The first item is included in the headers, and should include at least a
66302 <emphasis>Subject:</emphasis> header. Exim does not check the syntax of these headers.
66303 </para>
66304 </listitem>
66305 <listitem>
66306 <para>
66307 The second item forms the start of the error message. After it, Exim lists the
66308 failing addresses with their error messages.
66309 </para>
66310 </listitem>
66311 <listitem>
66312 <para>
66313 The third item is used to introduce any text from pipe transports that is to be
66314 returned to the sender. It is omitted if there is no such text.
66315 </para>
66316 </listitem>
66317 <listitem>
66318 <para>
66319 The fourth, fifth and sixth items will be ignored and may be empty.
66320 The fields exist for back-compatibility
66321 </para>
66322 </listitem>
66323 </itemizedlist>
66324 <para>
66325 The default state (<option>bounce_message_file</option> unset) is equivalent to the
66326 following file, in which the sixth item is empty. The <emphasis>Subject:</emphasis> and some
66327 other lines have been split in order to fit them on the page:
66328 </para>
66329 <literallayout class="monospaced">
66330 Subject: Mail delivery failed
66331   ${if eq{$sender_address}{$bounce_recipient}
66332   {: returning message to sender}}
66333 ****
66334 This message was created automatically by mail delivery software.
66335
66336 A message ${if eq{$sender_address}{$bounce_recipient}
66337   {that you sent }{sent by
66338
66339 &lt;$sender_address&gt;
66340
66341 }}could not be delivered to all of its recipients.
66342 This is a permanent error. The following address(es) failed:
66343 ****
66344 The following text was generated during the delivery attempt(s):
66345 ****
66346 ------ This is a copy of the message, including all the headers.
66347   ------
66348 ****
66349 ------ The body of the message is $message_size characters long;
66350   only the first
66351 ------ $bounce_return_size_limit or so are included here.
66352 ****
66353 </literallayout>
66354 </section>
66355 <section id="SECTcustwarn">
66356 <title>Customizing warning messages</title>
66357 <para>
66358 <indexterm role="concept">
66359 <primary>customizing</primary>
66360 <secondary>warning message</secondary>
66361 </indexterm>
66362 <indexterm role="concept">
66363 <primary>warning of delay</primary>
66364 <secondary>customizing the message</secondary>
66365 </indexterm>
66366 The option <option>warn_message_file</option> can be pointed at a template file for use when
66367 warnings about message delays are created. In this case there are only three
66368 text sections:
66369 </para>
66370 <itemizedlist>
66371 <listitem>
66372 <para>
66373 The first item is included in the headers, and should include at least a
66374 <emphasis>Subject:</emphasis> header. Exim does not check the syntax of these headers.
66375 </para>
66376 </listitem>
66377 <listitem>
66378 <para>
66379 The second item forms the start of the warning message. After it, Exim lists
66380 the delayed addresses.
66381 </para>
66382 </listitem>
66383 <listitem>
66384 <para>
66385 The third item then ends the message.
66386 </para>
66387 </listitem>
66388 </itemizedlist>
66389 <para>
66390 The default state is equivalent to the following file, except that some lines
66391 have been split here, in order to fit them on the page:
66392 </para>
66393 <literallayout class="monospaced">
66394 Subject: Warning: message $message_exim_id delayed
66395   $warn_message_delay
66396 ****
66397 This message was created automatically by mail delivery software.
66398
66399 A message ${if eq{$sender_address}{$warn_message_recipients}
66400 {that you sent }{sent by
66401
66402 &lt;$sender_address&gt;
66403
66404 }}has not been delivered to all of its recipients after
66405 more than $warn_message_delay in the queue on $primary_hostname.
66406
66407 The message identifier is:     $message_exim_id
66408 The subject of the message is: $h_subject
66409 The date of the message is:    $h_date
66410
66411 The following address(es) have not yet been delivered:
66412 ****
66413 No action is required on your part. Delivery attempts will
66414 continue for some time, and this warning may be repeated at
66415 intervals if the message remains undelivered. Eventually the
66416 mail delivery software will give up, and when that happens,
66417 the message will be returned to you.
66418 </literallayout>
66419 <para>
66420 <indexterm role="variable">
66421 <primary><varname>$warn_message_delay</varname></primary>
66422 </indexterm>
66423 <indexterm role="variable">
66424 <primary><varname>$warn_message_recipients</varname></primary>
66425 </indexterm>
66426 However, in the default state the subject and date lines are omitted if no
66427 appropriate headers exist. During the expansion of this file,
66428 <varname>$warn_message_delay</varname> is set to the delay time in one of the forms <quote>&lt;<emphasis>n</emphasis>&gt;
66429 minutes</quote> or <quote>&lt;<emphasis>n</emphasis>&gt; hours</quote>, and <varname>$warn_message_recipients</varname> contains a list
66430 of recipients for the warning message. There may be more than one if there are
66431 multiple addresses with different <option>errors_to</option> settings on the routers that
66432 handled them.
66433 </para>
66434 </section>
66435 </chapter>
66436
66437 <chapter id="CHAPcomconreq">
66438 <title>Some common configuration settings</title>
66439 <para>
66440 This chapter discusses some configuration settings that seem to be fairly
66441 common. More examples and discussion can be found in the Exim book.
66442 </para>
66443 <section id="SECID240">
66444 <title>Sending mail to a smart host</title>
66445 <para>
66446 <indexterm role="concept">
66447 <primary>smart host</primary>
66448 <secondary>example router</secondary>
66449 </indexterm>
66450 If you want to send all mail for non-local domains to a <quote>smart host</quote>, you
66451 should replace the default <command>dnslookup</command> router with a router which does the
66452 routing explicitly:
66453 </para>
66454 <literallayout class="monospaced">
66455 send_to_smart_host:
66456   driver = manualroute
66457   route_list = !+local_domains smart.host.name
66458   transport = remote_smtp
66459 </literallayout>
66460 <para>
66461 You can use the smart host&#x2019;s IP address instead of the name if you wish.
66462 If you are using Exim only to submit messages to a smart host, and not for
66463 receiving incoming messages, you can arrange for it to do the submission
66464 synchronously by setting the <option>mua_wrapper</option> option (see chapter
66465 <xref linkend="CHAPnonqueueing"/>).
66466 </para>
66467 </section>
66468 <section id="SECTmailinglists">
66469 <title>Using Exim to handle mailing lists</title>
66470 <para>
66471 <indexterm role="concept">
66472 <primary>mailing lists</primary>
66473 </indexterm>
66474 Exim can be used to run simple mailing lists, but for large and/or complicated
66475 requirements, the use of additional specialized mailing list software such as
66476 Majordomo or Mailman is recommended.
66477 </para>
66478 <para>
66479 The <command>redirect</command> router can be used to handle mailing lists where each list
66480 is maintained in a separate file, which can therefore be managed by an
66481 independent manager. The <option>domains</option> router option can be used to run these
66482 lists in a separate domain from normal mail. For example:
66483 </para>
66484 <literallayout class="monospaced">
66485 lists:
66486   driver = redirect
66487   domains = lists.example
66488   file = /usr/lists/$local_part
66489   forbid_pipe
66490   forbid_file
66491   errors_to = $local_part-request@lists.example
66492   no_more
66493 </literallayout>
66494 <para>
66495 This router is skipped for domains other than <emphasis>lists.example</emphasis>. For addresses
66496 in that domain, it looks for a file that matches the local part. If there is no
66497 such file, the router declines, but because <option>no_more</option> is set, no subsequent
66498 routers are tried, and so the whole delivery fails.
66499 </para>
66500 <para>
66501 The <option>forbid_pipe</option> and <option>forbid_file</option> options prevent a local part from being
66502 expanded into a filename or a pipe delivery, which is usually inappropriate in
66503 a mailing list.
66504 </para>
66505 <para>
66506 <indexterm role="option">
66507 <primary><option>errors_to</option></primary>
66508 </indexterm>
66509 The <option>errors_to</option> option specifies that any delivery errors caused by addresses
66510 taken from a mailing list are to be sent to the given address rather than the
66511 original sender of the message. However, before acting on this, Exim verifies
66512 the error address, and ignores it if verification fails.
66513 </para>
66514 <para>
66515 For example, using the configuration above, mail sent to
66516 <emphasis>dicts@lists.example</emphasis> is passed on to those addresses contained in
66517 <filename>/usr/lists/dicts</filename>, with error reports directed to
66518 <emphasis>dicts-request@lists.example</emphasis>, provided that this address can be verified.
66519 There could be a file called <filename>/usr/lists/dicts-request</filename> containing
66520 the address(es) of this particular list&#x2019;s manager(s), but other approaches,
66521 such as setting up an earlier router (possibly using the <option>local_part_prefix</option>
66522 or <option>local_part_suffix</option> options) to handle addresses of the form
66523 <option>owner-</option><emphasis>xxx</emphasis> or <option>xxx-</option><emphasis>request</emphasis>, are also possible.
66524 </para>
66525 </section>
66526 <section id="SECID241">
66527 <title>Syntax errors in mailing lists</title>
66528 <para>
66529 <indexterm role="concept">
66530 <primary>mailing lists</primary>
66531 <secondary>syntax errors in</secondary>
66532 </indexterm>
66533 If an entry in redirection data contains a syntax error, Exim normally defers
66534 delivery of the original address. That means that a syntax error in a mailing
66535 list holds up all deliveries to the list. This may not be appropriate when a
66536 list is being maintained automatically from data supplied by users, and the
66537 addresses are not rigorously checked.
66538 </para>
66539 <para>
66540 If the <option>skip_syntax_errors</option> option is set, the <command>redirect</command> router just skips
66541 entries that fail to parse, noting the incident in the log. If in addition
66542 <option>syntax_errors_to</option> is set to a verifiable address, a message is sent to it
66543 whenever a broken address is skipped. It is usually appropriate to set
66544 <option>syntax_errors_to</option> to the same address as <option>errors_to</option>.
66545 </para>
66546 </section>
66547 <section id="SECID242">
66548 <title>Re-expansion of mailing lists</title>
66549 <para>
66550 <indexterm role="concept">
66551 <primary>mailing lists</primary>
66552 <secondary>re-expansion of</secondary>
66553 </indexterm>
66554 Exim remembers every individual address to which a message has been delivered,
66555 in order to avoid duplication, but it normally stores only the original
66556 recipient addresses with a message. If all the deliveries to a mailing list
66557 cannot be done at the first attempt, the mailing list is re-expanded when the
66558 delivery is next tried. This means that alterations to the list are taken into
66559 account at each delivery attempt, so addresses that have been added to
66560 the list since the message arrived will therefore receive a copy of the
66561 message, even though it pre-dates their subscription.
66562 </para>
66563 <para>
66564 If this behaviour is felt to be undesirable, the <option>one_time</option> option can be set
66565 on the <command>redirect</command> router. If this is done, any addresses generated by the
66566 router that fail to deliver at the first attempt are added to the message as
66567 <quote>top level</quote> addresses, and the parent address that generated them is marked
66568 <quote>delivered</quote>. Thus, expansion of the mailing list does not happen again at the
66569 subsequent delivery attempts. The disadvantage of this is that if any of the
66570 failing addresses are incorrect, correcting them in the file has no effect on
66571 pre-existing messages.
66572 </para>
66573 <para>
66574 The original top-level address is remembered with each of the generated
66575 addresses, and is output in any log messages. However, any intermediate parent
66576 addresses are not recorded. This makes a difference to the log only if the
66577 <option>all_parents</option> selector is set, but for mailing lists there is normally only
66578 one level of expansion anyway.
66579 </para>
66580 </section>
66581 <section id="SECID243">
66582 <title>Closed mailing lists</title>
66583 <para>
66584 <indexterm role="concept">
66585 <primary>mailing lists</primary>
66586 <secondary>closed</secondary>
66587 </indexterm>
66588 The examples so far have assumed open mailing lists, to which anybody may
66589 send mail. It is also possible to set up closed lists, where mail is accepted
66590 from specified senders only. This is done by making use of the generic
66591 <option>senders</option> option to restrict the router that handles the list.
66592 </para>
66593 <para>
66594 The following example uses the same file as a list of recipients and as a list
66595 of permitted senders. It requires three routers:
66596 </para>
66597 <literallayout class="monospaced">
66598 lists_request:
66599   driver = redirect
66600   domains = lists.example
66601   local_part_suffix = -request
66602   file = /usr/lists/$local_part$local_part_suffix
66603   no_more
66604
66605 lists_post:
66606   driver = redirect
66607   domains = lists.example
66608   senders = ${if exists {/usr/lists/$local_part}\
66609              {lsearch;/usr/lists/$local_part}{*}}
66610   file = /usr/lists/$local_part
66611   forbid_pipe
66612   forbid_file
66613   errors_to = $local_part-request@lists.example
66614   no_more
66615
66616 lists_closed:
66617   driver = redirect
66618   domains = lists.example
66619   allow_fail
66620   data = :fail: $local_part@lists.example is a closed mailing list
66621 </literallayout>
66622 <para>
66623 All three routers have the same <option>domains</option> setting, so for any other domains,
66624 they are all skipped. The first router runs only if the local part ends in
66625 <option>-request</option>. It handles messages to the list manager(s) by means of an open
66626 mailing list.
66627 </para>
66628 <para>
66629 The second router runs only if the <option>senders</option> precondition is satisfied. It
66630 checks for the existence of a list that corresponds to the local part, and then
66631 checks that the sender is on the list by means of a linear search. It is
66632 necessary to check for the existence of the file before trying to search it,
66633 because otherwise Exim thinks there is a configuration error. If the file does
66634 not exist, the expansion of <option>senders</option> is *, which matches all senders. This
66635 means that the router runs, but because there is no list, declines, and
66636 <option>no_more</option> ensures that no further routers are run. The address fails with an
66637 <quote>unrouteable address</quote> error.
66638 </para>
66639 <para>
66640 The third router runs only if the second router is skipped, which happens when
66641 a mailing list exists, but the sender is not on it. This router forcibly fails
66642 the address, giving a suitable error message.
66643 </para>
66644 </section>
66645 <section id="SECTverp">
66646 <title>Variable Envelope Return Paths (VERP)</title>
66647 <para>
66648 <indexterm role="concept">
66649 <primary>VERP</primary>
66650 </indexterm>
66651 <indexterm role="concept">
66652 <primary>Variable Envelope Return Paths</primary>
66653 </indexterm>
66654 <indexterm role="concept">
66655 <primary>envelope from</primary>
66656 </indexterm>
66657 <indexterm role="concept">
66658 <primary>envelope sender</primary>
66659 </indexterm>
66660 Variable Envelope Return Paths &ndash; see <emphasis role="bold"><ulink url="https://cr.yp.to/proto/verp.txt">https://cr.yp.to/proto/verp.txt</ulink></emphasis> &ndash;
66661 are a way of helping mailing list administrators discover which subscription
66662 address is the cause of a particular delivery failure. The idea is to encode
66663 the original recipient address in the outgoing envelope sender address, so that
66664 if the message is forwarded by another host and then subsequently bounces, the
66665 original recipient can be extracted from the recipient address of the bounce.
66666 </para>
66667 <para>
66668 <indexterm role="option">
66669 <primary><option>errors_to</option></primary>
66670 </indexterm>
66671 <indexterm role="option">
66672 <primary><option>return_path</option></primary>
66673 </indexterm>
66674 Envelope sender addresses can be modified by Exim using two different
66675 facilities: the <option>errors_to</option> option on a router (as shown in previous mailing
66676 list examples), or the <option>return_path</option> option on a transport. The second of
66677 these is effective only if the message is successfully delivered to another
66678 host; it is not used for errors detected on the local host (see the description
66679 of <option>return_path</option> in chapter <xref linkend="CHAPtransportgeneric"/>). Here is an example
66680 of the use of <option>return_path</option> to implement VERP on an <command>smtp</command> transport:
66681 </para>
66682 <literallayout class="monospaced">
66683 verp_smtp:
66684   driver = smtp
66685   max_rcpt = 1
66686   return_path = \
66687     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
66688       {$1-request+$local_part=$domain@your.dom.example}fail}
66689 </literallayout>
66690 <para>
66691 This has the effect of rewriting the return path (envelope sender) on outgoing
66692 SMTP messages, if the local part of the original return path ends in
66693 <quote>-request</quote>, and the domain is <emphasis>your.dom.example</emphasis>. The rewriting inserts the
66694 local part and domain of the recipient into the return path. Suppose, for
66695 example, that a message whose return path has been set to
66696 <emphasis>somelist-request@your.dom.example</emphasis> is sent to
66697 <emphasis>subscriber@other.dom.example</emphasis>. In the transport, the return path is
66698 rewritten as
66699 </para>
66700 <literallayout class="monospaced">
66701 somelist-request+subscriber=other.dom.example@your.dom.example
66702 </literallayout>
66703 <para>
66704 <indexterm role="variable">
66705 <primary><varname>$local_part</varname></primary>
66706 </indexterm>
66707 For this to work, you must tell Exim to send multiple copies of messages that
66708 have more than one recipient, so that each copy has just one recipient. This is
66709 achieved by setting <option>max_rcpt</option> to 1. Without this, a single copy of a message
66710 might be sent to several different recipients in the same domain, in which case
66711 <varname>$local_part</varname> is not available in the transport, because it is not unique.
66712 </para>
66713 <para>
66714 Unless your host is doing nothing but mailing list deliveries, you should
66715 probably use a separate transport for the VERP deliveries, so as not to use
66716 extra resources in making one-per-recipient copies for other deliveries. This
66717 can easily be done by expanding the <option>transport</option> option in the router:
66718 </para>
66719 <literallayout class="monospaced">
66720 dnslookup:
66721   driver = dnslookup
66722   domains = ! +local_domains
66723   transport = \
66724     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
66725       {verp_smtp}{remote_smtp}}
66726   no_more
66727 </literallayout>
66728 <para>
66729 If you want to change the return path using <option>errors_to</option> in a router instead
66730 of using <option>return_path</option> in the transport, you need to set <option>errors_to</option> on all
66731 routers that handle mailing list addresses. This will ensure that all delivery
66732 errors, including those detected on the local host, are sent to the VERP
66733 address.
66734 </para>
66735 <para>
66736 On a host that does no local deliveries and has no manual routing, only the
66737 <command>dnslookup</command> router needs to be changed. A special transport is not needed for
66738 SMTP deliveries. Every mailing list recipient has its own return path value,
66739 and so Exim must hand them to the transport one at a time. Here is an example
66740 of a <command>dnslookup</command> router that implements VERP:
66741 </para>
66742 <literallayout class="monospaced">
66743 verp_dnslookup:
66744   driver = dnslookup
66745   domains = ! +local_domains
66746   transport = remote_smtp
66747   errors_to = \
66748     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}}
66749      {$1-request+$local_part=$domain@your.dom.example}fail}
66750   no_more
66751 </literallayout>
66752 <para>
66753 Before you start sending out messages with VERPed return paths, you must also
66754 configure Exim to accept the bounce messages that come back to those paths.
66755 Typically this is done by setting a <option>local_part_suffix</option> option for a
66756 router, and using this to route the messages to wherever you want to handle
66757 them.
66758 </para>
66759 <para>
66760 The overhead incurred in using VERP depends very much on the size of the
66761 message, the number of recipient addresses that resolve to the same remote
66762 host, and the speed of the connection over which the message is being sent. If
66763 a lot of addresses resolve to the same host and the connection is slow, sending
66764 a separate copy of the message for each address may take substantially longer
66765 than sending a single copy with many recipients (for which VERP cannot be
66766 used).
66767 </para>
66768 </section>
66769 <section id="SECTvirtualdomains">
66770 <title>Virtual domains</title>
66771 <para>
66772 <indexterm role="concept">
66773 <primary>virtual domains</primary>
66774 </indexterm>
66775 <indexterm role="concept">
66776 <primary>domain</primary>
66777 <secondary>virtual</secondary>
66778 </indexterm>
66779 The phrase <emphasis>virtual domain</emphasis> is unfortunately used with two rather different
66780 meanings:
66781 </para>
66782 <itemizedlist>
66783 <listitem>
66784 <para>
66785 A domain for which there are no real mailboxes; all valid local parts are
66786 aliases for other email addresses. Common examples are organizational
66787 top-level domains and <quote>vanity</quote> domains.
66788 </para>
66789 </listitem>
66790 <listitem>
66791 <para>
66792 One of a number of independent domains that are all handled by the same host,
66793 with mailboxes on that host, but where the mailbox owners do not necessarily
66794 have login accounts on that host.
66795 </para>
66796 </listitem>
66797 </itemizedlist>
66798 <para>
66799 The first usage is probably more common, and does seem more <quote>virtual</quote> than
66800 the second. This kind of domain can be handled in Exim with a straightforward
66801 aliasing router. One approach is to create a separate alias file for each
66802 virtual domain. Exim can test for the existence of the alias file to determine
66803 whether the domain exists. The <command>dsearch</command> lookup type is useful here, leading
66804 to a router of this form:
66805 </para>
66806 <literallayout class="monospaced">
66807 virtual:
66808   driver = redirect
66809   domains = dsearch;/etc/mail/virtual
66810   data = ${lookup{$local_part}lsearch{/etc/mail/virtual/$domain}}
66811   no_more
66812 </literallayout>
66813 <para>
66814 The <option>domains</option> option specifies that the router is to be skipped, unless there
66815 is a file in the <filename>/etc/mail/virtual</filename> directory whose name is the same as the
66816 domain that is being processed. When the router runs, it looks up the local
66817 part in the file to find a new address (or list of addresses). The <option>no_more</option>
66818 setting ensures that if the lookup fails (leading to <option>data</option> being an empty
66819 string), Exim gives up on the address without trying any subsequent routers.
66820 </para>
66821 <para>
66822 This one router can handle all the virtual domains because the alias filenames
66823 follow a fixed pattern. Permissions can be arranged so that appropriate people
66824 can edit the different alias files. A successful aliasing operation results in
66825 a new envelope recipient address, which is then routed from scratch.
66826 </para>
66827 <para>
66828 The other kind of <quote>virtual</quote> domain can also be handled in a straightforward
66829 way. One approach is to create a file for each domain containing a list of
66830 valid local parts, and use it in a router like this:
66831 </para>
66832 <literallayout class="monospaced">
66833 my_domains:
66834   driver = accept
66835   domains = dsearch;/etc/mail/domains
66836   local_parts = lsearch;/etc/mail/domains/$domain
66837   transport = my_mailboxes
66838 </literallayout>
66839 <para>
66840 The address is accepted if there is a file for the domain, and the local part
66841 can be found in the file. The <option>domains</option> option is used to check for the
66842 file&#x2019;s existence because <option>domains</option> is tested before the <option>local_parts</option>
66843 option (see section <xref linkend="SECTrouprecon"/>). You cannot use <option>require_files</option>,
66844 because that option is tested after <option>local_parts</option>. The transport is as
66845 follows:
66846 </para>
66847 <literallayout class="monospaced">
66848 my_mailboxes:
66849   driver = appendfile
66850   file = /var/mail/$domain/$local_part
66851   user = mail
66852 </literallayout>
66853 <para>
66854 This uses a directory of mailboxes for each domain. The <option>user</option> setting is
66855 required, to specify which uid is to be used for writing to the mailboxes.
66856 </para>
66857 <para>
66858 The configuration shown here is just one example of how you might support this
66859 requirement. There are many other ways this kind of configuration can be set
66860 up, for example, by using a database instead of separate files to hold all the
66861 information about the domains.
66862 </para>
66863 </section>
66864 <section id="SECTmulbox">
66865 <title>Multiple user mailboxes</title>
66866 <para>
66867 <indexterm role="concept">
66868 <primary>multiple mailboxes</primary>
66869 </indexterm>
66870 <indexterm role="concept">
66871 <primary>mailbox</primary>
66872 <secondary>multiple</secondary>
66873 </indexterm>
66874 <indexterm role="concept">
66875 <primary>local part</primary>
66876 <secondary>prefix</secondary>
66877 </indexterm>
66878 <indexterm role="concept">
66879 <primary>local part</primary>
66880 <secondary>suffix</secondary>
66881 </indexterm>
66882 Heavy email users often want to operate with multiple mailboxes, into which
66883 incoming mail is automatically sorted. A popular way of handling this is to
66884 allow users to use multiple sender addresses, so that replies can easily be
66885 identified. Users are permitted to add prefixes or suffixes to their local
66886 parts for this purpose. The wildcard facility of the generic router options
66887 <option>local_part_prefix</option> and <option>local_part_suffix</option> can be used for this. For
66888 example, consider this router:
66889 </para>
66890 <literallayout class="monospaced">
66891 userforward:
66892   driver = redirect
66893   check_local_user
66894   file = $home/.forward
66895   local_part_suffix = -*
66896   local_part_suffix_optional
66897   allow_filter
66898 </literallayout>
66899 <para>
66900 <indexterm role="variable">
66901 <primary><varname>$local_part_suffix</varname></primary>
66902 </indexterm>
66903 It runs a user&#x2019;s <filename>.forward</filename> file for all local parts of the form
66904 <emphasis>username-*</emphasis>. Within the filter file the user can distinguish different
66905 cases by testing the variable <varname>$local_part_suffix</varname>. For example:
66906 </para>
66907 <literallayout class="monospaced">
66908 if $local_part_suffix contains -special then
66909 save /home/$local_part/Mail/special
66910 endif
66911 </literallayout>
66912 <para>
66913 If the filter file does not exist, or does not deal with such addresses, they
66914 fall through to subsequent routers, and, assuming no subsequent use of the
66915 <option>local_part_suffix</option> option is made, they presumably fail. Thus, users have
66916 control over which suffixes are valid.
66917 </para>
66918 <para>
66919 Alternatively, a suffix can be used to trigger the use of a different
66920 <filename>.forward</filename> file &ndash; which is the way a similar facility is implemented in
66921 another MTA:
66922 </para>
66923 <literallayout class="monospaced">
66924 userforward:
66925   driver = redirect
66926   check_local_user
66927   file = $home/.forward$local_part_suffix
66928   local_part_suffix = -*
66929   local_part_suffix_optional
66930   allow_filter
66931 </literallayout>
66932 <para>
66933 If there is no suffix, <filename>.forward</filename> is used; if the suffix is <emphasis>-special</emphasis>, for
66934 example, <filename>.forward-special</filename> is used. Once again, if the appropriate file
66935 does not exist, or does not deal with the address, it is passed on to
66936 subsequent routers, which could, if required, look for an unqualified
66937 <filename>.forward</filename> file to use as a default.
66938 </para>
66939 </section>
66940 <section id="SECID244">
66941 <title>Simplified vacation processing</title>
66942 <para>
66943 <indexterm role="concept">
66944 <primary>vacation processing</primary>
66945 </indexterm>
66946 The traditional way of running the <emphasis>vacation</emphasis> program is for a user to set up
66947 a pipe command in a <filename>.forward</filename> file
66948 (see section <xref linkend="SECTspecitredli"/> for syntax details).
66949 This is prone to error by inexperienced users. There are two features of Exim
66950 that can be used to make this process simpler for users:
66951 </para>
66952 <itemizedlist>
66953 <listitem>
66954 <para>
66955 A local part prefix such as <quote>vacation-</quote> can be specified on a router which
66956 can cause the message to be delivered directly to the <emphasis>vacation</emphasis> program, or
66957 alternatively can use Exim&#x2019;s <command>autoreply</command> transport. The contents of a user&#x2019;s
66958 <filename>.forward</filename> file are then much simpler. For example:
66959 </para>
66960 <literallayout class="monospaced">
66961 spqr, vacation-spqr
66962 </literallayout>
66963 </listitem>
66964 <listitem>
66965 <para>
66966 The <option>require_files</option> generic router option can be used to trigger a
66967 vacation delivery by checking for the existence of a certain file in the
66968 user&#x2019;s home directory. The <option>unseen</option> generic option should also be used, to
66969 ensure that the original delivery also proceeds. In this case, all the user has
66970 to do is to create a file called, say, <filename>.vacation</filename>, containing a vacation
66971 message.
66972 </para>
66973 </listitem>
66974 </itemizedlist>
66975 <para>
66976 Another advantage of both these methods is that they both work even when the
66977 use of arbitrary pipes by users is locked out.
66978 </para>
66979 </section>
66980 <section id="SECID245">
66981 <title>Taking copies of mail</title>
66982 <para>
66983 <indexterm role="concept">
66984 <primary>message</primary>
66985 <secondary>copying every</secondary>
66986 </indexterm>
66987 Some installations have policies that require archive copies of all messages to
66988 be made. A single copy of each message can easily be taken by an appropriate
66989 command in a system filter, which could, for example, use a different file for
66990 each day&#x2019;s messages.
66991 </para>
66992 <para>
66993 There is also a shadow transport mechanism that can be used to take copies of
66994 messages that are successfully delivered by local transports, one copy per
66995 delivery. This could be used, <emphasis>inter alia</emphasis>, to implement automatic
66996 notification of delivery by sites that insist on doing such things.
66997 </para>
66998 </section>
66999 <section id="SECID246">
67000 <title>Intermittently connected hosts</title>
67001 <para>
67002 <indexterm role="concept">
67003 <primary>intermittently connected hosts</primary>
67004 </indexterm>
67005 It has become quite common (because it is cheaper) for hosts to connect to the
67006 Internet periodically rather than remain connected all the time. The normal
67007 arrangement is that mail for such hosts accumulates on a system that is
67008 permanently connected.
67009 </para>
67010 <para>
67011 Exim was designed for use on permanently connected hosts, and so it is not
67012 particularly well-suited to use in an intermittently connected environment.
67013 Nevertheless there are some features that can be used.
67014 </para>
67015 </section>
67016 <section id="SECID247">
67017 <title>Exim on the upstream server host</title>
67018 <para>
67019 It is tempting to arrange for incoming mail for the intermittently connected
67020 host to remain in Exim&#x2019;s queue until the client connects. However, this
67021 approach does not scale very well. Two different kinds of waiting message are
67022 being mixed up in the same queue &ndash; those that cannot be delivered because of
67023 some temporary problem, and those that are waiting for their destination host
67024 to connect. This makes it hard to manage the queue, as well as wasting
67025 resources, because each queue runner scans the entire queue.
67026 </para>
67027 <para>
67028 A better approach is to separate off those messages that are waiting for an
67029 intermittently connected host. This can be done by delivering these messages
67030 into local files in batch SMTP, <quote>mailstore</quote>, or other envelope-preserving
67031 format, from where they are transmitted by other software when their
67032 destination connects. This makes it easy to collect all the mail for one host
67033 in a single directory, and to apply local timeout rules on a per-message basis
67034 if required.
67035 </para>
67036 <para>
67037 On a very small scale, leaving the mail on Exim&#x2019;s queue can be made to work. If
67038 you are doing this, you should configure Exim with a long retry period for the
67039 intermittent host. For example:
67040 </para>
67041 <literallayout class="monospaced">
67042 cheshire.wonderland.fict.example    *   F,5d,24h
67043 </literallayout>
67044 <para>
67045 This stops a lot of failed delivery attempts from occurring, but Exim remembers
67046 which messages it has queued up for that host. Once the intermittent host comes
67047 online, forcing delivery of one message (either by using the <option>-M</option> or <option>-R</option>
67048 options, or by using the ETRN SMTP command (see section <xref linkend="SECTETRN"/>)
67049 causes all the queued up messages to be delivered, often down a single SMTP
67050 connection. While the host remains connected, any new messages get delivered
67051 immediately.
67052 </para>
67053 <para>
67054 If the connecting hosts do not have fixed IP addresses, that is, if a host is
67055 issued with a different IP address each time it connects, Exim&#x2019;s retry
67056 mechanisms on the holding host get confused, because the IP address is normally
67057 used as part of the key string for holding retry information. This can be
67058 avoided by unsetting <option>retry_include_ip_address</option> on the <command>smtp</command> transport.
67059 Since this has disadvantages for permanently connected hosts, it is best to
67060 arrange a separate transport for the intermittently connected ones.
67061 </para>
67062 </section>
67063 <section id="SECID248">
67064 <title>Exim on the intermittently connected client host</title>
67065 <para>
67066 The value of <option>smtp_accept_queue_per_connection</option> should probably be
67067 increased, or even set to zero (that is, disabled) on the intermittently
67068 connected host, so that all incoming messages down a single connection get
67069 delivered immediately.
67070 </para>
67071 <para>
67072 <indexterm role="concept">
67073 <primary>SMTP</primary>
67074 <secondary>passed connection</secondary>
67075 </indexterm>
67076 <indexterm role="concept">
67077 <primary>SMTP</primary>
67078 <secondary>multiple deliveries</secondary>
67079 </indexterm>
67080 <indexterm role="concept">
67081 <primary>multiple SMTP deliveries</primary>
67082 </indexterm>
67083 Mail waiting to be sent from an intermittently connected host will probably
67084 not have been routed, because without a connection DNS lookups are not
67085 possible. This means that if a normal queue run is done at connection time,
67086 each message is likely to be sent in a separate SMTP session. This can be
67087 avoided by starting the queue run with a command line option beginning with
67088 <option>-qq</option> instead of <option>-q</option>. In this case, the queue is scanned twice. In the
67089 first pass, routing is done but no deliveries take place. The second pass is a
67090 normal queue run; since all the messages have been previously routed, those
67091 destined for the same host are likely to get sent as multiple deliveries in a
67092 single SMTP connection.
67093 </para>
67094 </section>
67095 </chapter>
67096
67097 <chapter id="CHAPnonqueueing">
67098 <title>Using Exim as a non-queueing client</title>
67099 <titleabbrev>Exim as a non-queueing client</titleabbrev>
67100 <para>
67101 <indexterm role="concept">
67102 <primary>client, non-queueing</primary>
67103 </indexterm>
67104 <indexterm role="concept">
67105 <primary>smart host</primary>
67106 <secondary>suppressing queueing</secondary>
67107 </indexterm>
67108 On a personal computer, it is a common requirement for all
67109 email to be sent to a <quote>smart host</quote>. There are plenty of MUAs that can be
67110 configured to operate that way, for all the popular operating systems.
67111 However, there are some MUAs for Unix-like systems that cannot be so
67112 configured: they submit messages using the command line interface of
67113 <filename>/usr/sbin/sendmail</filename>. Furthermore, utility programs such as <emphasis>cron</emphasis> submit
67114 messages this way.
67115 </para>
67116 <para>
67117 If the personal computer runs continuously, there is no problem, because it can
67118 run a conventional MTA that handles delivery to the smart host, and deal with
67119 any delays via its queueing mechanism. However, if the computer does not run
67120 continuously or runs different operating systems at different times, queueing
67121 email is not desirable.
67122 </para>
67123 <para>
67124 There is therefore a requirement for something that can provide the
67125 <filename>/usr/sbin/sendmail</filename> interface but deliver messages to a smart host without
67126 any queueing or retrying facilities. Furthermore, the delivery to the smart
67127 host should be synchronous, so that if it fails, the sending MUA is immediately
67128 informed. In other words, we want something that extends an MUA that submits
67129 to a local MTA via the command line so that it behaves like one that submits
67130 to a remote smart host using TCP/SMTP.
67131 </para>
67132 <para>
67133 There are a number of applications (for example, there is one called <emphasis>ssmtp</emphasis>)
67134 that do this job. However, people have found them to be lacking in various
67135 ways. For instance, you might want to allow aliasing and forwarding to be done
67136 before sending a message to the smart host.
67137 </para>
67138 <para>
67139 Exim already had the necessary infrastructure for doing this job. Just a few
67140 tweaks were needed to make it behave as required, though it is somewhat of an
67141 overkill to use a fully-featured MTA for this purpose.
67142 </para>
67143 <para>
67144 <indexterm role="option">
67145 <primary><option>mua_wrapper</option></primary>
67146 </indexterm>
67147 There is a Boolean global option called <option>mua_wrapper</option>, defaulting false.
67148 Setting <option>mua_wrapper</option> true causes Exim to run in a special mode where it
67149 assumes that it is being used to <quote>wrap</quote> a command-line MUA in the manner
67150 just described. As well as setting <option>mua_wrapper</option>, you also need to provide a
67151 compatible router and transport configuration. Typically there will be just one
67152 router and one transport, sending everything to a smart host.
67153 </para>
67154 <para>
67155 When run in MUA wrapping mode, the behaviour of Exim changes in the
67156 following ways:
67157 </para>
67158 <itemizedlist>
67159 <listitem>
67160 <para>
67161 A daemon cannot be run, nor will Exim accept incoming messages from <emphasis>inetd</emphasis>.
67162 In other words, the only way to submit messages is via the command line.
67163 </para>
67164 </listitem>
67165 <listitem>
67166 <para>
67167 Each message is synchronously delivered as soon as it is received (<option>-odi</option> is
67168 assumed). All queueing options (<option>queue_only</option>, <option>queue_smtp_domains</option>,
67169 <option>control</option> in an ACL, etc.) are quietly ignored. The Exim reception process
67170 does not finish until the delivery attempt is complete. If the delivery is
67171 successful, a zero return code is given.
67172 </para>
67173 </listitem>
67174 <listitem>
67175 <para>
67176 Address redirection is permitted, but the final routing for all addresses must
67177 be to the same remote transport, and to the same list of hosts. Furthermore,
67178 the return address (envelope sender) must be the same for all recipients, as
67179 must any added or deleted header lines. In other words, it must be possible to
67180 deliver the message in a single SMTP transaction, however many recipients there
67181 are.
67182 </para>
67183 </listitem>
67184 <listitem>
67185 <para>
67186 If these conditions are not met, or if routing any address results in a
67187 failure or defer status, or if Exim is unable to deliver all the recipients
67188 successfully to one of the smart hosts, delivery of the entire message fails.
67189 </para>
67190 </listitem>
67191 <listitem>
67192 <para>
67193 Because no queueing is allowed, all failures are treated as permanent; there
67194 is no distinction between 4<emphasis>xx</emphasis> and 5<emphasis>xx</emphasis> SMTP response codes from the
67195 smart host. Furthermore, because only a single yes/no response can be given to
67196 the caller, it is not possible to deliver to some recipients and not others. If
67197 there is an error (temporary or permanent) for any recipient, all are failed.
67198 </para>
67199 </listitem>
67200 <listitem>
67201 <para>
67202 If more than one smart host is listed, Exim will try another host after a
67203 connection failure or a timeout, in the normal way. However, if this kind of
67204 failure happens for all the hosts, the delivery fails.
67205 </para>
67206 </listitem>
67207 <listitem>
67208 <para>
67209 When delivery fails, an error message is written to the standard error stream
67210 (as well as to Exim&#x2019;s log), and Exim exits to the caller with a return code
67211 value 1. The message is expunged from Exim&#x2019;s spool files. No bounce messages
67212 are ever generated.
67213 </para>
67214 </listitem>
67215 <listitem>
67216 <para>
67217 No retry data is maintained, and any retry rules are ignored.
67218 </para>
67219 </listitem>
67220 <listitem>
67221 <para>
67222 A number of Exim options are overridden: <option>deliver_drop_privilege</option> is forced
67223 true, <option>max_rcpt</option> in the <command>smtp</command> transport is forced to <quote>unlimited</quote>,
67224 <option>remote_max_parallel</option> is forced to one, and fallback hosts are ignored.
67225 </para>
67226 </listitem>
67227 </itemizedlist>
67228 <para>
67229 The overall effect is that Exim makes a single synchronous attempt to deliver
67230 the message, failing if there is any kind of problem. Because no local
67231 deliveries are done and no daemon can be run, Exim does not need root
67232 privilege. It should be possible to run it setuid to <emphasis>exim</emphasis> instead of setuid
67233 to <emphasis>root</emphasis>. See section <xref linkend="SECTrunexiwitpri"/> for a general discussion about
67234 the advantages and disadvantages of running without root privilege.
67235 </para>
67236 </chapter>
67237
67238 <chapter id="CHAPlog">
67239 <title>Log files</title>
67240 <para>
67241 <indexterm role="concept" id="IIDloggen" class="startofrange">
67242 <primary>log</primary>
67243 <secondary>general description</secondary>
67244 </indexterm>
67245 <indexterm role="concept">
67246 <primary>log</primary>
67247 <secondary>types of</secondary>
67248 </indexterm>
67249 Exim writes three different logs, referred to as the main log, the reject log,
67250 and the panic log:
67251 </para>
67252 <itemizedlist>
67253 <listitem>
67254 <para>
67255 <indexterm role="concept">
67256 <primary>main log</primary>
67257 </indexterm>
67258 The main log records the arrival of each message and each delivery in a single
67259 line in each case. The format is as compact as possible, in an attempt to keep
67260 down the size of log files. Two-character flag sequences make it easy to pick
67261 out these lines. A number of other events are recorded in the main log. Some of
67262 them are optional, in which case the <option>log_selector</option> option controls whether
67263 they are included or not. A Perl script called <emphasis>eximstats</emphasis>, which does simple
67264 analysis of main log files, is provided in the Exim distribution (see section
67265 <xref linkend="SECTmailstat"/>).
67266 </para>
67267 </listitem>
67268 <listitem>
67269 <para>
67270 <indexterm role="concept">
67271 <primary>reject log</primary>
67272 </indexterm>
67273 The reject log records information from messages that are rejected as a result
67274 of a configuration option (that is, for policy reasons).
67275 The first line of each rejection is a copy of the line that is also written to
67276 the main log. Then, if the message&#x2019;s header has been read at the time the log
67277 is written, its contents are written to this log. Only the original header
67278 lines are available; header lines added by ACLs are not logged. You can use the
67279 reject log to check that your policy controls are working correctly; on a busy
67280 host this may be easier than scanning the main log for rejection messages. You
67281 can suppress the writing of the reject log by setting <option>write_rejectlog</option>
67282 false.
67283 </para>
67284 </listitem>
67285 <listitem>
67286 <para>
67287 <indexterm role="concept">
67288 <primary>panic log</primary>
67289 </indexterm>
67290 <indexterm role="concept">
67291 <primary>system log</primary>
67292 </indexterm>
67293 When certain serious errors occur, Exim writes entries to its panic log. If the
67294 error is sufficiently disastrous, Exim bombs out afterwards. Panic log entries
67295 are usually written to the main log as well, but can get lost amid the mass of
67296 other entries. The panic log should be empty under normal circumstances. It is
67297 therefore a good idea to check it (or to have a <emphasis>cron</emphasis> script check it)
67298 regularly, in order to become aware of any problems. When Exim cannot open its
67299 panic log, it tries as a last resort to write to the system log (syslog). This
67300 is opened with LOG_PID+LOG_CONS and the facility code of LOG_MAIL. The
67301 message itself is written at priority LOG_CRIT.
67302 </para>
67303 </listitem>
67304 </itemizedlist>
67305 <para>
67306 Every log line starts with a timestamp, in the format shown in the following
67307 example. Note that many of the examples shown in this chapter are line-wrapped.
67308 In the log file, this would be all on one line:
67309 </para>
67310 <literallayout class="monospaced">
67311 2001-09-16 16:09:47 SMTP connection from [127.0.0.1] closed
67312   by QUIT
67313 </literallayout>
67314 <para>
67315 By default, the timestamps are in the local timezone. There are two
67316 ways of changing this:
67317 </para>
67318 <itemizedlist>
67319 <listitem>
67320 <para>
67321 You can set the <option>timezone</option> option to a different time zone; in particular, if
67322 you set
67323 </para>
67324 <literallayout class="monospaced">
67325 timezone = UTC
67326 </literallayout>
67327 <para>
67328 the timestamps will be in UTC (aka GMT).
67329 </para>
67330 </listitem>
67331 <listitem>
67332 <para>
67333 If you set <option>log_timezone</option> true, the time zone is added to the timestamp, for
67334 example:
67335 </para>
67336 <literallayout class="monospaced">
67337 2003-04-25 11:17:07 +0100 Start queue run: pid=12762
67338 </literallayout>
67339 </listitem>
67340 </itemizedlist>
67341 <para>
67342 <indexterm role="concept">
67343 <primary>log</primary>
67344 <secondary>process ids in</secondary>
67345 </indexterm>
67346 <indexterm role="concept">
67347 <primary>pid (process id)</primary>
67348 <secondary>in log lines</secondary>
67349 </indexterm>
67350 Exim does not include its process id in log lines by default, but you can
67351 request that it does so by specifying the <literal>pid</literal> log selector (see section
67352 <xref linkend="SECTlogselector"/>). When this is set, the process id is output, in square
67353 brackets, immediately after the time and date.
67354 </para>
67355 <section id="SECTwhelogwri">
67356 <title>Where the logs are written</title>
67357 <para>
67358 <indexterm role="concept">
67359 <primary>log</primary>
67360 <secondary>destination</secondary>
67361 </indexterm>
67362 <indexterm role="concept">
67363 <primary>log</primary>
67364 <secondary>to file</secondary>
67365 </indexterm>
67366 <indexterm role="concept">
67367 <primary>log</primary>
67368 <secondary>to syslog</secondary>
67369 </indexterm>
67370 <indexterm role="concept">
67371 <primary>syslog</primary>
67372 </indexterm>
67373 The logs may be written to local files, or to syslog, or both. However, it
67374 should be noted that many syslog implementations use UDP as a transport, and
67375 are therefore unreliable in the sense that messages are not guaranteed to
67376 arrive at the loghost, nor is the ordering of messages necessarily maintained.
67377 It has also been reported that on large log files (tens of megabytes) you may
67378 need to tweak syslog to prevent it syncing the file with each write &ndash; on
67379 Linux this has been seen to make syslog take 90% plus of CPU time.
67380 </para>
67381 <para>
67382 The destination for Exim&#x2019;s logs is configured by setting LOG_FILE_PATH in
67383 <filename>Local/Makefile</filename> or by setting <option>log_file_path</option> in the runtime
67384 configuration. This latter string is expanded, so it can contain, for example,
67385 references to the host name:
67386 </para>
67387 <literallayout class="monospaced">
67388 log_file_path = /var/log/$primary_hostname/exim_%slog
67389 </literallayout>
67390 <para>
67391 It is generally advisable, however, to set the string in <filename>Local/Makefile</filename>
67392 rather than at runtime, because then the setting is available right from the
67393 start of Exim&#x2019;s execution. Otherwise, if there&#x2019;s something it wants to log
67394 before it has read the configuration file (for example, an error in the
67395 configuration file) it will not use the path you want, and may not be able to
67396 log at all.
67397 </para>
67398 <para>
67399 The value of LOG_FILE_PATH or <option>log_file_path</option> is a colon-separated
67400 list, currently limited to at most two items. This is one option where the
67401 facility for changing a list separator may not be used. The list must always be
67402 colon-separated. If an item in the list is <quote>syslog</quote> then syslog is used;
67403 otherwise the item must either be an absolute path, containing <literal>%s</literal> at the
67404 point where <quote>main</quote>, <quote>reject</quote>, or <quote>panic</quote> is to be inserted, or be empty,
67405 implying the use of a default path.
67406 </para>
67407 <para>
67408 When Exim encounters an empty item in the list, it searches the list defined by
67409 LOG_FILE_PATH, and uses the first item it finds that is neither empty nor
67410 <quote>syslog</quote>. This means that an empty item in <option>log_file_path</option> can be used to
67411 mean <quote>use the path specified at build time</quote>. It no such item exists, log
67412 files are written in the <filename>log</filename> subdirectory of the spool directory. This is
67413 equivalent to the setting:
67414 </para>
67415 <literallayout class="monospaced">
67416 log_file_path = $spool_directory/log/%slog
67417 </literallayout>
67418 <para>
67419 If you do not specify anything at build time or runtime,
67420 or if you unset the option at runtime (i.e. <literal>log_file_path = </literal>),
67421 that is where the logs are written.
67422 </para>
67423 <para>
67424 A log file path may also contain <literal>%D</literal> or <literal>%M</literal> if datestamped log filenames
67425 are in use &ndash; see section <xref linkend="SECTdatlogfil"/> below.
67426 </para>
67427 <para>
67428 Here are some examples of possible settings:
67429 </para>
67430 <literallayout>
67431 <literal>LOG_FILE_PATH=syslog                    </literal> syslog only
67432 <literal>LOG_FILE_PATH=:syslog                   </literal> syslog and default path
67433 <literal>LOG_FILE_PATH=syslog : /usr/log/exim_%s </literal> syslog and specified path
67434 <literal>LOG_FILE_PATH=/usr/log/exim_%s          </literal> specified path only
67435 </literallayout>
67436 <para>
67437 If there are more than two paths in the list, the first is used and a panic
67438 error is logged.
67439 </para>
67440 </section>
67441 <section id="SECID285">
67442 <title>Logging to local files that are periodically <quote>cycled</quote></title>
67443 <para>
67444 <indexterm role="concept">
67445 <primary>log</primary>
67446 <secondary>cycling local files</secondary>
67447 </indexterm>
67448 <indexterm role="concept">
67449 <primary>cycling logs</primary>
67450 </indexterm>
67451 <indexterm role="concept">
67452 <primary><emphasis>exicyclog</emphasis></primary>
67453 </indexterm>
67454 <indexterm role="concept">
67455 <primary>log</primary>
67456 <secondary>local files; writing to</secondary>
67457 </indexterm>
67458 Some operating systems provide centralized and standardized methods for cycling
67459 log files. For those that do not, a utility script called <emphasis>exicyclog</emphasis> is
67460 provided (see section <xref linkend="SECTcyclogfil"/>). This renames and compresses the
67461 main and reject logs each time it is called. The maximum number of old logs to
67462 keep can be set. It is suggested this script is run as a daily <emphasis>cron</emphasis> job.
67463 </para>
67464 <para>
67465 An Exim delivery process opens the main log when it first needs to write to it,
67466 and it keeps the file open in case subsequent entries are required &ndash; for
67467 example, if a number of different deliveries are being done for the same
67468 message. However, remote SMTP deliveries can take a long time, and this means
67469 that the file may be kept open long after it is renamed if <emphasis>exicyclog</emphasis> or
67470 something similar is being used to rename log files on a regular basis. To
67471 ensure that a switch of log files is noticed as soon as possible, Exim calls
67472 <function>stat()</function> on the main log&#x2019;s name before reusing an open file, and if the file
67473 does not exist, or its inode has changed, the old file is closed and Exim
67474 tries to open the main log from scratch. Thus, an old log file may remain open
67475 for quite some time, but no Exim processes should write to it once it has been
67476 renamed.
67477 </para>
67478 </section>
67479 <section id="SECTdatlogfil">
67480 <title>Datestamped log files</title>
67481 <para>
67482 <indexterm role="concept">
67483 <primary>log</primary>
67484 <secondary>datestamped files</secondary>
67485 </indexterm>
67486 Instead of cycling the main and reject log files by renaming them
67487 periodically, some sites like to use files whose names contain a datestamp,
67488 for example, <filename>mainlog-20031225</filename>. The datestamp is in the form <filename>yyyymmdd</filename> or
67489 <filename>yyyymm</filename>. Exim has support for this way of working. It is enabled by setting
67490 the <option>log_file_path</option> option to a path that includes <literal>%D</literal> or <literal>%M</literal> at the
67491 point where the datestamp is required. For example:
67492 </para>
67493 <literallayout class="monospaced">
67494 log_file_path = /var/spool/exim/log/%slog-%D
67495 log_file_path = /var/log/exim-%s-%D.log
67496 log_file_path = /var/spool/exim/log/%D-%slog
67497 log_file_path = /var/log/exim/%s.%M
67498 </literallayout>
67499 <para>
67500 As before, <literal>%s</literal> is replaced by <quote>main</quote> or <quote>reject</quote>; the following are
67501 examples of names generated by the above examples:
67502 </para>
67503 <literallayout class="monospaced">
67504 /var/spool/exim/log/mainlog-20021225
67505 /var/log/exim-reject-20021225.log
67506 /var/spool/exim/log/20021225-mainlog
67507 /var/log/exim/main.200212
67508 </literallayout>
67509 <para>
67510 When this form of log file is specified, Exim automatically switches to new
67511 files at midnight. It does not make any attempt to compress old logs; you
67512 will need to write your own script if you require this. You should not
67513 run <emphasis>exicyclog</emphasis> with this form of logging.
67514 </para>
67515 <para>
67516 The location of the panic log is also determined by <option>log_file_path</option>, but it
67517 is not datestamped, because rotation of the panic log does not make sense.
67518 When generating the name of the panic log, <literal>%D</literal> or <literal>%M</literal> are removed from
67519 the string. In addition, if it immediately follows a slash, a following
67520 non-alphanumeric character is removed; otherwise a preceding non-alphanumeric
67521 character is removed. Thus, the four examples above would give these panic
67522 log names:
67523 </para>
67524 <literallayout class="monospaced">
67525 /var/spool/exim/log/paniclog
67526 /var/log/exim-panic.log
67527 /var/spool/exim/log/paniclog
67528 /var/log/exim/panic
67529 </literallayout>
67530 </section>
67531 <section id="SECID249">
67532 <title>Logging to syslog</title>
67533 <para>
67534 <indexterm role="concept">
67535 <primary>log</primary>
67536 <secondary>syslog; writing to</secondary>
67537 </indexterm>
67538 The use of syslog does not change what Exim logs or the format of its messages,
67539 except in one respect. If <option>syslog_timestamp</option> is set false, the timestamps on
67540 Exim&#x2019;s log lines are omitted when these lines are sent to syslog. Apart from
67541 that, the same strings are written to syslog as to log files. The syslog
67542 <quote>facility</quote> is set to LOG_MAIL, and the program name to <quote>exim</quote>
67543 by default, but you can change these by setting the <option>syslog_facility</option> and
67544 <option>syslog_processname</option> options, respectively. If Exim was compiled with
67545 SYSLOG_LOG_PID set in <filename>Local/Makefile</filename> (this is the default in
67546 <filename>src/EDITME</filename>), then, on systems that permit it (all except ULTRIX), the
67547 LOG_PID flag is set so that the <function>syslog()</function> call adds the pid as well as
67548 the time and host name to each line.
67549 The three log streams are mapped onto syslog priorities as follows:
67550 </para>
67551 <itemizedlist>
67552 <listitem>
67553 <para>
67554 <emphasis>mainlog</emphasis> is mapped to LOG_INFO
67555 </para>
67556 </listitem>
67557 <listitem>
67558 <para>
67559 <emphasis>rejectlog</emphasis> is mapped to LOG_NOTICE
67560 </para>
67561 </listitem>
67562 <listitem>
67563 <para>
67564 <emphasis>paniclog</emphasis> is mapped to LOG_ALERT
67565 </para>
67566 </listitem>
67567 </itemizedlist>
67568 <para>
67569 Many log lines are written to both <emphasis>mainlog</emphasis> and <emphasis>rejectlog</emphasis>, and some are
67570 written to both <emphasis>mainlog</emphasis> and <emphasis>paniclog</emphasis>, so there will be duplicates if
67571 these are routed by syslog to the same place. You can suppress this duplication
67572 by setting <option>syslog_duplication</option> false.
67573 </para>
67574 <para>
67575 Exim&#x2019;s log lines can sometimes be very long, and some of its <emphasis>rejectlog</emphasis>
67576 entries contain multiple lines when headers are included. To cope with both
67577 these cases, entries written to syslog are split into separate <function>syslog()</function>
67578 calls at each internal newline, and also after a maximum of
67579 870 data characters. (This allows for a total syslog line length of 1024, when
67580 additions such as timestamps are added.) If you are running a syslog
67581 replacement that can handle lines longer than the 1024 characters allowed by
67582 RFC 3164, you should set
67583 </para>
67584 <literallayout class="monospaced">
67585 SYSLOG_LONG_LINES=yes
67586 </literallayout>
67587 <para>
67588 in <filename>Local/Makefile</filename> before building Exim. That stops Exim from splitting long
67589 lines, but it still splits at internal newlines in <emphasis>reject</emphasis> log entries.
67590 </para>
67591 <para>
67592 To make it easy to re-assemble split lines later, each component of a split
67593 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;]
67594 where &lt;<emphasis>n</emphasis>&gt; is the component number and &lt;<emphasis>m</emphasis>&gt; is the total number of
67595 components in the entry. The / delimiter is used when the line was split
67596 because it was too long; if it was split because of an internal newline, the \
67597 delimiter is used. For example, supposing the length limit to be 50 instead of
67598 870, the following would be the result of a typical rejection message to
67599 <emphasis>mainlog</emphasis> (LOG_INFO), each line in addition being preceded by the time, host
67600 name, and pid as added by syslog:
67601 </para>
67602 <literallayout class="monospaced">
67603 [1/5] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from
67604 [2/5]  [127.0.0.1] (ph10): syntax error in 'From' header
67605 [3/5]  when scanning for sender: missing or malformed lo
67606 [4/5] cal part in "&lt;&gt;" (envelope sender is &lt;ph10@cam.exa
67607 [5/5] mple&gt;)
67608 </literallayout>
67609 <para>
67610 The same error might cause the following lines to be written to <quote>rejectlog</quote>
67611 (LOG_NOTICE):
67612 </para>
67613 <literallayout class="monospaced">
67614 [1/18] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected fro
67615 [2/18] m [127.0.0.1] (ph10): syntax error in 'From' head
67616 [3/18] er when scanning for sender: missing or malformed
67617 [4/18]  local part in "&lt;&gt;" (envelope sender is &lt;ph10@cam
67618 [5\18] .example&gt;)
67619 [6\18] Recipients: ph10@some.domain.cam.example
67620 [7\18] P Received: from [127.0.0.1] (ident=ph10)
67621 [8\18]        by xxxxx.cam.example with smtp (Exim 4.00)
67622 [9\18]        id 16RdAL-0006pc-00
67623 [10/18]        for ph10@cam.example; Mon, 16 Sep 2002 16:
67624 [11\18] 09:43 +0100
67625 [12\18] F From: &lt;&gt;
67626 [13\18]   Subject: this is a test header
67627 [18\18]   X-something: this is another header
67628 [15/18] I Message-Id: &lt;E16RdAL-0006pc-00@xxxxx.cam.examp
67629 [16\18] le&gt;
67630 [17\18] B Bcc:
67631 [18/18]   Date: Mon, 16 Sep 2002 16:09:43 +0100
67632 </literallayout>
67633 <para>
67634 Log lines that are neither too long nor contain newlines are written to syslog
67635 without modification.
67636 </para>
67637 <para>
67638 If only syslog is being used, the Exim monitor is unable to provide a log tail
67639 display, unless syslog is routing <emphasis>mainlog</emphasis> to a file on the local host and
67640 the environment variable EXIMON_LOG_FILE_PATH is set to tell the monitor
67641 where it is.
67642 </para>
67643 </section>
67644 <section id="SECID250">
67645 <title>Log line flags</title>
67646 <para>
67647 One line is written to the main log for each message received, and for each
67648 successful, unsuccessful, and delayed delivery. These lines can readily be
67649 picked out by the distinctive two-character flags that immediately follow the
67650 timestamp. The flags are:
67651 </para>
67652 <literallayout>
67653 <literal>&lt;=</literal>     message arrival
67654 <literal>(=</literal>     message fakereject
67655 <literal>=&gt;</literal>     normal message delivery
67656 <literal>-&gt;</literal>     additional address in same delivery
67657 <literal>&gt;&gt;</literal>     cutthrough message delivery
67658 <literal>*&gt;</literal>     delivery suppressed by <option>-N</option>
67659 <literal>**</literal>     delivery failed; address bounced
67660 <literal>==</literal>     delivery deferred; temporary problem
67661 </literallayout>
67662 </section>
67663 <section id="SECID251">
67664 <title>Logging message reception</title>
67665 <para>
67666 <indexterm role="concept">
67667 <primary>log</primary>
67668 <secondary>reception line</secondary>
67669 </indexterm>
67670 The format of the single-line entry in the main log that is written for every
67671 message received is shown in the basic example below, which is split over
67672 several lines in order to fit it on the page:
67673 </para>
67674 <literallayout class="monospaced">
67675 2002-10-31 08:57:53 16ZCW1-0005MB-00 &lt;= kryten@dwarf.fict.example
67676   H=mailer.fict.example [192.168.123.123] U=exim
67677   P=smtp S=5678 id=&lt;incoming message id&gt;
67678 </literallayout>
67679 <para>
67680 The address immediately following <quote>&lt;=</quote> is the envelope sender address. A
67681 bounce message is shown with the sender address <quote>&lt;&gt;</quote>, and if it is locally
67682 generated, this is followed by an item of the form
67683 </para>
67684 <literallayout class="monospaced">
67685 R=&lt;message id&gt;
67686 </literallayout>
67687 <para>
67688 which is a reference to the message that caused the bounce to be sent.
67689 </para>
67690 <para>
67691 <indexterm role="concept">
67692 <primary>HELO</primary>
67693 </indexterm>
67694 <indexterm role="concept">
67695 <primary>EHLO</primary>
67696 </indexterm>
67697 For messages from other hosts, the H and U fields identify the remote host and
67698 record the RFC 1413 identity of the user that sent the message, if one was
67699 received. The number given in square brackets is the IP address of the sending
67700 host. If there is a single, unparenthesized  host name in the H field, as
67701 above, it has been verified to correspond to the IP address (see the
67702 <option>host_lookup</option> option). If the name is in parentheses, it was the name quoted
67703 by the remote host in the SMTP HELO or EHLO command, and has not been
67704 verified. If verification yields a different name to that given for HELO or
67705 EHLO, the verified name appears first, followed by the HELO or EHLO
67706 name in parentheses.
67707 </para>
67708 <para>
67709 Misconfigured hosts (and mail forgers) sometimes put an IP address, with or
67710 without brackets, in the HELO or EHLO command, leading to entries in
67711 the log containing text like these examples:
67712 </para>
67713 <literallayout class="monospaced">
67714 H=(10.21.32.43) [192.168.8.34]
67715 H=([10.21.32.43]) [192.168.8.34]
67716 </literallayout>
67717 <para>
67718 This can be confusing. Only the final address in square brackets can be relied
67719 on.
67720 </para>
67721 <para>
67722 For locally generated messages (that is, messages not received over TCP/IP),
67723 the H field is omitted, and the U field contains the login name of the caller
67724 of Exim.
67725 </para>
67726 <para>
67727 <indexterm role="concept">
67728 <primary>authentication</primary>
67729 <secondary>logging</secondary>
67730 </indexterm>
67731 <indexterm role="concept">
67732 <primary>AUTH</primary>
67733 <secondary>logging</secondary>
67734 </indexterm>
67735 For all messages, the P field specifies the protocol used to receive the
67736 message. This is the value that is stored in <varname>$received_protocol</varname>. In the case
67737 of incoming SMTP messages, the value indicates whether or not any SMTP
67738 extensions (ESMTP), encryption, or authentication were used. If the SMTP
67739 session was encrypted, there is an additional X field that records the cipher
67740 suite that was used.
67741 </para>
67742 <para>
67743 <indexterm role="concept">
67744 <primary>log</primary>
67745 <secondary>protocol</secondary>
67746 </indexterm>
67747 The protocol is set to <quote>esmtpsa</quote> or <quote>esmtpa</quote> for messages received from
67748 hosts that have authenticated themselves using the SMTP AUTH command. The first
67749 value is used when the SMTP connection was encrypted (<quote>secure</quote>). In this case
67750 there is an additional item A= followed by the name of the authenticator that
67751 was used. If an authenticated identification was set up by the authenticator&#x2019;s
67752 <option>server_set_id</option> option, this is logged too, separated by a colon from the
67753 authenticator name.
67754 </para>
67755 <para>
67756 <indexterm role="concept">
67757 <primary>size</primary>
67758 <secondary>of message</secondary>
67759 </indexterm>
67760 The id field records the existing message id, if present. The size of the
67761 received message is given by the S field. When the message is delivered,
67762 headers may be removed or added, so that the size of delivered copies of the
67763 message may not correspond with this value (and indeed may be different to each
67764 other).
67765 </para>
67766 <para>
67767 The <option>log_selector</option> option can be used to request the logging of additional
67768 data when a message is received. See section <xref linkend="SECTlogselector"/> below.
67769 </para>
67770 </section>
67771 <section id="SECID252">
67772 <title>Logging deliveries</title>
67773 <para>
67774 <indexterm role="concept">
67775 <primary>log</primary>
67776 <secondary>delivery line</secondary>
67777 </indexterm>
67778 The format of the single-line entry in the main log that is written for every
67779 delivery is shown in one of the examples below, for local and remote
67780 deliveries, respectively. Each example has been split into multiple lines in order
67781 to fit it on the page:
67782 </para>
67783 <literallayout class="monospaced">
67784 2002-10-31 08:59:13 16ZCW1-0005MB-00 =&gt; marv
67785   &lt;marv@hitch.fict.example&gt; R=localuser T=local_delivery
67786 2002-10-31 09:00:10 16ZCW1-0005MB-00 =&gt;
67787   monk@holistic.fict.example R=dnslookup T=remote_smtp
67788   H=holistic.fict.example [192.168.234.234]
67789 </literallayout>
67790 <para>
67791 For ordinary local deliveries, the original address is given in angle brackets
67792 after the final delivery address, which might be a pipe or a file. If
67793 intermediate address(es) exist between the original and the final address, the
67794 last of these is given in parentheses after the final address. The R and T
67795 fields record the router and transport that were used to process the address.
67796 </para>
67797 <para>
67798 If SMTP AUTH was used for the delivery there is an additional item A=
67799 followed by the name of the authenticator that was used.
67800 If an authenticated identification was set up by the authenticator&#x2019;s <option>client_set_id</option>
67801 option, this is logged too, separated by a colon from the authenticator name.
67802 </para>
67803 <para>
67804 If a shadow transport was run after a successful local delivery, the log line
67805 for the successful delivery has an item added on the end, of the form
67806 </para>
67807 <literallayout>
67808 <literal>ST=&lt;</literal><emphasis>shadow transport name</emphasis><literal>&gt;</literal>
67809 </literallayout>
67810 <para>
67811 If the shadow transport did not succeed, the error message is put in
67812 parentheses afterwards.
67813 </para>
67814 <para>
67815 <indexterm role="concept">
67816 <primary>asterisk</primary>
67817 <secondary>after IP address</secondary>
67818 </indexterm>
67819 When more than one address is included in a single delivery (for example, two
67820 SMTP RCPT commands in one transaction) the second and subsequent addresses are
67821 flagged with <literal>-&gt;</literal> instead of <literal>=&gt;</literal>. When two or more messages are delivered
67822 down a single SMTP connection, an asterisk follows the IP address in the log
67823 lines for the second and subsequent messages.
67824 When two or more messages are delivered down a single TLS connection, the
67825 DNS and some TLS-related information logged for the first message delivered
67826 will not be present in the log lines for the second and subsequent messages.
67827 TLS cipher information is still available.
67828 </para>
67829 <para>
67830 <indexterm role="concept">
67831 <primary>delivery</primary>
67832 <secondary>cutthrough; logging</secondary>
67833 </indexterm>
67834 <indexterm role="concept">
67835 <primary>cutthrough</primary>
67836 <secondary>logging</secondary>
67837 </indexterm>
67838 When delivery is done in cutthrough mode it is flagged with <literal>&gt;&gt;</literal> and the log
67839 line precedes the reception line, since cutthrough waits for a possible
67840 rejection from the destination in case it can reject the sourced item.
67841 </para>
67842 <para>
67843 The generation of a reply message by a filter file gets logged as a
67844 <quote>delivery</quote> to the addressee, preceded by <quote>&gt;</quote>.
67845 </para>
67846 <para>
67847 The <option>log_selector</option> option can be used to request the logging of additional
67848 data when a message is delivered. See section <xref linkend="SECTlogselector"/> below.
67849 </para>
67850 </section>
67851 <section id="SECID253">
67852 <title>Discarded deliveries</title>
67853 <para>
67854 <indexterm role="concept">
67855 <primary>discarded messages</primary>
67856 </indexterm>
67857 <indexterm role="concept">
67858 <primary>message</primary>
67859 <secondary>discarded</secondary>
67860 </indexterm>
67861 <indexterm role="concept">
67862 <primary>delivery</primary>
67863 <secondary>discarded; logging</secondary>
67864 </indexterm>
67865 When a message is discarded as a result of the command <quote>seen finish</quote> being
67866 obeyed in a filter file which generates no deliveries, a log entry of the form
67867 </para>
67868 <literallayout class="monospaced">
67869 2002-12-10 00:50:49 16auJc-0001UB-00 =&gt; discarded
67870   &lt;low.club@bridge.example&gt; R=userforward
67871 </literallayout>
67872 <para>
67873 is written, to record why no deliveries are logged. When a message is discarded
67874 because it is aliased to <quote>:blackhole:</quote> the log line is like this:
67875 </para>
67876 <literallayout class="monospaced">
67877 1999-03-02 09:44:33 10HmaX-0005vi-00 =&gt; :blackhole:
67878   &lt;hole@nowhere.example&gt; R=blackhole_router
67879 </literallayout>
67880 </section>
67881 <section id="SECID254">
67882 <title>Deferred deliveries</title>
67883 <para>
67884 When a delivery is deferred, a line of the following form is logged:
67885 </para>
67886 <literallayout class="monospaced">
67887 2002-12-19 16:20:23 16aiQz-0002Q5-00 == marvin@endrest.example
67888   R=dnslookup T=smtp defer (146): Connection refused
67889 </literallayout>
67890 <para>
67891 In the case of remote deliveries, the error is the one that was given for the
67892 last IP address that was tried. Details of individual SMTP failures are also
67893 written to the log, so the above line would be preceded by something like
67894 </para>
67895 <literallayout class="monospaced">
67896 2002-12-19 16:20:23 16aiQz-0002Q5-00 Failed to connect to
67897   mail1.endrest.example [192.168.239.239]: Connection refused
67898 </literallayout>
67899 <para>
67900 When a deferred address is skipped because its retry time has not been reached,
67901 a message is written to the log, but this can be suppressed by setting an
67902 appropriate value in <option>log_selector</option>.
67903 </para>
67904 </section>
67905 <section id="SECID255">
67906 <title>Delivery failures</title>
67907 <para>
67908 <indexterm role="concept">
67909 <primary>delivery</primary>
67910 <secondary>failure; logging</secondary>
67911 </indexterm>
67912 If a delivery fails because an address cannot be routed, a line of the
67913 following form is logged:
67914 </para>
67915 <literallayout class="monospaced">
67916 1995-12-19 16:20:23 0tRiQz-0002Q5-00 ** jim@trek99.example
67917   &lt;jim@trek99.example&gt;: unknown mail domain
67918 </literallayout>
67919 <para>
67920 If a delivery fails at transport time, the router and transport are shown, and
67921 the response from the remote host is included, as in this example:
67922 </para>
67923 <literallayout class="monospaced">
67924 2002-07-11 07:14:17 17SXDU-000189-00 ** ace400@pb.example
67925   R=dnslookup T=remote_smtp: SMTP error from remote mailer
67926   after pipelined RCPT TO:&lt;ace400@pb.example&gt;: host
67927   pbmail3.py.example [192.168.63.111]: 553 5.3.0
67928   &lt;ace400@pb.example&gt;...Addressee unknown
67929 </literallayout>
67930 <para>
67931 The word <quote>pipelined</quote> indicates that the SMTP PIPELINING extension was being
67932 used. See <option>hosts_avoid_esmtp</option> in the <command>smtp</command> transport for a way of
67933 disabling PIPELINING. The log lines for all forms of delivery failure are
67934 flagged with <literal>**</literal>.
67935 </para>
67936 </section>
67937 <section id="SECID256">
67938 <title>Fake deliveries</title>
67939 <para>
67940 <indexterm role="concept">
67941 <primary>delivery</primary>
67942 <secondary>fake; logging</secondary>
67943 </indexterm>
67944 If a delivery does not actually take place because the <option>-N</option> option has been
67945 used to suppress it, a normal delivery line is written to the log, except that
67946 <quote>=&gt;</quote> is replaced by <quote>*&gt;</quote>.
67947 </para>
67948 </section>
67949 <section id="SECID257">
67950 <title>Completion</title>
67951 <para>
67952 A line of the form
67953 </para>
67954 <literallayout class="monospaced">
67955 2002-10-31 09:00:11 16ZCW1-0005MB-00 Completed
67956 </literallayout>
67957 <para>
67958 is written to the main log when a message is about to be removed from the spool
67959 at the end of its processing.
67960 </para>
67961 </section>
67962 <section id="SECID258">
67963 <title>Summary of Fields in Log Lines</title>
67964 <para>
67965 <indexterm role="concept">
67966 <primary>log</primary>
67967 <secondary>summary of fields</secondary>
67968 </indexterm>
67969 A summary of the field identifiers that are used in log lines is shown in
67970 the following table:
67971 </para>
67972 <literallayout>
67973 <literal>A   </literal>        authenticator name (and optional id and sender)
67974 <literal>C   </literal>        SMTP confirmation on delivery
67975 <literal>    </literal>        command list for <quote>no mail in SMTP session</quote>
67976 <literal>CV  </literal>        certificate verification status
67977 <literal>D   </literal>        duration of <quote>no mail in SMTP session</quote>
67978 <literal>DKIM</literal>        domain verified in incoming message
67979 <literal>DN  </literal>        distinguished name from peer certificate
67980 <literal>DS  </literal>        DNSSEC secured lookups
67981 <literal>DT  </literal>        on <literal>=&gt;</literal> lines: time taken for a delivery
67982 <literal>F   </literal>        sender address (on delivery lines)
67983 <literal>H   </literal>        host name and IP address
67984 <literal>I   </literal>        local interface used
67985 <literal>id  </literal>        message id (from header) for incoming message
67986 <literal>K   </literal>        CHUNKING extension used
67987 <literal>L   </literal>        on <literal>&lt;=</literal> and <literal>=&gt;</literal> lines: PIPELINING extension used
67988 <literal>M8S </literal>        8BITMIME status for incoming message
67989 <literal>P   </literal>        on <literal>&lt;=</literal> lines: protocol used
67990 <literal>    </literal>        on <literal>=&gt;</literal> and <literal>**</literal> lines: return path
67991 <literal>PRDR</literal>        PRDR extension used
67992 <literal>PRX </literal>        on <literal>&lt;=</literal> and <literal>=&gt;</literal> lines: proxy address
67993 <literal>Q   </literal>        alternate queue name
67994 <literal>QT  </literal>        on <literal>=&gt;</literal> lines: time spent on queue so far
67995 <literal>    </literal>        on <quote>Completed</quote> lines: time spent on queue
67996 <literal>R   </literal>        on <literal>&lt;=</literal> lines: reference for local bounce
67997 <literal>    </literal>        on <literal>=&gt;</literal>  <literal>&gt;&gt;</literal> <literal>**</literal> and <literal>==</literal> lines: router name
67998 <literal>RT  </literal>        on <literal>&lt;=</literal> lines: time taken for reception
67999 <literal>S   </literal>        size of message in bytes
68000 <literal>SNI </literal>        server name indication from TLS client hello
68001 <literal>ST  </literal>        shadow transport name
68002 <literal>T   </literal>        on <literal>&lt;=</literal> lines: message subject (topic)
68003 <literal>TFO </literal>        connection took advantage of TCP Fast Open
68004 <literal>    </literal>        on <literal>=&gt;</literal> <literal>**</literal> and <literal>==</literal> lines: transport name
68005 <literal>U   </literal>        local user or RFC 1413 identity
68006 <literal>X   </literal>        TLS cipher suite
68007 </literallayout>
68008 </section>
68009 <section id="SECID259">
68010 <title>Other log entries</title>
68011 <para>
68012 Various other types of log entry are written from time to time. Most should be
68013 self-explanatory. Among the more common are:
68014 </para>
68015 <itemizedlist>
68016 <listitem>
68017 <para>
68018 <indexterm role="concept">
68019 <primary>retry</primary>
68020 <secondary>time not reached</secondary>
68021 </indexterm>
68022 <emphasis>retry time not reached</emphasis>&nbsp;&nbsp;An address previously suffered a temporary error
68023 during routing or local delivery, and the time to retry has not yet arrived.
68024 This message is not written to an individual message log file unless it happens
68025 during the first delivery attempt.
68026 </para>
68027 </listitem>
68028 <listitem>
68029 <para>
68030 <emphasis>retry time not reached for any host</emphasis>&nbsp;&nbsp;An address previously suffered
68031 temporary errors during remote delivery, and the retry time has not yet arrived
68032 for any of the hosts to which it is routed.
68033 </para>
68034 </listitem>
68035 <listitem>
68036 <para>
68037 <indexterm role="concept">
68038 <primary>spool directory</primary>
68039 <secondary>file locked</secondary>
68040 </indexterm>
68041 <emphasis>spool file locked</emphasis>&nbsp;&nbsp;An attempt to deliver a message cannot proceed because
68042 some other Exim process is already working on the message. This can be quite
68043 common if queue running processes are started at frequent intervals. The
68044 <emphasis>exiwhat</emphasis> utility script can be used to find out what Exim processes are
68045 doing.
68046 </para>
68047 </listitem>
68048 <listitem>
68049 <para>
68050 <indexterm role="concept">
68051 <primary>error</primary>
68052 <secondary>ignored</secondary>
68053 </indexterm>
68054 <emphasis>error ignored</emphasis>&nbsp;&nbsp;There are several circumstances that give rise to this
68055 message:
68056 </para>
68057 <orderedlist numeration="arabic">
68058 <listitem>
68059 <para>
68060 Exim failed to deliver a bounce message whose age was greater than
68061 <option>ignore_bounce_errors_after</option>. The bounce was discarded.
68062 </para>
68063 </listitem>
68064 <listitem>
68065 <para>
68066 A filter file set up a delivery using the <quote>noerror</quote> option, and the delivery
68067 failed. The delivery was discarded.
68068 </para>
68069 </listitem>
68070 <listitem>
68071 <para>
68072 A delivery set up by a router configured with
68073 </para>
68074 <literallayout class="monospaced">
68075     errors_to = &lt;&gt;
68076 </literallayout>
68077 <para>
68078 failed. The delivery was discarded.
68079 </para>
68080 </listitem>
68081 </orderedlist>
68082 </listitem>
68083 <listitem>
68084 <para>
68085 <indexterm role="concept">
68086 <primary>DKIM</primary>
68087 <secondary>log line</secondary>
68088 </indexterm>
68089 <emphasis>DKIM: d=</emphasis>&nbsp;&nbsp;Verbose results of a DKIM verification attempt, if enabled for
68090 logging and the message has a DKIM signature header.
68091 </para>
68092 </listitem>
68093 </itemizedlist>
68094 </section>
68095 <section id="SECTlogselector">
68096 <title>Reducing or increasing what is logged</title>
68097 <para>
68098 <indexterm role="concept">
68099 <primary>log</primary>
68100 <secondary>selectors</secondary>
68101 </indexterm>
68102 By setting the <option>log_selector</option> global option, you can disable some of Exim&#x2019;s
68103 default logging, or you can request additional logging. The value of
68104 <option>log_selector</option> is made up of names preceded by plus or minus characters. For
68105 example:
68106 </para>
68107 <literallayout class="monospaced">
68108 log_selector = +arguments -retry_defer
68109 </literallayout>
68110 <para>
68111 The list of optional log items is in the following table, with the default
68112 selection marked by asterisks:
68113 </para>
68114 <literallayout>
68115 <literal> 8bitmime                   </literal>  received 8BITMIME status
68116 <literal>*acl_warn_skipped           </literal>  skipped <option>warn</option> statement in ACL
68117 <literal> address_rewrite            </literal>  address rewriting
68118 <literal> all_parents                </literal>  all parents in =&gt; lines
68119 <literal> arguments                  </literal>  command line arguments
68120 <literal>*connection_reject          </literal>  connection rejections
68121 <literal>*delay_delivery             </literal>  immediate delivery delayed
68122 <literal> deliver_time               </literal>  time taken to perform delivery
68123 <literal> delivery_size              </literal>  add <literal>S=</literal><emphasis>nnn</emphasis> to =&gt; lines
68124 <literal>*dkim                       </literal>  DKIM verified domain on &lt;= lines
68125 <literal> dkim_verbose               </literal>  separate full DKIM verification result line, per signature
68126 <literal>*dnslist_defer              </literal>  defers of DNS list (aka RBL) lookups
68127 <literal> dnssec                     </literal>  DNSSEC secured lookups
68128 <literal>*etrn                       </literal>  ETRN commands
68129 <literal>*host_lookup_failed         </literal>  as it says
68130 <literal> ident_timeout              </literal>  timeout for ident connection
68131 <literal> incoming_interface         </literal>  local interface on &lt;= and =&gt; lines
68132 <literal> incoming_port              </literal>  remote port on &lt;= lines
68133 <literal>*lost_incoming_connection   </literal>  as it says (includes timeouts)
68134 <literal> millisec                   </literal>  millisecond timestamps and RT,QT,DT,D times
68135 <literal>*msg_id                     </literal>  on &lt;= lines, Message-ID: header value
68136 <literal> msg_id_created             </literal>  on &lt;= lines, Message-ID: header value when one had to be added
68137 <literal> outgoing_interface         </literal>  local interface on =&gt; lines
68138 <literal> outgoing_port              </literal>  add remote port to =&gt; lines
68139 <literal>*queue_run                  </literal>  start and end queue runs
68140 <literal> queue_time                 </literal>  time on queue for one recipient
68141 <literal> queue_time_overall         </literal>  time on queue for whole message
68142 <literal> pid                        </literal>  Exim process id
68143 <literal> pipelining                 </literal>  PIPELINING use, on &lt;= and =&gt; lines
68144 <literal> proxy                      </literal>  proxy address on &lt;= and =&gt; lines
68145 <literal> receive_time               </literal>  time taken to receive message
68146 <literal> received_recipients        </literal>  recipients on &lt;= lines
68147 <literal> received_sender            </literal>  sender on &lt;= lines
68148 <literal>*rejected_header            </literal>  header contents on reject log
68149 <literal>*retry_defer                </literal>  <quote>retry time not reached</quote>
68150 <literal> return_path_on_delivery    </literal>  put return path on =&gt; and ** lines
68151 <literal> sender_on_delivery         </literal>  add sender to =&gt; lines
68152 <literal>*sender_verify_fail         </literal>  sender verification failures
68153 <literal>*size_reject                </literal>  rejection because too big
68154 <literal>*skip_delivery              </literal>  delivery skipped in a queue run
68155 <literal>*smtp_confirmation          </literal>  SMTP confirmation on =&gt; lines
68156 <literal> smtp_connection            </literal>  incoming SMTP connections
68157 <literal> smtp_incomplete_transaction</literal>  incomplete SMTP transactions
68158 <literal> smtp_mailauth              </literal>  AUTH argument to MAIL commands
68159 <literal> smtp_no_mail               </literal>  session with no MAIL commands
68160 <literal> smtp_protocol_error        </literal>  SMTP protocol errors
68161 <literal> smtp_syntax_error          </literal>  SMTP syntax errors
68162 <literal> subject                    </literal>  contents of <emphasis>Subject:</emphasis> on &lt;= lines
68163 <literal>*tls_certificate_verified   </literal>  certificate verification status
68164 <literal>*tls_cipher                 </literal>  TLS cipher suite on &lt;= and =&gt; lines
68165 <literal> tls_peerdn                 </literal>  TLS peer DN on &lt;= and =&gt; lines
68166 <literal> tls_sni                    </literal>  TLS SNI on &lt;= lines
68167 <literal> unknown_in_list            </literal>  DNS lookup failed in list match
68168
68169 <literal> all                        </literal>  all of the above
68170 </literallayout>
68171 <para>
68172 See also the <option>slow_lookup_log</option> main configuration option,
68173 section <xref linkend="SECID99"/>
68174 </para>
68175 <para>
68176 More details on each of these items follows:
68177 </para>
68178 <itemizedlist>
68179 <listitem>
68180 <para>
68181 <indexterm role="concept">
68182 <primary>8BITMIME</primary>
68183 </indexterm>
68184 <indexterm role="concept">
68185 <primary>log</primary>
68186 <secondary>8BITMIME</secondary>
68187 </indexterm>
68188 <option>8bitmime</option>: This causes Exim to log any 8BITMIME status of received messages,
68189 which may help in tracking down interoperability issues with ancient MTAs
68190 that are not 8bit clean.  This is added to the <quote>&lt;=</quote> line, tagged with
68191 <literal>M8S=</literal> and a value of <literal>0</literal>, <literal>7</literal> or <literal>8</literal>, corresponding to "not given",
68192 <literal>7BIT</literal> and <literal>8BITMIME</literal> respectively.
68193 </para>
68194 </listitem>
68195 <listitem>
68196 <para>
68197 <indexterm role="concept">
68198 <primary><option>warn</option> ACL verb</primary>
68199 <secondary>log when skipping</secondary>
68200 </indexterm>
68201 <option>acl_warn_skipped</option>: When an ACL <option>warn</option> statement is skipped because one of
68202 its conditions cannot be evaluated, a log line to this effect is written if
68203 this log selector is set.
68204 </para>
68205 </listitem>
68206 <listitem>
68207 <para>
68208 <indexterm role="concept">
68209 <primary>log</primary>
68210 <secondary>rewriting</secondary>
68211 </indexterm>
68212 <indexterm role="concept">
68213 <primary>rewriting</primary>
68214 <secondary>logging</secondary>
68215 </indexterm>
68216 <option>address_rewrite</option>: This applies both to global rewrites and per-transport
68217 rewrites, but not to rewrites in filters run as an unprivileged user (because
68218 such users cannot access the log).
68219 </para>
68220 </listitem>
68221 <listitem>
68222 <para>
68223 <indexterm role="concept">
68224 <primary>log</primary>
68225 <secondary>full parentage</secondary>
68226 </indexterm>
68227 <option>all_parents</option>: Normally only the original and final addresses are logged on
68228 delivery lines; with this selector, intermediate parents are given in
68229 parentheses between them.
68230 </para>
68231 </listitem>
68232 <listitem>
68233 <para>
68234 <indexterm role="concept">
68235 <primary>log</primary>
68236 <secondary>Exim arguments</secondary>
68237 </indexterm>
68238 <indexterm role="concept">
68239 <primary>Exim arguments, logging</primary>
68240 </indexterm>
68241 <option>arguments</option>: This causes Exim to write the arguments with which it was called
68242 to the main log, preceded by the current working directory. This is a debugging
68243 feature, added to make it easier to find out how certain MUAs call
68244 <filename>/usr/sbin/sendmail</filename>. The logging does not happen if Exim has given up root
68245 privilege because it was called with the <option>-C</option> or <option>-D</option> options. Arguments
68246 that are empty or that contain white space are quoted. Non-printing characters
68247 are shown as escape sequences. This facility cannot log unrecognized arguments,
68248 because the arguments are checked before the configuration file is read. The
68249 only way to log such cases is to interpose a script such as <filename>util/logargs.sh</filename>
68250 between the caller and Exim.
68251 </para>
68252 </listitem>
68253 <listitem>
68254 <para>
68255 <indexterm role="concept">
68256 <primary>log</primary>
68257 <secondary>connection rejections</secondary>
68258 </indexterm>
68259 <option>connection_reject</option>: A log entry is written whenever an incoming SMTP
68260 connection is rejected, for whatever reason.
68261 </para>
68262 </listitem>
68263 <listitem>
68264 <para>
68265 <indexterm role="concept">
68266 <primary>log</primary>
68267 <secondary>delayed delivery</secondary>
68268 </indexterm>
68269 <indexterm role="concept">
68270 <primary>delayed delivery, logging</primary>
68271 </indexterm>
68272 <option>delay_delivery</option>: A log entry is written whenever a delivery process is not
68273 started for an incoming message because the load is too high or too many
68274 messages were received on one connection. Logging does not occur if no delivery
68275 process is started because <option>queue_only</option> is set or <option>-odq</option> was used.
68276 </para>
68277 </listitem>
68278 <listitem>
68279 <para>
68280 <indexterm role="concept">
68281 <primary>log</primary>
68282 <secondary>delivery duration</secondary>
68283 </indexterm>
68284 <option>deliver_time</option>: For each delivery, the amount of real time it has taken to
68285 perform the actual delivery is logged as DT=&lt;<emphasis>time</emphasis>&gt;, for example, <literal>DT=1s</literal>.
68286 If millisecond logging is enabled, short times will be shown with greater
68287 precision, eg. <literal>DT=0.304s</literal>.
68288 </para>
68289 </listitem>
68290 <listitem>
68291 <para>
68292 <indexterm role="concept">
68293 <primary>log</primary>
68294 <secondary>message size on delivery</secondary>
68295 </indexterm>
68296 <indexterm role="concept">
68297 <primary>size</primary>
68298 <secondary>of message</secondary>
68299 </indexterm>
68300 <option>delivery_size</option>: For each delivery, the size of message delivered is added to
68301 the <quote>=&gt;</quote> line, tagged with S=.
68302 </para>
68303 </listitem>
68304 <listitem>
68305 <para>
68306 <indexterm role="concept">
68307 <primary>log</primary>
68308 <secondary>DKIM verification</secondary>
68309 </indexterm>
68310 <indexterm role="concept">
68311 <primary>DKIM</primary>
68312 <secondary>verification logging</secondary>
68313 </indexterm>
68314 <option>dkim</option>: For message acceptance log lines, when an DKIM signature in the header
68315 verifies successfully a tag of DKIM is added, with one of the verified domains.
68316 </para>
68317 </listitem>
68318 <listitem>
68319 <para>
68320 <indexterm role="concept">
68321 <primary>log</primary>
68322 <secondary>DKIM verification</secondary>
68323 </indexterm>
68324 <indexterm role="concept">
68325 <primary>DKIM</primary>
68326 <secondary>verification logging</secondary>
68327 </indexterm>
68328 <option>dkim_verbose</option>: A log entry is written for each attempted DKIM verification.
68329 </para>
68330 </listitem>
68331 <listitem>
68332 <para>
68333 <indexterm role="concept">
68334 <primary>log</primary>
68335 <secondary>dnslist defer</secondary>
68336 </indexterm>
68337 <indexterm role="concept">
68338 <primary>DNS list</primary>
68339 <secondary>logging defer</secondary>
68340 </indexterm>
68341 <indexterm role="concept">
68342 <primary>black list (DNS)</primary>
68343 </indexterm>
68344 <option>dnslist_defer</option>: A log entry is written if an attempt to look up a host in a
68345 DNS black list suffers a temporary error.
68346 </para>
68347 </listitem>
68348 <listitem>
68349 <para>
68350 <indexterm role="concept">
68351 <primary>log</primary>
68352 <secondary>dnssec</secondary>
68353 </indexterm>
68354 <indexterm role="concept">
68355 <primary>dnssec</primary>
68356 <secondary>logging</secondary>
68357 </indexterm>
68358 <option>dnssec</option>: For message acceptance and (attempted) delivery log lines, when
68359 dns lookups gave secure results a tag of DS is added.
68360 For acceptance this covers the reverse and forward lookups for host name verification.
68361 It does not cover helo-name verification.
68362 For delivery this covers the SRV, MX, A and/or AAAA lookups.
68363 </para>
68364 </listitem>
68365 <listitem>
68366 <para>
68367 <indexterm role="concept">
68368 <primary>log</primary>
68369 <secondary>ETRN commands</secondary>
68370 </indexterm>
68371 <indexterm role="concept">
68372 <primary>ETRN</primary>
68373 <secondary>logging</secondary>
68374 </indexterm>
68375 <option>etrn</option>: Every valid ETRN command that is received is logged, before the ACL
68376 is run to determine whether or not it is actually accepted. An invalid ETRN
68377 command, or one received within a message transaction is not logged by this
68378 selector (see <option>smtp_syntax_error</option> and <option>smtp_protocol_error</option>).
68379 </para>
68380 </listitem>
68381 <listitem>
68382 <para>
68383 <indexterm role="concept">
68384 <primary>log</primary>
68385 <secondary>host lookup failure</secondary>
68386 </indexterm>
68387 <option>host_lookup_failed</option>: When a lookup of a host&#x2019;s IP addresses fails to find
68388 any addresses, or when a lookup of an IP address fails to find a host name, a
68389 log line is written. This logging does not apply to direct DNS lookups when
68390 routing email addresses, but it does apply to <quote>byname</quote> lookups.
68391 </para>
68392 </listitem>
68393 <listitem>
68394 <para>
68395 <indexterm role="concept">
68396 <primary>log</primary>
68397 <secondary>ident timeout</secondary>
68398 </indexterm>
68399 <indexterm role="concept">
68400 <primary>RFC 1413</primary>
68401 <secondary>logging timeout</secondary>
68402 </indexterm>
68403 <option>ident_timeout</option>: A log line is written whenever an attempt to connect to a
68404 client&#x2019;s ident port times out.
68405 </para>
68406 </listitem>
68407 <listitem>
68408 <para>
68409 <indexterm role="concept">
68410 <primary>log</primary>
68411 <secondary>incoming interface</secondary>
68412 </indexterm>
68413 <indexterm role="concept">
68414 <primary>log</primary>
68415 <secondary>local interface</secondary>
68416 </indexterm>
68417 <indexterm role="concept">
68418 <primary>log</primary>
68419 <secondary>local address and port</secondary>
68420 </indexterm>
68421 <indexterm role="concept">
68422 <primary>TCP/IP</primary>
68423 <secondary>logging local address and port</secondary>
68424 </indexterm>
68425 <indexterm role="concept">
68426 <primary>interface</primary>
68427 <secondary>logging</secondary>
68428 </indexterm>
68429 <option>incoming_interface</option>: The interface on which a message was received is added
68430 to the <quote>&lt;=</quote> line as an IP address in square brackets, tagged by I= and
68431 followed by a colon and the port number. The local interface and port are also
68432 added to other SMTP log lines, for example, <quote>SMTP connection from</quote>, to
68433 rejection lines, and (despite the name) to outgoing <quote>=&gt;</quote> and <quote>-&gt;</quote> lines.
68434 The latter can be disabled by turning off the <option>outgoing_interface</option> option.
68435 </para>
68436 </listitem>
68437 <listitem>
68438 <para>
68439 <indexterm role="concept">
68440 <primary>log</primary>
68441 <secondary>incoming proxy address</secondary>
68442 </indexterm>
68443 <indexterm role="concept">
68444 <primary>proxy</primary>
68445 <secondary>logging proxy address</secondary>
68446 </indexterm>
68447 <indexterm role="concept">
68448 <primary>TCP/IP</primary>
68449 <secondary>logging proxy address</secondary>
68450 </indexterm>
68451 <option>proxy</option>: The internal (closest to the system running Exim) IP address
68452 of the proxy, tagged by PRX=, on the <quote>&lt;=</quote> line for a message accepted
68453 on a proxied connection
68454 or the <quote>=&gt;</quote> line for a message delivered on a proxied connection.
68455 See <xref linkend="SECTproxyInbound"/> for more information.
68456 </para>
68457 </listitem>
68458 <listitem>
68459 <para>
68460 <indexterm role="concept">
68461 <primary>log</primary>
68462 <secondary>incoming remote port</secondary>
68463 </indexterm>
68464 <indexterm role="concept">
68465 <primary>port</primary>
68466 <secondary>logging remote</secondary>
68467 </indexterm>
68468 <indexterm role="concept">
68469 <primary>TCP/IP</primary>
68470 <secondary>logging incoming remote port</secondary>
68471 </indexterm>
68472 <indexterm role="variable">
68473 <primary><varname>$sender_fullhost</varname></primary>
68474 </indexterm>
68475 <indexterm role="variable">
68476 <primary><varname>$sender_rcvhost</varname></primary>
68477 </indexterm>
68478 <option>incoming_port</option>: The remote port number from which a message was received is
68479 added to log entries and <emphasis>Received:</emphasis> header lines, following the IP address
68480 in square brackets, and separated from it by a colon. This is implemented by
68481 changing the value that is put in the <varname>$sender_fullhost</varname> and
68482 <varname>$sender_rcvhost</varname> variables. Recording the remote port number has become more
68483 important with the widening use of NAT (see RFC 2505).
68484 </para>
68485 </listitem>
68486 <listitem>
68487 <para>
68488 <indexterm role="concept">
68489 <primary>log</primary>
68490 <secondary>dropped connection</secondary>
68491 </indexterm>
68492 <option>lost_incoming_connection</option>: A log line is written when an incoming SMTP
68493 connection is unexpectedly dropped.
68494 </para>
68495 </listitem>
68496 <listitem>
68497 <para>
68498 <indexterm role="concept">
68499 <primary>log</primary>
68500 <secondary>millisecond timestamps</secondary>
68501 </indexterm>
68502 <indexterm role="concept">
68503 <primary>millisecond</primary>
68504 <secondary>logging</secondary>
68505 </indexterm>
68506 <indexterm role="concept">
68507 <primary>timestamps</primary>
68508 <secondary>millisecond, in logs</secondary>
68509 </indexterm>
68510 <option>millisec</option>: Timestamps have a period and three decimal places of finer granularity
68511 appended to the seconds value.
68512 </para>
68513 </listitem>
68514 <listitem>
68515 <para revisionflag="changed">
68516 <indexterm role="concept">
68517 <primary>log</primary>
68518 <secondary>message id</secondary>
68519 </indexterm>
68520 <option>msg_id</option>: The value of the Message-ID: header.
68521 </para>
68522 </listitem>
68523 <listitem>
68524 <para revisionflag="changed">
68525 <option>msg_id_created</option>: The value of the Message-ID: header, when one had to be created.
68526 This will be either because the message is a bounce, or was submitted locally
68527 (submission mode) without one.
68528 The field identifier will have an asterix appended: <quote>id*=</quote>.
68529 </para>
68530 </listitem>
68531 <listitem>
68532 <para>
68533 <indexterm role="concept">
68534 <primary>log</primary>
68535 <secondary>outgoing interface</secondary>
68536 </indexterm>
68537 <indexterm role="concept">
68538 <primary>log</primary>
68539 <secondary>local interface</secondary>
68540 </indexterm>
68541 <indexterm role="concept">
68542 <primary>log</primary>
68543 <secondary>local address and port</secondary>
68544 </indexterm>
68545 <indexterm role="concept">
68546 <primary>TCP/IP</primary>
68547 <secondary>logging local address and port</secondary>
68548 </indexterm>
68549 <indexterm role="concept">
68550 <primary>interface</primary>
68551 <secondary>logging</secondary>
68552 </indexterm>
68553 <option>outgoing_interface</option>: If <option>incoming_interface</option> is turned on, then the
68554 interface on which a message was sent is added to delivery lines as an I= tag
68555 followed by IP address in square brackets. You can disable this by turning
68556 off the <option>outgoing_interface</option> option.
68557 </para>
68558 </listitem>
68559 <listitem>
68560 <para>
68561 <indexterm role="concept">
68562 <primary>log</primary>
68563 <secondary>outgoing remote port</secondary>
68564 </indexterm>
68565 <indexterm role="concept">
68566 <primary>port</primary>
68567 <secondary>logging outgoing remote</secondary>
68568 </indexterm>
68569 <indexterm role="concept">
68570 <primary>TCP/IP</primary>
68571 <secondary>logging outgoing remote port</secondary>
68572 </indexterm>
68573 <option>outgoing_port</option>: The remote port number is added to delivery log lines (those
68574 containing =&gt; tags) following the IP address.
68575 The local port is also added if <option>incoming_interface</option> and
68576 <option>outgoing_interface</option> are both enabled.
68577 This option is not included in the default setting, because for most ordinary
68578 configurations, the remote port number is always 25 (the SMTP port), and the
68579 local port is a random ephemeral port.
68580 </para>
68581 </listitem>
68582 <listitem>
68583 <para>
68584 <indexterm role="concept">
68585 <primary>log</primary>
68586 <secondary>process ids in</secondary>
68587 </indexterm>
68588 <indexterm role="concept">
68589 <primary>pid (process id)</primary>
68590 <secondary>in log lines</secondary>
68591 </indexterm>
68592 <option>pid</option>: The current process id is added to every log line, in square brackets,
68593 immediately after the time and date.
68594 </para>
68595 </listitem>
68596 <listitem>
68597 <para>
68598 <indexterm role="concept">
68599 <primary>log</primary>
68600 <secondary>pipelining</secondary>
68601 </indexterm>
68602 <indexterm role="concept">
68603 <primary>pipelining</primary>
68604 <secondary>logging outgoing</secondary>
68605 </indexterm>
68606 <option>pipelining</option>: A field is added to delivery and accept
68607 log lines when the ESMTP PIPELINING extension was used.
68608 The field is a single "L".
68609 </para>
68610 <para>
68611 On accept lines, where PIPELINING was offered but not used by the client,
68612 the field has a minus appended.
68613 </para>
68614 <para revisionflag="changed">
68615 <indexterm role="concept">
68616 <primary>pipelining</primary>
68617 <secondary>early connection</secondary>
68618 </indexterm>
68619 If Exim is built with the SUPPORT_PIPE_CONNECT build option
68620 accept "L" fields have a period appended if the feature was
68621 offered but not used, or an asterisk appended if used.
68622 Delivery "L" fields have an asterisk appended if used.
68623 </para>
68624 </listitem>
68625 <listitem>
68626 <para>
68627 <indexterm role="concept">
68628 <primary>log</primary>
68629 <secondary>queue run</secondary>
68630 </indexterm>
68631 <indexterm role="concept">
68632 <primary>queue runner</primary>
68633 <secondary>logging</secondary>
68634 </indexterm>
68635 <option>queue_run</option>: The start and end of every queue run are logged.
68636 </para>
68637 </listitem>
68638 <listitem>
68639 <para>
68640 <indexterm role="concept">
68641 <primary>log</primary>
68642 <secondary>queue time</secondary>
68643 </indexterm>
68644 <option>queue_time</option>: The amount of time the message has been in the queue on the
68645 local host is logged as QT=&lt;<emphasis>time</emphasis>&gt; on delivery (<literal>=&gt;</literal>) lines, for example,
68646 <literal>QT=3m45s</literal>. The clock starts when Exim starts to receive the message, so it
68647 includes reception time as well as the delivery time for the current address.
68648 This means that it may be longer than the difference between the arrival and
68649 delivery log line times, because the arrival log line is not written until the
68650 message has been successfully received.
68651 If millisecond logging is enabled, short times will be shown with greater
68652 precision, eg. <literal>QT=1.578s</literal>.
68653 </para>
68654 </listitem>
68655 <listitem>
68656 <para>
68657 <option>queue_time_overall</option>: The amount of time the message has been in the queue on
68658 the local host is logged as QT=&lt;<emphasis>time</emphasis>&gt; on <quote>Completed</quote> lines, for
68659 example, <literal>QT=3m45s</literal>. The clock starts when Exim starts to receive the
68660 message, so it includes reception time as well as the total delivery time.
68661 </para>
68662 </listitem>
68663 <listitem>
68664 <para>
68665 <indexterm role="concept">
68666 <primary>log</primary>
68667 <secondary>receive duration</secondary>
68668 </indexterm>
68669 <option>receive_time</option>: For each message, the amount of real time it has taken to
68670 perform the reception is logged as RT=&lt;<emphasis>time</emphasis>&gt;, for example, <literal>RT=1s</literal>.
68671 If millisecond logging is enabled, short times will be shown with greater
68672 precision, eg. <literal>RT=0.204s</literal>.
68673 </para>
68674 </listitem>
68675 <listitem>
68676 <para>
68677 <indexterm role="concept">
68678 <primary>log</primary>
68679 <secondary>recipients</secondary>
68680 </indexterm>
68681 <option>received_recipients</option>: The recipients of a message are listed in the main log
68682 as soon as the message is received. The list appears at the end of the log line
68683 that is written when a message is received, preceded by the word <quote>for</quote>. The
68684 addresses are listed after they have been qualified, but before any rewriting
68685 has taken place.
68686 Recipients that were discarded by an ACL for MAIL or RCPT do not appear
68687 in the list.
68688 </para>
68689 </listitem>
68690 <listitem>
68691 <para>
68692 <indexterm role="concept">
68693 <primary>log</primary>
68694 <secondary>sender reception</secondary>
68695 </indexterm>
68696 <option>received_sender</option>: The unrewritten original sender of a message is added to
68697 the end of the log line that records the message&#x2019;s arrival, after the word
68698 <quote>from</quote> (before the recipients if <option>received_recipients</option> is also set).
68699 </para>
68700 </listitem>
68701 <listitem>
68702 <para>
68703 <indexterm role="concept">
68704 <primary>log</primary>
68705 <secondary>header lines for rejection</secondary>
68706 </indexterm>
68707 <option>rejected_header</option>: If a message&#x2019;s header has been received at the time a
68708 rejection is written to the reject log, the complete header is added to the
68709 log. Header logging can be turned off individually for messages that are
68710 rejected by the <function>local_scan()</function> function (see section <xref linkend="SECTapiforloc"/>).
68711 </para>
68712 </listitem>
68713 <listitem>
68714 <para>
68715 <indexterm role="concept">
68716 <primary>log</primary>
68717 <secondary>retry defer</secondary>
68718 </indexterm>
68719 <option>retry_defer</option>: A log line is written if a delivery is deferred because a
68720 retry time has not yet been reached. However, this <quote>retry time not reached</quote>
68721 message is always omitted from individual message logs after the first delivery
68722 attempt.
68723 </para>
68724 </listitem>
68725 <listitem>
68726 <para>
68727 <indexterm role="concept">
68728 <primary>log</primary>
68729 <secondary>return path</secondary>
68730 </indexterm>
68731 <option>return_path_on_delivery</option>: The return path that is being transmitted with
68732 the message is included in delivery and bounce lines, using the tag P=.
68733 This is omitted if no delivery actually happens, for example, if routing fails,
68734 or if delivery is to <filename>/dev/null</filename> or to <literal>:blackhole:</literal>.
68735 </para>
68736 </listitem>
68737 <listitem>
68738 <para>
68739 <indexterm role="concept">
68740 <primary>log</primary>
68741 <secondary>sender on delivery</secondary>
68742 </indexterm>
68743 <option>sender_on_delivery</option>: The message&#x2019;s sender address is added to every delivery
68744 and bounce line, tagged by F= (for <quote>from</quote>).
68745 This is the original sender that was received with the message; it is not
68746 necessarily the same as the outgoing return path.
68747 </para>
68748 </listitem>
68749 <listitem>
68750 <para>
68751 <indexterm role="concept">
68752 <primary>log</primary>
68753 <secondary>sender verify failure</secondary>
68754 </indexterm>
68755 <option>sender_verify_fail</option>: If this selector is unset, the separate log line that
68756 gives details of a sender verification failure is not written. Log lines for
68757 the rejection of SMTP commands contain just <quote>sender verify failed</quote>, so some
68758 detail is lost.
68759 </para>
68760 </listitem>
68761 <listitem>
68762 <para>
68763 <indexterm role="concept">
68764 <primary>log</primary>
68765 <secondary>size rejection</secondary>
68766 </indexterm>
68767 <option>size_reject</option>: A log line is written whenever a message is rejected because
68768 it is too big.
68769 </para>
68770 </listitem>
68771 <listitem>
68772 <para>
68773 <indexterm role="concept">
68774 <primary>log</primary>
68775 <secondary>frozen messages; skipped</secondary>
68776 </indexterm>
68777 <indexterm role="concept">
68778 <primary>frozen messages</primary>
68779 <secondary>logging skipping</secondary>
68780 </indexterm>
68781 <option>skip_delivery</option>: A log line is written whenever a message is skipped during a
68782 queue run because it is frozen or because another process is already delivering
68783 it.
68784 <indexterm role="concept">
68785 <primary><quote>spool file is locked</quote></primary>
68786 </indexterm>
68787 The message that is written is <quote>spool file is locked</quote>.
68788 </para>
68789 </listitem>
68790 <listitem>
68791 <para>
68792 <indexterm role="concept">
68793 <primary>log</primary>
68794 <secondary>smtp confirmation</secondary>
68795 </indexterm>
68796 <indexterm role="concept">
68797 <primary>SMTP</primary>
68798 <secondary>logging confirmation</secondary>
68799 </indexterm>
68800 <indexterm role="concept">
68801 <primary>LMTP</primary>
68802 <secondary>logging confirmation</secondary>
68803 </indexterm>
68804 <option>smtp_confirmation</option>: The response to the final <quote>.</quote> in the SMTP or LMTP dialogue for
68805 outgoing messages is added to delivery log lines in the form <literal>C=</literal>&lt;<emphasis>text</emphasis>&gt;.
68806 A number of MTAs (including Exim) return an identifying string in this
68807 response.
68808 </para>
68809 </listitem>
68810 <listitem>
68811 <para>
68812 <indexterm role="concept">
68813 <primary>log</primary>
68814 <secondary>SMTP connections</secondary>
68815 </indexterm>
68816 <indexterm role="concept">
68817 <primary>SMTP</primary>
68818 <secondary>logging connections</secondary>
68819 </indexterm>
68820 <option>smtp_connection</option>: A log line is written whenever an incoming SMTP connection is
68821 established or closed, unless the connection is from a host that matches
68822 <option>hosts_connection_nolog</option>. (In contrast, <option>lost_incoming_connection</option> applies
68823 only when the closure is unexpected.) This applies to connections from local
68824 processes that use <option>-bs</option> as well as to TCP/IP connections. If a connection is
68825 dropped in the middle of a message, a log line is always written, whether or
68826 not this selector is set, but otherwise nothing is written at the start and end
68827 of connections unless this selector is enabled.
68828 </para>
68829 <para>
68830 For TCP/IP connections to an Exim daemon, the current number of connections is
68831 included in the log message for each new connection, but note that the count is
68832 reset if the daemon is restarted.
68833 Also, because connections are closed (and the closure is logged) in
68834 subprocesses, the count may not include connections that have been closed but
68835 whose termination the daemon has not yet noticed. Thus, while it is possible to
68836 match up the opening and closing of connections in the log, the value of the
68837 logged counts may not be entirely accurate.
68838 </para>
68839 </listitem>
68840 <listitem>
68841 <para>
68842 <indexterm role="concept">
68843 <primary>log</primary>
68844 <secondary>SMTP transaction; incomplete</secondary>
68845 </indexterm>
68846 <indexterm role="concept">
68847 <primary>SMTP</primary>
68848 <secondary>logging incomplete transactions</secondary>
68849 </indexterm>
68850 <option>smtp_incomplete_transaction</option>: When a mail transaction is aborted by
68851 RSET, QUIT, loss of connection, or otherwise, the incident is logged,
68852 and the message sender plus any accepted recipients are included in the log
68853 line. This can provide evidence of dictionary attacks.
68854 </para>
68855 </listitem>
68856 <listitem>
68857 <para>
68858 <indexterm role="concept">
68859 <primary>log</primary>
68860 <secondary>non-MAIL SMTP sessions</secondary>
68861 </indexterm>
68862 <indexterm role="concept">
68863 <primary>MAIL</primary>
68864 <secondary>logging session without</secondary>
68865 </indexterm>
68866 <option>smtp_no_mail</option>: A line is written to the main log whenever an accepted SMTP
68867 connection terminates without having issued a MAIL command. This includes both
68868 the case when the connection is dropped, and the case when QUIT is used. It
68869 does not include cases where the connection is rejected right at the start (by
68870 an ACL, or because there are too many connections, or whatever). These cases
68871 already have their own log lines.
68872 </para>
68873 <para>
68874 The log line that is written contains the identity of the client in the usual
68875 way, followed by D= and a time, which records the duration of the connection.
68876 If the connection was authenticated, this fact is logged exactly as it is for
68877 an incoming message, with an A= item. If the connection was encrypted, CV=,
68878 DN=, and X= items may appear as they do for an incoming message, controlled by
68879 the same logging options.
68880 </para>
68881 <para>
68882 Finally, if any SMTP commands were issued during the connection, a C= item
68883 is added to the line, listing the commands that were used. For example,
68884 </para>
68885 <literallayout class="monospaced">
68886 C=EHLO,QUIT
68887 </literallayout>
68888 <para>
68889 shows that the client issued QUIT straight after EHLO. If there were fewer
68890 than 20 commands, they are all listed. If there were more than 20 commands,
68891 the last 20 are listed, preceded by <quote>...</quote>. However, with the default
68892 setting of 10 for <option>smtp_accept_max_nonmail</option>, the connection will in any case
68893 have been aborted before 20 non-mail commands are processed.
68894 </para>
68895 </listitem>
68896 <listitem>
68897 <para>
68898 <option>smtp_mailauth</option>: A third subfield with the authenticated sender,
68899 colon-separated, is appended to the A= item for a message arrival or delivery
68900 log line, if an AUTH argument to the SMTP MAIL command (see <xref linkend="SECTauthparamail"/>)
68901 was accepted or used.
68902 </para>
68903 </listitem>
68904 <listitem>
68905 <para>
68906 <indexterm role="concept">
68907 <primary>log</primary>
68908 <secondary>SMTP protocol error</secondary>
68909 </indexterm>
68910 <indexterm role="concept">
68911 <primary>SMTP</primary>
68912 <secondary>logging protocol error</secondary>
68913 </indexterm>
68914 <option>smtp_protocol_error</option>: A log line is written for every SMTP protocol error
68915 encountered. Exim does not have perfect detection of all protocol errors
68916 because of transmission delays and the use of pipelining. If PIPELINING has
68917 been advertised to a client, an Exim server assumes that the client will use
68918 it, and therefore it does not count <quote>expected</quote> errors (for example, RCPT
68919 received after rejecting MAIL) as protocol errors.
68920 </para>
68921 </listitem>
68922 <listitem>
68923 <para>
68924 <indexterm role="concept">
68925 <primary>SMTP</primary>
68926 <secondary>logging syntax errors</secondary>
68927 </indexterm>
68928 <indexterm role="concept">
68929 <primary>SMTP</primary>
68930 <secondary>syntax errors; logging</secondary>
68931 </indexterm>
68932 <indexterm role="concept">
68933 <primary>SMTP</primary>
68934 <secondary>unknown command; logging</secondary>
68935 </indexterm>
68936 <indexterm role="concept">
68937 <primary>log</primary>
68938 <secondary>unknown SMTP command</secondary>
68939 </indexterm>
68940 <indexterm role="concept">
68941 <primary>log</primary>
68942 <secondary>SMTP syntax error</secondary>
68943 </indexterm>
68944 <option>smtp_syntax_error</option>: A log line is written for every SMTP syntax error
68945 encountered. An unrecognized command is treated as a syntax error. For an
68946 external connection, the host identity is given; for an internal connection
68947 using <option>-bs</option> the sender identification (normally the calling user) is given.
68948 </para>
68949 </listitem>
68950 <listitem>
68951 <para>
68952 <indexterm role="concept">
68953 <primary>log</primary>
68954 <secondary>subject</secondary>
68955 </indexterm>
68956 <indexterm role="concept">
68957 <primary>subject, logging</primary>
68958 </indexterm>
68959 <option>subject</option>: The subject of the message is added to the arrival log line,
68960 preceded by <quote>T=</quote> (T for <quote>topic</quote>, since S is already used for <quote>size</quote>).
68961 Any MIME <quote>words</quote> in the subject are decoded. The <option>print_topbitchars</option> option
68962 specifies whether characters with values greater than 127 should be logged
68963 unchanged, or whether they should be rendered as escape sequences.
68964 </para>
68965 </listitem>
68966 <listitem>
68967 <para>
68968 <indexterm role="concept">
68969 <primary>log</primary>
68970 <secondary>certificate verification</secondary>
68971 </indexterm>
68972 <indexterm role="concept">
68973 <primary>log</primary>
68974 <secondary>DANE</secondary>
68975 </indexterm>
68976 <indexterm role="concept">
68977 <primary>DANE</primary>
68978 <secondary>logging</secondary>
68979 </indexterm>
68980 <option>tls_certificate_verified</option>: An extra item is added to &lt;= and =&gt; log lines
68981 when TLS is in use. The item is <literal>CV=yes</literal> if the peer&#x2019;s certificate was
68982 verified
68983 using a CA trust anchor,
68984 <literal>CA=dane</literal> if using a DNS trust anchor,
68985 and <literal>CV=no</literal> if not.
68986 </para>
68987 </listitem>
68988 <listitem>
68989 <para>
68990 <indexterm role="concept">
68991 <primary>log</primary>
68992 <secondary>TLS cipher</secondary>
68993 </indexterm>
68994 <indexterm role="concept">
68995 <primary>TLS</primary>
68996 <secondary>logging cipher</secondary>
68997 </indexterm>
68998 <option>tls_cipher</option>: When a message is sent or received over an encrypted
68999 connection, the cipher suite used is added to the log line, preceded by X=.
69000 </para>
69001 </listitem>
69002 <listitem>
69003 <para>
69004 <indexterm role="concept">
69005 <primary>log</primary>
69006 <secondary>TLS peer DN</secondary>
69007 </indexterm>
69008 <indexterm role="concept">
69009 <primary>TLS</primary>
69010 <secondary>logging peer DN</secondary>
69011 </indexterm>
69012 <option>tls_peerdn</option>: When a message is sent or received over an encrypted
69013 connection, and a certificate is supplied by the remote host, the peer DN is
69014 added to the log line, preceded by DN=.
69015 </para>
69016 </listitem>
69017 <listitem>
69018 <para>
69019 <indexterm role="concept">
69020 <primary>log</primary>
69021 <secondary>TLS SNI</secondary>
69022 </indexterm>
69023 <indexterm role="concept">
69024 <primary>TLS</primary>
69025 <secondary>logging SNI</secondary>
69026 </indexterm>
69027 <option>tls_sni</option>: When a message is received over an encrypted connection, and
69028 the remote host provided the Server Name Indication extension, the SNI is
69029 added to the log line, preceded by SNI=.
69030 </para>
69031 </listitem>
69032 <listitem>
69033 <para>
69034 <indexterm role="concept">
69035 <primary>log</primary>
69036 <secondary>DNS failure in list</secondary>
69037 </indexterm>
69038 <option>unknown_in_list</option>: This setting causes a log entry to be written when the
69039 result of a list match is failure because a DNS lookup failed.
69040 </para>
69041 </listitem>
69042 </itemizedlist>
69043 </section>
69044 <section id="SECID260">
69045 <title>Message log</title>
69046 <para>
69047 <indexterm role="concept">
69048 <primary>message</primary>
69049 <secondary>log file for</secondary>
69050 </indexterm>
69051 <indexterm role="concept">
69052 <primary>log</primary>
69053 <secondary>message log; description of</secondary>
69054 </indexterm>
69055 <indexterm role="concept">
69056 <primary><filename>msglog</filename> directory</primary>
69057 </indexterm>
69058 <indexterm role="option">
69059 <primary><option>preserve_message_logs</option></primary>
69060 </indexterm>
69061 In addition to the general log files, Exim writes a log file for each message
69062 that it handles. The names of these per-message logs are the message ids, and
69063 they are kept in the <filename>msglog</filename> sub-directory of the spool directory. Each
69064 message log contains copies of the log lines that apply to the message. This
69065 makes it easier to inspect the status of an individual message without having
69066 to search the main log. A message log is deleted when processing of the message
69067 is complete, unless <option>preserve_message_logs</option> is set, but this should be used
69068 only with great care because they can fill up your disk very quickly.
69069 </para>
69070 <para>
69071 On a heavily loaded system, it may be desirable to disable the use of
69072 per-message logs, in order to reduce disk I/O. This can be done by setting the
69073 <option>message_logs</option> option false.
69074 <indexterm role="concept" startref="IIDloggen" class="endofrange"/>
69075 </para>
69076 </section>
69077 </chapter>
69078
69079 <chapter id="CHAPutils">
69080 <title>Exim utilities</title>
69081 <para>
69082 <indexterm role="concept" id="IIDutils" class="startofrange">
69083 <primary>utilities</primary>
69084 </indexterm>
69085 A number of utility scripts and programs are supplied with Exim and are
69086 described in this chapter. There is also the Exim Monitor, which is covered in
69087 the next chapter. The utilities described here are:
69088 </para>
69089 <informaltable frame="none">
69090 <tgroup cols="3" colsep="0" rowsep="0">
69091 <colspec colwidth="7*" align="left"/>
69092 <colspec colwidth="15*" align="left"/>
69093 <colspec colwidth="40*" align="left"/>
69094 <tbody>
69095 <row>
69096 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTfinoutwha"/></entry>
69097 <entry><emphasis>exiwhat</emphasis></entry>
69098 <entry>list what Exim processes are doing</entry>
69099 </row>
69100 <row>
69101 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTgreptheque"/></entry>
69102 <entry><emphasis>exiqgrep</emphasis></entry>
69103 <entry>grep the queue</entry>
69104 </row>
69105 <row>
69106 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTsumtheque"/></entry>
69107 <entry><emphasis>exiqsumm</emphasis></entry>
69108 <entry>summarize the queue</entry>
69109 </row>
69110 <row>
69111 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTextspeinf"/></entry>
69112 <entry><emphasis>exigrep</emphasis></entry>
69113 <entry>search the main log</entry>
69114 </row>
69115 <row>
69116 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTexipick"/></entry>
69117 <entry><emphasis>exipick</emphasis></entry>
69118 <entry>select messages on various criteria</entry>
69119 </row>
69120 <row>
69121 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTcyclogfil"/></entry>
69122 <entry><emphasis>exicyclog</emphasis></entry>
69123 <entry>cycle (rotate) log files</entry>
69124 </row>
69125 <row>
69126 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTmailstat"/></entry>
69127 <entry><emphasis>eximstats</emphasis></entry>
69128 <entry>extract statistics from the log</entry>
69129 </row>
69130 <row>
69131 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTcheckaccess"/></entry>
69132 <entry><emphasis>exim_checkaccess</emphasis></entry>
69133 <entry>check address acceptance from given IP</entry>
69134 </row>
69135 <row>
69136 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTdbmbuild"/></entry>
69137 <entry><emphasis>exim_dbmbuild</emphasis></entry>
69138 <entry>build a DBM file</entry>
69139 </row>
69140 <row>
69141 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTfinindret"/></entry>
69142 <entry><emphasis>exinext</emphasis></entry>
69143 <entry>extract retry information</entry>
69144 </row>
69145 <row>
69146 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECThindatmai"/></entry>
69147 <entry><emphasis>exim_dumpdb</emphasis></entry>
69148 <entry>dump a hints database</entry>
69149 </row>
69150 <row>
69151 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECThindatmai"/></entry>
69152 <entry><emphasis>exim_tidydb</emphasis></entry>
69153 <entry>clean up a hints database</entry>
69154 </row>
69155 <row>
69156 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECThindatmai"/></entry>
69157 <entry><emphasis>exim_fixdb</emphasis></entry>
69158 <entry>patch a hints database</entry>
69159 </row>
69160 <row>
69161 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTmailboxmaint"/></entry>
69162 <entry><emphasis>exim_lock</emphasis></entry>
69163 <entry>lock a mailbox file</entry>
69164 </row>
69165 </tbody>
69166 </tgroup>
69167 </informaltable>
69168 <para>
69169 Another utility that might be of use to sites with many MTAs is Tom Kistner&#x2019;s
69170 <emphasis>exilog</emphasis>. It provides log visualizations across multiple Exim servers. See
69171 <emphasis role="bold"><ulink url="https://duncanthrax.net/exilog/">https://duncanthrax.net/exilog/</ulink></emphasis> for details.
69172 </para>
69173 <section id="SECTfinoutwha">
69174 <title>Finding out what Exim processes are doing (exiwhat)</title>
69175 <para>
69176 <indexterm role="concept">
69177 <primary><emphasis>exiwhat</emphasis></primary>
69178 </indexterm>
69179 <indexterm role="concept">
69180 <primary>process, querying</primary>
69181 </indexterm>
69182 <indexterm role="concept">
69183 <primary>SIGUSR1</primary>
69184 </indexterm>
69185 On operating systems that can restart a system call after receiving a signal
69186 (most modern OS), an Exim process responds to the SIGUSR1 signal by writing
69187 a line describing what it is doing to the file <filename>exim-process.info</filename> in the
69188 Exim spool directory. The <emphasis>exiwhat</emphasis> script sends the signal to all Exim
69189 processes it can find, having first emptied the file. It then waits for one
69190 second to allow the Exim processes to react before displaying the results. In
69191 order to run <emphasis>exiwhat</emphasis> successfully you have to have sufficient privilege to
69192 send the signal to the Exim processes, so it is normally run as root.
69193 </para>
69194 <para>
69195 <emphasis role="bold">Warning</emphasis>: This is not an efficient process. It is intended for occasional
69196 use by system administrators. It is not sensible, for example, to set up a
69197 script that sends SIGUSR1 signals to Exim processes at short intervals.
69198 </para>
69199 <para>
69200 Unfortunately, the <emphasis>ps</emphasis> command that <emphasis>exiwhat</emphasis> uses to find Exim processes
69201 varies in different operating systems. Not only are different options used,
69202 but the format of the output is different. For this reason, there are some
69203 system configuration options that configure exactly how <emphasis>exiwhat</emphasis> works. If
69204 it doesn&#x2019;t seem to be working for you, check the following compile-time
69205 options:
69206 </para>
69207 <literallayout>
69208 <literal>EXIWHAT_PS_CMD    </literal> the command for running <emphasis>ps</emphasis>
69209 <literal>EXIWHAT_PS_ARG    </literal> the argument for <emphasis>ps</emphasis>
69210 <literal>EXIWHAT_EGREP_ARG </literal> the argument for <emphasis>egrep</emphasis> to select from <emphasis>ps</emphasis> output
69211 <literal>EXIWHAT_KILL_ARG  </literal> the argument for the <emphasis>kill</emphasis> command
69212 </literallayout>
69213 <para>
69214 An example of typical output from <emphasis>exiwhat</emphasis> is
69215 </para>
69216 <literallayout class="monospaced">
69217 164 daemon: -q1h, listening on port 25
69218 10483 running queue: waiting for 0tAycK-0002ij-00 (10492)
69219 10492 delivering 0tAycK-0002ij-00 to mail.ref.example
69220   [10.19.42.42] (editor@ref.example)
69221 10592 handling incoming call from [192.168.243.242]
69222 10628 accepting a local non-SMTP message
69223 </literallayout>
69224 <para>
69225 The first number in the output line is the process number. The third line has
69226 been split here, in order to fit it on the page.
69227 </para>
69228 </section>
69229 <section id="SECTgreptheque">
69230 <title>Selective queue listing (exiqgrep)</title>
69231 <para>
69232 <indexterm role="concept">
69233 <primary><emphasis>exiqgrep</emphasis></primary>
69234 </indexterm>
69235 <indexterm role="concept">
69236 <primary>queue</primary>
69237 <secondary>grepping</secondary>
69238 </indexterm>
69239 This utility is a Perl script contributed by Matt Hubbard. It runs
69240 </para>
69241 <literallayout class="monospaced">
69242 exim -bpu
69243 </literallayout>
69244 <para>
69245 or (in case <emphasis role="bold">-a</emphasis> switch is specified)
69246 </para>
69247 <literallayout class="monospaced">
69248 exim -bp
69249 </literallayout>
69250 <para>
69251 The <emphasis role="bold">-C</emphasis> option is used to specify an alternate <filename>exim.conf</filename> which might
69252 contain alternate exim configuration the queue management might be using.
69253 </para>
69254 <para>
69255 to obtain a queue listing, and then greps the output to select messages
69256 that match given criteria. The following selection options are available:
69257 </para>
69258 <variablelist>
69259 <varlistentry>
69260 <term><emphasis role="bold">-f</emphasis>&nbsp;&lt;<emphasis>regex</emphasis>&gt;</term>
69261 <listitem>
69262 <para>
69263 Match the sender address using a case-insensitive search. The field that is
69264 tested is enclosed in angle brackets, so you can test for bounce messages with
69265 </para>
69266 <literallayout class="monospaced">
69267 exiqgrep -f '^&lt;&gt;$'
69268 </literallayout>
69269 </listitem></varlistentry>
69270 <varlistentry>
69271 <term><emphasis role="bold">-r</emphasis>&nbsp;&lt;<emphasis>regex</emphasis>&gt;</term>
69272 <listitem>
69273 <para>
69274 Match a recipient address using a case-insensitive search. The field that is
69275 tested is not enclosed in angle brackets.
69276 </para>
69277 </listitem></varlistentry>
69278 <varlistentry>
69279 <term><emphasis role="bold">-s</emphasis>&nbsp;&lt;<emphasis>regex</emphasis>&gt;</term>
69280 <listitem>
69281 <para>
69282 Match against the size field.
69283 </para>
69284 </listitem></varlistentry>
69285 <varlistentry>
69286 <term><emphasis role="bold">-y</emphasis>&nbsp;&lt;<emphasis>seconds</emphasis>&gt;</term>
69287 <listitem>
69288 <para>
69289 Match messages that are younger than the given time.
69290 </para>
69291 </listitem></varlistentry>
69292 <varlistentry>
69293 <term><emphasis role="bold">-o</emphasis>&nbsp;&lt;<emphasis>seconds</emphasis>&gt;</term>
69294 <listitem>
69295 <para>
69296 Match messages that are older than the given time.
69297 </para>
69298 </listitem></varlistentry>
69299 <varlistentry>
69300 <term><emphasis role="bold">-z</emphasis></term>
69301 <listitem>
69302 <para>
69303 Match only frozen messages.
69304 </para>
69305 </listitem></varlistentry>
69306 <varlistentry>
69307 <term><emphasis role="bold">-x</emphasis></term>
69308 <listitem>
69309 <para>
69310 Match only non-frozen messages.
69311 </para>
69312 </listitem></varlistentry>
69313 <varlistentry revisionflag="changed">
69314 <term><emphasis role="bold">-G</emphasis>&nbsp;&lt;<emphasis>queuename</emphasis>&gt;</term>
69315 <listitem>
69316 <para revisionflag="changed">
69317 Match only messages in the given queue.  Without this, the default queue is searched.
69318 </para>
69319 </listitem></varlistentry>
69320 </variablelist>
69321 <para>
69322 The following options control the format of the output:
69323 </para>
69324 <variablelist>
69325 <varlistentry>
69326 <term><emphasis role="bold">-c</emphasis></term>
69327 <listitem>
69328 <para>
69329 Display only the count of matching messages.
69330 </para>
69331 </listitem></varlistentry>
69332 <varlistentry>
69333 <term><emphasis role="bold">-l</emphasis></term>
69334 <listitem>
69335 <para>
69336 Long format &ndash; display the full message information as output by Exim. This is
69337 the default.
69338 </para>
69339 </listitem></varlistentry>
69340 <varlistentry>
69341 <term><emphasis role="bold">-i</emphasis></term>
69342 <listitem>
69343 <para>
69344 Display message ids only.
69345 </para>
69346 </listitem></varlistentry>
69347 <varlistentry>
69348 <term><emphasis role="bold">-b</emphasis></term>
69349 <listitem>
69350 <para>
69351 Brief format &ndash; one line per message.
69352 </para>
69353 </listitem></varlistentry>
69354 <varlistentry>
69355 <term><emphasis role="bold">-R</emphasis></term>
69356 <listitem>
69357 <para>
69358 Display messages in reverse order.
69359 </para>
69360 </listitem></varlistentry>
69361 <varlistentry>
69362 <term><emphasis role="bold">-a</emphasis></term>
69363 <listitem>
69364 <para>
69365 Include delivered recipients in queue listing.
69366 </para>
69367 </listitem></varlistentry>
69368 </variablelist>
69369 <para>
69370 There is one more option, <option>-h</option>, which outputs a list of options.
69371 </para>
69372 </section>
69373 <section id="SECTsumtheque">
69374 <title>Summarizing the queue (exiqsumm)</title>
69375 <para>
69376 <indexterm role="concept">
69377 <primary><emphasis>exiqsumm</emphasis></primary>
69378 </indexterm>
69379 <indexterm role="concept">
69380 <primary>queue</primary>
69381 <secondary>summary</secondary>
69382 </indexterm>
69383 The <emphasis>exiqsumm</emphasis> utility is a Perl script which reads the output of <literal>exim
69384 -bp</literal> and produces a summary of the messages in the queue. Thus, you use it by
69385 running a command such as
69386 </para>
69387 <literallayout class="monospaced">
69388 exim -bp | exiqsumm
69389 </literallayout>
69390 <para>
69391 The output consists of one line for each domain that has messages waiting for
69392 it, as in the following example:
69393 </para>
69394 <literallayout class="monospaced">
69395 3   2322   74m   66m  msn.com.example
69396 </literallayout>
69397 <para>
69398 Each line lists the number of pending deliveries for a domain, their total
69399 volume, and the length of time that the oldest and the newest messages have
69400 been waiting. Note that the number of pending deliveries is greater than the
69401 number of messages when messages have more than one recipient.
69402 </para>
69403 <para>
69404 A summary line is output at the end. By default the output is sorted on the
69405 domain name, but <emphasis>exiqsumm</emphasis> has the options <option>-a</option> and <option>-c</option>, which cause
69406 the output to be sorted by oldest message and by count of messages,
69407 respectively. There are also three options that split the messages for each
69408 domain into two or more subcounts: <option>-b</option> separates bounce messages, <option>-f</option>
69409 separates frozen messages, and <option>-s</option> separates messages according to their
69410 sender.
69411 </para>
69412 <para>
69413 The output of <emphasis>exim -bp</emphasis> contains the original addresses in the message, so
69414 this also applies to the output from <emphasis>exiqsumm</emphasis>. No domains from addresses
69415 generated by aliasing or forwarding are included (unless the <option>one_time</option>
69416 option of the <command>redirect</command> router has been used to convert them into <quote>top
69417 level</quote> addresses).
69418 </para>
69419 </section>
69420 <section id="SECTextspeinf">
69421 <title>Extracting specific information from the log (exigrep)</title>
69422 <para>
69423 <indexterm role="concept">
69424 <primary><emphasis>exigrep</emphasis></primary>
69425 </indexterm>
69426 <indexterm role="concept">
69427 <primary>log</primary>
69428 <secondary>extracts; grepping for</secondary>
69429 </indexterm>
69430 The <emphasis>exigrep</emphasis> utility is a Perl script that searches one or more main log
69431 files for entries that match a given pattern. When it finds a match, it
69432 extracts all the log entries for the relevant message, not just those that
69433 match the pattern. Thus, <emphasis>exigrep</emphasis> can extract complete log entries for a
69434 given message, or all mail for a given user, or for a given host, for example.
69435 The input files can be in Exim log format or syslog format.
69436 If a matching log line is not associated with a specific message, it is
69437 included in <emphasis>exigrep</emphasis>&#x2019;s output without any additional lines. The usage is:
69438 </para>
69439 <literallayout>
69440 <literal>exigrep [-t&lt;</literal><emphasis>n</emphasis><literal>&gt;] [-I] [-l] [-M] [-v] &lt;</literal><emphasis>pattern</emphasis><literal>&gt; [&lt;</literal><emphasis>log file</emphasis><literal>&gt;] ...</literal>
69441 </literallayout>
69442 <para>
69443 If no log filenames are given on the command line, the standard input is read.
69444 </para>
69445 <para>
69446 The <option>-t</option> argument specifies a number of seconds. It adds an additional
69447 condition for message selection. Messages that are complete are shown only if
69448 they spent more than &lt;<emphasis>n</emphasis>&gt; seconds in the queue.
69449 </para>
69450 <para>
69451 By default, <emphasis>exigrep</emphasis> does case-insensitive matching. The <option>-I</option> option
69452 makes it case-sensitive. This may give a performance improvement when searching
69453 large log files. Without <option>-I</option>, the Perl pattern matches use Perl&#x2019;s <literal>/i</literal>
69454 option; with <option>-I</option> they do not. In both cases it is possible to change the
69455 case sensitivity within the pattern by using <literal>(?i)</literal> or <literal>(?-i)</literal>.
69456 </para>
69457 <para>
69458 The <option>-l</option> option means <quote>literal</quote>, that is, treat all characters in the
69459 pattern as standing for themselves. Otherwise the pattern must be a Perl
69460 regular expression.
69461 </para>
69462 <para>
69463 The <option>-v</option> option inverts the matching condition. That is, a line is selected
69464 if it does <emphasis>not</emphasis> match the pattern.
69465 </para>
69466 <para>
69467 The <option>-M</option> options means <quote>related messages</quote>. <emphasis>exigrep</emphasis> will show messages
69468 that are generated as a result/response to a message that <emphasis>exigrep</emphasis> matched
69469 normally.
69470 </para>
69471 <para>
69472 Example of <option>-M</option>:
69473 user_a sends a message to user_b, which generates a bounce back to user_b. If
69474 <emphasis>exigrep</emphasis> is used to search for <quote>user_a</quote>, only the first message will be
69475 displayed.  But if <emphasis>exigrep</emphasis> is used to search for <quote>user_b</quote>, the first and
69476 the second (bounce) message will be displayed. Using <option>-M</option> with <emphasis>exigrep</emphasis>
69477 when searching for <quote>user_a</quote> will show both messages since the bounce is
69478 <quote>related</quote> to or a <quote>result</quote> of the first message that was found by the
69479 search term.
69480 </para>
69481 <para>
69482 If the location of a <emphasis>zcat</emphasis> command is known from the definition of
69483 ZCAT_COMMAND in <filename>Local/Makefile</filename>, <emphasis>exigrep</emphasis> automatically passes any file
69484 whose name ends in COMPRESS_SUFFIX through <emphasis>zcat</emphasis> as it searches it.
69485 If the ZCAT_COMMAND is not executable, <emphasis>exigrep</emphasis> tries to use
69486 autodetection of some well known compression extensions.
69487 </para>
69488 </section>
69489 <section id="SECTexipick">
69490 <title>Selecting messages by various criteria (exipick)</title>
69491 <para>
69492 <indexterm role="concept">
69493 <primary><emphasis>exipick</emphasis></primary>
69494 </indexterm>
69495 John Jetmore&#x2019;s <emphasis>exipick</emphasis> utility is included in the Exim distribution. It
69496 lists messages from the queue according to a variety of criteria. For details
69497 of <emphasis>exipick</emphasis>&#x2019;s facilities, run <emphasis>exipick</emphasis> with
69498 the <option>--help</option> option.
69499 </para>
69500 </section>
69501 <section id="SECTcyclogfil">
69502 <title>Cycling log files (exicyclog)</title>
69503 <para>
69504 <indexterm role="concept">
69505 <primary>log</primary>
69506 <secondary>cycling local files</secondary>
69507 </indexterm>
69508 <indexterm role="concept">
69509 <primary>cycling logs</primary>
69510 </indexterm>
69511 <indexterm role="concept">
69512 <primary><emphasis>exicyclog</emphasis></primary>
69513 </indexterm>
69514 The <emphasis>exicyclog</emphasis> script can be used to cycle (rotate) <emphasis>mainlog</emphasis> and
69515 <emphasis>rejectlog</emphasis> files. This is not necessary if only syslog is being used, or if
69516 you are using log files with datestamps in their names (see section
69517 <xref linkend="SECTdatlogfil"/>). Some operating systems have their own standard mechanisms
69518 for log cycling, and these can be used instead of <emphasis>exicyclog</emphasis> if preferred.
69519 There are two command line options for <emphasis>exicyclog</emphasis>:
69520 </para>
69521 <itemizedlist>
69522 <listitem>
69523 <para>
69524 <option>-k</option> &lt;<emphasis>count</emphasis>&gt; specifies the number of log files to keep, overriding the
69525 default that is set when Exim is built. The default default is 10.
69526 </para>
69527 </listitem>
69528 <listitem>
69529 <para>
69530 <option>-l</option> &lt;<emphasis>path</emphasis>&gt; specifies the log file path, in the same format as Exim&#x2019;s
69531 <option>log_file_path</option> option (for example, <literal>/var/log/exim_%slog</literal>), again
69532 overriding the script&#x2019;s default, which is to find the setting from Exim&#x2019;s
69533 configuration.
69534 </para>
69535 </listitem>
69536 </itemizedlist>
69537 <para>
69538 Each time <emphasis>exicyclog</emphasis> is run the filenames get <quote>shuffled down</quote> by one. If
69539 the main log filename is <filename>mainlog</filename> (the default) then when <emphasis>exicyclog</emphasis> is
69540 run <filename>mainlog</filename> becomes <filename>mainlog.01</filename>, the previous <filename>mainlog.01</filename> becomes
69541 <filename>mainlog.02</filename> and so on, up to the limit that is set in the script or by the
69542 <option>-k</option> option. Log files whose numbers exceed the limit are discarded. Reject
69543 logs are handled similarly.
69544 </para>
69545 <para>
69546 If the limit is greater than 99, the script uses 3-digit numbers such as
69547 <filename>mainlog.001</filename>, <filename>mainlog.002</filename>, etc. If you change from a number less than 99
69548 to one that is greater, or <emphasis>vice versa</emphasis>, you will have to fix the names of
69549 any existing log files.
69550 </para>
69551 <para>
69552 If no <filename>mainlog</filename> file exists, the script does nothing. Files that <quote>drop off</quote>
69553 the end are deleted. All files with numbers greater than 01 are compressed,
69554 using a compression command which is configured by the COMPRESS_COMMAND
69555 setting in <filename>Local/Makefile</filename>. It is usual to run <emphasis>exicyclog</emphasis> daily from a
69556 root <option>crontab</option> entry of the form
69557 </para>
69558 <literallayout class="monospaced">
69559 1 0 * * * su exim -c /usr/exim/bin/exicyclog
69560 </literallayout>
69561 <para>
69562 assuming you have used the name <quote>exim</quote> for the Exim user. You can run
69563 <emphasis>exicyclog</emphasis> as root if you wish, but there is no need.
69564 </para>
69565 </section>
69566 <section id="SECTmailstat">
69567 <title>Mail statistics (eximstats)</title>
69568 <para>
69569 <indexterm role="concept">
69570 <primary>statistics</primary>
69571 </indexterm>
69572 <indexterm role="concept">
69573 <primary><emphasis>eximstats</emphasis></primary>
69574 </indexterm>
69575 A Perl script called <emphasis>eximstats</emphasis> is provided for extracting statistical
69576 information from log files. The output is either plain text, or HTML.
69577 </para>
69578 <para>
69579 The <emphasis>eximstats</emphasis> script has been hacked about quite a bit over time. The
69580 latest version is the result of some extensive revision by Steve Campbell. A
69581 lot of information is given by default, but there are options for suppressing
69582 various parts of it. Following any options, the arguments to the script are a
69583 list of files, which should be main log files. For example:
69584 </para>
69585 <literallayout class="monospaced">
69586 eximstats -nr /var/spool/exim/log/mainlog.01
69587 </literallayout>
69588 <para>
69589 By default, <emphasis>eximstats</emphasis> extracts information about the number and volume of
69590 messages received from or delivered to various hosts. The information is sorted
69591 both by message count and by volume, and the top fifty hosts in each category
69592 are listed on the standard output. Similar information, based on email
69593 addresses or domains instead of hosts can be requested by means of various
69594 options. For messages delivered and received locally, similar statistics are
69595 also produced per user.
69596 </para>
69597 <para>
69598 The output also includes total counts and statistics about delivery errors, and
69599 histograms showing the number of messages received and deliveries made in each
69600 hour of the day. A delivery with more than one address in its envelope (for
69601 example, an SMTP transaction with more than one RCPT command) is counted
69602 as a single delivery by <emphasis>eximstats</emphasis>.
69603 </para>
69604 <para>
69605 Though normally more deliveries than receipts are reported (as messages may
69606 have multiple recipients), it is possible for <emphasis>eximstats</emphasis> to report more
69607 messages received than delivered, even though the queue is empty at the start
69608 and end of the period in question. If an incoming message contains no valid
69609 recipients, no deliveries are recorded for it. A bounce message is handled as
69610 an entirely separate message.
69611 </para>
69612 <para>
69613 <emphasis>eximstats</emphasis> always outputs a grand total summary giving the volume and number
69614 of messages received and deliveries made, and the number of hosts involved in
69615 each case. It also outputs the number of messages that were delayed (that is,
69616 not completely delivered at the first attempt), and the number that had at
69617 least one address that failed.
69618 </para>
69619 <para>
69620 The remainder of the output is in sections that can be independently disabled
69621 or modified by various options. It consists of a summary of deliveries by
69622 transport, histograms of messages received and delivered per time interval
69623 (default per hour), information about the time messages spent in the queue,
69624 a list of relayed messages, lists of the top fifty sending hosts, local
69625 senders, destination hosts, and destination local users by count and by volume,
69626 and a list of delivery errors that occurred.
69627 </para>
69628 <para>
69629 The relay information lists messages that were actually relayed, that is, they
69630 came from a remote host and were directly delivered to some other remote host,
69631 without being processed (for example, for aliasing or forwarding) locally.
69632 </para>
69633 <para>
69634 There are quite a few options for <emphasis>eximstats</emphasis> to control exactly what it
69635 outputs. These are documented in the Perl script itself, and can be extracted
69636 by running the command <command>perldoc</command> on the script. For example:
69637 </para>
69638 <literallayout class="monospaced">
69639 perldoc /usr/exim/bin/eximstats
69640 </literallayout>
69641 </section>
69642 <section id="SECTcheckaccess">
69643 <title>Checking access policy (exim_checkaccess)</title>
69644 <para>
69645 <indexterm role="concept">
69646 <primary><emphasis>exim_checkaccess</emphasis></primary>
69647 </indexterm>
69648 <indexterm role="concept">
69649 <primary>policy control</primary>
69650 <secondary>checking access</secondary>
69651 </indexterm>
69652 <indexterm role="concept">
69653 <primary>checking access</primary>
69654 </indexterm>
69655 The <option>-bh</option> command line argument allows you to run a fake SMTP session with
69656 debugging output, in order to check what Exim is doing when it is applying
69657 policy controls to incoming SMTP mail. However, not everybody is sufficiently
69658 familiar with the SMTP protocol to be able to make full use of <option>-bh</option>, and
69659 sometimes you just want to answer the question <quote>Does this address have
69660 access?</quote> without bothering with any further details.
69661 </para>
69662 <para>
69663 The <emphasis>exim_checkaccess</emphasis> utility is a <quote>packaged</quote> version of <option>-bh</option>. It takes
69664 two arguments, an IP address and an email address:
69665 </para>
69666 <literallayout class="monospaced">
69667 exim_checkaccess 10.9.8.7 A.User@a.domain.example
69668 </literallayout>
69669 <para>
69670 The utility runs a call to Exim with the <option>-bh</option> option, to test whether the
69671 given email address would be accepted in a RCPT command in a TCP/IP
69672 connection from the host with the given IP address. The output of the utility
69673 is either the word <quote>accepted</quote>, or the SMTP error response, for example:
69674 </para>
69675 <literallayout class="monospaced">
69676 Rejected:
69677 550 Relay not permitted
69678 </literallayout>
69679 <para>
69680 When running this test, the utility uses <literal>&lt;&gt;</literal> as the envelope sender address
69681 for the MAIL command, but you can change this by providing additional
69682 options. These are passed directly to the Exim command. For example, to specify
69683 that the test is to be run with the sender address <emphasis>himself@there.example</emphasis>
69684 you can use:
69685 </para>
69686 <literallayout class="monospaced">
69687 exim_checkaccess 10.9.8.7 A.User@a.domain.example \
69688                  -f himself@there.example
69689 </literallayout>
69690 <para>
69691 Note that these additional Exim command line items must be given after the two
69692 mandatory arguments.
69693 </para>
69694 <para>
69695 Because the <option>exim_checkaccess</option> uses <option>-bh</option>, it does not perform callouts
69696 while running its checks. You can run checks that include callouts by using
69697 <option>-bhc</option>, but this is not yet available in a <quote>packaged</quote> form.
69698 </para>
69699 </section>
69700 <section id="SECTdbmbuild">
69701 <title>Making DBM files (exim_dbmbuild)</title>
69702 <para>
69703 <indexterm role="concept">
69704 <primary>DBM</primary>
69705 <secondary>building dbm files</secondary>
69706 </indexterm>
69707 <indexterm role="concept">
69708 <primary>building DBM files</primary>
69709 </indexterm>
69710 <indexterm role="concept">
69711 <primary><emphasis>exim_dbmbuild</emphasis></primary>
69712 </indexterm>
69713 <indexterm role="concept">
69714 <primary>lower casing</primary>
69715 </indexterm>
69716 <indexterm role="concept">
69717 <primary>binary zero</primary>
69718 <secondary>in lookup key</secondary>
69719 </indexterm>
69720 The <emphasis>exim_dbmbuild</emphasis> program reads an input file containing keys and data in
69721 the format used by the <command>lsearch</command> lookup (see section
69722 <xref linkend="SECTsinglekeylookups"/>). It writes a DBM file using the lower-cased alias
69723 names as keys and the remainder of the information as data. The lower-casing
69724 can be prevented by calling the program with the <option>-nolc</option> option.
69725 </para>
69726 <para>
69727 A terminating zero is included as part of the key string. This is expected by
69728 the <command>dbm</command> lookup type. However, if the option <option>-nozero</option> is given,
69729 <emphasis>exim_dbmbuild</emphasis> creates files without terminating zeroes in either the key
69730 strings or the data strings. The <command>dbmnz</command> lookup type can be used with such
69731 files.
69732 </para>
69733 <para>
69734 The program requires two arguments: the name of the input file (which can be a
69735 single hyphen to indicate the standard input), and the name of the output file.
69736 It creates the output under a temporary name, and then renames it if all went
69737 well.
69738 </para>
69739 <para>
69740 <indexterm role="concept">
69741 <primary>USE_DB</primary>
69742 </indexterm>
69743 If the native DB interface is in use (USE_DB is set in a compile-time
69744 configuration file &ndash; this is common in free versions of Unix) the two
69745 filenames must be different, because in this mode the Berkeley DB functions
69746 create a single output file using exactly the name given. For example,
69747 </para>
69748 <literallayout class="monospaced">
69749 exim_dbmbuild /etc/aliases /etc/aliases.db
69750 </literallayout>
69751 <para>
69752 reads the system alias file and creates a DBM version of it in
69753 <filename>/etc/aliases.db</filename>.
69754 </para>
69755 <para>
69756 In systems that use the <emphasis>ndbm</emphasis> routines (mostly proprietary versions of
69757 Unix), two files are used, with the suffixes <filename>.dir</filename> and <filename>.pag</filename>. In this
69758 environment, the suffixes are added to the second argument of
69759 <emphasis>exim_dbmbuild</emphasis>, so it can be the same as the first. This is also the case
69760 when the Berkeley functions are used in compatibility mode (though this is not
69761 recommended), because in that case it adds a <filename>.db</filename> suffix to the filename.
69762 </para>
69763 <para>
69764 If a duplicate key is encountered, the program outputs a warning, and when it
69765 finishes, its return code is 1 rather than zero, unless the <option>-noduperr</option>
69766 option is used. By default, only the first of a set of duplicates is used &ndash;
69767 this makes it compatible with <command>lsearch</command> lookups. There is an option
69768 <option>-lastdup</option> which causes it to use the data for the last duplicate instead.
69769 There is also an option <option>-nowarn</option>, which stops it listing duplicate keys to
69770 <option>stderr</option>. For other errors, where it doesn&#x2019;t actually make a new file, the
69771 return code is 2.
69772 </para>
69773 </section>
69774 <section id="SECTfinindret">
69775 <title>Finding individual retry times (exinext)</title>
69776 <para>
69777 <indexterm role="concept">
69778 <primary>retry</primary>
69779 <secondary>times</secondary>
69780 </indexterm>
69781 <indexterm role="concept">
69782 <primary><emphasis>exinext</emphasis></primary>
69783 </indexterm>
69784 A utility called <emphasis>exinext</emphasis> (mostly a Perl script) provides the ability to
69785 fish specific information out of the retry database. Given a mail domain (or a
69786 complete address), it looks up the hosts for that domain, and outputs any retry
69787 information for the hosts or for the domain. At present, the retry information
69788 is obtained by running <emphasis>exim_dumpdb</emphasis> (see below) and post-processing the
69789 output. For example:
69790 </para>
69791 <literallayout class="monospaced">
69792 $ exinext piglet@milne.fict.example
69793 kanga.milne.example:192.168.8.1 error 146: Connection refused
69794   first failed: 21-Feb-1996 14:57:34
69795   last tried:   21-Feb-1996 14:57:34
69796   next try at:  21-Feb-1996 15:02:34
69797 roo.milne.example:192.168.8.3 error 146: Connection refused
69798   first failed: 20-Jan-1996 13:12:08
69799   last tried:   21-Feb-1996 11:42:03
69800   next try at:  21-Feb-1996 19:42:03
69801   past final cutoff time
69802 </literallayout>
69803 <para>
69804 You can also give <emphasis>exinext</emphasis> a local part, without a domain, and it
69805 will give any retry information for that local part in your default domain.
69806 A message id can be used to obtain retry information pertaining to a specific
69807 message. This exists only when an attempt to deliver a message to a remote host
69808 suffers a message-specific error (see section <xref linkend="SECToutSMTPerr"/>).
69809 <emphasis>exinext</emphasis> is not particularly efficient, but then it is not expected to be
69810 run very often.
69811 </para>
69812 <para>
69813 The <emphasis>exinext</emphasis> utility calls Exim to find out information such as the location
69814 of the spool directory. The utility has <option>-C</option> and <option>-D</option> options, which are
69815 passed on to the <emphasis>exim</emphasis> commands. The first specifies an alternate Exim
69816 configuration file, and the second sets macros for use within the configuration
69817 file. These features are mainly to help in testing, but might also be useful in
69818 environments where more than one configuration file is in use.
69819 </para>
69820 </section>
69821 <section id="SECThindatmai">
69822 <title>Hints database maintenance</title>
69823 <para>
69824 <indexterm role="concept">
69825 <primary>hints database</primary>
69826 <secondary>maintenance</secondary>
69827 </indexterm>
69828 <indexterm role="concept">
69829 <primary>maintaining Exim&#x2019;s hints database</primary>
69830 </indexterm>
69831 Three utility programs are provided for maintaining the DBM files that Exim
69832 uses to contain its delivery hint information. Each program requires two
69833 arguments. The first specifies the name of Exim&#x2019;s spool directory, and the
69834 second is the name of the database it is to operate on. These are as follows:
69835 </para>
69836 <itemizedlist>
69837 <listitem>
69838 <para>
69839 <emphasis>retry</emphasis>: the database of retry information
69840 </para>
69841 </listitem>
69842 <listitem>
69843 <para>
69844 <emphasis>wait-</emphasis>&lt;<emphasis>transport name</emphasis>&gt;: databases of information about messages waiting
69845 for remote hosts
69846 </para>
69847 </listitem>
69848 <listitem>
69849 <para>
69850 <emphasis>callout</emphasis>: the callout cache
69851 </para>
69852 </listitem>
69853 <listitem>
69854 <para>
69855 <emphasis>ratelimit</emphasis>: the data for implementing the ratelimit ACL condition
69856 </para>
69857 </listitem>
69858 <listitem>
69859 <para>
69860 <emphasis>misc</emphasis>: other hints data
69861 </para>
69862 </listitem>
69863 </itemizedlist>
69864 <para>
69865 The <emphasis>misc</emphasis> database is used for
69866 </para>
69867 <itemizedlist>
69868 <listitem>
69869 <para>
69870 Serializing ETRN runs (when <option>smtp_etrn_serialize</option> is set)
69871 </para>
69872 </listitem>
69873 <listitem>
69874 <para>
69875 Serializing delivery to a specific host (when <option>serialize_hosts</option> is set in an
69876 <command>smtp</command> transport)
69877 </para>
69878 </listitem>
69879 <listitem>
69880 <para>
69881 Limiting the concurrency of specific transports (when <option>max_parallel</option> is set
69882 in a transport)
69883 </para>
69884 </listitem>
69885 </itemizedlist>
69886 </section>
69887 <section id="SECID261">
69888 <title>exim_dumpdb</title>
69889 <para>
69890 <indexterm role="concept">
69891 <primary><emphasis>exim_dumpdb</emphasis></primary>
69892 </indexterm>
69893 The entire contents of a database are written to the standard output by the
69894 <emphasis>exim_dumpdb</emphasis> program, which has no options or arguments other than the
69895 spool and database names. For example, to dump the retry database:
69896 </para>
69897 <literallayout class="monospaced">
69898 exim_dumpdb /var/spool/exim retry
69899 </literallayout>
69900 <para>
69901 Two lines of output are produced for each entry:
69902 </para>
69903 <literallayout class="monospaced">
69904 T:mail.ref.example:192.168.242.242 146 77 Connection refused
69905 31-Oct-1995 12:00:12 02-Nov-1995 12:21:39 02-Nov-1995 20:21:39 *
69906 </literallayout>
69907 <para>
69908 The first item on the first line is the key of the record. It starts with one
69909 of the letters R, or T, depending on whether it refers to a routing or
69910 transport retry. For a local delivery, the next part is the local address; for
69911 a remote delivery it is the name of the remote host, followed by its failing IP
69912 address (unless <option>retry_include_ip_address</option> is set false on the <command>smtp</command>
69913 transport). If the remote port is not the standard one (port 25), it is added
69914 to the IP address. Then there follows an error code, an additional error code,
69915 and a textual description of the error.
69916 </para>
69917 <para>
69918 The three times on the second line are the time of first failure, the time of
69919 the last delivery attempt, and the computed time for the next attempt. The line
69920 ends with an asterisk if the cutoff time for the last retry rule has been
69921 exceeded.
69922 </para>
69923 <para>
69924 Each output line from <emphasis>exim_dumpdb</emphasis> for the <emphasis>wait-xxx</emphasis> databases
69925 consists of a host name followed by a list of ids for messages that are or were
69926 waiting to be delivered to that host. If there are a very large number for any
69927 one host, continuation records, with a sequence number added to the host name,
69928 may be seen. The data in these records is often out of date, because a message
69929 may be routed to several alternative hosts, and Exim makes no effort to keep
69930 cross-references.
69931 </para>
69932 </section>
69933 <section id="SECID262">
69934 <title>exim_tidydb</title>
69935 <para>
69936 <indexterm role="concept">
69937 <primary><emphasis>exim_tidydb</emphasis></primary>
69938 </indexterm>
69939 The <emphasis>exim_tidydb</emphasis> utility program is used to tidy up the contents of a hints
69940 database. If run with no options, it removes all records that are more than 30
69941 days old. The age is calculated from the date and time that the record was last
69942 updated. Note that, in the case of the retry database, it is <emphasis>not</emphasis> the time
69943 since the first delivery failure. Information about a host that has been down
69944 for more than 30 days will remain in the database, provided that the record is
69945 updated sufficiently often.
69946 </para>
69947 <para>
69948 The cutoff date can be altered by means of the <option>-t</option> option, which must be
69949 followed by a time. For example, to remove all records older than a week from
69950 the retry database:
69951 </para>
69952 <literallayout class="monospaced">
69953 exim_tidydb -t 7d /var/spool/exim retry
69954 </literallayout>
69955 <para>
69956 Both the <emphasis>wait-xxx</emphasis> and <emphasis>retry</emphasis> databases contain items that involve
69957 message ids. In the former these appear as data in records keyed by host &ndash;
69958 they were messages that were waiting for that host &ndash; and in the latter they
69959 are the keys for retry information for messages that have suffered certain
69960 types of error. When <emphasis>exim_tidydb</emphasis> is run, a check is made to ensure that
69961 message ids in database records are those of messages that are still on the
69962 queue. Message ids for messages that no longer exist are removed from
69963 <emphasis>wait-xxx</emphasis> records, and if this leaves any records empty, they are deleted.
69964 For the <emphasis>retry</emphasis> database, records whose keys are non-existent message ids are
69965 removed. The <emphasis>exim_tidydb</emphasis> utility outputs comments on the standard output
69966 whenever it removes information from the database.
69967 </para>
69968 <para>
69969 Certain records are automatically removed by Exim when they are no longer
69970 needed, but others are not. For example, if all the MX hosts for a domain are
69971 down, a retry record is created for each one. If the primary MX host comes back
69972 first, its record is removed when Exim successfully delivers to it, but the
69973 records for the others remain because Exim has not tried to use those hosts.
69974 </para>
69975 <para>
69976 It is important, therefore, to run <emphasis>exim_tidydb</emphasis> periodically on all the
69977 hints databases. You should do this at a quiet time of day, because it requires
69978 a database to be locked (and therefore inaccessible to Exim) while it does its
69979 work. Removing records from a DBM file does not normally make the file smaller,
69980 but all the common DBM libraries are able to re-use the space that is released.
69981 After an initial phase of increasing in size, the databases normally reach a
69982 point at which they no longer get any bigger, as long as they are regularly
69983 tidied.
69984 </para>
69985 <para>
69986 <emphasis role="bold">Warning</emphasis>: If you never run <emphasis>exim_tidydb</emphasis>, the space used by the hints
69987 databases is likely to keep on increasing.
69988 </para>
69989 </section>
69990 <section id="SECID263">
69991 <title>exim_fixdb</title>
69992 <para>
69993 <indexterm role="concept">
69994 <primary><emphasis>exim_fixdb</emphasis></primary>
69995 </indexterm>
69996 The <emphasis>exim_fixdb</emphasis> program is a utility for interactively modifying databases.
69997 Its main use is for testing Exim, but it might also be occasionally useful for
69998 getting round problems in a live system. It has no options, and its interface
69999 is somewhat crude. On entry, it prompts for input with a right angle-bracket. A
70000 key of a database record can then be entered, and the data for that record is
70001 displayed.
70002 </para>
70003 <para>
70004 If <quote>d</quote> is typed at the next prompt, the entire record is deleted. For all
70005 except the <emphasis>retry</emphasis> database, that is the only operation that can be carried
70006 out. For the <emphasis>retry</emphasis> database, each field is output preceded by a number, and
70007 data for individual fields can be changed by typing the field number followed
70008 by new data, for example:
70009 </para>
70010 <literallayout class="monospaced">
70011 &gt; 4 951102:1000
70012 </literallayout>
70013 <para>
70014 resets the time of the next delivery attempt. Time values are given as a
70015 sequence of digit pairs for year, month, day, hour, and minute. Colons can be
70016 used as optional separators.
70017 </para>
70018 </section>
70019 <section id="SECTmailboxmaint">
70020 <title>Mailbox maintenance (exim_lock)</title>
70021 <para>
70022 <indexterm role="concept">
70023 <primary>mailbox</primary>
70024 <secondary>maintenance</secondary>
70025 </indexterm>
70026 <indexterm role="concept">
70027 <primary><emphasis>exim_lock</emphasis></primary>
70028 </indexterm>
70029 <indexterm role="concept">
70030 <primary>locking mailboxes</primary>
70031 </indexterm>
70032 The <emphasis>exim_lock</emphasis> utility locks a mailbox file using the same algorithm as
70033 Exim. For a discussion of locking issues, see section <xref linkend="SECTopappend"/>.
70034 <emphasis>Exim_lock</emphasis> can be used to prevent any modification of a mailbox by Exim or
70035 a user agent while investigating a problem. The utility requires the name of
70036 the file as its first argument. If the locking is successful, the second
70037 argument is run as a command (using C&#x2019;s <function>system()</function> function); if there is no
70038 second argument, the value of the SHELL environment variable is used; if this
70039 is unset or empty, <filename>/bin/sh</filename> is run. When the command finishes, the mailbox
70040 is unlocked and the utility ends. The following options are available:
70041 </para>
70042 <variablelist>
70043 <varlistentry>
70044 <term><option>-fcntl</option></term>
70045 <listitem>
70046 <para>
70047 Use <function>fcntl()</function> locking on the open mailbox.
70048 </para>
70049 </listitem></varlistentry>
70050 <varlistentry>
70051 <term><option>-flock</option></term>
70052 <listitem>
70053 <para>
70054 Use <function>flock()</function> locking on the open mailbox, provided the operating system
70055 supports it.
70056 </para>
70057 </listitem></varlistentry>
70058 <varlistentry>
70059 <term><option>-interval</option></term>
70060 <listitem>
70061 <para>
70062 This must be followed by a number, which is a number of seconds; it sets the
70063 interval to sleep between retries (default 3).
70064 </para>
70065 </listitem></varlistentry>
70066 <varlistentry>
70067 <term><option>-lockfile</option></term>
70068 <listitem>
70069 <para>
70070 Create a lock file before opening the mailbox.
70071 </para>
70072 </listitem></varlistentry>
70073 <varlistentry>
70074 <term><option>-mbx</option></term>
70075 <listitem>
70076 <para>
70077 Lock the mailbox using MBX rules.
70078 </para>
70079 </listitem></varlistentry>
70080 <varlistentry>
70081 <term><option>-q</option></term>
70082 <listitem>
70083 <para>
70084 Suppress verification output.
70085 </para>
70086 </listitem></varlistentry>
70087 <varlistentry>
70088 <term><option>-retries</option></term>
70089 <listitem>
70090 <para>
70091 This must be followed by a number; it sets the number of times to try to get
70092 the lock (default 10).
70093 </para>
70094 </listitem></varlistentry>
70095 <varlistentry>
70096 <term><option>-restore_time</option></term>
70097 <listitem>
70098 <para>
70099 This option causes <option>exim_lock</option> to restore the modified and read times to the
70100 locked file before exiting. This allows you to access a locked mailbox (for
70101 example, to take a backup copy) without disturbing the times that the user
70102 subsequently sees.
70103 </para>
70104 </listitem></varlistentry>
70105 <varlistentry>
70106 <term><option>-timeout</option></term>
70107 <listitem>
70108 <para>
70109 This must be followed by a number, which is a number of seconds; it sets a
70110 timeout to be used with a blocking <function>fcntl()</function> lock. If it is not set (the
70111 default), a non-blocking call is used.
70112 </para>
70113 </listitem></varlistentry>
70114 <varlistentry>
70115 <term><option>-v</option></term>
70116 <listitem>
70117 <para>
70118 Generate verbose output.
70119 </para>
70120 </listitem></varlistentry>
70121 </variablelist>
70122 <para>
70123 If none of <option>-fcntl</option>, <option>-flock</option>, <option>-lockfile</option> or <option>-mbx</option> are given, the
70124 default is to create a lock file and also to use <function>fcntl()</function> locking on the
70125 mailbox, which is the same as Exim&#x2019;s default. The use of <option>-flock</option> or
70126 <option>-fcntl</option> requires that the file be writeable; the use of <option>-lockfile</option>
70127 requires that the directory containing the file be writeable. Locking by lock
70128 file does not last forever; Exim assumes that a lock file is expired if it is
70129 more than 30 minutes old.
70130 </para>
70131 <para>
70132 The <option>-mbx</option> option can be used with either or both of <option>-fcntl</option> or
70133 <option>-flock</option>. It assumes <option>-fcntl</option> by default. MBX locking causes a shared lock
70134 to be taken out on the open mailbox, and an exclusive lock on the file
70135 <filename>/tmp/.n.m</filename> where <emphasis>n</emphasis> and <emphasis>m</emphasis> are the device number and inode
70136 number of the mailbox file. When the locking is released, if an exclusive lock
70137 can be obtained for the mailbox, the file in <filename>/tmp</filename> is deleted.
70138 </para>
70139 <para>
70140 The default output contains verification of the locking that takes place. The
70141 <option>-v</option> option causes some additional information to be given. The <option>-q</option> option
70142 suppresses all output except error messages.
70143 </para>
70144 <para>
70145 A command such as
70146 </para>
70147 <literallayout class="monospaced">
70148 exim_lock /var/spool/mail/spqr
70149 </literallayout>
70150 <para>
70151 runs an interactive shell while the file is locked, whereas
70152 </para>
70153 <literallayout>
70154 <literal>exim_lock -q /var/spool/mail/spqr &lt;&lt;End</literal>
70155 &lt;<emphasis>some commands</emphasis>&gt;
70156 <literal>End</literal>
70157 </literallayout>
70158 <para>
70159 runs a specific non-interactive sequence of commands while the file is locked,
70160 suppressing all verification output. A single command can be run by a command
70161 such as
70162 </para>
70163 <literallayout class="monospaced">
70164 exim_lock -q /var/spool/mail/spqr \
70165   "cp /var/spool/mail/spqr /some/where"
70166 </literallayout>
70167 <para>
70168 Note that if a command is supplied, it must be entirely contained within the
70169 second argument &ndash; hence the quotes.
70170 <indexterm role="concept" startref="IIDutils" class="endofrange"/>
70171 </para>
70172 </section>
70173 </chapter>
70174
70175 <chapter id="CHAPeximon">
70176 <title>The Exim monitor</title>
70177 <para>
70178 <indexterm role="concept" id="IIDeximon" class="startofrange">
70179 <primary>Exim monitor</primary>
70180 <secondary>description</secondary>
70181 </indexterm>
70182 <indexterm role="concept">
70183 <primary>X-windows</primary>
70184 </indexterm>
70185 <indexterm role="concept">
70186 <primary><emphasis>eximon</emphasis></primary>
70187 </indexterm>
70188 <indexterm role="concept">
70189 <primary>Local/eximon.conf</primary>
70190 </indexterm>
70191 <indexterm role="concept">
70192 <primary><filename>exim_monitor/EDITME</filename></primary>
70193 </indexterm>
70194 The Exim monitor is an application which displays in an X window information
70195 about the state of Exim&#x2019;s queue and what Exim is doing. An admin user can
70196 perform certain operations on messages from this GUI interface; however all
70197 such facilities are also available from the command line, and indeed, the
70198 monitor itself makes use of the command line to perform any actions requested.
70199 </para>
70200 <section id="SECID264">
70201 <title>Running the monitor</title>
70202 <para>
70203 The monitor is started by running the script called <emphasis>eximon</emphasis>. This is a shell
70204 script that sets up a number of environment variables, and then runs the
70205 binary called <filename>eximon.bin</filename>. The default appearance of the monitor window can
70206 be changed by editing the <filename>Local/eximon.conf</filename> file created by editing
70207 <filename>exim_monitor/EDITME</filename>. Comments in that file describe what the various
70208 parameters are for.
70209 </para>
70210 <para>
70211 The parameters that get built into the <emphasis>eximon</emphasis> script can be overridden for
70212 a particular invocation by setting up environment variables of the same names,
70213 preceded by <literal>EXIMON_</literal>. For example, a shell command such as
70214 </para>
70215 <literallayout class="monospaced">
70216 EXIMON_LOG_DEPTH=400 eximon
70217 </literallayout>
70218 <para>
70219 (in a Bourne-compatible shell) runs <emphasis>eximon</emphasis> with an overriding setting of
70220 the LOG_DEPTH parameter. If EXIMON_LOG_FILE_PATH is set in the environment, it
70221 overrides the Exim log file configuration. This makes it possible to have
70222 <emphasis>eximon</emphasis> tailing log data that is written to syslog, provided that MAIL.INFO
70223 syslog messages are routed to a file on the local host.
70224 </para>
70225 <para>
70226 X resources can be used to change the appearance of the window in the normal
70227 way. For example, a resource setting of the form
70228 </para>
70229 <literallayout class="monospaced">
70230 Eximon*background: gray94
70231 </literallayout>
70232 <para>
70233 changes the colour of the background to light grey rather than white. The
70234 stripcharts are drawn with both the data lines and the reference lines in
70235 black. This means that the reference lines are not visible when on top of the
70236 data. However, their colour can be changed by setting a resource called
70237 <quote>highlight</quote> (an odd name, but that&#x2019;s what the Athena stripchart widget uses).
70238 For example, if your X server is running Unix, you could set up lighter
70239 reference lines in the stripcharts by obeying
70240 </para>
70241 <literallayout class="monospaced">
70242 xrdb -merge &lt;&lt;End
70243 Eximon*highlight: gray
70244 End
70245 </literallayout>
70246 <para>
70247 <indexterm role="concept">
70248 <primary>admin user</primary>
70249 </indexterm>
70250 In order to see the contents of messages in the queue, and to operate on them,
70251 <emphasis>eximon</emphasis> must either be run as root or by an admin user.
70252 </para>
70253 <para>
70254 The command-line parameters of <emphasis>eximon</emphasis> are passed to <filename>eximon.bin</filename> and may
70255 contain X11 resource parameters interpreted by the X11 library.  In addition,
70256 if the first parameter starts with the string "gdb" then it is removed and the
70257 binary is invoked under gdb (the parameter is used as the gdb command-name, so
70258 versioned variants of gdb can be invoked).
70259 </para>
70260 <para>
70261 The monitor&#x2019;s window is divided into three parts. The first contains one or
70262 more stripcharts and two action buttons, the second contains a <quote>tail</quote> of the
70263 main log file, and the third is a display of the queue of messages awaiting
70264 delivery, with two more action buttons. The following sections describe these
70265 different parts of the display.
70266 </para>
70267 </section>
70268 <section id="SECID265">
70269 <title>The stripcharts</title>
70270 <para>
70271 <indexterm role="concept">
70272 <primary>stripchart</primary>
70273 </indexterm>
70274 The first stripchart is always a count of messages in the queue. Its name can
70275 be configured by setting QUEUE_STRIPCHART_NAME in the
70276 <filename>Local/eximon.conf</filename> file. The remaining stripcharts are defined in the
70277 configuration script by regular expression matches on log file entries, making
70278 it possible to display, for example, counts of messages delivered to certain
70279 hosts or using certain transports. The supplied defaults display counts of
70280 received and delivered messages, and of local and SMTP deliveries. The default
70281 period between stripchart updates is one minute; this can be adjusted by a
70282 parameter in the <filename>Local/eximon.conf</filename> file.
70283 </para>
70284 <para>
70285 The stripchart displays rescale themselves automatically as the value they are
70286 displaying changes. There are always 10 horizontal lines in each chart; the
70287 title string indicates the value of each division when it is greater than one.
70288 For example, <quote>x2</quote> means that each division represents a value of 2.
70289 </para>
70290 <para>
70291 It is also possible to have a stripchart which shows the percentage fullness of
70292 a particular disk partition, which is useful when local deliveries are confined
70293 to a single partition.
70294 </para>
70295 <para>
70296 <indexterm role="concept">
70297 <primary><option>statvfs</option> function</primary>
70298 </indexterm>
70299 This relies on the availability of the <function>statvfs()</function> function or equivalent in
70300 the operating system. Most, but not all versions of Unix that support Exim have
70301 this. For this particular stripchart, the top of the chart always represents
70302 100%, and the scale is given as <quote>x10%</quote>. This chart is configured by setting
70303 SIZE_STRIPCHART and (optionally) SIZE_STRIPCHART_NAME in the
70304 <filename>Local/eximon.conf</filename> file.
70305 </para>
70306 </section>
70307 <section id="SECID266">
70308 <title>Main action buttons</title>
70309 <para>
70310 <indexterm role="concept">
70311 <primary>size</primary>
70312 <secondary>of monitor window</secondary>
70313 </indexterm>
70314 <indexterm role="concept">
70315 <primary>Exim monitor</primary>
70316 <secondary>window size</secondary>
70317 </indexterm>
70318 <indexterm role="concept">
70319 <primary>window size</primary>
70320 </indexterm>
70321 Below the stripcharts there is an action button for quitting the monitor. Next
70322 to this is another button marked <quote>Size</quote>. They are placed here so that
70323 shrinking the window to its default minimum size leaves just the queue count
70324 stripchart and these two buttons visible. Pressing the <quote>Size</quote> button causes
70325 the window to expand to its maximum size, unless it is already at the maximum,
70326 in which case it is reduced to its minimum.
70327 </para>
70328 <para>
70329 When expanding to the maximum, if the window cannot be fully seen where it
70330 currently is, it is moved back to where it was the last time it was at full
70331 size. When it is expanding from its minimum size, the old position is
70332 remembered, and next time it is reduced to the minimum it is moved back there.
70333 </para>
70334 <para>
70335 The idea is that you can keep a reduced window just showing one or two
70336 stripcharts at a convenient place on your screen, easily expand it to show
70337 the full window when required, and just as easily put it back to what it was.
70338 The idea is copied from what the <emphasis>twm</emphasis> window manager does for its
70339 <emphasis>f.fullzoom</emphasis> action. The minimum size of the window can be changed by setting
70340 the MIN_HEIGHT and MIN_WIDTH values in <filename>Local/eximon.conf</filename>.
70341 </para>
70342 <para>
70343 Normally, the monitor starts up with the window at its full size, but it can be
70344 built so that it starts up with the window at its smallest size, by setting
70345 START_SMALL=yes in <filename>Local/eximon.conf</filename>.
70346 </para>
70347 </section>
70348 <section id="SECID267">
70349 <title>The log display</title>
70350 <para>
70351 <indexterm role="concept">
70352 <primary>log</primary>
70353 <secondary>tail of; in monitor</secondary>
70354 </indexterm>
70355 The second section of the window is an area in which a display of the tail of
70356 the main log is maintained.
70357 To save space on the screen, the timestamp on each log line is shortened by
70358 removing the date and, if <option>log_timezone</option> is set, the timezone.
70359 The log tail is not available when the only destination for logging data is
70360 syslog, unless the syslog lines are routed to a local file whose name is passed
70361 to <emphasis>eximon</emphasis> via the EXIMON_LOG_FILE_PATH environment variable.
70362 </para>
70363 <para>
70364 The log sub-window has a scroll bar at its lefthand side which can be used to
70365 move back to look at earlier text, and the up and down arrow keys also have a
70366 scrolling effect. The amount of log that is kept depends on the setting of
70367 LOG_BUFFER in <filename>Local/eximon.conf</filename>, which specifies the amount of memory
70368 to use. When this is full, the earlier 50% of data is discarded &ndash; this is
70369 much more efficient than throwing it away line by line. The sub-window also has
70370 a horizontal scroll bar for accessing the ends of long log lines. This is the
70371 only means of horizontal scrolling; the right and left arrow keys are not
70372 available. Text can be cut from this part of the window using the mouse in the
70373 normal way. The size of this subwindow is controlled by parameters in the
70374 configuration file <filename>Local/eximon.conf</filename>.
70375 </para>
70376 <para>
70377 Searches of the text in the log window can be carried out by means of the ^R
70378 and ^S keystrokes, which default to a reverse and a forward search,
70379 respectively. The search covers only the text that is displayed in the window.
70380 It cannot go further back up the log.
70381 </para>
70382 <para>
70383 The point from which the search starts is indicated by a caret marker. This is
70384 normally at the end of the text in the window, but can be positioned explicitly
70385 by pointing and clicking with the left mouse button, and is moved automatically
70386 by a successful search. If new text arrives in the window when it is scrolled
70387 back, the caret remains where it is, but if the window is not scrolled back,
70388 the caret is moved to the end of the new text.
70389 </para>
70390 <para>
70391 Pressing ^R or ^S pops up a window into which the search text can be typed.
70392 There are buttons for selecting forward or reverse searching, for carrying out
70393 the search, and for cancelling. If the <quote>Search</quote> button is pressed, the search
70394 happens and the window remains so that further searches can be done. If the
70395 <quote>Return</quote> key is pressed, a single search is done and the window is closed. If
70396 ^C is typed the search is cancelled.
70397 </para>
70398 <para>
70399 The searching facility is implemented using the facilities of the Athena text
70400 widget. By default this pops up a window containing both <quote>search</quote> and
70401 <quote>replace</quote> options. In order to suppress the unwanted <quote>replace</quote> portion for
70402 eximon, a modified version of the <option>TextPop</option> widget is distributed with Exim.
70403 However, the linkers in BSDI and HP-UX seem unable to handle an externally
70404 provided version of <option>TextPop</option> when the remaining parts of the text widget
70405 come from the standard libraries. The compile-time option EXIMON_TEXTPOP can be
70406 unset to cut out the modified <option>TextPop</option>, making it possible to build Eximon
70407 on these systems, at the expense of having unwanted items in the search popup
70408 window.
70409 </para>
70410 </section>
70411 <section id="SECID268">
70412 <title>The queue display</title>
70413 <para>
70414 <indexterm role="concept">
70415 <primary>queue</primary>
70416 <secondary>display in monitor</secondary>
70417 </indexterm>
70418 The bottom section of the monitor window contains a list of all messages that
70419 are in the queue, which includes those currently being received or delivered,
70420 as well as those awaiting delivery. The size of this subwindow is controlled by
70421 parameters in the configuration file <filename>Local/eximon.conf</filename>, and the frequency
70422 at which it is updated is controlled by another parameter in the same file &ndash;
70423 the default is 5 minutes, since queue scans can be quite expensive. However,
70424 there is an <quote>Update</quote> action button just above the display which can be used
70425 to force an update of the queue display at any time.
70426 </para>
70427 <para>
70428 When a host is down for some time, a lot of pending mail can build up for it,
70429 and this can make it hard to deal with other messages in the queue. To help
70430 with this situation there is a button next to <quote>Update</quote> called <quote>Hide</quote>. If
70431 pressed, a dialogue box called <quote>Hide addresses ending with</quote> is put up. If you
70432 type anything in here and press <quote>Return</quote>, the text is added to a chain of
70433 such texts, and if every undelivered address in a message matches at least one
70434 of the texts, the message is not displayed.
70435 </para>
70436 <para>
70437 If there is an address that does not match any of the texts, all the addresses
70438 are displayed as normal. The matching happens on the ends of addresses so, for
70439 example, <emphasis>cam.ac.uk</emphasis> specifies all addresses in Cambridge, while
70440 <emphasis>xxx@foo.com.example</emphasis> specifies just one specific address. When any hiding
70441 has been set up, a button called <quote>Unhide</quote> is displayed. If pressed, it
70442 cancels all hiding. Also, to ensure that hidden messages do not get forgotten,
70443 a hide request is automatically cancelled after one hour.
70444 </para>
70445 <para>
70446 While the dialogue box is displayed, you can&#x2019;t press any buttons or do anything
70447 else to the monitor window. For this reason, if you want to cut text from the
70448 queue display to use in the dialogue box, you have to do the cutting before
70449 pressing the <quote>Hide</quote> button.
70450 </para>
70451 <para>
70452 The queue display contains, for each unhidden queued message, the length of
70453 time it has been in the queue, the size of the message, the message id, the
70454 message sender, and the first undelivered recipient, all on one line. If it is
70455 a bounce message, the sender is shown as <quote>&lt;&gt;</quote>. If there is more than one
70456 recipient to which the message has not yet been delivered, subsequent ones are
70457 listed on additional lines, up to a maximum configured number, following which
70458 an ellipsis is displayed. Recipients that have already received the message are
70459 not shown.
70460 </para>
70461 <para>
70462 <indexterm role="concept">
70463 <primary>frozen messages</primary>
70464 <secondary>display</secondary>
70465 </indexterm>
70466 If a message is frozen, an asterisk is displayed at the left-hand side.
70467 </para>
70468 <para>
70469 The queue display has a vertical scroll bar, and can also be scrolled by means
70470 of the arrow keys. Text can be cut from it using the mouse in the normal way.
70471 The text searching facilities, as described above for the log window, are also
70472 available, but the caret is always moved to the end of the text when the queue
70473 display is updated.
70474 </para>
70475 </section>
70476 <section id="SECID269">
70477 <title>The queue menu</title>
70478 <para>
70479 <indexterm role="concept">
70480 <primary>queue</primary>
70481 <secondary>menu in monitor</secondary>
70482 </indexterm>
70483 If the <option>shift</option> key is held down and the left button is clicked when the mouse
70484 pointer is over the text for any message, an action menu pops up, and the first
70485 line of the queue display for the message is highlighted. This does not affect
70486 any selected text.
70487 </para>
70488 <para>
70489 If you want to use some other event for popping up the menu, you can set the
70490 MENU_EVENT parameter in <filename>Local/eximon.conf</filename> to change the default, or
70491 set EXIMON_MENU_EVENT in the environment before starting the monitor. The
70492 value set in this parameter is a standard X event description. For example, to
70493 run eximon using <option>ctrl</option> rather than <option>shift</option> you could use
70494 </para>
70495 <literallayout class="monospaced">
70496 EXIMON_MENU_EVENT='Ctrl&lt;Btn1Down&gt;' eximon
70497 </literallayout>
70498 <para>
70499 The title of the menu is the message id, and it contains entries which act as
70500 follows:
70501 </para>
70502 <itemizedlist>
70503 <listitem>
70504 <para>
70505 <emphasis>message log</emphasis>: The contents of the message log for the message are displayed
70506 in a new text window.
70507 </para>
70508 </listitem>
70509 <listitem>
70510 <para>
70511 <emphasis>headers</emphasis>: Information from the spool file that contains the envelope
70512 information and headers is displayed in a new text window. See chapter
70513 <xref linkend="CHAPspool"/> for a description of the format of spool files.
70514 </para>
70515 </listitem>
70516 <listitem>
70517 <para>
70518 <emphasis>body</emphasis>: The contents of the spool file containing the body of the message are
70519 displayed in a new text window. There is a default limit of 20,000 bytes to the
70520 amount of data displayed. This can be changed by setting the BODY_MAX
70521 option at compile time, or the EXIMON_BODY_MAX option at runtime.
70522 </para>
70523 </listitem>
70524 <listitem>
70525 <para>
70526 <emphasis>deliver message</emphasis>: A call to Exim is made using the <option>-M</option> option to request
70527 delivery of the message. This causes an automatic thaw if the message is
70528 frozen. The <option>-v</option> option is also set, and the output from Exim is displayed in
70529 a new text window. The delivery is run in a separate process, to avoid holding
70530 up the monitor while the delivery proceeds.
70531 </para>
70532 </listitem>
70533 <listitem>
70534 <para>
70535 <emphasis>freeze message</emphasis>: A call to Exim is made using the <option>-Mf</option> option to request
70536 that the message be frozen.
70537 </para>
70538 </listitem>
70539 <listitem>
70540 <para>
70541 <indexterm role="concept">
70542 <primary>thawing messages</primary>
70543 </indexterm>
70544 <indexterm role="concept">
70545 <primary>unfreezing messages</primary>
70546 </indexterm>
70547 <indexterm role="concept">
70548 <primary>frozen messages</primary>
70549 <secondary>thawing</secondary>
70550 </indexterm>
70551 <emphasis>thaw message</emphasis>: A call to Exim is made using the <option>-Mt</option> option to request
70552 that the message be thawed.
70553 </para>
70554 </listitem>
70555 <listitem>
70556 <para>
70557 <indexterm role="concept">
70558 <primary>delivery</primary>
70559 <secondary>forcing failure</secondary>
70560 </indexterm>
70561 <emphasis>give up on msg</emphasis>: A call to Exim is made using the <option>-Mg</option> option to request
70562 that Exim gives up trying to deliver the message. A bounce message is generated
70563 for any remaining undelivered addresses.
70564 </para>
70565 </listitem>
70566 <listitem>
70567 <para>
70568 <emphasis>remove message</emphasis>: A call to Exim is made using the <option>-Mrm</option> option to request
70569 that the message be deleted from the system without generating a bounce
70570 message.
70571 </para>
70572 </listitem>
70573 <listitem>
70574 <para>
70575 <emphasis>add recipient</emphasis>: A dialog box is displayed into which a recipient address can
70576 be typed. If the address is not qualified and the QUALIFY_DOMAIN parameter
70577 is set in <filename>Local/eximon.conf</filename>, the address is qualified with that domain.
70578 Otherwise it must be entered as a fully qualified address. Pressing RETURN
70579 causes a call to Exim to be made using the <option>-Mar</option> option to request that an
70580 additional recipient be added to the message, unless the entry box is empty, in
70581 which case no action is taken.
70582 </para>
70583 </listitem>
70584 <listitem>
70585 <para>
70586 <emphasis>mark delivered</emphasis>: A dialog box is displayed into which a recipient address
70587 can be typed. If the address is not qualified and the QUALIFY_DOMAIN parameter
70588 is set in <filename>Local/eximon.conf</filename>, the address is qualified with that domain.
70589 Otherwise it must be entered as a fully qualified address. Pressing RETURN
70590 causes a call to Exim to be made using the <option>-Mmd</option> option to mark the given
70591 recipient address as already delivered, unless the entry box is empty, in which
70592 case no action is taken.
70593 </para>
70594 </listitem>
70595 <listitem>
70596 <para>
70597 <emphasis>mark all delivered</emphasis>: A call to Exim is made using the <option>-Mmad</option> option to
70598 mark all recipient addresses as already delivered.
70599 </para>
70600 </listitem>
70601 <listitem>
70602 <para>
70603 <emphasis>edit sender</emphasis>: A dialog box is displayed initialized with the current
70604 sender&#x2019;s address. Pressing RETURN causes a call to Exim to be made using the
70605 <option>-Mes</option> option to replace the sender address, unless the entry box is empty,
70606 in which case no action is taken. If you want to set an empty sender (as in
70607 bounce messages), you must specify it as <quote>&lt;&gt;</quote>. Otherwise, if the address is
70608 not qualified and the QUALIFY_DOMAIN parameter is set in <filename>Local/eximon.conf</filename>,
70609 the address is qualified with that domain.
70610 </para>
70611 </listitem>
70612 </itemizedlist>
70613 <para>
70614 When a delivery is forced, a window showing the <option>-v</option> output is displayed. In
70615 other cases when a call to Exim is made, if there is any output from Exim (in
70616 particular, if the command fails) a window containing the command and the
70617 output is displayed. Otherwise, the results of the action are normally apparent
70618 from the log and queue displays. However, if you set ACTION_OUTPUT=yes in
70619 <filename>Local/eximon.conf</filename>, a window showing the Exim command is always opened, even
70620 if no output is generated.
70621 </para>
70622 <para>
70623 The queue display is automatically updated for actions such as freezing and
70624 thawing, unless ACTION_QUEUE_UPDATE=no has been set in
70625 <filename>Local/eximon.conf</filename>. In this case the <quote>Update</quote> button has to be used to
70626 force an update of the display after one of these actions.
70627 </para>
70628 <para>
70629 In any text window that is displayed as result of a menu action, the normal
70630 cut-and-paste facility is available, and searching can be carried out using ^R
70631 and ^S, as described above for the log tail window.
70632 <indexterm role="concept" startref="IIDeximon" class="endofrange"/>
70633 </para>
70634 </section>
70635 </chapter>
70636
70637 <chapter id="CHAPsecurity">
70638 <title>Security considerations</title>
70639 <para>
70640 <indexterm role="concept" id="IIDsecurcon" class="startofrange">
70641 <primary>security</primary>
70642 <secondary>discussion of</secondary>
70643 </indexterm>
70644 This chapter discusses a number of issues concerned with security, some of
70645 which are also covered in other parts of this manual.
70646 </para>
70647 <para>
70648 For reasons that this author does not understand, some people have promoted
70649 Exim as a <quote>particularly secure</quote> mailer. Perhaps it is because of the
70650 existence of this chapter in the documentation. However, the intent of the
70651 chapter is simply to describe the way Exim works in relation to certain
70652 security concerns, not to make any specific claims about the effectiveness of
70653 its security as compared with other MTAs.
70654 </para>
70655 <para>
70656 What follows is a description of the way Exim is supposed to be. Best efforts
70657 have been made to try to ensure that the code agrees with the theory, but an
70658 absence of bugs can never be guaranteed. Any that are reported will get fixed
70659 as soon as possible.
70660 </para>
70661 <section id="SECID286">
70662 <title>Building a more <quote>hardened</quote> Exim</title>
70663 <para>
70664 <indexterm role="concept">
70665 <primary>security</primary>
70666 <secondary>build-time features</secondary>
70667 </indexterm>
70668 There are a number of build-time options that can be set in <filename>Local/Makefile</filename>
70669 to create Exim binaries that are <quote>harder</quote> to attack, in particular by a rogue
70670 Exim administrator who does not have the root password, or by someone who has
70671 penetrated the Exim (but not the root) account. These options are as follows:
70672 </para>
70673 <itemizedlist>
70674 <listitem>
70675 <para>
70676 ALT_CONFIG_PREFIX can be set to a string that is required to match the
70677 start of any filenames used with the <option>-C</option> option. When it is set, these
70678 filenames are also not allowed to contain the sequence <quote>/../</quote>. (However, if
70679 the value of the <option>-C</option> option is identical to the value of CONFIGURE_FILE in
70680 <filename>Local/Makefile</filename>, Exim ignores <option>-C</option> and proceeds as usual.) There is no
70681 default setting for <option>ALT_CONFIG_PREFIX</option>.
70682 </para>
70683 <para>
70684 If the permitted configuration files are confined to a directory to
70685 which only root has access, this guards against someone who has broken
70686 into the Exim account from running a privileged Exim with an arbitrary
70687 configuration file, and using it to break into other accounts.
70688 </para>
70689 </listitem>
70690 <listitem>
70691 <para>
70692 If a non-trusted configuration file (i.e. not the default configuration file
70693 or one which is trusted by virtue of being listed in the TRUSTED_CONFIG_LIST
70694 file) is specified with <option>-C</option>, or if macros are given with <option>-D</option> (but see
70695 the next item), then root privilege is retained only if the caller of Exim is
70696 root. This locks out the possibility of testing a configuration using <option>-C</option>
70697 right through message reception and delivery, even if the caller is root. The
70698 reception works, but by that time, Exim is running as the Exim user, so when
70699 it re-execs to regain privilege for the delivery, the use of <option>-C</option> causes
70700 privilege to be lost. However, root can test reception and delivery using two
70701 separate commands.
70702 </para>
70703 </listitem>
70704 <listitem>
70705 <para>
70706 The WHITELIST_D_MACROS build option declares some macros to be safe to override
70707 with <option>-D</option> if the real uid is one of root, the Exim run-time user or the
70708 CONFIGURE_OWNER, if defined.  The potential impact of this option is limited by
70709 requiring the run-time value supplied to <option>-D</option> to match a regex that errs on
70710 the restrictive side.  Requiring build-time selection of safe macros is onerous
70711 but this option is intended solely as a transition mechanism to permit
70712 previously-working configurations to continue to work after release 4.73.
70713 </para>
70714 </listitem>
70715 <listitem>
70716 <para>
70717 If DISABLE_D_OPTION is defined, the use of the <option>-D</option> command line option
70718 is disabled.
70719 </para>
70720 </listitem>
70721 <listitem>
70722 <para>
70723 FIXED_NEVER_USERS can be set to a colon-separated list of users that are
70724 never to be used for any deliveries. This is like the <option>never_users</option> runtime
70725 option, but it cannot be overridden; the runtime option adds additional users
70726 to the list. The default setting is <quote>root</quote>; this prevents a non-root user who
70727 is permitted to modify the runtime file from using Exim as a way to get root.
70728 </para>
70729 </listitem>
70730 </itemizedlist>
70731 </section>
70732 <section id="SECID270">
70733 <title>Root privilege</title>
70734 <para>
70735 <indexterm role="concept">
70736 <primary>setuid</primary>
70737 </indexterm>
70738 <indexterm role="concept">
70739 <primary>root privilege</primary>
70740 </indexterm>
70741 The Exim binary is normally setuid to root, which means that it gains root
70742 privilege (runs as root) when it starts execution. In some special cases (for
70743 example, when the daemon is not in use and there are no local deliveries), it
70744 may be possible to run Exim setuid to some user other than root. This is
70745 discussed in the next section. However, in most installations, root privilege
70746 is required for two things:
70747 </para>
70748 <itemizedlist>
70749 <listitem>
70750 <para>
70751 To set up a socket connected to the standard SMTP port (25) when initialising
70752 the listening daemon. If Exim is run from <emphasis>inetd</emphasis>, this privileged action is
70753 not required.
70754 </para>
70755 </listitem>
70756 <listitem>
70757 <para>
70758 To be able to change uid and gid in order to read users&#x2019; <filename>.forward</filename> files and
70759 perform local deliveries as the receiving user or as specified in the
70760 configuration.
70761 </para>
70762 </listitem>
70763 </itemizedlist>
70764 <para>
70765 It is not necessary to be root to do any of the other things Exim does, such as
70766 receiving messages and delivering them externally over SMTP, and it is
70767 obviously more secure if Exim does not run as root except when necessary.
70768 For this reason, a user and group for Exim to use must be defined in
70769 <filename>Local/Makefile</filename>. These are known as <quote>the Exim user</quote> and <quote>the Exim
70770 group</quote>. Their values can be changed by the runtime configuration, though this
70771 is not recommended. Often a user called <emphasis>exim</emphasis> is used, but some sites use
70772 <emphasis>mail</emphasis> or another user name altogether.
70773 </para>
70774 <para>
70775 Exim uses <function>setuid()</function> whenever it gives up root privilege. This is a permanent
70776 abdication; the process cannot regain root afterwards. Prior to release 4.00,
70777 <function>seteuid()</function> was used in some circumstances, but this is no longer the case.
70778 </para>
70779 <para>
70780 After a new Exim process has interpreted its command line options, it changes
70781 uid and gid in the following cases:
70782 </para>
70783 <itemizedlist>
70784 <listitem>
70785 <para>
70786 <indexterm role="option">
70787 <primary><option>-C</option></primary>
70788 </indexterm>
70789 <indexterm role="option">
70790 <primary><option>-D</option></primary>
70791 </indexterm>
70792 If the <option>-C</option> option is used to specify an alternate configuration file, or if
70793 the <option>-D</option> option is used to define macro values for the configuration, and the
70794 calling process is not running as root, the uid and gid are changed to those of
70795 the calling process.
70796 However, if DISABLE_D_OPTION is defined in <filename>Local/Makefile</filename>, the <option>-D</option>
70797 option may not be used at all.
70798 If WHITELIST_D_MACROS is defined in <filename>Local/Makefile</filename>, then some macro values
70799 can be supplied if the calling process is running as root, the Exim run-time
70800 user or CONFIGURE_OWNER, if defined.
70801 </para>
70802 </listitem>
70803 <listitem>
70804 <para>
70805 <indexterm role="option">
70806 <primary><option>-be</option></primary>
70807 </indexterm>
70808 <indexterm role="option">
70809 <primary><option>-bf</option></primary>
70810 </indexterm>
70811 <indexterm role="option">
70812 <primary><option>-bF</option></primary>
70813 </indexterm>
70814 If the expansion test option (<option>-be</option>) or one of the filter testing options
70815 (<option>-bf</option> or <option>-bF</option>) are used, the uid and gid are changed to those of the
70816 calling process.
70817 </para>
70818 </listitem>
70819 <listitem>
70820 <para>
70821 If the process is not a daemon process or a queue runner process or a delivery
70822 process or a process for testing address routing (started with <option>-bt</option>), the
70823 uid and gid are changed to the Exim user and group. This means that Exim always
70824 runs under its own uid and gid when receiving messages. This also applies when
70825 testing address verification
70826 <indexterm role="option">
70827 <primary><option>-bv</option></primary>
70828 </indexterm>
70829 <indexterm role="option">
70830 <primary><option>-bh</option></primary>
70831 </indexterm>
70832 (the <option>-bv</option> option) and testing incoming message policy controls (the <option>-bh</option>
70833 option).
70834 </para>
70835 </listitem>
70836 <listitem>
70837 <para>
70838 For a daemon, queue runner, delivery, or address testing process, the uid
70839 remains as root at this stage, but the gid is changed to the Exim group.
70840 </para>
70841 </listitem>
70842 </itemizedlist>
70843 <para>
70844 The processes that initially retain root privilege behave as follows:
70845 </para>
70846 <itemizedlist>
70847 <listitem>
70848 <para>
70849 A daemon process changes the gid to the Exim group and the uid to the Exim
70850 user after setting up one or more listening sockets. The <function>initgroups()</function>
70851 function is called, so that if the Exim user is in any additional groups, they
70852 will be used during message reception.
70853 </para>
70854 </listitem>
70855 <listitem>
70856 <para>
70857 A queue runner process retains root privilege throughout its execution. Its
70858 job is to fork a controlled sequence of delivery processes.
70859 </para>
70860 </listitem>
70861 <listitem>
70862 <para>
70863 A delivery process retains root privilege throughout most of its execution,
70864 but any actual deliveries (that is, the transports themselves) are run in
70865 subprocesses which always change to a non-root uid and gid. For local
70866 deliveries this is typically the uid and gid of the owner of the mailbox; for
70867 remote deliveries, the Exim uid and gid are used. Once all the delivery
70868 subprocesses have been run, a delivery process changes to the Exim uid and gid
70869 while doing post-delivery tidying up such as updating the retry database and
70870 generating bounce and warning messages.
70871 </para>
70872 <para>
70873 While the recipient addresses in a message are being routed, the delivery
70874 process runs as root. However, if a user&#x2019;s filter file has to be processed,
70875 this is done in a subprocess that runs under the individual user&#x2019;s uid and
70876 gid. A system filter is run as root unless <option>system_filter_user</option> is set.
70877 </para>
70878 </listitem>
70879 <listitem>
70880 <para>
70881 A process that is testing addresses (the <option>-bt</option> option) runs as root so that
70882 the routing is done in the same environment as a message delivery.
70883 </para>
70884 </listitem>
70885 </itemizedlist>
70886 </section>
70887 <section id="SECTrunexiwitpri">
70888 <title>Running Exim without privilege</title>
70889 <para>
70890 <indexterm role="concept">
70891 <primary>privilege, running without</primary>
70892 </indexterm>
70893 <indexterm role="concept">
70894 <primary>unprivileged running</primary>
70895 </indexterm>
70896 <indexterm role="concept">
70897 <primary>root privilege</primary>
70898 <secondary>running without</secondary>
70899 </indexterm>
70900 Some installations like to run Exim in an unprivileged state for more of its
70901 operation, for added security. Support for this mode of operation is provided
70902 by the global option <option>deliver_drop_privilege</option>. When this is set, the uid and
70903 gid are changed to the Exim user and group at the start of a delivery process
70904 (and also queue runner and address testing processes). This means that address
70905 routing is no longer run as root, and the deliveries themselves cannot change
70906 to any other uid.
70907 </para>
70908 <para>
70909 <indexterm role="concept">
70910 <primary>SIGHUP</primary>
70911 </indexterm>
70912 <indexterm role="concept">
70913 <primary>daemon</primary>
70914 <secondary>restarting</secondary>
70915 </indexterm>
70916 Leaving the binary setuid to root, but setting <option>deliver_drop_privilege</option> means
70917 that the daemon can still be started in the usual way, and it can respond
70918 correctly to SIGHUP because the re-invocation regains root privilege.
70919 </para>
70920 <para>
70921 An alternative approach is to make Exim setuid to the Exim user and also setgid
70922 to the Exim group. If you do this, the daemon must be started from a root
70923 process. (Calling Exim from a root process makes it behave in the way it does
70924 when it is setuid root.) However, the daemon cannot restart itself after a
70925 SIGHUP signal because it cannot regain privilege.
70926 </para>
70927 <para>
70928 It is still useful to set <option>deliver_drop_privilege</option> in this case, because it
70929 stops Exim from trying to re-invoke itself to do a delivery after a message has
70930 been received. Such a re-invocation is a waste of resources because it has no
70931 effect.
70932 </para>
70933 <para>
70934 If restarting the daemon is not an issue (for example, if <option>mua_wrapper</option> is
70935 set, or <emphasis>inetd</emphasis> is being used instead of a daemon), having the binary setuid
70936 to the Exim user seems a clean approach, but there is one complication:
70937 </para>
70938 <para>
70939 In this style of operation, Exim is running with the real uid and gid set to
70940 those of the calling process, and the effective uid/gid set to Exim&#x2019;s values.
70941 Ideally, any association with the calling process&#x2019; uid/gid should be dropped,
70942 that is, the real uid/gid should be reset to the effective values so as to
70943 discard any privileges that the caller may have. While some operating systems
70944 have a function that permits this action for a non-root effective uid, quite a
70945 number of them do not. Because of this lack of standardization, Exim does not
70946 address this problem at this time.
70947 </para>
70948 <para>
70949 For this reason, the recommended approach for <quote>mostly unprivileged</quote> running
70950 is to keep the Exim binary setuid to root, and to set
70951 <option>deliver_drop_privilege</option>. This also has the advantage of allowing a daemon to
70952 be used in the most straightforward way.
70953 </para>
70954 <para>
70955 If you configure Exim not to run delivery processes as root, there are a
70956 number of restrictions on what you can do:
70957 </para>
70958 <itemizedlist>
70959 <listitem>
70960 <para>
70961 You can deliver only as the Exim user/group. You should  explicitly use the
70962 <option>user</option> and <option>group</option> options to override routers or local transports that
70963 normally deliver as the recipient. This makes sure that configurations that
70964 work in this mode function the same way in normal mode. Any implicit or
70965 explicit specification of another user causes an error.
70966 </para>
70967 </listitem>
70968 <listitem>
70969 <para>
70970 Use of <filename>.forward</filename> files is severely restricted, such that it is usually
70971 not worthwhile to include them in the configuration.
70972 </para>
70973 </listitem>
70974 <listitem>
70975 <para>
70976 Users who wish to use <filename>.forward</filename> would have to make their home directory and
70977 the file itself accessible to the Exim user. Pipe and append-to-file entries,
70978 and their equivalents in Exim filters, cannot be used. While they could be
70979 enabled in the Exim user&#x2019;s name, that would be insecure and not very useful.
70980 </para>
70981 </listitem>
70982 <listitem>
70983 <para>
70984 Unless the local user mailboxes are all owned by the Exim user (possible in
70985 some POP3 or IMAP-only environments):
70986 </para>
70987 <orderedlist numeration="arabic">
70988 <listitem>
70989 <para>
70990 They must be owned by the Exim group and be writeable by that group. This
70991 implies you must set <option>mode</option> in the appendfile configuration, as well as the
70992 mode of the mailbox files themselves.
70993 </para>
70994 </listitem>
70995 <listitem>
70996 <para>
70997 You must set <option>no_check_owner</option>, since most or all of the files will not be
70998 owned by the Exim user.
70999 </para>
71000 </listitem>
71001 <listitem>
71002 <para>
71003 You must set <option>file_must_exist</option>, because Exim cannot set the owner correctly
71004 on a newly created mailbox when unprivileged. This also implies that new
71005 mailboxes need to be created manually.
71006 </para>
71007 </listitem>
71008 </orderedlist>
71009 </listitem>
71010 </itemizedlist>
71011 <para>
71012 These restrictions severely restrict what can be done in local deliveries.
71013 However, there are no restrictions on remote deliveries. If you are running a
71014 gateway host that does no local deliveries, setting <option>deliver_drop_privilege</option>
71015 gives more security at essentially no cost.
71016 </para>
71017 <para>
71018 If you are using the <option>mua_wrapper</option> facility (see chapter
71019 <xref linkend="CHAPnonqueueing"/>), <option>deliver_drop_privilege</option> is forced to be true.
71020 </para>
71021 </section>
71022 <section id="SECID271">
71023 <title>Delivering to local files</title>
71024 <para>
71025 Full details of the checks applied by <command>appendfile</command> before it writes to a file
71026 are given in chapter <xref linkend="CHAPappendfile"/>.
71027 </para>
71028 </section>
71029 <section id="SECTsecconslocalcmds">
71030 <title>Running local commands</title>
71031 <para>
71032 <indexterm role="concept">
71033 <primary>security</primary>
71034 <secondary>local commands</secondary>
71035 </indexterm>
71036 <indexterm role="concept">
71037 <primary>security</primary>
71038 <secondary>command injection attacks</secondary>
71039 </indexterm>
71040 There are a number of ways in which an administrator can configure Exim to run
71041 commands based upon received, untrustworthy, data. Further, in some
71042 configurations a user who can control a <filename>.forward</filename> file can also arrange to
71043 run commands. Configuration to check includes, but is not limited to:
71044 </para>
71045 <itemizedlist>
71046 <listitem>
71047 <para>
71048 Use of <option>use_shell</option> in the pipe transport: various forms of shell command
71049 injection may be possible with this option present. It is dangerous and should
71050 be used only with considerable caution. Consider constraints which whitelist
71051 allowed characters in a variable which is to be used in a pipe transport that
71052 has <option>use_shell</option> enabled.
71053 </para>
71054 </listitem>
71055 <listitem>
71056 <para>
71057 A number of options such as <option>forbid_filter_run</option>, <option>forbid_filter_perl</option>,
71058 <option>forbid_filter_dlfunc</option> and so forth which restrict facilities available to
71059 <filename>.forward</filename> files in a redirect router. If Exim is running on a central mail
71060 hub to which ordinary users do not have shell access, but home directories are
71061 NFS mounted (for instance) then administrators should review the list of these
71062 forbid options available, and should bear in mind that the options that may
71063 need forbidding can change as new features are added between releases.
71064 </para>
71065 </listitem>
71066 <listitem>
71067 <para>
71068 The <option>${run...}</option> expansion item does not use a shell by default, but
71069 administrators can configure use of <filename>/bin/sh</filename> as part of the command.
71070 Such invocations should be viewed with prejudicial suspicion.
71071 </para>
71072 </listitem>
71073 <listitem>
71074 <para>
71075 Administrators who use embedded Perl are advised to explore how Perl&#x2019;s
71076 taint checking might apply to their usage.
71077 </para>
71078 </listitem>
71079 <listitem>
71080 <para>
71081 Use of <option>${expand...}</option> is somewhat analogous to shell&#x2019;s eval builtin and
71082 administrators are well advised to view its use with suspicion, in case (for
71083 instance) it allows a local-part to contain embedded Exim directives.
71084 </para>
71085 </listitem>
71086 <listitem>
71087 <para>
71088 Use of <option>${match_local_part...}</option> and friends becomes more dangerous if
71089 Exim was built with EXPAND_LISTMATCH_RHS defined: the second string in
71090 each can reference arbitrary lists and files, rather than just being a list
71091 of opaque strings.
71092 The EXPAND_LISTMATCH_RHS option was added and set false by default because of
71093 real-world security vulnerabilities caused by its use with untrustworthy data
71094 injected in, for SQL injection attacks.
71095 Consider the use of the <option>inlisti</option> expansion condition instead.
71096 </para>
71097 </listitem>
71098 </itemizedlist>
71099 </section>
71100 <section id="SECTsecconfdata">
71101 <title>Trust in configuration data</title>
71102 <para>
71103 <indexterm role="concept">
71104 <primary>security</primary>
71105 <secondary>data sources</secondary>
71106 </indexterm>
71107 <indexterm role="concept">
71108 <primary>security</primary>
71109 <secondary>regular expressions</secondary>
71110 </indexterm>
71111 <indexterm role="concept">
71112 <primary>regular expressions</primary>
71113 <secondary>security</secondary>
71114 </indexterm>
71115 <indexterm role="concept">
71116 <primary>PCRE</primary>
71117 <secondary>security</secondary>
71118 </indexterm>
71119 If configuration data for Exim can come from untrustworthy sources, there
71120 are some issues to be aware of:
71121 </para>
71122 <itemizedlist>
71123 <listitem>
71124 <para>
71125 Use of <option>${expand...}</option> may provide a path for shell injection attacks.
71126 </para>
71127 </listitem>
71128 <listitem>
71129 <para>
71130 Letting untrusted data provide a regular expression is unwise.
71131 </para>
71132 </listitem>
71133 <listitem>
71134 <para>
71135 Using <option>${match...}</option> to apply a fixed regular expression against untrusted
71136 data may result in pathological behaviour within PCRE.  Be aware of what
71137 "backtracking" means and consider options for being more strict with a regular
71138 expression. Avenues to explore include limiting what can match (avoiding <literal>.</literal>
71139 when <literal>[a-z0-9]</literal> or other character class will do), use of atomic grouping and
71140 possessive quantifiers or just not using regular expressions against untrusted
71141 data.
71142 </para>
71143 </listitem>
71144 <listitem>
71145 <para>
71146 It can be important to correctly use <option>${quote:...}</option>,
71147 <option>${quote_local_part:...}</option> and <option>${quote_</option>&lt;<emphasis>lookup-type</emphasis>&gt;<option>:...}</option> expansion
71148 items to ensure that data is correctly constructed.
71149 </para>
71150 </listitem>
71151 <listitem>
71152 <para>
71153 Some lookups might return multiple results, even though normal usage is only
71154 expected to yield one result.
71155 </para>
71156 </listitem>
71157 </itemizedlist>
71158 </section>
71159 <section id="SECID272">
71160 <title>IPv4 source routing</title>
71161 <para>
71162 <indexterm role="concept">
71163 <primary>source routing</primary>
71164 <secondary>in IP packets</secondary>
71165 </indexterm>
71166 <indexterm role="concept">
71167 <primary>IP source routing</primary>
71168 </indexterm>
71169 Many operating systems suppress IP source-routed packets in the kernel, but
71170 some cannot be made to do this, so Exim does its own check. It logs incoming
71171 IPv4 source-routed TCP calls, and then drops them. Things are all different in
71172 IPv6. No special checking is currently done.
71173 </para>
71174 </section>
71175 <section id="SECID273">
71176 <title>The VRFY, EXPN, and ETRN commands in SMTP</title>
71177 <para>
71178 Support for these SMTP commands is disabled by default. If required, they can
71179 be enabled by defining suitable ACLs.
71180 </para>
71181 </section>
71182 <section id="SECID274">
71183 <title>Privileged users</title>
71184 <para>
71185 <indexterm role="concept">
71186 <primary>trusted users</primary>
71187 </indexterm>
71188 <indexterm role="concept">
71189 <primary>admin user</primary>
71190 </indexterm>
71191 <indexterm role="concept">
71192 <primary>privileged user</primary>
71193 </indexterm>
71194 <indexterm role="concept">
71195 <primary>user</primary>
71196 <secondary>trusted</secondary>
71197 </indexterm>
71198 <indexterm role="concept">
71199 <primary>user</primary>
71200 <secondary>admin</secondary>
71201 </indexterm>
71202 Exim recognizes two sets of users with special privileges. Trusted users are
71203 able to submit new messages to Exim locally, but supply their own sender
71204 addresses and information about a sending host. For other users submitting
71205 local messages, Exim sets up the sender address from the uid, and doesn&#x2019;t
71206 permit a remote host to be specified.
71207 </para>
71208 <para>
71209 <indexterm role="option">
71210 <primary><option>-f</option></primary>
71211 </indexterm>
71212 However, an untrusted user is permitted to use the <option>-f</option> command line option
71213 in the special form <option>-f &lt;&gt;</option> to indicate that a delivery failure for the
71214 message should not cause an error report. This affects the message&#x2019;s envelope,
71215 but it does not affect the <emphasis>Sender:</emphasis> header. Untrusted users may also be
71216 permitted to use specific forms of address with the <option>-f</option> option by setting
71217 the <option>untrusted_set_sender</option> option.
71218 </para>
71219 <para>
71220 Trusted users are used to run processes that receive mail messages from some
71221 other mail domain and pass them on to Exim for delivery either locally, or over
71222 the Internet. Exim trusts a caller that is running as root, as the Exim user,
71223 as any user listed in the <option>trusted_users</option> configuration option, or under any
71224 group listed in the <option>trusted_groups</option> option.
71225 </para>
71226 <para>
71227 Admin users are permitted to do things to the messages on Exim&#x2019;s queue. They
71228 can freeze or thaw messages, cause them to be returned to their senders, remove
71229 them entirely, or modify them in various ways. In addition, admin users can run
71230 the Exim monitor and see all the information it is capable of providing, which
71231 includes the contents of files on the spool.
71232 </para>
71233 <para>
71234 <indexterm role="option">
71235 <primary><option>-M</option></primary>
71236 </indexterm>
71237 <indexterm role="option">
71238 <primary><option>-q</option></primary>
71239 </indexterm>
71240 By default, the use of the <option>-M</option> and <option>-q</option> options to cause Exim to attempt
71241 delivery of messages on its queue is restricted to admin users. This
71242 restriction can be relaxed by setting the <option>no_prod_requires_admin</option> option.
71243 Similarly, the use of <option>-bp</option> (and its variants) to list the contents of the
71244 queue is also restricted to admin users. This restriction can be relaxed by
71245 setting <option>no_queue_list_requires_admin</option>.
71246 </para>
71247 <para>
71248 Exim recognizes an admin user if the calling process is running as root or as
71249 the Exim user or if any of the groups associated with the calling process is
71250 the Exim group. It is not necessary actually to be running under the Exim
71251 group. However, if admin users who are not root or the Exim user are to access
71252 the contents of files on the spool via the Exim monitor (which runs
71253 unprivileged), Exim must be built to allow group read access to its spool
71254 files.
71255 </para>
71256 <para>
71257 By default, regular users are trusted to perform basic testing and
71258 introspection commands, as themselves.  This setting can be tightened by
71259 setting the <option>commandline_checks_require_admin</option> option.
71260 This affects most of the checking options,
71261 such as <option>-be</option> and anything else <option>-b*</option>.
71262 </para>
71263 </section>
71264 <section id="SECID275">
71265 <title>Spool files</title>
71266 <para>
71267 <indexterm role="concept">
71268 <primary>spool directory</primary>
71269 <secondary>files</secondary>
71270 </indexterm>
71271 Exim&#x2019;s spool directory and everything it contains is owned by the Exim user and
71272 set to the Exim group. The mode for spool files is defined in the
71273 <filename>Local/Makefile</filename> configuration file, and defaults to 0640. This means that
71274 any user who is a member of the Exim group can access these files.
71275 </para>
71276 </section>
71277 <section id="SECID276">
71278 <title>Use of argv[0]</title>
71279 <para>
71280 Exim examines the last component of <option>argv[0]</option>, and if it matches one of a set
71281 of specific strings, Exim assumes certain options. For example, calling Exim
71282 with the last component of <option>argv[0]</option> set to <quote>rsmtp</quote> is exactly equivalent
71283 to calling it with the option <option>-bS</option>. There are no security implications in
71284 this.
71285 </para>
71286 </section>
71287 <section id="SECID277">
71288 <title>Use of %f formatting</title>
71289 <para>
71290 The only use made of <quote>%f</quote> by Exim is in formatting load average values. These
71291 are actually stored in integer variables as 1000 times the load average.
71292 Consequently, their range is limited and so therefore is the length of the
71293 converted output.
71294 </para>
71295 </section>
71296 <section id="SECID278">
71297 <title>Embedded Exim path</title>
71298 <para>
71299 Exim uses its own path name, which is embedded in the code, only when it needs
71300 to re-exec in order to regain root privilege. Therefore, it is not root when it
71301 does so. If some bug allowed the path to get overwritten, it would lead to an
71302 arbitrary program&#x2019;s being run as exim, not as root.
71303 </para>
71304 </section>
71305 <section id="SECTdynmoddir">
71306 <title>Dynamic module directory</title>
71307 <para>
71308 Any dynamically loadable modules must be installed into the directory
71309 defined in <literal>LOOKUP_MODULE_DIR</literal> in <filename>Local/Makefile</filename> for Exim to permit
71310 loading it.
71311 </para>
71312 </section>
71313 <section id="SECID279">
71314 <title>Use of sprintf()</title>
71315 <para>
71316 <indexterm role="concept">
71317 <primary><function>sprintf()</function></primary>
71318 </indexterm>
71319 A large number of occurrences of <quote>sprintf</quote> in the code are actually calls to
71320 <emphasis>string_sprintf()</emphasis>, a function that returns the result in malloc&#x2019;d store.
71321 The intermediate formatting is done into a large fixed buffer by a function
71322 that runs through the format string itself, and checks the length of each
71323 conversion before performing it, thus preventing buffer overruns.
71324 </para>
71325 <para>
71326 The remaining uses of <function>sprintf()</function> happen in controlled circumstances where
71327 the output buffer is known to be sufficiently long to contain the converted
71328 string.
71329 </para>
71330 </section>
71331 <section id="SECID280">
71332 <title>Use of debug_printf() and log_write()</title>
71333 <para>
71334 Arbitrary strings are passed to both these functions, but they do their
71335 formatting by calling the function <emphasis>string_vformat()</emphasis>, which runs through
71336 the format string itself, and checks the length of each conversion.
71337 </para>
71338 </section>
71339 <section id="SECID281">
71340 <title>Use of strcat() and strcpy()</title>
71341 <para>
71342 These are used only in cases where the output buffer is known to be large
71343 enough to hold the result.
71344 <indexterm role="concept" startref="IIDsecurcon" class="endofrange"/>
71345 </para>
71346 </section>
71347 </chapter>
71348
71349 <chapter id="CHAPspool">
71350 <title>Format of spool files</title>
71351 <para>
71352 <indexterm role="concept" id="IIDforspo1" class="startofrange">
71353 <primary>format</primary>
71354 <secondary>spool files</secondary>
71355 </indexterm>
71356 <indexterm role="concept" id="IIDforspo2" class="startofrange">
71357 <primary>spool directory</primary>
71358 <secondary>format of files</secondary>
71359 </indexterm>
71360 <indexterm role="concept" id="IIDforspo3" class="startofrange">
71361 <primary>spool files</primary>
71362 <secondary>format of</secondary>
71363 </indexterm>
71364 <indexterm role="concept">
71365 <primary>spool files</primary>
71366 <secondary>editing</secondary>
71367 </indexterm>
71368 A message on Exim&#x2019;s queue consists of two files, whose names are the message id
71369 followed by -D and -H, respectively. The data portion of the message is kept in
71370 the -D file on its own. The message&#x2019;s envelope, status, and headers are all
71371 kept in the -H file, whose format is described in this chapter. Each of these
71372 two files contains the final component of its own name as its first line. This
71373 is insurance against disk crashes where the directory is lost but the files
71374 themselves are recoverable.
71375 </para>
71376 <para>
71377 The file formats may be changed, or new formats added, at any release.
71378 Spool files are not intended as an interface to other programs
71379 and should not be used as such.
71380 </para>
71381 <para>
71382 Some people are tempted into editing -D files in order to modify messages. You
71383 need to be extremely careful if you do this; it is not recommended and you are
71384 on your own if you do it. Here are some of the pitfalls:
71385 </para>
71386 <itemizedlist>
71387 <listitem>
71388 <para>
71389 You must ensure that Exim does not try to deliver the message while you are
71390 fiddling with it. The safest way is to take out a write lock on the -D file,
71391 which is what Exim itself does, using <function>fcntl()</function>. If you update the file in
71392 place, the lock will be retained. If you write a new file and rename it, the
71393 lock will be lost at the instant of rename.
71394 </para>
71395 </listitem>
71396 <listitem>
71397 <para>
71398 <indexterm role="variable">
71399 <primary><varname>$body_linecount</varname></primary>
71400 </indexterm>
71401 If you change the number of lines in the file, the value of
71402 <varname>$body_linecount</varname>, which is stored in the -H file, will be incorrect and can
71403 cause incomplete transmission of messages or undeliverable messages.
71404 </para>
71405 </listitem>
71406 <listitem>
71407 <para>
71408 If the message is in MIME format, you must take care not to break it.
71409 </para>
71410 </listitem>
71411 <listitem>
71412 <para>
71413 If the message is cryptographically signed, any change will invalidate the
71414 signature.
71415 </para>
71416 </listitem>
71417 </itemizedlist>
71418 <para>
71419 All in all, modifying -D files is fraught with danger.
71420 </para>
71421 <para>
71422 Files whose names end with -J may also be seen in the <filename>input</filename> directory (or
71423 its subdirectories when <option>split_spool_directory</option> is set). These are journal
71424 files, used to record addresses to which the message has been delivered during
71425 the course of a delivery attempt. If there are still undelivered recipients at
71426 the end, the -H file is updated, and the -J file is deleted. If, however, there
71427 is some kind of crash (for example, a power outage) before this happens, the -J
71428 file remains in existence. When Exim next processes the message, it notices the
71429 -J file and uses it to update the -H file before starting the next delivery
71430 attempt.
71431 </para>
71432 <para>
71433 Files whose names end with -K or .eml may also be seen in the spool.
71434 These are temporaries used for DKIM or malware processing, when that is used.
71435 They should be tidied up by normal operations; any old ones are probably
71436 relics of crashes and can be removed.
71437 </para>
71438 <section id="SECID282">
71439 <title>Format of the -H file</title>
71440 <para>
71441 <indexterm role="concept">
71442 <primary>uid (user id)</primary>
71443 <secondary>in spool file</secondary>
71444 </indexterm>
71445 <indexterm role="concept">
71446 <primary>gid (group id)</primary>
71447 <secondary>in spool file</secondary>
71448 </indexterm>
71449 The second line of the -H file contains the login name for the uid of the
71450 process that called Exim to read the message, followed by the numerical uid and
71451 gid. For a locally generated message, this is normally the user who sent the
71452 message. For a message received over TCP/IP via the daemon, it is
71453 normally the Exim user.
71454 </para>
71455 <para>
71456 The third line of the file contains the address of the message&#x2019;s sender as
71457 transmitted in the envelope, contained in angle brackets. The sender address is
71458 empty for bounce messages. For incoming SMTP mail, the sender address is given
71459 in the MAIL command. For locally generated mail, the sender address is
71460 created by Exim from the login name of the current user and the configured
71461 <option>qualify_domain</option>. However, this can be overridden by the <option>-f</option> option or a
71462 leading <quote>From&nbsp;</quote> line if the caller is trusted, or if the supplied address is
71463 <quote>&lt;&gt;</quote> or an address that matches <option>untrusted_set_senders</option>.
71464 </para>
71465 <para>
71466 The fourth line contains two numbers. The first is the time that the message
71467 was received, in the conventional Unix form &ndash; the number of seconds since the
71468 start of the epoch. The second number is a count of the number of messages
71469 warning of delayed delivery that have been sent to the sender.
71470 </para>
71471 <para>
71472 There follow a number of lines starting with a hyphen. These can appear in any
71473 order, and are omitted when not relevant:
71474 </para>
71475 <variablelist>
71476 <varlistentry>
71477 <term><option>-acl</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;&nbsp;&lt;<emphasis>length</emphasis>&gt;</term>
71478 <listitem>
71479 <para>
71480 This item is obsolete, and is not generated from Exim release 4.61 onwards;
71481 <option>-aclc</option> and <option>-aclm</option> are used instead. However, <option>-acl</option> is still
71482 recognized, to provide backward compatibility. In the old format, a line of
71483 this form is present for every ACL variable that is not empty. The number
71484 identifies the variable; the <option>acl_c</option><emphasis role="bold">x</emphasis> variables are numbered 0&ndash;9 and
71485 the <option>acl_m</option><emphasis role="bold">x</emphasis> variables are numbered 10&ndash;19. The length is the length of
71486 the data string for the variable. The string itself starts at the beginning of
71487 the next line, and is followed by a newline character. It may contain internal
71488 newlines.
71489 </para>
71490 </listitem></varlistentry>
71491 <varlistentry>
71492 <term><option>-aclc</option>&nbsp;&lt;<emphasis>rest-of-name</emphasis>&gt;&nbsp;&lt;<emphasis>length</emphasis>&gt;</term>
71493 <listitem>
71494 <para>
71495 A line of this form is present for every ACL connection variable that is
71496 defined. Note that there is a space between <option>-aclc</option> and the rest of the name.
71497 The length is the length of the data string for the variable. The string itself
71498 starts at the beginning of the next line, and is followed by a newline
71499 character. It may contain internal newlines.
71500 </para>
71501 </listitem></varlistentry>
71502 <varlistentry>
71503 <term><option>-aclm</option>&nbsp;&lt;<emphasis>rest-of-name</emphasis>&gt;&nbsp;&lt;<emphasis>length</emphasis>&gt;</term>
71504 <listitem>
71505 <para>
71506 A line of this form is present for every ACL message variable that is defined.
71507 Note that there is a space between <option>-aclm</option> and the rest of the name. The
71508 length is the length of the data string for the variable. The string itself
71509 starts at the beginning of the next line, and is followed by a newline
71510 character. It may contain internal newlines.
71511 </para>
71512 </listitem></varlistentry>
71513 <varlistentry>
71514 <term><option>-active_hostname</option>&nbsp;&lt;<emphasis>hostname</emphasis>&gt;</term>
71515 <listitem>
71516 <para>
71517 This is present if, when the message was received over SMTP, the value of
71518 <varname>$smtp_active_hostname</varname> was different to the value of <varname>$primary_hostname</varname>.
71519 </para>
71520 </listitem></varlistentry>
71521 <varlistentry>
71522 <term><option>-allow_unqualified_recipient</option></term>
71523 <listitem>
71524 <para>
71525 This is present if unqualified recipient addresses are permitted in header
71526 lines (to stop such addresses from being qualified if rewriting occurs at
71527 transport time). Local messages that were input using <option>-bnq</option> and remote
71528 messages from hosts that match <option>recipient_unqualified_hosts</option> set this flag.
71529 </para>
71530 </listitem></varlistentry>
71531 <varlistentry>
71532 <term><option>-allow_unqualified_sender</option></term>
71533 <listitem>
71534 <para>
71535 This is present if unqualified sender addresses are permitted in header lines
71536 (to stop such addresses from being qualified if rewriting occurs at transport
71537 time). Local messages that were input using <option>-bnq</option> and remote messages from
71538 hosts that match <option>sender_unqualified_hosts</option> set this flag.
71539 </para>
71540 </listitem></varlistentry>
71541 <varlistentry>
71542 <term><option>-auth_id</option>&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
71543 <listitem>
71544 <para>
71545 The id information for a message received on an authenticated SMTP connection
71546 &ndash; the value of the <varname>$authenticated_id</varname> variable.
71547 </para>
71548 </listitem></varlistentry>
71549 <varlistentry>
71550 <term><option>-auth_sender</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;</term>
71551 <listitem>
71552 <para>
71553 The address of an authenticated sender &ndash; the value of the
71554 <varname>$authenticated_sender</varname> variable.
71555 </para>
71556 </listitem></varlistentry>
71557 <varlistentry>
71558 <term><option>-body_linecount</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;</term>
71559 <listitem>
71560 <para>
71561 This records the number of lines in the body of the message, and is
71562 present unless <option>-spool_file_wireformat</option> is.
71563 </para>
71564 </listitem></varlistentry>
71565 <varlistentry>
71566 <term><option>-body_zerocount</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;</term>
71567 <listitem>
71568 <para>
71569 This records the number of binary zero bytes in the body of the message, and is
71570 present if the number is greater than zero.
71571 </para>
71572 </listitem></varlistentry>
71573 <varlistentry>
71574 <term><option>-deliver_firsttime</option></term>
71575 <listitem>
71576 <para>
71577 This is written when a new message is first added to the spool. When the spool
71578 file is updated after a deferral, it is omitted.
71579 </para>
71580 </listitem></varlistentry>
71581 <varlistentry>
71582 <term><option>-frozen</option>&nbsp;&lt;<emphasis>time</emphasis>&gt;</term>
71583 <listitem>
71584 <para>
71585 <indexterm role="concept">
71586 <primary>frozen messages</primary>
71587 <secondary>spool data</secondary>
71588 </indexterm>
71589 The message is frozen, and the freezing happened at &lt;<emphasis>time</emphasis>&gt;.
71590 </para>
71591 </listitem></varlistentry>
71592 <varlistentry>
71593 <term><option>-helo_name</option>&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
71594 <listitem>
71595 <para>
71596 This records the host name as specified by a remote host in a HELO or EHLO
71597 command.
71598 </para>
71599 </listitem></varlistentry>
71600 <varlistentry>
71601 <term><option>-host_address</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;.&lt;<emphasis>port</emphasis>&gt;</term>
71602 <listitem>
71603 <para>
71604 This records the IP address of the host from which the message was received and
71605 the remote port number that was used. It is omitted for locally generated
71606 messages.
71607 </para>
71608 </listitem></varlistentry>
71609 <varlistentry>
71610 <term><option>-host_auth</option>&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
71611 <listitem>
71612 <para>
71613 If the message was received on an authenticated SMTP connection, this records
71614 the name of the authenticator &ndash; the value of the
71615 <varname>$sender_host_authenticated</varname> variable.
71616 </para>
71617 </listitem></varlistentry>
71618 <varlistentry>
71619 <term><option>-host_lookup_failed</option></term>
71620 <listitem>
71621 <para>
71622 This is present if an attempt to look up the sending host&#x2019;s name from its IP
71623 address failed. It corresponds to the <varname>$host_lookup_failed</varname> variable.
71624 </para>
71625 </listitem></varlistentry>
71626 <varlistentry>
71627 <term><option>-host_name</option>&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
71628 <listitem>
71629 <para>
71630 <indexterm role="concept">
71631 <primary>reverse DNS lookup</primary>
71632 </indexterm>
71633 <indexterm role="concept">
71634 <primary>DNS</primary>
71635 <secondary>reverse lookup</secondary>
71636 </indexterm>
71637 This records the name of the remote host from which the message was received,
71638 if the host name was looked up from the IP address when the message was being
71639 received. It is not present if no reverse lookup was done.
71640 </para>
71641 </listitem></varlistentry>
71642 <varlistentry>
71643 <term><option>-ident</option>&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
71644 <listitem>
71645 <para>
71646 For locally submitted messages, this records the login of the originating user,
71647 unless it was a trusted user and the <option>-oMt</option> option was used to specify an
71648 ident value. For messages received over TCP/IP, this records the ident string
71649 supplied by the remote host, if any.
71650 </para>
71651 </listitem></varlistentry>
71652 <varlistentry>
71653 <term><option>-interface_address</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;.&lt;<emphasis>port</emphasis>&gt;</term>
71654 <listitem>
71655 <para>
71656 This records the IP address of the local interface and the port number through
71657 which a message was received from a remote host. It is omitted for locally
71658 generated messages.
71659 </para>
71660 </listitem></varlistentry>
71661 <varlistentry>
71662 <term><option>-local</option></term>
71663 <listitem>
71664 <para>
71665 The message is from a local sender.
71666 </para>
71667 </listitem></varlistentry>
71668 <varlistentry>
71669 <term><option>-localerror</option></term>
71670 <listitem>
71671 <para>
71672 The message is a locally-generated bounce message.
71673 </para>
71674 </listitem></varlistentry>
71675 <varlistentry>
71676 <term><option>-local_scan</option>&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
71677 <listitem>
71678 <para>
71679 This records the data string that was returned by the <function>local_scan()</function> function
71680 when the message was received &ndash; the value of the <varname>$local_scan_data</varname>
71681 variable. It is omitted if no data was returned.
71682 </para>
71683 </listitem></varlistentry>
71684 <varlistentry>
71685 <term><option>-manual_thaw</option></term>
71686 <listitem>
71687 <para>
71688 The message was frozen but has been thawed manually, that is, by an explicit
71689 Exim command rather than via the auto-thaw process.
71690 </para>
71691 </listitem></varlistentry>
71692 <varlistentry>
71693 <term><option>-N</option></term>
71694 <listitem>
71695 <para>
71696 A testing delivery process was started using the <option>-N</option> option to suppress any
71697 actual deliveries, but delivery was deferred. At any further delivery attempts,
71698 <option>-N</option> is assumed.
71699 </para>
71700 </listitem></varlistentry>
71701 <varlistentry>
71702 <term><option>-received_protocol</option></term>
71703 <listitem>
71704 <para>
71705 This records the value of the <varname>$received_protocol</varname> variable, which contains
71706 the name of the protocol by which the message was received.
71707 </para>
71708 </listitem></varlistentry>
71709 <varlistentry>
71710 <term><option>-sender_set_untrusted</option></term>
71711 <listitem>
71712 <para>
71713 The envelope sender of this message was set by an untrusted local caller (used
71714 to ensure that the caller is displayed in queue listings).
71715 </para>
71716 </listitem></varlistentry>
71717 <varlistentry>
71718 <term><option>-spam_score_int</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;</term>
71719 <listitem>
71720 <para>
71721 If a message was scanned by SpamAssassin, this is present. It records the value
71722 of <varname>$spam_score_int</varname>.
71723 </para>
71724 </listitem></varlistentry>
71725 <varlistentry>
71726 <term><option>-spool_file_wireformat</option></term>
71727 <listitem>
71728 <para>
71729 The -D file for this message is in wire-format (for ESMTP CHUNKING)
71730 rather than Unix-format.
71731 The line-ending is CRLF rather than newline.
71732 There is still, however, no leading-dot-stuffing.
71733 </para>
71734 </listitem></varlistentry>
71735 <varlistentry>
71736 <term><option>-tls_certificate_verified</option></term>
71737 <listitem>
71738 <para>
71739 A TLS certificate was received from the client that sent this message, and the
71740 certificate was verified by the server.
71741 </para>
71742 </listitem></varlistentry>
71743 <varlistentry>
71744 <term><option>-tls_cipher</option>&nbsp;&lt;<emphasis>cipher name</emphasis>&gt;</term>
71745 <listitem>
71746 <para>
71747 When the message was received over an encrypted connection, this records the
71748 name of the cipher suite that was used.
71749 </para>
71750 </listitem></varlistentry>
71751 <varlistentry>
71752 <term><option>-tls_peerdn</option>&nbsp;&lt;<emphasis>peer DN</emphasis>&gt;</term>
71753 <listitem>
71754 <para>
71755 When the message was received over an encrypted connection, and a certificate
71756 was received from the client, this records the Distinguished Name from that
71757 certificate.
71758 </para>
71759 </listitem></varlistentry>
71760 </variablelist>
71761 <para revisionflag="changed">
71762 Any of the above may have an extra hyphen prepended, to indicate the the
71763 corresponding data is untrusted.
71764 </para>
71765 <para>
71766 Following the options there is a list of those addresses to which the message
71767 is not to be delivered. This set of addresses is initialized from the command
71768 line when the <option>-t</option> option is used and <option>extract_addresses_remove_arguments</option>
71769 is set; otherwise it starts out empty. Whenever a successful delivery is made,
71770 the address is added to this set. The addresses are kept internally as a
71771 balanced binary tree, and it is a representation of that tree which is written
71772 to the spool file. If an address is expanded via an alias or forward file, the
71773 original address is added to the tree when deliveries to all its child
71774 addresses are complete.
71775 </para>
71776 <para>
71777 If the tree is empty, there is a single line in the spool file containing just
71778 the text <quote>XX</quote>. Otherwise, each line consists of two letters, which are either
71779 Y or N, followed by an address. The address is the value for the node of the
71780 tree, and the letters indicate whether the node has a left branch and/or a
71781 right branch attached to it, respectively. If branches exist, they immediately
71782 follow. Here is an example of a three-node tree:
71783 </para>
71784 <literallayout class="monospaced">
71785 YY darcy@austen.fict.example
71786 NN alice@wonderland.fict.example
71787 NN editor@thesaurus.ref.example
71788 </literallayout>
71789 <para>
71790 After the non-recipients tree, there is a list of the message&#x2019;s recipients.
71791 This is a simple list, preceded by a count. It includes all the original
71792 recipients of the message, including those to whom the message has already been
71793 delivered. In the simplest case, the list contains one address per line. For
71794 example:
71795 </para>
71796 <literallayout class="monospaced">
71797 4
71798 editor@thesaurus.ref.example
71799 darcy@austen.fict.example
71800 rdo@foundation
71801 alice@wonderland.fict.example
71802 </literallayout>
71803 <para>
71804 However, when a child address has been added to the top-level addresses as a
71805 result of the use of the <option>one_time</option> option on a <command>redirect</command> router, each
71806 line is of the following form:
71807 </para>
71808 <literallayout>
71809 &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;
71810 </literallayout>
71811 <para>
71812 The 01 flag bit indicates the presence of the three other fields that follow
71813 the top-level address. Other bits may be used in future to support additional
71814 fields. The &lt;<emphasis>parent number</emphasis>&gt; is the offset in the recipients list of the
71815 original parent of the <quote>one time</quote> address. The first two fields are the
71816 envelope sender that is associated with this address and its length. If the
71817 length is zero, there is no special envelope sender (there are then two space
71818 characters in the line). A non-empty field can arise from a <command>redirect</command> router
71819 that has an <option>errors_to</option> setting.
71820 </para>
71821 <para>
71822 A blank line separates the envelope and status information from the headers
71823 which follow. A header may occupy several lines of the file, and to save effort
71824 when reading it in, each header is preceded by a number and an identifying
71825 character. The number is the number of characters in the header, including any
71826 embedded newlines and the terminating newline. The character is one of the
71827 following:
71828 </para>
71829 <informaltable frame="none">
71830 <tgroup cols="2" colsep="0" rowsep="0">
71831 <colspec colwidth="50pt" align="left"/>
71832 <colspec colwidth="254pt" align="left"/>
71833 <tbody>
71834 <row>
71835 <entry>&lt;<emphasis>blank</emphasis>&gt;</entry>
71836 <entry>header in which Exim has no special interest</entry>
71837 </row>
71838 <row>
71839 <entry><literal>B</literal></entry>
71840 <entry><emphasis>Bcc:</emphasis> header</entry>
71841 </row>
71842 <row>
71843 <entry><literal>C</literal></entry>
71844 <entry><emphasis>Cc:</emphasis> header</entry>
71845 </row>
71846 <row>
71847 <entry><literal>F</literal></entry>
71848 <entry><emphasis>From:</emphasis> header</entry>
71849 </row>
71850 <row>
71851 <entry><literal>I</literal></entry>
71852 <entry><emphasis>Message-id:</emphasis> header</entry>
71853 </row>
71854 <row>
71855 <entry><literal>P</literal></entry>
71856 <entry><emphasis>Received:</emphasis> header &ndash; P for <quote>postmark</quote></entry>
71857 </row>
71858 <row>
71859 <entry><literal>R</literal></entry>
71860 <entry><emphasis>Reply-To:</emphasis> header</entry>
71861 </row>
71862 <row>
71863 <entry><literal>S</literal></entry>
71864 <entry><emphasis>Sender:</emphasis> header</entry>
71865 </row>
71866 <row>
71867 <entry><literal>T</literal></entry>
71868 <entry><emphasis>To:</emphasis> header</entry>
71869 </row>
71870 <row>
71871 <entry><literal>*</literal></entry>
71872 <entry>replaced or deleted header</entry>
71873 </row>
71874 </tbody>
71875 </tgroup>
71876 </informaltable>
71877 <para>
71878 Deleted or replaced (rewritten) headers remain in the spool file for debugging
71879 purposes. They are not transmitted when the message is delivered. Here is a
71880 typical set of headers:
71881 </para>
71882 <literallayout class="monospaced">
71883 111P Received: by hobbit.fict.example with local (Exim 4.00)
71884 id 14y9EI-00026G-00; Fri, 11 May 2001 10:28:59 +0100
71885 049  Message-Id: &lt;E14y9EI-00026G-00@hobbit.fict.example&gt;
71886 038* X-rewrote-sender: bb@hobbit.fict.example
71887 042* From: Bilbo Baggins &lt;bb@hobbit.fict.example&gt;
71888 049F From: Bilbo Baggins &lt;B.Baggins@hobbit.fict.example&gt;
71889 099* To: alice@wonderland.fict.example, rdo@foundation,
71890 darcy@austen.fict.example, editor@thesaurus.ref.example
71891 104T To: alice@wonderland.fict.example, rdo@foundation.example,
71892 darcy@austen.fict.example, editor@thesaurus.ref.example
71893 038  Date: Fri, 11 May 2001 10:28:59 +0100
71894 </literallayout>
71895 <para>
71896 The asterisked headers indicate that the envelope sender, <emphasis>From:</emphasis> header, and
71897 <emphasis>To:</emphasis> header have been rewritten, the last one because routing expanded the
71898 unqualified domain <emphasis>foundation</emphasis>.
71899 <indexterm role="concept" startref="IIDforspo1" class="endofrange"/>
71900 <indexterm role="concept" startref="IIDforspo2" class="endofrange"/>
71901 <indexterm role="concept" startref="IIDforspo3" class="endofrange"/>
71902 </para>
71903 </section>
71904 <section id="SECID282a">
71905 <title>Format of the -D file</title>
71906 <para>
71907 The data file is traditionally in Unix-standard format: lines are ended with
71908 an ASCII newline character.
71909 However, when the <option>spool_wireformat</option> main option is used some -D files
71910 can have an alternate format.
71911 This is flagged by a <option>-spool_file_wireformat</option> line in the corresponding -H file.
71912 The -D file lines (not including the first name-component line) are
71913 suitable for direct copying to the wire when transmitting using the
71914 ESMTP CHUNKING option, meaning lower processing overhead.
71915 Lines are terminated with an ASCII CRLF pair.
71916 There is no dot-stuffing (and no dot-termination).
71917 </para>
71918 </section>
71919 </chapter>
71920
71921 <chapter id="CHAPdkim">
71922 <title>DKIM, SPF and DMARC</title>
71923 <titleabbrev>DKIM, SPF and DMARC Support</titleabbrev>
71924 <section id="SECDKIM">
71925 <title>DKIM (DomainKeys Identified Mail)</title>
71926 <para>
71927 <indexterm role="concept">
71928 <primary>DKIM</primary>
71929 </indexterm>
71930 </para>
71931 <para>
71932 DKIM is a mechanism by which messages sent by some entity can be provably
71933 linked to a domain which that entity controls.  It permits reputation to
71934 be tracked on a per-domain basis, rather than merely upon source IP address.
71935 DKIM is documented in RFC 6376.
71936 </para>
71937 <para>
71938 As DKIM relies on the message being unchanged in transit, messages handled
71939 by a mailing-list (which traditionally adds to the message) will not match
71940 any original DKIM signature.
71941 </para>
71942 <para>
71943 DKIM support is compiled into Exim by default if TLS support is present.
71944 It can be disabled by setting DISABLE_DKIM=yes in <filename>Local/Makefile</filename>.
71945 </para>
71946 <para>
71947 Exim&#x2019;s DKIM implementation allows for
71948 </para>
71949 <orderedlist numeration="arabic">
71950 <listitem>
71951 <para>
71952 Signing outgoing messages: This function is implemented in the SMTP transport.
71953 It can co-exist with all other Exim features
71954 (including transport filters)
71955 except cutthrough delivery.
71956 </para>
71957 </listitem>
71958 <listitem>
71959 <para>
71960 Verifying signatures in incoming messages: This is implemented by an additional
71961 ACL (acl_smtp_dkim), which can be called several times per message, with
71962 different signature contexts.
71963 </para>
71964 </listitem>
71965 </orderedlist>
71966 <para>
71967 In typical Exim style, the verification implementation does not include any
71968 default "policy". Instead it enables you to build your own policy using
71969 Exim&#x2019;s standard controls.
71970 </para>
71971 <para>
71972 Please note that verification of DKIM signatures in incoming mail is turned
71973 on by default for logging (in the &lt;= line) purposes.
71974 </para>
71975 <para>
71976 Additional log detail can be enabled using the <option>dkim_verbose</option> log_selector.
71977 When set, for each signature in incoming email,
71978 exim will log a line displaying the most important signature details, and the
71979 signature status. Here is an example (with line-breaks added for clarity):
71980 </para>
71981 <literallayout class="monospaced">
71982 2009-09-09 10:22:28 1MlIRf-0003LU-U3 DKIM:
71983     d=facebookmail.com s=q1-2009b
71984     c=relaxed/relaxed a=rsa-sha1
71985     i=@facebookmail.com t=1252484542 [verification succeeded]
71986 </literallayout>
71987 <para>
71988 You might want to turn off DKIM verification processing entirely for internal
71989 or relay mail sources. To do that, set the <option>dkim_disable_verify</option> ACL
71990 control modifier. This should typically be done in the RCPT ACL, at points
71991 where you accept mail from relay sources (internal hosts or authenticated
71992 senders).
71993 </para>
71994 </section>
71995 <section id="SECDKIMSIGN">
71996 <title>Signing outgoing messages</title>
71997 <para>
71998 <indexterm role="concept">
71999 <primary>DKIM</primary>
72000 <secondary>signing</secondary>
72001 </indexterm>
72002 </para>
72003 <para>
72004 For signing to be usable you must have published a DKIM record in DNS.
72005 Note that RFC 8301 (which does not cover EC keys) says:
72006 </para>
72007 <literallayout class="monospaced">
72008 rsa-sha1 MUST NOT be used for signing or verifying.
72009
72010 Signers MUST use RSA keys of at least 1024 bits for all keys.
72011 Signers SHOULD use RSA keys of at least 2048 bits.
72012 </literallayout>
72013 <para>
72014 Note also that the key content (the &#x2019;p=&#x2019; field)
72015 in the DNS record is different between RSA and EC keys;
72016 for the former it is the base64 of the ASN.1 for the RSA public key
72017 (equivalent to the private-key .pem with the header/trailer stripped)
72018 but for EC keys it is the base64 of the pure key; no ASN.1 wrapping.
72019 </para>
72020 <para>
72021 Signing is enabled by setting private options on the SMTP transport.
72022 These options take (expandable) strings as arguments.
72023 </para>
72024 <para>
72025 <indexterm role="option">
72026 <primary><option>unset</option></primary>
72027 </indexterm>
72028 </para>
72029 <informaltable frame="all">
72030 <tgroup cols="4" colsep="0" rowsep="0">
72031 <colspec colwidth="8*" align="left"/>
72032 <colspec colwidth="6*" align="center"/>
72033 <colspec colwidth="6*" align="center"/>
72034 <colspec colwidth="6*" align="right"/>
72035 <tbody>
72036 <row>
72037 <entry><option>dkim_domain</option></entry>
72038 <entry>Use: <emphasis>smtp</emphasis></entry>
72039 <entry>Type: <emphasis>string</emphasis></entry>
72040 <entry>Default: <emphasis>list</emphasis>&dagger;<emphasis></emphasis></entry>
72041 </row>
72042 </tbody>
72043 </tgroup>
72044 </informaltable>
72045 <para>
72046 The domain(s) you want to sign with.
72047 After expansion, this can be a list.
72048 Each element in turn,
72049 </para>
72050 <para revisionflag="changed">
72051 lowercased,
72052 </para>
72053 <para>
72054 is put into the <option>$dkim_domain</option> expansion variable
72055 while expanding the remaining signing options.
72056 If it is empty after expansion, DKIM signing is not done,
72057 and no error will result even if <option>dkim_strict</option> is set.
72058 </para>
72059 <para>
72060 <indexterm role="option">
72061 <primary><option>unset</option></primary>
72062 </indexterm>
72063 </para>
72064 <informaltable frame="all">
72065 <tgroup cols="4" colsep="0" rowsep="0">
72066 <colspec colwidth="8*" align="left"/>
72067 <colspec colwidth="6*" align="center"/>
72068 <colspec colwidth="6*" align="center"/>
72069 <colspec colwidth="6*" align="right"/>
72070 <tbody>
72071 <row>
72072 <entry><option>dkim_selector</option></entry>
72073 <entry>Use: <emphasis>smtp</emphasis></entry>
72074 <entry>Type: <emphasis>string</emphasis></entry>
72075 <entry>Default: <emphasis>list</emphasis>&dagger;<emphasis></emphasis></entry>
72076 </row>
72077 </tbody>
72078 </tgroup>
72079 </informaltable>
72080 <para>
72081 This sets the key selector string.
72082 After expansion, which can use <varname>$dkim_domain</varname>, this can be a list.
72083 Each element in turn is put in the expansion
72084 variable <option>$dkim_selector</option> which may be used in the <option>dkim_private_key</option>
72085 option along with <option>$dkim_domain</option>.
72086 If the option is empty after expansion, DKIM signing is not done for this domain,
72087 and no error will result even if <option>dkim_strict</option> is set.
72088 </para>
72089 <para>
72090 <indexterm role="option">
72091 <primary><option>dkim_private_key</option></primary>
72092 </indexterm>
72093 </para>
72094 <informaltable frame="all">
72095 <tgroup cols="4" colsep="0" rowsep="0">
72096 <colspec colwidth="8*" align="left"/>
72097 <colspec colwidth="6*" align="center"/>
72098 <colspec colwidth="6*" align="center"/>
72099 <colspec colwidth="6*" align="right"/>
72100 <tbody>
72101 <row>
72102 <entry><option>dkim_private_key</option></entry>
72103 <entry>Use: <emphasis>smtp</emphasis></entry>
72104 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
72105 <entry>Default: <emphasis>unset</emphasis></entry>
72106 </row>
72107 </tbody>
72108 </tgroup>
72109 </informaltable>
72110 <para>
72111 This sets the private key to use.
72112 You can use the <option>$dkim_domain</option> and
72113 <option>$dkim_selector</option> expansion variables to determine the private key to use.
72114 The result can either
72115 </para>
72116 <itemizedlist>
72117 <listitem>
72118 <para>
72119 be a valid RSA private key in ASCII armor (.pem file), including line breaks
72120 </para>
72121 </listitem>
72122 <listitem>
72123 <para>
72124 with GnuTLS 3.6.0 or OpenSSL 1.1.1 or later,
72125 be a valid Ed25519 private key (same format as above)
72126 </para>
72127 </listitem>
72128 <listitem>
72129 <para>
72130 start with a slash, in which case it is treated as a file that contains
72131 the private key
72132 </para>
72133 </listitem>
72134 <listitem>
72135 <para>
72136 be "0", "false" or the empty string, in which case the message will not
72137 be signed. This case will not result in an error, even if <option>dkim_strict</option>
72138 is set.
72139 </para>
72140 </listitem>
72141 </itemizedlist>
72142 <para>
72143 To generate keys under OpenSSL:
72144 </para>
72145 <literallayout class="monospaced">
72146 openssl genrsa -out dkim_rsa.private 2048
72147 openssl rsa -in dkim_rsa.private -out /dev/stdout -pubout -outform PEM
72148 </literallayout>
72149 <para>
72150 Take the base-64 lines from the output of the second command, concatenated,
72151 for the DNS TXT record.
72152 See section 3.6 of RFC6376 for the record specification.
72153 </para>
72154 <para>
72155 Under GnuTLS:
72156 </para>
72157 <literallayout class="monospaced">
72158 certtool --generate-privkey --rsa --bits=2048 --password='' -8 --outfile=dkim_rsa.private
72159 certtool --load-privkey=dkim_rsa.private --pubkey-info
72160 </literallayout>
72161 <para>
72162 Note that RFC 8301 says:
72163 </para>
72164 <literallayout class="monospaced">
72165 Signers MUST use RSA keys of at least 1024 bits for all keys.
72166 Signers SHOULD use RSA keys of at least 2048 bits.
72167 </literallayout>
72168 <para revisionflag="changed">
72169 EC keys for DKIM are defined by RFC 8463.
72170 </para>
72171 <para>
72172 They are considerably smaller than RSA keys for equivalent protection.
72173 As they are a recent development, users should consider dual-signing
72174 (by setting a list of selectors, and an expansion for this option)
72175 for some transition period.
72176 The "_CRYPTO_SIGN_ED25519" macro will be defined if support is present
72177 for EC keys.
72178 </para>
72179 <para>
72180 OpenSSL 1.1.1 and GnuTLS 3.6.0 can create Ed25519 private keys:
72181 </para>
72182 <literallayout class="monospaced">
72183 openssl genpkey -algorithm ed25519 -out dkim_ed25519.private
72184 certtool --generate-privkey --key-type=ed25519 --outfile=dkim_ed25519.private
72185 </literallayout>
72186 <para>
72187 To produce the required public key value for a DNS record:
72188 </para>
72189 <literallayout class="monospaced">
72190 openssl pkey -outform DER -pubout -in dkim_ed25519.private | tail -c +13 | base64
72191 certtool --load_privkey=dkim_ed25519.private --pubkey_info --outder | tail -c +13 | base64
72192 </literallayout>
72193 <para revisionflag="changed">
72194 Exim also supports an alternate format
72195 of Ed25519 keys in DNS which was a candidate during development
72196 of the standard, but not adopted.
72197 A future release will probably drop that support.
72198 </para>
72199 <para>
72200 <indexterm role="option">
72201 <primary><option>dkim_hash</option></primary>
72202 </indexterm>
72203 </para>
72204 <informaltable frame="all">
72205 <tgroup cols="4" colsep="0" rowsep="0">
72206 <colspec colwidth="8*" align="left"/>
72207 <colspec colwidth="6*" align="center"/>
72208 <colspec colwidth="6*" align="center"/>
72209 <colspec colwidth="6*" align="right"/>
72210 <tbody>
72211 <row>
72212 <entry><option>dkim_hash</option></entry>
72213 <entry>Use: <emphasis>smtp</emphasis></entry>
72214 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
72215 <entry>Default: <emphasis>sha256</emphasis></entry>
72216 </row>
72217 </tbody>
72218 </tgroup>
72219 </informaltable>
72220 <para>
72221 Can be set to any one of the supported hash methods, which are:
72222 </para>
72223 <itemizedlist>
72224 <listitem>
72225 <para>
72226 <literal>sha1</literal> &ndash; should not be used, is old and insecure
72227 </para>
72228 </listitem>
72229 <listitem>
72230 <para>
72231 <literal>sha256</literal> &ndash; the default
72232 </para>
72233 </listitem>
72234 <listitem>
72235 <para>
72236 <literal>sha512</literal> &ndash; possibly more secure but less well supported
72237 </para>
72238 </listitem>
72239 </itemizedlist>
72240 <para>
72241 Note that RFC 8301 says:
72242 </para>
72243 <literallayout class="monospaced">
72244 rsa-sha1 MUST NOT be used for signing or verifying.
72245 </literallayout>
72246 <para>
72247 <indexterm role="option">
72248 <primary><option>dkim_identity</option></primary>
72249 </indexterm>
72250 </para>
72251 <informaltable frame="all">
72252 <tgroup cols="4" colsep="0" rowsep="0">
72253 <colspec colwidth="8*" align="left"/>
72254 <colspec colwidth="6*" align="center"/>
72255 <colspec colwidth="6*" align="center"/>
72256 <colspec colwidth="6*" align="right"/>
72257 <tbody>
72258 <row>
72259 <entry><option>dkim_identity</option></entry>
72260 <entry>Use: <emphasis>smtp</emphasis></entry>
72261 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
72262 <entry>Default: <emphasis>unset</emphasis></entry>
72263 </row>
72264 </tbody>
72265 </tgroup>
72266 </informaltable>
72267 <para>
72268 If set after expansion, the value is used to set an "i=" tag in
72269 the signing header.  The DKIM standards restrict the permissible
72270 syntax of this optional tag to a mail address, with possibly-empty
72271 local part, an @, and a domain identical to or subdomain of the "d="
72272 tag value.  Note that Exim does not check the value.
72273 </para>
72274 <para>
72275 <indexterm role="option">
72276 <primary><option>dkim_canon</option></primary>
72277 </indexterm>
72278 </para>
72279 <informaltable frame="all">
72280 <tgroup cols="4" colsep="0" rowsep="0">
72281 <colspec colwidth="8*" align="left"/>
72282 <colspec colwidth="6*" align="center"/>
72283 <colspec colwidth="6*" align="center"/>
72284 <colspec colwidth="6*" align="right"/>
72285 <tbody>
72286 <row>
72287 <entry><option>dkim_canon</option></entry>
72288 <entry>Use: <emphasis>smtp</emphasis></entry>
72289 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
72290 <entry>Default: <emphasis>unset</emphasis></entry>
72291 </row>
72292 </tbody>
72293 </tgroup>
72294 </informaltable>
72295 <para>
72296 This option sets the canonicalization method used when signing a message.
72297 The DKIM RFC currently supports two methods: "simple" and "relaxed".
72298 The option defaults to "relaxed" when unset. Note: the current implementation
72299 only supports signing with the same canonicalization method for both headers and body.
72300 </para>
72301 <para>
72302 <indexterm role="option">
72303 <primary><option>dkim_strict</option></primary>
72304 </indexterm>
72305 </para>
72306 <informaltable frame="all">
72307 <tgroup cols="4" colsep="0" rowsep="0">
72308 <colspec colwidth="8*" align="left"/>
72309 <colspec colwidth="6*" align="center"/>
72310 <colspec colwidth="6*" align="center"/>
72311 <colspec colwidth="6*" align="right"/>
72312 <tbody>
72313 <row>
72314 <entry><option>dkim_strict</option></entry>
72315 <entry>Use: <emphasis>smtp</emphasis></entry>
72316 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
72317 <entry>Default: <emphasis>unset</emphasis></entry>
72318 </row>
72319 </tbody>
72320 </tgroup>
72321 </informaltable>
72322 <para>
72323 This  option  defines  how  Exim  behaves  when  signing a message that
72324 should be signed fails for some reason.  When the expansion evaluates to
72325 either "1" or "true", Exim will defer. Otherwise Exim will send the message
72326 unsigned. You can use the <option>$dkim_domain</option> and <option>$dkim_selector</option> expansion
72327 variables here.
72328 </para>
72329 <para>
72330 <indexterm role="option">
72331 <primary><option>dkim_sign_headers</option></primary>
72332 </indexterm>
72333 </para>
72334 <informaltable frame="all">
72335 <tgroup cols="4" colsep="0" rowsep="0">
72336 <colspec colwidth="8*" align="left"/>
72337 <colspec colwidth="6*" align="center"/>
72338 <colspec colwidth="6*" align="center"/>
72339 <colspec colwidth="6*" align="right"/>
72340 <tbody>
72341 <row>
72342 <entry><option>dkim_sign_headers</option></entry>
72343 <entry>Use: <emphasis>smtp</emphasis></entry>
72344 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
72345 <entry>Default: <emphasis>see below</emphasis></entry>
72346 </row>
72347 </tbody>
72348 </tgroup>
72349 </informaltable>
72350 <para>
72351 If set, this option must expand to a colon-separated
72352 list of header names.
72353 Headers with these names, or the absence or such a header, will be included
72354 in the message signature.
72355 When unspecified, the header names listed in RFC4871 will be used,
72356 whether or not each header is present in the message.
72357 The default list is available for the expansion in the macro
72358 "_DKIM_SIGN_HEADERS".
72359 </para>
72360 <para>
72361 If a name is repeated, multiple headers by that name (or the absence thereof)
72362 will be signed.  The textually later headers in the headers part of the
72363 message are signed first, if there are multiples.
72364 </para>
72365 <para>
72366 A name can be prefixed with either an &#x2019;=&#x2019; or a &#x2019;+&#x2019; character.
72367 If an &#x2019;=&#x2019; prefix is used, all headers that are present with this name
72368 will be signed.
72369 If a &#x2019;+&#x2019; prefix if used, all headers that are present with this name
72370 will be signed, and one signature added for a missing header with the
72371 name will be appended.
72372 </para>
72373 <para>
72374 <indexterm role="option">
72375 <primary><option>dkim_timestamps</option></primary>
72376 </indexterm>
72377 </para>
72378 <informaltable frame="all">
72379 <tgroup cols="4" colsep="0" rowsep="0">
72380 <colspec colwidth="8*" align="left"/>
72381 <colspec colwidth="6*" align="center"/>
72382 <colspec colwidth="6*" align="center"/>
72383 <colspec colwidth="6*" align="right"/>
72384 <tbody>
72385 <row>
72386 <entry><option>dkim_timestamps</option></entry>
72387 <entry>Use: <emphasis>smtp</emphasis></entry>
72388 <entry>Type: <emphasis>integer</emphasis>&dagger;<emphasis></emphasis></entry>
72389 <entry>Default: <emphasis>unset</emphasis></entry>
72390 </row>
72391 </tbody>
72392 </tgroup>
72393 </informaltable>
72394 <para>
72395 This option controls the inclusion of timestamp information in the signature.
72396 If not set, no such information will be included.
72397 Otherwise, must be an unsigned number giving an offset in seconds from the current time
72398 for the expiry tag
72399 (eg. 1209600 for two weeks);
72400 both creation (t=) and expiry (x=) tags will be included.
72401 </para>
72402 <para>
72403 RFC 6376 lists these tags as RECOMMENDED.
72404 </para>
72405 </section>
72406 <section id="SECDKIMVFY">
72407 <title>Verifying DKIM signatures in incoming mail</title>
72408 <para>
72409 <indexterm role="concept">
72410 <primary>DKIM</primary>
72411 <secondary>verification</secondary>
72412 </indexterm>
72413 </para>
72414 <para>
72415 Verification of DKIM signatures in SMTP incoming email is done for all
72416 messages for which an ACL control <option>dkim_disable_verify</option> has not been set.
72417 </para>
72418 <para revisionflag="changed">
72419 <indexterm role="concept">
72420 <primary>DKIM</primary>
72421 <secondary>selecting signature algorithms</secondary>
72422 </indexterm>
72423 Individual classes of signature algorithm can be ignored by changing
72424 the main options <option>dkim_verify_hashes</option> or <option>dkim_verify_keytypes</option>.
72425 The <option>dkim_verify_minimal</option> option can be set to cease verification
72426 processing for a message once the first passing signature is found.
72427 </para>
72428 <para>
72429 <indexterm role="concept">
72430 <primary>authentication</primary>
72431 <secondary>expansion item</secondary>
72432 </indexterm>
72433 Performing verification sets up information used by the
72434 <option>authresults</option> expansion item.
72435 </para>
72436 <para revisionflag="changed">
72437 For most purposes the default option settings suffice and the remainder
72438 of this section can be ignored.
72439 </para>
72440 <para>
72441 The results of verification are made available to the
72442 <option>acl_smtp_dkim</option> ACL, which can examine and modify them.
72443 A missing ACL definition defaults to accept.
72444 By default, the ACL is called once for each
72445 syntactically(!) correct signature in the incoming message.
72446 If any ACL call does not accept, the message is not accepted.
72447 If a cutthrough delivery was in progress for the message, that is
72448 summarily dropped (having wasted the transmission effort).
72449 </para>
72450 <para>
72451 To evaluate the verification result in the ACL
72452 a large number of expansion variables
72453 containing the signature status and its details are set up during the
72454 runtime of the ACL.
72455 </para>
72456 <para>
72457 Calling the ACL only for existing signatures is not sufficient to build
72458 more advanced policies. For that reason, the main option
72459 <option>dkim_verify_signers</option>, and an expansion variable
72460 <option>$dkim_signers</option> exist.
72461 </para>
72462 <para>
72463 The main option <option>dkim_verify_signers</option> can be set to a colon-separated
72464 list of DKIM domains or identities for which the ACL <option>acl_smtp_dkim</option> is
72465 called. It is expanded when the message has been received. At this point,
72466 the expansion variable <option>$dkim_signers</option> already contains a colon-separated
72467 list of signer domains and identities for the message. When
72468 <option>dkim_verify_signers</option> is not specified in the main configuration,
72469 it defaults as:
72470 </para>
72471 <literallayout class="monospaced">
72472 dkim_verify_signers = $dkim_signers
72473 </literallayout>
72474 <para>
72475 This leads to the default behaviour of calling <option>acl_smtp_dkim</option> for each
72476 DKIM signature in the message. Current DKIM verifiers may want to explicitly
72477 call the ACL for known domains or identities. This would be achieved as follows:
72478 </para>
72479 <literallayout class="monospaced">
72480 dkim_verify_signers = paypal.com:ebay.com:$dkim_signers
72481 </literallayout>
72482 <para>
72483 This would result in <option>acl_smtp_dkim</option> always being called for "paypal.com"
72484 and "ebay.com", plus all domains and identities that have signatures in the message.
72485 You can also be more creative in constructing your policy. For example:
72486 </para>
72487 <literallayout class="monospaced">
72488 dkim_verify_signers = $sender_address_domain:$dkim_signers
72489 </literallayout>
72490 <para>
72491 If a domain or identity is listed several times in the (expanded) value of
72492 <option>dkim_verify_signers</option>, the ACL is only called once for that domain or identity.
72493 </para>
72494 <para revisionflag="changed">
72495 Note that if the option is set using untrustworthy data
72496 (such as the From: header)
72497 care should be taken to force lowercase for domains
72498 and for the domain part if identities.
72499 The default setting can be regarded as trustworthy in this respect.
72500 </para>
72501 <para>
72502 If multiple signatures match a domain (or identity), the ACL is called once
72503 for each matching signature.
72504 </para>
72505 <para>
72506 Inside the DKIM ACL, the following expansion variables are
72507 available (from most to least important):
72508 </para>
72509 <variablelist>
72510 <varlistentry>
72511 <term><option>$dkim_cur_signer</option></term>
72512 <listitem>
72513 <para>
72514 The signer that is being evaluated in this ACL run. This can be a domain or
72515 an identity. This is one of the list items from the expanded main option
72516 <option>dkim_verify_signers</option> (see above).
72517 </para>
72518 </listitem></varlistentry>
72519 <varlistentry>
72520 <term><option>$dkim_verify_status</option></term>
72521 <listitem>
72522 <para>
72523 Within the DKIM ACL,
72524 a string describing the general status of the signature. One of
72525 </para>
72526 <itemizedlist>
72527 <listitem>
72528 <para>
72529 <option>none</option>: There is no signature in the message for the current domain or
72530 identity (as reflected by <option>$dkim_cur_signer</option>).
72531 </para>
72532 </listitem>
72533 <listitem>
72534 <para>
72535 <option>invalid</option>: The signature could not be verified due to a processing error.
72536 More detail is available in <option>$dkim_verify_reason</option>.
72537 </para>
72538 </listitem>
72539 <listitem>
72540 <para>
72541 <option>fail</option>: Verification of the signature failed.  More detail is
72542 available in <option>$dkim_verify_reason</option>.
72543 </para>
72544 </listitem>
72545 <listitem>
72546 <para>
72547 <option>pass</option>: The signature passed verification. It is valid.
72548 </para>
72549 </listitem>
72550 </itemizedlist>
72551 <para>
72552 This variable can be overwritten using an ACL &#x2019;set&#x2019; modifier.
72553 This might, for instance, be done to enforce a policy restriction on
72554 hash-method or key-size:
72555 </para>
72556 <literallayout class="monospaced">
72557   warn condition       = ${if eq {$dkim_verify_status}{pass}}
72558        condition       = ${if eq {${length_3:$dkim_algo}}{rsa}}
72559        condition       = ${if or {{eq {$dkim_algo}{rsa-sha1}} \
72560                                   {&lt; {$dkim_key_length}{1024}}}}
72561        logwrite        = NOTE: forcing DKIM verify fail (was pass)
72562        set dkim_verify_status = fail
72563        set dkim_verify_reason = hash too weak or key too short
72564 </literallayout>
72565 <para>
72566 So long as a DKIM ACL is defined (it need do no more than accept),
72567 after all the DKIM ACL runs have completed, the value becomes a
72568 colon-separated list of the values after each run.
72569 This is maintained for the mime, prdr and data ACLs.
72570 </para>
72571 </listitem></varlistentry>
72572 <varlistentry>
72573 <term><option>$dkim_verify_reason</option></term>
72574 <listitem>
72575 <para>
72576 A string giving a little bit more detail when <option>$dkim_verify_status</option> is either
72577 "fail" or "invalid". One of
72578 </para>
72579 <itemizedlist>
72580 <listitem>
72581 <para>
72582 <option>pubkey_unavailable</option> (when <option>$dkim_verify_status</option>="invalid"): The public
72583 key for the domain could not be retrieved. This may be a temporary problem.
72584 </para>
72585 </listitem>
72586 <listitem>
72587 <para>
72588 <option>pubkey_syntax</option> (when <option>$dkim_verify_status</option>="invalid"): The public key
72589 record for the domain is syntactically invalid.
72590 </para>
72591 </listitem>
72592 <listitem>
72593 <para>
72594 <option>bodyhash_mismatch</option> (when <option>$dkim_verify_status</option>="fail"): The calculated
72595 body hash does not match the one specified in the signature header. This
72596 means that the message body was modified in transit.
72597 </para>
72598 </listitem>
72599 <listitem>
72600 <para>
72601 <option>signature_incorrect</option> (when <option>$dkim_verify_status</option>="fail"): The signature
72602 could not be verified. This may mean that headers were modified,
72603 re-written or otherwise changed in a way which is incompatible with
72604 DKIM verification. It may of course also mean that the signature is forged.
72605 </para>
72606 </listitem>
72607 </itemizedlist>
72608 <para>
72609 This variable can be overwritten, with any value, using an ACL &#x2019;set&#x2019; modifier.
72610 </para>
72611 </listitem></varlistentry>
72612 <varlistentry>
72613 <term><option>$dkim_domain</option></term>
72614 <listitem>
72615 <para>
72616 The signing domain. IMPORTANT: This variable is only populated if there is
72617 an actual signature in the message for the current domain or identity (as
72618 reflected by <option>$dkim_cur_signer</option>).
72619 </para>
72620 </listitem></varlistentry>
72621 <varlistentry>
72622 <term><option>$dkim_identity</option></term>
72623 <listitem>
72624 <para>
72625 The signing identity, if present. IMPORTANT: This variable is only populated
72626 if there is an actual signature in the message for the current domain or
72627 identity (as reflected by <option>$dkim_cur_signer</option>).
72628 </para>
72629 </listitem></varlistentry>
72630 <varlistentry>
72631 <term><option>$dkim_selector</option></term>
72632 <listitem>
72633 <para>
72634 The key record selector string.
72635 </para>
72636 </listitem></varlistentry>
72637 <varlistentry>
72638 <term><option>$dkim_algo</option></term>
72639 <listitem>
72640 <para>
72641 The algorithm used. One of &#x2019;rsa-sha1&#x2019; or &#x2019;rsa-sha256&#x2019;.
72642 If running under GnuTLS 3.6.0 or OpenSSL 1.1.1 or later,
72643 may also be &#x2019;ed25519-sha256&#x2019;.
72644 The "_CRYPTO_SIGN_ED25519" macro will be defined if support is present
72645 for EC keys.
72646 </para>
72647 <para>
72648 Note that RFC 8301 says:
72649 </para>
72650 <literallayout class="monospaced">
72651 rsa-sha1 MUST NOT be used for signing or verifying.
72652
72653 DKIM signatures identified as having been signed with historic
72654 algorithms (currently, rsa-sha1) have permanently failed evaluation
72655 </literallayout>
72656 <para>
72657 To enforce this you must either have a DKIM ACL which checks this variable
72658 and overwrites the <varname>$dkim_verify_status</varname> variable as discussed above,
72659 </para>
72660 <para revisionflag="changed">
72661 or have set the main option <option>dkim_verify_hashes</option> to exclude
72662 processing of such signatures.
72663 </para>
72664 </listitem></varlistentry>
72665 <varlistentry>
72666 <term><option>$dkim_canon_body</option></term>
72667 <listitem>
72668 <para>
72669 The body canonicalization method. One of &#x2019;relaxed&#x2019; or &#x2019;simple&#x2019;.
72670 </para>
72671 </listitem></varlistentry>
72672 <varlistentry>
72673 <term><option>$dkim_canon_headers</option></term>
72674 <listitem>
72675 <para>
72676 The header canonicalization method. One of &#x2019;relaxed&#x2019; or &#x2019;simple&#x2019;.
72677 </para>
72678 </listitem></varlistentry>
72679 <varlistentry>
72680 <term><option>$dkim_copiedheaders</option></term>
72681 <listitem>
72682 <para>
72683 A transcript of headers and their values which are included in the signature
72684 (copied from the &#x2019;z=&#x2019; tag of the signature).
72685 Note that RFC6376 requires that verification fail if the From: header is
72686 not included in the signature.  Exim does not enforce this; sites wishing
72687 strict enforcement should code the check explicitly.
72688 </para>
72689 </listitem></varlistentry>
72690 <varlistentry>
72691 <term><option>$dkim_bodylength</option></term>
72692 <listitem>
72693 <para>
72694 The number of signed body bytes. If zero ("0"), the body is unsigned. If no
72695 limit was set by the signer, "9999999999999" is returned. This makes sure
72696 that this variable always expands to an integer value.
72697 <emphasis role="bold">Note:</emphasis> The presence of the signature tag specifying a signing body length
72698 is one possible route to spoofing of valid DKIM signatures.
72699 A paranoid implementation might wish to regard signature where this variable
72700 shows less than the "no limit" return as being invalid.
72701 </para>
72702 </listitem></varlistentry>
72703 <varlistentry>
72704 <term><option>$dkim_created</option></term>
72705 <listitem>
72706 <para>
72707 UNIX timestamp reflecting the date and time when the signature was created.
72708 When this was not specified by the signer, "0" is returned.
72709 </para>
72710 </listitem></varlistentry>
72711 <varlistentry>
72712 <term><option>$dkim_expires</option></term>
72713 <listitem>
72714 <para>
72715 UNIX timestamp reflecting the date and time when the signer wants the
72716 signature to be treated as "expired". When this was not specified by the
72717 signer, "9999999999999" is returned. This makes it possible to do useful
72718 integer size comparisons against this value.
72719 Note that Exim does not check this value.
72720 </para>
72721 </listitem></varlistentry>
72722 <varlistentry>
72723 <term><option>$dkim_headernames</option></term>
72724 <listitem>
72725 <para>
72726 A colon-separated list of names of headers included in the signature.
72727 </para>
72728 </listitem></varlistentry>
72729 <varlistentry>
72730 <term><option>$dkim_key_testing</option></term>
72731 <listitem>
72732 <para>
72733 "1" if the key record has the "testing" flag set, "0" if not.
72734 </para>
72735 </listitem></varlistentry>
72736 <varlistentry>
72737 <term><option>$dkim_key_nosubdomains</option></term>
72738 <listitem>
72739 <para>
72740 "1" if the key record forbids subdomaining, "0" otherwise.
72741 </para>
72742 </listitem></varlistentry>
72743 <varlistentry>
72744 <term><option>$dkim_key_srvtype</option></term>
72745 <listitem>
72746 <para>
72747 Service type (tag s=) from the key record. Defaults to "*" if not specified
72748 in the key record.
72749 </para>
72750 </listitem></varlistentry>
72751 <varlistentry>
72752 <term><option>$dkim_key_granularity</option></term>
72753 <listitem>
72754 <para>
72755 Key granularity (tag g=) from the key record. Defaults to "*" if not specified
72756 in the key record.
72757 </para>
72758 </listitem></varlistentry>
72759 <varlistentry>
72760 <term><option>$dkim_key_notes</option></term>
72761 <listitem>
72762 <para>
72763 Notes from the key record (tag n=).
72764 </para>
72765 </listitem></varlistentry>
72766 <varlistentry>
72767 <term><option>$dkim_key_length</option></term>
72768 <listitem>
72769 <para>
72770 Number of bits in the key.
72771 </para>
72772 <para>
72773 Note that RFC 8301 says:
72774 </para>
72775 <literallayout class="monospaced">
72776 Verifiers MUST NOT consider signatures using RSA keys of
72777 less than 1024 bits as valid signatures.
72778 </literallayout>
72779 <para>
72780 To enforce this you must have a DKIM ACL which checks this variable
72781 and overwrites the <varname>$dkim_verify_status</varname> variable as discussed above.
72782 As EC keys are much smaller, the check should only do this for RSA keys.
72783 </para>
72784 </listitem></varlistentry>
72785 </variablelist>
72786 <para>
72787 In addition, two ACL conditions are provided:
72788 </para>
72789 <variablelist>
72790 <varlistentry>
72791 <term><option>dkim_signers</option></term>
72792 <listitem>
72793 <para>
72794 ACL condition that checks a colon-separated list of domains or identities
72795 for a match against the domain or identity that the ACL is currently verifying
72796 (reflected by <option>$dkim_cur_signer</option>). This is typically used to restrict an ACL
72797 verb to a group of domains or identities. For example:
72798 </para>
72799 <literallayout class="monospaced">
72800 # Warn when Mail purportedly from GMail has no gmail signature
72801 warn log_message = GMail sender without gmail.com DKIM signature
72802      sender_domains = gmail.com
72803      dkim_signers = gmail.com
72804      dkim_status = none
72805 </literallayout>
72806 <para>
72807 Note that the above does not check for a total lack of DKIM signing;
72808 for that check for empty <varname>$h_DKIM-Signature:</varname> in the data ACL.
72809 </para>
72810 </listitem></varlistentry>
72811 <varlistentry>
72812 <term><option>dkim_status</option></term>
72813 <listitem>
72814 <para>
72815 ACL condition that checks a colon-separated list of possible DKIM verification
72816 results against the actual result of verification. This is typically used
72817 to restrict an ACL verb to a list of verification outcomes, for example:
72818 </para>
72819 <literallayout class="monospaced">
72820 deny message = Mail from Paypal with invalid/missing signature
72821      sender_domains = paypal.com:paypal.de
72822      dkim_signers = paypal.com:paypal.de
72823      dkim_status = none:invalid:fail
72824 </literallayout>
72825 <para>
72826 The possible status keywords are: &#x2019;none&#x2019;,&#x2019;invalid&#x2019;,&#x2019;fail&#x2019; and &#x2019;pass&#x2019;. Please
72827 see the documentation of the <option>$dkim_verify_status</option> expansion variable above
72828 for more information of what they mean.
72829 </para>
72830 </listitem></varlistentry>
72831 </variablelist>
72832 </section>
72833 <section id="SECSPF">
72834 <title>SPF (Sender Policy Framework)</title>
72835 <para>
72836 <indexterm role="concept">
72837 <primary>SPF</primary>
72838 <secondary>verification</secondary>
72839 </indexterm>
72840 </para>
72841 <para>
72842 SPF is a mechanism whereby a domain may assert which IP addresses may transmit
72843 messages with its domain in the envelope from, documented by RFC 7208.
72844 For more information on SPF see <emphasis role="bold"><ulink url="http://www.open-spf.org">http://www.open-spf.org</ulink></emphasis>, a static copy of
72845 the <emphasis role="bold"><ulink url="http://openspf.org">http://openspf.org</ulink></emphasis>.
72846 </para>
72847 <para>
72848 Messages sent by a system not authorised will fail checking of such assertions.
72849 This includes retransmissions done by traditional forwarders.
72850 </para>
72851 <para>
72852 SPF verification support is built into Exim if SUPPORT_SPF=yes is set in
72853 <filename>Local/Makefile</filename>.  The support uses the <filename>libspf2</filename> library
72854 <emphasis role="bold"><ulink url="https://www.libspf2.org/">https://www.libspf2.org/</ulink></emphasis>.
72855 There is no Exim involvement in the transmission of messages;
72856 publishing certain DNS records is all that is required.
72857 </para>
72858 <para>
72859 For verification, an ACL condition and an expansion lookup are provided.
72860 <indexterm role="concept">
72861 <primary>authentication</primary>
72862 <secondary>expansion item</secondary>
72863 </indexterm>
72864 Performing verification sets up information used by the
72865 <option>authresults</option> expansion item.
72866 </para>
72867 <para>
72868 <indexterm role="concept">
72869 <primary>SPF</primary>
72870 <secondary>ACL condition</secondary>
72871 </indexterm>
72872 <indexterm role="concept">
72873 <primary>ACL</primary>
72874 <secondary>spf condition</secondary>
72875 </indexterm>
72876 The ACL condition "spf" can be used at or after the MAIL ACL.
72877 It takes as an argument a list of strings giving the outcome of the SPF check,
72878 and will succeed for any matching outcome.
72879 Valid strings are:
72880 </para>
72881 <variablelist>
72882 <varlistentry>
72883 <term><option>pass</option></term>
72884 <listitem>
72885 <para>
72886 The SPF check passed, the sending host is positively verified by SPF.
72887 </para>
72888 </listitem></varlistentry>
72889 <varlistentry>
72890 <term><option>fail</option></term>
72891 <listitem>
72892 <para>
72893 The SPF check failed, the sending host is NOT allowed to send mail for the
72894 domain in the envelope-from address.
72895 </para>
72896 </listitem></varlistentry>
72897 <varlistentry>
72898 <term><option>softfail</option></term>
72899 <listitem>
72900 <para>
72901 The SPF check failed, but the queried domain can&#x2019;t absolutely confirm that this
72902 is a forgery.
72903 </para>
72904 </listitem></varlistentry>
72905 <varlistentry>
72906 <term><option>none</option></term>
72907 <listitem>
72908 <para>
72909 The queried domain does not publish SPF records.
72910 </para>
72911 </listitem></varlistentry>
72912 <varlistentry>
72913 <term><option>neutral</option></term>
72914 <listitem>
72915 <para>
72916 The SPF check returned a "neutral" state.  This means the queried domain has
72917 published a SPF record, but wants to allow outside servers to send mail under
72918 its domain as well.  This should be treated like "none".
72919 </para>
72920 </listitem></varlistentry>
72921 <varlistentry>
72922 <term><option>permerror</option></term>
72923 <listitem>
72924 <para>
72925 This indicates a syntax error in the SPF record of the queried domain.
72926 You may deny messages when this occurs.
72927 </para>
72928 </listitem></varlistentry>
72929 <varlistentry>
72930 <term><option>temperror</option></term>
72931 <listitem>
72932 <para>
72933 This indicates a temporary error during all processing, including Exim&#x2019;s
72934 SPF processing.  You may defer messages when this occurs.
72935 </para>
72936 </listitem></varlistentry>
72937 </variablelist>
72938 <para>
72939 You can prefix each string with an exclamation mark to  invert
72940 its meaning,  for example  "!fail" will  match all  results but
72941 "fail".  The  string  list is  evaluated  left-to-right,  in a
72942 short-circuit fashion.
72943 </para>
72944 <para>
72945 Example:
72946 </para>
72947 <literallayout class="monospaced">
72948 deny spf = fail
72949      message = $sender_host_address is not allowed to send mail from \
72950                ${if def:sender_address_domain \
72951                     {$sender_address_domain}{$sender_helo_name}}.  \
72952                Please see http://www.open-spf.org/Why?scope=\
72953                ${if def:sender_address_domain {mfrom}{helo}};\
72954                identity=${if def:sender_address_domain \
72955                              {$sender_address}{$sender_helo_name}};\
72956                ip=$sender_host_address
72957 </literallayout>
72958 <para>
72959 When the spf condition has run, it sets up several expansion
72960 variables:
72961 </para>
72962 <para>
72963 <indexterm role="concept">
72964 <primary>SPF</primary>
72965 <secondary>verification variables</secondary>
72966 </indexterm>
72967 </para>
72968 <variablelist>
72969 <varlistentry>
72970 <term><varname>$spf_header_comment</varname></term>
72971 <listitem>
72972 <para>
72973 <indexterm role="variable">
72974 <primary><varname>$spf_header_comment</varname></primary>
72975 </indexterm>
72976   This contains a human-readable string describing the outcome
72977   of the SPF check. You can add it to a custom header or use
72978   it for logging purposes.
72979 </para>
72980 </listitem></varlistentry>
72981 <varlistentry>
72982 <term><varname>$spf_received</varname></term>
72983 <listitem>
72984 <para>
72985 <indexterm role="variable">
72986 <primary><varname>$spf_received</varname></primary>
72987 </indexterm>
72988   This contains a complete Received-SPF: header that can be
72989   added to the message. Please note that according to the SPF
72990   draft, this header must be added at the top of the header
72991   list. Please see section 10 on how you can do this.
72992 </para>
72993 <para>
72994   Note: in case of "Best-guess" (see below), the convention is
72995   to put this string in a header called X-SPF-Guess: instead.
72996 </para>
72997 </listitem></varlistentry>
72998 <varlistentry>
72999 <term><varname>$spf_result</varname></term>
73000 <listitem>
73001 <para>
73002 <indexterm role="variable">
73003 <primary><varname>$spf_result</varname></primary>
73004 </indexterm>
73005   This contains the outcome of the SPF check in string form,
73006   one of pass, fail, softfail, none, neutral, permerror or
73007   temperror.
73008 </para>
73009 </listitem></varlistentry>
73010 <varlistentry>
73011 <term><varname>$spf_result_guessed</varname></term>
73012 <listitem>
73013 <para>
73014 <indexterm role="variable">
73015 <primary><varname>$spf_result_guessed</varname></primary>
73016 </indexterm>
73017   This boolean is true only if a best-guess operation was used
73018   and required in order to obtain a result.
73019 </para>
73020 </listitem></varlistentry>
73021 <varlistentry>
73022 <term><varname>$spf_smtp_comment</varname></term>
73023 <listitem>
73024 <para>
73025 <indexterm role="variable">
73026 <primary><varname>$spf_smtp_comment</varname></primary>
73027 </indexterm>
73028   This contains a string that can be used in a SMTP response
73029   to the calling party. Useful for "fail".
73030 </para>
73031 </listitem></varlistentry>
73032 </variablelist>
73033 <para>
73034 <indexterm role="concept">
73035 <primary>SPF</primary>
73036 <secondary>ACL condition</secondary>
73037 </indexterm>
73038 <indexterm role="concept">
73039 <primary>ACL</primary>
73040 <secondary>spf_guess condition</secondary>
73041 </indexterm>
73042 <indexterm role="concept">
73043 <primary>SPF</primary>
73044 <secondary>best guess</secondary>
73045 </indexterm>
73046 In addition to SPF, you can also perform checks for so-called
73047 "Best-guess".  Strictly speaking, "Best-guess" is not standard
73048 SPF, but it is supported by the same framework that enables SPF
73049 capability.
73050 Refer to <emphasis role="bold"><ulink url="http://www.open-spf.org/FAQ/Best_guess_record">http://www.open-spf.org/FAQ/Best_guess_record</ulink></emphasis>
73051 for a description of what it means.
73052 </para>
73053 <para>
73054 To access this feature, simply use the spf_guess condition in place
73055 of the spf one.  For example:
73056 </para>
73057 <literallayout class="monospaced">
73058 deny spf_guess = fail
73059      message = $sender_host_address doesn't look trustworthy to me
73060 </literallayout>
73061 <para>
73062 In case you decide to reject messages based on this check, you
73063 should note that although it uses the same framework, "Best-guess"
73064 is not SPF, and therefore you should not mention SPF at all in your
73065 reject message.
73066 </para>
73067 <para>
73068 When the spf_guess condition has run, it sets up the same expansion
73069 variables as when spf condition is run, described above.
73070 </para>
73071 <para>
73072 Additionally, since Best-guess is not standardized, you may redefine
73073 what "Best-guess" means to you by redefining the main configuration
73074 <option>spf_guess</option> option.
73075 For example, the following:
73076 </para>
73077 <literallayout class="monospaced">
73078 spf_guess = v=spf1 a/16 mx/16 ptr ?all
73079 </literallayout>
73080 <para>
73081 would relax host matching rules to a broader network range.
73082 </para>
73083 <para>
73084 <indexterm role="concept">
73085 <primary>SPF</primary>
73086 <secondary>lookup expansion</secondary>
73087 </indexterm>
73088 <indexterm role="concept">
73089 <primary>lookup</primary>
73090 <secondary>spf</secondary>
73091 </indexterm>
73092 A lookup expansion is also available. It takes an email
73093 address as the key and an IP address
73094 </para>
73095 <para revisionflag="changed">
73096 (v4 or v6)
73097 </para>
73098 <para>
73099 as the database:
73100 </para>
73101 <literallayout class="monospaced">
73102   ${lookup {username@domain} spf {ip.ip.ip.ip}}
73103 </literallayout>
73104 <para>
73105 The lookup will return the same result strings as can appear in
73106 <varname>$spf_result</varname> (pass,fail,softfail,neutral,none,err_perm,err_temp).
73107 </para>
73108 </section>
73109 <section id="SECDMARC" revisionflag="changed">
73110 <title>DMARC</title>
73111 <para revisionflag="changed">
73112 <indexterm role="concept">
73113 <primary>DMARC</primary>
73114 <secondary>verification</secondary>
73115 </indexterm>
73116 </para>
73117 <para revisionflag="changed">
73118 DMARC combines feedback from SPF, DKIM, and header From: in order
73119 to attempt to provide better indicators of the authenticity of an
73120 email.  This document does not explain the fundamentals; you
73121 should read and understand how it works by visiting the website at
73122 <emphasis role="bold"><ulink url="http://www.dmarc.org/">http://www.dmarc.org/</ulink></emphasis>.
73123 </para>
73124 <para revisionflag="changed">
73125 If Exim is built with DMARC support,
73126 the libopendmarc library is used.
73127 </para>
73128 <para revisionflag="changed">
73129 For building Exim yourself, obtain the library from
73130 <emphasis role="bold"><ulink url="http://sourceforge.net/projects/opendmarc/">http://sourceforge.net/projects/opendmarc/</ulink></emphasis>
73131 to obtain a copy, or find it in your favorite package
73132 repository.  You will need to attend to the local/Makefile feature
73133 SUPPORT_DMARC and the associated LDFLAGS addition.
73134 This description assumes
73135 that headers will be in /usr/local/include, and that the libraries
73136 are in /usr/local/lib.
73137 </para>
73138 <para revisionflag="changed">
73139 There are three main-configuration options:
73140 <indexterm role="concept">
73141 <primary>DMARC</primary>
73142 <secondary>configuration options</secondary>
73143 </indexterm>
73144 </para>
73145 <para revisionflag="changed">
73146 The <option>dmarc_tld_file</option> option
73147 <indexterm role="option">
73148 <primary><option>dmarc_tld_file</option></primary>
73149 </indexterm>
73150 defines the location of a text file of valid
73151 top level domains the opendmarc library uses
73152 during domain parsing. Maintained by Mozilla,
73153 the most current version can be downloaded
73154 from a link at <emphasis role="bold"><ulink url="https://publicsuffix.org/list/">currently pointing
73155 at https://publicsuffix.org/list/public_suffix_list.dat</ulink></emphasis>
73156 See also util/renew-opendmarc-tlds.sh script.
73157 The default for the option is /etc/exim/opendmarc.tlds.
73158 </para>
73159 <para revisionflag="changed">
73160 The <option>dmarc_history_file</option> option, if set
73161 <indexterm role="option">
73162 <primary><option>dmarc_history_file</option></primary>
73163 </indexterm>
73164 defines the location of a file to log results
73165 of dmarc verification on inbound emails. The
73166 contents are importable by the opendmarc tools
73167 which will manage the data, send out DMARC
73168 reports, and expire the data. Make sure the
73169 directory of this file is writable by the user
73170 exim runs as.
73171 The default is unset.
73172 </para>
73173 <para revisionflag="changed">
73174 The <option>dmarc_forensic_sender</option> option
73175 <indexterm role="option">
73176 <primary><option>dmarc_forensic_sender</option></primary>
73177 </indexterm>
73178 defines an alternate email address to use when sending a
73179 forensic report detailing alignment failures
73180 if a sender domain&#x2019;s dmarc record specifies it
73181 and you have configured Exim to send them.
73182 If set, this is expanded and used for the
73183 From: header line; the address is extracted
73184 from it and used for the envelope from.
73185 If not set (the default), the From: header is expanded from
73186 the dsn_from option, and &lt;&gt; is used for the
73187 envelope from.
73188 </para>
73189 <para revisionflag="changed">
73190 <indexterm role="concept">
73191 <primary>DMARC</primary>
73192 <secondary>controls</secondary>
73193 </indexterm>
73194 By default, the DMARC processing will run for any remote,
73195 non-authenticated user.  It makes sense to only verify DMARC
73196 status of messages coming from remote, untrusted sources.  You can
73197 use standard conditions such as hosts, senders, etc, to decide that
73198 DMARC verification should *not* be performed for them and disable
73199 DMARC with an ACL control modifier:
73200 </para>
73201 <literallayout class="monospaced" revisionflag="changed">
73202   control = dmarc_disable_verify
73203 </literallayout>
73204 <para revisionflag="changed">
73205 A DMARC record can also specify a "forensic address", which gives
73206 exim an email address to submit reports about failed alignment.
73207 Exim does not do this by default because in certain conditions it
73208 results in unintended information leakage (what lists a user might
73209 be subscribed to, etc).  You must configure exim to submit forensic
73210 reports to the owner of the domain.  If the DMARC record contains a
73211 forensic address and you specify the control statement below, then
73212 exim will send these forensic emails.  It is also advised that you
73213 configure a <option>dmarc_forensic_sender</option> because the default sender address
73214 construction might be inadequate.
73215 </para>
73216 <literallayout class="monospaced" revisionflag="changed">
73217   control = dmarc_enable_forensic
73218 </literallayout>
73219 <para revisionflag="changed">
73220 (AGAIN: You can choose not to send these forensic reports by simply
73221 not putting the dmarc_enable_forensic control line at any point in
73222 your exim config.  If you don&#x2019;t tell exim to send them, it will not
73223 send them.)
73224 </para>
73225 <para revisionflag="changed">
73226 There are no options to either control.  Both must appear before
73227 the DATA acl.
73228 </para>
73229 <para revisionflag="changed">
73230 DMARC checks cam be run on incoming SMTP  messages by using the
73231 <quote>dmarc_status</quote> ACL condition in the DATA ACL.  You are required to
73232 call the <quote>spf</quote> condition first in the ACLs, then the <quote>dmarc_status</quote>
73233 condition.  Putting this condition in the ACLs is required in order
73234 for a DMARC check to actually occur.  All of the variables are set
73235 up before the DATA ACL, but there is no actual DMARC check that
73236 occurs until a <quote>dmarc_status</quote> condition is encountered in the ACLs.
73237 </para>
73238 <para revisionflag="changed">
73239 The <quote>dmarc_status</quote> condition takes a list of strings on its
73240 right-hand side.  These strings describe recommended action based
73241 on the DMARC check.  To understand what the policy recommendations
73242 mean, refer to the DMARC website above.  Valid strings are:
73243 </para>
73244 <literallayout revisionflag="changed">
73245 <emphasis>accept      </emphasis> The DMARC check passed and the library recommends accepting the email.
73246 <emphasis>reject      </emphasis> The DMARC check failed and the library recommends rejecting the email.
73247 <emphasis>quarantine  </emphasis> The DMARC check failed and the library recommends keeping it for further inspection.
73248 <emphasis>none        </emphasis> The DMARC check passed and the library recommends no specific action, neutral.
73249 <emphasis>norecord    </emphasis> No policy section in the DMARC record for this sender domain.
73250 <emphasis>nofrom      </emphasis> Unable to determine the domain of the sender.
73251 <emphasis>temperror   </emphasis> Library error or dns error.
73252 <emphasis>off         </emphasis> The DMARC check was disabled for this email.
73253 </literallayout>
73254 <para revisionflag="changed">
73255 You can prefix each string with an exclamation mark to invert its
73256 meaning, for example "!accept" will match all results but
73257 "accept".  The string list is evaluated left-to-right in a
73258 short-circuit fashion.  When a string matches the outcome of the
73259 DMARC check, the condition succeeds.  If none of the listed
73260 strings matches the outcome of the DMARC check, the condition
73261 fails.
73262 </para>
73263 <para revisionflag="changed">
73264 Of course, you can also use any other lookup method that Exim
73265 supports, including LDAP, Postgres, MySQL, etc, as long as the
73266 result is a list of colon-separated strings.
73267 </para>
73268 <para revisionflag="changed">
73269 Performing the check sets up information used by the
73270 <option>authresults</option> expansion item.
73271 </para>
73272 <para revisionflag="changed">
73273 Several expansion variables are set before the DATA ACL is
73274 processed, and you can use them in this ACL.  The following
73275 expansion variables are available:
73276 </para>
73277 <variablelist revisionflag="changed">
73278 <varlistentry revisionflag="changed">
73279 <term><varname>$dmarc_status</varname></term>
73280 <listitem>
73281 <para revisionflag="changed">
73282 <indexterm role="variable">
73283 <primary><varname>$dmarc_status</varname></primary>
73284 </indexterm>
73285 <indexterm role="concept">
73286 <primary>DMARC</primary>
73287 <secondary>result</secondary>
73288 </indexterm>
73289 A one word status indicating what the DMARC library
73290 thinks of the email.  It is a combination of the results of
73291 DMARC record lookup and the SPF/DKIM/DMARC processing results
73292 (if a DMARC record was found).  The actual policy declared
73293 in the DMARC record is in a separate expansion variable.
73294 </para>
73295 </listitem></varlistentry>
73296 <varlistentry revisionflag="changed">
73297 <term><varname>$dmarc_status_text</varname></term>
73298 <listitem>
73299 <para revisionflag="changed">
73300 <indexterm role="variable">
73301 <primary><varname>$dmarc_status_text</varname></primary>
73302 </indexterm>
73303 Slightly longer, human readable status.
73304 </para>
73305 </listitem></varlistentry>
73306 <varlistentry revisionflag="changed">
73307 <term><varname>$dmarc_used_domain</varname></term>
73308 <listitem>
73309 <para revisionflag="changed">
73310 <indexterm role="variable">
73311 <primary><varname>$dmarc_used_domain</varname></primary>
73312 </indexterm>
73313 The domain which DMARC used to look up the DMARC policy record.
73314 </para>
73315 </listitem></varlistentry>
73316 <varlistentry revisionflag="changed">
73317 <term><varname>$dmarc_domain_policy</varname></term>
73318 <listitem>
73319 <para revisionflag="changed">
73320 <indexterm role="variable">
73321 <primary><varname>$dmarc_domain_policy</varname></primary>
73322 </indexterm>
73323 The policy declared in the DMARC record.  Valid values
73324 are "none", "reject" and "quarantine".  It is blank when there
73325 is any error, including no DMARC record.
73326 </para>
73327 </listitem></varlistentry>
73328 </variablelist>
73329 <para revisionflag="changed">
73330 By default, Exim&#x2019;s DMARC configuration is intended to be
73331 non-intrusive and conservative.  To facilitate this, Exim will not
73332 create any type of logging files without explicit configuration by
73333 you, the admin.  Nor will Exim send out any emails/reports about
73334 DMARC issues without explicit configuration by you, the admin (other
73335 than typical bounce messages that may come about due to ACL
73336 processing or failure delivery issues).
73337 </para>
73338 <para revisionflag="changed">
73339 In order to log statistics suitable to be imported by the opendmarc
73340 tools, you need to:
73341 </para>
73342 <itemizedlist revisionflag="changed">
73343 <listitem>
73344 <para revisionflag="changed">
73345 Configure the global option <option>dmarc_history_file</option>
73346 </para>
73347 </listitem>
73348 <listitem>
73349 <para revisionflag="changed">
73350 Configure cron jobs to call the appropriate opendmarc history
73351 import scripts and truncating the dmarc_history_file
73352 </para>
73353 </listitem>
73354 </itemizedlist>
73355 <para revisionflag="changed">
73356 In order to send forensic reports, you need to:
73357 </para>
73358 <itemizedlist revisionflag="changed">
73359 <listitem>
73360 <para revisionflag="changed">
73361 Configure the global option <option>dmarc_forensic_sender</option>
73362 </para>
73363 </listitem>
73364 <listitem>
73365 <para revisionflag="changed">
73366 Configure, somewhere before the DATA ACL, the control option to
73367 enable sending DMARC forensic reports
73368 </para>
73369 </listitem>
73370 </itemizedlist>
73371 <para revisionflag="changed">
73372 Example usage:
73373 </para>
73374 <literallayout class="monospaced" revisionflag="changed">
73375 (RCPT ACL)
73376   warn    domains        = +local_domains
73377           hosts          = +local_hosts
73378           control        = dmarc_disable_verify
73379
73380   warn    !domains       = +screwed_up_dmarc_records
73381           control        = dmarc_enable_forensic
73382
73383   warn    condition      = (lookup if destined to mailing list)
73384           set acl_m_mailing_list = 1
73385
73386 (DATA ACL)
73387   warn    dmarc_status   = accept : none : off
73388           !authenticated = *
73389           log_message    = DMARC DEBUG: $dmarc_status $dmarc_used_domain
73390
73391   warn    dmarc_status   = !accept
73392           !authenticated = *
73393           log_message    = DMARC DEBUG: '$dmarc_status' for $dmarc_used_domain
73394
73395   warn    dmarc_status   = quarantine
73396           !authenticated = *
73397           set $acl_m_quarantine = 1
73398           # Do something in a transport with this flag variable
73399
73400   deny    condition      = ${if eq{$dmarc_domain_policy}{reject}}
73401           condition      = ${if eq{$acl_m_mailing_list}{1}}
73402           message        = Messages from $dmarc_used_domain break mailing lists
73403
73404   deny    dmarc_status   = reject
73405           !authenticated = *
73406           message        = Message from $dmarc_used_domain failed sender's DMARC policy, REJECT
73407
73408   warn    add_header     = :at_start:${authresults {$primary_hostname}}
73409 </literallayout>
73410 </section>
73411 </chapter>
73412
73413 <chapter id="CHAPproxies">
73414 <title>Proxies</title>
73415 <titleabbrev>Proxy support</titleabbrev>
73416 <para>
73417 <indexterm role="concept">
73418 <primary>proxy support</primary>
73419 </indexterm>
73420 <indexterm role="concept">
73421 <primary>proxy</primary>
73422 <secondary>access via</secondary>
73423 </indexterm>
73424 </para>
73425 <para>
73426 A proxy is an intermediate system through which communication is passed.
73427 Proxies may provide a security, availability or load-distribution function.
73428 </para>
73429 <section id="SECTproxyInbound">
73430 <title>Inbound proxies</title>
73431 <para>
73432 <indexterm role="concept">
73433 <primary>proxy</primary>
73434 <secondary>inbound</secondary>
73435 </indexterm>
73436 <indexterm role="concept">
73437 <primary>proxy</primary>
73438 <secondary>server side</secondary>
73439 </indexterm>
73440 <indexterm role="concept">
73441 <primary>proxy</primary>
73442 <secondary>Proxy protocol</secondary>
73443 </indexterm>
73444 <indexterm role="concept">
73445 <primary>Proxy protocol</primary>
73446 <secondary>proxy</secondary>
73447 </indexterm>
73448 </para>
73449 <para>
73450 Exim has support for receiving inbound SMTP connections via a proxy
73451 that uses <quote>Proxy Protocol</quote> to speak to it.
73452 To include this support, include <quote>SUPPORT_PROXY=yes</quote>
73453 in Local/Makefile.
73454 </para>
73455 <para>
73456 It was built on the HAProxy specification, found at
73457 <emphasis role="bold"><ulink url="https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt">https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt</ulink></emphasis>.
73458 </para>
73459 <para>
73460 The purpose of this facility is so that an application load balancer,
73461 such as HAProxy, can sit in front of several Exim servers
73462 to distribute load.
73463 Exim uses the local protocol communication with the proxy to obtain
73464 the remote SMTP system IP address and port information.
73465 There is no logging if a host passes or
73466 fails Proxy Protocol negotiation, but it can easily be determined and
73467 recorded in an ACL (example is below).
73468 </para>
73469 <para>
73470 Use of a proxy is enabled by setting the <option>hosts_proxy</option>
73471 main configuration option to a hostlist; connections from these
73472 hosts will use Proxy Protocol.
73473 Exim supports both version 1 and version 2 of the Proxy Protocol and
73474 automatically determines which version is in use.
73475 </para>
73476 <para>
73477 The Proxy Protocol header is the first data received on a TCP connection
73478 and is inserted before any TLS-on-connect handshake from the client; Exim
73479 negotiates TLS between Exim-as-server and the remote client, not between
73480 Exim and the proxy server.
73481 </para>
73482 <para>
73483 The following expansion variables are usable
73484 (<quote>internal</quote> and <quote>external</quote> here refer to the interfaces
73485 of the proxy):
73486 </para>
73487 <literallayout>
73488 <emphasis>proxy_external_address   </emphasis> IP of host being proxied or IP of remote interface of proxy
73489 <emphasis>proxy_external_port      </emphasis> Port of host being proxied or Port on remote interface of proxy
73490 <emphasis>proxy_local_address      </emphasis> IP of proxy server inbound or IP of local interface of proxy
73491 <emphasis>proxy_local_port         </emphasis> Port of proxy server inbound or Port on local interface of proxy
73492 <emphasis>proxy_session            </emphasis> boolean: SMTP connection via proxy
73493 </literallayout>
73494 <para>
73495 If <varname>$proxy_session</varname> is set but <varname>$proxy_external_address</varname> is empty
73496 there was a protocol error.
73497 The variables <varname>$sender_host_address</varname> and <varname>$sender_host_port</varname>
73498 will have values for the actual client system, not the proxy.
73499 </para>
73500 <para>
73501 Since the real connections are all coming from the proxy, and the
73502 per host connection tracking is done before Proxy Protocol is
73503 evaluated, <option>smtp_accept_max_per_host</option> must be set high enough to
73504 handle all of the parallel volume you expect per inbound proxy.
73505 With the option set so high, you lose the ability
73506 to protect your server from many connections from one IP.
73507 In order to prevent your server from overload, you
73508 need to add a per connection ratelimit to your connect ACL.
73509 A possible solution is:
73510 </para>
73511 <literallayout>
73512   # Set max number of connections per host
73513   LIMIT   = 5
73514   # Or do some kind of IP lookup in a flat file or database
73515   # LIMIT = ${lookup{$sender_host_address}iplsearch{/etc/exim/proxy_limits}}
73516
73517   defer   message        = Too many connections from this IP right now
73518           ratelimit      = LIMIT / 5s / per_conn / strict
73519 </literallayout>
73520 </section>
73521 <section id="SECTproxySOCKS">
73522 <title>Outbound proxies</title>
73523 <para>
73524 <indexterm role="concept">
73525 <primary>proxy</primary>
73526 <secondary>outbound</secondary>
73527 </indexterm>
73528 <indexterm role="concept">
73529 <primary>proxy</primary>
73530 <secondary>client side</secondary>
73531 </indexterm>
73532 <indexterm role="concept">
73533 <primary>proxy</primary>
73534 <secondary>SOCKS</secondary>
73535 </indexterm>
73536 <indexterm role="concept">
73537 <primary>SOCKS</primary>
73538 <secondary>proxy</secondary>
73539 </indexterm>
73540 Exim has support for sending outbound SMTP via a proxy
73541 using a protocol called SOCKS5 (defined by RFC1928).
73542 The support can be optionally included by defining SUPPORT_SOCKS=yes in
73543 Local/Makefile.
73544 </para>
73545 <para>
73546 Use of a proxy is enabled by setting the <option>socks_proxy</option> option
73547 on an smtp transport.
73548 The option value is expanded and should then be a list
73549 (colon-separated by default) of proxy specifiers.
73550 Each proxy specifier is a list
73551 (space-separated by default) where the initial element
73552 is an IP address and any subsequent elements are options.
73553 </para>
73554 <para>
73555 Options are a string &lt;name&gt;=&lt;value&gt;.
73556 The list of options is in the following table:
73557 </para>
73558 <literallayout>
73559 <emphasis>auth   </emphasis> authentication method
73560 <emphasis>name   </emphasis> authentication username
73561 <emphasis>pass   </emphasis> authentication password
73562 <emphasis>port   </emphasis> tcp port
73563 <emphasis>tmo    </emphasis> connection timeout
73564 <emphasis>pri    </emphasis> priority
73565 <emphasis>weight </emphasis> selection bias
73566 </literallayout>
73567 <para>
73568 More details on each of these options follows:
73569 </para>
73570 <itemizedlist>
73571 <listitem>
73572 <para>
73573 <indexterm role="concept">
73574 <primary>authentication</primary>
73575 <secondary>to proxy</secondary>
73576 </indexterm>
73577 <indexterm role="concept">
73578 <primary>proxy</primary>
73579 <secondary>authentication</secondary>
73580 </indexterm>
73581 <option>auth</option>: Either <quote>none</quote> (default) or <quote>name</quote>.
73582 Using <quote>name</quote> selects username/password authentication per RFC 1929
73583 for access to the proxy.
73584 Default is <quote>none</quote>.
73585 </para>
73586 </listitem>
73587 <listitem>
73588 <para>
73589 <option>name</option>: sets the username for the <quote>name</quote> authentication method.
73590 Default is empty.
73591 </para>
73592 </listitem>
73593 <listitem>
73594 <para>
73595 <option>pass</option>: sets the password for the <quote>name</quote> authentication method.
73596 Default is empty.
73597 </para>
73598 </listitem>
73599 <listitem>
73600 <para>
73601 <option>port</option>: the TCP port number to use for the connection to the proxy.
73602 Default is 1080.
73603 </para>
73604 </listitem>
73605 <listitem>
73606 <para>
73607 <option>tmo</option>: sets a connection timeout in seconds for this proxy.
73608 Default is 5.
73609 </para>
73610 </listitem>
73611 <listitem>
73612 <para>
73613 <option>pri</option>: specifies a priority for the proxy within the list,
73614 higher values being tried first.
73615 The default priority is 1.
73616 </para>
73617 </listitem>
73618 <listitem>
73619 <para>
73620 <option>weight</option>: specifies a selection bias.
73621 Within a priority set servers are queried in a random fashion,
73622 weighted by this value.
73623 The default value for selection bias is 1.
73624 </para>
73625 </listitem>
73626 </itemizedlist>
73627 <para>
73628 Proxies from the list are tried according to their priority
73629 and weight settings until one responds.  The timeout for the
73630 overall connection applies to the set of proxied attempts.
73631 </para>
73632 </section>
73633 <section id="SECTproxyLog">
73634 <title>Logging</title>
73635 <para>
73636 To log the (local) IP of a proxy in the incoming or delivery logline,
73637 add <quote>+proxy</quote> to the <option>log_selector</option> option.
73638 This will add a component tagged with <quote>PRX=</quote> to the line.
73639 </para>
73640 </section>
73641 </chapter>
73642
73643 <chapter id="CHAPi18n">
73644 <title>Internationalisation</title>
73645 <titleabbrev>Internationalisation"</titleabbrev>
73646 <para>
73647 <indexterm role="concept">
73648 <primary>internationalisation</primary>
73649 <secondary>email address</secondary>
73650 </indexterm>
73651 <indexterm role="concept">
73652 <primary>EAI</primary>
73653 </indexterm>
73654 <indexterm role="concept">
73655 <primary>i18n</primary>
73656 </indexterm>
73657 <indexterm role="concept">
73658 <primary>utf8</primary>
73659 <secondary>mail name handling</secondary>
73660 </indexterm>
73661 </para>
73662 <para>
73663 Exim has support for Internationalised mail names.
73664 To include this it must be built with SUPPORT_I18N and the libidn library.
73665 Standards supported are RFCs 2060, 5890, 6530 and 6533.
73666 </para>
73667 <para>
73668 If Exim is built with SUPPORT_I18N_2008 (in addition to SUPPORT_I18N, not
73669 instead of it) then IDNA2008 is supported; this adds an extra library
73670 requirement, upon libidn2.
73671 </para>
73672 <section id="SECTi18nMTA">
73673 <title>MTA operations</title>
73674 <para>
73675 <indexterm role="concept">
73676 <primary>SMTPUTF8</primary>
73677 <secondary>ESMTP option</secondary>
73678 </indexterm>
73679 The main configuration option <option>smtputf8_advertise_hosts</option> specifies
73680 a host list.  If this matches the sending host and
73681 accept_8bitmime is true (the default) then the ESMTP option
73682 SMTPUTF8 will be advertised.
73683 </para>
73684 <para>
73685 If the sender specifies the SMTPUTF8 option on a MAIL command
73686 international handling for the message is enabled and
73687 the expansion variable <varname>$message_smtputf8</varname> will have value TRUE.
73688 </para>
73689 <para>
73690 The option <option>allow_utf8_domains</option> is set to true for this
73691 message. All DNS lookups are converted to a-label form
73692 whatever the setting of <option>allow_utf8_domains</option>
73693 when Exim is built with SUPPORT_I18N.
73694 </para>
73695 <para>
73696 Both localparts and domain are maintained as the original
73697 UTF-8 form internally; any comparison or regular-expression use will
73698 require appropriate care.  Filenames created, eg. by
73699 the appendfile transport, will have UTF-8 names.
73700 </para>
73701 <para>
73702 HELO names sent by the smtp transport will have any UTF-8
73703 components expanded to a-label form,
73704 and any certificate name checks will be done using the a-label
73705 form of the name.
73706 </para>
73707 <para>
73708 <indexterm role="concept">
73709 <primary>log</primary>
73710 <secondary>protocol</secondary>
73711 </indexterm>
73712 <indexterm role="concept">
73713 <primary>SMTPUTF8</primary>
73714 <secondary>logging</secondary>
73715 </indexterm>
73716 <indexterm role="concept">
73717 <primary>i18n</primary>
73718 <secondary>logging</secondary>
73719 </indexterm>
73720 Log lines and Received-by: header lines will acquire a "utf8"
73721 prefix on the protocol element, eg. utf8esmtp.
73722 </para>
73723 <para>
73724 The following expansion operators can be used:
73725 </para>
73726 <literallayout class="monospaced">
73727 ${utf8_domain_to_alabel:str}
73728 ${utf8_domain_from_alabel:str}
73729 ${utf8_localpart_to_alabel:str}
73730 ${utf8_localpart_from_alabel:str}
73731 </literallayout>
73732 <para>
73733 <indexterm role="concept">
73734 <primary>utf8</primary>
73735 <secondary>address downconversion</secondary>
73736 </indexterm>
73737 <indexterm role="concept">
73738 <primary>i18n</primary>
73739 <secondary>utf8 address downconversion</secondary>
73740 </indexterm>
73741 The RCPT ACL
73742 may use the following modifier:
73743 </para>
73744 <literallayout>
73745 control = utf8_downconvert
73746 control = utf8_downconvert/&lt;value&gt;
73747 </literallayout>
73748 <para>
73749 This sets a flag requiring that addresses are converted to
73750 a-label form before smtp delivery, for use in a
73751 Message Submission Agent context.
73752 If a value is appended it may be:
73753 </para>
73754 <literallayout>
73755 <literal>1  </literal> (default) mandatory downconversion
73756 <literal>0  </literal> no downconversion
73757 <literal>-1 </literal> if SMTPUTF8 not supported by destination host
73758 </literallayout>
73759 <para>
73760 If mua_wrapper is set, the utf8_downconvert control
73761 is initially set to -1.
73762 </para>
73763 <para>
73764 The smtp transport has an option <option>utf8_downconvert</option>.
73765 If set it must expand to one of the three values described above,
73766 and it overrides any previously set value.
73767 </para>
73768 <para>
73769 There is no explicit support for VRFY and EXPN.
73770 Configurations supporting these should inspect
73771 <varname>$smtp_command_argument</varname> for an SMTPUTF8 argument.
73772 </para>
73773 <para>
73774 There is no support for LMTP on Unix sockets.
73775 Using the "lmtp" protocol option on an smtp transport,
73776 for LMTP over TCP, should work as expected.
73777 </para>
73778 <para>
73779 There is no support for DSN unitext handling,
73780 and no provision for converting logging from or to UTF-8.
73781 </para>
73782 </section>
73783 <section id="SECTi18nMDA">
73784 <title>MDA operations</title>
73785 <para>
73786 To aid in constructing names suitable for IMAP folders
73787 the following expansion operator can be used:
73788 </para>
73789 <literallayout class="monospaced">
73790 ${imapfolder {&lt;string&gt;} {&lt;sep&gt;} {&lt;specials&gt;}}
73791 </literallayout>
73792 <para>
73793 The string is converted from the charset specified by
73794 the "headers charset" command (in a filter file)
73795 or <option>headers_charset</option> main configuration option (otherwise),
73796 to the
73797 modified UTF-7 encoding specified by RFC 2060,
73798 with the following exception: All occurrences of &lt;sep&gt;
73799 (which has to be a single character)
73800 are replaced with periods ("."), and all periods and slashes that are not
73801 &lt;sep&gt; and are not in the &lt;specials&gt; string are BASE64 encoded.
73802 </para>
73803 <para>
73804 The third argument can be omitted, defaulting to an empty string.
73805 The second argument can be omitted, defaulting to "/".
73806 </para>
73807 <para>
73808 This is the encoding used by Courier for Maildir names on disk, and followed
73809 by many other IMAP servers.
73810 </para>
73811 <para>
73812 Examples:
73813 </para>
73814 <literallayout>
73815 <literal>${imapfolder {Foo/Bar}}       </literal> yields <literal>Foo.Bar</literal>
73816 <literal>${imapfolder {Foo/Bar}{.}{/}} </literal> yields <literal>Foo&amp;AC8-Bar</literal>
73817 <literal>${imapfolder {Räksmörgås}}    </literal> yields <literal>R&amp;AOQ-ksm&amp;APY-rg&amp;AOU-s</literal>
73818 </literallayout>
73819 <para>
73820 Note that the source charset setting is vital, and also that characters
73821 must be representable in UTF-16.
73822 </para>
73823 </section>
73824 </chapter>
73825
73826 <chapter id="CHAPevents">
73827 <title>Events</title>
73828 <titleabbrev>Events</titleabbrev>
73829 <para>
73830 <indexterm role="concept">
73831 <primary>events</primary>
73832 </indexterm>
73833 </para>
73834 <para>
73835 The events mechanism in Exim can be used to intercept processing at a number
73836 of points.  It was originally invented to give a way to do customised logging
73837 actions (for example, to a database) but can also be used to modify some
73838 processing actions.
73839 </para>
73840 <para>
73841 Most installations will never need to use Events.
73842 The support can be left out of a build by defining DISABLE_EVENT=yes
73843 in <filename>Local/Makefile</filename>.
73844 </para>
73845 <para>
73846 There are two major classes of events: main and transport.
73847 The main configuration option <option>event_action</option> controls reception events;
73848 a transport option <option>event_action</option> controls delivery events.
73849 </para>
73850 <para>
73851 Both options are a string which is expanded when the event fires.
73852 An example might look like:
73853 <indexterm role="concept">
73854 <primary>logging</primary>
73855 <secondary>custom</secondary>
73856 </indexterm>
73857 </para>
73858 <literallayout class="monospaced">
73859 event_action = ${if eq {msg:delivery}{$event_name} \
73860 {${lookup pgsql {SELECT * FROM record_Delivery( \
73861     '${quote_pgsql:$sender_address_domain}',\
73862     '${quote_pgsql:${lc:$sender_address_local_part}}', \
73863     '${quote_pgsql:$domain}', \
73864     '${quote_pgsql:${lc:$local_part}}', \
73865     '${quote_pgsql:$host_address}', \
73866     '${quote_pgsql:${lc:$host}}', \
73867     '${quote_pgsql:$message_exim_id}')}} \
73868 } {}}
73869 </literallayout>
73870 <para>
73871 Events have names which correspond to the point in process at which they fire.
73872 The name is placed in the variable <varname>$event_name</varname> and the event action
73873 expansion must check this, as it will be called for every possible event type.
73874 </para>
73875 <para revisionflag="changed">
73876 The current list of events is:
73877 </para>
73878 <literallayout>
73879 <literal>dane:fail              after    transport  </literal> per connection
73880 <literal>msg:complete           after    main       </literal> per message
73881 <literal>msg:delivery           after    transport  </literal> per recipient
73882 <literal>msg:rcpt:host:defer    after    transport  </literal> per recipient per host
73883 <literal>msg:rcpt:defer         after    transport  </literal> per recipient
73884 <literal>msg:host:defer         after    transport  </literal> per attempt
73885 <literal>msg:fail:delivery      after    transport  </literal> per recipient
73886 <literal>msg:fail:internal      after    main       </literal> per recipient
73887 <literal>tcp:connect            before   transport  </literal> per connection
73888 <literal>tcp:close              after    transport  </literal> per connection
73889 <literal>tls:cert               before   both       </literal> per certificate in verification chain
73890 <literal>smtp:connect           after    transport  </literal> per connection
73891 <literal>smtp:ehlo              after    transport  </literal> per connection
73892 </literallayout>
73893 <para>
73894 New event types may be added in future.
73895 </para>
73896 <para>
73897 The event name is a colon-separated list, defining the type of
73898 event in a tree of possibilities.  It may be used as a list
73899 or just matched on as a whole.  There will be no spaces in the name.
73900 </para>
73901 <para>
73902 The second column in the table above describes whether the event fires
73903 before or after the action is associates with.  Those which fire before
73904 can be used to affect that action (more on this below).
73905 </para>
73906 <para>
73907 The third column in the table above says what section of the configuration
73908 should define the event action.
73909 </para>
73910 <para>
73911 An additional variable, <varname>$event_data</varname>, is filled with information varying
73912 with the event type:
73913 </para>
73914 <literallayout>
73915 <literal>dane:fail            </literal> failure reason
73916 <literal>msg:delivery         </literal> smtp confirmation message
73917 <literal>msg:fail:internal    </literal> failure reason
73918 <literal>msg:fail:delivery    </literal> smtp error message
73919 <literal>msg:rcpt:host:defer  </literal> error string
73920 <literal>msg:rcpt:defer       </literal> error string
73921 <literal>msg:host:defer       </literal> error string
73922 <literal>tls:cert             </literal> verification chain depth
73923 <literal>smtp:connect         </literal> smtp banner
73924 <literal>smtp:ehlo            </literal> smtp ehlo response
73925 </literallayout>
73926 <para>
73927 The :defer events populate one extra variable: <varname>$event_defer_errno</varname>.
73928 </para>
73929 <para>
73930 For complex operations an ACL expansion can be used in <option>event_action</option>
73931 however due to the multiple contexts that Exim operates in during
73932 the course of its processing:
73933 </para>
73934 <itemizedlist>
73935 <listitem>
73936 <para>
73937 variables set in transport events will not be visible outside that
73938 transport call
73939 </para>
73940 </listitem>
73941 <listitem>
73942 <para>
73943 acl_m variables in a server context are lost on a new connection,
73944 and after smtp helo/ehlo/mail/starttls/rset commands
73945 </para>
73946 </listitem>
73947 </itemizedlist>
73948 <para>
73949 Using an ACL expansion with the logwrite modifier can be
73950 a useful way of writing to the main log.
73951 </para>
73952 <para>
73953 The expansion of the event_action option should normally
73954 return an empty string.  Should it return anything else the
73955 following will be forced:
73956 </para>
73957 <literallayout>
73958 <literal>tcp:connect      </literal>  do not connect
73959 <literal>tls:cert         </literal>  refuse verification
73960 <literal>smtp:connect     </literal>  close connection
73961 </literallayout>
73962 <para>
73963 All other message types ignore the result string, and
73964 no other use is made of it.
73965 </para>
73966 <para>
73967 For a tcp:connect event, if the connection is being made to a proxy
73968 then the address and port variables will be that of the proxy and not
73969 the target system.
73970 </para>
73971 <para>
73972 For tls:cert events, if GnuTLS is in use this will trigger only per
73973 chain element received on the connection.
73974 For OpenSSL it will trigger for every chain element including those
73975 loaded locally.
73976 </para>
73977 </chapter>
73978
73979 <chapter id="CHID13">
73980 <title>Adding new drivers or lookup types</title>
73981 <titleabbrev>Adding drivers or lookups</titleabbrev>
73982 <para>
73983 <indexterm role="concept">
73984 <primary>adding drivers</primary>
73985 </indexterm>
73986 <indexterm role="concept">
73987 <primary>new drivers, adding</primary>
73988 </indexterm>
73989 <indexterm role="concept">
73990 <primary>drivers</primary>
73991 <secondary>adding new</secondary>
73992 </indexterm>
73993 The following actions have to be taken in order to add a new router, transport,
73994 authenticator, or lookup type to Exim:
73995 </para>
73996 <orderedlist numeration="arabic">
73997 <listitem>
73998 <para>
73999 Choose a name for the driver or lookup type that does not conflict with any
74000 existing name; I will use <quote>newdriver</quote> in what follows.
74001 </para>
74002 </listitem>
74003 <listitem>
74004 <para>
74005 Add to <filename>src/EDITME</filename> the line:
74006 </para>
74007 <literallayout>
74008 &lt;<emphasis>type</emphasis>&gt;<literal>_NEWDRIVER=yes</literal>
74009 </literallayout>
74010 <para>
74011 where &lt;<emphasis>type</emphasis>&gt; is ROUTER, TRANSPORT, AUTH, or LOOKUP. If the
74012 code is not to be included in the binary by default, comment this line out. You
74013 should also add any relevant comments about the driver or lookup type.
74014 </para>
74015 </listitem>
74016 <listitem>
74017 <para>
74018 Add to <filename>src/config.h.defaults</filename> the line:
74019 </para>
74020 <literallayout class="monospaced">
74021 #define &lt;type&gt;_NEWDRIVER
74022 </literallayout>
74023 </listitem>
74024 <listitem>
74025 <para>
74026 Edit <filename>src/drtables.c</filename>, adding conditional code to pull in the private header
74027 and create a table entry as is done for all the other drivers and lookup types.
74028 </para>
74029 </listitem>
74030 <listitem>
74031 <para>
74032 Edit <filename>scripts/lookups-Makefile</filename> if this is a new lookup; there is a for-loop
74033 near the bottom, ranging the <literal>name_mod</literal> variable over a list of all lookups.
74034 Add your <literal>NEWDRIVER</literal> to that list.
74035 As long as the dynamic module would be named <filename>newdriver.so</filename>, you can use the
74036 simple form that most lookups have.
74037 </para>
74038 </listitem>
74039 <listitem>
74040 <para>
74041 Edit <filename>Makefile</filename> in the appropriate sub-directory (<filename>src/routers</filename>,
74042 <filename>src/transports</filename>, <filename>src/auths</filename>, or <filename>src/lookups</filename>); add a line for the new
74043 driver or lookup type and add it to the definition of OBJ.
74044 </para>
74045 </listitem>
74046 <listitem>
74047 <para>
74048 Edit <filename>OS/Makefile-Base</filename> adding a <filename>.o</filename> file for the predefined-macros, to the
74049 definition of OBJ_MACRO.  Add a set of line to do the compile also.
74050 </para>
74051 </listitem>
74052 <listitem>
74053 <para>
74054 Create <filename>newdriver.h</filename> and <filename>newdriver.c</filename> in the appropriate sub-directory of
74055 <filename>src</filename>.
74056 </para>
74057 </listitem>
74058 <listitem>
74059 <para>
74060 Edit <filename>scripts/MakeLinks</filename> and add commands to link the <filename>.h</filename> and <filename>.c</filename> files
74061 as for other drivers and lookups.
74062 </para>
74063 </listitem>
74064 </orderedlist>
74065 <para>
74066 Then all you need to do is write the code! A good way to start is to make a
74067 proforma by copying an existing module of the same type, globally changing all
74068 occurrences of the name, and cutting out most of the code. Note that any
74069 options you create must be listed in alphabetical order, because the tables are
74070 searched using a binary chop procedure.
74071 </para>
74072 <para>
74073 There is a <filename>README</filename> file in each of the sub-directories of <filename>src</filename> describing
74074 the interface that is expected.
74075 </para>
74076 <?sdop
74077   format="newpage"
74078   foot_right_recto="&chaptertitle;"
74079   foot_right_verso="&chaptertitle;"
74080 ?>
74081 </chapter>
74082
74083 <index role="option">
74084 <title>Options index</title>
74085 </index>
74086
74087 <index role="variable">
74088 <title>Variables index</title>
74089 </index>
74090
74091 <index role="concept">
74092 <title>Concept index</title>
74093 </index>
74094
74095 </book>